@yuno-payments/dashboard-design-system 0.0.151-beta.1 → 0.0.151-beta.2
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.
|
@@ -28,10 +28,10 @@ export interface DataTableProps<TData, TValue> {
|
|
|
28
28
|
*/
|
|
29
29
|
checkboxSelection?: boolean;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
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
33
|
*/
|
|
34
|
-
|
|
34
|
+
selectionResetKey?: string | number;
|
|
35
35
|
/**
|
|
36
36
|
* Callback fired when row selection changes
|
|
37
37
|
*/
|
|
@@ -131,4 +131,4 @@ export interface DataTableProps<TData, TValue> {
|
|
|
131
131
|
* />
|
|
132
132
|
* ```
|
|
133
133
|
*/
|
|
134
|
-
export declare function DataTable<TData, TValue>({ columns, data, isLoading, empty, checkboxSelection,
|
|
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,176 +1,168 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import * as
|
|
1
|
+
import { j as e } from "../../../_virtual/jsx-runtime.js";
|
|
2
|
+
import * as b from "react";
|
|
3
3
|
import { useReactTable as U } from "../../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
4
4
|
import { Table as V } from "../../../vendor/shadcn/table.js";
|
|
5
|
-
import { cn as
|
|
5
|
+
import { cn as h } 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
|
|
13
|
-
import { Empty as
|
|
14
|
-
function
|
|
15
|
-
columns:
|
|
16
|
-
data:
|
|
17
|
-
isLoading:
|
|
18
|
-
empty:
|
|
19
|
-
checkboxSelection:
|
|
20
|
-
|
|
21
|
-
onRowSelectionChange:
|
|
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:
|
|
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
|
+
columns: m,
|
|
16
|
+
data: d,
|
|
17
|
+
isLoading: S = !1,
|
|
18
|
+
empty: j,
|
|
19
|
+
checkboxSelection: u = !1,
|
|
20
|
+
selectionResetKey: c,
|
|
21
|
+
onRowSelectionChange: l,
|
|
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
|
|
38
38
|
}) {
|
|
39
|
-
const
|
|
40
|
-
columns:
|
|
41
|
-
checkboxSelection:
|
|
42
|
-
actions:
|
|
39
|
+
const _ = X({
|
|
40
|
+
columns: m,
|
|
41
|
+
checkboxSelection: u,
|
|
42
|
+
actions: s
|
|
43
43
|
}), {
|
|
44
|
-
sorting:
|
|
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
|
-
initialSettings:
|
|
60
|
-
onUpdate:
|
|
61
|
-
}),
|
|
62
|
-
data:
|
|
63
|
-
columns:
|
|
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({
|
|
62
|
+
data: d,
|
|
63
|
+
columns: _,
|
|
64
64
|
getCoreRowModel: O(),
|
|
65
|
-
enableColumnResizing:
|
|
66
|
-
columnResizeMode:
|
|
67
|
-
enableColumnPinning:
|
|
65
|
+
enableColumnResizing: r,
|
|
66
|
+
columnResizeMode: F,
|
|
67
|
+
enableColumnPinning: v,
|
|
68
68
|
defaultColumn: {
|
|
69
69
|
enableSorting: !1,
|
|
70
70
|
minSize: 50
|
|
71
71
|
},
|
|
72
|
-
...
|
|
73
|
-
onSortingChange: (
|
|
74
|
-
|
|
72
|
+
...w && {
|
|
73
|
+
onSortingChange: (o) => {
|
|
74
|
+
p(typeof o == "function" ? o(g) : o);
|
|
75
75
|
},
|
|
76
|
-
getSortedRowModel:
|
|
77
|
-
manualSorting:
|
|
76
|
+
getSortedRowModel: K(),
|
|
77
|
+
manualSorting: y
|
|
78
78
|
},
|
|
79
|
-
...
|
|
80
|
-
onColumnFiltersChange:
|
|
81
|
-
getFilteredRowModel:
|
|
79
|
+
...D && {
|
|
80
|
+
onColumnFiltersChange: z,
|
|
81
|
+
getFilteredRowModel: k()
|
|
82
82
|
},
|
|
83
|
-
onColumnVisibilityChange:
|
|
84
|
-
onRowSelectionChange:
|
|
85
|
-
onColumnPinningChange:
|
|
83
|
+
onColumnVisibilityChange: G,
|
|
84
|
+
onRowSelectionChange: C,
|
|
85
|
+
onColumnPinningChange: B,
|
|
86
86
|
state: {
|
|
87
|
-
sorting:
|
|
88
|
-
columnFilters:
|
|
89
|
-
columnVisibility:
|
|
90
|
-
rowSelection:
|
|
91
|
-
columnPinning:
|
|
87
|
+
sorting: g,
|
|
88
|
+
columnFilters: $,
|
|
89
|
+
columnVisibility: A,
|
|
90
|
+
rowSelection: x,
|
|
91
|
+
columnPinning: L
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
if (b.useEffect(() => {
|
|
95
|
+
c !== void 0 && C({});
|
|
96
|
+
}, [c]), b.useEffect(() => {
|
|
97
|
+
if (l) {
|
|
98
|
+
const o = i.getFilteredSelectedRowModel().rows.map((t) => t.original);
|
|
99
|
+
l(o);
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}), m(e);
|
|
104
|
-
}, [a, s, m]), S.useEffect(() => {
|
|
105
|
-
if (u) {
|
|
106
|
-
const e = n.getFilteredSelectedRowModel().rows.map((o) => o.original);
|
|
107
|
-
u(e);
|
|
108
|
-
}
|
|
109
|
-
}, [h, u, n]), j)
|
|
110
|
-
return /* @__PURE__ */ t.jsx(
|
|
101
|
+
}, [x, l, i]), S)
|
|
102
|
+
return /* @__PURE__ */ e.jsx(
|
|
111
103
|
q,
|
|
112
104
|
{
|
|
113
|
-
columns:
|
|
114
|
-
checkboxSelection:
|
|
115
|
-
actions:
|
|
116
|
-
rowHeight:
|
|
105
|
+
columns: m,
|
|
106
|
+
checkboxSelection: u,
|
|
107
|
+
actions: s,
|
|
108
|
+
rowHeight: f
|
|
117
109
|
}
|
|
118
110
|
);
|
|
119
|
-
if (
|
|
120
|
-
const
|
|
121
|
-
title:
|
|
122
|
-
description:
|
|
123
|
-
media:
|
|
124
|
-
actions:
|
|
125
|
-
} =
|
|
126
|
-
return /* @__PURE__ */
|
|
127
|
-
|
|
111
|
+
if (d.length === 0) {
|
|
112
|
+
const o = j || {}, {
|
|
113
|
+
title: t = "No results",
|
|
114
|
+
description: a = "No data available",
|
|
115
|
+
media: n,
|
|
116
|
+
actions: I
|
|
117
|
+
} = o;
|
|
118
|
+
return /* @__PURE__ */ e.jsx(
|
|
119
|
+
oo,
|
|
128
120
|
{
|
|
129
|
-
media:
|
|
130
|
-
title:
|
|
131
|
-
description:
|
|
132
|
-
actions:
|
|
121
|
+
media: n,
|
|
122
|
+
title: t,
|
|
123
|
+
description: a,
|
|
124
|
+
actions: I
|
|
133
125
|
}
|
|
134
126
|
);
|
|
135
127
|
}
|
|
136
|
-
return /* @__PURE__ */
|
|
128
|
+
return /* @__PURE__ */ e.jsx("div", { className: h("yuno-data-table space-y-4", N), children: /* @__PURE__ */ e.jsx(
|
|
137
129
|
"div",
|
|
138
130
|
{
|
|
139
131
|
className: "rounded-md border overflow-x-auto",
|
|
140
|
-
style: { height:
|
|
141
|
-
children: /* @__PURE__ */
|
|
132
|
+
style: { height: M || "auto" },
|
|
133
|
+
children: /* @__PURE__ */ e.jsxs(
|
|
142
134
|
V,
|
|
143
135
|
{
|
|
144
|
-
className:
|
|
136
|
+
className: h("table-fixed"),
|
|
145
137
|
children: [
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
const
|
|
148
|
-
return
|
|
138
|
+
/* @__PURE__ */ e.jsx("colgroup", { children: i.getHeaderGroups()[0]?.headers.map((o) => {
|
|
139
|
+
const t = o.column.columnDef.enableResizing === !1, a = o.column.id === "_spacer", n = o.column.getSize();
|
|
140
|
+
return a ? /* @__PURE__ */ e.jsx("col", { style: { width: "auto" } }, o.id) : /* @__PURE__ */ e.jsx(
|
|
149
141
|
"col",
|
|
150
142
|
{
|
|
151
143
|
style: {
|
|
152
|
-
width:
|
|
153
|
-
minWidth:
|
|
154
|
-
maxWidth:
|
|
144
|
+
width: t ? `${n}px` : "auto",
|
|
145
|
+
minWidth: t ? `${n}px` : void 0,
|
|
146
|
+
maxWidth: t ? `${n}px` : void 0
|
|
155
147
|
}
|
|
156
148
|
},
|
|
157
|
-
|
|
149
|
+
o.id
|
|
158
150
|
);
|
|
159
151
|
}) }),
|
|
160
|
-
/* @__PURE__ */
|
|
152
|
+
/* @__PURE__ */ e.jsx(
|
|
161
153
|
J,
|
|
162
154
|
{
|
|
163
|
-
table:
|
|
164
|
-
enableColumnResizing:
|
|
155
|
+
table: i,
|
|
156
|
+
enableColumnResizing: r
|
|
165
157
|
}
|
|
166
158
|
),
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
|
|
159
|
+
/* @__PURE__ */ e.jsx(
|
|
160
|
+
Q,
|
|
169
161
|
{
|
|
170
|
-
table:
|
|
171
|
-
enableColumnResizing:
|
|
172
|
-
onRowClick:
|
|
173
|
-
rowHeight:
|
|
162
|
+
table: i,
|
|
163
|
+
enableColumnResizing: r,
|
|
164
|
+
onRowClick: E,
|
|
165
|
+
rowHeight: f
|
|
174
166
|
}
|
|
175
167
|
)
|
|
176
168
|
]
|
|
@@ -180,5 +172,5 @@ function de({
|
|
|
180
172
|
) });
|
|
181
173
|
}
|
|
182
174
|
export {
|
|
183
|
-
|
|
175
|
+
go as DataTable
|
|
184
176
|
};
|
|
@@ -100,7 +100,7 @@ export interface DataTableProps<TData> {
|
|
|
100
100
|
isLoading?: boolean;
|
|
101
101
|
empty?: EmptyProps;
|
|
102
102
|
checkboxSelection?: boolean;
|
|
103
|
-
|
|
103
|
+
selectionResetKey?: string | number;
|
|
104
104
|
onRowSelectionChange?: (selectedRows: TData[]) => void;
|
|
105
105
|
enablePagination?: boolean;
|
|
106
106
|
pageSize?: number;
|