@yuno-payments/dashboard-design-system 0.0.165 → 0.0.167
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/atoms/alert/alert.d.ts +5 -1
- package/dist/components/atoms/alert/alert.js +9 -8
- package/dist/components/organisms/data-table/data-table.d.ts +23 -6
- package/dist/components/organisms/data-table/data-table.js +115 -110
- package/dist/components/organisms/data-table/data-table.types.d.ts +13 -3
- package/dist/components/organisms/data-table/hooks/use-data-table-state.d.ts +2 -1
- package/dist/components/organisms/data-table/hooks/use-data-table-state.js +39 -38
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Alert as ShadcnAlert } from '../../../vendor/shadcn/alert';
|
|
2
2
|
import { ComponentProps } from 'react';
|
|
3
|
-
import { IconName } from '../icon';
|
|
3
|
+
import { Icon, IconName } from '../icon';
|
|
4
4
|
/**
|
|
5
5
|
* Props for the Alert component
|
|
6
6
|
*/
|
|
@@ -17,6 +17,10 @@ interface AlertProps extends Omit<ComponentProps<typeof ShadcnAlert>, "children"
|
|
|
17
17
|
* Alert description/body text
|
|
18
18
|
*/
|
|
19
19
|
description?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Props for the icon component
|
|
22
|
+
*/
|
|
23
|
+
iconProps?: ComponentProps<typeof Icon>;
|
|
20
24
|
}
|
|
21
25
|
/**
|
|
22
26
|
* Alert component for displaying informational, success, warning, or error messages.
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { j as r } from "../../../_virtual/jsx-runtime.js";
|
|
2
|
-
import { Alert as
|
|
2
|
+
import { Alert as a, AlertTitle as i, AlertDescription as f } from "../../../vendor/shadcn/alert.js";
|
|
3
3
|
import { forwardRef as n } from "react";
|
|
4
4
|
import { Icon as p } from "../icon/icon.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import { cn as x } from "../../../lib/utils.js";
|
|
6
|
+
const c = n(
|
|
7
|
+
({ icon: e, title: m, description: s, iconProps: t, ...l }, o) => /* @__PURE__ */ r.jsxs(a, { ref: o, ...l, children: [
|
|
8
|
+
e && /* @__PURE__ */ r.jsx(p, { name: e, className: x("size-4", t?.className), ...t }),
|
|
9
|
+
m && /* @__PURE__ */ r.jsx(i, { children: m }),
|
|
10
|
+
s && /* @__PURE__ */ r.jsx(f, { children: s })
|
|
10
11
|
] })
|
|
11
12
|
);
|
|
12
|
-
|
|
13
|
+
c.displayName = "Alert";
|
|
13
14
|
export {
|
|
14
|
-
|
|
15
|
+
c as Alert
|
|
15
16
|
};
|
|
@@ -28,14 +28,15 @@ export interface DataTableProps<TData, TValue> {
|
|
|
28
28
|
*/
|
|
29
29
|
checkboxSelection?: boolean;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
* Controlled row selection state (optional)
|
|
32
|
+
* If provided, component operates in controlled mode
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
rowSelection?: import('@tanstack/react-table').RowSelectionState;
|
|
35
35
|
/**
|
|
36
36
|
* Callback fired when row selection changes
|
|
37
|
+
* In controlled mode, you must update the rowSelection prop
|
|
37
38
|
*/
|
|
38
|
-
onRowSelectionChange?: (selectedRows: TData[]) => void;
|
|
39
|
+
onRowSelectionChange?: (rowSelectionState: import('@tanstack/react-table').RowSelectionState, selectedRows: TData[]) => void;
|
|
39
40
|
/**
|
|
40
41
|
* Whether to enable column sorting
|
|
41
42
|
* @default true
|
|
@@ -117,6 +118,7 @@ export interface DataTableProps<TData, TValue> {
|
|
|
117
118
|
*
|
|
118
119
|
* @example
|
|
119
120
|
* ```tsx
|
|
121
|
+
* // Uncontrolled selection
|
|
120
122
|
* <DataTable
|
|
121
123
|
* columns={[
|
|
122
124
|
* { accessorKey: 'name', header: 'Name' },
|
|
@@ -124,11 +126,26 @@ export interface DataTableProps<TData, TValue> {
|
|
|
124
126
|
* ]}
|
|
125
127
|
* data={users}
|
|
126
128
|
* checkboxSelection
|
|
127
|
-
* onRowSelectionChange={(
|
|
129
|
+
* onRowSelectionChange={(rowSelectionState, selectedRows) => {
|
|
130
|
+
* console.log('Selected rows:', selectedRows);
|
|
131
|
+
* }}
|
|
128
132
|
* actions={{
|
|
129
133
|
* items: [{ label: 'Edit', onClick: (row) => editUser(row) }]
|
|
130
134
|
* }}
|
|
131
135
|
* />
|
|
136
|
+
*
|
|
137
|
+
* // Controlled selection
|
|
138
|
+
* const [rowSelection, setRowSelection] = useState({});
|
|
139
|
+
* <DataTable
|
|
140
|
+
* columns={columns}
|
|
141
|
+
* data={users}
|
|
142
|
+
* checkboxSelection
|
|
143
|
+
* rowSelection={rowSelection}
|
|
144
|
+
* onRowSelectionChange={(newRowSelection, selectedRows) => {
|
|
145
|
+
* setRowSelection(newRowSelection);
|
|
146
|
+
* console.log('Selected rows:', selectedRows);
|
|
147
|
+
* }}
|
|
148
|
+
* />
|
|
132
149
|
* ```
|
|
133
150
|
*/
|
|
134
|
-
export declare function DataTable<TData, TValue>({ columns, data, isLoading, empty, checkboxSelection,
|
|
151
|
+
export declare function DataTable<TData, TValue>({ columns, data, isLoading, empty, checkboxSelection, rowSelection: externalRowSelection, onRowSelectionChange, enableSorting, manualSorting, sorting: externalSorting, onSortingChange: externalOnSortingChange, enableColumnFilters, enableColumnResizing, columnResizeMode, enableColumnPinning, onRowClick, actions, height, rowHeight, className, persistKey, initialSettings, onUpdate, }: DataTableProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,149 +1,154 @@
|
|
|
1
1
|
import { j as e } from "../../../_virtual/jsx-runtime.js";
|
|
2
|
-
import * as
|
|
3
|
-
import { useReactTable as
|
|
4
|
-
import { Table as
|
|
5
|
-
import { cn as
|
|
2
|
+
import * as L from "react";
|
|
3
|
+
import { useReactTable as k } from "../../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
4
|
+
import { Table as U } from "../../../vendor/shadcn/table.js";
|
|
5
|
+
import { cn as x } from "../../../lib/utils.js";
|
|
6
6
|
import { DataTableLoading as q } from "./components/states/data-table-loading.js";
|
|
7
7
|
import { DataTableHeader as J } from "./components/data-table-header.js";
|
|
8
|
-
import { DataTableBody as
|
|
9
|
-
import { useDataTableColumns as
|
|
10
|
-
import { useDataTableState as
|
|
11
|
-
import { ROW_HEIGHT_DEFAULT as
|
|
12
|
-
import { getFilteredRowModel as
|
|
8
|
+
import { DataTableBody as K } from "./components/data-table-body.js";
|
|
9
|
+
import { useDataTableColumns as Q } from "./hooks/use-data-table-columns.js";
|
|
10
|
+
import { useDataTableState as X } from "./hooks/use-data-table-state.js";
|
|
11
|
+
import { ROW_HEIGHT_DEFAULT as Y } from "./utils/data-table-constants.js";
|
|
12
|
+
import { getFilteredRowModel as Z, getSortedRowModel as O, getCoreRowModel as V } from "../../../node_modules/@tanstack/table-core/build/lib/index.js";
|
|
13
13
|
import { Empty as oo } from "../../molecules/empty/empty.js";
|
|
14
|
-
function
|
|
15
|
-
columns:
|
|
16
|
-
data:
|
|
17
|
-
isLoading:
|
|
18
|
-
empty:
|
|
19
|
-
checkboxSelection:
|
|
20
|
-
|
|
14
|
+
function po({
|
|
15
|
+
columns: u,
|
|
16
|
+
data: s,
|
|
17
|
+
isLoading: C = !1,
|
|
18
|
+
empty: y,
|
|
19
|
+
checkboxSelection: d = !1,
|
|
20
|
+
rowSelection: m,
|
|
21
21
|
onRowSelectionChange: l,
|
|
22
|
-
enableSorting:
|
|
23
|
-
manualSorting:
|
|
24
|
-
sorting:
|
|
25
|
-
onSortingChange:
|
|
26
|
-
enableColumnFilters:
|
|
27
|
-
enableColumnResizing:
|
|
28
|
-
columnResizeMode:
|
|
29
|
-
enableColumnPinning:
|
|
30
|
-
onRowClick:
|
|
31
|
-
actions:
|
|
32
|
-
height:
|
|
33
|
-
rowHeight:
|
|
34
|
-
className:
|
|
35
|
-
persistKey:
|
|
36
|
-
initialSettings:
|
|
37
|
-
onUpdate:
|
|
22
|
+
enableSorting: j = !0,
|
|
23
|
+
manualSorting: h = !1,
|
|
24
|
+
sorting: S,
|
|
25
|
+
onSortingChange: T,
|
|
26
|
+
enableColumnFilters: w = !1,
|
|
27
|
+
enableColumnResizing: a = !0,
|
|
28
|
+
columnResizeMode: v = "onChange",
|
|
29
|
+
enableColumnPinning: D = !0,
|
|
30
|
+
onRowClick: F,
|
|
31
|
+
actions: c,
|
|
32
|
+
height: E,
|
|
33
|
+
rowHeight: p = Y,
|
|
34
|
+
className: M,
|
|
35
|
+
persistKey: R,
|
|
36
|
+
initialSettings: N,
|
|
37
|
+
onUpdate: B
|
|
38
38
|
}) {
|
|
39
|
-
const
|
|
40
|
-
columns:
|
|
41
|
-
checkboxSelection:
|
|
42
|
-
actions:
|
|
39
|
+
const H = Q({
|
|
40
|
+
columns: u,
|
|
41
|
+
checkboxSelection: d,
|
|
42
|
+
actions: c
|
|
43
43
|
}), {
|
|
44
44
|
sorting: g,
|
|
45
|
-
setSorting:
|
|
46
|
-
columnFilters:
|
|
47
|
-
setColumnFilters:
|
|
48
|
-
columnVisibility:
|
|
49
|
-
setColumnVisibility:
|
|
50
|
-
rowSelection:
|
|
51
|
-
setRowSelection:
|
|
52
|
-
columnPinning:
|
|
53
|
-
handleColumnPinningChange:
|
|
54
|
-
} =
|
|
55
|
-
persistKey:
|
|
56
|
-
hasActions: !!
|
|
57
|
-
externalSorting:
|
|
58
|
-
onExternalSortingChange:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
45
|
+
setSorting: b,
|
|
46
|
+
columnFilters: I,
|
|
47
|
+
setColumnFilters: P,
|
|
48
|
+
columnVisibility: W,
|
|
49
|
+
setColumnVisibility: _,
|
|
50
|
+
rowSelection: n,
|
|
51
|
+
setRowSelection: $,
|
|
52
|
+
columnPinning: z,
|
|
53
|
+
handleColumnPinningChange: A
|
|
54
|
+
} = X({
|
|
55
|
+
persistKey: R,
|
|
56
|
+
hasActions: !!c,
|
|
57
|
+
externalSorting: S,
|
|
58
|
+
onExternalSortingChange: T,
|
|
59
|
+
externalRowSelection: m,
|
|
60
|
+
initialSettings: N,
|
|
61
|
+
onUpdate: B
|
|
62
|
+
}), f = k({
|
|
63
|
+
data: s,
|
|
64
|
+
columns: H,
|
|
65
|
+
getCoreRowModel: V(),
|
|
66
|
+
enableColumnResizing: a,
|
|
67
|
+
columnResizeMode: v,
|
|
68
|
+
enableColumnPinning: D,
|
|
68
69
|
defaultColumn: {
|
|
69
70
|
enableSorting: !1,
|
|
70
71
|
minSize: 50
|
|
71
72
|
},
|
|
72
|
-
...
|
|
73
|
+
...j && {
|
|
73
74
|
onSortingChange: (o) => {
|
|
74
|
-
|
|
75
|
+
b(typeof o == "function" ? o(g) : o);
|
|
75
76
|
},
|
|
76
|
-
getSortedRowModel:
|
|
77
|
-
manualSorting:
|
|
77
|
+
getSortedRowModel: O(),
|
|
78
|
+
manualSorting: h
|
|
79
|
+
},
|
|
80
|
+
...w && {
|
|
81
|
+
onColumnFiltersChange: P,
|
|
82
|
+
getFilteredRowModel: Z()
|
|
78
83
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
onColumnVisibilityChange: _,
|
|
85
|
+
onRowSelectionChange: (o) => {
|
|
86
|
+
const t = typeof o == "function" ? o(n) : o;
|
|
87
|
+
if ($(t), l && m !== void 0) {
|
|
88
|
+
const r = Object.keys(t).filter((i) => t[i]).map((i) => s[parseInt(i)]).filter(Boolean);
|
|
89
|
+
l(t, r);
|
|
90
|
+
}
|
|
82
91
|
},
|
|
83
|
-
|
|
84
|
-
onRowSelectionChange: C,
|
|
85
|
-
onColumnPinningChange: B,
|
|
92
|
+
onColumnPinningChange: A,
|
|
86
93
|
state: {
|
|
87
94
|
sorting: g,
|
|
88
|
-
columnFilters:
|
|
89
|
-
columnVisibility:
|
|
90
|
-
rowSelection:
|
|
91
|
-
columnPinning:
|
|
95
|
+
columnFilters: I,
|
|
96
|
+
columnVisibility: W,
|
|
97
|
+
rowSelection: n,
|
|
98
|
+
columnPinning: z
|
|
92
99
|
}
|
|
93
100
|
});
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const o = i.getFilteredSelectedRowModel().rows.map((t) => t.original);
|
|
99
|
-
l(o);
|
|
101
|
+
if (L.useEffect(() => {
|
|
102
|
+
if (l && m === void 0) {
|
|
103
|
+
const o = Object.keys(n).filter((t) => n[t]).map((t) => s[parseInt(t)]).filter(Boolean);
|
|
104
|
+
l(n, o);
|
|
100
105
|
}
|
|
101
|
-
}, [
|
|
106
|
+
}, [n, l, s, m]), C)
|
|
102
107
|
return /* @__PURE__ */ e.jsx(
|
|
103
108
|
q,
|
|
104
109
|
{
|
|
105
|
-
columns:
|
|
106
|
-
checkboxSelection:
|
|
107
|
-
actions:
|
|
108
|
-
rowHeight:
|
|
110
|
+
columns: u,
|
|
111
|
+
checkboxSelection: d,
|
|
112
|
+
actions: c,
|
|
113
|
+
rowHeight: p
|
|
109
114
|
}
|
|
110
115
|
);
|
|
111
|
-
if (
|
|
112
|
-
const o =
|
|
116
|
+
if (s.length === 0) {
|
|
117
|
+
const o = y || {}, {
|
|
113
118
|
title: t = "No results",
|
|
114
|
-
description:
|
|
115
|
-
media:
|
|
116
|
-
actions:
|
|
119
|
+
description: r = "No data available",
|
|
120
|
+
media: i,
|
|
121
|
+
actions: G
|
|
117
122
|
} = o;
|
|
118
123
|
return /* @__PURE__ */ e.jsx(
|
|
119
124
|
oo,
|
|
120
125
|
{
|
|
121
|
-
media:
|
|
126
|
+
media: i,
|
|
122
127
|
title: t,
|
|
123
|
-
description:
|
|
124
|
-
actions:
|
|
128
|
+
description: r,
|
|
129
|
+
actions: G
|
|
125
130
|
}
|
|
126
131
|
);
|
|
127
132
|
}
|
|
128
|
-
return /* @__PURE__ */ e.jsx("div", { className:
|
|
133
|
+
return /* @__PURE__ */ e.jsx("div", { className: x("yuno-data-table space-y-4", M), children: /* @__PURE__ */ e.jsx(
|
|
129
134
|
"div",
|
|
130
135
|
{
|
|
131
136
|
className: "rounded-md border overflow-x-auto",
|
|
132
|
-
style: { height:
|
|
137
|
+
style: { height: E || "auto" },
|
|
133
138
|
children: /* @__PURE__ */ e.jsxs(
|
|
134
|
-
|
|
139
|
+
U,
|
|
135
140
|
{
|
|
136
|
-
className:
|
|
141
|
+
className: x("table-fixed"),
|
|
137
142
|
children: [
|
|
138
|
-
/* @__PURE__ */ e.jsx("colgroup", { children:
|
|
139
|
-
const t = o.column.columnDef.enableResizing === !1,
|
|
140
|
-
return
|
|
143
|
+
/* @__PURE__ */ e.jsx("colgroup", { children: f.getHeaderGroups()[0]?.headers.map((o) => {
|
|
144
|
+
const t = o.column.columnDef.enableResizing === !1, r = o.column.id === "_spacer", i = o.column.getSize();
|
|
145
|
+
return r ? /* @__PURE__ */ e.jsx("col", { style: { width: "auto" } }, o.id) : /* @__PURE__ */ e.jsx(
|
|
141
146
|
"col",
|
|
142
147
|
{
|
|
143
148
|
style: {
|
|
144
|
-
width: t ? `${
|
|
145
|
-
minWidth: t ? `${
|
|
146
|
-
maxWidth: t ? `${
|
|
149
|
+
width: t ? `${i}px` : "auto",
|
|
150
|
+
minWidth: t ? `${i}px` : void 0,
|
|
151
|
+
maxWidth: t ? `${i}px` : void 0
|
|
147
152
|
}
|
|
148
153
|
},
|
|
149
154
|
o.id
|
|
@@ -152,17 +157,17 @@ function go({
|
|
|
152
157
|
/* @__PURE__ */ e.jsx(
|
|
153
158
|
J,
|
|
154
159
|
{
|
|
155
|
-
table:
|
|
156
|
-
enableColumnResizing:
|
|
160
|
+
table: f,
|
|
161
|
+
enableColumnResizing: a
|
|
157
162
|
}
|
|
158
163
|
),
|
|
159
164
|
/* @__PURE__ */ e.jsx(
|
|
160
|
-
|
|
165
|
+
K,
|
|
161
166
|
{
|
|
162
|
-
table:
|
|
163
|
-
enableColumnResizing:
|
|
164
|
-
onRowClick:
|
|
165
|
-
rowHeight:
|
|
167
|
+
table: f,
|
|
168
|
+
enableColumnResizing: a,
|
|
169
|
+
onRowClick: F,
|
|
170
|
+
rowHeight: p
|
|
166
171
|
}
|
|
167
172
|
)
|
|
168
173
|
]
|
|
@@ -172,5 +177,5 @@ function go({
|
|
|
172
177
|
) });
|
|
173
178
|
}
|
|
174
179
|
export {
|
|
175
|
-
|
|
180
|
+
po as DataTable
|
|
176
181
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnDef, RowData, SortingState, VisibilityState, ColumnFiltersState, PaginationState, Table, Column, CellContext, HeaderContext } from '@tanstack/react-table';
|
|
1
|
+
import { ColumnDef, RowData, SortingState, VisibilityState, ColumnFiltersState, PaginationState, RowSelectionState, Table, Column, CellContext, HeaderContext } from '@tanstack/react-table';
|
|
2
2
|
import { IconName } from '../../atoms/icon';
|
|
3
3
|
import { EmptyProps } from '../../molecules';
|
|
4
4
|
declare module "@tanstack/react-table" {
|
|
@@ -100,8 +100,18 @@ export interface DataTableProps<TData> {
|
|
|
100
100
|
isLoading?: boolean;
|
|
101
101
|
empty?: EmptyProps;
|
|
102
102
|
checkboxSelection?: boolean;
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Controlled row selection state (optional)
|
|
105
|
+
* If provided, component operates in controlled mode
|
|
106
|
+
*/
|
|
107
|
+
rowSelection?: RowSelectionState;
|
|
108
|
+
/**
|
|
109
|
+
* Callback fired when row selection changes
|
|
110
|
+
* In controlled mode, you must update the rowSelection prop
|
|
111
|
+
* @param rowSelectionState - Object with row indices as keys (e.g., { "0": true, "2": true })
|
|
112
|
+
* @param selectedRows - Array of actual row data objects
|
|
113
|
+
*/
|
|
114
|
+
onRowSelectionChange?: (rowSelectionState: RowSelectionState, selectedRows: TData[]) => void;
|
|
105
115
|
enablePagination?: boolean;
|
|
106
116
|
pageSize?: number;
|
|
107
117
|
pageIndex?: number;
|
|
@@ -6,10 +6,11 @@ interface UseDataTableStateProps {
|
|
|
6
6
|
hasActions?: boolean;
|
|
7
7
|
externalSorting?: SortingState;
|
|
8
8
|
onExternalSortingChange?: (sorting: SortingState) => void;
|
|
9
|
+
externalRowSelection?: RowSelectionState;
|
|
9
10
|
initialSettings?: DataTableSettings;
|
|
10
11
|
onUpdate?: (settings: DataTableSettings) => void;
|
|
11
12
|
}
|
|
12
|
-
export declare function useDataTableState({ persistKey, hasActions, externalSorting, onExternalSortingChange, initialSettings, onUpdate, }: UseDataTableStateProps): {
|
|
13
|
+
export declare function useDataTableState({ persistKey, hasActions, externalSorting, onExternalSortingChange, externalRowSelection, initialSettings, onUpdate, }: UseDataTableStateProps): {
|
|
13
14
|
sorting: SortingState;
|
|
14
15
|
setSorting: (sorting: SortingState) => void;
|
|
15
16
|
columnFilters: ColumnFiltersState;
|
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
import * as i from "react";
|
|
2
|
-
function
|
|
3
|
-
persistKey:
|
|
2
|
+
function $({
|
|
3
|
+
persistKey: r,
|
|
4
4
|
hasActions: s = !1,
|
|
5
5
|
externalSorting: P,
|
|
6
|
-
onExternalSortingChange:
|
|
7
|
-
|
|
6
|
+
onExternalSortingChange: l,
|
|
7
|
+
externalRowSelection: y,
|
|
8
|
+
initialSettings: o,
|
|
8
9
|
onUpdate: m
|
|
9
10
|
}) {
|
|
10
|
-
const [c, a] = i.useState([]), [
|
|
11
|
+
const [c, a] = i.useState([]), [w, I] = i.useState(
|
|
11
12
|
[]
|
|
12
13
|
), [u, d] = i.useState({}), [V, C] = i.useState({}), [f, g] = i.useState({
|
|
13
14
|
left: [],
|
|
14
15
|
right: s ? ["actions"] : []
|
|
15
|
-
}), F = P ?? c,
|
|
16
|
+
}), F = P ?? c, O = l ?? a, R = y ?? V, v = C;
|
|
16
17
|
i.useEffect(() => {
|
|
17
|
-
if (
|
|
18
|
-
if (
|
|
18
|
+
if (o) {
|
|
19
|
+
if (o.hide || o.show) {
|
|
19
20
|
const e = {};
|
|
20
|
-
|
|
21
|
+
o.hide?.forEach((t) => {
|
|
21
22
|
e[t] = !1;
|
|
22
23
|
}), d(e);
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
left:
|
|
25
|
+
o.pinnedColumns && g({
|
|
26
|
+
left: o.pinnedColumns.left || [],
|
|
26
27
|
right: [
|
|
27
|
-
...(
|
|
28
|
+
...(o.pinnedColumns.right || []).filter(
|
|
28
29
|
(e) => e !== "actions"
|
|
29
30
|
),
|
|
30
31
|
...s ? ["actions"] : []
|
|
31
32
|
]
|
|
32
|
-
}), !
|
|
33
|
+
}), !l && o.sorting && a(o.sorting);
|
|
33
34
|
}
|
|
34
|
-
}, [
|
|
35
|
-
if (!
|
|
36
|
-
const e = localStorage.getItem(`datatable-${
|
|
35
|
+
}, [o, s, l]), i.useEffect(() => {
|
|
36
|
+
if (!r) return;
|
|
37
|
+
const e = localStorage.getItem(`datatable-${r}`);
|
|
37
38
|
if (e)
|
|
38
39
|
try {
|
|
39
40
|
const t = JSON.parse(e);
|
|
@@ -41,45 +42,45 @@ function N({
|
|
|
41
42
|
left: t.columnPinning.left || [],
|
|
42
43
|
right: [
|
|
43
44
|
...(t.columnPinning.right || []).filter(
|
|
44
|
-
(
|
|
45
|
+
(n) => n !== "actions"
|
|
45
46
|
),
|
|
46
47
|
...s ? ["actions"] : []
|
|
47
48
|
]
|
|
48
|
-
}), !
|
|
49
|
+
}), !l && t.sorting && a(t.sorting);
|
|
49
50
|
} catch (t) {
|
|
50
51
|
console.error("Failed to load table state", t);
|
|
51
52
|
}
|
|
52
|
-
}, [
|
|
53
|
-
const e = Object.entries(u).filter(([,
|
|
53
|
+
}, [r, s, l]), i.useEffect(() => {
|
|
54
|
+
const e = Object.entries(u).filter(([, n]) => !n).map(([n]) => n), t = {
|
|
54
55
|
hide: e.length > 0 ? e : void 0,
|
|
55
56
|
pinnedColumns: {
|
|
56
57
|
left: f.left || [],
|
|
57
58
|
right: f.right || []
|
|
58
59
|
},
|
|
59
60
|
// Only include sorting if not controlled externally
|
|
60
|
-
...!
|
|
61
|
+
...!l && c.length > 0 && { sorting: c }
|
|
61
62
|
};
|
|
62
|
-
if (
|
|
63
|
-
const
|
|
63
|
+
if (r) {
|
|
64
|
+
const n = {
|
|
64
65
|
columnVisibility: u,
|
|
65
66
|
columnPinning: f,
|
|
66
|
-
...!
|
|
67
|
+
...!l && { sorting: c }
|
|
67
68
|
};
|
|
68
|
-
localStorage.setItem(`datatable-${
|
|
69
|
+
localStorage.setItem(`datatable-${r}`, JSON.stringify(n));
|
|
69
70
|
}
|
|
70
71
|
m && m(t);
|
|
71
|
-
}, [u, f, c,
|
|
72
|
-
const
|
|
72
|
+
}, [u, f, c, r, l, m]);
|
|
73
|
+
const J = i.useCallback(
|
|
73
74
|
(e) => {
|
|
74
75
|
g((t) => {
|
|
75
|
-
const
|
|
76
|
+
const n = typeof e == "function" ? e(t) : e, h = Array.isArray(n.left) ? n.left : [], b = Array.isArray(n.right) ? n.right : [];
|
|
76
77
|
if (s) {
|
|
77
|
-
const
|
|
78
|
-
(
|
|
78
|
+
const N = b.filter(
|
|
79
|
+
(S) => S !== "actions"
|
|
79
80
|
);
|
|
80
81
|
return {
|
|
81
82
|
left: h,
|
|
82
|
-
right: [...
|
|
83
|
+
right: [...N, "actions"]
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
return {
|
|
@@ -92,17 +93,17 @@ function N({
|
|
|
92
93
|
);
|
|
93
94
|
return {
|
|
94
95
|
sorting: F,
|
|
95
|
-
setSorting:
|
|
96
|
-
columnFilters:
|
|
97
|
-
setColumnFilters:
|
|
96
|
+
setSorting: O,
|
|
97
|
+
columnFilters: w,
|
|
98
|
+
setColumnFilters: I,
|
|
98
99
|
columnVisibility: u,
|
|
99
100
|
setColumnVisibility: d,
|
|
100
|
-
rowSelection:
|
|
101
|
-
setRowSelection:
|
|
101
|
+
rowSelection: R,
|
|
102
|
+
setRowSelection: v,
|
|
102
103
|
columnPinning: f,
|
|
103
|
-
handleColumnPinningChange:
|
|
104
|
+
handleColumnPinningChange: J
|
|
104
105
|
};
|
|
105
106
|
}
|
|
106
107
|
export {
|
|
107
|
-
|
|
108
|
+
$ as useDataTableState
|
|
108
109
|
};
|