@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
@@ -1,5 +1,6 @@
1
- import { defineComponent as V, computed as $, openBlock as l, createElementBlock as u, createTextVNode as N, toDisplayString as x, createCommentVNode as p, renderSlot as E, normalizeProps as J, guardReactiveProps as O, Fragment as w, renderList as F, ref as I, onMounted as Q, onUnmounted as W, createBlock as k, withCtx as B, createElementVNode as g, mergeProps as C, withModifiers as X, normalizeClass as Y, unref as D, resolveDynamicComponent as z, resolveComponent as Z } from "vue";
2
- import { b as _, t as U, q as ee, h as M } from "./MaskEngine-mLoXKd4d.js";
1
+ import { defineComponent as V, computed as $, openBlock as l, createElementBlock as s, createTextVNode as N, toDisplayString as x, createCommentVNode as p, renderSlot as E, normalizeProps as J, guardReactiveProps as O, Fragment as w, renderList as F, ref as I, onMounted as Q, onUnmounted as W, createBlock as k, withCtx as q, createElementVNode as g, mergeProps as C, withModifiers as X, normalizeClass as Y, unref as D, resolveDynamicComponent as z, resolveComponent as Z } from "vue";
2
+ import { b as _, d as U, u as ee } from "./MaskEngine-BEXwX4BK.js";
3
+ import { g as M } from "./ValidationEngine-BC4U1ef1.js";
3
4
  const te = { class: "mb-4" }, re = ["for"], le = {
4
5
  key: 0,
5
6
  class: "text-red-400 ml-0.5",
@@ -12,32 +13,32 @@ const te = { class: "mb-4" }, re = ["for"], le = {
12
13
  touched: { type: Boolean }
13
14
  },
14
15
  setup(e) {
15
- const m = e, r = $(() => {
16
- var n;
17
- return !!(m.touched && ((n = m.error) != null && n.length));
16
+ const m = e, t = $(() => {
17
+ var d;
18
+ return !!(m.touched && ((d = m.error) != null && d.length));
18
19
  }), c = $(() => `${m.field.name}-error`), a = $(() => ({
19
20
  "aria-required": m.field.required ? "true" : void 0,
20
- "aria-invalid": r.value ? "true" : "false",
21
- "aria-describedby": r.value ? c.value : void 0
21
+ "aria-invalid": t.value ? "true" : "false",
22
+ "aria-describedby": t.value ? c.value : void 0
22
23
  }));
23
- return (n, d) => (l(), u("div", te, [
24
- e.field.label ? (l(), u("label", {
24
+ return (d, n) => (l(), s("div", te, [
25
+ e.field.label ? (l(), s("label", {
25
26
  key: 0,
26
27
  for: e.field.name,
27
28
  class: "block text-xs font-semibold uppercase tracking-wider text-gray-400 mb-1.5"
28
29
  }, [
29
30
  N(x(e.field.label) + " ", 1),
30
- e.field.required ? (l(), u("span", le, "*")) : p("", !0)
31
+ e.field.required ? (l(), s("span", le, "*")) : p("", !0)
31
32
  ], 8, re)) : p("", !0),
32
- E(n.$slots, "default", J(O(a.value))),
33
- r.value ? (l(), u("ul", {
33
+ E(d.$slots, "default", J(O(a.value))),
34
+ t.value ? (l(), s("ul", {
34
35
  key: 1,
35
36
  id: c.value,
36
37
  class: "mt-1 space-y-0.5",
37
38
  role: "alert",
38
39
  "aria-live": "polite"
39
40
  }, [
40
- (l(!0), u(w, null, F(e.error, (i, f) => (l(), u("li", {
41
+ (l(!0), s(w, null, F(e.error, (i, f) => (l(), s("li", {
41
42
  key: f,
42
43
  class: "text-red-400 text-xs"
43
44
  }, x(i), 1))), 128))
@@ -54,20 +55,20 @@ const te = { class: "mb-4" }, re = ["for"], le = {
54
55
  },
55
56
  emits: ["update:modelValue", "blur"],
56
57
  setup(e, { emit: m }) {
57
- const r = e, c = m, a = I(null);
58
- let n = null;
59
- const d = $(() => {
58
+ const t = e, c = m, a = I(null);
59
+ let d = null;
60
+ const n = $(() => {
60
61
  var i;
61
- return !!(r.touched && ((i = r.error) != null && i.length));
62
+ return !!(t.touched && ((i = t.error) != null && i.length));
62
63
  });
63
64
  return Q(() => {
64
- a.value && r.field.mask && (n = _(a.value, r.field.mask));
65
- }), W(() => n == null ? void 0 : n()), (i, f) => (l(), k(T, {
65
+ a.value && t.field.mask && (d = _(a.value, t.field.mask));
66
+ }), W(() => d == null ? void 0 : d()), (i, f) => (l(), k(T, {
66
67
  field: e.field,
67
68
  error: e.error,
68
69
  touched: e.touched
69
70
  }, {
70
- default: B((b) => [
71
+ default: q((b) => [
71
72
  g("input", C({
72
73
  id: e.field.name,
73
74
  ref_key: "inputRef",
@@ -79,7 +80,10 @@ const te = { class: "mb-4" }, re = ["for"], le = {
79
80
  disabled: e.field.disabled === !0,
80
81
  required: e.field.required
81
82
  }, b, {
82
- class: ["w-full rounded-lg border bg-gray-900 px-3 py-2 text-sm text-gray-100 placeholder-gray-500 outline-none transition focus:ring-2 disabled:cursor-not-allowed disabled:opacity-50", d.value ? "border-red-500 focus:ring-red-500" : "border-gray-700 focus:ring-indigo-500 focus:border-indigo-500"],
83
+ class: [
84
+ "w-full rounded-lg border bg-gray-900 px-3 py-2 text-sm text-gray-100 placeholder-gray-500 outline-none transition focus:ring-2 disabled:cursor-not-allowed disabled:opacity-50",
85
+ n.value ? "border-red-500 focus:ring-red-500" : "border-gray-700 focus:ring-indigo-500 focus:border-indigo-500"
86
+ ],
83
87
  onInput: f[0] || (f[0] = (y) => c("update:modelValue", y.target.value)),
84
88
  onBlur: f[1] || (f[1] = (y) => c("blur"))
85
89
  }), null, 16, ae)
@@ -87,7 +91,7 @@ const te = { class: "mb-4" }, re = ["for"], le = {
87
91
  _: 1
88
92
  }, 8, ["field", "error", "touched"]));
89
93
  }
90
- }), ne = ["id", "name", "value", "placeholder", "disabled", "required"], P = /* @__PURE__ */ V({
94
+ }), de = ["id", "name", "value", "placeholder", "disabled", "required"], P = /* @__PURE__ */ V({
91
95
  __name: "NumberField",
92
96
  props: {
93
97
  field: {},
@@ -97,20 +101,20 @@ const te = { class: "mb-4" }, re = ["for"], le = {
97
101
  },
98
102
  emits: ["update:modelValue", "blur"],
99
103
  setup(e, { emit: m }) {
100
- const r = e, c = m, a = $(() => {
101
- var d;
102
- return !!(r.touched && ((d = r.error) != null && d.length));
104
+ const t = e, c = m, a = $(() => {
105
+ var n;
106
+ return !!(t.touched && ((n = t.error) != null && n.length));
103
107
  });
104
- function n(d) {
105
- const i = d.target.value;
108
+ function d(n) {
109
+ const i = n.target.value;
106
110
  c("update:modelValue", i === "" ? null : Number(i));
107
111
  }
108
- return (d, i) => (l(), k(T, {
112
+ return (n, i) => (l(), k(T, {
109
113
  field: e.field,
110
114
  error: e.error,
111
115
  touched: e.touched
112
116
  }, {
113
- default: B((f) => [
117
+ default: q((f) => [
114
118
  g("input", C({
115
119
  id: e.field.name,
116
120
  type: "number",
@@ -120,15 +124,18 @@ const te = { class: "mb-4" }, re = ["for"], le = {
120
124
  disabled: e.field.disabled === !0,
121
125
  required: e.field.required
122
126
  }, f, {
123
- class: ["w-full rounded-lg border bg-gray-900 px-3 py-2 text-sm text-gray-100 placeholder-gray-500 outline-none transition focus:ring-2 disabled:cursor-not-allowed disabled:opacity-50", a.value ? "border-red-500 focus:ring-red-500" : "border-gray-700 focus:ring-indigo-500 focus:border-indigo-500"],
124
- onInput: n,
127
+ class: [
128
+ "w-full rounded-lg border bg-gray-900 px-3 py-2 text-sm text-gray-100 placeholder-gray-500 outline-none transition focus:ring-2 disabled:cursor-not-allowed disabled:opacity-50",
129
+ a.value ? "border-red-500 focus:ring-red-500" : "border-gray-700 focus:ring-indigo-500 focus:border-indigo-500"
130
+ ],
131
+ onInput: d,
125
132
  onBlur: i[0] || (i[0] = (b) => c("blur"))
126
- }), null, 16, ne)
133
+ }), null, 16, de)
127
134
  ]),
128
135
  _: 1
129
136
  }, 8, ["field", "error", "touched"]));
130
137
  }
131
- }), de = ["id", "name", "value", "placeholder", "disabled", "required"], L = /* @__PURE__ */ V({
138
+ }), ne = ["id", "name", "value", "placeholder", "disabled", "required"], L = /* @__PURE__ */ V({
132
139
  __name: "TextareaField",
133
140
  props: {
134
141
  field: {},
@@ -138,16 +145,16 @@ const te = { class: "mb-4" }, re = ["for"], le = {
138
145
  },
139
146
  emits: ["update:modelValue", "blur"],
140
147
  setup(e, { emit: m }) {
141
- const r = e, c = m, a = $(() => {
142
- var n;
143
- return !!(r.touched && ((n = r.error) != null && n.length));
148
+ const t = e, c = m, a = $(() => {
149
+ var d;
150
+ return !!(t.touched && ((d = t.error) != null && d.length));
144
151
  });
145
- return (n, d) => (l(), k(T, {
152
+ return (d, n) => (l(), k(T, {
146
153
  field: e.field,
147
154
  error: e.error,
148
155
  touched: e.touched
149
156
  }, {
150
- default: B((i) => [
157
+ default: q((i) => [
151
158
  g("textarea", C({
152
159
  id: e.field.name,
153
160
  name: e.field.name,
@@ -156,11 +163,14 @@ const te = { class: "mb-4" }, re = ["for"], le = {
156
163
  disabled: e.field.disabled === !0,
157
164
  required: e.field.required
158
165
  }, i, {
159
- class: ["w-full resize-y rounded-lg border bg-gray-900 px-3 py-2 text-sm text-gray-100 placeholder-gray-500 outline-none transition focus:ring-2 disabled:cursor-not-allowed disabled:opacity-50", a.value ? "border-red-500 focus:ring-red-500" : "border-gray-700 focus:ring-indigo-500 focus:border-indigo-500"],
166
+ class: [
167
+ "w-full resize-y rounded-lg border bg-gray-900 px-3 py-2 text-sm text-gray-100 placeholder-gray-500 outline-none transition focus:ring-2 disabled:cursor-not-allowed disabled:opacity-50",
168
+ a.value ? "border-red-500 focus:ring-red-500" : "border-gray-700 focus:ring-indigo-500 focus:border-indigo-500"
169
+ ],
160
170
  style: { "min-height": "80px" },
161
- onInput: d[0] || (d[0] = (f) => c("update:modelValue", f.target.value)),
162
- onBlur: d[1] || (d[1] = (f) => c("blur"))
163
- }), null, 16, de)
171
+ onInput: n[0] || (n[0] = (f) => c("update:modelValue", f.target.value)),
172
+ onBlur: n[1] || (n[1] = (f) => c("blur"))
173
+ }), null, 16, ne)
164
174
  ]),
165
175
  _: 1
166
176
  }, 8, ["field", "error", "touched"]));
@@ -178,13 +188,11 @@ const te = { class: "mb-4" }, re = ["for"], le = {
178
188
  },
179
189
  emits: ["update:modelValue", "blur"],
180
190
  setup(e, { emit: m }) {
181
- const r = e, c = m, a = $(
182
- () => Array.isArray(r.field.options) ? r.field.options : []
183
- ), n = $(() => {
191
+ const t = e, c = m, a = $(() => Array.isArray(t.field.options) ? t.field.options : []), d = $(() => {
184
192
  var i;
185
- return !!(r.touched && ((i = r.error) != null && i.length));
193
+ return !!(t.touched && ((i = t.error) != null && i.length));
186
194
  });
187
- function d(i) {
195
+ function n(i) {
188
196
  const f = i.target, b = a.value.find((y) => String(y.value) === f.value);
189
197
  c("update:modelValue", (b == null ? void 0 : b.value) ?? f.value);
190
198
  }
@@ -193,16 +201,19 @@ const te = { class: "mb-4" }, re = ["for"], le = {
193
201
  error: e.error,
194
202
  touched: e.touched
195
203
  }, {
196
- default: B((b) => [
197
- e.field.optionsLoading ? (l(), u("div", ie, "Loading…")) : (l(), u("select", C({
204
+ default: q((b) => [
205
+ e.field.optionsLoading ? (l(), s("div", ie, "Loading…")) : (l(), s("select", C({
198
206
  key: 1,
199
207
  id: e.field.name,
200
208
  name: e.field.name,
201
209
  disabled: e.field.disabled === !0 || e.field.optionsLoading,
202
210
  required: e.field.required
203
211
  }, b, {
204
- class: ["w-full rounded-lg border bg-gray-900 px-3 py-2 text-sm text-gray-100 outline-none transition focus:ring-2 disabled:cursor-not-allowed disabled:opacity-50", n.value ? "border-red-500 focus:ring-red-500" : "border-gray-700 focus:ring-indigo-500 focus:border-indigo-500"],
205
- onChange: d,
212
+ class: [
213
+ "w-full rounded-lg border bg-gray-900 px-3 py-2 text-sm text-gray-100 outline-none transition focus:ring-2 disabled:cursor-not-allowed disabled:opacity-50",
214
+ d.value ? "border-red-500 focus:ring-red-500" : "border-gray-700 focus:ring-indigo-500 focus:border-indigo-500"
215
+ ],
216
+ onChange: n,
206
217
  onBlur: f[0] || (f[0] = (y) => c("blur"))
207
218
  }), [
208
219
  g("option", {
@@ -211,7 +222,7 @@ const te = { class: "mb-4" }, re = ["for"], le = {
211
222
  selected: e.modelValue === null || e.modelValue === void 0 || e.modelValue === "",
212
223
  class: "bg-gray-800"
213
224
  }, x(e.field.placeholder ?? "Select an option"), 9, se),
214
- (l(!0), u(w, null, F(a.value, (y) => (l(), u("option", {
225
+ (l(!0), s(w, null, F(a.value, (y) => (l(), s("option", {
215
226
  key: String(y.value),
216
227
  value: String(y.value),
217
228
  selected: e.modelValue === y.value,
@@ -235,13 +246,13 @@ const te = { class: "mb-4" }, re = ["for"], le = {
235
246
  },
236
247
  emits: ["update:modelValue", "blur"],
237
248
  setup(e, { emit: m }) {
238
- const r = m;
249
+ const t = m;
239
250
  return (c, a) => (l(), k(T, {
240
251
  field: { ...e.field, label: void 0 },
241
252
  error: e.error,
242
253
  touched: e.touched
243
254
  }, {
244
- default: B((n) => [
255
+ default: q((d) => [
245
256
  g("label", me, [
246
257
  g("input", C({
247
258
  id: e.field.name,
@@ -251,12 +262,12 @@ const te = { class: "mb-4" }, re = ["for"], le = {
251
262
  disabled: e.field.disabled === !0,
252
263
  required: e.field.required,
253
264
  "aria-checked": e.modelValue ? "true" : "false"
254
- }, n, {
265
+ }, d, {
255
266
  class: "h-4 w-4 cursor-pointer rounded border-gray-600 bg-gray-900 text-indigo-500 accent-indigo-500 disabled:cursor-not-allowed disabled:opacity-50",
256
- onChange: a[0] || (a[0] = (d) => r("update:modelValue", d.target.checked)),
257
- onBlur: a[1] || (a[1] = (d) => r("blur"))
267
+ onChange: a[0] || (a[0] = (n) => t("update:modelValue", n.target.checked)),
268
+ onBlur: a[1] || (a[1] = (n) => t("blur"))
258
269
  }), null, 16, fe),
259
- e.field.label ? (l(), u("span", be, x(e.field.label), 1)) : p("", !0)
270
+ e.field.label ? (l(), s("span", be, x(e.field.label), 1)) : p("", !0)
260
271
  ])
261
272
  ]),
262
273
  _: 1
@@ -279,24 +290,22 @@ const te = { class: "mb-4" }, re = ["for"], le = {
279
290
  },
280
291
  emits: ["update:modelValue", "blur"],
281
292
  setup(e, { emit: m }) {
282
- const r = e, c = m, a = $(() => {
293
+ const t = e, c = m, a = $(() => {
283
294
  var i;
284
- return !!(r.touched && ((i = r.error) != null && i.length));
285
- }), n = $(() => `${r.field.name}-error`), d = $(
286
- () => Array.isArray(r.field.options) ? r.field.options : []
287
- );
288
- return (i, f) => (l(), u("fieldset", {
295
+ return !!(t.touched && ((i = t.error) != null && i.length));
296
+ }), d = $(() => `${t.field.name}-error`), n = $(() => Array.isArray(t.field.options) ? t.field.options : []);
297
+ return (i, f) => (l(), s("fieldset", {
289
298
  class: "mb-4",
290
299
  "aria-required": e.field.required ? "true" : void 0,
291
300
  "aria-invalid": a.value ? "true" : "false",
292
- "aria-describedby": a.value ? n.value : void 0
301
+ "aria-describedby": a.value ? d.value : void 0
293
302
  }, [
294
- e.field.label ? (l(), u("legend", ye, [
303
+ e.field.label ? (l(), s("legend", ye, [
295
304
  N(x(e.field.label) + " ", 1),
296
- e.field.required ? (l(), u("span", he, "*")) : p("", !0)
305
+ e.field.required ? (l(), s("span", he, "*")) : p("", !0)
297
306
  ])) : p("", !0),
298
307
  g("div", ve, [
299
- (l(!0), u(w, null, F(d.value, (b) => (l(), u("label", {
308
+ (l(!0), s(w, null, F(n.value, (b) => (l(), s("label", {
300
309
  key: String(b.value),
301
310
  class: "flex cursor-pointer items-center gap-2.5"
302
311
  }, [
@@ -313,14 +322,14 @@ const te = { class: "mb-4" }, re = ["for"], le = {
313
322
  g("span", $e, x(b.label), 1)
314
323
  ]))), 128))
315
324
  ]),
316
- a.value ? (l(), u("ul", {
325
+ a.value ? (l(), s("ul", {
317
326
  key: 1,
318
- id: n.value,
327
+ id: d.value,
319
328
  class: "mt-1 space-y-0.5",
320
329
  role: "alert",
321
330
  "aria-live": "polite"
322
331
  }, [
323
- (l(!0), u(w, null, F(e.error, (b, y) => (l(), u("li", {
332
+ (l(!0), s(w, null, F(e.error, (b, y) => (l(), s("li", {
324
333
  key: y,
325
334
  class: "text-red-400 text-xs"
326
335
  }, x(b), 1))), 128))
@@ -337,16 +346,16 @@ const te = { class: "mb-4" }, re = ["for"], le = {
337
346
  },
338
347
  emits: ["update:modelValue", "blur"],
339
348
  setup(e, { emit: m }) {
340
- const r = e, c = m, a = $(() => {
341
- var n;
342
- return !!(r.touched && ((n = r.error) != null && n.length));
349
+ const t = e, c = m, a = $(() => {
350
+ var d;
351
+ return !!(t.touched && ((d = t.error) != null && d.length));
343
352
  });
344
- return (n, d) => (l(), k(T, {
353
+ return (d, n) => (l(), k(T, {
345
354
  field: e.field,
346
355
  error: e.error,
347
356
  touched: e.touched
348
357
  }, {
349
- default: B((i) => [
358
+ default: q((i) => [
350
359
  g("input", C({
351
360
  id: e.field.name,
352
361
  type: "date",
@@ -355,18 +364,21 @@ const te = { class: "mb-4" }, re = ["for"], le = {
355
364
  disabled: e.field.disabled === !0,
356
365
  required: e.field.required
357
366
  }, i, {
358
- class: ["w-full rounded-lg border bg-gray-900 px-3 py-2 text-sm text-gray-100 outline-none transition focus:ring-2 disabled:cursor-not-allowed disabled:opacity-50", a.value ? "border-red-500 focus:ring-red-500" : "border-gray-700 focus:ring-indigo-500 focus:border-indigo-500"],
359
- onInput: d[0] || (d[0] = (f) => c("update:modelValue", f.target.value)),
360
- onBlur: d[1] || (d[1] = (f) => c("blur"))
367
+ class: [
368
+ "w-full rounded-lg border bg-gray-900 px-3 py-2 text-sm text-gray-100 outline-none transition focus:ring-2 disabled:cursor-not-allowed disabled:opacity-50",
369
+ a.value ? "border-red-500 focus:ring-red-500" : "border-gray-700 focus:ring-indigo-500 focus:border-indigo-500"
370
+ ],
371
+ onInput: n[0] || (n[0] = (f) => c("update:modelValue", f.target.value)),
372
+ onBlur: n[1] || (n[1] = (f) => c("blur"))
361
373
  }), null, 16, ke)
362
374
  ]),
363
375
  _: 1
364
376
  }, 8, ["field", "error", "touched"]));
365
377
  }
366
- }), Ve = ["id", "name", "accept", "multiple", "disabled", "required"], we = { class: "pointer-events-none space-y-1" }, Fe = { class: "text-sm text-gray-300" }, qe = {
378
+ }), Ve = ["id", "name", "accept", "multiple", "disabled", "required"], we = { class: "pointer-events-none space-y-1" }, Fe = { class: "text-sm text-gray-300" }, Be = {
367
379
  key: 0,
368
380
  class: "text-xs text-gray-500"
369
- }, Be = {
381
+ }, qe = {
370
382
  key: 0,
371
383
  class: "mt-2 space-y-1"
372
384
  }, Ce = { class: "truncate text-gray-200" }, Te = { class: "ml-2 shrink-0 text-xs text-gray-500" }, Se = ["aria-label", "onClick"], Re = /* @__PURE__ */ V({
@@ -379,7 +391,7 @@ const te = { class: "mb-4" }, re = ["for"], le = {
379
391
  },
380
392
  emits: ["update:modelValue", "blur"],
381
393
  setup(e, { emit: m }) {
382
- const r = e, c = m, a = I(!1), n = I(null), d = $(() => r.modelValue ? Array.isArray(r.modelValue) ? r.modelValue : [r.modelValue] : []), i = $(() => r.field.multiple ?? !1);
394
+ const t = e, c = m, a = I(!1), d = I(null), n = $(() => t.modelValue ? Array.isArray(t.modelValue) ? t.modelValue : [t.modelValue] : []), i = $(() => t.field.multiple ?? !1);
383
395
  function f(o) {
384
396
  if (!o || o.length === 0) {
385
397
  c("update:modelValue", null);
@@ -391,34 +403,37 @@ const te = { class: "mb-4" }, re = ["for"], le = {
391
403
  f(o.target.files), c("blur");
392
404
  }
393
405
  function y(o) {
394
- var t;
395
- a.value = !1, o.preventDefault(), f(((t = o.dataTransfer) == null ? void 0 : t.files) ?? null), c("blur");
406
+ var r;
407
+ a.value = !1, o.preventDefault(), f(((r = o.dataTransfer) == null ? void 0 : r.files) ?? null), c("blur");
396
408
  }
397
409
  function S(o) {
398
- const t = d.value.filter((h, v) => v !== o);
399
- t.length === 0 ? (c("update:modelValue", null), n.value && (n.value.value = "")) : c("update:modelValue", i.value ? t : t[0]);
410
+ const r = n.value.filter((h, v) => v !== o);
411
+ r.length === 0 ? (c("update:modelValue", null), d.value && (d.value.value = "")) : c("update:modelValue", i.value ? r : r[0]);
400
412
  }
401
413
  function R(o) {
402
414
  return o < 1024 ? `${o} B` : o < 1024 * 1024 ? `${(o / 1024).toFixed(1)} KB` : `${(o / (1024 * 1024)).toFixed(1)} MB`;
403
415
  }
404
- return (o, t) => (l(), k(T, {
416
+ return (o, r) => (l(), k(T, {
405
417
  field: e.field,
406
418
  error: e.error,
407
419
  touched: e.touched
408
420
  }, {
409
- default: B((h) => {
421
+ default: q((h) => {
410
422
  var v;
411
423
  return [
412
424
  g("div", {
413
- class: Y(["relative rounded-lg border-2 border-dashed p-6 text-center transition", a.value ? "border-indigo-500 bg-indigo-500/10" : e.touched && ((v = e.error) != null && v.length) ? "border-red-500 bg-red-500/5" : "border-gray-700 bg-gray-900 hover:border-gray-500"]),
414
- onDragover: t[0] || (t[0] = X((s) => a.value = !0, ["prevent"])),
415
- onDragleave: t[1] || (t[1] = (s) => a.value = !1),
425
+ class: Y([
426
+ "relative rounded-lg border-2 border-dashed p-6 text-center transition",
427
+ a.value ? "border-indigo-500 bg-indigo-500/10" : e.touched && ((v = e.error) != null && v.length) ? "border-red-500 bg-red-500/5" : "border-gray-700 bg-gray-900 hover:border-gray-500"
428
+ ]),
429
+ onDragover: r[0] || (r[0] = X((u) => a.value = !0, ["prevent"])),
430
+ onDragleave: r[1] || (r[1] = (u) => a.value = !1),
416
431
  onDrop: y
417
432
  }, [
418
433
  g("input", C({
419
434
  id: e.field.name,
420
435
  ref_key: "inputRef",
421
- ref: n,
436
+ ref: d,
422
437
  type: "file",
423
438
  name: e.field.name,
424
439
  accept: e.field.accept,
@@ -430,23 +445,23 @@ const te = { class: "mb-4" }, re = ["for"], le = {
430
445
  onChange: b
431
446
  }), null, 16, Ve),
432
447
  g("div", we, [
433
- t[2] || (t[2] = g("div", { class: "text-2xl" }, "📁", -1)),
448
+ r[2] || (r[2] = g("div", { class: "text-2xl" }, "📁", -1)),
434
449
  g("p", Fe, x(a.value ? "Drop files here" : "Click to upload or drag & drop"), 1),
435
- e.field.accept ? (l(), u("p", qe, x(e.field.accept), 1)) : p("", !0)
450
+ e.field.accept ? (l(), s("p", Be, x(e.field.accept), 1)) : p("", !0)
436
451
  ])
437
452
  ], 34),
438
- d.value.length ? (l(), u("ul", Be, [
439
- (l(!0), u(w, null, F(d.value, (s, q) => (l(), u("li", {
440
- key: `${s.name}-${q}`,
453
+ n.value.length ? (l(), s("ul", qe, [
454
+ (l(!0), s(w, null, F(n.value, (u, B) => (l(), s("li", {
455
+ key: `${u.name}-${B}`,
441
456
  class: "flex items-center justify-between rounded-lg border border-gray-700 bg-gray-900 px-3 py-2 text-sm"
442
457
  }, [
443
- g("span", Ce, x(s.name), 1),
444
- g("span", Te, x(R(s.size)), 1),
458
+ g("span", Ce, x(u.name), 1),
459
+ g("span", Te, x(R(u.size)), 1),
445
460
  g("button", {
446
461
  type: "button",
447
- "aria-label": `Remove ${s.name}`,
462
+ "aria-label": `Remove ${u.name}`,
448
463
  class: "ml-2 shrink-0 text-gray-500 hover:text-red-400 transition",
449
- onClick: (Pe) => S(q)
464
+ onClick: (Pe) => S(B)
450
465
  }, " × ", 8, Se)
451
466
  ]))), 128))
452
467
  ])) : p("", !0)
@@ -466,7 +481,7 @@ const te = { class: "mb-4" }, re = ["for"], le = {
466
481
  components: {}
467
482
  },
468
483
  setup(e) {
469
- const m = e, r = U(), c = {
484
+ const m = e, t = U(), c = {
470
485
  text: A,
471
486
  email: A,
472
487
  number: P,
@@ -477,20 +492,20 @@ const te = { class: "mb-4" }, re = ["for"], le = {
477
492
  date: H
478
493
  };
479
494
  function a(o) {
480
- var t;
481
- return o.component ? o.component : ((t = m.components) == null ? void 0 : t[o.type]) ?? r[o.type] ?? c[o.type] ?? null;
495
+ var r;
496
+ return o.component ? o.component : ((r = m.components) == null ? void 0 : r[o.type]) ?? t[o.type] ?? c[o.type] ?? null;
482
497
  }
483
- const { rows: n, append: d, remove: i } = ee(m.form, m.field.name);
498
+ const { rows: d, append: n, remove: i } = ee(m.form, m.field.name);
484
499
  function f(o) {
485
500
  return M(m.form.values.value, o.name);
486
501
  }
487
- function b(o, t) {
488
- m.form.setField(o.name, t);
502
+ function b(o, r) {
503
+ m.form.setField(o.name, r);
489
504
  }
490
505
  function y(o) {
491
506
  var h;
492
- const t = m.form;
493
- (h = t.touchField) == null || h.call(t, o.name);
507
+ const r = m.form;
508
+ (h = r.touchField) == null || h.call(r, o.name);
494
509
  }
495
510
  function S(o) {
496
511
  return m.form.errors.value[o.name] ?? [];
@@ -498,14 +513,14 @@ const te = { class: "mb-4" }, re = ["for"], le = {
498
513
  function R(o) {
499
514
  return m.form.touched.value[o.name] ?? !1;
500
515
  }
501
- return (o, t) => (l(), u("div", Ae, [
502
- e.field.label ? (l(), u("div", De, x(e.field.label), 1)) : p("", !0),
503
- (l(!0), u(w, null, F(D(n), (h) => (l(), u("div", {
516
+ return (o, r) => (l(), s("div", Ae, [
517
+ e.field.label ? (l(), s("div", De, x(e.field.label), 1)) : p("", !0),
518
+ (l(!0), s(w, null, F(D(d), (h) => (l(), s("div", {
504
519
  key: h.key,
505
520
  class: "mb-2 flex items-start gap-2 rounded-lg border border-gray-700 bg-gray-900 p-3"
506
521
  }, [
507
522
  g("div", Ee, [
508
- (l(!0), u(w, null, F(h.fields, (v) => (l(), u(w, {
523
+ (l(!0), s(w, null, F(h.fields, (v) => (l(), s(w, {
509
524
  key: v.name
510
525
  }, [
511
526
  a(v) ? (l(), k(z(a(v)), {
@@ -514,8 +529,8 @@ const te = { class: "mb-4" }, re = ["for"], le = {
514
529
  "model-value": f(v),
515
530
  error: S(v),
516
531
  touched: R(v),
517
- "onUpdate:modelValue": (s) => b(v, s),
518
- onBlur: (s) => y(v)
532
+ "onUpdate:modelValue": (u) => b(v, u),
533
+ onBlur: (u) => y(v)
519
534
  }, null, 40, ["field", "model-value", "error", "touched", "onUpdate:modelValue", "onBlur"])) : p("", !0)
520
535
  ], 64))), 128))
521
536
  ]),
@@ -528,7 +543,7 @@ const te = { class: "mb-4" }, re = ["for"], le = {
528
543
  g("button", {
529
544
  type: "button",
530
545
  class: "mt-1 rounded-lg border border-dashed border-gray-600 px-4 py-2 text-sm text-gray-400 hover:border-indigo-500 hover:text-indigo-400 transition",
531
- onClick: t[0] || (t[0] = (h) => D(d)())
546
+ onClick: r[0] || (r[0] = (h) => D(n)())
532
547
  }, " + Add row ")
533
548
  ]));
534
549
  }
@@ -538,16 +553,17 @@ const te = { class: "mb-4" }, re = ["for"], le = {
538
553
  }, Ue = {
539
554
  key: 0,
540
555
  class: "px-1 text-xs font-semibold uppercase tracking-wider text-gray-400"
541
- }, Me = ["disabled"], Ke = /* @__PURE__ */ V({
556
+ }, Me = ["disabled"], Ge = /* @__PURE__ */ V({
542
557
  __name: "TailwindFormRenderer",
543
558
  props: {
544
559
  form: {},
545
560
  components: {},
546
- submitLabel: {}
561
+ submitLabel: {},
562
+ fields: {}
547
563
  },
548
564
  emits: ["submit"],
549
565
  setup(e, { emit: m }) {
550
- const r = e, c = U(), a = m, n = {
566
+ const t = e, c = U(), a = m, d = {
551
567
  text: A,
552
568
  email: A,
553
569
  number: P,
@@ -558,71 +574,74 @@ const te = { class: "mb-4" }, re = ["for"], le = {
558
574
  date: H,
559
575
  file: Re
560
576
  };
561
- function d(t) {
577
+ function n(r) {
562
578
  var h;
563
- return t.component ? t.component : ((h = r.components) == null ? void 0 : h[t.type]) ?? c[t.type] ?? n[t.type] ?? null;
579
+ return r.component ? r.component : ((h = t.components) == null ? void 0 : h[r.type]) ?? c[r.type] ?? d[r.type] ?? null;
564
580
  }
565
- function i(t) {
566
- return M(r.form.values.value, t.name);
581
+ function i(r) {
582
+ return M(t.form.values.value, r.name);
567
583
  }
568
- function f(t, h) {
569
- r.form.setField(t.name, h);
584
+ function f(r, h) {
585
+ t.form.setField(r.name, h);
570
586
  }
571
- function b(t) {
587
+ function b(r) {
572
588
  var v;
573
- const h = r.form;
574
- (v = h.touchField) == null || v.call(h, t.name);
589
+ const h = t.form;
590
+ (v = h.touchField) == null || v.call(h, r.name);
575
591
  }
576
- function y(t) {
577
- return r.form.errors.value[t.name] ?? [];
592
+ function y(r) {
593
+ return t.form.errors.value[r.name] ?? [];
578
594
  }
579
- function S(t) {
580
- return r.form.touched.value[t.name] ?? !1;
595
+ function S(r) {
596
+ return t.form.touched.value[r.name] ?? !1;
581
597
  }
582
- const R = $(() => r.form.fields.value.filter((t) => t.visible !== !1));
583
- async function o(t) {
584
- t.preventDefault(), await r.form.submit(), a("submit");
598
+ const R = $(
599
+ () => (t.fields ?? t.form.fields.value).filter((r) => r.visible !== !1)
600
+ );
601
+ async function o(r) {
602
+ r.preventDefault(), await t.form.submit(), a("submit");
585
603
  }
586
- return (t, h) => {
604
+ return (r, h) => {
587
605
  const v = Z("TailwindFormRenderer", !0);
588
- return l(), u("form", {
606
+ return l(), s("form", {
589
607
  novalidate: "",
590
608
  onSubmit: o
591
609
  }, [
592
- (l(!0), u(w, null, F(R.value, (s) => (l(), u(w, {
593
- key: s.name
610
+ (l(!0), s(w, null, F(R.value, (u) => (l(), s(w, {
611
+ key: u.name
594
612
  }, [
595
- t.$slots[`field-${s.name}`] ? E(t.$slots, `field-${s.name}`, {
613
+ r.$slots[`field-${u.name}`] ? E(r.$slots, `field-${u.name}`, {
596
614
  key: 0,
597
- field: s,
598
- value: i(s),
599
- error: y(s),
600
- touched: S(s),
601
- setValue: (q) => f(s, q),
602
- touch: () => b(s)
603
- }) : s.type === "group" ? (l(), u("fieldset", ze, [
604
- s.label ? (l(), u("legend", Ue, x(s.label), 1)) : p("", !0),
605
- s.fields ? (l(), k(v, {
615
+ field: u,
616
+ value: i(u),
617
+ error: y(u),
618
+ touched: S(u),
619
+ setValue: (B) => f(u, B),
620
+ touch: () => b(u)
621
+ }) : u.type === "group" ? (l(), s("fieldset", ze, [
622
+ u.label ? (l(), s("legend", Ue, x(u.label), 1)) : p("", !0),
623
+ u.fields ? (l(), k(v, {
606
624
  key: 1,
607
625
  form: e.form,
626
+ fields: u.fields,
608
627
  components: e.components
609
- }, null, 8, ["form", "components"])) : p("", !0)
610
- ])) : s.type === "array" ? (l(), k(Ne, {
628
+ }, null, 8, ["form", "fields", "components"])) : p("", !0)
629
+ ])) : u.type === "array" ? (l(), k(Ne, {
611
630
  key: 2,
612
- field: s,
631
+ field: u,
613
632
  form: e.form,
614
633
  components: e.components
615
- }, null, 8, ["field", "form", "components"])) : d(s) ? (l(), k(z(d(s)), {
634
+ }, null, 8, ["field", "form", "components"])) : n(u) ? (l(), k(z(n(u)), {
616
635
  key: 3,
617
- field: s,
618
- "model-value": i(s),
619
- error: y(s),
620
- touched: S(s),
621
- "onUpdate:modelValue": (q) => f(s, q),
622
- onBlur: (q) => b(s)
636
+ field: u,
637
+ "model-value": i(u),
638
+ error: y(u),
639
+ touched: S(u),
640
+ "onUpdate:modelValue": (B) => f(u, B),
641
+ onBlur: (B) => b(u)
623
642
  }, null, 40, ["field", "model-value", "error", "touched", "onUpdate:modelValue", "onBlur"])) : p("", !0)
624
643
  ], 64))), 128)),
625
- E(t.$slots, "submit", {
644
+ E(r.$slots, "submit", {
626
645
  isSubmitting: e.form.isSubmitting.value,
627
646
  isValid: e.form.isValid.value
628
647
  }, () => [
@@ -637,7 +656,7 @@ const te = { class: "mb-4" }, re = ["for"], le = {
637
656
  }
638
657
  });
639
658
  export {
640
- Ke as TailwindFormRenderer,
659
+ Ge as TailwindFormRenderer,
641
660
  Ne as TwArrayField,
642
661
  K as TwCheckboxField,
643
662
  H as TwDateField,