material-react-table 1.9.4 → 1.11.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/cjs/index.js +216 -215
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/MaterialReactTable.d.ts +4 -0
- package/dist/cjs/types/_locales/fi.d.ts +2 -0
- package/dist/cjs/types/_locales/id.d.ts +2 -0
- package/dist/cjs/types/body/MRT_TableDetailPanel.d.ts +2 -1
- package/dist/cjs/types/column.utils.d.ts +1 -1
- package/dist/cjs/types/menus/MRT_ShowHideColumnsMenu.d.ts +1 -1
- package/dist/cjs/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -2
- package/dist/esm/material-react-table.esm.js +213 -212
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/MaterialReactTable.d.ts +4 -0
- package/dist/esm/types/_locales/fi.d.ts +2 -0
- package/dist/esm/types/_locales/id.d.ts +2 -0
- package/dist/esm/types/body/MRT_TableDetailPanel.d.ts +2 -1
- package/dist/esm/types/column.utils.d.ts +1 -1
- package/dist/esm/types/menus/MRT_ShowHideColumnsMenu.d.ts +1 -1
- package/dist/esm/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -2
- package/dist/index.d.ts +4 -0
- package/locales/fi.d.ts +2 -0
- package/locales/fi.esm.d.ts +2 -0
- package/locales/fi.esm.js +94 -0
- package/locales/fi.esm.js.map +1 -0
- package/locales/fi.js +98 -0
- package/locales/fi.js.map +1 -0
- package/locales/id.d.ts +2 -0
- package/locales/id.esm.d.ts +2 -0
- package/locales/id.esm.js +94 -0
- package/locales/id.esm.js.map +1 -0
- package/locales/id.js +98 -0
- package/locales/id.js.map +1 -0
- package/package.json +10 -8
- package/src/MaterialReactTable.tsx +4 -0
- package/src/_locales/fi.ts +94 -0
- package/src/_locales/id.ts +95 -0
- package/src/body/MRT_TableBody.tsx +22 -17
- package/src/body/MRT_TableBodyRow.tsx +2 -1
- package/src/body/MRT_TableDetailPanel.tsx +3 -1
- package/src/column.utils.ts +95 -83
- package/src/head/MRT_TableHeadCell.tsx +2 -2
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +1 -1
- package/src/menus/MRT_ColumnActionMenu.tsx +3 -26
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +4 -6
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +3 -8
- package/src/toolbar/MRT_ToolbarDropZone.tsx +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo,
|
|
1
|
+
import React, { useMemo, useState, useRef, useCallback, useEffect, Fragment, memo, useLayoutEffect } from 'react';
|
|
2
2
|
import { aggregationFns, filterFns, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
|
|
3
3
|
import { alpha, lighten, useTheme, darken } from '@mui/material/styles';
|
|
4
4
|
import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
|
|
@@ -39,10 +39,6 @@ import ListItemIcon from '@mui/material/ListItemIcon';
|
|
|
39
39
|
import Menu from '@mui/material/Menu';
|
|
40
40
|
import MenuItem from '@mui/material/MenuItem';
|
|
41
41
|
import Button from '@mui/material/Button';
|
|
42
|
-
import Divider from '@mui/material/Divider';
|
|
43
|
-
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
44
|
-
import Switch from '@mui/material/Switch';
|
|
45
|
-
import Typography from '@mui/material/Typography';
|
|
46
42
|
import Checkbox from '@mui/material/Checkbox';
|
|
47
43
|
import Radio from '@mui/material/Radio';
|
|
48
44
|
import Paper from '@mui/material/Paper';
|
|
@@ -57,6 +53,10 @@ import TablePagination from '@mui/material/TablePagination';
|
|
|
57
53
|
import Alert from '@mui/material/Alert';
|
|
58
54
|
import AlertTitle from '@mui/material/AlertTitle';
|
|
59
55
|
import Chip from '@mui/material/Chip';
|
|
56
|
+
import Divider from '@mui/material/Divider';
|
|
57
|
+
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
58
|
+
import Switch from '@mui/material/Switch';
|
|
59
|
+
import Typography from '@mui/material/Typography';
|
|
60
60
|
import Fade from '@mui/material/Fade';
|
|
61
61
|
import TableContainer from '@mui/material/TableContainer';
|
|
62
62
|
import { useVirtualizer, defaultRangeExtractor } from '@tanstack/react-virtual';
|
|
@@ -200,13 +200,17 @@ const getTrailingDisplayColumnIds = (props) => {
|
|
|
200
200
|
props.positionExpandColumn === 'last' &&
|
|
201
201
|
showExpandColumn(props) &&
|
|
202
202
|
'mrt-row-expand',
|
|
203
|
-
];
|
|
203
|
+
].filter(Boolean);
|
|
204
|
+
};
|
|
205
|
+
const getDefaultColumnOrderIds = (props) => {
|
|
206
|
+
const leadingDisplayCols = getLeadingDisplayColumnIds(props);
|
|
207
|
+
const trailingDisplayCols = getTrailingDisplayColumnIds(props);
|
|
208
|
+
const allLeafColumnDefs = getAllLeafColumnDefs(props.columns)
|
|
209
|
+
.map((columnDef) => getColumnId(columnDef))
|
|
210
|
+
.filter((columnId) => !leadingDisplayCols.includes(columnId) &&
|
|
211
|
+
!trailingDisplayCols.includes(columnId));
|
|
212
|
+
return [...leadingDisplayCols, ...allLeafColumnDefs, ...trailingDisplayCols];
|
|
204
213
|
};
|
|
205
|
-
const getDefaultColumnOrderIds = (props) => [
|
|
206
|
-
...getLeadingDisplayColumnIds(props),
|
|
207
|
-
...getAllLeafColumnDefs(props.columns).map((columnDef) => getColumnId(columnDef)),
|
|
208
|
-
...getTrailingDisplayColumnIds(props),
|
|
209
|
-
].filter(Boolean);
|
|
210
214
|
const getDefaultColumnFilterFn = (columnDef) => {
|
|
211
215
|
if (columnDef.filterVariant === 'multi-select')
|
|
212
216
|
return 'arrIncludesSome';
|
|
@@ -236,28 +240,33 @@ const getTotalRight = (table, column) => {
|
|
|
236
240
|
};
|
|
237
241
|
const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
|
238
242
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
239
|
-
|
|
243
|
+
const widthStyles = {
|
|
244
|
+
minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_a = header === null || header === void 0 ? void 0 : header.id) !== null && _a !== void 0 ? _a : column.id)}-size) * 1px), ${(_b = column.columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
|
|
245
|
+
width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_c = header === null || header === void 0 ? void 0 : header.id) !== null && _c !== void 0 ? _c : column.id)}-size) * 1px)`,
|
|
246
|
+
};
|
|
247
|
+
return Object.assign(Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
240
248
|
? alpha(lighten(theme.palette.background.default, 0.04), 0.97)
|
|
241
249
|
: 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
|
|
242
250
|
? `-4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
|
243
251
|
: getIsFirstRightPinnedColumn(column)
|
|
244
252
|
? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
|
245
253
|
: undefined, display: table.options.layoutMode === 'grid' ? 'flex' : 'table-cell', flex: table.options.layoutMode === 'grid'
|
|
246
|
-
? `var(--${header ? 'header' : 'col'}-${parseCSSVarId((
|
|
254
|
+
? `var(--${header ? 'header' : 'col'}-${parseCSSVarId((_d = header === null || header === void 0 ? void 0 : header.id) !== null && _d !== void 0 ? _d : column.id)}-size) 0 auto`
|
|
247
255
|
: undefined, left: column.getIsPinned() === 'left'
|
|
248
256
|
? `${column.getStart('left')}px`
|
|
249
257
|
: undefined, ml: table.options.enableColumnVirtualization &&
|
|
250
258
|
column.getIsPinned() === 'left' &&
|
|
251
259
|
column.getPinnedIndex() === 0
|
|
252
|
-
? `-${column.getSize() *
|
|
260
|
+
? `-${column.getSize() *
|
|
261
|
+
((_f = (_e = table.getState().columnPinning.left) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 1)}px`
|
|
253
262
|
: undefined, mr: table.options.enableColumnVirtualization &&
|
|
254
263
|
column.getIsPinned() === 'right' &&
|
|
255
264
|
column.getPinnedIndex() === table.getVisibleLeafColumns().length - 1
|
|
256
265
|
? `-${column.getSize() *
|
|
257
|
-
((
|
|
266
|
+
((_h = (_g = table.getState().columnPinning.right) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 1) *
|
|
258
267
|
1.2}px`
|
|
259
|
-
: undefined, opacity: ((
|
|
260
|
-
((
|
|
268
|
+
: undefined, opacity: ((_j = table.getState().draggingColumn) === null || _j === void 0 ? void 0 : _j.id) === column.id ||
|
|
269
|
+
((_k = table.getState().hoveredColumn) === null || _k === void 0 ? void 0 : _k.id) === column.id
|
|
261
270
|
? 0.5
|
|
262
271
|
: 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
263
272
|
? 'sticky'
|
|
@@ -265,9 +274,9 @@ const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, })
|
|
|
265
274
|
? `${getTotalRight(table, column)}px`
|
|
266
275
|
: undefined, transition: table.options.enableColumnVirtualization
|
|
267
276
|
? 'none'
|
|
268
|
-
: `padding 150ms ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
277
|
+
: `padding 150ms ease-in-out` }, (!table.options.enableColumnResizing && widthStyles)), ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
269
278
|
? tableCellProps.sx(theme)
|
|
270
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)),
|
|
279
|
+
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), (table.options.enableColumnResizing && widthStyles));
|
|
271
280
|
};
|
|
272
281
|
const MRT_DefaultColumn = {
|
|
273
282
|
filterVariant: 'text',
|
|
@@ -660,168 +669,6 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilt
|
|
|
660
669
|
label)))));
|
|
661
670
|
};
|
|
662
671
|
|
|
663
|
-
const MRT_ColumnPinningButtons = ({ column, table, }) => {
|
|
664
|
-
const { options: { icons: { PushPinIcon }, localization, }, } = table;
|
|
665
|
-
const handlePinColumn = (pinDirection) => {
|
|
666
|
-
column.pin(pinDirection);
|
|
667
|
-
};
|
|
668
|
-
return (React.createElement(Box, { sx: { minWidth: '70px', textAlign: 'center' } }, column.getIsPinned() ? (React.createElement(Tooltip, { arrow: true, title: localization.unpin },
|
|
669
|
-
React.createElement(IconButton, { onClick: () => handlePinColumn(false), size: "small" },
|
|
670
|
-
React.createElement(PushPinIcon, null)))) : (React.createElement(React.Fragment, null,
|
|
671
|
-
React.createElement(Tooltip, { arrow: true, title: localization.pinToLeft },
|
|
672
|
-
React.createElement(IconButton, { onClick: () => handlePinColumn('left'), size: "small" },
|
|
673
|
-
React.createElement(PushPinIcon, { style: {
|
|
674
|
-
transform: 'rotate(90deg)',
|
|
675
|
-
} }))),
|
|
676
|
-
React.createElement(Tooltip, { arrow: true, title: localization.pinToRight },
|
|
677
|
-
React.createElement(IconButton, { onClick: () => handlePinColumn('right'), size: "small" },
|
|
678
|
-
React.createElement(PushPinIcon, { style: {
|
|
679
|
-
transform: 'rotate(-90deg)',
|
|
680
|
-
} })))))));
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
|
|
684
|
-
var _a;
|
|
685
|
-
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
|
686
|
-
return (React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.move },
|
|
687
|
-
React.createElement(IconButton, Object.assign({ disableRipple: true, draggable: "true", size: "small" }, iconButtonProps, { onClick: (e) => {
|
|
688
|
-
var _a;
|
|
689
|
-
e.stopPropagation();
|
|
690
|
-
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
|
|
691
|
-
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: '0 -0.1rem', opacity: 0.5, p: '2px', transition: 'all 150ms ease-in-out', '&:hover': {
|
|
692
|
-
backgroundColor: 'transparent',
|
|
693
|
-
opacity: 1,
|
|
694
|
-
}, '&:active': {
|
|
695
|
-
cursor: 'grabbing',
|
|
696
|
-
} }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
697
|
-
? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
|
|
698
|
-
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }),
|
|
699
|
-
React.createElement(DragHandleIcon, null))));
|
|
700
|
-
};
|
|
701
|
-
|
|
702
|
-
const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, isSubMenu, table, }) => {
|
|
703
|
-
var _a;
|
|
704
|
-
const { getState, options: { enableColumnOrdering, enableHiding, enablePinning, localization, }, setColumnOrder, } = table;
|
|
705
|
-
const { columnOrder } = getState();
|
|
706
|
-
const { columnDef } = column;
|
|
707
|
-
const { columnDefType } = columnDef;
|
|
708
|
-
const switchChecked = (columnDefType !== 'group' && column.getIsVisible()) ||
|
|
709
|
-
(columnDefType === 'group' &&
|
|
710
|
-
column.getLeafColumns().some((col) => col.getIsVisible()));
|
|
711
|
-
const handleToggleColumnHidden = (column) => {
|
|
712
|
-
var _a, _b;
|
|
713
|
-
if (columnDefType === 'group') {
|
|
714
|
-
(_b = (_a = column === null || column === void 0 ? void 0 : column.columns) === null || _a === void 0 ? void 0 : _a.forEach) === null || _b === void 0 ? void 0 : _b.call(_a, (childColumn) => {
|
|
715
|
-
childColumn.toggleVisibility(!switchChecked);
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
|
-
else {
|
|
719
|
-
column.toggleVisibility();
|
|
720
|
-
}
|
|
721
|
-
};
|
|
722
|
-
const menuItemRef = useRef(null);
|
|
723
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
724
|
-
const handleDragStart = (e) => {
|
|
725
|
-
setIsDragging(true);
|
|
726
|
-
e.dataTransfer.setDragImage(menuItemRef.current, 0, 0);
|
|
727
|
-
};
|
|
728
|
-
const handleDragEnd = (_e) => {
|
|
729
|
-
setIsDragging(false);
|
|
730
|
-
setHoveredColumn(null);
|
|
731
|
-
if (hoveredColumn) {
|
|
732
|
-
setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
const handleDragEnter = (_e) => {
|
|
736
|
-
if (!isDragging && columnDef.enableColumnOrdering !== false) {
|
|
737
|
-
setHoveredColumn(column);
|
|
738
|
-
}
|
|
739
|
-
};
|
|
740
|
-
return (React.createElement(React.Fragment, null,
|
|
741
|
-
React.createElement(MenuItem, { disableRipple: true, ref: menuItemRef, onDragEnter: handleDragEnter, sx: (theme) => ({
|
|
742
|
-
alignItems: 'center',
|
|
743
|
-
justifyContent: 'flex-start',
|
|
744
|
-
my: 0,
|
|
745
|
-
opacity: isDragging ? 0.5 : 1,
|
|
746
|
-
outlineOffset: '-2px',
|
|
747
|
-
outline: isDragging
|
|
748
|
-
? `2px dashed ${theme.palette.divider}`
|
|
749
|
-
: (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
750
|
-
? `2px dashed ${theme.palette.primary.main}`
|
|
751
|
-
: 'none',
|
|
752
|
-
pl: `${(column.depth + 0.5) * 2}rem`,
|
|
753
|
-
py: '6px',
|
|
754
|
-
}) },
|
|
755
|
-
React.createElement(Box, { sx: {
|
|
756
|
-
display: 'flex',
|
|
757
|
-
flexWrap: 'nowrap',
|
|
758
|
-
gap: '8px',
|
|
759
|
-
} },
|
|
760
|
-
!isSubMenu &&
|
|
761
|
-
columnDefType !== 'group' &&
|
|
762
|
-
enableColumnOrdering &&
|
|
763
|
-
!allColumns.some((col) => col.columnDef.columnDefType === 'group') &&
|
|
764
|
-
(columnDef.enableColumnOrdering !== false ? (React.createElement(MRT_GrabHandleButton, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })) : (React.createElement(Box, { sx: { width: '28px' } }))),
|
|
765
|
-
!isSubMenu &&
|
|
766
|
-
enablePinning &&
|
|
767
|
-
(column.getCanPin() ? (React.createElement(MRT_ColumnPinningButtons, { column: column, table: table })) : (React.createElement(Box, { sx: { width: '70px' } }))),
|
|
768
|
-
enableHiding ? (React.createElement(FormControlLabel, { componentsProps: {
|
|
769
|
-
typography: {
|
|
770
|
-
sx: {
|
|
771
|
-
mb: 0,
|
|
772
|
-
opacity: columnDefType !== 'display' ? 1 : 0.5,
|
|
773
|
-
},
|
|
774
|
-
},
|
|
775
|
-
}, checked: switchChecked, control: React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.toggleVisibility },
|
|
776
|
-
React.createElement(Switch, null)), disabled: (isSubMenu && switchChecked) || !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (React.createElement(Typography, { sx: { alignSelf: 'center' } }, columnDef.header)))), (_a = column.columns) === null || _a === void 0 ? void 0 :
|
|
777
|
-
_a.map((c, i) => (React.createElement(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, isSubMenu: isSubMenu, key: `${i}-${c.id}`, setHoveredColumn: setHoveredColumn, table: table })))));
|
|
778
|
-
};
|
|
779
|
-
|
|
780
|
-
const MRT_ShowHideColumnsMenu = ({ anchorEl, isSubMenu, setAnchorEl, table, }) => {
|
|
781
|
-
const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, toggleAllColumnsVisible, options: { enableColumnOrdering, enableHiding, enablePinning, localization, }, } = table;
|
|
782
|
-
const { density, columnOrder, columnPinning } = getState();
|
|
783
|
-
const hideAllColumns = () => {
|
|
784
|
-
getAllLeafColumns()
|
|
785
|
-
.filter((col) => col.columnDef.enableHiding !== false)
|
|
786
|
-
.forEach((col) => col.toggleVisibility(false));
|
|
787
|
-
};
|
|
788
|
-
const allColumns = useMemo(() => {
|
|
789
|
-
const columns = getAllColumns();
|
|
790
|
-
if (columnOrder.length > 0 &&
|
|
791
|
-
!columns.some((col) => col.columnDef.columnDefType === 'group')) {
|
|
792
|
-
return [
|
|
793
|
-
...getLeftLeafColumns(),
|
|
794
|
-
...Array.from(new Set(columnOrder)).map((colId) => getCenterLeafColumns().find((col) => (col === null || col === void 0 ? void 0 : col.id) === colId)),
|
|
795
|
-
...getRightLeafColumns(),
|
|
796
|
-
].filter(Boolean);
|
|
797
|
-
}
|
|
798
|
-
return columns;
|
|
799
|
-
}, [
|
|
800
|
-
columnOrder,
|
|
801
|
-
columnPinning,
|
|
802
|
-
getAllColumns(),
|
|
803
|
-
getCenterLeafColumns(),
|
|
804
|
-
getLeftLeafColumns(),
|
|
805
|
-
getRightLeafColumns(),
|
|
806
|
-
]);
|
|
807
|
-
const [hoveredColumn, setHoveredColumn] = useState(null);
|
|
808
|
-
return (React.createElement(Menu, { anchorEl: anchorEl, open: !!anchorEl, onClose: () => setAnchorEl(null), MenuListProps: {
|
|
809
|
-
dense: density === 'compact',
|
|
810
|
-
} },
|
|
811
|
-
React.createElement(Box, { sx: {
|
|
812
|
-
display: 'flex',
|
|
813
|
-
justifyContent: isSubMenu ? 'center' : 'space-between',
|
|
814
|
-
p: '0.5rem',
|
|
815
|
-
pt: 0,
|
|
816
|
-
} },
|
|
817
|
-
!isSubMenu && enableHiding && (React.createElement(Button, { disabled: !getIsSomeColumnsVisible(), onClick: hideAllColumns }, localization.hideAll)),
|
|
818
|
-
!isSubMenu && enableColumnOrdering && (React.createElement(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options)) }, localization.resetOrder)),
|
|
819
|
-
!isSubMenu && enablePinning && (React.createElement(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true) }, localization.unpinAll)),
|
|
820
|
-
enableHiding && (React.createElement(Button, { disabled: getIsAllColumnsVisible(), onClick: () => toggleAllColumnsVisible(true) }, localization.showAll))),
|
|
821
|
-
React.createElement(Divider, null),
|
|
822
|
-
allColumns.map((column, index) => (React.createElement(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isSubMenu: isSubMenu, key: `${index}-${column.id}`, setHoveredColumn: setHoveredColumn, table: table })))));
|
|
823
|
-
};
|
|
824
|
-
|
|
825
672
|
const commonMenuItemStyles = {
|
|
826
673
|
py: '6px',
|
|
827
674
|
my: 0,
|
|
@@ -837,9 +684,8 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
837
684
|
const { getState, toggleAllColumnsVisible, setColumnOrder, options: { columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnResizing, enableGrouping, enableHiding, enablePinning, enableSorting, icons: { ArrowRightIcon, ClearAllIcon, ViewColumnIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, SortIcon, RestartAltIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnSizingInfo, setShowColumnFilters, } = table;
|
|
838
685
|
const { column } = header;
|
|
839
686
|
const { columnDef } = column;
|
|
840
|
-
const { columnSizing, columnVisibility, density } = getState();
|
|
687
|
+
const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
|
|
841
688
|
const [filterMenuAnchorEl, setFilterMenuAnchorEl] = useState(null);
|
|
842
|
-
const [showHideColumnsMenuAnchorEl, setShowHideColumnsMenuAnchorEl] = useState(null);
|
|
843
689
|
const handleClearSort = () => {
|
|
844
690
|
column.clearSorting();
|
|
845
691
|
setAnchorEl(null);
|
|
@@ -887,10 +733,6 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
887
733
|
event.stopPropagation();
|
|
888
734
|
setFilterMenuAnchorEl(event.currentTarget);
|
|
889
735
|
};
|
|
890
|
-
const handleOpenShowHideColumnsMenu = (event) => {
|
|
891
|
-
event.stopPropagation();
|
|
892
|
-
setShowHideColumnsMenuAnchorEl(event.currentTarget);
|
|
893
|
-
};
|
|
894
736
|
const isSelectFilter = !!columnDef.filterSelectOptions;
|
|
895
737
|
const allowedColumnFilterOptions = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _a !== void 0 ? _a : columnFilterModeOptions;
|
|
896
738
|
const showFilterModeSubMenu = enableColumnFilterModes &&
|
|
@@ -934,7 +776,7 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
934
776
|
React.createElement(ListItemIcon, null,
|
|
935
777
|
React.createElement(FilterListOffIcon, null)),
|
|
936
778
|
localization.clearFilter)),
|
|
937
|
-
React.createElement(MenuItem, { divider: enableGrouping || enableHiding, key: 1, onClick: handleFilterByColumn, sx: commonMenuItemStyles },
|
|
779
|
+
React.createElement(MenuItem, { disabled: showColumnFilters && !enableColumnFilterModes, divider: enableGrouping || enableHiding, key: 1, onClick: handleFilterByColumn, sx: commonMenuItemStyles },
|
|
938
780
|
React.createElement(Box, { sx: commonListItemStyles },
|
|
939
781
|
React.createElement(ListItemIcon, null,
|
|
940
782
|
React.createElement(FilterListIcon, null)), (_g = localization.filterByColumn) === null || _g === void 0 ? void 0 :
|
|
@@ -988,10 +830,7 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
988
830
|
React.createElement(Box, { sx: commonListItemStyles },
|
|
989
831
|
React.createElement(ListItemIcon, null,
|
|
990
832
|
React.createElement(ViewColumnIcon, null)), (_k = localization.showAllColumns) === null || _k === void 0 ? void 0 :
|
|
991
|
-
_k.replace('{column}', String(columnDef.header))),
|
|
992
|
-
React.createElement(IconButton, { onClick: handleOpenShowHideColumnsMenu, onMouseEnter: handleOpenShowHideColumnsMenu, size: "small", sx: { p: 0 } },
|
|
993
|
-
React.createElement(ArrowRightIcon, null))),
|
|
994
|
-
React.createElement(MRT_ShowHideColumnsMenu, { anchorEl: showHideColumnsMenuAnchorEl, isSubMenu: true, key: 2, setAnchorEl: setShowHideColumnsMenuAnchorEl, table: table }),
|
|
833
|
+
_k.replace('{column}', String(columnDef.header)))),
|
|
995
834
|
]));
|
|
996
835
|
};
|
|
997
836
|
|
|
@@ -1282,6 +1121,166 @@ const MRT_FullScreenToggleButton = (_a) => {
|
|
|
1282
1121
|
React.createElement(IconButton, Object.assign({ "aria-label": localization.showHideFilters, onClick: handleToggleFullScreen }, rest, { title: undefined }), isFullScreen ? React.createElement(FullscreenExitIcon, null) : React.createElement(FullscreenIcon, null))));
|
|
1283
1122
|
};
|
|
1284
1123
|
|
|
1124
|
+
const MRT_ColumnPinningButtons = ({ column, table, }) => {
|
|
1125
|
+
const { options: { icons: { PushPinIcon }, localization, }, } = table;
|
|
1126
|
+
const handlePinColumn = (pinDirection) => {
|
|
1127
|
+
column.pin(pinDirection);
|
|
1128
|
+
};
|
|
1129
|
+
return (React.createElement(Box, { sx: { minWidth: '70px', textAlign: 'center' } }, column.getIsPinned() ? (React.createElement(Tooltip, { arrow: true, title: localization.unpin },
|
|
1130
|
+
React.createElement(IconButton, { onClick: () => handlePinColumn(false), size: "small" },
|
|
1131
|
+
React.createElement(PushPinIcon, null)))) : (React.createElement(React.Fragment, null,
|
|
1132
|
+
React.createElement(Tooltip, { arrow: true, title: localization.pinToLeft },
|
|
1133
|
+
React.createElement(IconButton, { onClick: () => handlePinColumn('left'), size: "small" },
|
|
1134
|
+
React.createElement(PushPinIcon, { style: {
|
|
1135
|
+
transform: 'rotate(90deg)',
|
|
1136
|
+
} }))),
|
|
1137
|
+
React.createElement(Tooltip, { arrow: true, title: localization.pinToRight },
|
|
1138
|
+
React.createElement(IconButton, { onClick: () => handlePinColumn('right'), size: "small" },
|
|
1139
|
+
React.createElement(PushPinIcon, { style: {
|
|
1140
|
+
transform: 'rotate(-90deg)',
|
|
1141
|
+
} })))))));
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
|
|
1145
|
+
var _a;
|
|
1146
|
+
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
|
1147
|
+
return (React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.move },
|
|
1148
|
+
React.createElement(IconButton, Object.assign({ disableRipple: true, draggable: "true", size: "small" }, iconButtonProps, { onClick: (e) => {
|
|
1149
|
+
var _a;
|
|
1150
|
+
e.stopPropagation();
|
|
1151
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
|
|
1152
|
+
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: '0 -0.1rem', opacity: 0.5, p: '2px', transition: 'all 150ms ease-in-out', '&:hover': {
|
|
1153
|
+
backgroundColor: 'transparent',
|
|
1154
|
+
opacity: 1,
|
|
1155
|
+
}, '&:active': {
|
|
1156
|
+
cursor: 'grabbing',
|
|
1157
|
+
} }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
1158
|
+
? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
|
|
1159
|
+
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }),
|
|
1160
|
+
React.createElement(DragHandleIcon, null))));
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1163
|
+
const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, table, }) => {
|
|
1164
|
+
var _a;
|
|
1165
|
+
const { getState, options: { enableColumnOrdering, enableHiding, enablePinning, localization, }, setColumnOrder, } = table;
|
|
1166
|
+
const { columnOrder } = getState();
|
|
1167
|
+
const { columnDef } = column;
|
|
1168
|
+
const { columnDefType } = columnDef;
|
|
1169
|
+
const switchChecked = (columnDefType !== 'group' && column.getIsVisible()) ||
|
|
1170
|
+
(columnDefType === 'group' &&
|
|
1171
|
+
column.getLeafColumns().some((col) => col.getIsVisible()));
|
|
1172
|
+
const handleToggleColumnHidden = (column) => {
|
|
1173
|
+
var _a, _b;
|
|
1174
|
+
if (columnDefType === 'group') {
|
|
1175
|
+
(_b = (_a = column === null || column === void 0 ? void 0 : column.columns) === null || _a === void 0 ? void 0 : _a.forEach) === null || _b === void 0 ? void 0 : _b.call(_a, (childColumn) => {
|
|
1176
|
+
childColumn.toggleVisibility(!switchChecked);
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
else {
|
|
1180
|
+
column.toggleVisibility();
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
const menuItemRef = useRef(null);
|
|
1184
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
1185
|
+
const handleDragStart = (e) => {
|
|
1186
|
+
setIsDragging(true);
|
|
1187
|
+
e.dataTransfer.setDragImage(menuItemRef.current, 0, 0);
|
|
1188
|
+
};
|
|
1189
|
+
const handleDragEnd = (_e) => {
|
|
1190
|
+
setIsDragging(false);
|
|
1191
|
+
setHoveredColumn(null);
|
|
1192
|
+
if (hoveredColumn) {
|
|
1193
|
+
setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
const handleDragEnter = (_e) => {
|
|
1197
|
+
if (!isDragging && columnDef.enableColumnOrdering !== false) {
|
|
1198
|
+
setHoveredColumn(column);
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
return (React.createElement(React.Fragment, null,
|
|
1202
|
+
React.createElement(MenuItem, { disableRipple: true, ref: menuItemRef, onDragEnter: handleDragEnter, sx: (theme) => ({
|
|
1203
|
+
alignItems: 'center',
|
|
1204
|
+
justifyContent: 'flex-start',
|
|
1205
|
+
my: 0,
|
|
1206
|
+
opacity: isDragging ? 0.5 : 1,
|
|
1207
|
+
outlineOffset: '-2px',
|
|
1208
|
+
outline: isDragging
|
|
1209
|
+
? `2px dashed ${theme.palette.divider}`
|
|
1210
|
+
: (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
1211
|
+
? `2px dashed ${theme.palette.primary.main}`
|
|
1212
|
+
: 'none',
|
|
1213
|
+
pl: `${(column.depth + 0.5) * 2}rem`,
|
|
1214
|
+
py: '6px',
|
|
1215
|
+
}) },
|
|
1216
|
+
React.createElement(Box, { sx: {
|
|
1217
|
+
display: 'flex',
|
|
1218
|
+
flexWrap: 'nowrap',
|
|
1219
|
+
gap: '8px',
|
|
1220
|
+
} },
|
|
1221
|
+
columnDefType !== 'group' &&
|
|
1222
|
+
enableColumnOrdering &&
|
|
1223
|
+
!allColumns.some((col) => col.columnDef.columnDefType === 'group') &&
|
|
1224
|
+
(columnDef.enableColumnOrdering !== false ? (React.createElement(MRT_GrabHandleButton, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })) : (React.createElement(Box, { sx: { width: '28px' } }))),
|
|
1225
|
+
enablePinning &&
|
|
1226
|
+
(column.getCanPin() ? (React.createElement(MRT_ColumnPinningButtons, { column: column, table: table })) : (React.createElement(Box, { sx: { width: '70px' } }))),
|
|
1227
|
+
enableHiding ? (React.createElement(FormControlLabel, { componentsProps: {
|
|
1228
|
+
typography: {
|
|
1229
|
+
sx: {
|
|
1230
|
+
mb: 0,
|
|
1231
|
+
opacity: columnDefType !== 'display' ? 1 : 0.5,
|
|
1232
|
+
},
|
|
1233
|
+
},
|
|
1234
|
+
}, checked: switchChecked, control: React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.toggleVisibility },
|
|
1235
|
+
React.createElement(Switch, null)), disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (React.createElement(Typography, { sx: { alignSelf: 'center' } }, columnDef.header)))), (_a = column.columns) === null || _a === void 0 ? void 0 :
|
|
1236
|
+
_a.map((c, i) => (React.createElement(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, key: `${i}-${c.id}`, setHoveredColumn: setHoveredColumn, table: table })))));
|
|
1237
|
+
};
|
|
1238
|
+
|
|
1239
|
+
const MRT_ShowHideColumnsMenu = ({ anchorEl, setAnchorEl, table, }) => {
|
|
1240
|
+
const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, toggleAllColumnsVisible, options: { enableColumnOrdering, enableHiding, enablePinning, localization, }, } = table;
|
|
1241
|
+
const { density, columnOrder, columnPinning } = getState();
|
|
1242
|
+
const hideAllColumns = () => {
|
|
1243
|
+
getAllLeafColumns()
|
|
1244
|
+
.filter((col) => col.columnDef.enableHiding !== false)
|
|
1245
|
+
.forEach((col) => col.toggleVisibility(false));
|
|
1246
|
+
};
|
|
1247
|
+
const allColumns = useMemo(() => {
|
|
1248
|
+
const columns = getAllColumns();
|
|
1249
|
+
if (columnOrder.length > 0 &&
|
|
1250
|
+
!columns.some((col) => col.columnDef.columnDefType === 'group')) {
|
|
1251
|
+
return [
|
|
1252
|
+
...getLeftLeafColumns(),
|
|
1253
|
+
...Array.from(new Set(columnOrder)).map((colId) => getCenterLeafColumns().find((col) => (col === null || col === void 0 ? void 0 : col.id) === colId)),
|
|
1254
|
+
...getRightLeafColumns(),
|
|
1255
|
+
].filter(Boolean);
|
|
1256
|
+
}
|
|
1257
|
+
return columns;
|
|
1258
|
+
}, [
|
|
1259
|
+
columnOrder,
|
|
1260
|
+
columnPinning,
|
|
1261
|
+
getAllColumns(),
|
|
1262
|
+
getCenterLeafColumns(),
|
|
1263
|
+
getLeftLeafColumns(),
|
|
1264
|
+
getRightLeafColumns(),
|
|
1265
|
+
]);
|
|
1266
|
+
const [hoveredColumn, setHoveredColumn] = useState(null);
|
|
1267
|
+
return (React.createElement(Menu, { anchorEl: anchorEl, open: !!anchorEl, onClose: () => setAnchorEl(null), MenuListProps: {
|
|
1268
|
+
dense: density === 'compact',
|
|
1269
|
+
} },
|
|
1270
|
+
React.createElement(Box, { sx: {
|
|
1271
|
+
display: 'flex',
|
|
1272
|
+
justifyContent: 'space-between',
|
|
1273
|
+
p: '0.5rem',
|
|
1274
|
+
pt: 0,
|
|
1275
|
+
} },
|
|
1276
|
+
enableHiding && (React.createElement(Button, { disabled: !getIsSomeColumnsVisible(), onClick: hideAllColumns }, localization.hideAll)),
|
|
1277
|
+
enableColumnOrdering && (React.createElement(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options)) }, localization.resetOrder)),
|
|
1278
|
+
enablePinning && (React.createElement(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true) }, localization.unpinAll)),
|
|
1279
|
+
enableHiding && (React.createElement(Button, { disabled: getIsAllColumnsVisible(), onClick: () => toggleAllColumnsVisible(true) }, localization.showAll))),
|
|
1280
|
+
React.createElement(Divider, null),
|
|
1281
|
+
allColumns.map((column, index) => (React.createElement(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, key: `${index}-${column.id}`, setHoveredColumn: setHoveredColumn, table: table })))));
|
|
1282
|
+
};
|
|
1283
|
+
|
|
1285
1284
|
const MRT_ShowHideColumnsButton = (_a) => {
|
|
1286
1285
|
var _b;
|
|
1287
1286
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
@@ -1370,6 +1369,7 @@ const MRT_ToolbarDropZone = ({ table, }) => {
|
|
|
1370
1369
|
if (((_a = table.options.state) === null || _a === void 0 ? void 0 : _a.showToolbarDropZone) !== undefined) {
|
|
1371
1370
|
setShowToolbarDropZone(!!enableGrouping &&
|
|
1372
1371
|
!!draggingColumn &&
|
|
1372
|
+
draggingColumn.columnDef.enableGrouping !== false &&
|
|
1373
1373
|
!grouping.includes(draggingColumn.id));
|
|
1374
1374
|
}
|
|
1375
1375
|
}, [enableGrouping, draggingColumn, grouping]);
|
|
@@ -1870,7 +1870,7 @@ const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
|
|
|
1870
1870
|
cursor: 'col-resize',
|
|
1871
1871
|
mr: density === 'compact' ? '-0.75rem' : '-1rem',
|
|
1872
1872
|
position: 'absolute',
|
|
1873
|
-
right: '
|
|
1873
|
+
right: '4px',
|
|
1874
1874
|
px: '4px',
|
|
1875
1875
|
'&:active > hr': {
|
|
1876
1876
|
backgroundColor: theme.palette.info.main,
|
|
@@ -2014,7 +2014,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
2014
2014
|
theme,
|
|
2015
2015
|
})), draggingBorders)) }),
|
|
2016
2016
|
header.isPlaceholder ? null : (React.createElement(Box, { className: "Mui-TableHeadCell-Content", sx: {
|
|
2017
|
-
alignItems: '
|
|
2017
|
+
alignItems: 'center',
|
|
2018
2018
|
display: 'flex',
|
|
2019
2019
|
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
|
2020
2020
|
justifyContent: columnDefType === 'group' || (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
|
|
@@ -2038,7 +2038,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
2038
2038
|
: undefined,
|
|
2039
2039
|
} },
|
|
2040
2040
|
React.createElement(Box, { className: "Mui-TableHeadCell-Content-Wrapper", sx: {
|
|
2041
|
-
minWidth:
|
|
2041
|
+
minWidth: `${Math.min(columnDef.header.length, 5)}ch`,
|
|
2042
2042
|
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
|
2043
2043
|
textOverflow: 'ellipsis',
|
|
2044
2044
|
whiteSpace: ((_d = (_c = columnDef.header) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) < 20 ? 'nowrap' : 'normal',
|
|
@@ -2436,11 +2436,11 @@ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, ta
|
|
|
2436
2436
|
};
|
|
2437
2437
|
const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
|
|
2438
2438
|
|
|
2439
|
-
const MRT_TableDetailPanel = ({ parentRowRef, row, table, virtualRow, }) => {
|
|
2439
|
+
const MRT_TableDetailPanel = ({ parentRowRef, row, rowIndex, table, virtualRow, }) => {
|
|
2440
2440
|
const { getVisibleLeafColumns, getState, options: { layoutMode, muiTableBodyRowProps, muiTableDetailPanelProps, renderDetailPanel, }, } = table;
|
|
2441
2441
|
const { isLoading } = getState();
|
|
2442
2442
|
const tableRowProps = muiTableBodyRowProps instanceof Function
|
|
2443
|
-
? muiTableBodyRowProps({ isDetailPanel: true, row, table })
|
|
2443
|
+
? muiTableBodyRowProps({ isDetailPanel: true, row, staticRowIndex: rowIndex, table })
|
|
2444
2444
|
: muiTableBodyRowProps;
|
|
2445
2445
|
const tableCellProps = muiTableDetailPanelProps instanceof Function
|
|
2446
2446
|
? muiTableDetailPanelProps({ row, table })
|
|
@@ -2466,7 +2466,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, row
|
|
|
2466
2466
|
const { getState, options: { enableRowOrdering, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, }, setHoveredRow, } = table;
|
|
2467
2467
|
const { draggingColumn, draggingRow, editingCell, editingRow, hoveredRow } = getState();
|
|
2468
2468
|
const tableRowProps = muiTableBodyRowProps instanceof Function
|
|
2469
|
-
? muiTableBodyRowProps({ row, table })
|
|
2469
|
+
? muiTableBodyRowProps({ row, staticRowIndex: rowIndex, table })
|
|
2470
2470
|
: muiTableBodyRowProps;
|
|
2471
2471
|
const handleDragEnter = (_e) => {
|
|
2472
2472
|
if (enableRowOrdering && draggingRow) {
|
|
@@ -2518,13 +2518,13 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, row
|
|
|
2518
2518
|
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (React.createElement(Memo_MRT_TableBodyCell, Object.assign({}, props))) : (React.createElement(MRT_TableBodyCell, Object.assign({}, props)));
|
|
2519
2519
|
}),
|
|
2520
2520
|
virtualPaddingRight ? (React.createElement("td", { style: { display: 'flex', width: virtualPaddingRight } })) : null),
|
|
2521
|
-
renderDetailPanel && !row.getIsGrouped() && (React.createElement(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, table: table, virtualRow: virtualRow }))));
|
|
2521
|
+
renderDetailPanel && !row.getIsGrouped() && (React.createElement(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, rowIndex: rowIndex, table: table, virtualRow: virtualRow }))));
|
|
2522
2522
|
};
|
|
2523
2523
|
const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.rowIndex === next.rowIndex);
|
|
2524
2524
|
|
|
2525
2525
|
const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
|
2526
|
-
var _a, _b, _c;
|
|
2527
|
-
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, layoutMode, localization, manualExpanding, manualFiltering, manualGrouping, manualPagination, manualSorting, memoMode, muiTableBodyProps, rowVirtualizerInstanceRef, rowVirtualizerProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
|
|
2526
|
+
var _a, _b, _c, _d;
|
|
2527
|
+
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, layoutMode, localization, manualExpanding, manualFiltering, manualGrouping, manualPagination, manualSorting, memoMode, muiTableBodyProps, renderEmptyRowsFallback, rowVirtualizerInstanceRef, rowVirtualizerProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
|
|
2528
2528
|
const { columnFilters, density, expanded, globalFilter, globalFilterFn, pagination, sorting, } = getState();
|
|
2529
2529
|
const tableBodyProps = muiTableBodyProps instanceof Function
|
|
2530
2530
|
? muiTableBodyProps({ table })
|
|
@@ -2587,17 +2587,18 @@ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddin
|
|
|
2587
2587
|
: 'inherit', minHeight: !rows.length ? '100px' : undefined, position: 'relative' }, ((tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx) instanceof Function
|
|
2588
2588
|
? tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx(theme)
|
|
2589
2589
|
: tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx))) }), (_a = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _a !== void 0 ? _a : (!rows.length ? (React.createElement("tr", { style: { display: layoutMode === 'grid' ? 'grid' : 'table-row' } },
|
|
2590
|
-
React.createElement("td", { colSpan: table.getVisibleLeafColumns().length, style: {
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2590
|
+
React.createElement("td", { colSpan: table.getVisibleLeafColumns().length, style: {
|
|
2591
|
+
display: layoutMode === 'grid' ? 'grid' : 'table-cell',
|
|
2592
|
+
} }, (_b = renderEmptyRowsFallback === null || renderEmptyRowsFallback === void 0 ? void 0 : renderEmptyRowsFallback({ table })) !== null && _b !== void 0 ? _b : (React.createElement(Typography, { sx: {
|
|
2593
|
+
color: 'text.secondary',
|
|
2594
|
+
fontStyle: 'italic',
|
|
2595
|
+
maxWidth: `min(100vw, ${(_d = (_c = tablePaperRef.current) === null || _c === void 0 ? void 0 : _c.clientWidth) !== null && _d !== void 0 ? _d : 360}px)`,
|
|
2596
|
+
py: '2rem',
|
|
2597
|
+
textAlign: 'center',
|
|
2598
|
+
width: '100%',
|
|
2599
|
+
} }, globalFilter || columnFilters.length
|
|
2600
|
+
? localization.noResultsFound
|
|
2601
|
+
: localization.noRecordsToDisplay))))) : (React.createElement(React.Fragment, null, (virtualRows !== null && virtualRows !== void 0 ? virtualRows : rows).map((rowOrVirtualRow, rowIndex) => {
|
|
2601
2602
|
const row = rowVirtualizer
|
|
2602
2603
|
? rows[rowOrVirtualRow.index]
|
|
2603
2604
|
: rowOrVirtualRow;
|