material-react-table 0.6.8 → 0.7.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 (107) hide show
  1. package/dist/MaterialReactTable.d.ts +147 -82
  2. package/dist/body/MRT_TableBody.d.ts +3 -0
  3. package/dist/body/MRT_TableBodyCell.d.ts +2 -11
  4. package/dist/body/MRT_TableBodyRow.d.ts +3 -1
  5. package/dist/body/MRT_TableDetailPanel.d.ts +2 -1
  6. package/dist/buttons/MRT_CopyButton.d.ts +4 -2
  7. package/dist/buttons/MRT_EditActionButtons.d.ts +2 -1
  8. package/dist/buttons/MRT_ExpandAllButton.d.ts +2 -0
  9. package/dist/buttons/MRT_ExpandButton.d.ts +2 -1
  10. package/dist/buttons/MRT_FullScreenToggleButton.d.ts +2 -0
  11. package/dist/buttons/MRT_ShowHideColumnsButton.d.ts +2 -0
  12. package/dist/buttons/MRT_ToggleColumnActionMenuButton.d.ts +3 -2
  13. package/dist/buttons/MRT_ToggleDensePaddingButton.d.ts +2 -0
  14. package/dist/buttons/MRT_ToggleFiltersButton.d.ts +2 -0
  15. package/dist/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -1
  16. package/dist/buttons/MRT_ToggleSearchButton.d.ts +2 -0
  17. package/dist/enums.d.ts +2 -1
  18. package/dist/filtersFNs.d.ts +13 -5
  19. package/dist/footer/MRT_TableFooter.d.ts +3 -0
  20. package/dist/footer/MRT_TableFooterCell.d.ts +3 -2
  21. package/dist/footer/MRT_TableFooterRow.d.ts +2 -1
  22. package/dist/head/MRT_TableHead.d.ts +3 -0
  23. package/dist/head/MRT_TableHeadCell.d.ts +4 -18
  24. package/dist/head/MRT_TableHeadRow.d.ts +2 -1
  25. package/dist/icons.d.ts +1 -1
  26. package/dist/inputs/MRT_EditCellTextField.d.ts +2 -1
  27. package/dist/inputs/MRT_FilterTextField.d.ts +3 -2
  28. package/dist/inputs/MRT_SearchTextField.d.ts +2 -0
  29. package/dist/inputs/MRT_SelectCheckbox.d.ts +2 -1
  30. package/dist/localization.d.ts +9 -2
  31. package/dist/material-react-table.cjs.development.js +2183 -1686
  32. package/dist/material-react-table.cjs.development.js.map +1 -1
  33. package/dist/material-react-table.cjs.production.min.js +1 -1
  34. package/dist/material-react-table.cjs.production.min.js.map +1 -1
  35. package/dist/material-react-table.esm.js +2191 -1694
  36. package/dist/material-react-table.esm.js.map +1 -1
  37. package/dist/menus/MRT_ColumnActionMenu.d.ts +3 -2
  38. package/dist/menus/MRT_FilterTypeMenu.d.ts +4 -3
  39. package/dist/menus/MRT_RowActionMenu.d.ts +3 -2
  40. package/dist/menus/MRT_ShowHideColumnsMenu.d.ts +2 -0
  41. package/dist/menus/MRT_ShowHideColumnsMenuItems.d.ts +2 -1
  42. package/dist/table/MRT_Table.d.ts +3 -0
  43. package/dist/table/MRT_TableContainer.d.ts +2 -0
  44. package/dist/table/MRT_TablePaper.d.ts +7 -0
  45. package/dist/table/MRT_TableRoot.d.ts +3 -0
  46. package/dist/toolbar/MRT_LinearProgressBar.d.ts +2 -0
  47. package/dist/toolbar/MRT_TablePagination.d.ts +2 -0
  48. package/dist/toolbar/MRT_ToolbarAlertBanner.d.ts +2 -0
  49. package/dist/toolbar/MRT_ToolbarBottom.d.ts +2 -0
  50. package/dist/toolbar/MRT_ToolbarInternalButtons.d.ts +2 -0
  51. package/dist/toolbar/MRT_ToolbarTop.d.ts +4 -2
  52. package/dist/utils.d.ts +12 -2
  53. package/package.json +27 -28
  54. package/src/MaterialReactTable.tsx +314 -241
  55. package/src/body/MRT_TableBody.tsx +25 -21
  56. package/src/body/MRT_TableBodyCell.tsx +74 -53
  57. package/src/body/MRT_TableBodyRow.tsx +35 -51
  58. package/src/body/MRT_TableDetailPanel.tsx +16 -14
  59. package/src/buttons/MRT_CopyButton.tsx +36 -11
  60. package/src/buttons/MRT_EditActionButtons.tsx +13 -12
  61. package/src/buttons/MRT_ExpandAllButton.tsx +36 -28
  62. package/src/buttons/MRT_ExpandButton.tsx +34 -40
  63. package/src/buttons/MRT_FullScreenToggleButton.tsx +18 -11
  64. package/src/buttons/MRT_ShowHideColumnsButton.tsx +18 -7
  65. package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +17 -9
  66. package/src/buttons/MRT_ToggleDensePaddingButton.tsx +18 -11
  67. package/src/buttons/MRT_ToggleFiltersButton.tsx +16 -9
  68. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +26 -21
  69. package/src/buttons/MRT_ToggleSearchButton.tsx +18 -11
  70. package/src/enums.ts +2 -1
  71. package/src/filtersFNs.ts +17 -3
  72. package/src/footer/MRT_TableFooter.tsx +23 -7
  73. package/src/footer/MRT_TableFooterCell.tsx +32 -24
  74. package/src/footer/MRT_TableFooterRow.tsx +20 -38
  75. package/src/head/MRT_TableHead.tsx +23 -7
  76. package/src/head/MRT_TableHeadCell.tsx +201 -151
  77. package/src/head/MRT_TableHeadRow.tsx +15 -81
  78. package/src/icons.ts +3 -3
  79. package/src/inputs/MRT_EditCellTextField.tsx +23 -24
  80. package/src/inputs/MRT_FilterTextField.tsx +51 -37
  81. package/src/inputs/MRT_SearchTextField.tsx +63 -22
  82. package/src/inputs/MRT_SelectCheckbox.tsx +75 -42
  83. package/src/localization.ts +19 -4
  84. package/src/menus/MRT_ColumnActionMenu.tsx +129 -69
  85. package/src/menus/MRT_FilterTypeMenu.tsx +55 -23
  86. package/src/menus/MRT_RowActionMenu.tsx +16 -11
  87. package/src/menus/MRT_ShowHideColumnsMenu.tsx +52 -20
  88. package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +28 -17
  89. package/src/table/MRT_Table.tsx +24 -14
  90. package/src/table/MRT_TableContainer.tsx +109 -44
  91. package/src/table/MRT_TablePaper.tsx +61 -0
  92. package/src/table/MRT_TableRoot.tsx +236 -0
  93. package/src/toolbar/MRT_LinearProgressBar.tsx +9 -6
  94. package/src/toolbar/MRT_TablePagination.tsx +28 -18
  95. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +31 -19
  96. package/src/toolbar/MRT_ToolbarBottom.tsx +31 -20
  97. package/src/toolbar/MRT_ToolbarInternalButtons.tsx +29 -16
  98. package/src/toolbar/MRT_ToolbarTop.tsx +34 -27
  99. package/src/utils.ts +37 -8
  100. package/dist/head/MRT_TableHeadCellActions.d.ts +0 -5
  101. package/dist/table/MRT_TableSpacerCell.d.ts +0 -6
  102. package/dist/useMRT.d.ts +0 -27
  103. package/src/@types/faker.d.ts +0 -4
  104. package/src/@types/react-table-config.d.ts +0 -53
  105. package/src/head/MRT_TableHeadCellActions.tsx +0 -29
  106. package/src/table/MRT_TableSpacerCell.tsx +0 -20
  107. package/src/useMRT.tsx +0 -215
package/src/icons.ts CHANGED
@@ -3,7 +3,6 @@ import CancelIcon from '@mui/icons-material/Cancel';
3
3
  import CheckBoxIcon from '@mui/icons-material/CheckBox';
4
4
  import ClearAllIcon from '@mui/icons-material/ClearAll';
5
5
  import CloseIcon from '@mui/icons-material/Close';
6
- import ContentCopyIcon from '@mui/icons-material/ContentCopy';
7
6
  import DensityMediumIcon from '@mui/icons-material/DensityMedium';
8
7
  import DensitySmallIcon from '@mui/icons-material/DensitySmall';
9
8
  import DoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
@@ -19,6 +18,7 @@ import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
19
18
  import FullscreenIcon from '@mui/icons-material/Fullscreen';
20
19
  import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
21
20
  import MoreVertIcon from '@mui/icons-material/MoreVert';
21
+ import PushPinIcon from '@mui/icons-material/PushPin';
22
22
  import SaveIcon from '@mui/icons-material/Save';
23
23
  import SearchIcon from '@mui/icons-material/Search';
24
24
  import SearchOffIcon from '@mui/icons-material/SearchOff';
@@ -32,7 +32,6 @@ export interface MRT_Icons {
32
32
  CheckBoxIcon: any;
33
33
  ClearAllIcon: any;
34
34
  CloseIcon: any;
35
- ContentCopyIcon: any;
36
35
  DensityMediumIcon: any;
37
36
  DensitySmallIcon: any;
38
37
  DoubleArrowDownIcon: any;
@@ -48,6 +47,7 @@ export interface MRT_Icons {
48
47
  FullscreenIcon: any;
49
48
  MoreHorizIcon: any;
50
49
  MoreVertIcon: any;
50
+ PushPinIcon: any;
51
51
  SaveIcon: any;
52
52
  SearchIcon: any;
53
53
  SearchOffIcon: any;
@@ -62,7 +62,6 @@ export const MRT_Default_Icons: MRT_Icons = {
62
62
  CheckBoxIcon,
63
63
  ClearAllIcon,
64
64
  CloseIcon,
65
- ContentCopyIcon,
66
65
  DensityMediumIcon,
67
66
  DensitySmallIcon,
68
67
  DoubleArrowDownIcon,
@@ -78,6 +77,7 @@ export const MRT_Default_Icons: MRT_Icons = {
78
77
  FullscreenIcon,
79
78
  MoreHorizIcon,
80
79
  MoreVertIcon,
80
+ PushPinIcon,
81
81
  SaveIcon,
82
82
  SearchIcon,
83
83
  SearchOffIcon,
@@ -1,29 +1,28 @@
1
- import React, { ChangeEvent, FC } from 'react';
1
+ import React, { ChangeEvent, FC, MouseEvent } from 'react';
2
2
  import { TextField } from '@mui/material';
3
- import { useMRT } from '../useMRT';
4
- import type { MRT_Cell } from '..';
3
+ import type { MRT_Cell, MRT_TableInstance } from '..';
5
4
 
6
5
  interface Props {
7
6
  cell: MRT_Cell;
7
+ tableInstance: MRT_TableInstance;
8
8
  }
9
9
 
10
- export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
10
+ export const MRT_EditCellTextField: FC<Props> = ({ cell, tableInstance }) => {
11
11
  const {
12
- muiTableBodyCellEditTextFieldProps,
13
- setCurrentEditingRow,
14
- tableInstance: {
15
- state: { currentEditingRow },
16
- },
17
- } = useMRT();
12
+ getState,
13
+ options: { muiTableBodyCellEditTextFieldProps },
14
+ } = tableInstance;
15
+
16
+ const { column, row } = cell;
18
17
 
19
18
  const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
20
- if (currentEditingRow) {
21
- cell.row.values[cell.column.id] = event.target.value;
22
- setCurrentEditingRow({
23
- ...currentEditingRow,
24
- });
19
+ if (getState().currentEditingRow) {
20
+ row.values[column.id] = event.target.value;
21
+ // setCurrentEditingRow({
22
+ // ...getState().currentEditingRow,
23
+ // });
25
24
  }
26
- cell.column.onCellEditChange?.(event, cell);
25
+ column.onCellEditChange?.(event, cell);
27
26
  };
28
27
 
29
28
  const mTableBodyCellEditTextFieldProps =
@@ -32,25 +31,25 @@ export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
32
31
  : muiTableBodyCellEditTextFieldProps;
33
32
 
34
33
  const mcTableBodyCellEditTextFieldProps =
35
- cell.column.muiTableBodyCellEditTextFieldProps instanceof Function
36
- ? cell.column.muiTableBodyCellEditTextFieldProps(cell)
37
- : cell.column.muiTableBodyCellEditTextFieldProps;
34
+ column.muiTableBodyCellEditTextFieldProps instanceof Function
35
+ ? column.muiTableBodyCellEditTextFieldProps(cell)
36
+ : column.muiTableBodyCellEditTextFieldProps;
38
37
 
39
38
  const textFieldProps = {
40
39
  ...mTableBodyCellEditTextFieldProps,
41
40
  ...mcTableBodyCellEditTextFieldProps,
42
41
  };
43
42
 
44
- if (!cell.column.disableEditing && cell.column.Edit) {
45
- return <>{cell.column.Edit({ ...textFieldProps, cell })}</>;
46
- }
43
+ // if (enableEditing && Edit) {
44
+ // return <>{Edit({ ...textFieldProps, cell })}</>;
45
+ // }
47
46
 
48
47
  return (
49
48
  <TextField
50
49
  margin="dense"
51
50
  onChange={handleChange}
52
- onClick={(e) => e.stopPropagation()}
53
- placeholder={cell.column.Header as string}
51
+ onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
52
+ placeholder={column.header}
54
53
  value={cell.value}
55
54
  variant="standard"
56
55
  {...textFieldProps}
@@ -1,6 +1,13 @@
1
- import React, { ChangeEvent, FC, MouseEvent, useState } from 'react';
1
+ import React, {
2
+ ChangeEvent,
3
+ FC,
4
+ MouseEvent,
5
+ useCallback,
6
+ useState,
7
+ } from 'react';
2
8
  import {
3
9
  Chip,
10
+ debounce,
4
11
  IconButton,
5
12
  InputAdornment,
6
13
  MenuItem,
@@ -8,25 +15,30 @@ import {
8
15
  TextFieldProps,
9
16
  Tooltip,
10
17
  } from '@mui/material';
11
- import { useAsyncDebounce } from 'react-table';
12
- import { useMRT } from '../useMRT';
13
- import type { MRT_HeaderGroup } from '..';
18
+ import type { MRT_Header, MRT_TableInstance } from '..';
14
19
  import { MRT_FilterTypeMenu } from '../menus/MRT_FilterTypeMenu';
15
20
  import { MRT_FILTER_TYPE } from '../enums';
16
21
 
17
22
  interface Props {
18
- column: MRT_HeaderGroup;
23
+ header: MRT_Header;
24
+ tableInstance: MRT_TableInstance;
19
25
  }
20
26
 
21
- export const MRT_FilterTextField: FC<Props> = ({ column }) => {
27
+ export const MRT_FilterTextField: FC<Props> = ({ header, tableInstance }) => {
22
28
  const {
23
- icons: { FilterListIcon, CloseIcon },
24
- idPrefix,
25
- localization,
26
- muiTableHeadCellFilterTextFieldProps,
27
- setCurrentFilterTypes,
28
- tableInstance,
29
- } = useMRT();
29
+ getState,
30
+ options: {
31
+ icons: { FilterListIcon, CloseIcon },
32
+ idPrefix,
33
+ localization,
34
+ muiTableHeadCellFilterTextFieldProps,
35
+ setCurrentFilterTypes,
36
+ },
37
+ } = tableInstance;
38
+
39
+ const { column } = header;
40
+
41
+ const { currentFilterTypes } = getState();
30
42
 
31
43
  const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
32
44
 
@@ -45,11 +57,18 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
45
57
  ...mcTableHeadCellFilterTextFieldProps,
46
58
  } as TextFieldProps;
47
59
 
48
- const [filterValue, setFilterValue] = useState('');
60
+ const [filterValue, setFilterValue] = useState<string>(
61
+ (column.getColumnFilterValue() ?? '') as string,
62
+ );
49
63
 
50
- const handleChange = useAsyncDebounce((value) => {
51
- column.setFilter(value ?? undefined);
52
- }, 150);
64
+ const handleChange = useCallback(
65
+ debounce(
66
+ (event: ChangeEvent<HTMLInputElement>) =>
67
+ column.setColumnFilterValue(event.target.value ?? undefined),
68
+ 150,
69
+ ),
70
+ [],
71
+ );
53
72
 
54
73
  const handleFilterMenuOpen = (event: MouseEvent<HTMLElement>) => {
55
74
  setAnchorEl(event.currentTarget);
@@ -57,24 +76,24 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
57
76
 
58
77
  const handleClear = () => {
59
78
  setFilterValue('');
60
- column.setFilter(undefined);
79
+ column.setColumnFilterValue(undefined);
61
80
  };
62
81
 
63
82
  const handleClearFilterChip = () => {
64
83
  setFilterValue('');
65
- column.setFilter(undefined);
84
+ column.setColumnFilterValue(undefined);
66
85
  setCurrentFilterTypes((prev) => ({
67
86
  ...prev,
68
- [column.id]: MRT_FILTER_TYPE.FUZZY,
87
+ [header.id]: MRT_FILTER_TYPE.BEST_MATCH,
69
88
  }));
70
89
  };
71
90
 
72
91
  if (column.Filter) {
73
- return <>{column.Filter?.({ column })}</>;
92
+ return <>{column.Filter?.({ header, tableInstance })}</>;
74
93
  }
75
94
 
76
- const filterId = `mrt-${idPrefix}-${column.id}-filter-text-field`;
77
- const filterType = tableInstance.state.currentFilterTypes[column.id];
95
+ const filterId = `mrt-${idPrefix}-${header.id}-filter-text-field`;
96
+ const filterType = currentFilterTypes?.[header.id];
78
97
  const isSelectFilter = !!column.filterSelectOptions;
79
98
  const filterChipLabel =
80
99
  !(filterType instanceof Function) &&
@@ -88,7 +107,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
88
107
  : '';
89
108
  const filterPlaceholder = localization.filterByColumn?.replace(
90
109
  '{column}',
91
- String(column.Header),
110
+ String(column.header),
92
111
  );
93
112
 
94
113
  return (
@@ -132,22 +151,16 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
132
151
  sx: { fontSize: '0.6rem', lineHeight: '0.8rem' },
133
152
  }}
134
153
  label={isSelectFilter && !filterValue ? filterPlaceholder : undefined}
135
- InputLabelProps={{
136
- shrink: false,
137
- sx: {
138
- maxWidth: 'calc(100% - 2.5rem)',
139
- },
140
- title: filterPlaceholder,
141
- }}
142
154
  margin="none"
143
155
  placeholder={
144
- filterChipLabel || isSelectFilter ? undefined : filterPlaceholder
156
+ filterPlaceholder
157
+ // filterChipLabel || isSelectFilter ? undefined : filterPlaceholder
145
158
  }
146
- onChange={(e: ChangeEvent<HTMLInputElement>) => {
147
- setFilterValue(e.target.value);
148
- handleChange(e.target.value);
159
+ onChange={(event: ChangeEvent<HTMLInputElement>) => {
160
+ setFilterValue(event.target.value);
161
+ handleChange(event);
149
162
  }}
150
- onClick={(e) => e.stopPropagation()}
163
+ onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
151
164
  select={isSelectFilter}
152
165
  value={filterValue ?? ''}
153
166
  variant="standard"
@@ -237,8 +250,9 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
237
250
  </TextField>
238
251
  <MRT_FilterTypeMenu
239
252
  anchorEl={anchorEl}
240
- column={column}
253
+ header={header}
241
254
  setAnchorEl={setAnchorEl}
255
+ tableInstance={tableInstance}
242
256
  />
243
257
  </>
244
258
  );
@@ -1,37 +1,62 @@
1
- import React, { ChangeEvent, FC, useState } from 'react';
2
- import { Collapse, IconButton, InputAdornment, TextField } from '@mui/material';
3
- import { useMRT } from '../useMRT';
4
- import { useAsyncDebounce } from 'react-table';
1
+ import React, {
2
+ ChangeEvent,
3
+ FC,
4
+ MouseEvent,
5
+ useCallback,
6
+ useState,
7
+ } from 'react';
8
+ import {
9
+ Collapse,
10
+ debounce,
11
+ IconButton,
12
+ InputAdornment,
13
+ TextField,
14
+ Tooltip,
15
+ } from '@mui/material';
16
+ import { MRT_FilterTypeMenu } from '../menus/MRT_FilterTypeMenu';
17
+ import { MRT_TableInstance } from '..';
5
18
 
6
- interface Props {}
19
+ interface Props {
20
+ tableInstance: MRT_TableInstance;
21
+ }
7
22
 
8
- export const MRT_SearchTextField: FC<Props> = () => {
23
+ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
9
24
  const {
10
- icons: { SearchIcon, CloseIcon },
11
- idPrefix,
12
- localization,
13
- muiSearchTextFieldProps,
14
- onGlobalFilterChange,
15
- tableInstance,
16
- } = useMRT();
25
+ getState,
26
+ setGlobalFilter,
27
+ options: {
28
+ icons: { SearchIcon, CloseIcon },
29
+ idPrefix,
30
+ localization,
31
+ muiSearchTextFieldProps,
32
+ onGlobalFilterChange,
33
+ },
34
+ } = tableInstance;
35
+
36
+ const { globalFilter, showSearch } = getState();
17
37
 
18
- const [searchValue, setSearchValue] = useState('');
38
+ const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
39
+ const [searchValue, setSearchValue] = useState(globalFilter ?? '');
19
40
 
20
- const handleChange = useAsyncDebounce(
21
- (event: ChangeEvent<HTMLInputElement>) => {
22
- tableInstance.setGlobalFilter(event.target.value ?? undefined);
41
+ const handleChange = useCallback(
42
+ debounce((event: ChangeEvent<HTMLInputElement>) => {
43
+ setGlobalFilter(event.target.value ?? undefined);
23
44
  onGlobalFilterChange?.(event);
24
- },
25
- 200,
45
+ }, 200),
46
+ [],
26
47
  );
27
48
 
49
+ const handleGlobalFilterMenuOpen = (event: MouseEvent<HTMLElement>) => {
50
+ setAnchorEl(event.currentTarget);
51
+ };
52
+
28
53
  const handleClear = () => {
29
54
  setSearchValue('');
30
- tableInstance.setGlobalFilter(undefined);
55
+ setGlobalFilter(undefined);
31
56
  };
32
57
 
33
58
  return (
34
- <Collapse in={tableInstance.state.showSearch} orientation="horizontal">
59
+ <Collapse in={showSearch} orientation="horizontal">
35
60
  <TextField
36
61
  id={`mrt-${idPrefix}-search-text-field`}
37
62
  placeholder={localization.search}
@@ -44,7 +69,18 @@ export const MRT_SearchTextField: FC<Props> = () => {
44
69
  InputProps={{
45
70
  startAdornment: (
46
71
  <InputAdornment position="start">
47
- <SearchIcon fontSize="small" />
72
+ <Tooltip arrow title={localization.changeSearchMode}>
73
+ <span>
74
+ <IconButton
75
+ aria-label={localization.changeSearchMode}
76
+ onClick={handleGlobalFilterMenuOpen}
77
+ size="small"
78
+ sx={{ height: '1.75rem', width: '1.75rem' }}
79
+ >
80
+ <SearchIcon fontSize="small" />
81
+ </IconButton>
82
+ </span>
83
+ </Tooltip>
48
84
  </InputAdornment>
49
85
  ),
50
86
  endAdornment: (
@@ -64,6 +100,11 @@ export const MRT_SearchTextField: FC<Props> = () => {
64
100
  {...muiSearchTextFieldProps}
65
101
  sx={{ justifySelf: 'end', ...muiSearchTextFieldProps?.sx }}
66
102
  />
103
+ <MRT_FilterTypeMenu
104
+ anchorEl={anchorEl}
105
+ setAnchorEl={setAnchorEl}
106
+ tableInstance={tableInstance}
107
+ />
67
108
  </Collapse>
68
109
  );
69
110
  };
@@ -1,61 +1,94 @@
1
1
  import React, { ChangeEvent, FC } from 'react';
2
- import { Checkbox, TableCell, Tooltip } from '@mui/material';
3
- import { useMRT } from '../useMRT';
4
- import type { MRT_Row } from '..';
5
- import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
2
+ import { Checkbox, Tooltip } from '@mui/material';
3
+ import type { MRT_Row, MRT_TableInstance } from '..';
6
4
 
7
5
  interface Props {
8
6
  row?: MRT_Row;
9
7
  selectAll?: boolean;
8
+ tableInstance: MRT_TableInstance;
10
9
  }
11
10
 
12
- export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
13
- const { localization, onRowSelectChange, onSelectAllChange, tableInstance } =
14
- useMRT();
11
+ export const MRT_SelectCheckbox: FC<Props> = ({
12
+ row,
13
+ selectAll,
14
+ tableInstance,
15
+ }) => {
16
+ const {
17
+ getRowModel,
18
+ getSelectedRowModel,
19
+ getState,
20
+ getToggleAllRowsSelectedProps,
21
+ options: {
22
+ isLoading,
23
+ localization,
24
+ muiSelectCheckboxProps,
25
+ onSelectChange,
26
+ onSelectAllChange,
27
+ },
28
+ } = tableInstance;
15
29
 
16
- const onSelectChange = (event: ChangeEvent<HTMLInputElement>) => {
30
+ const { isDensePadding } = getState();
31
+
32
+ const handleSelectChange = (event: ChangeEvent<HTMLInputElement>) => {
17
33
  if (selectAll) {
18
- tableInstance?.getToggleAllRowsSelectedProps?.()?.onChange?.(event);
19
- onSelectAllChange?.(event, tableInstance.selectedFlatRows);
34
+ getToggleAllRowsSelectedProps?.()?.onChange?.(event as any);
35
+ onSelectAllChange?.(
36
+ event,
37
+ event.target.checked ? getRowModel().flatRows : [],
38
+ );
20
39
  } else if (row) {
21
- row?.getToggleRowSelectedProps()?.onChange?.(event);
22
- onRowSelectChange?.(event, row, tableInstance.selectedFlatRows);
40
+ row?.getToggleSelectedProps()?.onChange?.(event as any);
41
+ onSelectChange?.(
42
+ event,
43
+ row,
44
+ event.target.checked
45
+ ? [...getSelectedRowModel().flatRows, row]
46
+ : getSelectedRowModel().flatRows.filter(
47
+ (selectedRow) => selectedRow.id !== row.id,
48
+ ),
49
+ );
23
50
  }
24
51
  };
25
52
 
26
- const checkboxProps = selectAll
27
- ? tableInstance.getToggleAllRowsSelectedProps()
28
- : row?.getToggleRowSelectedProps();
53
+ const mTableBodyRowSelectCheckboxProps =
54
+ muiSelectCheckboxProps instanceof Function
55
+ ? muiSelectCheckboxProps(selectAll, row, tableInstance)
56
+ : muiSelectCheckboxProps;
57
+
58
+ const rtSelectCheckboxProps = selectAll
59
+ ? getToggleAllRowsSelectedProps()
60
+ : row?.getToggleSelectedProps();
61
+
62
+ const checkboxProps = {
63
+ ...rtSelectCheckboxProps,
64
+ ...mTableBodyRowSelectCheckboxProps,
65
+ };
29
66
 
30
67
  return (
31
- <TableCell
32
- sx={{
33
- ...commonTableBodyButtonCellStyles(tableInstance.state.densePadding),
34
- maxWidth: '2rem',
35
- width: '2rem',
36
- }}
68
+ <Tooltip
69
+ arrow
70
+ enterDelay={1000}
71
+ enterNextDelay={1000}
72
+ title={
73
+ selectAll ? localization.toggleSelectAll : localization.toggleSelectRow
74
+ }
37
75
  >
38
- <Tooltip
39
- arrow
40
- enterDelay={1000}
41
- enterNextDelay={1000}
42
- title={
43
- selectAll
76
+ <Checkbox
77
+ disabled={isLoading}
78
+ inputProps={{
79
+ 'aria-label': selectAll
44
80
  ? localization.toggleSelectAll
45
- : localization.toggleSelectRow
46
- }
47
- >
48
- <Checkbox
49
- inputProps={{
50
- 'aria-label': selectAll
51
- ? localization.toggleSelectAll
52
- : localization.toggleSelectRow,
53
- }}
54
- onChange={onSelectChange}
55
- {...checkboxProps}
56
- title={undefined}
57
- />
58
- </Tooltip>
59
- </TableCell>
81
+ : localization.toggleSelectRow,
82
+ }}
83
+ size={isDensePadding ? 'small' : 'medium'}
84
+ {...checkboxProps}
85
+ sx={{
86
+ height: isDensePadding ? '1.75rem' : '2.25rem',
87
+ width: isDensePadding ? '1.75rem' : '2.25rem',
88
+ }}
89
+ onChange={handleSelectChange}
90
+ title={undefined}
91
+ />
92
+ </Tooltip>
60
93
  );
61
94
  };
@@ -2,6 +2,7 @@ export interface MRT_Localization {
2
2
  actions: string;
3
3
  cancel: string;
4
4
  changeFilterMode: string;
5
+ changeSearchMode: string;
5
6
  clearFilter: string;
6
7
  clearSearch: string;
7
8
  clearSort: string;
@@ -11,12 +12,13 @@ export interface MRT_Localization {
11
12
  edit: string;
12
13
  expand: string;
13
14
  expandAll: string;
15
+ filterBestMatch: string;
16
+ filterBestMatchFirst: string;
14
17
  filterByColumn: string;
15
18
  filterContains: string;
16
19
  filterEmpty: string;
17
20
  filterEndsWith: string;
18
21
  filterEquals: string;
19
- filterFuzzy: string;
20
22
  filterGreaterThan: string;
21
23
  filterLessThan: string;
22
24
  filterMode: string;
@@ -28,13 +30,17 @@ export interface MRT_Localization {
28
30
  groupedBy: string;
29
31
  hideAll: string;
30
32
  hideColumn: string;
33
+ pinToLeft: string;
34
+ pinToRight: string;
31
35
  rowActions: string;
36
+ rowNumbers: string;
32
37
  save: string;
33
38
  search: string;
39
+ select: string;
34
40
  selectedCountOfRowCountRowsSelected: string;
35
41
  showAll: string;
36
- showHideColumns: string;
37
42
  showAllColumns: string;
43
+ showHideColumns: string;
38
44
  showHideFilters: string;
39
45
  showHideSearch: string;
40
46
  sortByColumnAsc: string;
@@ -45,12 +51,14 @@ export interface MRT_Localization {
45
51
  toggleSelectAll: string;
46
52
  toggleSelectRow: string;
47
53
  ungroupByColumn: string;
54
+ unpin: string;
48
55
  }
49
56
 
50
57
  export const MRT_DefaultLocalization_EN: MRT_Localization = {
51
58
  actions: 'Actions',
52
59
  cancel: 'Cancel',
53
60
  changeFilterMode: 'Change filter mode',
61
+ changeSearchMode: 'Change search mode',
54
62
  clearFilter: 'Clear filter',
55
63
  clearSearch: 'Clear search',
56
64
  clearSort: 'Clear sort',
@@ -60,12 +68,13 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
60
68
  edit: 'Edit',
61
69
  expand: 'Expand',
62
70
  expandAll: 'Expand all',
71
+ filterBestMatch: 'Best Match',
72
+ filterBestMatchFirst: 'Best Match First',
63
73
  filterByColumn: 'Filter by {column}',
64
- filterContains: 'Contains Exact',
74
+ filterContains: 'Contains',
65
75
  filterEmpty: 'Empty',
66
76
  filterEndsWith: 'Ends With',
67
77
  filterEquals: 'Equals',
68
- filterFuzzy: 'Fuzzy Match',
69
78
  filterGreaterThan: 'Greater Than',
70
79
  filterLessThan: 'Less Than',
71
80
  filterMode: 'Filter Mode: {filterType}',
@@ -77,11 +86,16 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
77
86
  groupedBy: 'Grouped by ',
78
87
  hideAll: 'Hide all',
79
88
  hideColumn: 'Hide {column} column',
89
+ pinToLeft: 'Pin to left',
90
+ pinToRight: 'Pin to right',
80
91
  rowActions: 'Row Actions',
92
+ rowNumbers: 'Row Numbers',
81
93
  save: 'Save',
82
94
  search: 'Search',
83
95
  selectedCountOfRowCountRowsSelected:
84
96
  '{selectedCount} of {rowCount} row(s) selected',
97
+
98
+ select: 'Select',
85
99
  showAll: 'Show all',
86
100
  showAllColumns: 'Show all columns',
87
101
  showHideColumns: 'Show/Hide columns',
@@ -95,4 +109,5 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
95
109
  toggleSelectAll: 'Toggle select all',
96
110
  toggleSelectRow: 'Toggle select row',
97
111
  ungroupByColumn: 'Ungroup by {column}',
112
+ unpin: 'Unpin',
98
113
  };