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