material-react-table 0.5.4 → 0.5.7
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/MaterialReactTable.d.ts +3 -1
- package/dist/icons.d.ts +3 -0
- package/dist/localization.d.ts +4 -0
- package/dist/material-react-table.cjs.development.js +243 -158
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +244 -159
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +4 -0
- package/dist/menus/{MRT_FilterMenu.d.ts → MRT_FilterTypeMenu.d.ts} +1 -1
- package/package.json +6 -7
- package/src/MaterialReactTable.tsx +8 -0
- package/src/body/MRT_TableBodyCell.tsx +12 -3
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +9 -3
- package/src/footer/MRT_TableFooterCell.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +47 -1
- package/src/{icons.tsx → icons.ts} +9 -0
- package/src/inputs/MRT_FilterTextField.tsx +11 -7
- package/src/localization.ts +11 -3
- package/src/menus/MRT_ColumnActionMenu.tsx +122 -98
- package/src/menus/{MRT_FilterMenu.tsx → MRT_FilterTypeMenu.tsx} +12 -9
- package/src/menus/MRT_RowActionMenu.tsx +14 -3
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +1 -1
- package/src/table/MRT_TableContainer.tsx +7 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React, { FC, useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Menu, MenuItem } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_FilterType, MRT_HeaderGroup } from '..';
|
|
5
|
+
import { commonMenuItemStyles } from './MRT_ColumnActionMenu';
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
interface Props {
|
|
7
9
|
anchorEl: HTMLElement | null;
|
|
@@ -10,7 +12,7 @@ interface Props {
|
|
|
10
12
|
onSelect?: () => void;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
export const
|
|
15
|
+
export const MRT_FilterTypeMenu: FC<Props> = ({
|
|
14
16
|
anchorEl,
|
|
15
17
|
column,
|
|
16
18
|
onSelect,
|
|
@@ -68,7 +70,7 @@ export const MRT_FilterMenu: FC<Props> = ({
|
|
|
68
70
|
[],
|
|
69
71
|
);
|
|
70
72
|
|
|
71
|
-
const
|
|
73
|
+
const handleSelectFilterType = (value: MRT_FilterType) => {
|
|
72
74
|
setAnchorEl(null);
|
|
73
75
|
setCurrentFilterTypes((prev: { [key: string]: MRT_FilterType }) => ({
|
|
74
76
|
...prev,
|
|
@@ -85,21 +87,22 @@ export const MRT_FilterMenu: FC<Props> = ({
|
|
|
85
87
|
return (
|
|
86
88
|
<Menu
|
|
87
89
|
anchorEl={anchorEl}
|
|
88
|
-
open={!!anchorEl}
|
|
89
90
|
anchorOrigin={{ vertical: 'center', horizontal: 'right' }}
|
|
90
91
|
onClose={() => setAnchorEl(null)}
|
|
92
|
+
open={!!anchorEl}
|
|
93
|
+
MenuListProps={{
|
|
94
|
+
dense: tableInstance.state.densePadding,
|
|
95
|
+
disablePadding: true,
|
|
96
|
+
}}
|
|
91
97
|
>
|
|
92
|
-
<Typography sx={{ fontWeight: 'bold', p: '1rem', fontSize: '1.1rem' }}>
|
|
93
|
-
{localization.filterMenuTitle}
|
|
94
|
-
</Typography>
|
|
95
|
-
<Divider />
|
|
96
98
|
{filterTypes.map(({ type, label, divider }) => (
|
|
97
99
|
<MenuItem
|
|
98
100
|
divider={divider}
|
|
99
101
|
key={type}
|
|
100
|
-
onClick={() =>
|
|
102
|
+
onClick={() => handleSelectFilterType(type)}
|
|
101
103
|
selected={type === filterType}
|
|
102
104
|
value={type}
|
|
105
|
+
sx={commonMenuItemStyles}
|
|
103
106
|
>
|
|
104
107
|
{label}
|
|
105
108
|
</MenuItem>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { Menu, MenuItem } from '@mui/material';
|
|
2
|
+
import { ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_Row } from '..';
|
|
5
|
+
import { commonMenuItemStyles } from './MRT_ColumnActionMenu';
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
interface Props {
|
|
7
9
|
anchorEl: HTMLElement | null;
|
|
@@ -29,10 +31,19 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
29
31
|
anchorEl={anchorEl}
|
|
30
32
|
open={!!anchorEl}
|
|
31
33
|
onClose={() => setAnchorEl(null)}
|
|
34
|
+
MenuListProps={{
|
|
35
|
+
dense: tableInstance.state.densePadding,
|
|
36
|
+
disablePadding: true,
|
|
37
|
+
}}
|
|
32
38
|
>
|
|
33
39
|
{enableRowEditing && (
|
|
34
|
-
<MenuItem
|
|
35
|
-
<
|
|
40
|
+
<MenuItem onClick={handleEdit} sx={commonMenuItemStyles}>
|
|
41
|
+
<ListItemIcon>
|
|
42
|
+
<EditIcon />
|
|
43
|
+
</ListItemIcon>
|
|
44
|
+
<ListItemText sx={commonMenuItemStyles}>
|
|
45
|
+
{localization.rowActionMenuItemEdit}
|
|
46
|
+
</ListItemText>
|
|
36
47
|
</MenuItem>
|
|
37
48
|
)}
|
|
38
49
|
{renderRowActionMenuItems?.(row, tableInstance, () =>
|
|
@@ -8,7 +8,7 @@ interface Props {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const MRT_ShowHideColumnsMenu: FC<Props> = ({ column }) => {
|
|
11
|
-
const isParentHeader =
|
|
11
|
+
const isParentHeader = !!column?.columns?.length;
|
|
12
12
|
|
|
13
13
|
const allChildColumnsVisible =
|
|
14
14
|
isParentHeader &&
|
|
@@ -19,6 +19,7 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
19
19
|
hideToolbarTop,
|
|
20
20
|
isFetching,
|
|
21
21
|
isLoading,
|
|
22
|
+
muiLinearProgressProps,
|
|
22
23
|
muiTableContainerProps,
|
|
23
24
|
tableInstance,
|
|
24
25
|
} = useMRT();
|
|
@@ -47,6 +48,11 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
47
48
|
? muiTableContainerProps(tableInstance)
|
|
48
49
|
: muiTableContainerProps;
|
|
49
50
|
|
|
51
|
+
const linearProgressProps =
|
|
52
|
+
muiLinearProgressProps instanceof Function
|
|
53
|
+
? muiLinearProgressProps(tableInstance)
|
|
54
|
+
: muiLinearProgressProps;
|
|
55
|
+
|
|
50
56
|
return (
|
|
51
57
|
<TableContainer
|
|
52
58
|
component={Paper}
|
|
@@ -67,7 +73,7 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
67
73
|
>
|
|
68
74
|
{!hideToolbarTop && <MRT_ToolbarTop />}
|
|
69
75
|
<Collapse in={isFetching || isLoading} unmountOnExit>
|
|
70
|
-
<LinearProgress />
|
|
76
|
+
<LinearProgress {...linearProgressProps} />
|
|
71
77
|
</Collapse>
|
|
72
78
|
<Box
|
|
73
79
|
sx={{
|