material-react-table 0.36.2 → 0.37.2

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 (40) hide show
  1. package/README.md +7 -3
  2. package/dist/cjs/MaterialReactTable.d.ts +34 -15
  3. package/dist/cjs/body/MRT_TableBodyCellValue.d.ts +8 -0
  4. package/dist/cjs/buttons/MRT_CopyButton.d.ts +5 -5
  5. package/dist/cjs/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -1
  6. package/dist/cjs/column.utils.d.ts +2 -1
  7. package/dist/cjs/index.d.ts +2 -1
  8. package/dist/cjs/index.js +172 -122
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/esm/MaterialReactTable.d.ts +34 -15
  11. package/dist/esm/body/MRT_TableBodyCellValue.d.ts +8 -0
  12. package/dist/esm/buttons/MRT_CopyButton.d.ts +5 -5
  13. package/dist/esm/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -1
  14. package/dist/esm/column.utils.d.ts +2 -1
  15. package/dist/esm/index.d.ts +2 -1
  16. package/dist/esm/material-react-table.esm.js +172 -123
  17. package/dist/esm/material-react-table.esm.js.map +1 -1
  18. package/dist/index.d.ts +42 -16
  19. package/package.json +4 -4
  20. package/src/MaterialReactTable.tsx +49 -11
  21. package/src/body/MRT_EditRowModal.tsx +21 -19
  22. package/src/body/MRT_TableBodyCell.tsx +12 -26
  23. package/src/body/MRT_TableBodyCellValue.tsx +27 -0
  24. package/src/body/MRT_TableBodyRow.tsx +1 -1
  25. package/src/body/MRT_TableBodyRowGrabHandle.tsx +3 -2
  26. package/src/buttons/MRT_CopyButton.tsx +11 -7
  27. package/src/buttons/MRT_EditActionButtons.tsx +13 -4
  28. package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -16
  29. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +9 -4
  30. package/src/column.utils.ts +15 -10
  31. package/src/head/MRT_TableHeadCell.tsx +3 -5
  32. package/src/index.tsx +2 -0
  33. package/src/inputs/MRT_EditCellTextField.tsx +16 -5
  34. package/src/inputs/MRT_FilterTextField.tsx +9 -6
  35. package/src/inputs/MRT_GlobalFilterTextField.tsx +7 -2
  36. package/src/menus/MRT_ColumnActionMenu.tsx +2 -12
  37. package/src/table/MRT_TableContainer.tsx +10 -10
  38. package/src/table/MRT_TableRoot.tsx +45 -27
  39. package/src/toolbar/MRT_BottomToolbar.tsx +9 -5
  40. package/src/toolbar/MRT_TopToolbar.tsx +8 -2
@@ -2,7 +2,7 @@ import React, { FC, MouseEvent, useState } from 'react';
2
2
  import { IconButton, Tooltip } from '@mui/material';
3
3
  import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
4
4
  import { MRT_EditActionButtons } from './MRT_EditActionButtons';
5
- import type { MRT_Row, MRT_TableInstance } from '..';
5
+ import type { MRT_Cell, MRT_Row, MRT_TableInstance } from '..';
6
6
 
7
7
  const commonIconButtonStyles = {
8
8
  height: '2rem',
@@ -16,11 +16,12 @@ const commonIconButtonStyles = {
16
16
  };
17
17
 
18
18
  interface Props {
19
+ cell: MRT_Cell
19
20
  row: MRT_Row;
20
21
  table: MRT_TableInstance;
21
22
  }
22
23
 
23
- export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row, table }) => {
24
+ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ cell, row, table }) => {
24
25
  const {
25
26
  getState,
26
27
  options: {
@@ -52,12 +53,16 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row, table }) => {
52
53
  return (
53
54
  <>
54
55
  {renderRowActions ? (
55
- <>{renderRowActions({ row, table })}</>
56
+ <>{renderRowActions({ cell, row, table })}</>
56
57
  ) : row.id === editingRow?.id && editingMode === 'row' ? (
57
58
  <MRT_EditActionButtons row={row} table={table} />
58
59
  ) : !renderRowActionMenuItems && enableEditing ? (
59
60
  <Tooltip placement="right" arrow title={localization.edit}>
60
- <IconButton sx={commonIconButtonStyles} onClick={handleStartEditMode}>
61
+ <IconButton
62
+ aria-label={localization.edit}
63
+ sx={commonIconButtonStyles}
64
+ onClick={handleStartEditMode}
65
+ >
61
66
  <EditIcon />
62
67
  </IconButton>
63
68
  </Tooltip>
@@ -1,4 +1,4 @@
1
- import { ColumnOrderState } from '@tanstack/react-table';
1
+ import { ColumnOrderState, GroupingState } from '@tanstack/react-table';
2
2
  import {
3
3
  MaterialReactTableProps,
4
4
  MRT_Column,
@@ -74,10 +74,9 @@ export const prepareColumns = <TData extends Record<string, any> = {}>(
74
74
  } else if (columnDef.columnDefType === 'data') {
75
75
  if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
76
76
  columnDef.filterFn =
77
- // @ts-ignore
78
77
  filterFns[columnFilterFns[columnDef.id]] ?? filterFns.fuzzy;
79
- //@ts-ignore
80
- columnDef._filterFn = columnFilterFns[columnDef.id];
78
+ (columnDef as MRT_DefinedColumnDef)._filterFn =
79
+ columnFilterFns[columnDef.id];
81
80
  }
82
81
  if (Object.keys(sortingFns).includes(columnDef.sortingFn as string)) {
83
82
  // @ts-ignore
@@ -108,6 +107,16 @@ export const reorderColumn = <TData extends Record<string, any> = {}>(
108
107
  return [...columnOrder];
109
108
  };
110
109
 
110
+ export const showExpandColumn = <TData extends Record<string, any> = {}>(
111
+ props: MaterialReactTableProps<TData>,
112
+ grouping?: GroupingState,
113
+ ) =>
114
+ !!(
115
+ props.enableExpanding ||
116
+ (props.enableGrouping && (grouping === undefined || grouping?.length)) ||
117
+ props.renderDetailPanel
118
+ );
119
+
111
120
  export const getLeadingDisplayColumnIds = <
112
121
  TData extends Record<string, any> = {},
113
122
  >(
@@ -120,9 +129,7 @@ export const getLeadingDisplayColumnIds = <
120
129
  ['row', 'modal'].includes(props.editingMode ?? ''))) &&
121
130
  'mrt-row-actions',
122
131
  props.positionExpandColumn === 'first' &&
123
- (props.enableExpanding ||
124
- props.enableGrouping ||
125
- props.renderDetailPanel) &&
132
+ showExpandColumn(props) &&
126
133
  'mrt-row-expand',
127
134
  props.enableRowSelection && 'mrt-row-select',
128
135
  props.enableRowNumbers && 'mrt-row-numbers',
@@ -138,9 +145,7 @@ export const getTrailingDisplayColumnIds = <
138
145
  ['row', 'modal'].includes(props.editingMode ?? ''))) &&
139
146
  'mrt-row-actions',
140
147
  props.positionExpandColumn === 'last' &&
141
- (props.enableExpanding ||
142
- props.enableGrouping ||
143
- props.renderDetailPanel) &&
148
+ showExpandColumn(props) &&
144
149
  'mrt-row-expand',
145
150
  ];
146
151
 
@@ -70,7 +70,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
70
70
  if (enableGrouping && hoveredColumn?.id === 'drop-zone') {
71
71
  setHoveredColumn(null);
72
72
  }
73
- if (enableColumnOrdering && draggingColumn) {
73
+ if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
74
74
  setHoveredColumn(
75
75
  columnDef.enableColumnOrdering !== false ? column : null,
76
76
  );
@@ -151,10 +151,8 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
151
151
  ? 'sticky'
152
152
  : undefined,
153
153
  pt:
154
- columnDefType === 'group'
155
- ? 0
156
- : density === 'compact'
157
- ? '0.25'
154
+ columnDefType === 'group' || density === 'compact'
155
+ ? '0.25rem'
158
156
  : density === 'comfortable'
159
157
  ? '.75rem'
160
158
  : '1.25rem',
package/src/index.tsx CHANGED
@@ -6,6 +6,7 @@ import type { MRT_Icons } from './icons';
6
6
  import type { MRT_Localization } from './localization';
7
7
  export type { MRT_Localization, MRT_Icons };
8
8
 
9
+ import { MRT_CopyButton } from './buttons/MRT_CopyButton';
9
10
  import { MRT_FullScreenToggleButton } from './buttons/MRT_FullScreenToggleButton';
10
11
  import { MRT_GlobalFilterTextField } from './inputs/MRT_GlobalFilterTextField';
11
12
  import { MRT_ShowHideColumnsButton } from './buttons/MRT_ShowHideColumnsButton';
@@ -20,4 +21,5 @@ export {
20
21
  MRT_ToggleDensePaddingButton,
21
22
  MRT_ToggleFiltersButton,
22
23
  MRT_ToggleGlobalFilterButton,
24
+ MRT_CopyButton,
23
25
  };
@@ -15,11 +15,12 @@ export const MRT_EditCellTextField = <TData extends Record<string, any> = {}>({
15
15
  }: Props<TData>) => {
16
16
  const {
17
17
  getState,
18
- options: { tableId, muiTableBodyCellEditTextFieldProps },
18
+ options: { muiTableBodyCellEditTextFieldProps },
19
+ refs: { editInputRefs },
19
20
  setEditingCell,
20
21
  setEditingRow,
21
22
  } = table;
22
- const { column } = cell;
23
+ const { column, row } = cell;
23
24
  const { columnDef } = column;
24
25
  const { editingRow } = getState();
25
26
 
@@ -27,13 +28,15 @@ export const MRT_EditCellTextField = <TData extends Record<string, any> = {}>({
27
28
 
28
29
  const mTableBodyCellEditTextFieldProps =
29
30
  muiTableBodyCellEditTextFieldProps instanceof Function
30
- ? muiTableBodyCellEditTextFieldProps({ cell, table })
31
+ ? muiTableBodyCellEditTextFieldProps({ cell, column, row, table })
31
32
  : muiTableBodyCellEditTextFieldProps;
32
33
 
33
34
  const mcTableBodyCellEditTextFieldProps =
34
35
  columnDef.muiTableBodyCellEditTextFieldProps instanceof Function
35
36
  ? columnDef.muiTableBodyCellEditTextFieldProps({
36
37
  cell,
38
+ column,
39
+ row,
37
40
  table,
38
41
  })
39
42
  : columnDef.muiTableBodyCellEditTextFieldProps;
@@ -60,21 +63,29 @@ export const MRT_EditCellTextField = <TData extends Record<string, any> = {}>({
60
63
  };
61
64
 
62
65
  if (columnDef.Edit) {
63
- return <>{columnDef.Edit?.({ cell, column, table })}</>;
66
+ return <>{columnDef.Edit?.({ cell, column, row, table })}</>;
64
67
  }
65
68
 
66
69
  return (
67
70
  <TextField
68
71
  disabled={columnDef.enableEditing === false}
69
72
  fullWidth
70
- id={`mrt-${tableId}-edit-cell-text-field-${cell.id}`}
71
73
  label={showLabel ? column.columnDef.header : undefined}
72
74
  margin="none"
75
+ name={cell.id}
73
76
  onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
74
77
  placeholder={columnDef.header}
75
78
  value={value}
76
79
  variant="standard"
77
80
  {...textFieldProps}
81
+ inputRef={(inputRef) => {
82
+ if (inputRef) {
83
+ editInputRefs.current[column.id] = inputRef;
84
+ if (textFieldProps.inputRef) {
85
+ textFieldProps.inputRef = inputRef;
86
+ }
87
+ }
88
+ }}
78
89
  onBlur={handleBlur}
79
90
  onChange={handleChange}
80
91
  />
@@ -40,8 +40,8 @@ export const MRT_FilterTextField: FC<Props> = ({
40
40
  icons: { FilterListIcon, CloseIcon },
41
41
  localization,
42
42
  muiTableHeadCellFilterTextFieldProps,
43
- tableId,
44
43
  },
44
+ refs: { filterInputRefs },
45
45
  setColumnFilterFns,
46
46
  } = table;
47
47
  const { column } = header;
@@ -80,9 +80,6 @@ export const MRT_FilterTextField: FC<Props> = ({
80
80
  (!isSelectFilter && !isMultiSelectFilter);
81
81
 
82
82
  const currentFilterOption = columnFilterFns?.[header.id];
83
- const filterId = `mrt-${tableId}-${header.id}-filter-text-field${
84
- rangeFilterIndex ?? ''
85
- }`;
86
83
  const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
87
84
  ? //@ts-ignore
88
85
  localization[
@@ -184,7 +181,6 @@ export const MRT_FilterTextField: FC<Props> = ({
184
181
  <>
185
182
  <TextField
186
183
  fullWidth
187
- id={filterId}
188
184
  inputProps={{
189
185
  disabled: !!filterChipLabel,
190
186
  sx: {
@@ -195,7 +191,7 @@ export const MRT_FilterTextField: FC<Props> = ({
195
191
  }}
196
192
  helperText={
197
193
  showChangeModeButton ? (
198
- <label htmlFor={filterId}>
194
+ <label>
199
195
  {localization.filterMode.replace(
200
196
  '{filterType}',
201
197
  // @ts-ignore
@@ -294,6 +290,13 @@ export const MRT_FilterTextField: FC<Props> = ({
294
290
  : undefined,
295
291
  }}
296
292
  {...textFieldProps}
293
+ inputRef={(inputRef) => {
294
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`] =
295
+ inputRef;
296
+ if (textFieldProps.inputRef) {
297
+ textFieldProps.inputRef = inputRef;
298
+ }
299
+ }}
297
300
  sx={(theme) => ({
298
301
  p: 0,
299
302
  minWidth: !filterChipLabel ? '6rem' : 'auto',
@@ -27,8 +27,8 @@ export const MRT_GlobalFilterTextField = <
27
27
  icons: { SearchIcon, CloseIcon },
28
28
  localization,
29
29
  muiSearchTextFieldProps,
30
- tableId,
31
30
  },
31
+ refs: { searchInputRef },
32
32
  } = table;
33
33
  const { globalFilter, showGlobalFilter } = getState();
34
34
 
@@ -64,7 +64,6 @@ export const MRT_GlobalFilterTextField = <
64
64
  return (
65
65
  <Collapse in={showGlobalFilter} orientation="horizontal">
66
66
  <TextField
67
- id={`mrt-${tableId}-search-text-field`}
68
67
  placeholder={localization.search}
69
68
  onChange={handleChange}
70
69
  value={searchValue ?? ''}
@@ -104,6 +103,12 @@ export const MRT_GlobalFilterTextField = <
104
103
  ),
105
104
  }}
106
105
  {...textFieldProps}
106
+ inputRef={(inputRef) => {
107
+ searchInputRef.current = inputRef;
108
+ if (textFieldProps?.inputRef) {
109
+ textFieldProps.inputRef = inputRef;
110
+ }
111
+ }}
107
112
  />
108
113
  <MRT_FilterOptionMenu
109
114
  anchorEl={anchorEl}
@@ -54,9 +54,9 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
54
54
  RestartAltIcon,
55
55
  VisibilityOffIcon,
56
56
  },
57
- tableId,
58
57
  localization,
59
58
  },
59
+ refs: { filterInputRefs },
60
60
  setShowFilters,
61
61
  } = table;
62
62
  const { column } = header;
@@ -111,17 +111,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
111
111
 
112
112
  const handleFilterByColumn = () => {
113
113
  setShowFilters(true);
114
- setTimeout(
115
- () =>
116
- document
117
- .getElementById(
118
- // @ts-ignore
119
- header.muiTableHeadCellFilterTextFieldProps?.id ??
120
- `mrt-${tableId}-${header.id}-filter-text-field`,
121
- )
122
- ?.focus(),
123
- 200,
124
- );
114
+ queueMicrotask(() => filterInputRefs.current[`${column.id}-0`]?.focus());
125
115
  setAnchorEl(null);
126
116
  };
127
117
 
@@ -3,7 +3,6 @@ import React, {
3
3
  RefObject,
4
4
  useEffect,
5
5
  useLayoutEffect,
6
- useRef,
7
6
  useState,
8
7
  } from 'react';
9
8
  import { TableContainer } from '@mui/material';
@@ -24,8 +23,8 @@ export const MRT_TableContainer: FC<Props> = ({ table }) => {
24
23
  enableStickyHeader,
25
24
  enableRowVirtualization,
26
25
  muiTableContainerProps,
27
- tableId,
28
26
  },
27
+ refs: { tableContainerRef, bottomToolbarRef, topToolbarRef },
29
28
  } = table;
30
29
  const { isFullScreen } = getState();
31
30
 
@@ -36,20 +35,15 @@ export const MRT_TableContainer: FC<Props> = ({ table }) => {
36
35
  ? muiTableContainerProps({ table })
37
36
  : muiTableContainerProps;
38
37
 
39
- const tableContainerRef =
40
- tableContainerProps?.ref ?? useRef<HTMLDivElement>(null);
41
-
42
38
  useIsomorphicLayoutEffect(() => {
43
39
  const topToolbarHeight =
44
40
  typeof document !== 'undefined'
45
- ? document?.getElementById(`mrt-${tableId}-toolbar-top`)
46
- ?.offsetHeight ?? 0
41
+ ? topToolbarRef.current?.offsetHeight ?? 0
47
42
  : 0;
48
43
 
49
44
  const bottomToolbarHeight =
50
45
  typeof document !== 'undefined'
51
- ? document?.getElementById(`mrt-${tableId}-toolbar-bottom`)
52
- ?.offsetHeight ?? 0
46
+ ? bottomToolbarRef?.current?.offsetHeight ?? 0
53
47
  : 0;
54
48
 
55
49
  setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
@@ -57,8 +51,14 @@ export const MRT_TableContainer: FC<Props> = ({ table }) => {
57
51
 
58
52
  return (
59
53
  <TableContainer
60
- ref={tableContainerRef}
61
54
  {...tableContainerProps}
55
+ ref={(ref: HTMLDivElement) => {
56
+ tableContainerRef.current = ref;
57
+ if (tableContainerProps?.ref) {
58
+ //@ts-ignore
59
+ tableContainerProps.ref.current = ref;
60
+ }
61
+ }}
62
62
  sx={(theme) => ({
63
63
  maxWidth: '100%',
64
64
  maxHeight:
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useMemo, useState } from 'react';
1
+ import React, { useMemo, useRef, useState } from 'react';
2
2
  import {
3
3
  TableState,
4
4
  getCoreRowModel,
@@ -9,6 +9,7 @@ import {
9
9
  getPaginationRowModel,
10
10
  getSortedRowModel,
11
11
  useReactTable,
12
+ GroupingState,
12
13
  } from '@tanstack/react-table';
13
14
  import { Box, Dialog, Grow } from '@mui/material';
14
15
  import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton';
@@ -22,6 +23,7 @@ import {
22
23
  getDefaultColumnOrderIds,
23
24
  getDefaultColumnFilterFn,
24
25
  defaultDisplayColumnDefOptions,
26
+ showExpandColumn,
25
27
  } from '../column.utils';
26
28
  import type {
27
29
  MRT_Cell,
@@ -38,12 +40,12 @@ import { MRT_EditRowModal } from '../body/MRT_EditRowModal';
38
40
  export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
39
41
  props: MaterialReactTableProps<TData>,
40
42
  ) => {
41
- const [tableId, setIdPrefix] = useState(props.tableId);
42
- useEffect(
43
- () =>
44
- setIdPrefix(props.tableId ?? Math.random().toString(36).substring(2, 9)),
45
- [props.tableId],
46
- );
43
+ const bottomToolbarRef = useRef<HTMLDivElement>(null);
44
+ const editInputRefs = useRef<Record<string, HTMLInputElement>>({});
45
+ const filterInputRefs = useRef<Record<string, HTMLInputElement>>({});
46
+ const searchInputRef = useRef<HTMLInputElement>(null);
47
+ const tableContainerRef = useRef<HTMLDivElement>(null);
48
+ const topToolbarRef = useRef<HTMLDivElement>(null);
47
49
 
48
50
  const initialState: Partial<MRT_TableState<TData>> = useMemo(() => {
49
51
  const initState = props.initialState ?? {};
@@ -95,6 +97,9 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
95
97
  const [globalFilterFn, setGlobalFilterFn] = useState<MRT_FilterOption>(
96
98
  initialState.globalFilterFn ?? 'fuzzy',
97
99
  );
100
+ const [grouping, setGrouping] = useState<GroupingState>(
101
+ initialState.grouping ?? [],
102
+ );
98
103
  const [hoveredColumn, setHoveredColumn] = useState<
99
104
  MRT_Column<TData> | { id: string } | null
100
105
  >(initialState.hoveredColumn ?? null);
@@ -126,9 +131,10 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
126
131
  id: 'mrt-row-drag',
127
132
  },
128
133
  columnOrder.includes('mrt-row-actions') && {
129
- Cell: ({ cell }) => (
134
+ Cell: ({ cell, row }) => (
130
135
  <MRT_ToggleRowActionMenuButton
131
- row={cell.row as any}
136
+ cell={cell as any}
137
+ row={row as any}
132
138
  table={table}
133
139
  />
134
140
  ),
@@ -138,23 +144,24 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
138
144
  ...props.displayColumnDefOptions?.['mrt-row-actions'],
139
145
  id: 'mrt-row-actions',
140
146
  },
141
- columnOrder.includes('mrt-row-expand') && {
142
- Cell: ({ cell }) => (
143
- <MRT_ExpandButton row={cell.row as any} table={table} />
144
- ),
145
- Header: () =>
146
- props.enableExpandAll ? (
147
- <MRT_ExpandAllButton table={table} />
148
- ) : null,
149
- header: props.localization?.expand,
150
- size: 60,
151
- ...defaultDisplayColumnDefOptions,
152
- ...props.displayColumnDefOptions?.['mrt-row-expand'],
153
- id: 'mrt-row-expand',
154
- },
147
+ columnOrder.includes('mrt-row-expand') &&
148
+ showExpandColumn(props, grouping) && {
149
+ Cell: ({ row }) => (
150
+ <MRT_ExpandButton row={row as any} table={table} />
151
+ ),
152
+ Header: () =>
153
+ props.enableExpandAll ? (
154
+ <MRT_ExpandAllButton table={table} />
155
+ ) : null,
156
+ header: props.localization?.expand,
157
+ size: 60,
158
+ ...defaultDisplayColumnDefOptions,
159
+ ...props.displayColumnDefOptions?.['mrt-row-expand'],
160
+ id: 'mrt-row-expand',
161
+ },
155
162
  columnOrder.includes('mrt-row-select') && {
156
- Cell: ({ cell }) => (
157
- <MRT_SelectCheckbox row={cell.row as any} table={table} />
163
+ Cell: ({ row }) => (
164
+ <MRT_SelectCheckbox row={row as any} table={table} />
158
165
  ),
159
166
  Header: () =>
160
167
  props.enableSelectAll ? (
@@ -167,7 +174,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
167
174
  id: 'mrt-row-select',
168
175
  },
169
176
  columnOrder.includes('mrt-row-numbers') && {
170
- Cell: ({ cell }) => cell.row.index + 1,
177
+ Cell: ({ row }) => row.index + 1,
171
178
  Header: () => props.localization?.rowNumber,
172
179
  header: props.localization?.rowNumbers,
173
180
  size: 60,
@@ -179,6 +186,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
179
186
  ).filter(Boolean),
180
187
  [
181
188
  columnOrder,
189
+ grouping,
182
190
  props.displayColumnDefOptions,
183
191
  props.editingMode,
184
192
  props.enableColumnDragging,
@@ -195,6 +203,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
195
203
  props.enableSelectAll,
196
204
  props.localization,
197
205
  props.positionActionsColumn,
206
+ props.renderDetailPanel,
198
207
  ],
199
208
  );
200
209
 
@@ -244,6 +253,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
244
253
  getPaginationRowModel: getPaginationRowModel(),
245
254
  getSortedRowModel: getSortedRowModel(),
246
255
  onColumnOrderChange: setColumnOrder,
256
+ onGroupingChange: setGrouping,
247
257
  getSubRows: (row) => row?.subRows,
248
258
  ...props,
249
259
  //@ts-ignore
@@ -261,6 +271,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
261
271
  editingCell,
262
272
  editingRow,
263
273
  globalFilterFn,
274
+ grouping,
264
275
  hoveredColumn,
265
276
  hoveredRow,
266
277
  isFullScreen,
@@ -269,8 +280,15 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
269
280
  showGlobalFilter,
270
281
  ...props.state,
271
282
  } as TableState,
272
- tableId,
273
283
  }),
284
+ refs: {
285
+ bottomToolbarRef,
286
+ editInputRefs,
287
+ filterInputRefs,
288
+ searchInputRef,
289
+ tableContainerRef,
290
+ topToolbarRef,
291
+ },
274
292
  setColumnFilterFns: props.onFilterFnsChange ?? setColumnFilterFns,
275
293
  setDensity: props.onDensityChange ?? setDensity,
276
294
  setDraggingColumn: props.onDraggingColumnChange ?? setDraggingColumn,
@@ -21,8 +21,8 @@ export const MRT_BottomToolbar: FC<Props> = ({ table }) => {
21
21
  positionToolbarAlertBanner,
22
22
  positionToolbarDropZone,
23
23
  renderBottomToolbarCustomActions,
24
- tableId,
25
24
  },
25
+ refs: { bottomToolbarRef },
26
26
  } = table;
27
27
  const { isFullScreen } = getState();
28
28
 
@@ -37,9 +37,15 @@ export const MRT_BottomToolbar: FC<Props> = ({ table }) => {
37
37
 
38
38
  return (
39
39
  <Toolbar
40
- id={`mrt-${tableId}-toolbar-bottom`}
41
40
  variant="dense"
42
41
  {...toolbarProps}
42
+ ref={(ref: HTMLDivElement) => {
43
+ bottomToolbarRef.current = ref;
44
+ if (toolbarProps?.ref) {
45
+ // @ts-ignore
46
+ toolbarProps.ref.current = ref;
47
+ }
48
+ }}
43
49
  sx={(theme) =>
44
50
  ({
45
51
  ...commonToolbarStyles({ theme }),
@@ -69,9 +75,7 @@ export const MRT_BottomToolbar: FC<Props> = ({ table }) => {
69
75
  }}
70
76
  >
71
77
  {renderBottomToolbarCustomActions ? (
72
- <Box sx={{ p: '0.5rem' }}>
73
- {renderBottomToolbarCustomActions({ table })}
74
- </Box>
78
+ renderBottomToolbarCustomActions({ table })
75
79
  ) : (
76
80
  <span />
77
81
  )}
@@ -37,8 +37,8 @@ export const MRT_TopToolbar: FC<Props> = ({ table }) => {
37
37
  positionToolbarAlertBanner,
38
38
  positionToolbarDropZone,
39
39
  renderTopToolbarCustomActions,
40
- tableId,
41
40
  },
41
+ refs: { topToolbarRef },
42
42
  } = table;
43
43
 
44
44
  const { isFullScreen, showGlobalFilter } = getState();
@@ -55,9 +55,15 @@ export const MRT_TopToolbar: FC<Props> = ({ table }) => {
55
55
 
56
56
  return (
57
57
  <Toolbar
58
- id={`mrt-${tableId}-toolbar-top`}
59
58
  variant="dense"
60
59
  {...toolbarProps}
60
+ ref={(ref: HTMLDivElement) => {
61
+ topToolbarRef.current = ref;
62
+ if (toolbarProps?.ref) {
63
+ // @ts-ignore
64
+ toolbarProps.ref.current = ref;
65
+ }
66
+ }}
61
67
  sx={(theme) =>
62
68
  ({
63
69
  position: isFullScreen ? 'sticky' : undefined,