@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 CHANGED
@@ -1,961 +1,164 @@
1
- import { ref as Z, computed as E, readonly as R, defineComponent as C, h as N, withModifiers as ue, toRaw as T, watch as $, isProxy as Ie, onMounted as ee, provide as te, toRefs as se, useId as de, inject as J, onBeforeUnmount as G, unref as M, resolveComponent as A, defineAsyncComponent as De, getCurrentInstance as Ne } from "vue";
2
- import { watchIgnorable as Pe, throttleFilter as $e } from "@vueuse/core";
3
- var k = /* @__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))(k || {}), D = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e.submitting = "submitting", e.reset = "reset", e.updated = "updated", e.unknown = "unknown", e))(D || {}), B;
4
- (function(e) {
5
- e.assertEqual = (t) => {
6
- };
7
- function r(t) {
8
- }
9
- e.assertIs = r;
10
- function n(t) {
11
- throw new Error();
12
- }
13
- e.assertNever = n, e.arrayToEnum = (t) => {
14
- const o = {};
15
- for (const s of t)
16
- o[s] = s;
17
- return o;
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 He(e) {
19
+ function Se(e) {
817
20
  return Array.isArray(e) ? "array" : e === null ? "null" : typeof e;
818
21
  }
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;
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 F(e, r) {
26
+ function W(e, t) {
824
27
  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;
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 F(i, r);
35
+ return W(i, t);
833
36
  }
834
37
  }
835
- return F(e.anyOf[0], r);
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 r == "string" ? r : e.default;
43
+ return typeof t == "string" ? t : e.default;
841
44
  case "number":
842
45
  case "integer":
843
- return typeof r == "number" ? r : e.default;
46
+ return typeof t == "number" ? t : e.default;
844
47
  case "boolean":
845
- return typeof r == "boolean" ? r : e.default;
48
+ return typeof t == "boolean" ? t : e.default;
846
49
  case "null":
847
- return r === null ? r : e.default;
50
+ return t === null ? t : e.default;
848
51
  case "array":
849
- return Array.isArray(r) && e.items ? r.map((s) => F(e.items, s)) : e.default;
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, 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);
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 (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);
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 o;
66
+ return u;
864
67
  }
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);
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 = q(e);
875
- return W(n) ? {
876
- ...n._def.unknownKeys === "passthrough" ? r : {},
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
- ([t, o]) => {
880
- const s = r[t], i = qe(o);
881
- let f = q(o), m;
882
- if (Le(f) && (m = f._def.defaultValue(), f = f._def.innerType), s === null && Ce(f))
883
- return [t, s];
884
- if (s == null && i)
885
- return [t, m];
886
- if (f) {
887
- const d = o.safeParse(s);
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 [t, d.data ?? m];
92
+ return [r, d.data ?? f];
890
93
  }
891
- if (We(f) && Array.isArray(s) && s.length) {
892
- const d = q(f._def.type);
893
- if (W(d))
94
+ if (De(l) && Array.isArray(o) && o.length) {
95
+ const d = z(l._def.type);
96
+ if (K(d))
894
97
  return [
895
- t,
896
- s.map(
897
- (c) => Q(
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 (Ke(f) && s) {
905
- const d = q(f._def.valueType);
906
- if (W(d))
907
- return [t, Object.keys(s).reduce((c, g) => (c[g] = Q(d, s[g]), c), {})];
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 W(f) ? [
910
- t,
911
- Q(
912
- f,
913
- s && typeof s == "object" ? s : m
112
+ return K(l) ? [
113
+ r,
114
+ J(
115
+ l,
116
+ o && typeof o == "object" ? o : f
914
117
  )
915
- ] : [t, m];
118
+ ] : [r, f];
916
119
  }
917
120
  )
918
121
  )
919
- } : r;
122
+ } : t;
920
123
  }
921
- const Xe = (e, r) => re(e) ? Me(e, r) : e.safeParseAsync(r), Ye = (e, r) => re(e) ? ge(r) : r.format(), et = (e, r) => re(e) ? ge(new ye(r)) : new L(r).format();
922
- function tt(e, r, n, u, t) {
923
- const o = Z(), s = Z(), i = E(() => s.value === D.invalid), f = Z(), m = Z(!1);
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 V = Q(e, _);
128
+ const c = (w) => {
129
+ const S = J(e, w);
927
130
  if (n?.class) {
928
- const v = n.class;
929
- return new v(V);
131
+ const a = n.class;
132
+ return new a(S);
930
133
  }
931
- return V;
932
- }, g = async (_ = f.value, V) => {
933
- if (d = V?.fields, m.value)
134
+ return S;
135
+ }, h = async (w = l.value, S) => {
136
+ if (d = S?.fields, f.value)
934
137
  return !0;
935
- const v = await Xe(e, _);
936
- if (!v.success) {
937
- if (s.value = D.invalid, !d?.size)
938
- return o.value = Ye(e, v.error), !1;
939
- const S = v.error.issues.filter(
940
- (z) => d?.has(z.path.join("."))
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 S.length ? (o.value = et(e, S), !1) : (o.value = void 0, !0);
145
+ return j.length ? (u.value = Ee(e, j), !1) : (u.value = void 0, !0);
943
146
  }
944
- return o.value = void 0, s.value = D.valid, f.value = c(v.data), !0;
945
- }, h = () => {
946
- o.value = void 0, s.value = void 0, d = void 0;
947
- }, a = () => {
948
- f.value = c(), h(), s.value = D.reset;
949
- }, l = async (_) => m.value || !await g(void 0, _) ? !1 : (s.value = D.submitting, !0), { ignoreUpdates: p, stop: y } = Pe(
950
- f,
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
- s.value = D.updated;
155
+ o.value = R.updated;
953
156
  },
954
157
  {
955
158
  deep: !0,
956
- eventFilter: $e(n?.updateThrottle ?? 500)
159
+ eventFilter: me(n?.updateThrottle ?? 500)
957
160
  }
958
- ), w = R(o), O = R(s), x = C({
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(_, { emit: V }) {
1013
- return f.value = c(T(_.modelValue)), $(
1014
- () => _.modelValue,
1015
- (v) => {
1016
- if (v) {
1017
- const S = Ie(v) ? T(v) : v;
1018
- if (JSON.stringify(S) === JSON.stringify(T(f.value)))
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
- f.value = typeof S?.clone == "function" ? S.clone() : JSON.parse(JSON.stringify(S));
223
+ l.value = typeof j?.clone == "function" ? j.clone() : JSON.parse(JSON.stringify(j));
1021
224
  }
1022
225
  },
1023
226
  { deep: !0 }
1024
- ), $(s, async (v) => {
1025
- if (v === D.invalid) {
1026
- const S = T(o.value);
1027
- V("invalid", S), n?.onInvalid?.(
1028
- S
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 (v === D.valid) {
1033
- const S = T(f.value);
1034
- V("valid", S), n?.onValid?.(S), V("update:modelValue", S), n?.onUpdate?.(S);
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 (v === D.submitting) {
1038
- const S = T(f.value);
1039
- V("submit", S), n?.onSubmit?.(S);
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 (v === D.reset) {
1043
- const S = T(f.value);
1044
- V("reset", S), n?.onReset?.(S);
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 (v === D.updated) {
1048
- if ((o.value || n?.continuousValidation || _.continuousValidation) && await g(void 0, {
1049
- superRefine: _.superRefine,
1050
- fields: d ?? new Set(_.validateFields)
1051
- }), !f.value || !_.modelValue || JSON.stringify(f.value) !== JSON.stringify(_.modelValue)) {
1052
- const S = T(f.value);
1053
- V("update:modelValue", S), n?.onUpdate?.(S);
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
- s.value === D.updated && (s.value = D.unknown);
258
+ o.value === R.updated && (o.value = R.unknown);
1056
259
  }
1057
- }), ee(() => {
1058
- _.readonly !== void 0 && (m.value = _.readonly);
1059
- }), $(
1060
- () => _.readonly,
1061
- (v) => {
1062
- m.value = v;
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
- ), $(m, (v) => {
1065
- v !== _.readonly && V("update:readonly", m.value);
1066
- }), te(r, {
1067
- clear: h,
1068
- errors: w,
1069
- formData: f,
1070
- ignoreUpdates: p,
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: m,
1073
- reset: a,
1074
- status: O,
275
+ readonly: f,
276
+ reset: O,
277
+ status: I,
1075
278
  stopUpdatesWatch: y,
1076
- submit: l,
1077
- validate: g,
1078
- wrappers: t
279
+ submit: v,
280
+ validate: h,
281
+ wrappers: r
1079
282
  }), {
1080
- clear: h,
1081
- errors: w,
1082
- formData: f,
1083
- ignoreUpdates: p,
283
+ clear: g,
284
+ errors: x,
285
+ formData: l,
286
+ ignoreUpdates: m,
1084
287
  invalid: i,
1085
- isReadonly: m,
1086
- reset: a,
1087
- status: O,
288
+ isReadonly: f,
289
+ reset: O,
290
+ status: I,
1088
291
  stopUpdatesWatch: y,
1089
- submit: () => l({
1090
- superRefine: _.superRefine,
1091
- fields: new Set(_.validateFields)
292
+ submit: () => v({
293
+ superRefine: w.superRefine,
294
+ fields: new Set(w.validateFields)
1092
295
  }),
1093
- validate: g,
1094
- wrappers: t
296
+ validate: h,
297
+ wrappers: r
1095
298
  };
1096
299
  },
1097
300
  render() {
1098
- const _ = () => this.$slots?.default?.({
1099
- errors: w.value,
1100
- formData: f.value,
301
+ const w = () => this.$slots?.default?.({
302
+ errors: x.value,
303
+ formData: l.value,
1101
304
  invalid: i.value,
1102
- readonly: m.value,
1103
- status: O.value,
1104
- wrappers: t,
1105
- clear: h,
1106
- ignoreUpdates: p,
1107
- reset: a,
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: l,
1110
- validate: g
312
+ submit: v,
313
+ validate: h
1111
314
  }) ?? this.$slots.default;
1112
- return N(
315
+ return E(
1113
316
  this.tag,
1114
317
  {
1115
- onSubmit: ue(this.submit, ["prevent"]),
1116
- onReset: ue(this.reset, ["prevent"])
318
+ onSubmit: te(this.submit, ["prevent"]),
319
+ onReset: te(this.reset, ["prevent"])
1117
320
  },
1118
- (this.template ?? n?.template) && u ? [
1119
- N(
1120
- u,
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: h,
1136
- errors: o,
1137
- formData: f,
1138
- ignoreUpdates: p,
338
+ clear: g,
339
+ errors: u,
340
+ formData: l,
341
+ ignoreUpdates: m,
1139
342
  invalid: i,
1140
- readonly: m,
1141
- reset: a,
1142
- status: s,
1143
- wrappers: t,
343
+ readonly: f,
344
+ reset: O,
345
+ status: o,
346
+ wrappers: r,
1144
347
  stopUpdatesWatch: y,
1145
- submit: l,
1146
- validate: g,
1147
- VvForm: x
348
+ submit: v,
349
+ validate: h,
350
+ VvForm: A
1148
351
  };
1149
352
  }
1150
- function ne(e) {
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: (t) => Object.values(k).includes(t),
1220
- default: k.custom
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(t, { slots: o, emit: s }) {
1268
- const { props: i, name: f } = se(t), m = de(), d = J(r, void 0);
1269
- d && d.fields.value.set(m, t.name);
1270
- const c = J(e), g = E({
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 U(
413
+ return L(
1274
414
  new Object(c.formData.value),
1275
- String(t.name)
415
+ String(r.name)
1276
416
  );
1277
417
  },
1278
- set(v) {
1279
- c?.formData && (ae(
418
+ set(a) {
419
+ c?.formData && (ne(
1280
420
  new Object(c.formData.value),
1281
- String(t.name),
1282
- v
1283
- ), s("update:modelValue", {
1284
- newValue: g.value,
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
- ee(() => {
1290
- g.value === void 0 && t.defaultValue !== void 0 && (g.value = t.defaultValue);
1291
- }), G(() => {
1292
- d && d.fields.value.delete(m);
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 h = E(() => {
434
+ const g = D(() => {
1295
435
  if (c?.errors.value)
1296
- return U(c.errors.value, String(t.name));
1297
- }), a = E(() => h.value?._errors), l = E(() => h.value !== void 0), p = $(l, (v) => {
1298
- if (v) {
1299
- s("invalid", h.value), d && d.errors.value.set(
1300
- String(t.name),
1301
- h.value
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
- s("valid", g.value), d && d.errors.value.delete(
1306
- t.name
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
- s("update:formData", c?.formData);
451
+ o("update:formData", c?.formData);
1312
452
  },
1313
453
  { deep: !0 }
1314
454
  );
1315
- G(() => {
1316
- p(), y();
455
+ U(() => {
456
+ m(), y();
1317
457
  });
1318
- const w = (v) => {
1319
- v instanceof InputEvent && (v = v.target.value), g.value = v;
1320
- }, O = E(() => {
1321
- let v = i.value;
1322
- return typeof v == "function" && (v = v(c?.formData)), Object.keys(v).reduce(
1323
- (S, z) => (S[z] = M(v[z]), S),
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
- }), x = E(() => c?.readonly.value || d?.readonly.value ? !0 : O.value.readonly ?? t.readonly), _ = E(() => ({
1327
- ...O.value,
1328
- name: O.value.name ?? t.name,
1329
- invalid: l.value,
1330
- valid: t.showValid ? !!(!l.value && g.value) : void 0,
1331
- type: ((v) => {
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
- k.color,
1334
- k.date,
1335
- k.datetimeLocal,
1336
- k.email,
1337
- k.month,
1338
- k.number,
1339
- k.password,
1340
- k.search,
1341
- k.tel,
1342
- k.text,
1343
- k.time,
1344
- k.url,
1345
- k.week
1346
- ].includes(v))
1347
- return v;
1348
- })(t.type),
1349
- invalidLabel: a.value,
1350
- modelValue: g.value,
1351
- readonly: x.value,
1352
- "onUpdate:modelValue": w
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 te(n, {
1355
- name: R(f),
1356
- errors: R(h)
1357
- }), { component: E(() => {
1358
- if (t.type === k.custom)
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 o.default?.({
1362
- errors: h.value,
501
+ return u.default?.({
502
+ errors: g.value,
1363
503
  formData: c?.formData.value,
1364
504
  formErrors: c?.errors.value,
1365
- invalid: l.value,
1366
- invalidLabel: a.value,
1367
- modelValue: g.value,
1368
- readonly: x.value,
1369
- onUpdate: w,
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
- }) ?? o.default;
512
+ }) ?? u.default;
1373
513
  }
1374
514
  };
1375
- if (!(u?.lazyLoad ?? t.lazyLoad)) {
1376
- let v;
1377
- switch (t.type) {
1378
- case k.select:
1379
- v = A("VvSelect");
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 k.checkbox:
1382
- v = A("VvCheckbox");
521
+ case V.checkbox:
522
+ a = Z("VvCheckbox");
1383
523
  break;
1384
- case k.radio:
1385
- v = A("VvRadio");
524
+ case V.radio:
525
+ a = Z("VvRadio");
1386
526
  break;
1387
- case k.textarea:
1388
- v = A("VvTextarea");
527
+ case V.textarea:
528
+ a = Z("VvTextarea");
1389
529
  break;
1390
- case k.radioGroup:
1391
- v = A("VvRadioGroup");
530
+ case V.radioGroup:
531
+ a = Z("VvRadioGroup");
1392
532
  break;
1393
- case k.checkboxGroup:
1394
- v = A("VvCheckboxGroup");
533
+ case V.checkboxGroup:
534
+ a = Z("VvCheckboxGroup");
1395
535
  break;
1396
- case k.combobox:
1397
- v = A("VvCombobox");
536
+ case V.combobox:
537
+ a = Z("VvCombobox");
1398
538
  break;
1399
539
  default:
1400
- v = A("VvInputText");
540
+ a = Z("VvInputText");
1401
541
  }
1402
- if (typeof v != "string")
1403
- return v;
542
+ if (typeof a != "string")
543
+ return a;
1404
544
  console.warn(
1405
- `[@volverjs/form-vue]: ${v} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
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 De(async () => {
1409
- switch (u?.sideEffects && await Promise.resolve(u.sideEffects(t.type)), t.type) {
1410
- case k.textarea:
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 k.radio:
552
+ case V.radio:
1413
553
  return import("@volverjs/ui-vue/vv-radio");
1414
- case k.radioGroup:
554
+ case V.radioGroup:
1415
555
  return import("@volverjs/ui-vue/vv-radio-group");
1416
- case k.checkbox:
556
+ case V.checkbox:
1417
557
  return import("@volverjs/ui-vue/vv-checkbox");
1418
- case k.checkboxGroup:
558
+ case V.checkboxGroup:
1419
559
  return import("@volverjs/ui-vue/vv-checkbox-group");
1420
- case k.select:
560
+ case V.select:
1421
561
  return import("@volverjs/ui-vue/vv-select");
1422
- case k.combobox:
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: _, invalid: l };
567
+ }), hasProps: w, invalid: v };
1428
568
  },
1429
569
  render() {
1430
- return this.is ? N(this.is, this.hasProps, this.$slots) : this.type === k.custom ? N(this.component, null, this.$slots) : N(this.component, this.hasProps, this.$slots);
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 ot(e, r, n) {
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(u, { slots: t, emit: o }) {
1479
- const { props: s, names: i, defaultValues: f } = se(u), m = de(), d = E(() => Array.isArray(i.value) ? i.value : Object.values(i.value)), c = E(() => Array.isArray(i.value) ? i.value : Object.keys(i.value)), g = E(() => Array.isArray(i.value) ? i.value.reduce((b, j) => (b[String(j)] = j, b), {}) : i.value), h = E(() => Object.keys(g.value).reduce((b, j) => (b[String(g.value[j])] = j, b), {})), a = J(r, void 0);
1480
- a && d.value.forEach((b) => {
1481
- a.fields.value.set(`${m}-${b}`, b);
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 l = J(e), p = E({
623
+ const v = B(e), m = D({
1484
624
  get() {
1485
- return l?.formData ? c.value.reduce((b, j) => (b[j] = U(
1486
- new Object(l.formData.value),
1487
- g.value[j]
1488
- ), b), {}) : {};
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(b) {
1491
- l?.formData && (c.value.forEach((j) => {
1492
- ae(
1493
- new Object(l.formData.value),
1494
- g.value[j],
1495
- b?.[j]
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
- }), o("update:modelValue", {
1498
- newValue: p.value,
1499
- formData: l?.formData
637
+ }), u("update:modelValue", {
638
+ newValue: m.value,
639
+ formData: v?.formData
1500
640
  }));
1501
641
  }
1502
642
  });
1503
- ee(() => {
1504
- f.value && d.value.forEach((b) => {
1505
- f.value?.[b] !== void 0 && p.value[b] === void 0 && (p.value = {
1506
- ...p.value,
1507
- [b]: f.value?.[b]
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
- }), G(() => {
1511
- a && d.value.forEach((b) => {
1512
- a.fields.value.delete(
1513
- `${m}-${b}`
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 = E(() => {
1518
- if (!l?.errors.value)
657
+ const y = D(() => {
658
+ if (!v?.errors.value)
1519
659
  return;
1520
- const b = d.value.reduce((j, P) => {
1521
- if (!l.errors.value)
1522
- return j;
1523
- const ie = U(l.errors.value, String(P));
1524
- return ie === void 0 || (j[String(P)] = ie), j;
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(b).length !== 0)
1527
- return b;
1528
- }), w = E(() => {
666
+ if (Object.keys(s).length !== 0)
667
+ return s;
668
+ }), x = D(() => {
1529
669
  if (!y.value)
1530
670
  return;
1531
- const b = Object.keys(y.value).reduce((j, P) => (y.value?.[P] && (j[h.value[P]] = y.value[P]._errors), j), {});
1532
- if (Object.keys(b).length !== 0)
1533
- return b;
1534
- }), O = E(() => y.value !== void 0), x = E(() => c.value.reduce((b, j) => (b[j] = !!y.value?.[h.value[j]], b), {})), _ = $(O, () => {
1535
- if (O.value) {
1536
- o("invalid", y.value), a && d.value.forEach((b) => {
1537
- if (!y.value?.[b]) {
1538
- a.errors.value.delete(
1539
- b
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
- a.errors.value.set(
1544
- b,
1545
- y.value?.[b]
683
+ O.errors.value.set(
684
+ s,
685
+ y.value?.[s]
1546
686
  );
1547
687
  });
1548
688
  return;
1549
689
  }
1550
- o("valid", p.value), a && d.value.forEach((b) => {
1551
- a.errors.value.delete(
1552
- b
690
+ u("valid", m.value), O && d.value.forEach((s) => {
691
+ O.errors.value.delete(
692
+ s
1553
693
  );
1554
694
  });
1555
- }), V = $(
1556
- () => l?.formData,
695
+ }), S = k(
696
+ () => v?.formData,
1557
697
  () => {
1558
- o("update:formData", l?.formData);
698
+ u("update:formData", v?.formData);
1559
699
  },
1560
700
  { deep: !0 }
1561
701
  );
1562
- G(() => {
1563
- _(), V();
702
+ U(() => {
703
+ w(), S();
1564
704
  });
1565
- const v = (b) => {
1566
- p.value = b;
1567
- }, S = (b, j) => {
1568
- j instanceof InputEvent && (j = j.target.value), c.value.includes(b) && (p.value = {
1569
- ...p.value,
1570
- [b]: j
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
- }, z = E(() => {
1573
- let b = s.value;
1574
- return typeof b == "function" && (b = b(l?.formData)), Object.keys(b).reduce(
1575
- (j, P) => (j[P] = M(b[P]), j),
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
- }), oe = E(() => l?.readonly.value ? !0 : z.value.readonly ?? u.readonly), xe = E(() => c.value.reduce((b, j) => (b[`onUpdate:${j}`] = (P) => {
1579
- S(j, P);
1580
- }, b), {
1581
- "onUpdate:modelValue": v
1582
- })), Ve = E(() => ({
1583
- ...xe.value,
1584
- ...z.value,
1585
- ...p.value,
1586
- modelValue: p.value,
1587
- names: z.value.name ?? d.value,
1588
- invalid: O.value,
1589
- invalids: x.value,
1590
- valid: u.showValid ? !!(!O.value && p.value) : void 0,
1591
- invalidLabels: w.value,
1592
- readonly: oe.value
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 te(n, {
1595
- names: R(i),
1596
- errors: R(y)
1597
- }), { component: E(() => ({
734
+ return H(n, {
735
+ names: N(i),
736
+ errors: N(y)
737
+ }), { component: D(() => ({
1598
738
  render() {
1599
- return t.default?.({
739
+ return r.default?.({
1600
740
  errors: y.value,
1601
- formData: l?.formData.value,
1602
- formErrors: l?.errors.value,
1603
- invalid: O.value,
1604
- invalids: x.value,
1605
- invalidLabels: w.value,
1606
- modelValue: p.value,
1607
- onUpdate: v,
1608
- onUpdateField: S,
1609
- readonly: oe.value,
1610
- submit: l?.submit,
1611
- validate: l?.validate
1612
- }) ?? t.default;
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: Ve, invalid: O };
754
+ })), hasProps: ie, invalid: I };
1615
755
  },
1616
756
  render() {
1617
- return this.is ? N(this.is, this.hasProps, this.$slots) : N(this.component, null, this.$slots);
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 it(e, r) {
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: u }) {
1655
- const t = J(e), o = J(r, void 0), s = Z(/* @__PURE__ */ new Map()), i = Z(/* @__PURE__ */ new Map()), { name: f } = se(n), m = E(() => t?.invalid.value ? i.value.size > 0 : !1);
1656
- $(m, (a) => {
1657
- if (a) {
1658
- u("invalid");
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
- u("valid");
801
+ b("valid");
1662
802
  });
1663
- const d = E(() => t?.readonly.value || n.readonly), c = {
1664
- name: R(f),
803
+ const d = D(() => r?.readonly.value || n.readonly), c = {
804
+ name: N(l),
1665
805
  errors: i,
1666
- invalid: R(m),
1667
- readonly: R(d),
1668
- fields: s
806
+ invalid: N(f),
807
+ readonly: N(d),
808
+ fields: o
1669
809
  };
1670
- te(r, c);
1671
- const g = E(() => new Map(s.value));
1672
- $(
1673
- g,
1674
- (a, l) => {
1675
- o?.fields && (l.forEach((p, y) => {
1676
- a.has(y) || o?.fields.value.delete(y);
1677
- }), a.forEach((p, y) => {
1678
- o?.fields.value.has(y) || o?.fields.value.set(y, p);
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
- (a) => {
1685
- o?.errors && s.value.forEach((l) => {
1686
- if (a.has(l) || o.errors.value.delete(l), a.has(l)) {
1687
- const p = a.get(l);
1688
- p && o.errors.value.set(l, p);
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
- ), ee(() => {
1694
- if (!t?.wrappers || !f.value) {
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 (t.wrappers.has(f.value)) {
1699
- console.warn(`[@volverjs/form-vue]: wrapper name "${f.value}" is already used`);
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
- t.wrappers.set(f.value, c);
1703
- }), G(() => {
1704
- t?.wrappers && f.value && t.wrappers.delete(f.value);
842
+ r.wrappers.set(l.value, c);
843
+ }), U(() => {
844
+ r?.wrappers && l.value && r.wrappers.delete(l.value);
1705
845
  });
1706
- const h = () => t?.validate(void 0, { fields: new Set(s.value.values()) }) ?? Promise.resolve(!0);
846
+ const g = () => r?.validate(void 0, { fields: new Set(o.value.values()) }) ?? Promise.resolve(!0);
1707
847
  return {
1708
- errors: t?.errors,
1709
- fields: s,
848
+ errors: r?.errors,
849
+ fields: o,
1710
850
  fieldsErrors: i,
1711
- formData: t?.formData,
1712
- invalid: m,
851
+ formData: r?.formData,
852
+ invalid: f,
1713
853
  readonly: d,
1714
- clear: t?.clear,
1715
- reset: t?.reset,
1716
- submit: t?.submit,
1717
- validate: t?.validate,
1718
- validateWrapper: h
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 ? N(this.tag, null, {
874
+ return this.tag ? E(this.tag, null, {
1735
875
  default: n
1736
876
  }) : n();
1737
877
  }
1738
878
  });
1739
879
  }
1740
- function ut(e, r) {
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(u, { slots: t }) {
1755
- const o = J(e);
1756
- if (o?.formData)
894
+ setup(b, { slots: r }) {
895
+ const u = B(e);
896
+ if (u?.formData)
1757
897
  return () => {
1758
- const s = typeof u.schema == "function" ? u.schema(
1759
- o,
1760
- u.scope
1761
- ) : u.schema;
898
+ const o = typeof b.schema == "function" ? b.schema(
899
+ u,
900
+ b.scope
901
+ ) : b.schema;
1762
902
  let i;
1763
- const f = s.reduce((m, d) => {
1764
- const c = typeof d == "function" ? d(o, u.scope) : d, {
1765
- vvIs: g,
1766
- vvName: h,
1767
- vvSlots: a,
1768
- vvChildren: l,
1769
- vvIf: p,
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: w,
1772
- vvDefaultValue: O,
1773
- vvShowValid: x,
1774
- vvContent: _,
1775
- ...V
911
+ vvType: x,
912
+ vvDefaultValue: I,
913
+ vvShowValid: A,
914
+ vvContent: w,
915
+ ...S
1776
916
  } = c;
1777
- if (p !== void 0) {
1778
- if (typeof p == "string" ? i = !!U(
1779
- new Object(o.formData.value),
1780
- p
1781
- ) : typeof p == "function" ? i = M(p(o)) : i = M(p), !i)
1782
- return m;
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 = !!U(
1785
- new Object(o.formData.value),
924
+ if (i || (typeof y == "string" ? i = !!L(
925
+ new Object(u.formData.value),
1786
926
  y
1787
- ) : typeof y == "function" ? i = M(y(o)) : i = M(y), !i))
1788
- return m;
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 v;
1792
- return l && (typeof g == "string" ? v = N(n, {
1793
- schema: l
1794
- }) : v = {
1795
- default: (S) => N(n, {
1796
- schema: l,
1797
- scope: S
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
- }), h ? (m.push(
1800
- N(
1801
- r,
939
+ }), g ? (f.push(
940
+ E(
941
+ t,
1802
942
  {
1803
- name: h,
1804
- is: g,
1805
- type: w,
1806
- defaultValue: O,
1807
- showValid: x,
1808
- props: V
943
+ name: g,
944
+ is: h,
945
+ type: x,
946
+ defaultValue: I,
947
+ showValid: A,
948
+ props: S
1809
949
  },
1810
- a ?? v ?? _
950
+ O ?? a ?? w
1811
951
  )
1812
- ), m) : g ? (m.push(
1813
- N(
1814
- g,
1815
- V,
1816
- a ?? v ?? _
952
+ ), f) : h ? (f.push(
953
+ E(
954
+ h,
955
+ S,
956
+ O ?? a ?? w
1817
957
  )
1818
- ), m) : (v && ("default" in v ? m.push(v.default(u.scope)) : m.push(v)), m);
958
+ ), f) : (a && ("default" in a ? f.push(a.default(b.scope)) : f.push(a)), f);
1819
959
  }, []);
1820
- return f.push(
1821
- t?.default?.({
1822
- errors: o?.errors.value,
1823
- formData: o?.formData.value,
1824
- invalid: o?.invalid.value,
1825
- status: o?.status.value,
1826
- submit: o?.submit,
1827
- validate: o?.validate,
1828
- clear: o?.clear,
1829
- reset: o?.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
- ), f;
971
+ ), l;
1832
972
  };
1833
973
  }
1834
974
  });
1835
975
  return n;
1836
976
  }
1837
- function Y(e, r = {}) {
1838
- const n = Symbol("formInjectionKey"), u = Symbol("formWrapperInjectionKey"), t = Symbol("formFieldInjectionKey"), o = Symbol("formFieldsGroupInjectionKey"), s = it(
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
- u
1841
- ), i = at(
980
+ b
981
+ ), i = Fe(
1842
982
  n,
1843
- u,
1844
- t,
1845
- r
1846
- ), f = ot(
983
+ b,
984
+ r,
985
+ t
986
+ ), l = ke(
1847
987
  n,
1848
- u,
1849
- o
1850
- ), m = ut(n, i), d = /* @__PURE__ */ new Map(), {
988
+ b,
989
+ u
990
+ ), f = $e(n, i), d = /* @__PURE__ */ new Map(), {
1851
991
  clear: c,
1852
- errors: g,
1853
- formData: h,
1854
- ignoreUpdates: a,
1855
- invalid: l,
1856
- readonly: p,
992
+ errors: h,
993
+ formData: g,
994
+ ignoreUpdates: O,
995
+ invalid: v,
996
+ readonly: m,
1857
997
  reset: y,
1858
- status: w,
1859
- stopUpdatesWatch: O,
1860
- submit: x,
1861
- validate: _,
1862
- VvForm: V
1863
- } = tt(e, n, r, m, d);
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: g,
1867
- formData: h,
1868
- formFieldInjectionKey: t,
1006
+ errors: h,
1007
+ formData: g,
1008
+ formFieldInjectionKey: r,
1869
1009
  formInjectionKey: n,
1870
- formWrapperInjectionKey: u,
1871
- ignoreUpdates: a,
1872
- invalid: l,
1873
- readonly: p,
1010
+ formWrapperInjectionKey: b,
1011
+ ignoreUpdates: O,
1012
+ invalid: v,
1013
+ readonly: m,
1874
1014
  reset: y,
1875
- status: w,
1876
- stopUpdatesWatch: O,
1877
- submit: x,
1878
- validate: _,
1015
+ status: x,
1016
+ stopUpdatesWatch: I,
1017
+ submit: A,
1018
+ validate: w,
1879
1019
  wrappers: d,
1880
- VvForm: V,
1020
+ VvForm: S,
1881
1021
  VvFormField: i,
1882
- VvFormFieldsGroup: f,
1883
- VvFormTemplate: m,
1884
- VvFormWrapper: s
1022
+ VvFormFieldsGroup: l,
1023
+ VvFormTemplate: f,
1024
+ VvFormWrapper: o
1885
1025
  };
1886
1026
  }
1887
- const Ee = Symbol("pluginInjectionKey");
1888
- function dt(e) {
1889
- let r = {};
1890
- return e.schema && (r = Y(e.schema, e)), {
1891
- ...r,
1892
- install(n, { global: u = !1 } = {}) {
1893
- n.provide(Ee, e), u && (n.config.globalProperties.$vvForm = e, r?.VvForm && n.component("VvForm", r.VvForm), r?.VvFormWrapper && n.component("VvFormWrapper", r.VvFormWrapper), r?.VvFormField && n.component("VvFormField", r.VvFormField), r?.VvFormFieldsGroup && n.component("VvFormFieldsGroup", r.VvFormFieldsGroup), r?.VvFormTemplate && n.component("VvFormTemplate", r.VvFormTemplate));
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 H = /* @__PURE__ */ new Map();
1898
- function pt(e, r = {}) {
1899
- if (r.scope && H.has(r.scope))
1900
- return H.get(r.scope);
1901
- if (!Ne()) {
1902
- const u = Y(e, r);
1903
- return r.scope && H.set(r.scope, u), u;
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 = Y(
1045
+ const n = T(
1906
1046
  e,
1907
1047
  {
1908
- ...J(Ee, {}),
1909
- ...r
1048
+ ...B(le, {}),
1049
+ ...t
1910
1050
  }
1911
1051
  );
1912
- return r.scope && H.set(r.scope, n), n;
1052
+ return t.scope && M.set(t.scope, n), n;
1913
1053
  }
1914
- function mt(e, r = {}) {
1915
- return Y(e, r);
1054
+ function Ke(e, t = {}) {
1055
+ return T(e, t);
1916
1056
  }
1917
1057
  export {
1918
- k as FormFieldType,
1919
- dt as createForm,
1920
- Q as defaultObjectBySchema,
1921
- mt as formType,
1922
- Ee as pluginInjectionKey,
1923
- pt as useForm
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
  };