material-react-table 0.33.4 → 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/README.md +1 -0
- 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 +2820 -0
- package/dist/cjs/index.js.map +1 -0
- 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 +2806 -0
- package/dist/esm/material-react-table.esm.js.map +1 -0
- 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 +9 -10
- package/src/MaterialReactTable.tsx +11 -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/table/MRT_TableContainer.tsx +15 -4
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +2 -7
- package/dist/cjs/index.min.js +0 -7398
- package/dist/cjs/index.min.js.map +0 -1
- package/dist/esm/material-react-table.esm.min.js +0 -7374
- package/dist/esm/material-react-table.esm.min.js.map +0 -1
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.",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"bugs": {
|
|
20
20
|
"url": "https://github.com/KevinVandy/material-react-table/issues"
|
|
21
21
|
},
|
|
22
|
-
"main": "dist/cjs/index.
|
|
23
|
-
"module": "dist/esm/material-react-table.esm.
|
|
22
|
+
"main": "dist/cjs/index.js",
|
|
23
|
+
"module": "dist/esm/material-react-table.esm.js",
|
|
24
24
|
"typings": "dist/index.d.ts",
|
|
25
25
|
"files": [
|
|
26
26
|
"dist",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
],
|
|
29
29
|
"size-limit": [
|
|
30
30
|
{
|
|
31
|
-
"path": "dist/cjs/index.
|
|
31
|
+
"path": "dist/cjs/index.js",
|
|
32
32
|
"limit": "50 KB"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
|
-
"path": "dist/esm/material-react-table.esm.
|
|
35
|
+
"path": "dist/esm/material-react-table.esm.js",
|
|
36
36
|
"limit": "50 KB"
|
|
37
37
|
}
|
|
38
38
|
],
|
|
@@ -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",
|
|
@@ -81,7 +81,6 @@
|
|
|
81
81
|
"rollup": "^2.77.2",
|
|
82
82
|
"rollup-plugin-dts": "^4.2.2",
|
|
83
83
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
84
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
85
84
|
"size-limit": "^8.0.0",
|
|
86
85
|
"storybook-dark-mode": "^1.1.0",
|
|
87
86
|
"tslib": "^2.4.0",
|
|
@@ -96,7 +95,7 @@
|
|
|
96
95
|
},
|
|
97
96
|
"dependencies": {
|
|
98
97
|
"@tanstack/match-sorter-utils": "8.1.1",
|
|
99
|
-
"@tanstack/react-table": "8.5.
|
|
100
|
-
"
|
|
98
|
+
"@tanstack/react-table": "8.5.11",
|
|
99
|
+
"react-virtual": "^2.10.4"
|
|
101
100
|
}
|
|
102
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
|
|
@@ -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,
|
|
@@ -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
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
Dispatch,
|
|
3
3
|
DragEvent,
|
|
4
|
-
FC,
|
|
5
4
|
SetStateAction,
|
|
5
|
+
useRef,
|
|
6
6
|
useState,
|
|
7
7
|
} from 'react';
|
|
8
8
|
import {
|
|
@@ -18,23 +18,25 @@ import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
|
|
18
18
|
import { reorderColumn } from '../column.utils';
|
|
19
19
|
import type { MRT_Column, MRT_TableInstance } from '..';
|
|
20
20
|
|
|
21
|
-
interface Props {
|
|
22
|
-
allColumns: MRT_Column[];
|
|
23
|
-
column: MRT_Column
|
|
24
|
-
currentHoveredColumn: MRT_Column | null;
|
|
21
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
22
|
+
allColumns: MRT_Column<TData>[];
|
|
23
|
+
column: MRT_Column<TData>;
|
|
24
|
+
currentHoveredColumn: MRT_Column<TData> | null;
|
|
25
25
|
isSubMenu?: boolean;
|
|
26
|
-
setCurrentHoveredColumn: Dispatch<SetStateAction<MRT_Column | null>>;
|
|
27
|
-
table: MRT_TableInstance
|
|
26
|
+
setCurrentHoveredColumn: Dispatch<SetStateAction<MRT_Column<TData> | null>>;
|
|
27
|
+
table: MRT_TableInstance<TData>;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export const MRT_ShowHideColumnsMenuItems
|
|
30
|
+
export const MRT_ShowHideColumnsMenuItems = <
|
|
31
|
+
TData extends Record<string, any> = {},
|
|
32
|
+
>({
|
|
31
33
|
allColumns,
|
|
32
34
|
currentHoveredColumn,
|
|
33
35
|
setCurrentHoveredColumn,
|
|
34
36
|
column,
|
|
35
37
|
isSubMenu,
|
|
36
38
|
table,
|
|
37
|
-
}) => {
|
|
39
|
+
}: Props<TData>) => {
|
|
38
40
|
const {
|
|
39
41
|
getState,
|
|
40
42
|
options: {
|
|
@@ -54,9 +56,9 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
54
56
|
(columnDefType === 'group' &&
|
|
55
57
|
column.getLeafColumns().some((col) => col.getIsVisible()));
|
|
56
58
|
|
|
57
|
-
const handleToggleColumnHidden = (column: MRT_Column) => {
|
|
59
|
+
const handleToggleColumnHidden = (column: MRT_Column<TData>) => {
|
|
58
60
|
if (columnDefType === 'group') {
|
|
59
|
-
column?.columns?.forEach?.((childColumn: MRT_Column) => {
|
|
61
|
+
column?.columns?.forEach?.((childColumn: MRT_Column<TData>) => {
|
|
60
62
|
childColumn.toggleVisibility(!switchChecked);
|
|
61
63
|
});
|
|
62
64
|
} else {
|
|
@@ -64,7 +66,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
64
66
|
}
|
|
65
67
|
};
|
|
66
68
|
|
|
67
|
-
const menuItemRef =
|
|
69
|
+
const menuItemRef = useRef<HTMLElement>(null);
|
|
68
70
|
|
|
69
71
|
const [isDragging, setIsDragging] = useState(false);
|
|
70
72
|
|
|
@@ -172,7 +174,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
172
174
|
)}
|
|
173
175
|
</Box>
|
|
174
176
|
</MenuItem>
|
|
175
|
-
{column.columns?.map((c: MRT_Column
|
|
177
|
+
{column.columns?.map((c: MRT_Column<TData>, i) => (
|
|
176
178
|
<MRT_ShowHideColumnsMenuItems
|
|
177
179
|
allColumns={allColumns}
|
|
178
180
|
column={c}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
FC,
|
|
3
|
+
RefObject,
|
|
4
|
+
useEffect,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'react';
|
|
2
9
|
import { TableContainer } from '@mui/material';
|
|
3
10
|
import { MRT_Table } from './MRT_Table';
|
|
4
11
|
import type { MRT_TableInstance } from '..';
|
|
@@ -29,6 +36,9 @@ export const MRT_TableContainer: FC<Props> = ({ table }) => {
|
|
|
29
36
|
? muiTableContainerProps({ table })
|
|
30
37
|
: muiTableContainerProps;
|
|
31
38
|
|
|
39
|
+
const tableContainerRef =
|
|
40
|
+
tableContainerProps?.ref ?? useRef<HTMLDivElement>(null);
|
|
41
|
+
|
|
32
42
|
useIsomorphicLayoutEffect(() => {
|
|
33
43
|
const topToolbarHeight =
|
|
34
44
|
typeof document !== 'undefined'
|
|
@@ -45,8 +55,6 @@ export const MRT_TableContainer: FC<Props> = ({ table }) => {
|
|
|
45
55
|
setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
|
|
46
56
|
});
|
|
47
57
|
|
|
48
|
-
const tableContainerRef = useRef<HTMLDivElement>(null);
|
|
49
|
-
|
|
50
58
|
return (
|
|
51
59
|
<TableContainer
|
|
52
60
|
ref={tableContainerRef}
|
|
@@ -69,7 +77,10 @@ export const MRT_TableContainer: FC<Props> = ({ table }) => {
|
|
|
69
77
|
...tableContainerProps?.style,
|
|
70
78
|
}}
|
|
71
79
|
>
|
|
72
|
-
<MRT_Table
|
|
80
|
+
<MRT_Table
|
|
81
|
+
tableContainerRef={tableContainerRef as RefObject<HTMLDivElement>}
|
|
82
|
+
table={table}
|
|
83
|
+
/>
|
|
73
84
|
</TableContainer>
|
|
74
85
|
);
|
|
75
86
|
};
|