@prolibu-suite/cobalt-form-vue 0.1.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FieldObject-Cxd3I0Jv.js +4 -0
- package/dist/components/CoFieldRenderer.test.d.ts +2 -0
- package/dist/components/CoFieldRenderer.test.d.ts.map +1 -0
- package/dist/components/CoFieldRenderer.vue.d.ts +40 -3
- package/dist/components/CoFieldRenderer.vue.d.ts.map +1 -1
- package/dist/components/CoFieldShell.vue.d.ts +23 -0
- package/dist/components/CoFieldShell.vue.d.ts.map +1 -0
- package/dist/components/CoFormRenderer.file.test.d.ts +2 -0
- package/dist/components/CoFormRenderer.file.test.d.ts.map +1 -0
- package/dist/components/CoFormRenderer.vue.d.ts +35 -6
- package/dist/components/CoFormRenderer.vue.d.ts.map +1 -1
- package/dist/components/fields/FieldBoolean.vue.d.ts.map +1 -1
- package/dist/components/fields/FieldColor.vue.d.ts +17 -0
- package/dist/components/fields/FieldColor.vue.d.ts.map +1 -0
- package/dist/components/fields/FieldDate.vue.d.ts.map +1 -1
- package/dist/components/fields/FieldDatePicker.vue.d.ts +18 -0
- package/dist/components/fields/FieldDatePicker.vue.d.ts.map +1 -0
- package/dist/components/fields/FieldFile.test.d.ts +2 -0
- package/dist/components/fields/FieldFile.test.d.ts.map +1 -0
- package/dist/components/fields/FieldFile.vue.d.ts +61 -0
- package/dist/components/fields/FieldFile.vue.d.ts.map +1 -0
- package/dist/components/fields/FieldMasked.test.d.ts +2 -0
- package/dist/components/fields/FieldMasked.test.d.ts.map +1 -0
- package/dist/components/fields/FieldMasked.vue.d.ts +23 -0
- package/dist/components/fields/FieldMasked.vue.d.ts.map +1 -0
- package/dist/components/fields/FieldMixed.vue.d.ts +17 -0
- package/dist/components/fields/FieldMixed.vue.d.ts.map +1 -0
- package/dist/components/fields/FieldMultiple.vue.d.ts +17 -0
- package/dist/components/fields/FieldMultiple.vue.d.ts.map +1 -0
- package/dist/components/fields/FieldNumber.vue.d.ts.map +1 -1
- package/dist/components/fields/FieldObject.vue.d.ts +18 -0
- package/dist/components/fields/FieldObject.vue.d.ts.map +1 -0
- package/dist/components/fields/FieldPhone.vue.d.ts +16 -0
- package/dist/components/fields/FieldPhone.vue.d.ts.map +1 -0
- package/dist/components/fields/FieldRef.vue.d.ts +2 -2
- package/dist/components/fields/FieldRichText.vue.d.ts +16 -0
- package/dist/components/fields/FieldRichText.vue.d.ts.map +1 -0
- package/dist/components/fields/FieldSelect.vue.d.ts.map +1 -1
- package/dist/components/fields/FieldText.vue.d.ts.map +1 -1
- package/dist/components/fields/FieldTextArea.vue.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +23 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3787 -363
- package/dist/utils/formContext.d.ts +40 -0
- package/dist/utils/formContext.d.ts.map +1 -0
- package/dist/utils/gridCell.d.ts +28 -0
- package/dist/utils/gridCell.d.ts.map +1 -0
- package/dist/utils/gridCell.test.d.ts +2 -0
- package/dist/utils/gridCell.test.d.ts.map +1 -0
- package/dist/utils/normalizeMaskConfig.d.ts +23 -0
- package/dist/utils/normalizeMaskConfig.d.ts.map +1 -0
- package/dist/utils/normalizeMaskConfig.test.d.ts +2 -0
- package/dist/utils/normalizeMaskConfig.test.d.ts.map +1 -0
- package/dist/utils/sectionPreview.d.ts +26 -0
- package/dist/utils/sectionPreview.d.ts.map +1 -0
- package/dist/utils/sectionPreview.test.d.ts +2 -0
- package/dist/utils/sectionPreview.test.d.ts.map +1 -0
- package/package.json +13 -6
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createForm as
|
|
2
|
-
import { createForm as
|
|
3
|
-
import { shallowRef as
|
|
4
|
-
import {
|
|
5
|
-
function
|
|
6
|
-
const
|
|
1
|
+
import { createForm as ht, normalizeForValidation as ct } from "@prolibu-suite/cobalt-form-core";
|
|
2
|
+
import { createForm as $s } from "@prolibu-suite/cobalt-form-core";
|
|
3
|
+
import { shallowRef as Re, watch as J, toValue as pt, onBeforeUnmount as Ue, computed as c, defineComponent as T, openBlock as w, createBlock as R, unref as O, withCtx as Ie, createElementBlock as j, renderSlot as he, createCommentVNode as ue, normalizeClass as ft, createTextVNode as mt, toDisplayString as _e, createElementVNode as ce, ref as H, onMounted as Se, withModifiers as Pe, createVNode as me, defineAsyncComponent as gt, resolveDynamicComponent as vt, provide as se, reactive as Oe, normalizeStyle as Be, Fragment as je, renderList as He, mergeProps as Ge, nextTick as kt, inject as le } from "vue";
|
|
4
|
+
import { CoSwitch as Ct, CoColorPicker as yt, CoDatePicker as bt, CoFileField as At, CoIcon as Ft, CoJsonField as Et, CoTagsField as xt, CoNumberField as _t, CoPhoneField as St, CoRefField as Bt, CoRichTextEditor as Mt, CoSelect as wt, CoInput as Ke, CoTextarea as It, CoButton as Vt, CoAccordion as Dt } from "@prolibu-suite/cobalt-vue";
|
|
5
|
+
function Ts(i) {
|
|
6
|
+
const e = Re(null), t = Re({
|
|
7
7
|
values: {},
|
|
8
8
|
errors: {},
|
|
9
9
|
touched: {},
|
|
@@ -11,118 +11,3021 @@ function he(e) {
|
|
|
11
11
|
isDirty: !1,
|
|
12
12
|
isSubmitting: !1
|
|
13
13
|
});
|
|
14
|
-
let
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
t.value =
|
|
14
|
+
let s = null;
|
|
15
|
+
function r(n) {
|
|
16
|
+
s == null || s();
|
|
17
|
+
const a = ht(n);
|
|
18
|
+
e.value = a, t.value = a.state, s = a.subscribe((l) => {
|
|
19
|
+
t.value = l;
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
return
|
|
23
|
-
() =>
|
|
24
|
-
(n) =>
|
|
22
|
+
return J(
|
|
23
|
+
() => pt(i),
|
|
24
|
+
(n) => r(n),
|
|
25
25
|
{ immediate: !0, deep: !1 }
|
|
26
|
-
),
|
|
27
|
-
|
|
26
|
+
), Ue(() => {
|
|
27
|
+
s == null || s(), s = null;
|
|
28
28
|
}), {
|
|
29
|
-
controller:
|
|
30
|
-
values:
|
|
31
|
-
errors:
|
|
32
|
-
touched:
|
|
33
|
-
isValid:
|
|
34
|
-
isDirty:
|
|
35
|
-
isSubmitting:
|
|
36
|
-
fields:
|
|
29
|
+
controller: e,
|
|
30
|
+
values: c(() => t.value.values),
|
|
31
|
+
errors: c(() => t.value.errors),
|
|
32
|
+
touched: c(() => t.value.touched),
|
|
33
|
+
isValid: c(() => t.value.isValid),
|
|
34
|
+
isDirty: c(() => t.value.isDirty),
|
|
35
|
+
isSubmitting: c(() => t.value.isSubmitting),
|
|
36
|
+
fields: c(() => {
|
|
37
37
|
var n;
|
|
38
|
-
return ((n =
|
|
38
|
+
return ((n = e.value) == null ? void 0 : n.fields) ?? [];
|
|
39
39
|
}),
|
|
40
|
-
setValue: (n,
|
|
41
|
-
var
|
|
42
|
-
return (
|
|
40
|
+
setValue: (n, a) => {
|
|
41
|
+
var l;
|
|
42
|
+
return (l = e.value) == null ? void 0 : l.setValue(n, a);
|
|
43
43
|
},
|
|
44
44
|
setValues: (n) => {
|
|
45
|
-
var
|
|
46
|
-
return (
|
|
45
|
+
var a;
|
|
46
|
+
return (a = e.value) == null ? void 0 : a.setValues(n);
|
|
47
47
|
},
|
|
48
48
|
touch: (n) => {
|
|
49
|
-
var
|
|
50
|
-
return (
|
|
49
|
+
var a;
|
|
50
|
+
return (a = e.value) == null ? void 0 : a.touch(n);
|
|
51
51
|
},
|
|
52
52
|
touchAll: () => {
|
|
53
53
|
var n;
|
|
54
|
-
return (n =
|
|
54
|
+
return (n = e.value) == null ? void 0 : n.touchAll();
|
|
55
55
|
},
|
|
56
56
|
setSchema: (n) => {
|
|
57
|
-
var
|
|
58
|
-
return (
|
|
57
|
+
var a;
|
|
58
|
+
return (a = e.value) == null ? void 0 : a.setSchema(n);
|
|
59
59
|
},
|
|
60
60
|
validate: () => {
|
|
61
61
|
var n;
|
|
62
|
-
return ((n =
|
|
62
|
+
return ((n = e.value) == null ? void 0 : n.validate()) ?? !0;
|
|
63
|
+
},
|
|
64
|
+
submit: () => {
|
|
65
|
+
var n;
|
|
66
|
+
return ((n = e.value) == null ? void 0 : n.submit()) ?? Promise.resolve({ values: {}, isValid: !0, errors: {} });
|
|
67
|
+
},
|
|
68
|
+
reset: (n) => {
|
|
69
|
+
var a;
|
|
70
|
+
return (a = e.value) == null ? void 0 : a.reset(n);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const Tt = /* @__PURE__ */ T({
|
|
75
|
+
__name: "FieldBoolean",
|
|
76
|
+
props: {
|
|
77
|
+
field: {},
|
|
78
|
+
value: {},
|
|
79
|
+
errors: {},
|
|
80
|
+
disabled: { type: Boolean }
|
|
81
|
+
},
|
|
82
|
+
emits: ["update:value"],
|
|
83
|
+
setup(i, { emit: e }) {
|
|
84
|
+
const t = i, s = e, r = c(() => t.errors.length > 0 ? "error" : "default"), n = c(() => t.errors[0] || t.field.helperText);
|
|
85
|
+
return (a, l) => (w(), R(O(Ct), {
|
|
86
|
+
label: i.field.label,
|
|
87
|
+
required: i.field.required,
|
|
88
|
+
disabled: i.disabled,
|
|
89
|
+
status: r.value,
|
|
90
|
+
"helper-text": n.value,
|
|
91
|
+
checked: !!i.value,
|
|
92
|
+
onCoChange: l[0] || (l[0] = (u) => s("update:value", u.detail))
|
|
93
|
+
}, null, 8, ["label", "required", "disabled", "status", "helper-text", "checked"]));
|
|
94
|
+
}
|
|
95
|
+
}), Rt = /* @__PURE__ */ T({
|
|
96
|
+
__name: "FieldColor",
|
|
97
|
+
props: {
|
|
98
|
+
field: {},
|
|
99
|
+
value: {},
|
|
100
|
+
errors: {},
|
|
101
|
+
disabled: { type: Boolean },
|
|
102
|
+
locale: {}
|
|
103
|
+
},
|
|
104
|
+
emits: ["update:value", "blur"],
|
|
105
|
+
setup(i, { emit: e }) {
|
|
106
|
+
const t = i, s = e, r = {
|
|
107
|
+
en: {
|
|
108
|
+
green: "Green",
|
|
109
|
+
yellow: "Yellow",
|
|
110
|
+
blue: "Blue",
|
|
111
|
+
pink: "Pink",
|
|
112
|
+
red: "Red",
|
|
113
|
+
orange: "Orange",
|
|
114
|
+
teal: "Teal",
|
|
115
|
+
lightBlue: "Light blue",
|
|
116
|
+
electricBlue: "Electric blue",
|
|
117
|
+
violet: "Violet",
|
|
118
|
+
burgundy: "Burgundy",
|
|
119
|
+
olive: "Olive"
|
|
120
|
+
},
|
|
121
|
+
es: {
|
|
122
|
+
green: "Verde",
|
|
123
|
+
yellow: "Amarillo",
|
|
124
|
+
blue: "Azul",
|
|
125
|
+
pink: "Rosado",
|
|
126
|
+
red: "Rojo",
|
|
127
|
+
orange: "Naranja",
|
|
128
|
+
teal: "Turquesa",
|
|
129
|
+
lightBlue: "Azul claro",
|
|
130
|
+
electricBlue: "Azul eléctrico",
|
|
131
|
+
violet: "Violeta",
|
|
132
|
+
burgundy: "Guinda",
|
|
133
|
+
olive: "Oliva"
|
|
134
|
+
},
|
|
135
|
+
pt: {
|
|
136
|
+
green: "Verde",
|
|
137
|
+
yellow: "Amarelo",
|
|
138
|
+
blue: "Azul",
|
|
139
|
+
pink: "Rosa",
|
|
140
|
+
red: "Vermelho",
|
|
141
|
+
orange: "Laranja",
|
|
142
|
+
teal: "Turquesa",
|
|
143
|
+
lightBlue: "Azul claro",
|
|
144
|
+
electricBlue: "Azul elétrico",
|
|
145
|
+
violet: "Violeta",
|
|
146
|
+
burgundy: "Bordô",
|
|
147
|
+
olive: "Oliva"
|
|
148
|
+
}
|
|
149
|
+
}, n = [
|
|
150
|
+
{ key: "green", value: "#02A270" },
|
|
151
|
+
{ key: "yellow", value: "#FDBF00" },
|
|
152
|
+
{ key: "blue", value: "#2563EB" },
|
|
153
|
+
{ key: "pink", value: "#F32A73" },
|
|
154
|
+
{ key: "red", value: "#EB1E1E" },
|
|
155
|
+
{ key: "orange", value: "#F0821E" },
|
|
156
|
+
{ key: "teal", value: "#00AFAF" },
|
|
157
|
+
{ key: "lightBlue", value: "#00BEE6" },
|
|
158
|
+
{ key: "electricBlue", value: "#000AFF" },
|
|
159
|
+
{ key: "violet", value: "#5F4BD7" },
|
|
160
|
+
{ key: "burgundy", value: "#811137" },
|
|
161
|
+
{ key: "olive", value: "#AAB43C" }
|
|
162
|
+
], a = c(() => t.errors.length > 0 ? "error" : "default"), l = c(() => t.errors[0] || t.field.helperText), u = c(() => {
|
|
163
|
+
var E;
|
|
164
|
+
const o = (E = t.field.originalAttrs) == null ? void 0 : E.presets;
|
|
165
|
+
if (Array.isArray(o) && o.length) return JSON.stringify(o);
|
|
166
|
+
const v = (t.locale || "en").split("-")[0].toLowerCase(), p = r[v] || r.en, m = n.map((b) => ({
|
|
167
|
+
name: p[b.key] || b.key,
|
|
168
|
+
value: b.value
|
|
169
|
+
}));
|
|
170
|
+
return JSON.stringify(m);
|
|
171
|
+
});
|
|
172
|
+
return (o, v) => (w(), R(O(yt), {
|
|
173
|
+
label: i.field.label,
|
|
174
|
+
placeholder: i.field.placeholder,
|
|
175
|
+
required: i.field.required,
|
|
176
|
+
disabled: i.disabled,
|
|
177
|
+
status: a.value,
|
|
178
|
+
"helper-text": l.value,
|
|
179
|
+
presets: u.value,
|
|
180
|
+
value: String(i.value ?? ""),
|
|
181
|
+
onCoChange: v[0] || (v[0] = (p) => s("update:value", p.detail))
|
|
182
|
+
}, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "presets", "value"]));
|
|
183
|
+
}
|
|
184
|
+
}), Ot = /* @__PURE__ */ T({
|
|
185
|
+
__name: "FieldDatePicker",
|
|
186
|
+
props: {
|
|
187
|
+
field: {},
|
|
188
|
+
value: {},
|
|
189
|
+
errors: {},
|
|
190
|
+
disabled: { type: Boolean },
|
|
191
|
+
locale: {}
|
|
192
|
+
},
|
|
193
|
+
emits: ["update:value", "blur"],
|
|
194
|
+
setup(i, { emit: e }) {
|
|
195
|
+
const t = i, s = e, r = c(() => {
|
|
196
|
+
const p = t.value;
|
|
197
|
+
return typeof p != "string" || p === "" ? null : p.length >= 10 ? p.slice(0, 10) : p;
|
|
198
|
+
}), n = c(() => t.field.originalAttrs.min), a = c(() => t.field.originalAttrs.max), l = c(() => t.field.originalAttrs.disabledDates), u = c(() => t.field.originalAttrs.disabledDaysOfWeek), o = c(
|
|
199
|
+
() => t.locale || t.field.originalAttrs.locale || "es-CO"
|
|
200
|
+
), v = c(
|
|
201
|
+
() => t.field.originalAttrs.displayFormat || "d MMM yyyy"
|
|
202
|
+
);
|
|
203
|
+
return (p, m) => (w(), R(O(bt), {
|
|
204
|
+
label: i.field.label,
|
|
205
|
+
placeholder: i.field.placeholder,
|
|
206
|
+
required: i.field.required,
|
|
207
|
+
disabled: i.disabled,
|
|
208
|
+
clearable: !i.field.required,
|
|
209
|
+
invalid: i.errors.length > 0,
|
|
210
|
+
"error-message": i.errors[0],
|
|
211
|
+
"helper-text": i.field.helperText,
|
|
212
|
+
value: r.value,
|
|
213
|
+
min: n.value,
|
|
214
|
+
max: a.value,
|
|
215
|
+
"disabled-dates": l.value,
|
|
216
|
+
"disabled-days-of-week": u.value,
|
|
217
|
+
locale: o.value,
|
|
218
|
+
"display-format": v.value,
|
|
219
|
+
onCoChange: m[0] || (m[0] = (E) => s("update:value", E.detail)),
|
|
220
|
+
onCoBlur: m[1] || (m[1] = (E) => s("blur"))
|
|
221
|
+
}, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "invalid", "error-message", "helper-text", "value", "min", "max", "disabled-dates", "disabled-days-of-week", "locale", "display-format"]));
|
|
222
|
+
}
|
|
223
|
+
}), Lt = {
|
|
224
|
+
key: 0,
|
|
225
|
+
slot: "actions",
|
|
226
|
+
style: { display: "contents" }
|
|
227
|
+
}, Nt = /* @__PURE__ */ T({
|
|
228
|
+
__name: "FieldFile",
|
|
229
|
+
props: {
|
|
230
|
+
field: {},
|
|
231
|
+
value: {},
|
|
232
|
+
errors: {},
|
|
233
|
+
disabled: { type: Boolean },
|
|
234
|
+
fileState: {},
|
|
235
|
+
locale: {}
|
|
236
|
+
},
|
|
237
|
+
emits: ["update:value", "upload", "remove-file", "reorder", "copy-url"],
|
|
238
|
+
setup(i, { emit: e }) {
|
|
239
|
+
const t = i, s = e, r = c(() => t.errors.length > 0 ? "error" : "default"), n = c(() => t.errors[0] || t.field.helperText), a = c(() => {
|
|
240
|
+
var E;
|
|
241
|
+
const m = t.field.originalAttrs;
|
|
242
|
+
return !!m.multiple || Array.isArray(m.type) || ((E = m.type) == null ? void 0 : E[0]) === "array";
|
|
243
|
+
}), l = c(() => {
|
|
244
|
+
const m = t.field.originalAttrs.ext;
|
|
245
|
+
if (Array.isArray(m)) return m.join(",");
|
|
246
|
+
if (typeof m == "string") return m;
|
|
247
|
+
}), u = c(() => {
|
|
248
|
+
const m = t.field.originalAttrs.maxElements;
|
|
249
|
+
return typeof m == "number" ? m : 100;
|
|
250
|
+
}), o = c(() => {
|
|
251
|
+
const m = t.field.originalAttrs.maxBytes;
|
|
252
|
+
return typeof m == "number" ? m : void 0;
|
|
253
|
+
});
|
|
254
|
+
function v(m) {
|
|
255
|
+
const E = (S) => {
|
|
256
|
+
if (!S) return null;
|
|
257
|
+
if (typeof S == "string") return { id: S, name: S, status: "done" };
|
|
258
|
+
if (typeof S == "object") {
|
|
259
|
+
const M = S._id || S.id;
|
|
260
|
+
return M ? {
|
|
261
|
+
id: M,
|
|
262
|
+
name: S.fileName || S.name || S.originalName || M,
|
|
263
|
+
size: S.size,
|
|
264
|
+
url: S.url,
|
|
265
|
+
thumbnail: S.thumbnail,
|
|
266
|
+
fileCode: S.fileCode,
|
|
267
|
+
status: "done"
|
|
268
|
+
} : null;
|
|
269
|
+
}
|
|
270
|
+
return null;
|
|
271
|
+
};
|
|
272
|
+
if (m == null || m === "") return [];
|
|
273
|
+
if (Array.isArray(m)) return m.map(E).filter((S) => !!S);
|
|
274
|
+
const b = E(m);
|
|
275
|
+
return b ? [b] : [];
|
|
276
|
+
}
|
|
277
|
+
const p = c(
|
|
278
|
+
() => JSON.stringify(t.fileState ?? v(t.value))
|
|
279
|
+
);
|
|
280
|
+
return (m, E) => (w(), R(O(At), {
|
|
281
|
+
label: i.field.label,
|
|
282
|
+
required: i.field.required,
|
|
283
|
+
disabled: i.disabled,
|
|
284
|
+
multiple: a.value,
|
|
285
|
+
accept: l.value,
|
|
286
|
+
"max-files": u.value,
|
|
287
|
+
"max-bytes": o.value,
|
|
288
|
+
status: r.value,
|
|
289
|
+
"helper-text": n.value,
|
|
290
|
+
locale: i.locale,
|
|
291
|
+
files: p.value,
|
|
292
|
+
onCoFilesSelected: E[0] || (E[0] = (b) => s("upload", b.detail)),
|
|
293
|
+
onCoRemove: E[1] || (E[1] = (b) => s("remove-file", b.detail)),
|
|
294
|
+
onCoClear: E[2] || (E[2] = (b) => s("update:value", a.value ? [] : null)),
|
|
295
|
+
onCoReorder: E[3] || (E[3] = (b) => s("reorder", b.detail)),
|
|
296
|
+
onCoCopy: E[4] || (E[4] = (b) => s("copy-url", b.detail))
|
|
297
|
+
}, {
|
|
298
|
+
default: Ie(() => [
|
|
299
|
+
m.$slots.actions ? (w(), j("div", Lt, [
|
|
300
|
+
he(m.$slots, "actions")
|
|
301
|
+
])) : ue("", !0)
|
|
302
|
+
]),
|
|
303
|
+
_: 3
|
|
304
|
+
}, 8, ["label", "required", "disabled", "multiple", "accept", "max-files", "max-bytes", "status", "helper-text", "locale", "files"]));
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
function Q(i) {
|
|
308
|
+
return typeof i == "string" || i instanceof String;
|
|
309
|
+
}
|
|
310
|
+
function Le(i) {
|
|
311
|
+
var e;
|
|
312
|
+
return typeof i == "object" && i != null && (i == null || (e = i.constructor) == null ? void 0 : e.name) === "Object";
|
|
313
|
+
}
|
|
314
|
+
function Je(i, e) {
|
|
315
|
+
return Array.isArray(e) ? Je(i, (t, s) => e.includes(s)) : Object.entries(i).reduce((t, s) => {
|
|
316
|
+
let [r, n] = s;
|
|
317
|
+
return e(n, r) && (t[r] = n), t;
|
|
318
|
+
}, {});
|
|
319
|
+
}
|
|
320
|
+
const y = {
|
|
321
|
+
NONE: "NONE",
|
|
322
|
+
LEFT: "LEFT",
|
|
323
|
+
FORCE_LEFT: "FORCE_LEFT",
|
|
324
|
+
RIGHT: "RIGHT",
|
|
325
|
+
FORCE_RIGHT: "FORCE_RIGHT"
|
|
326
|
+
};
|
|
327
|
+
function qt(i) {
|
|
328
|
+
switch (i) {
|
|
329
|
+
case y.LEFT:
|
|
330
|
+
return y.FORCE_LEFT;
|
|
331
|
+
case y.RIGHT:
|
|
332
|
+
return y.FORCE_RIGHT;
|
|
333
|
+
default:
|
|
334
|
+
return i;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function Fe(i) {
|
|
338
|
+
return i.replace(/([.*+?^=!:${}()|[\]/\\])/g, "\\$1");
|
|
339
|
+
}
|
|
340
|
+
function ge(i, e) {
|
|
341
|
+
if (e === i) return !0;
|
|
342
|
+
const t = Array.isArray(e), s = Array.isArray(i);
|
|
343
|
+
let r;
|
|
344
|
+
if (t && s) {
|
|
345
|
+
if (e.length != i.length) return !1;
|
|
346
|
+
for (r = 0; r < e.length; r++) if (!ge(e[r], i[r])) return !1;
|
|
347
|
+
return !0;
|
|
348
|
+
}
|
|
349
|
+
if (t != s) return !1;
|
|
350
|
+
if (e && i && typeof e == "object" && typeof i == "object") {
|
|
351
|
+
const n = e instanceof Date, a = i instanceof Date;
|
|
352
|
+
if (n && a) return e.getTime() == i.getTime();
|
|
353
|
+
if (n != a) return !1;
|
|
354
|
+
const l = e instanceof RegExp, u = i instanceof RegExp;
|
|
355
|
+
if (l && u) return e.toString() == i.toString();
|
|
356
|
+
if (l != u) return !1;
|
|
357
|
+
const o = Object.keys(e);
|
|
358
|
+
for (r = 0; r < o.length; r++) if (!Object.prototype.hasOwnProperty.call(i, o[r])) return !1;
|
|
359
|
+
for (r = 0; r < o.length; r++) if (!ge(i[o[r]], e[o[r]])) return !1;
|
|
360
|
+
return !0;
|
|
361
|
+
} else if (e && i && typeof e == "function" && typeof i == "function")
|
|
362
|
+
return e.toString() === i.toString();
|
|
363
|
+
return !1;
|
|
364
|
+
}
|
|
365
|
+
class $t {
|
|
366
|
+
/** Current input value */
|
|
367
|
+
/** Current cursor position */
|
|
368
|
+
/** Old input value */
|
|
369
|
+
/** Old selection */
|
|
370
|
+
constructor(e) {
|
|
371
|
+
for (Object.assign(this, e); this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos); )
|
|
372
|
+
--this.oldSelection.start;
|
|
373
|
+
if (this.insertedCount)
|
|
374
|
+
for (; this.value.slice(this.cursorPos) !== this.oldValue.slice(this.oldSelection.end); )
|
|
375
|
+
this.value.length - this.cursorPos < this.oldValue.length - this.oldSelection.end ? ++this.oldSelection.end : ++this.cursorPos;
|
|
376
|
+
}
|
|
377
|
+
/** Start changing position */
|
|
378
|
+
get startChangePos() {
|
|
379
|
+
return Math.min(this.cursorPos, this.oldSelection.start);
|
|
380
|
+
}
|
|
381
|
+
/** Inserted symbols count */
|
|
382
|
+
get insertedCount() {
|
|
383
|
+
return this.cursorPos - this.startChangePos;
|
|
384
|
+
}
|
|
385
|
+
/** Inserted symbols */
|
|
386
|
+
get inserted() {
|
|
387
|
+
return this.value.substr(this.startChangePos, this.insertedCount);
|
|
388
|
+
}
|
|
389
|
+
/** Removed symbols count */
|
|
390
|
+
get removedCount() {
|
|
391
|
+
return Math.max(this.oldSelection.end - this.startChangePos || // for Delete
|
|
392
|
+
this.oldValue.length - this.value.length, 0);
|
|
393
|
+
}
|
|
394
|
+
/** Removed symbols */
|
|
395
|
+
get removed() {
|
|
396
|
+
return this.oldValue.substr(this.startChangePos, this.removedCount);
|
|
397
|
+
}
|
|
398
|
+
/** Unchanged head symbols */
|
|
399
|
+
get head() {
|
|
400
|
+
return this.value.substring(0, this.startChangePos);
|
|
401
|
+
}
|
|
402
|
+
/** Unchanged tail symbols */
|
|
403
|
+
get tail() {
|
|
404
|
+
return this.value.substring(this.startChangePos + this.insertedCount);
|
|
405
|
+
}
|
|
406
|
+
/** Remove direction */
|
|
407
|
+
get removeDirection() {
|
|
408
|
+
return !this.removedCount || this.insertedCount ? y.NONE : (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) && // if not range removed (event with backspace)
|
|
409
|
+
this.oldSelection.end === this.oldSelection.start ? y.RIGHT : y.LEFT;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
function F(i, e) {
|
|
413
|
+
return new F.InputMask(i, e);
|
|
414
|
+
}
|
|
415
|
+
function Ye(i) {
|
|
416
|
+
if (i == null) throw new Error("mask property should be defined");
|
|
417
|
+
return i instanceof RegExp ? F.MaskedRegExp : Q(i) ? F.MaskedPattern : i === Date ? F.MaskedDate : i === Number ? F.MaskedNumber : Array.isArray(i) || i === Array ? F.MaskedDynamic : F.Masked && i.prototype instanceof F.Masked ? i : F.Masked && i instanceof F.Masked ? i.constructor : i instanceof Function ? F.MaskedFunction : (console.warn("Mask not found for mask", i), F.Masked);
|
|
418
|
+
}
|
|
419
|
+
function pe(i) {
|
|
420
|
+
if (!i) throw new Error("Options in not defined");
|
|
421
|
+
if (F.Masked) {
|
|
422
|
+
if (i.prototype instanceof F.Masked) return {
|
|
423
|
+
mask: i
|
|
424
|
+
};
|
|
425
|
+
const {
|
|
426
|
+
mask: e = void 0,
|
|
427
|
+
...t
|
|
428
|
+
} = i instanceof F.Masked ? {
|
|
429
|
+
mask: i
|
|
430
|
+
} : Le(i) && i.mask instanceof F.Masked ? i : {};
|
|
431
|
+
if (e) {
|
|
432
|
+
const s = e.mask;
|
|
433
|
+
return {
|
|
434
|
+
...Je(e, (r, n) => !n.startsWith("_")),
|
|
435
|
+
mask: e.constructor,
|
|
436
|
+
_mask: s,
|
|
437
|
+
...t
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return Le(i) ? {
|
|
442
|
+
...i
|
|
443
|
+
} : {
|
|
444
|
+
mask: i
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
function Y(i) {
|
|
448
|
+
if (F.Masked && i instanceof F.Masked) return i;
|
|
449
|
+
const e = pe(i), t = Ye(e.mask);
|
|
450
|
+
if (!t) throw new Error("Masked class is not found for provided mask " + e.mask + ", appropriate module needs to be imported manually before creating mask.");
|
|
451
|
+
return e.mask === t && delete e.mask, e._mask && (e.mask = e._mask, delete e._mask), new t(e);
|
|
452
|
+
}
|
|
453
|
+
F.createMask = Y;
|
|
454
|
+
class Ve {
|
|
455
|
+
/** */
|
|
456
|
+
/** */
|
|
457
|
+
/** */
|
|
458
|
+
/** Safely returns selection start */
|
|
459
|
+
get selectionStart() {
|
|
460
|
+
let e;
|
|
461
|
+
try {
|
|
462
|
+
e = this._unsafeSelectionStart;
|
|
463
|
+
} catch {
|
|
464
|
+
}
|
|
465
|
+
return e ?? this.value.length;
|
|
466
|
+
}
|
|
467
|
+
/** Safely returns selection end */
|
|
468
|
+
get selectionEnd() {
|
|
469
|
+
let e;
|
|
470
|
+
try {
|
|
471
|
+
e = this._unsafeSelectionEnd;
|
|
472
|
+
} catch {
|
|
473
|
+
}
|
|
474
|
+
return e ?? this.value.length;
|
|
475
|
+
}
|
|
476
|
+
/** Safely sets element selection */
|
|
477
|
+
select(e, t) {
|
|
478
|
+
if (!(e == null || t == null || e === this.selectionStart && t === this.selectionEnd))
|
|
479
|
+
try {
|
|
480
|
+
this._unsafeSelect(e, t);
|
|
481
|
+
} catch {
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
/** */
|
|
485
|
+
get isActive() {
|
|
486
|
+
return !1;
|
|
487
|
+
}
|
|
488
|
+
/** */
|
|
489
|
+
/** */
|
|
490
|
+
/** */
|
|
491
|
+
}
|
|
492
|
+
F.MaskElement = Ve;
|
|
493
|
+
const Ne = 90, zt = 89;
|
|
494
|
+
class ke extends Ve {
|
|
495
|
+
/** HTMLElement to use mask on */
|
|
496
|
+
constructor(e) {
|
|
497
|
+
super(), this.input = e, this._onKeydown = this._onKeydown.bind(this), this._onInput = this._onInput.bind(this), this._onBeforeinput = this._onBeforeinput.bind(this), this._onCompositionEnd = this._onCompositionEnd.bind(this);
|
|
498
|
+
}
|
|
499
|
+
get rootElement() {
|
|
500
|
+
var e, t, s;
|
|
501
|
+
return (e = (t = (s = this.input).getRootNode) == null ? void 0 : t.call(s)) != null ? e : document;
|
|
502
|
+
}
|
|
503
|
+
/** Is element in focus */
|
|
504
|
+
get isActive() {
|
|
505
|
+
return this.input === this.rootElement.activeElement;
|
|
506
|
+
}
|
|
507
|
+
/** Binds HTMLElement events to mask internal events */
|
|
508
|
+
bindEvents(e) {
|
|
509
|
+
this.input.addEventListener("keydown", this._onKeydown), this.input.addEventListener("input", this._onInput), this.input.addEventListener("beforeinput", this._onBeforeinput), this.input.addEventListener("compositionend", this._onCompositionEnd), this.input.addEventListener("drop", e.drop), this.input.addEventListener("click", e.click), this.input.addEventListener("focus", e.focus), this.input.addEventListener("blur", e.commit), this._handlers = e;
|
|
510
|
+
}
|
|
511
|
+
_onKeydown(e) {
|
|
512
|
+
if (this._handlers.redo && (e.keyCode === Ne && e.shiftKey && (e.metaKey || e.ctrlKey) || e.keyCode === zt && e.ctrlKey))
|
|
513
|
+
return e.preventDefault(), this._handlers.redo(e);
|
|
514
|
+
if (this._handlers.undo && e.keyCode === Ne && (e.metaKey || e.ctrlKey))
|
|
515
|
+
return e.preventDefault(), this._handlers.undo(e);
|
|
516
|
+
e.isComposing || this._handlers.selectionChange(e);
|
|
517
|
+
}
|
|
518
|
+
_onBeforeinput(e) {
|
|
519
|
+
if (e.inputType === "historyUndo" && this._handlers.undo)
|
|
520
|
+
return e.preventDefault(), this._handlers.undo(e);
|
|
521
|
+
if (e.inputType === "historyRedo" && this._handlers.redo)
|
|
522
|
+
return e.preventDefault(), this._handlers.redo(e);
|
|
523
|
+
}
|
|
524
|
+
_onCompositionEnd(e) {
|
|
525
|
+
this._handlers.input(e);
|
|
526
|
+
}
|
|
527
|
+
_onInput(e) {
|
|
528
|
+
e.isComposing || this._handlers.input(e);
|
|
529
|
+
}
|
|
530
|
+
/** Unbinds HTMLElement events to mask internal events */
|
|
531
|
+
unbindEvents() {
|
|
532
|
+
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 = {};
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
F.HTMLMaskElement = ke;
|
|
536
|
+
class Ut extends ke {
|
|
537
|
+
/** InputElement to use mask on */
|
|
538
|
+
constructor(e) {
|
|
539
|
+
super(e), this.input = e;
|
|
540
|
+
}
|
|
541
|
+
/** Returns InputElement selection start */
|
|
542
|
+
get _unsafeSelectionStart() {
|
|
543
|
+
return this.input.selectionStart != null ? this.input.selectionStart : this.value.length;
|
|
544
|
+
}
|
|
545
|
+
/** Returns InputElement selection end */
|
|
546
|
+
get _unsafeSelectionEnd() {
|
|
547
|
+
return this.input.selectionEnd;
|
|
548
|
+
}
|
|
549
|
+
/** Sets InputElement selection */
|
|
550
|
+
_unsafeSelect(e, t) {
|
|
551
|
+
this.input.setSelectionRange(e, t);
|
|
552
|
+
}
|
|
553
|
+
get value() {
|
|
554
|
+
return this.input.value;
|
|
555
|
+
}
|
|
556
|
+
set value(e) {
|
|
557
|
+
this.input.value = e;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
F.HTMLMaskElement = ke;
|
|
561
|
+
class We extends ke {
|
|
562
|
+
/** Returns HTMLElement selection start */
|
|
563
|
+
get _unsafeSelectionStart() {
|
|
564
|
+
const e = this.rootElement, t = e.getSelection && e.getSelection(), s = t && t.anchorOffset, r = t && t.focusOffset;
|
|
565
|
+
return r == null || s == null || s < r ? s : r;
|
|
566
|
+
}
|
|
567
|
+
/** Returns HTMLElement selection end */
|
|
568
|
+
get _unsafeSelectionEnd() {
|
|
569
|
+
const e = this.rootElement, t = e.getSelection && e.getSelection(), s = t && t.anchorOffset, r = t && t.focusOffset;
|
|
570
|
+
return r == null || s == null || s > r ? s : r;
|
|
571
|
+
}
|
|
572
|
+
/** Sets HTMLElement selection */
|
|
573
|
+
_unsafeSelect(e, t) {
|
|
574
|
+
if (!this.rootElement.createRange) return;
|
|
575
|
+
const s = this.rootElement.createRange();
|
|
576
|
+
s.setStart(this.input.firstChild || this.input, e), s.setEnd(this.input.lastChild || this.input, t);
|
|
577
|
+
const r = this.rootElement, n = r.getSelection && r.getSelection();
|
|
578
|
+
n && (n.removeAllRanges(), n.addRange(s));
|
|
579
|
+
}
|
|
580
|
+
/** HTMLElement value */
|
|
581
|
+
get value() {
|
|
582
|
+
return this.input.textContent || "";
|
|
583
|
+
}
|
|
584
|
+
set value(e) {
|
|
585
|
+
this.input.textContent = e;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
F.HTMLContenteditableMaskElement = We;
|
|
589
|
+
class Ce {
|
|
590
|
+
constructor() {
|
|
591
|
+
this.states = [], this.currentIndex = 0;
|
|
592
|
+
}
|
|
593
|
+
get currentState() {
|
|
594
|
+
return this.states[this.currentIndex];
|
|
595
|
+
}
|
|
596
|
+
get isEmpty() {
|
|
597
|
+
return this.states.length === 0;
|
|
598
|
+
}
|
|
599
|
+
push(e) {
|
|
600
|
+
this.currentIndex < this.states.length - 1 && (this.states.length = this.currentIndex + 1), this.states.push(e), this.states.length > Ce.MAX_LENGTH && this.states.shift(), this.currentIndex = this.states.length - 1;
|
|
601
|
+
}
|
|
602
|
+
go(e) {
|
|
603
|
+
return this.currentIndex = Math.min(Math.max(this.currentIndex + e, 0), this.states.length - 1), this.currentState;
|
|
604
|
+
}
|
|
605
|
+
undo() {
|
|
606
|
+
return this.go(-1);
|
|
607
|
+
}
|
|
608
|
+
redo() {
|
|
609
|
+
return this.go(1);
|
|
610
|
+
}
|
|
611
|
+
clear() {
|
|
612
|
+
this.states.length = 0, this.currentIndex = 0;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
Ce.MAX_LENGTH = 100;
|
|
616
|
+
class Pt {
|
|
617
|
+
/**
|
|
618
|
+
View element
|
|
619
|
+
*/
|
|
620
|
+
/** Internal {@link Masked} model */
|
|
621
|
+
constructor(e, t) {
|
|
622
|
+
this.el = e instanceof Ve ? e : e.isContentEditable && e.tagName !== "INPUT" && e.tagName !== "TEXTAREA" ? new We(e) : new Ut(e), this.masked = Y(t), this._listeners = {}, this._value = "", this._unmaskedValue = "", this._rawInputValue = "", this.history = new Ce(), 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();
|
|
623
|
+
}
|
|
624
|
+
maskEquals(e) {
|
|
625
|
+
var t;
|
|
626
|
+
return e == null || ((t = this.masked) == null ? void 0 : t.maskEquals(e));
|
|
627
|
+
}
|
|
628
|
+
/** Masked */
|
|
629
|
+
get mask() {
|
|
630
|
+
return this.masked.mask;
|
|
631
|
+
}
|
|
632
|
+
set mask(e) {
|
|
633
|
+
if (this.maskEquals(e)) return;
|
|
634
|
+
if (!(e instanceof F.Masked) && this.masked.constructor === Ye(e)) {
|
|
635
|
+
this.masked.updateOptions({
|
|
636
|
+
mask: e
|
|
637
|
+
});
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
const t = e instanceof F.Masked ? e : Y({
|
|
641
|
+
mask: e
|
|
642
|
+
});
|
|
643
|
+
t.unmaskedValue = this.masked.unmaskedValue, this.masked = t;
|
|
644
|
+
}
|
|
645
|
+
/** Raw value */
|
|
646
|
+
get value() {
|
|
647
|
+
return this._value;
|
|
648
|
+
}
|
|
649
|
+
set value(e) {
|
|
650
|
+
this.value !== e && (this.masked.value = e, this.updateControl("auto"));
|
|
651
|
+
}
|
|
652
|
+
/** Unmasked value */
|
|
653
|
+
get unmaskedValue() {
|
|
654
|
+
return this._unmaskedValue;
|
|
655
|
+
}
|
|
656
|
+
set unmaskedValue(e) {
|
|
657
|
+
this.unmaskedValue !== e && (this.masked.unmaskedValue = e, this.updateControl("auto"));
|
|
658
|
+
}
|
|
659
|
+
/** Raw input value */
|
|
660
|
+
get rawInputValue() {
|
|
661
|
+
return this._rawInputValue;
|
|
662
|
+
}
|
|
663
|
+
set rawInputValue(e) {
|
|
664
|
+
this.rawInputValue !== e && (this.masked.rawInputValue = e, this.updateControl(), this.alignCursor());
|
|
665
|
+
}
|
|
666
|
+
/** Typed unmasked value */
|
|
667
|
+
get typedValue() {
|
|
668
|
+
return this.masked.typedValue;
|
|
669
|
+
}
|
|
670
|
+
set typedValue(e) {
|
|
671
|
+
this.masked.typedValueEquals(e) || (this.masked.typedValue = e, this.updateControl("auto"));
|
|
672
|
+
}
|
|
673
|
+
/** Display value */
|
|
674
|
+
get displayValue() {
|
|
675
|
+
return this.masked.displayValue;
|
|
676
|
+
}
|
|
677
|
+
/** Starts listening to element events */
|
|
678
|
+
_bindEvents() {
|
|
679
|
+
this.el.bindEvents({
|
|
680
|
+
selectionChange: this._saveSelection,
|
|
681
|
+
input: this._onInput,
|
|
682
|
+
drop: this._onDrop,
|
|
683
|
+
click: this._onClick,
|
|
684
|
+
focus: this._onFocus,
|
|
685
|
+
commit: this._onChange,
|
|
686
|
+
undo: this._onUndo,
|
|
687
|
+
redo: this._onRedo
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
/** Stops listening to element events */
|
|
691
|
+
_unbindEvents() {
|
|
692
|
+
this.el && this.el.unbindEvents();
|
|
693
|
+
}
|
|
694
|
+
/** Fires custom event */
|
|
695
|
+
_fireEvent(e, t) {
|
|
696
|
+
const s = this._listeners[e];
|
|
697
|
+
s && s.forEach((r) => r(t));
|
|
698
|
+
}
|
|
699
|
+
/** Current selection start */
|
|
700
|
+
get selectionStart() {
|
|
701
|
+
return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
|
|
702
|
+
}
|
|
703
|
+
/** Current cursor position */
|
|
704
|
+
get cursorPos() {
|
|
705
|
+
return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
|
|
706
|
+
}
|
|
707
|
+
set cursorPos(e) {
|
|
708
|
+
!this.el || !this.el.isActive || (this.el.select(e, e), this._saveSelection());
|
|
709
|
+
}
|
|
710
|
+
/** Stores current selection */
|
|
711
|
+
_saveSelection() {
|
|
712
|
+
this.displayValue !== this.el.value && console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."), this._selection = {
|
|
713
|
+
start: this.selectionStart,
|
|
714
|
+
end: this.cursorPos
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
/** Syncronizes model value from view */
|
|
718
|
+
updateValue() {
|
|
719
|
+
this.masked.value = this.el.value, this._value = this.masked.value, this._unmaskedValue = this.masked.unmaskedValue, this._rawInputValue = this.masked.rawInputValue;
|
|
720
|
+
}
|
|
721
|
+
/** Syncronizes view from model value, fires change events */
|
|
722
|
+
updateControl(e) {
|
|
723
|
+
const t = this.masked.unmaskedValue, s = this.masked.value, r = this.masked.rawInputValue, n = this.displayValue, a = this.unmaskedValue !== t || this.value !== s || this._rawInputValue !== r;
|
|
724
|
+
this._unmaskedValue = t, this._value = s, this._rawInputValue = r, this.el.value !== n && (this.el.value = n), e === "auto" ? this.alignCursor() : e != null && (this.cursorPos = e), a && this._fireChangeEvents(), !this._historyChanging && (a || this.history.isEmpty) && this.history.push({
|
|
725
|
+
unmaskedValue: t,
|
|
726
|
+
selection: {
|
|
727
|
+
start: this.selectionStart,
|
|
728
|
+
end: this.cursorPos
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
/** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */
|
|
733
|
+
updateOptions(e) {
|
|
734
|
+
const {
|
|
735
|
+
mask: t,
|
|
736
|
+
...s
|
|
737
|
+
} = e, r = !this.maskEquals(t), n = this.masked.optionsIsChanged(s);
|
|
738
|
+
r && (this.mask = t), n && this.masked.updateOptions(s), (r || n) && this.updateControl();
|
|
739
|
+
}
|
|
740
|
+
/** Updates cursor */
|
|
741
|
+
updateCursor(e) {
|
|
742
|
+
e != null && (this.cursorPos = e, this._delayUpdateCursor(e));
|
|
743
|
+
}
|
|
744
|
+
/** Delays cursor update to support mobile browsers */
|
|
745
|
+
_delayUpdateCursor(e) {
|
|
746
|
+
this._abortUpdateCursor(), this._changingCursorPos = e, this._cursorChanging = setTimeout(() => {
|
|
747
|
+
this.el && (this.cursorPos = this._changingCursorPos, this._abortUpdateCursor());
|
|
748
|
+
}, 10);
|
|
749
|
+
}
|
|
750
|
+
/** Fires custom events */
|
|
751
|
+
_fireChangeEvents() {
|
|
752
|
+
this._fireEvent("accept", this._inputEvent), this.masked.isComplete && this._fireEvent("complete", this._inputEvent);
|
|
753
|
+
}
|
|
754
|
+
/** Aborts delayed cursor update */
|
|
755
|
+
_abortUpdateCursor() {
|
|
756
|
+
this._cursorChanging && (clearTimeout(this._cursorChanging), delete this._cursorChanging);
|
|
757
|
+
}
|
|
758
|
+
/** Aligns cursor to nearest available position */
|
|
759
|
+
alignCursor() {
|
|
760
|
+
this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, y.LEFT));
|
|
761
|
+
}
|
|
762
|
+
/** Aligns cursor only if selection is empty */
|
|
763
|
+
alignCursorFriendly() {
|
|
764
|
+
this.selectionStart === this.cursorPos && this.alignCursor();
|
|
765
|
+
}
|
|
766
|
+
/** Adds listener on custom event */
|
|
767
|
+
on(e, t) {
|
|
768
|
+
return this._listeners[e] || (this._listeners[e] = []), this._listeners[e].push(t), this;
|
|
769
|
+
}
|
|
770
|
+
/** Removes custom event listener */
|
|
771
|
+
off(e, t) {
|
|
772
|
+
if (!this._listeners[e]) return this;
|
|
773
|
+
if (!t)
|
|
774
|
+
return delete this._listeners[e], this;
|
|
775
|
+
const s = this._listeners[e].indexOf(t);
|
|
776
|
+
return s >= 0 && this._listeners[e].splice(s, 1), this;
|
|
777
|
+
}
|
|
778
|
+
/** Handles view input event */
|
|
779
|
+
_onInput(e) {
|
|
780
|
+
this._inputEvent = e, this._abortUpdateCursor();
|
|
781
|
+
const t = new $t({
|
|
782
|
+
// new state
|
|
783
|
+
value: this.el.value,
|
|
784
|
+
cursorPos: this.cursorPos,
|
|
785
|
+
// old state
|
|
786
|
+
oldValue: this.displayValue,
|
|
787
|
+
oldSelection: this._selection
|
|
788
|
+
}), s = this.masked.rawInputValue, r = this.masked.splice(t.startChangePos, t.removed.length, t.inserted, t.removeDirection, {
|
|
789
|
+
input: !0,
|
|
790
|
+
raw: !0
|
|
791
|
+
}).offset, n = s === this.masked.rawInputValue ? t.removeDirection : y.NONE;
|
|
792
|
+
let a = this.masked.nearestInputPos(t.startChangePos + r, n);
|
|
793
|
+
n !== y.NONE && (a = this.masked.nearestInputPos(a, y.NONE)), this.updateControl(a), delete this._inputEvent;
|
|
794
|
+
}
|
|
795
|
+
/** Handles view change event and commits model value */
|
|
796
|
+
_onChange() {
|
|
797
|
+
this.displayValue !== this.el.value && this.updateValue(), this.masked.doCommit(), this.updateControl(), this._saveSelection();
|
|
798
|
+
}
|
|
799
|
+
/** Handles view drop event, prevents by default */
|
|
800
|
+
_onDrop(e) {
|
|
801
|
+
e.preventDefault(), e.stopPropagation();
|
|
802
|
+
}
|
|
803
|
+
/** Restore last selection on focus */
|
|
804
|
+
_onFocus(e) {
|
|
805
|
+
this.alignCursorFriendly();
|
|
806
|
+
}
|
|
807
|
+
/** Restore last selection on focus */
|
|
808
|
+
_onClick(e) {
|
|
809
|
+
this.alignCursorFriendly();
|
|
810
|
+
}
|
|
811
|
+
_onUndo() {
|
|
812
|
+
this._applyHistoryState(this.history.undo());
|
|
813
|
+
}
|
|
814
|
+
_onRedo() {
|
|
815
|
+
this._applyHistoryState(this.history.redo());
|
|
816
|
+
}
|
|
817
|
+
_applyHistoryState(e) {
|
|
818
|
+
e && (this._historyChanging = !0, this.unmaskedValue = e.unmaskedValue, this.el.select(e.selection.start, e.selection.end), this._saveSelection(), this._historyChanging = !1);
|
|
819
|
+
}
|
|
820
|
+
/** Unbind view events and removes element reference */
|
|
821
|
+
destroy() {
|
|
822
|
+
this._unbindEvents(), this._listeners.length = 0, delete this.el;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
F.InputMask = Pt;
|
|
826
|
+
class x {
|
|
827
|
+
/** Inserted symbols */
|
|
828
|
+
/** Additional offset if any changes occurred before tail */
|
|
829
|
+
/** Raw inserted is used by dynamic mask */
|
|
830
|
+
/** Can skip chars */
|
|
831
|
+
static normalize(e) {
|
|
832
|
+
return Array.isArray(e) ? e : [e, new x()];
|
|
833
|
+
}
|
|
834
|
+
constructor(e) {
|
|
835
|
+
Object.assign(this, {
|
|
836
|
+
inserted: "",
|
|
837
|
+
rawInserted: "",
|
|
838
|
+
tailShift: 0,
|
|
839
|
+
skip: !1
|
|
840
|
+
}, e);
|
|
841
|
+
}
|
|
842
|
+
/** Aggregate changes */
|
|
843
|
+
aggregate(e) {
|
|
844
|
+
return this.inserted += e.inserted, this.rawInserted += e.rawInserted, this.tailShift += e.tailShift, this.skip = this.skip || e.skip, this;
|
|
845
|
+
}
|
|
846
|
+
/** Total offset considering all changes */
|
|
847
|
+
get offset() {
|
|
848
|
+
return this.tailShift + this.inserted.length;
|
|
849
|
+
}
|
|
850
|
+
get consumed() {
|
|
851
|
+
return !!this.rawInserted || this.skip;
|
|
852
|
+
}
|
|
853
|
+
equals(e) {
|
|
854
|
+
return this.inserted === e.inserted && this.tailShift === e.tailShift && this.rawInserted === e.rawInserted && this.skip === e.skip;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
F.ChangeDetails = x;
|
|
858
|
+
class G {
|
|
859
|
+
/** Tail value as string */
|
|
860
|
+
/** Tail start position */
|
|
861
|
+
/** Start position */
|
|
862
|
+
constructor(e, t, s) {
|
|
863
|
+
e === void 0 && (e = ""), t === void 0 && (t = 0), this.value = e, this.from = t, this.stop = s;
|
|
864
|
+
}
|
|
865
|
+
toString() {
|
|
866
|
+
return this.value;
|
|
867
|
+
}
|
|
868
|
+
extend(e) {
|
|
869
|
+
this.value += String(e);
|
|
870
|
+
}
|
|
871
|
+
appendTo(e) {
|
|
872
|
+
return e.append(this.toString(), {
|
|
873
|
+
tail: !0
|
|
874
|
+
}).aggregate(e._appendPlaceholder());
|
|
875
|
+
}
|
|
876
|
+
get state() {
|
|
877
|
+
return {
|
|
878
|
+
value: this.value,
|
|
879
|
+
from: this.from,
|
|
880
|
+
stop: this.stop
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
set state(e) {
|
|
884
|
+
Object.assign(this, e);
|
|
885
|
+
}
|
|
886
|
+
unshift(e) {
|
|
887
|
+
if (!this.value.length || e != null && this.from >= e) return "";
|
|
888
|
+
const t = this.value[0];
|
|
889
|
+
return this.value = this.value.slice(1), t;
|
|
890
|
+
}
|
|
891
|
+
shift() {
|
|
892
|
+
if (!this.value.length) return "";
|
|
893
|
+
const e = this.value[this.value.length - 1];
|
|
894
|
+
return this.value = this.value.slice(0, -1), e;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
class L {
|
|
898
|
+
/** */
|
|
899
|
+
/** */
|
|
900
|
+
/** Transforms value before mask processing */
|
|
901
|
+
/** Transforms each char before mask processing */
|
|
902
|
+
/** Validates if value is acceptable */
|
|
903
|
+
/** Does additional processing at the end of editing */
|
|
904
|
+
/** Format typed value to string */
|
|
905
|
+
/** Parse string to get typed value */
|
|
906
|
+
/** Enable characters overwriting */
|
|
907
|
+
/** */
|
|
908
|
+
/** */
|
|
909
|
+
/** */
|
|
910
|
+
/** */
|
|
911
|
+
constructor(e) {
|
|
912
|
+
this._value = "", this._update({
|
|
913
|
+
...L.DEFAULTS,
|
|
914
|
+
...e
|
|
915
|
+
}), this._initialized = !0;
|
|
916
|
+
}
|
|
917
|
+
/** Sets and applies new options */
|
|
918
|
+
updateOptions(e) {
|
|
919
|
+
this.optionsIsChanged(e) && this.withValueRefresh(this._update.bind(this, e));
|
|
920
|
+
}
|
|
921
|
+
/** Sets new options */
|
|
922
|
+
_update(e) {
|
|
923
|
+
Object.assign(this, e);
|
|
924
|
+
}
|
|
925
|
+
/** Mask state */
|
|
926
|
+
get state() {
|
|
927
|
+
return {
|
|
928
|
+
_value: this.value,
|
|
929
|
+
_rawInputValue: this.rawInputValue
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
set state(e) {
|
|
933
|
+
this._value = e._value;
|
|
934
|
+
}
|
|
935
|
+
/** Resets value */
|
|
936
|
+
reset() {
|
|
937
|
+
this._value = "";
|
|
938
|
+
}
|
|
939
|
+
get value() {
|
|
940
|
+
return this._value;
|
|
941
|
+
}
|
|
942
|
+
set value(e) {
|
|
943
|
+
this.resolve(e, {
|
|
944
|
+
input: !0
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
/** Resolve new value */
|
|
948
|
+
resolve(e, t) {
|
|
949
|
+
t === void 0 && (t = {
|
|
950
|
+
input: !0
|
|
951
|
+
}), this.reset(), this.append(e, t, ""), this.doCommit();
|
|
952
|
+
}
|
|
953
|
+
get unmaskedValue() {
|
|
954
|
+
return this.value;
|
|
955
|
+
}
|
|
956
|
+
set unmaskedValue(e) {
|
|
957
|
+
this.resolve(e, {});
|
|
958
|
+
}
|
|
959
|
+
get typedValue() {
|
|
960
|
+
return this.parse ? this.parse(this.value, this) : this.unmaskedValue;
|
|
961
|
+
}
|
|
962
|
+
set typedValue(e) {
|
|
963
|
+
this.format ? this.value = this.format(e, this) : this.unmaskedValue = String(e);
|
|
964
|
+
}
|
|
965
|
+
/** Value that includes raw user input */
|
|
966
|
+
get rawInputValue() {
|
|
967
|
+
return this.extractInput(0, this.displayValue.length, {
|
|
968
|
+
raw: !0
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
set rawInputValue(e) {
|
|
972
|
+
this.resolve(e, {
|
|
973
|
+
raw: !0
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
get displayValue() {
|
|
977
|
+
return this.value;
|
|
978
|
+
}
|
|
979
|
+
get isComplete() {
|
|
980
|
+
return !0;
|
|
981
|
+
}
|
|
982
|
+
get isFilled() {
|
|
983
|
+
return this.isComplete;
|
|
984
|
+
}
|
|
985
|
+
/** Finds nearest input position in direction */
|
|
986
|
+
nearestInputPos(e, t) {
|
|
987
|
+
return e;
|
|
988
|
+
}
|
|
989
|
+
totalInputPositions(e, t) {
|
|
990
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), Math.min(this.displayValue.length, t - e);
|
|
991
|
+
}
|
|
992
|
+
/** Extracts value in range considering flags */
|
|
993
|
+
extractInput(e, t, s) {
|
|
994
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), this.displayValue.slice(e, t);
|
|
995
|
+
}
|
|
996
|
+
/** Extracts tail in range */
|
|
997
|
+
extractTail(e, t) {
|
|
998
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), new G(this.extractInput(e, t), e);
|
|
999
|
+
}
|
|
1000
|
+
/** Appends tail */
|
|
1001
|
+
appendTail(e) {
|
|
1002
|
+
return Q(e) && (e = new G(String(e))), e.appendTo(this);
|
|
1003
|
+
}
|
|
1004
|
+
/** Appends char */
|
|
1005
|
+
_appendCharRaw(e, t) {
|
|
1006
|
+
return e ? (this._value += e, new x({
|
|
1007
|
+
inserted: e,
|
|
1008
|
+
rawInserted: e
|
|
1009
|
+
})) : new x();
|
|
1010
|
+
}
|
|
1011
|
+
/** Appends char */
|
|
1012
|
+
_appendChar(e, t, s) {
|
|
1013
|
+
t === void 0 && (t = {});
|
|
1014
|
+
const r = this.state;
|
|
1015
|
+
let n;
|
|
1016
|
+
if ([e, n] = this.doPrepareChar(e, t), e && (n = n.aggregate(this._appendCharRaw(e, t)), !n.rawInserted && this.autofix === "pad")) {
|
|
1017
|
+
const a = this.state;
|
|
1018
|
+
this.state = r;
|
|
1019
|
+
let l = this.pad(t);
|
|
1020
|
+
const u = this._appendCharRaw(e, t);
|
|
1021
|
+
l = l.aggregate(u), u.rawInserted || l.equals(n) ? n = l : this.state = a;
|
|
1022
|
+
}
|
|
1023
|
+
if (n.inserted) {
|
|
1024
|
+
let a, l = this.doValidate(t) !== !1;
|
|
1025
|
+
if (l && s != null) {
|
|
1026
|
+
const u = this.state;
|
|
1027
|
+
if (this.overwrite === !0) {
|
|
1028
|
+
a = s.state;
|
|
1029
|
+
for (let v = 0; v < n.rawInserted.length; ++v)
|
|
1030
|
+
s.unshift(this.displayValue.length - n.tailShift);
|
|
1031
|
+
}
|
|
1032
|
+
let o = this.appendTail(s);
|
|
1033
|
+
if (l = o.rawInserted.length === s.toString().length, !(l && o.inserted) && this.overwrite === "shift") {
|
|
1034
|
+
this.state = u, a = s.state;
|
|
1035
|
+
for (let v = 0; v < n.rawInserted.length; ++v)
|
|
1036
|
+
s.shift();
|
|
1037
|
+
o = this.appendTail(s), l = o.rawInserted.length === s.toString().length;
|
|
1038
|
+
}
|
|
1039
|
+
l && o.inserted && (this.state = u);
|
|
1040
|
+
}
|
|
1041
|
+
l || (n = new x(), this.state = r, s && a && (s.state = a));
|
|
1042
|
+
}
|
|
1043
|
+
return n;
|
|
1044
|
+
}
|
|
1045
|
+
/** Appends optional placeholder at the end */
|
|
1046
|
+
_appendPlaceholder() {
|
|
1047
|
+
return new x();
|
|
1048
|
+
}
|
|
1049
|
+
/** Appends optional eager placeholder at the end */
|
|
1050
|
+
_appendEager() {
|
|
1051
|
+
return new x();
|
|
1052
|
+
}
|
|
1053
|
+
/** Appends symbols considering flags */
|
|
1054
|
+
append(e, t, s) {
|
|
1055
|
+
if (!Q(e)) throw new Error("value should be string");
|
|
1056
|
+
const r = Q(s) ? new G(String(s)) : s;
|
|
1057
|
+
t != null && t.tail && (t._beforeTailState = this.state);
|
|
1058
|
+
let n;
|
|
1059
|
+
[e, n] = this.doPrepare(e, t);
|
|
1060
|
+
for (let a = 0; a < e.length; ++a) {
|
|
1061
|
+
const l = this._appendChar(e[a], t, r);
|
|
1062
|
+
if (!l.rawInserted && !this.doSkipInvalid(e[a], t, r)) break;
|
|
1063
|
+
n.aggregate(l);
|
|
1064
|
+
}
|
|
1065
|
+
return (this.eager === !0 || this.eager === "append") && t != null && t.input && e && n.aggregate(this._appendEager()), r != null && (n.tailShift += this.appendTail(r).tailShift), n;
|
|
1066
|
+
}
|
|
1067
|
+
remove(e, t) {
|
|
1068
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), this._value = this.displayValue.slice(0, e) + this.displayValue.slice(t), new x();
|
|
1069
|
+
}
|
|
1070
|
+
/** Calls function and reapplies current value */
|
|
1071
|
+
withValueRefresh(e) {
|
|
1072
|
+
if (this._refreshing || !this._initialized) return e();
|
|
1073
|
+
this._refreshing = !0;
|
|
1074
|
+
const t = this.rawInputValue, s = this.value, r = e();
|
|
1075
|
+
return this.rawInputValue = t, this.value && this.value !== s && s.indexOf(this.value) === 0 && (this.append(s.slice(this.displayValue.length), {}, ""), this.doCommit()), delete this._refreshing, r;
|
|
1076
|
+
}
|
|
1077
|
+
runIsolated(e) {
|
|
1078
|
+
if (this._isolated || !this._initialized) return e(this);
|
|
1079
|
+
this._isolated = !0;
|
|
1080
|
+
const t = this.state, s = e(this);
|
|
1081
|
+
return this.state = t, delete this._isolated, s;
|
|
1082
|
+
}
|
|
1083
|
+
doSkipInvalid(e, t, s) {
|
|
1084
|
+
return !!this.skipInvalid;
|
|
1085
|
+
}
|
|
1086
|
+
/** Prepares string before mask processing */
|
|
1087
|
+
doPrepare(e, t) {
|
|
1088
|
+
return t === void 0 && (t = {}), x.normalize(this.prepare ? this.prepare(e, this, t) : e);
|
|
1089
|
+
}
|
|
1090
|
+
/** Prepares each char before mask processing */
|
|
1091
|
+
doPrepareChar(e, t) {
|
|
1092
|
+
return t === void 0 && (t = {}), x.normalize(this.prepareChar ? this.prepareChar(e, this, t) : e);
|
|
1093
|
+
}
|
|
1094
|
+
/** Validates if value is acceptable */
|
|
1095
|
+
doValidate(e) {
|
|
1096
|
+
return (!this.validate || this.validate(this.value, this, e)) && (!this.parent || this.parent.doValidate(e));
|
|
1097
|
+
}
|
|
1098
|
+
/** Does additional processing at the end of editing */
|
|
1099
|
+
doCommit() {
|
|
1100
|
+
this.commit && this.commit(this.value, this);
|
|
1101
|
+
}
|
|
1102
|
+
splice(e, t, s, r, n) {
|
|
1103
|
+
s === void 0 && (s = ""), r === void 0 && (r = y.NONE), n === void 0 && (n = {
|
|
1104
|
+
input: !0
|
|
1105
|
+
});
|
|
1106
|
+
const a = e + t, l = this.extractTail(a), u = this.eager === !0 || this.eager === "remove";
|
|
1107
|
+
let o;
|
|
1108
|
+
u && (r = qt(r), o = this.extractInput(0, a, {
|
|
1109
|
+
raw: !0
|
|
1110
|
+
}));
|
|
1111
|
+
let v = e;
|
|
1112
|
+
const p = new x();
|
|
1113
|
+
if (r !== y.NONE && (v = this.nearestInputPos(e, t > 1 && e !== 0 && !u ? y.NONE : r), p.tailShift = v - e), p.aggregate(this.remove(v)), u && r !== y.NONE && o === this.rawInputValue)
|
|
1114
|
+
if (r === y.FORCE_LEFT) {
|
|
1115
|
+
let m;
|
|
1116
|
+
for (; o === this.rawInputValue && (m = this.displayValue.length); )
|
|
1117
|
+
p.aggregate(new x({
|
|
1118
|
+
tailShift: -1
|
|
1119
|
+
})).aggregate(this.remove(m - 1));
|
|
1120
|
+
} else r === y.FORCE_RIGHT && l.unshift();
|
|
1121
|
+
return p.aggregate(this.append(s, n, l));
|
|
1122
|
+
}
|
|
1123
|
+
maskEquals(e) {
|
|
1124
|
+
return this.mask === e;
|
|
1125
|
+
}
|
|
1126
|
+
optionsIsChanged(e) {
|
|
1127
|
+
return !ge(this, e);
|
|
1128
|
+
}
|
|
1129
|
+
typedValueEquals(e) {
|
|
1130
|
+
const t = this.typedValue;
|
|
1131
|
+
return e === t || L.EMPTY_VALUES.includes(e) && L.EMPTY_VALUES.includes(t) || (this.format ? this.format(e, this) === this.format(this.typedValue, this) : !1);
|
|
1132
|
+
}
|
|
1133
|
+
pad(e) {
|
|
1134
|
+
return new x();
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
L.DEFAULTS = {
|
|
1138
|
+
skipInvalid: !0
|
|
1139
|
+
};
|
|
1140
|
+
L.EMPTY_VALUES = [void 0, null, ""];
|
|
1141
|
+
F.Masked = L;
|
|
1142
|
+
class ie {
|
|
1143
|
+
/** */
|
|
1144
|
+
constructor(e, t) {
|
|
1145
|
+
e === void 0 && (e = []), t === void 0 && (t = 0), this.chunks = e, this.from = t;
|
|
1146
|
+
}
|
|
1147
|
+
toString() {
|
|
1148
|
+
return this.chunks.map(String).join("");
|
|
1149
|
+
}
|
|
1150
|
+
extend(e) {
|
|
1151
|
+
if (!String(e)) return;
|
|
1152
|
+
e = Q(e) ? new G(String(e)) : e;
|
|
1153
|
+
const t = this.chunks[this.chunks.length - 1], s = t && // if stops are same or tail has no stop
|
|
1154
|
+
(t.stop === e.stop || e.stop == null) && // if tail chunk goes just after last chunk
|
|
1155
|
+
e.from === t.from + t.toString().length;
|
|
1156
|
+
if (e instanceof G)
|
|
1157
|
+
s ? t.extend(e.toString()) : this.chunks.push(e);
|
|
1158
|
+
else if (e instanceof ie) {
|
|
1159
|
+
if (e.stop == null) {
|
|
1160
|
+
let r;
|
|
1161
|
+
for (; e.chunks.length && e.chunks[0].stop == null; )
|
|
1162
|
+
r = e.chunks.shift(), r.from += e.from, this.extend(r);
|
|
1163
|
+
}
|
|
1164
|
+
e.toString() && (e.stop = e.blockIndex, this.chunks.push(e));
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
appendTo(e) {
|
|
1168
|
+
if (!(e instanceof F.MaskedPattern))
|
|
1169
|
+
return new G(this.toString()).appendTo(e);
|
|
1170
|
+
const t = new x();
|
|
1171
|
+
for (let s = 0; s < this.chunks.length; ++s) {
|
|
1172
|
+
const r = this.chunks[s], n = e._mapPosToBlock(e.displayValue.length), a = r.stop;
|
|
1173
|
+
let l;
|
|
1174
|
+
if (a != null && // if block not found or stop is behind lastBlock
|
|
1175
|
+
(!n || n.index <= a) && ((r instanceof ie || // for continuous block also check if stop is exist
|
|
1176
|
+
e._stops.indexOf(a) >= 0) && t.aggregate(e._appendPlaceholder(a)), l = r instanceof ie && e._blocks[a]), l) {
|
|
1177
|
+
const u = l.appendTail(r);
|
|
1178
|
+
t.aggregate(u);
|
|
1179
|
+
const o = r.toString().slice(u.rawInserted.length);
|
|
1180
|
+
o && t.aggregate(e.append(o, {
|
|
1181
|
+
tail: !0
|
|
1182
|
+
}));
|
|
1183
|
+
} else
|
|
1184
|
+
t.aggregate(e.append(r.toString(), {
|
|
1185
|
+
tail: !0
|
|
1186
|
+
}));
|
|
1187
|
+
}
|
|
1188
|
+
return t;
|
|
1189
|
+
}
|
|
1190
|
+
get state() {
|
|
1191
|
+
return {
|
|
1192
|
+
chunks: this.chunks.map((e) => e.state),
|
|
1193
|
+
from: this.from,
|
|
1194
|
+
stop: this.stop,
|
|
1195
|
+
blockIndex: this.blockIndex
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
set state(e) {
|
|
1199
|
+
const {
|
|
1200
|
+
chunks: t,
|
|
1201
|
+
...s
|
|
1202
|
+
} = e;
|
|
1203
|
+
Object.assign(this, s), this.chunks = t.map((r) => {
|
|
1204
|
+
const n = "chunks" in r ? new ie() : new G();
|
|
1205
|
+
return n.state = r, n;
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
unshift(e) {
|
|
1209
|
+
if (!this.chunks.length || e != null && this.from >= e) return "";
|
|
1210
|
+
const t = e != null ? e - this.from : e;
|
|
1211
|
+
let s = 0;
|
|
1212
|
+
for (; s < this.chunks.length; ) {
|
|
1213
|
+
const r = this.chunks[s], n = r.unshift(t);
|
|
1214
|
+
if (r.toString()) {
|
|
1215
|
+
if (!n) break;
|
|
1216
|
+
++s;
|
|
1217
|
+
} else
|
|
1218
|
+
this.chunks.splice(s, 1);
|
|
1219
|
+
if (n) return n;
|
|
1220
|
+
}
|
|
1221
|
+
return "";
|
|
1222
|
+
}
|
|
1223
|
+
shift() {
|
|
1224
|
+
if (!this.chunks.length) return "";
|
|
1225
|
+
let e = this.chunks.length - 1;
|
|
1226
|
+
for (; 0 <= e; ) {
|
|
1227
|
+
const t = this.chunks[e], s = t.shift();
|
|
1228
|
+
if (t.toString()) {
|
|
1229
|
+
if (!s) break;
|
|
1230
|
+
--e;
|
|
1231
|
+
} else
|
|
1232
|
+
this.chunks.splice(e, 1);
|
|
1233
|
+
if (s) return s;
|
|
1234
|
+
}
|
|
1235
|
+
return "";
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
class jt {
|
|
1239
|
+
constructor(e, t) {
|
|
1240
|
+
this.masked = e, this._log = [];
|
|
1241
|
+
const {
|
|
1242
|
+
offset: s,
|
|
1243
|
+
index: r
|
|
1244
|
+
} = e._mapPosToBlock(t) || (t < 0 ? (
|
|
1245
|
+
// first
|
|
1246
|
+
{
|
|
1247
|
+
index: 0,
|
|
1248
|
+
offset: 0
|
|
1249
|
+
}
|
|
1250
|
+
) : (
|
|
1251
|
+
// last
|
|
1252
|
+
{
|
|
1253
|
+
index: this.masked._blocks.length,
|
|
1254
|
+
offset: 0
|
|
1255
|
+
}
|
|
1256
|
+
));
|
|
1257
|
+
this.offset = s, this.index = r, this.ok = !1;
|
|
1258
|
+
}
|
|
1259
|
+
get block() {
|
|
1260
|
+
return this.masked._blocks[this.index];
|
|
1261
|
+
}
|
|
1262
|
+
get pos() {
|
|
1263
|
+
return this.masked._blockStartPos(this.index) + this.offset;
|
|
1264
|
+
}
|
|
1265
|
+
get state() {
|
|
1266
|
+
return {
|
|
1267
|
+
index: this.index,
|
|
1268
|
+
offset: this.offset,
|
|
1269
|
+
ok: this.ok
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
set state(e) {
|
|
1273
|
+
Object.assign(this, e);
|
|
1274
|
+
}
|
|
1275
|
+
pushState() {
|
|
1276
|
+
this._log.push(this.state);
|
|
1277
|
+
}
|
|
1278
|
+
popState() {
|
|
1279
|
+
const e = this._log.pop();
|
|
1280
|
+
return e && (this.state = e), e;
|
|
1281
|
+
}
|
|
1282
|
+
bindBlock() {
|
|
1283
|
+
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));
|
|
1284
|
+
}
|
|
1285
|
+
_pushLeft(e) {
|
|
1286
|
+
for (this.pushState(), this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((t = this.block) == null ? void 0 : t.displayValue.length) || 0) {
|
|
1287
|
+
var t;
|
|
1288
|
+
if (e()) return this.ok = !0;
|
|
1289
|
+
}
|
|
1290
|
+
return this.ok = !1;
|
|
1291
|
+
}
|
|
1292
|
+
_pushRight(e) {
|
|
1293
|
+
for (this.pushState(), this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0)
|
|
1294
|
+
if (e()) return this.ok = !0;
|
|
1295
|
+
return this.ok = !1;
|
|
1296
|
+
}
|
|
1297
|
+
pushLeftBeforeFilled() {
|
|
1298
|
+
return this._pushLeft(() => {
|
|
1299
|
+
if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, y.FORCE_LEFT), this.offset !== 0))
|
|
1300
|
+
return !0;
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
pushLeftBeforeInput() {
|
|
1304
|
+
return this._pushLeft(() => {
|
|
1305
|
+
if (!this.block.isFixed)
|
|
1306
|
+
return this.offset = this.block.nearestInputPos(this.offset, y.LEFT), !0;
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
1309
|
+
pushLeftBeforeRequired() {
|
|
1310
|
+
return this._pushLeft(() => {
|
|
1311
|
+
if (!(this.block.isFixed || this.block.isOptional && !this.block.value))
|
|
1312
|
+
return this.offset = this.block.nearestInputPos(this.offset, y.LEFT), !0;
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
pushRightBeforeFilled() {
|
|
1316
|
+
return this._pushRight(() => {
|
|
1317
|
+
if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, y.FORCE_RIGHT), this.offset !== this.block.value.length))
|
|
1318
|
+
return !0;
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
pushRightBeforeInput() {
|
|
1322
|
+
return this._pushRight(() => {
|
|
1323
|
+
if (!this.block.isFixed)
|
|
1324
|
+
return this.offset = this.block.nearestInputPos(this.offset, y.NONE), !0;
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
pushRightBeforeRequired() {
|
|
1328
|
+
return this._pushRight(() => {
|
|
1329
|
+
if (!(this.block.isFixed || this.block.isOptional && !this.block.value))
|
|
1330
|
+
return this.offset = this.block.nearestInputPos(this.offset, y.NONE), !0;
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
class Ze {
|
|
1335
|
+
/** */
|
|
1336
|
+
/** */
|
|
1337
|
+
/** */
|
|
1338
|
+
/** */
|
|
1339
|
+
/** */
|
|
1340
|
+
/** */
|
|
1341
|
+
constructor(e) {
|
|
1342
|
+
Object.assign(this, e), this._value = "", this.isFixed = !0;
|
|
1343
|
+
}
|
|
1344
|
+
get value() {
|
|
1345
|
+
return this._value;
|
|
1346
|
+
}
|
|
1347
|
+
get unmaskedValue() {
|
|
1348
|
+
return this.isUnmasking ? this.value : "";
|
|
1349
|
+
}
|
|
1350
|
+
get rawInputValue() {
|
|
1351
|
+
return this._isRawInput ? this.value : "";
|
|
1352
|
+
}
|
|
1353
|
+
get displayValue() {
|
|
1354
|
+
return this.value;
|
|
1355
|
+
}
|
|
1356
|
+
reset() {
|
|
1357
|
+
this._isRawInput = !1, this._value = "";
|
|
1358
|
+
}
|
|
1359
|
+
remove(e, t) {
|
|
1360
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this._value.length), this._value = this._value.slice(0, e) + this._value.slice(t), this._value || (this._isRawInput = !1), new x();
|
|
1361
|
+
}
|
|
1362
|
+
nearestInputPos(e, t) {
|
|
1363
|
+
t === void 0 && (t = y.NONE);
|
|
1364
|
+
const s = 0, r = this._value.length;
|
|
1365
|
+
switch (t) {
|
|
1366
|
+
case y.LEFT:
|
|
1367
|
+
case y.FORCE_LEFT:
|
|
1368
|
+
return s;
|
|
1369
|
+
case y.NONE:
|
|
1370
|
+
case y.RIGHT:
|
|
1371
|
+
case y.FORCE_RIGHT:
|
|
1372
|
+
default:
|
|
1373
|
+
return r;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
totalInputPositions(e, t) {
|
|
1377
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this._value.length), this._isRawInput ? t - e : 0;
|
|
1378
|
+
}
|
|
1379
|
+
extractInput(e, t, s) {
|
|
1380
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this._value.length), s === void 0 && (s = {}), s.raw && this._isRawInput && this._value.slice(e, t) || "";
|
|
1381
|
+
}
|
|
1382
|
+
get isComplete() {
|
|
1383
|
+
return !0;
|
|
1384
|
+
}
|
|
1385
|
+
get isFilled() {
|
|
1386
|
+
return !!this._value;
|
|
1387
|
+
}
|
|
1388
|
+
_appendChar(e, t) {
|
|
1389
|
+
if (t === void 0 && (t = {}), this.isFilled) return new x();
|
|
1390
|
+
const s = this.eager === !0 || this.eager === "append", n = this.char === e && (this.isUnmasking || t.input || t.raw) && (!t.raw || !s) && !t.tail, a = new x({
|
|
1391
|
+
inserted: this.char,
|
|
1392
|
+
rawInserted: n ? this.char : ""
|
|
1393
|
+
});
|
|
1394
|
+
return this._value = this.char, this._isRawInput = n && (t.raw || t.input), a;
|
|
1395
|
+
}
|
|
1396
|
+
_appendEager() {
|
|
1397
|
+
return this._appendChar(this.char, {
|
|
1398
|
+
tail: !0
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
_appendPlaceholder() {
|
|
1402
|
+
const e = new x();
|
|
1403
|
+
return this.isFilled || (this._value = e.inserted = this.char), e;
|
|
1404
|
+
}
|
|
1405
|
+
extractTail() {
|
|
1406
|
+
return new G("");
|
|
1407
|
+
}
|
|
1408
|
+
appendTail(e) {
|
|
1409
|
+
return Q(e) && (e = new G(String(e))), e.appendTo(this);
|
|
1410
|
+
}
|
|
1411
|
+
append(e, t, s) {
|
|
1412
|
+
const r = this._appendChar(e[0], t);
|
|
1413
|
+
return s != null && (r.tailShift += this.appendTail(s).tailShift), r;
|
|
1414
|
+
}
|
|
1415
|
+
doCommit() {
|
|
1416
|
+
}
|
|
1417
|
+
get state() {
|
|
1418
|
+
return {
|
|
1419
|
+
_value: this._value,
|
|
1420
|
+
_rawInputValue: this.rawInputValue
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
set state(e) {
|
|
1424
|
+
this._value = e._value, this._isRawInput = !!e._rawInputValue;
|
|
1425
|
+
}
|
|
1426
|
+
pad(e) {
|
|
1427
|
+
return this._appendPlaceholder();
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
class ve {
|
|
1431
|
+
/** */
|
|
1432
|
+
/** */
|
|
1433
|
+
/** */
|
|
1434
|
+
/** */
|
|
1435
|
+
/** */
|
|
1436
|
+
/** */
|
|
1437
|
+
/** */
|
|
1438
|
+
/** */
|
|
1439
|
+
constructor(e) {
|
|
1440
|
+
const {
|
|
1441
|
+
parent: t,
|
|
1442
|
+
isOptional: s,
|
|
1443
|
+
placeholderChar: r,
|
|
1444
|
+
displayChar: n,
|
|
1445
|
+
lazy: a,
|
|
1446
|
+
eager: l,
|
|
1447
|
+
...u
|
|
1448
|
+
} = e;
|
|
1449
|
+
this.masked = Y(u), Object.assign(this, {
|
|
1450
|
+
parent: t,
|
|
1451
|
+
isOptional: s,
|
|
1452
|
+
placeholderChar: r,
|
|
1453
|
+
displayChar: n,
|
|
1454
|
+
lazy: a,
|
|
1455
|
+
eager: l
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
reset() {
|
|
1459
|
+
this.isFilled = !1, this.masked.reset();
|
|
1460
|
+
}
|
|
1461
|
+
remove(e, t) {
|
|
1462
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.value.length), e === 0 && t >= 1 ? (this.isFilled = !1, this.masked.remove(e, t)) : new x();
|
|
1463
|
+
}
|
|
1464
|
+
get value() {
|
|
1465
|
+
return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : "");
|
|
1466
|
+
}
|
|
1467
|
+
get unmaskedValue() {
|
|
1468
|
+
return this.masked.unmaskedValue;
|
|
1469
|
+
}
|
|
1470
|
+
get rawInputValue() {
|
|
1471
|
+
return this.masked.rawInputValue;
|
|
1472
|
+
}
|
|
1473
|
+
get displayValue() {
|
|
1474
|
+
return this.masked.value && this.displayChar || this.value;
|
|
1475
|
+
}
|
|
1476
|
+
get isComplete() {
|
|
1477
|
+
return !!this.masked.value || this.isOptional;
|
|
1478
|
+
}
|
|
1479
|
+
_appendChar(e, t) {
|
|
1480
|
+
if (t === void 0 && (t = {}), this.isFilled) return new x();
|
|
1481
|
+
const s = this.masked.state;
|
|
1482
|
+
let r = this.masked._appendChar(e, this.currentMaskFlags(t));
|
|
1483
|
+
return r.inserted && this.doValidate(t) === !1 && (r = new x(), this.masked.state = s), !r.inserted && !this.isOptional && !this.lazy && !t.input && (r.inserted = this.placeholderChar), r.skip = !r.inserted && !this.isOptional, this.isFilled = !!r.inserted, r;
|
|
1484
|
+
}
|
|
1485
|
+
append(e, t, s) {
|
|
1486
|
+
return this.masked.append(e, this.currentMaskFlags(t), s);
|
|
1487
|
+
}
|
|
1488
|
+
_appendPlaceholder() {
|
|
1489
|
+
return this.isFilled || this.isOptional ? new x() : (this.isFilled = !0, new x({
|
|
1490
|
+
inserted: this.placeholderChar
|
|
1491
|
+
}));
|
|
1492
|
+
}
|
|
1493
|
+
_appendEager() {
|
|
1494
|
+
return new x();
|
|
1495
|
+
}
|
|
1496
|
+
extractTail(e, t) {
|
|
1497
|
+
return this.masked.extractTail(e, t);
|
|
1498
|
+
}
|
|
1499
|
+
appendTail(e) {
|
|
1500
|
+
return this.masked.appendTail(e);
|
|
1501
|
+
}
|
|
1502
|
+
extractInput(e, t, s) {
|
|
1503
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.value.length), this.masked.extractInput(e, t, s);
|
|
1504
|
+
}
|
|
1505
|
+
nearestInputPos(e, t) {
|
|
1506
|
+
t === void 0 && (t = y.NONE);
|
|
1507
|
+
const s = 0, r = this.value.length, n = Math.min(Math.max(e, s), r);
|
|
1508
|
+
switch (t) {
|
|
1509
|
+
case y.LEFT:
|
|
1510
|
+
case y.FORCE_LEFT:
|
|
1511
|
+
return this.isComplete ? n : s;
|
|
1512
|
+
case y.RIGHT:
|
|
1513
|
+
case y.FORCE_RIGHT:
|
|
1514
|
+
return this.isComplete ? n : r;
|
|
1515
|
+
case y.NONE:
|
|
1516
|
+
default:
|
|
1517
|
+
return n;
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
totalInputPositions(e, t) {
|
|
1521
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.value.length), this.value.slice(e, t).length;
|
|
1522
|
+
}
|
|
1523
|
+
doValidate(e) {
|
|
1524
|
+
return this.masked.doValidate(this.currentMaskFlags(e)) && (!this.parent || this.parent.doValidate(this.currentMaskFlags(e)));
|
|
1525
|
+
}
|
|
1526
|
+
doCommit() {
|
|
1527
|
+
this.masked.doCommit();
|
|
1528
|
+
}
|
|
1529
|
+
get state() {
|
|
1530
|
+
return {
|
|
1531
|
+
_value: this.value,
|
|
1532
|
+
_rawInputValue: this.rawInputValue,
|
|
1533
|
+
masked: this.masked.state,
|
|
1534
|
+
isFilled: this.isFilled
|
|
1535
|
+
};
|
|
1536
|
+
}
|
|
1537
|
+
set state(e) {
|
|
1538
|
+
this.masked.state = e.masked, this.isFilled = e.isFilled;
|
|
1539
|
+
}
|
|
1540
|
+
currentMaskFlags(e) {
|
|
1541
|
+
var t;
|
|
1542
|
+
return {
|
|
1543
|
+
...e,
|
|
1544
|
+
_beforeTailState: (e == null || (t = e._beforeTailState) == null ? void 0 : t.masked) || (e == null ? void 0 : e._beforeTailState)
|
|
1545
|
+
};
|
|
1546
|
+
}
|
|
1547
|
+
pad(e) {
|
|
1548
|
+
return new x();
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
ve.DEFAULT_DEFINITIONS = {
|
|
1552
|
+
0: /\d/,
|
|
1553
|
+
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]/,
|
|
1554
|
+
// http://stackoverflow.com/a/22075070
|
|
1555
|
+
"*": /./
|
|
1556
|
+
};
|
|
1557
|
+
class Ht extends L {
|
|
1558
|
+
/** */
|
|
1559
|
+
/** Enable characters overwriting */
|
|
1560
|
+
/** */
|
|
1561
|
+
/** */
|
|
1562
|
+
/** */
|
|
1563
|
+
updateOptions(e) {
|
|
1564
|
+
super.updateOptions(e);
|
|
1565
|
+
}
|
|
1566
|
+
_update(e) {
|
|
1567
|
+
const t = e.mask;
|
|
1568
|
+
t && (e.validate = (s) => s.search(t) >= 0), super._update(e);
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
F.MaskedRegExp = Ht;
|
|
1572
|
+
class N extends L {
|
|
1573
|
+
/** */
|
|
1574
|
+
/** */
|
|
1575
|
+
/** Single char for empty input */
|
|
1576
|
+
/** Single char for filled input */
|
|
1577
|
+
/** Show placeholder only when needed */
|
|
1578
|
+
/** Enable characters overwriting */
|
|
1579
|
+
/** */
|
|
1580
|
+
/** */
|
|
1581
|
+
/** */
|
|
1582
|
+
constructor(e) {
|
|
1583
|
+
super({
|
|
1584
|
+
...N.DEFAULTS,
|
|
1585
|
+
...e,
|
|
1586
|
+
definitions: Object.assign({}, ve.DEFAULT_DEFINITIONS, e == null ? void 0 : e.definitions)
|
|
1587
|
+
});
|
|
1588
|
+
}
|
|
1589
|
+
updateOptions(e) {
|
|
1590
|
+
super.updateOptions(e);
|
|
1591
|
+
}
|
|
1592
|
+
_update(e) {
|
|
1593
|
+
e.definitions = Object.assign({}, this.definitions, e.definitions), super._update(e), this._rebuildMask();
|
|
1594
|
+
}
|
|
1595
|
+
_rebuildMask() {
|
|
1596
|
+
const e = this.definitions;
|
|
1597
|
+
this._blocks = [], this.exposeBlock = void 0, this._stops = [], this._maskedBlocks = {};
|
|
1598
|
+
const t = this.mask;
|
|
1599
|
+
if (!t || !e) return;
|
|
1600
|
+
let s = !1, r = !1;
|
|
1601
|
+
for (let n = 0; n < t.length; ++n) {
|
|
1602
|
+
if (this.blocks) {
|
|
1603
|
+
const o = t.slice(n), v = Object.keys(this.blocks).filter((m) => o.indexOf(m) === 0);
|
|
1604
|
+
v.sort((m, E) => E.length - m.length);
|
|
1605
|
+
const p = v[0];
|
|
1606
|
+
if (p) {
|
|
1607
|
+
const {
|
|
1608
|
+
expose: m,
|
|
1609
|
+
repeat: E,
|
|
1610
|
+
...b
|
|
1611
|
+
} = pe(this.blocks[p]), S = {
|
|
1612
|
+
lazy: this.lazy,
|
|
1613
|
+
eager: this.eager,
|
|
1614
|
+
placeholderChar: this.placeholderChar,
|
|
1615
|
+
displayChar: this.displayChar,
|
|
1616
|
+
overwrite: this.overwrite,
|
|
1617
|
+
autofix: this.autofix,
|
|
1618
|
+
...b,
|
|
1619
|
+
repeat: E,
|
|
1620
|
+
parent: this
|
|
1621
|
+
}, M = E != null ? new F.RepeatBlock(
|
|
1622
|
+
S
|
|
1623
|
+
/* TODO */
|
|
1624
|
+
) : Y(S);
|
|
1625
|
+
M && (this._blocks.push(M), m && (this.exposeBlock = M), this._maskedBlocks[p] || (this._maskedBlocks[p] = []), this._maskedBlocks[p].push(this._blocks.length - 1)), n += p.length - 1;
|
|
1626
|
+
continue;
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
let a = t[n], l = a in e;
|
|
1630
|
+
if (a === N.STOP_CHAR) {
|
|
1631
|
+
this._stops.push(this._blocks.length);
|
|
1632
|
+
continue;
|
|
1633
|
+
}
|
|
1634
|
+
if (a === "{" || a === "}") {
|
|
1635
|
+
s = !s;
|
|
1636
|
+
continue;
|
|
1637
|
+
}
|
|
1638
|
+
if (a === "[" || a === "]") {
|
|
1639
|
+
r = !r;
|
|
1640
|
+
continue;
|
|
1641
|
+
}
|
|
1642
|
+
if (a === N.ESCAPE_CHAR) {
|
|
1643
|
+
if (++n, a = t[n], !a) break;
|
|
1644
|
+
l = !1;
|
|
1645
|
+
}
|
|
1646
|
+
const u = l ? new ve({
|
|
1647
|
+
isOptional: r,
|
|
1648
|
+
lazy: this.lazy,
|
|
1649
|
+
eager: this.eager,
|
|
1650
|
+
placeholderChar: this.placeholderChar,
|
|
1651
|
+
displayChar: this.displayChar,
|
|
1652
|
+
...pe(e[a]),
|
|
1653
|
+
parent: this
|
|
1654
|
+
}) : new Ze({
|
|
1655
|
+
char: a,
|
|
1656
|
+
eager: this.eager,
|
|
1657
|
+
isUnmasking: s
|
|
1658
|
+
});
|
|
1659
|
+
this._blocks.push(u);
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
get state() {
|
|
1663
|
+
return {
|
|
1664
|
+
...super.state,
|
|
1665
|
+
_blocks: this._blocks.map((e) => e.state)
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
set state(e) {
|
|
1669
|
+
if (!e) {
|
|
1670
|
+
this.reset();
|
|
1671
|
+
return;
|
|
1672
|
+
}
|
|
1673
|
+
const {
|
|
1674
|
+
_blocks: t,
|
|
1675
|
+
...s
|
|
1676
|
+
} = e;
|
|
1677
|
+
this._blocks.forEach((r, n) => r.state = t[n]), super.state = s;
|
|
1678
|
+
}
|
|
1679
|
+
reset() {
|
|
1680
|
+
super.reset(), this._blocks.forEach((e) => e.reset());
|
|
1681
|
+
}
|
|
1682
|
+
get isComplete() {
|
|
1683
|
+
return this.exposeBlock ? this.exposeBlock.isComplete : this._blocks.every((e) => e.isComplete);
|
|
1684
|
+
}
|
|
1685
|
+
get isFilled() {
|
|
1686
|
+
return this._blocks.every((e) => e.isFilled);
|
|
1687
|
+
}
|
|
1688
|
+
get isFixed() {
|
|
1689
|
+
return this._blocks.every((e) => e.isFixed);
|
|
1690
|
+
}
|
|
1691
|
+
get isOptional() {
|
|
1692
|
+
return this._blocks.every((e) => e.isOptional);
|
|
1693
|
+
}
|
|
1694
|
+
doCommit() {
|
|
1695
|
+
this._blocks.forEach((e) => e.doCommit()), super.doCommit();
|
|
1696
|
+
}
|
|
1697
|
+
get unmaskedValue() {
|
|
1698
|
+
return this.exposeBlock ? this.exposeBlock.unmaskedValue : this._blocks.reduce((e, t) => e += t.unmaskedValue, "");
|
|
1699
|
+
}
|
|
1700
|
+
set unmaskedValue(e) {
|
|
1701
|
+
if (this.exposeBlock) {
|
|
1702
|
+
const t = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
|
|
1703
|
+
this.exposeBlock.unmaskedValue = e, this.appendTail(t), this.doCommit();
|
|
1704
|
+
} else super.unmaskedValue = e;
|
|
1705
|
+
}
|
|
1706
|
+
get value() {
|
|
1707
|
+
return this.exposeBlock ? this.exposeBlock.value : (
|
|
1708
|
+
// TODO return _value when not in change?
|
|
1709
|
+
this._blocks.reduce((e, t) => e += t.value, "")
|
|
1710
|
+
);
|
|
1711
|
+
}
|
|
1712
|
+
set value(e) {
|
|
1713
|
+
if (this.exposeBlock) {
|
|
1714
|
+
const t = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
|
|
1715
|
+
this.exposeBlock.value = e, this.appendTail(t), this.doCommit();
|
|
1716
|
+
} else super.value = e;
|
|
1717
|
+
}
|
|
1718
|
+
get typedValue() {
|
|
1719
|
+
return this.exposeBlock ? this.exposeBlock.typedValue : super.typedValue;
|
|
1720
|
+
}
|
|
1721
|
+
set typedValue(e) {
|
|
1722
|
+
if (this.exposeBlock) {
|
|
1723
|
+
const t = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
|
|
1724
|
+
this.exposeBlock.typedValue = e, this.appendTail(t), this.doCommit();
|
|
1725
|
+
} else super.typedValue = e;
|
|
1726
|
+
}
|
|
1727
|
+
get displayValue() {
|
|
1728
|
+
return this._blocks.reduce((e, t) => e += t.displayValue, "");
|
|
1729
|
+
}
|
|
1730
|
+
appendTail(e) {
|
|
1731
|
+
return super.appendTail(e).aggregate(this._appendPlaceholder());
|
|
1732
|
+
}
|
|
1733
|
+
_appendEager() {
|
|
1734
|
+
var e;
|
|
1735
|
+
const t = new x();
|
|
1736
|
+
let s = (e = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : e.index;
|
|
1737
|
+
if (s == null) return t;
|
|
1738
|
+
this._blocks[s].isFilled && ++s;
|
|
1739
|
+
for (let r = s; r < this._blocks.length; ++r) {
|
|
1740
|
+
const n = this._blocks[r]._appendEager();
|
|
1741
|
+
if (!n.inserted) break;
|
|
1742
|
+
t.aggregate(n);
|
|
1743
|
+
}
|
|
1744
|
+
return t;
|
|
1745
|
+
}
|
|
1746
|
+
_appendCharRaw(e, t) {
|
|
1747
|
+
t === void 0 && (t = {});
|
|
1748
|
+
const s = this._mapPosToBlock(this.displayValue.length), r = new x();
|
|
1749
|
+
if (!s) return r;
|
|
1750
|
+
for (let a = s.index, l; l = this._blocks[a]; ++a) {
|
|
1751
|
+
var n;
|
|
1752
|
+
const u = l._appendChar(e, {
|
|
1753
|
+
...t,
|
|
1754
|
+
_beforeTailState: (n = t._beforeTailState) == null || (n = n._blocks) == null ? void 0 : n[a]
|
|
1755
|
+
});
|
|
1756
|
+
if (r.aggregate(u), u.consumed) break;
|
|
1757
|
+
}
|
|
1758
|
+
return r;
|
|
1759
|
+
}
|
|
1760
|
+
extractTail(e, t) {
|
|
1761
|
+
e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length);
|
|
1762
|
+
const s = new ie();
|
|
1763
|
+
return e === t || this._forEachBlocksInRange(e, t, (r, n, a, l) => {
|
|
1764
|
+
const u = r.extractTail(a, l);
|
|
1765
|
+
u.stop = this._findStopBefore(n), u.from = this._blockStartPos(n), u instanceof ie && (u.blockIndex = n), s.extend(u);
|
|
1766
|
+
}), s;
|
|
1767
|
+
}
|
|
1768
|
+
extractInput(e, t, s) {
|
|
1769
|
+
if (e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), s === void 0 && (s = {}), e === t) return "";
|
|
1770
|
+
let r = "";
|
|
1771
|
+
return this._forEachBlocksInRange(e, t, (n, a, l, u) => {
|
|
1772
|
+
r += n.extractInput(l, u, s);
|
|
1773
|
+
}), r;
|
|
1774
|
+
}
|
|
1775
|
+
_findStopBefore(e) {
|
|
1776
|
+
let t;
|
|
1777
|
+
for (let s = 0; s < this._stops.length; ++s) {
|
|
1778
|
+
const r = this._stops[s];
|
|
1779
|
+
if (r <= e) t = r;
|
|
1780
|
+
else break;
|
|
1781
|
+
}
|
|
1782
|
+
return t;
|
|
1783
|
+
}
|
|
1784
|
+
/** Appends placeholder depending on laziness */
|
|
1785
|
+
_appendPlaceholder(e) {
|
|
1786
|
+
const t = new x();
|
|
1787
|
+
if (this.lazy && e == null) return t;
|
|
1788
|
+
const s = this._mapPosToBlock(this.displayValue.length);
|
|
1789
|
+
if (!s) return t;
|
|
1790
|
+
const r = s.index, n = e ?? this._blocks.length;
|
|
1791
|
+
return this._blocks.slice(r, n).forEach((a) => {
|
|
1792
|
+
if (!a.lazy || e != null) {
|
|
1793
|
+
var l;
|
|
1794
|
+
t.aggregate(a._appendPlaceholder((l = a._blocks) == null ? void 0 : l.length));
|
|
1795
|
+
}
|
|
1796
|
+
}), t;
|
|
1797
|
+
}
|
|
1798
|
+
/** Finds block in pos */
|
|
1799
|
+
_mapPosToBlock(e) {
|
|
1800
|
+
let t = "";
|
|
1801
|
+
for (let s = 0; s < this._blocks.length; ++s) {
|
|
1802
|
+
const r = this._blocks[s], n = t.length;
|
|
1803
|
+
if (t += r.displayValue, e <= t.length)
|
|
1804
|
+
return {
|
|
1805
|
+
index: s,
|
|
1806
|
+
offset: e - n
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
_blockStartPos(e) {
|
|
1811
|
+
return this._blocks.slice(0, e).reduce((t, s) => t += s.displayValue.length, 0);
|
|
1812
|
+
}
|
|
1813
|
+
_forEachBlocksInRange(e, t, s) {
|
|
1814
|
+
t === void 0 && (t = this.displayValue.length);
|
|
1815
|
+
const r = this._mapPosToBlock(e);
|
|
1816
|
+
if (r) {
|
|
1817
|
+
const n = this._mapPosToBlock(t), a = n && r.index === n.index, l = r.offset, u = n && a ? n.offset : this._blocks[r.index].displayValue.length;
|
|
1818
|
+
if (s(this._blocks[r.index], r.index, l, u), n && !a) {
|
|
1819
|
+
for (let o = r.index + 1; o < n.index; ++o)
|
|
1820
|
+
s(this._blocks[o], o, 0, this._blocks[o].displayValue.length);
|
|
1821
|
+
s(this._blocks[n.index], n.index, 0, n.offset);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
remove(e, t) {
|
|
1826
|
+
e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length);
|
|
1827
|
+
const s = super.remove(e, t);
|
|
1828
|
+
return this._forEachBlocksInRange(e, t, (r, n, a, l) => {
|
|
1829
|
+
s.aggregate(r.remove(a, l));
|
|
1830
|
+
}), s;
|
|
1831
|
+
}
|
|
1832
|
+
nearestInputPos(e, t) {
|
|
1833
|
+
if (t === void 0 && (t = y.NONE), !this._blocks.length) return 0;
|
|
1834
|
+
const s = new jt(this, e);
|
|
1835
|
+
if (t === y.NONE)
|
|
1836
|
+
return s.pushRightBeforeInput() || (s.popState(), s.pushLeftBeforeInput()) ? s.pos : this.displayValue.length;
|
|
1837
|
+
if (t === y.LEFT || t === y.FORCE_LEFT) {
|
|
1838
|
+
if (t === y.LEFT) {
|
|
1839
|
+
if (s.pushRightBeforeFilled(), s.ok && s.pos === e) return e;
|
|
1840
|
+
s.popState();
|
|
1841
|
+
}
|
|
1842
|
+
if (s.pushLeftBeforeInput(), s.pushLeftBeforeRequired(), s.pushLeftBeforeFilled(), t === y.LEFT) {
|
|
1843
|
+
if (s.pushRightBeforeInput(), s.pushRightBeforeRequired(), s.ok && s.pos <= e || (s.popState(), s.ok && s.pos <= e)) return s.pos;
|
|
1844
|
+
s.popState();
|
|
1845
|
+
}
|
|
1846
|
+
return s.ok ? s.pos : t === y.FORCE_LEFT ? 0 : (s.popState(), s.ok || (s.popState(), s.ok) ? s.pos : 0);
|
|
1847
|
+
}
|
|
1848
|
+
return t === y.RIGHT || t === y.FORCE_RIGHT ? (s.pushRightBeforeInput(), s.pushRightBeforeRequired(), s.pushRightBeforeFilled() ? s.pos : t === y.FORCE_RIGHT ? this.displayValue.length : (s.popState(), s.ok || (s.popState(), s.ok) ? s.pos : this.nearestInputPos(e, y.LEFT))) : e;
|
|
1849
|
+
}
|
|
1850
|
+
totalInputPositions(e, t) {
|
|
1851
|
+
e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length);
|
|
1852
|
+
let s = 0;
|
|
1853
|
+
return this._forEachBlocksInRange(e, t, (r, n, a, l) => {
|
|
1854
|
+
s += r.totalInputPositions(a, l);
|
|
1855
|
+
}), s;
|
|
1856
|
+
}
|
|
1857
|
+
/** Get block by name */
|
|
1858
|
+
maskedBlock(e) {
|
|
1859
|
+
return this.maskedBlocks(e)[0];
|
|
1860
|
+
}
|
|
1861
|
+
/** Get all blocks by name */
|
|
1862
|
+
maskedBlocks(e) {
|
|
1863
|
+
const t = this._maskedBlocks[e];
|
|
1864
|
+
return t ? t.map((s) => this._blocks[s]) : [];
|
|
1865
|
+
}
|
|
1866
|
+
pad(e) {
|
|
1867
|
+
const t = new x();
|
|
1868
|
+
return this._forEachBlocksInRange(0, this.displayValue.length, (s) => t.aggregate(s.pad(e))), t;
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
N.DEFAULTS = {
|
|
1872
|
+
...L.DEFAULTS,
|
|
1873
|
+
lazy: !0,
|
|
1874
|
+
placeholderChar: "_"
|
|
1875
|
+
};
|
|
1876
|
+
N.STOP_CHAR = "`";
|
|
1877
|
+
N.ESCAPE_CHAR = "\\";
|
|
1878
|
+
N.InputDefinition = ve;
|
|
1879
|
+
N.FixedDefinition = Ze;
|
|
1880
|
+
F.MaskedPattern = N;
|
|
1881
|
+
class fe extends N {
|
|
1882
|
+
/**
|
|
1883
|
+
Optionally sets max length of pattern.
|
|
1884
|
+
Used when pattern length is longer then `to` param length. Pads zeros at start in this case.
|
|
1885
|
+
*/
|
|
1886
|
+
/** Min bound */
|
|
1887
|
+
/** Max bound */
|
|
1888
|
+
get _matchFrom() {
|
|
1889
|
+
return this.maxLength - String(this.from).length;
|
|
1890
|
+
}
|
|
1891
|
+
constructor(e) {
|
|
1892
|
+
super(e);
|
|
1893
|
+
}
|
|
1894
|
+
updateOptions(e) {
|
|
1895
|
+
super.updateOptions(e);
|
|
1896
|
+
}
|
|
1897
|
+
_update(e) {
|
|
1898
|
+
const {
|
|
1899
|
+
to: t = this.to || 0,
|
|
1900
|
+
from: s = this.from || 0,
|
|
1901
|
+
maxLength: r = this.maxLength || 0,
|
|
1902
|
+
autofix: n = this.autofix,
|
|
1903
|
+
...a
|
|
1904
|
+
} = e;
|
|
1905
|
+
this.to = t, this.from = s, this.maxLength = Math.max(String(t).length, r), this.autofix = n;
|
|
1906
|
+
const l = String(this.from).padStart(this.maxLength, "0"), u = String(this.to).padStart(this.maxLength, "0");
|
|
1907
|
+
let o = 0;
|
|
1908
|
+
for (; o < u.length && u[o] === l[o]; ) ++o;
|
|
1909
|
+
a.mask = u.slice(0, o).replace(/0/g, "\\0") + "0".repeat(this.maxLength - o), super._update(a);
|
|
1910
|
+
}
|
|
1911
|
+
get isComplete() {
|
|
1912
|
+
return super.isComplete && !!this.value;
|
|
1913
|
+
}
|
|
1914
|
+
boundaries(e) {
|
|
1915
|
+
let t = "", s = "";
|
|
1916
|
+
const [, r, n] = e.match(/^(\D*)(\d*)(\D*)/) || [];
|
|
1917
|
+
return n && (t = "0".repeat(r.length) + n, s = "9".repeat(r.length) + n), t = t.padEnd(this.maxLength, "0"), s = s.padEnd(this.maxLength, "9"), [t, s];
|
|
1918
|
+
}
|
|
1919
|
+
doPrepareChar(e, t) {
|
|
1920
|
+
t === void 0 && (t = {});
|
|
1921
|
+
let s;
|
|
1922
|
+
return [e, s] = super.doPrepareChar(e.replace(/\D/g, ""), t), e || (s.skip = !this.isComplete), [e, s];
|
|
1923
|
+
}
|
|
1924
|
+
_appendCharRaw(e, t) {
|
|
1925
|
+
if (t === void 0 && (t = {}), !this.autofix || this.value.length + 1 > this.maxLength) return super._appendCharRaw(e, t);
|
|
1926
|
+
const s = String(this.from).padStart(this.maxLength, "0"), r = String(this.to).padStart(this.maxLength, "0"), [n, a] = this.boundaries(this.value + e);
|
|
1927
|
+
return Number(a) < this.from ? super._appendCharRaw(s[this.value.length], t) : Number(n) > this.to ? !t.tail && this.autofix === "pad" && this.value.length + 1 < this.maxLength ? super._appendCharRaw(s[this.value.length], t).aggregate(this._appendCharRaw(e, t)) : super._appendCharRaw(r[this.value.length], t) : super._appendCharRaw(e, t);
|
|
1928
|
+
}
|
|
1929
|
+
doValidate(e) {
|
|
1930
|
+
const t = this.value;
|
|
1931
|
+
if (t.search(/[^0]/) === -1 && t.length <= this._matchFrom) return !0;
|
|
1932
|
+
const [r, n] = this.boundaries(t);
|
|
1933
|
+
return this.from <= Number(n) && Number(r) <= this.to && super.doValidate(e);
|
|
1934
|
+
}
|
|
1935
|
+
pad(e) {
|
|
1936
|
+
const t = new x();
|
|
1937
|
+
if (this.value.length === this.maxLength) return t;
|
|
1938
|
+
const s = this.value, r = this.maxLength - this.value.length;
|
|
1939
|
+
if (r) {
|
|
1940
|
+
this.reset();
|
|
1941
|
+
for (let n = 0; n < r; ++n)
|
|
1942
|
+
t.aggregate(super._appendCharRaw("0", e));
|
|
1943
|
+
s.split("").forEach((n) => this._appendCharRaw(n));
|
|
1944
|
+
}
|
|
1945
|
+
return t;
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
F.MaskedRange = fe;
|
|
1949
|
+
const Gt = "d{.}`m{.}`Y";
|
|
1950
|
+
class K extends N {
|
|
1951
|
+
static extractPatternOptions(e) {
|
|
1952
|
+
const {
|
|
1953
|
+
mask: t,
|
|
1954
|
+
pattern: s,
|
|
1955
|
+
...r
|
|
1956
|
+
} = e;
|
|
1957
|
+
return {
|
|
1958
|
+
...r,
|
|
1959
|
+
mask: Q(t) ? t : s
|
|
1960
|
+
};
|
|
1961
|
+
}
|
|
1962
|
+
/** Pattern mask for date according to {@link MaskedDate#format} */
|
|
1963
|
+
/** Start date */
|
|
1964
|
+
/** End date */
|
|
1965
|
+
/** Format typed value to string */
|
|
1966
|
+
/** Parse string to get typed value */
|
|
1967
|
+
constructor(e) {
|
|
1968
|
+
super(K.extractPatternOptions({
|
|
1969
|
+
...K.DEFAULTS,
|
|
1970
|
+
...e
|
|
1971
|
+
}));
|
|
1972
|
+
}
|
|
1973
|
+
updateOptions(e) {
|
|
1974
|
+
super.updateOptions(e);
|
|
1975
|
+
}
|
|
1976
|
+
_update(e) {
|
|
1977
|
+
const {
|
|
1978
|
+
mask: t,
|
|
1979
|
+
pattern: s,
|
|
1980
|
+
blocks: r,
|
|
1981
|
+
...n
|
|
1982
|
+
} = {
|
|
1983
|
+
...K.DEFAULTS,
|
|
1984
|
+
...e
|
|
1985
|
+
}, a = Object.assign({}, K.GET_DEFAULT_BLOCKS());
|
|
1986
|
+
e.min && (a.Y.from = e.min.getFullYear()), e.max && (a.Y.to = e.max.getFullYear()), e.min && e.max && a.Y.from === a.Y.to && (a.m.from = e.min.getMonth() + 1, a.m.to = e.max.getMonth() + 1, a.m.from === a.m.to && (a.d.from = e.min.getDate(), a.d.to = e.max.getDate())), Object.assign(a, this.blocks, r), super._update({
|
|
1987
|
+
...n,
|
|
1988
|
+
mask: Q(t) ? t : s,
|
|
1989
|
+
blocks: a
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
doValidate(e) {
|
|
1993
|
+
const t = this.date;
|
|
1994
|
+
return super.doValidate(e) && (!this.isComplete || this.isDateExist(this.value) && t != null && (this.min == null || this.min <= t) && (this.max == null || t <= this.max));
|
|
1995
|
+
}
|
|
1996
|
+
/** Checks if date is exists */
|
|
1997
|
+
isDateExist(e) {
|
|
1998
|
+
return this.format(this.parse(e, this), this).indexOf(e) >= 0;
|
|
1999
|
+
}
|
|
2000
|
+
/** Parsed Date */
|
|
2001
|
+
get date() {
|
|
2002
|
+
return this.typedValue;
|
|
2003
|
+
}
|
|
2004
|
+
set date(e) {
|
|
2005
|
+
this.typedValue = e;
|
|
2006
|
+
}
|
|
2007
|
+
get typedValue() {
|
|
2008
|
+
return this.isComplete ? super.typedValue : null;
|
|
2009
|
+
}
|
|
2010
|
+
set typedValue(e) {
|
|
2011
|
+
super.typedValue = e;
|
|
2012
|
+
}
|
|
2013
|
+
maskEquals(e) {
|
|
2014
|
+
return e === Date || super.maskEquals(e);
|
|
2015
|
+
}
|
|
2016
|
+
optionsIsChanged(e) {
|
|
2017
|
+
return super.optionsIsChanged(K.extractPatternOptions(e));
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
K.GET_DEFAULT_BLOCKS = () => ({
|
|
2021
|
+
d: {
|
|
2022
|
+
mask: fe,
|
|
2023
|
+
from: 1,
|
|
2024
|
+
to: 31,
|
|
2025
|
+
maxLength: 2
|
|
2026
|
+
},
|
|
2027
|
+
m: {
|
|
2028
|
+
mask: fe,
|
|
2029
|
+
from: 1,
|
|
2030
|
+
to: 12,
|
|
2031
|
+
maxLength: 2
|
|
2032
|
+
},
|
|
2033
|
+
Y: {
|
|
2034
|
+
mask: fe,
|
|
2035
|
+
from: 1900,
|
|
2036
|
+
to: 9999
|
|
2037
|
+
}
|
|
2038
|
+
});
|
|
2039
|
+
K.DEFAULTS = {
|
|
2040
|
+
...N.DEFAULTS,
|
|
2041
|
+
mask: Date,
|
|
2042
|
+
pattern: Gt,
|
|
2043
|
+
format: (i, e) => {
|
|
2044
|
+
if (!i) return "";
|
|
2045
|
+
const t = String(i.getDate()).padStart(2, "0"), s = String(i.getMonth() + 1).padStart(2, "0"), r = i.getFullYear();
|
|
2046
|
+
return [t, s, r].join(".");
|
|
2047
|
+
},
|
|
2048
|
+
parse: (i, e) => {
|
|
2049
|
+
const [t, s, r] = i.split(".").map(Number);
|
|
2050
|
+
return new Date(r, s - 1, t);
|
|
2051
|
+
}
|
|
2052
|
+
};
|
|
2053
|
+
F.MaskedDate = K;
|
|
2054
|
+
class ye extends L {
|
|
2055
|
+
constructor(e) {
|
|
2056
|
+
super({
|
|
2057
|
+
...ye.DEFAULTS,
|
|
2058
|
+
...e
|
|
2059
|
+
}), this.currentMask = void 0;
|
|
2060
|
+
}
|
|
2061
|
+
updateOptions(e) {
|
|
2062
|
+
super.updateOptions(e);
|
|
2063
|
+
}
|
|
2064
|
+
_update(e) {
|
|
2065
|
+
super._update(e), "mask" in e && (this.exposeMask = void 0, this.compiledMasks = Array.isArray(e.mask) ? e.mask.map((t) => {
|
|
2066
|
+
const {
|
|
2067
|
+
expose: s,
|
|
2068
|
+
...r
|
|
2069
|
+
} = pe(t), n = Y({
|
|
2070
|
+
overwrite: this._overwrite,
|
|
2071
|
+
eager: this._eager,
|
|
2072
|
+
skipInvalid: this._skipInvalid,
|
|
2073
|
+
...r
|
|
2074
|
+
});
|
|
2075
|
+
return s && (this.exposeMask = n), n;
|
|
2076
|
+
}) : []);
|
|
2077
|
+
}
|
|
2078
|
+
_appendCharRaw(e, t) {
|
|
2079
|
+
t === void 0 && (t = {});
|
|
2080
|
+
const s = this._applyDispatch(e, t);
|
|
2081
|
+
return this.currentMask && s.aggregate(this.currentMask._appendChar(e, this.currentMaskFlags(t))), s;
|
|
2082
|
+
}
|
|
2083
|
+
_applyDispatch(e, t, s) {
|
|
2084
|
+
e === void 0 && (e = ""), t === void 0 && (t = {}), s === void 0 && (s = "");
|
|
2085
|
+
const r = t.tail && t._beforeTailState != null ? t._beforeTailState._value : this.value, n = this.rawInputValue, a = t.tail && t._beforeTailState != null ? t._beforeTailState._rawInputValue : n, l = n.slice(a.length), u = this.currentMask, o = new x(), v = u == null ? void 0 : u.state;
|
|
2086
|
+
return this.currentMask = this.doDispatch(e, {
|
|
2087
|
+
...t
|
|
2088
|
+
}, s), this.currentMask && (this.currentMask !== u ? (this.currentMask.reset(), a && (this.currentMask.append(a, {
|
|
2089
|
+
raw: !0
|
|
2090
|
+
}), o.tailShift = this.currentMask.value.length - r.length), l && (o.tailShift += this.currentMask.append(l, {
|
|
2091
|
+
raw: !0,
|
|
2092
|
+
tail: !0
|
|
2093
|
+
}).tailShift)) : v && (this.currentMask.state = v)), o;
|
|
2094
|
+
}
|
|
2095
|
+
_appendPlaceholder() {
|
|
2096
|
+
const e = this._applyDispatch();
|
|
2097
|
+
return this.currentMask && e.aggregate(this.currentMask._appendPlaceholder()), e;
|
|
2098
|
+
}
|
|
2099
|
+
_appendEager() {
|
|
2100
|
+
const e = this._applyDispatch();
|
|
2101
|
+
return this.currentMask && e.aggregate(this.currentMask._appendEager()), e;
|
|
2102
|
+
}
|
|
2103
|
+
appendTail(e) {
|
|
2104
|
+
const t = new x();
|
|
2105
|
+
return e && t.aggregate(this._applyDispatch("", {}, e)), t.aggregate(this.currentMask ? this.currentMask.appendTail(e) : super.appendTail(e));
|
|
2106
|
+
}
|
|
2107
|
+
currentMaskFlags(e) {
|
|
2108
|
+
var t, s;
|
|
2109
|
+
return {
|
|
2110
|
+
...e,
|
|
2111
|
+
_beforeTailState: ((t = e._beforeTailState) == null ? void 0 : t.currentMaskRef) === this.currentMask && ((s = e._beforeTailState) == null ? void 0 : s.currentMask) || e._beforeTailState
|
|
2112
|
+
};
|
|
2113
|
+
}
|
|
2114
|
+
doDispatch(e, t, s) {
|
|
2115
|
+
return t === void 0 && (t = {}), s === void 0 && (s = ""), this.dispatch(e, this, t, s);
|
|
2116
|
+
}
|
|
2117
|
+
doValidate(e) {
|
|
2118
|
+
return super.doValidate(e) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(e)));
|
|
2119
|
+
}
|
|
2120
|
+
doPrepare(e, t) {
|
|
2121
|
+
t === void 0 && (t = {});
|
|
2122
|
+
let [s, r] = super.doPrepare(e, t);
|
|
2123
|
+
if (this.currentMask) {
|
|
2124
|
+
let n;
|
|
2125
|
+
[s, n] = super.doPrepare(s, this.currentMaskFlags(t)), r = r.aggregate(n);
|
|
2126
|
+
}
|
|
2127
|
+
return [s, r];
|
|
2128
|
+
}
|
|
2129
|
+
doPrepareChar(e, t) {
|
|
2130
|
+
t === void 0 && (t = {});
|
|
2131
|
+
let [s, r] = super.doPrepareChar(e, t);
|
|
2132
|
+
if (this.currentMask) {
|
|
2133
|
+
let n;
|
|
2134
|
+
[s, n] = super.doPrepareChar(s, this.currentMaskFlags(t)), r = r.aggregate(n);
|
|
2135
|
+
}
|
|
2136
|
+
return [s, r];
|
|
2137
|
+
}
|
|
2138
|
+
reset() {
|
|
2139
|
+
var e;
|
|
2140
|
+
(e = this.currentMask) == null || e.reset(), this.compiledMasks.forEach((t) => t.reset());
|
|
2141
|
+
}
|
|
2142
|
+
get value() {
|
|
2143
|
+
return this.exposeMask ? this.exposeMask.value : this.currentMask ? this.currentMask.value : "";
|
|
2144
|
+
}
|
|
2145
|
+
set value(e) {
|
|
2146
|
+
this.exposeMask ? (this.exposeMask.value = e, this.currentMask = this.exposeMask, this._applyDispatch()) : super.value = e;
|
|
2147
|
+
}
|
|
2148
|
+
get unmaskedValue() {
|
|
2149
|
+
return this.exposeMask ? this.exposeMask.unmaskedValue : this.currentMask ? this.currentMask.unmaskedValue : "";
|
|
2150
|
+
}
|
|
2151
|
+
set unmaskedValue(e) {
|
|
2152
|
+
this.exposeMask ? (this.exposeMask.unmaskedValue = e, this.currentMask = this.exposeMask, this._applyDispatch()) : super.unmaskedValue = e;
|
|
2153
|
+
}
|
|
2154
|
+
get typedValue() {
|
|
2155
|
+
return this.exposeMask ? this.exposeMask.typedValue : this.currentMask ? this.currentMask.typedValue : "";
|
|
2156
|
+
}
|
|
2157
|
+
set typedValue(e) {
|
|
2158
|
+
if (this.exposeMask) {
|
|
2159
|
+
this.exposeMask.typedValue = e, this.currentMask = this.exposeMask, this._applyDispatch();
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
let t = String(e);
|
|
2163
|
+
this.currentMask && (this.currentMask.typedValue = e, t = this.currentMask.unmaskedValue), this.unmaskedValue = t;
|
|
2164
|
+
}
|
|
2165
|
+
get displayValue() {
|
|
2166
|
+
return this.currentMask ? this.currentMask.displayValue : "";
|
|
2167
|
+
}
|
|
2168
|
+
get isComplete() {
|
|
2169
|
+
var e;
|
|
2170
|
+
return !!((e = this.currentMask) != null && e.isComplete);
|
|
2171
|
+
}
|
|
2172
|
+
get isFilled() {
|
|
2173
|
+
var e;
|
|
2174
|
+
return !!((e = this.currentMask) != null && e.isFilled);
|
|
2175
|
+
}
|
|
2176
|
+
remove(e, t) {
|
|
2177
|
+
const s = new x();
|
|
2178
|
+
return this.currentMask && s.aggregate(this.currentMask.remove(e, t)).aggregate(this._applyDispatch()), s;
|
|
2179
|
+
}
|
|
2180
|
+
get state() {
|
|
2181
|
+
var e;
|
|
2182
|
+
return {
|
|
2183
|
+
...super.state,
|
|
2184
|
+
_rawInputValue: this.rawInputValue,
|
|
2185
|
+
compiledMasks: this.compiledMasks.map((t) => t.state),
|
|
2186
|
+
currentMaskRef: this.currentMask,
|
|
2187
|
+
currentMask: (e = this.currentMask) == null ? void 0 : e.state
|
|
2188
|
+
};
|
|
2189
|
+
}
|
|
2190
|
+
set state(e) {
|
|
2191
|
+
const {
|
|
2192
|
+
compiledMasks: t,
|
|
2193
|
+
currentMaskRef: s,
|
|
2194
|
+
currentMask: r,
|
|
2195
|
+
...n
|
|
2196
|
+
} = e;
|
|
2197
|
+
t && this.compiledMasks.forEach((a, l) => a.state = t[l]), s != null && (this.currentMask = s, this.currentMask.state = r), super.state = n;
|
|
2198
|
+
}
|
|
2199
|
+
extractInput(e, t, s) {
|
|
2200
|
+
return this.currentMask ? this.currentMask.extractInput(e, t, s) : "";
|
|
2201
|
+
}
|
|
2202
|
+
extractTail(e, t) {
|
|
2203
|
+
return this.currentMask ? this.currentMask.extractTail(e, t) : super.extractTail(e, t);
|
|
2204
|
+
}
|
|
2205
|
+
doCommit() {
|
|
2206
|
+
this.currentMask && this.currentMask.doCommit(), super.doCommit();
|
|
2207
|
+
}
|
|
2208
|
+
nearestInputPos(e, t) {
|
|
2209
|
+
return this.currentMask ? this.currentMask.nearestInputPos(e, t) : super.nearestInputPos(e, t);
|
|
2210
|
+
}
|
|
2211
|
+
get overwrite() {
|
|
2212
|
+
return this.currentMask ? this.currentMask.overwrite : this._overwrite;
|
|
2213
|
+
}
|
|
2214
|
+
set overwrite(e) {
|
|
2215
|
+
this._overwrite = e;
|
|
2216
|
+
}
|
|
2217
|
+
get eager() {
|
|
2218
|
+
return this.currentMask ? this.currentMask.eager : this._eager;
|
|
2219
|
+
}
|
|
2220
|
+
set eager(e) {
|
|
2221
|
+
this._eager = e;
|
|
2222
|
+
}
|
|
2223
|
+
get skipInvalid() {
|
|
2224
|
+
return this.currentMask ? this.currentMask.skipInvalid : this._skipInvalid;
|
|
2225
|
+
}
|
|
2226
|
+
set skipInvalid(e) {
|
|
2227
|
+
this._skipInvalid = e;
|
|
2228
|
+
}
|
|
2229
|
+
get autofix() {
|
|
2230
|
+
return this.currentMask ? this.currentMask.autofix : this._autofix;
|
|
2231
|
+
}
|
|
2232
|
+
set autofix(e) {
|
|
2233
|
+
this._autofix = e;
|
|
2234
|
+
}
|
|
2235
|
+
maskEquals(e) {
|
|
2236
|
+
return Array.isArray(e) ? this.compiledMasks.every((t, s) => {
|
|
2237
|
+
if (!e[s]) return;
|
|
2238
|
+
const {
|
|
2239
|
+
mask: r,
|
|
2240
|
+
...n
|
|
2241
|
+
} = e[s];
|
|
2242
|
+
return ge(t, n) && t.maskEquals(r);
|
|
2243
|
+
}) : super.maskEquals(e);
|
|
2244
|
+
}
|
|
2245
|
+
typedValueEquals(e) {
|
|
2246
|
+
var t;
|
|
2247
|
+
return !!((t = this.currentMask) != null && t.typedValueEquals(e));
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
ye.DEFAULTS = {
|
|
2251
|
+
...L.DEFAULTS,
|
|
2252
|
+
dispatch: (i, e, t, s) => {
|
|
2253
|
+
if (!e.compiledMasks.length) return;
|
|
2254
|
+
const r = e.rawInputValue, n = e.compiledMasks.map((a, l) => {
|
|
2255
|
+
const u = e.currentMask === a, o = u ? a.displayValue.length : a.nearestInputPos(a.displayValue.length, y.FORCE_LEFT);
|
|
2256
|
+
return a.rawInputValue !== r ? (a.reset(), a.append(r, {
|
|
2257
|
+
raw: !0
|
|
2258
|
+
})) : u || a.remove(o), a.append(i, e.currentMaskFlags(t)), a.appendTail(s), {
|
|
2259
|
+
index: l,
|
|
2260
|
+
weight: a.rawInputValue.length,
|
|
2261
|
+
totalInputPositions: a.totalInputPositions(0, Math.max(o, a.nearestInputPos(a.displayValue.length, y.FORCE_LEFT)))
|
|
2262
|
+
};
|
|
2263
|
+
});
|
|
2264
|
+
return n.sort((a, l) => l.weight - a.weight || l.totalInputPositions - a.totalInputPositions), e.compiledMasks[n[0].index];
|
|
2265
|
+
}
|
|
2266
|
+
};
|
|
2267
|
+
F.MaskedDynamic = ye;
|
|
2268
|
+
class be extends N {
|
|
2269
|
+
constructor(e) {
|
|
2270
|
+
super({
|
|
2271
|
+
...be.DEFAULTS,
|
|
2272
|
+
...e
|
|
2273
|
+
});
|
|
2274
|
+
}
|
|
2275
|
+
updateOptions(e) {
|
|
2276
|
+
super.updateOptions(e);
|
|
2277
|
+
}
|
|
2278
|
+
_update(e) {
|
|
2279
|
+
const {
|
|
2280
|
+
enum: t,
|
|
2281
|
+
...s
|
|
2282
|
+
} = e;
|
|
2283
|
+
if (t) {
|
|
2284
|
+
const r = t.map((l) => l.length), n = Math.min(...r), a = Math.max(...r) - n;
|
|
2285
|
+
s.mask = "*".repeat(n), a && (s.mask += "[" + "*".repeat(a) + "]"), this.enum = t;
|
|
2286
|
+
}
|
|
2287
|
+
super._update(s);
|
|
2288
|
+
}
|
|
2289
|
+
_appendCharRaw(e, t) {
|
|
2290
|
+
t === void 0 && (t = {});
|
|
2291
|
+
const s = Math.min(this.nearestInputPos(0, y.FORCE_RIGHT), this.value.length), r = this.enum.filter((n) => this.matchValue(n, this.unmaskedValue + e, s));
|
|
2292
|
+
if (r.length) {
|
|
2293
|
+
r.length === 1 && this._forEachBlocksInRange(0, this.value.length, (a, l) => {
|
|
2294
|
+
const u = r[0][l];
|
|
2295
|
+
l >= this.value.length || u === a.value || (a.reset(), a._appendChar(u, t));
|
|
2296
|
+
});
|
|
2297
|
+
const n = super._appendCharRaw(r[0][this.value.length], t);
|
|
2298
|
+
return r.length === 1 && r[0].slice(this.unmaskedValue.length).split("").forEach((a) => n.aggregate(super._appendCharRaw(a))), n;
|
|
2299
|
+
}
|
|
2300
|
+
return new x({
|
|
2301
|
+
skip: !this.isComplete
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2304
|
+
extractTail(e, t) {
|
|
2305
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), new G("", e);
|
|
2306
|
+
}
|
|
2307
|
+
remove(e, t) {
|
|
2308
|
+
if (e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), e === t) return new x();
|
|
2309
|
+
const s = Math.min(super.nearestInputPos(0, y.FORCE_RIGHT), this.value.length);
|
|
2310
|
+
let r;
|
|
2311
|
+
for (r = e; r >= 0 && !(this.enum.filter((l) => this.matchValue(l, this.value.slice(s, r), s)).length > 1); --r)
|
|
2312
|
+
;
|
|
2313
|
+
const n = super.remove(r, t);
|
|
2314
|
+
return n.tailShift += r - e, n;
|
|
2315
|
+
}
|
|
2316
|
+
get isComplete() {
|
|
2317
|
+
return this.enum.indexOf(this.value) >= 0;
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
be.DEFAULTS = {
|
|
2321
|
+
...N.DEFAULTS,
|
|
2322
|
+
matchValue: (i, e, t) => i.indexOf(e, t) === t
|
|
2323
|
+
};
|
|
2324
|
+
F.MaskedEnum = be;
|
|
2325
|
+
class Kt extends L {
|
|
2326
|
+
/** */
|
|
2327
|
+
/** Enable characters overwriting */
|
|
2328
|
+
/** */
|
|
2329
|
+
/** */
|
|
2330
|
+
/** */
|
|
2331
|
+
updateOptions(e) {
|
|
2332
|
+
super.updateOptions(e);
|
|
2333
|
+
}
|
|
2334
|
+
_update(e) {
|
|
2335
|
+
super._update({
|
|
2336
|
+
...e,
|
|
2337
|
+
validate: e.mask
|
|
2338
|
+
});
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
F.MaskedFunction = Kt;
|
|
2342
|
+
var Xe;
|
|
2343
|
+
class $ extends L {
|
|
2344
|
+
/** Single char */
|
|
2345
|
+
/** Single char */
|
|
2346
|
+
/** Array of single chars */
|
|
2347
|
+
/** */
|
|
2348
|
+
/** */
|
|
2349
|
+
/** Digits after point */
|
|
2350
|
+
/** Flag to remove leading and trailing zeros in the end of editing */
|
|
2351
|
+
/** Flag to pad trailing zeros after point in the end of editing */
|
|
2352
|
+
/** Enable characters overwriting */
|
|
2353
|
+
/** */
|
|
2354
|
+
/** */
|
|
2355
|
+
/** */
|
|
2356
|
+
/** Format typed value to string */
|
|
2357
|
+
/** Parse string to get typed value */
|
|
2358
|
+
constructor(e) {
|
|
2359
|
+
super({
|
|
2360
|
+
...$.DEFAULTS,
|
|
2361
|
+
...e
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2364
|
+
updateOptions(e) {
|
|
2365
|
+
super.updateOptions(e);
|
|
2366
|
+
}
|
|
2367
|
+
_update(e) {
|
|
2368
|
+
super._update(e), this._updateRegExps();
|
|
2369
|
+
}
|
|
2370
|
+
_updateRegExps() {
|
|
2371
|
+
const e = "^" + (this.allowNegative ? "[+|\\-]?" : ""), t = "\\d*", s = (this.scale ? "(" + Fe(this.radix) + "\\d{0," + this.scale + "})?" : "") + "$";
|
|
2372
|
+
this._numberRegExp = new RegExp(e + t + s), this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(Fe).join("") + "]", "g"), this._thousandsSeparatorRegExp = new RegExp(Fe(this.thousandsSeparator), "g");
|
|
2373
|
+
}
|
|
2374
|
+
_removeThousandsSeparators(e) {
|
|
2375
|
+
return e.replace(this._thousandsSeparatorRegExp, "");
|
|
2376
|
+
}
|
|
2377
|
+
_insertThousandsSeparators(e) {
|
|
2378
|
+
const t = e.split(this.radix);
|
|
2379
|
+
return t[0] = t[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator), t.join(this.radix);
|
|
2380
|
+
}
|
|
2381
|
+
doPrepareChar(e, t) {
|
|
2382
|
+
t === void 0 && (t = {});
|
|
2383
|
+
const [s, r] = super.doPrepareChar(this._removeThousandsSeparators(this.scale && this.mapToRadix.length && /*
|
|
2384
|
+
radix should be mapped when
|
|
2385
|
+
1) input is done from keyboard = flags.input && flags.raw
|
|
2386
|
+
2) unmasked value is set = !flags.input && !flags.raw
|
|
2387
|
+
and should not be mapped when
|
|
2388
|
+
1) value is set = flags.input && !flags.raw
|
|
2389
|
+
2) raw value is set = !flags.input && flags.raw
|
|
2390
|
+
*/
|
|
2391
|
+
(t.input && t.raw || !t.input && !t.raw) ? e.replace(this._mapToRadixRegExp, this.radix) : e), t);
|
|
2392
|
+
return e && !s && (r.skip = !0), s && !this.allowPositive && !this.value && s !== "-" && r.aggregate(this._appendChar("-")), [s, r];
|
|
2393
|
+
}
|
|
2394
|
+
_separatorsCount(e, t) {
|
|
2395
|
+
t === void 0 && (t = !1);
|
|
2396
|
+
let s = 0;
|
|
2397
|
+
for (let r = 0; r < e; ++r)
|
|
2398
|
+
this._value.indexOf(this.thousandsSeparator, r) === r && (++s, t && (e += this.thousandsSeparator.length));
|
|
2399
|
+
return s;
|
|
2400
|
+
}
|
|
2401
|
+
_separatorsCountFromSlice(e) {
|
|
2402
|
+
return e === void 0 && (e = this._value), this._separatorsCount(this._removeThousandsSeparators(e).length, !0);
|
|
2403
|
+
}
|
|
2404
|
+
extractInput(e, t, s) {
|
|
2405
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), [e, t] = this._adjustRangeWithSeparators(e, t), this._removeThousandsSeparators(super.extractInput(e, t, s));
|
|
2406
|
+
}
|
|
2407
|
+
_appendCharRaw(e, t) {
|
|
2408
|
+
t === void 0 && (t = {});
|
|
2409
|
+
const s = t.tail && t._beforeTailState ? t._beforeTailState._value : this._value, r = this._separatorsCountFromSlice(s);
|
|
2410
|
+
this._value = this._removeThousandsSeparators(this.value);
|
|
2411
|
+
const n = this._value;
|
|
2412
|
+
this._value += e;
|
|
2413
|
+
const a = this.number;
|
|
2414
|
+
let l = !isNaN(a), u = !1;
|
|
2415
|
+
if (l) {
|
|
2416
|
+
let m;
|
|
2417
|
+
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($.UNMASKED_RADIX, this.radix), u || (u = n === this._value && !t.tail)) : l = !1), l && (l = !!this._value.match(this._numberRegExp));
|
|
2418
|
+
}
|
|
2419
|
+
let o;
|
|
2420
|
+
l ? o = new x({
|
|
2421
|
+
inserted: this._value.slice(n.length),
|
|
2422
|
+
rawInserted: u ? "" : e,
|
|
2423
|
+
skip: u
|
|
2424
|
+
}) : (this._value = n, o = new x()), this._value = this._insertThousandsSeparators(this._value);
|
|
2425
|
+
const v = t.tail && t._beforeTailState ? t._beforeTailState._value : this._value, p = this._separatorsCountFromSlice(v);
|
|
2426
|
+
return o.tailShift += (p - r) * this.thousandsSeparator.length, o;
|
|
2427
|
+
}
|
|
2428
|
+
_findSeparatorAround(e) {
|
|
2429
|
+
if (this.thousandsSeparator) {
|
|
2430
|
+
const t = e - this.thousandsSeparator.length + 1, s = this.value.indexOf(this.thousandsSeparator, t);
|
|
2431
|
+
if (s <= e) return s;
|
|
2432
|
+
}
|
|
2433
|
+
return -1;
|
|
2434
|
+
}
|
|
2435
|
+
_adjustRangeWithSeparators(e, t) {
|
|
2436
|
+
const s = this._findSeparatorAround(e);
|
|
2437
|
+
s >= 0 && (e = s);
|
|
2438
|
+
const r = this._findSeparatorAround(t);
|
|
2439
|
+
return r >= 0 && (t = r + this.thousandsSeparator.length), [e, t];
|
|
2440
|
+
}
|
|
2441
|
+
remove(e, t) {
|
|
2442
|
+
e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), [e, t] = this._adjustRangeWithSeparators(e, t);
|
|
2443
|
+
const s = this.value.slice(0, e), r = this.value.slice(t), n = this._separatorsCount(s.length);
|
|
2444
|
+
this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(s + r));
|
|
2445
|
+
const a = this._separatorsCountFromSlice(s);
|
|
2446
|
+
return new x({
|
|
2447
|
+
tailShift: (a - n) * this.thousandsSeparator.length
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
nearestInputPos(e, t) {
|
|
2451
|
+
if (!this.thousandsSeparator) return e;
|
|
2452
|
+
switch (t) {
|
|
2453
|
+
case y.NONE:
|
|
2454
|
+
case y.LEFT:
|
|
2455
|
+
case y.FORCE_LEFT: {
|
|
2456
|
+
const s = this._findSeparatorAround(e - 1);
|
|
2457
|
+
if (s >= 0) {
|
|
2458
|
+
const r = s + this.thousandsSeparator.length;
|
|
2459
|
+
if (e < r || this.value.length <= r || t === y.FORCE_LEFT)
|
|
2460
|
+
return s;
|
|
2461
|
+
}
|
|
2462
|
+
break;
|
|
2463
|
+
}
|
|
2464
|
+
case y.RIGHT:
|
|
2465
|
+
case y.FORCE_RIGHT: {
|
|
2466
|
+
const s = this._findSeparatorAround(e);
|
|
2467
|
+
if (s >= 0)
|
|
2468
|
+
return s + this.thousandsSeparator.length;
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
return e;
|
|
2472
|
+
}
|
|
2473
|
+
doCommit() {
|
|
2474
|
+
if (this.value) {
|
|
2475
|
+
const e = this.number;
|
|
2476
|
+
let t = e;
|
|
2477
|
+
this.min != null && (t = Math.max(t, this.min)), this.max != null && (t = Math.min(t, this.max)), t !== e && (this.unmaskedValue = this.format(t, this));
|
|
2478
|
+
let s = this.value;
|
|
2479
|
+
this.normalizeZeros && (s = this._normalizeZeros(s)), this.padFractionalZeros && this.scale > 0 && (s = this._padFractionalZeros(s)), this._value = s;
|
|
2480
|
+
}
|
|
2481
|
+
super.doCommit();
|
|
2482
|
+
}
|
|
2483
|
+
_normalizeZeros(e) {
|
|
2484
|
+
const t = this._removeThousandsSeparators(e).split(this.radix);
|
|
2485
|
+
return t[0] = t[0].replace(/^(\D*)(0*)(\d*)/, (s, r, n, a) => r + a), e.length && !/\d$/.test(t[0]) && (t[0] = t[0] + "0"), t.length > 1 && (t[1] = t[1].replace(/0*$/, ""), t[1].length || (t.length = 1)), this._insertThousandsSeparators(t.join(this.radix));
|
|
2486
|
+
}
|
|
2487
|
+
_padFractionalZeros(e) {
|
|
2488
|
+
if (!e) return e;
|
|
2489
|
+
const t = e.split(this.radix);
|
|
2490
|
+
return t.length < 2 && t.push(""), t[1] = t[1].padEnd(this.scale, "0"), t.join(this.radix);
|
|
2491
|
+
}
|
|
2492
|
+
doSkipInvalid(e, t, s) {
|
|
2493
|
+
t === void 0 && (t = {});
|
|
2494
|
+
const r = this.scale === 0 && e !== this.thousandsSeparator && (e === this.radix || e === $.UNMASKED_RADIX || this.mapToRadix.includes(e));
|
|
2495
|
+
return super.doSkipInvalid(e, t, s) && !r;
|
|
2496
|
+
}
|
|
2497
|
+
get unmaskedValue() {
|
|
2498
|
+
return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, $.UNMASKED_RADIX);
|
|
2499
|
+
}
|
|
2500
|
+
set unmaskedValue(e) {
|
|
2501
|
+
super.unmaskedValue = e;
|
|
2502
|
+
}
|
|
2503
|
+
get typedValue() {
|
|
2504
|
+
return this.parse(this.unmaskedValue, this);
|
|
2505
|
+
}
|
|
2506
|
+
set typedValue(e) {
|
|
2507
|
+
this.rawInputValue = this.format(e, this).replace($.UNMASKED_RADIX, this.radix);
|
|
2508
|
+
}
|
|
2509
|
+
/** Parsed Number */
|
|
2510
|
+
get number() {
|
|
2511
|
+
return this.typedValue;
|
|
2512
|
+
}
|
|
2513
|
+
set number(e) {
|
|
2514
|
+
this.typedValue = e;
|
|
2515
|
+
}
|
|
2516
|
+
get allowNegative() {
|
|
2517
|
+
return this.min != null && this.min < 0 || this.max != null && this.max < 0;
|
|
2518
|
+
}
|
|
2519
|
+
get allowPositive() {
|
|
2520
|
+
return this.min != null && this.min > 0 || this.max != null && this.max > 0;
|
|
2521
|
+
}
|
|
2522
|
+
typedValueEquals(e) {
|
|
2523
|
+
return (super.typedValueEquals(e) || $.EMPTY_VALUES.includes(e) && $.EMPTY_VALUES.includes(this.typedValue)) && !(e === 0 && this.value === "");
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
Xe = $;
|
|
2527
|
+
$.UNMASKED_RADIX = ".";
|
|
2528
|
+
$.EMPTY_VALUES = [...L.EMPTY_VALUES, 0];
|
|
2529
|
+
$.DEFAULTS = {
|
|
2530
|
+
...L.DEFAULTS,
|
|
2531
|
+
mask: Number,
|
|
2532
|
+
radix: ",",
|
|
2533
|
+
thousandsSeparator: "",
|
|
2534
|
+
mapToRadix: [Xe.UNMASKED_RADIX],
|
|
2535
|
+
min: Number.MIN_SAFE_INTEGER,
|
|
2536
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
2537
|
+
scale: 2,
|
|
2538
|
+
normalizeZeros: !0,
|
|
2539
|
+
padFractionalZeros: !1,
|
|
2540
|
+
parse: Number,
|
|
2541
|
+
format: (i) => i.toLocaleString("en-US", {
|
|
2542
|
+
useGrouping: !1,
|
|
2543
|
+
maximumFractionDigits: 20
|
|
2544
|
+
})
|
|
2545
|
+
};
|
|
2546
|
+
F.MaskedNumber = $;
|
|
2547
|
+
const Me = {
|
|
2548
|
+
MASKED: "value",
|
|
2549
|
+
UNMASKED: "unmaskedValue",
|
|
2550
|
+
TYPED: "typedValue"
|
|
2551
|
+
};
|
|
2552
|
+
function Qe(i, e, t) {
|
|
2553
|
+
e === void 0 && (e = Me.MASKED), t === void 0 && (t = Me.MASKED);
|
|
2554
|
+
const s = Y(i);
|
|
2555
|
+
return (r) => s.runIsolated((n) => (n[e] = r, n[t]));
|
|
2556
|
+
}
|
|
2557
|
+
function Jt(i, e, t, s) {
|
|
2558
|
+
return Qe(e, t, s)(i);
|
|
2559
|
+
}
|
|
2560
|
+
F.PIPE_TYPE = Me;
|
|
2561
|
+
F.createPipe = Qe;
|
|
2562
|
+
F.pipe = Jt;
|
|
2563
|
+
class Yt extends N {
|
|
2564
|
+
get repeatFrom() {
|
|
2565
|
+
var e;
|
|
2566
|
+
return (e = Array.isArray(this.repeat) ? this.repeat[0] : this.repeat === 1 / 0 ? 0 : this.repeat) != null ? e : 0;
|
|
2567
|
+
}
|
|
2568
|
+
get repeatTo() {
|
|
2569
|
+
var e;
|
|
2570
|
+
return (e = Array.isArray(this.repeat) ? this.repeat[1] : this.repeat) != null ? e : 1 / 0;
|
|
2571
|
+
}
|
|
2572
|
+
constructor(e) {
|
|
2573
|
+
super(e);
|
|
2574
|
+
}
|
|
2575
|
+
updateOptions(e) {
|
|
2576
|
+
super.updateOptions(e);
|
|
2577
|
+
}
|
|
2578
|
+
_update(e) {
|
|
2579
|
+
var t, s, r;
|
|
2580
|
+
const {
|
|
2581
|
+
repeat: n,
|
|
2582
|
+
...a
|
|
2583
|
+
} = pe(e);
|
|
2584
|
+
this._blockOpts = Object.assign({}, this._blockOpts, a);
|
|
2585
|
+
const l = Y(this._blockOpts);
|
|
2586
|
+
this.repeat = (t = (s = n ?? l.repeat) != null ? s : this.repeat) != null ? t : 1 / 0, super._update({
|
|
2587
|
+
mask: "m".repeat(Math.max(this.repeatTo === 1 / 0 && ((r = this._blocks) == null ? void 0 : r.length) || 0, this.repeatFrom)),
|
|
2588
|
+
blocks: {
|
|
2589
|
+
m: l
|
|
2590
|
+
},
|
|
2591
|
+
eager: l.eager,
|
|
2592
|
+
overwrite: l.overwrite,
|
|
2593
|
+
skipInvalid: l.skipInvalid,
|
|
2594
|
+
lazy: l.lazy,
|
|
2595
|
+
placeholderChar: l.placeholderChar,
|
|
2596
|
+
displayChar: l.displayChar
|
|
2597
|
+
});
|
|
2598
|
+
}
|
|
2599
|
+
_allocateBlock(e) {
|
|
2600
|
+
if (e < this._blocks.length) return this._blocks[e];
|
|
2601
|
+
if (this.repeatTo === 1 / 0 || this._blocks.length < this.repeatTo)
|
|
2602
|
+
return this._blocks.push(Y(this._blockOpts)), this.mask += "m", this._blocks[this._blocks.length - 1];
|
|
2603
|
+
}
|
|
2604
|
+
_appendCharRaw(e, t) {
|
|
2605
|
+
t === void 0 && (t = {});
|
|
2606
|
+
const s = new x();
|
|
2607
|
+
for (
|
|
2608
|
+
let u = (r = (n = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : n.index) != null ? r : Math.max(this._blocks.length - 1, 0), o, v;
|
|
2609
|
+
// try to get a block or
|
|
2610
|
+
// try to allocate a new block if not allocated already
|
|
2611
|
+
o = (a = this._blocks[u]) != null ? a : v = !v && this._allocateBlock(u);
|
|
2612
|
+
++u
|
|
2613
|
+
) {
|
|
2614
|
+
var r, n, a, l;
|
|
2615
|
+
const p = o._appendChar(e, {
|
|
2616
|
+
...t,
|
|
2617
|
+
_beforeTailState: (l = t._beforeTailState) == null || (l = l._blocks) == null ? void 0 : l[u]
|
|
2618
|
+
});
|
|
2619
|
+
if (p.skip && v) {
|
|
2620
|
+
this._blocks.pop(), this.mask = this.mask.slice(1);
|
|
2621
|
+
break;
|
|
2622
|
+
}
|
|
2623
|
+
if (s.aggregate(p), p.consumed) break;
|
|
2624
|
+
}
|
|
2625
|
+
return s;
|
|
2626
|
+
}
|
|
2627
|
+
_trimEmptyTail(e, t) {
|
|
2628
|
+
var s, r;
|
|
2629
|
+
e === void 0 && (e = 0);
|
|
2630
|
+
const n = Math.max(((s = this._mapPosToBlock(e)) == null ? void 0 : s.index) || 0, this.repeatFrom, 0);
|
|
2631
|
+
let a;
|
|
2632
|
+
t != null && (a = (r = this._mapPosToBlock(t)) == null ? void 0 : r.index), a == null && (a = this._blocks.length - 1);
|
|
2633
|
+
let l = 0;
|
|
2634
|
+
for (let u = a; n <= u && !this._blocks[u].unmaskedValue; --u, ++l)
|
|
2635
|
+
;
|
|
2636
|
+
l && (this._blocks.splice(a - l + 1, l), this.mask = this.mask.slice(l));
|
|
2637
|
+
}
|
|
2638
|
+
reset() {
|
|
2639
|
+
super.reset(), this._trimEmptyTail();
|
|
2640
|
+
}
|
|
2641
|
+
remove(e, t) {
|
|
2642
|
+
e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length);
|
|
2643
|
+
const s = super.remove(e, t);
|
|
2644
|
+
return this._trimEmptyTail(e, t), s;
|
|
2645
|
+
}
|
|
2646
|
+
totalInputPositions(e, t) {
|
|
2647
|
+
return e === void 0 && (e = 0), t == null && this.repeatTo === 1 / 0 ? 1 / 0 : super.totalInputPositions(e, t);
|
|
2648
|
+
}
|
|
2649
|
+
get state() {
|
|
2650
|
+
return super.state;
|
|
2651
|
+
}
|
|
2652
|
+
set state(e) {
|
|
2653
|
+
this._blocks.length = e._blocks.length, this.mask = this.mask.slice(0, this._blocks.length), super.state = e;
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
F.RepeatBlock = Yt;
|
|
2657
|
+
try {
|
|
2658
|
+
globalThis.IMask = F;
|
|
2659
|
+
} catch {
|
|
2660
|
+
}
|
|
2661
|
+
const X = {
|
|
2662
|
+
lazy: !0,
|
|
2663
|
+
placeholderChar: "_",
|
|
2664
|
+
rawMode: "unmasked",
|
|
2665
|
+
normalize: "none"
|
|
2666
|
+
};
|
|
2667
|
+
function Wt(i) {
|
|
2668
|
+
return i === "unmasked" || i === "masked" || i === "typed";
|
|
2669
|
+
}
|
|
2670
|
+
function Zt(i) {
|
|
2671
|
+
return i === "digits" || i === "e164" || i === "none";
|
|
2672
|
+
}
|
|
2673
|
+
function et(i) {
|
|
2674
|
+
const e = i.match(/\+\{(\d+)\}/);
|
|
2675
|
+
return (e == null ? void 0 : e[1]) ?? null;
|
|
2676
|
+
}
|
|
2677
|
+
function Xt(i) {
|
|
2678
|
+
const e = i.trim();
|
|
2679
|
+
if (!e) return null;
|
|
2680
|
+
const t = X.lazy, s = X.placeholderChar, r = X.rawMode, n = X.normalize;
|
|
2681
|
+
return {
|
|
2682
|
+
pattern: e,
|
|
2683
|
+
lazy: t,
|
|
2684
|
+
placeholderChar: s,
|
|
2685
|
+
rawMode: r,
|
|
2686
|
+
normalize: n,
|
|
2687
|
+
countryCode: et(e),
|
|
2688
|
+
imaskOptions: {
|
|
2689
|
+
mask: e,
|
|
2690
|
+
lazy: t,
|
|
2691
|
+
placeholderChar: s
|
|
63
2692
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
2693
|
+
cacheKey: JSON.stringify({ pattern: e, lazy: t, placeholderChar: s, rawMode: r, normalize: n })
|
|
2694
|
+
};
|
|
2695
|
+
}
|
|
2696
|
+
function Qt(i) {
|
|
2697
|
+
const e = typeof i.pattern == "string" ? i.pattern.trim() : "";
|
|
2698
|
+
if (!e) return null;
|
|
2699
|
+
const t = typeof i.lazy == "boolean" ? i.lazy : X.lazy, s = typeof i.placeholderChar == "string" && i.placeholderChar.length > 0 ? i.placeholderChar : X.placeholderChar, r = Wt(i.rawMode) ? i.rawMode : X.rawMode, n = Zt(i.normalize) ? i.normalize : X.normalize;
|
|
2700
|
+
return {
|
|
2701
|
+
pattern: e,
|
|
2702
|
+
lazy: t,
|
|
2703
|
+
placeholderChar: s,
|
|
2704
|
+
rawMode: r,
|
|
2705
|
+
normalize: n,
|
|
2706
|
+
countryCode: et(e),
|
|
2707
|
+
imaskOptions: {
|
|
2708
|
+
mask: e,
|
|
2709
|
+
lazy: t,
|
|
2710
|
+
placeholderChar: s
|
|
67
2711
|
},
|
|
68
|
-
|
|
69
|
-
var s;
|
|
70
|
-
return (s = c.value) == null ? void 0 : s.reset(n);
|
|
71
|
-
}
|
|
2712
|
+
cacheKey: JSON.stringify({ pattern: e, lazy: t, placeholderChar: s, rawMode: r, normalize: n })
|
|
72
2713
|
};
|
|
73
2714
|
}
|
|
74
|
-
|
|
75
|
-
|
|
2715
|
+
function es(i) {
|
|
2716
|
+
return typeof i == "string" ? Xt(i) : i && typeof i == "object" ? Qt(i) : null;
|
|
2717
|
+
}
|
|
2718
|
+
const ts = ["for"], ss = {
|
|
2719
|
+
key: 0,
|
|
2720
|
+
class: "co-field-shell__required",
|
|
2721
|
+
"aria-hidden": "true"
|
|
2722
|
+
}, is = { class: "co-field-shell__control" }, rs = {
|
|
2723
|
+
key: 1,
|
|
2724
|
+
class: "co-field-shell__message"
|
|
2725
|
+
}, ns = /* @__PURE__ */ T({
|
|
2726
|
+
__name: "CoFieldShell",
|
|
2727
|
+
props: {
|
|
2728
|
+
label: {},
|
|
2729
|
+
inputId: {},
|
|
2730
|
+
required: { type: Boolean },
|
|
2731
|
+
disabled: { type: Boolean },
|
|
2732
|
+
focused: { type: Boolean },
|
|
2733
|
+
helperText: {},
|
|
2734
|
+
errors: {},
|
|
2735
|
+
size: {}
|
|
2736
|
+
},
|
|
2737
|
+
setup(i) {
|
|
2738
|
+
const e = i, t = c(() => {
|
|
2739
|
+
var n;
|
|
2740
|
+
return (((n = e.errors) == null ? void 0 : n.length) ?? 0) > 0;
|
|
2741
|
+
}), s = c(() => {
|
|
2742
|
+
var n;
|
|
2743
|
+
return ((n = e.errors) == null ? void 0 : n[0]) || e.helperText || "";
|
|
2744
|
+
}), r = c(() => e.size ?? "md");
|
|
2745
|
+
return (n, a) => (w(), j("div", {
|
|
2746
|
+
class: ft([
|
|
2747
|
+
"co-field-shell",
|
|
2748
|
+
`co-field-shell--${r.value}`,
|
|
2749
|
+
{
|
|
2750
|
+
"co-field-shell--error": t.value,
|
|
2751
|
+
"co-field-shell--disabled": i.disabled,
|
|
2752
|
+
"co-field-shell--focused": i.focused
|
|
2753
|
+
}
|
|
2754
|
+
])
|
|
2755
|
+
}, [
|
|
2756
|
+
i.label ? (w(), j("label", {
|
|
2757
|
+
key: 0,
|
|
2758
|
+
for: i.inputId,
|
|
2759
|
+
class: "co-field-shell__label"
|
|
2760
|
+
}, [
|
|
2761
|
+
mt(_e(i.label) + " ", 1),
|
|
2762
|
+
i.required ? (w(), j("span", ss, "*")) : ue("", !0)
|
|
2763
|
+
], 8, ts)) : ue("", !0),
|
|
2764
|
+
ce("div", is, [
|
|
2765
|
+
he(n.$slots, "default", {}, void 0, !0)
|
|
2766
|
+
]),
|
|
2767
|
+
s.value ? (w(), j("p", rs, _e(s.value), 1)) : ue("", !0)
|
|
2768
|
+
], 2));
|
|
2769
|
+
}
|
|
2770
|
+
}), De = (i, e) => {
|
|
2771
|
+
const t = i.__vccOpts || i;
|
|
2772
|
+
for (const [s, r] of e)
|
|
2773
|
+
t[s] = r;
|
|
2774
|
+
return t;
|
|
2775
|
+
}, as = /* @__PURE__ */ De(ns, [["__scopeId", "data-v-9aa9efaf"]]), ls = ["id", "type", "placeholder", "disabled"], us = /* @__PURE__ */ T({
|
|
2776
|
+
__name: "FieldMasked",
|
|
76
2777
|
props: {
|
|
77
2778
|
field: {},
|
|
78
2779
|
value: {},
|
|
79
2780
|
errors: {},
|
|
80
2781
|
disabled: { type: Boolean }
|
|
81
2782
|
},
|
|
82
|
-
emits: ["update:value", "blur"],
|
|
83
|
-
setup(
|
|
84
|
-
const t = e, r =
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
2783
|
+
emits: ["update:value", "blur", "mask:accept"],
|
|
2784
|
+
setup(i, { emit: e }) {
|
|
2785
|
+
const t = i, s = e, r = H(null), n = H(!1), a = c(() => `co-masked-${t.field.name}`), l = c(() => !!t.disabled || !!t.field.disabled), u = c(() => t.value !== null && t.value !== void 0 && `${t.value}`.length > 0), o = c(() => !t.field.required && u.value && !l.value), v = c(() => {
|
|
2786
|
+
var B;
|
|
2787
|
+
const C = (B = t.field.originalAttrs) == null ? void 0 : B.size;
|
|
2788
|
+
return C === "sm" || C === "lg" ? C : "md";
|
|
2789
|
+
}), p = c(() => {
|
|
2790
|
+
const C = t.field.originalAttrs ?? {}, B = C.format || C.uiCom;
|
|
2791
|
+
return B === "email" || t.field.name === "email" ? "email" : B === "tel" || B === "phone" ? "tel" : B === "url" ? "url" : "text";
|
|
2792
|
+
}), m = c(() => {
|
|
2793
|
+
var C;
|
|
2794
|
+
return es((C = t.field.originalAttrs) == null ? void 0 : C.mask);
|
|
2795
|
+
}), E = c(() => {
|
|
2796
|
+
var C;
|
|
2797
|
+
return ((C = m.value) == null ? void 0 : C.cacheKey) ?? "no-mask-config";
|
|
2798
|
+
});
|
|
2799
|
+
let b = null, S = !1;
|
|
2800
|
+
function M(C) {
|
|
2801
|
+
return C.replace(/\D/g, "");
|
|
2802
|
+
}
|
|
2803
|
+
function W(C, B, U) {
|
|
2804
|
+
const q = C.length > 0, te = B.trim().length > 0, P = U != null && `${U}`.length > 0;
|
|
2805
|
+
return q || te || P;
|
|
2806
|
+
}
|
|
2807
|
+
function re(C, B, U) {
|
|
2808
|
+
const q = m.value;
|
|
2809
|
+
if (!q) return C || null;
|
|
2810
|
+
if (!W(C, B, U)) return null;
|
|
2811
|
+
let P;
|
|
2812
|
+
if (q.rawMode === "masked" ? P = B : q.rawMode === "typed" ? P = U : P = C, P === "" || P === null || P === void 0) return null;
|
|
2813
|
+
if (q.normalize === "none") return P;
|
|
2814
|
+
const Ae = q.rawMode === "masked" ? B : C || `${P}`, d = M(Ae);
|
|
2815
|
+
if (!d) return null;
|
|
2816
|
+
if (q.normalize === "digits") return d;
|
|
2817
|
+
const g = q.countryCode;
|
|
2818
|
+
return g ? d.startsWith(g) ? `+${d}` : `+${g}${d}` : `+${d}`;
|
|
2819
|
+
}
|
|
2820
|
+
function Z(C) {
|
|
2821
|
+
if (b) {
|
|
2822
|
+
S = !0;
|
|
2823
|
+
try {
|
|
2824
|
+
if (C == null) {
|
|
2825
|
+
b.value = "";
|
|
2826
|
+
return;
|
|
2827
|
+
}
|
|
2828
|
+
const B = m.value;
|
|
2829
|
+
if (!B) {
|
|
2830
|
+
b.value = String(C);
|
|
2831
|
+
return;
|
|
2832
|
+
}
|
|
2833
|
+
if (B.rawMode === "masked") {
|
|
2834
|
+
b.value = String(C);
|
|
2835
|
+
return;
|
|
2836
|
+
}
|
|
2837
|
+
if (B.rawMode === "typed") {
|
|
2838
|
+
try {
|
|
2839
|
+
b.typedValue = C;
|
|
2840
|
+
} catch {
|
|
2841
|
+
b.value = String(C);
|
|
2842
|
+
}
|
|
2843
|
+
return;
|
|
2844
|
+
}
|
|
2845
|
+
const U = B.normalize === "none" ? String(C) : M(String(C));
|
|
2846
|
+
b.unmaskedValue = U;
|
|
2847
|
+
} finally {
|
|
2848
|
+
S = !1;
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
function ee() {
|
|
2853
|
+
var te;
|
|
2854
|
+
if (!b || S) return;
|
|
2855
|
+
const C = `${b.unmaskedValue ?? ""}`, B = `${b.value ?? ""}`, U = b.typedValue, q = !!((te = b.masked) != null && te.isComplete);
|
|
2856
|
+
s("mask:accept", { rawValue: C, maskedValue: B, isComplete: q }), s("update:value", re(C, B, U));
|
|
2857
|
+
}
|
|
2858
|
+
function z() {
|
|
2859
|
+
!r.value || !m.value || (b = F(r.value, m.value.imaskOptions), b.on("accept", ee), Z(t.value));
|
|
2860
|
+
}
|
|
2861
|
+
function ne() {
|
|
2862
|
+
b && (b.off("accept", ee), b.destroy(), b = null);
|
|
2863
|
+
}
|
|
2864
|
+
function oe() {
|
|
2865
|
+
ne(), z();
|
|
2866
|
+
}
|
|
2867
|
+
function de(C) {
|
|
2868
|
+
if (b) return;
|
|
2869
|
+
const B = C.target.value;
|
|
2870
|
+
s("update:value", B.trim() ? B : null);
|
|
2871
|
+
}
|
|
2872
|
+
function I() {
|
|
2873
|
+
var C;
|
|
2874
|
+
if (b) {
|
|
2875
|
+
S = !0;
|
|
2876
|
+
try {
|
|
2877
|
+
b.value = "";
|
|
2878
|
+
} finally {
|
|
2879
|
+
S = !1;
|
|
2880
|
+
}
|
|
2881
|
+
} else r.value && (r.value.value = "");
|
|
2882
|
+
s("update:value", null), (C = r.value) == null || C.focus();
|
|
2883
|
+
}
|
|
2884
|
+
function A() {
|
|
2885
|
+
n.value = !0;
|
|
2886
|
+
}
|
|
2887
|
+
function D() {
|
|
2888
|
+
n.value = !1, s("blur");
|
|
2889
|
+
}
|
|
2890
|
+
return J(
|
|
2891
|
+
() => t.value,
|
|
2892
|
+
(C) => {
|
|
2893
|
+
Z(C);
|
|
2894
|
+
}
|
|
2895
|
+
), J(E, () => {
|
|
2896
|
+
oe();
|
|
2897
|
+
}), Se(() => {
|
|
2898
|
+
z(), !b && r.value && (r.value.value = t.value == null ? "" : String(t.value));
|
|
2899
|
+
}), Ue(() => {
|
|
2900
|
+
ne();
|
|
2901
|
+
}), (C, B) => (w(), R(as, {
|
|
2902
|
+
label: i.field.label,
|
|
2903
|
+
"input-id": a.value,
|
|
2904
|
+
required: i.field.required,
|
|
2905
|
+
disabled: l.value,
|
|
2906
|
+
focused: n.value,
|
|
2907
|
+
"helper-text": i.field.helperText,
|
|
2908
|
+
errors: i.errors,
|
|
2909
|
+
size: v.value
|
|
2910
|
+
}, {
|
|
2911
|
+
default: Ie(() => [
|
|
2912
|
+
ce("input", {
|
|
2913
|
+
id: a.value,
|
|
2914
|
+
ref_key: "inputRef",
|
|
2915
|
+
ref: r,
|
|
2916
|
+
class: "co-field-shell__input",
|
|
2917
|
+
type: p.value,
|
|
2918
|
+
placeholder: i.field.placeholder,
|
|
2919
|
+
disabled: l.value,
|
|
2920
|
+
onInput: de,
|
|
2921
|
+
onFocus: A,
|
|
2922
|
+
onBlur: D
|
|
2923
|
+
}, null, 40, ls),
|
|
2924
|
+
o.value ? (w(), j("button", {
|
|
2925
|
+
key: 0,
|
|
2926
|
+
class: "co-masked__clear",
|
|
2927
|
+
type: "button",
|
|
2928
|
+
tabindex: "-1",
|
|
2929
|
+
"aria-label": "Clear",
|
|
2930
|
+
onMousedown: B[0] || (B[0] = Pe(() => {
|
|
2931
|
+
}, ["prevent"])),
|
|
2932
|
+
onClick: I
|
|
2933
|
+
}, [
|
|
2934
|
+
me(O(Ft), {
|
|
2935
|
+
name: "x-circle",
|
|
2936
|
+
size: 16,
|
|
2937
|
+
weight: "fill"
|
|
2938
|
+
})
|
|
2939
|
+
], 32)) : ue("", !0)
|
|
2940
|
+
]),
|
|
2941
|
+
_: 1
|
|
2942
|
+
}, 8, ["label", "input-id", "required", "disabled", "focused", "helper-text", "errors", "size"]));
|
|
100
2943
|
}
|
|
101
|
-
}),
|
|
102
|
-
__name: "
|
|
2944
|
+
}), os = /* @__PURE__ */ De(us, [["__scopeId", "data-v-6a147f90"]]), ds = /* @__PURE__ */ T({
|
|
2945
|
+
__name: "FieldMixed",
|
|
103
2946
|
props: {
|
|
104
2947
|
field: {},
|
|
105
2948
|
value: {},
|
|
106
2949
|
errors: {},
|
|
107
|
-
disabled: { type: Boolean }
|
|
2950
|
+
disabled: { type: Boolean },
|
|
2951
|
+
locale: {}
|
|
108
2952
|
},
|
|
109
2953
|
emits: ["update:value", "blur"],
|
|
110
|
-
setup(
|
|
111
|
-
const t =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
2954
|
+
setup(i, { emit: e }) {
|
|
2955
|
+
const t = i, s = e, r = c(() => t.errors.length > 0 ? "error" : "default"), n = c(() => t.errors[0] || t.field.helperText);
|
|
2956
|
+
function a(o) {
|
|
2957
|
+
if (o == null) return "";
|
|
2958
|
+
if (typeof o == "string") {
|
|
2959
|
+
const v = o.trim();
|
|
2960
|
+
if (!v) return "";
|
|
2961
|
+
try {
|
|
2962
|
+
return JSON.stringify(JSON.parse(v), null, 2);
|
|
2963
|
+
} catch {
|
|
2964
|
+
return o;
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
try {
|
|
2968
|
+
return JSON.stringify(o, null, 2);
|
|
2969
|
+
} catch {
|
|
2970
|
+
return String(o);
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
function l(o) {
|
|
2974
|
+
const v = (o ?? "").trim();
|
|
2975
|
+
if (!v) return null;
|
|
2976
|
+
try {
|
|
2977
|
+
return JSON.parse(v);
|
|
2978
|
+
} catch {
|
|
2979
|
+
return o;
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
const u = c(() => a(t.value));
|
|
2983
|
+
return (o, v) => (w(), R(O(Et), {
|
|
2984
|
+
label: i.field.label,
|
|
2985
|
+
placeholder: i.field.placeholder || "{ }",
|
|
2986
|
+
required: i.field.required,
|
|
2987
|
+
disabled: i.disabled,
|
|
2988
|
+
status: r.value,
|
|
118
2989
|
"helper-text": n.value,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
onBlur: a[1] || (a[1] = (o) => r("blur"))
|
|
2990
|
+
value: u.value,
|
|
2991
|
+
onCoChange: v[0] || (v[0] = (p) => s("update:value", l(p.detail))),
|
|
2992
|
+
onCoBlur: v[1] || (v[1] = (p) => s("blur"))
|
|
123
2993
|
}, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "value"]));
|
|
124
2994
|
}
|
|
125
|
-
}),
|
|
2995
|
+
}), hs = /* @__PURE__ */ T({
|
|
2996
|
+
__name: "FieldMultiple",
|
|
2997
|
+
props: {
|
|
2998
|
+
field: {},
|
|
2999
|
+
value: {},
|
|
3000
|
+
errors: {},
|
|
3001
|
+
disabled: { type: Boolean },
|
|
3002
|
+
locale: {}
|
|
3003
|
+
},
|
|
3004
|
+
emits: ["update:value", "blur"],
|
|
3005
|
+
setup(i, { emit: e }) {
|
|
3006
|
+
const t = i, s = e, r = c(() => {
|
|
3007
|
+
const a = t.value;
|
|
3008
|
+
return Array.isArray(a) ? JSON.stringify(a.map((l) => String(l))) : a == null || a === "" ? "[]" : JSON.stringify([String(a)]);
|
|
3009
|
+
}), n = c(() => {
|
|
3010
|
+
const a = t.field.originalAttrs.maxElements;
|
|
3011
|
+
return typeof a == "number" ? a : void 0;
|
|
3012
|
+
});
|
|
3013
|
+
return (a, l) => (w(), R(O(xt), {
|
|
3014
|
+
label: i.field.label,
|
|
3015
|
+
placeholder: i.field.placeholder,
|
|
3016
|
+
required: i.field.required,
|
|
3017
|
+
disabled: i.disabled,
|
|
3018
|
+
clearable: !i.field.required,
|
|
3019
|
+
invalid: i.errors.length > 0,
|
|
3020
|
+
"error-message": i.errors[0],
|
|
3021
|
+
"helper-text": i.field.helperText,
|
|
3022
|
+
"max-tags": n.value,
|
|
3023
|
+
value: r.value,
|
|
3024
|
+
onCoChange: l[0] || (l[0] = (u) => s("update:value", u.detail)),
|
|
3025
|
+
onCoBlur: l[1] || (l[1] = (u) => s("blur"))
|
|
3026
|
+
}, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "invalid", "error-message", "helper-text", "max-tags", "value"]));
|
|
3027
|
+
}
|
|
3028
|
+
}), Ee = /* @__PURE__ */ T({
|
|
126
3029
|
__name: "FieldNumber",
|
|
127
3030
|
props: {
|
|
128
3031
|
field: {},
|
|
@@ -131,24 +3034,25 @@ const D = /* @__PURE__ */ C({
|
|
|
131
3034
|
disabled: { type: Boolean }
|
|
132
3035
|
},
|
|
133
3036
|
emits: ["update:value", "blur"],
|
|
134
|
-
setup(
|
|
135
|
-
const t =
|
|
136
|
-
return (
|
|
137
|
-
label:
|
|
138
|
-
placeholder:
|
|
139
|
-
required:
|
|
140
|
-
disabled:
|
|
141
|
-
|
|
3037
|
+
setup(i, { emit: e }) {
|
|
3038
|
+
const t = i, s = e, r = c(() => t.errors.length > 0 ? "error" : "default"), n = c(() => t.errors[0] || t.field.helperText), a = c(() => t.field.originalAttrs.min), l = c(() => t.field.originalAttrs.max), u = c(() => typeof t.value == "number" ? t.value : null);
|
|
3039
|
+
return (o, v) => (w(), R(O(_t), {
|
|
3040
|
+
label: i.field.label,
|
|
3041
|
+
placeholder: i.field.placeholder,
|
|
3042
|
+
required: i.field.required,
|
|
3043
|
+
disabled: i.disabled,
|
|
3044
|
+
clearable: !i.field.required,
|
|
3045
|
+
status: r.value,
|
|
142
3046
|
"helper-text": n.value,
|
|
143
|
-
min:
|
|
144
|
-
max:
|
|
145
|
-
value:
|
|
146
|
-
onCoChange:
|
|
147
|
-
onBlur:
|
|
148
|
-
}, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "min", "max", "value"]));
|
|
3047
|
+
min: a.value,
|
|
3048
|
+
max: l.value,
|
|
3049
|
+
value: u.value,
|
|
3050
|
+
onCoChange: v[0] || (v[0] = (p) => s("update:value", p.detail)),
|
|
3051
|
+
onBlur: v[1] || (v[1] = (p) => s("blur"))
|
|
3052
|
+
}, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "status", "helper-text", "min", "max", "value"]));
|
|
149
3053
|
}
|
|
150
|
-
}),
|
|
151
|
-
__name: "
|
|
3054
|
+
}), cs = /* @__PURE__ */ T({
|
|
3055
|
+
__name: "FieldPhone",
|
|
152
3056
|
props: {
|
|
153
3057
|
field: {},
|
|
154
3058
|
value: {},
|
|
@@ -156,42 +3060,117 @@ const D = /* @__PURE__ */ C({
|
|
|
156
3060
|
disabled: { type: Boolean }
|
|
157
3061
|
},
|
|
158
3062
|
emits: ["update:value", "blur"],
|
|
159
|
-
setup(
|
|
160
|
-
const t =
|
|
161
|
-
return (
|
|
162
|
-
label:
|
|
163
|
-
placeholder:
|
|
164
|
-
required:
|
|
165
|
-
disabled:
|
|
166
|
-
status:
|
|
3063
|
+
setup(i, { emit: e }) {
|
|
3064
|
+
const t = i, s = e, r = c(() => t.errors.length > 0 ? "error" : "default"), n = c(() => t.errors[0] || t.field.helperText), a = c(() => t.field.originalAttrs.defaultCountry || "CO");
|
|
3065
|
+
return (l, u) => (w(), R(O(St), {
|
|
3066
|
+
label: i.field.label,
|
|
3067
|
+
placeholder: i.field.placeholder,
|
|
3068
|
+
required: i.field.required,
|
|
3069
|
+
disabled: i.disabled,
|
|
3070
|
+
status: r.value,
|
|
167
3071
|
"helper-text": n.value,
|
|
168
|
-
|
|
169
|
-
value: String(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "value"]));
|
|
3072
|
+
"default-country": a.value,
|
|
3073
|
+
value: String(i.value ?? ""),
|
|
3074
|
+
onCoChange: u[0] || (u[0] = (o) => s("update:value", o.detail))
|
|
3075
|
+
}, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "default-country", "value"]));
|
|
173
3076
|
}
|
|
174
|
-
}),
|
|
175
|
-
__name: "
|
|
3077
|
+
}), ps = /* @__PURE__ */ T({
|
|
3078
|
+
__name: "FieldRef",
|
|
3079
|
+
props: {
|
|
3080
|
+
field: {},
|
|
3081
|
+
value: {},
|
|
3082
|
+
errors: {},
|
|
3083
|
+
disabled: { type: Boolean },
|
|
3084
|
+
refState: {}
|
|
3085
|
+
},
|
|
3086
|
+
emits: ["update:value", "search", "load-more", "open"],
|
|
3087
|
+
setup(i, { emit: e }) {
|
|
3088
|
+
const t = i, s = e, r = c(() => t.errors.length > 0 ? "error" : "default"), n = c(() => t.errors[0] || t.field.helperText), a = c(
|
|
3089
|
+
() => !!t.field.originalAttrs.multiple || t.field.originalAttrs.type === "array"
|
|
3090
|
+
), l = c(() => {
|
|
3091
|
+
const p = t.value;
|
|
3092
|
+
if (p == null) return "";
|
|
3093
|
+
if (Array.isArray(p)) {
|
|
3094
|
+
const m = p.map((E) => typeof E == "string" ? E : (E == null ? void 0 : E._id) || "");
|
|
3095
|
+
return JSON.stringify(m);
|
|
3096
|
+
}
|
|
3097
|
+
return typeof p == "string" ? a.value ? JSON.stringify([p]) : p : typeof p == "object" && p._id ? a.value ? JSON.stringify([p._id]) : String(p._id) : "";
|
|
3098
|
+
}), u = c(() => {
|
|
3099
|
+
var p;
|
|
3100
|
+
return JSON.stringify(((p = t.refState) == null ? void 0 : p.options) || []);
|
|
3101
|
+
}), o = c(() => {
|
|
3102
|
+
var p;
|
|
3103
|
+
return JSON.stringify(((p = t.refState) == null ? void 0 : p.selectedDisplay) || []);
|
|
3104
|
+
});
|
|
3105
|
+
function v(p) {
|
|
3106
|
+
const m = p.detail ?? {};
|
|
3107
|
+
s("update:value", m.value);
|
|
3108
|
+
}
|
|
3109
|
+
return (p, m) => {
|
|
3110
|
+
var E, b;
|
|
3111
|
+
return w(), R(O(Bt), {
|
|
3112
|
+
label: i.field.label,
|
|
3113
|
+
placeholder: i.field.placeholder,
|
|
3114
|
+
required: i.field.required,
|
|
3115
|
+
disabled: i.disabled,
|
|
3116
|
+
clearable: !i.field.required,
|
|
3117
|
+
multiple: a.value,
|
|
3118
|
+
status: r.value,
|
|
3119
|
+
"helper-text": n.value,
|
|
3120
|
+
model: i.field.originalAttrs.ref,
|
|
3121
|
+
value: l.value,
|
|
3122
|
+
options: u.value,
|
|
3123
|
+
"selected-display": o.value,
|
|
3124
|
+
loading: ((E = i.refState) == null ? void 0 : E.loading) || !1,
|
|
3125
|
+
total: ((b = i.refState) == null ? void 0 : b.total) || 0,
|
|
3126
|
+
onCoOpen: m[0] || (m[0] = (S) => s("open")),
|
|
3127
|
+
onCoSearch: m[1] || (m[1] = (S) => s("search", S.detail)),
|
|
3128
|
+
onCoLoadMore: m[2] || (m[2] = (S) => s("load-more")),
|
|
3129
|
+
onCoChange: v,
|
|
3130
|
+
onCoClear: m[3] || (m[3] = (S) => s("update:value", a.value ? [] : null))
|
|
3131
|
+
}, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "multiple", "status", "helper-text", "model", "value", "options", "selected-display", "loading", "total"]);
|
|
3132
|
+
};
|
|
3133
|
+
}
|
|
3134
|
+
}), fs = /* @__PURE__ */ T({
|
|
3135
|
+
__name: "FieldRichText",
|
|
176
3136
|
props: {
|
|
177
3137
|
field: {},
|
|
178
3138
|
value: {},
|
|
179
3139
|
errors: {},
|
|
180
3140
|
disabled: { type: Boolean }
|
|
181
3141
|
},
|
|
182
|
-
emits: ["update:value"],
|
|
183
|
-
setup(
|
|
184
|
-
const t =
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
3142
|
+
emits: ["update:value", "blur"],
|
|
3143
|
+
setup(i, { emit: e }) {
|
|
3144
|
+
const t = i, s = e, r = c(() => t.errors.length > 0 ? "error" : "default"), n = c(() => t.errors[0] || t.field.helperText), a = c(() => {
|
|
3145
|
+
var v;
|
|
3146
|
+
return ((v = t.field.originalAttrs) == null ? void 0 : v.preset) || "task";
|
|
3147
|
+
}), l = H(null), u = H(t.value == null ? "" : String(t.value));
|
|
3148
|
+
J(
|
|
3149
|
+
() => t.value,
|
|
3150
|
+
(v) => {
|
|
3151
|
+
const p = v == null ? "" : String(v);
|
|
3152
|
+
p !== l.value && (u.value = p);
|
|
3153
|
+
}
|
|
3154
|
+
);
|
|
3155
|
+
function o(v) {
|
|
3156
|
+
var m;
|
|
3157
|
+
const p = ((m = v.detail) == null ? void 0 : m.html) ?? "";
|
|
3158
|
+
l.value = p, s("update:value", p);
|
|
3159
|
+
}
|
|
3160
|
+
return (v, p) => (w(), R(O(Mt), {
|
|
3161
|
+
label: i.field.label,
|
|
3162
|
+
placeholder: i.field.placeholder,
|
|
3163
|
+
required: i.field.required,
|
|
3164
|
+
disabled: i.disabled,
|
|
3165
|
+
status: r.value,
|
|
189
3166
|
"helper-text": n.value,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
3167
|
+
preset: a.value,
|
|
3168
|
+
value: u.value,
|
|
3169
|
+
onCoInput: o,
|
|
3170
|
+
onCoBlur: p[0] || (p[0] = (m) => s("blur"))
|
|
3171
|
+
}, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "preset", "value"]));
|
|
193
3172
|
}
|
|
194
|
-
}),
|
|
3173
|
+
}), xe = /* @__PURE__ */ T({
|
|
195
3174
|
__name: "FieldSelect",
|
|
196
3175
|
props: {
|
|
197
3176
|
field: {},
|
|
@@ -200,82 +3179,88 @@ const D = /* @__PURE__ */ C({
|
|
|
200
3179
|
disabled: { type: Boolean }
|
|
201
3180
|
},
|
|
202
3181
|
emits: ["update:value", "blur"],
|
|
203
|
-
setup(
|
|
204
|
-
const t =
|
|
205
|
-
const
|
|
206
|
-
return Array.isArray(
|
|
207
|
-
});
|
|
208
|
-
return (
|
|
209
|
-
label:
|
|
210
|
-
placeholder:
|
|
211
|
-
required:
|
|
212
|
-
disabled:
|
|
213
|
-
|
|
3182
|
+
setup(i, { emit: e }) {
|
|
3183
|
+
const t = i, s = e, r = c(() => t.errors.length > 0 ? "error" : "default"), n = c(() => t.errors[0] || t.field.helperText), a = c(() => {
|
|
3184
|
+
const l = t.field.originalAttrs.enum;
|
|
3185
|
+
return Array.isArray(l) ? JSON.stringify(l.map((u) => ({ label: String(u), value: String(u) }))) : "[]";
|
|
3186
|
+
});
|
|
3187
|
+
return (l, u) => (w(), R(O(wt), {
|
|
3188
|
+
label: i.field.label,
|
|
3189
|
+
placeholder: i.field.placeholder,
|
|
3190
|
+
required: i.field.required,
|
|
3191
|
+
disabled: i.disabled,
|
|
3192
|
+
clearable: !i.field.required,
|
|
3193
|
+
status: r.value,
|
|
214
3194
|
"helper-text": n.value,
|
|
215
|
-
options:
|
|
216
|
-
value: String(
|
|
217
|
-
onCoChange:
|
|
218
|
-
onBlur:
|
|
219
|
-
}, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "options", "value"]));
|
|
3195
|
+
options: a.value,
|
|
3196
|
+
value: String(i.value ?? ""),
|
|
3197
|
+
onCoChange: u[0] || (u[0] = (o) => s("update:value", o.detail)),
|
|
3198
|
+
onBlur: u[1] || (u[1] = (o) => s("blur"))
|
|
3199
|
+
}, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "status", "helper-text", "options", "value"]));
|
|
220
3200
|
}
|
|
221
|
-
}),
|
|
222
|
-
__name: "
|
|
3201
|
+
}), ms = /* @__PURE__ */ T({
|
|
3202
|
+
__name: "FieldText",
|
|
223
3203
|
props: {
|
|
224
3204
|
field: {},
|
|
225
3205
|
value: {},
|
|
226
3206
|
errors: {},
|
|
227
|
-
disabled: { type: Boolean }
|
|
228
|
-
refState: {}
|
|
3207
|
+
disabled: { type: Boolean }
|
|
229
3208
|
},
|
|
230
|
-
emits: ["update:value", "
|
|
231
|
-
setup(
|
|
232
|
-
const t =
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
3209
|
+
emits: ["update:value", "blur"],
|
|
3210
|
+
setup(i, { emit: e }) {
|
|
3211
|
+
const t = i, s = e, r = c(() => t.errors.length > 0 ? "error" : "default"), n = c(() => t.errors[0] || t.field.helperText), a = c(() => {
|
|
3212
|
+
const l = t.field.originalAttrs, u = l.format || l.uiCom;
|
|
3213
|
+
return u === "email" || t.field.name === "email" ? "email" : u === "password" || u === "Password" ? "password" : u === "tel" || u === "phone" ? "tel" : u === "url" ? "url" : "text";
|
|
3214
|
+
});
|
|
3215
|
+
return (l, u) => (w(), R(O(Ke), {
|
|
3216
|
+
label: i.field.label,
|
|
3217
|
+
placeholder: i.field.placeholder,
|
|
3218
|
+
required: i.field.required,
|
|
3219
|
+
disabled: i.disabled,
|
|
3220
|
+
clearable: !i.field.required,
|
|
3221
|
+
status: r.value,
|
|
3222
|
+
"helper-text": n.value,
|
|
3223
|
+
type: a.value,
|
|
3224
|
+
value: String(i.value ?? ""),
|
|
3225
|
+
onCoInput: u[0] || (u[0] = (o) => s("update:value", o.detail)),
|
|
3226
|
+
onBlur: u[1] || (u[1] = (o) => s("blur"))
|
|
3227
|
+
}, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "status", "helper-text", "type", "value"]));
|
|
3228
|
+
}
|
|
3229
|
+
}), gs = /* @__PURE__ */ T({
|
|
3230
|
+
__name: "FieldTextArea",
|
|
3231
|
+
props: {
|
|
3232
|
+
field: {},
|
|
3233
|
+
value: {},
|
|
3234
|
+
errors: {},
|
|
3235
|
+
disabled: { type: Boolean }
|
|
3236
|
+
},
|
|
3237
|
+
emits: ["update:value", "blur"],
|
|
3238
|
+
setup(i, { emit: e }) {
|
|
3239
|
+
const t = i, s = e, r = c(() => t.errors.length > 0 ? "error" : "default"), n = c(() => t.errors[0] || t.field.helperText), a = c(() => {
|
|
3240
|
+
var u;
|
|
3241
|
+
return ((u = t.field.originalAttrs) == null ? void 0 : u.rows) ?? 4;
|
|
3242
|
+
}), l = c(
|
|
3243
|
+
() => {
|
|
3244
|
+
var u, o;
|
|
3245
|
+
return ((u = t.field.originalAttrs) == null ? void 0 : u.maxLength) ?? ((o = t.field.ajvProperty) == null ? void 0 : o.maxLength) ?? void 0;
|
|
3246
|
+
}
|
|
3247
|
+
);
|
|
3248
|
+
return (u, o) => (w(), R(O(It), {
|
|
3249
|
+
label: i.field.label,
|
|
3250
|
+
placeholder: i.field.placeholder,
|
|
3251
|
+
required: i.field.required,
|
|
3252
|
+
disabled: i.disabled,
|
|
3253
|
+
clearable: !i.field.required,
|
|
3254
|
+
status: r.value,
|
|
3255
|
+
"helper-text": n.value,
|
|
3256
|
+
rows: a.value,
|
|
3257
|
+
"max-length": l.value,
|
|
3258
|
+
value: String(i.value ?? ""),
|
|
3259
|
+
onCoInput: o[0] || (o[0] = (v) => s("update:value", v.detail)),
|
|
3260
|
+
onCoBlur: o[1] || (o[1] = (v) => s("blur"))
|
|
3261
|
+
}, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "status", "helper-text", "rows", "max-length", "value"]));
|
|
277
3262
|
}
|
|
278
|
-
}),
|
|
3263
|
+
}), tt = /* @__PURE__ */ T({
|
|
279
3264
|
__name: "CoFieldRenderer",
|
|
280
3265
|
props: {
|
|
281
3266
|
field: {},
|
|
@@ -283,91 +3268,163 @@ const D = /* @__PURE__ */ C({
|
|
|
283
3268
|
errors: {},
|
|
284
3269
|
disabled: { type: Boolean },
|
|
285
3270
|
refState: {},
|
|
3271
|
+
fileState: {},
|
|
3272
|
+
locale: {},
|
|
286
3273
|
fieldComponents: {}
|
|
287
3274
|
},
|
|
288
|
-
emits: ["update:value", "blur", "search", "load-more", "open"],
|
|
289
|
-
setup(
|
|
290
|
-
const t = {
|
|
291
|
-
text:
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
3275
|
+
emits: ["update:value", "blur", "mask:accept", "search", "load-more", "open", "upload", "remove-file", "reorder", "add-files", "copy-url"],
|
|
3276
|
+
setup(i, { emit: e }) {
|
|
3277
|
+
const t = gt(() => import("./FieldObject-Cxd3I0Jv.js")), s = {
|
|
3278
|
+
text: ms,
|
|
3279
|
+
masked: os,
|
|
3280
|
+
phone: cs,
|
|
3281
|
+
textarea: gs,
|
|
3282
|
+
html: fs,
|
|
3283
|
+
number: Ee,
|
|
3284
|
+
// Default date renderer is the Cobalt date picker (manual input + calendar).
|
|
3285
|
+
// The native `<input type="date">` wrapper (FieldDate) stays exported for
|
|
3286
|
+
// apps that opt back in via the `fieldComponents` prop.
|
|
3287
|
+
date: Ot,
|
|
3288
|
+
boolean: Tt,
|
|
3289
|
+
select: xe,
|
|
3290
|
+
radio: xe,
|
|
3291
|
+
checkbox: xe,
|
|
3292
|
+
ref: ps,
|
|
3293
|
+
rating: Ee,
|
|
3294
|
+
slider: Ee,
|
|
3295
|
+
color: Rt,
|
|
302
3296
|
section: null,
|
|
303
|
-
file:
|
|
3297
|
+
file: Nt,
|
|
304
3298
|
array: null,
|
|
3299
|
+
object: t,
|
|
3300
|
+
tags: hs,
|
|
3301
|
+
mixed: ds,
|
|
3302
|
+
"fill-blank": null,
|
|
3303
|
+
ordering: null,
|
|
3304
|
+
matching: null,
|
|
3305
|
+
"image-choice": null,
|
|
305
3306
|
custom: null
|
|
306
|
-
}, r =
|
|
307
|
-
var
|
|
308
|
-
const
|
|
309
|
-
return
|
|
310
|
-
});
|
|
311
|
-
return (
|
|
312
|
-
field:
|
|
313
|
-
value:
|
|
314
|
-
errors:
|
|
315
|
-
disabled:
|
|
316
|
-
"ref-state":
|
|
317
|
-
"
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
3307
|
+
}, r = i, n = e, a = c(() => {
|
|
3308
|
+
var u, o;
|
|
3309
|
+
const l = r.field.originalAttrs.uiCom;
|
|
3310
|
+
return l && ((u = r.fieldComponents) != null && u[l]) ? r.fieldComponents[l] : (o = r.fieldComponents) != null && o[r.field.kind] ? r.fieldComponents[r.field.kind] : s[r.field.kind] ?? null;
|
|
3311
|
+
});
|
|
3312
|
+
return (l, u) => (w(), R(vt(a.value), {
|
|
3313
|
+
field: i.field,
|
|
3314
|
+
value: i.value,
|
|
3315
|
+
errors: i.errors,
|
|
3316
|
+
disabled: i.disabled,
|
|
3317
|
+
"ref-state": i.refState,
|
|
3318
|
+
"file-state": i.fileState,
|
|
3319
|
+
locale: i.locale,
|
|
3320
|
+
"field-components": i.fieldComponents,
|
|
3321
|
+
"onUpdate:value": u[0] || (u[0] = (o) => n("update:value", o)),
|
|
3322
|
+
onBlur: u[1] || (u[1] = (o) => n("blur")),
|
|
3323
|
+
onSearch: u[2] || (u[2] = (o) => n("search", o)),
|
|
3324
|
+
onLoadMore: u[3] || (u[3] = (o) => n("load-more")),
|
|
3325
|
+
onOpen: u[4] || (u[4] = (o) => n("open")),
|
|
3326
|
+
onUpload: u[5] || (u[5] = (o) => n("upload", o)),
|
|
3327
|
+
onRemoveFile: u[6] || (u[6] = (o) => n("remove-file", o)),
|
|
3328
|
+
onReorder: u[7] || (u[7] = (o) => n("reorder", o)),
|
|
3329
|
+
onAddFiles: u[8] || (u[8] = (o) => n("add-files", o)),
|
|
3330
|
+
onCopyUrl: u[9] || (u[9] = (o) => n("copy-url", o)),
|
|
3331
|
+
"onMask:accept": u[10] || (u[10] = (o) => n("mask:accept", o))
|
|
3332
|
+
}, null, 40, ["field", "value", "errors", "disabled", "ref-state", "file-state", "locale", "field-components"]));
|
|
3333
|
+
}
|
|
3334
|
+
}), qe = {
|
|
3335
|
+
sm: "var(--co-spacing-sm, 8px)",
|
|
3336
|
+
md: "var(--co-spacing-md, 12px)",
|
|
3337
|
+
lg: "var(--co-spacing-lg, 16px)"
|
|
3338
|
+
}, vs = "15rem", ks = /* @__PURE__ */ new Set([
|
|
3339
|
+
"TextArea",
|
|
3340
|
+
"HtmlEditor",
|
|
3341
|
+
"CodeEditor",
|
|
3342
|
+
"TemplateEditor",
|
|
3343
|
+
"FilterEditor",
|
|
3344
|
+
"objectEditor",
|
|
3345
|
+
"langEditor"
|
|
3346
|
+
]);
|
|
3347
|
+
function st(i) {
|
|
3348
|
+
var t;
|
|
3349
|
+
if (i.fullWidth) return !0;
|
|
3350
|
+
const e = (t = i.originalAttrs) == null ? void 0 : t.uiCom;
|
|
3351
|
+
return typeof e == "string" && ks.has(e);
|
|
3352
|
+
}
|
|
3353
|
+
function it(i, e) {
|
|
3354
|
+
const t = Math.max(1, Math.floor(i));
|
|
3355
|
+
return {
|
|
3356
|
+
display: "grid",
|
|
3357
|
+
gap: qe[e] ?? qe.lg,
|
|
3358
|
+
"grid-template-columns": t <= 1 ? "1fr" : `repeat(auto-fit, minmax(min(100%, ${vs}), 1fr))`
|
|
3359
|
+
};
|
|
3360
|
+
}
|
|
3361
|
+
function Cs(i, e) {
|
|
3362
|
+
return !i.colSpan || i.colSpan < 1 ? 1 : Math.min(Math.floor(i.colSpan), Math.max(1, e));
|
|
3363
|
+
}
|
|
3364
|
+
function rt(i, e, t) {
|
|
3365
|
+
if (t) return { style: { "grid-column": "1 / -1" } };
|
|
3366
|
+
const s = Cs(i, e);
|
|
3367
|
+
return s <= 1 ? {} : { style: { "grid-column": `span ${s}` } };
|
|
3368
|
+
}
|
|
3369
|
+
const $e = Symbol("co-form-depth"), nt = Symbol("co-form-expand-all"), we = Symbol("co-form-columns"), at = Symbol("co-form-errors"), lt = Symbol("co-form-touched"), ut = Symbol("co-form-touch"), ys = ["data-has-error"], bs = { class: "co-form-footer" }, ze = 20, As = /* @__PURE__ */ T({
|
|
325
3370
|
__name: "CoFormRenderer",
|
|
326
3371
|
props: {
|
|
327
3372
|
form: {},
|
|
328
3373
|
layout: {},
|
|
329
3374
|
disabled: { type: Boolean },
|
|
330
3375
|
excludeFields: {},
|
|
3376
|
+
locale: {},
|
|
331
3377
|
fieldComponents: {},
|
|
332
|
-
refResolver: { type: Function }
|
|
3378
|
+
refResolver: { type: Function },
|
|
3379
|
+
uploadResolver: { type: Function },
|
|
3380
|
+
removeResolver: { type: Function },
|
|
3381
|
+
columns: {},
|
|
3382
|
+
gap: {},
|
|
3383
|
+
expandAll: { type: Boolean }
|
|
333
3384
|
},
|
|
334
|
-
emits: ["submit", "invalid", "change"],
|
|
335
|
-
setup(
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
3385
|
+
emits: ["submit", "invalid", "change", "copy-url"],
|
|
3386
|
+
setup(i, { expose: e, emit: t }) {
|
|
3387
|
+
const s = i, r = t, n = c(() => s.layout ?? "grid");
|
|
3388
|
+
se(nt, c(() => !!s.expandAll));
|
|
3389
|
+
const a = c(() => {
|
|
3390
|
+
const d = new Set(s.excludeFields ?? []);
|
|
3391
|
+
return s.form.fields.value.filter((g) => !g.hidden && !d.has(g.name));
|
|
3392
|
+
}), l = c(() => n.value === "stack" ? 1 : s.columns ?? 2), u = c(() => s.gap ?? "lg");
|
|
3393
|
+
se(we, l), se(at, c(() => s.form.errors.value)), se(lt, c(() => s.form.touched.value)), se(ut, (d) => s.form.touch(d));
|
|
3394
|
+
const o = c(() => it(l.value, u.value));
|
|
3395
|
+
function v(d) {
|
|
3396
|
+
return rt(d, l.value, st(d));
|
|
3397
|
+
}
|
|
3398
|
+
function p(d) {
|
|
3399
|
+
const g = d.path ?? d.name;
|
|
3400
|
+
return s.form.touched.value[g] ? s.form.errors.value[g] || [] : [];
|
|
3401
|
+
}
|
|
3402
|
+
const m = H(null);
|
|
3403
|
+
function E() {
|
|
3404
|
+
var h, k;
|
|
3405
|
+
const d = (h = m.value) == null ? void 0 : h.querySelector("[data-has-error]");
|
|
3406
|
+
if (!d) return;
|
|
3407
|
+
d.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
3408
|
+
const f = Array.from(d.querySelectorAll("*")).find(
|
|
3409
|
+
(_) => _.tagName.startsWith("CO-")
|
|
3410
|
+
) ?? d.querySelector("input, textarea, select, button, [tabindex]");
|
|
3411
|
+
(k = f == null ? void 0 : f.focus) == null || k.call(f, { preventScroll: !0 });
|
|
3412
|
+
}
|
|
3413
|
+
e({ scrollToFirstError: E });
|
|
3414
|
+
function b(d, g) {
|
|
3415
|
+
s.form.setValue(d, g), r("change", { name: d, value: g });
|
|
3416
|
+
}
|
|
3417
|
+
async function S() {
|
|
3418
|
+
const d = await s.form.submit();
|
|
3419
|
+
if (!d.isValid) {
|
|
3420
|
+
s.form.touchAll(), r("invalid", d.errors), kt(E);
|
|
364
3421
|
return;
|
|
365
3422
|
}
|
|
366
|
-
const
|
|
367
|
-
r("submit", { values:
|
|
3423
|
+
const g = s.form.fields.value.reduce((f, h) => (f[h.name] = h.ajvProperty, f), {});
|
|
3424
|
+
r("submit", { values: ct(d.values, g) });
|
|
368
3425
|
}
|
|
369
|
-
const
|
|
370
|
-
function
|
|
3426
|
+
const M = Oe({});
|
|
3427
|
+
function W() {
|
|
371
3428
|
return {
|
|
372
3429
|
options: [],
|
|
373
3430
|
selectedDisplay: [],
|
|
@@ -378,137 +3435,504 @@ const D = /* @__PURE__ */ C({
|
|
|
378
3435
|
query: ""
|
|
379
3436
|
};
|
|
380
3437
|
}
|
|
381
|
-
function
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
value:
|
|
385
|
-
label: String(
|
|
386
|
-
meta:
|
|
3438
|
+
function re(d, g) {
|
|
3439
|
+
const f = d.originalAttrs.displayName || "name", h = [], k = [], _ = (V) => {
|
|
3440
|
+
V && (typeof V == "string" ? h.push(V) : typeof V == "object" && V._id && (h.push(V._id), k.push({
|
|
3441
|
+
value: V._id,
|
|
3442
|
+
label: String(V[f] ?? V.name ?? V._id),
|
|
3443
|
+
meta: V
|
|
387
3444
|
})));
|
|
388
3445
|
};
|
|
389
|
-
return Array.isArray(
|
|
3446
|
+
return Array.isArray(g) ? g.forEach(_) : _(g), { ids: h, display: k };
|
|
390
3447
|
}
|
|
391
|
-
async function
|
|
392
|
-
if (!
|
|
393
|
-
const
|
|
394
|
-
|
|
3448
|
+
async function Z(d, g) {
|
|
3449
|
+
if (!s.refResolver) return;
|
|
3450
|
+
const f = M[d.name] || W();
|
|
3451
|
+
f.loading = !0, M[d.name] = { ...f };
|
|
395
3452
|
try {
|
|
396
|
-
const
|
|
397
|
-
model:
|
|
398
|
-
pageSize:
|
|
399
|
-
...
|
|
400
|
-
}),
|
|
401
|
-
|
|
402
|
-
...
|
|
403
|
-
options:
|
|
404
|
-
total:
|
|
405
|
-
hasMore:
|
|
406
|
-
page:
|
|
407
|
-
query:
|
|
3453
|
+
const h = await s.refResolver({
|
|
3454
|
+
model: d.originalAttrs.ref,
|
|
3455
|
+
pageSize: ze,
|
|
3456
|
+
...g
|
|
3457
|
+
}), k = M[d.name], _ = (g.page ?? 1) > 1;
|
|
3458
|
+
M[d.name] = {
|
|
3459
|
+
...k,
|
|
3460
|
+
options: _ ? [...k.options, ...h.options] : h.options,
|
|
3461
|
+
total: h.total ?? h.options.length,
|
|
3462
|
+
hasMore: h.hasMore ?? (g.page ?? 1) * ze < (h.total ?? h.options.length),
|
|
3463
|
+
page: g.page ?? 1,
|
|
3464
|
+
query: g.query ?? k.query,
|
|
408
3465
|
loading: !1
|
|
409
3466
|
};
|
|
410
|
-
} catch (
|
|
411
|
-
console.error("[CoFormRenderer] refResolver failed:",
|
|
3467
|
+
} catch (h) {
|
|
3468
|
+
console.error("[CoFormRenderer] refResolver failed:", h), M[d.name] = { ...M[d.name], loading: !1 };
|
|
412
3469
|
}
|
|
413
3470
|
}
|
|
414
|
-
async function
|
|
415
|
-
if (!
|
|
416
|
-
const
|
|
417
|
-
|
|
3471
|
+
async function ee(d, g) {
|
|
3472
|
+
if (!s.refResolver) return;
|
|
3473
|
+
const f = M[d.name] || W();
|
|
3474
|
+
f.loading = !0, M[d.name] = { ...f };
|
|
418
3475
|
try {
|
|
419
|
-
const
|
|
420
|
-
for (const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
} catch (
|
|
424
|
-
console.error("[CoFormRenderer] hydrateRef failed:",
|
|
3476
|
+
const h = await s.refResolver({ model: d.originalAttrs.ref, ids: g }), k = M[d.name], _ = new Set(k.selectedDisplay.map((ae) => ae.value)), V = [...k.selectedDisplay];
|
|
3477
|
+
for (const ae of h.options)
|
|
3478
|
+
_.has(ae.value) || V.push(ae);
|
|
3479
|
+
M[d.name] = { ...k, selectedDisplay: V, loading: !1 };
|
|
3480
|
+
} catch (h) {
|
|
3481
|
+
console.error("[CoFormRenderer] hydrateRef failed:", h), M[d.name] = { ...M[d.name], loading: !1 };
|
|
425
3482
|
}
|
|
426
3483
|
}
|
|
427
|
-
function
|
|
428
|
-
for (const
|
|
429
|
-
if (
|
|
430
|
-
const { ids:
|
|
431
|
-
|
|
432
|
-
const
|
|
433
|
-
|
|
3484
|
+
function z() {
|
|
3485
|
+
for (const d of s.form.fields.value) {
|
|
3486
|
+
if (d.kind !== "ref") continue;
|
|
3487
|
+
const { ids: g, display: f } = re(d, s.form.values.value[d.name]);
|
|
3488
|
+
M[d.name] = { ...W(), selectedDisplay: f };
|
|
3489
|
+
const h = g.filter((k) => !f.some((_) => _.value === k));
|
|
3490
|
+
h.length > 0 && ee(d, h);
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
3493
|
+
Se(z), J(() => s.form.fields.value, z, { flush: "post" });
|
|
3494
|
+
function ne(d) {
|
|
3495
|
+
const g = M[d.name];
|
|
3496
|
+
g && g.options.length === 0 && !g.loading && Z(d, { query: "", page: 1 });
|
|
3497
|
+
}
|
|
3498
|
+
function oe(d, g) {
|
|
3499
|
+
Z(d, { query: g, page: 1 });
|
|
3500
|
+
}
|
|
3501
|
+
function de(d) {
|
|
3502
|
+
const g = M[d.name];
|
|
3503
|
+
!g || g.loading || !g.hasMore || Z(d, { query: g.query, page: g.page + 1 });
|
|
3504
|
+
}
|
|
3505
|
+
const I = Oe({});
|
|
3506
|
+
function A(d) {
|
|
3507
|
+
var f;
|
|
3508
|
+
const g = d.originalAttrs;
|
|
3509
|
+
return !!g.multiple || Array.isArray(g.type) || ((f = g.type) == null ? void 0 : f[0]) === "array";
|
|
3510
|
+
}
|
|
3511
|
+
function D(d) {
|
|
3512
|
+
const g = (h) => {
|
|
3513
|
+
if (!h) return null;
|
|
3514
|
+
if (typeof h == "string") return { id: h, name: h, status: "done" };
|
|
3515
|
+
if (typeof h == "object") {
|
|
3516
|
+
const k = h._id || h.id;
|
|
3517
|
+
return k ? {
|
|
3518
|
+
id: k,
|
|
3519
|
+
name: h.fileName || h.name || h.originalName || k,
|
|
3520
|
+
size: h.size,
|
|
3521
|
+
url: h.url,
|
|
3522
|
+
thumbnail: h.thumbnail,
|
|
3523
|
+
fileCode: h.fileCode,
|
|
3524
|
+
status: "done"
|
|
3525
|
+
} : null;
|
|
3526
|
+
}
|
|
3527
|
+
return null;
|
|
3528
|
+
};
|
|
3529
|
+
if (d == null || d === "") return [];
|
|
3530
|
+
if (Array.isArray(d)) return d.map(g).filter((h) => !!h);
|
|
3531
|
+
const f = g(d);
|
|
3532
|
+
return f ? [f] : [];
|
|
3533
|
+
}
|
|
3534
|
+
function C() {
|
|
3535
|
+
for (const d of s.form.fields.value)
|
|
3536
|
+
d.kind === "file" && (I[d.name] = D(s.form.values.value[d.name]));
|
|
3537
|
+
}
|
|
3538
|
+
Se(C), J(() => s.form.fields.value, C, { flush: "post" });
|
|
3539
|
+
function B(d) {
|
|
3540
|
+
var h;
|
|
3541
|
+
const g = (I[d.name] || []).filter((k) => k.status === "done" && k.id), f = A(d) ? g.map((k) => k.id) : ((h = g[0]) == null ? void 0 : h.id) ?? null;
|
|
3542
|
+
s.form.setValue(d.name, f), r("change", { name: d.name, value: f });
|
|
3543
|
+
}
|
|
3544
|
+
async function U(d, g) {
|
|
3545
|
+
if (!s.uploadResolver) {
|
|
3546
|
+
console.warn("[CoFormRenderer] file upload requires an `uploadResolver` prop.");
|
|
3547
|
+
return;
|
|
3548
|
+
}
|
|
3549
|
+
const f = A(d);
|
|
3550
|
+
I[d.name] || (I[d.name] = []), f || (I[d.name] = []), g.files.forEach((h, k) => {
|
|
3551
|
+
const _ = g.tempIds[k];
|
|
3552
|
+
I[d.name] = [
|
|
3553
|
+
...I[d.name],
|
|
3554
|
+
{ tempId: _, name: h.name, size: h.size, status: "uploading", progress: 0 }
|
|
3555
|
+
], q(d, h, _);
|
|
3556
|
+
});
|
|
3557
|
+
}
|
|
3558
|
+
async function q(d, g, f) {
|
|
3559
|
+
const h = (k) => {
|
|
3560
|
+
I[d.name] = (I[d.name] || []).map(
|
|
3561
|
+
(_) => _.tempId === f ? k(_) : _
|
|
3562
|
+
);
|
|
3563
|
+
};
|
|
3564
|
+
try {
|
|
3565
|
+
const k = await s.uploadResolver({
|
|
3566
|
+
field: d.name,
|
|
3567
|
+
file: g,
|
|
3568
|
+
multiple: A(d),
|
|
3569
|
+
originalAttrs: d.originalAttrs,
|
|
3570
|
+
onProgress: (_) => h((V) => ({ ...V, progress: _ }))
|
|
3571
|
+
});
|
|
3572
|
+
h((_) => ({
|
|
3573
|
+
..._,
|
|
3574
|
+
id: k.id,
|
|
3575
|
+
name: k.name ?? _.name,
|
|
3576
|
+
url: k.url,
|
|
3577
|
+
thumbnail: k.thumbnail,
|
|
3578
|
+
fileCode: k.fileCode,
|
|
3579
|
+
progress: 100,
|
|
3580
|
+
status: "done"
|
|
3581
|
+
})), B(d);
|
|
3582
|
+
} catch (k) {
|
|
3583
|
+
console.error("[CoFormRenderer] uploadResolver failed:", k), h((_) => ({ ..._, status: "error", error: (k == null ? void 0 : k.message) || "Upload failed" }));
|
|
434
3584
|
}
|
|
435
3585
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
3586
|
+
function te(d, g) {
|
|
3587
|
+
const f = (I[d.name] || []).find(
|
|
3588
|
+
(h) => h.id === g || h.tempId === g
|
|
3589
|
+
);
|
|
3590
|
+
I[d.name] = (I[d.name] || []).filter(
|
|
3591
|
+
(h) => h.id !== g && h.tempId !== g
|
|
3592
|
+
), B(d), s.removeResolver && (f == null ? void 0 : f.status) === "done" && f.id && s.removeResolver({
|
|
3593
|
+
field: d.name,
|
|
3594
|
+
id: f.id,
|
|
3595
|
+
fileCode: f.fileCode,
|
|
3596
|
+
originalAttrs: d.originalAttrs
|
|
3597
|
+
}).catch((h) => console.error("[CoFormRenderer] removeResolver failed:", h));
|
|
440
3598
|
}
|
|
441
|
-
function
|
|
442
|
-
|
|
3599
|
+
function P(d, g) {
|
|
3600
|
+
const f = I[d.name] || [], h = (_) => _.id || _.tempId || `${_.name}:${_.size ?? ""}`, k = new Map(g.map((_, V) => [_, V]));
|
|
3601
|
+
I[d.name] = [...f].sort((_, V) => {
|
|
3602
|
+
const ae = k.has(h(_)) ? k.get(h(_)) : g.length + f.indexOf(_), dt = k.has(h(V)) ? k.get(h(V)) : g.length + f.indexOf(V);
|
|
3603
|
+
return ae - dt;
|
|
3604
|
+
}), B(d);
|
|
443
3605
|
}
|
|
444
|
-
function
|
|
445
|
-
|
|
446
|
-
|
|
3606
|
+
function Ae(d, g) {
|
|
3607
|
+
if (!(g != null && g.length)) return;
|
|
3608
|
+
const f = g.filter((k) => k && k.id).map((k) => ({
|
|
3609
|
+
id: k.id,
|
|
3610
|
+
name: k.name || k.id,
|
|
3611
|
+
size: k.size,
|
|
3612
|
+
url: k.url,
|
|
3613
|
+
thumbnail: k.thumbnail,
|
|
3614
|
+
fileCode: k.fileCode,
|
|
3615
|
+
status: "done"
|
|
3616
|
+
}));
|
|
3617
|
+
if (!f.length) return;
|
|
3618
|
+
const h = I[d.name] || [];
|
|
3619
|
+
if (!A(d))
|
|
3620
|
+
I[d.name] = [f[0]];
|
|
3621
|
+
else {
|
|
3622
|
+
const k = new Set(h.map((_) => _.id).filter(Boolean));
|
|
3623
|
+
I[d.name] = [...h, ...f.filter((_) => !k.has(_.id))];
|
|
3624
|
+
}
|
|
3625
|
+
B(d);
|
|
447
3626
|
}
|
|
448
|
-
return (
|
|
449
|
-
|
|
3627
|
+
return (d, g) => (w(), j("form", {
|
|
3628
|
+
ref_key: "formEl",
|
|
3629
|
+
ref: m,
|
|
3630
|
+
onSubmit: Pe(S, ["prevent"])
|
|
450
3631
|
}, [
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
class:
|
|
3632
|
+
he(d.$slots, "header", { form: i.form }, void 0, !0),
|
|
3633
|
+
ce("div", {
|
|
3634
|
+
class: "co-form-grid",
|
|
3635
|
+
style: Be(o.value)
|
|
454
3636
|
}, [
|
|
455
|
-
(
|
|
456
|
-
key:
|
|
457
|
-
class:
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
3637
|
+
(w(!0), j(je, null, He(a.value, (f) => (w(), j("div", Ge({
|
|
3638
|
+
key: f.name,
|
|
3639
|
+
class: "co-form-field",
|
|
3640
|
+
"data-has-error": p(f).length > 0 || void 0
|
|
3641
|
+
}, { ref_for: !0 }, v(f)), [
|
|
3642
|
+
he(d.$slots, `field:${f.name}`, {
|
|
3643
|
+
field: f,
|
|
3644
|
+
value: i.form.values.value[f.name],
|
|
3645
|
+
errors: p(f),
|
|
3646
|
+
setValue: (h) => i.form.setValue(f.name, h),
|
|
3647
|
+
touch: () => i.form.touch(f.name)
|
|
465
3648
|
}, () => [
|
|
466
|
-
|
|
467
|
-
field:
|
|
468
|
-
value:
|
|
469
|
-
errors:
|
|
470
|
-
disabled:
|
|
471
|
-
"ref-state":
|
|
472
|
-
"
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
3649
|
+
me(tt, {
|
|
3650
|
+
field: f,
|
|
3651
|
+
value: i.form.values.value[f.name],
|
|
3652
|
+
errors: p(f),
|
|
3653
|
+
disabled: i.disabled || f.disabled,
|
|
3654
|
+
"ref-state": M[f.name],
|
|
3655
|
+
"file-state": I[f.name],
|
|
3656
|
+
locale: i.locale,
|
|
3657
|
+
"field-components": i.fieldComponents,
|
|
3658
|
+
"onUpdate:value": (h) => b(f.name, h),
|
|
3659
|
+
onBlur: (h) => i.form.touch(f.name),
|
|
3660
|
+
onSearch: (h) => oe(f, h),
|
|
3661
|
+
onLoadMore: (h) => de(f),
|
|
3662
|
+
onOpen: (h) => ne(f),
|
|
3663
|
+
onUpload: (h) => U(f, h),
|
|
3664
|
+
onRemoveFile: (h) => te(f, h),
|
|
3665
|
+
onReorder: (h) => P(f, h),
|
|
3666
|
+
onAddFiles: (h) => Ae(f, h),
|
|
3667
|
+
onCopyUrl: (h) => r("copy-url", { field: f.name, ...h })
|
|
3668
|
+
}, null, 8, ["field", "value", "errors", "disabled", "ref-state", "file-state", "locale", "field-components", "onUpdate:value", "onBlur", "onSearch", "onLoadMore", "onOpen", "onUpload", "onRemoveFile", "onReorder", "onAddFiles", "onCopyUrl"])
|
|
479
3669
|
], !0)
|
|
480
|
-
],
|
|
481
|
-
],
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
form:
|
|
485
|
-
submit:
|
|
3670
|
+
], 16, ys))), 128))
|
|
3671
|
+
], 4),
|
|
3672
|
+
ce("div", bs, [
|
|
3673
|
+
he(d.$slots, "footer", {
|
|
3674
|
+
form: i.form,
|
|
3675
|
+
submit: S
|
|
486
3676
|
}, () => [
|
|
487
|
-
|
|
3677
|
+
me(O(Vt), {
|
|
488
3678
|
type: "submit",
|
|
489
3679
|
label: "Enviar",
|
|
490
3680
|
variant: "primary"
|
|
491
3681
|
})
|
|
492
3682
|
], !0)
|
|
493
3683
|
])
|
|
494
|
-
],
|
|
3684
|
+
], 544));
|
|
495
3685
|
}
|
|
496
|
-
}),
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
},
|
|
3686
|
+
}), Rs = /* @__PURE__ */ De(As, [["__scopeId", "data-v-15ca81e7"]]), Os = /* @__PURE__ */ T({
|
|
3687
|
+
__name: "FieldDate",
|
|
3688
|
+
props: {
|
|
3689
|
+
field: {},
|
|
3690
|
+
value: {},
|
|
3691
|
+
errors: {},
|
|
3692
|
+
disabled: { type: Boolean }
|
|
3693
|
+
},
|
|
3694
|
+
emits: ["update:value", "blur"],
|
|
3695
|
+
setup(i, { emit: e }) {
|
|
3696
|
+
const t = i, s = e, r = c(() => t.errors.length > 0 ? "error" : "default"), n = c(() => t.errors[0] || t.field.helperText);
|
|
3697
|
+
return (a, l) => (w(), R(O(Ke), {
|
|
3698
|
+
label: i.field.label,
|
|
3699
|
+
placeholder: i.field.placeholder,
|
|
3700
|
+
required: i.field.required,
|
|
3701
|
+
disabled: i.disabled,
|
|
3702
|
+
clearable: !i.field.required,
|
|
3703
|
+
status: r.value,
|
|
3704
|
+
"helper-text": n.value,
|
|
3705
|
+
type: "date",
|
|
3706
|
+
value: String(i.value ?? ""),
|
|
3707
|
+
onCoInput: l[0] || (l[0] = (u) => s("update:value", u.detail)),
|
|
3708
|
+
onBlur: l[1] || (l[1] = (u) => s("blur"))
|
|
3709
|
+
}, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "status", "helper-text", "value"]));
|
|
3710
|
+
}
|
|
3711
|
+
}), Fs = 3;
|
|
3712
|
+
function Te(i) {
|
|
3713
|
+
return i == null || i === "" ? !0 : Array.isArray(i) ? i.length === 0 : typeof i == "object" ? Object.keys(i).length === 0 : !1;
|
|
3714
|
+
}
|
|
3715
|
+
function ot(i, e) {
|
|
3716
|
+
return i == null ? void 0 : i[e.name];
|
|
3717
|
+
}
|
|
3718
|
+
function Es(i, e) {
|
|
3719
|
+
return i.some((t) => !Te(ot(e, t)));
|
|
3720
|
+
}
|
|
3721
|
+
function xs(i, e) {
|
|
3722
|
+
return i.some((t) => t.required && Te(ot(e, t)));
|
|
3723
|
+
}
|
|
3724
|
+
function _s({
|
|
3725
|
+
children: i,
|
|
3726
|
+
objectValue: e,
|
|
3727
|
+
errors: t,
|
|
3728
|
+
originalAttrs: s
|
|
3729
|
+
}) {
|
|
3730
|
+
return t && t.length > 0 || (s == null ? void 0 : s.expanded) === !0 ? !0 : (s == null ? void 0 : s.collapsed) === !0 ? !1 : !!(xs(i, e) || !Es(i, e));
|
|
3731
|
+
}
|
|
3732
|
+
function Ss(i, e) {
|
|
3733
|
+
var t, s, r;
|
|
3734
|
+
if (Te(e)) return null;
|
|
3735
|
+
switch (i.kind) {
|
|
3736
|
+
case "select":
|
|
3737
|
+
case "radio":
|
|
3738
|
+
case "checkbox": {
|
|
3739
|
+
const n = ((t = i.originalAttrs) == null ? void 0 : t.enumLabels) ?? ((s = i.originalAttrs) == null ? void 0 : s.labels) ?? null;
|
|
3740
|
+
return n && typeof n == "object" && !Array.isArray(n) ? String(n[e] ?? e) : String(e);
|
|
3741
|
+
}
|
|
3742
|
+
case "boolean":
|
|
3743
|
+
return e ? "Sí" : "No";
|
|
3744
|
+
case "ref": {
|
|
3745
|
+
if (e && typeof e == "object") {
|
|
3746
|
+
const n = ((r = i.originalAttrs) == null ? void 0 : r.displayName) || "name", a = e[n] ?? e.name ?? e.label ?? e.displayName;
|
|
3747
|
+
return a ? String(a) : null;
|
|
3748
|
+
}
|
|
3749
|
+
return null;
|
|
3750
|
+
}
|
|
3751
|
+
case "tags":
|
|
3752
|
+
case "array":
|
|
3753
|
+
return Array.isArray(e) ? e.map(String).join(", ") : null;
|
|
3754
|
+
case "object":
|
|
3755
|
+
case "file":
|
|
3756
|
+
return null;
|
|
3757
|
+
// don't summarize nested objects or files inline
|
|
3758
|
+
default:
|
|
3759
|
+
return typeof e == "object" ? null : String(e);
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
function Bs(i, e, t) {
|
|
3763
|
+
const s = [];
|
|
3764
|
+
for (const a of i) {
|
|
3765
|
+
const l = Ss(a, e == null ? void 0 : e[a.name]);
|
|
3766
|
+
l != null && l !== "" && s.push(l);
|
|
3767
|
+
}
|
|
3768
|
+
if (s.length === 0) return "";
|
|
3769
|
+
const r = s.slice(0, Fs), n = s.length - r.length;
|
|
3770
|
+
return n > 0 ? `${r.join(" · ")} +${n}` : r.join(" · ");
|
|
3771
|
+
}
|
|
3772
|
+
const Ms = ["data-has-error"], ws = {
|
|
3773
|
+
key: 0,
|
|
3774
|
+
style: {
|
|
3775
|
+
marginTop: "var(--co-spacing-sm, 8px)",
|
|
3776
|
+
color: "var(--co-semantic-status-error, #aa2e1b)",
|
|
3777
|
+
fontSize: "var(--co-font-size-14, 14px)",
|
|
3778
|
+
fontFamily: "var(--co-font-family-primary)"
|
|
3779
|
+
}
|
|
3780
|
+
}, Ls = /* @__PURE__ */ T({
|
|
3781
|
+
__name: "FieldObject",
|
|
3782
|
+
props: {
|
|
3783
|
+
field: {},
|
|
3784
|
+
value: {},
|
|
3785
|
+
errors: {},
|
|
3786
|
+
disabled: { type: Boolean },
|
|
3787
|
+
locale: {},
|
|
3788
|
+
fieldComponents: {}
|
|
3789
|
+
},
|
|
3790
|
+
emits: ["update:value"],
|
|
3791
|
+
setup(i, { emit: e }) {
|
|
3792
|
+
const t = i, s = e, r = c(() => t.field.children ?? []), n = r.value.filter((A) => A.kind === "ref" || A.kind === "file");
|
|
3793
|
+
n.length > 0 && console.warn(
|
|
3794
|
+
`[FieldObject] ${n.map((A) => `"${A.path ?? A.name}" (${A.kind})`).join(", ")} nested inside an object field: ref/file resolvers do not reach nested fields yet.`
|
|
3795
|
+
);
|
|
3796
|
+
const a = le($e, 0);
|
|
3797
|
+
se($e, a + 1);
|
|
3798
|
+
const l = c(
|
|
3799
|
+
() => a > 0 ? {
|
|
3800
|
+
paddingLeft: "var(--co-spacing-lg, 16px)",
|
|
3801
|
+
borderLeft: "1px solid var(--co-semantic-border-subtle, rgba(31, 28, 27, 0.08))"
|
|
3802
|
+
} : {}
|
|
3803
|
+
), u = c(
|
|
3804
|
+
() => t.value && typeof t.value == "object" && !Array.isArray(t.value) ? t.value : {}
|
|
3805
|
+
), o = le(we, H(2)), v = c(() => {
|
|
3806
|
+
var D;
|
|
3807
|
+
const A = Number((D = t.field.originalAttrs) == null ? void 0 : D.columns);
|
|
3808
|
+
return Number.isFinite(A) && A >= 1 ? Math.floor(A) : o.value;
|
|
3809
|
+
});
|
|
3810
|
+
se(we, v);
|
|
3811
|
+
const p = c(() => {
|
|
3812
|
+
var D;
|
|
3813
|
+
const A = (D = t.field.originalAttrs) == null ? void 0 : D.gap;
|
|
3814
|
+
return A === "sm" || A === "md" || A === "lg" ? A : "lg";
|
|
3815
|
+
}), m = c(() => it(v.value, p.value));
|
|
3816
|
+
function E(A) {
|
|
3817
|
+
return rt(A, v.value, st(A));
|
|
3818
|
+
}
|
|
3819
|
+
const b = le(at, H({})), S = le(lt, H({})), M = le(ut, () => {
|
|
3820
|
+
});
|
|
3821
|
+
function W(A) {
|
|
3822
|
+
return A.path ?? A.name;
|
|
3823
|
+
}
|
|
3824
|
+
function re(A) {
|
|
3825
|
+
const D = W(A);
|
|
3826
|
+
return S.value[D] ? b.value[D] || [] : [];
|
|
3827
|
+
}
|
|
3828
|
+
function Z(A) {
|
|
3829
|
+
M(W(A));
|
|
3830
|
+
}
|
|
3831
|
+
const ee = le(nt, H(!1)), z = H(
|
|
3832
|
+
ee.value || _s({
|
|
3833
|
+
children: r.value,
|
|
3834
|
+
objectValue: u.value,
|
|
3835
|
+
errors: t.errors,
|
|
3836
|
+
originalAttrs: t.field.originalAttrs
|
|
3837
|
+
})
|
|
3838
|
+
);
|
|
3839
|
+
J(
|
|
3840
|
+
() => t.errors,
|
|
3841
|
+
(A) => {
|
|
3842
|
+
A && A.length > 0 && (z.value = !0);
|
|
3843
|
+
}
|
|
3844
|
+
);
|
|
3845
|
+
const ne = c(() => `${t.field.path ?? t.field.name}.`), oe = c(
|
|
3846
|
+
() => Object.keys(b.value).some(
|
|
3847
|
+
(A) => {
|
|
3848
|
+
var D;
|
|
3849
|
+
return A.startsWith(ne.value) && S.value[A] && (((D = b.value[A]) == null ? void 0 : D.length) ?? 0) > 0;
|
|
3850
|
+
}
|
|
3851
|
+
)
|
|
3852
|
+
);
|
|
3853
|
+
J(oe, (A) => {
|
|
3854
|
+
A && (z.value = !0);
|
|
3855
|
+
}), J(ee, (A) => {
|
|
3856
|
+
A && (z.value = !0);
|
|
3857
|
+
});
|
|
3858
|
+
const de = c(
|
|
3859
|
+
() => Bs(r.value, u.value, t.locale)
|
|
3860
|
+
);
|
|
3861
|
+
function I(A, D) {
|
|
3862
|
+
s("update:value", { ...u.value, [A]: D });
|
|
3863
|
+
}
|
|
3864
|
+
return (A, D) => (w(), R(O(Dt), {
|
|
3865
|
+
class: "co-fieldset",
|
|
3866
|
+
heading: i.field.label,
|
|
3867
|
+
subheading: z.value ? "" : de.value,
|
|
3868
|
+
open: z.value,
|
|
3869
|
+
style: Be(l.value),
|
|
3870
|
+
onCoToggle: D[0] || (D[0] = (C) => z.value = C.detail)
|
|
3871
|
+
}, {
|
|
3872
|
+
default: Ie(() => [
|
|
3873
|
+
ce("div", {
|
|
3874
|
+
class: "co-form-grid",
|
|
3875
|
+
style: Be(m.value)
|
|
3876
|
+
}, [
|
|
3877
|
+
(w(!0), j(je, null, He(r.value, (C) => (w(), j("div", Ge({
|
|
3878
|
+
key: C.name,
|
|
3879
|
+
class: "co-form-field",
|
|
3880
|
+
"data-has-error": re(C).length > 0 || void 0
|
|
3881
|
+
}, { ref_for: !0 }, E(C)), [
|
|
3882
|
+
me(tt, {
|
|
3883
|
+
field: C,
|
|
3884
|
+
value: u.value[C.name],
|
|
3885
|
+
errors: re(C),
|
|
3886
|
+
disabled: i.disabled || C.disabled,
|
|
3887
|
+
locale: i.locale,
|
|
3888
|
+
"field-components": i.fieldComponents,
|
|
3889
|
+
"onUpdate:value": (B) => I(C.name, B),
|
|
3890
|
+
onBlur: (B) => Z(C)
|
|
3891
|
+
}, null, 8, ["field", "value", "errors", "disabled", "locale", "field-components", "onUpdate:value", "onBlur"])
|
|
3892
|
+
], 16, Ms))), 128))
|
|
3893
|
+
], 4),
|
|
3894
|
+
i.errors.length ? (w(), j("div", ws, _e(i.errors[0]), 1)) : ue("", !0)
|
|
3895
|
+
]),
|
|
3896
|
+
_: 1
|
|
3897
|
+
}, 8, ["heading", "subheading", "open", "style"]));
|
|
3898
|
+
}
|
|
3899
|
+
});
|
|
502
3900
|
export {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
3901
|
+
tt as CoFieldRenderer,
|
|
3902
|
+
Rs as CoFormRenderer,
|
|
3903
|
+
X as DEFAULT_MASK_CONFIG,
|
|
3904
|
+
we as FORM_COLUMNS,
|
|
3905
|
+
$e as FORM_DEPTH,
|
|
3906
|
+
at as FORM_ERRORS,
|
|
3907
|
+
nt as FORM_EXPAND_ALL,
|
|
3908
|
+
ut as FORM_TOUCH,
|
|
3909
|
+
lt as FORM_TOUCHED,
|
|
3910
|
+
ks as FULL_WIDTH_UICOMS,
|
|
3911
|
+
Tt as FieldBoolean,
|
|
3912
|
+
Rt as FieldColor,
|
|
3913
|
+
Os as FieldDate,
|
|
3914
|
+
Ot as FieldDatePicker,
|
|
3915
|
+
Nt as FieldFile,
|
|
3916
|
+
os as FieldMasked,
|
|
3917
|
+
ds as FieldMixed,
|
|
3918
|
+
hs as FieldMultiple,
|
|
3919
|
+
Ee as FieldNumber,
|
|
3920
|
+
Ls as FieldObject,
|
|
3921
|
+
cs as FieldPhone,
|
|
3922
|
+
ps as FieldRef,
|
|
3923
|
+
xe as FieldSelect,
|
|
3924
|
+
ms as FieldText,
|
|
3925
|
+
gs as FieldTextArea,
|
|
3926
|
+
rt as cellBindings,
|
|
3927
|
+
Cs as cellSpan,
|
|
3928
|
+
_s as computeInitialOpen,
|
|
3929
|
+
$s as createForm,
|
|
3930
|
+
Bs as formatSectionPreview,
|
|
3931
|
+
it as gridRootStyle,
|
|
3932
|
+
Es as hasAnyValue,
|
|
3933
|
+
xs as hasEmptyRequiredChild,
|
|
3934
|
+
Te as isEmptyValue,
|
|
3935
|
+
st as isFullWidthField,
|
|
3936
|
+
es as normalizeMaskConfig,
|
|
3937
|
+
Ts as useForm
|
|
514
3938
|
};
|