ngx-mask 22.0.2 → 22.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-mask",
3
- "version": "22.0.2",
3
+ "version": "22.2.0",
4
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",
@@ -19,6 +19,7 @@
19
19
  "LICENSE",
20
20
  "README.md",
21
21
  "fesm2022/ngx-mask.mjs",
22
+ "fesm2022/ngx-mask.mjs.map",
22
23
  "types",
23
24
  "package.json"
24
25
  ],
@@ -138,19 +138,25 @@ declare class NgxMaskApplierService {
138
138
  protected percentage: (str: string) => boolean;
139
139
  getPrecision: (maskExpression: string) => number;
140
140
  private checkAndRemoveSuffix;
141
- protected checkInputPrecision: (inputValue: string, precision: number, decimalMarker: NgxMaskConfig["decimalMarker"]) => string;
141
+ protected checkInputPrecision: (inputValue: string, precision: number) => string;
142
142
  protected _stripToDecimal(str: string): string;
143
143
  protected _charToRegExpExpression(char: string): string;
144
144
  protected _shiftStep(cursor: number): void;
145
145
  protected _compareOrIncludes<T>(value: T, comparedValue: T | T[], excludedValue: T): boolean;
146
146
  protected _validIP(valuesIP: string[]): boolean;
147
+ /**
148
+ * The single rule for "which decimal marker is active": the configured marker, or — for an
149
+ * array — the first configured marker present in `value` that is not the thousandSeparator,
150
+ * else the first configured marker that is not the thousandSeparator (#1653).
151
+ */
152
+ protected _activeDecimalMarker(value: string): DecimalMarkerChar;
147
153
  protected _splitPercentZero(value: string): string;
148
154
  protected _findFirstNonZeroAndDecimalIndex(inputString: string, decimalMarker: '.' | ','): {
149
155
  decimalMarkerIndex: number | null;
150
156
  nonZeroIndex: number | null;
151
157
  };
152
158
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxMaskApplierService, never>;
153
- static ɵprov: _angular_core.ɵɵInjectableDeclaration<NgxMaskApplierService>;
159
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<any>;
154
160
  }
155
161
 
156
162
  declare class NgxMaskService extends NgxMaskApplierService {
@@ -269,10 +275,10 @@ declare class NgxMaskService extends NgxMaskApplierService {
269
275
  */
270
276
  currentLocaleDecimalMarker(): string;
271
277
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxMaskService, never>;
272
- static ɵprov: _angular_core.ɵɵInjectableDeclaration<NgxMaskService>;
278
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<any>;
273
279
  }
274
280
 
275
- declare class NgxMaskDirective implements ControlValueAccessor, OnChanges, Validator, FormValueControl<string> {
281
+ declare class NgxMaskDirective implements ControlValueAccessor, OnChanges, Validator, FormValueControl<string | number | null | undefined> {
276
282
  mask: _angular_core.InputSignal<string | null | undefined>;
277
283
  specialCharacters: _angular_core.InputSignal<string[] | readonly string[]>;
278
284
  patterns: _angular_core.InputSignal<Record<string, {
@@ -303,7 +309,19 @@ declare class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valid
303
309
  keepCharacterPositions: _angular_core.InputSignal<boolean | null>;
304
310
  instantPrefix: _angular_core.InputSignal<boolean | null>;
305
311
  defaultValueOnBlur: _angular_core.InputSignal<string | null>;
306
- value: _angular_core.ModelSignal<string>;
312
+ /**
313
+ * Signal Forms `FormValueControl` surface. At runtime `FormField` never drives this model
314
+ * when the directive is bound (it prefers the `NG_VALUE_ACCESSOR` provided above, see
315
+ * `_isCvaMode`), but the template type-checker treats any directive owning a `value` model
316
+ * as the field's custom control and checks the bound field's value type against it (#1640).
317
+ * The model therefore accepts exactly what `writeValue()` accepts — `string | number | null |
318
+ * undefined` — so numeric and nullable fields (`signal({ amount: 0 })`,
319
+ * `signal<number | null>(null)`, `signal<string | null>(null)`) compile under
320
+ * `strictTemplates`. Values pushed back into the model are always the unmasked string (see
321
+ * `_propagateToValueModel`), i.e. `value()` / `valueChange` are declared wider than what is
322
+ * emitted.
323
+ */
324
+ value: _angular_core.ModelSignal<string | number | null | undefined>;
307
325
  disabled: _angular_core.InputSignalWithTransform<boolean, unknown>;
308
326
  touched: _angular_core.ModelSignal<boolean>;
309
327
  maskFilled: _angular_core.OutputEmitterRef<void>;
@@ -389,6 +407,34 @@ declare class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valid
389
407
  onFocus(): void;
390
408
  onModelChange(value: unknown): void;
391
409
  onInput(e: Event): void;
410
+ /**
411
+ * #1488: locates the date/time field (DAY/MONTH/HOURS/HOUR/MINUTE/SECOND) that
412
+ * `position` falls within, scanning `maskExpression` left-to-right. A field spans
413
+ * its token plus its digit-pair companion — `0` for DAY/MONTH/MINUTE/SECOND (e.g.
414
+ * `d0`, `M0`, `m0`, `s0`), or `HOUR` for the combined `Hh` hour field. Matches any
415
+ * position from the field's first char up to and including its end (separator index),
416
+ * so both a still-mid-typing caret and the just-completed field are covered — the
417
+ * precise overflow decision (single first digit vs. completed 2-digit value) happens
418
+ * in `_isFieldOverflowing`. Returns null for non-date/time masks, a no-op for the caller.
419
+ */
420
+ private _findDateTimeFieldAt;
421
+ /**
422
+ * Per-token overflow thresholds, mirroring the ones `generic-pattern.handler.ts`
423
+ * already establishes (day 31, month 12, hour 23/12 w/ apm, minute/second 59) — kept
424
+ * as a small local table rather than importing from the handler (see design's
425
+ * Rejected Alternatives: the directive and the handler stay on separate sides of the
426
+ * display/parse boundary).
427
+ *
428
+ * Two overflow shapes are checked, mirroring how the handler itself decides mid-type:
429
+ * - `firstDigitValue`: when `position` is exactly one char past the field's start (the
430
+ * just-typed char is the field's first digit), an out-of-range first digit alone
431
+ * (e.g. month digit `3`, day digit `4`) already triggers the handler's own leadZero
432
+ * pad within this same keystroke — `el.value` hasn't caught up yet at this point in
433
+ * the pipeline, so the raw typed digit (`inputValue`) must be read instead.
434
+ * - `fieldValue`: once both digits of the field are present in `el.value`, an
435
+ * out-of-range 2-digit value (e.g. day `33`, month `13`) triggers the shift directly.
436
+ */
437
+ private _isFieldOverflowing;
392
438
  /**
393
439
  * Whether any pattern slot of the current mask expression can accept a letter.
394
440
  * IME composition is only meaningful for such masks; for purely numeric masks
@@ -412,6 +458,15 @@ declare class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valid
412
458
  private _applyDefaultValueOnBlur;
413
459
  onClick(e: Event): void;
414
460
  onKeyDown(event: Event): void;
461
+ /**
462
+ * #1641: on layouts whose decimal separator is a comma, the numeric keypad still emits
463
+ * a period, which a separator mask configured with a comma decimal marker rejects. The
464
+ * keypad decimal key (`key: 'Decimal'`, or a `.` from `code: 'NumpadDecimal'`) is
465
+ * therefore turned into the configured marker. Only the keypad key is intercepted: a
466
+ * period typed on the main keyboard keeps its normal behavior (e.g. as a thousand
467
+ * separator). Returns true when the key press was handled.
468
+ */
469
+ private _insertNumpadDecimalMarker;
415
470
  /**
416
471
  * Restores the control's pristine/untouched state after a writeValue-driven emission.
417
472
  *