material-react-table 0.33.5 → 0.34.1
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/MaterialReactTable.d.ts +9 -22
- package/dist/cjs/buttons/MRT_ColumnPinningButtons.d.ts +4 -5
- package/dist/cjs/buttons/MRT_FullScreenToggleButton.d.ts +3 -4
- package/dist/cjs/buttons/MRT_GrabHandleButton.d.ts +4 -4
- package/dist/cjs/buttons/MRT_ShowHideColumnsButton.d.ts +3 -4
- package/dist/cjs/buttons/MRT_ToggleDensePaddingButton.d.ts +3 -4
- package/dist/cjs/buttons/MRT_ToggleFiltersButton.d.ts +3 -4
- package/dist/cjs/buttons/MRT_ToggleGlobalFilterButton.d.ts +3 -4
- package/dist/cjs/index.d.ts +8 -2
- package/dist/cjs/index.js +529 -17
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/inputs/MRT_GlobalFilterTextField.d.ts +3 -4
- package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +3 -4
- package/dist/cjs/menus/MRT_ShowHideColumnsMenu.d.ts +3 -4
- package/dist/cjs/menus/MRT_ShowHideColumnsMenuItems.d.ts +8 -8
- package/dist/cjs/table/MRT_TableRoot.d.ts +0 -1
- package/dist/cjs/toolbar/MRT_ToolbarInternalButtons.d.ts +1 -1
- package/dist/esm/MaterialReactTable.d.ts +9 -22
- package/dist/esm/buttons/MRT_ColumnPinningButtons.d.ts +4 -5
- package/dist/esm/buttons/MRT_FullScreenToggleButton.d.ts +3 -4
- package/dist/esm/buttons/MRT_GrabHandleButton.d.ts +4 -4
- package/dist/esm/buttons/MRT_ShowHideColumnsButton.d.ts +3 -4
- package/dist/esm/buttons/MRT_ToggleDensePaddingButton.d.ts +3 -4
- package/dist/esm/buttons/MRT_ToggleFiltersButton.d.ts +3 -4
- package/dist/esm/buttons/MRT_ToggleGlobalFilterButton.d.ts +3 -4
- package/dist/esm/index.d.ts +8 -2
- package/dist/esm/inputs/MRT_GlobalFilterTextField.d.ts +3 -4
- package/dist/esm/material-react-table.esm.js +522 -18
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +3 -4
- package/dist/esm/menus/MRT_ShowHideColumnsMenu.d.ts +3 -4
- package/dist/esm/menus/MRT_ShowHideColumnsMenuItems.d.ts +8 -8
- package/dist/esm/table/MRT_TableRoot.d.ts +0 -1
- package/dist/esm/toolbar/MRT_ToolbarInternalButtons.d.ts +1 -1
- package/dist/index.d.ts +40 -23
- package/package.json +5 -5
- package/src/MaterialReactTable.tsx +15 -24
- package/src/body/MRT_TableBody.tsx +30 -11
- package/src/body/MRT_TableBodyCell.tsx +1 -1
- package/src/body/MRT_TableBodyRow.tsx +1 -1
- package/src/buttons/MRT_ColumnPinningButtons.tsx +10 -5
- package/src/buttons/MRT_FullScreenToggleButton.tsx +10 -4
- package/src/buttons/MRT_GrabHandleButton.tsx +5 -5
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +10 -4
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +10 -4
- package/src/buttons/MRT_ToggleFiltersButton.tsx +10 -4
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +10 -4
- package/src/head/MRT_TableHeadCell.tsx +1 -1
- package/src/index.tsx +17 -3
- package/src/inputs/MRT_GlobalFilterTextField.tsx +7 -4
- package/src/menus/MRT_FilterOptionMenu.tsx +5 -5
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +9 -7
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +15 -13
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +2 -7
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
1
|
import type { MRT_Header, MRT_TableInstance } from '..';
|
|
3
2
|
import { MRT_Localization } from '../localization';
|
|
4
3
|
export declare const internalFilterOptions: (localization: MRT_Localization) => {
|
|
@@ -7,12 +6,12 @@ export declare const internalFilterOptions: (localization: MRT_Localization) =>
|
|
|
7
6
|
label: string;
|
|
8
7
|
divider: boolean;
|
|
9
8
|
}[];
|
|
10
|
-
interface Props {
|
|
9
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
11
10
|
anchorEl: HTMLElement | null;
|
|
12
11
|
header?: MRT_Header;
|
|
13
12
|
onSelect?: () => void;
|
|
14
13
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
15
|
-
table: MRT_TableInstance
|
|
14
|
+
table: MRT_TableInstance<TData>;
|
|
16
15
|
}
|
|
17
|
-
export declare const MRT_FilterOptionMenu:
|
|
16
|
+
export declare const MRT_FilterOptionMenu: <TData extends Record<string, any> = {}>({ anchorEl, header, onSelect, setAnchorEl, table, }: Props<TData>) => JSX.Element;
|
|
18
17
|
export {};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
1
|
import type { MRT_TableInstance } from '..';
|
|
3
|
-
interface Props {
|
|
2
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
4
3
|
anchorEl: HTMLElement | null;
|
|
5
4
|
isSubMenu?: boolean;
|
|
6
5
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
7
|
-
table: MRT_TableInstance
|
|
6
|
+
table: MRT_TableInstance<TData>;
|
|
8
7
|
}
|
|
9
|
-
export declare const MRT_ShowHideColumnsMenu:
|
|
8
|
+
export declare const MRT_ShowHideColumnsMenu: <TData extends Record<string, any> = {}>({ anchorEl, isSubMenu, setAnchorEl, table, }: Props<TData>) => JSX.Element;
|
|
10
9
|
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Dispatch,
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import type { MRT_Column, MRT_TableInstance } from '..';
|
|
3
|
-
interface Props {
|
|
4
|
-
allColumns: MRT_Column[];
|
|
5
|
-
column: MRT_Column
|
|
6
|
-
currentHoveredColumn: MRT_Column | null;
|
|
3
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
4
|
+
allColumns: MRT_Column<TData>[];
|
|
5
|
+
column: MRT_Column<TData>;
|
|
6
|
+
currentHoveredColumn: MRT_Column<TData> | null;
|
|
7
7
|
isSubMenu?: boolean;
|
|
8
|
-
setCurrentHoveredColumn: Dispatch<SetStateAction<MRT_Column | null>>;
|
|
9
|
-
table: MRT_TableInstance
|
|
8
|
+
setCurrentHoveredColumn: Dispatch<SetStateAction<MRT_Column<TData> | null>>;
|
|
9
|
+
table: MRT_TableInstance<TData>;
|
|
10
10
|
}
|
|
11
|
-
export declare const MRT_ShowHideColumnsMenuItems:
|
|
11
|
+
export declare const MRT_ShowHideColumnsMenuItems: <TData extends Record<string, any> = {}>({ allColumns, currentHoveredColumn, setCurrentHoveredColumn, column, isSubMenu, table, }: Props<TData>) => JSX.Element;
|
|
12
12
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction, ReactNode, FocusEvent, ChangeEvent, DragEvent
|
|
1
|
+
import { Dispatch, SetStateAction, ReactNode, FocusEvent, ChangeEvent, DragEvent } from 'react';
|
|
2
2
|
import { ButtonProps, TextFieldProps, TableCellProps, IconButtonProps, LinearProgressProps, CheckboxProps, SkeletonProps, TableBodyProps, TableRowProps, ToolbarProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, PaperProps, TableProps, AlertProps } from '@mui/material';
|
|
3
3
|
import { Row, Table, TableState, ColumnDef, DeepKeys, Column, Header, HeaderGroup, Cell, SortingFn, FilterFn, TableOptions, OnChangeFn } from '@tanstack/react-table';
|
|
4
|
-
import {
|
|
4
|
+
import { Options } from 'react-virtual';
|
|
5
5
|
import * as _tanstack_table_core from '@tanstack/table-core';
|
|
6
6
|
import { RankingInfo } from '@tanstack/match-sorter-utils';
|
|
7
7
|
|
|
@@ -442,10 +442,11 @@ declare type MRT_DisplayColumnIds = 'mrt-row-drag' | 'mrt-row-actions' | 'mrt-ro
|
|
|
442
442
|
* See the full props list on the official docs site:
|
|
443
443
|
* @link https://www.material-react-table.com/docs/api/props
|
|
444
444
|
*/
|
|
445
|
-
declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = Omit<Partial<TableOptions<TData>>, 'columns' | 'data' | 'expandRowsFn' | 'initialState' | 'onStateChange' | 'state'> & {
|
|
445
|
+
declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = Omit<Partial<TableOptions<TData>>, 'columns' | 'data' | 'defaultColumn' | 'enableRowSelection' | 'expandRowsFn' | 'initialState' | 'onStateChange' | 'state'> & {
|
|
446
446
|
columnFilterModeOptions?: (MRT_FilterOption | string)[] | null;
|
|
447
447
|
columns: MRT_ColumnDef<TData>[];
|
|
448
448
|
data: TData[];
|
|
449
|
+
defaultColumn?: Partial<MRT_ColumnDef<TData>>;
|
|
449
450
|
displayColumnDefOptions?: Partial<{
|
|
450
451
|
[key in MRT_DisplayColumnIds]: Partial<MRT_ColumnDef>;
|
|
451
452
|
}>;
|
|
@@ -467,6 +468,7 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
467
468
|
enableRowDragging?: boolean;
|
|
468
469
|
enableRowNumbers?: boolean;
|
|
469
470
|
enableRowOrdering?: boolean;
|
|
471
|
+
enableRowSelection?: boolean | ((row: MRT_Row<TData>) => boolean);
|
|
470
472
|
enableRowVirtualization?: boolean;
|
|
471
473
|
enableSelectAll?: boolean;
|
|
472
474
|
enableStickyHeader?: boolean;
|
|
@@ -652,23 +654,8 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
652
654
|
row: MRT_Row<TData>;
|
|
653
655
|
table: MRT_TableInstance<TData>;
|
|
654
656
|
}) => ReactNode;
|
|
655
|
-
renderToolbarInternalActions?: ({ table,
|
|
656
|
-
table: MRT_TableInstance<TData>;
|
|
657
|
-
MRT_ToggleGlobalFilterButton: FC<IconButtonProps & {
|
|
658
|
-
table: MRT_TableInstance<TData>;
|
|
659
|
-
}>;
|
|
660
|
-
MRT_ToggleFiltersButton: FC<IconButtonProps & {
|
|
661
|
-
table: MRT_TableInstance<TData>;
|
|
662
|
-
}>;
|
|
663
|
-
MRT_ShowHideColumnsButton: FC<IconButtonProps & {
|
|
664
|
-
table: MRT_TableInstance<TData>;
|
|
665
|
-
}>;
|
|
666
|
-
MRT_ToggleDensePaddingButton: FC<IconButtonProps & {
|
|
667
|
-
table: MRT_TableInstance<TData>;
|
|
668
|
-
}>;
|
|
669
|
-
MRT_FullScreenToggleButton: FC<IconButtonProps & {
|
|
670
|
-
table: MRT_TableInstance<TData>;
|
|
671
|
-
}>;
|
|
657
|
+
renderToolbarInternalActions?: ({ table, }: {
|
|
658
|
+
table: MRT_TableInstance<TData>;
|
|
672
659
|
}) => ReactNode;
|
|
673
660
|
renderTopToolbarCustomActions?: ({ table, }: {
|
|
674
661
|
table: MRT_TableInstance<TData>;
|
|
@@ -678,10 +665,40 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
678
665
|
selectAllMode?: 'all' | 'page';
|
|
679
666
|
state?: Partial<MRT_TableState<TData>>;
|
|
680
667
|
tableId?: string;
|
|
681
|
-
virtualizerProps?: Partial<
|
|
668
|
+
virtualizerProps?: Partial<Options<HTMLDivElement>> | (({ table, }: {
|
|
682
669
|
table: MRT_TableInstance<TData>;
|
|
683
|
-
}) => Partial<
|
|
670
|
+
}) => Partial<Options<HTMLDivElement>>);
|
|
684
671
|
};
|
|
685
672
|
declare const _default: <TData extends Record<string, any> = {}>({ aggregationFns, autoResetExpanded, columnResizeMode, defaultColumn, editingMode, enableBottomToolbar, enableColumnActions, enableColumnFilterChangeMode, enableColumnFilters, enableColumnOrdering, enableColumnResizing, enableDensityToggle, enableExpandAll, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableGlobalFilterChangeMode, enableGlobalFilterRankedResults, enableGrouping, enableHiding, enableMultiRowSelection, enableMultiSort, enablePagination, enablePinning, enableRowSelection, enableSelectAll, enableSorting, enableStickyHeader, enableTableFooter, enableTableHead, enableToolbarInternalActions, enableTopToolbar, filterFns, icons, localization, positionActionsColumn, positionExpandColumn, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, rowNumberMode, selectAllMode, sortingFns, ...rest }: MaterialReactTableProps<TData>) => JSX.Element;
|
|
686
673
|
|
|
687
|
-
|
|
674
|
+
interface Props$5<TData extends Record<string, any> = {}> extends IconButtonProps {
|
|
675
|
+
table: MRT_TableInstance<TData>;
|
|
676
|
+
}
|
|
677
|
+
declare const MRT_FullScreenToggleButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props$5<TData>) => JSX.Element;
|
|
678
|
+
|
|
679
|
+
interface Props$4<TData extends Record<string, any> = {}> {
|
|
680
|
+
table: MRT_TableInstance<TData>;
|
|
681
|
+
}
|
|
682
|
+
declare const MRT_GlobalFilterTextField: <TData extends Record<string, any> = {}>({ table, }: Props$4<TData>) => JSX.Element;
|
|
683
|
+
|
|
684
|
+
interface Props$3<TData extends Record<string, any> = {}> extends IconButtonProps {
|
|
685
|
+
table: MRT_TableInstance<TData>;
|
|
686
|
+
}
|
|
687
|
+
declare const MRT_ShowHideColumnsButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props$3<TData>) => JSX.Element;
|
|
688
|
+
|
|
689
|
+
interface Props$2<TData extends Record<string, any> = {}> extends IconButtonProps {
|
|
690
|
+
table: MRT_TableInstance<TData>;
|
|
691
|
+
}
|
|
692
|
+
declare const MRT_ToggleDensePaddingButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props$2<TData>) => JSX.Element;
|
|
693
|
+
|
|
694
|
+
interface Props$1<TData extends Record<string, any> = {}> extends IconButtonProps {
|
|
695
|
+
table: MRT_TableInstance<TData>;
|
|
696
|
+
}
|
|
697
|
+
declare const MRT_ToggleFiltersButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props$1<TData>) => JSX.Element;
|
|
698
|
+
|
|
699
|
+
interface Props<TData extends Record<string, any> = {}> extends IconButtonProps {
|
|
700
|
+
table: MRT_TableInstance<TData>;
|
|
701
|
+
}
|
|
702
|
+
declare const MRT_ToggleGlobalFilterButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props<TData>) => JSX.Element;
|
|
703
|
+
|
|
704
|
+
export { MRT_Cell, MRT_Column, MRT_ColumnDef, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterFn, MRT_FilterOption, MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_Header, MRT_HeaderGroup, MRT_Icons, MRT_Localization, MRT_Row, MRT_RowModel, MRT_ShowHideColumnsButton, MRT_SortingFn, MRT_SortingOption, MRT_TableInstance, MRT_TableState, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MaterialReactTableProps, _default as default };
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.34.1",
|
|
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.",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@emotion/styled": "^11.10.0",
|
|
56
56
|
"@faker-js/faker": "^7.3.0",
|
|
57
57
|
"@mui/icons-material": "^5.8.4",
|
|
58
|
-
"@mui/material": "^5.
|
|
58
|
+
"@mui/material": "^5.10.0",
|
|
59
59
|
"@rollup/plugin-babel": "^5.3.1",
|
|
60
60
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
61
61
|
"@rollup/plugin-typescript": "^8.3.4",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@storybook/addon-storysource": "^6.5.10",
|
|
69
69
|
"@storybook/addons": "^6.5.10",
|
|
70
70
|
"@storybook/react": "^6.5.10",
|
|
71
|
-
"@types/react": "^18.0.
|
|
71
|
+
"@types/react": "^18.0.17",
|
|
72
72
|
"@types/react-dom": "^18.0.6",
|
|
73
73
|
"babel-loader": "^8.2.5",
|
|
74
74
|
"eslint": "^8.21.0",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
97
|
"@tanstack/match-sorter-utils": "8.1.1",
|
|
98
|
-
"@tanstack/react-table": "8.5.
|
|
99
|
-
"
|
|
98
|
+
"@tanstack/react-table": "8.5.11",
|
|
99
|
+
"react-virtual": "^2.10.4"
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -2,7 +2,6 @@ import React, {
|
|
|
2
2
|
ChangeEvent,
|
|
3
3
|
Dispatch,
|
|
4
4
|
DragEvent,
|
|
5
|
-
FC,
|
|
6
5
|
FocusEvent,
|
|
7
6
|
ReactNode,
|
|
8
7
|
SetStateAction,
|
|
@@ -41,7 +40,8 @@ import type {
|
|
|
41
40
|
TableOptions,
|
|
42
41
|
TableState,
|
|
43
42
|
} from '@tanstack/react-table';
|
|
44
|
-
import type { VirtualizerOptions } from '
|
|
43
|
+
import type { Options as VirtualizerOptions } from 'react-virtual';
|
|
44
|
+
// import type { VirtualizerOptions } from '@tanstack/react-virtual';
|
|
45
45
|
import { MRT_AggregationFns } from './aggregationFns';
|
|
46
46
|
import { MRT_Default_Icons, MRT_Icons } from './icons';
|
|
47
47
|
import { MRT_FilterFns } from './filterFns';
|
|
@@ -445,6 +445,8 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
445
445
|
Partial<TableOptions<TData>>,
|
|
446
446
|
| 'columns'
|
|
447
447
|
| 'data'
|
|
448
|
+
| 'defaultColumn'
|
|
449
|
+
| 'enableRowSelection'
|
|
448
450
|
| 'expandRowsFn'
|
|
449
451
|
| 'initialState'
|
|
450
452
|
| 'onStateChange'
|
|
@@ -453,6 +455,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
453
455
|
columnFilterModeOptions?: (MRT_FilterOption | string)[] | null;
|
|
454
456
|
columns: MRT_ColumnDef<TData>[];
|
|
455
457
|
data: TData[];
|
|
458
|
+
defaultColumn?: Partial<MRT_ColumnDef<TData>>;
|
|
456
459
|
displayColumnDefOptions?: Partial<{
|
|
457
460
|
[key in MRT_DisplayColumnIds]: Partial<MRT_ColumnDef>;
|
|
458
461
|
}>;
|
|
@@ -474,6 +477,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
474
477
|
enableRowDragging?: boolean;
|
|
475
478
|
enableRowNumbers?: boolean;
|
|
476
479
|
enableRowOrdering?: boolean;
|
|
480
|
+
enableRowSelection?: boolean | ((row: MRT_Row<TData>) => boolean);
|
|
477
481
|
enableRowVirtualization?: boolean;
|
|
478
482
|
enableSelectAll?: boolean;
|
|
479
483
|
enableStickyHeader?: boolean;
|
|
@@ -779,28 +783,8 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
779
783
|
}) => ReactNode;
|
|
780
784
|
renderToolbarInternalActions?: ({
|
|
781
785
|
table,
|
|
782
|
-
MRT_ToggleGlobalFilterButton,
|
|
783
|
-
MRT_ToggleFiltersButton,
|
|
784
|
-
MRT_ShowHideColumnsButton,
|
|
785
|
-
MRT_ToggleDensePaddingButton,
|
|
786
|
-
MRT_FullScreenToggleButton,
|
|
787
786
|
}: {
|
|
788
787
|
table: MRT_TableInstance<TData>;
|
|
789
|
-
MRT_ToggleGlobalFilterButton: FC<
|
|
790
|
-
IconButtonProps & { table: MRT_TableInstance<TData> }
|
|
791
|
-
>;
|
|
792
|
-
MRT_ToggleFiltersButton: FC<
|
|
793
|
-
IconButtonProps & { table: MRT_TableInstance<TData> }
|
|
794
|
-
>;
|
|
795
|
-
MRT_ShowHideColumnsButton: FC<
|
|
796
|
-
IconButtonProps & { table: MRT_TableInstance<TData> }
|
|
797
|
-
>;
|
|
798
|
-
MRT_ToggleDensePaddingButton: FC<
|
|
799
|
-
IconButtonProps & { table: MRT_TableInstance<TData> }
|
|
800
|
-
>;
|
|
801
|
-
MRT_FullScreenToggleButton: FC<
|
|
802
|
-
IconButtonProps & { table: MRT_TableInstance<TData> }
|
|
803
|
-
>;
|
|
804
788
|
}) => ReactNode;
|
|
805
789
|
renderTopToolbarCustomActions?: ({
|
|
806
790
|
table,
|
|
@@ -813,12 +797,19 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
813
797
|
state?: Partial<MRT_TableState<TData>>;
|
|
814
798
|
tableId?: string;
|
|
815
799
|
virtualizerProps?:
|
|
816
|
-
| Partial<VirtualizerOptions<HTMLDivElement
|
|
800
|
+
| Partial<VirtualizerOptions<HTMLDivElement>>
|
|
817
801
|
| (({
|
|
818
802
|
table,
|
|
819
803
|
}: {
|
|
820
804
|
table: MRT_TableInstance<TData>;
|
|
821
|
-
}) => Partial<VirtualizerOptions<HTMLDivElement
|
|
805
|
+
}) => Partial<VirtualizerOptions<HTMLDivElement>>);
|
|
806
|
+
// virtualizerProps?:
|
|
807
|
+
// | Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>
|
|
808
|
+
// | (({
|
|
809
|
+
// table,
|
|
810
|
+
// }: {
|
|
811
|
+
// table: MRT_TableInstance<TData>;
|
|
812
|
+
// }) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>);
|
|
822
813
|
};
|
|
823
814
|
|
|
824
815
|
export default <TData extends Record<string, any> = {}>({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { FC, RefObject, useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useVirtual } from 'react-virtual';
|
|
3
|
+
// import { useVirtualizer, Virtualizer } from '@tanstack/react-virtual';
|
|
3
4
|
import { TableBody } from '@mui/material';
|
|
4
5
|
import { MRT_TableBodyRow } from './MRT_TableBodyRow';
|
|
5
6
|
import { rankGlobalFuzzy } from '../sortingFns';
|
|
@@ -23,7 +24,7 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
23
24
|
virtualizerProps,
|
|
24
25
|
},
|
|
25
26
|
} = table;
|
|
26
|
-
const {
|
|
27
|
+
const { globalFilter, pagination, sorting } = getState();
|
|
27
28
|
|
|
28
29
|
const tableBodyProps =
|
|
29
30
|
muiTableBodyProps instanceof Function
|
|
@@ -61,28 +62,47 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
61
62
|
globalFilter,
|
|
62
63
|
]);
|
|
63
64
|
|
|
64
|
-
const rowVirtualizer
|
|
65
|
-
?
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
overscan: 10,
|
|
65
|
+
const rowVirtualizer = enableRowVirtualization
|
|
66
|
+
? useVirtual({
|
|
67
|
+
size: rows.length,
|
|
68
|
+
parentRef: tableContainerRef,
|
|
69
|
+
overscan: 15,
|
|
70
70
|
...vProps,
|
|
71
71
|
})
|
|
72
72
|
: ({} as any);
|
|
73
73
|
|
|
74
|
+
// const rowVirtualizer: Virtualizer = enableRowVirtualization
|
|
75
|
+
// ? useVirtualizer({
|
|
76
|
+
// count: rows.length,
|
|
77
|
+
// estimateSize: () => (density === 'compact' ? 25 : 50),
|
|
78
|
+
// getScrollElement: () => tableContainerRef.current as HTMLDivElement,
|
|
79
|
+
// overscan: 15,
|
|
80
|
+
// ...vProps,
|
|
81
|
+
// })
|
|
82
|
+
// : ({} as any);
|
|
83
|
+
|
|
74
84
|
const virtualRows = enableRowVirtualization
|
|
75
|
-
? rowVirtualizer.
|
|
85
|
+
? rowVirtualizer.virtualItems
|
|
76
86
|
: [];
|
|
77
87
|
|
|
88
|
+
// const virtualRows = enableRowVirtualization
|
|
89
|
+
// ? rowVirtualizer.getVirtualItems()
|
|
90
|
+
// : [];
|
|
91
|
+
|
|
78
92
|
let paddingTop = 0;
|
|
79
93
|
let paddingBottom = 0;
|
|
80
94
|
if (enableRowVirtualization) {
|
|
81
95
|
paddingTop = !!virtualRows.length ? virtualRows[0].start : 0;
|
|
82
96
|
paddingBottom = !!virtualRows.length
|
|
83
|
-
? rowVirtualizer.
|
|
97
|
+
? rowVirtualizer.totalSize - virtualRows[virtualRows.length - 1].end
|
|
84
98
|
: 0;
|
|
85
99
|
}
|
|
100
|
+
// if (enableRowVirtualization) {
|
|
101
|
+
// paddingTop = !!virtualRows.length ? virtualRows[0].start : 0;
|
|
102
|
+
// paddingBottom = !!virtualRows.length
|
|
103
|
+
// ? rowVirtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end
|
|
104
|
+
// : 0;
|
|
105
|
+
// }
|
|
86
106
|
|
|
87
107
|
return (
|
|
88
108
|
<TableBody {...tableBodyProps}>
|
|
@@ -91,7 +111,6 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
91
111
|
<td style={{ height: `${paddingTop}px` }} />
|
|
92
112
|
</tr>
|
|
93
113
|
)}
|
|
94
|
-
{/* @ts-ignore */}
|
|
95
114
|
{(enableRowVirtualization ? virtualRows : rows).map(
|
|
96
115
|
(rowOrVirtualRow: any, rowIndex: number) => {
|
|
97
116
|
const row = enableRowVirtualization
|
|
@@ -156,7 +156,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
156
156
|
|
|
157
157
|
const draggingBorder =
|
|
158
158
|
currentDraggingColumn?.id === column.id
|
|
159
|
-
? `1px dashed ${theme.palette.
|
|
159
|
+
? `1px dashed ${theme.palette.text.secondary}`
|
|
160
160
|
: currentHoveredColumn?.id === column.id
|
|
161
161
|
? `2px dashed ${theme.palette.primary.main}`
|
|
162
162
|
: undefined;
|
|
@@ -35,7 +35,7 @@ export const MRT_TableBodyRow: FC<Props> = ({ row, rowIndex, table }) => {
|
|
|
35
35
|
|
|
36
36
|
const draggingBorder =
|
|
37
37
|
currentDraggingRow?.id === row.id
|
|
38
|
-
? `1px dashed ${theme.palette.
|
|
38
|
+
? `1px dashed ${theme.palette.text.secondary}`
|
|
39
39
|
: currentHoveredRow?.id === row.id
|
|
40
40
|
? `2px dashed ${theme.palette.primary.main}`
|
|
41
41
|
: undefined;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { Box, IconButton, Tooltip } from '@mui/material';
|
|
3
3
|
import type { MRT_Column, MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
|
-
interface Props {
|
|
6
|
-
column: MRT_Column
|
|
7
|
-
table: MRT_TableInstance
|
|
5
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
6
|
+
column: MRT_Column<TData>;
|
|
7
|
+
table: MRT_TableInstance<TData>;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const MRT_ColumnPinningButtons
|
|
10
|
+
export const MRT_ColumnPinningButtons = <
|
|
11
|
+
TData extends Record<string, any> = {},
|
|
12
|
+
>({
|
|
13
|
+
column,
|
|
14
|
+
table,
|
|
15
|
+
}: Props<TData>) => {
|
|
11
16
|
const {
|
|
12
17
|
options: {
|
|
13
18
|
icons: { PushPinIcon },
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
|
-
interface Props extends
|
|
6
|
-
|
|
5
|
+
interface Props<TData extends Record<string, any> = {}>
|
|
6
|
+
extends IconButtonProps {
|
|
7
|
+
table: MRT_TableInstance<TData>;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export const MRT_FullScreenToggleButton
|
|
10
|
+
export const MRT_FullScreenToggleButton = <
|
|
11
|
+
TData extends Record<string, any> = {},
|
|
12
|
+
>({
|
|
13
|
+
table,
|
|
14
|
+
...rest
|
|
15
|
+
}: Props<TData>) => {
|
|
10
16
|
const {
|
|
11
17
|
getState,
|
|
12
18
|
options: {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
2
|
-
import React, { DragEventHandler
|
|
2
|
+
import React, { DragEventHandler } from 'react';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
|
-
interface Props {
|
|
5
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
6
6
|
iconButtonProps?: IconButtonProps;
|
|
7
7
|
onDragStart: DragEventHandler<HTMLButtonElement>;
|
|
8
8
|
onDragEnd: DragEventHandler<HTMLButtonElement>;
|
|
9
|
-
table: MRT_TableInstance
|
|
9
|
+
table: MRT_TableInstance<TData>;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const MRT_GrabHandleButton
|
|
12
|
+
export const MRT_GrabHandleButton = <TData extends Record<string, any> = {}>({
|
|
13
13
|
iconButtonProps,
|
|
14
14
|
onDragEnd,
|
|
15
15
|
onDragStart,
|
|
16
16
|
table,
|
|
17
|
-
}) => {
|
|
17
|
+
}: Props<TData>) => {
|
|
18
18
|
const {
|
|
19
19
|
options: {
|
|
20
20
|
icons: { DragHandleIcon },
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { MouseEvent, useState } from 'react';
|
|
2
2
|
import { IconButton, Tooltip, IconButtonProps } from '@mui/material';
|
|
3
3
|
import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
|
|
4
4
|
import { MRT_TableInstance } from '..';
|
|
5
5
|
|
|
6
|
-
interface Props extends
|
|
7
|
-
|
|
6
|
+
interface Props<TData extends Record<string, any> = {}>
|
|
7
|
+
extends IconButtonProps {
|
|
8
|
+
table: MRT_TableInstance<TData>;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
export const MRT_ShowHideColumnsButton
|
|
11
|
+
export const MRT_ShowHideColumnsButton = <
|
|
12
|
+
TData extends Record<string, any> = {},
|
|
13
|
+
>({
|
|
14
|
+
table,
|
|
15
|
+
...rest
|
|
16
|
+
}: Props<TData>) => {
|
|
11
17
|
const {
|
|
12
18
|
options: {
|
|
13
19
|
icons: { ViewColumnIcon },
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
|
-
interface Props extends
|
|
6
|
-
|
|
5
|
+
interface Props<TData extends Record<string, any> = {}>
|
|
6
|
+
extends IconButtonProps {
|
|
7
|
+
table: MRT_TableInstance<TData>;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export const MRT_ToggleDensePaddingButton
|
|
10
|
+
export const MRT_ToggleDensePaddingButton = <
|
|
11
|
+
TData extends Record<string, any> = {},
|
|
12
|
+
>({
|
|
13
|
+
table,
|
|
14
|
+
...rest
|
|
15
|
+
}: Props<TData>) => {
|
|
10
16
|
const {
|
|
11
17
|
getState,
|
|
12
18
|
options: {
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
|
-
interface Props extends
|
|
6
|
-
|
|
5
|
+
interface Props<TData extends Record<string, any> = {}>
|
|
6
|
+
extends IconButtonProps {
|
|
7
|
+
table: MRT_TableInstance<TData>;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export const MRT_ToggleFiltersButton
|
|
10
|
+
export const MRT_ToggleFiltersButton = <
|
|
11
|
+
TData extends Record<string, any> = {},
|
|
12
|
+
>({
|
|
13
|
+
table,
|
|
14
|
+
...rest
|
|
15
|
+
}: Props<TData>) => {
|
|
10
16
|
const {
|
|
11
17
|
getState,
|
|
12
18
|
options: {
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
|
-
interface Props extends
|
|
6
|
-
|
|
5
|
+
interface Props<TData extends Record<string, any> = {}>
|
|
6
|
+
extends IconButtonProps {
|
|
7
|
+
table: MRT_TableInstance<TData>;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export const MRT_ToggleGlobalFilterButton
|
|
10
|
+
export const MRT_ToggleGlobalFilterButton = <
|
|
11
|
+
TData extends Record<string, any> = {},
|
|
12
|
+
>({
|
|
13
|
+
table,
|
|
14
|
+
...rest
|
|
15
|
+
}: Props<TData>) => {
|
|
10
16
|
const {
|
|
11
17
|
getState,
|
|
12
18
|
options: {
|
|
@@ -83,7 +83,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
|
83
83
|
|
|
84
84
|
const draggingBorder =
|
|
85
85
|
currentDraggingColumn?.id === column.id
|
|
86
|
-
? `1px dashed ${theme.palette.
|
|
86
|
+
? `1px dashed ${theme.palette.text.secondary}`
|
|
87
87
|
: currentHoveredColumn?.id === column.id
|
|
88
88
|
? `2px dashed ${theme.palette.primary.main}`
|
|
89
89
|
: undefined;
|
package/src/index.tsx
CHANGED
|
@@ -3,7 +3,21 @@ export default MaterialReactTable;
|
|
|
3
3
|
export * from './MaterialReactTable';
|
|
4
4
|
|
|
5
5
|
import type { MRT_Icons } from './icons';
|
|
6
|
-
export type { MRT_Icons };
|
|
7
|
-
|
|
8
6
|
import type { MRT_Localization } from './localization';
|
|
9
|
-
export type { MRT_Localization };
|
|
7
|
+
export type { MRT_Localization, MRT_Icons };
|
|
8
|
+
|
|
9
|
+
import { MRT_FullScreenToggleButton } from './buttons/MRT_FullScreenToggleButton';
|
|
10
|
+
import { MRT_GlobalFilterTextField } from './inputs/MRT_GlobalFilterTextField';
|
|
11
|
+
import { MRT_ShowHideColumnsButton } from './buttons/MRT_ShowHideColumnsButton';
|
|
12
|
+
import { MRT_ToggleDensePaddingButton } from './buttons/MRT_ToggleDensePaddingButton';
|
|
13
|
+
import { MRT_ToggleFiltersButton } from './buttons/MRT_ToggleFiltersButton';
|
|
14
|
+
import { MRT_ToggleGlobalFilterButton } from './buttons/MRT_ToggleGlobalFilterButton';
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
MRT_FullScreenToggleButton,
|
|
18
|
+
MRT_GlobalFilterTextField,
|
|
19
|
+
MRT_ShowHideColumnsButton,
|
|
20
|
+
MRT_ToggleDensePaddingButton,
|
|
21
|
+
MRT_ToggleFiltersButton,
|
|
22
|
+
MRT_ToggleGlobalFilterButton,
|
|
23
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
ChangeEvent,
|
|
3
|
-
FC,
|
|
4
3
|
MouseEvent,
|
|
5
4
|
useCallback,
|
|
6
5
|
useState,
|
|
@@ -16,11 +15,15 @@ import {
|
|
|
16
15
|
import { MRT_FilterOptionMenu } from '../menus/MRT_FilterOptionMenu';
|
|
17
16
|
import { MRT_TableInstance } from '..';
|
|
18
17
|
|
|
19
|
-
interface Props {
|
|
20
|
-
table: MRT_TableInstance
|
|
18
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
19
|
+
table: MRT_TableInstance<TData>;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
export const MRT_GlobalFilterTextField
|
|
22
|
+
export const MRT_GlobalFilterTextField = <
|
|
23
|
+
TData extends Record<string, any> = {},
|
|
24
|
+
>({
|
|
25
|
+
table,
|
|
26
|
+
}: Props<TData>) => {
|
|
24
27
|
const {
|
|
25
28
|
getState,
|
|
26
29
|
setGlobalFilter,
|