@volverjs/form-vue 0.0.10-beta.9 → 0.0.10

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