ngx-mask 14.3.0 → 14.3.2-test

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.
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, EventEmitter, inject, Injectable, ElementRef, Renderer2, makeEnvironmentProviders, Directive, Input, Output, HostListener, Pipe } from '@angular/core';
3
- import { DOCUMENT } from '@angular/common';
2
+ import { InjectionToken, EventEmitter, inject, Injectable, ElementRef, Renderer2, forwardRef, Directive, Input, Output, HostListener, Pipe, NgModule } from '@angular/core';
4
3
  import { __awaiter, __rest } from 'tslib';
4
+ import { DOCUMENT } from '@angular/common';
5
5
  import { NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
6
6
 
7
7
  const NGX_MASK_CONFIG = new InjectionToken('ngx-mask config');
@@ -313,13 +313,21 @@ class NgxMaskApplierService {
313
313
  }
314
314
  // eslint-disable-next-line no-param-reassign
315
315
  inputValue =
316
- inputValue.length > 1 &&
317
- inputValue[0] === '0' &&
318
- inputValue[1] !== this.thousandSeparator &&
319
- !this._compareOrIncludes(inputValue[1], this.decimalMarker, this.thousandSeparator) &&
320
- !backspaced
321
- ? inputValue.slice(0, inputValue.length - 1)
322
- : inputValue;
316
+ inputValue[0] === '-' && this.allowNegativeNumbers
317
+ ? inputValue.length > 2 &&
318
+ inputValue[1] === '0' &&
319
+ inputValue[2] !== this.thousandSeparator &&
320
+ !this._compareOrIncludes(inputValue[2], this.decimalMarker, this.thousandSeparator) &&
321
+ !backspaced
322
+ ? inputValue.slice(0, inputValue.length - 1)
323
+ : inputValue
324
+ : inputValue.length > 1 &&
325
+ inputValue[0] === '0' &&
326
+ inputValue[1] !== this.thousandSeparator &&
327
+ !this._compareOrIncludes(inputValue[1], this.decimalMarker, this.thousandSeparator) &&
328
+ !backspaced
329
+ ? inputValue.slice(0, inputValue.length - 1)
330
+ : inputValue;
323
331
  if (backspaced) {
324
332
  // eslint-disable-next-line no-param-reassign
325
333
  inputValue = this._compareOrIncludes(inputValue[inputValue.length - 1], this.decimalMarker, this.thousandSeparator)
@@ -657,6 +665,12 @@ class NgxMaskApplierService {
657
665
  }
658
666
  return res;
659
667
  }
668
+ _findDropSpecialChar(inputSymbol) {
669
+ if (Array.isArray(this.dropSpecialCharacters)) {
670
+ return this.dropSpecialCharacters.find((val) => val === inputSymbol);
671
+ }
672
+ return this._findSpecialChar(inputSymbol);
673
+ }
660
674
  _findSpecialChar(inputSymbol) {
661
675
  return this.specialCharacters.find((val) => val === inputSymbol);
662
676
  }
@@ -730,9 +744,9 @@ class NgxMaskApplierService {
730
744
  }
731
745
  }
732
746
  }
733
- NgxMaskApplierService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NgxMaskApplierService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
734
- NgxMaskApplierService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NgxMaskApplierService });
735
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NgxMaskApplierService, decorators: [{
747
+ NgxMaskApplierService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskApplierService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
748
+ NgxMaskApplierService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskApplierService });
749
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskApplierService, decorators: [{
736
750
  type: Injectable
737
751
  }] });
738
752
 
@@ -877,7 +891,10 @@ class NgxMaskService extends NgxMaskApplierService {
877
891
  if (result || result === '') {
878
892
  this._previousValue = this._currentValue;
879
893
  this._currentValue = result;
880
- this._emitValue = this._previousValue !== this._currentValue || this.maskChanged;
894
+ this._emitValue =
895
+ this._previousValue !== this._currentValue ||
896
+ this.maskChanged ||
897
+ (this._previousValue === this._currentValue && justPasted);
881
898
  }
882
899
  this._emitValue ? this.formControlResult(result) : '';
883
900
  if (!this.showMaskTyped || (this.showMaskTyped && this.hiddenInput)) {
@@ -1044,10 +1061,10 @@ class NgxMaskService extends NgxMaskApplierService {
1044
1061
  }
1045
1062
  Promise.resolve().then(() => { var _a, _b; return (_a = this._renderer) === null || _a === void 0 ? void 0 : _a.setProperty((_b = this._elementRef) === null || _b === void 0 ? void 0 : _b.nativeElement, name, value); });
1046
1063
  }
1047
- checkSpecialCharAmount(mask) {
1064
+ checkDropSpecialCharAmount(mask) {
1048
1065
  const chars = mask
1049
1066
  .split("" /* MaskExpression.EMPTY_STRING */)
1050
- .filter((item) => this._findSpecialChar(item));
1067
+ .filter((item) => this._findDropSpecialChar(item));
1051
1068
  return chars.length;
1052
1069
  }
1053
1070
  removeMask(inputValue) {
@@ -1303,42 +1320,14 @@ class NgxMaskService extends NgxMaskApplierService {
1303
1320
  return (1.1).toLocaleString().substring(1, 2);
1304
1321
  }
1305
1322
  }
1306
- NgxMaskService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NgxMaskService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
1307
- NgxMaskService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NgxMaskService });
1308
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NgxMaskService, decorators: [{
1323
+ NgxMaskService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
1324
+ NgxMaskService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskService });
1325
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskService, decorators: [{
1309
1326
  type: Injectable
1310
1327
  }] });
1311
1328
 
1312
- /**
1313
- * @internal
1314
- */
1315
- function _configFactory() {
1316
- const initConfig = inject(INITIAL_CONFIG);
1317
- const configValue = inject(NEW_CONFIG);
1318
- return configValue instanceof Function
1319
- ? Object.assign(Object.assign({}, initConfig), configValue()) : Object.assign(Object.assign({}, initConfig), configValue);
1320
- }
1321
- function provideNgxMask(configValue) {
1322
- return [
1323
- {
1324
- provide: NEW_CONFIG,
1325
- useValue: configValue,
1326
- },
1327
- {
1328
- provide: INITIAL_CONFIG,
1329
- useValue: initialConfig,
1330
- },
1331
- {
1332
- provide: NGX_MASK_CONFIG,
1333
- useFactory: _configFactory,
1334
- },
1335
- NgxMaskService,
1336
- ];
1337
- }
1338
- function provideEnvironmentNgxMask(configValue) {
1339
- return makeEnvironmentProviders(provideNgxMask(configValue));
1340
- }
1341
-
1329
+ // tslint:disable deprecation
1330
+ // tslint:disable no-input-rename
1342
1331
  class NgxMaskDirective {
1343
1332
  constructor() {
1344
1333
  // eslint-disable-next-line @angular-eslint/no-input-rename
@@ -1552,10 +1541,12 @@ class NgxMaskDirective {
1552
1541
  }
1553
1542
  if (this._maskValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */) === -1 ||
1554
1543
  this._maskValue.indexOf("?" /* MaskExpression.SYMBOL_QUESTION */) === -1) {
1544
+ // eslint-disable-next-line no-param-reassign
1545
+ value = typeof value === 'number' ? String(value) : value;
1555
1546
  const array = this._maskValue.split('*');
1556
1547
  const length = this._maskService.dropSpecialCharacters
1557
1548
  ? this._maskValue.length -
1558
- this._maskService.checkSpecialCharAmount(this._maskValue) -
1549
+ this._maskService.checkDropSpecialCharAmount(this._maskValue) -
1559
1550
  counterOfOpt
1560
1551
  : this.prefix
1561
1552
  ? this._maskValue.length + this.prefix.length - counterOfOpt
@@ -1948,6 +1939,7 @@ class NgxMaskDirective {
1948
1939
  }
1949
1940
  }
1950
1941
  /** It writes the value in the input */
1942
+ // public async writeValue(controlValue: unknown): Promise<void> {
1951
1943
  writeValue(controlValue) {
1952
1944
  var _a;
1953
1945
  return __awaiter(this, void 0, void 0, function* () {
@@ -1955,7 +1947,7 @@ class NgxMaskDirective {
1955
1947
  if ('disable' in controlValue) {
1956
1948
  this.setDisabledState(Boolean(controlValue.disable));
1957
1949
  }
1958
- // eslint-disable-next-line no-param-reassign
1950
+ // // eslint-disable-next-line no-param-reassign
1959
1951
  controlValue = controlValue.value;
1960
1952
  }
1961
1953
  if (controlValue !== null) {
@@ -2134,39 +2126,37 @@ class NgxMaskDirective {
2134
2126
  });
2135
2127
  }
2136
2128
  }
2137
- NgxMaskDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NgxMaskDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2138
- NgxMaskDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.8", type: NgxMaskDirective, isStandalone: true, 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: [
2129
+ NgxMaskDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2130
+ NgxMaskDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.8", 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: [
2139
2131
  {
2140
2132
  provide: NG_VALUE_ACCESSOR,
2141
- useExisting: NgxMaskDirective,
2133
+ useExisting: forwardRef(() => NgxMaskDirective),
2142
2134
  multi: true,
2143
2135
  },
2144
2136
  {
2145
2137
  provide: NG_VALIDATORS,
2146
- useExisting: NgxMaskDirective,
2138
+ useExisting: forwardRef(() => NgxMaskDirective),
2147
2139
  multi: true,
2148
2140
  },
2149
2141
  NgxMaskService,
2150
- ], exportAs: ["mask", "ngxMask"], usesOnChanges: true, ngImport: i0 });
2151
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NgxMaskDirective, decorators: [{
2142
+ ], usesOnChanges: true, ngImport: i0 });
2143
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskDirective, decorators: [{
2152
2144
  type: Directive,
2153
2145
  args: [{
2154
2146
  selector: 'input[mask], textarea[mask]',
2155
- standalone: true,
2156
2147
  providers: [
2157
2148
  {
2158
2149
  provide: NG_VALUE_ACCESSOR,
2159
- useExisting: NgxMaskDirective,
2150
+ useExisting: forwardRef(() => NgxMaskDirective),
2160
2151
  multi: true,
2161
2152
  },
2162
2153
  {
2163
2154
  provide: NG_VALIDATORS,
2164
- useExisting: NgxMaskDirective,
2155
+ useExisting: forwardRef(() => NgxMaskDirective),
2165
2156
  multi: true,
2166
2157
  },
2167
2158
  NgxMaskService,
2168
2159
  ],
2169
- exportAs: 'mask,ngxMask',
2170
2160
  }]
2171
2161
  }], propDecorators: { maskExpression: [{
2172
2162
  type: Input,
@@ -2246,9 +2236,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
2246
2236
  }] } });
2247
2237
 
2248
2238
  class NgxMaskPipe {
2249
- constructor() {
2239
+ constructor(_maskService) {
2240
+ this._maskService = _maskService;
2250
2241
  this.defaultOptions = {};
2251
- this._maskService = inject(NgxMaskService);
2252
2242
  this._maskExpressionArray = [];
2253
2243
  this.mask = '';
2254
2244
  }
@@ -2328,14 +2318,59 @@ class NgxMaskPipe {
2328
2318
  }
2329
2319
  }
2330
2320
  }
2331
- NgxMaskPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NgxMaskPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2332
- NgxMaskPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: NgxMaskPipe, isStandalone: true, name: "mask" });
2333
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NgxMaskPipe, decorators: [{
2321
+ NgxMaskPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskPipe, deps: [{ token: NgxMaskService }], target: i0.ɵɵFactoryTarget.Pipe });
2322
+ NgxMaskPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskPipe, name: "mask" });
2323
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskPipe, decorators: [{
2334
2324
  type: Pipe,
2335
2325
  args: [{
2336
2326
  name: 'mask',
2337
2327
  pure: true,
2338
- standalone: true,
2328
+ }]
2329
+ }], ctorParameters: function () { return [{ type: NgxMaskService }]; } });
2330
+
2331
+ /**
2332
+ * @internal
2333
+ */
2334
+ function _configFactory(initConfig, configValue) {
2335
+ return configValue instanceof Function
2336
+ ? Object.assign(Object.assign({}, initConfig), configValue()) : Object.assign(Object.assign({}, initConfig), configValue);
2337
+ }
2338
+ class NgxMaskModule {
2339
+ static forRoot(configValue) {
2340
+ return {
2341
+ ngModule: NgxMaskModule,
2342
+ providers: [
2343
+ {
2344
+ provide: NEW_CONFIG,
2345
+ useValue: configValue,
2346
+ },
2347
+ {
2348
+ provide: INITIAL_CONFIG,
2349
+ useValue: initialConfig,
2350
+ },
2351
+ {
2352
+ provide: NGX_MASK_CONFIG,
2353
+ useFactory: _configFactory,
2354
+ deps: [INITIAL_CONFIG, NEW_CONFIG],
2355
+ },
2356
+ NgxMaskService,
2357
+ ],
2358
+ };
2359
+ }
2360
+ static forChild() {
2361
+ return {
2362
+ ngModule: NgxMaskModule,
2363
+ };
2364
+ }
2365
+ }
2366
+ NgxMaskModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2367
+ NgxMaskModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskModule, declarations: [NgxMaskDirective, NgxMaskPipe], exports: [NgxMaskDirective, NgxMaskPipe] });
2368
+ NgxMaskModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskModule });
2369
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskModule, decorators: [{
2370
+ type: NgModule,
2371
+ args: [{
2372
+ exports: [NgxMaskDirective, NgxMaskPipe],
2373
+ declarations: [NgxMaskDirective, NgxMaskPipe],
2339
2374
  }]
2340
2375
  }] });
2341
2376
 
@@ -2343,5 +2378,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
2343
2378
  * Generated bundle index. Do not edit.
2344
2379
  */
2345
2380
 
2346
- export { INITIAL_CONFIG, NEW_CONFIG, NGX_MASK_CONFIG, NgxMaskDirective, NgxMaskPipe, NgxMaskService, initialConfig, provideEnvironmentNgxMask, provideNgxMask, timeMasks, withoutValidation };
2381
+ export { INITIAL_CONFIG, NEW_CONFIG, NGX_MASK_CONFIG, NgxMaskDirective, NgxMaskModule, NgxMaskPipe, NgxMaskService, _configFactory, initialConfig, timeMasks, withoutValidation };
2347
2382
  //# sourceMappingURL=ngx-mask.mjs.map