diff --git a/package-lock.json b/package-lock.json index 65c8826d..2a820601 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ngx-mask", - "version": "7.6.5", + "version": "7.7.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -3781,7 +3781,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -3799,11 +3800,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3816,15 +3819,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -3927,7 +3933,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -3937,6 +3944,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3949,17 +3957,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3976,6 +3987,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -4048,7 +4060,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -4058,6 +4071,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -4133,7 +4147,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -4163,6 +4178,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4180,6 +4196,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4218,11 +4235,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.0.3", - "bundled": true + "bundled": true, + "optional": true } } }, diff --git a/src/app/ngx-mask/mask.directive.ts b/src/app/ngx-mask/mask.directive.ts index d762c1c3..d504b1c6 100644 --- a/src/app/ngx-mask/mask.directive.ts +++ b/src/app/ngx-mask/mask.directive.ts @@ -229,7 +229,8 @@ export class MaskDirective implements ControlValueAccessor { // return; // } this._maskService.maskIsShown = this._maskService.showMaskInInput(); - if (el.setSelectionRange) { + if (el.setSelectionRange && + this._maskService.prefix + this._maskService.maskIsShown === el.value) { el.focus(); el.setSelectionRange(posStart, posEnd); } @@ -255,9 +256,6 @@ export class MaskDirective implements ControlValueAccessor { e.preventDefault(); } if (e.keyCode === 37 || e.keyCode === 8) { - if (e.keyCode === 37) { - el.selectionStart = (el.selectionEnd as number) - 1; - } if ( (el.selectionStart as number) <= this._maskService.prefix.length && (el.selectionEnd as number) <= this._maskService.prefix.length diff --git a/src/app/ngx-mask/mask.service.ts b/src/app/ngx-mask/mask.service.ts index 2dcfa971..c86b5f50 100644 --- a/src/app/ngx-mask/mask.service.ts +++ b/src/app/ngx-mask/mask.service.ts @@ -207,6 +207,17 @@ export class MaskService extends MaskApplierService { return new RegExp(specialCharactersForRemove.map((item: string) => `\\${item}`).join('|'), 'gi'); } private _checkSymbols(result: string): string | number | undefined { + if ('dot_separator.2' === this.maskExpression ) { + // tslint:disable-next-line:max-line-length + return Number(this._removeMask(this._removeSufix(this._removePrefix(result)), this.maskSpecialCharacters).replace( + ',', + '.' + )).toFixed(2); + } + if ('comma_separator.2' === this.maskExpression) { + // tslint:disable-next-line:max-line-length + return Number(this._removeMask(this._removeSufix(this._removePrefix(result)), this.maskSpecialCharacters)).toFixed(2); + } if (this.isNumberValue) { return Number(this._removeMask(this._removeSufix(this._removePrefix(result)), this.maskSpecialCharacters)); } else if (