@volverjs/form-vue 1.0.0-beta.6 → 1.0.0-beta.8

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,7 +1,7 @@
1
- import { defineComponent as z, computed as k, onMounted as D, onBeforeUnmount as j, inject as U, toRefs as P, watch as A, unref as $, provide as M, readonly as I, resolveComponent as O, defineAsyncComponent as F, h as w, ref as B, toRaw as S, isProxy as ee, withModifiers as re, getCurrentInstance as te } from "vue";
1
+ import { defineComponent as z, computed as w, onMounted as P, onBeforeUnmount as j, inject as B, toRefs as H, watch as O, unref as C, provide as M, readonly as E, resolveComponent as S, defineAsyncComponent as F, h as p, ref as $, toRaw as A, isProxy as ee, withModifiers as re, getCurrentInstance as te } from "vue";
2
2
  import { watchIgnorable as ae, throttleFilter as ne } from "@vueuse/core";
3
- import { ZodObject as J, ZodDefault as ue, ZodNullable as le, ZodSchema as se, ZodArray as ie, ZodEffects as fe, ZodOptional as oe } from "zod";
4
- function K(e) {
3
+ import { ZodObject as Z, ZodDefault as ue, ZodNullable as le, ZodSchema as se, ZodArray as ie, ZodEffects as fe, ZodOptional as oe } from "zod";
4
+ function J(e) {
5
5
  return Array.isArray(e);
6
6
  }
7
7
  function de(e) {
@@ -10,38 +10,38 @@ function de(e) {
10
10
  function q(e) {
11
11
  return e === null;
12
12
  }
13
- function H(e) {
13
+ function Q(e) {
14
14
  return typeof e == "object";
15
15
  }
16
- function Q(e) {
16
+ function X(e) {
17
17
  return typeof e == "string";
18
18
  }
19
- function C(e) {
19
+ function G(e) {
20
20
  return typeof e > "u";
21
21
  }
22
22
  const ve = /^[0-9]+$/, ce = ["__proto__", "prototype", "constructor"];
23
- function G(e, s, t) {
23
+ function L(e, s, t) {
24
24
  const o = de(t) ? t : void 0;
25
- if (!H(e) || !Q(s))
25
+ if (!Q(e) || !X(s))
26
26
  return o;
27
- const u = Y(s);
27
+ const u = T(s);
28
28
  if (u.length !== 0) {
29
29
  for (const r of u) {
30
30
  if (r === "*")
31
31
  continue;
32
- const l = function(a) {
33
- return a.map((f) => C(f) || q(f) ? f : K(f) ? l(f) : f[r]);
32
+ const l = function(n) {
33
+ return n.map((i) => G(i) || q(i) ? i : J(i) ? l(i) : i[r]);
34
34
  };
35
- if (K(e) && !ve.test(r) ? e = l(e) : e = e[r], C(e) || q(e))
35
+ if (J(e) && !ve.test(r) ? e = l(e) : e = e[r], G(e) || q(e))
36
36
  break;
37
37
  }
38
- return C(e) ? o : e;
38
+ return G(e) ? o : e;
39
39
  }
40
40
  }
41
- function X(e, s, t) {
42
- if (!H(e) || !Q(s))
41
+ function Y(e, s, t) {
42
+ if (!Q(e) || !X(s))
43
43
  return;
44
- const o = Y(s);
44
+ const o = T(s);
45
45
  if (o.length === 0)
46
46
  return;
47
47
  const u = o.length;
@@ -51,20 +51,20 @@ function X(e, s, t) {
51
51
  e[l] = t;
52
52
  return;
53
53
  }
54
- if (l === "*" && K(e)) {
55
- const a = o.slice(r + 1).join(".");
56
- for (const f of e)
57
- X(f, a, t);
54
+ if (l === "*" && J(e)) {
55
+ const n = o.slice(r + 1).join(".");
56
+ for (const i of e)
57
+ Y(i, n, t);
58
58
  return;
59
59
  }
60
- C(e[l]) && (e[l] = {}), e = e[l];
60
+ G(e[l]) && (e[l] = {}), e = e[l];
61
61
  }
62
62
  }
63
- function Y(e) {
63
+ function T(e) {
64
64
  const s = e.split(/[.]|(?:\[(\d|\*)\])/).filter((t) => !!t);
65
65
  return s.some((t) => ce.indexOf(t) !== -1) ? [] : s;
66
66
  }
67
- var d = /* @__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))(d || {}), x = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e.submitting = "submitting", e.updated = "updated", e.unknown = "unknown", e))(x || {});
67
+ var d = /* @__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))(d || {}), k = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e.submitting = "submitting", e.updated = "updated", e.unknown = "unknown", e))(k || {});
68
68
  const me = (e, s, t, o) => z({
69
69
  name: "VvFormField",
70
70
  props: {
@@ -96,72 +96,76 @@ const me = (e, s, t, o) => z({
96
96
  lazyLoad: {
97
97
  type: Boolean,
98
98
  default: !1
99
+ },
100
+ readonly: {
101
+ type: Boolean,
102
+ default: void 0
99
103
  }
100
104
  },
101
105
  emits: ["invalid", "valid", "update:formData", "update:modelValue"],
102
106
  expose: ["invalid", "invalidLabel", "errors"],
103
107
  setup(u, { slots: r, emit: l }) {
104
- const a = k({
108
+ const n = w({
105
109
  get() {
106
- if (n != null && n.formData)
107
- return G(
108
- Object(n.formData.value),
110
+ if (a != null && a.formData)
111
+ return L(
112
+ Object(a.formData.value),
109
113
  String(u.name)
110
114
  );
111
115
  },
112
- set(i) {
113
- n != null && n.formData && (X(
114
- Object(n.formData.value),
116
+ set(f) {
117
+ a != null && a.formData && (Y(
118
+ Object(a.formData.value),
115
119
  String(u.name),
116
- i
120
+ f
117
121
  ), l("update:modelValue", {
118
- newValue: a.value,
119
- formData: n == null ? void 0 : n.formData
122
+ newValue: n.value,
123
+ formData: a == null ? void 0 : a.formData
120
124
  }));
121
125
  }
122
126
  });
123
- D(() => {
124
- a.value === void 0 && u.defaultValue !== void 0 && (a.value = u.defaultValue);
127
+ P(() => {
128
+ n.value === void 0 && u.defaultValue !== void 0 && (n.value = u.defaultValue);
125
129
  }), j(() => {
126
- b(), y();
130
+ h(), m();
127
131
  });
128
- const f = U(s, void 0);
129
- f && f.fields.value.add(u.name);
130
- const n = U(e), { props: c, name: h } = P(u), V = k(() => {
131
- if (n != null && n.errors.value)
132
- return G(n.errors.value, String(u.name));
133
- }), m = k(() => {
134
- var i;
135
- return (i = V.value) == null ? void 0 : i._errors;
136
- }), v = k(() => V.value !== void 0), b = A(v, () => {
137
- v.value ? (l("invalid", m.value), f && f.errors.value.set(
132
+ const i = B(s, void 0);
133
+ i && i.fields.value.add(u.name);
134
+ const a = B(e), { props: c, name: b } = H(u), g = w(() => {
135
+ if (a != null && a.errors.value)
136
+ return L(a.errors.value, String(u.name));
137
+ }), V = w(() => {
138
+ var f;
139
+ return (f = g.value) == null ? void 0 : f._errors;
140
+ }), v = w(() => g.value !== void 0), h = O(v, () => {
141
+ v.value ? (l("invalid", V.value), i && i.errors.value.set(
138
142
  u.name,
139
143
  {
140
- _errors: m.value
144
+ _errors: V.value
141
145
  }
142
- )) : (l("valid", a.value), f && f.errors.value.delete(
146
+ )) : (l("valid", n.value), i && i.errors.value.delete(
143
147
  u.name
144
148
  ));
145
- }), y = A(
146
- () => n == null ? void 0 : n.formData,
149
+ }), m = O(
150
+ () => a == null ? void 0 : a.formData,
147
151
  () => {
148
- l("update:formData", n == null ? void 0 : n.formData);
152
+ l("update:formData", a == null ? void 0 : a.formData);
149
153
  },
150
154
  { deep: !0 }
151
- ), g = (i) => {
152
- a.value = i;
153
- }, p = k(() => {
154
- let i = c.value;
155
- return typeof i == "function" && (i = i(n == null ? void 0 : n.formData)), Object.keys(i).reduce(
156
- (N, _) => (N[_] = $(i[_]), N),
155
+ ), y = (f) => {
156
+ n.value = f;
157
+ }, x = w(() => {
158
+ let f = c.value;
159
+ return typeof f == "function" && (f = f(a == null ? void 0 : a.formData)), Object.keys(f).reduce(
160
+ (_, W) => (_[W] = C(f[W]), _),
157
161
  {}
158
162
  );
159
- }), E = k(() => ({
160
- ...p.value,
161
- name: p.value.name ?? u.name,
163
+ }), I = w(() => a != null && a.readonly.value ? !0 : x.value.readonly ?? u.readonly), U = w(() => ({
164
+ ...x.value,
165
+ name: x.value.name ?? u.name,
162
166
  invalid: v.value,
163
- valid: u.showValid ? !!(!v.value && a.value) : void 0,
164
- type: ((i) => {
167
+ valid: u.showValid ? !!(!v.value && n.value) : void 0,
168
+ type: ((f) => {
165
169
  if ([
166
170
  d.text,
167
171
  d.number,
@@ -176,65 +180,67 @@ const me = (e, s, t, o) => z({
176
180
  d.month,
177
181
  d.week,
178
182
  d.color
179
- ].includes(i))
180
- return i;
183
+ ].includes(f))
184
+ return f;
181
185
  })(u.type),
182
- invalidLabel: m.value,
183
- modelValue: a.value,
184
- "onUpdate:modelValue": g
186
+ invalidLabel: V.value,
187
+ modelValue: n.value,
188
+ readonly: I.value,
189
+ "onUpdate:modelValue": y
185
190
  }));
186
191
  return M(t, {
187
- name: I(h),
188
- errors: I(V)
189
- }), { component: k(() => {
192
+ name: E(b),
193
+ errors: E(g)
194
+ }), { component: w(() => {
190
195
  if (u.type === d.custom)
191
196
  return {
192
197
  render() {
193
- var i;
194
- return ((i = r.default) == null ? void 0 : i.call(r, {
195
- modelValue: a.value,
196
- onUpdate: g,
197
- submit: n == null ? void 0 : n.submit,
198
- validate: n == null ? void 0 : n.validate,
198
+ var f;
199
+ return ((f = r.default) == null ? void 0 : f.call(r, {
200
+ modelValue: n.value,
201
+ onUpdate: y,
202
+ submit: a == null ? void 0 : a.submit,
203
+ validate: a == null ? void 0 : a.validate,
199
204
  invalid: v.value,
200
- invalidLabel: m.value,
201
- formData: n == null ? void 0 : n.formData.value,
202
- formErrors: n == null ? void 0 : n.errors.value,
203
- errors: V.value
205
+ invalidLabel: V.value,
206
+ formData: a == null ? void 0 : a.formData.value,
207
+ formErrors: a == null ? void 0 : a.errors.value,
208
+ errors: g.value,
209
+ readonly: I.value
204
210
  })) ?? r.defalut;
205
211
  }
206
212
  };
207
213
  if (!((o == null ? void 0 : o.lazyLoad) ?? u.lazyLoad)) {
208
- let i;
214
+ let f;
209
215
  switch (u.type) {
210
216
  case d.select:
211
- i = O("VvSelect");
217
+ f = S("VvSelect");
212
218
  break;
213
219
  case d.checkbox:
214
- i = O("VvCheckbox");
220
+ f = S("VvCheckbox");
215
221
  break;
216
222
  case d.radio:
217
- i = O("VvRadio");
223
+ f = S("VvRadio");
218
224
  break;
219
225
  case d.textarea:
220
- i = O("VvTextarea");
226
+ f = S("VvTextarea");
221
227
  break;
222
228
  case d.radioGroup:
223
- i = O("VvRadioGroup");
229
+ f = S("VvRadioGroup");
224
230
  break;
225
231
  case d.checkboxGroup:
226
- i = O("VvCheckboxGroup");
232
+ f = S("VvCheckboxGroup");
227
233
  break;
228
234
  case d.combobox:
229
- i = O("VvCombobox");
235
+ f = S("VvCombobox");
230
236
  break;
231
237
  default:
232
- i = O("VvInputText");
238
+ f = S("VvInputText");
233
239
  }
234
- if (typeof i != "string")
235
- return i;
240
+ if (typeof f != "string")
241
+ return f;
236
242
  console.warn(
237
- `[form-vue warn]: ${i} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
243
+ `[form-vue warn]: ${f} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
238
244
  );
239
245
  }
240
246
  return F(async () => {
@@ -256,12 +262,12 @@ const me = (e, s, t, o) => z({
256
262
  }
257
263
  return import("@volverjs/ui-vue/vv-input-text");
258
264
  });
259
- }), hasProps: E, invalid: v };
265
+ }), hasProps: U, invalid: v };
260
266
  },
261
267
  render() {
262
- return this.is ? w(this.is, this.hasProps, this.$slots) : this.type === d.custom ? w(this.component, null, this.$slots) : w(this.component, this.hasProps, this.$slots);
268
+ return this.is ? p(this.is, this.hasProps, this.$slots) : this.type === d.custom ? p(this.component, null, this.$slots) : p(this.component, this.hasProps, this.$slots);
263
269
  }
264
- }), R = (e, s = {}) => {
270
+ }), K = (e, s = {}) => {
265
271
  const t = (r) => {
266
272
  let l = r;
267
273
  for (; l instanceof fe; )
@@ -269,51 +275,53 @@ const me = (e, s, t, o) => z({
269
275
  return l instanceof oe && (l = l._def.innerType), l;
270
276
  }, o = t(e);
271
277
  return {
272
- ...(o instanceof J ? o._def.unknownKeys === "passthrough" : !1) ? s : {},
278
+ ...(o instanceof Z ? o._def.unknownKeys === "passthrough" : !1) ? s : {},
273
279
  ...Object.fromEntries(
274
280
  Object.entries(o.shape).map(
275
281
  ([r, l]) => {
276
- const a = s[r];
277
- let f = t(l), n;
278
- if (f instanceof ue && (n = f._def.defaultValue(), f = f._def.innerType), a === null && f instanceof le)
279
- return [r, a];
280
- if (f instanceof se) {
281
- const c = l.safeParse(a);
282
+ const n = s[r];
283
+ let i = t(l), a;
284
+ if (i instanceof ue && (a = i._def.defaultValue(), i = i._def.innerType), n === null && i instanceof le)
285
+ return [r, n];
286
+ if (i instanceof se) {
287
+ const c = l.safeParse(n);
282
288
  if (c.success)
283
- return [r, c.data ?? n];
289
+ return [r, c.data ?? a];
284
290
  }
285
- if (f instanceof ie && Array.isArray(a) && a.length) {
286
- const c = t(f._def.type);
287
- if (c instanceof J)
291
+ if (i instanceof ie && Array.isArray(n) && n.length) {
292
+ const c = t(i._def.type);
293
+ if (c instanceof Z)
288
294
  return [
289
295
  r,
290
- a.map(
291
- (h) => R(
296
+ n.map(
297
+ (b) => K(
292
298
  c,
293
- h && typeof h == "object" ? h : void 0
299
+ b && typeof b == "object" ? b : void 0
294
300
  )
295
- ) ?? n
301
+ ) ?? a
296
302
  ];
297
303
  }
298
- return f instanceof J ? [
304
+ return i instanceof Z ? [
299
305
  r,
300
- R(
301
- f,
302
- a && typeof a == "object" ? a : n
306
+ K(
307
+ i,
308
+ n && typeof n == "object" ? n : a
303
309
  )
304
- ] : [r, n];
310
+ ] : [r, a];
305
311
  }
306
312
  )
307
313
  )
308
314
  };
309
315
  }, he = (e, s, t, o) => {
310
- const u = B(), r = B(), l = k(() => r.value === x.invalid), a = B(), f = async (m = a.value) => {
311
- const v = await e.safeParseAsync(m);
312
- return v.success ? (u.value = void 0, r.value = x.valid, a.value = v.data, !0) : (u.value = v.error.format(), r.value = x.invalid, !1);
313
- }, n = async () => await f() ? (r.value = x.submitting, !0) : !1, { ignoreUpdates: c, stop: h } = ae(
314
- a,
316
+ const u = $(), r = $(), l = w(() => r.value === k.invalid), n = $(), i = $(!1), a = async (v = n.value) => {
317
+ if (i.value)
318
+ return !0;
319
+ const h = await e.safeParseAsync(v);
320
+ return h.success ? (u.value = void 0, r.value = k.valid, n.value = h.data, !0) : (u.value = h.error.format(), r.value = k.invalid, !1);
321
+ }, c = async () => i.value || !await a() ? !1 : (r.value = k.submitting, !0), { ignoreUpdates: b, stop: g } = ae(
322
+ n,
315
323
  () => {
316
- r.value = x.updated;
324
+ r.value = k.updated;
317
325
  },
318
326
  {
319
327
  deep: !0,
@@ -330,6 +338,10 @@ const me = (e, s, t, o) => z({
330
338
  type: Object,
331
339
  default: () => ({})
332
340
  },
341
+ readonly: {
342
+ type: Boolean,
343
+ default: (t == null ? void 0 : t.readonly) ?? !1
344
+ },
333
345
  tag: {
334
346
  type: String,
335
347
  default: "form"
@@ -339,74 +351,99 @@ const me = (e, s, t, o) => z({
339
351
  default: void 0
340
352
  }
341
353
  },
342
- emits: ["invalid", "valid", "submit", "update:modelValue"],
343
- expose: ["submit", "validate", "errors", "status", "valid", "invalid"],
344
- setup(m, { emit: v }) {
345
- return a.value = R(
354
+ emits: [
355
+ "invalid",
356
+ "valid",
357
+ "submit",
358
+ "update:modelValue",
359
+ "update:readonly"
360
+ ],
361
+ expose: [
362
+ "submit",
363
+ "validate",
364
+ "errors",
365
+ "status",
366
+ "valid",
367
+ "invalid",
368
+ "readonly"
369
+ ],
370
+ setup(v, { emit: h }) {
371
+ return n.value = K(
346
372
  e,
347
- S(m.modelValue)
348
- ), A(
349
- () => m.modelValue,
350
- (b) => {
351
- if (b) {
352
- const y = ee(b) ? S(b) : b;
353
- if (JSON.stringify(y) === JSON.stringify(S(a.value)))
373
+ A(v.modelValue)
374
+ ), O(
375
+ () => v.modelValue,
376
+ (m) => {
377
+ if (m) {
378
+ const y = ee(m) ? A(m) : m;
379
+ if (JSON.stringify(y) === JSON.stringify(A(n.value)))
354
380
  return;
355
- a.value = typeof (y == null ? void 0 : y.clone) == "function" ? y.clone() : JSON.parse(JSON.stringify(y));
381
+ n.value = typeof (y == null ? void 0 : y.clone) == "function" ? y.clone() : JSON.parse(JSON.stringify(y));
356
382
  }
357
383
  },
358
384
  { deep: !0 }
359
- ), A(r, async (b) => {
360
- var y, g, p, E, W;
361
- if (b === x.invalid) {
362
- const i = S(
385
+ ), O(r, async (m) => {
386
+ var y, x, I, U, N;
387
+ if (m === k.invalid) {
388
+ const f = A(
363
389
  u.value
364
390
  );
365
- v("invalid", i), (y = t == null ? void 0 : t.onInvalid) == null || y.call(t, i);
391
+ h("invalid", f), (y = t == null ? void 0 : t.onInvalid) == null || y.call(t, f);
366
392
  return;
367
393
  }
368
- if (b === x.valid) {
369
- const i = S(a.value);
370
- v("valid", i), (g = t == null ? void 0 : t.onValid) == null || g.call(t, i), v("update:modelValue", i), (p = t == null ? void 0 : t.onUpdate) == null || p.call(t, i);
394
+ if (m === k.valid) {
395
+ const f = A(n.value);
396
+ h("valid", f), (x = t == null ? void 0 : t.onValid) == null || x.call(t, f), h("update:modelValue", f), (I = t == null ? void 0 : t.onUpdate) == null || I.call(t, f);
371
397
  return;
372
398
  }
373
- if (b === x.submitting) {
374
- const i = S(a.value);
375
- v("submit", i), (E = t == null ? void 0 : t.onSubmit) == null || E.call(t, i);
399
+ if (m === k.submitting) {
400
+ const f = A(n.value);
401
+ h("submit", f), (U = t == null ? void 0 : t.onSubmit) == null || U.call(t, f);
376
402
  }
377
- if (b === x.updated) {
378
- if ((u.value || t != null && t.continuosValidation || m.continuosValidation) && await f(), !a.value || !m.modelValue || JSON.stringify(a.value) !== JSON.stringify(m.modelValue)) {
379
- const i = S(
380
- a.value
403
+ if (m === k.updated) {
404
+ if ((u.value || t != null && t.continuosValidation || v.continuosValidation) && await a(), !n.value || !v.modelValue || JSON.stringify(n.value) !== JSON.stringify(v.modelValue)) {
405
+ const f = A(
406
+ n.value
381
407
  );
382
- v("update:modelValue", i), (W = t == null ? void 0 : t.onUpdate) == null || W.call(t, i);
408
+ h("update:modelValue", f), (N = t == null ? void 0 : t.onUpdate) == null || N.call(t, f);
383
409
  }
384
- r.value === x.updated && (r.value = x.unknown);
410
+ r.value === k.updated && (r.value = k.unknown);
411
+ }
412
+ }), P(() => {
413
+ v.readonly && !i.value && (i.value = v.readonly);
414
+ }), O(
415
+ () => v.readonly,
416
+ (m) => {
417
+ i.value = m;
385
418
  }
419
+ ), O(i, (m) => {
420
+ m !== v.readonly && h("update:readonly", i.value);
386
421
  }), M(s, {
387
- formData: a,
388
- submit: n,
389
- validate: f,
390
- ignoreUpdates: c,
391
- stopUpdatesWatch: h,
392
- errors: I(u),
393
- status: I(r),
394
- invalid: l
422
+ formData: n,
423
+ submit: c,
424
+ validate: a,
425
+ ignoreUpdates: b,
426
+ stopUpdatesWatch: g,
427
+ errors: E(u),
428
+ status: E(r),
429
+ invalid: l,
430
+ readonly: i
395
431
  }), {
396
- formData: a,
397
- submit: n,
398
- validate: f,
399
- ignoreUpdates: c,
400
- stopUpdatesWatch: h,
401
- errors: I(u),
402
- status: I(r),
403
- invalid: l
432
+ formData: n,
433
+ submit: c,
434
+ validate: a,
435
+ ignoreUpdates: b,
436
+ stopUpdatesWatch: g,
437
+ errors: E(u),
438
+ status: E(r),
439
+ invalid: l,
440
+ isReadonly: i
404
441
  };
405
442
  },
406
443
  render() {
407
- const m = () => {
408
- var v, b;
409
- return ((b = (v = this.$slots) == null ? void 0 : v.default) == null ? void 0 : b.call(v, {
444
+ const v = () => {
445
+ var h, m;
446
+ return ((m = (h = this.$slots) == null ? void 0 : h.default) == null ? void 0 : m.call(h, {
410
447
  formData: this.formData,
411
448
  submit: this.submit,
412
449
  validate: this.validate,
@@ -414,26 +451,27 @@ const me = (e, s, t, o) => z({
414
451
  stopUpdatesWatch: this.stopUpdatesWatch,
415
452
  errors: this.errors,
416
453
  status: this.status,
417
- invalid: this.invalid
454
+ invalid: this.invalid,
455
+ readonly: this.isReadonly
418
456
  })) ?? this.$slots.default;
419
457
  };
420
- return w(
458
+ return p(
421
459
  this.tag,
422
460
  {
423
461
  onSubmit: re(this.submit, ["prevent"])
424
462
  },
425
463
  (this.template ?? (t == null ? void 0 : t.template)) && o ? [
426
- w(
464
+ p(
427
465
  o,
428
466
  {
429
467
  schema: this.template ?? (t == null ? void 0 : t.template)
430
468
  },
431
469
  {
432
- default: m
470
+ default: v
433
471
  }
434
472
  )
435
473
  ] : {
436
- default: m
474
+ default: v
437
475
  }
438
476
  );
439
477
  }
@@ -442,17 +480,18 @@ const me = (e, s, t, o) => z({
442
480
  errors: u,
443
481
  status: r,
444
482
  invalid: l,
445
- formData: a,
446
- validate: f,
447
- submit: n,
448
- ignoreUpdates: c,
449
- stopUpdatesWatch: h,
483
+ readonly: i,
484
+ formData: n,
485
+ validate: a,
486
+ submit: c,
487
+ ignoreUpdates: b,
488
+ stopUpdatesWatch: g,
450
489
  /**
451
490
  * An hack to add types to the default slot
452
491
  */
453
492
  VvForm: V
454
493
  };
455
- }, be = (e, s) => z({
494
+ }, ye = (e, s) => z({
456
495
  name: "VvFormWrapper",
457
496
  props: {
458
497
  name: {
@@ -467,33 +506,33 @@ const me = (e, s, t, o) => z({
467
506
  emits: ["invalid", "valid"],
468
507
  expose: ["fields", "invalid"],
469
508
  setup(o, { emit: u }) {
470
- const r = U(e), l = U(s, void 0), a = B(/* @__PURE__ */ new Set()), f = B(/* @__PURE__ */ new Map()), { name: n } = P(o);
509
+ const r = B(e), l = B(s, void 0), n = $(/* @__PURE__ */ new Set()), i = $(/* @__PURE__ */ new Map()), { name: a } = H(o);
471
510
  M(s, {
472
- name: I(n),
473
- errors: f,
474
- fields: a
475
- }), A(
476
- a,
477
- (h) => {
478
- l != null && l.fields && h.forEach((V) => {
479
- l == null || l.fields.value.add(V);
511
+ name: E(a),
512
+ errors: i,
513
+ fields: n
514
+ }), O(
515
+ n,
516
+ (b) => {
517
+ l != null && l.fields && b.forEach((g) => {
518
+ l == null || l.fields.value.add(g);
480
519
  });
481
520
  },
482
521
  { deep: !0 }
483
- ), A(
484
- () => new Map(f.value),
485
- (h, V) => {
486
- l != null && l.errors && (Array.from(V.keys()).forEach((m) => {
487
- l.errors.value.delete(m);
488
- }), Array.from(h.keys()).forEach((m) => {
489
- const v = h.get(m);
490
- v && l.errors.value.set(m, v);
522
+ ), O(
523
+ () => new Map(i.value),
524
+ (b, g) => {
525
+ l != null && l.errors && (Array.from(g.keys()).forEach((V) => {
526
+ l.errors.value.delete(V);
527
+ }), Array.from(b.keys()).forEach((V) => {
528
+ const v = b.get(V);
529
+ v && l.errors.value.set(V, v);
491
530
  }));
492
531
  },
493
532
  { deep: !0 }
494
533
  );
495
- const c = k(() => r != null && r.invalid.value ? f.value.size > 0 : !1);
496
- return A(c, () => {
534
+ const c = w(() => r != null && r.invalid.value ? i.value.size > 0 : !1);
535
+ return O(c, () => {
497
536
  c.value ? u("invalid") : u("valid");
498
537
  }), {
499
538
  formData: r == null ? void 0 : r.formData,
@@ -501,13 +540,13 @@ const me = (e, s, t, o) => z({
501
540
  submit: r == null ? void 0 : r.submit,
502
541
  validate: r == null ? void 0 : r.validate,
503
542
  invalid: c,
504
- fields: a,
505
- fieldsErrors: f
543
+ fields: n,
544
+ fieldsErrors: i
506
545
  };
507
546
  },
508
547
  render() {
509
548
  var o, u;
510
- return this.tag ? w(this.tag, null, {
549
+ return this.tag ? p(this.tag, null, {
511
550
  default: () => {
512
551
  var r, l;
513
552
  return ((l = (r = this.$slots).default) == null ? void 0 : l.call(r, {
@@ -528,7 +567,7 @@ const me = (e, s, t, o) => z({
528
567
  fieldsErrors: this.fieldsErrors
529
568
  })) ?? this.$slots.defalut;
530
569
  }
531
- }), ye = (e, s) => {
570
+ }), be = (e, s) => {
532
571
  const t = z({
533
572
  name: "VvFormTemplate",
534
573
  props: {
@@ -538,66 +577,66 @@ const me = (e, s, t, o) => z({
538
577
  }
539
578
  },
540
579
  setup(o, { slots: u }) {
541
- const r = U(e);
580
+ const r = B(e);
542
581
  if (r != null && r.formData)
543
582
  return () => {
544
- var n;
583
+ var a;
545
584
  const l = typeof o.schema == "function" ? o.schema(r) : o.schema;
546
- let a;
547
- const f = l.reduce((c, h) => {
548
- const V = typeof h == "function" ? h(r) : h, {
549
- vvIs: m,
585
+ let n;
586
+ const i = l.reduce((c, b) => {
587
+ const g = typeof b == "function" ? b(r) : b, {
588
+ vvIs: V,
550
589
  vvName: v,
551
- vvSlots: b,
552
- vvChildren: y,
553
- vvIf: g,
554
- vvElseIf: p,
555
- vvType: E,
556
- vvDefaultValue: W,
557
- vvShowValid: i,
558
- vvContent: N,
590
+ vvSlots: h,
591
+ vvChildren: m,
592
+ vvIf: y,
593
+ vvElseIf: x,
594
+ vvType: I,
595
+ vvDefaultValue: U,
596
+ vvShowValid: N,
597
+ vvContent: f,
559
598
  ..._
560
- } = V;
561
- if (g !== void 0) {
562
- if (typeof g == "string" ? a = !!G(
599
+ } = g;
600
+ if (y !== void 0) {
601
+ if (typeof y == "string" ? n = !!L(
563
602
  Object(r.formData.value),
564
- g
565
- ) : typeof g == "function" ? a = $(g(r)) : a = $(g), !a)
603
+ y
604
+ ) : typeof y == "function" ? n = C(y(r)) : n = C(y), !n)
566
605
  return c;
567
- } else if (p !== void 0 && a !== void 0) {
568
- if (a || (typeof p == "string" ? a = !!G(
606
+ } else if (x !== void 0 && n !== void 0) {
607
+ if (n || (typeof x == "string" ? n = !!L(
569
608
  Object(r.formData.value),
570
- p
571
- ) : typeof p == "function" ? a = $(p(r)) : a = $(p), !a))
609
+ x
610
+ ) : typeof x == "function" ? n = C(x(r)) : n = C(x), !n))
572
611
  return c;
573
612
  } else
574
- a = void 0;
575
- const Z = y ? w(t, {
576
- schema: y
613
+ n = void 0;
614
+ const W = m ? p(t, {
615
+ schema: m
577
616
  }) : void 0;
578
617
  return v ? (c.push(
579
- w(
618
+ p(
580
619
  s,
581
620
  {
582
621
  name: v,
583
- is: m,
584
- type: E,
585
- defaultValue: W,
586
- showValid: i,
622
+ is: V,
623
+ type: I,
624
+ defaultValue: U,
625
+ showValid: N,
587
626
  props: _
588
627
  },
589
- b ?? Z ?? N
628
+ h ?? W ?? f
590
629
  )
591
- ), c) : m ? (c.push(
592
- w(
593
- m,
630
+ ), c) : V ? (c.push(
631
+ p(
632
+ V,
594
633
  _,
595
- b ?? Z ?? N
634
+ h ?? W ?? f
596
635
  )
597
- ), c) : (y && c.push(Z), c);
636
+ ), c) : (m && c.push(W), c);
598
637
  }, []);
599
- return f.push(
600
- (n = u == null ? void 0 : u.default) == null ? void 0 : n.call(u, {
638
+ return i.push(
639
+ (a = u == null ? void 0 : u.default) == null ? void 0 : a.call(u, {
601
640
  formData: r == null ? void 0 : r.formData.value,
602
641
  submit: r == null ? void 0 : r.submit,
603
642
  validate: r == null ? void 0 : r.validate,
@@ -605,13 +644,13 @@ const me = (e, s, t, o) => z({
605
644
  status: r == null ? void 0 : r.status.value,
606
645
  invalid: r == null ? void 0 : r.invalid.value
607
646
  })
608
- ), f;
647
+ ), i;
609
648
  };
610
649
  }
611
650
  });
612
651
  return t;
613
- }, L = (e, s = {}) => {
614
- const t = Symbol(), o = Symbol(), u = Symbol(), r = be(
652
+ }, R = (e, s = {}) => {
653
+ const t = Symbol(), o = Symbol(), u = Symbol(), r = ye(
615
654
  t,
616
655
  o
617
656
  ), l = me(
@@ -619,54 +658,56 @@ const me = (e, s, t, o) => z({
619
658
  o,
620
659
  u,
621
660
  s
622
- ), a = ye(t, l), {
623
- VvForm: f,
624
- errors: n,
661
+ ), n = be(t, l), {
662
+ VvForm: i,
663
+ errors: a,
625
664
  status: c,
626
- invalid: h,
665
+ invalid: b,
666
+ readonly: g,
627
667
  formData: V,
628
- validate: m,
629
- submit: v,
630
- ignoreUpdates: b,
668
+ validate: v,
669
+ submit: h,
670
+ ignoreUpdates: m,
631
671
  stopUpdatesWatch: y
632
- } = he(e, t, s, a);
672
+ } = he(e, t, s, n);
633
673
  return {
634
- VvForm: f,
674
+ VvForm: i,
635
675
  VvFormWrapper: r,
636
676
  VvFormField: l,
637
- VvFormTemplate: a,
677
+ VvFormTemplate: n,
638
678
  formInjectionKey: t,
639
679
  formWrapperInjectionKey: o,
640
680
  formFieldInjectionKey: u,
641
- errors: n,
681
+ errors: a,
642
682
  status: c,
643
- invalid: h,
683
+ invalid: b,
684
+ readonly: g,
644
685
  formData: V,
645
- validate: m,
646
- submit: v,
647
- ignoreUpdates: b,
686
+ validate: v,
687
+ submit: h,
688
+ ignoreUpdates: m,
648
689
  stopUpdatesWatch: y
649
690
  };
650
- }, T = Symbol(), xe = (e) => {
691
+ }, D = Symbol(), ke = (e) => {
651
692
  let s = {};
652
- return e.schema && (s = L(e.schema, e)), {
693
+ return e.schema && (s = R(e.schema, e)), {
653
694
  ...s,
654
695
  install(t, { global: o = !1 } = {}) {
655
- t.provide(T, e), o && (t.config.globalProperties.$vvForm = e, s != null && s.VvForm && t.component("VvForm", s.VvForm), s != null && s.VvFormWrapper && t.component("VvFormWrapper", s.VvFormWrapper), s != null && s.VvFormField && t.component("VvFormField", s.VvFormField), s != null && s.VvFormTemplate && t.component("VvFormTemplate", s.VvFormTemplate));
696
+ t.provide(D, e), o && (t.config.globalProperties.$vvForm = e, s != null && s.VvForm && t.component("VvForm", s.VvForm), s != null && s.VvFormWrapper && t.component("VvFormWrapper", s.VvFormWrapper), s != null && s.VvFormField && t.component("VvFormField", s.VvFormField), s != null && s.VvFormTemplate && t.component("VvFormTemplate", s.VvFormTemplate));
656
697
  }
657
698
  };
658
- }, ke = (e, s = {}) => te() ? L(
699
+ }, we = (e, s = {}) => te() ? R(
659
700
  e,
660
701
  {
661
- ...U(T, {}),
702
+ ...B(D, {}),
662
703
  ...s
663
704
  }
664
- ) : L(e, s), we = (e, s = {}) => L(e, s);
705
+ ) : R(e, s), Oe = (e, s = {}) => R(e, s);
665
706
  export {
666
707
  d as FormFieldType,
667
- xe as createForm,
668
- R as defaultObjectBySchema,
669
- we as formFactory,
670
- T as pluginInjectionKey,
671
- ke as useForm
708
+ ke as createForm,
709
+ K as defaultObjectBySchema,
710
+ Oe as formFactory,
711
+ D as pluginInjectionKey,
712
+ we as useForm
672
713
  };