asterui 0.12.14 → 0.12.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Autocomplete.d.ts +22 -2
- package/dist/components/Button.d.ts +10 -5
- package/dist/components/Form.d.ts +11 -1
- package/dist/components/Rating.d.ts +12 -4
- package/dist/index34.js +133 -119
- package/dist/index34.js.map +1 -1
- package/dist/index42.js +59 -50
- package/dist/index42.js.map +1 -1
- package/dist/index5.js +161 -80
- package/dist/index5.js.map +1 -1
- package/dist/index67.js +16 -16
- package/dist/index67.js.map +1 -1
- package/dist/index70.js +105 -44
- package/dist/index70.js.map +1 -1
- package/dist/index9.js +55 -53
- package/dist/index9.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,17 +2,37 @@ import { default as React } from 'react';
|
|
|
2
2
|
export interface AutocompleteOption {
|
|
3
3
|
value: string;
|
|
4
4
|
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
5
6
|
}
|
|
6
|
-
export interface AutocompleteProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
7
|
+
export interface AutocompleteProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'onSelect'> {
|
|
7
8
|
value?: string;
|
|
8
9
|
defaultValue?: string;
|
|
9
10
|
onChange?: (value: string) => void;
|
|
11
|
+
onSelect?: (value: string, option: AutocompleteOption) => void;
|
|
12
|
+
onSearch?: (value: string) => void;
|
|
10
13
|
options: AutocompleteOption[] | string[];
|
|
11
14
|
placeholder?: string;
|
|
12
15
|
disabled?: boolean;
|
|
13
|
-
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
16
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
17
|
+
color?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error';
|
|
18
|
+
/** Validation status */
|
|
19
|
+
status?: 'error' | 'warning';
|
|
14
20
|
allowCustomValue?: boolean;
|
|
15
21
|
filterOption?: (option: AutocompleteOption, inputValue: string) => boolean;
|
|
16
22
|
notFoundContent?: React.ReactNode;
|
|
23
|
+
/** Show clear button when input has value */
|
|
24
|
+
allowClear?: boolean | {
|
|
25
|
+
clearIcon?: React.ReactNode;
|
|
26
|
+
};
|
|
27
|
+
/** Callback when clear button is clicked */
|
|
28
|
+
onClear?: () => void;
|
|
29
|
+
/** Controlled open state */
|
|
30
|
+
open?: boolean;
|
|
31
|
+
/** Default open state */
|
|
32
|
+
defaultOpen?: boolean;
|
|
33
|
+
/** Callback when open state changes */
|
|
34
|
+
onOpenChange?: (open: boolean) => void;
|
|
35
|
+
/** Activate first option by default */
|
|
36
|
+
defaultActiveFirstOption?: boolean;
|
|
17
37
|
}
|
|
18
38
|
export declare const Autocomplete: React.FC<AutocompleteProps>;
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
type BaseButtonProps = {
|
|
3
|
-
|
|
3
|
+
/** Button color */
|
|
4
|
+
color?: 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'neutral';
|
|
5
|
+
/** Button style variant */
|
|
6
|
+
variant?: 'solid' | 'outline' | 'dash' | 'soft' | 'ghost' | 'link';
|
|
7
|
+
/** Button size */
|
|
4
8
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
5
|
-
|
|
6
|
-
dash?: boolean;
|
|
7
|
-
soft?: boolean;
|
|
9
|
+
/** Active/pressed visual state */
|
|
8
10
|
active?: boolean;
|
|
11
|
+
/** Show loading spinner and disable button */
|
|
9
12
|
loading?: boolean;
|
|
13
|
+
/** Button shape */
|
|
10
14
|
shape?: 'square' | 'circle' | 'wide' | 'block' | 'round';
|
|
15
|
+
/** Disable click animation */
|
|
11
16
|
noAnimation?: boolean;
|
|
12
17
|
/** Icon element to display */
|
|
13
18
|
icon?: React.ReactNode;
|
|
14
19
|
/** Position of the icon */
|
|
15
20
|
iconPosition?: 'start' | 'end';
|
|
16
|
-
/** Applies error/danger styling (shorthand for
|
|
21
|
+
/** Applies error/danger styling (shorthand for color="error") */
|
|
17
22
|
danger?: boolean;
|
|
18
23
|
/** Toggle button pressed state (sets aria-pressed) */
|
|
19
24
|
pressed?: boolean;
|
|
@@ -3,11 +3,21 @@ import { UseFormReturn, FieldValues, SubmitHandler, UseFormProps, FieldArrayPath
|
|
|
3
3
|
export interface FormProps<TFieldValues extends FieldValues = FieldValues> extends Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onSubmit'> {
|
|
4
4
|
form?: UseFormReturn<TFieldValues>;
|
|
5
5
|
onFinish?: SubmitHandler<TFieldValues>;
|
|
6
|
+
/** Called when form validation fails */
|
|
7
|
+
onFinishFailed?: (errorInfo: {
|
|
8
|
+
values: TFieldValues;
|
|
9
|
+
errorFields: Array<{
|
|
10
|
+
name: string;
|
|
11
|
+
errors: string[];
|
|
12
|
+
}>;
|
|
13
|
+
}) => void;
|
|
6
14
|
initialValues?: UseFormProps<TFieldValues>['defaultValues'];
|
|
7
15
|
layout?: 'vertical' | 'horizontal' | 'inline';
|
|
8
16
|
/** Label width in pixels for horizontal layout (default: 80) */
|
|
9
17
|
labelWidth?: number;
|
|
10
18
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
19
|
+
/** Disable all form fields */
|
|
20
|
+
disabled?: boolean;
|
|
11
21
|
children: React.ReactNode;
|
|
12
22
|
}
|
|
13
23
|
export interface FormRule {
|
|
@@ -62,7 +72,7 @@ export interface FormListProps<TFieldValues extends FieldValues = FieldValues> {
|
|
|
62
72
|
move: (from: number, to: number) => void;
|
|
63
73
|
}) => React.ReactNode;
|
|
64
74
|
}
|
|
65
|
-
declare function FormRoot<TFieldValues extends FieldValues = FieldValues>({ form: externalForm, onFinish, initialValues, layout, labelWidth, size, children, className, noValidate, ...props }: FormProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
75
|
+
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;
|
|
66
76
|
declare function FormItem({ name, label, help, required, rules, valuePropName, inline, className, children, tooltip, extra, hasFeedback, dependencies, validateTrigger, initialValue, hidden, }: FormItemProps): import("react/jsx-runtime").JSX.Element;
|
|
67
77
|
declare function FormList<TFieldValues extends FieldValues = FieldValues>({ name, children, }: FormListProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
68
78
|
export declare function useFormInstance<TFieldValues extends FieldValues = FieldValues>(): UseFormReturn<TFieldValues, any, TFieldValues> & {
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
export interface RatingProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {
|
|
3
|
-
children
|
|
3
|
+
children?: React.ReactNode;
|
|
4
4
|
value?: number;
|
|
5
5
|
defaultValue?: number;
|
|
6
6
|
onChange?: (value: number) => void;
|
|
7
|
+
onHoverChange?: (value: number) => void;
|
|
8
|
+
count?: number;
|
|
7
9
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
8
|
-
|
|
10
|
+
gap?: 'none' | 'xs' | 'sm' | 'md' | 'lg';
|
|
11
|
+
color?: string;
|
|
12
|
+
mask?: 'star' | 'star-2' | 'heart';
|
|
13
|
+
allowClear?: boolean;
|
|
14
|
+
allowHalf?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
9
16
|
}
|
|
10
17
|
export interface RatingItemProps {
|
|
11
18
|
value: number;
|
|
12
19
|
mask?: 'star' | 'star-2' | 'heart';
|
|
13
20
|
color?: string;
|
|
14
21
|
hidden?: boolean;
|
|
22
|
+
half?: 'first' | 'second';
|
|
15
23
|
className?: string;
|
|
16
24
|
}
|
|
17
|
-
declare function RatingRoot({ children, value, defaultValue, onChange, size,
|
|
18
|
-
declare function RatingItem({ value, mask, color, hidden, className }: RatingItemProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
declare function RatingRoot({ children, value, defaultValue, onChange, onHoverChange, count, size, gap, color, mask, allowClear, allowHalf, disabled, className, ...rest }: RatingProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
declare function RatingItem({ value, mask, color, hidden, half, className }: RatingItemProps): import("react/jsx-runtime").JSX.Element;
|
|
19
27
|
export declare const Rating: typeof RatingRoot & {
|
|
20
28
|
Item: typeof RatingItem;
|
|
21
29
|
};
|
package/dist/index34.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useForm as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as t, jsxs as j } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as ie, useId as H, useEffect as U, useRef as Y, isValidElement as G, cloneElement as le, useContext as ce } from "react";
|
|
3
|
+
import { useForm as Q, useFieldArray as ue, useWatch as de, Controller as me } from "react-hook-form";
|
|
4
|
+
const T = ie(void 0), W = {
|
|
5
5
|
email: {
|
|
6
6
|
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
|
7
7
|
message: "Please enter a valid email address"
|
|
@@ -15,209 +15,223 @@ const P = ae(void 0), M = {
|
|
|
15
15
|
message: "Please enter a valid number"
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
-
function
|
|
19
|
-
const r =
|
|
18
|
+
function Z() {
|
|
19
|
+
const r = ce(T);
|
|
20
20
|
if (!r)
|
|
21
21
|
throw new Error("Form compound components must be used within Form");
|
|
22
22
|
return r;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function fe({
|
|
25
25
|
form: r,
|
|
26
26
|
onFinish: o,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
onFinishFailed: s,
|
|
28
|
+
initialValues: u,
|
|
29
|
+
layout: f = "vertical",
|
|
30
|
+
labelWidth: k = 60,
|
|
31
|
+
size: h,
|
|
32
|
+
disabled: d = !1,
|
|
33
|
+
children: l,
|
|
34
|
+
className: g = "",
|
|
35
|
+
noValidate: p = !0,
|
|
36
|
+
...y
|
|
35
37
|
}) {
|
|
36
|
-
const
|
|
37
|
-
defaultValues:
|
|
38
|
-
}), v = r ||
|
|
39
|
-
|
|
38
|
+
const i = Q({
|
|
39
|
+
defaultValues: u
|
|
40
|
+
}), v = r || i, I = async (c) => {
|
|
41
|
+
if (c.preventDefault(), await v.trigger())
|
|
42
|
+
o && o(v.getValues());
|
|
43
|
+
else if (s) {
|
|
44
|
+
const P = v.formState.errors, E = [], z = (R, L = "") => {
|
|
45
|
+
for (const $ in R) {
|
|
46
|
+
const m = L ? `${L}.${$}` : $, b = R[$];
|
|
47
|
+
b?.message ? E.push({ name: m, errors: [b.message] }) : typeof b == "object" && b !== null && z(b, m);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
z(P), s({ values: v.getValues(), errorFields: E });
|
|
51
|
+
}
|
|
52
|
+
}, M = (c) => {
|
|
53
|
+
c.preventDefault(), v.reset(u);
|
|
40
54
|
};
|
|
41
|
-
return /* @__PURE__ */ t(
|
|
55
|
+
return /* @__PURE__ */ t(T.Provider, { value: { form: v, layout: f, labelWidth: k, size: h, disabled: d }, children: /* @__PURE__ */ t("form", { onSubmit: I, onReset: M, className: g, noValidate: p, ...y, children: l }) });
|
|
42
56
|
}
|
|
43
|
-
function
|
|
57
|
+
function he({
|
|
44
58
|
name: r,
|
|
45
59
|
label: o,
|
|
46
60
|
help: s,
|
|
47
61
|
required: u = !1,
|
|
48
|
-
rules:
|
|
49
|
-
valuePropName:
|
|
62
|
+
rules: f,
|
|
63
|
+
valuePropName: k = "value",
|
|
50
64
|
inline: h = !1,
|
|
51
|
-
className:
|
|
52
|
-
children:
|
|
65
|
+
className: d = "",
|
|
66
|
+
children: l,
|
|
53
67
|
tooltip: g,
|
|
54
68
|
extra: p,
|
|
55
|
-
hasFeedback:
|
|
56
|
-
dependencies:
|
|
57
|
-
validateTrigger:
|
|
58
|
-
initialValue:
|
|
59
|
-
hidden:
|
|
69
|
+
hasFeedback: y = !1,
|
|
70
|
+
dependencies: i,
|
|
71
|
+
validateTrigger: v = "onChange",
|
|
72
|
+
initialValue: I,
|
|
73
|
+
hidden: M = !1
|
|
60
74
|
}) {
|
|
61
|
-
const { form:
|
|
75
|
+
const { form: c, size: q, listName: P, layout: E, labelWidth: z, disabled: R } = Z(), L = H(), $ = H();
|
|
62
76
|
if (!r)
|
|
63
|
-
return /* @__PURE__ */ t("div", { className: `form-control ${h ? "w-auto" : "w-full"} ${
|
|
64
|
-
let
|
|
65
|
-
Array.isArray(r) ?
|
|
66
|
-
|
|
77
|
+
return /* @__PURE__ */ t("div", { className: `form-control ${h ? "w-auto" : "w-full"} ${d}`, style: M ? { display: "none" } : void 0, children: l });
|
|
78
|
+
let m;
|
|
79
|
+
Array.isArray(r) ? m = (P ? [P, ...r] : r).join(".") : m = r, U(() => {
|
|
80
|
+
I !== void 0 && c.getValues(m) === void 0 && c.setValue(m, I);
|
|
67
81
|
}, []);
|
|
68
|
-
const
|
|
69
|
-
control:
|
|
70
|
-
name:
|
|
71
|
-
disabled: !
|
|
72
|
-
}),
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
if (!
|
|
77
|
-
if (
|
|
78
|
-
|
|
82
|
+
const b = de({
|
|
83
|
+
control: c.control,
|
|
84
|
+
name: i,
|
|
85
|
+
disabled: !i || i.length === 0
|
|
86
|
+
}), O = Y(c);
|
|
87
|
+
O.current = c;
|
|
88
|
+
const B = Y(void 0);
|
|
89
|
+
U(() => {
|
|
90
|
+
if (!i || i.length === 0) return;
|
|
91
|
+
if (B.current === void 0) {
|
|
92
|
+
B.current = JSON.stringify(b);
|
|
79
93
|
return;
|
|
80
94
|
}
|
|
81
|
-
const e = JSON.stringify(
|
|
82
|
-
|
|
83
|
-
}, [
|
|
84
|
-
const
|
|
95
|
+
const e = JSON.stringify(b);
|
|
96
|
+
B.current !== e && (B.current = e, O.current.trigger(m));
|
|
97
|
+
}, [b, i, m]);
|
|
98
|
+
const A = ((e) => {
|
|
85
99
|
const n = e.split(".");
|
|
86
|
-
let a =
|
|
87
|
-
for (const
|
|
100
|
+
let a = c.formState.errors;
|
|
101
|
+
for (const C of n) {
|
|
88
102
|
if (!a) break;
|
|
89
|
-
a = a[
|
|
103
|
+
a = a[C];
|
|
90
104
|
}
|
|
91
105
|
return a;
|
|
92
|
-
})(
|
|
93
|
-
u && (
|
|
94
|
-
for (const e of
|
|
95
|
-
if (e.required && (
|
|
96
|
-
pattern:
|
|
97
|
-
message: e.message ||
|
|
106
|
+
})(m), V = A?.message, X = f ? Array.isArray(f) ? f : [f] : [], w = {}, S = [], D = [];
|
|
107
|
+
u && (w.required = "This field is required");
|
|
108
|
+
for (const e of X) {
|
|
109
|
+
if (e.required && (w.required = typeof e.required == "string" ? e.required : e.message || "This field is required"), e.type && W[e.type] && S.push({
|
|
110
|
+
pattern: W[e.type].value,
|
|
111
|
+
message: e.message || W[e.type].message
|
|
98
112
|
}), e.min !== void 0) {
|
|
99
113
|
const n = typeof e.min == "object" ? e.min.value : e.min, a = typeof e.min == "object" ? e.min.message : e.message || `Minimum length is ${n} characters`;
|
|
100
|
-
|
|
114
|
+
w.minLength = { value: n, message: a };
|
|
101
115
|
}
|
|
102
116
|
if (e.max !== void 0) {
|
|
103
117
|
const n = typeof e.max == "object" ? e.max.value : e.max, a = typeof e.max == "object" ? e.max.message : e.message || `Maximum length is ${n} characters`;
|
|
104
|
-
|
|
118
|
+
w.maxLength = { value: n, message: a };
|
|
105
119
|
}
|
|
106
120
|
if (e.pattern) {
|
|
107
121
|
const n = e.pattern instanceof RegExp ? e.pattern : e.pattern.value, a = e.pattern instanceof RegExp ? e.message || "Invalid format" : e.pattern.message;
|
|
108
|
-
|
|
122
|
+
S.push({ pattern: n, message: a });
|
|
109
123
|
}
|
|
110
|
-
e.validate &&
|
|
124
|
+
e.validate && D.push(e.validate);
|
|
111
125
|
}
|
|
112
|
-
(
|
|
113
|
-
if (!e && !
|
|
114
|
-
for (const { pattern: n, message: a } of
|
|
126
|
+
(S.length > 0 || D.length > 0) && (w.validate = async (e) => {
|
|
127
|
+
if (!e && !w.required) return !0;
|
|
128
|
+
for (const { pattern: n, message: a } of S)
|
|
115
129
|
if (e && !n.test(e))
|
|
116
130
|
return a;
|
|
117
|
-
for (const n of
|
|
131
|
+
for (const n of D) {
|
|
118
132
|
const a = await n(e);
|
|
119
133
|
if (a !== !0)
|
|
120
134
|
return a;
|
|
121
135
|
}
|
|
122
136
|
return !0;
|
|
123
137
|
});
|
|
124
|
-
const
|
|
138
|
+
const _ = Array.isArray(v) ? v : [v], J = _.includes("onChange"), ee = _.includes("onBlur"), te = ({ hasError: e, isValidating: n }) => n ? /* @__PURE__ */ t("span", { className: "loading loading-spinner loading-xs 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" }) }), re = () => /* @__PURE__ */ t("div", { className: "tooltip tooltip-top ml-1", "data-tip": g, 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" }) }) });
|
|
125
139
|
return /* @__PURE__ */ t(
|
|
126
140
|
me,
|
|
127
141
|
{
|
|
128
|
-
name:
|
|
129
|
-
control:
|
|
130
|
-
rules:
|
|
142
|
+
name: m,
|
|
143
|
+
control: c.control,
|
|
144
|
+
rules: w,
|
|
131
145
|
render: ({ field: e, fieldState: n }) => {
|
|
132
|
-
const { value: a, onChange:
|
|
133
|
-
id:
|
|
134
|
-
ref:
|
|
135
|
-
"aria-invalid":
|
|
136
|
-
"aria-describedby":
|
|
146
|
+
const { value: a, onChange: C, onBlur: se, ref: oe } = e, ne = n.isTouched && c.formState.isValidating, x = {
|
|
147
|
+
id: L,
|
|
148
|
+
ref: oe,
|
|
149
|
+
"aria-invalid": A ? !0 : void 0,
|
|
150
|
+
"aria-describedby": A ? $ : void 0
|
|
137
151
|
};
|
|
138
152
|
x.onBlur = () => {
|
|
139
|
-
|
|
140
|
-
},
|
|
141
|
-
|
|
153
|
+
se(), ee && c.trigger(m);
|
|
154
|
+
}, k === "checked" ? (x.checked = a, x.onChange = (F) => {
|
|
155
|
+
C(F.target.checked), J && c.trigger(m);
|
|
142
156
|
}) : (x.value = a || "", x.onChange = (F) => {
|
|
143
|
-
F && F.target !== void 0 ?
|
|
144
|
-
}),
|
|
145
|
-
const
|
|
146
|
-
return /* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */
|
|
157
|
+
F && F.target !== void 0 ? C(F.target.value) : C(F), J && c.trigger(m);
|
|
158
|
+
}), q && G(l) && (l.props.size || (x.size = q)), A && (x.color = "error", x["aria-invalid"] = !0), R && (x.disabled = !0);
|
|
159
|
+
const ae = G(l) ? le(l, x) : l, N = E === "horizontal", K = E === "inline";
|
|
160
|
+
return /* @__PURE__ */ j("div", { className: `form-control ${h ? "w-auto" : "w-full"} ${N ? "mb-4" : ""} ${K ? "inline-flex mr-4" : ""} ${d}`, style: M ? { display: "none" } : void 0, children: [
|
|
161
|
+
/* @__PURE__ */ j("div", { className: N ? "flex items-center gap-4" : "", children: [
|
|
148
162
|
o && /* @__PURE__ */ t(
|
|
149
163
|
"label",
|
|
150
164
|
{
|
|
151
|
-
htmlFor:
|
|
152
|
-
className: `label ${
|
|
153
|
-
style:
|
|
154
|
-
children: /* @__PURE__ */
|
|
165
|
+
htmlFor: L,
|
|
166
|
+
className: `label ${N ? "flex-shrink-0 justify-end py-0" : ""} ${!N && !K ? "pb-1" : ""}`,
|
|
167
|
+
style: N ? { width: z } : void 0,
|
|
168
|
+
children: /* @__PURE__ */ j("span", { className: "label-text flex items-center", children: [
|
|
155
169
|
o,
|
|
156
170
|
u && /* @__PURE__ */ t("span", { className: "text-error ml-1", children: "*" }),
|
|
157
|
-
g && /* @__PURE__ */ t(
|
|
171
|
+
g && /* @__PURE__ */ t(re, {})
|
|
158
172
|
] })
|
|
159
173
|
}
|
|
160
174
|
),
|
|
161
|
-
/* @__PURE__ */
|
|
162
|
-
|
|
163
|
-
|
|
175
|
+
/* @__PURE__ */ j("div", { className: `${N ? "flex-1" : ""} ${y ? "relative" : ""}`, children: [
|
|
176
|
+
ae,
|
|
177
|
+
y && n.isTouched && /* @__PURE__ */ t("span", { className: "absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none", children: /* @__PURE__ */ t(te, { hasError: !!A, isValidating: ne }) })
|
|
164
178
|
] })
|
|
165
179
|
] }),
|
|
166
|
-
!
|
|
167
|
-
|
|
180
|
+
!N && !h && /* @__PURE__ */ t("p", { id: $, className: `validator-hint ${V ? "!visible text-error" : ""} min-h-[1.25rem]`, role: V ? "alert" : void 0, children: V || s && /* @__PURE__ */ t("span", { className: "text-base-content/70", children: s }) || " " }),
|
|
181
|
+
N && (V || s) && /* @__PURE__ */ t("p", { id: $, className: `validator-hint ${V ? "!visible text-error" : ""} min-h-[1.25rem]`, role: V ? "alert" : void 0, children: V || s && /* @__PURE__ */ t("span", { className: "text-base-content/70", children: s }) }),
|
|
168
182
|
p && /* @__PURE__ */ t("div", { className: "text-sm text-base-content/60 mt-1", children: p })
|
|
169
183
|
] });
|
|
170
184
|
}
|
|
171
185
|
}
|
|
172
186
|
);
|
|
173
187
|
}
|
|
174
|
-
function
|
|
188
|
+
function ge({
|
|
175
189
|
name: r,
|
|
176
190
|
children: o
|
|
177
191
|
}) {
|
|
178
|
-
const { form: s, layout: u, size:
|
|
192
|
+
const { form: s, layout: u, size: f, disabled: k } = Z(), { fields: h, append: d, remove: l, move: g } = ue({
|
|
179
193
|
control: s.control,
|
|
180
194
|
name: r
|
|
181
|
-
}),
|
|
182
|
-
...
|
|
183
|
-
name:
|
|
195
|
+
}), p = h.map((y, i) => ({
|
|
196
|
+
...y,
|
|
197
|
+
name: i
|
|
184
198
|
}));
|
|
185
|
-
return /* @__PURE__ */ t(
|
|
186
|
-
add:
|
|
199
|
+
return /* @__PURE__ */ t(T.Provider, { value: { form: s, layout: u, size: f, listName: r, disabled: k }, children: o(p, {
|
|
200
|
+
add: d,
|
|
187
201
|
remove: l,
|
|
188
|
-
move:
|
|
202
|
+
move: g
|
|
189
203
|
}) });
|
|
190
204
|
}
|
|
191
|
-
function
|
|
192
|
-
const r =
|
|
205
|
+
function pe() {
|
|
206
|
+
const r = Q(), o = r;
|
|
193
207
|
return o.setFieldValue = r.setValue, o.getFieldValue = (s) => r.getValues(s), o.getFieldsValue = r.getValues, o.setFieldsValue = (s) => {
|
|
194
208
|
Object.keys(s).forEach((u) => {
|
|
195
209
|
r.setValue(u, s[u]);
|
|
196
210
|
});
|
|
197
211
|
}, o.validateFields = r.trigger, o.resetFields = r.reset, o.isFieldTouched = (s) => !!r.formState.touchedFields[s], o.getFieldError = (s) => r.formState.errors[s]?.message, o;
|
|
198
212
|
}
|
|
199
|
-
function
|
|
200
|
-
const { form: s } =
|
|
213
|
+
function ve({ fields: r, className: o = "" }) {
|
|
214
|
+
const { form: s } = Z(), { errors: u } = s.formState, f = (d, l = "") => {
|
|
201
215
|
const g = [];
|
|
202
|
-
for (const p in
|
|
203
|
-
const
|
|
204
|
-
|
|
216
|
+
for (const p in d) {
|
|
217
|
+
const y = l ? `${l}.${p}` : p, i = d[p];
|
|
218
|
+
i?.message ? g.push({ field: y, message: i.message }) : typeof i == "object" && i !== null && g.push(...f(i, y));
|
|
205
219
|
}
|
|
206
220
|
return g;
|
|
207
|
-
},
|
|
208
|
-
return h.length === 0 ? null : /* @__PURE__ */ t("ul", { className: `text-error text-sm space-y-1 ${o}`, role: "alert", children: h.map((
|
|
221
|
+
}, k = f(u), h = r ? k.filter((d) => r.includes(d.field)) : k;
|
|
222
|
+
return h.length === 0 ? null : /* @__PURE__ */ t("ul", { className: `text-error text-sm space-y-1 ${o}`, role: "alert", children: h.map((d, l) => /* @__PURE__ */ j("li", { className: "flex items-start gap-2", children: [
|
|
209
223
|
/* @__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" }) }),
|
|
210
|
-
/* @__PURE__ */ t("span", { children:
|
|
211
|
-
] }, `${
|
|
224
|
+
/* @__PURE__ */ t("span", { children: d.message })
|
|
225
|
+
] }, `${d.field}-${l}`)) });
|
|
212
226
|
}
|
|
213
|
-
const Ne = Object.assign(
|
|
214
|
-
Item:
|
|
215
|
-
List:
|
|
216
|
-
ErrorList:
|
|
217
|
-
useForm:
|
|
227
|
+
const Ne = Object.assign(fe, {
|
|
228
|
+
Item: he,
|
|
229
|
+
List: ge,
|
|
230
|
+
ErrorList: ve,
|
|
231
|
+
useForm: pe
|
|
218
232
|
});
|
|
219
233
|
export {
|
|
220
234
|
Ne as Form,
|
|
221
|
-
|
|
235
|
+
pe as useFormInstance
|
|
222
236
|
};
|
|
223
237
|
//# sourceMappingURL=index34.js.map
|