ngx-mask 19.0.1 → 19.0.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.
@@ -282,7 +282,9 @@ class NgxMaskApplierService {
282
282
  : processedValue;
283
283
  }
284
284
  else {
285
- if (processedValue[0] === decimalMarker && processedValue.length > 1) {
285
+ if (processedValue[0] === decimalMarker &&
286
+ processedValue.length > 1 &&
287
+ !backspaced) {
286
288
  processedValue =
287
289
  MaskExpression.NUMBER_ZERO +
288
290
  processedValue.slice(0, processedValue.length + 1);
@@ -323,11 +325,18 @@ class NgxMaskApplierService {
323
325
  const positionOfZeroOrDecimalMarker = processedValue[processedPosition] === MaskExpression.NUMBER_ZERO ||
324
326
  processedValue[processedPosition] === decimalMarker;
325
327
  const zeroIndexNumberZero = processedValue[0] === MaskExpression.NUMBER_ZERO;
328
+ const firstIndexNumberZero = processedValue[1] === MaskExpression.NUMBER_ZERO;
326
329
  const zeroIndexMinus = processedValue[0] === MaskExpression.MINUS;
327
330
  const zeroIndexThousand = processedValue[0] === this.thousandSeparator;
328
331
  const firstIndexDecimalMarker = processedValue[1] === decimalMarker;
329
- const firstIndexNumberZero = processedValue[1] === MaskExpression.NUMBER_ZERO;
332
+ const zeroIndexDecimalMarker = processedValue[0] === decimalMarker;
330
333
  const secondIndexDecimalMarker = processedValue[2] === decimalMarker;
334
+ if (zeroIndexNumberZero && firstIndexDecimalMarker && processedPosition === 0) {
335
+ return processedValue;
336
+ }
337
+ if (zeroIndexDecimalMarker && processedPosition === 0) {
338
+ processedValue = inputValueAfterZero;
339
+ }
331
340
  if (zeroIndexNumberZero &&
332
341
  firstIndexDecimalMarker &&
333
342
  positionOfZeroOrDecimalMarker &&
@@ -856,10 +865,10 @@ class NgxMaskApplierService {
856
865
  }
857
866
  return -1;
858
867
  }
859
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxMaskApplierService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
860
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxMaskApplierService });
868
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskApplierService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
869
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskApplierService });
861
870
  }
862
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxMaskApplierService, decorators: [{
871
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskApplierService, decorators: [{
863
872
  type: Injectable
864
873
  }] });
865
874
 
@@ -1249,7 +1258,7 @@ class NgxMaskService extends NgxMaskApplierService {
1249
1258
  }
1250
1259
  formControlResult(inputValue) {
1251
1260
  if (this.writingValue && !inputValue) {
1252
- this.onChange('');
1261
+ this.onChange(this.outputTransformFn(''));
1253
1262
  return;
1254
1263
  }
1255
1264
  if (this.writingValue || (!this.triggerOnMaskChange && this.maskChanged)) {
@@ -1342,7 +1351,9 @@ class NgxMaskService extends NgxMaskApplierService {
1342
1351
  processedResult = processedResult.replace(MaskExpression.COMMA, MaskExpression.DOT);
1343
1352
  }
1344
1353
  const separatorPrecision = this._retrieveSeparatorPrecision(this.maskExpression);
1345
- const separatorValue = this._replaceDecimalMarkerToDot(this._retrieveSeparatorValue(processedResult));
1354
+ const separatorValue = this.specialCharacters.length === 0
1355
+ ? this._retrieveSeparatorValue(processedResult)
1356
+ : this._replaceDecimalMarkerToDot(this._retrieveSeparatorValue(processedResult));
1346
1357
  if (!this.isNumberValue) {
1347
1358
  return separatorValue;
1348
1359
  }
@@ -1419,10 +1430,10 @@ class NgxMaskService extends NgxMaskApplierService {
1419
1430
  currentLocaleDecimalMarker() {
1420
1431
  return (1.1).toLocaleString().substring(1, 2);
1421
1432
  }
1422
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxMaskService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
1423
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxMaskService });
1433
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
1434
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskService });
1424
1435
  }
1425
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxMaskService, decorators: [{
1436
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskService, decorators: [{
1426
1437
  type: Injectable
1427
1438
  }] });
1428
1439
 
@@ -1484,7 +1495,6 @@ class NgxMaskDirective {
1484
1495
  _position = signal(null);
1485
1496
  _code = signal('');
1486
1497
  _maskExpressionArray = signal([]);
1487
- _allowFewMaskChangeMask = signal(false);
1488
1498
  _justPasted = signal(false);
1489
1499
  _isFocused = signal(false);
1490
1500
  _isComposing = signal(false);
@@ -1875,10 +1885,11 @@ class NgxMaskDirective {
1875
1885
  if (this._maskExpressionArray().length) {
1876
1886
  if (this._code() === MaskExpression.BACKSPACE) {
1877
1887
  const specialChartMinusOne = this.specialCharacters().includes(this._maskService.actualValue.slice(position - 1, position));
1888
+ const allowFewMaskChangeMask = this._maskService.removeMask(this._inputValue())?.length ===
1889
+ this._maskService.removeMask(this._maskService.maskExpression)?.length;
1878
1890
  const specialChartPlusOne = this.specialCharacters().includes(this._maskService.actualValue.slice(position, position + 1));
1879
- if (this._allowFewMaskChangeMask() && !specialChartPlusOne) {
1891
+ if (allowFewMaskChangeMask && !specialChartPlusOne) {
1880
1892
  position = el.selectionStart + 1;
1881
- this._allowFewMaskChangeMask.set(false);
1882
1893
  }
1883
1894
  else {
1884
1895
  position = specialChartMinusOne ? position - 1 : position;
@@ -2237,9 +2248,6 @@ class NgxMaskDirective {
2237
2248
  return test;
2238
2249
  }
2239
2250
  else {
2240
- if (this._code() === MaskExpression.BACKSPACE) {
2241
- this._allowFewMaskChangeMask.set(true);
2242
- }
2243
2251
  const expression = this._maskExpressionArray()[this._maskExpressionArray().length - 1] ??
2244
2252
  MaskExpression.EMPTY_STRING;
2245
2253
  const maskValue = expression.includes(MaskExpression.CURLY_BRACKETS_LEFT)
@@ -2277,8 +2285,8 @@ class NgxMaskDirective {
2277
2285
  return uniqueCharacters.size === 1;
2278
2286
  });
2279
2287
  }
2280
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxMaskDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2281
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: NgxMaskDirective, isStandalone: true, selector: "input[mask], textarea[mask]", inputs: { mask: { classPropertyName: "mask", publicName: "mask", isSignal: true, isRequired: false, transformFunction: null }, specialCharacters: { classPropertyName: "specialCharacters", publicName: "specialCharacters", isSignal: true, isRequired: false, transformFunction: null }, patterns: { classPropertyName: "patterns", publicName: "patterns", isSignal: true, isRequired: false, transformFunction: null }, prefix: { classPropertyName: "prefix", publicName: "prefix", isSignal: true, isRequired: false, transformFunction: null }, suffix: { classPropertyName: "suffix", publicName: "suffix", isSignal: true, isRequired: false, transformFunction: null }, thousandSeparator: { classPropertyName: "thousandSeparator", publicName: "thousandSeparator", isSignal: true, isRequired: false, transformFunction: null }, decimalMarker: { classPropertyName: "decimalMarker", publicName: "decimalMarker", isSignal: true, isRequired: false, transformFunction: null }, dropSpecialCharacters: { classPropertyName: "dropSpecialCharacters", publicName: "dropSpecialCharacters", isSignal: true, isRequired: false, transformFunction: null }, hiddenInput: { classPropertyName: "hiddenInput", publicName: "hiddenInput", isSignal: true, isRequired: false, transformFunction: null }, showMaskTyped: { classPropertyName: "showMaskTyped", publicName: "showMaskTyped", isSignal: true, isRequired: false, transformFunction: null }, placeHolderCharacter: { classPropertyName: "placeHolderCharacter", publicName: "placeHolderCharacter", isSignal: true, isRequired: false, transformFunction: null }, shownMaskExpression: { classPropertyName: "shownMaskExpression", publicName: "shownMaskExpression", isSignal: true, isRequired: false, transformFunction: null }, clearIfNotMatch: { classPropertyName: "clearIfNotMatch", publicName: "clearIfNotMatch", isSignal: true, isRequired: false, transformFunction: null }, validation: { classPropertyName: "validation", publicName: "validation", isSignal: true, isRequired: false, transformFunction: null }, separatorLimit: { classPropertyName: "separatorLimit", publicName: "separatorLimit", isSignal: true, isRequired: false, transformFunction: null }, allowNegativeNumbers: { classPropertyName: "allowNegativeNumbers", publicName: "allowNegativeNumbers", isSignal: true, isRequired: false, transformFunction: null }, leadZeroDateTime: { classPropertyName: "leadZeroDateTime", publicName: "leadZeroDateTime", isSignal: true, isRequired: false, transformFunction: null }, leadZero: { classPropertyName: "leadZero", publicName: "leadZero", isSignal: true, isRequired: false, transformFunction: null }, triggerOnMaskChange: { classPropertyName: "triggerOnMaskChange", publicName: "triggerOnMaskChange", isSignal: true, isRequired: false, transformFunction: null }, apm: { classPropertyName: "apm", publicName: "apm", isSignal: true, isRequired: false, transformFunction: null }, inputTransformFn: { classPropertyName: "inputTransformFn", publicName: "inputTransformFn", isSignal: true, isRequired: false, transformFunction: null }, outputTransformFn: { classPropertyName: "outputTransformFn", publicName: "outputTransformFn", isSignal: true, isRequired: false, transformFunction: null }, keepCharacterPositions: { classPropertyName: "keepCharacterPositions", publicName: "keepCharacterPositions", isSignal: true, isRequired: false, transformFunction: null } }, 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: [
2288
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2289
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.3", type: NgxMaskDirective, isStandalone: true, selector: "input[mask], textarea[mask]", inputs: { mask: { classPropertyName: "mask", publicName: "mask", isSignal: true, isRequired: false, transformFunction: null }, specialCharacters: { classPropertyName: "specialCharacters", publicName: "specialCharacters", isSignal: true, isRequired: false, transformFunction: null }, patterns: { classPropertyName: "patterns", publicName: "patterns", isSignal: true, isRequired: false, transformFunction: null }, prefix: { classPropertyName: "prefix", publicName: "prefix", isSignal: true, isRequired: false, transformFunction: null }, suffix: { classPropertyName: "suffix", publicName: "suffix", isSignal: true, isRequired: false, transformFunction: null }, thousandSeparator: { classPropertyName: "thousandSeparator", publicName: "thousandSeparator", isSignal: true, isRequired: false, transformFunction: null }, decimalMarker: { classPropertyName: "decimalMarker", publicName: "decimalMarker", isSignal: true, isRequired: false, transformFunction: null }, dropSpecialCharacters: { classPropertyName: "dropSpecialCharacters", publicName: "dropSpecialCharacters", isSignal: true, isRequired: false, transformFunction: null }, hiddenInput: { classPropertyName: "hiddenInput", publicName: "hiddenInput", isSignal: true, isRequired: false, transformFunction: null }, showMaskTyped: { classPropertyName: "showMaskTyped", publicName: "showMaskTyped", isSignal: true, isRequired: false, transformFunction: null }, placeHolderCharacter: { classPropertyName: "placeHolderCharacter", publicName: "placeHolderCharacter", isSignal: true, isRequired: false, transformFunction: null }, shownMaskExpression: { classPropertyName: "shownMaskExpression", publicName: "shownMaskExpression", isSignal: true, isRequired: false, transformFunction: null }, clearIfNotMatch: { classPropertyName: "clearIfNotMatch", publicName: "clearIfNotMatch", isSignal: true, isRequired: false, transformFunction: null }, validation: { classPropertyName: "validation", publicName: "validation", isSignal: true, isRequired: false, transformFunction: null }, separatorLimit: { classPropertyName: "separatorLimit", publicName: "separatorLimit", isSignal: true, isRequired: false, transformFunction: null }, allowNegativeNumbers: { classPropertyName: "allowNegativeNumbers", publicName: "allowNegativeNumbers", isSignal: true, isRequired: false, transformFunction: null }, leadZeroDateTime: { classPropertyName: "leadZeroDateTime", publicName: "leadZeroDateTime", isSignal: true, isRequired: false, transformFunction: null }, leadZero: { classPropertyName: "leadZero", publicName: "leadZero", isSignal: true, isRequired: false, transformFunction: null }, triggerOnMaskChange: { classPropertyName: "triggerOnMaskChange", publicName: "triggerOnMaskChange", isSignal: true, isRequired: false, transformFunction: null }, apm: { classPropertyName: "apm", publicName: "apm", isSignal: true, isRequired: false, transformFunction: null }, inputTransformFn: { classPropertyName: "inputTransformFn", publicName: "inputTransformFn", isSignal: true, isRequired: false, transformFunction: null }, outputTransformFn: { classPropertyName: "outputTransformFn", publicName: "outputTransformFn", isSignal: true, isRequired: false, transformFunction: null }, keepCharacterPositions: { classPropertyName: "keepCharacterPositions", publicName: "keepCharacterPositions", isSignal: true, isRequired: false, transformFunction: null } }, 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: [
2282
2290
  {
2283
2291
  provide: NG_VALUE_ACCESSOR,
2284
2292
  useExisting: NgxMaskDirective,
@@ -2292,7 +2300,7 @@ class NgxMaskDirective {
2292
2300
  NgxMaskService,
2293
2301
  ], exportAs: ["mask", "ngxMask"], usesOnChanges: true, ngImport: i0 });
2294
2302
  }
2295
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxMaskDirective, decorators: [{
2303
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskDirective, decorators: [{
2296
2304
  type: Directive,
2297
2305
  args: [{
2298
2306
  selector: 'input[mask], textarea[mask]',
@@ -2425,10 +2433,10 @@ class NgxMaskPipe {
2425
2433
  });
2426
2434
  }
2427
2435
  }
2428
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxMaskPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2429
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.0.0", ngImport: i0, type: NgxMaskPipe, isStandalone: true, name: "mask" });
2436
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2437
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskPipe, isStandalone: true, name: "mask" });
2430
2438
  }
2431
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgxMaskPipe, decorators: [{
2439
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskPipe, decorators: [{
2432
2440
  type: Pipe,
2433
2441
  args: [{
2434
2442
  name: 'mask',