material-react-table 0.4.3 → 0.4.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 (50) hide show
  1. package/dist/MaterialReactTable.d.ts +15 -5
  2. package/dist/buttons/MRT_FullScreenToggleButton.d.ts +3 -1
  3. package/dist/buttons/MRT_ShowHideColumnsButton.d.ts +2 -1
  4. package/dist/buttons/MRT_ToggleDensePaddingButton.d.ts +2 -1
  5. package/dist/buttons/MRT_ToggleFiltersButton.d.ts +3 -1
  6. package/dist/buttons/MRT_ToggleSearchButton.d.ts +3 -1
  7. package/dist/icons.d.ts +25 -0
  8. package/dist/inputs/MRT_SelectCheckbox.d.ts +2 -1
  9. package/dist/{utils/localization.d.ts → localization.d.ts} +1 -1
  10. package/dist/material-react-table.cjs.development.js +265 -205
  11. package/dist/material-react-table.cjs.development.js.map +1 -1
  12. package/dist/material-react-table.cjs.production.min.js +1 -1
  13. package/dist/material-react-table.cjs.production.min.js.map +1 -1
  14. package/dist/material-react-table.esm.js +266 -206
  15. package/dist/material-react-table.esm.js.map +1 -1
  16. package/dist/useMRT.d.ts +6 -2
  17. package/package.json +5 -6
  18. package/src/MaterialReactTable.tsx +27 -5
  19. package/src/body/MRT_TableBodyRow.tsx +9 -6
  20. package/src/buttons/MRT_EditActionButtons.tsx +5 -6
  21. package/src/buttons/MRT_ExpandAllButton.tsx +17 -18
  22. package/src/buttons/MRT_ExpandButton.tsx +18 -19
  23. package/src/buttons/MRT_FullScreenToggleButton.tsx +13 -9
  24. package/src/buttons/MRT_ShowHideColumnsButton.tsx +13 -8
  25. package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +18 -10
  26. package/src/buttons/MRT_ToggleDensePaddingButton.tsx +12 -8
  27. package/src/buttons/MRT_ToggleFiltersButton.tsx +12 -8
  28. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +6 -7
  29. package/src/buttons/MRT_ToggleSearchButton.tsx +12 -9
  30. package/src/footer/MRT_TableFooterRow.tsx +9 -10
  31. package/src/head/MRT_TableHeadCell.tsx +21 -12
  32. package/src/head/MRT_TableHeadCellActions.tsx +1 -1
  33. package/src/head/MRT_TableHeadRow.tsx +6 -5
  34. package/src/icons.tsx +72 -0
  35. package/src/inputs/MRT_EditCellTextField.tsx +1 -2
  36. package/src/inputs/MRT_FilterTextField.tsx +12 -13
  37. package/src/inputs/MRT_SearchTextField.tsx +4 -5
  38. package/src/inputs/MRT_SelectCheckbox.tsx +44 -15
  39. package/src/{utils/localization.ts → localization.ts} +4 -4
  40. package/src/menus/MRT_ColumnActionMenu.tsx +14 -12
  41. package/src/menus/MRT_RowActionMenu.tsx +2 -2
  42. package/src/table/MRT_TableContainer.tsx +3 -11
  43. package/src/toolbar/MRT_TablePagination.tsx +1 -0
  44. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +3 -3
  45. package/src/toolbar/MRT_ToolbarBottom.tsx +2 -2
  46. package/src/toolbar/MRT_ToolbarInternalButtons.tsx +16 -0
  47. package/src/toolbar/MRT_ToolbarTop.tsx +2 -2
  48. package/src/useMRT.tsx +6 -2
  49. package/dist/inputs/MRT_SelectAllCheckbox.d.ts +0 -2
  50. package/src/inputs/MRT_SelectAllCheckbox.tsx +0 -22
@@ -5,6 +5,7 @@ import {
5
5
  styled,
6
6
  Divider as MuiDivider,
7
7
  Collapse,
8
+ Tooltip,
8
9
  } from '@mui/material';
9
10
  import { HeaderGroup } from 'react-table';
10
11
  import { useMRT } from '../useMRT';
@@ -89,6 +90,18 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
89
90
  },
90
91
  };
91
92
 
93
+ const sortTooltip = column.isSorted
94
+ ? column.isSortedDesc
95
+ ? localization.columnActionMenuItemClearSort
96
+ : localization.columnActionMenuItemSortDesc?.replace(
97
+ '{column}',
98
+ column.Header as string,
99
+ )
100
+ : localization.columnActionMenuItemSortAsc?.replace(
101
+ '{column}',
102
+ column.Header as string,
103
+ );
104
+
92
105
  return (
93
106
  <MRT_StyledTableHeadCell
94
107
  align={isParentHeader ? 'center' : 'left'}
@@ -100,20 +113,16 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
100
113
  <TableCellTopContents
101
114
  style={{ justifyContent: isParentHeader ? 'center' : undefined }}
102
115
  >
103
- <CellFlexItem {...column.getSortByToggleProps()}>
116
+ <CellFlexItem {...column.getSortByToggleProps()} title={undefined}>
104
117
  {column.render('Header')}
105
118
  {!isParentHeader && column.canSort && (
106
- <TableSortLabel
107
- aria-label={
108
- column.isSorted
109
- ? column.sortDescFirst
110
- ? localization?.columnActionMenuItemClearSort
111
- : localization?.columnActionMenuItemSortDesc
112
- : localization?.columnActionMenuItemSortAsc
113
- }
114
- active={column.isSorted}
115
- direction={column.isSortedDesc ? 'desc' : 'asc'}
116
- />
119
+ <Tooltip arrow title={sortTooltip}>
120
+ <TableSortLabel
121
+ aria-label={sortTooltip}
122
+ active={column.isSorted}
123
+ direction={column.isSortedDesc ? 'desc' : 'asc'}
124
+ />
125
+ </Tooltip>
117
126
  )}
118
127
  </CellFlexItem>
119
128
  <CellFlexItem>
@@ -12,7 +12,7 @@ export const MRT_TableHeadCellActions: FC<Props> = () => {
12
12
  densePadding={densePadding}
13
13
  style={{ textAlign: 'center' }}
14
14
  >
15
- {localization?.actionsHeadColumnTitle}
15
+ {localization.actionsHeadColumnTitle}
16
16
  </MRT_StyledTableHeadCell>
17
17
  );
18
18
  };
@@ -6,7 +6,7 @@ import {
6
6
  MRT_TableHeadCell,
7
7
  } from './MRT_TableHeadCell';
8
8
  import { useMRT } from '../useMRT';
9
- import { MRT_SelectAllCheckbox } from '../inputs/MRT_SelectAllCheckbox';
9
+ import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
10
10
  import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton';
11
11
  import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
12
12
  import { MRT_TableHeadCellActions } from './MRT_TableHeadCellActions';
@@ -19,8 +19,9 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
19
19
  const {
20
20
  anyRowsCanExpand,
21
21
  disableExpandAll,
22
- enableRowNumbers,
23
22
  enableRowActions,
23
+ enableRowEditing,
24
+ enableRowNumbers,
24
25
  enableSelection,
25
26
  muiTableHeadRowProps,
26
27
  positionActionsColumn,
@@ -55,7 +56,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
55
56
  ) : (
56
57
  <MRT_StyledTableHeadCell>#</MRT_StyledTableHeadCell>
57
58
  ))}
58
- {enableRowActions &&
59
+ {(enableRowActions || enableRowEditing) &&
59
60
  positionActionsColumn === 'first' &&
60
61
  (isParentHeader ? (
61
62
  <MRT_TableSpacerCell />
@@ -75,7 +76,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
75
76
  ) : null}
76
77
  {enableSelection ? (
77
78
  !isParentHeader ? (
78
- <MRT_SelectAllCheckbox />
79
+ <MRT_SelectCheckbox selectAll />
79
80
  ) : (
80
81
  <MRT_TableSpacerCell width="1rem" />
81
82
  )
@@ -83,7 +84,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
83
84
  {headerGroup.headers.map((column: HeaderGroup) => (
84
85
  <MRT_TableHeadCell key={column.getHeaderProps().key} column={column} />
85
86
  ))}
86
- {enableRowActions &&
87
+ {(enableRowActions || enableRowEditing) &&
87
88
  positionActionsColumn === 'last' &&
88
89
  (isParentHeader ? (
89
90
  <MRT_TableSpacerCell />
package/src/icons.tsx ADDED
@@ -0,0 +1,72 @@
1
+ import CancelIcon from '@mui/icons-material/Cancel';
2
+ import ClearAllIcon from '@mui/icons-material/ClearAll';
3
+ import CloseIcon from '@mui/icons-material/Close';
4
+ import DensityMediumIcon from '@mui/icons-material/DensityMedium';
5
+ import DensitySmallIcon from '@mui/icons-material/DensitySmall';
6
+ import DoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
7
+ import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
8
+ import EditIcon from '@mui/icons-material/Edit';
9
+ import ExpandLessIcon from '@mui/icons-material/ExpandLess';
10
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
11
+ import FilterListIcon from '@mui/icons-material/FilterList';
12
+ import FilterListOffIcon from '@mui/icons-material/FilterListOff';
13
+ import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
14
+ import FullscreenIcon from '@mui/icons-material/Fullscreen';
15
+ import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
16
+ import MoreVertIcon from '@mui/icons-material/MoreVert';
17
+ import SaveIcon from '@mui/icons-material/Save';
18
+ import SearchIcon from '@mui/icons-material/Search';
19
+ import SearchOffIcon from '@mui/icons-material/SearchOff';
20
+ import SortIcon from '@mui/icons-material/Sort';
21
+ import ViewColumnIcon from '@mui/icons-material/ViewColumn';
22
+ import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
23
+
24
+ export interface MRT_Icons {
25
+ CancelIcon: any;
26
+ ClearAllIcon: any;
27
+ CloseIcon: any;
28
+ DensityMediumIcon: any;
29
+ DensitySmallIcon: any;
30
+ DoubleArrowDownIcon: any;
31
+ DynamicFeedIcon: any;
32
+ EditIcon: any;
33
+ ExpandLessIcon: any;
34
+ ExpandMoreIcon: any;
35
+ FilterListIcon: any;
36
+ FilterListOffIcon: any;
37
+ FullscreenExitIcon: any;
38
+ FullscreenIcon: any;
39
+ MoreHorizIcon: any;
40
+ MoreVertIcon: any;
41
+ SaveIcon: any;
42
+ SearchIcon: any;
43
+ SearchOffIcon: any;
44
+ SortIcon: any;
45
+ ViewColumnIcon: any;
46
+ VisibilityOffIcon: any;
47
+ }
48
+
49
+ export const MRT_Default_Icons: MRT_Icons = {
50
+ CancelIcon,
51
+ ClearAllIcon,
52
+ CloseIcon,
53
+ DensityMediumIcon,
54
+ DensitySmallIcon,
55
+ DoubleArrowDownIcon,
56
+ DynamicFeedIcon,
57
+ EditIcon,
58
+ ExpandLessIcon,
59
+ ExpandMoreIcon,
60
+ FilterListIcon,
61
+ FilterListOffIcon,
62
+ FullscreenExitIcon,
63
+ FullscreenIcon,
64
+ MoreHorizIcon,
65
+ MoreVertIcon,
66
+ SaveIcon,
67
+ SearchIcon,
68
+ SearchOffIcon,
69
+ SortIcon,
70
+ ViewColumnIcon,
71
+ VisibilityOffIcon,
72
+ };
@@ -10,7 +10,6 @@ interface Props {
10
10
  export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
11
11
  const {
12
12
  currentEditingRow,
13
- localization,
14
13
  muiTableBodyCellEditTextFieldProps,
15
14
  setCurrentEditingRow,
16
15
  } = useMRT();
@@ -55,7 +54,7 @@ export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
55
54
  margin="dense"
56
55
  onChange={handleChange}
57
56
  onClick={(e) => e.stopPropagation()}
58
- placeholder={localization?.filterTextFieldPlaceholder}
57
+ placeholder={cell.column.Header as string}
59
58
  value={cell.value}
60
59
  variant="standard"
61
60
  {...textFieldProps}
@@ -1,7 +1,5 @@
1
1
  import React, { ChangeEvent, FC, useState } from 'react';
2
2
  import { IconButton, InputAdornment, TextField, Tooltip } from '@mui/material';
3
- import CloseIcon from '@mui/icons-material/Close';
4
- import FilterIcon from '@mui/icons-material/FilterList';
5
3
  import { HeaderGroup, useAsyncDebounce } from 'react-table';
6
4
  import { useMRT } from '../useMRT';
7
5
 
@@ -10,7 +8,10 @@ interface Props {
10
8
  }
11
9
 
12
10
  export const MRT_FilterTextField: FC<Props> = ({ column }) => {
13
- const { localization } = useMRT();
11
+ const {
12
+ icons: { FilterListIcon, CloseIcon },
13
+ localization,
14
+ } = useMRT();
14
15
 
15
16
  const [filterValue, setFilterValue] = useState('');
16
17
 
@@ -37,7 +38,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
37
38
  },
38
39
  }}
39
40
  margin="dense"
40
- placeholder={localization?.filterTextFieldPlaceholder?.replace(
41
+ placeholder={localization.filterTextFieldPlaceholder?.replace(
41
42
  '{column}',
42
43
  String(column.Header),
43
44
  )}
@@ -52,15 +53,13 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
52
53
  startAdornment: (
53
54
  <Tooltip
54
55
  arrow
55
- title={
56
- localization?.filterTextFieldPlaceholder?.replace(
57
- '{column}',
58
- String(column.Header),
59
- ) ?? ''
60
- }
56
+ title={localization.filterTextFieldPlaceholder?.replace(
57
+ '{column}',
58
+ String(column.Header),
59
+ )}
61
60
  >
62
61
  <InputAdornment position="start">
63
- <FilterIcon />
62
+ <FilterListIcon />
64
63
  </InputAdornment>
65
64
  </Tooltip>
66
65
  ),
@@ -68,11 +67,11 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
68
67
  <InputAdornment position="end">
69
68
  <Tooltip
70
69
  arrow
71
- title={localization?.filterTextFieldClearButtonTitle ?? ''}
70
+ title={localization.filterTextFieldClearButtonTitle ?? ''}
72
71
  >
73
72
  <span>
74
73
  <IconButton
75
- aria-label={localization?.filterTextFieldClearButtonTitle}
74
+ aria-label={localization.filterTextFieldClearButtonTitle}
76
75
  disabled={filterValue?.length === 0}
77
76
  onClick={handleClear}
78
77
  size="small"
@@ -6,8 +6,6 @@ import {
6
6
  styled,
7
7
  TextField as MuiTextField,
8
8
  } from '@mui/material';
9
- import SearchIcon from '@mui/icons-material/Search';
10
- import CloseIcon from '@mui/icons-material/Close';
11
9
  import { useMRT } from '../useMRT';
12
10
  import { useAsyncDebounce } from 'react-table';
13
11
 
@@ -19,6 +17,7 @@ interface Props {}
19
17
 
20
18
  export const MRT_SearchTextField: FC<Props> = () => {
21
19
  const {
20
+ icons: { SearchIcon, CloseIcon },
22
21
  showSearch,
23
22
  localization,
24
23
  muiSearchTextFieldProps,
@@ -45,7 +44,7 @@ export const MRT_SearchTextField: FC<Props> = () => {
45
44
  <Collapse in={showSearch} orientation="horizontal">
46
45
  <TextField
47
46
  id="global-search-text-field"
48
- placeholder={localization?.searchTextFieldPlaceholder}
47
+ placeholder={localization.searchTextFieldPlaceholder}
49
48
  onChange={(event: ChangeEvent<HTMLInputElement>) => {
50
49
  setSearchValue(event.target.value);
51
50
  handleChange(event);
@@ -61,11 +60,11 @@ export const MRT_SearchTextField: FC<Props> = () => {
61
60
  endAdornment: (
62
61
  <InputAdornment position="end">
63
62
  <IconButton
64
- aria-label={localization?.searchTextFieldClearButtonTitle}
63
+ aria-label={localization.searchTextFieldClearButtonTitle}
65
64
  disabled={searchValue?.length === 0}
66
65
  onClick={handleClear}
67
66
  size="small"
68
- title={localization?.searchTextFieldClearButtonTitle}
67
+ title={localization.searchTextFieldClearButtonTitle}
69
68
  >
70
69
  <CloseIcon fontSize="small" />
71
70
  </IconButton>
@@ -1,31 +1,60 @@
1
1
  import React, { ChangeEvent, FC } from 'react';
2
- import { Checkbox } from '@mui/material';
2
+ import { Checkbox, Tooltip } from '@mui/material';
3
3
  import { Row } from 'react-table';
4
4
  import { useMRT } from '../useMRT';
5
5
  import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
6
6
 
7
7
  interface Props {
8
- row: Row;
8
+ row?: Row;
9
+ selectAll?: boolean;
9
10
  }
10
11
 
11
- export const MRT_SelectCheckbox: FC<Props> = ({ row }) => {
12
- const { tableInstance, onRowSelectChange, densePadding, localization } =
13
- useMRT();
12
+ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
13
+ const {
14
+ densePadding,
15
+ localization,
16
+ onRowSelectChange,
17
+ onSelectAllChange,
18
+ tableInstance,
19
+ } = useMRT();
14
20
 
15
- const onSelectChange = (event: ChangeEvent) => {
16
- row.getToggleRowSelectedProps()?.onChange?.(event);
17
- onRowSelectChange?.(event, row, tableInstance.selectedFlatRows);
21
+ const onSelectChange = (event: ChangeEvent<HTMLInputElement>) => {
22
+ if (selectAll) {
23
+ onSelectAllChange?.(event, tableInstance.selectedFlatRows);
24
+ tableInstance.toggleAllRowsSelected(event.target.checked);
25
+ } else if (row) {
26
+ row?.getToggleRowSelectedProps()?.onChange?.(event);
27
+ onRowSelectChange?.(event, row, tableInstance.selectedFlatRows);
28
+ }
18
29
  };
19
30
 
31
+ const checkboxProps = selectAll
32
+ ? tableInstance.getToggleAllRowsSelectedProps()
33
+ : row?.getToggleRowSelectedProps();
34
+
20
35
  return (
21
36
  <MRT_TableButtonCell densePadding={densePadding}>
22
- <Checkbox
23
- inputProps={{
24
- 'aria-label': localization?.selectCheckboxTitle,
25
- }}
26
- onChange={onSelectChange}
27
- {...row.getToggleRowSelectedProps()}
28
- />
37
+ <Tooltip
38
+ arrow
39
+ enterDelay={1000}
40
+ enterNextDelay={1000}
41
+ title={
42
+ selectAll
43
+ ? localization.selectAllCheckboxTitle
44
+ : localization.selectCheckboxTitle
45
+ }
46
+ >
47
+ <Checkbox
48
+ inputProps={{
49
+ 'aria-label': selectAll
50
+ ? localization.selectAllCheckboxTitle
51
+ : localization.selectCheckboxTitle,
52
+ }}
53
+ onChange={onSelectChange}
54
+ {...checkboxProps}
55
+ title={undefined}
56
+ />
57
+ </Tooltip>
29
58
  </MRT_TableButtonCell>
30
59
  );
31
60
  };
@@ -32,10 +32,10 @@ export interface MRT_Localization {
32
32
  toolbarAlertGroupedThenByMessage: string;
33
33
  }
34
34
 
35
- export const defaultLocalization: MRT_Localization = {
35
+ export const MRT_DefaultLocalization_EN: MRT_Localization = {
36
36
  actionsHeadColumnTitle: 'Actions',
37
37
  columnActionMenuButtonTitle: 'Column Actions',
38
- columnActionMenuItemClearSort: 'Clear sorting',
38
+ columnActionMenuItemClearSort: 'Clear sort',
39
39
  columnActionMenuItemGroupBy: 'Group by {column}',
40
40
  columnActionMenuItemHideColumn: 'Hide {column} column',
41
41
  columnActionMenuItemSortAsc: 'Sort by {column} ascending',
@@ -54,8 +54,8 @@ export const defaultLocalization: MRT_Localization = {
54
54
  rowActionsColumnTitle: 'Actions',
55
55
  searchTextFieldClearButtonTitle: 'Clear search',
56
56
  searchTextFieldPlaceholder: 'Search',
57
- selectAllCheckboxTitle: 'Select all',
58
- selectCheckboxTitle: 'Select row',
57
+ selectAllCheckboxTitle: 'Toggle select all',
58
+ selectCheckboxTitle: 'Toggle select row',
59
59
  showHideColumnsButtonTitle: 'Show/Hide columns',
60
60
  toggleDensePaddingSwitchTitle: 'Toggle dense padding',
61
61
  toggleFilterButtonTitle: 'Toggle filters',
@@ -2,11 +2,6 @@ import React, { FC } from 'react';
2
2
  import { Divider, Menu, MenuItem as MuiMenuItem, styled } from '@mui/material';
3
3
  import { useMRT } from '../useMRT';
4
4
  import { HeaderGroup } from 'react-table';
5
- import ClearAllIcon from '@mui/icons-material/ClearAll';
6
- import SortIcon from '@mui/icons-material/Sort';
7
- import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
8
- import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
9
- import FilterIcon from '@mui/icons-material/FilterList';
10
5
 
11
6
  const MenuItem = styled(MuiMenuItem)({
12
7
  display: 'flex',
@@ -31,6 +26,13 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
31
26
  enableColumnGrouping,
32
27
  localization,
33
28
  setShowFilters,
29
+ icons: {
30
+ FilterListIcon,
31
+ SortIcon,
32
+ ClearAllIcon,
33
+ DynamicFeedIcon,
34
+ VisibilityOffIcon,
35
+ },
34
36
  } = useMRT();
35
37
 
36
38
  const handleClearSort = () => {
@@ -87,7 +89,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
87
89
  disabled={!column.isSorted}
88
90
  onClick={handleClearSort}
89
91
  >
90
- <ClearAllIcon /> {localization?.columnActionMenuItemClearSort}
92
+ <ClearAllIcon /> {localization.columnActionMenuItemClearSort}
91
93
  </MenuItem>,
92
94
  <MenuItem
93
95
  key={2}
@@ -95,7 +97,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
95
97
  onClick={handleSortAsc}
96
98
  >
97
99
  <SortIcon />{' '}
98
- {localization?.columnActionMenuItemSortAsc?.replace(
100
+ {localization.columnActionMenuItemSortAsc?.replace(
99
101
  '{column}',
100
102
  String(column.Header),
101
103
  )}
@@ -106,7 +108,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
106
108
  onClick={handleSortDesc}
107
109
  >
108
110
  <SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />{' '}
109
- {localization?.columnActionMenuItemSortDesc?.replace(
111
+ {localization.columnActionMenuItemSortDesc?.replace(
110
112
  '{column}',
111
113
  String(column.Header),
112
114
  )}
@@ -116,8 +118,8 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
116
118
  column.canFilter && [
117
119
  <Divider key={0} />,
118
120
  <MenuItem key={1} onClick={handleFilterByColumn}>
119
- <FilterIcon />{' '}
120
- {localization?.filterTextFieldPlaceholder?.replace(
121
+ <FilterListIcon />{' '}
122
+ {localization.filterTextFieldPlaceholder?.replace(
121
123
  '{column}',
122
124
  String(column.Header),
123
125
  )}
@@ -128,7 +130,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
128
130
  <Divider key={1} />,
129
131
  <MenuItem key={2} onClick={handleGroupByColumn}>
130
132
  <DynamicFeedIcon />{' '}
131
- {localization?.[
133
+ {localization[
132
134
  column.isGrouped
133
135
  ? 'columnActionMenuItemUnGroupBy'
134
136
  : 'columnActionMenuItemGroupBy'
@@ -139,7 +141,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
139
141
  <Divider key={0} />,
140
142
  <MenuItem key={1} onClick={handleHideColumn}>
141
143
  <VisibilityOffIcon />{' '}
142
- {localization?.columnActionMenuItemHideColumn?.replace(
144
+ {localization.columnActionMenuItemHideColumn?.replace(
143
145
  '{column}',
144
146
  String(column.Header),
145
147
  )}
@@ -2,7 +2,6 @@ import React, { FC } from 'react';
2
2
  import { Menu, MenuItem as MuiMenuItem, styled } from '@mui/material';
3
3
  import { useMRT } from '../useMRT';
4
4
  import { Row } from 'react-table';
5
- import EditIcon from '@mui/icons-material/Edit';
6
5
 
7
6
  const MenuItem = styled(MuiMenuItem)({
8
7
  display: 'flex',
@@ -23,6 +22,7 @@ export const MRT_RowActionMenu: FC<Props> = ({
23
22
  setAnchorEl,
24
23
  }) => {
25
24
  const {
25
+ icons: { EditIcon },
26
26
  enableRowEditing,
27
27
  localization,
28
28
  renderRowActionMenuItems,
@@ -37,7 +37,7 @@ export const MRT_RowActionMenu: FC<Props> = ({
37
37
  >
38
38
  {enableRowEditing && (
39
39
  <MenuItem onClick={handleEdit}>
40
- <EditIcon /> {localization?.rowActionMenuItemEdit}
40
+ <EditIcon /> {localization.rowActionMenuItemEdit}
41
41
  </MenuItem>
42
42
  )}
43
43
  {renderRowActionMenuItems?.(row, tableInstance, () =>
@@ -1,4 +1,4 @@
1
- import React, { FC, useEffect } from 'react';
1
+ import React, { FC } from 'react';
2
2
  import {
3
3
  CircularProgress,
4
4
  LinearProgress,
@@ -14,12 +14,12 @@ import { MRT_ToolbarBottom } from '../toolbar/MRT_ToolbarBottom';
14
14
 
15
15
  const TableContainer = styled(MuiTableContainer, {
16
16
  shouldForwardProp: (prop) => prop !== 'fullScreen',
17
- })<{ fullScreen?: boolean, component: any }>(({ fullScreen }) => ({
17
+ })<{ fullScreen?: boolean; component: any }>(({ fullScreen }) => ({
18
18
  bottom: fullScreen ? '0' : undefined,
19
19
  height: fullScreen ? '100%' : undefined,
20
20
  left: fullScreen ? '0' : undefined,
21
21
  margin: fullScreen ? '0' : undefined,
22
- position: fullScreen ? 'absolute' : undefined,
22
+ position: fullScreen ? 'fixed' : undefined,
23
23
  right: fullScreen ? '0' : undefined,
24
24
  top: fullScreen ? '0' : undefined,
25
25
  transition: 'all 0.2s ease-in-out',
@@ -51,14 +51,6 @@ export const MRT_TableContainer: FC<Props> = () => {
51
51
  tableInstance,
52
52
  } = useMRT();
53
53
 
54
- useEffect(() => {
55
- if(fullScreen) {
56
- document.body.style.overflow = 'hidden';
57
- } else {
58
- document.body.style.overflow = 'auto';
59
- }
60
- }, [fullScreen]);
61
-
62
54
  const tableContainerProps =
63
55
  muiTableContainerProps instanceof Function
64
56
  ? muiTableContainerProps(tableInstance)
@@ -25,6 +25,7 @@ export const MRT_TablePagination: FC<Props> = () => {
25
25
  onRowsPerPageChange={handleChangeRowsPerPage}
26
26
  page={tableInstance.state.pageIndex}
27
27
  rowsPerPage={tableInstance.state.pageSize}
28
+ SelectProps={{ style: { margin: '0 1rem 0 1ch' } }}
28
29
  showFirstButton={
29
30
  tableInstance.rows.length / tableInstance.state.pageSize > 2
30
31
  }
@@ -47,7 +47,7 @@ export const MRT_ToolbarAlertBanner: FC<Props> = () => {
47
47
 
48
48
  const selectMessage =
49
49
  tableInstance.selectedFlatRows.length > 0
50
- ? localization?.toolbarAlertSelectionMessage
50
+ ? localization.toolbarAlertSelectionMessage
51
51
  ?.replace(
52
52
  '{selectedCount}',
53
53
  tableInstance.selectedFlatRows.length.toString(),
@@ -58,10 +58,10 @@ export const MRT_ToolbarAlertBanner: FC<Props> = () => {
58
58
  const groupedByMessage =
59
59
  tableInstance.state.groupBy.length > 0 ? (
60
60
  <span>
61
- {localization?.toolbarAlertGroupedByMessage}{' '}
61
+ {localization.toolbarAlertGroupedByMessage}{' '}
62
62
  {tableInstance.state.groupBy.map((columnId, index) => (
63
63
  <Fragment key={`${index}-${columnId}`}>
64
- {index > 0 ? localization?.toolbarAlertGroupedThenByMessage : ''}
64
+ {index > 0 ? localization.toolbarAlertGroupedThenByMessage : ''}
65
65
  <Chip
66
66
  color="secondary"
67
67
  label={
@@ -27,7 +27,7 @@ interface Props {}
27
27
 
28
28
  export const MRT_ToolbarBottom: FC<Props> = () => {
29
29
  const {
30
- hideToolbarActions,
30
+ hideToolbarInternalActions,
31
31
  manualPagination,
32
32
  muiTableToolbarBottomProps,
33
33
  positionPagination,
@@ -44,7 +44,7 @@ export const MRT_ToolbarBottom: FC<Props> = () => {
44
44
 
45
45
  return (
46
46
  <Toolbar fullScreen={fullScreen} variant="dense" {...toolbarProps}>
47
- {!hideToolbarActions && positionToolbarActions === 'bottom' ? (
47
+ {!hideToolbarInternalActions && positionToolbarActions === 'bottom' ? (
48
48
  <MRT_ToolbarInternalButtons />
49
49
  ) : (
50
50
  <span />
@@ -22,8 +22,24 @@ export const MRT_ToolbarInternalButtons: FC<Props> = () => {
22
22
  disableDensePaddingToggle,
23
23
  disableGlobalFilter,
24
24
  disableFullScreenToggle,
25
+ renderToolbarInternalActions,
26
+ tableInstance,
25
27
  } = useMRT();
26
28
 
29
+ if (renderToolbarInternalActions) {
30
+ return (
31
+ <>
32
+ {renderToolbarInternalActions(tableInstance, {
33
+ MRT_ToggleSearchButton,
34
+ MRT_ToggleFiltersButton,
35
+ MRT_ShowHideColumnsButton,
36
+ MRT_ToggleDensePaddingButton,
37
+ MRT_FullScreenToggleButton,
38
+ })}
39
+ </>
40
+ );
41
+ }
42
+
27
43
  return (
28
44
  <ToolbarButtonsContainer>
29
45
  {!disableGlobalFilter && <MRT_ToggleSearchButton />}
@@ -40,7 +40,7 @@ interface Props {}
40
40
  export const MRT_ToolbarTop: FC<Props> = () => {
41
41
  const {
42
42
  disableGlobalFilter,
43
- hideToolbarActions,
43
+ hideToolbarInternalActions,
44
44
  manualPagination,
45
45
  muiTableToolbarTopProps,
46
46
  positionPagination,
@@ -63,7 +63,7 @@ export const MRT_ToolbarTop: FC<Props> = () => {
63
63
  {renderToolbarCustomActions?.(tableInstance) ?? <span />}
64
64
  <ToolbarActionsContainer>
65
65
  {!disableGlobalFilter && <MRT_SearchTextField />}
66
- {!hideToolbarActions && positionToolbarActions === 'top' && (
66
+ {!hideToolbarInternalActions && positionToolbarActions === 'top' && (
67
67
  <MRT_ToolbarInternalButtons />
68
68
  )}
69
69
  </ToolbarActionsContainer>
package/src/useMRT.tsx CHANGED
@@ -21,14 +21,18 @@ import {
21
21
  useSortBy,
22
22
  useTable,
23
23
  } from 'react-table';
24
+ import { MRT_Icons } from './icons';
25
+ import { MRT_Localization } from './localization';
24
26
  import { MaterialReactTableProps } from './MaterialReactTable';
25
27
 
26
- export interface UseMRT<D extends {} = {}> extends MaterialReactTableProps<D> {
28
+ export type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
27
29
  anyRowsCanExpand: boolean;
28
30
  anyRowsExpanded: boolean;
29
31
  currentEditingRow: Row<D> | null;
30
32
  densePadding: boolean;
31
33
  fullScreen: boolean;
34
+ icons: MRT_Icons;
35
+ localization: MRT_Localization;
32
36
  setCurrentEditingRow: (currentRowEditingId: Row<D> | null) => void;
33
37
  setDensePadding: (densePadding: boolean) => void;
34
38
  setFullScreen: (fullScreen: boolean) => void;
@@ -37,7 +41,7 @@ export interface UseMRT<D extends {} = {}> extends MaterialReactTableProps<D> {
37
41
  showFilters: boolean;
38
42
  showSearch: boolean;
39
43
  tableInstance: TableInstance<D>;
40
- }
44
+ };
41
45
 
42
46
  const MaterialReactTableContext = (<D extends {}>() =>
43
47
  createContext<UseMRT<D>>({} as UseMRT<D>) as Context<UseMRT<D>>)();