asterui 0.12.49 → 0.12.50
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/Alert.js +18 -18
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/Anchor.js +53 -53
- package/dist/components/Anchor.js.map +1 -1
- package/dist/components/Autocomplete.js +115 -114
- package/dist/components/Autocomplete.js.map +1 -1
- package/dist/components/Avatar.js +33 -32
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Badge.js +99 -99
- package/dist/components/Badge.js.map +1 -1
- package/dist/components/Breadcrumb.js +12 -11
- package/dist/components/Breadcrumb.js.map +1 -1
- package/dist/components/Browser.js +10 -10
- package/dist/components/Browser.js.map +1 -1
- package/dist/components/Button.js +80 -79
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.d.ts +2 -0
- package/dist/components/Card.js +111 -110
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Carousel.js +59 -59
- package/dist/components/Carousel.js.map +1 -1
- package/dist/components/Cascader.js +175 -174
- package/dist/components/Cascader.js.map +1 -1
- package/dist/components/Chat.js +27 -27
- package/dist/components/Chat.js.map +1 -1
- package/dist/components/Checkbox.js +98 -97
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Code.js +11 -11
- package/dist/components/Code.js.map +1 -1
- package/dist/components/Collapse.js +46 -46
- package/dist/components/Collapse.js.map +1 -1
- package/dist/components/ColorPicker.d.ts +1 -1
- package/dist/components/ColorPicker.js +93 -91
- package/dist/components/ColorPicker.js.map +1 -1
- package/dist/components/Command.js +120 -120
- package/dist/components/Command.js.map +1 -1
- package/dist/components/ConfigProvider.d.ts +1 -1
- package/dist/components/ConfigProvider.js +9 -9
- package/dist/components/ConfigProvider.js.map +1 -1
- package/dist/components/ContextMenu.js +33 -33
- package/dist/components/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton.js +74 -73
- package/dist/components/CopyButton.js.map +1 -1
- package/dist/components/Countdown.js +60 -59
- package/dist/components/Countdown.js.map +1 -1
- package/dist/components/DatePicker.d.ts +1 -1
- package/dist/components/DatePicker.js +54 -53
- package/dist/components/DatePicker.js.map +1 -1
- package/dist/components/Diff.js +10 -10
- package/dist/components/Diff.js.map +1 -1
- package/dist/components/Divider.js +21 -20
- package/dist/components/Divider.js.map +1 -1
- package/dist/components/Dock.js +28 -27
- package/dist/components/Dock.js.map +1 -1
- package/dist/components/Drawer.js +43 -43
- package/dist/components/Drawer.js.map +1 -1
- package/dist/components/Dropdown.js +127 -127
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/Empty.js +16 -15
- package/dist/components/Empty.js.map +1 -1
- package/dist/components/Fieldset.js +11 -10
- package/dist/components/Fieldset.js.map +1 -1
- package/dist/components/FileInput.js +30 -29
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/Filter.d.ts +1 -1
- package/dist/components/Filter.js +32 -30
- package/dist/components/Filter.js.map +1 -1
- package/dist/components/FloatButton.js +83 -83
- package/dist/components/FloatButton.js.map +1 -1
- package/dist/components/Footer.js +14 -13
- package/dist/components/Footer.js.map +1 -1
- package/dist/components/Form.js +133 -132
- package/dist/components/Form.js.map +1 -1
- package/dist/components/Hero.js +12 -11
- package/dist/components/Hero.js.map +1 -1
- package/dist/components/HoverGallery.js +7 -7
- package/dist/components/HoverGallery.js.map +1 -1
- package/dist/components/Image.js +40 -40
- package/dist/components/Image.js.map +1 -1
- package/dist/components/Input.js +171 -169
- package/dist/components/Input.js.map +1 -1
- package/dist/components/InputNumber.js +84 -83
- package/dist/components/InputNumber.js.map +1 -1
- package/dist/components/Join.js +11 -10
- package/dist/components/Join.js.map +1 -1
- package/dist/components/Kbd.js +15 -15
- package/dist/components/Kbd.js.map +1 -1
- package/dist/components/Layout.js +66 -66
- package/dist/components/Layout.js.map +1 -1
- package/dist/components/List.d.ts +1 -1
- package/dist/components/List.js +75 -72
- package/dist/components/List.js.map +1 -1
- package/dist/components/Loading.d.ts +1 -1
- package/dist/components/Loading.js +31 -29
- package/dist/components/Loading.js.map +1 -1
- package/dist/components/Mask.js +31 -31
- package/dist/components/Mask.js.map +1 -1
- package/dist/components/Mention.js +61 -61
- package/dist/components/Mention.js.map +1 -1
- package/dist/components/Menu.js +84 -84
- package/dist/components/Menu.js.map +1 -1
- package/dist/components/Message.js +30 -29
- package/dist/components/Message.js.map +1 -1
- package/dist/components/Modal.js +117 -116
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/MonthCalendar.d.ts +31 -0
- package/dist/components/MonthCalendar.js +205 -0
- package/dist/components/MonthCalendar.js.map +1 -0
- package/dist/components/Navbar.js +25 -25
- package/dist/components/Navbar.js.map +1 -1
- package/dist/components/Notification.js +56 -55
- package/dist/components/Notification.js.map +1 -1
- package/dist/components/OTPInput.js +69 -68
- package/dist/components/OTPInput.js.map +1 -1
- package/dist/components/Pagination.d.ts +1 -1
- package/dist/components/Pagination.js +60 -58
- package/dist/components/Pagination.js.map +1 -1
- package/dist/components/Phone.js +10 -10
- package/dist/components/Phone.js.map +1 -1
- package/dist/components/Popconfirm.js +60 -60
- package/dist/components/Popconfirm.js.map +1 -1
- package/dist/components/Progress.js +17 -17
- package/dist/components/Progress.js.map +1 -1
- package/dist/components/QRCode.js +23 -23
- package/dist/components/QRCode.js.map +1 -1
- package/dist/components/RadialProgress.js +17 -17
- package/dist/components/RadialProgress.js.map +1 -1
- package/dist/components/Radio.js +41 -40
- package/dist/components/Radio.js.map +1 -1
- package/dist/components/Range.d.ts +1 -1
- package/dist/components/Range.js +39 -37
- package/dist/components/Range.js.map +1 -1
- package/dist/components/Rating.js +79 -78
- package/dist/components/Rating.js.map +1 -1
- package/dist/components/ResponsiveDrawer.js +27 -27
- package/dist/components/ResponsiveDrawer.js.map +1 -1
- package/dist/components/RichTextEditor.d.ts +32 -0
- package/dist/components/RichTextEditor.js +335 -0
- package/dist/components/RichTextEditor.js.map +1 -0
- package/dist/components/Segmented.d.ts +1 -1
- package/dist/components/Segmented.js +48 -46
- package/dist/components/Segmented.js.map +1 -1
- package/dist/components/Select.js +55 -54
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Skeleton.js +9 -9
- package/dist/components/Skeleton.js.map +1 -1
- package/dist/components/Splitter.js +93 -93
- package/dist/components/Splitter.js.map +1 -1
- package/dist/components/Stat.js +17 -16
- package/dist/components/Stat.js.map +1 -1
- package/dist/components/Status.js +29 -29
- package/dist/components/Status.js.map +1 -1
- package/dist/components/Steps.js +61 -61
- package/dist/components/Steps.js.map +1 -1
- package/dist/components/Table.js +256 -256
- package/dist/components/Table.js.map +1 -1
- package/dist/components/Tabs.js +65 -65
- package/dist/components/Tabs.js.map +1 -1
- package/dist/components/Tag.js +147 -147
- package/dist/components/Tag.js.map +1 -1
- package/dist/components/TextRotate.js +6 -6
- package/dist/components/TextRotate.js.map +1 -1
- package/dist/components/Textarea.js +35 -34
- package/dist/components/Textarea.js.map +1 -1
- package/dist/components/ThemeController.d.ts +1 -1
- package/dist/components/ThemeController.js +71 -68
- package/dist/components/ThemeController.js.map +1 -1
- package/dist/components/TimePicker.d.ts +1 -1
- package/dist/components/TimePicker.js +133 -129
- package/dist/components/TimePicker.js.map +1 -1
- package/dist/components/Timeline.js +79 -79
- package/dist/components/Timeline.js.map +1 -1
- package/dist/components/Toggle.js +33 -32
- package/dist/components/Toggle.js.map +1 -1
- package/dist/components/Tooltip.js +25 -25
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/Tour.js +126 -126
- package/dist/components/Tour.js.map +1 -1
- package/dist/components/Transfer.js +93 -92
- package/dist/components/Transfer.js.map +1 -1
- package/dist/components/Tree.js +200 -200
- package/dist/components/Tree.js.map +1 -1
- package/dist/components/TreeSelect.js +255 -254
- package/dist/components/TreeSelect.js.map +1 -1
- package/dist/components/Typography.js +71 -70
- package/dist/components/Typography.js.map +1 -1
- package/dist/components/Upload.js +81 -81
- package/dist/components/Upload.js.map +1 -1
- package/dist/components/WeekCalendar.d.ts +35 -0
- package/dist/components/WeekCalendar.js +204 -0
- package/dist/components/WeekCalendar.js.map +1 -0
- package/dist/components/Window.js +7 -7
- package/dist/components/Window.js.map +1 -1
- package/dist/editor.d.ts +1 -0
- package/dist/editor.js +5 -0
- package/dist/editor.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +211 -207
- package/dist/index.js.map +1 -1
- package/package.json +30 -1
|
@@ -1,100 +1,101 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
|
|
1
|
+
import { jsxs as N, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as K, useState as W, useRef as G, useImperativeHandle as H } from "react";
|
|
3
|
+
import { useConfig as U } from "./ConfigProvider.js";
|
|
4
|
+
const q = "input", E = "input-xs", J = "input-sm", O = "input-md", P = "input-lg", Q = "input-xl", T = "input-disabled", k = "btn", Y = "btn-xs", Z = "btn-sm", w = "btn-ghost", _ = K(
|
|
4
5
|
({
|
|
5
|
-
value:
|
|
6
|
-
defaultValue:
|
|
7
|
-
min:
|
|
8
|
-
max:
|
|
9
|
-
step:
|
|
6
|
+
value: i,
|
|
7
|
+
defaultValue: B,
|
|
8
|
+
min: r = -1 / 0,
|
|
9
|
+
max: a = 1 / 0,
|
|
10
|
+
step: d = 1,
|
|
10
11
|
precision: s,
|
|
11
|
-
size:
|
|
12
|
+
size: C,
|
|
12
13
|
disabled: l = !1,
|
|
13
|
-
onChange:
|
|
14
|
+
onChange: p,
|
|
14
15
|
formatter: f,
|
|
15
|
-
parser:
|
|
16
|
-
className:
|
|
17
|
-
controls:
|
|
18
|
-
block:
|
|
19
|
-
...
|
|
20
|
-
},
|
|
21
|
-
const [j,
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
let
|
|
26
|
-
return s !== void 0 && (
|
|
27
|
-
},
|
|
28
|
-
if (!
|
|
29
|
-
const
|
|
30
|
-
return isNaN(
|
|
31
|
-
},
|
|
32
|
-
let
|
|
33
|
-
return s !== void 0 && (
|
|
34
|
-
},
|
|
35
|
-
if (
|
|
36
|
-
|
|
16
|
+
parser: m,
|
|
17
|
+
className: D = "",
|
|
18
|
+
controls: h = !0,
|
|
19
|
+
block: $ = !1,
|
|
20
|
+
...S
|
|
21
|
+
}, M) => {
|
|
22
|
+
const { componentSize: V } = U(), c = C ?? V ?? "md", [j, v] = W(B ?? null), I = G(null);
|
|
23
|
+
H(M, () => I.current);
|
|
24
|
+
const e = i !== void 0 ? i : j, z = (n) => {
|
|
25
|
+
if (n === null) return "";
|
|
26
|
+
let t = n;
|
|
27
|
+
return s !== void 0 && (t = Number(n.toFixed(s))), f ? f(t) : String(t);
|
|
28
|
+
}, L = (n) => {
|
|
29
|
+
if (!n) return null;
|
|
30
|
+
const t = m ? m(n) : parseFloat(n);
|
|
31
|
+
return isNaN(t) ? null : t;
|
|
32
|
+
}, b = (n) => {
|
|
33
|
+
let t = Math.max(r, Math.min(a, n));
|
|
34
|
+
return s !== void 0 && (t = Number(t.toFixed(s))), t;
|
|
35
|
+
}, u = (n) => {
|
|
36
|
+
if (n === null) {
|
|
37
|
+
i === void 0 && v(null), p?.(null);
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
},
|
|
40
|
+
const t = b(n);
|
|
41
|
+
i === void 0 && v(t), p?.(t);
|
|
42
|
+
}, x = () => {
|
|
42
43
|
if (l) return;
|
|
43
|
-
|
|
44
|
-
},
|
|
44
|
+
u((e ?? 0) + d);
|
|
45
|
+
}, y = () => {
|
|
45
46
|
if (l) return;
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
l || (
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
|
|
47
|
+
u((e ?? 0) - d);
|
|
48
|
+
}, F = (n) => {
|
|
49
|
+
const t = L(n.target.value);
|
|
50
|
+
t !== null ? u(t) : n.target.value === "" && u(null);
|
|
51
|
+
}, R = (n) => {
|
|
52
|
+
l || (n.key === "ArrowUp" ? (n.preventDefault(), x()) : n.key === "ArrowDown" && (n.preventDefault(), y()));
|
|
53
|
+
}, X = () => {
|
|
54
|
+
e !== null && (e < r || e > a) && u(b(e));
|
|
55
|
+
}, A = [
|
|
56
|
+
q,
|
|
56
57
|
"w-full",
|
|
57
58
|
c && {
|
|
58
|
-
xs:
|
|
59
|
-
sm:
|
|
60
|
-
md:
|
|
61
|
-
lg:
|
|
62
|
-
xl:
|
|
59
|
+
xs: E,
|
|
60
|
+
sm: J,
|
|
61
|
+
md: O,
|
|
62
|
+
lg: P,
|
|
63
|
+
xl: Q
|
|
63
64
|
}[c],
|
|
64
|
-
l &&
|
|
65
|
-
|
|
66
|
-
].filter(Boolean).join(" "),
|
|
67
|
-
return /* @__PURE__ */
|
|
68
|
-
/* @__PURE__ */
|
|
65
|
+
l && T,
|
|
66
|
+
h && "pr-8"
|
|
67
|
+
].filter(Boolean).join(" "), g = c === "xs" || c === "sm" ? Y : Z;
|
|
68
|
+
return /* @__PURE__ */ N("div", { className: `relative ${$ ? "w-full" : "inline-block"} group ${D}`, children: [
|
|
69
|
+
/* @__PURE__ */ o(
|
|
69
70
|
"input",
|
|
70
71
|
{
|
|
71
|
-
ref:
|
|
72
|
+
ref: I,
|
|
72
73
|
type: "text",
|
|
73
74
|
inputMode: "decimal",
|
|
74
75
|
role: "spinbutton",
|
|
75
|
-
"aria-valuemin":
|
|
76
|
-
"aria-valuemax":
|
|
77
|
-
"aria-valuenow":
|
|
78
|
-
className:
|
|
79
|
-
value:
|
|
80
|
-
onChange:
|
|
81
|
-
onKeyDown:
|
|
82
|
-
onBlur:
|
|
76
|
+
"aria-valuemin": r !== -1 / 0 ? r : void 0,
|
|
77
|
+
"aria-valuemax": a !== 1 / 0 ? a : void 0,
|
|
78
|
+
"aria-valuenow": e ?? void 0,
|
|
79
|
+
className: A,
|
|
80
|
+
value: z(e),
|
|
81
|
+
onChange: F,
|
|
82
|
+
onKeyDown: R,
|
|
83
|
+
onBlur: X,
|
|
83
84
|
disabled: l,
|
|
84
|
-
...
|
|
85
|
+
...S
|
|
85
86
|
}
|
|
86
87
|
),
|
|
87
|
-
|
|
88
|
-
/* @__PURE__ */
|
|
88
|
+
h && /* @__PURE__ */ N("div", { className: "absolute right-1 top-1/2 -translate-y-1/2 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity", children: [
|
|
89
|
+
/* @__PURE__ */ o(
|
|
89
90
|
"button",
|
|
90
91
|
{
|
|
91
92
|
type: "button",
|
|
92
93
|
"aria-label": "Increase value",
|
|
93
|
-
className:
|
|
94
|
-
onClick:
|
|
95
|
-
disabled: l ||
|
|
94
|
+
className: `${k} ${g} ${w} px-1 min-h-0 h-3.5`,
|
|
95
|
+
onClick: x,
|
|
96
|
+
disabled: l || e !== null && e >= a,
|
|
96
97
|
tabIndex: -1,
|
|
97
|
-
children: /* @__PURE__ */
|
|
98
|
+
children: /* @__PURE__ */ o(
|
|
98
99
|
"svg",
|
|
99
100
|
{
|
|
100
101
|
className: "w-3 h-3",
|
|
@@ -102,7 +103,7 @@ const H = S(
|
|
|
102
103
|
viewBox: "0 0 24 24",
|
|
103
104
|
stroke: "currentColor",
|
|
104
105
|
"aria-hidden": "true",
|
|
105
|
-
children: /* @__PURE__ */
|
|
106
|
+
children: /* @__PURE__ */ o(
|
|
106
107
|
"path",
|
|
107
108
|
{
|
|
108
109
|
strokeLinecap: "round",
|
|
@@ -115,16 +116,16 @@ const H = S(
|
|
|
115
116
|
)
|
|
116
117
|
}
|
|
117
118
|
),
|
|
118
|
-
/* @__PURE__ */
|
|
119
|
+
/* @__PURE__ */ o(
|
|
119
120
|
"button",
|
|
120
121
|
{
|
|
121
122
|
type: "button",
|
|
122
123
|
"aria-label": "Decrease value",
|
|
123
|
-
className:
|
|
124
|
-
onClick:
|
|
125
|
-
disabled: l ||
|
|
124
|
+
className: `${k} ${g} ${w} px-1 min-h-0 h-3.5`,
|
|
125
|
+
onClick: y,
|
|
126
|
+
disabled: l || e !== null && e <= r,
|
|
126
127
|
tabIndex: -1,
|
|
127
|
-
children: /* @__PURE__ */
|
|
128
|
+
children: /* @__PURE__ */ o(
|
|
128
129
|
"svg",
|
|
129
130
|
{
|
|
130
131
|
className: "w-3 h-3",
|
|
@@ -132,7 +133,7 @@ const H = S(
|
|
|
132
133
|
viewBox: "0 0 24 24",
|
|
133
134
|
stroke: "currentColor",
|
|
134
135
|
"aria-hidden": "true",
|
|
135
|
-
children: /* @__PURE__ */
|
|
136
|
+
children: /* @__PURE__ */ o(
|
|
136
137
|
"path",
|
|
137
138
|
{
|
|
138
139
|
strokeLinecap: "round",
|
|
@@ -149,9 +150,9 @@ const H = S(
|
|
|
149
150
|
] });
|
|
150
151
|
}
|
|
151
152
|
);
|
|
152
|
-
|
|
153
|
+
_.displayName = "InputNumber";
|
|
153
154
|
export {
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
_ as InputNumber,
|
|
156
|
+
_ as default
|
|
156
157
|
};
|
|
157
158
|
//# sourceMappingURL=InputNumber.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputNumber.js","sources":["../../src/components/InputNumber.tsx"],"sourcesContent":["import React, { useState, useRef, forwardRef, useImperativeHandle } from 'react'\n\nexport interface InputNumberProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'onChange' | 'value' | 'defaultValue'> {\n value?: number\n defaultValue?: number\n min?: number\n max?: number\n step?: number\n precision?: number\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n disabled?: boolean\n onChange?: (value: number | null) => void\n formatter?: (value: number | undefined) => string\n parser?: (displayValue: string) => number\n className?: string\n controls?: boolean\n block?: boolean\n}\n\nexport const InputNumber = forwardRef<HTMLInputElement, InputNumberProps>(\n (\n {\n value: controlledValue,\n defaultValue,\n min = -Infinity,\n max = Infinity,\n step = 1,\n precision,\n size,\n disabled = false,\n onChange,\n formatter,\n parser,\n className = '',\n controls = true,\n block = false,\n ...props\n },\n ref\n ) => {\n const [internalValue, setInternalValue] = useState<number | null>(defaultValue ?? null)\n const inputRef = useRef<HTMLInputElement>(null)\n\n useImperativeHandle(ref, () => inputRef.current!)\n\n const value = controlledValue !== undefined ? controlledValue : internalValue\n\n const formatValue = (num: number | null): string => {\n if (num === null) return ''\n let formatted = num\n if (precision !== undefined) {\n formatted = Number(num.toFixed(precision))\n }\n return formatter ? formatter(formatted) : String(formatted)\n }\n\n const parseValue = (str: string): number | null => {\n if (!str) return null\n const parsed = parser ? parser(str) : parseFloat(str)\n if (isNaN(parsed)) return null\n return parsed\n }\n\n const clampValue = (num: number): number => {\n let clamped = Math.max(min, Math.min(max, num))\n if (precision !== undefined) {\n clamped = Number(clamped.toFixed(precision))\n }\n return clamped\n }\n\n const updateValue = (newValue: number | null) => {\n if (newValue === null) {\n if (controlledValue === undefined) {\n setInternalValue(null)\n }\n onChange?.(null)\n return\n }\n\n const clamped = clampValue(newValue)\n if (controlledValue === undefined) {\n setInternalValue(clamped)\n }\n onChange?.(clamped)\n }\n\n const handleIncrement = () => {\n if (disabled) return\n const currentValue = value ?? 0\n updateValue(currentValue + step)\n }\n\n const handleDecrement = () => {\n if (disabled) return\n const currentValue = value ?? 0\n updateValue(currentValue - step)\n }\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const parsed = parseValue(e.target.value)\n if (parsed !== null) {\n updateValue(parsed)\n } else if (e.target.value === '') {\n updateValue(null)\n }\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled) return\n\n if (e.key === 'ArrowUp') {\n e.preventDefault()\n handleIncrement()\n } else if (e.key === 'ArrowDown') {\n e.preventDefault()\n handleDecrement()\n }\n }\n\n const handleBlur = () => {\n // Ensure value is within bounds on blur\n if (value !== null && (value < min || value > max)) {\n updateValue(clampValue(value))\n }\n }\n\n const sizeClasses = {\n xs: 'input-xs',\n sm: 'input-sm',\n md: 'input-md',\n lg: 'input-lg',\n xl: 'input-xl',\n }\n\n const inputClasses = [\n 'input',\n 'w-full',\n size && sizeClasses[size],\n disabled && 'input-disabled',\n controls && 'pr-8',\n ]\n .filter(Boolean)\n .join(' ')\n\n const buttonSize = size === 'xs' || size === 'sm' ? 'btn-xs' : 'btn-sm'\n\n return (\n <div className={`relative ${block ? 'w-full' : 'inline-block'} group ${className}`}>\n <input\n ref={inputRef}\n type=\"text\"\n inputMode=\"decimal\"\n role=\"spinbutton\"\n aria-valuemin={min !== -Infinity ? min : undefined}\n aria-valuemax={max !== Infinity ? max : undefined}\n aria-valuenow={value ?? undefined}\n className={inputClasses}\n value={formatValue(value)}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n disabled={disabled}\n {...props}\n />\n {controls && (\n <div className=\"absolute right-1 top-1/2 -translate-y-1/2 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity\">\n <button\n type=\"button\"\n aria-label=\"Increase value\"\n className={`btn ${buttonSize} btn-ghost px-1 min-h-0 h-3.5`}\n onClick={handleIncrement}\n disabled={disabled || (value !== null && value >= max)}\n tabIndex={-1}\n >\n <svg\n className=\"w-3 h-3\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M5 15l7-7 7 7\"\n />\n </svg>\n </button>\n <button\n type=\"button\"\n aria-label=\"Decrease value\"\n className={`btn ${buttonSize} btn-ghost px-1 min-h-0 h-3.5`}\n onClick={handleDecrement}\n disabled={disabled || (value !== null && value <= min)}\n tabIndex={-1}\n >\n <svg\n className=\"w-3 h-3\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M19 9l-7 7-7-7\"\n />\n </svg>\n </button>\n </div>\n )}\n </div>\n )\n }\n)\n\nInputNumber.displayName = 'InputNumber'\n\nexport default InputNumber\n"],"names":["InputNumber","forwardRef","controlledValue","defaultValue","min","max","step","precision","size","disabled","onChange","formatter","parser","className","controls","block","props","ref","internalValue","setInternalValue","useState","inputRef","useRef","useImperativeHandle","value","formatValue","num","formatted","parseValue","str","parsed","clampValue","clamped","updateValue","newValue","handleIncrement","handleDecrement","handleInputChange","handleKeyDown","handleBlur","inputClasses","buttonSize","jsxs","jsx"],"mappings":";;AAmBO,MAAMA,IAAcC;AAAA,EACzB,CACE;AAAA,IACE,OAAOC;AAAA,IACP,cAAAC;AAAA,IACA,KAAAC,IAAM;AAAA,IACN,KAAAC,IAAM;AAAA,IACN,MAAAC,IAAO;AAAA,IACP,WAAAC;AAAA,IACA,MAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,UAAAC,IAAW;AAAA,IACX,OAAAC,IAAQ;AAAA,IACR,GAAGC;AAAA,EAAA,GAELC,MACG;AACH,UAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAwBjB,KAAgB,IAAI,GAChFkB,IAAWC,EAAyB,IAAI;AAE9C,IAAAC,EAAoBN,GAAK,MAAMI,EAAS,OAAQ;AAEhD,UAAMG,IAAQtB,MAAoB,SAAYA,IAAkBgB,GAE1DO,IAAc,CAACC,MAA+B;AAClD,UAAIA,MAAQ,KAAM,QAAO;AACzB,UAAIC,IAAYD;AAChB,aAAInB,MAAc,WAChBoB,IAAY,OAAOD,EAAI,QAAQnB,CAAS,CAAC,IAEpCI,IAAYA,EAAUgB,CAAS,IAAI,OAAOA,CAAS;AAAA,IAC5D,GAEMC,IAAa,CAACC,MAA+B;AACjD,UAAI,CAACA,EAAK,QAAO;AACjB,YAAMC,IAASlB,IAASA,EAAOiB,CAAG,IAAI,WAAWA,CAAG;AACpD,aAAI,MAAMC,CAAM,IAAU,OACn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;AAAA,QAAA;AAAA,QAEF,gBAAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,cAAW;AAAA,YACX,WAAW,OAAOF,CAAU;AAAA,YAC5B,SAASL;AAAA,YACT,UAAU3B,KAAae,MAAU,QAAQA,KAASpB;AAAA,YAClD,UAAU;AAAA,YAEV,UAAA,gBAAAuC;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAU;AAAA,gBACV,MAAK;AAAA,gBACL,SAAQ;AAAA,gBACR,QAAO;AAAA,gBACP,eAAY;AAAA,gBAEZ,UAAA,gBAAAA;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,eAAc;AAAA,oBACd,gBAAe;AAAA,oBACf,aAAa;AAAA,oBACb,GAAE;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACJ;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,MACF,EAAA,CACF;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;AAEA3C,EAAY,cAAc;"}
|
|
1
|
+
{"version":3,"file":"InputNumber.js","sources":["../../src/components/InputNumber.tsx"],"sourcesContent":["import React, { useState, useRef, forwardRef, useImperativeHandle } from 'react'\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 dInputDisabled = 'input-disabled'\nconst dBtn = 'btn'\nconst dBtnXs = 'btn-xs'\nconst dBtnSm = 'btn-sm'\nconst dBtnGhost = 'btn-ghost'\n\nexport interface InputNumberProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'onChange' | 'value' | 'defaultValue'> {\n value?: number\n defaultValue?: number\n min?: number\n max?: number\n step?: number\n precision?: number\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n disabled?: boolean\n onChange?: (value: number | null) => void\n formatter?: (value: number | undefined) => string\n parser?: (displayValue: string) => number\n className?: string\n controls?: boolean\n block?: boolean\n}\n\nexport const InputNumber = forwardRef<HTMLInputElement, InputNumberProps>(\n (\n {\n value: controlledValue,\n defaultValue,\n min = -Infinity,\n max = Infinity,\n step = 1,\n precision,\n size,\n disabled = false,\n onChange,\n formatter,\n parser,\n className = '',\n controls = true,\n block = false,\n ...props\n },\n ref\n ) => {\n const { componentSize } = useConfig()\n const effectiveSize = size ?? componentSize ?? 'md'\n\n const [internalValue, setInternalValue] = useState<number | null>(defaultValue ?? null)\n const inputRef = useRef<HTMLInputElement>(null)\n\n useImperativeHandle(ref, () => inputRef.current!)\n\n const value = controlledValue !== undefined ? controlledValue : internalValue\n\n const formatValue = (num: number | null): string => {\n if (num === null) return ''\n let formatted = num\n if (precision !== undefined) {\n formatted = Number(num.toFixed(precision))\n }\n return formatter ? formatter(formatted) : String(formatted)\n }\n\n const parseValue = (str: string): number | null => {\n if (!str) return null\n const parsed = parser ? parser(str) : parseFloat(str)\n if (isNaN(parsed)) return null\n return parsed\n }\n\n const clampValue = (num: number): number => {\n let clamped = Math.max(min, Math.min(max, num))\n if (precision !== undefined) {\n clamped = Number(clamped.toFixed(precision))\n }\n return clamped\n }\n\n const updateValue = (newValue: number | null) => {\n if (newValue === null) {\n if (controlledValue === undefined) {\n setInternalValue(null)\n }\n onChange?.(null)\n return\n }\n\n const clamped = clampValue(newValue)\n if (controlledValue === undefined) {\n setInternalValue(clamped)\n }\n onChange?.(clamped)\n }\n\n const handleIncrement = () => {\n if (disabled) return\n const currentValue = value ?? 0\n updateValue(currentValue + step)\n }\n\n const handleDecrement = () => {\n if (disabled) return\n const currentValue = value ?? 0\n updateValue(currentValue - step)\n }\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const parsed = parseValue(e.target.value)\n if (parsed !== null) {\n updateValue(parsed)\n } else if (e.target.value === '') {\n updateValue(null)\n }\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled) return\n\n if (e.key === 'ArrowUp') {\n e.preventDefault()\n handleIncrement()\n } else if (e.key === 'ArrowDown') {\n e.preventDefault()\n handleDecrement()\n }\n }\n\n const handleBlur = () => {\n // Ensure value is within bounds on blur\n if (value !== null && (value < min || value > max)) {\n updateValue(clampValue(value))\n }\n }\n\n const sizeClasses = {\n xs: dInputXs,\n sm: dInputSm,\n md: dInputMd,\n lg: dInputLg,\n xl: dInputXl,\n }\n\n const inputClasses = [\n dInput,\n 'w-full',\n effectiveSize && sizeClasses[effectiveSize],\n disabled && dInputDisabled,\n controls && 'pr-8',\n ]\n .filter(Boolean)\n .join(' ')\n\n const buttonSize = effectiveSize === 'xs' || effectiveSize === 'sm' ? dBtnXs : dBtnSm\n\n return (\n <div className={`relative ${block ? 'w-full' : 'inline-block'} group ${className}`}>\n <input\n ref={inputRef}\n type=\"text\"\n inputMode=\"decimal\"\n role=\"spinbutton\"\n aria-valuemin={min !== -Infinity ? min : undefined}\n aria-valuemax={max !== Infinity ? max : undefined}\n aria-valuenow={value ?? undefined}\n className={inputClasses}\n value={formatValue(value)}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n disabled={disabled}\n {...props}\n />\n {controls && (\n <div className=\"absolute right-1 top-1/2 -translate-y-1/2 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity\">\n <button\n type=\"button\"\n aria-label=\"Increase value\"\n className={`${dBtn} ${buttonSize} ${dBtnGhost} px-1 min-h-0 h-3.5`}\n onClick={handleIncrement}\n disabled={disabled || (value !== null && value >= max)}\n tabIndex={-1}\n >\n <svg\n className=\"w-3 h-3\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M5 15l7-7 7 7\"\n />\n </svg>\n </button>\n <button\n type=\"button\"\n aria-label=\"Decrease value\"\n className={`${dBtn} ${buttonSize} ${dBtnGhost} px-1 min-h-0 h-3.5`}\n onClick={handleDecrement}\n disabled={disabled || (value !== null && value <= min)}\n tabIndex={-1}\n >\n <svg\n className=\"w-3 h-3\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M19 9l-7 7-7-7\"\n />\n </svg>\n </button>\n </div>\n )}\n </div>\n )\n }\n)\n\nInputNumber.displayName = 'InputNumber'\n\nexport default InputNumber\n"],"names":["dInput","dInputXs","dInputSm","dInputMd","dInputLg","dInputXl","dInputDisabled","dBtn","dBtnXs","dBtnSm","dBtnGhost","InputNumber","forwardRef","controlledValue","defaultValue","min","max","step","precision","size","disabled","onChange","formatter","parser","className","controls","block","props","ref","componentSize","useConfig","effectiveSize","internalValue","setInternalValue","useState","inputRef","useRef","useImperativeHandle","value","formatValue","num","formatted","parseValue","str","parsed","clampValue","clamped","updateValue","newValue","handleIncrement","handleDecrement","handleInputChange","e","handleKeyDown","handleBlur","inputClasses","buttonSize","jsxs","jsx"],"mappings":";;;AAIA,MAAMA,IAAS,SACTC,IAAW,YACXC,IAAW,YACXC,IAAW,YACXC,IAAW,YACXC,IAAW,YACXC,IAAiB,kBACjBC,IAAO,OACPC,IAAS,UACTC,IAAS,UACTC,IAAY,aAmBLC,IAAcC;AAAA,EACzB,CACE;AAAA,IACE,OAAOC;AAAA,IACP,cAAAC;AAAA,IACA,KAAAC,IAAM;AAAA,IACN,KAAAC,IAAM;AAAA,IACN,MAAAC,IAAO;AAAA,IACP,WAAAC;AAAA,IACA,MAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,UAAAC,IAAW;AAAA,IACX,OAAAC,IAAQ;AAAA,IACR,GAAGC;AAAA,EAAA,GAELC,MAC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;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,MACF,EAAA,CACF;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;AAEA/C,EAAY,cAAc;"}
|
package/dist/components/Join.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import e from "react";
|
|
3
|
+
const d = "join", f = "join-vertical", t = "join-item";
|
|
4
|
+
function N({ children: i, direction: s = "horizontal", className: r = "", ...a }) {
|
|
5
|
+
const c = [d, s === "vertical" && f, r].filter(Boolean).join(" "), l = e.Children.map(i, (n) => {
|
|
6
|
+
if (e.isValidElement(n)) {
|
|
7
|
+
const o = n.props.className || "", m = o ? `${t} ${o}` : t;
|
|
8
|
+
return e.cloneElement(n, {
|
|
8
9
|
className: m
|
|
9
10
|
});
|
|
10
11
|
}
|
|
11
|
-
return
|
|
12
|
+
return n;
|
|
12
13
|
});
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
+
return /* @__PURE__ */ p("div", { className: c, ...a, children: l });
|
|
14
15
|
}
|
|
15
16
|
export {
|
|
16
|
-
|
|
17
|
+
N as Join
|
|
17
18
|
};
|
|
18
19
|
//# sourceMappingURL=Join.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Join.js","sources":["../../src/components/Join.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface JoinProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n direction?: 'horizontal' | 'vertical'\n}\n\nexport function Join({ children, direction = 'horizontal', className = '', ...rest }: JoinProps) {\n const classes = [
|
|
1
|
+
{"version":3,"file":"Join.js","sources":["../../src/components/Join.tsx"],"sourcesContent":["import React from 'react'\n\n// DaisyUI classes\nconst dJoin = 'join'\nconst dJoinVertical = 'join-vertical'\nconst dJoinItem = 'join-item'\n\nexport interface JoinProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n direction?: 'horizontal' | 'vertical'\n}\n\nexport function Join({ children, direction = 'horizontal', className = '', ...rest }: JoinProps) {\n const classes = [dJoin, direction === 'vertical' && dJoinVertical, className].filter(Boolean).join(' ')\n\n // Automatically add join-item class to all children\n const childrenWithJoinItem = React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n const existingClassName = (child.props as any).className || ''\n const newClassName = existingClassName ? `${dJoinItem} ${existingClassName}` : dJoinItem\n\n return React.cloneElement(child as React.ReactElement<any>, {\n className: newClassName,\n })\n }\n return child\n })\n\n return <div className={classes} {...rest}>{childrenWithJoinItem}</div>\n}\n"],"names":["dJoin","dJoinVertical","dJoinItem","Join","children","direction","className","rest","classes","childrenWithJoinItem","React","child","existingClassName","newClassName"],"mappings":";;AAGA,MAAMA,IAAQ,QACRC,IAAgB,iBAChBC,IAAY;AAOX,SAASC,EAAK,EAAE,UAAAC,GAAU,WAAAC,IAAY,cAAc,WAAAC,IAAY,IAAI,GAAGC,KAAmB;AAC/F,QAAMC,IAAU,CAACR,GAAOK,MAAc,cAAcJ,GAAeK,CAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,GAGhGG,IAAuBC,EAAM,SAAS,IAAIN,GAAU,CAACO,MAAU;AACnE,QAAID,EAAM,eAAeC,CAAK,GAAG;AAC/B,YAAMC,IAAqBD,EAAM,MAAc,aAAa,IACtDE,IAAeD,IAAoB,GAAGV,CAAS,IAAIU,CAAiB,KAAKV;AAE/E,aAAOQ,EAAM,aAAaC,GAAkC;AAAA,QAC1D,WAAWE;AAAA,MAAA,CACZ;AAAA,IACH;AACA,WAAOF;AAAA,EACT,CAAC;AAED,2BAAQ,OAAA,EAAI,WAAWH,GAAU,GAAGD,GAAO,UAAAE,GAAqB;AAClE;"}
|
package/dist/components/Kbd.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
const k = {
|
|
3
|
-
xs:
|
|
4
|
-
sm:
|
|
5
|
-
md:
|
|
6
|
-
lg:
|
|
7
|
-
xl:
|
|
8
|
-
},
|
|
9
|
-
size:
|
|
10
|
-
children:
|
|
11
|
-
className:
|
|
12
|
-
...
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
const c = "kbd", l = "kbd-xs", m = "kbd-sm", e = "kbd-md", k = "kbd-lg", K = "kbd-xl", r = {
|
|
3
|
+
xs: l,
|
|
4
|
+
sm: m,
|
|
5
|
+
md: e,
|
|
6
|
+
lg: k,
|
|
7
|
+
xl: K
|
|
8
|
+
}, a = ({
|
|
9
|
+
size: d,
|
|
10
|
+
children: s,
|
|
11
|
+
className: o = "",
|
|
12
|
+
...b
|
|
13
13
|
}) => {
|
|
14
|
-
const
|
|
15
|
-
return /* @__PURE__ */
|
|
14
|
+
const t = [c, d ? r[d] : "", o].filter(Boolean).join(" ");
|
|
15
|
+
return /* @__PURE__ */ n("kbd", { className: t, ...b, children: s });
|
|
16
16
|
};
|
|
17
17
|
export {
|
|
18
|
-
|
|
18
|
+
a as Kbd
|
|
19
19
|
};
|
|
20
20
|
//# sourceMappingURL=Kbd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Kbd.js","sources":["../../src/components/Kbd.tsx"],"sourcesContent":["import React from 'react'\n\nexport type KbdSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n\nexport interface KbdProps extends React.HTMLAttributes<HTMLElement> {\n /** Size of the kbd */\n size?: KbdSize\n /** Key content */\n children?: React.ReactNode\n}\n\nconst sizeClasses: Record<KbdSize, string> = {\n xs:
|
|
1
|
+
{"version":3,"file":"Kbd.js","sources":["../../src/components/Kbd.tsx"],"sourcesContent":["import React from 'react'\n\n// DaisyUI classes\nconst dKbd = 'kbd'\nconst dKbdXs = 'kbd-xs'\nconst dKbdSm = 'kbd-sm'\nconst dKbdMd = 'kbd-md'\nconst dKbdLg = 'kbd-lg'\nconst dKbdXl = 'kbd-xl'\n\nexport type KbdSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n\nexport interface KbdProps extends React.HTMLAttributes<HTMLElement> {\n /** Size of the kbd */\n size?: KbdSize\n /** Key content */\n children?: React.ReactNode\n}\n\nconst sizeClasses: Record<KbdSize, string> = {\n xs: dKbdXs,\n sm: dKbdSm,\n md: dKbdMd,\n lg: dKbdLg,\n xl: dKbdXl,\n}\n\nexport const Kbd: React.FC<KbdProps> = ({\n size,\n children,\n className = '',\n ...rest\n}) => {\n const classes = [dKbd, size ? sizeClasses[size] : '', className]\n .filter(Boolean)\n .join(' ')\n\n return (\n <kbd className={classes} {...rest}>\n {children}\n </kbd>\n )\n}\n"],"names":["dKbd","dKbdXs","dKbdSm","dKbdMd","dKbdLg","dKbdXl","sizeClasses","Kbd","size","children","className","rest","classes"],"mappings":";AAGA,MAAMA,IAAO,OACPC,IAAS,UACTC,IAAS,UACTC,IAAS,UACTC,IAAS,UACTC,IAAS,UAWTC,IAAuC;AAAA,EAC3C,IAAIL;AAAA,EACJ,IAAIC;AAAA,EACJ,IAAIC;AAAA,EACJ,IAAIC;AAAA,EACJ,IAAIC;AACN,GAEaE,IAA0B,CAAC;AAAA,EACtC,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAU,CAACZ,GAAMQ,IAAOF,EAAYE,CAAI,IAAI,IAAIE,CAAS,EAC5D,OAAO,OAAO,EACd,KAAK,GAAG;AAEX,2BACG,OAAA,EAAI,WAAWE,GAAU,GAAGD,GAC1B,UAAAF,GACH;AAEJ;"}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { jsx as a, jsxs as
|
|
2
|
-
import
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
return
|
|
1
|
+
import { jsx as a, jsxs as Z } from "react/jsx-runtime";
|
|
2
|
+
import C, { forwardRef as y, useContext as _, createContext as q, useState as S, useEffect as G, useCallback as J } from "react";
|
|
3
|
+
const U = "bg-base-100", X = "bg-base-200", v = "bg-base-300", E = q(null);
|
|
4
|
+
function ae() {
|
|
5
|
+
return _(E);
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const b = y(
|
|
8
8
|
({ children: s, hasSider: o, className: n = "", "data-testid": e, ...l }, r) => {
|
|
9
|
-
const d =
|
|
10
|
-
(t) =>
|
|
9
|
+
const d = C.Children.toArray(s), f = d.some(
|
|
10
|
+
(t) => C.isValidElement(t) && t.type.displayName === "LayoutSider"
|
|
11
11
|
), c = o ?? f, p = [
|
|
12
12
|
"flex",
|
|
13
13
|
"min-h-0",
|
|
14
14
|
c ? "flex-row" : "flex-col",
|
|
15
15
|
n
|
|
16
|
-
].filter(Boolean).join(" "),
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
20
|
-
return
|
|
21
|
-
className: `flex-1 ${
|
|
16
|
+
].filter(Boolean).join(" "), g = c ? d.map((t) => {
|
|
17
|
+
if (C.isValidElement(t) && (t.type === b || t.type.displayName === "LayoutRoot") && t.type.displayName !== "LayoutSider") {
|
|
18
|
+
const N = t.props.className || "";
|
|
19
|
+
if (!N.includes("flex-1"))
|
|
20
|
+
return C.cloneElement(t, {
|
|
21
|
+
className: `flex-1 ${N}`.trim()
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
return t;
|
|
25
25
|
}) : s;
|
|
26
|
-
return /* @__PURE__ */ a("div", { ref: r, className: p, "data-testid": e, ...l, children:
|
|
26
|
+
return /* @__PURE__ */ a("div", { ref: r, className: p, "data-testid": e, ...l, children: g });
|
|
27
27
|
}
|
|
28
28
|
);
|
|
29
|
-
|
|
30
|
-
const
|
|
29
|
+
b.displayName = "LayoutRoot";
|
|
30
|
+
const $ = y(
|
|
31
31
|
({ children: s, className: o = "", "data-testid": n, ...e }, l) => {
|
|
32
32
|
const r = [
|
|
33
33
|
"flex",
|
|
34
34
|
"items-center",
|
|
35
35
|
"px-6",
|
|
36
36
|
"h-16",
|
|
37
|
-
|
|
37
|
+
v,
|
|
38
38
|
"flex-shrink-0",
|
|
39
39
|
o
|
|
40
40
|
].filter(Boolean).join(" ");
|
|
41
41
|
return /* @__PURE__ */ a("header", { ref: l, className: r, "data-testid": n, ...e, children: s });
|
|
42
42
|
}
|
|
43
43
|
);
|
|
44
|
-
|
|
44
|
+
$.displayName = "LayoutHeader";
|
|
45
45
|
const R = y(
|
|
46
46
|
({ children: s, className: o = "", "data-testid": n, ...e }, l) => {
|
|
47
47
|
const r = [
|
|
48
48
|
"px-6",
|
|
49
49
|
"py-4",
|
|
50
50
|
"text-center",
|
|
51
|
-
|
|
51
|
+
v,
|
|
52
52
|
"flex-shrink-0",
|
|
53
53
|
o
|
|
54
54
|
].filter(Boolean).join(" ");
|
|
@@ -56,20 +56,20 @@ const R = y(
|
|
|
56
56
|
}
|
|
57
57
|
);
|
|
58
58
|
R.displayName = "LayoutFooter";
|
|
59
|
-
const
|
|
59
|
+
const A = y(
|
|
60
60
|
({ children: s, className: o = "", "data-testid": n, ...e }, l) => {
|
|
61
61
|
const r = ["flex-1", "min-h-0", "overflow-auto", o].filter(Boolean).join(" ");
|
|
62
62
|
return /* @__PURE__ */ a("main", { ref: l, className: r, "data-testid": n, ...e, children: s });
|
|
63
63
|
}
|
|
64
64
|
);
|
|
65
|
-
|
|
66
|
-
const
|
|
65
|
+
A.displayName = "LayoutContent";
|
|
66
|
+
const Y = {
|
|
67
67
|
sm: "(max-width: 639px)",
|
|
68
68
|
md: "(max-width: 767px)",
|
|
69
69
|
lg: "(max-width: 1023px)",
|
|
70
70
|
xl: "(max-width: 1279px)",
|
|
71
71
|
"2xl": "(max-width: 1535px)"
|
|
72
|
-
},
|
|
72
|
+
}, M = y(
|
|
73
73
|
({
|
|
74
74
|
children: s,
|
|
75
75
|
width: o = 200,
|
|
@@ -81,49 +81,49 @@ const J = {
|
|
|
81
81
|
trigger: f,
|
|
82
82
|
breakpoint: c,
|
|
83
83
|
onBreakpoint: p,
|
|
84
|
-
reverseArrow:
|
|
84
|
+
reverseArrow: g = !1,
|
|
85
85
|
theme: t = "dark",
|
|
86
|
-
zeroWidthTriggerStyle:
|
|
87
|
-
className:
|
|
88
|
-
style:
|
|
86
|
+
zeroWidthTriggerStyle: N,
|
|
87
|
+
className: T = "",
|
|
88
|
+
style: W,
|
|
89
89
|
"data-testid": x,
|
|
90
|
-
...
|
|
91
|
-
},
|
|
92
|
-
const [
|
|
93
|
-
|
|
90
|
+
...z
|
|
91
|
+
}, F) => {
|
|
92
|
+
const [H, w] = S(l), [k, P] = S(!1), i = e ?? H;
|
|
93
|
+
G(() => {
|
|
94
94
|
if (!c) return;
|
|
95
|
-
const m = window.matchMedia(
|
|
96
|
-
const h =
|
|
97
|
-
|
|
95
|
+
const m = window.matchMedia(Y[c]), L = (Q) => {
|
|
96
|
+
const h = Q.matches;
|
|
97
|
+
P(h), p?.(h), e === void 0 && w(h), h !== k && d?.(h, "responsive");
|
|
98
98
|
};
|
|
99
|
-
return
|
|
100
|
-
}, [c, p, e, d,
|
|
101
|
-
const
|
|
99
|
+
return L(m), m.addEventListener("change", L), () => m.removeEventListener("change", L);
|
|
100
|
+
}, [c, p, e, d, k]);
|
|
101
|
+
const B = J(() => {
|
|
102
102
|
const m = !i;
|
|
103
|
-
e === void 0 &&
|
|
104
|
-
}, [i, e, d]), u = i ? n : o, j = u === 0 || u === "0" || u === "0px",
|
|
103
|
+
e === void 0 && w(m), d?.(m, "clickTrigger");
|
|
104
|
+
}, [i, e, d]), u = i ? n : o, j = u === 0 || u === "0" || u === "0px", O = [
|
|
105
105
|
"flex",
|
|
106
106
|
"flex-col",
|
|
107
107
|
{
|
|
108
|
-
light:
|
|
109
|
-
dark:
|
|
108
|
+
light: U,
|
|
109
|
+
dark: X
|
|
110
110
|
}[t],
|
|
111
111
|
"flex-shrink-0",
|
|
112
112
|
"transition-all",
|
|
113
113
|
"duration-200",
|
|
114
114
|
"relative",
|
|
115
|
-
|
|
116
|
-
].filter(Boolean).join(" "),
|
|
115
|
+
T
|
|
116
|
+
].filter(Boolean).join(" "), V = () => g ? i ? "" : "rotate-180" : i ? "rotate-180" : "", D = r && f !== null && /* @__PURE__ */ a(
|
|
117
117
|
"button",
|
|
118
118
|
{
|
|
119
|
-
onClick:
|
|
120
|
-
className:
|
|
119
|
+
onClick: B,
|
|
120
|
+
className: `flex items-center justify-center h-10 w-full ${v} hover:bg-base-content/10 transition-colors`,
|
|
121
121
|
"aria-label": i ? "Expand sidebar" : "Collapse sidebar",
|
|
122
122
|
"data-testid": x ? `${x}-trigger` : void 0,
|
|
123
123
|
children: /* @__PURE__ */ a(
|
|
124
124
|
"svg",
|
|
125
125
|
{
|
|
126
|
-
className: `w-4 h-4 transition-transform ${
|
|
126
|
+
className: `w-4 h-4 transition-transform ${V()}`,
|
|
127
127
|
fill: "none",
|
|
128
128
|
viewBox: "0 0 24 24",
|
|
129
129
|
stroke: "currentColor",
|
|
@@ -131,18 +131,18 @@ const J = {
|
|
|
131
131
|
}
|
|
132
132
|
)
|
|
133
133
|
}
|
|
134
|
-
),
|
|
134
|
+
), K = r && j && i && /* @__PURE__ */ a(
|
|
135
135
|
"button",
|
|
136
136
|
{
|
|
137
|
-
onClick:
|
|
138
|
-
className:
|
|
137
|
+
onClick: B,
|
|
138
|
+
className: `absolute top-1/2 -translate-y-1/2 right-0 translate-x-full w-6 h-12 flex items-center justify-center ${v} hover:bg-base-content/10 transition-colors rounded-r z-10`,
|
|
139
139
|
"aria-label": "Expand sidebar",
|
|
140
|
-
style:
|
|
140
|
+
style: N,
|
|
141
141
|
"data-testid": x ? `${x}-zero-trigger` : void 0,
|
|
142
142
|
children: /* @__PURE__ */ a(
|
|
143
143
|
"svg",
|
|
144
144
|
{
|
|
145
|
-
className: `w-3 h-3 ${
|
|
145
|
+
className: `w-3 h-3 ${g ? "rotate-180" : ""}`,
|
|
146
146
|
fill: "none",
|
|
147
147
|
viewBox: "0 0 24 24",
|
|
148
148
|
stroke: "currentColor",
|
|
@@ -151,38 +151,38 @@ const J = {
|
|
|
151
151
|
)
|
|
152
152
|
}
|
|
153
153
|
);
|
|
154
|
-
return /* @__PURE__ */ a(
|
|
154
|
+
return /* @__PURE__ */ a(E.Provider, { value: { collapsed: i, collapsedWidth: n, width: o }, children: /* @__PURE__ */ Z(
|
|
155
155
|
"aside",
|
|
156
156
|
{
|
|
157
|
-
ref:
|
|
158
|
-
className:
|
|
157
|
+
ref: F,
|
|
158
|
+
className: O,
|
|
159
159
|
style: {
|
|
160
160
|
width: typeof u == "number" ? `${u}px` : u,
|
|
161
|
-
...
|
|
161
|
+
...W
|
|
162
162
|
},
|
|
163
163
|
"data-collapsed": i,
|
|
164
164
|
"data-theme": t,
|
|
165
165
|
"data-testid": x,
|
|
166
166
|
"aria-expanded": !i,
|
|
167
|
-
...
|
|
167
|
+
...z,
|
|
168
168
|
children: [
|
|
169
169
|
/* @__PURE__ */ a("div", { className: "flex-1 overflow-auto", children: s }),
|
|
170
|
-
!j && f !== null && (f ??
|
|
171
|
-
|
|
170
|
+
!j && f !== null && (f ?? D),
|
|
171
|
+
K
|
|
172
172
|
]
|
|
173
173
|
}
|
|
174
174
|
) });
|
|
175
175
|
}
|
|
176
176
|
);
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
Header:
|
|
177
|
+
M.displayName = "LayoutSider";
|
|
178
|
+
const se = Object.assign(b, {
|
|
179
|
+
Header: $,
|
|
180
180
|
Footer: R,
|
|
181
|
-
Content:
|
|
182
|
-
Sider:
|
|
181
|
+
Content: A,
|
|
182
|
+
Sider: M
|
|
183
183
|
});
|
|
184
184
|
export {
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
se as Layout,
|
|
186
|
+
ae as useSiderContext
|
|
187
187
|
};
|
|
188
188
|
//# sourceMappingURL=Layout.js.map
|