material-react-table 0.7.4 → 0.8.0-alpha.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.
Files changed (57) hide show
  1. package/dist/MaterialReactTable.d.ts +25 -31
  2. package/dist/body/MRT_TableBody.d.ts +0 -1
  3. package/dist/body/MRT_TableBodyCell.d.ts +1 -0
  4. package/dist/body/MRT_TableBodyRow.d.ts +0 -1
  5. package/dist/buttons/MRT_ColumnPinningButtons.d.ts +8 -0
  6. package/dist/buttons/MRT_CopyButton.d.ts +2 -1
  7. package/dist/enums.d.ts +3 -3
  8. package/dist/filtersFNs.d.ts +31 -30
  9. package/dist/footer/MRT_TableFooter.d.ts +0 -1
  10. package/dist/head/MRT_TableHead.d.ts +0 -1
  11. package/dist/inputs/MRT_FilterRangeFields.d.ts +8 -0
  12. package/dist/inputs/MRT_FilterTextField.d.ts +1 -0
  13. package/dist/localization.d.ts +7 -2
  14. package/dist/material-react-table.cjs.development.js +489 -448
  15. package/dist/material-react-table.cjs.development.js.map +1 -1
  16. package/dist/material-react-table.cjs.production.min.js +1 -1
  17. package/dist/material-react-table.cjs.production.min.js.map +1 -1
  18. package/dist/material-react-table.esm.js +492 -451
  19. package/dist/material-react-table.esm.js.map +1 -1
  20. package/dist/menus/{MRT_FilterTypeMenu.d.ts → MRT_FilterOptionMenu.d.ts} +1 -1
  21. package/dist/table/MRT_Table.d.ts +0 -1
  22. package/dist/toolbar/MRT_ToolbarTop.d.ts +1 -0
  23. package/dist/utils.d.ts +6 -6
  24. package/package.json +24 -24
  25. package/src/MaterialReactTable.tsx +39 -41
  26. package/src/body/MRT_TableBody.tsx +3 -11
  27. package/src/body/MRT_TableBodyCell.tsx +102 -51
  28. package/src/body/MRT_TableBodyRow.tsx +21 -30
  29. package/src/buttons/MRT_ColumnPinningButtons.tsx +57 -0
  30. package/src/buttons/MRT_CopyButton.tsx +3 -2
  31. package/src/buttons/MRT_EditActionButtons.tsx +1 -2
  32. package/src/buttons/MRT_ExpandAllButton.tsx +1 -2
  33. package/src/enums.ts +3 -3
  34. package/src/filtersFNs.ts +71 -81
  35. package/src/footer/MRT_TableFooter.tsx +6 -16
  36. package/src/footer/MRT_TableFooterCell.tsx +5 -7
  37. package/src/footer/MRT_TableFooterRow.tsx +5 -8
  38. package/src/head/MRT_TableHead.tsx +5 -16
  39. package/src/head/MRT_TableHeadCell.tsx +101 -44
  40. package/src/head/MRT_TableHeadRow.tsx +8 -15
  41. package/src/inputs/MRT_EditCellTextField.tsx +2 -2
  42. package/src/inputs/MRT_FilterRangeFields.tsx +41 -0
  43. package/src/inputs/MRT_FilterTextField.tsx +84 -52
  44. package/src/inputs/MRT_SearchTextField.tsx +2 -2
  45. package/src/inputs/MRT_SelectCheckbox.tsx +16 -17
  46. package/src/localization.ts +15 -5
  47. package/src/menus/MRT_ColumnActionMenu.tsx +9 -8
  48. package/src/menus/{MRT_FilterTypeMenu.tsx → MRT_FilterOptionMenu.tsx} +54 -49
  49. package/src/menus/MRT_ShowHideColumnsMenu.tsx +25 -11
  50. package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +15 -5
  51. package/src/table/MRT_Table.tsx +8 -19
  52. package/src/table/MRT_TableContainer.tsx +8 -69
  53. package/src/table/MRT_TableRoot.tsx +70 -70
  54. package/src/toolbar/MRT_LinearProgressBar.tsx +5 -2
  55. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +3 -2
  56. package/src/toolbar/MRT_ToolbarTop.tsx +4 -6
  57. package/src/utils.ts +10 -10
@@ -1,19 +1,21 @@
1
1
  import React, { FC, MouseEvent } from 'react';
2
2
  import {
3
+ Box,
4
+ Collapse,
5
+ Divider,
6
+ IconButton,
3
7
  TableCell,
4
8
  TableSortLabel,
5
- Divider,
6
- Collapse,
9
+ Theme,
7
10
  Tooltip,
8
- Box,
9
- IconButton,
10
11
  alpha,
11
- Theme,
12
+ lighten,
12
13
  } from '@mui/material';
13
14
  import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
14
15
  import { MRT_ToggleColumnActionMenuButton } from '../buttons/MRT_ToggleColumnActionMenuButton';
15
16
  import type { MRT_Header, MRT_TableInstance } from '..';
16
- import { ColumnResizerProps } from '@tanstack/react-table';
17
+ import MRT_FilterRangeFields from '../inputs/MRT_FilterRangeFields';
18
+ import { MRT_FILTER_OPTION } from '../enums';
17
19
 
18
20
  interface Props {
19
21
  header: MRT_Header;
@@ -34,7 +36,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
34
36
  setShowFilters,
35
37
  } = tableInstance;
36
38
 
37
- const { isDensePadding, showFilters } = getState();
39
+ const { currentFilterFns, isDensePadding, showFilters } = getState();
38
40
 
39
41
  const { column } = header;
40
42
 
@@ -49,7 +51,6 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
49
51
  : column.muiTableHeadCellProps;
50
52
 
51
53
  const tableCellProps = {
52
- ...header.getHeaderProps(),
53
54
  ...mTableHeadCellProps,
54
55
  ...mcTableHeadCellProps,
55
56
  };
@@ -60,23 +61,30 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
60
61
  : localization.sortedByColumnAsc.replace('{column}', column.header)
61
62
  : localization.unsorted;
62
63
 
63
- const filterType = getState()?.currentFilterTypes?.[header.id];
64
+ const filterFn = getState()?.currentFilterFns?.[header.id];
64
65
 
65
- const filterTooltip = !!column.getColumnFilterValue()
66
+ const filterTooltip = !!column.getFilterValue()
66
67
  ? localization.filteringByColumn
67
68
  .replace('{column}', String(column.header))
68
69
  .replace(
69
70
  '{filterType}',
70
- filterType instanceof Function
71
+ filterFn instanceof Function
71
72
  ? ''
72
73
  : // @ts-ignore
73
74
  localization[
74
- `filter${
75
- filterType.charAt(0).toUpperCase() + filterType.slice(1)
76
- }`
75
+ `filter${filterFn.charAt(0).toUpperCase() + filterFn.slice(1)}`
77
76
  ],
78
77
  )
79
- .replace('{filterValue}', column.getColumnFilterValue() as string)
78
+ .replace(
79
+ '{filterValue}',
80
+ `"${
81
+ Array.isArray(column.getFilterValue())
82
+ ? (column.getFilterValue() as [string, string]).join(
83
+ `" ${localization.and} "`,
84
+ )
85
+ : (column.getFilterValue() as string)
86
+ }"`,
87
+ )
80
88
  .replace('" "', '')
81
89
  : localization.showHideFilters;
82
90
 
@@ -86,21 +94,51 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
86
94
  tableInstance,
87
95
  }) ?? column.header;
88
96
 
97
+ const getIsLastLeftPinnedColumn = () => {
98
+ return (
99
+ column.getIsPinned() === 'left' &&
100
+ tableInstance.getLeftLeafHeaders().length - 1 === column.getPinnedIndex()
101
+ );
102
+ };
103
+
104
+ const getIsFirstRightPinnedColumn = () => {
105
+ return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
106
+ };
107
+
108
+ const getTotalRight = () => {
109
+ return (
110
+ (tableInstance.getRightLeafHeaders().length -
111
+ 1 -
112
+ column.getPinnedIndex()) *
113
+ 150
114
+ );
115
+ };
116
+
89
117
  return (
90
118
  <TableCell
91
119
  align={column.columnDefType === 'group' ? 'center' : 'left'}
120
+ colSpan={header.colSpan}
92
121
  {...tableCellProps}
93
- //@ts-ignore
94
122
  sx={(theme: Theme) => ({
95
- backgroundColor: theme.palette.background.default,
96
- backgroundImage: `linear-gradient(${alpha(
97
- theme.palette.common.white,
98
- 0.05,
99
- )},${alpha(theme.palette.common.white, 0.05)})`,
123
+ backgroundColor:
124
+ column.getIsPinned() && column.columnDefType !== 'group'
125
+ ? alpha(lighten(theme.palette.background.default, 0.04), 0.95)
126
+ : 'inherit',
127
+ backgroundImage: 'inherit',
128
+ boxShadow: getIsLastLeftPinnedColumn()
129
+ ? `4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
130
+ : getIsFirstRightPinnedColumn()
131
+ ? `-4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
132
+ : undefined,
100
133
  fontWeight: 'bold',
101
134
  height: '100%',
102
- maxWidth: `min(${column.getWidth()}px, ${column.maxWidth}px)`,
103
- minWidth: `max(${column.getWidth()}px, ${column.minWidth}px)`,
135
+ left:
136
+ column.getIsPinned() === 'left'
137
+ ? `${column.getStart('left')}px`
138
+ : undefined,
139
+ maxWidth: `min(${column.getSize()}px, fit-content)`,
140
+ minWidth: `max(${column.getSize()}px, ${column.minSize}px)`,
141
+ overflow: 'visible',
104
142
  p: isDensePadding
105
143
  ? column.columnDefType === 'display'
106
144
  ? '0 0.5rem'
@@ -108,20 +146,28 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
108
146
  : column.columnDefType === 'display'
109
147
  ? '0.5rem 0.75rem'
110
148
  : '1rem',
149
+ pb: column.columnDefType === 'display' ? 0 : undefined,
150
+ position:
151
+ column.getIsPinned() && column.columnDefType !== 'group'
152
+ ? 'sticky'
153
+ : undefined,
111
154
  pt:
112
155
  column.columnDefType === 'display'
113
156
  ? 0
114
157
  : isDensePadding
115
158
  ? '0.75rem'
116
159
  : '1.25rem',
117
- pb: column.columnDefType === 'display' ? 0 : undefined,
118
- overflow: 'visible',
160
+ right:
161
+ column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined,
119
162
  transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`,
120
163
  verticalAlign: 'text-top',
121
- width: header.getWidth(),
122
- zIndex: column.getIsResizing() ? 2 : 1,
123
- //@ts-ignore
124
- ...tableCellProps?.sx,
164
+ width: header.getSize(),
165
+ zIndex: column.getIsResizing()
166
+ ? 3
167
+ : column.getIsPinned() && column.columnDefType !== 'group'
168
+ ? 2
169
+ : 1,
170
+ ...(tableCellProps?.sx as any),
125
171
  })}
126
172
  >
127
173
  {header.isPlaceholder ? null : column.columnDefType === 'display' ? (
@@ -165,7 +211,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
165
211
  )}
166
212
  {column.columnDefType === 'data' &&
167
213
  enableColumnFilters &&
168
- !!column.getCanColumnFilter() && (
214
+ !!column.getCanFilter() && (
169
215
  <Tooltip arrow placement="top" title={filterTooltip}>
170
216
  <IconButton
171
217
  disableRipple
@@ -176,7 +222,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
176
222
  size="small"
177
223
  sx={{
178
224
  m: 0,
179
- opacity: !!column.getColumnFilterValue() ? 0.8 : 0,
225
+ opacity: !!column.getFilterValue() ? 0.8 : 0,
180
226
  p: '2px',
181
227
  transition: 'all 0.2s ease-in-out',
182
228
  '&:hover': {
@@ -185,7 +231,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
185
231
  },
186
232
  }}
187
233
  >
188
- {showFilters && !column.getColumnFilterValue() ? (
234
+ {showFilters && !column.getFilterValue() ? (
189
235
  <FilterAltOff />
190
236
  ) : (
191
237
  <FilterAltIcon />
@@ -206,7 +252,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
206
252
  <Divider
207
253
  flexItem
208
254
  orientation="vertical"
209
- onDoubleClick={() => header.resetSize()}
255
+ onDoubleClick={() => column.resetSize()}
210
256
  sx={(theme: Theme) => ({
211
257
  borderRadius: '2px',
212
258
  borderRightWidth: '2px',
@@ -227,21 +273,32 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
227
273
  opacity: 1,
228
274
  },
229
275
  })}
230
- {...(header.getResizerProps((props: ColumnResizerProps) => ({
231
- ...props,
232
- style: {
233
- transform: column.getIsResizing()
234
- ? `translateX(${getState().columnSizingInfo.deltaOffset}px)`
235
- : '',
236
- },
237
- })) as any)}
276
+ {...{
277
+ onMouseDown: header.getResizeHandler,
278
+ onTouchStart: header.getResizeHandler,
279
+ }}
280
+ style={{
281
+ transform: column.getIsResizing()
282
+ ? `translateX(${getState().columnSizingInfo.deltaOffset}px)`
283
+ : 'none',
284
+ }}
238
285
  />
239
286
  )}
240
287
  </Box>
241
288
  )}
242
- {column.columnDefType === 'data' && column.getCanColumnFilter() && (
243
- <Collapse in={showFilters}>
244
- <MRT_FilterTextField header={header} tableInstance={tableInstance} />
289
+ {column.columnDefType === 'data' && column.getCanFilter() && (
290
+ <Collapse in={showFilters} mountOnEnter unmountOnExit>
291
+ {currentFilterFns[column.id] === MRT_FILTER_OPTION.BETWEEN ? (
292
+ <MRT_FilterRangeFields
293
+ header={header}
294
+ tableInstance={tableInstance}
295
+ />
296
+ ) : (
297
+ <MRT_FilterTextField
298
+ header={header}
299
+ tableInstance={tableInstance}
300
+ />
301
+ )}
245
302
  </Collapse>
246
303
  )}
247
304
  </TableCell>
@@ -1,5 +1,5 @@
1
- import React, { CSSProperties, FC } from 'react';
2
- import { alpha, TableRow } from '@mui/material';
1
+ import React, { FC } from 'react';
2
+ import { alpha, lighten, TableRow } from '@mui/material';
3
3
  import { MRT_TableHeadCell } from './MRT_TableHeadCell';
4
4
  import type { MRT_Header, MRT_HeaderGroup, MRT_TableInstance } from '..';
5
5
 
@@ -13,26 +13,19 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup, tableInstance }) => {
13
13
  options: { muiTableHeadRowProps },
14
14
  } = tableInstance;
15
15
 
16
- const mTableHeadRowProps =
16
+ const tableRowProps =
17
17
  muiTableHeadRowProps instanceof Function
18
18
  ? muiTableHeadRowProps({ headerGroup, tableInstance })
19
19
  : muiTableHeadRowProps;
20
20
 
21
- const tableRowProps = {
22
- ...headerGroup?.getHeaderGroupProps(),
23
- ...mTableHeadRowProps,
24
- };
25
-
26
21
  return (
27
22
  <TableRow
28
23
  {...tableRowProps}
29
- sx={(theme) =>
30
- ({
31
- boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`,
32
- //@ts-ignore
33
- ...tableRowProps?.sx,
34
- } as CSSProperties)
35
- }
24
+ sx={(theme) => ({
25
+ boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`,
26
+ backgroundColor: lighten(theme.palette.background.default, 0.04),
27
+ ...(tableRowProps?.sx as any),
28
+ })}
36
29
  >
37
30
  {headerGroup.headers.map((header: MRT_Header, index) => (
38
31
  <MRT_TableHeadCell
@@ -27,7 +27,7 @@ export const MRT_EditCellTextField: FC<Props> = ({ cell, tableInstance }) => {
27
27
  setCurrentEditingRow,
28
28
  } = tableInstance;
29
29
 
30
- const [value, setValue] = useState(cell.value);
30
+ const [value, setValue] = useState(cell.getValue());
31
31
 
32
32
  const { column, row } = cell;
33
33
 
@@ -39,7 +39,7 @@ export const MRT_EditCellTextField: FC<Props> = ({ cell, tableInstance }) => {
39
39
 
40
40
  const handleBlur = (event: FocusEvent<HTMLInputElement>) => {
41
41
  if (getState().currentEditingRow) {
42
- row.values[column.id] = value;
42
+ row._valuesCache[column.id] = value;
43
43
  setCurrentEditingRow({ ...getState().currentEditingRow } as MRT_Row);
44
44
  }
45
45
  setCurrentEditingCell(null);
@@ -0,0 +1,41 @@
1
+ import React, { FC } from 'react';
2
+ import { Box } from '@mui/material';
3
+ import { MRT_FilterTextField } from './MRT_FilterTextField';
4
+ import { MRT_Header, MRT_TableInstance } from '..';
5
+
6
+ interface Props {
7
+ header: MRT_Header;
8
+ tableInstance: MRT_TableInstance;
9
+ }
10
+
11
+ const MRT_FilterRangeFields: FC<Props> = ({ header, tableInstance }) => {
12
+ const {
13
+ options: { localization },
14
+ } = tableInstance;
15
+
16
+ return (
17
+ <Box sx={{ display: 'grid', gridTemplateColumns: '6fr auto 5fr' }}>
18
+ <MRT_FilterTextField
19
+ header={header}
20
+ inputIndex={0}
21
+ tableInstance={tableInstance}
22
+ />
23
+ <Box
24
+ sx={{
25
+ width: '100%',
26
+ minWidth: '5ch',
27
+ textAlign: 'center',
28
+ }}
29
+ >
30
+ {localization.to}
31
+ </Box>
32
+ <MRT_FilterTextField
33
+ header={header}
34
+ inputIndex={1}
35
+ tableInstance={tableInstance}
36
+ />
37
+ </Box>
38
+ );
39
+ };
40
+
41
+ export default MRT_FilterRangeFields;
@@ -16,15 +16,20 @@ import {
16
16
  Tooltip,
17
17
  } from '@mui/material';
18
18
  import type { MRT_Header, MRT_TableInstance } from '..';
19
- import { MRT_FilterTypeMenu } from '../menus/MRT_FilterTypeMenu';
20
- import { MRT_FILTER_TYPE } from '../enums';
19
+ import { MRT_FilterOptionMenu } from '../menus/MRT_FilterOptionMenu';
20
+ import { MRT_FILTER_OPTION } from '../enums';
21
21
 
22
22
  interface Props {
23
23
  header: MRT_Header;
24
+ inputIndex?: number;
24
25
  tableInstance: MRT_TableInstance;
25
26
  }
26
27
 
27
- export const MRT_FilterTextField: FC<Props> = ({ header, tableInstance }) => {
28
+ export const MRT_FilterTextField: FC<Props> = ({
29
+ header,
30
+ inputIndex,
31
+ tableInstance,
32
+ }) => {
28
33
  const {
29
34
  getState,
30
35
  options: {
@@ -33,12 +38,12 @@ export const MRT_FilterTextField: FC<Props> = ({ header, tableInstance }) => {
33
38
  localization,
34
39
  muiTableHeadCellFilterTextFieldProps,
35
40
  },
36
- setCurrentFilterTypes,
41
+ setCurrentFilterFns,
37
42
  } = tableInstance;
38
43
 
39
44
  const { column } = header;
40
45
 
41
- const { currentFilterTypes } = getState();
46
+ const { currentFilterFns } = getState();
42
47
 
43
48
  const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
44
49
 
@@ -57,14 +62,22 @@ export const MRT_FilterTextField: FC<Props> = ({ header, tableInstance }) => {
57
62
  ...mcTableHeadCellFilterTextFieldProps,
58
63
  } as TextFieldProps;
59
64
 
60
- const [filterValue, setFilterValue] = useState<string>(
61
- (column.getColumnFilterValue() ?? '') as string,
65
+ const [filterValue, setFilterValue] = useState<string>(() =>
66
+ inputIndex !== undefined
67
+ ? (column.getFilterValue() as [string, string])?.[inputIndex] ?? ''
68
+ : (column.getFilterValue() as string) ?? '',
62
69
  );
63
70
 
64
- const handleChange = useCallback(
71
+ const handleChangeDebounced = useCallback(
65
72
  debounce(
66
73
  (event: ChangeEvent<HTMLInputElement>) =>
67
- column.setColumnFilterValue(event.target.value ?? undefined),
74
+ inputIndex !== undefined
75
+ ? column.setFilterValue((old: [string, string]) => {
76
+ const newFilterValues = old ?? ['', ''];
77
+ newFilterValues[inputIndex] = event.target.value;
78
+ return newFilterValues;
79
+ })
80
+ : column.setFilterValue(event.target.value ?? undefined),
68
81
  150,
69
82
  ),
70
83
  [],
@@ -76,15 +89,23 @@ export const MRT_FilterTextField: FC<Props> = ({ header, tableInstance }) => {
76
89
 
77
90
  const handleClear = () => {
78
91
  setFilterValue('');
79
- column.setColumnFilterValue(undefined);
92
+ if (inputIndex !== undefined) {
93
+ column.setFilterValue((old: [string | undefined, string | undefined]) => {
94
+ const newFilterValues = old ?? ['', ''];
95
+ newFilterValues[inputIndex] = undefined;
96
+ return newFilterValues;
97
+ });
98
+ } else {
99
+ column.setFilterValue(undefined);
100
+ }
80
101
  };
81
102
 
82
103
  const handleClearFilterChip = () => {
83
104
  setFilterValue('');
84
- column.setColumnFilterValue(undefined);
85
- setCurrentFilterTypes((prev) => ({
105
+ column.setFilterValue(undefined);
106
+ setCurrentFilterFns((prev) => ({
86
107
  ...prev,
87
- [header.id]: MRT_FILTER_TYPE.BEST_MATCH,
108
+ [header.id]: MRT_FILTER_OPTION.FUZZY,
88
109
  }));
89
110
  };
90
111
 
@@ -92,23 +113,29 @@ export const MRT_FilterTextField: FC<Props> = ({ header, tableInstance }) => {
92
113
  return <>{column.Filter?.({ header, tableInstance })}</>;
93
114
  }
94
115
 
95
- const filterId = `mrt-${idPrefix}-${header.id}-filter-text-field`;
96
- const filterType = currentFilterTypes?.[header.id];
116
+ const filterId = `mrt-${idPrefix}-${header.id}-filter-text-field${
117
+ inputIndex ?? ''
118
+ }`;
119
+ const filterFn = currentFilterFns?.[header.id];
97
120
  const isSelectFilter = !!column.filterSelectOptions;
98
121
  const filterChipLabel =
99
- !(filterType instanceof Function) &&
100
- [MRT_FILTER_TYPE.EMPTY, MRT_FILTER_TYPE.NOT_EMPTY].includes(
101
- filterType as MRT_FILTER_TYPE,
122
+ !(filterFn instanceof Function) &&
123
+ [MRT_FILTER_OPTION.EMPTY, MRT_FILTER_OPTION.NOT_EMPTY].includes(
124
+ filterFn as MRT_FILTER_OPTION,
102
125
  )
103
126
  ? //@ts-ignore
104
127
  localization[
105
- `filter${filterType.charAt(0).toUpperCase() + filterType.slice(1)}`
128
+ `filter${filterFn.charAt(0).toUpperCase() + filterFn.slice(1)}`
106
129
  ]
107
130
  : '';
108
- const filterPlaceholder = localization.filterByColumn?.replace(
109
- '{column}',
110
- String(column.header),
111
- );
131
+ const filterPlaceholder =
132
+ inputIndex === undefined
133
+ ? localization.filterByColumn?.replace('{column}', String(column.header))
134
+ : inputIndex === 0
135
+ ? localization.min
136
+ : inputIndex === 1
137
+ ? localization.max
138
+ : '';
112
139
 
113
140
  return (
114
141
  <>
@@ -124,48 +151,53 @@ export const MRT_FilterTextField: FC<Props> = ({ header, tableInstance }) => {
124
151
  title: filterPlaceholder,
125
152
  }}
126
153
  helperText={
127
- <label htmlFor={filterId}>
128
- {filterType instanceof Function
129
- ? localization.filterMode.replace(
130
- '{filterType}',
131
- // @ts-ignore
132
- localization[
133
- `filter${
134
- filterType.name.charAt(0).toUpperCase() +
135
- filterType.name.slice(1)
136
- }`
137
- ] ?? '',
138
- ) ?? ''
139
- : localization.filterMode.replace(
140
- '{filterType}',
141
- // @ts-ignore
142
- localization[
143
- `filter${
144
- filterType.charAt(0).toUpperCase() + filterType.slice(1)
145
- }`
146
- ],
147
- )}
148
- </label>
154
+ !inputIndex ? (
155
+ <label htmlFor={filterId}>
156
+ {filterFn instanceof Function
157
+ ? localization.filterMode.replace(
158
+ '{filterType}',
159
+ // @ts-ignore
160
+ localization[
161
+ `filter${
162
+ filterFn.name.charAt(0).toUpperCase() +
163
+ filterFn.name.slice(1)
164
+ }`
165
+ ] ?? '',
166
+ ) ?? ''
167
+ : localization.filterMode.replace(
168
+ '{filterType}',
169
+ // @ts-ignore
170
+ localization[
171
+ `filter${
172
+ filterFn.charAt(0).toUpperCase() + filterFn.slice(1)
173
+ }`
174
+ ],
175
+ )}
176
+ </label>
177
+ ) : null
149
178
  }
150
179
  FormHelperTextProps={{
151
- sx: { fontSize: '0.6rem', lineHeight: '0.8rem' },
180
+ sx: {
181
+ fontSize: '0.6rem',
182
+ lineHeight: '0.8rem',
183
+ whiteSpace: 'nowrap',
184
+ },
152
185
  }}
153
186
  label={isSelectFilter && !filterValue ? filterPlaceholder : undefined}
154
187
  margin="none"
155
188
  placeholder={
156
- filterPlaceholder
157
- // filterChipLabel || isSelectFilter ? undefined : filterPlaceholder
189
+ filterChipLabel || isSelectFilter ? undefined : filterPlaceholder
158
190
  }
159
191
  onChange={(event: ChangeEvent<HTMLInputElement>) => {
160
192
  setFilterValue(event.target.value);
161
- handleChange(event);
193
+ handleChangeDebounced(event);
162
194
  }}
163
195
  onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
164
196
  select={isSelectFilter}
165
197
  value={filterValue ?? ''}
166
198
  variant="standard"
167
199
  InputProps={{
168
- startAdornment: !isSelectFilter && (
200
+ startAdornment: !isSelectFilter && !inputIndex && (
169
201
  <InputAdornment position="start">
170
202
  <Tooltip arrow title={localization.changeFilterMode}>
171
203
  <span>
@@ -217,7 +249,7 @@ export const MRT_FilterTextField: FC<Props> = ({ header, tableInstance }) => {
217
249
  sx={{
218
250
  m: '-0.25rem',
219
251
  p: 0,
220
- minWidth: !filterChipLabel ? '5rem' : 'auto',
252
+ minWidth: !filterChipLabel ? '6rem' : 'auto',
221
253
  width: 'calc(100% + 0.5rem)',
222
254
  mt: isSelectFilter && !filterValue ? '-1rem' : undefined,
223
255
  '& .MuiSelect-icon': {
@@ -248,7 +280,7 @@ export const MRT_FilterTextField: FC<Props> = ({ header, tableInstance }) => {
248
280
  );
249
281
  })}
250
282
  </TextField>
251
- <MRT_FilterTypeMenu
283
+ <MRT_FilterOptionMenu
252
284
  anchorEl={anchorEl}
253
285
  header={header}
254
286
  setAnchorEl={setAnchorEl}
@@ -13,7 +13,7 @@ import {
13
13
  TextField,
14
14
  Tooltip,
15
15
  } from '@mui/material';
16
- import { MRT_FilterTypeMenu } from '../menus/MRT_FilterTypeMenu';
16
+ import { MRT_FilterOptionMenu } from '../menus/MRT_FilterOptionMenu';
17
17
  import { MRT_TableInstance } from '..';
18
18
 
19
19
  interface Props {
@@ -105,7 +105,7 @@ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
105
105
  {...textFieldProps}
106
106
  sx={{ justifySelf: 'end', ...textFieldProps?.sx }}
107
107
  />
108
- <MRT_FilterTypeMenu
108
+ <MRT_FilterOptionMenu
109
109
  anchorEl={anchorEl}
110
110
  setAnchorEl={setAnchorEl}
111
111
  tableInstance={tableInstance}