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