@volverjs/form-vue 0.0.14-beta.1 → 0.0.14-beta.3
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/VvForm.d.ts +25 -15
- package/dist/VvFormField.d.ts +4 -4
- package/dist/VvFormTemplate.d.ts +115 -5
- package/dist/VvFormWrapper.d.ts +7 -13
- package/dist/index.d.ts +1008 -104
- package/dist/index.es.js +326 -310
- package/dist/index.umd.js +1 -1
- package/dist/types.d.ts +62 -128
- package/package.json +19 -18
- package/src/VvForm.ts +32 -14
- package/src/VvFormField.ts +1 -1
- package/src/VvFormTemplate.ts +14 -17
- package/src/VvFormWrapper.ts +1 -1
- package/src/index.ts +20 -13
- package/src/{types.d.ts → types.ts} +37 -14
- package/src/utils.ts +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as W, computed as g, onMounted as Y, onBeforeUnmount as D, inject as I, toRefs as P, watch as E, unref as C, provide as J, readonly as S, resolveComponent as O, defineAsyncComponent as j, h as x, ref as _, toRaw as w, isProxy as F, withModifiers as ee, getCurrentInstance as re } from "vue";
|
|
2
2
|
import { watchThrottled as te } from "@vueuse/core";
|
|
3
|
-
import { ZodObject as
|
|
4
|
-
function
|
|
3
|
+
import { ZodObject as Z, ZodDefault as ae, ZodNullable as ue, ZodSchema as ne, ZodArray as le, ZodEffects as se, ZodOptional as ie } from "zod";
|
|
4
|
+
function K(e) {
|
|
5
5
|
return Array.isArray(e);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function fe(e) {
|
|
8
8
|
return typeof e < "u";
|
|
9
9
|
}
|
|
10
10
|
function q(e) {
|
|
11
11
|
return e === null;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function H(e) {
|
|
14
14
|
return typeof e == "object";
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function Q(e) {
|
|
17
17
|
return typeof e == "string";
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function N(e) {
|
|
20
20
|
return typeof e > "u";
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
function
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
26
|
-
return
|
|
27
|
-
const n =
|
|
22
|
+
const oe = /^[0-9]+$/, ve = ["__proto__", "prototype", "constructor"];
|
|
23
|
+
function G(e, s, t) {
|
|
24
|
+
const f = fe(t) ? t : void 0;
|
|
25
|
+
if (!H(e) || !Q(s))
|
|
26
|
+
return f;
|
|
27
|
+
const n = T(s);
|
|
28
28
|
if (n.length !== 0) {
|
|
29
29
|
for (const r of n) {
|
|
30
30
|
if (r === "*")
|
|
31
31
|
continue;
|
|
32
|
-
const
|
|
33
|
-
return
|
|
32
|
+
const u = function(i) {
|
|
33
|
+
return i.map((l) => N(l) || q(l) ? l : K(l) ? u(l) : l[r]);
|
|
34
34
|
};
|
|
35
|
-
if (
|
|
35
|
+
if (K(e) && !oe.test(r) ? e = u(e) : e = e[r], N(e) || q(e))
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return N(e) ? f : e;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
if (!
|
|
41
|
+
function R(e, s, t) {
|
|
42
|
+
if (!H(e) || !Q(s))
|
|
43
43
|
return;
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
44
|
+
const f = T(s);
|
|
45
|
+
if (f.length === 0)
|
|
46
46
|
return;
|
|
47
|
-
const n =
|
|
47
|
+
const n = f.length;
|
|
48
48
|
for (let r = 0; r < n; r++) {
|
|
49
|
-
const
|
|
49
|
+
const u = f[r];
|
|
50
50
|
if (r === n - 1) {
|
|
51
|
-
e[
|
|
51
|
+
e[u] = t;
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
55
|
-
const
|
|
56
|
-
for (const
|
|
57
|
-
|
|
54
|
+
if (u === "*" && K(e)) {
|
|
55
|
+
const i = f.slice(r + 1).join(".");
|
|
56
|
+
for (const l of e)
|
|
57
|
+
R(l, i, t);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
N(e[u]) && (e[u] = {}), e = e[u];
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
function
|
|
64
|
-
const
|
|
65
|
-
return
|
|
63
|
+
function T(e) {
|
|
64
|
+
const s = e.split(/[.]|(?:\[(\d|\*)\])/).filter((t) => !!t);
|
|
65
|
+
return s.some((t) => ve.indexOf(t) !== -1) ? [] : s;
|
|
66
66
|
}
|
|
67
|
-
var v = /* @__PURE__ */ ((e) => (e.text = "text", e.number = "number", e.email = "email", e.password = "password", e.tel = "tel", e.url = "url", e.search = "search", e.date = "date", e.time = "time", e.datetimeLocal = "datetime-local", e.month = "month", e.week = "week", e.color = "color", e.select = "select", e.checkbox = "checkbox", e.radio = "radio", e.textarea = "textarea", e.radioGroup = "radioGroup", e.checkboxGroup = "checkboxGroup", e.combobox = "combobox", e.custom = "custom", e))(v || {}),
|
|
68
|
-
const de = (e,
|
|
67
|
+
var v = /* @__PURE__ */ ((e) => (e.text = "text", e.number = "number", e.email = "email", e.password = "password", e.tel = "tel", e.url = "url", e.search = "search", e.date = "date", e.time = "time", e.datetimeLocal = "datetime-local", e.month = "month", e.week = "week", e.color = "color", e.select = "select", e.checkbox = "checkbox", e.radio = "radio", e.textarea = "textarea", e.radioGroup = "radioGroup", e.checkboxGroup = "checkboxGroup", e.combobox = "combobox", e.custom = "custom", e))(v || {}), B = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e))(B || {});
|
|
68
|
+
const de = (e, s, t, f) => W({
|
|
69
69
|
name: "FieldComponent",
|
|
70
70
|
props: {
|
|
71
71
|
type: {
|
|
@@ -100,68 +100,68 @@ const de = (e, o, l, i) => G({
|
|
|
100
100
|
},
|
|
101
101
|
emits: ["invalid", "valid", "update:formData", "update:modelValue"],
|
|
102
102
|
expose: ["invalid", "invalidLabel", "errors"],
|
|
103
|
-
setup(n, { slots: r, emit:
|
|
104
|
-
const
|
|
103
|
+
setup(n, { slots: r, emit: u }) {
|
|
104
|
+
const i = g({
|
|
105
105
|
get() {
|
|
106
|
-
if (
|
|
107
|
-
return
|
|
108
|
-
Object(
|
|
106
|
+
if (a != null && a.formData)
|
|
107
|
+
return G(
|
|
108
|
+
Object(a.formData.value),
|
|
109
109
|
String(n.name)
|
|
110
110
|
);
|
|
111
111
|
},
|
|
112
|
-
set(
|
|
113
|
-
|
|
114
|
-
Object(
|
|
112
|
+
set(o) {
|
|
113
|
+
a != null && a.formData && (R(
|
|
114
|
+
Object(a.formData.value),
|
|
115
115
|
String(n.name),
|
|
116
|
-
|
|
117
|
-
),
|
|
118
|
-
newValue:
|
|
119
|
-
formData:
|
|
116
|
+
o
|
|
117
|
+
), u("update:modelValue", {
|
|
118
|
+
newValue: i.value,
|
|
119
|
+
formData: a == null ? void 0 : a.formData
|
|
120
120
|
}));
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
123
|
Y(() => {
|
|
124
|
-
|
|
124
|
+
i.value === void 0 && n.defaultValue !== void 0 && (i.value = n.defaultValue);
|
|
125
125
|
}), D(() => {
|
|
126
|
-
|
|
126
|
+
k(), V();
|
|
127
127
|
});
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
return
|
|
133
|
-
}),
|
|
134
|
-
var
|
|
135
|
-
return (
|
|
136
|
-
}),
|
|
137
|
-
|
|
128
|
+
const l = I(s, void 0);
|
|
129
|
+
l && l.fields.value.add(n.name);
|
|
130
|
+
const a = I(e), { props: m, name: h } = P(n), b = g(() => {
|
|
131
|
+
if (a != null && a.errors.value)
|
|
132
|
+
return G(a.errors.value, String(n.name));
|
|
133
|
+
}), d = g(() => {
|
|
134
|
+
var o;
|
|
135
|
+
return (o = b.value) == null ? void 0 : o._errors;
|
|
136
|
+
}), c = g(() => b.value !== void 0), k = E(c, () => {
|
|
137
|
+
c.value ? (u("invalid", d.value), l && l.errors.value.set(
|
|
138
138
|
n.name,
|
|
139
139
|
{
|
|
140
|
-
_errors:
|
|
140
|
+
_errors: d.value
|
|
141
141
|
}
|
|
142
|
-
)) : (
|
|
142
|
+
)) : (u("valid", i.value), l && l.errors.value.delete(
|
|
143
143
|
n.name
|
|
144
144
|
));
|
|
145
|
-
}), V =
|
|
146
|
-
() =>
|
|
145
|
+
}), V = E(
|
|
146
|
+
() => a == null ? void 0 : a.formData,
|
|
147
147
|
() => {
|
|
148
|
-
|
|
148
|
+
u("update:formData", a == null ? void 0 : a.formData);
|
|
149
149
|
},
|
|
150
150
|
{ deep: !0 }
|
|
151
|
-
),
|
|
152
|
-
|
|
153
|
-
},
|
|
154
|
-
let
|
|
155
|
-
return typeof
|
|
156
|
-
(
|
|
151
|
+
), y = (o) => {
|
|
152
|
+
i.value = o;
|
|
153
|
+
}, $ = g(() => {
|
|
154
|
+
let o = m.value;
|
|
155
|
+
return typeof o == "function" && (o = o(a == null ? void 0 : a.formData)), Object.keys(o).reduce(
|
|
156
|
+
(A, p) => (A[p] = C(o[p]), A),
|
|
157
157
|
{}
|
|
158
158
|
);
|
|
159
|
-
}),
|
|
160
|
-
|
|
161
|
-
name:
|
|
162
|
-
invalid:
|
|
163
|
-
valid: n.showValid ? !!(!
|
|
164
|
-
type: ((
|
|
159
|
+
}), z = g(() => ({
|
|
160
|
+
...$.value,
|
|
161
|
+
name: $.value.name ?? n.name,
|
|
162
|
+
invalid: c.value,
|
|
163
|
+
valid: n.showValid ? !!(!c.value && i.value) : void 0,
|
|
164
|
+
type: ((o) => {
|
|
165
165
|
if ([
|
|
166
166
|
v.text,
|
|
167
167
|
v.number,
|
|
@@ -176,69 +176,69 @@ const de = (e, o, l, i) => G({
|
|
|
176
176
|
v.month,
|
|
177
177
|
v.week,
|
|
178
178
|
v.color
|
|
179
|
-
].includes(
|
|
180
|
-
return
|
|
179
|
+
].includes(o))
|
|
180
|
+
return o;
|
|
181
181
|
})(n.type),
|
|
182
|
-
invalidLabel:
|
|
183
|
-
modelValue:
|
|
184
|
-
"onUpdate:modelValue":
|
|
182
|
+
invalidLabel: d.value,
|
|
183
|
+
modelValue: i.value,
|
|
184
|
+
"onUpdate:modelValue": y
|
|
185
185
|
}));
|
|
186
|
-
return
|
|
187
|
-
name:
|
|
188
|
-
errors:
|
|
189
|
-
}), { component:
|
|
186
|
+
return J(t, {
|
|
187
|
+
name: S(h),
|
|
188
|
+
errors: S(b)
|
|
189
|
+
}), { component: g(() => {
|
|
190
190
|
if (n.type === v.custom)
|
|
191
191
|
return {
|
|
192
192
|
render() {
|
|
193
|
-
var
|
|
194
|
-
return ((
|
|
195
|
-
modelValue:
|
|
196
|
-
onUpdate:
|
|
197
|
-
submit:
|
|
198
|
-
validate:
|
|
199
|
-
invalid:
|
|
200
|
-
invalidLabel:
|
|
201
|
-
formData:
|
|
202
|
-
formErrors:
|
|
203
|
-
errors:
|
|
193
|
+
var o;
|
|
194
|
+
return ((o = r.default) == null ? void 0 : o.call(r, {
|
|
195
|
+
modelValue: i.value,
|
|
196
|
+
onUpdate: y,
|
|
197
|
+
submit: a == null ? void 0 : a.submit,
|
|
198
|
+
validate: a == null ? void 0 : a.validate,
|
|
199
|
+
invalid: c.value,
|
|
200
|
+
invalidLabel: d.value,
|
|
201
|
+
formData: a == null ? void 0 : a.formData.value,
|
|
202
|
+
formErrors: a == null ? void 0 : a.errors.value,
|
|
203
|
+
errors: b.value
|
|
204
204
|
})) ?? r.defalut;
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
|
-
if (!((
|
|
208
|
-
let
|
|
207
|
+
if (!((f == null ? void 0 : f.lazyLoad) ?? n.lazyLoad)) {
|
|
208
|
+
let o;
|
|
209
209
|
switch (n.type) {
|
|
210
210
|
case v.select:
|
|
211
|
-
|
|
211
|
+
o = O("VvSelect");
|
|
212
212
|
break;
|
|
213
213
|
case v.checkbox:
|
|
214
|
-
|
|
214
|
+
o = O("VvCheckbox");
|
|
215
215
|
break;
|
|
216
216
|
case v.radio:
|
|
217
|
-
|
|
217
|
+
o = O("VvRadio");
|
|
218
218
|
break;
|
|
219
219
|
case v.textarea:
|
|
220
|
-
|
|
220
|
+
o = O("VvTextarea");
|
|
221
221
|
break;
|
|
222
222
|
case v.radioGroup:
|
|
223
|
-
|
|
223
|
+
o = O("VvRadioGroup");
|
|
224
224
|
break;
|
|
225
225
|
case v.checkboxGroup:
|
|
226
|
-
|
|
226
|
+
o = O("VvCheckboxGroup");
|
|
227
227
|
break;
|
|
228
228
|
case v.combobox:
|
|
229
|
-
|
|
229
|
+
o = O("VvCombobox");
|
|
230
230
|
break;
|
|
231
231
|
default:
|
|
232
|
-
|
|
232
|
+
o = O("VvInputText");
|
|
233
233
|
}
|
|
234
|
-
if (typeof
|
|
235
|
-
return
|
|
234
|
+
if (typeof o != "string")
|
|
235
|
+
return o;
|
|
236
236
|
console.warn(
|
|
237
|
-
`[form-vue warn]: ${
|
|
237
|
+
`[form-vue warn]: ${o} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
240
|
return j(async () => {
|
|
241
|
-
switch (
|
|
241
|
+
switch (f != null && f.sideEffects && await Promise.resolve(f.sideEffects(n.type)), n.type) {
|
|
242
242
|
case v.textarea:
|
|
243
243
|
return import("@volverjs/ui-vue/vv-textarea");
|
|
244
244
|
case v.radio:
|
|
@@ -256,58 +256,58 @@ const de = (e, o, l, i) => G({
|
|
|
256
256
|
}
|
|
257
257
|
return import("@volverjs/ui-vue/vv-input-text");
|
|
258
258
|
});
|
|
259
|
-
}), hasProps:
|
|
259
|
+
}), hasProps: z, invalid: c };
|
|
260
260
|
},
|
|
261
261
|
render() {
|
|
262
262
|
return this.is ? x(this.is, this.hasProps, this.$slots) : this.type === v.custom ? x(this.component, null, this.$slots) : x(this.component, this.hasProps, this.$slots);
|
|
263
263
|
}
|
|
264
|
-
}),
|
|
265
|
-
const
|
|
266
|
-
let
|
|
267
|
-
for (;
|
|
268
|
-
|
|
269
|
-
return
|
|
270
|
-
},
|
|
264
|
+
}), U = (e, s = {}) => {
|
|
265
|
+
const t = (r) => {
|
|
266
|
+
let u = r;
|
|
267
|
+
for (; u instanceof se; )
|
|
268
|
+
u = u.innerType();
|
|
269
|
+
return u instanceof ie && (u = u._def.innerType), u;
|
|
270
|
+
}, f = t(e);
|
|
271
271
|
return {
|
|
272
|
-
...(
|
|
272
|
+
...(f instanceof Z ? f._def.unknownKeys === "passthrough" : !1) ? s : {},
|
|
273
273
|
...Object.fromEntries(
|
|
274
|
-
Object.entries(
|
|
275
|
-
([r,
|
|
276
|
-
const
|
|
277
|
-
let
|
|
278
|
-
if (
|
|
279
|
-
return [r,
|
|
280
|
-
if (
|
|
281
|
-
const m =
|
|
274
|
+
Object.entries(f.shape).map(
|
|
275
|
+
([r, u]) => {
|
|
276
|
+
const i = s[r];
|
|
277
|
+
let l = t(u), a;
|
|
278
|
+
if (l instanceof ae && (a = l._def.defaultValue(), l = l._def.innerType), i === null && l instanceof ue)
|
|
279
|
+
return [r, i];
|
|
280
|
+
if (l instanceof ne) {
|
|
281
|
+
const m = u.safeParse(i);
|
|
282
282
|
if (m.success)
|
|
283
|
-
return [r, m.data ??
|
|
283
|
+
return [r, m.data ?? a];
|
|
284
284
|
}
|
|
285
|
-
if (
|
|
286
|
-
const m =
|
|
287
|
-
if (m instanceof
|
|
285
|
+
if (l instanceof le && Array.isArray(i) && i.length) {
|
|
286
|
+
const m = t(l._def.type);
|
|
287
|
+
if (m instanceof Z)
|
|
288
288
|
return [
|
|
289
289
|
r,
|
|
290
|
-
|
|
291
|
-
(h) =>
|
|
290
|
+
i.map(
|
|
291
|
+
(h) => U(
|
|
292
292
|
m,
|
|
293
293
|
h && typeof h == "object" ? h : void 0
|
|
294
294
|
)
|
|
295
|
-
) ??
|
|
295
|
+
) ?? a
|
|
296
296
|
];
|
|
297
297
|
}
|
|
298
|
-
return
|
|
298
|
+
return l instanceof Z ? [
|
|
299
299
|
r,
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
300
|
+
U(
|
|
301
|
+
l,
|
|
302
|
+
i && typeof i == "object" ? i : a
|
|
303
303
|
)
|
|
304
|
-
] : [r,
|
|
304
|
+
] : [r, a];
|
|
305
305
|
}
|
|
306
306
|
)
|
|
307
307
|
)
|
|
308
308
|
};
|
|
309
|
-
}, ce = (e,
|
|
310
|
-
const
|
|
309
|
+
}, ce = (e, s, t, f) => {
|
|
310
|
+
const n = _(), r = _(), u = _(), i = W({
|
|
311
311
|
name: "FormComponent",
|
|
312
312
|
props: {
|
|
313
313
|
modelValue: {
|
|
@@ -321,51 +321,59 @@ const de = (e, o, l, i) => G({
|
|
|
321
321
|
continuosValidation: {
|
|
322
322
|
type: Boolean,
|
|
323
323
|
default: !1
|
|
324
|
+
},
|
|
325
|
+
template: {
|
|
326
|
+
type: [Array, Function]
|
|
324
327
|
}
|
|
325
328
|
},
|
|
326
329
|
emits: ["invalid", "valid", "submit", "update:modelValue"],
|
|
327
330
|
expose: ["submit", "validate", "errors", "status", "valid", "invalid"],
|
|
328
|
-
setup(
|
|
329
|
-
|
|
331
|
+
setup(l, { emit: a }) {
|
|
332
|
+
u.value = U(
|
|
330
333
|
e,
|
|
331
|
-
|
|
332
|
-
),
|
|
333
|
-
() =>
|
|
334
|
+
w(l.modelValue)
|
|
335
|
+
), E(
|
|
336
|
+
() => l.modelValue,
|
|
334
337
|
(d) => {
|
|
335
338
|
if (d) {
|
|
336
|
-
const c = F(d) ?
|
|
337
|
-
|
|
339
|
+
const c = F(d) ? w(d) : d;
|
|
340
|
+
u.value = typeof (c == null ? void 0 : c.clone) == "function" ? c.clone() : JSON.parse(JSON.stringify(c));
|
|
338
341
|
}
|
|
339
342
|
},
|
|
340
343
|
{ deep: !0 }
|
|
341
344
|
), te(
|
|
342
|
-
|
|
345
|
+
u,
|
|
343
346
|
(d) => {
|
|
344
|
-
|
|
347
|
+
var c;
|
|
348
|
+
((n.value || (t == null ? void 0 : t.continuosValidation)) ?? l.continuosValidation) && m(), (!d || !l.modelValue || JSON.stringify(d) !== JSON.stringify(l.modelValue)) && (a("update:modelValue", d), (c = t == null ? void 0 : t.onUpdate) == null || c.call(t, w(d)));
|
|
345
349
|
},
|
|
346
350
|
{
|
|
347
351
|
deep: !0,
|
|
348
|
-
throttle: (
|
|
352
|
+
throttle: (t == null ? void 0 : t.updateThrottle) ?? l.updateThrottle
|
|
349
353
|
}
|
|
350
354
|
);
|
|
351
|
-
const
|
|
355
|
+
const m = (d = u.value) => {
|
|
356
|
+
var k, V, y;
|
|
352
357
|
const c = e.safeParse(d);
|
|
353
|
-
return c.success ? (
|
|
354
|
-
},
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
358
|
+
return c.success ? (n.value = void 0, r.value = B.valid, u.value = c.data, a("update:modelValue", u.value), (V = t == null ? void 0 : t.onUpdate) == null || V.call(t, w(u.value)), a("valid", c.data), (y = t == null ? void 0 : t.onValid) == null || y.call(t, w(u.value)), !0) : (n.value = c.error.format(), r.value = B.invalid, a("invalid", n.value), (k = t == null ? void 0 : t.onInvalid) == null || k.call(t, w(n.value)), !1);
|
|
359
|
+
}, h = () => {
|
|
360
|
+
var d;
|
|
361
|
+
return m() ? (a("submit", u.value), (d = t == null ? void 0 : t.onSubmit) == null || d.call(t, w(u.value)), !0) : !1;
|
|
362
|
+
}, b = g(() => r.value === B.invalid);
|
|
363
|
+
return J(s, {
|
|
364
|
+
formData: u,
|
|
365
|
+
submit: h,
|
|
366
|
+
validate: m,
|
|
367
|
+
errors: S(n),
|
|
368
|
+
status: S(r),
|
|
369
|
+
invalid: b
|
|
362
370
|
}), {
|
|
363
|
-
formData:
|
|
364
|
-
submit:
|
|
365
|
-
validate:
|
|
366
|
-
errors:
|
|
367
|
-
status:
|
|
368
|
-
invalid:
|
|
371
|
+
formData: u,
|
|
372
|
+
submit: h,
|
|
373
|
+
validate: m,
|
|
374
|
+
errors: S(n),
|
|
375
|
+
status: S(r),
|
|
376
|
+
invalid: b
|
|
369
377
|
};
|
|
370
378
|
},
|
|
371
379
|
render() {
|
|
@@ -374,10 +382,14 @@ const de = (e, o, l, i) => G({
|
|
|
374
382
|
{
|
|
375
383
|
onSubmit: ee(this.submit, ["prevent"])
|
|
376
384
|
},
|
|
377
|
-
|
|
385
|
+
(this.template ?? (t == null ? void 0 : t.template)) && f ? [
|
|
386
|
+
x(f, {
|
|
387
|
+
schema: this.template ?? (t == null ? void 0 : t.template)
|
|
388
|
+
})
|
|
389
|
+
] : {
|
|
378
390
|
default: () => {
|
|
379
|
-
var
|
|
380
|
-
return ((
|
|
391
|
+
var l, a;
|
|
392
|
+
return ((a = (l = this.$slots) == null ? void 0 : l.default) == null ? void 0 : a.call(l, {
|
|
381
393
|
formData: this.formData,
|
|
382
394
|
submit: this.submit,
|
|
383
395
|
validate: this.validate,
|
|
@@ -391,15 +403,15 @@ const de = (e, o, l, i) => G({
|
|
|
391
403
|
}
|
|
392
404
|
});
|
|
393
405
|
return {
|
|
394
|
-
errors:
|
|
395
|
-
status:
|
|
396
|
-
formData:
|
|
406
|
+
errors: n,
|
|
407
|
+
status: r,
|
|
408
|
+
formData: u,
|
|
397
409
|
/**
|
|
398
410
|
* An hack to add types to the default slot
|
|
399
411
|
*/
|
|
400
|
-
VvForm:
|
|
412
|
+
VvForm: i
|
|
401
413
|
};
|
|
402
|
-
}, me = (e,
|
|
414
|
+
}, me = (e, s) => W({
|
|
403
415
|
name: "WrapperComponent",
|
|
404
416
|
props: {
|
|
405
417
|
name: {
|
|
@@ -413,34 +425,34 @@ const de = (e, o, l, i) => G({
|
|
|
413
425
|
},
|
|
414
426
|
emits: ["invalid", "valid"],
|
|
415
427
|
expose: ["fields", "invalid"],
|
|
416
|
-
setup(
|
|
417
|
-
const r =
|
|
418
|
-
|
|
419
|
-
name:
|
|
420
|
-
errors:
|
|
421
|
-
fields:
|
|
422
|
-
}),
|
|
423
|
-
|
|
428
|
+
setup(f, { emit: n }) {
|
|
429
|
+
const r = I(e), u = I(s, void 0), i = _(/* @__PURE__ */ new Set()), l = _(/* @__PURE__ */ new Map()), { name: a } = P(f);
|
|
430
|
+
J(s, {
|
|
431
|
+
name: S(a),
|
|
432
|
+
errors: l,
|
|
433
|
+
fields: i
|
|
434
|
+
}), E(
|
|
435
|
+
i,
|
|
424
436
|
(h) => {
|
|
425
|
-
|
|
426
|
-
|
|
437
|
+
u != null && u.fields && h.forEach((b) => {
|
|
438
|
+
u == null || u.fields.value.add(b);
|
|
427
439
|
});
|
|
428
440
|
},
|
|
429
441
|
{ deep: !0 }
|
|
430
|
-
),
|
|
431
|
-
() => new Map(
|
|
432
|
-
(h,
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}), Array.from(h.keys()).forEach((
|
|
436
|
-
const
|
|
437
|
-
|
|
442
|
+
), E(
|
|
443
|
+
() => new Map(l.value),
|
|
444
|
+
(h, b) => {
|
|
445
|
+
u != null && u.errors && (Array.from(b.keys()).forEach((d) => {
|
|
446
|
+
u.errors.value.delete(d);
|
|
447
|
+
}), Array.from(h.keys()).forEach((d) => {
|
|
448
|
+
const c = h.get(d);
|
|
449
|
+
c && u.errors.value.set(d, c);
|
|
438
450
|
}));
|
|
439
451
|
},
|
|
440
452
|
{ deep: !0 }
|
|
441
453
|
);
|
|
442
|
-
const m =
|
|
443
|
-
return
|
|
454
|
+
const m = g(() => r != null && r.invalid.value ? l.value.size > 0 : !1);
|
|
455
|
+
return E(m, () => {
|
|
444
456
|
m.value ? n("invalid") : n("valid");
|
|
445
457
|
}), {
|
|
446
458
|
formData: r == null ? void 0 : r.formData,
|
|
@@ -448,16 +460,16 @@ const de = (e, o, l, i) => G({
|
|
|
448
460
|
submit: r == null ? void 0 : r.submit,
|
|
449
461
|
validate: r == null ? void 0 : r.validate,
|
|
450
462
|
invalid: m,
|
|
451
|
-
fields:
|
|
452
|
-
fieldsErrors:
|
|
463
|
+
fields: i,
|
|
464
|
+
fieldsErrors: l
|
|
453
465
|
};
|
|
454
466
|
},
|
|
455
467
|
render() {
|
|
456
|
-
var
|
|
468
|
+
var f, n;
|
|
457
469
|
return this.tag ? x(this.tag, null, {
|
|
458
470
|
default: () => {
|
|
459
|
-
var r,
|
|
460
|
-
return ((
|
|
471
|
+
var r, u;
|
|
472
|
+
return ((u = (r = this.$slots).default) == null ? void 0 : u.call(r, {
|
|
461
473
|
invalid: this.invalid,
|
|
462
474
|
formData: this.formData,
|
|
463
475
|
submit: this.submit,
|
|
@@ -466,7 +478,7 @@ const de = (e, o, l, i) => G({
|
|
|
466
478
|
fieldsErrors: this.fieldsErrors
|
|
467
479
|
})) ?? this.$slots.defalut;
|
|
468
480
|
}
|
|
469
|
-
}) : ((n = (
|
|
481
|
+
}) : ((n = (f = this.$slots).default) == null ? void 0 : n.call(f, {
|
|
470
482
|
invalid: this.invalid,
|
|
471
483
|
formData: this.formData,
|
|
472
484
|
submit: this.submit,
|
|
@@ -475,132 +487,136 @@ const de = (e, o, l, i) => G({
|
|
|
475
487
|
fieldsErrors: this.fieldsErrors
|
|
476
488
|
})) ?? this.$slots.defalut;
|
|
477
489
|
}
|
|
478
|
-
}), he = (e,
|
|
479
|
-
const
|
|
490
|
+
}), he = (e, s) => {
|
|
491
|
+
const t = W({
|
|
480
492
|
props: {
|
|
481
493
|
schema: {
|
|
482
494
|
type: [Array, Function],
|
|
483
495
|
required: !0
|
|
484
496
|
}
|
|
485
497
|
},
|
|
486
|
-
setup(
|
|
487
|
-
const r =
|
|
488
|
-
if (
|
|
489
|
-
return
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
498
|
+
setup(f, { slots: n }) {
|
|
499
|
+
const r = I(e);
|
|
500
|
+
if (r != null && r.formData)
|
|
501
|
+
return () => {
|
|
502
|
+
var l;
|
|
503
|
+
const u = typeof f.schema == "function" ? f.schema(r) : f.schema;
|
|
504
|
+
let i;
|
|
505
|
+
return u.reduce(
|
|
506
|
+
(a, m) => {
|
|
507
|
+
const h = typeof m == "function" ? m(r) : m, {
|
|
508
|
+
vvIs: b,
|
|
509
|
+
vvName: d,
|
|
510
|
+
vvSlots: c,
|
|
511
|
+
vvChildren: k,
|
|
512
|
+
vvIf: V,
|
|
513
|
+
vvElseIf: y,
|
|
514
|
+
vvType: $,
|
|
515
|
+
vvDefaultValue: z,
|
|
516
|
+
vvShowValid: M,
|
|
517
|
+
vvContent: o,
|
|
518
|
+
...A
|
|
519
|
+
} = h;
|
|
520
|
+
if (V !== void 0) {
|
|
521
|
+
if (typeof V == "string" ? i = !!G(
|
|
522
|
+
Object(r.formData.value),
|
|
523
|
+
V
|
|
524
|
+
) : typeof V == "function" ? i = C(V(r)) : i = C(V), !i)
|
|
525
|
+
return a;
|
|
526
|
+
} else if (y !== void 0 && i !== void 0) {
|
|
527
|
+
if (i || (typeof y == "string" ? i = !!G(
|
|
528
|
+
Object(r.formData.value),
|
|
529
|
+
y
|
|
530
|
+
) : typeof y == "function" ? i = C(y(r)) : i = C(y), !i))
|
|
531
|
+
return a;
|
|
532
|
+
} else
|
|
533
|
+
i = void 0;
|
|
534
|
+
const p = k ? x(t, {
|
|
535
|
+
schema: k
|
|
536
|
+
}) : void 0;
|
|
537
|
+
return d ? (a.push(
|
|
538
|
+
x(
|
|
539
|
+
s,
|
|
540
|
+
{
|
|
541
|
+
name: d,
|
|
542
|
+
is: b,
|
|
543
|
+
type: $,
|
|
544
|
+
defaultValue: z,
|
|
545
|
+
showValid: M,
|
|
546
|
+
props: A
|
|
547
|
+
},
|
|
548
|
+
c ?? p ?? o
|
|
549
|
+
)
|
|
550
|
+
), a) : b ? (a.push(
|
|
551
|
+
x(
|
|
552
|
+
b,
|
|
553
|
+
A,
|
|
554
|
+
c ?? p ?? o
|
|
555
|
+
)
|
|
556
|
+
), a) : (k && a.push(p), a);
|
|
557
|
+
},
|
|
558
|
+
[
|
|
559
|
+
(l = n == null ? void 0 : n.default) == null ? void 0 : l.call(n, {
|
|
560
|
+
formData: r == null ? void 0 : r.formData.value,
|
|
561
|
+
submit: r == null ? void 0 : r.submit,
|
|
562
|
+
validate: r == null ? void 0 : r.validate,
|
|
563
|
+
errors: r == null ? void 0 : r.errors.value,
|
|
564
|
+
status: r == null ? void 0 : r.status.value,
|
|
565
|
+
invalid: r == null ? void 0 : r.invalid.value
|
|
566
|
+
})
|
|
567
|
+
]
|
|
568
|
+
);
|
|
569
|
+
};
|
|
558
570
|
}
|
|
559
571
|
});
|
|
560
|
-
return
|
|
561
|
-
},
|
|
562
|
-
const
|
|
572
|
+
return t;
|
|
573
|
+
}, L = (e, s = {}) => {
|
|
574
|
+
const t = Symbol(), f = Symbol(), n = Symbol(), r = me(
|
|
575
|
+
t,
|
|
576
|
+
f
|
|
577
|
+
), u = de(
|
|
578
|
+
t,
|
|
579
|
+
f,
|
|
580
|
+
n,
|
|
581
|
+
s
|
|
582
|
+
), i = he(t, u), { VvForm: l, errors: a, status: m, formData: h } = ce(
|
|
563
583
|
e,
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
), t = me(
|
|
567
|
-
l,
|
|
584
|
+
t,
|
|
585
|
+
s,
|
|
568
586
|
i
|
|
569
|
-
)
|
|
570
|
-
l,
|
|
571
|
-
i,
|
|
572
|
-
n,
|
|
573
|
-
o
|
|
574
|
-
), h = he(l, m);
|
|
587
|
+
);
|
|
575
588
|
return {
|
|
576
|
-
VvForm:
|
|
577
|
-
VvFormWrapper:
|
|
578
|
-
VvFormField:
|
|
579
|
-
VvFormTemplate:
|
|
580
|
-
formInjectionKey:
|
|
581
|
-
formWrapperInjectionKey:
|
|
589
|
+
VvForm: l,
|
|
590
|
+
VvFormWrapper: r,
|
|
591
|
+
VvFormField: u,
|
|
592
|
+
VvFormTemplate: i,
|
|
593
|
+
formInjectionKey: t,
|
|
594
|
+
formWrapperInjectionKey: f,
|
|
582
595
|
formFieldInjectionKey: n,
|
|
583
|
-
errors:
|
|
584
|
-
status:
|
|
585
|
-
formData:
|
|
596
|
+
errors: a,
|
|
597
|
+
status: m,
|
|
598
|
+
formData: h
|
|
586
599
|
};
|
|
587
|
-
}, X = Symbol(),
|
|
588
|
-
let
|
|
589
|
-
return e.schema && (
|
|
590
|
-
...
|
|
591
|
-
install(
|
|
592
|
-
|
|
600
|
+
}, X = Symbol(), ge = (e) => {
|
|
601
|
+
let s = {};
|
|
602
|
+
return e.schema && (s = L(e.schema, e)), {
|
|
603
|
+
...s,
|
|
604
|
+
install(t, { global: f = !1 } = {}) {
|
|
605
|
+
t.provide(X, e), f && (t.config.globalProperties.$vvForm = e, s != null && s.VvForm && t.component("VvForm", s.VvForm), s != null && s.VvFormWrapper && t.component("VvFormWrapper", s.VvFormWrapper), s != null && s.VvFormField && t.component("VvFormField", s.VvFormField), s != null && s.VvFormTemplate && t.component("VvFormTemplate", s.VvFormTemplate));
|
|
593
606
|
}
|
|
594
607
|
};
|
|
595
|
-
},
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
608
|
+
}, xe = (e, s = {}) => re() ? L(
|
|
609
|
+
e,
|
|
610
|
+
{
|
|
611
|
+
...I(X, {}),
|
|
612
|
+
...s
|
|
613
|
+
}
|
|
614
|
+
) : L(e, s), ke = (e, s = {}) => L(e, s);
|
|
599
615
|
export {
|
|
600
616
|
v as FormFieldType,
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
617
|
+
ge as createForm,
|
|
618
|
+
U as defaultObjectBySchema,
|
|
619
|
+
ke as formFactory,
|
|
604
620
|
X as pluginInjectionKey,
|
|
605
|
-
|
|
621
|
+
xe as useForm
|
|
606
622
|
};
|