ngx-mask 19.0.0 → 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.
- package/fesm2022/ngx-mask.mjs +257 -305
- package/fesm2022/ngx-mask.mjs.map +1 -1
- package/lib/ngx-mask-applier.service.d.ts +0 -2
- package/lib/ngx-mask.config.d.ts +0 -1
- package/lib/ngx-mask.directive.d.ts +30 -28
- package/lib/ngx-mask.pipe.d.ts +1 -1
- package/lib/ngx-mask.service.d.ts +4 -4
- package/package.json +1 -1
package/fesm2022/ngx-mask.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, EventEmitter, inject, Injectable, ElementRef, Renderer2, makeEnvironmentProviders,
|
|
2
|
+
import { InjectionToken, EventEmitter, inject, Injectable, ElementRef, Renderer2, makeEnvironmentProviders, input, output, signal, Directive, HostListener, Pipe } from '@angular/core';
|
|
3
3
|
import { DOCUMENT } from '@angular/common';
|
|
4
4
|
import { NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
|
|
5
5
|
|
|
@@ -57,7 +57,6 @@ const initialConfig = {
|
|
|
57
57
|
thousandSeparator: ' ',
|
|
58
58
|
decimalMarker: ['.', ','],
|
|
59
59
|
clearIfNotMatch: false,
|
|
60
|
-
showTemplate: false,
|
|
61
60
|
showMaskTyped: false,
|
|
62
61
|
placeHolderCharacter: '_',
|
|
63
62
|
dropSpecialCharacters: true,
|
|
@@ -140,7 +139,6 @@ class NgxMaskApplierService {
|
|
|
140
139
|
_config = inject(NGX_MASK_CONFIG);
|
|
141
140
|
dropSpecialCharacters = this._config.dropSpecialCharacters;
|
|
142
141
|
hiddenInput = this._config.hiddenInput;
|
|
143
|
-
showTemplate;
|
|
144
142
|
clearIfNotMatch = this._config.clearIfNotMatch;
|
|
145
143
|
specialCharacters = this._config.specialCharacters;
|
|
146
144
|
patterns = this._config.patterns;
|
|
@@ -169,11 +167,6 @@ class NgxMaskApplierService {
|
|
|
169
167
|
deletedSpecialCharacter = false;
|
|
170
168
|
ipError;
|
|
171
169
|
cpfCnpjError;
|
|
172
|
-
applyMaskWithPattern(inputValue, maskAndPattern) {
|
|
173
|
-
const [mask, customPattern] = maskAndPattern;
|
|
174
|
-
this.customPattern = customPattern;
|
|
175
|
-
return this.applyMask(inputValue, mask);
|
|
176
|
-
}
|
|
177
170
|
applyMask(inputValue, maskExpression, position = 0, justPasted = false, backspaced = false, cb = () => { }) {
|
|
178
171
|
if (!maskExpression || typeof inputValue !== 'string') {
|
|
179
172
|
return MaskExpression.EMPTY_STRING;
|
|
@@ -289,7 +282,9 @@ class NgxMaskApplierService {
|
|
|
289
282
|
: processedValue;
|
|
290
283
|
}
|
|
291
284
|
else {
|
|
292
|
-
if (processedValue[0] === decimalMarker &&
|
|
285
|
+
if (processedValue[0] === decimalMarker &&
|
|
286
|
+
processedValue.length > 1 &&
|
|
287
|
+
!backspaced) {
|
|
293
288
|
processedValue =
|
|
294
289
|
MaskExpression.NUMBER_ZERO +
|
|
295
290
|
processedValue.slice(0, processedValue.length + 1);
|
|
@@ -330,11 +325,18 @@ class NgxMaskApplierService {
|
|
|
330
325
|
const positionOfZeroOrDecimalMarker = processedValue[processedPosition] === MaskExpression.NUMBER_ZERO ||
|
|
331
326
|
processedValue[processedPosition] === decimalMarker;
|
|
332
327
|
const zeroIndexNumberZero = processedValue[0] === MaskExpression.NUMBER_ZERO;
|
|
328
|
+
const firstIndexNumberZero = processedValue[1] === MaskExpression.NUMBER_ZERO;
|
|
333
329
|
const zeroIndexMinus = processedValue[0] === MaskExpression.MINUS;
|
|
334
330
|
const zeroIndexThousand = processedValue[0] === this.thousandSeparator;
|
|
335
331
|
const firstIndexDecimalMarker = processedValue[1] === decimalMarker;
|
|
336
|
-
const
|
|
332
|
+
const zeroIndexDecimalMarker = processedValue[0] === decimalMarker;
|
|
337
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
|
+
}
|
|
338
340
|
if (zeroIndexNumberZero &&
|
|
339
341
|
firstIndexDecimalMarker &&
|
|
340
342
|
positionOfZeroOrDecimalMarker &&
|
|
@@ -863,10 +865,10 @@ class NgxMaskApplierService {
|
|
|
863
865
|
}
|
|
864
866
|
return -1;
|
|
865
867
|
}
|
|
866
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.
|
|
867
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.
|
|
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 });
|
|
868
870
|
}
|
|
869
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.
|
|
871
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskApplierService, decorators: [{
|
|
870
872
|
type: Injectable
|
|
871
873
|
}] });
|
|
872
874
|
|
|
@@ -875,12 +877,12 @@ class NgxMaskService extends NgxMaskApplierService {
|
|
|
875
877
|
maskIsShown = '';
|
|
876
878
|
selStart = null;
|
|
877
879
|
selEnd = null;
|
|
878
|
-
writingValue = false;
|
|
879
880
|
maskChanged = false;
|
|
880
|
-
|
|
881
|
+
maskExpressionArray = [];
|
|
881
882
|
triggerOnMaskChange = false;
|
|
882
|
-
|
|
883
|
-
|
|
883
|
+
previousValue = '';
|
|
884
|
+
currentValue = '';
|
|
885
|
+
writingValue = false;
|
|
884
886
|
_emitValue = false;
|
|
885
887
|
_start;
|
|
886
888
|
_end;
|
|
@@ -949,7 +951,7 @@ class NgxMaskService extends NgxMaskApplierService {
|
|
|
949
951
|
this.specialCharacters.indexOf(this.maskExpression[newPosition] ?? MaskExpression.EMPTY_STRING) !== -1 &&
|
|
950
952
|
this.showMaskTyped &&
|
|
951
953
|
!this.prefix) {
|
|
952
|
-
newInputValue = this.
|
|
954
|
+
newInputValue = this.currentValue;
|
|
953
955
|
}
|
|
954
956
|
if (this.deletedSpecialCharacter && newPosition) {
|
|
955
957
|
if (this.specialCharacters.includes(this.actualValue.slice(newPosition, newPosition + 1))) {
|
|
@@ -996,13 +998,13 @@ class NgxMaskService extends NgxMaskApplierService {
|
|
|
996
998
|
this.specialCharacters = this.specialCharacters.filter((item) => !this._compareOrIncludes(item, this.decimalMarker, this.thousandSeparator));
|
|
997
999
|
}
|
|
998
1000
|
if (result || result === '') {
|
|
999
|
-
this.
|
|
1000
|
-
this.
|
|
1001
|
+
this.previousValue = this.currentValue;
|
|
1002
|
+
this.currentValue = result;
|
|
1001
1003
|
this._emitValue =
|
|
1002
|
-
this.
|
|
1004
|
+
this.previousValue !== this.currentValue ||
|
|
1003
1005
|
this.maskChanged ||
|
|
1004
1006
|
this.writingValue ||
|
|
1005
|
-
(this.
|
|
1007
|
+
(this.previousValue === this.currentValue && justPasted);
|
|
1006
1008
|
}
|
|
1007
1009
|
this._emitValue
|
|
1008
1010
|
? this.writingValue && this.triggerOnMaskChange
|
|
@@ -1256,7 +1258,7 @@ class NgxMaskService extends NgxMaskApplierService {
|
|
|
1256
1258
|
}
|
|
1257
1259
|
formControlResult(inputValue) {
|
|
1258
1260
|
if (this.writingValue && !inputValue) {
|
|
1259
|
-
this.onChange('');
|
|
1261
|
+
this.onChange(this.outputTransformFn(''));
|
|
1260
1262
|
return;
|
|
1261
1263
|
}
|
|
1262
1264
|
if (this.writingValue || (!this.triggerOnMaskChange && this.maskChanged)) {
|
|
@@ -1349,7 +1351,9 @@ class NgxMaskService extends NgxMaskApplierService {
|
|
|
1349
1351
|
processedResult = processedResult.replace(MaskExpression.COMMA, MaskExpression.DOT);
|
|
1350
1352
|
}
|
|
1351
1353
|
const separatorPrecision = this._retrieveSeparatorPrecision(this.maskExpression);
|
|
1352
|
-
const separatorValue = this.
|
|
1354
|
+
const separatorValue = this.specialCharacters.length === 0
|
|
1355
|
+
? this._retrieveSeparatorValue(processedResult)
|
|
1356
|
+
: this._replaceDecimalMarkerToDot(this._retrieveSeparatorValue(processedResult));
|
|
1353
1357
|
if (!this.isNumberValue) {
|
|
1354
1358
|
return separatorValue;
|
|
1355
1359
|
}
|
|
@@ -1426,10 +1430,10 @@ class NgxMaskService extends NgxMaskApplierService {
|
|
|
1426
1430
|
currentLocaleDecimalMarker() {
|
|
1427
1431
|
return (1.1).toLocaleString().substring(1, 2);
|
|
1428
1432
|
}
|
|
1429
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.
|
|
1430
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.
|
|
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 });
|
|
1431
1435
|
}
|
|
1432
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.
|
|
1436
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskService, decorators: [{
|
|
1433
1437
|
type: Injectable
|
|
1434
1438
|
}] });
|
|
1435
1439
|
|
|
@@ -1462,65 +1466,59 @@ function provideEnvironmentNgxMask(configValue) {
|
|
|
1462
1466
|
}
|
|
1463
1467
|
|
|
1464
1468
|
class NgxMaskDirective {
|
|
1465
|
-
|
|
1466
|
-
specialCharacters = [];
|
|
1467
|
-
patterns = {};
|
|
1468
|
-
prefix = '';
|
|
1469
|
-
suffix = '';
|
|
1470
|
-
thousandSeparator = ' ';
|
|
1471
|
-
decimalMarker = '.';
|
|
1472
|
-
dropSpecialCharacters = null;
|
|
1473
|
-
hiddenInput = null;
|
|
1474
|
-
showMaskTyped = null;
|
|
1475
|
-
placeHolderCharacter = null;
|
|
1476
|
-
shownMaskExpression = null;
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
_isFocused = false;
|
|
1498
|
-
_isComposing = false;
|
|
1499
|
-
document = inject(DOCUMENT);
|
|
1469
|
+
mask = input('');
|
|
1470
|
+
specialCharacters = input([]);
|
|
1471
|
+
patterns = input({});
|
|
1472
|
+
prefix = input('');
|
|
1473
|
+
suffix = input('');
|
|
1474
|
+
thousandSeparator = input(' ');
|
|
1475
|
+
decimalMarker = input('.');
|
|
1476
|
+
dropSpecialCharacters = input(null);
|
|
1477
|
+
hiddenInput = input(null);
|
|
1478
|
+
showMaskTyped = input(null);
|
|
1479
|
+
placeHolderCharacter = input(null);
|
|
1480
|
+
shownMaskExpression = input(null);
|
|
1481
|
+
clearIfNotMatch = input(null);
|
|
1482
|
+
validation = input(null);
|
|
1483
|
+
separatorLimit = input('');
|
|
1484
|
+
allowNegativeNumbers = input(null);
|
|
1485
|
+
leadZeroDateTime = input(null);
|
|
1486
|
+
leadZero = input(null);
|
|
1487
|
+
triggerOnMaskChange = input(null);
|
|
1488
|
+
apm = input(null);
|
|
1489
|
+
inputTransformFn = input(null);
|
|
1490
|
+
outputTransformFn = input(null);
|
|
1491
|
+
keepCharacterPositions = input(null);
|
|
1492
|
+
maskFilled = output();
|
|
1493
|
+
_maskValue = signal('');
|
|
1494
|
+
_inputValue = signal('');
|
|
1495
|
+
_position = signal(null);
|
|
1496
|
+
_code = signal('');
|
|
1497
|
+
_maskExpressionArray = signal([]);
|
|
1498
|
+
_justPasted = signal(false);
|
|
1499
|
+
_isFocused = signal(false);
|
|
1500
|
+
_isComposing = signal(false);
|
|
1500
1501
|
_maskService = inject(NgxMaskService, { self: true });
|
|
1502
|
+
document = inject(DOCUMENT);
|
|
1501
1503
|
_config = inject(NGX_MASK_CONFIG);
|
|
1502
1504
|
onChange = (_) => { };
|
|
1503
1505
|
onTouch = () => { };
|
|
1504
1506
|
ngOnChanges(changes) {
|
|
1505
|
-
const {
|
|
1506
|
-
if (
|
|
1507
|
-
if (
|
|
1508
|
-
!maskExpression.firstChange) {
|
|
1507
|
+
const { mask, specialCharacters, patterns, prefix, suffix, thousandSeparator, decimalMarker, dropSpecialCharacters, hiddenInput, showMaskTyped, placeHolderCharacter, shownMaskExpression, clearIfNotMatch, validation, separatorLimit, allowNegativeNumbers, leadZeroDateTime, leadZero, triggerOnMaskChange, apm, inputTransformFn, outputTransformFn, keepCharacterPositions, } = changes;
|
|
1508
|
+
if (mask) {
|
|
1509
|
+
if (mask.currentValue !== mask.previousValue && !mask.firstChange) {
|
|
1509
1510
|
this._maskService.maskChanged = true;
|
|
1510
1511
|
}
|
|
1511
|
-
if (
|
|
1512
|
-
|
|
1513
|
-
this._maskExpressionArray = maskExpression.currentValue
|
|
1514
|
-
.split(MaskExpression.OR)
|
|
1515
|
-
.sort((a, b) => {
|
|
1512
|
+
if (mask.currentValue && mask.currentValue.split(MaskExpression.OR).length > 1) {
|
|
1513
|
+
this._maskExpressionArray.set(mask.currentValue.split(MaskExpression.OR).sort((a, b) => {
|
|
1516
1514
|
return a.length - b.length;
|
|
1517
|
-
});
|
|
1515
|
+
}));
|
|
1518
1516
|
this._setMask();
|
|
1519
1517
|
}
|
|
1520
1518
|
else {
|
|
1521
|
-
this._maskExpressionArray
|
|
1522
|
-
this._maskValue
|
|
1523
|
-
this._maskService.maskExpression = this._maskValue;
|
|
1519
|
+
this._maskExpressionArray.set([]);
|
|
1520
|
+
this._maskValue.set(mask.currentValue || MaskExpression.EMPTY_STRING);
|
|
1521
|
+
this._maskService.maskExpression = this._maskValue();
|
|
1524
1522
|
}
|
|
1525
1523
|
}
|
|
1526
1524
|
if (specialCharacters) {
|
|
@@ -1565,7 +1563,7 @@ class NgxMaskDirective {
|
|
|
1565
1563
|
this._maskService.showMaskTyped = showMaskTyped.currentValue;
|
|
1566
1564
|
if (showMaskTyped.previousValue === false &&
|
|
1567
1565
|
showMaskTyped.currentValue === true &&
|
|
1568
|
-
this._isFocused) {
|
|
1566
|
+
this._isFocused()) {
|
|
1569
1567
|
requestAnimationFrame(() => {
|
|
1570
1568
|
this._maskService._elementRef?.nativeElement.click();
|
|
1571
1569
|
});
|
|
@@ -1577,9 +1575,6 @@ class NgxMaskDirective {
|
|
|
1577
1575
|
if (shownMaskExpression) {
|
|
1578
1576
|
this._maskService.shownMaskExpression = shownMaskExpression.currentValue;
|
|
1579
1577
|
}
|
|
1580
|
-
if (showTemplate) {
|
|
1581
|
-
this._maskService.showTemplate = showTemplate.currentValue;
|
|
1582
|
-
}
|
|
1583
1578
|
if (clearIfNotMatch) {
|
|
1584
1579
|
this._maskService.clearIfNotMatch = clearIfNotMatch.currentValue;
|
|
1585
1580
|
}
|
|
@@ -1611,7 +1606,8 @@ class NgxMaskDirective {
|
|
|
1611
1606
|
}
|
|
1612
1607
|
validate({ value }) {
|
|
1613
1608
|
const processedValue = typeof value === 'number' ? String(value) : value;
|
|
1614
|
-
|
|
1609
|
+
const maskValue = this._maskValue();
|
|
1610
|
+
if (!this._maskService.validation || !maskValue) {
|
|
1615
1611
|
return null;
|
|
1616
1612
|
}
|
|
1617
1613
|
if (this._maskService.ipError) {
|
|
@@ -1620,19 +1616,19 @@ class NgxMaskDirective {
|
|
|
1620
1616
|
if (this._maskService.cpfCnpjError) {
|
|
1621
1617
|
return this._createValidationError(processedValue);
|
|
1622
1618
|
}
|
|
1623
|
-
if (
|
|
1619
|
+
if (maskValue.startsWith(MaskExpression.SEPARATOR)) {
|
|
1624
1620
|
return null;
|
|
1625
1621
|
}
|
|
1626
|
-
if (withoutValidation.includes(
|
|
1622
|
+
if (withoutValidation.includes(maskValue)) {
|
|
1627
1623
|
return null;
|
|
1628
1624
|
}
|
|
1629
1625
|
if (this._maskService.clearIfNotMatch) {
|
|
1630
1626
|
return null;
|
|
1631
1627
|
}
|
|
1632
|
-
if (timeMasks.includes(
|
|
1628
|
+
if (timeMasks.includes(maskValue)) {
|
|
1633
1629
|
return this._validateTime(processedValue);
|
|
1634
1630
|
}
|
|
1635
|
-
if (
|
|
1631
|
+
if (maskValue === MaskExpression.EMAIL_MASK) {
|
|
1636
1632
|
const emailPattern = /^[^@]+@[^@]+\.[^@]+$/;
|
|
1637
1633
|
if (!emailPattern.test(processedValue) && processedValue) {
|
|
1638
1634
|
return this._createValidationError(processedValue);
|
|
@@ -1643,53 +1639,53 @@ class NgxMaskDirective {
|
|
|
1643
1639
|
}
|
|
1644
1640
|
if (processedValue && processedValue.length >= 1) {
|
|
1645
1641
|
let counterOfOpt = 0;
|
|
1646
|
-
if (
|
|
1647
|
-
|
|
1648
|
-
const lengthInsideCurlyBrackets =
|
|
1642
|
+
if (maskValue.includes(MaskExpression.CURLY_BRACKETS_LEFT) &&
|
|
1643
|
+
maskValue.includes(MaskExpression.CURLY_BRACKETS_RIGHT)) {
|
|
1644
|
+
const lengthInsideCurlyBrackets = maskValue.slice(maskValue.indexOf(MaskExpression.CURLY_BRACKETS_LEFT) + 1, maskValue.indexOf(MaskExpression.CURLY_BRACKETS_RIGHT));
|
|
1649
1645
|
return lengthInsideCurlyBrackets === String(processedValue.length)
|
|
1650
1646
|
? null
|
|
1651
1647
|
: this._createValidationError(processedValue);
|
|
1652
1648
|
}
|
|
1653
|
-
if (
|
|
1649
|
+
if (maskValue.startsWith(MaskExpression.PERCENT)) {
|
|
1654
1650
|
return null;
|
|
1655
1651
|
}
|
|
1656
1652
|
for (const key in this._maskService.patterns) {
|
|
1657
1653
|
if (this._maskService.patterns[key]?.optional) {
|
|
1658
|
-
if (
|
|
1659
|
-
const opt =
|
|
1654
|
+
if (maskValue.indexOf(key) !== maskValue.lastIndexOf(key)) {
|
|
1655
|
+
const opt = maskValue
|
|
1660
1656
|
.split(MaskExpression.EMPTY_STRING)
|
|
1661
1657
|
.filter((i) => i === key)
|
|
1662
1658
|
.join(MaskExpression.EMPTY_STRING);
|
|
1663
1659
|
counterOfOpt += opt.length;
|
|
1664
1660
|
}
|
|
1665
|
-
else if (
|
|
1661
|
+
else if (maskValue.indexOf(key) !== -1) {
|
|
1666
1662
|
counterOfOpt++;
|
|
1667
1663
|
}
|
|
1668
|
-
if (
|
|
1669
|
-
processedValue.length >=
|
|
1664
|
+
if (maskValue.indexOf(key) !== -1 &&
|
|
1665
|
+
processedValue.length >= maskValue.indexOf(key)) {
|
|
1670
1666
|
return null;
|
|
1671
1667
|
}
|
|
1672
|
-
if (counterOfOpt ===
|
|
1668
|
+
if (counterOfOpt === maskValue.length) {
|
|
1673
1669
|
return null;
|
|
1674
1670
|
}
|
|
1675
1671
|
}
|
|
1676
1672
|
}
|
|
1677
|
-
if ((
|
|
1678
|
-
processedValue.length <
|
|
1679
|
-
(
|
|
1680
|
-
processedValue.length <
|
|
1673
|
+
if ((maskValue.indexOf(MaskExpression.SYMBOL_STAR) > 1 &&
|
|
1674
|
+
processedValue.length < maskValue.indexOf(MaskExpression.SYMBOL_STAR)) ||
|
|
1675
|
+
(maskValue.indexOf(MaskExpression.SYMBOL_QUESTION) > 1 &&
|
|
1676
|
+
processedValue.length < maskValue.indexOf(MaskExpression.SYMBOL_QUESTION))) {
|
|
1681
1677
|
return this._createValidationError(processedValue);
|
|
1682
1678
|
}
|
|
1683
|
-
if (
|
|
1684
|
-
|
|
1685
|
-
const array =
|
|
1679
|
+
if (maskValue.indexOf(MaskExpression.SYMBOL_STAR) === -1 ||
|
|
1680
|
+
maskValue.indexOf(MaskExpression.SYMBOL_QUESTION) === -1) {
|
|
1681
|
+
const array = maskValue.split('*');
|
|
1686
1682
|
const length = this._maskService.dropSpecialCharacters
|
|
1687
|
-
?
|
|
1688
|
-
this._maskService.checkDropSpecialCharAmount(
|
|
1683
|
+
? maskValue.length -
|
|
1684
|
+
this._maskService.checkDropSpecialCharAmount(maskValue) -
|
|
1689
1685
|
counterOfOpt
|
|
1690
|
-
: this.prefix
|
|
1691
|
-
?
|
|
1692
|
-
:
|
|
1686
|
+
: this.prefix()
|
|
1687
|
+
? maskValue.length + this.prefix().length - counterOfOpt
|
|
1688
|
+
: maskValue.length - counterOfOpt;
|
|
1693
1689
|
if (array.length === 1) {
|
|
1694
1690
|
if (processedValue.length < length) {
|
|
1695
1691
|
return this._createValidationError(processedValue);
|
|
@@ -1700,7 +1696,7 @@ class NgxMaskDirective {
|
|
|
1700
1696
|
if (lastIndexArray &&
|
|
1701
1697
|
this._maskService.specialCharacters.includes(lastIndexArray[0]) &&
|
|
1702
1698
|
String(processedValue).includes(lastIndexArray[0] ?? '') &&
|
|
1703
|
-
!this.dropSpecialCharacters) {
|
|
1699
|
+
!this.dropSpecialCharacters()) {
|
|
1704
1700
|
const special = value.split(lastIndexArray[0]);
|
|
1705
1701
|
return special[special.length - 1].length === lastIndexArray.length - 1
|
|
1706
1702
|
? null
|
|
@@ -1718,8 +1714,8 @@ class NgxMaskDirective {
|
|
|
1718
1714
|
}
|
|
1719
1715
|
}
|
|
1720
1716
|
}
|
|
1721
|
-
if (
|
|
1722
|
-
|
|
1717
|
+
if (maskValue.indexOf(MaskExpression.SYMBOL_STAR) === 1 ||
|
|
1718
|
+
maskValue.indexOf(MaskExpression.SYMBOL_QUESTION) === 1) {
|
|
1723
1719
|
return null;
|
|
1724
1720
|
}
|
|
1725
1721
|
}
|
|
@@ -1730,10 +1726,10 @@ class NgxMaskDirective {
|
|
|
1730
1726
|
return null;
|
|
1731
1727
|
}
|
|
1732
1728
|
onPaste() {
|
|
1733
|
-
this._justPasted
|
|
1729
|
+
this._justPasted.set(true);
|
|
1734
1730
|
}
|
|
1735
1731
|
onFocus() {
|
|
1736
|
-
this._isFocused
|
|
1732
|
+
this._isFocused.set(true);
|
|
1737
1733
|
}
|
|
1738
1734
|
onModelChange(value) {
|
|
1739
1735
|
if ((value === MaskExpression.EMPTY_STRING ||
|
|
@@ -1744,7 +1740,7 @@ class NgxMaskDirective {
|
|
|
1744
1740
|
}
|
|
1745
1741
|
}
|
|
1746
1742
|
onInput(e) {
|
|
1747
|
-
if (this._isComposing) {
|
|
1743
|
+
if (this._isComposing()) {
|
|
1748
1744
|
return;
|
|
1749
1745
|
}
|
|
1750
1746
|
const el = e.target;
|
|
@@ -1752,20 +1748,22 @@ class NgxMaskDirective {
|
|
|
1752
1748
|
if (el.type !== 'number') {
|
|
1753
1749
|
if (typeof transformedValue === 'string' || typeof transformedValue === 'number') {
|
|
1754
1750
|
el.value = transformedValue.toString();
|
|
1755
|
-
this._inputValue
|
|
1751
|
+
this._inputValue.set(el.value);
|
|
1756
1752
|
this._setMask();
|
|
1757
|
-
if (!this._maskValue) {
|
|
1753
|
+
if (!this._maskValue()) {
|
|
1758
1754
|
this.onChange(el.value);
|
|
1759
1755
|
return;
|
|
1760
1756
|
}
|
|
1761
1757
|
let position = el.selectionStart === 1
|
|
1762
1758
|
? el.selectionStart + this._maskService.prefix.length
|
|
1763
1759
|
: el.selectionStart;
|
|
1764
|
-
if (this.showMaskTyped &&
|
|
1765
|
-
this.keepCharacterPositions &&
|
|
1760
|
+
if (this.showMaskTyped() &&
|
|
1761
|
+
this.keepCharacterPositions() &&
|
|
1766
1762
|
this._maskService.placeHolderCharacter.length === 1) {
|
|
1763
|
+
const suffix = this.suffix();
|
|
1764
|
+
const prefix = this.prefix();
|
|
1767
1765
|
const inputSymbol = el.value.slice(position - 1, position);
|
|
1768
|
-
const prefixLength =
|
|
1766
|
+
const prefixLength = prefix.length;
|
|
1769
1767
|
const checkSymbols = this._maskService._checkSymbolMask(inputSymbol, this._maskService.maskExpression[position - 1 - prefixLength] ??
|
|
1770
1768
|
MaskExpression.EMPTY_STRING);
|
|
1771
1769
|
const checkSpecialCharacter = this._maskService._checkSymbolMask(inputSymbol, this._maskService.maskExpression[position + 1 - prefixLength] ??
|
|
@@ -1773,32 +1771,32 @@ class NgxMaskDirective {
|
|
|
1773
1771
|
const selectRangeBackspace = this._maskService.selStart === this._maskService.selEnd;
|
|
1774
1772
|
const selStart = Number(this._maskService.selStart) - prefixLength;
|
|
1775
1773
|
const selEnd = Number(this._maskService.selEnd) - prefixLength;
|
|
1776
|
-
const backspaceOrDelete = this._code === MaskExpression.BACKSPACE ||
|
|
1777
|
-
this._code === MaskExpression.DELETE;
|
|
1774
|
+
const backspaceOrDelete = this._code() === MaskExpression.BACKSPACE ||
|
|
1775
|
+
this._code() === MaskExpression.DELETE;
|
|
1778
1776
|
if (backspaceOrDelete) {
|
|
1779
1777
|
if (!selectRangeBackspace) {
|
|
1780
1778
|
if (this._maskService.selStart === prefixLength) {
|
|
1781
|
-
this._maskService.actualValue = `${
|
|
1779
|
+
this._maskService.actualValue = `${prefix}${this._maskService.maskIsShown.slice(0, selEnd)}${this._inputValue().split(prefix).join('')}`;
|
|
1782
1780
|
}
|
|
1783
1781
|
else if (this._maskService.selStart ===
|
|
1784
1782
|
this._maskService.maskIsShown.length + prefixLength) {
|
|
1785
|
-
this._maskService.actualValue = `${this._inputValue}${this._maskService.maskIsShown.slice(selStart, selEnd)}`;
|
|
1783
|
+
this._maskService.actualValue = `${this._inputValue()}${this._maskService.maskIsShown.slice(selStart, selEnd)}`;
|
|
1786
1784
|
}
|
|
1787
1785
|
else {
|
|
1788
|
-
this._maskService.actualValue = `${
|
|
1789
|
-
.split(
|
|
1786
|
+
this._maskService.actualValue = `${prefix}${this._inputValue()
|
|
1787
|
+
.split(prefix)
|
|
1790
1788
|
.join('')
|
|
1791
|
-
.slice(0, selStart)}${this._maskService.maskIsShown.slice(selStart, selEnd)}${this._maskService.actualValue.slice(selEnd + prefixLength, this._maskService.maskIsShown.length + prefixLength)}${
|
|
1789
|
+
.slice(0, selStart)}${this._maskService.maskIsShown.slice(selStart, selEnd)}${this._maskService.actualValue.slice(selEnd + prefixLength, this._maskService.maskIsShown.length + prefixLength)}${suffix}`;
|
|
1792
1790
|
}
|
|
1793
1791
|
}
|
|
1794
|
-
else if (!this._maskService.specialCharacters.includes(this._maskService.maskExpression.slice(position -
|
|
1792
|
+
else if (!this._maskService.specialCharacters.includes(this._maskService.maskExpression.slice(position - prefixLength, position + 1 - prefixLength)) &&
|
|
1795
1793
|
selectRangeBackspace) {
|
|
1796
|
-
if (selStart === 1 &&
|
|
1797
|
-
this._maskService.actualValue = `${
|
|
1798
|
-
.split(
|
|
1794
|
+
if (selStart === 1 && prefix) {
|
|
1795
|
+
this._maskService.actualValue = `${prefix}${this._maskService.placeHolderCharacter}${el.value
|
|
1796
|
+
.split(prefix)
|
|
1799
1797
|
.join('')
|
|
1800
|
-
.split(
|
|
1801
|
-
.join('')}${
|
|
1798
|
+
.split(suffix)
|
|
1799
|
+
.join('')}${suffix}`;
|
|
1802
1800
|
position = position - 1;
|
|
1803
1801
|
}
|
|
1804
1802
|
else {
|
|
@@ -1807,7 +1805,7 @@ class NgxMaskDirective {
|
|
|
1807
1805
|
this._maskService.actualValue = `${part1}${this._maskService.placeHolderCharacter}${part2}`;
|
|
1808
1806
|
}
|
|
1809
1807
|
}
|
|
1810
|
-
position = this._code === MaskExpression.DELETE ? position + 1 : position;
|
|
1808
|
+
position = this._code() === MaskExpression.DELETE ? position + 1 : position;
|
|
1811
1809
|
}
|
|
1812
1810
|
if (!backspaceOrDelete) {
|
|
1813
1811
|
if (!checkSymbols && !checkSpecialCharacter && selectRangeBackspace) {
|
|
@@ -1821,49 +1819,49 @@ class NgxMaskDirective {
|
|
|
1821
1819
|
}
|
|
1822
1820
|
else if (checkSymbols) {
|
|
1823
1821
|
if (el.value.length === 1 && position === 1) {
|
|
1824
|
-
this._maskService.actualValue = `${
|
|
1822
|
+
this._maskService.actualValue = `${prefix}${inputSymbol}${this._maskService.maskIsShown.slice(1, this._maskService.maskIsShown.length)}${suffix}`;
|
|
1825
1823
|
}
|
|
1826
1824
|
else {
|
|
1827
1825
|
this._maskService.actualValue = `${el.value.slice(0, position - 1)}${inputSymbol}${el.value
|
|
1828
1826
|
.slice(position + 1)
|
|
1829
|
-
.split(
|
|
1830
|
-
.join('')}${
|
|
1827
|
+
.split(suffix)
|
|
1828
|
+
.join('')}${suffix}`;
|
|
1831
1829
|
}
|
|
1832
1830
|
}
|
|
1833
|
-
else if (
|
|
1831
|
+
else if (prefix &&
|
|
1834
1832
|
el.value.length === 1 &&
|
|
1835
1833
|
position - prefixLength === 1 &&
|
|
1836
1834
|
this._maskService._checkSymbolMask(el.value, this._maskService.maskExpression[position - 1 - prefixLength] ??
|
|
1837
1835
|
MaskExpression.EMPTY_STRING)) {
|
|
1838
|
-
this._maskService.actualValue = `${
|
|
1836
|
+
this._maskService.actualValue = `${prefix}${el.value}${this._maskService.maskIsShown.slice(1, this._maskService.maskIsShown.length)}${suffix}`;
|
|
1839
1837
|
}
|
|
1840
1838
|
}
|
|
1841
1839
|
}
|
|
1842
1840
|
let caretShift = 0;
|
|
1843
1841
|
let backspaceShift = false;
|
|
1844
|
-
if (this._code === MaskExpression.DELETE && MaskExpression.SEPARATOR) {
|
|
1842
|
+
if (this._code() === MaskExpression.DELETE && MaskExpression.SEPARATOR) {
|
|
1845
1843
|
this._maskService.deletedSpecialCharacter = true;
|
|
1846
1844
|
}
|
|
1847
|
-
if (this._inputValue.length >= this._maskService.maskExpression.length - 1 &&
|
|
1848
|
-
this._code !== MaskExpression.BACKSPACE &&
|
|
1845
|
+
if (this._inputValue().length >= this._maskService.maskExpression.length - 1 &&
|
|
1846
|
+
this._code() !== MaskExpression.BACKSPACE &&
|
|
1849
1847
|
this._maskService.maskExpression === MaskExpression.DAYS_MONTHS_YEARS &&
|
|
1850
1848
|
position < 10) {
|
|
1851
|
-
const inputSymbol = this._inputValue.slice(position - 1, position);
|
|
1849
|
+
const inputSymbol = this._inputValue().slice(position - 1, position);
|
|
1852
1850
|
el.value =
|
|
1853
|
-
this._inputValue.slice(0, position - 1) +
|
|
1851
|
+
this._inputValue().slice(0, position - 1) +
|
|
1854
1852
|
inputSymbol +
|
|
1855
|
-
this._inputValue.slice(position + 1);
|
|
1853
|
+
this._inputValue().slice(position + 1);
|
|
1856
1854
|
}
|
|
1857
1855
|
if (this._maskService.maskExpression === MaskExpression.DAYS_MONTHS_YEARS &&
|
|
1858
|
-
this.leadZeroDateTime) {
|
|
1856
|
+
this.leadZeroDateTime()) {
|
|
1859
1857
|
if ((position < 3 && Number(el.value) > 31 && Number(el.value) < 40) ||
|
|
1860
1858
|
(position === 5 && Number(el.value.slice(3, 5)) > 12)) {
|
|
1861
1859
|
position = position + 2;
|
|
1862
1860
|
}
|
|
1863
1861
|
}
|
|
1864
1862
|
if (this._maskService.maskExpression === MaskExpression.HOURS_MINUTES_SECONDS &&
|
|
1865
|
-
this.apm) {
|
|
1866
|
-
if (this._justPasted && el.value.slice(0, 2) === MaskExpression.DOUBLE_ZERO) {
|
|
1863
|
+
this.apm()) {
|
|
1864
|
+
if (this._justPasted() && el.value.slice(0, 2) === MaskExpression.DOUBLE_ZERO) {
|
|
1867
1865
|
el.value = el.value.slice(1, 2) + el.value.slice(2, el.value.length);
|
|
1868
1866
|
}
|
|
1869
1867
|
el.value =
|
|
@@ -1871,8 +1869,9 @@ class NgxMaskDirective {
|
|
|
1871
1869
|
? MaskExpression.NUMBER_ZERO
|
|
1872
1870
|
: el.value;
|
|
1873
1871
|
}
|
|
1874
|
-
this._maskService.applyValueChanges(position, this._justPasted, this._code === MaskExpression.BACKSPACE ||
|
|
1875
|
-
this.
|
|
1872
|
+
this._maskService.applyValueChanges(position, this._justPasted(), this._code() === MaskExpression.BACKSPACE ||
|
|
1873
|
+
this._code() === MaskExpression.DELETE, (shift, _backspaceShift) => {
|
|
1874
|
+
this._justPasted.set(false);
|
|
1876
1875
|
caretShift = shift;
|
|
1877
1876
|
backspaceShift = _backspaceShift;
|
|
1878
1877
|
});
|
|
@@ -1883,13 +1882,14 @@ class NgxMaskDirective {
|
|
|
1883
1882
|
position = position + 1;
|
|
1884
1883
|
this._maskService.plusOnePosition = false;
|
|
1885
1884
|
}
|
|
1886
|
-
if (this._maskExpressionArray.length) {
|
|
1887
|
-
if (this._code === MaskExpression.BACKSPACE) {
|
|
1888
|
-
const specialChartMinusOne = this.specialCharacters.includes(this._maskService.actualValue.slice(position - 1, position));
|
|
1889
|
-
const
|
|
1890
|
-
|
|
1885
|
+
if (this._maskExpressionArray().length) {
|
|
1886
|
+
if (this._code() === MaskExpression.BACKSPACE) {
|
|
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;
|
|
1890
|
+
const specialChartPlusOne = this.specialCharacters().includes(this._maskService.actualValue.slice(position, position + 1));
|
|
1891
|
+
if (allowFewMaskChangeMask && !specialChartPlusOne) {
|
|
1891
1892
|
position = el.selectionStart + 1;
|
|
1892
|
-
this._allowFewMaskChangeMask = false;
|
|
1893
1893
|
}
|
|
1894
1894
|
else {
|
|
1895
1895
|
position = specialChartMinusOne ? position - 1 : position;
|
|
@@ -1902,12 +1902,15 @@ class NgxMaskDirective {
|
|
|
1902
1902
|
: el.selectionStart;
|
|
1903
1903
|
}
|
|
1904
1904
|
}
|
|
1905
|
-
this._position
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1905
|
+
this._position.set(this._position() === 1 && this._inputValue().length === 1
|
|
1906
|
+
? null
|
|
1907
|
+
: this._position());
|
|
1908
|
+
let positionToApply = this._position()
|
|
1909
|
+
? this._inputValue().length + position + caretShift
|
|
1909
1910
|
: position +
|
|
1910
|
-
(this._code === MaskExpression.BACKSPACE && !backspaceShift
|
|
1911
|
+
(this._code() === MaskExpression.BACKSPACE && !backspaceShift
|
|
1912
|
+
? 0
|
|
1913
|
+
: caretShift);
|
|
1911
1914
|
if (positionToApply > this._getActualInputLength()) {
|
|
1912
1915
|
positionToApply =
|
|
1913
1916
|
el.value === this._maskService.decimalMarker && el.value.length === 1
|
|
@@ -1918,59 +1921,59 @@ class NgxMaskDirective {
|
|
|
1918
1921
|
positionToApply = 0;
|
|
1919
1922
|
}
|
|
1920
1923
|
el.setSelectionRange(positionToApply, positionToApply);
|
|
1921
|
-
this._position
|
|
1924
|
+
this._position.set(null);
|
|
1922
1925
|
}
|
|
1923
1926
|
else {
|
|
1924
1927
|
console.warn('Ngx-mask writeValue work with string | number, your current value:', typeof transformedValue);
|
|
1925
1928
|
}
|
|
1926
1929
|
}
|
|
1927
1930
|
else {
|
|
1928
|
-
if (!this._maskValue) {
|
|
1931
|
+
if (!this._maskValue()) {
|
|
1929
1932
|
this.onChange(el.value);
|
|
1930
1933
|
return;
|
|
1931
1934
|
}
|
|
1932
|
-
this._maskService.applyValueChanges(el.value.length, this._justPasted, this._code === MaskExpression.BACKSPACE || this._code === MaskExpression.DELETE);
|
|
1935
|
+
this._maskService.applyValueChanges(el.value.length, this._justPasted(), this._code() === MaskExpression.BACKSPACE || this._code() === MaskExpression.DELETE);
|
|
1933
1936
|
}
|
|
1934
1937
|
}
|
|
1935
1938
|
onCompositionStart() {
|
|
1936
|
-
this._isComposing
|
|
1939
|
+
this._isComposing.set(true);
|
|
1937
1940
|
}
|
|
1938
1941
|
onCompositionEnd(e) {
|
|
1939
|
-
this._isComposing
|
|
1940
|
-
this._justPasted
|
|
1942
|
+
this._isComposing.set(false);
|
|
1943
|
+
this._justPasted.set(true);
|
|
1941
1944
|
this.onInput(e);
|
|
1942
1945
|
}
|
|
1943
1946
|
onBlur(e) {
|
|
1944
|
-
if (this._maskValue) {
|
|
1947
|
+
if (this._maskValue()) {
|
|
1945
1948
|
const el = e.target;
|
|
1946
1949
|
if (this._maskService.leadZero &&
|
|
1947
1950
|
el.value.length > 0 &&
|
|
1948
1951
|
typeof this._maskService.decimalMarker === 'string') {
|
|
1949
1952
|
const maskExpression = this._maskService.maskExpression;
|
|
1953
|
+
const decimalMarker = this._maskService.decimalMarker;
|
|
1954
|
+
const suffix = this._maskService.suffix;
|
|
1950
1955
|
const precision = Number(this._maskService.maskExpression.slice(maskExpression.length - 1, maskExpression.length));
|
|
1951
1956
|
if (precision > 0) {
|
|
1952
|
-
el.value =
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
const decimalPart = el.value.split(this._maskService.decimalMarker)[1];
|
|
1956
|
-
el.value = el.value.includes(this._maskService.decimalMarker)
|
|
1957
|
+
el.value = suffix ? el.value.split(suffix).join('') : el.value;
|
|
1958
|
+
const decimalPart = el.value.split(decimalMarker)[1];
|
|
1959
|
+
el.value = el.value.includes(decimalMarker)
|
|
1957
1960
|
? el.value +
|
|
1958
1961
|
MaskExpression.NUMBER_ZERO.repeat(precision - decimalPart.length) +
|
|
1959
|
-
|
|
1962
|
+
suffix
|
|
1960
1963
|
: el.value +
|
|
1961
|
-
|
|
1964
|
+
decimalMarker +
|
|
1962
1965
|
MaskExpression.NUMBER_ZERO.repeat(precision) +
|
|
1963
|
-
|
|
1966
|
+
suffix;
|
|
1964
1967
|
this._maskService.actualValue = el.value;
|
|
1965
1968
|
}
|
|
1966
1969
|
}
|
|
1967
1970
|
this._maskService.clearIfNotMatchFn();
|
|
1968
1971
|
}
|
|
1969
|
-
this._isFocused
|
|
1972
|
+
this._isFocused.set(false);
|
|
1970
1973
|
this.onTouch();
|
|
1971
1974
|
}
|
|
1972
1975
|
onClick(e) {
|
|
1973
|
-
if (!this._maskValue) {
|
|
1976
|
+
if (!this._maskValue()) {
|
|
1974
1977
|
return;
|
|
1975
1978
|
}
|
|
1976
1979
|
const el = e.target;
|
|
@@ -1981,7 +1984,7 @@ class NgxMaskDirective {
|
|
|
1981
1984
|
el.selectionStart === el.selectionEnd &&
|
|
1982
1985
|
el.selectionStart > this._maskService.prefix.length &&
|
|
1983
1986
|
e.keyCode !== 38) {
|
|
1984
|
-
if (this._maskService.showMaskTyped && !this.keepCharacterPositions) {
|
|
1987
|
+
if (this._maskService.showMaskTyped && !this.keepCharacterPositions()) {
|
|
1985
1988
|
this._maskService.maskIsShown = this._maskService.showMaskInInput();
|
|
1986
1989
|
if (el.setSelectionRange &&
|
|
1987
1990
|
this._maskService.prefix + this._maskService.maskIsShown === el.value) {
|
|
@@ -2015,18 +2018,18 @@ class NgxMaskDirective {
|
|
|
2015
2018
|
}
|
|
2016
2019
|
}
|
|
2017
2020
|
onKeyDown(e) {
|
|
2018
|
-
if (!this._maskValue) {
|
|
2021
|
+
if (!this._maskValue()) {
|
|
2019
2022
|
return;
|
|
2020
2023
|
}
|
|
2021
|
-
if (this._isComposing) {
|
|
2024
|
+
if (this._isComposing()) {
|
|
2022
2025
|
if (e.key === 'Enter') {
|
|
2023
2026
|
this.onCompositionEnd(e);
|
|
2024
2027
|
}
|
|
2025
2028
|
return;
|
|
2026
2029
|
}
|
|
2027
|
-
this._code
|
|
2030
|
+
this._code.set(e.code ? e.code : e.key);
|
|
2028
2031
|
const el = e.target;
|
|
2029
|
-
this._inputValue
|
|
2032
|
+
this._inputValue.set(el.value);
|
|
2030
2033
|
this._setMask();
|
|
2031
2034
|
if (el.type !== 'number') {
|
|
2032
2035
|
if (e.key === MaskExpression.ARROW_UP) {
|
|
@@ -2039,21 +2042,21 @@ class NgxMaskDirective {
|
|
|
2039
2042
|
el.selectionStart = el.selectionEnd;
|
|
2040
2043
|
}
|
|
2041
2044
|
if (e.key === MaskExpression.BACKSPACE && el.selectionStart !== 0) {
|
|
2042
|
-
|
|
2043
|
-
|
|
2045
|
+
const prefixLength = this.prefix().length;
|
|
2046
|
+
const specialCharacters = this.specialCharacters().length
|
|
2047
|
+
? this.specialCharacters()
|
|
2044
2048
|
: this._config.specialCharacters;
|
|
2045
|
-
if (
|
|
2046
|
-
el.
|
|
2047
|
-
el.setSelectionRange(this.prefix.length, el.selectionEnd);
|
|
2049
|
+
if (prefixLength > 1 && el.selectionStart <= prefixLength) {
|
|
2050
|
+
el.setSelectionRange(prefixLength, el.selectionEnd);
|
|
2048
2051
|
}
|
|
2049
2052
|
else {
|
|
2050
|
-
if (this._inputValue.length !== el.selectionStart &&
|
|
2053
|
+
if (this._inputValue().length !== el.selectionStart &&
|
|
2051
2054
|
el.selectionStart !== 1) {
|
|
2052
|
-
while (
|
|
2055
|
+
while (specialCharacters.includes((this._inputValue()[el.selectionStart - 1] ??
|
|
2053
2056
|
MaskExpression.EMPTY_STRING).toString()) &&
|
|
2054
|
-
((
|
|
2055
|
-
el.selectionStart >
|
|
2056
|
-
|
|
2057
|
+
((prefixLength >= 1 &&
|
|
2058
|
+
el.selectionStart > prefixLength) ||
|
|
2059
|
+
prefixLength === 0)) {
|
|
2057
2060
|
el.setSelectionRange(el.selectionStart - 1, el.selectionEnd);
|
|
2058
2061
|
}
|
|
2059
2062
|
}
|
|
@@ -2071,14 +2074,14 @@ class NgxMaskDirective {
|
|
|
2071
2074
|
cursorStart === 0 &&
|
|
2072
2075
|
el.selectionEnd === el.value.length &&
|
|
2073
2076
|
el.value.length !== 0) {
|
|
2074
|
-
this._position
|
|
2075
|
-
this._maskService.applyMask(this._maskService.prefix, this._maskService.maskExpression, this._position);
|
|
2077
|
+
this._position.set(this._maskService.prefix ? this._maskService.prefix.length : 0);
|
|
2078
|
+
this._maskService.applyMask(this._maskService.prefix, this._maskService.maskExpression, this._position());
|
|
2076
2079
|
}
|
|
2077
2080
|
}
|
|
2078
|
-
if (!!this.suffix &&
|
|
2079
|
-
this.suffix.length > 1 &&
|
|
2080
|
-
this._inputValue.length - this.suffix.length < el.selectionStart) {
|
|
2081
|
-
el.setSelectionRange(this._inputValue.length - this.suffix.length, this._inputValue.length);
|
|
2081
|
+
if (!!this.suffix() &&
|
|
2082
|
+
this.suffix().length > 1 &&
|
|
2083
|
+
this._inputValue().length - this.suffix().length < el.selectionStart) {
|
|
2084
|
+
el.setSelectionRange(this._inputValue().length - this.suffix().length, this._inputValue().length);
|
|
2082
2085
|
}
|
|
2083
2086
|
else if ((e.code === 'KeyA' && e.ctrlKey) ||
|
|
2084
2087
|
(e.code === 'KeyA' && e.metaKey)) {
|
|
@@ -2091,6 +2094,7 @@ class NgxMaskDirective {
|
|
|
2091
2094
|
}
|
|
2092
2095
|
async writeValue(controlValue) {
|
|
2093
2096
|
let value = controlValue;
|
|
2097
|
+
const inputTransformFn = this.inputTransformFn();
|
|
2094
2098
|
if (typeof value === 'object' && value !== null && 'value' in value) {
|
|
2095
2099
|
if ('disable' in value) {
|
|
2096
2100
|
this.setDisabledState(Boolean(value.disable));
|
|
@@ -2098,19 +2102,19 @@ class NgxMaskDirective {
|
|
|
2098
2102
|
value = value.value;
|
|
2099
2103
|
}
|
|
2100
2104
|
if (value !== null) {
|
|
2101
|
-
value =
|
|
2105
|
+
value = inputTransformFn ? inputTransformFn(value) : value;
|
|
2102
2106
|
}
|
|
2103
2107
|
if (typeof value === 'string' ||
|
|
2104
2108
|
typeof value === 'number' ||
|
|
2105
2109
|
value === null ||
|
|
2106
2110
|
typeof value === 'undefined') {
|
|
2107
2111
|
if (value === null || typeof value === 'undefined' || value === '') {
|
|
2108
|
-
this._maskService.
|
|
2109
|
-
this._maskService.
|
|
2112
|
+
this._maskService.currentValue = '';
|
|
2113
|
+
this._maskService.previousValue = '';
|
|
2110
2114
|
}
|
|
2111
2115
|
let inputValue = value;
|
|
2112
2116
|
if (typeof inputValue === 'number' ||
|
|
2113
|
-
this._maskValue.startsWith(MaskExpression.SEPARATOR)) {
|
|
2117
|
+
this._maskValue().startsWith(MaskExpression.SEPARATOR)) {
|
|
2114
2118
|
inputValue = String(inputValue);
|
|
2115
2119
|
const localeDecimalMarker = this._maskService.currentLocaleDecimalMarker();
|
|
2116
2120
|
if (!Array.isArray(this._maskService.decimalMarker)) {
|
|
@@ -2121,8 +2125,8 @@ class NgxMaskDirective {
|
|
|
2121
2125
|
}
|
|
2122
2126
|
if (this._maskService.leadZero &&
|
|
2123
2127
|
inputValue &&
|
|
2124
|
-
this.
|
|
2125
|
-
this.dropSpecialCharacters !== false) {
|
|
2128
|
+
this.mask() &&
|
|
2129
|
+
this.dropSpecialCharacters() !== false) {
|
|
2126
2130
|
inputValue = this._maskService._checkPrecision(this._maskService.maskExpression, inputValue);
|
|
2127
2131
|
}
|
|
2128
2132
|
if (this._maskService.decimalMarker === MaskExpression.COMMA ||
|
|
@@ -2132,7 +2136,7 @@ class NgxMaskDirective {
|
|
|
2132
2136
|
.toString()
|
|
2133
2137
|
.replace(MaskExpression.DOT, MaskExpression.COMMA);
|
|
2134
2138
|
}
|
|
2135
|
-
if (this.
|
|
2139
|
+
if (this.mask()?.startsWith(MaskExpression.SEPARATOR) && this.leadZero()) {
|
|
2136
2140
|
requestAnimationFrame(() => {
|
|
2137
2141
|
this._maskService.applyMask(inputValue?.toString() ?? '', this._maskService.maskExpression);
|
|
2138
2142
|
});
|
|
@@ -2142,26 +2146,26 @@ class NgxMaskDirective {
|
|
|
2142
2146
|
if (typeof inputValue !== 'string') {
|
|
2143
2147
|
inputValue = '';
|
|
2144
2148
|
}
|
|
2145
|
-
this._inputValue
|
|
2149
|
+
this._inputValue.set(inputValue);
|
|
2146
2150
|
this._setMask();
|
|
2147
2151
|
if ((inputValue && this._maskService.maskExpression) ||
|
|
2148
2152
|
(this._maskService.maskExpression &&
|
|
2149
2153
|
(this._maskService.prefix || this._maskService.showMaskTyped))) {
|
|
2150
|
-
if (typeof
|
|
2154
|
+
if (typeof inputTransformFn !== 'function') {
|
|
2151
2155
|
this._maskService.writingValue = true;
|
|
2152
2156
|
}
|
|
2153
2157
|
this._maskService.formElementProperty = [
|
|
2154
2158
|
'value',
|
|
2155
2159
|
this._maskService.applyMask(inputValue, this._maskService.maskExpression),
|
|
2156
2160
|
];
|
|
2157
|
-
if (typeof
|
|
2161
|
+
if (typeof inputTransformFn !== 'function') {
|
|
2158
2162
|
this._maskService.writingValue = false;
|
|
2159
2163
|
}
|
|
2160
2164
|
}
|
|
2161
2165
|
else {
|
|
2162
2166
|
this._maskService.formElementProperty = ['value', inputValue];
|
|
2163
2167
|
}
|
|
2164
|
-
this._inputValue
|
|
2168
|
+
this._inputValue.set(inputValue);
|
|
2165
2169
|
}
|
|
2166
2170
|
else {
|
|
2167
2171
|
console.warn('Ngx-mask writeValue work with string | number, your current value:', typeof value);
|
|
@@ -2183,21 +2187,24 @@ class NgxMaskDirective {
|
|
|
2183
2187
|
}
|
|
2184
2188
|
}
|
|
2185
2189
|
checkSelectionOnDeletion(el) {
|
|
2186
|
-
|
|
2187
|
-
|
|
2190
|
+
const prefixLength = this.prefix().length;
|
|
2191
|
+
const suffixLength = this.suffix().length;
|
|
2192
|
+
const inputValueLength = this._inputValue().length;
|
|
2193
|
+
el.selectionStart = Math.min(Math.max(prefixLength, el.selectionStart), inputValueLength - suffixLength);
|
|
2194
|
+
el.selectionEnd = Math.min(Math.max(prefixLength, el.selectionEnd), inputValueLength - suffixLength);
|
|
2188
2195
|
}
|
|
2189
2196
|
setDisabledState(isDisabled) {
|
|
2190
2197
|
this._maskService.formElementProperty = ['disabled', isDisabled];
|
|
2191
2198
|
}
|
|
2192
2199
|
_applyMask() {
|
|
2193
|
-
this._maskService.maskExpression = this._maskService._repeatPatternSymbols(this._maskValue || '');
|
|
2200
|
+
this._maskService.maskExpression = this._maskService._repeatPatternSymbols(this._maskValue() || '');
|
|
2194
2201
|
this._maskService.formElementProperty = [
|
|
2195
2202
|
'value',
|
|
2196
|
-
this._maskService.applyMask(this._inputValue, this._maskService.maskExpression),
|
|
2203
|
+
this._maskService.applyMask(this._inputValue(), this._maskService.maskExpression),
|
|
2197
2204
|
];
|
|
2198
2205
|
}
|
|
2199
2206
|
_validateTime(value) {
|
|
2200
|
-
const rowMaskLen = this._maskValue
|
|
2207
|
+
const rowMaskLen = this._maskValue()
|
|
2201
2208
|
.split(MaskExpression.EMPTY_STRING)
|
|
2202
2209
|
.filter((s) => s !== ':').length;
|
|
2203
2210
|
if (!value) {
|
|
@@ -2216,55 +2223,51 @@ class NgxMaskDirective {
|
|
|
2216
2223
|
_createValidationError(actualValue) {
|
|
2217
2224
|
return {
|
|
2218
2225
|
mask: {
|
|
2219
|
-
requiredMask: this._maskValue,
|
|
2226
|
+
requiredMask: this._maskValue(),
|
|
2220
2227
|
actualValue,
|
|
2221
2228
|
},
|
|
2222
2229
|
};
|
|
2223
2230
|
}
|
|
2224
2231
|
_setMask() {
|
|
2225
|
-
this._maskExpressionArray.some((mask) => {
|
|
2232
|
+
this._maskExpressionArray().some((mask) => {
|
|
2226
2233
|
const specialChart = mask
|
|
2227
2234
|
.split(MaskExpression.EMPTY_STRING)
|
|
2228
2235
|
.some((char) => this._maskService.specialCharacters.includes(char));
|
|
2229
2236
|
if ((specialChart &&
|
|
2230
|
-
this._inputValue &&
|
|
2231
|
-
this._areAllCharactersInEachStringSame(this._maskExpressionArray)) ||
|
|
2237
|
+
this._inputValue() &&
|
|
2238
|
+
this._areAllCharactersInEachStringSame(this._maskExpressionArray())) ||
|
|
2232
2239
|
mask.includes(MaskExpression.CURLY_BRACKETS_LEFT)) {
|
|
2233
|
-
const test = this._maskService.removeMask(this._inputValue)?.length <=
|
|
2240
|
+
const test = this._maskService.removeMask(this._inputValue())?.length <=
|
|
2234
2241
|
this._maskService.removeMask(mask)?.length;
|
|
2235
2242
|
if (test) {
|
|
2236
|
-
|
|
2237
|
-
this.
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
: mask;
|
|
2243
|
+
const maskValue = mask.includes(MaskExpression.CURLY_BRACKETS_LEFT)
|
|
2244
|
+
? this._maskService._repeatPatternSymbols(mask)
|
|
2245
|
+
: mask;
|
|
2246
|
+
this._maskValue.set(maskValue);
|
|
2247
|
+
this._maskService.maskExpression = maskValue;
|
|
2242
2248
|
return test;
|
|
2243
2249
|
}
|
|
2244
2250
|
else {
|
|
2245
|
-
|
|
2246
|
-
this._allowFewMaskChangeMask = true;
|
|
2247
|
-
}
|
|
2248
|
-
const expression = this._maskExpressionArray[this._maskExpressionArray.length - 1] ??
|
|
2251
|
+
const expression = this._maskExpressionArray()[this._maskExpressionArray().length - 1] ??
|
|
2249
2252
|
MaskExpression.EMPTY_STRING;
|
|
2250
|
-
|
|
2251
|
-
this.
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
: expression;
|
|
2253
|
+
const maskValue = expression.includes(MaskExpression.CURLY_BRACKETS_LEFT)
|
|
2254
|
+
? this._maskService._repeatPatternSymbols(expression)
|
|
2255
|
+
: expression;
|
|
2256
|
+
this._maskValue.set(maskValue);
|
|
2257
|
+
this._maskService.maskExpression = maskValue;
|
|
2256
2258
|
}
|
|
2257
2259
|
}
|
|
2258
2260
|
else {
|
|
2259
2261
|
const check = this._maskService
|
|
2260
|
-
.removeMask(this._inputValue)
|
|
2262
|
+
.removeMask(this._inputValue())
|
|
2261
2263
|
?.split(MaskExpression.EMPTY_STRING)
|
|
2262
2264
|
.every((character, index) => {
|
|
2263
2265
|
const indexMask = mask.charAt(index);
|
|
2264
2266
|
return this._maskService._checkSymbolMask(character, indexMask);
|
|
2265
2267
|
});
|
|
2266
|
-
if (check || this._justPasted) {
|
|
2267
|
-
this._maskValue
|
|
2268
|
+
if (check || this._justPasted()) {
|
|
2269
|
+
this._maskValue.set(mask);
|
|
2270
|
+
this._maskService.maskExpression = mask;
|
|
2268
2271
|
return check;
|
|
2269
2272
|
}
|
|
2270
2273
|
}
|
|
@@ -2282,8 +2285,8 @@ class NgxMaskDirective {
|
|
|
2282
2285
|
return uniqueCharacters.size === 1;
|
|
2283
2286
|
});
|
|
2284
2287
|
}
|
|
2285
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.
|
|
2286
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
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: [
|
|
2287
2290
|
{
|
|
2288
2291
|
provide: NG_VALUE_ACCESSOR,
|
|
2289
2292
|
useExisting: NgxMaskDirective,
|
|
@@ -2297,7 +2300,7 @@ class NgxMaskDirective {
|
|
|
2297
2300
|
NgxMaskService,
|
|
2298
2301
|
], exportAs: ["mask", "ngxMask"], usesOnChanges: true, ngImport: i0 });
|
|
2299
2302
|
}
|
|
2300
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.
|
|
2303
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskDirective, decorators: [{
|
|
2301
2304
|
type: Directive,
|
|
2302
2305
|
args: [{
|
|
2303
2306
|
selector: 'input[mask], textarea[mask]',
|
|
@@ -2317,58 +2320,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
2317
2320
|
],
|
|
2318
2321
|
exportAs: 'mask,ngxMask',
|
|
2319
2322
|
}]
|
|
2320
|
-
}], propDecorators: {
|
|
2321
|
-
type: Input,
|
|
2322
|
-
args: ['mask']
|
|
2323
|
-
}], specialCharacters: [{
|
|
2324
|
-
type: Input
|
|
2325
|
-
}], patterns: [{
|
|
2326
|
-
type: Input
|
|
2327
|
-
}], prefix: [{
|
|
2328
|
-
type: Input
|
|
2329
|
-
}], suffix: [{
|
|
2330
|
-
type: Input
|
|
2331
|
-
}], thousandSeparator: [{
|
|
2332
|
-
type: Input
|
|
2333
|
-
}], decimalMarker: [{
|
|
2334
|
-
type: Input
|
|
2335
|
-
}], dropSpecialCharacters: [{
|
|
2336
|
-
type: Input
|
|
2337
|
-
}], hiddenInput: [{
|
|
2338
|
-
type: Input
|
|
2339
|
-
}], showMaskTyped: [{
|
|
2340
|
-
type: Input
|
|
2341
|
-
}], placeHolderCharacter: [{
|
|
2342
|
-
type: Input
|
|
2343
|
-
}], shownMaskExpression: [{
|
|
2344
|
-
type: Input
|
|
2345
|
-
}], showTemplate: [{
|
|
2346
|
-
type: Input
|
|
2347
|
-
}], clearIfNotMatch: [{
|
|
2348
|
-
type: Input
|
|
2349
|
-
}], validation: [{
|
|
2350
|
-
type: Input
|
|
2351
|
-
}], separatorLimit: [{
|
|
2352
|
-
type: Input
|
|
2353
|
-
}], allowNegativeNumbers: [{
|
|
2354
|
-
type: Input
|
|
2355
|
-
}], leadZeroDateTime: [{
|
|
2356
|
-
type: Input
|
|
2357
|
-
}], leadZero: [{
|
|
2358
|
-
type: Input
|
|
2359
|
-
}], triggerOnMaskChange: [{
|
|
2360
|
-
type: Input
|
|
2361
|
-
}], apm: [{
|
|
2362
|
-
type: Input
|
|
2363
|
-
}], inputTransformFn: [{
|
|
2364
|
-
type: Input
|
|
2365
|
-
}], outputTransformFn: [{
|
|
2366
|
-
type: Input
|
|
2367
|
-
}], keepCharacterPositions: [{
|
|
2368
|
-
type: Input
|
|
2369
|
-
}], maskFilled: [{
|
|
2370
|
-
type: Output
|
|
2371
|
-
}], onPaste: [{
|
|
2323
|
+
}], propDecorators: { onPaste: [{
|
|
2372
2324
|
type: HostListener,
|
|
2373
2325
|
args: ['paste']
|
|
2374
2326
|
}], onFocus: [{
|
|
@@ -2400,8 +2352,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
2400
2352
|
class NgxMaskPipe {
|
|
2401
2353
|
defaultOptions = inject(NGX_MASK_CONFIG);
|
|
2402
2354
|
_maskService = inject(NgxMaskService);
|
|
2403
|
-
_maskExpressionArray = [];
|
|
2404
|
-
|
|
2355
|
+
_maskExpressionArray = signal([]);
|
|
2356
|
+
_mask = signal('');
|
|
2405
2357
|
transform(value, mask, { patterns, ...config } = {}) {
|
|
2406
2358
|
let processedValue = value;
|
|
2407
2359
|
const currentConfig = {
|
|
@@ -2419,13 +2371,13 @@ class NgxMaskPipe {
|
|
|
2419
2371
|
if (mask.includes('||')) {
|
|
2420
2372
|
const maskParts = mask.split('||');
|
|
2421
2373
|
if (maskParts.length > 1) {
|
|
2422
|
-
this._maskExpressionArray
|
|
2374
|
+
this._maskExpressionArray.set(maskParts.sort((a, b) => a.length - b.length));
|
|
2423
2375
|
this._setMask(processedValue);
|
|
2424
|
-
return this._maskService.applyMask(`${processedValue}`, this.
|
|
2376
|
+
return this._maskService.applyMask(`${processedValue}`, this._mask());
|
|
2425
2377
|
}
|
|
2426
2378
|
else {
|
|
2427
|
-
this._maskExpressionArray
|
|
2428
|
-
return this._maskService.applyMask(`${processedValue}`, this.
|
|
2379
|
+
this._maskExpressionArray.set([]);
|
|
2380
|
+
return this._maskService.applyMask(`${processedValue}`, this._mask());
|
|
2429
2381
|
}
|
|
2430
2382
|
}
|
|
2431
2383
|
if (mask.includes(MaskExpression.CURLY_BRACKETS_LEFT)) {
|
|
@@ -2465,26 +2417,26 @@ class NgxMaskPipe {
|
|
|
2465
2417
|
return this._maskService.applyMask(`${processedValue}`, mask);
|
|
2466
2418
|
}
|
|
2467
2419
|
_setMask(value) {
|
|
2468
|
-
if (this._maskExpressionArray.length > 0) {
|
|
2469
|
-
this._maskExpressionArray.some((mask) => {
|
|
2420
|
+
if (this._maskExpressionArray().length > 0) {
|
|
2421
|
+
this._maskExpressionArray().some((mask) => {
|
|
2470
2422
|
const test = this._maskService.removeMask(value)?.length <=
|
|
2471
2423
|
this._maskService.removeMask(mask)?.length;
|
|
2472
2424
|
if (value && test) {
|
|
2473
|
-
this.mask
|
|
2425
|
+
this._mask.set(mask);
|
|
2474
2426
|
return test;
|
|
2475
2427
|
}
|
|
2476
2428
|
else {
|
|
2477
|
-
const expression = this._maskExpressionArray[this._maskExpressionArray.length - 1] ??
|
|
2429
|
+
const expression = this._maskExpressionArray()[this._maskExpressionArray.length - 1] ??
|
|
2478
2430
|
MaskExpression.EMPTY_STRING;
|
|
2479
|
-
this.
|
|
2431
|
+
this._mask.set(expression);
|
|
2480
2432
|
}
|
|
2481
2433
|
});
|
|
2482
2434
|
}
|
|
2483
2435
|
}
|
|
2484
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.
|
|
2485
|
-
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.0.
|
|
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" });
|
|
2486
2438
|
}
|
|
2487
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.
|
|
2439
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: NgxMaskPipe, decorators: [{
|
|
2488
2440
|
type: Pipe,
|
|
2489
2441
|
args: [{
|
|
2490
2442
|
name: 'mask',
|