material-react-table 0.5.3 → 0.5.6

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 (35) hide show
  1. package/dist/MaterialReactTable.d.ts +8 -1
  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 +447 -81
  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 +448 -82
  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 +9 -5
  14. package/src/MaterialReactTable.tsx +23 -1
  15. package/src/body/MRT_TableBodyCell.tsx +12 -3
  16. package/src/buttons/MRT_EditActionButtons.tsx +3 -1
  17. package/src/buttons/MRT_ShowHideColumnsButton.tsx +7 -3
  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_TableFooterCell.tsx +1 -1
  23. package/src/head/MRT_TableHeadCell.tsx +91 -44
  24. package/src/{icons.tsx → icons.ts} +9 -0
  25. package/src/index.tsx +0 -2
  26. package/src/inputs/MRT_FilterTextField.tsx +121 -52
  27. package/src/inputs/MRT_SearchTextField.tsx +2 -1
  28. package/src/inputs/MRT_SelectCheckbox.tsx +5 -7
  29. package/src/localization.ts +30 -4
  30. package/src/menus/MRT_ColumnActionMenu.tsx +103 -39
  31. package/src/menus/MRT_FilterTypeMenu.tsx +109 -0
  32. package/src/menus/MRT_RowActionMenu.tsx +10 -3
  33. package/src/menus/MRT_ShowHideColumnsMenu.tsx +1 -1
  34. package/src/table/MRT_TableContainer.tsx +7 -1
  35. package/src/useMRT.tsx +67 -13
@@ -0,0 +1,10 @@
1
+ import { FC } from 'react';
2
+ import { MRT_HeaderGroup } from '..';
3
+ interface Props {
4
+ anchorEl: HTMLElement | null;
5
+ column: MRT_HeaderGroup;
6
+ setAnchorEl: (anchorEl: HTMLElement | null) => void;
7
+ onSelect?: () => void;
8
+ }
9
+ export declare const MRT_FilterTypeMenu: FC<Props>;
10
+ export {};
package/dist/useMRT.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import React, { PropsWithChildren } from 'react';
2
- import { MRT_Row, MRT_TableInstance } from '.';
1
+ import React, { PropsWithChildren, Dispatch, SetStateAction } from 'react';
2
+ import { MRT_FilterType, MRT_Row, MRT_TableInstance } from '.';
3
3
  import { MRT_Icons } from './icons';
4
4
  import { MRT_Localization } from './localization';
5
5
  import { MaterialReactTableProps } from './MaterialReactTable';
@@ -7,13 +7,17 @@ export declare type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
7
7
  anyRowsCanExpand: boolean;
8
8
  anyRowsExpanded: boolean;
9
9
  icons: MRT_Icons;
10
+ idPrefix: string;
10
11
  localization: MRT_Localization;
11
- setCurrentEditingRow: (currentRowEditingId: MRT_Row<D> | null) => void;
12
- setDensePadding: (densePadding: boolean) => void;
13
- setFullScreen: (fullScreen: boolean) => void;
14
- setShowFilters: (showFilters: boolean) => void;
15
- setShowSearch: (showSearch: boolean) => void;
12
+ setCurrentEditingRow: Dispatch<SetStateAction<MRT_Row<D> | null>>;
13
+ setCurrentFilterTypes: Dispatch<SetStateAction<{
14
+ [key: string]: MRT_FilterType;
15
+ }>>;
16
+ setDensePadding: Dispatch<SetStateAction<boolean>>;
17
+ setFullScreen: Dispatch<SetStateAction<boolean>>;
18
+ setShowFilters: Dispatch<SetStateAction<boolean>>;
19
+ setShowSearch: Dispatch<SetStateAction<boolean>>;
16
20
  tableInstance: MRT_TableInstance<D>;
17
21
  };
18
- export declare const MaterialReactTableProvider: <D extends {}>(props: React.PropsWithChildren<MaterialReactTableProps<D>>) => JSX.Element;
19
- export declare const useMRT: <D extends {}>() => UseMRT<D>;
22
+ export declare const MaterialReactTableProvider: <D extends {} = {}>(props: React.PropsWithChildren<MaterialReactTableProps<D>>) => JSX.Element;
23
+ export declare const useMRT: <D extends {} = {}>() => UseMRT<D>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.3",
2
+ "version": "0.5.6",
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.",
@@ -60,9 +60,9 @@
60
60
  "@emotion/react": "^11.8.1",
61
61
  "@emotion/styled": "^11.8.1",
62
62
  "@etchteam/storybook-addon-status": "^4.2.0",
63
- "@faker-js/faker": "^6.0.0-alpha.7",
64
- "@mui/icons-material": "^5.4.4",
65
- "@mui/material": "^5.4.4",
63
+ "@faker-js/faker": "^6.0.0-beta.0",
64
+ "@mui/icons-material": "^5.5.0",
65
+ "@mui/material": "^5.5.0",
66
66
  "@size-limit/preset-small-lib": "^7.0.8",
67
67
  "@storybook/addon-a11y": "^6.4.19",
68
68
  "@storybook/addon-actions": "^6.4.19",
@@ -75,7 +75,7 @@
75
75
  "@storybook/react": "^6.4.19",
76
76
  "@types/faker": "^6.6.8",
77
77
  "@types/react": "^17.0.39",
78
- "@types/react-dom": "^17.0.11",
78
+ "@types/react-dom": "^17.0.13",
79
79
  "@types/react-table": "^7.7.9",
80
80
  "babel-loader": "^8.2.3",
81
81
  "husky": "^7.0.4",
@@ -93,9 +93,13 @@
93
93
  },
94
94
  "peerDependencies": {
95
95
  "@emotion/react": ">=11",
96
+ "@emotion/styled": ">=11",
96
97
  "@mui/icons-material": ">=5",
97
98
  "@mui/material": ">=5",
98
99
  "react": ">=16.8",
99
100
  "react-table": ">=7"
101
+ },
102
+ "dependencies": {
103
+ "match-sorter": "^6.3.1"
100
104
  }
101
105
  }
@@ -2,6 +2,8 @@ import React, { ChangeEvent, FC, MouseEvent, ReactNode } from 'react';
2
2
  import {
3
3
  AlertProps,
4
4
  IconButtonProps,
5
+ LinearProgressProps,
6
+ SkeletonProps,
5
7
  TableBodyProps,
6
8
  TableCellProps,
7
9
  TableContainerProps,
@@ -181,6 +183,16 @@ export type MRT_Cell<D extends {} = {}, _V = any> = Cell<D> &
181
183
  UseGroupByCellProps<D> &
182
184
  UseRowStateCellProps<D> & {};
183
185
 
186
+ export type MRT_FilterType =
187
+ | 'contains'
188
+ | 'empty'
189
+ | 'endsWith'
190
+ | 'equals'
191
+ | 'fuzzy'
192
+ | 'notEmpty'
193
+ | 'notEquals'
194
+ | 'startsWith';
195
+
184
196
  export type MRT_TableState<D extends {} = {}> = TableState<D> &
185
197
  UseColumnOrderState<D> &
186
198
  UseExpandedState<D> &
@@ -193,6 +205,7 @@ export type MRT_TableState<D extends {} = {}> = TableState<D> &
193
205
  UseRowStateState<D> &
194
206
  UseSortByState<D> & {
195
207
  currentEditingRow: MRT_Row<D> | null;
208
+ currentFilterTypes: { [key: string]: MRT_FilterType };
196
209
  densePadding: boolean;
197
210
  fullScreen: boolean;
198
211
  showFilters: boolean;
@@ -229,9 +242,13 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
229
242
  hideToolbarInternalActions?: boolean;
230
243
  hideToolbarTop?: boolean;
231
244
  icons?: Partial<MRT_Icons>;
245
+ idPrefix?: string;
232
246
  isFetching?: boolean;
233
247
  isLoading?: boolean;
234
248
  localization?: Partial<MRT_Localization>;
249
+ muiLinearProgressProps?:
250
+ | LinearProgressProps
251
+ | ((tableInstance: MRT_TableInstance) => LinearProgressProps);
235
252
  muiSearchTextFieldProps?: TextFieldProps;
236
253
  muiTableBodyCellEditTextFieldProps?:
237
254
  | TextFieldProps
@@ -239,6 +256,9 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
239
256
  muiTableBodyCellProps?:
240
257
  | TableCellProps
241
258
  | ((cell?: MRT_Cell<D>) => TableCellProps);
259
+ muiTableBodyCellSkeletonProps?:
260
+ | SkeletonProps
261
+ | ((cell?: MRT_Cell<D>) => SkeletonProps);
242
262
  muiTableBodyProps?:
243
263
  | TableBodyProps
244
264
  | ((tableInstance: MRT_TableInstance<D>) => TableBodyProps);
@@ -275,7 +295,9 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
275
295
  | ((
276
296
  tableInstance: MRT_TableInstance<D>,
277
297
  ) => Partial<TablePaginationProps>);
278
- muiTableProps?: TableProps | ((tableInstance: MRT_TableInstance<D>) => TableProps);
298
+ muiTableProps?:
299
+ | TableProps
300
+ | ((tableInstance: MRT_TableInstance<D>) => TableProps);
279
301
  muiTableToolbarAlertBannerProps?:
280
302
  | AlertProps
281
303
  | ((tableInstance: MRT_TableInstance<D>) => AlertProps);
@@ -1,5 +1,5 @@
1
1
  import React, { FC, MouseEvent } from 'react';
2
- import { TableCell, TableCellProps } from '@mui/material';
2
+ import { Skeleton, TableCell, TableCellProps } from '@mui/material';
3
3
  import { useMRT } from '../useMRT';
4
4
  import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
5
5
  import { MRT_Cell } from '..';
@@ -22,8 +22,10 @@ interface Props {
22
22
 
23
23
  export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
24
24
  const {
25
- onCellClick,
25
+ isLoading,
26
26
  muiTableBodyCellProps,
27
+ muiTableBodyCellSkeletonProps,
28
+ onCellClick,
27
29
  tableInstance: {
28
30
  state: { currentEditingRow, densePadding },
29
31
  },
@@ -63,7 +65,14 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
63
65
  } as TableCellProps['sx']
64
66
  }
65
67
  >
66
- {currentEditingRow?.id === cell.row.id ? (
68
+ {isLoading ? (
69
+ <Skeleton
70
+ animation="wave"
71
+ height={20}
72
+ width={Math.random() * (120 - 60) + 60}
73
+ {...muiTableBodyCellSkeletonProps}
74
+ />
75
+ ) : currentEditingRow?.id === cell.row.id ? (
67
76
  <MRT_EditCellTextField cell={cell} />
68
77
  ) : cell.isPlaceholder ? null : cell.isAggregated ? (
69
78
  cell.render('Aggregated')
@@ -13,7 +13,9 @@ export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
13
13
  localization,
14
14
  onRowEditSubmit,
15
15
  setCurrentEditingRow,
16
- tableInstance: { state: { currentEditingRow } },
16
+ tableInstance: {
17
+ state: { currentEditingRow },
18
+ },
17
19
  } = useMRT();
18
20
 
19
21
  const handleCancel = () => {
@@ -16,9 +16,9 @@ interface Props extends IconButtonProps {}
16
16
 
17
17
  export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
18
18
  const {
19
- tableInstance,
20
- localization,
21
19
  icons: { ViewColumnIcon },
20
+ localization,
21
+ tableInstance,
22
22
  } = useMRT();
23
23
 
24
24
  const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
@@ -43,12 +43,16 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
43
43
  anchorEl={anchorEl}
44
44
  open={!!anchorEl}
45
45
  onClose={() => setAnchorEl(null)}
46
+ MenuListProps={{
47
+ dense: tableInstance.state.densePadding,
48
+ disablePadding: true,
49
+ }}
46
50
  >
47
51
  <Box
48
52
  sx={{
49
53
  display: 'flex',
50
54
  justifyContent: 'space-between',
51
- p: '0 0.5rem 0.5rem 0.5rem',
55
+ p: '0.5rem',
52
56
  }}
53
57
  >
54
58
  <Button
@@ -35,11 +35,12 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
35
35
  onClick={handleClick}
36
36
  size="small"
37
37
  sx={{
38
+ height: '2rem',
39
+ mr: '2px',
40
+ mt: '-0.2rem',
38
41
  opacity: 0.5,
39
42
  transition: 'opacity 0.2s',
40
- marginRight: '2px',
41
- height: '1.6rem',
42
- width: '1.6rem',
43
+ width: '2rem',
43
44
  '&:hover': {
44
45
  opacity: 1,
45
46
  },
@@ -9,7 +9,9 @@ export const MRT_ToggleFiltersButton: FC<Props> = ({ ...rest }) => {
9
9
  icons: { FilterListIcon, FilterListOffIcon },
10
10
  localization,
11
11
  setShowFilters,
12
- tableInstance: { state: { showFilters } },
12
+ tableInstance: {
13
+ state: { showFilters },
14
+ },
13
15
  } = useMRT();
14
16
 
15
17
  return (
@@ -7,10 +7,13 @@ interface Props extends IconButtonProps {}
7
7
  export const MRT_ToggleSearchButton: FC<Props> = ({ ...rest }) => {
8
8
  const {
9
9
  icons: { SearchIcon, SearchOffIcon },
10
+ idPrefix,
10
11
  localization,
11
12
  muiSearchTextFieldProps,
12
13
  setShowSearch,
13
- tableInstance: { state: { showSearch } },
14
+ tableInstance: {
15
+ state: { showSearch },
16
+ },
14
17
  } = useMRT();
15
18
 
16
19
  const handleToggleSearch = () => {
@@ -19,7 +22,7 @@ export const MRT_ToggleSearchButton: FC<Props> = ({ ...rest }) => {
19
22
  () =>
20
23
  document
21
24
  .getElementById(
22
- muiSearchTextFieldProps?.id ?? `global-search-text-field`,
25
+ muiSearchTextFieldProps?.id ?? `mrt-${idPrefix}-search-text-field`,
23
26
  )
24
27
  ?.focus(),
25
28
  200,
@@ -0,0 +1,112 @@
1
+ import { matchSorter } from 'match-sorter';
2
+ import { MRT_Row } from '.';
3
+
4
+ export const fuzzyFilterFN = (
5
+ rows: MRT_Row[],
6
+ id: string,
7
+ filterValue: string | number,
8
+ ) =>
9
+ matchSorter(rows, filterValue.toString().trim(), {
10
+ keys: [`values.${id}`],
11
+ sorter: (rankedItems) => rankedItems,
12
+ });
13
+
14
+ fuzzyFilterFN.autoRemove = (val: any) => !val;
15
+
16
+ export const containsFilterFN = (
17
+ rows: MRT_Row[],
18
+ id: string,
19
+ filterValue: string | number,
20
+ ) =>
21
+ rows.filter((row) =>
22
+ row.values[id]
23
+ .toString()
24
+ .toLowerCase()
25
+ .trim()
26
+ .includes(filterValue.toString().toLowerCase().trim()),
27
+ );
28
+
29
+ containsFilterFN.autoRemove = (val: any) => !val;
30
+
31
+ export const startsWithFilterFN = (
32
+ rows: MRT_Row[],
33
+ id: string,
34
+ filterValue: string | number,
35
+ ) =>
36
+ rows.filter((row) =>
37
+ row.values[id]
38
+ .toString()
39
+ .toLowerCase()
40
+ .trim()
41
+ .startsWith(filterValue.toString().toLowerCase().trim()),
42
+ );
43
+
44
+ startsWithFilterFN.autoRemove = (val: any) => !val;
45
+
46
+ export const endsWithFilterFN = (
47
+ rows: MRT_Row[],
48
+ id: string,
49
+ filterValue: string | number,
50
+ ) =>
51
+ rows.filter((row) =>
52
+ row.values[id]
53
+ .toString()
54
+ .toLowerCase()
55
+ .trim()
56
+ .endsWith(filterValue.toString().toLowerCase().trim()),
57
+ );
58
+
59
+ endsWithFilterFN.autoRemove = (val: any) => !val;
60
+
61
+ export const equalsFilterFN = (
62
+ rows: MRT_Row[],
63
+ id: string,
64
+ filterValue: string | number,
65
+ ) =>
66
+ rows.filter(
67
+ (row) =>
68
+ row.values[id].toString().toLowerCase().trim() ===
69
+ filterValue.toString().toLowerCase().trim(),
70
+ );
71
+
72
+ equalsFilterFN.autoRemove = (val: any) => !val;
73
+
74
+ export const notEqualsFilterFN = (
75
+ rows: MRT_Row[],
76
+ id: string,
77
+ filterValue: string | number,
78
+ ) =>
79
+ rows.filter(
80
+ (row) =>
81
+ row.values[id].toString().toLowerCase().trim() !==
82
+ filterValue.toString().toLowerCase().trim(),
83
+ );
84
+
85
+ notEqualsFilterFN.autoRemove = (val: any) => !val;
86
+
87
+ export const emptyFilterFN = (
88
+ rows: MRT_Row[],
89
+ id: string,
90
+ _filterValue: string | number,
91
+ ) => rows.filter((row) => !row.values[id].toString().toLowerCase().trim());
92
+
93
+ emptyFilterFN.autoRemove = (val: any) => !val;
94
+
95
+ export const notEmptyFilterFN = (
96
+ rows: MRT_Row[],
97
+ id: string,
98
+ _filterValue: string | number,
99
+ ) => rows.filter((row) => !!row.values[id].toString().toLowerCase().trim());
100
+
101
+ notEmptyFilterFN.autoRemove = (val: any) => !val;
102
+
103
+ export const defaultFilterFNs = {
104
+ contains: containsFilterFN,
105
+ empty: emptyFilterFN,
106
+ endsWith: endsWithFilterFN,
107
+ equals: equalsFilterFN,
108
+ fuzzy: fuzzyFilterFN,
109
+ notEmpty: notEmptyFilterFN,
110
+ notEquals: notEqualsFilterFN,
111
+ startsWith: startsWithFilterFN,
112
+ };
@@ -16,7 +16,7 @@ export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
16
16
  },
17
17
  } = useMRT();
18
18
 
19
- const isParentHeader = (column?.columns?.length ?? 0) > 0;
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 = (column?.columns?.length ?? 0) > 0;
44
+ const isParentHeader = !!column?.columns?.length;
42
45
 
43
46
  const mTableHeadCellProps =
44
47
  muiTableHeadCellProps instanceof Function
@@ -73,6 +76,25 @@ 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
+
96
+ const columnHeader = column.render('Header') as string;
97
+
76
98
  return (
77
99
  <TableCell
78
100
  align={isParentHeader ? 'center' : 'left'}
@@ -86,59 +108,84 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
86
108
  }}
87
109
  >
88
110
  <Box
89
- sx={{ alignContent: 'space-between', display: 'grid', height: '100%' }}
111
+ sx={{
112
+ alignItems: 'flex-start',
113
+ display: 'flex',
114
+ justifyContent: isParentHeader ? 'center' : 'space-between',
115
+ width: '100%',
116
+ }}
90
117
  >
91
118
  <Box
119
+ {...column.getSortByToggleProps()}
92
120
  sx={{
93
- alignItems: 'flex-start',
121
+ alignItems: 'center',
94
122
  display: 'flex',
95
- justifyContent: isParentHeader ? 'center' : 'space-between',
96
- width: '100%',
123
+ flexWrap: 'nowrap',
124
+ whiteSpace: columnHeader.length < 15 ? 'nowrap' : 'normal',
97
125
  }}
126
+ title={undefined}
98
127
  >
99
- <Box
100
- {...column.getSortByToggleProps()}
101
- sx={{ alignItems: 'center', display: 'flex', flexWrap: 'nowrap' }}
102
- title={undefined}
103
- >
104
- {column.render('Header')}
105
- {!isParentHeader && column.canSort && (
106
- <Tooltip arrow title={sortTooltip}>
107
- <TableSortLabel
108
- aria-label={sortTooltip}
109
- active={column.isSorted}
110
- direction={column.isSortedDesc ? 'desc' : 'asc'}
111
- />
112
- </Tooltip>
113
- )}
114
- </Box>
115
- <Box
116
- sx={{ alignItems: 'center', display: 'flex', flexWrap: 'nowrap' }}
117
- >
118
- {!disableColumnActions && !isParentHeader && (
119
- <MRT_ToggleColumnActionMenuButton column={column} />
120
- )}
121
- {enableColumnResizing && !isParentHeader && (
122
- <Divider
123
- flexItem
124
- orientation="vertical"
125
- onDoubleClick={() => tableInstance.resetResizing()}
126
- {...column.getResizerProps()}
128
+ {column.render('Header')}
129
+ {!isParentHeader && column.canSort && (
130
+ <Tooltip arrow title={sortTooltip}>
131
+ <TableSortLabel
132
+ aria-label={sortTooltip}
133
+ active={column.isSorted}
134
+ direction={column.isSortedDesc ? 'desc' : 'asc'}
135
+ />
136
+ </Tooltip>
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"
127
146
  sx={{
128
- borderRightWidth: '2px',
129
- borderRadius: '2px',
130
- maxHeight: '2rem',
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
+ },
131
154
  }}
132
- />
133
- )}
134
- </Box>
155
+ >
156
+ {tableInstance.state.showFilters && !column.filterValue ? (
157
+ <FilterAltOff fontSize="small" />
158
+ ) : (
159
+ <FilterAltIcon fontSize="small" />
160
+ )}
161
+ </IconButton>
162
+ </Tooltip>
163
+ )}
164
+ </Box>
165
+ <Box sx={{ alignItems: 'center', display: 'flex', flexWrap: 'nowrap' }}>
166
+ {!disableColumnActions && !isParentHeader && (
167
+ <MRT_ToggleColumnActionMenuButton column={column} />
168
+ )}
169
+ {enableColumnResizing && !isParentHeader && (
170
+ <Divider
171
+ flexItem
172
+ orientation="vertical"
173
+ onDoubleClick={() => tableInstance.resetResizing()}
174
+ {...column.getResizerProps()}
175
+ sx={{
176
+ borderRightWidth: '2px',
177
+ borderRadius: '2px',
178
+ maxHeight: '2rem',
179
+ }}
180
+ />
181
+ )}
135
182
  </Box>
136
- {!disableFilters && column.canFilter && (
137
- <Collapse in={tableInstance.state.showFilters}>
138
- <MRT_FilterTextField column={column} />
139
- </Collapse>
140
- )}
141
183
  </Box>
184
+ {!disableFilters && column.canFilter && (
185
+ <Collapse in={tableInstance.state.showFilters}>
186
+ <MRT_FilterTextField column={column} />
187
+ </Collapse>
188
+ )}
142
189
  </TableCell>
143
190
  );
144
191
  };
@@ -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
-