use-mask-input 1.0.1 → 2.0.0

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.
Files changed (51) hide show
  1. package/dist/example/App.example.d.ts +3 -0
  2. package/dist/{useMaskInput.test.d.ts → example/index.d.ts} +0 -0
  3. package/dist/index.js +1 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.modern.js +1 -2
  6. package/dist/index.modern.js.map +1 -1
  7. package/dist/useMaskInput.d.ts +3 -3
  8. package/node_modules/inputmask/README.md +109 -79
  9. package/node_modules/inputmask/bundle.js +6 -5
  10. package/node_modules/inputmask/dist/inputmask.es6.js +5 -0
  11. package/node_modules/inputmask/dist/inputmask.js +2892 -2608
  12. package/node_modules/inputmask/dist/inputmask.min.js +3 -3
  13. package/node_modules/inputmask/dist/jquery.inputmask.js +2829 -2534
  14. package/node_modules/inputmask/dist/jquery.inputmask.min.js +3 -3
  15. package/node_modules/inputmask/lib/bindings/inputmask.es6.js +5 -0
  16. package/node_modules/inputmask/lib/canUseDOM.js +7 -0
  17. package/node_modules/inputmask/lib/defaults.js +101 -0
  18. package/node_modules/inputmask/lib/definitions.js +13 -0
  19. package/node_modules/inputmask/lib/dependencyLibs/data.js +8 -0
  20. package/node_modules/inputmask/lib/dependencyLibs/events.js +199 -0
  21. package/node_modules/inputmask/lib/dependencyLibs/extend.js +58 -0
  22. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.jquery.js +4 -3
  23. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.js +12 -343
  24. package/node_modules/inputmask/lib/environment.js +9 -0
  25. package/node_modules/inputmask/lib/escapeRegex.js +4 -0
  26. package/node_modules/inputmask/lib/eventhandlers.js +513 -0
  27. package/node_modules/inputmask/lib/eventruler.js +124 -0
  28. package/node_modules/inputmask/lib/extensions/inputmask.date.extensions.js +552 -385
  29. package/node_modules/inputmask/lib/extensions/inputmask.extensions.js +116 -97
  30. package/node_modules/inputmask/lib/extensions/inputmask.numeric.extensions.js +594 -565
  31. package/node_modules/inputmask/lib/global/window.js +2 -6
  32. package/node_modules/inputmask/lib/inputHandling.js +252 -0
  33. package/node_modules/inputmask/lib/inputmask.js +129 -126
  34. package/node_modules/inputmask/lib/inputmaskElement.js +26 -20
  35. package/node_modules/inputmask/lib/jquery.inputmask.js +3 -1
  36. package/node_modules/inputmask/lib/keycode.json +6 -1
  37. package/node_modules/inputmask/lib/mask-lexer.js +467 -0
  38. package/node_modules/inputmask/lib/mask.js +244 -0
  39. package/node_modules/inputmask/lib/masktoken.js +13 -0
  40. package/node_modules/inputmask/lib/polyfills/Array.includes.js +48 -0
  41. package/node_modules/inputmask/lib/polyfills/Object.getPrototypeOf.js +7 -0
  42. package/node_modules/inputmask/lib/positioning.js +348 -0
  43. package/node_modules/inputmask/lib/validation-tests.js +597 -0
  44. package/node_modules/inputmask/lib/validation.js +664 -0
  45. package/node_modules/inputmask/package.json +41 -71
  46. package/package.json +40 -43
  47. package/node_modules/inputmask/CHANGELOG.md +0 -714
  48. package/node_modules/inputmask/index.js +0 -1
  49. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.jqlite.js +0 -170
  50. package/node_modules/inputmask/lib/maskScope.js +0 -2498
  51. package/node_modules/inputmask/lib/maskset.js +0 -466
@@ -1,27 +1,33 @@
1
+ import window from "./global/window";
1
2
  import Inputmask from "./inputmask";
3
+ import canUseDOM from "./canUseDOM";
4
+
5
+ const document = window.document;
2
6
 
3
7
  // add check if it is supported by the browser
4
8
  // integrate shadowroot into maskcope
5
- if (document.head.createShadowRoot || document.head.attachShadow) {
6
- class InputmaskElement extends HTMLElement {
7
- constructor() {
8
- super();
9
- var attributeNames = this.getAttributeNames(),
10
- shadow = this.attachShadow({ mode: "closed" }),
11
- input = document.createElement("input");
12
- input.type = "text";
13
- shadow.appendChild(input);
9
+ if (canUseDOM && document && document.head && document.head.attachShadow && window.customElements && window.customElements.get("input-mask") === undefined) {
10
+ class InputmaskElement extends HTMLElement {
11
+ constructor() {
12
+ super();
13
+ var attributeNames = this.getAttributeNames(),
14
+ shadow = this.attachShadow({mode: "closed"}),
15
+ input = document.createElement("input");
16
+ input.type = "text";
17
+ shadow.appendChild(input);
14
18
 
15
- for (var attr in attributeNames) {
16
- if (Object.prototype.hasOwnProperty.call(attributeNames, attr)) {
17
- input.setAttribute("data-inputmask-" + attributeNames[attr], this.getAttribute(attributeNames[attr]));
18
- }
19
- }
19
+ for (var attr in attributeNames) {
20
+ if (Object.prototype.hasOwnProperty.call(attributeNames, attr)) {
21
+ input.setAttribute(attributeNames[attr], this.getAttribute(attributeNames[attr]));
22
+ }
23
+ }
20
24
 
21
- new Inputmask().mask(input);
22
- input.inputmask.shadowRoot = shadow; //make the shadowRoot available
23
- }
24
- }
25
+ var im = new Inputmask();
26
+ im.dataAttribute = "";
27
+ im.mask(input);
28
+ input.inputmask.shadowRoot = shadow; //make the shadowRoot available
29
+ }
30
+ }
25
31
 
26
- customElements.define("input-mask", InputmaskElement);
27
- }
32
+ window.customElements.define("input-mask", InputmaskElement);
33
+ }
@@ -4,7 +4,9 @@
4
4
  * Copyright (c) Robin Herbots
5
5
  * Licensed under the MIT license
6
6
  */
7
- var $ = require("jquery"), Inputmask = require("./inputmask");
7
+ import $ from "jquery";
8
+ import Inputmask from "./inputmask";
9
+
8
10
  if ($.fn.inputmask === undefined) {
9
11
  //jquery plugin
10
12
  $.fn.inputmask = function (fn, options) {
@@ -16,5 +16,10 @@
16
16
  "TAB": 9,
17
17
  "UP": 38,
18
18
  "X": 88,
19
- "CONTROL": 17
19
+ "Z": 90,
20
+ "CONTROL": 17,
21
+ "PAUSE/BREAK": 19,
22
+ "WINDOWS_LEFT": 91,
23
+ "WINDOWS_RIGHT": 92,
24
+ "KEY_229": 229
20
25
  }
@@ -0,0 +1,467 @@
1
+ import $ from "./dependencyLibs/inputmask.dependencyLib";
2
+ import MaskToken from "./masktoken";
3
+ import Inputmask from "./inputmask";
4
+
5
+ export {generateMaskSet, analyseMask};
6
+
7
+ function generateMaskSet(opts, nocache) {
8
+ var ms;
9
+
10
+ function generateMask(mask, metadata, opts) {
11
+ var regexMask = false;
12
+ if (mask === null || mask === "") {
13
+ regexMask = opts.regex !== null;
14
+ if (regexMask) {
15
+ mask = opts.regex;
16
+ mask = mask.replace(/^(\^)(.*)(\$)$/, "$2");
17
+ } else {
18
+ regexMask = true;
19
+ mask = ".*";
20
+ }
21
+ }
22
+ if (mask.length === 1 && opts.greedy === false && opts.repeat !== 0) {
23
+ opts.placeholder = "";
24
+ } //hide placeholder with single non-greedy mask
25
+ if (opts.repeat > 0 || opts.repeat === "*" || opts.repeat === "+") {
26
+ var repeatStart = opts.repeat === "*" ? 0 : (opts.repeat === "+" ? 1 : opts.repeat);
27
+ mask = opts.groupmarker[0] + mask + opts.groupmarker[1] + opts.quantifiermarker[0] + repeatStart + "," + opts.repeat + opts.quantifiermarker[1];
28
+ }
29
+
30
+ // console.log(mask);
31
+ var masksetDefinition, maskdefKey;
32
+ maskdefKey = regexMask ? "regex_" + opts.regex : opts.numericInput ? mask.split("").reverse().join("") : mask;
33
+ if (opts.keepStatic !== null) { //keepstatic modifies the output from the testdefinitions ~ so differentiate in the maskcache
34
+ maskdefKey = "ks_" + opts.keepStatic + maskdefKey;
35
+ }
36
+
37
+ if (Inputmask.prototype.masksCache[maskdefKey] === undefined || nocache === true) {
38
+ masksetDefinition = {
39
+ "mask": mask,
40
+ "maskToken": Inputmask.prototype.analyseMask(mask, regexMask, opts),
41
+ "validPositions": {},
42
+ "_buffer": undefined,
43
+ "buffer": undefined,
44
+ "tests": {},
45
+ "excludes": {}, //excluded alternations
46
+ "metadata": metadata,
47
+ "maskLength": undefined,
48
+ "jitOffset": {}
49
+ };
50
+ if (nocache !== true) {
51
+ Inputmask.prototype.masksCache[maskdefKey] = masksetDefinition;
52
+ masksetDefinition = $.extend(true, {}, Inputmask.prototype.masksCache[maskdefKey]);
53
+ }
54
+ } else {
55
+ masksetDefinition = $.extend(true, {}, Inputmask.prototype.masksCache[maskdefKey]);
56
+ }
57
+
58
+ return masksetDefinition;
59
+ }
60
+
61
+ if (typeof opts.mask === "function") { //allow mask to be a preprocessing fn - should return a valid mask
62
+ opts.mask = opts.mask(opts);
63
+ }
64
+ if (Array.isArray(opts.mask)) {
65
+ if (opts.mask.length > 1) {
66
+ if (opts.keepStatic === null) { //enable by default when passing multiple masks when the option is not explicitly specified
67
+ opts.keepStatic = true;
68
+ }
69
+ var altMask = opts.groupmarker[0];
70
+ (opts.isRTL ? opts.mask.reverse() : opts.mask).forEach(function (msk) {
71
+ if (altMask.length > 1) {
72
+ altMask += opts.alternatormarker;
73
+ }
74
+ if (msk.mask !== undefined && typeof msk.mask !== "function") {
75
+ altMask += msk.mask;
76
+ } else {
77
+ altMask += msk;
78
+ }
79
+ });
80
+ altMask += opts.groupmarker[1];
81
+ // console.log(altMask);
82
+ return generateMask(altMask, opts.mask, opts);
83
+ } else {
84
+ opts.mask = opts.mask.pop();
85
+ }
86
+ }
87
+ if (opts.mask && opts.mask.mask !== undefined && typeof opts.mask.mask !== "function") {
88
+ ms = generateMask(opts.mask.mask, opts.mask, opts);
89
+ } else {
90
+ ms = generateMask(opts.mask, opts.mask, opts);
91
+ }
92
+ if (opts.keepStatic === null) opts.keepStatic = false;
93
+ return ms;
94
+ }
95
+
96
+ function analyseMask(mask, regexMask, opts) {
97
+ const tokenizer = /(?:[?*+]|\{[0-9+*]+(?:,[0-9+*]*)?(?:\|[0-9+*]*)?\})|[^.?*+^${[]()|\\]+|./g,
98
+ //Thx to https://github.com/slevithan/regex-colorizer for the regexTokenizer regex
99
+ regexTokenizer = /\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g;
100
+ var escaped = false,
101
+ currentToken = new MaskToken(),
102
+ match,
103
+ m,
104
+ openenings = [],
105
+ maskTokens = [],
106
+ openingToken,
107
+ currentOpeningToken,
108
+ alternator,
109
+ lastMatch,
110
+ closeRegexGroup = false;
111
+
112
+ //test definition => {fn: RegExp/function, static: true/false optionality: bool, newBlockMarker: bool, casing: null/upper/lower, def: definitionSymbol, placeholder: placeholder, mask: real maskDefinition}
113
+ function insertTestDefinition(mtoken, element, position) {
114
+ position = position !== undefined ? position : mtoken.matches.length;
115
+ var prevMatch = mtoken.matches[position - 1];
116
+ if (regexMask) {
117
+ if (element.indexOf("[") === 0 || (escaped && /\\d|\\s|\\w/i.test(element)) || element === ".") {
118
+ mtoken.matches.splice(position++, 0, {
119
+ fn: new RegExp(element, opts.casing ? "i" : ""),
120
+ static: false,
121
+ optionality: false,
122
+ newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== element,
123
+ casing: null,
124
+ def: element,
125
+ placeholder: undefined,
126
+ nativeDef: element
127
+ });
128
+ } else {
129
+ if (escaped) element = element[element.length - 1];
130
+ element.split("").forEach(function (lmnt, ndx) {
131
+ prevMatch = mtoken.matches[position - 1];
132
+ mtoken.matches.splice(position++, 0, {
133
+ fn: /[a-z]/i.test((opts.staticDefinitionSymbol || lmnt)) ? new RegExp("[" + (opts.staticDefinitionSymbol || lmnt) + "]", opts.casing ? "i" : "") : null,
134
+ static: true,
135
+ optionality: false,
136
+ newBlockMarker: prevMatch === undefined ? "master" : (prevMatch.def !== lmnt && prevMatch.static !== true),
137
+ casing: null,
138
+ def: opts.staticDefinitionSymbol || lmnt,
139
+ placeholder: opts.staticDefinitionSymbol !== undefined ? lmnt : undefined,
140
+ nativeDef: (escaped ? "'" : "") + lmnt
141
+ });
142
+ });
143
+ }
144
+ escaped = false;
145
+ } else {
146
+ var maskdef = (opts.definitions && opts.definitions[element]) || (opts.usePrototypeDefinitions && Inputmask.prototype.definitions[element]);
147
+ if (maskdef && !escaped) {
148
+ mtoken.matches.splice(position++, 0, {
149
+ fn: maskdef.validator ? typeof maskdef.validator == "string" ? new RegExp(maskdef.validator, opts.casing ? "i" : "") : new function () {
150
+ this.test = maskdef.validator;
151
+ } : new RegExp("."),
152
+ static: maskdef.static || false,
153
+ optionality: maskdef.optional || false,
154
+ newBlockMarker: (prevMatch === undefined || maskdef.optional) ? "master" : prevMatch.def !== (maskdef.definitionSymbol || element),
155
+ casing: maskdef.casing,
156
+ def: maskdef.definitionSymbol || element,
157
+ placeholder: maskdef.placeholder,
158
+ nativeDef: element,
159
+ generated: maskdef.generated
160
+ });
161
+ } else {
162
+ mtoken.matches.splice(position++, 0, {
163
+ fn: /[a-z]/i.test((opts.staticDefinitionSymbol || element)) ? new RegExp("[" + (opts.staticDefinitionSymbol || element) + "]", opts.casing ? "i" : "") : null,
164
+ static: true,
165
+ optionality: false,
166
+ newBlockMarker: prevMatch === undefined ? "master" : (prevMatch.def !== element && prevMatch.static !== true),
167
+ casing: null,
168
+ def: opts.staticDefinitionSymbol || element,
169
+ placeholder: opts.staticDefinitionSymbol !== undefined ? element : undefined,
170
+ nativeDef: (escaped ? "'" : "") + element
171
+ });
172
+ escaped = false;
173
+ }
174
+ }
175
+ }
176
+
177
+ function verifyGroupMarker(maskToken) {
178
+ if (maskToken && maskToken.matches) {
179
+ maskToken.matches.forEach(function (token, ndx) {
180
+ var nextToken = maskToken.matches[ndx + 1];
181
+ if ((nextToken === undefined || (nextToken.matches === undefined || nextToken.isQuantifier === false)) && token && token.isGroup) { //this is not a group but a normal mask => convert
182
+ token.isGroup = false;
183
+ if (!regexMask) {
184
+ insertTestDefinition(token, opts.groupmarker[0], 0);
185
+ if (token.openGroup !== true) {
186
+ insertTestDefinition(token, opts.groupmarker[1]);
187
+ }
188
+ }
189
+ }
190
+ verifyGroupMarker(token);
191
+ });
192
+ }
193
+ }
194
+
195
+ function defaultCase() {
196
+ if (openenings.length > 0) {
197
+ currentOpeningToken = openenings[openenings.length - 1];
198
+ insertTestDefinition(currentOpeningToken, m);
199
+ if (currentOpeningToken.isAlternator) { //handle alternator a | b case
200
+ alternator = openenings.pop();
201
+ for (var mndx = 0; mndx < alternator.matches.length; mndx++) {
202
+ if (alternator.matches[mndx].isGroup) alternator.matches[mndx].isGroup = false; //don't mark alternate groups as group
203
+ }
204
+ if (openenings.length > 0) {
205
+ currentOpeningToken = openenings[openenings.length - 1];
206
+ currentOpeningToken.matches.push(alternator);
207
+ } else {
208
+ currentToken.matches.push(alternator);
209
+ }
210
+ }
211
+ } else {
212
+ insertTestDefinition(currentToken, m);
213
+ }
214
+ }
215
+
216
+ function reverseTokens(maskToken) {
217
+ function reverseStatic(st) {
218
+ if (st === opts.optionalmarker[0]) {
219
+ st = opts.optionalmarker[1];
220
+ } else if (st === opts.optionalmarker[1]) {
221
+ st = opts.optionalmarker[0];
222
+ } else if (st === opts.groupmarker[0]) {
223
+ st = opts.groupmarker[1];
224
+ } else if (st === opts.groupmarker[1]) st = opts.groupmarker[0];
225
+
226
+ return st;
227
+ }
228
+
229
+ maskToken.matches = maskToken.matches.reverse();
230
+ for (var match in maskToken.matches) {
231
+ if (Object.prototype.hasOwnProperty.call(maskToken.matches, match)) {
232
+ var intMatch = parseInt(match);
233
+ if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) { //reposition quantifier
234
+ var qt = maskToken.matches[match];
235
+ maskToken.matches.splice(match, 1);
236
+ maskToken.matches.splice(intMatch + 1, 0, qt);
237
+ }
238
+ if (maskToken.matches[match].matches !== undefined) {
239
+ maskToken.matches[match] = reverseTokens(maskToken.matches[match]);
240
+ } else {
241
+ maskToken.matches[match] = reverseStatic(maskToken.matches[match]);
242
+ }
243
+ }
244
+ }
245
+
246
+ return maskToken;
247
+ }
248
+
249
+ function groupify(matches) {
250
+ var groupToken = new MaskToken(true);
251
+ groupToken.openGroup = false;
252
+ groupToken.matches = matches;
253
+ return groupToken;
254
+ }
255
+
256
+ function closeGroup() {
257
+ // Group closing
258
+ openingToken = openenings.pop();
259
+ openingToken.openGroup = false; //mark group as complete
260
+ if (openingToken !== undefined) {
261
+ if (openenings.length > 0) {
262
+ currentOpeningToken = openenings[openenings.length - 1];
263
+ currentOpeningToken.matches.push(openingToken);
264
+ if (currentOpeningToken.isAlternator) { //handle alternator (a) | (b) case
265
+ alternator = openenings.pop();
266
+ let altMatchesLength = alternator.matches[0].matches ? alternator.matches[0].matches.length : 1;
267
+ for (var mndx = 0; mndx < alternator.matches.length; mndx++) {
268
+ alternator.matches[mndx].isGroup = false; //don't mark alternate groups as group
269
+ alternator.matches[mndx].alternatorGroup = false;
270
+ if (opts.keepStatic === null && altMatchesLength < (alternator.matches[mndx].matches ? alternator.matches[mndx].matches.length : 1)) { //enable by default when passing multiple masks when the option is not explicitly specified
271
+ opts.keepStatic = true;
272
+ }
273
+ altMatchesLength = alternator.matches[mndx].matches ? alternator.matches[mndx].matches.length : 1;
274
+ }
275
+ if (openenings.length > 0) {
276
+ currentOpeningToken = openenings[openenings.length - 1];
277
+ currentOpeningToken.matches.push(alternator);
278
+ } else {
279
+ currentToken.matches.push(alternator);
280
+ }
281
+ }
282
+ } else {
283
+ currentToken.matches.push(openingToken);
284
+ }
285
+ } else {
286
+ defaultCase();
287
+ }
288
+ }
289
+
290
+ function groupQuantifier(matches) {
291
+ var lastMatch = matches.pop();
292
+ if (lastMatch.isQuantifier) {
293
+ lastMatch = groupify([matches.pop(), lastMatch]);
294
+ }
295
+ return lastMatch;
296
+ }
297
+
298
+ if (regexMask) {
299
+ opts.optionalmarker[0] = undefined;
300
+ opts.optionalmarker[1] = undefined;
301
+ }
302
+ while ((match = regexMask ? regexTokenizer.exec(mask) : tokenizer.exec(mask))) {
303
+ m = match[0];
304
+
305
+ if (regexMask) {
306
+ switch (m.charAt(0)) {
307
+ //Quantifier
308
+ case "?":
309
+ m = "{0,1}";
310
+ break;
311
+ case "+":
312
+ case "*":
313
+ m = "{" + m + "}";
314
+ break;
315
+ case "|":
316
+ //regex mask alternator ex: [01][0-9]|2[0-3] => ([01][0-9]|2[0-3])
317
+ if (openenings.length === 0) { //wrap the mask in a group to form a regex alternator ([01][0-9]|2[0-3])
318
+ var altRegexGroup = groupify(currentToken.matches);
319
+ altRegexGroup.openGroup = true;
320
+ openenings.push(altRegexGroup);
321
+ currentToken.matches = [];
322
+ closeRegexGroup = true;
323
+ }
324
+ break;
325
+ }
326
+ switch (m) {
327
+ case "\\d":
328
+ m = "[0-9]";
329
+ break;
330
+ case "(?=": //lookahead
331
+ // openenings.push(new MaskToken(true));
332
+ break;
333
+ case "(?!": //negative lookahead
334
+ // openenings.push(new MaskToken(true));
335
+ break;
336
+ case "(?<=": //lookbehind
337
+ // openenings.push(new MaskToken(true));
338
+ break;
339
+ case "(?<!": //negative lookbehind
340
+ // openenings.push(new MaskToken(true));
341
+ break;
342
+ }
343
+ }
344
+
345
+ if (escaped) {
346
+ defaultCase();
347
+ continue;
348
+ }
349
+ switch (m.charAt(0)) {
350
+ case "$":
351
+ case "^":
352
+ //ignore beginswith and endswith as in masking this makes no point
353
+ if (!regexMask) {
354
+ defaultCase();
355
+ }
356
+ break;
357
+ case opts.escapeChar:
358
+ escaped = true;
359
+ if (regexMask) defaultCase();
360
+ break;
361
+ // optional closing
362
+ case opts.optionalmarker[1]:
363
+ case opts.groupmarker[1]:
364
+ closeGroup();
365
+ break;
366
+ case opts.optionalmarker[0]:
367
+ // optional opening
368
+ openenings.push(new MaskToken(false, true));
369
+ break;
370
+ case opts.groupmarker[0]:
371
+ // Group opening
372
+ openenings.push(new MaskToken(true));
373
+ break;
374
+ case opts.quantifiermarker[0]:
375
+ //Quantifier
376
+ var quantifier = new MaskToken(false, false, true);
377
+
378
+ m = m.replace(/[{}?]/g, ""); //? matches lazy quantifiers
379
+ var mqj = m.split("|"),
380
+ mq = mqj[0].split(","),
381
+ mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]),
382
+ mq1 = mq.length === 1 ? mq0 : (isNaN(mq[1]) ? mq[1] : parseInt(mq[1])),
383
+ mqJit = isNaN(mqj[1]) ? mqj[1] : parseInt(mqj[1]);
384
+ if (mq0 === "*" || mq0 === "+") {
385
+ mq0 = mq1 === "*" ? 0 : 1;
386
+ }
387
+ quantifier.quantifier = {
388
+ min: mq0,
389
+ max: mq1,
390
+ jit: mqJit
391
+ };
392
+ var matches = openenings.length > 0 ? openenings[openenings.length - 1].matches : currentToken.matches;
393
+ match = matches.pop();
394
+ if (match.isAlternator) { //handle quantifier in an alternation [0-9]{2}|[0-9]{3}
395
+ matches.push(match); //push back alternator
396
+ matches = match.matches; //remap target matches
397
+ var groupToken = new MaskToken(true);
398
+ var tmpMatch = matches.pop();
399
+ matches.push(groupToken); //push the group
400
+ matches = groupToken.matches;
401
+ match = tmpMatch;
402
+ }
403
+ if (!match.isGroup) {
404
+ // if (regexMask && match.fn === null) { //why is this needed???
405
+ // if (match.def === ".") match.fn = new RegExp(match.def, opts.casing ? "i" : "");
406
+ // }
407
+
408
+ match = groupify([match]);
409
+ }
410
+ matches.push(match);
411
+ matches.push(quantifier);
412
+
413
+ break;
414
+ case opts.alternatormarker:
415
+ if (openenings.length > 0) {
416
+ currentOpeningToken = openenings[openenings.length - 1];
417
+ var subToken = currentOpeningToken.matches[currentOpeningToken.matches.length - 1];
418
+ if (currentOpeningToken.openGroup && //regexp alt syntax
419
+ (subToken.matches === undefined || (subToken.isGroup === false && subToken.isAlternator === false))) { //alternations within group
420
+ lastMatch = openenings.pop();
421
+ } else {
422
+ lastMatch = groupQuantifier(currentOpeningToken.matches);
423
+ }
424
+ } else {
425
+ lastMatch = groupQuantifier(currentToken.matches);
426
+ }
427
+ if (lastMatch.isAlternator) {
428
+ openenings.push(lastMatch);
429
+ } else {
430
+ if (lastMatch.alternatorGroup) {
431
+ alternator = openenings.pop();
432
+ lastMatch.alternatorGroup = false;
433
+ } else {
434
+ alternator = new MaskToken(false, false, false, true);
435
+ }
436
+ alternator.matches.push(lastMatch);
437
+ openenings.push(alternator);
438
+ if (lastMatch.openGroup) { //regexp alt syntax
439
+ lastMatch.openGroup = false;
440
+ var alternatorGroup = new MaskToken(true);
441
+ alternatorGroup.alternatorGroup = true;
442
+ openenings.push(alternatorGroup);
443
+ }
444
+ }
445
+ break;
446
+ default:
447
+ defaultCase();
448
+ }
449
+ }
450
+
451
+ if (closeRegexGroup) closeGroup();
452
+
453
+ while (openenings.length > 0) {
454
+ openingToken = openenings.pop();
455
+ currentToken.matches.push(openingToken);
456
+ }
457
+ if (currentToken.matches.length > 0) {
458
+ verifyGroupMarker(currentToken);
459
+ maskTokens.push(currentToken);
460
+ }
461
+
462
+ if (opts.numericInput || opts.isRTL) {
463
+ reverseTokens(maskTokens[0]);
464
+ }
465
+ // console.log(JSON.stringify(maskTokens));
466
+ return maskTokens;
467
+ }