@ackplus/react-tanstack-data-table 1.0.19-beta-0.6 → 1.0.19-beta-0.8
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/package.json +3 -11
- package/{index.js → src/index.d.ts} +3 -26
- package/src/index.js +31 -0
- package/src/lib/components/droupdown/menu-dropdown.d.ts +17 -0
- package/src/lib/components/droupdown/menu-dropdown.js +52 -0
- package/src/lib/components/filters/filter-value-input.d.ts +9 -0
- package/src/lib/components/filters/filter-value-input.js +58 -0
- package/src/lib/components/filters/index.d.ts +23 -0
- package/{lib → src/lib}/components/filters/index.js +6 -2
- package/src/lib/components/headers/draggable-header.d.ts +12 -0
- package/{lib → src/lib}/components/headers/draggable-header.js +35 -49
- package/{lib/components/headers/index.js → src/lib/components/headers/index.d.ts} +0 -3
- package/src/lib/components/headers/index.js +5 -0
- package/src/lib/components/headers/table-header.d.ts +10 -0
- package/src/lib/components/headers/table-header.js +48 -0
- package/src/lib/components/index.d.ts +7 -0
- package/src/lib/components/index.js +10 -0
- package/src/lib/components/pagination/data-table-pagination.d.ts +11 -0
- package/src/lib/components/pagination/data-table-pagination.js +25 -0
- package/src/lib/components/pagination/index.d.ts +1 -0
- package/src/lib/components/pagination/index.js +4 -0
- package/src/lib/components/rows/data-table-row.d.ts +13 -0
- package/src/lib/components/rows/data-table-row.js +31 -0
- package/src/lib/components/rows/empty-data-row.d.ts +6 -0
- package/src/lib/components/rows/empty-data-row.js +11 -0
- package/{lib/components/rows/index.js → src/lib/components/rows/index.d.ts} +0 -3
- package/src/lib/components/rows/index.js +6 -0
- package/src/lib/components/rows/loading-rows.d.ts +5 -0
- package/src/lib/components/rows/loading-rows.js +49 -0
- package/src/lib/components/table/data-table.d.ts +3 -0
- package/src/lib/components/table/data-table.js +492 -0
- package/src/lib/components/table/data-table.types.d.ts +114 -0
- package/src/lib/components/table/data-table.types.js +2 -0
- package/{lib/components/table/index.js → src/lib/components/table/index.d.ts} +0 -3
- package/src/lib/components/table/index.js +5 -0
- package/src/lib/components/toolbar/bulk-actions-toolbar.d.ts +9 -0
- package/src/lib/components/toolbar/bulk-actions-toolbar.js +25 -0
- package/src/lib/components/toolbar/column-custom-filter-control.d.ts +1 -0
- package/src/lib/components/toolbar/column-custom-filter-control.js +137 -0
- package/src/lib/components/toolbar/column-pinning-control.d.ts +1 -0
- package/src/lib/components/toolbar/column-pinning-control.js +105 -0
- package/src/lib/components/toolbar/column-reset-control.d.ts +1 -0
- package/src/lib/components/toolbar/column-reset-control.js +16 -0
- package/src/lib/components/toolbar/column-visibility-control.d.ts +1 -0
- package/src/lib/components/toolbar/column-visibility-control.js +31 -0
- package/src/lib/components/toolbar/data-table-toolbar.d.ts +14 -0
- package/src/lib/components/toolbar/data-table-toolbar.js +26 -0
- package/{lib/components/toolbar/index.js → src/lib/components/toolbar/index.d.ts} +1 -6
- package/src/lib/components/toolbar/index.js +17 -0
- package/src/lib/components/toolbar/table-export-control.d.ts +25 -0
- package/src/lib/components/toolbar/table-export-control.js +93 -0
- package/src/lib/components/toolbar/table-search-control.d.ts +1 -0
- package/src/lib/components/toolbar/table-search-control.js +61 -0
- package/src/lib/components/toolbar/table-size-control.d.ts +1 -0
- package/src/lib/components/toolbar/table-size-control.js +36 -0
- package/src/lib/contexts/data-table-context.d.ts +43 -0
- package/{lib → src/lib}/contexts/data-table-context.js +12 -8
- package/src/lib/examples/advanced-features-example.d.ts +1 -0
- package/src/lib/examples/advanced-features-example.js +264 -0
- package/src/lib/examples/bulk-actions-test.d.ts +1 -0
- package/src/lib/examples/bulk-actions-test.js +44 -0
- package/src/lib/examples/custom-column-filter-example.d.ts +1 -0
- package/{lib → src/lib}/examples/custom-column-filter-example.js +10 -10
- package/src/lib/examples/index.js +13 -0
- package/src/lib/examples/selection-test-example.d.ts +1 -0
- package/src/lib/examples/selection-test-example.js +101 -0
- package/src/lib/examples/simple-local-example.d.ts +1 -0
- package/{lib → src/lib}/examples/simple-local-example.js +14 -18
- package/src/lib/features/custom-column-filter.feature.d.ts +45 -0
- package/{lib → src/lib}/features/custom-column-filter.feature.js +40 -99
- package/src/lib/features/custom-selection.feature.d.ts +46 -0
- package/{lib → src/lib}/features/custom-selection.feature.js +18 -70
- package/src/lib/features/index.d.ts +2 -0
- package/src/lib/features/index.js +8 -0
- package/src/lib/hooks/index.d.ts +1 -0
- package/src/lib/hooks/index.js +4 -0
- package/src/lib/hooks/use-data-table-api.d.ts +56 -0
- package/{lib → src/lib}/hooks/use-data-table-api.js +79 -136
- package/src/lib/icons/add-icon.d.ts +2 -0
- package/src/lib/icons/add-icon.js +8 -0
- package/src/lib/icons/csv-icon.d.ts +2 -0
- package/src/lib/icons/csv-icon.js +8 -0
- package/src/lib/icons/delete-icon.d.ts +2 -0
- package/src/lib/icons/delete-icon.js +8 -0
- package/src/lib/icons/excel-icon.d.ts +2 -0
- package/src/lib/icons/excel-icon.js +8 -0
- package/src/lib/icons/index.js +17 -0
- package/src/lib/icons/unpin-icon.d.ts +2 -0
- package/src/lib/icons/unpin-icon.js +8 -0
- package/src/lib/icons/view-comfortable-icon.d.ts +2 -0
- package/src/lib/icons/view-comfortable-icon.js +8 -0
- package/src/lib/icons/view-compact-icon.d.ts +2 -0
- package/src/lib/icons/view-compact-icon.js +8 -0
- package/src/lib/types/column.types.d.ts +29 -0
- package/src/lib/types/column.types.js +5 -0
- package/src/lib/types/data-table-api.d.ts +134 -0
- package/src/lib/types/data-table-api.js +2 -0
- package/src/lib/types/export.types.d.ts +99 -0
- package/src/lib/types/export.types.js +2 -0
- package/src/lib/types/index.d.ts +6 -0
- package/src/lib/types/index.js +8 -0
- package/src/lib/types/slots.types.d.ts +272 -0
- package/src/lib/types/slots.types.js +2 -0
- package/src/lib/types/table.types.d.ts +63 -0
- package/src/lib/types/table.types.js +2 -0
- package/src/lib/utils/column-helpers.d.ts +7 -0
- package/src/lib/utils/column-helpers.js +43 -0
- package/src/lib/utils/debounced-fetch.utils.d.ts +11 -0
- package/{lib → src/lib}/utils/debounced-fetch.utils.js +15 -17
- package/src/lib/utils/export-utils.d.ts +30 -0
- package/src/lib/utils/export-utils.js +152 -0
- package/{lib/utils/index.js → src/lib/utils/index.d.ts} +0 -10
- package/src/lib/utils/index.js +10 -0
- package/src/lib/utils/slot-helpers.d.ts +9 -0
- package/src/lib/utils/slot-helpers.js +21 -0
- package/src/lib/utils/special-columns.utils.d.ts +6 -0
- package/src/lib/utils/special-columns.utils.js +52 -0
- package/src/lib/utils/styling-helpers.d.ts +36 -0
- package/src/lib/utils/styling-helpers.js +61 -0
- package/src/lib/utils/table-helpers.d.ts +9 -0
- package/{lib → src/lib}/utils/table-helpers.js +16 -31
- package/tsconfig.tsbuildinfo +1 -0
- package/LICENSE +0 -21
- package/index.d.ts.map +0 -1
- package/lib/components/droupdown/menu-dropdown.d.ts.map +0 -1
- package/lib/components/droupdown/menu-dropdown.js +0 -47
- package/lib/components/export-progress-dialog.d.ts.map +0 -1
- package/lib/components/export-progress-dialog.js +0 -30
- package/lib/components/filters/filter-value-input.d.ts.map +0 -1
- package/lib/components/filters/filter-value-input.js +0 -64
- package/lib/components/filters/index.d.ts.map +0 -1
- package/lib/components/headers/draggable-header.d.ts.map +0 -1
- package/lib/components/headers/index.d.ts.map +0 -1
- package/lib/components/headers/table-header.d.ts.map +0 -1
- package/lib/components/headers/table-header.js +0 -59
- package/lib/components/index.d.ts.map +0 -1
- package/lib/components/index.js +0 -18
- package/lib/components/pagination/data-table-pagination.d.ts.map +0 -1
- package/lib/components/pagination/data-table-pagination.js +0 -24
- package/lib/components/pagination/index.d.ts.map +0 -1
- package/lib/components/pagination/index.js +0 -4
- package/lib/components/rows/data-table-row.d.ts.map +0 -1
- package/lib/components/rows/data-table-row.js +0 -42
- package/lib/components/rows/empty-data-row.d.ts.map +0 -1
- package/lib/components/rows/empty-data-row.js +0 -8
- package/lib/components/rows/index.d.ts.map +0 -1
- package/lib/components/rows/loading-rows.d.ts.map +0 -1
- package/lib/components/rows/loading-rows.js +0 -46
- package/lib/components/table/data-table.d.ts.map +0 -1
- package/lib/components/table/data-table.js +0 -663
- package/lib/components/table/data-table.types.d.ts.map +0 -1
- package/lib/components/table/data-table.types.js +0 -6
- package/lib/components/table/index.d.ts.map +0 -1
- package/lib/components/toolbar/bulk-actions-toolbar.d.ts.map +0 -1
- package/lib/components/toolbar/bulk-actions-toolbar.js +0 -31
- package/lib/components/toolbar/column-custom-filter-control.d.ts.map +0 -1
- package/lib/components/toolbar/column-custom-filter-control.js +0 -149
- package/lib/components/toolbar/column-custum-filter-control.d.ts.map +0 -1
- package/lib/components/toolbar/column-custum-filter-control.js +0 -150
- package/lib/components/toolbar/column-pinning-control.d.ts.map +0 -1
- package/lib/components/toolbar/column-pinning-control.js +0 -103
- package/lib/components/toolbar/column-reset-control.d.ts.map +0 -1
- package/lib/components/toolbar/column-reset-control.js +0 -13
- package/lib/components/toolbar/column-visibility-control.d.ts.map +0 -1
- package/lib/components/toolbar/column-visibility-control.js +0 -27
- package/lib/components/toolbar/data-table-toolbar.d.ts.map +0 -1
- package/lib/components/toolbar/data-table-toolbar.js +0 -23
- package/lib/components/toolbar/index.d.ts.map +0 -1
- package/lib/components/toolbar/table-export-control.d.ts.map +0 -1
- package/lib/components/toolbar/table-export-control.js +0 -94
- package/lib/components/toolbar/table-search-control.d.ts.map +0 -1
- package/lib/components/toolbar/table-search-control.js +0 -61
- package/lib/components/toolbar/table-size-control.d.ts.map +0 -1
- package/lib/components/toolbar/table-size-control.js +0 -33
- package/lib/contexts/data-table-context.d.ts.map +0 -1
- package/lib/examples/advanced-features-example.d.ts.map +0 -1
- package/lib/examples/advanced-features-example.js +0 -282
- package/lib/examples/basic-example.d.ts.map +0 -1
- package/lib/examples/basic-example.js +0 -323
- package/lib/examples/bulk-actions-test.d.ts.map +0 -1
- package/lib/examples/bulk-actions-test.js +0 -47
- package/lib/examples/crud-api-example.d.ts.map +0 -1
- package/lib/examples/crud-api-example.js +0 -321
- package/lib/examples/custom-column-filter-example.d.ts.map +0 -1
- package/lib/examples/custom-selection-example.d.ts.map +0 -1
- package/lib/examples/custom-selection-example.js +0 -184
- package/lib/examples/export-callbacks-example.d.ts.map +0 -1
- package/lib/examples/export-callbacks-example.js +0 -155
- package/lib/examples/improved-export-example.d.ts.map +0 -1
- package/lib/examples/improved-export-example.js +0 -153
- package/lib/examples/improved-server-selection-example.d.ts.map +0 -1
- package/lib/examples/improved-server-selection-example.js +0 -118
- package/lib/examples/index.d.ts.map +0 -1
- package/lib/examples/selection-test-example.d.ts.map +0 -1
- package/lib/examples/selection-test-example.js +0 -111
- package/lib/examples/simple-local-example.d.ts.map +0 -1
- package/lib/examples/simple-server-selection-example.d.ts.map +0 -1
- package/lib/examples/simple-server-selection-example.js +0 -178
- package/lib/examples/virtualized-example.d.ts.map +0 -1
- package/lib/examples/virtualized-example.js +0 -119
- package/lib/features/custom-column-filter.feature.d.ts.map +0 -1
- package/lib/features/custom-selection.feature.d.ts.map +0 -1
- package/lib/features/index.d.ts.map +0 -1
- package/lib/features/index.js +0 -9
- package/lib/hooks/index.d.ts.map +0 -1
- package/lib/hooks/index.js +0 -6
- package/lib/hooks/use-data-table-api.d.ts.map +0 -1
- package/lib/hooks/use-table-state.d.ts.map +0 -1
- package/lib/hooks/use-table-state.js +0 -74
- package/lib/icons/add-icon.d.ts.map +0 -1
- package/lib/icons/add-icon.js +0 -5
- package/lib/icons/csv-icon.d.ts.map +0 -1
- package/lib/icons/csv-icon.js +0 -5
- package/lib/icons/delete-icon.d.ts.map +0 -1
- package/lib/icons/delete-icon.js +0 -5
- package/lib/icons/excel-icon.d.ts.map +0 -1
- package/lib/icons/excel-icon.js +0 -5
- package/lib/icons/index.d.ts.map +0 -1
- package/lib/icons/unpin-icon.d.ts.map +0 -1
- package/lib/icons/unpin-icon.js +0 -5
- package/lib/icons/view-comfortable-icon.d.ts.map +0 -1
- package/lib/icons/view-comfortable-icon.js +0 -5
- package/lib/icons/view-compact-icon.d.ts.map +0 -1
- package/lib/icons/view-compact-icon.js +0 -5
- package/lib/types/column.types.d.ts.map +0 -1
- package/lib/types/column.types.js +0 -2
- package/lib/types/data-table-api.d.ts.map +0 -1
- package/lib/types/data-table-api.js +0 -1
- package/lib/types/export.types.d.ts.map +0 -1
- package/lib/types/export.types.js +0 -5
- package/lib/types/hooks.types.d.ts.map +0 -1
- package/lib/types/hooks.types.js +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/index.js +0 -14
- package/lib/types/slots.types.d.ts.map +0 -1
- package/lib/types/slots.types.js +0 -1
- package/lib/types/table.types.d.ts.map +0 -1
- package/lib/types/table.types.js +0 -1
- package/lib/utils/column-helpers.d.ts.map +0 -1
- package/lib/utils/column-helpers.js +0 -46
- package/lib/utils/debounced-fetch.utils.d.ts.map +0 -1
- package/lib/utils/export-utils.d.ts.map +0 -1
- package/lib/utils/export-utils.js +0 -181
- package/lib/utils/index.d.ts.map +0 -1
- package/lib/utils/selection-helpers.d.ts.map +0 -1
- package/lib/utils/selection-helpers.js +0 -162
- package/lib/utils/slot-helpers.d.ts.map +0 -1
- package/lib/utils/slot-helpers.js +0 -27
- package/lib/utils/special-columns.utils.d.ts.map +0 -1
- package/lib/utils/special-columns.utils.js +0 -77
- package/lib/utils/styling-helpers.d.ts.map +0 -1
- package/lib/utils/styling-helpers.js +0 -97
- package/lib/utils/table-helpers.d.ts.map +0 -1
- package/lib/utils/value-helpers.d.ts.map +0 -1
- package/lib/utils/value-helpers.js +0 -48
- package/tsconfig.lib.tsbuildinfo +0 -1
- /package/{lib/examples/index.js → src/lib/examples/index.d.ts} +0 -0
- /package/{lib/icons/index.js → src/lib/icons/index.d.ts} +0 -0
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Chip, MenuItem, FormControl, InputLabel, Select, } from '@mui/material';
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
import { DataTable } from '../components';
|
|
5
|
-
// Cell renderers (moved outside to avoid recreation on each render)
|
|
6
|
-
function StatusCell({ getValue }) {
|
|
7
|
-
return (_jsx(Chip, { label: getValue(), color: getValue() === 'active' ? 'success' : 'default', size: "small" }));
|
|
8
|
-
}
|
|
9
|
-
const DateCell = ({ getValue }) => (new Date(getValue()).toLocaleDateString());
|
|
10
|
-
function BooleanCell({ getValue }) {
|
|
11
|
-
return (_jsx(Chip, { label: getValue() ? 'Yes' : 'No', color: getValue() ? 'success' : 'default', size: "small" }));
|
|
12
|
-
}
|
|
13
|
-
// Custom filter component example for priority
|
|
14
|
-
function PriorityFilterComponent({ value, onChange }) {
|
|
15
|
-
return (_jsxs(FormControl, { size: "small", sx: { minWidth: 120 }, children: [_jsx(InputLabel, { children: "Priority" }), _jsxs(Select, { value: value, label: "Priority", onChange: (e) => onChange(e.target.value), children: [_jsx(MenuItem, { value: 1, children: "High (1)" }), _jsx(MenuItem, { value: 2, children: "Medium (2)" }), _jsx(MenuItem, { value: 3, children: "Low (3)" })] })] }));
|
|
16
|
-
}
|
|
17
|
-
// Example data
|
|
18
|
-
const sampleData = [
|
|
19
|
-
{
|
|
20
|
-
id: 1,
|
|
21
|
-
name: 'John Doe',
|
|
22
|
-
email: 'john@example.com',
|
|
23
|
-
role: {
|
|
24
|
-
id: 1,
|
|
25
|
-
name: 'Admin',
|
|
26
|
-
},
|
|
27
|
-
status: 'active',
|
|
28
|
-
createdAt: '2024-01-15',
|
|
29
|
-
isActive: true,
|
|
30
|
-
priority: 1,
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
id: 2,
|
|
34
|
-
name: 'Jane Smith',
|
|
35
|
-
email: 'jane@example.com',
|
|
36
|
-
role: {
|
|
37
|
-
id: 2,
|
|
38
|
-
name: 'User',
|
|
39
|
-
},
|
|
40
|
-
status: 'active',
|
|
41
|
-
createdAt: '2024-01-20',
|
|
42
|
-
isActive: true,
|
|
43
|
-
priority: 2,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: 3,
|
|
47
|
-
name: 'Bob Wilson',
|
|
48
|
-
email: 'bob@example.com',
|
|
49
|
-
role: {
|
|
50
|
-
id: 3,
|
|
51
|
-
name: 'Moderator',
|
|
52
|
-
},
|
|
53
|
-
status: 'inactive',
|
|
54
|
-
createdAt: '2024-02-01',
|
|
55
|
-
isActive: false,
|
|
56
|
-
priority: 3,
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
id: 4,
|
|
60
|
-
name: 'John Doe',
|
|
61
|
-
email: 'john@example.com',
|
|
62
|
-
role: {
|
|
63
|
-
id: 1,
|
|
64
|
-
name: 'Admin',
|
|
65
|
-
},
|
|
66
|
-
status: 'active',
|
|
67
|
-
createdAt: '2024-01-15',
|
|
68
|
-
isActive: true,
|
|
69
|
-
priority: 1,
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
id: 5,
|
|
73
|
-
name: 'John Doe',
|
|
74
|
-
email: 'john@example.com',
|
|
75
|
-
role: {
|
|
76
|
-
id: 1,
|
|
77
|
-
name: 'Admin',
|
|
78
|
-
},
|
|
79
|
-
status: 'active',
|
|
80
|
-
createdAt: '2024-01-15',
|
|
81
|
-
isActive: true,
|
|
82
|
-
priority: 1,
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: 6,
|
|
86
|
-
name: 'John Doe',
|
|
87
|
-
email: 'john@example.com',
|
|
88
|
-
role: {
|
|
89
|
-
id: 1,
|
|
90
|
-
name: 'Admin',
|
|
91
|
-
},
|
|
92
|
-
status: 'active',
|
|
93
|
-
createdAt: '2024-01-15',
|
|
94
|
-
isActive: true,
|
|
95
|
-
priority: 1,
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
id: 7,
|
|
99
|
-
name: 'John Doe',
|
|
100
|
-
email: 'john@example.com',
|
|
101
|
-
role: {
|
|
102
|
-
id: 1,
|
|
103
|
-
name: 'Admin',
|
|
104
|
-
},
|
|
105
|
-
status: 'active',
|
|
106
|
-
createdAt: '2024-01-15',
|
|
107
|
-
isActive: true,
|
|
108
|
-
priority: 1,
|
|
109
|
-
},
|
|
110
|
-
];
|
|
111
|
-
export function DataTableExample() {
|
|
112
|
-
const [selectedUsers, setSelectedUsers] = useState([]);
|
|
113
|
-
const [loading, setLoading] = useState(false);
|
|
114
|
-
/*
|
|
115
|
-
Enhanced Column Filtering Features:
|
|
116
|
-
|
|
117
|
-
1. Type-based Input Components:
|
|
118
|
-
- text: Regular text input
|
|
119
|
-
- number: Number input with validation
|
|
120
|
-
- date: Date picker
|
|
121
|
-
- boolean: Yes/No dropdown
|
|
122
|
-
- select: Dropdown with predefined options
|
|
123
|
-
|
|
124
|
-
2. Column Meta Configuration:
|
|
125
|
-
meta: {
|
|
126
|
-
type: 'text' | 'number' | 'date' | 'boolean' | 'select',
|
|
127
|
-
filterable: true/false,
|
|
128
|
-
options: [{ value: 'key', label: 'Display' }], // For select types
|
|
129
|
-
filterComponent: CustomComponent, // Custom filter component
|
|
130
|
-
enableColumnOrdering: false // Disable drag & drop for this column
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
3. Custom Filter Components:
|
|
134
|
-
- Receive props: { value, onChange, filter, column }
|
|
135
|
-
- Can implement API search, autocomplete, etc.
|
|
136
|
-
|
|
137
|
-
4. Filter Logic:
|
|
138
|
-
- Switch between AND/OR logic for multiple filters
|
|
139
|
-
|
|
140
|
-
5. Column Drag & Drop Control:
|
|
141
|
-
- Set enableColumnOrdering: false in column meta to disable dragging
|
|
142
|
-
- Columns without this setting (or set to true) can be dragged
|
|
143
|
-
- Drag handle (⋮⋮) only shows for draggable columns
|
|
144
|
-
- Visual indicators and smart UI
|
|
145
|
-
*/
|
|
146
|
-
// Define columns with proper typing and filtering metadata
|
|
147
|
-
const columns = [
|
|
148
|
-
{
|
|
149
|
-
id: 'name',
|
|
150
|
-
accessorKey: 'name',
|
|
151
|
-
header: 'Name',
|
|
152
|
-
enableSorting: true,
|
|
153
|
-
enableHiding: false,
|
|
154
|
-
meta: {
|
|
155
|
-
type: 'text',
|
|
156
|
-
filterable: true,
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
id: 'email',
|
|
161
|
-
accessorKey: 'email',
|
|
162
|
-
header: 'Email',
|
|
163
|
-
enableSorting: true,
|
|
164
|
-
meta: {
|
|
165
|
-
type: 'text',
|
|
166
|
-
filterable: true,
|
|
167
|
-
enableColumnOrdering: false, // Disable dragging for this column
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
id: 'role',
|
|
172
|
-
accessorKey: 'role.name',
|
|
173
|
-
header: 'Role',
|
|
174
|
-
enableSorting: true,
|
|
175
|
-
minSize: 400,
|
|
176
|
-
meta: {
|
|
177
|
-
type: 'select',
|
|
178
|
-
filterable: true,
|
|
179
|
-
options: [
|
|
180
|
-
{
|
|
181
|
-
value: 'Admin',
|
|
182
|
-
label: 'Administrator',
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
value: 'User',
|
|
186
|
-
label: 'Regular User',
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
value: 'Moderator',
|
|
190
|
-
label: 'Moderator',
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
id: 'status',
|
|
197
|
-
accessorKey: 'status',
|
|
198
|
-
header: 'Status',
|
|
199
|
-
cell: StatusCell,
|
|
200
|
-
enableSorting: true,
|
|
201
|
-
minSize: 400,
|
|
202
|
-
meta: {
|
|
203
|
-
type: 'select',
|
|
204
|
-
filterable: true,
|
|
205
|
-
options: [
|
|
206
|
-
{
|
|
207
|
-
value: 'active',
|
|
208
|
-
label: 'Active',
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
value: 'inactive',
|
|
212
|
-
label: 'Inactive',
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
enableColumnOrdering: false, // Disable dragging for this column
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
id: 'role_id',
|
|
220
|
-
accessorKey: 'role.id',
|
|
221
|
-
header: 'Is Active',
|
|
222
|
-
cell: BooleanCell,
|
|
223
|
-
enableSorting: false, // Disable sorting for this column to show difference
|
|
224
|
-
minSize: 200,
|
|
225
|
-
meta: {
|
|
226
|
-
type: 'boolean',
|
|
227
|
-
filterable: true,
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
id: 'isActive',
|
|
232
|
-
accessorKey: 'isActive',
|
|
233
|
-
header: 'Is Active',
|
|
234
|
-
cell: BooleanCell,
|
|
235
|
-
minSize: 200,
|
|
236
|
-
enableSorting: false, // Disable sorting for this column to show difference
|
|
237
|
-
meta: {
|
|
238
|
-
type: 'boolean',
|
|
239
|
-
filterable: true,
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
id: 'priority',
|
|
244
|
-
accessorKey: 'priority',
|
|
245
|
-
header: 'Priority',
|
|
246
|
-
enableSorting: true,
|
|
247
|
-
minSize: 200,
|
|
248
|
-
meta: {
|
|
249
|
-
type: 'number',
|
|
250
|
-
filterable: true,
|
|
251
|
-
filterComponent: PriorityFilterComponent,
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
id: 'createdAt',
|
|
256
|
-
accessorKey: 'createdAt',
|
|
257
|
-
header: 'Created At',
|
|
258
|
-
cell: DateCell,
|
|
259
|
-
enableSorting: true,
|
|
260
|
-
minSize: 400,
|
|
261
|
-
meta: {
|
|
262
|
-
type: 'date',
|
|
263
|
-
filterable: true,
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
];
|
|
267
|
-
const handleSelectionChange = (selected) => {
|
|
268
|
-
setSelectedUsers(selected);
|
|
269
|
-
};
|
|
270
|
-
const handleColumnFiltersChange = (filterState) => {
|
|
271
|
-
console.log('Column filters changed:', filterState);
|
|
272
|
-
// You can implement custom filtering logic here
|
|
273
|
-
// filterState.filters contains the active filters
|
|
274
|
-
// filterState.logic contains 'AND' or 'OR'
|
|
275
|
-
};
|
|
276
|
-
const handleSortingChange = (sorting) => {
|
|
277
|
-
console.log('Sorting changed:', sorting);
|
|
278
|
-
// You can implement server-side sorting here
|
|
279
|
-
// sorting is an array of { id: string, desc: boolean }
|
|
280
|
-
// For server-side: send sorting to your API
|
|
281
|
-
// For client-side: TanStack handles it automatically
|
|
282
|
-
};
|
|
283
|
-
const handleColumnOrderChange = (columnOrder) => {
|
|
284
|
-
console.log('Column order changed:', columnOrder);
|
|
285
|
-
// You can implement custom column ordering logic here
|
|
286
|
-
// columnOrder is an array of column ids in the new order
|
|
287
|
-
};
|
|
288
|
-
const handleColumnPinningChange = (pinning) => {
|
|
289
|
-
console.log('Column pinning changed:', pinning);
|
|
290
|
-
// You can implement custom column pinning logic here
|
|
291
|
-
// pinning contains { left: string[], right: string[] }
|
|
292
|
-
};
|
|
293
|
-
return (_jsxs("div", { style: { padding: '20px' }, children: [_jsx("h1", { children: "DataTable Example - Sticky Header & Footer" }), _jsx("p", { style: {
|
|
294
|
-
marginBottom: '20px',
|
|
295
|
-
color: '#666',
|
|
296
|
-
}, children: "This table has a fixed height with sticky header and footer. The table body scrolls independently while header and pagination remain visible." }), selectedUsers.length > 0 && (_jsxs("div", { style: { marginBottom: '16px' }, children: [_jsxs("h3", { children: ["Selected Users:", selectedUsers.length] }), selectedUsers.map(user => (_jsxs("div", { children: [user.name, ' ', "-", ' ', user.email] }, user.id)))] })), _jsx(DataTable, { data: sampleData, columns: columns, totalRow: sampleData.length, loading: loading, skeletonRows: 8, enableRowSelection: true, enableMultiRowSelection: true, onRowSelectionChange: handleSelectionChange, enableColumnResizing: true, columnResizeMode: "onChange", enablePagination: true, enableGlobalFilter: true, enableColumnFilters: true, enableSorting: true, onSortingChange: handleSortingChange, enableHover: true, enableStripes: true, enableColumnVisibility: true, enableExport: true, enableReset: true, selectMode: "page", onColumnFiltersChange: handleColumnFiltersChange, enableStickyHeaderOrFooter: true, draggable: true, enableColumnPinning: true, onColumnPinningChange: handleColumnPinningChange, onColumnDragEnd: handleColumnOrderChange, maxHeight: "300px", extraFilter: (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outlined", size: "small", onClick: () => setLoading(!loading), color: loading ? 'secondary' : 'primary', children: loading ? 'Stop Loading' : 'Show Loading' }), _jsx(Button, { variant: "outlined", size: "small", children: "Custom Filter" })] })), slotProps: {
|
|
297
|
-
pagination: {
|
|
298
|
-
rowsPerPageOptions: [5, 20, 50, 100],
|
|
299
|
-
},
|
|
300
|
-
} })] }));
|
|
301
|
-
}
|
|
302
|
-
// Example with expandable rows
|
|
303
|
-
export function DataTableExpandableExample() {
|
|
304
|
-
const expandableColumns = [
|
|
305
|
-
{
|
|
306
|
-
accessorKey: 'name',
|
|
307
|
-
header: 'Name',
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
accessorKey: 'email',
|
|
311
|
-
header: 'Email',
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
accessorKey: 'role',
|
|
315
|
-
header: 'Role',
|
|
316
|
-
},
|
|
317
|
-
];
|
|
318
|
-
const renderSubComponent = (row) => (_jsxs("div", { style: {
|
|
319
|
-
padding: '16px',
|
|
320
|
-
backgroundColor: '#f5f5f5',
|
|
321
|
-
}, children: [_jsx("h4", { children: "User Details" }), _jsxs("p", { children: [_jsx("strong", { children: "ID:" }), ' ', row.original.id] }), _jsxs("p", { children: [_jsx("strong", { children: "Status:" }), ' ', row.original.status] }), _jsxs("p", { children: [_jsx("strong", { children: "Created:" }), ' ', row.original.createdAt] })] }));
|
|
322
|
-
return (_jsxs("div", { style: { padding: '20px' }, children: [_jsx("h1", { children: "DataTable with Expandable Rows" }), _jsx(DataTable, { data: sampleData, enableRowSelection: true, columns: expandableColumns, totalRow: sampleData.length, enableExpanding: true, renderSubComponent: renderSubComponent, getRowCanExpand: () => true, enableColumnResizing: true, enableGlobalFilter: true })] }));
|
|
323
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bulk-actions-test.d.ts","sourceRoot":"","sources":["../../../src/lib/examples/bulk-actions-test.tsx"],"names":[],"mappings":"AAiCA,wBAAgB,eAAe,4CAyE9B"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useCallback } from 'react';
|
|
3
|
-
import { Box, Typography, Button } from '@mui/material';
|
|
4
|
-
import { DataTable } from '../components';
|
|
5
|
-
const testData = [
|
|
6
|
-
{ id: 1, name: 'Item 1', value: 100 },
|
|
7
|
-
{ id: 2, name: 'Item 2', value: 200 },
|
|
8
|
-
{ id: 3, name: 'Item 3', value: 300 },
|
|
9
|
-
{ id: 4, name: 'Item 4', value: 400 },
|
|
10
|
-
{ id: 5, name: 'Item 5', value: 500 },
|
|
11
|
-
];
|
|
12
|
-
const columns = [
|
|
13
|
-
{
|
|
14
|
-
accessorKey: 'name',
|
|
15
|
-
header: 'Name',
|
|
16
|
-
size: 150,
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
accessorKey: 'value',
|
|
20
|
-
header: 'Value',
|
|
21
|
-
size: 100,
|
|
22
|
-
},
|
|
23
|
-
];
|
|
24
|
-
export function BulkActionsTest() {
|
|
25
|
-
const [selectionInfo, setSelectionInfo] = useState('No selection');
|
|
26
|
-
const handleSelectionChange = (selection) => {
|
|
27
|
-
const count = selection.type === 'include'
|
|
28
|
-
? selection.ids.length
|
|
29
|
-
: testData.length - selection.ids.length;
|
|
30
|
-
setSelectionInfo(`Selected: ${count} items (${selection.type} mode) - IDs: [${selection.ids.join(', ')}]`);
|
|
31
|
-
};
|
|
32
|
-
const bulkActions = useCallback((selectionState) => {
|
|
33
|
-
const selectedCount = selectionState.type === 'include'
|
|
34
|
-
? selectionState.ids.length
|
|
35
|
-
: testData.length - selectionState.ids.length;
|
|
36
|
-
return (_jsx(Box, { sx: { display: 'flex', gap: 1 }, children: _jsxs(Button, { variant: "outlined", size: "small", onClick: () => {
|
|
37
|
-
alert(`Action on ${selectedCount} items. Selection state: ${JSON.stringify(selectionState, null, 2)}`);
|
|
38
|
-
}, children: ["Test Action (", selectedCount, ")"] }) }));
|
|
39
|
-
}, []);
|
|
40
|
-
return (_jsxs(Box, { sx: { p: 3 }, children: [_jsx(Typography, { variant: "h4", gutterBottom: true, children: "Bulk Actions Test" }), _jsx(Typography, { variant: "body1", color: "text.secondary", sx: { mb: 2 }, children: "This example tests that bulk actions work without infinite loops." }), _jsxs(Typography, { variant: "body2", sx: { mb: 3, p: 2, backgroundColor: 'grey.100', borderRadius: 1 }, children: [_jsx("strong", { children: "Current Selection:" }), " ", selectionInfo] }), _jsx(DataTable, { data: testData, totalRow: testData.length, columns: columns,
|
|
41
|
-
// Enable selection and bulk actions
|
|
42
|
-
enableRowSelection: true, enableMultiRowSelection: true, enableBulkActions: true, bulkActions: bulkActions, onSelectionChange: handleSelectionChange,
|
|
43
|
-
// Basic features
|
|
44
|
-
enablePagination: false, enableSorting: true, enableGlobalFilter: false,
|
|
45
|
-
// Fit to screen
|
|
46
|
-
fitToScreen: true }), _jsx(Box, { sx: { mt: 2, p: 2, backgroundColor: 'success.light', borderRadius: 1 }, children: _jsx(Typography, { variant: "body2", color: "success.dark", children: "\u2705 If you can see this and select rows without the page freezing, the infinite loop issue is fixed!" }) })] }));
|
|
47
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crud-api-example.d.ts","sourceRoot":"","sources":["../../../src/lib/examples/crud-api-example.tsx"],"names":[],"mappings":"AA2IA,wBAAgB,cAAc,4CAie7B"}
|