@volverjs/form-vue 1.1.0-beta.3 → 1.1.0-beta.5
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/index.es.js +655 -1515
- package/dist/index.umd.js +1 -3
- package/dist/utils.d.ts +12 -0
- package/package.json +9 -9
- package/src/utils.ts +182 -30
package/dist/index.es.js
CHANGED
|
@@ -1,961 +1,164 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { watchIgnorable as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
})(le || (le = {}));
|
|
48
|
-
B.arrayToEnum([
|
|
49
|
-
"string",
|
|
50
|
-
"nan",
|
|
51
|
-
"number",
|
|
52
|
-
"integer",
|
|
53
|
-
"float",
|
|
54
|
-
"boolean",
|
|
55
|
-
"date",
|
|
56
|
-
"bigint",
|
|
57
|
-
"symbol",
|
|
58
|
-
"function",
|
|
59
|
-
"undefined",
|
|
60
|
-
"null",
|
|
61
|
-
"array",
|
|
62
|
-
"object",
|
|
63
|
-
"unknown",
|
|
64
|
-
"promise",
|
|
65
|
-
"void",
|
|
66
|
-
"never",
|
|
67
|
-
"map",
|
|
68
|
-
"set"
|
|
69
|
-
]);
|
|
70
|
-
B.arrayToEnum([
|
|
71
|
-
"invalid_type",
|
|
72
|
-
"invalid_literal",
|
|
73
|
-
"custom",
|
|
74
|
-
"invalid_union",
|
|
75
|
-
"invalid_union_discriminator",
|
|
76
|
-
"invalid_enum_value",
|
|
77
|
-
"unrecognized_keys",
|
|
78
|
-
"invalid_arguments",
|
|
79
|
-
"invalid_return_type",
|
|
80
|
-
"invalid_date",
|
|
81
|
-
"invalid_string",
|
|
82
|
-
"too_small",
|
|
83
|
-
"too_big",
|
|
84
|
-
"invalid_intersection_types",
|
|
85
|
-
"not_multiple_of",
|
|
86
|
-
"not_finite"
|
|
87
|
-
]);
|
|
88
|
-
class L extends Error {
|
|
89
|
-
get errors() {
|
|
90
|
-
return this.issues;
|
|
91
|
-
}
|
|
92
|
-
constructor(r) {
|
|
93
|
-
super(), this.issues = [], this.addIssue = (u) => {
|
|
94
|
-
this.issues = [...this.issues, u];
|
|
95
|
-
}, this.addIssues = (u = []) => {
|
|
96
|
-
this.issues = [...this.issues, ...u];
|
|
97
|
-
};
|
|
98
|
-
const n = new.target.prototype;
|
|
99
|
-
Object.setPrototypeOf ? Object.setPrototypeOf(this, n) : this.__proto__ = n, this.name = "ZodError", this.issues = r;
|
|
100
|
-
}
|
|
101
|
-
format(r) {
|
|
102
|
-
const n = r || function(o) {
|
|
103
|
-
return o.message;
|
|
104
|
-
}, u = { _errors: [] }, t = (o) => {
|
|
105
|
-
for (const s of o.issues)
|
|
106
|
-
if (s.code === "invalid_union")
|
|
107
|
-
s.unionErrors.map(t);
|
|
108
|
-
else if (s.code === "invalid_return_type")
|
|
109
|
-
t(s.returnTypeError);
|
|
110
|
-
else if (s.code === "invalid_arguments")
|
|
111
|
-
t(s.argumentsError);
|
|
112
|
-
else if (s.path.length === 0)
|
|
113
|
-
u._errors.push(n(s));
|
|
114
|
-
else {
|
|
115
|
-
let i = u, f = 0;
|
|
116
|
-
for (; f < s.path.length; ) {
|
|
117
|
-
const m = s.path[f];
|
|
118
|
-
f === s.path.length - 1 ? (i[m] = i[m] || { _errors: [] }, i[m]._errors.push(n(s))) : i[m] = i[m] || { _errors: [] }, i = i[m], f++;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
return t(this), u;
|
|
123
|
-
}
|
|
124
|
-
static assert(r) {
|
|
125
|
-
if (!(r instanceof L))
|
|
126
|
-
throw new Error(`Not a ZodError: ${r}`);
|
|
127
|
-
}
|
|
128
|
-
toString() {
|
|
129
|
-
return this.message;
|
|
130
|
-
}
|
|
131
|
-
get message() {
|
|
132
|
-
return JSON.stringify(this.issues, B.jsonStringifyReplacer, 2);
|
|
133
|
-
}
|
|
134
|
-
get isEmpty() {
|
|
135
|
-
return this.issues.length === 0;
|
|
136
|
-
}
|
|
137
|
-
flatten(r = (n) => n.message) {
|
|
138
|
-
const n = {}, u = [];
|
|
139
|
-
for (const t of this.issues)
|
|
140
|
-
if (t.path.length > 0) {
|
|
141
|
-
const o = t.path[0];
|
|
142
|
-
n[o] = n[o] || [], n[o].push(r(t));
|
|
143
|
-
} else
|
|
144
|
-
u.push(r(t));
|
|
145
|
-
return { formErrors: u, fieldErrors: n };
|
|
146
|
-
}
|
|
147
|
-
get formErrors() {
|
|
148
|
-
return this.flatten();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
L.create = (e) => new L(e);
|
|
152
|
-
function pe(e, r, n) {
|
|
153
|
-
function u(i, f) {
|
|
154
|
-
var m;
|
|
155
|
-
Object.defineProperty(i, "_zod", {
|
|
156
|
-
value: i._zod ?? {},
|
|
157
|
-
enumerable: !1
|
|
158
|
-
}), (m = i._zod).traits ?? (m.traits = /* @__PURE__ */ new Set()), i._zod.traits.add(e), r(i, f);
|
|
159
|
-
for (const d in s.prototype)
|
|
160
|
-
d in i || Object.defineProperty(i, d, { value: s.prototype[d].bind(i) });
|
|
161
|
-
i._zod.constr = s, i._zod.def = f;
|
|
162
|
-
}
|
|
163
|
-
const t = n?.Parent ?? Object;
|
|
164
|
-
class o extends t {
|
|
165
|
-
}
|
|
166
|
-
Object.defineProperty(o, "name", { value: e });
|
|
167
|
-
function s(i) {
|
|
168
|
-
var f;
|
|
169
|
-
const m = n?.Parent ? new o() : this;
|
|
170
|
-
u(m, i), (f = m._zod).deferred ?? (f.deferred = []);
|
|
171
|
-
for (const d of m._zod.deferred)
|
|
172
|
-
d();
|
|
173
|
-
return m;
|
|
174
|
-
}
|
|
175
|
-
return Object.defineProperty(s, "init", { value: u }), Object.defineProperty(s, Symbol.hasInstance, {
|
|
176
|
-
value: (i) => n?.Parent && i instanceof n.Parent ? !0 : i?._zod?.traits?.has(e)
|
|
177
|
-
}), Object.defineProperty(s, "name", { value: e }), s;
|
|
178
|
-
}
|
|
179
|
-
class Re extends Error {
|
|
180
|
-
constructor() {
|
|
181
|
-
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const ze = {};
|
|
185
|
-
function me(e) {
|
|
186
|
-
return ze;
|
|
187
|
-
}
|
|
188
|
-
function Te(e) {
|
|
189
|
-
const r = Object.values(e).filter((u) => typeof u == "number");
|
|
190
|
-
return Object.entries(e).filter(([u, t]) => r.indexOf(+u) === -1).map(([u, t]) => t);
|
|
191
|
-
}
|
|
192
|
-
function Ae(e, r) {
|
|
193
|
-
return typeof r == "bigint" ? r.toString() : r;
|
|
194
|
-
}
|
|
195
|
-
function K(e) {
|
|
196
|
-
return typeof e == "string" ? e : e?.message;
|
|
197
|
-
}
|
|
198
|
-
function ve(e, r, n) {
|
|
199
|
-
const u = { ...e, path: e.path ?? [] };
|
|
200
|
-
if (!e.message) {
|
|
201
|
-
const t = K(e.inst?._zod.def?.error?.(e)) ?? K(r?.error?.(e)) ?? K(n.customError?.(e)) ?? K(n.localeError?.(e)) ?? "Invalid input";
|
|
202
|
-
u.message = t;
|
|
203
|
-
}
|
|
204
|
-
return delete u.inst, delete u.continue, r?.reportInput || delete u.input, u;
|
|
205
|
-
}
|
|
206
|
-
const he = (e, r) => {
|
|
207
|
-
e.name = "$ZodError", Object.defineProperty(e, "_zod", {
|
|
208
|
-
value: e._zod,
|
|
209
|
-
enumerable: !1
|
|
210
|
-
}), Object.defineProperty(e, "issues", {
|
|
211
|
-
value: r,
|
|
212
|
-
enumerable: !1
|
|
213
|
-
}), e.message = JSON.stringify(r, Ae, 2), Object.defineProperty(e, "toString", {
|
|
214
|
-
value: () => e.message,
|
|
215
|
-
enumerable: !1
|
|
216
|
-
});
|
|
217
|
-
}, ye = pe("$ZodError", he), be = pe("$ZodError", he, { Parent: Error });
|
|
218
|
-
function ge(e, r) {
|
|
219
|
-
const n = function(o) {
|
|
220
|
-
return o.message;
|
|
221
|
-
}, u = { _errors: [] }, t = (o) => {
|
|
222
|
-
for (const s of o.issues)
|
|
223
|
-
if (s.code === "invalid_union" && s.errors.length)
|
|
224
|
-
s.errors.map((i) => t({ issues: i }));
|
|
225
|
-
else if (s.code === "invalid_key")
|
|
226
|
-
t({ issues: s.issues });
|
|
227
|
-
else if (s.code === "invalid_element")
|
|
228
|
-
t({ issues: s.issues });
|
|
229
|
-
else if (s.path.length === 0)
|
|
230
|
-
u._errors.push(n(s));
|
|
231
|
-
else {
|
|
232
|
-
let i = u, f = 0;
|
|
233
|
-
for (; f < s.path.length; ) {
|
|
234
|
-
const m = s.path[f];
|
|
235
|
-
f === s.path.length - 1 ? (i[m] = i[m] || { _errors: [] }, i[m]._errors.push(n(s))) : i[m] = i[m] || { _errors: [] }, i = i[m], f++;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
return t(e), u;
|
|
240
|
-
}
|
|
241
|
-
const Je = (e) => (r, n, u) => {
|
|
242
|
-
const t = u ? { ...u, async: !1 } : { async: !1 }, o = r._zod.run({ value: n, issues: [] }, t);
|
|
243
|
-
if (o instanceof Promise)
|
|
244
|
-
throw new Re();
|
|
245
|
-
return o.issues.length ? {
|
|
246
|
-
success: !1,
|
|
247
|
-
error: new (e ?? ye)(o.issues.map((s) => ve(s, t, me())))
|
|
248
|
-
} : { success: !0, data: o.value };
|
|
249
|
-
}, Fe = /* @__PURE__ */ Je(be), Ze = (e) => async (r, n, u) => {
|
|
250
|
-
const t = u ? Object.assign(u, { async: !0 }) : { async: !0 };
|
|
251
|
-
let o = r._zod.run({ value: n, issues: [] }, t);
|
|
252
|
-
return o instanceof Promise && (o = await o), o.issues.length ? {
|
|
253
|
-
success: !1,
|
|
254
|
-
error: new e(o.issues.map((s) => ve(s, t, me())))
|
|
255
|
-
} : { success: !0, data: o.value };
|
|
256
|
-
}, Me = /* @__PURE__ */ Ze(be);
|
|
257
|
-
class we {
|
|
258
|
-
constructor() {
|
|
259
|
-
this._map = /* @__PURE__ */ new Map(), this._idmap = /* @__PURE__ */ new Map();
|
|
260
|
-
}
|
|
261
|
-
add(r, ...n) {
|
|
262
|
-
const u = n[0];
|
|
263
|
-
if (this._map.set(r, u), u && typeof u == "object" && "id" in u) {
|
|
264
|
-
if (this._idmap.has(u.id))
|
|
265
|
-
throw new Error(`ID ${u.id} already exists in the registry`);
|
|
266
|
-
this._idmap.set(u.id, r);
|
|
267
|
-
}
|
|
268
|
-
return this;
|
|
269
|
-
}
|
|
270
|
-
clear() {
|
|
271
|
-
return this._map = /* @__PURE__ */ new Map(), this._idmap = /* @__PURE__ */ new Map(), this;
|
|
272
|
-
}
|
|
273
|
-
remove(r) {
|
|
274
|
-
const n = this._map.get(r);
|
|
275
|
-
return n && typeof n == "object" && "id" in n && this._idmap.delete(n.id), this._map.delete(r), this;
|
|
276
|
-
}
|
|
277
|
-
get(r) {
|
|
278
|
-
const n = r._zod.parent;
|
|
279
|
-
if (n) {
|
|
280
|
-
const u = { ...this.get(n) ?? {} };
|
|
281
|
-
delete u.id;
|
|
282
|
-
const t = { ...u, ...this._map.get(r) };
|
|
283
|
-
return Object.keys(t).length ? t : void 0;
|
|
284
|
-
}
|
|
285
|
-
return this._map.get(r);
|
|
286
|
-
}
|
|
287
|
-
has(r) {
|
|
288
|
-
return this._map.has(r);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
function Ue() {
|
|
292
|
-
return new we();
|
|
293
|
-
}
|
|
294
|
-
const Ge = /* @__PURE__ */ Ue();
|
|
295
|
-
class ce {
|
|
296
|
-
constructor(r) {
|
|
297
|
-
this.counter = 0, this.metadataRegistry = r?.metadata ?? Ge, this.target = r?.target ?? "draft-2020-12", this.unrepresentable = r?.unrepresentable ?? "throw", this.override = r?.override ?? (() => {
|
|
298
|
-
}), this.io = r?.io ?? "output", this.seen = /* @__PURE__ */ new Map();
|
|
299
|
-
}
|
|
300
|
-
process(r, n = { path: [], schemaPath: [] }) {
|
|
301
|
-
var u;
|
|
302
|
-
const t = r._zod.def, o = {
|
|
303
|
-
guid: "uuid",
|
|
304
|
-
url: "uri",
|
|
305
|
-
datetime: "date-time",
|
|
306
|
-
json_string: "json-string",
|
|
307
|
-
regex: ""
|
|
308
|
-
// do not set
|
|
309
|
-
}, s = this.seen.get(r);
|
|
310
|
-
if (s)
|
|
311
|
-
return s.count++, n.schemaPath.includes(r) && (s.cycle = n.path), s.schema;
|
|
312
|
-
const i = { schema: {}, count: 1, cycle: void 0, path: n.path };
|
|
313
|
-
this.seen.set(r, i);
|
|
314
|
-
const f = r._zod.toJSONSchema?.();
|
|
315
|
-
if (f)
|
|
316
|
-
i.schema = f;
|
|
317
|
-
else {
|
|
318
|
-
const c = {
|
|
319
|
-
...n,
|
|
320
|
-
schemaPath: [...n.schemaPath, r],
|
|
321
|
-
path: n.path
|
|
322
|
-
}, g = r._zod.parent;
|
|
323
|
-
if (g)
|
|
324
|
-
i.ref = g, this.process(g, c), this.seen.get(g).isParent = !0;
|
|
325
|
-
else {
|
|
326
|
-
const h = i.schema;
|
|
327
|
-
switch (t.type) {
|
|
328
|
-
case "string": {
|
|
329
|
-
const a = h;
|
|
330
|
-
a.type = "string";
|
|
331
|
-
const { minimum: l, maximum: p, format: y, patterns: w, contentEncoding: O } = r._zod.bag;
|
|
332
|
-
if (typeof l == "number" && (a.minLength = l), typeof p == "number" && (a.maxLength = p), y && (a.format = o[y] ?? y, a.format === "" && delete a.format), O && (a.contentEncoding = O), w && w.size > 0) {
|
|
333
|
-
const x = [...w];
|
|
334
|
-
x.length === 1 ? a.pattern = x[0].source : x.length > 1 && (i.schema.allOf = [
|
|
335
|
-
...x.map((_) => ({
|
|
336
|
-
...this.target === "draft-7" ? { type: "string" } : {},
|
|
337
|
-
pattern: _.source
|
|
338
|
-
}))
|
|
339
|
-
]);
|
|
1
|
+
import { ref as B, computed as O, readonly as F, defineComponent as U, h as z, withModifiers as re, toRaw as N, watch as Z, isProxy as me, onMounted as H, provide as Q, toRefs as Y, useId as ae, inject as G, onBeforeUnmount as L, unref as W, resolveComponent as $, defineAsyncComponent as pe, getCurrentInstance as ye } from "vue";
|
|
2
|
+
import { watchIgnorable as he, throttleFilter as be } from "@vueuse/core";
|
|
3
|
+
import { ZodError as je } from "zod/v3";
|
|
4
|
+
import { safeParse as Ve, safeParseAsync as ge, formatError as ne, $ZodError as we } from "zod/v4/core";
|
|
5
|
+
import { set as oe, get as P } from "ts-dot-prop";
|
|
6
|
+
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 || {}), S = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e.submitting = "submitting", e.reset = "reset", e.updated = "updated", e.unknown = "unknown", e))(S || {});
|
|
7
|
+
const K = (e) => e._def.typeName === "ZodObject", T = (e) => e._zod.def.type === "object", De = (e) => e._def.typeName === "ZodDefault", Oe = (e) => e._zod.def.type === "default", _e = (e) => e._def.typeName === "ZodNullable", Re = (e) => e._zod.def.type === "nullable", Se = (e) => e._def.typeName === "ZodRecord", Ie = (e) => e._zod.def.type === "record", ze = (e) => e._def.typeName === "ZodArray", Ee = (e) => e._zod.def.type === "array", le = (e) => e._def.typeName === "ZodEffects", ue = (e) => e._def.typeName === "ZodOptional", ie = (e) => e._zod.def.type === "optional", se = (e) => e._zod.def.type === "pipe", de = (e) => e._zod.def.type === "transform", C = (e) => {
|
|
8
|
+
let t = e;
|
|
9
|
+
for (; le(t); )
|
|
10
|
+
t = t.innerType();
|
|
11
|
+
return ue(t) && (t = t._def.innerType), t;
|
|
12
|
+
}, M = (e) => {
|
|
13
|
+
let t = e;
|
|
14
|
+
for (; se(t); )
|
|
15
|
+
de(t._zod.def.out) ? t = t._zod.def.in : t = t._zod.def.out;
|
|
16
|
+
return ie(t) && (t = t._zod.def.innerType), t;
|
|
17
|
+
}, xe = (e) => {
|
|
18
|
+
let t = e;
|
|
19
|
+
for (; le(t); )
|
|
20
|
+
t = t.innerType();
|
|
21
|
+
return !!ue(t);
|
|
22
|
+
}, Ze = (e) => {
|
|
23
|
+
let t = e;
|
|
24
|
+
for (; se(t); )
|
|
25
|
+
de(t._zod.def.out) ? t = t._zod.def.in : t = t._zod.def.out;
|
|
26
|
+
return !!ie(t);
|
|
27
|
+
}, X = (e) => "_zod" in e;
|
|
28
|
+
function k(e, t = {}) {
|
|
29
|
+
if (X(e)) {
|
|
30
|
+
const a = M(e);
|
|
31
|
+
return T(a) ? {
|
|
32
|
+
...!(!a._zod.def.catchall || a._zod.def.catchall?._zod.def.type === "never") ? t : {},
|
|
33
|
+
...Object.fromEntries(
|
|
34
|
+
("shape" in a._zod.def ? Object.entries(a._zod.def.shape) : []).map(
|
|
35
|
+
([l, f]) => {
|
|
36
|
+
const r = t[l], v = Ze(f);
|
|
37
|
+
let o = M(f), d;
|
|
38
|
+
if (Oe(o) && (d = o._zod.def.defaultValue, o = o._zod.def.innerType), r === null && Re(o))
|
|
39
|
+
return [l, r];
|
|
40
|
+
if (r == null && v)
|
|
41
|
+
return [l, d];
|
|
42
|
+
if (o) {
|
|
43
|
+
const c = Ve(f, r);
|
|
44
|
+
if (c.success)
|
|
45
|
+
return [l, c.data ?? d];
|
|
340
46
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
case "bigint": {
|
|
354
|
-
if (this.unrepresentable === "throw")
|
|
355
|
-
throw new Error("BigInt cannot be represented in JSON Schema");
|
|
356
|
-
break;
|
|
357
|
-
}
|
|
358
|
-
case "symbol": {
|
|
359
|
-
if (this.unrepresentable === "throw")
|
|
360
|
-
throw new Error("Symbols cannot be represented in JSON Schema");
|
|
361
|
-
break;
|
|
362
|
-
}
|
|
363
|
-
case "null": {
|
|
364
|
-
h.type = "null";
|
|
365
|
-
break;
|
|
366
|
-
}
|
|
367
|
-
case "any":
|
|
368
|
-
break;
|
|
369
|
-
case "unknown":
|
|
370
|
-
break;
|
|
371
|
-
case "undefined": {
|
|
372
|
-
if (this.unrepresentable === "throw")
|
|
373
|
-
throw new Error("Undefined cannot be represented in JSON Schema");
|
|
374
|
-
break;
|
|
375
|
-
}
|
|
376
|
-
case "void": {
|
|
377
|
-
if (this.unrepresentable === "throw")
|
|
378
|
-
throw new Error("Void cannot be represented in JSON Schema");
|
|
379
|
-
break;
|
|
380
|
-
}
|
|
381
|
-
case "never": {
|
|
382
|
-
h.not = {};
|
|
383
|
-
break;
|
|
384
|
-
}
|
|
385
|
-
case "date": {
|
|
386
|
-
if (this.unrepresentable === "throw")
|
|
387
|
-
throw new Error("Date cannot be represented in JSON Schema");
|
|
388
|
-
break;
|
|
389
|
-
}
|
|
390
|
-
case "array": {
|
|
391
|
-
const a = h, { minimum: l, maximum: p } = r._zod.bag;
|
|
392
|
-
typeof l == "number" && (a.minItems = l), typeof p == "number" && (a.maxItems = p), a.type = "array", a.items = this.process(t.element, { ...c, path: [...c.path, "items"] });
|
|
393
|
-
break;
|
|
394
|
-
}
|
|
395
|
-
case "object": {
|
|
396
|
-
const a = h;
|
|
397
|
-
a.type = "object", a.properties = {};
|
|
398
|
-
const l = t.shape;
|
|
399
|
-
for (const w in l)
|
|
400
|
-
a.properties[w] = this.process(l[w], {
|
|
401
|
-
...c,
|
|
402
|
-
path: [...c.path, "properties", w]
|
|
403
|
-
});
|
|
404
|
-
const p = new Set(Object.keys(l)), y = new Set([...p].filter((w) => {
|
|
405
|
-
const O = t.shape[w]._zod;
|
|
406
|
-
return this.io === "input" ? O.optin === void 0 : O.optout === void 0;
|
|
407
|
-
}));
|
|
408
|
-
y.size > 0 && (a.required = Array.from(y)), t.catchall?._zod.def.type === "never" ? a.additionalProperties = !1 : t.catchall ? t.catchall && (a.additionalProperties = this.process(t.catchall, {
|
|
409
|
-
...c,
|
|
410
|
-
path: [...c.path, "additionalProperties"]
|
|
411
|
-
})) : this.io === "output" && (a.additionalProperties = !1);
|
|
412
|
-
break;
|
|
413
|
-
}
|
|
414
|
-
case "union": {
|
|
415
|
-
const a = h;
|
|
416
|
-
a.anyOf = t.options.map((l, p) => this.process(l, {
|
|
417
|
-
...c,
|
|
418
|
-
path: [...c.path, "anyOf", p]
|
|
419
|
-
}));
|
|
420
|
-
break;
|
|
421
|
-
}
|
|
422
|
-
case "intersection": {
|
|
423
|
-
const a = h, l = this.process(t.left, {
|
|
424
|
-
...c,
|
|
425
|
-
path: [...c.path, "allOf", 0]
|
|
426
|
-
}), p = this.process(t.right, {
|
|
427
|
-
...c,
|
|
428
|
-
path: [...c.path, "allOf", 1]
|
|
429
|
-
}), y = (O) => "allOf" in O && Object.keys(O).length === 1, w = [
|
|
430
|
-
...y(l) ? l.allOf : [l],
|
|
431
|
-
...y(p) ? p.allOf : [p]
|
|
432
|
-
];
|
|
433
|
-
a.allOf = w;
|
|
434
|
-
break;
|
|
435
|
-
}
|
|
436
|
-
case "tuple": {
|
|
437
|
-
const a = h;
|
|
438
|
-
a.type = "array";
|
|
439
|
-
const l = t.items.map((w, O) => this.process(w, { ...c, path: [...c.path, "prefixItems", O] }));
|
|
440
|
-
if (this.target === "draft-2020-12" ? a.prefixItems = l : a.items = l, t.rest) {
|
|
441
|
-
const w = this.process(t.rest, {
|
|
442
|
-
...c,
|
|
443
|
-
path: [...c.path, "items"]
|
|
444
|
-
});
|
|
445
|
-
this.target === "draft-2020-12" ? a.items = w : a.additionalItems = w;
|
|
47
|
+
if (Ee(o) && Array.isArray(r) && r.length) {
|
|
48
|
+
const c = M(o._zod.def.element);
|
|
49
|
+
if (T(c))
|
|
50
|
+
return [
|
|
51
|
+
l,
|
|
52
|
+
r.map(
|
|
53
|
+
(D) => k(
|
|
54
|
+
c,
|
|
55
|
+
D && typeof D == "object" ? D : void 0
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
];
|
|
446
59
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
const { minimum: p, maximum: y } = r._zod.bag;
|
|
452
|
-
typeof p == "number" && (a.minItems = p), typeof y == "number" && (a.maxItems = y);
|
|
453
|
-
break;
|
|
454
|
-
}
|
|
455
|
-
case "record": {
|
|
456
|
-
const a = h;
|
|
457
|
-
a.type = "object", a.propertyNames = this.process(t.keyType, { ...c, path: [...c.path, "propertyNames"] }), a.additionalProperties = this.process(t.valueType, {
|
|
458
|
-
...c,
|
|
459
|
-
path: [...c.path, "additionalProperties"]
|
|
460
|
-
});
|
|
461
|
-
break;
|
|
462
|
-
}
|
|
463
|
-
case "map": {
|
|
464
|
-
if (this.unrepresentable === "throw")
|
|
465
|
-
throw new Error("Map cannot be represented in JSON Schema");
|
|
466
|
-
break;
|
|
467
|
-
}
|
|
468
|
-
case "set": {
|
|
469
|
-
if (this.unrepresentable === "throw")
|
|
470
|
-
throw new Error("Set cannot be represented in JSON Schema");
|
|
471
|
-
break;
|
|
472
|
-
}
|
|
473
|
-
case "enum": {
|
|
474
|
-
const a = h, l = Te(t.entries);
|
|
475
|
-
l.every((p) => typeof p == "number") && (a.type = "number"), l.every((p) => typeof p == "string") && (a.type = "string"), a.enum = l;
|
|
476
|
-
break;
|
|
477
|
-
}
|
|
478
|
-
case "literal": {
|
|
479
|
-
const a = h, l = [];
|
|
480
|
-
for (const p of t.values)
|
|
481
|
-
if (p === void 0) {
|
|
482
|
-
if (this.unrepresentable === "throw")
|
|
483
|
-
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
484
|
-
} else if (typeof p == "bigint") {
|
|
485
|
-
if (this.unrepresentable === "throw")
|
|
486
|
-
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
487
|
-
l.push(Number(p));
|
|
488
|
-
} else
|
|
489
|
-
l.push(p);
|
|
490
|
-
if (l.length !== 0) if (l.length === 1) {
|
|
491
|
-
const p = l[0];
|
|
492
|
-
a.type = p === null ? "null" : typeof p, a.const = p;
|
|
493
|
-
} else
|
|
494
|
-
l.every((p) => typeof p == "number") && (a.type = "number"), l.every((p) => typeof p == "string") && (a.type = "string"), l.every((p) => typeof p == "boolean") && (a.type = "string"), l.every((p) => p === null) && (a.type = "null"), a.enum = l;
|
|
495
|
-
break;
|
|
496
|
-
}
|
|
497
|
-
case "file": {
|
|
498
|
-
const a = h, l = {
|
|
499
|
-
type: "string",
|
|
500
|
-
format: "binary",
|
|
501
|
-
contentEncoding: "binary"
|
|
502
|
-
}, { minimum: p, maximum: y, mime: w } = r._zod.bag;
|
|
503
|
-
p !== void 0 && (l.minLength = p), y !== void 0 && (l.maxLength = y), w ? w.length === 1 ? (l.contentMediaType = w[0], Object.assign(a, l)) : a.anyOf = w.map((O) => ({ ...l, contentMediaType: O })) : Object.assign(a, l);
|
|
504
|
-
break;
|
|
505
|
-
}
|
|
506
|
-
case "transform": {
|
|
507
|
-
if (this.unrepresentable === "throw")
|
|
508
|
-
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
509
|
-
break;
|
|
510
|
-
}
|
|
511
|
-
case "nullable": {
|
|
512
|
-
const a = this.process(t.innerType, c);
|
|
513
|
-
h.anyOf = [a, { type: "null" }];
|
|
514
|
-
break;
|
|
515
|
-
}
|
|
516
|
-
case "nonoptional": {
|
|
517
|
-
this.process(t.innerType, c), i.ref = t.innerType;
|
|
518
|
-
break;
|
|
519
|
-
}
|
|
520
|
-
case "success": {
|
|
521
|
-
const a = h;
|
|
522
|
-
a.type = "boolean";
|
|
523
|
-
break;
|
|
524
|
-
}
|
|
525
|
-
case "default": {
|
|
526
|
-
this.process(t.innerType, c), i.ref = t.innerType, h.default = JSON.parse(JSON.stringify(t.defaultValue));
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
case "prefault": {
|
|
530
|
-
this.process(t.innerType, c), i.ref = t.innerType, this.io === "input" && (h._prefault = JSON.parse(JSON.stringify(t.defaultValue)));
|
|
531
|
-
break;
|
|
532
|
-
}
|
|
533
|
-
case "catch": {
|
|
534
|
-
this.process(t.innerType, c), i.ref = t.innerType;
|
|
535
|
-
let a;
|
|
536
|
-
try {
|
|
537
|
-
a = t.catchValue(void 0);
|
|
538
|
-
} catch {
|
|
539
|
-
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
60
|
+
if (Ie(o) && r) {
|
|
61
|
+
const c = M(o._zod.def.valueType);
|
|
62
|
+
if (T(c))
|
|
63
|
+
return [l, Object.keys(r).reduce((D, p) => (D[p] = k(c, r[p]), D), {})];
|
|
540
64
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
}
|
|
549
|
-
case "template_literal": {
|
|
550
|
-
const a = h, l = r._zod.pattern;
|
|
551
|
-
if (!l)
|
|
552
|
-
throw new Error("Pattern not found in template literal");
|
|
553
|
-
a.type = "string", a.pattern = l.source;
|
|
554
|
-
break;
|
|
555
|
-
}
|
|
556
|
-
case "pipe": {
|
|
557
|
-
const a = this.io === "input" ? t.in._zod.def.type === "transform" ? t.out : t.in : t.out;
|
|
558
|
-
this.process(a, c), i.ref = a;
|
|
559
|
-
break;
|
|
560
|
-
}
|
|
561
|
-
case "readonly": {
|
|
562
|
-
this.process(t.innerType, c), i.ref = t.innerType, h.readOnly = !0;
|
|
563
|
-
break;
|
|
564
|
-
}
|
|
565
|
-
// passthrough types
|
|
566
|
-
case "promise": {
|
|
567
|
-
this.process(t.innerType, c), i.ref = t.innerType;
|
|
568
|
-
break;
|
|
569
|
-
}
|
|
570
|
-
case "optional": {
|
|
571
|
-
this.process(t.innerType, c), i.ref = t.innerType;
|
|
572
|
-
break;
|
|
573
|
-
}
|
|
574
|
-
case "lazy": {
|
|
575
|
-
const a = r._zod.innerType;
|
|
576
|
-
this.process(a, c), i.ref = a;
|
|
577
|
-
break;
|
|
578
|
-
}
|
|
579
|
-
case "custom": {
|
|
580
|
-
if (this.unrepresentable === "throw")
|
|
581
|
-
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
582
|
-
break;
|
|
65
|
+
return T(o) ? [
|
|
66
|
+
l,
|
|
67
|
+
k(
|
|
68
|
+
o,
|
|
69
|
+
r && typeof r == "object" ? r : d
|
|
70
|
+
)
|
|
71
|
+
] : [l, d];
|
|
583
72
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
}
|
|
587
|
-
const m = this.metadataRegistry.get(r);
|
|
588
|
-
return m && Object.assign(i.schema, m), this.io === "input" && I(r) && (delete i.schema.examples, delete i.schema.default), this.io === "input" && i.schema._prefault && ((u = i.schema).default ?? (u.default = i.schema._prefault)), delete i.schema._prefault, this.seen.get(r).schema;
|
|
589
|
-
}
|
|
590
|
-
emit(r, n) {
|
|
591
|
-
const u = {
|
|
592
|
-
cycles: n?.cycles ?? "ref",
|
|
593
|
-
reused: n?.reused ?? "inline",
|
|
594
|
-
// unrepresentable: _params?.unrepresentable ?? "throw",
|
|
595
|
-
// uri: _params?.uri ?? ((id) => `${id}`),
|
|
596
|
-
external: n?.external ?? void 0
|
|
597
|
-
}, t = this.seen.get(r);
|
|
598
|
-
if (!t)
|
|
599
|
-
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
600
|
-
const o = (d) => {
|
|
601
|
-
const c = this.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
602
|
-
if (u.external) {
|
|
603
|
-
const l = u.external.registry.get(d[0])?.id, p = u.external.uri ?? ((w) => w);
|
|
604
|
-
if (l)
|
|
605
|
-
return { ref: p(l) };
|
|
606
|
-
const y = d[1].defId ?? d[1].schema.id ?? `schema${this.counter++}`;
|
|
607
|
-
return d[1].defId = y, { defId: y, ref: `${p("__shared")}#/${c}/${y}` };
|
|
608
|
-
}
|
|
609
|
-
if (d[1] === t)
|
|
610
|
-
return { ref: "#" };
|
|
611
|
-
const h = `#/${c}/`, a = d[1].schema.id ?? `__schema${this.counter++}`;
|
|
612
|
-
return { defId: a, ref: h + a };
|
|
613
|
-
}, s = (d) => {
|
|
614
|
-
if (d[1].schema.$ref)
|
|
615
|
-
return;
|
|
616
|
-
const c = d[1], { ref: g, defId: h } = o(d);
|
|
617
|
-
c.def = { ...c.schema }, h && (c.defId = h);
|
|
618
|
-
const a = c.schema;
|
|
619
|
-
for (const l in a)
|
|
620
|
-
delete a[l];
|
|
621
|
-
a.$ref = g;
|
|
622
|
-
};
|
|
623
|
-
if (u.cycles === "throw")
|
|
624
|
-
for (const d of this.seen.entries()) {
|
|
625
|
-
const c = d[1];
|
|
626
|
-
if (c.cycle)
|
|
627
|
-
throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
628
|
-
|
|
629
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
630
|
-
}
|
|
631
|
-
for (const d of this.seen.entries()) {
|
|
632
|
-
const c = d[1];
|
|
633
|
-
if (r === d[0]) {
|
|
634
|
-
s(d);
|
|
635
|
-
continue;
|
|
636
|
-
}
|
|
637
|
-
if (u.external) {
|
|
638
|
-
const h = u.external.registry.get(d[0])?.id;
|
|
639
|
-
if (r !== d[0] && h) {
|
|
640
|
-
s(d);
|
|
641
|
-
continue;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
if (this.metadataRegistry.get(d[0])?.id) {
|
|
645
|
-
s(d);
|
|
646
|
-
continue;
|
|
647
|
-
}
|
|
648
|
-
if (c.cycle) {
|
|
649
|
-
s(d);
|
|
650
|
-
continue;
|
|
651
|
-
}
|
|
652
|
-
if (c.count > 1 && u.reused === "ref") {
|
|
653
|
-
s(d);
|
|
654
|
-
continue;
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
const i = (d, c) => {
|
|
658
|
-
const g = this.seen.get(d), h = g.def ?? g.schema, a = { ...h };
|
|
659
|
-
if (g.ref === null)
|
|
660
|
-
return;
|
|
661
|
-
const l = g.ref;
|
|
662
|
-
if (g.ref = null, l) {
|
|
663
|
-
i(l, c);
|
|
664
|
-
const p = this.seen.get(l).schema;
|
|
665
|
-
p.$ref && c.target === "draft-7" ? (h.allOf = h.allOf ?? [], h.allOf.push(p)) : (Object.assign(h, p), Object.assign(h, a));
|
|
666
|
-
}
|
|
667
|
-
g.isParent || this.override({
|
|
668
|
-
zodSchema: d,
|
|
669
|
-
jsonSchema: h,
|
|
670
|
-
path: g.path ?? []
|
|
671
|
-
});
|
|
672
|
-
};
|
|
673
|
-
for (const d of [...this.seen.entries()].reverse())
|
|
674
|
-
i(d[0], { target: this.target });
|
|
675
|
-
const f = {};
|
|
676
|
-
if (this.target === "draft-2020-12" ? f.$schema = "https://json-schema.org/draft/2020-12/schema" : this.target === "draft-7" ? f.$schema = "http://json-schema.org/draft-07/schema#" : console.warn(`Invalid target: ${this.target}`), u.external?.uri) {
|
|
677
|
-
const d = u.external.registry.get(r)?.id;
|
|
678
|
-
if (!d)
|
|
679
|
-
throw new Error("Schema is missing an `id` property");
|
|
680
|
-
f.$id = u.external.uri(d);
|
|
681
|
-
}
|
|
682
|
-
Object.assign(f, t.def);
|
|
683
|
-
const m = u.external?.defs ?? {};
|
|
684
|
-
for (const d of this.seen.entries()) {
|
|
685
|
-
const c = d[1];
|
|
686
|
-
c.def && c.defId && (m[c.defId] = c.def);
|
|
687
|
-
}
|
|
688
|
-
u.external || Object.keys(m).length > 0 && (this.target === "draft-2020-12" ? f.$defs = m : f.definitions = m);
|
|
689
|
-
try {
|
|
690
|
-
return JSON.parse(JSON.stringify(f));
|
|
691
|
-
} catch {
|
|
692
|
-
throw new Error("Error converting schema to JSON.");
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
function Be(e, r) {
|
|
697
|
-
if (e instanceof we) {
|
|
698
|
-
const u = new ce(r), t = {};
|
|
699
|
-
for (const i of e._idmap.entries()) {
|
|
700
|
-
const [f, m] = i;
|
|
701
|
-
u.process(m);
|
|
702
|
-
}
|
|
703
|
-
const o = {}, s = {
|
|
704
|
-
registry: e,
|
|
705
|
-
uri: r?.uri,
|
|
706
|
-
defs: t
|
|
707
|
-
};
|
|
708
|
-
for (const i of e._idmap.entries()) {
|
|
709
|
-
const [f, m] = i;
|
|
710
|
-
o[f] = u.emit(m, {
|
|
711
|
-
...r,
|
|
712
|
-
external: s
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
|
-
if (Object.keys(t).length > 0) {
|
|
716
|
-
const i = u.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
717
|
-
o.__shared = {
|
|
718
|
-
[i]: t
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
|
-
return { schemas: o };
|
|
722
|
-
}
|
|
723
|
-
const n = new ce(r);
|
|
724
|
-
return n.process(e), n.emit(e, r);
|
|
725
|
-
}
|
|
726
|
-
function I(e, r) {
|
|
727
|
-
const n = r ?? { seen: /* @__PURE__ */ new Set() };
|
|
728
|
-
if (n.seen.has(e))
|
|
729
|
-
return !1;
|
|
730
|
-
n.seen.add(e);
|
|
731
|
-
const t = e._zod.def;
|
|
732
|
-
switch (t.type) {
|
|
733
|
-
case "string":
|
|
734
|
-
case "number":
|
|
735
|
-
case "bigint":
|
|
736
|
-
case "boolean":
|
|
737
|
-
case "date":
|
|
738
|
-
case "symbol":
|
|
739
|
-
case "undefined":
|
|
740
|
-
case "null":
|
|
741
|
-
case "any":
|
|
742
|
-
case "unknown":
|
|
743
|
-
case "never":
|
|
744
|
-
case "void":
|
|
745
|
-
case "literal":
|
|
746
|
-
case "enum":
|
|
747
|
-
case "nan":
|
|
748
|
-
case "file":
|
|
749
|
-
case "template_literal":
|
|
750
|
-
return !1;
|
|
751
|
-
case "array":
|
|
752
|
-
return I(t.element, n);
|
|
753
|
-
case "object": {
|
|
754
|
-
for (const o in t.shape)
|
|
755
|
-
if (I(t.shape[o], n))
|
|
756
|
-
return !0;
|
|
757
|
-
return !1;
|
|
758
|
-
}
|
|
759
|
-
case "union": {
|
|
760
|
-
for (const o of t.options)
|
|
761
|
-
if (I(o, n))
|
|
762
|
-
return !0;
|
|
763
|
-
return !1;
|
|
764
|
-
}
|
|
765
|
-
case "intersection":
|
|
766
|
-
return I(t.left, n) || I(t.right, n);
|
|
767
|
-
case "tuple": {
|
|
768
|
-
for (const o of t.items)
|
|
769
|
-
if (I(o, n))
|
|
770
|
-
return !0;
|
|
771
|
-
return !!(t.rest && I(t.rest, n));
|
|
772
|
-
}
|
|
773
|
-
case "record":
|
|
774
|
-
return I(t.keyType, n) || I(t.valueType, n);
|
|
775
|
-
case "map":
|
|
776
|
-
return I(t.keyType, n) || I(t.valueType, n);
|
|
777
|
-
case "set":
|
|
778
|
-
return I(t.valueType, n);
|
|
779
|
-
// inner types
|
|
780
|
-
case "promise":
|
|
781
|
-
case "optional":
|
|
782
|
-
case "nonoptional":
|
|
783
|
-
case "nullable":
|
|
784
|
-
case "readonly":
|
|
785
|
-
return I(t.innerType, n);
|
|
786
|
-
case "lazy":
|
|
787
|
-
return I(t.getter(), n);
|
|
788
|
-
case "default":
|
|
789
|
-
return I(t.innerType, n);
|
|
790
|
-
case "prefault":
|
|
791
|
-
return I(t.innerType, n);
|
|
792
|
-
case "custom":
|
|
793
|
-
return !1;
|
|
794
|
-
case "transform":
|
|
795
|
-
return !0;
|
|
796
|
-
case "pipe":
|
|
797
|
-
return I(t.in, n) || I(t.out, n);
|
|
798
|
-
case "success":
|
|
799
|
-
return !1;
|
|
800
|
-
case "catch":
|
|
801
|
-
return !1;
|
|
802
|
-
}
|
|
803
|
-
throw new Error(`Unknown schema type: ${t.type}`);
|
|
804
|
-
}
|
|
805
|
-
const W = (e) => e._def.typeName === "ZodObject", Le = (e) => e._def.typeName === "ZodDefault", Ce = (e) => e._def.typeName === "ZodNullable", Ke = (e) => e._def.typeName === "ZodRecord", We = (e) => e._def.typeName === "ZodArray", Oe = (e) => e._def.typeName === "ZodEffects", je = (e) => e._def.typeName === "ZodOptional", q = (e) => {
|
|
806
|
-
let r = e;
|
|
807
|
-
for (; Oe(r); )
|
|
808
|
-
r = r.innerType();
|
|
809
|
-
return je(r) && (r = r._def.innerType), r;
|
|
810
|
-
}, qe = (e) => {
|
|
811
|
-
let r = e;
|
|
812
|
-
for (; Oe(r); )
|
|
813
|
-
r = r.innerType();
|
|
814
|
-
return !!je(r);
|
|
815
|
-
};
|
|
816
|
-
function He(e) {
|
|
817
|
-
return Array.isArray(e) ? "array" : e === null ? "null" : typeof e;
|
|
818
|
-
}
|
|
819
|
-
function Qe(e, r) {
|
|
820
|
-
const n = He(e);
|
|
821
|
-
return r.type ? r.type === n || r.type === "integer" && n === "number" && Number.isInteger(e) : !0;
|
|
822
|
-
}
|
|
823
|
-
function F(e, r) {
|
|
824
|
-
if (e.anyOf && Array.isArray(e.anyOf)) {
|
|
825
|
-
if (r !== void 0) {
|
|
826
|
-
for (const s of e.anyOf)
|
|
827
|
-
if (Qe(r, s))
|
|
828
|
-
return F(s, r);
|
|
829
|
-
for (const s of e.anyOf) {
|
|
830
|
-
const i = s;
|
|
831
|
-
if (!i.type || i.type === "object")
|
|
832
|
-
return F(i, r);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
return F(e.anyOf[0], r);
|
|
836
|
-
}
|
|
837
|
-
if (e.type !== "object" || !e.properties)
|
|
838
|
-
switch (e.type) {
|
|
839
|
-
case "string":
|
|
840
|
-
return typeof r == "string" ? r : e.default;
|
|
841
|
-
case "number":
|
|
842
|
-
case "integer":
|
|
843
|
-
return typeof r == "number" ? r : e.default;
|
|
844
|
-
case "boolean":
|
|
845
|
-
return typeof r == "boolean" ? r : e.default;
|
|
846
|
-
case "null":
|
|
847
|
-
return r === null ? r : e.default;
|
|
848
|
-
case "array":
|
|
849
|
-
return Array.isArray(r) && e.items ? r.map((s) => F(e.items, s)) : e.default;
|
|
850
|
-
default:
|
|
851
|
-
return e.default;
|
|
852
|
-
}
|
|
853
|
-
const n = e.properties, t = r && typeof r == "object" && !Array.isArray(r) ? r : void 0, o = {};
|
|
854
|
-
for (const s in n) {
|
|
855
|
-
const i = t?.[s];
|
|
856
|
-
o[s] = F(n[s], i);
|
|
857
|
-
}
|
|
858
|
-
if (t && e.additionalProperties !== !1) {
|
|
859
|
-
const s = new Set(Object.keys(n));
|
|
860
|
-
for (const [i, f] of Object.entries(t))
|
|
861
|
-
s.has(i) || (o[i] = f);
|
|
862
|
-
}
|
|
863
|
-
return o;
|
|
864
|
-
}
|
|
865
|
-
const re = (e) => "_zod" in e;
|
|
866
|
-
function Q(e, r = {}) {
|
|
867
|
-
if (re(e)) {
|
|
868
|
-
const t = Be(e);
|
|
869
|
-
if (t.type !== "object" || !t.properties)
|
|
870
|
-
return r;
|
|
871
|
-
const o = Fe(e, r);
|
|
872
|
-
return F(t, o.success ? o.data : r);
|
|
73
|
+
)
|
|
74
|
+
)
|
|
75
|
+
} : t;
|
|
873
76
|
}
|
|
874
|
-
const
|
|
875
|
-
return
|
|
876
|
-
...
|
|
77
|
+
const u = C(e);
|
|
78
|
+
return K(u) ? {
|
|
79
|
+
...u._def.unknownKeys === "passthrough" ? t : {},
|
|
877
80
|
...Object.fromEntries(
|
|
878
|
-
("shape" in
|
|
879
|
-
([
|
|
880
|
-
const
|
|
881
|
-
let
|
|
882
|
-
if (
|
|
883
|
-
return [
|
|
884
|
-
if (
|
|
885
|
-
return [
|
|
886
|
-
if (
|
|
887
|
-
const
|
|
888
|
-
if (
|
|
889
|
-
return [
|
|
81
|
+
("shape" in u ? Object.entries(u.shape) : []).map(
|
|
82
|
+
([a, s]) => {
|
|
83
|
+
const l = t[a], f = xe(s);
|
|
84
|
+
let r = C(s), v;
|
|
85
|
+
if (De(r) && (v = r._def.defaultValue(), r = r._def.innerType), l === null && _e(r))
|
|
86
|
+
return [a, l];
|
|
87
|
+
if (l == null && f)
|
|
88
|
+
return [a, v];
|
|
89
|
+
if (r) {
|
|
90
|
+
const o = s.safeParse(l);
|
|
91
|
+
if (o.success)
|
|
92
|
+
return [a, o.data ?? v];
|
|
890
93
|
}
|
|
891
|
-
if (
|
|
892
|
-
const
|
|
893
|
-
if (
|
|
94
|
+
if (ze(r) && Array.isArray(l) && l.length) {
|
|
95
|
+
const o = C(r._def.type);
|
|
96
|
+
if (K(o))
|
|
894
97
|
return [
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
(
|
|
898
|
-
|
|
899
|
-
|
|
98
|
+
a,
|
|
99
|
+
l.map(
|
|
100
|
+
(d) => k(
|
|
101
|
+
o,
|
|
102
|
+
d && typeof d == "object" ? d : void 0
|
|
900
103
|
)
|
|
901
104
|
)
|
|
902
105
|
];
|
|
903
106
|
}
|
|
904
|
-
if (
|
|
905
|
-
const
|
|
906
|
-
if (
|
|
907
|
-
return [
|
|
107
|
+
if (Se(r) && l) {
|
|
108
|
+
const o = C(r._def.valueType);
|
|
109
|
+
if (K(o))
|
|
110
|
+
return [a, Object.keys(l).reduce((d, c) => (d[c] = k(o, l[c]), d), {})];
|
|
908
111
|
}
|
|
909
|
-
return
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
112
|
+
return K(r) ? [
|
|
113
|
+
a,
|
|
114
|
+
k(
|
|
115
|
+
r,
|
|
116
|
+
l && typeof l == "object" ? l : v
|
|
914
117
|
)
|
|
915
|
-
] : [
|
|
118
|
+
] : [a, v];
|
|
916
119
|
}
|
|
917
120
|
)
|
|
918
121
|
)
|
|
919
|
-
} :
|
|
122
|
+
} : t;
|
|
920
123
|
}
|
|
921
|
-
const
|
|
922
|
-
function
|
|
923
|
-
const
|
|
924
|
-
let
|
|
925
|
-
const
|
|
926
|
-
const
|
|
927
|
-
if (
|
|
928
|
-
const
|
|
929
|
-
return new
|
|
124
|
+
const Fe = (e, t) => X(e) ? ge(e, t) : e.safeParseAsync(t), Ae = (e, t) => X(e) ? ne(t) : t.format(), Ne = (e, t) => X(e) ? ne(new we(t)) : new je(t).format();
|
|
125
|
+
function $e(e, t, u, g, a) {
|
|
126
|
+
const s = B(), l = B(), f = O(() => l.value === S.invalid), r = B(), v = B(!1);
|
|
127
|
+
let o;
|
|
128
|
+
const d = (w) => {
|
|
129
|
+
const _ = k(e, w);
|
|
130
|
+
if (u?.class) {
|
|
131
|
+
const n = u.class;
|
|
132
|
+
return new n(_);
|
|
930
133
|
}
|
|
931
|
-
return
|
|
932
|
-
},
|
|
933
|
-
if (
|
|
134
|
+
return _;
|
|
135
|
+
}, c = async (w = r.value, _) => {
|
|
136
|
+
if (o = _?.fields, v.value)
|
|
934
137
|
return !0;
|
|
935
|
-
const
|
|
936
|
-
if (!
|
|
937
|
-
if (
|
|
938
|
-
return
|
|
939
|
-
const
|
|
940
|
-
(
|
|
138
|
+
const n = await Fe(e, w);
|
|
139
|
+
if (!n.success) {
|
|
140
|
+
if (l.value = S.invalid, !o?.size)
|
|
141
|
+
return s.value = Ae(e, n.error), !1;
|
|
142
|
+
const j = n.error.issues.filter(
|
|
143
|
+
(A) => o?.has(A.path.join("."))
|
|
941
144
|
);
|
|
942
|
-
return
|
|
145
|
+
return j.length ? (s.value = Ne(e, j), !1) : (s.value = void 0, !0);
|
|
943
146
|
}
|
|
944
|
-
return
|
|
945
|
-
},
|
|
946
|
-
|
|
947
|
-
},
|
|
948
|
-
|
|
949
|
-
},
|
|
950
|
-
|
|
147
|
+
return s.value = void 0, l.value = S.valid, r.value = d(n.data), !0;
|
|
148
|
+
}, D = () => {
|
|
149
|
+
s.value = void 0, l.value = void 0, o = void 0;
|
|
150
|
+
}, p = () => {
|
|
151
|
+
r.value = d(), D(), l.value = S.reset;
|
|
152
|
+
}, m = async (w) => v.value || !await c(void 0, w) ? !1 : (l.value = S.submitting, !0), { ignoreUpdates: y, stop: b } = he(
|
|
153
|
+
r,
|
|
951
154
|
() => {
|
|
952
|
-
|
|
155
|
+
l.value = S.updated;
|
|
953
156
|
},
|
|
954
157
|
{
|
|
955
158
|
deep: !0,
|
|
956
|
-
eventFilter:
|
|
159
|
+
eventFilter: be(u?.updateThrottle ?? 500)
|
|
957
160
|
}
|
|
958
|
-
),
|
|
161
|
+
), I = F(s), R = F(l), E = U({
|
|
959
162
|
name: "VvForm",
|
|
960
163
|
props: {
|
|
961
164
|
continuousValidation: {
|
|
@@ -968,7 +171,7 @@ function tt(e, r, n, u, t) {
|
|
|
968
171
|
},
|
|
969
172
|
readonly: {
|
|
970
173
|
type: Boolean,
|
|
971
|
-
default:
|
|
174
|
+
default: u?.readonly
|
|
972
175
|
},
|
|
973
176
|
tag: {
|
|
974
177
|
type: String,
|
|
@@ -1009,215 +212,152 @@ function tt(e, r, n, u, t) {
|
|
|
1009
212
|
"reset"
|
|
1010
213
|
],
|
|
1011
214
|
slots: Object,
|
|
1012
|
-
setup(
|
|
1013
|
-
return
|
|
1014
|
-
() =>
|
|
1015
|
-
(
|
|
1016
|
-
if (
|
|
1017
|
-
const
|
|
1018
|
-
if (JSON.stringify(
|
|
215
|
+
setup(w, { emit: _ }) {
|
|
216
|
+
return r.value = d(N(w.modelValue)), Z(
|
|
217
|
+
() => w.modelValue,
|
|
218
|
+
(n) => {
|
|
219
|
+
if (n) {
|
|
220
|
+
const j = me(n) ? N(n) : n;
|
|
221
|
+
if (JSON.stringify(j) === JSON.stringify(N(r.value)))
|
|
1019
222
|
return;
|
|
1020
|
-
|
|
223
|
+
r.value = typeof j?.clone == "function" ? j.clone() : JSON.parse(JSON.stringify(j));
|
|
1021
224
|
}
|
|
1022
225
|
},
|
|
1023
226
|
{ deep: !0 }
|
|
1024
|
-
),
|
|
1025
|
-
if (
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1028
|
-
|
|
227
|
+
), Z(l, async (n) => {
|
|
228
|
+
if (n === S.invalid) {
|
|
229
|
+
const j = N(s.value);
|
|
230
|
+
_("invalid", j), u?.onInvalid?.(
|
|
231
|
+
j
|
|
1029
232
|
);
|
|
1030
233
|
return;
|
|
1031
234
|
}
|
|
1032
|
-
if (
|
|
1033
|
-
const
|
|
1034
|
-
|
|
235
|
+
if (n === S.valid) {
|
|
236
|
+
const j = N(r.value);
|
|
237
|
+
_("valid", j), u?.onValid?.(j), _("update:modelValue", j), u?.onUpdate?.(j);
|
|
1035
238
|
return;
|
|
1036
239
|
}
|
|
1037
|
-
if (
|
|
1038
|
-
const
|
|
1039
|
-
|
|
240
|
+
if (n === S.submitting) {
|
|
241
|
+
const j = N(r.value);
|
|
242
|
+
_("submit", j), u?.onSubmit?.(j);
|
|
1040
243
|
return;
|
|
1041
244
|
}
|
|
1042
|
-
if (
|
|
1043
|
-
const
|
|
1044
|
-
|
|
245
|
+
if (n === S.reset) {
|
|
246
|
+
const j = N(r.value);
|
|
247
|
+
_("reset", j), u?.onReset?.(j);
|
|
1045
248
|
return;
|
|
1046
249
|
}
|
|
1047
|
-
if (
|
|
1048
|
-
if ((
|
|
1049
|
-
superRefine:
|
|
1050
|
-
fields:
|
|
1051
|
-
}), !
|
|
1052
|
-
const
|
|
1053
|
-
|
|
250
|
+
if (n === S.updated) {
|
|
251
|
+
if ((s.value || u?.continuousValidation || w.continuousValidation) && await c(void 0, {
|
|
252
|
+
superRefine: w.superRefine,
|
|
253
|
+
fields: o ?? new Set(w.validateFields)
|
|
254
|
+
}), !r.value || !w.modelValue || JSON.stringify(r.value) !== JSON.stringify(w.modelValue)) {
|
|
255
|
+
const j = N(r.value);
|
|
256
|
+
_("update:modelValue", j), u?.onUpdate?.(j);
|
|
1054
257
|
}
|
|
1055
|
-
|
|
258
|
+
l.value === S.updated && (l.value = S.unknown);
|
|
1056
259
|
}
|
|
1057
|
-
}),
|
|
1058
|
-
|
|
1059
|
-
}),
|
|
1060
|
-
() =>
|
|
1061
|
-
(
|
|
1062
|
-
|
|
260
|
+
}), H(() => {
|
|
261
|
+
w.readonly !== void 0 && (v.value = w.readonly);
|
|
262
|
+
}), Z(
|
|
263
|
+
() => w.readonly,
|
|
264
|
+
(n) => {
|
|
265
|
+
v.value = n;
|
|
1063
266
|
}
|
|
1064
|
-
),
|
|
1065
|
-
|
|
1066
|
-
}),
|
|
1067
|
-
clear:
|
|
1068
|
-
errors:
|
|
1069
|
-
formData:
|
|
1070
|
-
ignoreUpdates:
|
|
1071
|
-
invalid:
|
|
1072
|
-
readonly:
|
|
1073
|
-
reset:
|
|
1074
|
-
status:
|
|
1075
|
-
stopUpdatesWatch:
|
|
1076
|
-
submit:
|
|
1077
|
-
validate:
|
|
1078
|
-
wrappers:
|
|
267
|
+
), Z(v, (n) => {
|
|
268
|
+
n !== w.readonly && _("update:readonly", v.value);
|
|
269
|
+
}), Q(t, {
|
|
270
|
+
clear: D,
|
|
271
|
+
errors: I,
|
|
272
|
+
formData: r,
|
|
273
|
+
ignoreUpdates: y,
|
|
274
|
+
invalid: f,
|
|
275
|
+
readonly: v,
|
|
276
|
+
reset: p,
|
|
277
|
+
status: R,
|
|
278
|
+
stopUpdatesWatch: b,
|
|
279
|
+
submit: m,
|
|
280
|
+
validate: c,
|
|
281
|
+
wrappers: a
|
|
1079
282
|
}), {
|
|
1080
|
-
clear:
|
|
1081
|
-
errors:
|
|
1082
|
-
formData:
|
|
1083
|
-
ignoreUpdates:
|
|
1084
|
-
invalid:
|
|
1085
|
-
isReadonly:
|
|
1086
|
-
reset:
|
|
1087
|
-
status:
|
|
1088
|
-
stopUpdatesWatch:
|
|
1089
|
-
submit: () =>
|
|
1090
|
-
superRefine:
|
|
1091
|
-
fields: new Set(
|
|
283
|
+
clear: D,
|
|
284
|
+
errors: I,
|
|
285
|
+
formData: r,
|
|
286
|
+
ignoreUpdates: y,
|
|
287
|
+
invalid: f,
|
|
288
|
+
isReadonly: v,
|
|
289
|
+
reset: p,
|
|
290
|
+
status: R,
|
|
291
|
+
stopUpdatesWatch: b,
|
|
292
|
+
submit: () => m({
|
|
293
|
+
superRefine: w.superRefine,
|
|
294
|
+
fields: new Set(w.validateFields)
|
|
1092
295
|
}),
|
|
1093
|
-
validate:
|
|
1094
|
-
wrappers:
|
|
296
|
+
validate: c,
|
|
297
|
+
wrappers: a
|
|
1095
298
|
};
|
|
1096
299
|
},
|
|
1097
300
|
render() {
|
|
1098
|
-
const
|
|
1099
|
-
errors:
|
|
1100
|
-
formData:
|
|
1101
|
-
invalid:
|
|
1102
|
-
readonly:
|
|
1103
|
-
status:
|
|
1104
|
-
wrappers:
|
|
1105
|
-
clear:
|
|
1106
|
-
ignoreUpdates:
|
|
1107
|
-
reset:
|
|
1108
|
-
stopUpdatesWatch:
|
|
1109
|
-
submit:
|
|
1110
|
-
validate:
|
|
301
|
+
const w = () => this.$slots?.default?.({
|
|
302
|
+
errors: I.value,
|
|
303
|
+
formData: r.value,
|
|
304
|
+
invalid: f.value,
|
|
305
|
+
readonly: v.value,
|
|
306
|
+
status: R.value,
|
|
307
|
+
wrappers: a,
|
|
308
|
+
clear: D,
|
|
309
|
+
ignoreUpdates: y,
|
|
310
|
+
reset: p,
|
|
311
|
+
stopUpdatesWatch: b,
|
|
312
|
+
submit: m,
|
|
313
|
+
validate: c
|
|
1111
314
|
}) ?? this.$slots.default;
|
|
1112
|
-
return
|
|
315
|
+
return z(
|
|
1113
316
|
this.tag,
|
|
1114
317
|
{
|
|
1115
|
-
onSubmit:
|
|
1116
|
-
onReset:
|
|
318
|
+
onSubmit: re(this.submit, ["prevent"]),
|
|
319
|
+
onReset: re(this.reset, ["prevent"])
|
|
1117
320
|
},
|
|
1118
|
-
(this.template ??
|
|
1119
|
-
|
|
1120
|
-
|
|
321
|
+
(this.template ?? u?.template) && g ? [
|
|
322
|
+
z(
|
|
323
|
+
g,
|
|
1121
324
|
{
|
|
1122
|
-
schema: this.template ??
|
|
325
|
+
schema: this.template ?? u?.template
|
|
1123
326
|
},
|
|
1124
327
|
{
|
|
1125
|
-
default:
|
|
328
|
+
default: w
|
|
1126
329
|
}
|
|
1127
330
|
)
|
|
1128
331
|
] : {
|
|
1129
|
-
default:
|
|
332
|
+
default: w
|
|
1130
333
|
}
|
|
1131
334
|
);
|
|
1132
335
|
}
|
|
1133
336
|
});
|
|
1134
337
|
return {
|
|
1135
|
-
clear:
|
|
1136
|
-
errors:
|
|
1137
|
-
formData:
|
|
1138
|
-
ignoreUpdates:
|
|
1139
|
-
invalid:
|
|
1140
|
-
readonly:
|
|
1141
|
-
reset:
|
|
1142
|
-
status:
|
|
1143
|
-
wrappers:
|
|
1144
|
-
stopUpdatesWatch:
|
|
1145
|
-
submit:
|
|
1146
|
-
validate:
|
|
1147
|
-
VvForm:
|
|
338
|
+
clear: D,
|
|
339
|
+
errors: s,
|
|
340
|
+
formData: r,
|
|
341
|
+
ignoreUpdates: y,
|
|
342
|
+
invalid: f,
|
|
343
|
+
readonly: v,
|
|
344
|
+
reset: p,
|
|
345
|
+
status: l,
|
|
346
|
+
wrappers: a,
|
|
347
|
+
stopUpdatesWatch: b,
|
|
348
|
+
submit: m,
|
|
349
|
+
validate: c,
|
|
350
|
+
VvForm: E
|
|
1148
351
|
};
|
|
1149
352
|
}
|
|
1150
|
-
function
|
|
1151
|
-
return
|
|
1152
|
-
}
|
|
1153
|
-
function rt(e) {
|
|
1154
|
-
return !1;
|
|
1155
|
-
}
|
|
1156
|
-
function fe(e) {
|
|
1157
|
-
return e === null;
|
|
1158
|
-
}
|
|
1159
|
-
function _e(e) {
|
|
1160
|
-
return typeof e == "object";
|
|
1161
|
-
}
|
|
1162
|
-
function Se(e) {
|
|
1163
|
-
return typeof e == "string";
|
|
1164
|
-
}
|
|
1165
|
-
function X(e) {
|
|
1166
|
-
return typeof e > "u";
|
|
1167
|
-
}
|
|
1168
|
-
const nt = /^[0-9]+$/, st = ["__proto__", "prototype", "constructor"];
|
|
1169
|
-
function U(e, r, n) {
|
|
1170
|
-
const u = rt() ? n : void 0;
|
|
1171
|
-
if (!_e(e) || !Se(r))
|
|
1172
|
-
return u;
|
|
1173
|
-
const t = ke(r);
|
|
1174
|
-
if (t.length !== 0) {
|
|
1175
|
-
for (const o of t) {
|
|
1176
|
-
if (o === "*")
|
|
1177
|
-
continue;
|
|
1178
|
-
const s = function(i) {
|
|
1179
|
-
return i.map((f) => X(f) || fe(f) ? f : ne(f) ? s(f) : f[o]);
|
|
1180
|
-
};
|
|
1181
|
-
if (ne(e) && !nt.test(o) ? e = s(e) : e = e[o], X(e) || fe(e))
|
|
1182
|
-
break;
|
|
1183
|
-
}
|
|
1184
|
-
return X(e) ? u : e;
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
function ae(e, r, n) {
|
|
1188
|
-
if (!_e(e) || !Se(r))
|
|
1189
|
-
return;
|
|
1190
|
-
const u = ke(r);
|
|
1191
|
-
if (u.length === 0)
|
|
1192
|
-
return;
|
|
1193
|
-
const t = u.length;
|
|
1194
|
-
for (let o = 0; o < t; o++) {
|
|
1195
|
-
const s = u[o];
|
|
1196
|
-
if (o === t - 1) {
|
|
1197
|
-
e[s] = n;
|
|
1198
|
-
return;
|
|
1199
|
-
}
|
|
1200
|
-
if (s === "*" && ne(e)) {
|
|
1201
|
-
const i = u.slice(o + 1).join(".");
|
|
1202
|
-
for (const f of e)
|
|
1203
|
-
ae(f, i, n);
|
|
1204
|
-
return;
|
|
1205
|
-
}
|
|
1206
|
-
X(e[s]) && (e[s] = {}), e = e[s];
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
function ke(e) {
|
|
1210
|
-
const r = e.split(/[.]|(?:\[(\d|\*)\])/).filter((n) => !!n);
|
|
1211
|
-
return r.some((n) => st.indexOf(n) !== -1) ? [] : r;
|
|
1212
|
-
}
|
|
1213
|
-
function at(e, r, n, u) {
|
|
1214
|
-
return C({
|
|
353
|
+
function Ge(e, t, u, g) {
|
|
354
|
+
return U({
|
|
1215
355
|
name: "VvFormField",
|
|
1216
356
|
props: {
|
|
1217
357
|
type: {
|
|
1218
358
|
type: String,
|
|
1219
|
-
validator: (
|
|
1220
|
-
default:
|
|
359
|
+
validator: (a) => Object.values(V).includes(a),
|
|
360
|
+
default: V.custom
|
|
1221
361
|
},
|
|
1222
362
|
is: {
|
|
1223
363
|
type: [Object, String],
|
|
@@ -1264,175 +404,175 @@ function at(e, r, n, u) {
|
|
|
1264
404
|
"type"
|
|
1265
405
|
],
|
|
1266
406
|
slots: Object,
|
|
1267
|
-
setup(
|
|
1268
|
-
const { props:
|
|
1269
|
-
|
|
1270
|
-
const
|
|
407
|
+
setup(a, { slots: s, emit: l }) {
|
|
408
|
+
const { props: f, name: r } = Y(a), v = ae(), o = G(t, void 0);
|
|
409
|
+
o && o.fields.value.set(v, a.name);
|
|
410
|
+
const d = G(e), c = O({
|
|
1271
411
|
get() {
|
|
1272
|
-
if (
|
|
1273
|
-
return
|
|
1274
|
-
new Object(
|
|
1275
|
-
String(
|
|
412
|
+
if (d?.formData)
|
|
413
|
+
return P(
|
|
414
|
+
new Object(d.formData.value),
|
|
415
|
+
String(a.name)
|
|
1276
416
|
);
|
|
1277
417
|
},
|
|
1278
|
-
set(
|
|
1279
|
-
|
|
1280
|
-
new Object(
|
|
1281
|
-
String(
|
|
1282
|
-
|
|
1283
|
-
),
|
|
1284
|
-
newValue:
|
|
1285
|
-
formData:
|
|
418
|
+
set(n) {
|
|
419
|
+
d?.formData && (oe(
|
|
420
|
+
new Object(d.formData.value),
|
|
421
|
+
String(a.name),
|
|
422
|
+
n
|
|
423
|
+
), l("update:modelValue", {
|
|
424
|
+
newValue: c.value,
|
|
425
|
+
formData: d?.formData
|
|
1286
426
|
}));
|
|
1287
427
|
}
|
|
1288
428
|
});
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
}),
|
|
1292
|
-
|
|
429
|
+
H(() => {
|
|
430
|
+
c.value === void 0 && a.defaultValue !== void 0 && (c.value = a.defaultValue);
|
|
431
|
+
}), L(() => {
|
|
432
|
+
o && o.fields.value.delete(v);
|
|
1293
433
|
});
|
|
1294
|
-
const
|
|
1295
|
-
if (
|
|
1296
|
-
return
|
|
1297
|
-
}),
|
|
1298
|
-
if (
|
|
1299
|
-
|
|
1300
|
-
String(
|
|
1301
|
-
|
|
434
|
+
const D = O(() => {
|
|
435
|
+
if (d?.errors.value)
|
|
436
|
+
return P(d.errors.value, String(a.name));
|
|
437
|
+
}), p = O(() => D.value?._errors), m = O(() => D.value !== void 0), y = Z(m, (n) => {
|
|
438
|
+
if (n) {
|
|
439
|
+
l("invalid", D.value), o && o.errors.value.set(
|
|
440
|
+
String(a.name),
|
|
441
|
+
D.value
|
|
1302
442
|
);
|
|
1303
443
|
return;
|
|
1304
444
|
}
|
|
1305
|
-
|
|
1306
|
-
|
|
445
|
+
l("valid", c.value), o && o.errors.value.delete(
|
|
446
|
+
a.name
|
|
1307
447
|
);
|
|
1308
|
-
}),
|
|
1309
|
-
() =>
|
|
448
|
+
}), b = Z(
|
|
449
|
+
() => d?.formData,
|
|
1310
450
|
() => {
|
|
1311
|
-
|
|
451
|
+
l("update:formData", d?.formData);
|
|
1312
452
|
},
|
|
1313
453
|
{ deep: !0 }
|
|
1314
454
|
);
|
|
1315
|
-
|
|
1316
|
-
|
|
455
|
+
L(() => {
|
|
456
|
+
y(), b();
|
|
1317
457
|
});
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1320
|
-
},
|
|
1321
|
-
let
|
|
1322
|
-
return typeof
|
|
1323
|
-
(
|
|
458
|
+
const I = (n) => {
|
|
459
|
+
n instanceof InputEvent && (n = n.target.value), c.value = n;
|
|
460
|
+
}, R = O(() => {
|
|
461
|
+
let n = f.value;
|
|
462
|
+
return typeof n == "function" && (n = n(d?.formData)), Object.keys(n).reduce(
|
|
463
|
+
(j, A) => (j[A] = W(n[A]), j),
|
|
1324
464
|
{}
|
|
1325
465
|
);
|
|
1326
|
-
}),
|
|
1327
|
-
...
|
|
1328
|
-
name:
|
|
1329
|
-
invalid:
|
|
1330
|
-
valid:
|
|
1331
|
-
type: ((
|
|
466
|
+
}), E = O(() => d?.readonly.value || o?.readonly.value ? !0 : R.value.readonly ?? a.readonly), w = O(() => ({
|
|
467
|
+
...R.value,
|
|
468
|
+
name: R.value.name ?? a.name,
|
|
469
|
+
invalid: m.value,
|
|
470
|
+
valid: a.showValid ? !!(!m.value && c.value) : void 0,
|
|
471
|
+
type: ((n) => {
|
|
1332
472
|
if ([
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
].includes(
|
|
1347
|
-
return
|
|
1348
|
-
})(
|
|
1349
|
-
invalidLabel:
|
|
1350
|
-
modelValue:
|
|
1351
|
-
readonly:
|
|
1352
|
-
"onUpdate:modelValue":
|
|
473
|
+
V.color,
|
|
474
|
+
V.date,
|
|
475
|
+
V.datetimeLocal,
|
|
476
|
+
V.email,
|
|
477
|
+
V.month,
|
|
478
|
+
V.number,
|
|
479
|
+
V.password,
|
|
480
|
+
V.search,
|
|
481
|
+
V.tel,
|
|
482
|
+
V.text,
|
|
483
|
+
V.time,
|
|
484
|
+
V.url,
|
|
485
|
+
V.week
|
|
486
|
+
].includes(n))
|
|
487
|
+
return n;
|
|
488
|
+
})(a.type),
|
|
489
|
+
invalidLabel: p.value,
|
|
490
|
+
modelValue: c.value,
|
|
491
|
+
readonly: E.value,
|
|
492
|
+
"onUpdate:modelValue": I
|
|
1353
493
|
}));
|
|
1354
|
-
return
|
|
1355
|
-
name:
|
|
1356
|
-
errors:
|
|
1357
|
-
}), { component:
|
|
1358
|
-
if (
|
|
494
|
+
return Q(u, {
|
|
495
|
+
name: F(r),
|
|
496
|
+
errors: F(D)
|
|
497
|
+
}), { component: O(() => {
|
|
498
|
+
if (a.type === V.custom)
|
|
1359
499
|
return {
|
|
1360
500
|
render() {
|
|
1361
|
-
return
|
|
1362
|
-
errors:
|
|
1363
|
-
formData:
|
|
1364
|
-
formErrors:
|
|
1365
|
-
invalid:
|
|
1366
|
-
invalidLabel:
|
|
1367
|
-
modelValue:
|
|
1368
|
-
readonly:
|
|
1369
|
-
onUpdate:
|
|
1370
|
-
submit:
|
|
1371
|
-
validate:
|
|
1372
|
-
}) ??
|
|
501
|
+
return s.default?.({
|
|
502
|
+
errors: D.value,
|
|
503
|
+
formData: d?.formData.value,
|
|
504
|
+
formErrors: d?.errors.value,
|
|
505
|
+
invalid: m.value,
|
|
506
|
+
invalidLabel: p.value,
|
|
507
|
+
modelValue: c.value,
|
|
508
|
+
readonly: E.value,
|
|
509
|
+
onUpdate: I,
|
|
510
|
+
submit: d?.submit,
|
|
511
|
+
validate: d?.validate
|
|
512
|
+
}) ?? s.default;
|
|
1373
513
|
}
|
|
1374
514
|
};
|
|
1375
|
-
if (!(
|
|
1376
|
-
let
|
|
1377
|
-
switch (
|
|
1378
|
-
case
|
|
1379
|
-
|
|
515
|
+
if (!(g?.lazyLoad ?? a.lazyLoad)) {
|
|
516
|
+
let n;
|
|
517
|
+
switch (a.type) {
|
|
518
|
+
case V.select:
|
|
519
|
+
n = $("VvSelect");
|
|
1380
520
|
break;
|
|
1381
|
-
case
|
|
1382
|
-
|
|
521
|
+
case V.checkbox:
|
|
522
|
+
n = $("VvCheckbox");
|
|
1383
523
|
break;
|
|
1384
|
-
case
|
|
1385
|
-
|
|
524
|
+
case V.radio:
|
|
525
|
+
n = $("VvRadio");
|
|
1386
526
|
break;
|
|
1387
|
-
case
|
|
1388
|
-
|
|
527
|
+
case V.textarea:
|
|
528
|
+
n = $("VvTextarea");
|
|
1389
529
|
break;
|
|
1390
|
-
case
|
|
1391
|
-
|
|
530
|
+
case V.radioGroup:
|
|
531
|
+
n = $("VvRadioGroup");
|
|
1392
532
|
break;
|
|
1393
|
-
case
|
|
1394
|
-
|
|
533
|
+
case V.checkboxGroup:
|
|
534
|
+
n = $("VvCheckboxGroup");
|
|
1395
535
|
break;
|
|
1396
|
-
case
|
|
1397
|
-
|
|
536
|
+
case V.combobox:
|
|
537
|
+
n = $("VvCombobox");
|
|
1398
538
|
break;
|
|
1399
539
|
default:
|
|
1400
|
-
|
|
540
|
+
n = $("VvInputText");
|
|
1401
541
|
}
|
|
1402
|
-
if (typeof
|
|
1403
|
-
return
|
|
542
|
+
if (typeof n != "string")
|
|
543
|
+
return n;
|
|
1404
544
|
console.warn(
|
|
1405
|
-
`[@volverjs/form-vue]: ${
|
|
545
|
+
`[@volverjs/form-vue]: ${n} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
|
|
1406
546
|
);
|
|
1407
547
|
}
|
|
1408
|
-
return
|
|
1409
|
-
switch (
|
|
1410
|
-
case
|
|
548
|
+
return pe(async () => {
|
|
549
|
+
switch (g?.sideEffects && await Promise.resolve(g.sideEffects(a.type)), a.type) {
|
|
550
|
+
case V.textarea:
|
|
1411
551
|
return import("@volverjs/ui-vue/vv-textarea");
|
|
1412
|
-
case
|
|
552
|
+
case V.radio:
|
|
1413
553
|
return import("@volverjs/ui-vue/vv-radio");
|
|
1414
|
-
case
|
|
554
|
+
case V.radioGroup:
|
|
1415
555
|
return import("@volverjs/ui-vue/vv-radio-group");
|
|
1416
|
-
case
|
|
556
|
+
case V.checkbox:
|
|
1417
557
|
return import("@volverjs/ui-vue/vv-checkbox");
|
|
1418
|
-
case
|
|
558
|
+
case V.checkboxGroup:
|
|
1419
559
|
return import("@volverjs/ui-vue/vv-checkbox-group");
|
|
1420
|
-
case
|
|
560
|
+
case V.select:
|
|
1421
561
|
return import("@volverjs/ui-vue/vv-select");
|
|
1422
|
-
case
|
|
562
|
+
case V.combobox:
|
|
1423
563
|
return import("@volverjs/ui-vue/vv-combobox");
|
|
1424
564
|
}
|
|
1425
565
|
return import("@volverjs/ui-vue/vv-input-text");
|
|
1426
566
|
});
|
|
1427
|
-
}), hasProps:
|
|
567
|
+
}), hasProps: w, invalid: m };
|
|
1428
568
|
},
|
|
1429
569
|
render() {
|
|
1430
|
-
return this.is ?
|
|
570
|
+
return this.is ? z(this.is, this.hasProps, this.$slots) : this.type === V.custom ? z(this.component, null, this.$slots) : z(this.component, this.hasProps, this.$slots);
|
|
1431
571
|
}
|
|
1432
572
|
});
|
|
1433
573
|
}
|
|
1434
|
-
function
|
|
1435
|
-
return
|
|
574
|
+
function ke(e, t, u) {
|
|
575
|
+
return U({
|
|
1436
576
|
name: "VvFormFieldsGroup",
|
|
1437
577
|
props: {
|
|
1438
578
|
is: {
|
|
@@ -1475,151 +615,151 @@ function ot(e, r, n) {
|
|
|
1475
615
|
"is"
|
|
1476
616
|
],
|
|
1477
617
|
slots: Object,
|
|
1478
|
-
setup(
|
|
1479
|
-
const { props:
|
|
1480
|
-
|
|
1481
|
-
|
|
618
|
+
setup(g, { slots: a, emit: s }) {
|
|
619
|
+
const { props: l, names: f, defaultValues: r } = Y(g), v = ae(), o = O(() => Array.isArray(f.value) ? f.value : Object.values(f.value)), d = O(() => Array.isArray(f.value) ? f.value : Object.keys(f.value)), c = O(() => Array.isArray(f.value) ? f.value.reduce((i, h) => (i[String(h)] = h, i), {}) : f.value), D = O(() => Object.keys(c.value).reduce((i, h) => (i[String(c.value[h])] = h, i), {})), p = G(t, void 0);
|
|
620
|
+
p && o.value.forEach((i) => {
|
|
621
|
+
p.fields.value.set(`${v}-${i}`, i);
|
|
1482
622
|
});
|
|
1483
|
-
const
|
|
623
|
+
const m = G(e), y = O({
|
|
1484
624
|
get() {
|
|
1485
|
-
return
|
|
1486
|
-
new Object(
|
|
1487
|
-
|
|
1488
|
-
),
|
|
625
|
+
return m?.formData ? d.value.reduce((i, h) => (i[h] = P(
|
|
626
|
+
new Object(m.formData.value),
|
|
627
|
+
c.value[h]
|
|
628
|
+
), i), {}) : {};
|
|
1489
629
|
},
|
|
1490
|
-
set(
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
new Object(
|
|
1494
|
-
|
|
1495
|
-
|
|
630
|
+
set(i) {
|
|
631
|
+
m?.formData && (d.value.forEach((h) => {
|
|
632
|
+
oe(
|
|
633
|
+
new Object(m.formData.value),
|
|
634
|
+
c.value[h],
|
|
635
|
+
i?.[h]
|
|
1496
636
|
);
|
|
1497
|
-
}),
|
|
1498
|
-
newValue:
|
|
1499
|
-
formData:
|
|
637
|
+
}), s("update:modelValue", {
|
|
638
|
+
newValue: y.value,
|
|
639
|
+
formData: m?.formData
|
|
1500
640
|
}));
|
|
1501
641
|
}
|
|
1502
642
|
});
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
...
|
|
1507
|
-
[
|
|
643
|
+
H(() => {
|
|
644
|
+
r.value && o.value.forEach((i) => {
|
|
645
|
+
r.value?.[i] !== void 0 && y.value[i] === void 0 && (y.value = {
|
|
646
|
+
...y.value,
|
|
647
|
+
[i]: r.value?.[i]
|
|
1508
648
|
});
|
|
1509
649
|
});
|
|
1510
|
-
}),
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
`${
|
|
650
|
+
}), L(() => {
|
|
651
|
+
p && o.value.forEach((i) => {
|
|
652
|
+
p.fields.value.delete(
|
|
653
|
+
`${v}-${i}`
|
|
1514
654
|
);
|
|
1515
655
|
});
|
|
1516
656
|
});
|
|
1517
|
-
const
|
|
1518
|
-
if (!
|
|
657
|
+
const b = O(() => {
|
|
658
|
+
if (!m?.errors.value)
|
|
1519
659
|
return;
|
|
1520
|
-
const
|
|
1521
|
-
if (!
|
|
1522
|
-
return
|
|
1523
|
-
const
|
|
1524
|
-
return
|
|
660
|
+
const i = o.value.reduce((h, x) => {
|
|
661
|
+
if (!m.errors.value)
|
|
662
|
+
return h;
|
|
663
|
+
const te = P(m.errors.value, String(x));
|
|
664
|
+
return te === void 0 || (h[String(x)] = te), h;
|
|
1525
665
|
}, {});
|
|
1526
|
-
if (Object.keys(
|
|
1527
|
-
return
|
|
1528
|
-
}),
|
|
1529
|
-
if (!
|
|
666
|
+
if (Object.keys(i).length !== 0)
|
|
667
|
+
return i;
|
|
668
|
+
}), I = O(() => {
|
|
669
|
+
if (!b.value)
|
|
1530
670
|
return;
|
|
1531
|
-
const
|
|
1532
|
-
if (Object.keys(
|
|
1533
|
-
return
|
|
1534
|
-
}),
|
|
1535
|
-
if (
|
|
1536
|
-
|
|
1537
|
-
if (!
|
|
1538
|
-
|
|
1539
|
-
|
|
671
|
+
const i = Object.keys(b.value).reduce((h, x) => (b.value?.[x] && (h[D.value[x]] = b.value[x]._errors), h), {});
|
|
672
|
+
if (Object.keys(i).length !== 0)
|
|
673
|
+
return i;
|
|
674
|
+
}), R = O(() => b.value !== void 0), E = O(() => d.value.reduce((i, h) => (i[h] = !!b.value?.[D.value[h]], i), {})), w = Z(R, () => {
|
|
675
|
+
if (R.value) {
|
|
676
|
+
s("invalid", b.value), p && o.value.forEach((i) => {
|
|
677
|
+
if (!b.value?.[i]) {
|
|
678
|
+
p.errors.value.delete(
|
|
679
|
+
i
|
|
1540
680
|
);
|
|
1541
681
|
return;
|
|
1542
682
|
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
683
|
+
p.errors.value.set(
|
|
684
|
+
i,
|
|
685
|
+
b.value?.[i]
|
|
1546
686
|
);
|
|
1547
687
|
});
|
|
1548
688
|
return;
|
|
1549
689
|
}
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
690
|
+
s("valid", y.value), p && o.value.forEach((i) => {
|
|
691
|
+
p.errors.value.delete(
|
|
692
|
+
i
|
|
1553
693
|
);
|
|
1554
694
|
});
|
|
1555
|
-
}),
|
|
1556
|
-
() =>
|
|
695
|
+
}), _ = Z(
|
|
696
|
+
() => m?.formData,
|
|
1557
697
|
() => {
|
|
1558
|
-
|
|
698
|
+
s("update:formData", m?.formData);
|
|
1559
699
|
},
|
|
1560
700
|
{ deep: !0 }
|
|
1561
701
|
);
|
|
1562
|
-
|
|
1563
|
-
|
|
702
|
+
L(() => {
|
|
703
|
+
w(), _();
|
|
1564
704
|
});
|
|
1565
|
-
const
|
|
1566
|
-
|
|
1567
|
-
},
|
|
1568
|
-
|
|
1569
|
-
...
|
|
1570
|
-
[
|
|
705
|
+
const n = (i) => {
|
|
706
|
+
y.value = i;
|
|
707
|
+
}, j = (i, h) => {
|
|
708
|
+
h instanceof InputEvent && (h = h.target.value), d.value.includes(i) && (y.value = {
|
|
709
|
+
...y.value,
|
|
710
|
+
[i]: h
|
|
1571
711
|
});
|
|
1572
|
-
},
|
|
1573
|
-
let
|
|
1574
|
-
return typeof
|
|
1575
|
-
(
|
|
712
|
+
}, A = O(() => {
|
|
713
|
+
let i = l.value;
|
|
714
|
+
return typeof i == "function" && (i = i(m?.formData)), Object.keys(i).reduce(
|
|
715
|
+
(h, x) => (h[x] = W(i[x]), h),
|
|
1576
716
|
{}
|
|
1577
717
|
);
|
|
1578
|
-
}),
|
|
1579
|
-
|
|
1580
|
-
},
|
|
1581
|
-
"onUpdate:modelValue":
|
|
1582
|
-
})),
|
|
1583
|
-
...
|
|
1584
|
-
...
|
|
1585
|
-
...
|
|
1586
|
-
modelValue:
|
|
1587
|
-
names:
|
|
1588
|
-
invalid:
|
|
1589
|
-
invalids:
|
|
1590
|
-
valid:
|
|
1591
|
-
invalidLabels:
|
|
1592
|
-
readonly:
|
|
718
|
+
}), ee = O(() => m?.readonly.value ? !0 : A.value.readonly ?? g.readonly), ve = O(() => d.value.reduce((i, h) => (i[`onUpdate:${h}`] = (x) => {
|
|
719
|
+
j(h, x);
|
|
720
|
+
}, i), {
|
|
721
|
+
"onUpdate:modelValue": n
|
|
722
|
+
})), ce = O(() => ({
|
|
723
|
+
...ve.value,
|
|
724
|
+
...A.value,
|
|
725
|
+
...y.value,
|
|
726
|
+
modelValue: y.value,
|
|
727
|
+
names: A.value.name ?? o.value,
|
|
728
|
+
invalid: R.value,
|
|
729
|
+
invalids: E.value,
|
|
730
|
+
valid: g.showValid ? !!(!R.value && y.value) : void 0,
|
|
731
|
+
invalidLabels: I.value,
|
|
732
|
+
readonly: ee.value
|
|
1593
733
|
}));
|
|
1594
|
-
return
|
|
1595
|
-
names:
|
|
1596
|
-
errors:
|
|
1597
|
-
}), { component:
|
|
734
|
+
return Q(u, {
|
|
735
|
+
names: F(f),
|
|
736
|
+
errors: F(b)
|
|
737
|
+
}), { component: O(() => ({
|
|
1598
738
|
render() {
|
|
1599
|
-
return
|
|
1600
|
-
errors:
|
|
1601
|
-
formData:
|
|
1602
|
-
formErrors:
|
|
1603
|
-
invalid:
|
|
1604
|
-
invalids:
|
|
1605
|
-
invalidLabels:
|
|
1606
|
-
modelValue:
|
|
1607
|
-
onUpdate:
|
|
1608
|
-
onUpdateField:
|
|
1609
|
-
readonly:
|
|
1610
|
-
submit:
|
|
1611
|
-
validate:
|
|
1612
|
-
}) ??
|
|
739
|
+
return a.default?.({
|
|
740
|
+
errors: b.value,
|
|
741
|
+
formData: m?.formData.value,
|
|
742
|
+
formErrors: m?.errors.value,
|
|
743
|
+
invalid: R.value,
|
|
744
|
+
invalids: E.value,
|
|
745
|
+
invalidLabels: I.value,
|
|
746
|
+
modelValue: y.value,
|
|
747
|
+
onUpdate: n,
|
|
748
|
+
onUpdateField: j,
|
|
749
|
+
readonly: ee.value,
|
|
750
|
+
submit: m?.submit,
|
|
751
|
+
validate: m?.validate
|
|
752
|
+
}) ?? a.default;
|
|
1613
753
|
}
|
|
1614
|
-
})), hasProps:
|
|
754
|
+
})), hasProps: ce, invalid: R };
|
|
1615
755
|
},
|
|
1616
756
|
render() {
|
|
1617
|
-
return this.is ?
|
|
757
|
+
return this.is ? z(this.is, this.hasProps, this.$slots) : z(this.component, null, this.$slots);
|
|
1618
758
|
}
|
|
1619
759
|
});
|
|
1620
760
|
}
|
|
1621
|
-
function
|
|
1622
|
-
return
|
|
761
|
+
function Be(e, t) {
|
|
762
|
+
return U({
|
|
1623
763
|
name: "VvFormWrapper",
|
|
1624
764
|
props: {
|
|
1625
765
|
name: {
|
|
@@ -1651,75 +791,75 @@ function it(e, r) {
|
|
|
1651
791
|
"validateWrapper"
|
|
1652
792
|
],
|
|
1653
793
|
slots: Object,
|
|
1654
|
-
setup(
|
|
1655
|
-
const
|
|
1656
|
-
|
|
1657
|
-
if (
|
|
1658
|
-
|
|
794
|
+
setup(u, { emit: g }) {
|
|
795
|
+
const a = G(e), s = G(t, void 0), l = B(/* @__PURE__ */ new Map()), f = B(/* @__PURE__ */ new Map()), { name: r } = Y(u), v = O(() => a?.invalid.value ? f.value.size > 0 : !1);
|
|
796
|
+
Z(v, (p) => {
|
|
797
|
+
if (p) {
|
|
798
|
+
g("invalid");
|
|
1659
799
|
return;
|
|
1660
800
|
}
|
|
1661
|
-
|
|
801
|
+
g("valid");
|
|
1662
802
|
});
|
|
1663
|
-
const
|
|
1664
|
-
name:
|
|
1665
|
-
errors:
|
|
1666
|
-
invalid:
|
|
1667
|
-
readonly:
|
|
1668
|
-
fields:
|
|
803
|
+
const o = O(() => a?.readonly.value || u.readonly), d = {
|
|
804
|
+
name: F(r),
|
|
805
|
+
errors: f,
|
|
806
|
+
invalid: F(v),
|
|
807
|
+
readonly: F(o),
|
|
808
|
+
fields: l
|
|
1669
809
|
};
|
|
1670
|
-
|
|
1671
|
-
const
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
(
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
}),
|
|
1678
|
-
|
|
810
|
+
Q(t, d);
|
|
811
|
+
const c = O(() => new Map(l.value));
|
|
812
|
+
Z(
|
|
813
|
+
c,
|
|
814
|
+
(p, m) => {
|
|
815
|
+
s?.fields && (m.forEach((y, b) => {
|
|
816
|
+
p.has(b) || s?.fields.value.delete(b);
|
|
817
|
+
}), p.forEach((y, b) => {
|
|
818
|
+
s?.fields.value.has(b) || s?.fields.value.set(b, y);
|
|
1679
819
|
}));
|
|
1680
820
|
},
|
|
1681
821
|
{ deep: !0 }
|
|
1682
|
-
),
|
|
1683
|
-
|
|
1684
|
-
(
|
|
1685
|
-
|
|
1686
|
-
if (
|
|
1687
|
-
const
|
|
1688
|
-
|
|
822
|
+
), Z(
|
|
823
|
+
f,
|
|
824
|
+
(p) => {
|
|
825
|
+
s?.errors && l.value.forEach((m) => {
|
|
826
|
+
if (p.has(m) || s.errors.value.delete(m), p.has(m)) {
|
|
827
|
+
const y = p.get(m);
|
|
828
|
+
y && s.errors.value.set(m, y);
|
|
1689
829
|
}
|
|
1690
830
|
});
|
|
1691
831
|
},
|
|
1692
832
|
{ deep: !0 }
|
|
1693
|
-
),
|
|
1694
|
-
if (!
|
|
833
|
+
), H(() => {
|
|
834
|
+
if (!a?.wrappers || !r.value) {
|
|
1695
835
|
console.warn("[@volverjs/form-vue]: Invalid wrapper registration state");
|
|
1696
836
|
return;
|
|
1697
837
|
}
|
|
1698
|
-
if (
|
|
1699
|
-
console.warn(`[@volverjs/form-vue]: wrapper name "${
|
|
838
|
+
if (a.wrappers.has(r.value)) {
|
|
839
|
+
console.warn(`[@volverjs/form-vue]: wrapper name "${r.value}" is already used`);
|
|
1700
840
|
return;
|
|
1701
841
|
}
|
|
1702
|
-
|
|
1703
|
-
}),
|
|
1704
|
-
|
|
842
|
+
a.wrappers.set(r.value, d);
|
|
843
|
+
}), L(() => {
|
|
844
|
+
a?.wrappers && r.value && a.wrappers.delete(r.value);
|
|
1705
845
|
});
|
|
1706
|
-
const
|
|
846
|
+
const D = () => a?.validate(void 0, { fields: new Set(l.value.values()) }) ?? Promise.resolve(!0);
|
|
1707
847
|
return {
|
|
1708
|
-
errors:
|
|
1709
|
-
fields:
|
|
1710
|
-
fieldsErrors:
|
|
1711
|
-
formData:
|
|
1712
|
-
invalid:
|
|
1713
|
-
readonly:
|
|
1714
|
-
clear:
|
|
1715
|
-
reset:
|
|
1716
|
-
submit:
|
|
1717
|
-
validate:
|
|
1718
|
-
validateWrapper:
|
|
848
|
+
errors: a?.errors,
|
|
849
|
+
fields: l,
|
|
850
|
+
fieldsErrors: f,
|
|
851
|
+
formData: a?.formData,
|
|
852
|
+
invalid: v,
|
|
853
|
+
readonly: o,
|
|
854
|
+
clear: a?.clear,
|
|
855
|
+
reset: a?.reset,
|
|
856
|
+
submit: a?.submit,
|
|
857
|
+
validate: a?.validate,
|
|
858
|
+
validateWrapper: D
|
|
1719
859
|
};
|
|
1720
860
|
},
|
|
1721
861
|
render() {
|
|
1722
|
-
const
|
|
862
|
+
const u = () => this.$slots.default?.({
|
|
1723
863
|
errors: this.errors,
|
|
1724
864
|
fieldsErrors: this.fieldsErrors,
|
|
1725
865
|
formData: this.formData,
|
|
@@ -1731,14 +871,14 @@ function it(e, r) {
|
|
|
1731
871
|
validate: this.validate,
|
|
1732
872
|
validateWrapper: this.validateWrapper
|
|
1733
873
|
});
|
|
1734
|
-
return this.tag ?
|
|
1735
|
-
default:
|
|
1736
|
-
}) :
|
|
874
|
+
return this.tag ? z(this.tag, null, {
|
|
875
|
+
default: u
|
|
876
|
+
}) : u();
|
|
1737
877
|
}
|
|
1738
878
|
});
|
|
1739
879
|
}
|
|
1740
|
-
function
|
|
1741
|
-
const
|
|
880
|
+
function We(e, t) {
|
|
881
|
+
const u = U({
|
|
1742
882
|
name: "VvFormTemplate",
|
|
1743
883
|
props: {
|
|
1744
884
|
schema: {
|
|
@@ -1751,174 +891,174 @@ function ut(e, r) {
|
|
|
1751
891
|
}
|
|
1752
892
|
},
|
|
1753
893
|
slots: Object,
|
|
1754
|
-
setup(
|
|
1755
|
-
const
|
|
1756
|
-
if (
|
|
894
|
+
setup(g, { slots: a }) {
|
|
895
|
+
const s = G(e);
|
|
896
|
+
if (s?.formData)
|
|
1757
897
|
return () => {
|
|
1758
|
-
const
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
) :
|
|
1762
|
-
let
|
|
1763
|
-
const
|
|
1764
|
-
const
|
|
1765
|
-
vvIs:
|
|
1766
|
-
vvName:
|
|
1767
|
-
vvSlots:
|
|
1768
|
-
vvChildren:
|
|
1769
|
-
vvIf:
|
|
1770
|
-
vvElseIf:
|
|
1771
|
-
vvType:
|
|
1772
|
-
vvDefaultValue:
|
|
1773
|
-
vvShowValid:
|
|
1774
|
-
vvContent:
|
|
1775
|
-
...
|
|
1776
|
-
} =
|
|
1777
|
-
if (
|
|
1778
|
-
if (typeof
|
|
1779
|
-
new Object(
|
|
1780
|
-
p
|
|
1781
|
-
) : typeof p == "function" ? i = M(p(o)) : i = M(p), !i)
|
|
1782
|
-
return m;
|
|
1783
|
-
} else if (y !== void 0 && i !== void 0) {
|
|
1784
|
-
if (i || (typeof y == "string" ? i = !!U(
|
|
1785
|
-
new Object(o.formData.value),
|
|
898
|
+
const l = typeof g.schema == "function" ? g.schema(
|
|
899
|
+
s,
|
|
900
|
+
g.scope
|
|
901
|
+
) : g.schema;
|
|
902
|
+
let f;
|
|
903
|
+
const r = l.reduce((v, o) => {
|
|
904
|
+
const d = typeof o == "function" ? o(s, g.scope) : o, {
|
|
905
|
+
vvIs: c,
|
|
906
|
+
vvName: D,
|
|
907
|
+
vvSlots: p,
|
|
908
|
+
vvChildren: m,
|
|
909
|
+
vvIf: y,
|
|
910
|
+
vvElseIf: b,
|
|
911
|
+
vvType: I,
|
|
912
|
+
vvDefaultValue: R,
|
|
913
|
+
vvShowValid: E,
|
|
914
|
+
vvContent: w,
|
|
915
|
+
..._
|
|
916
|
+
} = d;
|
|
917
|
+
if (y !== void 0) {
|
|
918
|
+
if (typeof y == "string" ? f = !!P(
|
|
919
|
+
new Object(s.formData.value),
|
|
1786
920
|
y
|
|
1787
|
-
) : typeof y == "function" ?
|
|
1788
|
-
return
|
|
921
|
+
) : typeof y == "function" ? f = W(y(s)) : f = W(y), !f)
|
|
922
|
+
return v;
|
|
923
|
+
} else if (b !== void 0 && f !== void 0) {
|
|
924
|
+
if (f || (typeof b == "string" ? f = !!P(
|
|
925
|
+
new Object(s.formData.value),
|
|
926
|
+
b
|
|
927
|
+
) : typeof b == "function" ? f = W(b(s)) : f = W(b), !f))
|
|
928
|
+
return v;
|
|
1789
929
|
} else
|
|
1790
|
-
|
|
1791
|
-
let
|
|
1792
|
-
return
|
|
1793
|
-
schema:
|
|
1794
|
-
}) :
|
|
1795
|
-
default: (
|
|
1796
|
-
schema:
|
|
1797
|
-
scope:
|
|
930
|
+
f = void 0;
|
|
931
|
+
let n;
|
|
932
|
+
return m && (typeof c == "string" ? n = z(u, {
|
|
933
|
+
schema: m
|
|
934
|
+
}) : n = {
|
|
935
|
+
default: (j) => z(u, {
|
|
936
|
+
schema: m,
|
|
937
|
+
scope: j
|
|
1798
938
|
})
|
|
1799
|
-
}),
|
|
1800
|
-
|
|
1801
|
-
|
|
939
|
+
}), D ? (v.push(
|
|
940
|
+
z(
|
|
941
|
+
t,
|
|
1802
942
|
{
|
|
1803
|
-
name:
|
|
1804
|
-
is:
|
|
1805
|
-
type:
|
|
1806
|
-
defaultValue:
|
|
1807
|
-
showValid:
|
|
1808
|
-
props:
|
|
943
|
+
name: D,
|
|
944
|
+
is: c,
|
|
945
|
+
type: I,
|
|
946
|
+
defaultValue: R,
|
|
947
|
+
showValid: E,
|
|
948
|
+
props: _
|
|
1809
949
|
},
|
|
1810
|
-
|
|
950
|
+
p ?? n ?? w
|
|
1811
951
|
)
|
|
1812
|
-
),
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
952
|
+
), v) : c ? (v.push(
|
|
953
|
+
z(
|
|
954
|
+
c,
|
|
955
|
+
_,
|
|
956
|
+
p ?? n ?? w
|
|
1817
957
|
)
|
|
1818
|
-
),
|
|
958
|
+
), v) : (n && ("default" in n ? v.push(n.default(g.scope)) : v.push(n)), v);
|
|
1819
959
|
}, []);
|
|
1820
|
-
return
|
|
1821
|
-
|
|
1822
|
-
errors:
|
|
1823
|
-
formData:
|
|
1824
|
-
invalid:
|
|
1825
|
-
status:
|
|
1826
|
-
submit:
|
|
1827
|
-
validate:
|
|
1828
|
-
clear:
|
|
1829
|
-
reset:
|
|
960
|
+
return r.push(
|
|
961
|
+
a?.default?.({
|
|
962
|
+
errors: s?.errors.value,
|
|
963
|
+
formData: s?.formData.value,
|
|
964
|
+
invalid: s?.invalid.value,
|
|
965
|
+
status: s?.status.value,
|
|
966
|
+
submit: s?.submit,
|
|
967
|
+
validate: s?.validate,
|
|
968
|
+
clear: s?.clear,
|
|
969
|
+
reset: s?.reset
|
|
1830
970
|
})
|
|
1831
|
-
),
|
|
971
|
+
), r;
|
|
1832
972
|
};
|
|
1833
973
|
}
|
|
1834
974
|
});
|
|
1835
|
-
return
|
|
975
|
+
return u;
|
|
1836
976
|
}
|
|
1837
|
-
function
|
|
1838
|
-
const
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
),
|
|
1842
|
-
n,
|
|
977
|
+
function q(e, t = {}) {
|
|
978
|
+
const u = Symbol("formInjectionKey"), g = Symbol("formWrapperInjectionKey"), a = Symbol("formFieldInjectionKey"), s = Symbol("formFieldsGroupInjectionKey"), l = Be(
|
|
979
|
+
u,
|
|
980
|
+
g
|
|
981
|
+
), f = Ge(
|
|
1843
982
|
u,
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
983
|
+
g,
|
|
984
|
+
a,
|
|
985
|
+
t
|
|
986
|
+
), r = ke(
|
|
1848
987
|
u,
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
988
|
+
g,
|
|
989
|
+
s
|
|
990
|
+
), v = We(u, f), o = /* @__PURE__ */ new Map(), {
|
|
991
|
+
clear: d,
|
|
992
|
+
errors: c,
|
|
993
|
+
formData: D,
|
|
994
|
+
ignoreUpdates: p,
|
|
995
|
+
invalid: m,
|
|
996
|
+
readonly: y,
|
|
997
|
+
reset: b,
|
|
998
|
+
status: I,
|
|
999
|
+
stopUpdatesWatch: R,
|
|
1000
|
+
submit: E,
|
|
1001
|
+
validate: w,
|
|
1002
|
+
VvForm: _
|
|
1003
|
+
} = $e(e, u, t, v, o);
|
|
1864
1004
|
return {
|
|
1865
|
-
clear:
|
|
1866
|
-
errors:
|
|
1867
|
-
formData:
|
|
1868
|
-
formFieldInjectionKey:
|
|
1869
|
-
formInjectionKey:
|
|
1870
|
-
formWrapperInjectionKey:
|
|
1871
|
-
ignoreUpdates:
|
|
1872
|
-
invalid:
|
|
1873
|
-
readonly:
|
|
1874
|
-
reset:
|
|
1875
|
-
status:
|
|
1876
|
-
stopUpdatesWatch:
|
|
1877
|
-
submit:
|
|
1878
|
-
validate:
|
|
1879
|
-
wrappers:
|
|
1880
|
-
VvForm:
|
|
1881
|
-
VvFormField:
|
|
1882
|
-
VvFormFieldsGroup:
|
|
1883
|
-
VvFormTemplate:
|
|
1884
|
-
VvFormWrapper:
|
|
1005
|
+
clear: d,
|
|
1006
|
+
errors: c,
|
|
1007
|
+
formData: D,
|
|
1008
|
+
formFieldInjectionKey: a,
|
|
1009
|
+
formInjectionKey: u,
|
|
1010
|
+
formWrapperInjectionKey: g,
|
|
1011
|
+
ignoreUpdates: p,
|
|
1012
|
+
invalid: m,
|
|
1013
|
+
readonly: y,
|
|
1014
|
+
reset: b,
|
|
1015
|
+
status: I,
|
|
1016
|
+
stopUpdatesWatch: R,
|
|
1017
|
+
submit: E,
|
|
1018
|
+
validate: w,
|
|
1019
|
+
wrappers: o,
|
|
1020
|
+
VvForm: _,
|
|
1021
|
+
VvFormField: f,
|
|
1022
|
+
VvFormFieldsGroup: r,
|
|
1023
|
+
VvFormTemplate: v,
|
|
1024
|
+
VvFormWrapper: l
|
|
1885
1025
|
};
|
|
1886
1026
|
}
|
|
1887
|
-
const
|
|
1888
|
-
function
|
|
1889
|
-
let
|
|
1890
|
-
return e.schema && (
|
|
1891
|
-
...
|
|
1892
|
-
install(
|
|
1893
|
-
|
|
1027
|
+
const fe = Symbol("pluginInjectionKey");
|
|
1028
|
+
function Me(e) {
|
|
1029
|
+
let t = {};
|
|
1030
|
+
return e.schema && (t = q(e.schema, e)), {
|
|
1031
|
+
...t,
|
|
1032
|
+
install(u, { global: g = !1 } = {}) {
|
|
1033
|
+
u.provide(fe, e), g && (u.config.globalProperties.$vvForm = e, t?.VvForm && u.component("VvForm", t.VvForm), t?.VvFormWrapper && u.component("VvFormWrapper", t.VvFormWrapper), t?.VvFormField && u.component("VvFormField", t.VvFormField), t?.VvFormFieldsGroup && u.component("VvFormFieldsGroup", t.VvFormFieldsGroup), t?.VvFormTemplate && u.component("VvFormTemplate", t.VvFormTemplate));
|
|
1894
1034
|
}
|
|
1895
1035
|
};
|
|
1896
1036
|
}
|
|
1897
|
-
const
|
|
1898
|
-
function
|
|
1899
|
-
if (
|
|
1900
|
-
return
|
|
1901
|
-
if (!
|
|
1902
|
-
const
|
|
1903
|
-
return
|
|
1037
|
+
const J = /* @__PURE__ */ new Map();
|
|
1038
|
+
function Je(e, t = {}) {
|
|
1039
|
+
if (t.scope && J.has(t.scope))
|
|
1040
|
+
return J.get(t.scope);
|
|
1041
|
+
if (!ye()) {
|
|
1042
|
+
const g = q(e, t);
|
|
1043
|
+
return t.scope && J.set(t.scope, g), g;
|
|
1904
1044
|
}
|
|
1905
|
-
const
|
|
1045
|
+
const u = q(
|
|
1906
1046
|
e,
|
|
1907
1047
|
{
|
|
1908
|
-
...
|
|
1909
|
-
...
|
|
1048
|
+
...G(fe, {}),
|
|
1049
|
+
...t
|
|
1910
1050
|
}
|
|
1911
1051
|
);
|
|
1912
|
-
return
|
|
1052
|
+
return t.scope && J.set(t.scope, u), u;
|
|
1913
1053
|
}
|
|
1914
|
-
function
|
|
1915
|
-
return
|
|
1054
|
+
function qe(e, t = {}) {
|
|
1055
|
+
return q(e, t);
|
|
1916
1056
|
}
|
|
1917
1057
|
export {
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1058
|
+
V as FormFieldType,
|
|
1059
|
+
Me as createForm,
|
|
1060
|
+
k as defaultObjectBySchema,
|
|
1061
|
+
qe as formType,
|
|
1062
|
+
fe as pluginInjectionKey,
|
|
1063
|
+
Je as useForm
|
|
1924
1064
|
};
|