asterui 0.12.57 → 0.12.59

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 (80) hide show
  1. package/dist/components/Autocomplete.js +1 -1
  2. package/dist/components/Autocomplete.js.map +1 -1
  3. package/dist/components/Button.js +1 -1
  4. package/dist/components/Button.js.map +1 -1
  5. package/dist/components/Checkbox.js +1 -1
  6. package/dist/components/Checkbox.js.map +1 -1
  7. package/dist/components/ColorPicker.js +1 -1
  8. package/dist/components/ColorPicker.js.map +1 -1
  9. package/dist/components/CopyButton.js +1 -1
  10. package/dist/components/CopyButton.js.map +1 -1
  11. package/dist/components/Countdown.js +1 -1
  12. package/dist/components/Countdown.js.map +1 -1
  13. package/dist/components/DatePicker.js +1 -1
  14. package/dist/components/DatePicker.js.map +1 -1
  15. package/dist/components/Dock.js +1 -1
  16. package/dist/components/Dock.js.map +1 -1
  17. package/dist/components/Empty.js +1 -1
  18. package/dist/components/Empty.js.map +1 -1
  19. package/dist/components/FileInput.js +1 -1
  20. package/dist/components/FileInput.js.map +1 -1
  21. package/dist/components/Filter.js +1 -1
  22. package/dist/components/Filter.js.map +1 -1
  23. package/dist/components/Form.d.ts +10 -1
  24. package/dist/components/Form.js +205 -184
  25. package/dist/components/Form.js.map +1 -1
  26. package/dist/components/Input.js +1 -1
  27. package/dist/components/Input.js.map +1 -1
  28. package/dist/components/InputNumber.js +1 -1
  29. package/dist/components/InputNumber.js.map +1 -1
  30. package/dist/components/List.js +1 -1
  31. package/dist/components/List.js.map +1 -1
  32. package/dist/components/Loading.js +1 -1
  33. package/dist/components/Loading.js.map +1 -1
  34. package/dist/components/Modal.js +1 -1
  35. package/dist/components/Modal.js.map +1 -1
  36. package/dist/components/OTPInput.js +1 -1
  37. package/dist/components/OTPInput.js.map +1 -1
  38. package/dist/components/Pagination.js +1 -1
  39. package/dist/components/Pagination.js.map +1 -1
  40. package/dist/components/Popconfirm.js +1 -1
  41. package/dist/components/Popconfirm.js.map +1 -1
  42. package/dist/components/Radio.js +1 -1
  43. package/dist/components/Radio.js.map +1 -1
  44. package/dist/components/Range.js +1 -1
  45. package/dist/components/Range.js.map +1 -1
  46. package/dist/components/Rating.js +1 -1
  47. package/dist/components/Rating.js.map +1 -1
  48. package/dist/components/RichTextEditor.js +1 -1
  49. package/dist/components/RichTextEditor.js.map +1 -1
  50. package/dist/components/Segmented.js +1 -1
  51. package/dist/components/Segmented.js.map +1 -1
  52. package/dist/components/Select.js +1 -1
  53. package/dist/components/Select.js.map +1 -1
  54. package/dist/components/Table.d.ts +19 -0
  55. package/dist/components/Table.js +348 -310
  56. package/dist/components/Table.js.map +1 -1
  57. package/dist/components/Tabs.js +1 -1
  58. package/dist/components/Tabs.js.map +1 -1
  59. package/dist/components/Textarea.js +1 -1
  60. package/dist/components/Textarea.js.map +1 -1
  61. package/dist/components/ThemeController.js +1 -1
  62. package/dist/components/ThemeController.js.map +1 -1
  63. package/dist/components/TimePicker.js +1 -1
  64. package/dist/components/TimePicker.js.map +1 -1
  65. package/dist/components/Toggle.js +1 -1
  66. package/dist/components/Toggle.js.map +1 -1
  67. package/dist/hooks/useTheme.d.ts +1 -1
  68. package/dist/hooks/useTheme.js +1 -1
  69. package/dist/hooks/useTheme.js.map +1 -1
  70. package/dist/index.d.ts +4 -4
  71. package/dist/index.js +2 -2
  72. package/dist/providers/ConfigProvider.js.map +1 -0
  73. package/dist/providers/ThemeProvider.js.map +1 -0
  74. package/package.json +1 -1
  75. package/dist/components/ConfigProvider.js.map +0 -1
  76. package/dist/components/ThemeProvider.js.map +0 -1
  77. /package/dist/{components → providers}/ConfigProvider.d.ts +0 -0
  78. /package/dist/{components → providers}/ConfigProvider.js +0 -0
  79. /package/dist/{components → providers}/ThemeProvider.d.ts +0 -0
  80. /package/dist/{components → providers}/ThemeProvider.js +0 -0
@@ -1,8 +1,8 @@
1
- import { jsx as t, jsxs as C } from "react/jsx-runtime";
2
- import { createContext as pe, useId as te, useEffect as se, useRef as re, isValidElement as ne, cloneElement as ge, useContext as ve } from "react";
3
- import { useForm as oe, useFieldArray as xe, useWatch as ye, Controller as be } from "react-hook-form";
4
- import { useConfig as $e } from "./ConfigProvider.js";
5
- const Ne = "input", ke = "input-xs", Fe = "input-sm", Ve = "input-md", we = "input-lg", Le = "input-xl", Ce = "floating-label", Ee = "loading", Ae = "loading-spinner", je = "loading-xs", ze = "tooltip", Se = "tooltip-top", J = pe(void 0), X = {
1
+ import { jsx as t, jsxs as E } from "react/jsx-runtime";
2
+ import { createContext as be, useId as ae, useEffect as ie, useRef as K, isValidElement as U, cloneElement as $e, useContext as Ne } from "react";
3
+ import { useForm as ce, useFieldArray as Fe, useWatch as ke, Controller as Ve } from "react-hook-form";
4
+ import { useConfig as we } from "../providers/ConfigProvider.js";
5
+ const Ce = "input", Le = "input-xs", Ee = "input-sm", Ae = "input-md", Se = "input-lg", je = "input-xl", ze = "floating-label", Me = "loading", Pe = "loading-spinner", Re = "loading-xs", Te = "tooltip", Be = "tooltip-top", le = "validator-hint", G = be(void 0), Y = {
6
6
  email: {
7
7
  value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
8
8
  message: "Please enter a valid email address"
@@ -16,265 +16,286 @@ const Ne = "input", ke = "input-xs", Fe = "input-sm", Ve = "input-md", we = "inp
16
16
  message: "Please enter a valid number"
17
17
  }
18
18
  };
19
- function K() {
20
- const s = ve(J);
19
+ function Q() {
20
+ const s = Ne(G);
21
21
  if (!s)
22
22
  throw new Error("Form compound components must be used within Form");
23
23
  return s;
24
24
  }
25
- function Me({
25
+ function Ie({
26
26
  form: s,
27
- onFinish: n,
27
+ onFinish: a,
28
28
  onFinishFailed: r,
29
29
  initialValues: i,
30
- layout: b = "vertical",
31
- labelWidth: h = 60,
32
- size: V,
33
- disabled: v = !1,
34
- children: l,
35
- className: c = "",
36
- noValidate: x = !0,
37
- ...y
30
+ layout: $ = "vertical",
31
+ labelWidth: g = 60,
32
+ size: w,
33
+ disabled: x = !1,
34
+ children: c,
35
+ className: l = "",
36
+ noValidate: y = !0,
37
+ ...b
38
38
  }) {
39
- const { componentSize: $ } = $e(), d = V ?? $ ?? "md", z = oe({
39
+ const { componentSize: N } = we(), u = w ?? N ?? "md", z = ce({
40
40
  defaultValues: i
41
- }), N = s || z, W = async (w) => {
42
- if (w.preventDefault(), await N.trigger())
43
- n && n(N.getValues());
41
+ }), F = s || z, I = async (C) => {
42
+ if (C.preventDefault(), await F.trigger())
43
+ a && a(F.getValues());
44
44
  else if (r) {
45
- const u = N.formState.errors, k = [], S = (M, I = "") => {
46
- for (const P in M) {
47
- const R = I ? `${I}.${P}` : P, F = M[P];
48
- F?.message ? k.push({ name: R, errors: [F.message] }) : typeof F == "object" && F !== null && S(F, R);
45
+ const d = F.formState.errors, k = [], M = (P, W = "") => {
46
+ for (const R in P) {
47
+ const T = W ? `${W}.${R}` : R, V = P[R];
48
+ V?.message ? k.push({ name: T, errors: [V.message] }) : typeof V == "object" && V !== null && M(V, T);
49
49
  }
50
50
  };
51
- S(u), r({ values: N.getValues(), errorFields: k });
51
+ M(d), r({ values: F.getValues(), errorFields: k });
52
52
  }
53
- }, j = (w) => {
54
- w.preventDefault(), N.reset(i);
53
+ }, S = (C) => {
54
+ C.preventDefault(), F.reset(i);
55
55
  };
56
- return /* @__PURE__ */ t(J.Provider, { value: { form: N, layout: b, labelWidth: h, size: d, disabled: v }, children: /* @__PURE__ */ t("form", { onSubmit: W, onReset: j, className: c, noValidate: x, ...y, children: l }) });
56
+ return /* @__PURE__ */ t(G.Provider, { value: { form: F, layout: $, labelWidth: g, size: u, disabled: x }, children: /* @__PURE__ */ t("form", { onSubmit: I, onReset: S, className: l, noValidate: y, ...b, children: c }) });
57
57
  }
58
- function Pe({
58
+ function We({
59
59
  name: s,
60
- label: n,
60
+ label: a,
61
61
  floatingLabel: r,
62
62
  help: i,
63
- required: b = !1,
64
- rules: h,
65
- valuePropName: V = "value",
66
- inline: v = !1,
67
- className: l = "",
68
- children: c,
69
- tooltip: x,
70
- extra: y,
71
- hasFeedback: $ = !1,
72
- dependencies: d,
63
+ required: $ = !1,
64
+ rules: g,
65
+ valuePropName: w = "value",
66
+ inline: x = !1,
67
+ className: c = "",
68
+ children: l,
69
+ tooltip: y,
70
+ extra: b,
71
+ hasFeedback: N = !1,
72
+ dependencies: u,
73
73
  validateTrigger: z = "onChange",
74
- initialValue: N,
75
- hidden: W = !1,
76
- addonBefore: j,
77
- addonAfter: w,
78
- "data-testid": m
74
+ initialValue: F,
75
+ hidden: I = !1,
76
+ addonBefore: S,
77
+ addonAfter: C,
78
+ "data-testid": f
79
79
  }) {
80
- const { form: u, size: k, listName: S, layout: M, labelWidth: I, disabled: P } = K(), R = te(), F = te();
80
+ const { form: d, size: k, listName: M, layout: P, labelWidth: W, disabled: R } = Q(), T = ae(), V = ae();
81
81
  if (!s)
82
- return /* @__PURE__ */ t("div", { className: `${v ? "w-auto" : "w-full"} ${l}`, style: W ? { display: "none" } : void 0, children: c });
83
- let p;
84
- Array.isArray(s) ? p = (S ? [S, ...s] : s).join(".") : p = s, se(() => {
85
- N !== void 0 && u.getValues(p) === void 0 && u.setValue(p, N);
82
+ return /* @__PURE__ */ t("div", { className: `${x ? "w-auto" : "w-full"} ${c}`, style: I ? { display: "none" } : void 0, children: l });
83
+ let h;
84
+ Array.isArray(s) ? h = (M ? [M, ...s] : s).join(".") : h = s, ie(() => {
85
+ F !== void 0 && d.getValues(h) === void 0 && d.setValue(h, F);
86
86
  }, []);
87
- const Z = ye({
88
- control: u.control,
89
- name: d,
90
- disabled: !d || d.length === 0
91
- }), H = re(u);
92
- H.current = u;
93
- const D = re(void 0);
94
- se(() => {
95
- if (!d || d.length === 0) return;
87
+ const O = ke({
88
+ control: d.control,
89
+ name: u,
90
+ disabled: !u || u.length === 0
91
+ }), _ = K(d);
92
+ _.current = d;
93
+ const D = K(void 0);
94
+ ie(() => {
95
+ if (!u || u.length === 0) return;
96
96
  if (D.current === void 0) {
97
- D.current = JSON.stringify(Z);
97
+ D.current = JSON.stringify(O);
98
98
  return;
99
99
  }
100
- const e = JSON.stringify(Z);
101
- D.current !== e && (D.current = e, H.current.trigger(p));
102
- }, [Z, d, p]);
100
+ const e = JSON.stringify(O);
101
+ if (D.current !== e) {
102
+ D.current = e;
103
+ const n = _.current.formState.touchedFields;
104
+ h.split(".").reduce((p, H) => p?.[H], n) && _.current.trigger(h);
105
+ }
106
+ }, [O, u, h]);
103
107
  const B = ((e) => {
104
- const o = e.split(".");
105
- let a = u.formState.errors;
106
- for (const T of o) {
107
- if (!a) break;
108
- a = a[T];
108
+ const n = e.split(".");
109
+ let o = d.formState.errors;
110
+ for (const p of n) {
111
+ if (!o) break;
112
+ o = o[p];
109
113
  }
110
- return a;
111
- })(p), E = B?.message, ae = h ? Array.isArray(h) ? h : [h] : [], A = {}, q = [], O = [];
112
- b && (A.required = "This field is required");
113
- for (const e of ae) {
114
- if (e.required && (A.required = typeof e.required == "string" ? e.required : e.message || "This field is required"), e.type && X[e.type] && q.push({
115
- pattern: X[e.type].value,
116
- message: e.message || X[e.type].message
114
+ return o;
115
+ })(h), A = B?.message, de = g ? Array.isArray(g) ? g : [g] : [], X = K(d);
116
+ X.current = d;
117
+ const ue = {
118
+ getFieldValue: (e) => X.current.getValues(e),
119
+ getFieldsValue: () => X.current.getValues()
120
+ }, me = de.map(
121
+ (e) => typeof e == "function" ? e(ue) : e
122
+ ), j = {}, Z = [], q = [];
123
+ $ && (j.required = "This field is required");
124
+ for (const e of me) {
125
+ if (e.required && (j.required = typeof e.required == "string" ? e.required : e.message || "This field is required"), e.type && Y[e.type] && Z.push({
126
+ pattern: Y[e.type].value,
127
+ message: e.message || Y[e.type].message
117
128
  }), e.min !== void 0) {
118
- const o = typeof e.min == "object" ? e.min.value : e.min, a = typeof e.min == "object" ? e.min.message : e.message || `Minimum length is ${o} characters`;
119
- A.minLength = { value: o, message: a };
129
+ const n = typeof e.min == "object" ? e.min.value : e.min, o = typeof e.min == "object" ? e.min.message : e.message || `Minimum length is ${n} characters`;
130
+ j.minLength = { value: n, message: o };
120
131
  }
121
132
  if (e.max !== void 0) {
122
- const o = typeof e.max == "object" ? e.max.value : e.max, a = typeof e.max == "object" ? e.max.message : e.message || `Maximum length is ${o} characters`;
123
- A.maxLength = { value: o, message: a };
133
+ const n = typeof e.max == "object" ? e.max.value : e.max, o = typeof e.max == "object" ? e.max.message : e.message || `Maximum length is ${n} characters`;
134
+ j.maxLength = { value: n, message: o };
124
135
  }
125
136
  if (e.pattern) {
126
- const o = e.pattern instanceof RegExp ? e.pattern : e.pattern.value, a = e.pattern instanceof RegExp ? e.message || "Invalid format" : e.pattern.message;
127
- q.push({ pattern: o, message: a });
137
+ const n = e.pattern instanceof RegExp ? e.pattern : e.pattern.value, o = e.pattern instanceof RegExp ? e.message || "Invalid format" : e.pattern.message;
138
+ Z.push({ pattern: n, message: o });
139
+ }
140
+ if (e.validate && q.push(e.validate), e.validator) {
141
+ const n = e.validator;
142
+ q.push(async (o) => {
143
+ try {
144
+ return await n(e, o), !0;
145
+ } catch (p) {
146
+ return p instanceof Error ? p.message : String(p);
147
+ }
148
+ });
128
149
  }
129
- e.validate && O.push(e.validate);
130
150
  }
131
- (q.length > 0 || O.length > 0) && (A.validate = async (e) => {
132
- if (!e && !A.required) return !0;
133
- for (const { pattern: o, message: a } of q)
134
- if (e && !o.test(e))
135
- return a;
136
- for (const o of O) {
137
- const a = await o(e);
138
- if (a !== !0)
139
- return a;
151
+ (Z.length > 0 || q.length > 0) && (j.validate = async (e) => {
152
+ for (const { pattern: n, message: o } of Z)
153
+ if (e && !n.test(e))
154
+ return o;
155
+ for (const n of q) {
156
+ const o = await n(e);
157
+ if (o !== !0)
158
+ return o;
140
159
  }
141
160
  return !0;
142
161
  });
143
- const U = Array.isArray(z) ? z : [z], Y = U.includes("onChange"), ie = U.includes("onBlur"), le = ({ hasError: e, isValidating: o }) => o ? /* @__PURE__ */ t("span", { className: `${Ee} ${Ae} ${je} text-base-content/50` }) : e ? /* @__PURE__ */ t("svg", { className: "w-4 h-4 text-error", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) : /* @__PURE__ */ t("svg", { className: "w-4 h-4 text-success", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }), ce = () => /* @__PURE__ */ t("div", { className: `${ze} ${Se} ml-1`, "data-tip": x, children: /* @__PURE__ */ t("svg", { className: "w-4 h-4 text-base-content/50 cursor-help", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }) });
162
+ const ee = Array.isArray(z) ? z : [z], te = ee.includes("onChange"), fe = ee.includes("onBlur"), he = ({ hasError: e, isValidating: n }) => n ? /* @__PURE__ */ t("span", { className: `${Me} ${Pe} ${Re} text-base-content/50` }) : e ? /* @__PURE__ */ t("svg", { className: "w-4 h-4 text-error", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) : /* @__PURE__ */ t("svg", { className: "w-4 h-4 text-success", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }), ge = () => /* @__PURE__ */ t("div", { className: `${Te} ${Be} ml-1`, "data-tip": y, children: /* @__PURE__ */ t("svg", { className: "w-4 h-4 text-base-content/50 cursor-help", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }) });
144
163
  return /* @__PURE__ */ t(
145
- be,
164
+ Ve,
146
165
  {
147
- name: p,
148
- control: u.control,
149
- rules: A,
150
- render: ({ field: e, fieldState: o }) => {
151
- const { value: a, onChange: T, onBlur: de, ref: ue } = e, me = o.isTouched && u.formState.isValidating, g = {
152
- id: R,
153
- ref: ue,
166
+ name: h,
167
+ control: d.control,
168
+ rules: j,
169
+ render: ({ field: e, fieldState: n }) => {
170
+ const { value: o, onChange: p, onBlur: H, ref: pe } = e, ve = n.isTouched && d.formState.isValidating, v = {
171
+ id: T,
172
+ ref: pe,
154
173
  "aria-invalid": B ? !0 : void 0,
155
- "aria-describedby": B ? F : void 0,
156
- "data-testid": m ? `${m}-input` : void 0
174
+ "aria-describedby": B ? V : void 0,
175
+ "data-testid": f ? `${f}-input` : void 0
176
+ };
177
+ v.onBlur = () => {
178
+ H(), fe && d.trigger(h);
157
179
  };
158
- g.onBlur = () => {
159
- de(), ie && u.trigger(p);
160
- }, V === "checked" ? (g.checked = a, g.onChange = (f) => {
161
- T(f.target.checked), Y && u.trigger(p);
162
- }) : (g.value = a || "", g.onChange = (f) => {
163
- f && f.target !== void 0 ? T(f.target.value) : T(f), Y && u.trigger(p);
164
- }), k && ne(c) && (c.props.size || (g.size = k)), B && (g.color = "error", g["aria-invalid"] = !0), P && (g.disabled = !0), (j || w) && (g.unstyled = !0);
165
- const G = ne(c) ? ge(c, g) : c, L = M === "horizontal", Q = M === "inline", ee = {
166
- xs: ke,
167
- sm: Fe,
168
- md: Ve,
169
- lg: we,
170
- xl: Le
171
- }, fe = () => {
172
- const f = /* @__PURE__ */ C("div", { className: `${L ? "flex-1" : ""} ${$ ? "relative" : ""}`, children: [
173
- G,
174
- $ && o.isTouched && /* @__PURE__ */ t("span", { className: "absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none", children: /* @__PURE__ */ t(le, { hasError: !!B, isValidating: me }) })
180
+ const se = U(l) ? l.props.onChange : void 0;
181
+ w === "checked" ? (v.checked = o, v.onChange = (m) => {
182
+ p(m.target.checked), te && d.trigger(h), se?.(m);
183
+ }) : (v.value = o || "", v.onChange = (m) => {
184
+ m && m.target !== void 0 ? p(m.target.value) : p(m), te && d.trigger(h), se?.(m);
185
+ }), k && U(l) && (l.props.size || (v.size = k)), B && (v.color = "error", v["aria-invalid"] = !0), R && (v.disabled = !0), (S || C) && (v.unstyled = !0);
186
+ const re = U(l) ? $e(l, v) : l, L = P === "horizontal", ne = P === "inline", oe = {
187
+ xs: Le,
188
+ sm: Ee,
189
+ md: Ae,
190
+ lg: Se,
191
+ xl: je
192
+ }, xe = () => {
193
+ const m = /* @__PURE__ */ E("div", { className: `${L ? "flex-1" : ""} ${N ? "relative" : ""}`, children: [
194
+ re,
195
+ N && n.isTouched && /* @__PURE__ */ t("span", { className: "absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none", children: /* @__PURE__ */ t(he, { hasError: !!B, isValidating: ve }) })
175
196
  ] });
176
197
  if (r) {
177
- const _ = [
178
- Ce,
179
- k && ee[k]
198
+ const J = [
199
+ ze,
200
+ k && oe[k]
180
201
  ].filter(Boolean).join(" ");
181
- return /* @__PURE__ */ C("label", { className: _, children: [
182
- G,
183
- /* @__PURE__ */ C("span", { children: [
202
+ return /* @__PURE__ */ E("label", { className: J, children: [
203
+ re,
204
+ /* @__PURE__ */ E("span", { children: [
184
205
  r,
185
- b && /* @__PURE__ */ t("span", { className: "text-error ml-1", children: "*" })
206
+ $ && /* @__PURE__ */ t("span", { className: "text-error ml-1", children: "*" })
186
207
  ] })
187
208
  ] });
188
209
  }
189
- return f;
190
- }, he = (f) => {
191
- if (!j && !w) return f;
192
- const _ = [
193
- Ne,
210
+ return m;
211
+ }, ye = (m) => {
212
+ if (!S && !C) return m;
213
+ const J = [
214
+ Ce,
194
215
  "flex",
195
216
  "items-center",
196
217
  "gap-2",
197
- k && ee[k]
218
+ k && oe[k]
198
219
  ].filter(Boolean).join(" ");
199
- return /* @__PURE__ */ C("label", { className: _, children: [
200
- j && /* @__PURE__ */ t("span", { className: "text-base-content/70", children: j }),
201
- f,
202
- w && /* @__PURE__ */ t("span", { className: "text-base-content/70", children: w })
220
+ return /* @__PURE__ */ E("label", { className: J, children: [
221
+ S && /* @__PURE__ */ t("span", { className: "text-base-content/70", children: S }),
222
+ m,
223
+ C && /* @__PURE__ */ t("span", { className: "text-base-content/70", children: C })
203
224
  ] });
204
225
  };
205
- return /* @__PURE__ */ C("div", { className: `${v ? "w-auto" : "w-full"} ${L ? "mb-4" : ""} ${Q ? "inline-flex mr-4" : ""} ${l}`, style: W ? { display: "none" } : void 0, "data-testid": m, children: [
206
- /* @__PURE__ */ C("div", { className: L ? "flex items-center gap-4" : "", children: [
207
- n && !r && /* @__PURE__ */ t(
226
+ return /* @__PURE__ */ E("div", { className: `${x ? "w-auto" : "w-full"} ${L ? "mb-4" : ""} ${ne ? "inline-flex mr-4" : ""} ${c}`, style: I ? { display: "none" } : void 0, "data-testid": f, children: [
227
+ /* @__PURE__ */ E("div", { className: L ? "flex items-center gap-4" : "", children: [
228
+ a && !r && /* @__PURE__ */ t(
208
229
  "label",
209
230
  {
210
- htmlFor: R,
211
- className: `block text-sm font-medium ${L ? "flex-shrink-0 text-right" : ""} ${!L && !Q ? "mb-1" : ""}`,
212
- style: L ? { width: I } : void 0,
213
- "data-testid": m ? `${m}-label` : void 0,
214
- children: /* @__PURE__ */ C("span", { className: "flex items-center", children: [
215
- n,
216
- b && /* @__PURE__ */ t("span", { className: "text-error ml-1", children: "*" }),
217
- x && /* @__PURE__ */ t(ce, {})
231
+ htmlFor: T,
232
+ className: `block text-sm font-medium ${L ? "flex-shrink-0 text-right" : ""} ${!L && !ne ? "mb-1" : ""}`,
233
+ style: L ? { width: W } : void 0,
234
+ "data-testid": f ? `${f}-label` : void 0,
235
+ children: /* @__PURE__ */ E("span", { className: "flex items-center", children: [
236
+ a,
237
+ $ && /* @__PURE__ */ t("span", { className: "text-error ml-1", children: "*" }),
238
+ y && /* @__PURE__ */ t(ge, {})
218
239
  ] })
219
240
  }
220
241
  ),
221
- he(fe())
242
+ ye(xe())
222
243
  ] }),
223
- !L && !v && /* @__PURE__ */ t("p", { id: F, className: `validator-hint ${E ? "!visible text-error" : ""} min-h-[1.25rem]`, role: E ? "alert" : void 0, "data-testid": m ? `${m}-error` : void 0, children: E || i && /* @__PURE__ */ t("span", { className: "text-base-content/70", children: i }) || " " }),
224
- L && (E || i) && /* @__PURE__ */ t("p", { id: F, className: `validator-hint ${E ? "!visible text-error" : ""} min-h-[1.25rem]`, role: E ? "alert" : void 0, "data-testid": m ? `${m}-error` : void 0, children: E || i && /* @__PURE__ */ t("span", { className: "text-base-content/70", children: i }) }),
225
- y && /* @__PURE__ */ t("div", { className: "text-sm text-base-content/60 mt-1", "data-testid": m ? `${m}-extra` : void 0, children: y })
244
+ !L && !x && /* @__PURE__ */ t("p", { id: V, className: `${le} ${A ? "!visible text-error" : ""} min-h-[1.25rem]`, role: A ? "alert" : void 0, "data-testid": f ? `${f}-error` : void 0, children: A || i && /* @__PURE__ */ t("span", { className: "text-base-content/70", children: i }) || " " }),
245
+ L && (A || i) && /* @__PURE__ */ t("p", { id: V, className: `${le} ${A ? "!visible text-error" : ""} min-h-[1.25rem]`, role: A ? "alert" : void 0, "data-testid": f ? `${f}-error` : void 0, children: A || i && /* @__PURE__ */ t("span", { className: "text-base-content/70", children: i }) }),
246
+ b && /* @__PURE__ */ t("div", { className: "text-sm text-base-content/60 mt-1", "data-testid": f ? `${f}-extra` : void 0, children: b })
226
247
  ] });
227
248
  }
228
249
  }
229
250
  );
230
251
  }
231
- function Re({
252
+ function De({
232
253
  name: s,
233
- children: n
254
+ children: a
234
255
  }) {
235
- const { form: r, layout: i, size: b, disabled: h } = K(), { fields: V, append: v, remove: l, move: c } = xe({
256
+ const { form: r, layout: i, size: $, disabled: g } = Q(), { fields: w, append: x, remove: c, move: l } = Fe({
236
257
  control: r.control,
237
258
  name: s
238
- }), x = V.map((y, $) => ({
239
- ...y,
240
- name: $
259
+ }), y = w.map((b, N) => ({
260
+ ...b,
261
+ name: N
241
262
  }));
242
- return /* @__PURE__ */ t(J.Provider, { value: { form: r, layout: i, size: b, listName: s, disabled: h }, children: n(x, {
243
- add: v,
244
- remove: l,
245
- move: c
263
+ return /* @__PURE__ */ t(G.Provider, { value: { form: r, layout: i, size: $, listName: s, disabled: g }, children: a(y, {
264
+ add: x,
265
+ remove: c,
266
+ move: l
246
267
  }) });
247
268
  }
248
- function Be() {
249
- const s = oe(), n = s;
250
- return n.setFieldValue = s.setValue, n.getFieldValue = (r) => s.getValues(r), n.getFieldsValue = s.getValues, n.setFieldsValue = (r) => {
269
+ function Ze() {
270
+ const s = ce(), a = s;
271
+ return a.setFieldValue = s.setValue, a.getFieldValue = (r) => s.getValues(r), a.getFieldsValue = s.getValues, a.setFieldsValue = (r) => {
251
272
  Object.keys(r).forEach((i) => {
252
273
  s.setValue(i, r[i]);
253
274
  });
254
- }, n.validateFields = s.trigger, n.resetFields = s.reset, n.isFieldTouched = (r) => !!s.formState.touchedFields[r], n.getFieldError = (r) => s.formState.errors[r]?.message, n;
275
+ }, a.validateFields = s.trigger, a.resetFields = s.reset, a.isFieldTouched = (r) => !!s.formState.touchedFields[r], a.getFieldError = (r) => s.formState.errors[r]?.message, a;
255
276
  }
256
- function Te({ fields: s, className: n = "", "data-testid": r }) {
257
- const { form: i } = K(), { errors: b } = i.formState, h = (l, c = "") => {
258
- const x = [];
259
- for (const y in l) {
260
- const $ = c ? `${c}.${y}` : y, d = l[y];
261
- d?.message ? x.push({ field: $, message: d.message }) : typeof d == "object" && d !== null && x.push(...h(d, $));
277
+ function qe({ fields: s, className: a = "", "data-testid": r }) {
278
+ const { form: i } = Q(), { errors: $ } = i.formState, g = (c, l = "") => {
279
+ const y = [];
280
+ for (const b in c) {
281
+ const N = l ? `${l}.${b}` : b, u = c[b];
282
+ u?.message ? y.push({ field: N, message: u.message }) : typeof u == "object" && u !== null && y.push(...g(u, N));
262
283
  }
263
- return x;
264
- }, V = h(b), v = s ? V.filter((l) => s.includes(l.field)) : V;
265
- return v.length === 0 ? null : /* @__PURE__ */ t("ul", { className: `text-error text-sm space-y-1 ${n}`, role: "alert", "data-testid": r, children: v.map((l, c) => /* @__PURE__ */ C("li", { className: "flex items-start gap-2", "data-testid": r ? `${r}-${l.field}` : void 0, children: [
284
+ return y;
285
+ }, w = g($), x = s ? w.filter((c) => s.includes(c.field)) : w;
286
+ return x.length === 0 ? null : /* @__PURE__ */ t("ul", { className: `text-error text-sm space-y-1 ${a}`, role: "alert", "data-testid": r, children: x.map((c, l) => /* @__PURE__ */ E("li", { className: "flex items-start gap-2", "data-testid": r ? `${r}-${c.field}` : void 0, children: [
266
287
  /* @__PURE__ */ t("svg", { className: "w-4 h-4 mt-0.5 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
267
- /* @__PURE__ */ t("span", { children: l.message })
268
- ] }, `${l.field}-${c}`)) });
288
+ /* @__PURE__ */ t("span", { children: c.message })
289
+ ] }, `${c.field}-${l}`)) });
269
290
  }
270
- const _e = Object.assign(Me, {
271
- Item: Pe,
272
- List: Re,
273
- ErrorList: Te,
274
- useForm: Be
291
+ const Ue = Object.assign(Ie, {
292
+ Item: We,
293
+ List: De,
294
+ ErrorList: qe,
295
+ useForm: Ze
275
296
  });
276
297
  export {
277
- _e as Form,
278
- Be as useFormInstance
298
+ Ue as Form,
299
+ Ze as useFormInstance
279
300
  };
280
301
  //# sourceMappingURL=Form.js.map