ngx-mask 14.3.1 → 14.3.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.
- package/esm2020/index.mjs +2 -2
- package/esm2020/lib/ngx-mask-applier.service.mjs +25 -11
- package/esm2020/lib/ngx-mask.directive.mjs +15 -14
- package/esm2020/lib/ngx-mask.module.mjs +53 -0
- package/esm2020/lib/ngx-mask.pipe.mjs +9 -10
- package/esm2020/lib/ngx-mask.service.mjs +6 -6
- package/fesm2015/ngx-mask.mjs +96 -66
- package/fesm2015/ngx-mask.mjs.map +1 -1
- package/fesm2020/ngx-mask.mjs +96 -66
- package/fesm2020/ngx-mask.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/lib/custom-keyboard-event.d.ts +1 -1
- package/lib/ngx-mask-applier.service.d.ts +1 -0
- package/lib/ngx-mask.config.d.ts +1 -1
- package/lib/ngx-mask.directive.d.ts +5 -2
- package/lib/ngx-mask.module.d.ts +16 -0
- package/lib/ngx-mask.pipe.d.ts +4 -2
- package/lib/ngx-mask.service.d.ts +1 -1
- package/package.json +1 -1
- package/esm2020/lib/ngx-mask.providers.mjs +0 -34
- package/lib/ngx-mask.providers.d.ts +0 -4
package/fesm2015/ngx-mask.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, EventEmitter, inject, Injectable, ElementRef, Renderer2,
|
|
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
|
|
317
|
-
inputValue
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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: "
|
|
734
|
-
NgxMaskApplierService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
735
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
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
|
|
|
@@ -1047,10 +1061,10 @@ class NgxMaskService extends NgxMaskApplierService {
|
|
|
1047
1061
|
}
|
|
1048
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); });
|
|
1049
1063
|
}
|
|
1050
|
-
|
|
1064
|
+
checkDropSpecialCharAmount(mask) {
|
|
1051
1065
|
const chars = mask
|
|
1052
1066
|
.split("" /* MaskExpression.EMPTY_STRING */)
|
|
1053
|
-
.filter((item) => this.
|
|
1067
|
+
.filter((item) => this._findDropSpecialChar(item));
|
|
1054
1068
|
return chars.length;
|
|
1055
1069
|
}
|
|
1056
1070
|
removeMask(inputValue) {
|
|
@@ -1306,42 +1320,14 @@ class NgxMaskService extends NgxMaskApplierService {
|
|
|
1306
1320
|
return (1.1).toLocaleString().substring(1, 2);
|
|
1307
1321
|
}
|
|
1308
1322
|
}
|
|
1309
|
-
NgxMaskService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1310
|
-
NgxMaskService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1311
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
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: [{
|
|
1312
1326
|
type: Injectable
|
|
1313
1327
|
}] });
|
|
1314
1328
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
*/
|
|
1318
|
-
function _configFactory() {
|
|
1319
|
-
const initConfig = inject(INITIAL_CONFIG);
|
|
1320
|
-
const configValue = inject(NEW_CONFIG);
|
|
1321
|
-
return configValue instanceof Function
|
|
1322
|
-
? Object.assign(Object.assign({}, initConfig), configValue()) : Object.assign(Object.assign({}, initConfig), configValue);
|
|
1323
|
-
}
|
|
1324
|
-
function provideNgxMask(configValue) {
|
|
1325
|
-
return [
|
|
1326
|
-
{
|
|
1327
|
-
provide: NEW_CONFIG,
|
|
1328
|
-
useValue: configValue,
|
|
1329
|
-
},
|
|
1330
|
-
{
|
|
1331
|
-
provide: INITIAL_CONFIG,
|
|
1332
|
-
useValue: initialConfig,
|
|
1333
|
-
},
|
|
1334
|
-
{
|
|
1335
|
-
provide: NGX_MASK_CONFIG,
|
|
1336
|
-
useFactory: _configFactory,
|
|
1337
|
-
},
|
|
1338
|
-
NgxMaskService,
|
|
1339
|
-
];
|
|
1340
|
-
}
|
|
1341
|
-
function provideEnvironmentNgxMask(configValue) {
|
|
1342
|
-
return makeEnvironmentProviders(provideNgxMask(configValue));
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1329
|
+
// tslint:disable deprecation
|
|
1330
|
+
// tslint:disable no-input-rename
|
|
1345
1331
|
class NgxMaskDirective {
|
|
1346
1332
|
constructor() {
|
|
1347
1333
|
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
@@ -1560,7 +1546,7 @@ class NgxMaskDirective {
|
|
|
1560
1546
|
const array = this._maskValue.split('*');
|
|
1561
1547
|
const length = this._maskService.dropSpecialCharacters
|
|
1562
1548
|
? this._maskValue.length -
|
|
1563
|
-
this._maskService.
|
|
1549
|
+
this._maskService.checkDropSpecialCharAmount(this._maskValue) -
|
|
1564
1550
|
counterOfOpt
|
|
1565
1551
|
: this.prefix
|
|
1566
1552
|
? this._maskValue.length + this.prefix.length - counterOfOpt
|
|
@@ -1953,6 +1939,7 @@ class NgxMaskDirective {
|
|
|
1953
1939
|
}
|
|
1954
1940
|
}
|
|
1955
1941
|
/** It writes the value in the input */
|
|
1942
|
+
// public async writeValue(controlValue: unknown): Promise<void> {
|
|
1956
1943
|
writeValue(controlValue) {
|
|
1957
1944
|
var _a;
|
|
1958
1945
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1960,7 +1947,7 @@ class NgxMaskDirective {
|
|
|
1960
1947
|
if ('disable' in controlValue) {
|
|
1961
1948
|
this.setDisabledState(Boolean(controlValue.disable));
|
|
1962
1949
|
}
|
|
1963
|
-
// eslint-disable-next-line no-param-reassign
|
|
1950
|
+
// // eslint-disable-next-line no-param-reassign
|
|
1964
1951
|
controlValue = controlValue.value;
|
|
1965
1952
|
}
|
|
1966
1953
|
if (controlValue !== null) {
|
|
@@ -2139,39 +2126,37 @@ class NgxMaskDirective {
|
|
|
2139
2126
|
});
|
|
2140
2127
|
}
|
|
2141
2128
|
}
|
|
2142
|
-
NgxMaskDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2143
|
-
NgxMaskDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
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: [
|
|
2144
2131
|
{
|
|
2145
2132
|
provide: NG_VALUE_ACCESSOR,
|
|
2146
|
-
useExisting: NgxMaskDirective,
|
|
2133
|
+
useExisting: forwardRef(() => NgxMaskDirective),
|
|
2147
2134
|
multi: true,
|
|
2148
2135
|
},
|
|
2149
2136
|
{
|
|
2150
2137
|
provide: NG_VALIDATORS,
|
|
2151
|
-
useExisting: NgxMaskDirective,
|
|
2138
|
+
useExisting: forwardRef(() => NgxMaskDirective),
|
|
2152
2139
|
multi: true,
|
|
2153
2140
|
},
|
|
2154
2141
|
NgxMaskService,
|
|
2155
|
-
],
|
|
2156
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2142
|
+
], usesOnChanges: true, ngImport: i0 });
|
|
2143
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: NgxMaskDirective, decorators: [{
|
|
2157
2144
|
type: Directive,
|
|
2158
2145
|
args: [{
|
|
2159
2146
|
selector: 'input[mask], textarea[mask]',
|
|
2160
|
-
standalone: true,
|
|
2161
2147
|
providers: [
|
|
2162
2148
|
{
|
|
2163
2149
|
provide: NG_VALUE_ACCESSOR,
|
|
2164
|
-
useExisting: NgxMaskDirective,
|
|
2150
|
+
useExisting: forwardRef(() => NgxMaskDirective),
|
|
2165
2151
|
multi: true,
|
|
2166
2152
|
},
|
|
2167
2153
|
{
|
|
2168
2154
|
provide: NG_VALIDATORS,
|
|
2169
|
-
useExisting: NgxMaskDirective,
|
|
2155
|
+
useExisting: forwardRef(() => NgxMaskDirective),
|
|
2170
2156
|
multi: true,
|
|
2171
2157
|
},
|
|
2172
2158
|
NgxMaskService,
|
|
2173
2159
|
],
|
|
2174
|
-
exportAs: 'mask,ngxMask',
|
|
2175
2160
|
}]
|
|
2176
2161
|
}], propDecorators: { maskExpression: [{
|
|
2177
2162
|
type: Input,
|
|
@@ -2251,9 +2236,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
|
|
|
2251
2236
|
}] } });
|
|
2252
2237
|
|
|
2253
2238
|
class NgxMaskPipe {
|
|
2254
|
-
constructor() {
|
|
2239
|
+
constructor(_maskService) {
|
|
2240
|
+
this._maskService = _maskService;
|
|
2255
2241
|
this.defaultOptions = {};
|
|
2256
|
-
this._maskService = inject(NgxMaskService);
|
|
2257
2242
|
this._maskExpressionArray = [];
|
|
2258
2243
|
this.mask = '';
|
|
2259
2244
|
}
|
|
@@ -2333,14 +2318,59 @@ class NgxMaskPipe {
|
|
|
2333
2318
|
}
|
|
2334
2319
|
}
|
|
2335
2320
|
}
|
|
2336
|
-
NgxMaskPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2337
|
-
NgxMaskPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "
|
|
2338
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
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: [{
|
|
2339
2324
|
type: Pipe,
|
|
2340
2325
|
args: [{
|
|
2341
2326
|
name: 'mask',
|
|
2342
2327
|
pure: true,
|
|
2343
|
-
|
|
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],
|
|
2344
2374
|
}]
|
|
2345
2375
|
}] });
|
|
2346
2376
|
|
|
@@ -2348,5 +2378,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
|
|
|
2348
2378
|
* Generated bundle index. Do not edit.
|
|
2349
2379
|
*/
|
|
2350
2380
|
|
|
2351
|
-
export { INITIAL_CONFIG, NEW_CONFIG, NGX_MASK_CONFIG, NgxMaskDirective, NgxMaskPipe, NgxMaskService,
|
|
2381
|
+
export { INITIAL_CONFIG, NEW_CONFIG, NGX_MASK_CONFIG, NgxMaskDirective, NgxMaskModule, NgxMaskPipe, NgxMaskService, _configFactory, initialConfig, timeMasks, withoutValidation };
|
|
2352
2382
|
//# sourceMappingURL=ngx-mask.mjs.map
|