material-react-table 2.9.2 → 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 (143) hide show
  1. package/dist/index.d.ts +162 -111
  2. package/dist/index.esm.js +694 -606
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +708 -618
  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 +4 -4
  79. package/src/components/body/MRT_TableBodyCell.tsx +41 -32
  80. package/src/components/body/MRT_TableBodyRow.tsx +0 -4
  81. package/src/components/buttons/MRT_CopyButton.tsx +1 -0
  82. package/src/components/head/MRT_TableHeadCell.tsx +6 -0
  83. package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +1 -0
  84. package/src/components/head/MRT_TableHeadRow.tsx +1 -0
  85. package/src/components/menus/MRT_ActionMenuItem.tsx +60 -0
  86. package/src/components/menus/MRT_CellActionMenu.tsx +108 -0
  87. package/src/components/menus/MRT_ColumnActionMenu.tsx +89 -170
  88. package/src/components/menus/MRT_FilterOptionMenu.tsx +6 -14
  89. package/src/components/menus/MRT_RowActionMenu.tsx +7 -15
  90. package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +3 -1
  91. package/src/components/table/MRT_TableContainer.tsx +4 -0
  92. package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +1 -8
  93. package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +1 -8
  94. package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +1 -8
  95. package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +1 -8
  96. package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +1 -8
  97. package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +1 -8
  98. package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +1 -8
  99. package/src/hooks/useMRT_Effects.ts +10 -0
  100. package/src/hooks/useMRT_TableInstance.ts +112 -59
  101. package/src/icons.ts +2 -0
  102. package/src/index.ts +2 -0
  103. package/src/locales/ar.ts +1 -0
  104. package/src/locales/az.ts +1 -0
  105. package/src/locales/bg.ts +1 -0
  106. package/src/locales/cs.ts +1 -0
  107. package/src/locales/da.ts +1 -0
  108. package/src/locales/de.ts +1 -0
  109. package/src/locales/en.ts +1 -0
  110. package/src/locales/es.ts +1 -0
  111. package/src/locales/et.ts +1 -0
  112. package/src/locales/fa.ts +1 -0
  113. package/src/locales/fi.ts +1 -0
  114. package/src/locales/fr.ts +1 -0
  115. package/src/locales/he.ts +1 -0
  116. package/src/locales/hu.ts +1 -0
  117. package/src/locales/hy.ts +1 -0
  118. package/src/locales/id.ts +1 -0
  119. package/src/locales/it.ts +1 -0
  120. package/src/locales/ja.ts +1 -0
  121. package/src/locales/ko.ts +1 -0
  122. package/src/locales/nl.ts +1 -0
  123. package/src/locales/no.ts +1 -0
  124. package/src/locales/np.ts +1 -0
  125. package/src/locales/pl.ts +1 -0
  126. package/src/locales/pt-BR.ts +1 -0
  127. package/src/locales/pt.ts +1 -0
  128. package/src/locales/ro.ts +1 -0
  129. package/src/locales/ru.ts +1 -0
  130. package/src/locales/sk.ts +1 -0
  131. package/src/locales/sr-Cyrl-RS.ts +1 -0
  132. package/src/locales/sr-Latn-RS.ts +1 -0
  133. package/src/locales/sv.ts +1 -0
  134. package/src/locales/tr.ts +1 -0
  135. package/src/locales/uk.ts +1 -0
  136. package/src/locales/vi.ts +1 -0
  137. package/src/locales/zh-Hans.ts +1 -0
  138. package/src/locales/zh-Hant.ts +1 -0
  139. package/src/types.ts +41 -9
  140. package/src/utils/cell.utils.ts +50 -0
  141. package/src/utils/displayColumn.utils.ts +38 -20
  142. package/src/hooks/display-columns/getMRT_DisplayColumns.tsx +0 -26
  143. 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, }) => {
@@ -584,355 +615,19 @@ const getCommonTooltipProps = (placement) => ({
584
615
  placement,
585
616
  });
586
617
 
587
- const mrtFilterOptions = (localization) => [
588
- {
589
- divider: false,
590
- label: localization.filterFuzzy,
591
- option: 'fuzzy',
592
- symbol: '',
593
- },
594
- {
595
- divider: false,
596
- label: localization.filterContains,
597
- option: 'contains',
598
- symbol: '*',
599
- },
600
- {
601
- divider: false,
602
- label: localization.filterStartsWith,
603
- option: 'startsWith',
604
- symbol: 'a',
605
- },
606
- {
607
- divider: true,
608
- label: localization.filterEndsWith,
609
- option: 'endsWith',
610
- symbol: 'z',
611
- },
612
- {
613
- divider: false,
614
- label: localization.filterEquals,
615
- option: 'equals',
616
- symbol: '=',
617
- },
618
- {
619
- divider: true,
620
- label: localization.filterNotEquals,
621
- option: 'notEquals',
622
- symbol: '≠',
623
- },
624
- {
625
- divider: false,
626
- label: localization.filterBetween,
627
- option: 'between',
628
- symbol: '⇿',
629
- },
630
- {
631
- divider: true,
632
- label: localization.filterBetweenInclusive,
633
- option: 'betweenInclusive',
634
- symbol: '⬌',
635
- },
636
- {
637
- divider: false,
638
- label: localization.filterGreaterThan,
639
- option: 'greaterThan',
640
- symbol: '>',
641
- },
642
- {
643
- divider: false,
644
- label: localization.filterGreaterThanOrEqualTo,
645
- option: 'greaterThanOrEqualTo',
646
- symbol: '≥',
647
- },
648
- {
649
- divider: false,
650
- label: localization.filterLessThan,
651
- option: 'lessThan',
652
- symbol: '<',
653
- },
654
- {
655
- divider: true,
656
- label: localization.filterLessThanOrEqualTo,
657
- option: 'lessThanOrEqualTo',
658
- symbol: '≤',
659
- },
660
- {
661
- divider: false,
662
- label: localization.filterEmpty,
663
- option: 'empty',
664
- symbol: '∅',
665
- },
666
- {
667
- divider: false,
668
- label: localization.filterNotEmpty,
669
- option: 'notEmpty',
670
- symbol: '!∅',
671
- },
672
- ];
673
- const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
674
- const emptyModes = ['empty', 'notEmpty'];
675
- const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
676
- const rangeVariants = ['range-slider', 'date-range', 'datetime-range', 'range'];
677
- const MRT_FilterOptionMenu = (_a) => {
678
- var _b, _c, _d, _e;
679
- var { anchorEl, header, onSelect, setAnchorEl, setFilterValue, table } = _a, rest = __rest(_a, ["anchorEl", "header", "onSelect", "setAnchorEl", "setFilterValue", "table"]);
680
- const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
681
- const { density, globalFilterFn } = getState();
682
- const { column } = header !== null && header !== void 0 ? header : {};
683
- const { columnDef } = column !== null && column !== void 0 ? column : {};
684
- const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
685
- let allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
686
- if (rangeVariants.includes(columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant)) {
687
- allowedColumnFilterOptions = [
688
- ...rangeModes,
689
- ...(allowedColumnFilterOptions !== null && allowedColumnFilterOptions !== void 0 ? allowedColumnFilterOptions : []),
690
- ].filter((option) => rangeModes.includes(option));
691
- }
692
- const internalFilterOptions = useMemo(() => mrtFilterOptions(localization).filter((filterOption) => columnDef
693
- ? allowedColumnFilterOptions === undefined ||
694
- (allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.includes(filterOption.option))
695
- : (!globalFilterModeOptions ||
696
- globalFilterModeOptions.includes(filterOption.option)) &&
697
- ['contains', 'fuzzy', 'startsWith'].includes(filterOption.option)), []);
698
- const handleSelectFilterMode = (option) => {
699
- var _a, _b;
700
- const prevFilterMode = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef._filterFn) !== null && _a !== void 0 ? _a : '';
701
- if (!header || !column) {
702
- // global filter mode
703
- setGlobalFilterFn(option);
704
- }
705
- else if (option !== prevFilterMode) {
706
- // column filter mode
707
- setColumnFilterFns((prev) => (Object.assign(Object.assign({}, prev), { [header.id]: option })));
708
- // reset filter value and/or perform new filter render
709
- if (emptyModes.includes(option)) {
710
- // will now be empty/notEmpty filter mode
711
- if (currentFilterValue !== ' ' &&
712
- !emptyModes.includes(prevFilterMode)) {
713
- column.setFilterValue(' ');
714
- }
715
- else if (currentFilterValue) {
716
- column.setFilterValue(currentFilterValue); // perform new filter render
717
- }
718
- }
719
- else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
720
- arrModes.includes(option)) {
721
- // will now be array filter mode
722
- if (currentFilterValue instanceof String ||
723
- (currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.length)) {
724
- column.setFilterValue([]);
725
- setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue([]);
726
- }
727
- else if (currentFilterValue) {
728
- column.setFilterValue(currentFilterValue); // perform new filter render
729
- }
730
- }
731
- else if (((_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === null || _b === void 0 ? void 0 : _b.includes('range')) ||
732
- rangeModes.includes(option)) {
733
- // will now be range filter mode
734
- if (!Array.isArray(currentFilterValue) ||
735
- (!(currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.every((v) => v === '')) &&
736
- !rangeModes.includes(prevFilterMode))) {
737
- column.setFilterValue(['', '']);
738
- setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
739
- }
740
- else {
741
- column.setFilterValue(currentFilterValue); // perform new filter render
742
- }
743
- }
744
- else {
745
- // will now be single value filter mode
746
- if (Array.isArray(currentFilterValue)) {
747
- column.setFilterValue('');
748
- setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
749
- }
750
- else if (currentFilterValue === ' ' &&
751
- emptyModes.includes(prevFilterMode)) {
752
- column.setFilterValue(undefined);
753
- }
754
- else {
755
- column.setFilterValue(currentFilterValue); // perform new filter render
756
- }
757
- }
758
- }
759
- setAnchorEl(null);
760
- onSelect === null || onSelect === void 0 ? void 0 : onSelect();
761
- };
762
- const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
763
- const theme = useTheme();
764
- const { menuBackgroundColor } = getMRTTheme(table, theme);
765
- return (jsx(Menu, Object.assign({ MenuListProps: {
766
- dense: density === 'compact',
767
- sx: {
768
- backgroundColor: menuBackgroundColor,
769
- },
770
- }, anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_e = (header && column && columnDef
771
- ? (_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
772
- column: column,
773
- internalFilterOptions,
774
- onSelectFilterMode: handleSelectFilterMode,
775
- table,
776
- })) !== null && _d !== void 0 ? _d : renderColumnFilterModeMenuItems === null || renderColumnFilterModeMenuItems === void 0 ? void 0 : renderColumnFilterModeMenuItems({
777
- column: column,
778
- internalFilterOptions,
779
- onSelectFilterMode: handleSelectFilterMode,
780
- table,
781
- })
782
- : renderGlobalFilterModeMenuItems === null || renderGlobalFilterModeMenuItems === void 0 ? void 0 : renderGlobalFilterModeMenuItems({
783
- internalFilterOptions,
784
- onSelectFilterMode: handleSelectFilterMode,
785
- table,
786
- }))) !== null && _e !== void 0 ? _e : internalFilterOptions.map(({ divider, label, option, symbol }, index) => (jsxs(MenuItem, { divider: divider, onClick: () => handleSelectFilterMode(option), selected: option === filterOption, sx: {
787
- alignItems: 'center',
788
- display: 'flex',
789
- gap: '2ch',
790
- my: 0,
791
- py: '6px',
792
- }, value: option, children: [jsx(Box, { sx: { fontSize: '1.25rem', width: '2ch' }, children: symbol }), label] }, index))) })));
793
- };
794
-
795
- const commonMenuItemStyles = {
796
- alignItems: 'center',
797
- justifyContent: 'space-between',
798
- my: 0,
799
- py: '6px',
800
- };
801
- const commonListItemStyles = {
802
- alignItems: 'center',
803
- display: 'flex',
804
- };
805
- const MRT_ColumnActionMenu = (_a) => {
806
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
807
- var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
808
- 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;
809
- const { column } = header;
810
- const { columnDef } = column;
811
- const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
812
- const columnFilterValue = column.getFilterValue();
813
- const [filterMenuAnchorEl, setFilterMenuAnchorEl] = useState(null);
814
- const handleClearSort = () => {
815
- column.clearSorting();
816
- setAnchorEl(null);
817
- };
818
- const handleSortAsc = () => {
819
- column.toggleSorting(false);
820
- setAnchorEl(null);
821
- };
822
- const handleSortDesc = () => {
823
- column.toggleSorting(true);
824
- setAnchorEl(null);
825
- };
826
- const handleResetColumnSize = () => {
827
- setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
828
- column.resetSize();
829
- setAnchorEl(null);
830
- };
831
- const handleHideColumn = () => {
832
- column.toggleVisibility(false);
833
- setAnchorEl(null);
834
- };
835
- const handlePinColumn = (pinDirection) => {
836
- column.pin(pinDirection);
837
- setAnchorEl(null);
838
- };
839
- const handleGroupByColumn = () => {
840
- column.toggleGrouping();
841
- setColumnOrder((old) => ['mrt-row-expand', ...old]);
842
- setAnchorEl(null);
843
- };
844
- const handleClearFilter = () => {
845
- column.setFilterValue(undefined);
846
- setAnchorEl(null);
847
- if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
848
- setColumnFilterFns((prev) => {
849
- var _a;
850
- return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
851
- });
852
- }
853
- };
854
- const handleFilterByColumn = () => {
855
- setShowColumnFilters(true);
856
- queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); });
857
- setAnchorEl(null);
858
- };
859
- const handleShowAllColumns = () => {
860
- toggleAllColumnsVisible(true);
861
- setAnchorEl(null);
862
- };
863
- const handleOpenFilterModeMenu = (event) => {
864
- event.stopPropagation();
865
- setFilterMenuAnchorEl(event.currentTarget);
866
- };
867
- const isSelectFilter = !!columnDef.filterSelectOptions;
868
- const allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
869
- const showFilterModeSubMenu = enableColumnFilterModes &&
870
- columnDef.enableColumnFilterModes !== false &&
871
- !isSelectFilter &&
872
- (allowedColumnFilterOptions === undefined ||
873
- !!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
874
- const internalColumnMenuItems = [
875
- ...(enableSorting && column.getCanSort()
876
- ? [
877
- 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)),
878
- 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),
879
- 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),
880
- ]
881
- : []),
882
- ...(enableColumnFilters && column.getCanFilter()
883
- ? [
884
- jsx(MenuItem, { disabled: !columnFilterValue ||
885
- (Array.isArray(columnFilterValue) &&
886
- !columnFilterValue.filter((value) => value).length), onClick: handleClearFilter, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(FilterListOffIcon, {}) }), localization.clearFilter] }) }, 3),
887
- columnFilterDisplayMode === 'subheader' && (jsxs(MenuItem, { disabled: showColumnFilters && !enableColumnFilterModes, divider: enableGrouping || enableHiding, onClick: showColumnFilters
888
- ? handleOpenFilterModeMenu
889
- : 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)),
890
- showFilterModeSubMenu && (jsx(MRT_FilterOptionMenu, { anchorEl: filterMenuAnchorEl, header: header, onSelect: handleFilterByColumn, setAnchorEl: setFilterMenuAnchorEl, table: table }, 5)),
891
- ].filter(Boolean)
892
- : []),
893
- ...(enableGrouping && column.getCanGroup()
894
- ? [
895
- 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),
896
- ]
897
- : []),
898
- ...(enableColumnPinning && column.getCanPin()
899
- ? [
900
- 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),
901
- 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),
902
- 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),
903
- ]
904
- : []),
905
- ...(enableColumnResizing && column.getCanResize()
906
- ? [
907
- jsx(MenuItem, { disabled: !columnSizing[column.id], onClick: handleResetColumnSize, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(RestartAltIcon, {}) }), localization.resetColumnSize] }) }, 10),
908
- ]
909
- : []),
910
- ...(enableHiding
911
- ? [
912
- 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),
913
- jsx(MenuItem, { disabled: !Object.values(columnVisibility).filter((visible) => !visible)
914
- .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),
915
- ]
916
- : []),
917
- ].filter(Boolean);
918
- const theme = useTheme();
919
- const { menuBackgroundColor } = getMRTTheme(table, theme);
920
- return (jsx(Menu, Object.assign({ MenuListProps: {
921
- dense: density === 'compact',
922
- sx: {
923
- backgroundColor: menuBackgroundColor,
924
- },
925
- }, 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, {
926
- closeMenu: () => setAnchorEl(null),
927
- column,
928
- internalColumnMenuItems,
929
- table,
930
- })) !== null && _k !== void 0 ? _k : renderColumnActionsMenuItems === null || renderColumnActionsMenuItems === void 0 ? void 0 : renderColumnActionsMenuItems({
931
- closeMenu: () => setAnchorEl(null),
932
- column,
933
- internalColumnMenuItems,
934
- table,
935
- })) !== 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, {}) }))] })));
936
631
  };
937
632
 
938
633
  const MRT_RowActionMenu = (_a) => {
@@ -947,7 +642,7 @@ const MRT_RowActionMenu = (_a) => {
947
642
  backgroundColor: menuBackgroundColor,
948
643
  },
949
644
  }, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: [parseFromValuesOrFunc(enableEditing, row) &&
950
- ['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({
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({
951
646
  closeMenu: () => setAnchorEl(null),
952
647
  row,
953
648
  staticRowIndex,
@@ -990,9 +685,6 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
990
685
  };
991
686
 
992
687
  const getMRT_RowActionsColumnDef = (tableOptions) => {
993
- if (!showRowActionsColumn(tableOptions)) {
994
- return null;
995
- }
996
688
  return Object.assign({ Cell: ({ cell, row, staticRowIndex, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, staticRowIndex: staticRowIndex, table: table })) }, defaultDisplayColumnProps({
997
689
  header: 'actions',
998
690
  id: 'mrt-row-actions',
@@ -1046,9 +738,6 @@ const MRT_TableBodyRowGrabHandle = (_a) => {
1046
738
  };
1047
739
 
1048
740
  const getMRT_RowDragColumnDef = (tableOptions) => {
1049
- if (!showRowDragColumn(tableOptions)) {
1050
- return null;
1051
- }
1052
741
  return Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), grow: false }, defaultDisplayColumnProps({
1053
742
  header: 'move',
1054
743
  id: 'mrt-row-drag',
@@ -1108,9 +797,6 @@ const MRT_ExpandButton = ({ row, staticRowIndex, table, }) => {
1108
797
 
1109
798
  const getMRT_RowExpandColumnDef = (tableOptions) => {
1110
799
  var _a;
1111
- if (!showRowExpandColumn(tableOptions)) {
1112
- return null;
1113
- }
1114
800
  const { defaultColumn, enableExpandAll, groupedColumnMode, positionExpandColumn, renderDetailPanel, state: { grouping }, } = tableOptions;
1115
801
  const alignProps = positionExpandColumn === 'last'
1116
802
  ? {
@@ -1148,9 +834,6 @@ const getMRT_RowExpandColumnDef = (tableOptions) => {
1148
834
  };
1149
835
 
1150
836
  const getMRT_RowNumbersColumnDef = (tableOptions) => {
1151
- if (!showRowNumbersColumn(tableOptions)) {
1152
- return null;
1153
- }
1154
837
  const { localization, rowNumberDisplayMode } = tableOptions;
1155
838
  const { pagination: { pageIndex, pageSize }, } = tableOptions.state;
1156
839
  return Object.assign({ Cell: ({ row, staticRowIndex }) => {
@@ -1204,9 +887,6 @@ const MRT_TableBodyRowPinButton = (_a) => {
1204
887
  };
1205
888
 
1206
889
  const getMRT_RowPinningColumnDef = (tableOptions) => {
1207
- if (!showRowPinningColumn(tableOptions)) {
1208
- return null;
1209
- }
1210
890
  return Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), grow: false }, defaultDisplayColumnProps({
1211
891
  header: 'pin',
1212
892
  id: 'mrt-row-pin',
@@ -1278,9 +958,6 @@ const MRT_SelectCheckbox = (_a) => {
1278
958
  };
1279
959
 
1280
960
  const getMRT_RowSelectColumnDef = (tableOptions) => {
1281
- if (!showRowSelectionColumn(tableOptions)) {
1282
- return null;
1283
- }
1284
961
  const { enableMultiRowSelection, enableSelectAll } = tableOptions;
1285
962
  return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: enableSelectAll && enableMultiRowSelection
1286
963
  ? ({ table }) => jsx(MRT_SelectCheckbox, { table: table })
@@ -1300,6 +977,7 @@ const MRT_Default_Icons = {
1300
977
  ChevronRightIcon,
1301
978
  ClearAllIcon,
1302
979
  CloseIcon,
980
+ ContentCopy,
1303
981
  DensityLargeIcon,
1304
982
  DensityMediumIcon,
1305
983
  DensitySmallIcon,
@@ -1338,6 +1016,7 @@ const MRT_Localization_EN = {
1338
1016
  clearSearch: 'Clear search',
1339
1017
  clearSort: 'Clear sort',
1340
1018
  clickToCopy: 'Click to copy',
1019
+ copy: 'Copy',
1341
1020
  collapse: 'Collapse',
1342
1021
  collapseAll: 'Collapse all',
1343
1022
  columnActions: 'Column Actions',
@@ -1552,9 +1231,6 @@ const blankColProps = {
1552
1231
  },
1553
1232
  };
1554
1233
  const getMRT_RowSpacerColumnDef = (tableOptions) => {
1555
- if (!showRowSpacerColumn(tableOptions)) {
1556
- return null;
1557
- }
1558
1234
  return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumnProps({
1559
1235
  id: 'mrt-row-spacer',
1560
1236
  size: 0,
@@ -1562,21 +1238,10 @@ const getMRT_RowSpacerColumnDef = (tableOptions) => {
1562
1238
  })), { grow: true }), MRT_DefaultDisplayColumn), { muiTableBodyCellProps: blankColProps, muiTableFooterCellProps: blankColProps, muiTableHeadCellProps: blankColProps });
1563
1239
  };
1564
1240
 
1565
- const getMRT_DisplayColumns = (tableOptions) => {
1566
- return [
1567
- getMRT_RowNumbersColumnDef(tableOptions),
1568
- getMRT_RowSelectColumnDef(tableOptions),
1569
- getMRT_RowExpandColumnDef(tableOptions),
1570
- getMRT_RowActionsColumnDef(tableOptions),
1571
- getMRT_RowDragColumnDef(tableOptions),
1572
- getMRT_RowPinningColumnDef(tableOptions),
1573
- getMRT_RowSpacerColumnDef(tableOptions),
1574
- ].filter(Boolean);
1575
- };
1576
-
1577
1241
  const useMRT_Effects = (table) => {
1578
1242
  const { getIsSomeRowsPinned, getPrePaginationRowModel, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
1579
- 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;
1580
1245
  const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
1581
1246
  const rerender = useReducer(() => ({}), {})[1];
1582
1247
  const isMounted = useRef(false);
@@ -1640,10 +1305,22 @@ const useMRT_Effects = (table) => {
1640
1305
  }, 150);
1641
1306
  }
1642
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]);
1643
1314
  };
1644
1315
 
1645
- const useMRT_TableInstance = (_tableOptions) => {
1646
- 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);
1647
1324
  const bottomToolbarRef = useRef(null);
1648
1325
  const editInputRefs = useRef({});
1649
1326
  const filterInputRefs = useRef({});
@@ -1654,17 +1331,19 @@ const useMRT_TableInstance = (_tableOptions) => {
1654
1331
  const topToolbarRef = useRef(null);
1655
1332
  const tableHeadRef = useRef(null);
1656
1333
  const tableFooterRef = useRef(null);
1334
+ //transform initial state with proper column order
1657
1335
  const initialState = useMemo(() => {
1658
1336
  var _a, _b, _c;
1659
- const initState = (_a = _tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
1337
+ const initState = (_a = definedTableOptions.initialState) !== null && _a !== void 0 ? _a : {};
1660
1338
  initState.columnOrder =
1661
- (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(Object.assign(Object.assign({}, _tableOptions), { state: Object.assign(Object.assign({}, _tableOptions.initialState), _tableOptions.state) }));
1662
- 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';
1663
1341
  return initState;
1664
1342
  }, []);
1665
- _tableOptions.initialState = initialState;
1666
- const [creatingRow, _setCreatingRow] = useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
1667
- 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) => {
1668
1347
  var _a, _b, _c, _d;
1669
1348
  return ({
1670
1349
  [getColumnId(col)]: col.filterFn instanceof Function
@@ -1672,24 +1351,25 @@ const useMRT_TableInstance = (_tableOptions) => {
1672
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),
1673
1352
  });
1674
1353
  })));
1675
- const [columnOrder, onColumnOrderChange] = useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
1676
- const [columnSizingInfo, onColumnSizingInfoChange] = useState((_c = initialState.columnSizingInfo) !== null && _c !== void 0 ? _c : {});
1677
- const [density, setDensity] = useState((_d = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _d !== void 0 ? _d : 'comfortable');
1678
- const [draggingColumn, setDraggingColumn] = useState((_e = initialState.draggingColumn) !== null && _e !== void 0 ? _e : null);
1679
- const [draggingRow, setDraggingRow] = useState((_f = initialState.draggingRow) !== null && _f !== void 0 ? _f : null);
1680
- const [editingCell, setEditingCell] = useState((_g = initialState.editingCell) !== null && _g !== void 0 ? _g : null);
1681
- const [editingRow, setEditingRow] = useState((_h = initialState.editingRow) !== null && _h !== void 0 ? _h : null);
1682
- const [globalFilterFn, setGlobalFilterFn] = useState((_j = initialState.globalFilterFn) !== null && _j !== void 0 ? _j : 'fuzzy');
1683
- const [grouping, onGroupingChange] = useState((_k = initialState.grouping) !== null && _k !== void 0 ? _k : []);
1684
- const [hoveredColumn, setHoveredColumn] = useState((_l = initialState.hoveredColumn) !== null && _l !== void 0 ? _l : null);
1685
- const [hoveredRow, setHoveredRow] = useState((_m = initialState.hoveredRow) !== null && _m !== void 0 ? _m : null);
1686
- const [isFullScreen, setIsFullScreen] = useState((_o = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _o !== void 0 ? _o : false);
1687
- const [pagination, onPaginationChange] = useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _p !== void 0 ? _p : { pageIndex: 0, pageSize: 10 });
1688
- const [showAlertBanner, setShowAlertBanner] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _q !== void 0 ? _q : false);
1689
- const [showColumnFilters, setShowColumnFilters] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _r !== void 0 ? _r : false);
1690
- const [showGlobalFilter, setShowGlobalFilter] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _s !== void 0 ? _s : false);
1691
- const [showToolbarDropZone, setShowToolbarDropZone] = useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _t !== void 0 ? _t : false);
1692
- _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,
1693
1373
  columnOrder,
1694
1374
  columnSizingInfo,
1695
1375
  creatingRow,
@@ -1707,90 +1387,110 @@ const useMRT_TableInstance = (_tableOptions) => {
1707
1387
  showAlertBanner,
1708
1388
  showColumnFilters,
1709
1389
  showGlobalFilter,
1710
- showToolbarDropZone }, _tableOptions.state);
1711
- 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;
1712
1393
  //don't recompute columnDefs while resizing column or dragging column/row
1713
1394
  const columnDefsRef = useRef([]);
1714
- tableOptions.columns =
1715
- tableOptions.state.columnSizingInfo.isResizingColumn ||
1716
- tableOptions.state.draggingColumn ||
1717
- tableOptions.state.draggingRow
1395
+ statefulTableOptions.columns =
1396
+ statefulTableOptions.state.columnSizingInfo.isResizingColumn ||
1397
+ statefulTableOptions.state.draggingColumn ||
1398
+ statefulTableOptions.state.draggingRow
1718
1399
  ? columnDefsRef.current
1719
1400
  : prepareColumns({
1720
1401
  columnDefs: [
1721
- ...getMRT_DisplayColumns(tableOptions),
1722
- ...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),
1723
1421
  ],
1724
- tableOptions,
1422
+ tableOptions: statefulTableOptions,
1725
1423
  });
1726
- columnDefsRef.current = tableOptions.columns;
1727
- tableOptions.data = useMemo(() => (tableOptions.state.isLoading || tableOptions.state.showSkeletons) &&
1728
- !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
1729
1429
  ? [
1730
- ...Array(Math.min(tableOptions.state.pagination.pageSize, 20)).fill(null),
1731
- ].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) => ({
1732
1432
  [getColumnId(col)]: null,
1733
1433
  }))))
1734
- : tableOptions.data, [
1735
- tableOptions.data,
1736
- tableOptions.state.isLoading,
1737
- tableOptions.state.showSkeletons,
1434
+ : statefulTableOptions.data, [
1435
+ statefulTableOptions.data,
1436
+ statefulTableOptions.state.isLoading,
1437
+ statefulTableOptions.state.showSkeletons,
1738
1438
  ]);
1739
1439
  //@ts-ignore
1740
1440
  const table = useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
1741
1441
  onColumnSizingInfoChange,
1742
1442
  onGroupingChange,
1743
- onPaginationChange }, tableOptions), { globalFilterFn: (_u = tableOptions.filterFns) === null || _u === void 0 ? void 0 : _u[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1744
- //@ts-ignore
1443
+ onPaginationChange }, statefulTableOptions), { globalFilterFn: (_v = statefulTableOptions.filterFns) === null || _v === void 0 ? void 0 : _v[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1745
1444
  table.refs = {
1746
- //@ts-ignore
1445
+ actionCellRef,
1747
1446
  bottomToolbarRef,
1748
1447
  editInputRefs,
1749
1448
  filterInputRefs,
1750
- //@ts-ignore
1751
1449
  searchInputRef,
1752
- //@ts-ignore
1753
1450
  tableContainerRef,
1754
- //@ts-ignore
1755
1451
  tableFooterRef,
1756
1452
  tableHeadCellRefs,
1757
- //@ts-ignore
1758
1453
  tableHeadRef,
1759
- //@ts-ignore
1760
1454
  tablePaperRef,
1761
- //@ts-ignore
1762
1455
  topToolbarRef,
1763
1456
  };
1457
+ table.setActionCell =
1458
+ (_w = statefulTableOptions.onActionCellChange) !== null && _w !== void 0 ? _w : setActionCell;
1764
1459
  table.setCreatingRow = (row) => {
1765
1460
  var _a, _b;
1766
1461
  let _row = row;
1767
1462
  if (row === true) {
1768
1463
  _row = createRow(table);
1769
1464
  }
1770
- (_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);
1771
1466
  };
1772
1467
  table.setColumnFilterFns =
1773
- (_v = tableOptions.onColumnFilterFnsChange) !== null && _v !== void 0 ? _v : setColumnFilterFns;
1774
- 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;
1775
1470
  table.setDraggingColumn =
1776
- (_x = tableOptions.onDraggingColumnChange) !== null && _x !== void 0 ? _x : setDraggingColumn;
1777
- table.setDraggingRow = (_y = tableOptions.onDraggingRowChange) !== null && _y !== void 0 ? _y : setDraggingRow;
1778
- table.setEditingCell = (_z = tableOptions.onEditingCellChange) !== null && _z !== void 0 ? _z : setEditingCell;
1779
- 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;
1780
1478
  table.setGlobalFilterFn =
1781
- (_1 = tableOptions.onGlobalFilterFnChange) !== null && _1 !== void 0 ? _1 : setGlobalFilterFn;
1479
+ (_3 = statefulTableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
1782
1480
  table.setHoveredColumn =
1783
- (_2 = tableOptions.onHoveredColumnChange) !== null && _2 !== void 0 ? _2 : setHoveredColumn;
1784
- table.setHoveredRow = (_3 = tableOptions.onHoveredRowChange) !== null && _3 !== void 0 ? _3 : setHoveredRow;
1785
- 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;
1786
1486
  table.setShowAlertBanner =
1787
- (_5 = tableOptions.onShowAlertBannerChange) !== null && _5 !== void 0 ? _5 : setShowAlertBanner;
1487
+ (_7 = statefulTableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
1788
1488
  table.setShowColumnFilters =
1789
- (_6 = tableOptions.onShowColumnFiltersChange) !== null && _6 !== void 0 ? _6 : setShowColumnFilters;
1489
+ (_8 = statefulTableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
1790
1490
  table.setShowGlobalFilter =
1791
- (_7 = tableOptions.onShowGlobalFilterChange) !== null && _7 !== void 0 ? _7 : setShowGlobalFilter;
1491
+ (_9 = statefulTableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
1792
1492
  table.setShowToolbarDropZone =
1793
- (_8 = tableOptions.onShowToolbarDropZoneChange) !== null && _8 !== void 0 ? _8 : setShowToolbarDropZone;
1493
+ (_10 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
1794
1494
  useMRT_Effects(table);
1795
1495
  return table;
1796
1496
  };
@@ -2059,7 +1759,7 @@ const MRT_CopyButton = (_a) => {
2059
1759
  row,
2060
1760
  table,
2061
1761
  })), rest);
2062
- 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 })) })));
2063
1763
  };
2064
1764
 
2065
1765
  const MRT_EditCellTextField = (_a) => {
@@ -2160,10 +1860,10 @@ const MRT_EditCellTextField = (_a) => {
2160
1860
 
2161
1861
  const MRT_TableBodyCell = (_a) => {
2162
1862
  var _b, _c, _d, _e, _f;
2163
- 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"]);
2164
1864
  const theme = useTheme();
2165
- const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableEditing, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
2166
- 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();
2167
1867
  const { column, row } = cell;
2168
1868
  const { columnDef } = column;
2169
1869
  const { columnDefType } = columnDef;
@@ -2236,9 +1936,7 @@ const MRT_TableBodyCell = (_a) => {
2236
1936
  const isColumnPinned = enableColumnPinning &&
2237
1937
  columnDef.columnDefType !== 'group' &&
2238
1938
  column.getIsPinned();
2239
- const isEditable = !cell.getIsPlaceholder() &&
2240
- parseFromValuesOrFunc(enableEditing, row) &&
2241
- parseFromValuesOrFunc(columnDef.enableEditing, row) !== false;
1939
+ const isEditable = isCellEditable({ cell, table });
2242
1940
  const isEditing = isEditable &&
2243
1941
  !['custom', 'modal'].includes(editDisplayMode) &&
2244
1942
  (editDisplayMode === 'table' ||
@@ -2246,20 +1944,20 @@ const MRT_TableBodyCell = (_a) => {
2246
1944
  (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id) &&
2247
1945
  !row.getIsGrouped();
2248
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
+ };
2249
1957
  const handleDoubleClick = (event) => {
2250
1958
  var _a;
2251
1959
  (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDoubleClick) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2252
- if (isEditable && editDisplayMode === 'cell') {
2253
- setEditingCell(cell);
2254
- queueMicrotask(() => {
2255
- var _a;
2256
- const textField = editInputRefs.current[column.id];
2257
- if (textField) {
2258
- textField.focus();
2259
- (_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
2260
- }
2261
- });
2262
- }
1960
+ openEditingCell({ cell, table });
2263
1961
  };
2264
1962
  const handleDragEnter = (e) => {
2265
1963
  var _a;
@@ -2271,22 +1969,29 @@ const MRT_TableBodyCell = (_a) => {
2271
1969
  setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
2272
1970
  }
2273
1971
  };
2274
- const cellValueProps = {
2275
- cell,
2276
- 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
+ }
2277
1980
  };
2278
- return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, ref: (node) => {
2279
- if (node) {
2280
- measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
2281
- }
2282
- } }, tableCellProps, { onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
2283
- 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) ||
2284
1984
  (editDisplayMode === 'table' && (isCreating || isEditing))
2285
1985
  ? `1px solid ${theme.palette.grey[500]}`
2286
1986
  : undefined,
2287
- outlineOffset: '-1px',
2288
1987
  textOverflow: 'clip',
2289
- }, alignItems: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'center' : undefined, cursor: isEditable && editDisplayMode === 'cell' ? 'pointer' : 'inherit', 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'
2290
1995
  ? columnDefType === 'display'
2291
1996
  ? '0 0.5rem'
2292
1997
  : '0.5rem'
@@ -2311,8 +2016,7 @@ const MRT_TableBodyCell = (_a) => {
2311
2016
  rowRef,
2312
2017
  staticRowIndex,
2313
2018
  table,
2314
- })) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
2315
- 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, ")"] }))] })) })));
2316
2020
  };
2317
2021
  const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
2318
2022
 
@@ -2435,9 +2139,6 @@ const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVi
2435
2139
  }
2436
2140
  const props = {
2437
2141
  cell,
2438
- measureElement: !isDraggingRow && !isHoveredRow
2439
- ? columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement
2440
- : undefined,
2441
2142
  numRows,
2442
2143
  rowRef,
2443
2144
  staticColumnIndex,
@@ -2531,89 +2232,426 @@ const MRT_TableBody = (_a) => {
2531
2232
  return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
2532
2233
  }) })))] }));
2533
2234
  };
2534
- 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
+ };
2535
2521
 
2536
- const MRT_TableFooterCell = (_a) => {
2537
- var _b, _c, _d;
2538
- var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
2539
- const theme = useTheme();
2540
- const { getState, options: { enableColumnPinning, muiTableFooterCellProps }, } = table;
2541
- const { density } = getState();
2542
- 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;
2543
2527
  const { columnDef } = column;
2544
- const { columnDefType } = columnDef;
2545
- const isColumnPinned = enableColumnPinning &&
2546
- columnDef.columnDefType !== 'group' &&
2547
- column.getIsPinned();
2548
- const args = { column, table };
2549
- const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
2550
- return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
2551
- ? 'center'
2552
- : theme.direction === 'rtl'
2553
- ? 'right'
2554
- : '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'
2555
- ? '0.5rem'
2556
- : density === 'comfortable'
2557
- ? '1rem'
2558
- : '1.5rem', verticalAlign: 'top' }, 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),
2559
2646
  column,
2560
- header: footer,
2647
+ internalColumnMenuItems,
2561
2648
  table,
2562
- tableCellProps,
2563
- theme,
2564
- })), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (footer.isPlaceholder
2565
- ? null
2566
- : (_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
2567
- column,
2568
- footer,
2569
- table,
2570
- })) !== null && _c !== void 0 ? _c : columnDef.footer) !== null && _d !== void 0 ? _d : null) })));
2571
- };
2572
-
2573
- const MRT_TableFooterRow = (_a) => {
2574
- var _b;
2575
- var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
2576
- const { options: { layoutMode, muiTableFooterRowProps }, } = table;
2577
- const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2578
- // if no content in row, skip row
2579
- if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
2580
- !!header.column.columnDef.footer) ||
2581
- header.column.columnDef.Footer)))
2582
- return null;
2583
- const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterRowProps, {
2584
- footerGroup,
2585
- table,
2586
- })), rest);
2587
- 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) => {
2588
- let footer = footerOrVirtualFooter;
2589
- if (columnVirtualizer) {
2590
- staticColumnIndex = footerOrVirtualFooter
2591
- .index;
2592
- footer = footerGroup.headers[staticColumnIndex];
2593
- }
2594
- return footer ? (jsx(MRT_TableFooterCell, { footer: footer, staticColumnIndex: staticColumnIndex, table: table }, footer.id)) : null;
2595
- }), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
2596
- };
2597
-
2598
- const MRT_TableFooter = (_a) => {
2599
- var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2600
- const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
2601
- const { isFullScreen } = getState();
2602
- const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
2603
- table,
2604
- })), rest);
2605
- const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
2606
- return (jsx(TableFooter, Object.assign({}, tableFooterProps, { ref: (ref) => {
2607
- tableFooterRef.current = ref;
2608
- if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
2609
- // @ts-ignore
2610
- tableFooterProps.ref.current = ref;
2611
- }
2612
- }, 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
2613
- ? theme.palette.mode === 'light'
2614
- ? `1px solid ${theme.palette.grey[300]}`
2615
- : `1px solid ${theme.palette.grey[700]}`
2616
- : 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))) })));
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 })));
2617
2655
  };
2618
2656
 
2619
2657
  const MRT_TableHeadCellColumnActionsButton = (_a) => {
@@ -3037,7 +3075,7 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
3037
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: {
3038
3076
  horizontal: 'center',
3039
3077
  vertical: 'top',
3040
- }, onClick: (event) => event.stopPropagation(), onClose: (event) => {
3078
+ }, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: (event) => {
3041
3079
  //@ts-ignore
3042
3080
  event.stopPropagation();
3043
3081
  setAnchorEl(null);
@@ -3158,7 +3196,7 @@ const MRT_TableHeadCellSortLabel = (_a) => {
3158
3196
 
3159
3197
  const MRT_TableHeadCell = (_a) => {
3160
3198
  var _b, _c, _d, _f, _g, _h;
3161
- 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"]);
3162
3200
  const theme = useTheme();
3163
3201
  const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
3164
3202
  const { columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
@@ -3235,8 +3273,12 @@ const MRT_TableHeadCell = (_a) => {
3235
3273
  : theme.direction === 'rtl'
3236
3274
  ? 'right'
3237
3275
  : 'left', colSpan: header.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, onDragEnter: handleDragEnter, ref: (node) => {
3276
+ var _a;
3238
3277
  if (node) {
3239
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
+ }
3240
3282
  }
3241
3283
  } }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
3242
3284
  '.MuiButtonBase-root': {
@@ -3323,7 +3365,7 @@ const MRT_TableHeadRow = (_a) => {
3323
3365
  .index;
3324
3366
  header = headerGroup.headers[staticColumnIndex];
3325
3367
  }
3326
- 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;
3327
3369
  }), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
3328
3370
  };
3329
3371
 
@@ -3436,6 +3478,52 @@ const MRT_TableLoadingOverlay = (_a) => {
3436
3478
  }), children: jsx(CircularProgress, Object.assign({ "aria-label": localization.noRecordsToDisplay, id: "mrt-progress" }, circularProgressProps)) }));
3437
3479
  };
3438
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
+
3439
3527
  const MRT_EditRowModal = (_a) => {
3440
3528
  var _b;
3441
3529
  var { open, table } = _a, rest = __rest(_a, ["open", "table"]);
@@ -3480,8 +3568,8 @@ const MRT_EditRowModal = (_a) => {
3480
3568
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
3481
3569
  const MRT_TableContainer = (_a) => {
3482
3570
  var { table } = _a, rest = __rest(_a, ["table"]);
3483
- const { getState, options: { createDisplayMode, editDisplayMode, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
3484
- 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();
3485
3573
  const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
3486
3574
  const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
3487
3575
  const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableContainerProps, {
@@ -3511,7 +3599,7 @@ const MRT_TableContainer = (_a) => {
3511
3599
  ? `calc(100vh - ${totalToolbarHeight}px)`
3512
3600
  : undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign({ maxHeight: enableStickyHeader
3513
3601
  ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
3514
- : 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 })] })));
3515
3603
  };
3516
3604
 
3517
3605
  const MRT_LinearProgressBar = (_a) => {
@@ -3759,7 +3847,7 @@ const MRT_ShowHideColumnsMenu = (_a) => {
3759
3847
  justifyContent: 'space-between',
3760
3848
  p: '0.5rem',
3761
3849
  pt: 0,
3762
- }, 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}`)))] })));
3763
3851
  };
3764
3852
 
3765
3853
  const MRT_ShowHideColumnsButton = (_a) => {
@@ -3976,5 +4064,5 @@ const MaterialReactTable = (props) => {
3976
4064
  return jsx(MRT_TablePaper, { table: table });
3977
4065
  };
3978
4066
 
3979
- 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 };
3980
4068
  //# sourceMappingURL=index.esm.js.map