@macrulez/vue-form-schema 0.1.9 → 0.2.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.
Files changed (82) hide show
  1. package/README.md +461 -180
  2. package/dist/MaskEngine-BEXwX4BK.js +144 -0
  3. package/dist/MaskEngine-CPr-fSPy.cjs +1 -0
  4. package/dist/ValidationEngine-BC4U1ef1.js +135 -0
  5. package/dist/ValidationEngine-Diz-qTFs.cjs +1 -0
  6. package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
  7. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  8. package/dist/core/ConditionEvaluator.d.ts.map +1 -1
  9. package/dist/core/MaskEngine.d.ts.map +1 -1
  10. package/dist/core/ValidationEngine.d.ts +7 -0
  11. package/dist/core/ValidationEngine.d.ts.map +1 -1
  12. package/dist/core/formRegistry.d.ts +33 -0
  13. package/dist/core/formRegistry.d.ts.map +1 -0
  14. package/dist/core/inferTypes.d.ts.map +1 -1
  15. package/dist/core/schemaUtils.d.ts +38 -0
  16. package/dist/core/schemaUtils.d.ts.map +1 -1
  17. package/dist/core/serverErrors.d.ts +69 -0
  18. package/dist/core/serverErrors.d.ts.map +1 -0
  19. package/dist/core/types.d.ts +12 -0
  20. package/dist/core/types.d.ts.map +1 -1
  21. package/dist/core/useForm.d.ts +4 -1
  22. package/dist/core/useForm.d.ts.map +1 -1
  23. package/dist/core/useMultiStepForm.d.ts.map +1 -1
  24. package/dist/devtools/index.d.ts +26 -0
  25. package/dist/devtools/index.d.ts.map +1 -0
  26. package/dist/devtools.cjs +1 -0
  27. package/dist/devtools.d.ts +6 -0
  28. package/dist/devtools.js +93 -0
  29. package/dist/formRegistry-Bv1eaWQ-.js +31 -0
  30. package/dist/formRegistry-DaDmXyYY.cjs +1 -0
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.d.ts +4 -2
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +393 -368
  35. package/dist/openapi.cjs +1 -0
  36. package/dist/openapi.d.ts +202 -0
  37. package/dist/openapi.js +118 -0
  38. package/dist/parsers/json.d.ts.map +1 -1
  39. package/dist/parsers/openapi.d.ts +139 -0
  40. package/dist/parsers/openapi.d.ts.map +1 -0
  41. package/dist/parsers/valibot.d.ts +13 -4
  42. package/dist/parsers/valibot.d.ts.map +1 -1
  43. package/dist/parsers/yup.d.ts +10 -4
  44. package/dist/parsers/yup.d.ts.map +1 -1
  45. package/dist/parsers/zod.d.ts +18 -4
  46. package/dist/parsers/zod.d.ts.map +1 -1
  47. package/dist/schemaUtils-Cc7CwGXB.cjs +1 -0
  48. package/dist/schemaUtils-Cvlsk24U.js +337 -0
  49. package/dist/style.css +1 -0
  50. package/dist/ui/naive/index.d.ts +11 -0
  51. package/dist/ui/naive/index.d.ts.map +1 -0
  52. package/dist/ui/primevue/index.d.ts +11 -0
  53. package/dist/ui/primevue/index.d.ts.map +1 -0
  54. package/dist/ui/shadcn/index.d.ts +11 -0
  55. package/dist/ui/shadcn/index.d.ts.map +1 -0
  56. package/dist/ui-naive.cjs +1 -0
  57. package/dist/ui-naive.d.ts +276 -0
  58. package/dist/ui-naive.js +667 -0
  59. package/dist/ui-primevue.cjs +1 -0
  60. package/dist/ui-primevue.d.ts +276 -0
  61. package/dist/ui-primevue.js +651 -0
  62. package/dist/ui-shadcn.cjs +1 -0
  63. package/dist/ui-shadcn.d.ts +276 -0
  64. package/dist/ui-shadcn.js +650 -0
  65. package/dist/ui-tailwind.cjs +1 -1
  66. package/dist/ui-tailwind.d.ts +153 -274
  67. package/dist/ui-tailwind.js +180 -161
  68. package/dist/ui.cjs +1 -1
  69. package/dist/ui.d.ts +170 -308
  70. package/dist/ui.js +130 -131
  71. package/dist/valibot.cjs +1 -1
  72. package/dist/valibot.d.ts +25 -2
  73. package/dist/valibot.js +47 -20
  74. package/dist/yup.cjs +1 -1
  75. package/dist/yup.d.ts +23 -3
  76. package/dist/yup.js +16 -15
  77. package/dist/zod.cjs +1 -1
  78. package/dist/zod.d.ts +31 -3
  79. package/dist/zod.js +58 -28
  80. package/package.json +69 -7
  81. package/dist/MaskEngine-DAKSNIHQ.cjs +0 -1
  82. package/dist/MaskEngine-mLoXKd4d.js +0 -251
package/dist/ui.js CHANGED
@@ -1,10 +1,11 @@
1
- import { defineComponent as V, computed as B, openBlock as t, createElementBlock as r, normalizeClass as T, createTextVNode as I, toDisplayString as y, createCommentVNode as k, renderSlot as A, normalizeProps as W, guardReactiveProps as X, Fragment as x, renderList as S, ref as w, onMounted as Y, onUnmounted as Z, createBlock as F, withCtx as q, createElementVNode as b, mergeProps as R, createVNode as M, unref as z, resolveDynamicComponent as U, resolveComponent as _, createSlots as ee } from "vue";
2
- import { b as te, t as P, q as le, h as K } from "./MaskEngine-mLoXKd4d.js";
3
- const ae = ["for"], ne = {
1
+ import { defineComponent as V, computed as B, openBlock as t, createElementBlock as n, normalizeClass as T, createTextVNode as I, toDisplayString as y, createCommentVNode as k, renderSlot as A, normalizeProps as W, guardReactiveProps as X, Fragment as x, renderList as S, ref as w, onMounted as Y, onUnmounted as Z, createBlock as F, withCtx as q, createElementVNode as b, mergeProps as R, createVNode as M, unref as z, resolveDynamicComponent as U, resolveComponent as _, createSlots as ee } from "vue";
2
+ import { b as te, d as P, u as le } from "./MaskEngine-BEXwX4BK.js";
3
+ import { g as K } from "./ValidationEngine-BC4U1ef1.js";
4
+ const ae = ["for"], re = {
4
5
  key: 0,
5
6
  class: "vfs-field__required",
6
7
  "aria-hidden": "true"
7
- }, re = ["id"], C = /* @__PURE__ */ V({
8
+ }, ne = ["id"], C = /* @__PURE__ */ V({
8
9
  __name: "BaseField",
9
10
  props: {
10
11
  field: {},
@@ -13,37 +14,37 @@ const ae = ["for"], ne = {
13
14
  },
14
15
  setup(e) {
15
16
  const o = e, l = B(() => {
16
- var u;
17
- return !!(o.touched && ((u = o.error) != null && u.length));
17
+ var d;
18
+ return !!(o.touched && ((d = o.error) != null && d.length));
18
19
  }), s = B(() => `${o.field.name}-error`), a = B(() => ({
19
20
  "aria-required": o.field.required ? "true" : void 0,
20
21
  "aria-invalid": l.value ? "true" : "false",
21
22
  "aria-describedby": l.value ? s.value : void 0
22
23
  }));
23
- return (u, m) => (t(), r("div", {
24
+ return (d, m) => (t(), n("div", {
24
25
  class: T(["vfs-field", [`vfs-field--${o.field.type}`, { "vfs-field--error": l.value }]])
25
26
  }, [
26
- o.field.label ? (t(), r("label", {
27
+ o.field.label ? (t(), n("label", {
27
28
  key: 0,
28
29
  for: o.field.name,
29
30
  class: "vfs-field__label"
30
31
  }, [
31
32
  I(y(o.field.label) + " ", 1),
32
- o.field.required ? (t(), r("span", ne, "*")) : k("", !0)
33
+ o.field.required ? (t(), n("span", re, "*")) : k("", !0)
33
34
  ], 8, ae)) : k("", !0),
34
- A(u.$slots, "default", W(X(a.value))),
35
- l.value ? (t(), r("ul", {
35
+ A(d.$slots, "default", W(X(a.value))),
36
+ l.value ? (t(), n("ul", {
36
37
  key: 1,
37
38
  id: s.value,
38
39
  class: "vfs-field__errors",
39
40
  role: "alert",
40
41
  "aria-live": "polite"
41
42
  }, [
42
- (t(!0), r(x, null, S(e.error, (f, h) => (t(), r("li", {
43
+ (t(!0), n(x, null, S(e.error, (f, h) => (t(), n("li", {
43
44
  key: h,
44
45
  class: "vfs-field__error"
45
46
  }, y(f), 1))), 128))
46
- ], 8, re)) : k("", !0)
47
+ ], 8, ne)) : k("", !0)
47
48
  ], 2));
48
49
  }
49
50
  }), oe = ["id", "type", "name", "value", "placeholder", "disabled", "required"], N = /* @__PURE__ */ V({
@@ -57,10 +58,10 @@ const ae = ["for"], ne = {
57
58
  emits: ["update:modelValue", "blur"],
58
59
  setup(e, { emit: o }) {
59
60
  const l = e, s = o, a = w(null);
60
- let u = null;
61
+ let d = null;
61
62
  Y(() => {
62
- a.value && l.field.mask && (u = te(a.value, l.field.mask));
63
- }), Z(() => u == null ? void 0 : u());
63
+ a.value && l.field.mask && (d = te(a.value, l.field.mask));
64
+ }), Z(() => d == null ? void 0 : d());
64
65
  function m(f) {
65
66
  s("update:modelValue", f.target.value);
66
67
  }
@@ -101,10 +102,10 @@ const ae = ["for"], ne = {
101
102
  setup(e, { emit: o }) {
102
103
  const l = o;
103
104
  function s(a) {
104
- const u = a.target.value;
105
- l("update:modelValue", u === "" ? null : Number(u));
105
+ const d = a.target.value;
106
+ l("update:modelValue", d === "" ? null : Number(d));
106
107
  }
107
- return (a, u) => (t(), F(C, {
108
+ return (a, d) => (t(), F(C, {
108
109
  field: e.field,
109
110
  error: e.error,
110
111
  touched: e.touched
@@ -121,7 +122,7 @@ const ae = ["for"], ne = {
121
122
  }, m, {
122
123
  class: "vfs-input",
123
124
  onInput: s,
124
- onBlur: u[0] || (u[0] = (f) => l("blur"))
125
+ onBlur: d[0] || (d[0] = (f) => l("blur"))
125
126
  }), null, 16, ie)
126
127
  ]),
127
128
  _: 1
@@ -143,7 +144,7 @@ const ae = ["for"], ne = {
143
144
  error: e.error,
144
145
  touched: e.touched
145
146
  }, {
146
- default: q((u) => [
147
+ default: q((d) => [
147
148
  b("textarea", R({
148
149
  id: e.field.name,
149
150
  name: e.field.name,
@@ -151,7 +152,7 @@ const ae = ["for"], ne = {
151
152
  placeholder: e.field.placeholder,
152
153
  disabled: e.field.disabled === !0,
153
154
  required: e.field.required
154
- }, u, {
155
+ }, d, {
155
156
  class: "vfs-textarea",
156
157
  onInput: a[0] || (a[0] = (m) => l("update:modelValue", m.target.value)),
157
158
  onBlur: a[1] || (a[1] = (m) => l("blur"))
@@ -173,10 +174,8 @@ const ae = ["for"], ne = {
173
174
  },
174
175
  emits: ["update:modelValue", "blur"],
175
176
  setup(e, { emit: o }) {
176
- const l = e, s = o, a = B(
177
- () => Array.isArray(l.field.options) ? l.field.options : []
178
- );
179
- function u(m) {
177
+ const l = e, s = o, a = B(() => Array.isArray(l.field.options) ? l.field.options : []);
178
+ function d(m) {
180
179
  const f = m.target, h = a.value.find((c) => String(c.value) === f.value);
181
180
  s("update:modelValue", (h == null ? void 0 : h.value) ?? f.value);
182
181
  }
@@ -186,7 +185,7 @@ const ae = ["for"], ne = {
186
185
  touched: e.touched
187
186
  }, {
188
187
  default: q((h) => [
189
- e.field.optionsLoading ? (t(), r("div", de, "Loading…")) : (t(), r("select", R({
188
+ e.field.optionsLoading ? (t(), n("div", de, "Loading…")) : (t(), n("select", R({
190
189
  key: 1,
191
190
  id: e.field.name,
192
191
  name: e.field.name,
@@ -194,7 +193,7 @@ const ae = ["for"], ne = {
194
193
  required: e.field.required
195
194
  }, h, {
196
195
  class: "vfs-select",
197
- onChange: u,
196
+ onChange: d,
198
197
  onBlur: f[0] || (f[0] = (c) => s("blur"))
199
198
  }), [
200
199
  b("option", {
@@ -202,7 +201,7 @@ const ae = ["for"], ne = {
202
201
  disabled: "",
203
202
  selected: e.modelValue === null || e.modelValue === void 0 || e.modelValue === ""
204
203
  }, y(e.field.placeholder ?? "Select an option"), 9, ce),
205
- (t(!0), r(x, null, S(a.value, (c) => (t(), r("option", {
204
+ (t(!0), n(x, null, S(a.value, (c) => (t(), n("option", {
206
205
  key: String(c.value),
207
206
  value: String(c.value),
208
207
  selected: e.modelValue === c.value
@@ -231,7 +230,7 @@ const ae = ["for"], ne = {
231
230
  error: e.error,
232
231
  touched: e.touched
233
232
  }, {
234
- default: q((u) => [
233
+ default: q((d) => [
235
234
  b("label", fe, [
236
235
  b("input", R({
237
236
  id: e.field.name,
@@ -241,12 +240,12 @@ const ae = ["for"], ne = {
241
240
  disabled: e.field.disabled === !0,
242
241
  required: e.field.required,
243
242
  "aria-checked": e.modelValue ? "true" : "false"
244
- }, u, {
243
+ }, d, {
245
244
  class: "vfs-checkbox",
246
245
  onChange: a[0] || (a[0] = (m) => l("update:modelValue", m.target.checked)),
247
246
  onBlur: a[1] || (a[1] = (m) => l("blur"))
248
247
  }), null, 16, ve),
249
- e.field.label ? (t(), r("span", be, y(e.field.label), 1)) : k("", !0)
248
+ e.field.label ? (t(), n("span", be, y(e.field.label), 1)) : k("", !0)
250
249
  ])
251
250
  ]),
252
251
  _: 1
@@ -272,21 +271,19 @@ const ae = ["for"], ne = {
272
271
  const l = e, s = o, a = B(() => {
273
272
  var f;
274
273
  return !!(l.touched && ((f = l.error) != null && f.length));
275
- }), u = B(() => `${l.field.name}-error`), m = B(
276
- () => Array.isArray(l.field.options) ? l.field.options : []
277
- );
278
- return (f, h) => (t(), r("fieldset", {
274
+ }), d = B(() => `${l.field.name}-error`), m = B(() => Array.isArray(l.field.options) ? l.field.options : []);
275
+ return (f, h) => (t(), n("fieldset", {
279
276
  class: T(["vfs-field vfs-field--radio", { "vfs-field--error": a.value }]),
280
277
  "aria-required": e.field.required ? "true" : void 0,
281
278
  "aria-invalid": a.value ? "true" : "false",
282
- "aria-describedby": a.value ? u.value : void 0
279
+ "aria-describedby": a.value ? d.value : void 0
283
280
  }, [
284
- e.field.label ? (t(), r("legend", ye, [
281
+ e.field.label ? (t(), n("legend", ye, [
285
282
  I(y(e.field.label) + " ", 1),
286
- e.field.required ? (t(), r("span", $e, "*")) : k("", !0)
283
+ e.field.required ? (t(), n("span", $e, "*")) : k("", !0)
287
284
  ])) : k("", !0),
288
285
  b("div", ke, [
289
- (t(!0), r(x, null, S(m.value, (c) => (t(), r("label", {
286
+ (t(!0), n(x, null, S(m.value, (c) => (t(), n("label", {
290
287
  key: String(c.value),
291
288
  class: "vfs-radio-label"
292
289
  }, [
@@ -303,14 +300,14 @@ const ae = ["for"], ne = {
303
300
  I(" " + y(c.label), 1)
304
301
  ]))), 128))
305
302
  ]),
306
- a.value ? (t(), r("ul", {
303
+ a.value ? (t(), n("ul", {
307
304
  key: 1,
308
- id: u.value,
305
+ id: d.value,
309
306
  class: "vfs-field__errors",
310
307
  role: "alert",
311
308
  "aria-live": "polite"
312
309
  }, [
313
- (t(!0), r(x, null, S(e.error, (c, g) => (t(), r("li", {
310
+ (t(!0), n(x, null, S(e.error, (c, g) => (t(), n("li", {
314
311
  key: g,
315
312
  class: "vfs-field__error"
316
313
  }, y(c), 1))), 128))
@@ -333,7 +330,7 @@ const ae = ["for"], ne = {
333
330
  error: e.error,
334
331
  touched: e.touched
335
332
  }, {
336
- default: q((u) => [
333
+ default: q((d) => [
337
334
  b("input", R({
338
335
  id: e.field.name,
339
336
  type: "date",
@@ -341,7 +338,7 @@ const ae = ["for"], ne = {
341
338
  value: e.modelValue ?? "",
342
339
  disabled: e.field.disabled === !0,
343
340
  required: e.field.required
344
- }, u, {
341
+ }, d, {
345
342
  class: "vfs-input",
346
343
  onInput: a[0] || (a[0] = (m) => l("update:modelValue", m.target.value)),
347
344
  onBlur: a[1] || (a[1] = (m) => l("blur"))
@@ -372,20 +369,20 @@ const ae = ["for"], ne = {
372
369
  date: Q
373
370
  };
374
371
  function a($) {
375
- var n;
376
- return $.component ? $.component : ((n = o.components) == null ? void 0 : n[$.type]) ?? l[$.type] ?? s[$.type] ?? null;
372
+ var r;
373
+ return $.component ? $.component : ((r = o.components) == null ? void 0 : r[$.type]) ?? l[$.type] ?? s[$.type] ?? null;
377
374
  }
378
- const { rows: u, append: m, remove: f } = le(o.form, o.field.name);
375
+ const { rows: d, append: m, remove: f } = le(o.form, o.field.name);
379
376
  function h($) {
380
377
  return K(o.form.values.value, $.name);
381
378
  }
382
- function c($, n) {
383
- o.form.setField($.name, n);
379
+ function c($, r) {
380
+ o.form.setField($.name, r);
384
381
  }
385
382
  function g($) {
386
383
  var i;
387
- const n = o.form;
388
- (i = n.touchField) == null || i.call(n, $.name);
384
+ const r = o.form;
385
+ (i = r.touchField) == null || i.call(r, $.name);
389
386
  }
390
387
  function D($) {
391
388
  return o.form.errors.value[$.name] ?? [];
@@ -393,19 +390,19 @@ const ae = ["for"], ne = {
393
390
  function L($) {
394
391
  return o.form.touched.value[$.name] ?? !1;
395
392
  }
396
- return ($, n) => (t(), r("div", xe, [
393
+ return ($, r) => (t(), n("div", xe, [
397
394
  M(C, {
398
395
  field: { ...e.field, label: void 0 },
399
396
  error: [],
400
397
  touched: !1
401
398
  }, {
402
399
  default: q(() => [
403
- e.field.label ? (t(), r("div", Fe, y(e.field.label), 1)) : k("", !0),
404
- (t(!0), r(x, null, S(z(u), (i) => (t(), r("div", {
400
+ e.field.label ? (t(), n("div", Fe, y(e.field.label), 1)) : k("", !0),
401
+ (t(!0), n(x, null, S(z(d), (i) => (t(), n("div", {
405
402
  key: i.key,
406
403
  class: "vfs-array__row"
407
404
  }, [
408
- (t(!0), r(x, null, S(i.fields, (v) => (t(), r(x, {
405
+ (t(!0), n(x, null, S(i.fields, (v) => (t(), n(x, {
409
406
  key: v.name
410
407
  }, [
411
408
  a(v) ? (t(), F(U(a(v)), {
@@ -414,21 +411,21 @@ const ae = ["for"], ne = {
414
411
  "model-value": h(v),
415
412
  error: D(v),
416
413
  touched: L(v),
417
- "onUpdate:modelValue": (d) => c(v, d),
418
- onBlur: (d) => g(v)
414
+ "onUpdate:modelValue": (u) => c(v, u),
415
+ onBlur: (u) => g(v)
419
416
  }, null, 40, ["field", "model-value", "error", "touched", "onUpdate:modelValue", "onBlur"])) : k("", !0)
420
417
  ], 64))), 128)),
421
418
  b("button", {
422
419
  type: "button",
423
420
  class: "vfs-array__remove",
424
421
  onClick: (v) => z(f)(i.index)
425
- }, " Remove ", 8, qe)
422
+ }, "Remove", 8, qe)
426
423
  ]))), 128)),
427
424
  b("button", {
428
425
  type: "button",
429
426
  class: "vfs-array__add",
430
- onClick: n[0] || (n[0] = (i) => z(m)())
431
- }, " + Add row ")
427
+ onClick: r[0] || (r[0] = (i) => z(m)())
428
+ }, "+ Add row")
432
429
  ]),
433
430
  _: 1
434
431
  }, 8, ["field"])
@@ -450,7 +447,7 @@ const ae = ["for"], ne = {
450
447
  },
451
448
  emits: ["update:modelValue", "blur"],
452
449
  setup(e, { emit: o }) {
453
- const l = e, s = o, a = w(!1), u = w(null), m = B(() => l.modelValue ? Array.isArray(l.modelValue) ? l.modelValue : [l.modelValue] : []), f = B(() => l.field.multiple ?? !1);
450
+ const l = e, s = o, a = w(!1), d = w(null), m = B(() => l.modelValue ? Array.isArray(l.modelValue) ? l.modelValue : [l.modelValue] : []), f = B(() => l.field.multiple ?? !1);
454
451
  function h(i) {
455
452
  if (!i || i.length === 0) {
456
453
  s("update:modelValue", null);
@@ -472,10 +469,10 @@ const ae = ["for"], ne = {
472
469
  a.value = !1;
473
470
  }
474
471
  function $(i) {
475
- const v = m.value.filter((d, p) => p !== i);
476
- v.length === 0 ? (s("update:modelValue", null), u.value && (u.value.value = "")) : f.value ? s("update:modelValue", v) : s("update:modelValue", v[0]);
472
+ const v = m.value.filter((u, p) => p !== i);
473
+ v.length === 0 ? (s("update:modelValue", null), d.value && (d.value.value = "")) : f.value ? s("update:modelValue", v) : s("update:modelValue", v[0]);
477
474
  }
478
- function n(i) {
475
+ function r(i) {
479
476
  return i < 1024 ? `${i} B` : i < 1024 * 1024 ? `${(i / 1024).toFixed(1)} KB` : `${(i / (1024 * 1024)).toFixed(1)} MB`;
480
477
  }
481
478
  return (i, v) => (t(), F(C, {
@@ -483,7 +480,7 @@ const ae = ["for"], ne = {
483
480
  error: e.error,
484
481
  touched: e.touched
485
482
  }, {
486
- default: q((d) => [
483
+ default: q((u) => [
487
484
  b("div", {
488
485
  class: T(["vfs-file-zone", { "vfs-file-zone--dragging": a.value }]),
489
486
  onDragover: D,
@@ -493,14 +490,14 @@ const ae = ["for"], ne = {
493
490
  b("input", R({
494
491
  id: e.field.name,
495
492
  ref_key: "inputRef",
496
- ref: u,
493
+ ref: d,
497
494
  type: "file",
498
495
  name: e.field.name,
499
496
  accept: e.field.accept,
500
497
  multiple: f.value,
501
498
  disabled: e.field.disabled === !0,
502
499
  required: e.field.required
503
- }, d, {
500
+ }, u, {
504
501
  class: "vfs-file-input",
505
502
  onChange: c
506
503
  }), null, 16, Se),
@@ -513,16 +510,16 @@ const ae = ["for"], ne = {
513
510
  "aria-hidden": "true"
514
511
  }, "📁", -1)),
515
512
  b("span", null, y(a.value ? "Drop files here" : "Click to upload or drag & drop"), 1),
516
- e.field.accept ? (t(), r("span", Re, y(e.field.accept), 1)) : k("", !0)
513
+ e.field.accept ? (t(), n("span", Re, y(e.field.accept), 1)) : k("", !0)
517
514
  ], 8, Ce)
518
515
  ], 34),
519
- m.value.length ? (t(), r("ul", De, [
520
- (t(!0), r(x, null, S(m.value, (p, E) => (t(), r("li", {
516
+ m.value.length ? (t(), n("ul", De, [
517
+ (t(!0), n(x, null, S(m.value, (p, E) => (t(), n("li", {
521
518
  key: `${p.name}-${E}`,
522
519
  class: "vfs-file-item"
523
520
  }, [
524
521
  b("span", Le, y(p.name), 1),
525
- b("span", Ae, y(n(p.size)), 1),
522
+ b("span", Ae, y(r(p.size)), 1),
526
523
  b("button", {
527
524
  type: "button",
528
525
  class: "vfs-file-remove",
@@ -543,11 +540,12 @@ const ae = ["for"], ne = {
543
540
  props: {
544
541
  form: {},
545
542
  components: {},
546
- submitLabel: {}
543
+ submitLabel: {},
544
+ fields: {}
547
545
  },
548
546
  emits: ["submit"],
549
547
  setup(e, { emit: o }) {
550
- const l = e, s = P(), a = o, u = {
548
+ const l = e, s = P(), a = o, d = {
551
549
  text: N,
552
550
  email: N,
553
551
  number: O,
@@ -558,92 +556,93 @@ const ae = ["for"], ne = {
558
556
  date: Q,
559
557
  file: Te
560
558
  };
561
- function m(n) {
559
+ function m(r) {
562
560
  var i;
563
- return n.component ? n.component : ((i = l.components) == null ? void 0 : i[n.type]) ?? s[n.type] ?? u[n.type] ?? null;
561
+ return r.component ? r.component : ((i = l.components) == null ? void 0 : i[r.type]) ?? s[r.type] ?? d[r.type] ?? null;
564
562
  }
565
- function f(n) {
566
- return K(l.form.values.value, n.name);
563
+ function f(r) {
564
+ return K(l.form.values.value, r.name);
567
565
  }
568
- function h(n, i) {
569
- l.form.setField(n.name, i);
566
+ function h(r, i) {
567
+ l.form.setField(r.name, i);
570
568
  }
571
- function c(n) {
569
+ function c(r) {
572
570
  var v;
573
571
  const i = l.form;
574
- (v = i.touchField) == null || v.call(i, n.name);
572
+ (v = i.touchField) == null || v.call(i, r.name);
575
573
  }
576
- function g(n) {
577
- return l.form.errors.value[n.name] ?? [];
574
+ function g(r) {
575
+ return l.form.errors.value[r.name] ?? [];
578
576
  }
579
- function D(n) {
580
- return l.form.touched.value[n.name] ?? !1;
577
+ function D(r) {
578
+ return l.form.touched.value[r.name] ?? !1;
581
579
  }
582
580
  const L = B(
583
- () => l.form.fields.value.filter((n) => n.visible !== !1)
581
+ () => (l.fields ?? l.form.fields.value).filter((r) => r.visible !== !1)
584
582
  );
585
- async function $(n) {
586
- n.preventDefault(), await l.form.submit(), a("submit");
583
+ async function $(r) {
584
+ r.preventDefault(), await l.form.submit(), a("submit");
587
585
  }
588
- return (n, i) => {
586
+ return (r, i) => {
589
587
  const v = _("FormRenderer", !0);
590
- return t(), r("form", {
588
+ return t(), n("form", {
591
589
  class: "vfs-form",
592
590
  novalidate: "",
593
591
  onSubmit: $
594
592
  }, [
595
- (t(!0), r(x, null, S(L.value, (d) => (t(), r(x, {
596
- key: d.name
593
+ (t(!0), n(x, null, S(L.value, (u) => (t(), n(x, {
594
+ key: u.name
597
595
  }, [
598
- n.$slots[`field-${d.name}`] ? A(n.$slots, `field-${d.name}`, {
596
+ r.$slots[`field-${u.name}`] ? A(r.$slots, `field-${u.name}`, {
599
597
  key: 0,
600
- field: d,
601
- value: f(d),
602
- error: g(d),
603
- touched: D(d),
604
- setValue: (p) => h(d, p),
605
- touch: () => c(d)
606
- }) : d.type === "group" ? (t(), r("fieldset", ze, [
607
- d.label ? (t(), r("legend", Ie, y(d.label), 1)) : k("", !0),
608
- d.fields ? (t(), F(v, {
598
+ field: u,
599
+ value: f(u),
600
+ error: g(u),
601
+ touched: D(u),
602
+ setValue: (p) => h(u, p),
603
+ touch: () => c(u)
604
+ }) : u.type === "group" ? (t(), n("fieldset", ze, [
605
+ u.label ? (t(), n("legend", Ie, y(u.label), 1)) : k("", !0),
606
+ u.fields ? (t(), F(v, {
609
607
  key: 1,
610
608
  form: e.form,
609
+ fields: u.fields,
611
610
  components: e.components
612
- }, null, 8, ["form", "components"])) : k("", !0)
613
- ])) : d.type === "array" ? (t(), F(Be, {
611
+ }, null, 8, ["form", "fields", "components"])) : k("", !0)
612
+ ])) : u.type === "array" ? (t(), F(Be, {
614
613
  key: 2,
615
- field: d,
614
+ field: u,
616
615
  form: e.form,
617
616
  components: e.components
618
- }, null, 8, ["field", "form", "components"])) : m(d) ? (t(), F(U(m(d)), {
617
+ }, null, 8, ["field", "form", "components"])) : m(u) ? (t(), F(U(m(u)), {
619
618
  key: 3,
620
- field: d,
621
- "model-value": f(d),
622
- error: g(d),
623
- touched: D(d),
624
- "onUpdate:modelValue": (p) => h(d, p),
625
- onBlur: (p) => c(d)
619
+ field: u,
620
+ "model-value": f(u),
621
+ error: g(u),
622
+ touched: D(u),
623
+ "onUpdate:modelValue": (p) => h(u, p),
624
+ onBlur: (p) => c(u)
626
625
  }, ee({ _: 2 }, [
627
- n.$slots[`label-${d.name}`] ? {
626
+ r.$slots[`label-${u.name}`] ? {
628
627
  name: "label",
629
628
  fn: q(() => [
630
- A(n.$slots, `label-${d.name}`, { field: d })
629
+ A(r.$slots, `label-${u.name}`, { field: u })
631
630
  ]),
632
631
  key: "0"
633
632
  } : void 0,
634
- n.$slots[`error-${d.name}`] ? {
633
+ r.$slots[`error-${u.name}`] ? {
635
634
  name: "error",
636
635
  fn: q(() => [
637
- A(n.$slots, `error-${d.name}`, {
638
- field: d,
639
- error: g(d)
636
+ A(r.$slots, `error-${u.name}`, {
637
+ field: u,
638
+ error: g(u)
640
639
  })
641
640
  ]),
642
641
  key: "1"
643
642
  } : void 0
644
643
  ]), 1064, ["field", "model-value", "error", "touched", "onUpdate:modelValue", "onBlur"])) : k("", !0)
645
644
  ], 64))), 128)),
646
- A(n.$slots, "submit", {
645
+ A(r.$slots, "submit", {
647
646
  isSubmitting: e.form.isSubmitting.value,
648
647
  isValid: e.form.isValid.value
649
648
  }, () => [
@@ -659,7 +658,7 @@ const ae = ["for"], ne = {
659
658
  }), Me = { class: "vfs-multistep" }, Ue = { class: "vfs-multistep__steps" }, Pe = { class: "vfs-multistep__step-number" }, Ke = {
660
659
  key: 0,
661
660
  class: "vfs-multistep__step-label"
662
- }, Oe = { class: "vfs-multistep__progress" }, je = { class: "vfs-multistep__nav" }, Ge = ["disabled"], We = /* @__PURE__ */ V({
661
+ }, Oe = { class: "vfs-multistep__progress" }, je = { class: "vfs-multistep__nav" }, Ge = ["disabled"], Xe = /* @__PURE__ */ V({
663
662
  __name: "MultiStepFormRenderer",
664
663
  props: {
665
664
  form: {},
@@ -675,14 +674,14 @@ const ae = ["for"], ne = {
675
674
  async function a() {
676
675
  await l.form.next();
677
676
  }
678
- async function u() {
677
+ async function d() {
679
678
  await l.form.submit(), s("submit");
680
679
  }
681
- return (m, f) => (t(), r("div", Me, [
680
+ return (m, f) => (t(), n("div", Me, [
682
681
  b("div", Ue, [
683
- (t(!0), r(x, null, S(e.form.steps, (h, c) => {
682
+ (t(!0), n(x, null, S(e.form.steps, (h, c) => {
684
683
  var g;
685
- return t(), r("div", {
684
+ return t(), n("div", {
686
685
  key: c,
687
686
  class: T(["vfs-multistep__step", {
688
687
  "vfs-multistep__step--active": c === e.form.currentStep.value,
@@ -690,7 +689,7 @@ const ae = ["for"], ne = {
690
689
  }])
691
690
  }, [
692
691
  b("span", Pe, y(c + 1), 1),
693
- (g = e.stepLabels) != null && g[c] ? (t(), r("span", Ke, y(e.stepLabels[c]), 1)) : k("", !0)
692
+ (g = e.stepLabels) != null && g[c] ? (t(), n("span", Ke, y(e.stepLabels[c]), 1)) : k("", !0)
694
693
  ], 2);
695
694
  }), 128))
696
695
  ]),
@@ -701,19 +700,19 @@ const ae = ["for"], ne = {
701
700
  }, {
702
701
  submit: q(() => [
703
702
  b("div", je, [
704
- e.form.isFirstStep.value ? k("", !0) : (t(), r("button", {
703
+ e.form.isFirstStep.value ? k("", !0) : (t(), n("button", {
705
704
  key: 0,
706
705
  type: "button",
707
706
  class: "vfs-multistep__back",
708
707
  onClick: f[0] || (f[0] = (h) => e.form.back())
709
708
  }, y(e.backLabel ?? "← Back"), 1)),
710
- e.form.isLastStep.value ? (t(), r("button", {
709
+ e.form.isLastStep.value ? (t(), n("button", {
711
710
  key: 2,
712
711
  type: "button",
713
712
  class: "vfs-submit",
714
713
  disabled: e.form.isSubmitting.value,
715
- onClick: u
716
- }, y(e.submitLabel ?? "Submit"), 9, Ge)) : (t(), r("button", {
714
+ onClick: d
715
+ }, y(e.submitLabel ?? "Submit"), 9, Ge)) : (t(), n("button", {
717
716
  key: 1,
718
717
  type: "button",
719
718
  class: "vfs-multistep__next",
@@ -732,7 +731,7 @@ export {
732
731
  Q as DateField,
733
732
  Te as FileField,
734
733
  Ee as FormRenderer,
735
- We as MultiStepFormRenderer,
734
+ Xe as MultiStepFormRenderer,
736
735
  O as NumberField,
737
736
  J as RadioField,
738
737
  G as SelectField,
package/dist/valibot.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function p(t){if(!t||t.type!=="object"||!t.entries)throw new Error("[vue-form-schema] parseValibot expects a v.object() schema");return Object.entries(t.entries).map(([r,i])=>o(r,i))}function o(t,r){let i=!0,e=r;(e.type==="optional"||e.type==="nullable"||e.type==="nullish")&&(i=!1,e=e.wrapped??e);const a=u(e),s={type:a,name:t,required:i};return a==="select"&&(s.options=e.options.map(n=>({label:String(n),value:n}))),a==="group"&&e.entries&&(s.fields=Object.entries(e.entries).map(([n,l])=>o(n,l))),s}function u(t){const r=t.type;if(r==="string"&&Array.isArray(t.pipe)&&t.pipe.some(e=>e.type==="email"))return"email";switch(r){case"string":return"text";case"number":return"number";case"boolean":return"checkbox";case"picklist":case"enum":return"select";case"array":return"array";case"object":return"group";default:return"text"}}exports.parseValibot=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./schemaUtils-Cc7CwGXB.cjs");function b(r){const e=r;if((e==null?void 0:e.type)==="variant")return f(e);if(!e||e.type!=="object"||!e.entries)throw new Error("[vue-form-schema] parseValibot expects a v.object() or v.variant() schema");return Object.entries(e.entries).map(([i,t])=>l(i,t))}function f(r){const e=r.key,i=r.options;function t(n){var o;const s=n.entries??{};return String((o=s[e])==null?void 0:o.literal)}const c={type:"select",name:e,label:e,required:!0,options:i.map(n=>{const s=t(n);return{label:s,value:s}})},a={};for(const n of i){const s=n.entries??{};a[t(n)]=Object.entries(s).filter(([o])=>o!==e).map(([o,p])=>l(o,p))}return[c,...u.discriminatedFields(e,a)]}function l(r,e){let i=!0,t=e;(t.type==="optional"||t.type==="nullable"||t.type==="nullish")&&(i=!1,t=t.wrapped??t);const c=m(t),a={type:c,name:r,required:i};return c==="select"&&(a.options=t.options.map(n=>({label:String(n),value:n}))),c==="group"&&t.entries&&(a.fields=Object.entries(t.entries).map(([n,s])=>l(`${r}.${n}`,s))),a}function m(r){const e=r.type;if(e==="string"&&Array.isArray(r.pipe)&&r.pipe.some(t=>t.type==="email"))return"email";switch(e){case"string":return"text";case"number":return"number";case"boolean":return"checkbox";case"picklist":case"enum":return"select";case"array":return"array";case"object":return"group";default:return"text"}}exports.parseValibot=b;
package/dist/valibot.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { Component } from 'vue';
2
+ import { GenericSchema } from 'valibot';
3
+ import { InferOutput } from 'valibot';
2
4
 
3
5
  declare type AsyncValidatorFn = (value: unknown, values: Record<string, unknown>) => Promise<string | null>;
4
6
 
@@ -82,10 +84,31 @@ declare type MaskPreset = 'phone-ru' | 'phone-eu' | 'date' | 'inn' | 'iban';
82
84
  *
83
85
  * const schema = v.object({ email: v.pipe(v.string(), v.email()), age: v.number() })
84
86
  * const fields = parseValibot(schema)
87
+ *
88
+ * The return type carries the schema's inferred value type
89
+ * (`v.InferOutput<S>`), so `useForm({ schema: fields })` picks up fully
90
+ * typed `values`/`errors`/`onSubmit` without an explicit `useForm<Values>(...)`.
91
+ *
92
+ * Also accepts a `v.variant(key, [...])` schema — converted into a `select`
93
+ * field for the discriminator plus every variant's own fields, each only
94
+ * visible while the discriminator matches its variant (see
95
+ * `discriminatedFields`). Combine with `clearOnHide: true` on `useForm` so
96
+ * switching variants resets the now-hidden variant's values.
85
97
  */
86
- export declare function parseValibot(schema: ValibotSchema): FieldDefinition[];
98
+ export declare function parseValibot<S extends GenericSchema>(schema: S): TypedFieldDefinitions<InferOutput<S>>;
87
99
 
88
- declare type ValibotSchema = any;
100
+ /**
101
+ * A `FieldDefinition[]` returned by a schema adapter (`parseZod` / `parseYup`
102
+ * / `parseValibot`) that also carries the source schema's inferred value
103
+ * type at the type level. `useForm({ schema: parseZod(mySchema) })` then
104
+ * infers `T` automatically — no `useForm<Values>(...)` needed.
105
+ *
106
+ * `__inferredValues` does not exist at runtime; it is a type-only marker
107
+ * erased by the compiler.
108
+ */
109
+ declare type TypedFieldDefinitions<T> = FieldDefinition[] & {
110
+ readonly __inferredValues?: T;
111
+ };
89
112
 
90
113
  declare type ValidatorFn = (value: unknown, values: Record<string, unknown>) => string | null;
91
114