ngx-mask 20.0.1 → 20.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/ngx-mask.mjs +10 -3
- package/fesm2022/ngx-mask.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/package.json +1 -1
package/fesm2022/ngx-mask.mjs
CHANGED
|
@@ -927,6 +927,7 @@ class NgxMaskService extends NgxMaskApplierService {
|
|
|
927
927
|
* since writeValue should be a one way only process of writing the DOM value based on the Angular model value.
|
|
928
928
|
*/
|
|
929
929
|
writingValue = false;
|
|
930
|
+
isInitialized = false;
|
|
930
931
|
_emitValue = false;
|
|
931
932
|
_start;
|
|
932
933
|
_end;
|
|
@@ -1113,7 +1114,6 @@ class NgxMaskService extends NgxMaskApplierService {
|
|
|
1113
1114
|
this.currentValue = result;
|
|
1114
1115
|
this._emitValue =
|
|
1115
1116
|
this.previousValue !== this.currentValue ||
|
|
1116
|
-
(newInputValue !== this.currentValue && this.writingValue) ||
|
|
1117
1117
|
(this.previousValue === this.currentValue && justPasted);
|
|
1118
1118
|
}
|
|
1119
1119
|
// Propagate the input value back to the Angular model
|
|
@@ -1391,6 +1391,9 @@ class NgxMaskService extends NgxMaskApplierService {
|
|
|
1391
1391
|
: (v) => v;
|
|
1392
1392
|
this.writingValue = false;
|
|
1393
1393
|
this.maskChanged = false;
|
|
1394
|
+
if (!this.isInitialized && this._emitValue) {
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1394
1397
|
if (Array.isArray(this.dropSpecialCharacters)) {
|
|
1395
1398
|
this.onChange(outputTransformFn(this._toNumber(this._checkSymbols(this._removeMask(this._removeSuffix(this._removePrefix(inputValue)), this.dropSpecialCharacters)))));
|
|
1396
1399
|
}
|
|
@@ -1516,7 +1519,7 @@ class NgxMaskService extends NgxMaskApplierService {
|
|
|
1516
1519
|
const separatorPrecision = this.getPrecision(separatorExpression);
|
|
1517
1520
|
let value = separatorValue;
|
|
1518
1521
|
if (separatorExpression.indexOf('2') > 0 ||
|
|
1519
|
-
(this.leadZero && Number(separatorPrecision) > 0)) {
|
|
1522
|
+
(this.leadZero && Number(separatorPrecision) > 0 && Number.isFinite(separatorPrecision))) {
|
|
1520
1523
|
if (this.decimalMarker === MaskExpression.COMMA && this.leadZero) {
|
|
1521
1524
|
value = value.replace(',', '.');
|
|
1522
1525
|
}
|
|
@@ -1901,6 +1904,7 @@ class NgxMaskDirective {
|
|
|
1901
1904
|
}
|
|
1902
1905
|
}
|
|
1903
1906
|
onInput(e) {
|
|
1907
|
+
this._maskService.isInitialized = true;
|
|
1904
1908
|
// If IME is composing text, we wait for the composed text.
|
|
1905
1909
|
if (this._isComposing()) {
|
|
1906
1910
|
return;
|
|
@@ -2208,8 +2212,9 @@ class NgxMaskDirective {
|
|
|
2208
2212
|
const el = e.target;
|
|
2209
2213
|
this._inputValue.set(el.value);
|
|
2210
2214
|
this._setMask();
|
|
2215
|
+
const isTextarea = el.tagName.toLowerCase() === 'textarea';
|
|
2211
2216
|
if (el.type !== 'number') {
|
|
2212
|
-
if (e.key === MaskExpression.ARROW_UP) {
|
|
2217
|
+
if (e.key === MaskExpression.ARROW_UP && !isTextarea) {
|
|
2213
2218
|
e.preventDefault();
|
|
2214
2219
|
}
|
|
2215
2220
|
if (e.key === MaskExpression.ARROW_LEFT ||
|
|
@@ -2339,9 +2344,11 @@ class NgxMaskDirective {
|
|
|
2339
2344
|
];
|
|
2340
2345
|
// Let the service know we've finished writing value
|
|
2341
2346
|
this._maskService.writingValue = false;
|
|
2347
|
+
this._maskService.isInitialized = true;
|
|
2342
2348
|
}
|
|
2343
2349
|
else {
|
|
2344
2350
|
this._maskService.formElementProperty = ['value', inputValue];
|
|
2351
|
+
this._maskService.isInitialized = true;
|
|
2345
2352
|
}
|
|
2346
2353
|
this._inputValue.set(inputValue);
|
|
2347
2354
|
}
|