@formatica/react 0.1.1 → 0.2.1
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/dist/components/BaseField.d.ts +17 -0
- package/dist/components/BaseField.d.ts.map +1 -0
- package/dist/components/FormBuilder.d.ts +22 -0
- package/dist/components/FormBuilder.d.ts.map +1 -0
- package/dist/components/FormaticaProvider.d.ts +15 -0
- package/dist/components/FormaticaProvider.d.ts.map +1 -0
- package/dist/components/fields/CheckboxField.d.ts +10 -0
- package/dist/components/fields/CheckboxField.d.ts.map +1 -0
- package/dist/components/fields/NumberField.d.ts +17 -0
- package/dist/components/fields/NumberField.d.ts.map +1 -0
- package/dist/components/fields/RadioField.d.ts +17 -0
- package/dist/components/fields/RadioField.d.ts.map +1 -0
- package/dist/components/fields/SelectField.d.ts +19 -0
- package/dist/components/fields/SelectField.d.ts.map +1 -0
- package/dist/components/fields/SliderField.d.ts +13 -0
- package/dist/components/fields/SliderField.d.ts.map +1 -0
- package/dist/components/fields/SwitchField.d.ts +11 -0
- package/dist/components/fields/SwitchField.d.ts.map +1 -0
- package/dist/components/fields/TextField.d.ts +15 -0
- package/dist/components/fields/TextField.d.ts.map +1 -0
- package/dist/components/fields/TextareaField.d.ts +14 -0
- package/dist/components/fields/TextareaField.d.ts.map +1 -0
- package/dist/formatica-react.es.js +498 -486
- 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 +26 -0
- package/dist/hooks/useForm.d.ts.map +1 -0
- package/dist/hooks/useFormContext.d.ts +4 -0
- package/dist/hooks/useFormContext.d.ts.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/package.json +3 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { extractFields as
|
|
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
|
|
4
|
-
import {
|
|
5
|
-
function
|
|
3
|
+
import { useRef as A, useState as F, useCallback as D, createContext as B, useContext as ee, useEffect as re } from "react";
|
|
4
|
+
import { jsx as t, jsxs as y } from "react/jsx-runtime";
|
|
5
|
+
function ce(e) {
|
|
6
6
|
switch (e.type) {
|
|
7
7
|
case "tags":
|
|
8
8
|
case "checkbox-group":
|
|
@@ -18,171 +18,181 @@ function ie(e) {
|
|
|
18
18
|
return "";
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function ue(e) {
|
|
22
22
|
const n = {};
|
|
23
|
-
for (const
|
|
24
|
-
n[
|
|
23
|
+
for (const a of e)
|
|
24
|
+
n[a.name] = a.defaultValue ?? ce(a);
|
|
25
25
|
return n;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
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,
|
|
27
|
+
function de(e) {
|
|
28
|
+
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
29
|
name: n,
|
|
30
|
-
params: typeof
|
|
30
|
+
params: typeof a == "object" && a !== null ? a : { [n]: a }
|
|
31
31
|
})) : [];
|
|
32
32
|
}
|
|
33
33
|
function Z(e) {
|
|
34
|
-
const [n = "", ...
|
|
34
|
+
const [n = "", ...a] = e.split(":"), r = a.join(":"), s = {};
|
|
35
35
|
if (r) {
|
|
36
36
|
const o = r.split(",");
|
|
37
37
|
if (n === "between" && o.length === 2)
|
|
38
|
-
|
|
38
|
+
s.min = Number(o[0]), s.max = Number(o[1]);
|
|
39
39
|
else if (n === "pattern")
|
|
40
|
-
|
|
41
|
-
else if (
|
|
42
|
-
const
|
|
43
|
-
Number.isNaN(
|
|
40
|
+
s.pattern = r;
|
|
41
|
+
else if (s[n] = o.length === 1 ? o[0] : o, o.length === 1) {
|
|
42
|
+
const l = Number(o[0]);
|
|
43
|
+
Number.isNaN(l) || (s[n] = l, n === "minLength" && (s.min = l), n === "maxLength" && (s.max = l));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
return { name: n, params:
|
|
46
|
+
return { name: n, params: s };
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const
|
|
48
|
+
function fe(e, n) {
|
|
49
|
+
const a = oe(e.fields), r = A(ue(a)), s = A(a), [o, l] = F(() => ({
|
|
50
50
|
...r.current
|
|
51
|
-
})), [u,
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
}, []),
|
|
58
|
-
async (
|
|
59
|
-
const N =
|
|
51
|
+
})), [u, i] = F({}), [f, d] = F({}), [g, m] = F({}), [h, v] = F(!1), [b, p] = F(0), S = A(o);
|
|
52
|
+
S.current = o;
|
|
53
|
+
const $ = A(u);
|
|
54
|
+
$.current = u;
|
|
55
|
+
const j = Object.values(u).every((x) => x.length === 0), E = Object.values(g).some(Boolean), R = D((x, C) => {
|
|
56
|
+
l((N) => ({ ...N, [x]: C })), m((N) => ({ ...N, [x]: !0 }));
|
|
57
|
+
}, []), M = D((x) => S.current[x], []), k = D(
|
|
58
|
+
async (x, C) => {
|
|
59
|
+
const N = s.current.find((O) => O.name === x);
|
|
60
60
|
if (!N) return [];
|
|
61
|
-
if (N.condition && !
|
|
61
|
+
if (N.condition && !le(N.condition, C))
|
|
62
62
|
return [];
|
|
63
|
-
const
|
|
64
|
-
N.required && !
|
|
65
|
-
const
|
|
66
|
-
values:
|
|
67
|
-
getFieldValue: (
|
|
63
|
+
const T = de(N.rules);
|
|
64
|
+
N.required && !T.some((O) => O.name === "required") && T.unshift({ name: "required", params: {} });
|
|
65
|
+
const K = [], se = {
|
|
66
|
+
values: C,
|
|
67
|
+
getFieldValue: (O) => C[O]
|
|
68
68
|
};
|
|
69
|
-
for (const
|
|
70
|
-
const G =
|
|
69
|
+
for (const O of T) {
|
|
70
|
+
const G = ie(O.name);
|
|
71
71
|
if (!G) continue;
|
|
72
|
-
const W = await G(
|
|
73
|
-
typeof W == "string" &&
|
|
72
|
+
const W = await G(C[x], O.params, se);
|
|
73
|
+
typeof W == "string" && K.push(W);
|
|
74
74
|
}
|
|
75
|
-
return
|
|
75
|
+
return K;
|
|
76
76
|
},
|
|
77
77
|
[]
|
|
78
|
-
),
|
|
79
|
-
async (
|
|
80
|
-
const
|
|
81
|
-
return
|
|
78
|
+
), I = D(
|
|
79
|
+
async (x) => {
|
|
80
|
+
const C = await k(x, S.current);
|
|
81
|
+
return i((N) => ({ ...N, [x]: C })), d((N) => ({ ...N, [x]: !0 })), C.length === 0;
|
|
82
82
|
},
|
|
83
|
-
[
|
|
84
|
-
),
|
|
85
|
-
const
|
|
83
|
+
[k]
|
|
84
|
+
), z = D(async () => {
|
|
85
|
+
const x = S.current, C = {};
|
|
86
86
|
let N = !0;
|
|
87
|
-
for (const
|
|
88
|
-
const
|
|
89
|
-
|
|
87
|
+
for (const T of s.current) {
|
|
88
|
+
const K = await k(T.name, x);
|
|
89
|
+
C[T.name] = K, K.length > 0 && (N = !1);
|
|
90
90
|
}
|
|
91
|
-
return
|
|
92
|
-
}, [
|
|
93
|
-
async (
|
|
94
|
-
v(!0),
|
|
95
|
-
const
|
|
96
|
-
for (const N of
|
|
97
|
-
|
|
98
|
-
d(
|
|
91
|
+
return i(C), N;
|
|
92
|
+
}, [k]), q = D(
|
|
93
|
+
async (x) => {
|
|
94
|
+
v(!0), p((N) => N + 1);
|
|
95
|
+
const C = {};
|
|
96
|
+
for (const N of s.current)
|
|
97
|
+
C[N.name] = !0;
|
|
98
|
+
d(C);
|
|
99
99
|
try {
|
|
100
|
-
if (!await
|
|
101
|
-
await
|
|
100
|
+
if (!await z()) return;
|
|
101
|
+
await x({ ...S.current });
|
|
102
102
|
} finally {
|
|
103
103
|
v(!1);
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
|
-
[
|
|
106
|
+
[z]
|
|
107
107
|
), _ = D(() => {
|
|
108
|
-
|
|
108
|
+
l({ ...r.current }), i({}), d({}), m({});
|
|
109
109
|
}, []), U = D(() => {
|
|
110
|
-
const
|
|
111
|
-
for (const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}, []),
|
|
115
|
-
const N = Array.isArray(
|
|
116
|
-
|
|
117
|
-
}, []), c = D((
|
|
118
|
-
|
|
119
|
-
const N = {
|
|
120
|
-
return delete N[
|
|
110
|
+
const x = {};
|
|
111
|
+
for (const C of s.current)
|
|
112
|
+
x[C.name] = null;
|
|
113
|
+
l(x), i({});
|
|
114
|
+
}, []), H = D((x, C) => {
|
|
115
|
+
const N = Array.isArray(C) ? C : [C];
|
|
116
|
+
i((T) => ({ ...T, [x]: N }));
|
|
117
|
+
}, []), c = D((x) => {
|
|
118
|
+
i((C) => {
|
|
119
|
+
const N = { ...C };
|
|
120
|
+
return delete N[x], N;
|
|
121
121
|
});
|
|
122
122
|
}, []), w = D(() => {
|
|
123
|
-
|
|
123
|
+
i({});
|
|
124
124
|
}, []);
|
|
125
125
|
return {
|
|
126
126
|
values: o,
|
|
127
127
|
errors: u,
|
|
128
|
-
touched:
|
|
129
|
-
dirty:
|
|
130
|
-
isValid:
|
|
131
|
-
isDirty:
|
|
132
|
-
isSubmitting:
|
|
133
|
-
submitCount:
|
|
134
|
-
setFieldValue:
|
|
135
|
-
validate:
|
|
136
|
-
validateField:
|
|
137
|
-
submit:
|
|
128
|
+
touched: f,
|
|
129
|
+
dirty: g,
|
|
130
|
+
isValid: j,
|
|
131
|
+
isDirty: E,
|
|
132
|
+
isSubmitting: h,
|
|
133
|
+
submitCount: b,
|
|
134
|
+
setFieldValue: R,
|
|
135
|
+
validate: z,
|
|
136
|
+
validateField: I,
|
|
137
|
+
submit: q,
|
|
138
138
|
reset: _,
|
|
139
139
|
clear: U,
|
|
140
|
-
setError:
|
|
140
|
+
setError: H,
|
|
141
141
|
clearError: c,
|
|
142
142
|
clearErrors: w,
|
|
143
|
-
getFieldValue:
|
|
143
|
+
getFieldValue: M
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
|
-
const
|
|
147
|
-
function
|
|
148
|
-
const e =
|
|
146
|
+
const te = B(null);
|
|
147
|
+
function Ae() {
|
|
148
|
+
const e = ee(te);
|
|
149
149
|
if (!e) throw new Error("useFormContext must be used within a FormProvider");
|
|
150
150
|
return e;
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
const ne = B({});
|
|
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({
|
|
153
163
|
label: e,
|
|
154
164
|
required: n,
|
|
155
|
-
errors:
|
|
165
|
+
errors: a,
|
|
156
166
|
touched: r = !0,
|
|
157
|
-
helpText:
|
|
167
|
+
helpText: s,
|
|
158
168
|
tooltip: o,
|
|
159
|
-
disabled:
|
|
169
|
+
disabled: l,
|
|
160
170
|
readOnly: u,
|
|
161
|
-
fieldName:
|
|
162
|
-
children:
|
|
171
|
+
fieldName: i,
|
|
172
|
+
children: f,
|
|
163
173
|
className: d,
|
|
164
|
-
style:
|
|
174
|
+
style: g
|
|
165
175
|
}) {
|
|
166
|
-
const [
|
|
167
|
-
return /* @__PURE__ */
|
|
176
|
+
const [m, h] = F(!1), v = r && a !== void 0 && a.length > 0, b = i ? `fc-field-${i}` : void 0, p = i ? `fc-error-${i}` : void 0;
|
|
177
|
+
return /* @__PURE__ */ y(
|
|
168
178
|
"div",
|
|
169
179
|
{
|
|
170
|
-
className: `relative mb-4 ${
|
|
171
|
-
style:
|
|
180
|
+
className: `relative mb-4 ${l ? "opacity-50 cursor-not-allowed" : ""} ${u ? "fc-readonly" : ""} ${d ?? ""}`,
|
|
181
|
+
style: g,
|
|
172
182
|
children: [
|
|
173
|
-
e && /* @__PURE__ */
|
|
174
|
-
/* @__PURE__ */
|
|
183
|
+
e && /* @__PURE__ */ y("div", { className: "mb-1.5 flex items-center gap-1", children: [
|
|
184
|
+
/* @__PURE__ */ y("label", { htmlFor: b, className: "block text-sm font-medium text-gray-700", children: [
|
|
175
185
|
e,
|
|
176
186
|
n && /* @__PURE__ */ t("span", { className: "text-red-500 ml-0.5", "aria-hidden": "true", children: "*" })
|
|
177
187
|
] }),
|
|
178
|
-
o && /* @__PURE__ */
|
|
188
|
+
o && /* @__PURE__ */ y(
|
|
179
189
|
"span",
|
|
180
190
|
{
|
|
181
191
|
className: "relative inline-flex",
|
|
182
|
-
onMouseEnter: () =>
|
|
183
|
-
onMouseLeave: () =>
|
|
184
|
-
onFocus: () =>
|
|
185
|
-
onBlur: () =>
|
|
192
|
+
onMouseEnter: () => h(!0),
|
|
193
|
+
onMouseLeave: () => h(!1),
|
|
194
|
+
onFocus: () => h(!0),
|
|
195
|
+
onBlur: () => h(!1),
|
|
186
196
|
children: [
|
|
187
197
|
/* @__PURE__ */ t(
|
|
188
198
|
"button",
|
|
@@ -194,7 +204,7 @@ function fe({
|
|
|
194
204
|
children: "i"
|
|
195
205
|
}
|
|
196
206
|
),
|
|
197
|
-
|
|
207
|
+
m && /* @__PURE__ */ y(
|
|
198
208
|
"div",
|
|
199
209
|
{
|
|
200
210
|
role: "tooltip",
|
|
@@ -209,249 +219,249 @@ function fe({
|
|
|
209
219
|
}
|
|
210
220
|
)
|
|
211
221
|
] }),
|
|
212
|
-
/* @__PURE__ */ t("div", { id:
|
|
213
|
-
v && /* @__PURE__ */ t("div", { children:
|
|
222
|
+
/* @__PURE__ */ t("div", { id: b, children: f }),
|
|
223
|
+
v && /* @__PURE__ */ t("div", { children: a.map((S, $) => /* @__PURE__ */ t(
|
|
214
224
|
"p",
|
|
215
225
|
{
|
|
216
|
-
id:
|
|
226
|
+
id: $ === 0 ? p : void 0,
|
|
217
227
|
className: "mt-1 text-xs text-red-500",
|
|
218
228
|
role: "alert",
|
|
219
|
-
children:
|
|
229
|
+
children: S
|
|
220
230
|
},
|
|
221
|
-
`${
|
|
231
|
+
`${S}-${$}`
|
|
222
232
|
)) }),
|
|
223
|
-
|
|
233
|
+
s && !v && /* @__PURE__ */ t("p", { className: "mt-1 text-xs text-gray-400", children: s })
|
|
224
234
|
]
|
|
225
235
|
}
|
|
226
236
|
);
|
|
227
237
|
}
|
|
228
|
-
const
|
|
238
|
+
const pe = "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";
|
|
229
239
|
function J({
|
|
230
240
|
value: e,
|
|
231
241
|
onChange: n,
|
|
232
|
-
onBlur:
|
|
242
|
+
onBlur: a,
|
|
233
243
|
disabled: r,
|
|
234
|
-
placeholder:
|
|
244
|
+
placeholder: s,
|
|
235
245
|
inputType: o = "text",
|
|
236
|
-
readOnly:
|
|
246
|
+
readOnly: l,
|
|
237
247
|
prefix: u,
|
|
238
|
-
suffix:
|
|
239
|
-
maxLength:
|
|
248
|
+
suffix: i,
|
|
249
|
+
maxLength: f,
|
|
240
250
|
className: d
|
|
241
251
|
}) {
|
|
242
|
-
const v = `${
|
|
252
|
+
const v = `${pe} ${r ? "opacity-50 cursor-not-allowed bg-gray-100" : ""} ${u ? "rounded-l-none" : ""} ${i ? "rounded-r-none" : ""} ${d ?? ""}`.trim(), b = /* @__PURE__ */ t(
|
|
243
253
|
"input",
|
|
244
254
|
{
|
|
245
255
|
type: o,
|
|
246
256
|
className: v,
|
|
247
257
|
style: { borderColor: void 0 },
|
|
248
258
|
value: e ?? "",
|
|
249
|
-
onChange: (
|
|
250
|
-
onFocus: (
|
|
251
|
-
|
|
259
|
+
onChange: (p) => n(p.target.value),
|
|
260
|
+
onFocus: (p) => {
|
|
261
|
+
p.target.style.borderColor = "var(--fc-color-primary, #3b82f6)";
|
|
252
262
|
},
|
|
253
|
-
onBlur: (
|
|
254
|
-
|
|
263
|
+
onBlur: (p) => {
|
|
264
|
+
p.target.style.borderColor = "", a == null || a();
|
|
255
265
|
},
|
|
256
266
|
disabled: r,
|
|
257
|
-
placeholder:
|
|
258
|
-
readOnly:
|
|
259
|
-
maxLength:
|
|
267
|
+
placeholder: s,
|
|
268
|
+
readOnly: l,
|
|
269
|
+
maxLength: f,
|
|
260
270
|
"aria-disabled": r || void 0,
|
|
261
|
-
"aria-readonly":
|
|
271
|
+
"aria-readonly": l || void 0
|
|
262
272
|
}
|
|
263
273
|
);
|
|
264
|
-
return u ||
|
|
274
|
+
return u || i ? /* @__PURE__ */ y("div", { className: "flex items-stretch", children: [
|
|
265
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 }),
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
] }) :
|
|
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;
|
|
269
279
|
}
|
|
270
|
-
const
|
|
271
|
-
function
|
|
280
|
+
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
|
+
function ye({
|
|
272
282
|
value: e,
|
|
273
283
|
onChange: n,
|
|
274
|
-
onBlur:
|
|
284
|
+
onBlur: a,
|
|
275
285
|
disabled: r,
|
|
276
|
-
placeholder:
|
|
286
|
+
placeholder: s,
|
|
277
287
|
min: o,
|
|
278
|
-
max:
|
|
288
|
+
max: l,
|
|
279
289
|
step: u = 1,
|
|
280
|
-
precision:
|
|
281
|
-
readOnly:
|
|
290
|
+
precision: i,
|
|
291
|
+
readOnly: f,
|
|
282
292
|
prefix: d,
|
|
283
|
-
suffix:
|
|
284
|
-
className:
|
|
293
|
+
suffix: g,
|
|
294
|
+
className: m
|
|
285
295
|
}) {
|
|
286
|
-
const
|
|
287
|
-
function
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
296
|
+
const p = `${ge} ${r ? "opacity-50 cursor-not-allowed bg-gray-100" : ""} ${d ? "rounded-l-none" : ""} ${g ? "rounded-r-none" : ""} ${m ?? ""}`.trim();
|
|
297
|
+
function S(j) {
|
|
298
|
+
const E = j.target.value;
|
|
299
|
+
if (E === "") {
|
|
290
300
|
n(null);
|
|
291
301
|
return;
|
|
292
302
|
}
|
|
293
|
-
let
|
|
294
|
-
Number.isNaN(
|
|
303
|
+
let R = Number.parseFloat(E);
|
|
304
|
+
Number.isNaN(R) || (i !== void 0 && (R = Number.parseFloat(R.toFixed(i))), n(R));
|
|
295
305
|
}
|
|
296
|
-
const
|
|
306
|
+
const $ = /* @__PURE__ */ t(
|
|
297
307
|
"input",
|
|
298
308
|
{
|
|
299
309
|
type: "number",
|
|
300
|
-
className:
|
|
310
|
+
className: p,
|
|
301
311
|
value: e ?? "",
|
|
302
|
-
onChange:
|
|
303
|
-
onFocus: (
|
|
304
|
-
|
|
312
|
+
onChange: S,
|
|
313
|
+
onFocus: (j) => {
|
|
314
|
+
j.target.style.borderColor = "var(--fc-color-primary, #3b82f6)";
|
|
305
315
|
},
|
|
306
|
-
onBlur: (
|
|
307
|
-
|
|
316
|
+
onBlur: (j) => {
|
|
317
|
+
j.target.style.borderColor = "", a == null || a();
|
|
308
318
|
},
|
|
309
319
|
disabled: r,
|
|
310
|
-
placeholder:
|
|
320
|
+
placeholder: s,
|
|
311
321
|
min: o,
|
|
312
|
-
max:
|
|
322
|
+
max: l,
|
|
313
323
|
step: u,
|
|
314
|
-
readOnly:
|
|
324
|
+
readOnly: f,
|
|
315
325
|
"aria-disabled": r || void 0,
|
|
316
|
-
"aria-readonly":
|
|
326
|
+
"aria-readonly": f || void 0
|
|
317
327
|
}
|
|
318
328
|
);
|
|
319
|
-
return d ||
|
|
329
|
+
return d || g ? /* @__PURE__ */ y("div", { className: "flex items-stretch", children: [
|
|
320
330
|
d && /* @__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: d }),
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
] }) :
|
|
331
|
+
$,
|
|
332
|
+
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
|
+
] }) : $;
|
|
324
334
|
}
|
|
325
|
-
const
|
|
326
|
-
function
|
|
335
|
+
const he = "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";
|
|
336
|
+
function xe({
|
|
327
337
|
value: e,
|
|
328
338
|
onChange: n,
|
|
329
|
-
onBlur:
|
|
339
|
+
onBlur: a,
|
|
330
340
|
disabled: r,
|
|
331
|
-
placeholder:
|
|
341
|
+
placeholder: s,
|
|
332
342
|
rows: o = 3,
|
|
333
|
-
readOnly:
|
|
343
|
+
readOnly: l,
|
|
334
344
|
autoResize: u,
|
|
335
|
-
maxLength:
|
|
336
|
-
className:
|
|
345
|
+
maxLength: i,
|
|
346
|
+
className: f
|
|
337
347
|
}) {
|
|
338
|
-
const d =
|
|
348
|
+
const d = A(null), g = D(() => {
|
|
339
349
|
if (!u || !d.current) return;
|
|
340
|
-
const
|
|
341
|
-
|
|
350
|
+
const b = d.current;
|
|
351
|
+
b.style.height = "auto", b.style.height = `${b.scrollHeight}px`;
|
|
342
352
|
}, [u]);
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}, [e,
|
|
346
|
-
const v = `${
|
|
353
|
+
re(() => {
|
|
354
|
+
g();
|
|
355
|
+
}, [e, g]);
|
|
356
|
+
const v = `${he} ${r ? "opacity-50 cursor-not-allowed bg-gray-100" : ""} ${u ? "resize-none overflow-hidden" : ""} ${f ?? ""}`.trim();
|
|
347
357
|
return /* @__PURE__ */ t(
|
|
348
358
|
"textarea",
|
|
349
359
|
{
|
|
350
360
|
ref: d,
|
|
351
361
|
className: v,
|
|
352
362
|
value: e ?? "",
|
|
353
|
-
onChange: (
|
|
354
|
-
n(
|
|
363
|
+
onChange: (b) => {
|
|
364
|
+
n(b.target.value);
|
|
355
365
|
},
|
|
356
|
-
onFocus: (
|
|
357
|
-
|
|
366
|
+
onFocus: (b) => {
|
|
367
|
+
b.target.style.borderColor = "var(--fc-color-primary, #3b82f6)";
|
|
358
368
|
},
|
|
359
|
-
onBlur: (
|
|
360
|
-
|
|
369
|
+
onBlur: (b) => {
|
|
370
|
+
b.target.style.borderColor = "", a == null || a();
|
|
361
371
|
},
|
|
362
372
|
disabled: r,
|
|
363
|
-
placeholder:
|
|
373
|
+
placeholder: s,
|
|
364
374
|
rows: o,
|
|
365
|
-
readOnly:
|
|
366
|
-
maxLength:
|
|
375
|
+
readOnly: l,
|
|
376
|
+
maxLength: i,
|
|
367
377
|
"aria-disabled": r || void 0,
|
|
368
|
-
"aria-readonly":
|
|
378
|
+
"aria-readonly": l || void 0
|
|
369
379
|
}
|
|
370
380
|
);
|
|
371
381
|
}
|
|
372
|
-
function
|
|
382
|
+
function ve({
|
|
373
383
|
value: e,
|
|
374
384
|
onChange: n,
|
|
375
|
-
onBlur:
|
|
385
|
+
onBlur: a,
|
|
376
386
|
disabled: r,
|
|
377
|
-
placeholder:
|
|
387
|
+
placeholder: s = "Select...",
|
|
378
388
|
options: o,
|
|
379
|
-
multiple:
|
|
389
|
+
multiple: l = !1,
|
|
380
390
|
searchable: u = !1,
|
|
381
|
-
clearable:
|
|
382
|
-
className:
|
|
391
|
+
clearable: i = !1,
|
|
392
|
+
className: f
|
|
383
393
|
}) {
|
|
384
|
-
const [d,
|
|
385
|
-
if (
|
|
386
|
-
const c = o.find((w) => w.value ===
|
|
387
|
-
return (c == null ? void 0 : c.label) ?? String(
|
|
388
|
-
})(),
|
|
389
|
-
function
|
|
390
|
-
return
|
|
394
|
+
const [d, g] = F(!1), [m, h] = F(""), [v, b] = F(-1), p = A(null), S = A(null), $ = e == null ? [] : Array.isArray(e) ? e : [e], j = (() => {
|
|
395
|
+
if ($.length === 0 || l) return "";
|
|
396
|
+
const c = o.find((w) => w.value === $[0]);
|
|
397
|
+
return (c == null ? void 0 : c.label) ?? String($[0]);
|
|
398
|
+
})(), E = m ? o.filter((c) => c.label.toLowerCase().includes(m.toLowerCase())) : o;
|
|
399
|
+
function R(c) {
|
|
400
|
+
return $.includes(c);
|
|
391
401
|
}
|
|
392
|
-
function
|
|
393
|
-
const w = o.find((
|
|
402
|
+
function M(c) {
|
|
403
|
+
const w = o.find((x) => x.value === c);
|
|
394
404
|
return (w == null ? void 0 : w.label) ?? String(c);
|
|
395
405
|
}
|
|
396
|
-
const
|
|
397
|
-
|
|
406
|
+
const k = D(() => {
|
|
407
|
+
g(!0), b(-1), h(""), setTimeout(() => {
|
|
398
408
|
var c;
|
|
399
|
-
return (c =
|
|
409
|
+
return (c = S.current) == null ? void 0 : c.focus();
|
|
400
410
|
}, 0);
|
|
401
|
-
}, []),
|
|
402
|
-
|
|
403
|
-
}, [
|
|
404
|
-
function
|
|
405
|
-
r || (d ?
|
|
411
|
+
}, []), I = D(() => {
|
|
412
|
+
g(!1), h(""), a == null || a();
|
|
413
|
+
}, [a]);
|
|
414
|
+
function z() {
|
|
415
|
+
r || (d ? I() : k());
|
|
406
416
|
}
|
|
407
|
-
function
|
|
417
|
+
function q(c) {
|
|
408
418
|
if (!c.disabled)
|
|
409
|
-
if (
|
|
410
|
-
const w = [
|
|
411
|
-
|
|
419
|
+
if (l) {
|
|
420
|
+
const w = [...$], x = w.indexOf(c.value);
|
|
421
|
+
x >= 0 ? w.splice(x, 1) : w.push(c.value), n(w);
|
|
412
422
|
} else
|
|
413
|
-
n(c.value),
|
|
423
|
+
n(c.value), I();
|
|
414
424
|
}
|
|
415
425
|
function _(c) {
|
|
416
426
|
if (r) return;
|
|
417
|
-
const w =
|
|
418
|
-
n(w.length ? w :
|
|
427
|
+
const w = $.filter((x) => x !== c);
|
|
428
|
+
n(w.length ? w : l ? [] : null);
|
|
419
429
|
}
|
|
420
430
|
function U(c) {
|
|
421
|
-
c.stopPropagation(), n(
|
|
431
|
+
c.stopPropagation(), n(l ? [] : null);
|
|
422
432
|
}
|
|
423
|
-
function
|
|
433
|
+
function H(c) {
|
|
424
434
|
if (!d) {
|
|
425
|
-
(c.key === "Enter" || c.key === " " || c.key === "ArrowDown") && (c.preventDefault(),
|
|
435
|
+
(c.key === "Enter" || c.key === " " || c.key === "ArrowDown") && (c.preventDefault(), k());
|
|
426
436
|
return;
|
|
427
437
|
}
|
|
428
438
|
switch (c.key) {
|
|
429
439
|
case "ArrowDown":
|
|
430
|
-
c.preventDefault(),
|
|
440
|
+
c.preventDefault(), b((w) => Math.min(w + 1, E.length - 1));
|
|
431
441
|
break;
|
|
432
442
|
case "ArrowUp":
|
|
433
|
-
c.preventDefault(),
|
|
443
|
+
c.preventDefault(), b((w) => Math.max(w - 1, 0));
|
|
434
444
|
break;
|
|
435
445
|
case "Enter":
|
|
436
|
-
c.preventDefault(), v >= 0 &&
|
|
446
|
+
c.preventDefault(), v >= 0 && E[v] && q(E[v]);
|
|
437
447
|
break;
|
|
438
448
|
case "Escape":
|
|
439
|
-
c.preventDefault(),
|
|
449
|
+
c.preventDefault(), I();
|
|
440
450
|
break;
|
|
441
451
|
}
|
|
442
452
|
}
|
|
443
|
-
return
|
|
453
|
+
return re(() => {
|
|
444
454
|
function c(w) {
|
|
445
|
-
|
|
455
|
+
p.current && !p.current.contains(w.target) && I();
|
|
446
456
|
}
|
|
447
457
|
return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
|
|
448
|
-
}, [
|
|
458
|
+
}, [I]), /* @__PURE__ */ y(
|
|
449
459
|
"div",
|
|
450
460
|
{
|
|
451
|
-
ref:
|
|
452
|
-
className: `relative w-full ${r ? "opacity-50 cursor-not-allowed" : ""} ${
|
|
461
|
+
ref: p,
|
|
462
|
+
className: `relative w-full ${r ? "opacity-50 cursor-not-allowed" : ""} ${f ?? ""}`,
|
|
453
463
|
children: [
|
|
454
|
-
/* @__PURE__ */
|
|
464
|
+
/* @__PURE__ */ y(
|
|
455
465
|
"div",
|
|
456
466
|
{
|
|
457
467
|
role: "combobox",
|
|
@@ -460,11 +470,11 @@ function he({
|
|
|
460
470
|
tabIndex: 0,
|
|
461
471
|
className: `flex min-h-[38px] w-full cursor-pointer items-center rounded-md border border-gray-300 bg-white px-3 py-1.5 text-sm transition-colors duration-200 ${d ? "ring-2 ring-blue-500/20" : ""} ${r ? "pointer-events-none bg-gray-100" : ""}`,
|
|
462
472
|
style: d ? { borderColor: "var(--fc-color-primary, #3b82f6)" } : {},
|
|
463
|
-
onClick:
|
|
464
|
-
onKeyDown:
|
|
473
|
+
onClick: z,
|
|
474
|
+
onKeyDown: H,
|
|
465
475
|
children: [
|
|
466
|
-
/* @__PURE__ */
|
|
467
|
-
|
|
476
|
+
/* @__PURE__ */ y("div", { className: "flex flex-1 flex-wrap items-center gap-1", children: [
|
|
477
|
+
l && $.map((c) => /* @__PURE__ */ y(
|
|
468
478
|
"span",
|
|
469
479
|
{
|
|
470
480
|
className: "inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs",
|
|
@@ -473,7 +483,7 @@ function he({
|
|
|
473
483
|
color: "var(--fc-color-primary, #3b82f6)"
|
|
474
484
|
},
|
|
475
485
|
children: [
|
|
476
|
-
|
|
486
|
+
M(c),
|
|
477
487
|
/* @__PURE__ */ t(
|
|
478
488
|
"button",
|
|
479
489
|
{
|
|
@@ -491,11 +501,11 @@ function he({
|
|
|
491
501
|
},
|
|
492
502
|
String(c)
|
|
493
503
|
)),
|
|
494
|
-
!
|
|
495
|
-
|
|
496
|
-
|
|
504
|
+
!l && j && /* @__PURE__ */ t("span", { className: "truncate", children: j }),
|
|
505
|
+
$.length === 0 && !l && /* @__PURE__ */ t("span", { className: "text-gray-400", children: s }),
|
|
506
|
+
l && $.length === 0 && /* @__PURE__ */ t("span", { className: "text-gray-400", children: s })
|
|
497
507
|
] }),
|
|
498
|
-
|
|
508
|
+
i && $.length > 0 && !r && /* @__PURE__ */ t(
|
|
499
509
|
"button",
|
|
500
510
|
{
|
|
501
511
|
type: "button",
|
|
@@ -525,17 +535,17 @@ function he({
|
|
|
525
535
|
]
|
|
526
536
|
}
|
|
527
537
|
),
|
|
528
|
-
d && /* @__PURE__ */
|
|
538
|
+
d && /* @__PURE__ */ y("div", { className: "absolute z-50 mt-1 w-full rounded-md border border-gray-200 bg-white shadow-lg", children: [
|
|
529
539
|
u && /* @__PURE__ */ t("div", { className: "border-b border-gray-200 p-2", children: /* @__PURE__ */ t(
|
|
530
540
|
"input",
|
|
531
541
|
{
|
|
532
|
-
ref:
|
|
542
|
+
ref: S,
|
|
533
543
|
type: "text",
|
|
534
544
|
className: "w-full rounded border border-gray-300 px-2 py-1 text-sm focus:outline-none fc-select-search",
|
|
535
545
|
placeholder: "Search...",
|
|
536
|
-
value:
|
|
537
|
-
onChange: (c) =>
|
|
538
|
-
onKeyDown:
|
|
546
|
+
value: m,
|
|
547
|
+
onChange: (c) => h(c.target.value),
|
|
548
|
+
onKeyDown: H,
|
|
539
549
|
onFocus: (c) => {
|
|
540
550
|
c.target.style.borderColor = "var(--fc-color-primary, #3b82f6)";
|
|
541
551
|
},
|
|
@@ -544,45 +554,45 @@ function he({
|
|
|
544
554
|
}
|
|
545
555
|
}
|
|
546
556
|
) }),
|
|
547
|
-
/* @__PURE__ */
|
|
548
|
-
|
|
557
|
+
/* @__PURE__ */ y("ul", { role: "listbox", className: "max-h-60 overflow-auto py-1", children: [
|
|
558
|
+
E.map((c, w) => /* @__PURE__ */ t(
|
|
549
559
|
"li",
|
|
550
560
|
{
|
|
551
561
|
role: "option",
|
|
552
|
-
"aria-selected":
|
|
553
|
-
className: `cursor-pointer px-3 py-2 text-sm transition-colors duration-200 ${
|
|
554
|
-
style:
|
|
562
|
+
"aria-selected": R(c.value),
|
|
563
|
+
className: `cursor-pointer px-3 py-2 text-sm transition-colors duration-200 ${R(c.value) ? "" : "text-gray-900"} ${v === w ? "bg-gray-100" : ""} ${c.disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-gray-50"}`,
|
|
564
|
+
style: R(c.value) ? {
|
|
555
565
|
backgroundColor: "color-mix(in srgb, var(--fc-color-primary, #3b82f6) 8%, white)",
|
|
556
566
|
color: "var(--fc-color-primary, #3b82f6)"
|
|
557
567
|
} : {},
|
|
558
|
-
onClick: () =>
|
|
559
|
-
onMouseEnter: () =>
|
|
568
|
+
onClick: () => q(c),
|
|
569
|
+
onMouseEnter: () => b(w),
|
|
560
570
|
children: c.label
|
|
561
571
|
},
|
|
562
572
|
String(c.value)
|
|
563
573
|
)),
|
|
564
|
-
|
|
574
|
+
E.length === 0 && /* @__PURE__ */ t("li", { className: "px-3 py-2 text-sm text-gray-400", children: "No options found" })
|
|
565
575
|
] })
|
|
566
576
|
] })
|
|
567
577
|
]
|
|
568
578
|
}
|
|
569
579
|
);
|
|
570
580
|
}
|
|
571
|
-
function
|
|
581
|
+
function we({
|
|
572
582
|
value: e,
|
|
573
583
|
onChange: n,
|
|
574
|
-
onBlur:
|
|
584
|
+
onBlur: a,
|
|
575
585
|
disabled: r,
|
|
576
|
-
label:
|
|
586
|
+
label: s,
|
|
577
587
|
className: o
|
|
578
588
|
}) {
|
|
579
|
-
function
|
|
589
|
+
function l() {
|
|
580
590
|
r || n(!e);
|
|
581
591
|
}
|
|
582
|
-
function u(
|
|
583
|
-
(
|
|
592
|
+
function u(i) {
|
|
593
|
+
(i.key === " " || i.key === "Enter") && (i.preventDefault(), l());
|
|
584
594
|
}
|
|
585
|
-
return /* @__PURE__ */
|
|
595
|
+
return /* @__PURE__ */ y(
|
|
586
596
|
"label",
|
|
587
597
|
{
|
|
588
598
|
className: `inline-flex items-center gap-2 select-none ${r ? "opacity-50 cursor-not-allowed" : "cursor-pointer"} ${o ?? ""}`,
|
|
@@ -594,7 +604,7 @@ function xe({
|
|
|
594
604
|
checked: e ?? !1,
|
|
595
605
|
onChange: () => {
|
|
596
606
|
},
|
|
597
|
-
onBlur:
|
|
607
|
+
onBlur: a,
|
|
598
608
|
disabled: r,
|
|
599
609
|
className: "sr-only"
|
|
600
610
|
}
|
|
@@ -611,8 +621,8 @@ function xe({
|
|
|
611
621
|
borderColor: "var(--fc-color-primary, #3b82f6)",
|
|
612
622
|
backgroundColor: "var(--fc-color-primary, #3b82f6)"
|
|
613
623
|
} : {},
|
|
614
|
-
onClick: (
|
|
615
|
-
|
|
624
|
+
onClick: (i) => {
|
|
625
|
+
i.preventDefault(), l();
|
|
616
626
|
},
|
|
617
627
|
onKeyDown: u,
|
|
618
628
|
children: e && /* @__PURE__ */ t(
|
|
@@ -629,52 +639,52 @@ function xe({
|
|
|
629
639
|
)
|
|
630
640
|
}
|
|
631
641
|
),
|
|
632
|
-
|
|
642
|
+
s && /* @__PURE__ */ t("span", { className: "text-sm text-gray-700", children: s })
|
|
633
643
|
]
|
|
634
644
|
}
|
|
635
645
|
);
|
|
636
646
|
}
|
|
637
|
-
function
|
|
647
|
+
function Ne({
|
|
638
648
|
name: e,
|
|
639
649
|
value: n,
|
|
640
|
-
onChange:
|
|
650
|
+
onChange: a,
|
|
641
651
|
onBlur: r,
|
|
642
|
-
disabled:
|
|
652
|
+
disabled: s,
|
|
643
653
|
options: o,
|
|
644
|
-
inline:
|
|
654
|
+
inline: l = !1,
|
|
645
655
|
className: u
|
|
646
656
|
}) {
|
|
647
|
-
function
|
|
648
|
-
return n ===
|
|
657
|
+
function i(m) {
|
|
658
|
+
return n === m;
|
|
649
659
|
}
|
|
650
|
-
function m
|
|
651
|
-
return
|
|
660
|
+
function f(m) {
|
|
661
|
+
return s === !0 || !!m.disabled;
|
|
652
662
|
}
|
|
653
|
-
function d(
|
|
654
|
-
m
|
|
663
|
+
function d(m) {
|
|
664
|
+
f(m) || a(m.value);
|
|
655
665
|
}
|
|
656
|
-
function
|
|
657
|
-
(
|
|
666
|
+
function g(m, h) {
|
|
667
|
+
(m.key === " " || m.key === "Enter") && (m.preventDefault(), d(h));
|
|
658
668
|
}
|
|
659
669
|
return /* @__PURE__ */ t(
|
|
660
670
|
"div",
|
|
661
671
|
{
|
|
662
672
|
role: "radiogroup",
|
|
663
|
-
className: `${
|
|
664
|
-
children: o.map((
|
|
673
|
+
className: `${l ? "flex flex-wrap gap-4" : "flex flex-col gap-2"} ${u ?? ""}`,
|
|
674
|
+
children: o.map((m) => /* @__PURE__ */ y(
|
|
665
675
|
"label",
|
|
666
676
|
{
|
|
667
|
-
className: `inline-flex items-center gap-2 select-none ${m
|
|
677
|
+
className: `inline-flex items-center gap-2 select-none ${f(m) ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}`,
|
|
668
678
|
children: [
|
|
669
679
|
/* @__PURE__ */ t(
|
|
670
680
|
"input",
|
|
671
681
|
{
|
|
672
682
|
type: "radio",
|
|
673
|
-
checked:
|
|
674
|
-
disabled: m
|
|
683
|
+
checked: i(m.value),
|
|
684
|
+
disabled: f(m),
|
|
675
685
|
className: "sr-only",
|
|
676
686
|
name: e,
|
|
677
|
-
onChange: () => d(
|
|
687
|
+
onChange: () => d(m),
|
|
678
688
|
onBlur: r
|
|
679
689
|
}
|
|
680
690
|
),
|
|
@@ -682,14 +692,14 @@ function ve({
|
|
|
682
692
|
"div",
|
|
683
693
|
{
|
|
684
694
|
role: "radio",
|
|
685
|
-
"aria-checked":
|
|
686
|
-
"aria-disabled": m
|
|
695
|
+
"aria-checked": i(m.value),
|
|
696
|
+
"aria-disabled": f(m) || void 0,
|
|
687
697
|
tabIndex: 0,
|
|
688
|
-
className: `flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 transition-colors duration-200 ${
|
|
689
|
-
style:
|
|
690
|
-
onClick: () => d(
|
|
691
|
-
onKeyDown: (
|
|
692
|
-
children:
|
|
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(
|
|
693
703
|
"div",
|
|
694
704
|
{
|
|
695
705
|
className: "h-2.5 w-2.5 rounded-full",
|
|
@@ -700,33 +710,33 @@ function ve({
|
|
|
700
710
|
)
|
|
701
711
|
}
|
|
702
712
|
),
|
|
703
|
-
/* @__PURE__ */ t("span", { className: "text-sm text-gray-700", children:
|
|
713
|
+
/* @__PURE__ */ t("span", { className: "text-sm text-gray-700", children: m.label })
|
|
704
714
|
]
|
|
705
715
|
},
|
|
706
|
-
String(
|
|
716
|
+
String(m.value)
|
|
707
717
|
))
|
|
708
718
|
}
|
|
709
719
|
);
|
|
710
720
|
}
|
|
711
|
-
function
|
|
721
|
+
function Ce({
|
|
712
722
|
value: e,
|
|
713
723
|
onChange: n,
|
|
714
|
-
onBlur:
|
|
724
|
+
onBlur: a,
|
|
715
725
|
disabled: r,
|
|
716
|
-
activeLabel:
|
|
726
|
+
activeLabel: s,
|
|
717
727
|
inactiveLabel: o,
|
|
718
|
-
className:
|
|
728
|
+
className: l
|
|
719
729
|
}) {
|
|
720
730
|
function u() {
|
|
721
731
|
r || n(!e);
|
|
722
732
|
}
|
|
723
|
-
function
|
|
724
|
-
(
|
|
733
|
+
function i(f) {
|
|
734
|
+
(f.key === " " || f.key === "Enter") && (f.preventDefault(), u());
|
|
725
735
|
}
|
|
726
|
-
return /* @__PURE__ */
|
|
736
|
+
return /* @__PURE__ */ y(
|
|
727
737
|
"label",
|
|
728
738
|
{
|
|
729
|
-
className: `inline-flex items-center gap-2 select-none ${r ? "opacity-50 cursor-not-allowed" : "cursor-pointer"} ${
|
|
739
|
+
className: `inline-flex items-center gap-2 select-none ${r ? "opacity-50 cursor-not-allowed" : "cursor-pointer"} ${l ?? ""}`,
|
|
730
740
|
children: [
|
|
731
741
|
o && /* @__PURE__ */ t("span", { className: "text-sm text-gray-600", children: o }),
|
|
732
742
|
/* @__PURE__ */ t(
|
|
@@ -735,7 +745,7 @@ function we({
|
|
|
735
745
|
type: "checkbox",
|
|
736
746
|
checked: e ?? !1,
|
|
737
747
|
onChange: u,
|
|
738
|
-
onBlur:
|
|
748
|
+
onBlur: a,
|
|
739
749
|
disabled: r,
|
|
740
750
|
className: "sr-only"
|
|
741
751
|
}
|
|
@@ -751,7 +761,7 @@ function we({
|
|
|
751
761
|
className: `relative inline-flex h-6 w-11 shrink-0 rounded-full border-2 border-transparent transition-colors duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)] ${e ? "" : "bg-gray-300"} ${r ? "pointer-events-none" : "focus:outline-none focus:ring-2 focus:ring-blue-500/20"}`,
|
|
752
762
|
style: e ? { backgroundColor: "var(--fc-color-primary, #3b82f6)" } : {},
|
|
753
763
|
onClick: u,
|
|
754
|
-
onKeyDown:
|
|
764
|
+
onKeyDown: i,
|
|
755
765
|
children: /* @__PURE__ */ t(
|
|
756
766
|
"span",
|
|
757
767
|
{
|
|
@@ -761,41 +771,41 @@ function we({
|
|
|
761
771
|
)
|
|
762
772
|
}
|
|
763
773
|
),
|
|
764
|
-
|
|
774
|
+
s && /* @__PURE__ */ t("span", { className: "text-sm text-gray-600", children: s })
|
|
765
775
|
]
|
|
766
776
|
}
|
|
767
777
|
);
|
|
768
778
|
}
|
|
769
|
-
function
|
|
779
|
+
function $e({
|
|
770
780
|
value: e,
|
|
771
781
|
onChange: n,
|
|
772
|
-
onBlur:
|
|
782
|
+
onBlur: a,
|
|
773
783
|
disabled: r,
|
|
774
|
-
min:
|
|
784
|
+
min: s = 0,
|
|
775
785
|
max: o = 100,
|
|
776
|
-
step:
|
|
786
|
+
step: l = 1,
|
|
777
787
|
showTooltip: u = !0,
|
|
778
|
-
className:
|
|
788
|
+
className: i
|
|
779
789
|
}) {
|
|
780
|
-
const [
|
|
781
|
-
return /* @__PURE__ */
|
|
790
|
+
const [f, d] = F(!1), g = e ?? s, m = o - s, h = m === 0 ? 0 : (g - s) / m * 100;
|
|
791
|
+
return /* @__PURE__ */ y(
|
|
782
792
|
"div",
|
|
783
793
|
{
|
|
784
|
-
className: `relative w-full py-2 ${r ? "opacity-50 cursor-not-allowed" : ""} ${
|
|
794
|
+
className: `relative w-full py-2 ${r ? "opacity-50 cursor-not-allowed" : ""} ${i ?? ""}`,
|
|
785
795
|
children: [
|
|
786
|
-
u &&
|
|
796
|
+
u && f && /* @__PURE__ */ t(
|
|
787
797
|
"div",
|
|
788
798
|
{
|
|
789
799
|
className: "absolute -top-8 rounded bg-gray-800 px-2 py-1 text-xs text-white shadow-sm transition-opacity duration-200",
|
|
790
|
-
style: { left: `calc(${
|
|
791
|
-
children:
|
|
800
|
+
style: { left: `calc(${h}% - 16px)` },
|
|
801
|
+
children: g
|
|
792
802
|
}
|
|
793
803
|
),
|
|
794
804
|
/* @__PURE__ */ t(
|
|
795
805
|
"input",
|
|
796
806
|
{
|
|
797
807
|
type: "range",
|
|
798
|
-
value:
|
|
808
|
+
value: g,
|
|
799
809
|
onChange: (v) => n(Number.parseFloat(v.target.value)),
|
|
800
810
|
onMouseDown: () => d(!0),
|
|
801
811
|
onMouseUp: () => d(!1),
|
|
@@ -803,84 +813,84 @@ function Ne({
|
|
|
803
813
|
onTouchEnd: () => d(!1),
|
|
804
814
|
onFocus: () => d(!0),
|
|
805
815
|
onBlur: (v) => {
|
|
806
|
-
d(!1),
|
|
816
|
+
d(!1), a == null || a();
|
|
807
817
|
},
|
|
808
818
|
disabled: r,
|
|
809
|
-
min:
|
|
819
|
+
min: s,
|
|
810
820
|
max: o,
|
|
811
|
-
step:
|
|
812
|
-
"aria-valuenow":
|
|
813
|
-
"aria-valuemin":
|
|
821
|
+
step: l,
|
|
822
|
+
"aria-valuenow": g,
|
|
823
|
+
"aria-valuemin": s,
|
|
814
824
|
"aria-valuemax": o,
|
|
815
825
|
"aria-disabled": r || void 0,
|
|
816
826
|
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",
|
|
817
827
|
style: { accentColor: "var(--fc-color-primary, #3b82f6)" }
|
|
818
828
|
}
|
|
819
829
|
),
|
|
820
|
-
/* @__PURE__ */
|
|
821
|
-
/* @__PURE__ */ t("span", { children:
|
|
830
|
+
/* @__PURE__ */ y("div", { className: "mt-1 flex justify-between text-xs text-gray-400", children: [
|
|
831
|
+
/* @__PURE__ */ t("span", { children: s }),
|
|
822
832
|
/* @__PURE__ */ t("span", { children: o })
|
|
823
833
|
] })
|
|
824
834
|
]
|
|
825
835
|
}
|
|
826
836
|
);
|
|
827
837
|
}
|
|
828
|
-
function
|
|
838
|
+
function V(e) {
|
|
829
839
|
return e.replace(/[A-Z]/g, (n) => `-${n.toLowerCase()}`);
|
|
830
840
|
}
|
|
831
|
-
function
|
|
841
|
+
function ke(e) {
|
|
832
842
|
if (!e) return {};
|
|
833
843
|
const n = {};
|
|
834
844
|
if (e.colors)
|
|
835
|
-
for (const [
|
|
836
|
-
r && (n[`--fc-color-${
|
|
845
|
+
for (const [a, r] of Object.entries(e.colors))
|
|
846
|
+
r && (n[`--fc-color-${V(a)}`] = r);
|
|
837
847
|
if (e.typography)
|
|
838
|
-
for (const [
|
|
839
|
-
r && (n[`--fc-${
|
|
848
|
+
for (const [a, r] of Object.entries(e.typography))
|
|
849
|
+
r && (n[`--fc-${V(a)}`] = r);
|
|
840
850
|
if (e.spacing)
|
|
841
|
-
for (const [
|
|
842
|
-
r && (n[`--fc-${
|
|
851
|
+
for (const [a, r] of Object.entries(e.spacing))
|
|
852
|
+
r && (n[`--fc-${V(a)}`] = r);
|
|
843
853
|
if (e.borders)
|
|
844
|
-
for (const [
|
|
845
|
-
r && (n[`--fc-border-${
|
|
854
|
+
for (const [a, r] of Object.entries(e.borders))
|
|
855
|
+
r && (n[`--fc-border-${V(a)}`] = r);
|
|
846
856
|
if (e.shadows)
|
|
847
|
-
for (const [
|
|
848
|
-
r && (n[`--fc-shadow-${
|
|
857
|
+
for (const [a, r] of Object.entries(e.shadows))
|
|
858
|
+
r && (n[`--fc-shadow-${V(a)}`] = r);
|
|
849
859
|
if (e.transitions)
|
|
850
|
-
for (const [
|
|
851
|
-
r && (n[`--fc-transition-${
|
|
860
|
+
for (const [a, r] of Object.entries(e.transitions))
|
|
861
|
+
r && (n[`--fc-transition-${V(a)}`] = r);
|
|
852
862
|
return e.cssVars && Object.assign(n, e.cssVars), n;
|
|
853
863
|
}
|
|
854
|
-
function Q(e, n,
|
|
855
|
-
var
|
|
864
|
+
function Q(e, n, a, r, s) {
|
|
865
|
+
var i, f;
|
|
856
866
|
const o = e.translations;
|
|
857
|
-
if (!o) return
|
|
858
|
-
const
|
|
859
|
-
if ((
|
|
867
|
+
if (!o) return s;
|
|
868
|
+
const l = o[a];
|
|
869
|
+
if ((i = l == null ? void 0 : l.messages) != null && i[n]) return l.messages[n];
|
|
860
870
|
const u = o[r];
|
|
861
|
-
return ((
|
|
871
|
+
return ((f = u == null ? void 0 : u.messages) == null ? void 0 : f[n]) ?? s;
|
|
862
872
|
}
|
|
863
|
-
function X(e, n,
|
|
873
|
+
function X(e, n, a, r, s) {
|
|
864
874
|
const o = e.translations;
|
|
865
|
-
if (!o) return
|
|
866
|
-
const
|
|
867
|
-
if (
|
|
875
|
+
if (!o) return s;
|
|
876
|
+
const l = o[a];
|
|
877
|
+
if (l != null && l[n]) return l[n];
|
|
868
878
|
const u = o[r];
|
|
869
|
-
return (u == null ? void 0 : u[n]) ??
|
|
879
|
+
return (u == null ? void 0 : u[n]) ?? s;
|
|
870
880
|
}
|
|
871
881
|
function Y(e) {
|
|
872
882
|
return Array.isArray(e) ? e : [];
|
|
873
883
|
}
|
|
874
|
-
function
|
|
884
|
+
function Se({ field: e, value: n, onChange: a, onBlur: r, disabled: s }) {
|
|
875
885
|
switch (e.type) {
|
|
876
886
|
case "text":
|
|
877
887
|
return /* @__PURE__ */ t(
|
|
878
888
|
J,
|
|
879
889
|
{
|
|
880
890
|
value: String(n ?? ""),
|
|
881
|
-
onChange:
|
|
891
|
+
onChange: a,
|
|
882
892
|
onBlur: r,
|
|
883
|
-
disabled:
|
|
893
|
+
disabled: s,
|
|
884
894
|
placeholder: e.placeholder,
|
|
885
895
|
inputType: e.inputType,
|
|
886
896
|
readOnly: e.readOnly
|
|
@@ -888,12 +898,12 @@ function $e({ field: e, value: n, onChange: s, onBlur: r, disabled: a }) {
|
|
|
888
898
|
);
|
|
889
899
|
case "number":
|
|
890
900
|
return /* @__PURE__ */ t(
|
|
891
|
-
|
|
901
|
+
ye,
|
|
892
902
|
{
|
|
893
903
|
value: n,
|
|
894
|
-
onChange:
|
|
904
|
+
onChange: a,
|
|
895
905
|
onBlur: r,
|
|
896
|
-
disabled:
|
|
906
|
+
disabled: s,
|
|
897
907
|
placeholder: e.placeholder,
|
|
898
908
|
min: e.min,
|
|
899
909
|
max: e.max,
|
|
@@ -903,12 +913,12 @@ function $e({ field: e, value: n, onChange: s, onBlur: r, disabled: a }) {
|
|
|
903
913
|
);
|
|
904
914
|
case "textarea":
|
|
905
915
|
return /* @__PURE__ */ t(
|
|
906
|
-
|
|
916
|
+
xe,
|
|
907
917
|
{
|
|
908
918
|
value: String(n ?? ""),
|
|
909
|
-
onChange:
|
|
919
|
+
onChange: a,
|
|
910
920
|
onBlur: r,
|
|
911
|
-
disabled:
|
|
921
|
+
disabled: s,
|
|
912
922
|
placeholder: e.placeholder,
|
|
913
923
|
rows: e.rows,
|
|
914
924
|
readOnly: e.readOnly
|
|
@@ -916,56 +926,56 @@ function $e({ field: e, value: n, onChange: s, onBlur: r, disabled: a }) {
|
|
|
916
926
|
);
|
|
917
927
|
case "select":
|
|
918
928
|
return /* @__PURE__ */ t(
|
|
919
|
-
|
|
929
|
+
ve,
|
|
920
930
|
{
|
|
921
931
|
value: n,
|
|
922
|
-
onChange:
|
|
932
|
+
onChange: a,
|
|
923
933
|
onBlur: r,
|
|
924
|
-
disabled:
|
|
934
|
+
disabled: s,
|
|
925
935
|
placeholder: e.placeholder,
|
|
926
936
|
options: Y(e.options)
|
|
927
937
|
}
|
|
928
938
|
);
|
|
929
939
|
case "checkbox":
|
|
930
940
|
return /* @__PURE__ */ t(
|
|
931
|
-
|
|
941
|
+
we,
|
|
932
942
|
{
|
|
933
943
|
value: !!n,
|
|
934
|
-
onChange:
|
|
944
|
+
onChange: a,
|
|
935
945
|
onBlur: r,
|
|
936
|
-
disabled:
|
|
946
|
+
disabled: s
|
|
937
947
|
}
|
|
938
948
|
);
|
|
939
949
|
case "radio":
|
|
940
950
|
return /* @__PURE__ */ t(
|
|
941
|
-
|
|
951
|
+
Ne,
|
|
942
952
|
{
|
|
943
953
|
name: e.name,
|
|
944
954
|
value: n,
|
|
945
|
-
onChange:
|
|
955
|
+
onChange: a,
|
|
946
956
|
onBlur: r,
|
|
947
|
-
disabled:
|
|
957
|
+
disabled: s,
|
|
948
958
|
options: Y(e.options)
|
|
949
959
|
}
|
|
950
960
|
);
|
|
951
961
|
case "switch":
|
|
952
962
|
return /* @__PURE__ */ t(
|
|
953
|
-
|
|
963
|
+
Ce,
|
|
954
964
|
{
|
|
955
965
|
value: !!n,
|
|
956
|
-
onChange:
|
|
966
|
+
onChange: a,
|
|
957
967
|
onBlur: r,
|
|
958
|
-
disabled:
|
|
968
|
+
disabled: s
|
|
959
969
|
}
|
|
960
970
|
);
|
|
961
971
|
case "slider":
|
|
962
972
|
return /* @__PURE__ */ t(
|
|
963
|
-
|
|
973
|
+
$e,
|
|
964
974
|
{
|
|
965
975
|
value: n,
|
|
966
|
-
onChange:
|
|
976
|
+
onChange: a,
|
|
967
977
|
onBlur: r,
|
|
968
|
-
disabled:
|
|
978
|
+
disabled: s,
|
|
969
979
|
min: e.min,
|
|
970
980
|
max: e.max,
|
|
971
981
|
step: e.step
|
|
@@ -976,28 +986,28 @@ function $e({ field: e, value: n, onChange: s, onBlur: r, disabled: a }) {
|
|
|
976
986
|
J,
|
|
977
987
|
{
|
|
978
988
|
value: String(n ?? ""),
|
|
979
|
-
onChange:
|
|
989
|
+
onChange: a,
|
|
980
990
|
onBlur: r,
|
|
981
|
-
disabled:
|
|
991
|
+
disabled: s,
|
|
982
992
|
placeholder: e.placeholder
|
|
983
993
|
}
|
|
984
994
|
);
|
|
985
995
|
}
|
|
986
996
|
}
|
|
987
|
-
function
|
|
997
|
+
function ae(e) {
|
|
988
998
|
return e === "full" ? { gridColumn: "1 / -1" } : e === "auto" ? { gridColumn: "auto" } : typeof e == "number" ? { gridColumn: `span ${e} / span ${e}` } : { gridColumn: "span 12 / span 12" };
|
|
989
999
|
}
|
|
990
|
-
function
|
|
991
|
-
const r = n.errors[e.name] ?? [],
|
|
1000
|
+
function Fe(e, n, a) {
|
|
1001
|
+
const r = n.errors[e.name] ?? [], s = e.disabled === !0 || !1, o = {
|
|
992
1002
|
field: e,
|
|
993
1003
|
value: n.values[e.name],
|
|
994
|
-
onChange: (
|
|
1004
|
+
onChange: (i) => n.setFieldValue(e.name, i),
|
|
995
1005
|
onBlur: () => n.validateField(e.name),
|
|
996
1006
|
errors: r,
|
|
997
|
-
disabled:
|
|
998
|
-
}, u = (
|
|
1007
|
+
disabled: s
|
|
1008
|
+
}, u = (a == null ? void 0 : a[e.type]) ?? Se;
|
|
999
1009
|
return /* @__PURE__ */ t(
|
|
1000
|
-
|
|
1010
|
+
be,
|
|
1001
1011
|
{
|
|
1002
1012
|
label: e.label,
|
|
1003
1013
|
required: e.required,
|
|
@@ -1015,8 +1025,8 @@ function ke(e, n, s) {
|
|
|
1015
1025
|
e.name
|
|
1016
1026
|
);
|
|
1017
1027
|
}
|
|
1018
|
-
function
|
|
1019
|
-
const
|
|
1028
|
+
function De(e, n, a) {
|
|
1029
|
+
const s = {
|
|
1020
1030
|
start: "items-start",
|
|
1021
1031
|
center: "items-center",
|
|
1022
1032
|
end: "items-end",
|
|
@@ -1025,46 +1035,46 @@ function Se(e, n, s) {
|
|
|
1025
1035
|
return /* @__PURE__ */ t(
|
|
1026
1036
|
"div",
|
|
1027
1037
|
{
|
|
1028
|
-
className: `grid grid-cols-12 ${
|
|
1038
|
+
className: `grid grid-cols-12 ${s} ${e.className ?? ""}`,
|
|
1029
1039
|
style: { gap: o },
|
|
1030
1040
|
role: "group",
|
|
1031
|
-
children: e.children.map((
|
|
1041
|
+
children: e.children.map((l, u) => /* @__PURE__ */ t(
|
|
1032
1042
|
"div",
|
|
1033
1043
|
{
|
|
1034
|
-
style:
|
|
1035
|
-
children:
|
|
1044
|
+
style: ae(L(l) ? l.span : void 0),
|
|
1045
|
+
children: P(l, n, a)
|
|
1036
1046
|
},
|
|
1037
|
-
|
|
1047
|
+
L(l) ? l.name : `row-child-${u}`
|
|
1038
1048
|
))
|
|
1039
1049
|
}
|
|
1040
1050
|
);
|
|
1041
1051
|
}
|
|
1042
|
-
function
|
|
1052
|
+
function Re({
|
|
1043
1053
|
node: e,
|
|
1044
1054
|
form: n,
|
|
1045
|
-
components:
|
|
1055
|
+
components: a
|
|
1046
1056
|
}) {
|
|
1047
|
-
const [r,
|
|
1048
|
-
function
|
|
1049
|
-
e.collapsible &&
|
|
1057
|
+
const [r, s] = F(e.collapsed ?? !1), o = e.title ? `fc-group-${e.title.toLowerCase().replace(/\s+/g, "-")}` : void 0;
|
|
1058
|
+
function l() {
|
|
1059
|
+
e.collapsible && s(!r);
|
|
1050
1060
|
}
|
|
1051
1061
|
const u = e.collapsible ? "button" : "div";
|
|
1052
|
-
return /* @__PURE__ */
|
|
1062
|
+
return /* @__PURE__ */ y(
|
|
1053
1063
|
"fieldset",
|
|
1054
1064
|
{
|
|
1055
1065
|
className: `rounded-lg border border-gray-200 bg-white ${e.className ?? ""}`,
|
|
1056
1066
|
"aria-labelledby": o,
|
|
1057
1067
|
children: [
|
|
1058
|
-
(e.title || e.description) && /* @__PURE__ */ t("div", { className: "border-b border-gray-100 px-4 py-3", children: /* @__PURE__ */
|
|
1068
|
+
(e.title || e.description) && /* @__PURE__ */ t("div", { className: "border-b border-gray-100 px-4 py-3", children: /* @__PURE__ */ y(
|
|
1059
1069
|
u,
|
|
1060
1070
|
{
|
|
1061
1071
|
type: e.collapsible ? "button" : void 0,
|
|
1062
1072
|
className: `flex w-full items-center justify-between text-left ${e.collapsible ? "cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500/40 rounded" : ""}`,
|
|
1063
1073
|
"aria-expanded": e.collapsible ? !r : void 0,
|
|
1064
1074
|
"aria-controls": e.collapsible ? `fc-group-body-${o}` : void 0,
|
|
1065
|
-
onClick:
|
|
1075
|
+
onClick: l,
|
|
1066
1076
|
children: [
|
|
1067
|
-
/* @__PURE__ */
|
|
1077
|
+
/* @__PURE__ */ y("div", { children: [
|
|
1068
1078
|
e.title && /* @__PURE__ */ t(
|
|
1069
1079
|
"legend",
|
|
1070
1080
|
{
|
|
@@ -1101,48 +1111,48 @@ function Fe({
|
|
|
1101
1111
|
{
|
|
1102
1112
|
id: e.collapsible ? `fc-group-body-${o}` : void 0,
|
|
1103
1113
|
className: "p-4",
|
|
1104
|
-
children: e.children.map((
|
|
1114
|
+
children: e.children.map((i, f) => /* @__PURE__ */ t("div", { children: P(i, n, a) }, L(i) ? i.name : `group-child-${f}`))
|
|
1105
1115
|
}
|
|
1106
1116
|
)
|
|
1107
1117
|
]
|
|
1108
1118
|
}
|
|
1109
1119
|
);
|
|
1110
1120
|
}
|
|
1111
|
-
function
|
|
1121
|
+
function je({
|
|
1112
1122
|
node: e,
|
|
1113
1123
|
form: n,
|
|
1114
|
-
components:
|
|
1124
|
+
components: a
|
|
1115
1125
|
}) {
|
|
1116
|
-
const [r,
|
|
1117
|
-
function
|
|
1118
|
-
d || (
|
|
1119
|
-
const
|
|
1120
|
-
return
|
|
1121
|
-
}),
|
|
1126
|
+
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
|
+
function g() {
|
|
1128
|
+
d || (l((b) => {
|
|
1129
|
+
const p = new Set(b);
|
|
1130
|
+
return p.add(r), p;
|
|
1131
|
+
}), s((b) => b + 1));
|
|
1122
1132
|
}
|
|
1123
|
-
function
|
|
1124
|
-
|
|
1133
|
+
function m() {
|
|
1134
|
+
f || s((b) => b - 1);
|
|
1125
1135
|
}
|
|
1126
|
-
function
|
|
1127
|
-
e.linear &&
|
|
1136
|
+
function h(b) {
|
|
1137
|
+
e.linear && b > r || s(b);
|
|
1128
1138
|
}
|
|
1129
1139
|
const v = u[r];
|
|
1130
|
-
return /* @__PURE__ */
|
|
1131
|
-
/* @__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((
|
|
1140
|
+
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((b, p) => /* @__PURE__ */ y("li", { className: "flex items-center", children: [
|
|
1132
1142
|
/* @__PURE__ */ t(
|
|
1133
1143
|
"button",
|
|
1134
1144
|
{
|
|
1135
1145
|
type: "button",
|
|
1136
|
-
disabled: e.linear === !0 &&
|
|
1137
|
-
"aria-current":
|
|
1138
|
-
"aria-label": `Step ${
|
|
1139
|
-
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(
|
|
1140
|
-
style:
|
|
1146
|
+
disabled: e.linear === !0 && p > r,
|
|
1147
|
+
"aria-current": p === r ? "step" : void 0,
|
|
1148
|
+
"aria-label": `Step ${p + 1}: ${b.title}`,
|
|
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(p) && p !== r ? "border-green-500 bg-green-500 text-white" : p !== r ? "border-gray-300 bg-white text-gray-500" : "text-white"} ${e.linear === !0 && p > r ? "cursor-not-allowed" : "cursor-pointer hover:shadow-md"}`,
|
|
1150
|
+
style: p === r ? {
|
|
1141
1151
|
borderColor: "var(--fc-color-primary, #3b82f6)",
|
|
1142
1152
|
backgroundColor: "var(--fc-color-primary, #3b82f6)"
|
|
1143
1153
|
} : {},
|
|
1144
|
-
onClick: () =>
|
|
1145
|
-
children: o.has(
|
|
1154
|
+
onClick: () => h(p),
|
|
1155
|
+
children: o.has(p) && p !== r ? /* @__PURE__ */ t(
|
|
1146
1156
|
"svg",
|
|
1147
1157
|
{
|
|
1148
1158
|
className: "h-4 w-4 transition-transform duration-200",
|
|
@@ -1159,36 +1169,36 @@ function De({
|
|
|
1159
1169
|
}
|
|
1160
1170
|
)
|
|
1161
1171
|
}
|
|
1162
|
-
) : /* @__PURE__ */ t("span", { children:
|
|
1172
|
+
) : /* @__PURE__ */ t("span", { children: p + 1 })
|
|
1163
1173
|
}
|
|
1164
1174
|
),
|
|
1165
|
-
|
|
1175
|
+
p < u.length - 1 && /* @__PURE__ */ t(
|
|
1166
1176
|
"div",
|
|
1167
1177
|
{
|
|
1168
|
-
className: `mx-1 h-0.5 w-8 transition-colors duration-300 sm:w-12 ${o.has(
|
|
1178
|
+
className: `mx-1 h-0.5 w-8 transition-colors duration-300 sm:w-12 ${o.has(p) ? "bg-green-500" : "bg-gray-200"}`
|
|
1169
1179
|
}
|
|
1170
1180
|
)
|
|
1171
|
-
] },
|
|
1172
|
-
v && /* @__PURE__ */
|
|
1181
|
+
] }, b.title)) }) }),
|
|
1182
|
+
v && /* @__PURE__ */ y("div", { className: "text-center", children: [
|
|
1173
1183
|
/* @__PURE__ */ t("h3", { className: "text-base font-semibold text-gray-800", children: v.title }),
|
|
1174
1184
|
v.description && /* @__PURE__ */ t("p", { className: "mt-1 text-sm text-gray-500", children: v.description })
|
|
1175
1185
|
] }),
|
|
1176
|
-
v && /* @__PURE__ */ t("div", { children: v.children.map((
|
|
1177
|
-
/* @__PURE__ */
|
|
1186
|
+
v && /* @__PURE__ */ t("div", { children: v.children.map((b, p) => /* @__PURE__ */ t("div", { children: P(b, n, a) }, L(b) ? b.name : `step-child-${p}`)) }),
|
|
1187
|
+
/* @__PURE__ */ y("div", { className: "flex items-center justify-between border-t border-gray-100 pt-4", children: [
|
|
1178
1188
|
/* @__PURE__ */ t(
|
|
1179
1189
|
"button",
|
|
1180
1190
|
{
|
|
1181
1191
|
type: "button",
|
|
1182
|
-
disabled:
|
|
1192
|
+
disabled: f,
|
|
1183
1193
|
className: "rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 transition-colors duration-150 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500/40 disabled:cursor-not-allowed disabled:opacity-50",
|
|
1184
|
-
onClick:
|
|
1194
|
+
onClick: m,
|
|
1185
1195
|
children: "Previous"
|
|
1186
1196
|
}
|
|
1187
1197
|
),
|
|
1188
|
-
/* @__PURE__ */
|
|
1198
|
+
/* @__PURE__ */ y("span", { className: "text-xs text-gray-400", children: [
|
|
1189
1199
|
r + 1,
|
|
1190
1200
|
" / ",
|
|
1191
|
-
|
|
1201
|
+
i
|
|
1192
1202
|
] }),
|
|
1193
1203
|
d ? /* @__PURE__ */ t("div", { className: "w-[72px]" }) : /* @__PURE__ */ t(
|
|
1194
1204
|
"button",
|
|
@@ -1198,30 +1208,30 @@ function De({
|
|
|
1198
1208
|
style: {
|
|
1199
1209
|
backgroundColor: "var(--fc-color-primary, #3b82f6)"
|
|
1200
1210
|
},
|
|
1201
|
-
onClick:
|
|
1211
|
+
onClick: g,
|
|
1202
1212
|
children: "Next"
|
|
1203
1213
|
}
|
|
1204
1214
|
)
|
|
1205
1215
|
] })
|
|
1206
1216
|
] });
|
|
1207
1217
|
}
|
|
1208
|
-
function
|
|
1218
|
+
function Ee({
|
|
1209
1219
|
node: e,
|
|
1210
1220
|
form: n,
|
|
1211
|
-
components:
|
|
1221
|
+
components: a
|
|
1212
1222
|
}) {
|
|
1213
|
-
const [r,
|
|
1214
|
-
function
|
|
1215
|
-
|
|
1223
|
+
const [r, s] = F(0), o = e.tabs, l = o[r], u = `fc-tabpanel-${r}`;
|
|
1224
|
+
function i(f) {
|
|
1225
|
+
s(f);
|
|
1216
1226
|
}
|
|
1217
|
-
return /* @__PURE__ */
|
|
1227
|
+
return /* @__PURE__ */ y("div", { className: e.className ?? "", children: [
|
|
1218
1228
|
/* @__PURE__ */ t(
|
|
1219
1229
|
"div",
|
|
1220
1230
|
{
|
|
1221
1231
|
className: "relative flex border-b border-gray-200",
|
|
1222
1232
|
role: "tablist",
|
|
1223
1233
|
"aria-orientation": "horizontal",
|
|
1224
|
-
children: o.map((
|
|
1234
|
+
children: o.map((f, d) => /* @__PURE__ */ y(
|
|
1225
1235
|
"button",
|
|
1226
1236
|
{
|
|
1227
1237
|
id: `fc-tab-${d}`,
|
|
@@ -1232,9 +1242,9 @@ function Re({
|
|
|
1232
1242
|
tabIndex: d === r ? 0 : -1,
|
|
1233
1243
|
className: `relative px-4 py-2.5 text-sm font-medium transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blue-500/40 ${d !== r ? "text-gray-500 hover:text-gray-700" : ""}`,
|
|
1234
1244
|
style: d === r ? { color: "var(--fc-color-primary, #3b82f6)" } : {},
|
|
1235
|
-
onClick: () =>
|
|
1245
|
+
onClick: () => i(d),
|
|
1236
1246
|
children: [
|
|
1237
|
-
|
|
1247
|
+
f.title,
|
|
1238
1248
|
d === r && /* @__PURE__ */ t(
|
|
1239
1249
|
"span",
|
|
1240
1250
|
{
|
|
@@ -1246,11 +1256,11 @@ function Re({
|
|
|
1246
1256
|
)
|
|
1247
1257
|
]
|
|
1248
1258
|
},
|
|
1249
|
-
|
|
1259
|
+
f.title
|
|
1250
1260
|
))
|
|
1251
1261
|
}
|
|
1252
1262
|
),
|
|
1253
|
-
|
|
1263
|
+
l && /* @__PURE__ */ t(
|
|
1254
1264
|
"div",
|
|
1255
1265
|
{
|
|
1256
1266
|
id: u,
|
|
@@ -1258,31 +1268,31 @@ function Re({
|
|
|
1258
1268
|
"aria-labelledby": `fc-tab-${r}`,
|
|
1259
1269
|
tabIndex: 0,
|
|
1260
1270
|
className: "pt-4",
|
|
1261
|
-
children:
|
|
1271
|
+
children: l.children.map((f, d) => /* @__PURE__ */ t("div", { children: P(f, n, a) }, L(f) ? f.name : `tab-child-${d}`))
|
|
1262
1272
|
}
|
|
1263
1273
|
)
|
|
1264
1274
|
] });
|
|
1265
1275
|
}
|
|
1266
|
-
function
|
|
1267
|
-
return e.label ? /* @__PURE__ */
|
|
1276
|
+
function Ie(e) {
|
|
1277
|
+
return e.label ? /* @__PURE__ */ y("div", { className: `relative my-4 ${e.className ?? ""}`, children: [
|
|
1268
1278
|
/* @__PURE__ */ t("div", { className: "absolute inset-0 flex items-center", "aria-hidden": "true", children: /* @__PURE__ */ t("div", { className: "w-full border-t border-gray-200" }) }),
|
|
1269
1279
|
/* @__PURE__ */ t("div", { className: "relative flex justify-center", children: /* @__PURE__ */ t("span", { className: "bg-white px-3 text-sm text-gray-500", children: e.label }) })
|
|
1270
1280
|
] }) : /* @__PURE__ */ t("hr", { className: `my-4 border-gray-200 ${e.className ?? ""}` });
|
|
1271
1281
|
}
|
|
1272
|
-
function
|
|
1273
|
-
if (
|
|
1274
|
-
return
|
|
1282
|
+
function P(e, n, a) {
|
|
1283
|
+
if (L(e))
|
|
1284
|
+
return Fe(e, n, a);
|
|
1275
1285
|
switch (e.type) {
|
|
1276
1286
|
case "row":
|
|
1277
|
-
return
|
|
1287
|
+
return De(e, n, a);
|
|
1278
1288
|
case "group":
|
|
1279
|
-
return /* @__PURE__ */ t(
|
|
1289
|
+
return /* @__PURE__ */ t(Re, { node: e, form: n, components: a });
|
|
1280
1290
|
case "steps":
|
|
1281
|
-
return /* @__PURE__ */ t(
|
|
1291
|
+
return /* @__PURE__ */ t(je, { node: e, form: n, components: a });
|
|
1282
1292
|
case "tabs":
|
|
1283
|
-
return /* @__PURE__ */ t(
|
|
1293
|
+
return /* @__PURE__ */ t(Ee, { node: e, form: n, components: a });
|
|
1284
1294
|
case "divider":
|
|
1285
|
-
return
|
|
1295
|
+
return Ie(e);
|
|
1286
1296
|
case "html":
|
|
1287
1297
|
return /* @__PURE__ */ t(
|
|
1288
1298
|
"div",
|
|
@@ -1295,64 +1305,64 @@ function K(e, n, s) {
|
|
|
1295
1305
|
return null;
|
|
1296
1306
|
}
|
|
1297
1307
|
}
|
|
1298
|
-
function
|
|
1308
|
+
function Ve({
|
|
1299
1309
|
schema: e,
|
|
1300
1310
|
onSubmit: n,
|
|
1301
|
-
onError:
|
|
1302
|
-
locale: r
|
|
1303
|
-
fallbackLocale:
|
|
1311
|
+
onError: a,
|
|
1312
|
+
locale: r,
|
|
1313
|
+
fallbackLocale: s,
|
|
1304
1314
|
theme: o,
|
|
1305
|
-
components:
|
|
1315
|
+
components: l,
|
|
1306
1316
|
className: u
|
|
1307
1317
|
}) {
|
|
1308
|
-
var
|
|
1309
|
-
const l =
|
|
1310
|
-
|
|
1311
|
-
await n(
|
|
1312
|
-
}) : await
|
|
1313
|
-
},
|
|
1314
|
-
|
|
1318
|
+
var R, M;
|
|
1319
|
+
const i = me(), f = r ?? i.locale ?? "en", d = s ?? i.fallbackLocale ?? "en", g = o ?? i.theme, m = l ?? i.components, h = fe(e), v = ke(g), b = Q(e, "title", f, d, ""), p = Q(e, "description", f, d, ""), S = X(e, "submit", f, d, "Submit"), $ = X(e, "reset", f, d, "Reset"), j = async (k) => {
|
|
1320
|
+
k.preventDefault(), n ? await h.submit(async (I) => {
|
|
1321
|
+
await n(I);
|
|
1322
|
+
}) : await h.validate(), !h.isValid && a && a(h.errors);
|
|
1323
|
+
}, E = (k) => {
|
|
1324
|
+
k.preventDefault(), h.reset();
|
|
1315
1325
|
};
|
|
1316
|
-
return /* @__PURE__ */ t(
|
|
1326
|
+
return /* @__PURE__ */ t(te.Provider, { value: h, children: /* @__PURE__ */ y(
|
|
1317
1327
|
"form",
|
|
1318
1328
|
{
|
|
1319
|
-
className: `fc-form-builder ${((
|
|
1320
|
-
style:
|
|
1321
|
-
onSubmit:
|
|
1322
|
-
onReset:
|
|
1329
|
+
className: `fc-form-builder ${((R = g == null ? void 0 : g.components) == null ? void 0 : R.form) ?? ""} ${u ?? ""}`.trim(),
|
|
1330
|
+
style: v,
|
|
1331
|
+
onSubmit: j,
|
|
1332
|
+
onReset: E,
|
|
1323
1333
|
noValidate: !0,
|
|
1324
1334
|
children: [
|
|
1325
|
-
(
|
|
1326
|
-
|
|
1327
|
-
|
|
1335
|
+
(b || p) && /* @__PURE__ */ y("div", { className: "mb-6", children: [
|
|
1336
|
+
b && /* @__PURE__ */ t("h2", { className: "text-lg font-semibold text-gray-900", children: b }),
|
|
1337
|
+
p && /* @__PURE__ */ t("p", { className: "mt-1 text-sm text-gray-500", children: p })
|
|
1328
1338
|
] }),
|
|
1329
|
-
e.fields.map((
|
|
1339
|
+
e.fields.map((k, I) => /* @__PURE__ */ t(
|
|
1330
1340
|
"div",
|
|
1331
1341
|
{
|
|
1332
|
-
style:
|
|
1333
|
-
children:
|
|
1342
|
+
style: L(k) ? ae(k.span) : void 0,
|
|
1343
|
+
children: P(k, h, m)
|
|
1334
1344
|
},
|
|
1335
|
-
|
|
1345
|
+
L(k) ? k.name : `node-${I}`
|
|
1336
1346
|
)),
|
|
1337
|
-
/* @__PURE__ */
|
|
1338
|
-
/* @__PURE__ */
|
|
1347
|
+
/* @__PURE__ */ y("div", { className: "mt-6 flex items-center gap-3", children: [
|
|
1348
|
+
/* @__PURE__ */ y(
|
|
1339
1349
|
"button",
|
|
1340
1350
|
{
|
|
1341
1351
|
type: "submit",
|
|
1342
|
-
disabled:
|
|
1343
|
-
className: `fc-submit-btn rounded-md px-4 py-2 text-sm font-medium text-white transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-blue-500/40 disabled:cursor-not-allowed disabled:opacity-50 ${((
|
|
1352
|
+
disabled: h.isSubmitting,
|
|
1353
|
+
className: `fc-submit-btn rounded-md px-4 py-2 text-sm font-medium text-white transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-blue-500/40 disabled:cursor-not-allowed disabled:opacity-50 ${((M = g == null ? void 0 : g.components) == null ? void 0 : M.button) ?? ""}`,
|
|
1344
1354
|
style: {
|
|
1345
1355
|
backgroundColor: "var(--fc-color-primary, #3b82f6)"
|
|
1346
1356
|
},
|
|
1347
1357
|
children: [
|
|
1348
|
-
|
|
1358
|
+
h.isSubmitting && /* @__PURE__ */ t(
|
|
1349
1359
|
"span",
|
|
1350
1360
|
{
|
|
1351
1361
|
className: "mr-2 inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-white border-t-transparent",
|
|
1352
1362
|
"aria-hidden": "true"
|
|
1353
1363
|
}
|
|
1354
1364
|
),
|
|
1355
|
-
|
|
1365
|
+
S
|
|
1356
1366
|
]
|
|
1357
1367
|
}
|
|
1358
1368
|
),
|
|
@@ -1360,9 +1370,9 @@ function Ae({
|
|
|
1360
1370
|
"button",
|
|
1361
1371
|
{
|
|
1362
1372
|
type: "reset",
|
|
1363
|
-
disabled:
|
|
1373
|
+
disabled: h.isSubmitting,
|
|
1364
1374
|
className: "rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 transition-colors duration-150 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500/40 disabled:cursor-not-allowed disabled:opacity-50",
|
|
1365
|
-
children:
|
|
1375
|
+
children: $
|
|
1366
1376
|
}
|
|
1367
1377
|
)
|
|
1368
1378
|
] })
|
|
@@ -1371,9 +1381,11 @@ function Ae({
|
|
|
1371
1381
|
) });
|
|
1372
1382
|
}
|
|
1373
1383
|
export {
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1384
|
+
Ve as FormBuilder,
|
|
1385
|
+
te as FormContext,
|
|
1386
|
+
Me as FormaticaProvider,
|
|
1387
|
+
fe as useForm,
|
|
1388
|
+
Ae as useFormContext,
|
|
1389
|
+
me as useFormaticaConfig
|
|
1378
1390
|
};
|
|
1379
1391
|
//# sourceMappingURL=formatica-react.es.js.map
|