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.js CHANGED
@@ -17,12 +17,13 @@ var Box = require('@mui/material/Box');
17
17
  var reactTable = require('@tanstack/react-table');
18
18
  var reactVirtual = require('@tanstack/react-virtual');
19
19
  var highlightWords = require('highlight-words');
20
- var IconButton = require('@mui/material/IconButton');
21
- var Tooltip = require('@mui/material/Tooltip');
22
20
  var Button = require('@mui/material/Button');
21
+ var Tooltip = require('@mui/material/Tooltip');
23
22
  var MenuItem = require('@mui/material/MenuItem');
24
23
  var TextField = require('@mui/material/TextField');
25
24
  var Collapse = require('@mui/material/Collapse');
25
+ var Stack = require('@mui/material/Stack');
26
+ var IconButton = require('@mui/material/IconButton');
26
27
  var CircularProgress = require('@mui/material/CircularProgress');
27
28
  var ListItemIcon = require('@mui/material/ListItemIcon');
28
29
  var Menu = require('@mui/material/Menu');
@@ -75,7 +76,6 @@ var DateTimePicker = require('@mui/x-date-pickers/DateTimePicker');
75
76
  var TimePicker = require('@mui/x-date-pickers/TimePicker');
76
77
  var FormHelperText = require('@mui/material/FormHelperText');
77
78
  var Slider = require('@mui/material/Slider');
78
- var Stack = require('@mui/material/Stack');
79
79
  var Grow = require('@mui/material/Grow');
80
80
  var Popover = require('@mui/material/Popover');
81
81
  var Divider = require('@mui/material/Divider');
@@ -108,12 +108,13 @@ var Skeleton__default = /*#__PURE__*/_interopDefaultLegacy(Skeleton);
108
108
  var TableCell__default = /*#__PURE__*/_interopDefaultLegacy(TableCell);
109
109
  var Box__default = /*#__PURE__*/_interopDefaultLegacy(Box);
110
110
  var highlightWords__default = /*#__PURE__*/_interopDefaultLegacy(highlightWords);
111
- var IconButton__default = /*#__PURE__*/_interopDefaultLegacy(IconButton);
112
- var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
113
111
  var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
112
+ var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
114
113
  var MenuItem__default = /*#__PURE__*/_interopDefaultLegacy(MenuItem);
115
114
  var TextField__default = /*#__PURE__*/_interopDefaultLegacy(TextField);
116
115
  var Collapse__default = /*#__PURE__*/_interopDefaultLegacy(Collapse);
116
+ var Stack__default = /*#__PURE__*/_interopDefaultLegacy(Stack);
117
+ var IconButton__default = /*#__PURE__*/_interopDefaultLegacy(IconButton);
117
118
  var CircularProgress__default = /*#__PURE__*/_interopDefaultLegacy(CircularProgress);
118
119
  var ListItemIcon__default = /*#__PURE__*/_interopDefaultLegacy(ListItemIcon);
119
120
  var Menu__default = /*#__PURE__*/_interopDefaultLegacy(Menu);
@@ -160,7 +161,6 @@ var Chip__default = /*#__PURE__*/_interopDefaultLegacy(Chip);
160
161
  var InputAdornment__default = /*#__PURE__*/_interopDefaultLegacy(InputAdornment);
161
162
  var FormHelperText__default = /*#__PURE__*/_interopDefaultLegacy(FormHelperText);
162
163
  var Slider__default = /*#__PURE__*/_interopDefaultLegacy(Slider);
163
- var Stack__default = /*#__PURE__*/_interopDefaultLegacy(Stack);
164
164
  var Grow__default = /*#__PURE__*/_interopDefaultLegacy(Grow);
165
165
  var Popover__default = /*#__PURE__*/_interopDefaultLegacy(Popover);
166
166
  var Divider__default = /*#__PURE__*/_interopDefaultLegacy(Divider);
@@ -386,6 +386,8 @@ const createRow = (table, originalRow) => reactTable.createRow(table, 'mrt-row-c
386
386
  }))), -1, 0);
387
387
  const extraIndexRangeExtractor = (range, draggingIndex) => {
388
388
  const newIndexes = reactVirtual.defaultRangeExtractor(range);
389
+ if (draggingIndex === undefined)
390
+ return newIndexes;
389
391
  if (draggingIndex >= 0 &&
390
392
  draggingIndex < Math.max(range.startIndex - range.overscan, 0)) {
391
393
  newIndexes.unshift(draggingIndex);
@@ -430,7 +432,7 @@ const getMRTTheme = (table, theme) => (Object.assign({ baseBackgroundColor: them
430
432
  ? styles.darken(theme.palette.warning.dark, 0.25)
431
433
  : styles.lighten(theme.palette.warning.light, 0.5), pinnedRowBackgroundColor: styles.alpha(theme.palette.primary.main, 0.1), selectedRowBackgroundColor: styles.alpha(theme.palette.primary.main, 0.2) }, parseFromValuesOrFunc(table.options.mrtTheme, theme)));
432
434
  const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
433
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
435
+ var _a, _b, _c, _d, _e, _f;
434
436
  const { options: { layoutMode }, } = table;
435
437
  const widthStyles = {
436
438
  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)`,
@@ -450,19 +452,8 @@ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme,
450
452
  ? `4px 0 8px -6px ${styles.alpha(theme.palette.grey[700], 0.5)} inset`
451
453
  : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, left: column.getIsPinned() === 'left'
452
454
  ? `${column.getStart('left')}px`
453
- : undefined, ml: table.options.enableColumnVirtualization &&
454
- column.getIsPinned() === 'left' &&
455
- column.getPinnedIndex() === 0
456
- ? `-${column.getSize() *
457
- ((_f = (_e = table.getState().columnPinning.left) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 1)}px`
458
- : undefined, mr: table.options.enableColumnVirtualization &&
459
- column.getIsPinned() === 'right' &&
460
- column.getPinnedIndex() === table.getVisibleLeafColumns().length - 1
461
- ? `-${column.getSize() *
462
- ((_h = (_g = table.getState().columnPinning.right) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 1) *
463
- 1.2}px`
464
- : undefined, opacity: ((_j = table.getState().draggingColumn) === null || _j === void 0 ? void 0 : _j.id) === column.id ||
465
- ((_k = table.getState().hoveredColumn) === null || _k === void 0 ? void 0 : _k.id) === column.id
455
+ : undefined, opacity: ((_e = table.getState().draggingColumn) === null || _e === void 0 ? void 0 : _e.id) === column.id ||
456
+ ((_f = table.getState().hoveredColumn) === null || _f === void 0 ? void 0 : _f.id) === column.id
466
457
  ? 0.5
467
458
  : 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
468
459
  ? 'sticky'
@@ -485,7 +476,7 @@ const getCommonToolbarStyles = ({ table, theme, }) => ({
485
476
  });
486
477
 
487
478
  const allowedTypes = ['string', 'number'];
488
- const MRT_TableBodyCellValue = ({ cell, table, }) => {
479
+ const MRT_TableBodyCellValue = ({ cell, rowRef, staticRowIndex, table, }) => {
489
480
  var _a, _b, _c;
490
481
  const { getState, options: { enableFilterMatchHighlighting }, } = table;
491
482
  const { column, row } = cell;
@@ -547,51 +538,14 @@ const MRT_TableBodyCellValue = ({ cell, table, }) => {
547
538
  column,
548
539
  renderedCellValue,
549
540
  row,
541
+ rowRef,
542
+ staticRowIndex,
550
543
  table,
551
544
  });
552
545
  }
553
546
  return renderedCellValue;
554
547
  };
555
548
 
556
- const MRT_GrabHandleButton = (_a) => {
557
- var _b, _c;
558
- var { iconButtonProps, location, onDragEnd, onDragStart, table } = _a, rest = __rest(_a, ["iconButtonProps", "location", "onDragEnd", "onDragStart", "table"]);
559
- const { options: { icons: { DragHandleIcon }, localization, }, } = table;
560
- const _iconButtonProps = Object.assign(Object.assign({}, iconButtonProps), rest);
561
- return (jsxRuntime.jsx(Tooltip__default["default"], { 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: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": (_c = _iconButtonProps.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, _iconButtonProps, { onClick: (e) => {
562
- var _a;
563
- e.stopPropagation();
564
- (_a = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(_iconButtonProps, e);
565
- }, onDragEnd: onDragEnd, onDragStart: onDragStart, sx: (theme) => (Object.assign({ '&:active': {
566
- cursor: 'grabbing',
567
- }, '&:hover': {
568
- backgroundColor: 'transparent',
569
- opacity: 1,
570
- }, 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: jsxRuntime.jsx(DragHandleIcon, {}) })) }));
571
- };
572
-
573
- const MRT_TableBodyRowGrabHandle = (_a) => {
574
- var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
575
- const { options: { muiRowDragHandleProps }, } = table;
576
- const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
577
- row,
578
- table,
579
- })), rest);
580
- const handleDragStart = (event) => {
581
- var _a;
582
- (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
583
- event.dataTransfer.setDragImage(rowRef.current, 0, 0);
584
- table.setDraggingRow(row);
585
- };
586
- const handleDragEnd = (event) => {
587
- var _a;
588
- (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
589
- table.setDraggingRow(null);
590
- table.setHoveredRow(null);
591
- };
592
- return (jsxRuntime.jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
593
- };
594
-
595
549
  const MRT_CopyButton = (_a) => {
596
550
  var _b;
597
551
  var { cell, table } = _a, rest = __rest(_a, ["cell", "table"]);
@@ -710,7 +664,7 @@ const MRT_TableBodyCell = (_a) => {
710
664
  var _b, _c, _d, _e, _f;
711
665
  var { cell, measureElement, numRows, rowIndex, rowRef, table, virtualColumnIndex } = _a, rest = __rest(_a, ["cell", "measureElement", "numRows", "rowIndex", "rowRef", "table", "virtualColumnIndex"]);
712
666
  const theme = styles.useTheme();
713
- const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enableRowNumbers, layoutMode, muiSkeletonProps, muiTableBodyCellProps, rowNumberDisplayMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
667
+ const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
714
668
  const { columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
715
669
  const { column, row } = cell;
716
670
  const { columnDef } = column;
@@ -816,6 +770,10 @@ const MRT_TableBodyCell = (_a) => {
816
770
  setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
817
771
  }
818
772
  };
773
+ const cellValueProps = {
774
+ cell,
775
+ table,
776
+ };
819
777
  return (jsxRuntime.jsx(TableCell__default["default"], Object.assign({ "data-index": virtualColumnIndex, ref: (node) => {
820
778
  if (node) {
821
779
  measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
@@ -851,19 +809,18 @@ const MRT_TableBodyCell = (_a) => {
851
809
  table,
852
810
  tableCellProps,
853
811
  theme,
854
- })), draggingBorders)), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (jsxRuntime.jsxs(jsxRuntime.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) ? (jsxRuntime.jsx(Skeleton__default["default"], Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
855
- rowNumberDisplayMode === 'static' &&
856
- column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (jsxRuntime.jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
857
- (column.id === 'mrt-row-select' ||
858
- column.id === 'mrt-row-expand' ||
812
+ })), draggingBorders)), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (jsxRuntime.jsxs(jsxRuntime.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) ? (jsxRuntime.jsx(Skeleton__default["default"], Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : columnDefType === 'display' &&
813
+ (['mrt-row-expand', 'mrt-row-numbers', 'mrt-row-select'].includes(column.id) ||
859
814
  !row.getIsGrouped()) ? ((_e = columnDef.Cell) === null || _e === void 0 ? void 0 : _e.call(columnDef, {
860
815
  cell,
861
816
  column,
862
817
  renderedCellValue: cell.renderValue(),
863
818
  row,
819
+ rowRef,
820
+ staticRowIndex: rowIndex,
864
821
  table,
865
822
  })) : isCreating || isEditing ? (jsxRuntime.jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
866
- columnDef.enableClickToCopy !== false ? (jsxRuntime.jsx(MRT_CopyButton, { cell: cell, table: table, children: jsxRuntime.jsx(MRT_TableBodyCellValue, { cell: cell, table: table }) })) : (jsxRuntime.jsx(MRT_TableBodyCellValue, { cell: cell, table: table })), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
823
+ columnDef.enableClickToCopy !== false ? (jsxRuntime.jsx(MRT_CopyButton, { cell: cell, table: table, children: jsxRuntime.jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps)) })) : (jsxRuntime.jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps))), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
867
824
  };
868
825
  const Memo_MRT_TableBodyCell = react.memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
869
826
 
@@ -893,12 +850,12 @@ const MRT_TableDetailPanel = (_a) => {
893
850
  : 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 && (jsxRuntime.jsx(Collapse__default["default"], { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: !isLoading && renderDetailPanel({ row, table }) })) })) })));
894
851
  };
895
852
 
896
- const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table, virtualColumns, virtualRow, }) => {
853
+ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table, virtualRow, }) => {
897
854
  var _a, _b, _c, _d;
898
855
  const theme = styles.useTheme();
899
856
  const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
900
857
  const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
901
- const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
858
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
902
859
  const isPinned = enableRowPinning && row.getIsPinned();
903
860
  const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
904
861
  row,
@@ -998,7 +955,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
998
955
  const Memo_MRT_TableBodyRow = react.memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.rowIndex === next.rowIndex);
999
956
 
1000
957
  const useMRT_ColumnVirtualizer = (table) => {
1001
- var _a, _b, _c, _d;
958
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1002
959
  const { getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, enableColumnPinning, enableColumnVirtualization, }, refs: { tableContainerRef }, } = table;
1003
960
  const { columnPinning, columnVisibility, draggingColumn } = getState();
1004
961
  const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, {
@@ -1009,7 +966,8 @@ const useMRT_ColumnVirtualizer = (table) => {
1009
966
  table.getLeftLeafColumns().map((c) => c.getPinnedIndex()),
1010
967
  table
1011
968
  .getRightLeafColumns()
1012
- .map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1),
969
+ .map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1)
970
+ .sort((a, b) => a - b),
1013
971
  ]
1014
972
  : [[], []], [columnPinning, enableColumnVirtualization, enableColumnPinning]);
1015
973
  //get first 16 column widths and average them if calc is needed
@@ -1023,9 +981,11 @@ const useMRT_ColumnVirtualizer = (table) => {
1023
981
  .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 : [];
1024
982
  return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
1025
983
  }, [table.getRowModel().rows, columnPinning, columnVisibility]);
1026
- const draggingColumnIndex = table
1027
- .getVisibleLeafColumns()
1028
- .findIndex((c) => c.id === (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id));
984
+ const draggingColumnIndex = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)
985
+ ? table
986
+ .getVisibleLeafColumns()
987
+ .findIndex((c) => c.id === (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id))
988
+ : undefined;
1029
989
  const columnVirtualizer = enableColumnVirtualization
1030
990
  ? reactVirtual.useVirtualizer(Object.assign({ count: table.getVisibleLeafColumns().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: react.useCallback((range) => {
1031
991
  const newIndexes = extraIndexRangeExtractor(range, draggingColumnIndex);
@@ -1038,25 +998,68 @@ const useMRT_ColumnVirtualizer = (table) => {
1038
998
  ];
1039
999
  }, [leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex]) }, columnVirtualizerProps))
1040
1000
  : undefined;
1041
- if (columnVirtualizerInstanceRef && columnVirtualizer) {
1042
- //@ts-ignore
1043
- columnVirtualizerInstanceRef.current = columnVirtualizer;
1044
- }
1045
- const virtualColumns = columnVirtualizer
1046
- ? columnVirtualizer.getVirtualItems()
1047
- : undefined;
1048
- if (columnVirtualizer && (virtualColumns === null || virtualColumns === void 0 ? void 0 : virtualColumns.length)) {
1049
- // @ts-ignore
1050
- columnVirtualizer.virtualPaddingLeft =
1051
- (_b = (_a = virtualColumns[leftPinnedIndexes.length]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0;
1052
- // @ts-ignore
1053
- columnVirtualizer.virtualPaddingRight =
1054
- columnVirtualizer.getTotalSize() -
1055
- ((_d = (_c = virtualColumns[virtualColumns.length - 1 - rightPinnedIndexes.length]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0);
1001
+ if (columnVirtualizer) {
1002
+ const virtualColumns = columnVirtualizer.getVirtualItems();
1003
+ columnVirtualizer.virtualColumns = virtualColumns;
1004
+ if (virtualColumns.length) {
1005
+ columnVirtualizer.virtualPaddingLeft =
1006
+ ((_b = (_a = virtualColumns[leftPinnedIndexes.length]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0) -
1007
+ ((_d = (_c = virtualColumns[leftPinnedIndexes.length - 1]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0);
1008
+ columnVirtualizer.virtualPaddingRight =
1009
+ columnVirtualizer.getTotalSize() -
1010
+ ((_f = (_e = virtualColumns[virtualColumns.length - rightPinnedIndexes.length - 1]) === null || _e === void 0 ? void 0 : _e.end) !== null && _f !== void 0 ? _f : 0) -
1011
+ (rightPinnedIndexes.length
1012
+ ? columnVirtualizer.getTotalSize() -
1013
+ ((_h = (_g = virtualColumns[virtualColumns.length - rightPinnedIndexes.length]) === null || _g === void 0 ? void 0 : _g.start) !== null && _h !== void 0 ? _h : 0)
1014
+ : 0);
1015
+ }
1016
+ if (columnVirtualizerInstanceRef) {
1017
+ //@ts-ignore
1018
+ columnVirtualizerInstanceRef.current = columnVirtualizer;
1019
+ }
1056
1020
  }
1057
1021
  return columnVirtualizer;
1058
1022
  };
1059
1023
 
1024
+ const MRT_GrabHandleButton = (_a) => {
1025
+ var _b, _c;
1026
+ var { iconButtonProps, location, onDragEnd, onDragStart, table } = _a, rest = __rest(_a, ["iconButtonProps", "location", "onDragEnd", "onDragStart", "table"]);
1027
+ const { options: { icons: { DragHandleIcon }, localization, }, } = table;
1028
+ const _iconButtonProps = Object.assign(Object.assign({}, iconButtonProps), rest);
1029
+ return (jsxRuntime.jsx(Tooltip__default["default"], { 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: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": (_c = _iconButtonProps.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, _iconButtonProps, { onClick: (e) => {
1030
+ var _a;
1031
+ e.stopPropagation();
1032
+ (_a = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(_iconButtonProps, e);
1033
+ }, onDragEnd: onDragEnd, onDragStart: onDragStart, sx: (theme) => (Object.assign({ '&:active': {
1034
+ cursor: 'grabbing',
1035
+ }, '&:hover': {
1036
+ backgroundColor: 'transparent',
1037
+ opacity: 1,
1038
+ }, 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: jsxRuntime.jsx(DragHandleIcon, {}) })) }));
1039
+ };
1040
+
1041
+ const MRT_TableBodyRowGrabHandle = (_a) => {
1042
+ var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
1043
+ const { options: { muiRowDragHandleProps }, } = table;
1044
+ const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
1045
+ row,
1046
+ table,
1047
+ })), rest);
1048
+ const handleDragStart = (event) => {
1049
+ var _a;
1050
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1051
+ event.dataTransfer.setDragImage(rowRef.current, 0, 0);
1052
+ table.setDraggingRow(row);
1053
+ };
1054
+ const handleDragEnd = (event) => {
1055
+ var _a;
1056
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1057
+ table.setDraggingRow(null);
1058
+ table.setHoveredRow(null);
1059
+ };
1060
+ return (jsxRuntime.jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
1061
+ };
1062
+
1060
1063
  const MRT_RowPinButton = (_a) => {
1061
1064
  var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
1062
1065
  const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
@@ -1391,7 +1394,7 @@ const commonListItemStyles = {
1391
1394
  const MRT_ColumnActionMenu = (_a) => {
1392
1395
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1393
1396
  var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
1394
- 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;
1397
+ 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;
1395
1398
  const { column } = header;
1396
1399
  const { columnDef } = column;
1397
1400
  const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
@@ -1428,8 +1431,14 @@ const MRT_ColumnActionMenu = (_a) => {
1428
1431
  setAnchorEl(null);
1429
1432
  };
1430
1433
  const handleClearFilter = () => {
1431
- column.setFilterValue('');
1434
+ column.setFilterValue(undefined);
1432
1435
  setAnchorEl(null);
1436
+ if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
1437
+ setColumnFilterFns((prev) => {
1438
+ var _a;
1439
+ return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
1440
+ });
1441
+ }
1433
1442
  };
1434
1443
  const handleFilterByColumn = () => {
1435
1444
  setShowColumnFilters(true);
@@ -1560,40 +1569,53 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
1560
1569
 
1561
1570
  const MRT_SelectCheckbox = (_a) => {
1562
1571
  var _b;
1563
- var { row, selectAll, table } = _a, rest = __rest(_a, ["row", "selectAll", "table"]);
1572
+ var { row, selectAll, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "selectAll", "staticRowIndex", "table"]);
1564
1573
  const { getState, options: { enableMultiRowSelection, enableRowPinning, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, rowPinningDisplayMode, selectAllMode, }, } = table;
1565
1574
  const { density, isLoading } = getState();
1566
1575
  const checkboxProps = Object.assign(Object.assign({}, (!row
1567
1576
  ? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
1568
- : parseFromValuesOrFunc(muiSelectCheckboxProps, { row, table }))), rest);
1577
+ : parseFromValuesOrFunc(muiSelectCheckboxProps, {
1578
+ row,
1579
+ staticRowIndex,
1580
+ table,
1581
+ }))), rest);
1582
+ const isStickySelection = enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'));
1569
1583
  const allRowsSelected = selectAll
1570
1584
  ? selectAllMode === 'page'
1571
1585
  ? table.getIsAllPageRowsSelected()
1572
1586
  : table.getIsAllRowsSelected()
1573
1587
  : undefined;
1574
- 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: {
1588
+ const onSelectionChange = (event, row) => {
1589
+ var _a;
1590
+ if (row.getIsAllSubRowsSelected()) {
1591
+ (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.forEach((r) => r.toggleSelected(false));
1592
+ }
1593
+ row.getToggleSelectedHandler()(event);
1594
+ if (isStickySelection) {
1595
+ row.pin(!row.getIsPinned() && event.target.checked
1596
+ ? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
1597
+ ? 'bottom'
1598
+ : 'top'
1599
+ : false);
1600
+ }
1601
+ };
1602
+ const onSelectAllChange = (event) => {
1603
+ selectAllMode === 'all'
1604
+ ? table.getToggleAllRowsSelectedHandler()(event)
1605
+ : table.getToggleAllPageRowsSelectedHandler()(event);
1606
+ if (isStickySelection) {
1607
+ table.setRowPinning({ bottom: [], top: [] });
1608
+ }
1609
+ };
1610
+ const commonProps = Object.assign(Object.assign({ checked: selectAll
1611
+ ? allRowsSelected
1612
+ : (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: {
1575
1613
  'aria-label': selectAll
1576
1614
  ? localization.toggleSelectAll
1577
1615
  : localization.toggleSelectRow,
1578
1616
  }, onChange: (event) => {
1579
1617
  event.stopPropagation();
1580
- row
1581
- ? row.getToggleSelectedHandler()(event)
1582
- : selectAllMode === 'all'
1583
- ? table.getToggleAllRowsSelectedHandler()(event)
1584
- : table.getToggleAllPageRowsSelectedHandler()(event);
1585
- if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
1586
- if (row) {
1587
- row.pin(!row.getIsPinned() && event.target.checked
1588
- ? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
1589
- ? 'bottom'
1590
- : 'top'
1591
- : false);
1592
- }
1593
- else {
1594
- table.setRowPinning({ bottom: [], top: [] });
1595
- }
1596
- }
1618
+ row ? onSelectionChange(event, row) : onSelectAllChange(event);
1597
1619
  }, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
1598
1620
  var _a;
1599
1621
  e.stopPropagation();
@@ -1639,6 +1661,7 @@ const useMRT_DisplayColumns = (params) => {
1639
1661
  tableOptions.enableRowOrdering,
1640
1662
  tableOptions.enableRowSelection,
1641
1663
  tableOptions.enableSelectAll,
1664
+ tableOptions.groupedColumnMode,
1642
1665
  tableOptions.localization,
1643
1666
  tableOptions.positionActionsColumn,
1644
1667
  tableOptions.renderDetailPanel,
@@ -1674,20 +1697,38 @@ function makeRowActionsColumn({ creatingRow, tableOptions }, order) {
1674
1697
  return null;
1675
1698
  }
1676
1699
  function makeRowExpandColumn({ grouping, tableOptions }, order) {
1677
- var _a, _b;
1700
+ var _a, _b, _c;
1678
1701
  const id = 'mrt-row-expand';
1679
1702
  if (order.includes(id) &&
1680
1703
  showExpandColumn(tableOptions, (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.grouping) !== null && _b !== void 0 ? _b : grouping)) {
1681
- return Object.assign({ Cell: ({ row, table }) => jsxRuntime.jsx(MRT_ExpandButton, { row: row, table: table }), Header: tableOptions.enableExpandAll
1682
- ? ({ table }) => jsxRuntime.jsx(MRT_ExpandAllButton, { table: table })
1683
- : undefined }, defaultDisplayColumnProps(tableOptions, id, 'expand'));
1704
+ return Object.assign({ Cell: ({ cell, column, row, table }) => {
1705
+ var _a, _b, _c;
1706
+ const expandButtonProps = { row, table };
1707
+ const subRowsLength = (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length;
1708
+ if (tableOptions.groupedColumnMode === 'remove' &&
1709
+ row.groupingColumnId) {
1710
+ return (jsxRuntime.jsxs(Stack__default["default"], { alignItems: "center", flexDirection: "row", gap: "0.25rem", children: [jsxRuntime.jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), jsxRuntime.jsx(Tooltip__default["default"], { enterDelay: 1000, enterNextDelay: 1000, placement: "right", title: table.getColumn(row.groupingColumnId).columnDef.header, children: jsxRuntime.jsx("span", { children: row.groupingValue }) }), !!subRowsLength && jsxRuntime.jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
1711
+ }
1712
+ else {
1713
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), (_c = (_b = column.columnDef).GroupedCell) === null || _c === void 0 ? void 0 : _c.call(_b, { cell, column, row, table })] }));
1714
+ }
1715
+ }, Header: tableOptions.enableExpandAll
1716
+ ? ({ table }) => {
1717
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MRT_ExpandAllButton, { table: table }), tableOptions.groupedColumnMode === 'remove' &&
1718
+ grouping
1719
+ .map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)
1720
+ .join(', ')] }));
1721
+ }
1722
+ : undefined }, defaultDisplayColumnProps(tableOptions, id, 'expand', tableOptions.groupedColumnMode === 'remove'
1723
+ ? (_c = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.defaultColumn) === null || _c === void 0 ? void 0 : _c.size
1724
+ : 60));
1684
1725
  }
1685
1726
  return null;
1686
1727
  }
1687
1728
  function makeRowSelectColumn({ tableOptions }, order) {
1688
1729
  const id = 'mrt-row-select';
1689
1730
  if (order.includes(id)) {
1690
- return Object.assign({ Cell: ({ row, table }) => jsxRuntime.jsx(MRT_SelectCheckbox, { row: row, table: table }), Header: tableOptions.enableSelectAll && tableOptions.enableMultiRowSelection
1731
+ return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsxRuntime.jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: tableOptions.enableSelectAll && tableOptions.enableMultiRowSelection
1691
1732
  ? ({ table }) => jsxRuntime.jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
1692
1733
  : undefined }, defaultDisplayColumnProps(tableOptions, id, 'select'));
1693
1734
  }
@@ -1696,7 +1737,12 @@ function makeRowSelectColumn({ tableOptions }, order) {
1696
1737
  function makeRowNumbersColumn({ tableOptions }, order) {
1697
1738
  const id = 'mrt-row-numbers';
1698
1739
  if (order.includes(id) || tableOptions.enableRowNumbers)
1699
- return Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => tableOptions.localization.rowNumber }, defaultDisplayColumnProps(tableOptions, id, 'rowNumbers'));
1740
+ return Object.assign({ Cell: ({ row, staticRowIndex }) => {
1741
+ var _a;
1742
+ return ((_a = (tableOptions.rowNumberDisplayMode === 'static'
1743
+ ? staticRowIndex
1744
+ : row.index)) !== null && _a !== void 0 ? _a : 0) + 1;
1745
+ }, Header: () => tableOptions.localization.rowNumber }, defaultDisplayColumnProps(tableOptions, id, 'rowNumbers'));
1700
1746
  return null;
1701
1747
  }
1702
1748
  const blankColProps = {
@@ -1800,9 +1846,13 @@ const useMRT_RowVirtualizer = (table, rows) => {
1800
1846
  return extraIndexRangeExtractor(range, (_a = draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.index) !== null && _a !== void 0 ? _a : 0);
1801
1847
  }, [draggingRow]) }, rowVirtualizerProps))
1802
1848
  : undefined;
1803
- if (rowVirtualizerInstanceRef && rowVirtualizer) {
1804
- //@ts-ignore
1805
- rowVirtualizerInstanceRef.current = rowVirtualizer;
1849
+ if (rowVirtualizer) {
1850
+ const virtualRows = rowVirtualizer.getVirtualItems();
1851
+ rowVirtualizer.virtualRows = virtualRows;
1852
+ if (rowVirtualizerInstanceRef) {
1853
+ //@ts-ignore
1854
+ rowVirtualizerInstanceRef.current = rowVirtualizer;
1855
+ }
1806
1856
  }
1807
1857
  return rowVirtualizer;
1808
1858
  };
@@ -2361,7 +2411,7 @@ const useMRT_TableOptions = (_a) => {
2361
2411
 
2362
2412
  const MRT_TableBody = (_a) => {
2363
2413
  var _b, _c, _d, _e, _f, _g;
2364
- var { columnVirtualizer, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "table", "virtualColumns"]);
2414
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2365
2415
  const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { createDisplayMode, enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
2366
2416
  const { columnFilters, creatingRow, globalFilter, isFullScreen, rowPinning } = getState();
2367
2417
  const tableBodyProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyProps, { table })), rest);
@@ -2379,14 +2429,11 @@ const MRT_TableBody = (_a) => {
2379
2429
  }, [rowPinning, getRowModel().rows]);
2380
2430
  const rows = useMRT_Rows(table, pinnedRowIds);
2381
2431
  const rowVirtualizer = useMRT_RowVirtualizer(table, rows);
2382
- const virtualRows = rowVirtualizer
2383
- ? rowVirtualizer.getVirtualItems()
2384
- : undefined;
2432
+ const { virtualRows } = rowVirtualizer !== null && rowVirtualizer !== void 0 ? rowVirtualizer : {};
2385
2433
  const commonRowProps = {
2386
2434
  columnVirtualizer,
2387
2435
  numRows: rows.length,
2388
2436
  table,
2389
- virtualColumns,
2390
2437
  };
2391
2438
  const CreatingRow = creatingRow && createDisplayMode === 'row' && (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, commonRowProps, { row: creatingRow, rowIndex: -1 })));
2392
2439
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
@@ -2417,12 +2464,13 @@ const MRT_TableBody = (_a) => {
2417
2464
  row, rowIndex: rowVirtualizer ? rowOrVirtualRow.index : rowIndex, virtualRow: rowVirtualizer
2418
2465
  ? rowOrVirtualRow
2419
2466
  : undefined });
2420
- return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), `${row.id}-${row.index}`)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), `${row.id}-${row.index}`));
2467
+ const key = `${row.id}-${row.index}`;
2468
+ return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), key)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), key));
2421
2469
  }) })))] })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
2422
2470
  getIsSomeRowsPinned('bottom') && (jsxRuntime.jsx(TableBody__default["default"], 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) => {
2423
2471
  const props = Object.assign(Object.assign({}, commonRowProps), { row,
2424
2472
  rowIndex });
2425
- return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), `${row.id}`)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
2473
+ return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
2426
2474
  }) })))] }));
2427
2475
  };
2428
2476
  const Memo_MRT_TableBody = react.memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
@@ -2457,9 +2505,9 @@ const MRT_TableFooterCell = (_a) => {
2457
2505
 
2458
2506
  const MRT_TableFooterRow = (_a) => {
2459
2507
  var _b;
2460
- var { columnVirtualizer, footerGroup, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table", "virtualColumns"]);
2508
+ var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
2461
2509
  const { options: { layoutMode, muiTableFooterRowProps }, } = table;
2462
- const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2510
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2463
2511
  // if no content in row, skip row
2464
2512
  if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
2465
2513
  !!header.column.columnDef.footer) ||
@@ -2478,7 +2526,7 @@ const MRT_TableFooterRow = (_a) => {
2478
2526
  };
2479
2527
 
2480
2528
  const MRT_TableFooter = (_a) => {
2481
- var { columnVirtualizer, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "table", "virtualColumns"]);
2529
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2482
2530
  const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
2483
2531
  const { isFullScreen } = getState();
2484
2532
  const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
@@ -2495,7 +2543,7 @@ const MRT_TableFooter = (_a) => {
2495
2543
  ? theme.palette.mode === 'light'
2496
2544
  ? `1px solid ${theme.palette.grey[300]}`
2497
2545
  : `1px solid ${theme.palette.grey[700]}`
2498
- : undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsxRuntime.jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table, virtualColumns: virtualColumns }, footerGroup.id))) })));
2546
+ : undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsxRuntime.jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
2499
2547
  };
2500
2548
 
2501
2549
  const MRT_TableHeadCellColumnActionsButton = (_a) => {
@@ -2763,16 +2811,12 @@ const MRT_FilterTextField = (_a) => {
2763
2811
  } }))) : isAutocompleteFilter ? (jsxRuntime.jsx(Autocomplete__default["default"], 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) => {
2764
2812
  var _a;
2765
2813
  return (jsxRuntime.jsx(TextField__default["default"], 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 })));
2766
- }, value: filterValue }))) : (jsxRuntime.jsx(TextField__default["default"], Object.assign({ SelectProps: {
2767
- displayEmpty: true,
2768
- multiple: isMultiSelectFilter,
2769
- renderValue: isMultiSelectFilter
2814
+ }, value: filterValue }))) : (jsxRuntime.jsx(TextField__default["default"], Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
2770
2815
  ? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (jsxRuntime.jsx(Box__default["default"], { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsxRuntime.jsx(Box__default["default"], { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected === null || selected === void 0 ? void 0 : selected.map((value) => {
2771
2816
  const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
2772
2817
  return (jsxRuntime.jsx(Chip__default["default"], { label: getValueAndLabel(selectedValue).label }, value));
2773
2818
  }) }))
2774
- : undefined,
2775
- }, onChange: handleTextFieldChange, select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
2819
+ : undefined }, commonTextFieldProps.SelectProps), onChange: handleTextFieldChange, value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
2776
2820
  jsxRuntime.jsx(MenuItem__default["default"], { disabled: true, divider: true, hidden: true, value: "", children: jsxRuntime.jsx(Box__default["default"], { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
2777
2821
  ...[
2778
2822
  (_u = textFieldProps.children) !== null && _u !== void 0 ? _u : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
@@ -3184,9 +3228,9 @@ const MRT_TableHeadCell = (_a) => {
3184
3228
  };
3185
3229
 
3186
3230
  const MRT_TableHeadRow = (_a) => {
3187
- var { columnVirtualizer, headerGroup, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "headerGroup", "table", "virtualColumns"]);
3231
+ var { columnVirtualizer, headerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "headerGroup", "table"]);
3188
3232
  const { options: { layoutMode, muiTableHeadRowProps }, } = table;
3189
- const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
3233
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
3190
3234
  const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadRowProps, {
3191
3235
  headerGroup,
3192
3236
  table,
@@ -3229,6 +3273,8 @@ const MRT_TablePagination = (_a) => {
3229
3273
  const firstRowIndex = pageIndex * pageSize;
3230
3274
  const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
3231
3275
  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"]);
3276
+ const disableBack = pageIndex <= 0 || disabled;
3277
+ const disableNext = lastRowIndex >= totalRowCount || disabled;
3232
3278
  return (jsxRuntime.jsxs(Box__default["default"], { className: "MuiTablePagination-root", sx: {
3233
3279
  alignItems: 'center',
3234
3280
  display: 'flex',
@@ -3255,7 +3301,7 @@ const MRT_TablePagination = (_a) => {
3255
3301
  last: LastPageIcon,
3256
3302
  next: ChevronRightIcon,
3257
3303
  previous: ChevronLeftIcon,
3258
- } }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography__default["default"], { 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()}` }), jsxRuntime.jsxs(Box__default["default"], { gap: "xs", children: [showFirstButton && (jsxRuntime.jsx(Tooltip__default["default"], { title: localization.goToFirstPage, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToFirstPage, disabled: pageIndex <= 0 || disabled, onClick: () => setPageIndex(0), size: "small", children: jsxRuntime.jsx(FirstPageIcon, {}) }) })), jsxRuntime.jsx(Tooltip__default["default"], { title: localization.goToPreviousPage, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToPreviousPage, disabled: pageIndex <= 0 || disabled, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsxRuntime.jsx(ChevronLeftIcon, {}) }) }), jsxRuntime.jsx(Tooltip__default["default"], { title: localization.goToNextPage, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToNextPage, disabled: lastRowIndex >= totalRowCount || disabled, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsxRuntime.jsx(ChevronRightIcon, {}) }) }), showLastButton && (jsxRuntime.jsx(Tooltip__default["default"], { title: localization.goToLastPage, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToLastPage, disabled: lastRowIndex >= totalRowCount || disabled, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsxRuntime.jsx(LastPageIcon, {}) }) }))] })] })) : null] }));
3304
+ } }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography__default["default"], { 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()}` }), jsxRuntime.jsxs(Box__default["default"], { gap: "xs", children: [showFirstButton && (jsxRuntime.jsx(Tooltip__default["default"], { enterDelay: 1000, title: localization.goToFirstPage, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToFirstPage, disabled: disableBack, onClick: () => setPageIndex(0), size: "small", children: jsxRuntime.jsx(FirstPageIcon, {}) }) }) })), jsxRuntime.jsx(Tooltip__default["default"], { enterDelay: 1000, title: localization.goToPreviousPage, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToPreviousPage, disabled: disableBack, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsxRuntime.jsx(ChevronLeftIcon, {}) }) }) }), jsxRuntime.jsx(Tooltip__default["default"], { enterDelay: 1000, title: localization.goToNextPage, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToNextPage, disabled: disableNext, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsxRuntime.jsx(ChevronRightIcon, {}) }) }) }), showLastButton && (jsxRuntime.jsx(Tooltip__default["default"], { enterDelay: 1000, title: localization.goToLastPage, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToLastPage, disabled: disableNext, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsxRuntime.jsx(LastPageIcon, {}) }) }) }))] })] })) : null] }));
3259
3305
  };
3260
3306
 
3261
3307
  const MRT_GlobalFilterTextField = (_a) => {
@@ -3452,8 +3498,9 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
3452
3498
  setHoveredColumn(column);
3453
3499
  }
3454
3500
  };
3455
- if (!columnDef.header || columnDef.visibleInShowHideMenu === false)
3501
+ if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
3456
3502
  return null;
3503
+ }
3457
3504
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem__default["default"], 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
3458
3505
  ? `2px dashed ${theme.palette.grey[500]}`
3459
3506
  : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
@@ -3596,8 +3643,19 @@ const MRT_TopToolbar = ({ table, }) => {
3596
3643
  const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
3597
3644
  const { isFullScreen, showGlobalFilter } = getState();
3598
3645
  const isMobile = useMediaQuery__default["default"]('(max-width:720px)');
3646
+ const isTablet = useMediaQuery__default["default"]('(max-width:1024px)');
3599
3647
  const toolbarProps = parseFromValuesOrFunc(muiTopToolbarProps, { table });
3600
- const stackAlertBanner = isMobile || !!renderTopToolbarCustomActions || showGlobalFilter;
3648
+ const stackAlertBanner = isMobile ||
3649
+ !!renderTopToolbarCustomActions ||
3650
+ (showGlobalFilter && isTablet);
3651
+ const globalFilterProps = {
3652
+ sx: !isTablet
3653
+ ? {
3654
+ zIndex: 2,
3655
+ }
3656
+ : undefined,
3657
+ table,
3658
+ };
3601
3659
  return (jsxRuntime.jsxs(Box__default["default"], Object.assign({}, toolbarProps, { ref: (ref) => {
3602
3660
  topToolbarRef.current = ref;
3603
3661
  if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
@@ -3615,19 +3673,19 @@ const MRT_TopToolbar = ({ table, }) => {
3615
3673
  right: 0,
3616
3674
  top: 0,
3617
3675
  width: '100%',
3618
- }, children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, { table: table })), (_a = renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({ table })) !== null && _a !== void 0 ? _a : jsxRuntime.jsx("span", {}), enableToolbarInternalActions ? (jsxRuntime.jsxs(Box__default["default"], { sx: {
3676
+ }, children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), (_a = renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({ table })) !== null && _a !== void 0 ? _a : jsxRuntime.jsx("span", {}), enableToolbarInternalActions ? (jsxRuntime.jsxs(Box__default["default"], { sx: {
3619
3677
  alignItems: 'center',
3620
3678
  display: 'flex',
3621
3679
  flexWrap: 'wrap-reverse',
3622
3680
  gap: '0.5rem',
3623
3681
  justifyContent: 'flex-end',
3624
- }, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, { table: table })), jsxRuntime.jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
3625
- positionGlobalFilter === 'right' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, { table: table })))] }), enablePagination &&
3682
+ }, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), jsxRuntime.jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
3683
+ positionGlobalFilter === 'right' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))))] }), enablePagination &&
3626
3684
  ['both', 'top'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsxRuntime.jsx(MRT_TablePagination, { position: "top", table: table })), jsxRuntime.jsx(MRT_LinearProgressBar, { isTopToolbar: true, table: table })] })));
3627
3685
  };
3628
3686
 
3629
3687
  const MRT_TableHead = (_a) => {
3630
- var { columnVirtualizer, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "table", "virtualColumns"]);
3688
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
3631
3689
  const { getHeaderGroups, getSelectedRowModel, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps, positionToolbarAlertBanner, }, refs: { tableHeadRef }, } = table;
3632
3690
  const { isFullScreen, showAlertBanner } = getState();
3633
3691
  const tableHeadProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadProps, { table })), rest);
@@ -3644,7 +3702,7 @@ const MRT_TableHead = (_a) => {
3644
3702
  }, children: jsxRuntime.jsx("th", { colSpan: table.getVisibleLeafColumns().length, style: {
3645
3703
  display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
3646
3704
  padding: 0,
3647
- }, children: jsxRuntime.jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table, virtualColumns: virtualColumns }, headerGroup.id)))) })));
3705
+ }, children: jsxRuntime.jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table }, headerGroup.id)))) })));
3648
3706
  };
3649
3707
 
3650
3708
  const MRT_Table = (_a) => {
@@ -3667,13 +3725,9 @@ const MRT_Table = (_a) => {
3667
3725
  return colSizes;
3668
3726
  }, [columns, columnSizing, columnSizingInfo, columnVisibility]);
3669
3727
  const columnVirtualizer = useMRT_ColumnVirtualizer(table);
3670
- const virtualColumns = columnVirtualizer
3671
- ? columnVirtualizer.getVirtualItems()
3672
- : undefined;
3673
3728
  const commonTableGroupProps = {
3674
3729
  columnVirtualizer,
3675
3730
  table,
3676
- virtualColumns,
3677
3731
  };
3678
3732
  return (jsxRuntime.jsxs(Table__default["default"], 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 && jsxRuntime.jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsxRuntime.jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps))) : (jsxRuntime.jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps))), enableTableFooter && jsxRuntime.jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
3679
3733
  };