pdyform 2.2.1 → 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-B7OMM2UC.js → chunk-T3LQTNYY.js} +1 -0
- package/packages/core/dist/chunk-V4VK2GZU.js +108 -0
- package/packages/core/dist/formState.cjs +88 -60
- 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 -60
- 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 +1 -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 +383 -380
- package/packages/core/dist/chunk-J6ESJZ4U.js +0 -82
|
@@ -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,184 +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
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 Ie(e, l, i,
|
|
112
|
-
let
|
|
113
|
-
i && (
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
const u = await J(M(l, r.name), r,
|
|
117
|
-
u && (
|
|
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: $e(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
|
-
|
|
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)
|
|
145
148
|
}));
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
validatingFields: [...
|
|
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]
|
|
150
153
|
}));
|
|
151
154
|
try {
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
errors: { ...
|
|
155
|
-
validatingFields:
|
|
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)
|
|
156
159
|
}));
|
|
157
160
|
} catch {
|
|
158
|
-
|
|
159
|
-
validatingFields:
|
|
161
|
+
a((b) => ({
|
|
162
|
+
validatingFields: b.validatingFields.filter((k) => k !== m)
|
|
160
163
|
}));
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
166
|
},
|
|
164
|
-
setFieldBlur: async (
|
|
165
|
-
|
|
166
|
-
validatingFields: [...
|
|
167
|
+
setFieldBlur: async (m) => {
|
|
168
|
+
a((f) => ({
|
|
169
|
+
validatingFields: [...f.validatingFields, m]
|
|
167
170
|
}));
|
|
168
171
|
try {
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
errors: { ...
|
|
172
|
-
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)
|
|
173
176
|
}));
|
|
174
177
|
} catch {
|
|
175
|
-
|
|
176
|
-
validatingFields:
|
|
178
|
+
a((f) => ({
|
|
179
|
+
validatingFields: f.validatingFields.filter((v) => v !== m)
|
|
177
180
|
}));
|
|
178
181
|
}
|
|
179
182
|
},
|
|
180
|
-
setSubmitting: (
|
|
183
|
+
setSubmitting: (m) => a({ isSubmitting: m }),
|
|
181
184
|
runSubmitValidation: async () => {
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
return
|
|
185
|
-
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,
|
|
186
189
|
isSubmitting: !1
|
|
187
190
|
}), {
|
|
188
|
-
state:
|
|
189
|
-
hasError:
|
|
191
|
+
state: t(),
|
|
192
|
+
hasError: v
|
|
190
193
|
};
|
|
191
194
|
}
|
|
192
|
-
}
|
|
195
|
+
};
|
|
193
196
|
}
|
|
194
|
-
function
|
|
195
|
-
return le(
|
|
197
|
+
function B(...e) {
|
|
198
|
+
return ie(le(e));
|
|
196
199
|
}
|
|
197
|
-
const
|
|
200
|
+
const qe = ["type", "value"], Q = /* @__PURE__ */ y({
|
|
198
201
|
__name: "Input",
|
|
199
202
|
props: {
|
|
200
203
|
class: {},
|
|
@@ -203,16 +206,16 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
203
206
|
},
|
|
204
207
|
emits: ["update:modelValue", "blur"],
|
|
205
208
|
setup(e, { emit: l }) {
|
|
206
|
-
const i = e,
|
|
207
|
-
return (
|
|
209
|
+
const i = e, s = l;
|
|
210
|
+
return (t, a) => (d(), h("input", I(t.$attrs, {
|
|
208
211
|
type: e.type,
|
|
209
|
-
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),
|
|
210
213
|
value: e.modelValue,
|
|
211
|
-
onInput:
|
|
212
|
-
onBlur:
|
|
213
|
-
}), 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));
|
|
214
217
|
}
|
|
215
|
-
}), P = /* @__PURE__ */
|
|
218
|
+
}), P = /* @__PURE__ */ y({
|
|
216
219
|
__name: "InputRenderer",
|
|
217
220
|
props: {
|
|
218
221
|
field: {},
|
|
@@ -224,21 +227,21 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
224
227
|
},
|
|
225
228
|
emits: ["update:modelValue", "blur"],
|
|
226
229
|
setup(e, { emit: l }) {
|
|
227
|
-
const i = e,
|
|
228
|
-
|
|
230
|
+
const i = e, s = l, t = (a) => {
|
|
231
|
+
s("update:modelValue", W(i.field, a));
|
|
229
232
|
};
|
|
230
|
-
return (
|
|
233
|
+
return (a, r) => (d(), x(Q, {
|
|
231
234
|
id: e.fieldId,
|
|
232
235
|
type: e.field.type,
|
|
233
236
|
placeholder: e.field.placeholder,
|
|
234
237
|
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
235
238
|
name: e.field.name,
|
|
236
|
-
|
|
237
|
-
"onUpdate:modelValue":
|
|
238
|
-
onBlur: r[0] || (r[0] = (
|
|
239
|
-
}, 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"]));
|
|
240
243
|
}
|
|
241
|
-
}),
|
|
244
|
+
}), Pe = ["value"], De = /* @__PURE__ */ y({
|
|
242
245
|
__name: "Textarea",
|
|
243
246
|
props: {
|
|
244
247
|
class: {},
|
|
@@ -246,15 +249,15 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
246
249
|
},
|
|
247
250
|
emits: ["update:modelValue", "blur"],
|
|
248
251
|
setup(e, { emit: l }) {
|
|
249
|
-
const i = e,
|
|
250
|
-
return (
|
|
251
|
-
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),
|
|
252
255
|
value: e.modelValue,
|
|
253
|
-
onInput:
|
|
254
|
-
onBlur:
|
|
255
|
-
}), 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));
|
|
256
259
|
}
|
|
257
|
-
}),
|
|
260
|
+
}), Ne = /* @__PURE__ */ y({
|
|
258
261
|
__name: "TextareaRenderer",
|
|
259
262
|
props: {
|
|
260
263
|
field: {},
|
|
@@ -267,16 +270,16 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
267
270
|
emits: ["update:modelValue"],
|
|
268
271
|
setup(e, { emit: l }) {
|
|
269
272
|
const i = l;
|
|
270
|
-
return (
|
|
273
|
+
return (s, t) => (d(), x(De, {
|
|
271
274
|
id: e.fieldId,
|
|
272
275
|
placeholder: e.field.placeholder,
|
|
273
276
|
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
274
277
|
name: e.field.name,
|
|
275
|
-
|
|
276
|
-
"onUpdate:modelValue":
|
|
277
|
-
}, 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"]));
|
|
278
281
|
}
|
|
279
|
-
}),
|
|
282
|
+
}), Ee = /* @__PURE__ */ y({
|
|
280
283
|
__name: "SelectTrigger",
|
|
281
284
|
props: {
|
|
282
285
|
disabled: { type: Boolean },
|
|
@@ -285,18 +288,18 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
285
288
|
class: {}
|
|
286
289
|
},
|
|
287
290
|
setup(e) {
|
|
288
|
-
const l = e, i =
|
|
289
|
-
const { class:
|
|
290
|
-
return
|
|
291
|
-
}),
|
|
292
|
-
return (
|
|
293
|
-
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)
|
|
294
297
|
}), {
|
|
295
|
-
default:
|
|
296
|
-
q(
|
|
297
|
-
|
|
298
|
-
default:
|
|
299
|
-
|
|
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" })
|
|
300
303
|
]),
|
|
301
304
|
_: 1
|
|
302
305
|
})
|
|
@@ -304,7 +307,7 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
304
307
|
_: 3
|
|
305
308
|
}, 16, ["class"]));
|
|
306
309
|
}
|
|
307
|
-
}),
|
|
310
|
+
}), Ue = /* @__PURE__ */ y({
|
|
308
311
|
__name: "SelectContent",
|
|
309
312
|
props: {
|
|
310
313
|
forceMount: { type: Boolean },
|
|
@@ -327,21 +330,21 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
327
330
|
class: {}
|
|
328
331
|
},
|
|
329
332
|
setup(e) {
|
|
330
|
-
const l = e, i =
|
|
331
|
-
const { class:
|
|
332
|
-
return
|
|
333
|
-
}),
|
|
334
|
-
return (
|
|
335
|
-
default:
|
|
336
|
-
|
|
337
|
-
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)
|
|
338
341
|
}), {
|
|
339
|
-
default:
|
|
340
|
-
|
|
341
|
-
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)]"))
|
|
342
345
|
}, {
|
|
343
|
-
default:
|
|
344
|
-
q(
|
|
346
|
+
default: c(() => [
|
|
347
|
+
q(t.$slots, "default")
|
|
345
348
|
]),
|
|
346
349
|
_: 3
|
|
347
350
|
}, 8, ["class"])
|
|
@@ -352,7 +355,7 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
352
355
|
_: 3
|
|
353
356
|
}));
|
|
354
357
|
}
|
|
355
|
-
}),
|
|
358
|
+
}), je = { class: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center" }, Ae = /* @__PURE__ */ y({
|
|
356
359
|
__name: "SelectItem",
|
|
357
360
|
props: {
|
|
358
361
|
value: {},
|
|
@@ -363,28 +366,28 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
363
366
|
class: {}
|
|
364
367
|
},
|
|
365
368
|
setup(e) {
|
|
366
|
-
const l = e, i =
|
|
367
|
-
const { class:
|
|
368
|
-
return
|
|
369
|
-
}),
|
|
370
|
-
return (
|
|
371
|
-
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)(
|
|
372
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",
|
|
373
376
|
l.class
|
|
374
377
|
)
|
|
375
378
|
}), {
|
|
376
|
-
default:
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
default:
|
|
380
|
-
|
|
379
|
+
default: c(() => [
|
|
380
|
+
z("span", je, [
|
|
381
|
+
g(o(ce), null, {
|
|
382
|
+
default: c(() => [
|
|
383
|
+
g(o(K), { class: "h-4 w-4" })
|
|
381
384
|
]),
|
|
382
385
|
_: 1
|
|
383
386
|
})
|
|
384
387
|
]),
|
|
385
|
-
|
|
386
|
-
default:
|
|
387
|
-
q(
|
|
388
|
+
g(o(me), null, {
|
|
389
|
+
default: c(() => [
|
|
390
|
+
q(t.$slots, "default")
|
|
388
391
|
]),
|
|
389
392
|
_: 3
|
|
390
393
|
})
|
|
@@ -392,7 +395,7 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
392
395
|
_: 3
|
|
393
396
|
}, 16, ["class"]));
|
|
394
397
|
}
|
|
395
|
-
}),
|
|
398
|
+
}), Me = /* @__PURE__ */ y({
|
|
396
399
|
__name: "Select",
|
|
397
400
|
props: {
|
|
398
401
|
open: { type: Boolean },
|
|
@@ -407,15 +410,15 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
407
410
|
},
|
|
408
411
|
emits: ["update:modelValue", "update:open"],
|
|
409
412
|
setup(e, { emit: l }) {
|
|
410
|
-
const
|
|
411
|
-
return (
|
|
412
|
-
default:
|
|
413
|
-
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")
|
|
414
417
|
]),
|
|
415
418
|
_: 3
|
|
416
419
|
}, 16));
|
|
417
420
|
}
|
|
418
|
-
}),
|
|
421
|
+
}), ze = /* @__PURE__ */ y({
|
|
419
422
|
__name: "SelectRenderer",
|
|
420
423
|
props: {
|
|
421
424
|
field: {},
|
|
@@ -428,29 +431,29 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
428
431
|
emits: ["update:modelValue"],
|
|
429
432
|
setup(e, { emit: l }) {
|
|
430
433
|
const i = l;
|
|
431
|
-
return (
|
|
434
|
+
return (s, t) => (d(), x(Me, {
|
|
432
435
|
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
433
436
|
name: e.field.name,
|
|
434
|
-
|
|
435
|
-
"onUpdate:modelValue":
|
|
437
|
+
"model-value": e.modelValue != null ? String(e.modelValue) : "",
|
|
438
|
+
"onUpdate:modelValue": t[0] || (t[0] = (a) => i("update:modelValue", a))
|
|
436
439
|
}, {
|
|
437
|
-
default:
|
|
438
|
-
|
|
439
|
-
default:
|
|
440
|
-
|
|
440
|
+
default: c(() => [
|
|
441
|
+
g(Ee, { id: e.fieldId }, {
|
|
442
|
+
default: c(() => [
|
|
443
|
+
g(o(be), {
|
|
441
444
|
placeholder: e.field.placeholder || "Select an option"
|
|
442
445
|
}, null, 8, ["placeholder"])
|
|
443
446
|
]),
|
|
444
447
|
_: 1
|
|
445
448
|
}, 8, ["id"]),
|
|
446
|
-
|
|
447
|
-
default:
|
|
448
|
-
(d(!0),
|
|
449
|
-
key:
|
|
450
|
-
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)
|
|
451
454
|
}, {
|
|
452
|
-
default:
|
|
453
|
-
U(
|
|
455
|
+
default: c(() => [
|
|
456
|
+
U(R(a.label), 1)
|
|
454
457
|
]),
|
|
455
458
|
_: 2
|
|
456
459
|
}, 1032, ["value"]))), 128))
|
|
@@ -459,9 +462,9 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
459
462
|
})
|
|
460
463
|
]),
|
|
461
464
|
_: 1
|
|
462
|
-
}, 8, ["disabled", "name", "
|
|
465
|
+
}, 8, ["disabled", "name", "model-value"]));
|
|
463
466
|
}
|
|
464
|
-
}), Oe = /* @__PURE__ */
|
|
467
|
+
}), Oe = /* @__PURE__ */ y({
|
|
465
468
|
__name: "Checkbox",
|
|
466
469
|
props: {
|
|
467
470
|
defaultChecked: { type: Boolean },
|
|
@@ -477,18 +480,18 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
477
480
|
},
|
|
478
481
|
emits: ["update:checked", "blur"],
|
|
479
482
|
setup(e, { emit: l }) {
|
|
480
|
-
const i = e,
|
|
481
|
-
const { class: r, ...
|
|
482
|
-
return
|
|
483
|
-
}),
|
|
484
|
-
return (r,
|
|
485
|
-
class: o(
|
|
486
|
-
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"))
|
|
487
490
|
}), {
|
|
488
|
-
default:
|
|
489
|
-
|
|
490
|
-
default:
|
|
491
|
-
|
|
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" })
|
|
492
495
|
]),
|
|
493
496
|
_: 1
|
|
494
497
|
})
|
|
@@ -496,7 +499,7 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
496
499
|
_: 1
|
|
497
500
|
}, 16, ["class"]));
|
|
498
501
|
}
|
|
499
|
-
}), T = /* @__PURE__ */
|
|
502
|
+
}), T = /* @__PURE__ */ y({
|
|
500
503
|
__name: "Label",
|
|
501
504
|
props: {
|
|
502
505
|
for: {},
|
|
@@ -505,20 +508,20 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
505
508
|
class: {}
|
|
506
509
|
},
|
|
507
510
|
setup(e) {
|
|
508
|
-
const l = e, i =
|
|
509
|
-
const { class:
|
|
510
|
-
return
|
|
511
|
+
const l = e, i = V(() => {
|
|
512
|
+
const { class: s, ...t } = l;
|
|
513
|
+
return t;
|
|
511
514
|
});
|
|
512
|
-
return (
|
|
513
|
-
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)
|
|
514
517
|
}), {
|
|
515
|
-
default:
|
|
516
|
-
q(
|
|
518
|
+
default: c(() => [
|
|
519
|
+
q(s.$slots, "default")
|
|
517
520
|
]),
|
|
518
521
|
_: 3
|
|
519
522
|
}, 16, ["class"]));
|
|
520
523
|
}
|
|
521
|
-
}),
|
|
524
|
+
}), Te = { class: "flex flex-wrap gap-4" }, Ge = /* @__PURE__ */ y({
|
|
522
525
|
__name: "CheckboxRenderer",
|
|
523
526
|
props: {
|
|
524
527
|
field: {},
|
|
@@ -530,40 +533,40 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
530
533
|
},
|
|
531
534
|
emits: ["update:modelValue"],
|
|
532
535
|
setup(e, { emit: l }) {
|
|
533
|
-
const i = e,
|
|
534
|
-
const
|
|
536
|
+
const i = e, s = l, t = (a, r) => {
|
|
537
|
+
const n = Array.isArray(i.modelValue) ? [...i.modelValue] : [];
|
|
535
538
|
if (r)
|
|
536
|
-
|
|
539
|
+
n.push(a);
|
|
537
540
|
else {
|
|
538
|
-
const u =
|
|
539
|
-
u > -1 &&
|
|
541
|
+
const u = n.indexOf(a);
|
|
542
|
+
u > -1 && n.splice(u, 1);
|
|
540
543
|
}
|
|
541
|
-
|
|
544
|
+
s("update:modelValue", n);
|
|
542
545
|
};
|
|
543
|
-
return (
|
|
544
|
-
(d(!0),
|
|
545
|
-
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,
|
|
546
549
|
class: "flex items-center space-x-2"
|
|
547
550
|
}, [
|
|
548
|
-
|
|
549
|
-
id: `checkbox-${e.field.name}-${
|
|
551
|
+
g(Oe, {
|
|
552
|
+
id: `checkbox-${e.field.name}-${n.value}`,
|
|
550
553
|
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
551
|
-
checked: Array.isArray(e.modelValue) && e.modelValue.includes(
|
|
552
|
-
"onUpdate:checked": (u) =>
|
|
554
|
+
checked: Array.isArray(e.modelValue) && e.modelValue.includes(n.value),
|
|
555
|
+
"onUpdate:checked": (u) => t(n.value, !!u)
|
|
553
556
|
}, null, 8, ["id", "disabled", "checked", "onUpdate:checked"]),
|
|
554
|
-
|
|
555
|
-
for: `checkbox-${e.field.name}-${
|
|
557
|
+
g(T, {
|
|
558
|
+
for: `checkbox-${e.field.name}-${n.value}`,
|
|
556
559
|
class: "font-normal"
|
|
557
560
|
}, {
|
|
558
|
-
default:
|
|
559
|
-
U(
|
|
561
|
+
default: c(() => [
|
|
562
|
+
U(R(n.label), 1)
|
|
560
563
|
]),
|
|
561
564
|
_: 2
|
|
562
565
|
}, 1032, ["for"])
|
|
563
566
|
]))), 128))
|
|
564
567
|
]));
|
|
565
568
|
}
|
|
566
|
-
}),
|
|
569
|
+
}), Le = /* @__PURE__ */ y({
|
|
567
570
|
__name: "RadioGroupItem",
|
|
568
571
|
props: {
|
|
569
572
|
id: {},
|
|
@@ -576,17 +579,17 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
576
579
|
class: {}
|
|
577
580
|
},
|
|
578
581
|
setup(e) {
|
|
579
|
-
const l = e, i =
|
|
580
|
-
const { class:
|
|
581
|
-
return
|
|
582
|
-
}),
|
|
583
|
-
return (
|
|
584
|
-
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)
|
|
585
588
|
}), {
|
|
586
|
-
default:
|
|
587
|
-
|
|
588
|
-
default:
|
|
589
|
-
|
|
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" })
|
|
590
593
|
]),
|
|
591
594
|
_: 1
|
|
592
595
|
})
|
|
@@ -594,7 +597,7 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
594
597
|
_: 1
|
|
595
598
|
}, 16, ["class"]));
|
|
596
599
|
}
|
|
597
|
-
}),
|
|
600
|
+
}), He = /* @__PURE__ */ y({
|
|
598
601
|
__name: "RadioGroup",
|
|
599
602
|
props: {
|
|
600
603
|
modelValue: {},
|
|
@@ -611,20 +614,20 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
611
614
|
},
|
|
612
615
|
emits: ["update:modelValue"],
|
|
613
616
|
setup(e, { emit: l }) {
|
|
614
|
-
const i = e,
|
|
615
|
-
const { class: r, ...
|
|
616
|
-
return
|
|
617
|
-
}),
|
|
618
|
-
return (r,
|
|
619
|
-
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)
|
|
620
623
|
}), {
|
|
621
|
-
default:
|
|
624
|
+
default: c(() => [
|
|
622
625
|
q(r.$slots, "default")
|
|
623
626
|
]),
|
|
624
627
|
_: 3
|
|
625
628
|
}, 16, ["class"]));
|
|
626
629
|
}
|
|
627
|
-
}),
|
|
630
|
+
}), Ke = /* @__PURE__ */ y({
|
|
628
631
|
__name: "RadioRenderer",
|
|
629
632
|
props: {
|
|
630
633
|
field: {},
|
|
@@ -637,37 +640,37 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
637
640
|
emits: ["update:modelValue"],
|
|
638
641
|
setup(e, { emit: l }) {
|
|
639
642
|
const i = l;
|
|
640
|
-
return (
|
|
643
|
+
return (s, t) => (d(), x(He, {
|
|
641
644
|
class: "flex flex-wrap gap-4",
|
|
642
645
|
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
643
646
|
name: e.field.name,
|
|
644
|
-
|
|
645
|
-
"onUpdate:modelValue":
|
|
647
|
+
"model-value": e.modelValue != null ? String(e.modelValue) : "",
|
|
648
|
+
"onUpdate:modelValue": t[0] || (t[0] = (a) => i("update:modelValue", a))
|
|
646
649
|
}, {
|
|
647
|
-
default:
|
|
648
|
-
(d(!0),
|
|
649
|
-
key:
|
|
650
|
+
default: c(() => [
|
|
651
|
+
(d(!0), h(N, null, E(e.field.options, (a) => (d(), h("div", {
|
|
652
|
+
key: a.value,
|
|
650
653
|
class: "flex items-center space-x-2"
|
|
651
654
|
}, [
|
|
652
|
-
|
|
653
|
-
id: `radio-${e.field.name}-${
|
|
654
|
-
value: String(
|
|
655
|
+
g(Le, {
|
|
656
|
+
id: `radio-${e.field.name}-${a.value}`,
|
|
657
|
+
value: String(a.value)
|
|
655
658
|
}, null, 8, ["id", "value"]),
|
|
656
|
-
|
|
657
|
-
for: `radio-${e.field.name}-${
|
|
659
|
+
g(T, {
|
|
660
|
+
for: `radio-${e.field.name}-${a.value}`,
|
|
658
661
|
class: "font-normal"
|
|
659
662
|
}, {
|
|
660
|
-
default:
|
|
661
|
-
U(
|
|
663
|
+
default: c(() => [
|
|
664
|
+
U(R(a.label), 1)
|
|
662
665
|
]),
|
|
663
666
|
_: 2
|
|
664
667
|
}, 1032, ["for"])
|
|
665
668
|
]))), 128))
|
|
666
669
|
]),
|
|
667
670
|
_: 1
|
|
668
|
-
}, 8, ["disabled", "name", "
|
|
671
|
+
}, 8, ["disabled", "name", "model-value"]));
|
|
669
672
|
}
|
|
670
|
-
}),
|
|
673
|
+
}), We = /* @__PURE__ */ y({
|
|
671
674
|
__name: "DateRenderer",
|
|
672
675
|
props: {
|
|
673
676
|
field: {},
|
|
@@ -680,21 +683,21 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
680
683
|
emits: ["update:modelValue", "blur"],
|
|
681
684
|
setup(e, { emit: l }) {
|
|
682
685
|
const i = l;
|
|
683
|
-
return (
|
|
686
|
+
return (s, t) => (d(), x(Q, {
|
|
684
687
|
id: e.fieldId,
|
|
685
688
|
type: "date",
|
|
686
|
-
|
|
689
|
+
"model-value": e.modelValue,
|
|
687
690
|
placeholder: e.field.placeholder,
|
|
688
691
|
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
689
692
|
name: e.field.name,
|
|
690
693
|
"aria-invalid": e.ariaInvalid,
|
|
691
694
|
"aria-required": e.ariaRequired,
|
|
692
695
|
"aria-describedby": e.ariaDescribedby,
|
|
693
|
-
"onUpdate:modelValue":
|
|
694
|
-
onBlur:
|
|
695
|
-
}, 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"]));
|
|
696
699
|
}
|
|
697
|
-
}),
|
|
700
|
+
}), Je = /* @__PURE__ */ y({
|
|
698
701
|
__name: "Switch",
|
|
699
702
|
props: {
|
|
700
703
|
defaultChecked: { type: Boolean },
|
|
@@ -710,19 +713,19 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
710
713
|
},
|
|
711
714
|
emits: ["update:checked"],
|
|
712
715
|
setup(e, { emit: l }) {
|
|
713
|
-
const i = e,
|
|
714
|
-
const { class: r, ...
|
|
715
|
-
return
|
|
716
|
-
}),
|
|
717
|
-
return (r,
|
|
718
|
-
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)(
|
|
719
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",
|
|
720
723
|
i.class
|
|
721
724
|
)
|
|
722
725
|
}), {
|
|
723
|
-
default:
|
|
724
|
-
|
|
725
|
-
class: D(o(
|
|
726
|
+
default: c(() => [
|
|
727
|
+
g(o(ke), {
|
|
728
|
+
class: D(o(B)(
|
|
726
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"
|
|
727
730
|
))
|
|
728
731
|
}, null, 8, ["class"])
|
|
@@ -730,7 +733,7 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
730
733
|
_: 1
|
|
731
734
|
}, 16, ["class"]));
|
|
732
735
|
}
|
|
733
|
-
}),
|
|
736
|
+
}), Qe = { class: "flex items-center space-x-2" }, Xe = /* @__PURE__ */ y({
|
|
734
737
|
__name: "SwitchRenderer",
|
|
735
738
|
props: {
|
|
736
739
|
field: {},
|
|
@@ -743,15 +746,15 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
743
746
|
emits: ["update:modelValue", "blur"],
|
|
744
747
|
setup(e, { emit: l }) {
|
|
745
748
|
const i = l;
|
|
746
|
-
return (
|
|
747
|
-
|
|
749
|
+
return (s, t) => (d(), h("div", Qe, [
|
|
750
|
+
g(Je, {
|
|
748
751
|
id: e.fieldId,
|
|
749
752
|
checked: e.modelValue,
|
|
750
753
|
disabled: typeof e.field.disabled == "boolean" ? e.field.disabled : void 0,
|
|
751
754
|
"aria-invalid": e.ariaInvalid,
|
|
752
755
|
"aria-required": e.ariaRequired,
|
|
753
756
|
"aria-describedby": e.ariaDescribedby,
|
|
754
|
-
"onUpdate:checked":
|
|
757
|
+
"onUpdate:checked": t[0] || (t[0] = (a) => i("update:modelValue", a))
|
|
755
758
|
}, null, 8, ["id", "checked", "disabled", "aria-invalid", "aria-required", "aria-describedby"])
|
|
756
759
|
]));
|
|
757
760
|
}
|
|
@@ -760,16 +763,16 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
760
763
|
number: P,
|
|
761
764
|
password: P,
|
|
762
765
|
email: P,
|
|
763
|
-
textarea:
|
|
764
|
-
select:
|
|
765
|
-
checkbox:
|
|
766
|
-
radio:
|
|
767
|
-
date:
|
|
768
|
-
switch:
|
|
769
|
-
},
|
|
766
|
+
textarea: Ne,
|
|
767
|
+
select: ze,
|
|
768
|
+
checkbox: Ge,
|
|
769
|
+
radio: Ke,
|
|
770
|
+
date: We,
|
|
771
|
+
switch: Xe
|
|
772
|
+
}, Ye = {
|
|
770
773
|
key: 0,
|
|
771
774
|
class: "text-destructive"
|
|
772
|
-
},
|
|
775
|
+
}, Ze = ["id"], _e = ["id"], et = /* @__PURE__ */ y({
|
|
773
776
|
__name: "FormFieldRenderer",
|
|
774
777
|
props: {
|
|
775
778
|
field: {},
|
|
@@ -779,74 +782,74 @@ const Ce = ["type", "value"], Q = /* @__PURE__ */ p({
|
|
|
779
782
|
},
|
|
780
783
|
emits: ["update:modelValue", "blur"],
|
|
781
784
|
setup(e, { emit: l }) {
|
|
782
|
-
const i = e,
|
|
783
|
-
var
|
|
784
|
-
return (
|
|
785
|
-
}), u =
|
|
786
|
-
const
|
|
787
|
-
return i.field.description &&
|
|
788
|
-
}),
|
|
785
|
+
const i = e, s = l, t = V(() => `field-${i.field.name}`), a = V(() => `${t.value}-description`), r = V(() => `${t.value}-error`), n = V(() => {
|
|
786
|
+
var f;
|
|
787
|
+
return (f = i.field.validations) == null ? void 0 : f.some((v) => v.type === "required");
|
|
788
|
+
}), u = V(() => {
|
|
789
|
+
const f = [];
|
|
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(
|
|
789
792
|
() => i.componentMap ? { ...H, ...i.componentMap } : H
|
|
790
|
-
),
|
|
791
|
-
() =>
|
|
793
|
+
), m = V(
|
|
794
|
+
() => w.value[i.field.type] ?? P
|
|
792
795
|
);
|
|
793
|
-
return (
|
|
796
|
+
return (f, v) => (d(), h("div", {
|
|
794
797
|
class: D(["space-y-2", e.field.className])
|
|
795
798
|
}, [
|
|
796
|
-
e.field.label ? (d(),
|
|
799
|
+
e.field.label ? (d(), x(T, {
|
|
797
800
|
key: 0,
|
|
798
|
-
for:
|
|
799
|
-
class: D(
|
|
801
|
+
for: t.value,
|
|
802
|
+
class: D(n.value ? "flex items-center gap-1" : "")
|
|
800
803
|
}, {
|
|
801
|
-
default:
|
|
802
|
-
U(
|
|
803
|
-
|
|
804
|
+
default: c(() => [
|
|
805
|
+
U(R(e.field.label) + " ", 1),
|
|
806
|
+
n.value ? (d(), h("span", Ye, "*")) : C("", !0)
|
|
804
807
|
]),
|
|
805
808
|
_: 1
|
|
806
|
-
}, 8, ["for", "class"])) :
|
|
807
|
-
(d(),
|
|
809
|
+
}, 8, ["for", "class"])) : C("", !0),
|
|
810
|
+
(d(), x(_(m.value), {
|
|
808
811
|
field: e.field,
|
|
809
|
-
|
|
810
|
-
|
|
812
|
+
"field-id": t.value,
|
|
813
|
+
"model-value": e.modelValue,
|
|
811
814
|
"aria-invalid": !!e.error,
|
|
812
|
-
"aria-required":
|
|
815
|
+
"aria-required": n.value,
|
|
813
816
|
"aria-describedby": u.value,
|
|
814
|
-
"onUpdate:modelValue":
|
|
815
|
-
onBlur:
|
|
816
|
-
}, null, 40, ["field", "
|
|
817
|
-
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", {
|
|
818
821
|
key: 1,
|
|
819
|
-
id:
|
|
822
|
+
id: a.value,
|
|
820
823
|
class: "text-[0.8rem] text-muted-foreground"
|
|
821
|
-
},
|
|
822
|
-
e.error ? (d(),
|
|
824
|
+
}, R(e.field.description), 9, Ze)) : C("", !0),
|
|
825
|
+
e.error ? (d(), h("p", {
|
|
823
826
|
key: 2,
|
|
824
827
|
id: r.value,
|
|
825
828
|
class: "text-[0.8rem] font-medium text-destructive"
|
|
826
|
-
},
|
|
829
|
+
}, R(e.error), 9, _e)) : C("", !0)
|
|
827
830
|
], 2));
|
|
828
831
|
}
|
|
829
832
|
});
|
|
830
|
-
function
|
|
831
|
-
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) => {
|
|
832
835
|
i.value = u;
|
|
833
836
|
});
|
|
834
|
-
return
|
|
835
|
-
|
|
837
|
+
return te(() => {
|
|
838
|
+
s();
|
|
836
839
|
}), {
|
|
837
|
-
|
|
840
|
+
engine: l,
|
|
838
841
|
state: i,
|
|
839
842
|
// This is a Ref
|
|
840
|
-
setValue: async (u,
|
|
841
|
-
await l.
|
|
843
|
+
setValue: async (u, w) => {
|
|
844
|
+
await l.setFieldValue(u, w);
|
|
842
845
|
},
|
|
843
846
|
getValue: (u) => M(i.value.values, u),
|
|
844
847
|
validate: async () => {
|
|
845
|
-
const { hasError: u, state:
|
|
846
|
-
return { hasError: u, values:
|
|
848
|
+
const { hasError: u, state: w } = await l.runSubmitValidation();
|
|
849
|
+
return { hasError: u, values: w.values };
|
|
847
850
|
},
|
|
848
851
|
reset: () => {
|
|
849
|
-
l.setState({
|
|
852
|
+
l.store.setState({
|
|
850
853
|
values: {},
|
|
851
854
|
errors: {},
|
|
852
855
|
isSubmitting: !1
|
|
@@ -854,16 +857,16 @@ function et({ schema: e }) {
|
|
|
854
857
|
}
|
|
855
858
|
};
|
|
856
859
|
}
|
|
857
|
-
const
|
|
860
|
+
const at = {
|
|
858
861
|
key: 0,
|
|
859
862
|
class: "space-y-1"
|
|
860
|
-
},
|
|
863
|
+
}, lt = {
|
|
861
864
|
key: 0,
|
|
862
865
|
class: "text-2xl font-bold tracking-tight"
|
|
863
|
-
},
|
|
866
|
+
}, it = {
|
|
864
867
|
key: 1,
|
|
865
868
|
class: "text-muted-foreground"
|
|
866
|
-
},
|
|
869
|
+
}, st = { class: "space-y-4" }, nt = ["disabled"], mt = /* @__PURE__ */ y({
|
|
867
870
|
__name: "DynamicForm",
|
|
868
871
|
props: {
|
|
869
872
|
schema: {},
|
|
@@ -872,58 +875,58 @@ const tt = {
|
|
|
872
875
|
},
|
|
873
876
|
emits: ["submit"],
|
|
874
877
|
setup(e, { emit: l }) {
|
|
875
|
-
const i = e,
|
|
876
|
-
await r.
|
|
877
|
-
},
|
|
878
|
-
await r.
|
|
879
|
-
},
|
|
880
|
-
const
|
|
881
|
-
return { ...
|
|
882
|
-
},
|
|
883
|
-
const { hasError:
|
|
884
|
-
if (
|
|
885
|
-
const
|
|
886
|
-
if (
|
|
887
|
-
const
|
|
888
|
-
|
|
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" });
|
|
889
892
|
}
|
|
890
893
|
return;
|
|
891
894
|
}
|
|
892
|
-
await
|
|
893
|
-
},
|
|
894
|
-
return (
|
|
895
|
+
await s("submit", F);
|
|
896
|
+
}, S = V(() => n.value.validatingFields.length > 0);
|
|
897
|
+
return (p, F) => (d(), h("form", {
|
|
895
898
|
class: D(["space-y-6", e.className]),
|
|
896
|
-
onSubmit:
|
|
899
|
+
onSubmit: ae(v, ["prevent"])
|
|
897
900
|
}, [
|
|
898
|
-
e.schema.title || e.schema.description ? (d(),
|
|
899
|
-
e.schema.title ? (d(),
|
|
900
|
-
e.schema.description ? (d(),
|
|
901
|
-
])) :
|
|
902
|
-
|
|
903
|
-
(d(!0),
|
|
904
|
-
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
|
|
905
908
|
}, [
|
|
906
|
-
|
|
909
|
+
m(b) ? C("", !0) : (d(), x(et, {
|
|
907
910
|
key: 0,
|
|
908
|
-
field:
|
|
909
|
-
"model-value": o(M)(o(
|
|
910
|
-
error: o(
|
|
911
|
-
"onUpdate:modelValue": (
|
|
912
|
-
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)
|
|
913
916
|
}, null, 8, ["field", "model-value", "error", "onUpdate:modelValue", "onBlur"]))
|
|
914
917
|
], 64))), 128))
|
|
915
918
|
]),
|
|
916
|
-
|
|
919
|
+
z("button", {
|
|
917
920
|
type: "submit",
|
|
918
|
-
disabled: o(
|
|
921
|
+
disabled: o(n).isSubmitting || S.value,
|
|
919
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"
|
|
920
|
-
},
|
|
923
|
+
}, R(o(n).isSubmitting ? "Submitting..." : S.value ? "Validating..." : e.schema.submitButtonText || "Submit"), 9, nt)
|
|
921
924
|
], 34));
|
|
922
925
|
}
|
|
923
926
|
});
|
|
924
927
|
export {
|
|
925
|
-
|
|
926
|
-
|
|
928
|
+
mt as DynamicForm,
|
|
929
|
+
et as FormFieldRenderer,
|
|
927
930
|
H as defaultComponentMap,
|
|
928
|
-
|
|
931
|
+
tt as useForm
|
|
929
932
|
};
|