material-react-table 1.7.3 → 1.8.0

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 (54) hide show
  1. package/README.md +5 -13
  2. package/dist/cjs/index.js +110 -72
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/types/MaterialReactTable.d.ts +22 -8
  5. package/dist/cjs/types/body/MRT_TableBody.d.ts +3 -4
  6. package/dist/cjs/types/body/MRT_TableBodyCell.d.ts +2 -3
  7. package/dist/cjs/types/body/MRT_TableBodyRow.d.ts +4 -5
  8. package/dist/cjs/types/body/MRT_TableDetailPanel.d.ts +2 -3
  9. package/dist/cjs/types/column.utils.d.ts +3 -2
  10. package/dist/cjs/types/footer/MRT_TableFooter.d.ts +2 -3
  11. package/dist/cjs/types/footer/MRT_TableFooterRow.d.ts +2 -3
  12. package/dist/cjs/types/head/MRT_TableHead.d.ts +2 -3
  13. package/dist/cjs/types/head/MRT_TableHeadRow.d.ts +2 -3
  14. package/dist/cjs/types/icons.d.ts +0 -1
  15. package/dist/cjs/types/table/MRT_TableRoot.d.ts +1 -272
  16. package/dist/esm/material-react-table.esm.js +108 -72
  17. package/dist/esm/material-react-table.esm.js.map +1 -1
  18. package/dist/esm/types/MaterialReactTable.d.ts +22 -8
  19. package/dist/esm/types/body/MRT_TableBody.d.ts +3 -4
  20. package/dist/esm/types/body/MRT_TableBodyCell.d.ts +2 -3
  21. package/dist/esm/types/body/MRT_TableBodyRow.d.ts +4 -5
  22. package/dist/esm/types/body/MRT_TableDetailPanel.d.ts +2 -3
  23. package/dist/esm/types/column.utils.d.ts +3 -2
  24. package/dist/esm/types/footer/MRT_TableFooter.d.ts +2 -3
  25. package/dist/esm/types/footer/MRT_TableFooterRow.d.ts +2 -3
  26. package/dist/esm/types/head/MRT_TableHead.d.ts +2 -3
  27. package/dist/esm/types/head/MRT_TableHeadRow.d.ts +2 -3
  28. package/dist/esm/types/icons.d.ts +0 -1
  29. package/dist/esm/types/table/MRT_TableRoot.d.ts +1 -272
  30. package/dist/index.d.ts +22 -8
  31. package/package.json +13 -14
  32. package/src/MaterialReactTable.tsx +50 -7
  33. package/src/body/MRT_TableBody.tsx +11 -10
  34. package/src/body/MRT_TableBodyCell.tsx +11 -13
  35. package/src/body/MRT_TableBodyCellValue.tsx +1 -0
  36. package/src/body/MRT_TableBodyRow.tsx +14 -7
  37. package/src/body/MRT_TableDetailPanel.tsx +2 -3
  38. package/src/buttons/MRT_ExpandAllButton.tsx +10 -8
  39. package/src/buttons/MRT_ExpandButton.tsx +10 -8
  40. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +4 -1
  41. package/src/column.utils.ts +16 -6
  42. package/src/footer/MRT_TableFooter.tsx +2 -3
  43. package/src/footer/MRT_TableFooterRow.tsx +7 -3
  44. package/src/head/MRT_TableHead.tsx +2 -3
  45. package/src/head/MRT_TableHeadCell.tsx +1 -0
  46. package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +1 -1
  47. package/src/head/MRT_TableHeadCellResizeHandle.tsx +2 -5
  48. package/src/head/MRT_TableHeadRow.tsx +7 -3
  49. package/src/icons.ts +0 -3
  50. package/src/inputs/MRT_EditCellTextField.tsx +38 -2
  51. package/src/menus/MRT_FilterOptionMenu.tsx +14 -5
  52. package/src/menus/MRT_RowActionMenu.tsx +12 -10
  53. package/src/table/MRT_Table.tsx +6 -5
  54. package/src/table/MRT_TableRoot.tsx +33 -19
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.3",
2
+ "version": "1.8.0",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
@@ -34,7 +34,7 @@
34
34
  "size-limit": [
35
35
  {
36
36
  "path": "dist/cjs/index.js",
37
- "limit": "50 KB"
37
+ "limit": "54 KB"
38
38
  },
39
39
  {
40
40
  "path": "dist/esm/material-react-table.esm.js",
@@ -46,7 +46,6 @@
46
46
  },
47
47
  "scripts": {
48
48
  "build": "rm -rf dist && rollup -c && size-limit",
49
- "dev": "rm -rf dist && rollup -c -w",
50
49
  "lib:build": "rm -rf dist && rollup -c && size-limit",
51
50
  "lib:dev": "rm -rf dist && rollup -c -w",
52
51
  "lint": "eslint .",
@@ -58,17 +57,17 @@
58
57
  "@emotion/react": "^11.10.5",
59
58
  "@emotion/styled": "^11.10.5",
60
59
  "@mui/icons-material": "^5.11.0",
61
- "@mui/material": "^5.11.4",
60
+ "@mui/material": "^5.11.8",
62
61
  "@rollup/plugin-babel": "^6.0.3",
63
62
  "@rollup/plugin-node-resolve": "^15.0.1",
64
63
  "@rollup/plugin-typescript": "^11.0.0",
65
- "@size-limit/preset-small-lib": "^8.1.0",
66
- "@types/node": "^18.11.18",
67
- "@types/react": "^18.0.26",
64
+ "@size-limit/preset-small-lib": "^8.1.2",
65
+ "@types/node": "^18.13.0",
66
+ "@types/react": "^18.0.28",
68
67
  "@types/react-dom": "^18.0.10",
69
- "@typescript-eslint/eslint-plugin": "^5.48.1",
70
- "@typescript-eslint/parser": "^5.48.1",
71
- "eslint": "^8.31.0",
68
+ "@typescript-eslint/eslint-plugin": "^5.51.0",
69
+ "@typescript-eslint/parser": "^5.51.0",
70
+ "eslint": "^8.34.0",
72
71
  "eslint-plugin-mui-path-imports": "^0.0.9",
73
72
  "react": "^18.2.0",
74
73
  "react-dom": "^18.2.0",
@@ -77,9 +76,9 @@
77
76
  "rollup-plugin-copy": "^3.4.0",
78
77
  "rollup-plugin-dts": "^5.1.1",
79
78
  "rollup-plugin-peer-deps-external": "^2.2.4",
80
- "size-limit": "^8.1.0",
81
- "tslib": "^2.4.1",
82
- "typescript": "^4.9.4"
79
+ "size-limit": "^8.1.2",
80
+ "tslib": "^2.5.0",
81
+ "typescript": "^4.9.5"
83
82
  },
84
83
  "peerDependencies": {
85
84
  "@emotion/react": ">=11",
@@ -92,7 +91,7 @@
92
91
  "dependencies": {
93
92
  "@tanstack/match-sorter-utils": "8.7.6",
94
93
  "@tanstack/react-table": "8.7.9",
95
- "@tanstack/react-virtual": "3.0.0-beta.30",
94
+ "@tanstack/react-virtual": "3.0.0-beta.47",
96
95
  "highlight-words": "1.2.1"
97
96
  }
98
97
  }
@@ -29,18 +29,33 @@ import type {
29
29
  Cell,
30
30
  Column,
31
31
  ColumnDef,
32
+ ColumnFiltersState,
33
+ ColumnOrderState,
34
+ ColumnPinningState,
35
+ ColumnSizingInfoState,
36
+ ColumnSizingState,
32
37
  DeepKeys,
38
+ ExpandedState,
33
39
  FilterFn,
40
+ GroupingState,
34
41
  Header,
35
42
  HeaderGroup,
36
43
  OnChangeFn,
44
+ PaginationState,
37
45
  Row,
46
+ RowSelectionState,
38
47
  SortingFn,
48
+ SortingState,
39
49
  Table,
40
50
  TableOptions,
41
51
  TableState,
52
+ VisibilityState,
42
53
  } from '@tanstack/react-table';
43
- import type { VirtualizerOptions, Virtualizer } from '@tanstack/react-virtual';
54
+ import type {
55
+ VirtualizerOptions,
56
+ Virtualizer,
57
+ VirtualItem,
58
+ } from '@tanstack/react-virtual';
44
59
  import { MRT_AggregationFns } from './aggregationFns';
45
60
  import { MRT_DefaultColumn, MRT_DefaultDisplayColumn } from './column.utils';
46
61
  import { MRT_FilterFns } from './filterFns';
@@ -49,11 +64,30 @@ import { MRT_SortingFns } from './sortingFns';
49
64
  import { MRT_TableRoot } from './table/MRT_TableRoot';
50
65
  import { MRT_Localization_EN } from './_locales/en';
51
66
 
67
+ export { MRT_AggregationFns, MRT_FilterFns, MRT_SortingFns };
68
+
52
69
  /**
53
70
  * Most of this file is just TypeScript types
54
71
  */
55
72
 
56
- export type DensityState = 'comfortable' | 'compact' | 'spacious';
73
+ export type MRT_DensityState = 'comfortable' | 'compact' | 'spacious';
74
+
75
+ export type {
76
+ ColumnFiltersState as MRT_ColumnFiltersState,
77
+ ColumnOrderState as MRT_ColumnOrderState,
78
+ ColumnPinningState as MRT_ColumnPinningState,
79
+ ColumnSizingInfoState as MRT_ColumnSizingInfoState,
80
+ ColumnSizingState as MRT_ColumnSizingState,
81
+ ExpandedState as MRT_ExpandedState,
82
+ GroupingState as MRT_GroupingState,
83
+ PaginationState as MRT_PaginationState,
84
+ RowSelectionState as MRT_RowSelectionState,
85
+ SortingState as MRT_SortingState,
86
+ VirtualItem as MRT_VirtualItem,
87
+ Virtualizer as MRT_Virtualizer,
88
+ VirtualizerOptions as MRT_VirtualizerOptions,
89
+ VisibilityState as MRT_VisibilityState,
90
+ };
57
91
 
58
92
  type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
59
93
 
@@ -206,7 +240,7 @@ export type MRT_TableInstance<TData extends Record<string, any> = {}> = Omit<
206
240
  setColumnFilterFns: Dispatch<
207
241
  SetStateAction<{ [key: string]: MRT_FilterOption }>
208
242
  >;
209
- setDensity: Dispatch<SetStateAction<DensityState>>;
243
+ setDensity: Dispatch<SetStateAction<MRT_DensityState>>;
210
244
  setDraggingColumn: Dispatch<SetStateAction<MRT_Column<TData> | null>>;
211
245
  setDraggingRow: Dispatch<SetStateAction<MRT_Row<TData> | null>>;
212
246
  setEditingCell: Dispatch<SetStateAction<MRT_Cell<TData> | null>>;
@@ -228,7 +262,7 @@ export type MRT_TableInstance<TData extends Record<string, any> = {}> = Omit<
228
262
  export type MRT_TableState<TData extends Record<string, any> = {}> =
229
263
  TableState & {
230
264
  columnFilterFns: Record<string, MRT_FilterOption>;
231
- density: DensityState;
265
+ density: MRT_DensityState;
232
266
  draggingColumn: MRT_Column<TData> | null;
233
267
  draggingRow: MRT_Row<TData> | null;
234
268
  editingCell: MRT_Cell<TData> | null;
@@ -304,6 +338,12 @@ export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
304
338
  header: MRT_Header<TData>;
305
339
  table: MRT_TableInstance<TData>;
306
340
  }) => ReactNode);
341
+ PlaceholderCell?: (props: {
342
+ cell: MRT_Cell<TData>;
343
+ column: MRT_Column<TData>;
344
+ row: MRT_Row<TData>;
345
+ table: MRT_TableInstance<TData>;
346
+ }) => ReactNode;
307
347
  /**
308
348
  * Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
309
349
  * Specify a function here to point to the correct property in the data object.
@@ -334,12 +374,15 @@ export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
334
374
  LiteralUnion<string & MRT_FilterOption>
335
375
  > | null;
336
376
  columns?: MRT_ColumnDef<TData>[];
377
+ editSelectOptions?: (string | { text: string; value: any })[];
378
+ editVariant?: 'text' | 'select';
337
379
  enableClickToCopy?: boolean;
338
380
  enableColumnActions?: boolean;
339
381
  enableColumnDragging?: boolean;
340
382
  enableColumnFilterModes?: boolean;
341
383
  enableColumnOrdering?: boolean;
342
- enableEditing?: boolean;
384
+ enableEditing?: boolean | ((row: MRT_Row<TData>) => boolean);
385
+ enableFilterMatchHighlighting?: boolean;
343
386
  filterFn?: MRT_FilterFn<TData>;
344
387
  filterSelectOptions?: (string | { text: string; value: any })[];
345
388
  filterVariant?: 'text' | 'select' | 'multi-select' | 'range' | 'checkbox';
@@ -588,7 +631,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
588
631
  enableColumnOrdering?: boolean;
589
632
  enableColumnVirtualization?: boolean;
590
633
  enableDensityToggle?: boolean;
591
- enableEditing?: boolean;
634
+ enableEditing?: boolean | ((row: MRT_Row<TData>) => boolean);
592
635
  enableExpandAll?: boolean;
593
636
  enableFilterMatchHighlighting?: boolean;
594
637
  enableFullScreenToggle?: boolean;
@@ -798,7 +841,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
798
841
  muiTopToolbarProps?:
799
842
  | ToolbarProps
800
843
  | ((props: { table: MRT_TableInstance<TData> }) => ToolbarProps);
801
- onDensityChange?: OnChangeFn<DensityState>;
844
+ onDensityChange?: OnChangeFn<MRT_DensityState>;
802
845
  onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
803
846
  onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
804
847
  onEditingCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
@@ -1,19 +1,20 @@
1
1
  import React, { memo, useMemo } from 'react';
2
- import {
3
- useVirtualizer,
4
- Virtualizer,
5
- VirtualItem,
6
- } from '@tanstack/react-virtual';
2
+ import { useVirtualizer } from '@tanstack/react-virtual';
7
3
  import TableBody from '@mui/material/TableBody';
8
4
  import Typography from '@mui/material/Typography';
9
5
  import { Memo_MRT_TableBodyRow, MRT_TableBodyRow } from './MRT_TableBodyRow';
10
6
  import { rankGlobalFuzzy } from '../sortingFns';
11
- import type { MRT_Row, MRT_TableInstance } from '..';
7
+ import type {
8
+ MRT_Row,
9
+ MRT_TableInstance,
10
+ MRT_VirtualItem,
11
+ MRT_Virtualizer,
12
+ } from '..';
12
13
 
13
14
  interface Props {
14
- columnVirtualizer?: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
15
+ columnVirtualizer?: MRT_Virtualizer<HTMLDivElement, HTMLTableCellElement>;
15
16
  table: MRT_TableInstance;
16
- virtualColumns?: VirtualItem[];
17
+ virtualColumns?: MRT_VirtualItem[];
17
18
  virtualPaddingLeft?: number;
18
19
  virtualPaddingRight?: number;
19
20
  }
@@ -116,7 +117,7 @@ export const MRT_TableBody = ({
116
117
  ]);
117
118
 
118
119
  const rowVirtualizer:
119
- | Virtualizer<HTMLDivElement, HTMLTableRowElement>
120
+ | MRT_Virtualizer<HTMLDivElement, HTMLTableRowElement>
120
121
  | undefined = enableRowVirtualization
121
122
  ? useVirtualizer({
122
123
  count: rows.length,
@@ -201,7 +202,7 @@ export const MRT_TableBody = ({
201
202
  virtualPaddingLeft,
202
203
  virtualPaddingRight,
203
204
  virtualRow: rowVirtualizer
204
- ? (rowOrVirtualRow as VirtualItem)
205
+ ? (rowOrVirtualRow as MRT_VirtualItem)
205
206
  : undefined,
206
207
  };
207
208
  return memoMode === 'rows' ? (
@@ -19,8 +19,7 @@ import {
19
19
  getIsFirstColumn,
20
20
  getIsLastColumn,
21
21
  } from '../column.utils';
22
- import type { VirtualItem } from '@tanstack/react-virtual';
23
- import type { MRT_Cell, MRT_TableInstance } from '..';
22
+ import type { MRT_Cell, MRT_TableInstance, MRT_VirtualItem } from '..';
24
23
 
25
24
  interface Props {
26
25
  cell: MRT_Cell;
@@ -30,7 +29,7 @@ interface Props {
30
29
  rowIndex: number;
31
30
  rowRef: RefObject<HTMLTableRowElement>;
32
31
  table: MRT_TableInstance;
33
- virtualCell?: VirtualItem;
32
+ virtualCell?: MRT_VirtualItem;
34
33
  }
35
34
 
36
35
  export const MRT_TableBodyCell = ({
@@ -153,8 +152,10 @@ export const MRT_TableBodyCell = ({
153
152
  }, [draggingColumn, draggingRow, hoveredColumn, hoveredRow, rowIndex]);
154
153
 
155
154
  const isEditable =
156
- (enableEditing || columnDef.enableEditing) &&
157
- columnDef.enableEditing !== false;
155
+ (enableEditing instanceof Function ? enableEditing(row) : enableEditing) &&
156
+ (columnDef.enableEditing instanceof Function
157
+ ? columnDef.enableEditing(row)
158
+ : columnDef.enableEditing) !== false;
158
159
 
159
160
  const isEditing =
160
161
  isEditable &&
@@ -166,11 +167,7 @@ export const MRT_TableBodyCell = ({
166
167
 
167
168
  const handleDoubleClick = (event: MouseEvent<HTMLTableCellElement>) => {
168
169
  tableCellProps?.onDoubleClick?.(event);
169
- if (
170
- (enableEditing || columnDef.enableEditing) &&
171
- columnDef.enableEditing !== false &&
172
- editingMode === 'cell'
173
- ) {
170
+ if (isEditable && editingMode === 'cell') {
174
171
  setEditingCell(cell);
175
172
  queueMicrotask(() => {
176
173
  const textField = editInputRefs.current[column.id];
@@ -241,8 +238,7 @@ export const MRT_TableBodyCell = ({
241
238
  '&:hover': {
242
239
  backgroundColor:
243
240
  enableHover &&
244
- enableEditing &&
245
- columnDef.enableEditing !== false &&
241
+ isEditable &&
246
242
  ['table', 'cell'].includes(editingMode ?? '')
247
243
  ? theme.palette.mode === 'dark'
248
244
  ? `${lighten(theme.palette.background.default, 0.2)} !important`
@@ -259,7 +255,9 @@ export const MRT_TableBodyCell = ({
259
255
  })}
260
256
  >
261
257
  <>
262
- {cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (
258
+ {cell.getIsPlaceholder() ? (
259
+ columnDef.PlaceholderCell?.({ cell, column, row, table }) ?? null
260
+ ) : isLoading || showSkeletons ? (
263
261
  <Skeleton
264
262
  animation="wave"
265
263
  height={20}
@@ -48,6 +48,7 @@ export const MRT_TableBodyCellValue = ({ cell, table }: Props) => {
48
48
 
49
49
  if (
50
50
  enableFilterMatchHighlighting &&
51
+ columnDef.enableFilterMatchHighlighting !== false &&
51
52
  renderedCellValue &&
52
53
  allowedTypes.includes(typeof renderedCellValue) &&
53
54
  ((filterValue &&
@@ -3,20 +3,25 @@ import TableRow from '@mui/material/TableRow';
3
3
  import { darken, lighten } from '@mui/material/styles';
4
4
  import { Memo_MRT_TableBodyCell, MRT_TableBodyCell } from './MRT_TableBodyCell';
5
5
  import { MRT_TableDetailPanel } from './MRT_TableDetailPanel';
6
- import type { VirtualItem, Virtualizer } from '@tanstack/react-virtual';
7
- import type { MRT_Cell, MRT_Row, MRT_TableInstance } from '..';
6
+ import type {
7
+ MRT_Cell,
8
+ MRT_Row,
9
+ MRT_TableInstance,
10
+ MRT_VirtualItem,
11
+ MRT_Virtualizer,
12
+ } from '..';
8
13
 
9
14
  interface Props {
10
- columnVirtualizer?: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
15
+ columnVirtualizer?: MRT_Virtualizer<HTMLDivElement, HTMLTableCellElement>;
11
16
  measureElement?: (element: HTMLTableRowElement) => void;
12
17
  numRows: number;
13
18
  row: MRT_Row;
14
19
  rowIndex: number;
15
20
  table: MRT_TableInstance;
16
- virtualColumns?: VirtualItem[];
21
+ virtualColumns?: MRT_VirtualItem[];
17
22
  virtualPaddingLeft?: number;
18
23
  virtualPaddingRight?: number;
19
- virtualRow?: VirtualItem;
24
+ virtualRow?: MRT_VirtualItem;
20
25
  }
21
26
 
22
27
  export const MRT_TableBodyRow = ({
@@ -103,7 +108,9 @@ export const MRT_TableBodyRow = ({
103
108
  ) : null}
104
109
  {(virtualColumns ?? row.getVisibleCells()).map((cellOrVirtualCell) => {
105
110
  const cell = columnVirtualizer
106
- ? row.getVisibleCells()[(cellOrVirtualCell as VirtualItem).index]
111
+ ? row.getVisibleCells()[
112
+ (cellOrVirtualCell as MRT_VirtualItem).index
113
+ ]
107
114
  : (cellOrVirtualCell as MRT_Cell);
108
115
  const props = {
109
116
  cell,
@@ -115,7 +122,7 @@ export const MRT_TableBodyRow = ({
115
122
  rowRef,
116
123
  table,
117
124
  virtualCell: columnVirtualizer
118
- ? (cellOrVirtualCell as VirtualItem)
125
+ ? (cellOrVirtualCell as MRT_VirtualItem)
119
126
  : undefined,
120
127
  };
121
128
  return memoMode === 'cells' &&
@@ -3,14 +3,13 @@ import Collapse from '@mui/material/Collapse';
3
3
  import TableCell from '@mui/material/TableCell';
4
4
  import TableRow from '@mui/material/TableRow';
5
5
  import { lighten } from '@mui/material/styles';
6
- import type { VirtualItem } from '@tanstack/react-virtual';
7
- import type { MRT_Row, MRT_TableInstance } from '..';
6
+ import type { MRT_Row, MRT_TableInstance, MRT_VirtualItem } from '..';
8
7
 
9
8
  interface Props {
10
9
  parentRowRef: React.RefObject<HTMLTableRowElement>;
11
10
  row: MRT_Row;
12
11
  table: MRT_TableInstance;
13
- virtualRow?: VirtualItem;
12
+ virtualRow?: MRT_VirtualItem;
14
13
  }
15
14
 
16
15
  export const MRT_TableDetailPanel = ({
@@ -59,14 +59,16 @@ export const MRT_ExpandAllButton = ({ table }: Props) => {
59
59
  })}
60
60
  title={undefined}
61
61
  >
62
- <KeyboardDoubleArrowDownIcon
63
- style={{
64
- transform: `rotate(${
65
- isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0
66
- }deg)`,
67
- transition: 'transform 150ms',
68
- }}
69
- />
62
+ {iconButtonProps?.children ?? (
63
+ <KeyboardDoubleArrowDownIcon
64
+ style={{
65
+ transform: `rotate(${
66
+ isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0
67
+ }deg)`,
68
+ transition: 'transform 150ms',
69
+ }}
70
+ />
71
+ )}
70
72
  </IconButton>
71
73
  </span>
72
74
  </Tooltip>
@@ -61,14 +61,16 @@ export const MRT_ExpandButton = ({ row, table }: Props) => {
61
61
  })}
62
62
  title={undefined}
63
63
  >
64
- <ExpandMoreIcon
65
- style={{
66
- transform: `rotate(${
67
- !canExpand && !renderDetailPanel ? -90 : isExpanded ? -180 : 0
68
- }deg)`,
69
- transition: 'transform 150ms',
70
- }}
71
- />
64
+ {iconButtonProps?.children ?? (
65
+ <ExpandMoreIcon
66
+ style={{
67
+ transform: `rotate(${
68
+ !canExpand && !renderDetailPanel ? -90 : isExpanded ? -180 : 0
69
+ }deg)`,
70
+ transition: 'transform 150ms',
71
+ }}
72
+ />
73
+ )}
72
74
  </IconButton>
73
75
  </span>
74
76
  </Tooltip>
@@ -64,7 +64,10 @@ export const MRT_ToggleRowActionMenuButton = <
64
64
  <>{renderRowActions({ cell, row, table })}</>
65
65
  ) : row.id === editingRow?.id && editingMode === 'row' ? (
66
66
  <MRT_EditActionButtons row={row} table={table} />
67
- ) : !renderRowActionMenuItems && enableEditing ? (
67
+ ) : !renderRowActionMenuItems &&
68
+ (enableEditing instanceof Function
69
+ ? enableEditing(row)
70
+ : enableEditing) ? (
68
71
  <Tooltip placement="right" arrow title={localization.edit}>
69
72
  <IconButton
70
73
  aria-label={localization.edit}
@@ -16,6 +16,7 @@ import type {
16
16
  MRT_DefinedColumnDef,
17
17
  MRT_DisplayColumnIds,
18
18
  MRT_FilterOption,
19
+ MRT_Header,
19
20
  MRT_TableInstance,
20
21
  } from '.';
21
22
 
@@ -241,11 +242,13 @@ export const getTotalRight = (table: MRT_TableInstance, column: MRT_Column) => {
241
242
 
242
243
  export const getCommonCellStyles = ({
243
244
  column,
245
+ header,
244
246
  table,
245
247
  tableCellProps,
246
248
  theme,
247
249
  }: {
248
250
  column: MRT_Column;
251
+ header?: MRT_Header;
249
252
  table: MRT_TableInstance;
250
253
  tableCellProps: TableCellProps;
251
254
  theme: Theme;
@@ -263,7 +266,7 @@ export const getCommonCellStyles = ({
263
266
  display: table.options.layoutMode === 'grid' ? 'flex' : 'table-cell',
264
267
  flex:
265
268
  table.options.layoutMode === 'grid'
266
- ? `var(--col-${parseCSSVarId(column.id)}-size) 0 auto`
269
+ ? `var(--col-${parseCSSVarId(header?.id ?? column.id)}-size) 0 auto`
267
270
  : undefined,
268
271
  left:
269
272
  column.getIsPinned() === 'left'
@@ -306,10 +309,12 @@ export const getCommonCellStyles = ({
306
309
  ...(tableCellProps?.sx instanceof Function
307
310
  ? tableCellProps.sx(theme)
308
311
  : (tableCellProps?.sx as any)),
309
- minWidth: `max(calc(var(--col-${parseCSSVarId(column.id)}-size) * 1px), ${
310
- column.columnDef.minSize ?? 30
311
- }px)`,
312
- width: `calc(var(--col-${parseCSSVarId(column.id)}-size) * 1px)`,
312
+ minWidth: `max(calc(var(--col-${parseCSSVarId(
313
+ header?.id ?? column.id,
314
+ )}-size) * 1px), ${column.columnDef.minSize ?? 30}px)`,
315
+ width: `calc(var(--col-${parseCSSVarId(
316
+ header?.id ?? column.id,
317
+ )}-size) * 1px)`,
313
318
  });
314
319
 
315
320
  export const MRT_DefaultColumn = {
@@ -335,4 +340,9 @@ export const MRT_DefaultDisplayColumn = {
335
340
  } as const;
336
341
 
337
342
  export const parseCSSVarId = (id: string) =>
338
- id.replaceAll('.', '_').replaceAll(' ', '_').replaceAll('+', '_');
343
+ id
344
+ .replaceAll('.', '_')
345
+ .replaceAll(' ', '_')
346
+ .replaceAll('+', '_')
347
+ .replaceAll('(', '_')
348
+ .replaceAll(')', '_');
@@ -1,12 +1,11 @@
1
1
  import React from 'react';
2
2
  import TableFooter from '@mui/material/TableFooter';
3
3
  import { MRT_TableFooterRow } from './MRT_TableFooterRow';
4
- import type { VirtualItem } from '@tanstack/react-virtual';
5
- import type { MRT_TableInstance } from '..';
4
+ import type { MRT_TableInstance, MRT_VirtualItem } from '..';
6
5
 
7
6
  interface Props {
8
7
  table: MRT_TableInstance;
9
- virtualColumns?: VirtualItem[];
8
+ virtualColumns?: MRT_VirtualItem[];
10
9
  virtualPaddingLeft?: number;
11
10
  virtualPaddingRight?: number;
12
11
  }
@@ -2,13 +2,17 @@ import React from 'react';
2
2
  import TableRow from '@mui/material/TableRow';
3
3
  import { lighten } from '@mui/material/styles';
4
4
  import { MRT_TableFooterCell } from './MRT_TableFooterCell';
5
- import { VirtualItem } from '@tanstack/react-virtual';
6
- import type { MRT_Header, MRT_HeaderGroup, MRT_TableInstance } from '..';
5
+ import type {
6
+ MRT_Header,
7
+ MRT_HeaderGroup,
8
+ MRT_TableInstance,
9
+ MRT_VirtualItem,
10
+ } from '..';
7
11
 
8
12
  interface Props {
9
13
  footerGroup: MRT_HeaderGroup;
10
14
  table: MRT_TableInstance;
11
- virtualColumns?: VirtualItem[];
15
+ virtualColumns?: MRT_VirtualItem[];
12
16
  virtualPaddingLeft?: number;
13
17
  virtualPaddingRight?: number;
14
18
  }
@@ -1,12 +1,11 @@
1
1
  import React from 'react';
2
2
  import TableHead from '@mui/material/TableHead';
3
3
  import { MRT_TableHeadRow } from './MRT_TableHeadRow';
4
- import type { VirtualItem } from '@tanstack/react-virtual';
5
- import type { MRT_TableInstance } from '..';
4
+ import type { MRT_TableInstance, MRT_VirtualItem } from '..';
6
5
 
7
6
  interface Props {
8
7
  table: MRT_TableInstance;
9
- virtualColumns?: VirtualItem[];
8
+ virtualColumns?: MRT_VirtualItem[];
10
9
  virtualPaddingLeft?: number;
11
10
  virtualPaddingRight?: number;
12
11
  }
@@ -165,6 +165,7 @@ export const MRT_TableHeadCell = ({ header, table }: Props) => {
165
165
  : 1,
166
166
  ...getCommonCellStyles({
167
167
  column,
168
+ header,
168
169
  table,
169
170
  tableCellProps,
170
171
  theme,
@@ -67,7 +67,7 @@ export const MRT_TableHeadCellColumnActionsButton = ({
67
67
  height: '2rem',
68
68
  m: '-8px -4px',
69
69
  opacity: 0.5,
70
- transform: 'scale(0.85)',
70
+ transform: 'scale(0.85) translateX(-4px)',
71
71
  transition: 'opacity 150ms',
72
72
  width: '2rem',
73
73
  '&:hover': {
@@ -14,10 +14,8 @@ export const MRT_TableHeadCellResizeHandle = ({ header, table }: Props) => {
14
14
  options: { columnResizeMode },
15
15
  setColumnSizingInfo,
16
16
  } = table;
17
- const { density, showColumnFilters } = getState();
17
+ const { density } = getState();
18
18
  const { column } = header;
19
- const { columnDef } = column;
20
- const { columnDefType } = columnDef;
21
19
 
22
20
  return (
23
21
  <Box
@@ -54,8 +52,7 @@ export const MRT_TableHeadCellResizeHandle = ({ header, table }: Props) => {
54
52
  sx={{
55
53
  borderRadius: '2px',
56
54
  borderWidth: '2px',
57
- height:
58
- showColumnFilters && columnDefType === 'data' ? '3.5rem' : '1.5rem',
55
+ height: '24px',
59
56
  touchAction: 'none',
60
57
  transition: column.getIsResizing()
61
58
  ? undefined
@@ -2,13 +2,17 @@ import React from 'react';
2
2
  import TableRow from '@mui/material/TableRow';
3
3
  import { alpha, lighten } from '@mui/material/styles';
4
4
  import { MRT_TableHeadCell } from './MRT_TableHeadCell';
5
- import type { VirtualItem } from '@tanstack/react-virtual';
6
- import type { MRT_Header, MRT_HeaderGroup, MRT_TableInstance } from '..';
5
+ import type {
6
+ MRT_Header,
7
+ MRT_HeaderGroup,
8
+ MRT_TableInstance,
9
+ MRT_VirtualItem,
10
+ } from '..';
7
11
 
8
12
  interface Props {
9
13
  headerGroup: MRT_HeaderGroup;
10
14
  table: MRT_TableInstance;
11
- virtualColumns?: VirtualItem[];
15
+ virtualColumns?: MRT_VirtualItem[];
12
16
  virtualPaddingLeft?: number;
13
17
  virtualPaddingRight?: number;
14
18
  }
package/src/icons.ts CHANGED
@@ -9,7 +9,6 @@ import DensitySmallIcon from '@mui/icons-material/DensitySmall';
9
9
  import DragHandleIcon from '@mui/icons-material/DragHandle';
10
10
  import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
11
11
  import EditIcon from '@mui/icons-material/Edit';
12
- import ExpandLessIcon from '@mui/icons-material/ExpandLess';
13
12
  import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
14
13
  import FilterAltIcon from '@mui/icons-material/FilterAlt';
15
14
  import FilterListIcon from '@mui/icons-material/FilterList';
@@ -41,7 +40,6 @@ export interface MRT_Icons {
41
40
  DragHandleIcon: any;
42
41
  DynamicFeedIcon: any;
43
42
  EditIcon: any;
44
- ExpandLessIcon: any;
45
43
  ExpandMoreIcon: any;
46
44
  FilterAltIcon: any;
47
45
  FilterListIcon: any;
@@ -72,7 +70,6 @@ export const MRT_Default_Icons: MRT_Icons = {
72
70
  DragHandleIcon,
73
71
  DynamicFeedIcon,
74
72
  EditIcon,
75
- ExpandLessIcon,
76
73
  ExpandMoreIcon,
77
74
  FilterAltIcon,
78
75
  FilterListIcon,