From 23e1ee0f52dc8a6a6262b4e5a2a9b41b58445dd2 Mon Sep 17 00:00:00 2001 From: Andrii Kamaldinov <129040945+andriikamaldinov1@users.noreply.github.com> Date: Mon, 11 Nov 2024 16:07:44 +0200 Subject: [PATCH] fix(ref:#1452): fix issues * fix(ref: no-ref): fix issues * fix(ref: no-ref): fix issues * fix(ref: no-ref): fix issues * fix(ref: no-ref): fix issues --- CHANGELOG.md | 7 +++++++ package.json | 2 +- projects/ngx-mask-lib/package.json | 2 +- projects/ngx-mask-lib/src/lib/ngx-mask.config.ts | 4 ++-- projects/ngx-mask-lib/src/lib/ngx-mask.service.ts | 2 +- .../ngx-mask-lib/src/test/secure-mask.spec.ts | 15 +++++++++++++++ .../utils/cypress-test-component.component.ts | 2 +- src/app/options/options.component.html | 2 +- tsconfig.json | 15 +++++++++++---- 9 files changed, 40 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a18fc93..6b531147 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 18.0.4(2024-11-11) + +### Fix + +- Fix ([#1449](https://github.com/JsDaddy/ngx-mask/issues/1449)) + + # 18.0.3(2024-11-05) ### Fix diff --git a/package.json b/package.json index 8a20bd64..ebfea910 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-mask", - "version": "18.0.3", + "version": "18.0.4", "description": "Awesome ngx mask", "license": "MIT", "engines": { diff --git a/projects/ngx-mask-lib/package.json b/projects/ngx-mask-lib/package.json index fcdab315..15381d26 100644 --- a/projects/ngx-mask-lib/package.json +++ b/projects/ngx-mask-lib/package.json @@ -1,6 +1,6 @@ { "name": "ngx-mask", - "version": "18.0.3", + "version": "18.0.4", "description": "awesome ngx mask", "keywords": [ "ng2-mask", diff --git a/projects/ngx-mask-lib/src/lib/ngx-mask.config.ts b/projects/ngx-mask-lib/src/lib/ngx-mask.config.ts index 1732356b..62c15a61 100644 --- a/projects/ngx-mask-lib/src/lib/ngx-mask.config.ts +++ b/projects/ngx-mask-lib/src/lib/ngx-mask.config.ts @@ -17,7 +17,7 @@ export type NgxMaskConfig = { shownMaskExpression: string; specialCharacters: string[] | readonly string[]; dropSpecialCharacters: boolean | string[] | readonly string[]; - hiddenInput: boolean; + hiddenInput: boolean | null; validation: boolean; separatorLimit: string; apm: boolean; @@ -54,7 +54,7 @@ export const initialConfig: NgxMaskConfig = { showMaskTyped: false, placeHolderCharacter: '_', dropSpecialCharacters: true, - hiddenInput: false, + hiddenInput: null, shownMaskExpression: '', separatorLimit: '', allowNegativeNumbers: false, diff --git a/projects/ngx-mask-lib/src/lib/ngx-mask.service.ts b/projects/ngx-mask-lib/src/lib/ngx-mask.service.ts index 1de853eb..2dcad3cf 100644 --- a/projects/ngx-mask-lib/src/lib/ngx-mask.service.ts +++ b/projects/ngx-mask-lib/src/lib/ngx-mask.service.ts @@ -80,7 +80,7 @@ export class NgxMaskService extends NgxMaskApplierService { : MaskExpression.EMPTY_STRING; let newInputValue = ''; let newPosition = position; - if (this.hiddenInput && !this.writingValue) { + if (this.hiddenInput !== null && !this.writingValue) { let actualResult: string[] = inputValue && inputValue.length === 1 ? inputValue.split(MaskExpression.EMPTY_STRING) diff --git a/projects/ngx-mask-lib/src/test/secure-mask.spec.ts b/projects/ngx-mask-lib/src/test/secure-mask.spec.ts index a6e02619..fdedcdf8 100644 --- a/projects/ngx-mask-lib/src/test/secure-mask.spec.ts +++ b/projects/ngx-mask-lib/src/test/secure-mask.spec.ts @@ -222,4 +222,19 @@ describe('Directive: Mask (Secure)', () => { component.hiddenInput = false; equal(inputTarget.value, '123-45-6', fixture, true); }); + + it('change hiddenInput to false when mask is full', async () => { + const debug: DebugElement = fixture.debugElement.query(By.css('input')); + const inputTarget: HTMLInputElement = debug.nativeElement as HTMLInputElement; + spyOnProperty(document, 'activeElement').and.returnValue(inputTarget); + fixture.detectChanges(); + component.mask = 'XXX/XX/XXXX'; + component.hiddenInput = true; + equal('123456789', '***/**/****', fixture); + expect(component.form.value).toBe('123456789'); + fixture.detectChanges(); + component.hiddenInput = false; + equal(inputTarget.value, '123/45/6789', fixture, true); + expect(component.form.value).toBe('123456789'); + }); }); diff --git a/projects/ngx-mask-lib/src/test/utils/cypress-test-component.component.ts b/projects/ngx-mask-lib/src/test/utils/cypress-test-component.component.ts index b23114ae..70cb470a 100644 --- a/projects/ngx-mask-lib/src/test/utils/cypress-test-component.component.ts +++ b/projects/ngx-mask-lib/src/test/utils/cypress-test-component.component.ts @@ -38,7 +38,7 @@ export class CypressTestMaskComponent { protected _config = inject(NGX_MASK_CONFIG); @Input() public mask = ''; - @Input() public hiddenInput = false; + @Input() public hiddenInput = null; @Input() public allowNegativeNumbers = false; diff --git a/src/app/options/options.component.html b/src/app/options/options.component.html index f656d1c5..3b2442bd 100644 --- a/src/app/options/options.component.html +++ b/src/app/options/options.component.html @@ -72,7 +72,7 @@ [validation]="ex._validation || false" [showMaskTyped]="ex._showMaskTyped || false" [clearIfNotMatch]="ex._clearIfNotMatch" - [hiddenInput]="ex._hiddenInput || undefined" + [hiddenInput]="ex._hiddenInput || null" [outputTransformFn]="ex._outputTransformFn || outputTransformFn" [inputTransformFn]="ex._inputTransformFn || inputTransformFn" class="w-full h-[51px] placeholder:text-white/25 text-full-white py-3 px-5 outline-none bg-black border-b-2px border-b-white rounded-10px focus:border-b-yellow hover:border-b-yellow hover:bg-full-white/25 focus:bg-full-white/25" /> diff --git a/tsconfig.json b/tsconfig.json index 7ab3eef1..49d5458f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,12 +6,13 @@ "importHelpers": true, "outDir": "./dist/out-tsc", "sourceMap": true, + "esModuleInterop": true, "declaration": false, - "module": "esnext", + "module": "ES2022", "experimentalDecorators": true, "strict": true, "target": "ES2022", - "lib": ["es2020", "dom"], + "lib": ["ES2022", "dom"], "paths": { "ngx-mask": ["projects/ngx-mask-lib/src"], "ngx-mask/*": ["projects/ngx-mask-lib/src"], @@ -25,11 +26,17 @@ "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "noUncheckedIndexedAccess": true, + "useUnknownInCatchVariables": true, + "exactOptionalPropertyTypes": true, + "removeComments": true, + "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, "noImplicitOverride": true, "noPropertyAccessFromIndexSignature": true, - "useDefineForClassFields": false, "skipLibCheck": true, - "noImplicitAny": true + "noImplicitAny": true, + "useDefineForClassFields": true, + "isolatedModules": true }, "angularCompilerOptions": { "enableI18nLegacyMessageIdFormat": false,