@yuno-payments/dashboard-design-system 1.4.0 → 1.4.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.
- package/dist/components/organisms/data-table/components/cells/data-table-draggable-header-cell.d.ts +8 -0
- package/dist/components/organisms/data-table/components/cells/data-table-draggable-header-cell.js +51 -0
- package/dist/components/organisms/data-table/components/cells/data-table-list-cell.js +1 -6
- package/dist/components/organisms/data-table/components/data-table-header.d.ts +2 -13
- package/dist/components/organisms/data-table/components/data-table-header.js +30 -12
- package/dist/components/organisms/data-table/components/dialogs/data-table-manage-columns-dialog.js +6 -2
- package/dist/components/organisms/data-table/data-table.d.ts +13 -27
- package/dist/components/organisms/data-table/data-table.js +179 -150
- package/dist/components/organisms/data-table/hooks/use-data-table-state.d.ts +5 -2
- package/dist/components/organisms/data-table/hooks/use-data-table-state.js +80 -57
- package/dist/dashboard-design-system.css +1 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.min.js +10120 -10015
- package/dist/index.umd.min.js +24 -24
- package/dist/node_modules/@dnd-kit/dom/sortable.js +5 -5
- package/package.json +8 -3
- package/registry/components-registry.json +3899 -0
- package/registry/components-registry.schema.json +98 -0
package/dist/components/organisms/data-table/components/cells/data-table-draggable-header-cell.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Header } from '@tanstack/react-table';
|
|
2
|
+
interface DataTableDraggableHeaderCellProps<TData, TValue> {
|
|
3
|
+
header: Header<TData, TValue>;
|
|
4
|
+
index: number;
|
|
5
|
+
enableColumnResizing: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function DataTableDraggableHeaderCell<TData, TValue>({ header, index, enableColumnResizing, }: DataTableDraggableHeaderCellProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
package/dist/components/organisms/data-table/components/cells/data-table-draggable-header-cell.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { j as t } from "../../../../../_virtual/jsx-runtime.js";
|
|
2
|
+
import { flexRender as m } from "../../../../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
3
|
+
import { useSortable as c } from "../../../../../node_modules/@dnd-kit/react/sortable.js";
|
|
4
|
+
import { TableHead as p } from "../../../../../vendor/shadcn/table.js";
|
|
5
|
+
import { cn as u } from "../../../../../lib/utils.js";
|
|
6
|
+
import { getCellStyles as d } from "../../utils/data-table-styles.js";
|
|
7
|
+
import { CELL_BACKGROUND_COLORS as f } from "../../utils/data-table-constants.js";
|
|
8
|
+
import { DataTableResizeHandle as g } from "./data-table-resize-handle.js";
|
|
9
|
+
function H({
|
|
10
|
+
header: e,
|
|
11
|
+
index: r,
|
|
12
|
+
enableColumnResizing: l
|
|
13
|
+
}) {
|
|
14
|
+
const { style: s, className: i } = d(
|
|
15
|
+
e.column,
|
|
16
|
+
l,
|
|
17
|
+
f.header
|
|
18
|
+
), { ref: n, isDragging: o } = c({
|
|
19
|
+
id: e.column.id,
|
|
20
|
+
index: r,
|
|
21
|
+
group: "columns"
|
|
22
|
+
}), a = {
|
|
23
|
+
...s,
|
|
24
|
+
opacity: o ? 0.5 : 1,
|
|
25
|
+
zIndex: o ? 1 : void 0,
|
|
26
|
+
position: o ? "relative" : s?.position,
|
|
27
|
+
cursor: "grab"
|
|
28
|
+
};
|
|
29
|
+
return /* @__PURE__ */ t.jsxs(
|
|
30
|
+
p,
|
|
31
|
+
{
|
|
32
|
+
ref: n,
|
|
33
|
+
style: a,
|
|
34
|
+
className: u(i, o && "bg-muted/80"),
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ t.jsx("div", { className: "overflow-hidden text-ellipsis whitespace-nowrap", children: e.isPlaceholder ? null : m(e.column.columnDef.header, e.getContext()) }),
|
|
37
|
+
l && e.column.getCanResize() && /* @__PURE__ */ t.jsx(
|
|
38
|
+
g,
|
|
39
|
+
{
|
|
40
|
+
onMouseDown: e.getResizeHandler(),
|
|
41
|
+
onTouchStart: e.getResizeHandler()
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
e.id
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
H as DataTableDraggableHeaderCell
|
|
51
|
+
};
|
|
@@ -4,12 +4,7 @@ import { cn as f } from "../../../../../lib/utils.js";
|
|
|
4
4
|
import { TooltipProvider as c, Tooltip as i, TooltipTrigger as o, TooltipContent as m } from "../../../../../vendor/shadcn/tooltip.js";
|
|
5
5
|
import { Badge as g } from "../../../../atoms/badge/badge.js";
|
|
6
6
|
const N = u(
|
|
7
|
-
({
|
|
8
|
-
items: n,
|
|
9
|
-
maxLength: a = 7,
|
|
10
|
-
showRemainingCount: x = !0,
|
|
11
|
-
className: d
|
|
12
|
-
}, h) => {
|
|
7
|
+
({ items: n, maxLength: a = 7, showRemainingCount: x = !0, className: d }, h) => {
|
|
13
8
|
if (!n || n.length === 0) return null;
|
|
14
9
|
const s = n[0], l = n.slice(1), t = s.name.length > a && a > 0, p = t ? `${s.name.slice(0, a)}...` : s.name;
|
|
15
10
|
return /* @__PURE__ */ e.jsxs(
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import { Table } from '@tanstack/react-table';
|
|
2
|
-
/**
|
|
3
|
-
* Props for the DataTableHeader component
|
|
4
|
-
*/
|
|
5
2
|
interface DataTableHeaderProps<TData> {
|
|
6
|
-
/**
|
|
7
|
-
* TanStack Table instance
|
|
8
|
-
*/
|
|
9
3
|
table: Table<TData>;
|
|
10
|
-
/**
|
|
11
|
-
* Whether column resizing is enabled
|
|
12
|
-
*/
|
|
13
4
|
enableColumnResizing?: boolean;
|
|
5
|
+
enableColumnDragDrop?: boolean;
|
|
14
6
|
}
|
|
15
|
-
|
|
16
|
-
* Renders the table header with sortable and resizable columns
|
|
17
|
-
*/
|
|
18
|
-
export declare function DataTableHeader<TData>({ table, enableColumnResizing, }: DataTableHeaderProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function DataTableHeader<TData>({ table, enableColumnResizing, enableColumnDragDrop, }: DataTableHeaderProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
19
8
|
export {};
|
|
@@ -1,19 +1,37 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { j as a } from "../../../../_virtual/jsx-runtime.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { TableHeader as r, TableRow as m } from "../../../../vendor/shadcn/table.js";
|
|
4
|
+
import { DataTableHeaderCell as o } from "./cells/data-table-header-cell.js";
|
|
5
|
+
import { DataTableDraggableHeaderCell as d } from "./cells/data-table-draggable-header-cell.js";
|
|
6
|
+
function b({
|
|
5
7
|
table: l,
|
|
6
|
-
enableColumnResizing:
|
|
8
|
+
enableColumnResizing: i,
|
|
9
|
+
enableColumnDragDrop: t = !1
|
|
7
10
|
}) {
|
|
8
|
-
return /* @__PURE__ */
|
|
9
|
-
|
|
11
|
+
return t ? /* @__PURE__ */ a.jsx(r, { children: l.getHeaderGroups().map((s) => /* @__PURE__ */ a.jsx(m, { className: "bg-muted", children: s.headers.map((e, n) => e.column.id === "select" || e.column.id === "actions" || e.column.id === "_spacer" ? /* @__PURE__ */ a.jsx(
|
|
12
|
+
o,
|
|
10
13
|
{
|
|
11
|
-
header:
|
|
12
|
-
enableColumnResizing:
|
|
14
|
+
header: e,
|
|
15
|
+
enableColumnResizing: i ?? !1
|
|
13
16
|
},
|
|
14
|
-
|
|
15
|
-
)
|
|
17
|
+
e.id
|
|
18
|
+
) : /* @__PURE__ */ a.jsx(
|
|
19
|
+
d,
|
|
20
|
+
{
|
|
21
|
+
header: e,
|
|
22
|
+
index: n,
|
|
23
|
+
enableColumnResizing: i ?? !1
|
|
24
|
+
},
|
|
25
|
+
e.id
|
|
26
|
+
)) }, s.id)) }) : /* @__PURE__ */ a.jsx(r, { children: l.getHeaderGroups().map((s) => /* @__PURE__ */ a.jsx(m, { className: "bg-muted", children: s.headers.map((e) => /* @__PURE__ */ a.jsx(
|
|
27
|
+
o,
|
|
28
|
+
{
|
|
29
|
+
header: e,
|
|
30
|
+
enableColumnResizing: i ?? !1
|
|
31
|
+
},
|
|
32
|
+
e.id
|
|
33
|
+
)) }, s.id)) });
|
|
16
34
|
}
|
|
17
35
|
export {
|
|
18
|
-
|
|
36
|
+
b as DataTableHeader
|
|
19
37
|
};
|
package/dist/components/organisms/data-table/components/dialogs/data-table-manage-columns-dialog.js
CHANGED
|
@@ -15,9 +15,13 @@ function D({
|
|
|
15
15
|
}, o = l.filter((e) => c(e).toLowerCase().includes(a.toLowerCase())), u = () => {
|
|
16
16
|
l.forEach((e) => e.toggleVisibility(!0));
|
|
17
17
|
}, p = () => {
|
|
18
|
-
const e = l.filter(
|
|
18
|
+
const e = l.filter(
|
|
19
|
+
(i) => i.getIsVisible()
|
|
20
|
+
);
|
|
19
21
|
e.length <= 1 || e.slice(1).forEach((i) => i.toggleVisibility(!1));
|
|
20
|
-
}, f = l.every(
|
|
22
|
+
}, f = l.every(
|
|
23
|
+
(e) => e.getIsVisible()
|
|
24
|
+
), b = t <= 1;
|
|
21
25
|
return /* @__PURE__ */ s.jsx(
|
|
22
26
|
y,
|
|
23
27
|
{
|
|
@@ -110,42 +110,28 @@ export interface DataTableProps<TData, TValue> {
|
|
|
110
110
|
* Callback when table settings change (for syncing to backend)
|
|
111
111
|
*/
|
|
112
112
|
onUpdate?: (settings: import('./data-table.types').DataTableSettings) => void;
|
|
113
|
+
/**
|
|
114
|
+
* Whether to enable drag-and-drop column reordering.
|
|
115
|
+
* When enabled, column headers can be dragged to reorder.
|
|
116
|
+
* Order persists via persistKey (localStorage) and onUpdate callback.
|
|
117
|
+
* @default false
|
|
118
|
+
*/
|
|
119
|
+
enableColumnDragDrop?: boolean;
|
|
113
120
|
}
|
|
114
121
|
/**
|
|
115
122
|
* Advanced data table component built on TanStack Table.
|
|
116
|
-
* Features sorting, filtering, column resizing, row selection, and loading/empty states.
|
|
123
|
+
* Features sorting, filtering, column resizing, row selection, column drag-and-drop reordering, and loading/empty states.
|
|
117
124
|
* Supports column pinning, visibility control, and state persistence.
|
|
118
125
|
*
|
|
119
126
|
* @example
|
|
120
127
|
* ```tsx
|
|
121
|
-
* //
|
|
122
|
-
* <DataTable
|
|
123
|
-
* columns={[
|
|
124
|
-
* { accessorKey: 'name', header: 'Name' },
|
|
125
|
-
* { accessorKey: 'email', header: 'Email' }
|
|
126
|
-
* ]}
|
|
127
|
-
* data={users}
|
|
128
|
-
* checkboxSelection
|
|
129
|
-
* onRowSelectionChange={(rowSelectionState, selectedRows) => {
|
|
130
|
-
* console.log('Selected rows:', selectedRows);
|
|
131
|
-
* }}
|
|
132
|
-
* actions={{
|
|
133
|
-
* items: [{ label: 'Edit', onClick: (row) => editUser(row) }]
|
|
134
|
-
* }}
|
|
135
|
-
* />
|
|
136
|
-
*
|
|
137
|
-
* // Controlled selection
|
|
138
|
-
* const [rowSelection, setRowSelection] = useState({});
|
|
128
|
+
* // Column drag-and-drop reordering
|
|
139
129
|
* <DataTable
|
|
140
130
|
* columns={columns}
|
|
141
|
-
* data={
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* onRowSelectionChange={(newRowSelection, selectedRows) => {
|
|
145
|
-
* setRowSelection(newRowSelection);
|
|
146
|
-
* console.log('Selected rows:', selectedRows);
|
|
147
|
-
* }}
|
|
131
|
+
* data={data}
|
|
132
|
+
* enableColumnDragDrop
|
|
133
|
+
* persistKey="my-table"
|
|
148
134
|
* />
|
|
149
135
|
* ```
|
|
150
136
|
*/
|
|
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;
|
|
137
|
+
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, enableColumnDragDrop, }: DataTableProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,181 +1,210 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import * as
|
|
3
|
-
import { useReactTable as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
import { j as t } from "../../../_virtual/jsx-runtime.js";
|
|
2
|
+
import * as c from "react";
|
|
3
|
+
import { useReactTable as Y } from "../../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
4
|
+
import { DragDropProvider as Z } from "../../../node_modules/@dnd-kit/react/index.js";
|
|
5
|
+
import { move as V } from "../../../node_modules/@dnd-kit/helpers/dist/index.js";
|
|
6
|
+
import { Table as ee } from "../../../vendor/shadcn/table.js";
|
|
7
|
+
import { cn as S } from "../../../lib/utils.js";
|
|
8
|
+
import { DataTableLoading as oe } from "./components/states/data-table-loading.js";
|
|
9
|
+
import { DataTableHeader as te } from "./components/data-table-header.js";
|
|
10
|
+
import { DataTableBody as ne } from "./components/data-table-body.js";
|
|
11
|
+
import { useDataTableColumns as re } from "./hooks/use-data-table-columns.js";
|
|
12
|
+
import { useDataTableState as se } from "./hooks/use-data-table-state.js";
|
|
13
|
+
import { ROW_HEIGHT_DEFAULT as ie } from "./utils/data-table-constants.js";
|
|
14
|
+
import { getFilteredRowModel as le, getSortedRowModel as ae, getCoreRowModel as me } from "../../../node_modules/@tanstack/table-core/build/lib/index.js";
|
|
15
|
+
import { Empty as ce } from "../../molecules/empty/empty.js";
|
|
16
|
+
function Te({
|
|
17
|
+
columns: b,
|
|
18
|
+
data: l,
|
|
19
|
+
isLoading: T = !1,
|
|
20
|
+
empty: w,
|
|
21
|
+
checkboxSelection: h = !1,
|
|
22
|
+
rowSelection: u,
|
|
23
|
+
onRowSelectionChange: a,
|
|
24
|
+
enableSorting: E = !0,
|
|
25
|
+
manualSorting: R = !1,
|
|
26
|
+
sorting: F,
|
|
27
|
+
onSortingChange: M,
|
|
28
|
+
enableColumnFilters: O = !1,
|
|
29
|
+
enableColumnResizing: d = !0,
|
|
30
|
+
columnResizeMode: N = "onChange",
|
|
31
|
+
enableColumnPinning: k = !0,
|
|
32
|
+
onRowClick: A,
|
|
33
|
+
actions: g,
|
|
34
|
+
height: L,
|
|
35
|
+
rowHeight: x = ie,
|
|
36
|
+
className: P,
|
|
37
|
+
persistKey: B,
|
|
38
|
+
initialSettings: H,
|
|
39
|
+
onUpdate: I,
|
|
40
|
+
enableColumnDragDrop: p = !1
|
|
38
41
|
}) {
|
|
39
|
-
const
|
|
40
|
-
columns:
|
|
41
|
-
checkboxSelection:
|
|
42
|
-
actions:
|
|
42
|
+
const W = re({
|
|
43
|
+
columns: b,
|
|
44
|
+
checkboxSelection: h,
|
|
45
|
+
actions: g
|
|
43
46
|
}), {
|
|
44
|
-
sorting:
|
|
45
|
-
setSorting:
|
|
46
|
-
columnFilters:
|
|
47
|
-
setColumnFilters:
|
|
48
|
-
columnVisibility:
|
|
49
|
-
setColumnVisibility:
|
|
50
|
-
rowSelection:
|
|
51
|
-
setRowSelection:
|
|
52
|
-
columnPinning:
|
|
53
|
-
handleColumnPinningChange:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
47
|
+
sorting: j,
|
|
48
|
+
setSorting: y,
|
|
49
|
+
columnFilters: _,
|
|
50
|
+
setColumnFilters: $,
|
|
51
|
+
columnVisibility: z,
|
|
52
|
+
setColumnVisibility: G,
|
|
53
|
+
rowSelection: i,
|
|
54
|
+
setRowSelection: U,
|
|
55
|
+
columnPinning: q,
|
|
56
|
+
handleColumnPinningChange: J,
|
|
57
|
+
columnOrder: f,
|
|
58
|
+
setColumnOrder: m
|
|
59
|
+
} = se({
|
|
60
|
+
persistKey: B,
|
|
61
|
+
hasActions: !!g,
|
|
62
|
+
externalSorting: F,
|
|
63
|
+
onExternalSortingChange: M,
|
|
64
|
+
externalRowSelection: u,
|
|
65
|
+
initialSettings: H,
|
|
66
|
+
onUpdate: I,
|
|
67
|
+
enableColumnDragDrop: p
|
|
68
|
+
}), r = Y({
|
|
69
|
+
data: l,
|
|
70
|
+
columns: W,
|
|
71
|
+
getCoreRowModel: me(),
|
|
72
|
+
enableColumnResizing: d,
|
|
73
|
+
columnResizeMode: N,
|
|
74
|
+
enableColumnPinning: k,
|
|
69
75
|
defaultColumn: {
|
|
70
76
|
enableSorting: !1,
|
|
71
77
|
minSize: 50
|
|
72
78
|
},
|
|
73
|
-
...
|
|
74
|
-
onSortingChange: (
|
|
75
|
-
|
|
79
|
+
...E && {
|
|
80
|
+
onSortingChange: (e) => {
|
|
81
|
+
y(typeof e == "function" ? e(j) : e);
|
|
76
82
|
},
|
|
77
|
-
getSortedRowModel:
|
|
78
|
-
manualSorting:
|
|
83
|
+
getSortedRowModel: ae(),
|
|
84
|
+
manualSorting: R
|
|
79
85
|
},
|
|
80
|
-
...
|
|
81
|
-
onColumnFiltersChange:
|
|
82
|
-
getFilteredRowModel:
|
|
86
|
+
...O && {
|
|
87
|
+
onColumnFiltersChange: $,
|
|
88
|
+
getFilteredRowModel: le()
|
|
83
89
|
},
|
|
84
|
-
onColumnVisibilityChange:
|
|
85
|
-
onRowSelectionChange: (
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
+
onColumnVisibilityChange: G,
|
|
91
|
+
onRowSelectionChange: (e) => {
|
|
92
|
+
const o = typeof e == "function" ? e(i) : e;
|
|
93
|
+
if (U(o), a && u !== void 0) {
|
|
94
|
+
const s = Object.keys(o).filter((n) => o[n]).map((n) => l[parseInt(n)]).filter(Boolean);
|
|
95
|
+
a(o, s);
|
|
90
96
|
}
|
|
91
97
|
},
|
|
92
|
-
onColumnPinningChange:
|
|
98
|
+
onColumnPinningChange: J,
|
|
99
|
+
onColumnOrderChange: m,
|
|
93
100
|
state: {
|
|
94
|
-
sorting:
|
|
95
|
-
columnFilters:
|
|
96
|
-
columnVisibility:
|
|
97
|
-
rowSelection:
|
|
98
|
-
columnPinning:
|
|
101
|
+
sorting: j,
|
|
102
|
+
columnFilters: _,
|
|
103
|
+
columnVisibility: z,
|
|
104
|
+
rowSelection: i,
|
|
105
|
+
columnPinning: q,
|
|
106
|
+
columnOrder: f
|
|
99
107
|
}
|
|
100
108
|
});
|
|
101
|
-
|
|
102
|
-
if (
|
|
103
|
-
const
|
|
104
|
-
|
|
109
|
+
c.useEffect(() => {
|
|
110
|
+
if (a && u === void 0) {
|
|
111
|
+
const e = Object.keys(i).filter((o) => i[o]).map((o) => l[parseInt(o)]).filter(Boolean);
|
|
112
|
+
a(i, e);
|
|
105
113
|
}
|
|
106
|
-
}, [
|
|
107
|
-
|
|
108
|
-
|
|
114
|
+
}, [i, a, l, u]);
|
|
115
|
+
const v = c.useRef([]), K = c.useCallback(() => {
|
|
116
|
+
v.current = f.length > 0 ? [...f] : r.getAllLeafColumns().map((e) => e.id);
|
|
117
|
+
}, [f, r]), Q = c.useCallback(
|
|
118
|
+
(e) => {
|
|
119
|
+
m((o) => {
|
|
120
|
+
const s = o.length > 0 ? o : r.getAllLeafColumns().map((C) => C.id);
|
|
121
|
+
return V({ columns: s }, e).columns;
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
[r, m]
|
|
125
|
+
), X = c.useCallback(
|
|
126
|
+
(e) => {
|
|
127
|
+
e.operation.canceled && m(v.current);
|
|
128
|
+
},
|
|
129
|
+
[m]
|
|
130
|
+
);
|
|
131
|
+
if (T)
|
|
132
|
+
return /* @__PURE__ */ t.jsx(
|
|
133
|
+
oe,
|
|
109
134
|
{
|
|
110
|
-
columns:
|
|
111
|
-
checkboxSelection:
|
|
112
|
-
actions:
|
|
113
|
-
rowHeight:
|
|
135
|
+
columns: b,
|
|
136
|
+
checkboxSelection: h,
|
|
137
|
+
actions: g,
|
|
138
|
+
rowHeight: x
|
|
114
139
|
}
|
|
115
140
|
);
|
|
116
|
-
if (
|
|
117
|
-
const
|
|
118
|
-
title:
|
|
119
|
-
description:
|
|
120
|
-
media:
|
|
121
|
-
actions:
|
|
122
|
-
} =
|
|
123
|
-
return /* @__PURE__ */
|
|
124
|
-
|
|
141
|
+
if (l.length === 0) {
|
|
142
|
+
const e = w || {}, {
|
|
143
|
+
title: o = "No results",
|
|
144
|
+
description: s = "No data available",
|
|
145
|
+
media: n,
|
|
146
|
+
actions: C
|
|
147
|
+
} = e;
|
|
148
|
+
return /* @__PURE__ */ t.jsx(
|
|
149
|
+
ce,
|
|
125
150
|
{
|
|
126
|
-
media:
|
|
127
|
-
title:
|
|
128
|
-
description:
|
|
129
|
-
actions:
|
|
151
|
+
media: n,
|
|
152
|
+
title: o,
|
|
153
|
+
description: s,
|
|
154
|
+
actions: C
|
|
130
155
|
}
|
|
131
156
|
);
|
|
132
157
|
}
|
|
133
|
-
|
|
158
|
+
const D = /* @__PURE__ */ t.jsx("div", { className: S("yuno-data-table space-y-4", P), children: /* @__PURE__ */ t.jsx(
|
|
134
159
|
"div",
|
|
135
160
|
{
|
|
136
161
|
className: "rounded-md border overflow-x-auto",
|
|
137
|
-
style: { height:
|
|
138
|
-
children: /* @__PURE__ */
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
{
|
|
148
|
-
style: {
|
|
149
|
-
width: t ? `${i}px` : "auto",
|
|
150
|
-
minWidth: t ? `${i}px` : void 0,
|
|
151
|
-
maxWidth: t ? `${i}px` : void 0
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
o.id
|
|
155
|
-
);
|
|
156
|
-
}) }),
|
|
157
|
-
/* @__PURE__ */ e.jsx(
|
|
158
|
-
J,
|
|
159
|
-
{
|
|
160
|
-
table: f,
|
|
161
|
-
enableColumnResizing: a
|
|
162
|
-
}
|
|
163
|
-
),
|
|
164
|
-
/* @__PURE__ */ e.jsx(
|
|
165
|
-
K,
|
|
166
|
-
{
|
|
167
|
-
table: f,
|
|
168
|
-
enableColumnResizing: a,
|
|
169
|
-
onRowClick: F,
|
|
170
|
-
rowHeight: p
|
|
162
|
+
style: { height: L || "auto" },
|
|
163
|
+
children: /* @__PURE__ */ t.jsxs(ee, { className: S("table-fixed"), children: [
|
|
164
|
+
/* @__PURE__ */ t.jsx("colgroup", { children: r.getHeaderGroups()[0]?.headers.map((e) => {
|
|
165
|
+
const o = e.column.columnDef.enableResizing === !1, s = e.column.id === "_spacer", n = e.column.getSize();
|
|
166
|
+
return s ? /* @__PURE__ */ t.jsx("col", { style: { width: "auto" } }, e.id) : /* @__PURE__ */ t.jsx(
|
|
167
|
+
"col",
|
|
168
|
+
{
|
|
169
|
+
style: {
|
|
170
|
+
width: o ? `${n}px` : "auto",
|
|
171
|
+
minWidth: o ? `${n}px` : void 0,
|
|
172
|
+
maxWidth: o ? `${n}px` : void 0
|
|
171
173
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
},
|
|
175
|
+
e.id
|
|
176
|
+
);
|
|
177
|
+
}) }),
|
|
178
|
+
/* @__PURE__ */ t.jsx(
|
|
179
|
+
te,
|
|
180
|
+
{
|
|
181
|
+
table: r,
|
|
182
|
+
enableColumnResizing: d,
|
|
183
|
+
enableColumnDragDrop: p
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
/* @__PURE__ */ t.jsx(
|
|
187
|
+
ne,
|
|
188
|
+
{
|
|
189
|
+
table: r,
|
|
190
|
+
enableColumnResizing: d,
|
|
191
|
+
onRowClick: A,
|
|
192
|
+
rowHeight: x
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
] })
|
|
176
196
|
}
|
|
177
197
|
) });
|
|
198
|
+
return p ? /* @__PURE__ */ t.jsx(
|
|
199
|
+
Z,
|
|
200
|
+
{
|
|
201
|
+
onDragStart: K,
|
|
202
|
+
onDragOver: Q,
|
|
203
|
+
onDragEnd: X,
|
|
204
|
+
children: D
|
|
205
|
+
}
|
|
206
|
+
) : D;
|
|
178
207
|
}
|
|
179
208
|
export {
|
|
180
|
-
|
|
209
|
+
Te as DataTable
|
|
181
210
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnFiltersState, SortingState, VisibilityState, RowSelectionState, ColumnPinningState } from '@tanstack/react-table';
|
|
1
|
+
import { ColumnFiltersState, ColumnOrderState, SortingState, VisibilityState, RowSelectionState, ColumnPinningState } from '@tanstack/react-table';
|
|
2
2
|
import { DataTableSettings } from '../data-table.types';
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
interface UseDataTableStateProps {
|
|
@@ -9,8 +9,9 @@ interface UseDataTableStateProps {
|
|
|
9
9
|
externalRowSelection?: RowSelectionState;
|
|
10
10
|
initialSettings?: DataTableSettings;
|
|
11
11
|
onUpdate?: (settings: DataTableSettings) => void;
|
|
12
|
+
enableColumnDragDrop?: boolean;
|
|
12
13
|
}
|
|
13
|
-
export declare function useDataTableState({ persistKey, hasActions, externalSorting, onExternalSortingChange, externalRowSelection, initialSettings, onUpdate, }: UseDataTableStateProps): {
|
|
14
|
+
export declare function useDataTableState({ persistKey, hasActions, externalSorting, onExternalSortingChange, externalRowSelection, initialSettings, onUpdate, enableColumnDragDrop, }: UseDataTableStateProps): {
|
|
14
15
|
sorting: SortingState;
|
|
15
16
|
setSorting: (sorting: SortingState) => void;
|
|
16
17
|
columnFilters: ColumnFiltersState;
|
|
@@ -21,5 +22,7 @@ export declare function useDataTableState({ persistKey, hasActions, externalSort
|
|
|
21
22
|
setRowSelection: React.Dispatch<React.SetStateAction<RowSelectionState>>;
|
|
22
23
|
columnPinning: ColumnPinningState;
|
|
23
24
|
handleColumnPinningChange: (updater: React.SetStateAction<ColumnPinningState>) => void;
|
|
25
|
+
columnOrder: ColumnOrderState;
|
|
26
|
+
setColumnOrder: React.Dispatch<React.SetStateAction<ColumnOrderState>>;
|
|
24
27
|
};
|
|
25
28
|
export {};
|