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