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.
Files changed (43) hide show
  1. package/dist/cjs/index.js +178 -73
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/MaterialReactTable.d.ts +18 -5
  4. package/dist/cjs/types/body/MRT_TableBody.d.ts +5 -0
  5. package/dist/cjs/types/body/MRT_TableBodyCell.d.ts +3 -0
  6. package/dist/cjs/types/body/MRT_TableBodyRow.d.ts +5 -1
  7. package/dist/cjs/types/footer/MRT_TableFooter.d.ts +4 -0
  8. package/dist/cjs/types/footer/MRT_TableFooterRow.d.ts +4 -0
  9. package/dist/cjs/types/head/MRT_TableHead.d.ts +4 -0
  10. package/dist/cjs/types/head/MRT_TableHeadRow.d.ts +4 -0
  11. package/dist/cjs/types/table/MRT_TableRoot.d.ts +12 -5
  12. package/dist/cjs/types/toolbar/MRT_TablePagination.d.ts +1 -1
  13. package/dist/esm/material-react-table.esm.js +172 -66
  14. package/dist/esm/material-react-table.esm.js.map +1 -1
  15. package/dist/esm/types/MaterialReactTable.d.ts +18 -5
  16. package/dist/esm/types/body/MRT_TableBody.d.ts +5 -0
  17. package/dist/esm/types/body/MRT_TableBodyCell.d.ts +3 -0
  18. package/dist/esm/types/body/MRT_TableBodyRow.d.ts +5 -1
  19. package/dist/esm/types/footer/MRT_TableFooter.d.ts +4 -0
  20. package/dist/esm/types/footer/MRT_TableFooterRow.d.ts +4 -0
  21. package/dist/esm/types/head/MRT_TableHead.d.ts +4 -0
  22. package/dist/esm/types/head/MRT_TableHeadRow.d.ts +4 -0
  23. package/dist/esm/types/table/MRT_TableRoot.d.ts +12 -5
  24. package/dist/esm/types/toolbar/MRT_TablePagination.d.ts +1 -1
  25. package/dist/index.d.ts +20 -7
  26. package/locales/ru.esm.js +1 -1
  27. package/locales/ru.js +1 -1
  28. package/package.json +6 -6
  29. package/src/MaterialReactTable.tsx +30 -8
  30. package/src/_locales/ru.ts +1 -1
  31. package/src/body/MRT_TableBody.tsx +42 -13
  32. package/src/body/MRT_TableBodyCell.tsx +17 -1
  33. package/src/body/MRT_TableBodyRow.tsx +24 -3
  34. package/src/footer/MRT_TableFooter.tsx +13 -1
  35. package/src/footer/MRT_TableFooterCell.tsx +10 -2
  36. package/src/footer/MRT_TableFooterRow.tsx +31 -4
  37. package/src/head/MRT_TableHead.tsx +13 -1
  38. package/src/head/MRT_TableHeadCell.tsx +6 -3
  39. package/src/head/MRT_TableHeadRow.tsx +30 -4
  40. package/src/inputs/MRT_FilterTextField.tsx +3 -2
  41. package/src/inputs/MRT_GlobalFilterTextField.tsx +1 -1
  42. package/src/table/MRT_Table.tsx +105 -7
  43. 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
- tableInstanceRef?: MutableRefObject<MRT_TableInstance<TData> | null>;
694
- virtualizerProps?: Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>> | (({ table, }: {
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
- virtualizerInstanceRef?: MutableRefObject<Virtualizer<HTMLDivElement, HTMLTableRowElement> | null>;
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
- tableInstanceRef?: React.MutableRefObject<MRT_TableInstance<TData> | null> | undefined;
257
- virtualizerProps?: Partial<import("@tanstack/react-virtual").VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>> | (({ table, }: {
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
- virtualizerInstanceRef?: React.MutableRefObject<import("@tanstack/react-virtual").Virtualizer<HTMLDivElement, HTMLTableRowElement> | null> | undefined;
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: 'top' | 'bottom';
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;
package/dist/index.d.ts CHANGED
@@ -21,7 +21,7 @@ import { TextFieldProps } from '@mui/material/TextField';
21
21
  import { ToolbarProps } from '@mui/material/Toolbar';
22
22
  import * as _tanstack_react_table from '@tanstack/react-table';
23
23
  import { Row, Table, TableState, ColumnDef, DeepKeys, Column, Header, HeaderGroup, Cell, AggregationFn, SortingFn, FilterFn, TableOptions, OnChangeFn } from '@tanstack/react-table';
24
- import { VirtualizerOptions, Virtualizer } from '@tanstack/react-virtual';
24
+ import { Virtualizer, VirtualizerOptions } from '@tanstack/react-virtual';
25
25
  import { RankingInfo } from '@tanstack/match-sorter-utils';
26
26
 
27
27
  declare const MRT_AggregationFns: {
@@ -565,6 +565,7 @@ type MaterialReactTableProps<TData extends Record<string, any> = {}> = Omit<Part
565
565
  enableColumnDragging?: boolean;
566
566
  enableColumnFilterModes?: boolean;
567
567
  enableColumnOrdering?: boolean;
568
+ enableColumnVirtualization?: boolean;
568
569
  enableDensityToggle?: boolean;
569
570
  enableEditing?: boolean;
570
571
  enableExpandAll?: boolean;
@@ -760,8 +761,8 @@ type MaterialReactTableProps<TData extends Record<string, any> = {}> = Omit<Part
760
761
  onShowGlobalFilterChange?: OnChangeFn<boolean>;
761
762
  positionActionsColumn?: 'first' | 'last';
762
763
  positionExpandColumn?: 'first' | 'last';
763
- positionGlobalFilter?: 'left' | 'right';
764
- positionPagination?: 'bottom' | 'top' | 'both';
764
+ positionGlobalFilter?: 'left' | 'right' | 'none';
765
+ positionPagination?: 'bottom' | 'top' | 'both' | 'none';
765
766
  positionToolbarAlertBanner?: 'bottom' | 'top' | 'none';
766
767
  positionToolbarDropZone?: 'bottom' | 'top' | 'none' | 'both';
767
768
  renderBottomToolbar?: ReactNode | (({ table }: {
@@ -813,11 +814,23 @@ type MaterialReactTableProps<TData extends Record<string, any> = {}> = Omit<Part
813
814
  rowNumberMode?: 'original' | 'static';
814
815
  selectAllMode?: 'all' | 'page';
815
816
  state?: Partial<MRT_TableState<TData>>;
816
- tableInstanceRef?: MutableRefObject<MRT_TableInstance<TData> | null>;
817
- virtualizerProps?: Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>> | (({ table, }: {
817
+ columnVirtualizerInstanceRef?: MutableRefObject<Virtualizer<HTMLDivElement, HTMLTableCellElement> | null>;
818
+ columnVirtualizerProps?: Partial<VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>> | (({ table, }: {
819
+ table: MRT_TableInstance<TData>;
820
+ }) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>>);
821
+ rowVirtualizerInstanceRef?: MutableRefObject<Virtualizer<HTMLDivElement, HTMLTableRowElement> | null>;
822
+ rowVirtualizerProps?: Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>> | (({ table, }: {
818
823
  table: MRT_TableInstance<TData>;
819
824
  }) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>);
820
- virtualizerInstanceRef?: MutableRefObject<Virtualizer<HTMLDivElement, HTMLTableRowElement> | null>;
825
+ tableInstanceRef?: MutableRefObject<MRT_TableInstance<TData> | null>;
826
+ /**
827
+ * @deprecated Use `rowVirtualizerInstanceRef` instead
828
+ */
829
+ virtualizerInstanceRef?: any;
830
+ /**
831
+ * @deprecated Use `rowVirtualizerProps` instead
832
+ */
833
+ virtualizerProps?: any;
821
834
  };
822
835
  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;
823
836
 
@@ -854,7 +867,7 @@ interface Props$7<TData extends Record<string, any> = {}> extends IconButtonProp
854
867
  declare const MRT_ShowHideColumnsButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props$7<TData>) => JSX.Element;
855
868
 
856
869
  interface Props$6<TData extends Record<string, any> = {}> {
857
- position: 'top' | 'bottom';
870
+ position?: 'top' | 'bottom';
858
871
  table: MRT_TableInstance<TData>;
859
872
  }
860
873
  declare const MRT_TablePagination: <TData extends Record<string, any> = {}>({ table, position, }: Props$6<TData>) => JSX.Element;
package/locales/ru.esm.js CHANGED
@@ -32,7 +32,7 @@ const MRT_Localization_RU = {
32
32
  filterGreaterThanOrEqualTo: 'Больше или равно',
33
33
  filterInNumberRange: 'Между',
34
34
  filterIncludesString: 'Содержит',
35
- filterIncludesStringSensitive: 'Содержит (регистрозависисый)',
35
+ filterIncludesStringSensitive: 'Содержит (регистрозависимый)',
36
36
  filterLessThan: 'Меньше чем',
37
37
  filterLessThanOrEqualTo: 'Меньше или равно',
38
38
  filterMode: 'Режим фильтра: {filterType}',
package/locales/ru.js CHANGED
@@ -36,7 +36,7 @@ const MRT_Localization_RU = {
36
36
  filterGreaterThanOrEqualTo: 'Больше или равно',
37
37
  filterInNumberRange: 'Между',
38
38
  filterIncludesString: 'Содержит',
39
- filterIncludesStringSensitive: 'Содержит (регистрозависисый)',
39
+ filterIncludesStringSensitive: 'Содержит (регистрозависимый)',
40
40
  filterLessThan: 'Меньше чем',
41
41
  filterLessThanOrEqualTo: 'Меньше или равно',
42
42
  filterMode: 'Режим фильтра: {filterType}',
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.4.2",
2
+ "version": "1.5.0-beta.0",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
@@ -57,17 +57,17 @@
57
57
  "@babel/preset-react": "^7.18.6",
58
58
  "@emotion/react": "^11.10.5",
59
59
  "@emotion/styled": "^11.10.5",
60
- "@mui/icons-material": "^5.10.16",
61
- "@mui/material": "^5.10.17",
60
+ "@mui/icons-material": "^5.11.0",
61
+ "@mui/material": "^5.11.0",
62
62
  "@rollup/plugin-babel": "^6.0.3",
63
63
  "@rollup/plugin-node-resolve": "^15.0.1",
64
64
  "@rollup/plugin-typescript": "^10.0.1",
65
65
  "@size-limit/preset-small-lib": "^8.1.0",
66
- "@types/node": "^18.11.11",
66
+ "@types/node": "^18.11.15",
67
67
  "@types/react": "^18.0.26",
68
68
  "@types/react-dom": "^18.0.9",
69
- "@typescript-eslint/eslint-plugin": "^5.46.0",
70
- "@typescript-eslint/parser": "^5.46.0",
69
+ "@typescript-eslint/eslint-plugin": "^5.46.1",
70
+ "@typescript-eslint/parser": "^5.46.1",
71
71
  "eslint": "^8.29.0",
72
72
  "eslint-plugin-mui-path-imports": "^0.0.7",
73
73
  "react": "^18.2.0",
@@ -659,6 +659,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
659
659
  enableColumnDragging?: boolean;
660
660
  enableColumnFilterModes?: boolean;
661
661
  enableColumnOrdering?: boolean;
662
+ enableColumnVirtualization?: boolean;
662
663
  enableDensityToggle?: boolean;
663
664
  enableEditing?: boolean;
664
665
  enableExpandAll?: boolean;
@@ -972,8 +973,8 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
972
973
  onShowGlobalFilterChange?: OnChangeFn<boolean>;
973
974
  positionActionsColumn?: 'first' | 'last';
974
975
  positionExpandColumn?: 'first' | 'last';
975
- positionGlobalFilter?: 'left' | 'right';
976
- positionPagination?: 'bottom' | 'top' | 'both';
976
+ positionGlobalFilter?: 'left' | 'right' | 'none';
977
+ positionPagination?: 'bottom' | 'top' | 'both' | 'none';
977
978
  positionToolbarAlertBanner?: 'bottom' | 'top' | 'none';
978
979
  positionToolbarDropZone?: 'bottom' | 'top' | 'none' | 'both';
979
980
  renderBottomToolbar?:
@@ -1055,18 +1056,39 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
1055
1056
  rowNumberMode?: 'original' | 'static';
1056
1057
  selectAllMode?: 'all' | 'page';
1057
1058
  state?: Partial<MRT_TableState<TData>>;
1058
- tableInstanceRef?: MutableRefObject<MRT_TableInstance<TData> | null>;
1059
- virtualizerProps?:
1060
- | Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>
1059
+ columnVirtualizerInstanceRef?: MutableRefObject<Virtualizer<
1060
+ HTMLDivElement,
1061
+ HTMLTableCellElement
1062
+ > | null>;
1063
+ columnVirtualizerProps?:
1064
+ | Partial<VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>>
1061
1065
  | (({
1062
1066
  table,
1063
1067
  }: {
1064
1068
  table: MRT_TableInstance<TData>;
1065
- }) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>);
1066
- virtualizerInstanceRef?: MutableRefObject<Virtualizer<
1069
+ }) => Partial<
1070
+ VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>
1071
+ >);
1072
+ rowVirtualizerInstanceRef?: MutableRefObject<Virtualizer<
1067
1073
  HTMLDivElement,
1068
1074
  HTMLTableRowElement
1069
1075
  > | null>;
1076
+ rowVirtualizerProps?:
1077
+ | Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>
1078
+ | (({
1079
+ table,
1080
+ }: {
1081
+ table: MRT_TableInstance<TData>;
1082
+ }) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>);
1083
+ tableInstanceRef?: MutableRefObject<MRT_TableInstance<TData> | null>;
1084
+ /**
1085
+ * @deprecated Use `rowVirtualizerInstanceRef` instead
1086
+ */
1087
+ virtualizerInstanceRef?: any;
1088
+ /**
1089
+ * @deprecated Use `rowVirtualizerProps` instead
1090
+ */
1091
+ virtualizerProps?: any;
1070
1092
  };
1071
1093
 
1072
1094
  const MaterialReactTable = <TData extends Record<string, any> = {}>({
@@ -1142,7 +1164,7 @@ const MaterialReactTable = <TData extends Record<string, any> = {}>({
1142
1164
  [],
1143
1165
  );
1144
1166
 
1145
- if (rest.enableRowVirtualization) {
1167
+ if (rest.enableRowVirtualization || rest.enableColumnVirtualization) {
1146
1168
  layoutMode = 'grid';
1147
1169
  enableStickyHeader = true;
1148
1170
  }
@@ -34,7 +34,7 @@ export const MRT_Localization_RU: MRT_Localization = {
34
34
  filterGreaterThanOrEqualTo: 'Больше или равно',
35
35
  filterInNumberRange: 'Между',
36
36
  filterIncludesString: 'Содержит',
37
- filterIncludesStringSensitive: 'Содержит (регистрозависисый)',
37
+ filterIncludesStringSensitive: 'Содержит (регистрозависимый)',
38
38
  filterLessThan: 'Меньше чем',
39
39
  filterLessThanOrEqualTo: 'Меньше или равно',
40
40
  filterMode: 'Режим фильтра: {filterType}',
@@ -11,10 +11,20 @@ import { rankGlobalFuzzy } from '../sortingFns';
11
11
  import type { MRT_Row, MRT_TableInstance } from '..';
12
12
 
13
13
  interface Props {
14
+ columnVirtualizer?: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
14
15
  table: MRT_TableInstance;
16
+ virtualColumns?: VirtualItem[];
17
+ virtualPaddingLeft?: number;
18
+ virtualPaddingRight?: number;
15
19
  }
16
20
 
17
- export const MRT_TableBody: FC<Props> = ({ table }) => {
21
+ export const MRT_TableBody: FC<Props> = ({
22
+ columnVirtualizer,
23
+ table,
24
+ virtualColumns,
25
+ virtualPaddingLeft,
26
+ virtualPaddingRight,
27
+ }) => {
18
28
  const {
19
29
  getRowModel,
20
30
  getPrePaginationRowModel,
@@ -29,6 +39,8 @@ export const MRT_TableBody: FC<Props> = ({ table }) => {
29
39
  manualSorting,
30
40
  memoMode,
31
41
  muiTableBodyProps,
42
+ rowVirtualizerInstanceRef,
43
+ rowVirtualizerProps,
32
44
  virtualizerInstanceRef,
33
45
  virtualizerProps,
34
46
  },
@@ -42,11 +54,16 @@ export const MRT_TableBody: FC<Props> = ({ table }) => {
42
54
  ? muiTableBodyProps({ table })
43
55
  : muiTableBodyProps;
44
56
 
45
- const vProps =
57
+ const vProps_old =
46
58
  virtualizerProps instanceof Function
47
59
  ? virtualizerProps({ table })
48
60
  : virtualizerProps;
49
61
 
62
+ const vProps =
63
+ rowVirtualizerProps instanceof Function
64
+ ? rowVirtualizerProps({ table })
65
+ : rowVirtualizerProps;
66
+
50
67
  const rows = useMemo(() => {
51
68
  if (
52
69
  enableGlobalFilterRankedResults &&
@@ -78,7 +95,7 @@ export const MRT_TableBody: FC<Props> = ({ table }) => {
78
95
  pagination.pageSize,
79
96
  ]);
80
97
 
81
- const virtualizer:
98
+ const rowVirtualizer:
82
99
  | Virtualizer<HTMLDivElement, HTMLTableRowElement>
83
100
  | undefined = enableRowVirtualization
84
101
  ? useVirtualizer({
@@ -88,22 +105,32 @@ export const MRT_TableBody: FC<Props> = ({ table }) => {
88
105
  getScrollElement: () => tableContainerRef.current,
89
106
  measureElement: (element) => element?.getBoundingClientRect().height,
90
107
  overscan: 4,
108
+ ...vProps_old,
91
109
  ...vProps,
92
110
  })
93
111
  : undefined;
94
112
 
95
- if (virtualizerInstanceRef && virtualizer) {
96
- virtualizerInstanceRef.current = virtualizer;
113
+ if (rowVirtualizerInstanceRef && rowVirtualizer) {
114
+ rowVirtualizerInstanceRef.current = rowVirtualizer;
97
115
  }
98
116
 
99
- const virtualRows = virtualizer ? virtualizer.getVirtualItems() : undefined;
117
+ //deprecated
118
+ if (virtualizerInstanceRef && rowVirtualizer) {
119
+ virtualizerInstanceRef.current = rowVirtualizer;
120
+ }
121
+
122
+ const virtualRows = rowVirtualizer
123
+ ? rowVirtualizer.getVirtualItems()
124
+ : undefined;
100
125
 
101
126
  return (
102
127
  <TableBody
103
128
  {...tableBodyProps}
104
129
  sx={(theme) => ({
105
130
  display: layoutMode === 'grid' ? 'grid' : 'table-row-group',
106
- height: virtualizer ? `${virtualizer.getTotalSize()}px` : 'inherit',
131
+ height: rowVirtualizer
132
+ ? `${rowVirtualizer.getTotalSize()}px`
133
+ : 'inherit',
107
134
  minHeight: !rows.length ? '100px' : undefined,
108
135
  position: 'relative',
109
136
  ...(tableBodyProps?.sx instanceof Function
@@ -139,19 +166,21 @@ export const MRT_TableBody: FC<Props> = ({ table }) => {
139
166
  ) : (
140
167
  <>
141
168
  {(virtualRows ?? rows).map((rowOrVirtualRow, rowIndex) => {
142
- const row = virtualizer
169
+ const row = rowVirtualizer
143
170
  ? rows[rowOrVirtualRow.index]
144
171
  : (rowOrVirtualRow as MRT_Row);
145
172
  const props = {
173
+ columnVirtualizer,
146
174
  key: row.id,
147
- measureElement: virtualizer
148
- ? virtualizer.measureElement
149
- : undefined,
175
+ measureElement: rowVirtualizer?.measureElement,
150
176
  numRows: rows.length,
151
177
  row,
152
- rowIndex: virtualizer ? rowOrVirtualRow.index : rowIndex,
178
+ rowIndex: rowVirtualizer ? rowOrVirtualRow.index : rowIndex,
153
179
  table,
154
- virtualRow: virtualizer
180
+ virtualColumns,
181
+ virtualPaddingLeft,
182
+ virtualPaddingRight,
183
+ virtualRow: rowVirtualizer
155
184
  ? (rowOrVirtualRow as VirtualItem)
156
185
  : undefined,
157
186
  };
@@ -16,24 +16,29 @@ import { MRT_CopyButton } from '../buttons/MRT_CopyButton';
16
16
  import { MRT_TableBodyRowGrabHandle } from './MRT_TableBodyRowGrabHandle';
17
17
  import { MRT_TableBodyCellValue } from './MRT_TableBodyCellValue';
18
18
  import { getCommonCellStyles } from '../column.utils';
19
+ import type { VirtualItem } from '@tanstack/react-virtual';
19
20
  import type { MRT_Cell, MRT_TableInstance } from '..';
20
21
 
21
22
  interface Props {
22
23
  cell: MRT_Cell;
23
24
  enableHover?: boolean;
25
+ measureElement?: (element: HTMLTableCellElement) => void;
24
26
  numRows: number;
25
27
  rowIndex: number;
26
28
  rowRef: RefObject<HTMLTableRowElement>;
27
29
  table: MRT_TableInstance;
30
+ virtualCell?: VirtualItem;
28
31
  }
29
32
 
30
33
  export const MRT_TableBodyCell: FC<Props> = ({
31
34
  cell,
32
35
  enableHover,
36
+ measureElement,
33
37
  numRows,
34
38
  rowIndex,
35
39
  rowRef,
36
40
  table,
41
+ virtualCell,
37
42
  }) => {
38
43
  const theme = useTheme();
39
44
  const {
@@ -169,6 +174,12 @@ export const MRT_TableBodyCell: FC<Props> = ({
169
174
 
170
175
  return (
171
176
  <TableCell
177
+ data-index={virtualCell?.index}
178
+ ref={(node: HTMLTableCellElement) => {
179
+ if (node) {
180
+ measureElement?.(node);
181
+ }
182
+ }}
172
183
  {...tableCellProps}
173
184
  onDragEnter={handleDragEnter}
174
185
  onDoubleClick={handleDoubleClick}
@@ -214,7 +225,12 @@ export const MRT_TableBodyCell: FC<Props> = ({
214
225
  : `${darken(theme.palette.background.default, 0.1)} !important`
215
226
  : undefined,
216
227
  },
217
- ...getCommonCellStyles({ column, table, theme, tableCellProps }),
228
+ ...getCommonCellStyles({
229
+ column,
230
+ table,
231
+ theme,
232
+ tableCellProps,
233
+ }),
218
234
  ...draggingBorders,
219
235
  })}
220
236
  >
@@ -3,24 +3,32 @@ import TableRow from '@mui/material/TableRow';
3
3
  import { darken, lighten, useTheme } from '@mui/material/styles';
4
4
  import { Memo_MRT_TableBodyCell, MRT_TableBodyCell } from './MRT_TableBodyCell';
5
5
  import { MRT_TableDetailPanel } from './MRT_TableDetailPanel';
6
- import type { VirtualItem } from '@tanstack/react-virtual';
7
- import type { MRT_Row, MRT_TableInstance } from '..';
6
+ import type { VirtualItem, Virtualizer } from '@tanstack/react-virtual';
7
+ import type { MRT_Cell, MRT_Row, MRT_TableInstance } from '..';
8
8
 
9
9
  interface Props {
10
+ columnVirtualizer?: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
10
11
  measureElement?: (element: HTMLTableRowElement) => void;
11
12
  numRows: number;
12
13
  row: MRT_Row;
13
14
  rowIndex: number;
14
15
  table: MRT_TableInstance;
16
+ virtualColumns?: VirtualItem[];
17
+ virtualPaddingLeft?: number;
18
+ virtualPaddingRight?: number;
15
19
  virtualRow?: VirtualItem;
16
20
  }
17
21
 
18
22
  export const MRT_TableBodyRow: FC<Props> = ({
23
+ columnVirtualizer,
19
24
  measureElement,
20
25
  numRows,
21
26
  row,
22
27
  rowIndex,
23
28
  table,
29
+ virtualColumns,
30
+ virtualPaddingLeft,
31
+ virtualPaddingRight,
24
32
  virtualRow,
25
33
  }) => {
26
34
  const theme = useTheme();
@@ -108,15 +116,25 @@ export const MRT_TableBodyRow: FC<Props> = ({
108
116
  ...draggingBorders,
109
117
  })}
110
118
  >
111
- {row.getVisibleCells().map((cell) => {
119
+ {virtualPaddingLeft ? (
120
+ <td style={{ display: 'flex', width: virtualPaddingLeft }} />
121
+ ) : null}
122
+ {(virtualColumns ?? row.getVisibleCells()).map((cellOrVirtualCell) => {
123
+ const cell = columnVirtualizer
124
+ ? row.getVisibleCells()[(cellOrVirtualCell as VirtualItem).index]
125
+ : (cellOrVirtualCell as MRT_Cell);
112
126
  const props = {
113
127
  cell,
114
128
  enableHover: tableRowProps?.hover !== false,
115
129
  key: cell.id,
130
+ measureElement: columnVirtualizer?.measureElement,
116
131
  numRows,
117
132
  rowIndex,
118
133
  rowRef,
119
134
  table,
135
+ virtualCell: columnVirtualizer
136
+ ? (cellOrVirtualCell as VirtualItem)
137
+ : undefined,
120
138
  };
121
139
  return memoMode === 'cells' &&
122
140
  cell.column.columnDef.columnDefType === 'data' &&
@@ -129,6 +147,9 @@ export const MRT_TableBodyRow: FC<Props> = ({
129
147
  <MRT_TableBodyCell {...props} />
130
148
  );
131
149
  })}
150
+ {virtualPaddingRight ? (
151
+ <td style={{ display: 'flex', width: virtualPaddingRight }} />
152
+ ) : null}
132
153
  </TableRow>
133
154
  {renderDetailPanel && !row.getIsGrouped() && (
134
155
  <MRT_TableDetailPanel