vue-spear-tip 0.2.14 → 0.2.16-beta.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 (71) hide show
  1. package/dist/.vite/manifest.json +32 -32
  2. package/dist/{Button-C-_LLCJ8.cjs → Button-CegdAQx1.cjs} +1 -1
  3. package/dist/{Button-D3wxk32n.js → Button-b6rBibUU.js} +1 -1
  4. package/dist/{CodeHighlight-BQkI0Qdb.cjs → CodeHighlight-D8u7i5q3.cjs} +1 -1
  5. package/dist/{CodeHighlight-hA59-wK0.js → CodeHighlight-DK_itct_.js} +1 -1
  6. package/dist/{DateField-CbD-7nJo.js → DateField-DzpU2RzG.js} +38 -7
  7. package/dist/DateField-TSP3qae_.cjs +31 -0
  8. package/dist/{FieldComponent.vue_vue_type_script_lang-BBV9PhxZ.cjs → FieldComponent.vue_vue_type_script_lang-CMmfE7TT.cjs} +1 -1
  9. package/dist/{FieldComponent.vue_vue_type_script_lang-D8oglWYI.js → FieldComponent.vue_vue_type_script_lang-CnnnJaoS.js} +1 -1
  10. package/dist/Interfaces/IBaseVueComponent.d.ts +1 -1
  11. package/dist/Interfaces/IFieldComponent.d.ts +2 -1
  12. package/dist/Interfaces/IGlobalVST.d.ts +1 -1
  13. package/dist/Interfaces/IVueClass.d.ts +15 -3
  14. package/dist/{SelectField-0sIO2oZ8.cjs → SelectField-Cos_iPFh.cjs} +1 -1
  15. package/dist/{SelectField-_DCw7asw.js → SelectField-Nf4hj-Jx.js} +2 -2
  16. package/dist/StringField-0X0z4bJq.js +2947 -0
  17. package/dist/StringField-EHq_XTp1.cjs +1 -0
  18. package/dist/SwitchField-Bys_uVdf.cjs +1 -0
  19. package/dist/SwitchField-DtXJEtoV.js +247 -0
  20. package/dist/{Tabs-Bdbmi4vp.js → Tabs-B0rOz5l4.js} +1 -1
  21. package/dist/{Tabs-Bs59wIyv.cjs → Tabs-zIXIin4o.cjs} +1 -1
  22. package/dist/{TextField-BiySwnpX.js → TextField-CEmB9He5.js} +2 -2
  23. package/dist/{TextField-D4LS0W8b.cjs → TextField-OQmwJdtJ.cjs} +1 -1
  24. package/dist/components/Elements/Button/ButtonInherited.d.ts +1 -1
  25. package/dist/components/Fields/DateField/IDateField.d.ts +1 -1
  26. package/dist/core/Props.d.ts +1 -1
  27. package/dist/core/VST.lib.d.ts +4 -0
  28. package/dist/core/VueClass.d.ts +10 -2
  29. package/dist/core/VueClassComponent.d.ts +2 -2
  30. package/dist/core/index.d.ts +2 -13
  31. package/dist/grid-style.css +1 -1
  32. package/dist/index-BN_QKlXx.cjs +1 -0
  33. package/dist/{index-Cb9JNh32.js → index-DtaxH9ox.js} +2089 -2050
  34. package/dist/replaceable/BaseComponent.vue +8 -80
  35. package/dist/replaceable/Elements/Button/ButtonInherited.d.ts +1 -1
  36. package/dist/replaceable/FieldComponent.vue +1 -1
  37. package/dist/vue-spear-tip.cjs.js +1 -1
  38. package/dist/vue-spear-tip.css +1 -1
  39. package/dist/vue-spear-tip.d.ts +3 -0
  40. package/dist/vue-spear-tip.es.js +1 -1
  41. package/docs/index.html +2 -2
  42. package/docs/static/{Button-DQufd156.js → Button-CeDK-PBR.js} +1 -1
  43. package/docs/static/{CodeHighlight-B3Ig4KDk.js → CodeHighlight-CwVuCJVt.js} +1 -1
  44. package/docs/static/DateField-D4RyJiyD.js +31 -0
  45. package/docs/static/{FieldComponent.vue_vue_type_script_lang-DvjF0ufQ.js → FieldComponent.vue_vue_type_script_lang-GFnG0VWx.js} +1 -1
  46. package/docs/static/{NoSymbolIcon-BcSCXTGD.js → NoSymbolIcon-Dq590q9t.js} +1 -1
  47. package/docs/static/{SelectField-CIZ_xg-o.js → SelectField-61XgjABZ.js} +1 -1
  48. package/docs/static/StringField-4jEXE2Iq.js +1 -0
  49. package/docs/static/StringField-DkTD1rGV.css +1 -0
  50. package/docs/static/SwitchField-BXh1DoSh.css +1 -0
  51. package/docs/static/SwitchField-CIYufM5H.js +1 -0
  52. package/docs/static/{Tabs-D191loy_.js → Tabs-DdDx4FlO.js} +1 -1
  53. package/docs/static/{TextField-o2QP_97x.js → TextField-BifW_QMR.js} +1 -1
  54. package/docs/static/index-DuaCcUUh.js +2 -0
  55. package/docs/static/main-BGO0apQg.js +119 -0
  56. package/docs/static/main-CPQng82-.css +1 -0
  57. package/package.json +2 -1
  58. package/dist/DateField--anXRYwD.cjs +0 -5
  59. package/dist/StringField-Dx9x3hG1.cjs +0 -1
  60. package/dist/StringField-Q6tdcgNE.js +0 -2949
  61. package/dist/SwitchField-D2CUl-83.js +0 -252
  62. package/dist/SwitchField-DF62AQwm.cjs +0 -1
  63. package/dist/index-C6zu8hmM.cjs +0 -1
  64. package/docs/static/DateField-C6BbToAd.js +0 -5
  65. package/docs/static/StringField-BJ5e1NcF.css +0 -1
  66. package/docs/static/StringField-DoqZ8gGA.js +0 -1
  67. package/docs/static/SwitchField-D1HrNcLY.css +0 -1
  68. package/docs/static/SwitchField-Db23H0Im.js +0 -1
  69. package/docs/static/index-F0CNC5Sw.js +0 -2
  70. package/docs/static/main-Bqckh-QL.css +0 -1
  71. package/docs/static/main-DkOCkEos.js +0 -95
@@ -1,2949 +0,0 @@
1
- var We = Object.defineProperty;
2
- var o = (u, e) => We(u, "name", { value: e, configurable: !0 });
3
- import { P as j, C as Je, V as Qe } from "./index-Cb9JNh32.js";
4
- import { F as et } from "./FieldComponent.vue_vue_type_script_lang-D8oglWYI.js";
5
- import { isRef as tt, ref as R, watch as x, onMounted as st, onUnmounted as it, readonly as at, defineComponent as nt, toRef as G, h as ut, createElementBlock as O, openBlock as S, createElementVNode as W, resolveComponent as Z, normalizeClass as de, createCommentVNode as X, createBlock as pe, createVNode as je, withKeys as rt, normalizeStyle as lt, toDisplayString as ce, resolveDynamicComponent as ot, withCtx as ht, createTextVNode as dt } from "vue";
6
- import { r as pt } from "./NoSymbolIcon-aoAIVIx7.js";
7
- import { _ as ct } from "./_plugin-vue_export-helper-B9nE8o7z.js";
8
- function b(u) {
9
- return typeof u == "string" || u instanceof String;
10
- }
11
- o(b, "isString");
12
- function qe(u) {
13
- var e;
14
- return typeof u == "object" && u != null && (u == null || (e = u.constructor) == null ? void 0 : e.name) === "Object";
15
- }
16
- o(qe, "isObject");
17
- function Ke(u, e) {
18
- return Array.isArray(e) ? Ke(u, (t, s) => e.includes(s)) : Object.entries(u).reduce((t, s) => {
19
- let [i, a] = s;
20
- return e(a, i) && (t[i] = a), t;
21
- }, {});
22
- }
23
- o(Ke, "pick");
24
- const d = {
25
- NONE: "NONE",
26
- LEFT: "LEFT",
27
- FORCE_LEFT: "FORCE_LEFT",
28
- RIGHT: "RIGHT",
29
- FORCE_RIGHT: "FORCE_RIGHT"
30
- };
31
- function ft(u) {
32
- switch (u) {
33
- case d.LEFT:
34
- return d.FORCE_LEFT;
35
- case d.RIGHT:
36
- return d.FORCE_RIGHT;
37
- default:
38
- return u;
39
- }
40
- }
41
- o(ft, "forceDirection");
42
- function fe(u) {
43
- return u.replace(/([.*+?^=!:${}()|[\]/\\])/g, "\\$1");
44
- }
45
- o(fe, "escapeRegExp");
46
- function J(u, e) {
47
- if (e === u) return !0;
48
- const t = Array.isArray(e), s = Array.isArray(u);
49
- let i;
50
- if (t && s) {
51
- if (e.length != u.length) return !1;
52
- for (i = 0; i < e.length; i++) if (!J(e[i], u[i])) return !1;
53
- return !0;
54
- }
55
- if (t != s) return !1;
56
- if (e && u && typeof e == "object" && typeof u == "object") {
57
- const a = e instanceof Date, n = u instanceof Date;
58
- if (a && n) return e.getTime() == u.getTime();
59
- if (a != n) return !1;
60
- const r = e instanceof RegExp, l = u instanceof RegExp;
61
- if (r && l) return e.toString() == u.toString();
62
- if (r != l) return !1;
63
- const h = Object.keys(e);
64
- for (i = 0; i < h.length; i++) if (!Object.prototype.hasOwnProperty.call(u, h[i])) return !1;
65
- for (i = 0; i < h.length; i++) if (!J(u[h[i]], e[h[i]])) return !1;
66
- return !0;
67
- } else if (e && u && typeof e == "function" && typeof u == "function")
68
- return e.toString() === u.toString();
69
- return !1;
70
- }
71
- o(J, "objectIncludes");
72
- const Fe = class Fe {
73
- /** Current input value */
74
- /** Current cursor position */
75
- /** Old input value */
76
- /** Old selection */
77
- constructor(e) {
78
- for (Object.assign(this, e); this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos); )
79
- --this.oldSelection.start;
80
- if (this.insertedCount)
81
- for (; this.value.slice(this.cursorPos) !== this.oldValue.slice(this.oldSelection.end); )
82
- this.value.length - this.cursorPos < this.oldValue.length - this.oldSelection.end ? ++this.oldSelection.end : ++this.cursorPos;
83
- }
84
- /** Start changing position */
85
- get startChangePos() {
86
- return Math.min(this.cursorPos, this.oldSelection.start);
87
- }
88
- /** Inserted symbols count */
89
- get insertedCount() {
90
- return this.cursorPos - this.startChangePos;
91
- }
92
- /** Inserted symbols */
93
- get inserted() {
94
- return this.value.substr(this.startChangePos, this.insertedCount);
95
- }
96
- /** Removed symbols count */
97
- get removedCount() {
98
- return Math.max(this.oldSelection.end - this.startChangePos || // for Delete
99
- this.oldValue.length - this.value.length, 0);
100
- }
101
- /** Removed symbols */
102
- get removed() {
103
- return this.oldValue.substr(this.startChangePos, this.removedCount);
104
- }
105
- /** Unchanged head symbols */
106
- get head() {
107
- return this.value.substring(0, this.startChangePos);
108
- }
109
- /** Unchanged tail symbols */
110
- get tail() {
111
- return this.value.substring(this.startChangePos + this.insertedCount);
112
- }
113
- /** Remove direction */
114
- get removeDirection() {
115
- return !this.removedCount || this.insertedCount ? d.NONE : (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) && // if not range removed (event with backspace)
116
- this.oldSelection.end === this.oldSelection.start ? d.RIGHT : d.LEFT;
117
- }
118
- };
119
- o(Fe, "ActionDetails");
120
- let me = Fe;
121
- function c(u, e) {
122
- return new c.InputMask(u, e);
123
- }
124
- o(c, "IMask");
125
- function He(u) {
126
- if (u == null) throw new Error("mask property should be defined");
127
- return u instanceof RegExp ? c.MaskedRegExp : b(u) ? c.MaskedPattern : u === Date ? c.MaskedDate : u === Number ? c.MaskedNumber : Array.isArray(u) || u === Array ? c.MaskedDynamic : c.Masked && u.prototype instanceof c.Masked ? u : c.Masked && u instanceof c.Masked ? u.constructor : u instanceof Function ? c.MaskedFunction : (console.warn("Mask not found for mask", u), c.Masked);
128
- }
129
- o(He, "maskedClass");
130
- function q(u) {
131
- if (!u) throw new Error("Options in not defined");
132
- if (c.Masked) {
133
- if (u.prototype instanceof c.Masked) return {
134
- mask: u
135
- };
136
- const {
137
- mask: e = void 0,
138
- ...t
139
- } = u instanceof c.Masked ? {
140
- mask: u
141
- } : qe(u) && u.mask instanceof c.Masked ? u : {};
142
- if (e) {
143
- const s = e.mask;
144
- return {
145
- ...Ke(e, (i, a) => !a.startsWith("_")),
146
- mask: e.constructor,
147
- _mask: s,
148
- ...t
149
- };
150
- }
151
- }
152
- return qe(u) ? {
153
- ...u
154
- } : {
155
- mask: u
156
- };
157
- }
158
- o(q, "normalizeOpts");
159
- function V(u) {
160
- if (c.Masked && u instanceof c.Masked) return u;
161
- const e = q(u), t = He(e.mask);
162
- if (!t) throw new Error("Masked class is not found for provided mask " + e.mask + ", appropriate module needs to be imported manually before creating mask.");
163
- return e.mask === t && delete e.mask, e._mask && (e.mask = e._mask, delete e._mask), new t(e);
164
- }
165
- o(V, "createMask");
166
- c.createMask = V;
167
- const ye = class ye {
168
- /** */
169
- /** */
170
- /** */
171
- /** Safely returns selection start */
172
- get selectionStart() {
173
- let e;
174
- try {
175
- e = this._unsafeSelectionStart;
176
- } catch {
177
- }
178
- return e ?? this.value.length;
179
- }
180
- /** Safely returns selection end */
181
- get selectionEnd() {
182
- let e;
183
- try {
184
- e = this._unsafeSelectionEnd;
185
- } catch {
186
- }
187
- return e ?? this.value.length;
188
- }
189
- /** Safely sets element selection */
190
- select(e, t) {
191
- if (!(e == null || t == null || e === this.selectionStart && t === this.selectionEnd))
192
- try {
193
- this._unsafeSelect(e, t);
194
- } catch {
195
- }
196
- }
197
- /** */
198
- get isActive() {
199
- return !1;
200
- }
201
- /** */
202
- /** */
203
- /** */
204
- };
205
- o(ye, "MaskElement");
206
- let z = ye;
207
- c.MaskElement = z;
208
- const ze = 90, mt = 89, Se = class Se extends z {
209
- /** HTMLElement to use mask on */
210
- constructor(e) {
211
- super(), this.input = e, this._onKeydown = this._onKeydown.bind(this), this._onInput = this._onInput.bind(this), this._onBeforeinput = this._onBeforeinput.bind(this), this._onCompositionEnd = this._onCompositionEnd.bind(this);
212
- }
213
- get rootElement() {
214
- var e, t, s;
215
- return (e = (t = (s = this.input).getRootNode) == null ? void 0 : t.call(s)) != null ? e : document;
216
- }
217
- /** Is element in focus */
218
- get isActive() {
219
- return this.input === this.rootElement.activeElement;
220
- }
221
- /** Binds HTMLElement events to mask internal events */
222
- bindEvents(e) {
223
- this.input.addEventListener("keydown", this._onKeydown), this.input.addEventListener("input", this._onInput), this.input.addEventListener("beforeinput", this._onBeforeinput), this.input.addEventListener("compositionend", this._onCompositionEnd), this.input.addEventListener("drop", e.drop), this.input.addEventListener("click", e.click), this.input.addEventListener("focus", e.focus), this.input.addEventListener("blur", e.commit), this._handlers = e;
224
- }
225
- _onKeydown(e) {
226
- if (this._handlers.redo && (e.keyCode === ze && e.shiftKey && (e.metaKey || e.ctrlKey) || e.keyCode === mt && e.ctrlKey))
227
- return e.preventDefault(), this._handlers.redo(e);
228
- if (this._handlers.undo && e.keyCode === ze && (e.metaKey || e.ctrlKey))
229
- return e.preventDefault(), this._handlers.undo(e);
230
- e.isComposing || this._handlers.selectionChange(e);
231
- }
232
- _onBeforeinput(e) {
233
- if (e.inputType === "historyUndo" && this._handlers.undo)
234
- return e.preventDefault(), this._handlers.undo(e);
235
- if (e.inputType === "historyRedo" && this._handlers.redo)
236
- return e.preventDefault(), this._handlers.redo(e);
237
- }
238
- _onCompositionEnd(e) {
239
- this._handlers.input(e);
240
- }
241
- _onInput(e) {
242
- e.isComposing || this._handlers.input(e);
243
- }
244
- /** Unbinds HTMLElement events to mask internal events */
245
- unbindEvents() {
246
- this.input.removeEventListener("keydown", this._onKeydown), this.input.removeEventListener("input", this._onInput), this.input.removeEventListener("beforeinput", this._onBeforeinput), this.input.removeEventListener("compositionend", this._onCompositionEnd), this.input.removeEventListener("drop", this._handlers.drop), this.input.removeEventListener("click", this._handlers.click), this.input.removeEventListener("focus", this._handlers.focus), this.input.removeEventListener("blur", this._handlers.commit), this._handlers = {};
247
- }
248
- };
249
- o(Se, "HTMLMaskElement");
250
- let U = Se;
251
- c.HTMLMaskElement = U;
252
- const Ve = class Ve extends U {
253
- /** InputElement to use mask on */
254
- constructor(e) {
255
- super(e), this.input = e;
256
- }
257
- /** Returns InputElement selection start */
258
- get _unsafeSelectionStart() {
259
- return this.input.selectionStart != null ? this.input.selectionStart : this.value.length;
260
- }
261
- /** Returns InputElement selection end */
262
- get _unsafeSelectionEnd() {
263
- return this.input.selectionEnd;
264
- }
265
- /** Sets InputElement selection */
266
- _unsafeSelect(e, t) {
267
- this.input.setSelectionRange(e, t);
268
- }
269
- get value() {
270
- return this.input.value;
271
- }
272
- set value(e) {
273
- this.input.value = e;
274
- }
275
- };
276
- o(Ve, "HTMLInputMaskElement");
277
- let ke = Ve;
278
- c.HTMLMaskElement = U;
279
- const Be = class Be extends U {
280
- /** Returns HTMLElement selection start */
281
- get _unsafeSelectionStart() {
282
- const e = this.rootElement, t = e.getSelection && e.getSelection(), s = t && t.anchorOffset, i = t && t.focusOffset;
283
- return i == null || s == null || s < i ? s : i;
284
- }
285
- /** Returns HTMLElement selection end */
286
- get _unsafeSelectionEnd() {
287
- const e = this.rootElement, t = e.getSelection && e.getSelection(), s = t && t.anchorOffset, i = t && t.focusOffset;
288
- return i == null || s == null || s > i ? s : i;
289
- }
290
- /** Sets HTMLElement selection */
291
- _unsafeSelect(e, t) {
292
- if (!this.rootElement.createRange) return;
293
- const s = this.rootElement.createRange();
294
- s.setStart(this.input.firstChild || this.input, e), s.setEnd(this.input.lastChild || this.input, t);
295
- const i = this.rootElement, a = i.getSelection && i.getSelection();
296
- a && (a.removeAllRanges(), a.addRange(s));
297
- }
298
- /** HTMLElement value */
299
- get value() {
300
- return this.input.textContent || "";
301
- }
302
- set value(e) {
303
- this.input.textContent = e;
304
- }
305
- };
306
- o(Be, "HTMLContenteditableMaskElement");
307
- let Q = Be;
308
- c.HTMLContenteditableMaskElement = Q;
309
- const ne = class ne {
310
- constructor() {
311
- this.states = [], this.currentIndex = 0;
312
- }
313
- get currentState() {
314
- return this.states[this.currentIndex];
315
- }
316
- get isEmpty() {
317
- return this.states.length === 0;
318
- }
319
- push(e) {
320
- this.currentIndex < this.states.length - 1 && (this.states.length = this.currentIndex + 1), this.states.push(e), this.states.length > ne.MAX_LENGTH && this.states.shift(), this.currentIndex = this.states.length - 1;
321
- }
322
- go(e) {
323
- return this.currentIndex = Math.min(Math.max(this.currentIndex + e, 0), this.states.length - 1), this.currentState;
324
- }
325
- undo() {
326
- return this.go(-1);
327
- }
328
- redo() {
329
- return this.go(1);
330
- }
331
- clear() {
332
- this.states.length = 0, this.currentIndex = 0;
333
- }
334
- };
335
- o(ne, "InputHistory");
336
- let ee = ne;
337
- ee.MAX_LENGTH = 100;
338
- const xe = class xe {
339
- /**
340
- View element
341
- */
342
- /** Internal {@link Masked} model */
343
- constructor(e, t) {
344
- this.el = e instanceof z ? e : e.isContentEditable && e.tagName !== "INPUT" && e.tagName !== "TEXTAREA" ? new Q(e) : new ke(e), this.masked = V(t), this._listeners = {}, this._value = "", this._unmaskedValue = "", this._rawInputValue = "", this.history = new ee(), this._saveSelection = this._saveSelection.bind(this), this._onInput = this._onInput.bind(this), this._onChange = this._onChange.bind(this), this._onDrop = this._onDrop.bind(this), this._onFocus = this._onFocus.bind(this), this._onClick = this._onClick.bind(this), this._onUndo = this._onUndo.bind(this), this._onRedo = this._onRedo.bind(this), this.alignCursor = this.alignCursor.bind(this), this.alignCursorFriendly = this.alignCursorFriendly.bind(this), this._bindEvents(), this.updateValue(), this._onChange();
345
- }
346
- maskEquals(e) {
347
- var t;
348
- return e == null || ((t = this.masked) == null ? void 0 : t.maskEquals(e));
349
- }
350
- /** Masked */
351
- get mask() {
352
- return this.masked.mask;
353
- }
354
- set mask(e) {
355
- if (this.maskEquals(e)) return;
356
- if (!(e instanceof c.Masked) && this.masked.constructor === He(e)) {
357
- this.masked.updateOptions({
358
- mask: e
359
- });
360
- return;
361
- }
362
- const t = e instanceof c.Masked ? e : V({
363
- mask: e
364
- });
365
- t.unmaskedValue = this.masked.unmaskedValue, this.masked = t;
366
- }
367
- /** Raw value */
368
- get value() {
369
- return this._value;
370
- }
371
- set value(e) {
372
- this.value !== e && (this.masked.value = e, this.updateControl("auto"));
373
- }
374
- /** Unmasked value */
375
- get unmaskedValue() {
376
- return this._unmaskedValue;
377
- }
378
- set unmaskedValue(e) {
379
- this.unmaskedValue !== e && (this.masked.unmaskedValue = e, this.updateControl("auto"));
380
- }
381
- /** Raw input value */
382
- get rawInputValue() {
383
- return this._rawInputValue;
384
- }
385
- set rawInputValue(e) {
386
- this.rawInputValue !== e && (this.masked.rawInputValue = e, this.updateControl(), this.alignCursor());
387
- }
388
- /** Typed unmasked value */
389
- get typedValue() {
390
- return this.masked.typedValue;
391
- }
392
- set typedValue(e) {
393
- this.masked.typedValueEquals(e) || (this.masked.typedValue = e, this.updateControl("auto"));
394
- }
395
- /** Display value */
396
- get displayValue() {
397
- return this.masked.displayValue;
398
- }
399
- /** Starts listening to element events */
400
- _bindEvents() {
401
- this.el.bindEvents({
402
- selectionChange: this._saveSelection,
403
- input: this._onInput,
404
- drop: this._onDrop,
405
- click: this._onClick,
406
- focus: this._onFocus,
407
- commit: this._onChange,
408
- undo: this._onUndo,
409
- redo: this._onRedo
410
- });
411
- }
412
- /** Stops listening to element events */
413
- _unbindEvents() {
414
- this.el && this.el.unbindEvents();
415
- }
416
- /** Fires custom event */
417
- _fireEvent(e, t) {
418
- const s = this._listeners[e];
419
- s && s.forEach((i) => i(t));
420
- }
421
- /** Current selection start */
422
- get selectionStart() {
423
- return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
424
- }
425
- /** Current cursor position */
426
- get cursorPos() {
427
- return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
428
- }
429
- set cursorPos(e) {
430
- !this.el || !this.el.isActive || (this.el.select(e, e), this._saveSelection());
431
- }
432
- /** Stores current selection */
433
- _saveSelection() {
434
- this.displayValue !== this.el.value && console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."), this._selection = {
435
- start: this.selectionStart,
436
- end: this.cursorPos
437
- };
438
- }
439
- /** Syncronizes model value from view */
440
- updateValue() {
441
- this.masked.value = this.el.value, this._value = this.masked.value, this._unmaskedValue = this.masked.unmaskedValue, this._rawInputValue = this.masked.rawInputValue;
442
- }
443
- /** Syncronizes view from model value, fires change events */
444
- updateControl(e) {
445
- const t = this.masked.unmaskedValue, s = this.masked.value, i = this.masked.rawInputValue, a = this.displayValue, n = this.unmaskedValue !== t || this.value !== s || this._rawInputValue !== i;
446
- this._unmaskedValue = t, this._value = s, this._rawInputValue = i, this.el.value !== a && (this.el.value = a), e === "auto" ? this.alignCursor() : e != null && (this.cursorPos = e), n && this._fireChangeEvents(), !this._historyChanging && (n || this.history.isEmpty) && this.history.push({
447
- unmaskedValue: t,
448
- selection: {
449
- start: this.selectionStart,
450
- end: this.cursorPos
451
- }
452
- });
453
- }
454
- /** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */
455
- updateOptions(e) {
456
- const {
457
- mask: t,
458
- ...s
459
- } = e, i = !this.maskEquals(t), a = this.masked.optionsIsChanged(s);
460
- i && (this.mask = t), a && this.masked.updateOptions(s), (i || a) && this.updateControl();
461
- }
462
- /** Updates cursor */
463
- updateCursor(e) {
464
- e != null && (this.cursorPos = e, this._delayUpdateCursor(e));
465
- }
466
- /** Delays cursor update to support mobile browsers */
467
- _delayUpdateCursor(e) {
468
- this._abortUpdateCursor(), this._changingCursorPos = e, this._cursorChanging = setTimeout(() => {
469
- this.el && (this.cursorPos = this._changingCursorPos, this._abortUpdateCursor());
470
- }, 10);
471
- }
472
- /** Fires custom events */
473
- _fireChangeEvents() {
474
- this._fireEvent("accept", this._inputEvent), this.masked.isComplete && this._fireEvent("complete", this._inputEvent);
475
- }
476
- /** Aborts delayed cursor update */
477
- _abortUpdateCursor() {
478
- this._cursorChanging && (clearTimeout(this._cursorChanging), delete this._cursorChanging);
479
- }
480
- /** Aligns cursor to nearest available position */
481
- alignCursor() {
482
- this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, d.LEFT));
483
- }
484
- /** Aligns cursor only if selection is empty */
485
- alignCursorFriendly() {
486
- this.selectionStart === this.cursorPos && this.alignCursor();
487
- }
488
- /** Adds listener on custom event */
489
- on(e, t) {
490
- return this._listeners[e] || (this._listeners[e] = []), this._listeners[e].push(t), this;
491
- }
492
- /** Removes custom event listener */
493
- off(e, t) {
494
- if (!this._listeners[e]) return this;
495
- if (!t)
496
- return delete this._listeners[e], this;
497
- const s = this._listeners[e].indexOf(t);
498
- return s >= 0 && this._listeners[e].splice(s, 1), this;
499
- }
500
- /** Handles view input event */
501
- _onInput(e) {
502
- this._inputEvent = e, this._abortUpdateCursor();
503
- const t = new me({
504
- // new state
505
- value: this.el.value,
506
- cursorPos: this.cursorPos,
507
- // old state
508
- oldValue: this.displayValue,
509
- oldSelection: this._selection
510
- }), s = this.masked.rawInputValue, i = this.masked.splice(t.startChangePos, t.removed.length, t.inserted, t.removeDirection, {
511
- input: !0,
512
- raw: !0
513
- }).offset, a = s === this.masked.rawInputValue ? t.removeDirection : d.NONE;
514
- let n = this.masked.nearestInputPos(t.startChangePos + i, a);
515
- a !== d.NONE && (n = this.masked.nearestInputPos(n, d.NONE)), this.updateControl(n), delete this._inputEvent;
516
- }
517
- /** Handles view change event and commits model value */
518
- _onChange() {
519
- this.displayValue !== this.el.value && this.updateValue(), this.masked.doCommit(), this.updateControl(), this._saveSelection();
520
- }
521
- /** Handles view drop event, prevents by default */
522
- _onDrop(e) {
523
- e.preventDefault(), e.stopPropagation();
524
- }
525
- /** Restore last selection on focus */
526
- _onFocus(e) {
527
- this.alignCursorFriendly();
528
- }
529
- /** Restore last selection on focus */
530
- _onClick(e) {
531
- this.alignCursorFriendly();
532
- }
533
- _onUndo() {
534
- this._applyHistoryState(this.history.undo());
535
- }
536
- _onRedo() {
537
- this._applyHistoryState(this.history.redo());
538
- }
539
- _applyHistoryState(e) {
540
- e && (this._historyChanging = !0, this.unmaskedValue = e.unmaskedValue, this.el.select(e.selection.start, e.selection.end), this._saveSelection(), this._historyChanging = !1);
541
- }
542
- /** Unbind view events and removes element reference */
543
- destroy() {
544
- this._unbindEvents(), this._listeners.length = 0, delete this.el;
545
- }
546
- };
547
- o(xe, "InputMask");
548
- let ge = xe;
549
- c.InputMask = ge;
550
- const ue = class ue {
551
- /** Inserted symbols */
552
- /** Additional offset if any changes occurred before tail */
553
- /** Raw inserted is used by dynamic mask */
554
- /** Can skip chars */
555
- static normalize(e) {
556
- return Array.isArray(e) ? e : [e, new ue()];
557
- }
558
- constructor(e) {
559
- Object.assign(this, {
560
- inserted: "",
561
- rawInserted: "",
562
- tailShift: 0,
563
- skip: !1
564
- }, e);
565
- }
566
- /** Aggregate changes */
567
- aggregate(e) {
568
- return this.inserted += e.inserted, this.rawInserted += e.rawInserted, this.tailShift += e.tailShift, this.skip = this.skip || e.skip, this;
569
- }
570
- /** Total offset considering all changes */
571
- get offset() {
572
- return this.tailShift + this.inserted.length;
573
- }
574
- get consumed() {
575
- return !!this.rawInserted || this.skip;
576
- }
577
- equals(e) {
578
- return this.inserted === e.inserted && this.tailShift === e.tailShift && this.rawInserted === e.rawInserted && this.skip === e.skip;
579
- }
580
- };
581
- o(ue, "ChangeDetails");
582
- let f = ue;
583
- c.ChangeDetails = f;
584
- const be = class be {
585
- /** Tail value as string */
586
- /** Tail start position */
587
- /** Start position */
588
- constructor(e, t, s) {
589
- e === void 0 && (e = ""), t === void 0 && (t = 0), this.value = e, this.from = t, this.stop = s;
590
- }
591
- toString() {
592
- return this.value;
593
- }
594
- extend(e) {
595
- this.value += String(e);
596
- }
597
- appendTo(e) {
598
- return e.append(this.toString(), {
599
- tail: !0
600
- }).aggregate(e._appendPlaceholder());
601
- }
602
- get state() {
603
- return {
604
- value: this.value,
605
- from: this.from,
606
- stop: this.stop
607
- };
608
- }
609
- set state(e) {
610
- Object.assign(this, e);
611
- }
612
- unshift(e) {
613
- if (!this.value.length || e != null && this.from >= e) return "";
614
- const t = this.value[0];
615
- return this.value = this.value.slice(1), t;
616
- }
617
- shift() {
618
- if (!this.value.length) return "";
619
- const e = this.value[this.value.length - 1];
620
- return this.value = this.value.slice(0, -1), e;
621
- }
622
- };
623
- o(be, "ContinuousTailDetails");
624
- let A = be;
625
- const L = class L {
626
- /** */
627
- /** */
628
- /** Transforms value before mask processing */
629
- /** Transforms each char before mask processing */
630
- /** Validates if value is acceptable */
631
- /** Does additional processing at the end of editing */
632
- /** Format typed value to string */
633
- /** Parse string to get typed value */
634
- /** Enable characters overwriting */
635
- /** */
636
- /** */
637
- /** */
638
- /** */
639
- constructor(e) {
640
- this._value = "", this._update({
641
- ...L.DEFAULTS,
642
- ...e
643
- }), this._initialized = !0;
644
- }
645
- /** Sets and applies new options */
646
- updateOptions(e) {
647
- this.optionsIsChanged(e) && this.withValueRefresh(this._update.bind(this, e));
648
- }
649
- /** Sets new options */
650
- _update(e) {
651
- Object.assign(this, e);
652
- }
653
- /** Mask state */
654
- get state() {
655
- return {
656
- _value: this.value,
657
- _rawInputValue: this.rawInputValue
658
- };
659
- }
660
- set state(e) {
661
- this._value = e._value;
662
- }
663
- /** Resets value */
664
- reset() {
665
- this._value = "";
666
- }
667
- get value() {
668
- return this._value;
669
- }
670
- set value(e) {
671
- this.resolve(e, {
672
- input: !0
673
- });
674
- }
675
- /** Resolve new value */
676
- resolve(e, t) {
677
- t === void 0 && (t = {
678
- input: !0
679
- }), this.reset(), this.append(e, t, ""), this.doCommit();
680
- }
681
- get unmaskedValue() {
682
- return this.value;
683
- }
684
- set unmaskedValue(e) {
685
- this.resolve(e, {});
686
- }
687
- get typedValue() {
688
- return this.parse ? this.parse(this.value, this) : this.unmaskedValue;
689
- }
690
- set typedValue(e) {
691
- this.format ? this.value = this.format(e, this) : this.unmaskedValue = String(e);
692
- }
693
- /** Value that includes raw user input */
694
- get rawInputValue() {
695
- return this.extractInput(0, this.displayValue.length, {
696
- raw: !0
697
- });
698
- }
699
- set rawInputValue(e) {
700
- this.resolve(e, {
701
- raw: !0
702
- });
703
- }
704
- get displayValue() {
705
- return this.value;
706
- }
707
- get isComplete() {
708
- return !0;
709
- }
710
- get isFilled() {
711
- return this.isComplete;
712
- }
713
- /** Finds nearest input position in direction */
714
- nearestInputPos(e, t) {
715
- return e;
716
- }
717
- totalInputPositions(e, t) {
718
- return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), Math.min(this.displayValue.length, t - e);
719
- }
720
- /** Extracts value in range considering flags */
721
- extractInput(e, t, s) {
722
- return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), this.displayValue.slice(e, t);
723
- }
724
- /** Extracts tail in range */
725
- extractTail(e, t) {
726
- return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), new A(this.extractInput(e, t), e);
727
- }
728
- /** Appends tail */
729
- appendTail(e) {
730
- return b(e) && (e = new A(String(e))), e.appendTo(this);
731
- }
732
- /** Appends char */
733
- _appendCharRaw(e, t) {
734
- return e ? (this._value += e, new f({
735
- inserted: e,
736
- rawInserted: e
737
- })) : new f();
738
- }
739
- /** Appends char */
740
- _appendChar(e, t, s) {
741
- t === void 0 && (t = {});
742
- const i = this.state;
743
- let a;
744
- if ([e, a] = this.doPrepareChar(e, t), e && (a = a.aggregate(this._appendCharRaw(e, t)), !a.rawInserted && this.autofix === "pad")) {
745
- const n = this.state;
746
- this.state = i;
747
- let r = this.pad(t);
748
- const l = this._appendCharRaw(e, t);
749
- r = r.aggregate(l), l.rawInserted || r.equals(a) ? a = r : this.state = n;
750
- }
751
- if (a.inserted) {
752
- let n, r = this.doValidate(t) !== !1;
753
- if (r && s != null) {
754
- const l = this.state;
755
- if (this.overwrite === !0) {
756
- n = s.state;
757
- for (let p = 0; p < a.rawInserted.length; ++p)
758
- s.unshift(this.displayValue.length - a.tailShift);
759
- }
760
- let h = this.appendTail(s);
761
- if (r = h.rawInserted.length === s.toString().length, !(r && h.inserted) && this.overwrite === "shift") {
762
- this.state = l, n = s.state;
763
- for (let p = 0; p < a.rawInserted.length; ++p)
764
- s.shift();
765
- h = this.appendTail(s), r = h.rawInserted.length === s.toString().length;
766
- }
767
- r && h.inserted && (this.state = l);
768
- }
769
- r || (a = new f(), this.state = i, s && n && (s.state = n));
770
- }
771
- return a;
772
- }
773
- /** Appends optional placeholder at the end */
774
- _appendPlaceholder() {
775
- return new f();
776
- }
777
- /** Appends optional eager placeholder at the end */
778
- _appendEager() {
779
- return new f();
780
- }
781
- /** Appends symbols considering flags */
782
- append(e, t, s) {
783
- if (!b(e)) throw new Error("value should be string");
784
- const i = b(s) ? new A(String(s)) : s;
785
- t != null && t.tail && (t._beforeTailState = this.state);
786
- let a;
787
- [e, a] = this.doPrepare(e, t);
788
- for (let n = 0; n < e.length; ++n) {
789
- const r = this._appendChar(e[n], t, i);
790
- if (!r.rawInserted && !this.doSkipInvalid(e[n], t, i)) break;
791
- a.aggregate(r);
792
- }
793
- return (this.eager === !0 || this.eager === "append") && t != null && t.input && e && a.aggregate(this._appendEager()), i != null && (a.tailShift += this.appendTail(i).tailShift), a;
794
- }
795
- remove(e, t) {
796
- return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), this._value = this.displayValue.slice(0, e) + this.displayValue.slice(t), new f();
797
- }
798
- /** Calls function and reapplies current value */
799
- withValueRefresh(e) {
800
- if (this._refreshing || !this._initialized) return e();
801
- this._refreshing = !0;
802
- const t = this.rawInputValue, s = this.value, i = e();
803
- return this.rawInputValue = t, this.value && this.value !== s && s.indexOf(this.value) === 0 && (this.append(s.slice(this.displayValue.length), {}, ""), this.doCommit()), delete this._refreshing, i;
804
- }
805
- runIsolated(e) {
806
- if (this._isolated || !this._initialized) return e(this);
807
- this._isolated = !0;
808
- const t = this.state, s = e(this);
809
- return this.state = t, delete this._isolated, s;
810
- }
811
- doSkipInvalid(e, t, s) {
812
- return !!this.skipInvalid;
813
- }
814
- /** Prepares string before mask processing */
815
- doPrepare(e, t) {
816
- return t === void 0 && (t = {}), f.normalize(this.prepare ? this.prepare(e, this, t) : e);
817
- }
818
- /** Prepares each char before mask processing */
819
- doPrepareChar(e, t) {
820
- return t === void 0 && (t = {}), f.normalize(this.prepareChar ? this.prepareChar(e, this, t) : e);
821
- }
822
- /** Validates if value is acceptable */
823
- doValidate(e) {
824
- return (!this.validate || this.validate(this.value, this, e)) && (!this.parent || this.parent.doValidate(e));
825
- }
826
- /** Does additional processing at the end of editing */
827
- doCommit() {
828
- this.commit && this.commit(this.value, this);
829
- }
830
- splice(e, t, s, i, a) {
831
- s === void 0 && (s = ""), i === void 0 && (i = d.NONE), a === void 0 && (a = {
832
- input: !0
833
- });
834
- const n = e + t, r = this.extractTail(n), l = this.eager === !0 || this.eager === "remove";
835
- let h;
836
- l && (i = ft(i), h = this.extractInput(0, n, {
837
- raw: !0
838
- }));
839
- let p = e;
840
- const k = new f();
841
- if (i !== d.NONE && (p = this.nearestInputPos(e, t > 1 && e !== 0 && !l ? d.NONE : i), k.tailShift = p - e), k.aggregate(this.remove(p)), l && i !== d.NONE && h === this.rawInputValue)
842
- if (i === d.FORCE_LEFT) {
843
- let g;
844
- for (; h === this.rawInputValue && (g = this.displayValue.length); )
845
- k.aggregate(new f({
846
- tailShift: -1
847
- })).aggregate(this.remove(g - 1));
848
- } else i === d.FORCE_RIGHT && r.unshift();
849
- return k.aggregate(this.append(s, a, r));
850
- }
851
- maskEquals(e) {
852
- return this.mask === e;
853
- }
854
- optionsIsChanged(e) {
855
- return !J(this, e);
856
- }
857
- typedValueEquals(e) {
858
- const t = this.typedValue;
859
- return e === t || L.EMPTY_VALUES.includes(e) && L.EMPTY_VALUES.includes(t) || (this.format ? this.format(e, this) === this.format(this.typedValue, this) : !1);
860
- }
861
- pad(e) {
862
- return new f();
863
- }
864
- };
865
- o(L, "Masked");
866
- let C = L;
867
- C.DEFAULTS = {
868
- skipInvalid: !0
869
- };
870
- C.EMPTY_VALUES = [void 0, null, ""];
871
- c.Masked = C;
872
- const D = class D {
873
- /** */
874
- constructor(e, t) {
875
- e === void 0 && (e = []), t === void 0 && (t = 0), this.chunks = e, this.from = t;
876
- }
877
- toString() {
878
- return this.chunks.map(String).join("");
879
- }
880
- extend(e) {
881
- if (!String(e)) return;
882
- e = b(e) ? new A(String(e)) : e;
883
- const t = this.chunks[this.chunks.length - 1], s = t && // if stops are same or tail has no stop
884
- (t.stop === e.stop || e.stop == null) && // if tail chunk goes just after last chunk
885
- e.from === t.from + t.toString().length;
886
- if (e instanceof A)
887
- s ? t.extend(e.toString()) : this.chunks.push(e);
888
- else if (e instanceof D) {
889
- if (e.stop == null) {
890
- let i;
891
- for (; e.chunks.length && e.chunks[0].stop == null; )
892
- i = e.chunks.shift(), i.from += e.from, this.extend(i);
893
- }
894
- e.toString() && (e.stop = e.blockIndex, this.chunks.push(e));
895
- }
896
- }
897
- appendTo(e) {
898
- if (!(e instanceof c.MaskedPattern))
899
- return new A(this.toString()).appendTo(e);
900
- const t = new f();
901
- for (let s = 0; s < this.chunks.length; ++s) {
902
- const i = this.chunks[s], a = e._mapPosToBlock(e.displayValue.length), n = i.stop;
903
- let r;
904
- if (n != null && // if block not found or stop is behind lastBlock
905
- (!a || a.index <= n) && ((i instanceof D || // for continuous block also check if stop is exist
906
- e._stops.indexOf(n) >= 0) && t.aggregate(e._appendPlaceholder(n)), r = i instanceof D && e._blocks[n]), r) {
907
- const l = r.appendTail(i);
908
- t.aggregate(l);
909
- const h = i.toString().slice(l.rawInserted.length);
910
- h && t.aggregate(e.append(h, {
911
- tail: !0
912
- }));
913
- } else
914
- t.aggregate(e.append(i.toString(), {
915
- tail: !0
916
- }));
917
- }
918
- return t;
919
- }
920
- get state() {
921
- return {
922
- chunks: this.chunks.map((e) => e.state),
923
- from: this.from,
924
- stop: this.stop,
925
- blockIndex: this.blockIndex
926
- };
927
- }
928
- set state(e) {
929
- const {
930
- chunks: t,
931
- ...s
932
- } = e;
933
- Object.assign(this, s), this.chunks = t.map((i) => {
934
- const a = "chunks" in i ? new D() : new A();
935
- return a.state = i, a;
936
- });
937
- }
938
- unshift(e) {
939
- if (!this.chunks.length || e != null && this.from >= e) return "";
940
- const t = e != null ? e - this.from : e;
941
- let s = 0;
942
- for (; s < this.chunks.length; ) {
943
- const i = this.chunks[s], a = i.unshift(t);
944
- if (i.toString()) {
945
- if (!a) break;
946
- ++s;
947
- } else
948
- this.chunks.splice(s, 1);
949
- if (a) return a;
950
- }
951
- return "";
952
- }
953
- shift() {
954
- if (!this.chunks.length) return "";
955
- let e = this.chunks.length - 1;
956
- for (; 0 <= e; ) {
957
- const t = this.chunks[e], s = t.shift();
958
- if (t.toString()) {
959
- if (!s) break;
960
- --e;
961
- } else
962
- this.chunks.splice(e, 1);
963
- if (s) return s;
964
- }
965
- return "";
966
- }
967
- };
968
- o(D, "ChunksTailDetails");
969
- let te = D;
970
- const Ie = class Ie {
971
- constructor(e, t) {
972
- this.masked = e, this._log = [];
973
- const {
974
- offset: s,
975
- index: i
976
- } = e._mapPosToBlock(t) || (t < 0 ? (
977
- // first
978
- {
979
- index: 0,
980
- offset: 0
981
- }
982
- ) : (
983
- // last
984
- {
985
- index: this.masked._blocks.length,
986
- offset: 0
987
- }
988
- ));
989
- this.offset = s, this.index = i, this.ok = !1;
990
- }
991
- get block() {
992
- return this.masked._blocks[this.index];
993
- }
994
- get pos() {
995
- return this.masked._blockStartPos(this.index) + this.offset;
996
- }
997
- get state() {
998
- return {
999
- index: this.index,
1000
- offset: this.offset,
1001
- ok: this.ok
1002
- };
1003
- }
1004
- set state(e) {
1005
- Object.assign(this, e);
1006
- }
1007
- pushState() {
1008
- this._log.push(this.state);
1009
- }
1010
- popState() {
1011
- const e = this._log.pop();
1012
- return e && (this.state = e), e;
1013
- }
1014
- bindBlock() {
1015
- this.block || (this.index < 0 && (this.index = 0, this.offset = 0), this.index >= this.masked._blocks.length && (this.index = this.masked._blocks.length - 1, this.offset = this.block.displayValue.length));
1016
- }
1017
- _pushLeft(e) {
1018
- for (this.pushState(), this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((t = this.block) == null ? void 0 : t.displayValue.length) || 0) {
1019
- var t;
1020
- if (e()) return this.ok = !0;
1021
- }
1022
- return this.ok = !1;
1023
- }
1024
- _pushRight(e) {
1025
- for (this.pushState(), this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0)
1026
- if (e()) return this.ok = !0;
1027
- return this.ok = !1;
1028
- }
1029
- pushLeftBeforeFilled() {
1030
- return this._pushLeft(() => {
1031
- if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, d.FORCE_LEFT), this.offset !== 0))
1032
- return !0;
1033
- });
1034
- }
1035
- pushLeftBeforeInput() {
1036
- return this._pushLeft(() => {
1037
- if (!this.block.isFixed)
1038
- return this.offset = this.block.nearestInputPos(this.offset, d.LEFT), !0;
1039
- });
1040
- }
1041
- pushLeftBeforeRequired() {
1042
- return this._pushLeft(() => {
1043
- if (!(this.block.isFixed || this.block.isOptional && !this.block.value))
1044
- return this.offset = this.block.nearestInputPos(this.offset, d.LEFT), !0;
1045
- });
1046
- }
1047
- pushRightBeforeFilled() {
1048
- return this._pushRight(() => {
1049
- if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, d.FORCE_RIGHT), this.offset !== this.block.value.length))
1050
- return !0;
1051
- });
1052
- }
1053
- pushRightBeforeInput() {
1054
- return this._pushRight(() => {
1055
- if (!this.block.isFixed)
1056
- return this.offset = this.block.nearestInputPos(this.offset, d.NONE), !0;
1057
- });
1058
- }
1059
- pushRightBeforeRequired() {
1060
- return this._pushRight(() => {
1061
- if (!(this.block.isFixed || this.block.isOptional && !this.block.value))
1062
- return this.offset = this.block.nearestInputPos(this.offset, d.NONE), !0;
1063
- });
1064
- }
1065
- };
1066
- o(Ie, "PatternCursor");
1067
- let ve = Ie;
1068
- const we = class we {
1069
- /** */
1070
- /** */
1071
- /** */
1072
- /** */
1073
- /** */
1074
- /** */
1075
- constructor(e) {
1076
- Object.assign(this, e), this._value = "", this.isFixed = !0;
1077
- }
1078
- get value() {
1079
- return this._value;
1080
- }
1081
- get unmaskedValue() {
1082
- return this.isUnmasking ? this.value : "";
1083
- }
1084
- get rawInputValue() {
1085
- return this._isRawInput ? this.value : "";
1086
- }
1087
- get displayValue() {
1088
- return this.value;
1089
- }
1090
- reset() {
1091
- this._isRawInput = !1, this._value = "";
1092
- }
1093
- remove(e, t) {
1094
- return e === void 0 && (e = 0), t === void 0 && (t = this._value.length), this._value = this._value.slice(0, e) + this._value.slice(t), this._value || (this._isRawInput = !1), new f();
1095
- }
1096
- nearestInputPos(e, t) {
1097
- t === void 0 && (t = d.NONE);
1098
- const s = 0, i = this._value.length;
1099
- switch (t) {
1100
- case d.LEFT:
1101
- case d.FORCE_LEFT:
1102
- return s;
1103
- case d.NONE:
1104
- case d.RIGHT:
1105
- case d.FORCE_RIGHT:
1106
- default:
1107
- return i;
1108
- }
1109
- }
1110
- totalInputPositions(e, t) {
1111
- return e === void 0 && (e = 0), t === void 0 && (t = this._value.length), this._isRawInput ? t - e : 0;
1112
- }
1113
- extractInput(e, t, s) {
1114
- return e === void 0 && (e = 0), t === void 0 && (t = this._value.length), s === void 0 && (s = {}), s.raw && this._isRawInput && this._value.slice(e, t) || "";
1115
- }
1116
- get isComplete() {
1117
- return !0;
1118
- }
1119
- get isFilled() {
1120
- return !!this._value;
1121
- }
1122
- _appendChar(e, t) {
1123
- if (t === void 0 && (t = {}), this.isFilled) return new f();
1124
- const s = this.eager === !0 || this.eager === "append", a = this.char === e && (this.isUnmasking || t.input || t.raw) && (!t.raw || !s) && !t.tail, n = new f({
1125
- inserted: this.char,
1126
- rawInserted: a ? this.char : ""
1127
- });
1128
- return this._value = this.char, this._isRawInput = a && (t.raw || t.input), n;
1129
- }
1130
- _appendEager() {
1131
- return this._appendChar(this.char, {
1132
- tail: !0
1133
- });
1134
- }
1135
- _appendPlaceholder() {
1136
- const e = new f();
1137
- return this.isFilled || (this._value = e.inserted = this.char), e;
1138
- }
1139
- extractTail() {
1140
- return new A("");
1141
- }
1142
- appendTail(e) {
1143
- return b(e) && (e = new A(String(e))), e.appendTo(this);
1144
- }
1145
- append(e, t, s) {
1146
- const i = this._appendChar(e[0], t);
1147
- return s != null && (i.tailShift += this.appendTail(s).tailShift), i;
1148
- }
1149
- doCommit() {
1150
- }
1151
- get state() {
1152
- return {
1153
- _value: this._value,
1154
- _rawInputValue: this.rawInputValue
1155
- };
1156
- }
1157
- set state(e) {
1158
- this._value = e._value, this._isRawInput = !!e._rawInputValue;
1159
- }
1160
- pad(e) {
1161
- return this._appendPlaceholder();
1162
- }
1163
- };
1164
- o(we, "PatternFixedDefinition");
1165
- let se = we;
1166
- const De = class De {
1167
- /** */
1168
- /** */
1169
- /** */
1170
- /** */
1171
- /** */
1172
- /** */
1173
- /** */
1174
- /** */
1175
- constructor(e) {
1176
- const {
1177
- parent: t,
1178
- isOptional: s,
1179
- placeholderChar: i,
1180
- displayChar: a,
1181
- lazy: n,
1182
- eager: r,
1183
- ...l
1184
- } = e;
1185
- this.masked = V(l), Object.assign(this, {
1186
- parent: t,
1187
- isOptional: s,
1188
- placeholderChar: i,
1189
- displayChar: a,
1190
- lazy: n,
1191
- eager: r
1192
- });
1193
- }
1194
- reset() {
1195
- this.isFilled = !1, this.masked.reset();
1196
- }
1197
- remove(e, t) {
1198
- return e === void 0 && (e = 0), t === void 0 && (t = this.value.length), e === 0 && t >= 1 ? (this.isFilled = !1, this.masked.remove(e, t)) : new f();
1199
- }
1200
- get value() {
1201
- return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : "");
1202
- }
1203
- get unmaskedValue() {
1204
- return this.masked.unmaskedValue;
1205
- }
1206
- get rawInputValue() {
1207
- return this.masked.rawInputValue;
1208
- }
1209
- get displayValue() {
1210
- return this.masked.value && this.displayChar || this.value;
1211
- }
1212
- get isComplete() {
1213
- return !!this.masked.value || this.isOptional;
1214
- }
1215
- _appendChar(e, t) {
1216
- if (t === void 0 && (t = {}), this.isFilled) return new f();
1217
- const s = this.masked.state;
1218
- let i = this.masked._appendChar(e, this.currentMaskFlags(t));
1219
- return i.inserted && this.doValidate(t) === !1 && (i = new f(), this.masked.state = s), !i.inserted && !this.isOptional && !this.lazy && !t.input && (i.inserted = this.placeholderChar), i.skip = !i.inserted && !this.isOptional, this.isFilled = !!i.inserted, i;
1220
- }
1221
- append(e, t, s) {
1222
- return this.masked.append(e, this.currentMaskFlags(t), s);
1223
- }
1224
- _appendPlaceholder() {
1225
- return this.isFilled || this.isOptional ? new f() : (this.isFilled = !0, new f({
1226
- inserted: this.placeholderChar
1227
- }));
1228
- }
1229
- _appendEager() {
1230
- return new f();
1231
- }
1232
- extractTail(e, t) {
1233
- return this.masked.extractTail(e, t);
1234
- }
1235
- appendTail(e) {
1236
- return this.masked.appendTail(e);
1237
- }
1238
- extractInput(e, t, s) {
1239
- return e === void 0 && (e = 0), t === void 0 && (t = this.value.length), this.masked.extractInput(e, t, s);
1240
- }
1241
- nearestInputPos(e, t) {
1242
- t === void 0 && (t = d.NONE);
1243
- const s = 0, i = this.value.length, a = Math.min(Math.max(e, s), i);
1244
- switch (t) {
1245
- case d.LEFT:
1246
- case d.FORCE_LEFT:
1247
- return this.isComplete ? a : s;
1248
- case d.RIGHT:
1249
- case d.FORCE_RIGHT:
1250
- return this.isComplete ? a : i;
1251
- case d.NONE:
1252
- default:
1253
- return a;
1254
- }
1255
- }
1256
- totalInputPositions(e, t) {
1257
- return e === void 0 && (e = 0), t === void 0 && (t = this.value.length), this.value.slice(e, t).length;
1258
- }
1259
- doValidate(e) {
1260
- return this.masked.doValidate(this.currentMaskFlags(e)) && (!this.parent || this.parent.doValidate(this.currentMaskFlags(e)));
1261
- }
1262
- doCommit() {
1263
- this.masked.doCommit();
1264
- }
1265
- get state() {
1266
- return {
1267
- _value: this.value,
1268
- _rawInputValue: this.rawInputValue,
1269
- masked: this.masked.state,
1270
- isFilled: this.isFilled
1271
- };
1272
- }
1273
- set state(e) {
1274
- this.masked.state = e.masked, this.isFilled = e.isFilled;
1275
- }
1276
- currentMaskFlags(e) {
1277
- var t;
1278
- return {
1279
- ...e,
1280
- _beforeTailState: (e == null || (t = e._beforeTailState) == null ? void 0 : t.masked) || e?._beforeTailState
1281
- };
1282
- }
1283
- pad(e) {
1284
- return new f();
1285
- }
1286
- };
1287
- o(De, "PatternInputDefinition");
1288
- let Y = De;
1289
- Y.DEFAULT_DEFINITIONS = {
1290
- 0: /\d/,
1291
- a: /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
1292
- // http://stackoverflow.com/a/22075070
1293
- "*": /./
1294
- };
1295
- const Me = class Me extends C {
1296
- /** */
1297
- /** Enable characters overwriting */
1298
- /** */
1299
- /** */
1300
- /** */
1301
- updateOptions(e) {
1302
- super.updateOptions(e);
1303
- }
1304
- _update(e) {
1305
- const t = e.mask;
1306
- t && (e.validate = (s) => s.search(t) >= 0), super._update(e);
1307
- }
1308
- };
1309
- o(Me, "MaskedRegExp");
1310
- let _e = Me;
1311
- c.MaskedRegExp = _e;
1312
- const N = class N extends C {
1313
- /** */
1314
- /** */
1315
- /** Single char for empty input */
1316
- /** Single char for filled input */
1317
- /** Show placeholder only when needed */
1318
- /** Enable characters overwriting */
1319
- /** */
1320
- /** */
1321
- /** */
1322
- constructor(e) {
1323
- super({
1324
- ...N.DEFAULTS,
1325
- ...e,
1326
- definitions: Object.assign({}, Y.DEFAULT_DEFINITIONS, e?.definitions)
1327
- });
1328
- }
1329
- updateOptions(e) {
1330
- super.updateOptions(e);
1331
- }
1332
- _update(e) {
1333
- e.definitions = Object.assign({}, this.definitions, e.definitions), super._update(e), this._rebuildMask();
1334
- }
1335
- _rebuildMask() {
1336
- const e = this.definitions;
1337
- this._blocks = [], this.exposeBlock = void 0, this._stops = [], this._maskedBlocks = {};
1338
- const t = this.mask;
1339
- if (!t || !e) return;
1340
- let s = !1, i = !1;
1341
- for (let a = 0; a < t.length; ++a) {
1342
- if (this.blocks) {
1343
- const h = t.slice(a), p = Object.keys(this.blocks).filter((g) => h.indexOf(g) === 0);
1344
- p.sort((g, m) => m.length - g.length);
1345
- const k = p[0];
1346
- if (k) {
1347
- const {
1348
- expose: g,
1349
- repeat: m,
1350
- ..._
1351
- } = q(this.blocks[k]), T = {
1352
- lazy: this.lazy,
1353
- eager: this.eager,
1354
- placeholderChar: this.placeholderChar,
1355
- displayChar: this.displayChar,
1356
- overwrite: this.overwrite,
1357
- autofix: this.autofix,
1358
- ..._,
1359
- repeat: m,
1360
- parent: this
1361
- }, w = m != null ? new c.RepeatBlock(
1362
- T
1363
- /* TODO */
1364
- ) : V(T);
1365
- w && (this._blocks.push(w), g && (this.exposeBlock = w), this._maskedBlocks[k] || (this._maskedBlocks[k] = []), this._maskedBlocks[k].push(this._blocks.length - 1)), a += k.length - 1;
1366
- continue;
1367
- }
1368
- }
1369
- let n = t[a], r = n in e;
1370
- if (n === N.STOP_CHAR) {
1371
- this._stops.push(this._blocks.length);
1372
- continue;
1373
- }
1374
- if (n === "{" || n === "}") {
1375
- s = !s;
1376
- continue;
1377
- }
1378
- if (n === "[" || n === "]") {
1379
- i = !i;
1380
- continue;
1381
- }
1382
- if (n === N.ESCAPE_CHAR) {
1383
- if (++a, n = t[a], !n) break;
1384
- r = !1;
1385
- }
1386
- const l = r ? new Y({
1387
- isOptional: i,
1388
- lazy: this.lazy,
1389
- eager: this.eager,
1390
- placeholderChar: this.placeholderChar,
1391
- displayChar: this.displayChar,
1392
- ...q(e[n]),
1393
- parent: this
1394
- }) : new se({
1395
- char: n,
1396
- eager: this.eager,
1397
- isUnmasking: s
1398
- });
1399
- this._blocks.push(l);
1400
- }
1401
- }
1402
- get state() {
1403
- return {
1404
- ...super.state,
1405
- _blocks: this._blocks.map((e) => e.state)
1406
- };
1407
- }
1408
- set state(e) {
1409
- if (!e) {
1410
- this.reset();
1411
- return;
1412
- }
1413
- const {
1414
- _blocks: t,
1415
- ...s
1416
- } = e;
1417
- this._blocks.forEach((i, a) => i.state = t[a]), super.state = s;
1418
- }
1419
- reset() {
1420
- super.reset(), this._blocks.forEach((e) => e.reset());
1421
- }
1422
- get isComplete() {
1423
- return this.exposeBlock ? this.exposeBlock.isComplete : this._blocks.every((e) => e.isComplete);
1424
- }
1425
- get isFilled() {
1426
- return this._blocks.every((e) => e.isFilled);
1427
- }
1428
- get isFixed() {
1429
- return this._blocks.every((e) => e.isFixed);
1430
- }
1431
- get isOptional() {
1432
- return this._blocks.every((e) => e.isOptional);
1433
- }
1434
- doCommit() {
1435
- this._blocks.forEach((e) => e.doCommit()), super.doCommit();
1436
- }
1437
- get unmaskedValue() {
1438
- return this.exposeBlock ? this.exposeBlock.unmaskedValue : this._blocks.reduce((e, t) => e += t.unmaskedValue, "");
1439
- }
1440
- set unmaskedValue(e) {
1441
- if (this.exposeBlock) {
1442
- const t = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1443
- this.exposeBlock.unmaskedValue = e, this.appendTail(t), this.doCommit();
1444
- } else super.unmaskedValue = e;
1445
- }
1446
- get value() {
1447
- return this.exposeBlock ? this.exposeBlock.value : (
1448
- // TODO return _value when not in change?
1449
- this._blocks.reduce((e, t) => e += t.value, "")
1450
- );
1451
- }
1452
- set value(e) {
1453
- if (this.exposeBlock) {
1454
- const t = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1455
- this.exposeBlock.value = e, this.appendTail(t), this.doCommit();
1456
- } else super.value = e;
1457
- }
1458
- get typedValue() {
1459
- return this.exposeBlock ? this.exposeBlock.typedValue : super.typedValue;
1460
- }
1461
- set typedValue(e) {
1462
- if (this.exposeBlock) {
1463
- const t = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1464
- this.exposeBlock.typedValue = e, this.appendTail(t), this.doCommit();
1465
- } else super.typedValue = e;
1466
- }
1467
- get displayValue() {
1468
- return this._blocks.reduce((e, t) => e += t.displayValue, "");
1469
- }
1470
- appendTail(e) {
1471
- return super.appendTail(e).aggregate(this._appendPlaceholder());
1472
- }
1473
- _appendEager() {
1474
- var e;
1475
- const t = new f();
1476
- let s = (e = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : e.index;
1477
- if (s == null) return t;
1478
- this._blocks[s].isFilled && ++s;
1479
- for (let i = s; i < this._blocks.length; ++i) {
1480
- const a = this._blocks[i]._appendEager();
1481
- if (!a.inserted) break;
1482
- t.aggregate(a);
1483
- }
1484
- return t;
1485
- }
1486
- _appendCharRaw(e, t) {
1487
- t === void 0 && (t = {});
1488
- const s = this._mapPosToBlock(this.displayValue.length), i = new f();
1489
- if (!s) return i;
1490
- for (let n = s.index, r; r = this._blocks[n]; ++n) {
1491
- var a;
1492
- const l = r._appendChar(e, {
1493
- ...t,
1494
- _beforeTailState: (a = t._beforeTailState) == null || (a = a._blocks) == null ? void 0 : a[n]
1495
- });
1496
- if (i.aggregate(l), l.consumed) break;
1497
- }
1498
- return i;
1499
- }
1500
- extractTail(e, t) {
1501
- e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length);
1502
- const s = new te();
1503
- return e === t || this._forEachBlocksInRange(e, t, (i, a, n, r) => {
1504
- const l = i.extractTail(n, r);
1505
- l.stop = this._findStopBefore(a), l.from = this._blockStartPos(a), l instanceof te && (l.blockIndex = a), s.extend(l);
1506
- }), s;
1507
- }
1508
- extractInput(e, t, s) {
1509
- if (e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), s === void 0 && (s = {}), e === t) return "";
1510
- let i = "";
1511
- return this._forEachBlocksInRange(e, t, (a, n, r, l) => {
1512
- i += a.extractInput(r, l, s);
1513
- }), i;
1514
- }
1515
- _findStopBefore(e) {
1516
- let t;
1517
- for (let s = 0; s < this._stops.length; ++s) {
1518
- const i = this._stops[s];
1519
- if (i <= e) t = i;
1520
- else break;
1521
- }
1522
- return t;
1523
- }
1524
- /** Appends placeholder depending on laziness */
1525
- _appendPlaceholder(e) {
1526
- const t = new f();
1527
- if (this.lazy && e == null) return t;
1528
- const s = this._mapPosToBlock(this.displayValue.length);
1529
- if (!s) return t;
1530
- const i = s.index, a = e ?? this._blocks.length;
1531
- return this._blocks.slice(i, a).forEach((n) => {
1532
- if (!n.lazy || e != null) {
1533
- var r;
1534
- t.aggregate(n._appendPlaceholder((r = n._blocks) == null ? void 0 : r.length));
1535
- }
1536
- }), t;
1537
- }
1538
- /** Finds block in pos */
1539
- _mapPosToBlock(e) {
1540
- let t = "";
1541
- for (let s = 0; s < this._blocks.length; ++s) {
1542
- const i = this._blocks[s], a = t.length;
1543
- if (t += i.displayValue, e <= t.length)
1544
- return {
1545
- index: s,
1546
- offset: e - a
1547
- };
1548
- }
1549
- }
1550
- _blockStartPos(e) {
1551
- return this._blocks.slice(0, e).reduce((t, s) => t += s.displayValue.length, 0);
1552
- }
1553
- _forEachBlocksInRange(e, t, s) {
1554
- t === void 0 && (t = this.displayValue.length);
1555
- const i = this._mapPosToBlock(e);
1556
- if (i) {
1557
- const a = this._mapPosToBlock(t), n = a && i.index === a.index, r = i.offset, l = a && n ? a.offset : this._blocks[i.index].displayValue.length;
1558
- if (s(this._blocks[i.index], i.index, r, l), a && !n) {
1559
- for (let h = i.index + 1; h < a.index; ++h)
1560
- s(this._blocks[h], h, 0, this._blocks[h].displayValue.length);
1561
- s(this._blocks[a.index], a.index, 0, a.offset);
1562
- }
1563
- }
1564
- }
1565
- remove(e, t) {
1566
- e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length);
1567
- const s = super.remove(e, t);
1568
- return this._forEachBlocksInRange(e, t, (i, a, n, r) => {
1569
- s.aggregate(i.remove(n, r));
1570
- }), s;
1571
- }
1572
- nearestInputPos(e, t) {
1573
- if (t === void 0 && (t = d.NONE), !this._blocks.length) return 0;
1574
- const s = new ve(this, e);
1575
- if (t === d.NONE)
1576
- return s.pushRightBeforeInput() || (s.popState(), s.pushLeftBeforeInput()) ? s.pos : this.displayValue.length;
1577
- if (t === d.LEFT || t === d.FORCE_LEFT) {
1578
- if (t === d.LEFT) {
1579
- if (s.pushRightBeforeFilled(), s.ok && s.pos === e) return e;
1580
- s.popState();
1581
- }
1582
- if (s.pushLeftBeforeInput(), s.pushLeftBeforeRequired(), s.pushLeftBeforeFilled(), t === d.LEFT) {
1583
- if (s.pushRightBeforeInput(), s.pushRightBeforeRequired(), s.ok && s.pos <= e || (s.popState(), s.ok && s.pos <= e)) return s.pos;
1584
- s.popState();
1585
- }
1586
- return s.ok ? s.pos : t === d.FORCE_LEFT ? 0 : (s.popState(), s.ok || (s.popState(), s.ok) ? s.pos : 0);
1587
- }
1588
- return t === d.RIGHT || t === d.FORCE_RIGHT ? (s.pushRightBeforeInput(), s.pushRightBeforeRequired(), s.pushRightBeforeFilled() ? s.pos : t === d.FORCE_RIGHT ? this.displayValue.length : (s.popState(), s.ok || (s.popState(), s.ok) ? s.pos : this.nearestInputPos(e, d.LEFT))) : e;
1589
- }
1590
- totalInputPositions(e, t) {
1591
- e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length);
1592
- let s = 0;
1593
- return this._forEachBlocksInRange(e, t, (i, a, n, r) => {
1594
- s += i.totalInputPositions(n, r);
1595
- }), s;
1596
- }
1597
- /** Get block by name */
1598
- maskedBlock(e) {
1599
- return this.maskedBlocks(e)[0];
1600
- }
1601
- /** Get all blocks by name */
1602
- maskedBlocks(e) {
1603
- const t = this._maskedBlocks[e];
1604
- return t ? t.map((s) => this._blocks[s]) : [];
1605
- }
1606
- pad(e) {
1607
- const t = new f();
1608
- return this._forEachBlocksInRange(0, this.displayValue.length, (s) => t.aggregate(s.pad(e))), t;
1609
- }
1610
- };
1611
- o(N, "MaskedPattern");
1612
- let E = N;
1613
- E.DEFAULTS = {
1614
- ...C.DEFAULTS,
1615
- lazy: !0,
1616
- placeholderChar: "_"
1617
- };
1618
- E.STOP_CHAR = "`";
1619
- E.ESCAPE_CHAR = "\\";
1620
- E.InputDefinition = Y;
1621
- E.FixedDefinition = se;
1622
- c.MaskedPattern = E;
1623
- const Te = class Te extends E {
1624
- /**
1625
- Optionally sets max length of pattern.
1626
- Used when pattern length is longer then `to` param length. Pads zeros at start in this case.
1627
- */
1628
- /** Min bound */
1629
- /** Max bound */
1630
- get _matchFrom() {
1631
- return this.maxLength - String(this.from).length;
1632
- }
1633
- constructor(e) {
1634
- super(e);
1635
- }
1636
- updateOptions(e) {
1637
- super.updateOptions(e);
1638
- }
1639
- _update(e) {
1640
- const {
1641
- to: t = this.to || 0,
1642
- from: s = this.from || 0,
1643
- maxLength: i = this.maxLength || 0,
1644
- autofix: a = this.autofix,
1645
- ...n
1646
- } = e;
1647
- this.to = t, this.from = s, this.maxLength = Math.max(String(t).length, i), this.autofix = a;
1648
- const r = String(this.from).padStart(this.maxLength, "0"), l = String(this.to).padStart(this.maxLength, "0");
1649
- let h = 0;
1650
- for (; h < l.length && l[h] === r[h]; ) ++h;
1651
- n.mask = l.slice(0, h).replace(/0/g, "\\0") + "0".repeat(this.maxLength - h), super._update(n);
1652
- }
1653
- get isComplete() {
1654
- return super.isComplete && !!this.value;
1655
- }
1656
- boundaries(e) {
1657
- let t = "", s = "";
1658
- const [, i, a] = e.match(/^(\D*)(\d*)(\D*)/) || [];
1659
- return a && (t = "0".repeat(i.length) + a, s = "9".repeat(i.length) + a), t = t.padEnd(this.maxLength, "0"), s = s.padEnd(this.maxLength, "9"), [t, s];
1660
- }
1661
- doPrepareChar(e, t) {
1662
- t === void 0 && (t = {});
1663
- let s;
1664
- return [e, s] = super.doPrepareChar(e.replace(/\D/g, ""), t), e || (s.skip = !this.isComplete), [e, s];
1665
- }
1666
- _appendCharRaw(e, t) {
1667
- if (t === void 0 && (t = {}), !this.autofix || this.value.length + 1 > this.maxLength) return super._appendCharRaw(e, t);
1668
- const s = String(this.from).padStart(this.maxLength, "0"), i = String(this.to).padStart(this.maxLength, "0"), [a, n] = this.boundaries(this.value + e);
1669
- return Number(n) < this.from ? super._appendCharRaw(s[this.value.length], t) : Number(a) > this.to ? !t.tail && this.autofix === "pad" && this.value.length + 1 < this.maxLength ? super._appendCharRaw(s[this.value.length], t).aggregate(this._appendCharRaw(e, t)) : super._appendCharRaw(i[this.value.length], t) : super._appendCharRaw(e, t);
1670
- }
1671
- doValidate(e) {
1672
- const t = this.value;
1673
- if (t.search(/[^0]/) === -1 && t.length <= this._matchFrom) return !0;
1674
- const [i, a] = this.boundaries(t);
1675
- return this.from <= Number(a) && Number(i) <= this.to && super.doValidate(e);
1676
- }
1677
- pad(e) {
1678
- const t = new f();
1679
- if (this.value.length === this.maxLength) return t;
1680
- const s = this.value, i = this.maxLength - this.value.length;
1681
- if (i) {
1682
- this.reset();
1683
- for (let a = 0; a < i; ++a)
1684
- t.aggregate(super._appendCharRaw("0", e));
1685
- s.split("").forEach((a) => this._appendCharRaw(a));
1686
- }
1687
- return t;
1688
- }
1689
- };
1690
- o(Te, "MaskedRange");
1691
- let P = Te;
1692
- c.MaskedRange = P;
1693
- const kt = "d{.}`m{.}`Y", B = class B extends E {
1694
- static extractPatternOptions(e) {
1695
- const {
1696
- mask: t,
1697
- pattern: s,
1698
- ...i
1699
- } = e;
1700
- return {
1701
- ...i,
1702
- mask: b(t) ? t : s
1703
- };
1704
- }
1705
- /** Pattern mask for date according to {@link MaskedDate#format} */
1706
- /** Start date */
1707
- /** End date */
1708
- /** Format typed value to string */
1709
- /** Parse string to get typed value */
1710
- constructor(e) {
1711
- super(B.extractPatternOptions({
1712
- ...B.DEFAULTS,
1713
- ...e
1714
- }));
1715
- }
1716
- updateOptions(e) {
1717
- super.updateOptions(e);
1718
- }
1719
- _update(e) {
1720
- const {
1721
- mask: t,
1722
- pattern: s,
1723
- blocks: i,
1724
- ...a
1725
- } = {
1726
- ...B.DEFAULTS,
1727
- ...e
1728
- }, n = Object.assign({}, B.GET_DEFAULT_BLOCKS());
1729
- e.min && (n.Y.from = e.min.getFullYear()), e.max && (n.Y.to = e.max.getFullYear()), e.min && e.max && n.Y.from === n.Y.to && (n.m.from = e.min.getMonth() + 1, n.m.to = e.max.getMonth() + 1, n.m.from === n.m.to && (n.d.from = e.min.getDate(), n.d.to = e.max.getDate())), Object.assign(n, this.blocks, i), super._update({
1730
- ...a,
1731
- mask: b(t) ? t : s,
1732
- blocks: n
1733
- });
1734
- }
1735
- doValidate(e) {
1736
- const t = this.date;
1737
- return super.doValidate(e) && (!this.isComplete || this.isDateExist(this.value) && t != null && (this.min == null || this.min <= t) && (this.max == null || t <= this.max));
1738
- }
1739
- /** Checks if date is exists */
1740
- isDateExist(e) {
1741
- return this.format(this.parse(e, this), this).indexOf(e) >= 0;
1742
- }
1743
- /** Parsed Date */
1744
- get date() {
1745
- return this.typedValue;
1746
- }
1747
- set date(e) {
1748
- this.typedValue = e;
1749
- }
1750
- get typedValue() {
1751
- return this.isComplete ? super.typedValue : null;
1752
- }
1753
- set typedValue(e) {
1754
- super.typedValue = e;
1755
- }
1756
- maskEquals(e) {
1757
- return e === Date || super.maskEquals(e);
1758
- }
1759
- optionsIsChanged(e) {
1760
- return super.optionsIsChanged(B.extractPatternOptions(e));
1761
- }
1762
- };
1763
- o(B, "MaskedDate");
1764
- let K = B;
1765
- K.GET_DEFAULT_BLOCKS = () => ({
1766
- d: {
1767
- mask: P,
1768
- from: 1,
1769
- to: 31,
1770
- maxLength: 2
1771
- },
1772
- m: {
1773
- mask: P,
1774
- from: 1,
1775
- to: 12,
1776
- maxLength: 2
1777
- },
1778
- Y: {
1779
- mask: P,
1780
- from: 1900,
1781
- to: 9999
1782
- }
1783
- });
1784
- K.DEFAULTS = {
1785
- ...E.DEFAULTS,
1786
- mask: Date,
1787
- pattern: kt,
1788
- format: /* @__PURE__ */ o((u, e) => {
1789
- if (!u) return "";
1790
- const t = String(u.getDate()).padStart(2, "0"), s = String(u.getMonth() + 1).padStart(2, "0"), i = u.getFullYear();
1791
- return [t, s, i].join(".");
1792
- }, "format"),
1793
- parse: /* @__PURE__ */ o((u, e) => {
1794
- const [t, s, i] = u.split(".").map(Number);
1795
- return new Date(i, s - 1, t);
1796
- }, "parse")
1797
- };
1798
- c.MaskedDate = K;
1799
- const re = class re extends C {
1800
- constructor(e) {
1801
- super({
1802
- ...re.DEFAULTS,
1803
- ...e
1804
- }), this.currentMask = void 0;
1805
- }
1806
- updateOptions(e) {
1807
- super.updateOptions(e);
1808
- }
1809
- _update(e) {
1810
- super._update(e), "mask" in e && (this.exposeMask = void 0, this.compiledMasks = Array.isArray(e.mask) ? e.mask.map((t) => {
1811
- const {
1812
- expose: s,
1813
- ...i
1814
- } = q(t), a = V({
1815
- overwrite: this._overwrite,
1816
- eager: this._eager,
1817
- skipInvalid: this._skipInvalid,
1818
- ...i
1819
- });
1820
- return s && (this.exposeMask = a), a;
1821
- }) : []);
1822
- }
1823
- _appendCharRaw(e, t) {
1824
- t === void 0 && (t = {});
1825
- const s = this._applyDispatch(e, t);
1826
- return this.currentMask && s.aggregate(this.currentMask._appendChar(e, this.currentMaskFlags(t))), s;
1827
- }
1828
- _applyDispatch(e, t, s) {
1829
- e === void 0 && (e = ""), t === void 0 && (t = {}), s === void 0 && (s = "");
1830
- const i = t.tail && t._beforeTailState != null ? t._beforeTailState._value : this.value, a = this.rawInputValue, n = t.tail && t._beforeTailState != null ? t._beforeTailState._rawInputValue : a, r = a.slice(n.length), l = this.currentMask, h = new f(), p = l?.state;
1831
- return this.currentMask = this.doDispatch(e, {
1832
- ...t
1833
- }, s), this.currentMask && (this.currentMask !== l ? (this.currentMask.reset(), n && (this.currentMask.append(n, {
1834
- raw: !0
1835
- }), h.tailShift = this.currentMask.value.length - i.length), r && (h.tailShift += this.currentMask.append(r, {
1836
- raw: !0,
1837
- tail: !0
1838
- }).tailShift)) : p && (this.currentMask.state = p)), h;
1839
- }
1840
- _appendPlaceholder() {
1841
- const e = this._applyDispatch();
1842
- return this.currentMask && e.aggregate(this.currentMask._appendPlaceholder()), e;
1843
- }
1844
- _appendEager() {
1845
- const e = this._applyDispatch();
1846
- return this.currentMask && e.aggregate(this.currentMask._appendEager()), e;
1847
- }
1848
- appendTail(e) {
1849
- const t = new f();
1850
- return e && t.aggregate(this._applyDispatch("", {}, e)), t.aggregate(this.currentMask ? this.currentMask.appendTail(e) : super.appendTail(e));
1851
- }
1852
- currentMaskFlags(e) {
1853
- var t, s;
1854
- return {
1855
- ...e,
1856
- _beforeTailState: ((t = e._beforeTailState) == null ? void 0 : t.currentMaskRef) === this.currentMask && ((s = e._beforeTailState) == null ? void 0 : s.currentMask) || e._beforeTailState
1857
- };
1858
- }
1859
- doDispatch(e, t, s) {
1860
- return t === void 0 && (t = {}), s === void 0 && (s = ""), this.dispatch(e, this, t, s);
1861
- }
1862
- doValidate(e) {
1863
- return super.doValidate(e) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(e)));
1864
- }
1865
- doPrepare(e, t) {
1866
- t === void 0 && (t = {});
1867
- let [s, i] = super.doPrepare(e, t);
1868
- if (this.currentMask) {
1869
- let a;
1870
- [s, a] = super.doPrepare(s, this.currentMaskFlags(t)), i = i.aggregate(a);
1871
- }
1872
- return [s, i];
1873
- }
1874
- doPrepareChar(e, t) {
1875
- t === void 0 && (t = {});
1876
- let [s, i] = super.doPrepareChar(e, t);
1877
- if (this.currentMask) {
1878
- let a;
1879
- [s, a] = super.doPrepareChar(s, this.currentMaskFlags(t)), i = i.aggregate(a);
1880
- }
1881
- return [s, i];
1882
- }
1883
- reset() {
1884
- var e;
1885
- (e = this.currentMask) == null || e.reset(), this.compiledMasks.forEach((t) => t.reset());
1886
- }
1887
- get value() {
1888
- return this.exposeMask ? this.exposeMask.value : this.currentMask ? this.currentMask.value : "";
1889
- }
1890
- set value(e) {
1891
- this.exposeMask ? (this.exposeMask.value = e, this.currentMask = this.exposeMask, this._applyDispatch()) : super.value = e;
1892
- }
1893
- get unmaskedValue() {
1894
- return this.exposeMask ? this.exposeMask.unmaskedValue : this.currentMask ? this.currentMask.unmaskedValue : "";
1895
- }
1896
- set unmaskedValue(e) {
1897
- this.exposeMask ? (this.exposeMask.unmaskedValue = e, this.currentMask = this.exposeMask, this._applyDispatch()) : super.unmaskedValue = e;
1898
- }
1899
- get typedValue() {
1900
- return this.exposeMask ? this.exposeMask.typedValue : this.currentMask ? this.currentMask.typedValue : "";
1901
- }
1902
- set typedValue(e) {
1903
- if (this.exposeMask) {
1904
- this.exposeMask.typedValue = e, this.currentMask = this.exposeMask, this._applyDispatch();
1905
- return;
1906
- }
1907
- let t = String(e);
1908
- this.currentMask && (this.currentMask.typedValue = e, t = this.currentMask.unmaskedValue), this.unmaskedValue = t;
1909
- }
1910
- get displayValue() {
1911
- return this.currentMask ? this.currentMask.displayValue : "";
1912
- }
1913
- get isComplete() {
1914
- var e;
1915
- return !!((e = this.currentMask) != null && e.isComplete);
1916
- }
1917
- get isFilled() {
1918
- var e;
1919
- return !!((e = this.currentMask) != null && e.isFilled);
1920
- }
1921
- remove(e, t) {
1922
- const s = new f();
1923
- return this.currentMask && s.aggregate(this.currentMask.remove(e, t)).aggregate(this._applyDispatch()), s;
1924
- }
1925
- get state() {
1926
- var e;
1927
- return {
1928
- ...super.state,
1929
- _rawInputValue: this.rawInputValue,
1930
- compiledMasks: this.compiledMasks.map((t) => t.state),
1931
- currentMaskRef: this.currentMask,
1932
- currentMask: (e = this.currentMask) == null ? void 0 : e.state
1933
- };
1934
- }
1935
- set state(e) {
1936
- const {
1937
- compiledMasks: t,
1938
- currentMaskRef: s,
1939
- currentMask: i,
1940
- ...a
1941
- } = e;
1942
- t && this.compiledMasks.forEach((n, r) => n.state = t[r]), s != null && (this.currentMask = s, this.currentMask.state = i), super.state = a;
1943
- }
1944
- extractInput(e, t, s) {
1945
- return this.currentMask ? this.currentMask.extractInput(e, t, s) : "";
1946
- }
1947
- extractTail(e, t) {
1948
- return this.currentMask ? this.currentMask.extractTail(e, t) : super.extractTail(e, t);
1949
- }
1950
- doCommit() {
1951
- this.currentMask && this.currentMask.doCommit(), super.doCommit();
1952
- }
1953
- nearestInputPos(e, t) {
1954
- return this.currentMask ? this.currentMask.nearestInputPos(e, t) : super.nearestInputPos(e, t);
1955
- }
1956
- get overwrite() {
1957
- return this.currentMask ? this.currentMask.overwrite : this._overwrite;
1958
- }
1959
- set overwrite(e) {
1960
- this._overwrite = e;
1961
- }
1962
- get eager() {
1963
- return this.currentMask ? this.currentMask.eager : this._eager;
1964
- }
1965
- set eager(e) {
1966
- this._eager = e;
1967
- }
1968
- get skipInvalid() {
1969
- return this.currentMask ? this.currentMask.skipInvalid : this._skipInvalid;
1970
- }
1971
- set skipInvalid(e) {
1972
- this._skipInvalid = e;
1973
- }
1974
- get autofix() {
1975
- return this.currentMask ? this.currentMask.autofix : this._autofix;
1976
- }
1977
- set autofix(e) {
1978
- this._autofix = e;
1979
- }
1980
- maskEquals(e) {
1981
- return Array.isArray(e) ? this.compiledMasks.every((t, s) => {
1982
- if (!e[s]) return;
1983
- const {
1984
- mask: i,
1985
- ...a
1986
- } = e[s];
1987
- return J(t, a) && t.maskEquals(i);
1988
- }) : super.maskEquals(e);
1989
- }
1990
- typedValueEquals(e) {
1991
- var t;
1992
- return !!((t = this.currentMask) != null && t.typedValueEquals(e));
1993
- }
1994
- };
1995
- o(re, "MaskedDynamic");
1996
- let ie = re;
1997
- ie.DEFAULTS = {
1998
- ...C.DEFAULTS,
1999
- dispatch: /* @__PURE__ */ o((u, e, t, s) => {
2000
- if (!e.compiledMasks.length) return;
2001
- const i = e.rawInputValue, a = e.compiledMasks.map((n, r) => {
2002
- const l = e.currentMask === n, h = l ? n.displayValue.length : n.nearestInputPos(n.displayValue.length, d.FORCE_LEFT);
2003
- return n.rawInputValue !== i ? (n.reset(), n.append(i, {
2004
- raw: !0
2005
- })) : l || n.remove(h), n.append(u, e.currentMaskFlags(t)), n.appendTail(s), {
2006
- index: r,
2007
- weight: n.rawInputValue.length,
2008
- totalInputPositions: n.totalInputPositions(0, Math.max(h, n.nearestInputPos(n.displayValue.length, d.FORCE_LEFT)))
2009
- };
2010
- });
2011
- return a.sort((n, r) => r.weight - n.weight || r.totalInputPositions - n.totalInputPositions), e.compiledMasks[a[0].index];
2012
- }, "dispatch")
2013
- };
2014
- c.MaskedDynamic = ie;
2015
- const le = class le extends E {
2016
- constructor(e) {
2017
- super({
2018
- ...le.DEFAULTS,
2019
- ...e
2020
- });
2021
- }
2022
- updateOptions(e) {
2023
- super.updateOptions(e);
2024
- }
2025
- _update(e) {
2026
- const {
2027
- enum: t,
2028
- ...s
2029
- } = e;
2030
- if (t) {
2031
- const i = t.map((r) => r.length), a = Math.min(...i), n = Math.max(...i) - a;
2032
- s.mask = "*".repeat(a), n && (s.mask += "[" + "*".repeat(n) + "]"), this.enum = t;
2033
- }
2034
- super._update(s);
2035
- }
2036
- _appendCharRaw(e, t) {
2037
- t === void 0 && (t = {});
2038
- const s = Math.min(this.nearestInputPos(0, d.FORCE_RIGHT), this.value.length), i = this.enum.filter((a) => this.matchValue(a, this.unmaskedValue + e, s));
2039
- if (i.length) {
2040
- i.length === 1 && this._forEachBlocksInRange(0, this.value.length, (n, r) => {
2041
- const l = i[0][r];
2042
- r >= this.value.length || l === n.value || (n.reset(), n._appendChar(l, t));
2043
- });
2044
- const a = super._appendCharRaw(i[0][this.value.length], t);
2045
- return i.length === 1 && i[0].slice(this.unmaskedValue.length).split("").forEach((n) => a.aggregate(super._appendCharRaw(n))), a;
2046
- }
2047
- return new f({
2048
- skip: !this.isComplete
2049
- });
2050
- }
2051
- extractTail(e, t) {
2052
- return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), new A("", e);
2053
- }
2054
- remove(e, t) {
2055
- if (e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), e === t) return new f();
2056
- const s = Math.min(super.nearestInputPos(0, d.FORCE_RIGHT), this.value.length);
2057
- let i;
2058
- for (i = e; i >= 0 && !(this.enum.filter((r) => this.matchValue(r, this.value.slice(s, i), s)).length > 1); --i)
2059
- ;
2060
- const a = super.remove(i, t);
2061
- return a.tailShift += i - e, a;
2062
- }
2063
- get isComplete() {
2064
- return this.enum.indexOf(this.value) >= 0;
2065
- }
2066
- };
2067
- o(le, "MaskedEnum");
2068
- let ae = le;
2069
- ae.DEFAULTS = {
2070
- ...E.DEFAULTS,
2071
- matchValue: /* @__PURE__ */ o((u, e, t) => u.indexOf(e, t) === t, "matchValue")
2072
- };
2073
- c.MaskedEnum = ae;
2074
- const Re = class Re extends C {
2075
- /** */
2076
- /** Enable characters overwriting */
2077
- /** */
2078
- /** */
2079
- /** */
2080
- updateOptions(e) {
2081
- super.updateOptions(e);
2082
- }
2083
- _update(e) {
2084
- super._update({
2085
- ...e,
2086
- validate: e.mask
2087
- });
2088
- }
2089
- };
2090
- o(Re, "MaskedFunction");
2091
- let Ce = Re;
2092
- c.MaskedFunction = Ce;
2093
- var Ge;
2094
- const F = class F extends C {
2095
- /** Single char */
2096
- /** Single char */
2097
- /** Array of single chars */
2098
- /** */
2099
- /** */
2100
- /** Digits after point */
2101
- /** Flag to remove leading and trailing zeros in the end of editing */
2102
- /** Flag to pad trailing zeros after point in the end of editing */
2103
- /** Enable characters overwriting */
2104
- /** */
2105
- /** */
2106
- /** */
2107
- /** Format typed value to string */
2108
- /** Parse string to get typed value */
2109
- constructor(e) {
2110
- super({
2111
- ...F.DEFAULTS,
2112
- ...e
2113
- });
2114
- }
2115
- updateOptions(e) {
2116
- super.updateOptions(e);
2117
- }
2118
- _update(e) {
2119
- super._update(e), this._updateRegExps();
2120
- }
2121
- _updateRegExps() {
2122
- const e = "^" + (this.allowNegative ? "[+|\\-]?" : ""), t = "\\d*", s = (this.scale ? "(" + fe(this.radix) + "\\d{0," + this.scale + "})?" : "") + "$";
2123
- this._numberRegExp = new RegExp(e + t + s), this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(fe).join("") + "]", "g"), this._thousandsSeparatorRegExp = new RegExp(fe(this.thousandsSeparator), "g");
2124
- }
2125
- _removeThousandsSeparators(e) {
2126
- return e.replace(this._thousandsSeparatorRegExp, "");
2127
- }
2128
- _insertThousandsSeparators(e) {
2129
- const t = e.split(this.radix);
2130
- return t[0] = t[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator), t.join(this.radix);
2131
- }
2132
- doPrepareChar(e, t) {
2133
- t === void 0 && (t = {});
2134
- const [s, i] = super.doPrepareChar(this._removeThousandsSeparators(this.scale && this.mapToRadix.length && /*
2135
- radix should be mapped when
2136
- 1) input is done from keyboard = flags.input && flags.raw
2137
- 2) unmasked value is set = !flags.input && !flags.raw
2138
- and should not be mapped when
2139
- 1) value is set = flags.input && !flags.raw
2140
- 2) raw value is set = !flags.input && flags.raw
2141
- */
2142
- (t.input && t.raw || !t.input && !t.raw) ? e.replace(this._mapToRadixRegExp, this.radix) : e), t);
2143
- return e && !s && (i.skip = !0), s && !this.allowPositive && !this.value && s !== "-" && i.aggregate(this._appendChar("-")), [s, i];
2144
- }
2145
- _separatorsCount(e, t) {
2146
- t === void 0 && (t = !1);
2147
- let s = 0;
2148
- for (let i = 0; i < e; ++i)
2149
- this._value.indexOf(this.thousandsSeparator, i) === i && (++s, t && (e += this.thousandsSeparator.length));
2150
- return s;
2151
- }
2152
- _separatorsCountFromSlice(e) {
2153
- return e === void 0 && (e = this._value), this._separatorsCount(this._removeThousandsSeparators(e).length, !0);
2154
- }
2155
- extractInput(e, t, s) {
2156
- return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), [e, t] = this._adjustRangeWithSeparators(e, t), this._removeThousandsSeparators(super.extractInput(e, t, s));
2157
- }
2158
- _appendCharRaw(e, t) {
2159
- t === void 0 && (t = {});
2160
- const s = t.tail && t._beforeTailState ? t._beforeTailState._value : this._value, i = this._separatorsCountFromSlice(s);
2161
- this._value = this._removeThousandsSeparators(this.value);
2162
- const a = this._value;
2163
- this._value += e;
2164
- const n = this.number;
2165
- let r = !isNaN(n), l = !1;
2166
- if (r) {
2167
- let g;
2168
- this.min != null && this.min < 0 && this.number < this.min && (g = this.min), this.max != null && this.max > 0 && this.number > this.max && (g = this.max), g != null && (this.autofix ? (this._value = this.format(g, this).replace(F.UNMASKED_RADIX, this.radix), l || (l = a === this._value && !t.tail)) : r = !1), r && (r = !!this._value.match(this._numberRegExp));
2169
- }
2170
- let h;
2171
- r ? h = new f({
2172
- inserted: this._value.slice(a.length),
2173
- rawInserted: l ? "" : e,
2174
- skip: l
2175
- }) : (this._value = a, h = new f()), this._value = this._insertThousandsSeparators(this._value);
2176
- const p = t.tail && t._beforeTailState ? t._beforeTailState._value : this._value, k = this._separatorsCountFromSlice(p);
2177
- return h.tailShift += (k - i) * this.thousandsSeparator.length, h;
2178
- }
2179
- _findSeparatorAround(e) {
2180
- if (this.thousandsSeparator) {
2181
- const t = e - this.thousandsSeparator.length + 1, s = this.value.indexOf(this.thousandsSeparator, t);
2182
- if (s <= e) return s;
2183
- }
2184
- return -1;
2185
- }
2186
- _adjustRangeWithSeparators(e, t) {
2187
- const s = this._findSeparatorAround(e);
2188
- s >= 0 && (e = s);
2189
- const i = this._findSeparatorAround(t);
2190
- return i >= 0 && (t = i + this.thousandsSeparator.length), [e, t];
2191
- }
2192
- remove(e, t) {
2193
- e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), [e, t] = this._adjustRangeWithSeparators(e, t);
2194
- const s = this.value.slice(0, e), i = this.value.slice(t), a = this._separatorsCount(s.length);
2195
- this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(s + i));
2196
- const n = this._separatorsCountFromSlice(s);
2197
- return new f({
2198
- tailShift: (n - a) * this.thousandsSeparator.length
2199
- });
2200
- }
2201
- nearestInputPos(e, t) {
2202
- if (!this.thousandsSeparator) return e;
2203
- switch (t) {
2204
- case d.NONE:
2205
- case d.LEFT:
2206
- case d.FORCE_LEFT: {
2207
- const s = this._findSeparatorAround(e - 1);
2208
- if (s >= 0) {
2209
- const i = s + this.thousandsSeparator.length;
2210
- if (e < i || this.value.length <= i || t === d.FORCE_LEFT)
2211
- return s;
2212
- }
2213
- break;
2214
- }
2215
- case d.RIGHT:
2216
- case d.FORCE_RIGHT: {
2217
- const s = this._findSeparatorAround(e);
2218
- if (s >= 0)
2219
- return s + this.thousandsSeparator.length;
2220
- }
2221
- }
2222
- return e;
2223
- }
2224
- doCommit() {
2225
- if (this.value) {
2226
- const e = this.number;
2227
- let t = e;
2228
- this.min != null && (t = Math.max(t, this.min)), this.max != null && (t = Math.min(t, this.max)), t !== e && (this.unmaskedValue = this.format(t, this));
2229
- let s = this.value;
2230
- this.normalizeZeros && (s = this._normalizeZeros(s)), this.padFractionalZeros && this.scale > 0 && (s = this._padFractionalZeros(s)), this._value = s;
2231
- }
2232
- super.doCommit();
2233
- }
2234
- _normalizeZeros(e) {
2235
- const t = this._removeThousandsSeparators(e).split(this.radix);
2236
- return t[0] = t[0].replace(/^(\D*)(0*)(\d*)/, (s, i, a, n) => i + n), e.length && !/\d$/.test(t[0]) && (t[0] = t[0] + "0"), t.length > 1 && (t[1] = t[1].replace(/0*$/, ""), t[1].length || (t.length = 1)), this._insertThousandsSeparators(t.join(this.radix));
2237
- }
2238
- _padFractionalZeros(e) {
2239
- if (!e) return e;
2240
- const t = e.split(this.radix);
2241
- return t.length < 2 && t.push(""), t[1] = t[1].padEnd(this.scale, "0"), t.join(this.radix);
2242
- }
2243
- doSkipInvalid(e, t, s) {
2244
- t === void 0 && (t = {});
2245
- const i = this.scale === 0 && e !== this.thousandsSeparator && (e === this.radix || e === F.UNMASKED_RADIX || this.mapToRadix.includes(e));
2246
- return super.doSkipInvalid(e, t, s) && !i;
2247
- }
2248
- get unmaskedValue() {
2249
- return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, F.UNMASKED_RADIX);
2250
- }
2251
- set unmaskedValue(e) {
2252
- super.unmaskedValue = e;
2253
- }
2254
- get typedValue() {
2255
- return this.parse(this.unmaskedValue, this);
2256
- }
2257
- set typedValue(e) {
2258
- this.rawInputValue = this.format(e, this).replace(F.UNMASKED_RADIX, this.radix);
2259
- }
2260
- /** Parsed Number */
2261
- get number() {
2262
- return this.typedValue;
2263
- }
2264
- set number(e) {
2265
- this.typedValue = e;
2266
- }
2267
- get allowNegative() {
2268
- return this.min != null && this.min < 0 || this.max != null && this.max < 0;
2269
- }
2270
- get allowPositive() {
2271
- return this.min != null && this.min > 0 || this.max != null && this.max > 0;
2272
- }
2273
- typedValueEquals(e) {
2274
- return (super.typedValueEquals(e) || F.EMPTY_VALUES.includes(e) && F.EMPTY_VALUES.includes(this.typedValue)) && !(e === 0 && this.value === "");
2275
- }
2276
- };
2277
- o(F, "MaskedNumber");
2278
- let M = F;
2279
- Ge = M;
2280
- M.UNMASKED_RADIX = ".";
2281
- M.EMPTY_VALUES = [...C.EMPTY_VALUES, 0];
2282
- M.DEFAULTS = {
2283
- ...C.DEFAULTS,
2284
- mask: Number,
2285
- radix: ",",
2286
- thousandsSeparator: "",
2287
- mapToRadix: [Ge.UNMASKED_RADIX],
2288
- min: Number.MIN_SAFE_INTEGER,
2289
- max: Number.MAX_SAFE_INTEGER,
2290
- scale: 2,
2291
- normalizeZeros: !0,
2292
- padFractionalZeros: !1,
2293
- parse: Number,
2294
- format: /* @__PURE__ */ o((u) => u.toLocaleString("en-US", {
2295
- useGrouping: !1,
2296
- maximumFractionDigits: 20
2297
- }), "format")
2298
- };
2299
- c.MaskedNumber = M;
2300
- const Ee = {
2301
- MASKED: "value",
2302
- UNMASKED: "unmaskedValue",
2303
- TYPED: "typedValue"
2304
- };
2305
- function Ze(u, e, t) {
2306
- e === void 0 && (e = Ee.MASKED), t === void 0 && (t = Ee.MASKED);
2307
- const s = V(u);
2308
- return (i) => s.runIsolated((a) => (a[e] = i, a[t]));
2309
- }
2310
- o(Ze, "createPipe");
2311
- function gt(u, e, t, s) {
2312
- return Ze(e, t, s)(u);
2313
- }
2314
- o(gt, "pipe");
2315
- c.PIPE_TYPE = Ee;
2316
- c.createPipe = Ze;
2317
- c.pipe = gt;
2318
- const Oe = class Oe extends E {
2319
- get repeatFrom() {
2320
- var e;
2321
- return (e = Array.isArray(this.repeat) ? this.repeat[0] : this.repeat === 1 / 0 ? 0 : this.repeat) != null ? e : 0;
2322
- }
2323
- get repeatTo() {
2324
- var e;
2325
- return (e = Array.isArray(this.repeat) ? this.repeat[1] : this.repeat) != null ? e : 1 / 0;
2326
- }
2327
- constructor(e) {
2328
- super(e);
2329
- }
2330
- updateOptions(e) {
2331
- super.updateOptions(e);
2332
- }
2333
- _update(e) {
2334
- var t, s, i;
2335
- const {
2336
- repeat: a,
2337
- ...n
2338
- } = q(e);
2339
- this._blockOpts = Object.assign({}, this._blockOpts, n);
2340
- const r = V(this._blockOpts);
2341
- this.repeat = (t = (s = a ?? r.repeat) != null ? s : this.repeat) != null ? t : 1 / 0, super._update({
2342
- mask: "m".repeat(Math.max(this.repeatTo === 1 / 0 && ((i = this._blocks) == null ? void 0 : i.length) || 0, this.repeatFrom)),
2343
- blocks: {
2344
- m: r
2345
- },
2346
- eager: r.eager,
2347
- overwrite: r.overwrite,
2348
- skipInvalid: r.skipInvalid,
2349
- lazy: r.lazy,
2350
- placeholderChar: r.placeholderChar,
2351
- displayChar: r.displayChar
2352
- });
2353
- }
2354
- _allocateBlock(e) {
2355
- if (e < this._blocks.length) return this._blocks[e];
2356
- if (this.repeatTo === 1 / 0 || this._blocks.length < this.repeatTo)
2357
- return this._blocks.push(V(this._blockOpts)), this.mask += "m", this._blocks[this._blocks.length - 1];
2358
- }
2359
- _appendCharRaw(e, t) {
2360
- t === void 0 && (t = {});
2361
- const s = new f();
2362
- for (
2363
- let l = (i = (a = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : a.index) != null ? i : Math.max(this._blocks.length - 1, 0), h, p;
2364
- // try to get a block or
2365
- // try to allocate a new block if not allocated already
2366
- h = (n = this._blocks[l]) != null ? n : p = !p && this._allocateBlock(l);
2367
- ++l
2368
- ) {
2369
- var i, a, n, r;
2370
- const k = h._appendChar(e, {
2371
- ...t,
2372
- _beforeTailState: (r = t._beforeTailState) == null || (r = r._blocks) == null ? void 0 : r[l]
2373
- });
2374
- if (k.skip && p) {
2375
- this._blocks.pop(), this.mask = this.mask.slice(1);
2376
- break;
2377
- }
2378
- if (s.aggregate(k), k.consumed) break;
2379
- }
2380
- return s;
2381
- }
2382
- _trimEmptyTail(e, t) {
2383
- var s, i;
2384
- e === void 0 && (e = 0);
2385
- const a = Math.max(((s = this._mapPosToBlock(e)) == null ? void 0 : s.index) || 0, this.repeatFrom, 0);
2386
- let n;
2387
- t != null && (n = (i = this._mapPosToBlock(t)) == null ? void 0 : i.index), n == null && (n = this._blocks.length - 1);
2388
- let r = 0;
2389
- for (let l = n; a <= l && !this._blocks[l].unmaskedValue; --l, ++r)
2390
- ;
2391
- r && (this._blocks.splice(n - r + 1, r), this.mask = this.mask.slice(r));
2392
- }
2393
- reset() {
2394
- super.reset(), this._trimEmptyTail();
2395
- }
2396
- remove(e, t) {
2397
- e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length);
2398
- const s = super.remove(e, t);
2399
- return this._trimEmptyTail(e, t), s;
2400
- }
2401
- totalInputPositions(e, t) {
2402
- return e === void 0 && (e = 0), t == null && this.repeatTo === 1 / 0 ? 1 / 0 : super.totalInputPositions(e, t);
2403
- }
2404
- get state() {
2405
- return super.state;
2406
- }
2407
- set state(e) {
2408
- this._blocks.length = e._blocks.length, this.mask = this.mask.slice(0, this._blocks.length), super.state = e;
2409
- }
2410
- };
2411
- o(Oe, "RepeatBlock");
2412
- let Ae = Oe;
2413
- c.RepeatBlock = Ae;
2414
- try {
2415
- globalThis.IMask = c;
2416
- } catch {
2417
- }
2418
- var vt = {
2419
- // common
2420
- mask: void 0,
2421
- prepare: Function,
2422
- prepareChar: Function,
2423
- validate: Function,
2424
- commit: Function,
2425
- overwrite: {
2426
- type: Boolean,
2427
- required: !1,
2428
- default: void 0
2429
- },
2430
- eager: {
2431
- required: !1,
2432
- default: void 0,
2433
- validator: /* @__PURE__ */ o((u) => ["append", "remove"].includes(u) || typeof u == "boolean", "validator")
2434
- },
2435
- skipInvalid: {
2436
- type: Boolean,
2437
- required: !1,
2438
- default: void 0
2439
- },
2440
- // pattern
2441
- placeholderChar: String,
2442
- displayChar: String,
2443
- lazy: {
2444
- type: Boolean,
2445
- required: !1,
2446
- default: void 0
2447
- },
2448
- definitions: Object,
2449
- blocks: Object,
2450
- // enum
2451
- enum: Array,
2452
- // range
2453
- maxLength: Number,
2454
- from: Number,
2455
- to: Number,
2456
- // date
2457
- pattern: String,
2458
- format: Function,
2459
- parse: Function,
2460
- autofix: {
2461
- required: !1,
2462
- default: void 0,
2463
- validator: /* @__PURE__ */ o((u) => u === "pad" || typeof u == "boolean", "validator")
2464
- },
2465
- // number
2466
- radix: String,
2467
- thousandsSeparator: String,
2468
- mapToRadix: Array,
2469
- scale: Number,
2470
- normalizeZeros: {
2471
- type: Boolean,
2472
- required: !1,
2473
- default: void 0
2474
- },
2475
- padFractionalZeros: {
2476
- type: Boolean,
2477
- required: !1,
2478
- default: void 0
2479
- },
2480
- min: [Number, Date],
2481
- max: [Number, Date],
2482
- // dynamic
2483
- dispatch: Function
2484
- };
2485
- function _t(u, e) {
2486
- let {
2487
- emit: t,
2488
- onAccept: s,
2489
- onComplete: i,
2490
- defaultValue: a,
2491
- defaultUnmaskedValue: n,
2492
- defaultTypedValue: r
2493
- } = e === void 0 ? {} : e;
2494
- const l = tt(u) ? u : R(u), h = R(), p = R(), k = R(""), g = R(""), m = R();
2495
- let _, T = k.value, w = g.value, oe = m.value;
2496
- function Le() {
2497
- oe = m.value = p.value.typedValue, w = g.value = p.value.unmaskedValue, T = k.value = p.value.value;
2498
- }
2499
- o(Le, "storeLastAcceptedValues");
2500
- function H(v) {
2501
- Le(), t && (t("accept", k.value, v), t("accept:masked", k.value, v), t("accept:typed", m.value, v), t("accept:unmasked", g.value, v)), s?.(v);
2502
- }
2503
- o(H, "_onAccept");
2504
- function Xe(v) {
2505
- t && (t("complete", p.value.value, v), t("complete:masked", p.value.value, v), t("complete:typed", p.value.typedValue, v), t("complete:unmasked", p.value.unmaskedValue, v)), i?.(v);
2506
- }
2507
- o(Xe, "_onComplete");
2508
- const Ne = /* @__PURE__ */ o(() => {
2509
- !p.value || g.value === void 0 || (w !== g.value && (p.value.unmaskedValue = g.value, p.value.unmaskedValue !== g.value && H()), w = void 0);
2510
- }, "updateUnmaskedValue");
2511
- x(g, Ne);
2512
- const Pe = /* @__PURE__ */ o(() => {
2513
- !p.value || k.value === void 0 || (T !== k.value && (p.value.value = k.value, p.value.value !== k.value && H()), T = void 0);
2514
- }, "updateMaskedValue");
2515
- x(k, Pe);
2516
- const $e = /* @__PURE__ */ o(() => {
2517
- !p.value || m.value === void 0 || (oe !== m.value && (p.value.typedValue = m.value, p.value.masked.typedValueEquals(m.value) || H()), oe = void 0);
2518
- }, "updateTypedValue");
2519
- x(m, $e);
2520
- function Ue() {
2521
- _ = h.value;
2522
- const v = l.value;
2523
- !_ || !(v != null && v.mask) || (p.value = c(_, v), a !== void 0 && (k.value = a), n !== void 0 && (g.value = n), r !== void 0 && (m.value = r), Ne(), Pe(), $e(), Le(), p.value.on("accept", H).on("complete", Xe));
2524
- }
2525
- o(Ue, "_initMask");
2526
- function Ye() {
2527
- var v;
2528
- (v = p.value) == null || v.destroy(), p.value = void 0;
2529
- }
2530
- return o(Ye, "_destroyMask"), st(Ue), it(Ye), x([h, l], () => {
2531
- const v = h.value, he = l.value;
2532
- (!(he != null && he.mask) || v !== _) && Ye(), v && (p.value ? p.value.updateOptions(he) : Ue());
2533
- }), {
2534
- el: h,
2535
- mask: at(p),
2536
- masked: k,
2537
- unmasked: g,
2538
- typed: m
2539
- };
2540
- }
2541
- o(_t, "useIMask");
2542
- function Ct(u, e) {
2543
- return u = {
2544
- ...u
2545
- }, Object.keys(u).forEach((t) => {
2546
- (u[t] === void 0 || e.includes(t)) && delete u[t];
2547
- }), u;
2548
- }
2549
- o(Ct, "extractOptionsFromProps");
2550
- const Et = ["typed", "unmasked", "value", "modelValue"];
2551
- var At = nt({
2552
- name: "imask-input",
2553
- inheritAttrs: !1,
2554
- props: {
2555
- // plugin
2556
- modelValue: String,
2557
- value: String,
2558
- unmasked: String,
2559
- typed: {
2560
- validator: /* @__PURE__ */ o(() => !0, "validator")
2561
- },
2562
- ...vt
2563
- },
2564
- emits: ["update:modelValue", "update:masked", "update:value", "update:unmasked", "update:typed", "accept", "accept:value", "accept:masked", "accept:unmasked", "accept:typed", "complete", "complete:value", "complete:masked", "complete:unmasked", "complete:typed"],
2565
- setup(u, e) {
2566
- let {
2567
- attrs: t,
2568
- emit: s
2569
- } = e;
2570
- const {
2571
- el: i,
2572
- mask: a,
2573
- masked: n,
2574
- unmasked: r,
2575
- typed: l
2576
- } = _t(Ct(u, Et), {
2577
- emit: s,
2578
- onAccept: /* @__PURE__ */ o((m) => {
2579
- const _ = n.value;
2580
- s("accept:value", _, m), s("update:value", _, m), s("update:masked", _, m), s("update:modelValue", _, m), s("update:unmasked", r.value, m), s("update:typed", l.value, m);
2581
- }, "onAccept"),
2582
- onComplete: /* @__PURE__ */ o((m) => {
2583
- s("complete:value", n.value, m);
2584
- }, "onComplete")
2585
- }), h = G(u, "value"), p = G(u, "modelValue"), k = G(u, "unmasked"), g = G(u, "typed");
2586
- return n.value = p.value || h.value || "", r.value = k.value || "", l.value = g.value, x(h, (m) => n.value = m), x(p, (m) => n.value = m), x(k, (m) => r.value = m), x(g, (m) => l.value = m), () => {
2587
- const m = {
2588
- ...t,
2589
- value: u.value != null ? u.value : u.modelValue != null ? u.modelValue : a.value ? a.value.displayValue : "",
2590
- ref: i
2591
- };
2592
- return u.mask || (m.onInput = (_) => {
2593
- s("update:modelValue", _.target.value), s("update:value", _.target.value);
2594
- }), ut("input", m);
2595
- };
2596
- }
2597
- }), Ft = At;
2598
- function yt(u, e) {
2599
- return S(), O("svg", {
2600
- xmlns: "http://www.w3.org/2000/svg",
2601
- viewBox: "0 0 24 24",
2602
- fill: "currentColor",
2603
- "aria-hidden": "true",
2604
- "data-slot": "icon"
2605
- }, [
2606
- W("path", {
2607
- "fill-rule": "evenodd",
2608
- d: "M8.603 3.799A4.49 4.49 0 0 1 12 2.25c1.357 0 2.573.6 3.397 1.549a4.49 4.49 0 0 1 3.498 1.307 4.491 4.491 0 0 1 1.307 3.497A4.49 4.49 0 0 1 21.75 12a4.49 4.49 0 0 1-1.549 3.397 4.491 4.491 0 0 1-1.307 3.497 4.491 4.491 0 0 1-3.497 1.307A4.49 4.49 0 0 1 12 21.75a4.49 4.49 0 0 1-3.397-1.549 4.49 4.49 0 0 1-3.498-1.306 4.491 4.491 0 0 1-1.307-3.498A4.49 4.49 0 0 1 2.25 12c0-1.357.6-2.573 1.549-3.397a4.49 4.49 0 0 1 1.307-3.497 4.49 4.49 0 0 1 3.497-1.307Zm7.007 6.387a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",
2609
- "clip-rule": "evenodd"
2610
- })
2611
- ]);
2612
- }
2613
- o(yt, "render$2");
2614
- function St(u, e) {
2615
- return S(), O("svg", {
2616
- xmlns: "http://www.w3.org/2000/svg",
2617
- viewBox: "0 0 24 24",
2618
- fill: "currentColor",
2619
- "aria-hidden": "true",
2620
- "data-slot": "icon"
2621
- }, [
2622
- W("path", {
2623
- "fill-rule": "evenodd",
2624
- d: "M7.502 6h7.128A3.375 3.375 0 0 1 18 9.375v9.375a3 3 0 0 0 3-3V6.108c0-1.505-1.125-2.811-2.664-2.94a48.972 48.972 0 0 0-.673-.05A3 3 0 0 0 15 1.5h-1.5a3 3 0 0 0-2.663 1.618c-.225.015-.45.032-.673.05C8.662 3.295 7.554 4.542 7.502 6ZM13.5 3A1.5 1.5 0 0 0 12 4.5h4.5A1.5 1.5 0 0 0 15 3h-1.5Z",
2625
- "clip-rule": "evenodd"
2626
- }),
2627
- W("path", {
2628
- "fill-rule": "evenodd",
2629
- d: "M3 9.375C3 8.339 3.84 7.5 4.875 7.5h9.75c1.036 0 1.875.84 1.875 1.875v11.25c0 1.035-.84 1.875-1.875 1.875h-9.75A1.875 1.875 0 0 1 3 20.625V9.375ZM6 12a.75.75 0 0 1 .75-.75h.008a.75.75 0 0 1 .75.75v.008a.75.75 0 0 1-.75.75H6.75a.75.75 0 0 1-.75-.75V12Zm2.25 0a.75.75 0 0 1 .75-.75h3.75a.75.75 0 0 1 0 1.5H9a.75.75 0 0 1-.75-.75ZM6 15a.75.75 0 0 1 .75-.75h.008a.75.75 0 0 1 .75.75v.008a.75.75 0 0 1-.75.75H6.75a.75.75 0 0 1-.75-.75V15Zm2.25 0a.75.75 0 0 1 .75-.75h3.75a.75.75 0 0 1 0 1.5H9a.75.75 0 0 1-.75-.75ZM6 18a.75.75 0 0 1 .75-.75h.008a.75.75 0 0 1 .75.75v.008a.75.75 0 0 1-.75.75H6.75a.75.75 0 0 1-.75-.75V18Zm2.25 0a.75.75 0 0 1 .75-.75h3.75a.75.75 0 0 1 0 1.5H9a.75.75 0 0 1-.75-.75Z",
2630
- "clip-rule": "evenodd"
2631
- })
2632
- ]);
2633
- }
2634
- o(St, "render$1");
2635
- var Vt = Object.defineProperty, Bt = Object.getOwnPropertyDescriptor, I = /* @__PURE__ */ o((u, e, t, s) => {
2636
- for (var i = s > 1 ? void 0 : s ? Bt(e, t) : e, a = u.length - 1, n; a >= 0; a--)
2637
- (n = u[a]) && (i = (s ? n(e, t, i) : n(i)) || i);
2638
- return s && i && Vt(e, t, i), i;
2639
- }, "__decorateClass"), $;
2640
- let y = ($ = class extends et {
2641
- maskPreset = null;
2642
- force12hours = !1;
2643
- alwaysCopyIcon = !1;
2644
- disabled = !1;
2645
- dtPresetLocale = "";
2646
- emitsParent = ["input", "change", "focus", "blur", "update:modelValue", "dateMaskChange", "keypress.enter", "reset"];
2647
- componentsParent = { IMaskComponent: Ft, ClipboardDocumentListIcon: St, CheckBadgeIcon: yt, NoSymbolIcon: pt };
2648
- mask = null;
2649
- maskBlocks = {};
2650
- utc = "UTC";
2651
- placeholder = "Введите текст";
2652
- onAccept(e) {
2653
- const t = this.getFromMask(this.mask, e, "MM"), s = this.getFromMask(this.mask, e, "YYYY"), i = this.getFromMask(this.mask, e, "DD");
2654
- let a = this.getFromMask(this.mask, e, "hh");
2655
- const n = this.getFromMask(this.mask, e, "mm"), r = this.getFromMask(this.mask, e, "ss"), l = this.is12hours ? e.toLowerCase().includes("am") ? "am" : "pm" : "";
2656
- this.$emit("dateMaskChange", {
2657
- month: t,
2658
- year: s,
2659
- day: i,
2660
- hour: a,
2661
- minute: n,
2662
- seconds: r,
2663
- AmPm: l
2664
- });
2665
- }
2666
- onCompleteTyped(e) {
2667
- }
2668
- is12hours = !1;
2669
- _randKey = "";
2670
- createdParent() {
2671
- if (this._randKey = $VST.generateRandomKey(), !this.is12hours && this.isDateTime)
2672
- try {
2673
- const e = new Intl.DateTimeFormat(
2674
- this.dtPresetLocale || this.VST.$r.locale,
2675
- { hour: "numeric" }
2676
- ).resolvedOptions();
2677
- this.is12hours = e.hourCycle === "h11" || e.hourCycle === "h12";
2678
- } catch {
2679
- this.is12hours = !1;
2680
- }
2681
- else this.force12hours && (this.is12hours = !0);
2682
- }
2683
- beforeMountParent() {
2684
- let e = this.modelValue || this.inputValue || "";
2685
- if (typeof e != "string" && (e = ""), this.value = e, this.isDateTime) {
2686
- const t = new Intl.DateTimeFormat(this.dtPresetLocale || this.VST.$r.locale, {
2687
- year: "numeric",
2688
- month: "2-digit",
2689
- day: "2-digit",
2690
- hour: this.maskPreset == "datetime" || this.maskPreset == "datetimeSec" ? "2-digit" : void 0,
2691
- minute: this.maskPreset == "datetime" || this.maskPreset == "datetimeSec" ? "2-digit" : void 0,
2692
- second: this.maskPreset == "datetimeSec" ? "2-digit" : void 0,
2693
- timeZoneName: "longOffset"
2694
- }).formatToParts(new Date($VST.DT().epochMilliseconds));
2695
- if (this.mask = t.map((s) => {
2696
- switch (s.type) {
2697
- case "year":
2698
- return "YYYY";
2699
- case "month":
2700
- return "MM";
2701
- case "day":
2702
- return "DD";
2703
- case "hour":
2704
- return "hh";
2705
- case "second":
2706
- return "ss";
2707
- case "minute":
2708
- return "mm";
2709
- case "literal":
2710
- return s.value;
2711
- case "timeZoneName":
2712
- return this.utc = s.value, "";
2713
- default:
2714
- return "";
2715
- }
2716
- }).join(""), this.is12hours && this.maskPreset !== "date")
2717
- this.mask += "!";
2718
- else if (this.maskPreset === "date") {
2719
- const s = this._extractDateOnly(this.mask);
2720
- s && (this.mask = s);
2721
- }
2722
- this.mask = this.mask.replace(/\s+/g, " "), this.maskBlocks = {
2723
- YYYY: {
2724
- mask: c.MaskedRange,
2725
- from: 1e3,
2726
- to: 2300,
2727
- validate: /* @__PURE__ */ o((s, i) => this.dateMaskValidateWithReplaceDays(i), "validate"),
2728
- overwrite: !0
2729
- },
2730
- MM: {
2731
- mask: c.MaskedRange,
2732
- from: 1,
2733
- to: 12,
2734
- validate: /* @__PURE__ */ o((s, i) => this.dateMaskValidateWithReplaceDays(i), "validate"),
2735
- overwrite: !0
2736
- },
2737
- DD: {
2738
- mask: c.MaskedRange,
2739
- from: 1,
2740
- to: 31,
2741
- validate: /* @__PURE__ */ o((s, i) => this.dateMaskValidateWithReplaceDays(i), "validate"),
2742
- overwrite: !0
2743
- },
2744
- // todo определять 12 часовой формат
2745
- hh: {
2746
- mask: c.MaskedRange,
2747
- from: this.is12hours ? 1 : 0,
2748
- to: this.is12hours ? 12 : 23,
2749
- overwrite: !0
2750
- },
2751
- mm: {
2752
- mask: c.MaskedRange,
2753
- from: 0,
2754
- to: 59,
2755
- overwrite: !0
2756
- },
2757
- ss: {
2758
- mask: c.MaskedRange,
2759
- from: 0,
2760
- to: 59,
2761
- overwrite: !0
2762
- },
2763
- "!": {
2764
- mask: c.MaskedEnum,
2765
- enum: ["AM", "PM", "am", "pm"],
2766
- overwrite: !0
2767
- }
2768
- };
2769
- }
2770
- }
2771
- mountedParent() {
2772
- this.$refs.selectInput.$el.addEventListener("focus", this._onFocus), this.$refs.selectInput.$el.addEventListener("blur", this._onBlur), this.isDateTime || this.$refs.selectInput.$el.addEventListener("input", this._onInput);
2773
- }
2774
- beforeUnmountParent() {
2775
- this.$refs.selectInput.$el.removeEventListener("focus", this._onFocus), this.$refs.selectInput.$el.removeEventListener("blur", this._onBlur), this.isDateTime || this.$refs.selectInput.$el.removeEventListener("input", this._onInput);
2776
- }
2777
- focus(e = 0, t = 0) {
2778
- const s = this.$el.querySelector("input.inputMask");
2779
- s?.focus?.(), s?.setSelectionRange?.(
2780
- e,
2781
- t > e ? t || e : t
2782
- );
2783
- }
2784
- blur() {
2785
- this.$el.querySelector("input.inputMask")?.blur?.();
2786
- }
2787
- _onReset() {
2788
- this.$emit("reset"), this._onInput("", !0);
2789
- }
2790
- _onFocus() {
2791
- this.$emit("focus");
2792
- }
2793
- _onBlur() {
2794
- this.nextTick(() => this.$emit("blur", this.$refs.selectInput?.$el?.value));
2795
- }
2796
- _onInput(e, t = !1) {
2797
- const s = e?.target?.value?.trim?.() || e;
2798
- typeof s == "string" && (this.$emit("input", this.value = s, t), this.$emit("change", this.value, t), this.$emit("update:modelValue", this.value));
2799
- }
2800
- _extractDateOnly(e) {
2801
- const t = /([\d\w]{2,4}[./_-][\d\w]{2,4}[./_-][\d\w]{2,4})/, s = e.match(t);
2802
- return s ? s?.[0] ?? null : null;
2803
- }
2804
- getFromMask(e, t, s = "MM") {
2805
- const i = e.indexOf(s);
2806
- if (i === -1)
2807
- return 0;
2808
- const a = t.slice(i, i + s.length), n = parseInt(a, 10);
2809
- return isNaN(n) ? 0 : n;
2810
- }
2811
- setValue(e) {
2812
- this.$refs?.selectInput?.maskRef && (this.$refs.selectInput.maskRef.unmaskedValue = e), super.setValue(e);
2813
- }
2814
- _prepareIMask(e) {
2815
- if (this.isDateTime)
2816
- return e.toUpperCase();
2817
- }
2818
- replaceInMask(e, t, s, i = "MM") {
2819
- const a = e.indexOf(i);
2820
- if (a === -1) return t;
2821
- const n = s.toString().padStart(2, "0");
2822
- return t.slice(0, a) + n + t.slice(a + i.length);
2823
- }
2824
- /**
2825
- * Автоматическая корректировка дней дат по маске DT
2826
- * @param masked
2827
- */
2828
- dateMaskValidateWithReplaceDays(e) {
2829
- const t = this.getFromMask(e.parent.mask, e.parent.displayValue, "MM"), s = this.getFromMask(e.parent.mask, e.parent.displayValue, "YYYY"), i = this.getFromMask(e.parent.mask, e.parent.displayValue, "DD");
2830
- let a = i;
2831
- return t && (t == 2 && (!s || s && s % 4 == 0) ? a = 29 : t == 2 && s && s.toString().length == 4 && s % 4 != 0 ? a = 28 : [1, 3, 5, 7, 8, 10, 12].includes(t) ? a = 31 : a = 30, a < i && this.nextTick(() => {
2832
- this.$refs.selectInput.$el.value = this.replaceInMask(
2833
- e.parent.mask,
2834
- e.parent.displayValue,
2835
- a.toString(),
2836
- "DD"
2837
- ), this.$refs.selectInput.$el.blur(), this.nextTick(() => {
2838
- this.$refs.selectInput.$el.focus();
2839
- });
2840
- })), !0;
2841
- }
2842
- _isOnlyValueCopied = !1;
2843
- _copyValueToClipboard() {
2844
- this.value && $VST.copyToClipboard(this.value), this._isOnlyValueCopied = !0, setTimeout(() => this._isOnlyValueCopied = !1, 500);
2845
- }
2846
- _valueComputed() {
2847
- return ["date", "datetime", "datetimeSec"].includes(this.maskPreset ?? "");
2848
- }
2849
- }, o($, "StringField"), $);
2850
- I([
2851
- j(String)
2852
- ], y.prototype, "maskPreset", 2);
2853
- I([
2854
- j(Boolean)
2855
- ], y.prototype, "force12hours", 2);
2856
- I([
2857
- j(Boolean)
2858
- ], y.prototype, "alwaysCopyIcon", 2);
2859
- I([
2860
- j(Boolean)
2861
- ], y.prototype, "disabled", 2);
2862
- I([
2863
- j(String)
2864
- ], y.prototype, "dtPresetLocale", 2);
2865
- I([
2866
- j(String)
2867
- ], y.prototype, "placeholder", 2);
2868
- I([
2869
- Je("isDateTime")
2870
- ], y.prototype, "_valueComputed", 1);
2871
- y = I([
2872
- Qe
2873
- ], y);
2874
- const xt = { class: "relative w100%" }, bt = {
2875
- key: 0,
2876
- class: "w22px h22px text-stone absolute t-13px l-12px z4 cursor-pointer hover:scale-130"
2877
- };
2878
- function It(u, e, t, s, i, a) {
2879
- const n = Z("IMaskComponent"), r = Z("ClipboardDocumentListIcon"), l = Z("CheckBadgeIcon"), h = Z("NoSymbolIcon");
2880
- return S(), O("div", {
2881
- class: de(["d-inline-block my2px w100% relative", {
2882
- ["sf" + u._randKey]: !0
2883
- }])
2884
- }, [
2885
- W("div", xt, [
2886
- je(n, {
2887
- class: de(["w100% inputMask", {
2888
- "hover:bg-white": !u.disabled,
2889
- "user-select-none!": u.disabled
2890
- }]),
2891
- value: u.value,
2892
- mask: u.mask,
2893
- radix: ",",
2894
- placeholder: u.placeholder,
2895
- ref: "selectInput",
2896
- lazy: !1,
2897
- overwrite: !0,
2898
- blocks: u.maskBlocks,
2899
- autocomplete: u.maskPreset == "email" ? "email" : "off",
2900
- onsubmit: "return false;",
2901
- autocorrect: "off",
2902
- autocapitalize: "off",
2903
- onAccept: u.onAccept,
2904
- "onComplete:typed": u.onCompleteTyped,
2905
- disabled: u.disabled,
2906
- prepare: u._prepareIMask,
2907
- onKeypress: e[0] || (e[0] = rt((p) => u.$emit("keypress.enter"), ["enter"]))
2908
- }, null, 8, ["value", "mask", "placeholder", "blocks", "autocomplete", "onAccept", "onComplete:typed", "class", "disabled", "prepare"]),
2909
- u.maskPreset == "datetime" || u.maskPreset == "datetimeSec" ? (S(), O("div", {
2910
- key: 0,
2911
- class: "absolute! r-15px! t-2 fs-0.7rem text-stone-500 hover:scale-110 hover:fw-bold",
2912
- style: lt({
2913
- pointerEvents: u.disabled ? "none !important" : void 0
2914
- })
2915
- }, ce(u.utc), 5)) : X("", !0)
2916
- ]),
2917
- u.disabled || u.alwaysCopyIcon ? (S(), O("div", bt, [
2918
- u._isOnlyValueCopied ? (S(), pe(l, {
2919
- key: 1,
2920
- class: "text-emerald-500"
2921
- })) : (S(), pe(r, {
2922
- key: 0,
2923
- onClick: e[1] || (e[1] = (p) => u._copyValueToClipboard())
2924
- }))
2925
- ])) : X("", !0),
2926
- !u.disabled && u.value ? (S(), O("div", {
2927
- key: 1,
2928
- class: de(["w25px h25px text-stone absolute r-12px z4 cursor-pointer hover:scale-130", {
2929
- "t-15px": u.maskPreset == "datetime" || u.maskPreset == "datetimeSec",
2930
- "t-9px": u.maskPreset != "datetime" && u.maskPreset != "datetimeSec"
2931
- }])
2932
- }, [
2933
- je(h, {
2934
- onClick: e[2] || (e[2] = (p) => u._onReset())
2935
- })
2936
- ], 2)) : X("", !0),
2937
- u.disabled || u.alwaysCopyIcon ? (S(), pe(ot("style"), { key: 2 }, {
2938
- default: ht(() => [
2939
- dt(".sf" + ce(u._randKey) + "[" + ce(u.$options.__scopeId) + "] input { padding-left: 40px !important; }", 1)
2940
- ]),
2941
- _: 1
2942
- })) : X("", !0)
2943
- ], 2);
2944
- }
2945
- o(It, "render");
2946
- const Lt = /* @__PURE__ */ ct(y, [["render", It], ["__scopeId", "data-v-bd33d684"]]);
2947
- export {
2948
- Lt as default
2949
- };