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.
- package/dist/components/Autocomplete.js +1 -1
- package/dist/components/Autocomplete.js.map +1 -1
- package/dist/components/Button.js +1 -1
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/ColorPicker.js +1 -1
- package/dist/components/ColorPicker.js.map +1 -1
- package/dist/components/CopyButton.js +1 -1
- package/dist/components/CopyButton.js.map +1 -1
- package/dist/components/Countdown.js +1 -1
- package/dist/components/Countdown.js.map +1 -1
- package/dist/components/DatePicker.js +1 -1
- package/dist/components/DatePicker.js.map +1 -1
- package/dist/components/Dock.js +1 -1
- package/dist/components/Dock.js.map +1 -1
- package/dist/components/Empty.js +1 -1
- package/dist/components/Empty.js.map +1 -1
- package/dist/components/FileInput.js +1 -1
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/Filter.js +1 -1
- package/dist/components/Filter.js.map +1 -1
- package/dist/components/Form.d.ts +10 -1
- package/dist/components/Form.js +205 -184
- package/dist/components/Form.js.map +1 -1
- package/dist/components/Input.js +1 -1
- package/dist/components/Input.js.map +1 -1
- package/dist/components/InputNumber.js +1 -1
- package/dist/components/InputNumber.js.map +1 -1
- package/dist/components/List.js +1 -1
- package/dist/components/List.js.map +1 -1
- package/dist/components/Loading.js +1 -1
- package/dist/components/Loading.js.map +1 -1
- package/dist/components/Modal.js +1 -1
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/OTPInput.js +1 -1
- package/dist/components/OTPInput.js.map +1 -1
- package/dist/components/Pagination.js +1 -1
- package/dist/components/Pagination.js.map +1 -1
- package/dist/components/Popconfirm.js +1 -1
- package/dist/components/Popconfirm.js.map +1 -1
- package/dist/components/Radio.js +1 -1
- package/dist/components/Radio.js.map +1 -1
- package/dist/components/Range.js +1 -1
- package/dist/components/Range.js.map +1 -1
- package/dist/components/Rating.js +1 -1
- package/dist/components/Rating.js.map +1 -1
- package/dist/components/RichTextEditor.js +1 -1
- package/dist/components/RichTextEditor.js.map +1 -1
- package/dist/components/Segmented.js +1 -1
- package/dist/components/Segmented.js.map +1 -1
- package/dist/components/Select.js +1 -1
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Table.d.ts +19 -0
- package/dist/components/Table.js +348 -310
- package/dist/components/Table.js.map +1 -1
- package/dist/components/Tabs.js +1 -1
- package/dist/components/Tabs.js.map +1 -1
- package/dist/components/Textarea.js +1 -1
- package/dist/components/Textarea.js.map +1 -1
- package/dist/components/ThemeController.js +1 -1
- package/dist/components/ThemeController.js.map +1 -1
- package/dist/components/TimePicker.js +1 -1
- package/dist/components/TimePicker.js.map +1 -1
- package/dist/components/Toggle.js +1 -1
- package/dist/components/Toggle.js.map +1 -1
- package/dist/hooks/useTheme.d.ts +1 -1
- package/dist/hooks/useTheme.js +1 -1
- package/dist/hooks/useTheme.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/providers/ConfigProvider.js.map +1 -0
- package/dist/providers/ThemeProvider.js.map +1 -0
- package/package.json +1 -1
- package/dist/components/ConfigProvider.js.map +0 -1
- package/dist/components/ThemeProvider.js.map +0 -1
- /package/dist/{components → providers}/ConfigProvider.d.ts +0 -0
- /package/dist/{components → providers}/ConfigProvider.js +0 -0
- /package/dist/{components → providers}/ThemeProvider.d.ts +0 -0
- /package/dist/{components → providers}/ThemeProvider.js +0 -0
package/dist/components/Form.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useForm as
|
|
4
|
-
import { useConfig as
|
|
5
|
-
const
|
|
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
|
|
20
|
-
const s =
|
|
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
|
|
25
|
+
function Ie({
|
|
26
26
|
form: s,
|
|
27
|
-
onFinish:
|
|
27
|
+
onFinish: a,
|
|
28
28
|
onFinishFailed: r,
|
|
29
29
|
initialValues: i,
|
|
30
|
-
layout:
|
|
31
|
-
labelWidth:
|
|
32
|
-
size:
|
|
33
|
-
disabled:
|
|
34
|
-
children:
|
|
35
|
-
className:
|
|
36
|
-
noValidate:
|
|
37
|
-
...
|
|
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:
|
|
39
|
+
const { componentSize: N } = we(), u = w ?? N ?? "md", z = ce({
|
|
40
40
|
defaultValues: i
|
|
41
|
-
}),
|
|
42
|
-
if (
|
|
43
|
-
|
|
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
|
|
46
|
-
for (const
|
|
47
|
-
const
|
|
48
|
-
|
|
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
|
-
|
|
51
|
+
M(d), r({ values: F.getValues(), errorFields: k });
|
|
52
52
|
}
|
|
53
|
-
},
|
|
54
|
-
|
|
53
|
+
}, S = (C) => {
|
|
54
|
+
C.preventDefault(), F.reset(i);
|
|
55
55
|
};
|
|
56
|
-
return /* @__PURE__ */ t(
|
|
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
|
|
58
|
+
function We({
|
|
59
59
|
name: s,
|
|
60
|
-
label:
|
|
60
|
+
label: a,
|
|
61
61
|
floatingLabel: r,
|
|
62
62
|
help: i,
|
|
63
|
-
required:
|
|
64
|
-
rules:
|
|
65
|
-
valuePropName:
|
|
66
|
-
inline:
|
|
67
|
-
className:
|
|
68
|
-
children:
|
|
69
|
-
tooltip:
|
|
70
|
-
extra:
|
|
71
|
-
hasFeedback:
|
|
72
|
-
dependencies:
|
|
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:
|
|
75
|
-
hidden:
|
|
76
|
-
addonBefore:
|
|
77
|
-
addonAfter:
|
|
78
|
-
"data-testid":
|
|
74
|
+
initialValue: F,
|
|
75
|
+
hidden: I = !1,
|
|
76
|
+
addonBefore: S,
|
|
77
|
+
addonAfter: C,
|
|
78
|
+
"data-testid": f
|
|
79
79
|
}) {
|
|
80
|
-
const { form:
|
|
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: `${
|
|
83
|
-
let
|
|
84
|
-
Array.isArray(s) ?
|
|
85
|
-
|
|
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
|
|
88
|
-
control:
|
|
89
|
-
name:
|
|
90
|
-
disabled: !
|
|
91
|
-
}),
|
|
92
|
-
|
|
93
|
-
const D =
|
|
94
|
-
|
|
95
|
-
if (!
|
|
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(
|
|
97
|
+
D.current = JSON.stringify(O);
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
-
const e = JSON.stringify(
|
|
101
|
-
|
|
102
|
-
|
|
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
|
|
105
|
-
let
|
|
106
|
-
for (const
|
|
107
|
-
if (!
|
|
108
|
-
|
|
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
|
|
111
|
-
})(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
|
119
|
-
|
|
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
|
|
123
|
-
|
|
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
|
|
127
|
-
|
|
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
|
-
(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
|
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
|
-
|
|
164
|
+
Ve,
|
|
146
165
|
{
|
|
147
|
-
name:
|
|
148
|
-
control:
|
|
149
|
-
rules:
|
|
150
|
-
render: ({ field: e, fieldState:
|
|
151
|
-
const { value:
|
|
152
|
-
id:
|
|
153
|
-
ref:
|
|
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 ?
|
|
156
|
-
"data-testid":
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
179
|
-
k &&
|
|
198
|
+
const J = [
|
|
199
|
+
ze,
|
|
200
|
+
k && oe[k]
|
|
180
201
|
].filter(Boolean).join(" ");
|
|
181
|
-
return /* @__PURE__ */
|
|
182
|
-
|
|
183
|
-
/* @__PURE__ */
|
|
202
|
+
return /* @__PURE__ */ E("label", { className: J, children: [
|
|
203
|
+
re,
|
|
204
|
+
/* @__PURE__ */ E("span", { children: [
|
|
184
205
|
r,
|
|
185
|
-
|
|
206
|
+
$ && /* @__PURE__ */ t("span", { className: "text-error ml-1", children: "*" })
|
|
186
207
|
] })
|
|
187
208
|
] });
|
|
188
209
|
}
|
|
189
|
-
return
|
|
190
|
-
},
|
|
191
|
-
if (!
|
|
192
|
-
const
|
|
193
|
-
|
|
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 &&
|
|
218
|
+
k && oe[k]
|
|
198
219
|
].filter(Boolean).join(" ");
|
|
199
|
-
return /* @__PURE__ */
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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__ */
|
|
206
|
-
/* @__PURE__ */
|
|
207
|
-
|
|
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:
|
|
211
|
-
className: `block text-sm font-medium ${L ? "flex-shrink-0 text-right" : ""} ${!L && !
|
|
212
|
-
style: L ? { width:
|
|
213
|
-
"data-testid":
|
|
214
|
-
children: /* @__PURE__ */
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
242
|
+
ye(xe())
|
|
222
243
|
] }),
|
|
223
|
-
!L && !
|
|
224
|
-
L && (
|
|
225
|
-
|
|
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
|
|
252
|
+
function De({
|
|
232
253
|
name: s,
|
|
233
|
-
children:
|
|
254
|
+
children: a
|
|
234
255
|
}) {
|
|
235
|
-
const { form: r, layout: i, size:
|
|
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
|
-
}),
|
|
239
|
-
...
|
|
240
|
-
name:
|
|
259
|
+
}), y = w.map((b, N) => ({
|
|
260
|
+
...b,
|
|
261
|
+
name: N
|
|
241
262
|
}));
|
|
242
|
-
return /* @__PURE__ */ t(
|
|
243
|
-
add:
|
|
244
|
-
remove:
|
|
245
|
-
move:
|
|
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
|
|
249
|
-
const s =
|
|
250
|
-
return
|
|
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
|
-
},
|
|
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
|
|
257
|
-
const { form: i } =
|
|
258
|
-
const
|
|
259
|
-
for (const
|
|
260
|
-
const
|
|
261
|
-
|
|
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
|
|
264
|
-
},
|
|
265
|
-
return
|
|
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:
|
|
268
|
-
] }, `${
|
|
288
|
+
/* @__PURE__ */ t("span", { children: c.message })
|
|
289
|
+
] }, `${c.field}-${l}`)) });
|
|
269
290
|
}
|
|
270
|
-
const
|
|
271
|
-
Item:
|
|
272
|
-
List:
|
|
273
|
-
ErrorList:
|
|
274
|
-
useForm:
|
|
291
|
+
const Ue = Object.assign(Ie, {
|
|
292
|
+
Item: We,
|
|
293
|
+
List: De,
|
|
294
|
+
ErrorList: qe,
|
|
295
|
+
useForm: Ze
|
|
275
296
|
});
|
|
276
297
|
export {
|
|
277
|
-
|
|
278
|
-
|
|
298
|
+
Ue as Form,
|
|
299
|
+
Ze as useFormInstance
|
|
279
300
|
};
|
|
280
301
|
//# sourceMappingURL=Form.js.map
|