material-react-table 0.20.0 → 0.21.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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.20.0",
2
+ "version": "0.21.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.",
@@ -99,8 +99,8 @@
99
99
  "dependencies": {
100
100
  "@tanstack/match-sorter-utils": "8.1.1",
101
101
  "@tanstack/react-table": "8.1.3",
102
- "@tanstack/react-virtual": "^3.0.0-beta.2",
103
102
  "react-dnd": "^16.0.1",
104
- "react-dnd-html5-backend": "^16.0.1"
103
+ "react-dnd-html5-backend": "^16.0.1",
104
+ "react-virtual": "^2.10.4"
105
105
  }
106
106
  }
@@ -39,7 +39,7 @@ import {
39
39
  TableOptions,
40
40
  TableState,
41
41
  } from '@tanstack/react-table';
42
- // import type { VirtualizerOptions } from '@tanstack/react-virtual';
42
+ import { Options as VirtualizerOptions } from 'react-virtual';
43
43
  import { MRT_Localization, MRT_DefaultLocalization_EN } from './localization';
44
44
  import { MRT_Default_Icons, MRT_Icons } from './icons';
45
45
  import { MRT_TableRoot } from './table/MRT_TableRoot';
@@ -685,7 +685,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
685
685
  rowNumberMode?: 'original' | 'static';
686
686
  selectAllMode?: 'all' | 'page';
687
687
  tableId?: string;
688
- virtualizerProps?: any;
688
+ virtualizerProps?: Partial<VirtualizerOptions<HTMLDivElement>>;
689
689
  };
690
690
 
691
691
  export default <D extends Record<string, any> = {}>({
@@ -1,9 +1,9 @@
1
1
  import React, { FC, RefObject, useMemo } from 'react';
2
- import { useVirtualizer } from '@tanstack/react-virtual';
2
+ import { useVirtual } from 'react-virtual';
3
3
  import { TableBody } from '@mui/material';
4
4
  import { MRT_TableBodyRow } from './MRT_TableBodyRow';
5
- import type { MRT_Row, MRT_TableInstance } from '..';
6
5
  import { rankGlobalFuzzy } from '../sortingFns';
6
+ import type { MRT_Row, MRT_TableInstance } from '..';
7
7
 
8
8
  interface Props {
9
9
  table: MRT_TableInstance;
@@ -61,17 +61,17 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
61
61
  ]);
62
62
 
63
63
  const rowVirtualizer = enableRowVirtualization
64
- ? useVirtualizer({
65
- count: rows.length,
66
- estimateSize: () => (density === 'compact' ? 25 : 50),
67
- getScrollElement: () => tableContainerRef.current,
64
+ ? useVirtual({
65
+ // estimateSize: () => (density === 'compact' ? 25 : 50),
68
66
  overscan: density === 'compact' ? 30 : 10,
67
+ parentRef: tableContainerRef,
68
+ size: rows.length,
69
69
  ...virtualizerProps,
70
70
  })
71
- : {};
71
+ : ({} as any);
72
72
 
73
73
  const virtualRows = enableRowVirtualization
74
- ? rowVirtualizer.getVirtualItems()
74
+ ? rowVirtualizer.virtualItems
75
75
  : [];
76
76
 
77
77
  let paddingTop = 0;
@@ -80,8 +80,7 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
80
80
  paddingTop = virtualRows.length > 0 ? virtualRows[0].start : 0;
81
81
  paddingBottom =
82
82
  virtualRows.length > 0
83
- ? rowVirtualizer.getTotalSize() -
84
- virtualRows[virtualRows.length - 1].end
83
+ ? rowVirtualizer.totalSize - virtualRows[virtualRows.length - 1].end
85
84
  : 0;
86
85
  }
87
86