@ackplus/react-tanstack-data-table 1.0.19-beta-0.6

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.
Files changed (154) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +599 -0
  3. package/index.d.ts.map +1 -0
  4. package/index.js +42 -0
  5. package/lib/components/droupdown/menu-dropdown.d.ts.map +1 -0
  6. package/lib/components/droupdown/menu-dropdown.js +47 -0
  7. package/lib/components/export-progress-dialog.d.ts.map +1 -0
  8. package/lib/components/export-progress-dialog.js +30 -0
  9. package/lib/components/filters/filter-value-input.d.ts.map +1 -0
  10. package/lib/components/filters/filter-value-input.js +64 -0
  11. package/lib/components/filters/index.d.ts.map +1 -0
  12. package/lib/components/filters/index.js +125 -0
  13. package/lib/components/headers/draggable-header.d.ts.map +1 -0
  14. package/lib/components/headers/draggable-header.js +226 -0
  15. package/lib/components/headers/index.d.ts.map +1 -0
  16. package/lib/components/headers/index.js +5 -0
  17. package/lib/components/headers/table-header.d.ts.map +1 -0
  18. package/lib/components/headers/table-header.js +59 -0
  19. package/lib/components/index.d.ts.map +1 -0
  20. package/lib/components/index.js +18 -0
  21. package/lib/components/pagination/data-table-pagination.d.ts.map +1 -0
  22. package/lib/components/pagination/data-table-pagination.js +24 -0
  23. package/lib/components/pagination/index.d.ts.map +1 -0
  24. package/lib/components/pagination/index.js +4 -0
  25. package/lib/components/rows/data-table-row.d.ts.map +1 -0
  26. package/lib/components/rows/data-table-row.js +42 -0
  27. package/lib/components/rows/empty-data-row.d.ts.map +1 -0
  28. package/lib/components/rows/empty-data-row.js +8 -0
  29. package/lib/components/rows/index.d.ts.map +1 -0
  30. package/lib/components/rows/index.js +6 -0
  31. package/lib/components/rows/loading-rows.d.ts.map +1 -0
  32. package/lib/components/rows/loading-rows.js +46 -0
  33. package/lib/components/table/data-table.d.ts.map +1 -0
  34. package/lib/components/table/data-table.js +663 -0
  35. package/lib/components/table/data-table.types.d.ts.map +1 -0
  36. package/lib/components/table/data-table.types.js +6 -0
  37. package/lib/components/table/index.d.ts.map +1 -0
  38. package/lib/components/table/index.js +5 -0
  39. package/lib/components/toolbar/bulk-actions-toolbar.d.ts.map +1 -0
  40. package/lib/components/toolbar/bulk-actions-toolbar.js +31 -0
  41. package/lib/components/toolbar/column-custom-filter-control.d.ts.map +1 -0
  42. package/lib/components/toolbar/column-custom-filter-control.js +149 -0
  43. package/lib/components/toolbar/column-custum-filter-control.d.ts.map +1 -0
  44. package/lib/components/toolbar/column-custum-filter-control.js +150 -0
  45. package/lib/components/toolbar/column-pinning-control.d.ts.map +1 -0
  46. package/lib/components/toolbar/column-pinning-control.js +103 -0
  47. package/lib/components/toolbar/column-reset-control.d.ts.map +1 -0
  48. package/lib/components/toolbar/column-reset-control.js +13 -0
  49. package/lib/components/toolbar/column-visibility-control.d.ts.map +1 -0
  50. package/lib/components/toolbar/column-visibility-control.js +27 -0
  51. package/lib/components/toolbar/data-table-toolbar.d.ts.map +1 -0
  52. package/lib/components/toolbar/data-table-toolbar.js +23 -0
  53. package/lib/components/toolbar/index.d.ts.map +1 -0
  54. package/lib/components/toolbar/index.js +13 -0
  55. package/lib/components/toolbar/table-export-control.d.ts.map +1 -0
  56. package/lib/components/toolbar/table-export-control.js +94 -0
  57. package/lib/components/toolbar/table-search-control.d.ts.map +1 -0
  58. package/lib/components/toolbar/table-search-control.js +61 -0
  59. package/lib/components/toolbar/table-size-control.d.ts.map +1 -0
  60. package/lib/components/toolbar/table-size-control.js +33 -0
  61. package/lib/contexts/data-table-context.d.ts.map +1 -0
  62. package/lib/contexts/data-table-context.js +50 -0
  63. package/lib/examples/advanced-features-example.d.ts.map +1 -0
  64. package/lib/examples/advanced-features-example.js +282 -0
  65. package/lib/examples/basic-example.d.ts.map +1 -0
  66. package/lib/examples/basic-example.js +323 -0
  67. package/lib/examples/bulk-actions-test.d.ts.map +1 -0
  68. package/lib/examples/bulk-actions-test.js +47 -0
  69. package/lib/examples/crud-api-example.d.ts.map +1 -0
  70. package/lib/examples/crud-api-example.js +321 -0
  71. package/lib/examples/custom-column-filter-example.d.ts.map +1 -0
  72. package/lib/examples/custom-column-filter-example.js +60 -0
  73. package/lib/examples/custom-selection-example.d.ts.map +1 -0
  74. package/lib/examples/custom-selection-example.js +184 -0
  75. package/lib/examples/export-callbacks-example.d.ts.map +1 -0
  76. package/lib/examples/export-callbacks-example.js +155 -0
  77. package/lib/examples/improved-export-example.d.ts.map +1 -0
  78. package/lib/examples/improved-export-example.js +153 -0
  79. package/lib/examples/improved-server-selection-example.d.ts.map +1 -0
  80. package/lib/examples/improved-server-selection-example.js +118 -0
  81. package/lib/examples/index.d.ts.map +1 -0
  82. package/lib/examples/index.js +5 -0
  83. package/lib/examples/selection-test-example.d.ts.map +1 -0
  84. package/lib/examples/selection-test-example.js +111 -0
  85. package/lib/examples/simple-local-example.d.ts.map +1 -0
  86. package/lib/examples/simple-local-example.js +101 -0
  87. package/lib/examples/simple-server-selection-example.d.ts.map +1 -0
  88. package/lib/examples/simple-server-selection-example.js +178 -0
  89. package/lib/examples/virtualized-example.d.ts.map +1 -0
  90. package/lib/examples/virtualized-example.js +119 -0
  91. package/lib/features/custom-column-filter.feature.d.ts.map +1 -0
  92. package/lib/features/custom-column-filter.feature.js +306 -0
  93. package/lib/features/custom-selection.feature.d.ts.map +1 -0
  94. package/lib/features/custom-selection.feature.js +224 -0
  95. package/lib/features/index.d.ts.map +1 -0
  96. package/lib/features/index.js +9 -0
  97. package/lib/hooks/index.d.ts.map +1 -0
  98. package/lib/hooks/index.js +6 -0
  99. package/lib/hooks/use-data-table-api.d.ts.map +1 -0
  100. package/lib/hooks/use-data-table-api.js +673 -0
  101. package/lib/hooks/use-table-state.d.ts.map +1 -0
  102. package/lib/hooks/use-table-state.js +74 -0
  103. package/lib/icons/add-icon.d.ts.map +1 -0
  104. package/lib/icons/add-icon.js +5 -0
  105. package/lib/icons/csv-icon.d.ts.map +1 -0
  106. package/lib/icons/csv-icon.js +5 -0
  107. package/lib/icons/delete-icon.d.ts.map +1 -0
  108. package/lib/icons/delete-icon.js +5 -0
  109. package/lib/icons/excel-icon.d.ts.map +1 -0
  110. package/lib/icons/excel-icon.js +5 -0
  111. package/lib/icons/index.d.ts.map +1 -0
  112. package/lib/icons/index.js +7 -0
  113. package/lib/icons/unpin-icon.d.ts.map +1 -0
  114. package/lib/icons/unpin-icon.js +5 -0
  115. package/lib/icons/view-comfortable-icon.d.ts.map +1 -0
  116. package/lib/icons/view-comfortable-icon.js +5 -0
  117. package/lib/icons/view-compact-icon.d.ts.map +1 -0
  118. package/lib/icons/view-compact-icon.js +5 -0
  119. package/lib/types/column.types.d.ts.map +1 -0
  120. package/lib/types/column.types.js +2 -0
  121. package/lib/types/data-table-api.d.ts.map +1 -0
  122. package/lib/types/data-table-api.js +1 -0
  123. package/lib/types/export.types.d.ts.map +1 -0
  124. package/lib/types/export.types.js +5 -0
  125. package/lib/types/hooks.types.d.ts.map +1 -0
  126. package/lib/types/hooks.types.js +1 -0
  127. package/lib/types/index.d.ts.map +1 -0
  128. package/lib/types/index.js +14 -0
  129. package/lib/types/slots.types.d.ts.map +1 -0
  130. package/lib/types/slots.types.js +1 -0
  131. package/lib/types/table.types.d.ts.map +1 -0
  132. package/lib/types/table.types.js +1 -0
  133. package/lib/utils/column-helpers.d.ts.map +1 -0
  134. package/lib/utils/column-helpers.js +46 -0
  135. package/lib/utils/debounced-fetch.utils.d.ts.map +1 -0
  136. package/lib/utils/debounced-fetch.utils.js +51 -0
  137. package/lib/utils/export-utils.d.ts.map +1 -0
  138. package/lib/utils/export-utils.js +181 -0
  139. package/lib/utils/index.d.ts.map +1 -0
  140. package/lib/utils/index.js +17 -0
  141. package/lib/utils/selection-helpers.d.ts.map +1 -0
  142. package/lib/utils/selection-helpers.js +162 -0
  143. package/lib/utils/slot-helpers.d.ts.map +1 -0
  144. package/lib/utils/slot-helpers.js +27 -0
  145. package/lib/utils/special-columns.utils.d.ts.map +1 -0
  146. package/lib/utils/special-columns.utils.js +77 -0
  147. package/lib/utils/styling-helpers.d.ts.map +1 -0
  148. package/lib/utils/styling-helpers.js +97 -0
  149. package/lib/utils/table-helpers.d.ts.map +1 -0
  150. package/lib/utils/table-helpers.js +72 -0
  151. package/lib/utils/value-helpers.d.ts.map +1 -0
  152. package/lib/utils/value-helpers.js +48 -0
  153. package/package.json +57 -0
  154. package/tsconfig.lib.tsbuildinfo +1 -0
@@ -0,0 +1,323 @@
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
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulk-actions-test.d.ts","sourceRoot":"","sources":["../../../src/lib/examples/bulk-actions-test.tsx"],"names":[],"mappings":"AAiCA,wBAAgB,eAAe,4CAyE9B"}
@@ -0,0 +1,47 @@
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
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crud-api-example.d.ts","sourceRoot":"","sources":["../../../src/lib/examples/crud-api-example.tsx"],"names":[],"mappings":"AA2IA,wBAAgB,cAAc,4CAie7B"}