material-react-table 0.5.2 → 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.
Files changed (37) hide show
  1. package/dist/MaterialReactTable.d.ts +10 -5
  2. package/dist/filtersFNs.d.ts +67 -0
  3. package/dist/icons.d.ts +3 -0
  4. package/dist/localization.d.ts +14 -1
  5. package/dist/material-react-table.cjs.development.js +448 -85
  6. package/dist/material-react-table.cjs.development.js.map +1 -1
  7. package/dist/material-react-table.cjs.production.min.js +1 -1
  8. package/dist/material-react-table.cjs.production.min.js.map +1 -1
  9. package/dist/material-react-table.esm.js +449 -86
  10. package/dist/material-react-table.esm.js.map +1 -1
  11. package/dist/menus/MRT_FilterTypeMenu.d.ts +10 -0
  12. package/dist/useMRT.d.ts +13 -9
  13. package/package.json +6 -2
  14. package/src/MaterialReactTable.tsx +25 -5
  15. package/src/body/MRT_TableBody.tsx +7 -2
  16. package/src/buttons/MRT_EditActionButtons.tsx +3 -1
  17. package/src/buttons/MRT_ShowHideColumnsButton.tsx +34 -31
  18. package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +4 -3
  19. package/src/buttons/MRT_ToggleFiltersButton.tsx +3 -1
  20. package/src/buttons/MRT_ToggleSearchButton.tsx +5 -2
  21. package/src/filtersFNs.ts +112 -0
  22. package/src/footer/MRT_TableFooter.tsx +6 -1
  23. package/src/footer/MRT_TableFooterCell.tsx +1 -1
  24. package/src/head/MRT_TableHeadCell.tsx +91 -44
  25. package/src/{icons.tsx → icons.ts} +9 -0
  26. package/src/index.tsx +0 -2
  27. package/src/inputs/MRT_FilterTextField.tsx +121 -52
  28. package/src/inputs/MRT_SearchTextField.tsx +2 -1
  29. package/src/inputs/MRT_SelectCheckbox.tsx +5 -7
  30. package/src/localization.ts +30 -4
  31. package/src/menus/MRT_ColumnActionMenu.tsx +145 -78
  32. package/src/menus/MRT_FilterTypeMenu.tsx +107 -0
  33. package/src/menus/MRT_RowActionMenu.tsx +20 -9
  34. package/src/menus/MRT_ShowHideColumnsMenu.tsx +1 -1
  35. package/src/table/MRT_Table.tsx +7 -2
  36. package/src/table/MRT_TableContainer.tsx +15 -2
  37. package/src/useMRT.tsx +67 -13
@@ -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,
package/src/index.tsx CHANGED
@@ -1,5 +1,3 @@
1
1
  import MaterialReactTable from './MaterialReactTable';
2
2
  export default MaterialReactTable;
3
3
  export * from './MaterialReactTable';
4
-
5
-
@@ -1,8 +1,16 @@
1
- import React, { ChangeEvent, FC, useState } from 'react';
2
- import { IconButton, InputAdornment, TextField, Tooltip } from '@mui/material';
1
+ import React, { ChangeEvent, FC, MouseEvent, useState } from 'react';
2
+ import {
3
+ Chip,
4
+ IconButton,
5
+ InputAdornment,
6
+ TextField,
7
+ TextFieldProps,
8
+ Tooltip,
9
+ } from '@mui/material';
3
10
  import { useAsyncDebounce } from 'react-table';
4
11
  import { useMRT } from '../useMRT';
5
12
  import { MRT_HeaderGroup } from '..';
13
+ import { MRT_FilterTypeMenu } from '../menus/MRT_FilterTypeMenu';
6
14
 
7
15
  interface Props {
8
16
  column: MRT_HeaderGroup;
@@ -11,79 +19,140 @@ interface Props {
11
19
  export const MRT_FilterTextField: FC<Props> = ({ column }) => {
12
20
  const {
13
21
  icons: { FilterListIcon, CloseIcon },
22
+ idPrefix,
14
23
  localization,
24
+ muiTableHeadCellFilterTextFieldProps,
25
+ setCurrentFilterTypes,
26
+ tableInstance,
15
27
  } = useMRT();
16
28
 
29
+ const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
30
+
31
+ const mTableHeadCellFilterTextFieldProps =
32
+ muiTableHeadCellFilterTextFieldProps instanceof Function
33
+ ? muiTableHeadCellFilterTextFieldProps(column)
34
+ : muiTableHeadCellFilterTextFieldProps;
35
+
36
+ const mcTableHeadCellFilterTextFieldProps =
37
+ column.muiTableHeadCellFilterTextFieldProps instanceof Function
38
+ ? column.muiTableHeadCellFilterTextFieldProps(column)
39
+ : column.muiTableHeadCellFilterTextFieldProps;
40
+
41
+ const textFieldProps = {
42
+ ...mTableHeadCellFilterTextFieldProps,
43
+ ...mcTableHeadCellFilterTextFieldProps,
44
+ style: {
45
+ ...mTableHeadCellFilterTextFieldProps?.style,
46
+ ...mcTableHeadCellFilterTextFieldProps?.style,
47
+ },
48
+ } as TextFieldProps;
49
+
17
50
  const [filterValue, setFilterValue] = useState('');
18
51
 
19
52
  const handleChange = useAsyncDebounce((value) => {
20
53
  column.setFilter(value ?? undefined);
21
54
  }, 150);
22
55
 
56
+ const handleFilterMenuOpen = (event: MouseEvent<HTMLElement>) => {
57
+ setAnchorEl(event.currentTarget);
58
+ };
59
+
23
60
  const handleClear = () => {
24
61
  setFilterValue('');
25
62
  column.setFilter(undefined);
26
63
  };
27
64
 
65
+ const handleClearFilterChip = () => {
66
+ setFilterValue('');
67
+ column.setFilter(undefined);
68
+ setCurrentFilterTypes((prev) => ({ ...prev, [column.id]: 'fuzzy' }));
69
+ };
70
+
28
71
  if (column.Filter) {
29
72
  return <>{column.Filter?.({ column })}</>;
30
73
  }
31
74
 
75
+ const filterType = tableInstance.state.currentFilterTypes[column.id];
76
+ const filterChipLabel = ['empty', 'notEmpty'].includes(filterType);
77
+ const filterPlaceholder = localization.filterTextFieldPlaceholder?.replace(
78
+ '{column}',
79
+ String(column.Header),
80
+ );
81
+
32
82
  return (
33
- <TextField
34
- fullWidth
35
- id={`filter-${column.id}-column`}
36
- inputProps={{
37
- style: {
38
- textOverflow: 'ellipsis',
39
- },
40
- }}
41
- margin="dense"
42
- placeholder={localization.filterTextFieldPlaceholder?.replace(
43
- '{column}',
44
- String(column.Header),
45
- )}
46
- onChange={(e: ChangeEvent<HTMLInputElement>) => {
47
- setFilterValue(e.target.value);
48
- handleChange(e.target.value);
49
- }}
50
- onClick={(e) => e.stopPropagation()}
51
- value={filterValue ?? ''}
52
- variant="standard"
53
- InputProps={{
54
- startAdornment: (
55
- <Tooltip
56
- arrow
57
- title={localization.filterTextFieldPlaceholder?.replace(
58
- '{column}',
59
- String(column.Header),
60
- )}
61
- >
83
+ <>
84
+ <TextField
85
+ fullWidth
86
+ id={`mrt-${idPrefix}-${column.id}-filter-text-field`}
87
+ inputProps={{
88
+ disabled: !!filterChipLabel,
89
+ sx: {
90
+ textOverflow: 'ellipsis',
91
+ width: filterChipLabel ? 0 : 'auto',
92
+ },
93
+ title: filterPlaceholder,
94
+ }}
95
+ margin="none"
96
+ placeholder={filterChipLabel ? '' : filterPlaceholder}
97
+ onChange={(e: ChangeEvent<HTMLInputElement>) => {
98
+ setFilterValue(e.target.value);
99
+ handleChange(e.target.value);
100
+ }}
101
+ onClick={(e) => e.stopPropagation()}
102
+ value={filterValue ?? ''}
103
+ variant="standard"
104
+ InputProps={{
105
+ startAdornment: (
62
106
  <InputAdornment position="start">
63
- <FilterListIcon />
64
- </InputAdornment>
65
- </Tooltip>
66
- ),
67
- endAdornment: (
68
- <InputAdornment position="end">
69
- <Tooltip
70
- arrow
71
- title={localization.filterTextFieldClearButtonTitle ?? ''}
72
- >
73
- <span>
107
+ <Tooltip arrow title="Change Filter Mode">
74
108
  <IconButton
75
- aria-label={localization.filterTextFieldClearButtonTitle}
76
- disabled={filterValue?.length === 0}
77
- onClick={handleClear}
109
+ onClick={handleFilterMenuOpen}
78
110
  size="small"
111
+ sx={{ height: '1.75rem', width: '1.75rem' }}
79
112
  >
80
- <CloseIcon fontSize="small" />
113
+ <FilterListIcon />
81
114
  </IconButton>
82
- </span>
83
- </Tooltip>
84
- </InputAdornment>
85
- ),
86
- }}
87
- />
115
+ </Tooltip>
116
+ {filterChipLabel && (
117
+ <Chip onDelete={handleClearFilterChip} label={filterType} />
118
+ )}
119
+ </InputAdornment>
120
+ ),
121
+ endAdornment: !filterChipLabel && (
122
+ <InputAdornment position="end">
123
+ <Tooltip
124
+ arrow
125
+ placement="right"
126
+ title={localization.filterTextFieldClearButtonTitle ?? ''}
127
+ >
128
+ <span>
129
+ <IconButton
130
+ aria-label={localization.filterTextFieldClearButtonTitle}
131
+ disabled={filterValue?.length === 0}
132
+ onClick={handleClear}
133
+ size="small"
134
+ sx={{ height: '1.75rem', width: '1.75rem' }}
135
+ >
136
+ <CloseIcon fontSize="small" />
137
+ </IconButton>
138
+ </span>
139
+ </Tooltip>
140
+ </InputAdornment>
141
+ ),
142
+ }}
143
+ {...textFieldProps}
144
+ sx={{
145
+ m: '0 -0.25rem',
146
+ minWidth: !filterChipLabel ? '5rem' : 'auto',
147
+ width: 'calc(100% + 0.5rem)',
148
+ ...textFieldProps?.sx,
149
+ }}
150
+ />
151
+ <MRT_FilterTypeMenu
152
+ anchorEl={anchorEl}
153
+ column={column}
154
+ setAnchorEl={setAnchorEl}
155
+ />
156
+ </>
88
157
  );
89
158
  };
@@ -8,6 +8,7 @@ interface Props {}
8
8
  export const MRT_SearchTextField: FC<Props> = () => {
9
9
  const {
10
10
  icons: { SearchIcon, CloseIcon },
11
+ idPrefix,
11
12
  localization,
12
13
  muiSearchTextFieldProps,
13
14
  onGlobalFilterChange,
@@ -32,7 +33,7 @@ export const MRT_SearchTextField: FC<Props> = () => {
32
33
  return (
33
34
  <Collapse in={tableInstance.state.showSearch} orientation="horizontal">
34
35
  <TextField
35
- id="global-search-text-field"
36
+ id={`mrt-${idPrefix}-search-text-field`}
36
37
  placeholder={localization.searchTextFieldPlaceholder}
37
38
  onChange={(event: ChangeEvent<HTMLInputElement>) => {
38
39
  setSearchValue(event.target.value);
@@ -10,12 +10,8 @@ interface Props {
10
10
  }
11
11
 
12
12
  export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
13
- const {
14
- localization,
15
- onRowSelectChange,
16
- onSelectAllChange,
17
- tableInstance,
18
- } = useMRT();
13
+ const { localization, onRowSelectChange, onSelectAllChange, tableInstance } =
14
+ useMRT();
19
15
 
20
16
  const onSelectChange = (event: ChangeEvent<HTMLInputElement>) => {
21
17
  if (selectAll) {
@@ -32,7 +28,9 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
32
28
  : row?.getToggleRowSelectedProps();
33
29
 
34
30
  return (
35
- <TableCell sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)} >
31
+ <TableCell
32
+ sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)}
33
+ >
36
34
  <Tooltip
37
35
  arrow
38
36
  enterDelay={1000}
@@ -11,6 +11,19 @@ export interface MRT_Localization {
11
11
  columnShowHideMenuShowAll: string;
12
12
  expandAllButtonTitle: string;
13
13
  expandButtonTitle: string;
14
+ filterApplied: string;
15
+ filterMenuItemContains: string;
16
+ filterMenuItemEmpty: string;
17
+ filterMenuItemEndsWith: string;
18
+ filterMenuItemEquals: string;
19
+ filterMenuItemFuzzy: string;
20
+ filterMenuItemNotEmpty: string;
21
+ filterMenuItemNotEquals: string;
22
+ filterMenuItemStartsWith: string;
23
+ filterMenuTitle: string;
24
+ filterTextFieldChangeFilterButtonTitle: string;
25
+ filterTextFieldChipLabelEmpty: string;
26
+ filterTextFieldChipLabelNotEmpty: string;
14
27
  filterTextFieldClearButtonTitle: string;
15
28
  filterTextFieldPlaceholder: string;
16
29
  rowActionButtonCancel: string;
@@ -27,9 +40,9 @@ export interface MRT_Localization {
27
40
  toggleFilterButtonTitle: string;
28
41
  toggleFullScreenButtonTitle: string;
29
42
  toggleSearchButtonTitle: string;
30
- toolbarAlertSelectionMessage: string;
31
43
  toolbarAlertGroupedByMessage: string;
32
44
  toolbarAlertGroupedThenByMessage: string;
45
+ toolbarAlertSelectionMessage: string;
33
46
  }
34
47
 
35
48
  export const MRT_DefaultLocalization_EN: MRT_Localization = {
@@ -45,6 +58,19 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
45
58
  columnShowHideMenuShowAll: 'Show all',
46
59
  expandAllButtonTitle: 'Expand all',
47
60
  expandButtonTitle: 'Expand',
61
+ filterApplied: 'Filtering by {column} - ({filterType})',
62
+ filterMenuItemContains: 'Contains Exact',
63
+ filterMenuItemEmpty: 'Empty',
64
+ filterMenuItemEndsWith: 'Ends With',
65
+ filterMenuItemEquals: 'Equals',
66
+ filterMenuItemFuzzy: 'Fuzzy Match (Default)',
67
+ filterMenuItemNotEmpty: 'Not Empty',
68
+ filterMenuItemNotEquals: 'Not Equals',
69
+ filterMenuItemStartsWith: 'Starts With',
70
+ filterMenuTitle: 'Filter Mode',
71
+ filterTextFieldChangeFilterButtonTitle: 'Change Filter Mode',
72
+ filterTextFieldChipLabelEmpty: 'Empty',
73
+ filterTextFieldChipLabelNotEmpty: 'Not Empty',
48
74
  filterTextFieldClearButtonTitle: 'Clear filter',
49
75
  filterTextFieldPlaceholder: 'Filter by {column}',
50
76
  rowActionButtonCancel: 'Cancel',
@@ -58,10 +84,10 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
58
84
  selectCheckboxTitle: 'Toggle select row',
59
85
  showHideColumnsButtonTitle: 'Show/Hide columns',
60
86
  toggleDensePaddingSwitchTitle: 'Toggle dense padding',
61
- toggleFilterButtonTitle: 'Toggle filters',
87
+ toggleFilterButtonTitle: 'Show/Hide filters',
62
88
  toggleFullScreenButtonTitle: 'Toggle full screen',
63
- toggleSearchButtonTitle: 'Toggle search',
64
- toolbarAlertSelectionMessage: '{selectedCount} of {rowCount} row(s) selected',
89
+ toggleSearchButtonTitle: 'Show/Hide search',
65
90
  toolbarAlertGroupedByMessage: 'Grouped by ',
66
91
  toolbarAlertGroupedThenByMessage: ', then by ',
92
+ toolbarAlertSelectionMessage: '{selectedCount} of {rowCount} row(s) selected',
67
93
  };
@@ -1,11 +1,19 @@
1
- import React, { FC } from 'react';
2
- import { Divider, Menu, MenuItem } from '@mui/material';
1
+ import React, { FC, useState } from 'react';
2
+ import {
3
+ IconButton,
4
+ ListItemIcon,
5
+ ListItemText,
6
+ Menu,
7
+ MenuItem,
8
+ MenuList,
9
+ } from '@mui/material';
3
10
  import { useMRT } from '../useMRT';
4
11
  import { MRT_HeaderGroup } from '..';
12
+ import { MRT_FilterTypeMenu } from './MRT_FilterTypeMenu';
5
13
 
6
14
  const commonMenuItemStyles = {
7
15
  display: 'flex',
8
- gap: '0.75rem',
16
+ alignItems: 'center',
9
17
  };
10
18
 
11
19
  interface Props {
@@ -24,17 +32,23 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
24
32
  disableFilters,
25
33
  disableSortBy,
26
34
  enableColumnGrouping,
27
- localization,
28
- setShowFilters,
29
35
  icons: {
30
- FilterListIcon,
31
- SortIcon,
36
+ ArrowRightIcon,
32
37
  ClearAllIcon,
33
38
  DynamicFeedIcon,
39
+ FilterListIcon,
40
+ SortIcon,
34
41
  VisibilityOffIcon,
35
42
  },
43
+ idPrefix,
44
+ localization,
45
+ setShowFilters,
46
+ tableInstance,
36
47
  } = useMRT();
37
48
 
49
+ const [filterMenuAnchorEl, setFilterMenuAnchorEl] =
50
+ useState<null | HTMLElement>(null);
51
+
38
52
  const handleClearSort = () => {
39
53
  column.clearSortBy();
40
54
  setAnchorEl(null);
@@ -68,7 +82,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
68
82
  .getElementById(
69
83
  // @ts-ignore
70
84
  column.muiTableHeadCellFilterTextFieldProps?.id ??
71
- `filter-${column.id}-column`,
85
+ `mrt-${idPrefix}-${column.id}-filter-text-field`,
72
86
  )
73
87
  ?.focus(),
74
88
  200,
@@ -76,88 +90,141 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
76
90
  setAnchorEl(null);
77
91
  };
78
92
 
93
+ const handleOpenFilterModeMenu = (event: React.MouseEvent<HTMLElement>) => {
94
+ event.stopPropagation();
95
+ setFilterMenuAnchorEl(event.currentTarget);
96
+ };
97
+
79
98
  return (
80
99
  <Menu
81
100
  anchorEl={anchorEl}
82
101
  open={!!anchorEl}
83
102
  onClose={() => setAnchorEl(null)}
84
103
  >
85
- {!disableSortBy &&
86
- column.canSort && [
87
- <MenuItem
88
- key={1}
89
- disabled={!column.isSorted}
90
- onClick={handleClearSort}
91
- sx={commonMenuItemStyles}
92
- >
93
- <ClearAllIcon /> {localization.columnActionMenuItemClearSort}
94
- </MenuItem>,
95
- <MenuItem
96
- key={2}
97
- disabled={column.isSorted && !column.isSortedDesc}
98
- onClick={handleSortAsc}
99
- sx={commonMenuItemStyles}
100
- >
101
- <SortIcon />{' '}
102
- {localization.columnActionMenuItemSortAsc?.replace(
103
- '{column}',
104
- String(column.Header),
105
- )}
106
- </MenuItem>,
107
- <MenuItem
108
- key={3}
109
- disabled={column.isSorted && column.isSortedDesc}
110
- onClick={handleSortDesc}
111
- sx={commonMenuItemStyles}
112
- >
113
- <SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />{' '}
114
- {localization.columnActionMenuItemSortDesc?.replace(
115
- '{column}',
116
- String(column.Header),
117
- )}
118
- </MenuItem>,
119
- ]}
120
- {!disableFilters &&
121
- column.canFilter && [
122
- <Divider key={0} />,
104
+ <MenuList dense={tableInstance.state.densePadding} disablePadding>
105
+ {!disableSortBy &&
106
+ column.canSort && [
107
+ <MenuItem
108
+ key={1}
109
+ disabled={!column.isSorted}
110
+ onClick={handleClearSort}
111
+ sx={commonMenuItemStyles}
112
+ >
113
+ <ListItemIcon>
114
+ <ClearAllIcon />
115
+ </ListItemIcon>
116
+ <ListItemText>
117
+ {localization.columnActionMenuItemClearSort}
118
+ </ListItemText>
119
+ </MenuItem>,
120
+ <MenuItem
121
+ disabled={column.isSorted && !column.isSortedDesc}
122
+ key={2}
123
+ onClick={handleSortAsc}
124
+ sx={commonMenuItemStyles}
125
+ >
126
+ <ListItemIcon>
127
+ <SortIcon />
128
+ </ListItemIcon>
129
+ <ListItemText>
130
+ {localization.columnActionMenuItemSortAsc?.replace(
131
+ '{column}',
132
+ String(column.Header),
133
+ )}
134
+ </ListItemText>
135
+ </MenuItem>,
136
+ <MenuItem
137
+ divider={
138
+ !disableFilters || enableColumnGrouping || !disableColumnHiding
139
+ }
140
+ key={3}
141
+ disabled={column.isSorted && column.isSortedDesc}
142
+ onClick={handleSortDesc}
143
+ sx={commonMenuItemStyles}
144
+ >
145
+ <ListItemIcon>
146
+ <SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />
147
+ </ListItemIcon>
148
+ <ListItemText>
149
+ {localization.columnActionMenuItemSortDesc?.replace(
150
+ '{column}',
151
+ String(column.Header),
152
+ )}
153
+ </ListItemText>
154
+ </MenuItem>,
155
+ ]}
156
+ {!disableFilters &&
157
+ column.canFilter && [
158
+ <MenuItem
159
+ divider={enableColumnGrouping || !disableColumnHiding}
160
+ key={1}
161
+ onClick={handleFilterByColumn}
162
+ sx={commonMenuItemStyles}
163
+ >
164
+ <ListItemIcon>
165
+ <FilterListIcon />
166
+ </ListItemIcon>
167
+ <ListItemText>
168
+ {localization.filterTextFieldPlaceholder?.replace(
169
+ '{column}',
170
+ String(column.Header),
171
+ )}
172
+ </ListItemText>
173
+ <IconButton
174
+ onClick={handleOpenFilterModeMenu}
175
+ onMouseEnter={handleOpenFilterModeMenu}
176
+ size="small"
177
+ sx={{ p: 0 }}
178
+ >
179
+ <ArrowRightIcon />
180
+ </IconButton>
181
+ </MenuItem>,
182
+ <MRT_FilterTypeMenu
183
+ anchorEl={filterMenuAnchorEl}
184
+ column={column}
185
+ key={2}
186
+ setAnchorEl={setFilterMenuAnchorEl}
187
+ onSelect={handleFilterByColumn}
188
+ />,
189
+ ]}
190
+ {enableColumnGrouping &&
191
+ column.canGroupBy && [
192
+ <MenuItem
193
+ divider={!disableColumnHiding}
194
+ key={2}
195
+ onClick={handleGroupByColumn}
196
+ sx={commonMenuItemStyles}
197
+ >
198
+ <ListItemIcon>
199
+ <DynamicFeedIcon />
200
+ </ListItemIcon>
201
+ <ListItemText>
202
+ {localization[
203
+ column.isGrouped
204
+ ? 'columnActionMenuItemUnGroupBy'
205
+ : 'columnActionMenuItemGroupBy'
206
+ ]?.replace('{column}', String(column.Header))}
207
+ </ListItemText>
208
+ </MenuItem>,
209
+ ]}
210
+ {!disableColumnHiding && [
123
211
  <MenuItem
124
212
  key={1}
125
- onClick={handleFilterByColumn}
126
- sx={commonMenuItemStyles}
127
- >
128
- <FilterListIcon />{' '}
129
- {localization.filterTextFieldPlaceholder?.replace(
130
- '{column}',
131
- String(column.Header),
132
- )}
133
- </MenuItem>,
134
- ]}
135
- {enableColumnGrouping &&
136
- column.canGroupBy && [
137
- <Divider key={1} />,
138
- <MenuItem
139
- key={2}
140
- onClick={handleGroupByColumn}
213
+ onClick={handleHideColumn}
141
214
  sx={commonMenuItemStyles}
142
215
  >
143
- <DynamicFeedIcon />{' '}
144
- {localization[
145
- column.isGrouped
146
- ? 'columnActionMenuItemUnGroupBy'
147
- : 'columnActionMenuItemGroupBy'
148
- ]?.replace('{column}', String(column.Header))}
216
+ <ListItemIcon>
217
+ <VisibilityOffIcon />
218
+ </ListItemIcon>
219
+ <ListItemText>
220
+ {localization.columnActionMenuItemHideColumn?.replace(
221
+ '{column}',
222
+ String(column.Header),
223
+ )}
224
+ </ListItemText>
149
225
  </MenuItem>,
150
226
  ]}
151
- {!disableColumnHiding && [
152
- <Divider key={0} />,
153
- <MenuItem key={1} onClick={handleHideColumn} sx={commonMenuItemStyles}>
154
- <VisibilityOffIcon />{' '}
155
- {localization.columnActionMenuItemHideColumn?.replace(
156
- '{column}',
157
- String(column.Header),
158
- )}
159
- </MenuItem>,
160
- ]}
227
+ </MenuList>
161
228
  </Menu>
162
229
  );
163
230
  };