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.d.ts +11 -3
- package/dist/index.esm.js +137 -87
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +140 -90
- 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/hooks/useMRT_DisplayColumns.tsx +67 -6
- package/src/inputs/MRT_FilterTextField.tsx +3 -2
- package/src/inputs/MRT_SelectCheckbox.tsx +44 -21
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +2 -1
- 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
|
|
@@ -966,6 +932,45 @@ 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
|
+
event.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
963
|
+
table.setDraggingRow(row);
|
964
|
+
};
|
965
|
+
const handleDragEnd = (event) => {
|
966
|
+
var _a;
|
967
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
968
|
+
table.setDraggingRow(null);
|
969
|
+
table.setHoveredRow(null);
|
970
|
+
};
|
971
|
+
return (jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
|
972
|
+
};
|
973
|
+
|
969
974
|
const MRT_RowPinButton = (_a) => {
|
970
975
|
var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
|
971
976
|
const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
|
@@ -1475,40 +1480,53 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
|
|
1475
1480
|
|
1476
1481
|
const MRT_SelectCheckbox = (_a) => {
|
1477
1482
|
var _b;
|
1478
|
-
var { row, selectAll, table } = _a, rest = __rest(_a, ["row", "selectAll", "table"]);
|
1483
|
+
var { row, selectAll, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "selectAll", "staticRowIndex", "table"]);
|
1479
1484
|
const { getState, options: { enableMultiRowSelection, enableRowPinning, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, rowPinningDisplayMode, selectAllMode, }, } = table;
|
1480
1485
|
const { density, isLoading } = getState();
|
1481
1486
|
const checkboxProps = Object.assign(Object.assign({}, (!row
|
1482
1487
|
? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
|
1483
|
-
: parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
1488
|
+
: parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
1489
|
+
row,
|
1490
|
+
staticRowIndex,
|
1491
|
+
table,
|
1492
|
+
}))), rest);
|
1493
|
+
const isStickySelection = enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'));
|
1484
1494
|
const allRowsSelected = selectAll
|
1485
1495
|
? selectAllMode === 'page'
|
1486
1496
|
? table.getIsAllPageRowsSelected()
|
1487
1497
|
: table.getIsAllRowsSelected()
|
1488
1498
|
: undefined;
|
1489
|
-
const
|
1499
|
+
const onSelectionChange = (event, row) => {
|
1500
|
+
var _a;
|
1501
|
+
if (row.getIsAllSubRowsSelected()) {
|
1502
|
+
(_a = row.subRows) === null || _a === void 0 ? void 0 : _a.forEach((r) => r.toggleSelected(false));
|
1503
|
+
}
|
1504
|
+
row.getToggleSelectedHandler()(event);
|
1505
|
+
if (isStickySelection) {
|
1506
|
+
row.pin(!row.getIsPinned() && event.target.checked
|
1507
|
+
? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
|
1508
|
+
? 'bottom'
|
1509
|
+
: 'top'
|
1510
|
+
: false);
|
1511
|
+
}
|
1512
|
+
};
|
1513
|
+
const onSelectAllChange = (event) => {
|
1514
|
+
selectAllMode === 'all'
|
1515
|
+
? table.getToggleAllRowsSelectedHandler()(event)
|
1516
|
+
: table.getToggleAllPageRowsSelectedHandler()(event);
|
1517
|
+
if (isStickySelection) {
|
1518
|
+
table.setRowPinning({ bottom: [], top: [] });
|
1519
|
+
}
|
1520
|
+
};
|
1521
|
+
const commonProps = Object.assign(Object.assign({ checked: selectAll
|
1522
|
+
? allRowsSelected
|
1523
|
+
: (row === null || row === void 0 ? void 0 : row.getIsSelected()) || (row === null || row === void 0 ? void 0 : row.getIsAllSubRowsSelected()), disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
|
1490
1524
|
'aria-label': selectAll
|
1491
1525
|
? localization.toggleSelectAll
|
1492
1526
|
: localization.toggleSelectRow,
|
1493
1527
|
}, onChange: (event) => {
|
1494
1528
|
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
|
-
}
|
1529
|
+
row ? onSelectionChange(event, row) : onSelectAllChange(event);
|
1512
1530
|
}, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
1513
1531
|
var _a;
|
1514
1532
|
e.stopPropagation();
|
@@ -1554,6 +1572,7 @@ const useMRT_DisplayColumns = (params) => {
|
|
1554
1572
|
tableOptions.enableRowOrdering,
|
1555
1573
|
tableOptions.enableRowSelection,
|
1556
1574
|
tableOptions.enableSelectAll,
|
1575
|
+
tableOptions.groupedColumnMode,
|
1557
1576
|
tableOptions.localization,
|
1558
1577
|
tableOptions.positionActionsColumn,
|
1559
1578
|
tableOptions.renderDetailPanel,
|
@@ -1589,20 +1608,38 @@ function makeRowActionsColumn({ creatingRow, tableOptions }, order) {
|
|
1589
1608
|
return null;
|
1590
1609
|
}
|
1591
1610
|
function makeRowExpandColumn({ grouping, tableOptions }, order) {
|
1592
|
-
var _a, _b;
|
1611
|
+
var _a, _b, _c;
|
1593
1612
|
const id = 'mrt-row-expand';
|
1594
1613
|
if (order.includes(id) &&
|
1595
1614
|
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
|
-
|
1615
|
+
return Object.assign({ Cell: ({ cell, column, row, table }) => {
|
1616
|
+
var _a, _b, _c;
|
1617
|
+
const expandButtonProps = { row, table };
|
1618
|
+
const subRowsLength = (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length;
|
1619
|
+
if (tableOptions.groupedColumnMode === 'remove' &&
|
1620
|
+
row.groupingColumnId) {
|
1621
|
+
return (jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: "0.25rem", children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, placement: "right", title: table.getColumn(row.groupingColumnId).columnDef.header, children: jsx("span", { children: row.groupingValue }) }), !!subRowsLength && jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
|
1622
|
+
}
|
1623
|
+
else {
|
1624
|
+
return (jsxs(Fragment, { children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), (_c = (_b = column.columnDef).GroupedCell) === null || _c === void 0 ? void 0 : _c.call(_b, { cell, column, row, table })] }));
|
1625
|
+
}
|
1626
|
+
}, Header: tableOptions.enableExpandAll
|
1627
|
+
? ({ table }) => {
|
1628
|
+
return (jsxs(Fragment, { children: [jsx(MRT_ExpandAllButton, { table: table }), tableOptions.groupedColumnMode === 'remove' &&
|
1629
|
+
grouping
|
1630
|
+
.map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)
|
1631
|
+
.join(', ')] }));
|
1632
|
+
}
|
1633
|
+
: undefined }, defaultDisplayColumnProps(tableOptions, id, 'expand', tableOptions.groupedColumnMode === 'remove'
|
1634
|
+
? (_c = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.defaultColumn) === null || _c === void 0 ? void 0 : _c.size
|
1635
|
+
: 60));
|
1599
1636
|
}
|
1600
1637
|
return null;
|
1601
1638
|
}
|
1602
1639
|
function makeRowSelectColumn({ tableOptions }, order) {
|
1603
1640
|
const id = 'mrt-row-select';
|
1604
1641
|
if (order.includes(id)) {
|
1605
|
-
return Object.assign({ Cell: ({ row, table }) => jsx(MRT_SelectCheckbox, { row: row, table: table }), Header: tableOptions.enableSelectAll && tableOptions.enableMultiRowSelection
|
1642
|
+
return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: tableOptions.enableSelectAll && tableOptions.enableMultiRowSelection
|
1606
1643
|
? ({ table }) => jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
|
1607
1644
|
: undefined }, defaultDisplayColumnProps(tableOptions, id, 'select'));
|
1608
1645
|
}
|
@@ -1611,7 +1648,12 @@ function makeRowSelectColumn({ tableOptions }, order) {
|
|
1611
1648
|
function makeRowNumbersColumn({ tableOptions }, order) {
|
1612
1649
|
const id = 'mrt-row-numbers';
|
1613
1650
|
if (order.includes(id) || tableOptions.enableRowNumbers)
|
1614
|
-
return Object.assign({ Cell: ({ row
|
1651
|
+
return Object.assign({ Cell: ({ row, staticRowIndex }) => {
|
1652
|
+
var _a;
|
1653
|
+
return ((_a = (tableOptions.rowNumberDisplayMode === 'static'
|
1654
|
+
? staticRowIndex
|
1655
|
+
: row.index)) !== null && _a !== void 0 ? _a : 0) + 1;
|
1656
|
+
}, Header: () => tableOptions.localization.rowNumber }, defaultDisplayColumnProps(tableOptions, id, 'rowNumbers'));
|
1615
1657
|
return null;
|
1616
1658
|
}
|
1617
1659
|
const blankColProps = {
|
@@ -2680,16 +2722,12 @@ const MRT_FilterTextField = (_a) => {
|
|
2680
2722
|
} }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleChange(getValueAndLabel(newValue).value), options: (_t = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _t !== void 0 ? _t : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
|
2681
2723
|
var _a;
|
2682
2724
|
return (jsx(TextField, Object.assign({}, builtinTextFieldProps, commonTextFieldProps, { InputProps: Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), { startAdornment: (_a = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.startAdornment }), inputProps: Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.inputProps), onChange: handleTextFieldChange })));
|
2683
|
-
}, value: filterValue }))) : (jsx(TextField, Object.assign({ SelectProps: {
|
2684
|
-
displayEmpty: true,
|
2685
|
-
multiple: isMultiSelectFilter,
|
2686
|
-
renderValue: isMultiSelectFilter
|
2725
|
+
}, value: filterValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
|
2687
2726
|
? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected === null || selected === void 0 ? void 0 : selected.map((value) => {
|
2688
2727
|
const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
|
2689
2728
|
return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
|
2690
2729
|
}) }))
|
2691
|
-
: undefined,
|
2692
|
-
}, onChange: handleTextFieldChange, select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
|
2730
|
+
: undefined }, commonTextFieldProps.SelectProps), onChange: handleTextFieldChange, value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
|
2693
2731
|
jsx(MenuItem, { disabled: true, divider: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
|
2694
2732
|
...[
|
2695
2733
|
(_u = textFieldProps.children) !== null && _u !== void 0 ? _u : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
|
@@ -3371,8 +3409,9 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
3371
3409
|
setHoveredColumn(column);
|
3372
3410
|
}
|
3373
3411
|
};
|
3374
|
-
if (!columnDef.header || columnDef.visibleInShowHideMenu === false)
|
3412
|
+
if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
|
3375
3413
|
return null;
|
3414
|
+
}
|
3376
3415
|
return (jsxs(Fragment, { children: [jsx(MenuItem, Object.assign({ disableRipple: true, onDragEnter: handleDragEnter, ref: menuItemRef }, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', justifyContent: 'flex-start', my: 0, opacity: isDragging ? 0.5 : 1, outline: isDragging
|
3377
3416
|
? `2px dashed ${theme.palette.grey[500]}`
|
3378
3417
|
: (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
@@ -3515,8 +3554,19 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
3515
3554
|
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
|
3516
3555
|
const { isFullScreen, showGlobalFilter } = getState();
|
3517
3556
|
const isMobile = useMediaQuery('(max-width:720px)');
|
3557
|
+
const isTablet = useMediaQuery('(max-width:1024px)');
|
3518
3558
|
const toolbarProps = parseFromValuesOrFunc(muiTopToolbarProps, { table });
|
3519
|
-
const stackAlertBanner = isMobile ||
|
3559
|
+
const stackAlertBanner = isMobile ||
|
3560
|
+
!!renderTopToolbarCustomActions ||
|
3561
|
+
(showGlobalFilter && isTablet);
|
3562
|
+
const globalFilterProps = {
|
3563
|
+
sx: !isTablet
|
3564
|
+
? {
|
3565
|
+
zIndex: 2,
|
3566
|
+
}
|
3567
|
+
: undefined,
|
3568
|
+
table,
|
3569
|
+
};
|
3520
3570
|
return (jsxs(Box, Object.assign({}, toolbarProps, { ref: (ref) => {
|
3521
3571
|
topToolbarRef.current = ref;
|
3522
3572
|
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
@@ -3534,14 +3584,14 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
3534
3584
|
right: 0,
|
3535
3585
|
top: 0,
|
3536
3586
|
width: '100%',
|
3537
|
-
}, children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsx(MRT_GlobalFilterTextField, {
|
3587
|
+
}, children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), (_a = renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({ table })) !== null && _a !== void 0 ? _a : jsx("span", {}), enableToolbarInternalActions ? (jsxs(Box, { sx: {
|
3538
3588
|
alignItems: 'center',
|
3539
3589
|
display: 'flex',
|
3540
3590
|
flexWrap: 'wrap-reverse',
|
3541
3591
|
gap: '0.5rem',
|
3542
3592
|
justifyContent: 'flex-end',
|
3543
|
-
}, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, {
|
3544
|
-
positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, {
|
3593
|
+
}, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
|
3594
|
+
positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))))] }), enablePagination &&
|
3545
3595
|
['both', 'top'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsx(MRT_TablePagination, { position: "top", table: table })), jsx(MRT_LinearProgressBar, { isTopToolbar: true, table: table })] })));
|
3546
3596
|
};
|
3547
3597
|
|