ngx-mask 14.2.3 → 14.2.4

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.
@@ -91,7 +91,7 @@ class MaskApplierService {
91
91
  this.actualValue = '';
92
92
  this.shownMaskExpression = '';
93
93
  this._formatWithSeparators = (str, thousandSeparatorChar, decimalChars, precision) => {
94
- var _a, _b;
94
+ var _a, _b, _c;
95
95
  let x = [];
96
96
  let decimalChar = '';
97
97
  if (Array.isArray(decimalChars)) {
@@ -104,7 +104,7 @@ class MaskApplierService {
104
104
  decimalChar = decimalChars;
105
105
  }
106
106
  const decimals = x.length > 1 ? `${decimalChar}${x[1]}` : '';
107
- let res = x[0];
107
+ let res = (_c = x[0]) !== null && _c !== void 0 ? _c : '';
108
108
  const separatorLimit = this.separatorLimit.replace(/\s/g, '');
109
109
  if (separatorLimit && +separatorLimit) {
110
110
  if (res[0] === '-') {
@@ -124,7 +124,7 @@ class MaskApplierService {
124
124
  else if (precision === 0) {
125
125
  return res;
126
126
  }
127
- return res + decimals.substr(0, precision + 1);
127
+ return res + decimals.substring(0, precision + 1);
128
128
  };
129
129
  this.percentage = (str) => {
130
130
  return Number(str) >= 0 && Number(str) <= 100;
@@ -137,17 +137,20 @@ class MaskApplierService {
137
137
  return Infinity;
138
138
  };
139
139
  this.checkAndRemoveSuffix = (inputValue) => {
140
- var _a, _b, _c;
140
+ var _a, _b, _c, _d;
141
141
  for (let i = ((_a = this.suffix) === null || _a === void 0 ? void 0 : _a.length) - 1; i >= 0; i--) {
142
- const substr = this.suffix.substr(i, (_b = this.suffix) === null || _b === void 0 ? void 0 : _b.length);
142
+ const substr = this.suffix.substring(i, (_b = this.suffix) === null || _b === void 0 ? void 0 : _b.length);
143
143
  if (inputValue.includes(substr) &&
144
- (i - 1 < 0 || !inputValue.includes(this.suffix.substr(i - 1, (_c = this.suffix) === null || _c === void 0 ? void 0 : _c.length)))) {
144
+ i !== ((_c = this.suffix) === null || _c === void 0 ? void 0 : _c.length) - 1 &&
145
+ (i - 1 < 0 ||
146
+ !inputValue.includes(this.suffix.substring(i - 1, (_d = this.suffix) === null || _d === void 0 ? void 0 : _d.length)))) {
145
147
  return inputValue.replace(substr, '');
146
148
  }
147
149
  }
148
150
  return inputValue;
149
151
  };
150
152
  this.checkInputPrecision = (inputValue, precision, decimalMarker) => {
153
+ var _a, _b, _c;
151
154
  if (precision < Infinity) {
152
155
  // TODO need think about decimalMarker
153
156
  if (Array.isArray(decimalMarker)) {
@@ -156,9 +159,10 @@ class MaskApplierService {
156
159
  decimalMarker = marker ? marker : decimalMarker[0];
157
160
  }
158
161
  const precisionRegEx = new RegExp(this._charToRegExpExpression(decimalMarker) + `\\d{${precision}}.*$`);
159
- const precisionMatch = inputValue.match(precisionRegEx);
160
- if (precisionMatch && precisionMatch[0].length - 1 > precision) {
161
- const diff = precisionMatch[0].length - 1 - precision;
162
+ const precisionMatch = (_a = inputValue.match(precisionRegEx)) !== null && _a !== void 0 ? _a : [];
163
+ const precisionMatchLength = (_c = (_b = precisionMatch[0]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
164
+ if (precisionMatchLength - 1 > precision) {
165
+ const diff = precisionMatchLength - 1 - precision;
162
166
  // eslint-disable-next-line no-param-reassign
163
167
  inputValue = inputValue.substring(0, inputValue.length - diff);
164
168
  }
@@ -192,8 +196,10 @@ class MaskApplierService {
192
196
  this.customPattern = customPattern;
193
197
  return this.applyMask(inputValue, mask);
194
198
  }
195
- applyMask(inputValue, maskExpression, position = 0, justPasted = false, backspaced = false, cb = () => { }) {
196
- var _a, _b;
199
+ applyMask(inputValue, maskExpression, position = 0, justPasted = false, backspaced = false,
200
+ // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any
201
+ cb = () => { }) {
202
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
197
203
  if (!maskExpression || typeof inputValue !== 'string') {
198
204
  return '';
199
205
  }
@@ -221,7 +227,7 @@ class MaskApplierService {
221
227
  const arr = [];
222
228
  for (let i = 0; i < inputValue.length; i++) {
223
229
  if ((_a = inputValue[i]) === null || _a === void 0 ? void 0 : _a.match('\\d')) {
224
- arr.push(inputValue[i]);
230
+ arr.push((_b = inputValue[i]) !== null && _b !== void 0 ? _b : '');
225
231
  }
226
232
  }
227
233
  if (maskExpression === 'CPF_CNPJ') {
@@ -237,6 +243,7 @@ class MaskApplierService {
237
243
  }
238
244
  if (maskExpression.startsWith('percent')) {
239
245
  if (inputValue.match('[a-z]|[A-Z]') ||
246
+ // eslint-disable-next-line no-useless-escape
240
247
  inputValue.match(/[-!$%^&*()_+|~=`{}\[\]:";'<>?,\/.]/)) {
241
248
  // eslint-disable-next-line no-param-reassign
242
249
  inputValue = this._stripToDecimal(inputValue);
@@ -261,7 +268,7 @@ class MaskApplierService {
261
268
  if (inputValue.match('[wа-яА-Я]') ||
262
269
  inputValue.match('[ЁёА-я]') ||
263
270
  inputValue.match('[a-z]|[A-Z]') ||
264
- inputValue.match(/[-@#!$%\\^&*()_£¬'+|~=`{}\[\]:";<>.?\/]/) ||
271
+ inputValue.match(/[-@#!$%\\^&*()_£¬'+|~=`{}\]:";<>.?/]/) ||
265
272
  inputValue.match('[^A-Za-z0-9,]')) {
266
273
  // eslint-disable-next-line no-param-reassign
267
274
  inputValue = this._stripToDecimal(inputValue);
@@ -316,7 +323,9 @@ class MaskApplierService {
316
323
  _shift++;
317
324
  } while (_shift < shiftStep);
318
325
  }
319
- else if ((commaShift !== 0 && position > 0 && !(result.indexOf(',') >= position && position > 3)) ||
326
+ else if ((commaShift !== 0 &&
327
+ position > 0 &&
328
+ !(result.indexOf(',') >= position && position > 3)) ||
320
329
  (!(result.indexOf('.') >= position && position > 3) && shiftStep <= 0)) {
321
330
  this._shift.clear();
322
331
  backspaceShift = true;
@@ -332,33 +341,33 @@ class MaskApplierService {
332
341
  else {
333
342
  for (
334
343
  // eslint-disable-next-line
335
- let i = 0, inputSymbol = inputArray[0]; i < inputArray.length; i++, inputSymbol = inputArray[i]) {
344
+ let i = 0, inputSymbol = inputArray[0]; i < inputArray.length; i++, inputSymbol = (_c = inputArray[i]) !== null && _c !== void 0 ? _c : '') {
336
345
  if (cursor === maskExpression.length) {
337
346
  break;
338
347
  }
339
- if (this._checkSymbolMask(inputSymbol, maskExpression[cursor]) &&
348
+ if (this._checkSymbolMask(inputSymbol, (_d = maskExpression[cursor]) !== null && _d !== void 0 ? _d : '') &&
340
349
  maskExpression[cursor + 1] === '?') {
341
350
  result += inputSymbol;
342
351
  cursor += 2;
343
352
  }
344
353
  else if (maskExpression[cursor + 1] === '*' &&
345
354
  multi &&
346
- this._checkSymbolMask(inputSymbol, maskExpression[cursor + 2])) {
355
+ this._checkSymbolMask(inputSymbol, (_e = maskExpression[cursor + 2]) !== null && _e !== void 0 ? _e : '')) {
347
356
  result += inputSymbol;
348
357
  cursor += 3;
349
358
  multi = false;
350
359
  }
351
- else if (this._checkSymbolMask(inputSymbol, maskExpression[cursor]) &&
360
+ else if (this._checkSymbolMask(inputSymbol, (_f = maskExpression[cursor]) !== null && _f !== void 0 ? _f : '') &&
352
361
  maskExpression[cursor + 1] === '*') {
353
362
  result += inputSymbol;
354
363
  multi = true;
355
364
  }
356
365
  else if (maskExpression[cursor + 1] === '?' &&
357
- this._checkSymbolMask(inputSymbol, maskExpression[cursor + 2])) {
366
+ this._checkSymbolMask(inputSymbol, (_g = maskExpression[cursor + 2]) !== null && _g !== void 0 ? _g : '')) {
358
367
  result += inputSymbol;
359
368
  cursor += 3;
360
369
  }
361
- else if (this._checkSymbolMask(inputSymbol, maskExpression[cursor])) {
370
+ else if (this._checkSymbolMask(inputSymbol, (_h = maskExpression[cursor]) !== null && _h !== void 0 ? _h : '')) {
362
371
  if (maskExpression[cursor] === 'H') {
363
372
  if (Number(inputSymbol) > 2) {
364
373
  cursor += 1;
@@ -468,15 +477,15 @@ class MaskApplierService {
468
477
  result += inputSymbol;
469
478
  cursor++;
470
479
  }
471
- else if (this.maskSpecialCharacters.indexOf(maskExpression[cursor]) !== -1) {
480
+ else if (this.maskSpecialCharacters.indexOf((_j = maskExpression[cursor]) !== null && _j !== void 0 ? _j : '') !== -1) {
472
481
  result += maskExpression[cursor];
473
482
  cursor++;
474
483
  this._shiftStep(maskExpression, cursor, inputArray.length);
475
484
  i--;
476
485
  }
477
486
  else if (this.maskSpecialCharacters.indexOf(inputSymbol) > -1 &&
478
- this.maskAvailablePatterns[maskExpression[cursor]] &&
479
- ((_b = this.maskAvailablePatterns[maskExpression[cursor]]) === null || _b === void 0 ? void 0 : _b.optional)) {
487
+ this.maskAvailablePatterns[(_k = maskExpression[cursor]) !== null && _k !== void 0 ? _k : ''] &&
488
+ ((_m = this.maskAvailablePatterns[(_l = maskExpression[cursor]) !== null && _l !== void 0 ? _l : '']) === null || _m === void 0 ? void 0 : _m.optional)) {
480
489
  if (!!inputArray[cursor] &&
481
490
  maskExpression !== '099.099.099.099' &&
482
491
  maskExpression !== '000.000.000-00' &&
@@ -488,14 +497,14 @@ class MaskApplierService {
488
497
  i--;
489
498
  }
490
499
  else if (this.maskExpression[cursor + 1] === '*' &&
491
- this._findSpecialChar(this.maskExpression[cursor + 2]) &&
500
+ this._findSpecialChar((_o = this.maskExpression[cursor + 2]) !== null && _o !== void 0 ? _o : '') &&
492
501
  this._findSpecialChar(inputSymbol) === this.maskExpression[cursor + 2] &&
493
502
  multi) {
494
503
  cursor += 3;
495
504
  result += inputSymbol;
496
505
  }
497
506
  else if (this.maskExpression[cursor + 1] === '?' &&
498
- this._findSpecialChar(this.maskExpression[cursor + 2]) &&
507
+ this._findSpecialChar((_p = this.maskExpression[cursor + 2]) !== null && _p !== void 0 ? _p : '') &&
499
508
  this._findSpecialChar(inputSymbol) === this.maskExpression[cursor + 2] &&
500
509
  multi) {
501
510
  cursor += 3;
@@ -509,7 +518,8 @@ class MaskApplierService {
509
518
  }
510
519
  }
511
520
  if (result.length + 1 === maskExpression.length &&
512
- this.maskSpecialCharacters.indexOf(maskExpression[maskExpression.length - 1]) !== -1) {
521
+ this.maskSpecialCharacters.indexOf((_q = maskExpression[maskExpression.length - 1]) !== null && _q !== void 0 ? _q : '') !==
522
+ -1) {
513
523
  result += maskExpression[maskExpression.length - 1];
514
524
  }
515
525
  let newPosition = position + 1;
@@ -543,12 +553,12 @@ class MaskApplierService {
543
553
  return this.maskSpecialCharacters.find((val) => val === inputSymbol);
544
554
  }
545
555
  _checkSymbolMask(inputSymbol, maskSymbol) {
556
+ var _a, _b, _c;
546
557
  this.maskAvailablePatterns = this.customPattern
547
558
  ? this.customPattern
548
559
  : this.maskAvailablePatterns;
549
- return (this.maskAvailablePatterns[maskSymbol] &&
550
- this.maskAvailablePatterns[maskSymbol].pattern &&
551
- this.maskAvailablePatterns[maskSymbol].pattern.test(inputSymbol));
560
+ return ((_c = (((_a = this.maskAvailablePatterns[maskSymbol]) === null || _a === void 0 ? void 0 : _a.pattern) &&
561
+ ((_b = this.maskAvailablePatterns[maskSymbol]) === null || _b === void 0 ? void 0 : _b.pattern.test(inputSymbol)))) !== null && _c !== void 0 ? _c : false);
552
562
  }
553
563
  _stripToDecimal(str) {
554
564
  return str
@@ -576,7 +586,9 @@ class MaskApplierService {
576
586
  return char;
577
587
  }
578
588
  _shiftStep(maskExpression, cursor, inputLength) {
579
- const shiftStep = /[*?]/g.test(maskExpression.slice(0, cursor)) ? inputLength : cursor;
589
+ const shiftStep = /[*?]/g.test(maskExpression.slice(0, cursor))
590
+ ? inputLength
591
+ : cursor;
580
592
  this._shift.add(shiftStep + this.prefix.length || 0);
581
593
  }
582
594
  _compareOrIncludes(value, comparedValue, excludedValue) {
@@ -594,9 +606,9 @@ class MaskApplierService {
594
606
  }));
595
607
  }
596
608
  }
597
- MaskApplierService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: MaskApplierService, deps: [{ token: config }], target: i0.ɵɵFactoryTarget.Injectable });
598
- MaskApplierService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: MaskApplierService });
599
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: MaskApplierService, decorators: [{
609
+ MaskApplierService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: MaskApplierService, deps: [{ token: config }], target: i0.ɵɵFactoryTarget.Injectable });
610
+ MaskApplierService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: MaskApplierService });
611
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: MaskApplierService, decorators: [{
600
612
  type: Injectable
601
613
  }], ctorParameters: function () {
602
614
  return [{ type: undefined, decorators: [{
@@ -625,10 +637,14 @@ class MaskService extends MaskApplierService {
625
637
  this.writingValue = false;
626
638
  this.maskChanged = false;
627
639
  this.triggerOnMaskChange = false;
640
+ // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any
628
641
  this.onChange = (_) => { };
629
642
  }
630
643
  // eslint-disable-next-line complexity
631
- applyMask(inputValue, maskExpression, position = 0, justPasted = false, backspaced = false, cb = () => { }) {
644
+ applyMask(inputValue, maskExpression, position = 0, justPasted = false, backspaced = false,
645
+ // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any
646
+ cb = () => { }) {
647
+ var _a;
632
648
  if (!maskExpression) {
633
649
  return inputValue !== this.actualValue ? this.actualValue : inputValue;
634
650
  }
@@ -643,7 +659,9 @@ class MaskService extends MaskApplierService {
643
659
  this.formControlResult(this.prefix);
644
660
  return this.prefix + this.maskIsShown;
645
661
  }
646
- const getSymbol = !!inputValue && typeof this.selStart === 'number' ? inputValue[this.selStart] : '';
662
+ const getSymbol = !!inputValue && typeof this.selStart === 'number'
663
+ ? (_a = inputValue[this.selStart]) !== null && _a !== void 0 ? _a : ''
664
+ : '';
647
665
  let newInputValue = '';
648
666
  if (this.hiddenInput !== undefined && !this.writingValue) {
649
667
  let actualResult = this.actualValue.split('');
@@ -684,12 +702,15 @@ class MaskService extends MaskApplierService {
684
702
  }
685
703
  // b) remove decimal marker from list of special characters to mask
686
704
  if (this.maskExpression.startsWith('separator') && this.dropSpecialCharacters === true) {
687
- this.maskSpecialCharacters = this.maskSpecialCharacters.filter((item) => !this._compareOrIncludes(item, this.decimalMarker, this.thousandSeparator));
705
+ this.maskSpecialCharacters = this.maskSpecialCharacters.filter((item) => !this._compareOrIncludes(item, this.decimalMarker, this.thousandSeparator) //item !== this.decimalMarker, // !
706
+ );
688
707
  }
689
708
  this.formControlResult(result);
690
709
  if (!this.showMaskTyped) {
691
710
  if (this.hiddenInput) {
692
- return result && result.length ? this.hideInput(result, this.maskExpression) : result;
711
+ return result && result.length
712
+ ? this.hideInput(result, this.maskExpression)
713
+ : result;
693
714
  }
694
715
  return result;
695
716
  }
@@ -715,7 +736,9 @@ class MaskService extends MaskApplierService {
715
736
  }
716
737
  return countSkipedSymbol;
717
738
  }
718
- applyValueChanges(position, justPasted, backspaced, cb = () => { }) {
739
+ applyValueChanges(position, justPasted, backspaced,
740
+ // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any
741
+ cb = () => { }) {
719
742
  const formElement = this._elementRef.nativeElement;
720
743
  formElement.value = this.applyMask(formElement.value, this.maskExpression, position, justPasted, backspaced, cb);
721
744
  if (formElement === this._getActiveElement()) {
@@ -727,11 +750,11 @@ class MaskService extends MaskApplierService {
727
750
  return inputValue
728
751
  .split('')
729
752
  .map((curr, index) => {
730
- var _a, _b;
753
+ var _a, _b, _c, _d, _e;
731
754
  if (this.maskAvailablePatterns &&
732
- this.maskAvailablePatterns[maskExpression[index]] &&
733
- ((_a = this.maskAvailablePatterns[maskExpression[index]]) === null || _a === void 0 ? void 0 : _a.symbol)) {
734
- return (_b = this.maskAvailablePatterns[maskExpression[index]]) === null || _b === void 0 ? void 0 : _b.symbol;
755
+ this.maskAvailablePatterns[(_a = maskExpression[index]) !== null && _a !== void 0 ? _a : ''] &&
756
+ ((_c = this.maskAvailablePatterns[(_b = maskExpression[index]) !== null && _b !== void 0 ? _b : '']) === null || _c === void 0 ? void 0 : _c.symbol)) {
757
+ return (_e = this.maskAvailablePatterns[(_d = maskExpression[index]) !== null && _d !== void 0 ? _d : '']) === null || _e === void 0 ? void 0 : _e.symbol;
735
758
  }
736
759
  return curr;
737
760
  })
@@ -739,11 +762,12 @@ class MaskService extends MaskApplierService {
739
762
  }
740
763
  // this function is not necessary, it checks result against maskExpression
741
764
  getActualValue(res) {
742
- const compare = res
743
- .split('')
744
- .filter((symbol, i) => this._checkSymbolMask(symbol, this.maskExpression[i]) ||
745
- (this.maskSpecialCharacters.includes(this.maskExpression[i]) &&
746
- symbol === this.maskExpression[i]));
765
+ const compare = res.split('').filter((symbol, i) => {
766
+ var _a;
767
+ const maskChar = (_a = this.maskExpression[i]) !== null && _a !== void 0 ? _a : '';
768
+ return (this._checkSymbolMask(symbol, maskChar) ||
769
+ (this.maskSpecialCharacters.includes(maskChar) && symbol === maskChar));
770
+ });
747
771
  if (compare.join('') === res) {
748
772
  return compare.join('');
749
773
  }
@@ -753,7 +777,8 @@ class MaskService extends MaskApplierService {
753
777
  let symbolToReplace = '';
754
778
  const newInputValue = (inputValue &&
755
779
  inputValue.split('').map((currSymbol, index) => {
756
- if (this.maskSpecialCharacters.includes(inputValue[index + 1]) &&
780
+ var _a;
781
+ if (this.maskSpecialCharacters.includes((_a = inputValue[index + 1]) !== null && _a !== void 0 ? _a : '') &&
757
782
  inputValue[index + 1] !== this.maskExpression[index + 1]) {
758
783
  symbolToReplace = currSymbol;
759
784
  return inputValue[index + 1];
@@ -817,7 +842,9 @@ class MaskService extends MaskApplierService {
817
842
  Promise.resolve().then(() => this._renderer.setProperty(this._elementRef.nativeElement, name, value));
818
843
  }
819
844
  checkSpecialCharAmount(mask) {
820
- const chars = mask.split('').filter((item) => this._findSpecialChar(item));
845
+ const chars = mask
846
+ .split('')
847
+ .filter((item) => this._findSpecialChar(item));
821
848
  return chars.length;
822
849
  }
823
850
  removeMask(inputValue) {
@@ -830,8 +857,12 @@ class MaskService extends MaskApplierService {
830
857
  }
831
858
  const arr = [];
832
859
  for (let i = 0; i < inputVal.length; i++) {
833
- if ((_a = inputVal[i]) === null || _a === void 0 ? void 0 : _a.match('\\d')) {
834
- arr.push(inputVal[i]);
860
+ const value = (_a = inputVal[i]) !== null && _a !== void 0 ? _a : '';
861
+ if (!value) {
862
+ continue;
863
+ }
864
+ if (value.match('\\d')) {
865
+ arr.push(value);
835
866
  }
836
867
  }
837
868
  if (arr.length <= 3) {
@@ -864,8 +895,12 @@ class MaskService extends MaskApplierService {
864
895
  }
865
896
  const arr = [];
866
897
  for (let i = 0; i < inputVal.length; i++) {
867
- if ((_a = inputVal[i]) === null || _a === void 0 ? void 0 : _a.match('\\d')) {
868
- arr.push(inputVal[i]);
898
+ const value = (_a = inputVal[i]) !== null && _a !== void 0 ? _a : '';
899
+ if (!value) {
900
+ continue;
901
+ }
902
+ if (value.match('\\d')) {
903
+ arr.push(value);
869
904
  }
870
905
  }
871
906
  if (arr.length <= 3) {
@@ -958,7 +993,9 @@ class MaskService extends MaskApplierService {
958
993
  return new RegExp(specialCharactersForRemove.map((item) => `\\${item}`).join('|'), 'gi');
959
994
  }
960
995
  _replaceDecimalMarkerToDot(value) {
961
- const markers = Array.isArray(this.decimalMarker) ? this.decimalMarker : [this.decimalMarker];
996
+ const markers = Array.isArray(this.decimalMarker)
997
+ ? this.decimalMarker
998
+ : [this.decimalMarker];
962
999
  return value.replace(this._regExpForRemove(markers), '.');
963
1000
  }
964
1001
  _checkSymbols(result) {
@@ -992,12 +1029,12 @@ class MaskService extends MaskApplierService {
992
1029
  return Number(separatorValue);
993
1030
  }
994
1031
  }
995
- MaskService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: MaskService, deps: [{ token: DOCUMENT }, { token: config }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Injectable });
996
- MaskService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: MaskService });
997
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: MaskService, decorators: [{
1032
+ MaskService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: MaskService, deps: [{ token: DOCUMENT }, { token: config }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Injectable });
1033
+ MaskService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: MaskService });
1034
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: MaskService, decorators: [{
998
1035
  type: Injectable
999
1036
  }], ctorParameters: function () {
1000
- return [{ type: undefined, decorators: [{
1037
+ return [{ type: Document, decorators: [{
1001
1038
  type: Inject,
1002
1039
  args: [DOCUMENT]
1003
1040
  }] }, { type: undefined, decorators: [{
@@ -1036,7 +1073,9 @@ class MaskDirective {
1036
1073
  this._position = null;
1037
1074
  this._maskExpressionArray = [];
1038
1075
  this._justPasted = false;
1076
+ // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any
1039
1077
  this.onChange = (_) => { };
1078
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
1040
1079
  this.onTouch = () => { };
1041
1080
  }
1042
1081
  ngOnChanges(changes) {
@@ -1114,7 +1153,8 @@ class MaskDirective {
1114
1153
  if (allowNegativeNumbers) {
1115
1154
  this._maskService.allowNegativeNumbers = allowNegativeNumbers.currentValue;
1116
1155
  if (this._maskService.allowNegativeNumbers) {
1117
- this._maskService.maskSpecialCharacters = this._maskService.maskSpecialCharacters.filter((c) => c !== '-');
1156
+ this._maskService.maskSpecialCharacters =
1157
+ this._maskService.maskSpecialCharacters.filter((c) => c !== '-');
1118
1158
  }
1119
1159
  }
1120
1160
  if (leadZeroDateTime) {
@@ -1127,6 +1167,7 @@ class MaskDirective {
1127
1167
  }
1128
1168
  // eslint-disable-next-line complexity
1129
1169
  validate({ value }) {
1170
+ var _a, _b;
1130
1171
  if (!this._maskService.validation || !this._maskValue) {
1131
1172
  return null;
1132
1173
  }
@@ -1151,7 +1192,7 @@ class MaskDirective {
1151
1192
  if (value && value.toString().length >= 1) {
1152
1193
  let counterOfOpt = 0;
1153
1194
  for (const key in this._maskService.maskAvailablePatterns) {
1154
- if (this._maskService.maskAvailablePatterns[key].optional) {
1195
+ if ((_a = this._maskService.maskAvailablePatterns[key]) === null || _a === void 0 ? void 0 : _a.optional) {
1155
1196
  if (this._maskValue.indexOf(key) !== this._maskValue.lastIndexOf(key)) {
1156
1197
  const opt = this._maskValue
1157
1198
  .split('')
@@ -1173,7 +1214,9 @@ class MaskDirective {
1173
1214
  }
1174
1215
  if (this._maskValue.indexOf('{') === 1 &&
1175
1216
  value.toString().length ===
1176
- this._maskValue.length + Number(this._maskValue.split('{')[1].split('}')[0]) - 4) {
1217
+ this._maskValue.length +
1218
+ Number(((_b = this._maskValue.split('{')[1]) !== null && _b !== void 0 ? _b : '').split('}')[0]) -
1219
+ 4) {
1177
1220
  return null;
1178
1221
  }
1179
1222
  if (this._maskValue.indexOf('*') === 1 || this._maskValue.indexOf('?') === 1) {
@@ -1208,7 +1251,8 @@ class MaskDirective {
1208
1251
  }
1209
1252
  onModelChange(value) {
1210
1253
  // on form reset we need to update the actualValue
1211
- if ((value === '' || value === null || value === undefined) && this._maskService.actualValue) {
1254
+ if ((value === '' || value === null || value === undefined) &&
1255
+ this._maskService.actualValue) {
1212
1256
  this._maskService.actualValue = this._maskService.getActualValue('');
1213
1257
  }
1214
1258
  }
@@ -1234,7 +1278,8 @@ class MaskDirective {
1234
1278
  if (this._getActiveElement() !== el) {
1235
1279
  return;
1236
1280
  }
1237
- this._position = this._position === 1 && this._inputValue.length === 1 ? null : this._position;
1281
+ this._position =
1282
+ this._position === 1 && this._inputValue.length === 1 ? null : this._position;
1238
1283
  let positionToApply = this._position
1239
1284
  ? this._inputValue.length + position + caretShift
1240
1285
  : position + (this._code === 'Backspace' && !backspaceShift ? 0 : caretShift);
@@ -1284,27 +1329,29 @@ class MaskDirective {
1284
1329
  }
1285
1330
  }
1286
1331
  }
1287
- const nextValue = !el.value || el.value === this._maskService.prefix
1288
- ? this._maskService.prefix + this._maskService.maskIsShown
1289
- : el.value;
1332
+ const nextValue = el &&
1333
+ (!el.value || el.value === this._maskService.prefix
1334
+ ? this._maskService.prefix + this._maskService.maskIsShown
1335
+ : el.value);
1290
1336
  /** Fix of cursor position jumping to end in most browsers no matter where cursor is inserted onFocus */
1291
- if (el.value !== nextValue) {
1337
+ if (el && el.value !== nextValue) {
1292
1338
  el.value = nextValue;
1293
1339
  }
1294
1340
  /** fix of cursor position with prefix when mouse click occur */
1295
- if ((el.selectionStart || el.selectionEnd) <=
1296
- this._maskService.prefix.length) {
1341
+ if (el &&
1342
+ (el.selectionStart || el.selectionEnd) <=
1343
+ this._maskService.prefix.length) {
1297
1344
  el.selectionStart = this._maskService.prefix.length;
1298
1345
  return;
1299
1346
  }
1300
1347
  /** select only inserted text */
1301
- if (el.selectionEnd > this._getActualInputLength()) {
1348
+ if (el && el.selectionEnd > this._getActualInputLength()) {
1302
1349
  el.selectionEnd = this._getActualInputLength();
1303
1350
  }
1304
1351
  }
1305
1352
  // eslint-disable-next-line complexity
1306
1353
  onKeyDown(e) {
1307
- var _a;
1354
+ var _a, _b;
1308
1355
  if (!this._maskValue) {
1309
1356
  return;
1310
1357
  }
@@ -1330,8 +1377,9 @@ class MaskDirective {
1330
1377
  else {
1331
1378
  if (this._inputValue.length !== el.selectionStart &&
1332
1379
  el.selectionStart !== 1) {
1333
- while (this.specialCharacters.includes(this._inputValue[el.selectionStart - 1].toString()) &&
1334
- ((this.prefix.length >= 1 && el.selectionStart > this.prefix.length) ||
1380
+ while (this.specialCharacters.includes(((_b = this._inputValue[el.selectionStart - 1]) !== null && _b !== void 0 ? _b : '').toString()) &&
1381
+ ((this.prefix.length >= 1 &&
1382
+ el.selectionStart > this.prefix.length) ||
1335
1383
  this.prefix.length === 0)) {
1336
1384
  el.setSelectionRange(el.selectionStart - 1, el.selectionEnd);
1337
1385
  }
@@ -1384,7 +1432,9 @@ class MaskDirective {
1384
1432
  if (!Array.isArray(this.decimalMarker)) {
1385
1433
  // eslint-disable-next-line no-param-reassign
1386
1434
  inputValue =
1387
- this.decimalMarker !== '.' ? inputValue.replace('.', this.decimalMarker) : inputValue;
1435
+ this.decimalMarker !== '.'
1436
+ ? inputValue.replace('.', this.decimalMarker)
1437
+ : inputValue;
1388
1438
  }
1389
1439
  this._maskService.isNumberValue = true;
1390
1440
  }
@@ -1397,7 +1447,7 @@ class MaskDirective {
1397
1447
  if ((inputValue && this._maskService.maskExpression) ||
1398
1448
  (this._maskService.maskExpression &&
1399
1449
  (this._maskService.prefix || this._maskService.showMaskTyped))) {
1400
- // Let the service we know we are writing value so that triggering onChange function wont happen during applyMask
1450
+ // Let the service we know we are writing value so that triggering onChange function won't happen during applyMask
1401
1451
  this._maskService.writingValue = true;
1402
1452
  this._maskService.formElementProperty = [
1403
1453
  'value',
@@ -1438,10 +1488,14 @@ class MaskDirective {
1438
1488
  }
1439
1489
  _repeatPatternSymbols(maskExp) {
1440
1490
  return ((maskExp.match(/{[0-9]+}/) &&
1441
- maskExp.split('').reduce((accum, currval, index) => {
1442
- this._start = currval === '{' ? index : this._start;
1443
- if (currval !== '}') {
1444
- return this._maskService._findSpecialChar(currval) ? accum + currval : accum;
1491
+ maskExp
1492
+ .split('')
1493
+ .reduce((accum, currVal, index) => {
1494
+ this._start = currVal === '{' ? index : this._start;
1495
+ if (currVal !== '}') {
1496
+ return this._maskService._findSpecialChar(currVal)
1497
+ ? accum + currVal
1498
+ : accum;
1445
1499
  }
1446
1500
  this._end = index;
1447
1501
  const repeatNumber = Number(maskExp.slice(this._start + 1, this._end));
@@ -1459,11 +1513,14 @@ class MaskDirective {
1459
1513
  ];
1460
1514
  }
1461
1515
  _validateTime(value) {
1462
- const rowMaskLen = this._maskValue.split('').filter((s) => s !== ':').length;
1516
+ var _a;
1517
+ const rowMaskLen = this._maskValue
1518
+ .split('')
1519
+ .filter((s) => s !== ':').length;
1463
1520
  if (!value) {
1464
1521
  return null; // Don't validate empty values to allow for optional form control
1465
1522
  }
1466
- if ((+value[value.length - 1] === 0 && value.length < rowMaskLen) ||
1523
+ if ((+((_a = value[value.length - 1]) !== null && _a !== void 0 ? _a : -1) === 0 && value.length < rowMaskLen) ||
1467
1524
  value.length <= rowMaskLen - 2) {
1468
1525
  return this._createValidationError(value);
1469
1526
  }
@@ -1484,7 +1541,7 @@ class MaskDirective {
1484
1541
  _setMask() {
1485
1542
  if (this._maskExpressionArray.length > 0) {
1486
1543
  this._maskExpressionArray.some((mask) => {
1487
- var _a, _b;
1544
+ var _a, _b, _c;
1488
1545
  const test = ((_a = this._maskService.removeMask(this._inputValue)) === null || _a === void 0 ? void 0 : _a.length) <=
1489
1546
  ((_b = this._maskService.removeMask(mask)) === null || _b === void 0 ? void 0 : _b.length);
1490
1547
  if (this._inputValue && test) {
@@ -1494,17 +1551,18 @@ class MaskDirective {
1494
1551
  return test;
1495
1552
  }
1496
1553
  else {
1497
- this._maskValue = this._maskExpressionArray[this._maskExpressionArray.length - 1];
1498
- this.maskExpression = this._maskExpressionArray[this._maskExpressionArray.length - 1];
1499
- this._maskService.maskExpression =
1500
- this._maskExpressionArray[this._maskExpressionArray.length - 1];
1554
+ const expression = (_c = this._maskExpressionArray[this._maskExpressionArray.length - 1]) !== null && _c !== void 0 ? _c : '';
1555
+ this._maskValue =
1556
+ this.maskExpression =
1557
+ this._maskService.maskExpression =
1558
+ expression;
1501
1559
  }
1502
1560
  });
1503
1561
  }
1504
1562
  }
1505
1563
  }
1506
- MaskDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: MaskDirective, deps: [{ token: DOCUMENT }, { token: MaskService }, { token: config }], target: i0.ɵɵFactoryTarget.Directive });
1507
- MaskDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.1", type: MaskDirective, 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", triggerOnMaskChange: "triggerOnMaskChange" }, outputs: { maskFilled: "maskFilled" }, host: { listeners: { "paste": "onPaste()", "ngModelChange": "onModelChange($event)", "input": "onInput($event)", "blur": "onBlur()", "click": "onClick($event)", "keydown": "onKeyDown($event)" } }, providers: [
1564
+ MaskDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: MaskDirective, deps: [{ token: DOCUMENT }, { token: MaskService }, { token: config }], target: i0.ɵɵFactoryTarget.Directive });
1565
+ MaskDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.8", type: MaskDirective, 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", triggerOnMaskChange: "triggerOnMaskChange" }, outputs: { maskFilled: "maskFilled" }, host: { listeners: { "paste": "onPaste()", "ngModelChange": "onModelChange($event)", "input": "onInput($event)", "blur": "onBlur()", "click": "onClick($event)", "keydown": "onKeyDown($event)" } }, providers: [
1508
1566
  {
1509
1567
  provide: NG_VALUE_ACCESSOR,
1510
1568
  useExisting: forwardRef(() => MaskDirective),
@@ -1517,7 +1575,7 @@ MaskDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version:
1517
1575
  },
1518
1576
  MaskService,
1519
1577
  ], exportAs: ["mask", "ngxMask"], usesOnChanges: true, ngImport: i0 });
1520
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: MaskDirective, decorators: [{
1578
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: MaskDirective, decorators: [{
1521
1579
  type: Directive,
1522
1580
  args: [{
1523
1581
  selector: 'input[mask], textarea[mask]',
@@ -1537,7 +1595,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImpor
1537
1595
  exportAs: 'mask,ngxMask',
1538
1596
  }]
1539
1597
  }], ctorParameters: function () {
1540
- return [{ type: undefined, decorators: [{
1598
+ return [{ type: Document, decorators: [{
1541
1599
  type: Inject,
1542
1600
  args: [DOCUMENT]
1543
1601
  }] }, { type: MaskService }, { type: undefined, decorators: [{
@@ -1622,9 +1680,9 @@ class MaskPipe {
1622
1680
  return this._maskService.applyMaskWithPattern(`${value}`, mask);
1623
1681
  }
1624
1682
  }
1625
- MaskPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: MaskPipe, deps: [{ token: MaskApplierService }], target: i0.ɵɵFactoryTarget.Pipe });
1626
- MaskPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.2.1", ngImport: i0, type: MaskPipe, name: "mask" });
1627
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: MaskPipe, decorators: [{
1683
+ MaskPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: MaskPipe, deps: [{ token: MaskApplierService }], target: i0.ɵɵFactoryTarget.Pipe });
1684
+ MaskPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.2.8", ngImport: i0, type: MaskPipe, name: "mask" });
1685
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: MaskPipe, decorators: [{
1628
1686
  type: Pipe,
1629
1687
  args: [{
1630
1688
  name: 'mask',
@@ -1667,10 +1725,10 @@ class NgxMaskModule {
1667
1725
  };
1668
1726
  }
1669
1727
  }
1670
- NgxMaskModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: NgxMaskModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1671
- NgxMaskModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.1", ngImport: i0, type: NgxMaskModule, declarations: [MaskDirective, MaskPipe], exports: [MaskDirective, MaskPipe] });
1672
- NgxMaskModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: NgxMaskModule });
1673
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: NgxMaskModule, decorators: [{
1728
+ NgxMaskModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1729
+ NgxMaskModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskModule, declarations: [MaskDirective, MaskPipe], exports: [MaskDirective, MaskPipe] });
1730
+ NgxMaskModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskModule });
1731
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskModule, decorators: [{
1674
1732
  type: NgModule,
1675
1733
  args: [{
1676
1734
  exports: [MaskDirective, MaskPipe],
@@ -1689,6 +1747,7 @@ const commonjsGlobal = typeof globalThis !== 'undefined'
1689
1747
  : {};
1690
1748
  (function () {
1691
1749
  if (!commonjsGlobal.KeyboardEvent) {
1750
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
1692
1751
  commonjsGlobal.KeyboardEvent = function (_eventType, _init) { };
1693
1752
  }
1694
1753
  })();