material-react-table 0.5.4 → 0.5.5
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/icons.d.ts +3 -0
- package/dist/localization.d.ts +4 -0
- package/dist/material-react-table.cjs.development.js +115 -59
- 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 +116 -60
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/{MRT_FilterMenu.d.ts → MRT_FilterTypeMenu.d.ts} +1 -1
- package/package.json +1 -1
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +34 -31
- 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 +40 -13
- package/src/menus/{MRT_FilterMenu.tsx → MRT_FilterTypeMenu.tsx} +17 -19
- package/src/menus/MRT_RowActionMenu.tsx +20 -9
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.5.
|
|
2
|
+
"version": "0.5.5",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material-UI implementation of react-table, inspired by material-table and the mui DataGrid, written from the ground up in TypeScript.",
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
Divider,
|
|
8
8
|
IconButtonProps,
|
|
9
9
|
Box,
|
|
10
|
+
MenuList,
|
|
10
11
|
} from '@mui/material';
|
|
11
12
|
import { useMRT } from '../useMRT';
|
|
12
13
|
import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
|
|
@@ -16,9 +17,9 @@ interface Props extends IconButtonProps {}
|
|
|
16
17
|
|
|
17
18
|
export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
|
|
18
19
|
const {
|
|
19
|
-
tableInstance,
|
|
20
|
-
localization,
|
|
21
20
|
icons: { ViewColumnIcon },
|
|
21
|
+
localization,
|
|
22
|
+
tableInstance,
|
|
22
23
|
} = useMRT();
|
|
23
24
|
|
|
24
25
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
@@ -44,36 +45,38 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
|
|
|
44
45
|
open={!!anchorEl}
|
|
45
46
|
onClose={() => setAnchorEl(null)}
|
|
46
47
|
>
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
<Button
|
|
55
|
-
disabled={
|
|
56
|
-
!tableInstance.getToggleHideAllColumnsProps().checked &&
|
|
57
|
-
!tableInstance.getToggleHideAllColumnsProps().indeterminate
|
|
58
|
-
}
|
|
59
|
-
onClick={() => tableInstance.toggleHideAllColumns(true)}
|
|
60
|
-
>
|
|
61
|
-
{localization.columnShowHideMenuHideAll}
|
|
62
|
-
</Button>
|
|
63
|
-
<Button
|
|
64
|
-
disabled={tableInstance.getToggleHideAllColumnsProps().checked}
|
|
65
|
-
onClick={() => tableInstance.toggleHideAllColumns(false)}
|
|
48
|
+
<MenuList dense={tableInstance.state.densePadding} disablePadding>
|
|
49
|
+
<Box
|
|
50
|
+
sx={{
|
|
51
|
+
display: 'flex',
|
|
52
|
+
justifyContent: 'space-between',
|
|
53
|
+
p: '0 0.5rem 0.5rem 0.5rem',
|
|
54
|
+
}}
|
|
66
55
|
>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
<Button
|
|
57
|
+
disabled={
|
|
58
|
+
!tableInstance.getToggleHideAllColumnsProps().checked &&
|
|
59
|
+
!tableInstance.getToggleHideAllColumnsProps().indeterminate
|
|
60
|
+
}
|
|
61
|
+
onClick={() => tableInstance.toggleHideAllColumns(true)}
|
|
62
|
+
>
|
|
63
|
+
{localization.columnShowHideMenuHideAll}
|
|
64
|
+
</Button>
|
|
65
|
+
<Button
|
|
66
|
+
disabled={tableInstance.getToggleHideAllColumnsProps().checked}
|
|
67
|
+
onClick={() => tableInstance.toggleHideAllColumns(false)}
|
|
68
|
+
>
|
|
69
|
+
{localization.columnShowHideMenuShowAll}
|
|
70
|
+
</Button>
|
|
71
|
+
</Box>
|
|
72
|
+
<Divider />
|
|
73
|
+
{tableInstance.columns.map((column: MRT_ColumnInstance, index) => (
|
|
74
|
+
<MRT_ShowHideColumnsMenu
|
|
75
|
+
key={`${index}-${column.id}`}
|
|
76
|
+
column={column}
|
|
77
|
+
/>
|
|
78
|
+
))}
|
|
79
|
+
</MenuList>
|
|
77
80
|
</Menu>
|
|
78
81
|
</>
|
|
79
82
|
);
|
|
@@ -16,7 +16,7 @@ export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
|
|
|
16
16
|
},
|
|
17
17
|
} = useMRT();
|
|
18
18
|
|
|
19
|
-
const isParentHeader =
|
|
19
|
+
const isParentHeader = !!column?.columns?.length;
|
|
20
20
|
|
|
21
21
|
const mTableFooterCellProps =
|
|
22
22
|
muiTableFooterCellProps instanceof Function
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
Collapse,
|
|
7
7
|
Tooltip,
|
|
8
8
|
Box,
|
|
9
|
+
IconButton,
|
|
9
10
|
} from '@mui/material';
|
|
10
11
|
import { useMRT } from '../useMRT';
|
|
11
12
|
import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
|
|
@@ -33,12 +34,14 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
33
34
|
disableColumnActions,
|
|
34
35
|
disableFilters,
|
|
35
36
|
enableColumnResizing,
|
|
37
|
+
icons: { FilterAltIcon, FilterAltOff },
|
|
36
38
|
localization,
|
|
37
39
|
muiTableHeadCellProps,
|
|
40
|
+
setShowFilters,
|
|
38
41
|
tableInstance,
|
|
39
42
|
} = useMRT();
|
|
40
43
|
|
|
41
|
-
const isParentHeader =
|
|
44
|
+
const isParentHeader = !!column?.columns?.length;
|
|
42
45
|
|
|
43
46
|
const mTableHeadCellProps =
|
|
44
47
|
muiTableHeadCellProps instanceof Function
|
|
@@ -73,6 +76,23 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
73
76
|
column.Header as string,
|
|
74
77
|
);
|
|
75
78
|
|
|
79
|
+
const filterTooltip = !!column.filterValue
|
|
80
|
+
? localization.filterApplied
|
|
81
|
+
.replace('{column}', String(column.Header))
|
|
82
|
+
.replace(
|
|
83
|
+
'{filterType}',
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
localization[
|
|
86
|
+
`filterMenuItem${
|
|
87
|
+
tableInstance.state.currentFilterTypes[column.id]
|
|
88
|
+
.charAt(0)
|
|
89
|
+
.toUpperCase() +
|
|
90
|
+
tableInstance.state.currentFilterTypes[column.id].slice(1)
|
|
91
|
+
}`
|
|
92
|
+
],
|
|
93
|
+
)
|
|
94
|
+
: localization.toggleFilterButtonTitle;
|
|
95
|
+
|
|
76
96
|
const columnHeader = column.render('Header') as string;
|
|
77
97
|
|
|
78
98
|
return (
|
|
@@ -115,6 +135,32 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
115
135
|
/>
|
|
116
136
|
</Tooltip>
|
|
117
137
|
)}
|
|
138
|
+
{!isParentHeader && !!column.canFilter && (
|
|
139
|
+
<Tooltip arrow title={filterTooltip}>
|
|
140
|
+
<IconButton
|
|
141
|
+
onClick={(event) => {
|
|
142
|
+
event.stopPropagation();
|
|
143
|
+
setShowFilters(!tableInstance.state.showFilters);
|
|
144
|
+
}}
|
|
145
|
+
size="small"
|
|
146
|
+
sx={{
|
|
147
|
+
opacity: !!column.filterValue ? 0.8 : 0,
|
|
148
|
+
p: '2px',
|
|
149
|
+
m: 0,
|
|
150
|
+
transition: 'all 0.2s ease-in-out',
|
|
151
|
+
'&:hover': {
|
|
152
|
+
opacity: 0.8,
|
|
153
|
+
},
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
{tableInstance.state.showFilters && !column.filterValue ? (
|
|
157
|
+
<FilterAltOff fontSize="small" />
|
|
158
|
+
) : (
|
|
159
|
+
<FilterAltIcon fontSize="small" />
|
|
160
|
+
)}
|
|
161
|
+
</IconButton>
|
|
162
|
+
</Tooltip>
|
|
163
|
+
)}
|
|
118
164
|
</Box>
|
|
119
165
|
<Box sx={{ alignItems: 'center', display: 'flex', flexWrap: 'nowrap' }}>
|
|
120
166
|
{!disableColumnActions && !isParentHeader && (
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
|
|
1
2
|
import CancelIcon from '@mui/icons-material/Cancel';
|
|
2
3
|
import ClearAllIcon from '@mui/icons-material/ClearAll';
|
|
3
4
|
import CloseIcon from '@mui/icons-material/Close';
|
|
@@ -8,6 +9,8 @@ import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
|
|
|
8
9
|
import EditIcon from '@mui/icons-material/Edit';
|
|
9
10
|
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
|
10
11
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
12
|
+
import FilterAltIcon from '@mui/icons-material/FilterAlt';
|
|
13
|
+
import FilterAltOff from '@mui/icons-material/FilterAltOff';
|
|
11
14
|
import FilterListIcon from '@mui/icons-material/FilterList';
|
|
12
15
|
import FilterListOffIcon from '@mui/icons-material/FilterListOff';
|
|
13
16
|
import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
|
|
@@ -22,6 +25,7 @@ import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
|
|
22
25
|
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
|
23
26
|
|
|
24
27
|
export interface MRT_Icons {
|
|
28
|
+
ArrowRightIcon: any;
|
|
25
29
|
CancelIcon: any;
|
|
26
30
|
ClearAllIcon: any;
|
|
27
31
|
CloseIcon: any;
|
|
@@ -32,6 +36,8 @@ export interface MRT_Icons {
|
|
|
32
36
|
EditIcon: any;
|
|
33
37
|
ExpandLessIcon: any;
|
|
34
38
|
ExpandMoreIcon: any;
|
|
39
|
+
FilterAltIcon: any;
|
|
40
|
+
FilterAltOff: any;
|
|
35
41
|
FilterListIcon: any;
|
|
36
42
|
FilterListOffIcon: any;
|
|
37
43
|
FullscreenExitIcon: any;
|
|
@@ -47,6 +53,7 @@ export interface MRT_Icons {
|
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
export const MRT_Default_Icons: MRT_Icons = {
|
|
56
|
+
ArrowRightIcon,
|
|
50
57
|
CancelIcon,
|
|
51
58
|
ClearAllIcon,
|
|
52
59
|
CloseIcon,
|
|
@@ -57,6 +64,8 @@ export const MRT_Default_Icons: MRT_Icons = {
|
|
|
57
64
|
EditIcon,
|
|
58
65
|
ExpandLessIcon,
|
|
59
66
|
ExpandMoreIcon,
|
|
67
|
+
FilterAltIcon,
|
|
68
|
+
FilterAltOff,
|
|
60
69
|
FilterListIcon,
|
|
61
70
|
FilterListOffIcon,
|
|
62
71
|
FullscreenExitIcon,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { useAsyncDebounce } from 'react-table';
|
|
11
11
|
import { useMRT } from '../useMRT';
|
|
12
12
|
import { MRT_HeaderGroup } from '..';
|
|
13
|
-
import {
|
|
13
|
+
import { MRT_FilterTypeMenu } from '../menus/MRT_FilterTypeMenu';
|
|
14
14
|
|
|
15
15
|
interface Props {
|
|
16
16
|
column: MRT_HeaderGroup;
|
|
@@ -73,7 +73,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
const filterType = tableInstance.state.currentFilterTypes[column.id];
|
|
76
|
-
const
|
|
76
|
+
const filterChipLabel = ['empty', 'notEmpty'].includes(filterType);
|
|
77
77
|
const filterPlaceholder = localization.filterTextFieldPlaceholder?.replace(
|
|
78
78
|
'{column}',
|
|
79
79
|
String(column.Header),
|
|
@@ -85,13 +85,15 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
85
85
|
fullWidth
|
|
86
86
|
id={`mrt-${idPrefix}-${column.id}-filter-text-field`}
|
|
87
87
|
inputProps={{
|
|
88
|
+
disabled: !!filterChipLabel,
|
|
88
89
|
sx: {
|
|
89
90
|
textOverflow: 'ellipsis',
|
|
91
|
+
width: filterChipLabel ? 0 : 'auto',
|
|
90
92
|
},
|
|
91
93
|
title: filterPlaceholder,
|
|
92
94
|
}}
|
|
93
95
|
margin="none"
|
|
94
|
-
placeholder={
|
|
96
|
+
placeholder={filterChipLabel ? '' : filterPlaceholder}
|
|
95
97
|
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
|
96
98
|
setFilterValue(e.target.value);
|
|
97
99
|
handleChange(e.target.value);
|
|
@@ -111,12 +113,12 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
111
113
|
<FilterListIcon />
|
|
112
114
|
</IconButton>
|
|
113
115
|
</Tooltip>
|
|
114
|
-
{
|
|
116
|
+
{filterChipLabel && (
|
|
115
117
|
<Chip onDelete={handleClearFilterChip} label={filterType} />
|
|
116
118
|
)}
|
|
117
119
|
</InputAdornment>
|
|
118
120
|
),
|
|
119
|
-
endAdornment: !
|
|
121
|
+
endAdornment: !filterChipLabel && (
|
|
120
122
|
<InputAdornment position="end">
|
|
121
123
|
<Tooltip
|
|
122
124
|
arrow
|
|
@@ -140,11 +142,13 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
140
142
|
}}
|
|
141
143
|
{...textFieldProps}
|
|
142
144
|
sx={{
|
|
143
|
-
|
|
145
|
+
m: '0 -0.25rem',
|
|
146
|
+
minWidth: !filterChipLabel ? '5rem' : 'auto',
|
|
147
|
+
width: 'calc(100% + 0.5rem)',
|
|
144
148
|
...textFieldProps?.sx,
|
|
145
149
|
}}
|
|
146
150
|
/>
|
|
147
|
-
<
|
|
151
|
+
<MRT_FilterTypeMenu
|
|
148
152
|
anchorEl={anchorEl}
|
|
149
153
|
column={column}
|
|
150
154
|
setAnchorEl={setAnchorEl}
|
package/src/localization.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface MRT_Localization {
|
|
|
11
11
|
columnShowHideMenuShowAll: string;
|
|
12
12
|
expandAllButtonTitle: string;
|
|
13
13
|
expandButtonTitle: string;
|
|
14
|
+
filterApplied: string;
|
|
14
15
|
filterMenuItemContains: string;
|
|
15
16
|
filterMenuItemEmpty: string;
|
|
16
17
|
filterMenuItemEndsWith: string;
|
|
@@ -20,6 +21,9 @@ export interface MRT_Localization {
|
|
|
20
21
|
filterMenuItemNotEquals: string;
|
|
21
22
|
filterMenuItemStartsWith: string;
|
|
22
23
|
filterMenuTitle: string;
|
|
24
|
+
filterTextFieldChangeFilterButtonTitle: string;
|
|
25
|
+
filterTextFieldChipLabelEmpty: string;
|
|
26
|
+
filterTextFieldChipLabelNotEmpty: string;
|
|
23
27
|
filterTextFieldClearButtonTitle: string;
|
|
24
28
|
filterTextFieldPlaceholder: string;
|
|
25
29
|
rowActionButtonCancel: string;
|
|
@@ -54,15 +58,19 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
|
54
58
|
columnShowHideMenuShowAll: 'Show all',
|
|
55
59
|
expandAllButtonTitle: 'Expand all',
|
|
56
60
|
expandButtonTitle: 'Expand',
|
|
61
|
+
filterApplied: 'Filtering by {column} - ({filterType})',
|
|
57
62
|
filterMenuItemContains: 'Contains Exact',
|
|
58
63
|
filterMenuItemEmpty: 'Empty',
|
|
59
64
|
filterMenuItemEndsWith: 'Ends With',
|
|
60
65
|
filterMenuItemEquals: 'Equals',
|
|
61
|
-
filterMenuItemFuzzy: 'Fuzzy Match',
|
|
66
|
+
filterMenuItemFuzzy: 'Fuzzy Match (Default)',
|
|
62
67
|
filterMenuItemNotEmpty: 'Not Empty',
|
|
63
68
|
filterMenuItemNotEquals: 'Not Equals',
|
|
64
69
|
filterMenuItemStartsWith: 'Starts With',
|
|
65
70
|
filterMenuTitle: 'Filter Mode',
|
|
71
|
+
filterTextFieldChangeFilterButtonTitle: 'Change Filter Mode',
|
|
72
|
+
filterTextFieldChipLabelEmpty: 'Empty',
|
|
73
|
+
filterTextFieldChipLabelNotEmpty: 'Not Empty',
|
|
66
74
|
filterTextFieldClearButtonTitle: 'Clear filter',
|
|
67
75
|
filterTextFieldPlaceholder: 'Filter by {column}',
|
|
68
76
|
rowActionButtonCancel: 'Cancel',
|
|
@@ -76,9 +84,9 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
|
76
84
|
selectCheckboxTitle: 'Toggle select row',
|
|
77
85
|
showHideColumnsButtonTitle: 'Show/Hide columns',
|
|
78
86
|
toggleDensePaddingSwitchTitle: 'Toggle dense padding',
|
|
79
|
-
toggleFilterButtonTitle: '
|
|
87
|
+
toggleFilterButtonTitle: 'Show/Hide filters',
|
|
80
88
|
toggleFullScreenButtonTitle: 'Toggle full screen',
|
|
81
|
-
toggleSearchButtonTitle: '
|
|
89
|
+
toggleSearchButtonTitle: 'Show/Hide search',
|
|
82
90
|
toolbarAlertGroupedByMessage: 'Grouped by ',
|
|
83
91
|
toolbarAlertGroupedThenByMessage: ', then by ',
|
|
84
92
|
toolbarAlertSelectionMessage: '{selectedCount} of {rowCount} row(s) selected',
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { FC, useState } from 'react';
|
|
2
2
|
import {
|
|
3
|
-
Divider,
|
|
4
3
|
IconButton,
|
|
5
4
|
ListItemIcon,
|
|
6
5
|
ListItemText,
|
|
@@ -10,8 +9,12 @@ import {
|
|
|
10
9
|
} from '@mui/material';
|
|
11
10
|
import { useMRT } from '../useMRT';
|
|
12
11
|
import { MRT_HeaderGroup } from '..';
|
|
13
|
-
import {
|
|
14
|
-
|
|
12
|
+
import { MRT_FilterTypeMenu } from './MRT_FilterTypeMenu';
|
|
13
|
+
|
|
14
|
+
const commonMenuItemStyles = {
|
|
15
|
+
display: 'flex',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
};
|
|
15
18
|
|
|
16
19
|
interface Props {
|
|
17
20
|
anchorEl: HTMLElement | null;
|
|
@@ -30,6 +33,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
30
33
|
disableSortBy,
|
|
31
34
|
enableColumnGrouping,
|
|
32
35
|
icons: {
|
|
36
|
+
ArrowRightIcon,
|
|
33
37
|
ClearAllIcon,
|
|
34
38
|
DynamicFeedIcon,
|
|
35
39
|
FilterListIcon,
|
|
@@ -39,6 +43,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
39
43
|
idPrefix,
|
|
40
44
|
localization,
|
|
41
45
|
setShowFilters,
|
|
46
|
+
tableInstance,
|
|
42
47
|
} = useMRT();
|
|
43
48
|
|
|
44
49
|
const [filterMenuAnchorEl, setFilterMenuAnchorEl] =
|
|
@@ -96,13 +101,14 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
96
101
|
open={!!anchorEl}
|
|
97
102
|
onClose={() => setAnchorEl(null)}
|
|
98
103
|
>
|
|
99
|
-
<MenuList>
|
|
104
|
+
<MenuList dense={tableInstance.state.densePadding} disablePadding>
|
|
100
105
|
{!disableSortBy &&
|
|
101
106
|
column.canSort && [
|
|
102
107
|
<MenuItem
|
|
103
108
|
key={1}
|
|
104
109
|
disabled={!column.isSorted}
|
|
105
110
|
onClick={handleClearSort}
|
|
111
|
+
sx={commonMenuItemStyles}
|
|
106
112
|
>
|
|
107
113
|
<ListItemIcon>
|
|
108
114
|
<ClearAllIcon />
|
|
@@ -112,9 +118,10 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
112
118
|
</ListItemText>
|
|
113
119
|
</MenuItem>,
|
|
114
120
|
<MenuItem
|
|
115
|
-
key={2}
|
|
116
121
|
disabled={column.isSorted && !column.isSortedDesc}
|
|
122
|
+
key={2}
|
|
117
123
|
onClick={handleSortAsc}
|
|
124
|
+
sx={commonMenuItemStyles}
|
|
118
125
|
>
|
|
119
126
|
<ListItemIcon>
|
|
120
127
|
<SortIcon />
|
|
@@ -127,9 +134,13 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
127
134
|
</ListItemText>
|
|
128
135
|
</MenuItem>,
|
|
129
136
|
<MenuItem
|
|
137
|
+
divider={
|
|
138
|
+
!disableFilters || enableColumnGrouping || !disableColumnHiding
|
|
139
|
+
}
|
|
130
140
|
key={3}
|
|
131
141
|
disabled={column.isSorted && column.isSortedDesc}
|
|
132
142
|
onClick={handleSortDesc}
|
|
143
|
+
sx={commonMenuItemStyles}
|
|
133
144
|
>
|
|
134
145
|
<ListItemIcon>
|
|
135
146
|
<SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />
|
|
@@ -144,8 +155,12 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
144
155
|
]}
|
|
145
156
|
{!disableFilters &&
|
|
146
157
|
column.canFilter && [
|
|
147
|
-
<
|
|
148
|
-
|
|
158
|
+
<MenuItem
|
|
159
|
+
divider={enableColumnGrouping || !disableColumnHiding}
|
|
160
|
+
key={1}
|
|
161
|
+
onClick={handleFilterByColumn}
|
|
162
|
+
sx={commonMenuItemStyles}
|
|
163
|
+
>
|
|
149
164
|
<ListItemIcon>
|
|
150
165
|
<FilterListIcon />
|
|
151
166
|
</ListItemIcon>
|
|
@@ -155,11 +170,16 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
155
170
|
String(column.Header),
|
|
156
171
|
)}
|
|
157
172
|
</ListItemText>
|
|
158
|
-
<IconButton
|
|
173
|
+
<IconButton
|
|
174
|
+
onClick={handleOpenFilterModeMenu}
|
|
175
|
+
onMouseEnter={handleOpenFilterModeMenu}
|
|
176
|
+
size="small"
|
|
177
|
+
sx={{ p: 0 }}
|
|
178
|
+
>
|
|
159
179
|
<ArrowRightIcon />
|
|
160
180
|
</IconButton>
|
|
161
181
|
</MenuItem>,
|
|
162
|
-
<
|
|
182
|
+
<MRT_FilterTypeMenu
|
|
163
183
|
anchorEl={filterMenuAnchorEl}
|
|
164
184
|
column={column}
|
|
165
185
|
key={2}
|
|
@@ -169,8 +189,12 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
169
189
|
]}
|
|
170
190
|
{enableColumnGrouping &&
|
|
171
191
|
column.canGroupBy && [
|
|
172
|
-
<
|
|
173
|
-
|
|
192
|
+
<MenuItem
|
|
193
|
+
divider={!disableColumnHiding}
|
|
194
|
+
key={2}
|
|
195
|
+
onClick={handleGroupByColumn}
|
|
196
|
+
sx={commonMenuItemStyles}
|
|
197
|
+
>
|
|
174
198
|
<ListItemIcon>
|
|
175
199
|
<DynamicFeedIcon />
|
|
176
200
|
</ListItemIcon>
|
|
@@ -184,8 +208,11 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
184
208
|
</MenuItem>,
|
|
185
209
|
]}
|
|
186
210
|
{!disableColumnHiding && [
|
|
187
|
-
<
|
|
188
|
-
|
|
211
|
+
<MenuItem
|
|
212
|
+
key={1}
|
|
213
|
+
onClick={handleHideColumn}
|
|
214
|
+
sx={commonMenuItemStyles}
|
|
215
|
+
>
|
|
189
216
|
<ListItemIcon>
|
|
190
217
|
<VisibilityOffIcon />
|
|
191
218
|
</ListItemIcon>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC, useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Menu, MenuItem, MenuList } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_FilterType, MRT_HeaderGroup } from '..';
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ interface Props {
|
|
|
10
10
|
onSelect?: () => void;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const
|
|
13
|
+
export const MRT_FilterTypeMenu: FC<Props> = ({
|
|
14
14
|
anchorEl,
|
|
15
15
|
column,
|
|
16
16
|
onSelect,
|
|
@@ -68,7 +68,7 @@ export const MRT_FilterMenu: FC<Props> = ({
|
|
|
68
68
|
[],
|
|
69
69
|
);
|
|
70
70
|
|
|
71
|
-
const
|
|
71
|
+
const handleSelectFilterType = (value: MRT_FilterType) => {
|
|
72
72
|
setAnchorEl(null);
|
|
73
73
|
setCurrentFilterTypes((prev: { [key: string]: MRT_FilterType }) => ({
|
|
74
74
|
...prev,
|
|
@@ -85,25 +85,23 @@ export const MRT_FilterMenu: FC<Props> = ({
|
|
|
85
85
|
return (
|
|
86
86
|
<Menu
|
|
87
87
|
anchorEl={anchorEl}
|
|
88
|
-
open={!!anchorEl}
|
|
89
88
|
anchorOrigin={{ vertical: 'center', horizontal: 'right' }}
|
|
90
89
|
onClose={() => setAnchorEl(null)}
|
|
90
|
+
open={!!anchorEl}
|
|
91
91
|
>
|
|
92
|
-
<
|
|
93
|
-
{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
</MenuItem>
|
|
106
|
-
))}
|
|
92
|
+
<MenuList dense={tableInstance.state.densePadding} disablePadding>
|
|
93
|
+
{filterTypes.map(({ type, label, divider }) => (
|
|
94
|
+
<MenuItem
|
|
95
|
+
divider={divider}
|
|
96
|
+
key={type}
|
|
97
|
+
onClick={() => handleSelectFilterType(type)}
|
|
98
|
+
selected={type === filterType}
|
|
99
|
+
value={type}
|
|
100
|
+
>
|
|
101
|
+
{label}
|
|
102
|
+
</MenuItem>
|
|
103
|
+
))}
|
|
104
|
+
</MenuList>
|
|
107
105
|
</Menu>
|
|
108
106
|
);
|
|
109
107
|
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ListItemIcon,
|
|
4
|
+
ListItemText,
|
|
5
|
+
Menu,
|
|
6
|
+
MenuItem,
|
|
7
|
+
MenuList,
|
|
8
|
+
} from '@mui/material';
|
|
3
9
|
import { useMRT } from '../useMRT';
|
|
4
10
|
import { MRT_Row } from '..';
|
|
5
11
|
|
|
@@ -30,14 +36,19 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
30
36
|
open={!!anchorEl}
|
|
31
37
|
onClose={() => setAnchorEl(null)}
|
|
32
38
|
>
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
<MenuList dense={tableInstance.state.densePadding} disablePadding>
|
|
40
|
+
{enableRowEditing && (
|
|
41
|
+
<MenuItem onClick={handleEdit}>
|
|
42
|
+
<ListItemIcon>
|
|
43
|
+
<EditIcon />
|
|
44
|
+
</ListItemIcon>
|
|
45
|
+
<ListItemText>{localization.rowActionMenuItemEdit}</ListItemText>
|
|
46
|
+
</MenuItem>
|
|
47
|
+
)}
|
|
48
|
+
{renderRowActionMenuItems?.(row, tableInstance, () =>
|
|
49
|
+
setAnchorEl(null),
|
|
50
|
+
) ?? null}
|
|
51
|
+
</MenuList>
|
|
41
52
|
</Menu>
|
|
42
53
|
);
|
|
43
54
|
};
|
|
@@ -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 &&
|