@ackplus/react-tanstack-data-table 1.1.20 → 1.1.21

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 (61) hide show
  1. package/dist/lib/hooks/use-data-table-engine.d.ts.map +1 -1
  2. package/dist/lib/hooks/use-data-table-engine.js +4 -0
  3. package/package.json +3 -4
  4. package/src/index.ts +0 -75
  5. package/src/lib/components/data-table-view.tsx +0 -386
  6. package/src/lib/components/droupdown/menu-dropdown.tsx +0 -103
  7. package/src/lib/components/filters/filter-value-input.tsx +0 -225
  8. package/src/lib/components/filters/index.ts +0 -126
  9. package/src/lib/components/headers/draggable-header.tsx +0 -326
  10. package/src/lib/components/headers/index.ts +0 -6
  11. package/src/lib/components/headers/table-header.tsx +0 -175
  12. package/src/lib/components/index.ts +0 -21
  13. package/src/lib/components/pagination/data-table-pagination.tsx +0 -111
  14. package/src/lib/components/pagination/index.ts +0 -5
  15. package/src/lib/components/rows/data-table-row.tsx +0 -218
  16. package/src/lib/components/rows/empty-data-row.tsx +0 -69
  17. package/src/lib/components/rows/index.ts +0 -7
  18. package/src/lib/components/rows/loading-rows.tsx +0 -164
  19. package/src/lib/components/toolbar/bulk-actions-toolbar.tsx +0 -125
  20. package/src/lib/components/toolbar/column-filter-control.tsx +0 -432
  21. package/src/lib/components/toolbar/column-pinning-control.tsx +0 -275
  22. package/src/lib/components/toolbar/column-reset-control.tsx +0 -74
  23. package/src/lib/components/toolbar/column-visibility-control.tsx +0 -105
  24. package/src/lib/components/toolbar/data-table-toolbar.tsx +0 -257
  25. package/src/lib/components/toolbar/index.ts +0 -17
  26. package/src/lib/components/toolbar/table-export-control.tsx +0 -233
  27. package/src/lib/components/toolbar/table-refresh-control.tsx +0 -62
  28. package/src/lib/components/toolbar/table-search-control.tsx +0 -155
  29. package/src/lib/components/toolbar/table-size-control.tsx +0 -102
  30. package/src/lib/contexts/data-table-context.tsx +0 -126
  31. package/src/lib/data-table.tsx +0 -29
  32. package/src/lib/features/README.md +0 -161
  33. package/src/lib/features/column-filter.feature.ts +0 -493
  34. package/src/lib/features/index.ts +0 -23
  35. package/src/lib/features/selection.feature.ts +0 -322
  36. package/src/lib/hooks/index.ts +0 -2
  37. package/src/lib/hooks/use-data-table-engine.ts +0 -1552
  38. package/src/lib/icons/add-icon.tsx +0 -23
  39. package/src/lib/icons/csv-icon.tsx +0 -15
  40. package/src/lib/icons/delete-icon.tsx +0 -30
  41. package/src/lib/icons/excel-icon.tsx +0 -15
  42. package/src/lib/icons/index.ts +0 -7
  43. package/src/lib/icons/unpin-icon.tsx +0 -18
  44. package/src/lib/icons/view-comfortable-icon.tsx +0 -45
  45. package/src/lib/icons/view-compact-icon.tsx +0 -55
  46. package/src/lib/types/column.types.ts +0 -63
  47. package/src/lib/types/data-table-api.ts +0 -191
  48. package/src/lib/types/data-table.types.ts +0 -193
  49. package/src/lib/types/export.types.ts +0 -223
  50. package/src/lib/types/index.ts +0 -24
  51. package/src/lib/types/slots.types.ts +0 -342
  52. package/src/lib/types/table.types.ts +0 -88
  53. package/src/lib/utils/column-helpers.ts +0 -72
  54. package/src/lib/utils/debounced-fetch.utils.ts +0 -131
  55. package/src/lib/utils/export-utils.ts +0 -712
  56. package/src/lib/utils/index.ts +0 -27
  57. package/src/lib/utils/logger.ts +0 -203
  58. package/src/lib/utils/slot-helpers.tsx +0 -194
  59. package/src/lib/utils/special-columns.utils.ts +0 -101
  60. package/src/lib/utils/styling-helpers.ts +0 -126
  61. package/src/lib/utils/table-helpers.ts +0 -106
@@ -1,164 +0,0 @@
1
- import React, { ReactElement } from 'react';
2
- import { TableCell, TableRow, Skeleton, TableRowProps, TableCellProps, SxProps } from '@mui/material';
3
-
4
- import { useDataTableContext } from '../../contexts/data-table-context';
5
- import { getPinnedColumnStyle } from '../../utils';
6
- import { getSlotComponent, mergeSlotProps, extractSlotProps } from '../../utils/slot-helpers';
7
-
8
- export interface LoadingRowsProps {
9
- rowCount?: number;
10
- // Enhanced customization props
11
- rowProps?: TableRowProps;
12
- cellProps?: TableCellProps;
13
- skeletonProps?: any;
14
- containerSx?: SxProps;
15
- slots?: Record<string, any>;
16
- slotProps?: Record<string, any>;
17
- [key: string]: any;
18
- }
19
-
20
- export function LoadingRows(props: LoadingRowsProps): ReactElement {
21
- const {
22
- rowCount = 5,
23
- rowProps,
24
- cellProps,
25
- skeletonProps,
26
- containerSx,
27
- slots,
28
- slotProps,
29
- } = props;
30
-
31
- const { table } = useDataTableContext();
32
- const visibleColumns = table.getVisibleLeafColumns();
33
-
34
- // Extract slot-specific props with enhanced merging
35
- const cellSlotProps = extractSlotProps(slotProps, 'cell');
36
- const rowSlotProps = extractSlotProps(slotProps, 'row');
37
-
38
- const CellSlot = getSlotComponent(slots, 'cell', TableCell);
39
- const TableRowSlot = getSlotComponent(slots, 'row', TableRow);
40
-
41
- // Merge all props for maximum flexibility
42
- const mergedRowProps = mergeSlotProps(
43
- {
44
- sx: containerSx,
45
- },
46
- rowSlotProps,
47
- rowProps || {}
48
- );
49
-
50
- return (
51
- <>
52
- {Array.from({ length: rowCount }, (_, rowIndex) => (
53
- <TableRowSlot
54
- key={`skeleton-row-${rowIndex}`}
55
- {...mergedRowProps}
56
- >
57
- {visibleColumns.map((column: any, colIndex: number) => {
58
- const isPinned = column.getIsPinned();
59
- const pinnedPosition = isPinned ? column.getStart('left') : undefined;
60
- const pinnedRightPosition = isPinned === 'right' ? column.getAfter('right') : undefined;
61
- const minSize = column.columnDef?.minSize;
62
- const maxSize = column.columnDef?.maxSize;
63
-
64
- // Determine skeleton type based on column meta or content
65
- const columnMeta = column.columnDef?.meta;
66
- const isDateColumn = columnMeta?.type === 'date';
67
- const isBooleanColumn = columnMeta?.type === 'boolean';
68
- const isNumberColumn = columnMeta?.type === 'number';
69
- const isSelectionColumn = column.id === 'select';
70
-
71
- const mergedCellProps = mergeSlotProps(
72
- {
73
- sx: {
74
- ...getPinnedColumnStyle({
75
- width: column.getSize(),
76
- minWidth: minSize !== undefined ? minSize : undefined,
77
- maxWidth: maxSize !== undefined ? maxSize : undefined,
78
- isPinned,
79
- pinnedPosition,
80
- pinnedRightPosition,
81
- zIndex: isPinned ? 9 : 1,
82
- isLastLeftPinnedColumn: isPinned === 'left' && column.getIsLastColumn('left'),
83
- isFirstRightPinnedColumn: isPinned === 'right' && column.getIsFirstColumn('right'),
84
- }),
85
- },
86
- },
87
- cellSlotProps,
88
- cellProps || {}
89
- );
90
-
91
- const getSkeletonContent = () => {
92
- if (isSelectionColumn) {
93
- return (
94
- <Skeleton
95
- variant="rectangular"
96
- width={20}
97
- height={20}
98
- animation="wave"
99
- {...skeletonProps}
100
- />
101
- );
102
- }
103
-
104
- if (isBooleanColumn) {
105
- return (
106
- <Skeleton
107
- variant="circular"
108
- width={16}
109
- height={16}
110
- animation="wave"
111
- {...skeletonProps}
112
- />
113
- );
114
- }
115
-
116
- if (isDateColumn) {
117
- return (
118
- <Skeleton
119
- variant="text"
120
- width="80%"
121
- height={20}
122
- animation="wave"
123
- {...skeletonProps}
124
- />
125
- );
126
- }
127
-
128
- if (isNumberColumn) {
129
- return (
130
- <Skeleton
131
- variant="text"
132
- width="60%"
133
- height={20}
134
- animation="wave"
135
- {...skeletonProps}
136
- />
137
- );
138
- }
139
-
140
- return (
141
- <Skeleton
142
- variant="text"
143
- width={`${Math.random() * 40 + 60}%`}
144
- height={20}
145
- animation="wave"
146
- {...skeletonProps}
147
- />
148
- );
149
- };
150
-
151
- return (
152
- <CellSlot
153
- key={`skeleton-${column.id || colIndex}-${rowIndex}`}
154
- {...mergedCellProps}
155
- >
156
- {getSkeletonContent()}
157
- </CellSlot>
158
- );
159
- })}
160
- </TableRowSlot>
161
- ))}
162
- </>
163
- );
164
- }
@@ -1,125 +0,0 @@
1
- import {
2
- Box,
3
- Toolbar,
4
- Typography,
5
- Chip,
6
- Fade,
7
- alpha,
8
- Theme,
9
- ToolbarProps,
10
- SxProps,
11
- } from '@mui/material';
12
- import { ReactNode, useMemo, ReactElement } from 'react';
13
-
14
- import { useDataTableContext } from '../../contexts/data-table-context';
15
- import { getSlotComponent, mergeSlotProps, extractSlotProps } from '../../utils/slot-helpers';
16
- import { SelectionState } from '../../features';
17
-
18
- export interface BulkActionsToolbarProps extends ToolbarProps {
19
- selectionState: SelectionState;
20
- selectedRowCount: number;
21
- bulkActions?: (selectionState: SelectionState) => ReactNode;
22
- // Enhanced customization props
23
- chipProps?: any;
24
- containerSx?: SxProps;
25
- leftSectionSx?: SxProps;
26
- rightSectionSx?: SxProps;
27
- fadeProps?: any;
28
- [key: string]: any;
29
- }
30
-
31
- export function BulkActionsToolbar(props: BulkActionsToolbarProps): ReactElement {
32
- const {
33
- selectionState,
34
- selectedRowCount,
35
- bulkActions,
36
- chipProps,
37
- containerSx,
38
- leftSectionSx,
39
- rightSectionSx,
40
- fadeProps,
41
- sx,
42
- ...otherProps
43
- } = props;
44
-
45
- const { slots, slotProps } = useDataTableContext();
46
-
47
- // Extract slot-specific props with enhanced merging
48
- const toolbarSlotProps = extractSlotProps(slotProps, 'bulkActionsToolbar');
49
- const ToolbarSlot = getSlotComponent(slots, 'bulkActionsToolbar', Toolbar);
50
-
51
- // Memoize the bulk actions rendering to prevent infinite re-renders
52
- const renderedBulkActions = useMemo(() => {
53
- if (!bulkActions) return null;
54
- return bulkActions(selectionState) as any;
55
- }, [bulkActions, selectionState]);
56
-
57
- // Merge all props for maximum flexibility
58
- const mergedToolbarProps = mergeSlotProps(
59
- {
60
- sx: {
61
- pl: { sm: 2 },
62
- pr: { xs: 1, sm: 1 },
63
- bgcolor: (theme: Theme) => alpha(theme.palette.primary.main, 0.05),
64
- mb: 1,
65
- position: 'relative',
66
- zIndex: 1,
67
- ...sx,
68
- ...containerSx,
69
- },
70
- },
71
- toolbarSlotProps,
72
- otherProps
73
- );
74
-
75
- const mergedChipProps = mergeSlotProps(
76
- {
77
- label: `${selectedRowCount} selected`,
78
- size: 'small',
79
- color: 'primary',
80
- variant: 'outlined',
81
- },
82
- chipProps || {}
83
- );
84
-
85
- return (
86
- <Fade
87
- in={selectedRowCount > 0}
88
- {...fadeProps}
89
- >
90
- <ToolbarSlot
91
- {...mergedToolbarProps}
92
- >
93
- {/* Left section - Selection info */}
94
- <Box
95
- sx={{
96
- flex: '1 1 100%',
97
- ...leftSectionSx,
98
- }}
99
- >
100
- <Typography
101
- color="inherit"
102
- variant="subtitle1"
103
- component="div"
104
- >
105
- <Chip
106
- {...mergedChipProps}
107
- />
108
- </Typography>
109
- </Box>
110
-
111
- {/* Right section - Actions */}
112
- <Box
113
- sx={{
114
- display: 'flex',
115
- alignItems: 'center',
116
- gap: 1,
117
- ...rightSectionSx,
118
- }}
119
- >
120
- {renderedBulkActions}
121
- </Box>
122
- </ToolbarSlot>
123
- </Fade>
124
- );
125
- }