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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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:
@@ -241,48 +243,52 @@ const ie = (e, n, i, s) => G({
241
243
  return import("@volverjs/ui-vue/vv-checkbox");
242
244
  case f.checkboxGroup:
243
245
  return import("@volverjs/ui-vue/vv-checkbox-group");
246
+ case f.select:
247
+ return import("@volverjs/ui-vue/vv-select");
244
248
  case f.combobox:
245
249
  return import("@volverjs/ui-vue/vv-combobox");
246
250
  }
247
251
  return import("@volverjs/ui-vue/vv-input-text");
248
252
  });
249
- }), hasProps: W, invalid: v };
253
+ }), hasProps: W, invalid: b };
250
254
  },
251
255
  render() {
252
256
  return this.is ? x(this.is, this.hasProps, this.$slots) : this.type === f.custom ? x(this.component, null, this.$slots) : x(this.component, this.hasProps, this.$slots);
253
257
  }
254
- }), 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);
258
+ }), X = (e, s = {}) => {
259
+ const l = (r) => {
260
+ let u = r;
261
+ for (; u instanceof se; )
262
+ u = u.innerType();
263
+ return u;
264
+ }, o = l(e);
261
265
  return {
262
- ...(s instanceof M ? s._def.unknownKeys === "passthrough" : !1) ? n : {},
266
+ ...(o instanceof J ? o._def.unknownKeys === "passthrough" : !1) ? s : {},
263
267
  ...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];
268
+ Object.entries(o.shape).map(
269
+ ([r, u]) => {
270
+ const a = s[r], i = l(u);
271
+ let t;
272
+ if (i instanceof te && (t = i._def.defaultValue()), a === null && i instanceof ae)
273
+ return [r, a];
274
+ if (i instanceof ne) {
275
+ const m = u.safeParse(a);
276
+ if (m.success)
277
+ return [r, m.data ?? t];
278
+ }
279
+ return i instanceof J ? [
280
+ r,
281
+ X(
282
+ i,
283
+ a && typeof a == "object" ? a : {}
284
+ )
285
+ ] : [r, t];
273
286
  }
274
- return u instanceof M ? [
275
- r,
276
- H(
277
- u,
278
- o && typeof o == "object" ? o : {}
279
- )
280
- ] : [r, t];
281
- })
287
+ )
282
288
  )
283
289
  };
284
- }, fe = (e, n, i) => {
285
- const s = E(), a = E(), r = E(), l = G({
290
+ }, fe = (e, s, l) => {
291
+ const o = E(), n = E(), r = E(), u = G({
286
292
  name: "FormComponent",
287
293
  props: {
288
294
  modelValue: {
@@ -299,44 +305,47 @@ const ie = (e, n, i, s) => G({
299
305
  }
300
306
  },
301
307
  emits: ["invalid", "valid", "submit", "update:modelValue"],
302
- expose: ["submit", "errors", "status"],
303
- setup(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,
308
+ expose: ["submit", "validate", "errors", "status", "valid", "invalid"],
309
+ setup(a, { emit: i }) {
310
+ r.value = X(
311
+ e,
312
+ Z(a.modelValue)
313
+ ), w(
314
+ () => a.modelValue,
308
315
  (d) => {
309
316
  if (d) {
310
- const v = T(d) ? j(d) : d;
311
- r.value = typeof (v == null ? void 0 : v.clone) == "function" ? v.clone() : JSON.parse(JSON.stringify(v));
317
+ const c = j(d) ? Z(d) : d;
318
+ r.value = typeof (c == null ? void 0 : c.clone) == "function" ? c.clone() : JSON.parse(JSON.stringify(c));
312
319
  }
313
320
  },
314
321
  { deep: !0 }
315
322
  ), re(
316
323
  r,
317
324
  (d) => {
318
- (s.value || t) && m(), (!d || !o.modelValue || JSON.stringify(d) !== JSON.stringify(o.modelValue)) && u("update:modelValue", d);
325
+ ((o.value || (l == null ? void 0 : l.continuosValidation)) ?? a.continuosValidation) && t(), (!d || !a.modelValue || JSON.stringify(d) !== JSON.stringify(a.modelValue)) && i("update:modelValue", d);
319
326
  },
320
327
  {
321
328
  deep: !0,
322
- throttle: (i == null ? void 0 : i.updateThrottle) ?? o.updateThrottle
329
+ throttle: (l == null ? void 0 : l.updateThrottle) ?? a.updateThrottle
323
330
  }
324
331
  );
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, {
332
+ const t = (d = r.value) => {
333
+ const c = e.safeParse(d);
334
+ return c.success ? (o.value = void 0, n.value = L.valid, r.value = c.data, i("update:modelValue", r.value), i("valid", c.data), !0) : (o.value = c.error.format(), n.value = L.invalid, i("invalid", o.value), !1);
335
+ }, m = () => t() ? (i("submit", r.value), !0) : !1, h = y(() => n.value === L.invalid);
336
+ return z(s, {
330
337
  formData: r,
331
- submit: p,
332
- errors: k(s),
333
- status: k(a),
338
+ submit: m,
339
+ validate: t,
340
+ errors: k(o),
341
+ status: k(n),
334
342
  invalid: h
335
343
  }), {
336
344
  formData: r,
337
- submit: p,
338
- errors: k(s),
339
- status: k(a),
345
+ submit: m,
346
+ validate: t,
347
+ errors: k(o),
348
+ status: k(n),
340
349
  invalid: h
341
350
  };
342
351
  },
@@ -348,10 +357,11 @@ const ie = (e, n, i, s) => G({
348
357
  },
349
358
  {
350
359
  default: () => {
351
- var o, u;
352
- return ((u = (o = this.$slots) == null ? void 0 : o.default) == null ? void 0 : u.call(o, {
360
+ var a, i;
361
+ return ((i = (a = this.$slots) == null ? void 0 : a.default) == null ? void 0 : i.call(a, {
353
362
  formData: this.formData,
354
363
  submit: this.submit,
364
+ validate: this.validate,
355
365
  errors: this.errors,
356
366
  status: this.status,
357
367
  invalid: this.invalid
@@ -362,15 +372,15 @@ const ie = (e, n, i, s) => G({
362
372
  }
363
373
  });
364
374
  return {
365
- errors: s,
366
- status: a,
375
+ errors: o,
376
+ status: n,
367
377
  formData: r,
368
378
  /**
369
379
  * An hack to add types to the default slot
370
380
  */
371
- VvForm: l
381
+ VvForm: u
372
382
  };
373
- }, ce = (e, n) => G({
383
+ }, ve = (e, s) => G({
374
384
  name: "WrapperComponent",
375
385
  props: {
376
386
  name: {
@@ -384,134 +394,141 @@ const ie = (e, n, i, s) => G({
384
394
  },
385
395
  emits: ["invalid", "valid"],
386
396
  expose: ["fields", "invalid"],
387
- setup(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, {
397
+ setup(o, { emit: n }) {
398
+ const r = O(e), u = O(s, void 0), a = E(/* @__PURE__ */ new Set()), i = E(/* @__PURE__ */ new Map()), { name: t } = U(o);
399
+ z(s, {
390
400
  name: k(t),
391
- errors: u,
392
- fields: o
401
+ errors: i,
402
+ fields: a
393
403
  }), w(
394
- o,
395
- (p) => {
396
- l != null && l.fields && p.forEach((h) => {
397
- l == null || l.fields.value.add(h);
404
+ a,
405
+ (h) => {
406
+ u != null && u.fields && h.forEach((d) => {
407
+ u == null || u.fields.value.add(d);
398
408
  });
399
409
  },
400
410
  { deep: !0 }
401
411
  ), w(
402
- () => new Map(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);
412
+ () => new Map(i.value),
413
+ (h, d) => {
414
+ u != null && u.errors && (Array.from(d.keys()).forEach((c) => {
415
+ u.errors.value.delete(c);
416
+ }), Array.from(h.keys()).forEach((c) => {
417
+ const b = h.get(c);
418
+ b && u.errors.value.set(c, b);
409
419
  }));
410
420
  },
411
421
  { deep: !0 }
412
422
  );
413
- const m = V(() => r != null && r.invalid.value ? u.value.size > 0 : !1);
423
+ const m = y(() => r != null && r.invalid.value ? i.value.size > 0 : !1);
414
424
  return w(m, () => {
415
- m.value ? a("invalid") : a("valid");
425
+ m.value ? n("invalid") : n("valid");
416
426
  }), {
417
427
  formData: r == null ? void 0 : r.formData,
418
428
  errors: r == null ? void 0 : r.errors,
429
+ submit: r == null ? void 0 : r.submit,
430
+ validate: r == null ? void 0 : r.validate,
419
431
  invalid: m,
420
- fields: o,
421
- fieldsErrors: u
432
+ fields: a,
433
+ fieldsErrors: i
422
434
  };
423
435
  },
424
436
  render() {
425
- var s, a;
437
+ var o, n;
426
438
  return this.tag ? x(this.tag, null, {
427
439
  default: () => {
428
- var r, l;
429
- return ((l = (r = this.$slots).default) == null ? void 0 : l.call(r, {
440
+ var r, u;
441
+ return ((u = (r = this.$slots).default) == null ? void 0 : u.call(r, {
430
442
  invalid: this.invalid,
431
443
  formData: this.formData,
444
+ submit: this.submit,
445
+ validate: this.validate,
432
446
  errors: this.errors,
433
447
  fieldsErrors: this.fieldsErrors
434
448
  })) ?? this.$slots.defalut;
435
449
  }
436
- }) : ((a = (s = this.$slots).default) == null ? void 0 : a.call(s, {
450
+ }) : ((n = (o = this.$slots).default) == null ? void 0 : n.call(o, {
437
451
  invalid: this.invalid,
438
452
  formData: this.formData,
453
+ submit: this.submit,
454
+ validate: this.validate,
439
455
  errors: this.errors,
440
456
  fieldsErrors: this.fieldsErrors
441
457
  })) ?? this.$slots.defalut;
442
458
  }
443
- }), de = (e, n) => {
444
- const i = G({
459
+ }), de = (e, s) => {
460
+ const l = G({
445
461
  props: {
446
462
  schema: {
447
463
  type: [Array, Function],
448
464
  required: !0
449
465
  }
450
466
  },
451
- setup(s, { slots: a }) {
467
+ setup(o, { slots: n }) {
452
468
  const r = O(e);
453
469
  if (!(r != null && r.formData))
454
470
  return;
455
- const l = typeof s.schema == "function" ? s.schema(r) : s.schema;
456
- let o;
471
+ const u = typeof o.schema == "function" ? o.schema(r) : o.schema;
472
+ let a;
457
473
  return () => {
458
- var u;
459
- return l.reduce(
474
+ var i;
475
+ return u.reduce(
460
476
  (t, m) => {
461
- const p = typeof m == "function" ? m(r) : m, {
462
- vvIs: h,
463
- vvName: d,
464
- vvSlots: v,
477
+ const h = typeof m == "function" ? m(r) : m, {
478
+ vvIs: d,
479
+ vvName: c,
480
+ vvSlots: b,
465
481
  vvChildren: S,
466
- vvIf: y,
467
- vvElseIf: b,
482
+ vvIf: V,
483
+ vvElseIf: p,
468
484
  vvType: I,
469
485
  vvDefaultValue: W,
470
486
  vvShowValid: K,
471
- ...c
472
- } = p;
473
- if (y !== void 0) {
474
- if (typeof y == "string" ? o = !!N(
487
+ ...v
488
+ } = h;
489
+ if (V !== void 0) {
490
+ if (typeof V == "string" ? a = !!N(
475
491
  Object(r.formData.value),
476
- y
477
- ) : typeof y == "function" ? o = C(y(r)) : o = C(y), !o)
492
+ V
493
+ ) : typeof V == "function" ? a = C(V(r)) : a = C(V), !a)
478
494
  return t;
479
- } else if (b !== void 0 && o !== void 0) {
480
- if (o || (typeof b == "string" ? o = !!N(
495
+ } else if (p !== void 0 && a !== void 0) {
496
+ if (a || (typeof p == "string" ? a = !!N(
481
497
  Object(r.formData.value),
482
- b
483
- ) : typeof b == "function" ? o = C(b(r)) : o = C(b), !o))
498
+ p
499
+ ) : typeof p == "function" ? a = C(p(r)) : a = C(p), !a))
484
500
  return t;
485
501
  } else
486
- o = void 0;
487
- const A = S ? x(i, {
502
+ a = void 0;
503
+ const A = S ? x(l, {
488
504
  schema: S
489
505
  }) : void 0;
490
- return d ? (t.push(
506
+ return c ? (t.push(
491
507
  x(
492
- n,
508
+ s,
493
509
  {
494
- name: d,
495
- is: h,
510
+ name: c,
511
+ is: d,
496
512
  type: I,
497
513
  defaultValue: W,
498
514
  showValid: K,
499
- props: c
515
+ props: v
500
516
  },
501
- v ?? A
517
+ b ?? A
502
518
  )
503
- ), t) : h ? (t.push(
519
+ ), t) : d ? (t.push(
504
520
  x(
505
- h,
506
- c,
507
- v ?? A
521
+ d,
522
+ v,
523
+ b ?? A
508
524
  )
509
525
  ), t) : (S && t.push(A), t);
510
526
  },
511
527
  [
512
- (u = a == null ? void 0 : a.default) == null ? void 0 : u.call(a, {
528
+ (i = n == null ? void 0 : n.default) == null ? void 0 : i.call(n, {
513
529
  formData: r == null ? void 0 : r.formData.value,
514
530
  submit: r == null ? void 0 : r.submit,
531
+ validate: r == null ? void 0 : r.validate,
515
532
  errors: r == null ? void 0 : r.errors.value,
516
533
  status: r == null ? void 0 : r.status.value,
517
534
  invalid: r == null ? void 0 : r.invalid.value
@@ -521,50 +538,50 @@ const ie = (e, n, i, s) => G({
521
538
  };
522
539
  }
523
540
  });
524
- return i;
525
- }, B = (e, n = {}) => {
526
- const i = Symbol(), s = Symbol(), a = Symbol(), { VvForm: r, errors: l, status: o, formData: u } = fe(
541
+ return l;
542
+ }, B = (e, s = {}) => {
543
+ const l = Symbol(), o = Symbol(), n = Symbol(), { VvForm: r, errors: u, status: a, formData: i } = fe(
527
544
  e,
528
- i,
529
- n
530
- ), t = ce(
531
- i,
545
+ l,
546
+ s
547
+ ), t = ve(
548
+ l,
549
+ o
550
+ ), m = le(
551
+ l,
552
+ o,
553
+ n,
532
554
  s
533
- ), m = ie(
534
- i,
535
- s,
536
- a,
537
- n
538
- ), p = de(i, m);
555
+ ), h = de(l, m);
539
556
  return {
540
557
  VvForm: r,
541
558
  VvFormWrapper: t,
542
559
  VvFormField: m,
543
- VvFormTemplate: p,
544
- formInjectionKey: i,
545
- formWrapperInjectionKey: s,
546
- formFieldInjectionKey: a,
547
- errors: l,
548
- status: o,
549
- formData: u
560
+ VvFormTemplate: h,
561
+ formInjectionKey: l,
562
+ formWrapperInjectionKey: o,
563
+ formFieldInjectionKey: n,
564
+ errors: u,
565
+ status: a,
566
+ formData: i
550
567
  };
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));
568
+ }, Y = Symbol(), be = (e) => {
569
+ let s = {};
570
+ return e.schema && (s = B(e.schema, e)), {
571
+ ...s,
572
+ install(l, { global: o = !1 } = {}) {
573
+ l.provide(Y, e), o && (l.config.globalProperties.$vvForm = e, s != null && s.VvForm && l.component("VvForm", s.VvForm), s != null && s.VvFormWrapper && l.component("VvFormWrapper", s.VvFormWrapper), s != null && s.VvFormField && l.component("VvFormField", s.VvFormField), s != null && s.VvFormTemplate && l.component("VvFormTemplate", s.VvFormTemplate));
557
574
  }
558
575
  };
559
- }, be = (e, n = {}) => ee() ? B(e, {
560
- ...O(Q, {}),
561
- ...n
562
- }) : B(e, n), Ve = (e, n = {}) => B(e, n);
576
+ }, pe = (e, s = {}) => ee() ? B(e, {
577
+ ...O(Y, {}),
578
+ ...s
579
+ }) : B(e, s), ye = (e, s = {}) => B(e, s);
563
580
  export {
564
581
  f as FormFieldType,
565
- pe as createForm,
566
- H as defaultObjectBySchema,
567
- Ve as formFactory,
568
- Q as pluginInjectionKey,
569
- be as useForm
582
+ be as createForm,
583
+ X as defaultObjectBySchema,
584
+ ye as formFactory,
585
+ Y as pluginInjectionKey,
586
+ pe as useForm
570
587
  };