@aster-ui/prefixed 0.12.50 → 0.12.52

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