@ackplus/react-tanstack-data-table 1.0.19-beta-0.7 → 1.0.19-beta-0.9

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 (125) hide show
  1. package/README.md +599 -0
  2. package/package.json +3 -3
  3. package/src/index.d.ts +19 -0
  4. package/src/index.js +31 -0
  5. package/src/lib/components/droupdown/menu-dropdown.d.ts +17 -0
  6. package/src/lib/components/droupdown/menu-dropdown.js +52 -0
  7. package/src/lib/components/filters/filter-value-input.d.ts +9 -0
  8. package/src/lib/components/filters/filter-value-input.js +58 -0
  9. package/src/lib/components/filters/index.d.ts +23 -0
  10. package/src/lib/components/filters/index.js +129 -0
  11. package/src/lib/components/headers/draggable-header.d.ts +12 -0
  12. package/src/lib/components/headers/draggable-header.js +212 -0
  13. package/src/lib/components/headers/index.d.ts +2 -0
  14. package/src/lib/components/headers/index.js +5 -0
  15. package/src/lib/components/headers/table-header.d.ts +10 -0
  16. package/src/lib/components/headers/table-header.js +48 -0
  17. package/src/lib/components/index.d.ts +7 -0
  18. package/src/lib/components/index.js +10 -0
  19. package/src/lib/components/pagination/data-table-pagination.d.ts +11 -0
  20. package/src/lib/components/pagination/data-table-pagination.js +25 -0
  21. package/src/lib/components/pagination/index.d.ts +1 -0
  22. package/src/lib/components/pagination/index.js +4 -0
  23. package/src/lib/components/rows/data-table-row.d.ts +13 -0
  24. package/src/lib/components/rows/data-table-row.js +31 -0
  25. package/src/lib/components/rows/empty-data-row.d.ts +6 -0
  26. package/src/lib/components/rows/empty-data-row.js +11 -0
  27. package/src/lib/components/rows/index.d.ts +3 -0
  28. package/src/lib/components/rows/index.js +6 -0
  29. package/src/lib/components/rows/loading-rows.d.ts +5 -0
  30. package/src/lib/components/rows/loading-rows.js +49 -0
  31. package/src/lib/components/table/data-table.d.ts +3 -0
  32. package/src/lib/components/table/data-table.js +492 -0
  33. package/src/lib/components/table/data-table.types.d.ts +114 -0
  34. package/src/lib/components/table/data-table.types.js +2 -0
  35. package/src/lib/components/table/index.d.ts +2 -0
  36. package/src/lib/components/table/index.js +5 -0
  37. package/src/lib/components/toolbar/bulk-actions-toolbar.d.ts +9 -0
  38. package/src/lib/components/toolbar/bulk-actions-toolbar.js +25 -0
  39. package/src/lib/components/toolbar/column-custom-filter-control.d.ts +1 -0
  40. package/src/lib/components/toolbar/column-custom-filter-control.js +137 -0
  41. package/src/lib/components/toolbar/column-pinning-control.d.ts +1 -0
  42. package/src/lib/components/toolbar/column-pinning-control.js +105 -0
  43. package/src/lib/components/toolbar/column-reset-control.d.ts +1 -0
  44. package/src/lib/components/toolbar/column-reset-control.js +16 -0
  45. package/src/lib/components/toolbar/column-visibility-control.d.ts +1 -0
  46. package/src/lib/components/toolbar/column-visibility-control.js +31 -0
  47. package/src/lib/components/toolbar/data-table-toolbar.d.ts +14 -0
  48. package/src/lib/components/toolbar/data-table-toolbar.js +26 -0
  49. package/src/lib/components/toolbar/index.d.ts +8 -0
  50. package/src/lib/components/toolbar/index.js +17 -0
  51. package/src/lib/components/toolbar/table-export-control.d.ts +25 -0
  52. package/src/lib/components/toolbar/table-export-control.js +93 -0
  53. package/src/lib/components/toolbar/table-search-control.d.ts +1 -0
  54. package/src/lib/components/toolbar/table-search-control.js +61 -0
  55. package/src/lib/components/toolbar/table-size-control.d.ts +1 -0
  56. package/src/lib/components/toolbar/table-size-control.js +36 -0
  57. package/src/lib/contexts/data-table-context.d.ts +43 -0
  58. package/src/lib/contexts/data-table-context.js +54 -0
  59. package/src/lib/examples/advanced-features-example.d.ts +1 -0
  60. package/src/lib/examples/advanced-features-example.js +264 -0
  61. package/src/lib/examples/bulk-actions-test.d.ts +1 -0
  62. package/src/lib/examples/bulk-actions-test.js +44 -0
  63. package/src/lib/examples/custom-column-filter-example.d.ts +1 -0
  64. package/src/lib/examples/custom-column-filter-example.js +60 -0
  65. package/src/lib/examples/index.d.ts +5 -0
  66. package/src/lib/examples/index.js +13 -0
  67. package/src/lib/examples/selection-test-example.d.ts +1 -0
  68. package/src/lib/examples/selection-test-example.js +101 -0
  69. package/src/lib/examples/simple-local-example.d.ts +1 -0
  70. package/src/lib/examples/simple-local-example.js +97 -0
  71. package/src/lib/features/custom-column-filter.feature.d.ts +45 -0
  72. package/src/lib/features/custom-column-filter.feature.js +247 -0
  73. package/src/lib/features/custom-selection.feature.d.ts +46 -0
  74. package/src/lib/features/custom-selection.feature.js +172 -0
  75. package/src/lib/features/index.d.ts +2 -0
  76. package/src/lib/features/index.js +8 -0
  77. package/src/lib/hooks/index.d.ts +1 -0
  78. package/src/lib/hooks/index.js +4 -0
  79. package/src/lib/hooks/use-data-table-api.d.ts +56 -0
  80. package/src/lib/hooks/use-data-table-api.js +616 -0
  81. package/src/lib/icons/add-icon.d.ts +2 -0
  82. package/src/lib/icons/add-icon.js +8 -0
  83. package/src/lib/icons/csv-icon.d.ts +2 -0
  84. package/src/lib/icons/csv-icon.js +8 -0
  85. package/src/lib/icons/delete-icon.d.ts +2 -0
  86. package/src/lib/icons/delete-icon.js +8 -0
  87. package/src/lib/icons/excel-icon.d.ts +2 -0
  88. package/src/lib/icons/excel-icon.js +8 -0
  89. package/src/lib/icons/index.d.ts +7 -0
  90. package/src/lib/icons/index.js +17 -0
  91. package/src/lib/icons/unpin-icon.d.ts +2 -0
  92. package/src/lib/icons/unpin-icon.js +8 -0
  93. package/src/lib/icons/view-comfortable-icon.d.ts +2 -0
  94. package/src/lib/icons/view-comfortable-icon.js +8 -0
  95. package/src/lib/icons/view-compact-icon.d.ts +2 -0
  96. package/src/lib/icons/view-compact-icon.js +8 -0
  97. package/src/lib/types/column.types.d.ts +29 -0
  98. package/src/lib/types/column.types.js +5 -0
  99. package/src/lib/types/data-table-api.d.ts +134 -0
  100. package/src/lib/types/data-table-api.js +2 -0
  101. package/src/lib/types/export.types.d.ts +99 -0
  102. package/src/lib/types/export.types.js +2 -0
  103. package/src/lib/types/index.d.ts +6 -0
  104. package/src/lib/types/index.js +8 -0
  105. package/src/lib/types/slots.types.d.ts +272 -0
  106. package/src/lib/types/slots.types.js +2 -0
  107. package/src/lib/types/table.types.d.ts +63 -0
  108. package/src/lib/types/table.types.js +2 -0
  109. package/src/lib/utils/column-helpers.d.ts +7 -0
  110. package/src/lib/utils/column-helpers.js +43 -0
  111. package/src/lib/utils/debounced-fetch.utils.d.ts +11 -0
  112. package/src/lib/utils/debounced-fetch.utils.js +49 -0
  113. package/src/lib/utils/export-utils.d.ts +30 -0
  114. package/src/lib/utils/export-utils.js +152 -0
  115. package/src/lib/utils/index.d.ts +7 -0
  116. package/src/lib/utils/index.js +10 -0
  117. package/src/lib/utils/slot-helpers.d.ts +9 -0
  118. package/src/lib/utils/slot-helpers.js +21 -0
  119. package/src/lib/utils/special-columns.utils.d.ts +6 -0
  120. package/src/lib/utils/special-columns.utils.js +52 -0
  121. package/src/lib/utils/styling-helpers.d.ts +36 -0
  122. package/src/lib/utils/styling-helpers.js +61 -0
  123. package/src/lib/utils/table-helpers.d.ts +9 -0
  124. package/src/lib/utils/table-helpers.js +57 -0
  125. package/tsconfig.tsbuildinfo +1 -0
package/README.md ADDED
@@ -0,0 +1,599 @@
1
+ # @ackplus/react-tanstack-data-table
2
+
3
+ A powerful, feature-rich, and highly customizable React data table component built with Material-UI (MUI) and TanStack Table. Perfect for building modern data-intensive applications with advanced table functionality.
4
+
5
+ ## ✨ Features
6
+
7
+ - 🚀 **High Performance**: Built on TanStack Table for excellent performance with large datasets
8
+ - 🎨 **Material Design**: Beautiful UI components using MUI with consistent design system
9
+ - 📱 **Responsive**: Mobile-friendly responsive design with adaptive layouts
10
+ - 🔍 **Advanced Filtering**: Global search, column filters, and custom filter components
11
+ - 📊 **Multi-Column Sorting**: Powerful sorting with multiple columns support
12
+ - 📄 **Flexible Pagination**: Client-side and server-side pagination options
13
+ - 🎯 **Column Management**: Show/hide, resize, reorder, and pin columns
14
+ - 📤 **Data Export**: Export to CSV/Excel with progress tracking and customization
15
+ - 🖱️ **Row Selection**: Single and multi-row selection with bulk actions
16
+ - ⚡ **Virtualization**: Handle large datasets efficiently with row virtualization
17
+ - 🔄 **Server Integration**: Built-in support for server-side operations
18
+ - 🎛️ **Highly Customizable**: Extensive customization through slots and props
19
+ - 📝 **TypeScript**: Full TypeScript support with comprehensive type definitions
20
+ - 🔌 **Extensible**: Plugin architecture with custom components and hooks
21
+
22
+ ## 📦 Installation
23
+
24
+ ```bash
25
+ npm install @ackplus/react-tanstack-data-table
26
+ ```
27
+
28
+ ```bash
29
+ yarn add @ackplus/react-tanstack-data-table
30
+ ```
31
+
32
+ ```bash
33
+ pnpm add @ackplus/react-tanstack-data-table
34
+ ```
35
+
36
+ ## 🔧 Peer Dependencies
37
+
38
+ Make sure you have the following peer dependencies installed:
39
+
40
+ ```bash
41
+ npm install @emotion/react @emotion/styled @mui/icons-material @mui/material @tanstack/react-table @tanstack/react-virtual react react-dom
42
+ ```
43
+
44
+ ## 🚀 Quick Start
45
+
46
+ ```tsx
47
+ import React from 'react';
48
+ import { DataTable } from '@ackplus/react-tanstack-data-table';
49
+ import { createColumnHelper } from '@tanstack/react-table';
50
+
51
+ interface User {
52
+ id: number;
53
+ name: string;
54
+ email: string;
55
+ status: 'active' | 'inactive';
56
+ role: string;
57
+ }
58
+
59
+ const columnHelper = createColumnHelper<User>();
60
+
61
+ const columns = [
62
+ columnHelper.accessor('name', {
63
+ header: 'Name',
64
+ size: 150,
65
+ }),
66
+ columnHelper.accessor('email', {
67
+ header: 'Email',
68
+ size: 200,
69
+ }),
70
+ columnHelper.accessor('status', {
71
+ header: 'Status',
72
+ cell: ({ getValue }) => (
73
+ <Chip
74
+ label={getValue()}
75
+ color={getValue() === 'active' ? 'success' : 'default'}
76
+ />
77
+ ),
78
+ }),
79
+ columnHelper.accessor('role', {
80
+ header: 'Role',
81
+ size: 120,
82
+ }),
83
+ ];
84
+
85
+ const data: User[] = [
86
+ { id: 1, name: 'John Doe', email: 'john@example.com', status: 'active', role: 'Admin' },
87
+ { id: 2, name: 'Jane Smith', email: 'jane@example.com', status: 'inactive', role: 'User' },
88
+ // ... more data
89
+ ];
90
+
91
+ function MyDataTable() {
92
+ return (
93
+ <DataTable
94
+ columns={columns}
95
+ data={data}
96
+ enableSorting
97
+ enableGlobalFilter
98
+ enablePagination
99
+ enableRowSelection
100
+ enableColumnVisibility
101
+ enableExport
102
+ />
103
+ );
104
+ }
105
+ ```
106
+
107
+ ## 📋 Core Props
108
+
109
+ ### Basic Props
110
+
111
+ | Prop | Type | Default | Description |
112
+ |------|------|---------|-------------|
113
+ | `columns` | `DataTableColumn<T>[]` | **Required** | Column definitions array |
114
+ | `data` | `T[]` | `[]` | Array of data objects |
115
+ | `idKey` | `keyof T` | `'id'` | Unique identifier key for rows |
116
+ | `loading` | `boolean` | `false` | Loading state indicator |
117
+ | `emptyMessage` | `string` | `'No data available'` | Message when no data |
118
+
119
+ ### Data Management
120
+
121
+ | Prop | Type | Default | Description |
122
+ |------|------|---------|-------------|
123
+ | `dataMode` | `'client' \| 'server'` | `'client'` | Data management mode |
124
+ | `initialLoadData` | `boolean` | `true` | Load data on component mount |
125
+ | `onFetchData` | `(filters) => Promise<{data, total}>` | - | Server-side data fetching |
126
+ | `onDataStateChange` | `(state) => void` | - | Called when table state changes |
127
+ | `totalRow` | `number` | `0` | Total rows for server-side pagination |
128
+
129
+ ### Selection & Interaction
130
+
131
+ | Prop | Type | Default | Description |
132
+ |------|------|---------|-------------|
133
+ | `enableRowSelection` | `boolean \| ((row) => boolean)` | `false` | Enable row selection |
134
+ | `enableMultiRowSelection` | `boolean` | `true` | Allow multiple row selection |
135
+ | `onRowSelectionChange` | `(selectedRows: T[]) => void` | - | Selection change callback |
136
+ | `enableBulkActions` | `boolean` | `false` | Enable bulk actions toolbar |
137
+ | `bulkActions` | `(selectionState: SelectionState) => ReactNode` | - | Custom bulk actions component |
138
+
139
+ ### Selection State
140
+
141
+ The `SelectionState` interface provides detailed information about the current selection:
142
+
143
+ ```typescript
144
+ interface SelectionState {
145
+ ids: string[]; // Array of selected/excluded row IDs
146
+ type: 'include' | 'exclude'; // Selection mode
147
+ }
148
+ ```
149
+
150
+ - **Include mode**: `ids` contains the selected row IDs
151
+ - **Exclude mode**: `ids` contains the excluded row IDs (all others are selected)
152
+
153
+ This allows for efficient handling of large datasets where you might select "all except these few".
154
+
155
+ ### Pagination
156
+
157
+ | Prop | Type | Default | Description |
158
+ |------|------|---------|-------------|
159
+ | `enablePagination` | `boolean` | `true` | Enable pagination |
160
+ | `paginationMode` | `'client' \| 'server'` | `'client'` | Pagination mode |
161
+ | `initialState.pagination` | `{pageIndex: number, pageSize: number}` | `{pageIndex: 0, pageSize: 50}` | Initial pagination state |
162
+
163
+ ### Filtering & Search
164
+
165
+ | Prop | Type | Default | Description |
166
+ |------|------|---------|-------------|
167
+ | `enableGlobalFilter` | `boolean` | `true` | Enable global search |
168
+ | `enableColumnFilter` | `boolean` | `false` | Enable individual column filters |
169
+ | `filterMode` | `'client' \| 'server'` | `'client'` | Filtering mode |
170
+ | `onColumnFiltersChange` | `(filters) => void` | - | Column filters change callback |
171
+ | `extraFilter` | `ReactNode` | - | Additional filter components |
172
+
173
+ ### Sorting
174
+
175
+ | Prop | Type | Default | Description |
176
+ |------|------|---------|-------------|
177
+ | `enableSorting` | `boolean` | `true` | Enable column sorting |
178
+ | `sortingMode` | `'client' \| 'server'` | `'client'` | Sorting mode |
179
+ | `onSortingChange` | `(sorting) => void` | - | Sorting change callback |
180
+
181
+ ### Column Management
182
+
183
+ | Prop | Type | Default | Description |
184
+ |------|------|---------|-------------|
185
+ | `enableColumnVisibility` | `boolean` | `true` | Show/hide columns control |
186
+ | `enableColumnResizing` | `boolean` | `false` | Allow column resizing |
187
+ | `enableColumnPinning` | `boolean` | `false` | Allow column pinning |
188
+ | `draggable` | `boolean` | `false` | Enable column reordering |
189
+ | `onColumnDragEnd` | `(order: string[]) => void` | - | Column reorder callback |
190
+ | `onColumnPinningChange` | `(pinning) => void` | - | Column pinning callback |
191
+
192
+ ### Export Features
193
+
194
+ | Prop | Type | Default | Description |
195
+ |------|------|---------|-------------|
196
+ | `enableExport` | `boolean` | `true` | Enable data export |
197
+ | `exportFilename` | `string` | `'export'` | Default export filename |
198
+ | `onExportProgress` | `(progress) => void` | - | Export progress callback |
199
+ | `onExportComplete` | `(result) => void` | - | Export completion callback |
200
+ | `onExportError` | `(error) => void` | - | Export error callback |
201
+ | `onServerExport` | `(filters) => Promise<{data, total}>` | - | Server-side export handler |
202
+
203
+ ### Expandable Rows
204
+
205
+ | Prop | Type | Default | Description |
206
+ |------|------|---------|-------------|
207
+ | `enableExpanding` | `boolean` | `false` | Enable row expansion |
208
+ | `getRowCanExpand` | `(row) => boolean` | - | Determine if row can expand |
209
+ | `renderSubComponent` | `(row) => ReactNode` | - | Render expanded row content |
210
+
211
+ ### Styling & Layout
212
+
213
+ | Prop | Type | Default | Description |
214
+ |------|------|---------|-------------|
215
+ | `tableSize` | `'small' \| 'medium'` | `'medium'` | Table size/density |
216
+ | `enableHover` | `boolean` | `true` | Row hover effects |
217
+ | `enableStripes` | `boolean` | `false` | Alternating row colors |
218
+ | `fitToScreen` | `boolean` | `true` | Fit table to container width |
219
+ | `enableStickyHeaderOrFooter` | `boolean` | `false` | Sticky header/footer |
220
+ | `maxHeight` | `string \| number` | `'400px'` | Max table height |
221
+
222
+ ### Virtualization
223
+
224
+ | Prop | Type | Default | Description |
225
+ |------|------|---------|-------------|
226
+ | `enableVirtualization` | `boolean` | `false` | Enable row virtualization |
227
+ | `estimateRowHeight` | `number` | `52` | Estimated row height for virtualization |
228
+
229
+ ### Advanced Customization
230
+
231
+ | Prop | Type | Default | Description |
232
+ |------|------|---------|-------------|
233
+ | `slots` | `Partial<DataTableSlots<T>>` | `{}` | Custom component slots |
234
+ | `slotProps` | `PartialSlotProps<T>` | `{}` | Props for slot components |
235
+ | `tableContainerProps` | `object` | `{}` | Props for table container |
236
+ | `tableProps` | `object` | `{}` | Props for table element |
237
+
238
+ ## 🔥 Advanced Examples
239
+
240
+ ### Server-Side Data Management
241
+
242
+ ```tsx
243
+ import { DataTable } from '@ackplus/react-tanstack-data-table';
244
+ import { useState, useCallback } from 'react';
245
+
246
+ function ServerSideTable() {
247
+ const [loading, setLoading] = useState(false);
248
+
249
+ const fetchData = useCallback(async (filters) => {
250
+ setLoading(true);
251
+ try {
252
+ const response = await fetch('/api/users', {
253
+ method: 'POST',
254
+ headers: { 'Content-Type': 'application/json' },
255
+ body: JSON.stringify(filters),
256
+ });
257
+ const result = await response.json();
258
+ return { data: result.users, total: result.total };
259
+ } finally {
260
+ setLoading(false);
261
+ }
262
+ }, []);
263
+
264
+ return (
265
+ <DataTable
266
+ columns={columns}
267
+ dataMode="server"
268
+ loading={loading}
269
+ onFetchData={fetchData}
270
+ enablePagination
271
+ enableSorting
272
+ enableGlobalFilter
273
+ paginationMode="server"
274
+ sortingMode="server"
275
+ filterMode="server"
276
+ />
277
+ );
278
+ }
279
+ ```
280
+
281
+ ### Row Selection with Bulk Actions
282
+
283
+ ```tsx
284
+ function SelectableTable() {
285
+ const [selectedUsers, setSelectedUsers] = useState([]);
286
+
287
+ const bulkActions = (selectionState) => {
288
+ // Calculate selected count based on selection type
289
+ const selectedCount = selectionState.type === 'include'
290
+ ? selectionState.ids.length
291
+ : data.length - selectionState.ids.length;
292
+
293
+ // Get actual selected data
294
+ const selectedRows = selectionState.type === 'include'
295
+ ? data.filter(item => selectionState.ids.includes(item.id.toString()))
296
+ : data.filter(item => !selectionState.ids.includes(item.id.toString()));
297
+
298
+ return (
299
+ <Stack direction="row" spacing={1}>
300
+ <Button
301
+ variant="contained"
302
+ color="error"
303
+ onClick={() => deleteUsers(selectedRows)}
304
+ >
305
+ Delete ({selectedCount})
306
+ </Button>
307
+ <Button
308
+ variant="outlined"
309
+ onClick={() => exportUsers(selectedRows)}
310
+ >
311
+ Export Selected
312
+ </Button>
313
+ </Stack>
314
+ );
315
+ };
316
+
317
+ return (
318
+ <DataTable
319
+ columns={columns}
320
+ data={data}
321
+ enableRowSelection
322
+ enableMultiRowSelection
323
+ enableBulkActions
324
+ bulkActions={bulkActions}
325
+ onRowSelectionChange={setSelectedUsers}
326
+ />
327
+ );
328
+ }
329
+ ```
330
+
331
+ ### Custom Column Filters
332
+
333
+ ```tsx
334
+ const columns = [
335
+ {
336
+ accessorKey: 'status',
337
+ header: 'Status',
338
+ filterable: true,
339
+ type: 'select',
340
+ options: [
341
+ { value: 'active', label: 'Active' },
342
+ { value: 'inactive', label: 'Inactive' },
343
+ { value: 'pending', label: 'Pending' },
344
+ ],
345
+ },
346
+ {
347
+ accessorKey: 'priority',
348
+ header: 'Priority',
349
+ filterable: true,
350
+ type: 'number',
351
+ },
352
+ {
353
+ accessorKey: 'created',
354
+ header: 'Created Date',
355
+ filterable: true,
356
+ type: 'date',
357
+ },
358
+ ];
359
+
360
+ function FilterableTable() {
361
+ return (
362
+ <DataTable
363
+ columns={columns}
364
+ data={data}
365
+ enableColumnFilter
366
+ enableGlobalFilter
367
+ />
368
+ );
369
+ }
370
+ ```
371
+
372
+ ### Expandable Rows
373
+
374
+ ```tsx
375
+ function ExpandableTable() {
376
+ const renderSubComponent = (row) => (
377
+ <Box p={2}>
378
+ <Typography variant="h6">User Details</Typography>
379
+ <Grid container spacing={2}>
380
+ <Grid item xs={6}>
381
+ <Typography><strong>ID:</strong> {row.original.id}</Typography>
382
+ <Typography><strong>Email:</strong> {row.original.email}</Typography>
383
+ </Grid>
384
+ <Grid item xs={6}>
385
+ <Typography><strong>Role:</strong> {row.original.role}</Typography>
386
+ <Typography><strong>Status:</strong> {row.original.status}</Typography>
387
+ </Grid>
388
+ </Grid>
389
+ </Box>
390
+ );
391
+
392
+ return (
393
+ <DataTable
394
+ columns={columns}
395
+ data={data}
396
+ enableExpanding
397
+ getRowCanExpand={(row) => row.original.details != null}
398
+ renderSubComponent={renderSubComponent}
399
+ />
400
+ );
401
+ }
402
+ ```
403
+
404
+ ### Column Management
405
+
406
+ ```tsx
407
+ function ManageableColumnsTable() {
408
+ const [columnOrder, setColumnOrder] = useState([]);
409
+ const [columnPinning, setColumnPinning] = useState({ left: [], right: [] });
410
+
411
+ return (
412
+ <DataTable
413
+ columns={columns}
414
+ data={data}
415
+ enableColumnVisibility
416
+ enableColumnResizing
417
+ enableColumnPinning
418
+ draggable
419
+ onColumnDragEnd={setColumnOrder}
420
+ onColumnPinningChange={setColumnPinning}
421
+ initialState={{
422
+ columnOrder,
423
+ columnPinning,
424
+ }}
425
+ />
426
+ );
427
+ }
428
+ ```
429
+
430
+ ### Export with Progress Tracking
431
+
432
+ ```tsx
433
+ function ExportableTable() {
434
+ const [exportProgress, setExportProgress] = useState(null);
435
+
436
+ const handleExportProgress = (progress) => {
437
+ setExportProgress(progress);
438
+ };
439
+
440
+ const handleExportComplete = (result) => {
441
+ setExportProgress(null);
442
+ };
443
+
444
+ return (
445
+ <DataTable
446
+ columns={columns}
447
+ data={data}
448
+ enableExport
449
+ exportFilename="users-export"
450
+ onExportProgress={handleExportProgress}
451
+ onExportComplete={handleExportComplete}
452
+ onExportError={(error) => console.error('Export failed:', error)}
453
+ />
454
+ );
455
+ }
456
+ ```
457
+
458
+ ## 🎛️ API Reference
459
+
460
+ ### DataTable Component
461
+
462
+ The main component that renders the data table with all features.
463
+
464
+ ```tsx
465
+ <DataTable<T>
466
+ columns={DataTableColumn<T>[]}
467
+ data={T[]}
468
+ // ... other props
469
+ />
470
+ ```
471
+
472
+ ### Column Definition
473
+
474
+ Columns are defined using TanStack Table's column definition format with additional properties:
475
+
476
+ ```tsx
477
+ interface DataTableColumn<T> extends ColumnDef<T> {
478
+ // Display properties
479
+ align?: 'left' | 'center' | 'right';
480
+ // Filtering
481
+ filterable?: boolean;
482
+ type?: 'boolean' | 'number' | 'date' | 'select' | 'text';
483
+ options?: { label: string; value: string }[];
484
+
485
+ // Export
486
+ hideInExport?: boolean;
487
+ }
488
+ ```
489
+
490
+ ### useDataTableApi Hook
491
+
492
+ Access the table's imperative API:
493
+
494
+ ```tsx
495
+ import { useRef } from 'react';
496
+ import { DataTable, DataTableApi } from '@ackplus/react-tanstack-data-table';
497
+
498
+ function MyComponent() {
499
+ const tableRef = useRef<DataTableApi<User>>(null);
500
+
501
+ const handleGetData = () => {
502
+ const allData = tableRef.current?.data.getAllData();
503
+ };
504
+
505
+ return (
506
+ <DataTable
507
+ ref={tableRef}
508
+ columns={columns}
509
+ data={data}
510
+ />
511
+ );
512
+ }
513
+ ```
514
+
515
+ ## 🎨 Customization
516
+
517
+ ### Slots System
518
+
519
+ Customize any part of the table using the slots system:
520
+
521
+ ```tsx
522
+ const customSlots = {
523
+ toolbar: MyCustomToolbar,
524
+ pagination: MyCustomPagination,
525
+ loadingRow: MyCustomLoadingRow,
526
+ emptyRow: MyCustomEmptyRow,
527
+ };
528
+
529
+ <DataTable
530
+ columns={columns}
531
+ data={data}
532
+ slots={customSlots}
533
+ slotProps={{
534
+ toolbar: { customProp: 'value' },
535
+ pagination: { showFirstLastButtons: true },
536
+ }}
537
+ />
538
+ ```
539
+
540
+ ### Available Slots
541
+
542
+ - `root` - Root container
543
+ - `toolbar` - Main toolbar
544
+ - `bulkActionsToolbar` - Bulk actions toolbar
545
+ - `tableContainer` - Table container
546
+ - `table` - Table element
547
+ - `header` - Table header
548
+ - `body` - Table body
549
+ - `row` - Table row
550
+ - `cell` - Table cell
551
+ - `footer` - Table footer
552
+ - `pagination` - Pagination component
553
+ - `loadingRow` - Loading state row
554
+ - `emptyRow` - Empty state row
555
+
556
+ ## 🔧 Migration Guide
557
+
558
+ ### From v0.x to v1.x
559
+
560
+ Key changes in v1.0:
561
+ - Updated to latest TanStack Table v8
562
+ - Improved TypeScript support
563
+ - Enhanced slot system
564
+ - Better server-side integration
565
+
566
+ ## 🤝 Contributing
567
+
568
+ We welcome contributions! Please see our [Contributing Guide](https://github.com/ack-solutions/react-tanstack-data-table/blob/main/CONTRIBUTING.md) for details.
569
+
570
+ ## 💖 Support the Project
571
+
572
+ If you find this package helpful and want to support its development, consider making a donation:
573
+
574
+ <div align="center">
575
+
576
+ [![PayPal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](https://www.paypal.com/paypalme/my/profile)
577
+ [![Razorpay](https://img.shields.io/badge/Razorpay-02042B?style=for-the-badge&logo=razorpay&logoColor=white)](https://razorpay.me/@ackplus)
578
+
579
+ **[💳 PayPal](https://www.paypal.com/paypalme/my/profile)** • **[💳 Razorpay](https://razorpay.me/@ackplus)**
580
+
581
+ </div>
582
+
583
+ Your support helps us:
584
+ - 🛠️ Maintain and improve the library
585
+ - 🐛 Fix bugs and add new features
586
+ - 📚 Create better documentation
587
+ - 🚀 Keep the project active and up-to-date
588
+
589
+ ## 📄 License
590
+
591
+ MIT © [ACK Solutions](https://github.com/ack-solutions)
592
+
593
+ ## 🆘 Support
594
+
595
+ - 📖 [Documentation](https://github.com/ack-solutions/react-tanstack-data-table)
596
+ - 🐛 [Issue Tracker](https://github.com/ack-solutions/react-tanstack-data-table/issues)
597
+ - 💬 [Discussions](https://github.com/ack-solutions/react-tanstack-data-table/discussions)
598
+
599
+ If you find this package helpful, please consider giving it a ⭐ on [GitHub](https://github.com/ack-solutions/react-tanstack-data-table)!
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ackplus/react-tanstack-data-table",
3
3
  "type": "commonjs",
4
- "version": "1.0.19-beta-0.7",
4
+ "version": "1.0.19-beta-0.9",
5
5
  "description": "A powerful React data table component built with MUI and TanStack Table",
6
6
  "keywords": [
7
7
  "react",
@@ -26,8 +26,8 @@
26
26
  "bugs": {
27
27
  "url": "https://github.com/ack-solutions/react-tanstack-data-table/issues"
28
28
  },
29
- "main": "./index.js",
30
- "types": "./index.d.ts",
29
+ "main": "./src/index.js",
30
+ "types": "./src/index.d.ts",
31
31
  "peerDependencies": {
32
32
  "@emotion/react": ">=11.0.0",
33
33
  "@emotion/styled": ">=11.0.0",
package/src/index.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ export { DataTable } from './lib/components/table';
2
+ export type { DataTableProps } from './lib/components/table';
3
+ export * from './lib/components/headers';
4
+ export * from './lib/components/rows';
5
+ export * from './lib/components/filters';
6
+ export * from './lib/components/pagination';
7
+ export * from './lib/components/droupdown/menu-dropdown';
8
+ export { ColumnVisibilityControl, ColumnPinningControl, ColumnResetControl, TableExportControl, TableSizeControl, BulkActionsToolbar, DataTableToolbar, } from './lib/components/toolbar';
9
+ export type { BulkActionsToolbarProps } from './lib/components/toolbar';
10
+ export * from './lib/utils/styling-helpers';
11
+ export * from './lib/utils/column-helpers';
12
+ export * from './lib/utils/table-helpers';
13
+ export * from './lib/hooks';
14
+ export * from './lib/types';
15
+ export type { Column, ColumnDef, Row, Table, Header, Cell, SortingState, ColumnFiltersState, VisibilityState, ColumnOrderState, ColumnPinningState, PaginationState, } from '@tanstack/react-table';
16
+ export * from './lib/features';
17
+ export { CustomColumnFilterExample } from './lib/examples/custom-column-filter-example';
18
+ export { SimpleLocalExample } from './lib/examples/simple-local-example';
19
+ export { AdvancedFeaturesExample } from './lib/examples/advanced-features-example';
package/src/index.js ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdvancedFeaturesExample = exports.SimpleLocalExample = exports.CustomColumnFilterExample = exports.DataTableToolbar = exports.BulkActionsToolbar = exports.TableSizeControl = exports.TableExportControl = exports.ColumnResetControl = exports.ColumnPinningControl = exports.ColumnVisibilityControl = exports.DataTable = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var table_1 = require("./lib/components/table");
6
+ Object.defineProperty(exports, "DataTable", { enumerable: true, get: function () { return table_1.DataTable; } });
7
+ tslib_1.__exportStar(require("./lib/components/headers"), exports);
8
+ tslib_1.__exportStar(require("./lib/components/rows"), exports);
9
+ tslib_1.__exportStar(require("./lib/components/filters"), exports);
10
+ tslib_1.__exportStar(require("./lib/components/pagination"), exports);
11
+ tslib_1.__exportStar(require("./lib/components/droupdown/menu-dropdown"), exports);
12
+ var toolbar_1 = require("./lib/components/toolbar");
13
+ Object.defineProperty(exports, "ColumnVisibilityControl", { enumerable: true, get: function () { return toolbar_1.ColumnVisibilityControl; } });
14
+ Object.defineProperty(exports, "ColumnPinningControl", { enumerable: true, get: function () { return toolbar_1.ColumnPinningControl; } });
15
+ Object.defineProperty(exports, "ColumnResetControl", { enumerable: true, get: function () { return toolbar_1.ColumnResetControl; } });
16
+ Object.defineProperty(exports, "TableExportControl", { enumerable: true, get: function () { return toolbar_1.TableExportControl; } });
17
+ Object.defineProperty(exports, "TableSizeControl", { enumerable: true, get: function () { return toolbar_1.TableSizeControl; } });
18
+ Object.defineProperty(exports, "BulkActionsToolbar", { enumerable: true, get: function () { return toolbar_1.BulkActionsToolbar; } });
19
+ Object.defineProperty(exports, "DataTableToolbar", { enumerable: true, get: function () { return toolbar_1.DataTableToolbar; } });
20
+ tslib_1.__exportStar(require("./lib/utils/styling-helpers"), exports);
21
+ tslib_1.__exportStar(require("./lib/utils/column-helpers"), exports);
22
+ tslib_1.__exportStar(require("./lib/utils/table-helpers"), exports);
23
+ tslib_1.__exportStar(require("./lib/hooks"), exports);
24
+ tslib_1.__exportStar(require("./lib/types"), exports);
25
+ tslib_1.__exportStar(require("./lib/features"), exports);
26
+ var custom_column_filter_example_1 = require("./lib/examples/custom-column-filter-example");
27
+ Object.defineProperty(exports, "CustomColumnFilterExample", { enumerable: true, get: function () { return custom_column_filter_example_1.CustomColumnFilterExample; } });
28
+ var simple_local_example_1 = require("./lib/examples/simple-local-example");
29
+ Object.defineProperty(exports, "SimpleLocalExample", { enumerable: true, get: function () { return simple_local_example_1.SimpleLocalExample; } });
30
+ var advanced_features_example_1 = require("./lib/examples/advanced-features-example");
31
+ Object.defineProperty(exports, "AdvancedFeaturesExample", { enumerable: true, get: function () { return advanced_features_example_1.AdvancedFeaturesExample; } });
@@ -0,0 +1,17 @@
1
+ import { Menu, MenuProps, Popover } from '@mui/material';
2
+ import { ReactElement, ReactNode } from 'react';
3
+ type ChildrenEvent = {
4
+ handleClose: () => void;
5
+ open: boolean;
6
+ };
7
+ type AnchorEvent = {
8
+ isOpen: boolean;
9
+ };
10
+ export interface MenuDropdownProps extends Omit<MenuProps, 'children' | 'open'> {
11
+ children?: ((event: ChildrenEvent) => ReactNode) | ReactNode | any;
12
+ anchor?: ((event: AnchorEvent) => ReactElement<any>) | ReactElement<any>;
13
+ label?: ReactNode;
14
+ component?: typeof Popover | typeof Menu;
15
+ }
16
+ export declare function MenuDropdown({ children, anchor, label, component, sx, ...props }: MenuDropdownProps): import("react/jsx-runtime").JSX.Element;
17
+ export {};