PageSourceSearch

https://www.staymelloami.com/wp-content/themes/melloTheme2022/js/v-mask.js?ver=2.0.2

js staymelloami.com collected 2026-10-08 23:43:02 UTC 13,896 bytes, 438 lines download raw bytes

1(function (global, factory) {
2  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4  (global = global || self, factory(global.VueMask = {}));
5}(this, function (exports) { 'use strict';
6
7  function _typeof(obj) {
8    if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
9      _typeof = function (obj) {
10        return typeof obj;
11      };
12    } else {
13      _typeof = function (obj) {
14        return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
15      };
16    }
17
18    return _typeof(obj);
19  }
20
21  function _defineProperty(obj, key, value) {
22    if (key in obj) {
23      Object.defineProperty(obj, key, {
24        value: value,
25        enumerable: true,
26        configurable: true,
27        writable: true
28      });
29    } else {
30      obj[key] = value;
31    }
32
33    return obj;
34  }
35
36  function ownKeys(object, enumerableOnly) {
37    var keys = Object.keys(object);
38
39    if (Object.getOwnPropertySymbols) {
40      var symbols = Object.getOwnPropertySymbols(object);
41      if (enumerableOnly) symbols = symbols.filter(function (sym) {
42        return Object.getOwnPropertyDescriptor(object, sym).enumerable;
43      });
44      keys.push.apply(keys, symbols);
45    }
46
47    return keys;
48  }
49
50  function _objectSpread2(target) {
51    for (var i = 1; i < arguments.length; i++) {
52      var source = arguments[i] != null ? arguments[i] : {};
53
54      if (i % 2) {
55        ownKeys(source, true).forEach(function (key) {
56          _defineProperty(target, key, source[key]);
57        });
58      } else if (Object.getOwnPropertyDescriptors) {
59        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
60      } else {
61        ownKeys(source).forEach(function (key) {
62          Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
63        });
64      }
65    }
66
67    return target;
68  }
69
70  var placeholderChar = '_';
71  var strFunction = 'function';
72
73  var emptyArray = [];
74  function convertMaskToPlaceholder() {
75    var mask = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : emptyArray;
76    var placeholderChar$1 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : placeholderChar;
77
78    if (!isArray(mask)) {
79      throw new Error('Text-mask:convertMaskToPlaceholder; The mask property must be an array.');
80    }
81
82    if (mask.indexOf(placeholderChar$1) !== -1) {
83      throw new Error('Placeholder character must not be used as part of the mask. Please specify a character ' + 'that is not present in your mask as your placeholder character.\n\n' + "The placeholder character that was received is: ".concat(JSON.stringify(placeholderChar$1), "\n\n") + "The mask that was received is: ".concat(JSON.stringify(mask)));
84    }
85
86    return mask.map(function (char) {
87      return char instanceof RegExp ? placeholderChar$1 : char;
88    }).join('');
89  }
90  function isArray(value) {
91    return Array.isArray && Array.isArray(value) || value instanceof Array;
92  }
93  var strCaretTrap = '[]';
94  function processCaretTraps(mask) {
95    var indexes = [];
96    var indexOfCaretTrap;
97
98    while (indexOfCaretTrap = mask.indexOf(strCaretTrap), indexOfCaretTrap !== -1) {
99      indexes.push(indexOfCaretTrap);
100      mask.splice(indexOfCaretTrap, 1);
101    }
102
103    return {
104      maskWithoutCaretTraps: mask,
105      indexes: indexes
106    };
107  }
108
109  var emptyArray$1 = [];
110  var emptyString = '';
111  function conformToMask() {
112    var rawValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : emptyString;
113    var mask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : emptyArray$1;
114    var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
115
116    if (!isArray(mask)) {
117      if (_typeof(mask) === strFunction) {
118        mask = mask(rawValue, config);
119        mask = processCaretTraps(mask).maskWithoutCaretTraps;
120      } else {
121        throw new Error('Text-mask:conformToMask; The mask property must be an array.');
122      }
123    }
124
125    var _config$guide = config.guide,
126        guide = _config$guide === void 0 ? true : _config$guide,
127        _config$previousConfo = config.previousConformedValue,
128        previousConformedValue = _config$previousConfo === void 0 ? emptyString : _config$previousConfo,
129        _config$placeholderCh = config.placeholderChar,
130        placeholderChar$1 = _config$placeholderCh === void 0 ? placeholderChar : _config$placeholderCh,
131        _config$placeholder = config.placeholder,
132        placeholder = _config$placeholder === void 0 ? convertMaskToPlaceholder(mask, placeholderChar$1) : _
vendor: 6,027 bytes, lines 132-314
132config$placeholder,
133        currentCaretPosition = config.currentCaretPosition,
134        keepCharPositions = config.keepCharPositions;
135    var suppressGuide = guide === false && previousConformedValue !== undefined;
136    var rawValueLength = rawValue.length;
137    var previousConformedValueLength = previousConformedValue.length;
138    var placeholderLength = placeholder.length;
139    var maskLength = mask.length;
140    var editDistance = rawValueLength - previousConformedValueLength;
141    var isAddition = editDistance > 0;
142    var indexOfFirstChange = currentCaretPosition + (isAddition ? -editDistance : 0);
143    var indexOfLastChange = indexOfFirstChange + Math.abs(editDistance);
144
145    if (keepCharPositions === true && !isAddition) {
146      var compensatingPlaceholderChars = emptyString;
147
148      for (var i = indexOfFirstChange; i < indexOfLastChange; i++) {
149        if (placeholder[i] === placeholderChar$1) {
150          compensatingPlaceholderChars += placeholderChar$1;
151        }
152      }
153
154      rawValue = rawValue.slice(0, indexOfFirstChange) + compensatingPlaceholderChars + rawValue.slice(indexOfFirstChange, rawValueLength);
155    }
156
157    var rawValueArr = rawValue.split(emptyString).map(function (char, i) {
158      return {
159        char: char,
160        isNew: i >= indexOfFirstChange && i < indexOfLastChange
161      };
162    });
163
164    for (var _i = rawValueLength - 1; _i >= 0; _i--) {
165      var char = rawValueArr[_i].char;
166
167      if (char !== placeholderChar$1) {
168        var shouldOffset = _i >= indexOfFirstChange && previousConformedValueLength === maskLength;
169
170        if (char === placeholder[shouldOffset ? _i - editDistance : _i]) {
171          rawValueArr.splice(_i, 1);
172        }
173      }
174    }
175
176    var conformedValue = emptyString;
177    var someCharsRejected = false;
178
179    placeholderLoop: for (var _i2 = 0; _i2 < placeholderLength; _i2++) {
180      var charInPlaceholder = placeholder[_i2];
181
182      if (charInPlaceholder === placeholderChar$1) {
183        if (rawValueArr.length > 0) {
184          while (rawValueArr.length > 0) {
185            var _rawValueArr$shift = rawValueArr.shift(),
186                rawValueChar = _rawValueArr$shift.char,
187                isNew = _rawValueArr$shift.isNew;
188
189            if (rawValueChar === placeholderChar$1 && suppressGuide !== true) {
190              conformedValue += placeholderChar$1;
191              continue placeholderLoop;
192            } else if (mask[_i2].test(rawValueChar)) {
193              if (keepCharPositions !== true || isNew === false || previousConformedValue === emptyString || guide === false || !isAddition) {
194                conformedValue += rawValueChar;
195              } else {
196                var rawValueArrLength = rawValueArr.length;
197                var indexOfNextAvailablePlaceholderChar = null;
198
199                for (var _i3 = 0; _i3 < rawValueArrLength; _i3++) {
200                  var charData = rawValueArr[_i3];
201
202                  if (charData.char !== placeholderChar$1 && charData.isNew === false) {
203                    break;
204                  }
205
206                  if (charData.char === placeholderChar$1) {
207                    indexOfNextAvailablePlaceholderChar = _i3;
208                    break;
209                  }
210                }
211
212                if (indexOfNextAvailablePlaceholderChar !== null) {
213                  conformedValue += rawValueChar;
214                  rawValueArr.splice(indexOfNextAvailablePlaceholderChar, 1);
215                } else {
216                  _i2--;
217                }
218              }
219
220              continue placeholderLoop;
221            } else {
222              someCharsRejected = true;
223            }
224          }
225        }
226
227        if (suppressGuide === false) {
228          conformedValue += placeholder.substr(_i2, placeholderLength);
229        }
230
231        break;
232      } else {
233        conformedValue += charInPlaceholder;
234      }
235    }
236
237    if (suppressGuide && isAddition === false) {
238      var indexOfLastFilledPlaceholderChar = null;
239
240      for (var _i4 = 0; _i4 < conformedValue.length; _i4++) {
241        if (placeholder[_i4] === placeholderChar$1) {
242          indexOfLastFilledPlaceholderChar = _i4;
243        }
244      }
245
246      if (indexOfLastFilledPlaceholderChar !== null) {
247        conformedValue = conformedValue.substr(0, indexOfLastFilledPlaceholderChar + 1);
248      } else {
249        conformedValue = emptyString;
250      }
251    }
252
253    return {
254      conformedValue: conformedValue,
255      meta: {
256        someCharsRejected: someCharsRejected
257      }
258    };
259  }
260
261  var NEXT_CHAR_OPTIONAL = {
262    __nextCharOptional__: true
263  };
264  var defaultMaskReplacers = {
265    '#': /\d/,
266    A: /[a-z]/i,
267    N: /[a-z0-9]/i,
268    '?': NEXT_CHAR_OPTIONAL,
269    X: /./
270  };
271
272  var stringToRegexp = function stringToRegexp(str) {
273    var lastSlash = str.lastIndexOf('/');
274    return new RegExp(str.slice(1, lastSlash), str.slice(lastSlash + 1));
275  };
276
277  var makeRegexpOptional = function makeRegexpOptional(charRegexp) {
278    return stringToRegexp(charRegexp.toString().replace(/.(\/)[gmiyus]{0,6}$/, function (match) {
279      return match.replace('/', '?/');
280    }));
281  };
282
283  var escapeIfNeeded = function escapeIfNeeded(char) {
284    return '[\\^$.|?*+()'.indexOf(char) > -1 ? "\\".concat(char) : char;
285  };
286
287  var charRegexp = function charRegexp(char) {
288    return new RegExp("/[".concat(escapeIfNeeded(char), "]/"));
289  };
290
291  var isRegexp = function isRegexp(entity) {
292    return entity instanceof RegExp;
293  };
294
295  var castToRegexp = function castToRegexp(char) {
296    return isRegexp(char) ? char : charRegexp(char);
297  };
298
299  function stringMaskToRegExpMask(stringMask) {
300    return stringMask.split('').map(function (char, index, array) {
301      var maskChar = defaultMaskReplacers[char] || char;
302      var previousChar = array[index - 1];
303      var previousMaskChar = defaultMaskReplacers[previousChar] || previousChar;
304
305      if (maskChar === NEXT_CHAR_OPTIONAL) {
306        return null;
307      }
308
309      if (previousMaskChar === NEXT_CHAR_OPTIONAL) {
310        return makeRegexpOptional(castToRegexp(maskChar));
311      }
312
313      return maskChar;
314    }
314).filter(Boolean);
315  }
316
317  var trigger = function trigger(el, type) {
318    var e = document.createEvent('HTMLEvents');
319    e.initEvent(type, true, true);
320    el.dispatchEvent(e);
321  };
322  var queryInputElementInside = function queryInputElementInside(el) {
323    return el instanceof HTMLInputElement ? el : el.querySelector('input') || el;
324  };
325
326  var inBrowser = typeof window !== 'undefined';
327  var UA = inBrowser && window.navigator.userAgent.toLowerCase();
328  var isEdge = UA && UA.indexOf('edge/') > 0;
329  var isAndroid = UA && UA.indexOf('android') > 0;
330  var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
331
332  function createOptions() {
333    var elementOptions = new Map();
334    var defaultOptions = {
335      previousValue: '',
336      mask: []
337    };
338
339    function get(el) {
340      return elementOptions.get(el) || _objectSpread2({}, defaultOptions);
341    }
342
343    function partiallyUpdate(el, newOptions) {
344      elementOptions.set(el, _objectSpread2({}, get(el), {}, newOptions));
345    }
346
347    function remove(el) {
348      elementOptions.delete(el);
349    }
350
351    return {
352      partiallyUpdate: partiallyUpdate,
353      remove: remove,
354      get: get
355    };
356  }
357
358  var options = createOptions();
359
360  function triggerInputUpdate(el) {
361    var fn = trigger.bind(null, el, 'input');
362
363    if (isAndroid && isChrome) {
364      setTimeout(fn, 0);
365    } else {
366      fn();
367    }
368  }
369
370  function updateValue(el) {
371    var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
372    var value = el.value;
373
374    var _options$get = options.get(el),
375        previousValue = _options$get.previousValue,
376        mask = _options$get.mask;
377
378    var isValueChanged = value !== previousValue;
379    var isLengthIncreased = value.length > previousValue.length;
380    var isUpdateNeeded = value && isValueChanged && isLengthIncreased;
381
382    if (force || isUpdateNeeded) {
383      var _conformToMask = conformToMask(value, mask, {
384        guide: false
385      }),
386          conformedValue = _conformToMask.conformedValue;
387
388      el.value = conformedValue;
389      triggerInputUpdate(el);
390    }
391
392    options.partiallyUpdate(el, {
393      previousValue: value
394    });
395  }
396
397  function updateMask(el, mask) {
398    options.partiallyUpdate(el, {
399      mask: stringMaskToRegExpMask(mask)
400    });
401  }
402
403  var directive = {
404    bind: function bind(el, _ref) {
405      var value = _ref.value;
406      el = queryInputElementInside(el);
407      updateMask(el, value);
408      updateValue(el);
409    },
410    componentUpdated: function componentUpdated(el, _ref2) {
411      var value = _ref2.value,
412          oldValue = _ref2.oldValue;
413      el = queryInputElementInside(el);
414      var isMaskChanged = value !== oldValue;
415
416      if (isMaskChanged) {
417        updateMask(el, value);
418      }
419
420      updateValue(el, isMaskChanged);
421    },
422    unbind: function unbind(el) {
423      el = queryInputElementInside(el);
424      options.remove(el);
425    }
426  };
427
428  var plugin = (function (Vue) {
429    Vue.directive('mask', directive);
430  });
431
432  exports.VueMaskDirective = directive;
433  exports.VueMaskPlugin = plugin;
434  exports.default = plugin;
435
436  Object.defineProperty(exports, '__esModule', { value: true });
437
438}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.