From 8a29630a0e671731a4a9cf88fccf25e29b9fd43b Mon Sep 17 00:00:00 2001 From: Igor Nepipenko Date: Tue, 24 Nov 2020 17:21:50 +0200 Subject: [PATCH 1/2] fix: dropSpecialCharacters false also should return prefix [ref:#686] --- CHANGELOG.md | 9 ++++++++ package.json | 2 +- projects/ngx-mask-lib/package.json | 2 +- projects/ngx-mask-lib/src/lib/mask.service.ts | 23 +++++++++---------- .../ngx-mask-lib/src/test/add-prefix.spec.ts | 7 ++++++ 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afad39f1..d895d8a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ +# 11.1.2 (2020-11-24) + +### Bug Fixes + +DropSpecialCharacters false also should return prefix ([#686](https://github.com/JsDaddy/ngx-mask/issues/686)) ([830](https://github.com/JsDaddy/ngx-mask/pull/830)) + + + + # 11.1.1 (2020-11-24) ### Bug Fixes diff --git a/package.json b/package.json index d9786726..f7610b96 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-mask", - "version": "11.1.1", + "version": "11.1.2", "description": "awesome ngx mask", "license": "MIT", "angular-cli": {}, diff --git a/projects/ngx-mask-lib/package.json b/projects/ngx-mask-lib/package.json index 3b6e45a8..d97f6786 100644 --- a/projects/ngx-mask-lib/package.json +++ b/projects/ngx-mask-lib/package.json @@ -1,6 +1,6 @@ { "name": "ngx-mask", - "version": "11.1.1", + "version": "11.1.2", "description": "awesome ngx mask", "keywords": [ "ng2-mask", diff --git a/projects/ngx-mask-lib/src/lib/mask.service.ts b/projects/ngx-mask-lib/src/lib/mask.service.ts index 52dd720f..94542cb6 100644 --- a/projects/ngx-mask-lib/src/lib/mask.service.ts +++ b/projects/ngx-mask-lib/src/lib/mask.service.ts @@ -312,18 +312,17 @@ export class MaskService extends MaskApplierService { * @param inputValue the current form input value */ private formControlResult(inputValue: string): void { - if (!this.writingValue) { - if (Array.isArray(this.dropSpecialCharacters)) { - this.onChange( - this._toNumber( - this._removeMask(this._removeSuffix(this._removePrefix(inputValue)), this.dropSpecialCharacters) - ) - ); - } else if (this.dropSpecialCharacters) { - this.onChange(this._toNumber(this._checkSymbols(inputValue))); - } else { - this.onChange(this._removeSuffix(this._removePrefix(inputValue))); - } + if (this.writingValue) { + return; + } + if (Array.isArray(this.dropSpecialCharacters)) { + this.onChange( + this._toNumber(this._removeMask(this._removeSuffix(this._removePrefix(inputValue)), this.dropSpecialCharacters)) + ); + } else if (this.dropSpecialCharacters) { + this.onChange(this._toNumber(this._checkSymbols(inputValue))); + } else { + this.onChange(this._removeSuffix(inputValue)); } } diff --git a/projects/ngx-mask-lib/src/test/add-prefix.spec.ts b/projects/ngx-mask-lib/src/test/add-prefix.spec.ts index 256ea605..977371e6 100644 --- a/projects/ngx-mask-lib/src/test/add-prefix.spec.ts +++ b/projects/ngx-mask-lib/src/test/add-prefix.spec.ts @@ -50,4 +50,11 @@ describe('Directive: Mask (Add prefix)', () => { equal('+55 (12) 3456-7890', '+55 (12) 3456-7890', fixture); equal('+55 (12) 3 4567-8901', '+55 (12) 3 4567-8901', fixture); }); + it('dropSpecialCharacters false should return value with prefix', () => { + component.mask = '00-000-000-00'; + component.dropSpecialCharacters = false; + component.prefix = '+7 '; + equal('097', '+7 09-7', fixture); + expect(component.form.value).toEqual('+7 09-7'); + }); }); From 6cd61c9edeafc644f29b8c70d5ff208baff23c4d Mon Sep 17 00:00:00 2001 From: Igor Nepipenko Date: Tue, 24 Nov 2020 17:35:16 +0200 Subject: [PATCH 2/2] fix: linting errors [ref:#686] --- CHANGELOG.md | 91 ++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d895d8a7..07c91cad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,7 @@ ### Bug Fixes -DropSpecialCharacters false also should return prefix ([#686](https://github.com/JsDaddy/ngx-mask/issues/686)) ([830](https://github.com/JsDaddy/ngx-mask/pull/830)) - +DropSpecialCharacters false also should return prefix ([#686](https://github.com/JsDaddy/ngx-mask/issues/686)) ([830](https://github.com/JsDaddy/ngx-mask/pull/830)) @@ -31,25 +30,25 @@ Copy paste event should work as expected ([#765](https://github.com/JsDaddy/ngx- Difinition for form control with `{value, disable} should work ([#803](https://github.com/JsDaddy/ngx-mask/issues/803)) ([826](https://github.com/JsDaddy/ngx-mask/pull/826)) - + # [11.0.0 Update to Angular 11](2020-11-12) Update to Angular 11 - + # [9.1.0 Directive's selector change](2020-05-20) Change directive selector to restrict to input and textarea tags - + # [9.0.2 Bugfix](2020-04-20) Fix for #721 - prevent entering dots when decimal marker is comma - + # [9.0.1 Bugfix](2020-04-08) @@ -57,7 +56,7 @@ Fix for #715 - mark fields as touched on blur on form fields with an empty mask Fix for #711 - stop fields being marked as dirty after a form reset - + # [9.0.0 Update to Angular 9](2020-04-08) @@ -69,7 +68,7 @@ Fix: allowNegativeNumbers works correctly when set as true or false. If false, e Fix: stop cursor jumping around when mask is set as empty - + # [8.2.0 bugfix and breaking change](2020-01-17) @@ -82,7 +81,7 @@ Feature: Added new error page for handling 404's, and new bugs page for being a Breaking change: Made validation error return an object named mask. If you were previously checking for a validation error named 'Mask error' then it will need changing to just 'mask'. - + # [8.1.7 bugfix](2019-12-27) @@ -90,7 +89,7 @@ Fix for #369 - add thousandSeparator to separator pipe Fix for #381 - add support to negative number in separator mask - + # [8.1.6 bugfix](2019-10-30) @@ -100,13 +99,13 @@ Fix for #620 - allow delete button to work when at beginning of input and no pre Fix for #621 - validation config value now works correctly - + # [8.1.5 bugfix](2019-10-25) Fix for #614 - export everything from config - + # [8.1.4 bugfix](2019-10-23) @@ -114,202 +113,202 @@ Fix for #580 - honour the special characters that user may have specified, and p Project folder structure converted over to follow Angular CLI way of libraries - + # [8.1.3 bugfix](2019-10-23) Fix for #590 - Problem if prefix last char is not a number - + # [8.1.2 placeholder customisation](2019-10-11) Placeholder can now be customised - + # [8.1.1 bugfix](2019-10-10) bugs fix - + # [8.1.0 separator update](2019-11-09) update separator - + # [8.0.8 bugfix](2019-10-07) bugs fix [refs: #554, #580, #582] - + # [8.0.7 bugfix](2019-10-04) bugs fix [refs: #579, #576, #561] - + # [8.0.7 update date and time](2019-10-02) Update date and time masks [refs: #571, #567, #572, #564, #558, #573] - + # [8.0.4 bugfix](2019-09-09) minor bug fixes - + # [8.0.3 cursor](2019-09-04) minor bug fixes - + # [7.9.9 cursor](2019-05-8) Issues fix - + # [7.9.1 cursor](2019-04-15) Bugs fix - + # [7.9.1 cursor](2019-04-11) Fix Backspace on empty input causes cursor to jump after entering a value - + # [7.8.6 bugfix](2019-03-29) Bugfix - + # [7.8.5 update of returned value type](2019-03-28) Fix returned value when input value type is number - + # [7.8.4 decimal](2019-03-28) Added decimal percent, fix suffix prevents decimals - + # [7.7.3 polyfill](2019-03-28) Added polyfill for IE11 - + # [7.7.2 dot_separator](2019-03-27) Fix decimals - + # [7.7.1 coma_separator](2019-03-25) Readme update - + # [7.7.0 coma_separator](2019-03-21) Secure input and bugs fix - + # [7.6.6 coma_separator](2019-03-18) Bugs fix - + # [7.6.4 coma_separator] (2019-03-13) Bugs fix - + # [7.6.0 coma_separator] (2019-03-11) Feature: added default validation - + # [7.5.0 coma_separator] (2019-03-11) Bugs fix: fix minutes validation, '-' in separator, decimal part in separator and fix issues with FF/IE - + # [7.4.6 coma_separator] (2019-02-15) Fix coma_separator behavior - + # [7.4.5 dependencies] (2019-02-15) Update dev and prod dependencies - + # [7.3.4 decimals values separator] (2019-01-17) Added coma_separator - + # [7.3.3 decimals values separator] (2019-01-08) Added decimals values for separator and dot_separator - + # [7.3.1 update separator] (2018-12-19) Now separator can separate by dots - + # [7.3.0 feature percent] (2018-12-14) Added validation for percent - + # [7.2.0 feature 24 hour forma] (2018-12-12) Added valid 24 hour format mask and update separator - + # [7.1.0 feature thousand separator] (2018-12-11) Added new mask that separates number by thousands - + # [7.0.4 fix multiple mask] (2018-12-11) Fix multiple mask when you use the same symbols bettwen \* - + # [7.0.3 hotfix] (2018-12-10) hotfix - + # [7.0.2 update of sufix] (2018-12-10)