@yuno-payments/dashboard-design-system 0.0.151 → 0.0.152
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.
|
@@ -27,6 +27,11 @@ export interface DataTableProps<TData, TValue> {
|
|
|
27
27
|
* @default false
|
|
28
28
|
*/
|
|
29
29
|
checkboxSelection?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Key to force reset of row selection. Change this value to clear all selections.
|
|
32
|
+
* Useful when parent needs to programmatically clear selections.
|
|
33
|
+
*/
|
|
34
|
+
selectionResetKey?: string | number;
|
|
30
35
|
/**
|
|
31
36
|
* Callback fired when row selection changes
|
|
32
37
|
*/
|
|
@@ -126,4 +131,4 @@ export interface DataTableProps<TData, TValue> {
|
|
|
126
131
|
* />
|
|
127
132
|
* ```
|
|
128
133
|
*/
|
|
129
|
-
export declare function DataTable<TData, TValue>({ columns, data, isLoading, empty, checkboxSelection, 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;
|
|
134
|
+
export declare function DataTable<TData, TValue>({ columns, data, isLoading, empty, checkboxSelection, selectionResetKey, 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,136 +1,139 @@
|
|
|
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
|
|
6
|
-
import { DataTableLoading as
|
|
7
|
-
import { DataTableHeader as
|
|
8
|
-
import { DataTableBody as
|
|
9
|
-
import { useDataTableColumns as
|
|
10
|
-
import { useDataTableState as
|
|
11
|
-
import { ROW_HEIGHT_DEFAULT as
|
|
12
|
-
import { getFilteredRowModel as
|
|
13
|
-
import { Empty as
|
|
14
|
-
function
|
|
2
|
+
import * as b from "react";
|
|
3
|
+
import { useReactTable as U } from "../../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
4
|
+
import { Table as V } from "../../../vendor/shadcn/table.js";
|
|
5
|
+
import { cn as h } from "../../../lib/utils.js";
|
|
6
|
+
import { DataTableLoading as q } from "./components/states/data-table-loading.js";
|
|
7
|
+
import { DataTableHeader as J } from "./components/data-table-header.js";
|
|
8
|
+
import { DataTableBody as Q } from "./components/data-table-body.js";
|
|
9
|
+
import { useDataTableColumns as X } from "./hooks/use-data-table-columns.js";
|
|
10
|
+
import { useDataTableState as Y } from "./hooks/use-data-table-state.js";
|
|
11
|
+
import { ROW_HEIGHT_DEFAULT as Z } from "./utils/data-table-constants.js";
|
|
12
|
+
import { getFilteredRowModel as k, getSortedRowModel as K, getCoreRowModel as O } from "../../../node_modules/@tanstack/table-core/build/lib/index.js";
|
|
13
|
+
import { Empty as oo } from "../../molecules/empty/empty.js";
|
|
14
|
+
function go({
|
|
15
15
|
columns: m,
|
|
16
16
|
data: d,
|
|
17
|
-
isLoading:
|
|
18
|
-
empty:
|
|
19
|
-
checkboxSelection:
|
|
17
|
+
isLoading: S = !1,
|
|
18
|
+
empty: j,
|
|
19
|
+
checkboxSelection: u = !1,
|
|
20
|
+
selectionResetKey: c,
|
|
20
21
|
onRowSelectionChange: l,
|
|
21
|
-
enableSorting:
|
|
22
|
-
manualSorting:
|
|
23
|
-
sorting:
|
|
24
|
-
onSortingChange:
|
|
25
|
-
enableColumnFilters:
|
|
26
|
-
enableColumnResizing:
|
|
27
|
-
columnResizeMode:
|
|
28
|
-
enableColumnPinning:
|
|
29
|
-
onRowClick:
|
|
30
|
-
actions:
|
|
31
|
-
height:
|
|
32
|
-
rowHeight:
|
|
33
|
-
className:
|
|
34
|
-
persistKey:
|
|
35
|
-
initialSettings:
|
|
36
|
-
onUpdate:
|
|
22
|
+
enableSorting: w = !0,
|
|
23
|
+
manualSorting: y = !1,
|
|
24
|
+
sorting: T,
|
|
25
|
+
onSortingChange: R,
|
|
26
|
+
enableColumnFilters: D = !1,
|
|
27
|
+
enableColumnResizing: r = !0,
|
|
28
|
+
columnResizeMode: F = "onChange",
|
|
29
|
+
enableColumnPinning: v = !0,
|
|
30
|
+
onRowClick: E,
|
|
31
|
+
actions: s,
|
|
32
|
+
height: M,
|
|
33
|
+
rowHeight: f = Z,
|
|
34
|
+
className: N,
|
|
35
|
+
persistKey: H,
|
|
36
|
+
initialSettings: P,
|
|
37
|
+
onUpdate: W
|
|
37
38
|
}) {
|
|
38
|
-
const
|
|
39
|
+
const _ = X({
|
|
39
40
|
columns: m,
|
|
40
|
-
checkboxSelection:
|
|
41
|
-
actions:
|
|
41
|
+
checkboxSelection: u,
|
|
42
|
+
actions: s
|
|
42
43
|
}), {
|
|
43
|
-
sorting:
|
|
44
|
-
setSorting:
|
|
45
|
-
columnFilters:
|
|
46
|
-
setColumnFilters:
|
|
47
|
-
columnVisibility:
|
|
48
|
-
setColumnVisibility:
|
|
49
|
-
rowSelection:
|
|
50
|
-
setRowSelection:
|
|
51
|
-
columnPinning:
|
|
52
|
-
handleColumnPinningChange:
|
|
53
|
-
} =
|
|
54
|
-
persistKey:
|
|
55
|
-
hasActions: !!
|
|
56
|
-
externalSorting:
|
|
57
|
-
onExternalSortingChange:
|
|
58
|
-
initialSettings:
|
|
59
|
-
onUpdate:
|
|
60
|
-
}), i =
|
|
44
|
+
sorting: g,
|
|
45
|
+
setSorting: p,
|
|
46
|
+
columnFilters: $,
|
|
47
|
+
setColumnFilters: z,
|
|
48
|
+
columnVisibility: A,
|
|
49
|
+
setColumnVisibility: G,
|
|
50
|
+
rowSelection: x,
|
|
51
|
+
setRowSelection: C,
|
|
52
|
+
columnPinning: L,
|
|
53
|
+
handleColumnPinningChange: B
|
|
54
|
+
} = Y({
|
|
55
|
+
persistKey: H,
|
|
56
|
+
hasActions: !!s,
|
|
57
|
+
externalSorting: T,
|
|
58
|
+
onExternalSortingChange: R,
|
|
59
|
+
initialSettings: P,
|
|
60
|
+
onUpdate: W
|
|
61
|
+
}), i = U({
|
|
61
62
|
data: d,
|
|
62
|
-
columns:
|
|
63
|
-
getCoreRowModel:
|
|
64
|
-
enableColumnResizing:
|
|
65
|
-
columnResizeMode:
|
|
66
|
-
enableColumnPinning:
|
|
63
|
+
columns: _,
|
|
64
|
+
getCoreRowModel: O(),
|
|
65
|
+
enableColumnResizing: r,
|
|
66
|
+
columnResizeMode: F,
|
|
67
|
+
enableColumnPinning: v,
|
|
67
68
|
defaultColumn: {
|
|
68
69
|
enableSorting: !1,
|
|
69
70
|
minSize: 50
|
|
70
71
|
},
|
|
71
|
-
...
|
|
72
|
+
...w && {
|
|
72
73
|
onSortingChange: (o) => {
|
|
73
|
-
|
|
74
|
+
p(typeof o == "function" ? o(g) : o);
|
|
74
75
|
},
|
|
75
|
-
getSortedRowModel:
|
|
76
|
-
manualSorting:
|
|
76
|
+
getSortedRowModel: K(),
|
|
77
|
+
manualSorting: y
|
|
77
78
|
},
|
|
78
|
-
...
|
|
79
|
-
onColumnFiltersChange:
|
|
80
|
-
getFilteredRowModel:
|
|
79
|
+
...D && {
|
|
80
|
+
onColumnFiltersChange: z,
|
|
81
|
+
getFilteredRowModel: k()
|
|
81
82
|
},
|
|
82
|
-
onColumnVisibilityChange:
|
|
83
|
-
onRowSelectionChange:
|
|
84
|
-
onColumnPinningChange:
|
|
83
|
+
onColumnVisibilityChange: G,
|
|
84
|
+
onRowSelectionChange: C,
|
|
85
|
+
onColumnPinningChange: B,
|
|
85
86
|
state: {
|
|
86
|
-
sorting:
|
|
87
|
-
columnFilters:
|
|
88
|
-
columnVisibility:
|
|
89
|
-
rowSelection:
|
|
90
|
-
columnPinning:
|
|
87
|
+
sorting: g,
|
|
88
|
+
columnFilters: $,
|
|
89
|
+
columnVisibility: A,
|
|
90
|
+
rowSelection: x,
|
|
91
|
+
columnPinning: L
|
|
91
92
|
}
|
|
92
93
|
});
|
|
93
|
-
if (
|
|
94
|
+
if (b.useEffect(() => {
|
|
95
|
+
c !== void 0 && C({});
|
|
96
|
+
}, [c]), b.useEffect(() => {
|
|
94
97
|
if (l) {
|
|
95
98
|
const o = i.getFilteredSelectedRowModel().rows.map((t) => t.original);
|
|
96
99
|
l(o);
|
|
97
100
|
}
|
|
98
|
-
}, [
|
|
101
|
+
}, [x, l, i]), S)
|
|
99
102
|
return /* @__PURE__ */ e.jsx(
|
|
100
|
-
|
|
103
|
+
q,
|
|
101
104
|
{
|
|
102
105
|
columns: m,
|
|
103
|
-
checkboxSelection:
|
|
104
|
-
actions:
|
|
105
|
-
rowHeight:
|
|
106
|
+
checkboxSelection: u,
|
|
107
|
+
actions: s,
|
|
108
|
+
rowHeight: f
|
|
106
109
|
}
|
|
107
110
|
);
|
|
108
111
|
if (d.length === 0) {
|
|
109
|
-
const o =
|
|
112
|
+
const o = j || {}, {
|
|
110
113
|
title: t = "No results",
|
|
111
114
|
description: a = "No data available",
|
|
112
115
|
media: n,
|
|
113
|
-
actions:
|
|
116
|
+
actions: I
|
|
114
117
|
} = o;
|
|
115
118
|
return /* @__PURE__ */ e.jsx(
|
|
116
|
-
|
|
119
|
+
oo,
|
|
117
120
|
{
|
|
118
121
|
media: n,
|
|
119
122
|
title: t,
|
|
120
123
|
description: a,
|
|
121
|
-
actions:
|
|
124
|
+
actions: I
|
|
122
125
|
}
|
|
123
126
|
);
|
|
124
127
|
}
|
|
125
|
-
return /* @__PURE__ */ e.jsx("div", { className:
|
|
128
|
+
return /* @__PURE__ */ e.jsx("div", { className: h("yuno-data-table space-y-4", N), children: /* @__PURE__ */ e.jsx(
|
|
126
129
|
"div",
|
|
127
130
|
{
|
|
128
131
|
className: "rounded-md border overflow-x-auto",
|
|
129
|
-
style: { height:
|
|
132
|
+
style: { height: M || "auto" },
|
|
130
133
|
children: /* @__PURE__ */ e.jsxs(
|
|
131
|
-
|
|
134
|
+
V,
|
|
132
135
|
{
|
|
133
|
-
className:
|
|
136
|
+
className: h("table-fixed"),
|
|
134
137
|
children: [
|
|
135
138
|
/* @__PURE__ */ e.jsx("colgroup", { children: i.getHeaderGroups()[0]?.headers.map((o) => {
|
|
136
139
|
const t = o.column.columnDef.enableResizing === !1, a = o.column.id === "_spacer", n = o.column.getSize();
|
|
@@ -147,19 +150,19 @@ function fo({
|
|
|
147
150
|
);
|
|
148
151
|
}) }),
|
|
149
152
|
/* @__PURE__ */ e.jsx(
|
|
150
|
-
|
|
153
|
+
J,
|
|
151
154
|
{
|
|
152
155
|
table: i,
|
|
153
|
-
enableColumnResizing:
|
|
156
|
+
enableColumnResizing: r
|
|
154
157
|
}
|
|
155
158
|
),
|
|
156
159
|
/* @__PURE__ */ e.jsx(
|
|
157
|
-
|
|
160
|
+
Q,
|
|
158
161
|
{
|
|
159
162
|
table: i,
|
|
160
|
-
enableColumnResizing:
|
|
161
|
-
onRowClick:
|
|
162
|
-
rowHeight:
|
|
163
|
+
enableColumnResizing: r,
|
|
164
|
+
onRowClick: E,
|
|
165
|
+
rowHeight: f
|
|
163
166
|
}
|
|
164
167
|
)
|
|
165
168
|
]
|
|
@@ -169,5 +172,5 @@ function fo({
|
|
|
169
172
|
) });
|
|
170
173
|
}
|
|
171
174
|
export {
|
|
172
|
-
|
|
175
|
+
go as DataTable
|
|
173
176
|
};
|
|
@@ -100,6 +100,7 @@ export interface DataTableProps<TData> {
|
|
|
100
100
|
isLoading?: boolean;
|
|
101
101
|
empty?: EmptyProps;
|
|
102
102
|
checkboxSelection?: boolean;
|
|
103
|
+
selectionResetKey?: string | number;
|
|
103
104
|
onRowSelectionChange?: (selectedRows: TData[]) => void;
|
|
104
105
|
enablePagination?: boolean;
|
|
105
106
|
pageSize?: number;
|