@7shifts/sous-chef 3.31.1-beta → 3.31.1-beta2

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.
@@ -8980,8 +8980,11 @@ var calculateMask = function calculateMask(_ref) {
8980
8980
  var slotsSet = new Set(slots);
8981
8981
  var accept = new RegExp('\\d', 'g');
8982
8982
  var inputMatches = value.match(accept) || [];
8983
- if (isReplacingDigit(slots, format, inputMatches.length)) {
8984
- inputMatches.splice(cursorPosition.selectionStart, 1);
8983
+ var _calculateDigitReplac = calculateDigitReplacement(slots, format, inputMatches.length, cursorPosition),
8984
+ isReplacingDigit = _calculateDigitReplac.isReplacingDigit,
8985
+ isReplacingAt = _calculateDigitReplac.isReplacingAt;
8986
+ if (isReplacingDigit) {
8987
+ inputMatches.splice(isReplacingAt, 1);
8985
8988
  }
8986
8989
  if (isDeletingAnchor) {
8987
8990
  inputMatches.pop();
@@ -9020,10 +9023,19 @@ var calculateCursorPosition = function calculateCursorPosition(params) {
9020
9023
  });
9021
9024
  return calculatedCursorRange;
9022
9025
  };
9023
- var isReplacingDigit = function isReplacingDigit(slots, format, amountOfDigitsTyped) {
9026
+ var calculateDigitReplacement = function calculateDigitReplacement(slots, format, amountOfDigitsTyped, cursorPosition) {
9024
9027
  var slotsRegExp = new RegExp("[" + slots.split('').join('|') + "]", 'g');
9025
9028
  var slotsMatches = format.match(slotsRegExp) || [];
9026
- return amountOfDigitsTyped > slotsMatches.length;
9029
+ var isReplacingDigit = amountOfDigitsTyped > slotsMatches.length;
9030
+ var getCharacterPosition = function getCharacterPosition() {
9031
+ var formatUntilTheCursorPoint = format.slice(0, cursorPosition.selectionStart);
9032
+ var slotsFormatSlicedMatches = formatUntilTheCursorPoint.match(slotsRegExp) || [];
9033
+ return slotsFormatSlicedMatches.length;
9034
+ };
9035
+ return {
9036
+ isReplacingDigit: isReplacingDigit,
9037
+ isReplacingAt: isReplacingDigit ? getCharacterPosition() : 0
9038
+ };
9027
9039
  };
9028
9040
 
9029
9041
  var useFieldMask = function useFieldMask(format) {