@phila/phila-ui-core 1.0.21 → 1.0.25-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 (49) hide show
  1. package/README.md +79 -0
  2. package/dist/components.css +1 -0
  3. package/dist/components.d.ts +129 -0
  4. package/dist/components.js +1 -0
  5. package/dist/components.mjs +111 -0
  6. package/dist/composables.d.ts +27 -0
  7. package/dist/composables.js +1 -0
  8. package/dist/composables.mjs +5 -0
  9. package/dist/index-BoaHzp_d.js +5 -0
  10. package/dist/index-C8jyC31H.mjs +1724 -0
  11. package/dist/index.d.ts +37 -0
  12. package/dist/index.js +1 -0
  13. package/dist/index.mjs +4 -0
  14. package/dist/styles/template-blue.css +40 -0
  15. package/dist/styles/template-orange.css +40 -0
  16. package/dist/styles/variables.css +14 -0
  17. package/dist/utils.d.ts +37 -0
  18. package/dist/utils.js +1 -0
  19. package/dist/utils.mjs +6 -0
  20. package/package.json +58 -35
  21. package/LICENSE +0 -21
  22. package/dist/images/phila-small-logo.svg +0 -10
  23. package/dist/phila-ui-core.js +0 -2741
  24. package/dist/phila-ui-core.umd.cjs +0 -1
  25. package/dist/styles/scss/all.scss +0 -34
  26. package/dist/styles/scss/base.scss +0 -53
  27. package/dist/styles/scss/buttons.scss +0 -239
  28. package/dist/styles/scss/colors.scss +0 -72
  29. package/dist/styles/scss/content.scss +0 -103
  30. package/dist/styles/scss/deprecated/all.scss +0 -6
  31. package/dist/styles/scss/deprecated/buttons.scss +0 -135
  32. package/dist/styles/scss/deprecated/content-padding.scss +0 -3
  33. package/dist/styles/scss/deprecated/headings.scss +0 -112
  34. package/dist/styles/scss/deprecated/links.scss +0 -32
  35. package/dist/styles/scss/deprecated/table.scss +0 -15
  36. package/dist/styles/scss/deprecated/tabs.scss +0 -14
  37. package/dist/styles/scss/derived-colors.scss +0 -14
  38. package/dist/styles/scss/fonts.scss +0 -71
  39. package/dist/styles/scss/functions.scss +0 -57
  40. package/dist/styles/scss/headings.scss +0 -10
  41. package/dist/styles/scss/helpers.scss +0 -4
  42. package/dist/styles/scss/inputs.scss +0 -350
  43. package/dist/styles/scss/mixins.scss +0 -220
  44. package/dist/styles/scss/table.scss +0 -10
  45. package/dist/styles/scss/textbox-inputs.scss +0 -29
  46. package/dist/styles/scss/variables.scss +0 -86
  47. package/dist/styles/scss/vendors/vendors.scss +0 -1
  48. package/dist/styles/scss/vendors/vue-good-table.scss +0 -15
  49. package/dist/types.d.ts +0 -105
@@ -1,2741 +0,0 @@
1
- import { reactive as ut, computed as M, watch as A, onMounted as nt, ref as V, onBeforeMount as ft, isRef as kt, onUnmounted as mt, readonly as gt, defineComponent as _t, toRef as R, h as vt } from "vue";
2
- const D = ut({
3
- isMobile: !1,
4
- isTablet: !1,
5
- isDesktop: !1,
6
- isWideScreen: !1
7
- }), Et = (u) => {
8
- D.isMobile = u.matchMedia("(max-width: 767px)").matches, D.isTablet = u.matchMedia("(min-width: 768px) and (max-width: 1023px)").matches, D.isDesktop = u.matchMedia("(min-width: 1024px)").matches, D.isWideScreen = u.matchMedia("(min-width: 1152px)").matches;
9
- }, Ct = () => Math.random().toString(36).substring(2, 9), At = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10
- __proto__: null,
11
- randomID: Ct
12
- }, Symbol.toStringTag, { value: "Module" })), Ft = (u, t) => {
13
- const e = M(() => t.errors instanceof Array ? t.errors[0] : t.errors), s = () => {
14
- var l;
15
- e.value && t.id && ((l = u == null ? void 0 : u.parent) == null || l.emit("hasError", {
16
- [t.id]: e.value != ""
17
- }));
18
- }, i = M(() => {
19
- const l = [], o = {};
20
- let d = "";
21
- const f = t.options;
22
- return Object.keys(t.options).forEach((m) => {
23
- f && (Array.isArray(f[m]) ? (d = "array", l.push(f[m])) : (d = "object", Object.assign(o, f[m])));
24
- }), d === "array" ? l : o;
25
- }), a = (l) => typeof l == "object" ? l[t.textKey] : l, n = (l, o) => {
26
- const { optgroup: d, valueKey: f } = t;
27
- let { options: m } = t;
28
- return d && (m = i.value), Array.isArray(m) ? typeof l == "object" ? l[f] : l : o;
29
- }, r = M(() => {
30
- const l = [];
31
- return u != null && u.attrs.required && l.push("is-required"), e.value && l.push("has-error"), u != null && u.props.innerLabel && l.push("inner-label"), u != null && u.props.forceInputBoxSize && l.push("input-width"), l.join(" ");
32
- });
33
- return A(e, () => {
34
- s();
35
- }), nt(() => {
36
- s();
37
- }), {
38
- error: e,
39
- classes: r,
40
- hasError: s,
41
- optionText: a,
42
- optionValue: n
43
- };
44
- }, xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
45
- __proto__: null,
46
- useInputComposable: Ft
47
- }, Symbol.toStringTag, { value: "Module" })), yt = (u, t) => {
48
- const e = M(() => {
49
- const a = [];
50
- return t.isLoading && a.push("is-loading"), t.icon && a.push("has-icons-right"), a.join(" ");
51
- }), s = M(() => {
52
- let a = t.placeholder;
53
- return !a && (t.innerLabel == !0 || t.innerLabel == null) && (a = "Insert placeholder here"), a;
54
- });
55
- return {
56
- inputModifierClasses: e,
57
- defaultPlaceholder: s,
58
- onInput: (a) => {
59
- u("update:modelValue", a.target.value), u("input", a);
60
- }
61
- };
62
- }, St = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
63
- __proto__: null,
64
- useTextboxComposable: yt
65
- }, Symbol.toStringTag, { value: "Module" })), Bt = (u, t) => {
66
- const e = V(""), s = ut({
67
- mask: String,
68
- lazy: !1
69
- });
70
- return A(
71
- () => u == null ? void 0 : u.props.modelValue,
72
- (l) => {
73
- e.value = l;
74
- }
75
- ), ft(() => {
76
- e.value = u == null ? void 0 : u.props.modelValue;
77
- }), {
78
- localValue: e,
79
- mask: s,
80
- acceptEvent: (l) => {
81
- const o = l.detail;
82
- t("update:modelValue", o._value), t("input", o._value), t("unmasked-input", o._unmaskedValue);
83
- },
84
- completeEvent: (l) => {
85
- const o = l.detail;
86
- t("update:modelValue", o._value), t("complete", o._value);
87
- },
88
- onFocus: () => {
89
- e.value || (s.lazy = !1);
90
- },
91
- onBlur: (l) => {
92
- var o;
93
- (o = l.target.maskRef) != null && o._unmaskedValue || (s.lazy = !0);
94
- }
95
- };
96
- }, Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
97
- __proto__: null,
98
- useMaskedInputComposable: Bt
99
- }, Symbol.toStringTag, { value: "Module" }));
100
- function S(u) {
101
- return typeof u == "string" || u instanceof String;
102
- }
103
- function tt(u) {
104
- var t;
105
- return typeof u == "object" && u != null && (u == null || (t = u.constructor) == null ? void 0 : t.name) === "Object";
106
- }
107
- function rt(u, t) {
108
- return Array.isArray(t) ? rt(u, (e, s) => t.includes(s)) : Object.entries(u).reduce((e, s) => {
109
- let [i, a] = s;
110
- return t(a, i) && (e[i] = a), e;
111
- }, {});
112
- }
113
- const h = {
114
- NONE: "NONE",
115
- LEFT: "LEFT",
116
- FORCE_LEFT: "FORCE_LEFT",
117
- RIGHT: "RIGHT",
118
- FORCE_RIGHT: "FORCE_RIGHT"
119
- };
120
- function bt(u) {
121
- switch (u) {
122
- case h.LEFT:
123
- return h.FORCE_LEFT;
124
- case h.RIGHT:
125
- return h.FORCE_RIGHT;
126
- default:
127
- return u;
128
- }
129
- }
130
- function G(u) {
131
- return u.replace(/([.*+?^=!:${}()|[\]/\\])/g, "\\$1");
132
- }
133
- function L(u, t) {
134
- if (t === u)
135
- return !0;
136
- const e = Array.isArray(t), s = Array.isArray(u);
137
- let i;
138
- if (e && s) {
139
- if (t.length != u.length)
140
- return !1;
141
- for (i = 0; i < t.length; i++)
142
- if (!L(t[i], u[i]))
143
- return !1;
144
- return !0;
145
- }
146
- if (e != s)
147
- return !1;
148
- if (t && u && typeof t == "object" && typeof u == "object") {
149
- const a = t instanceof Date, n = u instanceof Date;
150
- if (a && n)
151
- return t.getTime() == u.getTime();
152
- if (a != n)
153
- return !1;
154
- const r = t instanceof RegExp, l = u instanceof RegExp;
155
- if (r && l)
156
- return t.toString() == u.toString();
157
- if (r != l)
158
- return !1;
159
- const o = Object.keys(t);
160
- for (i = 0; i < o.length; i++)
161
- if (!Object.prototype.hasOwnProperty.call(u, o[i]))
162
- return !1;
163
- for (i = 0; i < o.length; i++)
164
- if (!L(u[o[i]], t[o[i]]))
165
- return !1;
166
- return !0;
167
- } else if (t && u && typeof t == "function" && typeof u == "function")
168
- return t.toString() === u.toString();
169
- return !1;
170
- }
171
- class It {
172
- /** Current input value */
173
- /** Current cursor position */
174
- /** Old input value */
175
- /** Old selection */
176
- constructor(t) {
177
- for (Object.assign(this, t); this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos); )
178
- --this.oldSelection.start;
179
- if (this.insertedCount)
180
- for (; this.value.slice(this.cursorPos) !== this.oldValue.slice(this.oldSelection.end); )
181
- this.value.length - this.cursorPos < this.oldValue.length - this.oldSelection.end ? ++this.oldSelection.end : ++this.cursorPos;
182
- }
183
- /** Start changing position */
184
- get startChangePos() {
185
- return Math.min(this.cursorPos, this.oldSelection.start);
186
- }
187
- /** Inserted symbols count */
188
- get insertedCount() {
189
- return this.cursorPos - this.startChangePos;
190
- }
191
- /** Inserted symbols */
192
- get inserted() {
193
- return this.value.substr(this.startChangePos, this.insertedCount);
194
- }
195
- /** Removed symbols count */
196
- get removedCount() {
197
- return Math.max(this.oldSelection.end - this.startChangePos || // for Delete
198
- this.oldValue.length - this.value.length, 0);
199
- }
200
- /** Removed symbols */
201
- get removed() {
202
- return this.oldValue.substr(this.startChangePos, this.removedCount);
203
- }
204
- /** Unchanged head symbols */
205
- get head() {
206
- return this.value.substring(0, this.startChangePos);
207
- }
208
- /** Unchanged tail symbols */
209
- get tail() {
210
- return this.value.substring(this.startChangePos + this.insertedCount);
211
- }
212
- /** Remove direction */
213
- get removeDirection() {
214
- return !this.removedCount || this.insertedCount ? h.NONE : (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) && // if not range removed (event with backspace)
215
- this.oldSelection.end === this.oldSelection.start ? h.RIGHT : h.LEFT;
216
- }
217
- }
218
- function p(u, t) {
219
- return new p.InputMask(u, t);
220
- }
221
- function lt(u) {
222
- if (u == null)
223
- throw new Error("mask property should be defined");
224
- return u instanceof RegExp ? p.MaskedRegExp : S(u) ? p.MaskedPattern : u === Date ? p.MaskedDate : u === Number ? p.MaskedNumber : Array.isArray(u) || u === Array ? p.MaskedDynamic : p.Masked && u.prototype instanceof p.Masked ? u : p.Masked && u instanceof p.Masked ? u.constructor : u instanceof Function ? p.MaskedFunction : (console.warn("Mask not found for mask", u), p.Masked);
225
- }
226
- function w(u) {
227
- if (!u)
228
- throw new Error("Options in not defined");
229
- if (p.Masked) {
230
- if (u.prototype instanceof p.Masked)
231
- return {
232
- mask: u
233
- };
234
- const {
235
- mask: t = void 0,
236
- ...e
237
- } = u instanceof p.Masked ? {
238
- mask: u
239
- } : tt(u) && u.mask instanceof p.Masked ? u : {};
240
- if (t) {
241
- const s = t.mask;
242
- return {
243
- ...rt(t, (i, a) => !a.startsWith("_")),
244
- mask: t.constructor,
245
- _mask: s,
246
- ...e
247
- };
248
- }
249
- }
250
- return tt(u) ? {
251
- ...u
252
- } : {
253
- mask: u
254
- };
255
- }
256
- function y(u) {
257
- if (p.Masked && u instanceof p.Masked)
258
- return u;
259
- const t = w(u), e = lt(t.mask);
260
- if (!e)
261
- throw new Error("Masked class is not found for provided mask " + t.mask + ", appropriate module needs to be imported manually before creating mask.");
262
- return t.mask === e && delete t.mask, t._mask && (t.mask = t._mask, delete t._mask), new e(t);
263
- }
264
- p.createMask = y;
265
- class Y {
266
- /** */
267
- /** */
268
- /** */
269
- /** Safely returns selection start */
270
- get selectionStart() {
271
- let t;
272
- try {
273
- t = this._unsafeSelectionStart;
274
- } catch {
275
- }
276
- return t ?? this.value.length;
277
- }
278
- /** Safely returns selection end */
279
- get selectionEnd() {
280
- let t;
281
- try {
282
- t = this._unsafeSelectionEnd;
283
- } catch {
284
- }
285
- return t ?? this.value.length;
286
- }
287
- /** Safely sets element selection */
288
- select(t, e) {
289
- if (!(t == null || e == null || t === this.selectionStart && e === this.selectionEnd))
290
- try {
291
- this._unsafeSelect(t, e);
292
- } catch {
293
- }
294
- }
295
- /** */
296
- get isActive() {
297
- return !1;
298
- }
299
- /** */
300
- /** */
301
- /** */
302
- }
303
- p.MaskElement = Y;
304
- const et = 90, Dt = 89;
305
- class U extends Y {
306
- /** HTMLElement to use mask on */
307
- constructor(t) {
308
- super(), this.input = t, this._onKeydown = this._onKeydown.bind(this), this._onInput = this._onInput.bind(this), this._onBeforeinput = this._onBeforeinput.bind(this), this._onCompositionEnd = this._onCompositionEnd.bind(this);
309
- }
310
- get rootElement() {
311
- var t, e, s;
312
- return (t = (e = (s = this.input).getRootNode) == null ? void 0 : e.call(s)) != null ? t : document;
313
- }
314
- /** Is element in focus */
315
- get isActive() {
316
- return this.input === this.rootElement.activeElement;
317
- }
318
- /** Binds HTMLElement events to mask internal events */
319
- bindEvents(t) {
320
- 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", t.drop), this.input.addEventListener("click", t.click), this.input.addEventListener("focus", t.focus), this.input.addEventListener("blur", t.commit), this._handlers = t;
321
- }
322
- _onKeydown(t) {
323
- if (this._handlers.redo && (t.keyCode === et && t.shiftKey && (t.metaKey || t.ctrlKey) || t.keyCode === Dt && t.ctrlKey))
324
- return t.preventDefault(), this._handlers.redo(t);
325
- if (this._handlers.undo && t.keyCode === et && (t.metaKey || t.ctrlKey))
326
- return t.preventDefault(), this._handlers.undo(t);
327
- t.isComposing || this._handlers.selectionChange(t);
328
- }
329
- _onBeforeinput(t) {
330
- if (t.inputType === "historyUndo" && this._handlers.undo)
331
- return t.preventDefault(), this._handlers.undo(t);
332
- if (t.inputType === "historyRedo" && this._handlers.redo)
333
- return t.preventDefault(), this._handlers.redo(t);
334
- }
335
- _onCompositionEnd(t) {
336
- this._handlers.input(t);
337
- }
338
- _onInput(t) {
339
- t.isComposing || this._handlers.input(t);
340
- }
341
- /** Unbinds HTMLElement events to mask internal events */
342
- unbindEvents() {
343
- 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 = {};
344
- }
345
- }
346
- p.HTMLMaskElement = U;
347
- class Mt extends U {
348
- /** InputElement to use mask on */
349
- constructor(t) {
350
- super(t), this.input = t;
351
- }
352
- /** Returns InputElement selection start */
353
- get _unsafeSelectionStart() {
354
- return this.input.selectionStart != null ? this.input.selectionStart : this.value.length;
355
- }
356
- /** Returns InputElement selection end */
357
- get _unsafeSelectionEnd() {
358
- return this.input.selectionEnd;
359
- }
360
- /** Sets InputElement selection */
361
- _unsafeSelect(t, e) {
362
- this.input.setSelectionRange(t, e);
363
- }
364
- get value() {
365
- return this.input.value;
366
- }
367
- set value(t) {
368
- this.input.value = t;
369
- }
370
- }
371
- p.HTMLMaskElement = U;
372
- class ot extends U {
373
- /** Returns HTMLElement selection start */
374
- get _unsafeSelectionStart() {
375
- const t = this.rootElement, e = t.getSelection && t.getSelection(), s = e && e.anchorOffset, i = e && e.focusOffset;
376
- return i == null || s == null || s < i ? s : i;
377
- }
378
- /** Returns HTMLElement selection end */
379
- get _unsafeSelectionEnd() {
380
- const t = this.rootElement, e = t.getSelection && t.getSelection(), s = e && e.anchorOffset, i = e && e.focusOffset;
381
- return i == null || s == null || s > i ? s : i;
382
- }
383
- /** Sets HTMLElement selection */
384
- _unsafeSelect(t, e) {
385
- if (!this.rootElement.createRange)
386
- return;
387
- const s = this.rootElement.createRange();
388
- s.setStart(this.input.firstChild || this.input, t), s.setEnd(this.input.lastChild || this.input, e);
389
- const i = this.rootElement, a = i.getSelection && i.getSelection();
390
- a && (a.removeAllRanges(), a.addRange(s));
391
- }
392
- /** HTMLElement value */
393
- get value() {
394
- return this.input.textContent || "";
395
- }
396
- set value(t) {
397
- this.input.textContent = t;
398
- }
399
- }
400
- p.HTMLContenteditableMaskElement = ot;
401
- class P {
402
- constructor() {
403
- this.states = [], this.currentIndex = 0;
404
- }
405
- get currentState() {
406
- return this.states[this.currentIndex];
407
- }
408
- get isEmpty() {
409
- return this.states.length === 0;
410
- }
411
- push(t) {
412
- this.currentIndex < this.states.length - 1 && (this.states.length = this.currentIndex + 1), this.states.push(t), this.states.length > P.MAX_LENGTH && this.states.shift(), this.currentIndex = this.states.length - 1;
413
- }
414
- go(t) {
415
- return this.currentIndex = Math.min(Math.max(this.currentIndex + t, 0), this.states.length - 1), this.currentState;
416
- }
417
- undo() {
418
- return this.go(-1);
419
- }
420
- redo() {
421
- return this.go(1);
422
- }
423
- clear() {
424
- this.states.length = 0, this.currentIndex = 0;
425
- }
426
- }
427
- P.MAX_LENGTH = 100;
428
- class wt {
429
- /**
430
- View element
431
- */
432
- /** Internal {@link Masked} model */
433
- constructor(t, e) {
434
- this.el = t instanceof Y ? t : t.isContentEditable && t.tagName !== "INPUT" && t.tagName !== "TEXTAREA" ? new ot(t) : new Mt(t), this.masked = y(e), this._listeners = {}, this._value = "", this._unmaskedValue = "", this._rawInputValue = "", this.history = new P(), 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();
435
- }
436
- maskEquals(t) {
437
- var e;
438
- return t == null || ((e = this.masked) == null ? void 0 : e.maskEquals(t));
439
- }
440
- /** Masked */
441
- get mask() {
442
- return this.masked.mask;
443
- }
444
- set mask(t) {
445
- if (this.maskEquals(t))
446
- return;
447
- if (!(t instanceof p.Masked) && this.masked.constructor === lt(t)) {
448
- this.masked.updateOptions({
449
- mask: t
450
- });
451
- return;
452
- }
453
- const e = t instanceof p.Masked ? t : y({
454
- mask: t
455
- });
456
- e.unmaskedValue = this.masked.unmaskedValue, this.masked = e;
457
- }
458
- /** Raw value */
459
- get value() {
460
- return this._value;
461
- }
462
- set value(t) {
463
- this.value !== t && (this.masked.value = t, this.updateControl("auto"));
464
- }
465
- /** Unmasked value */
466
- get unmaskedValue() {
467
- return this._unmaskedValue;
468
- }
469
- set unmaskedValue(t) {
470
- this.unmaskedValue !== t && (this.masked.unmaskedValue = t, this.updateControl("auto"));
471
- }
472
- /** Raw input value */
473
- get rawInputValue() {
474
- return this._rawInputValue;
475
- }
476
- set rawInputValue(t) {
477
- this.rawInputValue !== t && (this.masked.rawInputValue = t, this.updateControl(), this.alignCursor());
478
- }
479
- /** Typed unmasked value */
480
- get typedValue() {
481
- return this.masked.typedValue;
482
- }
483
- set typedValue(t) {
484
- this.masked.typedValueEquals(t) || (this.masked.typedValue = t, this.updateControl("auto"));
485
- }
486
- /** Display value */
487
- get displayValue() {
488
- return this.masked.displayValue;
489
- }
490
- /** Starts listening to element events */
491
- _bindEvents() {
492
- this.el.bindEvents({
493
- selectionChange: this._saveSelection,
494
- input: this._onInput,
495
- drop: this._onDrop,
496
- click: this._onClick,
497
- focus: this._onFocus,
498
- commit: this._onChange,
499
- undo: this._onUndo,
500
- redo: this._onRedo
501
- });
502
- }
503
- /** Stops listening to element events */
504
- _unbindEvents() {
505
- this.el && this.el.unbindEvents();
506
- }
507
- /** Fires custom event */
508
- _fireEvent(t, e) {
509
- const s = this._listeners[t];
510
- s && s.forEach((i) => i(e));
511
- }
512
- /** Current selection start */
513
- get selectionStart() {
514
- return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
515
- }
516
- /** Current cursor position */
517
- get cursorPos() {
518
- return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
519
- }
520
- set cursorPos(t) {
521
- !this.el || !this.el.isActive || (this.el.select(t, t), this._saveSelection());
522
- }
523
- /** Stores current selection */
524
- _saveSelection() {
525
- this.displayValue !== this.el.value && console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."), this._selection = {
526
- start: this.selectionStart,
527
- end: this.cursorPos
528
- };
529
- }
530
- /** Syncronizes model value from view */
531
- updateValue() {
532
- this.masked.value = this.el.value, this._value = this.masked.value, this._unmaskedValue = this.masked.unmaskedValue, this._rawInputValue = this.masked.rawInputValue;
533
- }
534
- /** Syncronizes view from model value, fires change events */
535
- updateControl(t) {
536
- const e = this.masked.unmaskedValue, s = this.masked.value, i = this.masked.rawInputValue, a = this.displayValue, n = this.unmaskedValue !== e || this.value !== s || this._rawInputValue !== i;
537
- this._unmaskedValue = e, this._value = s, this._rawInputValue = i, this.el.value !== a && (this.el.value = a), t === "auto" ? this.alignCursor() : t != null && (this.cursorPos = t), n && this._fireChangeEvents(), !this._historyChanging && (n || this.history.isEmpty) && this.history.push({
538
- unmaskedValue: e,
539
- selection: {
540
- start: this.selectionStart,
541
- end: this.cursorPos
542
- }
543
- });
544
- }
545
- /** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */
546
- updateOptions(t) {
547
- const {
548
- mask: e,
549
- ...s
550
- } = t, i = !this.maskEquals(e), a = this.masked.optionsIsChanged(s);
551
- i && (this.mask = e), a && this.masked.updateOptions(s), (i || a) && this.updateControl();
552
- }
553
- /** Updates cursor */
554
- updateCursor(t) {
555
- t != null && (this.cursorPos = t, this._delayUpdateCursor(t));
556
- }
557
- /** Delays cursor update to support mobile browsers */
558
- _delayUpdateCursor(t) {
559
- this._abortUpdateCursor(), this._changingCursorPos = t, this._cursorChanging = setTimeout(() => {
560
- this.el && (this.cursorPos = this._changingCursorPos, this._abortUpdateCursor());
561
- }, 10);
562
- }
563
- /** Fires custom events */
564
- _fireChangeEvents() {
565
- this._fireEvent("accept", this._inputEvent), this.masked.isComplete && this._fireEvent("complete", this._inputEvent);
566
- }
567
- /** Aborts delayed cursor update */
568
- _abortUpdateCursor() {
569
- this._cursorChanging && (clearTimeout(this._cursorChanging), delete this._cursorChanging);
570
- }
571
- /** Aligns cursor to nearest available position */
572
- alignCursor() {
573
- this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, h.LEFT));
574
- }
575
- /** Aligns cursor only if selection is empty */
576
- alignCursorFriendly() {
577
- this.selectionStart === this.cursorPos && this.alignCursor();
578
- }
579
- /** Adds listener on custom event */
580
- on(t, e) {
581
- return this._listeners[t] || (this._listeners[t] = []), this._listeners[t].push(e), this;
582
- }
583
- /** Removes custom event listener */
584
- off(t, e) {
585
- if (!this._listeners[t])
586
- return this;
587
- if (!e)
588
- return delete this._listeners[t], this;
589
- const s = this._listeners[t].indexOf(e);
590
- return s >= 0 && this._listeners[t].splice(s, 1), this;
591
- }
592
- /** Handles view input event */
593
- _onInput(t) {
594
- this._inputEvent = t, this._abortUpdateCursor();
595
- const e = new It({
596
- // new state
597
- value: this.el.value,
598
- cursorPos: this.cursorPos,
599
- // old state
600
- oldValue: this.displayValue,
601
- oldSelection: this._selection
602
- }), s = this.masked.rawInputValue, i = this.masked.splice(e.startChangePos, e.removed.length, e.inserted, e.removeDirection, {
603
- input: !0,
604
- raw: !0
605
- }).offset, a = s === this.masked.rawInputValue ? e.removeDirection : h.NONE;
606
- let n = this.masked.nearestInputPos(e.startChangePos + i, a);
607
- a !== h.NONE && (n = this.masked.nearestInputPos(n, h.NONE)), this.updateControl(n), delete this._inputEvent;
608
- }
609
- /** Handles view change event and commits model value */
610
- _onChange() {
611
- this.displayValue !== this.el.value && this.updateValue(), this.masked.doCommit(), this.updateControl(), this._saveSelection();
612
- }
613
- /** Handles view drop event, prevents by default */
614
- _onDrop(t) {
615
- t.preventDefault(), t.stopPropagation();
616
- }
617
- /** Restore last selection on focus */
618
- _onFocus(t) {
619
- this.alignCursorFriendly();
620
- }
621
- /** Restore last selection on focus */
622
- _onClick(t) {
623
- this.alignCursorFriendly();
624
- }
625
- _onUndo() {
626
- this._applyHistoryState(this.history.undo());
627
- }
628
- _onRedo() {
629
- this._applyHistoryState(this.history.redo());
630
- }
631
- _applyHistoryState(t) {
632
- t && (this._historyChanging = !0, this.unmaskedValue = t.unmaskedValue, this.el.select(t.selection.start, t.selection.end), this._saveSelection(), this._historyChanging = !1);
633
- }
634
- /** Unbind view events and removes element reference */
635
- destroy() {
636
- this._unbindEvents(), this._listeners.length = 0, delete this.el;
637
- }
638
- }
639
- p.InputMask = wt;
640
- class c {
641
- /** Inserted symbols */
642
- /** Additional offset if any changes occurred before tail */
643
- /** Raw inserted is used by dynamic mask */
644
- /** Can skip chars */
645
- static normalize(t) {
646
- return Array.isArray(t) ? t : [t, new c()];
647
- }
648
- constructor(t) {
649
- Object.assign(this, {
650
- inserted: "",
651
- rawInserted: "",
652
- tailShift: 0,
653
- skip: !1
654
- }, t);
655
- }
656
- /** Aggregate changes */
657
- aggregate(t) {
658
- return this.inserted += t.inserted, this.rawInserted += t.rawInserted, this.tailShift += t.tailShift, this.skip = this.skip || t.skip, this;
659
- }
660
- /** Total offset considering all changes */
661
- get offset() {
662
- return this.tailShift + this.inserted.length;
663
- }
664
- get consumed() {
665
- return !!this.rawInserted || this.skip;
666
- }
667
- equals(t) {
668
- return this.inserted === t.inserted && this.tailShift === t.tailShift && this.rawInserted === t.rawInserted && this.skip === t.skip;
669
- }
670
- }
671
- p.ChangeDetails = c;
672
- class F {
673
- /** Tail value as string */
674
- /** Tail start position */
675
- /** Start position */
676
- constructor(t, e, s) {
677
- t === void 0 && (t = ""), e === void 0 && (e = 0), this.value = t, this.from = e, this.stop = s;
678
- }
679
- toString() {
680
- return this.value;
681
- }
682
- extend(t) {
683
- this.value += String(t);
684
- }
685
- appendTo(t) {
686
- return t.append(this.toString(), {
687
- tail: !0
688
- }).aggregate(t._appendPlaceholder());
689
- }
690
- get state() {
691
- return {
692
- value: this.value,
693
- from: this.from,
694
- stop: this.stop
695
- };
696
- }
697
- set state(t) {
698
- Object.assign(this, t);
699
- }
700
- unshift(t) {
701
- if (!this.value.length || t != null && this.from >= t)
702
- return "";
703
- const e = this.value[0];
704
- return this.value = this.value.slice(1), e;
705
- }
706
- shift() {
707
- if (!this.value.length)
708
- return "";
709
- const t = this.value[this.value.length - 1];
710
- return this.value = this.value.slice(0, -1), t;
711
- }
712
- }
713
- class _ {
714
- /** */
715
- /** */
716
- /** Transforms value before mask processing */
717
- /** Transforms each char before mask processing */
718
- /** Validates if value is acceptable */
719
- /** Does additional processing at the end of editing */
720
- /** Format typed value to string */
721
- /** Parse string to get typed value */
722
- /** Enable characters overwriting */
723
- /** */
724
- /** */
725
- /** */
726
- /** */
727
- constructor(t) {
728
- this._value = "", this._update({
729
- ..._.DEFAULTS,
730
- ...t
731
- }), this._initialized = !0;
732
- }
733
- /** Sets and applies new options */
734
- updateOptions(t) {
735
- this.optionsIsChanged(t) && this.withValueRefresh(this._update.bind(this, t));
736
- }
737
- /** Sets new options */
738
- _update(t) {
739
- Object.assign(this, t);
740
- }
741
- /** Mask state */
742
- get state() {
743
- return {
744
- _value: this.value,
745
- _rawInputValue: this.rawInputValue
746
- };
747
- }
748
- set state(t) {
749
- this._value = t._value;
750
- }
751
- /** Resets value */
752
- reset() {
753
- this._value = "";
754
- }
755
- get value() {
756
- return this._value;
757
- }
758
- set value(t) {
759
- this.resolve(t, {
760
- input: !0
761
- });
762
- }
763
- /** Resolve new value */
764
- resolve(t, e) {
765
- e === void 0 && (e = {
766
- input: !0
767
- }), this.reset(), this.append(t, e, ""), this.doCommit();
768
- }
769
- get unmaskedValue() {
770
- return this.value;
771
- }
772
- set unmaskedValue(t) {
773
- this.resolve(t, {});
774
- }
775
- get typedValue() {
776
- return this.parse ? this.parse(this.value, this) : this.unmaskedValue;
777
- }
778
- set typedValue(t) {
779
- this.format ? this.value = this.format(t, this) : this.unmaskedValue = String(t);
780
- }
781
- /** Value that includes raw user input */
782
- get rawInputValue() {
783
- return this.extractInput(0, this.displayValue.length, {
784
- raw: !0
785
- });
786
- }
787
- set rawInputValue(t) {
788
- this.resolve(t, {
789
- raw: !0
790
- });
791
- }
792
- get displayValue() {
793
- return this.value;
794
- }
795
- get isComplete() {
796
- return !0;
797
- }
798
- get isFilled() {
799
- return this.isComplete;
800
- }
801
- /** Finds nearest input position in direction */
802
- nearestInputPos(t, e) {
803
- return t;
804
- }
805
- totalInputPositions(t, e) {
806
- return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), Math.min(this.displayValue.length, e - t);
807
- }
808
- /** Extracts value in range considering flags */
809
- extractInput(t, e, s) {
810
- return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), this.displayValue.slice(t, e);
811
- }
812
- /** Extracts tail in range */
813
- extractTail(t, e) {
814
- return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), new F(this.extractInput(t, e), t);
815
- }
816
- /** Appends tail */
817
- appendTail(t) {
818
- return S(t) && (t = new F(String(t))), t.appendTo(this);
819
- }
820
- /** Appends char */
821
- _appendCharRaw(t, e) {
822
- return t ? (this._value += t, new c({
823
- inserted: t,
824
- rawInserted: t
825
- })) : new c();
826
- }
827
- /** Appends char */
828
- _appendChar(t, e, s) {
829
- e === void 0 && (e = {});
830
- const i = this.state;
831
- let a;
832
- if ([t, a] = this.doPrepareChar(t, e), t && (a = a.aggregate(this._appendCharRaw(t, e)), !a.rawInserted && this.autofix === "pad")) {
833
- const n = this.state;
834
- this.state = i;
835
- let r = this.pad(e);
836
- const l = this._appendCharRaw(t, e);
837
- r = r.aggregate(l), l.rawInserted || r.equals(a) ? a = r : this.state = n;
838
- }
839
- if (a.inserted) {
840
- let n, r = this.doValidate(e) !== !1;
841
- if (r && s != null) {
842
- const l = this.state;
843
- if (this.overwrite === !0) {
844
- n = s.state;
845
- for (let d = 0; d < a.rawInserted.length; ++d)
846
- s.unshift(this.displayValue.length - a.tailShift);
847
- }
848
- let o = this.appendTail(s);
849
- if (r = o.rawInserted.length === s.toString().length, !(r && o.inserted) && this.overwrite === "shift") {
850
- this.state = l, n = s.state;
851
- for (let d = 0; d < a.rawInserted.length; ++d)
852
- s.shift();
853
- o = this.appendTail(s), r = o.rawInserted.length === s.toString().length;
854
- }
855
- r && o.inserted && (this.state = l);
856
- }
857
- r || (a = new c(), this.state = i, s && n && (s.state = n));
858
- }
859
- return a;
860
- }
861
- /** Appends optional placeholder at the end */
862
- _appendPlaceholder() {
863
- return new c();
864
- }
865
- /** Appends optional eager placeholder at the end */
866
- _appendEager() {
867
- return new c();
868
- }
869
- /** Appends symbols considering flags */
870
- append(t, e, s) {
871
- if (!S(t))
872
- throw new Error("value should be string");
873
- const i = S(s) ? new F(String(s)) : s;
874
- e != null && e.tail && (e._beforeTailState = this.state);
875
- let a;
876
- [t, a] = this.doPrepare(t, e);
877
- for (let n = 0; n < t.length; ++n) {
878
- const r = this._appendChar(t[n], e, i);
879
- if (!r.rawInserted && !this.doSkipInvalid(t[n], e, i))
880
- break;
881
- a.aggregate(r);
882
- }
883
- return (this.eager === !0 || this.eager === "append") && e != null && e.input && t && a.aggregate(this._appendEager()), i != null && (a.tailShift += this.appendTail(i).tailShift), a;
884
- }
885
- remove(t, e) {
886
- return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), this._value = this.displayValue.slice(0, t) + this.displayValue.slice(e), new c();
887
- }
888
- /** Calls function and reapplies current value */
889
- withValueRefresh(t) {
890
- if (this._refreshing || !this._initialized)
891
- return t();
892
- this._refreshing = !0;
893
- const e = this.rawInputValue, s = this.value, i = t();
894
- return this.rawInputValue = e, this.value && this.value !== s && s.indexOf(this.value) === 0 && (this.append(s.slice(this.displayValue.length), {}, ""), this.doCommit()), delete this._refreshing, i;
895
- }
896
- runIsolated(t) {
897
- if (this._isolated || !this._initialized)
898
- return t(this);
899
- this._isolated = !0;
900
- const e = this.state, s = t(this);
901
- return this.state = e, delete this._isolated, s;
902
- }
903
- doSkipInvalid(t, e, s) {
904
- return !!this.skipInvalid;
905
- }
906
- /** Prepares string before mask processing */
907
- doPrepare(t, e) {
908
- return e === void 0 && (e = {}), c.normalize(this.prepare ? this.prepare(t, this, e) : t);
909
- }
910
- /** Prepares each char before mask processing */
911
- doPrepareChar(t, e) {
912
- return e === void 0 && (e = {}), c.normalize(this.prepareChar ? this.prepareChar(t, this, e) : t);
913
- }
914
- /** Validates if value is acceptable */
915
- doValidate(t) {
916
- return (!this.validate || this.validate(this.value, this, t)) && (!this.parent || this.parent.doValidate(t));
917
- }
918
- /** Does additional processing at the end of editing */
919
- doCommit() {
920
- this.commit && this.commit(this.value, this);
921
- }
922
- splice(t, e, s, i, a) {
923
- s === void 0 && (s = ""), i === void 0 && (i = h.NONE), a === void 0 && (a = {
924
- input: !0
925
- });
926
- const n = t + e, r = this.extractTail(n), l = this.eager === !0 || this.eager === "remove";
927
- let o;
928
- l && (i = bt(i), o = this.extractInput(0, n, {
929
- raw: !0
930
- }));
931
- let d = t;
932
- const f = new c();
933
- if (i !== h.NONE && (d = this.nearestInputPos(t, e > 1 && t !== 0 && !l ? h.NONE : i), f.tailShift = d - t), f.aggregate(this.remove(d)), l && i !== h.NONE && o === this.rawInputValue)
934
- if (i === h.FORCE_LEFT) {
935
- let m;
936
- for (; o === this.rawInputValue && (m = this.displayValue.length); )
937
- f.aggregate(new c({
938
- tailShift: -1
939
- })).aggregate(this.remove(m - 1));
940
- } else
941
- i === h.FORCE_RIGHT && r.unshift();
942
- return f.aggregate(this.append(s, a, r));
943
- }
944
- maskEquals(t) {
945
- return this.mask === t;
946
- }
947
- optionsIsChanged(t) {
948
- return !L(this, t);
949
- }
950
- typedValueEquals(t) {
951
- const e = this.typedValue;
952
- return t === e || _.EMPTY_VALUES.includes(t) && _.EMPTY_VALUES.includes(e) || (this.format ? this.format(t, this) === this.format(this.typedValue, this) : !1);
953
- }
954
- pad(t) {
955
- return new c();
956
- }
957
- }
958
- _.DEFAULTS = {
959
- skipInvalid: !0
960
- };
961
- _.EMPTY_VALUES = [void 0, null, ""];
962
- p.Masked = _;
963
- class b {
964
- /** */
965
- constructor(t, e) {
966
- t === void 0 && (t = []), e === void 0 && (e = 0), this.chunks = t, this.from = e;
967
- }
968
- toString() {
969
- return this.chunks.map(String).join("");
970
- }
971
- extend(t) {
972
- if (!String(t))
973
- return;
974
- t = S(t) ? new F(String(t)) : t;
975
- const e = this.chunks[this.chunks.length - 1], s = e && // if stops are same or tail has no stop
976
- (e.stop === t.stop || t.stop == null) && // if tail chunk goes just after last chunk
977
- t.from === e.from + e.toString().length;
978
- if (t instanceof F)
979
- s ? e.extend(t.toString()) : this.chunks.push(t);
980
- else if (t instanceof b) {
981
- if (t.stop == null) {
982
- let i;
983
- for (; t.chunks.length && t.chunks[0].stop == null; )
984
- i = t.chunks.shift(), i.from += t.from, this.extend(i);
985
- }
986
- t.toString() && (t.stop = t.blockIndex, this.chunks.push(t));
987
- }
988
- }
989
- appendTo(t) {
990
- if (!(t instanceof p.MaskedPattern))
991
- return new F(this.toString()).appendTo(t);
992
- const e = new c();
993
- for (let s = 0; s < this.chunks.length; ++s) {
994
- const i = this.chunks[s], a = t._mapPosToBlock(t.displayValue.length), n = i.stop;
995
- let r;
996
- if (n != null && // if block not found or stop is behind lastBlock
997
- (!a || a.index <= n) && ((i instanceof b || // for continuous block also check if stop is exist
998
- t._stops.indexOf(n) >= 0) && e.aggregate(t._appendPlaceholder(n)), r = i instanceof b && t._blocks[n]), r) {
999
- const l = r.appendTail(i);
1000
- e.aggregate(l);
1001
- const o = i.toString().slice(l.rawInserted.length);
1002
- o && e.aggregate(t.append(o, {
1003
- tail: !0
1004
- }));
1005
- } else
1006
- e.aggregate(t.append(i.toString(), {
1007
- tail: !0
1008
- }));
1009
- }
1010
- return e;
1011
- }
1012
- get state() {
1013
- return {
1014
- chunks: this.chunks.map((t) => t.state),
1015
- from: this.from,
1016
- stop: this.stop,
1017
- blockIndex: this.blockIndex
1018
- };
1019
- }
1020
- set state(t) {
1021
- const {
1022
- chunks: e,
1023
- ...s
1024
- } = t;
1025
- Object.assign(this, s), this.chunks = e.map((i) => {
1026
- const a = "chunks" in i ? new b() : new F();
1027
- return a.state = i, a;
1028
- });
1029
- }
1030
- unshift(t) {
1031
- if (!this.chunks.length || t != null && this.from >= t)
1032
- return "";
1033
- const e = t != null ? t - this.from : t;
1034
- let s = 0;
1035
- for (; s < this.chunks.length; ) {
1036
- const i = this.chunks[s], a = i.unshift(e);
1037
- if (i.toString()) {
1038
- if (!a)
1039
- break;
1040
- ++s;
1041
- } else
1042
- this.chunks.splice(s, 1);
1043
- if (a)
1044
- return a;
1045
- }
1046
- return "";
1047
- }
1048
- shift() {
1049
- if (!this.chunks.length)
1050
- return "";
1051
- let t = this.chunks.length - 1;
1052
- for (; 0 <= t; ) {
1053
- const e = this.chunks[t], s = e.shift();
1054
- if (e.toString()) {
1055
- if (!s)
1056
- break;
1057
- --t;
1058
- } else
1059
- this.chunks.splice(t, 1);
1060
- if (s)
1061
- return s;
1062
- }
1063
- return "";
1064
- }
1065
- }
1066
- class Tt {
1067
- constructor(t, e) {
1068
- this.masked = t, this._log = [];
1069
- const {
1070
- offset: s,
1071
- index: i
1072
- } = t._mapPosToBlock(e) || (e < 0 ? (
1073
- // first
1074
- {
1075
- index: 0,
1076
- offset: 0
1077
- }
1078
- ) : (
1079
- // last
1080
- {
1081
- index: this.masked._blocks.length,
1082
- offset: 0
1083
- }
1084
- ));
1085
- this.offset = s, this.index = i, this.ok = !1;
1086
- }
1087
- get block() {
1088
- return this.masked._blocks[this.index];
1089
- }
1090
- get pos() {
1091
- return this.masked._blockStartPos(this.index) + this.offset;
1092
- }
1093
- get state() {
1094
- return {
1095
- index: this.index,
1096
- offset: this.offset,
1097
- ok: this.ok
1098
- };
1099
- }
1100
- set state(t) {
1101
- Object.assign(this, t);
1102
- }
1103
- pushState() {
1104
- this._log.push(this.state);
1105
- }
1106
- popState() {
1107
- const t = this._log.pop();
1108
- return t && (this.state = t), t;
1109
- }
1110
- bindBlock() {
1111
- 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));
1112
- }
1113
- _pushLeft(t) {
1114
- for (this.pushState(), this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((e = this.block) == null ? void 0 : e.displayValue.length) || 0) {
1115
- var e;
1116
- if (t())
1117
- return this.ok = !0;
1118
- }
1119
- return this.ok = !1;
1120
- }
1121
- _pushRight(t) {
1122
- for (this.pushState(), this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0)
1123
- if (t())
1124
- return this.ok = !0;
1125
- return this.ok = !1;
1126
- }
1127
- pushLeftBeforeFilled() {
1128
- return this._pushLeft(() => {
1129
- if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, h.FORCE_LEFT), this.offset !== 0))
1130
- return !0;
1131
- });
1132
- }
1133
- pushLeftBeforeInput() {
1134
- return this._pushLeft(() => {
1135
- if (!this.block.isFixed)
1136
- return this.offset = this.block.nearestInputPos(this.offset, h.LEFT), !0;
1137
- });
1138
- }
1139
- pushLeftBeforeRequired() {
1140
- return this._pushLeft(() => {
1141
- if (!(this.block.isFixed || this.block.isOptional && !this.block.value))
1142
- return this.offset = this.block.nearestInputPos(this.offset, h.LEFT), !0;
1143
- });
1144
- }
1145
- pushRightBeforeFilled() {
1146
- return this._pushRight(() => {
1147
- if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, h.FORCE_RIGHT), this.offset !== this.block.value.length))
1148
- return !0;
1149
- });
1150
- }
1151
- pushRightBeforeInput() {
1152
- return this._pushRight(() => {
1153
- if (!this.block.isFixed)
1154
- return this.offset = this.block.nearestInputPos(this.offset, h.NONE), !0;
1155
- });
1156
- }
1157
- pushRightBeforeRequired() {
1158
- return this._pushRight(() => {
1159
- if (!(this.block.isFixed || this.block.isOptional && !this.block.value))
1160
- return this.offset = this.block.nearestInputPos(this.offset, h.NONE), !0;
1161
- });
1162
- }
1163
- }
1164
- class ht {
1165
- /** */
1166
- /** */
1167
- /** */
1168
- /** */
1169
- /** */
1170
- /** */
1171
- constructor(t) {
1172
- Object.assign(this, t), this._value = "", this.isFixed = !0;
1173
- }
1174
- get value() {
1175
- return this._value;
1176
- }
1177
- get unmaskedValue() {
1178
- return this.isUnmasking ? this.value : "";
1179
- }
1180
- get rawInputValue() {
1181
- return this._isRawInput ? this.value : "";
1182
- }
1183
- get displayValue() {
1184
- return this.value;
1185
- }
1186
- reset() {
1187
- this._isRawInput = !1, this._value = "";
1188
- }
1189
- remove(t, e) {
1190
- return t === void 0 && (t = 0), e === void 0 && (e = this._value.length), this._value = this._value.slice(0, t) + this._value.slice(e), this._value || (this._isRawInput = !1), new c();
1191
- }
1192
- nearestInputPos(t, e) {
1193
- e === void 0 && (e = h.NONE);
1194
- const s = 0, i = this._value.length;
1195
- switch (e) {
1196
- case h.LEFT:
1197
- case h.FORCE_LEFT:
1198
- return s;
1199
- case h.NONE:
1200
- case h.RIGHT:
1201
- case h.FORCE_RIGHT:
1202
- default:
1203
- return i;
1204
- }
1205
- }
1206
- totalInputPositions(t, e) {
1207
- return t === void 0 && (t = 0), e === void 0 && (e = this._value.length), this._isRawInput ? e - t : 0;
1208
- }
1209
- extractInput(t, e, s) {
1210
- return t === void 0 && (t = 0), e === void 0 && (e = this._value.length), s === void 0 && (s = {}), s.raw && this._isRawInput && this._value.slice(t, e) || "";
1211
- }
1212
- get isComplete() {
1213
- return !0;
1214
- }
1215
- get isFilled() {
1216
- return !!this._value;
1217
- }
1218
- _appendChar(t, e) {
1219
- if (e === void 0 && (e = {}), this.isFilled)
1220
- return new c();
1221
- const s = this.eager === !0 || this.eager === "append", a = this.char === t && (this.isUnmasking || e.input || e.raw) && (!e.raw || !s) && !e.tail, n = new c({
1222
- inserted: this.char,
1223
- rawInserted: a ? this.char : ""
1224
- });
1225
- return this._value = this.char, this._isRawInput = a && (e.raw || e.input), n;
1226
- }
1227
- _appendEager() {
1228
- return this._appendChar(this.char, {
1229
- tail: !0
1230
- });
1231
- }
1232
- _appendPlaceholder() {
1233
- const t = new c();
1234
- return this.isFilled || (this._value = t.inserted = this.char), t;
1235
- }
1236
- extractTail() {
1237
- return new F("");
1238
- }
1239
- appendTail(t) {
1240
- return S(t) && (t = new F(String(t))), t.appendTo(this);
1241
- }
1242
- append(t, e, s) {
1243
- const i = this._appendChar(t[0], e);
1244
- return s != null && (i.tailShift += this.appendTail(s).tailShift), i;
1245
- }
1246
- doCommit() {
1247
- }
1248
- get state() {
1249
- return {
1250
- _value: this._value,
1251
- _rawInputValue: this.rawInputValue
1252
- };
1253
- }
1254
- set state(t) {
1255
- this._value = t._value, this._isRawInput = !!t._rawInputValue;
1256
- }
1257
- pad(t) {
1258
- return this._appendPlaceholder();
1259
- }
1260
- }
1261
- class N {
1262
- /** */
1263
- /** */
1264
- /** */
1265
- /** */
1266
- /** */
1267
- /** */
1268
- /** */
1269
- /** */
1270
- constructor(t) {
1271
- const {
1272
- parent: e,
1273
- isOptional: s,
1274
- placeholderChar: i,
1275
- displayChar: a,
1276
- lazy: n,
1277
- eager: r,
1278
- ...l
1279
- } = t;
1280
- this.masked = y(l), Object.assign(this, {
1281
- parent: e,
1282
- isOptional: s,
1283
- placeholderChar: i,
1284
- displayChar: a,
1285
- lazy: n,
1286
- eager: r
1287
- });
1288
- }
1289
- reset() {
1290
- this.isFilled = !1, this.masked.reset();
1291
- }
1292
- remove(t, e) {
1293
- return t === void 0 && (t = 0), e === void 0 && (e = this.value.length), t === 0 && e >= 1 ? (this.isFilled = !1, this.masked.remove(t, e)) : new c();
1294
- }
1295
- get value() {
1296
- return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : "");
1297
- }
1298
- get unmaskedValue() {
1299
- return this.masked.unmaskedValue;
1300
- }
1301
- get rawInputValue() {
1302
- return this.masked.rawInputValue;
1303
- }
1304
- get displayValue() {
1305
- return this.masked.value && this.displayChar || this.value;
1306
- }
1307
- get isComplete() {
1308
- return !!this.masked.value || this.isOptional;
1309
- }
1310
- _appendChar(t, e) {
1311
- if (e === void 0 && (e = {}), this.isFilled)
1312
- return new c();
1313
- const s = this.masked.state;
1314
- let i = this.masked._appendChar(t, this.currentMaskFlags(e));
1315
- return i.inserted && this.doValidate(e) === !1 && (i = new c(), this.masked.state = s), !i.inserted && !this.isOptional && !this.lazy && !e.input && (i.inserted = this.placeholderChar), i.skip = !i.inserted && !this.isOptional, this.isFilled = !!i.inserted, i;
1316
- }
1317
- append(t, e, s) {
1318
- return this.masked.append(t, this.currentMaskFlags(e), s);
1319
- }
1320
- _appendPlaceholder() {
1321
- return this.isFilled || this.isOptional ? new c() : (this.isFilled = !0, new c({
1322
- inserted: this.placeholderChar
1323
- }));
1324
- }
1325
- _appendEager() {
1326
- return new c();
1327
- }
1328
- extractTail(t, e) {
1329
- return this.masked.extractTail(t, e);
1330
- }
1331
- appendTail(t) {
1332
- return this.masked.appendTail(t);
1333
- }
1334
- extractInput(t, e, s) {
1335
- return t === void 0 && (t = 0), e === void 0 && (e = this.value.length), this.masked.extractInput(t, e, s);
1336
- }
1337
- nearestInputPos(t, e) {
1338
- e === void 0 && (e = h.NONE);
1339
- const s = 0, i = this.value.length, a = Math.min(Math.max(t, s), i);
1340
- switch (e) {
1341
- case h.LEFT:
1342
- case h.FORCE_LEFT:
1343
- return this.isComplete ? a : s;
1344
- case h.RIGHT:
1345
- case h.FORCE_RIGHT:
1346
- return this.isComplete ? a : i;
1347
- case h.NONE:
1348
- default:
1349
- return a;
1350
- }
1351
- }
1352
- totalInputPositions(t, e) {
1353
- return t === void 0 && (t = 0), e === void 0 && (e = this.value.length), this.value.slice(t, e).length;
1354
- }
1355
- doValidate(t) {
1356
- return this.masked.doValidate(this.currentMaskFlags(t)) && (!this.parent || this.parent.doValidate(this.currentMaskFlags(t)));
1357
- }
1358
- doCommit() {
1359
- this.masked.doCommit();
1360
- }
1361
- get state() {
1362
- return {
1363
- _value: this.value,
1364
- _rawInputValue: this.rawInputValue,
1365
- masked: this.masked.state,
1366
- isFilled: this.isFilled
1367
- };
1368
- }
1369
- set state(t) {
1370
- this.masked.state = t.masked, this.isFilled = t.isFilled;
1371
- }
1372
- currentMaskFlags(t) {
1373
- var e;
1374
- return {
1375
- ...t,
1376
- _beforeTailState: (t == null || (e = t._beforeTailState) == null ? void 0 : e.masked) || (t == null ? void 0 : t._beforeTailState)
1377
- };
1378
- }
1379
- pad(t) {
1380
- return new c();
1381
- }
1382
- }
1383
- N.DEFAULT_DEFINITIONS = {
1384
- 0: /\d/,
1385
- 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]/,
1386
- // http://stackoverflow.com/a/22075070
1387
- "*": /./
1388
- };
1389
- class Rt extends _ {
1390
- /** */
1391
- /** Enable characters overwriting */
1392
- /** */
1393
- /** */
1394
- /** */
1395
- updateOptions(t) {
1396
- super.updateOptions(t);
1397
- }
1398
- _update(t) {
1399
- const e = t.mask;
1400
- e && (t.validate = (s) => s.search(e) >= 0), super._update(t);
1401
- }
1402
- }
1403
- p.MaskedRegExp = Rt;
1404
- class v extends _ {
1405
- /** */
1406
- /** */
1407
- /** Single char for empty input */
1408
- /** Single char for filled input */
1409
- /** Show placeholder only when needed */
1410
- /** Enable characters overwriting */
1411
- /** */
1412
- /** */
1413
- /** */
1414
- constructor(t) {
1415
- super({
1416
- ...v.DEFAULTS,
1417
- ...t,
1418
- definitions: Object.assign({}, N.DEFAULT_DEFINITIONS, t == null ? void 0 : t.definitions)
1419
- });
1420
- }
1421
- updateOptions(t) {
1422
- super.updateOptions(t);
1423
- }
1424
- _update(t) {
1425
- t.definitions = Object.assign({}, this.definitions, t.definitions), super._update(t), this._rebuildMask();
1426
- }
1427
- _rebuildMask() {
1428
- const t = this.definitions;
1429
- this._blocks = [], this.exposeBlock = void 0, this._stops = [], this._maskedBlocks = {};
1430
- const e = this.mask;
1431
- if (!e || !t)
1432
- return;
1433
- let s = !1, i = !1;
1434
- for (let a = 0; a < e.length; ++a) {
1435
- if (this.blocks) {
1436
- const o = e.slice(a), d = Object.keys(this.blocks).filter((m) => o.indexOf(m) === 0);
1437
- d.sort((m, k) => k.length - m.length);
1438
- const f = d[0];
1439
- if (f) {
1440
- const {
1441
- expose: m,
1442
- repeat: k,
1443
- ...E
1444
- } = w(this.blocks[f]), I = {
1445
- lazy: this.lazy,
1446
- eager: this.eager,
1447
- placeholderChar: this.placeholderChar,
1448
- displayChar: this.displayChar,
1449
- overwrite: this.overwrite,
1450
- autofix: this.autofix,
1451
- ...E,
1452
- repeat: k,
1453
- parent: this
1454
- }, B = k != null ? new p.RepeatBlock(
1455
- I
1456
- /* TODO */
1457
- ) : y(I);
1458
- B && (this._blocks.push(B), m && (this.exposeBlock = B), this._maskedBlocks[f] || (this._maskedBlocks[f] = []), this._maskedBlocks[f].push(this._blocks.length - 1)), a += f.length - 1;
1459
- continue;
1460
- }
1461
- }
1462
- let n = e[a], r = n in t;
1463
- if (n === v.STOP_CHAR) {
1464
- this._stops.push(this._blocks.length);
1465
- continue;
1466
- }
1467
- if (n === "{" || n === "}") {
1468
- s = !s;
1469
- continue;
1470
- }
1471
- if (n === "[" || n === "]") {
1472
- i = !i;
1473
- continue;
1474
- }
1475
- if (n === v.ESCAPE_CHAR) {
1476
- if (++a, n = e[a], !n)
1477
- break;
1478
- r = !1;
1479
- }
1480
- const l = r ? new N({
1481
- isOptional: i,
1482
- lazy: this.lazy,
1483
- eager: this.eager,
1484
- placeholderChar: this.placeholderChar,
1485
- displayChar: this.displayChar,
1486
- ...w(t[n]),
1487
- parent: this
1488
- }) : new ht({
1489
- char: n,
1490
- eager: this.eager,
1491
- isUnmasking: s
1492
- });
1493
- this._blocks.push(l);
1494
- }
1495
- }
1496
- get state() {
1497
- return {
1498
- ...super.state,
1499
- _blocks: this._blocks.map((t) => t.state)
1500
- };
1501
- }
1502
- set state(t) {
1503
- if (!t) {
1504
- this.reset();
1505
- return;
1506
- }
1507
- const {
1508
- _blocks: e,
1509
- ...s
1510
- } = t;
1511
- this._blocks.forEach((i, a) => i.state = e[a]), super.state = s;
1512
- }
1513
- reset() {
1514
- super.reset(), this._blocks.forEach((t) => t.reset());
1515
- }
1516
- get isComplete() {
1517
- return this.exposeBlock ? this.exposeBlock.isComplete : this._blocks.every((t) => t.isComplete);
1518
- }
1519
- get isFilled() {
1520
- return this._blocks.every((t) => t.isFilled);
1521
- }
1522
- get isFixed() {
1523
- return this._blocks.every((t) => t.isFixed);
1524
- }
1525
- get isOptional() {
1526
- return this._blocks.every((t) => t.isOptional);
1527
- }
1528
- doCommit() {
1529
- this._blocks.forEach((t) => t.doCommit()), super.doCommit();
1530
- }
1531
- get unmaskedValue() {
1532
- return this.exposeBlock ? this.exposeBlock.unmaskedValue : this._blocks.reduce((t, e) => t += e.unmaskedValue, "");
1533
- }
1534
- set unmaskedValue(t) {
1535
- if (this.exposeBlock) {
1536
- const e = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1537
- this.exposeBlock.unmaskedValue = t, this.appendTail(e), this.doCommit();
1538
- } else
1539
- super.unmaskedValue = t;
1540
- }
1541
- get value() {
1542
- return this.exposeBlock ? this.exposeBlock.value : (
1543
- // TODO return _value when not in change?
1544
- this._blocks.reduce((t, e) => t += e.value, "")
1545
- );
1546
- }
1547
- set value(t) {
1548
- if (this.exposeBlock) {
1549
- const e = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1550
- this.exposeBlock.value = t, this.appendTail(e), this.doCommit();
1551
- } else
1552
- super.value = t;
1553
- }
1554
- get typedValue() {
1555
- return this.exposeBlock ? this.exposeBlock.typedValue : super.typedValue;
1556
- }
1557
- set typedValue(t) {
1558
- if (this.exposeBlock) {
1559
- const e = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1560
- this.exposeBlock.typedValue = t, this.appendTail(e), this.doCommit();
1561
- } else
1562
- super.typedValue = t;
1563
- }
1564
- get displayValue() {
1565
- return this._blocks.reduce((t, e) => t += e.displayValue, "");
1566
- }
1567
- appendTail(t) {
1568
- return super.appendTail(t).aggregate(this._appendPlaceholder());
1569
- }
1570
- _appendEager() {
1571
- var t;
1572
- const e = new c();
1573
- let s = (t = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : t.index;
1574
- if (s == null)
1575
- return e;
1576
- this._blocks[s].isFilled && ++s;
1577
- for (let i = s; i < this._blocks.length; ++i) {
1578
- const a = this._blocks[i]._appendEager();
1579
- if (!a.inserted)
1580
- break;
1581
- e.aggregate(a);
1582
- }
1583
- return e;
1584
- }
1585
- _appendCharRaw(t, e) {
1586
- e === void 0 && (e = {});
1587
- const s = this._mapPosToBlock(this.displayValue.length), i = new c();
1588
- if (!s)
1589
- return i;
1590
- for (let n = s.index, r; r = this._blocks[n]; ++n) {
1591
- var a;
1592
- const l = r._appendChar(t, {
1593
- ...e,
1594
- _beforeTailState: (a = e._beforeTailState) == null || (a = a._blocks) == null ? void 0 : a[n]
1595
- });
1596
- if (i.aggregate(l), l.consumed)
1597
- break;
1598
- }
1599
- return i;
1600
- }
1601
- extractTail(t, e) {
1602
- t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
1603
- const s = new b();
1604
- return t === e || this._forEachBlocksInRange(t, e, (i, a, n, r) => {
1605
- const l = i.extractTail(n, r);
1606
- l.stop = this._findStopBefore(a), l.from = this._blockStartPos(a), l instanceof b && (l.blockIndex = a), s.extend(l);
1607
- }), s;
1608
- }
1609
- extractInput(t, e, s) {
1610
- if (t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), s === void 0 && (s = {}), t === e)
1611
- return "";
1612
- let i = "";
1613
- return this._forEachBlocksInRange(t, e, (a, n, r, l) => {
1614
- i += a.extractInput(r, l, s);
1615
- }), i;
1616
- }
1617
- _findStopBefore(t) {
1618
- let e;
1619
- for (let s = 0; s < this._stops.length; ++s) {
1620
- const i = this._stops[s];
1621
- if (i <= t)
1622
- e = i;
1623
- else
1624
- break;
1625
- }
1626
- return e;
1627
- }
1628
- /** Appends placeholder depending on laziness */
1629
- _appendPlaceholder(t) {
1630
- const e = new c();
1631
- if (this.lazy && t == null)
1632
- return e;
1633
- const s = this._mapPosToBlock(this.displayValue.length);
1634
- if (!s)
1635
- return e;
1636
- const i = s.index, a = t ?? this._blocks.length;
1637
- return this._blocks.slice(i, a).forEach((n) => {
1638
- if (!n.lazy || t != null) {
1639
- var r;
1640
- e.aggregate(n._appendPlaceholder((r = n._blocks) == null ? void 0 : r.length));
1641
- }
1642
- }), e;
1643
- }
1644
- /** Finds block in pos */
1645
- _mapPosToBlock(t) {
1646
- let e = "";
1647
- for (let s = 0; s < this._blocks.length; ++s) {
1648
- const i = this._blocks[s], a = e.length;
1649
- if (e += i.displayValue, t <= e.length)
1650
- return {
1651
- index: s,
1652
- offset: t - a
1653
- };
1654
- }
1655
- }
1656
- _blockStartPos(t) {
1657
- return this._blocks.slice(0, t).reduce((e, s) => e += s.displayValue.length, 0);
1658
- }
1659
- _forEachBlocksInRange(t, e, s) {
1660
- e === void 0 && (e = this.displayValue.length);
1661
- const i = this._mapPosToBlock(t);
1662
- if (i) {
1663
- const a = this._mapPosToBlock(e), n = a && i.index === a.index, r = i.offset, l = a && n ? a.offset : this._blocks[i.index].displayValue.length;
1664
- if (s(this._blocks[i.index], i.index, r, l), a && !n) {
1665
- for (let o = i.index + 1; o < a.index; ++o)
1666
- s(this._blocks[o], o, 0, this._blocks[o].displayValue.length);
1667
- s(this._blocks[a.index], a.index, 0, a.offset);
1668
- }
1669
- }
1670
- }
1671
- remove(t, e) {
1672
- t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
1673
- const s = super.remove(t, e);
1674
- return this._forEachBlocksInRange(t, e, (i, a, n, r) => {
1675
- s.aggregate(i.remove(n, r));
1676
- }), s;
1677
- }
1678
- nearestInputPos(t, e) {
1679
- if (e === void 0 && (e = h.NONE), !this._blocks.length)
1680
- return 0;
1681
- const s = new Tt(this, t);
1682
- if (e === h.NONE)
1683
- return s.pushRightBeforeInput() || (s.popState(), s.pushLeftBeforeInput()) ? s.pos : this.displayValue.length;
1684
- if (e === h.LEFT || e === h.FORCE_LEFT) {
1685
- if (e === h.LEFT) {
1686
- if (s.pushRightBeforeFilled(), s.ok && s.pos === t)
1687
- return t;
1688
- s.popState();
1689
- }
1690
- if (s.pushLeftBeforeInput(), s.pushLeftBeforeRequired(), s.pushLeftBeforeFilled(), e === h.LEFT) {
1691
- if (s.pushRightBeforeInput(), s.pushRightBeforeRequired(), s.ok && s.pos <= t || (s.popState(), s.ok && s.pos <= t))
1692
- return s.pos;
1693
- s.popState();
1694
- }
1695
- return s.ok ? s.pos : e === h.FORCE_LEFT ? 0 : (s.popState(), s.ok || (s.popState(), s.ok) ? s.pos : 0);
1696
- }
1697
- return e === h.RIGHT || e === h.FORCE_RIGHT ? (s.pushRightBeforeInput(), s.pushRightBeforeRequired(), s.pushRightBeforeFilled() ? s.pos : e === h.FORCE_RIGHT ? this.displayValue.length : (s.popState(), s.ok || (s.popState(), s.ok) ? s.pos : this.nearestInputPos(t, h.LEFT))) : t;
1698
- }
1699
- totalInputPositions(t, e) {
1700
- t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
1701
- let s = 0;
1702
- return this._forEachBlocksInRange(t, e, (i, a, n, r) => {
1703
- s += i.totalInputPositions(n, r);
1704
- }), s;
1705
- }
1706
- /** Get block by name */
1707
- maskedBlock(t) {
1708
- return this.maskedBlocks(t)[0];
1709
- }
1710
- /** Get all blocks by name */
1711
- maskedBlocks(t) {
1712
- const e = this._maskedBlocks[t];
1713
- return e ? e.map((s) => this._blocks[s]) : [];
1714
- }
1715
- pad(t) {
1716
- const e = new c();
1717
- return this._forEachBlocksInRange(0, this.displayValue.length, (s) => e.aggregate(s.pad(t))), e;
1718
- }
1719
- }
1720
- v.DEFAULTS = {
1721
- ..._.DEFAULTS,
1722
- lazy: !0,
1723
- placeholderChar: "_"
1724
- };
1725
- v.STOP_CHAR = "`";
1726
- v.ESCAPE_CHAR = "\\";
1727
- v.InputDefinition = N;
1728
- v.FixedDefinition = ht;
1729
- p.MaskedPattern = v;
1730
- class O extends v {
1731
- /**
1732
- Optionally sets max length of pattern.
1733
- Used when pattern length is longer then `to` param length. Pads zeros at start in this case.
1734
- */
1735
- /** Min bound */
1736
- /** Max bound */
1737
- get _matchFrom() {
1738
- return this.maxLength - String(this.from).length;
1739
- }
1740
- constructor(t) {
1741
- super(t);
1742
- }
1743
- updateOptions(t) {
1744
- super.updateOptions(t);
1745
- }
1746
- _update(t) {
1747
- const {
1748
- to: e = this.to || 0,
1749
- from: s = this.from || 0,
1750
- maxLength: i = this.maxLength || 0,
1751
- autofix: a = this.autofix,
1752
- ...n
1753
- } = t;
1754
- this.to = e, this.from = s, this.maxLength = Math.max(String(e).length, i), this.autofix = a;
1755
- const r = String(this.from).padStart(this.maxLength, "0"), l = String(this.to).padStart(this.maxLength, "0");
1756
- let o = 0;
1757
- for (; o < l.length && l[o] === r[o]; )
1758
- ++o;
1759
- n.mask = l.slice(0, o).replace(/0/g, "\\0") + "0".repeat(this.maxLength - o), super._update(n);
1760
- }
1761
- get isComplete() {
1762
- return super.isComplete && !!this.value;
1763
- }
1764
- boundaries(t) {
1765
- let e = "", s = "";
1766
- const [, i, a] = t.match(/^(\D*)(\d*)(\D*)/) || [];
1767
- return a && (e = "0".repeat(i.length) + a, s = "9".repeat(i.length) + a), e = e.padEnd(this.maxLength, "0"), s = s.padEnd(this.maxLength, "9"), [e, s];
1768
- }
1769
- doPrepareChar(t, e) {
1770
- e === void 0 && (e = {});
1771
- let s;
1772
- return [t, s] = super.doPrepareChar(t.replace(/\D/g, ""), e), t || (s.skip = !this.isComplete), [t, s];
1773
- }
1774
- _appendCharRaw(t, e) {
1775
- if (e === void 0 && (e = {}), !this.autofix || this.value.length + 1 > this.maxLength)
1776
- return super._appendCharRaw(t, e);
1777
- const s = String(this.from).padStart(this.maxLength, "0"), i = String(this.to).padStart(this.maxLength, "0"), [a, n] = this.boundaries(this.value + t);
1778
- return Number(n) < this.from ? super._appendCharRaw(s[this.value.length], e) : Number(a) > this.to ? !e.tail && this.autofix === "pad" && this.value.length + 1 < this.maxLength ? super._appendCharRaw(s[this.value.length], e).aggregate(this._appendCharRaw(t, e)) : super._appendCharRaw(i[this.value.length], e) : super._appendCharRaw(t, e);
1779
- }
1780
- doValidate(t) {
1781
- const e = this.value;
1782
- if (e.search(/[^0]/) === -1 && e.length <= this._matchFrom)
1783
- return !0;
1784
- const [i, a] = this.boundaries(e);
1785
- return this.from <= Number(a) && Number(i) <= this.to && super.doValidate(t);
1786
- }
1787
- pad(t) {
1788
- const e = new c();
1789
- if (this.value.length === this.maxLength)
1790
- return e;
1791
- const s = this.value, i = this.maxLength - this.value.length;
1792
- if (i) {
1793
- this.reset();
1794
- for (let a = 0; a < i; ++a)
1795
- e.aggregate(super._appendCharRaw("0", t));
1796
- s.split("").forEach((a) => this._appendCharRaw(a));
1797
- }
1798
- return e;
1799
- }
1800
- }
1801
- p.MaskedRange = O;
1802
- const Ot = "d{.}`m{.}`Y";
1803
- class x extends v {
1804
- static extractPatternOptions(t) {
1805
- const {
1806
- mask: e,
1807
- pattern: s,
1808
- ...i
1809
- } = t;
1810
- return {
1811
- ...i,
1812
- mask: S(e) ? e : s
1813
- };
1814
- }
1815
- /** Pattern mask for date according to {@link MaskedDate#format} */
1816
- /** Start date */
1817
- /** End date */
1818
- /** Format typed value to string */
1819
- /** Parse string to get typed value */
1820
- constructor(t) {
1821
- super(x.extractPatternOptions({
1822
- ...x.DEFAULTS,
1823
- ...t
1824
- }));
1825
- }
1826
- updateOptions(t) {
1827
- super.updateOptions(t);
1828
- }
1829
- _update(t) {
1830
- const {
1831
- mask: e,
1832
- pattern: s,
1833
- blocks: i,
1834
- ...a
1835
- } = {
1836
- ...x.DEFAULTS,
1837
- ...t
1838
- }, n = Object.assign({}, x.GET_DEFAULT_BLOCKS());
1839
- t.min && (n.Y.from = t.min.getFullYear()), t.max && (n.Y.to = t.max.getFullYear()), t.min && t.max && n.Y.from === n.Y.to && (n.m.from = t.min.getMonth() + 1, n.m.to = t.max.getMonth() + 1, n.m.from === n.m.to && (n.d.from = t.min.getDate(), n.d.to = t.max.getDate())), Object.assign(n, this.blocks, i), super._update({
1840
- ...a,
1841
- mask: S(e) ? e : s,
1842
- blocks: n
1843
- });
1844
- }
1845
- doValidate(t) {
1846
- const e = this.date;
1847
- return super.doValidate(t) && (!this.isComplete || this.isDateExist(this.value) && e != null && (this.min == null || this.min <= e) && (this.max == null || e <= this.max));
1848
- }
1849
- /** Checks if date is exists */
1850
- isDateExist(t) {
1851
- return this.format(this.parse(t, this), this).indexOf(t) >= 0;
1852
- }
1853
- /** Parsed Date */
1854
- get date() {
1855
- return this.typedValue;
1856
- }
1857
- set date(t) {
1858
- this.typedValue = t;
1859
- }
1860
- get typedValue() {
1861
- return this.isComplete ? super.typedValue : null;
1862
- }
1863
- set typedValue(t) {
1864
- super.typedValue = t;
1865
- }
1866
- maskEquals(t) {
1867
- return t === Date || super.maskEquals(t);
1868
- }
1869
- optionsIsChanged(t) {
1870
- return super.optionsIsChanged(x.extractPatternOptions(t));
1871
- }
1872
- }
1873
- x.GET_DEFAULT_BLOCKS = () => ({
1874
- d: {
1875
- mask: O,
1876
- from: 1,
1877
- to: 31,
1878
- maxLength: 2
1879
- },
1880
- m: {
1881
- mask: O,
1882
- from: 1,
1883
- to: 12,
1884
- maxLength: 2
1885
- },
1886
- Y: {
1887
- mask: O,
1888
- from: 1900,
1889
- to: 9999
1890
- }
1891
- });
1892
- x.DEFAULTS = {
1893
- ...v.DEFAULTS,
1894
- mask: Date,
1895
- pattern: Ot,
1896
- format: (u, t) => {
1897
- if (!u)
1898
- return "";
1899
- const e = String(u.getDate()).padStart(2, "0"), s = String(u.getMonth() + 1).padStart(2, "0"), i = u.getFullYear();
1900
- return [e, s, i].join(".");
1901
- },
1902
- parse: (u, t) => {
1903
- const [e, s, i] = u.split(".").map(Number);
1904
- return new Date(i, s - 1, e);
1905
- }
1906
- };
1907
- p.MaskedDate = x;
1908
- class j extends _ {
1909
- constructor(t) {
1910
- super({
1911
- ...j.DEFAULTS,
1912
- ...t
1913
- }), this.currentMask = void 0;
1914
- }
1915
- updateOptions(t) {
1916
- super.updateOptions(t);
1917
- }
1918
- _update(t) {
1919
- super._update(t), "mask" in t && (this.exposeMask = void 0, this.compiledMasks = Array.isArray(t.mask) ? t.mask.map((e) => {
1920
- const {
1921
- expose: s,
1922
- ...i
1923
- } = w(e), a = y({
1924
- overwrite: this._overwrite,
1925
- eager: this._eager,
1926
- skipInvalid: this._skipInvalid,
1927
- ...i
1928
- });
1929
- return s && (this.exposeMask = a), a;
1930
- }) : []);
1931
- }
1932
- _appendCharRaw(t, e) {
1933
- e === void 0 && (e = {});
1934
- const s = this._applyDispatch(t, e);
1935
- return this.currentMask && s.aggregate(this.currentMask._appendChar(t, this.currentMaskFlags(e))), s;
1936
- }
1937
- _applyDispatch(t, e, s) {
1938
- t === void 0 && (t = ""), e === void 0 && (e = {}), s === void 0 && (s = "");
1939
- const i = e.tail && e._beforeTailState != null ? e._beforeTailState._value : this.value, a = this.rawInputValue, n = e.tail && e._beforeTailState != null ? e._beforeTailState._rawInputValue : a, r = a.slice(n.length), l = this.currentMask, o = new c(), d = l == null ? void 0 : l.state;
1940
- return this.currentMask = this.doDispatch(t, {
1941
- ...e
1942
- }, s), this.currentMask && (this.currentMask !== l ? (this.currentMask.reset(), n && (this.currentMask.append(n, {
1943
- raw: !0
1944
- }), o.tailShift = this.currentMask.value.length - i.length), r && (o.tailShift += this.currentMask.append(r, {
1945
- raw: !0,
1946
- tail: !0
1947
- }).tailShift)) : d && (this.currentMask.state = d)), o;
1948
- }
1949
- _appendPlaceholder() {
1950
- const t = this._applyDispatch();
1951
- return this.currentMask && t.aggregate(this.currentMask._appendPlaceholder()), t;
1952
- }
1953
- _appendEager() {
1954
- const t = this._applyDispatch();
1955
- return this.currentMask && t.aggregate(this.currentMask._appendEager()), t;
1956
- }
1957
- appendTail(t) {
1958
- const e = new c();
1959
- return t && e.aggregate(this._applyDispatch("", {}, t)), e.aggregate(this.currentMask ? this.currentMask.appendTail(t) : super.appendTail(t));
1960
- }
1961
- currentMaskFlags(t) {
1962
- var e, s;
1963
- return {
1964
- ...t,
1965
- _beforeTailState: ((e = t._beforeTailState) == null ? void 0 : e.currentMaskRef) === this.currentMask && ((s = t._beforeTailState) == null ? void 0 : s.currentMask) || t._beforeTailState
1966
- };
1967
- }
1968
- doDispatch(t, e, s) {
1969
- return e === void 0 && (e = {}), s === void 0 && (s = ""), this.dispatch(t, this, e, s);
1970
- }
1971
- doValidate(t) {
1972
- return super.doValidate(t) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(t)));
1973
- }
1974
- doPrepare(t, e) {
1975
- e === void 0 && (e = {});
1976
- let [s, i] = super.doPrepare(t, e);
1977
- if (this.currentMask) {
1978
- let a;
1979
- [s, a] = super.doPrepare(s, this.currentMaskFlags(e)), i = i.aggregate(a);
1980
- }
1981
- return [s, i];
1982
- }
1983
- doPrepareChar(t, e) {
1984
- e === void 0 && (e = {});
1985
- let [s, i] = super.doPrepareChar(t, e);
1986
- if (this.currentMask) {
1987
- let a;
1988
- [s, a] = super.doPrepareChar(s, this.currentMaskFlags(e)), i = i.aggregate(a);
1989
- }
1990
- return [s, i];
1991
- }
1992
- reset() {
1993
- var t;
1994
- (t = this.currentMask) == null || t.reset(), this.compiledMasks.forEach((e) => e.reset());
1995
- }
1996
- get value() {
1997
- return this.exposeMask ? this.exposeMask.value : this.currentMask ? this.currentMask.value : "";
1998
- }
1999
- set value(t) {
2000
- this.exposeMask ? (this.exposeMask.value = t, this.currentMask = this.exposeMask, this._applyDispatch()) : super.value = t;
2001
- }
2002
- get unmaskedValue() {
2003
- return this.exposeMask ? this.exposeMask.unmaskedValue : this.currentMask ? this.currentMask.unmaskedValue : "";
2004
- }
2005
- set unmaskedValue(t) {
2006
- this.exposeMask ? (this.exposeMask.unmaskedValue = t, this.currentMask = this.exposeMask, this._applyDispatch()) : super.unmaskedValue = t;
2007
- }
2008
- get typedValue() {
2009
- return this.exposeMask ? this.exposeMask.typedValue : this.currentMask ? this.currentMask.typedValue : "";
2010
- }
2011
- set typedValue(t) {
2012
- if (this.exposeMask) {
2013
- this.exposeMask.typedValue = t, this.currentMask = this.exposeMask, this._applyDispatch();
2014
- return;
2015
- }
2016
- let e = String(t);
2017
- this.currentMask && (this.currentMask.typedValue = t, e = this.currentMask.unmaskedValue), this.unmaskedValue = e;
2018
- }
2019
- get displayValue() {
2020
- return this.currentMask ? this.currentMask.displayValue : "";
2021
- }
2022
- get isComplete() {
2023
- var t;
2024
- return !!((t = this.currentMask) != null && t.isComplete);
2025
- }
2026
- get isFilled() {
2027
- var t;
2028
- return !!((t = this.currentMask) != null && t.isFilled);
2029
- }
2030
- remove(t, e) {
2031
- const s = new c();
2032
- return this.currentMask && s.aggregate(this.currentMask.remove(t, e)).aggregate(this._applyDispatch()), s;
2033
- }
2034
- get state() {
2035
- var t;
2036
- return {
2037
- ...super.state,
2038
- _rawInputValue: this.rawInputValue,
2039
- compiledMasks: this.compiledMasks.map((e) => e.state),
2040
- currentMaskRef: this.currentMask,
2041
- currentMask: (t = this.currentMask) == null ? void 0 : t.state
2042
- };
2043
- }
2044
- set state(t) {
2045
- const {
2046
- compiledMasks: e,
2047
- currentMaskRef: s,
2048
- currentMask: i,
2049
- ...a
2050
- } = t;
2051
- e && this.compiledMasks.forEach((n, r) => n.state = e[r]), s != null && (this.currentMask = s, this.currentMask.state = i), super.state = a;
2052
- }
2053
- extractInput(t, e, s) {
2054
- return this.currentMask ? this.currentMask.extractInput(t, e, s) : "";
2055
- }
2056
- extractTail(t, e) {
2057
- return this.currentMask ? this.currentMask.extractTail(t, e) : super.extractTail(t, e);
2058
- }
2059
- doCommit() {
2060
- this.currentMask && this.currentMask.doCommit(), super.doCommit();
2061
- }
2062
- nearestInputPos(t, e) {
2063
- return this.currentMask ? this.currentMask.nearestInputPos(t, e) : super.nearestInputPos(t, e);
2064
- }
2065
- get overwrite() {
2066
- return this.currentMask ? this.currentMask.overwrite : this._overwrite;
2067
- }
2068
- set overwrite(t) {
2069
- this._overwrite = t;
2070
- }
2071
- get eager() {
2072
- return this.currentMask ? this.currentMask.eager : this._eager;
2073
- }
2074
- set eager(t) {
2075
- this._eager = t;
2076
- }
2077
- get skipInvalid() {
2078
- return this.currentMask ? this.currentMask.skipInvalid : this._skipInvalid;
2079
- }
2080
- set skipInvalid(t) {
2081
- this._skipInvalid = t;
2082
- }
2083
- get autofix() {
2084
- return this.currentMask ? this.currentMask.autofix : this._autofix;
2085
- }
2086
- set autofix(t) {
2087
- this._autofix = t;
2088
- }
2089
- maskEquals(t) {
2090
- return Array.isArray(t) ? this.compiledMasks.every((e, s) => {
2091
- if (!t[s])
2092
- return;
2093
- const {
2094
- mask: i,
2095
- ...a
2096
- } = t[s];
2097
- return L(e, a) && e.maskEquals(i);
2098
- }) : super.maskEquals(t);
2099
- }
2100
- typedValueEquals(t) {
2101
- var e;
2102
- return !!((e = this.currentMask) != null && e.typedValueEquals(t));
2103
- }
2104
- }
2105
- j.DEFAULTS = {
2106
- ..._.DEFAULTS,
2107
- dispatch: (u, t, e, s) => {
2108
- if (!t.compiledMasks.length)
2109
- return;
2110
- const i = t.rawInputValue, a = t.compiledMasks.map((n, r) => {
2111
- const l = t.currentMask === n, o = l ? n.displayValue.length : n.nearestInputPos(n.displayValue.length, h.FORCE_LEFT);
2112
- return n.rawInputValue !== i ? (n.reset(), n.append(i, {
2113
- raw: !0
2114
- })) : l || n.remove(o), n.append(u, t.currentMaskFlags(e)), n.appendTail(s), {
2115
- index: r,
2116
- weight: n.rawInputValue.length,
2117
- totalInputPositions: n.totalInputPositions(0, Math.max(o, n.nearestInputPos(n.displayValue.length, h.FORCE_LEFT)))
2118
- };
2119
- });
2120
- return a.sort((n, r) => r.weight - n.weight || r.totalInputPositions - n.totalInputPositions), t.compiledMasks[a[0].index];
2121
- }
2122
- };
2123
- p.MaskedDynamic = j;
2124
- class H extends v {
2125
- constructor(t) {
2126
- super({
2127
- ...H.DEFAULTS,
2128
- ...t
2129
- });
2130
- }
2131
- updateOptions(t) {
2132
- super.updateOptions(t);
2133
- }
2134
- _update(t) {
2135
- const {
2136
- enum: e,
2137
- ...s
2138
- } = t;
2139
- if (e) {
2140
- const i = e.map((r) => r.length), a = Math.min(...i), n = Math.max(...i) - a;
2141
- s.mask = "*".repeat(a), n && (s.mask += "[" + "*".repeat(n) + "]"), this.enum = e;
2142
- }
2143
- super._update(s);
2144
- }
2145
- _appendCharRaw(t, e) {
2146
- e === void 0 && (e = {});
2147
- const s = Math.min(this.nearestInputPos(0, h.FORCE_RIGHT), this.value.length), i = this.enum.filter((a) => this.matchValue(a, this.unmaskedValue + t, s));
2148
- if (i.length) {
2149
- i.length === 1 && this._forEachBlocksInRange(0, this.value.length, (n, r) => {
2150
- const l = i[0][r];
2151
- r >= this.value.length || l === n.value || (n.reset(), n._appendChar(l, e));
2152
- });
2153
- const a = super._appendCharRaw(i[0][this.value.length], e);
2154
- return i.length === 1 && i[0].slice(this.unmaskedValue.length).split("").forEach((n) => a.aggregate(super._appendCharRaw(n))), a;
2155
- }
2156
- return new c({
2157
- skip: !this.isComplete
2158
- });
2159
- }
2160
- extractTail(t, e) {
2161
- return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), new F("", t);
2162
- }
2163
- remove(t, e) {
2164
- if (t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), t === e)
2165
- return new c();
2166
- const s = Math.min(super.nearestInputPos(0, h.FORCE_RIGHT), this.value.length);
2167
- let i;
2168
- for (i = t; i >= 0 && !(this.enum.filter((r) => this.matchValue(r, this.value.slice(s, i), s)).length > 1); --i)
2169
- ;
2170
- const a = super.remove(i, e);
2171
- return a.tailShift += i - t, a;
2172
- }
2173
- get isComplete() {
2174
- return this.enum.indexOf(this.value) >= 0;
2175
- }
2176
- }
2177
- H.DEFAULTS = {
2178
- ...v.DEFAULTS,
2179
- matchValue: (u, t, e) => u.indexOf(t, e) === e
2180
- };
2181
- p.MaskedEnum = H;
2182
- class Lt extends _ {
2183
- /** */
2184
- /** Enable characters overwriting */
2185
- /** */
2186
- /** */
2187
- /** */
2188
- updateOptions(t) {
2189
- super.updateOptions(t);
2190
- }
2191
- _update(t) {
2192
- super._update({
2193
- ...t,
2194
- validate: t.mask
2195
- });
2196
- }
2197
- }
2198
- p.MaskedFunction = Lt;
2199
- var dt;
2200
- class C extends _ {
2201
- /** Single char */
2202
- /** Single char */
2203
- /** Array of single chars */
2204
- /** */
2205
- /** */
2206
- /** Digits after point */
2207
- /** Flag to remove leading and trailing zeros in the end of editing */
2208
- /** Flag to pad trailing zeros after point in the end of editing */
2209
- /** Enable characters overwriting */
2210
- /** */
2211
- /** */
2212
- /** */
2213
- /** Format typed value to string */
2214
- /** Parse string to get typed value */
2215
- constructor(t) {
2216
- super({
2217
- ...C.DEFAULTS,
2218
- ...t
2219
- });
2220
- }
2221
- updateOptions(t) {
2222
- super.updateOptions(t);
2223
- }
2224
- _update(t) {
2225
- super._update(t), this._updateRegExps();
2226
- }
2227
- _updateRegExps() {
2228
- const t = "^" + (this.allowNegative ? "[+|\\-]?" : ""), e = "\\d*", s = (this.scale ? "(" + G(this.radix) + "\\d{0," + this.scale + "})?" : "") + "$";
2229
- this._numberRegExp = new RegExp(t + e + s), this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(G).join("") + "]", "g"), this._thousandsSeparatorRegExp = new RegExp(G(this.thousandsSeparator), "g");
2230
- }
2231
- _removeThousandsSeparators(t) {
2232
- return t.replace(this._thousandsSeparatorRegExp, "");
2233
- }
2234
- _insertThousandsSeparators(t) {
2235
- const e = t.split(this.radix);
2236
- return e[0] = e[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator), e.join(this.radix);
2237
- }
2238
- doPrepareChar(t, e) {
2239
- e === void 0 && (e = {});
2240
- const [s, i] = super.doPrepareChar(this._removeThousandsSeparators(this.scale && this.mapToRadix.length && /*
2241
- radix should be mapped when
2242
- 1) input is done from keyboard = flags.input && flags.raw
2243
- 2) unmasked value is set = !flags.input && !flags.raw
2244
- and should not be mapped when
2245
- 1) value is set = flags.input && !flags.raw
2246
- 2) raw value is set = !flags.input && flags.raw
2247
- */
2248
- (e.input && e.raw || !e.input && !e.raw) ? t.replace(this._mapToRadixRegExp, this.radix) : t), e);
2249
- return t && !s && (i.skip = !0), s && !this.allowPositive && !this.value && s !== "-" && i.aggregate(this._appendChar("-")), [s, i];
2250
- }
2251
- _separatorsCount(t, e) {
2252
- e === void 0 && (e = !1);
2253
- let s = 0;
2254
- for (let i = 0; i < t; ++i)
2255
- this._value.indexOf(this.thousandsSeparator, i) === i && (++s, e && (t += this.thousandsSeparator.length));
2256
- return s;
2257
- }
2258
- _separatorsCountFromSlice(t) {
2259
- return t === void 0 && (t = this._value), this._separatorsCount(this._removeThousandsSeparators(t).length, !0);
2260
- }
2261
- extractInput(t, e, s) {
2262
- return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), [t, e] = this._adjustRangeWithSeparators(t, e), this._removeThousandsSeparators(super.extractInput(t, e, s));
2263
- }
2264
- _appendCharRaw(t, e) {
2265
- e === void 0 && (e = {});
2266
- const s = e.tail && e._beforeTailState ? e._beforeTailState._value : this._value, i = this._separatorsCountFromSlice(s);
2267
- this._value = this._removeThousandsSeparators(this.value);
2268
- const a = this._value;
2269
- this._value += t;
2270
- const n = this.number;
2271
- let r = !isNaN(n), l = !1;
2272
- if (r) {
2273
- let m;
2274
- this.min != null && this.min < 0 && this.number < this.min && (m = this.min), this.max != null && this.max > 0 && this.number > this.max && (m = this.max), m != null && (this.autofix ? (this._value = this.format(m, this).replace(C.UNMASKED_RADIX, this.radix), l || (l = a === this._value && !e.tail)) : r = !1), r && (r = !!this._value.match(this._numberRegExp));
2275
- }
2276
- let o;
2277
- r ? o = new c({
2278
- inserted: this._value.slice(a.length),
2279
- rawInserted: l ? "" : t,
2280
- skip: l
2281
- }) : (this._value = a, o = new c()), this._value = this._insertThousandsSeparators(this._value);
2282
- const d = e.tail && e._beforeTailState ? e._beforeTailState._value : this._value, f = this._separatorsCountFromSlice(d);
2283
- return o.tailShift += (f - i) * this.thousandsSeparator.length, o;
2284
- }
2285
- _findSeparatorAround(t) {
2286
- if (this.thousandsSeparator) {
2287
- const e = t - this.thousandsSeparator.length + 1, s = this.value.indexOf(this.thousandsSeparator, e);
2288
- if (s <= t)
2289
- return s;
2290
- }
2291
- return -1;
2292
- }
2293
- _adjustRangeWithSeparators(t, e) {
2294
- const s = this._findSeparatorAround(t);
2295
- s >= 0 && (t = s);
2296
- const i = this._findSeparatorAround(e);
2297
- return i >= 0 && (e = i + this.thousandsSeparator.length), [t, e];
2298
- }
2299
- remove(t, e) {
2300
- t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), [t, e] = this._adjustRangeWithSeparators(t, e);
2301
- const s = this.value.slice(0, t), i = this.value.slice(e), a = this._separatorsCount(s.length);
2302
- this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(s + i));
2303
- const n = this._separatorsCountFromSlice(s);
2304
- return new c({
2305
- tailShift: (n - a) * this.thousandsSeparator.length
2306
- });
2307
- }
2308
- nearestInputPos(t, e) {
2309
- if (!this.thousandsSeparator)
2310
- return t;
2311
- switch (e) {
2312
- case h.NONE:
2313
- case h.LEFT:
2314
- case h.FORCE_LEFT: {
2315
- const s = this._findSeparatorAround(t - 1);
2316
- if (s >= 0) {
2317
- const i = s + this.thousandsSeparator.length;
2318
- if (t < i || this.value.length <= i || e === h.FORCE_LEFT)
2319
- return s;
2320
- }
2321
- break;
2322
- }
2323
- case h.RIGHT:
2324
- case h.FORCE_RIGHT: {
2325
- const s = this._findSeparatorAround(t);
2326
- if (s >= 0)
2327
- return s + this.thousandsSeparator.length;
2328
- }
2329
- }
2330
- return t;
2331
- }
2332
- doCommit() {
2333
- if (this.value) {
2334
- const t = this.number;
2335
- let e = t;
2336
- this.min != null && (e = Math.max(e, this.min)), this.max != null && (e = Math.min(e, this.max)), e !== t && (this.unmaskedValue = this.format(e, this));
2337
- let s = this.value;
2338
- this.normalizeZeros && (s = this._normalizeZeros(s)), this.padFractionalZeros && this.scale > 0 && (s = this._padFractionalZeros(s)), this._value = s;
2339
- }
2340
- super.doCommit();
2341
- }
2342
- _normalizeZeros(t) {
2343
- const e = this._removeThousandsSeparators(t).split(this.radix);
2344
- return e[0] = e[0].replace(/^(\D*)(0*)(\d*)/, (s, i, a, n) => i + n), t.length && !/\d$/.test(e[0]) && (e[0] = e[0] + "0"), e.length > 1 && (e[1] = e[1].replace(/0*$/, ""), e[1].length || (e.length = 1)), this._insertThousandsSeparators(e.join(this.radix));
2345
- }
2346
- _padFractionalZeros(t) {
2347
- if (!t)
2348
- return t;
2349
- const e = t.split(this.radix);
2350
- return e.length < 2 && e.push(""), e[1] = e[1].padEnd(this.scale, "0"), e.join(this.radix);
2351
- }
2352
- doSkipInvalid(t, e, s) {
2353
- e === void 0 && (e = {});
2354
- const i = this.scale === 0 && t !== this.thousandsSeparator && (t === this.radix || t === C.UNMASKED_RADIX || this.mapToRadix.includes(t));
2355
- return super.doSkipInvalid(t, e, s) && !i;
2356
- }
2357
- get unmaskedValue() {
2358
- return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, C.UNMASKED_RADIX);
2359
- }
2360
- set unmaskedValue(t) {
2361
- super.unmaskedValue = t;
2362
- }
2363
- get typedValue() {
2364
- return this.parse(this.unmaskedValue, this);
2365
- }
2366
- set typedValue(t) {
2367
- this.rawInputValue = this.format(t, this).replace(C.UNMASKED_RADIX, this.radix);
2368
- }
2369
- /** Parsed Number */
2370
- get number() {
2371
- return this.typedValue;
2372
- }
2373
- set number(t) {
2374
- this.typedValue = t;
2375
- }
2376
- get allowNegative() {
2377
- return this.min != null && this.min < 0 || this.max != null && this.max < 0;
2378
- }
2379
- get allowPositive() {
2380
- return this.min != null && this.min > 0 || this.max != null && this.max > 0;
2381
- }
2382
- typedValueEquals(t) {
2383
- return (super.typedValueEquals(t) || C.EMPTY_VALUES.includes(t) && C.EMPTY_VALUES.includes(this.typedValue)) && !(t === 0 && this.value === "");
2384
- }
2385
- }
2386
- dt = C;
2387
- C.UNMASKED_RADIX = ".";
2388
- C.EMPTY_VALUES = [..._.EMPTY_VALUES, 0];
2389
- C.DEFAULTS = {
2390
- ..._.DEFAULTS,
2391
- mask: Number,
2392
- radix: ",",
2393
- thousandsSeparator: "",
2394
- mapToRadix: [dt.UNMASKED_RADIX],
2395
- min: Number.MIN_SAFE_INTEGER,
2396
- max: Number.MAX_SAFE_INTEGER,
2397
- scale: 2,
2398
- normalizeZeros: !0,
2399
- padFractionalZeros: !1,
2400
- parse: Number,
2401
- format: (u) => u.toLocaleString("en-US", {
2402
- useGrouping: !1,
2403
- maximumFractionDigits: 20
2404
- })
2405
- };
2406
- p.MaskedNumber = C;
2407
- const K = {
2408
- MASKED: "value",
2409
- UNMASKED: "unmaskedValue",
2410
- TYPED: "typedValue"
2411
- };
2412
- function pt(u, t, e) {
2413
- t === void 0 && (t = K.MASKED), e === void 0 && (e = K.MASKED);
2414
- const s = y(u);
2415
- return (i) => s.runIsolated((a) => (a[t] = i, a[e]));
2416
- }
2417
- function Nt(u, t, e, s) {
2418
- return pt(t, e, s)(u);
2419
- }
2420
- p.PIPE_TYPE = K;
2421
- p.createPipe = pt;
2422
- p.pipe = Nt;
2423
- class Ut extends v {
2424
- get repeatFrom() {
2425
- var t;
2426
- return (t = Array.isArray(this.repeat) ? this.repeat[0] : this.repeat === 1 / 0 ? 0 : this.repeat) != null ? t : 0;
2427
- }
2428
- get repeatTo() {
2429
- var t;
2430
- return (t = Array.isArray(this.repeat) ? this.repeat[1] : this.repeat) != null ? t : 1 / 0;
2431
- }
2432
- constructor(t) {
2433
- super(t);
2434
- }
2435
- updateOptions(t) {
2436
- super.updateOptions(t);
2437
- }
2438
- _update(t) {
2439
- var e, s, i;
2440
- const {
2441
- repeat: a,
2442
- ...n
2443
- } = w(t);
2444
- this._blockOpts = Object.assign({}, this._blockOpts, n);
2445
- const r = y(this._blockOpts);
2446
- this.repeat = (e = (s = a ?? r.repeat) != null ? s : this.repeat) != null ? e : 1 / 0, super._update({
2447
- mask: "m".repeat(Math.max(this.repeatTo === 1 / 0 && ((i = this._blocks) == null ? void 0 : i.length) || 0, this.repeatFrom)),
2448
- blocks: {
2449
- m: r
2450
- },
2451
- eager: r.eager,
2452
- overwrite: r.overwrite,
2453
- skipInvalid: r.skipInvalid,
2454
- lazy: r.lazy,
2455
- placeholderChar: r.placeholderChar,
2456
- displayChar: r.displayChar
2457
- });
2458
- }
2459
- _allocateBlock(t) {
2460
- if (t < this._blocks.length)
2461
- return this._blocks[t];
2462
- if (this.repeatTo === 1 / 0 || this._blocks.length < this.repeatTo)
2463
- return this._blocks.push(y(this._blockOpts)), this.mask += "m", this._blocks[this._blocks.length - 1];
2464
- }
2465
- _appendCharRaw(t, e) {
2466
- e === void 0 && (e = {});
2467
- const s = new c();
2468
- for (
2469
- let l = (i = (a = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : a.index) != null ? i : Math.max(this._blocks.length - 1, 0), o, d;
2470
- // try to get a block or
2471
- // try to allocate a new block if not allocated already
2472
- o = (n = this._blocks[l]) != null ? n : d = !d && this._allocateBlock(l);
2473
- ++l
2474
- ) {
2475
- var i, a, n, r;
2476
- const f = o._appendChar(t, {
2477
- ...e,
2478
- _beforeTailState: (r = e._beforeTailState) == null || (r = r._blocks) == null ? void 0 : r[l]
2479
- });
2480
- if (f.skip && d) {
2481
- this._blocks.pop(), this.mask = this.mask.slice(1);
2482
- break;
2483
- }
2484
- if (s.aggregate(f), f.consumed)
2485
- break;
2486
- }
2487
- return s;
2488
- }
2489
- _trimEmptyTail(t, e) {
2490
- var s, i;
2491
- t === void 0 && (t = 0);
2492
- const a = Math.max(((s = this._mapPosToBlock(t)) == null ? void 0 : s.index) || 0, this.repeatFrom, 0);
2493
- let n;
2494
- e != null && (n = (i = this._mapPosToBlock(e)) == null ? void 0 : i.index), n == null && (n = this._blocks.length - 1);
2495
- let r = 0;
2496
- for (let l = n; a <= l && !this._blocks[l].unmaskedValue; --l, ++r)
2497
- ;
2498
- r && (this._blocks.splice(n - r + 1, r), this.mask = this.mask.slice(r));
2499
- }
2500
- reset() {
2501
- super.reset(), this._trimEmptyTail();
2502
- }
2503
- remove(t, e) {
2504
- t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
2505
- const s = super.remove(t, e);
2506
- return this._trimEmptyTail(t, e), s;
2507
- }
2508
- totalInputPositions(t, e) {
2509
- return t === void 0 && (t = 0), e == null && this.repeatTo === 1 / 0 ? 1 / 0 : super.totalInputPositions(t, e);
2510
- }
2511
- get state() {
2512
- return super.state;
2513
- }
2514
- set state(t) {
2515
- this._blocks.length = t._blocks.length, this.mask = this.mask.slice(0, this._blocks.length), super.state = t;
2516
- }
2517
- }
2518
- p.RepeatBlock = Ut;
2519
- try {
2520
- globalThis.IMask = p;
2521
- } catch {
2522
- }
2523
- var Pt = {
2524
- // common
2525
- mask: void 0,
2526
- prepare: Function,
2527
- prepareChar: Function,
2528
- validate: Function,
2529
- commit: Function,
2530
- overwrite: {
2531
- type: Boolean,
2532
- required: !1,
2533
- default: void 0
2534
- },
2535
- eager: {
2536
- required: !1,
2537
- default: void 0,
2538
- validator: (u) => ["append", "remove"].includes(u) || typeof u == "boolean"
2539
- },
2540
- skipInvalid: {
2541
- type: Boolean,
2542
- required: !1,
2543
- default: void 0
2544
- },
2545
- // pattern
2546
- placeholderChar: String,
2547
- displayChar: String,
2548
- lazy: {
2549
- type: Boolean,
2550
- required: !1,
2551
- default: void 0
2552
- },
2553
- definitions: Object,
2554
- blocks: Object,
2555
- // enum
2556
- enum: Array,
2557
- // range
2558
- maxLength: Number,
2559
- from: Number,
2560
- to: Number,
2561
- // date
2562
- pattern: String,
2563
- format: Function,
2564
- parse: Function,
2565
- autofix: {
2566
- required: !1,
2567
- default: void 0,
2568
- validator: (u) => u === "pad" || typeof u == "boolean"
2569
- },
2570
- // number
2571
- radix: String,
2572
- thousandsSeparator: String,
2573
- mapToRadix: Array,
2574
- scale: Number,
2575
- normalizeZeros: {
2576
- type: Boolean,
2577
- required: !1,
2578
- default: void 0
2579
- },
2580
- padFractionalZeros: {
2581
- type: Boolean,
2582
- required: !1,
2583
- default: void 0
2584
- },
2585
- min: [Number, Date],
2586
- max: [Number, Date],
2587
- // dynamic
2588
- dispatch: Function
2589
- };
2590
- function jt(u, t) {
2591
- let {
2592
- emit: e,
2593
- onAccept: s,
2594
- onComplete: i,
2595
- defaultValue: a,
2596
- defaultUnmaskedValue: n,
2597
- defaultTypedValue: r
2598
- } = t === void 0 ? {} : t;
2599
- const l = kt(u) ? u : V(u), o = V(), d = V(), f = V(""), m = V(""), k = V();
2600
- let E, I = f.value, B = m.value, z = k.value;
2601
- function $() {
2602
- z = k.value = d.value.typedValue, B = m.value = d.value.unmaskedValue, I = f.value = d.value.value;
2603
- }
2604
- function T(g) {
2605
- $(), e && (e("accept", f.value, g), e("accept:masked", f.value, g), e("accept:typed", k.value, g), e("accept:unmasked", m.value, g)), s == null || s(g);
2606
- }
2607
- function ct(g) {
2608
- e && (e("complete", d.value.value, g), e("complete:masked", d.value.value, g), e("complete:typed", d.value.typedValue, g), e("complete:unmasked", d.value.unmaskedValue, g)), i == null || i(g);
2609
- }
2610
- const Z = () => {
2611
- !d.value || m.value === void 0 || (B !== m.value && (d.value.unmaskedValue = m.value, d.value.unmaskedValue !== m.value && T()), B = void 0);
2612
- };
2613
- A(m, Z);
2614
- const X = () => {
2615
- !d.value || f.value === void 0 || (I !== f.value && (d.value.value = f.value, d.value.value !== f.value && T()), I = void 0);
2616
- };
2617
- A(f, X);
2618
- const W = () => {
2619
- !d.value || k.value === void 0 || (z !== k.value && (d.value.typedValue = k.value, d.value.masked.typedValueEquals(k.value) || T()), z = void 0);
2620
- };
2621
- A(k, W);
2622
- function J() {
2623
- E = o.value;
2624
- const g = l.value;
2625
- !E || !(g != null && g.mask) || (d.value = p(E, g), a !== void 0 && (f.value = a), n !== void 0 && (m.value = n), r !== void 0 && (k.value = r), Z(), X(), W(), $(), d.value.on("accept", T).on("complete", ct));
2626
- }
2627
- function Q() {
2628
- var g;
2629
- (g = d.value) == null || g.destroy(), d.value = void 0;
2630
- }
2631
- return nt(J), mt(Q), A([o, l], () => {
2632
- const g = o.value, q = l.value;
2633
- (!(q != null && q.mask) || g !== E) && Q(), g && (d.value ? d.value.updateOptions(q) : J());
2634
- }), {
2635
- el: o,
2636
- mask: gt(d),
2637
- masked: f,
2638
- unmasked: m,
2639
- typed: k
2640
- };
2641
- }
2642
- function Ht(u, t) {
2643
- return u = {
2644
- ...u
2645
- }, Object.keys(u).forEach((e) => {
2646
- (u[e] === void 0 || t.includes(e)) && delete u[e];
2647
- }), u;
2648
- }
2649
- const zt = ["typed", "unmasked", "value", "modelValue"];
2650
- _t({
2651
- name: "imask-input",
2652
- inheritAttrs: !1,
2653
- props: {
2654
- // plugin
2655
- modelValue: String,
2656
- value: String,
2657
- unmasked: String,
2658
- typed: {
2659
- validator: () => !0
2660
- },
2661
- ...Pt
2662
- },
2663
- 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"],
2664
- setup(u, t) {
2665
- let {
2666
- attrs: e,
2667
- emit: s
2668
- } = t;
2669
- const {
2670
- el: i,
2671
- mask: a,
2672
- masked: n,
2673
- unmasked: r,
2674
- typed: l
2675
- } = jt(Ht(u, zt), {
2676
- emit: s,
2677
- onAccept: (k) => {
2678
- const E = n.value;
2679
- s("accept:value", E, k), s("update:value", E, k), s("update:masked", E, k), s("update:modelValue", E, k), s("update:unmasked", r.value, k), s("update:typed", l.value, k);
2680
- },
2681
- onComplete: (k) => {
2682
- s("complete:value", n.value, k);
2683
- }
2684
- }), o = R(u, "value"), d = R(u, "modelValue"), f = R(u, "unmasked"), m = R(u, "typed");
2685
- return n.value = d.value || o.value || "", r.value = f.value || "", l.value = m.value, A(o, (k) => n.value = k), A(d, (k) => n.value = k), A(f, (k) => r.value = k), A(m, (k) => l.value = k), () => {
2686
- const k = {
2687
- ...e,
2688
- value: u.value != null ? u.value : u.modelValue != null ? u.modelValue : a.value ? a.value.displayValue : "",
2689
- ref: i
2690
- };
2691
- return u.mask || (k.onInput = (E) => {
2692
- s("update:modelValue", E.target.value), s("update:value", E.target.value);
2693
- }), vt("input", k);
2694
- };
2695
- }
2696
- });
2697
- var qt = {
2698
- name: "imask",
2699
- beforeMount: (u, t) => {
2700
- let {
2701
- value: e
2702
- } = t;
2703
- e && it(u, e);
2704
- },
2705
- updated: (u, t) => {
2706
- let {
2707
- value: e
2708
- } = t;
2709
- e ? u.maskRef ? (u.maskRef.updateOptions(e), u.value !== u.maskRef.value && u.maskRef._onChange()) : it(u, e) : at(u);
2710
- },
2711
- unmounted: (u) => {
2712
- at(u);
2713
- }
2714
- };
2715
- function st(u, t, e) {
2716
- const s = document.createEvent("CustomEvent");
2717
- s.initCustomEvent(t, !0, !0, e), u.dispatchEvent(s);
2718
- }
2719
- function it(u, t) {
2720
- u.maskRef = p(u, t).on("accept", () => st(u, "accept", u.maskRef)).on("complete", () => st(u, "complete", u.maskRef));
2721
- }
2722
- function at(u) {
2723
- u.maskRef && (u.maskRef.destroy(), delete u.maskRef);
2724
- }
2725
- const Kt = {
2726
- formHelpers: {
2727
- ...At,
2728
- useInput: xt,
2729
- useTextbox: St,
2730
- useMaskedInput: Vt
2731
- },
2732
- install: (u) => {
2733
- u.directive("imask", qt), u.provide("responsiveHelpers", {
2734
- responsiveState: D,
2735
- updateResponsiveState: Et
2736
- });
2737
- }
2738
- };
2739
- export {
2740
- Kt as default
2741
- };