@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.
- package/README.md +461 -180
- package/dist/MaskEngine-BEXwX4BK.js +144 -0
- package/dist/MaskEngine-CPr-fSPy.cjs +1 -0
- package/dist/ValidationEngine-BC4U1ef1.js +135 -0
- package/dist/ValidationEngine-Diz-qTFs.cjs +1 -0
- package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
- package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
- package/dist/core/ConditionEvaluator.d.ts.map +1 -1
- package/dist/core/MaskEngine.d.ts.map +1 -1
- package/dist/core/ValidationEngine.d.ts +7 -0
- package/dist/core/ValidationEngine.d.ts.map +1 -1
- package/dist/core/formRegistry.d.ts +33 -0
- package/dist/core/formRegistry.d.ts.map +1 -0
- package/dist/core/inferTypes.d.ts.map +1 -1
- package/dist/core/schemaUtils.d.ts +38 -0
- package/dist/core/schemaUtils.d.ts.map +1 -1
- package/dist/core/serverErrors.d.ts +69 -0
- package/dist/core/serverErrors.d.ts.map +1 -0
- package/dist/core/types.d.ts +12 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/useForm.d.ts +4 -1
- package/dist/core/useForm.d.ts.map +1 -1
- package/dist/core/useMultiStepForm.d.ts.map +1 -1
- package/dist/devtools/index.d.ts +26 -0
- package/dist/devtools/index.d.ts.map +1 -0
- package/dist/devtools.cjs +1 -0
- package/dist/devtools.d.ts +6 -0
- package/dist/devtools.js +93 -0
- package/dist/formRegistry-Bv1eaWQ-.js +31 -0
- package/dist/formRegistry-DaDmXyYY.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +393 -368
- package/dist/openapi.cjs +1 -0
- package/dist/openapi.d.ts +202 -0
- package/dist/openapi.js +118 -0
- package/dist/parsers/json.d.ts.map +1 -1
- package/dist/parsers/openapi.d.ts +139 -0
- package/dist/parsers/openapi.d.ts.map +1 -0
- package/dist/parsers/valibot.d.ts +13 -4
- package/dist/parsers/valibot.d.ts.map +1 -1
- package/dist/parsers/yup.d.ts +10 -4
- package/dist/parsers/yup.d.ts.map +1 -1
- package/dist/parsers/zod.d.ts +18 -4
- package/dist/parsers/zod.d.ts.map +1 -1
- package/dist/schemaUtils-Cc7CwGXB.cjs +1 -0
- package/dist/schemaUtils-Cvlsk24U.js +337 -0
- package/dist/style.css +1 -0
- package/dist/ui/naive/index.d.ts +11 -0
- package/dist/ui/naive/index.d.ts.map +1 -0
- package/dist/ui/primevue/index.d.ts +11 -0
- package/dist/ui/primevue/index.d.ts.map +1 -0
- package/dist/ui/shadcn/index.d.ts +11 -0
- package/dist/ui/shadcn/index.d.ts.map +1 -0
- package/dist/ui-naive.cjs +1 -0
- package/dist/ui-naive.d.ts +276 -0
- package/dist/ui-naive.js +667 -0
- package/dist/ui-primevue.cjs +1 -0
- package/dist/ui-primevue.d.ts +276 -0
- package/dist/ui-primevue.js +651 -0
- package/dist/ui-shadcn.cjs +1 -0
- package/dist/ui-shadcn.d.ts +276 -0
- package/dist/ui-shadcn.js +650 -0
- package/dist/ui-tailwind.cjs +1 -1
- package/dist/ui-tailwind.d.ts +153 -274
- package/dist/ui-tailwind.js +180 -161
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +170 -308
- package/dist/ui.js +130 -131
- package/dist/valibot.cjs +1 -1
- package/dist/valibot.d.ts +25 -2
- package/dist/valibot.js +47 -20
- package/dist/yup.cjs +1 -1
- package/dist/yup.d.ts +23 -3
- package/dist/yup.js +16 -15
- package/dist/zod.cjs +1 -1
- package/dist/zod.d.ts +31 -3
- package/dist/zod.js +58 -28
- package/package.json +69 -7
- package/dist/MaskEngine-DAKSNIHQ.cjs +0 -1
- package/dist/MaskEngine-mLoXKd4d.js +0 -251
package/dist/ui-tailwind.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { defineComponent as V, computed as $, openBlock as l, createElementBlock as
|
|
2
|
-
import { b as _,
|
|
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,
|
|
16
|
-
var
|
|
17
|
-
return !!(m.touched && ((
|
|
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":
|
|
21
|
-
"aria-describedby":
|
|
21
|
+
"aria-invalid": t.value ? "true" : "false",
|
|
22
|
+
"aria-describedby": t.value ? c.value : void 0
|
|
22
23
|
}));
|
|
23
|
-
return (
|
|
24
|
-
e.field.label ? (l(),
|
|
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(),
|
|
31
|
+
e.field.required ? (l(), s("span", le, "*")) : p("", !0)
|
|
31
32
|
], 8, re)) : p("", !0),
|
|
32
|
-
E(
|
|
33
|
-
|
|
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),
|
|
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
|
|
58
|
-
let
|
|
59
|
-
const
|
|
58
|
+
const t = e, c = m, a = I(null);
|
|
59
|
+
let d = null;
|
|
60
|
+
const n = $(() => {
|
|
60
61
|
var i;
|
|
61
|
-
return !!(
|
|
62
|
+
return !!(t.touched && ((i = t.error) != null && i.length));
|
|
62
63
|
});
|
|
63
64
|
return Q(() => {
|
|
64
|
-
a.value &&
|
|
65
|
-
}), W(() =>
|
|
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:
|
|
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: [
|
|
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
|
-
}),
|
|
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
|
|
101
|
-
var
|
|
102
|
-
return !!(
|
|
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
|
|
105
|
-
const i =
|
|
108
|
+
function d(n) {
|
|
109
|
+
const i = n.target.value;
|
|
106
110
|
c("update:modelValue", i === "" ? null : Number(i));
|
|
107
111
|
}
|
|
108
|
-
return (
|
|
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:
|
|
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: [
|
|
124
|
-
|
|
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,
|
|
133
|
+
}), null, 16, de)
|
|
127
134
|
]),
|
|
128
135
|
_: 1
|
|
129
136
|
}, 8, ["field", "error", "touched"]));
|
|
130
137
|
}
|
|
131
|
-
}),
|
|
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
|
|
142
|
-
var
|
|
143
|
-
return !!(
|
|
148
|
+
const t = e, c = m, a = $(() => {
|
|
149
|
+
var d;
|
|
150
|
+
return !!(t.touched && ((d = t.error) != null && d.length));
|
|
144
151
|
});
|
|
145
|
-
return (
|
|
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:
|
|
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: [
|
|
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:
|
|
162
|
-
onBlur:
|
|
163
|
-
}), null, 16,
|
|
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
|
|
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 !!(
|
|
193
|
+
return !!(t.touched && ((i = t.error) != null && i.length));
|
|
186
194
|
});
|
|
187
|
-
function
|
|
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:
|
|
197
|
-
e.field.optionsLoading ? (l(),
|
|
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: [
|
|
205
|
-
|
|
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),
|
|
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
|
|
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:
|
|
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
|
-
},
|
|
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] = (
|
|
257
|
-
onBlur: a[1] || (a[1] = (
|
|
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(),
|
|
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
|
|
293
|
+
const t = e, c = m, a = $(() => {
|
|
283
294
|
var i;
|
|
284
|
-
return !!(
|
|
285
|
-
}),
|
|
286
|
-
|
|
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 ?
|
|
301
|
+
"aria-describedby": a.value ? d.value : void 0
|
|
293
302
|
}, [
|
|
294
|
-
e.field.label ? (l(),
|
|
303
|
+
e.field.label ? (l(), s("legend", ye, [
|
|
295
304
|
N(x(e.field.label) + " ", 1),
|
|
296
|
-
e.field.required ? (l(),
|
|
305
|
+
e.field.required ? (l(), s("span", he, "*")) : p("", !0)
|
|
297
306
|
])) : p("", !0),
|
|
298
307
|
g("div", ve, [
|
|
299
|
-
(l(!0),
|
|
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(),
|
|
325
|
+
a.value ? (l(), s("ul", {
|
|
317
326
|
key: 1,
|
|
318
|
-
id:
|
|
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),
|
|
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
|
|
341
|
-
var
|
|
342
|
-
return !!(
|
|
349
|
+
const t = e, c = m, a = $(() => {
|
|
350
|
+
var d;
|
|
351
|
+
return !!(t.touched && ((d = t.error) != null && d.length));
|
|
343
352
|
});
|
|
344
|
-
return (
|
|
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:
|
|
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: [
|
|
359
|
-
|
|
360
|
-
|
|
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" },
|
|
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
|
-
},
|
|
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
|
|
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
|
|
395
|
-
a.value = !1, o.preventDefault(), f(((
|
|
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
|
|
399
|
-
|
|
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,
|
|
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:
|
|
421
|
+
default: q((h) => {
|
|
410
422
|
var v;
|
|
411
423
|
return [
|
|
412
424
|
g("div", {
|
|
413
|
-
class: Y([
|
|
414
|
-
|
|
415
|
-
|
|
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:
|
|
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
|
-
|
|
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(),
|
|
450
|
+
e.field.accept ? (l(), s("p", Be, x(e.field.accept), 1)) : p("", !0)
|
|
436
451
|
])
|
|
437
452
|
], 34),
|
|
438
|
-
|
|
439
|
-
(l(!0),
|
|
440
|
-
key: `${
|
|
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(
|
|
444
|
-
g("span", Te, x(R(
|
|
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 ${
|
|
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(
|
|
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,
|
|
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
|
|
481
|
-
return o.component ? o.component : ((
|
|
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:
|
|
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,
|
|
488
|
-
m.form.setField(o.name,
|
|
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
|
|
493
|
-
(h =
|
|
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,
|
|
502
|
-
e.field.label ? (l(),
|
|
503
|
-
(l(!0),
|
|
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),
|
|
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": (
|
|
518
|
-
onBlur: (
|
|
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:
|
|
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"],
|
|
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
|
|
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
|
|
577
|
+
function n(r) {
|
|
562
578
|
var h;
|
|
563
|
-
return
|
|
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(
|
|
566
|
-
return M(
|
|
581
|
+
function i(r) {
|
|
582
|
+
return M(t.form.values.value, r.name);
|
|
567
583
|
}
|
|
568
|
-
function f(
|
|
569
|
-
|
|
584
|
+
function f(r, h) {
|
|
585
|
+
t.form.setField(r.name, h);
|
|
570
586
|
}
|
|
571
|
-
function b(
|
|
587
|
+
function b(r) {
|
|
572
588
|
var v;
|
|
573
|
-
const h =
|
|
574
|
-
(v = h.touchField) == null || v.call(h,
|
|
589
|
+
const h = t.form;
|
|
590
|
+
(v = h.touchField) == null || v.call(h, r.name);
|
|
575
591
|
}
|
|
576
|
-
function y(
|
|
577
|
-
return
|
|
592
|
+
function y(r) {
|
|
593
|
+
return t.form.errors.value[r.name] ?? [];
|
|
578
594
|
}
|
|
579
|
-
function S(
|
|
580
|
-
return
|
|
595
|
+
function S(r) {
|
|
596
|
+
return t.form.touched.value[r.name] ?? !1;
|
|
581
597
|
}
|
|
582
|
-
const R = $(
|
|
583
|
-
|
|
584
|
-
|
|
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 (
|
|
604
|
+
return (r, h) => {
|
|
587
605
|
const v = Z("TailwindFormRenderer", !0);
|
|
588
|
-
return l(),
|
|
606
|
+
return l(), s("form", {
|
|
589
607
|
novalidate: "",
|
|
590
608
|
onSubmit: o
|
|
591
609
|
}, [
|
|
592
|
-
(l(!0),
|
|
593
|
-
key:
|
|
610
|
+
(l(!0), s(w, null, F(R.value, (u) => (l(), s(w, {
|
|
611
|
+
key: u.name
|
|
594
612
|
}, [
|
|
595
|
-
|
|
613
|
+
r.$slots[`field-${u.name}`] ? E(r.$slots, `field-${u.name}`, {
|
|
596
614
|
key: 0,
|
|
597
|
-
field:
|
|
598
|
-
value: i(
|
|
599
|
-
error: y(
|
|
600
|
-
touched: S(
|
|
601
|
-
setValue: (
|
|
602
|
-
touch: () => b(
|
|
603
|
-
}) :
|
|
604
|
-
|
|
605
|
-
|
|
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
|
-
])) :
|
|
628
|
+
}, null, 8, ["form", "fields", "components"])) : p("", !0)
|
|
629
|
+
])) : u.type === "array" ? (l(), k(Ne, {
|
|
611
630
|
key: 2,
|
|
612
|
-
field:
|
|
631
|
+
field: u,
|
|
613
632
|
form: e.form,
|
|
614
633
|
components: e.components
|
|
615
|
-
}, null, 8, ["field", "form", "components"])) :
|
|
634
|
+
}, null, 8, ["field", "form", "components"])) : n(u) ? (l(), k(z(n(u)), {
|
|
616
635
|
key: 3,
|
|
617
|
-
field:
|
|
618
|
-
"model-value": i(
|
|
619
|
-
error: y(
|
|
620
|
-
touched: S(
|
|
621
|
-
"onUpdate:modelValue": (
|
|
622
|
-
onBlur: (
|
|
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(
|
|
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
|
-
|
|
659
|
+
Ge as TailwindFormRenderer,
|
|
641
660
|
Ne as TwArrayField,
|
|
642
661
|
K as TwCheckboxField,
|
|
643
662
|
H as TwDateField,
|