material-react-table 2.9.2 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
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.js CHANGED
@@ -12,8 +12,8 @@ var Box = require('@mui/material/Box');
12
12
  var Button = require('@mui/material/Button');
13
13
  var CircularProgress = require('@mui/material/CircularProgress');
14
14
  var styles = require('@mui/material/styles');
15
- var ListItemIcon = require('@mui/material/ListItemIcon');
16
15
  var Menu = require('@mui/material/Menu');
16
+ var ListItemIcon = require('@mui/material/ListItemIcon');
17
17
  var MenuItem = require('@mui/material/MenuItem');
18
18
  var Stack = require('@mui/material/Stack');
19
19
  var Checkbox = require('@mui/material/Checkbox');
@@ -25,6 +25,7 @@ var ChevronLeftIcon = require('@mui/icons-material/ChevronLeft');
25
25
  var ChevronRightIcon = require('@mui/icons-material/ChevronRight');
26
26
  var ClearAllIcon = require('@mui/icons-material/ClearAll');
27
27
  var CloseIcon = require('@mui/icons-material/Close');
28
+ var ContentCopy = require('@mui/icons-material/ContentCopy');
28
29
  var DensityLargeIcon = require('@mui/icons-material/DensityLarge');
29
30
  var DensityMediumIcon = require('@mui/icons-material/DensityMedium');
30
31
  var DensitySmallIcon = require('@mui/icons-material/DensitySmall');
@@ -102,8 +103,8 @@ var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
102
103
  var Box__default = /*#__PURE__*/_interopDefaultLegacy(Box);
103
104
  var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
104
105
  var CircularProgress__default = /*#__PURE__*/_interopDefaultLegacy(CircularProgress);
105
- var ListItemIcon__default = /*#__PURE__*/_interopDefaultLegacy(ListItemIcon);
106
106
  var Menu__default = /*#__PURE__*/_interopDefaultLegacy(Menu);
107
+ var ListItemIcon__default = /*#__PURE__*/_interopDefaultLegacy(ListItemIcon);
107
108
  var MenuItem__default = /*#__PURE__*/_interopDefaultLegacy(MenuItem);
108
109
  var Stack__default = /*#__PURE__*/_interopDefaultLegacy(Stack);
109
110
  var Checkbox__default = /*#__PURE__*/_interopDefaultLegacy(Checkbox);
@@ -115,6 +116,7 @@ var ChevronLeftIcon__default = /*#__PURE__*/_interopDefaultLegacy(ChevronLeftIco
115
116
  var ChevronRightIcon__default = /*#__PURE__*/_interopDefaultLegacy(ChevronRightIcon);
116
117
  var ClearAllIcon__default = /*#__PURE__*/_interopDefaultLegacy(ClearAllIcon);
117
118
  var CloseIcon__default = /*#__PURE__*/_interopDefaultLegacy(CloseIcon);
119
+ var ContentCopy__default = /*#__PURE__*/_interopDefaultLegacy(ContentCopy);
118
120
  var DensityLargeIcon__default = /*#__PURE__*/_interopDefaultLegacy(DensityLargeIcon);
119
121
  var DensityMediumIcon__default = /*#__PURE__*/_interopDefaultLegacy(DensityMediumIcon);
120
122
  var DensitySmallIcon__default = /*#__PURE__*/_interopDefaultLegacy(DensitySmallIcon);
@@ -301,17 +303,58 @@ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parent
301
303
  [getColumnId(col)]: '',
302
304
  }))), rowIndex, depth, subRows, parentId);
303
305
 
306
+ const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
307
+ const getValueAndLabel = (option) => {
308
+ var _a, _b, _c;
309
+ let label = '';
310
+ let value = '';
311
+ if (option) {
312
+ if (typeof option !== 'object') {
313
+ label = option;
314
+ value = option;
315
+ }
316
+ else {
317
+ label = (_b = (_a = option.label) !== null && _a !== void 0 ? _a : option.text) !== null && _b !== void 0 ? _b : option.value;
318
+ value = (_c = option.value) !== null && _c !== void 0 ? _c : label;
319
+ }
320
+ }
321
+ return { label, value };
322
+ };
323
+
324
+ const isCellEditable = ({ cell, table, }) => {
325
+ const { enableEditing } = table.options;
326
+ const { column: { columnDef }, row, } = cell;
327
+ return (!cell.getIsPlaceholder() &&
328
+ parseFromValuesOrFunc(enableEditing, row) &&
329
+ parseFromValuesOrFunc(columnDef.enableEditing, row) !== false);
330
+ };
331
+ const openEditingCell = ({ cell, table, }) => {
332
+ const { options: { editDisplayMode }, refs: { editInputRefs }, } = table;
333
+ const { column } = cell;
334
+ if (isCellEditable({ cell, table }) && editDisplayMode === 'cell') {
335
+ table.setEditingCell(cell);
336
+ queueMicrotask(() => {
337
+ var _a;
338
+ const textField = editInputRefs.current[column.id];
339
+ if (textField) {
340
+ textField.focus();
341
+ (_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
342
+ }
343
+ });
344
+ }
345
+ };
346
+
304
347
  function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
305
348
  const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
306
349
  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 });
307
350
  }
308
351
  const showRowPinningColumn = (tableOptions) => {
309
352
  const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
310
- return enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select'));
353
+ return !!(enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select')));
311
354
  };
312
355
  const showRowDragColumn = (tableOptions) => {
313
356
  const { enableRowDragging, enableRowOrdering } = tableOptions;
314
- return enableRowDragging || enableRowOrdering;
357
+ return !!(enableRowDragging || enableRowOrdering);
315
358
  };
316
359
  const showRowExpandColumn = (tableOptions) => {
317
360
  const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
@@ -321,12 +364,12 @@ const showRowExpandColumn = (tableOptions) => {
321
364
  };
322
365
  const showRowActionsColumn = (tableOptions) => {
323
366
  const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
324
- return (enableRowActions ||
367
+ return !!(enableRowActions ||
325
368
  (creatingRow && createDisplayMode === 'row') ||
326
369
  (enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
327
370
  };
328
- const showRowSelectionColumn = (tableOptions) => tableOptions.enableRowSelection;
329
- const showRowNumbersColumn = (tableOptions) => tableOptions.enableRowNumbers;
371
+ const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
372
+ const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
330
373
  const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
331
374
  const getLeadingDisplayColumnIds = (tableOptions) => [
332
375
  showRowPinningColumn(tableOptions) && 'mrt-row-pin',
@@ -349,32 +392,21 @@ const getTrailingDisplayColumnIds = (tableOptions) => [
349
392
  'mrt-row-expand',
350
393
  showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
351
394
  ].filter(Boolean);
352
- const getDefaultColumnOrderIds = (tableOptions) => {
353
- const leadingDisplayCols = getLeadingDisplayColumnIds(tableOptions);
354
- const trailingDisplayCols = getTrailingDisplayColumnIds(tableOptions);
355
- const allLeafColumnDefs = getAllLeafColumnDefs(tableOptions.columns)
356
- .map((columnDef) => getColumnId(columnDef))
357
- .filter((columnId) => !leadingDisplayCols.includes(columnId) &&
358
- !trailingDisplayCols.includes(columnId));
359
- return [...leadingDisplayCols, ...allLeafColumnDefs, ...trailingDisplayCols];
360
- };
361
-
362
- const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
363
- const getValueAndLabel = (option) => {
364
- var _a, _b, _c;
365
- let label = '';
366
- let value = '';
367
- if (option) {
368
- if (typeof option !== 'object') {
369
- label = option;
370
- value = option;
371
- }
372
- else {
373
- label = (_b = (_a = option.label) !== null && _a !== void 0 ? _a : option.text) !== null && _b !== void 0 ? _b : option.value;
374
- value = (_c = option.value) !== null && _c !== void 0 ? _c : label;
375
- }
376
- }
377
- return { label, value };
395
+ const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
396
+ const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
397
+ const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
398
+ const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
399
+ const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
400
+ let allLeafColumnDefIds = reset
401
+ ? defaultColumnDefIds
402
+ : Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
403
+ allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
404
+ !trailingDisplayColIds.includes(colId));
405
+ return [
406
+ ...leadingDisplayColIds,
407
+ ...allLeafColumnDefIds,
408
+ ...trailingDisplayColIds,
409
+ ];
378
410
  };
379
411
 
380
412
  const getIsRowSelected = ({ row, table, }) => {
@@ -673,373 +705,37 @@ const getCommonTooltipProps = (placement) => ({
673
705
  placement,
674
706
  });
675
707
 
676
- const mrtFilterOptions = (localization) => [
677
- {
678
- divider: false,
679
- label: localization.filterFuzzy,
680
- option: 'fuzzy',
681
- symbol: '',
682
- },
683
- {
684
- divider: false,
685
- label: localization.filterContains,
686
- option: 'contains',
687
- symbol: '*',
688
- },
689
- {
690
- divider: false,
691
- label: localization.filterStartsWith,
692
- option: 'startsWith',
693
- symbol: 'a',
694
- },
695
- {
696
- divider: true,
697
- label: localization.filterEndsWith,
698
- option: 'endsWith',
699
- symbol: 'z',
700
- },
701
- {
702
- divider: false,
703
- label: localization.filterEquals,
704
- option: 'equals',
705
- symbol: '=',
706
- },
707
- {
708
- divider: true,
709
- label: localization.filterNotEquals,
710
- option: 'notEquals',
711
- symbol: '≠',
712
- },
713
- {
714
- divider: false,
715
- label: localization.filterBetween,
716
- option: 'between',
717
- symbol: '⇿',
718
- },
719
- {
720
- divider: true,
721
- label: localization.filterBetweenInclusive,
722
- option: 'betweenInclusive',
723
- symbol: '⬌',
724
- },
725
- {
726
- divider: false,
727
- label: localization.filterGreaterThan,
728
- option: 'greaterThan',
729
- symbol: '>',
730
- },
731
- {
732
- divider: false,
733
- label: localization.filterGreaterThanOrEqualTo,
734
- option: 'greaterThanOrEqualTo',
735
- symbol: '≥',
736
- },
737
- {
738
- divider: false,
739
- label: localization.filterLessThan,
740
- option: 'lessThan',
741
- symbol: '<',
742
- },
743
- {
744
- divider: true,
745
- label: localization.filterLessThanOrEqualTo,
746
- option: 'lessThanOrEqualTo',
747
- symbol: '≤',
748
- },
749
- {
750
- divider: false,
751
- label: localization.filterEmpty,
752
- option: 'empty',
753
- symbol: '∅',
754
- },
755
- {
756
- divider: false,
757
- label: localization.filterNotEmpty,
758
- option: 'notEmpty',
759
- symbol: '!∅',
760
- },
761
- ];
762
- const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
763
- const emptyModes = ['empty', 'notEmpty'];
764
- const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
765
- const rangeVariants = ['range-slider', 'date-range', 'datetime-range', 'range'];
766
- const MRT_FilterOptionMenu = (_a) => {
767
- var _b, _c, _d, _e;
768
- var { anchorEl, header, onSelect, setAnchorEl, setFilterValue, table } = _a, rest = __rest(_a, ["anchorEl", "header", "onSelect", "setAnchorEl", "setFilterValue", "table"]);
769
- const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
770
- const { density, globalFilterFn } = getState();
771
- const { column } = header !== null && header !== void 0 ? header : {};
772
- const { columnDef } = column !== null && column !== void 0 ? column : {};
773
- const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
774
- let allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
775
- if (rangeVariants.includes(columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant)) {
776
- allowedColumnFilterOptions = [
777
- ...rangeModes,
778
- ...(allowedColumnFilterOptions !== null && allowedColumnFilterOptions !== void 0 ? allowedColumnFilterOptions : []),
779
- ].filter((option) => rangeModes.includes(option));
780
- }
781
- const internalFilterOptions = react.useMemo(() => mrtFilterOptions(localization).filter((filterOption) => columnDef
782
- ? allowedColumnFilterOptions === undefined ||
783
- (allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.includes(filterOption.option))
784
- : (!globalFilterModeOptions ||
785
- globalFilterModeOptions.includes(filterOption.option)) &&
786
- ['contains', 'fuzzy', 'startsWith'].includes(filterOption.option)), []);
787
- const handleSelectFilterMode = (option) => {
788
- var _a, _b;
789
- const prevFilterMode = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef._filterFn) !== null && _a !== void 0 ? _a : '';
790
- if (!header || !column) {
791
- // global filter mode
792
- setGlobalFilterFn(option);
793
- }
794
- else if (option !== prevFilterMode) {
795
- // column filter mode
796
- setColumnFilterFns((prev) => (Object.assign(Object.assign({}, prev), { [header.id]: option })));
797
- // reset filter value and/or perform new filter render
798
- if (emptyModes.includes(option)) {
799
- // will now be empty/notEmpty filter mode
800
- if (currentFilterValue !== ' ' &&
801
- !emptyModes.includes(prevFilterMode)) {
802
- column.setFilterValue(' ');
803
- }
804
- else if (currentFilterValue) {
805
- column.setFilterValue(currentFilterValue); // perform new filter render
806
- }
807
- }
808
- else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
809
- arrModes.includes(option)) {
810
- // will now be array filter mode
811
- if (currentFilterValue instanceof String ||
812
- (currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.length)) {
813
- column.setFilterValue([]);
814
- setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue([]);
815
- }
816
- else if (currentFilterValue) {
817
- column.setFilterValue(currentFilterValue); // perform new filter render
818
- }
819
- }
820
- else if (((_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === null || _b === void 0 ? void 0 : _b.includes('range')) ||
821
- rangeModes.includes(option)) {
822
- // will now be range filter mode
823
- if (!Array.isArray(currentFilterValue) ||
824
- (!(currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.every((v) => v === '')) &&
825
- !rangeModes.includes(prevFilterMode))) {
826
- column.setFilterValue(['', '']);
827
- setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
828
- }
829
- else {
830
- column.setFilterValue(currentFilterValue); // perform new filter render
831
- }
832
- }
833
- else {
834
- // will now be single value filter mode
835
- if (Array.isArray(currentFilterValue)) {
836
- column.setFilterValue('');
837
- setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
838
- }
839
- else if (currentFilterValue === ' ' &&
840
- emptyModes.includes(prevFilterMode)) {
841
- column.setFilterValue(undefined);
842
- }
843
- else {
844
- column.setFilterValue(currentFilterValue); // perform new filter render
845
- }
846
- }
847
- }
848
- setAnchorEl(null);
849
- onSelect === null || onSelect === void 0 ? void 0 : onSelect();
850
- };
851
- const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
708
+ const MRT_ActionMenuItem = (_a) => {
709
+ var { icon, label, onOpenSubMenu, table } = _a, rest = __rest(_a, ["icon", "label", "onOpenSubMenu", "table"]);
710
+ const { options: { icons: { ArrowRightIcon }, }, } = table;
711
+ return (jsxRuntime.jsxs(MenuItem__default["default"], Object.assign({ sx: {
712
+ alignItems: 'center',
713
+ justifyContent: 'space-between',
714
+ minWidth: '120px',
715
+ my: 0,
716
+ py: '6px',
717
+ } }, rest, { children: [jsxRuntime.jsxs(Box__default["default"], { sx: {
718
+ alignItems: 'center',
719
+ display: 'flex',
720
+ }, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: icon }), label] }), onOpenSubMenu && (jsxRuntime.jsx(IconButton__default["default"], { onClick: onOpenSubMenu, onMouseEnter: onOpenSubMenu, size: "small", sx: { p: 0 }, children: jsxRuntime.jsx(ArrowRightIcon, {}) }))] })));
721
+ };
722
+
723
+ const MRT_RowActionMenu = (_a) => {
724
+ var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
725
+ const { getState, options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, renderRowActionMenuItems, }, } = table;
726
+ const { density } = getState();
852
727
  const theme = styles.useTheme();
853
728
  const { menuBackgroundColor } = getMRTTheme(table, theme);
854
- return (jsxRuntime.jsx(Menu__default["default"], Object.assign({ MenuListProps: {
729
+ return (jsxRuntime.jsxs(Menu__default["default"], Object.assign({ MenuListProps: {
855
730
  dense: density === 'compact',
856
731
  sx: {
857
732
  backgroundColor: menuBackgroundColor,
858
733
  },
859
- }, anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_e = (header && column && columnDef
860
- ? (_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
861
- column: column,
862
- internalFilterOptions,
863
- onSelectFilterMode: handleSelectFilterMode,
864
- table,
865
- })) !== null && _d !== void 0 ? _d : renderColumnFilterModeMenuItems === null || renderColumnFilterModeMenuItems === void 0 ? void 0 : renderColumnFilterModeMenuItems({
866
- column: column,
867
- internalFilterOptions,
868
- onSelectFilterMode: handleSelectFilterMode,
869
- table,
870
- })
871
- : renderGlobalFilterModeMenuItems === null || renderGlobalFilterModeMenuItems === void 0 ? void 0 : renderGlobalFilterModeMenuItems({
872
- internalFilterOptions,
873
- onSelectFilterMode: handleSelectFilterMode,
874
- table,
875
- }))) !== null && _e !== void 0 ? _e : internalFilterOptions.map(({ divider, label, option, symbol }, index) => (jsxRuntime.jsxs(MenuItem__default["default"], { divider: divider, onClick: () => handleSelectFilterMode(option), selected: option === filterOption, sx: {
876
- alignItems: 'center',
877
- display: 'flex',
878
- gap: '2ch',
879
- my: 0,
880
- py: '6px',
881
- }, value: option, children: [jsxRuntime.jsx(Box__default["default"], { sx: { fontSize: '1.25rem', width: '2ch' }, children: symbol }), label] }, index))) })));
882
- };
883
-
884
- const commonMenuItemStyles = {
885
- alignItems: 'center',
886
- justifyContent: 'space-between',
887
- my: 0,
888
- py: '6px',
889
- };
890
- const commonListItemStyles = {
891
- alignItems: 'center',
892
- display: 'flex',
893
- };
894
- const MRT_ColumnActionMenu = (_a) => {
895
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
896
- var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
897
- 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;
898
- const { column } = header;
899
- const { columnDef } = column;
900
- const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
901
- const columnFilterValue = column.getFilterValue();
902
- const [filterMenuAnchorEl, setFilterMenuAnchorEl] = react.useState(null);
903
- const handleClearSort = () => {
904
- column.clearSorting();
905
- setAnchorEl(null);
906
- };
907
- const handleSortAsc = () => {
908
- column.toggleSorting(false);
909
- setAnchorEl(null);
910
- };
911
- const handleSortDesc = () => {
912
- column.toggleSorting(true);
913
- setAnchorEl(null);
914
- };
915
- const handleResetColumnSize = () => {
916
- setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
917
- column.resetSize();
918
- setAnchorEl(null);
919
- };
920
- const handleHideColumn = () => {
921
- column.toggleVisibility(false);
922
- setAnchorEl(null);
923
- };
924
- const handlePinColumn = (pinDirection) => {
925
- column.pin(pinDirection);
926
- setAnchorEl(null);
927
- };
928
- const handleGroupByColumn = () => {
929
- column.toggleGrouping();
930
- setColumnOrder((old) => ['mrt-row-expand', ...old]);
931
- setAnchorEl(null);
932
- };
933
- const handleClearFilter = () => {
934
- column.setFilterValue(undefined);
935
- setAnchorEl(null);
936
- if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
937
- setColumnFilterFns((prev) => {
938
- var _a;
939
- return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
940
- });
941
- }
942
- };
943
- const handleFilterByColumn = () => {
944
- setShowColumnFilters(true);
945
- queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); });
946
- setAnchorEl(null);
947
- };
948
- const handleShowAllColumns = () => {
949
- toggleAllColumnsVisible(true);
950
- setAnchorEl(null);
951
- };
952
- const handleOpenFilterModeMenu = (event) => {
953
- event.stopPropagation();
954
- setFilterMenuAnchorEl(event.currentTarget);
955
- };
956
- const isSelectFilter = !!columnDef.filterSelectOptions;
957
- const allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
958
- const showFilterModeSubMenu = enableColumnFilterModes &&
959
- columnDef.enableColumnFilterModes !== false &&
960
- !isSelectFilter &&
961
- (allowedColumnFilterOptions === undefined ||
962
- !!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
963
- const internalColumnMenuItems = [
964
- ...(enableSorting && column.getCanSort()
965
- ? [
966
- enableSortingRemoval !== false && (jsxRuntime.jsx(MenuItem__default["default"], { disabled: !column.getIsSorted(), onClick: handleClearSort, sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(ClearAllIcon, {}) }), localization.clearSort] }) }, 0)),
967
- jsxRuntime.jsx(MenuItem__default["default"], { disabled: column.getIsSorted() === 'asc', onClick: handleSortAsc, sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(SortIcon, { style: { transform: 'rotate(180deg) scaleX(-1)' } }) }), (_c = localization.sortByColumnAsc) === null || _c === void 0 ? void 0 : _c.replace('{column}', String(columnDef.header))] }) }, 1),
968
- jsxRuntime.jsx(MenuItem__default["default"], { disabled: column.getIsSorted() === 'desc', divider: enableColumnFilters || enableGrouping || enableHiding, onClick: handleSortDesc, sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(SortIcon, {}) }), (_d = localization.sortByColumnDesc) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header))] }) }, 2),
969
- ]
970
- : []),
971
- ...(enableColumnFilters && column.getCanFilter()
972
- ? [
973
- jsxRuntime.jsx(MenuItem__default["default"], { disabled: !columnFilterValue ||
974
- (Array.isArray(columnFilterValue) &&
975
- !columnFilterValue.filter((value) => value).length), onClick: handleClearFilter, sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(FilterListOffIcon, {}) }), localization.clearFilter] }) }, 3),
976
- columnFilterDisplayMode === 'subheader' && (jsxRuntime.jsxs(MenuItem__default["default"], { disabled: showColumnFilters && !enableColumnFilterModes, divider: enableGrouping || enableHiding, onClick: showColumnFilters
977
- ? handleOpenFilterModeMenu
978
- : handleFilterByColumn, sx: commonMenuItemStyles, children: [jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(FilterListIcon, {}) }), (_e = localization.filterByColumn) === null || _e === void 0 ? void 0 : _e.replace('{column}', String(columnDef.header))] }), showFilterModeSubMenu && (jsxRuntime.jsx(IconButton__default["default"], { onClick: handleOpenFilterModeMenu, onMouseEnter: handleOpenFilterModeMenu, size: "small", sx: { p: 0 }, children: jsxRuntime.jsx(ArrowRightIcon, {}) }))] }, 4)),
979
- showFilterModeSubMenu && (jsxRuntime.jsx(MRT_FilterOptionMenu, { anchorEl: filterMenuAnchorEl, header: header, onSelect: handleFilterByColumn, setAnchorEl: setFilterMenuAnchorEl, table: table }, 5)),
980
- ].filter(Boolean)
981
- : []),
982
- ...(enableGrouping && column.getCanGroup()
983
- ? [
984
- jsxRuntime.jsx(MenuItem__default["default"], { divider: enableColumnPinning, onClick: handleGroupByColumn, sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(DynamicFeedIcon, {}) }), (_f = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) === null || _f === void 0 ? void 0 : _f.replace('{column}', String(columnDef.header))] }) }, 6),
985
- ]
986
- : []),
987
- ...(enableColumnPinning && column.getCanPin()
988
- ? [
989
- jsxRuntime.jsx(MenuItem__default["default"], { disabled: column.getIsPinned() === 'left' || !column.getCanPin(), onClick: () => handlePinColumn('left'), sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(PushPinIcon, { style: { transform: 'rotate(90deg)' } }) }), localization.pinToLeft] }) }, 7),
990
- jsxRuntime.jsx(MenuItem__default["default"], { disabled: column.getIsPinned() === 'right' || !column.getCanPin(), onClick: () => handlePinColumn('right'), sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(PushPinIcon, { style: { transform: 'rotate(-90deg)' } }) }), localization.pinToRight] }) }, 8),
991
- jsxRuntime.jsx(MenuItem__default["default"], { disabled: !column.getIsPinned(), divider: enableHiding, onClick: () => handlePinColumn(false), sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(PushPinIcon, {}) }), localization.unpin] }) }, 9),
992
- ]
993
- : []),
994
- ...(enableColumnResizing && column.getCanResize()
995
- ? [
996
- jsxRuntime.jsx(MenuItem__default["default"], { disabled: !columnSizing[column.id], onClick: handleResetColumnSize, sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(RestartAltIcon, {}) }), localization.resetColumnSize] }) }, 10),
997
- ]
998
- : []),
999
- ...(enableHiding
1000
- ? [
1001
- jsxRuntime.jsx(MenuItem__default["default"], { disabled: !column.getCanHide(), onClick: handleHideColumn, sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(VisibilityOffIcon, {}) }), (_g = localization.hideColumn) === null || _g === void 0 ? void 0 : _g.replace('{column}', String(columnDef.header))] }) }, 11),
1002
- jsxRuntime.jsx(MenuItem__default["default"], { disabled: !Object.values(columnVisibility).filter((visible) => !visible)
1003
- .length, onClick: handleShowAllColumns, sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(ViewColumnIcon, {}) }), (_h = localization.showAllColumns) === null || _h === void 0 ? void 0 : _h.replace('{column}', String(columnDef.header))] }) }, 12),
1004
- ]
1005
- : []),
1006
- ].filter(Boolean);
1007
- const theme = styles.useTheme();
1008
- const { menuBackgroundColor } = getMRTTheme(table, theme);
1009
- return (jsxRuntime.jsx(Menu__default["default"], Object.assign({ MenuListProps: {
1010
- dense: density === 'compact',
1011
- sx: {
1012
- backgroundColor: menuBackgroundColor,
1013
- },
1014
- }, 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, {
1015
- closeMenu: () => setAnchorEl(null),
1016
- column,
1017
- internalColumnMenuItems,
1018
- table,
1019
- })) !== null && _k !== void 0 ? _k : renderColumnActionsMenuItems === null || renderColumnActionsMenuItems === void 0 ? void 0 : renderColumnActionsMenuItems({
1020
- closeMenu: () => setAnchorEl(null),
1021
- column,
1022
- internalColumnMenuItems,
1023
- table,
1024
- })) !== null && _l !== void 0 ? _l : internalColumnMenuItems })));
1025
- };
1026
-
1027
- const MRT_RowActionMenu = (_a) => {
1028
- var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
1029
- const { getState, options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, renderRowActionMenuItems, }, } = table;
1030
- const { density } = getState();
1031
- const theme = styles.useTheme();
1032
- const { menuBackgroundColor } = getMRTTheme(table, theme);
1033
- return (jsxRuntime.jsxs(Menu__default["default"], Object.assign({ MenuListProps: {
1034
- dense: density === 'compact',
1035
- sx: {
1036
- backgroundColor: menuBackgroundColor,
1037
- },
1038
- }, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: [parseFromValuesOrFunc(enableEditing, row) &&
1039
- ['modal', 'row'].includes(editDisplayMode) && (jsxRuntime.jsx(MenuItem__default["default"], { onClick: handleEdit, sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(EditIcon, {}) }), localization.edit] }) })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
1040
- closeMenu: () => setAnchorEl(null),
1041
- row,
1042
- staticRowIndex,
734
+ }, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: [parseFromValuesOrFunc(enableEditing, row) &&
735
+ ['modal', 'row'].includes(editDisplayMode) && (jsxRuntime.jsx(MRT_ActionMenuItem, { icon: jsxRuntime.jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
736
+ closeMenu: () => setAnchorEl(null),
737
+ row,
738
+ staticRowIndex,
1043
739
  table,
1044
740
  })] })));
1045
741
  };
@@ -1079,9 +775,6 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
1079
775
  };
1080
776
 
1081
777
  const getMRT_RowActionsColumnDef = (tableOptions) => {
1082
- if (!showRowActionsColumn(tableOptions)) {
1083
- return null;
1084
- }
1085
778
  return Object.assign({ Cell: ({ cell, row, staticRowIndex, table }) => (jsxRuntime.jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, staticRowIndex: staticRowIndex, table: table })) }, defaultDisplayColumnProps({
1086
779
  header: 'actions',
1087
780
  id: 'mrt-row-actions',
@@ -1135,9 +828,6 @@ const MRT_TableBodyRowGrabHandle = (_a) => {
1135
828
  };
1136
829
 
1137
830
  const getMRT_RowDragColumnDef = (tableOptions) => {
1138
- if (!showRowDragColumn(tableOptions)) {
1139
- return null;
1140
- }
1141
831
  return Object.assign({ Cell: ({ row, rowRef, table }) => (jsxRuntime.jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), grow: false }, defaultDisplayColumnProps({
1142
832
  header: 'move',
1143
833
  id: 'mrt-row-drag',
@@ -1197,9 +887,6 @@ const MRT_ExpandButton = ({ row, staticRowIndex, table, }) => {
1197
887
 
1198
888
  const getMRT_RowExpandColumnDef = (tableOptions) => {
1199
889
  var _a;
1200
- if (!showRowExpandColumn(tableOptions)) {
1201
- return null;
1202
- }
1203
890
  const { defaultColumn, enableExpandAll, groupedColumnMode, positionExpandColumn, renderDetailPanel, state: { grouping }, } = tableOptions;
1204
891
  const alignProps = positionExpandColumn === 'last'
1205
892
  ? {
@@ -1237,9 +924,6 @@ const getMRT_RowExpandColumnDef = (tableOptions) => {
1237
924
  };
1238
925
 
1239
926
  const getMRT_RowNumbersColumnDef = (tableOptions) => {
1240
- if (!showRowNumbersColumn(tableOptions)) {
1241
- return null;
1242
- }
1243
927
  const { localization, rowNumberDisplayMode } = tableOptions;
1244
928
  const { pagination: { pageIndex, pageSize }, } = tableOptions.state;
1245
929
  return Object.assign({ Cell: ({ row, staticRowIndex }) => {
@@ -1293,9 +977,6 @@ const MRT_TableBodyRowPinButton = (_a) => {
1293
977
  };
1294
978
 
1295
979
  const getMRT_RowPinningColumnDef = (tableOptions) => {
1296
- if (!showRowPinningColumn(tableOptions)) {
1297
- return null;
1298
- }
1299
980
  return Object.assign({ Cell: ({ row, table }) => (jsxRuntime.jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), grow: false }, defaultDisplayColumnProps({
1300
981
  header: 'pin',
1301
982
  id: 'mrt-row-pin',
@@ -1367,9 +1048,6 @@ const MRT_SelectCheckbox = (_a) => {
1367
1048
  };
1368
1049
 
1369
1050
  const getMRT_RowSelectColumnDef = (tableOptions) => {
1370
- if (!showRowSelectionColumn(tableOptions)) {
1371
- return null;
1372
- }
1373
1051
  const { enableMultiRowSelection, enableSelectAll } = tableOptions;
1374
1052
  return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsxRuntime.jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: enableSelectAll && enableMultiRowSelection
1375
1053
  ? ({ table }) => jsxRuntime.jsx(MRT_SelectCheckbox, { table: table })
@@ -1389,6 +1067,7 @@ const MRT_Default_Icons = {
1389
1067
  ChevronRightIcon: ChevronRightIcon__default["default"],
1390
1068
  ClearAllIcon: ClearAllIcon__default["default"],
1391
1069
  CloseIcon: CloseIcon__default["default"],
1070
+ ContentCopy: ContentCopy__default["default"],
1392
1071
  DensityLargeIcon: DensityLargeIcon__default["default"],
1393
1072
  DensityMediumIcon: DensityMediumIcon__default["default"],
1394
1073
  DensitySmallIcon: DensitySmallIcon__default["default"],
@@ -1427,6 +1106,7 @@ const MRT_Localization_EN = {
1427
1106
  clearSearch: 'Clear search',
1428
1107
  clearSort: 'Clear sort',
1429
1108
  clickToCopy: 'Click to copy',
1109
+ copy: 'Copy',
1430
1110
  collapse: 'Collapse',
1431
1111
  collapseAll: 'Collapse all',
1432
1112
  columnActions: 'Column Actions',
@@ -1641,9 +1321,6 @@ const blankColProps = {
1641
1321
  },
1642
1322
  };
1643
1323
  const getMRT_RowSpacerColumnDef = (tableOptions) => {
1644
- if (!showRowSpacerColumn(tableOptions)) {
1645
- return null;
1646
- }
1647
1324
  return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumnProps({
1648
1325
  id: 'mrt-row-spacer',
1649
1326
  size: 0,
@@ -1651,21 +1328,10 @@ const getMRT_RowSpacerColumnDef = (tableOptions) => {
1651
1328
  })), { grow: true }), MRT_DefaultDisplayColumn), { muiTableBodyCellProps: blankColProps, muiTableFooterCellProps: blankColProps, muiTableHeadCellProps: blankColProps });
1652
1329
  };
1653
1330
 
1654
- const getMRT_DisplayColumns = (tableOptions) => {
1655
- return [
1656
- getMRT_RowNumbersColumnDef(tableOptions),
1657
- getMRT_RowSelectColumnDef(tableOptions),
1658
- getMRT_RowExpandColumnDef(tableOptions),
1659
- getMRT_RowActionsColumnDef(tableOptions),
1660
- getMRT_RowDragColumnDef(tableOptions),
1661
- getMRT_RowPinningColumnDef(tableOptions),
1662
- getMRT_RowSpacerColumnDef(tableOptions),
1663
- ].filter(Boolean);
1664
- };
1665
-
1666
1331
  const useMRT_Effects = (table) => {
1667
1332
  const { getIsSomeRowsPinned, getPrePaginationRowModel, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
1668
- const { density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
1333
+ const { columnOrder, density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
1334
+ const totalColumnCount = table.options.columns.length;
1669
1335
  const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
1670
1336
  const rerender = react.useReducer(() => ({}), {})[1];
1671
1337
  const isMounted = react.useRef(false);
@@ -1729,10 +1395,22 @@ const useMRT_Effects = (table) => {
1729
1395
  }, 150);
1730
1396
  }
1731
1397
  }, [density]);
1398
+ //recalculate column order when columns change or features are toggled on/off
1399
+ react.useEffect(() => {
1400
+ if (totalColumnCount !== columnOrder.length) {
1401
+ table.setColumnOrder(getDefaultColumnOrderIds(table.options));
1402
+ }
1403
+ }, [totalColumnCount]);
1732
1404
  };
1733
1405
 
1734
- const useMRT_TableInstance = (_tableOptions) => {
1735
- 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;
1406
+ /**
1407
+ * The MRT hook that wraps the TanStack useReactTable hook and adds additional functionality
1408
+ * @param definedTableOptions - table options with proper defaults set
1409
+ * @returns the MRT table instance
1410
+ */
1411
+ const useMRT_TableInstance = (definedTableOptions) => {
1412
+ 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;
1413
+ const actionCellRef = react.useRef(null);
1736
1414
  const bottomToolbarRef = react.useRef(null);
1737
1415
  const editInputRefs = react.useRef({});
1738
1416
  const filterInputRefs = react.useRef({});
@@ -1743,17 +1421,19 @@ const useMRT_TableInstance = (_tableOptions) => {
1743
1421
  const topToolbarRef = react.useRef(null);
1744
1422
  const tableHeadRef = react.useRef(null);
1745
1423
  const tableFooterRef = react.useRef(null);
1424
+ //transform initial state with proper column order
1746
1425
  const initialState = react.useMemo(() => {
1747
1426
  var _a, _b, _c;
1748
- const initState = (_a = _tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
1427
+ const initState = (_a = definedTableOptions.initialState) !== null && _a !== void 0 ? _a : {};
1749
1428
  initState.columnOrder =
1750
- (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(Object.assign(Object.assign({}, _tableOptions), { state: Object.assign(Object.assign({}, _tableOptions.initialState), _tableOptions.state) }));
1751
- initState.globalFilterFn = (_c = _tableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
1429
+ (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(Object.assign(Object.assign({}, definedTableOptions), { state: Object.assign(Object.assign({}, definedTableOptions.initialState), definedTableOptions.state) }));
1430
+ initState.globalFilterFn = (_c = definedTableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
1752
1431
  return initState;
1753
1432
  }, []);
1754
- _tableOptions.initialState = initialState;
1755
- const [creatingRow, _setCreatingRow] = react.useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
1756
- const [columnFilterFns, setColumnFilterFns] = react.useState(() => Object.assign({}, ...getAllLeafColumnDefs(_tableOptions.columns).map((col) => {
1433
+ definedTableOptions.initialState = initialState;
1434
+ const [actionCell, setActionCell] = react.useState((_a = initialState.actionCell) !== null && _a !== void 0 ? _a : null);
1435
+ const [creatingRow, _setCreatingRow] = react.useState((_b = initialState.creatingRow) !== null && _b !== void 0 ? _b : null);
1436
+ const [columnFilterFns, setColumnFilterFns] = react.useState(() => Object.assign({}, ...getAllLeafColumnDefs(definedTableOptions.columns).map((col) => {
1757
1437
  var _a, _b, _c, _d;
1758
1438
  return ({
1759
1439
  [getColumnId(col)]: col.filterFn instanceof Function
@@ -1761,24 +1441,25 @@ const useMRT_TableInstance = (_tableOptions) => {
1761
1441
  : (_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),
1762
1442
  });
1763
1443
  })));
1764
- const [columnOrder, onColumnOrderChange] = react.useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
1765
- const [columnSizingInfo, onColumnSizingInfoChange] = react.useState((_c = initialState.columnSizingInfo) !== null && _c !== void 0 ? _c : {});
1766
- const [density, setDensity] = react.useState((_d = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _d !== void 0 ? _d : 'comfortable');
1767
- const [draggingColumn, setDraggingColumn] = react.useState((_e = initialState.draggingColumn) !== null && _e !== void 0 ? _e : null);
1768
- const [draggingRow, setDraggingRow] = react.useState((_f = initialState.draggingRow) !== null && _f !== void 0 ? _f : null);
1769
- const [editingCell, setEditingCell] = react.useState((_g = initialState.editingCell) !== null && _g !== void 0 ? _g : null);
1770
- const [editingRow, setEditingRow] = react.useState((_h = initialState.editingRow) !== null && _h !== void 0 ? _h : null);
1771
- const [globalFilterFn, setGlobalFilterFn] = react.useState((_j = initialState.globalFilterFn) !== null && _j !== void 0 ? _j : 'fuzzy');
1772
- const [grouping, onGroupingChange] = react.useState((_k = initialState.grouping) !== null && _k !== void 0 ? _k : []);
1773
- const [hoveredColumn, setHoveredColumn] = react.useState((_l = initialState.hoveredColumn) !== null && _l !== void 0 ? _l : null);
1774
- const [hoveredRow, setHoveredRow] = react.useState((_m = initialState.hoveredRow) !== null && _m !== void 0 ? _m : null);
1775
- const [isFullScreen, setIsFullScreen] = react.useState((_o = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _o !== void 0 ? _o : false);
1776
- const [pagination, onPaginationChange] = react.useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _p !== void 0 ? _p : { pageIndex: 0, pageSize: 10 });
1777
- const [showAlertBanner, setShowAlertBanner] = react.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _q !== void 0 ? _q : false);
1778
- const [showColumnFilters, setShowColumnFilters] = react.useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _r !== void 0 ? _r : false);
1779
- const [showGlobalFilter, setShowGlobalFilter] = react.useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _s !== void 0 ? _s : false);
1780
- const [showToolbarDropZone, setShowToolbarDropZone] = react.useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _t !== void 0 ? _t : false);
1781
- _tableOptions.state = Object.assign({ columnFilterFns,
1444
+ const [columnOrder, onColumnOrderChange] = react.useState((_c = initialState.columnOrder) !== null && _c !== void 0 ? _c : []);
1445
+ const [columnSizingInfo, onColumnSizingInfoChange] = react.useState((_d = initialState.columnSizingInfo) !== null && _d !== void 0 ? _d : {});
1446
+ const [density, setDensity] = react.useState((_e = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _e !== void 0 ? _e : 'comfortable');
1447
+ const [draggingColumn, setDraggingColumn] = react.useState((_f = initialState.draggingColumn) !== null && _f !== void 0 ? _f : null);
1448
+ const [draggingRow, setDraggingRow] = react.useState((_g = initialState.draggingRow) !== null && _g !== void 0 ? _g : null);
1449
+ const [editingCell, setEditingCell] = react.useState((_h = initialState.editingCell) !== null && _h !== void 0 ? _h : null);
1450
+ const [editingRow, setEditingRow] = react.useState((_j = initialState.editingRow) !== null && _j !== void 0 ? _j : null);
1451
+ const [globalFilterFn, setGlobalFilterFn] = react.useState((_k = initialState.globalFilterFn) !== null && _k !== void 0 ? _k : 'fuzzy');
1452
+ const [grouping, onGroupingChange] = react.useState((_l = initialState.grouping) !== null && _l !== void 0 ? _l : []);
1453
+ const [hoveredColumn, setHoveredColumn] = react.useState((_m = initialState.hoveredColumn) !== null && _m !== void 0 ? _m : null);
1454
+ const [hoveredRow, setHoveredRow] = react.useState((_o = initialState.hoveredRow) !== null && _o !== void 0 ? _o : null);
1455
+ const [isFullScreen, setIsFullScreen] = react.useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _p !== void 0 ? _p : false);
1456
+ const [pagination, onPaginationChange] = react.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _q !== void 0 ? _q : { pageIndex: 0, pageSize: 10 });
1457
+ const [showAlertBanner, setShowAlertBanner] = react.useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _r !== void 0 ? _r : false);
1458
+ const [showColumnFilters, setShowColumnFilters] = react.useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _s !== void 0 ? _s : false);
1459
+ const [showGlobalFilter, setShowGlobalFilter] = react.useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _t !== void 0 ? _t : false);
1460
+ const [showToolbarDropZone, setShowToolbarDropZone] = react.useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _u !== void 0 ? _u : false);
1461
+ definedTableOptions.state = Object.assign({ actionCell,
1462
+ columnFilterFns,
1782
1463
  columnOrder,
1783
1464
  columnSizingInfo,
1784
1465
  creatingRow,
@@ -1796,90 +1477,110 @@ const useMRT_TableInstance = (_tableOptions) => {
1796
1477
  showAlertBanner,
1797
1478
  showColumnFilters,
1798
1479
  showGlobalFilter,
1799
- showToolbarDropZone }, _tableOptions.state);
1800
- const tableOptions = _tableOptions;
1480
+ showToolbarDropZone }, definedTableOptions.state);
1481
+ //The table options now include all state needed to help determine column visibility and order logic
1482
+ const statefulTableOptions = definedTableOptions;
1801
1483
  //don't recompute columnDefs while resizing column or dragging column/row
1802
1484
  const columnDefsRef = react.useRef([]);
1803
- tableOptions.columns =
1804
- tableOptions.state.columnSizingInfo.isResizingColumn ||
1805
- tableOptions.state.draggingColumn ||
1806
- tableOptions.state.draggingRow
1485
+ statefulTableOptions.columns =
1486
+ statefulTableOptions.state.columnSizingInfo.isResizingColumn ||
1487
+ statefulTableOptions.state.draggingColumn ||
1488
+ statefulTableOptions.state.draggingRow
1807
1489
  ? columnDefsRef.current
1808
1490
  : prepareColumns({
1809
1491
  columnDefs: [
1810
- ...getMRT_DisplayColumns(tableOptions),
1811
- ...tableOptions.columns,
1492
+ ...[
1493
+ showRowPinningColumn(statefulTableOptions) &&
1494
+ getMRT_RowPinningColumnDef(statefulTableOptions),
1495
+ showRowDragColumn(statefulTableOptions) &&
1496
+ getMRT_RowDragColumnDef(statefulTableOptions),
1497
+ showRowActionsColumn(statefulTableOptions) &&
1498
+ getMRT_RowActionsColumnDef(statefulTableOptions),
1499
+ showRowExpandColumn(statefulTableOptions) &&
1500
+ getMRT_RowExpandColumnDef(statefulTableOptions),
1501
+ showRowSelectionColumn(statefulTableOptions) &&
1502
+ getMRT_RowSelectColumnDef(statefulTableOptions),
1503
+ showRowNumbersColumn(statefulTableOptions) &&
1504
+ getMRT_RowNumbersColumnDef(statefulTableOptions),
1505
+ ].filter(Boolean),
1506
+ ...statefulTableOptions.columns,
1507
+ ...[
1508
+ showRowSpacerColumn(statefulTableOptions) &&
1509
+ getMRT_RowSpacerColumnDef(statefulTableOptions),
1510
+ ].filter(Boolean),
1812
1511
  ],
1813
- tableOptions,
1512
+ tableOptions: statefulTableOptions,
1814
1513
  });
1815
- columnDefsRef.current = tableOptions.columns;
1816
- tableOptions.data = react.useMemo(() => (tableOptions.state.isLoading || tableOptions.state.showSkeletons) &&
1817
- !tableOptions.data.length
1514
+ columnDefsRef.current = statefulTableOptions.columns;
1515
+ //if loading, generate blank rows to show skeleton loaders
1516
+ statefulTableOptions.data = react.useMemo(() => (statefulTableOptions.state.isLoading ||
1517
+ statefulTableOptions.state.showSkeletons) &&
1518
+ !statefulTableOptions.data.length
1818
1519
  ? [
1819
- ...Array(Math.min(tableOptions.state.pagination.pageSize, 20)).fill(null),
1820
- ].map(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => ({
1520
+ ...Array(Math.min(statefulTableOptions.state.pagination.pageSize, 20)).fill(null),
1521
+ ].map(() => Object.assign({}, ...getAllLeafColumnDefs(statefulTableOptions.columns).map((col) => ({
1821
1522
  [getColumnId(col)]: null,
1822
1523
  }))))
1823
- : tableOptions.data, [
1824
- tableOptions.data,
1825
- tableOptions.state.isLoading,
1826
- tableOptions.state.showSkeletons,
1524
+ : statefulTableOptions.data, [
1525
+ statefulTableOptions.data,
1526
+ statefulTableOptions.state.isLoading,
1527
+ statefulTableOptions.state.showSkeletons,
1827
1528
  ]);
1828
1529
  //@ts-ignore
1829
1530
  const table = reactTable.useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
1830
1531
  onColumnSizingInfoChange,
1831
1532
  onGroupingChange,
1832
- onPaginationChange }, tableOptions), { globalFilterFn: (_u = tableOptions.filterFns) === null || _u === void 0 ? void 0 : _u[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1833
- //@ts-ignore
1533
+ onPaginationChange }, statefulTableOptions), { globalFilterFn: (_v = statefulTableOptions.filterFns) === null || _v === void 0 ? void 0 : _v[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1834
1534
  table.refs = {
1835
- //@ts-ignore
1535
+ actionCellRef,
1836
1536
  bottomToolbarRef,
1837
1537
  editInputRefs,
1838
1538
  filterInputRefs,
1839
- //@ts-ignore
1840
1539
  searchInputRef,
1841
- //@ts-ignore
1842
1540
  tableContainerRef,
1843
- //@ts-ignore
1844
1541
  tableFooterRef,
1845
1542
  tableHeadCellRefs,
1846
- //@ts-ignore
1847
1543
  tableHeadRef,
1848
- //@ts-ignore
1849
1544
  tablePaperRef,
1850
- //@ts-ignore
1851
1545
  topToolbarRef,
1852
1546
  };
1547
+ table.setActionCell =
1548
+ (_w = statefulTableOptions.onActionCellChange) !== null && _w !== void 0 ? _w : setActionCell;
1853
1549
  table.setCreatingRow = (row) => {
1854
1550
  var _a, _b;
1855
1551
  let _row = row;
1856
1552
  if (row === true) {
1857
1553
  _row = createRow(table);
1858
1554
  }
1859
- (_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);
1555
+ (_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);
1860
1556
  };
1861
1557
  table.setColumnFilterFns =
1862
- (_v = tableOptions.onColumnFilterFnsChange) !== null && _v !== void 0 ? _v : setColumnFilterFns;
1863
- table.setDensity = (_w = tableOptions.onDensityChange) !== null && _w !== void 0 ? _w : setDensity;
1558
+ (_x = statefulTableOptions.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns;
1559
+ table.setDensity = (_y = statefulTableOptions.onDensityChange) !== null && _y !== void 0 ? _y : setDensity;
1864
1560
  table.setDraggingColumn =
1865
- (_x = tableOptions.onDraggingColumnChange) !== null && _x !== void 0 ? _x : setDraggingColumn;
1866
- table.setDraggingRow = (_y = tableOptions.onDraggingRowChange) !== null && _y !== void 0 ? _y : setDraggingRow;
1867
- table.setEditingCell = (_z = tableOptions.onEditingCellChange) !== null && _z !== void 0 ? _z : setEditingCell;
1868
- table.setEditingRow = (_0 = tableOptions.onEditingRowChange) !== null && _0 !== void 0 ? _0 : setEditingRow;
1561
+ (_z = statefulTableOptions.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn;
1562
+ table.setDraggingRow =
1563
+ (_0 = statefulTableOptions.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow;
1564
+ table.setEditingCell =
1565
+ (_1 = statefulTableOptions.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell;
1566
+ table.setEditingRow =
1567
+ (_2 = statefulTableOptions.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow;
1869
1568
  table.setGlobalFilterFn =
1870
- (_1 = tableOptions.onGlobalFilterFnChange) !== null && _1 !== void 0 ? _1 : setGlobalFilterFn;
1569
+ (_3 = statefulTableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
1871
1570
  table.setHoveredColumn =
1872
- (_2 = tableOptions.onHoveredColumnChange) !== null && _2 !== void 0 ? _2 : setHoveredColumn;
1873
- table.setHoveredRow = (_3 = tableOptions.onHoveredRowChange) !== null && _3 !== void 0 ? _3 : setHoveredRow;
1874
- table.setIsFullScreen = (_4 = tableOptions.onIsFullScreenChange) !== null && _4 !== void 0 ? _4 : setIsFullScreen;
1571
+ (_4 = statefulTableOptions.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn;
1572
+ table.setHoveredRow =
1573
+ (_5 = statefulTableOptions.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow;
1574
+ table.setIsFullScreen =
1575
+ (_6 = statefulTableOptions.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen;
1875
1576
  table.setShowAlertBanner =
1876
- (_5 = tableOptions.onShowAlertBannerChange) !== null && _5 !== void 0 ? _5 : setShowAlertBanner;
1577
+ (_7 = statefulTableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
1877
1578
  table.setShowColumnFilters =
1878
- (_6 = tableOptions.onShowColumnFiltersChange) !== null && _6 !== void 0 ? _6 : setShowColumnFilters;
1579
+ (_8 = statefulTableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
1879
1580
  table.setShowGlobalFilter =
1880
- (_7 = tableOptions.onShowGlobalFilterChange) !== null && _7 !== void 0 ? _7 : setShowGlobalFilter;
1581
+ (_9 = statefulTableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
1881
1582
  table.setShowToolbarDropZone =
1882
- (_8 = tableOptions.onShowToolbarDropZoneChange) !== null && _8 !== void 0 ? _8 : setShowToolbarDropZone;
1583
+ (_10 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
1883
1584
  useMRT_Effects(table);
1884
1585
  return table;
1885
1586
  };
@@ -2148,7 +1849,7 @@ const MRT_CopyButton = (_a) => {
2148
1849
  row,
2149
1850
  table,
2150
1851
  })), rest);
2151
- return (jsxRuntime.jsx(Tooltip__default["default"], 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: jsxRuntime.jsx(Button__default["default"], 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 })) })));
1852
+ return (jsxRuntime.jsx(Tooltip__default["default"], 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: jsxRuntime.jsx(Button__default["default"], 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 })) })));
2152
1853
  };
2153
1854
 
2154
1855
  const MRT_EditCellTextField = (_a) => {
@@ -2249,10 +1950,10 @@ const MRT_EditCellTextField = (_a) => {
2249
1950
 
2250
1951
  const MRT_TableBodyCell = (_a) => {
2251
1952
  var _b, _c, _d, _e, _f;
2252
- var { cell, measureElement, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "measureElement", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
1953
+ var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
2253
1954
  const theme = styles.useTheme();
2254
- const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableEditing, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
2255
- const { columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
1955
+ const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
1956
+ const { actionCell, columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
2256
1957
  const { column, row } = cell;
2257
1958
  const { columnDef } = column;
2258
1959
  const { columnDefType } = columnDef;
@@ -2325,9 +2026,7 @@ const MRT_TableBodyCell = (_a) => {
2325
2026
  const isColumnPinned = enableColumnPinning &&
2326
2027
  columnDef.columnDefType !== 'group' &&
2327
2028
  column.getIsPinned();
2328
- const isEditable = !cell.getIsPlaceholder() &&
2329
- parseFromValuesOrFunc(enableEditing, row) &&
2330
- parseFromValuesOrFunc(columnDef.enableEditing, row) !== false;
2029
+ const isEditable = isCellEditable({ cell, table });
2331
2030
  const isEditing = isEditable &&
2332
2031
  !['custom', 'modal'].includes(editDisplayMode) &&
2333
2032
  (editDisplayMode === 'table' ||
@@ -2335,20 +2034,20 @@ const MRT_TableBodyCell = (_a) => {
2335
2034
  (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id) &&
2336
2035
  !row.getIsGrouped();
2337
2036
  const isCreating = isEditable && createDisplayMode === 'row' && (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
2037
+ const showClickToCopyButton = (parseFromValuesOrFunc(enableClickToCopy, cell) === true ||
2038
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) === true) &&
2039
+ !['context-menu', false].includes(
2040
+ // @ts-ignore
2041
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell));
2042
+ const isRightClickable = parseFromValuesOrFunc(enableCellActions, cell);
2043
+ const cellValueProps = {
2044
+ cell,
2045
+ table,
2046
+ };
2338
2047
  const handleDoubleClick = (event) => {
2339
2048
  var _a;
2340
2049
  (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDoubleClick) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2341
- if (isEditable && editDisplayMode === 'cell') {
2342
- setEditingCell(cell);
2343
- queueMicrotask(() => {
2344
- var _a;
2345
- const textField = editInputRefs.current[column.id];
2346
- if (textField) {
2347
- textField.focus();
2348
- (_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
2349
- }
2350
- });
2351
- }
2050
+ openEditingCell({ cell, table });
2352
2051
  };
2353
2052
  const handleDragEnter = (e) => {
2354
2053
  var _a;
@@ -2360,22 +2059,29 @@ const MRT_TableBodyCell = (_a) => {
2360
2059
  setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
2361
2060
  }
2362
2061
  };
2363
- const cellValueProps = {
2364
- cell,
2365
- table,
2062
+ const handleContextMenu = (e) => {
2063
+ var _a;
2064
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onContextMenu) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
2065
+ if (isRightClickable) {
2066
+ e.preventDefault();
2067
+ table.setActionCell(cell);
2068
+ table.refs.actionCellRef.current = e.currentTarget;
2069
+ }
2366
2070
  };
2367
- return (jsxRuntime.jsx(TableCell__default["default"], Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, ref: (node) => {
2368
- if (node) {
2369
- measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
2370
- }
2371
- } }, tableCellProps, { onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
2372
- outline: (editDisplayMode === 'cell' && isEditable) ||
2071
+ return (jsxRuntime.jsx(TableCell__default["default"], 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': {
2072
+ outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
2073
+ (editDisplayMode === 'cell' && isEditable) ||
2373
2074
  (editDisplayMode === 'table' && (isCreating || isEditing))
2374
2075
  ? `1px solid ${theme.palette.grey[500]}`
2375
2076
  : undefined,
2376
- outlineOffset: '-1px',
2377
2077
  textOverflow: 'clip',
2378
- }, alignItems: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'center' : undefined, cursor: isEditable && editDisplayMode === 'cell' ? 'pointer' : 'inherit', overflow: 'hidden', p: density === 'compact'
2078
+ }, alignItems: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'center' : undefined, cursor: isRightClickable
2079
+ ? 'context-menu'
2080
+ : isEditable && editDisplayMode === 'cell'
2081
+ ? 'pointer'
2082
+ : 'inherit', outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id
2083
+ ? `1px solid ${theme.palette.grey[500]}`
2084
+ : undefined, outlineOffset: '-1px', overflow: 'hidden', p: density === 'compact'
2379
2085
  ? columnDefType === 'display'
2380
2086
  ? '0 0.5rem'
2381
2087
  : '0.5rem'
@@ -2400,8 +2106,7 @@ const MRT_TableBodyCell = (_a) => {
2400
2106
  rowRef,
2401
2107
  staticRowIndex,
2402
2108
  table,
2403
- })) : isCreating || isEditing ? (jsxRuntime.jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
2404
- columnDef.enableClickToCopy !== false ? (jsxRuntime.jsx(MRT_CopyButton, { cell: cell, table: table, children: jsxRuntime.jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps)) })) : (jsxRuntime.jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps))), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
2109
+ })) : isCreating || isEditing ? (jsxRuntime.jsx(MRT_EditCellTextField, { cell: cell, table: table })) : showClickToCopyButton && columnDef.enableClickToCopy !== false ? (jsxRuntime.jsx(MRT_CopyButton, { cell: cell, table: table, children: jsxRuntime.jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps)) })) : (jsxRuntime.jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps))), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
2405
2110
  };
2406
2111
  const Memo_MRT_TableBodyCell = react.memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
2407
2112
 
@@ -2524,9 +2229,6 @@ const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVi
2524
2229
  }
2525
2230
  const props = {
2526
2231
  cell,
2527
- measureElement: !isDraggingRow && !isHoveredRow
2528
- ? columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement
2529
- : undefined,
2530
2232
  numRows,
2531
2233
  rowRef,
2532
2234
  staticColumnIndex,
@@ -2620,89 +2322,426 @@ const MRT_TableBody = (_a) => {
2620
2322
  return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
2621
2323
  }) })))] }));
2622
2324
  };
2623
- const Memo_MRT_TableBody = react.memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
2325
+ const Memo_MRT_TableBody = react.memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
2326
+
2327
+ const MRT_TableFooterCell = (_a) => {
2328
+ var _b, _c, _d;
2329
+ var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
2330
+ const theme = styles.useTheme();
2331
+ const { getState, options: { enableColumnPinning, muiTableFooterCellProps }, } = table;
2332
+ const { density } = getState();
2333
+ const { column } = footer;
2334
+ const { columnDef } = column;
2335
+ const { columnDefType } = columnDef;
2336
+ const isColumnPinned = enableColumnPinning &&
2337
+ columnDef.columnDefType !== 'group' &&
2338
+ column.getIsPinned();
2339
+ const args = { column, table };
2340
+ const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
2341
+ return (jsxRuntime.jsx(TableCell__default["default"], Object.assign({ align: columnDefType === 'group'
2342
+ ? 'center'
2343
+ : theme.direction === 'rtl'
2344
+ ? 'right'
2345
+ : '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'
2346
+ ? '0.5rem'
2347
+ : density === 'comfortable'
2348
+ ? '1rem'
2349
+ : '1.5rem', verticalAlign: 'top' }, getCommonMRTCellStyles({
2350
+ column,
2351
+ header: footer,
2352
+ table,
2353
+ tableCellProps,
2354
+ theme,
2355
+ })), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (footer.isPlaceholder
2356
+ ? null
2357
+ : (_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
2358
+ column,
2359
+ footer,
2360
+ table,
2361
+ })) !== null && _c !== void 0 ? _c : columnDef.footer) !== null && _d !== void 0 ? _d : null) })));
2362
+ };
2363
+
2364
+ const MRT_TableFooterRow = (_a) => {
2365
+ var _b;
2366
+ var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
2367
+ const { options: { layoutMode, muiTableFooterRowProps }, } = table;
2368
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2369
+ // if no content in row, skip row
2370
+ if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
2371
+ !!header.column.columnDef.footer) ||
2372
+ header.column.columnDef.Footer)))
2373
+ return null;
2374
+ const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterRowProps, {
2375
+ footerGroup,
2376
+ table,
2377
+ })), rest);
2378
+ return (jsxRuntime.jsxs(TableRow__default["default"], 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 ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter, staticColumnIndex) => {
2379
+ let footer = footerOrVirtualFooter;
2380
+ if (columnVirtualizer) {
2381
+ staticColumnIndex = footerOrVirtualFooter
2382
+ .index;
2383
+ footer = footerGroup.headers[staticColumnIndex];
2384
+ }
2385
+ return footer ? (jsxRuntime.jsx(MRT_TableFooterCell, { footer: footer, staticColumnIndex: staticColumnIndex, table: table }, footer.id)) : null;
2386
+ }), virtualPaddingRight ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
2387
+ };
2388
+
2389
+ const MRT_TableFooter = (_a) => {
2390
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2391
+ const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
2392
+ const { isFullScreen } = getState();
2393
+ const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
2394
+ table,
2395
+ })), rest);
2396
+ const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
2397
+ return (jsxRuntime.jsx(TableFooter__default["default"], Object.assign({}, tableFooterProps, { ref: (ref) => {
2398
+ tableFooterRef.current = ref;
2399
+ if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
2400
+ // @ts-ignore
2401
+ tableFooterProps.ref.current = ref;
2402
+ }
2403
+ }, 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
2404
+ ? theme.palette.mode === 'light'
2405
+ ? `1px solid ${theme.palette.grey[300]}`
2406
+ : `1px solid ${theme.palette.grey[700]}`
2407
+ : undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsxRuntime.jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
2408
+ };
2409
+
2410
+ const mrtFilterOptions = (localization) => [
2411
+ {
2412
+ divider: false,
2413
+ label: localization.filterFuzzy,
2414
+ option: 'fuzzy',
2415
+ symbol: '≈',
2416
+ },
2417
+ {
2418
+ divider: false,
2419
+ label: localization.filterContains,
2420
+ option: 'contains',
2421
+ symbol: '*',
2422
+ },
2423
+ {
2424
+ divider: false,
2425
+ label: localization.filterStartsWith,
2426
+ option: 'startsWith',
2427
+ symbol: 'a',
2428
+ },
2429
+ {
2430
+ divider: true,
2431
+ label: localization.filterEndsWith,
2432
+ option: 'endsWith',
2433
+ symbol: 'z',
2434
+ },
2435
+ {
2436
+ divider: false,
2437
+ label: localization.filterEquals,
2438
+ option: 'equals',
2439
+ symbol: '=',
2440
+ },
2441
+ {
2442
+ divider: true,
2443
+ label: localization.filterNotEquals,
2444
+ option: 'notEquals',
2445
+ symbol: '≠',
2446
+ },
2447
+ {
2448
+ divider: false,
2449
+ label: localization.filterBetween,
2450
+ option: 'between',
2451
+ symbol: '⇿',
2452
+ },
2453
+ {
2454
+ divider: true,
2455
+ label: localization.filterBetweenInclusive,
2456
+ option: 'betweenInclusive',
2457
+ symbol: '⬌',
2458
+ },
2459
+ {
2460
+ divider: false,
2461
+ label: localization.filterGreaterThan,
2462
+ option: 'greaterThan',
2463
+ symbol: '>',
2464
+ },
2465
+ {
2466
+ divider: false,
2467
+ label: localization.filterGreaterThanOrEqualTo,
2468
+ option: 'greaterThanOrEqualTo',
2469
+ symbol: '≥',
2470
+ },
2471
+ {
2472
+ divider: false,
2473
+ label: localization.filterLessThan,
2474
+ option: 'lessThan',
2475
+ symbol: '<',
2476
+ },
2477
+ {
2478
+ divider: true,
2479
+ label: localization.filterLessThanOrEqualTo,
2480
+ option: 'lessThanOrEqualTo',
2481
+ symbol: '≤',
2482
+ },
2483
+ {
2484
+ divider: false,
2485
+ label: localization.filterEmpty,
2486
+ option: 'empty',
2487
+ symbol: '∅',
2488
+ },
2489
+ {
2490
+ divider: false,
2491
+ label: localization.filterNotEmpty,
2492
+ option: 'notEmpty',
2493
+ symbol: '!∅',
2494
+ },
2495
+ ];
2496
+ const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
2497
+ const emptyModes = ['empty', 'notEmpty'];
2498
+ const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
2499
+ const rangeVariants = ['range-slider', 'date-range', 'datetime-range', 'range'];
2500
+ const MRT_FilterOptionMenu = (_a) => {
2501
+ var _b, _c, _d, _e;
2502
+ var { anchorEl, header, onSelect, setAnchorEl, setFilterValue, table } = _a, rest = __rest(_a, ["anchorEl", "header", "onSelect", "setAnchorEl", "setFilterValue", "table"]);
2503
+ const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
2504
+ const { density, globalFilterFn } = getState();
2505
+ const { column } = header !== null && header !== void 0 ? header : {};
2506
+ const { columnDef } = column !== null && column !== void 0 ? column : {};
2507
+ const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
2508
+ let allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
2509
+ if (rangeVariants.includes(columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant)) {
2510
+ allowedColumnFilterOptions = [
2511
+ ...rangeModes,
2512
+ ...(allowedColumnFilterOptions !== null && allowedColumnFilterOptions !== void 0 ? allowedColumnFilterOptions : []),
2513
+ ].filter((option) => rangeModes.includes(option));
2514
+ }
2515
+ const internalFilterOptions = react.useMemo(() => mrtFilterOptions(localization).filter((filterOption) => columnDef
2516
+ ? allowedColumnFilterOptions === undefined ||
2517
+ (allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.includes(filterOption.option))
2518
+ : (!globalFilterModeOptions ||
2519
+ globalFilterModeOptions.includes(filterOption.option)) &&
2520
+ ['contains', 'fuzzy', 'startsWith'].includes(filterOption.option)), []);
2521
+ const handleSelectFilterMode = (option) => {
2522
+ var _a, _b;
2523
+ const prevFilterMode = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef._filterFn) !== null && _a !== void 0 ? _a : '';
2524
+ if (!header || !column) {
2525
+ // global filter mode
2526
+ setGlobalFilterFn(option);
2527
+ }
2528
+ else if (option !== prevFilterMode) {
2529
+ // column filter mode
2530
+ setColumnFilterFns((prev) => (Object.assign(Object.assign({}, prev), { [header.id]: option })));
2531
+ // reset filter value and/or perform new filter render
2532
+ if (emptyModes.includes(option)) {
2533
+ // will now be empty/notEmpty filter mode
2534
+ if (currentFilterValue !== ' ' &&
2535
+ !emptyModes.includes(prevFilterMode)) {
2536
+ column.setFilterValue(' ');
2537
+ }
2538
+ else if (currentFilterValue) {
2539
+ column.setFilterValue(currentFilterValue); // perform new filter render
2540
+ }
2541
+ }
2542
+ else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
2543
+ arrModes.includes(option)) {
2544
+ // will now be array filter mode
2545
+ if (currentFilterValue instanceof String ||
2546
+ (currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.length)) {
2547
+ column.setFilterValue([]);
2548
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue([]);
2549
+ }
2550
+ else if (currentFilterValue) {
2551
+ column.setFilterValue(currentFilterValue); // perform new filter render
2552
+ }
2553
+ }
2554
+ else if (((_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === null || _b === void 0 ? void 0 : _b.includes('range')) ||
2555
+ rangeModes.includes(option)) {
2556
+ // will now be range filter mode
2557
+ if (!Array.isArray(currentFilterValue) ||
2558
+ (!(currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.every((v) => v === '')) &&
2559
+ !rangeModes.includes(prevFilterMode))) {
2560
+ column.setFilterValue(['', '']);
2561
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
2562
+ }
2563
+ else {
2564
+ column.setFilterValue(currentFilterValue); // perform new filter render
2565
+ }
2566
+ }
2567
+ else {
2568
+ // will now be single value filter mode
2569
+ if (Array.isArray(currentFilterValue)) {
2570
+ column.setFilterValue('');
2571
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
2572
+ }
2573
+ else if (currentFilterValue === ' ' &&
2574
+ emptyModes.includes(prevFilterMode)) {
2575
+ column.setFilterValue(undefined);
2576
+ }
2577
+ else {
2578
+ column.setFilterValue(currentFilterValue); // perform new filter render
2579
+ }
2580
+ }
2581
+ }
2582
+ setAnchorEl(null);
2583
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect();
2584
+ };
2585
+ const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
2586
+ const theme = styles.useTheme();
2587
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
2588
+ return (jsxRuntime.jsx(Menu__default["default"], Object.assign({ MenuListProps: {
2589
+ dense: density === 'compact',
2590
+ sx: {
2591
+ backgroundColor: menuBackgroundColor,
2592
+ },
2593
+ }, anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_e = (header && column && columnDef
2594
+ ? (_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
2595
+ column: column,
2596
+ internalFilterOptions,
2597
+ onSelectFilterMode: handleSelectFilterMode,
2598
+ table,
2599
+ })) !== null && _d !== void 0 ? _d : renderColumnFilterModeMenuItems === null || renderColumnFilterModeMenuItems === void 0 ? void 0 : renderColumnFilterModeMenuItems({
2600
+ column: column,
2601
+ internalFilterOptions,
2602
+ onSelectFilterMode: handleSelectFilterMode,
2603
+ table,
2604
+ })
2605
+ : renderGlobalFilterModeMenuItems === null || renderGlobalFilterModeMenuItems === void 0 ? void 0 : renderGlobalFilterModeMenuItems({
2606
+ internalFilterOptions,
2607
+ onSelectFilterMode: handleSelectFilterMode,
2608
+ table,
2609
+ }))) !== null && _e !== void 0 ? _e : internalFilterOptions.map(({ divider, label, option, symbol }, index) => (jsxRuntime.jsx(MRT_ActionMenuItem, { divider: divider, icon: symbol, label: label, onClick: () => handleSelectFilterMode(option), selected: option === filterOption, table: table, value: option }, index))) })));
2610
+ };
2624
2611
 
2625
- const MRT_TableFooterCell = (_a) => {
2626
- var _b, _c, _d;
2627
- var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
2628
- const theme = styles.useTheme();
2629
- const { getState, options: { enableColumnPinning, muiTableFooterCellProps }, } = table;
2630
- const { density } = getState();
2631
- const { column } = footer;
2612
+ const MRT_ColumnActionMenu = (_a) => {
2613
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2614
+ var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
2615
+ 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;
2616
+ const { column } = header;
2632
2617
  const { columnDef } = column;
2633
- const { columnDefType } = columnDef;
2634
- const isColumnPinned = enableColumnPinning &&
2635
- columnDef.columnDefType !== 'group' &&
2636
- column.getIsPinned();
2637
- const args = { column, table };
2638
- const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
2639
- return (jsxRuntime.jsx(TableCell__default["default"], Object.assign({ align: columnDefType === 'group'
2640
- ? 'center'
2641
- : theme.direction === 'rtl'
2642
- ? 'right'
2643
- : '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'
2644
- ? '0.5rem'
2645
- : density === 'comfortable'
2646
- ? '1rem'
2647
- : '1.5rem', verticalAlign: 'top' }, getCommonMRTCellStyles({
2618
+ const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
2619
+ const columnFilterValue = column.getFilterValue();
2620
+ const [filterMenuAnchorEl, setFilterMenuAnchorEl] = react.useState(null);
2621
+ const handleClearSort = () => {
2622
+ column.clearSorting();
2623
+ setAnchorEl(null);
2624
+ };
2625
+ const handleSortAsc = () => {
2626
+ column.toggleSorting(false);
2627
+ setAnchorEl(null);
2628
+ };
2629
+ const handleSortDesc = () => {
2630
+ column.toggleSorting(true);
2631
+ setAnchorEl(null);
2632
+ };
2633
+ const handleResetColumnSize = () => {
2634
+ setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
2635
+ column.resetSize();
2636
+ setAnchorEl(null);
2637
+ };
2638
+ const handleHideColumn = () => {
2639
+ column.toggleVisibility(false);
2640
+ setAnchorEl(null);
2641
+ };
2642
+ const handlePinColumn = (pinDirection) => {
2643
+ column.pin(pinDirection);
2644
+ setAnchorEl(null);
2645
+ };
2646
+ const handleGroupByColumn = () => {
2647
+ column.toggleGrouping();
2648
+ setColumnOrder((old) => ['mrt-row-expand', ...old]);
2649
+ setAnchorEl(null);
2650
+ };
2651
+ const handleClearFilter = () => {
2652
+ column.setFilterValue(undefined);
2653
+ setAnchorEl(null);
2654
+ if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
2655
+ setColumnFilterFns((prev) => {
2656
+ var _a;
2657
+ return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
2658
+ });
2659
+ }
2660
+ };
2661
+ const handleFilterByColumn = () => {
2662
+ setShowColumnFilters(true);
2663
+ queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); });
2664
+ setAnchorEl(null);
2665
+ };
2666
+ const handleShowAllColumns = () => {
2667
+ getAllLeafColumns()
2668
+ .filter((col) => col.columnDef.enableHiding !== false)
2669
+ .forEach((col) => col.toggleVisibility(true));
2670
+ setAnchorEl(null);
2671
+ };
2672
+ const handleOpenFilterModeMenu = (event) => {
2673
+ event.stopPropagation();
2674
+ setFilterMenuAnchorEl(event.currentTarget);
2675
+ };
2676
+ const isSelectFilter = !!columnDef.filterSelectOptions;
2677
+ const allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
2678
+ const showFilterModeSubMenu = enableColumnFilterModes &&
2679
+ columnDef.enableColumnFilterModes !== false &&
2680
+ !isSelectFilter &&
2681
+ (allowedColumnFilterOptions === undefined ||
2682
+ !!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
2683
+ const internalColumnMenuItems = [
2684
+ ...(enableSorting && column.getCanSort()
2685
+ ? [
2686
+ enableSortingRemoval !== false && (jsxRuntime.jsx(MRT_ActionMenuItem, { icon: jsxRuntime.jsx(ClearAllIcon, {}), label: localization.clearSort, onClick: handleClearSort, table: table }, 0)),
2687
+ jsxRuntime.jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === 'asc', icon: jsxRuntime.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),
2688
+ jsxRuntime.jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === 'desc', divider: enableColumnFilters || enableGrouping || enableHiding, icon: jsxRuntime.jsx(SortIcon, {}), label: (_d = localization.sortByColumnDesc) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header)), onClick: handleSortDesc, table: table }, 2),
2689
+ ]
2690
+ : []),
2691
+ ...(enableColumnFilters && column.getCanFilter()
2692
+ ? [
2693
+ jsxRuntime.jsx(MRT_ActionMenuItem, { disabled: !columnFilterValue ||
2694
+ (Array.isArray(columnFilterValue) &&
2695
+ !columnFilterValue.filter((value) => value).length), icon: jsxRuntime.jsx(FilterListOffIcon, {}), label: localization.clearFilter, onClick: handleClearFilter, table: table }, 3),
2696
+ columnFilterDisplayMode === 'subheader' && (jsxRuntime.jsx(MRT_ActionMenuItem, { disabled: showColumnFilters && !enableColumnFilterModes, divider: enableGrouping || enableHiding, icon: jsxRuntime.jsx(FilterListIcon, {}), label: (_e = localization.filterByColumn) === null || _e === void 0 ? void 0 : _e.replace('{column}', String(columnDef.header)), onClick: showColumnFilters
2697
+ ? handleOpenFilterModeMenu
2698
+ : handleFilterByColumn, onOpenSubMenu: showFilterModeSubMenu ? handleOpenFilterModeMenu : undefined, table: table }, 4)),
2699
+ showFilterModeSubMenu && (jsxRuntime.jsx(MRT_FilterOptionMenu, { anchorEl: filterMenuAnchorEl, header: header, onSelect: handleFilterByColumn, setAnchorEl: setFilterMenuAnchorEl, table: table }, 5)),
2700
+ ].filter(Boolean)
2701
+ : []),
2702
+ ...(enableGrouping && column.getCanGroup()
2703
+ ? [
2704
+ jsxRuntime.jsx(MRT_ActionMenuItem, { divider: enableColumnPinning, icon: jsxRuntime.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),
2705
+ ]
2706
+ : []),
2707
+ ...(enableColumnPinning && column.getCanPin()
2708
+ ? [
2709
+ jsxRuntime.jsx(MRT_ActionMenuItem, { disabled: column.getIsPinned() === 'left' || !column.getCanPin(), icon: jsxRuntime.jsx(PushPinIcon, { style: { transform: 'rotate(90deg)' } }), label: localization.pinToLeft, onClick: () => handlePinColumn('left'), table: table }, 7),
2710
+ jsxRuntime.jsx(MRT_ActionMenuItem, { disabled: column.getIsPinned() === 'right' || !column.getCanPin(), icon: jsxRuntime.jsx(PushPinIcon, { style: { transform: 'rotate(-90deg)' } }), label: localization.pinToRight, onClick: () => handlePinColumn('right'), table: table }, 8),
2711
+ jsxRuntime.jsx(MRT_ActionMenuItem, { disabled: !column.getIsPinned(), divider: enableHiding, icon: jsxRuntime.jsx(PushPinIcon, {}), label: localization.unpin, onClick: () => handlePinColumn(false), table: table }, 9),
2712
+ ]
2713
+ : []),
2714
+ ...(enableColumnResizing && column.getCanResize()
2715
+ ? [
2716
+ jsxRuntime.jsx(MRT_ActionMenuItem, { disabled: !columnSizing[column.id], icon: jsxRuntime.jsx(RestartAltIcon, {}), label: localization.resetColumnSize, onClick: handleResetColumnSize, table: table }, 10),
2717
+ ]
2718
+ : []),
2719
+ ...(enableHiding
2720
+ ? [
2721
+ jsxRuntime.jsx(MRT_ActionMenuItem, { disabled: !column.getCanHide(), icon: jsxRuntime.jsx(VisibilityOffIcon, {}), label: (_g = localization.hideColumn) === null || _g === void 0 ? void 0 : _g.replace('{column}', String(columnDef.header)), onClick: handleHideColumn, table: table }, 11),
2722
+ jsxRuntime.jsx(MRT_ActionMenuItem, { disabled: !Object.values(columnVisibility).filter((visible) => !visible)
2723
+ .length, icon: jsxRuntime.jsx(ViewColumnIcon, {}), label: (_h = localization.showAllColumns) === null || _h === void 0 ? void 0 : _h.replace('{column}', String(columnDef.header)), onClick: handleShowAllColumns, table: table }, 12),
2724
+ ]
2725
+ : []),
2726
+ ].filter(Boolean);
2727
+ const theme = styles.useTheme();
2728
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
2729
+ return (jsxRuntime.jsx(Menu__default["default"], Object.assign({ MenuListProps: {
2730
+ dense: density === 'compact',
2731
+ sx: {
2732
+ backgroundColor: menuBackgroundColor,
2733
+ },
2734
+ }, 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, {
2735
+ closeMenu: () => setAnchorEl(null),
2648
2736
  column,
2649
- header: footer,
2737
+ internalColumnMenuItems,
2650
2738
  table,
2651
- tableCellProps,
2652
- theme,
2653
- })), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (footer.isPlaceholder
2654
- ? null
2655
- : (_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
2656
- column,
2657
- footer,
2658
- table,
2659
- })) !== null && _c !== void 0 ? _c : columnDef.footer) !== null && _d !== void 0 ? _d : null) })));
2660
- };
2661
-
2662
- const MRT_TableFooterRow = (_a) => {
2663
- var _b;
2664
- var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
2665
- const { options: { layoutMode, muiTableFooterRowProps }, } = table;
2666
- const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2667
- // if no content in row, skip row
2668
- if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
2669
- !!header.column.columnDef.footer) ||
2670
- header.column.columnDef.Footer)))
2671
- return null;
2672
- const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterRowProps, {
2673
- footerGroup,
2674
- table,
2675
- })), rest);
2676
- return (jsxRuntime.jsxs(TableRow__default["default"], 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 ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter, staticColumnIndex) => {
2677
- let footer = footerOrVirtualFooter;
2678
- if (columnVirtualizer) {
2679
- staticColumnIndex = footerOrVirtualFooter
2680
- .index;
2681
- footer = footerGroup.headers[staticColumnIndex];
2682
- }
2683
- return footer ? (jsxRuntime.jsx(MRT_TableFooterCell, { footer: footer, staticColumnIndex: staticColumnIndex, table: table }, footer.id)) : null;
2684
- }), virtualPaddingRight ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
2685
- };
2686
-
2687
- const MRT_TableFooter = (_a) => {
2688
- var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2689
- const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
2690
- const { isFullScreen } = getState();
2691
- const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
2692
- table,
2693
- })), rest);
2694
- const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
2695
- return (jsxRuntime.jsx(TableFooter__default["default"], Object.assign({}, tableFooterProps, { ref: (ref) => {
2696
- tableFooterRef.current = ref;
2697
- if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
2698
- // @ts-ignore
2699
- tableFooterProps.ref.current = ref;
2700
- }
2701
- }, 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
2702
- ? theme.palette.mode === 'light'
2703
- ? `1px solid ${theme.palette.grey[300]}`
2704
- : `1px solid ${theme.palette.grey[700]}`
2705
- : undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsxRuntime.jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
2739
+ })) !== null && _k !== void 0 ? _k : renderColumnActionsMenuItems === null || renderColumnActionsMenuItems === void 0 ? void 0 : renderColumnActionsMenuItems({
2740
+ closeMenu: () => setAnchorEl(null),
2741
+ column,
2742
+ internalColumnMenuItems,
2743
+ table,
2744
+ })) !== null && _l !== void 0 ? _l : internalColumnMenuItems })));
2706
2745
  };
2707
2746
 
2708
2747
  const MRT_TableHeadCellColumnActionsButton = (_a) => {
@@ -3126,7 +3165,7 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
3126
3165
  }, 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: jsxRuntime.jsx(FilterAltIcon, {}) })) }) }) }), jsxRuntime.jsx(Popover__default["default"], { anchorEl: anchorEl, anchorOrigin: {
3127
3166
  horizontal: 'center',
3128
3167
  vertical: 'top',
3129
- }, onClick: (event) => event.stopPropagation(), onClose: (event) => {
3168
+ }, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: (event) => {
3130
3169
  //@ts-ignore
3131
3170
  event.stopPropagation();
3132
3171
  setAnchorEl(null);
@@ -3247,7 +3286,7 @@ const MRT_TableHeadCellSortLabel = (_a) => {
3247
3286
 
3248
3287
  const MRT_TableHeadCell = (_a) => {
3249
3288
  var _b, _c, _d, _f, _g, _h;
3250
- var { header, staticColumnIndex, table } = _a, rest = __rest(_a, ["header", "staticColumnIndex", "table"]);
3289
+ var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
3251
3290
  const theme = styles.useTheme();
3252
3291
  const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
3253
3292
  const { columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
@@ -3324,8 +3363,12 @@ const MRT_TableHeadCell = (_a) => {
3324
3363
  : theme.direction === 'rtl'
3325
3364
  ? 'right'
3326
3365
  : 'left', colSpan: header.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, onDragEnter: handleDragEnter, ref: (node) => {
3366
+ var _a;
3327
3367
  if (node) {
3328
3368
  tableHeadCellRefs.current[column.id] = node;
3369
+ if (columnDefType !== 'group') {
3370
+ (_a = columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(columnVirtualizer, node);
3371
+ }
3329
3372
  }
3330
3373
  } }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
3331
3374
  '.MuiButtonBase-root': {
@@ -3412,7 +3455,7 @@ const MRT_TableHeadRow = (_a) => {
3412
3455
  .index;
3413
3456
  header = headerGroup.headers[staticColumnIndex];
3414
3457
  }
3415
- return header ? (jsxRuntime.jsx(MRT_TableHeadCell, { header: header, staticColumnIndex: staticColumnIndex, table: table }, header.id)) : null;
3458
+ return header ? (jsxRuntime.jsx(MRT_TableHeadCell, { columnVirtualizer: columnVirtualizer, header: header, staticColumnIndex: staticColumnIndex, table: table }, header.id)) : null;
3416
3459
  }), virtualPaddingRight ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
3417
3460
  };
3418
3461
 
@@ -3525,6 +3568,52 @@ const MRT_TableLoadingOverlay = (_a) => {
3525
3568
  }), children: jsxRuntime.jsx(CircularProgress__default["default"], Object.assign({ "aria-label": localization.noRecordsToDisplay, id: "mrt-progress" }, circularProgressProps)) }));
3526
3569
  };
3527
3570
 
3571
+ const MRT_CellActionMenu = (_a) => {
3572
+ var _b, _c;
3573
+ var { table } = _a, rest = __rest(_a, ["table"]);
3574
+ const { getState, options: { editDisplayMode, enableClickToCopy, enableEditing, icons: { ContentCopy, EditIcon }, localization, renderCellActionMenuItems, }, refs: { actionCellRef }, } = table;
3575
+ const { actionCell, density } = getState();
3576
+ const cell = actionCell;
3577
+ const { row } = cell;
3578
+ const { column } = cell;
3579
+ const { columnDef } = column;
3580
+ const theme = styles.useTheme();
3581
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
3582
+ const handleClose = (event) => {
3583
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
3584
+ table.setActionCell(null);
3585
+ actionCellRef.current = null;
3586
+ };
3587
+ const internalMenuItems = [
3588
+ (parseFromValuesOrFunc(enableClickToCopy, cell) === 'context-menu' ||
3589
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) ===
3590
+ 'context-menu') && (jsxRuntime.jsx(MRT_ActionMenuItem, { icon: jsxRuntime.jsx(ContentCopy, {}), label: localization.copy, onClick: (event) => {
3591
+ event.stopPropagation();
3592
+ navigator.clipboard.writeText(cell.getValue());
3593
+ handleClose();
3594
+ }, table: table }, 'mrt-copy')),
3595
+ parseFromValuesOrFunc(enableEditing, row) && editDisplayMode === 'cell' && (jsxRuntime.jsx(MRT_ActionMenuItem, { icon: jsxRuntime.jsx(EditIcon, {}), label: localization.edit, onClick: () => {
3596
+ openEditingCell({ cell, table });
3597
+ handleClose();
3598
+ }, table: table }, 'mrt-edit')),
3599
+ ].filter(Boolean);
3600
+ const renderActionProps = {
3601
+ cell,
3602
+ closeMenu: handleClose,
3603
+ column,
3604
+ internalMenuItems,
3605
+ row,
3606
+ table,
3607
+ };
3608
+ 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);
3609
+ return ((!!(menuItems === null || menuItems === void 0 ? void 0 : menuItems.length) || !!(internalMenuItems === null || internalMenuItems === void 0 ? void 0 : internalMenuItems.length)) && (jsxRuntime.jsx(Menu__default["default"], Object.assign({ MenuListProps: {
3610
+ dense: density === 'compact',
3611
+ sx: {
3612
+ backgroundColor: menuBackgroundColor,
3613
+ },
3614
+ }, 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 }))));
3615
+ };
3616
+
3528
3617
  const MRT_EditRowModal = (_a) => {
3529
3618
  var _b;
3530
3619
  var { open, table } = _a, rest = __rest(_a, ["open", "table"]);
@@ -3569,8 +3658,8 @@ const MRT_EditRowModal = (_a) => {
3569
3658
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? react.useLayoutEffect : react.useEffect;
3570
3659
  const MRT_TableContainer = (_a) => {
3571
3660
  var { table } = _a, rest = __rest(_a, ["table"]);
3572
- const { getState, options: { createDisplayMode, editDisplayMode, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
3573
- const { creatingRow, editingRow, isFullScreen, isLoading, showLoadingOverlay, } = getState();
3661
+ const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
3662
+ const { actionCell, creatingRow, editingRow, isFullScreen, isLoading, showLoadingOverlay, } = getState();
3574
3663
  const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
3575
3664
  const [totalToolbarHeight, setTotalToolbarHeight] = react.useState(0);
3576
3665
  const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableContainerProps, {
@@ -3600,7 +3689,7 @@ const MRT_TableContainer = (_a) => {
3600
3689
  ? `calc(100vh - ${totalToolbarHeight}px)`
3601
3690
  : undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign({ maxHeight: enableStickyHeader
3602
3691
  ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
3603
- : undefined, maxWidth: '100%', overflow: 'auto', position: 'relative' }, parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [loading ? jsxRuntime.jsx(MRT_TableLoadingOverlay, { table: table }) : null, jsxRuntime.jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsxRuntime.jsx(MRT_EditRowModal, { open: true, table: table }))] })));
3692
+ : undefined, maxWidth: '100%', overflow: 'auto', position: 'relative' }, parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [loading ? jsxRuntime.jsx(MRT_TableLoadingOverlay, { table: table }) : null, jsxRuntime.jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsxRuntime.jsx(MRT_EditRowModal, { open: true, table: table })), enableCellActions && actionCell && jsxRuntime.jsx(MRT_CellActionMenu, { table: table })] })));
3604
3693
  };
3605
3694
 
3606
3695
  const MRT_LinearProgressBar = (_a) => {
@@ -3848,7 +3937,7 @@ const MRT_ShowHideColumnsMenu = (_a) => {
3848
3937
  justifyContent: 'space-between',
3849
3938
  p: '0.5rem',
3850
3939
  pt: 0,
3851
- }, children: [enableHiding && (jsxRuntime.jsx(Button__default["default"], { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsxRuntime.jsx(Button__default["default"], { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options)), children: localization.resetOrder })), enableColumnPinning && (jsxRuntime.jsx(Button__default["default"], { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsxRuntime.jsx(Button__default["default"], { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsxRuntime.jsx(Divider__default["default"], {}), allColumns.map((column, index) => (jsxRuntime.jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
3940
+ }, children: [enableHiding && (jsxRuntime.jsx(Button__default["default"], { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsxRuntime.jsx(Button__default["default"], { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), children: localization.resetOrder })), enableColumnPinning && (jsxRuntime.jsx(Button__default["default"], { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsxRuntime.jsx(Button__default["default"], { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsxRuntime.jsx(Divider__default["default"], {}), allColumns.map((column, index) => (jsxRuntime.jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
3852
3941
  };
3853
3942
 
3854
3943
  const MRT_ShowHideColumnsButton = (_a) => {
@@ -4065,6 +4154,7 @@ const MaterialReactTable = (props) => {
4065
4154
  return jsxRuntime.jsx(MRT_TablePaper, { table: table });
4066
4155
  };
4067
4156
 
4157
+ exports.MRT_ActionMenuItem = MRT_ActionMenuItem;
4068
4158
  exports.MRT_AggregationFns = MRT_AggregationFns;
4069
4159
  exports.MRT_BottomToolbar = MRT_BottomToolbar;
4070
4160
  exports.MRT_ColumnActionMenu = MRT_ColumnActionMenu;
@@ -4130,8 +4220,6 @@ exports.MaterialReactTable = MaterialReactTable;
4130
4220
  exports.Memo_MRT_TableBody = Memo_MRT_TableBody;
4131
4221
  exports.Memo_MRT_TableBodyCell = Memo_MRT_TableBodyCell;
4132
4222
  exports.Memo_MRT_TableBodyRow = Memo_MRT_TableBodyRow;
4133
- exports.commonListItemStyles = commonListItemStyles;
4134
- exports.commonMenuItemStyles = commonMenuItemStyles;
4135
4223
  exports.createMRTColumnHelper = createMRTColumnHelper;
4136
4224
  exports.createRow = createRow;
4137
4225
  exports.defaultDisplayColumnProps = defaultDisplayColumnProps;
@@ -4149,7 +4237,9 @@ exports.getIsRowSelected = getIsRowSelected;
4149
4237
  exports.getLeadingDisplayColumnIds = getLeadingDisplayColumnIds;
4150
4238
  exports.getTotalRight = getTotalRight;
4151
4239
  exports.getTrailingDisplayColumnIds = getTrailingDisplayColumnIds;
4240
+ exports.isCellEditable = isCellEditable;
4152
4241
  exports.mrtFilterOptions = mrtFilterOptions;
4242
+ exports.openEditingCell = openEditingCell;
4153
4243
  exports.prepareColumns = prepareColumns;
4154
4244
  exports.rankGlobalFuzzy = rankGlobalFuzzy;
4155
4245
  exports.reorderColumn = reorderColumn;