ngx-mask 14.2.1 → 14.2.3

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.
@@ -266,9 +266,10 @@ class MaskApplierService {
266
266
  inputValue =
267
267
  inputValue.length > 1 &&
268
268
  inputValue[0] === '0' &&
269
+ inputValue[1] !== this.thousandSeparator &&
269
270
  !this._compareOrIncludes(inputValue[1], this.decimalMarker, this.thousandSeparator) &&
270
271
  !backspaced
271
- ? inputValue.slice(1, inputValue.length)
272
+ ? inputValue.slice(0, inputValue.length - 1)
272
273
  : inputValue;
273
274
  if (backspaced) {
274
275
  // eslint-disable-next-line no-param-reassign
@@ -549,10 +550,13 @@ class MaskApplierService {
549
550
  return str
550
551
  .split('')
551
552
  .filter((i, idx) => {
553
+ const isDecimalMarker = typeof this.decimalMarker === 'string'
554
+ ? i === this.decimalMarker
555
+ : // TODO (inepipenko) use utility type
556
+ this.decimalMarker.includes(i);
552
557
  return (i.match('^-?\\d') ||
553
- i.match('\\s') ||
554
- i === '.' ||
555
- i === ',' ||
558
+ i === this.thousandSeparator ||
559
+ isDecimalMarker ||
556
560
  (i === '-' && idx === 0 && this.allowNegativeNumbers));
557
561
  })
558
562
  .join('');
@@ -660,6 +664,10 @@ class MaskService extends MaskApplierService {
660
664
  ? this.shiftTypedSymbols(actualResult.join(''))
661
665
  : inputValue;
662
666
  }
667
+ if (this.showMaskTyped) {
668
+ // eslint-disable-next-line no-param-reassign
669
+ inputValue = this.removeMask(inputValue);
670
+ }
663
671
  newInputValue = Boolean(newInputValue) && newInputValue.length ? newInputValue : inputValue;
664
672
  const result = super.applyMask(newInputValue, maskExpression, position, justPasted, backspaced, cb);
665
673
  this.actualValue = this.getActualValue(result);
@@ -1390,8 +1398,7 @@ class MaskDirective {
1390
1398
  this._inputValue = inputValue;
1391
1399
  }
1392
1400
  registerOnChange(fn) {
1393
- this.onChange = fn;
1394
- this._maskService.onChange = this.onChange;
1401
+ this._maskService.onChange = this.onChange = fn;
1395
1402
  }
1396
1403
  registerOnTouched(fn) {
1397
1404
  this.onTouch = fn;