ngx-mask 13.2.1 → 13.2.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.
@@ -97,6 +97,7 @@ class NgxMaskApplierService {
97
97
  constructor(_config) {
98
98
  this._config = _config;
99
99
  this._shift = new Set();
100
+ this.plusOnePosition = false;
100
101
  this.maskExpression = '';
101
102
  this.actualValue = '';
102
103
  this.showKeepCharacterExp = '';
@@ -227,7 +228,7 @@ class NgxMaskApplierService {
227
228
  let backspaceShift = false;
228
229
  let shift = 1;
229
230
  let stepBack = false;
230
- if (inputValue.slice(0, this.prefix.length) === this.prefix && !this.showMaskTyped) {
231
+ if (inputValue.slice(0, this.prefix.length) === this.prefix) {
231
232
  // eslint-disable-next-line no-param-reassign
232
233
  inputValue = inputValue.slice(this.prefix.length, inputValue.length);
233
234
  }
@@ -311,24 +312,91 @@ class NgxMaskApplierService {
311
312
  // eslint-disable-next-line no-param-reassign
312
313
  inputValue = this._stripToDecimal(inputValue);
313
314
  }
314
- // eslint-disable-next-line no-param-reassign
315
- inputValue =
316
- inputValue[0] === '-' && this.allowNegativeNumbers
315
+ const precision = this.getPrecision(maskExpression);
316
+ const decimalMarker = Array.isArray(this.decimalMarker)
317
+ ? "." /* DOT */
318
+ : this.decimalMarker;
319
+ if (precision === 0) {
320
+ // eslint-disable-next-line no-param-reassign
321
+ inputValue = this.allowNegativeNumbers
317
322
  ? inputValue.length > 2 &&
318
- inputValue[1] === '0' &&
323
+ inputValue[0] === "-" /* MINUS */ &&
324
+ inputValue[1] === "0" /* NUMBER_ZERO */ &&
319
325
  inputValue[2] !== this.thousandSeparator &&
320
- !this._compareOrIncludes(inputValue[2], this.decimalMarker, this.thousandSeparator) &&
321
- !backspaced
322
- ? inputValue.slice(0, inputValue.length - 1)
323
- : inputValue
326
+ inputValue[2] !== "," /* COMMA */ &&
327
+ inputValue[2] !== "." /* DOT */
328
+ ? '-' + inputValue.slice(2, inputValue.length)
329
+ : inputValue[0] === "0" /* NUMBER_ZERO */ &&
330
+ inputValue.length > 1 &&
331
+ inputValue[1] !== this.thousandSeparator &&
332
+ inputValue[1] !== "," /* COMMA */ &&
333
+ inputValue[1] !== "." /* DOT */
334
+ ? inputValue.slice(1, inputValue.length)
335
+ : inputValue
324
336
  : inputValue.length > 1 &&
325
- inputValue[0] === '0' &&
337
+ inputValue[0] === "0" /* NUMBER_ZERO */ &&
326
338
  inputValue[1] !== this.thousandSeparator &&
327
- !this._compareOrIncludes(inputValue[1], this.decimalMarker, this.thousandSeparator) &&
328
- !backspaced
329
- ? inputValue.slice(0, inputValue.length - 1)
339
+ inputValue[1] !== "," /* COMMA */ &&
340
+ inputValue[1] !== "." /* DOT */
341
+ ? inputValue.slice(1, inputValue.length)
330
342
  : inputValue;
343
+ }
344
+ else {
345
+ // eslint-disable-next-line no-param-reassign
346
+ if (inputValue[0] === decimalMarker && inputValue.length > 1) {
347
+ // eslint-disable-next-line no-param-reassign
348
+ inputValue =
349
+ "0" /* NUMBER_ZERO */ + inputValue.slice(0, inputValue.length + 1);
350
+ this.plusOnePosition = true;
351
+ }
352
+ if (inputValue[0] === "0" /* NUMBER_ZERO */ &&
353
+ inputValue[1] !== decimalMarker &&
354
+ inputValue[1] !== this.thousandSeparator) {
355
+ // eslint-disable-next-line no-param-reassign
356
+ inputValue =
357
+ inputValue.length > 1
358
+ ? inputValue.slice(0, 1) +
359
+ decimalMarker +
360
+ inputValue.slice(1, inputValue.length + 1)
361
+ : inputValue;
362
+ this.plusOnePosition = true;
363
+ }
364
+ if (this.allowNegativeNumbers &&
365
+ inputValue[0] === "-" /* MINUS */ &&
366
+ (inputValue[1] === decimalMarker ||
367
+ inputValue[1] === "0" /* NUMBER_ZERO */)) {
368
+ // eslint-disable-next-line no-param-reassign
369
+ inputValue =
370
+ inputValue[1] === decimalMarker && inputValue.length > 2
371
+ ? inputValue.slice(0, 1) +
372
+ "0" /* NUMBER_ZERO */ +
373
+ inputValue.slice(1, inputValue.length)
374
+ : inputValue[1] === "0" /* NUMBER_ZERO */ &&
375
+ inputValue.length > 2 &&
376
+ inputValue[2] !== decimalMarker
377
+ ? inputValue.slice(0, 2) +
378
+ decimalMarker +
379
+ inputValue.slice(2, inputValue.length)
380
+ : inputValue;
381
+ this.plusOnePosition = true;
382
+ }
383
+ }
331
384
  if (backspaced) {
385
+ if (inputValue[0] === "0" /* NUMBER_ZERO */ &&
386
+ inputValue[1] === this.decimalMarker &&
387
+ (inputValue[position] === "0" /* NUMBER_ZERO */ ||
388
+ inputValue[position] === this.decimalMarker)) {
389
+ // eslint-disable-next-line no-param-reassign
390
+ inputValue = inputValue.slice(2, inputValue.length);
391
+ }
392
+ if (inputValue[0] === "-" /* MINUS */ &&
393
+ inputValue[1] === "0" /* NUMBER_ZERO */ &&
394
+ inputValue[2] === this.decimalMarker &&
395
+ (inputValue[position] === "0" /* NUMBER_ZERO */ ||
396
+ inputValue[position] === this.decimalMarker)) {
397
+ // eslint-disable-next-line no-param-reassign
398
+ inputValue = "-" /* MINUS */ + inputValue.slice(3, inputValue.length);
399
+ }
332
400
  // eslint-disable-next-line no-param-reassign
333
401
  inputValue = this._compareOrIncludes(inputValue[inputValue.length - 1], this.decimalMarker, this.thousandSeparator)
334
402
  ? inputValue.slice(0, inputValue.length - 1)
@@ -348,13 +416,10 @@ class NgxMaskApplierService {
348
416
  invalidChars = invalidChars.replace(this._charToRegExpExpression(this.decimalMarker), '');
349
417
  }
350
418
  const invalidCharRegexp = new RegExp('[' + invalidChars + ']');
351
- if (inputValue.match(invalidCharRegexp) ||
352
- (inputValue.length === 1 &&
353
- this._compareOrIncludes(inputValue, this.decimalMarker, this.thousandSeparator))) {
419
+ if (inputValue.match(invalidCharRegexp)) {
354
420
  // eslint-disable-next-line no-param-reassign
355
421
  inputValue = inputValue.substring(0, inputValue.length - 1);
356
422
  }
357
- const precision = this.getPrecision(maskExpression);
358
423
  // eslint-disable-next-line no-param-reassign
359
424
  inputValue = this.checkInputPrecision(inputValue, precision, this.decimalMarker);
360
425
  const strForSep = inputValue.replace(new RegExp(thousandSeparatorCharEscaped, 'g'), '');
@@ -427,7 +492,7 @@ class NgxMaskApplierService {
427
492
  if (maskExpression[cursor] === "H" /* HOURS */) {
428
493
  if (this.apm ? Number(inputSymbol) > 9 : Number(inputSymbol) > 2) {
429
494
  // eslint-disable-next-line no-param-reassign
430
- position = position + 1;
495
+ position = !this.leadZeroDateTime ? position + 1 : position;
431
496
  cursor += 1;
432
497
  this._shiftStep(maskExpression, cursor, inputArray.length);
433
498
  i--;
@@ -463,7 +528,7 @@ class NgxMaskApplierService {
463
528
  maskExpression[cursor] === "s" /* SECOND */) {
464
529
  if (Number(inputSymbol) > 5) {
465
530
  // eslint-disable-next-line no-param-reassign
466
- position = position + 1;
531
+ position = !this.leadZeroDateTime ? position + 1 : position;
467
532
  cursor += 1;
468
533
  this._shiftStep(maskExpression, cursor, inputArray.length);
469
534
  i--;
@@ -501,7 +566,7 @@ class NgxMaskApplierService {
501
566
  : Number(inputValueSliceCursorPlusTwo) > daysCount ||
502
567
  this.specialCharacters.includes(inputValueCursorPlusOne))) {
503
568
  // eslint-disable-next-line no-param-reassign
504
- position = position + 1;
569
+ position = !this.leadZeroDateTime ? position + 1 : position;
505
570
  cursor += 1;
506
571
  this._shiftStep(maskExpression, cursor, inputArray.length);
507
572
  i--;
@@ -557,7 +622,7 @@ class NgxMaskApplierService {
557
622
  day2monthInput ||
558
623
  (day2monthInputDot && !this.leadZeroDateTime)) {
559
624
  // eslint-disable-next-line no-param-reassign
560
- position = position + 1;
625
+ position = !this.leadZeroDateTime ? position + 1 : position;
561
626
  cursor += 1;
562
627
  this._shiftStep(maskExpression, cursor, inputArray.length);
563
628
  i--;
@@ -651,7 +716,7 @@ class NgxMaskApplierService {
651
716
  if (backspaced) {
652
717
  onlySpecial = inputArray.every((char) => this.specialCharacters.includes(char));
653
718
  }
654
- let res = `${this.prefix}${onlySpecial ? "" /* EMPTY_STRING */ : result}${this.suffix}`;
719
+ let res = `${this.prefix}${onlySpecial ? "" /* EMPTY_STRING */ : result}${this.showMaskTyped ? '' : this.suffix}`;
655
720
  if (result.length === 0) {
656
721
  res = !this.dropSpecialCharacters ? `${this.prefix}${result}` : `${result}`;
657
722
  }
@@ -784,7 +849,7 @@ class NgxMaskService extends NgxMaskApplierService {
784
849
  applyMask(inputValue, maskExpression, position = 0, justPasted = false, backspaced = false,
785
850
  // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any
786
851
  cb = () => { }) {
787
- var _a;
852
+ var _a, _b;
788
853
  if (!maskExpression) {
789
854
  return inputValue !== this.actualValue ? this.actualValue : inputValue;
790
855
  }
@@ -799,7 +864,7 @@ class NgxMaskService extends NgxMaskApplierService {
799
864
  }
800
865
  if (!inputValue && this.showMaskTyped) {
801
866
  this.formControlResult(this.prefix);
802
- return this.prefix + this.maskIsShown;
867
+ return this.prefix + this.maskIsShown + this.suffix;
803
868
  }
804
869
  const getSymbol = !!inputValue && typeof this.selStart === 'number'
805
870
  ? (_a = inputValue[this.selStart]) !== null && _a !== void 0 ? _a : "" /* EMPTY_STRING */
@@ -845,6 +910,11 @@ class NgxMaskService extends NgxMaskApplierService {
845
910
  if (justPasted && (this.hiddenInput || !this.hiddenInput)) {
846
911
  newInputValue = inputValue;
847
912
  }
913
+ if (backspaced &&
914
+ this.specialCharacters.indexOf((_b = this.maskExpression[position]) !== null && _b !== void 0 ? _b : "" /* EMPTY_STRING */) !== -1 &&
915
+ this.showMaskTyped) {
916
+ newInputValue = this._currentValue;
917
+ }
848
918
  if (this.deletedSpecialCharacter && position) {
849
919
  if (this.specialCharacters.includes(this.actualValue.slice(position, position + 1))) {
850
920
  // eslint-disable-next-line no-param-reassign
@@ -913,7 +983,7 @@ class NgxMaskService extends NgxMaskApplierService {
913
983
  return result;
914
984
  }
915
985
  const resLen = result.length;
916
- const prefNmask = this.prefix + this.maskIsShown;
986
+ const prefNmask = this.prefix + this.maskIsShown + this.suffix;
917
987
  if (this.maskExpression.includes("H" /* HOURS */)) {
918
988
  const countSkipedSymbol = this._numberSkipedSymbols(result);
919
989
  return result + prefNmask.slice(resLen + countSkipedSymbol);
@@ -1233,11 +1303,17 @@ class NgxMaskService extends NgxMaskApplierService {
1233
1303
  return value ? value.replace(this.suffix, "" /* EMPTY_STRING */) : value;
1234
1304
  }
1235
1305
  _retrieveSeparatorValue(result) {
1236
- const specialCharacters = Array.isArray(this.dropSpecialCharacters)
1306
+ let specialCharacters = Array.isArray(this.dropSpecialCharacters)
1237
1307
  ? this.specialCharacters.filter((v) => {
1238
1308
  return this.dropSpecialCharacters.includes(v);
1239
1309
  })
1240
1310
  : this.specialCharacters;
1311
+ if (!this.deletedSpecialCharacter &&
1312
+ this._checkPatternForSpace() &&
1313
+ result.includes(" " /* WHITE_SPACE */) &&
1314
+ this.maskExpression.includes("*" /* SYMBOL_STAR */)) {
1315
+ specialCharacters = specialCharacters.filter((char) => char !== " " /* WHITE_SPACE */);
1316
+ }
1241
1317
  return this._removeMask(result, specialCharacters);
1242
1318
  }
1243
1319
  _regExpForRemove(specialCharactersForRemove) {
@@ -1276,6 +1352,21 @@ class NgxMaskService extends NgxMaskApplierService {
1276
1352
  return separatorValue;
1277
1353
  }
1278
1354
  }
1355
+ _checkPatternForSpace() {
1356
+ var _a, _b, _c;
1357
+ for (const key in this.patterns) {
1358
+ // eslint-disable-next-line no-prototype-builtins
1359
+ if (this.patterns[key] && ((_a = this.patterns[key]) === null || _a === void 0 ? void 0 : _a.hasOwnProperty('pattern'))) {
1360
+ const patternString = (_b = this.patterns[key]) === null || _b === void 0 ? void 0 : _b.pattern.toString();
1361
+ const pattern = (_c = this.patterns[key]) === null || _c === void 0 ? void 0 : _c.pattern;
1362
+ if ((patternString === null || patternString === void 0 ? void 0 : patternString.includes(" " /* WHITE_SPACE */)) &&
1363
+ (pattern === null || pattern === void 0 ? void 0 : pattern.test(this.maskExpression))) {
1364
+ return true;
1365
+ }
1366
+ }
1367
+ }
1368
+ return false;
1369
+ }
1279
1370
  // TODO should think about helpers or separting decimal precision to own property
1280
1371
  _retrieveSeparatorPrecision(maskExpretion) {
1281
1372
  const matcher = maskExpretion.match(new RegExp(`^separator\\.([^d]*)`));
@@ -1379,6 +1470,7 @@ class NgxMaskDirective {
1379
1470
  this.keepCharacterPositions = null;
1380
1471
  this.maskFilled = new EventEmitter();
1381
1472
  this._maskValue = '';
1473
+ this._isFocused = false;
1382
1474
  this._position = null;
1383
1475
  this._maskExpressionArray = [];
1384
1476
  this._justPasted = false;
@@ -1396,13 +1488,6 @@ class NgxMaskDirective {
1396
1488
  !maskExpression.firstChange) {
1397
1489
  this._maskService.maskChanged = true;
1398
1490
  }
1399
- if (allowNegativeNumbers) {
1400
- this._maskService.allowNegativeNumbers = allowNegativeNumbers.currentValue;
1401
- if (this._maskService.allowNegativeNumbers) {
1402
- this._maskService.specialCharacters =
1403
- this._maskService.specialCharacters.filter((c) => c !== "-" /* MINUS */);
1404
- }
1405
- }
1406
1491
  if (maskExpression.currentValue &&
1407
1492
  maskExpression.currentValue.split("||" /* OR */).length > 1) {
1408
1493
  this._maskExpressionArray = maskExpression.currentValue
@@ -1426,6 +1511,12 @@ class NgxMaskDirective {
1426
1511
  this._maskService.specialCharacters = specialCharacters.currentValue || [];
1427
1512
  }
1428
1513
  }
1514
+ if (allowNegativeNumbers) {
1515
+ this._maskService.allowNegativeNumbers = allowNegativeNumbers.currentValue;
1516
+ if (this._maskService.allowNegativeNumbers) {
1517
+ this._maskService.specialCharacters = this._maskService.specialCharacters.filter((c) => c !== "-" /* MINUS */);
1518
+ }
1519
+ }
1429
1520
  // Only overwrite the mask available patterns if a pattern has actually been passed in
1430
1521
  if (patterns && patterns.currentValue) {
1431
1522
  this._maskService.patterns = patterns.currentValue;
@@ -1453,6 +1544,14 @@ class NgxMaskDirective {
1453
1544
  }
1454
1545
  if (showMaskTyped) {
1455
1546
  this._maskService.showMaskTyped = showMaskTyped.currentValue;
1547
+ if (showMaskTyped.previousValue === false &&
1548
+ showMaskTyped.currentValue === true &&
1549
+ this._isFocused) {
1550
+ requestAnimationFrame(() => {
1551
+ var _a;
1552
+ (_a = this._maskService._elementRef) === null || _a === void 0 ? void 0 : _a.nativeElement.click();
1553
+ });
1554
+ }
1456
1555
  }
1457
1556
  if (placeHolderCharacter) {
1458
1557
  this._maskService.placeHolderCharacter = placeHolderCharacter.currentValue;
@@ -1612,6 +1711,9 @@ class NgxMaskDirective {
1612
1711
  onPaste() {
1613
1712
  this._justPasted = true;
1614
1713
  }
1714
+ onFocus() {
1715
+ this._isFocused = true;
1716
+ }
1615
1717
  onModelChange(value) {
1616
1718
  // on form reset we need to update the actualValue
1617
1719
  if ((value === "" /* EMPTY_STRING */ || value === null || value === undefined) &&
@@ -1620,7 +1722,7 @@ class NgxMaskDirective {
1620
1722
  }
1621
1723
  }
1622
1724
  onInput(e) {
1623
- var _a, _b, _c, _d;
1725
+ var _a, _b, _c, _d, _e;
1624
1726
  // If IME is composing text, we wait for the composed text.
1625
1727
  if (this._isComposing)
1626
1728
  return;
@@ -1711,13 +1813,32 @@ class NgxMaskDirective {
1711
1813
  position = position + 1;
1712
1814
  }
1713
1815
  else if (checkSymbols) {
1816
+ if (el.value.length === 1 && position === 1) {
1817
+ this._maskService.actualValue =
1818
+ this.prefix +
1819
+ inputSymbol +
1820
+ this._maskService.maskIsShown.slice(1, this._maskService.maskIsShown.length) +
1821
+ this.suffix;
1822
+ }
1823
+ else {
1824
+ this._maskService.actualValue =
1825
+ el.value.slice(0, position - 1) +
1826
+ inputSymbol +
1827
+ el.value
1828
+ .slice(position + 1)
1829
+ .split(this.suffix)
1830
+ .join('') +
1831
+ this.suffix;
1832
+ }
1833
+ }
1834
+ else if (this.prefix &&
1835
+ el.value.length === 1 &&
1836
+ position - prefixLength === 1 &&
1837
+ this._maskService._checkSymbolMask(el.value, (_e = this._maskService.maskExpression[position - 1 - prefixLength]) !== null && _e !== void 0 ? _e : "" /* EMPTY_STRING */)) {
1714
1838
  this._maskService.actualValue =
1715
- el.value.slice(0, position - 1) +
1716
- inputSymbol +
1717
- el.value
1718
- .slice(position + 1)
1719
- .split(this.suffix)
1720
- .join('') +
1839
+ this.prefix +
1840
+ el.value +
1841
+ this._maskService.maskIsShown.slice(1, this._maskService.maskIsShown.length) +
1721
1842
  this.suffix;
1722
1843
  }
1723
1844
  }
@@ -1737,6 +1858,13 @@ class NgxMaskDirective {
1737
1858
  inputSymbol +
1738
1859
  this._inputValue.slice(position + 1);
1739
1860
  }
1861
+ if (this._maskService.maskExpression === "d0/M0/0000" /* DAYS_MONTHS_YEARS */ &&
1862
+ this.leadZeroDateTime) {
1863
+ if ((position < 3 && Number(el.value) > 31 && Number(el.value) < 40) ||
1864
+ (position === 5 && Number(el.value.slice(3, 5)) > 12)) {
1865
+ position = position + 2;
1866
+ }
1867
+ }
1740
1868
  if (this._maskService.maskExpression === "Hh:m0:s0" /* HOURS_MINUTES_SECONDS */ &&
1741
1869
  this.apm) {
1742
1870
  if (this._justPasted && el.value.slice(0, 2) === "00" /* DOUBLE_ZERO */) {
@@ -1756,6 +1884,10 @@ class NgxMaskDirective {
1756
1884
  if (this._getActiveElement() !== el) {
1757
1885
  return;
1758
1886
  }
1887
+ if (this._maskService.plusOnePosition) {
1888
+ position = position + 1;
1889
+ this._maskService.plusOnePosition = false;
1890
+ }
1759
1891
  // update position after applyValueChanges to prevent cursor on wrong position when it has an array of maskExpression
1760
1892
  if (this._maskExpressionArray.length) {
1761
1893
  if (this._code === "Backspace" /* BACKSPACE */) {
@@ -1777,7 +1909,10 @@ class NgxMaskDirective {
1777
1909
  : position +
1778
1910
  (this._code === "Backspace" /* BACKSPACE */ && !backspaceShift ? 0 : caretShift);
1779
1911
  if (positionToApply > this._getActualInputLength()) {
1780
- positionToApply = this._getActualInputLength();
1912
+ positionToApply =
1913
+ el.value === this._maskService.decimalMarker && el.value.length === 1
1914
+ ? this._getActualInputLength() + 1
1915
+ : this._getActualInputLength();
1781
1916
  }
1782
1917
  if (positionToApply < 0) {
1783
1918
  positionToApply = 0;
@@ -1790,6 +1925,10 @@ class NgxMaskDirective {
1790
1925
  }
1791
1926
  }
1792
1927
  else {
1928
+ if (!this._maskValue) {
1929
+ this.onChange(el.value);
1930
+ return;
1931
+ }
1793
1932
  this._maskService.applyValueChanges(el.value.length, this._justPasted, this._code === "Backspace" /* BACKSPACE */ || this._code === "Delete" /* DELETE */);
1794
1933
  }
1795
1934
  }
@@ -1825,6 +1964,7 @@ class NgxMaskDirective {
1825
1964
  }
1826
1965
  this._maskService.clearIfNotMatchFn();
1827
1966
  }
1967
+ this._isFocused = false;
1828
1968
  this.onTouch();
1829
1969
  }
1830
1970
  onClick(e) {
@@ -1958,7 +2098,6 @@ class NgxMaskDirective {
1958
2098
  }
1959
2099
  }
1960
2100
  /** It writes the value in the input */
1961
- // public async writeValue(controlValue: unknown): Promise<void> {
1962
2101
  writeValue(controlValue) {
1963
2102
  var _a;
1964
2103
  return __awaiter(this, void 0, void 0, function* () {
@@ -1966,7 +2105,7 @@ class NgxMaskDirective {
1966
2105
  if ('disable' in controlValue) {
1967
2106
  this.setDisabledState(Boolean(controlValue.disable));
1968
2107
  }
1969
- // // eslint-disable-next-line no-param-reassign
2108
+ // eslint-disable-next-line no-param-reassign
1970
2109
  controlValue = controlValue.value;
1971
2110
  }
1972
2111
  if (controlValue !== null) {
@@ -1977,7 +2116,12 @@ class NgxMaskDirective {
1977
2116
  }
1978
2117
  if (typeof controlValue === 'string' ||
1979
2118
  typeof controlValue === 'number' ||
1980
- controlValue === null) {
2119
+ controlValue === null ||
2120
+ controlValue === undefined) {
2121
+ if (controlValue === null || controlValue === undefined || controlValue === '') {
2122
+ this._maskService._currentValue = '';
2123
+ this._maskService._previousValue = '';
2124
+ }
1981
2125
  // eslint-disable-next-line no-param-reassign
1982
2126
  let inputValue = controlValue;
1983
2127
  if (typeof inputValue === 'number' ||
@@ -2133,7 +2277,8 @@ class NgxMaskDirective {
2133
2277
  }
2134
2278
  }
2135
2279
  else {
2136
- const check = (_d = this._inputValue) === null || _d === void 0 ? void 0 : _d.split("" /* EMPTY_STRING */).every((character, index) => {
2280
+ const check = (_d = this._maskService
2281
+ .removeMask(this._inputValue)) === null || _d === void 0 ? void 0 : _d.split("" /* EMPTY_STRING */).every((character, index) => {
2137
2282
  const indexMask = mask.charAt(index);
2138
2283
  return this._maskService._checkSymbolMask(character, indexMask);
2139
2284
  });
@@ -2146,7 +2291,7 @@ class NgxMaskDirective {
2146
2291
  }
2147
2292
  }
2148
2293
  NgxMaskDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: NgxMaskDirective, deps: [{ token: DOCUMENT }, { token: NGX_MASK_CONFIG }, { token: NgxMaskService }], target: i0.ɵɵFactoryTarget.Directive });
2149
- NgxMaskDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: NgxMaskDirective, selector: "input[mask], textarea[mask]", inputs: { maskExpression: ["mask", "maskExpression"], specialCharacters: "specialCharacters", patterns: "patterns", prefix: "prefix", suffix: "suffix", thousandSeparator: "thousandSeparator", decimalMarker: "decimalMarker", dropSpecialCharacters: "dropSpecialCharacters", hiddenInput: "hiddenInput", showMaskTyped: "showMaskTyped", placeHolderCharacter: "placeHolderCharacter", shownMaskExpression: "shownMaskExpression", showTemplate: "showTemplate", clearIfNotMatch: "clearIfNotMatch", validation: "validation", separatorLimit: "separatorLimit", allowNegativeNumbers: "allowNegativeNumbers", leadZeroDateTime: "leadZeroDateTime", leadZero: "leadZero", triggerOnMaskChange: "triggerOnMaskChange", apm: "apm", inputTransformFn: "inputTransformFn", outputTransformFn: "outputTransformFn", keepCharacterPositions: "keepCharacterPositions" }, outputs: { maskFilled: "maskFilled" }, host: { listeners: { "paste": "onPaste()", "ngModelChange": "onModelChange($event)", "input": "onInput($event)", "compositionstart": "onCompositionStart($event)", "compositionend": "onCompositionEnd($event)", "blur": "onBlur($event)", "click": "onClick($event)", "keydown": "onKeyDown($event)" } }, providers: [
2294
+ NgxMaskDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: NgxMaskDirective, selector: "input[mask], textarea[mask]", inputs: { maskExpression: ["mask", "maskExpression"], specialCharacters: "specialCharacters", patterns: "patterns", prefix: "prefix", suffix: "suffix", thousandSeparator: "thousandSeparator", decimalMarker: "decimalMarker", dropSpecialCharacters: "dropSpecialCharacters", hiddenInput: "hiddenInput", showMaskTyped: "showMaskTyped", placeHolderCharacter: "placeHolderCharacter", shownMaskExpression: "shownMaskExpression", showTemplate: "showTemplate", clearIfNotMatch: "clearIfNotMatch", validation: "validation", separatorLimit: "separatorLimit", allowNegativeNumbers: "allowNegativeNumbers", leadZeroDateTime: "leadZeroDateTime", leadZero: "leadZero", triggerOnMaskChange: "triggerOnMaskChange", apm: "apm", inputTransformFn: "inputTransformFn", outputTransformFn: "outputTransformFn", keepCharacterPositions: "keepCharacterPositions" }, outputs: { maskFilled: "maskFilled" }, host: { listeners: { "paste": "onPaste()", "focus": "onFocus($event)", "ngModelChange": "onModelChange($event)", "input": "onInput($event)", "compositionstart": "onCompositionStart($event)", "compositionend": "onCompositionEnd($event)", "blur": "onBlur($event)", "click": "onClick($event)", "keydown": "onKeyDown($event)" } }, providers: [
2150
2295
  {
2151
2296
  provide: NG_VALUE_ACCESSOR,
2152
2297
  useExisting: forwardRef(() => NgxMaskDirective),
@@ -2240,6 +2385,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
2240
2385
  }], onPaste: [{
2241
2386
  type: HostListener,
2242
2387
  args: ['paste']
2388
+ }], onFocus: [{
2389
+ type: HostListener,
2390
+ args: ['focus', ['$event']]
2243
2391
  }], onModelChange: [{
2244
2392
  type: HostListener,
2245
2393
  args: ['ngModelChange', ['$event']]
@@ -2326,6 +2474,9 @@ class NgxMaskPipe {
2326
2474
  }
2327
2475
  this._maskService.isNumberValue = true;
2328
2476
  }
2477
+ if (value === null || value === undefined) {
2478
+ return this._maskService.applyMask('', mask);
2479
+ }
2329
2480
  return this._maskService.applyMask(`${value}`, mask);
2330
2481
  }
2331
2482
  _setMask(value) {