material-react-table 2.7.0 → 2.9.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 (96) hide show
  1. package/dist/index.d.ts +253 -99
  2. package/dist/index.esm.js +3546 -3475
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +3567 -3498
  5. package/dist/index.js.map +1 -1
  6. package/locales/ja/index.esm.js +4 -4
  7. package/locales/ja/index.js +4 -4
  8. package/package.json +25 -23
  9. package/src/{MaterialReactTable.tsx → components/MaterialReactTable.tsx} +3 -3
  10. package/src/{body → components/body}/MRT_TableBody.tsx +6 -7
  11. package/src/{body → components/body}/MRT_TableBodyCell.tsx +16 -26
  12. package/src/{body → components/body}/MRT_TableBodyCellValue.tsx +2 -2
  13. package/src/{body → components/body}/MRT_TableBodyRow.tsx +79 -59
  14. package/src/{body → components/body}/MRT_TableBodyRowGrabHandle.tsx +3 -3
  15. package/src/{body → components/body}/MRT_TableBodyRowPinButton.tsx +3 -3
  16. package/src/{body → components/body}/MRT_TableDetailPanel.tsx +3 -3
  17. package/src/{buttons → components/buttons}/MRT_ColumnPinningButtons.tsx +2 -2
  18. package/src/{buttons → components/buttons}/MRT_CopyButton.tsx +3 -3
  19. package/src/{buttons → components/buttons}/MRT_EditActionButtons.tsx +2 -2
  20. package/src/{buttons → components/buttons}/MRT_ExpandAllButton.tsx +3 -3
  21. package/src/{buttons → components/buttons}/MRT_ExpandButton.tsx +6 -3
  22. package/src/{buttons → components/buttons}/MRT_GrabHandleButton.tsx +3 -3
  23. package/src/{buttons → components/buttons}/MRT_RowPinButton.tsx +3 -3
  24. package/src/{buttons → components/buttons}/MRT_ShowHideColumnsButton.tsx +1 -1
  25. package/src/{buttons → components/buttons}/MRT_ToggleDensePaddingButton.tsx +1 -1
  26. package/src/{buttons → components/buttons}/MRT_ToggleFiltersButton.tsx +1 -1
  27. package/src/{buttons → components/buttons}/MRT_ToggleFullScreenButton.tsx +1 -1
  28. package/src/{buttons → components/buttons}/MRT_ToggleGlobalFilterButton.tsx +1 -1
  29. package/src/{buttons → components/buttons}/MRT_ToggleRowActionMenuButton.tsx +4 -4
  30. package/src/{footer → components/footer}/MRT_TableFooter.tsx +2 -2
  31. package/src/{footer → components/footer}/MRT_TableFooterCell.tsx +13 -4
  32. package/src/{footer → components/footer}/MRT_TableFooterRow.tsx +22 -11
  33. package/src/{head → components/head}/MRT_TableHead.tsx +3 -3
  34. package/src/{head → components/head}/MRT_TableHeadCell.tsx +13 -3
  35. package/src/{head → components/head}/MRT_TableHeadCellColumnActionsButton.tsx +4 -4
  36. package/src/{head → components/head}/MRT_TableHeadCellFilterContainer.tsx +5 -5
  37. package/src/{head → components/head}/MRT_TableHeadCellFilterLabel.tsx +2 -2
  38. package/src/{head → components/head}/MRT_TableHeadCellGrabHandle.tsx +4 -3
  39. package/src/{head → components/head}/MRT_TableHeadCellResizeHandle.tsx +6 -4
  40. package/src/{head → components/head}/MRT_TableHeadCellSortLabel.tsx +2 -2
  41. package/src/{head → components/head}/MRT_TableHeadRow.tsx +22 -11
  42. package/src/{inputs → components/inputs}/MRT_EditCellTextField.tsx +15 -6
  43. package/src/{inputs → components/inputs}/MRT_FilterCheckbox.tsx +3 -3
  44. package/src/{inputs → components/inputs}/MRT_FilterRangeFields.tsx +2 -2
  45. package/src/{inputs → components/inputs}/MRT_FilterRangeSlider.tsx +2 -2
  46. package/src/{inputs → components/inputs}/MRT_FilterTextField.tsx +3 -3
  47. package/src/{inputs → components/inputs}/MRT_GlobalFilterTextField.tsx +2 -2
  48. package/src/{inputs → components/inputs}/MRT_SelectCheckbox.tsx +7 -9
  49. package/src/{menus → components/menus}/MRT_ColumnActionMenu.tsx +8 -8
  50. package/src/{menus → components/menus}/MRT_FilterOptionMenu.tsx +2 -2
  51. package/src/{menus → components/menus}/MRT_RowActionMenu.tsx +9 -9
  52. package/src/{menus → components/menus}/MRT_ShowHideColumnsMenu.tsx +5 -7
  53. package/src/{menus → components/menus}/MRT_ShowHideColumnsMenuItems.tsx +6 -5
  54. package/src/{modals → components/modals}/MRT_EditRowModal.tsx +4 -4
  55. package/src/{table → components/table}/MRT_Table.tsx +8 -4
  56. package/src/{table → components/table}/MRT_TableContainer.tsx +2 -2
  57. package/src/{table → components/table}/MRT_TableLoadingOverlay.tsx +3 -3
  58. package/src/{table → components/table}/MRT_TablePaper.tsx +3 -3
  59. package/src/{toolbar → components/toolbar}/MRT_BottomToolbar.tsx +3 -3
  60. package/src/{toolbar → components/toolbar}/MRT_LinearProgressBar.tsx +2 -2
  61. package/src/{toolbar → components/toolbar}/MRT_TablePagination.tsx +3 -3
  62. package/src/{toolbar → components/toolbar}/MRT_ToolbarAlertBanner.tsx +3 -3
  63. package/src/{toolbar → components/toolbar}/MRT_ToolbarDropZone.tsx +2 -2
  64. package/src/{toolbar → components/toolbar}/MRT_ToolbarInternalButtons.tsx +2 -2
  65. package/src/{toolbar → components/toolbar}/MRT_TopToolbar.tsx +3 -3
  66. package/src/{filterFns.ts → fns/filterFns.ts} +1 -1
  67. package/src/{sortingFns.ts → fns/sortingFns.ts} +1 -1
  68. package/src/hooks/display-columns/getMRT_DisplayColumns.tsx +26 -0
  69. package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +35 -0
  70. package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +36 -0
  71. package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +98 -0
  72. package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +37 -0
  73. package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +31 -0
  74. package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +41 -0
  75. package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +40 -0
  76. package/src/hooks/useMRT_ColumnVirtualizer.ts +79 -80
  77. package/src/hooks/useMRT_Effects.ts +1 -1
  78. package/src/hooks/useMRT_RowVirtualizer.ts +32 -36
  79. package/src/hooks/useMRT_Rows.ts +2 -2
  80. package/src/hooks/useMRT_TableInstance.ts +54 -39
  81. package/src/hooks/useMRT_TableOptions.ts +30 -20
  82. package/src/{useMaterialReactTable.ts → hooks/useMaterialReactTable.ts} +3 -3
  83. package/src/index.ts +79 -82
  84. package/src/locales/ja.ts +4 -4
  85. package/src/types.ts +57 -26
  86. package/src/utils/column.utils.ts +173 -0
  87. package/src/utils/displayColumn.utils.ts +134 -0
  88. package/src/utils/row.utils.ts +47 -0
  89. package/src/{style.utils.ts → utils/style.utils.ts} +88 -42
  90. package/src/utils/tanstack.helpers.ts +64 -0
  91. package/src/utils/utils.ts +23 -0
  92. package/src/utils/virtualization.utils.ts +19 -0
  93. package/src/utils.ts +0 -0
  94. package/src/column.utils.ts +0 -361
  95. package/src/hooks/useMRT_DisplayColumns.tsx +0 -290
  96. /package/src/{aggregationFns.ts → fns/aggregationFns.ts} +0 -0
@@ -75,10 +75,10 @@ const MRT_Localization_JA = {
75
75
  showHideColumns: '列の表示状態',
76
76
  showHideFilters: '検索バーを表示',
77
77
  showHideSearch: '検索',
78
- sortByColumnAsc: '{column}を昇順でを並べ替え',
79
- sortByColumnDesc: '{column}を降順でを並べ替え',
80
- sortedByColumnAsc: '{column}を昇順でを並べ替え',
81
- sortedByColumnDesc: '{column}を降順でを並べ替え',
78
+ sortByColumnAsc: '{column}を昇順で並べ替え',
79
+ sortByColumnDesc: '{column}を降順で並べ替え',
80
+ sortedByColumnAsc: '{column}を昇順で並べ替え',
81
+ sortedByColumnDesc: '{column}を降順で並べ替え',
82
82
  thenBy: 'さらに',
83
83
  toggleDensity: 'テーブルの高さを変更',
84
84
  toggleFullScreen: 'フルスクリーン切り替え',
@@ -79,10 +79,10 @@ const MRT_Localization_JA = {
79
79
  showHideColumns: '列の表示状態',
80
80
  showHideFilters: '検索バーを表示',
81
81
  showHideSearch: '検索',
82
- sortByColumnAsc: '{column}を昇順でを並べ替え',
83
- sortByColumnDesc: '{column}を降順でを並べ替え',
84
- sortedByColumnAsc: '{column}を昇順でを並べ替え',
85
- sortedByColumnDesc: '{column}を降順でを並べ替え',
82
+ sortByColumnAsc: '{column}を昇順で並べ替え',
83
+ sortByColumnDesc: '{column}を降順で並べ替え',
84
+ sortedByColumnAsc: '{column}を昇順で並べ替え',
85
+ sortedByColumnDesc: '{column}を降順で並べ替え',
86
86
  thenBy: 'さらに',
87
87
  toggleDensity: 'テーブルの高さを変更',
88
88
  toggleFullScreen: 'フルスクリーン切り替え',
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.7.0",
2
+ "version": "2.9.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.",
@@ -50,8 +50,8 @@
50
50
  "build-locales": "pnpm lib:build-locales",
51
51
  "build-lib": "pnpm lib:build-lib",
52
52
  "dev": "pnpm lib:dev",
53
- "lib:build": "rm -rf dist && pnpm build-lib && pnpm build-locales && rm -rf dist/types",
54
- "lib:build-locales": "rm -rf locales && node build-locales.mjs",
53
+ "lib:build": "pnpm build-lib && pnpm build-locales",
54
+ "lib:build-locales": "node build-locales.mjs",
55
55
  "lib:build-lib": "rm -rf dist && rollup -c rollup.config.mjs && size-limit",
56
56
  "lib:dev": "rollup -c rollup.config.mjs --watch",
57
57
  "lint": "eslint .",
@@ -66,25 +66,25 @@
66
66
  "@emotion/react": "^11.11.3",
67
67
  "@emotion/styled": "^11.11.0",
68
68
  "@faker-js/faker": "^8.3.1",
69
- "@mui/icons-material": "^5.15.4",
70
- "@mui/material": "^5.15.4",
69
+ "@mui/icons-material": "^5.15.5",
70
+ "@mui/material": "^5.15.5",
71
71
  "@mui/x-date-pickers": "^6.19.0",
72
72
  "@rollup/plugin-typescript": "^11.1.6",
73
- "@size-limit/preset-small-lib": "^11.0.1",
74
- "@storybook/addon-a11y": "^7.6.7",
75
- "@storybook/addon-essentials": "^7.6.7",
76
- "@storybook/addon-interactions": "^7.6.7",
77
- "@storybook/addon-links": "^7.6.7",
78
- "@storybook/addon-storysource": "^7.6.7",
79
- "@storybook/blocks": "^7.6.7",
80
- "@storybook/react": "^7.6.7",
81
- "@storybook/react-vite": "^7.6.7",
73
+ "@size-limit/preset-small-lib": "^11.0.2",
74
+ "@storybook/addon-a11y": "^7.6.10",
75
+ "@storybook/addon-essentials": "^7.6.10",
76
+ "@storybook/addon-interactions": "^7.6.10",
77
+ "@storybook/addon-links": "^7.6.10",
78
+ "@storybook/addon-storysource": "^7.6.10",
79
+ "@storybook/blocks": "^7.6.10",
80
+ "@storybook/react": "^7.6.10",
81
+ "@storybook/react-vite": "^7.6.10",
82
82
  "@storybook/testing-library": "^0.2.2",
83
- "@types/node": "^20.11.0",
84
- "@types/react": "^18.2.47",
83
+ "@types/node": "^20.11.5",
84
+ "@types/react": "^18.2.48",
85
85
  "@types/react-dom": "^18.2.18",
86
- "@typescript-eslint/eslint-plugin": "^6.18.1",
87
- "@typescript-eslint/parser": "^6.18.1",
86
+ "@typescript-eslint/eslint-plugin": "^6.19.0",
87
+ "@typescript-eslint/parser": "^6.19.0",
88
88
  "@vitejs/plugin-react": "^4.2.1",
89
89
  "eslint": "^8.56.0",
90
90
  "eslint-plugin-mui-path-imports": "^0.0.15",
@@ -94,14 +94,16 @@
94
94
  "react-dom": "^18.2.0",
95
95
  "react-is": "^18.2.0",
96
96
  "rollup": "^2.79.1",
97
+ "rollup-plugin-copy": "^3.5.0",
98
+ "rollup-plugin-delete": "^2.0.0",
97
99
  "rollup-plugin-dts": "^6.1.0",
98
100
  "rollup-plugin-peer-deps-external": "^2.2.4",
99
- "size-limit": "^11.0.1",
100
- "storybook": "^7.6.7",
101
+ "size-limit": "^11.0.2",
102
+ "storybook": "^7.6.10",
101
103
  "storybook-dark-mode": "^3.0.3",
102
104
  "tslib": "^2.6.2",
103
105
  "typescript": "^5.3.3",
104
- "vite": "^5.0.11"
106
+ "vite": "^5.0.12"
105
107
  },
106
108
  "peerDependencies": {
107
109
  "@emotion/react": ">=11.11",
@@ -115,7 +117,7 @@
115
117
  "dependencies": {
116
118
  "@tanstack/match-sorter-utils": "8.11.3",
117
119
  "@tanstack/react-table": "8.11.6",
118
- "@tanstack/react-virtual": "3.0.1",
120
+ "@tanstack/react-virtual": "3.0.2",
119
121
  "highlight-words": "1.2.2"
120
122
  }
121
- }
123
+ }
@@ -1,11 +1,11 @@
1
- import { MRT_TablePaper } from './table/MRT_TablePaper';
1
+ import { useMaterialReactTable } from '../hooks/useMaterialReactTable';
2
2
  import {
3
3
  type MRT_RowData,
4
4
  type MRT_TableInstance,
5
5
  type MRT_TableOptions,
6
6
  type Xor,
7
- } from './types';
8
- import { useMaterialReactTable } from './useMaterialReactTable';
7
+ } from '../types';
8
+ import { MRT_TablePaper } from './table/MRT_TablePaper';
9
9
 
10
10
  type TableInstanceProp<TData extends MRT_RowData> = {
11
11
  table: MRT_TableInstance<TData>;
@@ -3,15 +3,15 @@ import { type VirtualItem } from '@tanstack/react-virtual';
3
3
  import TableBody, { type TableBodyProps } from '@mui/material/TableBody';
4
4
  import Typography from '@mui/material/Typography';
5
5
  import { MRT_TableBodyRow, Memo_MRT_TableBodyRow } from './MRT_TableBodyRow';
6
- import { parseFromValuesOrFunc } from '../column.utils';
7
- import { useMRT_RowVirtualizer } from '../hooks/useMRT_RowVirtualizer';
8
- import { useMRT_Rows } from '../hooks/useMRT_Rows';
6
+ import { useMRT_RowVirtualizer } from '../../hooks/useMRT_RowVirtualizer';
7
+ import { useMRT_Rows } from '../../hooks/useMRT_Rows';
9
8
  import {
10
9
  type MRT_ColumnVirtualizer,
11
10
  type MRT_Row,
12
11
  type MRT_RowData,
13
12
  type MRT_TableInstance,
14
- } from '../types';
13
+ } from '../../types';
14
+ import { parseFromValuesOrFunc } from '../../utils/utils';
15
15
 
16
16
  interface Props<TData extends MRT_RowData> extends TableBodyProps {
17
17
  columnVirtualizer?: MRT_ColumnVirtualizer;
@@ -151,6 +151,7 @@ export const MRT_TableBody = <TData extends MRT_RowData>({
151
151
  ) : (
152
152
  <>
153
153
  {(virtualRows ?? rows).map((rowOrVirtualRow, staticRowIndex) => {
154
+ let row = rowOrVirtualRow as MRT_Row<TData>;
154
155
  if (rowVirtualizer) {
155
156
  if (renderDetailPanel) {
156
157
  if (rowOrVirtualRow.index % 2 === 1) {
@@ -161,10 +162,8 @@ export const MRT_TableBody = <TData extends MRT_RowData>({
161
162
  } else {
162
163
  staticRowIndex = rowOrVirtualRow.index;
163
164
  }
165
+ row = rows[staticRowIndex];
164
166
  }
165
- const row = rowVirtualizer
166
- ? rows[staticRowIndex]
167
- : (rowOrVirtualRow as MRT_Row<TData>);
168
167
  const props = {
169
168
  ...commonRowProps,
170
169
  pinnedRowIds,
@@ -11,28 +11,25 @@ import Skeleton from '@mui/material/Skeleton';
11
11
  import TableCell, { type TableCellProps } from '@mui/material/TableCell';
12
12
  import { useTheme } from '@mui/material/styles';
13
13
  import { MRT_TableBodyCellValue } from './MRT_TableBodyCellValue';
14
- import { MRT_CopyButton } from '../buttons/MRT_CopyButton';
15
- import {
16
- getIsFirstColumn,
17
- getIsLastColumn,
18
- parseFromValuesOrFunc,
19
- } from '../column.utils';
20
- import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
21
- import { getCommonMRTCellStyles, getMRTTheme } from '../style.utils';
22
14
  import {
23
15
  type MRT_Cell,
24
16
  type MRT_RowData,
25
17
  type MRT_TableInstance,
26
- } from '../types';
18
+ } from '../../types';
19
+ import { getIsFirstColumn, getIsLastColumn } from '../../utils/column.utils';
20
+ import { getCommonMRTCellStyles, getMRTTheme } from '../../utils/style.utils';
21
+ import { parseFromValuesOrFunc } from '../../utils/utils';
22
+ import { MRT_CopyButton } from '../buttons/MRT_CopyButton';
23
+ import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
27
24
 
28
25
  interface Props<TData extends MRT_RowData> extends TableCellProps {
29
26
  cell: MRT_Cell<TData>;
30
27
  measureElement?: (element: HTMLTableCellElement) => void;
31
28
  numRows?: number;
32
29
  rowRef: RefObject<HTMLTableRowElement>;
30
+ staticColumnIndex?: number;
33
31
  staticRowIndex: number;
34
32
  table: MRT_TableInstance<TData>;
35
- virtualColumnIndex?: number;
36
33
  }
37
34
 
38
35
  export const MRT_TableBodyCell = <TData extends MRT_RowData>({
@@ -40,9 +37,9 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
40
37
  measureElement,
41
38
  numRows,
42
39
  rowRef,
40
+ staticColumnIndex,
43
41
  staticRowIndex,
44
42
  table,
45
- virtualColumnIndex,
46
43
  ...rest
47
44
  }: Props<TData>) => {
48
45
  const theme = useTheme();
@@ -55,12 +52,12 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
55
52
  editDisplayMode,
56
53
  enableClickToCopy,
57
54
  enableColumnOrdering,
55
+ enableColumnPinning,
58
56
  enableEditing,
59
57
  enableGrouping,
60
58
  layoutMode,
61
59
  muiSkeletonProps,
62
60
  muiTableBodyCellProps,
63
- positionExpandColumn,
64
61
  },
65
62
  refs: { editInputRefs },
66
63
  setEditingCell,
@@ -166,6 +163,11 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
166
163
  staticRowIndex,
167
164
  ]);
168
165
 
166
+ const isColumnPinned =
167
+ enableColumnPinning &&
168
+ columnDef.columnDefType !== 'group' &&
169
+ column.getIsPinned();
170
+
169
171
  const isEditable =
170
172
  !cell.getIsPlaceholder() &&
171
173
  parseFromValuesOrFunc(enableEditing, row) &&
@@ -216,7 +218,8 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
216
218
  return (
217
219
  <TableCell
218
220
  align={theme.direction === 'rtl' ? 'right' : 'left'}
219
- data-index={virtualColumnIndex}
221
+ data-index={staticColumnIndex}
222
+ data-pinned={!!isColumnPinned || undefined}
220
223
  ref={(node: HTMLTableCellElement) => {
221
224
  if (node) {
222
225
  measureElement?.(node);
@@ -255,19 +258,6 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
255
258
  ? '1rem 1.25rem'
256
259
  : '1.5rem',
257
260
  textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined,
258
- [theme.direction === 'rtl' || positionExpandColumn === 'last'
259
- ? 'pr'
260
- : 'pl']:
261
- column.id === 'mrt-row-expand'
262
- ? `${
263
- row.depth +
264
- (density === 'compact'
265
- ? 0.5
266
- : density === 'comfortable'
267
- ? 0.75
268
- : 1.25)
269
- }rem`
270
- : undefined,
271
261
  whiteSpace:
272
262
  row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal',
273
263
  zIndex:
@@ -1,11 +1,11 @@
1
1
  import { type ReactNode, type RefObject } from 'react';
2
2
  import Box from '@mui/material/Box';
3
- import { getMRTTheme } from '../style.utils';
4
3
  import {
5
4
  type MRT_Cell,
6
5
  type MRT_RowData,
7
6
  type MRT_TableInstance,
8
- } from '../types';
7
+ } from '../../types';
8
+ import { getMRTTheme } from '../../utils/style.utils';
9
9
  import highlightWords from 'highlight-words';
10
10
 
11
11
  const allowedTypes = ['string', 'number'];
@@ -10,8 +10,6 @@ import {
10
10
  } from '@mui/material/styles';
11
11
  import { MRT_TableBodyCell, Memo_MRT_TableBodyCell } from './MRT_TableBodyCell';
12
12
  import { MRT_TableDetailPanel } from './MRT_TableDetailPanel';
13
- import { parseFromValuesOrFunc } from '../column.utils';
14
- import { getMRTTheme } from '../style.utils';
15
13
  import {
16
14
  type MRT_Cell,
17
15
  type MRT_ColumnVirtualizer,
@@ -19,7 +17,15 @@ import {
19
17
  type MRT_RowData,
20
18
  type MRT_RowVirtualizer,
21
19
  type MRT_TableInstance,
22
- } from '../types';
20
+ type MRT_VirtualItem,
21
+ } from '../../types';
22
+ import { getIsRowSelected } from '../../utils/row.utils';
23
+ import {
24
+ getCommonPinnedCellStyles,
25
+ getMRTTheme,
26
+ pinnedBeforeAfterStyles,
27
+ } from '../../utils/style.utils';
28
+ import { parseFromValuesOrFunc } from '../../utils/utils';
23
29
 
24
30
  interface Props<TData extends MRT_RowData> {
25
31
  columnVirtualizer?: MRT_ColumnVirtualizer;
@@ -71,10 +77,13 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
71
77
  rowPinning,
72
78
  } = getState();
73
79
 
80
+ const visibleCells = row.getVisibleCells();
81
+
74
82
  const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } =
75
83
  columnVirtualizer ?? {};
76
84
 
77
- const isPinned = enableRowPinning && row.getIsPinned();
85
+ const isRowSelected = getIsRowSelected({ row, table });
86
+ const isRowPinned = enableRowPinning && row.getIsPinned();
78
87
  const isDraggingRow = draggingRow?.id === row.id;
79
88
  const isHoveredRow = hoveredRow?.id === row.id;
80
89
 
@@ -130,16 +139,27 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
130
139
  selectedRowBackgroundColor,
131
140
  } = getMRTTheme(table, theme);
132
141
 
142
+ const cellHighlightColor = isRowSelected
143
+ ? selectedRowBackgroundColor
144
+ : isRowPinned
145
+ ? pinnedRowBackgroundColor
146
+ : undefined;
147
+
148
+ const cellHighlightColorHover =
149
+ tableRowProps?.hover !== false
150
+ ? isRowSelected
151
+ ? cellHighlightColor
152
+ : theme.palette.mode === 'dark'
153
+ ? `${lighten(baseBackgroundColor, 0.3)}`
154
+ : `${darken(baseBackgroundColor, 0.3)}`
155
+ : undefined;
156
+
133
157
  return (
134
158
  <>
135
159
  <TableRow
136
160
  data-index={renderDetailPanel ? staticRowIndex * 2 : staticRowIndex}
137
- data-pinned={!!isPinned || undefined}
138
- data-selected={
139
- row?.getIsSelected() ||
140
- (row?.getIsAllSubRowsSelected() && row.getCanSelectSubRows()) ||
141
- undefined
142
- }
161
+ data-pinned={!!isRowPinned || undefined}
162
+ data-selected={isRowSelected || undefined}
143
163
  onDragEnter={handleDragEnter}
144
164
  ref={(node: HTMLTableRowElement) => {
145
165
  if (node) {
@@ -147,7 +167,7 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
147
167
  rowVirtualizer?.measureElement(node);
148
168
  }
149
169
  }}
150
- selected={row.getIsSelected()}
170
+ selected={isRowSelected}
151
171
  {...tableRowProps}
152
172
  style={{
153
173
  transform: virtualRow
@@ -157,18 +177,16 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
157
177
  }}
158
178
  sx={(theme: Theme) => ({
159
179
  '&:hover td': {
160
- backgroundColor:
161
- tableRowProps?.hover !== false
162
- ? row.getIsSelected()
163
- ? `${alpha(selectedRowBackgroundColor, 0.3)}`
164
- : theme.palette.mode === 'dark'
165
- ? `${lighten(baseBackgroundColor, 0.05)}`
166
- : `${darken(baseBackgroundColor, 0.05)}`
180
+ '&:after': {
181
+ backgroundColor: cellHighlightColorHover
182
+ ? alpha(cellHighlightColorHover, 0.3)
167
183
  : undefined,
184
+ ...pinnedBeforeAfterStyles,
185
+ },
168
186
  },
169
187
  backgroundColor: `${baseBackgroundColor} !important`,
170
188
  bottom:
171
- !virtualRow && bottomPinnedIndex !== undefined && isPinned
189
+ !virtualRow && bottomPinnedIndex !== undefined && isRowPinned
172
190
  ? `${
173
191
  bottomPinnedIndex * rowHeight +
174
192
  (enableStickyFooter ? tableFooterHeight - 1 : 0)
@@ -176,22 +194,22 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
176
194
  : undefined,
177
195
  boxSizing: 'border-box',
178
196
  display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
179
- opacity: isPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1,
197
+ opacity: isRowPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1,
180
198
  position: virtualRow
181
199
  ? 'absolute'
182
- : rowPinningDisplayMode?.includes('sticky') && isPinned
200
+ : rowPinningDisplayMode?.includes('sticky') && isRowPinned
183
201
  ? 'sticky'
184
202
  : undefined,
185
203
  td: {
186
- backgroundColor: row.getIsSelected()
187
- ? selectedRowBackgroundColor
188
- : isPinned
189
- ? pinnedRowBackgroundColor
190
- : undefined,
204
+ '&:after': {
205
+ backgroundColor: cellHighlightColor,
206
+ ...pinnedBeforeAfterStyles,
207
+ },
208
+ ...getCommonPinnedCellStyles({ table, theme }),
191
209
  },
192
210
  top: virtualRow
193
211
  ? 0
194
- : topPinnedIndex !== undefined && isPinned
212
+ : topPinnedIndex !== undefined && isRowPinned
195
213
  ? `${
196
214
  topPinnedIndex * rowHeight +
197
215
  (enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0)
@@ -200,7 +218,7 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
200
218
  transition: virtualRow ? 'none' : 'all 150ms ease-in-out',
201
219
  width: '100%',
202
220
  zIndex:
203
- rowPinningDisplayMode?.includes('sticky') && isPinned
221
+ rowPinningDisplayMode?.includes('sticky') && isRowPinned
204
222
  ? 2
205
223
  : undefined,
206
224
  ...(sx as any),
@@ -209,37 +227,39 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
209
227
  {virtualPaddingLeft ? (
210
228
  <td style={{ display: 'flex', width: virtualPaddingLeft }} />
211
229
  ) : null}
212
- {(virtualColumns ?? row.getVisibleCells()).map((cellOrVirtualCell) => {
213
- const cell = columnVirtualizer
214
- ? row.getVisibleCells()[(cellOrVirtualCell as VirtualItem).index]
215
- : (cellOrVirtualCell as MRT_Cell<TData>);
216
- const props = {
217
- cell,
218
- measureElement:
219
- !isDraggingRow && !isHoveredRow
220
- ? columnVirtualizer?.measureElement
221
- : undefined,
222
- numRows,
223
- rowRef,
224
- staticRowIndex,
225
- table,
226
- virtualColumnIndex: columnVirtualizer
227
- ? (cellOrVirtualCell as VirtualItem).index
228
- : undefined,
229
- };
230
- return cell ? (
231
- memoMode === 'cells' &&
232
- cell.column.columnDef.columnDefType === 'data' &&
233
- !draggingColumn &&
234
- !draggingRow &&
235
- editingCell?.id !== cell.id &&
236
- editingRow?.id !== row.id ? (
237
- <Memo_MRT_TableBodyCell key={cell.id} {...props} />
238
- ) : (
239
- <MRT_TableBodyCell key={cell.id} {...props} />
240
- )
241
- ) : null;
242
- })}
230
+ {(virtualColumns ?? visibleCells).map(
231
+ (cellOrVirtualCell, staticColumnIndex) => {
232
+ let cell = cellOrVirtualCell as MRT_Cell<TData>;
233
+ if (columnVirtualizer) {
234
+ staticColumnIndex = (cellOrVirtualCell as MRT_VirtualItem).index;
235
+ cell = visibleCells[staticColumnIndex];
236
+ }
237
+ const props = {
238
+ cell,
239
+ measureElement:
240
+ !isDraggingRow && !isHoveredRow
241
+ ? columnVirtualizer?.measureElement
242
+ : undefined,
243
+ numRows,
244
+ rowRef,
245
+ staticColumnIndex,
246
+ staticRowIndex,
247
+ table,
248
+ };
249
+ return cell ? (
250
+ memoMode === 'cells' &&
251
+ cell.column.columnDef.columnDefType === 'data' &&
252
+ !draggingColumn &&
253
+ !draggingRow &&
254
+ editingCell?.id !== cell.id &&
255
+ editingRow?.id !== row.id ? (
256
+ <Memo_MRT_TableBodyCell key={cell.id} {...props} />
257
+ ) : (
258
+ <MRT_TableBodyCell key={cell.id} {...props} />
259
+ )
260
+ ) : null;
261
+ },
262
+ )}
243
263
  {virtualPaddingRight ? (
244
264
  <td style={{ display: 'flex', width: virtualPaddingRight }} />
245
265
  ) : null}
@@ -1,12 +1,12 @@
1
1
  import { type DragEvent, type RefObject } from 'react';
2
2
  import { type IconButtonProps } from '@mui/material/IconButton';
3
- import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
4
- import { parseFromValuesOrFunc } from '../column.utils';
5
3
  import {
6
4
  type MRT_Row,
7
5
  type MRT_RowData,
8
6
  type MRT_TableInstance,
9
- } from '../types';
7
+ } from '../../types';
8
+ import { parseFromValuesOrFunc } from '../../utils/utils';
9
+ import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
10
10
 
11
11
  interface Props<TData extends MRT_RowData> extends IconButtonProps {
12
12
  row: MRT_Row<TData>;
@@ -1,12 +1,12 @@
1
1
  import Box from '@mui/material/Box';
2
2
  import { type IconButtonProps } from '@mui/material/IconButton';
3
- import { MRT_RowPinButton } from '../buttons/MRT_RowPinButton';
4
- import { parseFromValuesOrFunc } from '../column.utils';
5
3
  import {
6
4
  type MRT_Row,
7
5
  type MRT_RowData,
8
6
  type MRT_TableInstance,
9
- } from '../types';
7
+ } from '../../types';
8
+ import { parseFromValuesOrFunc } from '../../utils/utils';
9
+ import { MRT_RowPinButton } from '../buttons/MRT_RowPinButton';
10
10
 
11
11
  interface Props<TData extends MRT_RowData> extends IconButtonProps {
12
12
  row: MRT_Row<TData>;
@@ -2,15 +2,15 @@ import { type RefObject } from 'react';
2
2
  import Collapse from '@mui/material/Collapse';
3
3
  import TableCell, { type TableCellProps } from '@mui/material/TableCell';
4
4
  import TableRow from '@mui/material/TableRow';
5
- import { parseFromValuesOrFunc } from '../column.utils';
6
- import { getMRTTheme } from '../style.utils';
7
5
  import {
8
6
  type MRT_Row,
9
7
  type MRT_RowData,
10
8
  type MRT_RowVirtualizer,
11
9
  type MRT_TableInstance,
12
10
  type MRT_VirtualItem,
13
- } from '../types';
11
+ } from '../../types';
12
+ import { getMRTTheme } from '../../utils/style.utils';
13
+ import { parseFromValuesOrFunc } from '../../utils/utils';
14
14
 
15
15
  interface Props<TData extends MRT_RowData> extends TableCellProps {
16
16
  parentRowRef: RefObject<HTMLTableRowElement>;
@@ -1,12 +1,12 @@
1
1
  import Box, { type BoxProps } from '@mui/material/Box';
2
2
  import IconButton from '@mui/material/IconButton';
3
3
  import Tooltip from '@mui/material/Tooltip';
4
- import { parseFromValuesOrFunc } from '../column.utils';
5
4
  import {
6
5
  type MRT_Column,
7
6
  type MRT_RowData,
8
7
  type MRT_TableInstance,
9
- } from '../types';
8
+ } from '../../types';
9
+ import { parseFromValuesOrFunc } from '../../utils/utils';
10
10
 
11
11
  interface Props<TData extends MRT_RowData> extends BoxProps {
12
12
  column: MRT_Column<TData>;
@@ -1,13 +1,13 @@
1
1
  import { type MouseEvent, useState } from 'react';
2
2
  import Button, { type ButtonProps } from '@mui/material/Button';
3
3
  import Tooltip from '@mui/material/Tooltip';
4
- import { parseFromValuesOrFunc } from '../column.utils';
5
- import { getCommonTooltipProps } from '../style.utils';
6
4
  import {
7
5
  type MRT_Cell,
8
6
  type MRT_RowData,
9
7
  type MRT_TableInstance,
10
- } from '../types';
8
+ } from '../../types';
9
+ import { getCommonTooltipProps } from '../../utils/style.utils';
10
+ import { parseFromValuesOrFunc } from '../../utils/utils';
11
11
 
12
12
  interface Props<TData extends MRT_RowData> extends ButtonProps {
13
13
  cell: MRT_Cell<TData>;
@@ -3,12 +3,12 @@ import Button from '@mui/material/Button';
3
3
  import CircularProgress from '@mui/material/CircularProgress';
4
4
  import IconButton from '@mui/material/IconButton';
5
5
  import Tooltip from '@mui/material/Tooltip';
6
- import { parseFromValuesOrFunc } from '../column.utils';
7
6
  import {
8
7
  type MRT_Row,
9
8
  type MRT_RowData,
10
9
  type MRT_TableInstance,
11
- } from '../types';
10
+ } from '../../types';
11
+ import { parseFromValuesOrFunc } from '../../utils/utils';
12
12
 
13
13
  interface Props<TData extends MRT_RowData> extends BoxProps {
14
14
  row: MRT_Row<TData>;
@@ -1,8 +1,8 @@
1
1
  import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
2
2
  import Tooltip from '@mui/material/Tooltip';
3
- import { parseFromValuesOrFunc } from '../column.utils';
4
- import { getCommonTooltipProps } from '../style.utils';
5
- import { type MRT_RowData, type MRT_TableInstance } from '../types';
3
+ import { type MRT_RowData, type MRT_TableInstance } from '../../types';
4
+ import { getCommonTooltipProps } from '../../utils/style.utils';
5
+ import { parseFromValuesOrFunc } from '../../utils/utils';
6
6
 
7
7
  interface Props<TData extends MRT_RowData> extends IconButtonProps {
8
8
  table: MRT_TableInstance<TData>;
@@ -2,13 +2,13 @@ import { type MouseEvent } from 'react';
2
2
  import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
3
3
  import Tooltip from '@mui/material/Tooltip';
4
4
  import { useTheme } from '@mui/material/styles';
5
- import { parseFromValuesOrFunc } from '../column.utils';
6
- import { getCommonTooltipProps } from '../style.utils';
7
5
  import {
8
6
  type MRT_Row,
9
7
  type MRT_RowData,
10
8
  type MRT_TableInstance,
11
- } from '../types';
9
+ } from '../../types';
10
+ import { getCommonTooltipProps } from '../../utils/style.utils';
11
+ import { parseFromValuesOrFunc } from '../../utils/utils';
12
12
 
13
13
  interface Props<TData extends MRT_RowData> extends IconButtonProps {
14
14
  row: MRT_Row<TData>;
@@ -69,6 +69,9 @@ export const MRT_ExpandButton = <TData extends MRT_RowData>({
69
69
  sx={(theme) => ({
70
70
  height: density === 'compact' ? '1.75rem' : '2.25rem',
71
71
  opacity: !canExpand && !detailPanel ? 0.3 : 1,
72
+ [theme.direction === 'rtl' || positionExpandColumn === 'last'
73
+ ? 'mr'
74
+ : 'ml']: `${row.depth * 16}px`,
72
75
  width: density === 'compact' ? '1.75rem' : '2.25rem',
73
76
  ...(parseFromValuesOrFunc(iconButtonProps?.sx, theme) as any),
74
77
  })}