@foormjs/vue 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.js +862 -385
- package/dist/index.umd.cjs +3 -3
- package/dist/style.css +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,105 +1,120 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { defineComponent as
|
|
5
|
-
function
|
|
6
|
-
return typeof
|
|
1
|
+
var re = Object.defineProperty;
|
|
2
|
+
var se = (o, e, t) => e in o ? re(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var Y = (o, e, t) => se(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { defineComponent as I, useModel as ae, inject as te, ref as q, computed as _, watch as oe, onUnmounted as le, getCurrentInstance as Q, renderSlot as w, unref as x, mergeModels as ie, provide as ue, openBlock as y, createElementBlock as b, withModifiers as ce, nextTick as pe, createBlock as U, withCtx as K, toDisplayString as g, createCommentVNode as P, Fragment as H, renderList as R, mergeProps as L, resolveDynamicComponent as J, withDirectives as T, normalizeClass as O, createElementVNode as V, vModelDynamic as de, vShow as N, vModelSelect as me, vModelRadio as fe, createTextVNode as Z, vModelCheckbox as he, reactive as ye } from "vue";
|
|
5
|
+
function M(o, e) {
|
|
6
|
+
return typeof o == "function" ? o(e) : o;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const ge = /* @__PURE__ */ new Set(["action", "paragraph"]);
|
|
9
|
+
function ve(o) {
|
|
10
|
+
var e;
|
|
11
|
+
const t = {};
|
|
12
|
+
for (const r of o)
|
|
13
|
+
if (!ge.has(r.type)) {
|
|
14
|
+
const s = {
|
|
15
|
+
v: void 0,
|
|
16
|
+
data: t,
|
|
17
|
+
context: {},
|
|
18
|
+
entry: {
|
|
19
|
+
field: r.field,
|
|
20
|
+
type: r.type,
|
|
21
|
+
component: r.component,
|
|
22
|
+
name: r.name || r.field
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
t[r.field] = (e = M(r.value, s)) !== null && e !== void 0 ? e : void 0;
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
14
28
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
29
|
+
function be(o, e) {
|
|
30
|
+
return o.fields.some((t) => t.altAction === e);
|
|
17
31
|
}
|
|
18
|
-
function
|
|
19
|
-
if (!
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
function xe(o, e) {
|
|
33
|
+
if (!o)
|
|
34
|
+
return;
|
|
35
|
+
const t = {};
|
|
36
|
+
for (const [r, s] of Object.entries(o))
|
|
37
|
+
t[r] = M(s, e);
|
|
38
|
+
return t;
|
|
24
39
|
}
|
|
25
|
-
const
|
|
40
|
+
const ke = /* @__PURE__ */ I({
|
|
26
41
|
__name: "VuilessField",
|
|
27
|
-
props: /* @__PURE__ */
|
|
42
|
+
props: /* @__PURE__ */ ie({
|
|
28
43
|
rules: {}
|
|
29
44
|
}, {
|
|
30
45
|
modelValue: {},
|
|
31
46
|
modelModifiers: {}
|
|
32
47
|
}),
|
|
33
48
|
emits: ["update:modelValue"],
|
|
34
|
-
setup(
|
|
35
|
-
const
|
|
36
|
-
var
|
|
37
|
-
if ((
|
|
49
|
+
setup(o) {
|
|
50
|
+
const e = o, t = ae(o, "modelValue"), r = te("vuiless"), s = q(), a = q(!1), l = q(!1), c = _(() => {
|
|
51
|
+
var u;
|
|
52
|
+
if ((u = r == null ? void 0 : r.value) != null && u.firstValidation)
|
|
38
53
|
switch (r.value.firstValidation) {
|
|
39
54
|
case "on-change":
|
|
40
|
-
return r.value.firstSubmitHappened ||
|
|
55
|
+
return r.value.firstSubmitHappened || a.value;
|
|
41
56
|
case "touched-on-blur":
|
|
42
|
-
return r.value.firstSubmitHappened ||
|
|
57
|
+
return r.value.firstSubmitHappened || l.value && a.value;
|
|
43
58
|
case "on-blur":
|
|
44
|
-
return r.value.firstSubmitHappened ||
|
|
59
|
+
return r.value.firstSubmitHappened || l.value;
|
|
45
60
|
case "on-submit":
|
|
46
61
|
return r.value.firstSubmitHappened;
|
|
47
62
|
case "none":
|
|
48
63
|
return !1;
|
|
49
64
|
}
|
|
50
65
|
return !1;
|
|
51
|
-
}),
|
|
52
|
-
if (
|
|
53
|
-
return
|
|
66
|
+
}), m = _(() => {
|
|
67
|
+
if (c.value || s.value)
|
|
68
|
+
return p();
|
|
54
69
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}),
|
|
58
|
-
var
|
|
59
|
-
(
|
|
60
|
-
}), r != null && r.value && r.value.register(
|
|
61
|
-
validate: () => (
|
|
70
|
+
oe([t], () => {
|
|
71
|
+
s.value = void 0, a.value = !0;
|
|
72
|
+
}), le(() => {
|
|
73
|
+
var u;
|
|
74
|
+
(u = r == null ? void 0 : r.value) == null || u.unregister(Q());
|
|
75
|
+
}), r != null && r.value && r.value.register(Q(), {
|
|
76
|
+
validate: () => (s.value = p(), s.value || !0),
|
|
62
77
|
clearErrors: () => {
|
|
63
|
-
|
|
78
|
+
a.value = !1, l.value = !1, s.value = void 0;
|
|
64
79
|
},
|
|
65
80
|
reset: () => {
|
|
66
|
-
|
|
81
|
+
t.value = "";
|
|
67
82
|
}
|
|
68
83
|
});
|
|
69
|
-
function
|
|
70
|
-
var
|
|
71
|
-
if ((
|
|
72
|
-
for (const
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
(
|
|
76
|
-
(
|
|
84
|
+
function p() {
|
|
85
|
+
var u, d, A;
|
|
86
|
+
if ((u = e.rules) != null && u.length)
|
|
87
|
+
for (const v of e.rules) {
|
|
88
|
+
const E = v(
|
|
89
|
+
t.value,
|
|
90
|
+
(d = r == null ? void 0 : r.value) == null ? void 0 : d.formData,
|
|
91
|
+
(A = r == null ? void 0 : r.value) == null ? void 0 : A.formContext
|
|
77
92
|
);
|
|
78
|
-
if (
|
|
79
|
-
return
|
|
93
|
+
if (E !== !0)
|
|
94
|
+
return E || "Wrong value";
|
|
80
95
|
}
|
|
81
96
|
}
|
|
82
|
-
function
|
|
83
|
-
|
|
97
|
+
function f() {
|
|
98
|
+
l.value = !0;
|
|
84
99
|
}
|
|
85
|
-
const
|
|
86
|
-
v:
|
|
87
|
-
get: () =>
|
|
88
|
-
set: (
|
|
100
|
+
const h = {
|
|
101
|
+
v: _({
|
|
102
|
+
get: () => t.value,
|
|
103
|
+
set: (u) => t.value = u
|
|
89
104
|
})
|
|
90
105
|
};
|
|
91
|
-
return (
|
|
92
|
-
var
|
|
93
|
-
return
|
|
94
|
-
onBlur:
|
|
95
|
-
error:
|
|
96
|
-
formData: (
|
|
97
|
-
formContext: (
|
|
98
|
-
model:
|
|
106
|
+
return (u, d) => {
|
|
107
|
+
var A, v;
|
|
108
|
+
return w(u.$slots, "default", {
|
|
109
|
+
onBlur: f,
|
|
110
|
+
error: m.value,
|
|
111
|
+
formData: (A = x(r)) == null ? void 0 : A.formData,
|
|
112
|
+
formContext: (v = x(r)) == null ? void 0 : v.formContext,
|
|
113
|
+
model: h.v
|
|
99
114
|
});
|
|
100
115
|
};
|
|
101
116
|
}
|
|
102
|
-
}),
|
|
117
|
+
}), Ee = /* @__PURE__ */ I({
|
|
103
118
|
__name: "VuilessForm",
|
|
104
119
|
props: {
|
|
105
120
|
formData: {},
|
|
@@ -107,46 +122,46 @@ const ce = /* @__PURE__ */ T({
|
|
|
107
122
|
firstValidation: { default: "on-change" }
|
|
108
123
|
},
|
|
109
124
|
emits: ["submit"],
|
|
110
|
-
setup(
|
|
111
|
-
const
|
|
112
|
-
firstSubmitHappened:
|
|
113
|
-
firstValidation:
|
|
114
|
-
register: (
|
|
115
|
-
|
|
125
|
+
setup(o, { emit: e }) {
|
|
126
|
+
const t = o, r = e, s = /* @__PURE__ */ new Map(), a = q(!1), l = _(() => ({
|
|
127
|
+
firstSubmitHappened: a.value,
|
|
128
|
+
firstValidation: t.firstValidation,
|
|
129
|
+
register: (f, h) => {
|
|
130
|
+
s.set(f, h);
|
|
116
131
|
},
|
|
117
|
-
unregister: (
|
|
118
|
-
formData:
|
|
119
|
-
formContext:
|
|
132
|
+
unregister: (f) => s.delete(f),
|
|
133
|
+
formData: t.formData,
|
|
134
|
+
formContext: t.formContext
|
|
120
135
|
}));
|
|
121
|
-
|
|
122
|
-
function
|
|
123
|
-
|
|
124
|
-
for (const { clearErrors:
|
|
125
|
-
|
|
136
|
+
ue("vuiless", l);
|
|
137
|
+
function c() {
|
|
138
|
+
a.value = !1;
|
|
139
|
+
for (const { clearErrors: f } of s.values())
|
|
140
|
+
f();
|
|
126
141
|
}
|
|
127
|
-
async function
|
|
128
|
-
for (const { reset:
|
|
129
|
-
|
|
130
|
-
await
|
|
142
|
+
async function m() {
|
|
143
|
+
for (const { reset: f } of s.values())
|
|
144
|
+
f();
|
|
145
|
+
await pe(), c();
|
|
131
146
|
}
|
|
132
|
-
function
|
|
133
|
-
|
|
134
|
-
let
|
|
135
|
-
if (
|
|
136
|
-
for (const { validate:
|
|
137
|
-
|
|
138
|
-
|
|
147
|
+
function p() {
|
|
148
|
+
a.value = !0;
|
|
149
|
+
let f = !1;
|
|
150
|
+
if (t.firstValidation !== "none")
|
|
151
|
+
for (const { validate: h } of s.values())
|
|
152
|
+
h() !== !0 && (f = !0);
|
|
153
|
+
f || r("submit", t.formData);
|
|
139
154
|
}
|
|
140
|
-
return (
|
|
141
|
-
onSubmit:
|
|
155
|
+
return (f, h) => (y(), b("form", {
|
|
156
|
+
onSubmit: ce(p, ["prevent"])
|
|
142
157
|
}, [
|
|
143
|
-
|
|
144
|
-
clearErrors:
|
|
145
|
-
reset:
|
|
158
|
+
w(f.$slots, "default", {
|
|
159
|
+
clearErrors: c,
|
|
160
|
+
reset: m
|
|
146
161
|
})
|
|
147
162
|
], 32));
|
|
148
163
|
}
|
|
149
|
-
}),
|
|
164
|
+
}), _e = /* @__PURE__ */ I({
|
|
150
165
|
__name: "oo-field",
|
|
151
166
|
props: {
|
|
152
167
|
field: {},
|
|
@@ -163,11 +178,12 @@ const ce = /* @__PURE__ */ T({
|
|
|
163
178
|
optional: { type: [Boolean, Function] },
|
|
164
179
|
disabled: { type: [Boolean, Function] },
|
|
165
180
|
hidden: { type: [Boolean, Function] },
|
|
181
|
+
readonly: { type: [Boolean, Function] },
|
|
166
182
|
classes: { type: [String, Object, Function] },
|
|
167
183
|
styles: { type: [String, Object, Function] },
|
|
168
184
|
options: { type: [Array, Function] },
|
|
169
185
|
attrs: {},
|
|
170
|
-
value: {},
|
|
186
|
+
value: { type: Function },
|
|
171
187
|
validators: {},
|
|
172
188
|
maxLength: {},
|
|
173
189
|
minLength: {},
|
|
@@ -175,85 +191,112 @@ const ce = /* @__PURE__ */ T({
|
|
|
175
191
|
max: {},
|
|
176
192
|
error: {}
|
|
177
193
|
},
|
|
178
|
-
setup(
|
|
179
|
-
const
|
|
194
|
+
setup(o) {
|
|
195
|
+
const e = o, t = te(
|
|
180
196
|
"vuiless"
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
197
|
+
);
|
|
198
|
+
function r(i, k, S) {
|
|
199
|
+
return typeof i == "function" ? _(() => i(k.value)) : i ?? S;
|
|
200
|
+
}
|
|
201
|
+
const s = (i) => typeof i == "object" && i !== null && "value" in i ? i.value : i, a = _(() => ({
|
|
202
|
+
v: t.value.formData[e.field],
|
|
203
|
+
data: t.value.formData,
|
|
204
|
+
context: t.value.formContext ?? {},
|
|
205
|
+
entry: void 0
|
|
206
|
+
})), l = r(e.optional, a, !1), c = r(e.disabled, a, !1), m = r(e.hidden, a, !1), p = r(e.readonly, a, !1), f = _(() => !s(l)), h = _(() => ({
|
|
207
|
+
v: t.value.formData[e.field],
|
|
208
|
+
data: t.value.formData,
|
|
209
|
+
context: t.value.formContext ?? {},
|
|
187
210
|
entry: {
|
|
188
|
-
field:
|
|
189
|
-
type:
|
|
190
|
-
component:
|
|
191
|
-
name:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
hidden:
|
|
211
|
+
field: e.field,
|
|
212
|
+
type: e.type,
|
|
213
|
+
component: e.component,
|
|
214
|
+
name: e.name || e.field,
|
|
215
|
+
optional: s(l),
|
|
216
|
+
disabled: s(c),
|
|
217
|
+
hidden: s(m),
|
|
218
|
+
readonly: s(p)
|
|
195
219
|
}
|
|
196
|
-
})),
|
|
197
|
-
const
|
|
198
|
-
return typeof
|
|
199
|
-
[
|
|
200
|
-
disabled:
|
|
201
|
-
required: !
|
|
220
|
+
})), u = r(e.label, h, void 0), d = r(e.description, h, void 0), A = r(e.hint, h, void 0), v = r(e.placeholder, h, void 0), E = r(e.options, h, void 0), C = r(e.styles, h, void 0), n = _(() => {
|
|
221
|
+
const i = typeof e.classes == "function" ? e.classes(h.value) : e.classes;
|
|
222
|
+
return typeof i == "string" ? {
|
|
223
|
+
[i]: !0,
|
|
224
|
+
disabled: s(c),
|
|
225
|
+
required: !s(l)
|
|
202
226
|
} : {
|
|
203
|
-
...
|
|
204
|
-
disabled:
|
|
205
|
-
required: !
|
|
227
|
+
...i,
|
|
228
|
+
disabled: s(c),
|
|
229
|
+
required: !s(l)
|
|
206
230
|
};
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
231
|
+
});
|
|
232
|
+
function F(i, k) {
|
|
233
|
+
return {
|
|
234
|
+
...n.value,
|
|
235
|
+
error: !!i || !!k
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
const D = _(() => xe(e.attrs, h.value));
|
|
239
|
+
if (typeof e.value == "function") {
|
|
240
|
+
const i = _(() => {
|
|
241
|
+
if (s(p))
|
|
242
|
+
return e.value(h.value);
|
|
243
|
+
});
|
|
244
|
+
oe(
|
|
245
|
+
i,
|
|
246
|
+
(k) => {
|
|
247
|
+
k !== void 0 && s(p) && (t.value.formData[e.field] = k);
|
|
248
|
+
},
|
|
249
|
+
{ immediate: !0 }
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
const j = e.validators.map((i) => (k, S, X) => i({
|
|
253
|
+
v: k,
|
|
254
|
+
data: S,
|
|
255
|
+
context: X ?? {},
|
|
256
|
+
entry: h.value.entry
|
|
257
|
+
}));
|
|
258
|
+
return (i, k) => (y(), U(x(ke), {
|
|
259
|
+
modelValue: x(t).formData[e.field],
|
|
260
|
+
"onUpdate:modelValue": k[0] || (k[0] = (S) => x(t).formData[e.field] = S),
|
|
261
|
+
rules: x(j)
|
|
221
262
|
}, {
|
|
222
|
-
default:
|
|
223
|
-
|
|
224
|
-
onBlur:
|
|
225
|
-
error:
|
|
226
|
-
model:
|
|
227
|
-
formData:
|
|
228
|
-
formContext:
|
|
229
|
-
label:
|
|
230
|
-
description:
|
|
231
|
-
hint:
|
|
232
|
-
placeholder:
|
|
233
|
-
classes:
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
autocomplete: n.autocomplete,
|
|
250
|
-
attrs: y.value
|
|
263
|
+
default: K((S) => [
|
|
264
|
+
w(i.$slots, "default", {
|
|
265
|
+
onBlur: S.onBlur,
|
|
266
|
+
error: o.error || S.error,
|
|
267
|
+
model: S.model,
|
|
268
|
+
formData: x(t).formData,
|
|
269
|
+
formContext: x(t).formContext,
|
|
270
|
+
label: x(u),
|
|
271
|
+
description: x(d),
|
|
272
|
+
hint: x(A),
|
|
273
|
+
placeholder: x(v),
|
|
274
|
+
classes: F(o.error, S.error),
|
|
275
|
+
styles: x(C),
|
|
276
|
+
optional: x(l),
|
|
277
|
+
disabled: x(c),
|
|
278
|
+
hidden: x(m),
|
|
279
|
+
readonly: x(p),
|
|
280
|
+
type: o.type,
|
|
281
|
+
altAction: o.altAction,
|
|
282
|
+
component: o.component,
|
|
283
|
+
vName: o.name,
|
|
284
|
+
field: o.field,
|
|
285
|
+
options: x(E),
|
|
286
|
+
maxLength: o.maxLength,
|
|
287
|
+
required: f.value,
|
|
288
|
+
autocomplete: o.autocomplete,
|
|
289
|
+
attrs: D.value
|
|
251
290
|
})
|
|
252
291
|
]),
|
|
253
292
|
_: 3
|
|
254
293
|
}, 8, ["modelValue", "rules"]));
|
|
255
294
|
}
|
|
256
|
-
}),
|
|
295
|
+
}), Ve = { key: 0 }, $e = { key: 1 }, Ae = { key: 0 }, Se = ["onUpdate:modelValue", "onBlur", "placeholder", "autocomplete", "name", "type", "disabled", "readonly"], we = { class: "oo-error-slot" }, Ce = { key: 4 }, Le = { key: 0 }, Te = ["onUpdate:modelValue", "onBlur", "name", "disabled", "readonly"], Be = {
|
|
296
|
+
key: 0,
|
|
297
|
+
value: "",
|
|
298
|
+
disabled: ""
|
|
299
|
+
}, Fe = ["value"], De = { class: "oo-error-slot" }, je = { class: "oo-field-label" }, Pe = { key: 0 }, Oe = { class: "oo-radio-group" }, Ue = ["value", "onUpdate:modelValue", "onBlur", "name", "disabled", "readonly"], qe = { class: "oo-error-slot" }, Me = ["onUpdate:modelValue", "onBlur", "name", "disabled", "readonly"], Ne = { key: 0 }, Ie = { class: "oo-error-slot" }, ze = ["onClick"], He = { key: 9 }, Re = ["disabled"], ut = /* @__PURE__ */ I({
|
|
257
300
|
__name: "oo-form",
|
|
258
301
|
props: {
|
|
259
302
|
form: {},
|
|
@@ -265,153 +308,244 @@ const ce = /* @__PURE__ */ T({
|
|
|
265
308
|
errors: {}
|
|
266
309
|
},
|
|
267
310
|
emits: ["submit", "action", "unsupported-action"],
|
|
268
|
-
setup(
|
|
269
|
-
const
|
|
311
|
+
setup(o, { emit: e }) {
|
|
312
|
+
const t = o, r = q({}), s = _(() => t.formData || r.value), a = _(() => ({
|
|
270
313
|
v: void 0,
|
|
271
|
-
data:
|
|
272
|
-
context:
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
314
|
+
data: s.value,
|
|
315
|
+
context: t.formContext ?? {},
|
|
316
|
+
entry: void 0
|
|
317
|
+
})), l = _(() => M(t.form.title, a.value)), c = _(() => M(t.form.submit.text, a.value)), m = _(() => M(t.form.submit.disabled, a.value));
|
|
318
|
+
function p(d) {
|
|
319
|
+
be(t.form, d) ? f("action", d, s.value) : f("unsupported-action", d, s.value);
|
|
320
|
+
}
|
|
321
|
+
const f = e;
|
|
322
|
+
function h(d) {
|
|
323
|
+
return typeof d == "string" ? d : d.key;
|
|
324
|
+
}
|
|
325
|
+
function u(d) {
|
|
326
|
+
return typeof d == "string" ? d : d.label;
|
|
276
327
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
"
|
|
280
|
-
|
|
281
|
-
"form-
|
|
282
|
-
"form-context": n.formContext
|
|
328
|
+
return (d, A) => (y(), U(x(Ee), {
|
|
329
|
+
"first-validation": o.firstValidation,
|
|
330
|
+
onSubmit: A[0] || (A[0] = (v) => f("submit", v)),
|
|
331
|
+
"form-data": s.value,
|
|
332
|
+
"form-context": o.formContext
|
|
283
333
|
}, {
|
|
284
|
-
default:
|
|
285
|
-
|
|
286
|
-
clearErrors:
|
|
287
|
-
reset:
|
|
288
|
-
title:
|
|
289
|
-
formContext:
|
|
290
|
-
disabled:
|
|
334
|
+
default: K((v) => [
|
|
335
|
+
w(d.$slots, "form.header", {
|
|
336
|
+
clearErrors: v.clearErrors,
|
|
337
|
+
reset: v.reset,
|
|
338
|
+
title: l.value,
|
|
339
|
+
formContext: o.formContext,
|
|
340
|
+
disabled: m.value
|
|
291
341
|
}, () => [
|
|
292
|
-
|
|
342
|
+
l.value ? (y(), b("h2", Ve, g(l.value), 1)) : P("", !0)
|
|
293
343
|
]),
|
|
294
|
-
|
|
295
|
-
clearErrors:
|
|
296
|
-
reset:
|
|
344
|
+
w(d.$slots, "form.before", {
|
|
345
|
+
clearErrors: v.clearErrors,
|
|
346
|
+
reset: v.reset
|
|
297
347
|
}),
|
|
298
|
-
(
|
|
299
|
-
var
|
|
300
|
-
return
|
|
301
|
-
key:
|
|
302
|
-
}, { ref_for: !0 },
|
|
303
|
-
error: (
|
|
348
|
+
(y(!0), b(H, null, R(t.form.fields, (E) => {
|
|
349
|
+
var C;
|
|
350
|
+
return y(), U(_e, L({
|
|
351
|
+
key: E.field
|
|
352
|
+
}, { ref_for: !0 }, E, {
|
|
353
|
+
error: (C = o.errors) == null ? void 0 : C[E.field]
|
|
304
354
|
}), {
|
|
305
|
-
default:
|
|
306
|
-
|
|
307
|
-
var
|
|
355
|
+
default: K((n) => [
|
|
356
|
+
w(d.$slots, `field:${n.type}`, L({ ref_for: !0 }, n), () => {
|
|
357
|
+
var F, D, j;
|
|
308
358
|
return [
|
|
309
|
-
|
|
359
|
+
E.component && ((F = t.components) != null && F[E.component]) ? (y(), U(J(t.components[E.component]), L({
|
|
310
360
|
key: 0,
|
|
311
|
-
"on-blur":
|
|
312
|
-
error:
|
|
313
|
-
model:
|
|
314
|
-
"form-data":
|
|
315
|
-
"form-context":
|
|
316
|
-
label:
|
|
317
|
-
description:
|
|
318
|
-
hint:
|
|
319
|
-
placeholder:
|
|
320
|
-
class:
|
|
321
|
-
style:
|
|
322
|
-
optional:
|
|
323
|
-
required: !
|
|
324
|
-
disabled:
|
|
325
|
-
hidden:
|
|
326
|
-
type:
|
|
327
|
-
"alt-action":
|
|
328
|
-
name:
|
|
329
|
-
field:
|
|
330
|
-
options:
|
|
331
|
-
"max-length":
|
|
332
|
-
autocomplete:
|
|
333
|
-
onAction:
|
|
334
|
-
}, { ref_for: !0 },
|
|
335
|
-
modelValue:
|
|
336
|
-
"onUpdate:modelValue": (
|
|
337
|
-
}), null, 16, ["on-blur", "error", "model", "form-data", "form-context", "label", "description", "hint", "placeholder", "class", "style", "optional", "required", "disabled", "hidden", "type", "alt-action", "name", "field", "options", "max-length", "autocomplete", "modelValue", "onUpdate:modelValue"])) :
|
|
361
|
+
"on-blur": n.onBlur,
|
|
362
|
+
error: n.error,
|
|
363
|
+
model: n.model,
|
|
364
|
+
"form-data": n.formData,
|
|
365
|
+
"form-context": n.formContext,
|
|
366
|
+
label: n.label,
|
|
367
|
+
description: n.description,
|
|
368
|
+
hint: n.hint,
|
|
369
|
+
placeholder: n.placeholder,
|
|
370
|
+
class: n.classes,
|
|
371
|
+
style: n.styles,
|
|
372
|
+
optional: n.optional,
|
|
373
|
+
required: !n.required,
|
|
374
|
+
disabled: n.disabled,
|
|
375
|
+
hidden: n.hidden,
|
|
376
|
+
type: n.type,
|
|
377
|
+
"alt-action": n.altAction,
|
|
378
|
+
name: n.vName,
|
|
379
|
+
field: n,
|
|
380
|
+
options: n.options,
|
|
381
|
+
"max-length": n.maxLength,
|
|
382
|
+
autocomplete: n.autocomplete,
|
|
383
|
+
onAction: p
|
|
384
|
+
}, { ref_for: !0 }, n.attrs, {
|
|
385
|
+
modelValue: n.model.value,
|
|
386
|
+
"onUpdate:modelValue": (i) => n.model.value = i
|
|
387
|
+
}), null, 16, ["on-blur", "error", "model", "form-data", "form-context", "label", "description", "hint", "placeholder", "class", "style", "optional", "required", "disabled", "hidden", "type", "alt-action", "name", "field", "options", "max-length", "autocomplete", "modelValue", "onUpdate:modelValue"])) : E.component && !((D = t.components) != null && D[E.component]) ? (y(), b("div", $e, " [" + g(n.label) + '] Component "' + g(n.component) + '" not supplied ', 1)) : (j = t.types) != null && j[E.type] ? (y(), U(J(t.types[E.type]), L({
|
|
338
388
|
key: 2,
|
|
339
|
-
"on-blur":
|
|
340
|
-
error:
|
|
341
|
-
model:
|
|
342
|
-
"form-data":
|
|
343
|
-
"form-context":
|
|
344
|
-
label:
|
|
345
|
-
description:
|
|
346
|
-
hint:
|
|
347
|
-
placeholder:
|
|
348
|
-
class:
|
|
349
|
-
style:
|
|
350
|
-
optional:
|
|
351
|
-
required: !
|
|
352
|
-
disabled:
|
|
353
|
-
hidden:
|
|
354
|
-
type:
|
|
355
|
-
"alt-action":
|
|
356
|
-
name:
|
|
357
|
-
field:
|
|
358
|
-
options:
|
|
359
|
-
"max-length":
|
|
360
|
-
autocomplete:
|
|
361
|
-
onAction:
|
|
362
|
-
}, { ref_for: !0 },
|
|
363
|
-
modelValue:
|
|
364
|
-
"onUpdate:modelValue": (
|
|
365
|
-
}), null, 16, ["on-blur", "error", "model", "form-data", "form-context", "label", "description", "hint", "placeholder", "class", "style", "optional", "required", "disabled", "hidden", "type", "alt-action", "name", "field", "options", "max-length", "autocomplete", "modelValue", "onUpdate:modelValue"])) : ["text", "password", "number"].includes(
|
|
389
|
+
"on-blur": n.onBlur,
|
|
390
|
+
error: n.error,
|
|
391
|
+
model: n.model,
|
|
392
|
+
"form-data": n.formData,
|
|
393
|
+
"form-context": n.formContext,
|
|
394
|
+
label: n.label,
|
|
395
|
+
description: n.description,
|
|
396
|
+
hint: n.hint,
|
|
397
|
+
placeholder: n.placeholder,
|
|
398
|
+
class: n.classes,
|
|
399
|
+
style: n.styles,
|
|
400
|
+
optional: n.optional,
|
|
401
|
+
required: !n.required,
|
|
402
|
+
disabled: n.disabled,
|
|
403
|
+
hidden: n.hidden,
|
|
404
|
+
type: n.type,
|
|
405
|
+
"alt-action": n.altAction,
|
|
406
|
+
name: n.vName,
|
|
407
|
+
field: n,
|
|
408
|
+
options: n.options,
|
|
409
|
+
"max-length": n.maxLength,
|
|
410
|
+
autocomplete: n.autocomplete,
|
|
411
|
+
onAction: p
|
|
412
|
+
}, { ref_for: !0 }, n.attrs, {
|
|
413
|
+
modelValue: n.model.value,
|
|
414
|
+
"onUpdate:modelValue": (i) => n.model.value = i
|
|
415
|
+
}), null, 16, ["on-blur", "error", "model", "form-data", "form-context", "label", "description", "hint", "placeholder", "class", "style", "optional", "required", "disabled", "hidden", "type", "alt-action", "name", "field", "options", "max-length", "autocomplete", "modelValue", "onUpdate:modelValue"])) : ["text", "password", "number"].includes(n.type) ? T((y(), b("div", {
|
|
366
416
|
key: 3,
|
|
367
|
-
class:
|
|
417
|
+
class: O(["oo-default-field", n.classes])
|
|
418
|
+
}, [
|
|
419
|
+
V("label", null, g(n.label), 1),
|
|
420
|
+
n.description ? (y(), b("span", Ae, g(n.description), 1)) : P("", !0),
|
|
421
|
+
T(V("input", L({
|
|
422
|
+
"onUpdate:modelValue": (i) => n.model.value = i,
|
|
423
|
+
onBlur: n.onBlur,
|
|
424
|
+
placeholder: n.placeholder,
|
|
425
|
+
autocomplete: n.autocomplete,
|
|
426
|
+
name: n.vName,
|
|
427
|
+
type: n.type,
|
|
428
|
+
disabled: n.disabled,
|
|
429
|
+
readonly: n.readonly
|
|
430
|
+
}, { ref_for: !0 }, n.attrs), null, 16, Se), [
|
|
431
|
+
[de, n.model.value]
|
|
432
|
+
]),
|
|
433
|
+
V("div", we, g(n.error || n.hint), 1)
|
|
434
|
+
], 2)), [
|
|
435
|
+
[N, !n.hidden]
|
|
436
|
+
]) : n.type === "paragraph" ? (y(), b("p", Ce, g(n.description), 1)) : n.type === "select" ? T((y(), b("div", {
|
|
437
|
+
key: 5,
|
|
438
|
+
class: O(["oo-default-field", n.classes])
|
|
439
|
+
}, [
|
|
440
|
+
V("label", null, g(n.label), 1),
|
|
441
|
+
n.description ? (y(), b("span", Le, g(n.description), 1)) : P("", !0),
|
|
442
|
+
T(V("select", L({
|
|
443
|
+
"onUpdate:modelValue": (i) => n.model.value = i,
|
|
444
|
+
onBlur: n.onBlur,
|
|
445
|
+
name: n.vName,
|
|
446
|
+
disabled: n.disabled,
|
|
447
|
+
readonly: n.readonly
|
|
448
|
+
}, { ref_for: !0 }, n.attrs), [
|
|
449
|
+
n.placeholder ? (y(), b("option", Be, g(n.placeholder), 1)) : P("", !0),
|
|
450
|
+
(y(!0), b(H, null, R(n.options, (i) => (y(), b("option", {
|
|
451
|
+
key: h(i),
|
|
452
|
+
value: h(i)
|
|
453
|
+
}, g(u(i)), 9, Fe))), 128))
|
|
454
|
+
], 16, Te), [
|
|
455
|
+
[me, n.model.value]
|
|
456
|
+
]),
|
|
457
|
+
V("div", De, g(n.error || n.hint), 1)
|
|
458
|
+
], 2)), [
|
|
459
|
+
[N, !n.hidden]
|
|
460
|
+
]) : n.type === "radio" ? T((y(), b("div", {
|
|
461
|
+
key: 6,
|
|
462
|
+
class: O(["oo-default-field oo-radio-field", n.classes])
|
|
463
|
+
}, [
|
|
464
|
+
V("span", je, g(n.label), 1),
|
|
465
|
+
n.description ? (y(), b("span", Pe, g(n.description), 1)) : P("", !0),
|
|
466
|
+
V("div", Oe, [
|
|
467
|
+
(y(!0), b(H, null, R(n.options, (i) => (y(), b("label", {
|
|
468
|
+
key: h(i)
|
|
469
|
+
}, [
|
|
470
|
+
T(V("input", L({
|
|
471
|
+
type: "radio",
|
|
472
|
+
value: h(i),
|
|
473
|
+
"onUpdate:modelValue": (k) => n.model.value = k,
|
|
474
|
+
onBlur: n.onBlur,
|
|
475
|
+
name: n.vName,
|
|
476
|
+
disabled: n.disabled,
|
|
477
|
+
readonly: n.readonly
|
|
478
|
+
}, { ref_for: !0 }, n.attrs), null, 16, Ue), [
|
|
479
|
+
[fe, n.model.value]
|
|
480
|
+
]),
|
|
481
|
+
Z(" " + g(u(i)), 1)
|
|
482
|
+
]))), 128))
|
|
483
|
+
]),
|
|
484
|
+
V("div", qe, g(n.error || n.hint), 1)
|
|
485
|
+
], 2)), [
|
|
486
|
+
[N, !n.hidden]
|
|
487
|
+
]) : n.type === "checkbox" ? T((y(), b("div", {
|
|
488
|
+
key: 7,
|
|
489
|
+
class: O(["oo-default-field oo-checkbox-field", n.classes])
|
|
368
490
|
}, [
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
491
|
+
V("label", null, [
|
|
492
|
+
T(V("input", L({
|
|
493
|
+
type: "checkbox",
|
|
494
|
+
"onUpdate:modelValue": (i) => n.model.value = i,
|
|
495
|
+
onBlur: n.onBlur,
|
|
496
|
+
name: n.vName,
|
|
497
|
+
disabled: n.disabled,
|
|
498
|
+
readonly: n.readonly
|
|
499
|
+
}, { ref_for: !0 }, n.attrs), null, 16, Me), [
|
|
500
|
+
[he, n.model.value]
|
|
501
|
+
]),
|
|
502
|
+
Z(" " + g(n.label), 1)
|
|
380
503
|
]),
|
|
381
|
-
|
|
382
|
-
|
|
504
|
+
n.description ? (y(), b("span", Ne, g(n.description), 1)) : P("", !0),
|
|
505
|
+
V("div", Ie, g(n.error || n.hint), 1)
|
|
506
|
+
], 2)), [
|
|
507
|
+
[N, !n.hidden]
|
|
508
|
+
]) : n.type === "action" ? (y(), b("div", {
|
|
509
|
+
key: 8,
|
|
510
|
+
class: O(["oo-default-field oo-action-field", n.classes])
|
|
511
|
+
}, [
|
|
512
|
+
V("button", {
|
|
513
|
+
type: "button",
|
|
514
|
+
onClick: (i) => p(n.altAction)
|
|
515
|
+
}, g(n.label), 9, ze)
|
|
516
|
+
], 2)) : (y(), b("div", He, " [" + g(n.label) + '] Not supported field type "' + g(n.type) + '" ' + g(n.component), 1))
|
|
383
517
|
];
|
|
384
518
|
})
|
|
385
519
|
]),
|
|
386
520
|
_: 2
|
|
387
521
|
}, 1040, ["error"]);
|
|
388
522
|
}), 128)),
|
|
389
|
-
|
|
390
|
-
clearErrors:
|
|
391
|
-
reset:
|
|
392
|
-
disabled:
|
|
393
|
-
formContext:
|
|
523
|
+
w(d.$slots, "form.after", {
|
|
524
|
+
clearErrors: v.clearErrors,
|
|
525
|
+
reset: v.reset,
|
|
526
|
+
disabled: m.value,
|
|
527
|
+
formContext: o.formContext
|
|
394
528
|
}),
|
|
395
|
-
|
|
396
|
-
disabled:
|
|
397
|
-
text:
|
|
398
|
-
clearErrors:
|
|
399
|
-
reset:
|
|
400
|
-
formContext:
|
|
529
|
+
w(d.$slots, "form.submit", {
|
|
530
|
+
disabled: m.value,
|
|
531
|
+
text: c.value,
|
|
532
|
+
clearErrors: v.clearErrors,
|
|
533
|
+
reset: v.reset,
|
|
534
|
+
formContext: o.formContext
|
|
401
535
|
}, () => [
|
|
402
|
-
|
|
536
|
+
V("button", { disabled: m.value }, g(c.value), 9, Re)
|
|
403
537
|
]),
|
|
404
|
-
|
|
405
|
-
disabled:
|
|
406
|
-
clearErrors:
|
|
407
|
-
reset:
|
|
408
|
-
formContext:
|
|
538
|
+
w(d.$slots, "form.footer", {
|
|
539
|
+
disabled: m.value,
|
|
540
|
+
clearErrors: v.clearErrors,
|
|
541
|
+
reset: v.reset,
|
|
542
|
+
formContext: o.formContext
|
|
409
543
|
})
|
|
410
544
|
]),
|
|
411
545
|
_: 3
|
|
412
546
|
}, 8, ["first-validation", "form-data", "form-context"]));
|
|
413
547
|
}
|
|
414
|
-
}),
|
|
548
|
+
}), Ge = {
|
|
415
549
|
// Node.js Globals
|
|
416
550
|
global: null,
|
|
417
551
|
process: null,
|
|
@@ -498,121 +632,464 @@ const ce = /* @__PURE__ */ T({
|
|
|
498
632
|
eval: null,
|
|
499
633
|
__ctx__: null
|
|
500
634
|
};
|
|
501
|
-
class
|
|
635
|
+
class Ke {
|
|
502
636
|
constructor() {
|
|
503
|
-
|
|
637
|
+
Y(this, "cache", /* @__PURE__ */ new Map());
|
|
504
638
|
}
|
|
505
|
-
call(
|
|
506
|
-
return this.getFn(
|
|
639
|
+
call(e, t) {
|
|
640
|
+
return this.getFn(e)(t);
|
|
507
641
|
}
|
|
508
|
-
getFn(
|
|
509
|
-
let
|
|
510
|
-
return
|
|
642
|
+
getFn(e) {
|
|
643
|
+
let t = this.cache.get(e);
|
|
644
|
+
return t || (t = We(e), this.cache.set(e, t)), t;
|
|
511
645
|
}
|
|
512
646
|
}
|
|
513
|
-
function
|
|
514
|
-
const
|
|
515
|
-
${
|
|
516
|
-
}`,
|
|
647
|
+
function We(o) {
|
|
648
|
+
const e = `with(__ctx__){
|
|
649
|
+
${o}
|
|
650
|
+
}`, t = new Function("__ctx__", e);
|
|
517
651
|
return (r) => {
|
|
518
|
-
const
|
|
519
|
-
return
|
|
652
|
+
const s = Object.freeze(Object.assign({}, Ge, r));
|
|
653
|
+
return t(s);
|
|
520
654
|
};
|
|
521
655
|
}
|
|
522
|
-
const
|
|
523
|
-
function
|
|
524
|
-
const
|
|
525
|
-
return
|
|
656
|
+
const W = new Ke();
|
|
657
|
+
function ne(o) {
|
|
658
|
+
const e = `return (${o})(v, data, context, entry)`;
|
|
659
|
+
return W.getFn(e);
|
|
526
660
|
}
|
|
527
|
-
function
|
|
528
|
-
const
|
|
529
|
-
return
|
|
661
|
+
function G(o) {
|
|
662
|
+
const e = `return (${o})(data, context)`;
|
|
663
|
+
return W.getFn(e);
|
|
530
664
|
}
|
|
531
|
-
function
|
|
532
|
-
const
|
|
533
|
-
return
|
|
665
|
+
function Xe(o) {
|
|
666
|
+
const e = `return (${o})(v, data, context, entry)`;
|
|
667
|
+
return W.getFn(e);
|
|
534
668
|
}
|
|
535
|
-
function
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
669
|
+
function Ye(o, e) {
|
|
670
|
+
switch (o.type.kind) {
|
|
671
|
+
case "": {
|
|
672
|
+
const t = o;
|
|
673
|
+
return e.phantom && t.type.designType === "phantom" ? e.phantom(t) : e.final(t);
|
|
674
|
+
}
|
|
675
|
+
case "object":
|
|
676
|
+
return e.object(o);
|
|
677
|
+
case "array":
|
|
678
|
+
return e.array(o);
|
|
679
|
+
case "union":
|
|
680
|
+
return e.union(o);
|
|
681
|
+
case "intersection":
|
|
682
|
+
return e.intersection(o);
|
|
683
|
+
case "tuple":
|
|
684
|
+
return e.tuple(o);
|
|
685
|
+
default:
|
|
686
|
+
throw new Error(`Unknown type kind "${o.type.kind}"`);
|
|
687
|
+
}
|
|
541
688
|
}
|
|
542
|
-
function
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
689
|
+
function B(o, e, t) {
|
|
690
|
+
return e in o ? Object.defineProperty(o, e, {
|
|
691
|
+
value: t,
|
|
692
|
+
enumerable: !0,
|
|
693
|
+
configurable: !0,
|
|
694
|
+
writable: !0
|
|
695
|
+
}) : o[e] = t, o;
|
|
696
|
+
}
|
|
697
|
+
const ee = /* @__PURE__ */ new Map();
|
|
698
|
+
var Qe = class {
|
|
699
|
+
isLimitExceeded() {
|
|
700
|
+
return this.stackErrors.length > 0 ? this.stackErrors[this.stackErrors.length - 1].length >= this.opts.errorLimit : this.errors.length >= this.opts.errorLimit;
|
|
701
|
+
}
|
|
702
|
+
push(o) {
|
|
703
|
+
this.stackPath.push(o), this.stackErrors.push([]);
|
|
704
|
+
}
|
|
705
|
+
pop(o) {
|
|
706
|
+
this.stackPath.pop();
|
|
707
|
+
const e = this.stackErrors.pop();
|
|
708
|
+
return o && (e != null && e.length) && e.forEach((t) => {
|
|
709
|
+
this.error(t.message, t.path, t.details);
|
|
710
|
+
}), e;
|
|
711
|
+
}
|
|
712
|
+
clear() {
|
|
713
|
+
this.stackErrors[this.stackErrors.length - 1] = [];
|
|
714
|
+
}
|
|
715
|
+
error(o, e, t) {
|
|
716
|
+
const r = this.stackErrors[this.stackErrors.length - 1] || this.errors, s = {
|
|
717
|
+
path: e || this.path,
|
|
718
|
+
message: o
|
|
719
|
+
};
|
|
720
|
+
t != null && t.length && (s.details = t), r.push(s);
|
|
721
|
+
}
|
|
722
|
+
throw() {
|
|
723
|
+
throw new Je(this.errors);
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Validates a value against the type definition.
|
|
727
|
+
*
|
|
728
|
+
* Acts as a TypeScript type guard — when it returns `true`, the value
|
|
729
|
+
* is narrowed to `DataType`.
|
|
730
|
+
*
|
|
731
|
+
* @param value - The value to validate.
|
|
732
|
+
* @param safe - If `true`, returns `false` on failure instead of throwing.
|
|
733
|
+
* @returns `true` if the value matches the type definition.
|
|
734
|
+
* @throws {ValidatorError} When validation fails and `safe` is not `true`.
|
|
735
|
+
*/
|
|
736
|
+
validate(o, e) {
|
|
737
|
+
this.push(""), this.errors = [], this.stackErrors = [];
|
|
738
|
+
const t = this.validateSafe(this.def, o);
|
|
739
|
+
if (this.pop(!t), !t) {
|
|
740
|
+
if (e) return !1;
|
|
741
|
+
this.throw();
|
|
554
742
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
743
|
+
return !0;
|
|
744
|
+
}
|
|
745
|
+
validateSafe(o, e) {
|
|
746
|
+
if (this.isLimitExceeded()) return !1;
|
|
747
|
+
if (!Ze(o)) throw new Error("Can not validate not-annotated type");
|
|
748
|
+
if (typeof this.opts.replace == "function" && (o = this.opts.replace(o, this.path)), o.optional && e === void 0) return !0;
|
|
749
|
+
for (const t of this.opts.plugins) {
|
|
750
|
+
const r = t(this, o, e);
|
|
751
|
+
if (r === !1 || r === !0) return r;
|
|
752
|
+
}
|
|
753
|
+
return this.validateAnnotatedType(o, e);
|
|
754
|
+
}
|
|
755
|
+
get path() {
|
|
756
|
+
return this.stackPath.slice(1).join(".");
|
|
757
|
+
}
|
|
758
|
+
validateAnnotatedType(o, e) {
|
|
759
|
+
return Ye(o, {
|
|
760
|
+
final: (t) => this.validatePrimitive(t, e),
|
|
761
|
+
phantom: () => !0,
|
|
762
|
+
object: (t) => this.validateObject(t, e),
|
|
763
|
+
array: (t) => this.validateArray(t, e),
|
|
764
|
+
union: (t) => this.validateUnion(t, e),
|
|
765
|
+
intersection: (t) => this.validateIntersection(t, e),
|
|
766
|
+
tuple: (t) => this.validateTuple(t, e)
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
validateUnion(o, e) {
|
|
770
|
+
let t = 0;
|
|
771
|
+
const r = [];
|
|
772
|
+
for (const a of o.type.items) {
|
|
773
|
+
if (this.push(`[${a.type.kind || a.type.designType}(${t})]`), this.validateSafe(a, e))
|
|
774
|
+
return this.pop(!1), !0;
|
|
775
|
+
const l = this.pop(!1);
|
|
776
|
+
l && r.push(...l), t++;
|
|
777
|
+
}
|
|
778
|
+
this.clear();
|
|
779
|
+
const s = o.type.items.map((a, l) => `[${a.type.kind || a.type.designType}(${l})]`).join(", ");
|
|
780
|
+
return this.error(`Value does not match any of the allowed types: ${s}`, void 0, r), !1;
|
|
781
|
+
}
|
|
782
|
+
validateIntersection(o, e) {
|
|
783
|
+
for (const t of o.type.items) if (!this.validateSafe(t, e)) return !1;
|
|
784
|
+
return !0;
|
|
785
|
+
}
|
|
786
|
+
validateTuple(o, e) {
|
|
787
|
+
if (!Array.isArray(e) || e.length !== o.type.items.length)
|
|
788
|
+
return this.error(`Expected array of length ${o.type.items.length}`), !1;
|
|
789
|
+
let t = 0;
|
|
790
|
+
for (const r of o.type.items) {
|
|
791
|
+
if (this.push(`[${t}]`), !this.validateSafe(r, e[t]))
|
|
792
|
+
return this.pop(!0), !1;
|
|
793
|
+
this.pop(!1), t++;
|
|
794
|
+
}
|
|
795
|
+
return !0;
|
|
796
|
+
}
|
|
797
|
+
validateArray(o, e) {
|
|
798
|
+
if (!Array.isArray(e))
|
|
799
|
+
return this.error("Expected array"), !1;
|
|
800
|
+
const t = o.metadata.get("expect.minLength");
|
|
801
|
+
if (t) {
|
|
802
|
+
const l = typeof t == "number" ? t : t.length;
|
|
803
|
+
if (e.length < l) {
|
|
804
|
+
const c = typeof t == "object" && t.message ? t.message : `Expected minimum length of ${l} items, got ${e.length} items`;
|
|
805
|
+
return this.error(c), !1;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
const r = o.metadata.get("expect.maxLength");
|
|
809
|
+
if (r) {
|
|
810
|
+
const l = typeof r == "number" ? r : r.length;
|
|
811
|
+
if (e.length > l) {
|
|
812
|
+
const c = typeof r == "object" && r.message ? r.message : `Expected maximum length of ${l} items, got ${e.length} items`;
|
|
813
|
+
return this.error(c), !1;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
let s = 0, a = !0;
|
|
817
|
+
for (const l of e) {
|
|
818
|
+
if (this.push(`[${s}]`), this.validateSafe(o.type.of, l))
|
|
819
|
+
this.pop(!1);
|
|
820
|
+
else if (a = !1, this.pop(!0), this.isLimitExceeded()) return !1;
|
|
821
|
+
s++;
|
|
822
|
+
}
|
|
823
|
+
return a;
|
|
824
|
+
}
|
|
825
|
+
validateObject(o, e) {
|
|
826
|
+
if (typeof e != "object" || e === null || Array.isArray(e))
|
|
827
|
+
return this.error("Expected object"), !1;
|
|
828
|
+
let t = !0;
|
|
829
|
+
const r = new Set(Object.keys(e)), s = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
|
830
|
+
if (this.opts.skipList) {
|
|
831
|
+
const c = this.stackPath.length > 1 ? `${this.path}.` : "";
|
|
832
|
+
this.opts.skipList.forEach((m) => {
|
|
833
|
+
if (m.startsWith(c)) {
|
|
834
|
+
const p = m.slice(c.length);
|
|
835
|
+
a.add(p), r.delete(p);
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
let l = !1;
|
|
840
|
+
typeof this.opts.partial == "function" && (l = this.opts.partial(o, this.path));
|
|
841
|
+
for (const [c, m] of o.type.props.entries())
|
|
842
|
+
if (!(a.has(c) || et(m)) && (s.add(c), !(e[c] === void 0 && (l || this.opts.partial === "deep" || this.opts.partial === !0 && this.stackPath.length <= 1)))) {
|
|
843
|
+
if (this.push(c), this.validateSafe(m, e[c])) this.pop(!1);
|
|
844
|
+
else if (t = !1, this.pop(!0), this.isLimitExceeded()) return !1;
|
|
845
|
+
}
|
|
846
|
+
for (const c of r)
|
|
847
|
+
if (!s.has(c)) {
|
|
848
|
+
const m = [];
|
|
849
|
+
for (const { pattern: p, def: f } of o.type.propsPatterns) p.test(c) && m.push({
|
|
850
|
+
pattern: p,
|
|
851
|
+
def: f
|
|
852
|
+
});
|
|
853
|
+
if (m.length) {
|
|
854
|
+
let p = !1;
|
|
855
|
+
for (const { def: f } of m) if (this.validateSafe(f, e[c])) {
|
|
856
|
+
this.pop(!1), p = !0;
|
|
857
|
+
break;
|
|
858
|
+
}
|
|
859
|
+
if (!p && (this.push(c), this.validateSafe(m[0].def, e[c]), this.pop(!0), t = !1, this.isLimitExceeded()))
|
|
860
|
+
return !1;
|
|
861
|
+
} else if (this.opts.unknwonProps !== "ignore")
|
|
862
|
+
if (this.opts.unknwonProps === "error") {
|
|
863
|
+
if (this.push(c), this.error("Unexpected property"), this.pop(!0), this.isLimitExceeded()) return !1;
|
|
864
|
+
t = !1;
|
|
865
|
+
} else this.opts.unknwonProps === "strip" && delete e[c];
|
|
866
|
+
}
|
|
867
|
+
return t;
|
|
868
|
+
}
|
|
869
|
+
validatePrimitive(o, e) {
|
|
870
|
+
if (typeof o.type.value < "u")
|
|
871
|
+
return e !== o.type.value ? (this.error(`Expected ${o.type.value}, got ${e}`), !1) : !0;
|
|
872
|
+
const t = Array.isArray(e) ? "array" : typeof e;
|
|
873
|
+
switch (o.type.designType) {
|
|
874
|
+
case "never":
|
|
875
|
+
return this.error("This type is impossible, must be an internal problem"), !1;
|
|
876
|
+
case "any":
|
|
877
|
+
return !0;
|
|
878
|
+
case "string":
|
|
879
|
+
return t !== o.type.designType ? (this.error(`Expected ${o.type.designType}, got ${t}`), !1) : this.validateString(o, e);
|
|
880
|
+
case "number":
|
|
881
|
+
return t !== o.type.designType ? (this.error(`Expected ${o.type.designType}, got ${t}`), !1) : this.validateNumber(o, e);
|
|
882
|
+
case "boolean":
|
|
883
|
+
return t !== o.type.designType ? (this.error(`Expected ${o.type.designType}, got ${t}`), !1) : !0;
|
|
884
|
+
case "undefined":
|
|
885
|
+
return e !== void 0 ? (this.error(`Expected ${o.type.designType}, got ${t}`), !1) : !0;
|
|
886
|
+
case "null":
|
|
887
|
+
return e !== null ? (this.error(`Expected ${o.type.designType}, got ${t}`), !1) : !0;
|
|
888
|
+
default:
|
|
889
|
+
throw new Error(`Unknown type "${o.type.designType}"`);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
validateString(o, e) {
|
|
893
|
+
const t = o.metadata.get("expect.minLength");
|
|
894
|
+
if (t) {
|
|
895
|
+
const a = typeof t == "number" ? t : t.length;
|
|
896
|
+
if (e.length < a) {
|
|
897
|
+
const l = typeof t == "object" && t.message ? t.message : `Expected minimum length of ${a} characters, got ${e.length} characters`;
|
|
898
|
+
return this.error(l), !1;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
const r = o.metadata.get("expect.maxLength");
|
|
902
|
+
if (r) {
|
|
903
|
+
const a = typeof r == "number" ? r : r.length;
|
|
904
|
+
if (e.length > a) {
|
|
905
|
+
const l = typeof r == "object" && r.message ? r.message : `Expected maximum length of ${a} characters, got ${e.length} characters`;
|
|
906
|
+
return this.error(l), !1;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
const s = o.metadata.get("expect.pattern");
|
|
910
|
+
for (const { pattern: a, flags: l, message: c } of s || []) {
|
|
911
|
+
if (!a) continue;
|
|
912
|
+
const m = `${a}//${l || ""}`;
|
|
913
|
+
let p = ee.get(m);
|
|
914
|
+
if (p || (p = new RegExp(a, l), ee.set(m, p)), !p.test(e))
|
|
915
|
+
return this.error(c || `Value is expected to match pattern "${a}"`), !1;
|
|
916
|
+
}
|
|
917
|
+
return !0;
|
|
918
|
+
}
|
|
919
|
+
validateNumber(o, e) {
|
|
920
|
+
const t = o.metadata.get("expect.int");
|
|
921
|
+
if (t && e % 1 !== 0) {
|
|
922
|
+
const a = typeof t == "object" && t.message ? t.message : `Expected integer, got ${e}`;
|
|
923
|
+
return this.error(a), !1;
|
|
924
|
+
}
|
|
925
|
+
const r = o.metadata.get("expect.min");
|
|
926
|
+
if (r) {
|
|
927
|
+
const a = typeof r == "number" ? r : r.minValue;
|
|
928
|
+
if (e < a) {
|
|
929
|
+
const l = typeof r == "object" && r.message ? r.message : `Expected minimum ${a}, got ${e}`;
|
|
930
|
+
return this.error(l), !1;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
const s = o.metadata.get("expect.max");
|
|
934
|
+
if (s) {
|
|
935
|
+
const a = typeof s == "number" ? s : s.maxValue;
|
|
936
|
+
if (e > a) {
|
|
937
|
+
const l = typeof s == "object" && s.message ? s.message : `Expected maximum ${a}, got ${e}`;
|
|
938
|
+
return this.error(l), !1;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
return !0;
|
|
942
|
+
}
|
|
943
|
+
constructor(o, e) {
|
|
944
|
+
B(this, "def", void 0), B(this, "opts", void 0), B(this, "errors", void 0), B(this, "stackErrors", void 0), B(this, "stackPath", void 0), this.def = o, this.errors = [], this.stackErrors = [], this.stackPath = [], this.opts = {
|
|
945
|
+
partial: !1,
|
|
946
|
+
unknwonProps: "error",
|
|
947
|
+
errorLimit: 10,
|
|
948
|
+
...e,
|
|
949
|
+
plugins: (e == null ? void 0 : e.plugins) || []
|
|
602
950
|
};
|
|
603
|
-
i.push(G);
|
|
604
951
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
}
|
|
952
|
+
}, Je = class extends Error {
|
|
953
|
+
constructor(o) {
|
|
954
|
+
super(`${o[0].path ? o[0].path + ": " : ""}${o[0].message}`), B(this, "errors", void 0), B(this, "name", void 0), this.errors = o, this.name = "Validation Error";
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
function Ze(o) {
|
|
958
|
+
return o && o.__is_atscript_annotated_type;
|
|
959
|
+
}
|
|
960
|
+
function et(o) {
|
|
961
|
+
return o.type.kind === "" && o.type.designType === "phantom";
|
|
962
|
+
}
|
|
963
|
+
const tt = /* @__PURE__ */ new Set(["action", "paragraph", "select", "radio", "checkbox"]);
|
|
964
|
+
function ot(o) {
|
|
965
|
+
return (Array.isArray(o) ? o : [o]).map((t) => {
|
|
966
|
+
if (typeof t == "object" && t !== null && "label" in t) {
|
|
967
|
+
const { label: r, value: s } = t;
|
|
968
|
+
return s !== void 0 ? { key: s, label: r } : r;
|
|
969
|
+
}
|
|
970
|
+
return String(t);
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
function $(o, e, t, r) {
|
|
974
|
+
const { transform: s, defaultValue: a, staticAsBoolean: l = !1, compiler: c = ne } = r ?? {}, m = t.get(o);
|
|
975
|
+
if (typeof m == "string")
|
|
976
|
+
return c(m);
|
|
977
|
+
if (e !== void 0) {
|
|
978
|
+
const p = t.get(e);
|
|
979
|
+
if (p !== void 0)
|
|
980
|
+
return l ? !0 : s ? s(p) : p;
|
|
981
|
+
}
|
|
982
|
+
return a;
|
|
983
|
+
}
|
|
984
|
+
function nt(o, e) {
|
|
985
|
+
var t, r, s, a;
|
|
986
|
+
return {
|
|
987
|
+
optional: (t = $("foorm.fn.optional", void 0, o)) !== null && t !== void 0 ? t : e ?? !1,
|
|
988
|
+
disabled: (r = $("foorm.fn.disabled", "foorm.disabled", o, {
|
|
989
|
+
staticAsBoolean: !0
|
|
990
|
+
})) !== null && r !== void 0 ? r : !1,
|
|
991
|
+
hidden: (s = $("foorm.fn.hidden", "foorm.hidden", o, {
|
|
992
|
+
staticAsBoolean: !0
|
|
993
|
+
})) !== null && s !== void 0 ? s : !1,
|
|
994
|
+
readonly: (a = $("foorm.fn.readonly", "foorm.readonly", o, {
|
|
995
|
+
staticAsBoolean: !0
|
|
996
|
+
})) !== null && a !== void 0 ? a : !1
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
function rt(o, e) {
|
|
1000
|
+
return {
|
|
1001
|
+
label: $("foorm.fn.label", "meta.label", o, {
|
|
1002
|
+
defaultValue: e
|
|
1003
|
+
}),
|
|
1004
|
+
description: $("foorm.fn.description", "meta.description", o),
|
|
1005
|
+
hint: $("foorm.fn.hint", "meta.hint", o),
|
|
1006
|
+
placeholder: $("foorm.fn.placeholder", "meta.placeholder", o)
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
function st(o) {
|
|
1010
|
+
const e = o.get("foorm.attr"), t = o.get("foorm.fn.attr");
|
|
1011
|
+
if (!e && !t)
|
|
1012
|
+
return;
|
|
1013
|
+
const r = {};
|
|
1014
|
+
if (e) {
|
|
1015
|
+
const s = Array.isArray(e) ? e : [e];
|
|
1016
|
+
for (const a of s)
|
|
1017
|
+
if (typeof a == "object" && a !== null && "name" in a && "value" in a) {
|
|
1018
|
+
const { name: l, value: c } = a;
|
|
1019
|
+
r[l] = c;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
if (t) {
|
|
1023
|
+
const s = Array.isArray(t) ? t : [t];
|
|
1024
|
+
for (const a of s)
|
|
1025
|
+
if (typeof a == "object" && a !== null && "name" in a && "fn" in a) {
|
|
1026
|
+
const { name: l, fn: c } = a;
|
|
1027
|
+
r[l] = ne(c);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
return Object.keys(r).length > 0 ? r : void 0;
|
|
1031
|
+
}
|
|
1032
|
+
function at(o) {
|
|
1033
|
+
var e, t;
|
|
1034
|
+
const r = o.metadata, s = o.type.props, a = $("foorm.fn.title", "foorm.title", r, {
|
|
1035
|
+
compiler: G,
|
|
1036
|
+
defaultValue: ""
|
|
1037
|
+
}), l = $("foorm.fn.submit.text", "foorm.submit.text", r, {
|
|
1038
|
+
compiler: G,
|
|
1039
|
+
defaultValue: "Submit"
|
|
1040
|
+
}), c = $("foorm.fn.submit.disabled", "foorm.submit.disabled", r, {
|
|
1041
|
+
compiler: G,
|
|
1042
|
+
defaultValue: !1
|
|
1043
|
+
}), m = { text: l, disabled: c }, p = [];
|
|
1044
|
+
for (const [f, h] of s.entries()) {
|
|
1045
|
+
const u = h.metadata, d = (e = h.type) === null || e === void 0 ? void 0 : e.tags, A = u.get("foorm.type"), v = d ? [...d].find((i) => tt.has(i)) : void 0, E = (t = A ?? v) !== null && t !== void 0 ? t : "text", C = [], n = u.get("foorm.validate");
|
|
1046
|
+
if (n) {
|
|
1047
|
+
const i = Array.isArray(n) ? n : [n];
|
|
1048
|
+
for (const k of i)
|
|
1049
|
+
typeof k == "string" && C.push(Xe(k));
|
|
1050
|
+
}
|
|
1051
|
+
const F = u.get("expect.pattern") !== void 0 || u.get("expect.min") !== void 0 || u.get("expect.max") !== void 0 || u.get("expect.minLength") !== void 0 || u.get("expect.maxLength") !== void 0 || u.get("expect.int") !== void 0, D = d && d.size > 0;
|
|
1052
|
+
if (F || D) {
|
|
1053
|
+
const i = new Qe(h);
|
|
1054
|
+
C.push((k) => {
|
|
1055
|
+
var S;
|
|
1056
|
+
if (i.validate(k.v, !0))
|
|
1057
|
+
return !0;
|
|
1058
|
+
const z = (S = i.errors) === null || S === void 0 ? void 0 : S[0];
|
|
1059
|
+
return (z == null ? void 0 : z.message) || "Validation failed";
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
const j = Object.assign(Object.assign(Object.assign({ field: f, type: E, component: u.get("foorm.component"), autocomplete: u.get("foorm.autocomplete"), altAction: u.get("foorm.altAction"), order: u.get("foorm.order"), name: f }, rt(u, f)), nt(u, h.optional)), {
|
|
1063
|
+
// Appearance - truly optional
|
|
1064
|
+
classes: $("foorm.fn.classes", void 0, u),
|
|
1065
|
+
styles: $("foorm.fn.styles", void 0, u),
|
|
1066
|
+
// Data properties - truly optional
|
|
1067
|
+
options: $("foorm.fn.options", "foorm.options", u, {
|
|
1068
|
+
transform: ot
|
|
1069
|
+
}),
|
|
1070
|
+
value: $("foorm.fn.value", "foorm.value", u),
|
|
1071
|
+
validators: C,
|
|
1072
|
+
// Custom attributes/props
|
|
1073
|
+
attrs: st(u),
|
|
1074
|
+
// ATScript @expect constraints
|
|
1075
|
+
maxLength: u.get("expect.maxLength"),
|
|
1076
|
+
minLength: u.get("expect.minLength"),
|
|
1077
|
+
min: u.get("expect.min"),
|
|
1078
|
+
max: u.get("expect.max")
|
|
1079
|
+
});
|
|
1080
|
+
p.push(j);
|
|
1081
|
+
}
|
|
1082
|
+
return p.sort((f, h) => {
|
|
1083
|
+
var u, d;
|
|
1084
|
+
return ((u = f.order) !== null && u !== void 0 ? u : 1 / 0) - ((d = h.order) !== null && d !== void 0 ? d : 1 / 0);
|
|
1085
|
+
}), { title: a, submit: m, fields: p };
|
|
609
1086
|
}
|
|
610
|
-
function
|
|
611
|
-
const
|
|
612
|
-
return { form:
|
|
1087
|
+
function ct(o) {
|
|
1088
|
+
const e = at(o), t = ye(ve(e.fields));
|
|
1089
|
+
return { form: e, formData: t };
|
|
613
1090
|
}
|
|
614
1091
|
export {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
1092
|
+
_e as OoField,
|
|
1093
|
+
ut as OoForm,
|
|
1094
|
+
ct as useFoorm
|
|
618
1095
|
};
|