ngx-mask 20.0.0 → 20.0.1

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 &&