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