@volverjs/form-vue 1.1.0-beta.3 → 1.1.0-beta.4
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 +583 -1443
- package/dist/index.umd.js +1 -3
- package/package.json +9 -9
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
|
-
}, e.getValidEnumValues = (t) => {
|
|
19
|
-
const o = e.objectKeys(t).filter((i) => typeof t[t[i]] != "number"), s = {};
|
|
20
|
-
for (const i of o)
|
|
21
|
-
s[i] = t[i];
|
|
22
|
-
return e.objectValues(s);
|
|
23
|
-
}, e.objectValues = (t) => e.objectKeys(t).map(function(o) {
|
|
24
|
-
return t[o];
|
|
25
|
-
}), e.objectKeys = typeof Object.keys == "function" ? (t) => Object.keys(t) : (t) => {
|
|
26
|
-
const o = [];
|
|
27
|
-
for (const s in t)
|
|
28
|
-
Object.prototype.hasOwnProperty.call(t, s) && o.push(s);
|
|
29
|
-
return o;
|
|
30
|
-
}, e.find = (t, o) => {
|
|
31
|
-
for (const s of t)
|
|
32
|
-
if (o(s))
|
|
33
|
-
return s;
|
|
34
|
-
}, e.isInteger = typeof Number.isInteger == "function" ? (t) => Number.isInteger(t) : (t) => typeof t == "number" && Number.isFinite(t) && Math.floor(t) === t;
|
|
35
|
-
function u(t, o = " | ") {
|
|
36
|
-
return t.map((s) => typeof s == "string" ? `'${s}'` : s).join(o);
|
|
37
|
-
}
|
|
38
|
-
e.joinValues = u, e.jsonStringifyReplacer = (t, o) => typeof o == "bigint" ? o.toString() : o;
|
|
39
|
-
})(B || (B = {}));
|
|
40
|
-
var le;
|
|
41
|
-
(function(e) {
|
|
42
|
-
e.mergeShapes = (r, n) => ({
|
|
43
|
-
...r,
|
|
44
|
-
...n
|
|
45
|
-
// second overwrites first
|
|
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
|
-
]);
|
|
340
|
-
}
|
|
341
|
-
break;
|
|
342
|
-
}
|
|
343
|
-
case "number": {
|
|
344
|
-
const a = h, { minimum: l, maximum: p, format: y, multipleOf: w, exclusiveMaximum: O, exclusiveMinimum: x } = r._zod.bag;
|
|
345
|
-
typeof y == "string" && y.includes("int") ? a.type = "integer" : a.type = "number", typeof x == "number" && (a.exclusiveMinimum = x), typeof l == "number" && (a.minimum = l, typeof x == "number" && (x >= l ? delete a.minimum : delete a.exclusiveMinimum)), typeof O == "number" && (a.exclusiveMaximum = O), typeof p == "number" && (a.maximum = p, typeof O == "number" && (O <= p ? delete a.maximum : delete a.exclusiveMaximum)), typeof w == "number" && (a.multipleOf = w);
|
|
346
|
-
break;
|
|
347
|
-
}
|
|
348
|
-
case "boolean": {
|
|
349
|
-
const a = h;
|
|
350
|
-
a.type = "boolean";
|
|
351
|
-
break;
|
|
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;
|
|
446
|
-
}
|
|
447
|
-
t.rest && (a.items = this.process(t.rest, {
|
|
448
|
-
...c,
|
|
449
|
-
path: [...c.path, "items"]
|
|
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");
|
|
540
|
-
}
|
|
541
|
-
h.default = a;
|
|
542
|
-
break;
|
|
543
|
-
}
|
|
544
|
-
case "nan": {
|
|
545
|
-
if (this.unrepresentable === "throw")
|
|
546
|
-
throw new Error("NaN cannot be represented in JSON Schema");
|
|
547
|
-
break;
|
|
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;
|
|
583
|
-
}
|
|
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);
|
|
1
|
+
import { ref as _, computed as D, readonly as N, defineComponent as C, h as E, withModifiers as te, toRaw as G, watch as k, isProxy as de, onMounted as q, provide as H, toRefs as X, useId as re, inject as B, onBeforeUnmount as U, unref as P, resolveComponent as Z, defineAsyncComponent as fe, getCurrentInstance as ve } from "vue";
|
|
2
|
+
import { watchIgnorable as ce, throttleFilter as me } from "@vueuse/core";
|
|
3
|
+
import { ZodError as pe } from "zod/v3";
|
|
4
|
+
import { safeParse as ye, safeParseAsync as be, formatError as ae, $ZodError as he } from "zod/v4/core";
|
|
5
|
+
import { toJSONSchema as je } from "zod/v4";
|
|
6
|
+
import { set as ne, get as L } from "ts-dot-prop";
|
|
7
|
+
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 || {}), R = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e.submitting = "submitting", e.reset = "reset", e.updated = "updated", e.unknown = "unknown", e))(R || {});
|
|
8
|
+
const K = (e) => e._def.typeName === "ZodObject", Ve = (e) => e._def.typeName === "ZodDefault", Oe = (e) => e._def.typeName === "ZodNullable", we = (e) => e._def.typeName === "ZodRecord", De = (e) => e._def.typeName === "ZodArray", oe = (e) => e._def.typeName === "ZodEffects", ue = (e) => e._def.typeName === "ZodOptional", z = (e) => {
|
|
9
|
+
let t = e;
|
|
10
|
+
for (; oe(t); )
|
|
11
|
+
t = t.innerType();
|
|
12
|
+
return ue(t) && (t = t._def.innerType), t;
|
|
13
|
+
}, ge = (e) => {
|
|
14
|
+
let t = e;
|
|
15
|
+
for (; oe(t); )
|
|
16
|
+
t = t.innerType();
|
|
17
|
+
return !!ue(t);
|
|
815
18
|
};
|
|
816
|
-
function
|
|
19
|
+
function Se(e) {
|
|
817
20
|
return Array.isArray(e) ? "array" : e === null ? "null" : typeof e;
|
|
818
21
|
}
|
|
819
|
-
function
|
|
820
|
-
const n =
|
|
821
|
-
return
|
|
22
|
+
function Ie(e, t) {
|
|
23
|
+
const n = Se(e);
|
|
24
|
+
return t.type ? t.type === n || t.type === "integer" && n === "number" && Number.isInteger(e) : !0;
|
|
822
25
|
}
|
|
823
|
-
function
|
|
26
|
+
function W(e, t) {
|
|
824
27
|
if (e.anyOf && Array.isArray(e.anyOf)) {
|
|
825
|
-
if (
|
|
826
|
-
for (const
|
|
827
|
-
if (
|
|
828
|
-
return
|
|
829
|
-
for (const
|
|
830
|
-
const i =
|
|
28
|
+
if (t !== void 0) {
|
|
29
|
+
for (const o of e.anyOf)
|
|
30
|
+
if (Ie(t, o))
|
|
31
|
+
return W(o, t);
|
|
32
|
+
for (const o of e.anyOf) {
|
|
33
|
+
const i = o;
|
|
831
34
|
if (!i.type || i.type === "object")
|
|
832
|
-
return
|
|
35
|
+
return W(i, t);
|
|
833
36
|
}
|
|
834
37
|
}
|
|
835
|
-
return
|
|
38
|
+
return W(e.anyOf[0], t);
|
|
836
39
|
}
|
|
837
40
|
if (e.type !== "object" || !e.properties)
|
|
838
41
|
switch (e.type) {
|
|
839
42
|
case "string":
|
|
840
|
-
return typeof
|
|
43
|
+
return typeof t == "string" ? t : e.default;
|
|
841
44
|
case "number":
|
|
842
45
|
case "integer":
|
|
843
|
-
return typeof
|
|
46
|
+
return typeof t == "number" ? t : e.default;
|
|
844
47
|
case "boolean":
|
|
845
|
-
return typeof
|
|
48
|
+
return typeof t == "boolean" ? t : e.default;
|
|
846
49
|
case "null":
|
|
847
|
-
return
|
|
50
|
+
return t === null ? t : e.default;
|
|
848
51
|
case "array":
|
|
849
|
-
return Array.isArray(
|
|
52
|
+
return Array.isArray(t) && e.items ? t.map((o) => W(e.items, o)) : e.default;
|
|
850
53
|
default:
|
|
851
54
|
return e.default;
|
|
852
55
|
}
|
|
853
|
-
const n = e.properties,
|
|
854
|
-
for (const
|
|
855
|
-
const i =
|
|
856
|
-
o
|
|
56
|
+
const n = e.properties, r = t && typeof t == "object" && !Array.isArray(t) ? t : void 0, u = {};
|
|
57
|
+
for (const o in n) {
|
|
58
|
+
const i = r?.[o];
|
|
59
|
+
u[o] = W(n[o], i);
|
|
857
60
|
}
|
|
858
|
-
if (
|
|
859
|
-
const
|
|
860
|
-
for (const [i,
|
|
861
|
-
|
|
61
|
+
if (r && e.additionalProperties !== !1) {
|
|
62
|
+
const o = new Set(Object.keys(n));
|
|
63
|
+
for (const [i, l] of Object.entries(r))
|
|
64
|
+
o.has(i) || (u[i] = l);
|
|
862
65
|
}
|
|
863
|
-
return
|
|
66
|
+
return u;
|
|
864
67
|
}
|
|
865
|
-
const
|
|
866
|
-
function
|
|
867
|
-
if (
|
|
868
|
-
const
|
|
869
|
-
if (
|
|
870
|
-
return
|
|
871
|
-
const
|
|
872
|
-
return
|
|
68
|
+
const Q = (e) => "_zod" in e;
|
|
69
|
+
function J(e, t = {}) {
|
|
70
|
+
if (Q(e)) {
|
|
71
|
+
const r = je(e);
|
|
72
|
+
if (r.type !== "object" || !r.properties)
|
|
73
|
+
return t;
|
|
74
|
+
const u = ye(e, t);
|
|
75
|
+
return W(r, u.success ? u.data : t);
|
|
873
76
|
}
|
|
874
|
-
const n =
|
|
875
|
-
return
|
|
876
|
-
...n._def.unknownKeys === "passthrough" ?
|
|
77
|
+
const n = z(e);
|
|
78
|
+
return K(n) ? {
|
|
79
|
+
...n._def.unknownKeys === "passthrough" ? t : {},
|
|
877
80
|
...Object.fromEntries(
|
|
878
81
|
("shape" in n ? Object.entries(n.shape) : []).map(
|
|
879
|
-
([
|
|
880
|
-
const
|
|
881
|
-
let
|
|
882
|
-
if (
|
|
883
|
-
return [
|
|
884
|
-
if (
|
|
885
|
-
return [
|
|
886
|
-
if (
|
|
887
|
-
const d =
|
|
82
|
+
([r, u]) => {
|
|
83
|
+
const o = t[r], i = ge(u);
|
|
84
|
+
let l = z(u), f;
|
|
85
|
+
if (Ve(l) && (f = l._def.defaultValue(), l = l._def.innerType), o === null && Oe(l))
|
|
86
|
+
return [r, o];
|
|
87
|
+
if (o == null && i)
|
|
88
|
+
return [r, f];
|
|
89
|
+
if (l) {
|
|
90
|
+
const d = u.safeParse(o);
|
|
888
91
|
if (d.success)
|
|
889
|
-
return [
|
|
92
|
+
return [r, d.data ?? f];
|
|
890
93
|
}
|
|
891
|
-
if (
|
|
892
|
-
const d =
|
|
893
|
-
if (
|
|
94
|
+
if (De(l) && Array.isArray(o) && o.length) {
|
|
95
|
+
const d = z(l._def.type);
|
|
96
|
+
if (K(d))
|
|
894
97
|
return [
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
(c) =>
|
|
98
|
+
r,
|
|
99
|
+
o.map(
|
|
100
|
+
(c) => J(
|
|
898
101
|
d,
|
|
899
102
|
c && typeof c == "object" ? c : void 0
|
|
900
103
|
)
|
|
901
104
|
)
|
|
902
105
|
];
|
|
903
106
|
}
|
|
904
|
-
if (
|
|
905
|
-
const d =
|
|
906
|
-
if (
|
|
907
|
-
return [
|
|
107
|
+
if (we(l) && o) {
|
|
108
|
+
const d = z(l._def.valueType);
|
|
109
|
+
if (K(d))
|
|
110
|
+
return [r, Object.keys(o).reduce((c, h) => (c[h] = J(d, o[h]), c), {})];
|
|
908
111
|
}
|
|
909
|
-
return
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
112
|
+
return K(l) ? [
|
|
113
|
+
r,
|
|
114
|
+
J(
|
|
115
|
+
l,
|
|
116
|
+
o && typeof o == "object" ? o : f
|
|
914
117
|
)
|
|
915
|
-
] : [
|
|
118
|
+
] : [r, f];
|
|
916
119
|
}
|
|
917
120
|
)
|
|
918
121
|
)
|
|
919
|
-
} :
|
|
122
|
+
} : t;
|
|
920
123
|
}
|
|
921
|
-
const
|
|
922
|
-
function
|
|
923
|
-
const
|
|
124
|
+
const Re = (e, t) => Q(e) ? be(e, t) : e.safeParseAsync(t), xe = (e, t) => Q(e) ? ae(t) : t.format(), Ee = (e, t) => Q(e) ? ae(new he(t)) : new pe(t).format();
|
|
125
|
+
function Ae(e, t, n, b, r) {
|
|
126
|
+
const u = _(), o = _(), i = D(() => o.value === R.invalid), l = _(), f = _(!1);
|
|
924
127
|
let d;
|
|
925
|
-
const c = (
|
|
926
|
-
const
|
|
128
|
+
const c = (w) => {
|
|
129
|
+
const S = J(e, w);
|
|
927
130
|
if (n?.class) {
|
|
928
|
-
const
|
|
929
|
-
return new
|
|
131
|
+
const a = n.class;
|
|
132
|
+
return new a(S);
|
|
930
133
|
}
|
|
931
|
-
return
|
|
932
|
-
},
|
|
933
|
-
if (d =
|
|
134
|
+
return S;
|
|
135
|
+
}, h = async (w = l.value, S) => {
|
|
136
|
+
if (d = S?.fields, f.value)
|
|
934
137
|
return !0;
|
|
935
|
-
const
|
|
936
|
-
if (!
|
|
937
|
-
if (
|
|
938
|
-
return
|
|
939
|
-
const
|
|
940
|
-
(
|
|
138
|
+
const a = await Re(e, w);
|
|
139
|
+
if (!a.success) {
|
|
140
|
+
if (o.value = R.invalid, !d?.size)
|
|
141
|
+
return u.value = xe(e, a.error), !1;
|
|
142
|
+
const j = a.error.issues.filter(
|
|
143
|
+
($) => d?.has($.path.join("."))
|
|
941
144
|
);
|
|
942
|
-
return
|
|
145
|
+
return j.length ? (u.value = Ee(e, j), !1) : (u.value = void 0, !0);
|
|
943
146
|
}
|
|
944
|
-
return
|
|
945
|
-
},
|
|
946
|
-
|
|
947
|
-
},
|
|
948
|
-
|
|
949
|
-
},
|
|
950
|
-
|
|
147
|
+
return u.value = void 0, o.value = R.valid, l.value = c(a.data), !0;
|
|
148
|
+
}, g = () => {
|
|
149
|
+
u.value = void 0, o.value = void 0, d = void 0;
|
|
150
|
+
}, O = () => {
|
|
151
|
+
l.value = c(), g(), o.value = R.reset;
|
|
152
|
+
}, v = async (w) => f.value || !await h(void 0, w) ? !1 : (o.value = R.submitting, !0), { ignoreUpdates: m, stop: y } = ce(
|
|
153
|
+
l,
|
|
951
154
|
() => {
|
|
952
|
-
|
|
155
|
+
o.value = R.updated;
|
|
953
156
|
},
|
|
954
157
|
{
|
|
955
158
|
deep: !0,
|
|
956
|
-
eventFilter:
|
|
159
|
+
eventFilter: me(n?.updateThrottle ?? 500)
|
|
957
160
|
}
|
|
958
|
-
),
|
|
161
|
+
), x = N(u), I = N(o), A = C({
|
|
959
162
|
name: "VvForm",
|
|
960
163
|
props: {
|
|
961
164
|
continuousValidation: {
|
|
@@ -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: S }) {
|
|
216
|
+
return l.value = c(G(w.modelValue)), k(
|
|
217
|
+
() => w.modelValue,
|
|
218
|
+
(a) => {
|
|
219
|
+
if (a) {
|
|
220
|
+
const j = de(a) ? G(a) : a;
|
|
221
|
+
if (JSON.stringify(j) === JSON.stringify(G(l.value)))
|
|
1019
222
|
return;
|
|
1020
|
-
|
|
223
|
+
l.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
|
+
), k(o, async (a) => {
|
|
228
|
+
if (a === R.invalid) {
|
|
229
|
+
const j = G(u.value);
|
|
230
|
+
S("invalid", j), n?.onInvalid?.(
|
|
231
|
+
j
|
|
1029
232
|
);
|
|
1030
233
|
return;
|
|
1031
234
|
}
|
|
1032
|
-
if (
|
|
1033
|
-
const
|
|
1034
|
-
|
|
235
|
+
if (a === R.valid) {
|
|
236
|
+
const j = G(l.value);
|
|
237
|
+
S("valid", j), n?.onValid?.(j), S("update:modelValue", j), n?.onUpdate?.(j);
|
|
1035
238
|
return;
|
|
1036
239
|
}
|
|
1037
|
-
if (
|
|
1038
|
-
const
|
|
1039
|
-
|
|
240
|
+
if (a === R.submitting) {
|
|
241
|
+
const j = G(l.value);
|
|
242
|
+
S("submit", j), n?.onSubmit?.(j);
|
|
1040
243
|
return;
|
|
1041
244
|
}
|
|
1042
|
-
if (
|
|
1043
|
-
const
|
|
1044
|
-
|
|
245
|
+
if (a === R.reset) {
|
|
246
|
+
const j = G(l.value);
|
|
247
|
+
S("reset", j), n?.onReset?.(j);
|
|
1045
248
|
return;
|
|
1046
249
|
}
|
|
1047
|
-
if (
|
|
1048
|
-
if ((
|
|
1049
|
-
superRefine:
|
|
1050
|
-
fields: d ?? new Set(
|
|
1051
|
-
}), !
|
|
1052
|
-
const
|
|
1053
|
-
|
|
250
|
+
if (a === R.updated) {
|
|
251
|
+
if ((u.value || n?.continuousValidation || w.continuousValidation) && await h(void 0, {
|
|
252
|
+
superRefine: w.superRefine,
|
|
253
|
+
fields: d ?? new Set(w.validateFields)
|
|
254
|
+
}), !l.value || !w.modelValue || JSON.stringify(l.value) !== JSON.stringify(w.modelValue)) {
|
|
255
|
+
const j = G(l.value);
|
|
256
|
+
S("update:modelValue", j), n?.onUpdate?.(j);
|
|
1054
257
|
}
|
|
1055
|
-
|
|
258
|
+
o.value === R.updated && (o.value = R.unknown);
|
|
1056
259
|
}
|
|
1057
|
-
}),
|
|
1058
|
-
|
|
1059
|
-
}),
|
|
1060
|
-
() =>
|
|
1061
|
-
(
|
|
1062
|
-
|
|
260
|
+
}), q(() => {
|
|
261
|
+
w.readonly !== void 0 && (f.value = w.readonly);
|
|
262
|
+
}), k(
|
|
263
|
+
() => w.readonly,
|
|
264
|
+
(a) => {
|
|
265
|
+
f.value = a;
|
|
1063
266
|
}
|
|
1064
|
-
),
|
|
1065
|
-
|
|
1066
|
-
}),
|
|
1067
|
-
clear:
|
|
1068
|
-
errors:
|
|
1069
|
-
formData:
|
|
1070
|
-
ignoreUpdates:
|
|
267
|
+
), k(f, (a) => {
|
|
268
|
+
a !== w.readonly && S("update:readonly", f.value);
|
|
269
|
+
}), H(t, {
|
|
270
|
+
clear: g,
|
|
271
|
+
errors: x,
|
|
272
|
+
formData: l,
|
|
273
|
+
ignoreUpdates: m,
|
|
1071
274
|
invalid: i,
|
|
1072
|
-
readonly:
|
|
1073
|
-
reset:
|
|
1074
|
-
status:
|
|
275
|
+
readonly: f,
|
|
276
|
+
reset: O,
|
|
277
|
+
status: I,
|
|
1075
278
|
stopUpdatesWatch: y,
|
|
1076
|
-
submit:
|
|
1077
|
-
validate:
|
|
1078
|
-
wrappers:
|
|
279
|
+
submit: v,
|
|
280
|
+
validate: h,
|
|
281
|
+
wrappers: r
|
|
1079
282
|
}), {
|
|
1080
|
-
clear:
|
|
1081
|
-
errors:
|
|
1082
|
-
formData:
|
|
1083
|
-
ignoreUpdates:
|
|
283
|
+
clear: g,
|
|
284
|
+
errors: x,
|
|
285
|
+
formData: l,
|
|
286
|
+
ignoreUpdates: m,
|
|
1084
287
|
invalid: i,
|
|
1085
|
-
isReadonly:
|
|
1086
|
-
reset:
|
|
1087
|
-
status:
|
|
288
|
+
isReadonly: f,
|
|
289
|
+
reset: O,
|
|
290
|
+
status: I,
|
|
1088
291
|
stopUpdatesWatch: y,
|
|
1089
|
-
submit: () =>
|
|
1090
|
-
superRefine:
|
|
1091
|
-
fields: new Set(
|
|
292
|
+
submit: () => v({
|
|
293
|
+
superRefine: w.superRefine,
|
|
294
|
+
fields: new Set(w.validateFields)
|
|
1092
295
|
}),
|
|
1093
|
-
validate:
|
|
1094
|
-
wrappers:
|
|
296
|
+
validate: h,
|
|
297
|
+
wrappers: r
|
|
1095
298
|
};
|
|
1096
299
|
},
|
|
1097
300
|
render() {
|
|
1098
|
-
const
|
|
1099
|
-
errors:
|
|
1100
|
-
formData:
|
|
301
|
+
const w = () => this.$slots?.default?.({
|
|
302
|
+
errors: x.value,
|
|
303
|
+
formData: l.value,
|
|
1101
304
|
invalid: i.value,
|
|
1102
|
-
readonly:
|
|
1103
|
-
status:
|
|
1104
|
-
wrappers:
|
|
1105
|
-
clear:
|
|
1106
|
-
ignoreUpdates:
|
|
1107
|
-
reset:
|
|
305
|
+
readonly: f.value,
|
|
306
|
+
status: I.value,
|
|
307
|
+
wrappers: r,
|
|
308
|
+
clear: g,
|
|
309
|
+
ignoreUpdates: m,
|
|
310
|
+
reset: O,
|
|
1108
311
|
stopUpdatesWatch: y,
|
|
1109
|
-
submit:
|
|
1110
|
-
validate:
|
|
312
|
+
submit: v,
|
|
313
|
+
validate: h
|
|
1111
314
|
}) ?? this.$slots.default;
|
|
1112
|
-
return
|
|
315
|
+
return E(
|
|
1113
316
|
this.tag,
|
|
1114
317
|
{
|
|
1115
|
-
onSubmit:
|
|
1116
|
-
onReset:
|
|
318
|
+
onSubmit: te(this.submit, ["prevent"]),
|
|
319
|
+
onReset: te(this.reset, ["prevent"])
|
|
1117
320
|
},
|
|
1118
|
-
(this.template ?? n?.template) &&
|
|
1119
|
-
|
|
1120
|
-
|
|
321
|
+
(this.template ?? n?.template) && b ? [
|
|
322
|
+
E(
|
|
323
|
+
b,
|
|
1121
324
|
{
|
|
1122
325
|
schema: this.template ?? n?.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:
|
|
338
|
+
clear: g,
|
|
339
|
+
errors: u,
|
|
340
|
+
formData: l,
|
|
341
|
+
ignoreUpdates: m,
|
|
1139
342
|
invalid: i,
|
|
1140
|
-
readonly:
|
|
1141
|
-
reset:
|
|
1142
|
-
status:
|
|
1143
|
-
wrappers:
|
|
343
|
+
readonly: f,
|
|
344
|
+
reset: O,
|
|
345
|
+
status: o,
|
|
346
|
+
wrappers: r,
|
|
1144
347
|
stopUpdatesWatch: y,
|
|
1145
|
-
submit:
|
|
1146
|
-
validate:
|
|
1147
|
-
VvForm:
|
|
348
|
+
submit: v,
|
|
349
|
+
validate: h,
|
|
350
|
+
VvForm: A
|
|
1148
351
|
};
|
|
1149
352
|
}
|
|
1150
|
-
function
|
|
1151
|
-
return Array.isArray(e);
|
|
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) {
|
|
353
|
+
function Fe(e, t, n, b) {
|
|
1214
354
|
return C({
|
|
1215
355
|
name: "VvFormField",
|
|
1216
356
|
props: {
|
|
1217
357
|
type: {
|
|
1218
358
|
type: String,
|
|
1219
|
-
validator: (
|
|
1220
|
-
default:
|
|
359
|
+
validator: (r) => Object.values(V).includes(r),
|
|
360
|
+
default: V.custom
|
|
1221
361
|
},
|
|
1222
362
|
is: {
|
|
1223
363
|
type: [Object, String],
|
|
@@ -1264,174 +404,174 @@ function at(e, r, n, u) {
|
|
|
1264
404
|
"type"
|
|
1265
405
|
],
|
|
1266
406
|
slots: Object,
|
|
1267
|
-
setup(
|
|
1268
|
-
const { props: i, name:
|
|
1269
|
-
d && d.fields.value.set(
|
|
1270
|
-
const c =
|
|
407
|
+
setup(r, { slots: u, emit: o }) {
|
|
408
|
+
const { props: i, name: l } = X(r), f = re(), d = B(t, void 0);
|
|
409
|
+
d && d.fields.value.set(f, r.name);
|
|
410
|
+
const c = B(e), h = D({
|
|
1271
411
|
get() {
|
|
1272
412
|
if (c?.formData)
|
|
1273
|
-
return
|
|
413
|
+
return L(
|
|
1274
414
|
new Object(c.formData.value),
|
|
1275
|
-
String(
|
|
415
|
+
String(r.name)
|
|
1276
416
|
);
|
|
1277
417
|
},
|
|
1278
|
-
set(
|
|
1279
|
-
c?.formData && (
|
|
418
|
+
set(a) {
|
|
419
|
+
c?.formData && (ne(
|
|
1280
420
|
new Object(c.formData.value),
|
|
1281
|
-
String(
|
|
1282
|
-
|
|
1283
|
-
),
|
|
1284
|
-
newValue:
|
|
421
|
+
String(r.name),
|
|
422
|
+
a
|
|
423
|
+
), o("update:modelValue", {
|
|
424
|
+
newValue: h.value,
|
|
1285
425
|
formData: c?.formData
|
|
1286
426
|
}));
|
|
1287
427
|
}
|
|
1288
428
|
});
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
}),
|
|
1292
|
-
d && d.fields.value.delete(
|
|
429
|
+
q(() => {
|
|
430
|
+
h.value === void 0 && r.defaultValue !== void 0 && (h.value = r.defaultValue);
|
|
431
|
+
}), U(() => {
|
|
432
|
+
d && d.fields.value.delete(f);
|
|
1293
433
|
});
|
|
1294
|
-
const
|
|
434
|
+
const g = D(() => {
|
|
1295
435
|
if (c?.errors.value)
|
|
1296
|
-
return
|
|
1297
|
-
}),
|
|
1298
|
-
if (
|
|
1299
|
-
|
|
1300
|
-
String(
|
|
1301
|
-
|
|
436
|
+
return L(c.errors.value, String(r.name));
|
|
437
|
+
}), O = D(() => g.value?._errors), v = D(() => g.value !== void 0), m = k(v, (a) => {
|
|
438
|
+
if (a) {
|
|
439
|
+
o("invalid", g.value), d && d.errors.value.set(
|
|
440
|
+
String(r.name),
|
|
441
|
+
g.value
|
|
1302
442
|
);
|
|
1303
443
|
return;
|
|
1304
444
|
}
|
|
1305
|
-
|
|
1306
|
-
|
|
445
|
+
o("valid", h.value), d && d.errors.value.delete(
|
|
446
|
+
r.name
|
|
1307
447
|
);
|
|
1308
|
-
}), y =
|
|
448
|
+
}), y = k(
|
|
1309
449
|
() => c?.formData,
|
|
1310
450
|
() => {
|
|
1311
|
-
|
|
451
|
+
o("update:formData", c?.formData);
|
|
1312
452
|
},
|
|
1313
453
|
{ deep: !0 }
|
|
1314
454
|
);
|
|
1315
|
-
|
|
1316
|
-
|
|
455
|
+
U(() => {
|
|
456
|
+
m(), y();
|
|
1317
457
|
});
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1320
|
-
},
|
|
1321
|
-
let
|
|
1322
|
-
return typeof
|
|
1323
|
-
(
|
|
458
|
+
const x = (a) => {
|
|
459
|
+
a instanceof InputEvent && (a = a.target.value), h.value = a;
|
|
460
|
+
}, I = D(() => {
|
|
461
|
+
let a = i.value;
|
|
462
|
+
return typeof a == "function" && (a = a(c?.formData)), Object.keys(a).reduce(
|
|
463
|
+
(j, $) => (j[$] = P(a[$]), j),
|
|
1324
464
|
{}
|
|
1325
465
|
);
|
|
1326
|
-
}),
|
|
1327
|
-
...
|
|
1328
|
-
name:
|
|
1329
|
-
invalid:
|
|
1330
|
-
valid:
|
|
1331
|
-
type: ((
|
|
466
|
+
}), A = D(() => c?.readonly.value || d?.readonly.value ? !0 : I.value.readonly ?? r.readonly), w = D(() => ({
|
|
467
|
+
...I.value,
|
|
468
|
+
name: I.value.name ?? r.name,
|
|
469
|
+
invalid: v.value,
|
|
470
|
+
valid: r.showValid ? !!(!v.value && h.value) : void 0,
|
|
471
|
+
type: ((a) => {
|
|
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(a))
|
|
487
|
+
return a;
|
|
488
|
+
})(r.type),
|
|
489
|
+
invalidLabel: O.value,
|
|
490
|
+
modelValue: h.value,
|
|
491
|
+
readonly: A.value,
|
|
492
|
+
"onUpdate:modelValue": x
|
|
1353
493
|
}));
|
|
1354
|
-
return
|
|
1355
|
-
name:
|
|
1356
|
-
errors:
|
|
1357
|
-
}), { component:
|
|
1358
|
-
if (
|
|
494
|
+
return H(n, {
|
|
495
|
+
name: N(l),
|
|
496
|
+
errors: N(g)
|
|
497
|
+
}), { component: D(() => {
|
|
498
|
+
if (r.type === V.custom)
|
|
1359
499
|
return {
|
|
1360
500
|
render() {
|
|
1361
|
-
return
|
|
1362
|
-
errors:
|
|
501
|
+
return u.default?.({
|
|
502
|
+
errors: g.value,
|
|
1363
503
|
formData: c?.formData.value,
|
|
1364
504
|
formErrors: c?.errors.value,
|
|
1365
|
-
invalid:
|
|
1366
|
-
invalidLabel:
|
|
1367
|
-
modelValue:
|
|
1368
|
-
readonly:
|
|
1369
|
-
onUpdate:
|
|
505
|
+
invalid: v.value,
|
|
506
|
+
invalidLabel: O.value,
|
|
507
|
+
modelValue: h.value,
|
|
508
|
+
readonly: A.value,
|
|
509
|
+
onUpdate: x,
|
|
1370
510
|
submit: c?.submit,
|
|
1371
511
|
validate: c?.validate
|
|
1372
|
-
}) ??
|
|
512
|
+
}) ?? u.default;
|
|
1373
513
|
}
|
|
1374
514
|
};
|
|
1375
|
-
if (!(
|
|
1376
|
-
let
|
|
1377
|
-
switch (
|
|
1378
|
-
case
|
|
1379
|
-
|
|
515
|
+
if (!(b?.lazyLoad ?? r.lazyLoad)) {
|
|
516
|
+
let a;
|
|
517
|
+
switch (r.type) {
|
|
518
|
+
case V.select:
|
|
519
|
+
a = Z("VvSelect");
|
|
1380
520
|
break;
|
|
1381
|
-
case
|
|
1382
|
-
|
|
521
|
+
case V.checkbox:
|
|
522
|
+
a = Z("VvCheckbox");
|
|
1383
523
|
break;
|
|
1384
|
-
case
|
|
1385
|
-
|
|
524
|
+
case V.radio:
|
|
525
|
+
a = Z("VvRadio");
|
|
1386
526
|
break;
|
|
1387
|
-
case
|
|
1388
|
-
|
|
527
|
+
case V.textarea:
|
|
528
|
+
a = Z("VvTextarea");
|
|
1389
529
|
break;
|
|
1390
|
-
case
|
|
1391
|
-
|
|
530
|
+
case V.radioGroup:
|
|
531
|
+
a = Z("VvRadioGroup");
|
|
1392
532
|
break;
|
|
1393
|
-
case
|
|
1394
|
-
|
|
533
|
+
case V.checkboxGroup:
|
|
534
|
+
a = Z("VvCheckboxGroup");
|
|
1395
535
|
break;
|
|
1396
|
-
case
|
|
1397
|
-
|
|
536
|
+
case V.combobox:
|
|
537
|
+
a = Z("VvCombobox");
|
|
1398
538
|
break;
|
|
1399
539
|
default:
|
|
1400
|
-
|
|
540
|
+
a = Z("VvInputText");
|
|
1401
541
|
}
|
|
1402
|
-
if (typeof
|
|
1403
|
-
return
|
|
542
|
+
if (typeof a != "string")
|
|
543
|
+
return a;
|
|
1404
544
|
console.warn(
|
|
1405
|
-
`[@volverjs/form-vue]: ${
|
|
545
|
+
`[@volverjs/form-vue]: ${a} 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 fe(async () => {
|
|
549
|
+
switch (b?.sideEffects && await Promise.resolve(b.sideEffects(r.type)), r.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: v };
|
|
1428
568
|
},
|
|
1429
569
|
render() {
|
|
1430
|
-
return this.is ?
|
|
570
|
+
return this.is ? E(this.is, this.hasProps, this.$slots) : this.type === V.custom ? E(this.component, null, this.$slots) : E(this.component, this.hasProps, this.$slots);
|
|
1431
571
|
}
|
|
1432
572
|
});
|
|
1433
573
|
}
|
|
1434
|
-
function
|
|
574
|
+
function ke(e, t, n) {
|
|
1435
575
|
return C({
|
|
1436
576
|
name: "VvFormFieldsGroup",
|
|
1437
577
|
props: {
|
|
@@ -1475,150 +615,150 @@ function ot(e, r, n) {
|
|
|
1475
615
|
"is"
|
|
1476
616
|
],
|
|
1477
617
|
slots: Object,
|
|
1478
|
-
setup(
|
|
1479
|
-
const { props:
|
|
1480
|
-
|
|
1481
|
-
|
|
618
|
+
setup(b, { slots: r, emit: u }) {
|
|
619
|
+
const { props: o, names: i, defaultValues: l } = X(b), f = re(), d = D(() => Array.isArray(i.value) ? i.value : Object.values(i.value)), c = D(() => Array.isArray(i.value) ? i.value : Object.keys(i.value)), h = D(() => Array.isArray(i.value) ? i.value.reduce((s, p) => (s[String(p)] = p, s), {}) : i.value), g = D(() => Object.keys(h.value).reduce((s, p) => (s[String(h.value[p])] = p, s), {})), O = B(t, void 0);
|
|
620
|
+
O && d.value.forEach((s) => {
|
|
621
|
+
O.fields.value.set(`${f}-${s}`, s);
|
|
1482
622
|
});
|
|
1483
|
-
const
|
|
623
|
+
const v = B(e), m = D({
|
|
1484
624
|
get() {
|
|
1485
|
-
return
|
|
1486
|
-
new Object(
|
|
1487
|
-
|
|
1488
|
-
),
|
|
625
|
+
return v?.formData ? c.value.reduce((s, p) => (s[p] = L(
|
|
626
|
+
new Object(v.formData.value),
|
|
627
|
+
h.value[p]
|
|
628
|
+
), s), {}) : {};
|
|
1489
629
|
},
|
|
1490
|
-
set(
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
new Object(
|
|
1494
|
-
|
|
1495
|
-
|
|
630
|
+
set(s) {
|
|
631
|
+
v?.formData && (c.value.forEach((p) => {
|
|
632
|
+
ne(
|
|
633
|
+
new Object(v.formData.value),
|
|
634
|
+
h.value[p],
|
|
635
|
+
s?.[p]
|
|
1496
636
|
);
|
|
1497
|
-
}),
|
|
1498
|
-
newValue:
|
|
1499
|
-
formData:
|
|
637
|
+
}), u("update:modelValue", {
|
|
638
|
+
newValue: m.value,
|
|
639
|
+
formData: v?.formData
|
|
1500
640
|
}));
|
|
1501
641
|
}
|
|
1502
642
|
});
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
...
|
|
1507
|
-
[
|
|
643
|
+
q(() => {
|
|
644
|
+
l.value && d.value.forEach((s) => {
|
|
645
|
+
l.value?.[s] !== void 0 && m.value[s] === void 0 && (m.value = {
|
|
646
|
+
...m.value,
|
|
647
|
+
[s]: l.value?.[s]
|
|
1508
648
|
});
|
|
1509
649
|
});
|
|
1510
|
-
}),
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
`${
|
|
650
|
+
}), U(() => {
|
|
651
|
+
O && d.value.forEach((s) => {
|
|
652
|
+
O.fields.value.delete(
|
|
653
|
+
`${f}-${s}`
|
|
1514
654
|
);
|
|
1515
655
|
});
|
|
1516
656
|
});
|
|
1517
|
-
const y =
|
|
1518
|
-
if (!
|
|
657
|
+
const y = D(() => {
|
|
658
|
+
if (!v?.errors.value)
|
|
1519
659
|
return;
|
|
1520
|
-
const
|
|
1521
|
-
if (!
|
|
1522
|
-
return
|
|
1523
|
-
const
|
|
1524
|
-
return
|
|
660
|
+
const s = d.value.reduce((p, F) => {
|
|
661
|
+
if (!v.errors.value)
|
|
662
|
+
return p;
|
|
663
|
+
const ee = L(v.errors.value, String(F));
|
|
664
|
+
return ee === void 0 || (p[String(F)] = ee), p;
|
|
1525
665
|
}, {});
|
|
1526
|
-
if (Object.keys(
|
|
1527
|
-
return
|
|
1528
|
-
}),
|
|
666
|
+
if (Object.keys(s).length !== 0)
|
|
667
|
+
return s;
|
|
668
|
+
}), x = D(() => {
|
|
1529
669
|
if (!y.value)
|
|
1530
670
|
return;
|
|
1531
|
-
const
|
|
1532
|
-
if (Object.keys(
|
|
1533
|
-
return
|
|
1534
|
-
}),
|
|
1535
|
-
if (
|
|
1536
|
-
|
|
1537
|
-
if (!y.value?.[
|
|
1538
|
-
|
|
1539
|
-
|
|
671
|
+
const s = Object.keys(y.value).reduce((p, F) => (y.value?.[F] && (p[g.value[F]] = y.value[F]._errors), p), {});
|
|
672
|
+
if (Object.keys(s).length !== 0)
|
|
673
|
+
return s;
|
|
674
|
+
}), I = D(() => y.value !== void 0), A = D(() => c.value.reduce((s, p) => (s[p] = !!y.value?.[g.value[p]], s), {})), w = k(I, () => {
|
|
675
|
+
if (I.value) {
|
|
676
|
+
u("invalid", y.value), O && d.value.forEach((s) => {
|
|
677
|
+
if (!y.value?.[s]) {
|
|
678
|
+
O.errors.value.delete(
|
|
679
|
+
s
|
|
1540
680
|
);
|
|
1541
681
|
return;
|
|
1542
682
|
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
y.value?.[
|
|
683
|
+
O.errors.value.set(
|
|
684
|
+
s,
|
|
685
|
+
y.value?.[s]
|
|
1546
686
|
);
|
|
1547
687
|
});
|
|
1548
688
|
return;
|
|
1549
689
|
}
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
690
|
+
u("valid", m.value), O && d.value.forEach((s) => {
|
|
691
|
+
O.errors.value.delete(
|
|
692
|
+
s
|
|
1553
693
|
);
|
|
1554
694
|
});
|
|
1555
|
-
}),
|
|
1556
|
-
() =>
|
|
695
|
+
}), S = k(
|
|
696
|
+
() => v?.formData,
|
|
1557
697
|
() => {
|
|
1558
|
-
|
|
698
|
+
u("update:formData", v?.formData);
|
|
1559
699
|
},
|
|
1560
700
|
{ deep: !0 }
|
|
1561
701
|
);
|
|
1562
|
-
|
|
1563
|
-
|
|
702
|
+
U(() => {
|
|
703
|
+
w(), S();
|
|
1564
704
|
});
|
|
1565
|
-
const
|
|
1566
|
-
|
|
1567
|
-
},
|
|
1568
|
-
|
|
1569
|
-
...
|
|
1570
|
-
[
|
|
705
|
+
const a = (s) => {
|
|
706
|
+
m.value = s;
|
|
707
|
+
}, j = (s, p) => {
|
|
708
|
+
p instanceof InputEvent && (p = p.target.value), c.value.includes(s) && (m.value = {
|
|
709
|
+
...m.value,
|
|
710
|
+
[s]: p
|
|
1571
711
|
});
|
|
1572
|
-
},
|
|
1573
|
-
let
|
|
1574
|
-
return typeof
|
|
1575
|
-
(
|
|
712
|
+
}, $ = D(() => {
|
|
713
|
+
let s = o.value;
|
|
714
|
+
return typeof s == "function" && (s = s(v?.formData)), Object.keys(s).reduce(
|
|
715
|
+
(p, F) => (p[F] = P(s[F]), p),
|
|
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
|
+
}), Y = D(() => v?.readonly.value ? !0 : $.value.readonly ?? b.readonly), se = D(() => c.value.reduce((s, p) => (s[`onUpdate:${p}`] = (F) => {
|
|
719
|
+
j(p, F);
|
|
720
|
+
}, s), {
|
|
721
|
+
"onUpdate:modelValue": a
|
|
722
|
+
})), ie = D(() => ({
|
|
723
|
+
...se.value,
|
|
724
|
+
...$.value,
|
|
725
|
+
...m.value,
|
|
726
|
+
modelValue: m.value,
|
|
727
|
+
names: $.value.name ?? d.value,
|
|
728
|
+
invalid: I.value,
|
|
729
|
+
invalids: A.value,
|
|
730
|
+
valid: b.showValid ? !!(!I.value && m.value) : void 0,
|
|
731
|
+
invalidLabels: x.value,
|
|
732
|
+
readonly: Y.value
|
|
1593
733
|
}));
|
|
1594
|
-
return
|
|
1595
|
-
names:
|
|
1596
|
-
errors:
|
|
1597
|
-
}), { component:
|
|
734
|
+
return H(n, {
|
|
735
|
+
names: N(i),
|
|
736
|
+
errors: N(y)
|
|
737
|
+
}), { component: D(() => ({
|
|
1598
738
|
render() {
|
|
1599
|
-
return
|
|
739
|
+
return r.default?.({
|
|
1600
740
|
errors: y.value,
|
|
1601
|
-
formData:
|
|
1602
|
-
formErrors:
|
|
1603
|
-
invalid:
|
|
1604
|
-
invalids:
|
|
1605
|
-
invalidLabels:
|
|
1606
|
-
modelValue:
|
|
1607
|
-
onUpdate:
|
|
1608
|
-
onUpdateField:
|
|
1609
|
-
readonly:
|
|
1610
|
-
submit:
|
|
1611
|
-
validate:
|
|
1612
|
-
}) ??
|
|
741
|
+
formData: v?.formData.value,
|
|
742
|
+
formErrors: v?.errors.value,
|
|
743
|
+
invalid: I.value,
|
|
744
|
+
invalids: A.value,
|
|
745
|
+
invalidLabels: x.value,
|
|
746
|
+
modelValue: m.value,
|
|
747
|
+
onUpdate: a,
|
|
748
|
+
onUpdateField: j,
|
|
749
|
+
readonly: Y.value,
|
|
750
|
+
submit: v?.submit,
|
|
751
|
+
validate: v?.validate
|
|
752
|
+
}) ?? r.default;
|
|
1613
753
|
}
|
|
1614
|
-
})), hasProps:
|
|
754
|
+
})), hasProps: ie, invalid: I };
|
|
1615
755
|
},
|
|
1616
756
|
render() {
|
|
1617
|
-
return this.is ?
|
|
757
|
+
return this.is ? E(this.is, this.hasProps, this.$slots) : E(this.component, null, this.$slots);
|
|
1618
758
|
}
|
|
1619
759
|
});
|
|
1620
760
|
}
|
|
1621
|
-
function
|
|
761
|
+
function Ne(e, t) {
|
|
1622
762
|
return C({
|
|
1623
763
|
name: "VvFormWrapper",
|
|
1624
764
|
props: {
|
|
@@ -1651,71 +791,71 @@ function it(e, r) {
|
|
|
1651
791
|
"validateWrapper"
|
|
1652
792
|
],
|
|
1653
793
|
slots: Object,
|
|
1654
|
-
setup(n, { emit:
|
|
1655
|
-
const
|
|
1656
|
-
|
|
1657
|
-
if (
|
|
1658
|
-
|
|
794
|
+
setup(n, { emit: b }) {
|
|
795
|
+
const r = B(e), u = B(t, void 0), o = _(/* @__PURE__ */ new Map()), i = _(/* @__PURE__ */ new Map()), { name: l } = X(n), f = D(() => r?.invalid.value ? i.value.size > 0 : !1);
|
|
796
|
+
k(f, (O) => {
|
|
797
|
+
if (O) {
|
|
798
|
+
b("invalid");
|
|
1659
799
|
return;
|
|
1660
800
|
}
|
|
1661
|
-
|
|
801
|
+
b("valid");
|
|
1662
802
|
});
|
|
1663
|
-
const d =
|
|
1664
|
-
name:
|
|
803
|
+
const d = D(() => r?.readonly.value || n.readonly), c = {
|
|
804
|
+
name: N(l),
|
|
1665
805
|
errors: i,
|
|
1666
|
-
invalid:
|
|
1667
|
-
readonly:
|
|
1668
|
-
fields:
|
|
806
|
+
invalid: N(f),
|
|
807
|
+
readonly: N(d),
|
|
808
|
+
fields: o
|
|
1669
809
|
};
|
|
1670
|
-
|
|
1671
|
-
const
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
(
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
}),
|
|
1678
|
-
|
|
810
|
+
H(t, c);
|
|
811
|
+
const h = D(() => new Map(o.value));
|
|
812
|
+
k(
|
|
813
|
+
h,
|
|
814
|
+
(O, v) => {
|
|
815
|
+
u?.fields && (v.forEach((m, y) => {
|
|
816
|
+
O.has(y) || u?.fields.value.delete(y);
|
|
817
|
+
}), O.forEach((m, y) => {
|
|
818
|
+
u?.fields.value.has(y) || u?.fields.value.set(y, m);
|
|
1679
819
|
}));
|
|
1680
820
|
},
|
|
1681
821
|
{ deep: !0 }
|
|
1682
|
-
),
|
|
822
|
+
), k(
|
|
1683
823
|
i,
|
|
1684
|
-
(
|
|
1685
|
-
|
|
1686
|
-
if (
|
|
1687
|
-
const
|
|
1688
|
-
|
|
824
|
+
(O) => {
|
|
825
|
+
u?.errors && o.value.forEach((v) => {
|
|
826
|
+
if (O.has(v) || u.errors.value.delete(v), O.has(v)) {
|
|
827
|
+
const m = O.get(v);
|
|
828
|
+
m && u.errors.value.set(v, m);
|
|
1689
829
|
}
|
|
1690
830
|
});
|
|
1691
831
|
},
|
|
1692
832
|
{ deep: !0 }
|
|
1693
|
-
),
|
|
1694
|
-
if (!
|
|
833
|
+
), q(() => {
|
|
834
|
+
if (!r?.wrappers || !l.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 (r.wrappers.has(l.value)) {
|
|
839
|
+
console.warn(`[@volverjs/form-vue]: wrapper name "${l.value}" is already used`);
|
|
1700
840
|
return;
|
|
1701
841
|
}
|
|
1702
|
-
|
|
1703
|
-
}),
|
|
1704
|
-
|
|
842
|
+
r.wrappers.set(l.value, c);
|
|
843
|
+
}), U(() => {
|
|
844
|
+
r?.wrappers && l.value && r.wrappers.delete(l.value);
|
|
1705
845
|
});
|
|
1706
|
-
const
|
|
846
|
+
const g = () => r?.validate(void 0, { fields: new Set(o.value.values()) }) ?? Promise.resolve(!0);
|
|
1707
847
|
return {
|
|
1708
|
-
errors:
|
|
1709
|
-
fields:
|
|
848
|
+
errors: r?.errors,
|
|
849
|
+
fields: o,
|
|
1710
850
|
fieldsErrors: i,
|
|
1711
|
-
formData:
|
|
1712
|
-
invalid:
|
|
851
|
+
formData: r?.formData,
|
|
852
|
+
invalid: f,
|
|
1713
853
|
readonly: d,
|
|
1714
|
-
clear:
|
|
1715
|
-
reset:
|
|
1716
|
-
submit:
|
|
1717
|
-
validate:
|
|
1718
|
-
validateWrapper:
|
|
854
|
+
clear: r?.clear,
|
|
855
|
+
reset: r?.reset,
|
|
856
|
+
submit: r?.submit,
|
|
857
|
+
validate: r?.validate,
|
|
858
|
+
validateWrapper: g
|
|
1719
859
|
};
|
|
1720
860
|
},
|
|
1721
861
|
render() {
|
|
@@ -1731,13 +871,13 @@ function it(e, r) {
|
|
|
1731
871
|
validate: this.validate,
|
|
1732
872
|
validateWrapper: this.validateWrapper
|
|
1733
873
|
});
|
|
1734
|
-
return this.tag ?
|
|
874
|
+
return this.tag ? E(this.tag, null, {
|
|
1735
875
|
default: n
|
|
1736
876
|
}) : n();
|
|
1737
877
|
}
|
|
1738
878
|
});
|
|
1739
879
|
}
|
|
1740
|
-
function
|
|
880
|
+
function $e(e, t) {
|
|
1741
881
|
const n = C({
|
|
1742
882
|
name: "VvFormTemplate",
|
|
1743
883
|
props: {
|
|
@@ -1751,174 +891,174 @@ function ut(e, r) {
|
|
|
1751
891
|
}
|
|
1752
892
|
},
|
|
1753
893
|
slots: Object,
|
|
1754
|
-
setup(
|
|
1755
|
-
const
|
|
1756
|
-
if (
|
|
894
|
+
setup(b, { slots: r }) {
|
|
895
|
+
const u = B(e);
|
|
896
|
+
if (u?.formData)
|
|
1757
897
|
return () => {
|
|
1758
|
-
const
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
) :
|
|
898
|
+
const o = typeof b.schema == "function" ? b.schema(
|
|
899
|
+
u,
|
|
900
|
+
b.scope
|
|
901
|
+
) : b.schema;
|
|
1762
902
|
let i;
|
|
1763
|
-
const
|
|
1764
|
-
const c = typeof d == "function" ? d(
|
|
1765
|
-
vvIs:
|
|
1766
|
-
vvName:
|
|
1767
|
-
vvSlots:
|
|
1768
|
-
vvChildren:
|
|
1769
|
-
vvIf:
|
|
903
|
+
const l = o.reduce((f, d) => {
|
|
904
|
+
const c = typeof d == "function" ? d(u, b.scope) : d, {
|
|
905
|
+
vvIs: h,
|
|
906
|
+
vvName: g,
|
|
907
|
+
vvSlots: O,
|
|
908
|
+
vvChildren: v,
|
|
909
|
+
vvIf: m,
|
|
1770
910
|
vvElseIf: y,
|
|
1771
|
-
vvType:
|
|
1772
|
-
vvDefaultValue:
|
|
1773
|
-
vvShowValid:
|
|
1774
|
-
vvContent:
|
|
1775
|
-
...
|
|
911
|
+
vvType: x,
|
|
912
|
+
vvDefaultValue: I,
|
|
913
|
+
vvShowValid: A,
|
|
914
|
+
vvContent: w,
|
|
915
|
+
...S
|
|
1776
916
|
} = c;
|
|
1777
|
-
if (
|
|
1778
|
-
if (typeof
|
|
1779
|
-
new Object(
|
|
1780
|
-
|
|
1781
|
-
) : typeof
|
|
1782
|
-
return
|
|
917
|
+
if (m !== void 0) {
|
|
918
|
+
if (typeof m == "string" ? i = !!L(
|
|
919
|
+
new Object(u.formData.value),
|
|
920
|
+
m
|
|
921
|
+
) : typeof m == "function" ? i = P(m(u)) : i = P(m), !i)
|
|
922
|
+
return f;
|
|
1783
923
|
} else if (y !== void 0 && i !== void 0) {
|
|
1784
|
-
if (i || (typeof y == "string" ? i = !!
|
|
1785
|
-
new Object(
|
|
924
|
+
if (i || (typeof y == "string" ? i = !!L(
|
|
925
|
+
new Object(u.formData.value),
|
|
1786
926
|
y
|
|
1787
|
-
) : typeof y == "function" ? i =
|
|
1788
|
-
return
|
|
927
|
+
) : typeof y == "function" ? i = P(y(u)) : i = P(y), !i))
|
|
928
|
+
return f;
|
|
1789
929
|
} else
|
|
1790
930
|
i = void 0;
|
|
1791
|
-
let
|
|
1792
|
-
return
|
|
1793
|
-
schema:
|
|
1794
|
-
}) :
|
|
1795
|
-
default: (
|
|
1796
|
-
schema:
|
|
1797
|
-
scope:
|
|
931
|
+
let a;
|
|
932
|
+
return v && (typeof h == "string" ? a = E(n, {
|
|
933
|
+
schema: v
|
|
934
|
+
}) : a = {
|
|
935
|
+
default: (j) => E(n, {
|
|
936
|
+
schema: v,
|
|
937
|
+
scope: j
|
|
1798
938
|
})
|
|
1799
|
-
}),
|
|
1800
|
-
|
|
1801
|
-
|
|
939
|
+
}), g ? (f.push(
|
|
940
|
+
E(
|
|
941
|
+
t,
|
|
1802
942
|
{
|
|
1803
|
-
name:
|
|
1804
|
-
is:
|
|
1805
|
-
type:
|
|
1806
|
-
defaultValue:
|
|
1807
|
-
showValid:
|
|
1808
|
-
props:
|
|
943
|
+
name: g,
|
|
944
|
+
is: h,
|
|
945
|
+
type: x,
|
|
946
|
+
defaultValue: I,
|
|
947
|
+
showValid: A,
|
|
948
|
+
props: S
|
|
1809
949
|
},
|
|
1810
|
-
|
|
950
|
+
O ?? a ?? w
|
|
1811
951
|
)
|
|
1812
|
-
),
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
952
|
+
), f) : h ? (f.push(
|
|
953
|
+
E(
|
|
954
|
+
h,
|
|
955
|
+
S,
|
|
956
|
+
O ?? a ?? w
|
|
1817
957
|
)
|
|
1818
|
-
),
|
|
958
|
+
), f) : (a && ("default" in a ? f.push(a.default(b.scope)) : f.push(a)), f);
|
|
1819
959
|
}, []);
|
|
1820
|
-
return
|
|
1821
|
-
|
|
1822
|
-
errors:
|
|
1823
|
-
formData:
|
|
1824
|
-
invalid:
|
|
1825
|
-
status:
|
|
1826
|
-
submit:
|
|
1827
|
-
validate:
|
|
1828
|
-
clear:
|
|
1829
|
-
reset:
|
|
960
|
+
return l.push(
|
|
961
|
+
r?.default?.({
|
|
962
|
+
errors: u?.errors.value,
|
|
963
|
+
formData: u?.formData.value,
|
|
964
|
+
invalid: u?.invalid.value,
|
|
965
|
+
status: u?.status.value,
|
|
966
|
+
submit: u?.submit,
|
|
967
|
+
validate: u?.validate,
|
|
968
|
+
clear: u?.clear,
|
|
969
|
+
reset: u?.reset
|
|
1830
970
|
})
|
|
1831
|
-
),
|
|
971
|
+
), l;
|
|
1832
972
|
};
|
|
1833
973
|
}
|
|
1834
974
|
});
|
|
1835
975
|
return n;
|
|
1836
976
|
}
|
|
1837
|
-
function
|
|
1838
|
-
const n = Symbol("formInjectionKey"),
|
|
977
|
+
function T(e, t = {}) {
|
|
978
|
+
const n = Symbol("formInjectionKey"), b = Symbol("formWrapperInjectionKey"), r = Symbol("formFieldInjectionKey"), u = Symbol("formFieldsGroupInjectionKey"), o = Ne(
|
|
1839
979
|
n,
|
|
1840
|
-
|
|
1841
|
-
), i =
|
|
980
|
+
b
|
|
981
|
+
), i = Fe(
|
|
1842
982
|
n,
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
),
|
|
983
|
+
b,
|
|
984
|
+
r,
|
|
985
|
+
t
|
|
986
|
+
), l = ke(
|
|
1847
987
|
n,
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
),
|
|
988
|
+
b,
|
|
989
|
+
u
|
|
990
|
+
), f = $e(n, i), d = /* @__PURE__ */ new Map(), {
|
|
1851
991
|
clear: c,
|
|
1852
|
-
errors:
|
|
1853
|
-
formData:
|
|
1854
|
-
ignoreUpdates:
|
|
1855
|
-
invalid:
|
|
1856
|
-
readonly:
|
|
992
|
+
errors: h,
|
|
993
|
+
formData: g,
|
|
994
|
+
ignoreUpdates: O,
|
|
995
|
+
invalid: v,
|
|
996
|
+
readonly: m,
|
|
1857
997
|
reset: y,
|
|
1858
|
-
status:
|
|
1859
|
-
stopUpdatesWatch:
|
|
1860
|
-
submit:
|
|
1861
|
-
validate:
|
|
1862
|
-
VvForm:
|
|
1863
|
-
} =
|
|
998
|
+
status: x,
|
|
999
|
+
stopUpdatesWatch: I,
|
|
1000
|
+
submit: A,
|
|
1001
|
+
validate: w,
|
|
1002
|
+
VvForm: S
|
|
1003
|
+
} = Ae(e, n, t, f, d);
|
|
1864
1004
|
return {
|
|
1865
1005
|
clear: c,
|
|
1866
|
-
errors:
|
|
1867
|
-
formData:
|
|
1868
|
-
formFieldInjectionKey:
|
|
1006
|
+
errors: h,
|
|
1007
|
+
formData: g,
|
|
1008
|
+
formFieldInjectionKey: r,
|
|
1869
1009
|
formInjectionKey: n,
|
|
1870
|
-
formWrapperInjectionKey:
|
|
1871
|
-
ignoreUpdates:
|
|
1872
|
-
invalid:
|
|
1873
|
-
readonly:
|
|
1010
|
+
formWrapperInjectionKey: b,
|
|
1011
|
+
ignoreUpdates: O,
|
|
1012
|
+
invalid: v,
|
|
1013
|
+
readonly: m,
|
|
1874
1014
|
reset: y,
|
|
1875
|
-
status:
|
|
1876
|
-
stopUpdatesWatch:
|
|
1877
|
-
submit:
|
|
1878
|
-
validate:
|
|
1015
|
+
status: x,
|
|
1016
|
+
stopUpdatesWatch: I,
|
|
1017
|
+
submit: A,
|
|
1018
|
+
validate: w,
|
|
1879
1019
|
wrappers: d,
|
|
1880
|
-
VvForm:
|
|
1020
|
+
VvForm: S,
|
|
1881
1021
|
VvFormField: i,
|
|
1882
|
-
VvFormFieldsGroup:
|
|
1883
|
-
VvFormTemplate:
|
|
1884
|
-
VvFormWrapper:
|
|
1022
|
+
VvFormFieldsGroup: l,
|
|
1023
|
+
VvFormTemplate: f,
|
|
1024
|
+
VvFormWrapper: o
|
|
1885
1025
|
};
|
|
1886
1026
|
}
|
|
1887
|
-
const
|
|
1888
|
-
function
|
|
1889
|
-
let
|
|
1890
|
-
return e.schema && (
|
|
1891
|
-
...
|
|
1892
|
-
install(n, { global:
|
|
1893
|
-
n.provide(
|
|
1027
|
+
const le = Symbol("pluginInjectionKey");
|
|
1028
|
+
function Ue(e) {
|
|
1029
|
+
let t = {};
|
|
1030
|
+
return e.schema && (t = T(e.schema, e)), {
|
|
1031
|
+
...t,
|
|
1032
|
+
install(n, { global: b = !1 } = {}) {
|
|
1033
|
+
n.provide(le, e), b && (n.config.globalProperties.$vvForm = e, t?.VvForm && n.component("VvForm", t.VvForm), t?.VvFormWrapper && n.component("VvFormWrapper", t.VvFormWrapper), t?.VvFormField && n.component("VvFormField", t.VvFormField), t?.VvFormFieldsGroup && n.component("VvFormFieldsGroup", t.VvFormFieldsGroup), t?.VvFormTemplate && n.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 M = /* @__PURE__ */ new Map();
|
|
1038
|
+
function Ce(e, t = {}) {
|
|
1039
|
+
if (t.scope && M.has(t.scope))
|
|
1040
|
+
return M.get(t.scope);
|
|
1041
|
+
if (!ve()) {
|
|
1042
|
+
const b = T(e, t);
|
|
1043
|
+
return t.scope && M.set(t.scope, b), b;
|
|
1904
1044
|
}
|
|
1905
|
-
const n =
|
|
1045
|
+
const n = T(
|
|
1906
1046
|
e,
|
|
1907
1047
|
{
|
|
1908
|
-
...
|
|
1909
|
-
...
|
|
1048
|
+
...B(le, {}),
|
|
1049
|
+
...t
|
|
1910
1050
|
}
|
|
1911
1051
|
);
|
|
1912
|
-
return
|
|
1052
|
+
return t.scope && M.set(t.scope, n), n;
|
|
1913
1053
|
}
|
|
1914
|
-
function
|
|
1915
|
-
return
|
|
1054
|
+
function Ke(e, t = {}) {
|
|
1055
|
+
return T(e, t);
|
|
1916
1056
|
}
|
|
1917
1057
|
export {
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1058
|
+
V as FormFieldType,
|
|
1059
|
+
Ue as createForm,
|
|
1060
|
+
J as defaultObjectBySchema,
|
|
1061
|
+
Ke as formType,
|
|
1062
|
+
le as pluginInjectionKey,
|
|
1063
|
+
Ce as useForm
|
|
1924
1064
|
};
|