pdyform 2.1.0 → 2.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 +98 -74
- package/package.json +1 -1
- package/packages/core/dist/chunk-6F4PWJZI.js +0 -0
- package/packages/core/dist/chunk-B7OMM2UC.js +160 -0
- package/packages/core/dist/chunk-J6ESJZ4U.js +82 -0
- package/packages/core/dist/formState.cjs +140 -78
- package/packages/core/dist/formState.d.cts +14 -10
- package/packages/core/dist/formState.d.ts +14 -10
- package/packages/core/dist/formState.js +4 -12
- package/packages/core/dist/index.cjs +146 -78
- package/packages/core/dist/index.d.cts +4 -3
- package/packages/core/dist/index.d.ts +4 -3
- package/packages/core/dist/index.js +11 -12
- package/packages/core/dist/types.d.cts +17 -5
- package/packages/core/dist/types.d.ts +17 -5
- package/packages/core/dist/types.js +1 -0
- package/packages/core/dist/utils.cjs +80 -19
- package/packages/core/dist/utils.d.cts +17 -5
- package/packages/core/dist/utils.d.ts +17 -5
- package/packages/core/dist/utils.js +7 -1
- package/packages/react/dist/index.cjs +1 -461
- package/packages/react/dist/index.d.cts +33 -2
- package/packages/react/dist/index.d.ts +33 -2
- package/packages/react/dist/index.js +1 -411
- package/packages/vue/dist/index.d.ts +55 -9
- package/packages/vue/dist/index.js +1 -1
- package/packages/vue/dist/index.mjs +600 -247
- package/packages/core/dist/chunk-TP3IHKWV.js +0 -69
- package/packages/core/dist/chunk-WEDHXOHH.js +0 -102
|
@@ -1,13 +1,200 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { defineComponent as p, openBlock as d, createElementBlock as g, mergeProps as I, unref as o, createBlock as v, computed as h, withCtx as m, renderSlot as q, createVNode as b, normalizeClass as D, createElementVNode as O, normalizeProps as X, guardReactiveProps as Y, Fragment as N, renderList as E, createTextVNode as U, toDisplayString as F, createCommentVNode as R, resolveDynamicComponent as Z, ref as _, onUnmounted as ee, withModifiers as te } from "vue";
|
|
2
|
+
import { clsx as ae } from "clsx";
|
|
3
|
+
import { twMerge as le } from "tailwind-merge";
|
|
4
|
+
import { useForwardProps as j, SelectTrigger as ie, SelectIcon as ne, SelectPortal as se, SelectContent as re, SelectViewport as oe, SelectItem as de, SelectItemIndicator as ue, SelectItemText as ce, useForwardPropsEmits as A, SelectRoot as me, SelectValue as fe, CheckboxRoot as be, CheckboxIndicator as pe, Label as ge, RadioGroupItem as ye, RadioGroupIndicator as ve, RadioGroupRoot as he, SwitchRoot as xe, SwitchThumb as Ve } from "radix-vue";
|
|
5
|
+
import { ChevronDown as ke, Check as K, Circle as we } from "lucide-vue-next";
|
|
6
|
+
function z(e) {
|
|
7
|
+
if (typeof e == "number") return Number.isNaN(e) ? null : e;
|
|
8
|
+
if (typeof e != "string" || e.trim() === "") return null;
|
|
9
|
+
const l = Number(e);
|
|
10
|
+
return Number.isNaN(l) ? null : l;
|
|
9
11
|
}
|
|
10
|
-
|
|
12
|
+
var Be = {
|
|
13
|
+
required: "{label} is required",
|
|
14
|
+
min: "{label} must be at least {value}",
|
|
15
|
+
max: "{label} must be at most {value}",
|
|
16
|
+
email: "Invalid email address",
|
|
17
|
+
pattern: "Invalid format",
|
|
18
|
+
custom: "Invalid value"
|
|
19
|
+
};
|
|
20
|
+
function S(e, l, i) {
|
|
21
|
+
return e.replace("{label}", l.label).replace("{value}", String(i.value || ""));
|
|
22
|
+
}
|
|
23
|
+
function M(e, l, i) {
|
|
24
|
+
if (!l) return i;
|
|
25
|
+
const n = l.split(/[.[\]]/).filter(Boolean);
|
|
26
|
+
let a = e;
|
|
27
|
+
for (const t of n) {
|
|
28
|
+
if (a == null) return i;
|
|
29
|
+
a = a[t];
|
|
30
|
+
}
|
|
31
|
+
return a === void 0 ? i : a;
|
|
32
|
+
}
|
|
33
|
+
function Se(e, l, i) {
|
|
34
|
+
if (Object(e) !== e) return e;
|
|
35
|
+
const n = l.split(/[.[\]]/).filter(Boolean), a = { ...e };
|
|
36
|
+
let t = a;
|
|
37
|
+
for (let r = 0; r < n.length - 1; r++) {
|
|
38
|
+
const s = n[r], u = n[r + 1], f = /^\d+$/.test(u);
|
|
39
|
+
!(s in t) || t[s] === null || typeof t[s] != "object" ? t[s] = f ? [] : {} : t[s] = Array.isArray(t[s]) ? [...t[s]] : { ...t[s] }, t = t[s];
|
|
40
|
+
}
|
|
41
|
+
return t[n[n.length - 1]] = i, a;
|
|
42
|
+
}
|
|
43
|
+
function W(e, l) {
|
|
44
|
+
if (e.type !== "number") return l;
|
|
45
|
+
if (l === "" || l === void 0 || l === null) return "";
|
|
46
|
+
const i = z(l);
|
|
47
|
+
return i === null ? l : i;
|
|
48
|
+
}
|
|
49
|
+
async function J(e, l, i) {
|
|
50
|
+
if (!l.validations) return null;
|
|
51
|
+
const n = { ...Be, ...i };
|
|
52
|
+
for (const a of l.validations)
|
|
53
|
+
switch (a.type) {
|
|
54
|
+
case "required":
|
|
55
|
+
if (e == null || e === "" || Array.isArray(e) && e.length === 0)
|
|
56
|
+
return a.message || S(n.required, l, a);
|
|
57
|
+
break;
|
|
58
|
+
case "min":
|
|
59
|
+
if (l.type === "number") {
|
|
60
|
+
const t = z(e);
|
|
61
|
+
if (t !== null && t < a.value) {
|
|
62
|
+
const r = l.type === "number" ? n.min : typeof e == "string" ? "{label} must be at least {value} characters" : n.min;
|
|
63
|
+
return a.message || S(r, l, a);
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
if (typeof e == "number" && e < a.value)
|
|
68
|
+
return a.message || S(n.min, l, a);
|
|
69
|
+
if (typeof e == "string" && e.length < a.value)
|
|
70
|
+
return a.message || S("{label} must be at least {value} characters", l, a);
|
|
71
|
+
break;
|
|
72
|
+
case "max":
|
|
73
|
+
if (l.type === "number") {
|
|
74
|
+
const t = z(e);
|
|
75
|
+
if (t !== null && t > a.value)
|
|
76
|
+
return a.message || S(n.max, l, a);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
if (typeof e == "number" && e > a.value)
|
|
80
|
+
return a.message || S(n.max, l, a);
|
|
81
|
+
if (typeof e == "string" && e.length > a.value)
|
|
82
|
+
return a.message || S("{label} must be at most {value} characters", l, a);
|
|
83
|
+
break;
|
|
84
|
+
case "email": {
|
|
85
|
+
if (e && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))
|
|
86
|
+
return a.message || S(n.email, l, a);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case "pattern":
|
|
90
|
+
if (e && a.value && !new RegExp(a.value).test(e))
|
|
91
|
+
return a.message || S(n.pattern, l, a);
|
|
92
|
+
break;
|
|
93
|
+
case "custom":
|
|
94
|
+
if (a.validator) {
|
|
95
|
+
const t = await a.validator(e);
|
|
96
|
+
if (typeof t == "string") return t;
|
|
97
|
+
if (t === !1) return a.message || S(n.custom, l, a);
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
async function G(e, l, i, n, a, t) {
|
|
104
|
+
if (n && a) {
|
|
105
|
+
const s = await n(a);
|
|
106
|
+
if (s[l]) return s[l];
|
|
107
|
+
}
|
|
108
|
+
const r = e.find((s) => s.name === l);
|
|
109
|
+
return r ? await J(i, r, t) : null;
|
|
110
|
+
}
|
|
111
|
+
async function Ie(e, l, i, n) {
|
|
112
|
+
let a = {};
|
|
113
|
+
i && (a = await i(l));
|
|
114
|
+
const t = e.map(async (r) => {
|
|
115
|
+
if (a[r.name] || (typeof r.hidden == "function" ? r.hidden(l) : r.hidden)) return;
|
|
116
|
+
const u = await J(M(l, r.name), r, n);
|
|
117
|
+
u && (a[r.name] = u);
|
|
118
|
+
});
|
|
119
|
+
return await Promise.all(t), a;
|
|
120
|
+
}
|
|
121
|
+
function $e(e) {
|
|
122
|
+
return e.reduce((l, i) => (l[i.name] = i.defaultValue !== void 0 ? i.defaultValue : i.type === "checkbox" ? [] : "", l), {});
|
|
123
|
+
}
|
|
124
|
+
const L = (e) => {
|
|
125
|
+
let l;
|
|
126
|
+
const i = /* @__PURE__ */ new Set(), n = (f, $) => {
|
|
127
|
+
const c = typeof f == "function" ? f(l) : f;
|
|
128
|
+
if (!Object.is(c, l)) {
|
|
129
|
+
const x = l;
|
|
130
|
+
l = $ ?? (typeof c != "object" || c === null) ? c : Object.assign({}, l, c), i.forEach((V) => V(l, x));
|
|
131
|
+
}
|
|
132
|
+
}, a = () => l, s = { setState: n, getState: a, getInitialState: () => u, subscribe: (f) => (i.add(f), () => i.delete(f)) }, u = l = e(n, a, s);
|
|
133
|
+
return s;
|
|
134
|
+
}, Fe = (e) => e ? L(e) : L;
|
|
135
|
+
function Re(e, l, i) {
|
|
136
|
+
return Fe()((n, a) => ({
|
|
137
|
+
values: $e(e),
|
|
138
|
+
errors: {},
|
|
139
|
+
validatingFields: [],
|
|
140
|
+
isSubmitting: !1,
|
|
141
|
+
setFieldValue: async (t, r) => {
|
|
142
|
+
const s = e.find((c) => c.name === t), u = s ? W(s, r) : r;
|
|
143
|
+
n((c) => ({
|
|
144
|
+
values: Se(c.values, t, u)
|
|
145
|
+
}));
|
|
146
|
+
const f = !!a().errors[t];
|
|
147
|
+
if (s && ["select", "checkbox", "radio", "switch", "date"].includes(s.type) || f) {
|
|
148
|
+
n((c) => ({
|
|
149
|
+
validatingFields: [...c.validatingFields, t]
|
|
150
|
+
}));
|
|
151
|
+
try {
|
|
152
|
+
const c = a().values, x = await G(e, t, u, l, c, i);
|
|
153
|
+
n((V) => ({
|
|
154
|
+
errors: { ...V.errors, [t]: x || "" },
|
|
155
|
+
validatingFields: V.validatingFields.filter((y) => y !== t)
|
|
156
|
+
}));
|
|
157
|
+
} catch {
|
|
158
|
+
n((x) => ({
|
|
159
|
+
validatingFields: x.validatingFields.filter((V) => V !== t)
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
setFieldBlur: async (t) => {
|
|
165
|
+
n((r) => ({
|
|
166
|
+
validatingFields: [...r.validatingFields, t]
|
|
167
|
+
}));
|
|
168
|
+
try {
|
|
169
|
+
const r = a().values, s = M(r, t), u = await G(e, t, s, l, r, i);
|
|
170
|
+
n((f) => ({
|
|
171
|
+
errors: { ...f.errors, [t]: u || "" },
|
|
172
|
+
validatingFields: f.validatingFields.filter(($) => $ !== t)
|
|
173
|
+
}));
|
|
174
|
+
} catch {
|
|
175
|
+
n((s) => ({
|
|
176
|
+
validatingFields: s.validatingFields.filter((u) => u !== t)
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
setSubmitting: (t) => n({ isSubmitting: t }),
|
|
181
|
+
runSubmitValidation: async () => {
|
|
182
|
+
n({ isSubmitting: !0 });
|
|
183
|
+
const t = a(), r = await Ie(e, t.values, l, i), s = Object.keys(r).length > 0;
|
|
184
|
+
return n({
|
|
185
|
+
errors: r,
|
|
186
|
+
isSubmitting: !1
|
|
187
|
+
}), {
|
|
188
|
+
state: a(),
|
|
189
|
+
hasError: s
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}));
|
|
193
|
+
}
|
|
194
|
+
function w(...e) {
|
|
195
|
+
return le(ae(e));
|
|
196
|
+
}
|
|
197
|
+
const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
11
198
|
__name: "Input",
|
|
12
199
|
props: {
|
|
13
200
|
class: {},
|
|
@@ -15,74 +202,81 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
15
202
|
modelValue: {}
|
|
16
203
|
},
|
|
17
204
|
emits: ["update:modelValue", "blur"],
|
|
18
|
-
setup(e, { emit:
|
|
19
|
-
const
|
|
20
|
-
return (
|
|
205
|
+
setup(e, { emit: l }) {
|
|
206
|
+
const i = e, n = l;
|
|
207
|
+
return (a, t) => (d(), g("input", I(a.$attrs, {
|
|
21
208
|
type: e.type,
|
|
22
|
-
class:
|
|
209
|
+
class: o(w)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", i.class),
|
|
23
210
|
value: e.modelValue,
|
|
24
|
-
onInput: t[0] || (t[0] = (
|
|
25
|
-
onBlur: t[1] || (t[1] = (
|
|
26
|
-
}, null,
|
|
211
|
+
onInput: t[0] || (t[0] = (r) => n("update:modelValue", r.target.value)),
|
|
212
|
+
onBlur: t[1] || (t[1] = (r) => n("blur", r))
|
|
213
|
+
}), null, 16, Ce));
|
|
27
214
|
}
|
|
28
|
-
}),
|
|
215
|
+
}), P = /* @__PURE__ */ p({
|
|
29
216
|
__name: "InputRenderer",
|
|
30
217
|
props: {
|
|
31
218
|
field: {},
|
|
219
|
+
fieldId: {},
|
|
32
220
|
modelValue: {},
|
|
33
|
-
|
|
221
|
+
ariaInvalid: { type: Boolean },
|
|
222
|
+
ariaRequired: { type: Boolean },
|
|
223
|
+
ariaDescribedby: {}
|
|
34
224
|
},
|
|
35
|
-
emits: ["update:modelValue"],
|
|
36
|
-
setup(e, { emit:
|
|
37
|
-
const
|
|
38
|
-
|
|
225
|
+
emits: ["update:modelValue", "blur"],
|
|
226
|
+
setup(e, { emit: l }) {
|
|
227
|
+
const i = e, n = l, a = (t) => {
|
|
228
|
+
n("update:modelValue", W(i.field, t));
|
|
39
229
|
};
|
|
40
|
-
return (t,
|
|
230
|
+
return (t, r) => (d(), v(Q, {
|
|
41
231
|
id: e.fieldId,
|
|
42
232
|
type: e.field.type,
|
|
43
233
|
placeholder: e.field.placeholder,
|
|
44
|
-
disabled: e.field.disabled,
|
|
234
|
+
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
45
235
|
name: e.field.name,
|
|
46
236
|
modelValue: e.modelValue ?? "",
|
|
47
|
-
"onUpdate:modelValue":
|
|
237
|
+
"onUpdate:modelValue": a,
|
|
238
|
+
onBlur: r[0] || (r[0] = (s) => n("blur", s))
|
|
48
239
|
}, null, 8, ["id", "type", "placeholder", "disabled", "name", "modelValue"]));
|
|
49
240
|
}
|
|
50
|
-
}),
|
|
241
|
+
}), qe = ["value"], Pe = /* @__PURE__ */ p({
|
|
51
242
|
__name: "Textarea",
|
|
52
243
|
props: {
|
|
53
244
|
class: {},
|
|
54
245
|
modelValue: {}
|
|
55
246
|
},
|
|
56
247
|
emits: ["update:modelValue", "blur"],
|
|
57
|
-
setup(e, { emit:
|
|
58
|
-
const
|
|
59
|
-
return (
|
|
60
|
-
class:
|
|
248
|
+
setup(e, { emit: l }) {
|
|
249
|
+
const i = e, n = l;
|
|
250
|
+
return (a, t) => (d(), g("textarea", I(a.$attrs, {
|
|
251
|
+
class: o(w)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", i.class),
|
|
61
252
|
value: e.modelValue,
|
|
62
|
-
onInput: t[0] || (t[0] = (
|
|
63
|
-
onBlur: t[1] || (t[1] = (
|
|
64
|
-
}, null,
|
|
253
|
+
onInput: t[0] || (t[0] = (r) => n("update:modelValue", r.target.value)),
|
|
254
|
+
onBlur: t[1] || (t[1] = (r) => n("blur", r))
|
|
255
|
+
}), null, 16, qe));
|
|
65
256
|
}
|
|
66
|
-
}),
|
|
257
|
+
}), De = /* @__PURE__ */ p({
|
|
67
258
|
__name: "TextareaRenderer",
|
|
68
259
|
props: {
|
|
69
260
|
field: {},
|
|
261
|
+
fieldId: {},
|
|
70
262
|
modelValue: {},
|
|
71
|
-
|
|
263
|
+
ariaInvalid: { type: Boolean },
|
|
264
|
+
ariaRequired: { type: Boolean },
|
|
265
|
+
ariaDescribedby: {}
|
|
72
266
|
},
|
|
73
267
|
emits: ["update:modelValue"],
|
|
74
|
-
setup(e, { emit:
|
|
75
|
-
const
|
|
76
|
-
return (
|
|
268
|
+
setup(e, { emit: l }) {
|
|
269
|
+
const i = l;
|
|
270
|
+
return (n, a) => (d(), v(Pe, {
|
|
77
271
|
id: e.fieldId,
|
|
78
272
|
placeholder: e.field.placeholder,
|
|
79
|
-
disabled: e.field.disabled,
|
|
273
|
+
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
80
274
|
name: e.field.name,
|
|
81
275
|
modelValue: e.modelValue ?? "",
|
|
82
|
-
"onUpdate:modelValue":
|
|
276
|
+
"onUpdate:modelValue": a[0] || (a[0] = (t) => i("update:modelValue", t))
|
|
83
277
|
}, null, 8, ["id", "placeholder", "disabled", "name", "modelValue"]));
|
|
84
278
|
}
|
|
85
|
-
}),
|
|
279
|
+
}), Ne = /* @__PURE__ */ p({
|
|
86
280
|
__name: "SelectTrigger",
|
|
87
281
|
props: {
|
|
88
282
|
disabled: { type: Boolean },
|
|
@@ -91,18 +285,18 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
91
285
|
class: {}
|
|
92
286
|
},
|
|
93
287
|
setup(e) {
|
|
94
|
-
const
|
|
95
|
-
const { class:
|
|
288
|
+
const l = e, i = h(() => {
|
|
289
|
+
const { class: a, ...t } = l;
|
|
96
290
|
return t;
|
|
97
|
-
}),
|
|
98
|
-
return (
|
|
99
|
-
class:
|
|
291
|
+
}), n = j(i);
|
|
292
|
+
return (a, t) => (d(), v(o(ie), I(o(n), {
|
|
293
|
+
class: o(w)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", l.class)
|
|
100
294
|
}), {
|
|
101
|
-
default:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
default:
|
|
105
|
-
|
|
295
|
+
default: m(() => [
|
|
296
|
+
q(a.$slots, "default"),
|
|
297
|
+
b(o(ne), { "as-child": "" }, {
|
|
298
|
+
default: m(() => [
|
|
299
|
+
b(o(ke), { class: "h-4 w-4 opacity-50" })
|
|
106
300
|
]),
|
|
107
301
|
_: 1
|
|
108
302
|
})
|
|
@@ -110,7 +304,7 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
110
304
|
_: 3
|
|
111
305
|
}, 16, ["class"]));
|
|
112
306
|
}
|
|
113
|
-
}),
|
|
307
|
+
}), Ee = /* @__PURE__ */ p({
|
|
114
308
|
__name: "SelectContent",
|
|
115
309
|
props: {
|
|
116
310
|
forceMount: { type: Boolean },
|
|
@@ -133,21 +327,21 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
133
327
|
class: {}
|
|
134
328
|
},
|
|
135
329
|
setup(e) {
|
|
136
|
-
const
|
|
137
|
-
const { class:
|
|
330
|
+
const l = e, i = h(() => {
|
|
331
|
+
const { class: a, ...t } = l;
|
|
138
332
|
return t;
|
|
139
|
-
}),
|
|
140
|
-
return (
|
|
141
|
-
default:
|
|
142
|
-
|
|
143
|
-
class:
|
|
333
|
+
}), n = j(i);
|
|
334
|
+
return (a, t) => (d(), v(o(se), null, {
|
|
335
|
+
default: m(() => [
|
|
336
|
+
b(o(re), I(o(n), {
|
|
337
|
+
class: o(w)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", e.position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", l.class)
|
|
144
338
|
}), {
|
|
145
|
-
default:
|
|
146
|
-
|
|
147
|
-
class:
|
|
339
|
+
default: m(() => [
|
|
340
|
+
b(o(oe), {
|
|
341
|
+
class: D(o(w)("p-1", e.position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"))
|
|
148
342
|
}, {
|
|
149
|
-
default:
|
|
150
|
-
|
|
343
|
+
default: m(() => [
|
|
344
|
+
q(a.$slots, "default")
|
|
151
345
|
]),
|
|
152
346
|
_: 3
|
|
153
347
|
}, 8, ["class"])
|
|
@@ -158,7 +352,7 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
158
352
|
_: 3
|
|
159
353
|
}));
|
|
160
354
|
}
|
|
161
|
-
}),
|
|
355
|
+
}), Ue = { class: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center" }, je = /* @__PURE__ */ p({
|
|
162
356
|
__name: "SelectItem",
|
|
163
357
|
props: {
|
|
164
358
|
value: {},
|
|
@@ -169,28 +363,28 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
169
363
|
class: {}
|
|
170
364
|
},
|
|
171
365
|
setup(e) {
|
|
172
|
-
const
|
|
173
|
-
const { class:
|
|
366
|
+
const l = e, i = h(() => {
|
|
367
|
+
const { class: a, ...t } = l;
|
|
174
368
|
return t;
|
|
175
|
-
}),
|
|
176
|
-
return (
|
|
177
|
-
class:
|
|
369
|
+
}), n = j(i);
|
|
370
|
+
return (a, t) => (d(), v(o(de), I(o(n), {
|
|
371
|
+
class: o(w)(
|
|
178
372
|
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
179
|
-
|
|
373
|
+
l.class
|
|
180
374
|
)
|
|
181
375
|
}), {
|
|
182
|
-
default:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
default:
|
|
186
|
-
|
|
376
|
+
default: m(() => [
|
|
377
|
+
O("span", Ue, [
|
|
378
|
+
b(o(ue), null, {
|
|
379
|
+
default: m(() => [
|
|
380
|
+
b(o(K), { class: "h-4 w-4" })
|
|
187
381
|
]),
|
|
188
382
|
_: 1
|
|
189
383
|
})
|
|
190
384
|
]),
|
|
191
|
-
|
|
192
|
-
default:
|
|
193
|
-
|
|
385
|
+
b(o(ce), null, {
|
|
386
|
+
default: m(() => [
|
|
387
|
+
q(a.$slots, "default")
|
|
194
388
|
]),
|
|
195
389
|
_: 3
|
|
196
390
|
})
|
|
@@ -198,7 +392,7 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
198
392
|
_: 3
|
|
199
393
|
}, 16, ["class"]));
|
|
200
394
|
}
|
|
201
|
-
}),
|
|
395
|
+
}), Ae = /* @__PURE__ */ p({
|
|
202
396
|
__name: "Select",
|
|
203
397
|
props: {
|
|
204
398
|
open: { type: Boolean },
|
|
@@ -212,48 +406,51 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
212
406
|
required: { type: Boolean }
|
|
213
407
|
},
|
|
214
408
|
emits: ["update:modelValue", "update:open"],
|
|
215
|
-
setup(e, { emit:
|
|
216
|
-
const
|
|
217
|
-
return (t,
|
|
218
|
-
default:
|
|
219
|
-
|
|
409
|
+
setup(e, { emit: l }) {
|
|
410
|
+
const a = A(e, l);
|
|
411
|
+
return (t, r) => (d(), v(o(me), X(Y(o(a))), {
|
|
412
|
+
default: m(() => [
|
|
413
|
+
q(t.$slots, "default")
|
|
220
414
|
]),
|
|
221
415
|
_: 3
|
|
222
416
|
}, 16));
|
|
223
417
|
}
|
|
224
|
-
}),
|
|
418
|
+
}), Me = /* @__PURE__ */ p({
|
|
225
419
|
__name: "SelectRenderer",
|
|
226
420
|
props: {
|
|
227
421
|
field: {},
|
|
422
|
+
fieldId: {},
|
|
228
423
|
modelValue: {},
|
|
229
|
-
|
|
424
|
+
ariaInvalid: { type: Boolean },
|
|
425
|
+
ariaRequired: { type: Boolean },
|
|
426
|
+
ariaDescribedby: {}
|
|
230
427
|
},
|
|
231
428
|
emits: ["update:modelValue"],
|
|
232
|
-
setup(e, { emit:
|
|
233
|
-
const
|
|
234
|
-
return (
|
|
235
|
-
disabled: e.field.disabled,
|
|
429
|
+
setup(e, { emit: l }) {
|
|
430
|
+
const i = l;
|
|
431
|
+
return (n, a) => (d(), v(Ae, {
|
|
432
|
+
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
236
433
|
name: e.field.name,
|
|
237
434
|
modelValue: e.modelValue != null ? String(e.modelValue) : "",
|
|
238
|
-
"onUpdate:modelValue":
|
|
435
|
+
"onUpdate:modelValue": a[0] || (a[0] = (t) => i("update:modelValue", t))
|
|
239
436
|
}, {
|
|
240
|
-
default:
|
|
241
|
-
|
|
242
|
-
default:
|
|
243
|
-
|
|
437
|
+
default: m(() => [
|
|
438
|
+
b(Ne, { id: e.fieldId }, {
|
|
439
|
+
default: m(() => [
|
|
440
|
+
b(o(fe), {
|
|
244
441
|
placeholder: e.field.placeholder || "Select an option"
|
|
245
442
|
}, null, 8, ["placeholder"])
|
|
246
443
|
]),
|
|
247
444
|
_: 1
|
|
248
445
|
}, 8, ["id"]),
|
|
249
|
-
|
|
250
|
-
default:
|
|
251
|
-
(
|
|
446
|
+
b(Ee, null, {
|
|
447
|
+
default: m(() => [
|
|
448
|
+
(d(!0), g(N, null, E(e.field.options, (t) => (d(), v(je, {
|
|
252
449
|
key: t.value,
|
|
253
450
|
value: String(t.value)
|
|
254
451
|
}, {
|
|
255
|
-
default:
|
|
256
|
-
|
|
452
|
+
default: m(() => [
|
|
453
|
+
U(F(t.label), 1)
|
|
257
454
|
]),
|
|
258
455
|
_: 2
|
|
259
456
|
}, 1032, ["value"]))), 128))
|
|
@@ -264,7 +461,7 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
264
461
|
_: 1
|
|
265
462
|
}, 8, ["disabled", "name", "modelValue"]));
|
|
266
463
|
}
|
|
267
|
-
}),
|
|
464
|
+
}), Oe = /* @__PURE__ */ p({
|
|
268
465
|
__name: "Checkbox",
|
|
269
466
|
props: {
|
|
270
467
|
defaultChecked: { type: Boolean },
|
|
@@ -279,19 +476,19 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
279
476
|
class: {}
|
|
280
477
|
},
|
|
281
478
|
emits: ["update:checked", "blur"],
|
|
282
|
-
setup(e, { emit:
|
|
283
|
-
const
|
|
284
|
-
const { class:
|
|
285
|
-
return
|
|
286
|
-
}), t =
|
|
287
|
-
return (
|
|
288
|
-
class:
|
|
289
|
-
onBlur:
|
|
479
|
+
setup(e, { emit: l }) {
|
|
480
|
+
const i = e, n = l, a = h(() => {
|
|
481
|
+
const { class: r, ...s } = i;
|
|
482
|
+
return s;
|
|
483
|
+
}), t = A(a, n);
|
|
484
|
+
return (r, s) => (d(), v(o(be), I(o(t), {
|
|
485
|
+
class: o(w)("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", i.class),
|
|
486
|
+
onBlur: s[0] || (s[0] = (u) => n("blur"))
|
|
290
487
|
}), {
|
|
291
|
-
default:
|
|
292
|
-
|
|
293
|
-
default:
|
|
294
|
-
|
|
488
|
+
default: m(() => [
|
|
489
|
+
b(o(pe), { class: "flex h-full w-full items-center justify-center text-current" }, {
|
|
490
|
+
default: m(() => [
|
|
491
|
+
b(o(K), { class: "h-4 w-4" })
|
|
295
492
|
]),
|
|
296
493
|
_: 1
|
|
297
494
|
})
|
|
@@ -299,7 +496,7 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
299
496
|
_: 1
|
|
300
497
|
}, 16, ["class"]));
|
|
301
498
|
}
|
|
302
|
-
}),
|
|
499
|
+
}), T = /* @__PURE__ */ p({
|
|
303
500
|
__name: "Label",
|
|
304
501
|
props: {
|
|
305
502
|
for: {},
|
|
@@ -308,62 +505,65 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
308
505
|
class: {}
|
|
309
506
|
},
|
|
310
507
|
setup(e) {
|
|
311
|
-
const
|
|
312
|
-
const { class:
|
|
313
|
-
return
|
|
508
|
+
const l = e, i = h(() => {
|
|
509
|
+
const { class: n, ...a } = l;
|
|
510
|
+
return a;
|
|
314
511
|
});
|
|
315
|
-
return (
|
|
316
|
-
class:
|
|
512
|
+
return (n, a) => (d(), v(o(ge), I(i.value, {
|
|
513
|
+
class: o(w)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", l.class)
|
|
317
514
|
}), {
|
|
318
|
-
default:
|
|
319
|
-
|
|
515
|
+
default: m(() => [
|
|
516
|
+
q(n.$slots, "default")
|
|
320
517
|
]),
|
|
321
518
|
_: 3
|
|
322
519
|
}, 16, ["class"]));
|
|
323
520
|
}
|
|
324
|
-
}),
|
|
521
|
+
}), ze = { class: "flex flex-wrap gap-4" }, Te = /* @__PURE__ */ p({
|
|
325
522
|
__name: "CheckboxRenderer",
|
|
326
523
|
props: {
|
|
327
524
|
field: {},
|
|
525
|
+
fieldId: {},
|
|
328
526
|
modelValue: {},
|
|
329
|
-
|
|
527
|
+
ariaInvalid: { type: Boolean },
|
|
528
|
+
ariaRequired: { type: Boolean },
|
|
529
|
+
ariaDescribedby: {}
|
|
330
530
|
},
|
|
331
531
|
emits: ["update:modelValue"],
|
|
332
|
-
setup(e, { emit:
|
|
333
|
-
const
|
|
334
|
-
const
|
|
335
|
-
if (
|
|
336
|
-
|
|
532
|
+
setup(e, { emit: l }) {
|
|
533
|
+
const i = e, n = l, a = (t, r) => {
|
|
534
|
+
const s = Array.isArray(i.modelValue) ? [...i.modelValue] : [];
|
|
535
|
+
if (r)
|
|
536
|
+
s.push(t);
|
|
337
537
|
else {
|
|
338
|
-
const
|
|
339
|
-
|
|
538
|
+
const u = s.indexOf(t);
|
|
539
|
+
u > -1 && s.splice(u, 1);
|
|
340
540
|
}
|
|
341
|
-
|
|
541
|
+
n("update:modelValue", s);
|
|
342
542
|
};
|
|
343
|
-
return (t,
|
|
344
|
-
(
|
|
345
|
-
key:
|
|
543
|
+
return (t, r) => (d(), g("div", ze, [
|
|
544
|
+
(d(!0), g(N, null, E(e.field.options, (s) => (d(), g("div", {
|
|
545
|
+
key: s.value,
|
|
346
546
|
class: "flex items-center space-x-2"
|
|
347
547
|
}, [
|
|
348
|
-
|
|
349
|
-
id: `checkbox-${e.field.name}-${
|
|
350
|
-
disabled: e.field.disabled,
|
|
351
|
-
checked: Array.isArray(e.modelValue) && e.modelValue.includes(
|
|
352
|
-
"onUpdate:checked": (
|
|
548
|
+
b(Oe, {
|
|
549
|
+
id: `checkbox-${e.field.name}-${s.value}`,
|
|
550
|
+
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
551
|
+
checked: Array.isArray(e.modelValue) && e.modelValue.includes(s.value),
|
|
552
|
+
"onUpdate:checked": (u) => a(s.value, !!u)
|
|
353
553
|
}, null, 8, ["id", "disabled", "checked", "onUpdate:checked"]),
|
|
354
|
-
|
|
355
|
-
for: `checkbox-${e.field.name}-${
|
|
554
|
+
b(T, {
|
|
555
|
+
for: `checkbox-${e.field.name}-${s.value}`,
|
|
356
556
|
class: "font-normal"
|
|
357
557
|
}, {
|
|
358
|
-
default:
|
|
359
|
-
|
|
558
|
+
default: m(() => [
|
|
559
|
+
U(F(s.label), 1)
|
|
360
560
|
]),
|
|
361
561
|
_: 2
|
|
362
562
|
}, 1032, ["for"])
|
|
363
563
|
]))), 128))
|
|
364
564
|
]));
|
|
365
565
|
}
|
|
366
|
-
}),
|
|
566
|
+
}), Ge = /* @__PURE__ */ p({
|
|
367
567
|
__name: "RadioGroupItem",
|
|
368
568
|
props: {
|
|
369
569
|
id: {},
|
|
@@ -376,17 +576,17 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
376
576
|
class: {}
|
|
377
577
|
},
|
|
378
578
|
setup(e) {
|
|
379
|
-
const
|
|
380
|
-
const { class:
|
|
579
|
+
const l = e, i = h(() => {
|
|
580
|
+
const { class: a, ...t } = l;
|
|
381
581
|
return t;
|
|
382
|
-
}),
|
|
383
|
-
return (
|
|
384
|
-
class:
|
|
582
|
+
}), n = j(i);
|
|
583
|
+
return (a, t) => (d(), v(o(ye), I(o(n), {
|
|
584
|
+
class: o(w)("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", l.class)
|
|
385
585
|
}), {
|
|
386
|
-
default:
|
|
387
|
-
|
|
388
|
-
default:
|
|
389
|
-
|
|
586
|
+
default: m(() => [
|
|
587
|
+
b(o(ve), { class: "flex items-center justify-center" }, {
|
|
588
|
+
default: m(() => [
|
|
589
|
+
b(o(we), { class: "h-2.5 w-2.5 fill-current text-current" })
|
|
390
590
|
]),
|
|
391
591
|
_: 1
|
|
392
592
|
})
|
|
@@ -394,7 +594,7 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
394
594
|
_: 1
|
|
395
595
|
}, 16, ["class"]));
|
|
396
596
|
}
|
|
397
|
-
}),
|
|
597
|
+
}), Le = /* @__PURE__ */ p({
|
|
398
598
|
__name: "RadioGroup",
|
|
399
599
|
props: {
|
|
400
600
|
modelValue: {},
|
|
@@ -410,52 +610,55 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
410
610
|
class: {}
|
|
411
611
|
},
|
|
412
612
|
emits: ["update:modelValue"],
|
|
413
|
-
setup(e, { emit:
|
|
414
|
-
const
|
|
415
|
-
const { class:
|
|
416
|
-
return
|
|
417
|
-
}), t =
|
|
418
|
-
return (
|
|
419
|
-
class:
|
|
613
|
+
setup(e, { emit: l }) {
|
|
614
|
+
const i = e, n = l, a = h(() => {
|
|
615
|
+
const { class: r, ...s } = i;
|
|
616
|
+
return s;
|
|
617
|
+
}), t = A(a, n);
|
|
618
|
+
return (r, s) => (d(), v(o(he), I(o(t), {
|
|
619
|
+
class: o(w)("grid gap-2", i.class)
|
|
420
620
|
}), {
|
|
421
|
-
default:
|
|
422
|
-
|
|
621
|
+
default: m(() => [
|
|
622
|
+
q(r.$slots, "default")
|
|
423
623
|
]),
|
|
424
624
|
_: 3
|
|
425
625
|
}, 16, ["class"]));
|
|
426
626
|
}
|
|
427
|
-
}),
|
|
627
|
+
}), He = /* @__PURE__ */ p({
|
|
428
628
|
__name: "RadioRenderer",
|
|
429
629
|
props: {
|
|
430
630
|
field: {},
|
|
631
|
+
fieldId: {},
|
|
431
632
|
modelValue: {},
|
|
432
|
-
|
|
633
|
+
ariaInvalid: { type: Boolean },
|
|
634
|
+
ariaRequired: { type: Boolean },
|
|
635
|
+
ariaDescribedby: {}
|
|
433
636
|
},
|
|
434
637
|
emits: ["update:modelValue"],
|
|
435
|
-
setup(e, { emit:
|
|
436
|
-
const
|
|
437
|
-
return (
|
|
638
|
+
setup(e, { emit: l }) {
|
|
639
|
+
const i = l;
|
|
640
|
+
return (n, a) => (d(), v(Le, {
|
|
438
641
|
class: "flex flex-wrap gap-4",
|
|
439
|
-
disabled: e.field.disabled,
|
|
642
|
+
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
440
643
|
name: e.field.name,
|
|
441
644
|
modelValue: e.modelValue != null ? String(e.modelValue) : "",
|
|
442
|
-
"onUpdate:modelValue":
|
|
645
|
+
"onUpdate:modelValue": a[0] || (a[0] = (t) => i("update:modelValue", t))
|
|
443
646
|
}, {
|
|
444
|
-
default:
|
|
445
|
-
(
|
|
647
|
+
default: m(() => [
|
|
648
|
+
(d(!0), g(N, null, E(e.field.options, (t) => (d(), g("div", {
|
|
446
649
|
key: t.value,
|
|
447
650
|
class: "flex items-center space-x-2"
|
|
448
651
|
}, [
|
|
449
|
-
|
|
652
|
+
b(Ge, {
|
|
450
653
|
id: `radio-${e.field.name}-${t.value}`,
|
|
451
654
|
value: String(t.value)
|
|
452
655
|
}, null, 8, ["id", "value"]),
|
|
453
|
-
|
|
656
|
+
b(T, {
|
|
454
657
|
for: `radio-${e.field.name}-${t.value}`,
|
|
455
658
|
class: "font-normal"
|
|
456
659
|
}, {
|
|
457
|
-
default:
|
|
458
|
-
|
|
660
|
+
default: m(() => [
|
|
661
|
+
U(F(t.label), 1)
|
|
459
662
|
]),
|
|
460
663
|
_: 2
|
|
461
664
|
}, 1032, ["for"])
|
|
@@ -464,23 +667,109 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
464
667
|
_: 1
|
|
465
668
|
}, 8, ["disabled", "name", "modelValue"]));
|
|
466
669
|
}
|
|
467
|
-
}),
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
670
|
+
}), Ke = /* @__PURE__ */ p({
|
|
671
|
+
__name: "DateRenderer",
|
|
672
|
+
props: {
|
|
673
|
+
field: {},
|
|
674
|
+
modelValue: {},
|
|
675
|
+
fieldId: {},
|
|
676
|
+
ariaInvalid: { type: Boolean },
|
|
677
|
+
ariaRequired: { type: Boolean },
|
|
678
|
+
ariaDescribedby: {}
|
|
679
|
+
},
|
|
680
|
+
emits: ["update:modelValue", "blur"],
|
|
681
|
+
setup(e, { emit: l }) {
|
|
682
|
+
const i = l;
|
|
683
|
+
return (n, a) => (d(), v(Q, {
|
|
684
|
+
id: e.fieldId,
|
|
685
|
+
type: "date",
|
|
686
|
+
modelValue: e.modelValue,
|
|
687
|
+
placeholder: e.field.placeholder,
|
|
688
|
+
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
689
|
+
name: e.field.name,
|
|
690
|
+
"aria-invalid": e.ariaInvalid,
|
|
691
|
+
"aria-required": e.ariaRequired,
|
|
692
|
+
"aria-describedby": e.ariaDescribedby,
|
|
693
|
+
"onUpdate:modelValue": a[0] || (a[0] = (t) => i("update:modelValue", t)),
|
|
694
|
+
onBlur: a[1] || (a[1] = (t) => i("blur", t))
|
|
695
|
+
}, null, 8, ["id", "modelValue", "placeholder", "disabled", "name", "aria-invalid", "aria-required", "aria-describedby"]));
|
|
696
|
+
}
|
|
697
|
+
}), We = /* @__PURE__ */ p({
|
|
698
|
+
__name: "Switch",
|
|
699
|
+
props: {
|
|
700
|
+
defaultChecked: { type: Boolean },
|
|
701
|
+
checked: { type: Boolean },
|
|
702
|
+
disabled: { type: Boolean },
|
|
703
|
+
required: { type: Boolean },
|
|
704
|
+
name: {},
|
|
705
|
+
id: {},
|
|
706
|
+
value: {},
|
|
707
|
+
asChild: { type: Boolean },
|
|
708
|
+
as: {},
|
|
709
|
+
class: {}
|
|
710
|
+
},
|
|
711
|
+
emits: ["update:checked"],
|
|
712
|
+
setup(e, { emit: l }) {
|
|
713
|
+
const i = e, n = l, a = h(() => {
|
|
714
|
+
const { class: r, ...s } = i;
|
|
715
|
+
return s;
|
|
716
|
+
}), t = A(a, n);
|
|
717
|
+
return (r, s) => (d(), v(o(xe), I(o(t), {
|
|
718
|
+
class: o(w)(
|
|
719
|
+
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
720
|
+
i.class
|
|
721
|
+
)
|
|
722
|
+
}), {
|
|
723
|
+
default: m(() => [
|
|
724
|
+
b(o(Ve), {
|
|
725
|
+
class: D(o(w)(
|
|
726
|
+
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
|
|
727
|
+
))
|
|
728
|
+
}, null, 8, ["class"])
|
|
729
|
+
]),
|
|
730
|
+
_: 1
|
|
731
|
+
}, 16, ["class"]));
|
|
732
|
+
}
|
|
733
|
+
}), Je = { class: "flex items-center space-x-2" }, Qe = /* @__PURE__ */ p({
|
|
734
|
+
__name: "SwitchRenderer",
|
|
735
|
+
props: {
|
|
736
|
+
field: {},
|
|
737
|
+
modelValue: { type: Boolean },
|
|
738
|
+
fieldId: {},
|
|
739
|
+
ariaInvalid: { type: Boolean },
|
|
740
|
+
ariaRequired: { type: Boolean },
|
|
741
|
+
ariaDescribedby: {}
|
|
742
|
+
},
|
|
743
|
+
emits: ["update:modelValue", "blur"],
|
|
744
|
+
setup(e, { emit: l }) {
|
|
745
|
+
const i = l;
|
|
746
|
+
return (n, a) => (d(), g("div", Je, [
|
|
747
|
+
b(We, {
|
|
748
|
+
id: e.fieldId,
|
|
749
|
+
checked: e.modelValue,
|
|
750
|
+
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
751
|
+
"aria-invalid": e.ariaInvalid,
|
|
752
|
+
"aria-required": e.ariaRequired,
|
|
753
|
+
"aria-describedby": e.ariaDescribedby,
|
|
754
|
+
"onUpdate:checked": a[0] || (a[0] = (t) => i("update:modelValue", t))
|
|
755
|
+
}, null, 8, ["id", "checked", "disabled", "aria-invalid", "aria-required", "aria-describedby"])
|
|
756
|
+
]));
|
|
757
|
+
}
|
|
758
|
+
}), H = {
|
|
759
|
+
text: P,
|
|
760
|
+
number: P,
|
|
761
|
+
password: P,
|
|
762
|
+
email: P,
|
|
763
|
+
textarea: De,
|
|
764
|
+
select: Me,
|
|
765
|
+
checkbox: Te,
|
|
766
|
+
radio: He,
|
|
767
|
+
date: Ke,
|
|
768
|
+
switch: Qe
|
|
769
|
+
}, Xe = {
|
|
770
|
+
key: 0,
|
|
771
|
+
class: "text-destructive"
|
|
772
|
+
}, Ye = ["id"], Ze = ["id"], _e = /* @__PURE__ */ p({
|
|
484
773
|
__name: "FormFieldRenderer",
|
|
485
774
|
props: {
|
|
486
775
|
field: {},
|
|
@@ -488,89 +777,153 @@ const ce = ["type", "value"], me = /* @__PURE__ */ f({
|
|
|
488
777
|
error: {},
|
|
489
778
|
componentMap: {}
|
|
490
779
|
},
|
|
491
|
-
emits: ["update:modelValue"],
|
|
492
|
-
setup(e, { emit:
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
780
|
+
emits: ["update:modelValue", "blur"],
|
|
781
|
+
setup(e, { emit: l }) {
|
|
782
|
+
const i = e, n = l, a = h(() => `field-${i.field.name}`), t = h(() => `${a.value}-description`), r = h(() => `${a.value}-error`), s = h(() => {
|
|
783
|
+
var c;
|
|
784
|
+
return (c = i.field.validations) == null ? void 0 : c.some((x) => x.type === "required");
|
|
785
|
+
}), u = h(() => {
|
|
786
|
+
const c = [];
|
|
787
|
+
return i.field.description && c.push(t.value), i.error && c.push(r.value), c.length > 0 ? c.join(" ") : void 0;
|
|
788
|
+
}), f = h(
|
|
789
|
+
() => i.componentMap ? { ...H, ...i.componentMap } : H
|
|
790
|
+
), $ = h(
|
|
791
|
+
() => f.value[i.field.type] ?? P
|
|
497
792
|
);
|
|
498
|
-
return (
|
|
499
|
-
class:
|
|
793
|
+
return (c, x) => (d(), g("div", {
|
|
794
|
+
class: D(["space-y-2", e.field.className])
|
|
500
795
|
}, [
|
|
501
|
-
e.field.label ? (
|
|
796
|
+
e.field.label ? (d(), v(T, {
|
|
502
797
|
key: 0,
|
|
503
|
-
for:
|
|
798
|
+
for: a.value,
|
|
799
|
+
class: D(s.value ? "flex items-center gap-1" : "")
|
|
504
800
|
}, {
|
|
505
|
-
default:
|
|
506
|
-
|
|
801
|
+
default: m(() => [
|
|
802
|
+
U(F(e.field.label) + " ", 1),
|
|
803
|
+
s.value ? (d(), g("span", Xe, "*")) : R("", !0)
|
|
507
804
|
]),
|
|
508
805
|
_: 1
|
|
509
|
-
}, 8, ["for"])) :
|
|
510
|
-
(
|
|
806
|
+
}, 8, ["for", "class"])) : R("", !0),
|
|
807
|
+
(d(), v(Z($.value), {
|
|
511
808
|
field: e.field,
|
|
512
|
-
fieldId:
|
|
809
|
+
fieldId: a.value,
|
|
513
810
|
modelValue: e.modelValue,
|
|
514
|
-
"
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
811
|
+
"aria-invalid": !!e.error,
|
|
812
|
+
"aria-required": s.value,
|
|
813
|
+
"aria-describedby": u.value,
|
|
814
|
+
"onUpdate:modelValue": x[0] || (x[0] = (V) => n("update:modelValue", V)),
|
|
815
|
+
onBlur: x[1] || (x[1] = (V) => n("blur", V))
|
|
816
|
+
}, null, 40, ["field", "fieldId", "modelValue", "aria-invalid", "aria-required", "aria-describedby"])),
|
|
817
|
+
e.field.description ? (d(), g("p", {
|
|
818
|
+
key: 1,
|
|
819
|
+
id: t.value,
|
|
820
|
+
class: "text-[0.8rem] text-muted-foreground"
|
|
821
|
+
}, F(e.field.description), 9, Ye)) : R("", !0),
|
|
822
|
+
e.error ? (d(), g("p", {
|
|
823
|
+
key: 2,
|
|
824
|
+
id: r.value,
|
|
825
|
+
class: "text-[0.8rem] font-medium text-destructive"
|
|
826
|
+
}, F(e.error), 9, Ze)) : R("", !0)
|
|
518
827
|
], 2));
|
|
519
828
|
}
|
|
520
|
-
})
|
|
829
|
+
});
|
|
830
|
+
function et({ schema: e }) {
|
|
831
|
+
const l = Re(e.fields, e.resolver, e.errorMessages), i = _(l.getState()), n = l.subscribe((u) => {
|
|
832
|
+
i.value = u;
|
|
833
|
+
});
|
|
834
|
+
return ee(() => {
|
|
835
|
+
n();
|
|
836
|
+
}), {
|
|
837
|
+
store: l,
|
|
838
|
+
state: i,
|
|
839
|
+
// This is a Ref
|
|
840
|
+
setValue: async (u, f) => {
|
|
841
|
+
await l.getState().setFieldValue(u, f);
|
|
842
|
+
},
|
|
843
|
+
getValue: (u) => M(i.value.values, u),
|
|
844
|
+
validate: async () => {
|
|
845
|
+
const { hasError: u, state: f } = await l.getState().runSubmitValidation();
|
|
846
|
+
return { hasError: u, values: f.values };
|
|
847
|
+
},
|
|
848
|
+
reset: () => {
|
|
849
|
+
l.setState({
|
|
850
|
+
values: {},
|
|
851
|
+
errors: {},
|
|
852
|
+
isSubmitting: !1
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
const tt = {
|
|
521
858
|
key: 0,
|
|
522
859
|
class: "space-y-1"
|
|
523
|
-
},
|
|
860
|
+
}, at = {
|
|
524
861
|
key: 0,
|
|
525
862
|
class: "text-2xl font-bold tracking-tight"
|
|
526
|
-
},
|
|
863
|
+
}, lt = {
|
|
527
864
|
key: 1,
|
|
528
865
|
class: "text-muted-foreground"
|
|
529
|
-
},
|
|
866
|
+
}, it = { class: "space-y-4" }, nt = ["disabled"], ct = /* @__PURE__ */ p({
|
|
530
867
|
__name: "DynamicForm",
|
|
531
868
|
props: {
|
|
532
869
|
schema: {},
|
|
533
|
-
className: {}
|
|
870
|
+
className: {},
|
|
871
|
+
form: {}
|
|
534
872
|
},
|
|
535
873
|
emits: ["submit"],
|
|
536
|
-
setup(e, { emit:
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
},
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
874
|
+
setup(e, { emit: l }) {
|
|
875
|
+
const i = e, n = l, a = et({ schema: i.schema }), t = i.form || a, { store: r, state: s } = t, u = async (y, C) => {
|
|
876
|
+
await r.getState().setFieldValue(y, C);
|
|
877
|
+
}, f = async (y) => {
|
|
878
|
+
await r.getState().setFieldBlur(y);
|
|
879
|
+
}, $ = (y) => typeof y.hidden == "function" ? y.hidden(s.value.values) : !!y.hidden, c = (y) => {
|
|
880
|
+
const C = typeof y.disabled == "function" ? y.disabled(s.value.values) : !!y.disabled, k = s.value.validatingFields.includes(y.name);
|
|
881
|
+
return { ...y, disabled: C || k };
|
|
882
|
+
}, x = async () => {
|
|
883
|
+
const { hasError: y, values: C } = await t.validate();
|
|
884
|
+
if (y) {
|
|
885
|
+
const k = i.schema.fields.find((B) => s.value.errors[B.name]);
|
|
886
|
+
if (k) {
|
|
887
|
+
const B = document.getElementById(`field-${k.name}`);
|
|
888
|
+
B == null || B.focus(), B == null || B.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
889
|
+
}
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
await n("submit", C);
|
|
893
|
+
}, V = h(() => s.value.validatingFields.length > 0);
|
|
894
|
+
return (y, C) => (d(), g("form", {
|
|
895
|
+
class: D(["space-y-6", e.className]),
|
|
896
|
+
onSubmit: te(x, ["prevent"])
|
|
546
897
|
}, [
|
|
547
|
-
e.schema.title || e.schema.description ? (
|
|
548
|
-
e.schema.title ? (
|
|
549
|
-
e.schema.description ? (
|
|
550
|
-
])) :
|
|
551
|
-
|
|
552
|
-
(
|
|
553
|
-
key:
|
|
898
|
+
e.schema.title || e.schema.description ? (d(), g("div", tt, [
|
|
899
|
+
e.schema.title ? (d(), g("h2", at, F(e.schema.title), 1)) : R("", !0),
|
|
900
|
+
e.schema.description ? (d(), g("p", lt, F(e.schema.description), 1)) : R("", !0)
|
|
901
|
+
])) : R("", !0),
|
|
902
|
+
O("div", it, [
|
|
903
|
+
(d(!0), g(N, null, E(e.schema.fields, (k) => (d(), g(N, {
|
|
904
|
+
key: k.id
|
|
554
905
|
}, [
|
|
555
|
-
|
|
906
|
+
$(k) ? R("", !0) : (d(), v(_e, {
|
|
556
907
|
key: 0,
|
|
557
|
-
field:
|
|
558
|
-
"model-value":
|
|
559
|
-
error:
|
|
560
|
-
"onUpdate:modelValue": (
|
|
561
|
-
|
|
908
|
+
field: c(k),
|
|
909
|
+
"model-value": o(M)(o(s).values, k.name),
|
|
910
|
+
error: o(s).errors[k.name],
|
|
911
|
+
"onUpdate:modelValue": (B) => u(k.name, B),
|
|
912
|
+
onBlur: (B) => f(k.name)
|
|
913
|
+
}, null, 8, ["field", "model-value", "error", "onUpdate:modelValue", "onBlur"]))
|
|
562
914
|
], 64))), 128))
|
|
563
915
|
]),
|
|
564
|
-
|
|
916
|
+
O("button", {
|
|
565
917
|
type: "submit",
|
|
566
|
-
disabled:
|
|
918
|
+
disabled: o(s).isSubmitting || V.value,
|
|
567
919
|
class: "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2 w-full"
|
|
568
|
-
},
|
|
920
|
+
}, F(o(s).isSubmitting ? "Submitting..." : V.value ? "Validating..." : e.schema.submitButtonText || "Submit"), 9, nt)
|
|
569
921
|
], 34));
|
|
570
922
|
}
|
|
571
923
|
});
|
|
572
924
|
export {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
925
|
+
ct as DynamicForm,
|
|
926
|
+
_e as FormFieldRenderer,
|
|
927
|
+
H as defaultComponentMap,
|
|
928
|
+
et as useForm
|
|
576
929
|
};
|