material-react-table 1.4.2 → 1.5.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/index.js +178 -73
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/MaterialReactTable.d.ts +18 -5
- package/dist/cjs/types/body/MRT_TableBody.d.ts +5 -0
- package/dist/cjs/types/body/MRT_TableBodyCell.d.ts +3 -0
- package/dist/cjs/types/body/MRT_TableBodyRow.d.ts +5 -1
- package/dist/cjs/types/footer/MRT_TableFooter.d.ts +4 -0
- package/dist/cjs/types/footer/MRT_TableFooterRow.d.ts +4 -0
- package/dist/cjs/types/head/MRT_TableHead.d.ts +4 -0
- package/dist/cjs/types/head/MRT_TableHeadRow.d.ts +4 -0
- package/dist/cjs/types/table/MRT_TableRoot.d.ts +12 -5
- package/dist/cjs/types/toolbar/MRT_TablePagination.d.ts +1 -1
- package/dist/esm/material-react-table.esm.js +172 -66
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/MaterialReactTable.d.ts +18 -5
- package/dist/esm/types/body/MRT_TableBody.d.ts +5 -0
- package/dist/esm/types/body/MRT_TableBodyCell.d.ts +3 -0
- package/dist/esm/types/body/MRT_TableBodyRow.d.ts +5 -1
- package/dist/esm/types/footer/MRT_TableFooter.d.ts +4 -0
- package/dist/esm/types/footer/MRT_TableFooterRow.d.ts +4 -0
- package/dist/esm/types/head/MRT_TableHead.d.ts +4 -0
- package/dist/esm/types/head/MRT_TableHeadRow.d.ts +4 -0
- package/dist/esm/types/table/MRT_TableRoot.d.ts +12 -5
- package/dist/esm/types/toolbar/MRT_TablePagination.d.ts +1 -1
- package/dist/index.d.ts +20 -7
- package/locales/ru.esm.js +1 -1
- package/locales/ru.js +1 -1
- package/package.json +6 -6
- package/src/MaterialReactTable.tsx +30 -8
- package/src/_locales/ru.ts +1 -1
- package/src/body/MRT_TableBody.tsx +42 -13
- package/src/body/MRT_TableBodyCell.tsx +17 -1
- package/src/body/MRT_TableBodyRow.tsx +24 -3
- package/src/footer/MRT_TableFooter.tsx +13 -1
- package/src/footer/MRT_TableFooterCell.tsx +10 -2
- package/src/footer/MRT_TableFooterRow.tsx +31 -4
- package/src/head/MRT_TableHead.tsx +13 -1
- package/src/head/MRT_TableHeadCell.tsx +6 -3
- package/src/head/MRT_TableHeadRow.tsx +30 -4
- package/src/inputs/MRT_FilterTextField.tsx +3 -2
- package/src/inputs/MRT_GlobalFilterTextField.tsx +1 -1
- package/src/table/MRT_Table.tsx +105 -7
- package/src/toolbar/MRT_TablePagination.tsx +2 -2
@@ -54,7 +54,7 @@ import useMediaQuery from '@mui/material/useMediaQuery';
|
|
54
54
|
import Collapse from '@mui/material/Collapse';
|
55
55
|
import InputAdornment from '@mui/material/InputAdornment';
|
56
56
|
import TextField from '@mui/material/TextField';
|
57
|
-
import debounce from '@mui/material/utils
|
57
|
+
import { debounce } from '@mui/material/utils';
|
58
58
|
import LinearProgress from '@mui/material/LinearProgress';
|
59
59
|
import TablePagination from '@mui/material/TablePagination';
|
60
60
|
import Alert from '@mui/material/Alert';
|
@@ -62,12 +62,12 @@ import AlertTitle from '@mui/material/AlertTitle';
|
|
62
62
|
import Chip from '@mui/material/Chip';
|
63
63
|
import Fade from '@mui/material/Fade';
|
64
64
|
import TableContainer from '@mui/material/TableContainer';
|
65
|
+
import { useVirtualizer, defaultRangeExtractor } from '@tanstack/react-virtual';
|
65
66
|
import Table from '@mui/material/Table';
|
66
67
|
import TableHead from '@mui/material/TableHead';
|
67
68
|
import TableRow from '@mui/material/TableRow';
|
68
69
|
import TableCell from '@mui/material/TableCell';
|
69
70
|
import TableSortLabel from '@mui/material/TableSortLabel';
|
70
|
-
import { useVirtualizer } from '@tanstack/react-virtual';
|
71
71
|
import TableBody from '@mui/material/TableBody';
|
72
72
|
import Skeleton from '@mui/material/Skeleton';
|
73
73
|
import TableFooter from '@mui/material/TableFooter';
|
@@ -1131,7 +1131,7 @@ const MRT_LinearProgressBar = ({ isTopToolbar, table }) => {
|
|
1131
1131
|
React.createElement(LinearProgress, Object.assign({ "aria-label": "Loading", "aria-busy": "true", sx: { position: 'relative' } }, linearProgressProps))));
|
1132
1132
|
};
|
1133
1133
|
|
1134
|
-
const MRT_TablePagination = ({ table, position, }) => {
|
1134
|
+
const MRT_TablePagination = ({ table, position = 'bottom', }) => {
|
1135
1135
|
const { getPrePaginationRowModel, getState, setPageIndex, setPageSize, options: { muiTablePaginationProps, enableToolbarInternalActions, localization, rowCount, }, } = table;
|
1136
1136
|
const { pagination: { pageSize = 10, pageIndex = 0 }, showGlobalFilter, } = getState();
|
1137
1137
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
|
@@ -1447,7 +1447,7 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
1447
1447
|
};
|
1448
1448
|
|
1449
1449
|
const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
1450
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
1450
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
1451
1451
|
const { options: { enableColumnFilterModes, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, manualFiltering, muiTableHeadCellFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
1452
1452
|
const { column } = header;
|
1453
1453
|
const { columnDef } = column;
|
@@ -1478,13 +1478,13 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1478
1478
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
1479
1479
|
: '';
|
1480
1480
|
const filterPlaceholder = !isRangeFilter
|
1481
|
-
? (_c = localization.filterByColumn) === null ||
|
1481
|
+
? (_c = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.placeholder) !== null && _c !== void 0 ? _c : (_d = localization.filterByColumn) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header))
|
1482
1482
|
: rangeFilterIndex === 0
|
1483
1483
|
? localization.min
|
1484
1484
|
: rangeFilterIndex === 1
|
1485
1485
|
? localization.max
|
1486
1486
|
: '';
|
1487
|
-
const allowedColumnFilterOptions = (
|
1487
|
+
const allowedColumnFilterOptions = (_e = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _e !== void 0 ? _e : columnFilterModeOptions;
|
1488
1488
|
const showChangeModeButton = enableColumnFilterModes &&
|
1489
1489
|
columnDef.enableColumnFilterModes !== false &&
|
1490
1490
|
!rangeFilterIndex &&
|
@@ -1554,7 +1554,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1554
1554
|
isMounted.current = true;
|
1555
1555
|
}, [column.getFilterValue()]);
|
1556
1556
|
if (columnDef.Filter) {
|
1557
|
-
return (React.createElement(React.Fragment, null, (
|
1557
|
+
return (React.createElement(React.Fragment, null, (_f = columnDef.Filter) === null || _f === void 0 ? void 0 : _f.call(columnDef, { column, header, rangeFilterIndex, table })));
|
1558
1558
|
}
|
1559
1559
|
return (React.createElement(React.Fragment, null,
|
1560
1560
|
React.createElement(TextField, Object.assign({ fullWidth: true, inputProps: {
|
@@ -1566,7 +1566,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1566
1566
|
title: filterPlaceholder,
|
1567
1567
|
}, helperText: showChangeModeButton ? (React.createElement("label", null, localization.filterMode.replace('{filterType}',
|
1568
1568
|
// @ts-ignore
|
1569
|
-
localization[`filter${((
|
1569
|
+
localization[`filter${((_g = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _g === void 0 ? void 0 : _g.toUpperCase()) +
|
1570
1570
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]))) : null, FormHelperTextProps: {
|
1571
1571
|
sx: {
|
1572
1572
|
fontSize: '0.75rem',
|
@@ -1583,7 +1583,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1583
1583
|
React.createElement(FilterListIcon, null)))),
|
1584
1584
|
filterChipLabel && (React.createElement(Chip, { onDelete: handleClearEmptyFilterChip, label: filterChipLabel })))) : null,
|
1585
1585
|
endAdornment: !filterChipLabel && (React.createElement(InputAdornment, { position: "end" },
|
1586
|
-
React.createElement(Tooltip, { arrow: true, placement: "right", title: (
|
1586
|
+
React.createElement(Tooltip, { arrow: true, placement: "right", title: (_h = localization.clearFilter) !== null && _h !== void 0 ? _h : '' },
|
1587
1587
|
React.createElement("span", null,
|
1588
1588
|
React.createElement(IconButton, { "aria-label": localization.clearFilter, disabled: !(filterValue === null || filterValue === void 0 ? void 0 : filterValue.length), onClick: handleClear, size: "small", sx: {
|
1589
1589
|
height: '1.75rem',
|
@@ -1620,8 +1620,8 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1620
1620
|
? textFieldProps.sx(theme)
|
1621
1621
|
: textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx))) }),
|
1622
1622
|
(isSelectFilter || isMultiSelectFilter) && (React.createElement(MenuItem, { divider: true, disabled: true, hidden: true, value: "" },
|
1623
|
-
React.createElement(Box, { sx: { opacity: 0.5 } }, filterPlaceholder))), (
|
1624
|
-
|
1623
|
+
React.createElement(Box, { sx: { opacity: 0.5 } }, filterPlaceholder))), (_j = columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterSelectOptions) === null || _j === void 0 ? void 0 :
|
1624
|
+
_j.map((option) => {
|
1625
1625
|
var _a;
|
1626
1626
|
let value;
|
1627
1627
|
let text;
|
@@ -1830,7 +1830,7 @@ const MRT_TableHeadCellSortLabel = ({ header, table, tableCellProps, }) => {
|
|
1830
1830
|
}, IconComponent: ArrowDownwardIcon })));
|
1831
1831
|
};
|
1832
1832
|
|
1833
|
-
const MRT_TableHeadCell = ({ header, table }) => {
|
1833
|
+
const MRT_TableHeadCell = ({ header, table, }) => {
|
1834
1834
|
var _a, _b, _c, _d;
|
1835
1835
|
const theme = useTheme();
|
1836
1836
|
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, layoutMode, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
@@ -1962,17 +1962,25 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
1962
1962
|
column.getCanFilter() && (React.createElement(MRT_TableHeadCellFilterContainer, { header: header, table: table }))));
|
1963
1963
|
};
|
1964
1964
|
|
1965
|
-
const MRT_TableHeadRow = ({ headerGroup, table }) => {
|
1965
|
+
const MRT_TableHeadRow = ({ headerGroup, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
1966
1966
|
const { options: { layoutMode, muiTableHeadRowProps }, } = table;
|
1967
1967
|
const tableRowProps = muiTableHeadRowProps instanceof Function
|
1968
1968
|
? muiTableHeadRowProps({ headerGroup, table })
|
1969
1969
|
: muiTableHeadRowProps;
|
1970
1970
|
return (React.createElement(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.04), boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`, display: layoutMode === 'grid' ? 'flex' : 'table-row', top: 0 }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
|
1971
1971
|
? tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx(theme)
|
1972
|
-
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))) }),
|
1972
|
+
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))) }),
|
1973
|
+
virtualPaddingLeft ? (React.createElement("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null,
|
1974
|
+
(virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : headerGroup.headers).map((headerOrVirtualHeader) => {
|
1975
|
+
const header = virtualColumns
|
1976
|
+
? headerGroup.headers[headerOrVirtualHeader.index]
|
1977
|
+
: headerOrVirtualHeader;
|
1978
|
+
return (React.createElement(MRT_TableHeadCell, { header: header, key: header.id, table: table }));
|
1979
|
+
}),
|
1980
|
+
virtualPaddingRight ? (React.createElement("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null));
|
1973
1981
|
};
|
1974
1982
|
|
1975
|
-
const MRT_TableHead = ({ table }) => {
|
1983
|
+
const MRT_TableHead = ({ table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
1976
1984
|
const { getHeaderGroups, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps }, } = table;
|
1977
1985
|
const { isFullScreen } = getState();
|
1978
1986
|
const tableHeadProps = muiTableHeadProps instanceof Function
|
@@ -1981,7 +1989,7 @@ const MRT_TableHead = ({ table }) => {
|
|
1981
1989
|
const stickyHeader = enableStickyHeader || isFullScreen;
|
1982
1990
|
return (React.createElement(TableHead, Object.assign({}, tableHeadProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', opacity: 0.97, position: stickyHeader ? 'sticky' : 'relative', top: stickyHeader && layoutMode === 'grid' ? 0 : undefined, zIndex: stickyHeader ? 2 : undefined }, ((tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx) instanceof Function
|
1983
1991
|
? tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx(theme)
|
1984
|
-
: tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx))) }), getHeaderGroups().map((headerGroup) => (React.createElement(MRT_TableHeadRow, { headerGroup: headerGroup, key: headerGroup.id, table: table })))));
|
1992
|
+
: tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx))) }), getHeaderGroups().map((headerGroup) => (React.createElement(MRT_TableHeadRow, { headerGroup: headerGroup, key: headerGroup.id, table: table, virtualColumns: virtualColumns, virtualPaddingLeft: virtualPaddingLeft, virtualPaddingRight: virtualPaddingRight })))));
|
1985
1993
|
};
|
1986
1994
|
|
1987
1995
|
const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
@@ -2120,7 +2128,7 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
2120
2128
|
: (_b = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) !== null && _b !== void 0 ? _b : cell.renderValue()));
|
2121
2129
|
};
|
2122
2130
|
|
2123
|
-
const MRT_TableBodyCell = ({ cell, enableHover, numRows, rowIndex, rowRef, table, }) => {
|
2131
|
+
const MRT_TableBodyCell = ({ cell, enableHover, measureElement, numRows, rowIndex, rowRef, table, virtualCell, }) => {
|
2124
2132
|
var _a, _b;
|
2125
2133
|
const theme = useTheme();
|
2126
2134
|
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enableRowNumbers, layoutMode, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
@@ -2192,7 +2200,11 @@ const MRT_TableBodyCell = ({ cell, enableHover, numRows, rowIndex, rowRef, table
|
|
2192
2200
|
setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
2193
2201
|
}
|
2194
2202
|
};
|
2195
|
-
return (React.createElement(TableCell, Object.assign({
|
2203
|
+
return (React.createElement(TableCell, Object.assign({ "data-index": virtualCell === null || virtualCell === void 0 ? void 0 : virtualCell.index, ref: (node) => {
|
2204
|
+
if (node) {
|
2205
|
+
measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
|
2206
|
+
}
|
2207
|
+
} }, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => (Object.assign(Object.assign({ alignItems: layoutMode === 'grid' ? 'center' : undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'inherit', overflow: 'hidden', p: density === 'compact'
|
2196
2208
|
? columnDefType === 'display'
|
2197
2209
|
? '0 0.5rem'
|
2198
2210
|
: '0.5rem'
|
@@ -2218,7 +2230,12 @@ const MRT_TableBodyCell = ({ cell, enableHover, numRows, rowIndex, rowRef, table
|
|
2218
2230
|
? `${lighten(theme.palette.background.default, 0.2)} !important`
|
2219
2231
|
: `${darken(theme.palette.background.default, 0.1)} !important`
|
2220
2232
|
: undefined,
|
2221
|
-
} }, getCommonCellStyles({
|
2233
|
+
} }, getCommonCellStyles({
|
2234
|
+
column,
|
2235
|
+
table,
|
2236
|
+
theme,
|
2237
|
+
tableCellProps,
|
2238
|
+
})), draggingBorders)) }),
|
2222
2239
|
React.createElement(React.Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React.createElement(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
|
2223
2240
|
rowNumberMode === 'static' &&
|
2224
2241
|
column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React.createElement(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
|
@@ -2260,7 +2277,7 @@ const MRT_TableDetailPanel = ({ parentRowRef, row, table, virtualRow, }) => {
|
|
2260
2277
|
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }), renderDetailPanel && (React.createElement(Collapse, { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true }, !isLoading && renderDetailPanel({ row, table }))))));
|
2261
2278
|
};
|
2262
2279
|
|
2263
|
-
const MRT_TableBodyRow = ({ measureElement, numRows, row, rowIndex, table, virtualRow, }) => {
|
2280
|
+
const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, rowIndex, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, virtualRow, }) => {
|
2264
2281
|
const theme = useTheme();
|
2265
2282
|
const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, }, setHoveredRow, } = table;
|
2266
2283
|
const { draggingColumn, draggingRow, editingCell, editingRow, hoveredRow } = getState();
|
@@ -2299,37 +2316,50 @@ const MRT_TableBodyRow = ({ measureElement, numRows, row, rowIndex, table, virtu
|
|
2299
2316
|
: undefined,
|
2300
2317
|
} }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
|
2301
2318
|
? tableRowProps.sx(theme)
|
2302
|
-
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)), draggingBorders)) }),
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
+
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)), draggingBorders)) }),
|
2320
|
+
virtualPaddingLeft ? (React.createElement("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null,
|
2321
|
+
(virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : row.getVisibleCells()).map((cellOrVirtualCell) => {
|
2322
|
+
const cell = columnVirtualizer
|
2323
|
+
? row.getVisibleCells()[cellOrVirtualCell.index]
|
2324
|
+
: cellOrVirtualCell;
|
2325
|
+
const props = {
|
2326
|
+
cell,
|
2327
|
+
enableHover: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false,
|
2328
|
+
key: cell.id,
|
2329
|
+
measureElement: columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement,
|
2330
|
+
numRows,
|
2331
|
+
rowIndex,
|
2332
|
+
rowRef,
|
2333
|
+
table,
|
2334
|
+
virtualCell: columnVirtualizer
|
2335
|
+
? cellOrVirtualCell
|
2336
|
+
: undefined,
|
2337
|
+
};
|
2338
|
+
return memoMode === 'cells' &&
|
2339
|
+
cell.column.columnDef.columnDefType === 'data' &&
|
2340
|
+
!draggingColumn &&
|
2341
|
+
!draggingRow &&
|
2342
|
+
(editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
|
2343
|
+
(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)));
|
2344
|
+
}),
|
2345
|
+
virtualPaddingRight ? (React.createElement("td", { style: { display: 'flex', width: virtualPaddingRight } })) : null),
|
2319
2346
|
renderDetailPanel && !row.getIsGrouped() && (React.createElement(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, table: table, virtualRow: virtualRow }))));
|
2320
2347
|
};
|
2321
2348
|
const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row);
|
2322
2349
|
|
2323
|
-
const MRT_TableBody = ({ table }) => {
|
2350
|
+
const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
2324
2351
|
var _a, _b, _c;
|
2325
|
-
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, layoutMode, localization, manualFiltering, manualSorting, memoMode, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
|
2352
|
+
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, layoutMode, localization, manualFiltering, manualSorting, memoMode, muiTableBodyProps, rowVirtualizerInstanceRef, rowVirtualizerProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
|
2326
2353
|
const { columnFilters, density, globalFilter, pagination, sorting } = getState();
|
2327
2354
|
const tableBodyProps = muiTableBodyProps instanceof Function
|
2328
2355
|
? muiTableBodyProps({ table })
|
2329
2356
|
: muiTableBodyProps;
|
2330
|
-
const
|
2357
|
+
const vProps_old = virtualizerProps instanceof Function
|
2331
2358
|
? virtualizerProps({ table })
|
2332
2359
|
: virtualizerProps;
|
2360
|
+
const vProps = rowVirtualizerProps instanceof Function
|
2361
|
+
? rowVirtualizerProps({ table })
|
2362
|
+
: rowVirtualizerProps;
|
2333
2363
|
const rows = useMemo(() => {
|
2334
2364
|
if (enableGlobalFilterRankedResults &&
|
2335
2365
|
globalFilter &&
|
@@ -2355,14 +2385,22 @@ const MRT_TableBody = ({ table }) => {
|
|
2355
2385
|
pagination.pageIndex,
|
2356
2386
|
pagination.pageSize,
|
2357
2387
|
]);
|
2358
|
-
const
|
2359
|
-
? useVirtualizer(Object.assign({ count: rows.length, estimateSize: () => density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73, getScrollElement: () => tableContainerRef.current, measureElement: (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height, overscan: 4 }, vProps))
|
2388
|
+
const rowVirtualizer = enableRowVirtualization
|
2389
|
+
? useVirtualizer(Object.assign(Object.assign({ count: rows.length, estimateSize: () => density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73, getScrollElement: () => tableContainerRef.current, measureElement: (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height, overscan: 4 }, vProps_old), vProps))
|
2360
2390
|
: undefined;
|
2361
|
-
if (
|
2362
|
-
|
2391
|
+
if (rowVirtualizerInstanceRef && rowVirtualizer) {
|
2392
|
+
rowVirtualizerInstanceRef.current = rowVirtualizer;
|
2393
|
+
}
|
2394
|
+
//deprecated
|
2395
|
+
if (virtualizerInstanceRef && rowVirtualizer) {
|
2396
|
+
virtualizerInstanceRef.current = rowVirtualizer;
|
2363
2397
|
}
|
2364
|
-
const virtualRows =
|
2365
|
-
|
2398
|
+
const virtualRows = rowVirtualizer
|
2399
|
+
? rowVirtualizer.getVirtualItems()
|
2400
|
+
: undefined;
|
2401
|
+
return (React.createElement(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', height: rowVirtualizer
|
2402
|
+
? `${rowVirtualizer.getTotalSize()}px`
|
2403
|
+
: 'inherit', minHeight: !rows.length ? '100px' : undefined, position: 'relative' }, ((tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx) instanceof Function
|
2366
2404
|
? tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx(theme)
|
2367
2405
|
: 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' } },
|
2368
2406
|
React.createElement("td", { colSpan: table.getVisibleLeafColumns().length, style: { display: layoutMode === 'grid' ? 'grid' : 'table-cell' } },
|
@@ -2376,19 +2414,21 @@ const MRT_TableBody = ({ table }) => {
|
|
2376
2414
|
} }, globalFilter || columnFilters.length
|
2377
2415
|
? localization.noResultsFound
|
2378
2416
|
: localization.noRecordsToDisplay)))) : (React.createElement(React.Fragment, null, (virtualRows !== null && virtualRows !== void 0 ? virtualRows : rows).map((rowOrVirtualRow, rowIndex) => {
|
2379
|
-
const row =
|
2417
|
+
const row = rowVirtualizer
|
2380
2418
|
? rows[rowOrVirtualRow.index]
|
2381
2419
|
: rowOrVirtualRow;
|
2382
2420
|
const props = {
|
2421
|
+
columnVirtualizer,
|
2383
2422
|
key: row.id,
|
2384
|
-
measureElement:
|
2385
|
-
? virtualizer.measureElement
|
2386
|
-
: undefined,
|
2423
|
+
measureElement: rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement,
|
2387
2424
|
numRows: rows.length,
|
2388
2425
|
row,
|
2389
|
-
rowIndex:
|
2426
|
+
rowIndex: rowVirtualizer ? rowOrVirtualRow.index : rowIndex,
|
2390
2427
|
table,
|
2391
|
-
|
2428
|
+
virtualColumns,
|
2429
|
+
virtualPaddingLeft,
|
2430
|
+
virtualPaddingRight,
|
2431
|
+
virtualRow: rowVirtualizer
|
2392
2432
|
? rowOrVirtualRow
|
2393
2433
|
: undefined,
|
2394
2434
|
};
|
@@ -2397,7 +2437,7 @@ const MRT_TableBody = ({ table }) => {
|
|
2397
2437
|
};
|
2398
2438
|
const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
|
2399
2439
|
|
2400
|
-
const MRT_TableFooterCell = ({ footer, table }) => {
|
2440
|
+
const MRT_TableFooterCell = ({ footer, table, }) => {
|
2401
2441
|
var _a, _b, _c;
|
2402
2442
|
const { getState, options: { layoutMode, muiTableFooterCellProps }, } = table;
|
2403
2443
|
const { density } = getState();
|
@@ -2415,7 +2455,12 @@ const MRT_TableFooterCell = ({ footer, table }) => {
|
|
2415
2455
|
? '0.5rem'
|
2416
2456
|
: density === 'comfortable'
|
2417
2457
|
? '1rem'
|
2418
|
-
: '1.5rem', verticalAlign: 'top', zIndex: column.getIsPinned() && columnDefType !== 'group' ? 2 : 1 }, getCommonCellStyles({
|
2458
|
+
: '1.5rem', verticalAlign: 'top', zIndex: column.getIsPinned() && columnDefType !== 'group' ? 2 : 1 }, getCommonCellStyles({
|
2459
|
+
column,
|
2460
|
+
table,
|
2461
|
+
theme,
|
2462
|
+
tableCellProps,
|
2463
|
+
}))) }),
|
2419
2464
|
React.createElement(React.Fragment, null, footer.isPlaceholder
|
2420
2465
|
? null
|
2421
2466
|
: (_c = (_b = (columnDef.Footer instanceof Function
|
@@ -2427,7 +2472,7 @@ const MRT_TableFooterCell = ({ footer, table }) => {
|
|
2427
2472
|
: columnDef.Footer)) !== null && _b !== void 0 ? _b : columnDef.footer) !== null && _c !== void 0 ? _c : null)));
|
2428
2473
|
};
|
2429
2474
|
|
2430
|
-
const MRT_TableFooterRow = ({ footerGroup, table }) => {
|
2475
|
+
const MRT_TableFooterRow = ({ footerGroup, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
2431
2476
|
var _a;
|
2432
2477
|
const { options: { layoutMode, muiTableFooterRowProps }, } = table;
|
2433
2478
|
// if no content in row, skip row
|
@@ -2438,12 +2483,20 @@ const MRT_TableFooterRow = ({ footerGroup, table }) => {
|
|
2438
2483
|
const tableRowProps = muiTableFooterRowProps instanceof Function
|
2439
2484
|
? muiTableFooterRowProps({ footerGroup, table })
|
2440
2485
|
: muiTableFooterRowProps;
|
2441
|
-
return (React.createElement(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'flex' : 'table-row' }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
|
2486
|
+
return (React.createElement(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'flex' : 'table-row', width: '100%' }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
|
2442
2487
|
? tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx(theme)
|
2443
|
-
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))) }),
|
2488
|
+
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))) }),
|
2489
|
+
virtualPaddingLeft ? (React.createElement("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null,
|
2490
|
+
(virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter) => {
|
2491
|
+
const footer = virtualColumns
|
2492
|
+
? footerGroup.headers[footerOrVirtualFooter.index]
|
2493
|
+
: footerOrVirtualFooter;
|
2494
|
+
return (React.createElement(MRT_TableFooterCell, { footer: footer, key: footer.id, table: table }));
|
2495
|
+
}),
|
2496
|
+
virtualPaddingRight ? (React.createElement("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null));
|
2444
2497
|
};
|
2445
2498
|
|
2446
|
-
const MRT_TableFooter = ({ table }) => {
|
2499
|
+
const MRT_TableFooter = ({ table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
2447
2500
|
const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, } = table;
|
2448
2501
|
const { isFullScreen } = getState();
|
2449
2502
|
const tableFooterProps = muiTableFooterProps instanceof Function
|
@@ -2456,21 +2509,74 @@ const MRT_TableFooter = ({ table }) => {
|
|
2456
2509
|
: `1px solid ${theme.palette.grey[700]}`
|
2457
2510
|
: undefined, position: stickFooter ? 'sticky' : undefined }, ((tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx) instanceof Function
|
2458
2511
|
? tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx(theme)
|
2459
|
-
: tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx))) }), getFooterGroups().map((footerGroup) => (React.createElement(MRT_TableFooterRow, { footerGroup: footerGroup, key: footerGroup.id, table: table })))));
|
2512
|
+
: tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx))) }), getFooterGroups().map((footerGroup) => (React.createElement(MRT_TableFooterRow, { footerGroup: footerGroup, key: footerGroup.id, table: table, virtualColumns: virtualColumns, virtualPaddingLeft: virtualPaddingLeft, virtualPaddingRight: virtualPaddingRight })))));
|
2460
2513
|
};
|
2461
2514
|
|
2462
2515
|
const MRT_Table = ({ table }) => {
|
2463
|
-
|
2464
|
-
const {
|
2516
|
+
var _a, _b;
|
2517
|
+
const { getState, options: { columnVirtualizerInstanceRef, columnVirtualizerProps, enableColumnResizing, enableColumnVirtualization, enablePinning, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, refs: { tableContainerRef }, } = table;
|
2518
|
+
const { isFullScreen, columnPinning, columnVisibility } = getState();
|
2465
2519
|
const tableProps = muiTableProps instanceof Function
|
2466
2520
|
? muiTableProps({ table })
|
2467
2521
|
: muiTableProps;
|
2468
|
-
|
2522
|
+
const vProps = columnVirtualizerProps instanceof Function
|
2523
|
+
? columnVirtualizerProps({ table })
|
2524
|
+
: columnVirtualizerProps;
|
2525
|
+
//get first 16 column widths and average them
|
2526
|
+
const averageColumnWidth = useMemo(() => {
|
2527
|
+
var _a, _b, _c, _d;
|
2528
|
+
const columnsWidths = (_d = (_c = (_b = (_a = table
|
2529
|
+
.getRowModel()
|
2530
|
+
.rows[0]) === null || _a === void 0 ? void 0 : _a.getCenterVisibleCells()) === null || _b === void 0 ? void 0 : _b.slice(0, 16)) === null || _c === void 0 ? void 0 : _c.map((cell) => cell.column.getSize() * 1.25)) !== null && _d !== void 0 ? _d : [];
|
2531
|
+
return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
|
2532
|
+
}, [table.getRowModel().rows, columnPinning, columnVisibility]);
|
2533
|
+
const pinnedColumnIndexes = useMemo(() => enableColumnVirtualization && enablePinning
|
2534
|
+
? [
|
2535
|
+
...table.getLeftFlatHeaders().map((h) => h.column.getPinnedIndex()),
|
2536
|
+
...table
|
2537
|
+
.getRightFlatHeaders()
|
2538
|
+
.map((h) => table.getVisibleFlatColumns().length -
|
2539
|
+
h.column.getPinnedIndex() -
|
2540
|
+
1),
|
2541
|
+
]
|
2542
|
+
: [], [columnPinning, enableColumnVirtualization, enablePinning]);
|
2543
|
+
const columnVirtualizer = enableColumnVirtualization
|
2544
|
+
? useVirtualizer(Object.assign({ count: table.getRowModel().rows[0].getVisibleCells().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, measureElement: (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().width, overscan: 3, rangeExtractor: useCallback((range) => [
|
2545
|
+
...new Set([
|
2546
|
+
...pinnedColumnIndexes,
|
2547
|
+
...defaultRangeExtractor(range),
|
2548
|
+
]),
|
2549
|
+
].sort((a, b) => a - b), [pinnedColumnIndexes]) }, vProps))
|
2550
|
+
: undefined;
|
2551
|
+
if (columnVirtualizerInstanceRef && columnVirtualizer) {
|
2552
|
+
columnVirtualizerInstanceRef.current = columnVirtualizer;
|
2553
|
+
}
|
2554
|
+
const virtualColumns = columnVirtualizer
|
2555
|
+
? columnVirtualizer.getVirtualItems()
|
2556
|
+
: undefined;
|
2557
|
+
let virtualPaddingLeft;
|
2558
|
+
let virtualPaddingRight;
|
2559
|
+
if (columnVirtualizer && (virtualColumns === null || virtualColumns === void 0 ? void 0 : virtualColumns.length)) {
|
2560
|
+
virtualPaddingLeft = (virtualColumns === null || virtualColumns === void 0 ? void 0 : virtualColumns.length)
|
2561
|
+
? ((_a = virtualColumns[0]) === null || _a === void 0 ? void 0 : _a.start) || 0
|
2562
|
+
: 0;
|
2563
|
+
virtualPaddingRight = (virtualColumns === null || virtualColumns === void 0 ? void 0 : virtualColumns.length)
|
2564
|
+
? columnVirtualizer.getTotalSize() -
|
2565
|
+
(((_b = virtualColumns[virtualColumns.length - 1]) === null || _b === void 0 ? void 0 : _b.end) || 0)
|
2566
|
+
: 0;
|
2567
|
+
}
|
2568
|
+
const props = {
|
2569
|
+
table,
|
2570
|
+
virtualColumns,
|
2571
|
+
virtualPaddingLeft,
|
2572
|
+
virtualPaddingRight,
|
2573
|
+
};
|
2574
|
+
return (React.createElement(Table, Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table', tableLayout: layoutMode !== 'grid' && enableColumnResizing ? 'fixed' : undefined }, ((tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx) instanceof Function
|
2469
2575
|
? tableProps.sx(theme)
|
2470
2576
|
: tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))) }),
|
2471
|
-
enableTableHead && React.createElement(MRT_TableHead, {
|
2472
|
-
memoMode === 'table-body' ? (React.createElement(Memo_MRT_TableBody, {
|
2473
|
-
enableTableFooter && React.createElement(MRT_TableFooter, {
|
2577
|
+
enableTableHead && React.createElement(MRT_TableHead, Object.assign({}, props)),
|
2578
|
+
memoMode === 'table-body' ? (React.createElement(Memo_MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))) : (React.createElement(MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))),
|
2579
|
+
enableTableFooter && React.createElement(MRT_TableFooter, Object.assign({}, props))));
|
2474
2580
|
};
|
2475
2581
|
|
2476
2582
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
@@ -2825,7 +2931,7 @@ const MaterialReactTable = (_a) => {
|
|
2825
2931
|
const _sortingFns = useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
|
2826
2932
|
const _defaultColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), []);
|
2827
2933
|
const _defaultDisplayColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), []);
|
2828
|
-
if (rest.enableRowVirtualization) {
|
2934
|
+
if (rest.enableRowVirtualization || rest.enableColumnVirtualization) {
|
2829
2935
|
layoutMode = 'grid';
|
2830
2936
|
enableStickyHeader = true;
|
2831
2937
|
}
|