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,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,12 +1,12 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { Box } from '@mui/material';
|
|
3
3
|
import { MRT_FullScreenToggleButton } from '../buttons/MRT_FullScreenToggleButton';
|
|
4
|
+
import { MRT_GlobalFilterTextField } from '../inputs/MRT_GlobalFilterTextField';
|
|
4
5
|
import { MRT_ShowHideColumnsButton } from '../buttons/MRT_ShowHideColumnsButton';
|
|
5
6
|
import { MRT_ToggleDensePaddingButton } from '../buttons/MRT_ToggleDensePaddingButton';
|
|
6
7
|
import { MRT_ToggleFiltersButton } from '../buttons/MRT_ToggleFiltersButton';
|
|
7
8
|
import { MRT_ToggleGlobalFilterButton } from '../buttons/MRT_ToggleGlobalFilterButton';
|
|
8
|
-
import { MRT_TableInstance } from '..';
|
|
9
|
-
import { MRT_GlobalFilterTextField } from '../inputs/MRT_GlobalFilterTextField';
|
|
9
|
+
import type { MRT_TableInstance } from '..';
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
12
|
table: MRT_TableInstance;
|
|
@@ -37,11 +37,6 @@ export const MRT_ToolbarInternalButtons: FC<Props> = ({ table }) => {
|
|
|
37
37
|
}}
|
|
38
38
|
>
|
|
39
39
|
{renderToolbarInternalActions?.({
|
|
40
|
-
MRT_FullScreenToggleButton,
|
|
41
|
-
MRT_ShowHideColumnsButton,
|
|
42
|
-
MRT_ToggleDensePaddingButton,
|
|
43
|
-
MRT_ToggleFiltersButton,
|
|
44
|
-
MRT_ToggleGlobalFilterButton,
|
|
45
40
|
table,
|
|
46
41
|
}) ?? (
|
|
47
42
|
<>
|