dishui 0.0.82 → 0.0.84
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/Button/index.d.ts +1 -0
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/ButtonMenu/index.d.ts +28 -0
- package/dist/components/ButtonMenu/index.js +197 -0
- package/dist/components/ButtonMenu/index.js.map +1 -0
- package/dist/components/Demo/index.d.ts +5 -0
- package/dist/components/Demo/index.js +131 -56
- package/dist/components/Demo/index.js.map +1 -1
- package/dist/components/Demo/source.d.ts +9 -0
- package/dist/components/Demo/source.js +32 -0
- package/dist/components/Demo/source.js.map +1 -0
- package/dist/components/Field/index.d.ts +8 -0
- package/dist/components/Field/index.js +43 -0
- package/dist/components/Field/index.js.map +1 -0
- package/dist/components/LayoutSuite/DashboardSuite.d.ts +35 -0
- package/dist/components/LayoutSuite/DashboardSuite.js +61 -0
- package/dist/components/LayoutSuite/DashboardSuite.js.map +1 -0
- package/dist/components/LayoutSuite/index.d.ts +56 -0
- package/dist/components/LayoutSuite/index.js +101 -0
- package/dist/components/LayoutSuite/index.js.map +1 -0
- package/dist/components/Modal/focusScope.d.ts +1 -0
- package/dist/components/Modal/focusScope.js +81 -0
- package/dist/components/Modal/focusScope.js.map +1 -0
- package/dist/components/Modal/index.d.ts +4 -1
- package/dist/components/Modal/index.js +48 -43
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Page/Float.d.ts +14 -0
- package/dist/components/Page/Float2.js +154 -0
- package/dist/components/Page/Float2.js.map +1 -0
- package/dist/components/Page/index.d.ts +34 -7
- package/dist/components/Page/index.js +117 -36
- package/dist/components/Page/index.js.map +1 -1
- package/dist/components/Page/resize.d.ts +28 -0
- package/dist/components/Page/resize2.js +95 -0
- package/dist/components/Page/resize2.js.map +1 -0
- package/dist/components/PageHeader/index.d.ts +10 -3
- package/dist/components/PageHeader/index.js +46 -25
- package/dist/components/PageHeader/index.js.map +1 -1
- package/dist/components/PagePanel/index.d.ts +29 -0
- package/dist/components/PagePanel/index.js +99 -0
- package/dist/components/PagePanel/index.js.map +1 -0
- package/dist/components/Resizable/ResizeGrip.d.ts +5 -0
- package/dist/components/Resizable/ResizeGrip.js +14 -0
- package/dist/components/Resizable/ResizeGrip.js.map +1 -0
- package/dist/components/Resizable/index.js +57 -59
- package/dist/components/Resizable/index.js.map +1 -1
- package/dist/components/Resizable/useResize.d.ts +6 -0
- package/dist/components/Resizable/useResize.js +29 -28
- package/dist/components/Resizable/useResize.js.map +1 -1
- package/dist/components/SidebarToggleButton/index.d.ts +5 -3
- package/dist/components/SidebarToggleButton/index.js +24 -21
- package/dist/components/SidebarToggleButton/index.js.map +1 -1
- package/dist/components/Table/index.d.ts +10 -12
- package/dist/components/Table/index.js +25 -20
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Text/index.d.ts +2 -2
- package/dist/components/Text/index.js +13 -12
- package/dist/components/Text/index.js.map +1 -1
- package/dist/components/Textarea/index.d.ts +14 -0
- package/dist/components/Textarea/index.js +44 -0
- package/dist/components/Textarea/index.js.map +1 -0
- package/dist/components/Tree/Tree.d.ts +2 -0
- package/dist/components/Tree/Tree.js +49 -40
- package/dist/components/Tree/Tree.js.map +1 -1
- package/dist/dishui.css +1 -1
- package/dist/index-nostyled.d.ts +9 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +119 -113
- package/dist/layouts/Sidebar.d.ts +14 -1
- package/dist/layouts/Sidebar.js +170 -137
- package/dist/layouts/Sidebar.js.map +1 -1
- package/dist/lite.d.ts +10 -2
- package/dist/lite.js +17 -12
- package/dist/utils/i18n.js +1 -1
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/menu.js +14 -16
- package/dist/utils/menu.js.map +1 -1
- package/package.json +3 -1
|
@@ -2,25 +2,28 @@ import { cn as e } from "../../utils/cn.js";
|
|
|
2
2
|
import "react";
|
|
3
3
|
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/Table/index.tsx
|
|
5
|
-
var r = ({ children: n, className: r = "", onClick: i, onMouseEnter: a, onMouseLeave: o }) => {
|
|
6
|
-
let
|
|
5
|
+
var r = ({ children: n, className: r = "", onClick: i, onMouseEnter: a, onMouseLeave: o, ...s }) => {
|
|
6
|
+
let c = e("table", r);
|
|
7
7
|
return /* @__PURE__ */ t("table", {
|
|
8
|
-
|
|
8
|
+
...s,
|
|
9
|
+
className: c,
|
|
9
10
|
onClick: i,
|
|
10
11
|
onMouseEnter: a,
|
|
11
12
|
onMouseLeave: o,
|
|
12
13
|
children: n
|
|
13
14
|
});
|
|
14
|
-
}, i = ({ children: n, className: r = "" }) => {
|
|
15
|
-
let
|
|
15
|
+
}, i = ({ children: n, className: r = "", ...i }) => {
|
|
16
|
+
let a = e("table-header-group", r);
|
|
16
17
|
return /* @__PURE__ */ t("thead", {
|
|
17
|
-
|
|
18
|
+
...i,
|
|
19
|
+
className: a,
|
|
18
20
|
children: n
|
|
19
21
|
});
|
|
20
|
-
}, a = ({ children: n, className: r = "" }) => {
|
|
21
|
-
let
|
|
22
|
+
}, a = ({ children: n, className: r = "", ...i }) => {
|
|
23
|
+
let a = e("table-row-group", r);
|
|
22
24
|
return /* @__PURE__ */ t("tbody", {
|
|
23
|
-
|
|
25
|
+
...i,
|
|
26
|
+
className: a,
|
|
24
27
|
children: n
|
|
25
28
|
});
|
|
26
29
|
}, o = ({ children: n, className: r = "", selected: i = !1, onClick: a, onDoubleClick: o, onMouseEnter: s, onMouseLeave: c, ...l }) => {
|
|
@@ -34,10 +37,11 @@ var r = ({ children: n, className: r = "", onClick: i, onMouseEnter: a, onMouseL
|
|
|
34
37
|
...l,
|
|
35
38
|
children: n
|
|
36
39
|
});
|
|
37
|
-
}, s = ({ children: n, className: r = "", onClick: i, colSpan: a, style: o, onDoubleClick: s, onMouseEnter: c, onMouseLeave: l }) => {
|
|
38
|
-
let
|
|
40
|
+
}, s = ({ children: n, className: r = "", onClick: i, colSpan: a, style: o, onDoubleClick: s, onMouseEnter: c, onMouseLeave: l, ...u }) => {
|
|
41
|
+
let d = e("table-cell", r);
|
|
39
42
|
return /* @__PURE__ */ t("td", {
|
|
40
|
-
|
|
43
|
+
...u,
|
|
44
|
+
className: d,
|
|
41
45
|
onClick: i,
|
|
42
46
|
colSpan: a,
|
|
43
47
|
style: o,
|
|
@@ -46,10 +50,11 @@ var r = ({ children: n, className: r = "", onClick: i, onMouseEnter: a, onMouseL
|
|
|
46
50
|
onMouseLeave: l,
|
|
47
51
|
children: n
|
|
48
52
|
});
|
|
49
|
-
}, c = ({ children: r, className: i = "", onClick: a, sortable: o = !1, sortDirection: s = null, draggable: c, onDragStart: l, onDragOver: u, onDrop: d, onMouseEnter: f, onMouseLeave: p }) => {
|
|
50
|
-
let
|
|
53
|
+
}, c = ({ children: r, className: i = "", onClick: a, sortable: o = !1, sortDirection: s = null, draggable: c, onDragStart: l, onDragOver: u, onDrop: d, onMouseEnter: f, onMouseLeave: p, ...m }) => {
|
|
54
|
+
let h = e("table-cell font-medium", o && "cursor-pointer", i);
|
|
51
55
|
return /* @__PURE__ */ t("th", {
|
|
52
|
-
|
|
56
|
+
...m,
|
|
57
|
+
className: h,
|
|
53
58
|
onClick: a,
|
|
54
59
|
draggable: c,
|
|
55
60
|
onDragStart: l,
|
|
@@ -57,7 +62,7 @@ var r = ({ children: n, className: r = "", onClick: i, onMouseEnter: a, onMouseL
|
|
|
57
62
|
onDrop: d,
|
|
58
63
|
onMouseEnter: f,
|
|
59
64
|
onMouseLeave: p,
|
|
60
|
-
children: /* @__PURE__ */ n("div", {
|
|
65
|
+
children: o ? /* @__PURE__ */ n("div", {
|
|
61
66
|
className: "flex items-center gap-2",
|
|
62
67
|
children: [r, o && /* @__PURE__ */ t("div", {
|
|
63
68
|
className: "flex flex-col",
|
|
@@ -102,11 +107,11 @@ var r = ({ children: n, className: r = "", onClick: i, onMouseEnter: a, onMouseL
|
|
|
102
107
|
})
|
|
103
108
|
})
|
|
104
109
|
})]
|
|
105
|
-
})
|
|
110
|
+
}) : r
|
|
106
111
|
});
|
|
107
|
-
}, l = r;
|
|
108
|
-
l.Head = i,
|
|
112
|
+
}, l = (e) => /* @__PURE__ */ t("caption", { ...e }), u = (e) => /* @__PURE__ */ t("tfoot", { ...e }), d = r;
|
|
113
|
+
d.Caption = l, d.Footer = u, d.Head = i, d.Body = a, d.Row = o, d.Cell = s, d.HeaderCell = c;
|
|
109
114
|
//#endregion
|
|
110
|
-
export {
|
|
115
|
+
export { d as default };
|
|
111
116
|
|
|
112
117
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Table/index.tsx"],"sourcesContent":["import React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type TableProps = {\n children: React.ReactNode;\n className?: string;\n onClick?: (e: React.MouseEvent) => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Table/index.tsx"],"sourcesContent":["import React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type TableProps = {\n children: React.ReactNode;\n className?: string;\n onClick?: (e: React.MouseEvent) => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n} & React.TableHTMLAttributes<HTMLTableElement>;\n\nconst Table = ({\n children,\n className = '',\n onClick,\n onMouseEnter,\n onMouseLeave,\n ...rest\n}: TableProps) => {\n const baseClass = 'table';\n \n const tableClasses = cn(baseClass, className);\n\n return (\n <table \n {...rest}\n className={tableClasses}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n >\n {children}\n </table>\n );\n};\n\n// Table.Head 组件\nexport type TableHeadProps = React.HTMLAttributes<HTMLTableSectionElement>;\n\nconst TableHead = ({\n children,\n className = '',\n ...rest\n}: TableHeadProps) => {\n const baseClass = 'table-header-group';\n \n const headClasses = cn(baseClass, className);\n\n return (\n <thead {...rest} className={headClasses}>\n {children}\n </thead>\n );\n};\n\n// Table.Body 组件\nexport type TableBodyProps = React.HTMLAttributes<HTMLTableSectionElement>;\n\nconst TableBody = ({\n children,\n className = '',\n ...rest\n}: TableBodyProps) => {\n const baseClass = 'table-row-group';\n \n const bodyClasses = cn(baseClass, className);\n\n return (\n <tbody {...rest} className={bodyClasses}>\n {children}\n </tbody>\n );\n};\n\n// Table.Row 组件\nexport type TableRowProps = {\n children: React.ReactNode;\n className?: string;\n selected?: boolean;\n onClick?: (e: React.MouseEvent) => void;\n onDoubleClick?: (e: React.MouseEvent) => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n} & Omit<\n React.HTMLAttributes<HTMLTableRowElement>,\n 'className' | 'onClick' | 'onDoubleClick' | 'onMouseEnter' | 'onMouseLeave'\n>;\n\nconst TableRow = ({\n children,\n className = '',\n selected = false,\n onClick,\n onDoubleClick,\n onMouseEnter,\n onMouseLeave,\n ...rest\n}: TableRowProps) => {\n const baseClass = 'table-row';\n\n const rowClasses = cn(\n baseClass,\n selected && 'bg-base-200',\n 'hover:bg-base-100',\n className\n );\n\n return (\n <tr \n className={rowClasses}\n onClick={onClick}\n onDoubleClick={onDoubleClick}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n {...rest}\n >\n {children}\n </tr>\n );\n};\n\n// Table.Cell 组件\nexport type TableCellProps = {\n children?: React.ReactNode;\n className?: string;\n onClick?: (e: React.MouseEvent) => void;\n colSpan?: number;\n style?: React.CSSProperties;\n \n // 添加鼠标事件\n onDoubleClick?: (e: React.MouseEvent) => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n} & React.TdHTMLAttributes<HTMLTableCellElement>;\n\nconst TableCell = ({\n children,\n className = '',\n onClick,\n colSpan,\n style,\n onDoubleClick,\n onMouseEnter,\n onMouseLeave,\n ...rest\n}: TableCellProps) => {\n const baseClass = 'table-cell';\n \n const cellClasses = cn(baseClass, className);\n\n return (\n <td\n {...rest}\n className={cellClasses}\n onClick={onClick}\n colSpan={colSpan}\n style={style}\n onDoubleClick={onDoubleClick}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n >\n {children}\n </td>\n );\n};\n\n// Table.HeaderCell 组件\nexport type TableHeaderCellProps = {\n children: React.ReactNode;\n className?: string;\n onClick?: (e: React.MouseEvent) => void;\n sortable?: boolean;\n sortDirection?: 'asc' | 'desc' | null;\n \n // 拖拽相关属性\n draggable?: boolean;\n onDragStart?: (e: React.DragEvent) => void;\n onDragOver?: (e: React.DragEvent) => void;\n onDrop?: (e: React.DragEvent) => void;\n \n // 鼠标事件\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n} & React.ThHTMLAttributes<HTMLTableCellElement>;\n\nconst TableHeaderCell = ({\n children,\n className = '',\n onClick,\n sortable = false,\n sortDirection = null,\n \n // 拖拽相关属性\n draggable,\n onDragStart,\n onDragOver,\n onDrop,\n \n // 鼠标事件\n onMouseEnter,\n onMouseLeave,\n ...rest\n}: TableHeaderCellProps) => {\n const baseClass = 'table-cell font-medium';\n \n const headerCellClasses = cn(\n baseClass,\n sortable && 'cursor-pointer',\n className\n );\n\n return (\n <th\n {...rest}\n className={headerCellClasses}\n onClick={onClick}\n draggable={draggable}\n onDragStart={onDragStart}\n onDragOver={onDragOver}\n onDrop={onDrop}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n >\n {sortable ? <div className=\"flex items-center gap-2\">\n {children}\n {sortable && (\n <div className=\"flex flex-col\">\n {sortDirection === 'asc' ? (\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 15l7-7 7 7\" />\n </svg>\n ) : sortDirection === 'desc' ? (\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=\"M19 9l-7 7-7-7\" />\n </svg>\n ) : (\n <div className=\"h-4 w-4 opacity-30\">\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=\"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4\" />\n </svg>\n </div>\n )}\n </div>\n )}\n </div> : children}\n </th>\n );\n};\n\nexport type TableCaptionProps = React.HTMLAttributes<HTMLTableCaptionElement>;\nexport type TableFooterProps = React.HTMLAttributes<HTMLTableSectionElement>;\nconst TableCaption = (props: TableCaptionProps) => <caption {...props} />;\nconst TableFooter = (props: TableFooterProps) => <tfoot {...props} />;\n\n// 扩展Table组件,添加子组件\ninterface TableCompound extends React.FC<TableProps> {\n Caption: React.FC<TableCaptionProps>;\n Footer: React.FC<TableFooterProps>;\n Head: React.FC<TableHeadProps>;\n Body: React.FC<TableBodyProps>;\n Row: React.FC<TableRowProps>;\n Cell: React.FC<TableCellProps>;\n HeaderCell: React.FC<TableHeaderCellProps>;\n}\n\nconst TableWithCompounds = Table as TableCompound;\nTableWithCompounds.Caption = TableCaption;\nTableWithCompounds.Footer = TableFooter;\nTableWithCompounds.Head = TableHead;\nTableWithCompounds.Body = TableBody;\nTableWithCompounds.Row = TableRow;\nTableWithCompounds.Cell = TableCell;\nTableWithCompounds.HeaderCell = TableHeaderCell;\n\nexport default TableWithCompounds; "],"mappings":";;;;AAWA,IAAM,KAAS,EACb,aACA,eAAY,IACZ,YACA,iBACA,iBACA,GAAG,QACa;CAGhB,IAAM,IAAe,EAAG,SAAW,CAAS;CAE5C,OACE,kBAAC,SAAD;EACE,GAAI;EACJ,WAAW;EACF;EACK;EACA;EAEb;CACI,CAAA;AAEX,GAKM,KAAa,EACjB,aACA,eAAY,IACZ,GAAG,QACiB;CAGpB,IAAM,IAAc,EAAG,sBAAW,CAAS;CAE3C,OACE,kBAAC,SAAD;EAAO,GAAI;EAAM,WAAW;EACzB;CACI,CAAA;AAEX,GAKM,KAAa,EACjB,aACA,eAAY,IACZ,GAAG,QACiB;CAGpB,IAAM,IAAc,EAAG,mBAAW,CAAS;CAE3C,OACE,kBAAC,SAAD;EAAO,GAAI;EAAM,WAAW;EACzB;CACI,CAAA;AAEX,GAgBM,KAAY,EAChB,aACA,eAAY,IACZ,cAAW,IACX,YACA,kBACA,iBACA,iBACA,GAAG,QACgB;CAGnB,IAAM,IAAa,EACjB,aACA,KAAY,eACZ,qBACA,CACF;CAEA,OACE,kBAAC,MAAD;EACE,WAAW;EACF;EACM;EACD;EACA;EACd,GAAI;EAEH;CACC,CAAA;AAER,GAgBM,KAAa,EACjB,aACA,eAAY,IACZ,YACA,YACA,UACA,kBACA,iBACA,iBACA,GAAG,QACiB;CAGpB,IAAM,IAAc,EAAG,cAAW,CAAS;CAE3C,OACE,kBAAC,MAAD;EACE,GAAI;EACJ,WAAW;EACF;EACA;EACF;EACQ;EACD;EACA;EAEb;CACC,CAAA;AAER,GAqBM,KAAmB,EACvB,aACA,eAAY,IACZ,YACA,cAAW,IACX,mBAAgB,MAGhB,cACA,gBACA,eACA,WAGA,iBACA,iBACA,GAAG,QACuB;CAG1B,IAAM,IAAoB,EACxB,0BACA,KAAY,kBACZ,CACF;CAEA,OACE,kBAAC,MAAD;EACE,GAAI;EACJ,WAAW;EACF;EACE;EACE;EACD;EACJ;EACM;EACA;EAEb,UAAA,IAAW,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACT,GACA,KACC,kBAAC,OAAD;IAAK,WAAU;IACZ,UAAA,MAAkB,QACjB,kBAAC,OAAD;KAAK,OAAM;KAA6B,WAAU;KAAU,MAAK;KAAO,SAAQ;KAAY,QAAO;KACjG,UAAA,kBAAC,QAAD;MAAM,eAAc;MAAQ,gBAAe;MAAQ,aAAY;MAAI,GAAE;KAAiB,CAAA;IACnF,CAAA,IACH,MAAkB,SACpB,kBAAC,OAAD;KAAK,OAAM;KAA6B,WAAU;KAAU,MAAK;KAAO,SAAQ;KAAY,QAAO;KACjG,UAAA,kBAAC,QAAD;MAAM,eAAc;MAAQ,gBAAe;MAAQ,aAAY;MAAI,GAAE;KAAkB,CAAA;IACpF,CAAA,IAEL,kBAAC,OAAD;KAAK,WAAU;KACb,UAAA,kBAAC,OAAD;MAAK,OAAM;MAA6B,WAAU;MAAU,MAAK;MAAO,SAAQ;MAAY,QAAO;MACjG,UAAA,kBAAC,QAAD;OAAM,eAAc;OAAQ,gBAAe;OAAQ,aAAY;OAAI,GAAE;MAAoD,CAAA;KACtH,CAAA;IACF,CAAA;GAEJ,CAAA,CAEJ;EAAI,CAAA,IAAA;CACP,CAAA;AAER,GAIM,KAAgB,MAA6B,kBAAC,WAAD,EAAS,GAAI,EAAQ,CAAA,GAClE,KAAe,MAA4B,kBAAC,SAAD,EAAO,GAAI,EAAQ,CAAA,GAa9D,IAAqB;AAC3B,EAAmB,UAAU,GAC7B,EAAmB,SAAS,GAC5B,EAAmB,OAAO,GAC1B,EAAmB,OAAO,GAC1B,EAAmB,MAAM,GACzB,EAAmB,OAAO,GAC1B,EAAmB,aAAa"}
|
|
@@ -4,7 +4,7 @@ export type TextSize = 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl
|
|
|
4
4
|
export type TextWeight = 'normal' | 'medium' | 'semibold' | 'bold';
|
|
5
5
|
export type TextColor = 'default' | 'muted' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'inherit';
|
|
6
6
|
export type TextAlign = 'left' | 'center' | 'right' | 'justify';
|
|
7
|
-
export type TextProps = {
|
|
7
|
+
export type TextProps = Omit<React.HTMLAttributes<HTMLElement>, 'color'> & {
|
|
8
8
|
children?: React.ReactNode;
|
|
9
9
|
/** Rendered HTML element. */
|
|
10
10
|
as?: TextElement;
|
|
@@ -12,7 +12,7 @@ export type TextProps = {
|
|
|
12
12
|
size?: TextSize;
|
|
13
13
|
/** Font weight. */
|
|
14
14
|
weight?: TextWeight;
|
|
15
|
-
/**
|
|
15
|
+
/** `muted` is neutral supporting text; `secondary` is the explicit theme brand color. */
|
|
16
16
|
color?: TextColor;
|
|
17
17
|
/** Text alignment. */
|
|
18
18
|
align?: TextAlign;
|
|
@@ -18,9 +18,9 @@ var n = {
|
|
|
18
18
|
bold: "font-bold"
|
|
19
19
|
}, i = {
|
|
20
20
|
default: "text-base-content",
|
|
21
|
-
muted: "text-
|
|
21
|
+
muted: "text-[color:var(--dishui-text-secondary)]",
|
|
22
22
|
primary: "text-primary",
|
|
23
|
-
secondary: "text-secondary",
|
|
23
|
+
secondary: "text-[color:var(--color-secondary)]",
|
|
24
24
|
accent: "text-accent",
|
|
25
25
|
info: "text-info",
|
|
26
26
|
success: "text-success",
|
|
@@ -32,17 +32,18 @@ var n = {
|
|
|
32
32
|
center: "text-center",
|
|
33
33
|
right: "text-right",
|
|
34
34
|
justify: "text-justify"
|
|
35
|
-
}, o = ({ children: o, as: s = "span", size: c = "base", weight: l = "normal", color: u = "default", align: d, truncate: f = !1, clamp: p, italic: m = !1, underline: h = !1, uppercase: g = !1, mono: _ = !1, className: v = "", style: y, onClick: b }) => {
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
}, o = ({ children: o, as: s = "span", size: c = "base", weight: l = "normal", color: u = "default", align: d, truncate: f = !1, clamp: p, italic: m = !1, underline: h = !1, uppercase: g = !1, mono: _ = !1, className: v = "", style: y, onClick: b, ...x }) => {
|
|
36
|
+
let S = s, C = e(n[c], r[l], i[u], d && a[d], f && "truncate", m && "italic", h && "underline", g && "uppercase tracking-wider", _ && "font-mono", !f && p && p > 0 && "overflow-hidden", v), w = !f && p && p > 0 ? {
|
|
37
|
+
display: "-webkit-box",
|
|
38
|
+
WebkitLineClamp: p,
|
|
39
|
+
WebkitBoxOrient: "vertical",
|
|
40
|
+
overflow: "hidden"
|
|
41
|
+
} : {};
|
|
42
|
+
return /* @__PURE__ */ t(S, {
|
|
43
|
+
...x,
|
|
44
|
+
className: C,
|
|
39
45
|
style: {
|
|
40
|
-
|
|
41
|
-
display: "-webkit-box",
|
|
42
|
-
WebkitLineClamp: p,
|
|
43
|
-
WebkitBoxOrient: "vertical",
|
|
44
|
-
overflow: "hidden"
|
|
45
|
-
} : {},
|
|
46
|
+
...w,
|
|
46
47
|
...y
|
|
47
48
|
},
|
|
48
49
|
onClick: b,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Text/index.tsx"],"sourcesContent":["import React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type TextElement =\n | 'span'\n | 'p'\n | 'div'\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'h6'\n | 'strong'\n | 'em'\n | 'small'\n | 'code';\n\nexport type TextSize =\n | 'xs'\n | 'sm'\n | 'base'\n | 'lg'\n | 'xl'\n | '2xl'\n | '3xl'\n | '4xl';\n\nexport type TextWeight = 'normal' | 'medium' | 'semibold' | 'bold';\n\nexport type TextColor =\n | 'default'\n | 'muted'\n | 'primary'\n | 'secondary'\n | 'accent'\n | 'info'\n | 'success'\n | 'warning'\n | 'error'\n | 'inherit';\n\nexport type TextAlign = 'left' | 'center' | 'right' | 'justify';\n\nexport type TextProps = {\n children?: React.ReactNode;\n /** Rendered HTML element. */\n as?: TextElement;\n /** Font size preset. */\n size?: TextSize;\n /** Font weight. */\n weight?: TextWeight;\n /**
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Text/index.tsx"],"sourcesContent":["import React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type TextElement =\n | 'span'\n | 'p'\n | 'div'\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'h6'\n | 'strong'\n | 'em'\n | 'small'\n | 'code';\n\nexport type TextSize =\n | 'xs'\n | 'sm'\n | 'base'\n | 'lg'\n | 'xl'\n | '2xl'\n | '3xl'\n | '4xl';\n\nexport type TextWeight = 'normal' | 'medium' | 'semibold' | 'bold';\n\nexport type TextColor =\n | 'default'\n | 'muted'\n | 'primary'\n | 'secondary'\n | 'accent'\n | 'info'\n | 'success'\n | 'warning'\n | 'error'\n | 'inherit';\n\nexport type TextAlign = 'left' | 'center' | 'right' | 'justify';\n\nexport type TextProps = Omit<React.HTMLAttributes<HTMLElement>, 'color'> & {\n children?: React.ReactNode;\n /** Rendered HTML element. */\n as?: TextElement;\n /** Font size preset. */\n size?: TextSize;\n /** Font weight. */\n weight?: TextWeight;\n /** `muted` is neutral supporting text; `secondary` is the explicit theme brand color. */\n color?: TextColor;\n /** Text alignment. */\n align?: TextAlign;\n /** Single-line ellipsis. */\n truncate?: boolean;\n /** Multi-line clamp (number of lines). */\n clamp?: number;\n /** Italic style. */\n italic?: boolean;\n /** Underline decoration. */\n underline?: boolean;\n /** Uppercase + letter-spacing (overline style). */\n uppercase?: boolean;\n /** Monospace font. */\n mono?: boolean;\n /** Extra class names. */\n className?: string;\n /** Inline styles. */\n style?: React.CSSProperties;\n /** Click handler. */\n onClick?: (e: React.MouseEvent<HTMLElement>) => void;\n};\n\nconst SIZE_CLASS: Record<TextSize, string> = {\n xs: 'text-xs',\n sm: 'text-sm',\n base: 'text-base',\n lg: 'text-lg',\n xl: 'text-xl',\n '2xl': 'text-2xl',\n '3xl': 'text-3xl',\n '4xl': 'text-4xl',\n};\n\nconst WEIGHT_CLASS: Record<TextWeight, string> = {\n normal: 'font-normal',\n medium: 'font-medium',\n semibold: 'font-semibold',\n bold: 'font-bold',\n};\n\nconst COLOR_CLASS: Record<TextColor, string> = {\n default: 'text-base-content',\n muted: 'text-[color:var(--dishui-text-secondary)]',\n primary: 'text-primary',\n secondary: 'text-[color:var(--color-secondary)]',\n accent: 'text-accent',\n info: 'text-info',\n success: 'text-success',\n warning: 'text-warning',\n error: 'text-error',\n inherit: '',\n};\n\nconst ALIGN_CLASS: Record<TextAlign, string> = {\n left: 'text-left',\n center: 'text-center',\n right: 'text-right',\n justify: 'text-justify',\n};\n\n/**\n * Text —— A2UI 展示组件:文本排版原语。\n * 统一字号 / 字重 / 语义色 / 对齐与截断,替代散落各处的裸 `text-*` 组合。\n */\nconst Text: React.FC<TextProps> = ({\n children,\n as = 'span',\n size = 'base',\n weight = 'normal',\n color = 'default',\n align,\n truncate = false,\n clamp,\n italic = false,\n underline = false,\n uppercase = false,\n mono = false,\n className = '',\n style,\n onClick,\n ...attributes\n}) => {\n const Tag = as as React.ElementType;\n\n const classes = cn(\n SIZE_CLASS[size],\n WEIGHT_CLASS[weight],\n COLOR_CLASS[color],\n align && ALIGN_CLASS[align],\n truncate && 'truncate',\n italic && 'italic',\n underline && 'underline',\n uppercase && 'uppercase tracking-wider',\n mono && 'font-mono',\n !truncate && clamp && clamp > 0 && 'overflow-hidden',\n className,\n );\n\n const clampStyle: React.CSSProperties =\n !truncate && clamp && clamp > 0\n ? {\n display: '-webkit-box',\n WebkitLineClamp: clamp,\n WebkitBoxOrient: 'vertical',\n overflow: 'hidden',\n }\n : {};\n\n return (\n <Tag {...attributes} className={classes} style={{ ...clampStyle, ...style }} onClick={onClick}>\n {children}\n </Tag>\n );\n};\n\nexport default Text;\n"],"mappings":";;;;AA4EA,IAAM,IAAuC;CAC3C,IAAI;CACJ,IAAI;CACJ,MAAM;CACN,IAAI;CACJ,IAAI;CACJ,OAAO;CACP,OAAO;CACP,OAAO;AACT,GAEM,IAA2C;CAC/C,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,MAAM;AACR,GAEM,IAAyC;CAC7C,SAAS;CACT,OAAO;CACP,SAAS;CACT,WAAW;CACX,QAAQ;CACR,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;CACP,SAAS;AACX,GAEM,IAAyC;CAC7C,MAAM;CACN,QAAQ;CACR,OAAO;CACP,SAAS;AACX,GAMM,KAA6B,EACjC,aACA,QAAK,QACL,UAAO,QACP,YAAS,UACT,WAAQ,WACR,UACA,cAAW,IACX,UACA,YAAS,IACT,eAAY,IACZ,eAAY,IACZ,UAAO,IACP,eAAY,IACZ,UACA,YACA,GAAG,QACC;CACJ,IAAM,IAAM,GAEN,IAAU,EACd,EAAW,IACX,EAAa,IACb,EAAY,IACZ,KAAS,EAAY,IACrB,KAAY,YACZ,KAAU,UACV,KAAa,aACb,KAAa,4BACb,KAAQ,aACR,CAAC,KAAY,KAAS,IAAQ,KAAK,mBACnC,CACF,GAEM,IACJ,CAAC,KAAY,KAAS,IAAQ,IAC1B;EACE,SAAS;EACT,iBAAiB;EACjB,iBAAiB;EACjB,UAAU;CACZ,IACA,CAAC;CAEP,OACE,kBAAC,GAAD;EAAK,GAAI;EAAY,WAAW;EAAS,OAAO;GAAE,GAAG;GAAY,GAAG;EAAM;EAAY;EACnF;CACE,CAAA;AAET"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
3
|
+
label?: React.ReactNode;
|
|
4
|
+
description?: React.ReactNode;
|
|
5
|
+
error?: React.ReactNode;
|
|
6
|
+
wrapperClassName?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const Textarea: React.ForwardRefExoticComponent<React.TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
9
|
+
label?: React.ReactNode;
|
|
10
|
+
description?: React.ReactNode;
|
|
11
|
+
error?: React.ReactNode;
|
|
12
|
+
wrapperClassName?: string;
|
|
13
|
+
} & React.RefAttributes<HTMLTextAreaElement>>;
|
|
14
|
+
export default Textarea;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
import { forwardRef as e, useId as t } from "react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/Textarea/index.tsx
|
|
5
|
+
var i = (e) => e != null && typeof e != "boolean" && e !== "", a = e(function({ label: e, description: a, error: o, wrapperClassName: s = "", className: c = "", id: l, "aria-describedby": u, "aria-invalid": d, ...f }, p) {
|
|
6
|
+
let m = t(), h = l ?? m, g = `${m}-description`, _ = `${m}-error`, v = i(a), y = i(o), b = [
|
|
7
|
+
u,
|
|
8
|
+
v ? g : void 0,
|
|
9
|
+
y ? _ : void 0
|
|
10
|
+
].filter(Boolean).join(" ") || void 0;
|
|
11
|
+
return /* @__PURE__ */ r("div", {
|
|
12
|
+
className: `w-full space-y-2 ${s}`.trim(),
|
|
13
|
+
children: [
|
|
14
|
+
i(e) && /* @__PURE__ */ n("label", {
|
|
15
|
+
htmlFor: h,
|
|
16
|
+
className: "block text-sm font-medium",
|
|
17
|
+
children: e
|
|
18
|
+
}),
|
|
19
|
+
/* @__PURE__ */ n("textarea", {
|
|
20
|
+
...f,
|
|
21
|
+
ref: p,
|
|
22
|
+
id: h,
|
|
23
|
+
"aria-describedby": b,
|
|
24
|
+
"aria-invalid": y ? !0 : d,
|
|
25
|
+
className: `textarea dishui-textarea w-full resize-y rounded-md border-strong bg-page p-3 text-sm text-primary placeholder:text-tertiary ${c}`.trim()
|
|
26
|
+
}),
|
|
27
|
+
v && /* @__PURE__ */ n("div", {
|
|
28
|
+
id: g,
|
|
29
|
+
className: "text-xs leading-5 text-secondary",
|
|
30
|
+
children: a
|
|
31
|
+
}),
|
|
32
|
+
y && /* @__PURE__ */ n("div", {
|
|
33
|
+
id: _,
|
|
34
|
+
role: "alert",
|
|
35
|
+
className: "text-xs leading-5 text-error",
|
|
36
|
+
children: o
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
//#endregion
|
|
42
|
+
export { a as default };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Textarea/index.tsx"],"sourcesContent":["import React, { forwardRef, useId } from 'react';\nimport './Textarea.css';\n\nexport type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement> & {\n label?: React.ReactNode;\n description?: React.ReactNode;\n error?: React.ReactNode;\n wrapperClassName?: string;\n};\n\nconst hasContent = (node: React.ReactNode) => node !== undefined && node !== null && typeof node !== 'boolean' && node !== '';\n\nconst Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(function Textarea({\n label,\n description,\n error,\n wrapperClassName = '',\n className = '',\n id,\n 'aria-describedby': describedBy,\n 'aria-invalid': invalid,\n ...attributes\n}, ref) {\n const generatedId = useId();\n const fieldId = id ?? generatedId;\n const descriptionId = `${generatedId}-description`;\n const errorId = `${generatedId}-error`;\n const showDescription = hasContent(description);\n const showError = hasContent(error);\n const descriptionIds = [describedBy, showDescription ? descriptionId : undefined, showError ? errorId : undefined].filter(Boolean).join(' ') || undefined;\n\n return (\n <div className={`w-full space-y-2 ${wrapperClassName}`.trim()}>\n {hasContent(label) && <label htmlFor={fieldId} className=\"block text-sm font-medium\">{label}</label>}\n <textarea\n {...attributes}\n ref={ref}\n id={fieldId}\n aria-describedby={descriptionIds}\n aria-invalid={showError ? true : invalid}\n className={`textarea dishui-textarea w-full resize-y rounded-md border-strong bg-page p-3 text-sm text-primary placeholder:text-tertiary ${className}`.trim()}\n />\n {showDescription && <div id={descriptionId} className=\"text-xs leading-5 text-secondary\">{description}</div>}\n {showError && <div id={errorId} role=\"alert\" className=\"text-xs leading-5 text-error\">{error}</div>}\n </div>\n );\n});\n\nexport default Textarea;\n"],"mappings":";;;;AAUA,IAAM,KAAc,MAA0B,KAA+B,QAAQ,OAAO,KAAS,aAAa,MAAS,IAErH,IAAW,EAA+C,SAAkB,EAC9E,UACA,gBACA,UACA,sBAAmB,IACnB,eAAY,IACZ,OACA,oBAAoB,GACpB,gBAAgB,GAChB,GAAG,KACJ,GAAK;CACJ,IAAM,IAAc,EAAM,GACpB,IAAU,KAAM,GAChB,IAAgB,GAAG,EAAY,eAC/B,IAAU,GAAG,EAAY,SACzB,IAAkB,EAAW,CAAW,GACxC,IAAY,EAAW,CAAK,GAC5B,IAAiB;EAAC;EAAa,IAAkB,IAAgB,KAAA;EAAW,IAAY,IAAU,KAAA;CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;CAEhJ,OACI,kBAAC,OAAD;EAAK,WAAW,oBAAoB,IAAmB,KAAK;EAA5D,UAAA;GACK,EAAW,CAAK,KAAK,kBAAC,SAAD;IAAO,SAAS;IAAS,WAAU;IAA6B,UAAA;GAAa,CAAA;GACnG,kBAAC,YAAD;IACI,GAAI;IACC;IACL,IAAI;IACJ,oBAAkB;IAClB,gBAAc,IAAY,KAAO;IACjC,WAAW,gIAAgI,IAAY,KAAK;GAC/J,CAAA;GACA,KAAmB,kBAAC,OAAD;IAAK,IAAI;IAAe,WAAU;IAAoC,UAAA;GAAiB,CAAA;GAC1G,KAAa,kBAAC,OAAD;IAAK,IAAI;IAAS,MAAK;IAAQ,WAAU;IAAgC,UAAA;GAAW,CAAA;EACjG;;AAEb,CAAC"}
|
|
@@ -62,6 +62,8 @@ export interface TreeProps {
|
|
|
62
62
|
draggable?: boolean;
|
|
63
63
|
/** 是否可选择(暂不实现) */
|
|
64
64
|
checkable?: boolean;
|
|
65
|
+
/** Custom label content; depth is zero-based. The string label remains the search text and native title. */
|
|
66
|
+
renderLabel?: (node: TreeNode, depth: number) => React.ReactNode;
|
|
65
67
|
/** 自定义渲染节点 */
|
|
66
68
|
renderNode?: (node: TreeNode, defaultRender: React.ReactNode) => React.ReactNode;
|
|
67
69
|
}
|
|
@@ -2,15 +2,15 @@ import { generateTreeActiveStyles as e } from "../../styles/themeStyles.js";
|
|
|
2
2
|
import t, { useCallback as n, useMemo as r, useState as i } from "react";
|
|
3
3
|
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/Tree/Tree.tsx
|
|
5
|
-
var c = ({ data: c, onNodeClick: l, onNodeDoubleClick: u, onNodeToggle: d, activeNodeId: f, defaultExpandedIds: p = [], showSearch: m = !0, searchPlaceholder: h = "Search...", showExpandAll: g = !0, expandAllText: _ = "Expand All", collapseAllText: v = "Collapse All", showIcon: y = !0, defaultIcon: b, expandIcon: x, collapseIcon: S, showLine: C = !1, maxHeight: w = "600px", className: T = "", title: E, titleIcon: D, showCount: O = !0, emptyText: k = "No data", noResultsText: A = "No results found", indent: j = 16, togglePosition: M = "left",
|
|
6
|
-
let [
|
|
5
|
+
var c = ({ data: c, onNodeClick: l, onNodeDoubleClick: u, onNodeToggle: d, activeNodeId: f, defaultExpandedIds: p = [], showSearch: m = !0, searchPlaceholder: h = "Search...", showExpandAll: g = !0, expandAllText: _ = "Expand All", collapseAllText: v = "Collapse All", showIcon: y = !0, defaultIcon: b, expandIcon: x, collapseIcon: S, showLine: C = !1, maxHeight: w = "600px", className: T = "", title: E, titleIcon: D, showCount: O = !0, emptyText: k = "No data", noResultsText: A = "No results found", indent: j = 16, togglePosition: M = "left", renderLabel: N, renderNode: P }) => {
|
|
6
|
+
let [F, I] = i(""), [L, R] = i(new Set(p));
|
|
7
7
|
t.useEffect(() => {
|
|
8
|
-
p.length > 0 &&
|
|
8
|
+
p.length > 0 && R((e) => {
|
|
9
9
|
let t = new Set(e);
|
|
10
10
|
return p.forEach((e) => t.add(e)), t;
|
|
11
11
|
});
|
|
12
12
|
}, [p]);
|
|
13
|
-
let
|
|
13
|
+
let z = x || /* @__PURE__ */ o("svg", {
|
|
14
14
|
className: "w-3 h-3",
|
|
15
15
|
fill: "none",
|
|
16
16
|
viewBox: "0 0 24 24",
|
|
@@ -21,7 +21,7 @@ var c = ({ data: c, onNodeClick: l, onNodeDoubleClick: u, onNodeToggle: d, activ
|
|
|
21
21
|
strokeWidth: 2,
|
|
22
22
|
d: "M19 9l-7 7-7-7"
|
|
23
23
|
})
|
|
24
|
-
}),
|
|
24
|
+
}), B = S || /* @__PURE__ */ o("svg", {
|
|
25
25
|
className: "w-3 h-3",
|
|
26
26
|
fill: "none",
|
|
27
27
|
viewBox: "0 0 24 24",
|
|
@@ -32,7 +32,7 @@ var c = ({ data: c, onNodeClick: l, onNodeDoubleClick: u, onNodeToggle: d, activ
|
|
|
32
32
|
strokeWidth: 2,
|
|
33
33
|
d: "M9 5l7 7-7 7"
|
|
34
34
|
})
|
|
35
|
-
}),
|
|
35
|
+
}), V = b || /* @__PURE__ */ o("svg", {
|
|
36
36
|
className: "w-4 h-4",
|
|
37
37
|
fill: "none",
|
|
38
38
|
viewBox: "0 0 24 24",
|
|
@@ -43,36 +43,38 @@ var c = ({ data: c, onNodeClick: l, onNodeDoubleClick: u, onNodeToggle: d, activ
|
|
|
43
43
|
strokeWidth: 2,
|
|
44
44
|
d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
|
|
45
45
|
})
|
|
46
|
-
}),
|
|
46
|
+
}), H = n((e) => e.reduce((e, t) => e + 1 + (t.children ? H(t.children) : 0), 0), []), U = r(() => H(c), [c, H]), W = n((e, t) => {
|
|
47
47
|
if (!t) return e;
|
|
48
48
|
let n = t.toLowerCase(), r = [];
|
|
49
49
|
for (let i of e) {
|
|
50
|
-
let e = i.label.toLowerCase().includes(n), a = i.children ?
|
|
50
|
+
let e = i.label.toLowerCase().includes(n), a = i.children ? W(i.children, t) : [];
|
|
51
51
|
(e || a.length > 0) && r.push({
|
|
52
52
|
...i,
|
|
53
53
|
children: a.length > 0 ? a : i.children
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
return r;
|
|
57
|
-
}, []),
|
|
57
|
+
}, []), G = r(() => W(c, F), [
|
|
58
58
|
c,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
]),
|
|
62
|
-
let t = new Set(
|
|
63
|
-
t.has(e) ? (t.delete(e), d?.(e, !1)) : (t.add(e), d?.(e, !0)),
|
|
64
|
-
}, [
|
|
59
|
+
F,
|
|
60
|
+
W
|
|
61
|
+
]), K = n((e) => {
|
|
62
|
+
let t = new Set(L);
|
|
63
|
+
t.has(e) ? (t.delete(e), d?.(e, !1)) : (t.add(e), d?.(e, !0)), R(t);
|
|
64
|
+
}, [L, d]), q = n(() => {
|
|
65
65
|
let e = /* @__PURE__ */ new Set(), t = (n) => {
|
|
66
66
|
n.forEach((n) => {
|
|
67
67
|
n.children && n.children.length > 0 && (e.add(n.id), t(n.children));
|
|
68
68
|
});
|
|
69
69
|
};
|
|
70
|
-
t(c),
|
|
71
|
-
}, [c]),
|
|
72
|
-
|
|
73
|
-
}, []),
|
|
74
|
-
let r = e.children && e.children.length > 0, i =
|
|
70
|
+
t(c), R(e);
|
|
71
|
+
}, [c]), J = n(() => {
|
|
72
|
+
R(/* @__PURE__ */ new Set());
|
|
73
|
+
}, []), Y = n((e, t = 0, n = []) => {
|
|
74
|
+
let r = e.children && e.children.length > 0, i = L.has(e.id), c = f === e.id, d = [...n, e.id], p = /* @__PURE__ */ s("div", {
|
|
75
75
|
"data-node-id": e.id,
|
|
76
|
+
"data-depth": t,
|
|
77
|
+
"data-level": t + 1,
|
|
76
78
|
className: `tree-node ${c ? "tree-node-active" : ""} ${e.disabled ? "tree-node-disabled" : ""}`,
|
|
77
79
|
style: { paddingLeft: `${t * j}px` },
|
|
78
80
|
children: [/* @__PURE__ */ s("div", {
|
|
@@ -85,12 +87,15 @@ var c = ({ data: c, onNodeClick: l, onNodeDoubleClick: u, onNodeToggle: d, activ
|
|
|
85
87
|
},
|
|
86
88
|
children: [
|
|
87
89
|
M === "left" && /* @__PURE__ */ o(a, { children: r ? /* @__PURE__ */ o("button", {
|
|
90
|
+
type: "button",
|
|
91
|
+
"aria-label": `${i ? "Collapse" : "Expand"} ${e.label}`,
|
|
92
|
+
"aria-expanded": i,
|
|
88
93
|
className: `tree-node-toggle btn btn-xs btn-ghost btn-circle ${i ? "tree-node-toggle-expanded" : ""}`,
|
|
89
94
|
onClick: (t) => {
|
|
90
|
-
t.stopPropagation(), e.disabled ||
|
|
95
|
+
t.stopPropagation(), e.disabled || K(e.id);
|
|
91
96
|
},
|
|
92
97
|
disabled: e.disabled,
|
|
93
|
-
children: i ?
|
|
98
|
+
children: i ? z : B
|
|
94
99
|
}) : /* @__PURE__ */ o("span", {
|
|
95
100
|
className: "tree-node-toggle-placeholder",
|
|
96
101
|
style: {
|
|
@@ -101,12 +106,12 @@ var c = ({ data: c, onNodeClick: l, onNodeDoubleClick: u, onNodeToggle: d, activ
|
|
|
101
106
|
}) }),
|
|
102
107
|
y && /* @__PURE__ */ o("span", {
|
|
103
108
|
className: "tree-node-icon",
|
|
104
|
-
children: e.icon ||
|
|
109
|
+
children: e.icon || V
|
|
105
110
|
}),
|
|
106
111
|
/* @__PURE__ */ o("span", {
|
|
107
112
|
className: "tree-node-label text-sm truncate flex-1",
|
|
108
113
|
title: e.label,
|
|
109
|
-
children: e.label
|
|
114
|
+
children: N ? N(e, t) : e.label
|
|
110
115
|
}),
|
|
111
116
|
e.meta?.count !== void 0 && e.meta?.count !== null ? /* @__PURE__ */ o("span", {
|
|
112
117
|
className: "tree-node-count text-xs opacity-60",
|
|
@@ -120,34 +125,38 @@ var c = ({ data: c, onNodeClick: l, onNodeDoubleClick: u, onNodeToggle: d, activ
|
|
|
120
125
|
]
|
|
121
126
|
}) : null,
|
|
122
127
|
M === "right" && r && /* @__PURE__ */ o("button", {
|
|
128
|
+
type: "button",
|
|
129
|
+
"aria-label": `${i ? "Collapse" : "Expand"} ${e.label}`,
|
|
130
|
+
"aria-expanded": i,
|
|
123
131
|
className: `tree-node-toggle tree-node-toggle-right btn btn-xs btn-ghost ${i ? "tree-node-toggle-expanded" : ""}`,
|
|
124
132
|
onClick: (t) => {
|
|
125
|
-
t.stopPropagation(), e.disabled ||
|
|
133
|
+
t.stopPropagation(), e.disabled || K(e.id);
|
|
126
134
|
},
|
|
127
135
|
disabled: e.disabled,
|
|
128
|
-
children: i ?
|
|
136
|
+
children: i ? z : B
|
|
129
137
|
})
|
|
130
138
|
]
|
|
131
139
|
}), r && /* @__PURE__ */ o("div", {
|
|
132
140
|
className: `tree-node-children ${i ? "tree-node-children-expanded" : "tree-node-children-collapsed"}`,
|
|
133
|
-
children: e.children.map((e) =>
|
|
141
|
+
children: e.children.map((e) => Y(e, t + 1, d))
|
|
134
142
|
})]
|
|
135
143
|
}, e.id);
|
|
136
|
-
return
|
|
144
|
+
return P ? P(e, p) : p;
|
|
137
145
|
}, [
|
|
138
|
-
|
|
146
|
+
L,
|
|
139
147
|
f,
|
|
140
148
|
j,
|
|
141
149
|
y,
|
|
142
150
|
O,
|
|
143
151
|
M,
|
|
144
|
-
R,
|
|
145
152
|
z,
|
|
146
153
|
B,
|
|
154
|
+
V,
|
|
147
155
|
l,
|
|
148
156
|
u,
|
|
149
|
-
|
|
150
|
-
N
|
|
157
|
+
K,
|
|
158
|
+
N,
|
|
159
|
+
P
|
|
151
160
|
]);
|
|
152
161
|
return /* @__PURE__ */ s("div", {
|
|
153
162
|
className: `tree-component bg-base-100 border border-base-300 rounded-lg p-2 ${T}`,
|
|
@@ -164,7 +173,7 @@ var c = ({ data: c, onNodeClick: l, onNodeDoubleClick: u, onNodeToggle: d, activ
|
|
|
164
173
|
className: "text-xs opacity-60 ml-auto",
|
|
165
174
|
children: [
|
|
166
175
|
"(",
|
|
167
|
-
|
|
176
|
+
U,
|
|
168
177
|
")"
|
|
169
178
|
]
|
|
170
179
|
})
|
|
@@ -173,31 +182,31 @@ var c = ({ data: c, onNodeClick: l, onNodeDoubleClick: u, onNodeToggle: d, activ
|
|
|
173
182
|
m && /* @__PURE__ */ o("input", {
|
|
174
183
|
type: "text",
|
|
175
184
|
placeholder: h,
|
|
176
|
-
value:
|
|
177
|
-
onChange: (e) =>
|
|
185
|
+
value: F,
|
|
186
|
+
onChange: (e) => I(e.target.value),
|
|
178
187
|
className: "tree-search input input-sm input-bordered w-full mb-2"
|
|
179
188
|
}),
|
|
180
189
|
g && /* @__PURE__ */ s("div", {
|
|
181
190
|
className: "tree-actions flex gap-1 mb-2",
|
|
182
191
|
children: [/* @__PURE__ */ o("button", {
|
|
183
192
|
className: "btn btn-xs btn-ghost",
|
|
184
|
-
onClick:
|
|
193
|
+
onClick: q,
|
|
185
194
|
children: _
|
|
186
195
|
}), /* @__PURE__ */ o("button", {
|
|
187
196
|
className: "btn btn-xs btn-ghost",
|
|
188
|
-
onClick:
|
|
197
|
+
onClick: J,
|
|
189
198
|
children: v
|
|
190
199
|
})]
|
|
191
200
|
}),
|
|
192
201
|
/* @__PURE__ */ o("div", {
|
|
193
202
|
className: "tree-content overflow-y-auto",
|
|
194
203
|
style: { maxHeight: w },
|
|
195
|
-
children:
|
|
204
|
+
children: G.length === 0 ? /* @__PURE__ */ o("div", {
|
|
196
205
|
className: "tree-empty text-center text-sm opacity-60 py-4",
|
|
197
|
-
children:
|
|
206
|
+
children: F ? A : k
|
|
198
207
|
}) : /* @__PURE__ */ o("div", {
|
|
199
208
|
className: `tree-nodes ${C ? "tree-show-line" : ""}`,
|
|
200
|
-
children:
|
|
209
|
+
children: G.map((e) => Y(e))
|
|
201
210
|
})
|
|
202
211
|
}),
|
|
203
212
|
/* @__PURE__ */ o("style", { children: `
|