material-react-table 0.3.4 → 0.4.2

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 (60) hide show
  1. package/dist/MaterialReactTable.d.ts +9 -4
  2. package/dist/body/MRT_TableBodyCell.d.ts +3 -0
  3. package/dist/buttons/MRT_FullScreenToggleButton.d.ts +4 -0
  4. package/dist/head/MRT_TableHeadCell.d.ts +1 -1
  5. package/dist/head/MRT_TableHeadCellActions.d.ts +5 -0
  6. package/dist/material-react-table.cjs.development.js +420 -278
  7. package/dist/material-react-table.cjs.development.js.map +1 -1
  8. package/dist/material-react-table.cjs.production.min.js +1 -1
  9. package/dist/material-react-table.cjs.production.min.js.map +1 -1
  10. package/dist/material-react-table.esm.js +424 -282
  11. package/dist/material-react-table.esm.js.map +1 -1
  12. package/dist/toolbar/MRT_ToolbarAlertBanner.d.ts +5 -0
  13. package/dist/toolbar/MRT_ToolbarInternalButtons.d.ts +5 -0
  14. package/dist/{useMaterialReactTable.d.ts → useMRT.d.ts} +6 -3
  15. package/dist/utils/localization.d.ts +6 -0
  16. package/package.json +14 -14
  17. package/src/@types/react-table-config.d.ts +56 -31
  18. package/src/MaterialReactTable.tsx +67 -19
  19. package/src/body/MRT_TableBody.tsx +2 -2
  20. package/src/body/MRT_TableBodyCell.tsx +16 -9
  21. package/src/body/MRT_TableBodyRow.tsx +22 -7
  22. package/src/body/MRT_TableDetailPanel.tsx +14 -5
  23. package/src/buttons/MRT_EditActionButtons.tsx +11 -4
  24. package/src/buttons/MRT_ExpandAllButton.tsx +6 -3
  25. package/src/buttons/MRT_ExpandButton.tsx +9 -3
  26. package/src/buttons/MRT_FullScreenToggleButton.tsx +23 -0
  27. package/src/buttons/MRT_ShowHideColumnsButton.tsx +43 -5
  28. package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +7 -3
  29. package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
  30. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +7 -3
  31. package/src/buttons/MRT_ToggleSearchButton.tsx +7 -3
  32. package/src/footer/MRT_TableFooter.tsx +6 -3
  33. package/src/footer/MRT_TableFooterCell.tsx +5 -3
  34. package/src/footer/MRT_TableFooterRow.tsx +17 -6
  35. package/src/head/MRT_TableHead.tsx +9 -4
  36. package/src/head/MRT_TableHeadCell.tsx +11 -7
  37. package/src/head/MRT_TableHeadCellActions.tsx +18 -0
  38. package/src/head/MRT_TableHeadRow.tsx +19 -12
  39. package/src/inputs/MRT_DensePaddingSwitch.tsx +2 -2
  40. package/src/inputs/MRT_EditCellTextField.tsx +2 -2
  41. package/src/inputs/MRT_FilterTextField.tsx +6 -3
  42. package/src/inputs/MRT_SearchTextField.tsx +15 -7
  43. package/src/inputs/MRT_SelectAllCheckbox.tsx +3 -2
  44. package/src/inputs/MRT_SelectCheckbox.tsx +3 -2
  45. package/src/menus/MRT_ColumnActionMenu.tsx +40 -13
  46. package/src/menus/MRT_RowActionMenu.tsx +21 -6
  47. package/src/menus/MRT_ShowHideColumnsMenu.tsx +24 -15
  48. package/src/table/MRT_Table.tsx +3 -2
  49. package/src/table/MRT_TableContainer.tsx +37 -6
  50. package/src/table/MRT_TableSpacerCell.tsx +5 -3
  51. package/src/toolbar/MRT_TablePagination.tsx +9 -5
  52. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +102 -0
  53. package/src/toolbar/MRT_ToolbarBottom.tsx +14 -8
  54. package/src/toolbar/{MRT_ToolbarButtons.tsx → MRT_ToolbarInternalButtons.tsx} +11 -4
  55. package/src/toolbar/MRT_ToolbarTop.tsx +19 -11
  56. package/src/{useMaterialReactTable.tsx → useMRT.tsx} +43 -19
  57. package/src/utils/localization.ts +14 -2
  58. package/dist/toolbar/MRT_ToolbarButtons.d.ts +0 -5
  59. package/dist/utils/useMRTCalcs.d.ts +0 -11
  60. package/src/utils/useMRTCalcs.tsx +0 -40
@@ -1,6 +1,6 @@
1
1
  import React, { FC } from 'react';
2
2
  import { Divider, Menu, MenuItem as MuiMenuItem, styled } from '@mui/material';
3
- import { useMaterialReactTable } from '../useMaterialReactTable';
3
+ import { useMRT } from '../useMRT';
4
4
  import { HeaderGroup } from 'react-table';
5
5
  import ClearAllIcon from '@mui/icons-material/ClearAll';
6
6
  import SortIcon from '@mui/icons-material/Sort';
@@ -19,15 +19,19 @@ interface Props {
19
19
  setAnchorEl: (anchorEl: HTMLElement | null) => void;
20
20
  }
21
21
 
22
- export const MRT_ColumnActionMenu: FC<Props> = ({ anchorEl, column, setAnchorEl }) => {
22
+ export const MRT_ColumnActionMenu: FC<Props> = ({
23
+ anchorEl,
24
+ column,
25
+ setAnchorEl,
26
+ }) => {
23
27
  const {
24
28
  disableColumnHiding,
25
- enableColumnGrouping,
29
+ disableFilters,
26
30
  disableSortBy,
31
+ enableColumnGrouping,
27
32
  localization,
28
- disableFilters,
29
33
  setShowFilters,
30
- } = useMaterialReactTable();
34
+ } = useMRT();
31
35
 
32
36
  const handleClearSort = () => {
33
37
  column.clearSortBy();
@@ -61,7 +65,8 @@ export const MRT_ColumnActionMenu: FC<Props> = ({ anchorEl, column, setAnchorEl
61
65
  document
62
66
  .getElementById(
63
67
  // @ts-ignore
64
- column.muiTableHeadCellFilterTextFieldProps?.id ?? `filter-${column.id}-column`,
68
+ column.muiTableHeadCellFilterTextFieldProps?.id ??
69
+ `filter-${column.id}-column`,
65
70
  )
66
71
  ?.focus(),
67
72
  200,
@@ -70,10 +75,18 @@ export const MRT_ColumnActionMenu: FC<Props> = ({ anchorEl, column, setAnchorEl
70
75
  };
71
76
 
72
77
  return (
73
- <Menu anchorEl={anchorEl} open={!!anchorEl} onClose={() => setAnchorEl(null)}>
78
+ <Menu
79
+ anchorEl={anchorEl}
80
+ open={!!anchorEl}
81
+ onClose={() => setAnchorEl(null)}
82
+ >
74
83
  {!disableSortBy &&
75
84
  column.canSort && [
76
- <MenuItem key={1} disabled={!column.isSorted} onClick={handleClearSort}>
85
+ <MenuItem
86
+ key={1}
87
+ disabled={!column.isSorted}
88
+ onClick={handleClearSort}
89
+ >
77
90
  <ClearAllIcon /> {localization?.columnActionMenuItemClearSort}
78
91
  </MenuItem>,
79
92
  <MenuItem
@@ -82,7 +95,10 @@ export const MRT_ColumnActionMenu: FC<Props> = ({ anchorEl, column, setAnchorEl
82
95
  onClick={handleSortAsc}
83
96
  >
84
97
  <SortIcon />{' '}
85
- {localization?.columnActionMenuItemSortAsc?.replace('{column}', String(column.Header))}
98
+ {localization?.columnActionMenuItemSortAsc?.replace(
99
+ '{column}',
100
+ String(column.Header),
101
+ )}
86
102
  </MenuItem>,
87
103
  <MenuItem
88
104
  key={3}
@@ -90,7 +106,10 @@ export const MRT_ColumnActionMenu: FC<Props> = ({ anchorEl, column, setAnchorEl
90
106
  onClick={handleSortDesc}
91
107
  >
92
108
  <SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />{' '}
93
- {localization?.columnActionMenuItemSortDesc?.replace('{column}', String(column.Header))}
109
+ {localization?.columnActionMenuItemSortDesc?.replace(
110
+ '{column}',
111
+ String(column.Header),
112
+ )}
94
113
  </MenuItem>,
95
114
  ]}
96
115
  {!disableFilters &&
@@ -98,7 +117,10 @@ export const MRT_ColumnActionMenu: FC<Props> = ({ anchorEl, column, setAnchorEl
98
117
  <Divider key={0} />,
99
118
  <MenuItem key={1} onClick={handleFilterByColumn}>
100
119
  <FilterIcon />{' '}
101
- {localization?.filterTextFieldPlaceholder?.replace('{column}', String(column.Header))}
120
+ {localization?.filterTextFieldPlaceholder?.replace(
121
+ '{column}',
122
+ String(column.Header),
123
+ )}
102
124
  </MenuItem>,
103
125
  ]}
104
126
  {enableColumnGrouping &&
@@ -107,7 +129,9 @@ export const MRT_ColumnActionMenu: FC<Props> = ({ anchorEl, column, setAnchorEl
107
129
  <MenuItem key={2} onClick={handleGroupByColumn}>
108
130
  <DynamicFeedIcon />{' '}
109
131
  {localization?.[
110
- column.isGrouped ? 'columnActionMenuItemUnGroupBy' : 'columnActionMenuItemGroupBy'
132
+ column.isGrouped
133
+ ? 'columnActionMenuItemUnGroupBy'
134
+ : 'columnActionMenuItemGroupBy'
111
135
  ]?.replace('{column}', String(column.Header))}
112
136
  </MenuItem>,
113
137
  ]}
@@ -115,7 +139,10 @@ export const MRT_ColumnActionMenu: FC<Props> = ({ anchorEl, column, setAnchorEl
115
139
  <Divider key={0} />,
116
140
  <MenuItem key={1} onClick={handleHideColumn}>
117
141
  <VisibilityOffIcon />{' '}
118
- {localization?.columnActionMenuItemHideColumn?.replace('{column}', String(column.Header))}
142
+ {localization?.columnActionMenuItemHideColumn?.replace(
143
+ '{column}',
144
+ String(column.Header),
145
+ )}
119
146
  </MenuItem>,
120
147
  ]}
121
148
  </Menu>
@@ -1,6 +1,6 @@
1
1
  import React, { FC } from 'react';
2
2
  import { Menu, MenuItem as MuiMenuItem, styled } from '@mui/material';
3
- import { useMaterialReactTable } from '../useMaterialReactTable';
3
+ import { useMRT } from '../useMRT';
4
4
  import { Row } from 'react-table';
5
5
  import EditIcon from '@mui/icons-material/Edit';
6
6
 
@@ -16,18 +16,33 @@ interface Props {
16
16
  handleEdit: () => void;
17
17
  }
18
18
 
19
- export const MRT_RowActionMenu: FC<Props> = ({ anchorEl, row, handleEdit, setAnchorEl }) => {
20
- const { enableRowEditing, localization, renderRowActionMenuItems, tableInstance } =
21
- useMaterialReactTable();
19
+ export const MRT_RowActionMenu: FC<Props> = ({
20
+ anchorEl,
21
+ row,
22
+ handleEdit,
23
+ setAnchorEl,
24
+ }) => {
25
+ const {
26
+ enableRowEditing,
27
+ localization,
28
+ renderRowActionMenuItems,
29
+ tableInstance,
30
+ } = useMRT();
22
31
 
23
32
  return (
24
- <Menu anchorEl={anchorEl} open={!!anchorEl} onClose={() => setAnchorEl(null)}>
33
+ <Menu
34
+ anchorEl={anchorEl}
35
+ open={!!anchorEl}
36
+ onClose={() => setAnchorEl(null)}
37
+ >
25
38
  {enableRowEditing && (
26
39
  <MenuItem onClick={handleEdit}>
27
40
  <EditIcon /> {localization?.rowActionMenuItemEdit}
28
41
  </MenuItem>
29
42
  )}
30
- {renderRowActionMenuItems?.(row, tableInstance, () => setAnchorEl(null)) ?? null}
43
+ {renderRowActionMenuItems?.(row, tableInstance, () =>
44
+ setAnchorEl(null),
45
+ ) ?? null}
31
46
  </Menu>
32
47
  );
33
48
  };
@@ -1,6 +1,5 @@
1
1
  import React, { FC } from 'react';
2
- import { FormControlLabel, MenuItem, Switch, Typography } from '@mui/material';
3
- import { useMaterialReactTable } from '../useMaterialReactTable';
2
+ import { FormControlLabel, MenuItem, Switch } from '@mui/material';
4
3
  import { ColumnInstance } from 'react-table';
5
4
 
6
5
  interface Props {
@@ -8,23 +7,33 @@ interface Props {
8
7
  }
9
8
 
10
9
  export const MRT_ShowHideColumnsMenu: FC<Props> = ({ column }) => {
11
- const { maxColumnDepth } = useMaterialReactTable();
10
+ const isParentHeader = (column?.columns?.length ?? 0) > 0;
12
11
 
13
- const isMaxDepth = column.depth === maxColumnDepth;
12
+ const allChildColumnsVisible =
13
+ isParentHeader &&
14
+ !!column.columns?.every((childColumn) => childColumn.isVisible);
15
+
16
+ const switchChecked = column.isVisible ?? allChildColumnsVisible;
17
+
18
+ const handleToggleColumnHidden = (column: ColumnInstance) => {
19
+ if (isParentHeader) {
20
+ column?.columns?.forEach?.((childColumn) => {
21
+ childColumn.toggleHidden(switchChecked);
22
+ });
23
+ } else {
24
+ column.toggleHidden();
25
+ }
26
+ };
14
27
 
15
28
  return (
16
29
  <>
17
- <MenuItem style={{ paddingLeft: `${column.depth + 1}rem` }}>
18
- {isMaxDepth ? (
19
- <FormControlLabel
20
- checked={column.isVisible}
21
- control={<Switch />}
22
- label={column.Header as string}
23
- onChange={() => isMaxDepth && column.toggleHidden()}
24
- />
25
- ) : (
26
- <Typography>{column.Header}</Typography>
27
- )}
30
+ <MenuItem style={{ paddingLeft: `${(column.depth + 0.5) * 2}rem` }}>
31
+ <FormControlLabel
32
+ checked={switchChecked}
33
+ control={<Switch />}
34
+ label={column.Header as string}
35
+ onChange={() => handleToggleColumnHidden(column)}
36
+ />
28
37
  </MenuItem>
29
38
  {column.columns?.map((c, i) => (
30
39
  <MRT_ShowHideColumnsMenu key={`${i}-${c.id}`} column={c} />
@@ -3,12 +3,13 @@ import { Table } from '@mui/material';
3
3
  import { MRT_TableHead } from '../head/MRT_TableHead';
4
4
  import { MRT_TableBody } from '../body/MRT_TableBody';
5
5
  import { MRT_TableFooter } from '../footer/MRT_TableFooter';
6
- import { useMaterialReactTable } from '../useMaterialReactTable';
6
+ import { useMRT } from '../useMRT';
7
7
 
8
8
  interface Props {}
9
9
 
10
10
  export const MRT_Table: FC<Props> = () => {
11
- const { tableInstance, muiTableProps, hideTableHead, hideTableFooter } = useMaterialReactTable();
11
+ const { tableInstance, muiTableProps, hideTableHead, hideTableFooter } =
12
+ useMRT();
12
13
 
13
14
  const tableProps = {
14
15
  ...muiTableProps,
@@ -1,17 +1,32 @@
1
1
  import React, { FC } from 'react';
2
2
  import {
3
- alpha,
4
3
  CircularProgress,
5
4
  LinearProgress,
6
5
  Paper,
6
+ TableContainer as MuiTableContainer,
7
+ alpha,
7
8
  styled,
8
- TableContainer,
9
9
  } from '@mui/material';
10
- import { useMaterialReactTable } from '../useMaterialReactTable';
10
+ import { useMRT } from '../useMRT';
11
11
  import { MRT_Table } from './MRT_Table';
12
12
  import { MRT_ToolbarTop } from '../toolbar/MRT_ToolbarTop';
13
13
  import { MRT_ToolbarBottom } from '../toolbar/MRT_ToolbarBottom';
14
14
 
15
+ const TableContainer = styled(MuiTableContainer, {
16
+ shouldForwardProp: (prop) => prop !== 'fullScreen',
17
+ })<{ fullScreen?: boolean; component?: any }>(({ fullScreen }) => ({
18
+ bottom: fullScreen ? '0' : undefined,
19
+ height: fullScreen ? '100%' : undefined,
20
+ left: fullScreen ? '0' : undefined,
21
+ margin: fullScreen ? '0' : undefined,
22
+ position: fullScreen ? 'absolute' : undefined,
23
+ right: fullScreen ? '0' : undefined,
24
+ top: fullScreen ? '0' : undefined,
25
+ transition: 'all 0.2s ease-in-out',
26
+ width: fullScreen ? '100vw' : undefined,
27
+ zIndex: fullScreen ? 1200 : 1,
28
+ }));
29
+
15
30
  const CircularProgressWrapper = styled('div')(({ theme }) => ({
16
31
  alignItems: 'center',
17
32
  backgroundColor: alpha(theme.palette.background.paper, 0.5),
@@ -26,11 +41,27 @@ const CircularProgressWrapper = styled('div')(({ theme }) => ({
26
41
  interface Props {}
27
42
 
28
43
  export const MRT_TableContainer: FC<Props> = () => {
29
- const { muiTableContainerProps, hideToolbarTop, hideToolbarBottom, isLoading, isFetching } =
30
- useMaterialReactTable();
44
+ const {
45
+ fullScreen,
46
+ hideToolbarBottom,
47
+ hideToolbarTop,
48
+ isFetching,
49
+ isLoading,
50
+ muiTableContainerProps,
51
+ tableInstance,
52
+ } = useMRT();
53
+
54
+ const tableContainerProps =
55
+ muiTableContainerProps instanceof Function
56
+ ? muiTableContainerProps(tableInstance)
57
+ : muiTableContainerProps;
31
58
 
32
59
  return (
33
- <TableContainer component={Paper} {...muiTableContainerProps}>
60
+ <TableContainer
61
+ component={Paper}
62
+ fullScreen={fullScreen}
63
+ {...tableContainerProps}
64
+ >
34
65
  {!hideToolbarTop && <MRT_ToolbarTop />}
35
66
  {isFetching && <LinearProgress />}
36
67
  {isLoading && (
@@ -1,16 +1,18 @@
1
1
  import React, { CSSProperties, FC } from 'react';
2
2
  import { TableCell } from '@mui/material';
3
- import { useMaterialReactTable } from '../useMaterialReactTable';
3
+ import { useMRT } from '../useMRT';
4
4
 
5
5
  interface Props {
6
6
  width?: CSSProperties['width'];
7
7
  }
8
8
 
9
9
  export const MRT_TableSpacerCell: FC<Props> = ({ width }) => {
10
- const { muiTableBodyCellProps } = useMaterialReactTable();
10
+ const { muiTableBodyCellProps } = useMRT();
11
11
 
12
12
  const mTableBodyCellrops =
13
- muiTableBodyCellProps instanceof Function ? muiTableBodyCellProps() : muiTableBodyCellProps;
13
+ muiTableBodyCellProps instanceof Function
14
+ ? muiTableBodyCellProps()
15
+ : muiTableBodyCellProps;
14
16
 
15
17
  const tableCellProps = {
16
18
  ...mTableBodyCellrops,
@@ -1,11 +1,11 @@
1
1
  import React, { ChangeEvent, FC } from 'react';
2
2
  import { TablePagination } from '@mui/material';
3
- import { useMaterialReactTable } from '../useMaterialReactTable';
3
+ import { useMRT } from '../useMRT';
4
4
 
5
5
  interface Props {}
6
6
 
7
7
  export const MRT_TablePagination: FC<Props> = () => {
8
- const { tableInstance, muiTablePaginationProps } = useMaterialReactTable();
8
+ const { tableInstance, muiTablePaginationProps } = useMRT();
9
9
 
10
10
  const tablePaginationProps =
11
11
  muiTablePaginationProps instanceof Function
@@ -25,9 +25,13 @@ export const MRT_TablePagination: FC<Props> = () => {
25
25
  onRowsPerPageChange={handleChangeRowsPerPage}
26
26
  page={tableInstance.state.pageIndex}
27
27
  rowsPerPage={tableInstance.state.pageSize}
28
- showFirstButton={tableInstance.rows.length / tableInstance.state.pageSize > 2}
29
- showLastButton={tableInstance.rows.length / tableInstance.state.pageSize > 2}
30
- style={{ padding: 0 }}
28
+ showFirstButton={
29
+ tableInstance.rows.length / tableInstance.state.pageSize > 2
30
+ }
31
+ showLastButton={
32
+ tableInstance.rows.length / tableInstance.state.pageSize > 2
33
+ }
34
+ style={{ padding: 0, position: 'relative', zIndex: 2 }}
31
35
  {...tablePaginationProps}
32
36
  />
33
37
  );
@@ -0,0 +1,102 @@
1
+ import React, { FC, Fragment } from 'react';
2
+ import {
3
+ Alert as MuiAlert,
4
+ Chip,
5
+ Collapse,
6
+ styled,
7
+ useMediaQuery,
8
+ } from '@mui/material';
9
+ import { useMRT } from '../useMRT';
10
+
11
+ const Alert = styled(MuiAlert, {
12
+ shouldForwardProp: (prop) =>
13
+ prop !== 'displayAbsolute' && prop !== 'toolbarPosition',
14
+ })<{ displayAbsolute?: boolean; toolbarPosition?: 'top' | 'bottom' }>(
15
+ ({ displayAbsolute, toolbarPosition }) => ({
16
+ borderRadius: 0,
17
+ fontSize: '1rem',
18
+ left: 0,
19
+ marginLeft: !displayAbsolute ? '-0.5rem' : undefined,
20
+ padding: toolbarPosition === 'bottom' ? '0 1rem' : '0.5rem 1.25rem',
21
+ position: displayAbsolute ? 'absolute' : 'relative',
22
+ right: 0,
23
+ top: 0,
24
+ width: `calc(100% - ${displayAbsolute ? '2.5rem' : '1.5rem'})`,
25
+ zIndex: 2,
26
+ }),
27
+ );
28
+
29
+ interface Props {}
30
+
31
+ export const MRT_ToolbarAlertBanner: FC<Props> = () => {
32
+ const {
33
+ muiTableToolbarAlertBannerProps,
34
+ tableInstance,
35
+ positionToolbarAlertBanner,
36
+ positionToolbarActions,
37
+ localization,
38
+ renderToolbarCustomActions,
39
+ } = useMRT();
40
+
41
+ const isMobile = useMediaQuery('(max-width:720px)');
42
+
43
+ const alertProps =
44
+ muiTableToolbarAlertBannerProps instanceof Function
45
+ ? muiTableToolbarAlertBannerProps(tableInstance)
46
+ : muiTableToolbarAlertBannerProps;
47
+
48
+ const selectMessage =
49
+ tableInstance.selectedFlatRows.length > 0
50
+ ? localization?.toolbarAlertSelectionMessage
51
+ ?.replace(
52
+ '{selectedCount}',
53
+ tableInstance.selectedFlatRows.length.toString(),
54
+ )
55
+ ?.replace('{rowCount}', tableInstance.flatRows.length.toString())
56
+ : null;
57
+
58
+ const groupedByMessage =
59
+ tableInstance.state.groupBy.length > 0 ? (
60
+ <span>
61
+ {localization?.toolbarAlertGroupedByMessage}{' '}
62
+ {tableInstance.state.groupBy.map((columnId, index) => (
63
+ <Fragment key={`${index}-${columnId}`}>
64
+ {index > 0 ? localization?.toolbarAlertGroupedThenByMessage : ''}
65
+ <Chip
66
+ color="secondary"
67
+ label={
68
+ tableInstance.allColumns.find(
69
+ (column) => column.id === columnId,
70
+ )?.Header
71
+ }
72
+ onDelete={() => tableInstance.toggleGroupBy(columnId, false)}
73
+ />
74
+ </Fragment>
75
+ ))}
76
+ </span>
77
+ ) : null;
78
+
79
+ const displayAbsolute = !(
80
+ isMobile ||
81
+ (positionToolbarAlertBanner === 'bottom' &&
82
+ positionToolbarActions === 'bottom') ||
83
+ (positionToolbarAlertBanner === 'top' && !!renderToolbarCustomActions)
84
+ );
85
+
86
+ return (
87
+ <Collapse
88
+ in={!!selectMessage || !!groupedByMessage}
89
+ timeout={displayAbsolute ? 0 : 200}
90
+ >
91
+ <Alert
92
+ displayAbsolute={displayAbsolute}
93
+ icon={false}
94
+ color="info"
95
+ {...alertProps}
96
+ >
97
+ {selectMessage}
98
+ {groupedByMessage}
99
+ </Alert>
100
+ </Collapse>
101
+ );
102
+ };
@@ -1,12 +1,15 @@
1
1
  import React, { FC } from 'react';
2
2
  import { styled, Toolbar as MuiToolbar } from '@mui/material';
3
- import { useMaterialReactTable } from '../useMaterialReactTable';
3
+ import { useMRT } from '../useMRT';
4
4
  import { MRT_TablePagination } from './MRT_TablePagination';
5
- import { MRT_ToolbarButtons } from './MRT_ToolbarButtons';
5
+ import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
6
+ import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
6
7
 
7
8
  const Toolbar = styled(MuiToolbar)({
8
9
  display: 'flex',
9
10
  justifyContent: 'space-between',
11
+ padding: '0 0.5rem !important',
12
+ overflowY: 'hidden',
10
13
  });
11
14
 
12
15
  interface Props {}
@@ -18,8 +21,9 @@ export const MRT_ToolbarBottom: FC<Props> = () => {
18
21
  muiTableToolbarBottomProps,
19
22
  positionPagination,
20
23
  positionToolbarActions,
24
+ positionToolbarAlertBanner,
21
25
  tableInstance,
22
- } = useMaterialReactTable();
26
+ } = useMRT();
23
27
 
24
28
  const toolbarProps =
25
29
  muiTableToolbarBottomProps instanceof Function
@@ -27,15 +31,17 @@ export const MRT_ToolbarBottom: FC<Props> = () => {
27
31
  : muiTableToolbarBottomProps;
28
32
 
29
33
  return (
30
- <Toolbar style={{ padding: 0 }} variant="dense" {...toolbarProps}>
34
+ <Toolbar variant="dense" {...toolbarProps}>
31
35
  {!hideToolbarActions && positionToolbarActions === 'bottom' ? (
32
- <MRT_ToolbarButtons />
36
+ <MRT_ToolbarInternalButtons />
33
37
  ) : (
34
38
  <span />
35
39
  )}
36
- {!manualPagination && ['bottom', 'both'].includes(positionPagination ?? '') && (
37
- <MRT_TablePagination />
38
- )}
40
+ {positionToolbarAlertBanner === 'bottom' && <MRT_ToolbarAlertBanner />}
41
+ {!manualPagination &&
42
+ ['bottom', 'both'].includes(positionPagination ?? '') && (
43
+ <MRT_TablePagination />
44
+ )}
39
45
  </Toolbar>
40
46
  );
41
47
  };
@@ -2,9 +2,10 @@ import React, { FC } from 'react';
2
2
  import { styled } from '@mui/material';
3
3
  import { MRT_ToggleFiltersButton } from '../buttons/MRT_ToggleFiltersButton';
4
4
  import { MRT_ShowHideColumnsButton } from '../buttons/MRT_ShowHideColumnsButton';
5
- import { useMaterialReactTable } from '../useMaterialReactTable';
5
+ import { useMRT } from '../useMRT';
6
6
  import { MRT_DensePaddingSwitch } from '../inputs/MRT_DensePaddingSwitch';
7
7
  import { MRT_ToggleSearchButton } from '../buttons/MRT_ToggleSearchButton';
8
+ import { MRT_FullScreenToggleButton } from '../buttons/MRT_FullScreenToggleButton';
8
9
 
9
10
  const ToolbarButtonsContainer = styled('div')({
10
11
  display: 'flex',
@@ -14,9 +15,14 @@ const ToolbarButtonsContainer = styled('div')({
14
15
 
15
16
  interface Props {}
16
17
 
17
- export const MRT_ToolbarButtons: FC<Props> = () => {
18
- const { disableFilters, disableColumnHiding, disableDensePaddingToggle, disableGlobalFilter } =
19
- useMaterialReactTable();
18
+ export const MRT_ToolbarInternalButtons: FC<Props> = () => {
19
+ const {
20
+ disableFilters,
21
+ disableColumnHiding,
22
+ disableDensePaddingToggle,
23
+ disableGlobalFilter,
24
+ disableFullScreenToggle,
25
+ } = useMRT();
20
26
 
21
27
  return (
22
28
  <ToolbarButtonsContainer>
@@ -24,6 +30,7 @@ export const MRT_ToolbarButtons: FC<Props> = () => {
24
30
  {!disableFilters && <MRT_ToggleFiltersButton />}
25
31
  {!disableColumnHiding && <MRT_ShowHideColumnsButton />}
26
32
  {!disableDensePaddingToggle && <MRT_DensePaddingSwitch />}
33
+ {!disableFullScreenToggle && <MRT_FullScreenToggleButton />}
27
34
  </ToolbarButtonsContainer>
28
35
  );
29
36
  };
@@ -1,17 +1,18 @@
1
1
  import React, { FC } from 'react';
2
2
  import { styled, Toolbar as MuiToolbar } from '@mui/material';
3
3
  import { MRT_SearchTextField } from '../inputs/MRT_SearchTextField';
4
- import { useMaterialReactTable } from '../useMaterialReactTable';
5
- import { MRT_ToolbarButtons } from './MRT_ToolbarButtons';
4
+ import { useMRT } from '../useMRT';
5
+ import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
6
6
  import { MRT_TablePagination } from './MRT_TablePagination';
7
+ import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
7
8
 
8
9
  const Toolbar = styled(MuiToolbar)({
9
10
  display: 'grid',
10
- padding: '0.5rem !important',
11
+ padding: '0 0.5rem !important',
11
12
  });
12
13
 
13
14
  const ToolbarTopRow = styled('div')({
14
- padding: '0.5rem',
15
+ padding: '1rem 0.5rem',
15
16
  display: 'flex',
16
17
  justifyContent: 'space-between',
17
18
  });
@@ -19,6 +20,8 @@ const ToolbarTopRow = styled('div')({
19
20
  const ToolbarActionsContainer = styled('div')({
20
21
  display: 'flex',
21
22
  gap: '0.5rem',
23
+ position: 'relative',
24
+ zIndex: 3,
22
25
  });
23
26
 
24
27
  interface Props {}
@@ -31,9 +34,10 @@ export const MRT_ToolbarTop: FC<Props> = () => {
31
34
  muiTableToolbarTopProps,
32
35
  positionPagination,
33
36
  positionToolbarActions,
34
- renderToolbarActions,
37
+ positionToolbarAlertBanner,
38
+ renderToolbarCustomActions,
35
39
  tableInstance,
36
- } = useMaterialReactTable();
40
+ } = useMRT();
37
41
 
38
42
  const toolbarProps =
39
43
  muiTableToolbarTopProps instanceof Function
@@ -42,17 +46,21 @@ export const MRT_ToolbarTop: FC<Props> = () => {
42
46
 
43
47
  return (
44
48
  <Toolbar variant="dense" {...toolbarProps}>
49
+ {positionToolbarAlertBanner === 'top' && <MRT_ToolbarAlertBanner />}
45
50
  <ToolbarTopRow>
46
- {renderToolbarActions?.(tableInstance) ?? <span />}
51
+ {renderToolbarCustomActions?.(tableInstance) ?? <span />}
47
52
  <ToolbarActionsContainer>
48
53
  {!disableGlobalFilter && <MRT_SearchTextField />}
49
- {!hideToolbarActions && positionToolbarActions === 'top' && <MRT_ToolbarButtons />}
54
+ {!hideToolbarActions && positionToolbarActions === 'top' && (
55
+ <MRT_ToolbarInternalButtons />
56
+ )}
50
57
  </ToolbarActionsContainer>
51
58
  </ToolbarTopRow>
52
59
  <div>
53
- {!manualPagination && ['top', 'both'].includes(positionPagination ?? '') && (
54
- <MRT_TablePagination />
55
- )}
60
+ {!manualPagination &&
61
+ ['top', 'both'].includes(positionPagination ?? '') && (
62
+ <MRT_TablePagination />
63
+ )}
56
64
  </div>
57
65
  </Toolbar>
58
66
  );