material-react-table 1.0.10 → 1.1.0-beta.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/MaterialReactTable.d.ts +10 -3
- package/dist/cjs/body/MRT_TableBody.d.ts +2 -1
- package/dist/cjs/body/MRT_TableBodyCell.d.ts +2 -1
- package/dist/cjs/body/MRT_TableBodyRow.d.ts +2 -1
- package/dist/cjs/index.js +79 -48
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/table/MRT_TableRoot.d.ts +3 -2
- package/dist/esm/MaterialReactTable.d.ts +10 -3
- package/dist/esm/body/MRT_TableBody.d.ts +2 -1
- package/dist/esm/body/MRT_TableBodyCell.d.ts +2 -1
- package/dist/esm/body/MRT_TableBodyRow.d.ts +2 -1
- package/dist/esm/material-react-table.esm.js +81 -50
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/table/MRT_TableRoot.d.ts +3 -2
- package/dist/index.d.ts +10 -3
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +11 -3
- package/src/body/MRT_TableBody.tsx +18 -12
- package/src/body/MRT_TableBodyCell.tsx +7 -1
- package/src/body/MRT_TableBodyRow.tsx +36 -15
- package/src/body/MRT_TableDetailPanel.tsx +1 -1
- package/src/buttons/MRT_ExpandAllButton.tsx +1 -1
- package/src/buttons/MRT_ExpandButton.tsx +1 -1
- package/src/buttons/MRT_GrabHandleButton.tsx +1 -1
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +1 -1
- package/src/column.utils.ts +1 -1
- package/src/head/MRT_TableHead.tsx +8 -3
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +9 -7
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +3 -1
- package/src/inputs/MRT_SelectCheckbox.tsx +51 -46
- package/src/table/MRT_Table.tsx +7 -2
- package/src/table/MRT_TablePaper.tsx +1 -1
- package/src/table/MRT_TableRoot.tsx +1 -1
- package/src/toolbar/MRT_TopToolbar.tsx +1 -1
|
@@ -45,6 +45,7 @@ export declare const MRT_TableRoot: <TData extends Record<string, any> = {}>(pro
|
|
|
45
45
|
icons?: Partial<import("..").MRT_Icons> | undefined;
|
|
46
46
|
initialState?: Partial<MRT_TableState<TData>> | undefined;
|
|
47
47
|
localization?: Partial<MRT_Localization> | undefined;
|
|
48
|
+
memoMode?: "cell" | "row" | "table-body" | undefined;
|
|
48
49
|
muiBottomToolbarProps?: import("@mui/material").ToolbarProps<"div", {}> | (({ table }: {
|
|
49
50
|
table: MRT_TableInstance<TData>;
|
|
50
51
|
}) => import("@mui/material").ToolbarProps<"div", {}>) | undefined;
|
|
@@ -65,10 +66,10 @@ export declare const MRT_TableRoot: <TData extends Record<string, any> = {}>(pro
|
|
|
65
66
|
muiSelectAllCheckboxProps?: import("@mui/material").CheckboxProps | (({ table }: {
|
|
66
67
|
table: MRT_TableInstance<TData>;
|
|
67
68
|
}) => import("@mui/material").CheckboxProps) | undefined;
|
|
68
|
-
muiSelectCheckboxProps?: import("@mui/material").CheckboxProps | (({ table, row, }: {
|
|
69
|
+
muiSelectCheckboxProps?: import("@mui/material").CheckboxProps | import("@mui/material").RadioProps | (({ table, row, }: {
|
|
69
70
|
table: MRT_TableInstance<TData>;
|
|
70
71
|
row: MRT_Row<TData>;
|
|
71
|
-
}) => import("@mui/material").CheckboxProps) | undefined;
|
|
72
|
+
}) => import("@mui/material").CheckboxProps | import("@mui/material").RadioProps) | undefined;
|
|
72
73
|
muiTableBodyCellCopyButtonProps?: import("@mui/material").ButtonProps<"button", {}> | (({ cell, column, row, table, }: {
|
|
73
74
|
cell: MRT_Cell<TData>;
|
|
74
75
|
column: MRT_Column<TData>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, MutableRefObject, ReactNode, SetStateAction } from 'react';
|
|
2
|
-
import type { AlertProps, ButtonProps, CheckboxProps, ChipProps, IconButtonProps, LinearProgressProps, PaperProps, SkeletonProps, TableBodyProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, TableProps, TableRowProps, TextFieldProps, ToolbarProps } from '@mui/material';
|
|
2
|
+
import type { AlertProps, ButtonProps, CheckboxProps, ChipProps, IconButtonProps, LinearProgressProps, PaperProps, RadioProps, SkeletonProps, TableBodyProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, TableProps, TableRowProps, TextFieldProps, ToolbarProps } from '@mui/material';
|
|
3
3
|
import type { Cell, Column, ColumnDef, DeepKeys, FilterFn, Header, HeaderGroup, OnChangeFn, Row, SortingFn, Table, TableOptions, TableState } from '@tanstack/react-table';
|
|
4
4
|
import type { Options as VirtualizerOptions, VirtualItem } from 'react-virtual';
|
|
5
5
|
import { MRT_Icons } from './icons';
|
|
@@ -448,6 +448,13 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
448
448
|
* @link https://www.material-react-table.com/docs/guides/localization
|
|
449
449
|
*/
|
|
450
450
|
localization?: Partial<MRT_Localization>;
|
|
451
|
+
/**
|
|
452
|
+
* Memoize cells, rows, or the entire table body to potentially improve render performance.
|
|
453
|
+
*
|
|
454
|
+
* @warning This will break some dynamic rendering features. See the memoization guide for more info:
|
|
455
|
+
* @link https://www.material-react-table.com/docs/guides/memoize-components
|
|
456
|
+
*/
|
|
457
|
+
memoMode?: 'cell' | 'row' | 'table-body';
|
|
451
458
|
muiBottomToolbarProps?: ToolbarProps | (({ table }: {
|
|
452
459
|
table: MRT_TableInstance<TData>;
|
|
453
460
|
}) => ToolbarProps);
|
|
@@ -468,10 +475,10 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
468
475
|
muiSelectAllCheckboxProps?: CheckboxProps | (({ table }: {
|
|
469
476
|
table: MRT_TableInstance<TData>;
|
|
470
477
|
}) => CheckboxProps);
|
|
471
|
-
muiSelectCheckboxProps?: CheckboxProps | (({ table, row, }: {
|
|
478
|
+
muiSelectCheckboxProps?: (CheckboxProps | RadioProps) | (({ table, row, }: {
|
|
472
479
|
table: MRT_TableInstance<TData>;
|
|
473
480
|
row: MRT_Row<TData>;
|
|
474
|
-
}) => CheckboxProps);
|
|
481
|
+
}) => CheckboxProps | RadioProps);
|
|
475
482
|
muiTableBodyCellCopyButtonProps?: ButtonProps | (({ cell, column, row, table, }: {
|
|
476
483
|
cell: MRT_Cell<TData>;
|
|
477
484
|
column: MRT_Column<TData>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
2
|
import type { MRT_TableInstance } from '..';
|
|
3
3
|
interface Props {
|
|
4
4
|
table: MRT_TableInstance;
|
|
5
5
|
}
|
|
6
6
|
export declare const MRT_TableBody: FC<Props>;
|
|
7
|
+
export declare const Memo_MRT_TableBody: React.NamedExoticComponent<Props>;
|
|
7
8
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC, RefObject } from 'react';
|
|
1
|
+
import React, { FC, RefObject } from 'react';
|
|
2
2
|
import type { MRT_Cell, MRT_TableInstance } from '..';
|
|
3
3
|
interface Props {
|
|
4
4
|
cell: MRT_Cell;
|
|
@@ -8,4 +8,5 @@ interface Props {
|
|
|
8
8
|
table: MRT_TableInstance;
|
|
9
9
|
}
|
|
10
10
|
export declare const MRT_TableBodyCell: FC<Props>;
|
|
11
|
+
export declare const Memo_MRT_TableBodyCell: React.NamedExoticComponent<Props>;
|
|
11
12
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
2
|
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
3
3
|
interface Props {
|
|
4
4
|
row: MRT_Row;
|
|
@@ -7,4 +7,5 @@ interface Props {
|
|
|
7
7
|
virtualRow?: any;
|
|
8
8
|
}
|
|
9
9
|
export declare const MRT_TableBodyRow: FC<Props>;
|
|
10
|
+
export declare const Memo_MRT_TableBodyRow: React.NamedExoticComponent<Props>;
|
|
10
11
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { useMemo, useRef, useState, useCallback, useEffect, Fragment, useLayoutEffect } from 'react';
|
|
1
|
+
import React, { useMemo, useRef, useState, 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 { ArrowRight, Cancel, CheckBox, ClearAll, Close, DensityLarge, DensityMedium, DensitySmall, DragHandle, DynamicFeed, Edit, ExpandLess, ExpandMore, FilterAlt, FilterAltOff, FilterList, FilterListOff, FullscreenExit, Fullscreen, KeyboardDoubleArrowDown, MoreHoriz, MoreVert, PushPin, RestartAlt, Save, Search, SearchOff, Sort, ViewColumn, VisibilityOff } from '@mui/icons-material';
|
|
4
4
|
import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
|
|
5
|
-
import { Tooltip, IconButton, Menu, MenuItem, Box, alpha, lighten, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, LinearProgress, TablePagination, Chip, Alert, AlertTitle, Fade, useMediaQuery, Toolbar, Grow, TableSortLabel, useTheme, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog, DialogTitle, DialogContent, Stack, DialogActions } from '@mui/material';
|
|
5
|
+
import { Tooltip, IconButton, Menu, MenuItem, Box, alpha, lighten, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Radio, Checkbox, debounce, Collapse, TextField, InputAdornment, LinearProgress, TablePagination, Chip, Alert, AlertTitle, Fade, useMediaQuery, Toolbar, Grow, TableSortLabel, useTheme, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog, DialogTitle, DialogContent, Stack, DialogActions } from '@mui/material';
|
|
6
6
|
import { useVirtual } from 'react-virtual';
|
|
7
7
|
|
|
8
8
|
/******************************************************************************
|
|
@@ -273,7 +273,7 @@ const MRT_ExpandAllButton = ({ table }) => {
|
|
|
273
273
|
: getIsSomeRowsExpanded()
|
|
274
274
|
? -90
|
|
275
275
|
: 0}deg)`,
|
|
276
|
-
transition: 'transform
|
|
276
|
+
transition: 'transform 150ms',
|
|
277
277
|
} })))));
|
|
278
278
|
};
|
|
279
279
|
|
|
@@ -301,7 +301,7 @@ const MRT_ExpandButton = ({ row, table }) => {
|
|
|
301
301
|
: row.getIsExpanded()
|
|
302
302
|
? -180
|
|
303
303
|
: 0}deg)`,
|
|
304
|
-
transition: 'transform
|
|
304
|
+
transition: 'transform 150ms',
|
|
305
305
|
} })))));
|
|
306
306
|
};
|
|
307
307
|
|
|
@@ -489,7 +489,7 @@ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table,
|
|
|
489
489
|
var _a;
|
|
490
490
|
e.stopPropagation();
|
|
491
491
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
|
|
492
|
-
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all
|
|
492
|
+
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 150ms ease-in-out', '&:hover': {
|
|
493
493
|
backgroundColor: 'transparent',
|
|
494
494
|
opacity: 1,
|
|
495
495
|
}, '&:active': {
|
|
@@ -633,7 +633,7 @@ const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, })
|
|
|
633
633
|
? 'sticky'
|
|
634
634
|
: undefined, right: column.getIsPinned() === 'right'
|
|
635
635
|
? `${getTotalRight(table, column)}px`
|
|
636
|
-
: undefined, transition: `all ${column.getIsResizing() ? 0 : '
|
|
636
|
+
: undefined, transition: `all ${column.getIsResizing() ? 0 : '150ms'} ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
637
637
|
? tableCellProps.sx(theme)
|
|
638
638
|
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), { maxWidth: `min(${column.getSize()}px, fit-content)`, minWidth: `max(${column.getSize()}px, ${(_c = column.columnDef.minSize) !== null && _c !== void 0 ? _c : 30}px)`, width: (_d = header === null || header === void 0 ? void 0 : header.getSize()) !== null && _d !== void 0 ? _d : column.getSize() }));
|
|
639
639
|
};
|
|
@@ -1007,7 +1007,7 @@ const commonIconButtonStyles = {
|
|
|
1007
1007
|
height: '2rem',
|
|
1008
1008
|
ml: '10px',
|
|
1009
1009
|
opacity: 0.5,
|
|
1010
|
-
transition: 'opacity
|
|
1010
|
+
transition: 'opacity 150ms',
|
|
1011
1011
|
width: '2rem',
|
|
1012
1012
|
'&:hover': {
|
|
1013
1013
|
opacity: 1,
|
|
@@ -1038,7 +1038,7 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
|
|
|
1038
1038
|
|
|
1039
1039
|
const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
1040
1040
|
var _a;
|
|
1041
|
-
const { getState, options: { localization, muiSelectCheckboxProps, muiSelectAllCheckboxProps, selectAllMode, }, } = table;
|
|
1041
|
+
const { getState, options: { localization, enableMultiRowSelection, muiSelectCheckboxProps, muiSelectAllCheckboxProps, selectAllMode, }, } = table;
|
|
1042
1042
|
const { density } = getState();
|
|
1043
1043
|
const checkboxProps = !row
|
|
1044
1044
|
? muiSelectAllCheckboxProps instanceof Function
|
|
@@ -1047,33 +1047,33 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
1047
1047
|
: muiSelectCheckboxProps instanceof Function
|
|
1048
1048
|
? muiSelectCheckboxProps({ row, table })
|
|
1049
1049
|
: muiSelectCheckboxProps;
|
|
1050
|
+
const commonProps = Object.assign(Object.assign({ checked: selectAll
|
|
1051
|
+
? selectAllMode === 'page'
|
|
1052
|
+
? table.getIsAllPageRowsSelected()
|
|
1053
|
+
: table.getIsAllRowsSelected()
|
|
1054
|
+
: row === null || row === void 0 ? void 0 : row.getIsSelected(), inputProps: {
|
|
1055
|
+
'aria-label': selectAll
|
|
1056
|
+
? localization.toggleSelectAll
|
|
1057
|
+
: localization.toggleSelectRow,
|
|
1058
|
+
}, onChange: row
|
|
1059
|
+
? row.getToggleSelectedHandler()
|
|
1060
|
+
: selectAllMode === 'all'
|
|
1061
|
+
? table.getToggleAllRowsSelectedHandler()
|
|
1062
|
+
: table.getToggleAllPageRowsSelectedHandler(), size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
|
1063
|
+
var _a;
|
|
1064
|
+
e.stopPropagation();
|
|
1065
|
+
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
1066
|
+
}, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', width: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined }, ((checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx) instanceof Function
|
|
1067
|
+
? checkboxProps.sx(theme)
|
|
1068
|
+
: checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))), title: undefined });
|
|
1050
1069
|
return (React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _a !== void 0 ? _a : (selectAll
|
|
1051
1070
|
? localization.toggleSelectAll
|
|
1052
|
-
: localization.toggleSelectRow) },
|
|
1053
|
-
|
|
1054
|
-
|
|
1071
|
+
: localization.toggleSelectRow) }, enableMultiRowSelection === false ? (React.createElement(Radio, Object.assign({}, commonProps))) : (React.createElement(Checkbox, Object.assign({ indeterminate: selectAll
|
|
1072
|
+
? table.getIsSomeRowsSelected() &&
|
|
1073
|
+
!(selectAllMode === 'page'
|
|
1055
1074
|
? table.getIsAllPageRowsSelected()
|
|
1056
|
-
: table.getIsAllRowsSelected()
|
|
1057
|
-
|
|
1058
|
-
? table.getIsSomeRowsSelected() &&
|
|
1059
|
-
!(selectAllMode === 'page'
|
|
1060
|
-
? table.getIsAllPageRowsSelected()
|
|
1061
|
-
: table.getIsAllRowsSelected())
|
|
1062
|
-
: row === null || row === void 0 ? void 0 : row.getIsSomeSelected(), inputProps: {
|
|
1063
|
-
'aria-label': selectAll
|
|
1064
|
-
? localization.toggleSelectAll
|
|
1065
|
-
: localization.toggleSelectRow,
|
|
1066
|
-
}, onChange: row
|
|
1067
|
-
? row.getToggleSelectedHandler()
|
|
1068
|
-
: selectAllMode === 'all'
|
|
1069
|
-
? table.getToggleAllRowsSelectedHandler()
|
|
1070
|
-
: table.getToggleAllPageRowsSelectedHandler(), size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onClick: (e) => {
|
|
1071
|
-
var _a;
|
|
1072
|
-
e.stopPropagation();
|
|
1073
|
-
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
1074
|
-
}, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', width: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined }, ((checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx) instanceof Function
|
|
1075
|
-
? checkboxProps.sx(theme)
|
|
1076
|
-
: checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))), title: undefined }))));
|
|
1075
|
+
: table.getIsAllRowsSelected())
|
|
1076
|
+
: row === null || row === void 0 ? void 0 : row.getIsSomeSelected() }, commonProps)))));
|
|
1077
1077
|
};
|
|
1078
1078
|
|
|
1079
1079
|
const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
@@ -1336,7 +1336,7 @@ const commonToolbarStyles = ({ theme }) => ({
|
|
|
1336
1336
|
minHeight: '3.5rem',
|
|
1337
1337
|
overflow: 'hidden',
|
|
1338
1338
|
p: '0 !important',
|
|
1339
|
-
transition: 'all
|
|
1339
|
+
transition: 'all 150ms ease-in-out',
|
|
1340
1340
|
zIndex: 1,
|
|
1341
1341
|
});
|
|
1342
1342
|
const MRT_TopToolbar = ({ table }) => {
|
|
@@ -1446,13 +1446,13 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
|
1446
1446
|
const iconButtonProps = Object.assign(Object.assign({}, mTableHeadCellColumnActionsButtonProps), mcTableHeadCellColumnActionsButtonProps);
|
|
1447
1447
|
return (React.createElement(React.Fragment, null,
|
|
1448
1448
|
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.columnActions },
|
|
1449
|
-
React.createElement(IconButton, Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ height: '2rem', mt: '-0.2rem', opacity: 0.5, transition: 'opacity
|
|
1449
|
+
React.createElement(IconButton, Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ height: '2rem', mt: '-0.2rem', opacity: 0.5, transition: 'opacity 150ms', width: '2rem', '&:hover': {
|
|
1450
1450
|
opacity: 1,
|
|
1451
1451
|
} }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
1452
1452
|
? iconButtonProps.sx(theme)
|
|
1453
1453
|
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }),
|
|
1454
1454
|
React.createElement(MoreVertIcon, null))),
|
|
1455
|
-
React.createElement(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table })));
|
|
1455
|
+
anchorEl && (React.createElement(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table }))));
|
|
1456
1456
|
};
|
|
1457
1457
|
|
|
1458
1458
|
const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
@@ -1790,7 +1790,9 @@ const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
|
|
|
1790
1790
|
position: 'absolute',
|
|
1791
1791
|
right: '1px',
|
|
1792
1792
|
touchAction: 'none',
|
|
1793
|
-
transition: column.getIsResizing()
|
|
1793
|
+
transition: column.getIsResizing()
|
|
1794
|
+
? undefined
|
|
1795
|
+
: 'all 150ms ease-in-out',
|
|
1794
1796
|
userSelect: 'none',
|
|
1795
1797
|
zIndex: 4,
|
|
1796
1798
|
'&:active': {
|
|
@@ -1951,11 +1953,13 @@ const MRT_TableHeadRow = ({ headerGroup, table }) => {
|
|
|
1951
1953
|
};
|
|
1952
1954
|
|
|
1953
1955
|
const MRT_TableHead = ({ table }) => {
|
|
1954
|
-
const { getHeaderGroups, options: { enableStickyHeader, muiTableHeadProps }, } = table;
|
|
1956
|
+
const { getHeaderGroups, getState, options: { enableStickyHeader, muiTableHeadProps, enableRowVirtualization }, } = table;
|
|
1957
|
+
const { isFullScreen } = getState();
|
|
1955
1958
|
const tableHeadProps = muiTableHeadProps instanceof Function
|
|
1956
1959
|
? muiTableHeadProps({ table })
|
|
1957
1960
|
: muiTableHeadProps;
|
|
1958
|
-
|
|
1961
|
+
const stickyHeader = enableStickyHeader || enableRowVirtualization || isFullScreen;
|
|
1962
|
+
return (React.createElement(TableHead, Object.assign({}, tableHeadProps, { sx: (theme) => (Object.assign({ opacity: 0.97, position: stickyHeader ? 'sticky' : undefined, zIndex: stickyHeader ? 2 : undefined }, ((tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx) instanceof Function
|
|
1959
1963
|
? tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx(theme)
|
|
1960
1964
|
: tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx))) }), getHeaderGroups().map((headerGroup) => (React.createElement(MRT_TableHeadRow, { headerGroup: headerGroup, key: headerGroup.id, table: table })))));
|
|
1961
1965
|
};
|
|
@@ -2172,7 +2176,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2172
2176
|
: undefined,
|
|
2173
2177
|
}
|
|
2174
2178
|
: undefined;
|
|
2175
|
-
return (React.createElement(TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => (Object.assign(Object.assign({ cursor: isEditable && editingMode === 'cell' ? 'pointer' : '
|
|
2179
|
+
return (React.createElement(TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => (Object.assign(Object.assign({ cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'inherit', overflow: 'hidden', p: density === 'compact'
|
|
2176
2180
|
? columnDefType === 'display'
|
|
2177
2181
|
? '0 0.5rem'
|
|
2178
2182
|
: '0.5rem'
|
|
@@ -2212,6 +2216,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2212
2216
|
_b.length,
|
|
2213
2217
|
")"))));
|
|
2214
2218
|
};
|
|
2219
|
+
const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
|
|
2215
2220
|
|
|
2216
2221
|
const MRT_TableDetailPanel = ({ row, table }) => {
|
|
2217
2222
|
const { getVisibleLeafColumns, options: { muiTableBodyRowProps, muiTableDetailPanelProps, renderDetailPanel, }, } = table;
|
|
@@ -2222,7 +2227,7 @@ const MRT_TableDetailPanel = ({ row, table }) => {
|
|
|
2222
2227
|
? muiTableDetailPanelProps({ row, table })
|
|
2223
2228
|
: muiTableDetailPanelProps;
|
|
2224
2229
|
return (React.createElement(TableRow, Object.assign({}, tableRowProps),
|
|
2225
|
-
React.createElement(TableCell, Object.assign({ colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ borderBottom: !row.getIsExpanded() ? 'none' : undefined, pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all
|
|
2230
|
+
React.createElement(TableCell, Object.assign({ colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ borderBottom: !row.getIsExpanded() ? 'none' : undefined, pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
2226
2231
|
? tableCellProps.sx(theme)
|
|
2227
2232
|
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }), renderDetailPanel && (React.createElement(Collapse, { in: row.getIsExpanded() }, renderDetailPanel({ row, table }))))));
|
|
2228
2233
|
};
|
|
@@ -2230,8 +2235,8 @@ const MRT_TableDetailPanel = ({ row, table }) => {
|
|
|
2230
2235
|
const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
2231
2236
|
var _a, _b;
|
|
2232
2237
|
const theme = useTheme();
|
|
2233
|
-
const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, muiTableBodyRowProps, renderDetailPanel }, setHoveredRow, } = table;
|
|
2234
|
-
const { draggingRow, hoveredRow } = getState();
|
|
2238
|
+
const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, memoMode, muiTableBodyRowProps, renderDetailPanel, }, setHoveredRow, } = table;
|
|
2239
|
+
const { draggingColumn, draggingRow, editingCell, editingRow, hoveredRow } = getState();
|
|
2235
2240
|
const tableRowProps = muiTableBodyRowProps instanceof Function
|
|
2236
2241
|
? muiTableBodyRowProps({ row, table })
|
|
2237
2242
|
: muiTableBodyRowProps;
|
|
@@ -2257,7 +2262,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2257
2262
|
if (virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.measureRef) {
|
|
2258
2263
|
virtualRow.measureRef = node;
|
|
2259
2264
|
}
|
|
2260
|
-
} }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, transition: 'all
|
|
2265
|
+
} }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, transition: 'all 150ms ease-in-out', '&:hover td': {
|
|
2261
2266
|
backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned()
|
|
2262
2267
|
? theme.palette.mode === 'dark'
|
|
2263
2268
|
? `${lighten(theme.palette.background.default, 0.12)}`
|
|
@@ -2265,13 +2270,29 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2265
2270
|
: undefined,
|
|
2266
2271
|
} }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
|
|
2267
2272
|
? tableRowProps.sx(theme)
|
|
2268
|
-
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)), draggingBorders)) }), (_b = (_a = row === null || row === void 0 ? void 0 : row.getVisibleCells()) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (cell) =>
|
|
2273
|
+
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)), draggingBorders)) }), (_b = (_a = row === null || row === void 0 ? void 0 : row.getVisibleCells()) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (cell) => {
|
|
2274
|
+
const props = {
|
|
2275
|
+
cell,
|
|
2276
|
+
enableHover: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false,
|
|
2277
|
+
key: cell.id,
|
|
2278
|
+
rowIndex,
|
|
2279
|
+
rowRef,
|
|
2280
|
+
table,
|
|
2281
|
+
};
|
|
2282
|
+
return memoMode === 'cell' &&
|
|
2283
|
+
cell.column.columnDef.columnDefType === 'data' &&
|
|
2284
|
+
!draggingColumn &&
|
|
2285
|
+
!draggingRow &&
|
|
2286
|
+
(editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
|
|
2287
|
+
(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)));
|
|
2288
|
+
})),
|
|
2269
2289
|
renderDetailPanel && !row.getIsGrouped() && (React.createElement(MRT_TableDetailPanel, { row: row, table: table }))));
|
|
2270
2290
|
};
|
|
2291
|
+
const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row);
|
|
2271
2292
|
|
|
2272
2293
|
const MRT_TableBody = ({ table }) => {
|
|
2273
2294
|
var _a;
|
|
2274
|
-
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, localization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
|
|
2295
|
+
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, localization, manualFiltering, manualSorting, memoMode, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
|
|
2275
2296
|
const { columnFilters, globalFilter, pagination, sorting } = getState();
|
|
2276
2297
|
const tableBodyProps = muiTableBodyProps instanceof Function
|
|
2277
2298
|
? muiTableBodyProps({ table })
|
|
@@ -2355,11 +2376,21 @@ const MRT_TableBody = ({ table }) => {
|
|
|
2355
2376
|
const row = enableRowVirtualization
|
|
2356
2377
|
? rows[rowOrVirtualRow.index]
|
|
2357
2378
|
: rowOrVirtualRow;
|
|
2358
|
-
|
|
2379
|
+
const props = {
|
|
2380
|
+
key: row.id,
|
|
2381
|
+
row,
|
|
2382
|
+
rowIndex: enableRowVirtualization
|
|
2383
|
+
? rowOrVirtualRow.index
|
|
2384
|
+
: rowIndex,
|
|
2385
|
+
table,
|
|
2386
|
+
virtualRow: enableRowVirtualization ? rowOrVirtualRow : null,
|
|
2387
|
+
};
|
|
2388
|
+
return memoMode === 'row' ? (React.createElement(Memo_MRT_TableBodyRow, Object.assign({}, props))) : (React.createElement(MRT_TableBodyRow, Object.assign({}, props)));
|
|
2359
2389
|
}),
|
|
2360
2390
|
enableRowVirtualization && paddingBottom > 0 && (React.createElement("tr", null,
|
|
2361
2391
|
React.createElement("td", { style: { height: `${paddingBottom}px` } })))))));
|
|
2362
2392
|
};
|
|
2393
|
+
const Memo_MRT_TableBody = memo(MRT_TableBody, () => true);
|
|
2363
2394
|
|
|
2364
2395
|
const MRT_TableFooterCell = ({ footer, table }) => {
|
|
2365
2396
|
var _a, _b, _c;
|
|
@@ -2422,7 +2453,7 @@ const MRT_TableFooter = ({ table }) => {
|
|
|
2422
2453
|
};
|
|
2423
2454
|
|
|
2424
2455
|
const MRT_Table = ({ table }) => {
|
|
2425
|
-
const { getState, options: { enableColumnResizing, enableRowVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, muiTableProps, }, } = table;
|
|
2456
|
+
const { getState, options: { enableColumnResizing, enableRowVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, memoMode, muiTableProps, }, } = table;
|
|
2426
2457
|
const { isFullScreen } = getState();
|
|
2427
2458
|
const tableProps = muiTableProps instanceof Function
|
|
2428
2459
|
? muiTableProps({ table })
|
|
@@ -2431,7 +2462,7 @@ const MRT_Table = ({ table }) => {
|
|
|
2431
2462
|
? tableProps.sx(theme)
|
|
2432
2463
|
: tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))) }),
|
|
2433
2464
|
enableTableHead && React.createElement(MRT_TableHead, { table: table }),
|
|
2434
|
-
React.createElement(MRT_TableBody, { table: table }),
|
|
2465
|
+
memoMode === 'table-body' ? (React.createElement(Memo_MRT_TableBody, { table: table })) : (React.createElement(MRT_TableBody, { table: table })),
|
|
2435
2466
|
enableTableFooter && React.createElement(MRT_TableFooter, { table: table })));
|
|
2436
2467
|
};
|
|
2437
2468
|
|
|
@@ -2481,7 +2512,7 @@ const MRT_TablePaper = ({ table }) => {
|
|
|
2481
2512
|
//@ts-ignore
|
|
2482
2513
|
tablePaperProps.ref.current = ref;
|
|
2483
2514
|
}
|
|
2484
|
-
}, sx: (theme) => (Object.assign({ transition: 'all
|
|
2515
|
+
}, sx: (theme) => (Object.assign({ transition: 'all 150ms ease-in-out' }, ((tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx) instanceof Function
|
|
2485
2516
|
? tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx(theme)
|
|
2486
2517
|
: tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), (isFullScreen
|
|
2487
2518
|
? {
|
|
@@ -2572,7 +2603,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2572
2603
|
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row }) => (React.createElement(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header: props.localization.actions, size: 70 }, props.defaultDisplayColumn), (_b = props.displayColumnDefOptions) === null || _b === void 0 ? void 0 : _b['mrt-row-actions']), { id: 'mrt-row-actions' }),
|
|
2573
2604
|
columnOrder.includes('mrt-row-expand') &&
|
|
2574
2605
|
showExpandColumn(props, grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_ExpandButton, { row: row, table: table })), Header: () => props.enableExpandAll ? (React.createElement(MRT_ExpandAllButton, { table: table })) : null, header: props.localization.expand, size: 60 }, props.defaultDisplayColumn), (_c = props.displayColumnDefOptions) === null || _c === void 0 ? void 0 : _c['mrt-row-expand']), { id: 'mrt-row-expand' }),
|
|
2575
|
-
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll ? (React.createElement(MRT_SelectCheckbox, { selectAll: true, table: table })) : null, header: props.localization.select, size: 60 }, props.defaultDisplayColumn), (_d = props.displayColumnDefOptions) === null || _d === void 0 ? void 0 : _d['mrt-row-select']), { id: 'mrt-row-select' }),
|
|
2606
|
+
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll && props.enableMultiRowSelection ? (React.createElement(MRT_SelectCheckbox, { selectAll: true, table: table })) : null, header: props.localization.select, size: 60 }, props.defaultDisplayColumn), (_d = props.displayColumnDefOptions) === null || _d === void 0 ? void 0 : _d['mrt-row-select']), { id: 'mrt-row-select' }),
|
|
2576
2607
|
columnOrder.includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => props.localization.rowNumber, header: props.localization.rowNumbers, size: 60 }, props.defaultDisplayColumn), (_e = props.displayColumnDefOptions) === null || _e === void 0 ? void 0 : _e['mrt-row-numbers']), { id: 'mrt-row-numbers' }),
|
|
2577
2608
|
].filter(Boolean);
|
|
2578
2609
|
}, [
|