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