material-react-table 2.4.1 → 2.5.1
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.d.ts +11 -3
- package/dist/index.esm.js +174 -102
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +177 -105
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/body/MRT_TableBodyCell.tsx +12 -17
- package/src/body/MRT_TableBodyCellValue.tsx +7 -1
- package/src/body/MRT_TableBodyRow.tsx +10 -7
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +5 -1
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +1 -0
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +9 -5
- package/src/hooks/useMRT_DisplayColumns.tsx +67 -6
- package/src/inputs/MRT_FilterRangeSlider.tsx +1 -0
- package/src/inputs/MRT_FilterTextField.tsx +3 -2
- package/src/inputs/MRT_SelectCheckbox.tsx +47 -21
- package/src/menus/MRT_FilterOptionMenu.tsx +5 -0
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +7 -2
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +9 -8
- package/src/toolbar/MRT_TopToolbar.tsx +16 -4
- package/src/types.ts +12 -1
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,
|
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))) :
|
846
|
-
|
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, {
|
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
|
|
@@ -891,6 +857,8 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
891
857
|
const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
|
892
858
|
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
893
859
|
const isPinned = enableRowPinning && row.getIsPinned();
|
860
|
+
const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
|
861
|
+
const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
|
894
862
|
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
895
863
|
row,
|
896
864
|
staticRowIndex: rowIndex,
|
@@ -924,7 +892,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
924
892
|
};
|
925
893
|
const rowRef = react.useRef(null);
|
926
894
|
const { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, } = getMRTTheme(table, theme);
|
927
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(TableRow__default["default"], Object.assign({ "data-index": rowIndex, "data-pinned": !!isPinned || undefined, "data-selected": row.getIsSelected() || undefined, onDragEnter: handleDragEnter, ref: (node) => {
|
895
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(TableRow__default["default"], Object.assign({ "data-index": rowIndex, "data-pinned": !!isPinned || undefined, "data-selected": row.getIsSelected() || row.getIsAllSubRowsSelected() || undefined, onDragEnter: handleDragEnter, ref: (node) => {
|
928
896
|
if (node) {
|
929
897
|
rowRef.current = node;
|
930
898
|
measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
|
@@ -942,11 +910,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
942
910
|
}, backgroundColor: `${baseBackgroundColor} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isPinned
|
943
911
|
? `${bottomPinnedIndex * rowHeight +
|
944
912
|
(enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
|
945
|
-
: undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isPinned
|
946
|
-
? 0.97
|
947
|
-
: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id
|
948
|
-
? 0.5
|
949
|
-
: 1, position: virtualRow
|
913
|
+
: undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1, position: virtualRow
|
950
914
|
? 'absolute'
|
951
915
|
: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isPinned
|
952
916
|
? 'sticky'
|
@@ -969,7 +933,9 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
969
933
|
: cellOrVirtualCell;
|
970
934
|
const props = {
|
971
935
|
cell,
|
972
|
-
measureElement:
|
936
|
+
measureElement: !isDraggingRow && !isHoveredRow
|
937
|
+
? columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement
|
938
|
+
: undefined,
|
973
939
|
numRows,
|
974
940
|
rowIndex,
|
975
941
|
rowRef,
|
@@ -1055,6 +1021,50 @@ 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
|
+
try {
|
1052
|
+
event.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
1053
|
+
}
|
1054
|
+
catch (e) {
|
1055
|
+
console.error(e);
|
1056
|
+
}
|
1057
|
+
table.setDraggingRow(row);
|
1058
|
+
};
|
1059
|
+
const handleDragEnd = (event) => {
|
1060
|
+
var _a;
|
1061
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
1062
|
+
table.setDraggingRow(null);
|
1063
|
+
table.setHoveredRow(null);
|
1064
|
+
};
|
1065
|
+
return (jsxRuntime.jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
|
1066
|
+
};
|
1067
|
+
|
1058
1068
|
const MRT_RowPinButton = (_a) => {
|
1059
1069
|
var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
|
1060
1070
|
const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
|
@@ -1340,6 +1350,10 @@ const MRT_FilterOptionMenu = (_a) => {
|
|
1340
1350
|
column.setFilterValue('');
|
1341
1351
|
setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
|
1342
1352
|
}
|
1353
|
+
else if (currentFilterValue === ' ' &&
|
1354
|
+
emptyModes.includes(prevFilterMode)) {
|
1355
|
+
column.setFilterValue(undefined);
|
1356
|
+
}
|
1343
1357
|
else {
|
1344
1358
|
column.setFilterValue(currentFilterValue); // perform new filter render
|
1345
1359
|
}
|
@@ -1564,40 +1578,55 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
|
|
1564
1578
|
|
1565
1579
|
const MRT_SelectCheckbox = (_a) => {
|
1566
1580
|
var _b;
|
1567
|
-
var { row, selectAll, table } = _a, rest = __rest(_a, ["row", "selectAll", "table"]);
|
1581
|
+
var { row, selectAll, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "selectAll", "staticRowIndex", "table"]);
|
1568
1582
|
const { getState, options: { enableMultiRowSelection, enableRowPinning, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, rowPinningDisplayMode, selectAllMode, }, } = table;
|
1569
1583
|
const { density, isLoading } = getState();
|
1570
1584
|
const checkboxProps = Object.assign(Object.assign({}, (!row
|
1571
1585
|
? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
|
1572
|
-
: parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
1586
|
+
: parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
1587
|
+
row,
|
1588
|
+
staticRowIndex,
|
1589
|
+
table,
|
1590
|
+
}))), rest);
|
1591
|
+
const isStickySelection = enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'));
|
1573
1592
|
const allRowsSelected = selectAll
|
1574
1593
|
? selectAllMode === 'page'
|
1575
1594
|
? table.getIsAllPageRowsSelected()
|
1576
1595
|
: table.getIsAllRowsSelected()
|
1577
1596
|
: undefined;
|
1578
|
-
const
|
1597
|
+
const onSelectionChange = (event, row) => {
|
1598
|
+
var _a;
|
1599
|
+
if (row.getIsAllSubRowsSelected()) {
|
1600
|
+
(_a = row.subRows) === null || _a === void 0 ? void 0 : _a.forEach((r) => r.toggleSelected(false));
|
1601
|
+
}
|
1602
|
+
row.getToggleSelectedHandler()(event);
|
1603
|
+
if (isStickySelection) {
|
1604
|
+
row.pin(!row.getIsPinned() && event.target.checked
|
1605
|
+
? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
|
1606
|
+
? 'bottom'
|
1607
|
+
: 'top'
|
1608
|
+
: false);
|
1609
|
+
}
|
1610
|
+
};
|
1611
|
+
const onSelectAllChange = (event) => {
|
1612
|
+
selectAllMode === 'all'
|
1613
|
+
? table.getToggleAllRowsSelectedHandler()(event)
|
1614
|
+
: table.getToggleAllPageRowsSelectedHandler()(event);
|
1615
|
+
if (isStickySelection) {
|
1616
|
+
table.setRowPinning({ bottom: [], top: [] });
|
1617
|
+
}
|
1618
|
+
};
|
1619
|
+
const commonProps = Object.assign(Object.assign({ 'aria-label': selectAll
|
1620
|
+
? localization.toggleSelectAll
|
1621
|
+
: localization.toggleSelectRow, checked: selectAll
|
1622
|
+
? allRowsSelected
|
1623
|
+
: (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
1624
|
'aria-label': selectAll
|
1580
1625
|
? localization.toggleSelectAll
|
1581
1626
|
: localization.toggleSelectRow,
|
1582
1627
|
}, onChange: (event) => {
|
1583
1628
|
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
|
-
}
|
1629
|
+
row ? onSelectionChange(event, row) : onSelectAllChange(event);
|
1601
1630
|
}, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
1602
1631
|
var _a;
|
1603
1632
|
e.stopPropagation();
|
@@ -1643,6 +1672,7 @@ const useMRT_DisplayColumns = (params) => {
|
|
1643
1672
|
tableOptions.enableRowOrdering,
|
1644
1673
|
tableOptions.enableRowSelection,
|
1645
1674
|
tableOptions.enableSelectAll,
|
1675
|
+
tableOptions.groupedColumnMode,
|
1646
1676
|
tableOptions.localization,
|
1647
1677
|
tableOptions.positionActionsColumn,
|
1648
1678
|
tableOptions.renderDetailPanel,
|
@@ -1678,20 +1708,38 @@ function makeRowActionsColumn({ creatingRow, tableOptions }, order) {
|
|
1678
1708
|
return null;
|
1679
1709
|
}
|
1680
1710
|
function makeRowExpandColumn({ grouping, tableOptions }, order) {
|
1681
|
-
var _a, _b;
|
1711
|
+
var _a, _b, _c;
|
1682
1712
|
const id = 'mrt-row-expand';
|
1683
1713
|
if (order.includes(id) &&
|
1684
1714
|
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: ({
|
1686
|
-
|
1687
|
-
|
1715
|
+
return Object.assign({ Cell: ({ cell, column, row, table }) => {
|
1716
|
+
var _a, _b, _c;
|
1717
|
+
const expandButtonProps = { row, table };
|
1718
|
+
const subRowsLength = (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length;
|
1719
|
+
if (tableOptions.groupedColumnMode === 'remove' &&
|
1720
|
+
row.groupingColumnId) {
|
1721
|
+
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, ")"] })] }));
|
1722
|
+
}
|
1723
|
+
else {
|
1724
|
+
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 })] }));
|
1725
|
+
}
|
1726
|
+
}, Header: tableOptions.enableExpandAll
|
1727
|
+
? ({ table }) => {
|
1728
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MRT_ExpandAllButton, { table: table }), tableOptions.groupedColumnMode === 'remove' &&
|
1729
|
+
grouping
|
1730
|
+
.map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)
|
1731
|
+
.join(', ')] }));
|
1732
|
+
}
|
1733
|
+
: undefined }, defaultDisplayColumnProps(tableOptions, id, 'expand', tableOptions.groupedColumnMode === 'remove'
|
1734
|
+
? (_c = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.defaultColumn) === null || _c === void 0 ? void 0 : _c.size
|
1735
|
+
: 60));
|
1688
1736
|
}
|
1689
1737
|
return null;
|
1690
1738
|
}
|
1691
1739
|
function makeRowSelectColumn({ tableOptions }, order) {
|
1692
1740
|
const id = 'mrt-row-select';
|
1693
1741
|
if (order.includes(id)) {
|
1694
|
-
return Object.assign({ Cell: ({ row, table }) => jsxRuntime.jsx(MRT_SelectCheckbox, { row: row, table: table }), Header: tableOptions.enableSelectAll && tableOptions.enableMultiRowSelection
|
1742
|
+
return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsxRuntime.jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: tableOptions.enableSelectAll && tableOptions.enableMultiRowSelection
|
1695
1743
|
? ({ table }) => jsxRuntime.jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
|
1696
1744
|
: undefined }, defaultDisplayColumnProps(tableOptions, id, 'select'));
|
1697
1745
|
}
|
@@ -1700,7 +1748,12 @@ function makeRowSelectColumn({ tableOptions }, order) {
|
|
1700
1748
|
function makeRowNumbersColumn({ tableOptions }, order) {
|
1701
1749
|
const id = 'mrt-row-numbers';
|
1702
1750
|
if (order.includes(id) || tableOptions.enableRowNumbers)
|
1703
|
-
return Object.assign({ Cell: ({ row
|
1751
|
+
return Object.assign({ Cell: ({ row, staticRowIndex }) => {
|
1752
|
+
var _a;
|
1753
|
+
return ((_a = (tableOptions.rowNumberDisplayMode === 'static'
|
1754
|
+
? staticRowIndex
|
1755
|
+
: row.index)) !== null && _a !== void 0 ? _a : 0) + 1;
|
1756
|
+
}, Header: () => tableOptions.localization.rowNumber }, defaultDisplayColumnProps(tableOptions, id, 'rowNumbers'));
|
1704
1757
|
return null;
|
1705
1758
|
}
|
1706
1759
|
const blankColProps = {
|
@@ -2769,16 +2822,12 @@ const MRT_FilterTextField = (_a) => {
|
|
2769
2822
|
} }))) : 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
2823
|
var _a;
|
2771
2824
|
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
|
2825
|
+
}, value: filterValue }))) : (jsxRuntime.jsx(TextField__default["default"], Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
|
2776
2826
|
? (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
2827
|
const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
|
2778
2828
|
return (jsxRuntime.jsx(Chip__default["default"], { label: getValueAndLabel(selectedValue).label }, value));
|
2779
2829
|
}) }))
|
2780
|
-
: undefined,
|
2781
|
-
}, onChange: handleTextFieldChange, select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
|
2830
|
+
: undefined }, commonTextFieldProps.SelectProps), onChange: handleTextFieldChange, value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
|
2782
2831
|
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
2832
|
...[
|
2784
2833
|
(_u = textFieldProps.children) !== null && _u !== void 0 ? _u : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
|
@@ -2862,7 +2911,7 @@ const MRT_FilterRangeSlider = (_a) => {
|
|
2862
2911
|
}
|
2863
2912
|
},
|
2864
2913
|
},
|
2865
|
-
}, sx: (theme) => (Object.assign({ m: 'auto', mt: !showChangeModeButton ? '10px' : '6px', px: '4px', width: 'calc(100% - 8px)' }, parseFromValuesOrFunc(sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.sx, theme))) })), showChangeModeButton ? (jsxRuntime.jsx(FormHelperText__default["default"], { sx: {
|
2914
|
+
}, sx: (theme) => (Object.assign({ m: 'auto', minWidth: `${column.getSize() - 50}px`, mt: !showChangeModeButton ? '10px' : '6px', px: '4px', width: 'calc(100% - 8px)' }, parseFromValuesOrFunc(sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.sx, theme))) })), showChangeModeButton ? (jsxRuntime.jsx(FormHelperText__default["default"], { sx: {
|
2866
2915
|
fontSize: '0.75rem',
|
2867
2916
|
lineHeight: '0.8rem',
|
2868
2917
|
m: '-3px -6px',
|
@@ -2933,7 +2982,7 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
|
|
2933
2982
|
//@ts-ignore
|
2934
2983
|
event.stopPropagation();
|
2935
2984
|
setAnchorEl(null);
|
2936
|
-
}, onKeyDown: (event) => event.key === 'Enter' && setAnchorEl(null), open: !!anchorEl, transformOrigin: {
|
2985
|
+
}, onKeyDown: (event) => event.key === 'Enter' && setAnchorEl(null), open: !!anchorEl, slotProps: { paper: { sx: { overflow: 'visible' } } }, transformOrigin: {
|
2937
2986
|
horizontal: 'center',
|
2938
2987
|
vertical: 'bottom',
|
2939
2988
|
}, children: jsxRuntime.jsx(Box__default["default"], { sx: { p: '1rem' }, children: jsxRuntime.jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }) }) })] }));
|
@@ -2952,7 +3001,12 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
|
|
2952
3001
|
var _a;
|
2953
3002
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
2954
3003
|
setDraggingColumn(column);
|
2955
|
-
|
3004
|
+
try {
|
3005
|
+
event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
|
3006
|
+
}
|
3007
|
+
catch (e) {
|
3008
|
+
console.error(e);
|
3009
|
+
}
|
2956
3010
|
};
|
2957
3011
|
const handleDragEnd = (event) => {
|
2958
3012
|
var _a;
|
@@ -3317,16 +3371,17 @@ const MRT_GlobalFilterTextField = (_a) => {
|
|
3317
3371
|
const MRT_ToolbarAlertBanner = (_a) => {
|
3318
3372
|
var _b, _c, _d;
|
3319
3373
|
var { stackAlertBanner, table } = _a, rest = __rest(_a, ["stackAlertBanner", "table"]);
|
3320
|
-
const { getPrePaginationRowModel,
|
3321
|
-
const { density, grouping, showAlertBanner } = getState();
|
3374
|
+
const { getPrePaginationRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { tablePaperRef }, } = table;
|
3375
|
+
const { density, grouping, rowSelection, showAlertBanner } = getState();
|
3322
3376
|
const alertProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
|
3323
3377
|
table,
|
3324
3378
|
})), rest);
|
3325
3379
|
const chipProps = parseFromValuesOrFunc(muiToolbarAlertBannerChipProps, {
|
3326
3380
|
table,
|
3327
3381
|
});
|
3328
|
-
const
|
3329
|
-
|
3382
|
+
const selectedRowCount = react.useMemo(() => Object.values(rowSelection).filter(Boolean).length, [rowSelection]);
|
3383
|
+
const selectedAlert = selectedRowCount > 0
|
3384
|
+
? (_c = (_b = localization.selectedCountOfRowCountRowsSelected) === null || _b === void 0 ? void 0 : _b.replace('{selectedCount}', selectedRowCount.toLocaleString())) === null || _c === void 0 ? void 0 : _c.replace('{rowCount}', (rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length).toString())
|
3330
3385
|
: null;
|
3331
3386
|
const groupedAlert = grouping.length > 0 ? (jsxRuntime.jsxs("span", { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxRuntime.jsxs(react.Fragment, { children: [index > 0 ? localization.thenBy : '', jsxRuntime.jsx(Chip__default["default"], Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))] }, `${index}-${columnId}`)))] })) : null;
|
3332
3387
|
return (jsxRuntime.jsx(Collapse__default["default"], { in: showAlertBanner || !!selectedAlert || !!groupedAlert, timeout: stackAlertBanner ? 200 : 0, children: jsxRuntime.jsx(Alert__default["default"], Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => {
|
@@ -3446,7 +3501,12 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
3446
3501
|
const [isDragging, setIsDragging] = react.useState(false);
|
3447
3502
|
const handleDragStart = (e) => {
|
3448
3503
|
setIsDragging(true);
|
3449
|
-
|
3504
|
+
try {
|
3505
|
+
e.dataTransfer.setDragImage(menuItemRef.current, 0, 0);
|
3506
|
+
}
|
3507
|
+
catch (e) {
|
3508
|
+
console.error(e);
|
3509
|
+
}
|
3450
3510
|
};
|
3451
3511
|
const handleDragEnd = (_e) => {
|
3452
3512
|
setIsDragging(false);
|
@@ -3460,8 +3520,9 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
3460
3520
|
setHoveredColumn(column);
|
3461
3521
|
}
|
3462
3522
|
};
|
3463
|
-
if (!columnDef.header || columnDef.visibleInShowHideMenu === false)
|
3523
|
+
if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
|
3464
3524
|
return null;
|
3525
|
+
}
|
3465
3526
|
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
3527
|
? `2px dashed ${theme.palette.grey[500]}`
|
3467
3528
|
: (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
@@ -3604,8 +3665,19 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
3604
3665
|
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
|
3605
3666
|
const { isFullScreen, showGlobalFilter } = getState();
|
3606
3667
|
const isMobile = useMediaQuery__default["default"]('(max-width:720px)');
|
3668
|
+
const isTablet = useMediaQuery__default["default"]('(max-width:1024px)');
|
3607
3669
|
const toolbarProps = parseFromValuesOrFunc(muiTopToolbarProps, { table });
|
3608
|
-
const stackAlertBanner = isMobile ||
|
3670
|
+
const stackAlertBanner = isMobile ||
|
3671
|
+
!!renderTopToolbarCustomActions ||
|
3672
|
+
(showGlobalFilter && isTablet);
|
3673
|
+
const globalFilterProps = {
|
3674
|
+
sx: !isTablet
|
3675
|
+
? {
|
3676
|
+
zIndex: 2,
|
3677
|
+
}
|
3678
|
+
: undefined,
|
3679
|
+
table,
|
3680
|
+
};
|
3609
3681
|
return (jsxRuntime.jsxs(Box__default["default"], Object.assign({}, toolbarProps, { ref: (ref) => {
|
3610
3682
|
topToolbarRef.current = ref;
|
3611
3683
|
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
@@ -3623,14 +3695,14 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
3623
3695
|
right: 0,
|
3624
3696
|
top: 0,
|
3625
3697
|
width: '100%',
|
3626
|
-
}, children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, {
|
3698
|
+
}, 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
3699
|
alignItems: 'center',
|
3628
3700
|
display: 'flex',
|
3629
3701
|
flexWrap: 'wrap-reverse',
|
3630
3702
|
gap: '0.5rem',
|
3631
3703
|
justifyContent: 'flex-end',
|
3632
|
-
}, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, {
|
3633
|
-
positionGlobalFilter === 'right' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, {
|
3704
|
+
}, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), jsxRuntime.jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
|
3705
|
+
positionGlobalFilter === 'right' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))))] }), enablePagination &&
|
3634
3706
|
['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
3707
|
};
|
3636
3708
|
|