material-react-table 1.4.3 → 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 +167 -61
- 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 +163 -57
- 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 +1 -1
- 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/table/MRT_Table.tsx +105 -7
- package/src/toolbar/MRT_TablePagination.tsx +2 -2
@@ -442,6 +442,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> = Om
|
|
442
442
|
enableColumnDragging?: boolean;
|
443
443
|
enableColumnFilterModes?: boolean;
|
444
444
|
enableColumnOrdering?: boolean;
|
445
|
+
enableColumnVirtualization?: boolean;
|
445
446
|
enableDensityToggle?: boolean;
|
446
447
|
enableEditing?: boolean;
|
447
448
|
enableExpandAll?: boolean;
|
@@ -637,8 +638,8 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> = Om
|
|
637
638
|
onShowGlobalFilterChange?: OnChangeFn<boolean>;
|
638
639
|
positionActionsColumn?: 'first' | 'last';
|
639
640
|
positionExpandColumn?: 'first' | 'last';
|
640
|
-
positionGlobalFilter?: 'left' | 'right';
|
641
|
-
positionPagination?: 'bottom' | 'top' | 'both';
|
641
|
+
positionGlobalFilter?: 'left' | 'right' | 'none';
|
642
|
+
positionPagination?: 'bottom' | 'top' | 'both' | 'none';
|
642
643
|
positionToolbarAlertBanner?: 'bottom' | 'top' | 'none';
|
643
644
|
positionToolbarDropZone?: 'bottom' | 'top' | 'none' | 'both';
|
644
645
|
renderBottomToolbar?: ReactNode | (({ table }: {
|
@@ -690,11 +691,23 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> = Om
|
|
690
691
|
rowNumberMode?: 'original' | 'static';
|
691
692
|
selectAllMode?: 'all' | 'page';
|
692
693
|
state?: Partial<MRT_TableState<TData>>;
|
693
|
-
|
694
|
-
|
694
|
+
columnVirtualizerInstanceRef?: MutableRefObject<Virtualizer<HTMLDivElement, HTMLTableCellElement> | null>;
|
695
|
+
columnVirtualizerProps?: Partial<VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>> | (({ table, }: {
|
696
|
+
table: MRT_TableInstance<TData>;
|
697
|
+
}) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>>);
|
698
|
+
rowVirtualizerInstanceRef?: MutableRefObject<Virtualizer<HTMLDivElement, HTMLTableRowElement> | null>;
|
699
|
+
rowVirtualizerProps?: Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>> | (({ table, }: {
|
695
700
|
table: MRT_TableInstance<TData>;
|
696
701
|
}) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>);
|
697
|
-
|
702
|
+
tableInstanceRef?: MutableRefObject<MRT_TableInstance<TData> | null>;
|
703
|
+
/**
|
704
|
+
* @deprecated Use `rowVirtualizerInstanceRef` instead
|
705
|
+
*/
|
706
|
+
virtualizerInstanceRef?: any;
|
707
|
+
/**
|
708
|
+
* @deprecated Use `rowVirtualizerProps` instead
|
709
|
+
*/
|
710
|
+
virtualizerProps?: any;
|
698
711
|
};
|
699
712
|
declare const MaterialReactTable: <TData extends Record<string, any> = {}>({ aggregationFns, autoResetExpanded, columnResizeMode, defaultColumn, defaultDisplayColumn, editingMode, enableBottomToolbar, enableColumnActions, enableColumnFilters, enableColumnOrdering, enableColumnResizing, enableDensityToggle, enableExpandAll, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableGlobalFilterRankedResults, enableGrouping, enableHiding, enableMultiRowSelection, enableMultiSort, enablePagination, enablePinning, enableRowSelection, enableSelectAll, enableSorting, enableStickyHeader, enableTableFooter, enableTableHead, enableToolbarInternalActions, enableTopToolbar, filterFns, icons, layoutMode, localization, positionActionsColumn, positionExpandColumn, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, rowNumberMode, selectAllMode, sortingFns, ...rest }: MaterialReactTableProps<TData>) => JSX.Element;
|
700
713
|
export default MaterialReactTable;
|
@@ -1,7 +1,12 @@
|
|
1
1
|
import React, { FC } from 'react';
|
2
|
+
import { Virtualizer, VirtualItem } from '@tanstack/react-virtual';
|
2
3
|
import type { MRT_TableInstance } from '..';
|
3
4
|
interface Props {
|
5
|
+
columnVirtualizer?: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
4
6
|
table: MRT_TableInstance;
|
7
|
+
virtualColumns?: VirtualItem[];
|
8
|
+
virtualPaddingLeft?: number;
|
9
|
+
virtualPaddingRight?: number;
|
5
10
|
}
|
6
11
|
export declare const MRT_TableBody: FC<Props>;
|
7
12
|
export declare const Memo_MRT_TableBody: React.NamedExoticComponent<Props>;
|
@@ -1,12 +1,15 @@
|
|
1
1
|
import React, { FC, RefObject } from 'react';
|
2
|
+
import type { VirtualItem } from '@tanstack/react-virtual';
|
2
3
|
import type { MRT_Cell, MRT_TableInstance } from '..';
|
3
4
|
interface Props {
|
4
5
|
cell: MRT_Cell;
|
5
6
|
enableHover?: boolean;
|
7
|
+
measureElement?: (element: HTMLTableCellElement) => void;
|
6
8
|
numRows: number;
|
7
9
|
rowIndex: number;
|
8
10
|
rowRef: RefObject<HTMLTableRowElement>;
|
9
11
|
table: MRT_TableInstance;
|
12
|
+
virtualCell?: VirtualItem;
|
10
13
|
}
|
11
14
|
export declare const MRT_TableBodyCell: FC<Props>;
|
12
15
|
export declare const Memo_MRT_TableBodyCell: React.NamedExoticComponent<Props>;
|
@@ -1,12 +1,16 @@
|
|
1
1
|
import React, { FC } from 'react';
|
2
|
-
import type { VirtualItem } from '@tanstack/react-virtual';
|
2
|
+
import type { VirtualItem, Virtualizer } from '@tanstack/react-virtual';
|
3
3
|
import type { MRT_Row, MRT_TableInstance } from '..';
|
4
4
|
interface Props {
|
5
|
+
columnVirtualizer?: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
5
6
|
measureElement?: (element: HTMLTableRowElement) => void;
|
6
7
|
numRows: number;
|
7
8
|
row: MRT_Row;
|
8
9
|
rowIndex: number;
|
9
10
|
table: MRT_TableInstance;
|
11
|
+
virtualColumns?: VirtualItem[];
|
12
|
+
virtualPaddingLeft?: number;
|
13
|
+
virtualPaddingRight?: number;
|
10
14
|
virtualRow?: VirtualItem;
|
11
15
|
}
|
12
16
|
export declare const MRT_TableBodyRow: FC<Props>;
|
@@ -1,7 +1,11 @@
|
|
1
1
|
import { FC } from 'react';
|
2
|
+
import type { VirtualItem } from '@tanstack/react-virtual';
|
2
3
|
import type { MRT_TableInstance } from '..';
|
3
4
|
interface Props {
|
4
5
|
table: MRT_TableInstance;
|
6
|
+
virtualColumns?: VirtualItem[];
|
7
|
+
virtualPaddingLeft?: number;
|
8
|
+
virtualPaddingRight?: number;
|
5
9
|
}
|
6
10
|
export declare const MRT_TableFooter: FC<Props>;
|
7
11
|
export {};
|
@@ -1,8 +1,12 @@
|
|
1
1
|
import { FC } from 'react';
|
2
|
+
import { VirtualItem } from '@tanstack/react-virtual';
|
2
3
|
import type { MRT_HeaderGroup, MRT_TableInstance } from '..';
|
3
4
|
interface Props {
|
4
5
|
footerGroup: MRT_HeaderGroup;
|
5
6
|
table: MRT_TableInstance;
|
7
|
+
virtualColumns?: VirtualItem[];
|
8
|
+
virtualPaddingLeft?: number;
|
9
|
+
virtualPaddingRight?: number;
|
6
10
|
}
|
7
11
|
export declare const MRT_TableFooterRow: FC<Props>;
|
8
12
|
export {};
|
@@ -1,7 +1,11 @@
|
|
1
1
|
import { FC } from 'react';
|
2
|
+
import type { VirtualItem } from '@tanstack/react-virtual';
|
2
3
|
import type { MRT_TableInstance } from '..';
|
3
4
|
interface Props {
|
4
5
|
table: MRT_TableInstance;
|
6
|
+
virtualColumns?: VirtualItem[];
|
7
|
+
virtualPaddingLeft?: number;
|
8
|
+
virtualPaddingRight?: number;
|
5
9
|
}
|
6
10
|
export declare const MRT_TableHead: FC<Props>;
|
7
11
|
export {};
|
@@ -1,8 +1,12 @@
|
|
1
1
|
import { FC } from 'react';
|
2
|
+
import type { VirtualItem } from '@tanstack/react-virtual';
|
2
3
|
import type { MRT_HeaderGroup, MRT_TableInstance } from '..';
|
3
4
|
interface Props {
|
4
5
|
headerGroup: MRT_HeaderGroup;
|
5
6
|
table: MRT_TableInstance;
|
7
|
+
virtualColumns?: VirtualItem[];
|
8
|
+
virtualPaddingLeft?: number;
|
9
|
+
virtualPaddingRight?: number;
|
6
10
|
}
|
7
11
|
export declare const MRT_TableHeadRow: FC<Props>;
|
8
12
|
export {};
|
@@ -20,6 +20,7 @@ export declare const MRT_TableRoot: <TData extends Record<string, any> = {}>(pro
|
|
20
20
|
enableColumnDragging?: boolean | undefined;
|
21
21
|
enableColumnFilterModes?: boolean | undefined;
|
22
22
|
enableColumnOrdering?: boolean | undefined;
|
23
|
+
enableColumnVirtualization?: boolean | undefined;
|
23
24
|
enableDensityToggle?: boolean | undefined;
|
24
25
|
enableEditing?: boolean | undefined;
|
25
26
|
enableExpandAll?: boolean | undefined;
|
@@ -200,8 +201,8 @@ export declare const MRT_TableRoot: <TData extends Record<string, any> = {}>(pro
|
|
200
201
|
onShowGlobalFilterChange?: import("@tanstack/react-table").OnChangeFn<boolean> | undefined;
|
201
202
|
positionActionsColumn?: "first" | "last" | undefined;
|
202
203
|
positionExpandColumn?: "first" | "last" | undefined;
|
203
|
-
positionGlobalFilter?: "left" | "right" | undefined;
|
204
|
-
positionPagination?: "bottom" | "top" | "both" | undefined;
|
204
|
+
positionGlobalFilter?: "left" | "right" | "none" | undefined;
|
205
|
+
positionPagination?: "bottom" | "top" | "none" | "both" | undefined;
|
205
206
|
positionToolbarAlertBanner?: "bottom" | "top" | "none" | undefined;
|
206
207
|
positionToolbarDropZone?: "bottom" | "top" | "none" | "both" | undefined;
|
207
208
|
renderBottomToolbar?: React.ReactNode | (({ table }: {
|
@@ -253,11 +254,17 @@ export declare const MRT_TableRoot: <TData extends Record<string, any> = {}>(pro
|
|
253
254
|
rowNumberMode?: "original" | "static" | undefined;
|
254
255
|
selectAllMode?: "all" | "page" | undefined;
|
255
256
|
state?: Partial<MRT_TableState<TData>> | undefined;
|
256
|
-
|
257
|
-
|
257
|
+
columnVirtualizerInstanceRef?: React.MutableRefObject<import("@tanstack/react-virtual").Virtualizer<HTMLDivElement, HTMLTableCellElement> | null> | undefined;
|
258
|
+
columnVirtualizerProps?: Partial<import("@tanstack/react-virtual").VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>> | (({ table, }: {
|
259
|
+
table: MRT_TableInstance<TData>;
|
260
|
+
}) => Partial<import("@tanstack/react-virtual").VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>>) | undefined;
|
261
|
+
rowVirtualizerInstanceRef?: React.MutableRefObject<import("@tanstack/react-virtual").Virtualizer<HTMLDivElement, HTMLTableRowElement> | null> | undefined;
|
262
|
+
rowVirtualizerProps?: Partial<import("@tanstack/react-virtual").VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>> | (({ table, }: {
|
258
263
|
table: MRT_TableInstance<TData>;
|
259
264
|
}) => Partial<import("@tanstack/react-virtual").VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>) | undefined;
|
260
|
-
|
265
|
+
tableInstanceRef?: React.MutableRefObject<MRT_TableInstance<TData> | null> | undefined;
|
266
|
+
virtualizerInstanceRef?: any;
|
267
|
+
virtualizerProps?: any;
|
261
268
|
} & {
|
262
269
|
localization: MRT_Localization;
|
263
270
|
}) => JSX.Element;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { MRT_TableInstance } from '..';
|
3
3
|
interface Props<TData extends Record<string, any> = {}> {
|
4
|
-
position
|
4
|
+
position?: 'top' | 'bottom';
|
5
5
|
table: MRT_TableInstance<TData>;
|
6
6
|
}
|
7
7
|
export declare const MRT_TablePagination: <TData extends Record<string, any> = {}>({ table, position, }: Props<TData>) => JSX.Element;
|
@@ -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;
|
@@ -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
|
}
|