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

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