material-react-table 2.9.2 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/README.md +3 -2
  2. package/dist/index.d.ts +222 -152
  3. package/dist/index.esm.js +906 -769
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +910 -768
  6. package/dist/index.js.map +1 -1
  7. package/locales/ar/index.esm.js +2 -0
  8. package/locales/ar/index.js +2 -0
  9. package/locales/az/index.esm.js +2 -0
  10. package/locales/az/index.js +2 -0
  11. package/locales/bg/index.esm.js +2 -0
  12. package/locales/bg/index.js +2 -0
  13. package/locales/cs/index.esm.js +2 -0
  14. package/locales/cs/index.js +2 -0
  15. package/locales/da/index.esm.js +2 -0
  16. package/locales/da/index.js +2 -0
  17. package/locales/de/index.esm.js +2 -0
  18. package/locales/de/index.js +2 -0
  19. package/locales/en/index.esm.js +2 -0
  20. package/locales/en/index.js +2 -0
  21. package/locales/es/index.esm.js +2 -0
  22. package/locales/es/index.js +2 -0
  23. package/locales/et/index.esm.js +2 -0
  24. package/locales/et/index.js +2 -0
  25. package/locales/fa/index.esm.js +2 -0
  26. package/locales/fa/index.js +2 -0
  27. package/locales/fi/index.esm.js +2 -0
  28. package/locales/fi/index.js +2 -0
  29. package/locales/fr/index.esm.js +2 -0
  30. package/locales/fr/index.js +2 -0
  31. package/locales/he/index.esm.js +2 -0
  32. package/locales/he/index.js +2 -0
  33. package/locales/hu/index.esm.js +2 -0
  34. package/locales/hu/index.js +2 -0
  35. package/locales/hy/index.esm.js +2 -0
  36. package/locales/hy/index.js +2 -0
  37. package/locales/id/index.esm.js +2 -0
  38. package/locales/id/index.js +2 -0
  39. package/locales/it/index.esm.js +2 -0
  40. package/locales/it/index.js +2 -0
  41. package/locales/ja/index.esm.js +2 -0
  42. package/locales/ja/index.js +2 -0
  43. package/locales/ko/index.esm.js +2 -0
  44. package/locales/ko/index.js +2 -0
  45. package/locales/nl/index.esm.js +2 -0
  46. package/locales/nl/index.js +2 -0
  47. package/locales/no/index.esm.js +2 -0
  48. package/locales/no/index.js +2 -0
  49. package/locales/np/index.esm.js +2 -0
  50. package/locales/np/index.js +2 -0
  51. package/locales/pl/index.esm.js +2 -0
  52. package/locales/pl/index.js +2 -0
  53. package/locales/pt/index.esm.js +2 -0
  54. package/locales/pt/index.js +2 -0
  55. package/locales/pt-BR/index.esm.js +2 -0
  56. package/locales/pt-BR/index.js +2 -0
  57. package/locales/ro/index.esm.js +2 -0
  58. package/locales/ro/index.js +2 -0
  59. package/locales/ru/index.esm.js +2 -0
  60. package/locales/ru/index.js +2 -0
  61. package/locales/sk/index.esm.js +2 -0
  62. package/locales/sk/index.js +2 -0
  63. package/locales/sr-Cyrl-RS/index.esm.js +2 -0
  64. package/locales/sr-Cyrl-RS/index.js +2 -0
  65. package/locales/sr-Latn-RS/index.esm.js +2 -0
  66. package/locales/sr-Latn-RS/index.js +2 -0
  67. package/locales/sv/index.esm.js +2 -0
  68. package/locales/sv/index.js +2 -0
  69. package/locales/tr/index.esm.js +2 -0
  70. package/locales/tr/index.js +2 -0
  71. package/locales/uk/index.esm.js +2 -0
  72. package/locales/uk/index.js +2 -0
  73. package/locales/vi/index.esm.js +2 -0
  74. package/locales/vi/index.js +2 -0
  75. package/locales/zh-Hans/index.esm.js +2 -0
  76. package/locales/zh-Hans/index.js +2 -0
  77. package/locales/zh-Hant/index.esm.js +2 -0
  78. package/locales/zh-Hant/index.js +2 -0
  79. package/package.json +20 -20
  80. package/src/components/MaterialReactTable.tsx +3 -3
  81. package/src/components/body/MRT_TableBody.tsx +3 -2
  82. package/src/components/body/MRT_TableBodyCell.tsx +45 -34
  83. package/src/components/body/MRT_TableBodyCellValue.tsx +5 -2
  84. package/src/components/body/MRT_TableBodyRow.tsx +13 -12
  85. package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +4 -3
  86. package/src/components/body/MRT_TableBodyRowPinButton.tsx +3 -2
  87. package/src/components/body/MRT_TableDetailPanel.tsx +3 -2
  88. package/src/components/buttons/MRT_ColumnPinningButtons.tsx +3 -2
  89. package/src/components/buttons/MRT_CopyButton.tsx +4 -2
  90. package/src/components/buttons/MRT_EditActionButtons.tsx +3 -2
  91. package/src/components/buttons/MRT_ExpandAllButton.tsx +3 -2
  92. package/src/components/buttons/MRT_ExpandButton.tsx +3 -2
  93. package/src/components/buttons/MRT_GrabHandleButton.tsx +9 -15
  94. package/src/components/buttons/MRT_RowPinButton.tsx +3 -2
  95. package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +3 -2
  96. package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +3 -2
  97. package/src/components/buttons/MRT_ToggleFiltersButton.tsx +3 -2
  98. package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +3 -2
  99. package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -2
  100. package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +3 -2
  101. package/src/components/footer/MRT_TableFooter.tsx +3 -2
  102. package/src/components/footer/MRT_TableFooterCell.tsx +3 -2
  103. package/src/components/footer/MRT_TableFooterRow.tsx +5 -3
  104. package/src/components/head/MRT_TableHead.tsx +3 -2
  105. package/src/components/head/MRT_TableHeadCell.tsx +9 -5
  106. package/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx +4 -2
  107. package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +4 -2
  108. package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +4 -2
  109. package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +4 -3
  110. package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +3 -2
  111. package/src/components/head/MRT_TableHeadCellSortLabel.tsx +3 -2
  112. package/src/components/head/MRT_TableHeadRow.tsx +4 -2
  113. package/src/components/inputs/MRT_EditCellTextField.tsx +3 -2
  114. package/src/components/inputs/MRT_FilterCheckbox.tsx +3 -2
  115. package/src/components/inputs/MRT_FilterRangeFields.tsx +3 -2
  116. package/src/components/inputs/MRT_FilterRangeSlider.tsx +3 -2
  117. package/src/components/inputs/MRT_FilterTextField.tsx +15 -6
  118. package/src/components/inputs/MRT_GlobalFilterTextField.tsx +3 -2
  119. package/src/components/inputs/MRT_SelectCheckbox.tsx +26 -33
  120. package/src/components/menus/MRT_ActionMenuItem.tsx +61 -0
  121. package/src/components/menus/MRT_CellActionMenu.tsx +109 -0
  122. package/src/components/menus/MRT_ColumnActionMenu.tsx +92 -172
  123. package/src/components/menus/MRT_FilterOptionMenu.tsx +9 -16
  124. package/src/components/menus/MRT_RowActionMenu.tsx +10 -17
  125. package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +11 -3
  126. package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +7 -5
  127. package/src/components/modals/MRT_EditRowModal.tsx +3 -2
  128. package/src/components/table/MRT_Table.tsx +2 -2
  129. package/src/components/table/MRT_TableContainer.tsx +7 -2
  130. package/src/components/table/MRT_TableLoadingOverlay.tsx +11 -8
  131. package/src/components/table/MRT_TablePaper.tsx +3 -2
  132. package/src/components/toolbar/MRT_BottomToolbar.tsx +3 -2
  133. package/src/components/toolbar/MRT_LinearProgressBar.tsx +3 -2
  134. package/src/components/toolbar/MRT_TablePagination.tsx +2 -2
  135. package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +30 -13
  136. package/src/components/toolbar/MRT_ToolbarDropZone.tsx +3 -2
  137. package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +3 -2
  138. package/src/components/toolbar/MRT_TopToolbar.tsx +2 -2
  139. package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +1 -8
  140. package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +1 -8
  141. package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +1 -8
  142. package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +1 -8
  143. package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +1 -8
  144. package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +1 -8
  145. package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +1 -8
  146. package/src/hooks/useMRT_Effects.ts +14 -4
  147. package/src/hooks/useMRT_Rows.ts +11 -79
  148. package/src/hooks/useMRT_TableInstance.ts +114 -59
  149. package/src/hooks/useMRT_TableOptions.ts +2 -0
  150. package/src/icons.ts +2 -0
  151. package/src/index.ts +2 -0
  152. package/src/locales/ar.ts +2 -0
  153. package/src/locales/az.ts +2 -0
  154. package/src/locales/bg.ts +2 -0
  155. package/src/locales/cs.ts +2 -0
  156. package/src/locales/da.ts +2 -0
  157. package/src/locales/de.ts +2 -0
  158. package/src/locales/en.ts +2 -0
  159. package/src/locales/es.ts +2 -0
  160. package/src/locales/et.ts +2 -0
  161. package/src/locales/fa.ts +2 -0
  162. package/src/locales/fi.ts +2 -0
  163. package/src/locales/fr.ts +2 -0
  164. package/src/locales/he.ts +2 -0
  165. package/src/locales/hu.ts +2 -0
  166. package/src/locales/hy.ts +2 -0
  167. package/src/locales/id.ts +2 -0
  168. package/src/locales/it.ts +2 -0
  169. package/src/locales/ja.ts +2 -0
  170. package/src/locales/ko.ts +2 -0
  171. package/src/locales/nl.ts +2 -0
  172. package/src/locales/no.ts +2 -0
  173. package/src/locales/np.ts +2 -0
  174. package/src/locales/pl.ts +2 -0
  175. package/src/locales/pt-BR.ts +2 -0
  176. package/src/locales/pt.ts +2 -0
  177. package/src/locales/ro.ts +2 -0
  178. package/src/locales/ru.ts +2 -0
  179. package/src/locales/sk.ts +2 -0
  180. package/src/locales/sr-Cyrl-RS.ts +2 -0
  181. package/src/locales/sr-Latn-RS.ts +2 -0
  182. package/src/locales/sv.ts +2 -0
  183. package/src/locales/tr.ts +2 -0
  184. package/src/locales/uk.ts +2 -0
  185. package/src/locales/vi.ts +2 -0
  186. package/src/locales/zh-Hans.ts +2 -0
  187. package/src/locales/zh-Hant.ts +2 -0
  188. package/src/types.ts +51 -13
  189. package/src/utils/cell.utils.ts +50 -0
  190. package/src/utils/column.utils.ts +4 -6
  191. package/src/utils/displayColumn.utils.ts +39 -21
  192. package/src/utils/row.utils.ts +179 -21
  193. package/locales/am/index.d.ts +0 -3
  194. package/locales/am/index.esm.d.ts +0 -3
  195. package/locales/am/index.esm.js +0 -93
  196. package/locales/am/index.js +0 -97
  197. package/locales/am/package.json +0 -6
  198. package/src/hooks/display-columns/getMRT_DisplayColumns.tsx +0 -26
  199. package/src/locales/am.ts +0 -94
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
- import { flexRender as flexRender$1, createRow as createRow$1, aggregationFns, filterFns, sortingFns, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
2
- import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
3
- import { useMemo, useState, useReducer, useRef, useEffect, useCallback, memo, Fragment as Fragment$1, useLayoutEffect } from 'react';
1
+ import { flexRender as flexRender$1, createRow as createRow$1, sortingFns, aggregationFns, filterFns, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
2
+ import { compareItems, rankItem, rankings } from '@tanstack/match-sorter-utils';
3
+ import { useState, useMemo, useReducer, useRef, useEffect, useCallback, memo, Fragment as Fragment$1, useLayoutEffect } from 'react';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import IconButton from '@mui/material/IconButton';
6
6
  import Tooltip from '@mui/material/Tooltip';
@@ -8,8 +8,8 @@ import Box from '@mui/material/Box';
8
8
  import Button from '@mui/material/Button';
9
9
  import CircularProgress from '@mui/material/CircularProgress';
10
10
  import { lighten, darken, alpha, useTheme } from '@mui/material/styles';
11
- import ListItemIcon from '@mui/material/ListItemIcon';
12
11
  import Menu from '@mui/material/Menu';
12
+ import ListItemIcon from '@mui/material/ListItemIcon';
13
13
  import MenuItem from '@mui/material/MenuItem';
14
14
  import Stack from '@mui/material/Stack';
15
15
  import Checkbox from '@mui/material/Checkbox';
@@ -21,6 +21,7 @@ import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
21
21
  import ChevronRightIcon from '@mui/icons-material/ChevronRight';
22
22
  import ClearAllIcon from '@mui/icons-material/ClearAll';
23
23
  import CloseIcon from '@mui/icons-material/Close';
24
+ import ContentCopy from '@mui/icons-material/ContentCopy';
24
25
  import DensityLargeIcon from '@mui/icons-material/DensityLarge';
25
26
  import DensityMediumIcon from '@mui/icons-material/DensityMedium';
26
27
  import DensitySmallIcon from '@mui/icons-material/DensitySmall';
@@ -159,13 +160,12 @@ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
159
160
  return newColumnOrder;
160
161
  };
161
162
  const getDefaultColumnFilterFn = (columnDef) => {
162
- var _a;
163
- if (columnDef.filterVariant === 'multi-select')
163
+ const { filterVariant } = columnDef;
164
+ if (filterVariant === 'multi-select')
164
165
  return 'arrIncludesSome';
165
- if ((_a = columnDef.filterVariant) === null || _a === void 0 ? void 0 : _a.includes('range'))
166
+ if (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.includes('range'))
166
167
  return 'betweenInclusive';
167
- if (columnDef.filterVariant === 'select' ||
168
- columnDef.filterVariant === 'checkbox')
168
+ if (filterVariant === 'select' || filterVariant === 'checkbox')
169
169
  return 'equals';
170
170
  return 'fuzzy';
171
171
  };
@@ -212,32 +212,73 @@ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parent
212
212
  [getColumnId(col)]: '',
213
213
  }))), rowIndex, depth, subRows, parentId);
214
214
 
215
+ const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
216
+ const getValueAndLabel = (option) => {
217
+ var _a, _b, _c;
218
+ let label = '';
219
+ let value = '';
220
+ if (option) {
221
+ if (typeof option !== 'object') {
222
+ label = option;
223
+ value = option;
224
+ }
225
+ else {
226
+ label = (_b = (_a = option.label) !== null && _a !== void 0 ? _a : option.text) !== null && _b !== void 0 ? _b : option.value;
227
+ value = (_c = option.value) !== null && _c !== void 0 ? _c : label;
228
+ }
229
+ }
230
+ return { label, value };
231
+ };
232
+
233
+ const isCellEditable = ({ cell, table, }) => {
234
+ const { enableEditing } = table.options;
235
+ const { column: { columnDef }, row, } = cell;
236
+ return (!cell.getIsPlaceholder() &&
237
+ parseFromValuesOrFunc(enableEditing, row) &&
238
+ parseFromValuesOrFunc(columnDef.enableEditing, row) !== false);
239
+ };
240
+ const openEditingCell = ({ cell, table, }) => {
241
+ const { options: { editDisplayMode }, refs: { editInputRefs }, } = table;
242
+ const { column } = cell;
243
+ if (isCellEditable({ cell, table }) && editDisplayMode === 'cell') {
244
+ table.setEditingCell(cell);
245
+ queueMicrotask(() => {
246
+ var _a;
247
+ const textField = editInputRefs.current[column.id];
248
+ if (textField) {
249
+ textField.focus();
250
+ (_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
251
+ }
252
+ });
253
+ }
254
+ };
255
+
215
256
  function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
216
257
  const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
217
258
  return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumn), { header: header ? localization[header] : '', size }), displayColumnDefOptions === null || displayColumnDefOptions === void 0 ? void 0 : displayColumnDefOptions[id]), { id });
218
259
  }
219
260
  const showRowPinningColumn = (tableOptions) => {
220
261
  const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
221
- return enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select'));
262
+ return !!(enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select')));
222
263
  };
223
264
  const showRowDragColumn = (tableOptions) => {
224
265
  const { enableRowDragging, enableRowOrdering } = tableOptions;
225
- return enableRowDragging || enableRowOrdering;
266
+ return !!(enableRowDragging || enableRowOrdering);
226
267
  };
227
268
  const showRowExpandColumn = (tableOptions) => {
228
269
  const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
229
270
  return !!(enableExpanding ||
230
- (enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
271
+ (enableGrouping && (grouping === null || grouping === void 0 ? void 0 : grouping.length)) ||
231
272
  renderDetailPanel);
232
273
  };
233
274
  const showRowActionsColumn = (tableOptions) => {
234
275
  const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
235
- return (enableRowActions ||
276
+ return !!(enableRowActions ||
236
277
  (creatingRow && createDisplayMode === 'row') ||
237
278
  (enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
238
279
  };
239
- const showRowSelectionColumn = (tableOptions) => tableOptions.enableRowSelection;
240
- const showRowNumbersColumn = (tableOptions) => tableOptions.enableRowNumbers;
280
+ const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
281
+ const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
241
282
  const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
242
283
  const getLeadingDisplayColumnIds = (tableOptions) => [
243
284
  showRowPinningColumn(tableOptions) && 'mrt-row-pin',
@@ -260,44 +301,82 @@ const getTrailingDisplayColumnIds = (tableOptions) => [
260
301
  'mrt-row-expand',
261
302
  showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
262
303
  ].filter(Boolean);
263
- const getDefaultColumnOrderIds = (tableOptions) => {
264
- const leadingDisplayCols = getLeadingDisplayColumnIds(tableOptions);
265
- const trailingDisplayCols = getTrailingDisplayColumnIds(tableOptions);
266
- const allLeafColumnDefs = getAllLeafColumnDefs(tableOptions.columns)
267
- .map((columnDef) => getColumnId(columnDef))
268
- .filter((columnId) => !leadingDisplayCols.includes(columnId) &&
269
- !trailingDisplayCols.includes(columnId));
270
- return [...leadingDisplayCols, ...allLeafColumnDefs, ...trailingDisplayCols];
304
+ const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
305
+ const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
306
+ const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
307
+ const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
308
+ const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
309
+ let allLeafColumnDefIds = reset
310
+ ? defaultColumnDefIds
311
+ : Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
312
+ allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
313
+ !trailingDisplayColIds.includes(colId));
314
+ return [
315
+ ...leadingDisplayColIds,
316
+ ...allLeafColumnDefIds,
317
+ ...trailingDisplayColIds,
318
+ ];
271
319
  };
272
320
 
273
- const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
274
- const getValueAndLabel = (option) => {
275
- var _a, _b, _c;
276
- let label = '';
277
- let value = '';
278
- if (option) {
279
- if (typeof option !== 'object') {
280
- label = option;
281
- value = option;
282
- }
283
- else {
284
- label = (_b = (_a = option.label) !== null && _a !== void 0 ? _a : option.text) !== null && _b !== void 0 ? _b : option.value;
285
- value = (_c = option.value) !== null && _c !== void 0 ? _c : label;
286
- }
321
+ const fuzzy$1 = (rowA, rowB, columnId) => {
322
+ let dir = 0;
323
+ if (rowA.columnFiltersMeta[columnId]) {
324
+ dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
287
325
  }
288
- return { label, value };
326
+ // Provide a fallback for when the item ranks are equal
327
+ return dir === 0
328
+ ? sortingFns.alphanumeric(rowA, rowB, columnId)
329
+ : dir;
289
330
  };
331
+ const MRT_SortingFns = Object.assign(Object.assign({}, sortingFns), { fuzzy: fuzzy$1 });
332
+ const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
333
+ Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
290
334
 
291
- const getIsRowSelected = ({ row, table, }) => {
292
- const { options: { enableRowSelection }, } = table;
293
- return (row.getIsSelected() ||
294
- (parseFromValuesOrFunc(enableRowSelection, row) &&
295
- row.getCanSelectSubRows() &&
296
- row.getIsAllSubRowsSelected()));
335
+ const getMRT_Rows = (table, pinnedRowIds = [], all) => {
336
+ const { getBottomRows, getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { createDisplayMode, enablePagination, enableRowPinning, manualPagination, positionCreatingRow, rowPinningDisplayMode, }, } = table;
337
+ const { creatingRow, pagination } = getState();
338
+ const isRankingRows = getIsRankingRows(table);
339
+ let rows = [];
340
+ if (!isRankingRows) {
341
+ rows =
342
+ !enableRowPinning || (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))
343
+ ? all
344
+ ? getPrePaginationRowModel().rows
345
+ : getRowModel().rows
346
+ : getCenterRows();
347
+ }
348
+ else {
349
+ rows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
350
+ if (enablePagination && !manualPagination && !all) {
351
+ const start = pagination.pageIndex * pagination.pageSize;
352
+ rows = rows.slice(start, start + pagination.pageSize);
353
+ }
354
+ }
355
+ if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
356
+ rows = [
357
+ ...getTopRows().filter((row) => !pinnedRowIds.includes(row.id)),
358
+ ...rows,
359
+ ...getBottomRows().filter((row) => !pinnedRowIds.includes(row.id)),
360
+ ];
361
+ }
362
+ if (positionCreatingRow !== undefined &&
363
+ creatingRow &&
364
+ createDisplayMode === 'row') {
365
+ const creatingRowIndex = !isNaN(+positionCreatingRow)
366
+ ? +positionCreatingRow
367
+ : positionCreatingRow === 'top'
368
+ ? 0
369
+ : rows.length;
370
+ rows = [
371
+ ...rows.slice(0, creatingRowIndex),
372
+ creatingRow,
373
+ ...rows.slice(creatingRowIndex),
374
+ ];
375
+ }
376
+ return rows;
297
377
  };
298
378
  const getCanRankRows = (table) => {
299
- const { getState, options } = table;
300
- const { enableGlobalFilterRankedResults, manualExpanding, manualFiltering, manualGrouping, manualSorting, } = options;
379
+ const { getState, options: { enableGlobalFilterRankedResults, manualExpanding, manualFiltering, manualGrouping, manualSorting, }, } = table;
301
380
  const { expanded, globalFilterFn } = getState();
302
381
  return (!manualExpanding &&
303
382
  !manualFiltering &&
@@ -308,17 +387,67 @@ const getCanRankRows = (table) => {
308
387
  expanded !== true &&
309
388
  !Object.values(expanded).some(Boolean));
310
389
  };
390
+ const getIsRankingRows = (table) => {
391
+ const { globalFilter, sorting } = table.getState();
392
+ return (getCanRankRows(table) &&
393
+ globalFilter &&
394
+ !Object.values(sorting).some(Boolean));
395
+ };
396
+ const getIsRowSelected = ({ row, table, }) => {
397
+ const { options: { enableRowSelection }, } = table;
398
+ return (row.getIsSelected() ||
399
+ (parseFromValuesOrFunc(enableRowSelection, row) &&
400
+ row.getCanSelectSubRows() &&
401
+ row.getIsAllSubRowsSelected()));
402
+ };
403
+ const getMRT_RowSelectionHandler = () => ({ event, row, staticRowIndex = 0, table, }) => {
404
+ var _a;
405
+ const { getState, options: { enableBatchRowSelection, enableRowPinning, rowPinningDisplayMode, }, refs: { lastSelectedRowId: lastSelectedRowId }, } = table;
406
+ const { pagination: { pageIndex, pageSize }, } = getState();
407
+ const isChecked = getIsRowSelected({ row, table });
408
+ const isStickySelection = enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'));
409
+ // toggle selected of this row
410
+ row.getToggleSelectedHandler()(event);
411
+ // if shift key is pressed, select all rows between last selected and this one
412
+ if (enableBatchRowSelection &&
413
+ event.nativeEvent.shiftKey &&
414
+ lastSelectedRowId.current !== null) {
415
+ const rows = getMRT_Rows(table, undefined, true);
416
+ const lastIndex = rows.findIndex((r) => r.id === lastSelectedRowId.current);
417
+ if (lastIndex !== -1) {
418
+ const currentIndex = staticRowIndex + pageSize * pageIndex;
419
+ const [start, end] = lastIndex < currentIndex
420
+ ? [lastIndex, currentIndex]
421
+ : [currentIndex, lastIndex];
422
+ for (let i = start; i <= end; i++) {
423
+ rows[i].toggleSelected(!isChecked);
424
+ }
425
+ }
426
+ }
427
+ lastSelectedRowId.current = row.id;
428
+ // if all sub rows were selected, unselect them
429
+ if (row.getCanSelectSubRows() && row.getIsAllSubRowsSelected()) {
430
+ (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.forEach((r) => r.toggleSelected(false));
431
+ }
432
+ if (isStickySelection) {
433
+ row.pin(!row.getIsPinned() && isChecked
434
+ ? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
435
+ ? 'bottom'
436
+ : 'top'
437
+ : false);
438
+ }
439
+ };
311
440
 
312
441
  const MRT_AggregationFns = Object.assign({}, aggregationFns);
313
442
 
314
- const fuzzy$1 = (row, columnId, filterValue, addMeta) => {
443
+ const fuzzy = (row, columnId, filterValue, addMeta) => {
315
444
  const itemRank = rankItem(row.getValue(columnId), filterValue, {
316
445
  threshold: rankings.MATCHES,
317
446
  });
318
447
  addMeta(itemRank);
319
448
  return itemRank.passed;
320
449
  };
321
- fuzzy$1.autoRemove = (val) => !val;
450
+ fuzzy.autoRemove = (val) => !val;
322
451
  const contains = (row, id, filterValue) => row
323
452
  .getValue(id)
324
453
  .toString()
@@ -386,7 +515,7 @@ const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
386
515
  empty,
387
516
  endsWith,
388
517
  equals,
389
- fuzzy: fuzzy$1,
518
+ fuzzy,
390
519
  greaterThan,
391
520
  greaterThanOrEqualTo,
392
521
  lessThan,
@@ -395,20 +524,6 @@ const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
395
524
  notEquals,
396
525
  startsWith });
397
526
 
398
- const fuzzy = (rowA, rowB, columnId) => {
399
- let dir = 0;
400
- if (rowA.columnFiltersMeta[columnId]) {
401
- dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
402
- }
403
- // Provide a fallback for when the item ranks are equal
404
- return dir === 0
405
- ? sortingFns.alphanumeric(rowA, rowB, columnId)
406
- : dir;
407
- };
408
- const MRT_SortingFns = Object.assign(Object.assign({}, sortingFns), { fuzzy });
409
- const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
410
- Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
411
-
412
527
  /******************************************************************************
413
528
  Copyright (c) Microsoft Corporation.
414
529
 
@@ -584,380 +699,44 @@ const getCommonTooltipProps = (placement) => ({
584
699
  placement,
585
700
  });
586
701
 
587
- const mrtFilterOptions = (localization) => [
588
- {
589
- divider: false,
590
- label: localization.filterFuzzy,
591
- option: 'fuzzy',
592
- symbol: '',
593
- },
594
- {
595
- divider: false,
596
- label: localization.filterContains,
597
- option: 'contains',
598
- symbol: '*',
599
- },
600
- {
601
- divider: false,
602
- label: localization.filterStartsWith,
603
- option: 'startsWith',
604
- symbol: 'a',
605
- },
606
- {
607
- divider: true,
608
- label: localization.filterEndsWith,
609
- option: 'endsWith',
610
- symbol: 'z',
611
- },
612
- {
613
- divider: false,
614
- label: localization.filterEquals,
615
- option: 'equals',
616
- symbol: '=',
617
- },
618
- {
619
- divider: true,
620
- label: localization.filterNotEquals,
621
- option: 'notEquals',
622
- symbol: '≠',
623
- },
624
- {
625
- divider: false,
626
- label: localization.filterBetween,
627
- option: 'between',
628
- symbol: '⇿',
629
- },
630
- {
631
- divider: true,
632
- label: localization.filterBetweenInclusive,
633
- option: 'betweenInclusive',
634
- symbol: '⬌',
635
- },
636
- {
637
- divider: false,
638
- label: localization.filterGreaterThan,
639
- option: 'greaterThan',
640
- symbol: '>',
641
- },
642
- {
643
- divider: false,
644
- label: localization.filterGreaterThanOrEqualTo,
645
- option: 'greaterThanOrEqualTo',
646
- symbol: '≥',
647
- },
648
- {
649
- divider: false,
650
- label: localization.filterLessThan,
651
- option: 'lessThan',
652
- symbol: '<',
653
- },
654
- {
655
- divider: true,
656
- label: localization.filterLessThanOrEqualTo,
657
- option: 'lessThanOrEqualTo',
658
- symbol: '≤',
659
- },
660
- {
661
- divider: false,
662
- label: localization.filterEmpty,
663
- option: 'empty',
664
- symbol: '∅',
665
- },
666
- {
667
- divider: false,
668
- label: localization.filterNotEmpty,
669
- option: 'notEmpty',
670
- symbol: '!∅',
671
- },
672
- ];
673
- const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
674
- const emptyModes = ['empty', 'notEmpty'];
675
- const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
676
- const rangeVariants = ['range-slider', 'date-range', 'datetime-range', 'range'];
677
- const MRT_FilterOptionMenu = (_a) => {
678
- var _b, _c, _d, _e;
679
- var { anchorEl, header, onSelect, setAnchorEl, setFilterValue, table } = _a, rest = __rest(_a, ["anchorEl", "header", "onSelect", "setAnchorEl", "setFilterValue", "table"]);
680
- const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
681
- const { density, globalFilterFn } = getState();
682
- const { column } = header !== null && header !== void 0 ? header : {};
683
- const { columnDef } = column !== null && column !== void 0 ? column : {};
684
- const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
685
- let allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
686
- if (rangeVariants.includes(columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant)) {
687
- allowedColumnFilterOptions = [
688
- ...rangeModes,
689
- ...(allowedColumnFilterOptions !== null && allowedColumnFilterOptions !== void 0 ? allowedColumnFilterOptions : []),
690
- ].filter((option) => rangeModes.includes(option));
691
- }
692
- const internalFilterOptions = useMemo(() => mrtFilterOptions(localization).filter((filterOption) => columnDef
693
- ? allowedColumnFilterOptions === undefined ||
694
- (allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.includes(filterOption.option))
695
- : (!globalFilterModeOptions ||
696
- globalFilterModeOptions.includes(filterOption.option)) &&
697
- ['contains', 'fuzzy', 'startsWith'].includes(filterOption.option)), []);
698
- const handleSelectFilterMode = (option) => {
699
- var _a, _b;
700
- const prevFilterMode = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef._filterFn) !== null && _a !== void 0 ? _a : '';
701
- if (!header || !column) {
702
- // global filter mode
703
- setGlobalFilterFn(option);
704
- }
705
- else if (option !== prevFilterMode) {
706
- // column filter mode
707
- setColumnFilterFns((prev) => (Object.assign(Object.assign({}, prev), { [header.id]: option })));
708
- // reset filter value and/or perform new filter render
709
- if (emptyModes.includes(option)) {
710
- // will now be empty/notEmpty filter mode
711
- if (currentFilterValue !== ' ' &&
712
- !emptyModes.includes(prevFilterMode)) {
713
- column.setFilterValue(' ');
714
- }
715
- else if (currentFilterValue) {
716
- column.setFilterValue(currentFilterValue); // perform new filter render
717
- }
718
- }
719
- else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
720
- arrModes.includes(option)) {
721
- // will now be array filter mode
722
- if (currentFilterValue instanceof String ||
723
- (currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.length)) {
724
- column.setFilterValue([]);
725
- setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue([]);
726
- }
727
- else if (currentFilterValue) {
728
- column.setFilterValue(currentFilterValue); // perform new filter render
729
- }
730
- }
731
- else if (((_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === null || _b === void 0 ? void 0 : _b.includes('range')) ||
732
- rangeModes.includes(option)) {
733
- // will now be range filter mode
734
- if (!Array.isArray(currentFilterValue) ||
735
- (!(currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.every((v) => v === '')) &&
736
- !rangeModes.includes(prevFilterMode))) {
737
- column.setFilterValue(['', '']);
738
- setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
739
- }
740
- else {
741
- column.setFilterValue(currentFilterValue); // perform new filter render
742
- }
743
- }
744
- else {
745
- // will now be single value filter mode
746
- if (Array.isArray(currentFilterValue)) {
747
- column.setFilterValue('');
748
- setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
749
- }
750
- else if (currentFilterValue === ' ' &&
751
- emptyModes.includes(prevFilterMode)) {
752
- column.setFilterValue(undefined);
753
- }
754
- else {
755
- column.setFilterValue(currentFilterValue); // perform new filter render
756
- }
757
- }
758
- }
759
- setAnchorEl(null);
760
- onSelect === null || onSelect === void 0 ? void 0 : onSelect();
761
- };
762
- const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
763
- const theme = useTheme();
764
- const { menuBackgroundColor } = getMRTTheme(table, theme);
765
- return (jsx(Menu, Object.assign({ MenuListProps: {
766
- dense: density === 'compact',
767
- sx: {
768
- backgroundColor: menuBackgroundColor,
769
- },
770
- }, anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_e = (header && column && columnDef
771
- ? (_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
772
- column: column,
773
- internalFilterOptions,
774
- onSelectFilterMode: handleSelectFilterMode,
775
- table,
776
- })) !== null && _d !== void 0 ? _d : renderColumnFilterModeMenuItems === null || renderColumnFilterModeMenuItems === void 0 ? void 0 : renderColumnFilterModeMenuItems({
777
- column: column,
778
- internalFilterOptions,
779
- onSelectFilterMode: handleSelectFilterMode,
780
- table,
781
- })
782
- : renderGlobalFilterModeMenuItems === null || renderGlobalFilterModeMenuItems === void 0 ? void 0 : renderGlobalFilterModeMenuItems({
783
- internalFilterOptions,
784
- onSelectFilterMode: handleSelectFilterMode,
785
- table,
786
- }))) !== null && _e !== void 0 ? _e : internalFilterOptions.map(({ divider, label, option, symbol }, index) => (jsxs(MenuItem, { divider: divider, onClick: () => handleSelectFilterMode(option), selected: option === filterOption, sx: {
787
- alignItems: 'center',
788
- display: 'flex',
789
- gap: '2ch',
790
- my: 0,
791
- py: '6px',
792
- }, value: option, children: [jsx(Box, { sx: { fontSize: '1.25rem', width: '2ch' }, children: symbol }), label] }, index))) })));
793
- };
794
-
795
- const commonMenuItemStyles = {
796
- alignItems: 'center',
797
- justifyContent: 'space-between',
798
- my: 0,
799
- py: '6px',
800
- };
801
- const commonListItemStyles = {
802
- alignItems: 'center',
803
- display: 'flex',
804
- };
805
- const MRT_ColumnActionMenu = (_a) => {
806
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
807
- var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
808
- const { getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ArrowRightIcon, ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnFilterFns, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, toggleAllColumnsVisible, } = table;
809
- const { column } = header;
810
- const { columnDef } = column;
811
- const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
812
- const columnFilterValue = column.getFilterValue();
813
- const [filterMenuAnchorEl, setFilterMenuAnchorEl] = useState(null);
814
- const handleClearSort = () => {
815
- column.clearSorting();
816
- setAnchorEl(null);
817
- };
818
- const handleSortAsc = () => {
819
- column.toggleSorting(false);
820
- setAnchorEl(null);
821
- };
822
- const handleSortDesc = () => {
823
- column.toggleSorting(true);
824
- setAnchorEl(null);
825
- };
826
- const handleResetColumnSize = () => {
827
- setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
828
- column.resetSize();
829
- setAnchorEl(null);
830
- };
831
- const handleHideColumn = () => {
832
- column.toggleVisibility(false);
833
- setAnchorEl(null);
834
- };
835
- const handlePinColumn = (pinDirection) => {
836
- column.pin(pinDirection);
837
- setAnchorEl(null);
838
- };
839
- const handleGroupByColumn = () => {
840
- column.toggleGrouping();
841
- setColumnOrder((old) => ['mrt-row-expand', ...old]);
842
- setAnchorEl(null);
843
- };
844
- const handleClearFilter = () => {
845
- column.setFilterValue(undefined);
846
- setAnchorEl(null);
847
- if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
848
- setColumnFilterFns((prev) => {
849
- var _a;
850
- return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
851
- });
852
- }
853
- };
854
- const handleFilterByColumn = () => {
855
- setShowColumnFilters(true);
856
- queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); });
857
- setAnchorEl(null);
858
- };
859
- const handleShowAllColumns = () => {
860
- toggleAllColumnsVisible(true);
861
- setAnchorEl(null);
862
- };
863
- const handleOpenFilterModeMenu = (event) => {
864
- event.stopPropagation();
865
- setFilterMenuAnchorEl(event.currentTarget);
866
- };
867
- const isSelectFilter = !!columnDef.filterSelectOptions;
868
- const allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
869
- const showFilterModeSubMenu = enableColumnFilterModes &&
870
- columnDef.enableColumnFilterModes !== false &&
871
- !isSelectFilter &&
872
- (allowedColumnFilterOptions === undefined ||
873
- !!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
874
- const internalColumnMenuItems = [
875
- ...(enableSorting && column.getCanSort()
876
- ? [
877
- enableSortingRemoval !== false && (jsx(MenuItem, { disabled: !column.getIsSorted(), onClick: handleClearSort, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(ClearAllIcon, {}) }), localization.clearSort] }) }, 0)),
878
- jsx(MenuItem, { disabled: column.getIsSorted() === 'asc', onClick: handleSortAsc, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(SortIcon, { style: { transform: 'rotate(180deg) scaleX(-1)' } }) }), (_c = localization.sortByColumnAsc) === null || _c === void 0 ? void 0 : _c.replace('{column}', String(columnDef.header))] }) }, 1),
879
- jsx(MenuItem, { disabled: column.getIsSorted() === 'desc', divider: enableColumnFilters || enableGrouping || enableHiding, onClick: handleSortDesc, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(SortIcon, {}) }), (_d = localization.sortByColumnDesc) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header))] }) }, 2),
880
- ]
881
- : []),
882
- ...(enableColumnFilters && column.getCanFilter()
883
- ? [
884
- jsx(MenuItem, { disabled: !columnFilterValue ||
885
- (Array.isArray(columnFilterValue) &&
886
- !columnFilterValue.filter((value) => value).length), onClick: handleClearFilter, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(FilterListOffIcon, {}) }), localization.clearFilter] }) }, 3),
887
- columnFilterDisplayMode === 'subheader' && (jsxs(MenuItem, { disabled: showColumnFilters && !enableColumnFilterModes, divider: enableGrouping || enableHiding, onClick: showColumnFilters
888
- ? handleOpenFilterModeMenu
889
- : handleFilterByColumn, sx: commonMenuItemStyles, children: [jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(FilterListIcon, {}) }), (_e = localization.filterByColumn) === null || _e === void 0 ? void 0 : _e.replace('{column}', String(columnDef.header))] }), showFilterModeSubMenu && (jsx(IconButton, { onClick: handleOpenFilterModeMenu, onMouseEnter: handleOpenFilterModeMenu, size: "small", sx: { p: 0 }, children: jsx(ArrowRightIcon, {}) }))] }, 4)),
890
- showFilterModeSubMenu && (jsx(MRT_FilterOptionMenu, { anchorEl: filterMenuAnchorEl, header: header, onSelect: handleFilterByColumn, setAnchorEl: setFilterMenuAnchorEl, table: table }, 5)),
891
- ].filter(Boolean)
892
- : []),
893
- ...(enableGrouping && column.getCanGroup()
894
- ? [
895
- jsx(MenuItem, { divider: enableColumnPinning, onClick: handleGroupByColumn, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(DynamicFeedIcon, {}) }), (_f = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) === null || _f === void 0 ? void 0 : _f.replace('{column}', String(columnDef.header))] }) }, 6),
896
- ]
897
- : []),
898
- ...(enableColumnPinning && column.getCanPin()
899
- ? [
900
- jsx(MenuItem, { disabled: column.getIsPinned() === 'left' || !column.getCanPin(), onClick: () => handlePinColumn('left'), sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(PushPinIcon, { style: { transform: 'rotate(90deg)' } }) }), localization.pinToLeft] }) }, 7),
901
- jsx(MenuItem, { disabled: column.getIsPinned() === 'right' || !column.getCanPin(), onClick: () => handlePinColumn('right'), sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(PushPinIcon, { style: { transform: 'rotate(-90deg)' } }) }), localization.pinToRight] }) }, 8),
902
- jsx(MenuItem, { disabled: !column.getIsPinned(), divider: enableHiding, onClick: () => handlePinColumn(false), sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(PushPinIcon, {}) }), localization.unpin] }) }, 9),
903
- ]
904
- : []),
905
- ...(enableColumnResizing && column.getCanResize()
906
- ? [
907
- jsx(MenuItem, { disabled: !columnSizing[column.id], onClick: handleResetColumnSize, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(RestartAltIcon, {}) }), localization.resetColumnSize] }) }, 10),
908
- ]
909
- : []),
910
- ...(enableHiding
911
- ? [
912
- jsx(MenuItem, { disabled: !column.getCanHide(), onClick: handleHideColumn, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(VisibilityOffIcon, {}) }), (_g = localization.hideColumn) === null || _g === void 0 ? void 0 : _g.replace('{column}', String(columnDef.header))] }) }, 11),
913
- jsx(MenuItem, { disabled: !Object.values(columnVisibility).filter((visible) => !visible)
914
- .length, onClick: handleShowAllColumns, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(ViewColumnIcon, {}) }), (_h = localization.showAllColumns) === null || _h === void 0 ? void 0 : _h.replace('{column}', String(columnDef.header))] }) }, 12),
915
- ]
916
- : []),
917
- ].filter(Boolean);
918
- const theme = useTheme();
919
- const { menuBackgroundColor } = getMRTTheme(table, theme);
920
- return (jsx(Menu, Object.assign({ MenuListProps: {
921
- dense: density === 'compact',
922
- sx: {
923
- backgroundColor: menuBackgroundColor,
924
- },
925
- }, anchorEl: anchorEl, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_l = (_k = (_j = columnDef.renderColumnActionsMenuItems) === null || _j === void 0 ? void 0 : _j.call(columnDef, {
926
- closeMenu: () => setAnchorEl(null),
927
- column,
928
- internalColumnMenuItems,
929
- table,
930
- })) !== null && _k !== void 0 ? _k : renderColumnActionsMenuItems === null || renderColumnActionsMenuItems === void 0 ? void 0 : renderColumnActionsMenuItems({
931
- closeMenu: () => setAnchorEl(null),
932
- column,
933
- internalColumnMenuItems,
934
- table,
935
- })) !== null && _l !== void 0 ? _l : internalColumnMenuItems })));
936
- };
937
-
938
- const MRT_RowActionMenu = (_a) => {
939
- var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
940
- const { getState, options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, renderRowActionMenuItems, }, } = table;
941
- const { density } = getState();
942
- const theme = useTheme();
943
- const { menuBackgroundColor } = getMRTTheme(table, theme);
944
- return (jsxs(Menu, Object.assign({ MenuListProps: {
945
- dense: density === 'compact',
946
- sx: {
947
- backgroundColor: menuBackgroundColor,
948
- },
949
- }, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: [parseFromValuesOrFunc(enableEditing, row) &&
950
- ['modal', 'row'].includes(editDisplayMode) && (jsx(MenuItem, { onClick: handleEdit, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(EditIcon, {}) }), localization.edit] }) })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
951
- closeMenu: () => setAnchorEl(null),
952
- row,
953
- staticRowIndex,
954
- table,
955
- })] })));
956
- };
957
-
958
- const commonIconButtonStyles = {
959
- '&:hover': {
960
- opacity: 1,
702
+ const MRT_ActionMenuItem = (_a) => {
703
+ var { icon, label, onOpenSubMenu, table } = _a, rest = __rest(_a, ["icon", "label", "onOpenSubMenu", "table"]);
704
+ const { options: { icons: { ArrowRightIcon }, }, } = table;
705
+ return (jsxs(MenuItem, Object.assign({ sx: {
706
+ alignItems: 'center',
707
+ justifyContent: 'space-between',
708
+ minWidth: '120px',
709
+ my: 0,
710
+ py: '6px',
711
+ } }, rest, { children: [jsxs(Box, { sx: {
712
+ alignItems: 'center',
713
+ display: 'flex',
714
+ }, children: [jsx(ListItemIcon, { children: icon }), label] }), onOpenSubMenu && (jsx(IconButton, { onClick: onOpenSubMenu, onMouseEnter: onOpenSubMenu, size: "small", sx: { p: 0 }, children: jsx(ArrowRightIcon, {}) }))] })));
715
+ };
716
+
717
+ const MRT_RowActionMenu = (_a) => {
718
+ var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
719
+ const { getState, options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, renderRowActionMenuItems, }, } = table;
720
+ const { density } = getState();
721
+ const theme = useTheme();
722
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
723
+ return (jsxs(Menu, Object.assign({ MenuListProps: {
724
+ dense: density === 'compact',
725
+ sx: {
726
+ backgroundColor: menuBackgroundColor,
727
+ },
728
+ }, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: [parseFromValuesOrFunc(enableEditing, row) &&
729
+ ['modal', 'row'].includes(editDisplayMode) && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
730
+ closeMenu: () => setAnchorEl(null),
731
+ row,
732
+ staticRowIndex,
733
+ table,
734
+ })] })));
735
+ };
736
+
737
+ const commonIconButtonStyles = {
738
+ '&:hover': {
739
+ opacity: 1,
961
740
  },
962
741
  height: '2rem',
963
742
  ml: '10px',
@@ -990,9 +769,6 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
990
769
  };
991
770
 
992
771
  const getMRT_RowActionsColumnDef = (tableOptions) => {
993
- if (!showRowActionsColumn(tableOptions)) {
994
- return null;
995
- }
996
772
  return Object.assign({ Cell: ({ cell, row, staticRowIndex, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, staticRowIndex: staticRowIndex, table: table })) }, defaultDisplayColumnProps({
997
773
  header: 'actions',
998
774
  id: 'mrt-row-actions',
@@ -1003,19 +779,18 @@ const getMRT_RowActionsColumnDef = (tableOptions) => {
1003
779
 
1004
780
  const MRT_GrabHandleButton = (_a) => {
1005
781
  var _b, _c;
1006
- var { iconButtonProps, location, onDragEnd, onDragStart, table } = _a, rest = __rest(_a, ["iconButtonProps", "location", "onDragEnd", "onDragStart", "table"]);
782
+ var { location, table } = _a, rest = __rest(_a, ["location", "table"]);
1007
783
  const { options: { icons: { DragHandleIcon }, localization, }, } = table;
1008
- const _iconButtonProps = Object.assign(Object.assign({}, iconButtonProps), rest);
1009
- return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.title) !== null && _b !== void 0 ? _b : localization.move, children: jsx(IconButton, Object.assign({ "aria-label": (_c = _iconButtonProps.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, _iconButtonProps, { onClick: (e) => {
784
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.move, children: jsx(IconButton, Object.assign({ "aria-label": (_c = rest.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, rest, { onClick: (e) => {
1010
785
  var _a;
1011
786
  e.stopPropagation();
1012
- (_a = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(_iconButtonProps, e);
1013
- }, onDragEnd: onDragEnd, onDragStart: onDragStart, sx: (theme) => (Object.assign({ '&:active': {
787
+ (_a = rest === null || rest === void 0 ? void 0 : rest.onClick) === null || _a === void 0 ? void 0 : _a.call(rest, e);
788
+ }, sx: (theme) => (Object.assign({ '&:active': {
1014
789
  cursor: 'grabbing',
1015
790
  }, '&:hover': {
1016
791
  backgroundColor: 'transparent',
1017
792
  opacity: 1,
1018
- }, cursor: 'grab', m: '0 -0.1rem', opacity: location === 'row' ? 1 : 0.3, p: '2px', transition: 'all 150ms ease-in-out' }, parseFromValuesOrFunc(_iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.sx, theme))), title: undefined, children: jsx(DragHandleIcon, {}) })) })));
793
+ }, cursor: 'grab', m: '0 -0.1rem', opacity: location === 'row' ? 1 : 0.5, p: '2px', transition: 'all 150ms ease-in-out' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), title: undefined, children: jsx(DragHandleIcon, {}) })) })));
1019
794
  };
1020
795
 
1021
796
  const MRT_TableBodyRowGrabHandle = (_a) => {
@@ -1042,13 +817,10 @@ const MRT_TableBodyRowGrabHandle = (_a) => {
1042
817
  table.setDraggingRow(null);
1043
818
  table.setHoveredRow(null);
1044
819
  };
1045
- return (jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
820
+ return (jsx(MRT_GrabHandleButton, Object.assign({}, iconButtonProps, { location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })));
1046
821
  };
1047
822
 
1048
823
  const getMRT_RowDragColumnDef = (tableOptions) => {
1049
- if (!showRowDragColumn(tableOptions)) {
1050
- return null;
1051
- }
1052
824
  return Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), grow: false }, defaultDisplayColumnProps({
1053
825
  header: 'move',
1054
826
  id: 'mrt-row-drag',
@@ -1108,9 +880,6 @@ const MRT_ExpandButton = ({ row, staticRowIndex, table, }) => {
1108
880
 
1109
881
  const getMRT_RowExpandColumnDef = (tableOptions) => {
1110
882
  var _a;
1111
- if (!showRowExpandColumn(tableOptions)) {
1112
- return null;
1113
- }
1114
883
  const { defaultColumn, enableExpandAll, groupedColumnMode, positionExpandColumn, renderDetailPanel, state: { grouping }, } = tableOptions;
1115
884
  const alignProps = positionExpandColumn === 'last'
1116
885
  ? {
@@ -1148,9 +917,6 @@ const getMRT_RowExpandColumnDef = (tableOptions) => {
1148
917
  };
1149
918
 
1150
919
  const getMRT_RowNumbersColumnDef = (tableOptions) => {
1151
- if (!showRowNumbersColumn(tableOptions)) {
1152
- return null;
1153
- }
1154
920
  const { localization, rowNumberDisplayMode } = tableOptions;
1155
921
  const { pagination: { pageIndex, pageSize }, } = tableOptions.state;
1156
922
  return Object.assign({ Cell: ({ row, staticRowIndex }) => {
@@ -1204,9 +970,6 @@ const MRT_TableBodyRowPinButton = (_a) => {
1204
970
  };
1205
971
 
1206
972
  const getMRT_RowPinningColumnDef = (tableOptions) => {
1207
- if (!showRowPinningColumn(tableOptions)) {
1208
- return null;
1209
- }
1210
973
  return Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), grow: false }, defaultDisplayColumnProps({
1211
974
  header: 'pin',
1212
975
  id: 'mrt-row-pin',
@@ -1218,36 +981,25 @@ const getMRT_RowPinningColumnDef = (tableOptions) => {
1218
981
  const MRT_SelectCheckbox = (_a) => {
1219
982
  var _b;
1220
983
  var { row, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "staticRowIndex", "table"]);
1221
- const { getState, options: { enableMultiRowSelection, enableRowPinning, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, rowPinningDisplayMode, selectAllMode, }, } = table;
984
+ const { getState, options: { enableMultiRowSelection, enableRowPinning, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, rowPinningDisplayMode, selectAllMode, }, refs: { lastSelectedRowId }, } = table;
1222
985
  const { density, isLoading } = getState();
1223
986
  const selectAll = !row;
1224
- const checkboxProps = Object.assign(Object.assign({}, (!row
1225
- ? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
1226
- : parseFromValuesOrFunc(muiSelectCheckboxProps, {
1227
- row,
1228
- staticRowIndex,
1229
- table,
1230
- }))), rest);
1231
987
  const isStickySelection = enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'));
1232
988
  const allRowsSelected = selectAll
1233
989
  ? selectAllMode === 'page'
1234
990
  ? table.getIsAllPageRowsSelected()
1235
991
  : table.getIsAllRowsSelected()
1236
992
  : undefined;
1237
- const onSelectionChange = (event, row) => {
1238
- var _a;
1239
- if (row.getIsAllSubRowsSelected() && row.getCanSelectSubRows()) {
1240
- (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.forEach((r) => r.toggleSelected(false));
1241
- }
1242
- row.getToggleSelectedHandler()(event);
1243
- if (isStickySelection) {
1244
- row.pin(!row.getIsPinned() && event.target.checked
1245
- ? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
1246
- ? 'bottom'
1247
- : 'top'
1248
- : false);
1249
- }
1250
- };
993
+ const isChecked = selectAll
994
+ ? allRowsSelected
995
+ : getIsRowSelected({ row, table });
996
+ const checkboxProps = Object.assign(Object.assign({}, (selectAll
997
+ ? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
998
+ : parseFromValuesOrFunc(muiSelectCheckboxProps, {
999
+ row,
1000
+ table,
1001
+ }))), rest);
1002
+ const onSelectionChange = getMRT_RowSelectionHandler();
1251
1003
  const onSelectAllChange = (event) => {
1252
1004
  selectAllMode === 'all'
1253
1005
  ? table.getToggleAllRowsSelectedHandler()(event)
@@ -1255,16 +1007,19 @@ const MRT_SelectCheckbox = (_a) => {
1255
1007
  if (isStickySelection) {
1256
1008
  table.setRowPinning({ bottom: [], top: [] });
1257
1009
  }
1010
+ lastSelectedRowId.current = null;
1258
1011
  };
1259
1012
  const commonProps = Object.assign(Object.assign({ 'aria-label': selectAll
1260
1013
  ? localization.toggleSelectAll
1261
- : localization.toggleSelectRow, checked: selectAll ? allRowsSelected : getIsRowSelected({ row, table }), disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
1014
+ : localization.toggleSelectRow, checked: isChecked, disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
1262
1015
  'aria-label': selectAll
1263
1016
  ? localization.toggleSelectAll
1264
1017
  : localization.toggleSelectRow,
1265
1018
  }, onChange: (event) => {
1266
1019
  event.stopPropagation();
1267
- row ? onSelectionChange(event, row) : onSelectAllChange(event);
1020
+ row
1021
+ ? onSelectionChange({ event, row, staticRowIndex, table })
1022
+ : onSelectAllChange(event);
1268
1023
  }, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
1269
1024
  var _a;
1270
1025
  e.stopPropagation();
@@ -1278,9 +1033,6 @@ const MRT_SelectCheckbox = (_a) => {
1278
1033
  };
1279
1034
 
1280
1035
  const getMRT_RowSelectColumnDef = (tableOptions) => {
1281
- if (!showRowSelectionColumn(tableOptions)) {
1282
- return null;
1283
- }
1284
1036
  const { enableMultiRowSelection, enableSelectAll } = tableOptions;
1285
1037
  return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: enableSelectAll && enableMultiRowSelection
1286
1038
  ? ({ table }) => jsx(MRT_SelectCheckbox, { table: table })
@@ -1300,6 +1052,7 @@ const MRT_Default_Icons = {
1300
1052
  ChevronRightIcon,
1301
1053
  ClearAllIcon,
1302
1054
  CloseIcon,
1055
+ ContentCopy,
1303
1056
  DensityLargeIcon,
1304
1057
  DensityMediumIcon,
1305
1058
  DensitySmallIcon,
@@ -1336,8 +1089,10 @@ const MRT_Localization_EN = {
1336
1089
  changeSearchMode: 'Change search mode',
1337
1090
  clearFilter: 'Clear filter',
1338
1091
  clearSearch: 'Clear search',
1092
+ clearSelection: 'Clear selection',
1339
1093
  clearSort: 'Clear sort',
1340
1094
  clickToCopy: 'Click to copy',
1095
+ copy: 'Copy',
1341
1096
  collapse: 'Collapse',
1342
1097
  collapseAll: 'Collapse all',
1343
1098
  columnActions: 'Column Actions',
@@ -1442,7 +1197,7 @@ const MRT_DefaultDisplayColumn = {
1442
1197
  };
1443
1198
  const useMRT_TableOptions = (_a) => {
1444
1199
  var _b;
1445
- var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableRowVirtualization, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
1200
+ var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableRowVirtualization, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
1446
1201
  const theme = useTheme();
1447
1202
  icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
1448
1203
  localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
@@ -1483,6 +1238,7 @@ const useMRT_TableOptions = (_a) => {
1483
1238
  defaultColumn,
1484
1239
  defaultDisplayColumn,
1485
1240
  editDisplayMode,
1241
+ enableBatchRowSelection,
1486
1242
  enableBottomToolbar,
1487
1243
  enableColumnActions,
1488
1244
  enableColumnFilters,
@@ -1552,9 +1308,6 @@ const blankColProps = {
1552
1308
  },
1553
1309
  };
1554
1310
  const getMRT_RowSpacerColumnDef = (tableOptions) => {
1555
- if (!showRowSpacerColumn(tableOptions)) {
1556
- return null;
1557
- }
1558
1311
  return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumnProps({
1559
1312
  id: 'mrt-row-spacer',
1560
1313
  size: 0,
@@ -1562,24 +1315,12 @@ const getMRT_RowSpacerColumnDef = (tableOptions) => {
1562
1315
  })), { grow: true }), MRT_DefaultDisplayColumn), { muiTableBodyCellProps: blankColProps, muiTableFooterCellProps: blankColProps, muiTableHeadCellProps: blankColProps });
1563
1316
  };
1564
1317
 
1565
- const getMRT_DisplayColumns = (tableOptions) => {
1566
- return [
1567
- getMRT_RowNumbersColumnDef(tableOptions),
1568
- getMRT_RowSelectColumnDef(tableOptions),
1569
- getMRT_RowExpandColumnDef(tableOptions),
1570
- getMRT_RowActionsColumnDef(tableOptions),
1571
- getMRT_RowDragColumnDef(tableOptions),
1572
- getMRT_RowPinningColumnDef(tableOptions),
1573
- getMRT_RowSpacerColumnDef(tableOptions),
1574
- ].filter(Boolean);
1575
- };
1576
-
1577
1318
  const useMRT_Effects = (table) => {
1578
1319
  const { getIsSomeRowsPinned, getPrePaginationRowModel, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
1579
- const { density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
1320
+ const { columnOrder, density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
1321
+ const totalColumnCount = table.options.columns.length;
1580
1322
  const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
1581
1323
  const rerender = useReducer(() => ({}), {})[1];
1582
- const isMounted = useRef(false);
1583
1324
  const initialBodyHeight = useRef();
1584
1325
  const previousTop = useRef();
1585
1326
  useEffect(() => {
@@ -1587,11 +1328,12 @@ const useMRT_Effects = (table) => {
1587
1328
  initialBodyHeight.current = document.body.style.height;
1588
1329
  }
1589
1330
  }, []);
1331
+ //hide scrollbars when table is in full screen mode, preserve body scroll position after full screen exit
1590
1332
  useEffect(() => {
1591
- if (isMounted && typeof window !== 'undefined') {
1333
+ if (typeof window !== 'undefined') {
1592
1334
  if (isFullScreen) {
1593
1335
  previousTop.current = document.body.getBoundingClientRect().top; //save scroll position
1594
- document.body.style.height = '100vh'; //hide page scrollbars when table is in full screen mode
1336
+ document.body.style.height = '100dvh'; //hide page scrollbars when table is in full screen mode
1595
1337
  }
1596
1338
  else {
1597
1339
  document.body.style.height = initialBodyHeight.current;
@@ -1604,8 +1346,13 @@ const useMRT_Effects = (table) => {
1604
1346
  });
1605
1347
  }
1606
1348
  }
1607
- isMounted.current = true;
1608
1349
  }, [isFullScreen]);
1350
+ //recalculate column order when columns change or features are toggled on/off
1351
+ useEffect(() => {
1352
+ if (totalColumnCount !== columnOrder.length) {
1353
+ table.setColumnOrder(getDefaultColumnOrderIds(table.options));
1354
+ }
1355
+ }, [totalColumnCount]);
1609
1356
  //if page index is out of bounds, set it to the last page
1610
1357
  useEffect(() => {
1611
1358
  if (!enablePagination || isLoading || showSkeletons)
@@ -1633,6 +1380,7 @@ const useMRT_Effects = (table) => {
1633
1380
  table.setSorting(() => appliedSort.current || []);
1634
1381
  }
1635
1382
  }, [globalFilter]);
1383
+ //fix pinned row top style when density changes
1636
1384
  useEffect(() => {
1637
1385
  if (enableRowPinning && getIsSomeRowsPinned()) {
1638
1386
  setTimeout(() => {
@@ -1642,8 +1390,15 @@ const useMRT_Effects = (table) => {
1642
1390
  }, [density]);
1643
1391
  };
1644
1392
 
1645
- const useMRT_TableInstance = (_tableOptions) => {
1646
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
1393
+ /**
1394
+ * The MRT hook that wraps the TanStack useReactTable hook and adds additional functionality
1395
+ * @param definedTableOptions - table options with proper defaults set
1396
+ * @returns the MRT table instance
1397
+ */
1398
+ const useMRT_TableInstance = (definedTableOptions) => {
1399
+ 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;
1400
+ const lastSelectedRowId = useRef(null);
1401
+ const actionCellRef = useRef(null);
1647
1402
  const bottomToolbarRef = useRef(null);
1648
1403
  const editInputRefs = useRef({});
1649
1404
  const filterInputRefs = useRef({});
@@ -1654,17 +1409,19 @@ const useMRT_TableInstance = (_tableOptions) => {
1654
1409
  const topToolbarRef = useRef(null);
1655
1410
  const tableHeadRef = useRef(null);
1656
1411
  const tableFooterRef = useRef(null);
1412
+ //transform initial state with proper column order
1657
1413
  const initialState = useMemo(() => {
1658
1414
  var _a, _b, _c;
1659
- const initState = (_a = _tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
1415
+ const initState = (_a = definedTableOptions.initialState) !== null && _a !== void 0 ? _a : {};
1660
1416
  initState.columnOrder =
1661
- (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(Object.assign(Object.assign({}, _tableOptions), { state: Object.assign(Object.assign({}, _tableOptions.initialState), _tableOptions.state) }));
1662
- initState.globalFilterFn = (_c = _tableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
1417
+ (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(Object.assign(Object.assign({}, definedTableOptions), { state: Object.assign(Object.assign({}, definedTableOptions.initialState), definedTableOptions.state) }));
1418
+ initState.globalFilterFn = (_c = definedTableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
1663
1419
  return initState;
1664
1420
  }, []);
1665
- _tableOptions.initialState = initialState;
1666
- const [creatingRow, _setCreatingRow] = useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
1667
- const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(_tableOptions.columns).map((col) => {
1421
+ definedTableOptions.initialState = initialState;
1422
+ const [actionCell, setActionCell] = useState((_a = initialState.actionCell) !== null && _a !== void 0 ? _a : null);
1423
+ const [creatingRow, _setCreatingRow] = useState((_b = initialState.creatingRow) !== null && _b !== void 0 ? _b : null);
1424
+ const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(definedTableOptions.columns).map((col) => {
1668
1425
  var _a, _b, _c, _d;
1669
1426
  return ({
1670
1427
  [getColumnId(col)]: col.filterFn instanceof Function
@@ -1672,24 +1429,25 @@ const useMRT_TableInstance = (_tableOptions) => {
1672
1429
  : (_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col),
1673
1430
  });
1674
1431
  })));
1675
- const [columnOrder, onColumnOrderChange] = useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
1676
- const [columnSizingInfo, onColumnSizingInfoChange] = useState((_c = initialState.columnSizingInfo) !== null && _c !== void 0 ? _c : {});
1677
- const [density, setDensity] = useState((_d = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _d !== void 0 ? _d : 'comfortable');
1678
- const [draggingColumn, setDraggingColumn] = useState((_e = initialState.draggingColumn) !== null && _e !== void 0 ? _e : null);
1679
- const [draggingRow, setDraggingRow] = useState((_f = initialState.draggingRow) !== null && _f !== void 0 ? _f : null);
1680
- const [editingCell, setEditingCell] = useState((_g = initialState.editingCell) !== null && _g !== void 0 ? _g : null);
1681
- const [editingRow, setEditingRow] = useState((_h = initialState.editingRow) !== null && _h !== void 0 ? _h : null);
1682
- const [globalFilterFn, setGlobalFilterFn] = useState((_j = initialState.globalFilterFn) !== null && _j !== void 0 ? _j : 'fuzzy');
1683
- const [grouping, onGroupingChange] = useState((_k = initialState.grouping) !== null && _k !== void 0 ? _k : []);
1684
- const [hoveredColumn, setHoveredColumn] = useState((_l = initialState.hoveredColumn) !== null && _l !== void 0 ? _l : null);
1685
- const [hoveredRow, setHoveredRow] = useState((_m = initialState.hoveredRow) !== null && _m !== void 0 ? _m : null);
1686
- const [isFullScreen, setIsFullScreen] = useState((_o = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _o !== void 0 ? _o : false);
1687
- const [pagination, onPaginationChange] = useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _p !== void 0 ? _p : { pageIndex: 0, pageSize: 10 });
1688
- const [showAlertBanner, setShowAlertBanner] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _q !== void 0 ? _q : false);
1689
- const [showColumnFilters, setShowColumnFilters] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _r !== void 0 ? _r : false);
1690
- const [showGlobalFilter, setShowGlobalFilter] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _s !== void 0 ? _s : false);
1691
- const [showToolbarDropZone, setShowToolbarDropZone] = useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _t !== void 0 ? _t : false);
1692
- _tableOptions.state = Object.assign({ columnFilterFns,
1432
+ const [columnOrder, onColumnOrderChange] = useState((_c = initialState.columnOrder) !== null && _c !== void 0 ? _c : []);
1433
+ const [columnSizingInfo, onColumnSizingInfoChange] = useState((_d = initialState.columnSizingInfo) !== null && _d !== void 0 ? _d : {});
1434
+ const [density, setDensity] = useState((_e = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _e !== void 0 ? _e : 'comfortable');
1435
+ const [draggingColumn, setDraggingColumn] = useState((_f = initialState.draggingColumn) !== null && _f !== void 0 ? _f : null);
1436
+ const [draggingRow, setDraggingRow] = useState((_g = initialState.draggingRow) !== null && _g !== void 0 ? _g : null);
1437
+ const [editingCell, setEditingCell] = useState((_h = initialState.editingCell) !== null && _h !== void 0 ? _h : null);
1438
+ const [editingRow, setEditingRow] = useState((_j = initialState.editingRow) !== null && _j !== void 0 ? _j : null);
1439
+ const [globalFilterFn, setGlobalFilterFn] = useState((_k = initialState.globalFilterFn) !== null && _k !== void 0 ? _k : 'fuzzy');
1440
+ const [grouping, onGroupingChange] = useState((_l = initialState.grouping) !== null && _l !== void 0 ? _l : []);
1441
+ const [hoveredColumn, setHoveredColumn] = useState((_m = initialState.hoveredColumn) !== null && _m !== void 0 ? _m : null);
1442
+ const [hoveredRow, setHoveredRow] = useState((_o = initialState.hoveredRow) !== null && _o !== void 0 ? _o : null);
1443
+ const [isFullScreen, setIsFullScreen] = useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _p !== void 0 ? _p : false);
1444
+ const [pagination, onPaginationChange] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _q !== void 0 ? _q : { pageIndex: 0, pageSize: 10 });
1445
+ const [showAlertBanner, setShowAlertBanner] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _r !== void 0 ? _r : false);
1446
+ const [showColumnFilters, setShowColumnFilters] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _s !== void 0 ? _s : false);
1447
+ const [showGlobalFilter, setShowGlobalFilter] = useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _t !== void 0 ? _t : false);
1448
+ const [showToolbarDropZone, setShowToolbarDropZone] = useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _u !== void 0 ? _u : false);
1449
+ definedTableOptions.state = Object.assign({ actionCell,
1450
+ columnFilterFns,
1693
1451
  columnOrder,
1694
1452
  columnSizingInfo,
1695
1453
  creatingRow,
@@ -1707,90 +1465,111 @@ const useMRT_TableInstance = (_tableOptions) => {
1707
1465
  showAlertBanner,
1708
1466
  showColumnFilters,
1709
1467
  showGlobalFilter,
1710
- showToolbarDropZone }, _tableOptions.state);
1711
- const tableOptions = _tableOptions;
1468
+ showToolbarDropZone }, definedTableOptions.state);
1469
+ //The table options now include all state needed to help determine column visibility and order logic
1470
+ const statefulTableOptions = definedTableOptions;
1712
1471
  //don't recompute columnDefs while resizing column or dragging column/row
1713
1472
  const columnDefsRef = useRef([]);
1714
- tableOptions.columns =
1715
- tableOptions.state.columnSizingInfo.isResizingColumn ||
1716
- tableOptions.state.draggingColumn ||
1717
- tableOptions.state.draggingRow
1473
+ statefulTableOptions.columns =
1474
+ statefulTableOptions.state.columnSizingInfo.isResizingColumn ||
1475
+ statefulTableOptions.state.draggingColumn ||
1476
+ statefulTableOptions.state.draggingRow
1718
1477
  ? columnDefsRef.current
1719
1478
  : prepareColumns({
1720
1479
  columnDefs: [
1721
- ...getMRT_DisplayColumns(tableOptions),
1722
- ...tableOptions.columns,
1480
+ ...[
1481
+ showRowPinningColumn(statefulTableOptions) &&
1482
+ getMRT_RowPinningColumnDef(statefulTableOptions),
1483
+ showRowDragColumn(statefulTableOptions) &&
1484
+ getMRT_RowDragColumnDef(statefulTableOptions),
1485
+ showRowActionsColumn(statefulTableOptions) &&
1486
+ getMRT_RowActionsColumnDef(statefulTableOptions),
1487
+ showRowExpandColumn(statefulTableOptions) &&
1488
+ getMRT_RowExpandColumnDef(statefulTableOptions),
1489
+ showRowSelectionColumn(statefulTableOptions) &&
1490
+ getMRT_RowSelectColumnDef(statefulTableOptions),
1491
+ showRowNumbersColumn(statefulTableOptions) &&
1492
+ getMRT_RowNumbersColumnDef(statefulTableOptions),
1493
+ ].filter(Boolean),
1494
+ ...statefulTableOptions.columns,
1495
+ ...[
1496
+ showRowSpacerColumn(statefulTableOptions) &&
1497
+ getMRT_RowSpacerColumnDef(statefulTableOptions),
1498
+ ].filter(Boolean),
1723
1499
  ],
1724
- tableOptions,
1500
+ tableOptions: statefulTableOptions,
1725
1501
  });
1726
- columnDefsRef.current = tableOptions.columns;
1727
- tableOptions.data = useMemo(() => (tableOptions.state.isLoading || tableOptions.state.showSkeletons) &&
1728
- !tableOptions.data.length
1502
+ columnDefsRef.current = statefulTableOptions.columns;
1503
+ //if loading, generate blank rows to show skeleton loaders
1504
+ statefulTableOptions.data = useMemo(() => (statefulTableOptions.state.isLoading ||
1505
+ statefulTableOptions.state.showSkeletons) &&
1506
+ !statefulTableOptions.data.length
1729
1507
  ? [
1730
- ...Array(Math.min(tableOptions.state.pagination.pageSize, 20)).fill(null),
1731
- ].map(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => ({
1508
+ ...Array(Math.min(statefulTableOptions.state.pagination.pageSize, 20)).fill(null),
1509
+ ].map(() => Object.assign({}, ...getAllLeafColumnDefs(statefulTableOptions.columns).map((col) => ({
1732
1510
  [getColumnId(col)]: null,
1733
1511
  }))))
1734
- : tableOptions.data, [
1735
- tableOptions.data,
1736
- tableOptions.state.isLoading,
1737
- tableOptions.state.showSkeletons,
1512
+ : statefulTableOptions.data, [
1513
+ statefulTableOptions.data,
1514
+ statefulTableOptions.state.isLoading,
1515
+ statefulTableOptions.state.showSkeletons,
1738
1516
  ]);
1739
1517
  //@ts-ignore
1740
1518
  const table = useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
1741
1519
  onColumnSizingInfoChange,
1742
1520
  onGroupingChange,
1743
- onPaginationChange }, tableOptions), { globalFilterFn: (_u = tableOptions.filterFns) === null || _u === void 0 ? void 0 : _u[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1744
- //@ts-ignore
1521
+ onPaginationChange }, statefulTableOptions), { globalFilterFn: (_v = statefulTableOptions.filterFns) === null || _v === void 0 ? void 0 : _v[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1745
1522
  table.refs = {
1746
- //@ts-ignore
1523
+ actionCellRef,
1747
1524
  bottomToolbarRef,
1748
1525
  editInputRefs,
1749
1526
  filterInputRefs,
1750
- //@ts-ignore
1527
+ lastSelectedRowId,
1751
1528
  searchInputRef,
1752
- //@ts-ignore
1753
1529
  tableContainerRef,
1754
- //@ts-ignore
1755
1530
  tableFooterRef,
1756
1531
  tableHeadCellRefs,
1757
- //@ts-ignore
1758
1532
  tableHeadRef,
1759
- //@ts-ignore
1760
1533
  tablePaperRef,
1761
- //@ts-ignore
1762
1534
  topToolbarRef,
1763
1535
  };
1536
+ table.setActionCell =
1537
+ (_w = statefulTableOptions.onActionCellChange) !== null && _w !== void 0 ? _w : setActionCell;
1764
1538
  table.setCreatingRow = (row) => {
1765
1539
  var _a, _b;
1766
1540
  let _row = row;
1767
1541
  if (row === true) {
1768
1542
  _row = createRow(table);
1769
1543
  }
1770
- (_b = (_a = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(tableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
1544
+ (_b = (_a = statefulTableOptions === null || statefulTableOptions === void 0 ? void 0 : statefulTableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(statefulTableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
1771
1545
  };
1772
1546
  table.setColumnFilterFns =
1773
- (_v = tableOptions.onColumnFilterFnsChange) !== null && _v !== void 0 ? _v : setColumnFilterFns;
1774
- table.setDensity = (_w = tableOptions.onDensityChange) !== null && _w !== void 0 ? _w : setDensity;
1547
+ (_x = statefulTableOptions.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns;
1548
+ table.setDensity = (_y = statefulTableOptions.onDensityChange) !== null && _y !== void 0 ? _y : setDensity;
1775
1549
  table.setDraggingColumn =
1776
- (_x = tableOptions.onDraggingColumnChange) !== null && _x !== void 0 ? _x : setDraggingColumn;
1777
- table.setDraggingRow = (_y = tableOptions.onDraggingRowChange) !== null && _y !== void 0 ? _y : setDraggingRow;
1778
- table.setEditingCell = (_z = tableOptions.onEditingCellChange) !== null && _z !== void 0 ? _z : setEditingCell;
1779
- table.setEditingRow = (_0 = tableOptions.onEditingRowChange) !== null && _0 !== void 0 ? _0 : setEditingRow;
1550
+ (_z = statefulTableOptions.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn;
1551
+ table.setDraggingRow =
1552
+ (_0 = statefulTableOptions.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow;
1553
+ table.setEditingCell =
1554
+ (_1 = statefulTableOptions.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell;
1555
+ table.setEditingRow =
1556
+ (_2 = statefulTableOptions.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow;
1780
1557
  table.setGlobalFilterFn =
1781
- (_1 = tableOptions.onGlobalFilterFnChange) !== null && _1 !== void 0 ? _1 : setGlobalFilterFn;
1558
+ (_3 = statefulTableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
1782
1559
  table.setHoveredColumn =
1783
- (_2 = tableOptions.onHoveredColumnChange) !== null && _2 !== void 0 ? _2 : setHoveredColumn;
1784
- table.setHoveredRow = (_3 = tableOptions.onHoveredRowChange) !== null && _3 !== void 0 ? _3 : setHoveredRow;
1785
- table.setIsFullScreen = (_4 = tableOptions.onIsFullScreenChange) !== null && _4 !== void 0 ? _4 : setIsFullScreen;
1560
+ (_4 = statefulTableOptions.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn;
1561
+ table.setHoveredRow =
1562
+ (_5 = statefulTableOptions.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow;
1563
+ table.setIsFullScreen =
1564
+ (_6 = statefulTableOptions.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen;
1786
1565
  table.setShowAlertBanner =
1787
- (_5 = tableOptions.onShowAlertBannerChange) !== null && _5 !== void 0 ? _5 : setShowAlertBanner;
1566
+ (_7 = statefulTableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
1788
1567
  table.setShowColumnFilters =
1789
- (_6 = tableOptions.onShowColumnFiltersChange) !== null && _6 !== void 0 ? _6 : setShowColumnFilters;
1568
+ (_8 = statefulTableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
1790
1569
  table.setShowGlobalFilter =
1791
- (_7 = tableOptions.onShowGlobalFilterChange) !== null && _7 !== void 0 ? _7 : setShowGlobalFilter;
1570
+ (_9 = statefulTableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
1792
1571
  table.setShowToolbarDropZone =
1793
- (_8 = tableOptions.onShowToolbarDropZoneChange) !== null && _8 !== void 0 ? _8 : setShowToolbarDropZone;
1572
+ (_10 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
1794
1573
  useMRT_Effects(table);
1795
1574
  return table;
1796
1575
  };
@@ -1901,71 +1680,26 @@ const useMRT_RowVirtualizer = (table, rows) => {
1901
1680
  };
1902
1681
 
1903
1682
  const useMRT_Rows = (table, pinnedRowIds = []) => {
1904
- const { getBottomRows, getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { createDisplayMode, enableGlobalFilterRankedResults, enablePagination, enableRowPinning, manualExpanding, manualFiltering, manualGrouping, manualPagination, manualSorting, positionCreatingRow, rowPinningDisplayMode, }, } = table;
1683
+ const { getRowModel, getState, options: { data, enableGlobalFilterRankedResults, positionCreatingRow }, } = table;
1905
1684
  const { creatingRow, expanded, globalFilter, pagination, rowPinning, sorting, } = getState();
1906
- const shouldRankRows = useMemo(() => getCanRankRows(table) &&
1907
- !Object.values(sorting).some(Boolean) &&
1908
- globalFilter, [
1685
+ const rows = useMemo(() => getMRT_Rows(table, pinnedRowIds), [
1686
+ creatingRow,
1687
+ data,
1909
1688
  enableGlobalFilterRankedResults,
1910
1689
  expanded,
1690
+ getRowModel().rows,
1911
1691
  globalFilter,
1912
- manualExpanding,
1913
- manualFiltering,
1914
- manualGrouping,
1915
- manualSorting,
1916
- sorting,
1917
- ]);
1918
- const rows = useMemo(() => {
1919
- let rows = [];
1920
- if (!shouldRankRows) {
1921
- rows =
1922
- !enableRowPinning || (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))
1923
- ? getRowModel().rows
1924
- : getCenterRows();
1925
- }
1926
- else {
1927
- rows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
1928
- if (enablePagination && !manualPagination) {
1929
- const start = pagination.pageIndex * pagination.pageSize;
1930
- rows = rows.slice(start, start + pagination.pageSize);
1931
- }
1932
- }
1933
- if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
1934
- rows = [
1935
- ...getTopRows().filter((row) => !pinnedRowIds.includes(row.id)),
1936
- ...rows,
1937
- ...getBottomRows().filter((row) => !pinnedRowIds.includes(row.id)),
1938
- ];
1939
- }
1940
- if (positionCreatingRow !== undefined &&
1941
- creatingRow &&
1942
- createDisplayMode === 'row') {
1943
- const creatingRowIndex = !isNaN(+positionCreatingRow)
1944
- ? +positionCreatingRow
1945
- : positionCreatingRow === 'top'
1946
- ? 0
1947
- : rows.length;
1948
- rows = [
1949
- ...rows.slice(0, creatingRowIndex),
1950
- creatingRow,
1951
- ...rows.slice(creatingRowIndex),
1952
- ];
1953
- }
1954
- return rows;
1955
- }, [
1956
- creatingRow,
1957
1692
  pagination.pageIndex,
1958
1693
  pagination.pageSize,
1959
1694
  positionCreatingRow,
1960
1695
  rowPinning,
1961
- shouldRankRows ? getPrePaginationRowModel().rows : getRowModel().rows,
1962
- shouldRankRows,
1696
+ sorting,
1963
1697
  ]);
1964
1698
  return rows;
1965
1699
  };
1966
1700
 
1967
1701
  const allowedTypes = ['string', 'number'];
1968
- const MRT_TableBodyCellValue = ({ cell, rowRef, staticRowIndex, table, }) => {
1702
+ const MRT_TableBodyCellValue = ({ cell, rowRef, staticColumnIndex, staticRowIndex, table, }) => {
1969
1703
  var _a, _b, _c;
1970
1704
  const { getState, options: { enableFilterMatchHighlighting }, } = table;
1971
1705
  const { column, row } = cell;
@@ -2028,6 +1762,7 @@ const MRT_TableBodyCellValue = ({ cell, rowRef, staticRowIndex, table, }) => {
2028
1762
  renderedCellValue,
2029
1763
  row,
2030
1764
  rowRef,
1765
+ staticColumnIndex,
2031
1766
  staticRowIndex,
2032
1767
  table,
2033
1768
  });
@@ -2059,7 +1794,7 @@ const MRT_CopyButton = (_a) => {
2059
1794
  row,
2060
1795
  table,
2061
1796
  })), rest);
2062
- return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _b !== void 0 ? _b : (copied ? localization.copiedToClipboard : localization.clickToCopy), children: jsx(Button, Object.assign({ onClick: (e) => handleCopy(e, cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', textAlign: 'inherit', textTransform: 'inherit' }, parseFromValuesOrFunc(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx, theme))), title: undefined })) })));
1797
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _b !== void 0 ? _b : (copied ? localization.copiedToClipboard : localization.clickToCopy), children: jsx(Button, Object.assign({ onClick: (e) => handleCopy(e, cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', py: 0, textAlign: 'inherit', textTransform: 'inherit' }, parseFromValuesOrFunc(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx, theme))), title: undefined })) })));
2063
1798
  };
2064
1799
 
2065
1800
  const MRT_EditCellTextField = (_a) => {
@@ -2160,10 +1895,10 @@ const MRT_EditCellTextField = (_a) => {
2160
1895
 
2161
1896
  const MRT_TableBodyCell = (_a) => {
2162
1897
  var _b, _c, _d, _e, _f;
2163
- var { cell, measureElement, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "measureElement", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
1898
+ var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
2164
1899
  const theme = useTheme();
2165
- const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableEditing, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
2166
- const { columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
1900
+ const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
1901
+ const { actionCell, columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
2167
1902
  const { column, row } = cell;
2168
1903
  const { columnDef } = column;
2169
1904
  const { columnDefType } = columnDef;
@@ -2236,9 +1971,7 @@ const MRT_TableBodyCell = (_a) => {
2236
1971
  const isColumnPinned = enableColumnPinning &&
2237
1972
  columnDef.columnDefType !== 'group' &&
2238
1973
  column.getIsPinned();
2239
- const isEditable = !cell.getIsPlaceholder() &&
2240
- parseFromValuesOrFunc(enableEditing, row) &&
2241
- parseFromValuesOrFunc(columnDef.enableEditing, row) !== false;
1974
+ const isEditable = isCellEditable({ cell, table });
2242
1975
  const isEditing = isEditable &&
2243
1976
  !['custom', 'modal'].includes(editDisplayMode) &&
2244
1977
  (editDisplayMode === 'table' ||
@@ -2246,20 +1979,20 @@ const MRT_TableBodyCell = (_a) => {
2246
1979
  (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id) &&
2247
1980
  !row.getIsGrouped();
2248
1981
  const isCreating = isEditable && createDisplayMode === 'row' && (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
1982
+ const showClickToCopyButton = (parseFromValuesOrFunc(enableClickToCopy, cell) === true ||
1983
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) === true) &&
1984
+ !['context-menu', false].includes(
1985
+ // @ts-ignore
1986
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell));
1987
+ const isRightClickable = parseFromValuesOrFunc(enableCellActions, cell);
1988
+ const cellValueProps = {
1989
+ cell,
1990
+ table,
1991
+ };
2249
1992
  const handleDoubleClick = (event) => {
2250
1993
  var _a;
2251
1994
  (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDoubleClick) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2252
- if (isEditable && editDisplayMode === 'cell') {
2253
- setEditingCell(cell);
2254
- queueMicrotask(() => {
2255
- var _a;
2256
- const textField = editInputRefs.current[column.id];
2257
- if (textField) {
2258
- textField.focus();
2259
- (_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
2260
- }
2261
- });
2262
- }
1995
+ openEditingCell({ cell, table });
2263
1996
  };
2264
1997
  const handleDragEnter = (e) => {
2265
1998
  var _a;
@@ -2271,22 +2004,29 @@ const MRT_TableBodyCell = (_a) => {
2271
2004
  setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
2272
2005
  }
2273
2006
  };
2274
- const cellValueProps = {
2275
- cell,
2276
- table,
2007
+ const handleContextMenu = (e) => {
2008
+ var _a;
2009
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onContextMenu) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
2010
+ if (isRightClickable) {
2011
+ e.preventDefault();
2012
+ table.setActionCell(cell);
2013
+ table.refs.actionCellRef.current = e.currentTarget;
2014
+ }
2277
2015
  };
2278
- return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, ref: (node) => {
2279
- if (node) {
2280
- measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
2281
- }
2282
- } }, tableCellProps, { onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
2283
- outline: (editDisplayMode === 'cell' && isEditable) ||
2016
+ return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined }, tableCellProps, { onContextMenu: handleContextMenu, onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
2017
+ outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
2018
+ (editDisplayMode === 'cell' && isEditable) ||
2284
2019
  (editDisplayMode === 'table' && (isCreating || isEditing))
2285
2020
  ? `1px solid ${theme.palette.grey[500]}`
2286
2021
  : undefined,
2287
- outlineOffset: '-1px',
2288
2022
  textOverflow: 'clip',
2289
- }, alignItems: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'center' : undefined, cursor: isEditable && editDisplayMode === 'cell' ? 'pointer' : 'inherit', overflow: 'hidden', p: density === 'compact'
2023
+ }, alignItems: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'center' : undefined, cursor: isRightClickable
2024
+ ? 'context-menu'
2025
+ : isEditable && editDisplayMode === 'cell'
2026
+ ? 'pointer'
2027
+ : 'inherit', outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id
2028
+ ? `1px solid ${theme.palette.grey[500]}`
2029
+ : undefined, outlineOffset: '-1px', overflow: 'hidden', p: density === 'compact'
2290
2030
  ? columnDefType === 'display'
2291
2031
  ? '0 0.5rem'
2292
2032
  : '0.5rem'
@@ -2309,10 +2049,10 @@ const MRT_TableBodyCell = (_a) => {
2309
2049
  renderedCellValue: cell.renderValue(),
2310
2050
  row,
2311
2051
  rowRef,
2052
+ staticColumnIndex,
2312
2053
  staticRowIndex,
2313
2054
  table,
2314
- })) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
2315
- columnDef.enableClickToCopy !== false ? (jsx(MRT_CopyButton, { cell: cell, table: table, children: jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps)) })) : (jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps))), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxs(Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
2055
+ })) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : showClickToCopyButton && columnDef.enableClickToCopy !== false ? (jsx(MRT_CopyButton, { cell: cell, table: table, children: jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps)) })) : (jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps))), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxs(Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
2316
2056
  };
2317
2057
  const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
2318
2058
 
@@ -2350,8 +2090,9 @@ const MRT_TableDetailPanel = (_a) => {
2350
2090
  : undefined, width: `100%` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: enableRowVirtualization ? (row.getIsExpanded() && DetailPanel) : (jsx(Collapse, { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: DetailPanel })) })) })));
2351
2091
  };
2352
2092
 
2353
- const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow, }) => {
2354
- var _a, _b, _c, _d;
2093
+ const MRT_TableBodyRow = (_a) => {
2094
+ var _b, _c, _d, _f;
2095
+ var { columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow } = _a, rest = __rest(_a, ["columnVirtualizer", "numRows", "pinnedRowIds", "row", "rowVirtualizer", "staticRowIndex", "table", "virtualRow"]);
2355
2096
  const theme = useTheme();
2356
2097
  const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
2357
2098
  const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
@@ -2361,11 +2102,11 @@ const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVi
2361
2102
  const isRowPinned = enableRowPinning && row.getIsPinned();
2362
2103
  const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
2363
2104
  const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
2364
- const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
2105
+ const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyRowProps, {
2365
2106
  row,
2366
2107
  staticRowIndex,
2367
2108
  table,
2368
- });
2109
+ })), rest);
2369
2110
  const [bottomPinnedIndex, topPinnedIndex] = useMemo(() => {
2370
2111
  if (!enableRowPinning ||
2371
2112
  !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) ||
@@ -2378,14 +2119,14 @@ const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVi
2378
2119
  ];
2379
2120
  }, [pinnedRowIds, rowPinning]);
2380
2121
  const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
2381
- ((_a = tableHeadRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight)) ||
2122
+ ((_b = tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) ||
2382
2123
  0;
2383
- const tableFooterHeight = (enableStickyFooter && ((_b = tableFooterRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) || 0;
2124
+ const tableFooterHeight = (enableStickyFooter && ((_c = tableFooterRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight)) || 0;
2384
2125
  const sx = parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme);
2385
2126
  const defaultRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
2386
2127
  const customRowHeight =
2387
2128
  // @ts-ignore
2388
- parseInt((_d = (_c = tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : sx === null || sx === void 0 ? void 0 : sx.height, 10) || undefined;
2129
+ parseInt((_f = (_d = tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style) === null || _d === void 0 ? void 0 : _d.height) !== null && _f !== void 0 ? _f : sx === null || sx === void 0 ? void 0 : sx.height, 10) || undefined;
2389
2130
  const rowHeight = customRowHeight || defaultRowHeight;
2390
2131
  const handleDragEnter = (_e) => {
2391
2132
  if (enableRowOrdering && draggingRow) {
@@ -2435,9 +2176,6 @@ const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVi
2435
2176
  }
2436
2177
  const props = {
2437
2178
  cell,
2438
- measureElement: !isDraggingRow && !isHoveredRow
2439
- ? columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement
2440
- : undefined,
2441
2179
  numRows,
2442
2180
  rowRef,
2443
2181
  staticColumnIndex,
@@ -2531,89 +2269,427 @@ const MRT_TableBody = (_a) => {
2531
2269
  return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
2532
2270
  }) })))] }));
2533
2271
  };
2534
- const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
2272
+ const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
2273
+
2274
+ const MRT_TableFooterCell = (_a) => {
2275
+ var _b, _c, _d;
2276
+ var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
2277
+ const theme = useTheme();
2278
+ const { getState, options: { enableColumnPinning, muiTableFooterCellProps }, } = table;
2279
+ const { density } = getState();
2280
+ const { column } = footer;
2281
+ const { columnDef } = column;
2282
+ const { columnDefType } = columnDef;
2283
+ const isColumnPinned = enableColumnPinning &&
2284
+ columnDef.columnDefType !== 'group' &&
2285
+ column.getIsPinned();
2286
+ const args = { column, table };
2287
+ const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
2288
+ return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
2289
+ ? 'center'
2290
+ : theme.direction === 'rtl'
2291
+ ? 'right'
2292
+ : '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'
2293
+ ? '0.5rem'
2294
+ : density === 'comfortable'
2295
+ ? '1rem'
2296
+ : '1.5rem', verticalAlign: 'top' }, getCommonMRTCellStyles({
2297
+ column,
2298
+ header: footer,
2299
+ table,
2300
+ tableCellProps,
2301
+ theme,
2302
+ })), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (footer.isPlaceholder
2303
+ ? null
2304
+ : (_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
2305
+ column,
2306
+ footer,
2307
+ table,
2308
+ })) !== null && _c !== void 0 ? _c : columnDef.footer) !== null && _d !== void 0 ? _d : null) })));
2309
+ };
2310
+
2311
+ const MRT_TableFooterRow = (_a) => {
2312
+ var _b;
2313
+ var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
2314
+ const { options: { layoutMode, muiTableFooterRowProps }, } = table;
2315
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2316
+ // if no content in row, skip row
2317
+ if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
2318
+ !!header.column.columnDef.footer) ||
2319
+ header.column.columnDef.Footer))) {
2320
+ return null;
2321
+ }
2322
+ const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterRowProps, {
2323
+ footerGroup,
2324
+ table,
2325
+ })), rest);
2326
+ return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: getMRTTheme(table, theme).baseBackgroundColor, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: 'relative', width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter, staticColumnIndex) => {
2327
+ let footer = footerOrVirtualFooter;
2328
+ if (columnVirtualizer) {
2329
+ staticColumnIndex = footerOrVirtualFooter
2330
+ .index;
2331
+ footer = footerGroup.headers[staticColumnIndex];
2332
+ }
2333
+ return footer ? (jsx(MRT_TableFooterCell, { footer: footer, staticColumnIndex: staticColumnIndex, table: table }, footer.id)) : null;
2334
+ }), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
2335
+ };
2336
+
2337
+ const MRT_TableFooter = (_a) => {
2338
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2339
+ const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
2340
+ const { isFullScreen } = getState();
2341
+ const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
2342
+ table,
2343
+ })), rest);
2344
+ const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
2345
+ return (jsx(TableFooter, Object.assign({}, tableFooterProps, { ref: (ref) => {
2346
+ tableFooterRef.current = ref;
2347
+ if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
2348
+ // @ts-ignore
2349
+ tableFooterProps.ref.current = ref;
2350
+ }
2351
+ }, 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
2352
+ ? theme.palette.mode === 'light'
2353
+ ? `1px solid ${theme.palette.grey[300]}`
2354
+ : `1px solid ${theme.palette.grey[700]}`
2355
+ : undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
2356
+ };
2357
+
2358
+ const mrtFilterOptions = (localization) => [
2359
+ {
2360
+ divider: false,
2361
+ label: localization.filterFuzzy,
2362
+ option: 'fuzzy',
2363
+ symbol: '≈',
2364
+ },
2365
+ {
2366
+ divider: false,
2367
+ label: localization.filterContains,
2368
+ option: 'contains',
2369
+ symbol: '*',
2370
+ },
2371
+ {
2372
+ divider: false,
2373
+ label: localization.filterStartsWith,
2374
+ option: 'startsWith',
2375
+ symbol: 'a',
2376
+ },
2377
+ {
2378
+ divider: true,
2379
+ label: localization.filterEndsWith,
2380
+ option: 'endsWith',
2381
+ symbol: 'z',
2382
+ },
2383
+ {
2384
+ divider: false,
2385
+ label: localization.filterEquals,
2386
+ option: 'equals',
2387
+ symbol: '=',
2388
+ },
2389
+ {
2390
+ divider: true,
2391
+ label: localization.filterNotEquals,
2392
+ option: 'notEquals',
2393
+ symbol: '≠',
2394
+ },
2395
+ {
2396
+ divider: false,
2397
+ label: localization.filterBetween,
2398
+ option: 'between',
2399
+ symbol: '⇿',
2400
+ },
2401
+ {
2402
+ divider: true,
2403
+ label: localization.filterBetweenInclusive,
2404
+ option: 'betweenInclusive',
2405
+ symbol: '⬌',
2406
+ },
2407
+ {
2408
+ divider: false,
2409
+ label: localization.filterGreaterThan,
2410
+ option: 'greaterThan',
2411
+ symbol: '>',
2412
+ },
2413
+ {
2414
+ divider: false,
2415
+ label: localization.filterGreaterThanOrEqualTo,
2416
+ option: 'greaterThanOrEqualTo',
2417
+ symbol: '≥',
2418
+ },
2419
+ {
2420
+ divider: false,
2421
+ label: localization.filterLessThan,
2422
+ option: 'lessThan',
2423
+ symbol: '<',
2424
+ },
2425
+ {
2426
+ divider: true,
2427
+ label: localization.filterLessThanOrEqualTo,
2428
+ option: 'lessThanOrEqualTo',
2429
+ symbol: '≤',
2430
+ },
2431
+ {
2432
+ divider: false,
2433
+ label: localization.filterEmpty,
2434
+ option: 'empty',
2435
+ symbol: '∅',
2436
+ },
2437
+ {
2438
+ divider: false,
2439
+ label: localization.filterNotEmpty,
2440
+ option: 'notEmpty',
2441
+ symbol: '!∅',
2442
+ },
2443
+ ];
2444
+ const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
2445
+ const emptyModes = ['empty', 'notEmpty'];
2446
+ const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
2447
+ const rangeVariants = ['range-slider', 'date-range', 'datetime-range', 'range'];
2448
+ const MRT_FilterOptionMenu = (_a) => {
2449
+ var _b, _c, _d, _e;
2450
+ var { anchorEl, header, onSelect, setAnchorEl, setFilterValue, table } = _a, rest = __rest(_a, ["anchorEl", "header", "onSelect", "setAnchorEl", "setFilterValue", "table"]);
2451
+ const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
2452
+ const { density, globalFilterFn } = getState();
2453
+ const { column } = header !== null && header !== void 0 ? header : {};
2454
+ const { columnDef } = column !== null && column !== void 0 ? column : {};
2455
+ const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
2456
+ let allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
2457
+ if (rangeVariants.includes(columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant)) {
2458
+ allowedColumnFilterOptions = [
2459
+ ...rangeModes,
2460
+ ...(allowedColumnFilterOptions !== null && allowedColumnFilterOptions !== void 0 ? allowedColumnFilterOptions : []),
2461
+ ].filter((option) => rangeModes.includes(option));
2462
+ }
2463
+ const internalFilterOptions = useMemo(() => mrtFilterOptions(localization).filter((filterOption) => columnDef
2464
+ ? allowedColumnFilterOptions === undefined ||
2465
+ (allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.includes(filterOption.option))
2466
+ : (!globalFilterModeOptions ||
2467
+ globalFilterModeOptions.includes(filterOption.option)) &&
2468
+ ['contains', 'fuzzy', 'startsWith'].includes(filterOption.option)), []);
2469
+ const handleSelectFilterMode = (option) => {
2470
+ var _a, _b;
2471
+ const prevFilterMode = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef._filterFn) !== null && _a !== void 0 ? _a : '';
2472
+ if (!header || !column) {
2473
+ // global filter mode
2474
+ setGlobalFilterFn(option);
2475
+ }
2476
+ else if (option !== prevFilterMode) {
2477
+ // column filter mode
2478
+ setColumnFilterFns((prev) => (Object.assign(Object.assign({}, prev), { [header.id]: option })));
2479
+ // reset filter value and/or perform new filter render
2480
+ if (emptyModes.includes(option)) {
2481
+ // will now be empty/notEmpty filter mode
2482
+ if (currentFilterValue !== ' ' &&
2483
+ !emptyModes.includes(prevFilterMode)) {
2484
+ column.setFilterValue(' ');
2485
+ }
2486
+ else if (currentFilterValue) {
2487
+ column.setFilterValue(currentFilterValue); // perform new filter render
2488
+ }
2489
+ }
2490
+ else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
2491
+ arrModes.includes(option)) {
2492
+ // will now be array filter mode
2493
+ if (currentFilterValue instanceof String ||
2494
+ (currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.length)) {
2495
+ column.setFilterValue([]);
2496
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue([]);
2497
+ }
2498
+ else if (currentFilterValue) {
2499
+ column.setFilterValue(currentFilterValue); // perform new filter render
2500
+ }
2501
+ }
2502
+ else if (((_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === null || _b === void 0 ? void 0 : _b.includes('range')) ||
2503
+ rangeModes.includes(option)) {
2504
+ // will now be range filter mode
2505
+ if (!Array.isArray(currentFilterValue) ||
2506
+ (!(currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.every((v) => v === '')) &&
2507
+ !rangeModes.includes(prevFilterMode))) {
2508
+ column.setFilterValue(['', '']);
2509
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
2510
+ }
2511
+ else {
2512
+ column.setFilterValue(currentFilterValue); // perform new filter render
2513
+ }
2514
+ }
2515
+ else {
2516
+ // will now be single value filter mode
2517
+ if (Array.isArray(currentFilterValue)) {
2518
+ column.setFilterValue('');
2519
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
2520
+ }
2521
+ else if (currentFilterValue === ' ' &&
2522
+ emptyModes.includes(prevFilterMode)) {
2523
+ column.setFilterValue(undefined);
2524
+ }
2525
+ else {
2526
+ column.setFilterValue(currentFilterValue); // perform new filter render
2527
+ }
2528
+ }
2529
+ }
2530
+ setAnchorEl(null);
2531
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect();
2532
+ };
2533
+ const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
2534
+ const theme = useTheme();
2535
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
2536
+ return (jsx(Menu, Object.assign({ MenuListProps: {
2537
+ dense: density === 'compact',
2538
+ sx: {
2539
+ backgroundColor: menuBackgroundColor,
2540
+ },
2541
+ }, anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_e = (header && column && columnDef
2542
+ ? (_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
2543
+ column: column,
2544
+ internalFilterOptions,
2545
+ onSelectFilterMode: handleSelectFilterMode,
2546
+ table,
2547
+ })) !== null && _d !== void 0 ? _d : renderColumnFilterModeMenuItems === null || renderColumnFilterModeMenuItems === void 0 ? void 0 : renderColumnFilterModeMenuItems({
2548
+ column: column,
2549
+ internalFilterOptions,
2550
+ onSelectFilterMode: handleSelectFilterMode,
2551
+ table,
2552
+ })
2553
+ : renderGlobalFilterModeMenuItems === null || renderGlobalFilterModeMenuItems === void 0 ? void 0 : renderGlobalFilterModeMenuItems({
2554
+ internalFilterOptions,
2555
+ onSelectFilterMode: handleSelectFilterMode,
2556
+ table,
2557
+ }))) !== null && _e !== void 0 ? _e : internalFilterOptions.map(({ divider, label, option, symbol }, index) => (jsx(MRT_ActionMenuItem, { divider: divider, icon: symbol, label: label, onClick: () => handleSelectFilterMode(option), selected: option === filterOption, table: table, value: option }, index))) })));
2558
+ };
2535
2559
 
2536
- const MRT_TableFooterCell = (_a) => {
2537
- var _b, _c, _d;
2538
- var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
2539
- const theme = useTheme();
2540
- const { getState, options: { enableColumnPinning, muiTableFooterCellProps }, } = table;
2541
- const { density } = getState();
2542
- const { column } = footer;
2560
+ const MRT_ColumnActionMenu = (_a) => {
2561
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2562
+ var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
2563
+ const { getAllLeafColumns, getState, 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;
2564
+ const { column } = header;
2543
2565
  const { columnDef } = column;
2544
- const { columnDefType } = columnDef;
2545
- const isColumnPinned = enableColumnPinning &&
2546
- columnDef.columnDefType !== 'group' &&
2547
- column.getIsPinned();
2548
- const args = { column, table };
2549
- const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
2550
- return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
2551
- ? 'center'
2552
- : theme.direction === 'rtl'
2553
- ? 'right'
2554
- : 'left', colSpan: footer.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, variant: "footer" }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', p: density === 'compact'
2555
- ? '0.5rem'
2556
- : density === 'comfortable'
2557
- ? '1rem'
2558
- : '1.5rem', verticalAlign: 'top' }, getCommonMRTCellStyles({
2566
+ const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
2567
+ const columnFilterValue = column.getFilterValue();
2568
+ const [filterMenuAnchorEl, setFilterMenuAnchorEl] = useState(null);
2569
+ const handleClearSort = () => {
2570
+ column.clearSorting();
2571
+ setAnchorEl(null);
2572
+ };
2573
+ const handleSortAsc = () => {
2574
+ column.toggleSorting(false);
2575
+ setAnchorEl(null);
2576
+ };
2577
+ const handleSortDesc = () => {
2578
+ column.toggleSorting(true);
2579
+ setAnchorEl(null);
2580
+ };
2581
+ const handleResetColumnSize = () => {
2582
+ setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
2583
+ column.resetSize();
2584
+ setAnchorEl(null);
2585
+ };
2586
+ const handleHideColumn = () => {
2587
+ column.toggleVisibility(false);
2588
+ setAnchorEl(null);
2589
+ };
2590
+ const handlePinColumn = (pinDirection) => {
2591
+ column.pin(pinDirection);
2592
+ setAnchorEl(null);
2593
+ };
2594
+ const handleGroupByColumn = () => {
2595
+ column.toggleGrouping();
2596
+ setColumnOrder((old) => ['mrt-row-expand', ...old]);
2597
+ setAnchorEl(null);
2598
+ };
2599
+ const handleClearFilter = () => {
2600
+ column.setFilterValue(undefined);
2601
+ setAnchorEl(null);
2602
+ if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
2603
+ setColumnFilterFns((prev) => {
2604
+ var _a;
2605
+ return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
2606
+ });
2607
+ }
2608
+ };
2609
+ const handleFilterByColumn = () => {
2610
+ setShowColumnFilters(true);
2611
+ queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); });
2612
+ setAnchorEl(null);
2613
+ };
2614
+ const handleShowAllColumns = () => {
2615
+ getAllLeafColumns()
2616
+ .filter((col) => col.columnDef.enableHiding !== false)
2617
+ .forEach((col) => col.toggleVisibility(true));
2618
+ setAnchorEl(null);
2619
+ };
2620
+ const handleOpenFilterModeMenu = (event) => {
2621
+ event.stopPropagation();
2622
+ setFilterMenuAnchorEl(event.currentTarget);
2623
+ };
2624
+ const isSelectFilter = !!columnDef.filterSelectOptions;
2625
+ const allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
2626
+ const showFilterModeSubMenu = enableColumnFilterModes &&
2627
+ columnDef.enableColumnFilterModes !== false &&
2628
+ !isSelectFilter &&
2629
+ (allowedColumnFilterOptions === undefined ||
2630
+ !!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
2631
+ const internalColumnMenuItems = [
2632
+ ...(enableSorting && column.getCanSort()
2633
+ ? [
2634
+ enableSortingRemoval !== false && (jsx(MRT_ActionMenuItem, { icon: jsx(ClearAllIcon, {}), label: localization.clearSort, onClick: handleClearSort, table: table }, 0)),
2635
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === 'asc', icon: jsx(SortIcon, { style: { transform: 'rotate(180deg) scaleX(-1)' } }), label: (_c = localization.sortByColumnAsc) === null || _c === void 0 ? void 0 : _c.replace('{column}', String(columnDef.header)), onClick: handleSortAsc, table: table }, 1),
2636
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === 'desc', divider: enableColumnFilters || enableGrouping || enableHiding, icon: jsx(SortIcon, {}), label: (_d = localization.sortByColumnDesc) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header)), onClick: handleSortDesc, table: table }, 2),
2637
+ ]
2638
+ : []),
2639
+ ...(enableColumnFilters && column.getCanFilter()
2640
+ ? [
2641
+ jsx(MRT_ActionMenuItem, { disabled: !columnFilterValue ||
2642
+ (Array.isArray(columnFilterValue) &&
2643
+ !columnFilterValue.filter((value) => value).length), icon: jsx(FilterListOffIcon, {}), label: localization.clearFilter, onClick: handleClearFilter, table: table }, 3),
2644
+ columnFilterDisplayMode === 'subheader' && (jsx(MRT_ActionMenuItem, { disabled: showColumnFilters && !enableColumnFilterModes, divider: enableGrouping || enableHiding, icon: jsx(FilterListIcon, {}), label: (_e = localization.filterByColumn) === null || _e === void 0 ? void 0 : _e.replace('{column}', String(columnDef.header)), onClick: showColumnFilters
2645
+ ? handleOpenFilterModeMenu
2646
+ : handleFilterByColumn, onOpenSubMenu: showFilterModeSubMenu ? handleOpenFilterModeMenu : undefined, table: table }, 4)),
2647
+ showFilterModeSubMenu && (jsx(MRT_FilterOptionMenu, { anchorEl: filterMenuAnchorEl, header: header, onSelect: handleFilterByColumn, setAnchorEl: setFilterMenuAnchorEl, table: table }, 5)),
2648
+ ].filter(Boolean)
2649
+ : []),
2650
+ ...(enableGrouping && column.getCanGroup()
2651
+ ? [
2652
+ jsx(MRT_ActionMenuItem, { divider: enableColumnPinning, icon: jsx(DynamicFeedIcon, {}), label: (_f = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) === null || _f === void 0 ? void 0 : _f.replace('{column}', String(columnDef.header)), onClick: handleGroupByColumn, table: table }, 6),
2653
+ ]
2654
+ : []),
2655
+ ...(enableColumnPinning && column.getCanPin()
2656
+ ? [
2657
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsPinned() === 'left' || !column.getCanPin(), icon: jsx(PushPinIcon, { style: { transform: 'rotate(90deg)' } }), label: localization.pinToLeft, onClick: () => handlePinColumn('left'), table: table }, 7),
2658
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsPinned() === 'right' || !column.getCanPin(), icon: jsx(PushPinIcon, { style: { transform: 'rotate(-90deg)' } }), label: localization.pinToRight, onClick: () => handlePinColumn('right'), table: table }, 8),
2659
+ jsx(MRT_ActionMenuItem, { disabled: !column.getIsPinned(), divider: enableHiding, icon: jsx(PushPinIcon, {}), label: localization.unpin, onClick: () => handlePinColumn(false), table: table }, 9),
2660
+ ]
2661
+ : []),
2662
+ ...(enableColumnResizing && column.getCanResize()
2663
+ ? [
2664
+ jsx(MRT_ActionMenuItem, { disabled: !columnSizing[column.id], icon: jsx(RestartAltIcon, {}), label: localization.resetColumnSize, onClick: handleResetColumnSize, table: table }, 10),
2665
+ ]
2666
+ : []),
2667
+ ...(enableHiding
2668
+ ? [
2669
+ jsx(MRT_ActionMenuItem, { disabled: !column.getCanHide(), icon: jsx(VisibilityOffIcon, {}), label: (_g = localization.hideColumn) === null || _g === void 0 ? void 0 : _g.replace('{column}', String(columnDef.header)), onClick: handleHideColumn, table: table }, 11),
2670
+ jsx(MRT_ActionMenuItem, { disabled: !Object.values(columnVisibility).filter((visible) => !visible)
2671
+ .length, icon: jsx(ViewColumnIcon, {}), label: (_h = localization.showAllColumns) === null || _h === void 0 ? void 0 : _h.replace('{column}', String(columnDef.header)), onClick: handleShowAllColumns, table: table }, 12),
2672
+ ]
2673
+ : []),
2674
+ ].filter(Boolean);
2675
+ const theme = useTheme();
2676
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
2677
+ return (jsx(Menu, Object.assign({ MenuListProps: {
2678
+ dense: density === 'compact',
2679
+ sx: {
2680
+ backgroundColor: menuBackgroundColor,
2681
+ },
2682
+ }, 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, {
2683
+ closeMenu: () => setAnchorEl(null),
2559
2684
  column,
2560
- header: footer,
2685
+ internalColumnMenuItems,
2561
2686
  table,
2562
- tableCellProps,
2563
- theme,
2564
- })), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (footer.isPlaceholder
2565
- ? null
2566
- : (_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
2567
- column,
2568
- footer,
2569
- table,
2570
- })) !== null && _c !== void 0 ? _c : columnDef.footer) !== null && _d !== void 0 ? _d : null) })));
2571
- };
2572
-
2573
- const MRT_TableFooterRow = (_a) => {
2574
- var _b;
2575
- var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
2576
- const { options: { layoutMode, muiTableFooterRowProps }, } = table;
2577
- const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2578
- // if no content in row, skip row
2579
- if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
2580
- !!header.column.columnDef.footer) ||
2581
- header.column.columnDef.Footer)))
2582
- return null;
2583
- const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterRowProps, {
2584
- footerGroup,
2585
- table,
2586
- })), rest);
2587
- return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: getMRTTheme(table, theme).baseBackgroundColor, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: 'relative', width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter, staticColumnIndex) => {
2588
- let footer = footerOrVirtualFooter;
2589
- if (columnVirtualizer) {
2590
- staticColumnIndex = footerOrVirtualFooter
2591
- .index;
2592
- footer = footerGroup.headers[staticColumnIndex];
2593
- }
2594
- return footer ? (jsx(MRT_TableFooterCell, { footer: footer, staticColumnIndex: staticColumnIndex, table: table }, footer.id)) : null;
2595
- }), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
2596
- };
2597
-
2598
- const MRT_TableFooter = (_a) => {
2599
- var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2600
- const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
2601
- const { isFullScreen } = getState();
2602
- const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
2603
- table,
2604
- })), rest);
2605
- const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
2606
- return (jsx(TableFooter, Object.assign({}, tableFooterProps, { ref: (ref) => {
2607
- tableFooterRef.current = ref;
2608
- if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
2609
- // @ts-ignore
2610
- tableFooterProps.ref.current = ref;
2611
- }
2612
- }, sx: (theme) => (Object.assign({ bottom: stickFooter ? 0 : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, opacity: stickFooter ? 0.97 : undefined, outline: stickFooter
2613
- ? theme.palette.mode === 'light'
2614
- ? `1px solid ${theme.palette.grey[300]}`
2615
- : `1px solid ${theme.palette.grey[700]}`
2616
- : undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
2687
+ })) !== null && _k !== void 0 ? _k : renderColumnActionsMenuItems === null || renderColumnActionsMenuItems === void 0 ? void 0 : renderColumnActionsMenuItems({
2688
+ closeMenu: () => setAnchorEl(null),
2689
+ column,
2690
+ internalColumnMenuItems,
2691
+ table,
2692
+ })) !== null && _l !== void 0 ? _l : internalColumnMenuItems })));
2617
2693
  };
2618
2694
 
2619
2695
  const MRT_TableHeadCellColumnActionsButton = (_a) => {
@@ -2732,6 +2808,7 @@ const MRT_FilterTextField = (_a) => {
2732
2808
  ? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || ''
2733
2809
  : (_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '';
2734
2810
  });
2811
+ const [autocompleteValue, setAutocompleteValue] = useState(isAutocompleteFilter ? filterValue : null);
2735
2812
  const handleChangeDebounced = useCallback(debounce((newValue) => {
2736
2813
  if (isRangeFilter) {
2737
2814
  column.setFilterValue((old) => {
@@ -2758,6 +2835,10 @@ const MRT_FilterTextField = (_a) => {
2758
2835
  handleChange(newValue);
2759
2836
  (_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
2760
2837
  };
2838
+ const handleAutocompleteChange = (newValue) => {
2839
+ setAutocompleteValue(newValue);
2840
+ handleChange(getValueAndLabel(newValue).value);
2841
+ };
2761
2842
  const handleClear = () => {
2762
2843
  if (isMultiSelectFilter) {
2763
2844
  setFilterValue([]);
@@ -2878,10 +2959,10 @@ const MRT_FilterTextField = (_a) => {
2878
2959
  } }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) ? (jsx(DatePicker, Object.assign({}, commonDatePickerProps, datePickerProps, { slotProps: {
2879
2960
  field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_r = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _r === void 0 ? void 0 : _r.field),
2880
2961
  textField: Object.assign(Object.assign({}, commonTextFieldProps), (_s = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _s === void 0 ? void 0 : _s.textField),
2881
- } }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleChange(getValueAndLabel(newValue).value), options: (_t = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _t !== void 0 ? _t : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
2962
+ } }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleAutocompleteChange(newValue), options: (_t = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _t !== void 0 ? _t : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
2882
2963
  var _a;
2883
2964
  return (jsx(TextField, Object.assign({}, builtinTextFieldProps, commonTextFieldProps, { InputProps: Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), { startAdornment: (_a = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.startAdornment }), inputProps: Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.inputProps), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation() })));
2884
- }, value: filterValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ MenuProps: { disableScrollLock: true }, displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
2965
+ }, value: autocompleteValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ MenuProps: { disableScrollLock: true }, displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
2885
2966
  ? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected === null || selected === void 0 ? void 0 : selected.map((value) => {
2886
2967
  const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
2887
2968
  return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
@@ -3037,7 +3118,7 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
3037
3118
  }, size: "small" }, rest, { sx: (theme) => (Object.assign({ height: '16px', ml: '4px', opacity: isFilterActive ? 1 : 0.3, p: '8px', transform: 'scale(0.75)', transition: 'all 150ms ease-in-out', width: '16px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: jsx(FilterAltIcon, {}) })) }) }) }), jsx(Popover, { anchorEl: anchorEl, anchorOrigin: {
3038
3119
  horizontal: 'center',
3039
3120
  vertical: 'top',
3040
- }, onClick: (event) => event.stopPropagation(), onClose: (event) => {
3121
+ }, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: (event) => {
3041
3122
  //@ts-ignore
3042
3123
  event.stopPropagation();
3043
3124
  setAnchorEl(null);
@@ -3081,7 +3162,7 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
3081
3162
  setDraggingColumn(null);
3082
3163
  setHoveredColumn(null);
3083
3164
  };
3084
- return (jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
3165
+ return (jsx(MRT_GrabHandleButton, Object.assign({}, iconButtonProps, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })));
3085
3166
  };
3086
3167
 
3087
3168
  const MRT_TableHeadCellResizeHandle = (_a) => {
@@ -3158,7 +3239,7 @@ const MRT_TableHeadCellSortLabel = (_a) => {
3158
3239
 
3159
3240
  const MRT_TableHeadCell = (_a) => {
3160
3241
  var _b, _c, _d, _f, _g, _h;
3161
- var { header, staticColumnIndex, table } = _a, rest = __rest(_a, ["header", "staticColumnIndex", "table"]);
3242
+ var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
3162
3243
  const theme = useTheme();
3163
3244
  const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
3164
3245
  const { columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
@@ -3235,8 +3316,12 @@ const MRT_TableHeadCell = (_a) => {
3235
3316
  : theme.direction === 'rtl'
3236
3317
  ? 'right'
3237
3318
  : 'left', colSpan: header.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, onDragEnter: handleDragEnter, ref: (node) => {
3319
+ var _a;
3238
3320
  if (node) {
3239
3321
  tableHeadCellRefs.current[column.id] = node;
3322
+ if (columnDefType !== 'group') {
3323
+ (_a = columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(columnVirtualizer, node);
3324
+ }
3240
3325
  }
3241
3326
  } }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
3242
3327
  '.MuiButtonBase-root': {
@@ -3299,7 +3384,7 @@ const MRT_TableHeadCell = (_a) => {
3299
3384
  whiteSpace: ((_h = (_g = columnDef.header) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) < 20
3300
3385
  ? 'nowrap'
3301
3386
  : 'normal',
3302
- }, title: columnDefType === 'data' ? columnDef.header : undefined, children: HeaderElement }), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxs(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: {
3387
+ }, children: HeaderElement }), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxs(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: {
3303
3388
  whiteSpace: 'nowrap',
3304
3389
  }, children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
3305
3390
  current: tableHeadCellRefs.current[column.id],
@@ -3323,14 +3408,14 @@ const MRT_TableHeadRow = (_a) => {
3323
3408
  .index;
3324
3409
  header = headerGroup.headers[staticColumnIndex];
3325
3410
  }
3326
- return header ? (jsx(MRT_TableHeadCell, { header: header, staticColumnIndex: staticColumnIndex, table: table }, header.id)) : null;
3411
+ return header ? (jsx(MRT_TableHeadCell, { columnVirtualizer: columnVirtualizer, header: header, staticColumnIndex: staticColumnIndex, table: table }, header.id)) : null;
3327
3412
  }), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
3328
3413
  };
3329
3414
 
3330
3415
  const MRT_ToolbarAlertBanner = (_a) => {
3331
3416
  var _b, _c, _d;
3332
3417
  var { stackAlertBanner, table } = _a, rest = __rest(_a, ["stackAlertBanner", "table"]);
3333
- const { getPrePaginationRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { tablePaperRef }, } = table;
3418
+ const { getFilteredSelectedRowModel, getPrePaginationRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, manualPagination, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { lastSelectedRowId, tablePaperRef }, } = table;
3334
3419
  const { density, grouping, rowSelection, showAlertBanner } = getState();
3335
3420
  const alertProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
3336
3421
  table,
@@ -3338,10 +3423,14 @@ const MRT_ToolbarAlertBanner = (_a) => {
3338
3423
  const chipProps = parseFromValuesOrFunc(muiToolbarAlertBannerChipProps, {
3339
3424
  table,
3340
3425
  });
3341
- const selectedRowCount = useMemo(() => Object.values(rowSelection).filter(Boolean).length, [rowSelection]);
3342
- const selectedAlert = selectedRowCount > 0
3343
- ? (_c = (_b = localization.selectedCountOfRowCountRowsSelected) === null || _b === void 0 ? void 0 : _b.replace('{selectedCount}', selectedRowCount.toLocaleString())) === null || _c === void 0 ? void 0 : _c.replace('{rowCount}', (rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length).toString())
3344
- : null;
3426
+ const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
3427
+ const selectedRowCount = useMemo(() => manualPagination
3428
+ ? Object.values(rowSelection).filter(Boolean).length
3429
+ : getFilteredSelectedRowModel().rows.length, [rowSelection, totalRowCount, manualPagination]);
3430
+ const selectedAlert = selectedRowCount > 0 ? (jsxs(Stack, { alignItems: "center", direction: "row", gap: "16px", children: [(_c = (_b = localization.selectedCountOfRowCountRowsSelected) === null || _b === void 0 ? void 0 : _b.replace('{selectedCount}', selectedRowCount.toLocaleString())) === null || _c === void 0 ? void 0 : _c.replace('{rowCount}', totalRowCount.toString()), jsx(Button, { onClick: () => {
3431
+ table.toggleAllRowsSelected(false);
3432
+ lastSelectedRowId.current = null;
3433
+ }, size: "small", sx: { p: '2px' }, children: localization.clearSelection })] })) : null;
3345
3434
  const groupedAlert = grouping.length > 0 ? (jsxs("span", { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxs(Fragment$1, { children: [index > 0 ? localization.thenBy : '', jsx(Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))] }, `${index}-${columnId}`)))] })) : null;
3346
3435
  return (jsx(Collapse, { in: showAlertBanner || !!selectedAlert || !!groupedAlert, timeout: stackAlertBanner ? 200 : 0, children: jsx(Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => {
3347
3436
  var _a, _b;
@@ -3417,6 +3506,7 @@ const MRT_Table = (_a) => {
3417
3506
  };
3418
3507
 
3419
3508
  const MRT_TableLoadingOverlay = (_a) => {
3509
+ var _b;
3420
3510
  var { table } = _a, rest = __rest(_a, ["table"]);
3421
3511
  const { options: { localization, muiCircularProgressProps }, } = table;
3422
3512
  const circularProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCircularProgressProps, { table })), rest);
@@ -3432,8 +3522,54 @@ const MRT_TableLoadingOverlay = (_a) => {
3432
3522
  right: 0,
3433
3523
  top: 0,
3434
3524
  width: '100%',
3435
- zIndex: 2,
3436
- }), children: jsx(CircularProgress, Object.assign({ "aria-label": localization.noRecordsToDisplay, id: "mrt-progress" }, circularProgressProps)) }));
3525
+ zIndex: 3,
3526
+ }), children: (_b = circularProgressProps === null || circularProgressProps === void 0 ? void 0 : circularProgressProps.Component) !== null && _b !== void 0 ? _b : (jsx(CircularProgress, Object.assign({ "aria-label": localization.noRecordsToDisplay, id: "mrt-progress" }, circularProgressProps))) }));
3527
+ };
3528
+
3529
+ const MRT_CellActionMenu = (_a) => {
3530
+ var _b, _c;
3531
+ var { table } = _a, rest = __rest(_a, ["table"]);
3532
+ const { getState, options: { editDisplayMode, enableClickToCopy, enableEditing, icons: { ContentCopy, EditIcon }, localization, renderCellActionMenuItems, }, refs: { actionCellRef }, } = table;
3533
+ const { actionCell, density } = getState();
3534
+ const cell = actionCell;
3535
+ const { row } = cell;
3536
+ const { column } = cell;
3537
+ const { columnDef } = column;
3538
+ const theme = useTheme();
3539
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
3540
+ const handleClose = (event) => {
3541
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
3542
+ table.setActionCell(null);
3543
+ actionCellRef.current = null;
3544
+ };
3545
+ const internalMenuItems = [
3546
+ (parseFromValuesOrFunc(enableClickToCopy, cell) === 'context-menu' ||
3547
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) ===
3548
+ 'context-menu') && (jsx(MRT_ActionMenuItem, { icon: jsx(ContentCopy, {}), label: localization.copy, onClick: (event) => {
3549
+ event.stopPropagation();
3550
+ navigator.clipboard.writeText(cell.getValue());
3551
+ handleClose();
3552
+ }, table: table }, 'mrt-copy')),
3553
+ parseFromValuesOrFunc(enableEditing, row) && editDisplayMode === 'cell' && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: () => {
3554
+ openEditingCell({ cell, table });
3555
+ handleClose();
3556
+ }, table: table }, 'mrt-edit')),
3557
+ ].filter(Boolean);
3558
+ const renderActionProps = {
3559
+ cell,
3560
+ closeMenu: handleClose,
3561
+ column,
3562
+ internalMenuItems,
3563
+ row,
3564
+ table,
3565
+ };
3566
+ 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);
3567
+ return ((!!(menuItems === null || menuItems === void 0 ? void 0 : menuItems.length) || !!(internalMenuItems === null || internalMenuItems === void 0 ? void 0 : internalMenuItems.length)) && (jsx(Menu, Object.assign({ MenuListProps: {
3568
+ dense: density === 'compact',
3569
+ sx: {
3570
+ backgroundColor: menuBackgroundColor,
3571
+ },
3572
+ }, 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 }))));
3437
3573
  };
3438
3574
 
3439
3575
  const MRT_EditRowModal = (_a) => {
@@ -3480,8 +3616,8 @@ const MRT_EditRowModal = (_a) => {
3480
3616
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
3481
3617
  const MRT_TableContainer = (_a) => {
3482
3618
  var { table } = _a, rest = __rest(_a, ["table"]);
3483
- const { getState, options: { createDisplayMode, editDisplayMode, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
3484
- const { creatingRow, editingRow, isFullScreen, isLoading, showLoadingOverlay, } = getState();
3619
+ const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
3620
+ const { actionCell, creatingRow, editingRow, isFullScreen, isLoading, showLoadingOverlay, } = getState();
3485
3621
  const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
3486
3622
  const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
3487
3623
  const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableContainerProps, {
@@ -3511,7 +3647,7 @@ const MRT_TableContainer = (_a) => {
3511
3647
  ? `calc(100vh - ${totalToolbarHeight}px)`
3512
3648
  : undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign({ maxHeight: enableStickyHeader
3513
3649
  ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
3514
- : undefined, maxWidth: '100%', overflow: 'auto', position: 'relative' }, parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [loading ? jsx(MRT_TableLoadingOverlay, { table: table }) : null, jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsx(MRT_EditRowModal, { open: true, table: table }))] })));
3650
+ : undefined, maxWidth: '100%', overflow: 'auto', position: 'relative' }, parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [loading ? jsx(MRT_TableLoadingOverlay, { table: table }) : null, jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsx(MRT_EditRowModal, { open: true, table: table })), enableCellActions && actionCell && jsx(MRT_CellActionMenu, { table: table })] })));
3515
3651
  };
3516
3652
 
3517
3653
  const MRT_LinearProgressBar = (_a) => {
@@ -3651,7 +3787,7 @@ const MRT_ColumnPinningButtons = (_a) => {
3651
3787
 
3652
3788
  const MRT_ShowHideColumnsMenuItems = (_a) => {
3653
3789
  var _b;
3654
- var { allColumns, column, hoveredColumn, setHoveredColumn, table } = _a, rest = __rest(_a, ["allColumns", "column", "hoveredColumn", "setHoveredColumn", "table"]);
3790
+ var { allColumns, column, hoveredColumn, isNestedColumns, setHoveredColumn, table } = _a, rest = __rest(_a, ["allColumns", "column", "hoveredColumn", "isNestedColumns", "setHoveredColumn", "table"]);
3655
3791
  const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, }, setColumnOrder, } = table;
3656
3792
  const { columnOrder } = getState();
3657
3793
  const { columnDef } = column;
@@ -3706,7 +3842,7 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
3706
3842
  gap: '8px',
3707
3843
  }, children: [columnDefType !== 'group' &&
3708
3844
  enableColumnOrdering &&
3709
- !allColumns.some((col) => col.columnDef.columnDefType === 'group') &&
3845
+ !isNestedColumns &&
3710
3846
  (columnDef.enableColumnOrdering !== false ? (jsx(MRT_GrabHandleButton, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })) : (jsx(Box, { sx: { width: '28px' } }))), enableColumnPinning &&
3711
3847
  (column.getCanPin() ? (jsx(MRT_ColumnPinningButtons, { column: column, table: table })) : (jsx(Box, { sx: { width: '70px' } }))), enableHiding ? (jsx(FormControlLabel, { checked: switchChecked, componentsProps: {
3712
3848
  typography: {
@@ -3715,7 +3851,7 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
3715
3851
  opacity: columnDefType !== 'display' ? 1 : 0.5,
3716
3852
  },
3717
3853
  },
3718
- }, control: jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.toggleVisibility, children: jsx(Switch, {}) })), disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (jsx(Typography, { sx: { alignSelf: 'center' }, children: columnDef.header }))] }) })), (_b = column.columns) === null || _b === void 0 ? void 0 : _b.map((c, i) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
3854
+ }, control: jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.toggleVisibility, children: jsx(Switch, {}) })), disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (jsx(Typography, { sx: { alignSelf: 'center' }, children: columnDef.header }))] }) })), (_b = column.columns) === null || _b === void 0 ? void 0 : _b.map((c, i) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
3719
3855
  };
3720
3856
 
3721
3857
  const MRT_ShowHideColumnsMenu = (_a) => {
@@ -3746,6 +3882,7 @@ const MRT_ShowHideColumnsMenu = (_a) => {
3746
3882
  getLeftLeafColumns(),
3747
3883
  getRightLeafColumns(),
3748
3884
  ]);
3885
+ const isNestedColumns = allColumns.some((col) => col.columnDef.columnDefType === 'group');
3749
3886
  const [hoveredColumn, setHoveredColumn] = useState(null);
3750
3887
  const theme = useTheme();
3751
3888
  const { menuBackgroundColor } = getMRTTheme(table, theme);
@@ -3759,7 +3896,7 @@ const MRT_ShowHideColumnsMenu = (_a) => {
3759
3896
  justifyContent: 'space-between',
3760
3897
  p: '0.5rem',
3761
3898
  pt: 0,
3762
- }, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options)), children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
3899
+ }, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
3763
3900
  };
3764
3901
 
3765
3902
  const MRT_ShowHideColumnsButton = (_a) => {
@@ -3976,5 +4113,5 @@ const MaterialReactTable = (props) => {
3976
4113
  return jsx(MRT_TablePaper, { table: table });
3977
4114
  };
3978
4115
 
3979
- export { MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, commonListItemStyles, commonMenuItemStyles, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getIsRowSelected, getLeadingDisplayColumnIds, getTotalRight, getTrailingDisplayColumnIds, mrtFilterOptions, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
4116
+ export { MRT_ActionMenuItem, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getTotalRight, getTrailingDisplayColumnIds, isCellEditable, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
3980
4117
  //# sourceMappingURL=index.esm.js.map