ngx-mask 14.2.2 → 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('');
@@ -1394,8 +1398,7 @@ class MaskDirective {
1394
1398
  this._inputValue = inputValue;
1395
1399
  }
1396
1400
  registerOnChange(fn) {
1397
- this.onChange = fn;
1398
- this._maskService.onChange = this.onChange;
1401
+ this._maskService.onChange = this.onChange = fn;
1399
1402
  }
1400
1403
  registerOnTouched(fn) {
1401
1404
  this.onTouch = fn;