material-react-table 0.27.0 → 0.28.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/MaterialReactTable.d.ts +2 -2
- package/dist/material-react-table.cjs.development.js +12 -8
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +12 -8
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/MaterialReactTable.tsx +4 -2
- package/src/body/MRT_TableBody.tsx +12 -12
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.28.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
|
|
@@ -101,6 +101,6 @@
|
|
|
101
101
|
"dependencies": {
|
|
102
102
|
"@tanstack/match-sorter-utils": "8.1.1",
|
|
103
103
|
"@tanstack/react-table": "8.2.6",
|
|
104
|
-
"react-virtual": "^
|
|
104
|
+
"@tanstack/react-virtual": "^3.0.0-beta.13"
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -40,7 +40,7 @@ import type {
|
|
|
40
40
|
TableOptions,
|
|
41
41
|
TableState,
|
|
42
42
|
} from '@tanstack/react-table';
|
|
43
|
-
import type {
|
|
43
|
+
import type { VirtualizerOptions } from '@tanstack/react-virtual';
|
|
44
44
|
import { MRT_Localization, MRT_DefaultLocalization_EN } from './localization';
|
|
45
45
|
import { MRT_Default_Icons, MRT_Icons } from './icons';
|
|
46
46
|
import { MRT_TableRoot } from './table/MRT_TableRoot';
|
|
@@ -779,7 +779,9 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
779
779
|
selectAllMode?: 'all' | 'page';
|
|
780
780
|
state?: Partial<MRT_TableState<TData>>;
|
|
781
781
|
tableId?: string;
|
|
782
|
-
virtualizerProps?: Partial<
|
|
782
|
+
virtualizerProps?: Partial<
|
|
783
|
+
VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>
|
|
784
|
+
>;
|
|
783
785
|
};
|
|
784
786
|
|
|
785
787
|
export default <TData extends Record<string, any> = {}>({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC, RefObject, useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useVirtualizer, Virtualizer } from '@tanstack/react-virtual';
|
|
3
3
|
import { TableBody } from '@mui/material';
|
|
4
4
|
import { MRT_TableBodyRow } from './MRT_TableBodyRow';
|
|
5
5
|
import { rankGlobalFuzzy } from '../sortingFns';
|
|
@@ -60,28 +60,27 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
60
60
|
globalFilter,
|
|
61
61
|
]);
|
|
62
62
|
|
|
63
|
-
const rowVirtualizer = enableRowVirtualization
|
|
64
|
-
?
|
|
65
|
-
|
|
63
|
+
const rowVirtualizer: Virtualizer = enableRowVirtualization
|
|
64
|
+
? useVirtualizer({
|
|
65
|
+
estimateSize: () => (density === 'compact' ? 25 : 50),
|
|
66
66
|
overscan: density === 'compact' ? 30 : 10,
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
getScrollElement: () => tableContainerRef.current as HTMLDivElement,
|
|
68
|
+
count: rows.length,
|
|
69
69
|
...virtualizerProps,
|
|
70
70
|
})
|
|
71
71
|
: ({} as any);
|
|
72
72
|
|
|
73
73
|
const virtualRows = enableRowVirtualization
|
|
74
|
-
? rowVirtualizer.
|
|
74
|
+
? rowVirtualizer.getVirtualItems()
|
|
75
75
|
: [];
|
|
76
76
|
|
|
77
77
|
let paddingTop = 0;
|
|
78
78
|
let paddingBottom = 0;
|
|
79
79
|
if (enableRowVirtualization) {
|
|
80
|
-
paddingTop = virtualRows.length
|
|
81
|
-
paddingBottom =
|
|
82
|
-
virtualRows.length
|
|
83
|
-
|
|
84
|
-
: 0;
|
|
80
|
+
paddingTop = !!virtualRows.length ? virtualRows[0].start : 0;
|
|
81
|
+
paddingBottom = !!virtualRows.length
|
|
82
|
+
? rowVirtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end
|
|
83
|
+
: 0;
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
return (
|
|
@@ -91,6 +90,7 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
91
90
|
<td style={{ height: `${paddingTop}px` }} />
|
|
92
91
|
</tr>
|
|
93
92
|
)}
|
|
93
|
+
{/* @ts-ignore */}
|
|
94
94
|
{(enableRowVirtualization ? virtualRows : rows).map(
|
|
95
95
|
(rowOrVirtualRow: any, rowIndex: number) => {
|
|
96
96
|
const row = enableRowVirtualization
|