@formatica/react 0.2.1 → 0.2.3
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 +264 -25
- package/dist/components/FormBuilder.d.ts +1 -1
- package/dist/components/FormBuilder.d.ts.map +1 -1
- package/dist/components/FormaticaProvider.d.ts +1 -1
- package/dist/components/FormaticaProvider.d.ts.map +1 -1
- package/dist/formatica-react.es.js +356 -354
- package/dist/formatica-react.es.js.map +1 -1
- package/dist/formatica-react.umd.cjs +1 -1
- package/dist/formatica-react.umd.cjs.map +1 -1
- package/dist/hooks/useForm.d.ts.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { extractFields as oe, evaluateCondition as le, getRule as ie, isFieldNode as L } from "@formatica/core";
|
|
2
2
|
export * from "@formatica/core";
|
|
3
|
-
import { useRef as A, useState as F, useCallback as D, createContext as B, useContext as ee, useEffect as re } from "react";
|
|
4
3
|
import { jsx as t, jsxs as y } from "react/jsx-runtime";
|
|
5
|
-
|
|
4
|
+
import { createContext as B, useContext as ee, useRef as A, useState as F, useCallback as D, useEffect as re } from "react";
|
|
5
|
+
const te = B({});
|
|
6
|
+
function Me({
|
|
7
|
+
config: e,
|
|
8
|
+
children: n
|
|
9
|
+
}) {
|
|
10
|
+
return /* @__PURE__ */ t(te.Provider, { value: e, children: n });
|
|
11
|
+
}
|
|
12
|
+
function ce() {
|
|
13
|
+
return ee(te);
|
|
14
|
+
}
|
|
15
|
+
function ue(e) {
|
|
6
16
|
switch (e.type) {
|
|
7
17
|
case "tags":
|
|
8
18
|
case "checkbox-group":
|
|
@@ -18,13 +28,13 @@ function ce(e) {
|
|
|
18
28
|
return "";
|
|
19
29
|
}
|
|
20
30
|
}
|
|
21
|
-
function
|
|
31
|
+
function de(e) {
|
|
22
32
|
const n = {};
|
|
23
33
|
for (const a of e)
|
|
24
|
-
n[a.name] = a.defaultValue ??
|
|
34
|
+
n[a.name] = a.defaultValue ?? ue(a);
|
|
25
35
|
return n;
|
|
26
36
|
}
|
|
27
|
-
function
|
|
37
|
+
function fe(e) {
|
|
28
38
|
return e ? typeof e == "string" ? e.split("|").map(Z) : Array.isArray(e) ? e.map(Z) : Object.entries(e).filter(([, n]) => n !== !1 && n !== void 0).map(([n, a]) => ({
|
|
29
39
|
name: n,
|
|
30
40
|
params: typeof a == "object" && a !== null ? a : { [n]: a }
|
|
@@ -45,10 +55,10 @@ function Z(e) {
|
|
|
45
55
|
}
|
|
46
56
|
return { name: n, params: s };
|
|
47
57
|
}
|
|
48
|
-
function
|
|
49
|
-
const a = oe(e.fields), r = A(
|
|
58
|
+
function me(e, n) {
|
|
59
|
+
const a = oe(e.fields), r = A(de(a)), s = A(a), [o, l] = F(() => ({
|
|
50
60
|
...r.current
|
|
51
|
-
})), [u, i] = F({}), [f, d] = F({}), [g, m] = F({}), [h, v] = F(!1), [
|
|
61
|
+
})), [u, i] = F({}), [f, d] = F({}), [g, m] = F({}), [h, v] = F(!1), [p, b] = F(0), S = A(o);
|
|
52
62
|
S.current = o;
|
|
53
63
|
const $ = A(u);
|
|
54
64
|
$.current = u;
|
|
@@ -56,26 +66,26 @@ function fe(e, n) {
|
|
|
56
66
|
l((N) => ({ ...N, [x]: C })), m((N) => ({ ...N, [x]: !0 }));
|
|
57
67
|
}, []), M = D((x) => S.current[x], []), k = D(
|
|
58
68
|
async (x, C) => {
|
|
59
|
-
const N = s.current.find((
|
|
69
|
+
const N = s.current.find((I) => I.name === x);
|
|
60
70
|
if (!N) return [];
|
|
61
71
|
if (N.condition && !le(N.condition, C))
|
|
62
72
|
return [];
|
|
63
|
-
const T =
|
|
64
|
-
N.required && !T.some((
|
|
73
|
+
const T = fe(N.rules);
|
|
74
|
+
N.required && !T.some((I) => I.name === "required") && T.unshift({ name: "required", params: {} });
|
|
65
75
|
const K = [], se = {
|
|
66
76
|
values: C,
|
|
67
|
-
getFieldValue: (
|
|
77
|
+
getFieldValue: (I) => C[I]
|
|
68
78
|
};
|
|
69
|
-
for (const
|
|
70
|
-
const G = ie(
|
|
79
|
+
for (const I of T) {
|
|
80
|
+
const G = ie(I.name);
|
|
71
81
|
if (!G) continue;
|
|
72
|
-
const W = await G(C[x],
|
|
82
|
+
const W = await G(C[x], I.params, se);
|
|
73
83
|
typeof W == "string" && K.push(W);
|
|
74
84
|
}
|
|
75
85
|
return K;
|
|
76
86
|
},
|
|
77
87
|
[]
|
|
78
|
-
),
|
|
88
|
+
), O = D(
|
|
79
89
|
async (x) => {
|
|
80
90
|
const C = await k(x, S.current);
|
|
81
91
|
return i((N) => ({ ...N, [x]: C })), d((N) => ({ ...N, [x]: !0 })), C.length === 0;
|
|
@@ -91,7 +101,7 @@ function fe(e, n) {
|
|
|
91
101
|
return i(C), N;
|
|
92
102
|
}, [k]), q = D(
|
|
93
103
|
async (x) => {
|
|
94
|
-
v(!0),
|
|
104
|
+
v(!0), b((N) => N + 1);
|
|
95
105
|
const C = {};
|
|
96
106
|
for (const N of s.current)
|
|
97
107
|
C[N.name] = !0;
|
|
@@ -130,10 +140,10 @@ function fe(e, n) {
|
|
|
130
140
|
isValid: j,
|
|
131
141
|
isDirty: E,
|
|
132
142
|
isSubmitting: h,
|
|
133
|
-
submitCount:
|
|
143
|
+
submitCount: p,
|
|
134
144
|
setFieldValue: R,
|
|
135
145
|
validate: z,
|
|
136
|
-
validateField:
|
|
146
|
+
validateField: O,
|
|
137
147
|
submit: q,
|
|
138
148
|
reset: _,
|
|
139
149
|
clear: U,
|
|
@@ -143,23 +153,13 @@ function fe(e, n) {
|
|
|
143
153
|
getFieldValue: M
|
|
144
154
|
};
|
|
145
155
|
}
|
|
146
|
-
const
|
|
147
|
-
function
|
|
148
|
-
const e = ee(
|
|
156
|
+
const ne = B(null);
|
|
157
|
+
function Ve() {
|
|
158
|
+
const e = ee(ne);
|
|
149
159
|
if (!e) throw new Error("useFormContext must be used within a FormProvider");
|
|
150
160
|
return e;
|
|
151
161
|
}
|
|
152
|
-
|
|
153
|
-
function Me({
|
|
154
|
-
config: e,
|
|
155
|
-
children: n
|
|
156
|
-
}) {
|
|
157
|
-
return /* @__PURE__ */ t(ne.Provider, { value: e, children: n });
|
|
158
|
-
}
|
|
159
|
-
function me() {
|
|
160
|
-
return ee(ne);
|
|
161
|
-
}
|
|
162
|
-
function be({
|
|
162
|
+
function pe({
|
|
163
163
|
label: e,
|
|
164
164
|
required: n,
|
|
165
165
|
errors: a,
|
|
@@ -173,7 +173,7 @@ function be({
|
|
|
173
173
|
className: d,
|
|
174
174
|
style: g
|
|
175
175
|
}) {
|
|
176
|
-
const [m, h] = F(!1), v = r && a !== void 0 && a.length > 0,
|
|
176
|
+
const [m, h] = F(!1), v = r && a !== void 0 && a.length > 0, p = i ? `fc-field-${i}` : void 0, b = i ? `fc-error-${i}` : void 0;
|
|
177
177
|
return /* @__PURE__ */ y(
|
|
178
178
|
"div",
|
|
179
179
|
{
|
|
@@ -181,7 +181,7 @@ function be({
|
|
|
181
181
|
style: g,
|
|
182
182
|
children: [
|
|
183
183
|
e && /* @__PURE__ */ y("div", { className: "mb-1.5 flex items-center gap-1", children: [
|
|
184
|
-
/* @__PURE__ */ y("label", { htmlFor:
|
|
184
|
+
/* @__PURE__ */ y("label", { htmlFor: p, className: "block text-sm font-medium text-gray-700", children: [
|
|
185
185
|
e,
|
|
186
186
|
n && /* @__PURE__ */ t("span", { className: "text-red-500 ml-0.5", "aria-hidden": "true", children: "*" })
|
|
187
187
|
] }),
|
|
@@ -219,11 +219,11 @@ function be({
|
|
|
219
219
|
}
|
|
220
220
|
)
|
|
221
221
|
] }),
|
|
222
|
-
/* @__PURE__ */ t("div", { id:
|
|
222
|
+
/* @__PURE__ */ t("div", { id: p, children: f }),
|
|
223
223
|
v && /* @__PURE__ */ t("div", { children: a.map((S, $) => /* @__PURE__ */ t(
|
|
224
224
|
"p",
|
|
225
225
|
{
|
|
226
|
-
id: $ === 0 ?
|
|
226
|
+
id: $ === 0 ? b : void 0,
|
|
227
227
|
className: "mt-1 text-xs text-red-500",
|
|
228
228
|
role: "alert",
|
|
229
229
|
children: S
|
|
@@ -235,47 +235,71 @@ function be({
|
|
|
235
235
|
}
|
|
236
236
|
);
|
|
237
237
|
}
|
|
238
|
-
|
|
239
|
-
function J({
|
|
238
|
+
function be({
|
|
240
239
|
value: e,
|
|
241
240
|
onChange: n,
|
|
242
241
|
onBlur: a,
|
|
243
242
|
disabled: r,
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
readOnly: l,
|
|
247
|
-
prefix: u,
|
|
248
|
-
suffix: i,
|
|
249
|
-
maxLength: f,
|
|
250
|
-
className: d
|
|
243
|
+
label: s,
|
|
244
|
+
className: o
|
|
251
245
|
}) {
|
|
252
|
-
|
|
253
|
-
|
|
246
|
+
function l() {
|
|
247
|
+
r || n(!e);
|
|
248
|
+
}
|
|
249
|
+
function u(i) {
|
|
250
|
+
(i.key === " " || i.key === "Enter") && (i.preventDefault(), l());
|
|
251
|
+
}
|
|
252
|
+
return /* @__PURE__ */ y(
|
|
253
|
+
"label",
|
|
254
254
|
{
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
255
|
+
className: `inline-flex items-center gap-2 select-none ${r ? "opacity-50 cursor-not-allowed" : "cursor-pointer"} ${o ?? ""}`,
|
|
256
|
+
children: [
|
|
257
|
+
/* @__PURE__ */ t(
|
|
258
|
+
"input",
|
|
259
|
+
{
|
|
260
|
+
type: "checkbox",
|
|
261
|
+
checked: e ?? !1,
|
|
262
|
+
onChange: () => {
|
|
263
|
+
},
|
|
264
|
+
onBlur: a,
|
|
265
|
+
disabled: r,
|
|
266
|
+
className: "sr-only"
|
|
267
|
+
}
|
|
268
|
+
),
|
|
269
|
+
/* @__PURE__ */ t(
|
|
270
|
+
"div",
|
|
271
|
+
{
|
|
272
|
+
role: "checkbox",
|
|
273
|
+
"aria-checked": e,
|
|
274
|
+
"aria-disabled": r || void 0,
|
|
275
|
+
tabIndex: 0,
|
|
276
|
+
className: `flex h-5 w-5 shrink-0 items-center justify-center rounded border-2 transition-colors duration-200 ${e ? "text-white" : "border-gray-300 bg-white"}`,
|
|
277
|
+
style: e ? {
|
|
278
|
+
borderColor: "var(--fc-color-primary, #3b82f6)",
|
|
279
|
+
backgroundColor: "var(--fc-color-primary, #3b82f6)"
|
|
280
|
+
} : {},
|
|
281
|
+
onClick: (i) => {
|
|
282
|
+
i.preventDefault(), l();
|
|
283
|
+
},
|
|
284
|
+
onKeyDown: u,
|
|
285
|
+
children: e && /* @__PURE__ */ t(
|
|
286
|
+
"svg",
|
|
287
|
+
{
|
|
288
|
+
className: "h-3 w-3",
|
|
289
|
+
viewBox: "0 0 12 12",
|
|
290
|
+
fill: "none",
|
|
291
|
+
stroke: "currentColor",
|
|
292
|
+
strokeWidth: "2",
|
|
293
|
+
"aria-hidden": "true",
|
|
294
|
+
children: /* @__PURE__ */ t("path", { d: "M2 6l3 3 5-5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
295
|
+
}
|
|
296
|
+
)
|
|
297
|
+
}
|
|
298
|
+
),
|
|
299
|
+
s && /* @__PURE__ */ t("span", { className: "text-sm text-gray-700", children: s })
|
|
300
|
+
]
|
|
272
301
|
}
|
|
273
302
|
);
|
|
274
|
-
return u || i ? /* @__PURE__ */ y("div", { className: "flex items-stretch", children: [
|
|
275
|
-
u && /* @__PURE__ */ t("span", { className: "inline-flex items-center rounded-l-md border border-r-0 border-gray-300 bg-gray-50 px-3 text-sm text-gray-500", children: u }),
|
|
276
|
-
b,
|
|
277
|
-
i && /* @__PURE__ */ t("span", { className: "inline-flex items-center rounded-r-md border border-l-0 border-gray-300 bg-gray-50 px-3 text-sm text-gray-500", children: i })
|
|
278
|
-
] }) : b;
|
|
279
303
|
}
|
|
280
304
|
const ge = "w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500/20 transition-colors duration-200 fc-number-input";
|
|
281
305
|
function ye({
|
|
@@ -293,7 +317,7 @@ function ye({
|
|
|
293
317
|
suffix: g,
|
|
294
318
|
className: m
|
|
295
319
|
}) {
|
|
296
|
-
const
|
|
320
|
+
const b = `${ge} ${r ? "opacity-50 cursor-not-allowed bg-gray-100" : ""} ${d ? "rounded-l-none" : ""} ${g ? "rounded-r-none" : ""} ${m ?? ""}`.trim();
|
|
297
321
|
function S(j) {
|
|
298
322
|
const E = j.target.value;
|
|
299
323
|
if (E === "") {
|
|
@@ -307,7 +331,7 @@ function ye({
|
|
|
307
331
|
"input",
|
|
308
332
|
{
|
|
309
333
|
type: "number",
|
|
310
|
-
className:
|
|
334
|
+
className: b,
|
|
311
335
|
value: e ?? "",
|
|
312
336
|
onChange: S,
|
|
313
337
|
onFocus: (j) => {
|
|
@@ -332,54 +356,81 @@ function ye({
|
|
|
332
356
|
g && /* @__PURE__ */ t("span", { className: "inline-flex items-center rounded-r-md border border-l-0 border-gray-300 bg-gray-50 px-3 text-sm text-gray-500", children: g })
|
|
333
357
|
] }) : $;
|
|
334
358
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
value:
|
|
338
|
-
onChange:
|
|
339
|
-
onBlur:
|
|
340
|
-
disabled:
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
autoResize: u,
|
|
345
|
-
maxLength: i,
|
|
346
|
-
className: f
|
|
359
|
+
function he({
|
|
360
|
+
name: e,
|
|
361
|
+
value: n,
|
|
362
|
+
onChange: a,
|
|
363
|
+
onBlur: r,
|
|
364
|
+
disabled: s,
|
|
365
|
+
options: o,
|
|
366
|
+
inline: l = !1,
|
|
367
|
+
className: u
|
|
347
368
|
}) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
369
|
+
function i(m) {
|
|
370
|
+
return n === m;
|
|
371
|
+
}
|
|
372
|
+
function f(m) {
|
|
373
|
+
return s === !0 || !!m.disabled;
|
|
374
|
+
}
|
|
375
|
+
function d(m) {
|
|
376
|
+
f(m) || a(m.value);
|
|
377
|
+
}
|
|
378
|
+
function g(m, h) {
|
|
379
|
+
(m.key === " " || m.key === "Enter") && (m.preventDefault(), d(h));
|
|
380
|
+
}
|
|
357
381
|
return /* @__PURE__ */ t(
|
|
358
|
-
"
|
|
382
|
+
"div",
|
|
359
383
|
{
|
|
360
|
-
|
|
361
|
-
className:
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
384
|
+
role: "radiogroup",
|
|
385
|
+
className: `${l ? "flex flex-wrap gap-4" : "flex flex-col gap-2"} ${u ?? ""}`,
|
|
386
|
+
children: o.map((m) => /* @__PURE__ */ y(
|
|
387
|
+
"label",
|
|
388
|
+
{
|
|
389
|
+
className: `inline-flex items-center gap-2 select-none ${f(m) ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}`,
|
|
390
|
+
children: [
|
|
391
|
+
/* @__PURE__ */ t(
|
|
392
|
+
"input",
|
|
393
|
+
{
|
|
394
|
+
type: "radio",
|
|
395
|
+
checked: i(m.value),
|
|
396
|
+
disabled: f(m),
|
|
397
|
+
className: "sr-only",
|
|
398
|
+
name: e,
|
|
399
|
+
onChange: () => d(m),
|
|
400
|
+
onBlur: r
|
|
401
|
+
}
|
|
402
|
+
),
|
|
403
|
+
/* @__PURE__ */ t(
|
|
404
|
+
"div",
|
|
405
|
+
{
|
|
406
|
+
role: "radio",
|
|
407
|
+
"aria-checked": i(m.value),
|
|
408
|
+
"aria-disabled": f(m) || void 0,
|
|
409
|
+
tabIndex: 0,
|
|
410
|
+
className: `flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 transition-colors duration-200 ${i(m.value) ? "" : "border-gray-300"}`,
|
|
411
|
+
style: i(m.value) ? { borderColor: "var(--fc-color-primary, #3b82f6)" } : {},
|
|
412
|
+
onClick: () => d(m),
|
|
413
|
+
onKeyDown: (h) => g(h, m),
|
|
414
|
+
children: i(m.value) && /* @__PURE__ */ t(
|
|
415
|
+
"div",
|
|
416
|
+
{
|
|
417
|
+
className: "h-2.5 w-2.5 rounded-full",
|
|
418
|
+
style: {
|
|
419
|
+
backgroundColor: "var(--fc-color-primary, #3b82f6)"
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
)
|
|
423
|
+
}
|
|
424
|
+
),
|
|
425
|
+
/* @__PURE__ */ t("span", { className: "text-sm text-gray-700", children: m.label })
|
|
426
|
+
]
|
|
427
|
+
},
|
|
428
|
+
String(m.value)
|
|
429
|
+
))
|
|
379
430
|
}
|
|
380
431
|
);
|
|
381
432
|
}
|
|
382
|
-
function
|
|
433
|
+
function xe({
|
|
383
434
|
value: e,
|
|
384
435
|
onChange: n,
|
|
385
436
|
onBlur: a,
|
|
@@ -391,7 +442,7 @@ function ve({
|
|
|
391
442
|
clearable: i = !1,
|
|
392
443
|
className: f
|
|
393
444
|
}) {
|
|
394
|
-
const [d, g] = F(!1), [m, h] = F(""), [v,
|
|
445
|
+
const [d, g] = F(!1), [m, h] = F(""), [v, p] = F(-1), b = A(null), S = A(null), $ = e == null ? [] : Array.isArray(e) ? e : [e], j = (() => {
|
|
395
446
|
if ($.length === 0 || l) return "";
|
|
396
447
|
const c = o.find((w) => w.value === $[0]);
|
|
397
448
|
return (c == null ? void 0 : c.label) ?? String($[0]);
|
|
@@ -404,15 +455,15 @@ function ve({
|
|
|
404
455
|
return (w == null ? void 0 : w.label) ?? String(c);
|
|
405
456
|
}
|
|
406
457
|
const k = D(() => {
|
|
407
|
-
g(!0),
|
|
458
|
+
g(!0), p(-1), h(""), setTimeout(() => {
|
|
408
459
|
var c;
|
|
409
460
|
return (c = S.current) == null ? void 0 : c.focus();
|
|
410
461
|
}, 0);
|
|
411
|
-
}, []),
|
|
462
|
+
}, []), O = D(() => {
|
|
412
463
|
g(!1), h(""), a == null || a();
|
|
413
464
|
}, [a]);
|
|
414
465
|
function z() {
|
|
415
|
-
r || (d ?
|
|
466
|
+
r || (d ? O() : k());
|
|
416
467
|
}
|
|
417
468
|
function q(c) {
|
|
418
469
|
if (!c.disabled)
|
|
@@ -420,7 +471,7 @@ function ve({
|
|
|
420
471
|
const w = [...$], x = w.indexOf(c.value);
|
|
421
472
|
x >= 0 ? w.splice(x, 1) : w.push(c.value), n(w);
|
|
422
473
|
} else
|
|
423
|
-
n(c.value),
|
|
474
|
+
n(c.value), O();
|
|
424
475
|
}
|
|
425
476
|
function _(c) {
|
|
426
477
|
if (r) return;
|
|
@@ -437,28 +488,28 @@ function ve({
|
|
|
437
488
|
}
|
|
438
489
|
switch (c.key) {
|
|
439
490
|
case "ArrowDown":
|
|
440
|
-
c.preventDefault(),
|
|
491
|
+
c.preventDefault(), p((w) => Math.min(w + 1, E.length - 1));
|
|
441
492
|
break;
|
|
442
493
|
case "ArrowUp":
|
|
443
|
-
c.preventDefault(),
|
|
494
|
+
c.preventDefault(), p((w) => Math.max(w - 1, 0));
|
|
444
495
|
break;
|
|
445
496
|
case "Enter":
|
|
446
497
|
c.preventDefault(), v >= 0 && E[v] && q(E[v]);
|
|
447
498
|
break;
|
|
448
499
|
case "Escape":
|
|
449
|
-
c.preventDefault(),
|
|
500
|
+
c.preventDefault(), O();
|
|
450
501
|
break;
|
|
451
502
|
}
|
|
452
503
|
}
|
|
453
504
|
return re(() => {
|
|
454
505
|
function c(w) {
|
|
455
|
-
|
|
506
|
+
b.current && !b.current.contains(w.target) && O();
|
|
456
507
|
}
|
|
457
508
|
return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
|
|
458
|
-
}, [
|
|
509
|
+
}, [O]), /* @__PURE__ */ y(
|
|
459
510
|
"div",
|
|
460
511
|
{
|
|
461
|
-
ref:
|
|
512
|
+
ref: b,
|
|
462
513
|
className: `relative w-full ${r ? "opacity-50 cursor-not-allowed" : ""} ${f ?? ""}`,
|
|
463
514
|
children: [
|
|
464
515
|
/* @__PURE__ */ y(
|
|
@@ -566,7 +617,7 @@ function ve({
|
|
|
566
617
|
color: "var(--fc-color-primary, #3b82f6)"
|
|
567
618
|
} : {},
|
|
568
619
|
onClick: () => q(c),
|
|
569
|
-
onMouseEnter: () =>
|
|
620
|
+
onMouseEnter: () => p(w),
|
|
570
621
|
children: c.label
|
|
571
622
|
},
|
|
572
623
|
String(c.value)
|
|
@@ -578,147 +629,66 @@ function ve({
|
|
|
578
629
|
}
|
|
579
630
|
);
|
|
580
631
|
}
|
|
581
|
-
function
|
|
632
|
+
function ve({
|
|
582
633
|
value: e,
|
|
583
634
|
onChange: n,
|
|
584
635
|
onBlur: a,
|
|
585
636
|
disabled: r,
|
|
586
|
-
|
|
587
|
-
|
|
637
|
+
min: s = 0,
|
|
638
|
+
max: o = 100,
|
|
639
|
+
step: l = 1,
|
|
640
|
+
showTooltip: u = !0,
|
|
641
|
+
className: i
|
|
588
642
|
}) {
|
|
589
|
-
|
|
590
|
-
r || n(!e);
|
|
591
|
-
}
|
|
592
|
-
function u(i) {
|
|
593
|
-
(i.key === " " || i.key === "Enter") && (i.preventDefault(), l());
|
|
594
|
-
}
|
|
643
|
+
const [f, d] = F(!1), g = e ?? s, m = o - s, h = m === 0 ? 0 : (g - s) / m * 100;
|
|
595
644
|
return /* @__PURE__ */ y(
|
|
596
|
-
"
|
|
645
|
+
"div",
|
|
597
646
|
{
|
|
598
|
-
className: `
|
|
647
|
+
className: `relative w-full py-2 ${r ? "opacity-50 cursor-not-allowed" : ""} ${i ?? ""}`,
|
|
599
648
|
children: [
|
|
600
|
-
/* @__PURE__ */ t(
|
|
601
|
-
"
|
|
649
|
+
u && f && /* @__PURE__ */ t(
|
|
650
|
+
"div",
|
|
602
651
|
{
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
},
|
|
607
|
-
onBlur: a,
|
|
608
|
-
disabled: r,
|
|
609
|
-
className: "sr-only"
|
|
652
|
+
className: "absolute -top-8 rounded bg-gray-800 px-2 py-1 text-xs text-white shadow-sm transition-opacity duration-200",
|
|
653
|
+
style: { left: `calc(${h}% - 16px)` },
|
|
654
|
+
children: g
|
|
610
655
|
}
|
|
611
656
|
),
|
|
612
657
|
/* @__PURE__ */ t(
|
|
613
|
-
"
|
|
658
|
+
"input",
|
|
614
659
|
{
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
i.preventDefault(), l();
|
|
660
|
+
type: "range",
|
|
661
|
+
value: g,
|
|
662
|
+
onChange: (v) => n(Number.parseFloat(v.target.value)),
|
|
663
|
+
onMouseDown: () => d(!0),
|
|
664
|
+
onMouseUp: () => d(!1),
|
|
665
|
+
onTouchStart: () => d(!0),
|
|
666
|
+
onTouchEnd: () => d(!1),
|
|
667
|
+
onFocus: () => d(!0),
|
|
668
|
+
onBlur: (v) => {
|
|
669
|
+
d(!1), a == null || a();
|
|
626
670
|
},
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
children: /* @__PURE__ */ t("path", { d: "M2 6l3 3 5-5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
638
|
-
}
|
|
639
|
-
)
|
|
671
|
+
disabled: r,
|
|
672
|
+
min: s,
|
|
673
|
+
max: o,
|
|
674
|
+
step: l,
|
|
675
|
+
"aria-valuenow": g,
|
|
676
|
+
"aria-valuemin": s,
|
|
677
|
+
"aria-valuemax": o,
|
|
678
|
+
"aria-disabled": r || void 0,
|
|
679
|
+
className: "h-2 w-full cursor-pointer appearance-none rounded-full bg-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500/20 disabled:pointer-events-none",
|
|
680
|
+
style: { accentColor: "var(--fc-color-primary, #3b82f6)" }
|
|
640
681
|
}
|
|
641
682
|
),
|
|
642
|
-
|
|
683
|
+
/* @__PURE__ */ y("div", { className: "mt-1 flex justify-between text-xs text-gray-400", children: [
|
|
684
|
+
/* @__PURE__ */ t("span", { children: s }),
|
|
685
|
+
/* @__PURE__ */ t("span", { children: o })
|
|
686
|
+
] })
|
|
643
687
|
]
|
|
644
688
|
}
|
|
645
689
|
);
|
|
646
690
|
}
|
|
647
|
-
function
|
|
648
|
-
name: e,
|
|
649
|
-
value: n,
|
|
650
|
-
onChange: a,
|
|
651
|
-
onBlur: r,
|
|
652
|
-
disabled: s,
|
|
653
|
-
options: o,
|
|
654
|
-
inline: l = !1,
|
|
655
|
-
className: u
|
|
656
|
-
}) {
|
|
657
|
-
function i(m) {
|
|
658
|
-
return n === m;
|
|
659
|
-
}
|
|
660
|
-
function f(m) {
|
|
661
|
-
return s === !0 || !!m.disabled;
|
|
662
|
-
}
|
|
663
|
-
function d(m) {
|
|
664
|
-
f(m) || a(m.value);
|
|
665
|
-
}
|
|
666
|
-
function g(m, h) {
|
|
667
|
-
(m.key === " " || m.key === "Enter") && (m.preventDefault(), d(h));
|
|
668
|
-
}
|
|
669
|
-
return /* @__PURE__ */ t(
|
|
670
|
-
"div",
|
|
671
|
-
{
|
|
672
|
-
role: "radiogroup",
|
|
673
|
-
className: `${l ? "flex flex-wrap gap-4" : "flex flex-col gap-2"} ${u ?? ""}`,
|
|
674
|
-
children: o.map((m) => /* @__PURE__ */ y(
|
|
675
|
-
"label",
|
|
676
|
-
{
|
|
677
|
-
className: `inline-flex items-center gap-2 select-none ${f(m) ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}`,
|
|
678
|
-
children: [
|
|
679
|
-
/* @__PURE__ */ t(
|
|
680
|
-
"input",
|
|
681
|
-
{
|
|
682
|
-
type: "radio",
|
|
683
|
-
checked: i(m.value),
|
|
684
|
-
disabled: f(m),
|
|
685
|
-
className: "sr-only",
|
|
686
|
-
name: e,
|
|
687
|
-
onChange: () => d(m),
|
|
688
|
-
onBlur: r
|
|
689
|
-
}
|
|
690
|
-
),
|
|
691
|
-
/* @__PURE__ */ t(
|
|
692
|
-
"div",
|
|
693
|
-
{
|
|
694
|
-
role: "radio",
|
|
695
|
-
"aria-checked": i(m.value),
|
|
696
|
-
"aria-disabled": f(m) || void 0,
|
|
697
|
-
tabIndex: 0,
|
|
698
|
-
className: `flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 transition-colors duration-200 ${i(m.value) ? "" : "border-gray-300"}`,
|
|
699
|
-
style: i(m.value) ? { borderColor: "var(--fc-color-primary, #3b82f6)" } : {},
|
|
700
|
-
onClick: () => d(m),
|
|
701
|
-
onKeyDown: (h) => g(h, m),
|
|
702
|
-
children: i(m.value) && /* @__PURE__ */ t(
|
|
703
|
-
"div",
|
|
704
|
-
{
|
|
705
|
-
className: "h-2.5 w-2.5 rounded-full",
|
|
706
|
-
style: {
|
|
707
|
-
backgroundColor: "var(--fc-color-primary, #3b82f6)"
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
)
|
|
711
|
-
}
|
|
712
|
-
),
|
|
713
|
-
/* @__PURE__ */ t("span", { className: "text-sm text-gray-700", children: m.label })
|
|
714
|
-
]
|
|
715
|
-
},
|
|
716
|
-
String(m.value)
|
|
717
|
-
))
|
|
718
|
-
}
|
|
719
|
-
);
|
|
720
|
-
}
|
|
721
|
-
function Ce({
|
|
691
|
+
function we({
|
|
722
692
|
value: e,
|
|
723
693
|
onChange: n,
|
|
724
694
|
onBlur: a,
|
|
@@ -776,64 +746,94 @@ function Ce({
|
|
|
776
746
|
}
|
|
777
747
|
);
|
|
778
748
|
}
|
|
779
|
-
|
|
749
|
+
const Ne = "w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm placeholder:text-gray-400 resize-y focus:outline-none focus:ring-2 focus:ring-blue-500/20 transition-colors duration-200 fc-textarea-input";
|
|
750
|
+
function Ce({
|
|
780
751
|
value: e,
|
|
781
752
|
onChange: n,
|
|
782
753
|
onBlur: a,
|
|
783
754
|
disabled: r,
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
755
|
+
placeholder: s,
|
|
756
|
+
rows: o = 3,
|
|
757
|
+
readOnly: l,
|
|
758
|
+
autoResize: u,
|
|
759
|
+
maxLength: i,
|
|
760
|
+
className: f
|
|
789
761
|
}) {
|
|
790
|
-
const
|
|
791
|
-
|
|
792
|
-
|
|
762
|
+
const d = A(null), g = D(() => {
|
|
763
|
+
if (!u || !d.current) return;
|
|
764
|
+
const p = d.current;
|
|
765
|
+
p.style.height = "auto", p.style.height = `${p.scrollHeight}px`;
|
|
766
|
+
}, [u]);
|
|
767
|
+
re(() => {
|
|
768
|
+
g();
|
|
769
|
+
}, [g]);
|
|
770
|
+
const v = `${Ne} ${r ? "opacity-50 cursor-not-allowed bg-gray-100" : ""} ${u ? "resize-none overflow-hidden" : ""} ${f ?? ""}`.trim();
|
|
771
|
+
return /* @__PURE__ */ t(
|
|
772
|
+
"textarea",
|
|
793
773
|
{
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
774
|
+
ref: d,
|
|
775
|
+
className: v,
|
|
776
|
+
value: e ?? "",
|
|
777
|
+
onChange: (p) => {
|
|
778
|
+
n(p.target.value);
|
|
779
|
+
},
|
|
780
|
+
onFocus: (p) => {
|
|
781
|
+
p.target.style.borderColor = "var(--fc-color-primary, #3b82f6)";
|
|
782
|
+
},
|
|
783
|
+
onBlur: (p) => {
|
|
784
|
+
p.target.style.borderColor = "", a == null || a();
|
|
785
|
+
},
|
|
786
|
+
disabled: r,
|
|
787
|
+
placeholder: s,
|
|
788
|
+
rows: o,
|
|
789
|
+
readOnly: l,
|
|
790
|
+
maxLength: i,
|
|
791
|
+
"aria-disabled": r || void 0,
|
|
792
|
+
"aria-readonly": l || void 0
|
|
793
|
+
}
|
|
794
|
+
);
|
|
795
|
+
}
|
|
796
|
+
const $e = "w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500/20 transition-colors duration-200 fc-text-input";
|
|
797
|
+
function J({
|
|
798
|
+
value: e,
|
|
799
|
+
onChange: n,
|
|
800
|
+
onBlur: a,
|
|
801
|
+
disabled: r,
|
|
802
|
+
placeholder: s,
|
|
803
|
+
inputType: o = "text",
|
|
804
|
+
readOnly: l,
|
|
805
|
+
prefix: u,
|
|
806
|
+
suffix: i,
|
|
807
|
+
maxLength: f,
|
|
808
|
+
className: d
|
|
809
|
+
}) {
|
|
810
|
+
const v = `${$e} ${r ? "opacity-50 cursor-not-allowed bg-gray-100" : ""} ${u ? "rounded-l-none" : ""} ${i ? "rounded-r-none" : ""} ${d ?? ""}`.trim(), p = /* @__PURE__ */ t(
|
|
811
|
+
"input",
|
|
812
|
+
{
|
|
813
|
+
type: o,
|
|
814
|
+
className: v,
|
|
815
|
+
style: { borderColor: void 0 },
|
|
816
|
+
value: e ?? "",
|
|
817
|
+
onChange: (b) => n(b.target.value),
|
|
818
|
+
onFocus: (b) => {
|
|
819
|
+
b.target.style.borderColor = "var(--fc-color-primary, #3b82f6)";
|
|
820
|
+
},
|
|
821
|
+
onBlur: (b) => {
|
|
822
|
+
b.target.style.borderColor = "", a == null || a();
|
|
823
|
+
},
|
|
824
|
+
disabled: r,
|
|
825
|
+
placeholder: s,
|
|
826
|
+
readOnly: l,
|
|
827
|
+
maxLength: f,
|
|
828
|
+
"aria-disabled": r || void 0,
|
|
829
|
+
"aria-readonly": l || void 0
|
|
835
830
|
}
|
|
836
831
|
);
|
|
832
|
+
return u || i ? /* @__PURE__ */ y("div", { className: "flex items-stretch", children: [
|
|
833
|
+
u && /* @__PURE__ */ t("span", { className: "inline-flex items-center rounded-l-md border border-r-0 border-gray-300 bg-gray-50 px-3 text-sm text-gray-500", children: u }),
|
|
834
|
+
p,
|
|
835
|
+
i && /* @__PURE__ */ t("span", { className: "inline-flex items-center rounded-r-md border border-l-0 border-gray-300 bg-gray-50 px-3 text-sm text-gray-500", children: i })
|
|
836
|
+
] }) : p;
|
|
837
837
|
}
|
|
838
838
|
function V(e) {
|
|
839
839
|
return e.replace(/[A-Z]/g, (n) => `-${n.toLowerCase()}`);
|
|
@@ -881,7 +881,10 @@ function X(e, n, a, r, s) {
|
|
|
881
881
|
function Y(e) {
|
|
882
882
|
return Array.isArray(e) ? e : [];
|
|
883
883
|
}
|
|
884
|
-
function Se(
|
|
884
|
+
function Se(e) {
|
|
885
|
+
return typeof e == "function" ? !1 : e ?? !1;
|
|
886
|
+
}
|
|
887
|
+
function Fe({ field: e, value: n, onChange: a, onBlur: r, disabled: s }) {
|
|
885
888
|
switch (e.type) {
|
|
886
889
|
case "text":
|
|
887
890
|
return /* @__PURE__ */ t(
|
|
@@ -913,7 +916,7 @@ function Se({ field: e, value: n, onChange: a, onBlur: r, disabled: s }) {
|
|
|
913
916
|
);
|
|
914
917
|
case "textarea":
|
|
915
918
|
return /* @__PURE__ */ t(
|
|
916
|
-
|
|
919
|
+
Ce,
|
|
917
920
|
{
|
|
918
921
|
value: String(n ?? ""),
|
|
919
922
|
onChange: a,
|
|
@@ -926,7 +929,7 @@ function Se({ field: e, value: n, onChange: a, onBlur: r, disabled: s }) {
|
|
|
926
929
|
);
|
|
927
930
|
case "select":
|
|
928
931
|
return /* @__PURE__ */ t(
|
|
929
|
-
|
|
932
|
+
xe,
|
|
930
933
|
{
|
|
931
934
|
value: n,
|
|
932
935
|
onChange: a,
|
|
@@ -938,7 +941,7 @@ function Se({ field: e, value: n, onChange: a, onBlur: r, disabled: s }) {
|
|
|
938
941
|
);
|
|
939
942
|
case "checkbox":
|
|
940
943
|
return /* @__PURE__ */ t(
|
|
941
|
-
|
|
944
|
+
be,
|
|
942
945
|
{
|
|
943
946
|
value: !!n,
|
|
944
947
|
onChange: a,
|
|
@@ -948,7 +951,7 @@ function Se({ field: e, value: n, onChange: a, onBlur: r, disabled: s }) {
|
|
|
948
951
|
);
|
|
949
952
|
case "radio":
|
|
950
953
|
return /* @__PURE__ */ t(
|
|
951
|
-
|
|
954
|
+
he,
|
|
952
955
|
{
|
|
953
956
|
name: e.name,
|
|
954
957
|
value: n,
|
|
@@ -960,7 +963,7 @@ function Se({ field: e, value: n, onChange: a, onBlur: r, disabled: s }) {
|
|
|
960
963
|
);
|
|
961
964
|
case "switch":
|
|
962
965
|
return /* @__PURE__ */ t(
|
|
963
|
-
|
|
966
|
+
we,
|
|
964
967
|
{
|
|
965
968
|
value: !!n,
|
|
966
969
|
onChange: a,
|
|
@@ -970,7 +973,7 @@ function Se({ field: e, value: n, onChange: a, onBlur: r, disabled: s }) {
|
|
|
970
973
|
);
|
|
971
974
|
case "slider":
|
|
972
975
|
return /* @__PURE__ */ t(
|
|
973
|
-
|
|
976
|
+
ve,
|
|
974
977
|
{
|
|
975
978
|
value: n,
|
|
976
979
|
onChange: a,
|
|
@@ -997,7 +1000,7 @@ function Se({ field: e, value: n, onChange: a, onBlur: r, disabled: s }) {
|
|
|
997
1000
|
function ae(e) {
|
|
998
1001
|
return e === "full" ? { gridColumn: "1 / -1" } : e === "auto" ? { gridColumn: "auto" } : typeof e == "number" ? { gridColumn: `span ${e} / span ${e}` } : { gridColumn: "span 12 / span 12" };
|
|
999
1002
|
}
|
|
1000
|
-
function
|
|
1003
|
+
function De(e, n, a) {
|
|
1001
1004
|
const r = n.errors[e.name] ?? [], s = e.disabled === !0 || !1, o = {
|
|
1002
1005
|
field: e,
|
|
1003
1006
|
value: n.values[e.name],
|
|
@@ -1005,9 +1008,9 @@ function Fe(e, n, a) {
|
|
|
1005
1008
|
onBlur: () => n.validateField(e.name),
|
|
1006
1009
|
errors: r,
|
|
1007
1010
|
disabled: s
|
|
1008
|
-
}, u = (a == null ? void 0 : a[e.type]) ??
|
|
1011
|
+
}, u = (a == null ? void 0 : a[e.type]) ?? Fe;
|
|
1009
1012
|
return /* @__PURE__ */ t(
|
|
1010
|
-
|
|
1013
|
+
pe,
|
|
1011
1014
|
{
|
|
1012
1015
|
label: e.label,
|
|
1013
1016
|
required: e.required,
|
|
@@ -1015,8 +1018,8 @@ function Fe(e, n, a) {
|
|
|
1015
1018
|
touched: n.touched[e.name],
|
|
1016
1019
|
helpText: e.helpText,
|
|
1017
1020
|
tooltip: e.tooltip,
|
|
1018
|
-
disabled: e.disabled,
|
|
1019
|
-
readOnly: e.readOnly,
|
|
1021
|
+
disabled: Se(e.disabled),
|
|
1022
|
+
readOnly: e.readOnly === !0,
|
|
1020
1023
|
fieldName: e.name,
|
|
1021
1024
|
className: e.className,
|
|
1022
1025
|
style: e.style,
|
|
@@ -1025,7 +1028,7 @@ function Fe(e, n, a) {
|
|
|
1025
1028
|
e.name
|
|
1026
1029
|
);
|
|
1027
1030
|
}
|
|
1028
|
-
function
|
|
1031
|
+
function Re(e, n, a) {
|
|
1029
1032
|
const s = {
|
|
1030
1033
|
start: "items-start",
|
|
1031
1034
|
center: "items-center",
|
|
@@ -1049,7 +1052,7 @@ function De(e, n, a) {
|
|
|
1049
1052
|
}
|
|
1050
1053
|
);
|
|
1051
1054
|
}
|
|
1052
|
-
function
|
|
1055
|
+
function je({
|
|
1053
1056
|
node: e,
|
|
1054
1057
|
form: n,
|
|
1055
1058
|
components: a
|
|
@@ -1118,41 +1121,41 @@ function Re({
|
|
|
1118
1121
|
}
|
|
1119
1122
|
);
|
|
1120
1123
|
}
|
|
1121
|
-
function
|
|
1124
|
+
function Ee({
|
|
1122
1125
|
node: e,
|
|
1123
1126
|
form: n,
|
|
1124
1127
|
components: a
|
|
1125
1128
|
}) {
|
|
1126
1129
|
const [r, s] = F(0), [o, l] = F(/* @__PURE__ */ new Set()), u = e.steps, i = u.length, f = r === 0, d = r === i - 1;
|
|
1127
1130
|
function g() {
|
|
1128
|
-
d || (l((
|
|
1129
|
-
const
|
|
1130
|
-
return
|
|
1131
|
-
}), s((
|
|
1131
|
+
d || (l((p) => {
|
|
1132
|
+
const b = new Set(p);
|
|
1133
|
+
return b.add(r), b;
|
|
1134
|
+
}), s((p) => p + 1));
|
|
1132
1135
|
}
|
|
1133
1136
|
function m() {
|
|
1134
|
-
f || s((
|
|
1137
|
+
f || s((p) => p - 1);
|
|
1135
1138
|
}
|
|
1136
|
-
function h(
|
|
1137
|
-
e.linear &&
|
|
1139
|
+
function h(p) {
|
|
1140
|
+
e.linear && p > r || s(p);
|
|
1138
1141
|
}
|
|
1139
1142
|
const v = u[r];
|
|
1140
1143
|
return /* @__PURE__ */ y("div", { className: `space-y-6 ${e.className ?? ""}`, children: [
|
|
1141
|
-
/* @__PURE__ */ t("nav", { "aria-label": "Form steps", className: "flex items-center justify-center", children: /* @__PURE__ */ t("ol", { className: "flex items-center gap-0", children: u.map((
|
|
1144
|
+
/* @__PURE__ */ t("nav", { "aria-label": "Form steps", className: "flex items-center justify-center", children: /* @__PURE__ */ t("ol", { className: "flex items-center gap-0", children: u.map((p, b) => /* @__PURE__ */ y("li", { className: "flex items-center", children: [
|
|
1142
1145
|
/* @__PURE__ */ t(
|
|
1143
1146
|
"button",
|
|
1144
1147
|
{
|
|
1145
1148
|
type: "button",
|
|
1146
|
-
disabled: e.linear === !0 &&
|
|
1147
|
-
"aria-current":
|
|
1148
|
-
"aria-label": `Step ${
|
|
1149
|
-
className: `relative flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 text-xs font-semibold transition-all duration-300 focus:outline-none focus:ring-2 focus:ring-blue-500/40 ${o.has(
|
|
1150
|
-
style:
|
|
1149
|
+
disabled: e.linear === !0 && b > r,
|
|
1150
|
+
"aria-current": b === r ? "step" : void 0,
|
|
1151
|
+
"aria-label": `Step ${b + 1}: ${p.title}`,
|
|
1152
|
+
className: `relative flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 text-xs font-semibold transition-all duration-300 focus:outline-none focus:ring-2 focus:ring-blue-500/40 ${o.has(b) && b !== r ? "border-green-500 bg-green-500 text-white" : b !== r ? "border-gray-300 bg-white text-gray-500" : "text-white"} ${e.linear === !0 && b > r ? "cursor-not-allowed" : "cursor-pointer hover:shadow-md"}`,
|
|
1153
|
+
style: b === r ? {
|
|
1151
1154
|
borderColor: "var(--fc-color-primary, #3b82f6)",
|
|
1152
1155
|
backgroundColor: "var(--fc-color-primary, #3b82f6)"
|
|
1153
1156
|
} : {},
|
|
1154
|
-
onClick: () => h(
|
|
1155
|
-
children: o.has(
|
|
1157
|
+
onClick: () => h(b),
|
|
1158
|
+
children: o.has(b) && b !== r ? /* @__PURE__ */ t(
|
|
1156
1159
|
"svg",
|
|
1157
1160
|
{
|
|
1158
1161
|
className: "h-4 w-4 transition-transform duration-200",
|
|
@@ -1169,21 +1172,21 @@ function je({
|
|
|
1169
1172
|
}
|
|
1170
1173
|
)
|
|
1171
1174
|
}
|
|
1172
|
-
) : /* @__PURE__ */ t("span", { children:
|
|
1175
|
+
) : /* @__PURE__ */ t("span", { children: b + 1 })
|
|
1173
1176
|
}
|
|
1174
1177
|
),
|
|
1175
|
-
|
|
1178
|
+
b < u.length - 1 && /* @__PURE__ */ t(
|
|
1176
1179
|
"div",
|
|
1177
1180
|
{
|
|
1178
|
-
className: `mx-1 h-0.5 w-8 transition-colors duration-300 sm:w-12 ${o.has(
|
|
1181
|
+
className: `mx-1 h-0.5 w-8 transition-colors duration-300 sm:w-12 ${o.has(b) ? "bg-green-500" : "bg-gray-200"}`
|
|
1179
1182
|
}
|
|
1180
1183
|
)
|
|
1181
|
-
] },
|
|
1184
|
+
] }, p.title)) }) }),
|
|
1182
1185
|
v && /* @__PURE__ */ y("div", { className: "text-center", children: [
|
|
1183
1186
|
/* @__PURE__ */ t("h3", { className: "text-base font-semibold text-gray-800", children: v.title }),
|
|
1184
1187
|
v.description && /* @__PURE__ */ t("p", { className: "mt-1 text-sm text-gray-500", children: v.description })
|
|
1185
1188
|
] }),
|
|
1186
|
-
v && /* @__PURE__ */ t("div", { children: v.children.map((
|
|
1189
|
+
v && /* @__PURE__ */ t("div", { children: v.children.map((p, b) => /* @__PURE__ */ t("div", { children: P(p, n, a) }, L(p) ? p.name : `step-child-${b}`)) }),
|
|
1187
1190
|
/* @__PURE__ */ y("div", { className: "flex items-center justify-between border-t border-gray-100 pt-4", children: [
|
|
1188
1191
|
/* @__PURE__ */ t(
|
|
1189
1192
|
"button",
|
|
@@ -1215,7 +1218,7 @@ function je({
|
|
|
1215
1218
|
] })
|
|
1216
1219
|
] });
|
|
1217
1220
|
}
|
|
1218
|
-
function
|
|
1221
|
+
function Oe({
|
|
1219
1222
|
node: e,
|
|
1220
1223
|
form: n,
|
|
1221
1224
|
components: a
|
|
@@ -1266,7 +1269,6 @@ function Ee({
|
|
|
1266
1269
|
id: u,
|
|
1267
1270
|
role: "tabpanel",
|
|
1268
1271
|
"aria-labelledby": `fc-tab-${r}`,
|
|
1269
|
-
tabIndex: 0,
|
|
1270
1272
|
className: "pt-4",
|
|
1271
1273
|
children: l.children.map((f, d) => /* @__PURE__ */ t("div", { children: P(f, n, a) }, L(f) ? f.name : `tab-child-${d}`))
|
|
1272
1274
|
}
|
|
@@ -1281,16 +1283,16 @@ function Ie(e) {
|
|
|
1281
1283
|
}
|
|
1282
1284
|
function P(e, n, a) {
|
|
1283
1285
|
if (L(e))
|
|
1284
|
-
return
|
|
1286
|
+
return De(e, n, a);
|
|
1285
1287
|
switch (e.type) {
|
|
1286
1288
|
case "row":
|
|
1287
|
-
return
|
|
1289
|
+
return Re(e, n, a);
|
|
1288
1290
|
case "group":
|
|
1289
|
-
return /* @__PURE__ */ t(Re, { node: e, form: n, components: a });
|
|
1290
|
-
case "steps":
|
|
1291
1291
|
return /* @__PURE__ */ t(je, { node: e, form: n, components: a });
|
|
1292
|
-
case "
|
|
1292
|
+
case "steps":
|
|
1293
1293
|
return /* @__PURE__ */ t(Ee, { node: e, form: n, components: a });
|
|
1294
|
+
case "tabs":
|
|
1295
|
+
return /* @__PURE__ */ t(Oe, { node: e, form: n, components: a });
|
|
1294
1296
|
case "divider":
|
|
1295
1297
|
return Ie(e);
|
|
1296
1298
|
case "html":
|
|
@@ -1305,7 +1307,7 @@ function P(e, n, a) {
|
|
|
1305
1307
|
return null;
|
|
1306
1308
|
}
|
|
1307
1309
|
}
|
|
1308
|
-
function
|
|
1310
|
+
function ze({
|
|
1309
1311
|
schema: e,
|
|
1310
1312
|
onSubmit: n,
|
|
1311
1313
|
onError: a,
|
|
@@ -1316,14 +1318,14 @@ function Ve({
|
|
|
1316
1318
|
className: u
|
|
1317
1319
|
}) {
|
|
1318
1320
|
var R, M;
|
|
1319
|
-
const i =
|
|
1320
|
-
k.preventDefault(), n ? await h.submit(async (
|
|
1321
|
-
await n(
|
|
1321
|
+
const i = ce(), f = r ?? i.locale ?? "en", d = s ?? i.fallbackLocale ?? "en", g = o ?? i.theme, m = l ?? i.components, h = me(e), v = ke(g), p = Q(e, "title", f, d, ""), b = Q(e, "description", f, d, ""), S = X(e, "submit", f, d, "Submit"), $ = X(e, "reset", f, d, "Reset"), j = async (k) => {
|
|
1322
|
+
k.preventDefault(), n ? await h.submit(async (O) => {
|
|
1323
|
+
await n(O);
|
|
1322
1324
|
}) : await h.validate(), !h.isValid && a && a(h.errors);
|
|
1323
1325
|
}, E = (k) => {
|
|
1324
1326
|
k.preventDefault(), h.reset();
|
|
1325
1327
|
};
|
|
1326
|
-
return /* @__PURE__ */ t(
|
|
1328
|
+
return /* @__PURE__ */ t(ne.Provider, { value: h, children: /* @__PURE__ */ y(
|
|
1327
1329
|
"form",
|
|
1328
1330
|
{
|
|
1329
1331
|
className: `fc-form-builder ${((R = g == null ? void 0 : g.components) == null ? void 0 : R.form) ?? ""} ${u ?? ""}`.trim(),
|
|
@@ -1332,17 +1334,17 @@ function Ve({
|
|
|
1332
1334
|
onReset: E,
|
|
1333
1335
|
noValidate: !0,
|
|
1334
1336
|
children: [
|
|
1335
|
-
(
|
|
1336
|
-
|
|
1337
|
-
|
|
1337
|
+
(p || b) && /* @__PURE__ */ y("div", { className: "mb-6", children: [
|
|
1338
|
+
p && /* @__PURE__ */ t("h2", { className: "text-lg font-semibold text-gray-900", children: p }),
|
|
1339
|
+
b && /* @__PURE__ */ t("p", { className: "mt-1 text-sm text-gray-500", children: b })
|
|
1338
1340
|
] }),
|
|
1339
|
-
e.fields.map((k,
|
|
1341
|
+
e.fields.map((k, O) => /* @__PURE__ */ t(
|
|
1340
1342
|
"div",
|
|
1341
1343
|
{
|
|
1342
1344
|
style: L(k) ? ae(k.span) : void 0,
|
|
1343
1345
|
children: P(k, h, m)
|
|
1344
1346
|
},
|
|
1345
|
-
L(k) ? k.name : `node-${
|
|
1347
|
+
L(k) ? k.name : `node-${O}`
|
|
1346
1348
|
)),
|
|
1347
1349
|
/* @__PURE__ */ y("div", { className: "mt-6 flex items-center gap-3", children: [
|
|
1348
1350
|
/* @__PURE__ */ y(
|
|
@@ -1381,11 +1383,11 @@ function Ve({
|
|
|
1381
1383
|
) });
|
|
1382
1384
|
}
|
|
1383
1385
|
export {
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
+
ze as FormBuilder,
|
|
1387
|
+
ne as FormContext,
|
|
1386
1388
|
Me as FormaticaProvider,
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1389
|
+
me as useForm,
|
|
1390
|
+
Ve as useFormContext,
|
|
1391
|
+
ce as useFormaticaConfig
|
|
1390
1392
|
};
|
|
1391
1393
|
//# sourceMappingURL=formatica-react.es.js.map
|