@ackplus/react-tanstack-data-table 1.0.32 → 1.0.33

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ackplus/react-tanstack-data-table",
3
3
  "type": "commonjs",
4
- "version": "1.0.32",
4
+ "version": "1.0.33",
5
5
  "description": "A powerful React data table component built with MUI and TanStack Table",
6
6
  "keywords": [
7
7
  "react",
@@ -14,4 +14,5 @@ interface DraggableHeaderProps<T> {
14
14
  [key: string]: any;
15
15
  }
16
16
  export declare function DraggableHeader<T>(props: DraggableHeaderProps<T>): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>> | import("react/jsx-runtime").JSX.Element;
17
+ export declare const DraggableHeaderMemo: typeof DraggableHeader;
17
18
  export {};
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DraggableHeaderMemo = void 0;
3
4
  exports.DraggableHeader = DraggableHeader;
4
5
  const tslib_1 = require("tslib");
5
6
  const jsx_runtime_1 = require("react/jsx-runtime");
6
7
  const icons_material_1 = require("@mui/icons-material");
7
8
  const material_1 = require("@mui/material");
8
9
  const react_table_1 = require("@tanstack/react-table");
9
- const react_1 = require("react");
10
+ const react_1 = tslib_1.__importStar(require("react"));
10
11
  const slot_helpers_1 = require("../../utils/slot-helpers");
11
12
  function DraggableHeader(props) {
12
13
  const { header, enableSorting = true, draggable = false, onColumnReorder, containerSx, sortIconProps, alignment, slots, slotProps } = props, otherProps = tslib_1.__rest(props, ["header", "enableSorting", "draggable", "onColumnReorder", "containerSx", "sortIconProps", "alignment", "slots", "slotProps"]);
@@ -204,3 +205,4 @@ function DraggableHeader(props) {
204
205
  gap: 1,
205
206
  }, children: [(0, react_table_1.flexRender)(header.column.columnDef.header, header.getContext()), getSortIcon()] }) })));
206
207
  }
208
+ exports.DraggableHeaderMemo = react_1.default.memo(DraggableHeader);
@@ -14,3 +14,4 @@ export interface TableHeaderProps extends TableHeadProps {
14
14
  [key: string]: any;
15
15
  }
16
16
  export declare function TableHeader<T>(props: TableHeaderProps): import("react/jsx-runtime").JSX.Element;
17
+ export declare const TableHeaderMemo: typeof TableHeader;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TableHeaderMemo = void 0;
3
4
  exports.TableHeader = TableHeader;
4
5
  const tslib_1 = require("tslib");
5
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = tslib_1.__importStar(require("react"));
6
8
  const material_1 = require("@mui/material");
7
9
  const draggable_header_1 = require("./draggable-header");
8
10
  const data_table_context_1 = require("../../contexts/data-table-context");
@@ -22,16 +24,21 @@ function TableHeader(props) {
22
24
  sx: containerSx,
23
25
  }, headerSlotProps, otherProps);
24
26
  const mergedHeaderRowProps = (0, slot_helpers_1.mergeSlotProps)({}, headerRowSlotProps, headerRowProps || {});
25
- const renderHeaderCell = (header) => {
27
+ const renderHeaderCell = (0, react_1.useCallback)((header) => {
26
28
  const isPinned = header.column.getIsPinned();
27
29
  const pinnedPosition = isPinned ? header.column.getStart('left') : undefined;
28
30
  const pinnedRightPosition = isPinned === 'right' ? header.column.getAfter('right') : undefined;
29
31
  const alignment = (0, utils_1.getColumnAlignment)(header.column.columnDef);
30
32
  const enableSorting = header.column.getCanSort();
33
+ const minSize = header.column.columnDef.minSize;
34
+ const maxSize = header.column.columnDef.maxSize;
35
+ const columnSize = enableColumnResizing ? header.getSize() : (fitToScreen ? 'auto' : header.getSize());
31
36
  const mergedHeaderCellProps = (0, slot_helpers_1.mergeSlotProps)({
32
37
  align: alignment,
33
38
  sx: Object.assign({}, (0, utils_1.getPinnedColumnStyle)({
34
- width: (fitToScreen && !enableColumnResizing) ? 'auto' : header.getSize(),
39
+ width: columnSize,
40
+ minWidth: minSize !== undefined ? minSize : undefined,
41
+ maxWidth: maxSize !== undefined ? maxSize : undefined,
35
42
  isPinned,
36
43
  pinnedPosition,
37
44
  isLastLeftPinnedColumn: isPinned === 'left' && header.column.getIsLastColumn('left'),
@@ -49,6 +56,20 @@ function TableHeader(props) {
49
56
  } }, resizeHandleSx),
50
57
  });
51
58
  return ((0, jsx_runtime_1.jsxs)(HeaderCellSlot, Object.assign({}, mergedHeaderCellProps, { children: [(0, jsx_runtime_1.jsx)(draggable_header_1.DraggableHeader, { header: header, enableSorting: enableSorting, draggable: !!(draggable && !isPinned), onColumnReorder: onColumnReorder, slots: slots, slotProps: slotProps, alignment: alignment }), enableColumnResizing && header.column.getCanResize() ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({}, mergedResizeHandleProps))) : null] }), header.id));
52
- };
53
- return ((0, jsx_runtime_1.jsx)(HeaderSlot, Object.assign({}, mergedHeaderProps, { children: table.getHeaderGroups().map(headerGroup => ((0, jsx_runtime_1.jsx)(HeaderRowSlot, Object.assign({}, mergedHeaderRowProps, { children: headerGroup.headers.map(renderHeaderCell) }), headerGroup.id))) })));
59
+ }, [
60
+ fitToScreen,
61
+ enableColumnResizing,
62
+ enableStickyHeader,
63
+ headerCellSlotProps,
64
+ headerCellProps,
65
+ resizeHandleSx,
66
+ theme,
67
+ draggable,
68
+ onColumnReorder,
69
+ slots,
70
+ slotProps,
71
+ ]);
72
+ const headerGroups = (0, react_1.useMemo)(() => table.getHeaderGroups(), [table]);
73
+ return ((0, jsx_runtime_1.jsx)(HeaderSlot, Object.assign({}, mergedHeaderProps, { children: headerGroups.map(headerGroup => ((0, jsx_runtime_1.jsx)(HeaderRowSlot, Object.assign({}, mergedHeaderRowProps, { children: headerGroup.headers.map(renderHeaderCell) }), headerGroup.id))) })));
54
74
  }
75
+ exports.TableHeaderMemo = react_1.default.memo(TableHeader);
@@ -17,20 +17,32 @@ function DataTableRow(props) {
17
17
  const TableRowSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'row', material_1.TableRow);
18
18
  const mergedRowProps = (0, slot_helpers_1.mergeSlotProps)({
19
19
  hover: enableHover,
20
- sx: Object.assign({ backgroundColor: enableStripes && isOdd ? 'action.hover' : 'transparent' }, containerSx),
20
+ sx: (theme) => (Object.assign(Object.assign(Object.assign({ '--row-bg': enableStripes && isOdd
21
+ ? theme.palette.action.hover
22
+ : theme.palette.background.paper, backgroundColor: 'var(--row-bg)' }, (enableHover && {
23
+ '&:hover': { '--row-bg': theme.palette.action.hover },
24
+ })), { [`&.${material_1.tableRowClasses.selected}`]: {
25
+ '--row-bg': (0, material_1.alpha)(theme.palette.primary.dark, 0.08),
26
+ backgroundColor: 'var(--row-bg)',
27
+ } }), containerSx)),
21
28
  }, rowSlotProps, otherProps);
22
29
  const mergedExpandedRowProps = (0, slot_helpers_1.mergeSlotProps)({
23
30
  sx: expandedContainerSx,
24
31
  }, expandedRowSlotProps, expandedRowProps || {});
25
32
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(TableRowSlot, Object.assign({}, mergedRowProps, { children: row.getVisibleCells().map(cell => {
33
+ var _a;
26
34
  const isPinned = cell.column.getIsPinned();
27
35
  const pinnedPosition = isPinned ? cell.column.getStart('left') : undefined;
28
36
  const pinnedRightPosition = isPinned === 'right' ? cell.column.getAfter('right') : undefined;
29
37
  const alignment = (0, utils_1.getColumnAlignment)(cell.column.columnDef);
38
+ const minSize = (_a = cell.column.columnDef) === null || _a === void 0 ? void 0 : _a.minSize;
39
+ const maxSize = cell.column.columnDef.maxSize;
30
40
  const mergedCellProps = (0, slot_helpers_1.mergeSlotProps)({
31
41
  align: alignment,
32
42
  sx: Object.assign({}, (0, utils_1.getPinnedColumnStyle)({
33
43
  width: cell.column.getSize() || 'auto',
44
+ minWidth: minSize !== undefined ? minSize : undefined,
45
+ maxWidth: maxSize !== undefined ? maxSize : undefined,
34
46
  isPinned,
35
47
  pinnedPosition,
36
48
  pinnedRightPosition,
@@ -70,7 +70,6 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
70
70
  }
71
71
  return config;
72
72
  }, [initialState, logger]);
73
- console.log('initialStateConfig', initialStateConfig);
74
73
  const [sorting, setSorting] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.sorting) || DEFAULT_INITIAL_STATE.sorting);
75
74
  const [pagination, setPagination] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.pagination) || DEFAULT_INITIAL_STATE.pagination);
76
75
  const [globalFilter, setGlobalFilter] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.globalFilter) || DEFAULT_INITIAL_STATE.globalFilter);
@@ -80,6 +79,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
80
79
  const [tableSize, setTableSize] = (0, react_1.useState)(initialTableSize || 'medium');
81
80
  const [columnOrder, setColumnOrder] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.columnOrder) || DEFAULT_INITIAL_STATE.columnOrder);
82
81
  const [columnPinning, setColumnPinning] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.columnPinning) || DEFAULT_INITIAL_STATE.columnPinning);
82
+ const [columnVisibility, setColumnVisibility] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.columnVisibility) || DEFAULT_INITIAL_STATE.columnVisibility);
83
+ const [columnSizing, setColumnSizing] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.columnSizing) || DEFAULT_INITIAL_STATE.columnSizing);
83
84
  const [serverData, setServerData] = (0, react_1.useState)(null);
84
85
  const [serverTotal, setServerTotal] = (0, react_1.useState)(0);
85
86
  const [exportController, setExportController] = (0, react_1.useState)(null);
@@ -154,7 +155,6 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
154
155
  pagination,
155
156
  columnFilter,
156
157
  sorting }, overrides);
157
- console.log('filters', filters);
158
158
  if (logger.isLevelEnabled('info')) {
159
159
  logger.info('Requesting data', { filters });
160
160
  }
@@ -218,7 +218,9 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
218
218
  sorting,
219
219
  pagination,
220
220
  columnOrder,
221
- columnPinning }, overrides);
221
+ columnPinning,
222
+ columnVisibility,
223
+ columnSizing }, overrides);
222
224
  if (logger.isLevelEnabled('debug')) {
223
225
  logger.debug('Emitting tableStateChange', currentState);
224
226
  }
@@ -231,6 +233,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
231
233
  pagination,
232
234
  columnOrder,
233
235
  columnPinning,
236
+ columnVisibility,
237
+ columnSizing,
234
238
  logger,
235
239
  ]);
236
240
  const handleSortingChange = (0, react_1.useCallback)((updaterOrValue) => {
@@ -296,12 +300,10 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
296
300
  }
297
301
  }, [onColumnPinningChange, columnPinning]);
298
302
  const handleColumnVisibilityChange = (0, react_1.useCallback)((updater) => {
299
- var _a, _b;
300
- const tableInstance = (_b = (_a = internalApiRef.current) === null || _a === void 0 ? void 0 : _a.table) === null || _b === void 0 ? void 0 : _b.getTable();
301
- if (!tableInstance)
302
- return;
303
- const currentVisibility = tableInstance.getState().columnVisibility;
304
- const newVisibility = typeof updater === 'function' ? updater(currentVisibility) : updater;
303
+ const newVisibility = typeof updater === 'function'
304
+ ? updater(columnVisibility)
305
+ : updater;
306
+ setColumnVisibility(newVisibility);
305
307
  if (onColumnVisibilityChange) {
306
308
  setTimeout(() => {
307
309
  onColumnVisibilityChange(newVisibility);
@@ -312,14 +314,12 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
312
314
  tableStateChange({ columnVisibility: newVisibility });
313
315
  }, 0);
314
316
  }
315
- }, [onColumnVisibilityChange, onDataStateChange, tableStateChange]);
317
+ }, [onColumnVisibilityChange, onDataStateChange, tableStateChange, columnVisibility]);
316
318
  const handleColumnSizingChange = (0, react_1.useCallback)((updater) => {
317
- var _a, _b;
318
- const tableInstance = (_b = (_a = internalApiRef.current) === null || _a === void 0 ? void 0 : _a.table) === null || _b === void 0 ? void 0 : _b.getTable();
319
- if (!tableInstance)
320
- return;
321
- const currentSizing = tableInstance.getState().columnSizing;
322
- const newSizing = typeof updater === 'function' ? updater(currentSizing) : updater;
319
+ const newSizing = typeof updater === 'function'
320
+ ? updater(columnSizing)
321
+ : updater;
322
+ setColumnSizing(newSizing);
323
323
  if (onColumnSizingChange) {
324
324
  setTimeout(() => {
325
325
  onColumnSizingChange(newSizing);
@@ -330,7 +330,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
330
330
  tableStateChange({ columnSizing: newSizing });
331
331
  }, 0);
332
332
  }
333
- }, [onColumnSizingChange, onDataStateChange, tableStateChange]);
333
+ }, [onColumnSizingChange, onDataStateChange, tableStateChange, columnSizing]);
334
334
  const handlePaginationChange = (0, react_1.useCallback)((updater) => {
335
335
  const newPagination = typeof updater === 'function' ? updater(pagination) : updater;
336
336
  if (logger.isLevelEnabled('debug')) {
@@ -340,7 +340,6 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
340
340
  serverSide: isServerMode || isServerPagination,
341
341
  });
342
342
  }
343
- console.log('newPagination', newPagination);
344
343
  setPagination(newPagination);
345
344
  onPaginationChange === null || onPaginationChange === void 0 ? void 0 : onPaginationChange(newPagination);
346
345
  if (logger.isLevelEnabled('debug')) {
@@ -449,7 +448,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
449
448
  }
450
449
  }, 0);
451
450
  }, [isServerFiltering, fetchData, tableStateChange]);
452
- const table = (0, react_table_1.useReactTable)(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ _features: [column_filter_feature_1.ColumnFilterFeature, features_1.SelectionFeature], data: tableData, columns: enhancedColumns, initialState: Object.assign({}, DEFAULT_INITIAL_STATE), state: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (enableSorting ? { sorting } : {})), (enablePagination ? { pagination } : {})), (enableGlobalFilter ? { globalFilter } : {})), (enableExpanding ? { expanded } : {})), (enableColumnDragging ? { columnOrder } : {})), (enableColumnPinning ? { columnPinning } : {})), (enableColumnFilter ? { columnFilter } : {})), (enableRowSelection ? { selectionState } : {})), selectMode: selectMode, enableAdvanceSelection: !!enableRowSelection, isRowSelectable: isRowSelectable }, (enableRowSelection ? { onSelectionStateChange: handleSelectionStateChange } : {})), { enableAdvanceColumnFilter: enableColumnFilter, onColumnFilterChange: onColumnFilterChangeHandler, onColumnFilterApply: onColumnFilterApplyHandler }), (enableSorting ? { onSortingChange: handleSortingChange } : {})), (enablePagination ? { onPaginationChange: handlePaginationChange } : {})), (enableRowSelection ? { onRowSelectionChange: handleSelectionStateChange } : {})), (enableGlobalFilter ? { onGlobalFilterChange: handleGlobalFilterChange } : {})), (enableExpanding ? { onExpandedChange: setExpanded } : {})), (enableColumnDragging ? { onColumnOrderChange: handleColumnOrderChange } : {})), (enableColumnPinning ? { onColumnPinningChange: handleColumnPinningChange } : {})), (enableColumnVisibility ? { onColumnVisibilityChange: handleColumnVisibilityChange } : {})), (enableColumnResizing ? { onColumnSizingChange: handleColumnSizingChange } : {})), { getCoreRowModel: (0, react_table_1.getCoreRowModel)() }), (enableSorting ? { getSortedRowModel: (0, react_table_1.getSortedRowModel)() } : {})), (enableColumnFilter ? { getFilteredRowModel: (0, column_filter_feature_1.getCombinedFilteredRowModel)() } : {})), (enablePagination ? { getPaginationRowModel: (0, react_table_1.getPaginationRowModel)() } : {})), { enableSorting: enableSorting, manualSorting: isServerSorting, manualFiltering: isServerFiltering, enableColumnResizing: enableColumnResizing, columnResizeMode: columnResizeMode, enableColumnPinning: enableColumnPinning }), (enableExpanding ? { getRowCanExpand: getRowCanExpand } : {})), { manualPagination: isServerPagination, autoResetPageIndex: false, rowCount: tableTotalRow, getRowId: (row, index) => (0, utils_1.generateRowId)(row, index, idKey), debugAll: false }));
451
+ const table = (0, react_table_1.useReactTable)(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ _features: [column_filter_feature_1.ColumnFilterFeature, features_1.SelectionFeature], data: tableData, columns: enhancedColumns, initialState: Object.assign({}, DEFAULT_INITIAL_STATE), state: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (enableSorting ? { sorting } : {})), (enablePagination ? { pagination } : {})), (enableGlobalFilter ? { globalFilter } : {})), (enableExpanding ? { expanded } : {})), (enableColumnDragging ? { columnOrder } : {})), (enableColumnPinning ? { columnPinning } : {})), (enableColumnVisibility ? { columnVisibility } : {})), (enableColumnResizing ? { columnSizing } : {})), (enableColumnFilter ? { columnFilter } : {})), (enableRowSelection ? { selectionState } : {})), selectMode: selectMode, enableAdvanceSelection: !!enableRowSelection, isRowSelectable: isRowSelectable }, (enableRowSelection ? { onSelectionStateChange: handleSelectionStateChange } : {})), { enableAdvanceColumnFilter: enableColumnFilter, onColumnFilterChange: onColumnFilterChangeHandler, onColumnFilterApply: onColumnFilterApplyHandler }), (enableSorting ? { onSortingChange: handleSortingChange } : {})), (enablePagination ? { onPaginationChange: handlePaginationChange } : {})), (enableRowSelection ? { onRowSelectionChange: handleSelectionStateChange } : {})), (enableGlobalFilter ? { onGlobalFilterChange: handleGlobalFilterChange } : {})), (enableExpanding ? { onExpandedChange: setExpanded } : {})), (enableColumnDragging ? { onColumnOrderChange: handleColumnOrderChange } : {})), (enableColumnPinning ? { onColumnPinningChange: handleColumnPinningChange } : {})), (enableColumnVisibility ? { onColumnVisibilityChange: handleColumnVisibilityChange } : {})), (enableColumnResizing ? { onColumnSizingChange: handleColumnSizingChange } : {})), { getCoreRowModel: (0, react_table_1.getCoreRowModel)() }), (enableSorting ? { getSortedRowModel: (0, react_table_1.getSortedRowModel)() } : {})), (enableColumnFilter ? { getFilteredRowModel: (0, column_filter_feature_1.getCombinedFilteredRowModel)() } : {})), (enablePagination ? { getPaginationRowModel: (0, react_table_1.getPaginationRowModel)() } : {})), { enableSorting: enableSorting, manualSorting: isServerSorting, manualFiltering: isServerFiltering, enableColumnResizing: enableColumnResizing, columnResizeMode: columnResizeMode, enableColumnPinning: enableColumnPinning }), (enableExpanding ? { getRowCanExpand: getRowCanExpand } : {})), { manualPagination: isServerPagination, autoResetPageIndex: false, rowCount: tableTotalRow, getRowId: (row, index) => (0, utils_1.generateRowId)(row, index, idKey), debugAll: false }));
453
452
  const rows = ((_a = table.getRowModel()) === null || _a === void 0 ? void 0 : _a.rows) || [];
454
453
  const rowVirtualizer = (0, react_virtual_1.useVirtualizer)({
455
454
  count: rows.length,
@@ -468,8 +467,6 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
468
467
  const newPagination = { pageIndex: 0, pageSize: pagination.pageSize };
469
468
  setPagination(newPagination);
470
469
  onPaginationChange === null || onPaginationChange === void 0 ? void 0 : onPaginationChange(newPagination);
471
- console.log('newPagination', newPagination);
472
- console.log('onPaginationChange', onPaginationChange);
473
470
  return newPagination;
474
471
  };
475
472
  const handleColumnReorder = (0, react_1.useCallback)((draggedColumnId, targetColumnId) => {
@@ -151,35 +151,30 @@ function ServerSideFetchingExample() {
151
151
  id: 'name',
152
152
  accessorKey: 'name',
153
153
  header: 'Name',
154
- size: 200,
155
154
  enableGlobalFilter: true,
156
155
  },
157
156
  {
158
157
  id: 'email',
159
158
  accessorKey: 'email',
160
159
  header: 'Email',
161
- size: 250,
162
160
  enableGlobalFilter: true,
163
161
  },
164
162
  {
165
163
  id: 'department',
166
164
  accessorKey: 'department',
167
165
  header: 'Department',
168
- size: 150,
169
166
  enableGlobalFilter: true,
170
167
  },
171
168
  {
172
169
  id: 'role',
173
170
  accessorKey: 'role',
174
171
  header: 'Role',
175
- size: 120,
176
172
  enableGlobalFilter: true,
177
173
  },
178
174
  {
179
175
  id: 'salary',
180
176
  accessorKey: 'salary',
181
177
  header: 'Salary',
182
- size: 120,
183
178
  accessorFn: (row) => `$${row.salary.toLocaleString()}`,
184
179
  hideInExport: true,
185
180
  },
@@ -187,7 +182,6 @@ function ServerSideFetchingExample() {
187
182
  id: 'isActive',
188
183
  accessorKey: 'isActive',
189
184
  header: 'Status',
190
- size: 100,
191
185
  accessorFn: (row) => row.isActive ? 'Active' : 'Inactive',
192
186
  cell: ({ getValue }) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: getValue() ? 'Active' : 'Inactive', color: getValue() ? 'success' : 'default', size: "small" })),
193
187
  },
@@ -195,7 +189,6 @@ function ServerSideFetchingExample() {
195
189
  id: 'joinDate',
196
190
  accessorKey: 'joinDate',
197
191
  header: 'Join Date',
198
- size: 120,
199
192
  accessorFn: (row) => new Date(row.joinDate).toLocaleDateString(),
200
193
  },
201
194
  ];
@@ -28,30 +28,28 @@ const columns = [
28
28
  {
29
29
  accessorKey: 'name',
30
30
  header: 'Product Name',
31
- size: 180,
32
31
  },
33
32
  {
34
33
  accessorKey: 'category',
35
34
  header: 'Category',
36
- size: 120,
37
35
  cell: ({ getValue }) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: getValue(), size: "small", variant: "outlined", color: "primary" })),
38
36
  },
39
37
  {
40
38
  accessorKey: 'price',
41
39
  header: 'Price',
42
- size: 100,
43
40
  cell: ({ getValue }) => `$${getValue().toFixed(2)}`,
44
41
  },
45
42
  {
46
43
  accessorKey: 'inStock',
47
44
  header: 'In Stock',
48
- size: 100,
49
45
  cell: ({ getValue }) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: getValue() ? 'Yes' : 'No', color: getValue() ? 'success' : 'error', size: "small" })),
50
46
  },
51
47
  {
52
48
  accessorKey: 'rating',
53
49
  header: 'Rating',
54
50
  size: 100,
51
+ minSize: 100,
52
+ maxSize: 100,
55
53
  cell: ({ getValue }) => `⭐ ${getValue().toFixed(1)}`,
56
54
  },
57
55
  ];
@@ -62,6 +62,8 @@ export interface ChunkProcessingConfig {
62
62
  }
63
63
  export interface PinnedColumnStyleOptions {
64
64
  width?: number | string;
65
+ minWidth?: number;
66
+ maxWidth?: number;
65
67
  isPinned?: 'left' | 'right' | false;
66
68
  pinnedPosition?: number;
67
69
  pinnedRightPosition?: number;
@@ -2,5 +2,5 @@ import { DataTableColumn } from '../types';
2
2
  export interface SelectionColumnConfig<T> {
3
3
  multiSelect?: boolean;
4
4
  }
5
- export declare const createSelectionColumn: <T>(config: Partial<DataTableColumn<T>> & SelectionColumnConfig<T>) => DataTableColumn<T>;
5
+ export declare const createSelectionColumn: <T>(config: Partial<DataTableColumn<T>> & SelectionColumnConfig<T>) => DataTableColumn<T, any>;
6
6
  export declare const createExpandingColumn: <T>(config: Partial<DataTableColumn<T>>) => DataTableColumn<T>;
@@ -5,7 +5,7 @@ const icons_material_1 = require("@mui/icons-material");
5
5
  const material_1 = require("@mui/material");
6
6
  const react_1 = require("react");
7
7
  const types_1 = require("../types");
8
- const createSelectionColumn = (config) => (Object.assign({ id: types_1.DEFAULT_SELECTION_COLUMN_NAME, size: 60, align: 'center', filterable: false, enableResizing: false, enableSorting: false, enableHiding: false, enablePinning: false, hideInExport: true, header: ({ table }) => {
8
+ const createSelectionColumn = (config) => (Object.assign({ id: types_1.DEFAULT_SELECTION_COLUMN_NAME, size: 60, minSize: 60, align: 'center', filterable: false, enableResizing: false, enableSorting: false, enableHiding: false, enablePinning: false, hideInExport: true, header: ({ table }) => {
9
9
  var _a, _b;
10
10
  if (!config.multiSelect)
11
11
  return null;
@@ -44,7 +44,7 @@ const createSelectionColumn = (config) => (Object.assign({ id: types_1.DEFAULT_S
44
44
  });
45
45
  } }, config));
46
46
  exports.createSelectionColumn = createSelectionColumn;
47
- const createExpandingColumn = (config) => (Object.assign({ id: types_1.DEFAULT_EXPANDING_COLUMN_NAME, size: 60, align: 'center', filterable: false, enableResizing: false, enableSorting: false, enableHiding: false, enablePinning: false, hideInExport: true, header: '', cell: ({ row }) => (0, react_1.createElement)(material_1.IconButton, {
47
+ const createExpandingColumn = (config) => (Object.assign({ id: types_1.DEFAULT_EXPANDING_COLUMN_NAME, size: 60, minSize: 60, align: 'center', filterable: false, enableResizing: false, enableSorting: false, enableHiding: false, enablePinning: false, hideInExport: true, header: '', cell: ({ row }) => (0, react_1.createElement)(material_1.IconButton, {
48
48
  onClick: row.getToggleExpandedHandler(),
49
49
  size: 'small',
50
50
  sx: { p: 0 },
@@ -1,14 +1,19 @@
1
1
  import type { DataTableColumn, PinnedColumnStyleOptions } from '../types';
2
2
  export declare function getPinnedColumnStyle(options: PinnedColumnStyleOptions): {
3
- boxShadow: string;
4
3
  backgroundColor: string;
4
+ backgroundClip: string;
5
+ boxShadow: string;
6
+ willChange: string;
7
+ transform: string;
5
8
  left?: number;
6
9
  right?: number;
7
10
  zIndex?: number;
8
- width: string | number;
9
- maxWidth: string | number;
10
11
  overflow: string;
11
12
  whiteSpace: string;
13
+ textOverflow: string;
14
+ maxWidth?: string | number;
15
+ minWidth: number;
16
+ width: string | number;
12
17
  };
13
18
  export declare const tableCellStyles: {
14
19
  readonly sticky: {
@@ -13,9 +13,9 @@ const getBoxShadow = (isPinned, isLastLeftPinnedColumn, isFirstRightPinnedColumn
13
13
  return 'none';
14
14
  };
15
15
  function getPinnedColumnStyle(options) {
16
- const { width = 'auto', isPinned, pinnedPosition, pinnedRightPosition, isLastLeftPinnedColumn, isFirstRightPinnedColumn, zIndex = 1, disableStickyHeader = false, } = options;
16
+ const { width = 'auto', minWidth, maxWidth, isPinned, pinnedPosition, pinnedRightPosition, isLastLeftPinnedColumn, isFirstRightPinnedColumn, zIndex = 1, disableStickyHeader = false, } = options;
17
17
  const needsPinnedPositioning = isPinned;
18
- const shouldBeSticky = isPinned;
18
+ const shouldBeSticky = !!isPinned;
19
19
  let positionStyle = {};
20
20
  if (shouldBeSticky) {
21
21
  positionStyle = { position: 'sticky' };
@@ -23,13 +23,15 @@ function getPinnedColumnStyle(options) {
23
23
  else if (!disableStickyHeader) {
24
24
  positionStyle = { position: 'relative' };
25
25
  }
26
- return Object.assign(Object.assign(Object.assign(Object.assign({ width, maxWidth: width, overflow: 'hidden', whiteSpace: 'nowrap' }, positionStyle), (needsPinnedPositioning ? {
26
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ width }, (minWidth !== undefined && { minWidth })), (maxWidth !== undefined ? { maxWidth } : width !== 'auto' ? { maxWidth: width } : {})), { overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }), positionStyle), (needsPinnedPositioning ? {
27
27
  left: isPinned === 'left' ? pinnedPosition : undefined,
28
28
  right: isPinned === 'right' ? pinnedRightPosition : undefined,
29
29
  zIndex,
30
- } : {})), (isPinned && {
31
- backgroundColor: 'background.paper',
32
- })), { boxShadow: getBoxShadow(isPinned, !!isLastLeftPinnedColumn, !!isFirstRightPinnedColumn) });
30
+ } : {})), { backgroundColor: isPinned ? 'background.paper' : 'var(--row-bg, var(--mui-palette-background-paper))', backgroundClip: 'padding-box', boxShadow: isPinned === 'left' && isLastLeftPinnedColumn
31
+ ? 'inset -1px 0 0 var(--palette-TableCell-border), 6px 0 6px -4px rgba(0,0,0,.18)'
32
+ : isPinned === 'right' && isFirstRightPinnedColumn
33
+ ? 'inset 1px 0 0 var(--palette-TableCell-border), -6px 0 6px -4px rgba(0,0,0,.18)'
34
+ : undefined, willChange: 'transform', transform: 'translateZ(0)' });
33
35
  }
34
36
  exports.tableCellStyles = {
35
37
  sticky: {