material-react-table 0.5.7 → 0.5.8

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.
@@ -2,7 +2,14 @@ import { FC } from 'react';
2
2
  import { MRT_HeaderGroup } from '..';
3
3
  export declare const commonMenuItemStyles: {
4
4
  py: string;
5
- my: string;
5
+ my: number;
6
+ justifyContent: string;
7
+ alignItems: string;
8
+ };
9
+ export declare const commonListItemStyles: {
10
+ display: string;
11
+ gap: string;
12
+ alignItems: string;
6
13
  };
7
14
  interface Props {
8
15
  anchorEl: HTMLElement | null;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.7",
2
+ "version": "0.5.8",
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.",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "scripts": {
30
30
  "analyze": "size-limit --why",
31
- "build": "tsdx build && size-limit && cp -r dist material-react-table-docs/node_modules/material-react-table/dist && cp -r src material-react-table-docs/node_modules/material-react-table/src && cp -r package.json material-react-table-docs/node_modules/material-react-table/package.json",
31
+ "build": "tsdx build && size-limit && rm -rf material-react-table-docs/node_modules/material-react-table/dist && cp -r dist material-react-table-docs/node_modules/material-react-table/ && cp -r src material-react-table-docs/node_modules/material-react-table/ && cp -r package.json material-react-table-docs/node_modules/material-react-table/package.json",
32
32
  "build-storybook": "build-storybook",
33
33
  "format": "prettier -w .",
34
34
  "lint": "tsdx lint",
@@ -19,6 +19,7 @@ import {
19
19
  Cell,
20
20
  Column,
21
21
  ColumnInstance,
22
+ FilterType,
22
23
  // ColumnInterface,
23
24
  HeaderGroup,
24
25
  Row,
@@ -132,6 +133,8 @@ export type MRT_ColumnInterface<D extends {} = {}> =
132
133
  Header?: string;
133
134
  disableFilters?: boolean;
134
135
  editable?: boolean;
136
+ filter?: MRT_FilterType | string | FilterType<D>;
137
+ filterSelectOptions?: (string | { text: string; value: string })[];
135
138
  muiTableBodyCellEditTextFieldProps?:
136
139
  | TextFieldProps
137
140
  | ((cell: MRT_Cell<D>) => TextFieldProps);
@@ -183,15 +186,18 @@ export type MRT_Cell<D extends {} = {}, _V = any> = Cell<D> &
183
186
  UseGroupByCellProps<D> &
184
187
  UseRowStateCellProps<D> & {};
185
188
 
186
- export type MRT_FilterType =
187
- | 'contains'
188
- | 'empty'
189
- | 'endsWith'
190
- | 'equals'
191
- | 'fuzzy'
192
- | 'notEmpty'
193
- | 'notEquals'
194
- | 'startsWith';
189
+ export enum MRT_FILTER_TYPE {
190
+ CONTAINS = 'contains',
191
+ EMPTY = 'empty',
192
+ ENDS_WITH = 'endsWith',
193
+ EQUALS = 'equals',
194
+ FUZZY = 'fuzzy',
195
+ NOT_EMPTY = 'notEmpty',
196
+ NOT_EQUALS = 'notEquals',
197
+ STARTS_WITH = 'startsWith',
198
+ }
199
+
200
+ export type MRT_FilterType = MRT_FILTER_TYPE | Function;
195
201
 
196
202
  export type MRT_TableState<D extends {} = {}> = TableState<D> &
197
203
  UseColumnOrderState<D> &
@@ -11,7 +11,6 @@ import {
11
11
  import { useMRT } from '../useMRT';
12
12
  import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
13
13
  import { MRT_ColumnInstance } from '..';
14
- import { commonMenuItemStyles } from '../menus/MRT_ColumnActionMenu';
15
14
 
16
15
  interface Props extends IconButtonProps {}
17
16
 
@@ -46,9 +45,7 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
46
45
  onClose={() => setAnchorEl(null)}
47
46
  MenuListProps={{
48
47
  dense: tableInstance.state.densePadding,
49
- disablePadding: true,
50
48
  }}
51
- sx={commonMenuItemStyles}
52
49
  >
53
50
  <Box
54
51
  sx={{
package/src/filtersFNs.ts CHANGED
@@ -1,6 +1,18 @@
1
1
  import { matchSorter } from 'match-sorter';
2
2
  import { MRT_Row } from '.';
3
3
 
4
+ export const fuzzySearchFN = (
5
+ rows: MRT_Row[],
6
+ columnIds: string[],
7
+ filterValue: string | number,
8
+ ) =>
9
+ matchSorter(rows, filterValue.toString().trim(), {
10
+ keys: columnIds.map((c) => `values.${c}`),
11
+ sorter: (rankedItems) => rankedItems,
12
+ });
13
+
14
+ fuzzySearchFN.autoRemove = (val: any) => !val;
15
+
4
16
  export const fuzzyFilterFN = (
5
17
  rows: MRT_Row[],
6
18
  id: string,
@@ -79,18 +79,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
79
79
  const filterTooltip = !!column.filterValue
80
80
  ? localization.filterApplied
81
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
- )
82
+ .replace('{filterType}', column.filterValue)
94
83
  : localization.toggleFilterButtonTitle;
95
84
 
96
85
  const columnHeader = column.render('Header') as string;
@@ -127,7 +116,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
127
116
  >
128
117
  {column.render('Header')}
129
118
  {!isParentHeader && column.canSort && (
130
- <Tooltip arrow title={sortTooltip}>
119
+ <Tooltip arrow placement="top" title={sortTooltip}>
131
120
  <TableSortLabel
132
121
  aria-label={sortTooltip}
133
122
  active={column.isSorted}
@@ -136,19 +125,21 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
136
125
  </Tooltip>
137
126
  )}
138
127
  {!isParentHeader && !!column.canFilter && (
139
- <Tooltip arrow title={filterTooltip}>
128
+ <Tooltip arrow placement="top" title={filterTooltip}>
140
129
  <IconButton
130
+ disableRipple
141
131
  onClick={(event) => {
142
132
  event.stopPropagation();
143
133
  setShowFilters(!tableInstance.state.showFilters);
144
134
  }}
145
135
  size="small"
146
136
  sx={{
137
+ m: 0,
147
138
  opacity: !!column.filterValue ? 0.8 : 0,
148
139
  p: '2px',
149
- m: 0,
150
140
  transition: 'all 0.2s ease-in-out',
151
141
  '&:hover': {
142
+ backgroundColor: 'transparent',
152
143
  opacity: 0.8,
153
144
  },
154
145
  }}
@@ -3,13 +3,14 @@ import {
3
3
  Chip,
4
4
  IconButton,
5
5
  InputAdornment,
6
+ MenuItem,
6
7
  TextField,
7
8
  TextFieldProps,
8
9
  Tooltip,
9
10
  } from '@mui/material';
10
11
  import { useAsyncDebounce } from 'react-table';
11
12
  import { useMRT } from '../useMRT';
12
- import { MRT_HeaderGroup } from '..';
13
+ import { MRT_FILTER_TYPE, MRT_HeaderGroup } from '..';
13
14
  import { MRT_FilterTypeMenu } from '../menus/MRT_FilterTypeMenu';
14
15
 
15
16
  interface Props {
@@ -65,7 +66,10 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
65
66
  const handleClearFilterChip = () => {
66
67
  setFilterValue('');
67
68
  column.setFilter(undefined);
68
- setCurrentFilterTypes((prev) => ({ ...prev, [column.id]: 'fuzzy' }));
69
+ setCurrentFilterTypes((prev) => ({
70
+ ...prev,
71
+ [column.id]: MRT_FILTER_TYPE.FUZZY,
72
+ }));
69
73
  };
70
74
 
71
75
  if (column.Filter) {
@@ -73,7 +77,13 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
73
77
  }
74
78
 
75
79
  const filterType = tableInstance.state.currentFilterTypes[column.id];
76
- const filterChipLabel = ['empty', 'notEmpty'].includes(filterType);
80
+ const isCustomFilterType = filterType instanceof Function;
81
+ const isSelectFilter = !!column.filterSelectOptions;
82
+ const filterChipLabel =
83
+ !isCustomFilterType &&
84
+ [MRT_FILTER_TYPE.EMPTY, MRT_FILTER_TYPE.NOT_EMPTY].includes(
85
+ filterType as MRT_FILTER_TYPE,
86
+ );
77
87
  const filterPlaceholder = localization.filterTextFieldPlaceholder?.replace(
78
88
  '{column}',
79
89
  String(column.Header),
@@ -92,26 +102,40 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
92
102
  },
93
103
  title: filterPlaceholder,
94
104
  }}
105
+ label={isSelectFilter && !filterValue ? filterPlaceholder : undefined}
106
+ InputLabelProps={{
107
+ shrink: false,
108
+ sx: {
109
+ maxWidth: 'calc(100% - 2.5rem)',
110
+ },
111
+ title: filterPlaceholder,
112
+ }}
95
113
  margin="none"
96
- placeholder={filterChipLabel ? '' : filterPlaceholder}
114
+ placeholder={
115
+ filterChipLabel || isSelectFilter ? undefined : filterPlaceholder
116
+ }
97
117
  onChange={(e: ChangeEvent<HTMLInputElement>) => {
98
118
  setFilterValue(e.target.value);
99
119
  handleChange(e.target.value);
100
120
  }}
101
121
  onClick={(e) => e.stopPropagation()}
122
+ select={isSelectFilter}
102
123
  value={filterValue ?? ''}
103
124
  variant="standard"
104
125
  InputProps={{
105
- startAdornment: (
126
+ startAdornment: !isSelectFilter && (
106
127
  <InputAdornment position="start">
107
- <Tooltip arrow title="Change Filter Mode">
108
- <IconButton
109
- onClick={handleFilterMenuOpen}
110
- size="small"
111
- sx={{ height: '1.75rem', width: '1.75rem' }}
112
- >
113
- <FilterListIcon />
114
- </IconButton>
128
+ <Tooltip arrow title={localization.changeFilterMode}>
129
+ <span>
130
+ <IconButton
131
+ disabled={isCustomFilterType}
132
+ onClick={handleFilterMenuOpen}
133
+ size="small"
134
+ sx={{ height: '1.75rem', width: '1.75rem' }}
135
+ >
136
+ <FilterListIcon />
137
+ </IconButton>
138
+ </span>
115
139
  </Tooltip>
116
140
  {filterChipLabel && (
117
141
  <Chip onDelete={handleClearFilterChip} label={filterType} />
@@ -122,16 +146,20 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
122
146
  <InputAdornment position="end">
123
147
  <Tooltip
124
148
  arrow
149
+ disableHoverListener={isSelectFilter}
125
150
  placement="right"
126
151
  title={localization.filterTextFieldClearButtonTitle ?? ''}
127
152
  >
128
153
  <span>
129
154
  <IconButton
130
155
  aria-label={localization.filterTextFieldClearButtonTitle}
131
- disabled={filterValue?.length === 0}
156
+ disabled={!filterValue?.length}
132
157
  onClick={handleClear}
133
158
  size="small"
134
- sx={{ height: '1.75rem', width: '1.75rem' }}
159
+ sx={{
160
+ height: '1.75rem',
161
+ width: '1.75rem',
162
+ }}
135
163
  >
136
164
  <CloseIcon fontSize="small" />
137
165
  </IconButton>
@@ -145,9 +173,35 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
145
173
  m: '0 -0.25rem',
146
174
  minWidth: !filterChipLabel ? '5rem' : 'auto',
147
175
  width: 'calc(100% + 0.5rem)',
176
+ mt: isSelectFilter && !filterValue ? '-1rem' : undefined,
177
+ '& .MuiSelect-icon': {
178
+ mr: '1.5rem',
179
+ },
148
180
  ...textFieldProps?.sx,
149
181
  }}
150
- />
182
+ >
183
+ {isSelectFilter && (
184
+ <MenuItem divider disabled={!filterValue} value="">
185
+ {localization.filterTextFieldClearButtonTitle}
186
+ </MenuItem>
187
+ )}
188
+ {column?.filterSelectOptions?.map((option) => {
189
+ let value;
190
+ let text;
191
+ if (typeof option === 'string') {
192
+ value = option;
193
+ text = option;
194
+ } else if (typeof option === 'object') {
195
+ value = option.value;
196
+ text = option.text;
197
+ }
198
+ return (
199
+ <MenuItem key={value} value={value}>
200
+ {text}
201
+ </MenuItem>
202
+ );
203
+ })}
204
+ </TextField>
151
205
  <MRT_FilterTypeMenu
152
206
  anchorEl={anchorEl}
153
207
  column={column}
@@ -26,6 +26,7 @@ export interface MRT_Localization {
26
26
  filterTextFieldChipLabelNotEmpty: string;
27
27
  filterTextFieldClearButtonTitle: string;
28
28
  filterTextFieldPlaceholder: string;
29
+ changeFilterMode: string;
29
30
  rowActionButtonCancel: string;
30
31
  rowActionButtonSave: string;
31
32
  rowActionMenuButtonTitle: string;
@@ -63,6 +64,7 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
63
64
  filterMenuItemEmpty: 'Empty',
64
65
  filterMenuItemEndsWith: 'Ends With',
65
66
  filterMenuItemEquals: 'Equals',
67
+ changeFilterMode: 'Change filter mode',
66
68
  filterMenuItemFuzzy: 'Fuzzy Match (Default)',
67
69
  filterMenuItemNotEmpty: 'Not Empty',
68
70
  filterMenuItemNotEquals: 'Not Equals',
@@ -1,18 +1,20 @@
1
1
  import React, { FC, useState } from 'react';
2
- import {
3
- IconButton,
4
- ListItemIcon,
5
- ListItemText,
6
- Menu,
7
- MenuItem,
8
- } from '@mui/material';
2
+ import { Box, IconButton, Menu, MenuItem } from '@mui/material';
9
3
  import { useMRT } from '../useMRT';
10
4
  import { MRT_HeaderGroup } from '..';
11
5
  import { MRT_FilterTypeMenu } from './MRT_FilterTypeMenu';
12
6
 
13
7
  export const commonMenuItemStyles = {
14
- py: '0 !important',
15
- my: '0 !important',
8
+ py: '6px',
9
+ my: 0,
10
+ justifyContent: 'space-between',
11
+ alignItems: 'center',
12
+ };
13
+
14
+ export const commonListItemStyles = {
15
+ display: 'flex',
16
+ gap: '0.75rem',
17
+ alignItems: 'center',
16
18
  };
17
19
 
18
20
  interface Props {
@@ -36,6 +38,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
36
38
  ClearAllIcon,
37
39
  DynamicFeedIcon,
38
40
  FilterListIcon,
41
+ FilterListOffIcon,
39
42
  SortIcon,
40
43
  VisibilityOffIcon,
41
44
  },
@@ -73,6 +76,11 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
73
76
  setAnchorEl(null);
74
77
  };
75
78
 
79
+ const handleClearFilter = () => {
80
+ column.setFilter('');
81
+ setAnchorEl(null);
82
+ };
83
+
76
84
  const handleFilterByColumn = () => {
77
85
  setShowFilters(true);
78
86
  setTimeout(
@@ -101,23 +109,20 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
101
109
  onClose={() => setAnchorEl(null)}
102
110
  MenuListProps={{
103
111
  dense: tableInstance.state.densePadding,
104
- disablePadding: true,
105
112
  }}
106
113
  >
107
114
  {!disableSortBy &&
108
115
  column.canSort && [
109
116
  <MenuItem
110
- key={1}
111
117
  disabled={!column.isSorted}
118
+ key={1}
112
119
  onClick={handleClearSort}
113
120
  sx={commonMenuItemStyles}
114
121
  >
115
- <ListItemIcon>
122
+ <Box sx={commonListItemStyles}>
116
123
  <ClearAllIcon />
117
- </ListItemIcon>
118
- <ListItemText sx={commonMenuItemStyles}>
119
124
  {localization.columnActionMenuItemClearSort}
120
- </ListItemText>
125
+ </Box>
121
126
  </MenuItem>,
122
127
  <MenuItem
123
128
  disabled={column.isSorted && !column.isSortedDesc}
@@ -125,15 +130,13 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
125
130
  onClick={handleSortAsc}
126
131
  sx={commonMenuItemStyles}
127
132
  >
128
- <ListItemIcon>
133
+ <Box sx={commonListItemStyles}>
129
134
  <SortIcon />
130
- </ListItemIcon>
131
- <ListItemText sx={commonMenuItemStyles}>
132
135
  {localization.columnActionMenuItemSortAsc?.replace(
133
136
  '{column}',
134
137
  String(column.Header),
135
138
  )}
136
- </ListItemText>
139
+ </Box>
137
140
  </MenuItem>,
138
141
  <MenuItem
139
142
  divider={
@@ -144,42 +147,51 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
144
147
  onClick={handleSortDesc}
145
148
  sx={commonMenuItemStyles}
146
149
  >
147
- <ListItemIcon>
150
+ <Box sx={commonListItemStyles}>
148
151
  <SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />
149
- </ListItemIcon>
150
- <ListItemText sx={commonMenuItemStyles}>
151
152
  {localization.columnActionMenuItemSortDesc?.replace(
152
153
  '{column}',
153
154
  String(column.Header),
154
155
  )}
155
- </ListItemText>
156
+ </Box>
156
157
  </MenuItem>,
157
158
  ]}
158
159
  {!disableFilters &&
159
160
  column.canFilter && [
161
+ <MenuItem
162
+ disabled={!column.filterValue}
163
+ key={0}
164
+ onClick={handleClearFilter}
165
+ sx={commonMenuItemStyles}
166
+ >
167
+ <Box sx={commonListItemStyles}>
168
+ <FilterListOffIcon />
169
+ {localization.filterTextFieldClearButtonTitle}
170
+ </Box>
171
+ </MenuItem>,
160
172
  <MenuItem
161
173
  divider={enableColumnGrouping || !disableColumnHiding}
162
174
  key={1}
163
175
  onClick={handleFilterByColumn}
164
176
  sx={commonMenuItemStyles}
165
177
  >
166
- <ListItemIcon>
178
+ <Box sx={commonListItemStyles}>
167
179
  <FilterListIcon />
168
- </ListItemIcon>
169
- <ListItemText sx={commonMenuItemStyles}>
170
180
  {localization.filterTextFieldPlaceholder?.replace(
171
181
  '{column}',
172
182
  String(column.Header),
173
183
  )}
174
- </ListItemText>
175
- <IconButton
176
- onClick={handleOpenFilterModeMenu}
177
- onMouseEnter={handleOpenFilterModeMenu}
178
- size="small"
179
- sx={{ p: 0 }}
180
- >
181
- <ArrowRightIcon />
182
- </IconButton>
184
+ </Box>
185
+ {!column.filterSelectOptions && (
186
+ <IconButton
187
+ onClick={handleOpenFilterModeMenu}
188
+ onMouseEnter={handleOpenFilterModeMenu}
189
+ size="small"
190
+ sx={{ p: 0 }}
191
+ >
192
+ <ArrowRightIcon />
193
+ </IconButton>
194
+ )}
183
195
  </MenuItem>,
184
196
  <MRT_FilterTypeMenu
185
197
  anchorEl={filterMenuAnchorEl}
@@ -197,29 +209,25 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
197
209
  onClick={handleGroupByColumn}
198
210
  sx={commonMenuItemStyles}
199
211
  >
200
- <ListItemIcon>
212
+ <Box sx={commonListItemStyles}>
201
213
  <DynamicFeedIcon />
202
- </ListItemIcon>
203
- <ListItemText sx={commonMenuItemStyles}>
204
214
  {localization[
205
215
  column.isGrouped
206
216
  ? 'columnActionMenuItemUnGroupBy'
207
217
  : 'columnActionMenuItemGroupBy'
208
218
  ]?.replace('{column}', String(column.Header))}
209
- </ListItemText>
219
+ </Box>
210
220
  </MenuItem>,
211
221
  ]}
212
222
  {!disableColumnHiding && [
213
223
  <MenuItem key={1} onClick={handleHideColumn} sx={commonMenuItemStyles}>
214
- <ListItemIcon>
224
+ <Box sx={commonListItemStyles}>
215
225
  <VisibilityOffIcon />
216
- </ListItemIcon>
217
- <ListItemText sx={commonMenuItemStyles}>
218
226
  {localization.columnActionMenuItemHideColumn?.replace(
219
227
  '{column}',
220
228
  String(column.Header),
221
229
  )}
222
- </ListItemText>
230
+ </Box>
223
231
  </MenuItem>,
224
232
  ]}
225
233
  </Menu>
@@ -1,9 +1,13 @@
1
1
  import React, { FC, useMemo } from 'react';
2
2
  import { Menu, MenuItem } from '@mui/material';
3
3
  import { useMRT } from '../useMRT';
4
- import { MRT_FilterType, MRT_HeaderGroup } from '..';
5
- import { commonMenuItemStyles } from './MRT_ColumnActionMenu';
4
+ import { MRT_FilterType, MRT_FILTER_TYPE, MRT_HeaderGroup } from '..';
6
5
 
6
+ const commonMenuItemStyles = {
7
+ py: '6px',
8
+ my: 0,
9
+ alignItems: 'center',
10
+ };
7
11
 
8
12
  interface Props {
9
13
  anchorEl: HTMLElement | null;
@@ -21,48 +25,48 @@ export const MRT_FilterTypeMenu: FC<Props> = ({
21
25
  const { localization, setCurrentFilterTypes, tableInstance } = useMRT();
22
26
 
23
27
  const filterTypes: {
24
- type: MRT_FilterType;
28
+ type: MRT_FILTER_TYPE;
25
29
  label: string;
26
30
  divider: boolean;
27
31
  }[] = useMemo(
28
32
  () => [
29
33
  {
30
- type: 'fuzzy',
34
+ type: MRT_FILTER_TYPE.FUZZY,
31
35
  label: localization.filterMenuItemFuzzy,
32
36
  divider: false,
33
37
  },
34
38
  {
35
- type: 'contains',
39
+ type: MRT_FILTER_TYPE.CONTAINS,
36
40
  label: localization.filterMenuItemContains,
37
41
  divider: true,
38
42
  },
39
43
  {
40
- type: 'startsWith',
44
+ type: MRT_FILTER_TYPE.STARTS_WITH,
41
45
  label: localization.filterMenuItemStartsWith,
42
46
  divider: false,
43
47
  },
44
48
  {
45
- type: 'endsWith',
49
+ type: MRT_FILTER_TYPE.ENDS_WITH,
46
50
  label: localization.filterMenuItemEndsWith,
47
51
  divider: true,
48
52
  },
49
53
  {
50
- type: 'equals',
54
+ type: MRT_FILTER_TYPE.EQUALS,
51
55
  label: localization.filterMenuItemEquals,
52
56
  divider: false,
53
57
  },
54
58
  {
55
- type: 'notEquals',
59
+ type: MRT_FILTER_TYPE.NOT_EQUALS,
56
60
  label: localization.filterMenuItemNotEquals,
57
61
  divider: true,
58
62
  },
59
63
  {
60
- type: 'empty',
64
+ type: MRT_FILTER_TYPE.EMPTY,
61
65
  label: localization.filterMenuItemEmpty,
62
66
  divider: false,
63
67
  },
64
68
  {
65
- type: 'notEmpty',
69
+ type: MRT_FILTER_TYPE.NOT_EMPTY,
66
70
  label: localization.filterMenuItemNotEmpty,
67
71
  divider: false,
68
72
  },
@@ -70,13 +74,13 @@ export const MRT_FilterTypeMenu: FC<Props> = ({
70
74
  [],
71
75
  );
72
76
 
73
- const handleSelectFilterType = (value: MRT_FilterType) => {
77
+ const handleSelectFilterType = (value: MRT_FILTER_TYPE) => {
74
78
  setAnchorEl(null);
75
79
  setCurrentFilterTypes((prev: { [key: string]: MRT_FilterType }) => ({
76
80
  ...prev,
77
81
  [column.id]: value,
78
82
  }));
79
- if (['empty', 'notEmpty'].includes(value)) {
83
+ if ([MRT_FILTER_TYPE.EMPTY, MRT_FILTER_TYPE.NOT_EMPTY].includes(value)) {
80
84
  column.setFilter(' ');
81
85
  }
82
86
  onSelect?.();
@@ -92,17 +96,16 @@ export const MRT_FilterTypeMenu: FC<Props> = ({
92
96
  open={!!anchorEl}
93
97
  MenuListProps={{
94
98
  dense: tableInstance.state.densePadding,
95
- disablePadding: true,
96
99
  }}
97
100
  >
98
- {filterTypes.map(({ type, label, divider }) => (
101
+ {filterTypes.map(({ type, label, divider }, index) => (
99
102
  <MenuItem
100
103
  divider={divider}
101
- key={type}
104
+ key={index}
102
105
  onClick={() => handleSelectFilterType(type)}
103
106
  selected={type === filterType}
104
- value={type}
105
107
  sx={commonMenuItemStyles}
108
+ value={type}
106
109
  >
107
110
  {label}
108
111
  </MenuItem>
@@ -1,10 +1,9 @@
1
1
  import React, { FC } from 'react';
2
- import { ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/material';
2
+ import { Menu, MenuItem } from '@mui/material';
3
3
  import { useMRT } from '../useMRT';
4
4
  import { MRT_Row } from '..';
5
5
  import { commonMenuItemStyles } from './MRT_ColumnActionMenu';
6
6
 
7
-
8
7
  interface Props {
9
8
  anchorEl: HTMLElement | null;
10
9
  row: MRT_Row;
@@ -33,17 +32,12 @@ export const MRT_RowActionMenu: FC<Props> = ({
33
32
  onClose={() => setAnchorEl(null)}
34
33
  MenuListProps={{
35
34
  dense: tableInstance.state.densePadding,
36
- disablePadding: true,
37
35
  }}
38
36
  >
39
37
  {enableRowEditing && (
40
38
  <MenuItem onClick={handleEdit} sx={commonMenuItemStyles}>
41
- <ListItemIcon>
42
- <EditIcon />
43
- </ListItemIcon>
44
- <ListItemText sx={commonMenuItemStyles}>
45
- {localization.rowActionMenuItemEdit}
46
- </ListItemText>
39
+ <EditIcon />
40
+ {localization.rowActionMenuItemEdit}
47
41
  </MenuItem>
48
42
  )}
49
43
  {renderRowActionMenuItems?.(row, tableInstance, () =>