material-react-table 0.1.0-beta.1 → 0.3.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 (96) hide show
  1. package/dist/MaterialReactTable.d.ts +60 -26
  2. package/dist/{MRT_TableBody.d.ts → body/MRT_TableBody.d.ts} +0 -0
  3. package/dist/{MRT_TableBodyCell.d.ts → body/MRT_TableBodyCell.d.ts} +1 -1
  4. package/dist/{MRT_TableBodyRow.d.ts → body/MRT_TableBodyRow.d.ts} +1 -1
  5. package/dist/{MRT_TableDetailPanel.d.ts → body/MRT_TableDetailPanel.d.ts} +1 -1
  6. package/dist/{MRT_TableExpandButton.d.ts → buttons/MRT_EditActionButtons.d.ts} +2 -2
  7. package/dist/buttons/MRT_ExpandAllButton.d.ts +5 -0
  8. package/dist/buttons/MRT_ExpandButton.d.ts +7 -0
  9. package/dist/buttons/MRT_ShowHideColumnsButton.d.ts +5 -0
  10. package/dist/buttons/MRT_ToggleColumnActionMenuButton.d.ts +7 -0
  11. package/dist/buttons/MRT_ToggleFiltersButton.d.ts +4 -0
  12. package/dist/buttons/MRT_ToggleRowActionMenuButton.d.ts +7 -0
  13. package/dist/{MRT_TableFooter.d.ts → footer/MRT_TableFooter.d.ts} +0 -0
  14. package/dist/{MRT_TableFooterCell.d.ts → footer/MRT_TableFooterCell.d.ts} +0 -0
  15. package/dist/{MRT_TableFooterRow.d.ts → footer/MRT_TableFooterRow.d.ts} +1 -1
  16. package/dist/{MRT_TableHead.d.ts → head/MRT_TableHead.d.ts} +0 -0
  17. package/dist/head/MRT_TableHeadCell.d.ts +8 -0
  18. package/dist/{MRT_TableHeadRow.d.ts → head/MRT_TableHeadRow.d.ts} +1 -1
  19. package/dist/index.d.ts +2 -0
  20. package/dist/inputs/MRT_DensePaddingSwitch.d.ts +5 -0
  21. package/dist/{MRT_TableHeadCell.d.ts → inputs/MRT_FilterTextField.d.ts} +1 -1
  22. package/dist/inputs/MRT_SearchTextField.d.ts +5 -0
  23. package/dist/inputs/MRT_SelectAllCheckbox.d.ts +2 -0
  24. package/dist/inputs/MRT_SelectCheckbox.d.ts +7 -0
  25. package/dist/material-react-table.cjs.development.js +1933 -170
  26. package/dist/material-react-table.cjs.development.js.map +1 -1
  27. package/dist/material-react-table.cjs.production.min.js +1 -1
  28. package/dist/material-react-table.cjs.production.min.js.map +1 -1
  29. package/dist/material-react-table.esm.js +1939 -176
  30. package/dist/material-react-table.esm.js.map +1 -1
  31. package/dist/menus/MRT_ColumnActionMenu.d.ts +9 -0
  32. package/dist/menus/MRT_RowActionMenu.d.ts +9 -0
  33. package/dist/menus/MRT_ShowHideColumnsMenu.d.ts +7 -0
  34. package/dist/{MRT_Table.d.ts → table/MRT_Table.d.ts} +0 -0
  35. package/dist/{MRT_TableContainer.d.ts → table/MRT_TableContainer.d.ts} +0 -0
  36. package/dist/table/MRT_TableSpacerCell.d.ts +6 -0
  37. package/dist/{MRT_TablePagination.d.ts → toolbar/MRT_TablePagination.d.ts} +0 -0
  38. package/dist/toolbar/MRT_ToolbarBottom.d.ts +5 -0
  39. package/dist/toolbar/MRT_ToolbarButtons.d.ts +5 -0
  40. package/dist/toolbar/MRT_ToolbarTop.d.ts +5 -0
  41. package/dist/useMaterialReactTable.d.ts +13 -11
  42. package/dist/utils/localization.d.ts +25 -0
  43. package/dist/utils/useMRTCalcs.d.ts +11 -0
  44. package/package.json +21 -17
  45. package/src/MaterialReactTable.tsx +145 -37
  46. package/src/body/MRT_TableBody.tsx +56 -0
  47. package/src/body/MRT_TableBodyCell.tsx +48 -0
  48. package/src/body/MRT_TableBodyRow.tsx +74 -0
  49. package/src/body/MRT_TableDetailPanel.tsx +62 -0
  50. package/src/buttons/MRT_EditActionButtons.tsx +51 -0
  51. package/src/buttons/MRT_ExpandAllButton.tsx +45 -0
  52. package/src/buttons/MRT_ExpandButton.tsx +48 -0
  53. package/src/buttons/MRT_ShowHideColumnsButton.tsx +43 -0
  54. package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +51 -0
  55. package/src/buttons/MRT_ToggleFiltersButton.tsx +23 -0
  56. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +65 -0
  57. package/src/footer/MRT_TableFooter.tsx +21 -0
  58. package/src/footer/MRT_TableFooterCell.tsx +44 -0
  59. package/src/footer/MRT_TableFooterRow.tsx +62 -0
  60. package/src/{MRT_TableHead.tsx → head/MRT_TableHead.tsx} +7 -6
  61. package/src/head/MRT_TableHeadCell.tsx +120 -0
  62. package/src/head/MRT_TableHeadRow.tsx +89 -0
  63. package/src/index.tsx +2 -0
  64. package/src/inputs/MRT_DensePaddingSwitch.tsx +21 -0
  65. package/src/inputs/MRT_FilterTextField.tsx +64 -0
  66. package/src/inputs/MRT_SearchTextField.tsx +74 -0
  67. package/src/inputs/MRT_SelectAllCheckbox.tsx +26 -0
  68. package/src/inputs/MRT_SelectCheckbox.tsx +33 -0
  69. package/src/menus/MRT_ColumnActionMenu.tsx +107 -0
  70. package/src/menus/MRT_RowActionMenu.tsx +52 -0
  71. package/src/menus/MRT_ShowHideColumnsMenu.tsx +34 -0
  72. package/src/table/MRT_Table.tsx +30 -0
  73. package/src/table/MRT_TableContainer.tsx +22 -0
  74. package/src/table/MRT_TableSpacerCell.tsx +26 -0
  75. package/src/toolbar/MRT_TablePagination.tsx +37 -0
  76. package/src/toolbar/MRT_ToolbarBottom.tsx +58 -0
  77. package/src/toolbar/MRT_ToolbarButtons.tsx +27 -0
  78. package/src/toolbar/MRT_ToolbarTop.tsx +81 -0
  79. package/src/useMaterialReactTable.tsx +71 -32
  80. package/src/utils/localization.ts +49 -0
  81. package/src/utils/useMRTCalcs.tsx +42 -0
  82. package/dist/defaults.d.ts +0 -2
  83. package/src/MRT_Table.tsx +0 -20
  84. package/src/MRT_TableBody.tsx +0 -19
  85. package/src/MRT_TableBodyCell.tsx +0 -15
  86. package/src/MRT_TableBodyRow.tsx +0 -27
  87. package/src/MRT_TableContainer.tsx +0 -16
  88. package/src/MRT_TableDetailPanel.tsx +0 -27
  89. package/src/MRT_TableExpandButton.tsx +0 -25
  90. package/src/MRT_TableFooter.tsx +0 -31
  91. package/src/MRT_TableFooterCell.tsx +0 -25
  92. package/src/MRT_TableFooterRow.tsx +0 -22
  93. package/src/MRT_TableHeadCell.tsx +0 -27
  94. package/src/MRT_TableHeadRow.tsx +0 -22
  95. package/src/MRT_TablePagination.tsx +0 -34
  96. package/src/defaults.ts +0 -11
@@ -0,0 +1,74 @@
1
+ import React, { ChangeEvent, FC, useState } from 'react';
2
+ import {
3
+ IconButton,
4
+ InputAdornment,
5
+ styled,
6
+ TextField as MuiTextField,
7
+ } from '@mui/material';
8
+ import SearchIcon from '@mui/icons-material/Search';
9
+ import CloseIcon from '@mui/icons-material/Close';
10
+ import { useMaterialReactTable } from '../useMaterialReactTable';
11
+ import { useAsyncDebounce } from 'react-table';
12
+
13
+ const TextField = styled(MuiTextField)({
14
+ justifySelf: 'end',
15
+ });
16
+
17
+ interface Props {}
18
+
19
+ export const MRT_SearchTextField: FC<Props> = () => {
20
+ const {
21
+ tableInstance,
22
+ muiSearchTextFieldProps,
23
+ localization,
24
+ onGlobalFilterChange,
25
+ } = useMaterialReactTable();
26
+
27
+ const [searchValue, setSearchValue] = useState('');
28
+
29
+ const handleChange = useAsyncDebounce(
30
+ (event: ChangeEvent<HTMLInputElement>) => {
31
+ tableInstance.setGlobalFilter(event.target.value ?? undefined);
32
+ onGlobalFilterChange?.(event);
33
+ },
34
+ 200,
35
+ );
36
+
37
+ const handleClear = () => {
38
+ setSearchValue('');
39
+ tableInstance.setGlobalFilter(undefined);
40
+ };
41
+
42
+ return (
43
+ <TextField
44
+ placeholder={localization?.searchTextFieldPlaceholder}
45
+ onChange={(event: ChangeEvent<HTMLInputElement>) => {
46
+ setSearchValue(event.target.value);
47
+ handleChange(event);
48
+ }}
49
+ value={searchValue ?? ''}
50
+ variant="standard"
51
+ InputProps={{
52
+ startAdornment: (
53
+ <InputAdornment position="start">
54
+ <SearchIcon fontSize="small" />
55
+ </InputAdornment>
56
+ ),
57
+ endAdornment: (
58
+ <InputAdornment position="end">
59
+ <IconButton
60
+ aria-label={localization?.searchTextFieldClearButtonTitle}
61
+ disabled={searchValue?.length === 0}
62
+ onClick={handleClear}
63
+ size="small"
64
+ title={localization?.searchTextFieldClearButtonTitle}
65
+ >
66
+ <CloseIcon fontSize="small" />
67
+ </IconButton>
68
+ </InputAdornment>
69
+ ),
70
+ }}
71
+ {...muiSearchTextFieldProps}
72
+ />
73
+ );
74
+ };
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { Checkbox, TableCell } from '@mui/material';
3
+ import { useMaterialReactTable } from '../useMaterialReactTable';
4
+
5
+ export const MRT_SelectAllCheckbox = () => {
6
+ const { tableInstance, disableSelectAll, densePadding } =
7
+ useMaterialReactTable();
8
+
9
+ return (
10
+ <TableCell
11
+ style={{
12
+ width: '2rem',
13
+ padding: densePadding ? '0' : '0.6rem',
14
+ transition: 'all 0.2s ease-in-out',
15
+ }}
16
+ variant="head"
17
+ >
18
+ {!disableSelectAll ? (
19
+ <Checkbox
20
+ aria-label=""
21
+ {...tableInstance.getToggleAllPageRowsSelectedProps()}
22
+ />
23
+ ) : null}
24
+ </TableCell>
25
+ );
26
+ };
@@ -0,0 +1,33 @@
1
+ import React, { ChangeEvent, FC } from 'react';
2
+ import { Checkbox, TableCell } from '@mui/material';
3
+ import { Row } from 'react-table';
4
+ import { useMaterialReactTable } from '../useMaterialReactTable';
5
+
6
+ interface Props {
7
+ row: Row;
8
+ }
9
+
10
+ export const MRT_SelectCheckbox: FC<Props> = ({ row }) => {
11
+ const { tableInstance, onRowSelectChange, densePadding } =
12
+ useMaterialReactTable();
13
+
14
+ const onSelectChange = (event: ChangeEvent) => {
15
+ row.getToggleRowSelectedProps()?.onChange?.(event);
16
+ onRowSelectChange?.(event, row, tableInstance.selectedFlatRows);
17
+ };
18
+
19
+ return (
20
+ <TableCell
21
+ style={{
22
+ width: '2rem',
23
+ padding: densePadding ? '0' : '0.6rem',
24
+ transition: 'all 0.2s ease-in-out',
25
+ }}
26
+ >
27
+ <Checkbox
28
+ {...row.getToggleRowSelectedProps()}
29
+ onChange={onSelectChange}
30
+ />
31
+ </TableCell>
32
+ );
33
+ };
@@ -0,0 +1,107 @@
1
+ import React, { FC } from 'react';
2
+ import { Divider, Menu, MenuItem as MuiMenuItem, styled } from '@mui/material';
3
+ import { useMaterialReactTable } from '../useMaterialReactTable';
4
+ import { ColumnInstance } 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
+
10
+ const MenuItem = styled(MuiMenuItem)({
11
+ display: 'flex',
12
+ gap: '0.75rem',
13
+ });
14
+
15
+ interface Props {
16
+ anchorEl: HTMLElement | null;
17
+ column: ColumnInstance;
18
+ setAnchorEl: (anchorEl: HTMLElement | null) => void;
19
+ }
20
+
21
+ export const MRT_ColumnActionMenu: FC<Props> = ({
22
+ anchorEl,
23
+ column,
24
+ setAnchorEl,
25
+ }) => {
26
+ const {
27
+ disableColumnHiding,
28
+ enableColumnGrouping,
29
+ disableSortBy,
30
+ localization,
31
+ } = useMaterialReactTable();
32
+
33
+ const handleClearSort = () => {
34
+ column.clearSortBy();
35
+ setAnchorEl(null);
36
+ };
37
+
38
+ const handleSortAsc = () => {
39
+ column.toggleSortBy(false);
40
+ setAnchorEl(null);
41
+ };
42
+
43
+ const handleSortDesc = () => {
44
+ column.toggleSortBy(true);
45
+ setAnchorEl(null);
46
+ };
47
+
48
+ const handleHideColumn = () => {
49
+ column.toggleHidden();
50
+ setAnchorEl(null);
51
+ };
52
+
53
+ const handleGroupByColumn = () => {
54
+ column.toggleGroupBy();
55
+ setAnchorEl(null);
56
+ };
57
+
58
+ return (
59
+ <Menu
60
+ anchorEl={anchorEl}
61
+ open={!!anchorEl}
62
+ onClose={() => setAnchorEl(null)}
63
+ >
64
+ {!disableSortBy &&
65
+ column.canSort && [
66
+ <MenuItem
67
+ key={1}
68
+ disabled={!column.isSorted}
69
+ onClick={handleClearSort}
70
+ >
71
+ <ClearAllIcon /> {localization?.columnActionMenuItemClearSort}
72
+ </MenuItem>,
73
+ <MenuItem
74
+ key={2}
75
+ disabled={column.isSorted && !column.isSortedDesc}
76
+ onClick={handleSortAsc}
77
+ >
78
+ <SortIcon /> {localization?.columnActionMenuItemSortAsc}
79
+ </MenuItem>,
80
+ <MenuItem
81
+ key={3}
82
+ disabled={column.isSorted && column.isSortedDesc}
83
+ onClick={handleSortDesc}
84
+ >
85
+ <SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />{' '}
86
+ {localization?.columnActionMenuItemSortDesc}
87
+ </MenuItem>,
88
+ <Divider key={4} />,
89
+ ]}
90
+ {!disableColumnHiding && (
91
+ <MenuItem onClick={handleHideColumn}>
92
+ <VisibilityOffIcon /> {localization?.columnActionMenuItemHideColumn}
93
+ </MenuItem>
94
+ )}
95
+ {enableColumnGrouping && column.canGroupBy && (
96
+ <MenuItem disabled={column.isGrouped} onClick={handleGroupByColumn}>
97
+ <DynamicFeedIcon /> {localization?.columnActionMenuItemGroupBy}
98
+ </MenuItem>
99
+ )}
100
+ {enableColumnGrouping && column.canGroupBy && (
101
+ <MenuItem disabled={!column.isGrouped} onClick={handleGroupByColumn}>
102
+ <DynamicFeedIcon /> {localization?.columnActionMenuItemUnGroupBy}
103
+ </MenuItem>
104
+ )}
105
+ </Menu>
106
+ );
107
+ };
@@ -0,0 +1,52 @@
1
+ import React, { FC } from 'react';
2
+ import { Menu, MenuItem as MuiMenuItem, styled } from '@mui/material';
3
+ import { useMaterialReactTable } from '../useMaterialReactTable';
4
+ import { Row } from 'react-table';
5
+ import EditIcon from '@mui/icons-material/Edit';
6
+
7
+ const MenuItem = styled(MuiMenuItem)({
8
+ display: 'flex',
9
+ gap: '0.75rem',
10
+ });
11
+
12
+ interface Props {
13
+ anchorEl: HTMLElement | null;
14
+ row: Row;
15
+ setAnchorEl: (anchorEl: HTMLElement | null) => void;
16
+ }
17
+
18
+ export const MRT_RowActionMenu: FC<Props> = ({
19
+ anchorEl,
20
+ row,
21
+ setAnchorEl,
22
+ }) => {
23
+ const {
24
+ enableRowEditing,
25
+ localization,
26
+ renderRowActionMenuItems,
27
+ setCurrentEditingRowId,
28
+ tableInstance,
29
+ } = useMaterialReactTable();
30
+
31
+ const handleEdit = () => {
32
+ setCurrentEditingRowId(row.id);
33
+ setAnchorEl(null);
34
+ };
35
+
36
+ return (
37
+ <Menu
38
+ anchorEl={anchorEl}
39
+ open={!!anchorEl}
40
+ onClose={() => setAnchorEl(null)}
41
+ >
42
+ {enableRowEditing && (
43
+ <MenuItem onClick={handleEdit}>
44
+ <EditIcon /> {localization?.rowActionMenuItemEdit}
45
+ </MenuItem>
46
+ )}
47
+ {renderRowActionMenuItems?.(row, tableInstance, () =>
48
+ setAnchorEl(null),
49
+ ) ?? null}
50
+ </Menu>
51
+ );
52
+ };
@@ -0,0 +1,34 @@
1
+ import React, { FC } from 'react';
2
+ import { FormControlLabel, MenuItem, Switch, Typography } from '@mui/material';
3
+ import { useMaterialReactTable } from '../useMaterialReactTable';
4
+ import { ColumnInstance } from 'react-table';
5
+
6
+ interface Props {
7
+ column: ColumnInstance;
8
+ }
9
+
10
+ export const MRT_ShowHideColumnsMenu: FC<Props> = ({ column }) => {
11
+ const { maxColumnDepth } = useMaterialReactTable();
12
+
13
+ const isMaxDepth = column.depth === maxColumnDepth;
14
+
15
+ return (
16
+ <>
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
+ )}
28
+ </MenuItem>
29
+ {column.columns?.map((c, i) => (
30
+ <MRT_ShowHideColumnsMenu key={`${i}-${c.id}`} column={c} />
31
+ ))}
32
+ </>
33
+ );
34
+ };
@@ -0,0 +1,30 @@
1
+ import React, { FC } from 'react';
2
+ import { Table } from '@mui/material';
3
+ import { MRT_TableHead } from '../head/MRT_TableHead';
4
+ import { MRT_TableBody } from '../body/MRT_TableBody';
5
+ import { MRT_TableFooter } from '../footer/MRT_TableFooter';
6
+ import { useMaterialReactTable } from '../useMaterialReactTable';
7
+
8
+ interface Props {}
9
+
10
+ export const MRT_Table: FC<Props> = () => {
11
+ const { tableInstance, muiTableProps, hideTableHead, hideTableFooter } =
12
+ useMaterialReactTable();
13
+
14
+ const tableProps = {
15
+ ...muiTableProps,
16
+ ...tableInstance.getTableProps(),
17
+ style: {
18
+ ...tableInstance.getTableProps().style,
19
+ ...(muiTableProps?.style ?? {}),
20
+ },
21
+ };
22
+
23
+ return (
24
+ <Table {...tableProps}>
25
+ {!hideTableHead && <MRT_TableHead />}
26
+ <MRT_TableBody />
27
+ {!hideTableFooter && <MRT_TableFooter />}
28
+ </Table>
29
+ );
30
+ };
@@ -0,0 +1,22 @@
1
+ import React, { FC } from 'react';
2
+ import { LinearProgress, Paper, TableContainer } from '@mui/material';
3
+ import { useMaterialReactTable } from '../useMaterialReactTable';
4
+ import { MRT_Table } from './MRT_Table';
5
+ import { MRT_ToolbarTop } from '../toolbar/MRT_ToolbarTop';
6
+ import { MRT_ToolbarBottom } from '../toolbar/MRT_ToolbarBottom';
7
+
8
+ interface Props {}
9
+
10
+ export const MRT_TableContainer: FC<Props> = () => {
11
+ const { muiTableContainerProps, hideToolbarTop, hideToolbarBottom, isFetching } =
12
+ useMaterialReactTable();
13
+
14
+ return (
15
+ <TableContainer component={Paper} {...muiTableContainerProps}>
16
+ {!hideToolbarTop && <MRT_ToolbarTop />}
17
+ {isFetching && <LinearProgress />}
18
+ <MRT_Table />
19
+ {!hideToolbarBottom && <MRT_ToolbarBottom />}
20
+ </TableContainer>
21
+ );
22
+ };
@@ -0,0 +1,26 @@
1
+ import React, { CSSProperties, FC } from 'react';
2
+ import { TableCell } from '@mui/material';
3
+ import { useMaterialReactTable } from '../useMaterialReactTable';
4
+
5
+ interface Props {
6
+ width?: CSSProperties['width'];
7
+ }
8
+
9
+ export const MRT_TableSpacerCell: FC<Props> = ({ width }) => {
10
+ const { muiTableBodyCellProps } = useMaterialReactTable();
11
+
12
+ const mTableBodyRowProps =
13
+ muiTableBodyCellProps instanceof Function
14
+ ? muiTableBodyCellProps()
15
+ : muiTableBodyCellProps;
16
+
17
+ const tableCellProps = {
18
+ ...mTableBodyRowProps,
19
+ style: {
20
+ width,
21
+ ...(mTableBodyRowProps?.style ?? {}),
22
+ },
23
+ };
24
+
25
+ return <TableCell {...tableCellProps} />;
26
+ };
@@ -0,0 +1,37 @@
1
+ import React, { ChangeEvent, FC } from 'react';
2
+ import { TablePagination } from '@mui/material';
3
+ import { useMaterialReactTable } from '../useMaterialReactTable';
4
+
5
+ interface Props {}
6
+
7
+ export const MRT_TablePagination: FC<Props> = () => {
8
+ const { tableInstance, muiTablePaginationProps } = useMaterialReactTable();
9
+
10
+ const tablePaginationProps =
11
+ muiTablePaginationProps instanceof Function
12
+ ? muiTablePaginationProps(tableInstance)
13
+ : muiTablePaginationProps;
14
+
15
+ const handleChangeRowsPerPage = (event: ChangeEvent<HTMLInputElement>) => {
16
+ tableInstance.setPageSize(+event.target.value);
17
+ tableInstance.gotoPage(0);
18
+ };
19
+
20
+ return (
21
+ <TablePagination
22
+ component={'div'}
23
+ count={tableInstance.rows.length}
24
+ onPageChange={(_, newPage) => tableInstance.gotoPage(newPage)}
25
+ onRowsPerPageChange={handleChangeRowsPerPage}
26
+ page={tableInstance.state.pageIndex}
27
+ rowsPerPage={tableInstance.state.pageSize}
28
+ showFirstButton={
29
+ tableInstance.rows.length / tableInstance.state.pageSize > 2
30
+ }
31
+ showLastButton={
32
+ tableInstance.rows.length / tableInstance.state.pageSize > 2
33
+ }
34
+ {...tablePaginationProps}
35
+ />
36
+ );
37
+ };
@@ -0,0 +1,58 @@
1
+ import React, { FC } from 'react';
2
+ import { styled, Toolbar as MuiToolbar } from '@mui/material';
3
+ import { useMaterialReactTable } from '../useMaterialReactTable';
4
+ import { MRT_TablePagination } from './MRT_TablePagination';
5
+ import { MRT_ToolbarButtons } from './MRT_ToolbarButtons';
6
+
7
+ const Toolbar = styled(MuiToolbar)({
8
+ padding: 0,
9
+ display: 'flex',
10
+ justifyContent: 'space-between',
11
+ });
12
+
13
+ interface Props {}
14
+
15
+ export const MRT_ToolbarBottom: FC<Props> = () => {
16
+ const {
17
+ disableGlobalFilter,
18
+ disableColumnHiding,
19
+ manualPagination,
20
+ positionPagination,
21
+ disableFilters,
22
+ hideToolbarActions,
23
+ positionToolbarActions,
24
+ muiTableToolbarBottomProps,
25
+ title,
26
+ tableInstance,
27
+ } = useMaterialReactTable();
28
+
29
+ // if no features in the toolbar are enabled, don't render anything
30
+ if (
31
+ !muiTableToolbarBottomProps &&
32
+ !title &&
33
+ disableColumnHiding &&
34
+ disableFilters &&
35
+ disableGlobalFilter
36
+ ) {
37
+ return null;
38
+ }
39
+
40
+ const toolbarProps =
41
+ muiTableToolbarBottomProps instanceof Function
42
+ ? muiTableToolbarBottomProps(tableInstance)
43
+ : muiTableToolbarBottomProps;
44
+
45
+ return (
46
+ <Toolbar variant="dense" {...toolbarProps}>
47
+ {!hideToolbarActions && positionToolbarActions === 'bottom' ? (
48
+ <MRT_ToolbarButtons />
49
+ ) : (
50
+ <span />
51
+ )}
52
+ {!manualPagination &&
53
+ ['bottom', 'both'].includes(positionPagination ?? '') && (
54
+ <MRT_TablePagination />
55
+ )}
56
+ </Toolbar>
57
+ );
58
+ };
@@ -0,0 +1,27 @@
1
+ import React, { FC } from 'react';
2
+ import { styled } from '@mui/material';
3
+ import { MRT_ToggleFiltersButton } from '../buttons/MRT_ToggleFiltersButton';
4
+ import { MRT_ShowHideColumnsButton } from '../buttons/MRT_ShowHideColumnsButton';
5
+ import { useMaterialReactTable } from '../useMaterialReactTable';
6
+ import { MRT_DensePaddingSwitch } from '../inputs/MRT_DensePaddingSwitch';
7
+
8
+ const ToolbarButtonsContainer = styled('div')({
9
+ display: 'flex',
10
+ gap: '0.5rem',
11
+ alignItems: 'center',
12
+ });
13
+
14
+ interface Props {}
15
+
16
+ export const MRT_ToolbarButtons: FC<Props> = () => {
17
+ const { disableFilters, disableColumnHiding, disableDensePaddingToggle } =
18
+ useMaterialReactTable();
19
+
20
+ return (
21
+ <ToolbarButtonsContainer>
22
+ {!disableFilters && <MRT_ToggleFiltersButton />}
23
+ {!disableColumnHiding && <MRT_ShowHideColumnsButton />}
24
+ {!disableDensePaddingToggle && <MRT_DensePaddingSwitch />}
25
+ </ToolbarButtonsContainer>
26
+ );
27
+ };
@@ -0,0 +1,81 @@
1
+ import React, { FC } from 'react';
2
+ import { styled, Toolbar as MuiToolbar, Typography } from '@mui/material';
3
+ import { MRT_SearchTextField } from '../inputs/MRT_SearchTextField';
4
+ import { useMaterialReactTable } from '../useMaterialReactTable';
5
+ import { MRT_ToolbarButtons } from './MRT_ToolbarButtons';
6
+ import { MRT_TablePagination } from './MRT_TablePagination';
7
+
8
+ const Toolbar = styled(MuiToolbar)({
9
+ display: 'grid',
10
+ });
11
+
12
+ const ToolbarTopRow = styled('div')({
13
+ padding: '0.5rem',
14
+ display: 'flex',
15
+ justifyContent: 'space-between',
16
+ });
17
+
18
+ const ToolbarActionsContainer = styled('div')({
19
+ display: 'flex',
20
+ gap: '0.5rem',
21
+ });
22
+
23
+ interface Props {}
24
+
25
+ export const MRT_ToolbarTop: FC<Props> = () => {
26
+ const {
27
+ disableGlobalFilter,
28
+ disableColumnHiding,
29
+ muiTableTitleProps,
30
+ disableFilters,
31
+ manualPagination,
32
+ positionPagination,
33
+ muiTableToolbarTopProps,
34
+ hideToolbarActions,
35
+ positionToolbarActions,
36
+ title,
37
+ tableInstance,
38
+ } = useMaterialReactTable();
39
+
40
+ // if no features in the toolbar are enabled, don't render anything
41
+ if (
42
+ !muiTableToolbarTopProps &&
43
+ !title &&
44
+ disableColumnHiding &&
45
+ disableFilters &&
46
+ disableGlobalFilter
47
+ ) {
48
+ return null;
49
+ }
50
+
51
+ const toolbarProps =
52
+ muiTableToolbarTopProps instanceof Function
53
+ ? muiTableToolbarTopProps(tableInstance)
54
+ : muiTableToolbarTopProps;
55
+
56
+ return (
57
+ <Toolbar variant="dense" {...toolbarProps}>
58
+ <ToolbarTopRow>
59
+ {title ? (
60
+ <Typography variant="h5" {...muiTableTitleProps}>
61
+ {title}
62
+ </Typography>
63
+ ) : (
64
+ <span />
65
+ )}
66
+ <ToolbarActionsContainer>
67
+ {!disableGlobalFilter && <MRT_SearchTextField />}
68
+ {!hideToolbarActions && positionToolbarActions === 'top' && (
69
+ <MRT_ToolbarButtons />
70
+ )}
71
+ </ToolbarActionsContainer>
72
+ </ToolbarTopRow>
73
+ <div>
74
+ {!manualPagination &&
75
+ ['top', 'both'].includes(positionPagination ?? '') && (
76
+ <MRT_TablePagination />
77
+ )}
78
+ </div>
79
+ </Toolbar>
80
+ );
81
+ };