material-react-table 0.33.6 → 0.34.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/MaterialReactTable.d.ts +6 -21
- 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 +526 -14
- 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 +6 -21
- 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 +519 -15
- 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 +37 -22
- package/package.json +5 -5
- package/src/MaterialReactTable.tsx +11 -24
- package/src/body/MRT_TableBody.tsx +30 -11
- 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/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
|
|
|
@@ -652,23 +652,8 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
652
652
|
row: MRT_Row<TData>;
|
|
653
653
|
table: MRT_TableInstance<TData>;
|
|
654
654
|
}) => 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
|
-
}>;
|
|
655
|
+
renderToolbarInternalActions?: ({ table, }: {
|
|
656
|
+
table: MRT_TableInstance<TData>;
|
|
672
657
|
}) => ReactNode;
|
|
673
658
|
renderTopToolbarCustomActions?: ({ table, }: {
|
|
674
659
|
table: MRT_TableInstance<TData>;
|
|
@@ -678,10 +663,40 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
678
663
|
selectAllMode?: 'all' | 'page';
|
|
679
664
|
state?: Partial<MRT_TableState<TData>>;
|
|
680
665
|
tableId?: string;
|
|
681
|
-
virtualizerProps?: Partial<
|
|
666
|
+
virtualizerProps?: Partial<Options<HTMLDivElement>> | (({ table, }: {
|
|
682
667
|
table: MRT_TableInstance<TData>;
|
|
683
|
-
}) => Partial<
|
|
668
|
+
}) => Partial<Options<HTMLDivElement>>);
|
|
684
669
|
};
|
|
685
670
|
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
671
|
|
|
687
|
-
|
|
672
|
+
interface Props$5<TData extends Record<string, any> = {}> extends IconButtonProps {
|
|
673
|
+
table: MRT_TableInstance<TData>;
|
|
674
|
+
}
|
|
675
|
+
declare const MRT_FullScreenToggleButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props$5<TData>) => JSX.Element;
|
|
676
|
+
|
|
677
|
+
interface Props$4<TData extends Record<string, any> = {}> {
|
|
678
|
+
table: MRT_TableInstance<TData>;
|
|
679
|
+
}
|
|
680
|
+
declare const MRT_GlobalFilterTextField: <TData extends Record<string, any> = {}>({ table, }: Props$4<TData>) => JSX.Element;
|
|
681
|
+
|
|
682
|
+
interface Props$3<TData extends Record<string, any> = {}> extends IconButtonProps {
|
|
683
|
+
table: MRT_TableInstance<TData>;
|
|
684
|
+
}
|
|
685
|
+
declare const MRT_ShowHideColumnsButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props$3<TData>) => JSX.Element;
|
|
686
|
+
|
|
687
|
+
interface Props$2<TData extends Record<string, any> = {}> extends IconButtonProps {
|
|
688
|
+
table: MRT_TableInstance<TData>;
|
|
689
|
+
}
|
|
690
|
+
declare const MRT_ToggleDensePaddingButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props$2<TData>) => JSX.Element;
|
|
691
|
+
|
|
692
|
+
interface Props$1<TData extends Record<string, any> = {}> extends IconButtonProps {
|
|
693
|
+
table: MRT_TableInstance<TData>;
|
|
694
|
+
}
|
|
695
|
+
declare const MRT_ToggleFiltersButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props$1<TData>) => JSX.Element;
|
|
696
|
+
|
|
697
|
+
interface Props<TData extends Record<string, any> = {}> extends IconButtonProps {
|
|
698
|
+
table: MRT_TableInstance<TData>;
|
|
699
|
+
}
|
|
700
|
+
declare const MRT_ToggleGlobalFilterButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props<TData>) => JSX.Element;
|
|
701
|
+
|
|
702
|
+
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.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.",
|
|
@@ -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';
|
|
@@ -779,28 +779,8 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
779
779
|
}) => ReactNode;
|
|
780
780
|
renderToolbarInternalActions?: ({
|
|
781
781
|
table,
|
|
782
|
-
MRT_ToggleGlobalFilterButton,
|
|
783
|
-
MRT_ToggleFiltersButton,
|
|
784
|
-
MRT_ShowHideColumnsButton,
|
|
785
|
-
MRT_ToggleDensePaddingButton,
|
|
786
|
-
MRT_FullScreenToggleButton,
|
|
787
782
|
}: {
|
|
788
783
|
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
784
|
}) => ReactNode;
|
|
805
785
|
renderTopToolbarCustomActions?: ({
|
|
806
786
|
table,
|
|
@@ -813,12 +793,19 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
813
793
|
state?: Partial<MRT_TableState<TData>>;
|
|
814
794
|
tableId?: string;
|
|
815
795
|
virtualizerProps?:
|
|
816
|
-
| Partial<VirtualizerOptions<HTMLDivElement
|
|
796
|
+
| Partial<VirtualizerOptions<HTMLDivElement>>
|
|
817
797
|
| (({
|
|
818
798
|
table,
|
|
819
799
|
}: {
|
|
820
800
|
table: MRT_TableInstance<TData>;
|
|
821
|
-
}) => Partial<VirtualizerOptions<HTMLDivElement
|
|
801
|
+
}) => Partial<VirtualizerOptions<HTMLDivElement>>);
|
|
802
|
+
// virtualizerProps?:
|
|
803
|
+
// | Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>
|
|
804
|
+
// | (({
|
|
805
|
+
// table,
|
|
806
|
+
// }: {
|
|
807
|
+
// table: MRT_TableInstance<TData>;
|
|
808
|
+
// }) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>);
|
|
822
809
|
};
|
|
823
810
|
|
|
824
811
|
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
|
|
@@ -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: {
|
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,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import { Box, Menu, MenuItem } from '@mui/material';
|
|
3
3
|
import type { MRT_FilterOption, MRT_Header, MRT_TableInstance } from '..';
|
|
4
4
|
import { MRT_Localization } from '../localization';
|
|
@@ -97,21 +97,21 @@ export const internalFilterOptions = (
|
|
|
97
97
|
},
|
|
98
98
|
];
|
|
99
99
|
|
|
100
|
-
interface Props {
|
|
100
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
101
101
|
anchorEl: HTMLElement | null;
|
|
102
102
|
header?: MRT_Header;
|
|
103
103
|
onSelect?: () => void;
|
|
104
104
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
105
|
-
table: MRT_TableInstance
|
|
105
|
+
table: MRT_TableInstance<TData>;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
export const MRT_FilterOptionMenu
|
|
108
|
+
export const MRT_FilterOptionMenu = <TData extends Record<string, any> = {}>({
|
|
109
109
|
anchorEl,
|
|
110
110
|
header,
|
|
111
111
|
onSelect,
|
|
112
112
|
setAnchorEl,
|
|
113
113
|
table,
|
|
114
|
-
}) => {
|
|
114
|
+
}: Props<TData>) => {
|
|
115
115
|
const {
|
|
116
116
|
getState,
|
|
117
117
|
options: {
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
2
|
import { Button, Menu, Divider, Box } from '@mui/material';
|
|
3
3
|
import { MRT_ShowHideColumnsMenuItems } from './MRT_ShowHideColumnsMenuItems';
|
|
4
4
|
import type { MRT_Column, MRT_TableInstance } from '..';
|
|
5
5
|
import { getDefaultColumnOrderIds } from '../column.utils';
|
|
6
6
|
|
|
7
|
-
interface Props {
|
|
7
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
8
8
|
anchorEl: HTMLElement | null;
|
|
9
9
|
isSubMenu?: boolean;
|
|
10
10
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
11
|
-
table: MRT_TableInstance
|
|
11
|
+
table: MRT_TableInstance<TData>;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const MRT_ShowHideColumnsMenu
|
|
14
|
+
export const MRT_ShowHideColumnsMenu = <
|
|
15
|
+
TData extends Record<string, any> = {},
|
|
16
|
+
>({
|
|
15
17
|
anchorEl,
|
|
16
18
|
isSubMenu,
|
|
17
19
|
setAnchorEl,
|
|
18
20
|
table,
|
|
19
|
-
}) => {
|
|
21
|
+
}: Props<TData>) => {
|
|
20
22
|
const {
|
|
21
23
|
getAllColumns,
|
|
22
24
|
getAllLeafColumns,
|
|
@@ -60,10 +62,10 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
60
62
|
getCenterLeafColumns(),
|
|
61
63
|
getLeftLeafColumns(),
|
|
62
64
|
getRightLeafColumns(),
|
|
63
|
-
]) as MRT_Column[];
|
|
65
|
+
]) as MRT_Column<TData>[];
|
|
64
66
|
|
|
65
67
|
const [currentHoveredColumn, setCurrentHoveredColumn] =
|
|
66
|
-
useState<MRT_Column | null>(null);
|
|
68
|
+
useState<MRT_Column<TData> | null>(null);
|
|
67
69
|
|
|
68
70
|
return (
|
|
69
71
|
<Menu
|