ngx-mask 22.0.0 → 22.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +25 -28
- package/fesm2022/ngx-mask.mjs +818 -652
- package/package.json +13 -7
- package/types/ngx-mask.d.ts +41 -22
- package/fesm2022/ngx-mask.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-mask",
|
|
3
|
-
"version": "22.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "22.0.2",
|
|
4
|
+
"description": "Input masking for modern Angular — Reactive, template-driven and Signal Forms, zoneless and SSR ready. Dates, numbers, separators, custom patterns.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ng2-mask",
|
|
7
7
|
"ngx-mask",
|
|
@@ -11,21 +11,27 @@
|
|
|
11
11
|
"angular",
|
|
12
12
|
"angular2",
|
|
13
13
|
"angular2-mask",
|
|
14
|
-
"ng2mask"
|
|
15
|
-
"jsdaddy"
|
|
14
|
+
"ng2mask"
|
|
16
15
|
],
|
|
17
16
|
"license": "MIT",
|
|
18
17
|
"author": "ngx-mask",
|
|
18
|
+
"files": [
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"README.md",
|
|
21
|
+
"fesm2022/ngx-mask.mjs",
|
|
22
|
+
"types",
|
|
23
|
+
"package.json"
|
|
24
|
+
],
|
|
19
25
|
"contributors": [
|
|
20
26
|
"ngx-mask"
|
|
21
27
|
],
|
|
22
|
-
"homepage": "https://github.com/
|
|
28
|
+
"homepage": "https://github.com/NepipenkoIgor/ngx-mask",
|
|
23
29
|
"repository": {
|
|
24
30
|
"type": "git",
|
|
25
|
-
"url": "git@github.com:
|
|
31
|
+
"url": "git@github.com:NepipenkoIgor/ngx-mask.git"
|
|
26
32
|
},
|
|
27
33
|
"bugs": {
|
|
28
|
-
"url": "https://github.com/
|
|
34
|
+
"url": "https://github.com/NepipenkoIgor/ngx-mask/issues"
|
|
29
35
|
},
|
|
30
36
|
"peerDependencies": {
|
|
31
37
|
"@angular/common": "^22.0.0",
|
package/types/ngx-mask.d.ts
CHANGED
|
@@ -6,11 +6,13 @@ import { FormValueControl } from '@angular/forms/signals';
|
|
|
6
6
|
|
|
7
7
|
type InputTransformFn = (value: unknown) => string | number;
|
|
8
8
|
type OutputTransformFn = (value: string | number | undefined | null) => unknown;
|
|
9
|
+
/** Single decimal marker character accepted when `decimalMarker` is given as an array. */
|
|
10
|
+
type DecimalMarkerChar = '.' | ',';
|
|
9
11
|
type NgxMaskConfig = {
|
|
10
12
|
suffix: string;
|
|
11
13
|
prefix: string;
|
|
12
14
|
thousandSeparator: string;
|
|
13
|
-
decimalMarker:
|
|
15
|
+
decimalMarker: DecimalMarkerChar | [DecimalMarkerChar, DecimalMarkerChar];
|
|
14
16
|
clearIfNotMatch: boolean;
|
|
15
17
|
showMaskTyped: boolean;
|
|
16
18
|
placeHolderCharacter: string;
|
|
@@ -104,7 +106,7 @@ declare class NgxMaskApplierService {
|
|
|
104
106
|
keepCharacterPositions: NgxMaskConfig['keepCharacterPositions'];
|
|
105
107
|
instantPrefix: NgxMaskConfig['instantPrefix'];
|
|
106
108
|
triggerOnMaskChange: NgxMaskConfig['triggerOnMaskChange'];
|
|
107
|
-
|
|
109
|
+
protected _shift: Set<number>;
|
|
108
110
|
plusOnePosition: boolean;
|
|
109
111
|
maskExpression: string;
|
|
110
112
|
actualValue: string;
|
|
@@ -118,11 +120,11 @@ declare class NgxMaskApplierService {
|
|
|
118
120
|
writingValue: boolean;
|
|
119
121
|
ipError?: boolean;
|
|
120
122
|
cpfCnpjError?: boolean;
|
|
121
|
-
applyMask(inputValue: string | object | boolean | null | undefined, maskExpression: string, position?: number, justPasted?: boolean, backspaced?: boolean, cb?: (
|
|
123
|
+
applyMask(inputValue: string | object | boolean | null | undefined, maskExpression: string, position?: number, justPasted?: boolean, backspaced?: boolean, cb?: (actualShift: number, backspaceShift: boolean) => void): string;
|
|
122
124
|
_findDropSpecialChar(inputSymbol: string): undefined | string;
|
|
123
125
|
_findSpecialChar(inputSymbol: string): undefined | string;
|
|
124
126
|
_checkSymbolMask(inputSymbol: string, maskSymbol: string): boolean;
|
|
125
|
-
|
|
127
|
+
protected _formatWithSeparators: (str: string, thousandSeparatorChar: string, decimalChars: string | string[], precision: number) => string;
|
|
126
128
|
/**
|
|
127
129
|
* Formats a value for the `typeFromDecimals` mode: every digit of the raw value is
|
|
128
130
|
* read as one integer that is then split `precision` digits from the right
|
|
@@ -130,20 +132,23 @@ declare class NgxMaskApplierService {
|
|
|
130
132
|
* mid-string edits and backspace all reduce to "digits shifted through the
|
|
131
133
|
* decimal marker".
|
|
132
134
|
*/
|
|
133
|
-
|
|
135
|
+
protected _formatFromDecimals(value: string, precision: number, decimalMarker: string): string;
|
|
134
136
|
/** Inserts `separator` between every 3-digit group of an integer-digit string. */
|
|
135
137
|
private _applyThousandGrouping;
|
|
136
|
-
|
|
138
|
+
protected percentage: (str: string) => boolean;
|
|
137
139
|
getPrecision: (maskExpression: string) => number;
|
|
138
140
|
private checkAndRemoveSuffix;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
protected checkInputPrecision: (inputValue: string, precision: number, decimalMarker: NgxMaskConfig["decimalMarker"]) => string;
|
|
142
|
+
protected _stripToDecimal(str: string): string;
|
|
143
|
+
protected _charToRegExpExpression(char: string): string;
|
|
144
|
+
protected _shiftStep(cursor: number): void;
|
|
143
145
|
protected _compareOrIncludes<T>(value: T, comparedValue: T | T[], excludedValue: T): boolean;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
protected _validIP(valuesIP: string[]): boolean;
|
|
147
|
+
protected _splitPercentZero(value: string): string;
|
|
148
|
+
protected _findFirstNonZeroAndDecimalIndex(inputString: string, decimalMarker: '.' | ','): {
|
|
149
|
+
decimalMarkerIndex: number | null;
|
|
150
|
+
nonZeroIndex: number | null;
|
|
151
|
+
};
|
|
147
152
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxMaskApplierService, never>;
|
|
148
153
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<NgxMaskApplierService>;
|
|
149
154
|
}
|
|
@@ -172,7 +177,7 @@ declare class NgxMaskService extends NgxMaskApplierService {
|
|
|
172
177
|
private _emitValue;
|
|
173
178
|
private _start;
|
|
174
179
|
private _end;
|
|
175
|
-
onChange: (_:
|
|
180
|
+
onChange: (_: unknown) => void;
|
|
176
181
|
readonly _elementRef: ElementRef<any> | null;
|
|
177
182
|
private readonly document;
|
|
178
183
|
protected _config: NgxMaskConfig;
|
|
@@ -187,9 +192,9 @@ declare class NgxMaskService extends NgxMaskApplierService {
|
|
|
187
192
|
* @param cb Callback function.
|
|
188
193
|
* @returns The masked value.
|
|
189
194
|
*/
|
|
190
|
-
applyMask(inputValue: string, maskExpression: string, position?: number, justPasted?: boolean, backspaced?: boolean, cb?: (
|
|
195
|
+
applyMask(inputValue: string, maskExpression: string, position?: number, justPasted?: boolean, backspaced?: boolean, cb?: (actualShift: number, backspaceShift: boolean) => void): string;
|
|
191
196
|
private _numberSkipedSymbols;
|
|
192
|
-
applyValueChanges(position: number, justPasted: boolean, backspaced: boolean, cb?: (
|
|
197
|
+
applyValueChanges(position: number, justPasted: boolean, backspaced: boolean, cb?: (actualShift: number, backspaceShift: boolean) => void): void;
|
|
193
198
|
hideInput(inputValue: string, maskExpression: string): string;
|
|
194
199
|
getActualValue(res: string): string;
|
|
195
200
|
shiftTypedSymbols(inputValue: string): string;
|
|
@@ -226,7 +231,7 @@ declare class NgxMaskService extends NgxMaskApplierService {
|
|
|
226
231
|
* model value too. Therefore, we don't trigger onChange in this scenario.
|
|
227
232
|
* @param inputValue the current form input value
|
|
228
233
|
*/
|
|
229
|
-
|
|
234
|
+
formControlResult(inputValue: string): void;
|
|
230
235
|
private _toNumber;
|
|
231
236
|
private _removeMask;
|
|
232
237
|
private _removePrefix;
|
|
@@ -278,7 +283,7 @@ declare class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valid
|
|
|
278
283
|
prefix: _angular_core.InputSignal<string>;
|
|
279
284
|
suffix: _angular_core.InputSignal<string>;
|
|
280
285
|
thousandSeparator: _angular_core.InputSignal<string>;
|
|
281
|
-
decimalMarker: _angular_core.InputSignal<
|
|
286
|
+
decimalMarker: _angular_core.InputSignal<ngx_mask.DecimalMarkerChar | [ngx_mask.DecimalMarkerChar, ngx_mask.DecimalMarkerChar]>;
|
|
282
287
|
dropSpecialCharacters: _angular_core.InputSignal<boolean | string[] | readonly string[] | null>;
|
|
283
288
|
hiddenInput: _angular_core.InputSignal<boolean | null>;
|
|
284
289
|
showMaskTyped: _angular_core.InputSignal<boolean | null>;
|
|
@@ -375,7 +380,7 @@ declare class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valid
|
|
|
375
380
|
private readonly _injector;
|
|
376
381
|
private _ngControl;
|
|
377
382
|
private _resolveNgControl;
|
|
378
|
-
onChange: (_:
|
|
383
|
+
onChange: (_: unknown) => void;
|
|
379
384
|
onTouch: () => void;
|
|
380
385
|
constructor();
|
|
381
386
|
ngOnChanges(changes: SimpleChanges): void;
|
|
@@ -419,7 +424,7 @@ declare class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valid
|
|
|
419
424
|
*/
|
|
420
425
|
private _restoreControlStateAfterWrite;
|
|
421
426
|
/** It writes the value in the input */
|
|
422
|
-
writeValue(controlValue: unknown):
|
|
427
|
+
writeValue(controlValue: unknown): void;
|
|
423
428
|
/**
|
|
424
429
|
* Mirrors a writeValue-driven render into the DOM synchronously, in the same
|
|
425
430
|
* change-detection pass (#1305). The service's `formElementProperty` setter defers all
|
|
@@ -455,7 +460,21 @@ declare class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valid
|
|
|
455
460
|
focus(): void;
|
|
456
461
|
private _getActiveElement;
|
|
457
462
|
checkSelectionOnDeletion(el: HTMLInputElement): void;
|
|
458
|
-
/**
|
|
463
|
+
/**
|
|
464
|
+
* It disables the input element.
|
|
465
|
+
*
|
|
466
|
+
* Mirrors `_writeElementValueSync` (#1305): the service's `formElementProperty` setter
|
|
467
|
+
* defers ALL DOM writes via `queueMicrotask` to dodge ExpressionChangedAfterItHasBeenChecked
|
|
468
|
+
* and keep FIFO ordering with config-driven re-renders. For `disabled` specifically, that
|
|
469
|
+
* deferral leaves `nativeElement.disabled` stale for at least one microtask after Angular
|
|
470
|
+
* Forms' `setUpControl` calls this method synchronously during init — long enough for a
|
|
471
|
+
* consumer reading the DOM property in the same synchronous phase (or another deferred write
|
|
472
|
+
* racing in FIFO order) to observe the wrong value, e.g. an initially-disabled FormControl
|
|
473
|
+
* whose native input briefly (or, depending on interleaving, persistently) reports
|
|
474
|
+
* `disabled === false` (#1633). Writing synchronously here closes that gap; the deferred
|
|
475
|
+
* write below still runs afterwards and re-applies the same final value, preserving the
|
|
476
|
+
* existing ordering guarantees other call sites rely on.
|
|
477
|
+
*/
|
|
459
478
|
setDisabledState(isDisabled: boolean): void;
|
|
460
479
|
private _applyMask;
|
|
461
480
|
/**
|
|
@@ -517,4 +536,4 @@ declare class NgxMaskPipe implements PipeTransform {
|
|
|
517
536
|
}
|
|
518
537
|
|
|
519
538
|
export { INITIAL_CONFIG, NEW_CONFIG, NGX_MASK_CONFIG, NgxMaskDirective, NgxMaskPipe, NgxMaskService, initialConfig, provideEnvironmentNgxMask, provideNgxMask, resolveMaskAlias, timeMasks, withoutValidation };
|
|
520
|
-
export type { InputTransformFn, NgxMaskConfig, NgxMaskOptions, OutputTransformFn };
|
|
539
|
+
export type { DecimalMarkerChar, InputTransformFn, NgxMaskConfig, NgxMaskOptions, OutputTransformFn };
|