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.d.ts
CHANGED
@@ -400,6 +400,7 @@ type MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown> = Omit<ColumnDef
|
|
400
400
|
renderedCellValue: ReactNode;
|
401
401
|
row: MRT_Row<TData>;
|
402
402
|
rowRef?: RefObject<HTMLTableRowElement>;
|
403
|
+
staticRowIndex?: number;
|
403
404
|
table: MRT_TableInstance<TData>;
|
404
405
|
}) => ReactNode;
|
405
406
|
Edit?: (props: {
|
@@ -611,9 +612,12 @@ type MRT_Header<TData extends MRT_RowData> = Omit<Header<TData, unknown>, 'colum
|
|
611
612
|
type MRT_HeaderGroup<TData extends MRT_RowData> = Omit<HeaderGroup<TData>, 'headers'> & {
|
612
613
|
headers: MRT_Header<TData>[];
|
613
614
|
};
|
614
|
-
type MRT_Row<TData extends MRT_RowData> = Omit<Row<TData>, '_valuesCache' | 'getAllCells' | 'getVisibleCells' | 'subRows'> & {
|
615
|
+
type MRT_Row<TData extends MRT_RowData> = Omit<Row<TData>, '_valuesCache' | 'getAllCells' | 'getParentRow' | 'getParentRows' | 'getRow' | 'getVisibleCells' | 'subRows'> & {
|
615
616
|
_valuesCache: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
|
616
617
|
getAllCells: () => MRT_Cell<TData>[];
|
618
|
+
getParentRow: () => MRT_Row<TData> | null;
|
619
|
+
getParentRows: () => MRT_Row<TData>[];
|
620
|
+
getRow: () => MRT_Row<TData>;
|
617
621
|
getVisibleCells: () => MRT_Cell<TData>[];
|
618
622
|
subRows?: MRT_Row<TData>[];
|
619
623
|
};
|
@@ -847,6 +851,7 @@ type MRT_TableOptions<TData extends MRT_RowData> = Omit<Partial<TableOptions<TDa
|
|
847
851
|
}) => CheckboxProps) | CheckboxProps;
|
848
852
|
muiSelectCheckboxProps?: ((props: {
|
849
853
|
row: MRT_Row<TData>;
|
854
|
+
staticRowIndex?: number;
|
850
855
|
table: MRT_TableInstance<TData>;
|
851
856
|
}) => CheckboxProps | RadioProps) | (CheckboxProps | RadioProps);
|
852
857
|
muiSkeletonProps?: ((props: {
|
@@ -1059,9 +1064,11 @@ declare const Memo_MRT_TableBodyCell: <TData extends MRT_RowData>({ cell, measur
|
|
1059
1064
|
|
1060
1065
|
interface Props$R<TData extends MRT_RowData> {
|
1061
1066
|
cell: MRT_Cell<TData>;
|
1067
|
+
rowRef?: RefObject<HTMLTableRowElement>;
|
1068
|
+
staticRowIndex?: number;
|
1062
1069
|
table: MRT_TableInstance<TData>;
|
1063
1070
|
}
|
1064
|
-
declare const MRT_TableBodyCellValue: <TData extends MRT_RowData>({ cell, table, }: Props$R<TData>) => ReactNode;
|
1071
|
+
declare const MRT_TableBodyCellValue: <TData extends MRT_RowData>({ cell, rowRef, staticRowIndex, table, }: Props$R<TData>) => ReactNode;
|
1065
1072
|
|
1066
1073
|
interface Props$Q<TData extends MRT_RowData> {
|
1067
1074
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
@@ -1451,9 +1458,10 @@ declare const MRT_GlobalFilterTextField: <TData extends MRT_RowData>({ table, ..
|
|
1451
1458
|
interface Props$h<TData extends MRT_RowData> extends CheckboxProps {
|
1452
1459
|
row?: MRT_Row<TData>;
|
1453
1460
|
selectAll?: boolean;
|
1461
|
+
staticRowIndex?: number;
|
1454
1462
|
table: MRT_TableInstance<TData>;
|
1455
1463
|
}
|
1456
|
-
declare const MRT_SelectCheckbox: <TData extends MRT_RowData>({ row, selectAll, table, ...rest }: Props$h<TData>) => react_jsx_runtime.JSX.Element;
|
1464
|
+
declare const MRT_SelectCheckbox: <TData extends MRT_RowData>({ row, selectAll, staticRowIndex, table, ...rest }: Props$h<TData>) => react_jsx_runtime.JSX.Element;
|
1457
1465
|
|
1458
1466
|
declare const commonMenuItemStyles: {
|
1459
1467
|
alignItems: string;
|
package/dist/index.esm.js
CHANGED
@@ -13,12 +13,13 @@ import Box from '@mui/material/Box';
|
|
13
13
|
import { flexRender as flexRender$1, createRow as createRow$1, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, aggregationFns, filterFns } from '@tanstack/react-table';
|
14
14
|
import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual';
|
15
15
|
import highlightWords from 'highlight-words';
|
16
|
-
import IconButton from '@mui/material/IconButton';
|
17
|
-
import Tooltip from '@mui/material/Tooltip';
|
18
16
|
import Button from '@mui/material/Button';
|
17
|
+
import Tooltip from '@mui/material/Tooltip';
|
19
18
|
import MenuItem from '@mui/material/MenuItem';
|
20
19
|
import TextField from '@mui/material/TextField';
|
21
20
|
import Collapse from '@mui/material/Collapse';
|
21
|
+
import Stack from '@mui/material/Stack';
|
22
|
+
import IconButton from '@mui/material/IconButton';
|
22
23
|
import CircularProgress from '@mui/material/CircularProgress';
|
23
24
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
24
25
|
import Menu from '@mui/material/Menu';
|
@@ -71,7 +72,6 @@ import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
|
|
71
72
|
import { TimePicker } from '@mui/x-date-pickers/TimePicker';
|
72
73
|
import FormHelperText from '@mui/material/FormHelperText';
|
73
74
|
import Slider from '@mui/material/Slider';
|
74
|
-
import Stack from '@mui/material/Stack';
|
75
75
|
import Grow from '@mui/material/Grow';
|
76
76
|
import Popover from '@mui/material/Popover';
|
77
77
|
import Divider from '@mui/material/Divider';
|
@@ -387,7 +387,7 @@ const getCommonToolbarStyles = ({ table, theme, }) => ({
|
|
387
387
|
});
|
388
388
|
|
389
389
|
const allowedTypes = ['string', 'number'];
|
390
|
-
const MRT_TableBodyCellValue = ({ cell, table, }) => {
|
390
|
+
const MRT_TableBodyCellValue = ({ cell, rowRef, staticRowIndex, table, }) => {
|
391
391
|
var _a, _b, _c;
|
392
392
|
const { getState, options: { enableFilterMatchHighlighting }, } = table;
|
393
393
|
const { column, row } = cell;
|
@@ -449,51 +449,14 @@ const MRT_TableBodyCellValue = ({ cell, table, }) => {
|
|
449
449
|
column,
|
450
450
|
renderedCellValue,
|
451
451
|
row,
|
452
|
+
rowRef,
|
453
|
+
staticRowIndex,
|
452
454
|
table,
|
453
455
|
});
|
454
456
|
}
|
455
457
|
return renderedCellValue;
|
456
458
|
};
|
457
459
|
|
458
|
-
const MRT_GrabHandleButton = (_a) => {
|
459
|
-
var _b, _c;
|
460
|
-
var { iconButtonProps, location, onDragEnd, onDragStart, table } = _a, rest = __rest(_a, ["iconButtonProps", "location", "onDragEnd", "onDragStart", "table"]);
|
461
|
-
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
462
|
-
const _iconButtonProps = Object.assign(Object.assign({}, iconButtonProps), rest);
|
463
|
-
return (jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_b = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.title) !== null && _b !== void 0 ? _b : localization.move, children: jsx(IconButton, Object.assign({ "aria-label": (_c = _iconButtonProps.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, _iconButtonProps, { onClick: (e) => {
|
464
|
-
var _a;
|
465
|
-
e.stopPropagation();
|
466
|
-
(_a = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(_iconButtonProps, e);
|
467
|
-
}, onDragEnd: onDragEnd, onDragStart: onDragStart, sx: (theme) => (Object.assign({ '&:active': {
|
468
|
-
cursor: 'grabbing',
|
469
|
-
}, '&:hover': {
|
470
|
-
backgroundColor: 'transparent',
|
471
|
-
opacity: 1,
|
472
|
-
}, cursor: 'grab', m: '0 -0.1rem', opacity: location === 'row' ? 1 : 0.3, p: '2px', transition: 'all 150ms ease-in-out' }, parseFromValuesOrFunc(_iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.sx, theme))), title: undefined, children: jsx(DragHandleIcon, {}) })) }));
|
473
|
-
};
|
474
|
-
|
475
|
-
const MRT_TableBodyRowGrabHandle = (_a) => {
|
476
|
-
var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
|
477
|
-
const { options: { muiRowDragHandleProps }, } = table;
|
478
|
-
const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
|
479
|
-
row,
|
480
|
-
table,
|
481
|
-
})), rest);
|
482
|
-
const handleDragStart = (event) => {
|
483
|
-
var _a;
|
484
|
-
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
485
|
-
event.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
486
|
-
table.setDraggingRow(row);
|
487
|
-
};
|
488
|
-
const handleDragEnd = (event) => {
|
489
|
-
var _a;
|
490
|
-
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
491
|
-
table.setDraggingRow(null);
|
492
|
-
table.setHoveredRow(null);
|
493
|
-
};
|
494
|
-
return (jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
|
495
|
-
};
|
496
|
-
|
497
460
|
const MRT_CopyButton = (_a) => {
|
498
461
|
var _b;
|
499
462
|
var { cell, table } = _a, rest = __rest(_a, ["cell", "table"]);
|
@@ -612,7 +575,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
612
575
|
var _b, _c, _d, _e, _f;
|
613
576
|
var { cell, measureElement, numRows, rowIndex, rowRef, table, virtualColumnIndex } = _a, rest = __rest(_a, ["cell", "measureElement", "numRows", "rowIndex", "rowRef", "table", "virtualColumnIndex"]);
|
614
577
|
const theme = useTheme();
|
615
|
-
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping,
|
578
|
+
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
616
579
|
const { columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
|
617
580
|
const { column, row } = cell;
|
618
581
|
const { columnDef } = column;
|
@@ -718,6 +681,10 @@ const MRT_TableBodyCell = (_a) => {
|
|
718
681
|
setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
719
682
|
}
|
720
683
|
};
|
684
|
+
const cellValueProps = {
|
685
|
+
cell,
|
686
|
+
table,
|
687
|
+
};
|
721
688
|
return (jsx(TableCell, Object.assign({ "data-index": virtualColumnIndex, ref: (node) => {
|
722
689
|
if (node) {
|
723
690
|
measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
|
@@ -753,19 +720,18 @@ const MRT_TableBodyCell = (_a) => {
|
|
753
720
|
table,
|
754
721
|
tableCellProps,
|
755
722
|
theme,
|
756
|
-
})), draggingBorders)), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (jsxs(Fragment, { children: [cell.getIsPlaceholder() ? ((_d = (_c = columnDef.PlaceholderCell) === null || _c === void 0 ? void 0 : _c.call(columnDef, { cell, column, row, table })) !== null && _d !== void 0 ? _d : null) : showSkeletons !== false && (isLoading || showSkeletons) ? (jsx(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) :
|
757
|
-
|
758
|
-
column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
|
759
|
-
(column.id === 'mrt-row-select' ||
|
760
|
-
column.id === 'mrt-row-expand' ||
|
723
|
+
})), draggingBorders)), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (jsxs(Fragment, { children: [cell.getIsPlaceholder() ? ((_d = (_c = columnDef.PlaceholderCell) === null || _c === void 0 ? void 0 : _c.call(columnDef, { cell, column, row, table })) !== null && _d !== void 0 ? _d : null) : showSkeletons !== false && (isLoading || showSkeletons) ? (jsx(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : columnDefType === 'display' &&
|
724
|
+
(['mrt-row-expand', 'mrt-row-numbers', 'mrt-row-select'].includes(column.id) ||
|
761
725
|
!row.getIsGrouped()) ? ((_e = columnDef.Cell) === null || _e === void 0 ? void 0 : _e.call(columnDef, {
|
762
726
|
cell,
|
763
727
|
column,
|
764
728
|
renderedCellValue: cell.renderValue(),
|
765
729
|
row,
|
730
|
+
rowRef,
|
731
|
+
staticRowIndex: rowIndex,
|
766
732
|
table,
|
767
733
|
})) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
768
|
-
columnDef.enableClickToCopy !== false ? (jsx(MRT_CopyButton, { cell: cell, table: table, children: jsx(MRT_TableBodyCellValue, {
|
734
|
+
columnDef.enableClickToCopy !== false ? (jsx(MRT_CopyButton, { cell: cell, table: table, children: jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps)) })) : (jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps))), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxs(Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
|
769
735
|
};
|
770
736
|
const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
|
771
737
|
|
@@ -802,6 +768,8 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
802
768
|
const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
|
803
769
|
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
804
770
|
const isPinned = enableRowPinning && row.getIsPinned();
|
771
|
+
const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
|
772
|
+
const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
|
805
773
|
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
806
774
|
row,
|
807
775
|
staticRowIndex: rowIndex,
|
@@ -835,7 +803,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
835
803
|
};
|
836
804
|
const rowRef = useRef(null);
|
837
805
|
const { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, } = getMRTTheme(table, theme);
|
838
|
-
return (jsxs(Fragment, { children: [jsxs(TableRow, Object.assign({ "data-index": rowIndex, "data-pinned": !!isPinned || undefined, "data-selected": row.getIsSelected() || undefined, onDragEnter: handleDragEnter, ref: (node) => {
|
806
|
+
return (jsxs(Fragment, { children: [jsxs(TableRow, Object.assign({ "data-index": rowIndex, "data-pinned": !!isPinned || undefined, "data-selected": row.getIsSelected() || row.getIsAllSubRowsSelected() || undefined, onDragEnter: handleDragEnter, ref: (node) => {
|
839
807
|
if (node) {
|
840
808
|
rowRef.current = node;
|
841
809
|
measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
|
@@ -853,11 +821,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
853
821
|
}, backgroundColor: `${baseBackgroundColor} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isPinned
|
854
822
|
? `${bottomPinnedIndex * rowHeight +
|
855
823
|
(enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
|
856
|
-
: undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isPinned
|
857
|
-
? 0.97
|
858
|
-
: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id
|
859
|
-
? 0.5
|
860
|
-
: 1, position: virtualRow
|
824
|
+
: 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
|
861
825
|
? 'absolute'
|
862
826
|
: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isPinned
|
863
827
|
? 'sticky'
|
@@ -880,7 +844,9 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
880
844
|
: cellOrVirtualCell;
|
881
845
|
const props = {
|
882
846
|
cell,
|
883
|
-
measureElement:
|
847
|
+
measureElement: !isDraggingRow && !isHoveredRow
|
848
|
+
? columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement
|
849
|
+
: undefined,
|
884
850
|
numRows,
|
885
851
|
rowIndex,
|
886
852
|
rowRef,
|
@@ -966,6 +932,50 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
966
932
|
return columnVirtualizer;
|
967
933
|
};
|
968
934
|
|
935
|
+
const MRT_GrabHandleButton = (_a) => {
|
936
|
+
var _b, _c;
|
937
|
+
var { iconButtonProps, location, onDragEnd, onDragStart, table } = _a, rest = __rest(_a, ["iconButtonProps", "location", "onDragEnd", "onDragStart", "table"]);
|
938
|
+
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
939
|
+
const _iconButtonProps = Object.assign(Object.assign({}, iconButtonProps), rest);
|
940
|
+
return (jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_b = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.title) !== null && _b !== void 0 ? _b : localization.move, children: jsx(IconButton, Object.assign({ "aria-label": (_c = _iconButtonProps.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, _iconButtonProps, { onClick: (e) => {
|
941
|
+
var _a;
|
942
|
+
e.stopPropagation();
|
943
|
+
(_a = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(_iconButtonProps, e);
|
944
|
+
}, onDragEnd: onDragEnd, onDragStart: onDragStart, sx: (theme) => (Object.assign({ '&:active': {
|
945
|
+
cursor: 'grabbing',
|
946
|
+
}, '&:hover': {
|
947
|
+
backgroundColor: 'transparent',
|
948
|
+
opacity: 1,
|
949
|
+
}, cursor: 'grab', m: '0 -0.1rem', opacity: location === 'row' ? 1 : 0.3, p: '2px', transition: 'all 150ms ease-in-out' }, parseFromValuesOrFunc(_iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.sx, theme))), title: undefined, children: jsx(DragHandleIcon, {}) })) }));
|
950
|
+
};
|
951
|
+
|
952
|
+
const MRT_TableBodyRowGrabHandle = (_a) => {
|
953
|
+
var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
|
954
|
+
const { options: { muiRowDragHandleProps }, } = table;
|
955
|
+
const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
|
956
|
+
row,
|
957
|
+
table,
|
958
|
+
})), rest);
|
959
|
+
const handleDragStart = (event) => {
|
960
|
+
var _a;
|
961
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
962
|
+
try {
|
963
|
+
event.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
964
|
+
}
|
965
|
+
catch (e) {
|
966
|
+
console.error(e);
|
967
|
+
}
|
968
|
+
table.setDraggingRow(row);
|
969
|
+
};
|
970
|
+
const handleDragEnd = (event) => {
|
971
|
+
var _a;
|
972
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
973
|
+
table.setDraggingRow(null);
|
974
|
+
table.setHoveredRow(null);
|
975
|
+
};
|
976
|
+
return (jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
|
977
|
+
};
|
978
|
+
|
969
979
|
const MRT_RowPinButton = (_a) => {
|
970
980
|
var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
|
971
981
|
const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
|
@@ -1251,6 +1261,10 @@ const MRT_FilterOptionMenu = (_a) => {
|
|
1251
1261
|
column.setFilterValue('');
|
1252
1262
|
setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
|
1253
1263
|
}
|
1264
|
+
else if (currentFilterValue === ' ' &&
|
1265
|
+
emptyModes.includes(prevFilterMode)) {
|
1266
|
+
column.setFilterValue(undefined);
|
1267
|
+
}
|
1254
1268
|
else {
|
1255
1269
|
column.setFilterValue(currentFilterValue); // perform new filter render
|
1256
1270
|
}
|
@@ -1475,40 +1489,55 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
|
|
1475
1489
|
|
1476
1490
|
const MRT_SelectCheckbox = (_a) => {
|
1477
1491
|
var _b;
|
1478
|
-
var { row, selectAll, table } = _a, rest = __rest(_a, ["row", "selectAll", "table"]);
|
1492
|
+
var { row, selectAll, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "selectAll", "staticRowIndex", "table"]);
|
1479
1493
|
const { getState, options: { enableMultiRowSelection, enableRowPinning, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, rowPinningDisplayMode, selectAllMode, }, } = table;
|
1480
1494
|
const { density, isLoading } = getState();
|
1481
1495
|
const checkboxProps = Object.assign(Object.assign({}, (!row
|
1482
1496
|
? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
|
1483
|
-
: parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
1497
|
+
: parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
1498
|
+
row,
|
1499
|
+
staticRowIndex,
|
1500
|
+
table,
|
1501
|
+
}))), rest);
|
1502
|
+
const isStickySelection = enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'));
|
1484
1503
|
const allRowsSelected = selectAll
|
1485
1504
|
? selectAllMode === 'page'
|
1486
1505
|
? table.getIsAllPageRowsSelected()
|
1487
1506
|
: table.getIsAllRowsSelected()
|
1488
1507
|
: undefined;
|
1489
|
-
const
|
1508
|
+
const onSelectionChange = (event, row) => {
|
1509
|
+
var _a;
|
1510
|
+
if (row.getIsAllSubRowsSelected()) {
|
1511
|
+
(_a = row.subRows) === null || _a === void 0 ? void 0 : _a.forEach((r) => r.toggleSelected(false));
|
1512
|
+
}
|
1513
|
+
row.getToggleSelectedHandler()(event);
|
1514
|
+
if (isStickySelection) {
|
1515
|
+
row.pin(!row.getIsPinned() && event.target.checked
|
1516
|
+
? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
|
1517
|
+
? 'bottom'
|
1518
|
+
: 'top'
|
1519
|
+
: false);
|
1520
|
+
}
|
1521
|
+
};
|
1522
|
+
const onSelectAllChange = (event) => {
|
1523
|
+
selectAllMode === 'all'
|
1524
|
+
? table.getToggleAllRowsSelectedHandler()(event)
|
1525
|
+
: table.getToggleAllPageRowsSelectedHandler()(event);
|
1526
|
+
if (isStickySelection) {
|
1527
|
+
table.setRowPinning({ bottom: [], top: [] });
|
1528
|
+
}
|
1529
|
+
};
|
1530
|
+
const commonProps = Object.assign(Object.assign({ 'aria-label': selectAll
|
1531
|
+
? localization.toggleSelectAll
|
1532
|
+
: localization.toggleSelectRow, checked: selectAll
|
1533
|
+
? allRowsSelected
|
1534
|
+
: (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: {
|
1490
1535
|
'aria-label': selectAll
|
1491
1536
|
? localization.toggleSelectAll
|
1492
1537
|
: localization.toggleSelectRow,
|
1493
1538
|
}, onChange: (event) => {
|
1494
1539
|
event.stopPropagation();
|
1495
|
-
row
|
1496
|
-
? row.getToggleSelectedHandler()(event)
|
1497
|
-
: selectAllMode === 'all'
|
1498
|
-
? table.getToggleAllRowsSelectedHandler()(event)
|
1499
|
-
: table.getToggleAllPageRowsSelectedHandler()(event);
|
1500
|
-
if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
|
1501
|
-
if (row) {
|
1502
|
-
row.pin(!row.getIsPinned() && event.target.checked
|
1503
|
-
? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
|
1504
|
-
? 'bottom'
|
1505
|
-
: 'top'
|
1506
|
-
: false);
|
1507
|
-
}
|
1508
|
-
else {
|
1509
|
-
table.setRowPinning({ bottom: [], top: [] });
|
1510
|
-
}
|
1511
|
-
}
|
1540
|
+
row ? onSelectionChange(event, row) : onSelectAllChange(event);
|
1512
1541
|
}, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
1513
1542
|
var _a;
|
1514
1543
|
e.stopPropagation();
|
@@ -1554,6 +1583,7 @@ const useMRT_DisplayColumns = (params) => {
|
|
1554
1583
|
tableOptions.enableRowOrdering,
|
1555
1584
|
tableOptions.enableRowSelection,
|
1556
1585
|
tableOptions.enableSelectAll,
|
1586
|
+
tableOptions.groupedColumnMode,
|
1557
1587
|
tableOptions.localization,
|
1558
1588
|
tableOptions.positionActionsColumn,
|
1559
1589
|
tableOptions.renderDetailPanel,
|
@@ -1589,20 +1619,38 @@ function makeRowActionsColumn({ creatingRow, tableOptions }, order) {
|
|
1589
1619
|
return null;
|
1590
1620
|
}
|
1591
1621
|
function makeRowExpandColumn({ grouping, tableOptions }, order) {
|
1592
|
-
var _a, _b;
|
1622
|
+
var _a, _b, _c;
|
1593
1623
|
const id = 'mrt-row-expand';
|
1594
1624
|
if (order.includes(id) &&
|
1595
1625
|
showExpandColumn(tableOptions, (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.grouping) !== null && _b !== void 0 ? _b : grouping)) {
|
1596
|
-
return Object.assign({ Cell: ({
|
1597
|
-
|
1598
|
-
|
1626
|
+
return Object.assign({ Cell: ({ cell, column, row, table }) => {
|
1627
|
+
var _a, _b, _c;
|
1628
|
+
const expandButtonProps = { row, table };
|
1629
|
+
const subRowsLength = (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length;
|
1630
|
+
if (tableOptions.groupedColumnMode === 'remove' &&
|
1631
|
+
row.groupingColumnId) {
|
1632
|
+
return (jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: "0.25rem", children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, placement: "right", title: table.getColumn(row.groupingColumnId).columnDef.header, children: jsx("span", { children: row.groupingValue }) }), !!subRowsLength && jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
|
1633
|
+
}
|
1634
|
+
else {
|
1635
|
+
return (jsxs(Fragment, { children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), (_c = (_b = column.columnDef).GroupedCell) === null || _c === void 0 ? void 0 : _c.call(_b, { cell, column, row, table })] }));
|
1636
|
+
}
|
1637
|
+
}, Header: tableOptions.enableExpandAll
|
1638
|
+
? ({ table }) => {
|
1639
|
+
return (jsxs(Fragment, { children: [jsx(MRT_ExpandAllButton, { table: table }), tableOptions.groupedColumnMode === 'remove' &&
|
1640
|
+
grouping
|
1641
|
+
.map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)
|
1642
|
+
.join(', ')] }));
|
1643
|
+
}
|
1644
|
+
: undefined }, defaultDisplayColumnProps(tableOptions, id, 'expand', tableOptions.groupedColumnMode === 'remove'
|
1645
|
+
? (_c = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.defaultColumn) === null || _c === void 0 ? void 0 : _c.size
|
1646
|
+
: 60));
|
1599
1647
|
}
|
1600
1648
|
return null;
|
1601
1649
|
}
|
1602
1650
|
function makeRowSelectColumn({ tableOptions }, order) {
|
1603
1651
|
const id = 'mrt-row-select';
|
1604
1652
|
if (order.includes(id)) {
|
1605
|
-
return Object.assign({ Cell: ({ row, table }) => jsx(MRT_SelectCheckbox, { row: row, table: table }), Header: tableOptions.enableSelectAll && tableOptions.enableMultiRowSelection
|
1653
|
+
return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: tableOptions.enableSelectAll && tableOptions.enableMultiRowSelection
|
1606
1654
|
? ({ table }) => jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
|
1607
1655
|
: undefined }, defaultDisplayColumnProps(tableOptions, id, 'select'));
|
1608
1656
|
}
|
@@ -1611,7 +1659,12 @@ function makeRowSelectColumn({ tableOptions }, order) {
|
|
1611
1659
|
function makeRowNumbersColumn({ tableOptions }, order) {
|
1612
1660
|
const id = 'mrt-row-numbers';
|
1613
1661
|
if (order.includes(id) || tableOptions.enableRowNumbers)
|
1614
|
-
return Object.assign({ Cell: ({ row
|
1662
|
+
return Object.assign({ Cell: ({ row, staticRowIndex }) => {
|
1663
|
+
var _a;
|
1664
|
+
return ((_a = (tableOptions.rowNumberDisplayMode === 'static'
|
1665
|
+
? staticRowIndex
|
1666
|
+
: row.index)) !== null && _a !== void 0 ? _a : 0) + 1;
|
1667
|
+
}, Header: () => tableOptions.localization.rowNumber }, defaultDisplayColumnProps(tableOptions, id, 'rowNumbers'));
|
1615
1668
|
return null;
|
1616
1669
|
}
|
1617
1670
|
const blankColProps = {
|
@@ -2680,16 +2733,12 @@ const MRT_FilterTextField = (_a) => {
|
|
2680
2733
|
} }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleChange(getValueAndLabel(newValue).value), options: (_t = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _t !== void 0 ? _t : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
|
2681
2734
|
var _a;
|
2682
2735
|
return (jsx(TextField, Object.assign({}, builtinTextFieldProps, commonTextFieldProps, { InputProps: Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), { startAdornment: (_a = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.startAdornment }), inputProps: Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.inputProps), onChange: handleTextFieldChange })));
|
2683
|
-
}, value: filterValue }))) : (jsx(TextField, Object.assign({ SelectProps: {
|
2684
|
-
displayEmpty: true,
|
2685
|
-
multiple: isMultiSelectFilter,
|
2686
|
-
renderValue: isMultiSelectFilter
|
2736
|
+
}, value: filterValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
|
2687
2737
|
? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected === null || selected === void 0 ? void 0 : selected.map((value) => {
|
2688
2738
|
const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
|
2689
2739
|
return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
|
2690
2740
|
}) }))
|
2691
|
-
: undefined,
|
2692
|
-
}, onChange: handleTextFieldChange, select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
|
2741
|
+
: undefined }, commonTextFieldProps.SelectProps), onChange: handleTextFieldChange, value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
|
2693
2742
|
jsx(MenuItem, { disabled: true, divider: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
|
2694
2743
|
...[
|
2695
2744
|
(_u = textFieldProps.children) !== null && _u !== void 0 ? _u : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
|
@@ -2773,7 +2822,7 @@ const MRT_FilterRangeSlider = (_a) => {
|
|
2773
2822
|
}
|
2774
2823
|
},
|
2775
2824
|
},
|
2776
|
-
}, 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 ? (jsx(FormHelperText, { sx: {
|
2825
|
+
}, 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 ? (jsx(FormHelperText, { sx: {
|
2777
2826
|
fontSize: '0.75rem',
|
2778
2827
|
lineHeight: '0.8rem',
|
2779
2828
|
m: '-3px -6px',
|
@@ -2844,7 +2893,7 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
|
|
2844
2893
|
//@ts-ignore
|
2845
2894
|
event.stopPropagation();
|
2846
2895
|
setAnchorEl(null);
|
2847
|
-
}, onKeyDown: (event) => event.key === 'Enter' && setAnchorEl(null), open: !!anchorEl, transformOrigin: {
|
2896
|
+
}, onKeyDown: (event) => event.key === 'Enter' && setAnchorEl(null), open: !!anchorEl, slotProps: { paper: { sx: { overflow: 'visible' } } }, transformOrigin: {
|
2848
2897
|
horizontal: 'center',
|
2849
2898
|
vertical: 'bottom',
|
2850
2899
|
}, children: jsx(Box, { sx: { p: '1rem' }, children: jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }) }) })] }));
|
@@ -2863,7 +2912,12 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
|
|
2863
2912
|
var _a;
|
2864
2913
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
2865
2914
|
setDraggingColumn(column);
|
2866
|
-
|
2915
|
+
try {
|
2916
|
+
event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
|
2917
|
+
}
|
2918
|
+
catch (e) {
|
2919
|
+
console.error(e);
|
2920
|
+
}
|
2867
2921
|
};
|
2868
2922
|
const handleDragEnd = (event) => {
|
2869
2923
|
var _a;
|
@@ -3228,16 +3282,17 @@ const MRT_GlobalFilterTextField = (_a) => {
|
|
3228
3282
|
const MRT_ToolbarAlertBanner = (_a) => {
|
3229
3283
|
var _b, _c, _d;
|
3230
3284
|
var { stackAlertBanner, table } = _a, rest = __rest(_a, ["stackAlertBanner", "table"]);
|
3231
|
-
const { getPrePaginationRowModel,
|
3232
|
-
const { density, grouping, showAlertBanner } = getState();
|
3285
|
+
const { getPrePaginationRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { tablePaperRef }, } = table;
|
3286
|
+
const { density, grouping, rowSelection, showAlertBanner } = getState();
|
3233
3287
|
const alertProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
|
3234
3288
|
table,
|
3235
3289
|
})), rest);
|
3236
3290
|
const chipProps = parseFromValuesOrFunc(muiToolbarAlertBannerChipProps, {
|
3237
3291
|
table,
|
3238
3292
|
});
|
3239
|
-
const
|
3240
|
-
|
3293
|
+
const selectedRowCount = useMemo(() => Object.values(rowSelection).filter(Boolean).length, [rowSelection]);
|
3294
|
+
const selectedAlert = selectedRowCount > 0
|
3295
|
+
? (_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())
|
3241
3296
|
: null;
|
3242
3297
|
const groupedAlert = grouping.length > 0 ? (jsxs("span", { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxs(Fragment$1, { children: [index > 0 ? localization.thenBy : '', jsx(Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))] }, `${index}-${columnId}`)))] })) : null;
|
3243
3298
|
return (jsx(Collapse, { in: showAlertBanner || !!selectedAlert || !!groupedAlert, timeout: stackAlertBanner ? 200 : 0, children: jsx(Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => {
|
@@ -3357,7 +3412,12 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
3357
3412
|
const [isDragging, setIsDragging] = useState(false);
|
3358
3413
|
const handleDragStart = (e) => {
|
3359
3414
|
setIsDragging(true);
|
3360
|
-
|
3415
|
+
try {
|
3416
|
+
e.dataTransfer.setDragImage(menuItemRef.current, 0, 0);
|
3417
|
+
}
|
3418
|
+
catch (e) {
|
3419
|
+
console.error(e);
|
3420
|
+
}
|
3361
3421
|
};
|
3362
3422
|
const handleDragEnd = (_e) => {
|
3363
3423
|
setIsDragging(false);
|
@@ -3371,8 +3431,9 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
3371
3431
|
setHoveredColumn(column);
|
3372
3432
|
}
|
3373
3433
|
};
|
3374
|
-
if (!columnDef.header || columnDef.visibleInShowHideMenu === false)
|
3434
|
+
if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
|
3375
3435
|
return null;
|
3436
|
+
}
|
3376
3437
|
return (jsxs(Fragment, { children: [jsx(MenuItem, Object.assign({ disableRipple: true, onDragEnter: handleDragEnter, ref: menuItemRef }, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', justifyContent: 'flex-start', my: 0, opacity: isDragging ? 0.5 : 1, outline: isDragging
|
3377
3438
|
? `2px dashed ${theme.palette.grey[500]}`
|
3378
3439
|
: (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
@@ -3515,8 +3576,19 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
3515
3576
|
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
|
3516
3577
|
const { isFullScreen, showGlobalFilter } = getState();
|
3517
3578
|
const isMobile = useMediaQuery('(max-width:720px)');
|
3579
|
+
const isTablet = useMediaQuery('(max-width:1024px)');
|
3518
3580
|
const toolbarProps = parseFromValuesOrFunc(muiTopToolbarProps, { table });
|
3519
|
-
const stackAlertBanner = isMobile ||
|
3581
|
+
const stackAlertBanner = isMobile ||
|
3582
|
+
!!renderTopToolbarCustomActions ||
|
3583
|
+
(showGlobalFilter && isTablet);
|
3584
|
+
const globalFilterProps = {
|
3585
|
+
sx: !isTablet
|
3586
|
+
? {
|
3587
|
+
zIndex: 2,
|
3588
|
+
}
|
3589
|
+
: undefined,
|
3590
|
+
table,
|
3591
|
+
};
|
3520
3592
|
return (jsxs(Box, Object.assign({}, toolbarProps, { ref: (ref) => {
|
3521
3593
|
topToolbarRef.current = ref;
|
3522
3594
|
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
@@ -3534,14 +3606,14 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
3534
3606
|
right: 0,
|
3535
3607
|
top: 0,
|
3536
3608
|
width: '100%',
|
3537
|
-
}, children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsx(MRT_GlobalFilterTextField, {
|
3609
|
+
}, children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), (_a = renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({ table })) !== null && _a !== void 0 ? _a : jsx("span", {}), enableToolbarInternalActions ? (jsxs(Box, { sx: {
|
3538
3610
|
alignItems: 'center',
|
3539
3611
|
display: 'flex',
|
3540
3612
|
flexWrap: 'wrap-reverse',
|
3541
3613
|
gap: '0.5rem',
|
3542
3614
|
justifyContent: 'flex-end',
|
3543
|
-
}, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, {
|
3544
|
-
positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, {
|
3615
|
+
}, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
|
3616
|
+
positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))))] }), enablePagination &&
|
3545
3617
|
['both', 'top'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsx(MRT_TablePagination, { position: "top", table: table })), jsx(MRT_LinearProgressBar, { isTopToolbar: true, table: table })] })));
|
3546
3618
|
};
|
3547
3619
|
|