material-react-table 2.4.1 → 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);
@@ -476,7 +476,7 @@ const getCommonToolbarStyles = ({ table, theme, }) => ({
476
476
  });
477
477
 
478
478
  const allowedTypes = ['string', 'number'];
479
- const MRT_TableBodyCellValue = ({ cell, table, }) => {
479
+ const MRT_TableBodyCellValue = ({ cell, rowRef, staticRowIndex, table, }) => {
480
480
  var _a, _b, _c;
481
481
  const { getState, options: { enableFilterMatchHighlighting }, } = table;
482
482
  const { column, row } = cell;
@@ -538,51 +538,14 @@ const MRT_TableBodyCellValue = ({ cell, table, }) => {
538
538
  column,
539
539
  renderedCellValue,
540
540
  row,
541
+ rowRef,
542
+ staticRowIndex,
541
543
  table,
542
544
  });
543
545
  }
544
546
  return renderedCellValue;
545
547
  };
546
548
 
547
- const MRT_GrabHandleButton = (_a) => {
548
- var _b, _c;
549
- var { iconButtonProps, location, onDragEnd, onDragStart, table } = _a, rest = __rest(_a, ["iconButtonProps", "location", "onDragEnd", "onDragStart", "table"]);
550
- const { options: { icons: { DragHandleIcon }, localization, }, } = table;
551
- const _iconButtonProps = Object.assign(Object.assign({}, iconButtonProps), rest);
552
- 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) => {
553
- var _a;
554
- e.stopPropagation();
555
- (_a = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(_iconButtonProps, e);
556
- }, onDragEnd: onDragEnd, onDragStart: onDragStart, sx: (theme) => (Object.assign({ '&:active': {
557
- cursor: 'grabbing',
558
- }, '&:hover': {
559
- backgroundColor: 'transparent',
560
- opacity: 1,
561
- }, 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, {}) })) }));
562
- };
563
-
564
- const MRT_TableBodyRowGrabHandle = (_a) => {
565
- var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
566
- const { options: { muiRowDragHandleProps }, } = table;
567
- const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
568
- row,
569
- table,
570
- })), rest);
571
- const handleDragStart = (event) => {
572
- var _a;
573
- (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
574
- event.dataTransfer.setDragImage(rowRef.current, 0, 0);
575
- table.setDraggingRow(row);
576
- };
577
- const handleDragEnd = (event) => {
578
- var _a;
579
- (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
580
- table.setDraggingRow(null);
581
- table.setHoveredRow(null);
582
- };
583
- return (jsxRuntime.jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
584
- };
585
-
586
549
  const MRT_CopyButton = (_a) => {
587
550
  var _b;
588
551
  var { cell, table } = _a, rest = __rest(_a, ["cell", "table"]);
@@ -701,7 +664,7 @@ const MRT_TableBodyCell = (_a) => {
701
664
  var _b, _c, _d, _e, _f;
702
665
  var { cell, measureElement, numRows, rowIndex, rowRef, table, virtualColumnIndex } = _a, rest = __rest(_a, ["cell", "measureElement", "numRows", "rowIndex", "rowRef", "table", "virtualColumnIndex"]);
703
666
  const theme = styles.useTheme();
704
- 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;
705
668
  const { columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
706
669
  const { column, row } = cell;
707
670
  const { columnDef } = column;
@@ -807,6 +770,10 @@ const MRT_TableBodyCell = (_a) => {
807
770
  setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
808
771
  }
809
772
  };
773
+ const cellValueProps = {
774
+ cell,
775
+ table,
776
+ };
810
777
  return (jsxRuntime.jsx(TableCell__default["default"], Object.assign({ "data-index": virtualColumnIndex, ref: (node) => {
811
778
  if (node) {
812
779
  measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
@@ -842,19 +809,18 @@ const MRT_TableBodyCell = (_a) => {
842
809
  table,
843
810
  tableCellProps,
844
811
  theme,
845
- })), 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 &&
846
- rowNumberDisplayMode === 'static' &&
847
- column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (jsxRuntime.jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
848
- (column.id === 'mrt-row-select' ||
849
- 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) ||
850
814
  !row.getIsGrouped()) ? ((_e = columnDef.Cell) === null || _e === void 0 ? void 0 : _e.call(columnDef, {
851
815
  cell,
852
816
  column,
853
817
  renderedCellValue: cell.renderValue(),
854
818
  row,
819
+ rowRef,
820
+ staticRowIndex: rowIndex,
855
821
  table,
856
822
  })) : isCreating || isEditing ? (jsxRuntime.jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
857
- 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, ")"] }))] })) })));
858
824
  };
859
825
  const Memo_MRT_TableBodyCell = react.memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
860
826
 
@@ -1055,6 +1021,45 @@ const useMRT_ColumnVirtualizer = (table) => {
1055
1021
  return columnVirtualizer;
1056
1022
  };
1057
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
+
1058
1063
  const MRT_RowPinButton = (_a) => {
1059
1064
  var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
1060
1065
  const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
@@ -1564,40 +1569,53 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
1564
1569
 
1565
1570
  const MRT_SelectCheckbox = (_a) => {
1566
1571
  var _b;
1567
- 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"]);
1568
1573
  const { getState, options: { enableMultiRowSelection, enableRowPinning, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, rowPinningDisplayMode, selectAllMode, }, } = table;
1569
1574
  const { density, isLoading } = getState();
1570
1575
  const checkboxProps = Object.assign(Object.assign({}, (!row
1571
1576
  ? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
1572
- : 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'));
1573
1583
  const allRowsSelected = selectAll
1574
1584
  ? selectAllMode === 'page'
1575
1585
  ? table.getIsAllPageRowsSelected()
1576
1586
  : table.getIsAllRowsSelected()
1577
1587
  : undefined;
1578
- 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: {
1579
1613
  'aria-label': selectAll
1580
1614
  ? localization.toggleSelectAll
1581
1615
  : localization.toggleSelectRow,
1582
1616
  }, onChange: (event) => {
1583
1617
  event.stopPropagation();
1584
- row
1585
- ? row.getToggleSelectedHandler()(event)
1586
- : selectAllMode === 'all'
1587
- ? table.getToggleAllRowsSelectedHandler()(event)
1588
- : table.getToggleAllPageRowsSelectedHandler()(event);
1589
- if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
1590
- if (row) {
1591
- row.pin(!row.getIsPinned() && event.target.checked
1592
- ? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
1593
- ? 'bottom'
1594
- : 'top'
1595
- : false);
1596
- }
1597
- else {
1598
- table.setRowPinning({ bottom: [], top: [] });
1599
- }
1600
- }
1618
+ row ? onSelectionChange(event, row) : onSelectAllChange(event);
1601
1619
  }, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
1602
1620
  var _a;
1603
1621
  e.stopPropagation();
@@ -1643,6 +1661,7 @@ const useMRT_DisplayColumns = (params) => {
1643
1661
  tableOptions.enableRowOrdering,
1644
1662
  tableOptions.enableRowSelection,
1645
1663
  tableOptions.enableSelectAll,
1664
+ tableOptions.groupedColumnMode,
1646
1665
  tableOptions.localization,
1647
1666
  tableOptions.positionActionsColumn,
1648
1667
  tableOptions.renderDetailPanel,
@@ -1678,20 +1697,38 @@ function makeRowActionsColumn({ creatingRow, tableOptions }, order) {
1678
1697
  return null;
1679
1698
  }
1680
1699
  function makeRowExpandColumn({ grouping, tableOptions }, order) {
1681
- var _a, _b;
1700
+ var _a, _b, _c;
1682
1701
  const id = 'mrt-row-expand';
1683
1702
  if (order.includes(id) &&
1684
1703
  showExpandColumn(tableOptions, (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.grouping) !== null && _b !== void 0 ? _b : grouping)) {
1685
- return Object.assign({ Cell: ({ row, table }) => jsxRuntime.jsx(MRT_ExpandButton, { row: row, table: table }), Header: tableOptions.enableExpandAll
1686
- ? ({ table }) => jsxRuntime.jsx(MRT_ExpandAllButton, { table: table })
1687
- : 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));
1688
1725
  }
1689
1726
  return null;
1690
1727
  }
1691
1728
  function makeRowSelectColumn({ tableOptions }, order) {
1692
1729
  const id = 'mrt-row-select';
1693
1730
  if (order.includes(id)) {
1694
- 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
1695
1732
  ? ({ table }) => jsxRuntime.jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
1696
1733
  : undefined }, defaultDisplayColumnProps(tableOptions, id, 'select'));
1697
1734
  }
@@ -1700,7 +1737,12 @@ function makeRowSelectColumn({ tableOptions }, order) {
1700
1737
  function makeRowNumbersColumn({ tableOptions }, order) {
1701
1738
  const id = 'mrt-row-numbers';
1702
1739
  if (order.includes(id) || tableOptions.enableRowNumbers)
1703
- 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'));
1704
1746
  return null;
1705
1747
  }
1706
1748
  const blankColProps = {
@@ -2769,16 +2811,12 @@ const MRT_FilterTextField = (_a) => {
2769
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) => {
2770
2812
  var _a;
2771
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 })));
2772
- }, value: filterValue }))) : (jsxRuntime.jsx(TextField__default["default"], Object.assign({ SelectProps: {
2773
- displayEmpty: true,
2774
- multiple: isMultiSelectFilter,
2775
- 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
2776
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) => {
2777
2816
  const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
2778
2817
  return (jsxRuntime.jsx(Chip__default["default"], { label: getValueAndLabel(selectedValue).label }, value));
2779
2818
  }) }))
2780
- : undefined,
2781
- }, 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) && [
2782
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"),
2783
2821
  ...[
2784
2822
  (_u = textFieldProps.children) !== null && _u !== void 0 ? _u : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
@@ -3460,8 +3498,9 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
3460
3498
  setHoveredColumn(column);
3461
3499
  }
3462
3500
  };
3463
- if (!columnDef.header || columnDef.visibleInShowHideMenu === false)
3501
+ if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
3464
3502
  return null;
3503
+ }
3465
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
3466
3505
  ? `2px dashed ${theme.palette.grey[500]}`
3467
3506
  : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
@@ -3604,8 +3643,19 @@ const MRT_TopToolbar = ({ table, }) => {
3604
3643
  const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
3605
3644
  const { isFullScreen, showGlobalFilter } = getState();
3606
3645
  const isMobile = useMediaQuery__default["default"]('(max-width:720px)');
3646
+ const isTablet = useMediaQuery__default["default"]('(max-width:1024px)');
3607
3647
  const toolbarProps = parseFromValuesOrFunc(muiTopToolbarProps, { table });
3608
- 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
+ };
3609
3659
  return (jsxRuntime.jsxs(Box__default["default"], Object.assign({}, toolbarProps, { ref: (ref) => {
3610
3660
  topToolbarRef.current = ref;
3611
3661
  if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
@@ -3623,14 +3673,14 @@ const MRT_TopToolbar = ({ table, }) => {
3623
3673
  right: 0,
3624
3674
  top: 0,
3625
3675
  width: '100%',
3626
- }, 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: {
3627
3677
  alignItems: 'center',
3628
3678
  display: 'flex',
3629
3679
  flexWrap: 'wrap-reverse',
3630
3680
  gap: '0.5rem',
3631
3681
  justifyContent: 'flex-end',
3632
- }, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, { table: table })), jsxRuntime.jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
3633
- 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 &&
3634
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 })] })));
3635
3685
  };
3636
3686