dishui 0.0.64 → 0.0.65
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/Badge/index.js +12 -9
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Button/index.js +43 -40
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Card/index.d.ts +11 -0
- package/dist/components/Card/index.js +62 -37
- package/dist/components/Card/index.js.map +1 -1
- package/dist/components/Chart/Chart.js.map +1 -1
- package/dist/components/Checkbox/index.js +32 -30
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Demo/index.js.map +1 -1
- package/dist/components/EmptyState/index.d.ts +4 -1
- package/dist/components/EmptyState/index.js +3 -3
- package/dist/components/EmptyState/index.js.map +1 -1
- package/dist/components/FileUploader/DropZone.js.map +1 -1
- package/dist/components/FileUploader/FileItem.js.map +1 -1
- package/dist/components/FileUploader/FileUploader.js.map +1 -1
- package/dist/components/FileUploader/UploadQueue.js.map +1 -1
- package/dist/components/Input/index.js +30 -30
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/Label/index.js +41 -40
- package/dist/components/Label/index.js.map +1 -1
- package/dist/components/List/index.js +47 -32
- package/dist/components/List/index.js.map +1 -1
- package/dist/components/Markdown/Markdown.js +61 -57
- package/dist/components/Markdown/Markdown.js.map +1 -1
- package/dist/components/Markdown/markdownComponents.js +49 -49
- package/dist/components/Markdown/markdownComponents.js.map +1 -1
- package/dist/components/Modal/index.d.ts +7 -3
- package/dist/components/Modal/index.js +77 -65
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Page/index.d.ts +58 -0
- package/dist/components/Page/index.js +74 -0
- package/dist/components/Page/index.js.map +1 -0
- package/dist/components/PageHeader/index.js.map +1 -1
- package/dist/components/Select/index.js +0 -3
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/SidebarToggleButton/index.js.map +1 -1
- package/dist/components/StatCard/index.d.ts +3 -1
- package/dist/components/StatCard/index.js +39 -11
- package/dist/components/StatCard/index.js.map +1 -1
- package/dist/components/Table/index.js +103 -85
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +19 -5
- package/dist/components/Tabs/index.js +32 -13
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Tree/Tree.js.map +1 -1
- package/dist/components/pro/ArticleContextMenu/index.js.map +1 -1
- package/dist/components/pro/ArticleControl/ArticleControl2.js.map +1 -1
- package/dist/components/pro/CodeEditor/editors/CodeEditor.js +141 -134
- package/dist/components/pro/CodeEditor/editors/CodeEditor.js.map +1 -1
- package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js +81 -78
- package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js.map +1 -1
- package/dist/components/pro/CodeEditor/panels/FootnotePanel.js.map +1 -1
- package/dist/components/pro/CodeEditor/panels/HistoryPanel.js.map +1 -1
- package/dist/components/pro/CodeEditor/panels/OutlinePanel.js.map +1 -1
- package/dist/components/pro/CodeEditor/panels/TableOfContentsPanel.js.map +1 -1
- package/dist/components/pro/CodeEditor/panels/VariablePanel.js.map +1 -1
- package/dist/components/pro/CodeEditor/themes.js +59 -59
- package/dist/components/pro/CodeEditor/themes.js.map +1 -1
- package/dist/components/pro/DataTable/DataTable.js +49 -48
- package/dist/components/pro/DataTable/DataTable.js.map +1 -1
- package/dist/components/pro/DataTable/Filters.js +42 -42
- package/dist/components/pro/DataTable/Filters.js.map +1 -1
- package/dist/components/pro/DataTable/PivotPanel.js.map +1 -1
- package/dist/components/pro/DataTable/PivotView.js +35 -32
- package/dist/components/pro/DataTable/PivotView.js.map +1 -1
- package/dist/components/pro/DataTable/components/BulkActions.js.map +1 -1
- package/dist/components/pro/DataTable/components/ColumnSelector.js.map +1 -1
- package/dist/components/pro/DataTable/components/FilterBar.js.map +1 -1
- package/dist/components/pro/DataTable/components/TableBody.js.map +1 -1
- package/dist/components/pro/DataTable/components/TableHeader.js.map +1 -1
- package/dist/components/pro/DataTable/components/TablePagination.js.map +1 -1
- package/dist/components/pro/DataTable/components/TableToolbar.js.map +1 -1
- package/dist/components/pro/DataTable/pivotExtension.js.map +1 -1
- package/dist/components/pro/DataTable/rowDetailExtension.js.map +1 -1
- package/dist/components/pro/DataTable/tanstack-table.js +37 -37
- package/dist/components/pro/DataTable/tanstack-table.js.map +1 -1
- package/dist/components/pro/FileExplorer/Breadcrumb.js +53 -53
- package/dist/components/pro/FileExplorer/Breadcrumb.js.map +1 -1
- package/dist/components/pro/FileExplorer/CreateDialog.js.map +1 -1
- package/dist/components/pro/FileExplorer/FileExplorer.js.map +1 -1
- package/dist/components/pro/FileExplorer/FileIcon.js +22 -22
- package/dist/components/pro/FileExplorer/FileIcon.js.map +1 -1
- package/dist/components/pro/FileExplorer/GridView.js.map +1 -1
- package/dist/components/pro/FileExplorer/ListView.js.map +1 -1
- package/dist/components/pro/FileExplorer/Toolbar.js.map +1 -1
- package/dist/components/pro/Flow/Flow.js +496 -494
- package/dist/components/pro/Flow/Flow.js.map +1 -1
- package/dist/components/pro/Flow/FlowCanvas.js +916 -917
- package/dist/components/pro/Flow/FlowCanvas.js.map +1 -1
- package/dist/components/pro/Flow/context/FlowUIContext.js.map +1 -1
- package/dist/components/pro/Flow/edges/EdgeRenderer.js +59 -59
- package/dist/components/pro/Flow/edges/EdgeRenderer.js.map +1 -1
- package/dist/components/pro/Flow/hooks/useClipboard.js.map +1 -1
- package/dist/components/pro/Flow/hooks/useDeleteSelection.js.map +1 -1
- package/dist/components/pro/Flow/hooks/useEdgeMutations.js.map +1 -1
- package/dist/components/pro/Flow/hooks/useLayoutActions.js +9 -11
- package/dist/components/pro/Flow/hooks/useLayoutActions.js.map +1 -1
- package/dist/components/pro/Flow/hooks/useLineMutations.js.map +1 -1
- package/dist/components/pro/Flow/hooks/useMindMap.js.map +1 -1
- package/dist/components/pro/Flow/hooks/useNodeMutations.js.map +1 -1
- package/dist/components/pro/Flow/lines/FreehandTool.js +9 -9
- package/dist/components/pro/Flow/lines/FreehandTool.js.map +1 -1
- package/dist/components/pro/Flow/lines/LineRenderer.js +5 -5
- package/dist/components/pro/Flow/lines/LineRenderer.js.map +1 -1
- package/dist/components/pro/Flow/nodes/DataNodeView.js +113 -93
- package/dist/components/pro/Flow/nodes/DataNodeView.js.map +1 -1
- package/dist/components/pro/Flow/nodes/MediaContent.js.map +1 -1
- package/dist/components/pro/Flow/nodes/MediaOverlay.js.map +1 -1
- package/dist/components/pro/Flow/nodes/Model3DView.js +1 -1
- package/dist/components/pro/Flow/nodes/Model3DView.js.map +1 -1
- package/dist/components/pro/Flow/nodes/NodeRenderer.js +118 -118
- package/dist/components/pro/Flow/nodes/NodeRenderer.js.map +1 -1
- package/dist/components/pro/Flow/nodes/dataUtils.js.map +1 -1
- package/dist/components/pro/Flow/nodes/shapes.js +1 -3
- package/dist/components/pro/Flow/nodes/shapes.js.map +1 -1
- package/dist/components/pro/Flow/panels/AIPanel.js.map +1 -1
- package/dist/components/pro/Flow/panels/Breadcrumb.js.map +1 -1
- package/dist/components/pro/Flow/panels/ContextMenu.js.map +1 -1
- package/dist/components/pro/Flow/panels/DataInspectorSection.js.map +1 -1
- package/dist/components/pro/Flow/panels/ExpandableTextarea.js.map +1 -1
- package/dist/components/pro/Flow/panels/FlowPanelGroup.js.map +1 -1
- package/dist/components/pro/Flow/panels/FlowToolbar.js +97 -97
- package/dist/components/pro/Flow/panels/FlowToolbar.js.map +1 -1
- package/dist/components/pro/Flow/panels/InspectorPanel.js +57 -57
- package/dist/components/pro/Flow/panels/InspectorPanel.js.map +1 -1
- package/dist/components/pro/Flow/panels/OutlinePanel.js +26 -22
- package/dist/components/pro/Flow/panels/OutlinePanel.js.map +1 -1
- package/dist/components/pro/Flow/panels/PresentationMode.js +18 -16
- package/dist/components/pro/Flow/panels/PresentationMode.js.map +1 -1
- package/dist/components/pro/Flow/panels/ProjectTitle.js.map +1 -1
- package/dist/components/pro/Flow/panels/ShapePalette.js +109 -104
- package/dist/components/pro/Flow/panels/ShapePalette.js.map +1 -1
- package/dist/components/pro/Flow/panels/toolbarIcons.js.map +1 -1
- package/dist/components/pro/RichTextEditor/AIRewrite.js.map +1 -1
- package/dist/components/pro/RichTextEditor/BlockHandle.js.map +1 -1
- package/dist/components/pro/RichTextEditor/BubbleToolbar.js.map +1 -1
- package/dist/components/pro/RichTextEditor/CommentDialog.js.map +1 -1
- package/dist/components/pro/RichTextEditor/CommentPanel.js.map +1 -1
- package/dist/components/pro/RichTextEditor/CommentPopover.js.map +1 -1
- package/dist/components/pro/RichTextEditor/ContextMenu.js.map +1 -1
- package/dist/components/pro/RichTextEditor/RichTextEditor.js.map +1 -1
- package/dist/components/pro/RichTextEditor/SlashMenu.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/FloatingDialogMenu.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/MarkdownTemplates.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/SelectDropdown.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/TableOpsMenu.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/Toolbar.js.map +1 -1
- package/dist/components/pro/RichTextEditor/extensions/CodeBlockView.js.map +1 -1
- package/dist/components/pro/RichTextEditor/extensions/FloatingDialog.js.map +1 -1
- package/dist/components/pro/RichTextEditor/extensions/MarkdownBlock.js.map +1 -1
- package/dist/contexts/AppContext.js.map +1 -1
- package/dist/dishui.css +1 -1
- package/dist/hooks/useTableColumns.js +7 -8
- package/dist/hooks/useTableColumns.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +227 -221
- package/dist/layouts/MainLayout.js +22 -22
- package/dist/layouts/MainLayout.js.map +1 -1
- package/dist/layouts/Navbar.js.map +1 -1
- package/dist/layouts/Sidebar.js +94 -73
- package/dist/layouts/Sidebar.js.map +1 -1
- package/dist/layouts/headbar/Headbar.js.map +1 -1
- package/dist/layouts/headbar/HeadbarLangSwitcher.js.map +1 -1
- package/dist/layouts/headbar/HeadbarSearch.js.map +1 -1
- package/dist/layouts/headbar/HeadbarThemeSwitcher.js +11 -11
- package/dist/layouts/headbar/HeadbarThemeSwitcher.js.map +1 -1
- package/dist/layouts/headbar/HeadbarTitle.js.map +1 -1
- package/dist/utils/i18n.js +10 -10
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/menu.js.map +1 -1
- package/dist/utils/routerBuilder.js +17 -15
- package/dist/utils/routerBuilder.js.map +1 -1
- package/dist/utils/themes.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import "react";
|
|
2
|
-
import { jsx as
|
|
3
|
-
var
|
|
4
|
-
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
var b = ({ children: o, variant: e = "primary", size: a = "sm", outline: r = !1, className: s = "" }) => {
|
|
4
|
+
const d = [
|
|
5
5
|
"badge",
|
|
6
6
|
e ? `badge-${e}` : "",
|
|
7
7
|
a ? `badge-${a}` : "",
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
].filter(Boolean).join(" ")
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
r ? "badge-outline" : "",
|
|
9
|
+
s
|
|
10
|
+
].filter(Boolean).join(" ");
|
|
11
|
+
return /* @__PURE__ */ t("div", {
|
|
12
|
+
className: d,
|
|
13
|
+
children: o
|
|
14
|
+
});
|
|
15
|
+
};
|
|
13
16
|
export {
|
|
14
|
-
|
|
17
|
+
b as default
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Badge/index.tsx"],"sourcesContent":["import React from 'react';\n\nexport type BadgeProps = {\n children: React.ReactNode;\n variant?: 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'ghost';\n size?: 'xs' | 'sm' | 'md' | 'lg';\n outline?: boolean;\n className?: string;\n};\n\nconst Badge: React.FC<BadgeProps> = ({\n children,\n variant = 'primary',\n size = 'sm',\n outline = false,\n className = '',\n}) => {\n const baseClass = 'badge';\n const variantClass = variant ? `badge-${variant}` : '';\n const sizeClass = size ? `badge-${size}` : '';\n const outlineClass = outline ? 'badge-outline' : '';\n \n const badgeClasses = [\n baseClass,\n variantClass,\n sizeClass,\n outlineClass,\n className\n ].filter(Boolean).join(' ');\n\n return (\n <div className={badgeClasses}>\n {children}\n </div>\n );\n};\n\nexport default Badge; "],"mappings":";;AAUA,IAAM,IAAA,CAA+B,EACnC,UAAA,GACA,SAAA,IAAU,WACV,MAAA,IAAO,MACP,SAAA,IAAU,IACV,WAAA,IAAY,GAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Badge/index.tsx"],"sourcesContent":["import React from 'react';\n\nexport type BadgeProps = {\n children: React.ReactNode;\n variant?: 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'ghost';\n size?: 'xs' | 'sm' | 'md' | 'lg';\n outline?: boolean;\n className?: string;\n};\n\nconst Badge: React.FC<BadgeProps> = ({\n children,\n variant = 'primary',\n size = 'sm',\n outline = false,\n className = '',\n}) => {\n const baseClass = 'badge';\n const variantClass = variant ? `badge-${variant}` : '';\n const sizeClass = size ? `badge-${size}` : '';\n const outlineClass = outline ? 'badge-outline' : '';\n \n const badgeClasses = [\n baseClass,\n variantClass,\n sizeClass,\n outlineClass,\n className\n ].filter(Boolean).join(' ');\n\n return (\n <div className={badgeClasses}>\n {children}\n </div>\n );\n};\n\nexport default Badge; "],"mappings":";;AAUA,IAAM,IAAA,CAA+B,EACnC,UAAA,GACA,SAAA,IAAU,WACV,MAAA,IAAO,MACP,SAAA,IAAU,IACV,WAAA,IAAY,GAAA,MACR;AAMJ,QAAM,IAAe;AAAA,IACnB;AAAA,IALmB,IAAU,SAAS,CAAA,KAAY;AAAA,IAClC,IAAO,SAAS,CAAA,KAAS;AAAA,IACtB,IAAU,kBAAkB;AAAA,IAO/C;AAAA,EACF,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAE1B,SACE,gBAAA,EAAC,OAAD;AAAA,IAAK,WAAW;AAAA,IACb,UAAA;AAAA,EACE,CAAA;AAET"}
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import $, { useCallback as
|
|
2
|
-
import { Fragment as
|
|
3
|
-
var
|
|
4
|
-
const [B, q] = E(V), [k, L] = E(0), n =
|
|
1
|
+
import $, { useCallback as H, useState as E } from "react";
|
|
2
|
+
import { Fragment as J, jsx as p, jsxs as I } from "react/jsx-runtime";
|
|
3
|
+
var K = ({ children: f, variant: a = "primary", size: c = "sm", outline: t = !1, dash: j = !1, soft: s = !1, active: v = !1, disabled: o = !1, wide: m = !1, block: h = !1, square: C = !1, circle: N = !1, leftSection: e, rightSection: l, onClick: i, type: g, className: R = "", states: r, initialStateIndex: V = 0, onStateChange: x }) => {
|
|
4
|
+
const [B, q] = E(V), [k, L] = E(0), n = r && r.length > 0, b = n ? r[B] : null, W = H(() => {
|
|
5
5
|
if (n) {
|
|
6
|
-
const G = k + 1, u = (B + 1) %
|
|
7
|
-
L(G), q(u), x && x(
|
|
6
|
+
const G = k + 1, u = (B + 1) % r.length, D = r[u];
|
|
7
|
+
L(G), q(u), x && x(D, G, u);
|
|
8
8
|
}
|
|
9
9
|
i && i();
|
|
10
10
|
}, [
|
|
11
11
|
n,
|
|
12
|
-
|
|
12
|
+
r,
|
|
13
13
|
B,
|
|
14
14
|
k,
|
|
15
15
|
x,
|
|
16
16
|
i
|
|
17
|
-
]), w =
|
|
17
|
+
]), w = b?.variant || a, z = n ? /* @__PURE__ */ I(J, { children: [b?.icon && /* @__PURE__ */ p("span", {
|
|
18
18
|
className: "mr-1",
|
|
19
|
-
children:
|
|
20
|
-
}),
|
|
19
|
+
children: b.icon
|
|
20
|
+
}), b?.label] }) : f, A = [
|
|
21
|
+
"btn",
|
|
22
|
+
w ? `btn-${w}` : "",
|
|
23
|
+
c ? `btn-${c}` : "",
|
|
24
|
+
t ? "btn-outline" : "",
|
|
25
|
+
j ? "btn-dash" : "",
|
|
26
|
+
s ? "btn-soft" : "",
|
|
27
|
+
v || n ? "btn-active" : "",
|
|
28
|
+
m ? "btn-wide" : "",
|
|
29
|
+
h ? "btn-block" : "",
|
|
30
|
+
C ? "btn-square" : "",
|
|
31
|
+
N ? "btn-circle" : "",
|
|
32
|
+
R
|
|
33
|
+
].filter(Boolean).join(" ");
|
|
21
34
|
return /* @__PURE__ */ I("button", {
|
|
22
35
|
type: g,
|
|
23
|
-
className:
|
|
24
|
-
"btn",
|
|
25
|
-
w ? `btn-${w}` : "",
|
|
26
|
-
p ? `btn-${p}` : "",
|
|
27
|
-
t ? "btn-outline" : "",
|
|
28
|
-
j ? "btn-dash" : "",
|
|
29
|
-
s ? "btn-soft" : "",
|
|
30
|
-
v || n ? "btn-active" : "",
|
|
31
|
-
r ? "btn-wide" : "",
|
|
32
|
-
h ? "btn-block" : "",
|
|
33
|
-
C ? "btn-square" : "",
|
|
34
|
-
N ? "btn-circle" : "",
|
|
35
|
-
R
|
|
36
|
-
].filter(Boolean).join(" "),
|
|
36
|
+
className: A,
|
|
37
37
|
disabled: o,
|
|
38
38
|
onClick: W,
|
|
39
|
-
title: n ? `当前状态: ${
|
|
39
|
+
title: n ? `当前状态: ${b?.key} (点击次数: ${k})` : void 0,
|
|
40
40
|
children: [
|
|
41
|
-
!n && e && /* @__PURE__ */
|
|
41
|
+
!n && e && /* @__PURE__ */ p("span", {
|
|
42
42
|
className: "mr-2",
|
|
43
43
|
children: e
|
|
44
44
|
}),
|
|
45
45
|
z,
|
|
46
|
-
!n && l && /* @__PURE__ */
|
|
46
|
+
!n && l && /* @__PURE__ */ p("span", {
|
|
47
47
|
className: "ml-2",
|
|
48
48
|
children: l
|
|
49
49
|
})
|
|
50
50
|
]
|
|
51
51
|
});
|
|
52
|
-
},
|
|
52
|
+
}, M = ({ children: f, vertical: a = !1, className: c = "", rounded: t = "none", radius: j = "full", roundedStyle: s }) => {
|
|
53
53
|
const v = [
|
|
54
54
|
"join",
|
|
55
55
|
a ? "join-vertical" : "join-horizontal",
|
|
56
|
-
|
|
56
|
+
c
|
|
57
57
|
].filter(Boolean).join(" "), o = t !== "none" ? "full" : j;
|
|
58
|
-
return /* @__PURE__ */
|
|
58
|
+
return /* @__PURE__ */ p("div", {
|
|
59
59
|
className: v,
|
|
60
|
-
children: $.Children.map(f, (
|
|
61
|
-
if (!$.isValidElement(
|
|
62
|
-
const C =
|
|
60
|
+
children: $.Children.map(f, (m, h) => {
|
|
61
|
+
if (!$.isValidElement(m)) return m;
|
|
62
|
+
const C = m, N = C.props.className || "", e = h === 0, l = h === $.Children.count(f) - 1;
|
|
63
63
|
let i = "";
|
|
64
64
|
s ? a ? (t === "left" || t === "top") && e && s.top ? i = s.top : (t === "right" || t === "bottom") && l && s.bottom ? i = s.bottom : t === "both" && (e && s.top && (i = s.top), l && s.bottom && (i = s.bottom)) : (t === "left" || t === "top") && e && s.left ? i = s.left : (t === "right" || t === "bottom") && l && s.right ? i = s.right : t === "both" && (e && s.left && (i = s.left), l && s.right && (i = s.right)) : a ? t === "left" || t === "top" ? e && (i = `rounded-t-${o}`) : t === "right" || t === "bottom" ? l && (i = `rounded-b-${o}`) : t === "both" && (e && (i = `rounded-t-${o}`), l && (i = `rounded-b-${o}`)) : t === "left" || t === "top" ? e && (i = `rounded-l-${o}`) : t === "right" || t === "bottom" ? l && (i = `rounded-r-${o}`) : t === "both" && (e && (i = `rounded-l-${o}`), l && (i = `rounded-r-${o}`));
|
|
65
65
|
const g = `${N} join-item ${i}`.trim();
|
|
66
66
|
return $.cloneElement(C, { className: g });
|
|
67
67
|
})
|
|
68
68
|
});
|
|
69
|
-
},
|
|
70
|
-
|
|
69
|
+
}, O = ({ children: f, className: a = "" }) => {
|
|
70
|
+
const c = [
|
|
71
71
|
"join-item",
|
|
72
72
|
"flex",
|
|
73
73
|
"items-center",
|
|
@@ -76,11 +76,14 @@ var J = ({ children: f, variant: a = "primary", size: p = "sm", outline: t = !1,
|
|
|
76
76
|
"border",
|
|
77
77
|
"border-base-300",
|
|
78
78
|
a
|
|
79
|
-
].filter(Boolean).join(" ")
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
].filter(Boolean).join(" ");
|
|
80
|
+
return /* @__PURE__ */ p("div", {
|
|
81
|
+
className: c,
|
|
82
|
+
children: f
|
|
83
|
+
});
|
|
84
|
+
}, F = K;
|
|
85
|
+
F.Group = M;
|
|
86
|
+
F.GroupSection = O;
|
|
84
87
|
export {
|
|
85
88
|
F as default
|
|
86
89
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Button/index.tsx"],"sourcesContent":["import React, { ReactElement, useState, useCallback } from 'react';\n\n// 状态项定义\nexport type ButtonState = {\n label: string; // 显示的字符/文本\n key: string; // 状态的唯一标识\n variant?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'ghost' | 'link';\n icon?: React.ReactNode; // 可选的图标\n};\n\nexport type ButtonProps = {\n children?: React.ReactNode;\n variant?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'ghost' | 'link';\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n outline?: boolean;\n dash?: boolean;\n soft?: boolean;\n active?: boolean;\n disabled?: boolean;\n wide?: boolean;\n block?: boolean;\n square?: boolean;\n circle?: boolean;\n leftSection?: React.ReactNode;\n rightSection?: React.ReactNode;\n onClick?: () => void;\n /** 原生 button type;不传时保持浏览器默认行为(表单内默认 submit) */\n type?: 'button' | 'submit' | 'reset';\n className?: string;\n\n // 状态切换相关\n states?: ButtonState[]; // 状态列表\n initialStateIndex?: number; // 初始状态索引\n onStateChange?: (state: ButtonState, clickCount: number, stateIndex: number) => void; // 状态改变回调\n};\n\nconst Button = ({\n children,\n variant = 'primary',\n size = 'sm',\n outline = false,\n dash = false,\n soft = false,\n active = false,\n disabled = false,\n wide = false,\n block = false,\n square = false,\n circle = false,\n leftSection,\n rightSection,\n onClick,\n type,\n className = '',\n states,\n initialStateIndex = 0,\n onStateChange,\n}: ButtonProps) => {\n // 状态管理\n const [currentStateIndex, setCurrentStateIndex] = useState(initialStateIndex);\n const [clickCount, setClickCount] = useState(0);\n\n // 是否是状态按钮\n const isStateful = states && states.length > 0;\n\n // 获取当前状态\n const currentState = isStateful ? states[currentStateIndex] : null;\n\n // 处理点击\n const handleClick = useCallback(() => {\n if (isStateful) {\n const newClickCount = clickCount + 1;\n const newStateIndex = (currentStateIndex + 1) % states.length;\n const newState = states[newStateIndex];\n\n setClickCount(newClickCount);\n setCurrentStateIndex(newStateIndex);\n\n // 调用状态改变回调\n if (onStateChange) {\n onStateChange(newState, newClickCount, newStateIndex);\n }\n }\n\n // 调用原始 onClick\n if (onClick) {\n onClick();\n }\n }, [isStateful, states, currentStateIndex, clickCount, onStateChange, onClick]);\n\n // 确定使用的 variant\n const effectiveVariant = currentState?.variant || variant;\n\n // 确定显示的内容\n const displayContent = isStateful ? (\n <>\n {currentState?.icon && <span className=\"mr-1\">{currentState.icon}</span>}\n {currentState?.label}\n </>\n ) : children;\n\n const baseClass = 'btn';\n const variantClass = effectiveVariant ? `btn-${effectiveVariant}` : '';\n const sizeClass = size ? `btn-${size}` : '';\n const outlineClass = outline ? 'btn-outline' : '';\n const dashClass = dash ? 'btn-dash' : '';\n const softClass = soft ? 'btn-soft' : '';\n const activeClass = active || isStateful ? 'btn-active' : '';\n const wideClass = wide ? 'btn-wide' : '';\n const blockClass = block ? 'btn-block' : '';\n const squareClass = square ? 'btn-square' : '';\n const circleClass = circle ? 'btn-circle' : '';\n\n const buttonClasses = [\n baseClass,\n variantClass,\n sizeClass,\n outlineClass,\n dashClass,\n softClass,\n activeClass,\n wideClass,\n blockClass,\n squareClass,\n circleClass,\n className\n ].filter(Boolean).join(' ');\n\n return (\n <button\n type={type}\n className={buttonClasses}\n disabled={disabled}\n onClick={handleClick}\n title={isStateful ? `当前状态: ${currentState?.key} (点击次数: ${clickCount})` : undefined}\n >\n {!isStateful && leftSection && <span className=\"mr-2\">{leftSection}</span>}\n {displayContent}\n {!isStateful && rightSection && <span className=\"ml-2\">{rightSection}</span>}\n </button>\n );\n};\n\n// Button.Group 组件\nexport type ButtonGroupProps = {\n children: React.ReactNode;\n vertical?: boolean;\n className?: string;\n rounded?: 'left' | 'right' | 'both' | 'none' | 'top' | 'bottom';\n radius?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full';\n roundedStyle?: {\n left?: string;\n right?: string;\n top?: string;\n bottom?: string;\n };\n};\n\nconst ButtonGroup = ({\n children,\n vertical = false,\n className = '',\n rounded = 'none',\n radius = 'full',\n roundedStyle,\n}: ButtonGroupProps) => {\n const joinClasses = [\n 'join',\n vertical ? 'join-vertical' : 'join-horizontal',\n className\n ].filter(Boolean).join(' ');\n\n // 当rounded不为'none'时,强制使用'full'作为radius值\n const effectiveRadius = rounded !== 'none' ? 'full' : radius;\n\n return (\n <div className={joinClasses}>\n {React.Children.map(children, (child, index) => {\n // 只处理有效的React元素\n if (!React.isValidElement(child)) return child;\n\n const childElement = child as ReactElement<{ className?: string }>;\n const childClassName = childElement.props.className || '';\n const isFirstChild = index === 0;\n const isLastChild = index === React.Children.count(children) - 1;\n\n // 根据rounded属性添加额外的圆角类\n let roundedClasses = '';\n\n if (roundedStyle) {\n // 使用自定义圆角样式\n if (vertical) {\n if ((rounded === 'left' || rounded === 'top') && isFirstChild && roundedStyle.top) {\n roundedClasses = roundedStyle.top;\n } else if ((rounded === 'right' || rounded === 'bottom') && isLastChild && roundedStyle.bottom) {\n roundedClasses = roundedStyle.bottom;\n } else if (rounded === 'both') {\n if (isFirstChild && roundedStyle.top) roundedClasses = roundedStyle.top;\n if (isLastChild && roundedStyle.bottom) roundedClasses = roundedStyle.bottom;\n }\n } else {\n if ((rounded === 'left' || rounded === 'top') && isFirstChild && roundedStyle.left) {\n roundedClasses = roundedStyle.left;\n } else if ((rounded === 'right' || rounded === 'bottom') && isLastChild && roundedStyle.right) {\n roundedClasses = roundedStyle.right;\n } else if (rounded === 'both') {\n if (isFirstChild && roundedStyle.left) roundedClasses = roundedStyle.left;\n if (isLastChild && roundedStyle.right) roundedClasses = roundedStyle.right;\n }\n }\n } else {\n // 使用默认的圆角大小\n if (vertical) {\n // 垂直布局时,圆角应用在上下方\n if (rounded === 'left' || rounded === 'top') {\n if (isFirstChild) roundedClasses = `rounded-t-${effectiveRadius}`;\n } else if (rounded === 'right' || rounded === 'bottom') {\n if (isLastChild) roundedClasses = `rounded-b-${effectiveRadius}`;\n } else if (rounded === 'both') {\n if (isFirstChild) roundedClasses = `rounded-t-${effectiveRadius}`;\n if (isLastChild) roundedClasses = `rounded-b-${effectiveRadius}`;\n }\n } else {\n // 水平布局时,圆角应用在左右方\n if (rounded === 'left' || rounded === 'top') {\n if (isFirstChild) roundedClasses = `rounded-l-${effectiveRadius}`;\n } else if (rounded === 'right' || rounded === 'bottom') {\n if (isLastChild) roundedClasses = `rounded-r-${effectiveRadius}`;\n } else if (rounded === 'both') {\n if (isFirstChild) roundedClasses = `rounded-l-${effectiveRadius}`;\n if (isLastChild) roundedClasses = `rounded-r-${effectiveRadius}`;\n }\n }\n }\n\n const newClassName = `${childClassName} join-item ${roundedClasses}`.trim();\n\n return React.cloneElement(childElement, {\n className: newClassName,\n });\n })}\n </div>\n );\n};\n\n// Button.GroupSection 组件\nexport type ButtonGroupSectionProps = {\n children: React.ReactNode;\n className?: string;\n};\n\nconst ButtonGroupSection = ({\n children,\n className = '',\n}: ButtonGroupSectionProps) => {\n const sectionClasses = [\n 'join-item',\n 'flex',\n 'items-center',\n 'px-4',\n 'bg-base-200',\n 'border',\n 'border-base-300',\n className\n ].filter(Boolean).join(' ');\n\n return (\n <div className={sectionClasses}>\n {children}\n </div>\n );\n};\n\n// 扩展Button组件,添加Group和GroupSection子组件\ninterface ButtonCompound extends React.FC<ButtonProps> {\n Group: React.FC<ButtonGroupProps>;\n GroupSection: React.FC<ButtonGroupSectionProps>;\n}\n\nconst ButtonWithCompounds = Button as ButtonCompound;\nButtonWithCompounds.Group = ButtonGroup;\nButtonWithCompounds.GroupSection = ButtonGroupSection;\n\nexport default ButtonWithCompounds; "],"mappings":";;AAoCA,IAAM,IAAA,CAAU,EACd,UAAA,GACA,SAAA,IAAU,WACV,MAAA,IAAO,MACP,SAAA,IAAU,IACV,MAAA,IAAO,IACP,MAAA,IAAO,IACP,QAAA,IAAS,IACT,UAAA,IAAW,IACX,MAAA,IAAO,IACP,OAAA,IAAQ,IACR,QAAA,IAAS,IACT,QAAA,IAAS,IACT,aAAA,GACA,cAAA,GACA,SAAA,GACA,MAAA,GACA,WAAA,IAAY,IACZ,QAAA,GACA,mBAAA,IAAoB,GACpB,eAAA,EAAA,MACiB;AAEjB,QAAM,CAAC,GAAmB,CAAA,IAAwB,EAAS,CAAiB,GACtE,CAAC,GAAY,CAAA,IAAiB,EAAS,CAAC,GAGxC,IAAa,KAAU,EAAO,SAAS,GAGvC,IAAe,IAAa,EAAO,CAAA,IAAqB,MAGxD,IAAc,EAAA,MAAkB;AACpC,QAAI,GAAY;AACd,YAAM,IAAgB,IAAa,GAC7B,KAAiB,IAAoB,KAAK,EAAO,QACjD,IAAW,EAAO,CAAA;AAExB,MAAA,EAAc,CAAa,GAC3B,EAAqB,CAAa,GAG9B,KACF,EAAc,GAAU,GAAe,CAAa;AAAA,IAExD;AAGA,IAAI,KACF,EAAQ;AAAA,EAEZ,GAAG;AAAA,IAAC;AAAA,IAAY;AAAA,IAAQ;AAAA,IAAmB;AAAA,IAAY;AAAA,IAAe;AAAA,EAAO,CAAC,GAGxE,IAAmB,GAAc,WAAW,GAG5C,IAAiB,IACrB,gBAAA,EAAA,GAAA,EAAA,UAAA,CACG,GAAc,QAAQ,gBAAA,EAAC,QAAD;AAAA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AAD;AAAA,EAAK,WAZgB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAAE,OAAO,OAAO,EAAE,KAAK,GAGL;AAAA,EACb,UAAA;AACE,CAAA,GAUH,IAAsB;AAC5B,EAAoB,QAAQ;AAC5B,EAAoB,eAAe"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Button/index.tsx"],"sourcesContent":["import React, { ReactElement, useState, useCallback } from 'react';\n\n// 状态项定义\nexport type ButtonState = {\n label: string; // 显示的字符/文本\n key: string; // 状态的唯一标识\n variant?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'ghost' | 'link';\n icon?: React.ReactNode; // 可选的图标\n};\n\nexport type ButtonProps = {\n children?: React.ReactNode;\n variant?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'ghost' | 'link';\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n outline?: boolean;\n dash?: boolean;\n soft?: boolean;\n active?: boolean;\n disabled?: boolean;\n wide?: boolean;\n block?: boolean;\n square?: boolean;\n circle?: boolean;\n leftSection?: React.ReactNode;\n rightSection?: React.ReactNode;\n onClick?: () => void;\n /** 原生 button type;不传时保持浏览器默认行为(表单内默认 submit) */\n type?: 'button' | 'submit' | 'reset';\n className?: string;\n\n // 状态切换相关\n states?: ButtonState[]; // 状态列表\n initialStateIndex?: number; // 初始状态索引\n onStateChange?: (state: ButtonState, clickCount: number, stateIndex: number) => void; // 状态改变回调\n};\n\nconst Button = ({\n children,\n variant = 'primary',\n size = 'sm',\n outline = false,\n dash = false,\n soft = false,\n active = false,\n disabled = false,\n wide = false,\n block = false,\n square = false,\n circle = false,\n leftSection,\n rightSection,\n onClick,\n type,\n className = '',\n states,\n initialStateIndex = 0,\n onStateChange,\n}: ButtonProps) => {\n // 状态管理\n const [currentStateIndex, setCurrentStateIndex] = useState(initialStateIndex);\n const [clickCount, setClickCount] = useState(0);\n\n // 是否是状态按钮\n const isStateful = states && states.length > 0;\n\n // 获取当前状态\n const currentState = isStateful ? states[currentStateIndex] : null;\n\n // 处理点击\n const handleClick = useCallback(() => {\n if (isStateful) {\n const newClickCount = clickCount + 1;\n const newStateIndex = (currentStateIndex + 1) % states.length;\n const newState = states[newStateIndex];\n\n setClickCount(newClickCount);\n setCurrentStateIndex(newStateIndex);\n\n // 调用状态改变回调\n if (onStateChange) {\n onStateChange(newState, newClickCount, newStateIndex);\n }\n }\n\n // 调用原始 onClick\n if (onClick) {\n onClick();\n }\n }, [isStateful, states, currentStateIndex, clickCount, onStateChange, onClick]);\n\n // 确定使用的 variant\n const effectiveVariant = currentState?.variant || variant;\n\n // 确定显示的内容\n const displayContent = isStateful ? (\n <>\n {currentState?.icon && <span className=\"mr-1\">{currentState.icon}</span>}\n {currentState?.label}\n </>\n ) : children;\n\n const baseClass = 'btn';\n const variantClass = effectiveVariant ? `btn-${effectiveVariant}` : '';\n const sizeClass = size ? `btn-${size}` : '';\n const outlineClass = outline ? 'btn-outline' : '';\n const dashClass = dash ? 'btn-dash' : '';\n const softClass = soft ? 'btn-soft' : '';\n const activeClass = active || isStateful ? 'btn-active' : '';\n const wideClass = wide ? 'btn-wide' : '';\n const blockClass = block ? 'btn-block' : '';\n const squareClass = square ? 'btn-square' : '';\n const circleClass = circle ? 'btn-circle' : '';\n\n const buttonClasses = [\n baseClass,\n variantClass,\n sizeClass,\n outlineClass,\n dashClass,\n softClass,\n activeClass,\n wideClass,\n blockClass,\n squareClass,\n circleClass,\n className\n ].filter(Boolean).join(' ');\n\n return (\n <button\n type={type}\n className={buttonClasses}\n disabled={disabled}\n onClick={handleClick}\n title={isStateful ? `当前状态: ${currentState?.key} (点击次数: ${clickCount})` : undefined}\n >\n {!isStateful && leftSection && <span className=\"mr-2\">{leftSection}</span>}\n {displayContent}\n {!isStateful && rightSection && <span className=\"ml-2\">{rightSection}</span>}\n </button>\n );\n};\n\n// Button.Group 组件\nexport type ButtonGroupProps = {\n children: React.ReactNode;\n vertical?: boolean;\n className?: string;\n rounded?: 'left' | 'right' | 'both' | 'none' | 'top' | 'bottom';\n radius?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full';\n roundedStyle?: {\n left?: string;\n right?: string;\n top?: string;\n bottom?: string;\n };\n};\n\nconst ButtonGroup = ({\n children,\n vertical = false,\n className = '',\n rounded = 'none',\n radius = 'full',\n roundedStyle,\n}: ButtonGroupProps) => {\n const joinClasses = [\n 'join',\n vertical ? 'join-vertical' : 'join-horizontal',\n className\n ].filter(Boolean).join(' ');\n\n // 当rounded不为'none'时,强制使用'full'作为radius值\n const effectiveRadius = rounded !== 'none' ? 'full' : radius;\n\n return (\n <div className={joinClasses}>\n {React.Children.map(children, (child, index) => {\n // 只处理有效的React元素\n if (!React.isValidElement(child)) return child;\n\n const childElement = child as ReactElement<{ className?: string }>;\n const childClassName = childElement.props.className || '';\n const isFirstChild = index === 0;\n const isLastChild = index === React.Children.count(children) - 1;\n\n // 根据rounded属性添加额外的圆角类\n let roundedClasses = '';\n\n if (roundedStyle) {\n // 使用自定义圆角样式\n if (vertical) {\n if ((rounded === 'left' || rounded === 'top') && isFirstChild && roundedStyle.top) {\n roundedClasses = roundedStyle.top;\n } else if ((rounded === 'right' || rounded === 'bottom') && isLastChild && roundedStyle.bottom) {\n roundedClasses = roundedStyle.bottom;\n } else if (rounded === 'both') {\n if (isFirstChild && roundedStyle.top) roundedClasses = roundedStyle.top;\n if (isLastChild && roundedStyle.bottom) roundedClasses = roundedStyle.bottom;\n }\n } else {\n if ((rounded === 'left' || rounded === 'top') && isFirstChild && roundedStyle.left) {\n roundedClasses = roundedStyle.left;\n } else if ((rounded === 'right' || rounded === 'bottom') && isLastChild && roundedStyle.right) {\n roundedClasses = roundedStyle.right;\n } else if (rounded === 'both') {\n if (isFirstChild && roundedStyle.left) roundedClasses = roundedStyle.left;\n if (isLastChild && roundedStyle.right) roundedClasses = roundedStyle.right;\n }\n }\n } else {\n // 使用默认的圆角大小\n if (vertical) {\n // 垂直布局时,圆角应用在上下方\n if (rounded === 'left' || rounded === 'top') {\n if (isFirstChild) roundedClasses = `rounded-t-${effectiveRadius}`;\n } else if (rounded === 'right' || rounded === 'bottom') {\n if (isLastChild) roundedClasses = `rounded-b-${effectiveRadius}`;\n } else if (rounded === 'both') {\n if (isFirstChild) roundedClasses = `rounded-t-${effectiveRadius}`;\n if (isLastChild) roundedClasses = `rounded-b-${effectiveRadius}`;\n }\n } else {\n // 水平布局时,圆角应用在左右方\n if (rounded === 'left' || rounded === 'top') {\n if (isFirstChild) roundedClasses = `rounded-l-${effectiveRadius}`;\n } else if (rounded === 'right' || rounded === 'bottom') {\n if (isLastChild) roundedClasses = `rounded-r-${effectiveRadius}`;\n } else if (rounded === 'both') {\n if (isFirstChild) roundedClasses = `rounded-l-${effectiveRadius}`;\n if (isLastChild) roundedClasses = `rounded-r-${effectiveRadius}`;\n }\n }\n }\n\n const newClassName = `${childClassName} join-item ${roundedClasses}`.trim();\n\n return React.cloneElement(childElement, {\n className: newClassName,\n });\n })}\n </div>\n );\n};\n\n// Button.GroupSection 组件\nexport type ButtonGroupSectionProps = {\n children: React.ReactNode;\n className?: string;\n};\n\nconst ButtonGroupSection = ({\n children,\n className = '',\n}: ButtonGroupSectionProps) => {\n const sectionClasses = [\n 'join-item',\n 'flex',\n 'items-center',\n 'px-4',\n 'bg-base-200',\n 'border',\n 'border-base-300',\n className\n ].filter(Boolean).join(' ');\n\n return (\n <div className={sectionClasses}>\n {children}\n </div>\n );\n};\n\n// 扩展Button组件,添加Group和GroupSection子组件\ninterface ButtonCompound extends React.FC<ButtonProps> {\n Group: React.FC<ButtonGroupProps>;\n GroupSection: React.FC<ButtonGroupSectionProps>;\n}\n\nconst ButtonWithCompounds = Button as ButtonCompound;\nButtonWithCompounds.Group = ButtonGroup;\nButtonWithCompounds.GroupSection = ButtonG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,IAAK,WAAW;AAAA,IACb,UAAA;AAAA,EACE,CAAA;AAET,GAQM,IAAsB;AAC5B,EAAoB,QAAQ;AAC5B,EAAoB,eAAe"}
|
|
@@ -28,6 +28,17 @@ export type CardActionsProps = {
|
|
|
28
28
|
export type CardFigureProps = {
|
|
29
29
|
children: React.ReactNode;
|
|
30
30
|
className?: string;
|
|
31
|
+
/**
|
|
32
|
+
* 图片填充方式(作用于内部 <img>):
|
|
33
|
+
* - `cover` 等比裁切填满(默认,“撑满”)
|
|
34
|
+
* - `contain` 等比完整展示,可能留白
|
|
35
|
+
* - `fill` 拉伸填满(不保持比例)
|
|
36
|
+
*/
|
|
37
|
+
fit?: 'cover' | 'contain' | 'fill';
|
|
38
|
+
/** 图片撑满整个 figure(w/h 100%)。card-side 时建议开启。 */
|
|
39
|
+
fill?: boolean;
|
|
40
|
+
/** 指定 figure 高度(数字按 px,支持 "16rem"/"50%" 等);内部图片自动填满该高度 */
|
|
41
|
+
height?: number | string;
|
|
31
42
|
};
|
|
32
43
|
interface CardCompound extends React.FC<CardProps> {
|
|
33
44
|
Title: React.FC<CardTitleProps>;
|
|
@@ -1,47 +1,72 @@
|
|
|
1
1
|
import "react";
|
|
2
2
|
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
-
var x = ({ children: s, variant: a, bordered:
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
var x = ({ children: s, variant: a, bordered: o = !1, dash: e = !1, side: l = !1, imageFull: i = !1, compact: d = !1, hover: f = !0, glass: m = !0, size: n = "sm", className: c = "" }) => {
|
|
4
|
+
const u = "card", C = m && !a ? "glass shadow-lg" : "", g = a ? `bg-${a} text-${a}-content shadow-md` : "", v = o ? "card-bordered" : "", h = e ? "card-dash" : "", w = l ? "card-side" : "", b = i ? "image-full" : "", j = d ? "card-compact" : "", p = f ? "hover:shadow-xl transition-shadow duration-300" : "", y = n ? `card-${n}` : "";
|
|
5
|
+
c.includes("w-") || c.match(/max-w-|min-w-/);
|
|
6
|
+
const B = [
|
|
7
|
+
u,
|
|
8
|
+
"",
|
|
9
|
+
C,
|
|
10
|
+
g,
|
|
11
|
+
v,
|
|
12
|
+
h,
|
|
13
|
+
w,
|
|
14
|
+
b,
|
|
15
|
+
j,
|
|
16
|
+
p,
|
|
17
|
+
y,
|
|
18
|
+
c
|
|
19
|
+
].filter(Boolean).join(" ");
|
|
20
|
+
return /* @__PURE__ */ r("div", {
|
|
21
|
+
className: B,
|
|
20
22
|
children: s
|
|
21
23
|
});
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
24
|
+
}, $ = ({ children: s, className: a = "" }) => {
|
|
25
|
+
const o = ["card-title", a].filter(Boolean).join(" ");
|
|
26
|
+
return /* @__PURE__ */ r("h2", {
|
|
27
|
+
className: o,
|
|
28
|
+
children: s
|
|
29
|
+
});
|
|
30
|
+
}, F = ({ children: s, className: a = "" }) => {
|
|
31
|
+
const o = ["card-body", a].filter(Boolean).join(" ");
|
|
32
|
+
return /* @__PURE__ */ r("div", {
|
|
33
|
+
className: o,
|
|
34
|
+
children: s
|
|
35
|
+
});
|
|
36
|
+
}, S = ({ children: s, className: a = "", justify: o = "end" }) => {
|
|
37
|
+
const e = [
|
|
30
38
|
"card-actions",
|
|
31
|
-
|
|
39
|
+
o ? `justify-${o}` : "",
|
|
32
40
|
a
|
|
33
|
-
].filter(Boolean).join(" ")
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
o
|
|
41
|
+
].filter(Boolean).join(" ");
|
|
42
|
+
return /* @__PURE__ */ r("div", {
|
|
43
|
+
className: e,
|
|
44
|
+
children: s
|
|
45
|
+
});
|
|
46
|
+
}, A = {
|
|
47
|
+
cover: "[&>img]:object-cover",
|
|
48
|
+
contain: "[&>img]:object-contain",
|
|
49
|
+
fill: "[&>img]:object-fill"
|
|
50
|
+
}, N = (s) => typeof s == "number" ? `${s}px` : s, T = ({ children: s, className: a = "", fit: o = "cover", fill: e = !1, height: l }) => {
|
|
51
|
+
const i = [
|
|
52
|
+
"figure",
|
|
53
|
+
A[o],
|
|
54
|
+
e ? "w-full h-full [&>img]:h-full [&>img]:w-full" : "",
|
|
55
|
+
l !== void 0 ? "w-full [&>img]:h-full [&>img]:w-full" : "",
|
|
56
|
+
a
|
|
57
|
+
].filter(Boolean).join(" ");
|
|
58
|
+
return /* @__PURE__ */ r("figure", {
|
|
59
|
+
className: i,
|
|
60
|
+
style: l !== void 0 ? { height: N(l) } : void 0,
|
|
61
|
+
children: s
|
|
62
|
+
});
|
|
63
|
+
}, t = x;
|
|
64
|
+
t.Title = $;
|
|
65
|
+
t.Body = F;
|
|
66
|
+
t.Actions = S;
|
|
67
|
+
t.Figure = T;
|
|
43
68
|
export {
|
|
44
|
-
|
|
69
|
+
t as default
|
|
45
70
|
};
|
|
46
71
|
|
|
47
72
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Card/index.tsx"],"sourcesContent":["import React from 'react';\n\nexport type CardProps = {\n children: React.ReactNode;\n variant?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error';\n bordered?: boolean;\n dash?: boolean;\n side?: boolean;\n imageFull?: boolean;\n compact?: boolean;\n hover?: boolean;\n glass?: boolean; // 毛玻璃效果\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n className?: string;\n};\n\nconst Card = ({\n children,\n variant,\n bordered = false,\n dash = false,\n side = false,\n imageFull = false,\n compact = false,\n hover = true, // 默认启用 hover 效果\n glass = true, // 默认启用毛玻璃效果\n size = 'sm',\n className = '',\n}: CardProps) => {\n const baseClass = 'card';\n\n // 默认样式:如果没有指定 variant,则应用毛玻璃效果和阴影\n // 同时添加边界样式 (border + shadow)\n const defaultStyles = glass && !variant ? 'glass shadow-lg' : '';\n\n // 如果指定了 variant,使用该 variant 的背景色,并添加阴影\n const variantClass = variant ? `bg-${variant} text-${variant}-content shadow-md` : '';\n\n const borderedClass = bordered ? 'card-bordered' : '';\n const dashClass = dash ? 'card-dash' : '';\n const sideClass = side ? 'card-side' : '';\n const imageFullClass = imageFull ? 'image-full' : '';\n const compactClass = compact ? 'card-compact' : '';\n const hoverClass = hover ? 'hover:shadow-xl transition-shadow duration-300' : '';\n const sizeClass = size ? `card-${size}` : '';\n\n // 宽度策略:\n // 1. 如果用户指定了 w-/max-w-/min-w-,则完全使用用户的设置\n // 2. 否则不设置固定宽度,让 Card 自然适应父容器(Grid 中自动填充,Flex 中根据内容)\n const hasWidthClass = className.includes('w-') || className.match(/max-w-|min-w-/);\n const widthClass = ''; // 不设置默认宽度,让布局决定\n\n const cardClasses = [\n baseClass,\n widthClass,\n defaultStyles,\n variantClass,\n borderedClass,\n dashClass,\n sideClass,\n imageFullClass,\n compactClass,\n hoverClass,\n sizeClass,\n className\n ].filter(Boolean).join(' ');\n\n return (\n <div className={cardClasses}>\n {children}\n </div>\n );\n};\n\n// Card.Title 组件\nexport type CardTitleProps = {\n children: React.ReactNode;\n className?: string;\n};\n\nconst CardTitle = ({\n children,\n className = '',\n}: CardTitleProps) => {\n const titleClasses = [\n 'card-title',\n className\n ].filter(Boolean).join(' ');\n\n return (\n <h2 className={titleClasses}>\n {children}\n </h2>\n );\n};\n\n// Card.Body 组件\nexport type CardBodyProps = {\n children: React.ReactNode;\n className?: string;\n};\n\nconst CardBody = ({\n children,\n className = '',\n}: CardBodyProps) => {\n const bodyClasses = [\n 'card-body',\n className\n ].filter(Boolean).join(' ');\n\n return (\n <div className={bodyClasses}>\n {children}\n </div>\n );\n};\n\n// Card.Actions 组件\nexport type CardActionsProps = {\n children: React.ReactNode;\n className?: string;\n justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';\n};\n\nconst CardActions = ({\n children,\n className = '',\n justify = 'end',\n}: CardActionsProps) => {\n const actionsClasses = [\n 'card-actions',\n justify ? `justify-${justify}` : '',\n className\n ].filter(Boolean).join(' ');\n\n return (\n <div className={actionsClasses}>\n {children}\n </div>\n );\n};\n\n// Card.Figure 组件\nexport type CardFigureProps = {\n children: React.ReactNode;\n className?: string;\n};\n\nconst CardFigure = ({\n children,\n className = '',\n}: CardFigureProps) => {\n const figureClasses = [\n 'figure',\n className\n ].filter(Boolean).join(' ');\n\n return (\n <figure className={figureClasses}>\n {children}\n </figure>\n );\n};\n\n// 扩展Card组件,添加子组件\ninterface CardCompound extends React.FC<CardProps> {\n Title: React.FC<CardTitleProps>;\n Body: React.FC<CardBodyProps>;\n Actions: React.FC<CardActionsProps>;\n Figure: React.FC<CardFigureProps>;\n}\n\nconst CardWithCompounds = Card as CardCompound;\nCardWithCompounds.Title = CardTitle;\nCardWithCompounds.Body = CardBody;\nCardWithCompounds.Actions = CardActions;\nCardWithCompounds.Figure = CardFigure;\n\nexport default CardWithCompounds; "],"mappings":";;AAgBA,IAAM,IAAA,CAAQ,EACZ,UAAA,GACA,SAAA,GACA,UAAA,IAAW,IACX,MAAA,IAAO,IACP,MAAA,IAAO,IACP,WAAA,IAAY,IACZ,SAAA,IAAU,IACV,OAAA,IAAQ,IACR,OAAA,IAAQ,IACR,MAAA,IAAO,MACP,WAAA,IAAY,GAAA,MACG;AACf,QAAM,IAAY,QAIZ,IAAgB,KAAS,CAAC,IAAU,oBAAoB,IAGxD,IAAe,IAAU,MAAM,CAAA,SAAgB,CAAA,uBAA8B,IAE7E,IAAgB,IAAW,kBAAkB,IAC7C,IAAY,IAAO,cAAc,IACjC,IAAY,IAAO,cAAc,IACjC,IAAiB,IAAY,eAAe,IAC5C,IAAe,IAAU,iBAAiB,IAC1C,IAAa,IAAQ,mDAAmD,IACxE,IAAY,IAAO,QAAQ,CAAA,KAAS;AAKpB,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Card/index.tsx"],"sourcesContent":["import React from 'react';\n\nexport type CardProps = {\n children: React.ReactNode;\n variant?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error';\n bordered?: boolean;\n dash?: boolean;\n side?: boolean;\n imageFull?: boolean;\n compact?: boolean;\n hover?: boolean;\n glass?: boolean; // 毛玻璃效果\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n className?: string;\n};\n\nconst Card = ({\n children,\n variant,\n bordered = false,\n dash = false,\n side = false,\n imageFull = false,\n compact = false,\n hover = true, // 默认启用 hover 效果\n glass = true, // 默认启用毛玻璃效果\n size = 'sm',\n className = '',\n}: CardProps) => {\n const baseClass = 'card';\n\n // 默认样式:如果没有指定 variant,则应用毛玻璃效果和阴影\n // 同时添加边界样式 (border + shadow)\n const defaultStyles = glass && !variant ? 'glass shadow-lg' : '';\n\n // 如果指定了 variant,使用该 variant 的背景色,并添加阴影\n const variantClass = variant ? `bg-${variant} text-${variant}-content shadow-md` : '';\n\n const borderedClass = bordered ? 'card-bordered' : '';\n const dashClass = dash ? 'card-dash' : '';\n const sideClass = side ? 'card-side' : '';\n const imageFullClass = imageFull ? 'image-full' : '';\n const compactClass = compact ? 'card-compact' : '';\n const hoverClass = hover ? 'hover:shadow-xl transition-shadow duration-300' : '';\n const sizeClass = size ? `card-${size}` : '';\n\n // 宽度策略:\n // 1. 如果用户指定了 w-/max-w-/min-w-,则完全使用用户的设置\n // 2. 否则不设置固定宽度,让 Card 自然适应父容器(Grid 中自动填充,Flex 中根据内容)\n const hasWidthClass = className.includes('w-') || className.match(/max-w-|min-w-/);\n const widthClass = ''; // 不设置默认宽度,让布局决定\n\n const cardClasses = [\n baseClass,\n widthClass,\n defaultStyles,\n variantClass,\n borderedClass,\n dashClass,\n sideClass,\n imageFullClass,\n compactClass,\n hoverClass,\n sizeClass,\n className\n ].filter(Boolean).join(' ');\n\n return (\n <div className={cardClasses}>\n {children}\n </div>\n );\n};\n\n// Card.Title 组件\nexport type CardTitleProps = {\n children: React.ReactNode;\n className?: string;\n};\n\nconst CardTitle = ({\n children,\n className = '',\n}: CardTitleProps) => {\n const titleClasses = [\n 'card-title',\n className\n ].filter(Boolean).join(' ');\n\n return (\n <h2 className={titleClasses}>\n {children}\n </h2>\n );\n};\n\n// Card.Body 组件\nexport type CardBodyProps = {\n children: React.ReactNode;\n className?: string;\n};\n\nconst CardBody = ({\n children,\n className = '',\n}: CardBodyProps) => {\n const bodyClasses = [\n 'card-body',\n className\n ].filter(Boolean).join(' ');\n\n return (\n <div className={bodyClasses}>\n {children}\n </div>\n );\n};\n\n// Card.Actions 组件\nexport type CardActionsProps = {\n children: React.ReactNode;\n className?: string;\n justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';\n};\n\nconst CardActions = ({\n children,\n className = '',\n justify = 'end',\n}: CardActionsProps) => {\n const actionsClasses = [\n 'card-actions',\n justify ? `justify-${justify}` : '',\n className\n ].filter(Boolean).join(' ');\n\n return (\n <div className={actionsClasses}>\n {children}\n </div>\n );\n};\n\n// Card.Figure 组件\nexport type CardFigureProps = {\n children: React.ReactNode;\n className?: string;\n /**\n * 图片填充方式(作用于内部 <img>):\n * - `cover` 等比裁切填满(默认,“撑满”)\n * - `contain` 等比完整展示,可能留白\n * - `fill` 拉伸填满(不保持比例)\n */\n fit?: 'cover' | 'contain' | 'fill';\n /** 图片撑满整个 figure(w/h 100%)。card-side 时建议开启。 */\n fill?: boolean;\n /** 指定 figure 高度(数字按 px,支持 \"16rem\"/\"50%\" 等);内部图片自动填满该高度 */\n height?: number | string;\n};\n\nconst FIT_CLASS: Record<NonNullable<CardFigureProps['fit']>, string> = {\n cover: '[&>img]:object-cover',\n contain: '[&>img]:object-contain',\n fill: '[&>img]:object-fill',\n};\n\nconst toCssSize = (value: number | string | undefined): string | undefined =>\n typeof value === 'number' ? `${value}px` : value;\n\nconst CardFigure = ({\n children,\n className = '',\n fit = 'cover',\n fill = false,\n height,\n}: CardFigureProps) => {\n const figureClasses = [\n 'figure',\n FIT_CLASS[fit],\n // 撑满:figure 与内部 img 都占满可用空间\n fill ? 'w-full h-full [&>img]:h-full [&>img]:w-full' : '',\n // 指定高度:figure 定高,内部图片自动填满\n height !== undefined ? 'w-full [&>img]:h-full [&>img]:w-full' : '',\n className\n ].filter(Boolean).join(' ');\n\n return (\n <figure className={figureClasses} style={height !== undefined ? { height: toCssSize(height) } : undefined}>\n {children}\n </figure>\n );\n};\n\n// 扩展Card组件,添加子组件\ninterface CardCompound extends React.FC<CardProps> {\n Title: React.FC<CardTitleProps>;\n Body: React.FC<CardBodyProps>;\n Actions: React.FC<CardActionsProps>;\n Figure: React.FC<CardFigureProps>;\n}\n\nconst CardWithCompounds = Card as CardCompound;\nCardWithCompounds.Title = CardTitle;\nCardWithCompounds.Body = CardBody;\nCardWithCompounds.Actions = CardActions;\nCardWithCompounds.Figure = CardFigure;\n\nexport default CardWithCompounds; "],"mappings":";;AAgBA,IAAM,IAAA,CAAQ,EACZ,UAAA,GACA,SAAA,GACA,UAAA,IAAW,IACX,MAAA,IAAO,IACP,MAAA,IAAO,IACP,WAAA,IAAY,IACZ,SAAA,IAAU,IACV,OAAA,IAAQ,IACR,OAAA,IAAQ,IACR,MAAA,IAAO,MACP,WAAA,IAAY,GAAA,MACG;AACf,QAAM,IAAY,QAIZ,IAAgB,KAAS,CAAC,IAAU,oBAAoB,IAGxD,IAAe,IAAU,MAAM,CAAA,SAAgB,CAAA,uBAA8B,IAE7E,IAAgB,IAAW,kBAAkB,IAC7C,IAAY,IAAO,cAAc,IACjC,IAAY,IAAO,cAAc,IACjC,IAAiB,IAAY,eAAe,IAC5C,IAAe,IAAU,iBAAiB,IAC1C,IAAa,IAAQ,mDAAmD,IACxE,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AAA,CAAc,EAClB,UAAA,GACA,WAAA,IAAY,IACZ,KAAA,IAAM,SACN,MAAA,IAAO,IACP,QAAA,EAAA,MACqB;AACrB,QAAM,IAAgB;AAAA,IACpB;AAAA,IACA,EAAU,CAAA;AAAA,IAEV,IAAO,gDAAgD;AAAA,IAEvD,MAAW,SAAY,yCAAyC;AAAA,IAChE;AAAA,EACF,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAE1B,SACE,gBAAA,EAAC,UAAD;AAAA,IAAQ,WAAW;AAAA,IAAe,OAAO,MAAW,SAAY,EAAE,QAAQ,EAAU,CAAM,EAAE,IAAI;AAAA,IAC7F,UAAA;AAAA,EACK,CAAA;AAEZ,GAUM,IAAoB;AAC1B,EAAkB,QAAQ;AAC1B,EAAkB,OAAO;AACzB,EAAkB,UAAU;AAC5B,EAAkB,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.js","names":[],"sources":["../../../src/components/Chart/Chart.tsx"],"sourcesContent":["import React from 'react';\nimport { Chart as TanStackChart } from '@tanstack/react-charts/tooltip';\nimport type { DomChartDefinition } from '@tanstack/charts';\n\nexport interface ChartProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {\n /** TanStack Charts declarative chart definition. */\n definition: DomChartDefinition<any, any, any>;\n\n /** Wrapper height. TanStack Charts fills the available space. */\n height?: number | string;\n /** Additional wrapper class name. */\n className?: string;\n /** Additional wrapper style. */\n style?: React.CSSProperties;\n /** Optional empty state controlled by the caller. */\n empty?: boolean;\n emptyContent?: React.ReactNode;\n}\n\nconst Chart = React.forwardRef<HTMLDivElement, ChartProps>(function Chart({\n height = 360,\n className = '',\n style,\n empty = false,\n emptyContent = 'No chart data',\n definition,\n ...wrapperProps\n}, ref) {\n const numericChartHeight = typeof height === 'number' ? Math.max(1, height - 26) : undefined;\n\n return (\n <div\n ref={ref}\n className={`relative w-full overflow-hidden rounded-xl border border-base-300 bg-base-100 p-3 ${className}`}\n style={{ height, ...style }}\n {...wrapperProps}\n >\n {empty ? (\n <div className=\"flex h-full items-center justify-center p-6 text-sm text-base-content/50\">\n {emptyContent}\n </div>\n ) : (\n <TanStackChart\n definition={definition}\n ariaLabel={wrapperProps['aria-label'] || 'Chart'}\n height={numericChartHeight}\n style={typeof height === 'string' ? { height: '100%' } : undefined}\n />\n )}\n </div>\n );\n});\n\nexport default Chart;\n"],"mappings":";;;AAmBA,IAAM,IAAQ,EAAM,WAAuC,SAAe,EACxE,QAAA,IAAS,KACT,WAAA,IAAY,IACZ,OAAA,GACA,OAAA,IAAQ,IACR,cAAA,IAAe,iBACf,YAAA,GACA,GAAG,EAAA,GACF,GAAK;AACN,QAAM,IAAqB,OAAO,KAAW,WAAW,KAAK,IAAI,GAAG,IAAS,EAAE,IAAI;AAEnF,SACE,gBAAA,EAAC,OAAD;AAAA,IACO,KAAA;AAAA,IACL,WAAW,qFAAqF,CAAA;AAAA,IAChG,OAAO;AAAA,MAAE,QAAA;AAAA,MAAQ,GAAG;AAAA,IAAM;AAAA,IAC1B,GAAI;AAAA,
|
|
1
|
+
{"version":3,"file":"Chart.js","names":[],"sources":["../../../src/components/Chart/Chart.tsx"],"sourcesContent":["import React from 'react';\nimport { Chart as TanStackChart } from '@tanstack/react-charts/tooltip';\nimport type { DomChartDefinition } from '@tanstack/charts';\n\nexport interface ChartProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {\n /** TanStack Charts declarative chart definition. */\n definition: DomChartDefinition<any, any, any>;\n\n /** Wrapper height. TanStack Charts fills the available space. */\n height?: number | string;\n /** Additional wrapper class name. */\n className?: string;\n /** Additional wrapper style. */\n style?: React.CSSProperties;\n /** Optional empty state controlled by the caller. */\n empty?: boolean;\n emptyContent?: React.ReactNode;\n}\n\nconst Chart = React.forwardRef<HTMLDivElement, ChartProps>(function Chart({\n height = 360,\n className = '',\n style,\n empty = false,\n emptyContent = 'No chart data',\n definition,\n ...wrapperProps\n}, ref) {\n const numericChartHeight = typeof height === 'number' ? Math.max(1, height - 26) : undefined;\n\n return (\n <div\n ref={ref}\n className={`relative w-full overflow-hidden rounded-xl border border-base-300 bg-base-100 p-3 ${className}`}\n style={{ height, ...style }}\n {...wrapperProps}\n >\n {empty ? (\n <div className=\"flex h-full items-center justify-center p-6 text-sm text-base-content/50\">\n {emptyContent}\n </div>\n ) : (\n <TanStackChart\n definition={definition}\n ariaLabel={wrapperProps['aria-label'] || 'Chart'}\n height={numericChartHeight}\n style={typeof height === 'string' ? { height: '100%' } : undefined}\n />\n )}\n </div>\n );\n});\n\nexport default Chart;\n"],"mappings":";;;AAmBA,IAAM,IAAQ,EAAM,WAAuC,SAAe,EACxE,QAAA,IAAS,KACT,WAAA,IAAY,IACZ,OAAA,GACA,OAAA,IAAQ,IACR,cAAA,IAAe,iBACf,YAAA,GACA,GAAG,EAAA,GACF,GAAK;AACN,QAAM,IAAqB,OAAO,KAAW,WAAW,KAAK,IAAI,GAAG,IAAS,EAAE,IAAI;AAEnF,SACE,gBAAA,EAAC,OAAD;AAAA,IACO,KAAA;AAAA,IACL,WAAW,qFAAqF,CAAA;AAAA,IAChG,OAAO;AAAA,MAAE,QAAA;AAAA,MAAQ,GAAG;AAAA,IAAM;AAAA,IAC1B,GAAI;AAAA,IAEH,UAAA,IACC,gBAAA,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,MACZ,UAAA;AAAA,IACE,CAAA,IAEL,gBAAA,EAAC,GAAD;AAAA,MACc,YAAA;AAAA,MACZ,WAAW,EAAa,YAAA,KAAiB;AAAA,MACzC,QAAQ;AAAA,MACR,OAAO,OAAO,KAAW,WAAW,EAAE,QAAQ,OAAO,IAAI;AAAA,IAC1D,CAAA;AAAA,EAEA,CAAA;AAET,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useCallback as
|
|
2
|
-
import { jsx as
|
|
3
|
-
var
|
|
1
|
+
import { useCallback as y, useEffect as v, useRef as S } from "react";
|
|
2
|
+
import { jsx as s, jsxs as j } from "react/jsx-runtime";
|
|
3
|
+
var w = {
|
|
4
4
|
default: "",
|
|
5
5
|
primary: "checkbox-primary",
|
|
6
6
|
secondary: "checkbox-secondary",
|
|
@@ -9,50 +9,52 @@ var S = {
|
|
|
9
9
|
success: "checkbox-success",
|
|
10
10
|
warning: "checkbox-warning",
|
|
11
11
|
error: "checkbox-error"
|
|
12
|
-
},
|
|
12
|
+
}, A = {
|
|
13
13
|
xs: "checkbox-xs",
|
|
14
14
|
sm: "checkbox-sm",
|
|
15
15
|
md: "checkbox-md",
|
|
16
16
|
lg: "checkbox-lg"
|
|
17
|
-
},
|
|
18
|
-
const o =
|
|
19
|
-
|
|
17
|
+
}, E = ({ checked: h, defaultChecked: x, onChange: n, label: e, labelPosition: t = "right", variant: f = "default", size: u = "sm", disabled: a = !1, indeterminate: c = !1, name: k, value: p, className: r = "", style: d, id: m }) => {
|
|
18
|
+
const o = S(null);
|
|
19
|
+
v(() => {
|
|
20
20
|
o.current && (o.current.indeterminate = c);
|
|
21
21
|
}, [c]);
|
|
22
|
-
const b =
|
|
23
|
-
|
|
24
|
-
}, [
|
|
22
|
+
const b = y((l) => {
|
|
23
|
+
n?.(l.target.checked, l);
|
|
24
|
+
}, [n]), g = [
|
|
25
|
+
"checkbox",
|
|
26
|
+
w[f],
|
|
27
|
+
A[u],
|
|
28
|
+
r && !e ? r : ""
|
|
29
|
+
].filter(Boolean).join(" "), i = /* @__PURE__ */ s("input", {
|
|
25
30
|
ref: o,
|
|
26
|
-
id:
|
|
31
|
+
id: m,
|
|
27
32
|
type: "checkbox",
|
|
28
|
-
className:
|
|
29
|
-
|
|
30
|
-
S[f],
|
|
31
|
-
j[u],
|
|
32
|
-
r && !e ? r : ""
|
|
33
|
-
].filter(Boolean).join(" "),
|
|
34
|
-
checked: l,
|
|
33
|
+
className: g,
|
|
34
|
+
checked: h,
|
|
35
35
|
defaultChecked: x,
|
|
36
36
|
onChange: b,
|
|
37
|
-
disabled:
|
|
37
|
+
disabled: a,
|
|
38
38
|
name: k,
|
|
39
|
-
value:
|
|
39
|
+
value: p,
|
|
40
40
|
"aria-checked": c ? "mixed" : void 0
|
|
41
41
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
if (e == null || e === "") return i;
|
|
43
|
+
const C = [
|
|
44
|
+
"label cursor-pointer inline-flex items-center gap-2 w-fit",
|
|
45
|
+
a ? "opacity-50 cursor-not-allowed" : "",
|
|
46
|
+
r
|
|
47
|
+
].filter(Boolean).join(" ");
|
|
48
|
+
return /* @__PURE__ */ j("label", {
|
|
49
|
+
className: C,
|
|
50
|
+
style: d,
|
|
49
51
|
children: [
|
|
50
|
-
|
|
52
|
+
t === "left" && /* @__PURE__ */ s("span", {
|
|
51
53
|
className: "label-text",
|
|
52
54
|
children: e
|
|
53
55
|
}),
|
|
54
56
|
i,
|
|
55
|
-
|
|
57
|
+
t === "right" && /* @__PURE__ */ s("span", {
|
|
56
58
|
className: "label-text",
|
|
57
59
|
children: e
|
|
58
60
|
})
|
|
@@ -60,7 +62,7 @@ var S = {
|
|
|
60
62
|
});
|
|
61
63
|
};
|
|
62
64
|
export {
|
|
63
|
-
|
|
65
|
+
E as default
|
|
64
66
|
};
|
|
65
67
|
|
|
66
68
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Checkbox/index.tsx"],"sourcesContent":["import React, { useRef, useEffect, useCallback } from 'react';\n\nexport type CheckboxProps = {\n /** Controlled checked state. */\n checked?: boolean;\n /** Uncontrolled initial checked state. */\n defaultChecked?: boolean;\n /** Change handler; receives the new checked value. */\n onChange?: (checked: boolean, event: React.ChangeEvent<HTMLInputElement>) => void;\n /** Optional label rendered next to the box. */\n label?: React.ReactNode;\n /** Label position relative to the box. */\n labelPosition?: 'right' | 'left';\n /** Color variant (daisyUI). */\n variant?: 'default' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error';\n /** Size. */\n size?: 'xs' | 'sm' | 'md' | 'lg';\n /** Disabled state. */\n disabled?: boolean;\n /** Indeterminate (partial) state; overrides the visual check mark. */\n indeterminate?: boolean;\n /** Native name attribute (useful in forms). */\n name?: string;\n /** Native value attribute. */\n value?: string;\n /** Extra class names applied to the wrapping label element. */\n className?: string;\n /** Inline styles applied to the wrapping label element. */\n style?: React.CSSProperties;\n /** id forwarded to the input. */\n id?: string;\n};\n\nconst VARIANT_CLASS: Record<NonNullable<CheckboxProps['variant']>, string> = {\n default: '',\n primary: 'checkbox-primary',\n secondary: 'checkbox-secondary',\n accent: 'checkbox-accent',\n info: 'checkbox-info',\n success: 'checkbox-success',\n warning: 'checkbox-warning',\n error: 'checkbox-error',\n};\n\nconst SIZE_CLASS: Record<NonNullable<CheckboxProps['size']>, string> = {\n xs: 'checkbox-xs',\n sm: 'checkbox-sm',\n md: 'checkbox-md',\n lg: 'checkbox-lg',\n};\n\nconst Checkbox: React.FC<CheckboxProps> = ({\n checked,\n defaultChecked,\n onChange,\n label,\n labelPosition = 'right',\n variant = 'default',\n size = 'sm',\n disabled = false,\n indeterminate = false,\n name,\n value,\n className = '',\n style,\n id,\n}) => {\n const inputRef = useRef<HTMLInputElement>(null);\n\n // The `indeterminate` visual state can only be set imperatively on the DOM node.\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.indeterminate = indeterminate;\n }\n }, [indeterminate]);\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(e.target.checked, e);\n },\n [onChange],\n );\n\n const inputClasses = [\n 'checkbox',\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n // If there is no label, allow className to style the input directly.\n className && !label ? className : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const input = (\n <input\n ref={inputRef}\n id={id}\n type=\"checkbox\"\n className={inputClasses}\n checked={checked}\n defaultChecked={defaultChecked}\n onChange={handleChange}\n disabled={disabled}\n name={name}\n value={value}\n aria-checked={indeterminate ? 'mixed' : undefined}\n />\n );\n\n // No label → return the bare input.\n if (label === undefined || label === null || label === '') {\n return input;\n }\n\n const labelClasses = [\n 'label cursor-pointer inline-flex items-center gap-2 w-fit',\n disabled ? 'opacity-50 cursor-not-allowed' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <label className={labelClasses} style={style}>\n {labelPosition === 'left' && <span className=\"label-text\">{label}</span>}\n {input}\n {labelPosition === 'right' && <span className=\"label-text\">{label}</span>}\n </label>\n );\n};\n\nexport default Checkbox;\n"],"mappings":";;AAiCA,IAAM,IAAuE;AAAA,EAC3E,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACT,GAEM,IAAiE;AAAA,EACrE,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEM,IAAA,CAAqC,EACzC,SAAA,GACA,gBAAA,GACA,UAAA,GACA,OAAA,GACA,eAAA,IAAgB,SAChB,SAAA,IAAU,WACV,MAAA,IAAO,MACP,UAAA,IAAW,IACX,eAAA,IAAgB,IAChB,MAAA,GACA,OAAA,GACA,WAAA,IAAY,IACZ,OAAA,GACA,IAAA,EAAA,MACI;AACJ,QAAM,IAAW,EAAyB,IAAI;AAG9C,EAAA,EAAA,MAAgB;AACd,IAAI,EAAS,YACX,EAAS,QAAQ,gBAAgB;AAAA,EAErC,GAAG,CAAC,CAAa,CAAC;AAElB,QAAM,IAAe,EAAA,CAClB,MAA2C;AAC1C,IAAA,IAAW,EAAE,OAAO,SAAS,CAAC;AAAA,EAChC,GACA,CAAC,CAAQ,CACX,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Checkbox/index.tsx"],"sourcesContent":["import React, { useRef, useEffect, useCallback } from 'react';\n\nexport type CheckboxProps = {\n /** Controlled checked state. */\n checked?: boolean;\n /** Uncontrolled initial checked state. */\n defaultChecked?: boolean;\n /** Change handler; receives the new checked value. */\n onChange?: (checked: boolean, event: React.ChangeEvent<HTMLInputElement>) => void;\n /** Optional label rendered next to the box. */\n label?: React.ReactNode;\n /** Label position relative to the box. */\n labelPosition?: 'right' | 'left';\n /** Color variant (daisyUI). */\n variant?: 'default' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error';\n /** Size. */\n size?: 'xs' | 'sm' | 'md' | 'lg';\n /** Disabled state. */\n disabled?: boolean;\n /** Indeterminate (partial) state; overrides the visual check mark. */\n indeterminate?: boolean;\n /** Native name attribute (useful in forms). */\n name?: string;\n /** Native value attribute. */\n value?: string;\n /** Extra class names applied to the wrapping label element. */\n className?: string;\n /** Inline styles applied to the wrapping label element. */\n style?: React.CSSProperties;\n /** id forwarded to the input. */\n id?: string;\n};\n\nconst VARIANT_CLASS: Record<NonNullable<CheckboxProps['variant']>, string> = {\n default: '',\n primary: 'checkbox-primary',\n secondary: 'checkbox-secondary',\n accent: 'checkbox-accent',\n info: 'checkbox-info',\n success: 'checkbox-success',\n warning: 'checkbox-warning',\n error: 'checkbox-error',\n};\n\nconst SIZE_CLASS: Record<NonNullable<CheckboxProps['size']>, string> = {\n xs: 'checkbox-xs',\n sm: 'checkbox-sm',\n md: 'checkbox-md',\n lg: 'checkbox-lg',\n};\n\nconst Checkbox: React.FC<CheckboxProps> = ({\n checked,\n defaultChecked,\n onChange,\n label,\n labelPosition = 'right',\n variant = 'default',\n size = 'sm',\n disabled = false,\n indeterminate = false,\n name,\n value,\n className = '',\n style,\n id,\n}) => {\n const inputRef = useRef<HTMLInputElement>(null);\n\n // The `indeterminate` visual state can only be set imperatively on the DOM node.\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.indeterminate = indeterminate;\n }\n }, [indeterminate]);\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(e.target.checked, e);\n },\n [onChange],\n );\n\n const inputClasses = [\n 'checkbox',\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n // If there is no label, allow className to style the input directly.\n className && !label ? className : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const input = (\n <input\n ref={inputRef}\n id={id}\n type=\"checkbox\"\n className={inputClasses}\n checked={checked}\n defaultChecked={defaultChecked}\n onChange={handleChange}\n disabled={disabled}\n name={name}\n value={value}\n aria-checked={indeterminate ? 'mixed' : undefined}\n />\n );\n\n // No label → return the bare input.\n if (label === undefined || label === null || label === '') {\n return input;\n }\n\n const labelClasses = [\n 'label cursor-pointer inline-flex items-center gap-2 w-fit',\n disabled ? 'opacity-50 cursor-not-allowed' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <label className={labelClasses} style={style}>\n {labelPosition === 'left' && <span className=\"label-text\">{label}</span>}\n {input}\n {labelPosition === 'right' && <span className=\"label-text\">{label}</span>}\n </label>\n );\n};\n\nexport default Checkbox;\n"],"mappings":";;AAiCA,IAAM,IAAuE;AAAA,EAC3E,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACT,GAEM,IAAiE;AAAA,EACrE,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEM,IAAA,CAAqC,EACzC,SAAA,GACA,gBAAA,GACA,UAAA,GACA,OAAA,GACA,eAAA,IAAgB,SAChB,SAAA,IAAU,WACV,MAAA,IAAO,MACP,UAAA,IAAW,IACX,eAAA,IAAgB,IAChB,MAAA,GACA,OAAA,GACA,WAAA,IAAY,IACZ,OAAA,GACA,IAAA,EAAA,MACI;AACJ,QAAM,IAAW,EAAyB,IAAI;AAG9C,EAAA,EAAA,MAAgB;AACd,IAAI,EAAS,YACX,EAAS,QAAQ,gBAAgB;AAAA,EAErC,GAAG,CAAC,CAAa,CAAC;AAElB,QAAM,IAAe,EAAA,CAClB,MAA2C;AAC1C,IAAA,IAAW,EAAE,OAAO,SAAS,CAAC;AAAA,EAChC,GACA,CAAC,CAAQ,CACX,GAEM,IAAe;AAAA,IACnB;AAAA,IACA,EAAc,CAAA;AAAA,IACd,EAAW,CAAA;AAAA,IAEX,KAAa,CAAC,IAAQ,IAAY;AAAA,EACpC,EACG,OAAO,OAAO,EACd,KAAK,GAAG,GAEL,IACJ,gBAAA,EAAC,SAAD;AAAA,IACE,KAAK;AAAA,IACD,IAAA;AAAA,IACJ,MAAK;AAAA,IACL,WAAW;AAAA,IACF,SAAA;AAAA,IACO,gBAAA;AAAA,IAChB,UAAU;AAAA,IACA,UAAA;AAAA,IACJ,MAAA;AAAA,IACC,OAAA;AAAA,IACP,gBAAc,IAAgB,UAAU;AAAA,EACzC,CAAA;AAIH,MAA2B,KAAU,QAAQ,MAAU,GACrD,QAAO;AAGT,QAAM,IAAe;AAAA,IACnB;AAAA,IACA,IAAW,kCAAkC;AAAA,IAC7C;AAAA,EACF,EACG,OAAO,OAAO,EACd,KAAK,GAAG;AAEX,SACE,gBAAA,EAAC,SAAD;AAAA,IAAO,WAAW;AAAA,IAAqB,OAAA;AAAA,IAAvC,UAAA;AAAA,MACG,MAAkB,UAAU,gBAAA,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,QAAc,UAAA;AAAA,MAAY,CAAA;AAAA,MACtE;AAAA,MACA,MAAkB,WAAW,gBAAA,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,QAAc,UAAA;AAAA,MAAY,CAAA;AAAA,IACnE;AAAA;AAEX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Demo/index.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';\nimport { coldarkDark } from 'react-syntax-highlighter/dist/esm/styles/prism';\nimport Button from '../../components/Button';\nimport Label from '../../components/Label';\nimport { useCopyToClipboard } from '../../hooks/useCopyToClipboard';\n\n// 代码块组件\nexport interface CodeBlockProps {\n children: string;\n language?: string;\n}\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({ children, language = 'jsx' }) => {\n const { copied, copy } = useCopyToClipboard();\n\n return (\n <div className=\"relative my-4\">\n <SyntaxHighlighter\n language={language}\n style={coldarkDark}\n customStyle={{\n borderRadius: '0.5rem',\n fontSize: '0.875rem',\n padding: '1rem',\n }}\n >\n {children}\n </SyntaxHighlighter>\n <Button\n variant=\"ghost\"\n size=\"xs\"\n className=\"absolute top-2 right-2\"\n onClick={() => copy(children)}\n >\n {copied ? (\n <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-4 w-4\" 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 <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-4 w-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3\" />\n </svg>\n )}\n </Button>\n </div>\n );\n};\n\n// 示例展示区域组件\nexport interface DemoProps {\n title: string;\n description?: string;\n children: React.ReactNode;\n code: string;\n language?: string;\n}\n\nconst Demo: React.FC<DemoProps> = ({\n title,\n description,\n children,\n code,\n language = 'jsx'\n}) => {\n const [showCode, setShowCode] = useState(false);\n\n return (\n <div className=\"border border-base-300 rounded-lg mb-8\">\n <div className=\"p-4 border-b border-base-300\">\n <h3 className=\"text-lg font-medium\">{title}</h3>\n {description && <p className=\"mt-1 text-sm opacity-70\">{description}</p>}\n </div>\n\n <div className=\"px-4 py-5 flex flex-wrap gap-4 items-center\">\n {children}\n </div>\n\n <div className=\"border-t border-base-300\">\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className=\"w-full flex justify-between items-center\"\n onClick={() => setShowCode(!showCode)}\n >\n <Label variant=\"neutral\">Source Code</Label>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className={`h-4 w-4 transition-transform ${showCode ? 'rotate-180' : ''}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M19 9l-7 7-7-7\" />\n </svg>\n </Button>\n\n {showCode && (\n <div className=\"p-4 bg-base-200\">\n <CodeBlock language={language}>{code}</CodeBlock>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default Demo; "],"mappings":";;;;;;;AAaA,IAAM,IAAA,CAAuC,EAAE,UAAA,GAAU,UAAA,IAAW,MAAA,MAAY;AAC9E,QAAM,EAAE,QAAA,GAAQ,MAAA,EAAA,IAAS,EAAmB;AAE5C,SACE,gBAAA,EAAC,OAAD;AAAA,IAAK,WAAU;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Demo/index.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';\nimport { coldarkDark } from 'react-syntax-highlighter/dist/esm/styles/prism';\nimport Button from '../../components/Button';\nimport Label from '../../components/Label';\nimport { useCopyToClipboard } from '../../hooks/useCopyToClipboard';\n\n// 代码块组件\nexport interface CodeBlockProps {\n children: string;\n language?: string;\n}\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({ children, language = 'jsx' }) => {\n const { copied, copy } = useCopyToClipboard();\n\n return (\n <div className=\"relative my-4\">\n <SyntaxHighlighter\n language={language}\n style={coldarkDark}\n customStyle={{\n borderRadius: '0.5rem',\n fontSize: '0.875rem',\n padding: '1rem',\n }}\n >\n {children}\n </SyntaxHighlighter>\n <Button\n variant=\"ghost\"\n size=\"xs\"\n className=\"absolute top-2 right-2\"\n onClick={() => copy(children)}\n >\n {copied ? (\n <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-4 w-4\" 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 <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-4 w-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3\" />\n </svg>\n )}\n </Button>\n </div>\n );\n};\n\n// 示例展示区域组件\nexport interface DemoProps {\n title: string;\n description?: string;\n children: React.ReactNode;\n code: string;\n language?: string;\n}\n\nconst Demo: React.FC<DemoProps> = ({\n title,\n description,\n children,\n code,\n language = 'jsx'\n}) => {\n const [showCode, setShowCode] = useState(false);\n\n return (\n <div className=\"border border-base-300 rounded-lg mb-8\">\n <div className=\"p-4 border-b border-base-300\">\n <h3 className=\"text-lg font-medium\">{title}</h3>\n {description && <p className=\"mt-1 text-sm opacity-70\">{description}</p>}\n </div>\n\n <div className=\"px-4 py-5 flex flex-wrap gap-4 items-center\">\n {children}\n </div>\n\n <div className=\"border-t border-base-300\">\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className=\"w-full flex justify-between items-center\"\n onClick={() => setShowCode(!showCode)}\n >\n <Label variant=\"neutral\">Source Code</Label>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className={`h-4 w-4 transition-transform ${showCode ? 'rotate-180' : ''}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M19 9l-7 7-7-7\" />\n </svg>\n </Button>\n\n {showCode && (\n <div className=\"p-4 bg-base-200\">\n <CodeBlock language={language}>{code}</CodeBlock>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default Demo; "],"mappings":";;;;;;;AAaA,IAAM,IAAA,CAAuC,EAAE,UAAA,GAAU,UAAA,IAAW,MAAA,MAAY;AAC9E,QAAM,EAAE,QAAA,GAAQ,MAAA,EAAA,IAAS,EAAmB;AAE5C,SACE,gBAAA,EAAC,OAAD;AAAA,IAAK,WAAU;AAAA,IAAf,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,MACY,UAAA;AAAA,MACV,OAAO;AAAA,MACP,aAAa;AAAA,QACX,cAAc;AAAA,QACd,UAAU;AAAA,QACV,SAAS;AAAA,MACX;AAAA,MAEC,UAAA;AAAA,IACgB,CAAA,GACnB,gBAAA,EAAC,GAAD;AAAA,MACE,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,WAAU;AAAA,MACV,SAAA,MAAe,EAAK,CAAQ;AAAA,MAE3B,UAAA,IACC,gBAAA,EAAC,OAAD;AAAA,QAAK,OAAM;AAAA,QAA6B,WAAU;AAAA,QAAU,MAAK;AAAA,QAAO,SAAQ;AAAA,QAAY,QAAO;AAAA,QACjG,UAAA,gBAAA,EAAC,QAAD;AAAA,UAAM,eAAc;AAAA,UAAQ,gBAAe;AAAA,UAAQ,aAAY;AAAA,UAAI,GAAE;AAAA,QAAkB,CAAA;AAAA,MACpF,CAAA,IAEL,gBAAA,EAAC,OAAD;AAAA,QAAK,OAAM;AAAA,QAA6B,WAAU;AAAA,QAAU,MAAK;AAAA,QAAO,SAAQ;AAAA,QAAY,QAAO;AAAA,QACjG,UAAA,gBAAA,EAAC,QAAD;AAAA,UAAM,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,CAAA,CACC;AAAA,QAEP,CAAA,GAAA,KACC,gBAAA,EAAC,OAAD;AAAA,UAAK,WAAU;AAAA,UACb,UAAA,gBAAA,EAAC,GAAD;AAAA,YAAqB,UAAA;AAAA,YAAW,UAAA;AAAA,UAAgB,CAAA;AAAA,QAC7C,CAAA,CAEJ;AAAA;IACF;AAAA;AAET"}
|
|
@@ -8,10 +8,13 @@ export type EmptyStateProps = {
|
|
|
8
8
|
description?: React.ReactNode;
|
|
9
9
|
/** 底部操作(按钮等) */
|
|
10
10
|
action?: React.ReactNode;
|
|
11
|
+
/** 是否默认填满所在区域(宽高 100%,内容居中);默认 true */
|
|
12
|
+
fill?: boolean;
|
|
11
13
|
className?: string;
|
|
12
14
|
};
|
|
13
15
|
/**
|
|
14
16
|
* 空状态:虚线边框卡片 + 图标 + 标题 + 说明,统一列表为空时的展示。
|
|
17
|
+
* 默认填满所在区域(fill),在固定高度的容器内自动垂直居中。
|
|
15
18
|
*/
|
|
16
|
-
declare const EmptyState: ({ icon, title, description, action, className, }: EmptyStateProps) => React.JSX.Element;
|
|
19
|
+
declare const EmptyState: ({ icon, title, description, action, fill, className, }: EmptyStateProps) => React.JSX.Element;
|
|
17
20
|
export default EmptyState;
|