@anri1214/dynamic-forms-mui 0.1.7
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/LICENSE +22 -0
- package/README.md +403 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +554 -0
- package/dist/index.js +1831 -0
- package/package.json +67 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1831 @@
|
|
|
1
|
+
import { jsx as d, jsxs as D, Fragment as Pe } from "react/jsx-runtime";
|
|
2
|
+
import * as Te from "react";
|
|
3
|
+
import { createContext as pe, useContext as he, useState as X, useRef as H, useId as le, useEffect as O, useMemo as G, useCallback as z, Component as $e } from "react";
|
|
4
|
+
import { TextField as ge, InputLabel as ye, OutlinedInput as Oe, InputAdornment as ze, IconButton as ee, FormHelperText as L, FormControl as j, Select as Le, MenuItem as je, Autocomplete as Ne, FormControlLabel as oe, Checkbox as _e, Switch as Ue, FormLabel as Me, RadioGroup as Be, Radio as We, Box as V, Typography as I, Skeleton as Ke, Alert as be, Button as Ze } from "@mui/material";
|
|
5
|
+
import { NumberField as B } from "@base-ui/react/number-field";
|
|
6
|
+
import Ge from "@mui/icons-material/KeyboardArrowUp";
|
|
7
|
+
import He from "@mui/icons-material/KeyboardArrowDown";
|
|
8
|
+
import { DatePicker as Ye } from "@mui/x-date-pickers/DatePicker";
|
|
9
|
+
import { DateTimePicker as Je } from "@mui/x-date-pickers/DateTimePicker";
|
|
10
|
+
import { CloudUpload as Qe, Close as Xe } from "@mui/icons-material";
|
|
11
|
+
import { useFormContext as k, useWatch as xe, get as te, set as Q, appendErrors as ve, Controller as T, useForm as et, FormProvider as tt } from "react-hook-form";
|
|
12
|
+
import { z as b } from "zod";
|
|
13
|
+
import { useQuery as rt } from "@tanstack/react-query";
|
|
14
|
+
const ae = pe(null);
|
|
15
|
+
function R() {
|
|
16
|
+
const e = he(ae);
|
|
17
|
+
if (!e)
|
|
18
|
+
throw new Error(
|
|
19
|
+
"useDynamicFormsContext must be used within a DynamicFormsProvider. Wrap your app (or the part that uses DynamicForm) with <DynamicFormsProvider>."
|
|
20
|
+
);
|
|
21
|
+
return e;
|
|
22
|
+
}
|
|
23
|
+
function nt({ variant: e = "outlined", ...t }) {
|
|
24
|
+
return /* @__PURE__ */ d(ge, { variant: e, fullWidth: !0, ...t });
|
|
25
|
+
}
|
|
26
|
+
function Fe(e) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
Fe.muiName = "Input";
|
|
30
|
+
function st({
|
|
31
|
+
label: e,
|
|
32
|
+
error: t,
|
|
33
|
+
helperText: r,
|
|
34
|
+
placeholder: n,
|
|
35
|
+
size: o = "medium",
|
|
36
|
+
ref: i,
|
|
37
|
+
...s
|
|
38
|
+
}) {
|
|
39
|
+
const l = Te.useId(), u = o === "small" ? "small" : "medium";
|
|
40
|
+
return /* @__PURE__ */ D(
|
|
41
|
+
B.Root,
|
|
42
|
+
{
|
|
43
|
+
...s,
|
|
44
|
+
render: (a, c) => /* @__PURE__ */ d(
|
|
45
|
+
j,
|
|
46
|
+
{
|
|
47
|
+
size: o,
|
|
48
|
+
ref: a.ref,
|
|
49
|
+
disabled: c.disabled,
|
|
50
|
+
required: c.required,
|
|
51
|
+
error: t,
|
|
52
|
+
variant: "outlined",
|
|
53
|
+
fullWidth: !0,
|
|
54
|
+
children: a.children
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ d(Fe, { ...s }),
|
|
59
|
+
/* @__PURE__ */ d(ye, { htmlFor: l, children: e }),
|
|
60
|
+
/* @__PURE__ */ d(
|
|
61
|
+
B.Input,
|
|
62
|
+
{
|
|
63
|
+
id: l,
|
|
64
|
+
render: (a, c) => /* @__PURE__ */ d(
|
|
65
|
+
Oe,
|
|
66
|
+
{
|
|
67
|
+
label: e,
|
|
68
|
+
placeholder: n,
|
|
69
|
+
size: o,
|
|
70
|
+
inputRef: i || a.ref,
|
|
71
|
+
value: c.inputValue,
|
|
72
|
+
onBlur: a.onBlur,
|
|
73
|
+
onChange: a.onChange,
|
|
74
|
+
onKeyUp: a.onKeyUp,
|
|
75
|
+
onKeyDown: a.onKeyDown,
|
|
76
|
+
onFocus: a.onFocus,
|
|
77
|
+
slotProps: {
|
|
78
|
+
input: a
|
|
79
|
+
},
|
|
80
|
+
endAdornment: /* @__PURE__ */ D(
|
|
81
|
+
ze,
|
|
82
|
+
{
|
|
83
|
+
position: "end",
|
|
84
|
+
sx: {
|
|
85
|
+
flexDirection: "column",
|
|
86
|
+
maxHeight: "unset",
|
|
87
|
+
alignSelf: "stretch",
|
|
88
|
+
borderLeft: "1px solid",
|
|
89
|
+
borderColor: "divider",
|
|
90
|
+
ml: 0,
|
|
91
|
+
"& button": {
|
|
92
|
+
py: 0,
|
|
93
|
+
flex: 1,
|
|
94
|
+
borderRadius: 0.5
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ d(
|
|
99
|
+
B.Increment,
|
|
100
|
+
{
|
|
101
|
+
render: /* @__PURE__ */ d(ee, { size: u, "aria-label": "Increase" }),
|
|
102
|
+
children: /* @__PURE__ */ d(
|
|
103
|
+
Ge,
|
|
104
|
+
{
|
|
105
|
+
fontSize: u,
|
|
106
|
+
sx: { transform: "translateY(2px)" }
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
/* @__PURE__ */ d(
|
|
112
|
+
B.Decrement,
|
|
113
|
+
{
|
|
114
|
+
render: /* @__PURE__ */ d(ee, { size: u, "aria-label": "Decrease" }),
|
|
115
|
+
children: /* @__PURE__ */ d(
|
|
116
|
+
He,
|
|
117
|
+
{
|
|
118
|
+
fontSize: u,
|
|
119
|
+
sx: { transform: "translateY(-2px)" }
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
sx: { pr: 0 }
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
r && /* @__PURE__ */ d(L, { sx: { ml: 0 }, children: r })
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
function it({ options: e, onChange: t, ref: r, size: n, ...o }) {
|
|
138
|
+
return /* @__PURE__ */ d(
|
|
139
|
+
Le,
|
|
140
|
+
{
|
|
141
|
+
...o,
|
|
142
|
+
size: n,
|
|
143
|
+
onChange: t,
|
|
144
|
+
children: e.map((i) => /* @__PURE__ */ d(je, { value: i.value, disabled: i.disabled, children: i.label }, i.value))
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
function ot({
|
|
149
|
+
label: e,
|
|
150
|
+
placeholder: t,
|
|
151
|
+
error: r,
|
|
152
|
+
helperText: n,
|
|
153
|
+
required: o,
|
|
154
|
+
size: i,
|
|
155
|
+
...s
|
|
156
|
+
}) {
|
|
157
|
+
return /* @__PURE__ */ d(
|
|
158
|
+
Ne,
|
|
159
|
+
{
|
|
160
|
+
...s,
|
|
161
|
+
size: i,
|
|
162
|
+
getOptionLabel: (l) => typeof l == "string" ? l : l.label,
|
|
163
|
+
renderInput: (l) => /* @__PURE__ */ d(
|
|
164
|
+
ge,
|
|
165
|
+
{
|
|
166
|
+
...l,
|
|
167
|
+
label: e,
|
|
168
|
+
placeholder: t,
|
|
169
|
+
error: r,
|
|
170
|
+
helperText: n,
|
|
171
|
+
required: o
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
function at({
|
|
178
|
+
label: e,
|
|
179
|
+
error: t,
|
|
180
|
+
helperText: r,
|
|
181
|
+
size: n,
|
|
182
|
+
ref: o,
|
|
183
|
+
...i
|
|
184
|
+
}) {
|
|
185
|
+
return /* @__PURE__ */ D(j, { error: t, size: n, children: [
|
|
186
|
+
/* @__PURE__ */ d(oe, { control: /* @__PURE__ */ d(_e, { ...i, size: n }), label: e }),
|
|
187
|
+
r && /* @__PURE__ */ d(L, { children: r })
|
|
188
|
+
] });
|
|
189
|
+
}
|
|
190
|
+
function lt({
|
|
191
|
+
label: e,
|
|
192
|
+
error: t,
|
|
193
|
+
helperText: r,
|
|
194
|
+
size: n,
|
|
195
|
+
ref: o,
|
|
196
|
+
...i
|
|
197
|
+
}) {
|
|
198
|
+
return /* @__PURE__ */ D(j, { error: t, size: n, children: [
|
|
199
|
+
/* @__PURE__ */ d(oe, { control: /* @__PURE__ */ d(Ue, { ...i, size: n }), label: e }),
|
|
200
|
+
r && /* @__PURE__ */ d(L, { children: r })
|
|
201
|
+
] });
|
|
202
|
+
}
|
|
203
|
+
function ut({
|
|
204
|
+
label: e,
|
|
205
|
+
options: t,
|
|
206
|
+
error: r,
|
|
207
|
+
helperText: n,
|
|
208
|
+
disabled: o,
|
|
209
|
+
required: i,
|
|
210
|
+
size: s,
|
|
211
|
+
...l
|
|
212
|
+
}) {
|
|
213
|
+
return /* @__PURE__ */ D(j, { component: "fieldset", error: r, disabled: o, required: i, size: s, children: [
|
|
214
|
+
e && /* @__PURE__ */ d(Me, { component: "legend", children: e }),
|
|
215
|
+
/* @__PURE__ */ d(Be, { ...l, children: t.map((u) => /* @__PURE__ */ d(
|
|
216
|
+
oe,
|
|
217
|
+
{
|
|
218
|
+
value: u.value,
|
|
219
|
+
control: /* @__PURE__ */ d(We, { size: s }),
|
|
220
|
+
label: u.label
|
|
221
|
+
},
|
|
222
|
+
u.value
|
|
223
|
+
)) }),
|
|
224
|
+
n && /* @__PURE__ */ d(L, { children: n })
|
|
225
|
+
] });
|
|
226
|
+
}
|
|
227
|
+
function re({
|
|
228
|
+
includeTime: e,
|
|
229
|
+
error: t,
|
|
230
|
+
helperText: r,
|
|
231
|
+
required: n,
|
|
232
|
+
format: o,
|
|
233
|
+
size: i,
|
|
234
|
+
ref: s,
|
|
235
|
+
...l
|
|
236
|
+
}) {
|
|
237
|
+
return /* @__PURE__ */ d(
|
|
238
|
+
e ? Je : Ye,
|
|
239
|
+
{
|
|
240
|
+
...l,
|
|
241
|
+
format: o,
|
|
242
|
+
inputRef: s,
|
|
243
|
+
slotProps: {
|
|
244
|
+
textField: {
|
|
245
|
+
error: t,
|
|
246
|
+
helperText: r,
|
|
247
|
+
required: n,
|
|
248
|
+
fullWidth: !0,
|
|
249
|
+
size: i
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
function ct({
|
|
256
|
+
value: e,
|
|
257
|
+
onChange: t,
|
|
258
|
+
label: r,
|
|
259
|
+
disabled: n,
|
|
260
|
+
error: o,
|
|
261
|
+
helperText: i,
|
|
262
|
+
minDate: s,
|
|
263
|
+
maxDate: l,
|
|
264
|
+
required: u,
|
|
265
|
+
includeTime: a,
|
|
266
|
+
format: c,
|
|
267
|
+
size: f
|
|
268
|
+
}) {
|
|
269
|
+
const p = (x) => {
|
|
270
|
+
t?.({ start: x, end: e?.end ?? null });
|
|
271
|
+
}, m = (x) => {
|
|
272
|
+
t?.({ start: e?.start ?? null, end: x });
|
|
273
|
+
}, y = a ? "Start Date/Time" : "Start Date", g = a ? "End Date/Time" : "End Date";
|
|
274
|
+
return /* @__PURE__ */ D(V, { children: [
|
|
275
|
+
r && /* @__PURE__ */ D(I, { variant: "body2", sx: { mb: 1, color: o ? "error.main" : "text.secondary" }, children: [
|
|
276
|
+
r,
|
|
277
|
+
u && /* @__PURE__ */ d("span", { style: { color: "inherit" }, children: " *" })
|
|
278
|
+
] }),
|
|
279
|
+
/* @__PURE__ */ D(V, { sx: { display: "flex", gap: 2 }, children: [
|
|
280
|
+
/* @__PURE__ */ d(
|
|
281
|
+
re,
|
|
282
|
+
{
|
|
283
|
+
label: y,
|
|
284
|
+
includeTime: a,
|
|
285
|
+
format: c,
|
|
286
|
+
value: e?.start ?? null,
|
|
287
|
+
onChange: p,
|
|
288
|
+
disabled: n,
|
|
289
|
+
minDate: s,
|
|
290
|
+
maxDate: e?.end ?? l,
|
|
291
|
+
error: o,
|
|
292
|
+
size: f
|
|
293
|
+
}
|
|
294
|
+
),
|
|
295
|
+
/* @__PURE__ */ d(
|
|
296
|
+
re,
|
|
297
|
+
{
|
|
298
|
+
label: g,
|
|
299
|
+
includeTime: a,
|
|
300
|
+
format: c,
|
|
301
|
+
value: e?.end ?? null,
|
|
302
|
+
onChange: m,
|
|
303
|
+
disabled: n,
|
|
304
|
+
minDate: e?.start ?? s,
|
|
305
|
+
maxDate: l,
|
|
306
|
+
error: o,
|
|
307
|
+
size: f
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
] }),
|
|
311
|
+
i && /* @__PURE__ */ d(I, { variant: "caption", sx: { mt: 0.5, ml: 1.75, color: o ? "error.main" : "text.secondary" }, children: i })
|
|
312
|
+
] });
|
|
313
|
+
}
|
|
314
|
+
function dt(e) {
|
|
315
|
+
if (e === 0) return "0 KB";
|
|
316
|
+
const t = 1024, r = t * 1024, n = r * 1024;
|
|
317
|
+
return e >= n ? `${(e / n).toFixed(2)} GB` : e >= r ? `${(e / r).toFixed(2)} MB` : `${(e / t).toFixed(2)} KB`;
|
|
318
|
+
}
|
|
319
|
+
function ft({
|
|
320
|
+
value: e,
|
|
321
|
+
onChange: t,
|
|
322
|
+
onBlur: r,
|
|
323
|
+
multiple: n,
|
|
324
|
+
accept: o,
|
|
325
|
+
label: i,
|
|
326
|
+
disabled: s,
|
|
327
|
+
error: l,
|
|
328
|
+
helperText: u,
|
|
329
|
+
required: a,
|
|
330
|
+
ref: c
|
|
331
|
+
}) {
|
|
332
|
+
const [f, p] = X(!1), m = H(null), y = le(), g = le(), x = (h) => {
|
|
333
|
+
h.preventDefault(), h.stopPropagation(), s || p(!0);
|
|
334
|
+
}, F = (h) => {
|
|
335
|
+
h.preventDefault(), h.stopPropagation(), p(!1);
|
|
336
|
+
}, q = (h) => {
|
|
337
|
+
h.preventDefault(), h.stopPropagation();
|
|
338
|
+
}, S = (h, C) => {
|
|
339
|
+
const $ = new Set(h.map((E) => `${E.name}-${E.size}`));
|
|
340
|
+
return C.filter((E) => !$.has(`${E.name}-${E.size}`));
|
|
341
|
+
}, v = (h) => {
|
|
342
|
+
if (h.preventDefault(), h.stopPropagation(), p(!1), s) return;
|
|
343
|
+
const C = Array.from(h.dataTransfer.files);
|
|
344
|
+
if (C.length !== 0)
|
|
345
|
+
if (n) {
|
|
346
|
+
const $ = Array.isArray(e) ? e : [], E = S($, C);
|
|
347
|
+
t?.([...$, ...E]);
|
|
348
|
+
} else
|
|
349
|
+
t?.(C[0] || null);
|
|
350
|
+
}, w = (h) => {
|
|
351
|
+
const C = h.target.files;
|
|
352
|
+
if (!C || C.length === 0) return;
|
|
353
|
+
const $ = Array.from(C);
|
|
354
|
+
if (n) {
|
|
355
|
+
const E = Array.isArray(e) ? e : [], Ve = S(E, $);
|
|
356
|
+
t?.([...E, ...Ve]);
|
|
357
|
+
} else
|
|
358
|
+
t?.($[0] || null);
|
|
359
|
+
m.current && (m.current.value = "");
|
|
360
|
+
}, A = () => {
|
|
361
|
+
t?.(null), m.current && (m.current.value = "");
|
|
362
|
+
}, N = (h) => {
|
|
363
|
+
if (!Array.isArray(e)) return;
|
|
364
|
+
const C = e.filter(($, E) => E !== h);
|
|
365
|
+
t?.(C.length > 0 ? C : null), C.length === 0 && m.current && (m.current.value = "");
|
|
366
|
+
}, P = (h) => {
|
|
367
|
+
s || (h.key === "Enter" || h.key === " ") && (h.preventDefault(), m.current?.click());
|
|
368
|
+
}, M = e ? Array.isArray(e) ? e : [e] : [], Ae = () => l ? "error.main" : f ? "primary.main" : "divider", Ee = () => s ? "divider" : l ? "error.main" : "primary.main";
|
|
369
|
+
return /* @__PURE__ */ D(j, { fullWidth: !0, error: l, children: [
|
|
370
|
+
i && /* @__PURE__ */ D(
|
|
371
|
+
I,
|
|
372
|
+
{
|
|
373
|
+
component: "label",
|
|
374
|
+
htmlFor: y,
|
|
375
|
+
variant: "body2",
|
|
376
|
+
sx: { mb: 1, display: "block", fontWeight: 500 },
|
|
377
|
+
children: [
|
|
378
|
+
i,
|
|
379
|
+
a && /* @__PURE__ */ d(I, { component: "span", sx: { ml: 0.5 }, children: "*" })
|
|
380
|
+
]
|
|
381
|
+
}
|
|
382
|
+
),
|
|
383
|
+
/* @__PURE__ */ D(
|
|
384
|
+
V,
|
|
385
|
+
{
|
|
386
|
+
role: "button",
|
|
387
|
+
tabIndex: s ? -1 : 0,
|
|
388
|
+
"aria-label": `Upload ${n ? "files" : "file"}${i ? ` for ${i}` : ""}`,
|
|
389
|
+
"aria-disabled": s,
|
|
390
|
+
"aria-invalid": l,
|
|
391
|
+
"aria-required": a,
|
|
392
|
+
"aria-describedby": u ? g : void 0,
|
|
393
|
+
onDragEnter: x,
|
|
394
|
+
onDragOver: q,
|
|
395
|
+
onDragLeave: F,
|
|
396
|
+
onDrop: v,
|
|
397
|
+
onKeyDown: P,
|
|
398
|
+
sx: {
|
|
399
|
+
border: 2,
|
|
400
|
+
borderStyle: "dashed",
|
|
401
|
+
borderColor: Ae(),
|
|
402
|
+
borderRadius: 1,
|
|
403
|
+
p: 3,
|
|
404
|
+
textAlign: "center",
|
|
405
|
+
bgcolor: f ? "action.hover" : "background.paper",
|
|
406
|
+
cursor: s ? "not-allowed" : "pointer",
|
|
407
|
+
transition: "all 0.2s ease-in-out",
|
|
408
|
+
"&:hover": {
|
|
409
|
+
borderColor: Ee(),
|
|
410
|
+
bgcolor: s ? "background.paper" : "action.hover"
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
onClick: () => !s && m.current?.click(),
|
|
414
|
+
children: [
|
|
415
|
+
/* @__PURE__ */ d(Qe, { sx: { fontSize: 48, color: l ? "error.main" : "primary.main", mb: 1 } }),
|
|
416
|
+
/* @__PURE__ */ D(I, { variant: "body1", color: s ? "text.disabled" : "text.primary", children: [
|
|
417
|
+
"Drag & drop ",
|
|
418
|
+
n ? "files" : "a file",
|
|
419
|
+
" or click to select"
|
|
420
|
+
] }),
|
|
421
|
+
o && /* @__PURE__ */ D(I, { variant: "caption", color: "text.secondary", sx: { mt: 0.5, display: "block" }, children: [
|
|
422
|
+
"Accepted types: ",
|
|
423
|
+
o
|
|
424
|
+
] })
|
|
425
|
+
]
|
|
426
|
+
}
|
|
427
|
+
),
|
|
428
|
+
/* @__PURE__ */ d(
|
|
429
|
+
"input",
|
|
430
|
+
{
|
|
431
|
+
id: y,
|
|
432
|
+
ref: (h) => {
|
|
433
|
+
m.current = h, typeof c == "function" ? c(h) : c && (c.current = h);
|
|
434
|
+
},
|
|
435
|
+
type: "file",
|
|
436
|
+
accept: o,
|
|
437
|
+
multiple: n,
|
|
438
|
+
onChange: w,
|
|
439
|
+
onBlur: r,
|
|
440
|
+
style: { display: "none" },
|
|
441
|
+
disabled: s,
|
|
442
|
+
required: a,
|
|
443
|
+
"aria-invalid": l,
|
|
444
|
+
"aria-required": a,
|
|
445
|
+
"aria-describedby": u ? g : void 0
|
|
446
|
+
}
|
|
447
|
+
),
|
|
448
|
+
M.length > 0 && /* @__PURE__ */ d(V, { sx: { mt: 2 }, role: "status", "aria-live": "polite", "aria-label": `${M.length} ${M.length === 1 ? "file" : "files"} selected`, children: M.map((h, C) => /* @__PURE__ */ D(
|
|
449
|
+
V,
|
|
450
|
+
{
|
|
451
|
+
sx: {
|
|
452
|
+
display: "flex",
|
|
453
|
+
alignItems: "center",
|
|
454
|
+
justifyContent: "space-between",
|
|
455
|
+
p: 1.5,
|
|
456
|
+
mb: 1,
|
|
457
|
+
border: 1,
|
|
458
|
+
borderColor: "divider",
|
|
459
|
+
borderRadius: 1,
|
|
460
|
+
bgcolor: "background.paper",
|
|
461
|
+
"&:last-child": {
|
|
462
|
+
mb: 0
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
children: [
|
|
466
|
+
/* @__PURE__ */ D(V, { sx: { flex: 1, minWidth: 0 }, children: [
|
|
467
|
+
/* @__PURE__ */ d(
|
|
468
|
+
I,
|
|
469
|
+
{
|
|
470
|
+
variant: "body2",
|
|
471
|
+
sx: {
|
|
472
|
+
fontWeight: 500,
|
|
473
|
+
overflow: "hidden",
|
|
474
|
+
textOverflow: "ellipsis",
|
|
475
|
+
whiteSpace: "nowrap"
|
|
476
|
+
},
|
|
477
|
+
children: h.name
|
|
478
|
+
}
|
|
479
|
+
),
|
|
480
|
+
/* @__PURE__ */ d(I, { variant: "caption", color: "text.secondary", children: dt(h.size) })
|
|
481
|
+
] }),
|
|
482
|
+
/* @__PURE__ */ d(
|
|
483
|
+
ee,
|
|
484
|
+
{
|
|
485
|
+
size: "small",
|
|
486
|
+
onClick: ($) => {
|
|
487
|
+
$.stopPropagation(), n ? N(C) : A();
|
|
488
|
+
},
|
|
489
|
+
disabled: s,
|
|
490
|
+
"aria-label": `Remove ${h.name}`,
|
|
491
|
+
sx: { ml: 1 },
|
|
492
|
+
children: /* @__PURE__ */ d(Xe, { fontSize: "small" })
|
|
493
|
+
}
|
|
494
|
+
)
|
|
495
|
+
]
|
|
496
|
+
},
|
|
497
|
+
`${h.name}-${h.size}-${C}`
|
|
498
|
+
)) }),
|
|
499
|
+
u && /* @__PURE__ */ d(L, { id: g, children: u })
|
|
500
|
+
] });
|
|
501
|
+
}
|
|
502
|
+
function mt() {
|
|
503
|
+
return {
|
|
504
|
+
TextField: nt,
|
|
505
|
+
NumberField: st,
|
|
506
|
+
Select: it,
|
|
507
|
+
Autocomplete: ot,
|
|
508
|
+
Checkbox: at,
|
|
509
|
+
Switch: lt,
|
|
510
|
+
RadioGroup: ut,
|
|
511
|
+
DatePicker: re,
|
|
512
|
+
DateRangePicker: ct,
|
|
513
|
+
FileUpload: ft
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function pr({
|
|
517
|
+
apiClient: e,
|
|
518
|
+
components: t,
|
|
519
|
+
size: r,
|
|
520
|
+
sectionSlotProps: n,
|
|
521
|
+
onError: o,
|
|
522
|
+
children: i
|
|
523
|
+
}) {
|
|
524
|
+
const l = {
|
|
525
|
+
...mt(),
|
|
526
|
+
...t
|
|
527
|
+
};
|
|
528
|
+
return /* @__PURE__ */ d(ae, { value: {
|
|
529
|
+
apiClient: e,
|
|
530
|
+
components: l,
|
|
531
|
+
notifications: {
|
|
532
|
+
onError: o ?? console.error
|
|
533
|
+
},
|
|
534
|
+
size: r,
|
|
535
|
+
sectionSlotProps: n
|
|
536
|
+
}, children: i });
|
|
537
|
+
}
|
|
538
|
+
function U(e, t) {
|
|
539
|
+
return "and" in e ? e.and.every((r) => U(r, t)) : "or" in e ? e.or.some((r) => U(r, t)) : pt(e, t);
|
|
540
|
+
}
|
|
541
|
+
function pt(e, t) {
|
|
542
|
+
const r = t[e.field], n = e.value;
|
|
543
|
+
switch (e.operator) {
|
|
544
|
+
case "equals":
|
|
545
|
+
return r === n;
|
|
546
|
+
case "notEquals":
|
|
547
|
+
return r !== n;
|
|
548
|
+
case "in":
|
|
549
|
+
return Array.isArray(n) && n.includes(r);
|
|
550
|
+
case "notIn":
|
|
551
|
+
return Array.isArray(n) && !n.includes(r);
|
|
552
|
+
case "isEmpty":
|
|
553
|
+
return ne(r);
|
|
554
|
+
case "isNotEmpty":
|
|
555
|
+
return !ne(r);
|
|
556
|
+
case "gt":
|
|
557
|
+
return typeof r == "number" && typeof n == "number" && r > n;
|
|
558
|
+
case "gte":
|
|
559
|
+
return typeof r == "number" && typeof n == "number" && r >= n;
|
|
560
|
+
case "lt":
|
|
561
|
+
return typeof r == "number" && typeof n == "number" && r < n;
|
|
562
|
+
case "lte":
|
|
563
|
+
return typeof r == "number" && typeof n == "number" && r <= n;
|
|
564
|
+
default:
|
|
565
|
+
return !1;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function ne(e) {
|
|
569
|
+
return e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) ? e.length === 0 : !1;
|
|
570
|
+
}
|
|
571
|
+
function ue(e) {
|
|
572
|
+
if (e == null || e === "")
|
|
573
|
+
return;
|
|
574
|
+
if (e instanceof Date)
|
|
575
|
+
return isNaN(e.getTime()) || e.getTime() === 0 ? void 0 : e;
|
|
576
|
+
const t = new Date(e);
|
|
577
|
+
if (!(isNaN(t.getTime()) || t.getTime() === 0))
|
|
578
|
+
return t;
|
|
579
|
+
}
|
|
580
|
+
function ht(e) {
|
|
581
|
+
const t = {};
|
|
582
|
+
for (const [n, o] of Object.entries(e.fields))
|
|
583
|
+
t[n] = gt(o);
|
|
584
|
+
let r = b.object(t);
|
|
585
|
+
return r = xt(r, e), r;
|
|
586
|
+
}
|
|
587
|
+
function gt(e) {
|
|
588
|
+
const { type: t, validation: r = {} } = e;
|
|
589
|
+
let n;
|
|
590
|
+
switch (t) {
|
|
591
|
+
case "number":
|
|
592
|
+
n = bt(r);
|
|
593
|
+
break;
|
|
594
|
+
case "checkbox":
|
|
595
|
+
case "switch":
|
|
596
|
+
n = b.boolean();
|
|
597
|
+
break;
|
|
598
|
+
case "date": {
|
|
599
|
+
let o = b.preprocess(
|
|
600
|
+
ue,
|
|
601
|
+
b.date({
|
|
602
|
+
message: r.messages?.invalidDate || "Invalid date"
|
|
603
|
+
}).optional()
|
|
604
|
+
);
|
|
605
|
+
r.required && (o = o.refine(
|
|
606
|
+
(i) => i != null && i instanceof Date && !isNaN(i.getTime()) && i.getTime() !== 0,
|
|
607
|
+
{
|
|
608
|
+
message: r.messages?.required || "Date is required"
|
|
609
|
+
}
|
|
610
|
+
)), r.minDate && (o = o.refine(
|
|
611
|
+
(i) => !i || i >= r.minDate,
|
|
612
|
+
{
|
|
613
|
+
message: r.messages?.minDate || `Date must be after ${r.minDate.toLocaleDateString()}`
|
|
614
|
+
}
|
|
615
|
+
)), r.maxDate && (o = o.refine(
|
|
616
|
+
(i) => !i || i <= r.maxDate,
|
|
617
|
+
{
|
|
618
|
+
message: r.messages?.maxDate || `Date must be before ${r.maxDate.toLocaleDateString()}`
|
|
619
|
+
}
|
|
620
|
+
)), n = o;
|
|
621
|
+
break;
|
|
622
|
+
}
|
|
623
|
+
case "dateRange": {
|
|
624
|
+
const o = b.preprocess(
|
|
625
|
+
ue,
|
|
626
|
+
b.date({
|
|
627
|
+
message: r.messages?.invalidDate || "Invalid date"
|
|
628
|
+
}).optional().nullable()
|
|
629
|
+
);
|
|
630
|
+
let i = b.object({
|
|
631
|
+
start: o,
|
|
632
|
+
end: o
|
|
633
|
+
});
|
|
634
|
+
r.required && (i = i.refine(
|
|
635
|
+
(s) => {
|
|
636
|
+
const l = s.start !== null && s.start !== void 0 && s.start instanceof Date && !isNaN(s.start.getTime()) && s.start.getTime() !== 0, u = s.end !== null && s.end !== void 0 && s.end instanceof Date && !isNaN(s.end.getTime()) && s.end.getTime() !== 0;
|
|
637
|
+
return l && u;
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
message: r.messages?.required || "Both start and end dates are required",
|
|
641
|
+
path: ["start"]
|
|
642
|
+
}
|
|
643
|
+
)), i = i.refine(
|
|
644
|
+
(s) => !s.start || !s.end ? !0 : s.start <= s.end,
|
|
645
|
+
{
|
|
646
|
+
message: r.messages?.invalidRange || "End date must be after start date",
|
|
647
|
+
path: ["end"]
|
|
648
|
+
}
|
|
649
|
+
), n = i;
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
case "autocomplete":
|
|
653
|
+
case "multiselect":
|
|
654
|
+
n = t === "autocomplete" ? b.string() : b.array(b.string()), r.required && (t === "autocomplete" ? n = n.min(
|
|
655
|
+
1,
|
|
656
|
+
r.messages?.required || "Required"
|
|
657
|
+
) : n = n.min(
|
|
658
|
+
1,
|
|
659
|
+
r.messages?.required || "Select at least one option"
|
|
660
|
+
));
|
|
661
|
+
break;
|
|
662
|
+
case "file": {
|
|
663
|
+
const o = e;
|
|
664
|
+
let i = o.multiple ? b.array(b.instanceof(File)).nullable() : b.instanceof(File).nullable();
|
|
665
|
+
r.required && (o.multiple ? i = i.refine(
|
|
666
|
+
(s) => s === null ? !1 : s.length >= 1,
|
|
667
|
+
{
|
|
668
|
+
message: r.messages?.required || "At least one file is required"
|
|
669
|
+
}
|
|
670
|
+
) : i = i.refine(
|
|
671
|
+
(s) => s != null,
|
|
672
|
+
{
|
|
673
|
+
message: r.messages?.required || "File is required"
|
|
674
|
+
}
|
|
675
|
+
)), r.maxSize && (o.multiple ? i = i.refine(
|
|
676
|
+
(s) => s === null ? !0 : s.every((l) => l?.size <= r.maxSize),
|
|
677
|
+
{
|
|
678
|
+
message: r.messages?.maxSize || `File size must be less than ${r.maxSize / 1024 / 1024}MB`
|
|
679
|
+
}
|
|
680
|
+
) : i = i.refine(
|
|
681
|
+
(s) => s === null ? !0 : s.size <= r.maxSize,
|
|
682
|
+
{
|
|
683
|
+
message: r.messages?.maxSize || `File size must be less than ${r.maxSize / 1024 / 1024}MB`
|
|
684
|
+
}
|
|
685
|
+
)), o.accept && (o.multiple ? i = i.refine(
|
|
686
|
+
(s) => s === null ? !0 : s.every((l) => o.accept.split(",").map((a) => a.trim()).some((a) => a.startsWith(".") ? l.name.toLowerCase().endsWith(a.toLowerCase()) : l.type.match(a.replace("*", ".*")))),
|
|
687
|
+
{
|
|
688
|
+
message: r.messages?.fileType || `Invalid file type. Accepted: ${o.accept}`
|
|
689
|
+
}
|
|
690
|
+
) : i = i.refine(
|
|
691
|
+
(s) => {
|
|
692
|
+
if (s === null) return !0;
|
|
693
|
+
const l = s;
|
|
694
|
+
return o.accept.split(",").map((a) => a.trim()).some((a) => a.startsWith(".") ? l.name?.toLowerCase().endsWith(a.toLowerCase()) : l.type?.match(a.replace("*", ".*")));
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
message: r.messages?.fileType || `Invalid file type. Accepted: ${o.accept}`
|
|
698
|
+
}
|
|
699
|
+
)), r.minFiles && o.multiple && (i = i.refine(
|
|
700
|
+
(s) => s === null ? !1 : s.length >= r.minFiles,
|
|
701
|
+
{
|
|
702
|
+
message: r.messages?.minFiles || `At least ${r.minFiles} file(s) required`
|
|
703
|
+
}
|
|
704
|
+
)), r.maxFiles && o.multiple && (i = i.refine(
|
|
705
|
+
(s) => s === null ? !0 : s.length <= r.maxFiles,
|
|
706
|
+
{
|
|
707
|
+
message: r.messages?.maxFiles || `Max ${r.maxFiles} file(s) allowed`
|
|
708
|
+
}
|
|
709
|
+
)), n = i;
|
|
710
|
+
break;
|
|
711
|
+
}
|
|
712
|
+
default:
|
|
713
|
+
n = yt(r);
|
|
714
|
+
}
|
|
715
|
+
return !r.required && !r.requiredIf && (n = n.optional()), n;
|
|
716
|
+
}
|
|
717
|
+
function yt(e) {
|
|
718
|
+
if (e.email)
|
|
719
|
+
return e.required ? b.string().min(1, { message: e.messages?.required || "Email is required" }).pipe(b.email({ message: e.messages?.email || "Invalid email" })) : b.union([
|
|
720
|
+
b.literal(""),
|
|
721
|
+
b.email({ message: e.messages?.email || "Invalid email" })
|
|
722
|
+
]);
|
|
723
|
+
if (e.url)
|
|
724
|
+
return e.required ? b.string().min(1, { message: e.messages?.required || "URL is required" }).pipe(b.url({ message: e.messages?.url || "Invalid URL" })) : b.union([
|
|
725
|
+
b.literal(""),
|
|
726
|
+
b.url({ message: e.messages?.url || "Invalid URL" })
|
|
727
|
+
]);
|
|
728
|
+
let t = b.string();
|
|
729
|
+
if (e.required && (t = t.min(1, e.messages?.required || "Required")), e.minLength && (t = t.min(
|
|
730
|
+
e.minLength,
|
|
731
|
+
e.messages?.minLength || `Min ${e.minLength} characters`
|
|
732
|
+
)), e.maxLength && (t = t.max(
|
|
733
|
+
e.maxLength,
|
|
734
|
+
e.messages?.maxLength || `Max ${e.maxLength} characters`
|
|
735
|
+
)), e.pattern && (t = t.regex(
|
|
736
|
+
new RegExp(e.pattern),
|
|
737
|
+
e.messages?.pattern || "Invalid format"
|
|
738
|
+
)), e.hasUppercase) {
|
|
739
|
+
const r = e.hasUppercase === !0 ? 1 : e.hasUppercase, n = new RegExp(`(?=(.*[A-Z]){${r}})`);
|
|
740
|
+
t = t.regex(
|
|
741
|
+
n,
|
|
742
|
+
e.messages?.hasUppercase || `At least ${r} uppercase letter(s)`
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
if (e.hasLowercase) {
|
|
746
|
+
const r = e.hasLowercase === !0 ? 1 : e.hasLowercase, n = new RegExp(`(?=(.*[a-z]){${r}})`);
|
|
747
|
+
t = t.regex(
|
|
748
|
+
n,
|
|
749
|
+
e.messages?.hasLowercase || `At least ${r} lowercase letter(s)`
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
if (e.hasNumber) {
|
|
753
|
+
const r = e.hasNumber === !0 ? 1 : e.hasNumber, n = new RegExp(`(?=(.*[0-9]){${r}})`);
|
|
754
|
+
t = t.regex(
|
|
755
|
+
n,
|
|
756
|
+
e.messages?.hasNumber || `At least ${r} number(s)`
|
|
757
|
+
);
|
|
758
|
+
}
|
|
759
|
+
if (e.hasSpecialChar) {
|
|
760
|
+
const r = e.hasSpecialChar === !0 ? 1 : e.hasSpecialChar, n = new RegExp(
|
|
761
|
+
`(?=(.*[!@#$%^&*()_+\\-=\\[\\]{};':"\\\\|,.<>\\/?]){${r}})`
|
|
762
|
+
);
|
|
763
|
+
t = t.regex(
|
|
764
|
+
n,
|
|
765
|
+
e.messages?.hasSpecialChar || `At least ${r} special character(s)`
|
|
766
|
+
);
|
|
767
|
+
}
|
|
768
|
+
return e.includes && (t = t.includes(e.includes, {
|
|
769
|
+
message: e.messages?.includes || `Must include "${e.includes}"`
|
|
770
|
+
})), t;
|
|
771
|
+
}
|
|
772
|
+
function bt(e) {
|
|
773
|
+
let t = b.coerce.number();
|
|
774
|
+
return e.min !== void 0 && (t = t.min(
|
|
775
|
+
e.min,
|
|
776
|
+
e.messages?.min || `Min value is ${e.min}`
|
|
777
|
+
)), e.max !== void 0 && (t = t.max(
|
|
778
|
+
e.max,
|
|
779
|
+
e.messages?.max || `Max value is ${e.max}`
|
|
780
|
+
)), t;
|
|
781
|
+
}
|
|
782
|
+
function xt(e, t) {
|
|
783
|
+
const r = [], n = [];
|
|
784
|
+
for (const [i, s] of Object.entries(t.fields))
|
|
785
|
+
s.validation?.matchField && r.push({
|
|
786
|
+
fieldName: i,
|
|
787
|
+
matchField: s.validation.matchField,
|
|
788
|
+
message: s.validation.messages?.matchField || "Fields do not match"
|
|
789
|
+
}), s.validation?.requiredIf && n.push({
|
|
790
|
+
fieldName: i,
|
|
791
|
+
condition: s.validation.requiredIf,
|
|
792
|
+
message: s.validation.messages?.required || `${s.label} is required`
|
|
793
|
+
});
|
|
794
|
+
let o = e;
|
|
795
|
+
for (const { fieldName: i, matchField: s, message: l } of r)
|
|
796
|
+
o = o.refine(
|
|
797
|
+
(u) => u[i] === u[s],
|
|
798
|
+
{
|
|
799
|
+
message: l,
|
|
800
|
+
path: [i]
|
|
801
|
+
}
|
|
802
|
+
);
|
|
803
|
+
return n.length > 0 && (o = o.superRefine((i, s) => {
|
|
804
|
+
for (const { fieldName: l, condition: u, message: a } of n)
|
|
805
|
+
if (U(u, i)) {
|
|
806
|
+
const c = i[l];
|
|
807
|
+
ne(c) && s.issues.push({
|
|
808
|
+
code: "custom",
|
|
809
|
+
message: a,
|
|
810
|
+
path: [l],
|
|
811
|
+
input: c
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
})), o;
|
|
815
|
+
}
|
|
816
|
+
function vt(e, t, r) {
|
|
817
|
+
const n = new URL(e.apiUrl, window.location.origin);
|
|
818
|
+
if (e.queryParams)
|
|
819
|
+
for (const o of e.queryParams) {
|
|
820
|
+
let i;
|
|
821
|
+
if (o.dependsOnInput)
|
|
822
|
+
i = r || void 0;
|
|
823
|
+
else if (o.dependsOn) {
|
|
824
|
+
const s = t[o.dependsOn];
|
|
825
|
+
i = s != null ? String(s) : void 0;
|
|
826
|
+
} else o.value && (i = o.value);
|
|
827
|
+
i !== void 0 && n.searchParams.set(o.key, i);
|
|
828
|
+
}
|
|
829
|
+
return n.pathname + n.search;
|
|
830
|
+
}
|
|
831
|
+
function Ft(e) {
|
|
832
|
+
return e.queryParams ? e.queryParams.filter((t) => t.dependsOn).map((t) => t.dependsOn) : [];
|
|
833
|
+
}
|
|
834
|
+
function St(e, t) {
|
|
835
|
+
return e.every((r) => {
|
|
836
|
+
const n = t[r];
|
|
837
|
+
return n != null && n !== "";
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
function Dt(e) {
|
|
841
|
+
const t = {};
|
|
842
|
+
for (const [r, n] of Object.entries(e.fields))
|
|
843
|
+
if (n.defaultValue !== void 0)
|
|
844
|
+
t[r] = n.defaultValue;
|
|
845
|
+
else
|
|
846
|
+
switch (n.type) {
|
|
847
|
+
case "text":
|
|
848
|
+
case "email":
|
|
849
|
+
case "password":
|
|
850
|
+
case "textarea":
|
|
851
|
+
case "select":
|
|
852
|
+
case "autocomplete":
|
|
853
|
+
case "radio":
|
|
854
|
+
t[r] = "";
|
|
855
|
+
break;
|
|
856
|
+
case "number":
|
|
857
|
+
t[r] = null;
|
|
858
|
+
break;
|
|
859
|
+
case "checkbox":
|
|
860
|
+
case "switch":
|
|
861
|
+
t[r] = !1;
|
|
862
|
+
break;
|
|
863
|
+
case "multiselect":
|
|
864
|
+
t[r] = [];
|
|
865
|
+
break;
|
|
866
|
+
case "date":
|
|
867
|
+
t[r] = void 0;
|
|
868
|
+
break;
|
|
869
|
+
case "dateRange":
|
|
870
|
+
t[r] = { start: void 0, end: void 0 };
|
|
871
|
+
break;
|
|
872
|
+
case "file":
|
|
873
|
+
t[r] = n.multiple ? [] : null;
|
|
874
|
+
break;
|
|
875
|
+
default:
|
|
876
|
+
t[r] = "";
|
|
877
|
+
}
|
|
878
|
+
return t;
|
|
879
|
+
}
|
|
880
|
+
const _ = (e, t) => {
|
|
881
|
+
if (!t) return e;
|
|
882
|
+
const r = Array.isArray(e) ? e : [e], n = Array.isArray(t) ? t : [t];
|
|
883
|
+
return [...r, ...n];
|
|
884
|
+
}, W = (e, t) => e ? t ? { sx: _(e.sx ?? {}, t.sx) } : e : t, wt = (e, t) => e ? t ? {
|
|
885
|
+
root: W(e.root, t.root),
|
|
886
|
+
title: W(e.title, t.title),
|
|
887
|
+
description: W(e.description, t.description),
|
|
888
|
+
content: W(e.content, t.content)
|
|
889
|
+
} : e : t;
|
|
890
|
+
function qt(e) {
|
|
891
|
+
const { control: t } = k(), r = [];
|
|
892
|
+
for (const [u, a] of Object.entries(e.fields))
|
|
893
|
+
if (a.showIf) {
|
|
894
|
+
const c = se(a.showIf);
|
|
895
|
+
r.push({ name: u, dependsOn: c });
|
|
896
|
+
}
|
|
897
|
+
const n = [], o = /* @__PURE__ */ new Set();
|
|
898
|
+
for (const { dependsOn: u } of r)
|
|
899
|
+
for (const a of u)
|
|
900
|
+
o.has(a) || (o.add(a), n.push(a));
|
|
901
|
+
const i = xe({
|
|
902
|
+
control: t,
|
|
903
|
+
name: n
|
|
904
|
+
}), s = {};
|
|
905
|
+
n.length > 0 && i && n.forEach((u, a) => {
|
|
906
|
+
s[u] = Array.isArray(i) ? i[a] : i;
|
|
907
|
+
});
|
|
908
|
+
const l = /* @__PURE__ */ new Set();
|
|
909
|
+
for (const [u, a] of Object.entries(e.fields))
|
|
910
|
+
a.showIf ? U(a.showIf, s) && l.add(u) : l.add(u);
|
|
911
|
+
return l;
|
|
912
|
+
}
|
|
913
|
+
function se(e) {
|
|
914
|
+
return "and" in e ? e.and.flatMap(se) : "or" in e ? e.or.flatMap(se) : [e.field];
|
|
915
|
+
}
|
|
916
|
+
function Y(e, t, r) {
|
|
917
|
+
const { control: n } = k(), { apiClient: o, notifications: i } = R(), s = e?.queryParams?.some((w) => w.dependsOnInput) ?? !1, [l, u] = X(""), [a, c] = X("");
|
|
918
|
+
O(() => {
|
|
919
|
+
if (!s) return;
|
|
920
|
+
const w = setTimeout(() => c(l), 300);
|
|
921
|
+
return () => clearTimeout(w);
|
|
922
|
+
}, [l, s]);
|
|
923
|
+
const f = e ? Ft(e) : [], p = xe({
|
|
924
|
+
control: n,
|
|
925
|
+
name: f.length > 0 ? f : []
|
|
926
|
+
}), m = {};
|
|
927
|
+
f.length > 0 && f.forEach((w, A) => {
|
|
928
|
+
m[w] = Array.isArray(p) ? p[A] : p;
|
|
929
|
+
});
|
|
930
|
+
const y = e ? vt(e, m, s ? a : void 0) : "", g = e ? St(f, m) : !1, { data: x, isLoading: F, error: q } = rt({
|
|
931
|
+
queryKey: ["options", y],
|
|
932
|
+
queryFn: async () => o.get(y),
|
|
933
|
+
enabled: !!e && g,
|
|
934
|
+
staleTime: 300 * 1e3,
|
|
935
|
+
// 5 minutes
|
|
936
|
+
retry: 2
|
|
937
|
+
});
|
|
938
|
+
O(() => {
|
|
939
|
+
q && i.onError && i.onError(`Failed to load options: ${q.message}`);
|
|
940
|
+
}, [q, i]);
|
|
941
|
+
const S = G(() => {
|
|
942
|
+
if (!e) return t ?? [];
|
|
943
|
+
const w = x ? x.map((P) => ({
|
|
944
|
+
value: P[e.valueKey ?? "value"],
|
|
945
|
+
label: P[e.labelKey ?? "label"]
|
|
946
|
+
})) : [];
|
|
947
|
+
if (!r?.length) return w;
|
|
948
|
+
const A = new Set(w.map((P) => String(P.value)));
|
|
949
|
+
return [...r.filter((P) => !A.has(String(P.value))), ...w];
|
|
950
|
+
}, [x, r, e, t]), v = z(
|
|
951
|
+
(w, A) => {
|
|
952
|
+
u(A);
|
|
953
|
+
},
|
|
954
|
+
[]
|
|
955
|
+
);
|
|
956
|
+
return {
|
|
957
|
+
options: S,
|
|
958
|
+
isLoading: F,
|
|
959
|
+
error: q,
|
|
960
|
+
inputValue: s ? l : void 0,
|
|
961
|
+
onInputChange: s ? v : void 0
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
function Ct(e, t) {
|
|
965
|
+
const { apiClient: r } = R(), n = H(void 0), o = H(null), i = z(
|
|
966
|
+
async (u) => {
|
|
967
|
+
if (!t || !u || typeof u == "string" && u.trim() === "")
|
|
968
|
+
return !0;
|
|
969
|
+
o.current && o.current.abort();
|
|
970
|
+
const a = new AbortController();
|
|
971
|
+
o.current = a;
|
|
972
|
+
try {
|
|
973
|
+
const c = new URL(t.apiUrl, window.location.origin);
|
|
974
|
+
if (t.queryParams)
|
|
975
|
+
for (const m of t.queryParams)
|
|
976
|
+
(m.dependsOn === e || !m.dependsOn) && c.searchParams.set(m.key, String(u));
|
|
977
|
+
else
|
|
978
|
+
c.searchParams.set(e, String(u));
|
|
979
|
+
const f = await r.get(c.pathname + c.search, {
|
|
980
|
+
signal: a.signal
|
|
981
|
+
});
|
|
982
|
+
return f.valid ?? !f.exists ? !0 : t.message || "Validation failed";
|
|
983
|
+
} catch (c) {
|
|
984
|
+
return c instanceof Error && c.name === "AbortError" ? !0 : "⚠️ Validation unavailable (API error)";
|
|
985
|
+
}
|
|
986
|
+
},
|
|
987
|
+
[t, e, r]
|
|
988
|
+
), s = z(
|
|
989
|
+
(u) => new Promise((a) => {
|
|
990
|
+
n.current && clearTimeout(n.current), n.current = setTimeout(async () => {
|
|
991
|
+
const c = await i(u);
|
|
992
|
+
a(c);
|
|
993
|
+
}, t?.debounce ?? 500);
|
|
994
|
+
}),
|
|
995
|
+
[i, t?.debounce]
|
|
996
|
+
), l = z(
|
|
997
|
+
async (u) => (n.current && clearTimeout(n.current), i(u)),
|
|
998
|
+
[i]
|
|
999
|
+
);
|
|
1000
|
+
return { validateDebounced: s, validateImmediate: l };
|
|
1001
|
+
}
|
|
1002
|
+
const ce = (e, t, r) => {
|
|
1003
|
+
if (e && "reportValidity" in e) {
|
|
1004
|
+
const n = te(r, t);
|
|
1005
|
+
e.setCustomValidity(n && n.message || ""), e.reportValidity();
|
|
1006
|
+
}
|
|
1007
|
+
}, ie = (e, t) => {
|
|
1008
|
+
for (const r in t.fields) {
|
|
1009
|
+
const n = t.fields[r];
|
|
1010
|
+
n && n.ref && "reportValidity" in n.ref ? ce(n.ref, r, e) : n && n.refs && n.refs.forEach((o) => ce(o, r, e));
|
|
1011
|
+
}
|
|
1012
|
+
}, de = (e, t) => {
|
|
1013
|
+
t.shouldUseNativeValidation && ie(e, t);
|
|
1014
|
+
const r = {};
|
|
1015
|
+
for (const n in e) {
|
|
1016
|
+
const o = te(t.fields, n), i = Object.assign(e[n] || {}, { ref: o && o.ref });
|
|
1017
|
+
if (Rt(t.names || Object.keys(e), n)) {
|
|
1018
|
+
const s = Object.assign({}, te(r, n));
|
|
1019
|
+
Q(s, "root", i), Q(r, n, s);
|
|
1020
|
+
} else Q(r, n, i);
|
|
1021
|
+
}
|
|
1022
|
+
return r;
|
|
1023
|
+
}, Rt = (e, t) => {
|
|
1024
|
+
const r = fe(t);
|
|
1025
|
+
return e.some((n) => fe(n).match(`^${r}\\.\\d+`));
|
|
1026
|
+
};
|
|
1027
|
+
function fe(e) {
|
|
1028
|
+
return e.replace(/\]|\[/g, "");
|
|
1029
|
+
}
|
|
1030
|
+
function Se(e, t, r) {
|
|
1031
|
+
function n(l, u) {
|
|
1032
|
+
if (l._zod || Object.defineProperty(l, "_zod", {
|
|
1033
|
+
value: {
|
|
1034
|
+
def: u,
|
|
1035
|
+
constr: s,
|
|
1036
|
+
traits: /* @__PURE__ */ new Set()
|
|
1037
|
+
},
|
|
1038
|
+
enumerable: !1
|
|
1039
|
+
}), l._zod.traits.has(e))
|
|
1040
|
+
return;
|
|
1041
|
+
l._zod.traits.add(e), t(l, u);
|
|
1042
|
+
const a = s.prototype, c = Object.keys(a);
|
|
1043
|
+
for (let f = 0; f < c.length; f++) {
|
|
1044
|
+
const p = c[f];
|
|
1045
|
+
p in l || (l[p] = a[p].bind(l));
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
const o = r?.Parent ?? Object;
|
|
1049
|
+
class i extends o {
|
|
1050
|
+
}
|
|
1051
|
+
Object.defineProperty(i, "name", { value: e });
|
|
1052
|
+
function s(l) {
|
|
1053
|
+
var u;
|
|
1054
|
+
const a = r?.Parent ? new i() : this;
|
|
1055
|
+
n(a, l), (u = a._zod).deferred ?? (u.deferred = []);
|
|
1056
|
+
for (const c of a._zod.deferred)
|
|
1057
|
+
c();
|
|
1058
|
+
return a;
|
|
1059
|
+
}
|
|
1060
|
+
return Object.defineProperty(s, "init", { value: n }), Object.defineProperty(s, Symbol.hasInstance, {
|
|
1061
|
+
value: (l) => r?.Parent && l instanceof r.Parent ? !0 : l?._zod?.traits?.has(e)
|
|
1062
|
+
}), Object.defineProperty(s, "name", { value: e }), s;
|
|
1063
|
+
}
|
|
1064
|
+
class It extends Error {
|
|
1065
|
+
constructor() {
|
|
1066
|
+
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
const kt = {};
|
|
1070
|
+
function De(e) {
|
|
1071
|
+
return kt;
|
|
1072
|
+
}
|
|
1073
|
+
function At(e, t) {
|
|
1074
|
+
return typeof t == "bigint" ? t.toString() : t;
|
|
1075
|
+
}
|
|
1076
|
+
const we = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {
|
|
1077
|
+
};
|
|
1078
|
+
function K(e) {
|
|
1079
|
+
return typeof e == "string" ? e : e?.message;
|
|
1080
|
+
}
|
|
1081
|
+
function qe(e, t, r) {
|
|
1082
|
+
const n = { ...e, path: e.path ?? [] };
|
|
1083
|
+
if (!e.message) {
|
|
1084
|
+
const o = K(e.inst?._zod.def?.error?.(e)) ?? K(t?.error?.(e)) ?? K(r.customError?.(e)) ?? K(r.localeError?.(e)) ?? "Invalid input";
|
|
1085
|
+
n.message = o;
|
|
1086
|
+
}
|
|
1087
|
+
return delete n.inst, delete n.continue, t?.reportInput || delete n.input, n;
|
|
1088
|
+
}
|
|
1089
|
+
const Ce = (e, t) => {
|
|
1090
|
+
e.name = "$ZodError", Object.defineProperty(e, "_zod", {
|
|
1091
|
+
value: e._zod,
|
|
1092
|
+
enumerable: !1
|
|
1093
|
+
}), Object.defineProperty(e, "issues", {
|
|
1094
|
+
value: t,
|
|
1095
|
+
enumerable: !1
|
|
1096
|
+
}), e.message = JSON.stringify(t, At, 2), Object.defineProperty(e, "toString", {
|
|
1097
|
+
value: () => e.message,
|
|
1098
|
+
enumerable: !1
|
|
1099
|
+
});
|
|
1100
|
+
}, Et = Se("$ZodError", Ce), Re = Se("$ZodError", Ce, { Parent: Error }), Vt = (e) => (t, r, n, o) => {
|
|
1101
|
+
const i = n ? Object.assign(n, { async: !1 }) : { async: !1 }, s = t._zod.run({ value: r, issues: [] }, i);
|
|
1102
|
+
if (s instanceof Promise)
|
|
1103
|
+
throw new It();
|
|
1104
|
+
if (s.issues.length) {
|
|
1105
|
+
const l = new (o?.Err ?? e)(s.issues.map((u) => qe(u, i, De())));
|
|
1106
|
+
throw we(l, o?.callee), l;
|
|
1107
|
+
}
|
|
1108
|
+
return s.value;
|
|
1109
|
+
}, Pt = /* @__PURE__ */ Vt(Re), Tt = (e) => async (t, r, n, o) => {
|
|
1110
|
+
const i = n ? Object.assign(n, { async: !0 }) : { async: !0 };
|
|
1111
|
+
let s = t._zod.run({ value: r, issues: [] }, i);
|
|
1112
|
+
if (s instanceof Promise && (s = await s), s.issues.length) {
|
|
1113
|
+
const l = new (o?.Err ?? e)(s.issues.map((u) => qe(u, i, De())));
|
|
1114
|
+
throw we(l, o?.callee), l;
|
|
1115
|
+
}
|
|
1116
|
+
return s.value;
|
|
1117
|
+
}, $t = /* @__PURE__ */ Tt(Re);
|
|
1118
|
+
function me(e, t) {
|
|
1119
|
+
try {
|
|
1120
|
+
var r = e();
|
|
1121
|
+
} catch (n) {
|
|
1122
|
+
return t(n);
|
|
1123
|
+
}
|
|
1124
|
+
return r && r.then ? r.then(void 0, t) : r;
|
|
1125
|
+
}
|
|
1126
|
+
function Ot(e, t) {
|
|
1127
|
+
for (var r = {}; e.length; ) {
|
|
1128
|
+
var n = e[0], o = n.code, i = n.message, s = n.path.join(".");
|
|
1129
|
+
if (!r[s]) if ("unionErrors" in n) {
|
|
1130
|
+
var l = n.unionErrors[0].errors[0];
|
|
1131
|
+
r[s] = { message: l.message, type: l.code };
|
|
1132
|
+
} else r[s] = { message: i, type: o };
|
|
1133
|
+
if ("unionErrors" in n && n.unionErrors.forEach(function(c) {
|
|
1134
|
+
return c.errors.forEach(function(f) {
|
|
1135
|
+
return e.push(f);
|
|
1136
|
+
});
|
|
1137
|
+
}), t) {
|
|
1138
|
+
var u = r[s].types, a = u && u[n.code];
|
|
1139
|
+
r[s] = ve(s, t, r, o, a ? [].concat(a, n.message) : n.message);
|
|
1140
|
+
}
|
|
1141
|
+
e.shift();
|
|
1142
|
+
}
|
|
1143
|
+
return r;
|
|
1144
|
+
}
|
|
1145
|
+
function zt(e, t) {
|
|
1146
|
+
for (var r = {}; e.length; ) {
|
|
1147
|
+
var n = e[0], o = n.code, i = n.message, s = n.path.join(".");
|
|
1148
|
+
if (!r[s]) if (n.code === "invalid_union" && n.errors.length > 0) {
|
|
1149
|
+
var l = n.errors[0][0];
|
|
1150
|
+
r[s] = { message: l.message, type: l.code };
|
|
1151
|
+
} else r[s] = { message: i, type: o };
|
|
1152
|
+
if (n.code === "invalid_union" && n.errors.forEach(function(c) {
|
|
1153
|
+
return c.forEach(function(f) {
|
|
1154
|
+
return e.push(f);
|
|
1155
|
+
});
|
|
1156
|
+
}), t) {
|
|
1157
|
+
var u = r[s].types, a = u && u[n.code];
|
|
1158
|
+
r[s] = ve(s, t, r, o, a ? [].concat(a, n.message) : n.message);
|
|
1159
|
+
}
|
|
1160
|
+
e.shift();
|
|
1161
|
+
}
|
|
1162
|
+
return r;
|
|
1163
|
+
}
|
|
1164
|
+
function Lt(e, t, r) {
|
|
1165
|
+
if (r === void 0 && (r = {}), (function(n) {
|
|
1166
|
+
return "_def" in n && typeof n._def == "object" && "typeName" in n._def;
|
|
1167
|
+
})(e)) return function(n, o, i) {
|
|
1168
|
+
try {
|
|
1169
|
+
return Promise.resolve(me(function() {
|
|
1170
|
+
return Promise.resolve(e[r.mode === "sync" ? "parse" : "parseAsync"](n, t)).then(function(s) {
|
|
1171
|
+
return i.shouldUseNativeValidation && ie({}, i), { errors: {}, values: r.raw ? Object.assign({}, n) : s };
|
|
1172
|
+
});
|
|
1173
|
+
}, function(s) {
|
|
1174
|
+
if ((function(l) {
|
|
1175
|
+
return Array.isArray(l?.issues);
|
|
1176
|
+
})(s)) return { values: {}, errors: de(Ot(s.errors, !i.shouldUseNativeValidation && i.criteriaMode === "all"), i) };
|
|
1177
|
+
throw s;
|
|
1178
|
+
}));
|
|
1179
|
+
} catch (s) {
|
|
1180
|
+
return Promise.reject(s);
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
if ((function(n) {
|
|
1184
|
+
return "_zod" in n && typeof n._zod == "object";
|
|
1185
|
+
})(e)) return function(n, o, i) {
|
|
1186
|
+
try {
|
|
1187
|
+
return Promise.resolve(me(function() {
|
|
1188
|
+
return Promise.resolve((r.mode === "sync" ? Pt : $t)(e, n, t)).then(function(s) {
|
|
1189
|
+
return i.shouldUseNativeValidation && ie({}, i), { errors: {}, values: r.raw ? Object.assign({}, n) : s };
|
|
1190
|
+
});
|
|
1191
|
+
}, function(s) {
|
|
1192
|
+
if ((function(l) {
|
|
1193
|
+
return l instanceof Et;
|
|
1194
|
+
})(s)) return { values: {}, errors: de(zt(s.issues, !i.shouldUseNativeValidation && i.criteriaMode === "all"), i) };
|
|
1195
|
+
throw s;
|
|
1196
|
+
}));
|
|
1197
|
+
} catch (s) {
|
|
1198
|
+
return Promise.reject(s);
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
throw new Error("Invalid input: not a Zod schema");
|
|
1202
|
+
}
|
|
1203
|
+
function jt(e) {
|
|
1204
|
+
return z(
|
|
1205
|
+
async (t, r, n) => {
|
|
1206
|
+
const o = /* @__PURE__ */ new Set();
|
|
1207
|
+
for (const [a, c] of Object.entries(e.fields))
|
|
1208
|
+
(!c.showIf || U(c.showIf, t)) && o.add(a);
|
|
1209
|
+
const i = Object.entries(e.fields).filter(([a]) => o.has(a)).reduce((a, [c, f]) => (a[c] = f, a), {}), s = ht({
|
|
1210
|
+
...e,
|
|
1211
|
+
fields: i
|
|
1212
|
+
});
|
|
1213
|
+
return await Lt(s)(
|
|
1214
|
+
t,
|
|
1215
|
+
r,
|
|
1216
|
+
n
|
|
1217
|
+
);
|
|
1218
|
+
},
|
|
1219
|
+
[e]
|
|
1220
|
+
// Rebuild resolver when schema changes
|
|
1221
|
+
);
|
|
1222
|
+
}
|
|
1223
|
+
const Ie = pe(null);
|
|
1224
|
+
function Nt() {
|
|
1225
|
+
return he(Ie);
|
|
1226
|
+
}
|
|
1227
|
+
function J(e, t) {
|
|
1228
|
+
const r = Nt();
|
|
1229
|
+
O(() => (r?.register(e, t), () => {
|
|
1230
|
+
r?.unregister(e);
|
|
1231
|
+
}), [e, t, r]);
|
|
1232
|
+
}
|
|
1233
|
+
function Z({ name: e, config: t, disabled: r }) {
|
|
1234
|
+
const { control: n } = k(), { components: o, size: i } = R(), s = o.TextField, l = t, { validateDebounced: u, validateImmediate: a } = Ct(
|
|
1235
|
+
e,
|
|
1236
|
+
l.validation?.asyncValidation
|
|
1237
|
+
);
|
|
1238
|
+
if (t.type !== "text" && t.type !== "password" && t.type !== "email" && t.type !== "textarea")
|
|
1239
|
+
return null;
|
|
1240
|
+
const c = t.type === "textarea", f = c ? t.rows || 4 : void 0, p = !!(l.validation?.required || l.validation?.requiredIf);
|
|
1241
|
+
return /* @__PURE__ */ d(
|
|
1242
|
+
T,
|
|
1243
|
+
{
|
|
1244
|
+
name: e,
|
|
1245
|
+
control: n,
|
|
1246
|
+
rules: {
|
|
1247
|
+
validate: {
|
|
1248
|
+
// Async validation runs in parallel with sync
|
|
1249
|
+
asyncValidation: async (m) => u(m)
|
|
1250
|
+
}
|
|
1251
|
+
},
|
|
1252
|
+
render: ({ field: { value: m, onChange: y, onBlur: g, ref: x }, fieldState: { error: F } }) => /* @__PURE__ */ d(
|
|
1253
|
+
s,
|
|
1254
|
+
{
|
|
1255
|
+
value: m || "",
|
|
1256
|
+
onChange: y,
|
|
1257
|
+
onBlur: async () => {
|
|
1258
|
+
g(), l.validation?.asyncValidation && await a(m);
|
|
1259
|
+
},
|
|
1260
|
+
inputRef: x,
|
|
1261
|
+
type: t.type === "textarea" ? "text" : t.type,
|
|
1262
|
+
label: l.label,
|
|
1263
|
+
required: p,
|
|
1264
|
+
placeholder: l.placeholder,
|
|
1265
|
+
helperText: F?.message || l.helperText,
|
|
1266
|
+
error: !!F,
|
|
1267
|
+
disabled: r || l.disabled,
|
|
1268
|
+
autoComplete: l.autoComplete,
|
|
1269
|
+
multiline: c,
|
|
1270
|
+
rows: f,
|
|
1271
|
+
size: i
|
|
1272
|
+
}
|
|
1273
|
+
)
|
|
1274
|
+
}
|
|
1275
|
+
);
|
|
1276
|
+
}
|
|
1277
|
+
function _t({ name: e, config: t, disabled: r }) {
|
|
1278
|
+
const { control: n } = k(), { components: o, size: i } = R(), s = o.NumberField;
|
|
1279
|
+
if (t.type !== "number")
|
|
1280
|
+
return null;
|
|
1281
|
+
const l = !!(t.validation?.required || t.validation?.requiredIf);
|
|
1282
|
+
return /* @__PURE__ */ d(
|
|
1283
|
+
T,
|
|
1284
|
+
{
|
|
1285
|
+
name: e,
|
|
1286
|
+
control: n,
|
|
1287
|
+
render: ({ field: { value: u, onChange: a, onBlur: c, name: f }, fieldState: { error: p } }) => /* @__PURE__ */ d(
|
|
1288
|
+
s,
|
|
1289
|
+
{
|
|
1290
|
+
name: f,
|
|
1291
|
+
value: u,
|
|
1292
|
+
onValueChange: (m) => a(m),
|
|
1293
|
+
onBlur: c,
|
|
1294
|
+
label: t.label,
|
|
1295
|
+
required: l,
|
|
1296
|
+
placeholder: t.placeholder,
|
|
1297
|
+
helperText: p?.message || t.helperText,
|
|
1298
|
+
error: !!p,
|
|
1299
|
+
disabled: r || t.disabled,
|
|
1300
|
+
min: t.min,
|
|
1301
|
+
max: t.max,
|
|
1302
|
+
step: t.step,
|
|
1303
|
+
size: i
|
|
1304
|
+
}
|
|
1305
|
+
)
|
|
1306
|
+
}
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1309
|
+
function Ut({ name: e, config: t, disabled: r }) {
|
|
1310
|
+
const { control: n } = k(), { components: o, size: i } = R(), s = o.Checkbox;
|
|
1311
|
+
if (t.type !== "checkbox")
|
|
1312
|
+
return null;
|
|
1313
|
+
const l = !!(t.validation?.required || t.validation?.requiredIf);
|
|
1314
|
+
return /* @__PURE__ */ d(
|
|
1315
|
+
T,
|
|
1316
|
+
{
|
|
1317
|
+
name: e,
|
|
1318
|
+
control: n,
|
|
1319
|
+
render: ({ field: { value: u, onChange: a, ...c }, fieldState: { error: f } }) => /* @__PURE__ */ d(
|
|
1320
|
+
s,
|
|
1321
|
+
{
|
|
1322
|
+
...c,
|
|
1323
|
+
label: t.label,
|
|
1324
|
+
required: l,
|
|
1325
|
+
checked: !!u,
|
|
1326
|
+
onChange: (p) => a(p.target.checked),
|
|
1327
|
+
disabled: r || t.disabled,
|
|
1328
|
+
error: !!f,
|
|
1329
|
+
helperText: f?.message || t.helperText,
|
|
1330
|
+
size: i
|
|
1331
|
+
}
|
|
1332
|
+
)
|
|
1333
|
+
}
|
|
1334
|
+
);
|
|
1335
|
+
}
|
|
1336
|
+
function Mt({ name: e, config: t, disabled: r }) {
|
|
1337
|
+
const { control: n } = k(), { components: o, size: i } = R(), s = o.Switch;
|
|
1338
|
+
if (t.type !== "switch")
|
|
1339
|
+
return null;
|
|
1340
|
+
const l = !!(t.validation?.required || t.validation?.requiredIf);
|
|
1341
|
+
return /* @__PURE__ */ d(
|
|
1342
|
+
T,
|
|
1343
|
+
{
|
|
1344
|
+
name: e,
|
|
1345
|
+
control: n,
|
|
1346
|
+
render: ({ field: { value: u, onChange: a, ...c }, fieldState: { error: f } }) => /* @__PURE__ */ d(
|
|
1347
|
+
s,
|
|
1348
|
+
{
|
|
1349
|
+
...c,
|
|
1350
|
+
label: t.label,
|
|
1351
|
+
required: l,
|
|
1352
|
+
checked: !!u,
|
|
1353
|
+
onChange: (p) => a(p.target.checked),
|
|
1354
|
+
disabled: r || t.disabled,
|
|
1355
|
+
error: !!f,
|
|
1356
|
+
helperText: f?.message || t.helperText,
|
|
1357
|
+
size: i
|
|
1358
|
+
}
|
|
1359
|
+
)
|
|
1360
|
+
}
|
|
1361
|
+
);
|
|
1362
|
+
}
|
|
1363
|
+
function Bt({ name: e, config: t, disabled: r }) {
|
|
1364
|
+
const { control: n, setValue: o, getValues: i } = k(), { components: s, size: l } = R(), u = s.Select, a = t, { options: c, isLoading: f } = Y(
|
|
1365
|
+
t.type === "select" ? a.optionsSource : void 0,
|
|
1366
|
+
t.type === "select" ? a.options : void 0
|
|
1367
|
+
);
|
|
1368
|
+
if (J(e, c), O(() => {
|
|
1369
|
+
if (t.type !== "select") return;
|
|
1370
|
+
const m = i(e);
|
|
1371
|
+
m && !c.some((y) => y.value === m) && o(e, "", { shouldValidate: !1 });
|
|
1372
|
+
}, [c, e, o, i, t.type]), t.type !== "select")
|
|
1373
|
+
return null;
|
|
1374
|
+
const p = !!(a.validation?.required || a.validation?.requiredIf);
|
|
1375
|
+
return /* @__PURE__ */ d(
|
|
1376
|
+
T,
|
|
1377
|
+
{
|
|
1378
|
+
name: e,
|
|
1379
|
+
control: n,
|
|
1380
|
+
render: ({ field: { value: m, onChange: y, onBlur: g, ref: x }, fieldState: { error: F } }) => /* @__PURE__ */ D(j, { fullWidth: !0, error: !!F, disabled: r || a.disabled || f, size: l, children: [
|
|
1381
|
+
a.label && /* @__PURE__ */ d(ye, { required: p, children: a.label }),
|
|
1382
|
+
/* @__PURE__ */ d(
|
|
1383
|
+
u,
|
|
1384
|
+
{
|
|
1385
|
+
name: e,
|
|
1386
|
+
value: m || "",
|
|
1387
|
+
onChange: y,
|
|
1388
|
+
onBlur: g,
|
|
1389
|
+
label: a.label,
|
|
1390
|
+
options: c,
|
|
1391
|
+
size: l,
|
|
1392
|
+
ref: x
|
|
1393
|
+
}
|
|
1394
|
+
),
|
|
1395
|
+
(F?.message || a.helperText) && /* @__PURE__ */ d(L, { children: F?.message || a.helperText })
|
|
1396
|
+
] })
|
|
1397
|
+
}
|
|
1398
|
+
);
|
|
1399
|
+
}
|
|
1400
|
+
function Wt({ name: e, config: t, disabled: r }) {
|
|
1401
|
+
const { control: n, setValue: o, getValues: i } = k(), { components: s, size: l } = R(), u = s.Autocomplete, a = t, { options: c, isLoading: f, inputValue: p, onInputChange: m } = Y(
|
|
1402
|
+
t.type === "multiselect" ? a.optionsSource : void 0,
|
|
1403
|
+
t.type === "multiselect" ? a.options : void 0,
|
|
1404
|
+
t.type === "multiselect" ? a.initialOptions : void 0
|
|
1405
|
+
);
|
|
1406
|
+
if (J(e, c), O(() => {
|
|
1407
|
+
if (t.type !== "multiselect" || f || m) return;
|
|
1408
|
+
const g = i(e);
|
|
1409
|
+
if (Array.isArray(g) && g.length > 0) {
|
|
1410
|
+
const x = g.filter(
|
|
1411
|
+
(F) => c.some((q) => q.value === F)
|
|
1412
|
+
);
|
|
1413
|
+
x.length !== g.length && o(e, x, { shouldValidate: !1 });
|
|
1414
|
+
}
|
|
1415
|
+
}, [c, f, m, e, o, i, t.type]), t.type !== "multiselect")
|
|
1416
|
+
return null;
|
|
1417
|
+
const y = !!(a.validation?.required || a.validation?.requiredIf);
|
|
1418
|
+
return /* @__PURE__ */ d(
|
|
1419
|
+
T,
|
|
1420
|
+
{
|
|
1421
|
+
name: e,
|
|
1422
|
+
control: n,
|
|
1423
|
+
render: ({ field: { value: g, onChange: x, ...F }, fieldState: { error: q } }) => /* @__PURE__ */ d(
|
|
1424
|
+
u,
|
|
1425
|
+
{
|
|
1426
|
+
...F,
|
|
1427
|
+
multiple: !0,
|
|
1428
|
+
options: c,
|
|
1429
|
+
value: (
|
|
1430
|
+
// Convert string[] to Option[] for display
|
|
1431
|
+
Array.isArray(g) ? c.filter((S) => g.includes(S.value)) : []
|
|
1432
|
+
),
|
|
1433
|
+
onChange: (S, v) => {
|
|
1434
|
+
const w = v.map((A) => A.value);
|
|
1435
|
+
x(w);
|
|
1436
|
+
},
|
|
1437
|
+
isOptionEqualToValue: (S, v) => S.value === v.value,
|
|
1438
|
+
label: a.label,
|
|
1439
|
+
required: y,
|
|
1440
|
+
placeholder: a.placeholder,
|
|
1441
|
+
error: !!q,
|
|
1442
|
+
helperText: q?.message || a.helperText,
|
|
1443
|
+
disabled: r || a.disabled || f && !m,
|
|
1444
|
+
loading: f,
|
|
1445
|
+
size: l,
|
|
1446
|
+
inputValue: p,
|
|
1447
|
+
onInputChange: m,
|
|
1448
|
+
filterOptions: m ? (S) => S : void 0
|
|
1449
|
+
}
|
|
1450
|
+
)
|
|
1451
|
+
}
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1454
|
+
function Kt({ name: e, config: t, disabled: r }) {
|
|
1455
|
+
const { control: n, setValue: o, getValues: i } = k(), { components: s, size: l } = R(), u = s.Autocomplete, a = t, { options: c, isLoading: f, inputValue: p, onInputChange: m } = Y(
|
|
1456
|
+
t.type === "autocomplete" ? a.optionsSource : void 0,
|
|
1457
|
+
t.type === "autocomplete" ? a.options : void 0,
|
|
1458
|
+
t.type === "autocomplete" ? a.initialOptions : void 0
|
|
1459
|
+
);
|
|
1460
|
+
if (J(e, c), O(() => {
|
|
1461
|
+
if (t.type !== "autocomplete" || f || m) return;
|
|
1462
|
+
const g = i(e);
|
|
1463
|
+
g && !c.some((x) => x.value === g) && o(e, "", { shouldValidate: !1 });
|
|
1464
|
+
}, [c, f, m, e, o, i, t.type]), t.type !== "autocomplete")
|
|
1465
|
+
return null;
|
|
1466
|
+
const y = !!(a.validation?.required || a.validation?.requiredIf);
|
|
1467
|
+
return /* @__PURE__ */ d(
|
|
1468
|
+
T,
|
|
1469
|
+
{
|
|
1470
|
+
name: e,
|
|
1471
|
+
control: n,
|
|
1472
|
+
render: ({ field: { value: g, onChange: x, ...F }, fieldState: { error: q } }) => /* @__PURE__ */ d(
|
|
1473
|
+
u,
|
|
1474
|
+
{
|
|
1475
|
+
...F,
|
|
1476
|
+
options: c,
|
|
1477
|
+
value: c.find((S) => S.value === g) ?? null,
|
|
1478
|
+
onChange: (S, v) => {
|
|
1479
|
+
x(v?.value ?? "");
|
|
1480
|
+
},
|
|
1481
|
+
isOptionEqualToValue: (S, v) => S.value === v.value,
|
|
1482
|
+
label: a.label,
|
|
1483
|
+
required: y,
|
|
1484
|
+
placeholder: a.placeholder,
|
|
1485
|
+
error: !!q,
|
|
1486
|
+
helperText: q?.message || a.helperText,
|
|
1487
|
+
disabled: r || a.disabled || f && !m,
|
|
1488
|
+
loading: f,
|
|
1489
|
+
size: l,
|
|
1490
|
+
inputValue: p,
|
|
1491
|
+
onInputChange: m,
|
|
1492
|
+
filterOptions: m ? (S) => S : void 0
|
|
1493
|
+
}
|
|
1494
|
+
)
|
|
1495
|
+
}
|
|
1496
|
+
);
|
|
1497
|
+
}
|
|
1498
|
+
function Zt({ name: e, config: t, disabled: r }) {
|
|
1499
|
+
const { control: n, setValue: o, getValues: i } = k(), { components: s, size: l } = R(), u = s.RadioGroup, a = t, { options: c, isLoading: f } = Y(
|
|
1500
|
+
t.type === "radio" ? a.optionsSource : void 0,
|
|
1501
|
+
t.type === "radio" ? a.options : void 0
|
|
1502
|
+
);
|
|
1503
|
+
J(e, c);
|
|
1504
|
+
const p = c.map((y) => ({
|
|
1505
|
+
label: y.label,
|
|
1506
|
+
value: String(y.value)
|
|
1507
|
+
}));
|
|
1508
|
+
if (O(() => {
|
|
1509
|
+
if (t.type !== "radio") return;
|
|
1510
|
+
const y = i(e);
|
|
1511
|
+
y && !c.some((g) => String(g.value) === String(y)) && o(e, "", { shouldValidate: !1 });
|
|
1512
|
+
}, [c, e, o, i, t.type]), t.type !== "radio")
|
|
1513
|
+
return null;
|
|
1514
|
+
const m = !!(a.validation?.required || a.validation?.requiredIf);
|
|
1515
|
+
return f ? /* @__PURE__ */ d(Ke, { variant: "rectangular", height: 100 }) : /* @__PURE__ */ d(
|
|
1516
|
+
T,
|
|
1517
|
+
{
|
|
1518
|
+
name: e,
|
|
1519
|
+
control: n,
|
|
1520
|
+
render: ({ field: y, fieldState: { error: g } }) => /* @__PURE__ */ d(
|
|
1521
|
+
u,
|
|
1522
|
+
{
|
|
1523
|
+
...y,
|
|
1524
|
+
label: a.label,
|
|
1525
|
+
required: m,
|
|
1526
|
+
options: p,
|
|
1527
|
+
row: a.direction === "row",
|
|
1528
|
+
error: !!g,
|
|
1529
|
+
helperText: g?.message || a.helperText,
|
|
1530
|
+
disabled: r || a.disabled,
|
|
1531
|
+
size: l
|
|
1532
|
+
}
|
|
1533
|
+
)
|
|
1534
|
+
}
|
|
1535
|
+
);
|
|
1536
|
+
}
|
|
1537
|
+
function Gt({ name: e, config: t, disabled: r }) {
|
|
1538
|
+
const { control: n } = k(), { components: o, size: i } = R(), s = o.DatePicker, l = t;
|
|
1539
|
+
if (t.type !== "date")
|
|
1540
|
+
return null;
|
|
1541
|
+
const u = !!(l.validation?.required || l.validation?.requiredIf);
|
|
1542
|
+
return /* @__PURE__ */ d(
|
|
1543
|
+
T,
|
|
1544
|
+
{
|
|
1545
|
+
name: e,
|
|
1546
|
+
control: n,
|
|
1547
|
+
render: ({ field: { value: a, onChange: c }, fieldState: { error: f } }) => /* @__PURE__ */ d(
|
|
1548
|
+
s,
|
|
1549
|
+
{
|
|
1550
|
+
label: l.label,
|
|
1551
|
+
required: u,
|
|
1552
|
+
includeTime: l.includeTime,
|
|
1553
|
+
format: l.format,
|
|
1554
|
+
value: a || null,
|
|
1555
|
+
onChange: c,
|
|
1556
|
+
disabled: r || l.disabled,
|
|
1557
|
+
minDate: l.validation?.minDate,
|
|
1558
|
+
maxDate: l.validation?.maxDate,
|
|
1559
|
+
error: !!f,
|
|
1560
|
+
helperText: f?.message || l.helperText,
|
|
1561
|
+
size: i
|
|
1562
|
+
}
|
|
1563
|
+
)
|
|
1564
|
+
}
|
|
1565
|
+
);
|
|
1566
|
+
}
|
|
1567
|
+
function Ht({ name: e, config: t, disabled: r }) {
|
|
1568
|
+
const { control: n } = k(), { components: o, size: i } = R(), s = o.DateRangePicker, l = t;
|
|
1569
|
+
if (t.type !== "dateRange")
|
|
1570
|
+
return null;
|
|
1571
|
+
const u = !!(l.validation?.required || l.validation?.requiredIf);
|
|
1572
|
+
return /* @__PURE__ */ d(
|
|
1573
|
+
T,
|
|
1574
|
+
{
|
|
1575
|
+
name: e,
|
|
1576
|
+
control: n,
|
|
1577
|
+
render: ({ field: { value: a, onChange: c }, fieldState: { error: f } }) => /* @__PURE__ */ d(
|
|
1578
|
+
s,
|
|
1579
|
+
{
|
|
1580
|
+
label: l.label,
|
|
1581
|
+
required: u,
|
|
1582
|
+
includeTime: l.includeTime,
|
|
1583
|
+
format: l.format,
|
|
1584
|
+
value: a || { start: null, end: null },
|
|
1585
|
+
onChange: c,
|
|
1586
|
+
disabled: r || l.disabled,
|
|
1587
|
+
minDate: l.validation?.minDate,
|
|
1588
|
+
maxDate: l.validation?.maxDate,
|
|
1589
|
+
error: !!f,
|
|
1590
|
+
helperText: f?.message || l.helperText,
|
|
1591
|
+
size: i
|
|
1592
|
+
}
|
|
1593
|
+
)
|
|
1594
|
+
}
|
|
1595
|
+
);
|
|
1596
|
+
}
|
|
1597
|
+
function Yt({ name: e, config: t, disabled: r }) {
|
|
1598
|
+
const { control: n } = k(), { components: o } = R(), i = o.FileUpload, s = t;
|
|
1599
|
+
if (t.type !== "file")
|
|
1600
|
+
return null;
|
|
1601
|
+
const l = !!(s.validation?.required || s.validation?.requiredIf);
|
|
1602
|
+
return /* @__PURE__ */ d(
|
|
1603
|
+
T,
|
|
1604
|
+
{
|
|
1605
|
+
name: e,
|
|
1606
|
+
control: n,
|
|
1607
|
+
render: ({ field: { value: u, onChange: a, onBlur: c, ref: f }, fieldState: { error: p } }) => /* @__PURE__ */ d(
|
|
1608
|
+
i,
|
|
1609
|
+
{
|
|
1610
|
+
label: s.label,
|
|
1611
|
+
required: l,
|
|
1612
|
+
value: u || null,
|
|
1613
|
+
onChange: a,
|
|
1614
|
+
onBlur: c,
|
|
1615
|
+
disabled: r || s.disabled,
|
|
1616
|
+
multiple: s.multiple,
|
|
1617
|
+
accept: s.accept,
|
|
1618
|
+
error: !!p,
|
|
1619
|
+
helperText: p?.message || s.helperText,
|
|
1620
|
+
ref: f
|
|
1621
|
+
}
|
|
1622
|
+
)
|
|
1623
|
+
}
|
|
1624
|
+
);
|
|
1625
|
+
}
|
|
1626
|
+
const ke = {
|
|
1627
|
+
text: Z,
|
|
1628
|
+
password: Z,
|
|
1629
|
+
email: Z,
|
|
1630
|
+
textarea: Z,
|
|
1631
|
+
number: _t,
|
|
1632
|
+
checkbox: Ut,
|
|
1633
|
+
switch: Mt,
|
|
1634
|
+
select: Bt,
|
|
1635
|
+
multiselect: Wt,
|
|
1636
|
+
autocomplete: Kt,
|
|
1637
|
+
radio: Zt,
|
|
1638
|
+
date: Gt,
|
|
1639
|
+
dateRange: Ht,
|
|
1640
|
+
file: Yt
|
|
1641
|
+
};
|
|
1642
|
+
function Jt(e) {
|
|
1643
|
+
return ke[e] ?? null;
|
|
1644
|
+
}
|
|
1645
|
+
function hr(e, t) {
|
|
1646
|
+
ke[e] = t;
|
|
1647
|
+
}
|
|
1648
|
+
function Qt({ name: e, config: t, disabled: r }) {
|
|
1649
|
+
const n = Jt(t.type);
|
|
1650
|
+
return n ? /* @__PURE__ */ d(n, { name: e, config: t, disabled: r }) : (console.warn(`Unknown field type: ${t.type}`), /* @__PURE__ */ D(be, { severity: "warning", sx: { my: 1 }, children: [
|
|
1651
|
+
"Unknown field type: ",
|
|
1652
|
+
/* @__PURE__ */ d("code", { children: t.type })
|
|
1653
|
+
] }));
|
|
1654
|
+
}
|
|
1655
|
+
function Xt({ section: e, fields: t, disabled: r, visibleFields: n, slotProps: o }) {
|
|
1656
|
+
const i = e.fields.filter(
|
|
1657
|
+
(s) => n.has(s)
|
|
1658
|
+
);
|
|
1659
|
+
return i.length === 0 ? null : /* @__PURE__ */ D(V, { sx: _({ mb: 4 }, o?.root?.sx), children: [
|
|
1660
|
+
e.title && /* @__PURE__ */ d(I, { variant: "h6", sx: _({ mb: 2 }, o?.title?.sx), children: e.title }),
|
|
1661
|
+
e.description && /* @__PURE__ */ d(I, { variant: "body2", color: "text.secondary", sx: _({ mb: 2 }, o?.description?.sx), children: e.description }),
|
|
1662
|
+
/* @__PURE__ */ d(V, { sx: _({ display: "flex", flexDirection: "column", gap: 2 }, o?.content?.sx), children: i.map((s) => /* @__PURE__ */ d(
|
|
1663
|
+
Qt,
|
|
1664
|
+
{
|
|
1665
|
+
name: s,
|
|
1666
|
+
config: t[s],
|
|
1667
|
+
disabled: r
|
|
1668
|
+
},
|
|
1669
|
+
s
|
|
1670
|
+
)) })
|
|
1671
|
+
] });
|
|
1672
|
+
}
|
|
1673
|
+
class er extends $e {
|
|
1674
|
+
constructor(t) {
|
|
1675
|
+
super(t), this.handleReset = () => {
|
|
1676
|
+
this.setState({ hasError: !1, error: null });
|
|
1677
|
+
}, this.state = { hasError: !1, error: null };
|
|
1678
|
+
}
|
|
1679
|
+
static getDerivedStateFromError(t) {
|
|
1680
|
+
return { hasError: !0, error: t };
|
|
1681
|
+
}
|
|
1682
|
+
componentDidCatch(t, r) {
|
|
1683
|
+
console.error("DynamicForm Error:", t, r), this.props.onError?.(t, r);
|
|
1684
|
+
}
|
|
1685
|
+
render() {
|
|
1686
|
+
return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ D(V, { sx: { p: 3 }, children: [
|
|
1687
|
+
/* @__PURE__ */ D(be, { severity: "error", sx: { mb: 2 }, children: [
|
|
1688
|
+
/* @__PURE__ */ d(I, { variant: "h6", gutterBottom: !0, children: "Form Error" }),
|
|
1689
|
+
/* @__PURE__ */ d(I, { variant: "body2", sx: { mb: 2 }, children: "Something went wrong while rendering the form." }),
|
|
1690
|
+
this.state.error && /* @__PURE__ */ d(I, { variant: "caption", sx: { fontFamily: "monospace" }, children: this.state.error.message })
|
|
1691
|
+
] }),
|
|
1692
|
+
/* @__PURE__ */ d(Ze, { variant: "outlined", onClick: this.handleReset, children: "Reset Form" })
|
|
1693
|
+
] }) : this.props.children;
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
function tr({
|
|
1697
|
+
schema: e,
|
|
1698
|
+
mode: t,
|
|
1699
|
+
sectionSlotProps: r,
|
|
1700
|
+
children: n,
|
|
1701
|
+
formState: o
|
|
1702
|
+
}) {
|
|
1703
|
+
const i = qt(e), s = t === "disabled", l = new Map(e.sections.map((c) => [c.id, c])), u = (c) => {
|
|
1704
|
+
const f = l.get(c);
|
|
1705
|
+
return f ? /* @__PURE__ */ d(
|
|
1706
|
+
Xt,
|
|
1707
|
+
{
|
|
1708
|
+
section: f,
|
|
1709
|
+
fields: e.fields,
|
|
1710
|
+
disabled: s,
|
|
1711
|
+
visibleFields: i,
|
|
1712
|
+
slotProps: r
|
|
1713
|
+
},
|
|
1714
|
+
f.id
|
|
1715
|
+
) : null;
|
|
1716
|
+
}, a = (c, f) => {
|
|
1717
|
+
const p = c.columns ?? c.sections.length;
|
|
1718
|
+
return p <= 1 ? /* @__PURE__ */ d(V, { children: c.sections.map(u) }, f) : /* @__PURE__ */ d(
|
|
1719
|
+
V,
|
|
1720
|
+
{
|
|
1721
|
+
sx: {
|
|
1722
|
+
display: "grid",
|
|
1723
|
+
gridTemplateColumns: {
|
|
1724
|
+
xs: "1fr",
|
|
1725
|
+
md: `repeat(${p}, 1fr)`
|
|
1726
|
+
},
|
|
1727
|
+
gap: 3,
|
|
1728
|
+
alignItems: "start"
|
|
1729
|
+
},
|
|
1730
|
+
children: c.sections.map(u)
|
|
1731
|
+
},
|
|
1732
|
+
f
|
|
1733
|
+
);
|
|
1734
|
+
};
|
|
1735
|
+
return /* @__PURE__ */ D(Pe, { children: [
|
|
1736
|
+
e.layout ? e.layout.map(a) : e.sections.map((c) => u(c.id)),
|
|
1737
|
+
typeof n == "function" ? n(o) : n
|
|
1738
|
+
] });
|
|
1739
|
+
}
|
|
1740
|
+
function gr({
|
|
1741
|
+
schema: e,
|
|
1742
|
+
onSubmit: t,
|
|
1743
|
+
mode: r = "edit",
|
|
1744
|
+
defaultValues: n,
|
|
1745
|
+
apiClient: o,
|
|
1746
|
+
size: i,
|
|
1747
|
+
sectionSlotProps: s,
|
|
1748
|
+
children: l
|
|
1749
|
+
}) {
|
|
1750
|
+
const u = R(), a = !!(o || i !== void 0), c = G(() => a ? {
|
|
1751
|
+
...u,
|
|
1752
|
+
...o && { apiClient: o },
|
|
1753
|
+
...i !== void 0 && { size: i }
|
|
1754
|
+
} : u, [u, o, i, a]), f = G(
|
|
1755
|
+
() => wt(u.sectionSlotProps, s),
|
|
1756
|
+
[u.sectionSlotProps, s]
|
|
1757
|
+
), p = H(/* @__PURE__ */ new Map()), m = G(
|
|
1758
|
+
() => ({
|
|
1759
|
+
register: (v, w) => {
|
|
1760
|
+
p.current.set(v, w);
|
|
1761
|
+
},
|
|
1762
|
+
unregister: (v) => {
|
|
1763
|
+
p.current.delete(v);
|
|
1764
|
+
},
|
|
1765
|
+
buildLabelMap: () => {
|
|
1766
|
+
const v = {};
|
|
1767
|
+
for (const [w, A] of p.current.entries()) {
|
|
1768
|
+
if (A.length === 0) continue;
|
|
1769
|
+
const N = {};
|
|
1770
|
+
for (const P of A)
|
|
1771
|
+
N[String(P.value)] = P.label;
|
|
1772
|
+
v[w] = N;
|
|
1773
|
+
}
|
|
1774
|
+
return v;
|
|
1775
|
+
}
|
|
1776
|
+
}),
|
|
1777
|
+
[]
|
|
1778
|
+
), y = z(
|
|
1779
|
+
(v) => t(v, m.buildLabelMap()),
|
|
1780
|
+
[t, m]
|
|
1781
|
+
), g = jt(e), x = Dt(e), F = et({
|
|
1782
|
+
resolver: g,
|
|
1783
|
+
defaultValues: { ...x, ...n },
|
|
1784
|
+
mode: "onChange",
|
|
1785
|
+
reValidateMode: "onChange"
|
|
1786
|
+
}), q = {
|
|
1787
|
+
isValid: F.formState.isValid,
|
|
1788
|
+
isSubmitting: F.formState.isSubmitting
|
|
1789
|
+
}, S = /* @__PURE__ */ d(er, { children: /* @__PURE__ */ d(tt, { ...F, children: /* @__PURE__ */ d(Ie, { value: m, children: /* @__PURE__ */ d(
|
|
1790
|
+
V,
|
|
1791
|
+
{
|
|
1792
|
+
component: "form",
|
|
1793
|
+
onSubmit: F.handleSubmit(
|
|
1794
|
+
y,
|
|
1795
|
+
(v) => {
|
|
1796
|
+
console.error("❌ Form validation errors:", v);
|
|
1797
|
+
}
|
|
1798
|
+
),
|
|
1799
|
+
noValidate: !0,
|
|
1800
|
+
children: /* @__PURE__ */ d(
|
|
1801
|
+
tr,
|
|
1802
|
+
{
|
|
1803
|
+
schema: e,
|
|
1804
|
+
mode: r,
|
|
1805
|
+
sectionSlotProps: f,
|
|
1806
|
+
children: l,
|
|
1807
|
+
formState: q
|
|
1808
|
+
}
|
|
1809
|
+
)
|
|
1810
|
+
}
|
|
1811
|
+
) }) }) });
|
|
1812
|
+
return a ? /* @__PURE__ */ d(ae, { value: c, children: S }) : S;
|
|
1813
|
+
}
|
|
1814
|
+
export {
|
|
1815
|
+
gr as DynamicForm,
|
|
1816
|
+
pr as DynamicFormsProvider,
|
|
1817
|
+
er as FormErrorBoundary,
|
|
1818
|
+
St as areDependenciesFilled,
|
|
1819
|
+
vt as buildOptionsUrl,
|
|
1820
|
+
ht as buildZodSchema,
|
|
1821
|
+
U as evaluateCondition,
|
|
1822
|
+
Dt as extractDefaultValues,
|
|
1823
|
+
Ft as extractOptionsDependencies,
|
|
1824
|
+
dt as formatFileSize,
|
|
1825
|
+
ne as isEmpty,
|
|
1826
|
+
hr as registerFieldComponent,
|
|
1827
|
+
Ct as useAsyncValidation,
|
|
1828
|
+
R as useDynamicFormsContext,
|
|
1829
|
+
qt as useFieldVisibility,
|
|
1830
|
+
Y as useOptionsSource
|
|
1831
|
+
};
|