material-react-table 2.9.1 → 2.10.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 (151) hide show
  1. package/dist/index.d.ts +162 -111
  2. package/dist/index.esm.js +739 -639
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +741 -639
  5. package/dist/index.js.map +1 -1
  6. package/locales/ar/index.esm.js +1 -0
  7. package/locales/ar/index.js +1 -0
  8. package/locales/az/index.esm.js +1 -0
  9. package/locales/az/index.js +1 -0
  10. package/locales/bg/index.esm.js +1 -0
  11. package/locales/bg/index.js +1 -0
  12. package/locales/cs/index.esm.js +1 -0
  13. package/locales/cs/index.js +1 -0
  14. package/locales/da/index.esm.js +1 -0
  15. package/locales/da/index.js +1 -0
  16. package/locales/de/index.esm.js +1 -0
  17. package/locales/de/index.js +1 -0
  18. package/locales/en/index.esm.js +1 -0
  19. package/locales/en/index.js +1 -0
  20. package/locales/es/index.esm.js +1 -0
  21. package/locales/es/index.js +1 -0
  22. package/locales/et/index.esm.js +1 -0
  23. package/locales/et/index.js +1 -0
  24. package/locales/fa/index.esm.js +1 -0
  25. package/locales/fa/index.js +1 -0
  26. package/locales/fi/index.esm.js +1 -0
  27. package/locales/fi/index.js +1 -0
  28. package/locales/fr/index.esm.js +1 -0
  29. package/locales/fr/index.js +1 -0
  30. package/locales/he/index.esm.js +1 -0
  31. package/locales/he/index.js +1 -0
  32. package/locales/hu/index.esm.js +1 -0
  33. package/locales/hu/index.js +1 -0
  34. package/locales/hy/index.esm.js +1 -0
  35. package/locales/hy/index.js +1 -0
  36. package/locales/id/index.esm.js +1 -0
  37. package/locales/id/index.js +1 -0
  38. package/locales/it/index.esm.js +1 -0
  39. package/locales/it/index.js +1 -0
  40. package/locales/ja/index.esm.js +1 -0
  41. package/locales/ja/index.js +1 -0
  42. package/locales/ko/index.esm.js +1 -0
  43. package/locales/ko/index.js +1 -0
  44. package/locales/nl/index.esm.js +1 -0
  45. package/locales/nl/index.js +1 -0
  46. package/locales/no/index.esm.js +1 -0
  47. package/locales/no/index.js +1 -0
  48. package/locales/np/index.esm.js +1 -0
  49. package/locales/np/index.js +1 -0
  50. package/locales/pl/index.esm.js +1 -0
  51. package/locales/pl/index.js +1 -0
  52. package/locales/pt/index.esm.js +1 -0
  53. package/locales/pt/index.js +1 -0
  54. package/locales/pt-BR/index.esm.js +1 -0
  55. package/locales/pt-BR/index.js +1 -0
  56. package/locales/ro/index.esm.js +1 -0
  57. package/locales/ro/index.js +1 -0
  58. package/locales/ru/index.esm.js +1 -0
  59. package/locales/ru/index.js +1 -0
  60. package/locales/sk/index.esm.js +1 -0
  61. package/locales/sk/index.js +1 -0
  62. package/locales/sr-Cyrl-RS/index.esm.js +1 -0
  63. package/locales/sr-Cyrl-RS/index.js +1 -0
  64. package/locales/sr-Latn-RS/index.esm.js +1 -0
  65. package/locales/sr-Latn-RS/index.js +1 -0
  66. package/locales/sv/index.esm.js +1 -0
  67. package/locales/sv/index.js +1 -0
  68. package/locales/tr/index.esm.js +1 -0
  69. package/locales/tr/index.js +1 -0
  70. package/locales/uk/index.esm.js +1 -0
  71. package/locales/uk/index.js +1 -0
  72. package/locales/vi/index.esm.js +1 -0
  73. package/locales/vi/index.js +1 -0
  74. package/locales/zh-Hans/index.esm.js +1 -0
  75. package/locales/zh-Hans/index.js +1 -0
  76. package/locales/zh-Hant/index.esm.js +1 -0
  77. package/locales/zh-Hant/index.js +1 -0
  78. package/package.json +11 -11
  79. package/src/components/body/MRT_TableBodyCell.tsx +41 -37
  80. package/src/components/body/MRT_TableBodyRow.tsx +15 -21
  81. package/src/components/buttons/MRT_CopyButton.tsx +1 -0
  82. package/src/components/footer/MRT_TableFooter.tsx +1 -1
  83. package/src/components/footer/MRT_TableFooterCell.tsx +2 -4
  84. package/src/components/footer/MRT_TableFooterRow.tsx +1 -0
  85. package/src/components/head/MRT_TableHeadCell.tsx +6 -6
  86. package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +1 -0
  87. package/src/components/head/MRT_TableHeadRow.tsx +6 -1
  88. package/src/components/inputs/MRT_EditCellTextField.tsx +4 -1
  89. package/src/components/inputs/MRT_FilterTextField.tsx +1 -0
  90. package/src/components/menus/MRT_ActionMenuItem.tsx +60 -0
  91. package/src/components/menus/MRT_CellActionMenu.tsx +108 -0
  92. package/src/components/menus/MRT_ColumnActionMenu.tsx +90 -170
  93. package/src/components/menus/MRT_FilterOptionMenu.tsx +7 -14
  94. package/src/components/menus/MRT_RowActionMenu.tsx +8 -15
  95. package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +4 -1
  96. package/src/components/table/MRT_Table.tsx +1 -0
  97. package/src/components/table/MRT_TableContainer.tsx +4 -0
  98. package/src/components/toolbar/MRT_TablePagination.tsx +14 -5
  99. package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +1 -8
  100. package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +1 -8
  101. package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +1 -8
  102. package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +1 -8
  103. package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +1 -8
  104. package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +1 -8
  105. package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +1 -8
  106. package/src/hooks/useMRT_Effects.ts +10 -0
  107. package/src/hooks/useMRT_TableInstance.ts +112 -59
  108. package/src/icons.ts +2 -0
  109. package/src/index.ts +2 -0
  110. package/src/locales/ar.ts +1 -0
  111. package/src/locales/az.ts +1 -0
  112. package/src/locales/bg.ts +1 -0
  113. package/src/locales/cs.ts +1 -0
  114. package/src/locales/da.ts +1 -0
  115. package/src/locales/de.ts +1 -0
  116. package/src/locales/en.ts +1 -0
  117. package/src/locales/es.ts +1 -0
  118. package/src/locales/et.ts +1 -0
  119. package/src/locales/fa.ts +1 -0
  120. package/src/locales/fi.ts +1 -0
  121. package/src/locales/fr.ts +1 -0
  122. package/src/locales/he.ts +1 -0
  123. package/src/locales/hu.ts +1 -0
  124. package/src/locales/hy.ts +1 -0
  125. package/src/locales/id.ts +1 -0
  126. package/src/locales/it.ts +1 -0
  127. package/src/locales/ja.ts +1 -0
  128. package/src/locales/ko.ts +1 -0
  129. package/src/locales/nl.ts +1 -0
  130. package/src/locales/no.ts +1 -0
  131. package/src/locales/np.ts +1 -0
  132. package/src/locales/pl.ts +1 -0
  133. package/src/locales/pt-BR.ts +1 -0
  134. package/src/locales/pt.ts +1 -0
  135. package/src/locales/ro.ts +1 -0
  136. package/src/locales/ru.ts +1 -0
  137. package/src/locales/sk.ts +1 -0
  138. package/src/locales/sr-Cyrl-RS.ts +1 -0
  139. package/src/locales/sr-Latn-RS.ts +1 -0
  140. package/src/locales/sv.ts +1 -0
  141. package/src/locales/tr.ts +1 -0
  142. package/src/locales/uk.ts +1 -0
  143. package/src/locales/vi.ts +1 -0
  144. package/src/locales/zh-Hans.ts +1 -0
  145. package/src/locales/zh-Hant.ts +1 -0
  146. package/src/types.ts +41 -9
  147. package/src/utils/cell.utils.ts +50 -0
  148. package/src/utils/displayColumn.utils.ts +38 -20
  149. package/src/utils/style.utils.ts +17 -4
  150. package/src/hooks/display-columns/getMRT_DisplayColumns.tsx +0 -26
  151. package/src/locales/am.ts +0 -94
@@ -1,12 +1,8 @@
1
- import { useState } from 'react';
2
- import * as React from 'react';
3
- import Box from '@mui/material/Box';
4
- import IconButton from '@mui/material/IconButton';
5
- import ListItemIcon from '@mui/material/ListItemIcon';
1
+ import { type MouseEvent, useState } from 'react';
6
2
  import Menu, { type MenuProps } from '@mui/material/Menu';
7
- import MenuItem from '@mui/material/MenuItem';
8
3
  import { useTheme } from '@mui/material/styles';
9
4
  import { MRT_FilterOptionMenu } from './MRT_FilterOptionMenu';
5
+ import { MRT_ActionMenuItem } from './MRT_ActionMenuItem';
10
6
  import {
11
7
  type MRT_Header,
12
8
  type MRT_RowData,
@@ -14,18 +10,6 @@ import {
14
10
  } from '../../types';
15
11
  import { getMRTTheme } from '../../utils/style.utils';
16
12
 
17
- export const commonMenuItemStyles = {
18
- alignItems: 'center',
19
- justifyContent: 'space-between',
20
- my: 0,
21
- py: '6px',
22
- };
23
-
24
- export const commonListItemStyles = {
25
- alignItems: 'center',
26
- display: 'flex',
27
- };
28
-
29
13
  interface Props<TData extends MRT_RowData> extends Partial<MenuProps> {
30
14
  anchorEl: HTMLElement | null;
31
15
  header: MRT_Header<TData>;
@@ -42,6 +26,7 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
42
26
  }: Props<TData>) => {
43
27
  const {
44
28
  getState,
29
+ getAllLeafColumns,
45
30
  options: {
46
31
  columnFilterDisplayMode,
47
32
  columnFilterModeOptions,
@@ -54,7 +39,6 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
54
39
  enableSorting,
55
40
  enableSortingRemoval,
56
41
  icons: {
57
- ArrowRightIcon,
58
42
  ClearAllIcon,
59
43
  DynamicFeedIcon,
60
44
  FilterListIcon,
@@ -73,7 +57,6 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
73
57
  setColumnOrder,
74
58
  setColumnSizingInfo,
75
59
  setShowColumnFilters,
76
- toggleAllColumnsVisible,
77
60
  } = table;
78
61
  const { column } = header;
79
62
  const { columnDef } = column;
@@ -139,11 +122,13 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
139
122
  };
140
123
 
141
124
  const handleShowAllColumns = () => {
142
- toggleAllColumnsVisible(true);
125
+ getAllLeafColumns()
126
+ .filter((col) => col.columnDef.enableHiding !== false)
127
+ .forEach((col) => col.toggleVisibility(true));
143
128
  setAnchorEl(null);
144
129
  };
145
130
 
146
- const handleOpenFilterModeMenu = (event: React.MouseEvent<HTMLElement>) => {
131
+ const handleOpenFilterModeMenu = (event: MouseEvent<HTMLElement>) => {
147
132
  event.stopPropagation();
148
133
  setFilterMenuAnchorEl(event.currentTarget);
149
134
  };
@@ -164,106 +149,75 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
164
149
  ...(enableSorting && column.getCanSort()
165
150
  ? [
166
151
  enableSortingRemoval !== false && (
167
- <MenuItem
168
- disabled={!column.getIsSorted()}
152
+ <MRT_ActionMenuItem
153
+ icon={<ClearAllIcon />}
169
154
  key={0}
155
+ label={localization.clearSort}
170
156
  onClick={handleClearSort}
171
- sx={commonMenuItemStyles}
172
- >
173
- <Box sx={commonListItemStyles}>
174
- <ListItemIcon>
175
- <ClearAllIcon />
176
- </ListItemIcon>
177
- {localization.clearSort}
178
- </Box>
179
- </MenuItem>
157
+ table={table}
158
+ />
180
159
  ),
181
- <MenuItem
160
+ <MRT_ActionMenuItem
182
161
  disabled={column.getIsSorted() === 'asc'}
162
+ icon={
163
+ <SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />
164
+ }
183
165
  key={1}
166
+ label={localization.sortByColumnAsc?.replace(
167
+ '{column}',
168
+ String(columnDef.header),
169
+ )}
184
170
  onClick={handleSortAsc}
185
- sx={commonMenuItemStyles}
186
- >
187
- <Box sx={commonListItemStyles}>
188
- <ListItemIcon>
189
- <SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />
190
- </ListItemIcon>
191
- {localization.sortByColumnAsc?.replace(
192
- '{column}',
193
- String(columnDef.header),
194
- )}
195
- </Box>
196
- </MenuItem>,
197
- <MenuItem
171
+ table={table}
172
+ />,
173
+ <MRT_ActionMenuItem
198
174
  disabled={column.getIsSorted() === 'desc'}
199
175
  divider={enableColumnFilters || enableGrouping || enableHiding}
176
+ icon={<SortIcon />}
200
177
  key={2}
178
+ label={localization.sortByColumnDesc?.replace(
179
+ '{column}',
180
+ String(columnDef.header),
181
+ )}
201
182
  onClick={handleSortDesc}
202
- sx={commonMenuItemStyles}
203
- >
204
- <Box sx={commonListItemStyles}>
205
- <ListItemIcon>
206
- <SortIcon />
207
- </ListItemIcon>
208
- {localization.sortByColumnDesc?.replace(
209
- '{column}',
210
- String(columnDef.header),
211
- )}
212
- </Box>
213
- </MenuItem>,
183
+ table={table}
184
+ />,
214
185
  ]
215
186
  : []),
216
187
  ...(enableColumnFilters && column.getCanFilter()
217
188
  ? [
218
- <MenuItem
189
+ <MRT_ActionMenuItem
219
190
  disabled={
220
191
  !columnFilterValue ||
221
192
  (Array.isArray(columnFilterValue) &&
222
193
  !columnFilterValue.filter((value) => value).length)
223
194
  }
195
+ icon={<FilterListOffIcon />}
224
196
  key={3}
197
+ label={localization.clearFilter}
225
198
  onClick={handleClearFilter}
226
- sx={commonMenuItemStyles}
227
- >
228
- <Box sx={commonListItemStyles}>
229
- <ListItemIcon>
230
- <FilterListOffIcon />
231
- </ListItemIcon>
232
- {localization.clearFilter}
233
- </Box>
234
- </MenuItem>,
199
+ table={table}
200
+ />,
235
201
  columnFilterDisplayMode === 'subheader' && (
236
- <MenuItem
202
+ <MRT_ActionMenuItem
237
203
  disabled={showColumnFilters && !enableColumnFilterModes}
238
204
  divider={enableGrouping || enableHiding}
205
+ icon={<FilterListIcon />}
239
206
  key={4}
207
+ label={localization.filterByColumn?.replace(
208
+ '{column}',
209
+ String(columnDef.header),
210
+ )}
240
211
  onClick={
241
212
  showColumnFilters
242
213
  ? handleOpenFilterModeMenu
243
214
  : handleFilterByColumn
244
215
  }
245
- sx={commonMenuItemStyles}
246
- >
247
- <Box sx={commonListItemStyles}>
248
- <ListItemIcon>
249
- <FilterListIcon />
250
- </ListItemIcon>
251
- {localization.filterByColumn?.replace(
252
- '{column}',
253
- String(columnDef.header),
254
- )}
255
- </Box>
256
- {showFilterModeSubMenu && (
257
- <IconButton
258
- onClick={handleOpenFilterModeMenu}
259
- onMouseEnter={handleOpenFilterModeMenu}
260
- size="small"
261
- sx={{ p: 0 }}
262
- >
263
- <ArrowRightIcon />
264
- </IconButton>
265
- )}
266
- </MenuItem>
216
+ onOpenSubMenu={
217
+ showFilterModeSubMenu ? handleOpenFilterModeMenu : undefined
218
+ }
219
+ table={table}
220
+ />
267
221
  ),
268
222
  showFilterModeSubMenu && (
269
223
  <MRT_FilterOptionMenu
@@ -279,121 +233,86 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
279
233
  : []),
280
234
  ...(enableGrouping && column.getCanGroup()
281
235
  ? [
282
- <MenuItem
236
+ <MRT_ActionMenuItem
283
237
  divider={enableColumnPinning}
238
+ icon={<DynamicFeedIcon />}
284
239
  key={6}
240
+ label={localization[
241
+ column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn'
242
+ ]?.replace('{column}', String(columnDef.header))}
285
243
  onClick={handleGroupByColumn}
286
- sx={commonMenuItemStyles}
287
- >
288
- <Box sx={commonListItemStyles}>
289
- <ListItemIcon>
290
- <DynamicFeedIcon />
291
- </ListItemIcon>
292
- {localization[
293
- column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn'
294
- ]?.replace('{column}', String(columnDef.header))}
295
- </Box>
296
- </MenuItem>,
244
+ table={table}
245
+ />,
297
246
  ]
298
247
  : []),
299
248
  ...(enableColumnPinning && column.getCanPin()
300
249
  ? [
301
- <MenuItem
250
+ <MRT_ActionMenuItem
302
251
  disabled={column.getIsPinned() === 'left' || !column.getCanPin()}
252
+ icon={<PushPinIcon style={{ transform: 'rotate(90deg)' }} />}
303
253
  key={7}
254
+ label={localization.pinToLeft}
304
255
  onClick={() => handlePinColumn('left')}
305
- sx={commonMenuItemStyles}
306
- >
307
- <Box sx={commonListItemStyles}>
308
- <ListItemIcon>
309
- <PushPinIcon style={{ transform: 'rotate(90deg)' }} />
310
- </ListItemIcon>
311
- {localization.pinToLeft}
312
- </Box>
313
- </MenuItem>,
314
- <MenuItem
256
+ table={table}
257
+ />,
258
+ <MRT_ActionMenuItem
315
259
  disabled={column.getIsPinned() === 'right' || !column.getCanPin()}
260
+ icon={<PushPinIcon style={{ transform: 'rotate(-90deg)' }} />}
316
261
  key={8}
262
+ label={localization.pinToRight}
317
263
  onClick={() => handlePinColumn('right')}
318
- sx={commonMenuItemStyles}
319
- >
320
- <Box sx={commonListItemStyles}>
321
- <ListItemIcon>
322
- <PushPinIcon style={{ transform: 'rotate(-90deg)' }} />
323
- </ListItemIcon>
324
- {localization.pinToRight}
325
- </Box>
326
- </MenuItem>,
327
- <MenuItem
264
+ table={table}
265
+ />,
266
+ <MRT_ActionMenuItem
328
267
  disabled={!column.getIsPinned()}
329
268
  divider={enableHiding}
269
+ icon={<PushPinIcon />}
330
270
  key={9}
271
+ label={localization.unpin}
331
272
  onClick={() => handlePinColumn(false)}
332
- sx={commonMenuItemStyles}
333
- >
334
- <Box sx={commonListItemStyles}>
335
- <ListItemIcon>
336
- <PushPinIcon />
337
- </ListItemIcon>
338
- {localization.unpin}
339
- </Box>
340
- </MenuItem>,
273
+ table={table}
274
+ />,
341
275
  ]
342
276
  : []),
343
277
  ...(enableColumnResizing && column.getCanResize()
344
278
  ? [
345
- <MenuItem
279
+ <MRT_ActionMenuItem
346
280
  disabled={!columnSizing[column.id]}
281
+ icon={<RestartAltIcon />}
347
282
  key={10}
283
+ label={localization.resetColumnSize}
348
284
  onClick={handleResetColumnSize}
349
- sx={commonMenuItemStyles}
350
- >
351
- <Box sx={commonListItemStyles}>
352
- <ListItemIcon>
353
- <RestartAltIcon />
354
- </ListItemIcon>
355
- {localization.resetColumnSize}
356
- </Box>
357
- </MenuItem>,
285
+ table={table}
286
+ />,
358
287
  ]
359
288
  : []),
360
289
  ...(enableHiding
361
290
  ? [
362
- <MenuItem
291
+ <MRT_ActionMenuItem
363
292
  disabled={!column.getCanHide()}
293
+ icon={<VisibilityOffIcon />}
364
294
  key={11}
295
+ label={localization.hideColumn?.replace(
296
+ '{column}',
297
+ String(columnDef.header),
298
+ )}
365
299
  onClick={handleHideColumn}
366
- sx={commonMenuItemStyles}
367
- >
368
- <Box sx={commonListItemStyles}>
369
- <ListItemIcon>
370
- <VisibilityOffIcon />
371
- </ListItemIcon>
372
- {localization.hideColumn?.replace(
373
- '{column}',
374
- String(columnDef.header),
375
- )}
376
- </Box>
377
- </MenuItem>,
378
- <MenuItem
300
+ table={table}
301
+ />,
302
+ <MRT_ActionMenuItem
379
303
  disabled={
380
304
  !Object.values(columnVisibility).filter((visible) => !visible)
381
305
  .length
382
306
  }
307
+ icon={<ViewColumnIcon />}
383
308
  key={12}
309
+ label={localization.showAllColumns?.replace(
310
+ '{column}',
311
+ String(columnDef.header),
312
+ )}
384
313
  onClick={handleShowAllColumns}
385
- sx={commonMenuItemStyles}
386
- >
387
- <Box sx={commonListItemStyles}>
388
- <ListItemIcon>
389
- <ViewColumnIcon />
390
- </ListItemIcon>
391
- {localization.showAllColumns?.replace(
392
- '{column}',
393
- String(columnDef.header),
394
- )}
395
- </Box>
396
- </MenuItem>,
314
+ table={table}
315
+ />,
397
316
  ]
398
317
  : []),
399
318
  ].filter(Boolean);
@@ -410,6 +329,7 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
410
329
  },
411
330
  }}
412
331
  anchorEl={anchorEl}
332
+ disableScrollLock
413
333
  onClose={() => setAnchorEl(null)}
414
334
  open={!!anchorEl}
415
335
  {...rest}
@@ -1,8 +1,7 @@
1
1
  import { useMemo } from 'react';
2
- import Box from '@mui/material/Box';
3
2
  import Menu, { type MenuProps } from '@mui/material/Menu';
4
- import MenuItem from '@mui/material/MenuItem';
5
3
  import { useTheme } from '@mui/material/styles';
4
+ import { MRT_ActionMenuItem } from './MRT_ActionMenuItem';
6
5
  import {
7
6
  type MRT_FilterOption,
8
7
  type MRT_Header,
@@ -252,6 +251,7 @@ export const MRT_FilterOptionMenu = <TData extends MRT_RowData>({
252
251
  }}
253
252
  anchorEl={anchorEl}
254
253
  anchorOrigin={{ horizontal: 'right', vertical: 'center' }}
254
+ disableScrollLock
255
255
  onClose={() => setAnchorEl(null)}
256
256
  open={!!anchorEl}
257
257
  {...rest}
@@ -276,23 +276,16 @@ export const MRT_FilterOptionMenu = <TData extends MRT_RowData>({
276
276
  })) ??
277
277
  internalFilterOptions.map(
278
278
  ({ divider, label, option, symbol }, index) => (
279
- <MenuItem
279
+ <MRT_ActionMenuItem
280
280
  divider={divider}
281
+ icon={symbol}
281
282
  key={index}
283
+ label={label}
282
284
  onClick={() => handleSelectFilterMode(option as MRT_FilterOption)}
283
285
  selected={option === filterOption}
284
- sx={{
285
- alignItems: 'center',
286
- display: 'flex',
287
- gap: '2ch',
288
- my: 0,
289
- py: '6px',
290
- }}
286
+ table={table}
291
287
  value={option}
292
- >
293
- <Box sx={{ fontSize: '1.25rem', width: '2ch' }}>{symbol}</Box>
294
- {label}
295
- </MenuItem>
288
+ />
296
289
  ),
297
290
  )}
298
291
  </Menu>
@@ -1,13 +1,7 @@
1
1
  import { type MouseEvent } from 'react';
2
- import Box from '@mui/material/Box';
3
- import ListItemIcon from '@mui/material/ListItemIcon';
4
2
  import Menu, { type MenuProps } from '@mui/material/Menu';
5
- import MenuItem from '@mui/material/MenuItem';
6
3
  import { useTheme } from '@mui/material/styles';
7
- import {
8
- commonListItemStyles,
9
- commonMenuItemStyles,
10
- } from './MRT_ColumnActionMenu';
4
+ import { MRT_ActionMenuItem } from './MRT_ActionMenuItem';
11
5
  import {
12
6
  type MRT_Row,
13
7
  type MRT_RowData,
@@ -58,6 +52,7 @@ export const MRT_RowActionMenu = <TData extends MRT_RowData>({
58
52
  },
59
53
  }}
60
54
  anchorEl={anchorEl}
55
+ disableScrollLock
61
56
  onClick={(event) => event.stopPropagation()}
62
57
  onClose={() => setAnchorEl(null)}
63
58
  open={!!anchorEl}
@@ -65,14 +60,12 @@ export const MRT_RowActionMenu = <TData extends MRT_RowData>({
65
60
  >
66
61
  {parseFromValuesOrFunc(enableEditing, row) &&
67
62
  ['modal', 'row'].includes(editDisplayMode!) && (
68
- <MenuItem onClick={handleEdit} sx={commonMenuItemStyles}>
69
- <Box sx={commonListItemStyles}>
70
- <ListItemIcon>
71
- <EditIcon />
72
- </ListItemIcon>
73
- {localization.edit}
74
- </Box>
75
- </MenuItem>
63
+ <MRT_ActionMenuItem
64
+ icon={<EditIcon />}
65
+ label={localization.edit}
66
+ onClick={handleEdit}
67
+ table={table}
68
+ />
76
69
  )}
77
70
  {renderRowActionMenuItems?.({
78
71
  closeMenu: () => setAnchorEl(null),
@@ -91,6 +91,7 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
91
91
  },
92
92
  }}
93
93
  anchorEl={anchorEl}
94
+ disableScrollLock
94
95
  onClose={() => setAnchorEl(null)}
95
96
  open={!!anchorEl}
96
97
  {...rest}
@@ -114,7 +115,9 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
114
115
  {enableColumnOrdering && (
115
116
  <Button
116
117
  onClick={() =>
117
- table.setColumnOrder(getDefaultColumnOrderIds(table.options))
118
+ table.setColumnOrder(
119
+ getDefaultColumnOrderIds(table.options, true),
120
+ )
118
121
  }
119
122
  >
120
123
  {localization.resetOrder}
@@ -67,6 +67,7 @@ export const MRT_Table = <TData extends MRT_RowData>({
67
67
  sx={(theme) => ({
68
68
  borderCollapse: 'separate',
69
69
  display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
70
+ position: 'relative',
70
71
  ...(parseFromValuesOrFunc(tableProps?.sx, theme) as any),
71
72
  })}
72
73
  >
@@ -6,6 +6,7 @@ import { MRT_Table } from './MRT_Table';
6
6
  import { MRT_TableLoadingOverlay } from './MRT_TableLoadingOverlay';
7
7
  import { type MRT_RowData, type MRT_TableInstance } from '../../types';
8
8
  import { parseFromValuesOrFunc } from '../../utils/utils';
9
+ import { MRT_CellActionMenu } from '../menus/MRT_CellActionMenu';
9
10
  import { MRT_EditRowModal } from '../modals/MRT_EditRowModal';
10
11
 
11
12
  const useIsomorphicLayoutEffect =
@@ -24,12 +25,14 @@ export const MRT_TableContainer = <TData extends MRT_RowData>({
24
25
  options: {
25
26
  createDisplayMode,
26
27
  editDisplayMode,
28
+ enableCellActions,
27
29
  enableStickyHeader,
28
30
  muiTableContainerProps,
29
31
  },
30
32
  refs: { bottomToolbarRef, tableContainerRef, topToolbarRef },
31
33
  } = table;
32
34
  const {
35
+ actionCell,
33
36
  creatingRow,
34
37
  editingRow,
35
38
  isFullScreen,
@@ -101,6 +104,7 @@ export const MRT_TableContainer = <TData extends MRT_RowData>({
101
104
  {(createModalOpen || editModalOpen) && (
102
105
  <MRT_EditRowModal open table={table} />
103
106
  )}
107
+ {enableCellActions && actionCell && <MRT_CellActionMenu table={table} />}
104
108
  </TableContainer>
105
109
  );
106
110
  };
@@ -8,6 +8,7 @@ import Select, { type SelectProps } from '@mui/material/Select';
8
8
  import Tooltip from '@mui/material/Tooltip';
9
9
  import Typography from '@mui/material/Typography';
10
10
  import { useTheme } from '@mui/material/styles';
11
+ import useMediaQuery from '@mui/material/useMediaQuery';
11
12
  import { type MRT_RowData, type MRT_TableInstance } from '../../types';
12
13
  import { flipIconStyles, getCommonTooltipProps } from '../../utils/style.utils';
13
14
  import { parseFromValuesOrFunc } from '../../utils/utils';
@@ -33,6 +34,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
33
34
  ...rest
34
35
  }: Props<TData>) => {
35
36
  const theme = useTheme();
37
+ const isMobile = useMediaQuery('(max-width: 720px)');
36
38
 
37
39
  const {
38
40
  getPrePaginationRowModel,
@@ -67,18 +69,22 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
67
69
  const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
68
70
 
69
71
  const {
70
- SelectProps,
72
+ SelectProps = {},
71
73
  disabled = false,
72
74
  rowsPerPageOptions = defaultRowsPerPage,
73
75
  showFirstButton = showFirstLastPageButtons,
74
76
  showLastButton = showFirstLastPageButtons,
75
77
  showRowsPerPage = true,
76
- ..._rest
78
+ ...restPaginationProps
77
79
  } = paginationProps ?? {};
78
80
 
79
81
  const disableBack = pageIndex <= 0 || disabled;
80
82
  const disableNext = lastRowIndex >= totalRowCount || disabled;
81
83
 
84
+ if (isMobile && SelectProps?.native !== false) {
85
+ SelectProps.native = true;
86
+ }
87
+
82
88
  const tooltipProps = getCommonTooltipProps();
83
89
 
84
90
  return (
@@ -109,10 +115,13 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
109
115
  {localization.rowsPerPage}
110
116
  </InputLabel>
111
117
  <Select
118
+ MenuProps={{ disableScrollLock: true }}
112
119
  disableUnderline
113
120
  disabled={disabled}
114
- id="mrt-rows-per-page"
115
- inputProps={{ 'aria-label': localization.rowsPerPage }}
121
+ inputProps={{
122
+ 'aria-label': localization.rowsPerPage,
123
+ id: 'mrt-rows-per-page',
124
+ }}
116
125
  label={localization.rowsPerPage}
117
126
  onChange={(event) => setPageSize(+(event.target.value as any))}
118
127
  sx={{ mb: 0 }}
@@ -159,7 +168,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
159
168
  )}
160
169
  showFirstButton={showFirstButton}
161
170
  showLastButton={showLastButton}
162
- {..._rest}
171
+ {...restPaginationProps}
163
172
  />
164
173
  ) : paginationDisplayMode === 'default' ? (
165
174
  <>
@@ -4,18 +4,11 @@ import {
4
4
  type MRT_RowData,
5
5
  type MRT_StatefulTableOptions,
6
6
  } from '../../types';
7
- import {
8
- defaultDisplayColumnProps,
9
- showRowActionsColumn,
10
- } from '../../utils/displayColumn.utils';
7
+ import { defaultDisplayColumnProps } from '../../utils/displayColumn.utils';
11
8
 
12
9
  export const getMRT_RowActionsColumnDef = <TData extends MRT_RowData>(
13
10
  tableOptions: MRT_StatefulTableOptions<TData>,
14
11
  ): MRT_ColumnDef<TData> | null => {
15
- if (!showRowActionsColumn(tableOptions)) {
16
- return null;
17
- }
18
-
19
12
  return {
20
13
  Cell: ({ cell, row, staticRowIndex, table }) => (
21
14
  <MRT_ToggleRowActionMenuButton
@@ -5,18 +5,11 @@ import {
5
5
  type MRT_RowData,
6
6
  type MRT_StatefulTableOptions,
7
7
  } from '../../types';
8
- import {
9
- defaultDisplayColumnProps,
10
- showRowDragColumn,
11
- } from '../../utils/displayColumn.utils';
8
+ import { defaultDisplayColumnProps } from '../../utils/displayColumn.utils';
12
9
 
13
10
  export const getMRT_RowDragColumnDef = <TData extends MRT_RowData>(
14
11
  tableOptions: MRT_StatefulTableOptions<TData>,
15
12
  ): MRT_ColumnDef<TData> | null => {
16
- if (!showRowDragColumn(tableOptions)) {
17
- return null;
18
- }
19
-
20
13
  return {
21
14
  Cell: ({ row, rowRef, table }) => (
22
15
  <MRT_TableBodyRowGrabHandle
@@ -8,19 +8,12 @@ import {
8
8
  type MRT_RowData,
9
9
  type MRT_StatefulTableOptions,
10
10
  } from '../../types';
11
- import {
12
- defaultDisplayColumnProps,
13
- showRowExpandColumn,
14
- } from '../../utils/displayColumn.utils';
11
+ import { defaultDisplayColumnProps } from '../../utils/displayColumn.utils';
15
12
  import { getCommonTooltipProps } from '../../utils/style.utils';
16
13
 
17
14
  export const getMRT_RowExpandColumnDef = <TData extends MRT_RowData>(
18
15
  tableOptions: MRT_StatefulTableOptions<TData>,
19
16
  ): MRT_ColumnDef<TData> | null => {
20
- if (!showRowExpandColumn(tableOptions)) {
21
- return null;
22
- }
23
-
24
17
  const {
25
18
  defaultColumn,
26
19
  enableExpandAll,