ngx-mask 20.0.0 → 20.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.
@@ -184,8 +184,11 @@ class NgxMaskApplierService {
184
184
  let stepBack = false;
185
185
  let processedValue = inputValue;
186
186
  let processedPosition = position;
187
- if (processedValue.slice(0, this.prefix.length) === this.prefix) {
188
- processedValue = processedValue.slice(this.prefix.length, processedValue.length);
187
+ const startsWithPrefix = processedValue.slice(0, this.prefix.length) === this.prefix;
188
+ const pastedFullWithPrefix = justPasted && processedValue.length === this.prefix.length + maskExpression.length;
189
+ const looksLikeFullPrefixPaste = processedValue === this.prefix + processedValue.slice(this.prefix.length);
190
+ if (startsWithPrefix && (pastedFullWithPrefix || looksLikeFullPrefixPaste)) {
191
+ processedValue = processedValue.slice(this.prefix.length);
189
192
  }
190
193
  if (!!this.suffix && processedValue.length > 0) {
191
194
  processedValue = this.checkAndRemoveSuffix(processedValue);
@@ -395,7 +398,9 @@ class NgxMaskApplierService {
395
398
  result = this._formatWithSeparators(strForSep, this.thousandSeparator, this.decimalMarker, precision);
396
399
  const commaShift = result.indexOf(MaskExpression.COMMA) - processedValue.indexOf(MaskExpression.COMMA);
397
400
  const shiftStep = result.length - processedValue.length;
398
- const backspacedDecimalMarkerWithSeparatorLimit = backspaced && result.length < inputValue.length && this.separatorLimit;
401
+ const backspacedDecimalMarkerWithSeparatorLimit = backspaced &&
402
+ result.length < inputValue.length - this.suffix.length &&
403
+ this.separatorLimit;
399
404
  if ((result[processedPosition - 1] === this.thousandSeparator ||
400
405
  result[processedPosition - this.prefix.length]) &&
401
406
  this.prefix &&
@@ -1511,7 +1516,7 @@ class NgxMaskService extends NgxMaskApplierService {
1511
1516
  const separatorPrecision = this.getPrecision(separatorExpression);
1512
1517
  let value = separatorValue;
1513
1518
  if (separatorExpression.indexOf('2') > 0 ||
1514
- (this.leadZero && Number(separatorPrecision) > 0)) {
1519
+ (this.leadZero && Number(separatorPrecision) > 0 && Number.isFinite(separatorPrecision))) {
1515
1520
  if (this.decimalMarker === MaskExpression.COMMA && this.leadZero) {
1516
1521
  value = value.replace(',', '.');
1517
1522
  }
@@ -2203,8 +2208,9 @@ class NgxMaskDirective {
2203
2208
  const el = e.target;
2204
2209
  this._inputValue.set(el.value);
2205
2210
  this._setMask();
2211
+ const isTextarea = el.tagName.toLowerCase() === 'textarea';
2206
2212
  if (el.type !== 'number') {
2207
- if (e.key === MaskExpression.ARROW_UP) {
2213
+ if (e.key === MaskExpression.ARROW_UP && !isTextarea) {
2208
2214
  e.preventDefault();
2209
2215
  }
2210
2216
  if (e.key === MaskExpression.ARROW_LEFT ||