asterui 0.12.51 → 0.12.54
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/Form.d.ts +8 -2
- package/dist/components/Form.js +158 -155
- package/dist/components/Form.js.map +1 -1
- package/dist/components/QRCode.js +38 -37
- package/dist/components/QRCode.js.map +1 -1
- package/dist/hooks/useTheme.d.ts +29 -0
- package/dist/hooks/useTheme.js +56 -0
- package/dist/hooks/useTheme.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +44 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,8 @@ export interface FormProps<TFieldValues extends FieldValues = FieldValues> exten
|
|
|
19
19
|
/** Disable all form fields */
|
|
20
20
|
disabled?: boolean;
|
|
21
21
|
children: React.ReactNode;
|
|
22
|
+
/** Test ID for the form element */
|
|
23
|
+
'data-testid'?: string;
|
|
22
24
|
}
|
|
23
25
|
export interface FormRule {
|
|
24
26
|
required?: boolean | string;
|
|
@@ -69,6 +71,8 @@ export interface FormItemProps {
|
|
|
69
71
|
addonBefore?: React.ReactNode;
|
|
70
72
|
/** Text/element after input (outside, using DaisyUI label) */
|
|
71
73
|
addonAfter?: React.ReactNode;
|
|
74
|
+
/** Test ID for the form item (used as prefix for child elements) */
|
|
75
|
+
'data-testid'?: string;
|
|
72
76
|
}
|
|
73
77
|
export interface FormListProps<TFieldValues extends FieldValues = FieldValues> {
|
|
74
78
|
name: FieldArrayPath<TFieldValues>;
|
|
@@ -79,7 +83,7 @@ export interface FormListProps<TFieldValues extends FieldValues = FieldValues> {
|
|
|
79
83
|
}) => React.ReactNode;
|
|
80
84
|
}
|
|
81
85
|
declare function FormRoot<TFieldValues extends FieldValues = FieldValues>({ form: externalForm, onFinish, onFinishFailed, initialValues, layout, labelWidth, size, disabled, children, className, noValidate, ...props }: FormProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
82
|
-
declare function FormItem({ name, label, floatingLabel, help, required, rules, valuePropName, inline, className, children, tooltip, extra, hasFeedback, dependencies, validateTrigger, initialValue, hidden, addonBefore, addonAfter, }: FormItemProps): import("react/jsx-runtime").JSX.Element;
|
|
86
|
+
declare function FormItem({ name, label, floatingLabel, help, required, rules, valuePropName, inline, className, children, tooltip, extra, hasFeedback, dependencies, validateTrigger, initialValue, hidden, addonBefore, addonAfter, 'data-testid': testId, }: FormItemProps): import("react/jsx-runtime").JSX.Element;
|
|
83
87
|
declare function FormList<TFieldValues extends FieldValues = FieldValues>({ name, children, }: FormListProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
84
88
|
export declare function useFormInstance<TFieldValues extends FieldValues = FieldValues>(): UseFormReturn<TFieldValues, any, TFieldValues> & {
|
|
85
89
|
setFieldValue: import('react-hook-form').UseFormSetValue<TFieldValues>;
|
|
@@ -96,8 +100,10 @@ export interface FormErrorListProps {
|
|
|
96
100
|
fields?: string[];
|
|
97
101
|
/** Custom className */
|
|
98
102
|
className?: string;
|
|
103
|
+
/** Test ID for the error list */
|
|
104
|
+
'data-testid'?: string;
|
|
99
105
|
}
|
|
100
|
-
declare function FormErrorList({ fields, className }: FormErrorListProps): import("react/jsx-runtime").JSX.Element | null;
|
|
106
|
+
declare function FormErrorList({ fields, className, 'data-testid': testId }: FormErrorListProps): import("react/jsx-runtime").JSX.Element | null;
|
|
101
107
|
export declare const Form: typeof FormRoot & {
|
|
102
108
|
Item: typeof FormItem;
|
|
103
109
|
List: typeof FormList;
|
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 Ne = "input",
|
|
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 = {
|
|
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 = "input", $e = "input-xs", ke = "input-sm", Fe = "input-md", Ve = "inp
|
|
|
16
16
|
message: "Please enter a valid number"
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
function
|
|
20
|
-
const s =
|
|
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
|
|
25
|
+
function Me({
|
|
26
26
|
form: s,
|
|
27
27
|
onFinish: n,
|
|
28
28
|
onFinishFailed: r,
|
|
29
29
|
initialValues: i,
|
|
30
|
-
layout:
|
|
30
|
+
layout: b = "vertical",
|
|
31
31
|
labelWidth: h = 60,
|
|
32
|
-
size:
|
|
33
|
-
disabled:
|
|
34
|
-
children:
|
|
35
|
-
className:
|
|
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:
|
|
39
|
+
const { componentSize: $ } = $e(), d = V ?? $ ?? "md", z = oe({
|
|
40
40
|
defaultValues: i
|
|
41
|
-
}),
|
|
42
|
-
if (
|
|
43
|
-
n && n(
|
|
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
|
|
46
|
-
for (const
|
|
47
|
-
const
|
|
48
|
-
|
|
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(
|
|
51
|
+
S(u), r({ values: N.getValues(), errorFields: k });
|
|
52
52
|
}
|
|
53
|
-
},
|
|
54
|
-
|
|
53
|
+
}, j = (w) => {
|
|
54
|
+
w.preventDefault(), N.reset(i);
|
|
55
55
|
};
|
|
56
|
-
return /* @__PURE__ */ t(
|
|
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
|
|
58
|
+
function Pe({
|
|
59
59
|
name: s,
|
|
60
60
|
label: n,
|
|
61
61
|
floatingLabel: r,
|
|
62
62
|
help: i,
|
|
63
|
-
required:
|
|
63
|
+
required: b = !1,
|
|
64
64
|
rules: h,
|
|
65
|
-
valuePropName:
|
|
66
|
-
inline:
|
|
67
|
-
className:
|
|
68
|
-
children:
|
|
65
|
+
valuePropName: V = "value",
|
|
66
|
+
inline: v = !1,
|
|
67
|
+
className: l = "",
|
|
68
|
+
children: c,
|
|
69
69
|
tooltip: x,
|
|
70
70
|
extra: y,
|
|
71
|
-
hasFeedback:
|
|
72
|
-
dependencies:
|
|
73
|
-
validateTrigger:
|
|
74
|
-
initialValue:
|
|
75
|
-
hidden:
|
|
76
|
-
addonBefore:
|
|
77
|
-
addonAfter:
|
|
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:
|
|
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: `${
|
|
82
|
-
let
|
|
83
|
-
Array.isArray(s) ?
|
|
84
|
-
|
|
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
|
|
87
|
-
control:
|
|
88
|
-
name:
|
|
89
|
-
disabled:
|
|
90
|
-
}),
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
if (
|
|
96
|
-
|
|
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(
|
|
100
|
-
|
|
101
|
-
}, [
|
|
102
|
-
const
|
|
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 =
|
|
105
|
-
for (const
|
|
105
|
+
let a = u.formState.errors;
|
|
106
|
+
for (const T of o) {
|
|
106
107
|
if (!a) break;
|
|
107
|
-
a = a[
|
|
108
|
+
a = a[T];
|
|
108
109
|
}
|
|
109
110
|
return a;
|
|
110
|
-
})(
|
|
111
|
-
|
|
112
|
-
for (const e of
|
|
113
|
-
if (e.required && (
|
|
114
|
-
pattern:
|
|
115
|
-
message: e.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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
127
|
+
q.push({ pattern: o, message: a });
|
|
127
128
|
}
|
|
128
|
-
e.validate &&
|
|
129
|
+
e.validate && O.push(e.validate);
|
|
129
130
|
}
|
|
130
|
-
(
|
|
131
|
-
if (!e && !
|
|
132
|
-
for (const { pattern: o, message: a } of
|
|
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
|
|
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
|
|
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
|
-
|
|
145
|
+
be,
|
|
145
146
|
{
|
|
146
|
-
name:
|
|
147
|
-
control:
|
|
148
|
-
rules:
|
|
147
|
+
name: p,
|
|
148
|
+
control: u.control,
|
|
149
|
+
rules: A,
|
|
149
150
|
render: ({ field: e, fieldState: o }) => {
|
|
150
|
-
const { value: a, onChange:
|
|
151
|
-
id:
|
|
151
|
+
const { value: a, onChange: T, onBlur: de, ref: ue } = e, me = o.isTouched && u.formState.isValidating, g = {
|
|
152
|
+
id: R,
|
|
152
153
|
ref: ue,
|
|
153
|
-
"aria-invalid":
|
|
154
|
-
"aria-describedby":
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
}) : (
|
|
161
|
-
f && f.target !== void 0 ?
|
|
162
|
-
}),
|
|
163
|
-
const
|
|
164
|
-
xs:
|
|
165
|
-
sm:
|
|
166
|
-
md:
|
|
167
|
-
lg:
|
|
168
|
-
xl:
|
|
169
|
-
},
|
|
170
|
-
const f = /* @__PURE__ */
|
|
171
|
-
|
|
172
|
-
|
|
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
|
|
176
|
-
|
|
177
|
-
|
|
177
|
+
const _ = [
|
|
178
|
+
Ce,
|
|
179
|
+
k && ee[k]
|
|
178
180
|
].filter(Boolean).join(" ");
|
|
179
|
-
return /* @__PURE__ */
|
|
180
|
-
|
|
181
|
-
/* @__PURE__ */
|
|
181
|
+
return /* @__PURE__ */ C("label", { className: _, children: [
|
|
182
|
+
G,
|
|
183
|
+
/* @__PURE__ */ C("span", { children: [
|
|
182
184
|
r,
|
|
183
|
-
|
|
185
|
+
b && /* @__PURE__ */ t("span", { className: "text-error ml-1", children: "*" })
|
|
184
186
|
] })
|
|
185
187
|
] });
|
|
186
188
|
}
|
|
187
189
|
return f;
|
|
188
|
-
},
|
|
189
|
-
if (!
|
|
190
|
-
const
|
|
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
|
-
|
|
197
|
+
k && ee[k]
|
|
196
198
|
].filter(Boolean).join(" ");
|
|
197
|
-
return /* @__PURE__ */
|
|
198
|
-
|
|
199
|
+
return /* @__PURE__ */ C("label", { className: _, children: [
|
|
200
|
+
j && /* @__PURE__ */ t("span", { className: "text-base-content/70", children: j }),
|
|
199
201
|
f,
|
|
200
|
-
|
|
202
|
+
w && /* @__PURE__ */ t("span", { className: "text-base-content/70", children: w })
|
|
201
203
|
] });
|
|
202
204
|
};
|
|
203
|
-
return /* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */
|
|
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:
|
|
209
|
-
className: `block text-sm font-medium ${
|
|
210
|
-
style:
|
|
211
|
-
|
|
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
|
-
|
|
214
|
-
x && /* @__PURE__ */ t(
|
|
216
|
+
b && /* @__PURE__ */ t("span", { className: "text-error ml-1", children: "*" }),
|
|
217
|
+
x && /* @__PURE__ */ t(ce, {})
|
|
215
218
|
] })
|
|
216
219
|
}
|
|
217
220
|
),
|
|
218
|
-
fe(
|
|
221
|
+
he(fe())
|
|
219
222
|
] }),
|
|
220
|
-
!
|
|
221
|
-
|
|
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
|
|
231
|
+
function Re({
|
|
229
232
|
name: s,
|
|
230
233
|
children: n
|
|
231
234
|
}) {
|
|
232
|
-
const { form: r, layout: i, size:
|
|
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 =
|
|
238
|
+
}), x = V.map((y, $) => ({
|
|
236
239
|
...y,
|
|
237
|
-
name:
|
|
240
|
+
name: $
|
|
238
241
|
}));
|
|
239
|
-
return /* @__PURE__ */ t(
|
|
240
|
-
add:
|
|
241
|
-
remove:
|
|
242
|
-
move:
|
|
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
|
|
246
|
-
const 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
|
|
254
|
-
const { form:
|
|
255
|
-
const
|
|
256
|
-
for (const
|
|
257
|
-
const
|
|
258
|
-
d?.message ?
|
|
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
|
|
261
|
-
},
|
|
262
|
-
return
|
|
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:
|
|
265
|
-
] }, `${
|
|
267
|
+
/* @__PURE__ */ t("span", { children: l.message })
|
|
268
|
+
] }, `${l.field}-${c}`)) });
|
|
266
269
|
}
|
|
267
|
-
const
|
|
268
|
-
Item:
|
|
269
|
-
List:
|
|
270
|
-
ErrorList:
|
|
271
|
-
useForm:
|
|
270
|
+
const _e = Object.assign(Me, {
|
|
271
|
+
Item: Pe,
|
|
272
|
+
List: Re,
|
|
273
|
+
ErrorList: Te,
|
|
274
|
+
useForm: Be
|
|
272
275
|
});
|
|
273
276
|
export {
|
|
274
|
-
|
|
275
|
-
|
|
277
|
+
_e as Form,
|
|
278
|
+
Be as useFormInstance
|
|
276
279
|
};
|
|
277
280
|
//# sourceMappingURL=Form.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sources":["../../src/components/Form.tsx"],"sourcesContent":["import React, { createContext, useContext, cloneElement, isValidElement, useId, useEffect, useRef } from 'react'\nimport { useForm, UseFormReturn, FieldValues, SubmitHandler, UseFormProps, Controller, useFieldArray, FieldArrayPath, FieldArray, useWatch } from 'react-hook-form'\nimport { useConfig } from './ConfigProvider'\n\n// DaisyUI classes\nconst dInput = 'input'\nconst dInputXs = 'input-xs'\nconst dInputSm = 'input-sm'\nconst dInputMd = 'input-md'\nconst dInputLg = 'input-lg'\nconst dInputXl = 'input-xl'\nconst dFloatingLabel = 'floating-label'\nconst dLoading = 'loading'\nconst dLoadingSpinner = 'loading-spinner'\nconst dLoadingXs = 'loading-xs'\nconst dTooltip = 'tooltip'\nconst dTooltipTop = 'tooltip-top'\n\ninterface FormContextValue {\n form: UseFormReturn<any>\n layout?: 'vertical' | 'horizontal' | 'inline'\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n labelWidth?: number\n listName?: string\n disabled?: boolean\n}\n\nconst FormContext = createContext<FormContextValue | undefined>(undefined)\n\n// Built-in type validators\nconst TYPE_VALIDATORS = {\n email: {\n value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}$/i,\n message: 'Please enter a valid email address',\n },\n url: {\n value: /^https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)$/,\n message: 'Please enter a valid URL',\n },\n number: {\n value: /^-?\\d+(\\.\\d+)?$/,\n message: 'Please enter a valid number',\n },\n}\n\nexport interface FormProps<TFieldValues extends FieldValues = FieldValues>\n extends Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onSubmit'> {\n form?: UseFormReturn<TFieldValues>\n onFinish?: SubmitHandler<TFieldValues>\n /** Called when form validation fails */\n onFinishFailed?: (errorInfo: { values: TFieldValues; errorFields: Array<{ name: string; errors: string[] }> }) => void\n initialValues?: UseFormProps<TFieldValues>['defaultValues']\n layout?: 'vertical' | 'horizontal' | 'inline'\n /** Label width in pixels for horizontal layout (default: 80) */\n labelWidth?: number\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /** Disable all form fields */\n disabled?: boolean\n children: React.ReactNode\n}\n\nexport interface FormRule {\n required?: boolean | string\n type?: 'email' | 'url' | 'number'\n min?: number | { value: number; message: string }\n max?: number | { value: number; message: string }\n pattern?: RegExp | { value: RegExp; message: string }\n message?: string\n validate?: (value: any) => boolean | string | Promise<boolean | string>\n}\n\nexport type ValidateTrigger = 'onChange' | 'onBlur' | 'onSubmit' | ('onChange' | 'onBlur' | 'onSubmit')[]\n\nexport interface FormItemProps {\n name?: string | string[]\n label?: string\n /** Floating label text (alternative to label, uses DaisyUI floating-label) */\n floatingLabel?: string\n help?: string\n required?: boolean\n rules?: FormRule | FormRule[]\n valuePropName?: string\n inline?: boolean\n className?: string\n children: React.ReactElement\n /** Tooltip text to show next to label */\n tooltip?: string\n /** Additional content below the form control */\n extra?: React.ReactNode\n /** Show validation feedback icon */\n hasFeedback?: boolean\n /** Field names that this field depends on for validation */\n dependencies?: string[]\n /** When to trigger validation */\n validateTrigger?: ValidateTrigger\n /** Initial value for this field (overrides Form's initialValues) */\n initialValue?: any\n /** Hide this field (still validates and submits) */\n hidden?: boolean\n /** Text/element before input (outside, using DaisyUI label) */\n addonBefore?: React.ReactNode\n /** Text/element after input (outside, using DaisyUI label) */\n addonAfter?: React.ReactNode\n}\n\nexport interface FormListProps<TFieldValues extends FieldValues = FieldValues> {\n name: FieldArrayPath<TFieldValues>\n children: (\n fields: FieldArray<TFieldValues>[],\n operations: {\n add: (value?: any) => void\n remove: (index: number) => void\n move: (from: number, to: number) => void\n }\n ) => React.ReactNode\n}\n\nfunction useFormContext() {\n const context = useContext(FormContext)\n if (!context) {\n throw new Error('Form compound components must be used within Form')\n }\n return context\n}\n\nfunction FormRoot<TFieldValues extends FieldValues = FieldValues>({\n form: externalForm,\n onFinish,\n onFinishFailed,\n initialValues,\n layout = 'vertical',\n labelWidth = 60,\n size,\n disabled = false,\n children,\n className = '',\n noValidate = true,\n ...props\n}: FormProps<TFieldValues>) {\n const { componentSize } = useConfig()\n const effectiveSize = size ?? componentSize ?? 'md'\n\n const internalForm = useForm<TFieldValues>({\n defaultValues: initialValues,\n })\n\n const form = externalForm || internalForm\n\n const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault()\n\n // Trigger validation\n const isValid = await form.trigger()\n\n if (isValid) {\n if (onFinish) {\n onFinish(form.getValues())\n }\n } else {\n if (onFinishFailed) {\n const errors = form.formState.errors\n const errorFields: Array<{ name: string; errors: string[] }> = []\n\n // Flatten errors into errorFields array\n const flattenErrors = (obj: any, prefix = '') => {\n for (const key in obj) {\n const fullKey = prefix ? `${prefix}.${key}` : key\n const value = obj[key]\n if (value?.message) {\n errorFields.push({ name: fullKey, errors: [value.message as string] })\n } else if (typeof value === 'object' && value !== null) {\n flattenErrors(value, fullKey)\n }\n }\n }\n flattenErrors(errors)\n\n onFinishFailed({ values: form.getValues(), errorFields })\n }\n }\n }\n\n const handleReset = (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault()\n form.reset(initialValues as any)\n }\n\n return (\n <FormContext.Provider value={{ form, layout, labelWidth, size: effectiveSize, disabled }}>\n <form onSubmit={handleSubmit} onReset={handleReset} className={className} noValidate={noValidate} {...props}>\n {children}\n </form>\n </FormContext.Provider>\n )\n}\n\nfunction FormItem({\n name,\n label,\n floatingLabel,\n help,\n required = false,\n rules,\n valuePropName = 'value',\n inline = false,\n className = '',\n children,\n tooltip,\n extra,\n hasFeedback = false,\n dependencies,\n validateTrigger = 'onChange',\n initialValue,\n hidden = false,\n addonBefore,\n addonAfter,\n}: FormItemProps) {\n const { form, size, listName, layout, labelWidth, disabled: formDisabled } = useFormContext()\n const inputId = useId()\n const errorId = useId()\n\n if (!name) {\n // Render without form control if no name provided\n return <div className={`${inline ? 'w-auto' : 'w-full'} ${className}`} style={hidden ? { display: 'none' } : undefined}>{children}</div>\n }\n\n // Handle nested field names (for Form.List)\n let fieldName: string\n if (Array.isArray(name)) {\n // If we're inside a Form.List, prepend the list name\n const fullPath = listName ? [listName, ...name] : name\n fieldName = fullPath.join('.')\n } else {\n fieldName = name\n }\n\n // Set initial value if provided\n useEffect(() => {\n if (initialValue !== undefined) {\n const currentValue = form.getValues(fieldName as any)\n if (currentValue === undefined) {\n form.setValue(fieldName as any, initialValue)\n }\n }\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n // Watch dependencies and re-validate when they change\n const watchedDeps = useWatch({\n control: form.control,\n name: dependencies as any,\n disabled: !dependencies || dependencies.length === 0,\n })\n\n // Use refs to avoid infinite loops\n const formRef = useRef(form)\n formRef.current = form\n const prevDepsRef = useRef<string | undefined>(undefined)\n\n useEffect(() => {\n // Skip if no dependencies\n if (!dependencies || dependencies.length === 0) return\n\n // Skip initial render\n if (prevDepsRef.current === undefined) {\n prevDepsRef.current = JSON.stringify(watchedDeps)\n return\n }\n\n // Only trigger if dependency values actually changed\n const currentDeps = JSON.stringify(watchedDeps)\n if (prevDepsRef.current !== currentDeps) {\n prevDepsRef.current = currentDeps\n formRef.current.trigger(fieldName as any)\n }\n }, [watchedDeps, dependencies, fieldName])\n\n // Get error by traversing the error object path\n const getErrorByPath = (path: string) => {\n const keys = path.split('.')\n let error: any = form.formState.errors\n for (const key of keys) {\n if (!error) break\n error = error[key]\n }\n return error\n }\n\n const error = getErrorByPath(fieldName)\n const errorMessage = error?.message as string | undefined\n\n // Normalize rules to array\n const rulesArray: FormRule[] = rules\n ? Array.isArray(rules) ? rules : [rules]\n : []\n\n // Build validation rules\n const validationRules: any = {}\n const patternValidators: Array<{ pattern: RegExp; message: string }> = []\n const customValidators: Array<(value: any) => boolean | string | Promise<boolean | string>> = []\n\n // Handle top-level required prop\n if (required) {\n validationRules.required = 'This field is required'\n }\n\n // Process each rule\n for (const rule of rulesArray) {\n // Required\n if (rule.required) {\n validationRules.required = typeof rule.required === 'string'\n ? rule.required\n : rule.message || 'This field is required'\n }\n\n // Type validator\n if (rule.type && TYPE_VALIDATORS[rule.type]) {\n patternValidators.push({\n pattern: TYPE_VALIDATORS[rule.type].value,\n message: rule.message || TYPE_VALIDATORS[rule.type].message,\n })\n }\n\n // Min length\n if (rule.min !== undefined) {\n const minValue = typeof rule.min === 'object' ? rule.min.value : rule.min\n const minMessage = typeof rule.min === 'object'\n ? rule.min.message\n : rule.message || `Minimum length is ${minValue} characters`\n validationRules.minLength = { value: minValue, message: minMessage }\n }\n\n // Max length\n if (rule.max !== undefined) {\n const maxValue = typeof rule.max === 'object' ? rule.max.value : rule.max\n const maxMessage = typeof rule.max === 'object'\n ? rule.max.message\n : rule.message || `Maximum length is ${maxValue} characters`\n validationRules.maxLength = { value: maxValue, message: maxMessage }\n }\n\n // Pattern - collect all patterns\n if (rule.pattern) {\n const patternValue = rule.pattern instanceof RegExp ? rule.pattern : rule.pattern.value\n const patternMessage = rule.pattern instanceof RegExp\n ? rule.message || 'Invalid format'\n : rule.pattern.message\n patternValidators.push({ pattern: patternValue, message: patternMessage })\n }\n\n // Custom validator\n if (rule.validate) {\n customValidators.push(rule.validate)\n }\n }\n\n // Combine all pattern and custom validators into a single validate function\n if (patternValidators.length > 0 || customValidators.length > 0) {\n validationRules.validate = async (value: any) => {\n // Skip validation if empty (required rule handles that)\n if (!value && !validationRules.required) return true\n\n // Check all patterns\n for (const { pattern, message } of patternValidators) {\n if (value && !pattern.test(value)) {\n return message\n }\n }\n\n // Run all custom validators\n for (const validator of customValidators) {\n const result = await validator(value)\n if (result !== true) {\n return result\n }\n }\n\n return true\n }\n }\n\n // Normalize validateTrigger to array\n const triggers = Array.isArray(validateTrigger) ? validateTrigger : [validateTrigger]\n const shouldValidateOnChange = triggers.includes('onChange')\n const shouldValidateOnBlur = triggers.includes('onBlur')\n\n // Feedback icons\n const FeedbackIcon = ({ hasError, isValidating }: { hasError: boolean; isValidating: boolean }) => {\n if (isValidating) {\n return (\n <span className={`${dLoading} ${dLoadingSpinner} ${dLoadingXs} text-base-content/50`} />\n )\n }\n if (hasError) {\n return (\n <svg className=\"w-4 h-4 text-error\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n )\n }\n return (\n <svg className=\"w-4 h-4 text-success\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M5 13l4 4L19 7\" />\n </svg>\n )\n }\n\n // Tooltip icon\n const TooltipIcon = () => (\n <div className={`${dTooltip} ${dTooltipTop} ml-1`} data-tip={tooltip}>\n <svg className=\"w-4 h-4 text-base-content/50 cursor-help\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <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\" />\n </svg>\n </div>\n )\n\n return (\n <Controller\n name={fieldName}\n control={form.control}\n rules={validationRules}\n render={({ field, fieldState }) => {\n const { value, onChange, onBlur, ref } = field\n const isValidating = fieldState.isTouched && form.formState.isValidating\n\n // Clone the child element and inject form control props\n const childProps: any = {\n id: inputId,\n ref,\n 'aria-invalid': error ? true : undefined,\n 'aria-describedby': error ? errorId : undefined,\n }\n\n // Handle onBlur based on validateTrigger\n childProps.onBlur = () => {\n onBlur()\n if (shouldValidateOnBlur) {\n form.trigger(fieldName as any)\n }\n }\n\n // Handle different value prop names (e.g., 'checked' for checkboxes)\n if (valuePropName === 'checked') {\n childProps.checked = value\n childProps.onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange(e.target.checked)\n if (shouldValidateOnChange) {\n form.trigger(fieldName as any)\n }\n }\n } else {\n childProps.value = value || ''\n childProps.onChange = (eventOrValue: any) => {\n // Handle components that pass value directly (e.g., Range, Rating)\n // vs components that pass event object (e.g., Input, Select)\n if (eventOrValue && eventOrValue.target !== undefined) {\n onChange(eventOrValue.target.value)\n } else {\n onChange(eventOrValue)\n }\n if (shouldValidateOnChange) {\n form.trigger(fieldName as any)\n }\n }\n }\n\n // Apply size if specified at form level\n if (size && isValidElement(children)) {\n const existingProps = children.props as any\n if (!existingProps.size) {\n childProps.size = size\n }\n }\n\n // Apply error styling and accessibility\n if (error) {\n childProps.color = 'error'\n childProps['aria-invalid'] = true\n }\n\n // Apply form-level disabled state\n if (formDisabled) {\n childProps.disabled = true\n }\n\n // When wrapped with addons, the child input should be unstyled (the wrapper has the styling)\n const hasAddons = addonBefore || addonAfter\n if (hasAddons) {\n childProps.unstyled = true\n }\n\n const enhancedChild = isValidElement(children)\n ? cloneElement(children as React.ReactElement<any>, childProps)\n : children\n\n const isHorizontal = layout === 'horizontal'\n const isInline = layout === 'inline'\n\n // Size class for floating label\n const floatingSizeClasses: Record<string, string> = {\n xs: dInputXs,\n sm: dInputSm,\n md: dInputMd,\n lg: dInputLg,\n xl: dInputXl,\n }\n\n // Build the input element with optional floating label wrapper\n const renderInputElement = () => {\n const inputWithFeedback = (\n <div className={`${isHorizontal ? 'flex-1' : ''} ${hasFeedback ? 'relative' : ''}`}>\n {enhancedChild}\n {hasFeedback && fieldState.isTouched && (\n <span className=\"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none\">\n <FeedbackIcon hasError={!!error} isValidating={isValidating} />\n </span>\n )}\n </div>\n )\n\n // Floating label variant\n if (floatingLabel) {\n const floatingClasses = [\n dFloatingLabel,\n size && floatingSizeClasses[size],\n ].filter(Boolean).join(' ')\n\n return (\n <label className={floatingClasses}>\n {enhancedChild}\n <span>{floatingLabel}{required && <span className=\"text-error ml-1\">*</span>}</span>\n </label>\n )\n }\n\n return inputWithFeedback\n }\n\n // Wrap with external addons if specified using DaisyUI input wrapper pattern\n const renderWithAddons = (input: React.ReactNode) => {\n if (!addonBefore && !addonAfter) return input\n\n const addonClasses = [\n dInput,\n 'flex',\n 'items-center',\n 'gap-2',\n size && floatingSizeClasses[size],\n ].filter(Boolean).join(' ')\n\n return (\n <label className={addonClasses}>\n {addonBefore && <span className=\"text-base-content/70\">{addonBefore}</span>}\n {input}\n {addonAfter && <span className=\"text-base-content/70\">{addonAfter}</span>}\n </label>\n )\n }\n\n return (\n <div className={`${inline ? 'w-auto' : 'w-full'} ${isHorizontal ? 'mb-4' : ''} ${isInline ? 'inline-flex mr-4' : ''} ${className}`} style={hidden ? { display: 'none' } : undefined}>\n <div className={isHorizontal ? 'flex items-center gap-4' : ''}>\n {label && !floatingLabel && (\n <label\n htmlFor={inputId}\n className={`block text-sm font-medium ${isHorizontal ? 'flex-shrink-0 text-right' : ''} ${!isHorizontal && !isInline ? 'mb-1' : ''}`}\n style={isHorizontal ? { width: labelWidth } : undefined}\n >\n <span className=\"flex items-center\">\n {label}\n {required && <span className=\"text-error ml-1\">*</span>}\n {tooltip && <TooltipIcon />}\n </span>\n </label>\n )}\n {renderWithAddons(renderInputElement())}\n </div>\n {!isHorizontal && !inline && (\n <p id={errorId} className={`validator-hint ${errorMessage ? '!visible text-error' : ''} min-h-[1.25rem]`} role={errorMessage ? 'alert' : undefined}>\n {errorMessage || (help && <span className=\"text-base-content/70\">{help}</span>) || '\\u00A0'}\n </p>\n )}\n {isHorizontal && (errorMessage || help) && (\n <p id={errorId} className={`validator-hint ${errorMessage ? '!visible text-error' : ''} min-h-[1.25rem]`} role={errorMessage ? 'alert' : undefined}>\n {errorMessage || (help && <span className=\"text-base-content/70\">{help}</span>)}\n </p>\n )}\n {extra && (\n <div className=\"text-sm text-base-content/60 mt-1\">{extra}</div>\n )}\n </div>\n )\n }}\n />\n )\n}\n\nfunction FormList<TFieldValues extends FieldValues = FieldValues>({\n name,\n children,\n}: FormListProps<TFieldValues>) {\n const { form, layout, size, disabled } = useFormContext()\n\n const { fields, append, remove, move } = useFieldArray({\n control: form.control,\n name,\n })\n\n // Add name (index) to each field for proper path construction\n const fieldsWithName = fields.map((field, index) => ({\n ...field,\n name: index,\n }))\n\n return (\n <FormContext.Provider value={{ form, layout, size, listName: name as string, disabled }}>\n {children(fieldsWithName as any, {\n add: append,\n remove,\n move,\n })}\n </FormContext.Provider>\n )\n}\n\n// Enhanced hook to expose full form API\nexport function useFormInstance<TFieldValues extends FieldValues = FieldValues>() {\n const formInstance = useForm<TFieldValues>()\n\n // Add convenience methods to the instance\n const enhancedInstance = formInstance as typeof formInstance & {\n setFieldValue: typeof formInstance.setValue\n getFieldValue: (name: any) => any\n getFieldsValue: typeof formInstance.getValues\n setFieldsValue: (values: any) => void\n validateFields: typeof formInstance.trigger\n resetFields: typeof formInstance.reset\n isFieldTouched: (name: string) => boolean\n getFieldError: (name: string) => string | undefined\n }\n\n // Add the alias methods\n enhancedInstance.setFieldValue = formInstance.setValue\n enhancedInstance.getFieldValue = (name: any) => formInstance.getValues(name)\n enhancedInstance.getFieldsValue = formInstance.getValues\n enhancedInstance.setFieldsValue = (values: any) => {\n Object.keys(values).forEach((key) => {\n formInstance.setValue(key as any, values[key])\n })\n }\n enhancedInstance.validateFields = formInstance.trigger\n enhancedInstance.resetFields = formInstance.reset\n enhancedInstance.isFieldTouched = (name: string) => {\n const touched = formInstance.formState.touchedFields as any\n return !!touched[name]\n }\n enhancedInstance.getFieldError = (name: string) => {\n const errors = formInstance.formState.errors as any\n return errors[name]?.message as string | undefined\n }\n\n return enhancedInstance\n}\n\nexport interface FormErrorListProps {\n /** Specific field names to show errors for (shows all errors if not specified) */\n fields?: string[]\n /** Custom className */\n className?: string\n}\n\nfunction FormErrorList({ fields, className = '' }: FormErrorListProps) {\n const { form } = useFormContext()\n const { errors } = form.formState\n\n // Flatten nested errors into a list\n const flattenErrors = (obj: any, prefix = ''): Array<{ field: string; message: string }> => {\n const result: Array<{ field: string; message: string }> = []\n\n for (const key in obj) {\n const fullKey = prefix ? `${prefix}.${key}` : key\n const value = obj[key]\n\n if (value?.message) {\n result.push({ field: fullKey, message: value.message as string })\n } else if (typeof value === 'object' && value !== null) {\n result.push(...flattenErrors(value, fullKey))\n }\n }\n\n return result\n }\n\n const allErrors = flattenErrors(errors)\n const filteredErrors = fields\n ? allErrors.filter(e => fields.includes(e.field))\n : allErrors\n\n if (filteredErrors.length === 0) {\n return null\n }\n\n return (\n <ul className={`text-error text-sm space-y-1 ${className}`} role=\"alert\">\n {filteredErrors.map((error, index) => (\n <li key={`${error.field}-${index}`} className=\"flex items-start gap-2\">\n <svg className=\"w-4 h-4 mt-0.5 flex-shrink-0\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z\" />\n </svg>\n <span>{error.message}</span>\n </li>\n ))}\n </ul>\n )\n}\n\nexport const Form = Object.assign(FormRoot, {\n Item: FormItem,\n List: FormList,\n ErrorList: FormErrorList,\n useForm: useFormInstance,\n})\n\nexport type { UseFormReturn as FormInstance }\n"],"names":["dInput","dInputXs","dInputSm","dInputMd","dInputLg","dInputXl","dFloatingLabel","dLoading","dLoadingSpinner","dLoadingXs","dTooltip","dTooltipTop","FormContext","createContext","TYPE_VALIDATORS","useFormContext","context","useContext","FormRoot","externalForm","onFinish","onFinishFailed","initialValues","layout","labelWidth","size","disabled","children","className","noValidate","props","componentSize","useConfig","effectiveSize","internalForm","useForm","form","handleSubmit","e","errors","errorFields","flattenErrors","obj","prefix","key","fullKey","value","handleReset","jsx","FormItem","name","label","floatingLabel","help","required","rules","valuePropName","inline","tooltip","extra","hasFeedback","dependencies","validateTrigger","initialValue","hidden","addonBefore","addonAfter","listName","formDisabled","inputId","useId","errorId","fieldName","useEffect","watchedDeps","useWatch","formRef","useRef","prevDepsRef","currentDeps","error","path","keys","errorMessage","rulesArray","validationRules","patternValidators","customValidators","rule","minValue","minMessage","maxValue","maxMessage","patternValue","patternMessage","pattern","message","validator","result","triggers","shouldValidateOnChange","shouldValidateOnBlur","FeedbackIcon","hasError","isValidating","TooltipIcon","Controller","field","fieldState","onChange","onBlur","ref","childProps","eventOrValue","isValidElement","enhancedChild","cloneElement","isHorizontal","isInline","floatingSizeClasses","renderInputElement","inputWithFeedback","jsxs","floatingClasses","renderWithAddons","input","addonClasses","FormList","fields","append","remove","move","useFieldArray","fieldsWithName","index","useFormInstance","formInstance","enhancedInstance","values","FormErrorList","allErrors","filteredErrors","Form"],"mappings":";;;;AAKA,MAAMA,KAAS,SACTC,KAAW,YACXC,KAAW,YACXC,KAAW,YACXC,KAAW,YACXC,KAAW,YACXC,KAAiB,kBACjBC,KAAW,WACXC,KAAkB,mBAClBC,KAAa,cACbC,KAAW,WACXC,KAAc,eAWdC,IAAcC,GAA4C,MAAS,GAGnEC,IAAkB;AAAA,EACtB,OAAO;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAAA,EAEX,KAAK;AAAA,IACH,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAAA,EAEX,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAEb;AA0EA,SAASC,IAAiB;AACxB,QAAMC,IAAUC,GAAWL,CAAW;AACtC,MAAI,CAACI;AACH,UAAM,IAAI,MAAM,mDAAmD;AAErE,SAAOA;AACT;AAEA,SAASE,GAAyD;AAAA,EAChE,MAAMC;AAAA,EACN,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,YAAAC,IAAa;AAAA,EACb,MAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,YAAAC,IAAa;AAAA,EACb,GAAGC;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D,IAAoD,CAAA;AAE1D,eAAWtD,KAAOF,GAAK;AACrB,YAAMG,IAAUF,IAAS,GAAGA,CAAM,IAAIC,CAAG,KAAKA,GACxCE,IAAQJ,EAAIE,CAAG;AAErB,MAAIE,GAAO,UACToD,EAAO,KAAK,EAAE,OAAOrD,GAAS,SAASC,EAAM,SAAmB,IACvD,OAAOA,KAAU,YAAYA,MAAU,QAChDoD,EAAO,KAAK,GAAGzD,EAAcK,GAAOD,CAAO,CAAC;AAAA,IAEhD;AAEA,WAAOqD;AAAA,EACT,GAEM0C,IAAYnG,EAAcF,CAAM,GAChCsG,IAAiBb,IACnBY,EAAU,OAAO,CAAAtG,MAAK0F,EAAO,SAAS1F,EAAE,KAAK,CAAC,IAC9CsG;AAEJ,SAAIC,EAAe,WAAW,IACrB,yBAIN,MAAA,EAAG,WAAW,gCAAgCjH,CAAS,IAAI,MAAK,SAC9D,UAAAiH,EAAe,IAAI,CAAC7D,GAAOsD,MAC1B,gBAAAZ,EAAC,MAAA,EAAmC,WAAU,0BAC5C,UAAA;AAAA,IAAA,gBAAA1E,EAAC,SAAI,WAAU,gCAA+B,MAAK,QAAO,SAAQ,aAAY,QAAO,gBACnF,4BAAC,QAAA,EAAK,eAAc,SAAQ,gBAAe,SAAQ,aAAa,GAAG,GAAE,qDAAoD,EAAA,CAC3H;AAAA,IACA,gBAAAA,EAAC,QAAA,EAAM,UAAAgC,EAAM,QAAA,CAAQ;AAAA,EAAA,KAJd,GAAGA,EAAM,KAAK,IAAIsD,CAAK,EAKhC,CACD,GACH;AAEJ;AAEO,MAAMQ,KAAO,OAAO,OAAO5H,IAAU;AAAA,EAC1C,MAAM+B;AAAA,EACN,MAAM8E;AAAA,EACN,WAAWY;AAAA,EACX,SAASJ;AACX,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Form.js","sources":["../../src/components/Form.tsx"],"sourcesContent":["import React, { createContext, useContext, cloneElement, isValidElement, useId, useEffect, useRef } from 'react'\nimport { useForm, UseFormReturn, FieldValues, SubmitHandler, UseFormProps, Controller, useFieldArray, FieldArrayPath, FieldArray, useWatch } from 'react-hook-form'\nimport { useConfig } from './ConfigProvider'\n\n// DaisyUI classes\nconst dInput = 'input'\nconst dInputXs = 'input-xs'\nconst dInputSm = 'input-sm'\nconst dInputMd = 'input-md'\nconst dInputLg = 'input-lg'\nconst dInputXl = 'input-xl'\nconst dFloatingLabel = 'floating-label'\nconst dLoading = 'loading'\nconst dLoadingSpinner = 'loading-spinner'\nconst dLoadingXs = 'loading-xs'\nconst dTooltip = 'tooltip'\nconst dTooltipTop = 'tooltip-top'\n\ninterface FormContextValue {\n form: UseFormReturn<any>\n layout?: 'vertical' | 'horizontal' | 'inline'\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n labelWidth?: number\n listName?: string\n disabled?: boolean\n}\n\nconst FormContext = createContext<FormContextValue | undefined>(undefined)\n\n// Built-in type validators\nconst TYPE_VALIDATORS = {\n email: {\n value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}$/i,\n message: 'Please enter a valid email address',\n },\n url: {\n value: /^https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)$/,\n message: 'Please enter a valid URL',\n },\n number: {\n value: /^-?\\d+(\\.\\d+)?$/,\n message: 'Please enter a valid number',\n },\n}\n\nexport interface FormProps<TFieldValues extends FieldValues = FieldValues>\n extends Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onSubmit'> {\n form?: UseFormReturn<TFieldValues>\n onFinish?: SubmitHandler<TFieldValues>\n /** Called when form validation fails */\n onFinishFailed?: (errorInfo: { values: TFieldValues; errorFields: Array<{ name: string; errors: string[] }> }) => void\n initialValues?: UseFormProps<TFieldValues>['defaultValues']\n layout?: 'vertical' | 'horizontal' | 'inline'\n /** Label width in pixels for horizontal layout (default: 80) */\n labelWidth?: number\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /** Disable all form fields */\n disabled?: boolean\n children: React.ReactNode\n /** Test ID for the form element */\n 'data-testid'?: string\n}\n\nexport interface FormRule {\n required?: boolean | string\n type?: 'email' | 'url' | 'number'\n min?: number | { value: number; message: string }\n max?: number | { value: number; message: string }\n pattern?: RegExp | { value: RegExp; message: string }\n message?: string\n validate?: (value: any) => boolean | string | Promise<boolean | string>\n}\n\nexport type ValidateTrigger = 'onChange' | 'onBlur' | 'onSubmit' | ('onChange' | 'onBlur' | 'onSubmit')[]\n\nexport interface FormItemProps {\n name?: string | string[]\n label?: string\n /** Floating label text (alternative to label, uses DaisyUI floating-label) */\n floatingLabel?: string\n help?: string\n required?: boolean\n rules?: FormRule | FormRule[]\n valuePropName?: string\n inline?: boolean\n className?: string\n children: React.ReactElement\n /** Tooltip text to show next to label */\n tooltip?: string\n /** Additional content below the form control */\n extra?: React.ReactNode\n /** Show validation feedback icon */\n hasFeedback?: boolean\n /** Field names that this field depends on for validation */\n dependencies?: string[]\n /** When to trigger validation */\n validateTrigger?: ValidateTrigger\n /** Initial value for this field (overrides Form's initialValues) */\n initialValue?: any\n /** Hide this field (still validates and submits) */\n hidden?: boolean\n /** Text/element before input (outside, using DaisyUI label) */\n addonBefore?: React.ReactNode\n /** Text/element after input (outside, using DaisyUI label) */\n addonAfter?: React.ReactNode\n /** Test ID for the form item (used as prefix for child elements) */\n 'data-testid'?: string\n}\n\nexport interface FormListProps<TFieldValues extends FieldValues = FieldValues> {\n name: FieldArrayPath<TFieldValues>\n children: (\n fields: FieldArray<TFieldValues>[],\n operations: {\n add: (value?: any) => void\n remove: (index: number) => void\n move: (from: number, to: number) => void\n }\n ) => React.ReactNode\n}\n\nfunction useFormContext() {\n const context = useContext(FormContext)\n if (!context) {\n throw new Error('Form compound components must be used within Form')\n }\n return context\n}\n\nfunction FormRoot<TFieldValues extends FieldValues = FieldValues>({\n form: externalForm,\n onFinish,\n onFinishFailed,\n initialValues,\n layout = 'vertical',\n labelWidth = 60,\n size,\n disabled = false,\n children,\n className = '',\n noValidate = true,\n ...props\n}: FormProps<TFieldValues>) {\n const { componentSize } = useConfig()\n const effectiveSize = size ?? componentSize ?? 'md'\n\n const internalForm = useForm<TFieldValues>({\n defaultValues: initialValues,\n })\n\n const form = externalForm || internalForm\n\n const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault()\n\n // Trigger validation\n const isValid = await form.trigger()\n\n if (isValid) {\n if (onFinish) {\n onFinish(form.getValues())\n }\n } else {\n if (onFinishFailed) {\n const errors = form.formState.errors\n const errorFields: Array<{ name: string; errors: string[] }> = []\n\n // Flatten errors into errorFields array\n const flattenErrors = (obj: any, prefix = '') => {\n for (const key in obj) {\n const fullKey = prefix ? `${prefix}.${key}` : key\n const value = obj[key]\n if (value?.message) {\n errorFields.push({ name: fullKey, errors: [value.message as string] })\n } else if (typeof value === 'object' && value !== null) {\n flattenErrors(value, fullKey)\n }\n }\n }\n flattenErrors(errors)\n\n onFinishFailed({ values: form.getValues(), errorFields })\n }\n }\n }\n\n const handleReset = (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault()\n form.reset(initialValues as any)\n }\n\n return (\n <FormContext.Provider value={{ form, layout, labelWidth, size: effectiveSize, disabled }}>\n <form onSubmit={handleSubmit} onReset={handleReset} className={className} noValidate={noValidate} {...props}>\n {children}\n </form>\n </FormContext.Provider>\n )\n}\n\nfunction FormItem({\n name,\n label,\n floatingLabel,\n help,\n required = false,\n rules,\n valuePropName = 'value',\n inline = false,\n className = '',\n children,\n tooltip,\n extra,\n hasFeedback = false,\n dependencies,\n validateTrigger = 'onChange',\n initialValue,\n hidden = false,\n addonBefore,\n addonAfter,\n 'data-testid': testId,\n}: FormItemProps) {\n const { form, size, listName, layout, labelWidth, disabled: formDisabled } = useFormContext()\n const inputId = useId()\n const errorId = useId()\n\n if (!name) {\n // Render without form control if no name provided\n return <div className={`${inline ? 'w-auto' : 'w-full'} ${className}`} style={hidden ? { display: 'none' } : undefined}>{children}</div>\n }\n\n // Handle nested field names (for Form.List)\n let fieldName: string\n if (Array.isArray(name)) {\n // If we're inside a Form.List, prepend the list name\n const fullPath = listName ? [listName, ...name] : name\n fieldName = fullPath.join('.')\n } else {\n fieldName = name\n }\n\n // Set initial value if provided\n useEffect(() => {\n if (initialValue !== undefined) {\n const currentValue = form.getValues(fieldName as any)\n if (currentValue === undefined) {\n form.setValue(fieldName as any, initialValue)\n }\n }\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n // Watch dependencies and re-validate when they change\n const watchedDeps = useWatch({\n control: form.control,\n name: dependencies as any,\n disabled: !dependencies || dependencies.length === 0,\n })\n\n // Use refs to avoid infinite loops\n const formRef = useRef(form)\n formRef.current = form\n const prevDepsRef = useRef<string | undefined>(undefined)\n\n useEffect(() => {\n // Skip if no dependencies\n if (!dependencies || dependencies.length === 0) return\n\n // Skip initial render\n if (prevDepsRef.current === undefined) {\n prevDepsRef.current = JSON.stringify(watchedDeps)\n return\n }\n\n // Only trigger if dependency values actually changed\n const currentDeps = JSON.stringify(watchedDeps)\n if (prevDepsRef.current !== currentDeps) {\n prevDepsRef.current = currentDeps\n formRef.current.trigger(fieldName as any)\n }\n }, [watchedDeps, dependencies, fieldName])\n\n // Get error by traversing the error object path\n const getErrorByPath = (path: string) => {\n const keys = path.split('.')\n let error: any = form.formState.errors\n for (const key of keys) {\n if (!error) break\n error = error[key]\n }\n return error\n }\n\n const error = getErrorByPath(fieldName)\n const errorMessage = error?.message as string | undefined\n\n // Normalize rules to array\n const rulesArray: FormRule[] = rules\n ? Array.isArray(rules) ? rules : [rules]\n : []\n\n // Build validation rules\n const validationRules: any = {}\n const patternValidators: Array<{ pattern: RegExp; message: string }> = []\n const customValidators: Array<(value: any) => boolean | string | Promise<boolean | string>> = []\n\n // Handle top-level required prop\n if (required) {\n validationRules.required = 'This field is required'\n }\n\n // Process each rule\n for (const rule of rulesArray) {\n // Required\n if (rule.required) {\n validationRules.required = typeof rule.required === 'string'\n ? rule.required\n : rule.message || 'This field is required'\n }\n\n // Type validator\n if (rule.type && TYPE_VALIDATORS[rule.type]) {\n patternValidators.push({\n pattern: TYPE_VALIDATORS[rule.type].value,\n message: rule.message || TYPE_VALIDATORS[rule.type].message,\n })\n }\n\n // Min length\n if (rule.min !== undefined) {\n const minValue = typeof rule.min === 'object' ? rule.min.value : rule.min\n const minMessage = typeof rule.min === 'object'\n ? rule.min.message\n : rule.message || `Minimum length is ${minValue} characters`\n validationRules.minLength = { value: minValue, message: minMessage }\n }\n\n // Max length\n if (rule.max !== undefined) {\n const maxValue = typeof rule.max === 'object' ? rule.max.value : rule.max\n const maxMessage = typeof rule.max === 'object'\n ? rule.max.message\n : rule.message || `Maximum length is ${maxValue} characters`\n validationRules.maxLength = { value: maxValue, message: maxMessage }\n }\n\n // Pattern - collect all patterns\n if (rule.pattern) {\n const patternValue = rule.pattern instanceof RegExp ? rule.pattern : rule.pattern.value\n const patternMessage = rule.pattern instanceof RegExp\n ? rule.message || 'Invalid format'\n : rule.pattern.message\n patternValidators.push({ pattern: patternValue, message: patternMessage })\n }\n\n // Custom validator\n if (rule.validate) {\n customValidators.push(rule.validate)\n }\n }\n\n // Combine all pattern and custom validators into a single validate function\n if (patternValidators.length > 0 || customValidators.length > 0) {\n validationRules.validate = async (value: any) => {\n // Skip validation if empty (required rule handles that)\n if (!value && !validationRules.required) return true\n\n // Check all patterns\n for (const { pattern, message } of patternValidators) {\n if (value && !pattern.test(value)) {\n return message\n }\n }\n\n // Run all custom validators\n for (const validator of customValidators) {\n const result = await validator(value)\n if (result !== true) {\n return result\n }\n }\n\n return true\n }\n }\n\n // Normalize validateTrigger to array\n const triggers = Array.isArray(validateTrigger) ? validateTrigger : [validateTrigger]\n const shouldValidateOnChange = triggers.includes('onChange')\n const shouldValidateOnBlur = triggers.includes('onBlur')\n\n // Feedback icons\n const FeedbackIcon = ({ hasError, isValidating }: { hasError: boolean; isValidating: boolean }) => {\n if (isValidating) {\n return (\n <span className={`${dLoading} ${dLoadingSpinner} ${dLoadingXs} text-base-content/50`} />\n )\n }\n if (hasError) {\n return (\n <svg className=\"w-4 h-4 text-error\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n )\n }\n return (\n <svg className=\"w-4 h-4 text-success\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M5 13l4 4L19 7\" />\n </svg>\n )\n }\n\n // Tooltip icon\n const TooltipIcon = () => (\n <div className={`${dTooltip} ${dTooltipTop} ml-1`} data-tip={tooltip}>\n <svg className=\"w-4 h-4 text-base-content/50 cursor-help\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <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\" />\n </svg>\n </div>\n )\n\n return (\n <Controller\n name={fieldName}\n control={form.control}\n rules={validationRules}\n render={({ field, fieldState }) => {\n const { value, onChange, onBlur, ref } = field\n const isValidating = fieldState.isTouched && form.formState.isValidating\n\n // Clone the child element and inject form control props\n const childProps: any = {\n id: inputId,\n ref,\n 'aria-invalid': error ? true : undefined,\n 'aria-describedby': error ? errorId : undefined,\n 'data-testid': testId ? `${testId}-input` : undefined,\n }\n\n // Handle onBlur based on validateTrigger\n childProps.onBlur = () => {\n onBlur()\n if (shouldValidateOnBlur) {\n form.trigger(fieldName as any)\n }\n }\n\n // Handle different value prop names (e.g., 'checked' for checkboxes)\n if (valuePropName === 'checked') {\n childProps.checked = value\n childProps.onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange(e.target.checked)\n if (shouldValidateOnChange) {\n form.trigger(fieldName as any)\n }\n }\n } else {\n childProps.value = value || ''\n childProps.onChange = (eventOrValue: any) => {\n // Handle components that pass value directly (e.g., Range, Rating)\n // vs components that pass event object (e.g., Input, Select)\n if (eventOrValue && eventOrValue.target !== undefined) {\n onChange(eventOrValue.target.value)\n } else {\n onChange(eventOrValue)\n }\n if (shouldValidateOnChange) {\n form.trigger(fieldName as any)\n }\n }\n }\n\n // Apply size if specified at form level\n if (size && isValidElement(children)) {\n const existingProps = children.props as any\n if (!existingProps.size) {\n childProps.size = size\n }\n }\n\n // Apply error styling and accessibility\n if (error) {\n childProps.color = 'error'\n childProps['aria-invalid'] = true\n }\n\n // Apply form-level disabled state\n if (formDisabled) {\n childProps.disabled = true\n }\n\n // When wrapped with addons, the child input should be unstyled (the wrapper has the styling)\n const hasAddons = addonBefore || addonAfter\n if (hasAddons) {\n childProps.unstyled = true\n }\n\n const enhancedChild = isValidElement(children)\n ? cloneElement(children as React.ReactElement<any>, childProps)\n : children\n\n const isHorizontal = layout === 'horizontal'\n const isInline = layout === 'inline'\n\n // Size class for floating label\n const floatingSizeClasses: Record<string, string> = {\n xs: dInputXs,\n sm: dInputSm,\n md: dInputMd,\n lg: dInputLg,\n xl: dInputXl,\n }\n\n // Build the input element with optional floating label wrapper\n const renderInputElement = () => {\n const inputWithFeedback = (\n <div className={`${isHorizontal ? 'flex-1' : ''} ${hasFeedback ? 'relative' : ''}`}>\n {enhancedChild}\n {hasFeedback && fieldState.isTouched && (\n <span className=\"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none\">\n <FeedbackIcon hasError={!!error} isValidating={isValidating} />\n </span>\n )}\n </div>\n )\n\n // Floating label variant\n if (floatingLabel) {\n const floatingClasses = [\n dFloatingLabel,\n size && floatingSizeClasses[size],\n ].filter(Boolean).join(' ')\n\n return (\n <label className={floatingClasses}>\n {enhancedChild}\n <span>{floatingLabel}{required && <span className=\"text-error ml-1\">*</span>}</span>\n </label>\n )\n }\n\n return inputWithFeedback\n }\n\n // Wrap with external addons if specified using DaisyUI input wrapper pattern\n const renderWithAddons = (input: React.ReactNode) => {\n if (!addonBefore && !addonAfter) return input\n\n const addonClasses = [\n dInput,\n 'flex',\n 'items-center',\n 'gap-2',\n size && floatingSizeClasses[size],\n ].filter(Boolean).join(' ')\n\n return (\n <label className={addonClasses}>\n {addonBefore && <span className=\"text-base-content/70\">{addonBefore}</span>}\n {input}\n {addonAfter && <span className=\"text-base-content/70\">{addonAfter}</span>}\n </label>\n )\n }\n\n return (\n <div className={`${inline ? 'w-auto' : 'w-full'} ${isHorizontal ? 'mb-4' : ''} ${isInline ? 'inline-flex mr-4' : ''} ${className}`} style={hidden ? { display: 'none' } : undefined} data-testid={testId}>\n <div className={isHorizontal ? 'flex items-center gap-4' : ''}>\n {label && !floatingLabel && (\n <label\n htmlFor={inputId}\n className={`block text-sm font-medium ${isHorizontal ? 'flex-shrink-0 text-right' : ''} ${!isHorizontal && !isInline ? 'mb-1' : ''}`}\n style={isHorizontal ? { width: labelWidth } : undefined}\n data-testid={testId ? `${testId}-label` : undefined}\n >\n <span className=\"flex items-center\">\n {label}\n {required && <span className=\"text-error ml-1\">*</span>}\n {tooltip && <TooltipIcon />}\n </span>\n </label>\n )}\n {renderWithAddons(renderInputElement())}\n </div>\n {!isHorizontal && !inline && (\n <p id={errorId} className={`validator-hint ${errorMessage ? '!visible text-error' : ''} min-h-[1.25rem]`} role={errorMessage ? 'alert' : undefined} data-testid={testId ? `${testId}-error` : undefined}>\n {errorMessage || (help && <span className=\"text-base-content/70\">{help}</span>) || '\\u00A0'}\n </p>\n )}\n {isHorizontal && (errorMessage || help) && (\n <p id={errorId} className={`validator-hint ${errorMessage ? '!visible text-error' : ''} min-h-[1.25rem]`} role={errorMessage ? 'alert' : undefined} data-testid={testId ? `${testId}-error` : undefined}>\n {errorMessage || (help && <span className=\"text-base-content/70\">{help}</span>)}\n </p>\n )}\n {extra && (\n <div className=\"text-sm text-base-content/60 mt-1\" data-testid={testId ? `${testId}-extra` : undefined}>{extra}</div>\n )}\n </div>\n )\n }}\n />\n )\n}\n\nfunction FormList<TFieldValues extends FieldValues = FieldValues>({\n name,\n children,\n}: FormListProps<TFieldValues>) {\n const { form, layout, size, disabled } = useFormContext()\n\n const { fields, append, remove, move } = useFieldArray({\n control: form.control,\n name,\n })\n\n // Add name (index) to each field for proper path construction\n const fieldsWithName = fields.map((field, index) => ({\n ...field,\n name: index,\n }))\n\n return (\n <FormContext.Provider value={{ form, layout, size, listName: name as string, disabled }}>\n {children(fieldsWithName as any, {\n add: append,\n remove,\n move,\n })}\n </FormContext.Provider>\n )\n}\n\n// Enhanced hook to expose full form API\nexport function useFormInstance<TFieldValues extends FieldValues = FieldValues>() {\n const formInstance = useForm<TFieldValues>()\n\n // Add convenience methods to the instance\n const enhancedInstance = formInstance as typeof formInstance & {\n setFieldValue: typeof formInstance.setValue\n getFieldValue: (name: any) => any\n getFieldsValue: typeof formInstance.getValues\n setFieldsValue: (values: any) => void\n validateFields: typeof formInstance.trigger\n resetFields: typeof formInstance.reset\n isFieldTouched: (name: string) => boolean\n getFieldError: (name: string) => string | undefined\n }\n\n // Add the alias methods\n enhancedInstance.setFieldValue = formInstance.setValue\n enhancedInstance.getFieldValue = (name: any) => formInstance.getValues(name)\n enhancedInstance.getFieldsValue = formInstance.getValues\n enhancedInstance.setFieldsValue = (values: any) => {\n Object.keys(values).forEach((key) => {\n formInstance.setValue(key as any, values[key])\n })\n }\n enhancedInstance.validateFields = formInstance.trigger\n enhancedInstance.resetFields = formInstance.reset\n enhancedInstance.isFieldTouched = (name: string) => {\n const touched = formInstance.formState.touchedFields as any\n return !!touched[name]\n }\n enhancedInstance.getFieldError = (name: string) => {\n const errors = formInstance.formState.errors as any\n return errors[name]?.message as string | undefined\n }\n\n return enhancedInstance\n}\n\nexport interface FormErrorListProps {\n /** Specific field names to show errors for (shows all errors if not specified) */\n fields?: string[]\n /** Custom className */\n className?: string\n /** Test ID for the error list */\n 'data-testid'?: string\n}\n\nfunction FormErrorList({ fields, className = '', 'data-testid': testId }: FormErrorListProps) {\n const { form } = useFormContext()\n const { errors } = form.formState\n\n // Flatten nested errors into a list\n const flattenErrors = (obj: any, prefix = ''): Array<{ field: string; message: string }> => {\n const result: Array<{ field: string; message: string }> = []\n\n for (const key in obj) {\n const fullKey = prefix ? `${prefix}.${key}` : key\n const value = obj[key]\n\n if (value?.message) {\n result.push({ field: fullKey, message: value.message as string })\n } else if (typeof value === 'object' && value !== null) {\n result.push(...flattenErrors(value, fullKey))\n }\n }\n\n return result\n }\n\n const allErrors = flattenErrors(errors)\n const filteredErrors = fields\n ? allErrors.filter(e => fields.includes(e.field))\n : allErrors\n\n if (filteredErrors.length === 0) {\n return null\n }\n\n return (\n <ul className={`text-error text-sm space-y-1 ${className}`} role=\"alert\" data-testid={testId}>\n {filteredErrors.map((error, index) => (\n <li key={`${error.field}-${index}`} className=\"flex items-start gap-2\" data-testid={testId ? `${testId}-${error.field}` : undefined}>\n <svg className=\"w-4 h-4 mt-0.5 flex-shrink-0\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z\" />\n </svg>\n <span>{error.message}</span>\n </li>\n ))}\n </ul>\n )\n}\n\nexport const Form = Object.assign(FormRoot, {\n Item: FormItem,\n List: FormList,\n ErrorList: FormErrorList,\n useForm: useFormInstance,\n})\n\nexport type { UseFormReturn as FormInstance }\n"],"names":["dInput","dInputXs","dInputSm","dInputMd","dInputLg","dInputXl","dFloatingLabel","dLoading","dLoadingSpinner","dLoadingXs","dTooltip","dTooltipTop","FormContext","createContext","TYPE_VALIDATORS","useFormContext","context","useContext","FormRoot","externalForm","onFinish","onFinishFailed","initialValues","layout","labelWidth","size","disabled","children","className","noValidate","props","componentSize","useConfig","effectiveSize","internalForm","useForm","form","handleSubmit","e","errors","errorFields","flattenErrors","obj","prefix","key","fullKey","value","handleReset","jsx","FormItem","name","label","floatingLabel","help","required","rules","valuePropName","inline","tooltip","extra","hasFeedback","dependencies","validateTrigger","initialValue","hidden","addonBefore","addonAfter","testId","listName","formDisabled","inputId","useId","errorId","fieldName","useEffect","watchedDeps","useWatch","formRef","useRef","prevDepsRef","currentDeps","error","path","keys","errorMessage","rulesArray","validationRules","patternValidators","customValidators","rule","minValue","minMessage","maxValue","maxMessage","patternValue","patternMessage","pattern","message","validator","result","triggers","shouldValidateOnChange","shouldValidateOnBlur","FeedbackIcon","hasError","isValidating","TooltipIcon","Controller","field","fieldState","onChange","onBlur","ref","childProps","eventOrValue","isValidElement","enhancedChild","cloneElement","isHorizontal","isInline","floatingSizeClasses","renderInputElement","inputWithFeedback","jsxs","floatingClasses","renderWithAddons","input","addonClasses","FormList","fields","append","remove","move","useFieldArray","fieldsWithName","index","useFormInstance","formInstance","enhancedInstance","values","FormErrorList","allErrors","filteredErrors","Form"],"mappings":";;;;AAKA,MAAMA,KAAS,SACTC,KAAW,YACXC,KAAW,YACXC,KAAW,YACXC,KAAW,YACXC,KAAW,YACXC,KAAiB,kBACjBC,KAAW,WACXC,KAAkB,mBAClBC,KAAa,cACbC,KAAW,WACXC,KAAc,eAWdC,IAAcC,GAA4C,MAAS,GAGnEC,IAAkB;AAAA,EACtB,OAAO;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAAA,EAEX,KAAK;AAAA,IACH,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAAA,EAEX,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAEb;AA8EA,SAASC,IAAiB;AACxB,QAAMC,IAAUC,GAAWL,CAAW;AACtC,MAAI,CAACI;AACH,UAAM,IAAI,MAAM,mDAAmD;AAErE,SAAOA;AACT;AAEA,SAASE,GAAyD;AAAA,EAChE,MAAMC;AAAA,EACN,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,YAAAC,IAAa;AAAA,EACb,MAAAC;AA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AG,GAAE,qDAAoD,EAAA,CAC3H;AAAA,IACA,gBAAAA,EAAC,QAAA,EAAM,UAAAiC,EAAM,QAAA,CAAQ;AAAA,EAAA,KAJd,GAAGA,EAAM,KAAK,IAAIsD,CAAK,EAKhC,CACD,GACH;AAEJ;AAEO,MAAMQ,KAAO,OAAO,OAAO7H,IAAU;AAAA,EAC1C,MAAM+B;AAAA,EACN,MAAM+E;AAAA,EACN,WAAWY;AAAA,EACX,SAASJ;AACX,CAAC;"}
|
|
@@ -1,60 +1,61 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { jsx as e, jsxs as C } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as Q, useEffect as j } from "react";
|
|
3
|
+
import k from "qrcode";
|
|
4
|
+
import { useTheme as B } from "../hooks/useTheme.js";
|
|
5
|
+
const L = "loading", $ = "loading-spinner", E = "loading-lg", I = "btn", M = "btn-sm", V = "btn-primary", G = ({
|
|
6
|
+
value: d,
|
|
6
7
|
size: t = 160,
|
|
7
|
-
errorLevel:
|
|
8
|
+
errorLevel: h = "M",
|
|
8
9
|
icon: m,
|
|
9
10
|
iconSize: n = 40,
|
|
10
11
|
type: f = "canvas",
|
|
11
|
-
color:
|
|
12
|
-
bgColor:
|
|
12
|
+
color: y,
|
|
13
|
+
bgColor: R,
|
|
13
14
|
bordered: a = !0,
|
|
14
15
|
status: s = "active",
|
|
15
|
-
onRefresh:
|
|
16
|
-
className:
|
|
16
|
+
onRefresh: v,
|
|
17
|
+
className: w = "",
|
|
17
18
|
...r
|
|
18
19
|
}) => {
|
|
19
|
-
const c =
|
|
20
|
-
|
|
21
|
-
if (s !== "active" || !
|
|
20
|
+
const c = Q(null), { colors: x } = B(), p = y ?? x.foreground, g = R ?? x.background;
|
|
21
|
+
j(() => {
|
|
22
|
+
if (s !== "active" || !d || f !== "canvas") return;
|
|
22
23
|
(async () => {
|
|
23
24
|
if (c.current)
|
|
24
25
|
try {
|
|
25
|
-
if (await
|
|
26
|
+
if (await k.toCanvas(c.current, d, {
|
|
26
27
|
width: t,
|
|
27
28
|
margin: 1,
|
|
28
29
|
color: {
|
|
29
|
-
dark:
|
|
30
|
-
light:
|
|
30
|
+
dark: p,
|
|
31
|
+
light: g
|
|
31
32
|
},
|
|
32
|
-
errorCorrectionLevel:
|
|
33
|
+
errorCorrectionLevel: h
|
|
33
34
|
}), m && c.current) {
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
},
|
|
35
|
+
const l = c.current.getContext("2d");
|
|
36
|
+
if (l) {
|
|
37
|
+
const i = new Image();
|
|
38
|
+
i.crossOrigin = "anonymous", i.onload = () => {
|
|
39
|
+
const b = (t - n) / 2, N = (t - n) / 2;
|
|
40
|
+
l.fillStyle = g, l.fillRect(b - 4, N - 4, n + 8, n + 8), l.drawImage(i, b, N, n, n);
|
|
41
|
+
}, i.src = m;
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
|
-
} catch (
|
|
44
|
-
console.error("QR Code generation error:",
|
|
44
|
+
} catch (u) {
|
|
45
|
+
console.error("QR Code generation error:", u);
|
|
45
46
|
}
|
|
46
47
|
})();
|
|
47
|
-
}, [
|
|
48
|
-
const
|
|
48
|
+
}, [d, t, h, m, n, f, p, g, s]);
|
|
49
|
+
const o = [
|
|
49
50
|
"inline-flex items-center justify-center",
|
|
50
51
|
a && "border border-base-content/20 p-3",
|
|
51
52
|
"bg-base-100",
|
|
52
|
-
|
|
53
|
+
w
|
|
53
54
|
].filter(Boolean).join(" ");
|
|
54
|
-
return s === "loading" ? /* @__PURE__ */ e("div", { className:
|
|
55
|
-
/* @__PURE__ */ e("span", { className: `${
|
|
55
|
+
return s === "loading" ? /* @__PURE__ */ e("div", { className: o, style: { width: t + (a ? 24 : 0), height: t + (a ? 24 : 0) }, "data-state": "loading", ...r, children: /* @__PURE__ */ C("div", { className: "flex flex-col items-center justify-center gap-2", children: [
|
|
56
|
+
/* @__PURE__ */ e("span", { className: `${L} ${$} ${E}` }),
|
|
56
57
|
/* @__PURE__ */ e("span", { className: "text-sm text-base-content/70", children: "Loading..." })
|
|
57
|
-
] }) }) : s === "expired" ? /* @__PURE__ */ e("div", { className:
|
|
58
|
+
] }) }) : s === "expired" ? /* @__PURE__ */ e("div", { className: o, style: { width: t + (a ? 24 : 0), height: t + (a ? 24 : 0) }, "data-state": "expired", ...r, children: /* @__PURE__ */ C("div", { className: "flex flex-col items-center justify-center gap-2", children: [
|
|
58
59
|
/* @__PURE__ */ e("svg", { className: "w-12 h-12 text-base-content/30", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ e(
|
|
59
60
|
"path",
|
|
60
61
|
{
|
|
@@ -64,12 +65,12 @@ const Q = "loading", j = "loading-spinner", F = "loading-lg", L = "btn", $ = "bt
|
|
|
64
65
|
}
|
|
65
66
|
) }),
|
|
66
67
|
/* @__PURE__ */ e("span", { className: "text-sm text-base-content/70", children: "QR Code Expired" }),
|
|
67
|
-
|
|
68
|
-
] }) }) : f === "canvas" ? /* @__PURE__ */ e("div", { className: "inline-block", "data-state": "active", ...r, children: /* @__PURE__ */ e("div", { className:
|
|
68
|
+
v && /* @__PURE__ */ e("button", { className: `${I} ${M} ${V}`, onClick: v, children: "Refresh" })
|
|
69
|
+
] }) }) : f === "canvas" ? /* @__PURE__ */ e("div", { className: "inline-block", "data-state": "active", ...r, children: /* @__PURE__ */ e("div", { className: o, children: /* @__PURE__ */ e("canvas", { ref: c, style: { display: "block" } }) }) }) : /* @__PURE__ */ e("div", { className: "inline-block", "data-state": "active", ...r, children: /* @__PURE__ */ e("div", { className: o, children: /* @__PURE__ */ e("div", { style: { width: t, height: t }, className: "bg-base-content/5", children: /* @__PURE__ */ e("span", { className: "text-xs text-base-content/50", children: "SVG mode placeholder" }) }) }) });
|
|
69
70
|
};
|
|
70
|
-
|
|
71
|
+
G.displayName = "QRCode";
|
|
71
72
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
G as QRCode,
|
|
74
|
+
G as default
|
|
74
75
|
};
|
|
75
76
|
//# sourceMappingURL=QRCode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QRCode.js","sources":["../../src/components/QRCode.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react'\nimport QRCodeLib from 'qrcode'\n\n// DaisyUI classes\nconst dLoading = 'loading'\nconst dLoadingSpinner = 'loading-spinner'\nconst dLoadingLg = 'loading-lg'\nconst dBtn = 'btn'\nconst dBtnSm = 'btn-sm'\nconst dBtnPrimary = 'btn-primary'\n\nexport type QRCodeErrorLevel = 'L' | 'M' | 'Q' | 'H'\nexport type QRCodeType = 'canvas' | 'svg'\nexport type QRCodeStatus = 'active' | 'loading' | 'expired'\n\nexport interface QRCodeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'> {\n value: string\n size?: number\n errorLevel?: QRCodeErrorLevel\n icon?: string\n iconSize?: number\n type?: QRCodeType\n color?: string\n bgColor?: string\n bordered?: boolean\n status?: QRCodeStatus\n onRefresh?: () => void\n}\n\nexport const QRCode: React.FC<QRCodeProps> = ({\n value,\n size = 160,\n errorLevel = 'M',\n icon,\n iconSize = 40,\n type = 'canvas',\n color
|
|
1
|
+
{"version":3,"file":"QRCode.js","sources":["../../src/components/QRCode.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react'\nimport QRCodeLib from 'qrcode'\nimport { useTheme } from '../hooks/useTheme'\n\n// DaisyUI classes\nconst dLoading = 'loading'\nconst dLoadingSpinner = 'loading-spinner'\nconst dLoadingLg = 'loading-lg'\nconst dBtn = 'btn'\nconst dBtnSm = 'btn-sm'\nconst dBtnPrimary = 'btn-primary'\n\nexport type QRCodeErrorLevel = 'L' | 'M' | 'Q' | 'H'\nexport type QRCodeType = 'canvas' | 'svg'\nexport type QRCodeStatus = 'active' | 'loading' | 'expired'\n\nexport interface QRCodeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'> {\n value: string\n size?: number\n errorLevel?: QRCodeErrorLevel\n icon?: string\n iconSize?: number\n type?: QRCodeType\n color?: string\n bgColor?: string\n bordered?: boolean\n status?: QRCodeStatus\n onRefresh?: () => void\n}\n\nexport const QRCode: React.FC<QRCodeProps> = ({\n value,\n size = 160,\n errorLevel = 'M',\n icon,\n iconSize = 40,\n type = 'canvas',\n color,\n bgColor,\n bordered = true,\n status = 'active',\n onRefresh,\n className = '',\n ...rest\n}) => {\n const canvasRef = useRef<HTMLCanvasElement>(null)\n const { colors } = useTheme()\n\n // Theme-aware default colors from DaisyUI CSS variables\n const effectiveColor = color ?? colors.foreground\n const effectiveBgColor = bgColor ?? colors.background\n\n useEffect(() => {\n if (status !== 'active' || !value || type !== 'canvas') return\n\n const generateQRCode = async () => {\n if (!canvasRef.current) return\n\n try {\n await QRCodeLib.toCanvas(canvasRef.current, value, {\n width: size,\n margin: 1,\n color: {\n dark: effectiveColor,\n light: effectiveBgColor,\n },\n errorCorrectionLevel: errorLevel,\n })\n\n if (icon && canvasRef.current) {\n const canvas = canvasRef.current\n const ctx = canvas.getContext('2d')\n if (ctx) {\n const img = new Image()\n img.crossOrigin = 'anonymous'\n img.onload = () => {\n const iconX = (size - iconSize) / 2\n const iconY = (size - iconSize) / 2\n ctx.fillStyle = effectiveBgColor\n ctx.fillRect(iconX - 4, iconY - 4, iconSize + 8, iconSize + 8)\n ctx.drawImage(img, iconX, iconY, iconSize, iconSize)\n }\n img.src = icon\n }\n }\n } catch (error) {\n console.error('QR Code generation error:', error)\n }\n }\n\n generateQRCode()\n }, [value, size, errorLevel, icon, iconSize, type, effectiveColor, effectiveBgColor, status])\n\n // Download functionality can be implemented by consumers\n // by accessing the canvas ref and converting to data URL\n\n const containerClasses = [\n 'inline-flex items-center justify-center',\n bordered && 'border border-base-content/20 p-3',\n 'bg-base-100',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n if (status === 'loading') {\n return (\n <div className={containerClasses} style={{ width: size + (bordered ? 24 : 0), height: size + (bordered ? 24 : 0) }} data-state=\"loading\" {...rest}>\n <div className=\"flex flex-col items-center justify-center gap-2\">\n <span className={`${dLoading} ${dLoadingSpinner} ${dLoadingLg}`}></span>\n <span className=\"text-sm text-base-content/70\">Loading...</span>\n </div>\n </div>\n )\n }\n\n if (status === 'expired') {\n return (\n <div className={containerClasses} style={{ width: size + (bordered ? 24 : 0), height: size + (bordered ? 24 : 0) }} data-state=\"expired\" {...rest}>\n <div className=\"flex flex-col items-center justify-center gap-2\">\n <svg className=\"w-12 h-12 text-base-content/30\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path\n fillRule=\"evenodd\"\n d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z\"\n clipRule=\"evenodd\"\n />\n </svg>\n <span className=\"text-sm text-base-content/70\">QR Code Expired</span>\n {onRefresh && (\n <button className={`${dBtn} ${dBtnSm} ${dBtnPrimary}`} onClick={onRefresh}>\n Refresh\n </button>\n )}\n </div>\n </div>\n )\n }\n\n if (type === 'canvas') {\n return (\n <div className=\"inline-block\" data-state=\"active\" {...rest}>\n <div className={containerClasses}>\n <canvas ref={canvasRef} style={{ display: 'block' }} />\n </div>\n </div>\n )\n }\n\n return (\n <div className=\"inline-block\" data-state=\"active\" {...rest}>\n <div className={containerClasses}>\n <div style={{ width: size, height: size }} className=\"bg-base-content/5\">\n <span className=\"text-xs text-base-content/50\">SVG mode placeholder</span>\n </div>\n </div>\n </div>\n )\n}\n\nQRCode.displayName = 'QRCode'\n\nexport default QRCode\n"],"names":["dLoading","dLoadingSpinner","dLoadingLg","dBtn","dBtnSm","dBtnPrimary","QRCode","value","size","errorLevel","icon","iconSize","type","color","bgColor","bordered","status","onRefresh","className","rest","canvasRef","useRef","colors","useTheme","effectiveColor","effectiveBgColor","useEffect","QRCodeLib","ctx","img","iconX","iconY","error","containerClasses","jsx","jsxs"],"mappings":";;;;AAKA,MAAMA,IAAW,WACXC,IAAkB,mBAClBC,IAAa,cACbC,IAAO,OACPC,IAAS,UACTC,IAAc,eAoBPC,IAAgC,CAAC;AAAA,EAC5C,OAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,YAAAC,IAAa;AAAA,EACb,MAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,QAAAC,IAAS;AAAA,EACT,WAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAYC,EAA0B,IAAI,GAC1C,EAAE,QAAAC,EAAA,IAAWC,EAAA,GAGbC,IAAiBX,KAASS,EAAO,YACjCG,IAAmBX,KAAWQ,EAAO;AAE3C,EAAAI,EAAU,MAAM;AACd,QAAIV,MAAW,YAAY,CAACT,KAASK,MAAS,SAAU;AAqCxD,KAnCuB,YAAY;AACjC,UAAKQ,EAAU;AAEf,YAAI;AAWF,cAVA,MAAMO,EAAU,SAASP,EAAU,SAASb,GAAO;AAAA,YACjD,OAAOC;AAAA,YACP,QAAQ;AAAA,YACR,OAAO;AAAA,cACL,MAAMgB;AAAA,cACN,OAAOC;AAAA,YAAA;AAAA,YAET,sBAAsBhB;AAAA,UAAA,CACvB,GAEGC,KAAQU,EAAU,SAAS;AAE7B,kBAAMQ,IADSR,EAAU,QACN,WAAW,IAAI;AAClC,gBAAIQ,GAAK;AACP,oBAAMC,IAAM,IAAI,MAAA;AAChB,cAAAA,EAAI,cAAc,aAClBA,EAAI,SAAS,MAAM;AACjB,sBAAMC,KAAStB,IAAOG,KAAY,GAC5BoB,KAASvB,IAAOG,KAAY;AAClC,gBAAAiB,EAAI,YAAYH,GAChBG,EAAI,SAASE,IAAQ,GAAGC,IA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,MAAA;AAAA,QACC,UAAS;AAAA,QACT,GAAE;AAAA,QACF,UAAS;AAAA,MAAA;AAAA,IAAA,GAEb;AAAA,IACA,gBAAAA,EAAC,QAAA,EAAK,WAAU,gCAA+B,UAAA,mBAAe;AAAA,IAC7DjB,KACC,gBAAAiB,EAAC,UAAA,EAAO,WAAW,GAAG/B,CAAI,IAAIC,CAAM,IAAIC,CAAW,IAAI,SAASY,GAAW,UAAA,UAAA,CAE3E;AAAA,EAAA,EAAA,CAEJ,EAAA,CACF,IAIAL,MAAS,WAET,gBAAAsB,EAAC,SAAI,WAAU,gBAAe,cAAW,UAAU,GAAGf,GACpD,UAAA,gBAAAe,EAAC,OAAA,EAAI,WAAWD,GACd,UAAA,gBAAAC,EAAC,UAAA,EAAO,KAAKd,GAAW,OAAO,EAAE,SAAS,QAAA,GAAW,EAAA,CACvD,EAAA,CACF,IAKF,gBAAAc,EAAC,OAAA,EAAI,WAAU,gBAAe,cAAW,UAAU,GAAGf,GACpD,UAAA,gBAAAe,EAAC,OAAA,EAAI,WAAWD,GACd,4BAAC,OAAA,EAAI,OAAO,EAAE,OAAOzB,GAAM,QAAQA,EAAA,GAAQ,WAAU,qBACnD,UAAA,gBAAA0B,EAAC,QAAA,EAAK,WAAU,gCAA+B,UAAA,uBAAA,CAAoB,EAAA,CACrE,GACF,GACF;AAEJ;AAEA5B,EAAO,cAAc;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface ThemeColors {
|
|
2
|
+
/** Base background color (--b1 / base-100) */
|
|
3
|
+
background: string;
|
|
4
|
+
/** Base content/text color (--bc / base-content) */
|
|
5
|
+
foreground: string;
|
|
6
|
+
/** Primary color (--p / primary) */
|
|
7
|
+
primary: string;
|
|
8
|
+
/** Primary content color (--pc / primary-content) */
|
|
9
|
+
primaryContent: string;
|
|
10
|
+
}
|
|
11
|
+
export interface UseThemeReturn {
|
|
12
|
+
/** Whether dark mode is active */
|
|
13
|
+
isDark: boolean;
|
|
14
|
+
/** Computed theme colors as hex values */
|
|
15
|
+
colors: ThemeColors;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Hook to detect current theme and get computed colors
|
|
19
|
+
*
|
|
20
|
+
* Checks the `data-theme` attribute on the document root (for DaisyUI themes)
|
|
21
|
+
* and falls back to system preference via `prefers-color-scheme`.
|
|
22
|
+
*
|
|
23
|
+
* Returns both the dark mode state and computed theme colors as hex values,
|
|
24
|
+
* useful for canvas-based components that can't use CSS variables directly.
|
|
25
|
+
*
|
|
26
|
+
* Automatically updates when theme changes.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useTheme(): UseThemeReturn;
|
|
29
|
+
export default useTheme;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useState as m, useEffect as i } from "react";
|
|
2
|
+
function c(t) {
|
|
3
|
+
const r = document.createElement("canvas");
|
|
4
|
+
r.width = r.height = 1;
|
|
5
|
+
const e = r.getContext("2d");
|
|
6
|
+
if (!e) return "#000000";
|
|
7
|
+
e.fillStyle = t, e.fillRect(0, 0, 1, 1);
|
|
8
|
+
const [o, n, a] = e.getImageData(0, 0, 1, 1).data;
|
|
9
|
+
return `#${((1 << 24) + (o << 16) + (n << 8) + a).toString(16).slice(1)}`;
|
|
10
|
+
}
|
|
11
|
+
function u() {
|
|
12
|
+
const t = getComputedStyle(document.documentElement), r = t.getPropertyValue("--b1").trim(), e = t.getPropertyValue("--bc").trim(), o = t.getPropertyValue("--p").trim(), n = t.getPropertyValue("--pc").trim();
|
|
13
|
+
return {
|
|
14
|
+
background: r ? c(`oklch(${r})`) : "#ffffff",
|
|
15
|
+
foreground: e ? c(`oklch(${e})`) : "#000000",
|
|
16
|
+
primary: o ? c(`oklch(${o})`) : "#6366f1",
|
|
17
|
+
primaryContent: n ? c(`oklch(${n})`) : "#ffffff"
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function d() {
|
|
21
|
+
const [t, r] = m({
|
|
22
|
+
isDark: !1,
|
|
23
|
+
colors: {
|
|
24
|
+
background: "#ffffff",
|
|
25
|
+
foreground: "#000000",
|
|
26
|
+
primary: "#6366f1",
|
|
27
|
+
primaryContent: "#ffffff"
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return i(() => {
|
|
31
|
+
const e = () => {
|
|
32
|
+
const s = document.documentElement.getAttribute("data-theme"), f = s === "dark" || !s && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
33
|
+
requestAnimationFrame(() => {
|
|
34
|
+
r({
|
|
35
|
+
isDark: f,
|
|
36
|
+
colors: u()
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
e();
|
|
41
|
+
const o = new MutationObserver(e);
|
|
42
|
+
o.observe(document.documentElement, {
|
|
43
|
+
attributes: !0,
|
|
44
|
+
attributeFilter: ["data-theme", "class"]
|
|
45
|
+
});
|
|
46
|
+
const n = window.matchMedia("(prefers-color-scheme: dark)");
|
|
47
|
+
return n.addEventListener("change", e), () => {
|
|
48
|
+
o.disconnect(), n.removeEventListener("change", e);
|
|
49
|
+
};
|
|
50
|
+
}, []), t;
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
d as default,
|
|
54
|
+
d as useTheme
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=useTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.js","sources":["../../src/hooks/useTheme.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\nexport interface ThemeColors {\n /** Base background color (--b1 / base-100) */\n background: string\n /** Base content/text color (--bc / base-content) */\n foreground: string\n /** Primary color (--p / primary) */\n primary: string\n /** Primary content color (--pc / primary-content) */\n primaryContent: string\n}\n\nexport interface UseThemeReturn {\n /** Whether dark mode is active */\n isDark: boolean\n /** Computed theme colors as hex values */\n colors: ThemeColors\n}\n\n// Convert any CSS color to hex\nfunction colorToHex(color: string): string {\n const canvas = document.createElement('canvas')\n canvas.width = canvas.height = 1\n const ctx = canvas.getContext('2d')\n if (!ctx) return '#000000'\n ctx.fillStyle = color\n ctx.fillRect(0, 0, 1, 1)\n const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data\n return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`\n}\n\nfunction getThemeColors(): ThemeColors {\n const style = getComputedStyle(document.documentElement)\n\n // Get computed colors from CSS custom properties\n const background = style.getPropertyValue('--b1').trim()\n const foreground = style.getPropertyValue('--bc').trim()\n const primary = style.getPropertyValue('--p').trim()\n const primaryContent = style.getPropertyValue('--pc').trim()\n\n // DaisyUI uses oklch, convert to hex for canvas compatibility\n return {\n background: background ? colorToHex(`oklch(${background})`) : '#ffffff',\n foreground: foreground ? colorToHex(`oklch(${foreground})`) : '#000000',\n primary: primary ? colorToHex(`oklch(${primary})`) : '#6366f1',\n primaryContent: primaryContent ? colorToHex(`oklch(${primaryContent})`) : '#ffffff',\n }\n}\n\n/**\n * Hook to detect current theme and get computed colors\n *\n * Checks the `data-theme` attribute on the document root (for DaisyUI themes)\n * and falls back to system preference via `prefers-color-scheme`.\n *\n * Returns both the dark mode state and computed theme colors as hex values,\n * useful for canvas-based components that can't use CSS variables directly.\n *\n * Automatically updates when theme changes.\n */\nexport function useTheme(): UseThemeReturn {\n const [state, setState] = useState<UseThemeReturn>({\n isDark: false,\n colors: {\n background: '#ffffff',\n foreground: '#000000',\n primary: '#6366f1',\n primaryContent: '#ffffff',\n }\n })\n\n useEffect(() => {\n const checkTheme = () => {\n const html = document.documentElement\n const theme = html.getAttribute('data-theme')\n // Check for explicit dark theme or system preference\n const isDark = theme === 'dark' ||\n (!theme && window.matchMedia('(prefers-color-scheme: dark)').matches)\n\n // Small delay to ensure CSS variables are updated\n requestAnimationFrame(() => {\n setState({\n isDark,\n colors: getThemeColors()\n })\n })\n }\n\n checkTheme()\n\n // Watch for theme changes via attribute mutation\n const observer = new MutationObserver(checkTheme)\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['data-theme', 'class']\n })\n\n // Also watch for system preference changes\n const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')\n mediaQuery.addEventListener('change', checkTheme)\n\n return () => {\n observer.disconnect()\n mediaQuery.removeEventListener('change', checkTheme)\n }\n }, [])\n\n return state\n}\n\nexport default useTheme\n"],"names":["colorToHex","color","canvas","ctx","r","g","b","getThemeColors","style","background","foreground","primary","primaryContent","useTheme","state","setState","useState","useEffect","checkTheme","theme","isDark","observer","mediaQuery"],"mappings":";AAqBA,SAASA,EAAWC,GAAuB;AACzC,QAAMC,IAAS,SAAS,cAAc,QAAQ;AAC9C,EAAAA,EAAO,QAAQA,EAAO,SAAS;AAC/B,QAAMC,IAAMD,EAAO,WAAW,IAAI;AAClC,MAAI,CAACC,EAAK,QAAO;AACjB,EAAAA,EAAI,YAAYF,GAChBE,EAAI,SAAS,GAAG,GAAG,GAAG,CAAC;AACvB,QAAM,CAACC,GAAGC,GAAGC,CAAC,IAAIH,EAAI,aAAa,GAAG,GAAG,GAAG,CAAC,EAAE;AAC/C,SAAO,MAAM,KAAK,OAAOC,KAAK,OAAOC,KAAK,KAAKC,GAAG,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AACzE;AAEA,SAASC,IAA8B;AACrC,QAAMC,IAAQ,iBAAiB,SAAS,eAAe,GAGjDC,IAAaD,EAAM,iBAAiB,MAAM,EAAE,KAAA,GAC5CE,IAAaF,EAAM,iBAAiB,MAAM,EAAE,KAAA,GAC5CG,IAAUH,EAAM,iBAAiB,KAAK,EAAE,KAAA,GACxCI,IAAiBJ,EAAM,iBAAiB,MAAM,EAAE,KAAA;AAGtD,SAAO;AAAA,IACL,YAAYC,IAAaT,EAAW,SAASS,CAAU,GAAG,IAAI;AAAA,IAC9D,YAAYC,IAAaV,EAAW,SAASU,CAAU,GAAG,IAAI;AAAA,IAC9D,SAASC,IAAUX,EAAW,SAASW,CAAO,GAAG,IAAI;AAAA,IACrD,gBAAgBC,IAAiBZ,EAAW,SAASY,CAAc,GAAG,IAAI;AAAA,EAAA;AAE9E;AAaO,SAASC,IAA2B;AACzC,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAAyB;AAAA,IACjD,QAAQ;AAAA,IACR,QAAQ;AAAA,MACN,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,gBAAgB;AAAA,IAAA;AAAA,EAClB,CACD;AAED,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAa,MAAM;AAEvB,YAAMC,IADO,SAAS,gBACH,aAAa,YAAY,GAEtCC,IAASD,MAAU,UACtB,CAACA,KAAS,OAAO,WAAW,8BAA8B,EAAE;AAG/D,4BAAsB,MAAM;AAC1B,QAAAJ,EAAS;AAAA,UACP,QAAAK;AAAA,UACA,QAAQb,EAAA;AAAA,QAAe,CACxB;AAAA,MACH,CAAC;AAAA,IACH;AAEA,IAAAW,EAAA;AAGA,UAAMG,IAAW,IAAI,iBAAiBH,CAAU;AAChD,IAAAG,EAAS,QAAQ,SAAS,iBAAiB;AAAA,MACzC,YAAY;AAAA,MACZ,iBAAiB,CAAC,cAAc,OAAO;AAAA,IAAA,CACxC;AAGD,UAAMC,IAAa,OAAO,WAAW,8BAA8B;AACnE,WAAAA,EAAW,iBAAiB,UAAUJ,CAAU,GAEzC,MAAM;AACX,MAAAG,EAAS,WAAA,GACTC,EAAW,oBAAoB,UAAUJ,CAAU;AAAA,IACrD;AAAA,EACF,GAAG,CAAA,CAAE,GAEEJ;AACT;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -214,3 +214,5 @@ export { useKeyPress, useKeyPressCallback } from './hooks/useKeyPress';
|
|
|
214
214
|
export type { UseKeyPressOptions } from './hooks/useKeyPress';
|
|
215
215
|
export { useWindowSize } from './hooks/useWindowSize';
|
|
216
216
|
export type { WindowSize } from './hooks/useWindowSize';
|
|
217
|
+
export { useTheme } from './hooks/useTheme';
|
|
218
|
+
export type { UseThemeReturn, ThemeColors } from './hooks/useTheme';
|
package/dist/index.js
CHANGED
|
@@ -2,14 +2,14 @@ import { Affix as e } from "./components/Affix.js";
|
|
|
2
2
|
import { Anchor as p } from "./components/Anchor.js";
|
|
3
3
|
import { Alert as m } from "./components/Alert.js";
|
|
4
4
|
import { Autocomplete as a } from "./components/Autocomplete.js";
|
|
5
|
-
import { Avatar as
|
|
5
|
+
import { Avatar as n, AvatarGroup as i } from "./components/Avatar.js";
|
|
6
6
|
import { Badge as u } from "./components/Badge.js";
|
|
7
7
|
import { Breadcrumb as C } from "./components/Breadcrumb.js";
|
|
8
8
|
import { Button as g } from "./components/Button.js";
|
|
9
9
|
import { IconSizeContext as S } from "./contexts/IconSizeContext.js";
|
|
10
10
|
import { CopyButton as k } from "./components/CopyButton.js";
|
|
11
11
|
import { Checkbox as b } from "./components/Checkbox.js";
|
|
12
|
-
import { Chat as
|
|
12
|
+
import { Chat as v } from "./components/Chat.js";
|
|
13
13
|
import { ColorPicker as w } from "./components/ColorPicker.js";
|
|
14
14
|
import { Card as B } from "./components/Card.js";
|
|
15
15
|
import { Carousel as M } from "./components/Carousel.js";
|
|
@@ -26,15 +26,15 @@ import { WeekCalendar as ro } from "./components/WeekCalendar.js";
|
|
|
26
26
|
import { Descriptions as to } from "./components/Descriptions.js";
|
|
27
27
|
import { Diff as fo } from "./components/Diff.js";
|
|
28
28
|
import { Dock as xo } from "./components/Dock.js";
|
|
29
|
-
import { Divider as
|
|
29
|
+
import { Divider as so } from "./components/Divider.js";
|
|
30
30
|
import { Drawer as io } from "./components/Drawer.js";
|
|
31
31
|
import { ResponsiveDrawer as uo } from "./components/ResponsiveDrawer.js";
|
|
32
32
|
import { Fieldset as co } from "./components/Fieldset.js";
|
|
33
33
|
import { FileInput as To } from "./components/FileInput.js";
|
|
34
34
|
import { Filter as Po } from "./components/Filter.js";
|
|
35
35
|
import { Flex as Ro } from "./components/Flex.js";
|
|
36
|
-
import { FloatButton as
|
|
37
|
-
import { Footer as
|
|
36
|
+
import { FloatButton as ho } from "./components/FloatButton.js";
|
|
37
|
+
import { Footer as Do } from "./components/Footer.js";
|
|
38
38
|
import { Form as yo, useFormInstance as Bo } from "./components/Form.js";
|
|
39
39
|
import { Col as Mo, Grid as Ao, Row as Io } from "./components/Grid.js";
|
|
40
40
|
import { Hero as Go } from "./components/Hero.js";
|
|
@@ -51,15 +51,15 @@ import { List as er } from "./components/List.js";
|
|
|
51
51
|
import { Loading as pr } from "./components/Loading.js";
|
|
52
52
|
import { Mask as mr } from "./components/Mask.js";
|
|
53
53
|
import { Masonry as ar } from "./components/Masonry.js";
|
|
54
|
-
import { Mention as
|
|
54
|
+
import { Mention as nr } from "./components/Mention.js";
|
|
55
55
|
import { Menu as lr } from "./components/Menu.js";
|
|
56
56
|
import { Browser as dr } from "./components/Browser.js";
|
|
57
57
|
import { Code as cr } from "./components/Code.js";
|
|
58
58
|
import { Phone as Tr } from "./components/Phone.js";
|
|
59
59
|
import { Window as Pr } from "./components/Window.js";
|
|
60
60
|
import { Modal as Rr } from "./components/Modal.js";
|
|
61
|
-
import { Navbar as
|
|
62
|
-
import { notification as
|
|
61
|
+
import { Navbar as hr } from "./components/Navbar.js";
|
|
62
|
+
import { notification as Dr } from "./components/Notification.js";
|
|
63
63
|
import { MessageManager as yr, message as Br } from "./components/Message.js";
|
|
64
64
|
import { OTPInput as Mr } from "./components/OTPInput.js";
|
|
65
65
|
import { Pagination as Ir } from "./components/Pagination.js";
|
|
@@ -77,14 +77,14 @@ import { Skeleton as re } from "./components/Skeleton.js";
|
|
|
77
77
|
import { Space as te } from "./components/Space.js";
|
|
78
78
|
import { Splitter as fe } from "./components/Splitter.js";
|
|
79
79
|
import { Stats as xe } from "./components/Stat.js";
|
|
80
|
-
import { Status as
|
|
80
|
+
import { Status as se } from "./components/Status.js";
|
|
81
81
|
import { Steps as ie } from "./components/Steps.js";
|
|
82
82
|
import { Table as ue } from "./components/Table.js";
|
|
83
83
|
import { Tabs as Ce } from "./components/Tabs.js";
|
|
84
84
|
import { Textarea as ge } from "./components/Textarea.js";
|
|
85
85
|
import { TextRotate as Se } from "./components/TextRotate.js";
|
|
86
86
|
import { CheckableTag as ke, Tag as Re, TagLiveRegion as be } from "./components/Tag.js";
|
|
87
|
-
import { ThemeController as
|
|
87
|
+
import { ThemeController as ve } from "./components/ThemeController.js";
|
|
88
88
|
import { TimePicker as we } from "./components/TimePicker.js";
|
|
89
89
|
import { Timeline as Be } from "./components/Timeline.js";
|
|
90
90
|
import { Toggle as Me } from "./components/Toggle.js";
|
|
@@ -102,27 +102,28 @@ import { useDisclosure as rt } from "./hooks/useDisclosure.js";
|
|
|
102
102
|
import { useClipboard as tt } from "./hooks/useClipboard.js";
|
|
103
103
|
import { useLocalStorage as ft } from "./hooks/useLocalStorage.js";
|
|
104
104
|
import { useDebounce as xt } from "./hooks/useDebounce.js";
|
|
105
|
-
import { useClickOutside as
|
|
105
|
+
import { useClickOutside as st } from "./hooks/useClickOutside.js";
|
|
106
106
|
import { usePrevious as it } from "./hooks/usePrevious.js";
|
|
107
107
|
import { useHover as ut } from "./hooks/useHover.js";
|
|
108
108
|
import { useKeyPress as Ct, useKeyPressCallback as ct } from "./hooks/useKeyPress.js";
|
|
109
109
|
import { useWindowSize as Tt } from "./hooks/useWindowSize.js";
|
|
110
|
-
import {
|
|
111
|
-
import { default as Rt } from "./locale/en-
|
|
112
|
-
import { default as
|
|
113
|
-
import { default as
|
|
114
|
-
import { default as yt } from "./locale/
|
|
115
|
-
import { default as Ft } from "./locale/
|
|
116
|
-
import { default as At } from "./locale/
|
|
117
|
-
import { default as Lt } from "./locale/
|
|
118
|
-
import { default as Ht } from "./locale/
|
|
119
|
-
import { default as Wt } from "./locale/
|
|
110
|
+
import { useTheme as Pt } from "./hooks/useTheme.js";
|
|
111
|
+
import { default as Rt } from "./locale/en-US.js";
|
|
112
|
+
import { default as ht } from "./locale/en-GB.js";
|
|
113
|
+
import { default as Dt } from "./locale/en-CA.js";
|
|
114
|
+
import { default as yt } from "./locale/zh-CN.js";
|
|
115
|
+
import { default as Ft } from "./locale/es-ES.js";
|
|
116
|
+
import { default as At } from "./locale/ja-JP.js";
|
|
117
|
+
import { default as Lt } from "./locale/pt-BR.js";
|
|
118
|
+
import { default as Ht } from "./locale/de-DE.js";
|
|
119
|
+
import { default as Wt } from "./locale/fr-FR.js";
|
|
120
|
+
import { default as Et } from "./locale/ko-KR.js";
|
|
120
121
|
export {
|
|
121
122
|
e as Affix,
|
|
122
123
|
m as Alert,
|
|
123
124
|
p as Anchor,
|
|
124
125
|
a as Autocomplete,
|
|
125
|
-
|
|
126
|
+
n as Avatar,
|
|
126
127
|
i as AvatarGroup,
|
|
127
128
|
u as Badge,
|
|
128
129
|
C as Breadcrumb,
|
|
@@ -131,7 +132,7 @@ export {
|
|
|
131
132
|
B as Card,
|
|
132
133
|
M as Carousel,
|
|
133
134
|
I as Cascader,
|
|
134
|
-
|
|
135
|
+
v as Chat,
|
|
135
136
|
ke as CheckableTag,
|
|
136
137
|
b as Checkbox,
|
|
137
138
|
cr as Code,
|
|
@@ -148,7 +149,7 @@ export {
|
|
|
148
149
|
Z as DatePicker,
|
|
149
150
|
to as Descriptions,
|
|
150
151
|
fo as Diff,
|
|
151
|
-
|
|
152
|
+
so as Divider,
|
|
152
153
|
xo as Dock,
|
|
153
154
|
io as Drawer,
|
|
154
155
|
No as Dropdown,
|
|
@@ -157,8 +158,8 @@ export {
|
|
|
157
158
|
To as FileInput,
|
|
158
159
|
Po as Filter,
|
|
159
160
|
Ro as Flex,
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
ho as FloatButton,
|
|
162
|
+
Do as Footer,
|
|
162
163
|
yo as Form,
|
|
163
164
|
Ao as Grid,
|
|
164
165
|
Go as Hero,
|
|
@@ -175,12 +176,12 @@ export {
|
|
|
175
176
|
pr as Loading,
|
|
176
177
|
mr as Mask,
|
|
177
178
|
ar as Masonry,
|
|
178
|
-
|
|
179
|
+
nr as Mention,
|
|
179
180
|
lr as Menu,
|
|
180
181
|
yr as MessageManager,
|
|
181
182
|
Rr as Modal,
|
|
182
183
|
$ as MonthCalendar,
|
|
183
|
-
|
|
184
|
+
hr as Navbar,
|
|
184
185
|
Mr as OTPInput,
|
|
185
186
|
Ir as Pagination,
|
|
186
187
|
Tr as Phone,
|
|
@@ -201,7 +202,7 @@ export {
|
|
|
201
202
|
te as Space,
|
|
202
203
|
fe as Splitter,
|
|
203
204
|
xe as Stats,
|
|
204
|
-
|
|
205
|
+
se as Status,
|
|
205
206
|
ie as Steps,
|
|
206
207
|
ue as Table,
|
|
207
208
|
Ce as Tabs,
|
|
@@ -209,7 +210,7 @@ export {
|
|
|
209
210
|
be as TagLiveRegion,
|
|
210
211
|
Se as TextRotate,
|
|
211
212
|
ge as Textarea,
|
|
212
|
-
|
|
213
|
+
ve as ThemeController,
|
|
213
214
|
we as TimePicker,
|
|
214
215
|
Be as Timeline,
|
|
215
216
|
Me as Toggle,
|
|
@@ -224,19 +225,19 @@ export {
|
|
|
224
225
|
Ve as Watermark,
|
|
225
226
|
ro as WeekCalendar,
|
|
226
227
|
Pr as Window,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
228
|
+
Ht as deDE,
|
|
229
|
+
Dt as enCA,
|
|
230
|
+
ht as enGB,
|
|
231
|
+
Rt as enUS,
|
|
232
|
+
Ft as esES,
|
|
233
|
+
Wt as frFR,
|
|
234
|
+
At as jaJP,
|
|
235
|
+
Et as koKR,
|
|
235
236
|
Br as message,
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
Dr as notification,
|
|
238
|
+
Lt as ptBR,
|
|
238
239
|
$e as useBreakpoint,
|
|
239
|
-
|
|
240
|
+
st as useClickOutside,
|
|
240
241
|
tt as useClipboard,
|
|
241
242
|
K as useComponentLocale,
|
|
242
243
|
W as useConfig,
|
|
@@ -250,7 +251,8 @@ export {
|
|
|
250
251
|
z as useLocale,
|
|
251
252
|
it as usePrevious,
|
|
252
253
|
or as useSiderContext,
|
|
254
|
+
Pt as useTheme,
|
|
253
255
|
Tt as useWindowSize,
|
|
254
|
-
|
|
256
|
+
yt as zhCN
|
|
255
257
|
};
|
|
256
258
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|