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