dishui 0.0.89 → 0.0.91

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.
@@ -1,11 +1,26 @@
1
1
  import React from 'react';
2
+ export type TableCardOptions = {
3
+ /** Applied to each Table.Body grid. */
4
+ gridClassName?: string;
5
+ gridStyle?: React.CSSProperties;
6
+ /** Applied to each body row card. */
7
+ className?: string;
8
+ style?: React.CSSProperties;
9
+ fieldClassName?: string;
10
+ fieldStyle?: React.CSSProperties;
11
+ labelClassName?: string;
12
+ labelStyle?: React.CSSProperties;
13
+ };
2
14
  export type TableProps = {
3
15
  children: React.ReactNode;
16
+ card?: boolean;
17
+ cardOptions?: TableCardOptions;
4
18
  className?: string;
5
19
  onClick?: (e: React.MouseEvent) => void;
6
20
  onMouseEnter?: (e: React.MouseEvent) => void;
7
21
  onMouseLeave?: (e: React.MouseEvent) => void;
8
22
  } & React.TableHTMLAttributes<HTMLTableElement>;
23
+ declare const Table: ({ children, className, card, cardOptions, onClick, onMouseEnter, onMouseLeave, ...rest }: TableProps) => React.JSX.Element;
9
24
  export type TableHeadProps = React.HTMLAttributes<HTMLTableSectionElement>;
10
25
  export type TableBodyProps = React.HTMLAttributes<HTMLTableSectionElement>;
11
26
  export type TableRowProps = {
@@ -19,6 +34,8 @@ export type TableRowProps = {
19
34
  } & Omit<React.HTMLAttributes<HTMLTableRowElement>, 'className' | 'onClick' | 'onDoubleClick' | 'onMouseEnter' | 'onMouseLeave'>;
20
35
  export type TableCellProps = {
21
36
  children?: React.ReactNode;
37
+ /** Visible field label in card body cells only. */
38
+ label?: React.ReactNode;
22
39
  className?: string;
23
40
  onClick?: (e: React.MouseEvent) => void;
24
41
  colSpan?: number;
@@ -42,7 +59,8 @@ export type TableHeaderCellProps = {
42
59
  } & React.ThHTMLAttributes<HTMLTableCellElement>;
43
60
  export type TableCaptionProps = React.HTMLAttributes<HTMLTableCaptionElement>;
44
61
  export type TableFooterProps = React.HTMLAttributes<HTMLTableSectionElement>;
45
- interface TableCompound extends React.FC<TableProps> {
62
+ export type TableCardProps = Omit<TableProps, 'card'>;
63
+ interface TableSubcomponents {
46
64
  Caption: React.FC<TableCaptionProps>;
47
65
  Footer: React.FC<TableFooterProps>;
48
66
  Head: React.FC<TableHeadProps>;
@@ -51,5 +69,8 @@ interface TableCompound extends React.FC<TableProps> {
51
69
  Cell: React.FC<TableCellProps>;
52
70
  HeaderCell: React.FC<TableHeaderCellProps>;
53
71
  }
54
- declare const TableWithCompounds: TableCompound;
72
+ declare const TableCard: (props: TableCardProps) => React.JSX.Element;
73
+ declare const TableWithCompounds: typeof Table & TableSubcomponents & {
74
+ Card: typeof TableCard & TableSubcomponents;
75
+ };
55
76
  export default TableWithCompounds;
@@ -1,117 +1,169 @@
1
1
  import { cn as e } from "../../utils/cn.js";
2
- import "react";
3
- import { jsx as t, jsxs as n } from "react/jsx-runtime";
2
+ /* empty css */
3
+ import t from "react";
4
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
5
  //#region src/components/Table/index.tsx
5
- var r = ({ children: n, className: r = "", onClick: i, onMouseEnter: a, onMouseLeave: o, ...s }) => {
6
- let c = e("table", r);
7
- return /* @__PURE__ */ t("table", {
8
- ...s,
9
- className: c,
10
- onClick: i,
11
- onMouseEnter: a,
12
- onMouseLeave: o,
13
- children: n
6
+ var i = t.createContext(null), a = t.createContext(!1), o = {}, s = ({ children: t, className: r = "", card: s = !1, cardOptions: c = o, onClick: l, onMouseEnter: u, onMouseLeave: d, ...f }) => {
7
+ let p = e("table", s && "blade-table-card", r);
8
+ return /* @__PURE__ */ n(i.Provider, {
9
+ value: s ? c : null,
10
+ children: /* @__PURE__ */ n(a.Provider, {
11
+ value: !1,
12
+ children: /* @__PURE__ */ n("table", {
13
+ role: s ? "table" : void 0,
14
+ ...f,
15
+ className: p,
16
+ onClick: l,
17
+ onMouseEnter: u,
18
+ onMouseLeave: d,
19
+ children: t
20
+ })
21
+ })
14
22
  });
15
- }, i = ({ children: n, className: r = "", ...i }) => {
16
- let a = e("table-header-group", r);
17
- return /* @__PURE__ */ t("thead", {
18
- ...i,
19
- className: a,
20
- children: n
21
- });
22
- }, a = ({ children: n, className: r = "", ...i }) => {
23
- let a = e("table-row-group", r);
24
- return /* @__PURE__ */ t("tbody", {
25
- ...i,
26
- className: a,
27
- children: n
28
- });
29
- }, o = ({ children: n, className: r = "", selected: i = !1, onClick: a, onDoubleClick: o, onMouseEnter: s, onMouseLeave: c, ...l }) => {
30
- let u = e("table-row", i && "bg-base-200", "hover:bg-base-100", r);
31
- return /* @__PURE__ */ t("tr", {
32
- className: u,
33
- onClick: a,
34
- onDoubleClick: o,
35
- onMouseEnter: s,
36
- onMouseLeave: c,
37
- ...l,
38
- children: n
39
- });
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);
42
- return /* @__PURE__ */ t("td", {
43
- ...u,
44
- className: d,
45
- onClick: i,
46
- colSpan: a,
47
- style: o,
48
- onDoubleClick: s,
49
- onMouseEnter: c,
50
- onMouseLeave: l,
51
- children: n
52
- });
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);
55
- return /* @__PURE__ */ t("th", {
56
- ...m,
57
- className: h,
58
- onClick: a,
59
- draggable: c,
60
- onDragStart: l,
61
- onDragOver: u,
62
- onDrop: d,
63
- onMouseEnter: f,
64
- onMouseLeave: p,
65
- children: o ? /* @__PURE__ */ n("div", {
66
- className: "flex items-center gap-2",
67
- children: [r, o && /* @__PURE__ */ t("div", {
68
- className: "flex flex-col",
69
- children: s === "asc" ? /* @__PURE__ */ t("svg", {
70
- xmlns: "http://www.w3.org/2000/svg",
71
- className: "h-4 w-4",
72
- fill: "none",
73
- viewBox: "0 0 24 24",
74
- stroke: "currentColor",
75
- children: /* @__PURE__ */ t("path", {
76
- strokeLinecap: "round",
77
- strokeLinejoin: "round",
78
- strokeWidth: "2",
79
- d: "M5 15l7-7 7 7"
80
- })
81
- }) : s === "desc" ? /* @__PURE__ */ t("svg", {
82
- xmlns: "http://www.w3.org/2000/svg",
83
- className: "h-4 w-4",
84
- fill: "none",
85
- viewBox: "0 0 24 24",
86
- stroke: "currentColor",
87
- children: /* @__PURE__ */ t("path", {
88
- strokeLinecap: "round",
89
- strokeLinejoin: "round",
90
- strokeWidth: "2",
91
- d: "M19 9l-7 7-7-7"
92
- })
93
- }) : /* @__PURE__ */ t("div", {
94
- className: "h-4 w-4 opacity-30",
95
- children: /* @__PURE__ */ t("svg", {
23
+ }, c = {
24
+ Caption: (e) => /* @__PURE__ */ n("caption", { ...e }),
25
+ Footer: (e) => {
26
+ let r = t.useContext(i);
27
+ return /* @__PURE__ */ n("tfoot", {
28
+ role: r ? "rowgroup" : void 0,
29
+ ...e
30
+ });
31
+ },
32
+ Head: ({ children: r, className: a = "", ...o }) => {
33
+ let s = t.useContext(i), c = e("table-header-group", a);
34
+ return /* @__PURE__ */ n("thead", {
35
+ role: s ? "rowgroup" : void 0,
36
+ ...o,
37
+ className: c,
38
+ children: r
39
+ });
40
+ },
41
+ Body: ({ children: r, className: o = "", style: s, ...c }) => {
42
+ let l = t.useContext(i), u = e("table-row-group", l && "blade-table-card__grid", l?.gridClassName, o);
43
+ return /* @__PURE__ */ n(a.Provider, {
44
+ value: !0,
45
+ children: /* @__PURE__ */ n("tbody", {
46
+ role: l ? "rowgroup" : void 0,
47
+ ...c,
48
+ className: u,
49
+ style: l ? {
50
+ ...l.gridStyle,
51
+ ...s
52
+ } : s,
53
+ children: r
54
+ })
55
+ });
56
+ },
57
+ Row: ({ children: r, className: o = "", selected: s = !1, style: c, onClick: l, onDoubleClick: u, onMouseEnter: d, onMouseLeave: f, ...p }) => {
58
+ let m = t.useContext(i), h = t.useContext(a) ? m : null, g = e("table-row", s && "bg-base-200", "hover:bg-base-100", h && "blade-table-card__row", h?.className, o);
59
+ return /* @__PURE__ */ n("tr", {
60
+ role: m ? "row" : void 0,
61
+ "data-card-selected": h && s ? "true" : void 0,
62
+ style: h ? {
63
+ ...h.style,
64
+ ...c
65
+ } : c,
66
+ className: g,
67
+ onClick: l,
68
+ onDoubleClick: u,
69
+ onMouseEnter: d,
70
+ onMouseLeave: f,
71
+ ...p,
72
+ children: r
73
+ });
74
+ },
75
+ Cell: ({ children: o, label: s, className: c = "", onClick: l, colSpan: u, style: d, onDoubleClick: f, onMouseEnter: p, onMouseLeave: m, ...h }) => {
76
+ let g = t.useContext(i), _ = t.useContext(a) ? g : null, v = e("table-cell", _ && "blade-table-card__field", _?.fieldClassName, c);
77
+ return /* @__PURE__ */ r("td", {
78
+ role: g ? "cell" : void 0,
79
+ ...h,
80
+ className: v,
81
+ onClick: l,
82
+ colSpan: u,
83
+ style: _ ? {
84
+ ..._.fieldStyle,
85
+ ...d
86
+ } : d,
87
+ onDoubleClick: f,
88
+ onMouseEnter: p,
89
+ onMouseLeave: m,
90
+ children: [_ && s != null ? /* @__PURE__ */ n("div", {
91
+ className: e("blade-table-card__label", _.labelClassName),
92
+ style: _.labelStyle,
93
+ children: s
94
+ }) : null, o]
95
+ });
96
+ },
97
+ HeaderCell: ({ children: o, className: s = "", style: c, onClick: l, sortable: u = !1, sortDirection: d = null, draggable: f, onDragStart: p, onDragOver: m, onDrop: h, onMouseEnter: g, onMouseLeave: _, ...v }) => {
98
+ let y = t.useContext(i), b = t.useContext(a), x = b ? y : null, S = e("table-cell font-medium", u && "cursor-pointer", x && "blade-table-card__field", x?.fieldClassName, s);
99
+ return /* @__PURE__ */ n("th", {
100
+ role: y ? v.scope === "row" || v.scope === "rowgroup" || b && !v.scope ? "rowheader" : "columnheader" : void 0,
101
+ ...v,
102
+ style: x ? {
103
+ ...x.fieldStyle,
104
+ ...c
105
+ } : c,
106
+ className: S,
107
+ onClick: l,
108
+ draggable: f,
109
+ onDragStart: p,
110
+ onDragOver: m,
111
+ onDrop: h,
112
+ onMouseEnter: g,
113
+ onMouseLeave: _,
114
+ children: u ? /* @__PURE__ */ r("div", {
115
+ className: "flex items-center gap-2",
116
+ children: [o, u && /* @__PURE__ */ n("div", {
117
+ className: "flex flex-col",
118
+ children: d === "asc" ? /* @__PURE__ */ n("svg", {
96
119
  xmlns: "http://www.w3.org/2000/svg",
97
120
  className: "h-4 w-4",
98
121
  fill: "none",
99
122
  viewBox: "0 0 24 24",
100
123
  stroke: "currentColor",
101
- children: /* @__PURE__ */ t("path", {
124
+ children: /* @__PURE__ */ n("path", {
102
125
  strokeLinecap: "round",
103
126
  strokeLinejoin: "round",
104
127
  strokeWidth: "2",
105
- d: "M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"
128
+ d: "M5 15l7-7 7 7"
129
+ })
130
+ }) : d === "desc" ? /* @__PURE__ */ n("svg", {
131
+ xmlns: "http://www.w3.org/2000/svg",
132
+ className: "h-4 w-4",
133
+ fill: "none",
134
+ viewBox: "0 0 24 24",
135
+ stroke: "currentColor",
136
+ children: /* @__PURE__ */ n("path", {
137
+ strokeLinecap: "round",
138
+ strokeLinejoin: "round",
139
+ strokeWidth: "2",
140
+ d: "M19 9l-7 7-7-7"
141
+ })
142
+ }) : /* @__PURE__ */ n("div", {
143
+ className: "h-4 w-4 opacity-30",
144
+ children: /* @__PURE__ */ n("svg", {
145
+ xmlns: "http://www.w3.org/2000/svg",
146
+ className: "h-4 w-4",
147
+ fill: "none",
148
+ viewBox: "0 0 24 24",
149
+ stroke: "currentColor",
150
+ children: /* @__PURE__ */ n("path", {
151
+ strokeLinecap: "round",
152
+ strokeLinejoin: "round",
153
+ strokeWidth: "2",
154
+ d: "M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"
155
+ })
106
156
  })
107
157
  })
108
- })
109
- })]
110
- }) : r
111
- });
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;
158
+ })]
159
+ }) : o
160
+ });
161
+ }
162
+ }, l = Object.assign(s, c, { Card: Object.assign((e) => /* @__PURE__ */ n(s, {
163
+ ...e,
164
+ card: !0
165
+ }), c) });
114
166
  //#endregion
115
- export { d as default };
167
+ export { l as default };
116
168
 
117
169
  //# 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} & 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,GAK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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"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Table/index.tsx"],"sourcesContent":["import React from 'react';\nimport { cn } from '../../utils/cn';\nimport './Table.css';\n\nexport type TableCardOptions = {\n /** Applied to each Table.Body grid. */\n gridClassName?: string;\n gridStyle?: React.CSSProperties;\n /** Applied to each body row card. */\n className?: string;\n style?: React.CSSProperties;\n fieldClassName?: string;\n fieldStyle?: React.CSSProperties;\n labelClassName?: string;\n labelStyle?: React.CSSProperties;\n};\n\nconst CardContext = React.createContext<TableCardOptions | null>(null);\nconst BodyContext = React.createContext(false);\nconst defaultCardOptions: TableCardOptions = {};\n\nexport type TableProps = {\n children: React.ReactNode;\n card?: boolean;\n cardOptions?: TableCardOptions;\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 card = false,\n cardOptions = defaultCardOptions,\n onClick,\n onMouseEnter,\n onMouseLeave,\n ...rest\n}: TableProps) => {\n const baseClass = 'table';\n \n const tableClasses = cn(baseClass, card && 'blade-table-card', className);\n\n return (\n <CardContext.Provider value={card ? cardOptions : null}>\n <BodyContext.Provider value={false}>\n <table\n role={card ? 'table' : undefined}\n {...rest}\n className={tableClasses}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n >\n {children}\n </table>\n </BodyContext.Provider>\n </CardContext.Provider>\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 options = React.useContext(CardContext);\n const baseClass = 'table-header-group';\n \n const headClasses = cn(baseClass, className);\n\n return (\n <thead role={options ? 'rowgroup' : undefined} {...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 style,\n ...rest\n}: TableBodyProps) => {\n const options = React.useContext(CardContext);\n const bodyClasses = cn('table-row-group', options && 'blade-table-card__grid', options?.gridClassName, className);\n\n return (\n <BodyContext.Provider value={true}>\n <tbody\n role={options ? 'rowgroup' : undefined}\n {...rest}\n className={bodyClasses}\n style={options ? { ...options.gridStyle, ...style } : style}\n >\n {children}\n </tbody>\n </BodyContext.Provider>\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 style,\n onClick,\n onDoubleClick,\n onMouseEnter,\n onMouseLeave,\n ...rest\n}: TableRowProps) => {\n const cardOptions = React.useContext(CardContext);\n const inBody = React.useContext(BodyContext);\n const options = inBody ? cardOptions : null;\n const baseClass = 'table-row';\n\n const rowClasses = cn(\n baseClass,\n selected && 'bg-base-200',\n 'hover:bg-base-100',\n options && 'blade-table-card__row',\n options?.className,\n className\n );\n\n return (\n <tr\n role={cardOptions ? 'row' : undefined}\n data-card-selected={options && selected ? 'true' : undefined}\n style={options ? { ...options.style, ...style } : style}\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 /** Visible field label in card body cells only. */\n label?: 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 label,\n className = '',\n onClick,\n colSpan,\n style,\n onDoubleClick,\n onMouseEnter,\n onMouseLeave,\n ...rest\n}: TableCellProps) => {\n const cardOptions = React.useContext(CardContext);\n const inBody = React.useContext(BodyContext);\n const options = inBody ? cardOptions : null;\n const cellClasses = cn('table-cell', options && 'blade-table-card__field', options?.fieldClassName, className);\n\n return (\n <td\n role={cardOptions ? 'cell' : undefined}\n {...rest}\n className={cellClasses}\n onClick={onClick}\n colSpan={colSpan}\n style={options ? { ...options.fieldStyle, ...style } : style}\n onDoubleClick={onDoubleClick}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n >\n {/* Keep children in a fixed slot so mode/label changes preserve local state. */}\n {options && label !== null && label !== undefined ? <div className={cn('blade-table-card__label', options.labelClassName)} style={options.labelStyle}>{label}</div> : null}\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 style,\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 cardOptions = React.useContext(CardContext);\n const inBody = React.useContext(BodyContext);\n const options = inBody ? cardOptions : null;\n const baseClass = 'table-cell font-medium';\n \n const headerCellClasses = cn(\n baseClass,\n sortable && 'cursor-pointer',\n options && 'blade-table-card__field',\n options?.fieldClassName,\n className\n );\n\n return (\n <th\n role={cardOptions ? (rest.scope === 'row' || rest.scope === 'rowgroup' || (inBody && !rest.scope) ? 'rowheader' : 'columnheader') : undefined}\n {...rest}\n style={options ? { ...options.fieldStyle, ...style } : style}\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) => {\n const options = React.useContext(CardContext);\n return <tfoot role={options ? 'rowgroup' : undefined} {...props} />;\n};\n\n// 扩展Table组件,添加子组件\nexport type TableCardProps = Omit<TableProps, 'card'>;\n\ninterface TableSubcomponents {\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 subcomponents: TableSubcomponents = {\n Caption: TableCaption,\n Footer: TableFooter,\n Head: TableHead,\n Body: TableBody,\n Row: TableRow,\n Cell: TableCell,\n HeaderCell: TableHeaderCell,\n};\n\nconst TableCard = (props: TableCardProps) => <Table {...props} card />;\nconst TableWithCompounds = Object.assign(Table, subcomponents, {\n Card: Object.assign(TableCard, subcomponents),\n});\n\nexport default TableWithCompounds; "],"mappings":";;;;;AAiBA,IAAM,IAAc,EAAM,cAAuC,IAAI,GAC/D,IAAc,EAAM,cAAc,EAAK,GACvC,IAAuC,CAAC,GAYxC,KAAS,EACb,aACA,eAAY,IACZ,UAAO,IACP,iBAAc,GACd,YACA,iBACA,iBACA,GAAG,QACa;CAGhB,IAAM,IAAe,EAAG,SAAW,KAAQ,oBAAoB,CAAS;CAExE,OACE,kBAAC,EAAY,UAAb;EAAsB,OAAO,IAAO,IAAc;EAChD,UAAA,kBAAC,EAAY,UAAb;GAAsB,OAAO;GAC3B,UAAA,kBAAC,SAAD;IACE,MAAM,IAAO,UAAU,KAAA;IACvB,GAAI;IACJ,WAAW;IACF;IACK;IACA;IAEb;GACI,CAAA;EACa,CAAA;CACF,CAAA;AAE1B,GA4QM,IAAoC;CACxC,UApBoB,MAA6B,kBAAC,WAAD,EAAS,GAAI,EAAQ,CAAA;CAqBtE,SApBmB,MAA4B;EAC/C,IAAM,IAAU,EAAM,WAAW,CAAW;EAC5C,OAAO,kBAAC,SAAD;GAAO,MAAM,IAAU,aAAa,KAAA;GAAW,GAAI;EAAQ,CAAA;CACpE;CAkBE,OA1QiB,EACjB,aACA,eAAY,IACZ,GAAG,QACiB;EACpB,IAAM,IAAU,EAAM,WAAW,CAAW,GAGtC,IAAc,EAAG,sBAAW,CAAS;EAE3C,OACE,kBAAC,SAAD;GAAO,MAAM,IAAU,aAAa,KAAA;GAAW,GAAI;GAAM,WAAW;GACjE;EACI,CAAA;CAEX;CA4PE,OAvPiB,EACjB,aACA,eAAY,IACZ,UACA,GAAG,QACiB;EACpB,IAAM,IAAU,EAAM,WAAW,CAAW,GACtC,IAAc,EAAG,mBAAmB,KAAW,0BAA0B,GAAS,eAAe,CAAS;EAEhH,OACE,kBAAC,EAAY,UAAb;GA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AAA,IAAA;EACP,CAAA;CAER;AA+BA,GAGM,IAAqB,OAAO,OAAO,GAAO,GAAe,EAC7D,MAAM,OAAO,QAFI,MAA0B,kBAAC,GAAD;CAAO,GAAI;CAAO,MAAA;AAAM,CAAA,GAEpC,CAAa,EAC9C,CAAC"}
@@ -5,31 +5,33 @@ import { TableBody as r } from "./components/TableBody.js";
5
5
  import { TablePagination as i } from "./components/TablePagination.js";
6
6
  import { treeRowAnimationStyles as a } from "./treeDataUtils.js";
7
7
  import { useDataTableModel as o } from "./useDataTableModel.js";
8
- import { useColumnDragReorder as s } from "./useColumnDragReorder.js";
9
- import c, { useCallback as l, useEffect as u, useState as d } from "react";
10
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
8
+ import { useColumnDragReorder as ee } from "./useColumnDragReorder.js";
9
+ import s, { useCallback as c, useEffect as l, useState as u } from "react";
10
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
11
11
  //#region src/components/pro/DataTable/DataTable.tsx
12
- function h(h) {
13
- let { data: g, columns: _, className: v = "", enableSorting: y = !0, enablePagination: b = !0, enableColumnReordering: x = !0, enableExpanding: S = !1, indentSize: C = 16, toolbar: w = {
12
+ function m(m) {
13
+ let { data: h, columns: te, className: ne = "", viewMode: g, defaultViewMode: _ = "table", onViewModeChange: v, enableViewSwitcher: y = !1, viewSwitcherLabels: b, cardOptions: x, enableSorting: S = !0, enablePagination: C = !0, enableColumnReordering: w = !0, enableExpanding: re = !1, indentSize: ie = 16, toolbar: ae = {
14
14
  enabled: !1,
15
15
  enableColumnSelector: !1,
16
16
  enableFiltering: !1,
17
17
  enableBulkActions: !1
18
- }, customFilterPanel: T, onRowClick: ee, onRowDoubleClick: te, onRowMouseEnter: ne, onRowMouseLeave: re, onCellClick: E, onCellDoubleClick: D, onCellMouseEnter: O, onCellMouseLeave: k, onColumnMouseEnter: A, onColumnMouseLeave: j, extensions: M = [] } = h, { table: N, rowSelection: P, visibilityState: F, columnOrderState: I, setColumnOrderState: L, expandedRowsState: R, handleRowExpand: z, resolveRowId: B, handlePaginationChange: V } = o(h), [H, U] = d(null), { draggedColumnId: W, handleDragStart: G, handleDragOver: K, handleDrop: q } = s(I, L), J = {
18
+ }, customFilterPanel: oe, onRowClick: se, onRowDoubleClick: ce, onRowMouseEnter: le, onRowMouseLeave: T, onCellClick: E, onCellDoubleClick: D, onCellMouseEnter: O, onCellMouseLeave: k, onColumnMouseEnter: A, onColumnMouseLeave: j, extensions: M = [] } = m, { table: N, rowSelection: P, visibilityState: F, columnOrderState: I, setColumnOrderState: L, expandedRowsState: R, handleRowExpand: z, resolveRowId: B, handlePaginationChange: ue } = o(m), [V, H] = u(null), [U, de] = u(_), W = g ?? U, fe = (e) => {
19
+ e !== W && (g === void 0 && de(e), v?.(e));
20
+ }, { draggedColumnId: G, handleDragStart: K, handleDragOver: pe, handleDrop: q } = ee(I, L), J = {
19
21
  table: N,
20
- data: g,
22
+ data: h,
21
23
  rows: N.getRowModel().rows,
22
24
  selectedRows: N.getSelectedRowModel().flatRows.map((e) => e.original),
23
25
  getRowId: B
24
- }, [Y, X] = d(null);
25
- u(() => {
26
+ }, [Y, X] = u(null);
27
+ l(() => {
26
28
  if (!Y) return;
27
29
  let e = () => X(null);
28
30
  return window.addEventListener("click", e), window.addEventListener("scroll", e, !0), () => {
29
31
  window.removeEventListener("click", e), window.removeEventListener("scroll", e, !0);
30
32
  };
31
33
  }, [Y]);
32
- let ie = l((e, t, n, r) => {
34
+ let me = c((e, t, n, r) => {
33
35
  if (M.length === 0) return;
34
36
  let i = n?.id ?? "", a = {
35
37
  value: n?.id == null ? void 0 : t[n.id],
@@ -62,85 +64,102 @@ function h(h) {
62
64
  break;
63
65
  }
64
66
  }
65
- return u(() => {
67
+ return l(() => {
66
68
  let e = document.createElement("style");
67
69
  return e.textContent = a, document.head.appendChild(e), () => {
68
70
  document.head.removeChild(e);
69
71
  };
70
- }, []), /* @__PURE__ */ m("div", {
71
- className: `w-full ${v}`,
72
+ }, []), /* @__PURE__ */ p("div", {
73
+ className: `w-full ${ne}`,
72
74
  children: [
73
- /* @__PURE__ */ p(t, {
74
- toolbar: w,
75
+ /* @__PURE__ */ f(t, {
76
+ toolbar: ae,
75
77
  table: N,
76
- columns: _,
78
+ columns: te,
77
79
  columnOrderState: I,
78
80
  visibilityState: F,
79
- activeFilter: H,
80
- setActiveFilter: U,
81
- customFilterPanel: T,
82
- draggedColumnId: W,
83
- handleDragStart: G,
81
+ activeFilter: V,
82
+ setActiveFilter: H,
83
+ customFilterPanel: oe,
84
+ draggedColumnId: G,
85
+ handleDragStart: K,
84
86
  toggleColumnVisibility: (e) => {
85
87
  N.getColumn(e)?.toggleVisibility();
86
88
  },
87
89
  rowSelection: P,
88
- data: g,
89
- enableColumnReordering: x,
90
- handleDrop: q
90
+ data: h,
91
+ enableColumnReordering: w,
92
+ handleDrop: q,
93
+ viewSwitcher: y && $ === void 0 ? /* @__PURE__ */ f("div", {
94
+ role: "group",
95
+ "aria-label": b?.label ?? "显示方式",
96
+ className: "flex items-center gap-1",
97
+ children: ["table", "card"].map((e) => /* @__PURE__ */ f("button", {
98
+ type: "button",
99
+ className: `btn btn-sm ${W === e ? "btn-neutral" : "btn-ghost"}`,
100
+ "aria-pressed": W === e,
101
+ disabled: g !== void 0 && !v,
102
+ onClick: () => fe(e),
103
+ children: b?.[e] ?? (e === "table" ? "表格" : "卡片")
104
+ }, e))
105
+ }) : void 0
91
106
  }),
92
- Z.length > 0 && /* @__PURE__ */ p("div", {
107
+ Z.length > 0 && /* @__PURE__ */ f("div", {
93
108
  className: "flex flex-wrap items-start gap-3 mb-4",
94
- children: Z.map((e) => /* @__PURE__ */ p(c.Fragment, { children: e.node }, e.name))
109
+ children: Z.map((e) => /* @__PURE__ */ f(s.Fragment, { children: e.node }, e.name))
95
110
  }),
96
- $ === void 0 ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("div", {
111
+ $ === void 0 ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", {
97
112
  className: "overflow-x-auto",
98
- children: /* @__PURE__ */ m(e, {
113
+ children: /* @__PURE__ */ p(e, {
99
114
  className: "table-sm w-full",
100
- children: [/* @__PURE__ */ p(n, {
115
+ card: W === "card",
116
+ cardOptions: x,
117
+ children: [/* @__PURE__ */ f(n, {
101
118
  table: N,
102
119
  visibilityState: F,
103
- enableSorting: y,
104
- enableColumnReordering: x,
105
- draggedColumnId: W,
120
+ enableSorting: S,
121
+ enableColumnReordering: w,
122
+ draggedColumnId: G,
106
123
  onColumnMouseEnter: A,
107
124
  onColumnMouseLeave: j,
108
- handleDragStart: G,
109
- handleDragOver: K,
125
+ handleDragStart: K,
126
+ handleDragOver: pe,
110
127
  handleDrop: q
111
- }), /* @__PURE__ */ p(r, {
128
+ }), /* @__PURE__ */ f(r, {
112
129
  table: N,
130
+ card: W === "card",
131
+ fieldLabels: x?.fieldLabels,
113
132
  expandedRowsState: R,
114
- onRowClick: ee,
115
- onRowDoubleClick: te,
116
- onRowMouseEnter: ne,
117
- onRowMouseLeave: re,
133
+ onRowClick: se,
134
+ onRowDoubleClick: ce,
135
+ onRowMouseEnter: le,
136
+ onRowMouseLeave: T,
118
137
  onCellClick: E,
119
138
  onCellDoubleClick: D,
120
139
  onCellMouseEnter: O,
121
140
  onCellMouseLeave: k,
122
- enableExpanding: S,
123
- indentSize: C,
141
+ enableExpanding: re,
142
+ indentSize: ie,
124
143
  handleRowExpand: z,
125
144
  extensions: M,
126
145
  extensionApi: J,
127
146
  getRowId: B,
128
- onCellContextMenu: ie
147
+ onCellContextMenu: me
129
148
  })]
130
149
  })
131
- }), /* @__PURE__ */ p(i, {
132
- enablePagination: b,
150
+ }), /* @__PURE__ */ f(i, {
151
+ enablePagination: C,
133
152
  table: N,
134
- onPaginationChange: V
135
- })] }) : /* @__PURE__ */ p("div", {
153
+ onPaginationChange: ue
154
+ })] }) : /* @__PURE__ */ f("div", {
136
155
  className: "w-full",
137
156
  children: $
138
157
  }),
139
- Q.length > 0 && /* @__PURE__ */ p("div", {
158
+ Q.length > 0 && /* @__PURE__ */ f("div", {
140
159
  className: "flex flex-wrap items-center gap-3 mt-4",
141
- children: Q.map((e) => /* @__PURE__ */ p(c.Fragment, { children: e.node }, e.name))
160
+ children: Q.map((e) => /* @__PURE__ */ f(s.Fragment, { children: e.node }, e.name))
142
161
  }),
143
- Y && /* @__PURE__ */ p("ul", {
162
+ Y && /* @__PURE__ */ f("ul", {
144
163
  className: "menu bg-base-100 rounded-box shadow-lg border border-base-300 z-1000 p-1",
145
164
  style: {
146
165
  position: "fixed",
@@ -148,7 +167,7 @@ function h(h) {
148
167
  left: Y.x,
149
168
  minWidth: 160
150
169
  },
151
- children: Y.items.map((e) => e.separator ? /* @__PURE__ */ p("li", { className: "my-1 border-t border-base-300" }, e.key) : /* @__PURE__ */ p("li", { children: /* @__PURE__ */ p("button", {
170
+ children: Y.items.map((e) => e.separator ? /* @__PURE__ */ f("li", { className: "my-1 border-t border-base-300" }, e.key) : /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
152
171
  type: "button",
153
172
  disabled: e.disabled,
154
173
  onClick: () => {
@@ -161,6 +180,6 @@ function h(h) {
161
180
  });
162
181
  }
163
182
  //#endregion
164
- export { h as default };
183
+ export { m as default };
165
184
 
166
185
  //# sourceMappingURL=DataTable.js.map