material-react-table 2.4.0 → 2.5.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.
package/dist/index.esm.js CHANGED
@@ -13,12 +13,13 @@ import Box from '@mui/material/Box';
13
13
  import { flexRender as flexRender$1, createRow as createRow$1, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, aggregationFns, filterFns } from '@tanstack/react-table';
14
14
  import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual';
15
15
  import highlightWords from 'highlight-words';
16
- import IconButton from '@mui/material/IconButton';
17
- import Tooltip from '@mui/material/Tooltip';
18
16
  import Button from '@mui/material/Button';
17
+ import Tooltip from '@mui/material/Tooltip';
19
18
  import MenuItem from '@mui/material/MenuItem';
20
19
  import TextField from '@mui/material/TextField';
21
20
  import Collapse from '@mui/material/Collapse';
21
+ import Stack from '@mui/material/Stack';
22
+ import IconButton from '@mui/material/IconButton';
22
23
  import CircularProgress from '@mui/material/CircularProgress';
23
24
  import ListItemIcon from '@mui/material/ListItemIcon';
24
25
  import Menu from '@mui/material/Menu';
@@ -71,7 +72,6 @@ import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
71
72
  import { TimePicker } from '@mui/x-date-pickers/TimePicker';
72
73
  import FormHelperText from '@mui/material/FormHelperText';
73
74
  import Slider from '@mui/material/Slider';
74
- import Stack from '@mui/material/Stack';
75
75
  import Grow from '@mui/material/Grow';
76
76
  import Popover from '@mui/material/Popover';
77
77
  import Divider from '@mui/material/Divider';
@@ -297,6 +297,8 @@ const createRow = (table, originalRow) => createRow$1(table, 'mrt-row-create', o
297
297
  }))), -1, 0);
298
298
  const extraIndexRangeExtractor = (range, draggingIndex) => {
299
299
  const newIndexes = defaultRangeExtractor(range);
300
+ if (draggingIndex === undefined)
301
+ return newIndexes;
300
302
  if (draggingIndex >= 0 &&
301
303
  draggingIndex < Math.max(range.startIndex - range.overscan, 0)) {
302
304
  newIndexes.unshift(draggingIndex);
@@ -341,7 +343,7 @@ const getMRTTheme = (table, theme) => (Object.assign({ baseBackgroundColor: them
341
343
  ? darken(theme.palette.warning.dark, 0.25)
342
344
  : lighten(theme.palette.warning.light, 0.5), pinnedRowBackgroundColor: alpha(theme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(theme.palette.primary.main, 0.2) }, parseFromValuesOrFunc(table.options.mrtTheme, theme)));
343
345
  const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
344
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
346
+ var _a, _b, _c, _d, _e, _f;
345
347
  const { options: { layoutMode }, } = table;
346
348
  const widthStyles = {
347
349
  minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_a = header === null || header === void 0 ? void 0 : header.id) !== null && _a !== void 0 ? _a : column.id)}-size) * 1px), ${(_b = column.columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
@@ -361,19 +363,8 @@ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme,
361
363
  ? `4px 0 8px -6px ${alpha(theme.palette.grey[700], 0.5)} inset`
362
364
  : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, left: column.getIsPinned() === 'left'
363
365
  ? `${column.getStart('left')}px`
364
- : undefined, ml: table.options.enableColumnVirtualization &&
365
- column.getIsPinned() === 'left' &&
366
- column.getPinnedIndex() === 0
367
- ? `-${column.getSize() *
368
- ((_f = (_e = table.getState().columnPinning.left) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 1)}px`
369
- : undefined, mr: table.options.enableColumnVirtualization &&
370
- column.getIsPinned() === 'right' &&
371
- column.getPinnedIndex() === table.getVisibleLeafColumns().length - 1
372
- ? `-${column.getSize() *
373
- ((_h = (_g = table.getState().columnPinning.right) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 1) *
374
- 1.2}px`
375
- : undefined, opacity: ((_j = table.getState().draggingColumn) === null || _j === void 0 ? void 0 : _j.id) === column.id ||
376
- ((_k = table.getState().hoveredColumn) === null || _k === void 0 ? void 0 : _k.id) === column.id
366
+ : undefined, opacity: ((_e = table.getState().draggingColumn) === null || _e === void 0 ? void 0 : _e.id) === column.id ||
367
+ ((_f = table.getState().hoveredColumn) === null || _f === void 0 ? void 0 : _f.id) === column.id
377
368
  ? 0.5
378
369
  : 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
379
370
  ? 'sticky'
@@ -396,7 +387,7 @@ const getCommonToolbarStyles = ({ table, theme, }) => ({
396
387
  });
397
388
 
398
389
  const allowedTypes = ['string', 'number'];
399
- const MRT_TableBodyCellValue = ({ cell, table, }) => {
390
+ const MRT_TableBodyCellValue = ({ cell, rowRef, staticRowIndex, table, }) => {
400
391
  var _a, _b, _c;
401
392
  const { getState, options: { enableFilterMatchHighlighting }, } = table;
402
393
  const { column, row } = cell;
@@ -458,51 +449,14 @@ const MRT_TableBodyCellValue = ({ cell, table, }) => {
458
449
  column,
459
450
  renderedCellValue,
460
451
  row,
452
+ rowRef,
453
+ staticRowIndex,
461
454
  table,
462
455
  });
463
456
  }
464
457
  return renderedCellValue;
465
458
  };
466
459
 
467
- const MRT_GrabHandleButton = (_a) => {
468
- var _b, _c;
469
- var { iconButtonProps, location, onDragEnd, onDragStart, table } = _a, rest = __rest(_a, ["iconButtonProps", "location", "onDragEnd", "onDragStart", "table"]);
470
- const { options: { icons: { DragHandleIcon }, localization, }, } = table;
471
- const _iconButtonProps = Object.assign(Object.assign({}, iconButtonProps), rest);
472
- return (jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, placement: "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) => {
473
- var _a;
474
- e.stopPropagation();
475
- (_a = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(_iconButtonProps, e);
476
- }, onDragEnd: onDragEnd, onDragStart: onDragStart, sx: (theme) => (Object.assign({ '&:active': {
477
- cursor: 'grabbing',
478
- }, '&:hover': {
479
- backgroundColor: 'transparent',
480
- opacity: 1,
481
- }, 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, {}) })) }));
482
- };
483
-
484
- const MRT_TableBodyRowGrabHandle = (_a) => {
485
- var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
486
- const { options: { muiRowDragHandleProps }, } = table;
487
- const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
488
- row,
489
- table,
490
- })), rest);
491
- const handleDragStart = (event) => {
492
- var _a;
493
- (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
494
- event.dataTransfer.setDragImage(rowRef.current, 0, 0);
495
- table.setDraggingRow(row);
496
- };
497
- const handleDragEnd = (event) => {
498
- var _a;
499
- (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
500
- table.setDraggingRow(null);
501
- table.setHoveredRow(null);
502
- };
503
- return (jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
504
- };
505
-
506
460
  const MRT_CopyButton = (_a) => {
507
461
  var _b;
508
462
  var { cell, table } = _a, rest = __rest(_a, ["cell", "table"]);
@@ -621,7 +575,7 @@ const MRT_TableBodyCell = (_a) => {
621
575
  var _b, _c, _d, _e, _f;
622
576
  var { cell, measureElement, numRows, rowIndex, rowRef, table, virtualColumnIndex } = _a, rest = __rest(_a, ["cell", "measureElement", "numRows", "rowIndex", "rowRef", "table", "virtualColumnIndex"]);
623
577
  const theme = useTheme();
624
- const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enableRowNumbers, layoutMode, muiSkeletonProps, muiTableBodyCellProps, rowNumberDisplayMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
578
+ const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
625
579
  const { columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
626
580
  const { column, row } = cell;
627
581
  const { columnDef } = column;
@@ -727,6 +681,10 @@ const MRT_TableBodyCell = (_a) => {
727
681
  setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
728
682
  }
729
683
  };
684
+ const cellValueProps = {
685
+ cell,
686
+ table,
687
+ };
730
688
  return (jsx(TableCell, Object.assign({ "data-index": virtualColumnIndex, ref: (node) => {
731
689
  if (node) {
732
690
  measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
@@ -762,19 +720,18 @@ const MRT_TableBodyCell = (_a) => {
762
720
  table,
763
721
  tableCellProps,
764
722
  theme,
765
- })), draggingBorders)), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (jsxs(Fragment, { children: [cell.getIsPlaceholder() ? ((_d = (_c = columnDef.PlaceholderCell) === null || _c === void 0 ? void 0 : _c.call(columnDef, { cell, column, row, table })) !== null && _d !== void 0 ? _d : null) : showSkeletons !== false && (isLoading || showSkeletons) ? (jsx(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
766
- rowNumberDisplayMode === 'static' &&
767
- column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
768
- (column.id === 'mrt-row-select' ||
769
- column.id === 'mrt-row-expand' ||
723
+ })), draggingBorders)), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (jsxs(Fragment, { children: [cell.getIsPlaceholder() ? ((_d = (_c = columnDef.PlaceholderCell) === null || _c === void 0 ? void 0 : _c.call(columnDef, { cell, column, row, table })) !== null && _d !== void 0 ? _d : null) : showSkeletons !== false && (isLoading || showSkeletons) ? (jsx(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : columnDefType === 'display' &&
724
+ (['mrt-row-expand', 'mrt-row-numbers', 'mrt-row-select'].includes(column.id) ||
770
725
  !row.getIsGrouped()) ? ((_e = columnDef.Cell) === null || _e === void 0 ? void 0 : _e.call(columnDef, {
771
726
  cell,
772
727
  column,
773
728
  renderedCellValue: cell.renderValue(),
774
729
  row,
730
+ rowRef,
731
+ staticRowIndex: rowIndex,
775
732
  table,
776
733
  })) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
777
- columnDef.enableClickToCopy !== false ? (jsx(MRT_CopyButton, { cell: cell, table: table, children: jsx(MRT_TableBodyCellValue, { cell: cell, table: table }) })) : (jsx(MRT_TableBodyCellValue, { cell: cell, table: table })), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxs(Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
734
+ 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, ")"] }))] })) })));
778
735
  };
779
736
  const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
780
737
 
@@ -804,12 +761,12 @@ const MRT_TableDetailPanel = (_a) => {
804
761
  : undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, py: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: renderDetailPanel && (jsx(Collapse, { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: !isLoading && renderDetailPanel({ row, table }) })) })) })));
805
762
  };
806
763
 
807
- const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table, virtualColumns, virtualRow, }) => {
764
+ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table, virtualRow, }) => {
808
765
  var _a, _b, _c, _d;
809
766
  const theme = useTheme();
810
767
  const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
811
768
  const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
812
- const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
769
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
813
770
  const isPinned = enableRowPinning && row.getIsPinned();
814
771
  const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
815
772
  row,
@@ -909,7 +866,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
909
866
  const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.rowIndex === next.rowIndex);
910
867
 
911
868
  const useMRT_ColumnVirtualizer = (table) => {
912
- var _a, _b, _c, _d;
869
+ var _a, _b, _c, _d, _e, _f, _g, _h;
913
870
  const { getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, enableColumnPinning, enableColumnVirtualization, }, refs: { tableContainerRef }, } = table;
914
871
  const { columnPinning, columnVisibility, draggingColumn } = getState();
915
872
  const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, {
@@ -920,7 +877,8 @@ const useMRT_ColumnVirtualizer = (table) => {
920
877
  table.getLeftLeafColumns().map((c) => c.getPinnedIndex()),
921
878
  table
922
879
  .getRightLeafColumns()
923
- .map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1),
880
+ .map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1)
881
+ .sort((a, b) => a - b),
924
882
  ]
925
883
  : [[], []], [columnPinning, enableColumnVirtualization, enableColumnPinning]);
926
884
  //get first 16 column widths and average them if calc is needed
@@ -934,9 +892,11 @@ const useMRT_ColumnVirtualizer = (table) => {
934
892
  .rows[0]) === null || _a === void 0 ? void 0 : _a.getCenterVisibleCells()) === null || _b === void 0 ? void 0 : _b.slice(0, 16)) === null || _c === void 0 ? void 0 : _c.map((cell) => cell.column.getSize() * 1.2)) !== null && _d !== void 0 ? _d : [];
935
893
  return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
936
894
  }, [table.getRowModel().rows, columnPinning, columnVisibility]);
937
- const draggingColumnIndex = table
938
- .getVisibleLeafColumns()
939
- .findIndex((c) => c.id === (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id));
895
+ const draggingColumnIndex = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)
896
+ ? table
897
+ .getVisibleLeafColumns()
898
+ .findIndex((c) => c.id === (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id))
899
+ : undefined;
940
900
  const columnVirtualizer = enableColumnVirtualization
941
901
  ? useVirtualizer(Object.assign({ count: table.getVisibleLeafColumns().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: useCallback((range) => {
942
902
  const newIndexes = extraIndexRangeExtractor(range, draggingColumnIndex);
@@ -949,25 +909,68 @@ const useMRT_ColumnVirtualizer = (table) => {
949
909
  ];
950
910
  }, [leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex]) }, columnVirtualizerProps))
951
911
  : undefined;
952
- if (columnVirtualizerInstanceRef && columnVirtualizer) {
953
- //@ts-ignore
954
- columnVirtualizerInstanceRef.current = columnVirtualizer;
955
- }
956
- const virtualColumns = columnVirtualizer
957
- ? columnVirtualizer.getVirtualItems()
958
- : undefined;
959
- if (columnVirtualizer && (virtualColumns === null || virtualColumns === void 0 ? void 0 : virtualColumns.length)) {
960
- // @ts-ignore
961
- columnVirtualizer.virtualPaddingLeft =
962
- (_b = (_a = virtualColumns[leftPinnedIndexes.length]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0;
963
- // @ts-ignore
964
- columnVirtualizer.virtualPaddingRight =
965
- columnVirtualizer.getTotalSize() -
966
- ((_d = (_c = virtualColumns[virtualColumns.length - 1 - rightPinnedIndexes.length]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0);
912
+ if (columnVirtualizer) {
913
+ const virtualColumns = columnVirtualizer.getVirtualItems();
914
+ columnVirtualizer.virtualColumns = virtualColumns;
915
+ if (virtualColumns.length) {
916
+ columnVirtualizer.virtualPaddingLeft =
917
+ ((_b = (_a = virtualColumns[leftPinnedIndexes.length]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0) -
918
+ ((_d = (_c = virtualColumns[leftPinnedIndexes.length - 1]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0);
919
+ columnVirtualizer.virtualPaddingRight =
920
+ columnVirtualizer.getTotalSize() -
921
+ ((_f = (_e = virtualColumns[virtualColumns.length - rightPinnedIndexes.length - 1]) === null || _e === void 0 ? void 0 : _e.end) !== null && _f !== void 0 ? _f : 0) -
922
+ (rightPinnedIndexes.length
923
+ ? columnVirtualizer.getTotalSize() -
924
+ ((_h = (_g = virtualColumns[virtualColumns.length - rightPinnedIndexes.length]) === null || _g === void 0 ? void 0 : _g.start) !== null && _h !== void 0 ? _h : 0)
925
+ : 0);
926
+ }
927
+ if (columnVirtualizerInstanceRef) {
928
+ //@ts-ignore
929
+ columnVirtualizerInstanceRef.current = columnVirtualizer;
930
+ }
967
931
  }
968
932
  return columnVirtualizer;
969
933
  };
970
934
 
935
+ const MRT_GrabHandleButton = (_a) => {
936
+ var _b, _c;
937
+ var { iconButtonProps, location, onDragEnd, onDragStart, table } = _a, rest = __rest(_a, ["iconButtonProps", "location", "onDragEnd", "onDragStart", "table"]);
938
+ const { options: { icons: { DragHandleIcon }, localization, }, } = table;
939
+ const _iconButtonProps = Object.assign(Object.assign({}, iconButtonProps), rest);
940
+ return (jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, placement: "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) => {
941
+ var _a;
942
+ e.stopPropagation();
943
+ (_a = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(_iconButtonProps, e);
944
+ }, onDragEnd: onDragEnd, onDragStart: onDragStart, sx: (theme) => (Object.assign({ '&:active': {
945
+ cursor: 'grabbing',
946
+ }, '&:hover': {
947
+ backgroundColor: 'transparent',
948
+ opacity: 1,
949
+ }, 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, {}) })) }));
950
+ };
951
+
952
+ const MRT_TableBodyRowGrabHandle = (_a) => {
953
+ var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
954
+ const { options: { muiRowDragHandleProps }, } = table;
955
+ const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
956
+ row,
957
+ table,
958
+ })), rest);
959
+ const handleDragStart = (event) => {
960
+ var _a;
961
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
962
+ event.dataTransfer.setDragImage(rowRef.current, 0, 0);
963
+ table.setDraggingRow(row);
964
+ };
965
+ const handleDragEnd = (event) => {
966
+ var _a;
967
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
968
+ table.setDraggingRow(null);
969
+ table.setHoveredRow(null);
970
+ };
971
+ return (jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
972
+ };
973
+
971
974
  const MRT_RowPinButton = (_a) => {
972
975
  var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
973
976
  const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
@@ -1302,7 +1305,7 @@ const commonListItemStyles = {
1302
1305
  const MRT_ColumnActionMenu = (_a) => {
1303
1306
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1304
1307
  var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
1305
- 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 }, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, toggleAllColumnsVisible, } = table;
1308
+ 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;
1306
1309
  const { column } = header;
1307
1310
  const { columnDef } = column;
1308
1311
  const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
@@ -1339,8 +1342,14 @@ const MRT_ColumnActionMenu = (_a) => {
1339
1342
  setAnchorEl(null);
1340
1343
  };
1341
1344
  const handleClearFilter = () => {
1342
- column.setFilterValue('');
1345
+ column.setFilterValue(undefined);
1343
1346
  setAnchorEl(null);
1347
+ if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
1348
+ setColumnFilterFns((prev) => {
1349
+ var _a;
1350
+ return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
1351
+ });
1352
+ }
1344
1353
  };
1345
1354
  const handleFilterByColumn = () => {
1346
1355
  setShowColumnFilters(true);
@@ -1471,40 +1480,53 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
1471
1480
 
1472
1481
  const MRT_SelectCheckbox = (_a) => {
1473
1482
  var _b;
1474
- var { row, selectAll, table } = _a, rest = __rest(_a, ["row", "selectAll", "table"]);
1483
+ var { row, selectAll, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "selectAll", "staticRowIndex", "table"]);
1475
1484
  const { getState, options: { enableMultiRowSelection, enableRowPinning, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, rowPinningDisplayMode, selectAllMode, }, } = table;
1476
1485
  const { density, isLoading } = getState();
1477
1486
  const checkboxProps = Object.assign(Object.assign({}, (!row
1478
1487
  ? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
1479
- : parseFromValuesOrFunc(muiSelectCheckboxProps, { row, table }))), rest);
1488
+ : parseFromValuesOrFunc(muiSelectCheckboxProps, {
1489
+ row,
1490
+ staticRowIndex,
1491
+ table,
1492
+ }))), rest);
1493
+ const isStickySelection = enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'));
1480
1494
  const allRowsSelected = selectAll
1481
1495
  ? selectAllMode === 'page'
1482
1496
  ? table.getIsAllPageRowsSelected()
1483
1497
  : table.getIsAllRowsSelected()
1484
1498
  : undefined;
1485
- const commonProps = Object.assign(Object.assign({ checked: selectAll ? allRowsSelected : row === null || row === void 0 ? void 0 : row.getIsSelected(), disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
1499
+ const onSelectionChange = (event, row) => {
1500
+ var _a;
1501
+ if (row.getIsAllSubRowsSelected()) {
1502
+ (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.forEach((r) => r.toggleSelected(false));
1503
+ }
1504
+ row.getToggleSelectedHandler()(event);
1505
+ if (isStickySelection) {
1506
+ row.pin(!row.getIsPinned() && event.target.checked
1507
+ ? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
1508
+ ? 'bottom'
1509
+ : 'top'
1510
+ : false);
1511
+ }
1512
+ };
1513
+ const onSelectAllChange = (event) => {
1514
+ selectAllMode === 'all'
1515
+ ? table.getToggleAllRowsSelectedHandler()(event)
1516
+ : table.getToggleAllPageRowsSelectedHandler()(event);
1517
+ if (isStickySelection) {
1518
+ table.setRowPinning({ bottom: [], top: [] });
1519
+ }
1520
+ };
1521
+ const commonProps = Object.assign(Object.assign({ checked: selectAll
1522
+ ? allRowsSelected
1523
+ : (row === null || row === void 0 ? void 0 : row.getIsSelected()) || (row === null || row === void 0 ? void 0 : row.getIsAllSubRowsSelected()), disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
1486
1524
  'aria-label': selectAll
1487
1525
  ? localization.toggleSelectAll
1488
1526
  : localization.toggleSelectRow,
1489
1527
  }, onChange: (event) => {
1490
1528
  event.stopPropagation();
1491
- row
1492
- ? row.getToggleSelectedHandler()(event)
1493
- : selectAllMode === 'all'
1494
- ? table.getToggleAllRowsSelectedHandler()(event)
1495
- : table.getToggleAllPageRowsSelectedHandler()(event);
1496
- if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
1497
- if (row) {
1498
- row.pin(!row.getIsPinned() && event.target.checked
1499
- ? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
1500
- ? 'bottom'
1501
- : 'top'
1502
- : false);
1503
- }
1504
- else {
1505
- table.setRowPinning({ bottom: [], top: [] });
1506
- }
1507
- }
1529
+ row ? onSelectionChange(event, row) : onSelectAllChange(event);
1508
1530
  }, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
1509
1531
  var _a;
1510
1532
  e.stopPropagation();
@@ -1550,6 +1572,7 @@ const useMRT_DisplayColumns = (params) => {
1550
1572
  tableOptions.enableRowOrdering,
1551
1573
  tableOptions.enableRowSelection,
1552
1574
  tableOptions.enableSelectAll,
1575
+ tableOptions.groupedColumnMode,
1553
1576
  tableOptions.localization,
1554
1577
  tableOptions.positionActionsColumn,
1555
1578
  tableOptions.renderDetailPanel,
@@ -1585,20 +1608,38 @@ function makeRowActionsColumn({ creatingRow, tableOptions }, order) {
1585
1608
  return null;
1586
1609
  }
1587
1610
  function makeRowExpandColumn({ grouping, tableOptions }, order) {
1588
- var _a, _b;
1611
+ var _a, _b, _c;
1589
1612
  const id = 'mrt-row-expand';
1590
1613
  if (order.includes(id) &&
1591
1614
  showExpandColumn(tableOptions, (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.grouping) !== null && _b !== void 0 ? _b : grouping)) {
1592
- return Object.assign({ Cell: ({ row, table }) => jsx(MRT_ExpandButton, { row: row, table: table }), Header: tableOptions.enableExpandAll
1593
- ? ({ table }) => jsx(MRT_ExpandAllButton, { table: table })
1594
- : undefined }, defaultDisplayColumnProps(tableOptions, id, 'expand'));
1615
+ return Object.assign({ Cell: ({ cell, column, row, table }) => {
1616
+ var _a, _b, _c;
1617
+ const expandButtonProps = { row, table };
1618
+ const subRowsLength = (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length;
1619
+ if (tableOptions.groupedColumnMode === 'remove' &&
1620
+ row.groupingColumnId) {
1621
+ return (jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: "0.25rem", children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, placement: "right", title: table.getColumn(row.groupingColumnId).columnDef.header, children: jsx("span", { children: row.groupingValue }) }), !!subRowsLength && jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
1622
+ }
1623
+ else {
1624
+ return (jsxs(Fragment, { children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), (_c = (_b = column.columnDef).GroupedCell) === null || _c === void 0 ? void 0 : _c.call(_b, { cell, column, row, table })] }));
1625
+ }
1626
+ }, Header: tableOptions.enableExpandAll
1627
+ ? ({ table }) => {
1628
+ return (jsxs(Fragment, { children: [jsx(MRT_ExpandAllButton, { table: table }), tableOptions.groupedColumnMode === 'remove' &&
1629
+ grouping
1630
+ .map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)
1631
+ .join(', ')] }));
1632
+ }
1633
+ : undefined }, defaultDisplayColumnProps(tableOptions, id, 'expand', tableOptions.groupedColumnMode === 'remove'
1634
+ ? (_c = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.defaultColumn) === null || _c === void 0 ? void 0 : _c.size
1635
+ : 60));
1595
1636
  }
1596
1637
  return null;
1597
1638
  }
1598
1639
  function makeRowSelectColumn({ tableOptions }, order) {
1599
1640
  const id = 'mrt-row-select';
1600
1641
  if (order.includes(id)) {
1601
- return Object.assign({ Cell: ({ row, table }) => jsx(MRT_SelectCheckbox, { row: row, table: table }), Header: tableOptions.enableSelectAll && tableOptions.enableMultiRowSelection
1642
+ return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: tableOptions.enableSelectAll && tableOptions.enableMultiRowSelection
1602
1643
  ? ({ table }) => jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
1603
1644
  : undefined }, defaultDisplayColumnProps(tableOptions, id, 'select'));
1604
1645
  }
@@ -1607,7 +1648,12 @@ function makeRowSelectColumn({ tableOptions }, order) {
1607
1648
  function makeRowNumbersColumn({ tableOptions }, order) {
1608
1649
  const id = 'mrt-row-numbers';
1609
1650
  if (order.includes(id) || tableOptions.enableRowNumbers)
1610
- return Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => tableOptions.localization.rowNumber }, defaultDisplayColumnProps(tableOptions, id, 'rowNumbers'));
1651
+ return Object.assign({ Cell: ({ row, staticRowIndex }) => {
1652
+ var _a;
1653
+ return ((_a = (tableOptions.rowNumberDisplayMode === 'static'
1654
+ ? staticRowIndex
1655
+ : row.index)) !== null && _a !== void 0 ? _a : 0) + 1;
1656
+ }, Header: () => tableOptions.localization.rowNumber }, defaultDisplayColumnProps(tableOptions, id, 'rowNumbers'));
1611
1657
  return null;
1612
1658
  }
1613
1659
  const blankColProps = {
@@ -1711,9 +1757,13 @@ const useMRT_RowVirtualizer = (table, rows) => {
1711
1757
  return extraIndexRangeExtractor(range, (_a = draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.index) !== null && _a !== void 0 ? _a : 0);
1712
1758
  }, [draggingRow]) }, rowVirtualizerProps))
1713
1759
  : undefined;
1714
- if (rowVirtualizerInstanceRef && rowVirtualizer) {
1715
- //@ts-ignore
1716
- rowVirtualizerInstanceRef.current = rowVirtualizer;
1760
+ if (rowVirtualizer) {
1761
+ const virtualRows = rowVirtualizer.getVirtualItems();
1762
+ rowVirtualizer.virtualRows = virtualRows;
1763
+ if (rowVirtualizerInstanceRef) {
1764
+ //@ts-ignore
1765
+ rowVirtualizerInstanceRef.current = rowVirtualizer;
1766
+ }
1717
1767
  }
1718
1768
  return rowVirtualizer;
1719
1769
  };
@@ -2272,7 +2322,7 @@ const useMRT_TableOptions = (_a) => {
2272
2322
 
2273
2323
  const MRT_TableBody = (_a) => {
2274
2324
  var _b, _c, _d, _e, _f, _g;
2275
- var { columnVirtualizer, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "table", "virtualColumns"]);
2325
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2276
2326
  const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { createDisplayMode, enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
2277
2327
  const { columnFilters, creatingRow, globalFilter, isFullScreen, rowPinning } = getState();
2278
2328
  const tableBodyProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyProps, { table })), rest);
@@ -2290,14 +2340,11 @@ const MRT_TableBody = (_a) => {
2290
2340
  }, [rowPinning, getRowModel().rows]);
2291
2341
  const rows = useMRT_Rows(table, pinnedRowIds);
2292
2342
  const rowVirtualizer = useMRT_RowVirtualizer(table, rows);
2293
- const virtualRows = rowVirtualizer
2294
- ? rowVirtualizer.getVirtualItems()
2295
- : undefined;
2343
+ const { virtualRows } = rowVirtualizer !== null && rowVirtualizer !== void 0 ? rowVirtualizer : {};
2296
2344
  const commonRowProps = {
2297
2345
  columnVirtualizer,
2298
2346
  numRows: rows.length,
2299
2347
  table,
2300
- virtualColumns,
2301
2348
  };
2302
2349
  const CreatingRow = creatingRow && createDisplayMode === 'row' && (jsx(MRT_TableBodyRow, Object.assign({}, commonRowProps, { row: creatingRow, rowIndex: -1 })));
2303
2350
  return (jsxs(Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
@@ -2328,12 +2375,13 @@ const MRT_TableBody = (_a) => {
2328
2375
  row, rowIndex: rowVirtualizer ? rowOrVirtualRow.index : rowIndex, virtualRow: rowVirtualizer
2329
2376
  ? rowOrVirtualRow
2330
2377
  : undefined });
2331
- return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), `${row.id}-${row.index}`)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), `${row.id}-${row.index}`));
2378
+ const key = `${row.id}-${row.index}`;
2379
+ return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), key)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), key));
2332
2380
  }) })))] })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
2333
2381
  getIsSomeRowsPinned('bottom') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ bottom: tableFooterHeight - 1, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getBottomRows().map((row, rowIndex) => {
2334
2382
  const props = Object.assign(Object.assign({}, commonRowProps), { row,
2335
2383
  rowIndex });
2336
- return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), `${row.id}`)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
2384
+ return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
2337
2385
  }) })))] }));
2338
2386
  };
2339
2387
  const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
@@ -2368,9 +2416,9 @@ const MRT_TableFooterCell = (_a) => {
2368
2416
 
2369
2417
  const MRT_TableFooterRow = (_a) => {
2370
2418
  var _b;
2371
- var { columnVirtualizer, footerGroup, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table", "virtualColumns"]);
2419
+ var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
2372
2420
  const { options: { layoutMode, muiTableFooterRowProps }, } = table;
2373
- const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2421
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2374
2422
  // if no content in row, skip row
2375
2423
  if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
2376
2424
  !!header.column.columnDef.footer) ||
@@ -2389,7 +2437,7 @@ const MRT_TableFooterRow = (_a) => {
2389
2437
  };
2390
2438
 
2391
2439
  const MRT_TableFooter = (_a) => {
2392
- var { columnVirtualizer, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "table", "virtualColumns"]);
2440
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2393
2441
  const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
2394
2442
  const { isFullScreen } = getState();
2395
2443
  const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
@@ -2406,7 +2454,7 @@ const MRT_TableFooter = (_a) => {
2406
2454
  ? theme.palette.mode === 'light'
2407
2455
  ? `1px solid ${theme.palette.grey[300]}`
2408
2456
  : `1px solid ${theme.palette.grey[700]}`
2409
- : undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table, virtualColumns: virtualColumns }, footerGroup.id))) })));
2457
+ : undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
2410
2458
  };
2411
2459
 
2412
2460
  const MRT_TableHeadCellColumnActionsButton = (_a) => {
@@ -2674,16 +2722,12 @@ const MRT_FilterTextField = (_a) => {
2674
2722
  } }))) : 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) => {
2675
2723
  var _a;
2676
2724
  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 })));
2677
- }, value: filterValue }))) : (jsx(TextField, Object.assign({ SelectProps: {
2678
- displayEmpty: true,
2679
- multiple: isMultiSelectFilter,
2680
- renderValue: isMultiSelectFilter
2725
+ }, value: filterValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
2681
2726
  ? (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) => {
2682
2727
  const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
2683
2728
  return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
2684
2729
  }) }))
2685
- : undefined,
2686
- }, onChange: handleTextFieldChange, select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
2730
+ : undefined }, commonTextFieldProps.SelectProps), onChange: handleTextFieldChange, value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
2687
2731
  jsx(MenuItem, { disabled: true, divider: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
2688
2732
  ...[
2689
2733
  (_u = textFieldProps.children) !== null && _u !== void 0 ? _u : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
@@ -3095,9 +3139,9 @@ const MRT_TableHeadCell = (_a) => {
3095
3139
  };
3096
3140
 
3097
3141
  const MRT_TableHeadRow = (_a) => {
3098
- var { columnVirtualizer, headerGroup, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "headerGroup", "table", "virtualColumns"]);
3142
+ var { columnVirtualizer, headerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "headerGroup", "table"]);
3099
3143
  const { options: { layoutMode, muiTableHeadRowProps }, } = table;
3100
- const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
3144
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
3101
3145
  const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadRowProps, {
3102
3146
  headerGroup,
3103
3147
  table,
@@ -3140,6 +3184,8 @@ const MRT_TablePagination = (_a) => {
3140
3184
  const firstRowIndex = pageIndex * pageSize;
3141
3185
  const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
3142
3186
  const _b = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { SelectProps, disabled = false, rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _b, _rest = __rest(_b, ["SelectProps", "disabled", "rowsPerPageOptions", "showFirstButton", "showLastButton", "showRowsPerPage"]);
3187
+ const disableBack = pageIndex <= 0 || disabled;
3188
+ const disableNext = lastRowIndex >= totalRowCount || disabled;
3143
3189
  return (jsxs(Box, { className: "MuiTablePagination-root", sx: {
3144
3190
  alignItems: 'center',
3145
3191
  display: 'flex',
@@ -3166,7 +3212,7 @@ const MRT_TablePagination = (_a) => {
3166
3212
  last: LastPageIcon,
3167
3213
  next: ChevronRightIcon,
3168
3214
  previous: ChevronLeftIcon,
3169
- } }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxs(Box, { gap: "xs", children: [showFirstButton && (jsx(Tooltip, { title: localization.goToFirstPage, children: jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: pageIndex <= 0 || disabled, onClick: () => setPageIndex(0), size: "small", children: jsx(FirstPageIcon, {}) }) })), jsx(Tooltip, { title: localization.goToPreviousPage, children: jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: pageIndex <= 0 || disabled, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsx(ChevronLeftIcon, {}) }) }), jsx(Tooltip, { title: localization.goToNextPage, children: jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: lastRowIndex >= totalRowCount || disabled, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsx(ChevronRightIcon, {}) }) }), showLastButton && (jsx(Tooltip, { title: localization.goToLastPage, children: jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: lastRowIndex >= totalRowCount || disabled, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsx(LastPageIcon, {}) }) }))] })] })) : null] }));
3215
+ } }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxs(Box, { gap: "xs", children: [showFirstButton && (jsx(Tooltip, { enterDelay: 1000, title: localization.goToFirstPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: disableBack, onClick: () => setPageIndex(0), size: "small", children: jsx(FirstPageIcon, {}) }) }) })), jsx(Tooltip, { enterDelay: 1000, title: localization.goToPreviousPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: disableBack, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsx(ChevronLeftIcon, {}) }) }) }), jsx(Tooltip, { enterDelay: 1000, title: localization.goToNextPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: disableNext, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsx(ChevronRightIcon, {}) }) }) }), showLastButton && (jsx(Tooltip, { enterDelay: 1000, title: localization.goToLastPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: disableNext, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsx(LastPageIcon, {}) }) }) }))] })] })) : null] }));
3170
3216
  };
3171
3217
 
3172
3218
  const MRT_GlobalFilterTextField = (_a) => {
@@ -3363,8 +3409,9 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
3363
3409
  setHoveredColumn(column);
3364
3410
  }
3365
3411
  };
3366
- if (!columnDef.header || columnDef.visibleInShowHideMenu === false)
3412
+ if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
3367
3413
  return null;
3414
+ }
3368
3415
  return (jsxs(Fragment, { children: [jsx(MenuItem, Object.assign({ disableRipple: true, onDragEnter: handleDragEnter, ref: menuItemRef }, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', justifyContent: 'flex-start', my: 0, opacity: isDragging ? 0.5 : 1, outline: isDragging
3369
3416
  ? `2px dashed ${theme.palette.grey[500]}`
3370
3417
  : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
@@ -3507,8 +3554,19 @@ const MRT_TopToolbar = ({ table, }) => {
3507
3554
  const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
3508
3555
  const { isFullScreen, showGlobalFilter } = getState();
3509
3556
  const isMobile = useMediaQuery('(max-width:720px)');
3557
+ const isTablet = useMediaQuery('(max-width:1024px)');
3510
3558
  const toolbarProps = parseFromValuesOrFunc(muiTopToolbarProps, { table });
3511
- const stackAlertBanner = isMobile || !!renderTopToolbarCustomActions || showGlobalFilter;
3559
+ const stackAlertBanner = isMobile ||
3560
+ !!renderTopToolbarCustomActions ||
3561
+ (showGlobalFilter && isTablet);
3562
+ const globalFilterProps = {
3563
+ sx: !isTablet
3564
+ ? {
3565
+ zIndex: 2,
3566
+ }
3567
+ : undefined,
3568
+ table,
3569
+ };
3512
3570
  return (jsxs(Box, Object.assign({}, toolbarProps, { ref: (ref) => {
3513
3571
  topToolbarRef.current = ref;
3514
3572
  if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
@@ -3526,19 +3584,19 @@ const MRT_TopToolbar = ({ table, }) => {
3526
3584
  right: 0,
3527
3585
  top: 0,
3528
3586
  width: '100%',
3529
- }, children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsx(MRT_GlobalFilterTextField, { table: table })), (_a = renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({ table })) !== null && _a !== void 0 ? _a : jsx("span", {}), enableToolbarInternalActions ? (jsxs(Box, { sx: {
3587
+ }, children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), (_a = renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({ table })) !== null && _a !== void 0 ? _a : jsx("span", {}), enableToolbarInternalActions ? (jsxs(Box, { sx: {
3530
3588
  alignItems: 'center',
3531
3589
  display: 'flex',
3532
3590
  flexWrap: 'wrap-reverse',
3533
3591
  gap: '0.5rem',
3534
3592
  justifyContent: 'flex-end',
3535
- }, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, { table: table })), jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
3536
- positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, { table: table })))] }), enablePagination &&
3593
+ }, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
3594
+ positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))))] }), enablePagination &&
3537
3595
  ['both', 'top'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsx(MRT_TablePagination, { position: "top", table: table })), jsx(MRT_LinearProgressBar, { isTopToolbar: true, table: table })] })));
3538
3596
  };
3539
3597
 
3540
3598
  const MRT_TableHead = (_a) => {
3541
- var { columnVirtualizer, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "table", "virtualColumns"]);
3599
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
3542
3600
  const { getHeaderGroups, getSelectedRowModel, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps, positionToolbarAlertBanner, }, refs: { tableHeadRef }, } = table;
3543
3601
  const { isFullScreen, showAlertBanner } = getState();
3544
3602
  const tableHeadProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadProps, { table })), rest);
@@ -3555,7 +3613,7 @@ const MRT_TableHead = (_a) => {
3555
3613
  }, children: jsx("th", { colSpan: table.getVisibleLeafColumns().length, style: {
3556
3614
  display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
3557
3615
  padding: 0,
3558
- }, children: jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table, virtualColumns: virtualColumns }, headerGroup.id)))) })));
3616
+ }, children: jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table }, headerGroup.id)))) })));
3559
3617
  };
3560
3618
 
3561
3619
  const MRT_Table = (_a) => {
@@ -3578,13 +3636,9 @@ const MRT_Table = (_a) => {
3578
3636
  return colSizes;
3579
3637
  }, [columns, columnSizing, columnSizingInfo, columnVisibility]);
3580
3638
  const columnVirtualizer = useMRT_ColumnVirtualizer(table);
3581
- const virtualColumns = columnVirtualizer
3582
- ? columnVirtualizer.getVirtualItems()
3583
- : undefined;
3584
3639
  const commonTableGroupProps = {
3585
3640
  columnVirtualizer,
3586
3641
  table,
3587
- virtualColumns,
3588
3642
  };
3589
3643
  return (jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [enableTableHead && jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps))) : (jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps))), enableTableFooter && jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
3590
3644
  };