@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.
Files changed (34) hide show
  1. package/README.md +264 -25
  2. package/dist/components/BaseField.d.ts +17 -0
  3. package/dist/components/BaseField.d.ts.map +1 -0
  4. package/dist/components/FormBuilder.d.ts +22 -0
  5. package/dist/components/FormBuilder.d.ts.map +1 -0
  6. package/dist/components/FormaticaProvider.d.ts +15 -0
  7. package/dist/components/FormaticaProvider.d.ts.map +1 -0
  8. package/dist/components/fields/CheckboxField.d.ts +10 -0
  9. package/dist/components/fields/CheckboxField.d.ts.map +1 -0
  10. package/dist/components/fields/NumberField.d.ts +17 -0
  11. package/dist/components/fields/NumberField.d.ts.map +1 -0
  12. package/dist/components/fields/RadioField.d.ts +17 -0
  13. package/dist/components/fields/RadioField.d.ts.map +1 -0
  14. package/dist/components/fields/SelectField.d.ts +19 -0
  15. package/dist/components/fields/SelectField.d.ts.map +1 -0
  16. package/dist/components/fields/SliderField.d.ts +13 -0
  17. package/dist/components/fields/SliderField.d.ts.map +1 -0
  18. package/dist/components/fields/SwitchField.d.ts +11 -0
  19. package/dist/components/fields/SwitchField.d.ts.map +1 -0
  20. package/dist/components/fields/TextField.d.ts +15 -0
  21. package/dist/components/fields/TextField.d.ts.map +1 -0
  22. package/dist/components/fields/TextareaField.d.ts +14 -0
  23. package/dist/components/fields/TextareaField.d.ts.map +1 -0
  24. package/dist/formatica-react.es.js +630 -616
  25. package/dist/formatica-react.es.js.map +1 -1
  26. package/dist/formatica-react.umd.cjs +1 -1
  27. package/dist/formatica-react.umd.cjs.map +1 -1
  28. package/dist/hooks/useForm.d.ts +26 -0
  29. package/dist/hooks/useForm.d.ts.map +1 -0
  30. package/dist/hooks/useFormContext.d.ts +4 -0
  31. package/dist/hooks/useFormContext.d.ts.map +1 -0
  32. package/dist/index.d.ts +10 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/package.json +3 -2
@@ -1,8 +1,18 @@
1
- import { extractFields as ne, evaluateCondition as se, getRule as ae, isFieldNode as O } from "@formatica/core";
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 L, useState as S, useCallback as D, createContext as oe, useContext as le, useEffect as B } from "react";
4
- import { jsxs as g, jsx as t } from "react/jsx-runtime";
5
- function ie(e) {
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 ce(e) {
31
+ function de(e) {
22
32
  const n = {};
23
- for (const s of e)
24
- n[s.name] = s.defaultValue ?? ie(s);
33
+ for (const a of e)
34
+ n[a.name] = a.defaultValue ?? ue(a);
25
35
  return n;
26
36
  }
27
- function ue(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, s]) => ({
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 s == "object" && s !== null ? s : { [n]: s }
40
+ params: typeof a == "object" && a !== null ? a : { [n]: a }
31
41
  })) : [];
32
42
  }
33
43
  function Z(e) {
34
- const [n = "", ...s] = e.split(":"), r = s.join(":"), a = {};
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
- a.min = Number(o[0]), a.max = Number(o[1]);
48
+ s.min = Number(o[0]), s.max = Number(o[1]);
39
49
  else if (n === "pattern")
40
- a.pattern = r;
41
- else if (a[n] = o.length === 1 ? o[0] : o, o.length === 1) {
42
- const i = Number(o[0]);
43
- Number.isNaN(i) || (a[n] = i, n === "minLength" && (a.min = i), n === "maxLength" && (a.max = i));
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: a };
56
+ return { name: n, params: s };
47
57
  }
48
- function de(e, n) {
49
- const s = ne(e.fields), r = L(ce(s)), a = L(s), [o, i] = S(() => ({
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, l] = S({}), [m, d] = S({}), [h, f] = S({}), [C, v] = S(!1), [p, b] = S(0), k = L(o);
52
- k.current = o;
53
- const x = L(u);
54
- x.current = u;
55
- const F = Object.values(u).every((y) => y.length === 0), R = Object.values(h).some(Boolean), j = D((y, $) => {
56
- i((N) => ({ ...N, [y]: $ })), f((N) => ({ ...N, [y]: !0 }));
57
- }, []), H = D((y) => k.current[y], []), T = D(
58
- async (y, $) => {
59
- const N = a.current.find((E) => E.name === y);
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 && !se(N.condition, $))
71
+ if (N.condition && !le(N.condition, C))
62
72
  return [];
63
- const I = ue(N.rules);
64
- N.required && !I.some((E) => E.name === "required") && I.unshift({ name: "required", params: {} });
65
- const z = [], te = {
66
- values: $,
67
- getFieldValue: (E) => $[E]
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 E of I) {
70
- const G = ae(E.name);
79
+ for (const I of T) {
80
+ const G = ie(I.name);
71
81
  if (!G) continue;
72
- const W = await G($[y], E.params, te);
73
- typeof W == "string" && z.push(W);
82
+ const W = await G(C[x], I.params, se);
83
+ typeof W == "string" && K.push(W);
74
84
  }
75
- return z;
85
+ return K;
76
86
  },
77
87
  []
78
- ), A = D(
79
- async (y) => {
80
- const $ = await T(y, k.current);
81
- return l((N) => ({ ...N, [y]: $ })), d((N) => ({ ...N, [y]: !0 })), $.length === 0;
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
- [T]
84
- ), V = D(async () => {
85
- const y = k.current, $ = {};
93
+ [k]
94
+ ), z = D(async () => {
95
+ const x = S.current, C = {};
86
96
  let N = !0;
87
- for (const I of a.current) {
88
- const z = await T(I.name, y);
89
- $[I.name] = z, z.length > 0 && (N = !1);
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 l($), N;
92
- }, [T]), P = D(
93
- async (y) => {
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 a.current)
97
- $[N.name] = !0;
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 V()) return;
101
- await y({ ...k.current });
110
+ if (!await z()) return;
111
+ await x({ ...S.current });
102
112
  } finally {
103
113
  v(!1);
104
114
  }
105
115
  },
106
- [V]
116
+ [z]
107
117
  ), _ = D(() => {
108
- i({ ...r.current }), l({}), d({}), f({});
118
+ l({ ...r.current }), i({}), d({}), m({});
109
119
  }, []), U = D(() => {
110
- const y = {};
111
- for (const $ of a.current)
112
- y[$.name] = null;
113
- i(y), l({});
114
- }, []), q = D((y, $) => {
115
- const N = Array.isArray($) ? $ : [$];
116
- l((I) => ({ ...I, [y]: N }));
117
- }, []), c = D((y) => {
118
- l(($) => {
119
- const N = { ...$ };
120
- return delete N[y], 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
- l({});
133
+ i({});
124
134
  }, []);
125
135
  return {
126
136
  values: o,
127
137
  errors: u,
128
- touched: m,
129
- dirty: h,
130
- isValid: F,
131
- isDirty: R,
132
- isSubmitting: C,
138
+ touched: f,
139
+ dirty: g,
140
+ isValid: j,
141
+ isDirty: E,
142
+ isSubmitting: h,
133
143
  submitCount: p,
134
- setFieldValue: j,
135
- validate: V,
136
- validateField: A,
137
- submit: P,
144
+ setFieldValue: R,
145
+ validate: z,
146
+ validateField: O,
147
+ submit: q,
138
148
  reset: _,
139
149
  clear: U,
140
- setError: q,
150
+ setError: H,
141
151
  clearError: c,
142
152
  clearErrors: w,
143
- getFieldValue: H
153
+ getFieldValue: M
144
154
  };
145
155
  }
146
- const ee = oe(null);
147
- function Te() {
148
- const e = le(ee);
156
+ const ne = B(null);
157
+ function Ve() {
158
+ const e = ee(ne);
149
159
  if (!e) throw new Error("useFormContext must be used within a FormProvider");
150
160
  return e;
151
161
  }
152
- function fe({
162
+ function pe({
153
163
  label: e,
154
164
  required: n,
155
- errors: s,
165
+ errors: a,
156
166
  touched: r = !0,
157
- helpText: a,
167
+ helpText: s,
158
168
  tooltip: o,
159
- disabled: i,
169
+ disabled: l,
160
170
  readOnly: u,
161
- fieldName: l,
162
- children: m,
171
+ fieldName: i,
172
+ children: f,
163
173
  className: d,
164
- style: h
174
+ style: g
165
175
  }) {
166
- const [f, C] = S(!1), v = r && s !== void 0 && s.length > 0, p = l ? `fc-field-${l}` : void 0, b = l ? `fc-error-${l}` : void 0;
167
- return /* @__PURE__ */ g(
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 ${i ? "opacity-50 cursor-not-allowed" : ""} ${u ? "fc-readonly" : ""} ${d ?? ""}`,
171
- style: h,
180
+ className: `relative mb-4 ${l ? "opacity-50 cursor-not-allowed" : ""} ${u ? "fc-readonly" : ""} ${d ?? ""}`,
181
+ style: g,
172
182
  children: [
173
- e && /* @__PURE__ */ g("div", { className: "mb-1.5 flex items-center gap-1", children: [
174
- /* @__PURE__ */ g("label", { htmlFor: p, className: "block text-sm font-medium text-gray-700", children: [
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__ */ g(
188
+ o && /* @__PURE__ */ y(
179
189
  "span",
180
190
  {
181
191
  className: "relative inline-flex",
182
- onMouseEnter: () => C(!0),
183
- onMouseLeave: () => C(!1),
184
- onFocus: () => C(!0),
185
- onBlur: () => C(!1),
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
- f && /* @__PURE__ */ g(
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: m }),
213
- v && /* @__PURE__ */ t("div", { children: s.map((k, x) => /* @__PURE__ */ t(
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: x === 0 ? b : void 0,
226
+ id: $ === 0 ? b : void 0,
217
227
  className: "mt-1 text-xs text-red-500",
218
228
  role: "alert",
219
- children: k
229
+ children: S
220
230
  },
221
- `${k}-${x}`
231
+ `${S}-${$}`
222
232
  )) }),
223
- a && !v && /* @__PURE__ */ t("p", { className: "mt-1 text-xs text-gray-400", children: a })
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 me = "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
- function J({
238
+ function be({
230
239
  value: e,
231
240
  onChange: n,
232
- onBlur: s,
241
+ onBlur: a,
233
242
  disabled: r,
234
- placeholder: a,
235
- inputType: o = "text",
236
- readOnly: i,
237
- prefix: u,
238
- suffix: l,
239
- maxLength: m,
240
- className: d
243
+ label: s,
244
+ className: o
241
245
  }) {
242
- const v = `${me} ${r ? "opacity-50 cursor-not-allowed bg-gray-100" : ""} ${u ? "rounded-l-none" : ""} ${l ? "rounded-r-none" : ""} ${d ?? ""}`.trim(), p = /* @__PURE__ */ t(
243
- "input",
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
- type: o,
246
- className: v,
247
- style: { borderColor: void 0 },
248
- value: e ?? "",
249
- onChange: (b) => n(b.target.value),
250
- onFocus: (b) => {
251
- b.target.style.borderColor = "var(--fc-color-primary, #3b82f6)";
252
- },
253
- onBlur: (b) => {
254
- b.target.style.borderColor = "", s == null || s();
255
- },
256
- disabled: r,
257
- placeholder: a,
258
- readOnly: i,
259
- maxLength: m,
260
- "aria-disabled": r || void 0,
261
- "aria-readonly": i || void 0
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 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-number-input";
271
- function be({
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: s,
308
+ onBlur: a,
275
309
  disabled: r,
276
- placeholder: a,
310
+ placeholder: s,
277
311
  min: o,
278
- max: i,
312
+ max: l,
279
313
  step: u = 1,
280
- precision: l,
281
- readOnly: m,
314
+ precision: i,
315
+ readOnly: f,
282
316
  prefix: d,
283
- suffix: h,
284
- className: f
317
+ suffix: g,
318
+ className: m
285
319
  }) {
286
- const b = `${pe} ${r ? "opacity-50 cursor-not-allowed bg-gray-100" : ""} ${d ? "rounded-l-none" : ""} ${h ? "rounded-r-none" : ""} ${f ?? ""}`.trim();
287
- function k(F) {
288
- const R = F.target.value;
289
- if (R === "") {
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 j = Number.parseFloat(R);
294
- Number.isNaN(j) || (l !== void 0 && (j = Number.parseFloat(j.toFixed(l))), n(j));
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 x = /* @__PURE__ */ t(
330
+ const $ = /* @__PURE__ */ t(
297
331
  "input",
298
332
  {
299
333
  type: "number",
300
334
  className: b,
301
335
  value: e ?? "",
302
- onChange: k,
303
- onFocus: (F) => {
304
- F.target.style.borderColor = "var(--fc-color-primary, #3b82f6)";
336
+ onChange: S,
337
+ onFocus: (j) => {
338
+ j.target.style.borderColor = "var(--fc-color-primary, #3b82f6)";
305
339
  },
306
- onBlur: (F) => {
307
- F.target.style.borderColor = "", s == null || s();
340
+ onBlur: (j) => {
341
+ j.target.style.borderColor = "", a == null || a();
308
342
  },
309
343
  disabled: r,
310
- placeholder: a,
344
+ placeholder: s,
311
345
  min: o,
312
- max: i,
346
+ max: l,
313
347
  step: u,
314
- readOnly: m,
348
+ readOnly: f,
315
349
  "aria-disabled": r || void 0,
316
- "aria-readonly": m || void 0
350
+ "aria-readonly": f || void 0
317
351
  }
318
352
  );
319
- return d || h ? /* @__PURE__ */ g("div", { className: "flex items-stretch", children: [
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
- x,
322
- h && /* @__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: h })
323
- ] }) : x;
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
- const ge = "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";
326
- function ye({
327
- value: e,
328
- onChange: n,
329
- onBlur: s,
330
- disabled: r,
331
- placeholder: a,
332
- rows: o = 3,
333
- readOnly: i,
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
- const d = L(null), h = D(() => {
339
- if (!u || !d.current) return;
340
- const p = d.current;
341
- p.style.height = "auto", p.style.height = `${p.scrollHeight}px`;
342
- }, [u]);
343
- B(() => {
344
- h();
345
- }, [e, h]);
346
- const v = `${ge} ${r ? "opacity-50 cursor-not-allowed bg-gray-100" : ""} ${u ? "resize-none overflow-hidden" : ""} ${m ?? ""}`.trim();
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
- "textarea",
382
+ "div",
349
383
  {
350
- ref: d,
351
- className: v,
352
- value: e ?? "",
353
- onChange: (p) => {
354
- n(p.target.value);
355
- },
356
- onFocus: (p) => {
357
- p.target.style.borderColor = "var(--fc-color-primary, #3b82f6)";
358
- },
359
- onBlur: (p) => {
360
- p.target.style.borderColor = "", s == null || s();
361
- },
362
- disabled: r,
363
- placeholder: a,
364
- rows: o,
365
- readOnly: i,
366
- maxLength: l,
367
- "aria-disabled": r || void 0,
368
- "aria-readonly": i || void 0
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 he({
433
+ function xe({
373
434
  value: e,
374
435
  onChange: n,
375
- onBlur: s,
436
+ onBlur: a,
376
437
  disabled: r,
377
- placeholder: a = "Select...",
438
+ placeholder: s = "Select...",
378
439
  options: o,
379
- multiple: i = !1,
440
+ multiple: l = !1,
380
441
  searchable: u = !1,
381
- clearable: l = !1,
382
- className: m
442
+ clearable: i = !1,
443
+ className: f
383
444
  }) {
384
- const [d, h] = S(!1), [f, C] = S(""), [v, p] = S(-1), b = L(null), k = L(null), x = e == null ? [] : Array.isArray(e) ? e : [e], F = (() => {
385
- if (x.length === 0 || i) return "";
386
- const c = o.find((w) => w.value === x[0]);
387
- return (c == null ? void 0 : c.label) ?? String(x[0]);
388
- })(), R = f ? o.filter((c) => c.label.toLowerCase().includes(f.toLowerCase())) : o;
389
- function j(c) {
390
- return x.includes(c);
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 H(c) {
393
- const w = o.find((y) => y.value === c);
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 T = D(() => {
397
- h(!0), p(-1), C(""), setTimeout(() => {
457
+ const k = D(() => {
458
+ g(!0), p(-1), h(""), setTimeout(() => {
398
459
  var c;
399
- return (c = k.current) == null ? void 0 : c.focus();
460
+ return (c = S.current) == null ? void 0 : c.focus();
400
461
  }, 0);
401
- }, []), A = D(() => {
402
- h(!1), C(""), s == null || s();
403
- }, [s]);
404
- function V() {
405
- r || (d ? A() : T());
462
+ }, []), O = D(() => {
463
+ g(!1), h(""), a == null || a();
464
+ }, [a]);
465
+ function z() {
466
+ r || (d ? O() : k());
406
467
  }
407
- function P(c) {
468
+ function q(c) {
408
469
  if (!c.disabled)
409
- if (i) {
410
- const w = [...x], y = w.indexOf(c.value);
411
- y >= 0 ? w.splice(y, 1) : w.push(c.value), n(w);
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), A();
474
+ n(c.value), O();
414
475
  }
415
476
  function _(c) {
416
477
  if (r) return;
417
- const w = x.filter((y) => y !== c);
418
- n(w.length ? w : i ? [] : null);
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(i ? [] : null);
482
+ c.stopPropagation(), n(l ? [] : null);
422
483
  }
423
- function q(c) {
484
+ function H(c) {
424
485
  if (!d) {
425
- (c.key === "Enter" || c.key === " " || c.key === "ArrowDown") && (c.preventDefault(), T());
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, R.length - 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 && R[v] && P(R[v]);
497
+ c.preventDefault(), v >= 0 && E[v] && q(E[v]);
437
498
  break;
438
499
  case "Escape":
439
- c.preventDefault(), A();
500
+ c.preventDefault(), O();
440
501
  break;
441
502
  }
442
503
  }
443
- return B(() => {
504
+ return re(() => {
444
505
  function c(w) {
445
- b.current && !b.current.contains(w.target) && A();
506
+ b.current && !b.current.contains(w.target) && O();
446
507
  }
447
508
  return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
448
- }, [A]), /* @__PURE__ */ g(
509
+ }, [O]), /* @__PURE__ */ y(
449
510
  "div",
450
511
  {
451
512
  ref: b,
452
- className: `relative w-full ${r ? "opacity-50 cursor-not-allowed" : ""} ${m ?? ""}`,
513
+ className: `relative w-full ${r ? "opacity-50 cursor-not-allowed" : ""} ${f ?? ""}`,
453
514
  children: [
454
- /* @__PURE__ */ g(
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: V,
464
- onKeyDown: q,
524
+ onClick: z,
525
+ onKeyDown: H,
465
526
  children: [
466
- /* @__PURE__ */ g("div", { className: "flex flex-1 flex-wrap items-center gap-1", children: [
467
- i && x.map((c) => /* @__PURE__ */ g(
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
- H(c),
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
- !i && F && /* @__PURE__ */ t("span", { className: "truncate", children: F }),
495
- x.length === 0 && !i && /* @__PURE__ */ t("span", { className: "text-gray-400", children: a }),
496
- i && x.length === 0 && /* @__PURE__ */ t("span", { className: "text-gray-400", children: a })
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
- l && x.length > 0 && !r && /* @__PURE__ */ t(
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__ */ g("div", { className: "absolute z-50 mt-1 w-full rounded-md border border-gray-200 bg-white shadow-lg", children: [
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: k,
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: f,
537
- onChange: (c) => C(c.target.value),
538
- onKeyDown: q,
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__ */ g("ul", { role: "listbox", className: "max-h-60 overflow-auto py-1", children: [
548
- R.map((c, w) => /* @__PURE__ */ t(
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": j(c.value),
553
- className: `cursor-pointer px-3 py-2 text-sm transition-colors duration-200 ${j(c.value) ? "" : "text-gray-900"} ${v === w ? "bg-gray-100" : ""} ${c.disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-gray-50"}`,
554
- style: j(c.value) ? {
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: () => P(c),
619
+ onClick: () => q(c),
559
620
  onMouseEnter: () => p(w),
560
621
  children: c.label
561
622
  },
562
623
  String(c.value)
563
624
  )),
564
- R.length === 0 && /* @__PURE__ */ t("li", { className: "px-3 py-2 text-sm text-gray-400", children: "No options found" })
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 xe({
632
+ function ve({
572
633
  value: e,
573
634
  onChange: n,
574
- onBlur: s,
635
+ onBlur: a,
575
636
  disabled: r,
576
- label: a,
577
- className: o
637
+ min: s = 0,
638
+ max: o = 100,
639
+ step: l = 1,
640
+ showTooltip: u = !0,
641
+ className: i
578
642
  }) {
579
- function i() {
580
- r || n(!e);
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: `inline-flex items-center gap-2 select-none ${r ? "opacity-50 cursor-not-allowed" : "cursor-pointer"} ${o ?? ""}`,
647
+ className: `relative w-full py-2 ${r ? "opacity-50 cursor-not-allowed" : ""} ${i ?? ""}`,
589
648
  children: [
590
- /* @__PURE__ */ t(
591
- "input",
649
+ u && f && /* @__PURE__ */ t(
650
+ "div",
592
651
  {
593
- type: "checkbox",
594
- checked: e ?? !1,
595
- onChange: () => {
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
- "div",
658
+ "input",
604
659
  {
605
- role: "checkbox",
606
- "aria-checked": e,
607
- "aria-disabled": r || void 0,
608
- tabIndex: 0,
609
- 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"}`,
610
- style: e ? {
611
- borderColor: "var(--fc-color-primary, #3b82f6)",
612
- backgroundColor: "var(--fc-color-primary, #3b82f6)"
613
- } : {},
614
- onClick: (l) => {
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
- onKeyDown: u,
618
- children: e && /* @__PURE__ */ t(
619
- "svg",
620
- {
621
- className: "h-3 w-3",
622
- viewBox: "0 0 12 12",
623
- fill: "none",
624
- stroke: "currentColor",
625
- strokeWidth: "2",
626
- "aria-hidden": "true",
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
- a && /* @__PURE__ */ t("span", { className: "text-sm text-gray-700", children: a })
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: s,
694
+ onBlur: a,
715
695
  disabled: r,
716
- activeLabel: a,
696
+ activeLabel: s,
717
697
  inactiveLabel: o,
718
- className: i
698
+ className: l
719
699
  }) {
720
700
  function u() {
721
701
  r || n(!e);
722
702
  }
723
- function l(m) {
724
- (m.key === " " || m.key === "Enter") && (m.preventDefault(), u());
703
+ function i(f) {
704
+ (f.key === " " || f.key === "Enter") && (f.preventDefault(), u());
725
705
  }
726
- return /* @__PURE__ */ g(
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"} ${i ?? ""}`,
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: s,
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: l,
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
- a && /* @__PURE__ */ t("span", { className: "text-sm text-gray-600", children: a })
744
+ s && /* @__PURE__ */ t("span", { className: "text-sm text-gray-600", children: s })
765
745
  ]
766
746
  }
767
747
  );
768
748
  }
769
- function Ne({
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: s,
753
+ onBlur: a,
773
754
  disabled: r,
774
- min: a = 0,
775
- max: o = 100,
776
- step: i = 1,
777
- showTooltip: u = !0,
778
- className: l
755
+ placeholder: s,
756
+ rows: o = 3,
757
+ readOnly: l,
758
+ autoResize: u,
759
+ maxLength: i,
760
+ className: f
779
761
  }) {
780
- const [m, d] = S(!1), h = e ?? a, f = o - a, C = f === 0 ? 0 : (h - a) / f * 100;
781
- return /* @__PURE__ */ g(
782
- "div",
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
- className: `relative w-full py-2 ${r ? "opacity-50 cursor-not-allowed" : ""} ${l ?? ""}`,
785
- children: [
786
- u && m && /* @__PURE__ */ t(
787
- "div",
788
- {
789
- 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(${C}% - 16px)` },
791
- children: h
792
- }
793
- ),
794
- /* @__PURE__ */ t(
795
- "input",
796
- {
797
- type: "range",
798
- value: h,
799
- onChange: (v) => n(Number.parseFloat(v.target.value)),
800
- onMouseDown: () => d(!0),
801
- onMouseUp: () => d(!1),
802
- onTouchStart: () => d(!0),
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
- function M(e) {
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 Ce(e) {
841
+ function ke(e) {
832
842
  if (!e) return {};
833
843
  const n = {};
834
844
  if (e.colors)
835
- for (const [s, r] of Object.entries(e.colors))
836
- r && (n[`--fc-color-${M(s)}`] = r);
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 [s, r] of Object.entries(e.typography))
839
- r && (n[`--fc-${M(s)}`] = r);
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 [s, r] of Object.entries(e.spacing))
842
- r && (n[`--fc-${M(s)}`] = r);
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 [s, r] of Object.entries(e.borders))
845
- r && (n[`--fc-border-${M(s)}`] = r);
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 [s, r] of Object.entries(e.shadows))
848
- r && (n[`--fc-shadow-${M(s)}`] = r);
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 [s, r] of Object.entries(e.transitions))
851
- r && (n[`--fc-transition-${M(s)}`] = r);
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, s, r, a) {
855
- var l, m;
864
+ function Q(e, n, a, r, s) {
865
+ var i, f;
856
866
  const o = e.translations;
857
- if (!o) return a;
858
- const i = o[s];
859
- if ((l = i == null ? void 0 : i.messages) != null && l[n]) return i.messages[n];
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 ((m = u == null ? void 0 : u.messages) == null ? void 0 : m[n]) ?? a;
871
+ return ((f = u == null ? void 0 : u.messages) == null ? void 0 : f[n]) ?? s;
862
872
  }
863
- function X(e, n, s, r, a) {
873
+ function X(e, n, a, r, s) {
864
874
  const o = e.translations;
865
- if (!o) return a;
866
- const i = o[s];
867
- if (i != null && i[n]) return i[n];
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]) ?? a;
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 $e({ field: e, value: n, onChange: s, onBlur: r, disabled: a }) {
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: s,
894
+ onChange: a,
882
895
  onBlur: r,
883
- disabled: a,
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
- be,
904
+ ye,
892
905
  {
893
906
  value: n,
894
- onChange: s,
907
+ onChange: a,
895
908
  onBlur: r,
896
- disabled: a,
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
- ye,
919
+ Ce,
907
920
  {
908
921
  value: String(n ?? ""),
909
- onChange: s,
922
+ onChange: a,
910
923
  onBlur: r,
911
- disabled: a,
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
- he,
932
+ xe,
920
933
  {
921
934
  value: n,
922
- onChange: s,
935
+ onChange: a,
923
936
  onBlur: r,
924
- disabled: a,
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
- xe,
944
+ be,
932
945
  {
933
946
  value: !!n,
934
- onChange: s,
947
+ onChange: a,
935
948
  onBlur: r,
936
- disabled: a
949
+ disabled: s
937
950
  }
938
951
  );
939
952
  case "radio":
940
953
  return /* @__PURE__ */ t(
941
- ve,
954
+ he,
942
955
  {
943
956
  name: e.name,
944
957
  value: n,
945
- onChange: s,
958
+ onChange: a,
946
959
  onBlur: r,
947
- disabled: a,
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: s,
969
+ onChange: a,
957
970
  onBlur: r,
958
- disabled: a
971
+ disabled: s
959
972
  }
960
973
  );
961
974
  case "slider":
962
975
  return /* @__PURE__ */ t(
963
- Ne,
976
+ ve,
964
977
  {
965
978
  value: n,
966
- onChange: s,
979
+ onChange: a,
967
980
  onBlur: r,
968
- disabled: a,
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: s,
992
+ onChange: a,
980
993
  onBlur: r,
981
- disabled: a,
994
+ disabled: s,
982
995
  placeholder: e.placeholder
983
996
  }
984
997
  );
985
998
  }
986
999
  }
987
- function re(e) {
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 ke(e, n, s) {
991
- const r = n.errors[e.name] ?? [], a = e.disabled === !0 || !1, o = {
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: (l) => n.setFieldValue(e.name, l),
1007
+ onChange: (i) => n.setFieldValue(e.name, i),
995
1008
  onBlur: () => n.validateField(e.name),
996
1009
  errors: r,
997
- disabled: a
998
- }, u = (s == null ? void 0 : s[e.type]) ?? $e;
1010
+ disabled: s
1011
+ }, u = (a == null ? void 0 : a[e.type]) ?? Fe;
999
1012
  return /* @__PURE__ */ t(
1000
- fe,
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 Se(e, n, s) {
1019
- const a = {
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 ${a} ${e.className ?? ""}`,
1041
+ className: `grid grid-cols-12 ${s} ${e.className ?? ""}`,
1029
1042
  style: { gap: o },
1030
1043
  role: "group",
1031
- children: e.children.map((i, u) => /* @__PURE__ */ t(
1044
+ children: e.children.map((l, u) => /* @__PURE__ */ t(
1032
1045
  "div",
1033
1046
  {
1034
- style: re(O(i) ? i.span : void 0),
1035
- children: K(i, n, s)
1047
+ style: ae(L(l) ? l.span : void 0),
1048
+ children: P(l, n, a)
1036
1049
  },
1037
- O(i) ? i.name : `row-child-${u}`
1050
+ L(l) ? l.name : `row-child-${u}`
1038
1051
  ))
1039
1052
  }
1040
1053
  );
1041
1054
  }
1042
- function Fe({
1055
+ function je({
1043
1056
  node: e,
1044
1057
  form: n,
1045
- components: s
1058
+ components: a
1046
1059
  }) {
1047
- const [r, a] = S(e.collapsed ?? !1), o = e.title ? `fc-group-${e.title.toLowerCase().replace(/\s+/g, "-")}` : void 0;
1048
- function i() {
1049
- e.collapsible && a(!r);
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__ */ g(
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__ */ g(
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: i,
1078
+ onClick: l,
1066
1079
  children: [
1067
- /* @__PURE__ */ g("div", { children: [
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((l, m) => /* @__PURE__ */ t("div", { children: K(l, n, s) }, O(l) ? l.name : `group-child-${m}`))
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 De({
1124
+ function Ee({
1112
1125
  node: e,
1113
1126
  form: n,
1114
- components: s
1127
+ components: a
1115
1128
  }) {
1116
- const [r, a] = S(0), [o, i] = S(/* @__PURE__ */ new Set()), u = e.steps, l = u.length, m = r === 0, d = r === l - 1;
1117
- function h() {
1118
- d || (i((p) => {
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
- }), a((p) => p + 1));
1134
+ }), s((p) => p + 1));
1122
1135
  }
1123
- function f() {
1124
- m || a((p) => p - 1);
1136
+ function m() {
1137
+ f || s((p) => p - 1);
1125
1138
  }
1126
- function C(p) {
1127
- e.linear && p > r || a(p);
1139
+ function h(p) {
1140
+ e.linear && p > r || s(p);
1128
1141
  }
1129
1142
  const v = u[r];
1130
- return /* @__PURE__ */ g("div", { className: `space-y-6 ${e.className ?? ""}`, children: [
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__ */ g("li", { className: "flex items-center", children: [
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: () => C(b),
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__ */ g("div", { className: "text-center", children: [
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: K(p, n, s) }, O(p) ? p.name : `step-child-${b}`)) }),
1177
- /* @__PURE__ */ g("div", { className: "flex items-center justify-between border-t border-gray-100 pt-4", children: [
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: m,
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: f,
1197
+ onClick: m,
1185
1198
  children: "Previous"
1186
1199
  }
1187
1200
  ),
1188
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-400", children: [
1201
+ /* @__PURE__ */ y("span", { className: "text-xs text-gray-400", children: [
1189
1202
  r + 1,
1190
1203
  " / ",
1191
- l
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: h,
1214
+ onClick: g,
1202
1215
  children: "Next"
1203
1216
  }
1204
1217
  )
1205
1218
  ] })
1206
1219
  ] });
1207
1220
  }
1208
- function Re({
1221
+ function Oe({
1209
1222
  node: e,
1210
1223
  form: n,
1211
- components: s
1224
+ components: a
1212
1225
  }) {
1213
- const [r, a] = S(0), o = e.tabs, i = o[r], u = `fc-tabpanel-${r}`;
1214
- function l(m) {
1215
- a(m);
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__ */ g("div", { className: e.className ?? "", children: [
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((m, d) => /* @__PURE__ */ g(
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: () => l(d),
1248
+ onClick: () => i(d),
1236
1249
  children: [
1237
- m.title,
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
- m.title
1262
+ f.title
1250
1263
  ))
1251
1264
  }
1252
1265
  ),
1253
- i && /* @__PURE__ */ t(
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: i.children.map((m, d) => /* @__PURE__ */ t("div", { children: K(m, n, s) }, O(m) ? m.name : `tab-child-${d}`))
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 je(e) {
1267
- return e.label ? /* @__PURE__ */ g("div", { className: `relative my-4 ${e.className ?? ""}`, children: [
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 K(e, n, s) {
1273
- if (O(e))
1274
- return ke(e, n, s);
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 Se(e, n, s);
1289
+ return Re(e, n, a);
1278
1290
  case "group":
1279
- return /* @__PURE__ */ t(Fe, { node: e, form: n, components: s });
1291
+ return /* @__PURE__ */ t(je, { node: e, form: n, components: a });
1280
1292
  case "steps":
1281
- return /* @__PURE__ */ t(De, { node: e, form: n, components: s });
1293
+ return /* @__PURE__ */ t(Ee, { node: e, form: n, components: a });
1282
1294
  case "tabs":
1283
- return /* @__PURE__ */ t(Re, { node: e, form: n, components: s });
1295
+ return /* @__PURE__ */ t(Oe, { node: e, form: n, components: a });
1284
1296
  case "divider":
1285
- return je(e);
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 Ae({
1310
+ function ze({
1299
1311
  schema: e,
1300
1312
  onSubmit: n,
1301
- onError: s,
1302
- locale: r = "en",
1303
- fallbackLocale: a = "en",
1313
+ onError: a,
1314
+ locale: r,
1315
+ fallbackLocale: s,
1304
1316
  theme: o,
1305
- components: i,
1317
+ components: l,
1306
1318
  className: u
1307
1319
  }) {
1308
- var b, k;
1309
- const l = de(e), m = Ce(o), d = Q(e, "title", r, a, ""), h = Q(e, "description", r, a, ""), f = X(e, "submit", r, a, "Submit"), C = X(e, "reset", r, a, "Reset"), v = async (x) => {
1310
- x.preventDefault(), n ? await l.submit(async (F) => {
1311
- await n(F);
1312
- }) : await l.validate(), !l.isValid && s && s(l.errors);
1313
- }, p = (x) => {
1314
- x.preventDefault(), l.reset();
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(ee.Provider, { value: l, children: /* @__PURE__ */ g(
1328
+ return /* @__PURE__ */ t(ne.Provider, { value: h, children: /* @__PURE__ */ y(
1317
1329
  "form",
1318
1330
  {
1319
- className: `fc-form-builder ${((b = o == null ? void 0 : o.components) == null ? void 0 : b.form) ?? ""} ${u ?? ""}`.trim(),
1320
- style: m,
1321
- onSubmit: v,
1322
- onReset: p,
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
- (d || h) && /* @__PURE__ */ g("div", { className: "mb-6", children: [
1326
- d && /* @__PURE__ */ t("h2", { className: "text-lg font-semibold text-gray-900", children: d }),
1327
- h && /* @__PURE__ */ t("p", { className: "mt-1 text-sm text-gray-500", children: h })
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((x, F) => /* @__PURE__ */ t(
1341
+ e.fields.map((k, O) => /* @__PURE__ */ t(
1330
1342
  "div",
1331
1343
  {
1332
- style: O(x) ? re(x.span) : void 0,
1333
- children: K(x, l, i)
1344
+ style: L(k) ? ae(k.span) : void 0,
1345
+ children: P(k, h, m)
1334
1346
  },
1335
- O(x) ? x.name : `node-${F}`
1347
+ L(k) ? k.name : `node-${O}`
1336
1348
  )),
1337
- /* @__PURE__ */ g("div", { className: "mt-6 flex items-center gap-3", children: [
1338
- /* @__PURE__ */ g(
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: l.isSubmitting,
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 ${((k = o == null ? void 0 : o.components) == null ? void 0 : k.button) ?? ""}`,
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
- l.isSubmitting && /* @__PURE__ */ t(
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
- f
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: l.isSubmitting,
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: C
1377
+ children: $
1366
1378
  }
1367
1379
  )
1368
1380
  ] })
@@ -1371,9 +1383,11 @@ function Ae({
1371
1383
  ) });
1372
1384
  }
1373
1385
  export {
1374
- Ae as FormBuilder,
1375
- ee as FormContext,
1376
- de as useForm,
1377
- Te as useFormContext
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