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
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { flexRender as flexRender$1, createRow as createRow$1, aggregationFns, filterFns, sortingFns, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
2
2
  import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
3
- import { useMemo, useState, useReducer, useRef, useEffect, useCallback, memo, Fragment as Fragment$1, useLayoutEffect } from 'react';
3
+ import { useState, useMemo, useReducer, useRef, useEffect, useCallback, memo, Fragment as Fragment$1, useLayoutEffect } from 'react';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import IconButton from '@mui/material/IconButton';
6
6
  import Tooltip from '@mui/material/Tooltip';
@@ -8,8 +8,8 @@ import Box from '@mui/material/Box';
8
8
  import Button from '@mui/material/Button';
9
9
  import CircularProgress from '@mui/material/CircularProgress';
10
10
  import { lighten, darken, alpha, useTheme } from '@mui/material/styles';
11
- import ListItemIcon from '@mui/material/ListItemIcon';
12
11
  import Menu from '@mui/material/Menu';
12
+ import ListItemIcon from '@mui/material/ListItemIcon';
13
13
  import MenuItem from '@mui/material/MenuItem';
14
14
  import Stack from '@mui/material/Stack';
15
15
  import Checkbox from '@mui/material/Checkbox';
@@ -21,6 +21,7 @@ import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
21
21
  import ChevronRightIcon from '@mui/icons-material/ChevronRight';
22
22
  import ClearAllIcon from '@mui/icons-material/ClearAll';
23
23
  import CloseIcon from '@mui/icons-material/Close';
24
+ import ContentCopy from '@mui/icons-material/ContentCopy';
24
25
  import DensityLargeIcon from '@mui/icons-material/DensityLarge';
25
26
  import DensityMediumIcon from '@mui/icons-material/DensityMedium';
26
27
  import DensitySmallIcon from '@mui/icons-material/DensitySmall';
@@ -212,17 +213,58 @@ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parent
212
213
  [getColumnId(col)]: '',
213
214
  }))), rowIndex, depth, subRows, parentId);
214
215
 
216
+ const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
217
+ const getValueAndLabel = (option) => {
218
+ var _a, _b, _c;
219
+ let label = '';
220
+ let value = '';
221
+ if (option) {
222
+ if (typeof option !== 'object') {
223
+ label = option;
224
+ value = option;
225
+ }
226
+ else {
227
+ label = (_b = (_a = option.label) !== null && _a !== void 0 ? _a : option.text) !== null && _b !== void 0 ? _b : option.value;
228
+ value = (_c = option.value) !== null && _c !== void 0 ? _c : label;
229
+ }
230
+ }
231
+ return { label, value };
232
+ };
233
+
234
+ const isCellEditable = ({ cell, table, }) => {
235
+ const { enableEditing } = table.options;
236
+ const { column: { columnDef }, row, } = cell;
237
+ return (!cell.getIsPlaceholder() &&
238
+ parseFromValuesOrFunc(enableEditing, row) &&
239
+ parseFromValuesOrFunc(columnDef.enableEditing, row) !== false);
240
+ };
241
+ const openEditingCell = ({ cell, table, }) => {
242
+ const { options: { editDisplayMode }, refs: { editInputRefs }, } = table;
243
+ const { column } = cell;
244
+ if (isCellEditable({ cell, table }) && editDisplayMode === 'cell') {
245
+ table.setEditingCell(cell);
246
+ queueMicrotask(() => {
247
+ var _a;
248
+ const textField = editInputRefs.current[column.id];
249
+ if (textField) {
250
+ textField.focus();
251
+ (_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
252
+ }
253
+ });
254
+ }
255
+ };
256
+
215
257
  function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
216
258
  const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
217
259
  return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumn), { header: header ? localization[header] : '', size }), displayColumnDefOptions === null || displayColumnDefOptions === void 0 ? void 0 : displayColumnDefOptions[id]), { id });
218
260
  }
219
261
  const showRowPinningColumn = (tableOptions) => {
220
262
  const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
221
- return enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select'));
263
+ return !!(enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select')));
222
264
  };
223
265
  const showRowDragColumn = (tableOptions) => {
224
266
  const { enableRowDragging, enableRowOrdering } = tableOptions;
225
- return enableRowDragging || enableRowOrdering;
267
+ return !!(enableRowDragging || enableRowOrdering);
226
268
  };
227
269
  const showRowExpandColumn = (tableOptions) => {
228
270
  const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
@@ -232,12 +274,12 @@ const showRowExpandColumn = (tableOptions) => {
232
274
  };
233
275
  const showRowActionsColumn = (tableOptions) => {
234
276
  const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
235
- return (enableRowActions ||
277
+ return !!(enableRowActions ||
236
278
  (creatingRow && createDisplayMode === 'row') ||
237
279
  (enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
238
280
  };
239
- const showRowSelectionColumn = (tableOptions) => tableOptions.enableRowSelection;
240
- const showRowNumbersColumn = (tableOptions) => tableOptions.enableRowNumbers;
281
+ const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
282
+ const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
241
283
  const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
242
284
  const getLeadingDisplayColumnIds = (tableOptions) => [
243
285
  showRowPinningColumn(tableOptions) && 'mrt-row-pin',
@@ -260,32 +302,21 @@ const getTrailingDisplayColumnIds = (tableOptions) => [
260
302
  'mrt-row-expand',
261
303
  showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
262
304
  ].filter(Boolean);
263
- const getDefaultColumnOrderIds = (tableOptions) => {
264
- const leadingDisplayCols = getLeadingDisplayColumnIds(tableOptions);
265
- const trailingDisplayCols = getTrailingDisplayColumnIds(tableOptions);
266
- const allLeafColumnDefs = getAllLeafColumnDefs(tableOptions.columns)
267
- .map((columnDef) => getColumnId(columnDef))
268
- .filter((columnId) => !leadingDisplayCols.includes(columnId) &&
269
- !trailingDisplayCols.includes(columnId));
270
- return [...leadingDisplayCols, ...allLeafColumnDefs, ...trailingDisplayCols];
271
- };
272
-
273
- const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
274
- const getValueAndLabel = (option) => {
275
- var _a, _b, _c;
276
- let label = '';
277
- let value = '';
278
- if (option) {
279
- if (typeof option !== 'object') {
280
- label = option;
281
- value = option;
282
- }
283
- else {
284
- label = (_b = (_a = option.label) !== null && _a !== void 0 ? _a : option.text) !== null && _b !== void 0 ? _b : option.value;
285
- value = (_c = option.value) !== null && _c !== void 0 ? _c : label;
286
- }
287
- }
288
- return { label, value };
305
+ const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
306
+ const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
307
+ const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
308
+ const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
309
+ const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
310
+ let allLeafColumnDefIds = reset
311
+ ? defaultColumnDefIds
312
+ : Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
313
+ allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
314
+ !trailingDisplayColIds.includes(colId));
315
+ return [
316
+ ...leadingDisplayColIds,
317
+ ...allLeafColumnDefIds,
318
+ ...trailingDisplayColIds,
319
+ ];
289
320
  };
290
321
 
291
322
  const getIsRowSelected = ({ row, table, }) => {
@@ -500,7 +531,7 @@ const getMRTTheme = (table, theme) => {
500
531
  ? darken(theme.palette.warning.dark, 0.25)
501
532
  : lighten(theme.palette.warning.light, 0.5), menuBackgroundColor: lighten(baseBackgroundColor, 0.07), pinnedRowBackgroundColor: alpha(theme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(theme.palette.primary.main, 0.2) }, themeOverrides);
502
533
  };
503
- const pinnedBeforeAfterStyles = {
534
+ const commonCellBeforeAfterStyles = {
504
535
  content: '""',
505
536
  height: '100%',
506
537
  left: 0,
@@ -519,14 +550,16 @@ const getCommonPinnedCellStyles = ({ column, table, theme, }) => {
519
550
  : getIsFirstRightPinnedColumn(column)
520
551
  ? `4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset`
521
552
  : undefined
522
- : undefined }, pinnedBeforeAfterStyles),
553
+ : undefined }, commonCellBeforeAfterStyles),
523
554
  },
524
555
  };
525
556
  };
526
557
  const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
527
558
  var _a, _b, _c, _d, _e, _f;
528
- const { options: { enableColumnVirtualization, layoutMode }, } = table;
559
+ const { getState, options: { enableColumnVirtualization, layoutMode }, } = table;
560
+ const { draggingColumn } = getState();
529
561
  const { columnDef } = column;
562
+ const { columnDefType } = columnDef;
530
563
  const isColumnPinned = columnDef.columnDefType !== 'group' && column.getIsPinned();
531
564
  const widthStyles = {
532
565
  minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_a = header === null || header === void 0 ? void 0 : header.id) !== null && _a !== void 0 ? _a : column.id)}-size) * 1px), ${(_b = columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
@@ -545,13 +578,21 @@ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme,
545
578
  ? `${column.getStart('left')}px`
546
579
  : undefined, opacity: 0.97, position: 'sticky', right: isColumnPinned === 'right'
547
580
  ? `${getTotalRight(table, column)}px`
548
- : undefined, zIndex: 1 }) : {};
549
- return Object.assign(Object.assign(Object.assign({ backgroundColor: 'inherit', backgroundImage: 'inherit', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: ((_e = table.getState().draggingColumn) === null || _e === void 0 ? void 0 : _e.id) === column.id ||
581
+ : undefined }) : {};
582
+ return Object.assign(Object.assign(Object.assign({ backgroundColor: 'inherit', backgroundImage: 'inherit', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, justifyContent: columnDefType === 'group'
583
+ ? 'center'
584
+ : (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid'))
585
+ ? tableCellProps.align
586
+ : undefined, opacity: ((_e = table.getState().draggingColumn) === null || _e === void 0 ? void 0 : _e.id) === column.id ||
550
587
  ((_f = table.getState().hoveredColumn) === null || _f === void 0 ? void 0 : _f.id) === column.id
551
588
  ? 0.5
552
589
  : 1, position: 'relative', transition: enableColumnVirtualization
553
590
  ? 'none'
554
- : `padding 150ms ease-in-out`, zIndex: 0 }, pinnedStyles), widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
591
+ : `padding 150ms ease-in-out`, zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
592
+ ? 2
593
+ : columnDefType !== 'group' && isColumnPinned
594
+ ? 1
595
+ : 0 }, pinnedStyles), widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
555
596
  };
556
597
  const getCommonToolbarStyles = ({ table, theme, }) => ({
557
598
  alignItems: 'flex-start',
@@ -574,355 +615,19 @@ const getCommonTooltipProps = (placement) => ({
574
615
  placement,
575
616
  });
576
617
 
577
- const mrtFilterOptions = (localization) => [
578
- {
579
- divider: false,
580
- label: localization.filterFuzzy,
581
- option: 'fuzzy',
582
- symbol: '',
583
- },
584
- {
585
- divider: false,
586
- label: localization.filterContains,
587
- option: 'contains',
588
- symbol: '*',
589
- },
590
- {
591
- divider: false,
592
- label: localization.filterStartsWith,
593
- option: 'startsWith',
594
- symbol: 'a',
595
- },
596
- {
597
- divider: true,
598
- label: localization.filterEndsWith,
599
- option: 'endsWith',
600
- symbol: 'z',
601
- },
602
- {
603
- divider: false,
604
- label: localization.filterEquals,
605
- option: 'equals',
606
- symbol: '=',
607
- },
608
- {
609
- divider: true,
610
- label: localization.filterNotEquals,
611
- option: 'notEquals',
612
- symbol: '≠',
613
- },
614
- {
615
- divider: false,
616
- label: localization.filterBetween,
617
- option: 'between',
618
- symbol: '⇿',
619
- },
620
- {
621
- divider: true,
622
- label: localization.filterBetweenInclusive,
623
- option: 'betweenInclusive',
624
- symbol: '⬌',
625
- },
626
- {
627
- divider: false,
628
- label: localization.filterGreaterThan,
629
- option: 'greaterThan',
630
- symbol: '>',
631
- },
632
- {
633
- divider: false,
634
- label: localization.filterGreaterThanOrEqualTo,
635
- option: 'greaterThanOrEqualTo',
636
- symbol: '≥',
637
- },
638
- {
639
- divider: false,
640
- label: localization.filterLessThan,
641
- option: 'lessThan',
642
- symbol: '<',
643
- },
644
- {
645
- divider: true,
646
- label: localization.filterLessThanOrEqualTo,
647
- option: 'lessThanOrEqualTo',
648
- symbol: '≤',
649
- },
650
- {
651
- divider: false,
652
- label: localization.filterEmpty,
653
- option: 'empty',
654
- symbol: '∅',
655
- },
656
- {
657
- divider: false,
658
- label: localization.filterNotEmpty,
659
- option: 'notEmpty',
660
- symbol: '!∅',
661
- },
662
- ];
663
- const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
664
- const emptyModes = ['empty', 'notEmpty'];
665
- const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
666
- const rangeVariants = ['range-slider', 'date-range', 'datetime-range', 'range'];
667
- const MRT_FilterOptionMenu = (_a) => {
668
- var _b, _c, _d, _e;
669
- var { anchorEl, header, onSelect, setAnchorEl, setFilterValue, table } = _a, rest = __rest(_a, ["anchorEl", "header", "onSelect", "setAnchorEl", "setFilterValue", "table"]);
670
- const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
671
- const { density, globalFilterFn } = getState();
672
- const { column } = header !== null && header !== void 0 ? header : {};
673
- const { columnDef } = column !== null && column !== void 0 ? column : {};
674
- const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
675
- let allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
676
- if (rangeVariants.includes(columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant)) {
677
- allowedColumnFilterOptions = [
678
- ...rangeModes,
679
- ...(allowedColumnFilterOptions !== null && allowedColumnFilterOptions !== void 0 ? allowedColumnFilterOptions : []),
680
- ].filter((option) => rangeModes.includes(option));
681
- }
682
- const internalFilterOptions = useMemo(() => mrtFilterOptions(localization).filter((filterOption) => columnDef
683
- ? allowedColumnFilterOptions === undefined ||
684
- (allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.includes(filterOption.option))
685
- : (!globalFilterModeOptions ||
686
- globalFilterModeOptions.includes(filterOption.option)) &&
687
- ['contains', 'fuzzy', 'startsWith'].includes(filterOption.option)), []);
688
- const handleSelectFilterMode = (option) => {
689
- var _a, _b;
690
- const prevFilterMode = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef._filterFn) !== null && _a !== void 0 ? _a : '';
691
- if (!header || !column) {
692
- // global filter mode
693
- setGlobalFilterFn(option);
694
- }
695
- else if (option !== prevFilterMode) {
696
- // column filter mode
697
- setColumnFilterFns((prev) => (Object.assign(Object.assign({}, prev), { [header.id]: option })));
698
- // reset filter value and/or perform new filter render
699
- if (emptyModes.includes(option)) {
700
- // will now be empty/notEmpty filter mode
701
- if (currentFilterValue !== ' ' &&
702
- !emptyModes.includes(prevFilterMode)) {
703
- column.setFilterValue(' ');
704
- }
705
- else if (currentFilterValue) {
706
- column.setFilterValue(currentFilterValue); // perform new filter render
707
- }
708
- }
709
- else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
710
- arrModes.includes(option)) {
711
- // will now be array filter mode
712
- if (currentFilterValue instanceof String ||
713
- (currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.length)) {
714
- column.setFilterValue([]);
715
- setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue([]);
716
- }
717
- else if (currentFilterValue) {
718
- column.setFilterValue(currentFilterValue); // perform new filter render
719
- }
720
- }
721
- else if (((_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === null || _b === void 0 ? void 0 : _b.includes('range')) ||
722
- rangeModes.includes(option)) {
723
- // will now be range filter mode
724
- if (!Array.isArray(currentFilterValue) ||
725
- (!(currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.every((v) => v === '')) &&
726
- !rangeModes.includes(prevFilterMode))) {
727
- column.setFilterValue(['', '']);
728
- setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
729
- }
730
- else {
731
- column.setFilterValue(currentFilterValue); // perform new filter render
732
- }
733
- }
734
- else {
735
- // will now be single value filter mode
736
- if (Array.isArray(currentFilterValue)) {
737
- column.setFilterValue('');
738
- setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
739
- }
740
- else if (currentFilterValue === ' ' &&
741
- emptyModes.includes(prevFilterMode)) {
742
- column.setFilterValue(undefined);
743
- }
744
- else {
745
- column.setFilterValue(currentFilterValue); // perform new filter render
746
- }
747
- }
748
- }
749
- setAnchorEl(null);
750
- onSelect === null || onSelect === void 0 ? void 0 : onSelect();
751
- };
752
- const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
753
- const theme = useTheme();
754
- const { menuBackgroundColor } = getMRTTheme(table, theme);
755
- return (jsx(Menu, Object.assign({ MenuListProps: {
756
- dense: density === 'compact',
757
- sx: {
758
- backgroundColor: menuBackgroundColor,
759
- },
760
- }, anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_e = (header && column && columnDef
761
- ? (_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
762
- column: column,
763
- internalFilterOptions,
764
- onSelectFilterMode: handleSelectFilterMode,
765
- table,
766
- })) !== null && _d !== void 0 ? _d : renderColumnFilterModeMenuItems === null || renderColumnFilterModeMenuItems === void 0 ? void 0 : renderColumnFilterModeMenuItems({
767
- column: column,
768
- internalFilterOptions,
769
- onSelectFilterMode: handleSelectFilterMode,
770
- table,
771
- })
772
- : renderGlobalFilterModeMenuItems === null || renderGlobalFilterModeMenuItems === void 0 ? void 0 : renderGlobalFilterModeMenuItems({
773
- internalFilterOptions,
774
- onSelectFilterMode: handleSelectFilterMode,
775
- table,
776
- }))) !== null && _e !== void 0 ? _e : internalFilterOptions.map(({ divider, label, option, symbol }, index) => (jsxs(MenuItem, { divider: divider, onClick: () => handleSelectFilterMode(option), selected: option === filterOption, sx: {
777
- alignItems: 'center',
778
- display: 'flex',
779
- gap: '2ch',
780
- my: 0,
781
- py: '6px',
782
- }, value: option, children: [jsx(Box, { sx: { fontSize: '1.25rem', width: '2ch' }, children: symbol }), label] }, index))) })));
783
- };
784
-
785
- const commonMenuItemStyles = {
786
- alignItems: 'center',
787
- justifyContent: 'space-between',
788
- my: 0,
789
- py: '6px',
790
- };
791
- const commonListItemStyles = {
792
- alignItems: 'center',
793
- display: 'flex',
794
- };
795
- const MRT_ColumnActionMenu = (_a) => {
796
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
797
- var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
798
- const { getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ArrowRightIcon, ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnFilterFns, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, toggleAllColumnsVisible, } = table;
799
- const { column } = header;
800
- const { columnDef } = column;
801
- const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
802
- const columnFilterValue = column.getFilterValue();
803
- const [filterMenuAnchorEl, setFilterMenuAnchorEl] = useState(null);
804
- const handleClearSort = () => {
805
- column.clearSorting();
806
- setAnchorEl(null);
807
- };
808
- const handleSortAsc = () => {
809
- column.toggleSorting(false);
810
- setAnchorEl(null);
811
- };
812
- const handleSortDesc = () => {
813
- column.toggleSorting(true);
814
- setAnchorEl(null);
815
- };
816
- const handleResetColumnSize = () => {
817
- setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
818
- column.resetSize();
819
- setAnchorEl(null);
820
- };
821
- const handleHideColumn = () => {
822
- column.toggleVisibility(false);
823
- setAnchorEl(null);
824
- };
825
- const handlePinColumn = (pinDirection) => {
826
- column.pin(pinDirection);
827
- setAnchorEl(null);
828
- };
829
- const handleGroupByColumn = () => {
830
- column.toggleGrouping();
831
- setColumnOrder((old) => ['mrt-row-expand', ...old]);
832
- setAnchorEl(null);
833
- };
834
- const handleClearFilter = () => {
835
- column.setFilterValue(undefined);
836
- setAnchorEl(null);
837
- if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
838
- setColumnFilterFns((prev) => {
839
- var _a;
840
- return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
841
- });
842
- }
843
- };
844
- const handleFilterByColumn = () => {
845
- setShowColumnFilters(true);
846
- queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); });
847
- setAnchorEl(null);
848
- };
849
- const handleShowAllColumns = () => {
850
- toggleAllColumnsVisible(true);
851
- setAnchorEl(null);
852
- };
853
- const handleOpenFilterModeMenu = (event) => {
854
- event.stopPropagation();
855
- setFilterMenuAnchorEl(event.currentTarget);
856
- };
857
- const isSelectFilter = !!columnDef.filterSelectOptions;
858
- const allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
859
- const showFilterModeSubMenu = enableColumnFilterModes &&
860
- columnDef.enableColumnFilterModes !== false &&
861
- !isSelectFilter &&
862
- (allowedColumnFilterOptions === undefined ||
863
- !!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
864
- const internalColumnMenuItems = [
865
- ...(enableSorting && column.getCanSort()
866
- ? [
867
- enableSortingRemoval !== false && (jsx(MenuItem, { disabled: !column.getIsSorted(), onClick: handleClearSort, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(ClearAllIcon, {}) }), localization.clearSort] }) }, 0)),
868
- jsx(MenuItem, { disabled: column.getIsSorted() === 'asc', onClick: handleSortAsc, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(SortIcon, { style: { transform: 'rotate(180deg) scaleX(-1)' } }) }), (_c = localization.sortByColumnAsc) === null || _c === void 0 ? void 0 : _c.replace('{column}', String(columnDef.header))] }) }, 1),
869
- jsx(MenuItem, { disabled: column.getIsSorted() === 'desc', divider: enableColumnFilters || enableGrouping || enableHiding, onClick: handleSortDesc, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(SortIcon, {}) }), (_d = localization.sortByColumnDesc) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header))] }) }, 2),
870
- ]
871
- : []),
872
- ...(enableColumnFilters && column.getCanFilter()
873
- ? [
874
- jsx(MenuItem, { disabled: !columnFilterValue ||
875
- (Array.isArray(columnFilterValue) &&
876
- !columnFilterValue.filter((value) => value).length), onClick: handleClearFilter, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(FilterListOffIcon, {}) }), localization.clearFilter] }) }, 3),
877
- columnFilterDisplayMode === 'subheader' && (jsxs(MenuItem, { disabled: showColumnFilters && !enableColumnFilterModes, divider: enableGrouping || enableHiding, onClick: showColumnFilters
878
- ? handleOpenFilterModeMenu
879
- : handleFilterByColumn, sx: commonMenuItemStyles, children: [jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(FilterListIcon, {}) }), (_e = localization.filterByColumn) === null || _e === void 0 ? void 0 : _e.replace('{column}', String(columnDef.header))] }), showFilterModeSubMenu && (jsx(IconButton, { onClick: handleOpenFilterModeMenu, onMouseEnter: handleOpenFilterModeMenu, size: "small", sx: { p: 0 }, children: jsx(ArrowRightIcon, {}) }))] }, 4)),
880
- showFilterModeSubMenu && (jsx(MRT_FilterOptionMenu, { anchorEl: filterMenuAnchorEl, header: header, onSelect: handleFilterByColumn, setAnchorEl: setFilterMenuAnchorEl, table: table }, 5)),
881
- ].filter(Boolean)
882
- : []),
883
- ...(enableGrouping && column.getCanGroup()
884
- ? [
885
- jsx(MenuItem, { divider: enableColumnPinning, onClick: handleGroupByColumn, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(DynamicFeedIcon, {}) }), (_f = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) === null || _f === void 0 ? void 0 : _f.replace('{column}', String(columnDef.header))] }) }, 6),
886
- ]
887
- : []),
888
- ...(enableColumnPinning && column.getCanPin()
889
- ? [
890
- jsx(MenuItem, { disabled: column.getIsPinned() === 'left' || !column.getCanPin(), onClick: () => handlePinColumn('left'), sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(PushPinIcon, { style: { transform: 'rotate(90deg)' } }) }), localization.pinToLeft] }) }, 7),
891
- jsx(MenuItem, { disabled: column.getIsPinned() === 'right' || !column.getCanPin(), onClick: () => handlePinColumn('right'), sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(PushPinIcon, { style: { transform: 'rotate(-90deg)' } }) }), localization.pinToRight] }) }, 8),
892
- jsx(MenuItem, { disabled: !column.getIsPinned(), divider: enableHiding, onClick: () => handlePinColumn(false), sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(PushPinIcon, {}) }), localization.unpin] }) }, 9),
893
- ]
894
- : []),
895
- ...(enableColumnResizing && column.getCanResize()
896
- ? [
897
- jsx(MenuItem, { disabled: !columnSizing[column.id], onClick: handleResetColumnSize, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(RestartAltIcon, {}) }), localization.resetColumnSize] }) }, 10),
898
- ]
899
- : []),
900
- ...(enableHiding
901
- ? [
902
- jsx(MenuItem, { disabled: !column.getCanHide(), onClick: handleHideColumn, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(VisibilityOffIcon, {}) }), (_g = localization.hideColumn) === null || _g === void 0 ? void 0 : _g.replace('{column}', String(columnDef.header))] }) }, 11),
903
- jsx(MenuItem, { disabled: !Object.values(columnVisibility).filter((visible) => !visible)
904
- .length, onClick: handleShowAllColumns, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(ViewColumnIcon, {}) }), (_h = localization.showAllColumns) === null || _h === void 0 ? void 0 : _h.replace('{column}', String(columnDef.header))] }) }, 12),
905
- ]
906
- : []),
907
- ].filter(Boolean);
908
- const theme = useTheme();
909
- const { menuBackgroundColor } = getMRTTheme(table, theme);
910
- return (jsx(Menu, Object.assign({ MenuListProps: {
911
- dense: density === 'compact',
912
- sx: {
913
- backgroundColor: menuBackgroundColor,
914
- },
915
- }, anchorEl: anchorEl, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_l = (_k = (_j = columnDef.renderColumnActionsMenuItems) === null || _j === void 0 ? void 0 : _j.call(columnDef, {
916
- closeMenu: () => setAnchorEl(null),
917
- column,
918
- internalColumnMenuItems,
919
- table,
920
- })) !== null && _k !== void 0 ? _k : renderColumnActionsMenuItems === null || renderColumnActionsMenuItems === void 0 ? void 0 : renderColumnActionsMenuItems({
921
- closeMenu: () => setAnchorEl(null),
922
- column,
923
- internalColumnMenuItems,
924
- table,
925
- })) !== null && _l !== void 0 ? _l : internalColumnMenuItems })));
618
+ const MRT_ActionMenuItem = (_a) => {
619
+ var { icon, label, onOpenSubMenu, table } = _a, rest = __rest(_a, ["icon", "label", "onOpenSubMenu", "table"]);
620
+ const { options: { icons: { ArrowRightIcon }, }, } = table;
621
+ return (jsxs(MenuItem, Object.assign({ sx: {
622
+ alignItems: 'center',
623
+ justifyContent: 'space-between',
624
+ minWidth: '120px',
625
+ my: 0,
626
+ py: '6px',
627
+ } }, rest, { children: [jsxs(Box, { sx: {
628
+ alignItems: 'center',
629
+ display: 'flex',
630
+ }, children: [jsx(ListItemIcon, { children: icon }), label] }), onOpenSubMenu && (jsx(IconButton, { onClick: onOpenSubMenu, onMouseEnter: onOpenSubMenu, size: "small", sx: { p: 0 }, children: jsx(ArrowRightIcon, {}) }))] })));
926
631
  };
927
632
 
928
633
  const MRT_RowActionMenu = (_a) => {
@@ -936,8 +641,8 @@ const MRT_RowActionMenu = (_a) => {
936
641
  sx: {
937
642
  backgroundColor: menuBackgroundColor,
938
643
  },
939
- }, anchorEl: anchorEl, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: [parseFromValuesOrFunc(enableEditing, row) &&
940
- ['modal', 'row'].includes(editDisplayMode) && (jsx(MenuItem, { onClick: handleEdit, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(EditIcon, {}) }), localization.edit] }) })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
644
+ }, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: [parseFromValuesOrFunc(enableEditing, row) &&
645
+ ['modal', 'row'].includes(editDisplayMode) && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
941
646
  closeMenu: () => setAnchorEl(null),
942
647
  row,
943
648
  staticRowIndex,
@@ -980,9 +685,6 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
980
685
  };
981
686
 
982
687
  const getMRT_RowActionsColumnDef = (tableOptions) => {
983
- if (!showRowActionsColumn(tableOptions)) {
984
- return null;
985
- }
986
688
  return Object.assign({ Cell: ({ cell, row, staticRowIndex, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, staticRowIndex: staticRowIndex, table: table })) }, defaultDisplayColumnProps({
987
689
  header: 'actions',
988
690
  id: 'mrt-row-actions',
@@ -1036,9 +738,6 @@ const MRT_TableBodyRowGrabHandle = (_a) => {
1036
738
  };
1037
739
 
1038
740
  const getMRT_RowDragColumnDef = (tableOptions) => {
1039
- if (!showRowDragColumn(tableOptions)) {
1040
- return null;
1041
- }
1042
741
  return Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), grow: false }, defaultDisplayColumnProps({
1043
742
  header: 'move',
1044
743
  id: 'mrt-row-drag',
@@ -1098,9 +797,6 @@ const MRT_ExpandButton = ({ row, staticRowIndex, table, }) => {
1098
797
 
1099
798
  const getMRT_RowExpandColumnDef = (tableOptions) => {
1100
799
  var _a;
1101
- if (!showRowExpandColumn(tableOptions)) {
1102
- return null;
1103
- }
1104
800
  const { defaultColumn, enableExpandAll, groupedColumnMode, positionExpandColumn, renderDetailPanel, state: { grouping }, } = tableOptions;
1105
801
  const alignProps = positionExpandColumn === 'last'
1106
802
  ? {
@@ -1138,9 +834,6 @@ const getMRT_RowExpandColumnDef = (tableOptions) => {
1138
834
  };
1139
835
 
1140
836
  const getMRT_RowNumbersColumnDef = (tableOptions) => {
1141
- if (!showRowNumbersColumn(tableOptions)) {
1142
- return null;
1143
- }
1144
837
  const { localization, rowNumberDisplayMode } = tableOptions;
1145
838
  const { pagination: { pageIndex, pageSize }, } = tableOptions.state;
1146
839
  return Object.assign({ Cell: ({ row, staticRowIndex }) => {
@@ -1194,9 +887,6 @@ const MRT_TableBodyRowPinButton = (_a) => {
1194
887
  };
1195
888
 
1196
889
  const getMRT_RowPinningColumnDef = (tableOptions) => {
1197
- if (!showRowPinningColumn(tableOptions)) {
1198
- return null;
1199
- }
1200
890
  return Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), grow: false }, defaultDisplayColumnProps({
1201
891
  header: 'pin',
1202
892
  id: 'mrt-row-pin',
@@ -1268,9 +958,6 @@ const MRT_SelectCheckbox = (_a) => {
1268
958
  };
1269
959
 
1270
960
  const getMRT_RowSelectColumnDef = (tableOptions) => {
1271
- if (!showRowSelectionColumn(tableOptions)) {
1272
- return null;
1273
- }
1274
961
  const { enableMultiRowSelection, enableSelectAll } = tableOptions;
1275
962
  return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: enableSelectAll && enableMultiRowSelection
1276
963
  ? ({ table }) => jsx(MRT_SelectCheckbox, { table: table })
@@ -1290,6 +977,7 @@ const MRT_Default_Icons = {
1290
977
  ChevronRightIcon,
1291
978
  ClearAllIcon,
1292
979
  CloseIcon,
980
+ ContentCopy,
1293
981
  DensityLargeIcon,
1294
982
  DensityMediumIcon,
1295
983
  DensitySmallIcon,
@@ -1328,6 +1016,7 @@ const MRT_Localization_EN = {
1328
1016
  clearSearch: 'Clear search',
1329
1017
  clearSort: 'Clear sort',
1330
1018
  clickToCopy: 'Click to copy',
1019
+ copy: 'Copy',
1331
1020
  collapse: 'Collapse',
1332
1021
  collapseAll: 'Collapse all',
1333
1022
  columnActions: 'Column Actions',
@@ -1542,9 +1231,6 @@ const blankColProps = {
1542
1231
  },
1543
1232
  };
1544
1233
  const getMRT_RowSpacerColumnDef = (tableOptions) => {
1545
- if (!showRowSpacerColumn(tableOptions)) {
1546
- return null;
1547
- }
1548
1234
  return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumnProps({
1549
1235
  id: 'mrt-row-spacer',
1550
1236
  size: 0,
@@ -1552,21 +1238,10 @@ const getMRT_RowSpacerColumnDef = (tableOptions) => {
1552
1238
  })), { grow: true }), MRT_DefaultDisplayColumn), { muiTableBodyCellProps: blankColProps, muiTableFooterCellProps: blankColProps, muiTableHeadCellProps: blankColProps });
1553
1239
  };
1554
1240
 
1555
- const getMRT_DisplayColumns = (tableOptions) => {
1556
- return [
1557
- getMRT_RowNumbersColumnDef(tableOptions),
1558
- getMRT_RowSelectColumnDef(tableOptions),
1559
- getMRT_RowExpandColumnDef(tableOptions),
1560
- getMRT_RowActionsColumnDef(tableOptions),
1561
- getMRT_RowDragColumnDef(tableOptions),
1562
- getMRT_RowPinningColumnDef(tableOptions),
1563
- getMRT_RowSpacerColumnDef(tableOptions),
1564
- ].filter(Boolean);
1565
- };
1566
-
1567
1241
  const useMRT_Effects = (table) => {
1568
1242
  const { getIsSomeRowsPinned, getPrePaginationRowModel, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
1569
- const { density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
1243
+ const { columnOrder, density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
1244
+ const totalColumnCount = table.options.columns.length;
1570
1245
  const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
1571
1246
  const rerender = useReducer(() => ({}), {})[1];
1572
1247
  const isMounted = useRef(false);
@@ -1629,11 +1304,23 @@ const useMRT_Effects = (table) => {
1629
1304
  rerender();
1630
1305
  }, 150);
1631
1306
  }
1632
- }, [density]);
1307
+ }, [density]);
1308
+ //recalculate column order when columns change or features are toggled on/off
1309
+ useEffect(() => {
1310
+ if (totalColumnCount !== columnOrder.length) {
1311
+ table.setColumnOrder(getDefaultColumnOrderIds(table.options));
1312
+ }
1313
+ }, [totalColumnCount]);
1633
1314
  };
1634
1315
 
1635
- const useMRT_TableInstance = (_tableOptions) => {
1636
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
1316
+ /**
1317
+ * The MRT hook that wraps the TanStack useReactTable hook and adds additional functionality
1318
+ * @param definedTableOptions - table options with proper defaults set
1319
+ * @returns the MRT table instance
1320
+ */
1321
+ const useMRT_TableInstance = (definedTableOptions) => {
1322
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
1323
+ const actionCellRef = useRef(null);
1637
1324
  const bottomToolbarRef = useRef(null);
1638
1325
  const editInputRefs = useRef({});
1639
1326
  const filterInputRefs = useRef({});
@@ -1644,17 +1331,19 @@ const useMRT_TableInstance = (_tableOptions) => {
1644
1331
  const topToolbarRef = useRef(null);
1645
1332
  const tableHeadRef = useRef(null);
1646
1333
  const tableFooterRef = useRef(null);
1334
+ //transform initial state with proper column order
1647
1335
  const initialState = useMemo(() => {
1648
1336
  var _a, _b, _c;
1649
- const initState = (_a = _tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
1337
+ const initState = (_a = definedTableOptions.initialState) !== null && _a !== void 0 ? _a : {};
1650
1338
  initState.columnOrder =
1651
- (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(Object.assign(Object.assign({}, _tableOptions), { state: Object.assign(Object.assign({}, _tableOptions.initialState), _tableOptions.state) }));
1652
- initState.globalFilterFn = (_c = _tableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
1339
+ (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(Object.assign(Object.assign({}, definedTableOptions), { state: Object.assign(Object.assign({}, definedTableOptions.initialState), definedTableOptions.state) }));
1340
+ initState.globalFilterFn = (_c = definedTableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
1653
1341
  return initState;
1654
1342
  }, []);
1655
- _tableOptions.initialState = initialState;
1656
- const [creatingRow, _setCreatingRow] = useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
1657
- const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(_tableOptions.columns).map((col) => {
1343
+ definedTableOptions.initialState = initialState;
1344
+ const [actionCell, setActionCell] = useState((_a = initialState.actionCell) !== null && _a !== void 0 ? _a : null);
1345
+ const [creatingRow, _setCreatingRow] = useState((_b = initialState.creatingRow) !== null && _b !== void 0 ? _b : null);
1346
+ const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(definedTableOptions.columns).map((col) => {
1658
1347
  var _a, _b, _c, _d;
1659
1348
  return ({
1660
1349
  [getColumnId(col)]: col.filterFn instanceof Function
@@ -1662,24 +1351,25 @@ const useMRT_TableInstance = (_tableOptions) => {
1662
1351
  : (_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col),
1663
1352
  });
1664
1353
  })));
1665
- const [columnOrder, onColumnOrderChange] = useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
1666
- const [columnSizingInfo, onColumnSizingInfoChange] = useState((_c = initialState.columnSizingInfo) !== null && _c !== void 0 ? _c : {});
1667
- const [density, setDensity] = useState((_d = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _d !== void 0 ? _d : 'comfortable');
1668
- const [draggingColumn, setDraggingColumn] = useState((_e = initialState.draggingColumn) !== null && _e !== void 0 ? _e : null);
1669
- const [draggingRow, setDraggingRow] = useState((_f = initialState.draggingRow) !== null && _f !== void 0 ? _f : null);
1670
- const [editingCell, setEditingCell] = useState((_g = initialState.editingCell) !== null && _g !== void 0 ? _g : null);
1671
- const [editingRow, setEditingRow] = useState((_h = initialState.editingRow) !== null && _h !== void 0 ? _h : null);
1672
- const [globalFilterFn, setGlobalFilterFn] = useState((_j = initialState.globalFilterFn) !== null && _j !== void 0 ? _j : 'fuzzy');
1673
- const [grouping, onGroupingChange] = useState((_k = initialState.grouping) !== null && _k !== void 0 ? _k : []);
1674
- const [hoveredColumn, setHoveredColumn] = useState((_l = initialState.hoveredColumn) !== null && _l !== void 0 ? _l : null);
1675
- const [hoveredRow, setHoveredRow] = useState((_m = initialState.hoveredRow) !== null && _m !== void 0 ? _m : null);
1676
- const [isFullScreen, setIsFullScreen] = useState((_o = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _o !== void 0 ? _o : false);
1677
- const [pagination, onPaginationChange] = useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _p !== void 0 ? _p : { pageIndex: 0, pageSize: 10 });
1678
- const [showAlertBanner, setShowAlertBanner] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _q !== void 0 ? _q : false);
1679
- const [showColumnFilters, setShowColumnFilters] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _r !== void 0 ? _r : false);
1680
- const [showGlobalFilter, setShowGlobalFilter] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _s !== void 0 ? _s : false);
1681
- const [showToolbarDropZone, setShowToolbarDropZone] = useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _t !== void 0 ? _t : false);
1682
- _tableOptions.state = Object.assign({ columnFilterFns,
1354
+ const [columnOrder, onColumnOrderChange] = useState((_c = initialState.columnOrder) !== null && _c !== void 0 ? _c : []);
1355
+ const [columnSizingInfo, onColumnSizingInfoChange] = useState((_d = initialState.columnSizingInfo) !== null && _d !== void 0 ? _d : {});
1356
+ const [density, setDensity] = useState((_e = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _e !== void 0 ? _e : 'comfortable');
1357
+ const [draggingColumn, setDraggingColumn] = useState((_f = initialState.draggingColumn) !== null && _f !== void 0 ? _f : null);
1358
+ const [draggingRow, setDraggingRow] = useState((_g = initialState.draggingRow) !== null && _g !== void 0 ? _g : null);
1359
+ const [editingCell, setEditingCell] = useState((_h = initialState.editingCell) !== null && _h !== void 0 ? _h : null);
1360
+ const [editingRow, setEditingRow] = useState((_j = initialState.editingRow) !== null && _j !== void 0 ? _j : null);
1361
+ const [globalFilterFn, setGlobalFilterFn] = useState((_k = initialState.globalFilterFn) !== null && _k !== void 0 ? _k : 'fuzzy');
1362
+ const [grouping, onGroupingChange] = useState((_l = initialState.grouping) !== null && _l !== void 0 ? _l : []);
1363
+ const [hoveredColumn, setHoveredColumn] = useState((_m = initialState.hoveredColumn) !== null && _m !== void 0 ? _m : null);
1364
+ const [hoveredRow, setHoveredRow] = useState((_o = initialState.hoveredRow) !== null && _o !== void 0 ? _o : null);
1365
+ const [isFullScreen, setIsFullScreen] = useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _p !== void 0 ? _p : false);
1366
+ const [pagination, onPaginationChange] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _q !== void 0 ? _q : { pageIndex: 0, pageSize: 10 });
1367
+ const [showAlertBanner, setShowAlertBanner] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _r !== void 0 ? _r : false);
1368
+ const [showColumnFilters, setShowColumnFilters] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _s !== void 0 ? _s : false);
1369
+ const [showGlobalFilter, setShowGlobalFilter] = useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _t !== void 0 ? _t : false);
1370
+ const [showToolbarDropZone, setShowToolbarDropZone] = useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _u !== void 0 ? _u : false);
1371
+ definedTableOptions.state = Object.assign({ actionCell,
1372
+ columnFilterFns,
1683
1373
  columnOrder,
1684
1374
  columnSizingInfo,
1685
1375
  creatingRow,
@@ -1697,90 +1387,110 @@ const useMRT_TableInstance = (_tableOptions) => {
1697
1387
  showAlertBanner,
1698
1388
  showColumnFilters,
1699
1389
  showGlobalFilter,
1700
- showToolbarDropZone }, _tableOptions.state);
1701
- const tableOptions = _tableOptions;
1390
+ showToolbarDropZone }, definedTableOptions.state);
1391
+ //The table options now include all state needed to help determine column visibility and order logic
1392
+ const statefulTableOptions = definedTableOptions;
1702
1393
  //don't recompute columnDefs while resizing column or dragging column/row
1703
1394
  const columnDefsRef = useRef([]);
1704
- tableOptions.columns =
1705
- tableOptions.state.columnSizingInfo.isResizingColumn ||
1706
- tableOptions.state.draggingColumn ||
1707
- tableOptions.state.draggingRow
1395
+ statefulTableOptions.columns =
1396
+ statefulTableOptions.state.columnSizingInfo.isResizingColumn ||
1397
+ statefulTableOptions.state.draggingColumn ||
1398
+ statefulTableOptions.state.draggingRow
1708
1399
  ? columnDefsRef.current
1709
1400
  : prepareColumns({
1710
1401
  columnDefs: [
1711
- ...getMRT_DisplayColumns(tableOptions),
1712
- ...tableOptions.columns,
1402
+ ...[
1403
+ showRowPinningColumn(statefulTableOptions) &&
1404
+ getMRT_RowPinningColumnDef(statefulTableOptions),
1405
+ showRowDragColumn(statefulTableOptions) &&
1406
+ getMRT_RowDragColumnDef(statefulTableOptions),
1407
+ showRowActionsColumn(statefulTableOptions) &&
1408
+ getMRT_RowActionsColumnDef(statefulTableOptions),
1409
+ showRowExpandColumn(statefulTableOptions) &&
1410
+ getMRT_RowExpandColumnDef(statefulTableOptions),
1411
+ showRowSelectionColumn(statefulTableOptions) &&
1412
+ getMRT_RowSelectColumnDef(statefulTableOptions),
1413
+ showRowNumbersColumn(statefulTableOptions) &&
1414
+ getMRT_RowNumbersColumnDef(statefulTableOptions),
1415
+ ].filter(Boolean),
1416
+ ...statefulTableOptions.columns,
1417
+ ...[
1418
+ showRowSpacerColumn(statefulTableOptions) &&
1419
+ getMRT_RowSpacerColumnDef(statefulTableOptions),
1420
+ ].filter(Boolean),
1713
1421
  ],
1714
- tableOptions,
1422
+ tableOptions: statefulTableOptions,
1715
1423
  });
1716
- columnDefsRef.current = tableOptions.columns;
1717
- tableOptions.data = useMemo(() => (tableOptions.state.isLoading || tableOptions.state.showSkeletons) &&
1718
- !tableOptions.data.length
1424
+ columnDefsRef.current = statefulTableOptions.columns;
1425
+ //if loading, generate blank rows to show skeleton loaders
1426
+ statefulTableOptions.data = useMemo(() => (statefulTableOptions.state.isLoading ||
1427
+ statefulTableOptions.state.showSkeletons) &&
1428
+ !statefulTableOptions.data.length
1719
1429
  ? [
1720
- ...Array(Math.min(tableOptions.state.pagination.pageSize, 20)).fill(null),
1721
- ].map(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => ({
1430
+ ...Array(Math.min(statefulTableOptions.state.pagination.pageSize, 20)).fill(null),
1431
+ ].map(() => Object.assign({}, ...getAllLeafColumnDefs(statefulTableOptions.columns).map((col) => ({
1722
1432
  [getColumnId(col)]: null,
1723
1433
  }))))
1724
- : tableOptions.data, [
1725
- tableOptions.data,
1726
- tableOptions.state.isLoading,
1727
- tableOptions.state.showSkeletons,
1434
+ : statefulTableOptions.data, [
1435
+ statefulTableOptions.data,
1436
+ statefulTableOptions.state.isLoading,
1437
+ statefulTableOptions.state.showSkeletons,
1728
1438
  ]);
1729
1439
  //@ts-ignore
1730
1440
  const table = useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
1731
1441
  onColumnSizingInfoChange,
1732
1442
  onGroupingChange,
1733
- onPaginationChange }, tableOptions), { globalFilterFn: (_u = tableOptions.filterFns) === null || _u === void 0 ? void 0 : _u[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1734
- //@ts-ignore
1443
+ onPaginationChange }, statefulTableOptions), { globalFilterFn: (_v = statefulTableOptions.filterFns) === null || _v === void 0 ? void 0 : _v[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1735
1444
  table.refs = {
1736
- //@ts-ignore
1445
+ actionCellRef,
1737
1446
  bottomToolbarRef,
1738
1447
  editInputRefs,
1739
1448
  filterInputRefs,
1740
- //@ts-ignore
1741
1449
  searchInputRef,
1742
- //@ts-ignore
1743
1450
  tableContainerRef,
1744
- //@ts-ignore
1745
1451
  tableFooterRef,
1746
1452
  tableHeadCellRefs,
1747
- //@ts-ignore
1748
1453
  tableHeadRef,
1749
- //@ts-ignore
1750
1454
  tablePaperRef,
1751
- //@ts-ignore
1752
1455
  topToolbarRef,
1753
1456
  };
1457
+ table.setActionCell =
1458
+ (_w = statefulTableOptions.onActionCellChange) !== null && _w !== void 0 ? _w : setActionCell;
1754
1459
  table.setCreatingRow = (row) => {
1755
1460
  var _a, _b;
1756
1461
  let _row = row;
1757
1462
  if (row === true) {
1758
1463
  _row = createRow(table);
1759
1464
  }
1760
- (_b = (_a = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(tableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
1465
+ (_b = (_a = statefulTableOptions === null || statefulTableOptions === void 0 ? void 0 : statefulTableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(statefulTableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
1761
1466
  };
1762
1467
  table.setColumnFilterFns =
1763
- (_v = tableOptions.onColumnFilterFnsChange) !== null && _v !== void 0 ? _v : setColumnFilterFns;
1764
- table.setDensity = (_w = tableOptions.onDensityChange) !== null && _w !== void 0 ? _w : setDensity;
1468
+ (_x = statefulTableOptions.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns;
1469
+ table.setDensity = (_y = statefulTableOptions.onDensityChange) !== null && _y !== void 0 ? _y : setDensity;
1765
1470
  table.setDraggingColumn =
1766
- (_x = tableOptions.onDraggingColumnChange) !== null && _x !== void 0 ? _x : setDraggingColumn;
1767
- table.setDraggingRow = (_y = tableOptions.onDraggingRowChange) !== null && _y !== void 0 ? _y : setDraggingRow;
1768
- table.setEditingCell = (_z = tableOptions.onEditingCellChange) !== null && _z !== void 0 ? _z : setEditingCell;
1769
- table.setEditingRow = (_0 = tableOptions.onEditingRowChange) !== null && _0 !== void 0 ? _0 : setEditingRow;
1471
+ (_z = statefulTableOptions.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn;
1472
+ table.setDraggingRow =
1473
+ (_0 = statefulTableOptions.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow;
1474
+ table.setEditingCell =
1475
+ (_1 = statefulTableOptions.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell;
1476
+ table.setEditingRow =
1477
+ (_2 = statefulTableOptions.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow;
1770
1478
  table.setGlobalFilterFn =
1771
- (_1 = tableOptions.onGlobalFilterFnChange) !== null && _1 !== void 0 ? _1 : setGlobalFilterFn;
1479
+ (_3 = statefulTableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
1772
1480
  table.setHoveredColumn =
1773
- (_2 = tableOptions.onHoveredColumnChange) !== null && _2 !== void 0 ? _2 : setHoveredColumn;
1774
- table.setHoveredRow = (_3 = tableOptions.onHoveredRowChange) !== null && _3 !== void 0 ? _3 : setHoveredRow;
1775
- table.setIsFullScreen = (_4 = tableOptions.onIsFullScreenChange) !== null && _4 !== void 0 ? _4 : setIsFullScreen;
1481
+ (_4 = statefulTableOptions.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn;
1482
+ table.setHoveredRow =
1483
+ (_5 = statefulTableOptions.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow;
1484
+ table.setIsFullScreen =
1485
+ (_6 = statefulTableOptions.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen;
1776
1486
  table.setShowAlertBanner =
1777
- (_5 = tableOptions.onShowAlertBannerChange) !== null && _5 !== void 0 ? _5 : setShowAlertBanner;
1487
+ (_7 = statefulTableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
1778
1488
  table.setShowColumnFilters =
1779
- (_6 = tableOptions.onShowColumnFiltersChange) !== null && _6 !== void 0 ? _6 : setShowColumnFilters;
1489
+ (_8 = statefulTableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
1780
1490
  table.setShowGlobalFilter =
1781
- (_7 = tableOptions.onShowGlobalFilterChange) !== null && _7 !== void 0 ? _7 : setShowGlobalFilter;
1491
+ (_9 = statefulTableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
1782
1492
  table.setShowToolbarDropZone =
1783
- (_8 = tableOptions.onShowToolbarDropZoneChange) !== null && _8 !== void 0 ? _8 : setShowToolbarDropZone;
1493
+ (_10 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
1784
1494
  useMRT_Effects(table);
1785
1495
  return table;
1786
1496
  };
@@ -2049,7 +1759,7 @@ const MRT_CopyButton = (_a) => {
2049
1759
  row,
2050
1760
  table,
2051
1761
  })), rest);
2052
- return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _b !== void 0 ? _b : (copied ? localization.copiedToClipboard : localization.clickToCopy), children: jsx(Button, Object.assign({ onClick: (e) => handleCopy(e, cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', textAlign: 'inherit', textTransform: 'inherit' }, parseFromValuesOrFunc(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx, theme))), title: undefined })) })));
1762
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _b !== void 0 ? _b : (copied ? localization.copiedToClipboard : localization.clickToCopy), children: jsx(Button, Object.assign({ onClick: (e) => handleCopy(e, cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', py: 0, textAlign: 'inherit', textTransform: 'inherit' }, parseFromValuesOrFunc(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx, theme))), title: undefined })) })));
2053
1763
  };
2054
1764
 
2055
1765
  const MRT_EditCellTextField = (_a) => {
@@ -2131,7 +1841,9 @@ const MRT_EditCellTextField = (_a) => {
2131
1841
  : {})), textFieldProps.InputProps), { sx: (theme) => {
2132
1842
  var _a;
2133
1843
  return (Object.assign({ mb: 0 }, parseFromValuesOrFunc((_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.sx, theme)));
2134
- } }), inputProps: Object.assign({ autoComplete: 'new-password' }, textFieldProps.inputProps), onBlur: handleBlur, onChange: handleChange, onClick: (e) => {
1844
+ } }), SelectProps: {
1845
+ MenuProps: { disableScrollLock: true },
1846
+ }, inputProps: Object.assign({ autoComplete: 'new-password' }, textFieldProps.inputProps), onBlur: handleBlur, onChange: handleChange, onClick: (e) => {
2135
1847
  var _a;
2136
1848
  e.stopPropagation();
2137
1849
  (_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
@@ -2148,10 +1860,10 @@ const MRT_EditCellTextField = (_a) => {
2148
1860
 
2149
1861
  const MRT_TableBodyCell = (_a) => {
2150
1862
  var _b, _c, _d, _e, _f;
2151
- var { cell, measureElement, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "measureElement", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
1863
+ var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
2152
1864
  const theme = useTheme();
2153
- const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableEditing, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
2154
- const { columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
1865
+ const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
1866
+ const { actionCell, columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
2155
1867
  const { column, row } = cell;
2156
1868
  const { columnDef } = column;
2157
1869
  const { columnDefType } = columnDef;
@@ -2224,9 +1936,7 @@ const MRT_TableBodyCell = (_a) => {
2224
1936
  const isColumnPinned = enableColumnPinning &&
2225
1937
  columnDef.columnDefType !== 'group' &&
2226
1938
  column.getIsPinned();
2227
- const isEditable = !cell.getIsPlaceholder() &&
2228
- parseFromValuesOrFunc(enableEditing, row) &&
2229
- parseFromValuesOrFunc(columnDef.enableEditing, row) !== false;
1939
+ const isEditable = isCellEditable({ cell, table });
2230
1940
  const isEditing = isEditable &&
2231
1941
  !['custom', 'modal'].includes(editDisplayMode) &&
2232
1942
  (editDisplayMode === 'table' ||
@@ -2234,20 +1944,20 @@ const MRT_TableBodyCell = (_a) => {
2234
1944
  (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id) &&
2235
1945
  !row.getIsGrouped();
2236
1946
  const isCreating = isEditable && createDisplayMode === 'row' && (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
1947
+ const showClickToCopyButton = (parseFromValuesOrFunc(enableClickToCopy, cell) === true ||
1948
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) === true) &&
1949
+ !['context-menu', false].includes(
1950
+ // @ts-ignore
1951
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell));
1952
+ const isRightClickable = parseFromValuesOrFunc(enableCellActions, cell);
1953
+ const cellValueProps = {
1954
+ cell,
1955
+ table,
1956
+ };
2237
1957
  const handleDoubleClick = (event) => {
2238
1958
  var _a;
2239
1959
  (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDoubleClick) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2240
- if (isEditable && editDisplayMode === 'cell') {
2241
- setEditingCell(cell);
2242
- queueMicrotask(() => {
2243
- var _a;
2244
- const textField = editInputRefs.current[column.id];
2245
- if (textField) {
2246
- textField.focus();
2247
- (_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
2248
- }
2249
- });
2250
- }
1960
+ openEditingCell({ cell, table });
2251
1961
  };
2252
1962
  const handleDragEnter = (e) => {
2253
1963
  var _a;
@@ -2259,24 +1969,29 @@ const MRT_TableBodyCell = (_a) => {
2259
1969
  setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
2260
1970
  }
2261
1971
  };
2262
- const cellValueProps = {
2263
- cell,
2264
- table,
1972
+ const handleContextMenu = (e) => {
1973
+ var _a;
1974
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onContextMenu) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
1975
+ if (isRightClickable) {
1976
+ e.preventDefault();
1977
+ table.setActionCell(cell);
1978
+ table.refs.actionCellRef.current = e.currentTarget;
1979
+ }
2265
1980
  };
2266
- return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, ref: (node) => {
2267
- if (node) {
2268
- measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
2269
- }
2270
- } }, tableCellProps, { onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
2271
- outline: (editDisplayMode === 'cell' && isEditable) ||
1981
+ return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined }, tableCellProps, { onContextMenu: handleContextMenu, onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
1982
+ outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
1983
+ (editDisplayMode === 'cell' && isEditable) ||
2272
1984
  (editDisplayMode === 'table' && (isCreating || isEditing))
2273
1985
  ? `1px solid ${theme.palette.grey[500]}`
2274
1986
  : undefined,
2275
- outlineOffset: '-1px',
2276
1987
  textOverflow: 'clip',
2277
- }, alignItems: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'center' : undefined, cursor: isEditable && editDisplayMode === 'cell' ? 'pointer' : 'inherit', justifyContent: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid'))
2278
- ? tableCellProps.align
2279
- : undefined, overflow: 'hidden', p: density === 'compact'
1988
+ }, alignItems: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'center' : undefined, cursor: isRightClickable
1989
+ ? 'context-menu'
1990
+ : isEditable && editDisplayMode === 'cell'
1991
+ ? 'pointer'
1992
+ : 'inherit', outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id
1993
+ ? `1px solid ${theme.palette.grey[500]}`
1994
+ : undefined, outlineOffset: '-1px', overflow: 'hidden', p: density === 'compact'
2280
1995
  ? columnDefType === 'display'
2281
1996
  ? '0 0.5rem'
2282
1997
  : '0.5rem'
@@ -2286,7 +2001,7 @@ const MRT_TableBodyCell = (_a) => {
2286
2001
  : '1rem'
2287
2002
  : columnDefType === 'display'
2288
2003
  ? '1rem 1.25rem'
2289
- : '1.5rem', textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id ? 2 : column.getIsPinned() ? 1 : 0 }, getCommonMRTCellStyles({
2004
+ : '1.5rem', textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal' }, getCommonMRTCellStyles({
2290
2005
  column,
2291
2006
  table,
2292
2007
  tableCellProps,
@@ -2301,8 +2016,7 @@ const MRT_TableBodyCell = (_a) => {
2301
2016
  rowRef,
2302
2017
  staticRowIndex,
2303
2018
  table,
2304
- })) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
2305
- columnDef.enableClickToCopy !== false ? (jsx(MRT_CopyButton, { cell: cell, table: table, children: jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps)) })) : (jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps))), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxs(Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
2019
+ })) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : showClickToCopyButton && columnDef.enableClickToCopy !== false ? (jsx(MRT_CopyButton, { cell: cell, table: table, children: jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps)) })) : (jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps))), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxs(Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
2306
2020
  };
2307
2021
  const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
2308
2022
 
@@ -2403,25 +2117,21 @@ const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVi
2403
2117
  }
2404
2118
  }, selected: isRowSelected }, tableRowProps, { style: Object.assign({ transform: virtualRow
2405
2119
  ? `translateY(${virtualRow.start}px)`
2406
- : undefined }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style), sx: (theme) => (Object.assign({ '&:hover td': {
2407
- '&:after': Object.assign({ backgroundColor: cellHighlightColorHover
2408
- ? alpha(cellHighlightColorHover, 0.3)
2409
- : undefined }, pinnedBeforeAfterStyles),
2410
- }, backgroundColor: `${baseBackgroundColor} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isRowPinned
2120
+ : undefined }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style), sx: (theme) => (Object.assign({ '&:hover td:after': cellHighlightColorHover
2121
+ ? Object.assign({ backgroundColor: alpha(cellHighlightColorHover, 0.3) }, commonCellBeforeAfterStyles) : undefined, backgroundColor: `${baseBackgroundColor} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isRowPinned
2411
2122
  ? `${bottomPinnedIndex * rowHeight +
2412
2123
  (enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
2413
2124
  : undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isRowPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1, position: virtualRow
2414
2125
  ? 'absolute'
2415
2126
  : (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isRowPinned
2416
2127
  ? 'sticky'
2417
- : undefined, td: Object.assign({ '&:after': Object.assign({ backgroundColor: cellHighlightColor }, pinnedBeforeAfterStyles) }, getCommonPinnedCellStyles({ table, theme })), top: virtualRow
2128
+ : 'relative', td: Object.assign({}, getCommonPinnedCellStyles({ table, theme })), 'td:after': cellHighlightColor
2129
+ ? Object.assign({ backgroundColor: cellHighlightColor }, commonCellBeforeAfterStyles) : undefined, top: virtualRow
2418
2130
  ? 0
2419
2131
  : topPinnedIndex !== undefined && isRowPinned
2420
2132
  ? `${topPinnedIndex * rowHeight +
2421
2133
  (enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0)}px`
2422
- : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', width: '100%', zIndex: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isRowPinned
2423
- ? 2
2424
- : undefined }, sx)), children: [virtualPaddingLeft ? (jsx("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : visibleCells).map((cellOrVirtualCell, staticColumnIndex) => {
2134
+ : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', width: '100%', zIndex: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isRowPinned ? 2 : 0 }, sx)), children: [virtualPaddingLeft ? (jsx("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : visibleCells).map((cellOrVirtualCell, staticColumnIndex) => {
2425
2135
  let cell = cellOrVirtualCell;
2426
2136
  if (columnVirtualizer) {
2427
2137
  staticColumnIndex = cellOrVirtualCell.index;
@@ -2429,9 +2139,6 @@ const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVi
2429
2139
  }
2430
2140
  const props = {
2431
2141
  cell,
2432
- measureElement: !isDraggingRow && !isHoveredRow
2433
- ? columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement
2434
- : undefined,
2435
2142
  numRows,
2436
2143
  rowRef,
2437
2144
  staticColumnIndex,
@@ -2525,88 +2232,426 @@ const MRT_TableBody = (_a) => {
2525
2232
  return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
2526
2233
  }) })))] }));
2527
2234
  };
2528
- const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
2235
+ const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
2236
+
2237
+ const MRT_TableFooterCell = (_a) => {
2238
+ var _b, _c, _d;
2239
+ var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
2240
+ const theme = useTheme();
2241
+ const { getState, options: { enableColumnPinning, muiTableFooterCellProps }, } = table;
2242
+ const { density } = getState();
2243
+ const { column } = footer;
2244
+ const { columnDef } = column;
2245
+ const { columnDefType } = columnDef;
2246
+ const isColumnPinned = enableColumnPinning &&
2247
+ columnDef.columnDefType !== 'group' &&
2248
+ column.getIsPinned();
2249
+ const args = { column, table };
2250
+ const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
2251
+ return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
2252
+ ? 'center'
2253
+ : theme.direction === 'rtl'
2254
+ ? 'right'
2255
+ : 'left', colSpan: footer.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, variant: "footer" }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', p: density === 'compact'
2256
+ ? '0.5rem'
2257
+ : density === 'comfortable'
2258
+ ? '1rem'
2259
+ : '1.5rem', verticalAlign: 'top' }, getCommonMRTCellStyles({
2260
+ column,
2261
+ header: footer,
2262
+ table,
2263
+ tableCellProps,
2264
+ theme,
2265
+ })), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (footer.isPlaceholder
2266
+ ? null
2267
+ : (_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
2268
+ column,
2269
+ footer,
2270
+ table,
2271
+ })) !== null && _c !== void 0 ? _c : columnDef.footer) !== null && _d !== void 0 ? _d : null) })));
2272
+ };
2273
+
2274
+ const MRT_TableFooterRow = (_a) => {
2275
+ var _b;
2276
+ var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
2277
+ const { options: { layoutMode, muiTableFooterRowProps }, } = table;
2278
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2279
+ // if no content in row, skip row
2280
+ if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
2281
+ !!header.column.columnDef.footer) ||
2282
+ header.column.columnDef.Footer)))
2283
+ return null;
2284
+ const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterRowProps, {
2285
+ footerGroup,
2286
+ table,
2287
+ })), rest);
2288
+ return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: getMRTTheme(table, theme).baseBackgroundColor, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: 'relative', width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter, staticColumnIndex) => {
2289
+ let footer = footerOrVirtualFooter;
2290
+ if (columnVirtualizer) {
2291
+ staticColumnIndex = footerOrVirtualFooter
2292
+ .index;
2293
+ footer = footerGroup.headers[staticColumnIndex];
2294
+ }
2295
+ return footer ? (jsx(MRT_TableFooterCell, { footer: footer, staticColumnIndex: staticColumnIndex, table: table }, footer.id)) : null;
2296
+ }), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
2297
+ };
2298
+
2299
+ const MRT_TableFooter = (_a) => {
2300
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2301
+ const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
2302
+ const { isFullScreen } = getState();
2303
+ const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
2304
+ table,
2305
+ })), rest);
2306
+ const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
2307
+ return (jsx(TableFooter, Object.assign({}, tableFooterProps, { ref: (ref) => {
2308
+ tableFooterRef.current = ref;
2309
+ if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
2310
+ // @ts-ignore
2311
+ tableFooterProps.ref.current = ref;
2312
+ }
2313
+ }, sx: (theme) => (Object.assign({ bottom: stickFooter ? 0 : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, opacity: stickFooter ? 0.97 : undefined, outline: stickFooter
2314
+ ? theme.palette.mode === 'light'
2315
+ ? `1px solid ${theme.palette.grey[300]}`
2316
+ : `1px solid ${theme.palette.grey[700]}`
2317
+ : undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
2318
+ };
2319
+
2320
+ const mrtFilterOptions = (localization) => [
2321
+ {
2322
+ divider: false,
2323
+ label: localization.filterFuzzy,
2324
+ option: 'fuzzy',
2325
+ symbol: '≈',
2326
+ },
2327
+ {
2328
+ divider: false,
2329
+ label: localization.filterContains,
2330
+ option: 'contains',
2331
+ symbol: '*',
2332
+ },
2333
+ {
2334
+ divider: false,
2335
+ label: localization.filterStartsWith,
2336
+ option: 'startsWith',
2337
+ symbol: 'a',
2338
+ },
2339
+ {
2340
+ divider: true,
2341
+ label: localization.filterEndsWith,
2342
+ option: 'endsWith',
2343
+ symbol: 'z',
2344
+ },
2345
+ {
2346
+ divider: false,
2347
+ label: localization.filterEquals,
2348
+ option: 'equals',
2349
+ symbol: '=',
2350
+ },
2351
+ {
2352
+ divider: true,
2353
+ label: localization.filterNotEquals,
2354
+ option: 'notEquals',
2355
+ symbol: '≠',
2356
+ },
2357
+ {
2358
+ divider: false,
2359
+ label: localization.filterBetween,
2360
+ option: 'between',
2361
+ symbol: '⇿',
2362
+ },
2363
+ {
2364
+ divider: true,
2365
+ label: localization.filterBetweenInclusive,
2366
+ option: 'betweenInclusive',
2367
+ symbol: '⬌',
2368
+ },
2369
+ {
2370
+ divider: false,
2371
+ label: localization.filterGreaterThan,
2372
+ option: 'greaterThan',
2373
+ symbol: '>',
2374
+ },
2375
+ {
2376
+ divider: false,
2377
+ label: localization.filterGreaterThanOrEqualTo,
2378
+ option: 'greaterThanOrEqualTo',
2379
+ symbol: '≥',
2380
+ },
2381
+ {
2382
+ divider: false,
2383
+ label: localization.filterLessThan,
2384
+ option: 'lessThan',
2385
+ symbol: '<',
2386
+ },
2387
+ {
2388
+ divider: true,
2389
+ label: localization.filterLessThanOrEqualTo,
2390
+ option: 'lessThanOrEqualTo',
2391
+ symbol: '≤',
2392
+ },
2393
+ {
2394
+ divider: false,
2395
+ label: localization.filterEmpty,
2396
+ option: 'empty',
2397
+ symbol: '∅',
2398
+ },
2399
+ {
2400
+ divider: false,
2401
+ label: localization.filterNotEmpty,
2402
+ option: 'notEmpty',
2403
+ symbol: '!∅',
2404
+ },
2405
+ ];
2406
+ const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
2407
+ const emptyModes = ['empty', 'notEmpty'];
2408
+ const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
2409
+ const rangeVariants = ['range-slider', 'date-range', 'datetime-range', 'range'];
2410
+ const MRT_FilterOptionMenu = (_a) => {
2411
+ var _b, _c, _d, _e;
2412
+ var { anchorEl, header, onSelect, setAnchorEl, setFilterValue, table } = _a, rest = __rest(_a, ["anchorEl", "header", "onSelect", "setAnchorEl", "setFilterValue", "table"]);
2413
+ const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
2414
+ const { density, globalFilterFn } = getState();
2415
+ const { column } = header !== null && header !== void 0 ? header : {};
2416
+ const { columnDef } = column !== null && column !== void 0 ? column : {};
2417
+ const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
2418
+ let allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
2419
+ if (rangeVariants.includes(columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant)) {
2420
+ allowedColumnFilterOptions = [
2421
+ ...rangeModes,
2422
+ ...(allowedColumnFilterOptions !== null && allowedColumnFilterOptions !== void 0 ? allowedColumnFilterOptions : []),
2423
+ ].filter((option) => rangeModes.includes(option));
2424
+ }
2425
+ const internalFilterOptions = useMemo(() => mrtFilterOptions(localization).filter((filterOption) => columnDef
2426
+ ? allowedColumnFilterOptions === undefined ||
2427
+ (allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.includes(filterOption.option))
2428
+ : (!globalFilterModeOptions ||
2429
+ globalFilterModeOptions.includes(filterOption.option)) &&
2430
+ ['contains', 'fuzzy', 'startsWith'].includes(filterOption.option)), []);
2431
+ const handleSelectFilterMode = (option) => {
2432
+ var _a, _b;
2433
+ const prevFilterMode = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef._filterFn) !== null && _a !== void 0 ? _a : '';
2434
+ if (!header || !column) {
2435
+ // global filter mode
2436
+ setGlobalFilterFn(option);
2437
+ }
2438
+ else if (option !== prevFilterMode) {
2439
+ // column filter mode
2440
+ setColumnFilterFns((prev) => (Object.assign(Object.assign({}, prev), { [header.id]: option })));
2441
+ // reset filter value and/or perform new filter render
2442
+ if (emptyModes.includes(option)) {
2443
+ // will now be empty/notEmpty filter mode
2444
+ if (currentFilterValue !== ' ' &&
2445
+ !emptyModes.includes(prevFilterMode)) {
2446
+ column.setFilterValue(' ');
2447
+ }
2448
+ else if (currentFilterValue) {
2449
+ column.setFilterValue(currentFilterValue); // perform new filter render
2450
+ }
2451
+ }
2452
+ else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
2453
+ arrModes.includes(option)) {
2454
+ // will now be array filter mode
2455
+ if (currentFilterValue instanceof String ||
2456
+ (currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.length)) {
2457
+ column.setFilterValue([]);
2458
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue([]);
2459
+ }
2460
+ else if (currentFilterValue) {
2461
+ column.setFilterValue(currentFilterValue); // perform new filter render
2462
+ }
2463
+ }
2464
+ else if (((_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === null || _b === void 0 ? void 0 : _b.includes('range')) ||
2465
+ rangeModes.includes(option)) {
2466
+ // will now be range filter mode
2467
+ if (!Array.isArray(currentFilterValue) ||
2468
+ (!(currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.every((v) => v === '')) &&
2469
+ !rangeModes.includes(prevFilterMode))) {
2470
+ column.setFilterValue(['', '']);
2471
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
2472
+ }
2473
+ else {
2474
+ column.setFilterValue(currentFilterValue); // perform new filter render
2475
+ }
2476
+ }
2477
+ else {
2478
+ // will now be single value filter mode
2479
+ if (Array.isArray(currentFilterValue)) {
2480
+ column.setFilterValue('');
2481
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
2482
+ }
2483
+ else if (currentFilterValue === ' ' &&
2484
+ emptyModes.includes(prevFilterMode)) {
2485
+ column.setFilterValue(undefined);
2486
+ }
2487
+ else {
2488
+ column.setFilterValue(currentFilterValue); // perform new filter render
2489
+ }
2490
+ }
2491
+ }
2492
+ setAnchorEl(null);
2493
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect();
2494
+ };
2495
+ const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
2496
+ const theme = useTheme();
2497
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
2498
+ return (jsx(Menu, Object.assign({ MenuListProps: {
2499
+ dense: density === 'compact',
2500
+ sx: {
2501
+ backgroundColor: menuBackgroundColor,
2502
+ },
2503
+ }, anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_e = (header && column && columnDef
2504
+ ? (_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
2505
+ column: column,
2506
+ internalFilterOptions,
2507
+ onSelectFilterMode: handleSelectFilterMode,
2508
+ table,
2509
+ })) !== null && _d !== void 0 ? _d : renderColumnFilterModeMenuItems === null || renderColumnFilterModeMenuItems === void 0 ? void 0 : renderColumnFilterModeMenuItems({
2510
+ column: column,
2511
+ internalFilterOptions,
2512
+ onSelectFilterMode: handleSelectFilterMode,
2513
+ table,
2514
+ })
2515
+ : renderGlobalFilterModeMenuItems === null || renderGlobalFilterModeMenuItems === void 0 ? void 0 : renderGlobalFilterModeMenuItems({
2516
+ internalFilterOptions,
2517
+ onSelectFilterMode: handleSelectFilterMode,
2518
+ table,
2519
+ }))) !== null && _e !== void 0 ? _e : internalFilterOptions.map(({ divider, label, option, symbol }, index) => (jsx(MRT_ActionMenuItem, { divider: divider, icon: symbol, label: label, onClick: () => handleSelectFilterMode(option), selected: option === filterOption, table: table, value: option }, index))) })));
2520
+ };
2529
2521
 
2530
- const MRT_TableFooterCell = (_a) => {
2531
- var _b, _c, _d;
2532
- var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
2533
- const theme = useTheme();
2534
- const { getState, options: { enableColumnPinning, layoutMode, muiTableFooterCellProps }, } = table;
2535
- const { density } = getState();
2536
- const { column } = footer;
2522
+ const MRT_ColumnActionMenu = (_a) => {
2523
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2524
+ var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
2525
+ const { getState, getAllLeafColumns, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnFilterFns, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, } = table;
2526
+ const { column } = header;
2537
2527
  const { columnDef } = column;
2538
- const { columnDefType } = columnDef;
2539
- const isColumnPinned = enableColumnPinning &&
2540
- columnDef.columnDefType !== 'group' &&
2541
- column.getIsPinned();
2542
- const args = { column, table };
2543
- const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
2544
- return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
2545
- ? 'center'
2546
- : theme.direction === 'rtl'
2547
- ? 'right'
2548
- : 'left', colSpan: footer.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, variant: "footer" }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, fontWeight: 'bold', justifyContent: columnDefType === 'group' ? 'center' : undefined, p: density === 'compact'
2549
- ? '0.5rem'
2550
- : density === 'comfortable'
2551
- ? '1rem'
2552
- : '1.5rem', verticalAlign: 'top', zIndex: column.getIsPinned() && columnDefType !== 'group' ? 2 : 1 }, getCommonMRTCellStyles({
2528
+ const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
2529
+ const columnFilterValue = column.getFilterValue();
2530
+ const [filterMenuAnchorEl, setFilterMenuAnchorEl] = useState(null);
2531
+ const handleClearSort = () => {
2532
+ column.clearSorting();
2533
+ setAnchorEl(null);
2534
+ };
2535
+ const handleSortAsc = () => {
2536
+ column.toggleSorting(false);
2537
+ setAnchorEl(null);
2538
+ };
2539
+ const handleSortDesc = () => {
2540
+ column.toggleSorting(true);
2541
+ setAnchorEl(null);
2542
+ };
2543
+ const handleResetColumnSize = () => {
2544
+ setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
2545
+ column.resetSize();
2546
+ setAnchorEl(null);
2547
+ };
2548
+ const handleHideColumn = () => {
2549
+ column.toggleVisibility(false);
2550
+ setAnchorEl(null);
2551
+ };
2552
+ const handlePinColumn = (pinDirection) => {
2553
+ column.pin(pinDirection);
2554
+ setAnchorEl(null);
2555
+ };
2556
+ const handleGroupByColumn = () => {
2557
+ column.toggleGrouping();
2558
+ setColumnOrder((old) => ['mrt-row-expand', ...old]);
2559
+ setAnchorEl(null);
2560
+ };
2561
+ const handleClearFilter = () => {
2562
+ column.setFilterValue(undefined);
2563
+ setAnchorEl(null);
2564
+ if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
2565
+ setColumnFilterFns((prev) => {
2566
+ var _a;
2567
+ return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
2568
+ });
2569
+ }
2570
+ };
2571
+ const handleFilterByColumn = () => {
2572
+ setShowColumnFilters(true);
2573
+ queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); });
2574
+ setAnchorEl(null);
2575
+ };
2576
+ const handleShowAllColumns = () => {
2577
+ getAllLeafColumns()
2578
+ .filter((col) => col.columnDef.enableHiding !== false)
2579
+ .forEach((col) => col.toggleVisibility(true));
2580
+ setAnchorEl(null);
2581
+ };
2582
+ const handleOpenFilterModeMenu = (event) => {
2583
+ event.stopPropagation();
2584
+ setFilterMenuAnchorEl(event.currentTarget);
2585
+ };
2586
+ const isSelectFilter = !!columnDef.filterSelectOptions;
2587
+ const allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
2588
+ const showFilterModeSubMenu = enableColumnFilterModes &&
2589
+ columnDef.enableColumnFilterModes !== false &&
2590
+ !isSelectFilter &&
2591
+ (allowedColumnFilterOptions === undefined ||
2592
+ !!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
2593
+ const internalColumnMenuItems = [
2594
+ ...(enableSorting && column.getCanSort()
2595
+ ? [
2596
+ enableSortingRemoval !== false && (jsx(MRT_ActionMenuItem, { icon: jsx(ClearAllIcon, {}), label: localization.clearSort, onClick: handleClearSort, table: table }, 0)),
2597
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === 'asc', icon: jsx(SortIcon, { style: { transform: 'rotate(180deg) scaleX(-1)' } }), label: (_c = localization.sortByColumnAsc) === null || _c === void 0 ? void 0 : _c.replace('{column}', String(columnDef.header)), onClick: handleSortAsc, table: table }, 1),
2598
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === 'desc', divider: enableColumnFilters || enableGrouping || enableHiding, icon: jsx(SortIcon, {}), label: (_d = localization.sortByColumnDesc) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header)), onClick: handleSortDesc, table: table }, 2),
2599
+ ]
2600
+ : []),
2601
+ ...(enableColumnFilters && column.getCanFilter()
2602
+ ? [
2603
+ jsx(MRT_ActionMenuItem, { disabled: !columnFilterValue ||
2604
+ (Array.isArray(columnFilterValue) &&
2605
+ !columnFilterValue.filter((value) => value).length), icon: jsx(FilterListOffIcon, {}), label: localization.clearFilter, onClick: handleClearFilter, table: table }, 3),
2606
+ columnFilterDisplayMode === 'subheader' && (jsx(MRT_ActionMenuItem, { disabled: showColumnFilters && !enableColumnFilterModes, divider: enableGrouping || enableHiding, icon: jsx(FilterListIcon, {}), label: (_e = localization.filterByColumn) === null || _e === void 0 ? void 0 : _e.replace('{column}', String(columnDef.header)), onClick: showColumnFilters
2607
+ ? handleOpenFilterModeMenu
2608
+ : handleFilterByColumn, onOpenSubMenu: showFilterModeSubMenu ? handleOpenFilterModeMenu : undefined, table: table }, 4)),
2609
+ showFilterModeSubMenu && (jsx(MRT_FilterOptionMenu, { anchorEl: filterMenuAnchorEl, header: header, onSelect: handleFilterByColumn, setAnchorEl: setFilterMenuAnchorEl, table: table }, 5)),
2610
+ ].filter(Boolean)
2611
+ : []),
2612
+ ...(enableGrouping && column.getCanGroup()
2613
+ ? [
2614
+ jsx(MRT_ActionMenuItem, { divider: enableColumnPinning, icon: jsx(DynamicFeedIcon, {}), label: (_f = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) === null || _f === void 0 ? void 0 : _f.replace('{column}', String(columnDef.header)), onClick: handleGroupByColumn, table: table }, 6),
2615
+ ]
2616
+ : []),
2617
+ ...(enableColumnPinning && column.getCanPin()
2618
+ ? [
2619
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsPinned() === 'left' || !column.getCanPin(), icon: jsx(PushPinIcon, { style: { transform: 'rotate(90deg)' } }), label: localization.pinToLeft, onClick: () => handlePinColumn('left'), table: table }, 7),
2620
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsPinned() === 'right' || !column.getCanPin(), icon: jsx(PushPinIcon, { style: { transform: 'rotate(-90deg)' } }), label: localization.pinToRight, onClick: () => handlePinColumn('right'), table: table }, 8),
2621
+ jsx(MRT_ActionMenuItem, { disabled: !column.getIsPinned(), divider: enableHiding, icon: jsx(PushPinIcon, {}), label: localization.unpin, onClick: () => handlePinColumn(false), table: table }, 9),
2622
+ ]
2623
+ : []),
2624
+ ...(enableColumnResizing && column.getCanResize()
2625
+ ? [
2626
+ jsx(MRT_ActionMenuItem, { disabled: !columnSizing[column.id], icon: jsx(RestartAltIcon, {}), label: localization.resetColumnSize, onClick: handleResetColumnSize, table: table }, 10),
2627
+ ]
2628
+ : []),
2629
+ ...(enableHiding
2630
+ ? [
2631
+ jsx(MRT_ActionMenuItem, { disabled: !column.getCanHide(), icon: jsx(VisibilityOffIcon, {}), label: (_g = localization.hideColumn) === null || _g === void 0 ? void 0 : _g.replace('{column}', String(columnDef.header)), onClick: handleHideColumn, table: table }, 11),
2632
+ jsx(MRT_ActionMenuItem, { disabled: !Object.values(columnVisibility).filter((visible) => !visible)
2633
+ .length, icon: jsx(ViewColumnIcon, {}), label: (_h = localization.showAllColumns) === null || _h === void 0 ? void 0 : _h.replace('{column}', String(columnDef.header)), onClick: handleShowAllColumns, table: table }, 12),
2634
+ ]
2635
+ : []),
2636
+ ].filter(Boolean);
2637
+ const theme = useTheme();
2638
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
2639
+ return (jsx(Menu, Object.assign({ MenuListProps: {
2640
+ dense: density === 'compact',
2641
+ sx: {
2642
+ backgroundColor: menuBackgroundColor,
2643
+ },
2644
+ }, anchorEl: anchorEl, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_l = (_k = (_j = columnDef.renderColumnActionsMenuItems) === null || _j === void 0 ? void 0 : _j.call(columnDef, {
2645
+ closeMenu: () => setAnchorEl(null),
2553
2646
  column,
2647
+ internalColumnMenuItems,
2554
2648
  table,
2555
- tableCellProps,
2556
- theme,
2557
- })), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (footer.isPlaceholder
2558
- ? null
2559
- : (_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
2560
- column,
2561
- footer,
2562
- table,
2563
- })) !== null && _c !== void 0 ? _c : columnDef.footer) !== null && _d !== void 0 ? _d : null) })));
2564
- };
2565
-
2566
- const MRT_TableFooterRow = (_a) => {
2567
- var _b;
2568
- var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
2569
- const { options: { layoutMode, muiTableFooterRowProps }, } = table;
2570
- const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2571
- // if no content in row, skip row
2572
- if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
2573
- !!header.column.columnDef.footer) ||
2574
- header.column.columnDef.Footer)))
2575
- return null;
2576
- const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterRowProps, {
2577
- footerGroup,
2578
- table,
2579
- })), rest);
2580
- return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: getMRTTheme(table, theme).baseBackgroundColor, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter, staticColumnIndex) => {
2581
- let footer = footerOrVirtualFooter;
2582
- if (columnVirtualizer) {
2583
- staticColumnIndex = footerOrVirtualFooter
2584
- .index;
2585
- footer = footerGroup.headers[staticColumnIndex];
2586
- }
2587
- return footer ? (jsx(MRT_TableFooterCell, { footer: footer, staticColumnIndex: staticColumnIndex, table: table }, footer.id)) : null;
2588
- }), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
2589
- };
2590
-
2591
- const MRT_TableFooter = (_a) => {
2592
- var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2593
- const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
2594
- const { isFullScreen } = getState();
2595
- const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
2596
- table,
2597
- })), rest);
2598
- const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
2599
- return (jsx(TableFooter, Object.assign({}, tableFooterProps, { ref: (ref) => {
2600
- tableFooterRef.current = ref;
2601
- if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
2602
- // @ts-ignore
2603
- tableFooterProps.ref.current = ref;
2604
- }
2605
- }, sx: (theme) => (Object.assign({ bottom: stickFooter ? 0 : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, opacity: stickFooter ? 0.97 : undefined, outline: stickFooter
2606
- ? theme.palette.mode === 'light'
2607
- ? `1px solid ${theme.palette.grey[300]}`
2608
- : `1px solid ${theme.palette.grey[700]}`
2609
- : undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
2649
+ })) !== null && _k !== void 0 ? _k : renderColumnActionsMenuItems === null || renderColumnActionsMenuItems === void 0 ? void 0 : renderColumnActionsMenuItems({
2650
+ closeMenu: () => setAnchorEl(null),
2651
+ column,
2652
+ internalColumnMenuItems,
2653
+ table,
2654
+ })) !== null && _l !== void 0 ? _l : internalColumnMenuItems })));
2610
2655
  };
2611
2656
 
2612
2657
  const MRT_TableHeadCellColumnActionsButton = (_a) => {
@@ -2874,7 +2919,7 @@ const MRT_FilterTextField = (_a) => {
2874
2919
  } }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleChange(getValueAndLabel(newValue).value), options: (_t = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _t !== void 0 ? _t : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
2875
2920
  var _a;
2876
2921
  return (jsx(TextField, Object.assign({}, builtinTextFieldProps, commonTextFieldProps, { InputProps: Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), { startAdornment: (_a = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.startAdornment }), inputProps: Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.inputProps), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation() })));
2877
- }, value: filterValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
2922
+ }, value: filterValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ MenuProps: { disableScrollLock: true }, displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
2878
2923
  ? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected === null || selected === void 0 ? void 0 : selected.map((value) => {
2879
2924
  const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
2880
2925
  return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
@@ -3030,7 +3075,7 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
3030
3075
  }, size: "small" }, rest, { sx: (theme) => (Object.assign({ height: '16px', ml: '4px', opacity: isFilterActive ? 1 : 0.3, p: '8px', transform: 'scale(0.75)', transition: 'all 150ms ease-in-out', width: '16px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: jsx(FilterAltIcon, {}) })) }) }) }), jsx(Popover, { anchorEl: anchorEl, anchorOrigin: {
3031
3076
  horizontal: 'center',
3032
3077
  vertical: 'top',
3033
- }, onClick: (event) => event.stopPropagation(), onClose: (event) => {
3078
+ }, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: (event) => {
3034
3079
  //@ts-ignore
3035
3080
  event.stopPropagation();
3036
3081
  setAnchorEl(null);
@@ -3151,7 +3196,7 @@ const MRT_TableHeadCellSortLabel = (_a) => {
3151
3196
 
3152
3197
  const MRT_TableHeadCell = (_a) => {
3153
3198
  var _b, _c, _d, _f, _g, _h;
3154
- var { header, staticColumnIndex, table } = _a, rest = __rest(_a, ["header", "staticColumnIndex", "table"]);
3199
+ var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
3155
3200
  const theme = useTheme();
3156
3201
  const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
3157
3202
  const { columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
@@ -3228,8 +3273,12 @@ const MRT_TableHeadCell = (_a) => {
3228
3273
  : theme.direction === 'rtl'
3229
3274
  ? 'right'
3230
3275
  : 'left', colSpan: header.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, onDragEnter: handleDragEnter, ref: (node) => {
3276
+ var _a;
3231
3277
  if (node) {
3232
3278
  tableHeadCellRefs.current[column.id] = node;
3279
+ if (columnDefType !== 'group') {
3280
+ (_a = columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(columnVirtualizer, node);
3281
+ }
3233
3282
  }
3234
3283
  } }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
3235
3284
  '.MuiButtonBase-root': {
@@ -3251,11 +3300,7 @@ const MRT_TableHeadCell = (_a) => {
3251
3300
  ? '0.25rem'
3252
3301
  : density === 'comfortable'
3253
3302
  ? '.75rem'
3254
- : '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
3255
- ? 3
3256
- : column.getIsPinned() && columnDefType !== 'group'
3257
- ? 2
3258
- : 1 }, getCommonMRTCellStyles({
3303
+ : '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top' }, getCommonMRTCellStyles({
3259
3304
  column,
3260
3305
  header,
3261
3306
  table,
@@ -3305,20 +3350,22 @@ const MRT_TableHeadCell = (_a) => {
3305
3350
 
3306
3351
  const MRT_TableHeadRow = (_a) => {
3307
3352
  var { columnVirtualizer, headerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "headerGroup", "table"]);
3308
- const { options: { layoutMode, muiTableHeadRowProps }, } = table;
3353
+ const { options: { enableStickyHeader, layoutMode, muiTableHeadRowProps }, } = table;
3309
3354
  const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
3310
3355
  const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadRowProps, {
3311
3356
  headerGroup,
3312
3357
  table,
3313
3358
  })), rest);
3314
- return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: getMRTTheme(table, theme).baseBackgroundColor, boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, top: 0 }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : headerGroup.headers).map((headerOrVirtualHeader, staticColumnIndex) => {
3359
+ return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: getMRTTheme(table, theme).baseBackgroundColor, boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: enableStickyHeader && layoutMode === 'semantic'
3360
+ ? 'sticky'
3361
+ : 'relative', top: 0 }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : headerGroup.headers).map((headerOrVirtualHeader, staticColumnIndex) => {
3315
3362
  let header = headerOrVirtualHeader;
3316
3363
  if (columnVirtualizer) {
3317
3364
  staticColumnIndex = headerOrVirtualHeader
3318
3365
  .index;
3319
3366
  header = headerGroup.headers[staticColumnIndex];
3320
3367
  }
3321
- return header ? (jsx(MRT_TableHeadCell, { header: header, staticColumnIndex: staticColumnIndex, table: table }, header.id)) : null;
3368
+ return header ? (jsx(MRT_TableHeadCell, { columnVirtualizer: columnVirtualizer, header: header, staticColumnIndex: staticColumnIndex, table: table }, header.id)) : null;
3322
3369
  }), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
3323
3370
  };
3324
3371
 
@@ -3408,7 +3455,7 @@ const MRT_Table = (_a) => {
3408
3455
  columnVirtualizer,
3409
3456
  table,
3410
3457
  };
3411
- return (jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [!!Caption && jsx("caption", { children: Caption }), enableTableHead && jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps))) : (jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps))), enableTableFooter && jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
3458
+ return (jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'relative' }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [!!Caption && jsx("caption", { children: Caption }), enableTableHead && jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps))) : (jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps))), enableTableFooter && jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
3412
3459
  };
3413
3460
 
3414
3461
  const MRT_TableLoadingOverlay = (_a) => {
@@ -3431,6 +3478,52 @@ const MRT_TableLoadingOverlay = (_a) => {
3431
3478
  }), children: jsx(CircularProgress, Object.assign({ "aria-label": localization.noRecordsToDisplay, id: "mrt-progress" }, circularProgressProps)) }));
3432
3479
  };
3433
3480
 
3481
+ const MRT_CellActionMenu = (_a) => {
3482
+ var _b, _c;
3483
+ var { table } = _a, rest = __rest(_a, ["table"]);
3484
+ const { getState, options: { editDisplayMode, enableClickToCopy, enableEditing, icons: { ContentCopy, EditIcon }, localization, renderCellActionMenuItems, }, refs: { actionCellRef }, } = table;
3485
+ const { actionCell, density } = getState();
3486
+ const cell = actionCell;
3487
+ const { row } = cell;
3488
+ const { column } = cell;
3489
+ const { columnDef } = column;
3490
+ const theme = useTheme();
3491
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
3492
+ const handleClose = (event) => {
3493
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
3494
+ table.setActionCell(null);
3495
+ actionCellRef.current = null;
3496
+ };
3497
+ const internalMenuItems = [
3498
+ (parseFromValuesOrFunc(enableClickToCopy, cell) === 'context-menu' ||
3499
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) ===
3500
+ 'context-menu') && (jsx(MRT_ActionMenuItem, { icon: jsx(ContentCopy, {}), label: localization.copy, onClick: (event) => {
3501
+ event.stopPropagation();
3502
+ navigator.clipboard.writeText(cell.getValue());
3503
+ handleClose();
3504
+ }, table: table }, 'mrt-copy')),
3505
+ parseFromValuesOrFunc(enableEditing, row) && editDisplayMode === 'cell' && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: () => {
3506
+ openEditingCell({ cell, table });
3507
+ handleClose();
3508
+ }, table: table }, 'mrt-edit')),
3509
+ ].filter(Boolean);
3510
+ const renderActionProps = {
3511
+ cell,
3512
+ closeMenu: handleClose,
3513
+ column,
3514
+ internalMenuItems,
3515
+ row,
3516
+ table,
3517
+ };
3518
+ const menuItems = (_c = (_b = columnDef.renderCellActionMenuItems) === null || _b === void 0 ? void 0 : _b.call(columnDef, renderActionProps)) !== null && _c !== void 0 ? _c : renderCellActionMenuItems === null || renderCellActionMenuItems === void 0 ? void 0 : renderCellActionMenuItems(renderActionProps);
3519
+ return ((!!(menuItems === null || menuItems === void 0 ? void 0 : menuItems.length) || !!(internalMenuItems === null || internalMenuItems === void 0 ? void 0 : internalMenuItems.length)) && (jsx(Menu, Object.assign({ MenuListProps: {
3520
+ dense: density === 'compact',
3521
+ sx: {
3522
+ backgroundColor: menuBackgroundColor,
3523
+ },
3524
+ }, anchorEl: actionCellRef.current, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: handleClose, open: !!cell, transformOrigin: { horizontal: -100, vertical: 8 } }, rest, { children: menuItems !== null && menuItems !== void 0 ? menuItems : internalMenuItems }))));
3525
+ };
3526
+
3434
3527
  const MRT_EditRowModal = (_a) => {
3435
3528
  var _b;
3436
3529
  var { open, table } = _a, rest = __rest(_a, ["open", "table"]);
@@ -3475,8 +3568,8 @@ const MRT_EditRowModal = (_a) => {
3475
3568
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
3476
3569
  const MRT_TableContainer = (_a) => {
3477
3570
  var { table } = _a, rest = __rest(_a, ["table"]);
3478
- const { getState, options: { createDisplayMode, editDisplayMode, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
3479
- const { creatingRow, editingRow, isFullScreen, isLoading, showLoadingOverlay, } = getState();
3571
+ const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
3572
+ const { actionCell, creatingRow, editingRow, isFullScreen, isLoading, showLoadingOverlay, } = getState();
3480
3573
  const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
3481
3574
  const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
3482
3575
  const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableContainerProps, {
@@ -3506,7 +3599,7 @@ const MRT_TableContainer = (_a) => {
3506
3599
  ? `calc(100vh - ${totalToolbarHeight}px)`
3507
3600
  : undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign({ maxHeight: enableStickyHeader
3508
3601
  ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
3509
- : undefined, maxWidth: '100%', overflow: 'auto', position: 'relative' }, parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [loading ? jsx(MRT_TableLoadingOverlay, { table: table }) : null, jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsx(MRT_EditRowModal, { open: true, table: table }))] })));
3602
+ : undefined, maxWidth: '100%', overflow: 'auto', position: 'relative' }, parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [loading ? jsx(MRT_TableLoadingOverlay, { table: table }) : null, jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsx(MRT_EditRowModal, { open: true, table: table })), enableCellActions && actionCell && jsx(MRT_CellActionMenu, { table: table })] })));
3510
3603
  };
3511
3604
 
3512
3605
  const MRT_LinearProgressBar = (_a) => {
@@ -3529,6 +3622,7 @@ const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
3529
3622
  const MRT_TablePagination = (_a) => {
3530
3623
  var { position = 'bottom', table } = _a, rest = __rest(_a, ["position", "table"]);
3531
3624
  const theme = useTheme();
3625
+ const isMobile = useMediaQuery('(max-width: 720px)');
3532
3626
  const { getPrePaginationRowModel, getState, options: { enableToolbarInternalActions, icons: { ChevronLeftIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon }, localization, muiPaginationProps, paginationDisplayMode, rowCount, }, setPageIndex, setPageSize, } = table;
3533
3627
  const { pagination: { pageIndex = 0, pageSize = 10 }, showGlobalFilter, } = getState();
3534
3628
  const paginationProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiPaginationProps, {
@@ -3539,9 +3633,12 @@ const MRT_TablePagination = (_a) => {
3539
3633
  const showFirstLastPageButtons = numberOfPages > 2;
3540
3634
  const firstRowIndex = pageIndex * pageSize;
3541
3635
  const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
3542
- const _b = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { SelectProps, disabled = false, rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _b, _rest = __rest(_b, ["SelectProps", "disabled", "rowsPerPageOptions", "showFirstButton", "showLastButton", "showRowsPerPage"]);
3636
+ const _b = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { SelectProps = {}, disabled = false, rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _b, restPaginationProps = __rest(_b, ["SelectProps", "disabled", "rowsPerPageOptions", "showFirstButton", "showLastButton", "showRowsPerPage"]);
3543
3637
  const disableBack = pageIndex <= 0 || disabled;
3544
3638
  const disableNext = lastRowIndex >= totalRowCount || disabled;
3639
+ if (isMobile && (SelectProps === null || SelectProps === void 0 ? void 0 : SelectProps.native) !== false) {
3640
+ SelectProps.native = true;
3641
+ }
3545
3642
  const tooltipProps = getCommonTooltipProps();
3546
3643
  return (jsxs(Box, { className: "MuiTablePagination-root", sx: {
3547
3644
  alignItems: 'center',
@@ -3559,7 +3656,10 @@ const MRT_TablePagination = (_a) => {
3559
3656
  px: '8px',
3560
3657
  py: '12px',
3561
3658
  zIndex: 2,
3562
- }, children: [showRowsPerPage && (jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsx(InputLabel, { htmlFor: "mrt-rows-per-page", sx: { mb: 0 }, children: localization.rowsPerPage }), jsx(Select, Object.assign({ disableUnderline: true, disabled: disabled, id: "mrt-rows-per-page", inputProps: { 'aria-label': localization.rowsPerPage }, label: localization.rowsPerPage, onChange: (event) => setPageSize(+event.target.value), sx: { mb: 0 }, value: pageSize, variant: "standard" }, SelectProps, { children: rowsPerPageOptions.map((option) => {
3659
+ }, children: [showRowsPerPage && (jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsx(InputLabel, { htmlFor: "mrt-rows-per-page", sx: { mb: 0 }, children: localization.rowsPerPage }), jsx(Select, Object.assign({ MenuProps: { disableScrollLock: true }, disableUnderline: true, disabled: disabled, inputProps: {
3660
+ 'aria-label': localization.rowsPerPage,
3661
+ id: 'mrt-rows-per-page',
3662
+ }, label: localization.rowsPerPage, onChange: (event) => setPageSize(+event.target.value), sx: { mb: 0 }, value: pageSize, variant: "standard" }, SelectProps, { children: rowsPerPageOptions.map((option) => {
3563
3663
  var _a;
3564
3664
  const value = typeof option !== 'number' ? option.value : option;
3565
3665
  const label = typeof option !== 'number' ? option.label : `${option}`;
@@ -3569,7 +3669,7 @@ const MRT_TablePagination = (_a) => {
3569
3669
  last: LastPageIcon,
3570
3670
  next: ChevronRightIcon,
3571
3671
  previous: ChevronLeftIcon,
3572
- } }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxs(Box, { gap: "xs", children: [showFirstButton && (jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToFirstPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: disableBack, onClick: () => setPageIndex(0), size: "small", children: jsx(FirstPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) }))), jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToPreviousPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: disableBack, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsx(ChevronLeftIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToNextPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: disableNext, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsx(ChevronRightIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), showLastButton && (jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToLastPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: disableNext, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsx(LastPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) })))] })] })) : null] }));
3672
+ } }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, restPaginationProps))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxs(Box, { gap: "xs", children: [showFirstButton && (jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToFirstPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: disableBack, onClick: () => setPageIndex(0), size: "small", children: jsx(FirstPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) }))), jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToPreviousPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: disableBack, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsx(ChevronLeftIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToNextPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: disableNext, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsx(ChevronRightIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), showLastButton && (jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToLastPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: disableNext, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsx(LastPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) })))] })] })) : null] }));
3573
3673
  };
3574
3674
 
3575
3675
  const MRT_ToolbarDropZone = (_a) => {
@@ -3742,12 +3842,12 @@ const MRT_ShowHideColumnsMenu = (_a) => {
3742
3842
  sx: {
3743
3843
  backgroundColor: menuBackgroundColor,
3744
3844
  },
3745
- }, anchorEl: anchorEl, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: [jsxs(Box, { sx: {
3845
+ }, anchorEl: anchorEl, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: [jsxs(Box, { sx: {
3746
3846
  display: 'flex',
3747
3847
  justifyContent: 'space-between',
3748
3848
  p: '0.5rem',
3749
3849
  pt: 0,
3750
- }, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options)), children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
3850
+ }, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
3751
3851
  };
3752
3852
 
3753
3853
  const MRT_ShowHideColumnsButton = (_a) => {
@@ -3964,5 +4064,5 @@ const MaterialReactTable = (props) => {
3964
4064
  return jsx(MRT_TablePaper, { table: table });
3965
4065
  };
3966
4066
 
3967
- export { MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, commonListItemStyles, commonMenuItemStyles, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getIsRowSelected, getLeadingDisplayColumnIds, getTotalRight, getTrailingDisplayColumnIds, mrtFilterOptions, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
4067
+ export { MRT_ActionMenuItem, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getIsRowSelected, getLeadingDisplayColumnIds, getTotalRight, getTrailingDisplayColumnIds, isCellEditable, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
3968
4068
  //# sourceMappingURL=index.esm.js.map