material-react-table 0.13.3 → 0.14.0

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.
@@ -2,6 +2,7 @@ import { FC } from 'react';
2
2
  import { MRT_TableInstance } from '..';
3
3
  interface Props {
4
4
  instance: MRT_TableInstance;
5
+ position: 'top' | 'bottom';
5
6
  }
6
7
  export declare const MRT_TablePagination: FC<Props>;
7
8
  export {};
@@ -11,7 +11,6 @@ export declare const commonToolbarStyles: ({ theme }: {
11
11
  overflow: string;
12
12
  p: string;
13
13
  transition: string;
14
- width: string;
15
14
  zIndex: number;
16
15
  };
17
16
  interface Props {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.13.3",
2
+ "version": "0.14.0",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
@@ -762,7 +762,6 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
762
762
  positionActionsColumn?: 'first' | 'last';
763
763
  positionGlobalFilter?: 'left' | 'right';
764
764
  positionPagination?: 'bottom' | 'top' | 'both';
765
- positionToolbarActions?: 'bottom' | 'top';
766
765
  positionToolbarAlertBanner?: 'bottom' | 'top';
767
766
  renderDetailPanel?: ({
768
767
  row,
@@ -787,7 +786,12 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
787
786
  row: MRT_Row<D>;
788
787
  instance: MRT_TableInstance<D>;
789
788
  }) => ReactNode;
790
- renderToolbarCustomActions?: ({
789
+ renderToolbarBottomCustomActions?: ({
790
+ instance,
791
+ }: {
792
+ instance: MRT_TableInstance<D>;
793
+ }) => ReactNode;
794
+ renderToolbarTopCustomActions?: ({
791
795
  instance,
792
796
  }: {
793
797
  instance: MRT_TableInstance<D>;
@@ -857,7 +861,6 @@ export default <D extends Record<string, any> = {}>({
857
861
  positionActionsColumn = 'first',
858
862
  positionGlobalFilter = 'right',
859
863
  positionPagination = 'bottom',
860
- positionToolbarActions = 'top',
861
864
  positionToolbarAlertBanner = 'top',
862
865
  rowNumberMode = 'original',
863
866
  selectAllMode = 'all',
@@ -897,7 +900,6 @@ export default <D extends Record<string, any> = {}>({
897
900
  positionActionsColumn={positionActionsColumn}
898
901
  positionGlobalFilter={positionGlobalFilter}
899
902
  positionPagination={positionPagination}
900
- positionToolbarActions={positionToolbarActions}
901
903
  positionToolbarAlertBanner={positionToolbarAlertBanner}
902
904
  rowNumberMode={rowNumberMode}
903
905
  selectAllMode={selectAllMode}
@@ -79,16 +79,14 @@ export const MRT_SearchTextField: FC<Props> = ({ instance }) => {
79
79
  startAdornment: (
80
80
  <InputAdornment position="start">
81
81
  <Tooltip arrow title={localization.changeSearchMode}>
82
- <span>
83
- <IconButton
84
- aria-label={localization.changeSearchMode}
85
- onClick={handleGlobalFilterMenuOpen}
86
- size="small"
87
- sx={{ height: '1.75rem', width: '1.75rem' }}
88
- >
89
- <SearchIcon />
90
- </IconButton>
91
- </span>
82
+ <IconButton
83
+ aria-label={localization.changeSearchMode}
84
+ onClick={handleGlobalFilterMenuOpen}
85
+ size="small"
86
+ sx={{ height: '1.75rem', width: '1.75rem' }}
87
+ >
88
+ <SearchIcon />
89
+ </IconButton>
92
90
  </Tooltip>
93
91
  </InputAdornment>
94
92
  ),
@@ -107,7 +105,6 @@ export const MRT_SearchTextField: FC<Props> = ({ instance }) => {
107
105
  ),
108
106
  }}
109
107
  {...textFieldProps}
110
- sx={{ justifySelf: 'end', ...textFieldProps?.sx }}
111
108
  />
112
109
  <MRT_FilterOptionMenu
113
110
  anchorEl={anchorEl}
@@ -4,19 +4,21 @@ import { MRT_TableInstance } from '..';
4
4
 
5
5
  interface Props {
6
6
  instance: MRT_TableInstance;
7
+ position: 'top' | 'bottom';
7
8
  }
8
9
 
9
- export const MRT_TablePagination: FC<Props> = ({ instance }) => {
10
+ export const MRT_TablePagination: FC<Props> = ({ instance, position }) => {
10
11
  const {
11
12
  getPrePaginationRowModel,
12
13
  getState,
13
14
  setPageIndex,
14
15
  setPageSize,
15
- options: { muiTablePaginationProps },
16
+ options: { muiTablePaginationProps, enableToolbarInternalActions },
16
17
  } = instance;
17
18
 
18
19
  const {
19
20
  pagination: { pageSize = 10, pageIndex = 0 },
21
+ showGlobalFilter,
20
22
  } = getState();
21
23
 
22
24
  const tablePaginationProps =
@@ -49,6 +51,12 @@ export const MRT_TablePagination: FC<Props> = ({ instance }) => {
49
51
  {...tablePaginationProps}
50
52
  sx={{
51
53
  m: '0 0.5rem',
54
+ mt:
55
+ position === 'top' &&
56
+ enableToolbarInternalActions &&
57
+ !showGlobalFilter
58
+ ? '3.5rem'
59
+ : undefined,
52
60
  position: 'relative',
53
61
  zIndex: 2,
54
62
  ...tablePaginationProps?.sx,
@@ -1,7 +1,6 @@
1
1
  import React, { FC } from 'react';
2
2
  import { alpha, Box, Toolbar, useMediaQuery } from '@mui/material';
3
3
  import { MRT_TablePagination } from './MRT_TablePagination';
4
- import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
5
4
  import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
6
5
  import { MRT_LinearProgressBar } from './MRT_LinearProgressBar';
7
6
  import { commonToolbarStyles } from './MRT_ToolbarTop';
@@ -15,14 +14,12 @@ export const MRT_ToolbarBottom: FC<Props> = ({ instance }) => {
15
14
  const {
16
15
  getState,
17
16
  options: {
18
- enableToolbarInternalActions,
19
- tableId,
20
17
  enablePagination,
21
18
  muiTableToolbarBottomProps,
22
19
  positionPagination,
23
- positionToolbarActions,
24
20
  positionToolbarAlertBanner,
25
- renderToolbarCustomActions,
21
+ renderToolbarBottomCustomActions,
22
+ tableId,
26
23
  },
27
24
  } = instance;
28
25
 
@@ -38,10 +35,7 @@ export const MRT_ToolbarBottom: FC<Props> = ({ instance }) => {
38
35
  const stackAlertBanner =
39
36
  isMobile ||
40
37
  (positionToolbarAlertBanner === 'bottom' &&
41
- positionToolbarActions === 'bottom') ||
42
- (positionToolbarAlertBanner === 'bottom' &&
43
- !!renderToolbarCustomActions &&
44
- positionToolbarActions === 'bottom');
38
+ !!renderToolbarBottomCustomActions);
45
39
 
46
40
  return (
47
41
  <Toolbar
@@ -67,20 +61,29 @@ export const MRT_ToolbarBottom: FC<Props> = ({ instance }) => {
67
61
  display: 'flex',
68
62
  justifyContent: 'space-between',
69
63
  width: '100%',
70
- position: stackAlertBanner ? 'relative' : 'absolute',
71
- right: 0,
72
- top: 0,
73
64
  }}
74
65
  >
75
- {enableToolbarInternalActions && positionToolbarActions === 'bottom' ? (
76
- <MRT_ToolbarInternalButtons instance={instance} />
66
+ {renderToolbarBottomCustomActions ? (
67
+ <Box sx={{ p: '0.5rem' }}>
68
+ {renderToolbarBottomCustomActions({ instance })}
69
+ </Box>
77
70
  ) : (
78
71
  <span />
79
72
  )}
80
- {enablePagination &&
81
- ['bottom', 'both'].includes(positionPagination ?? '') && (
82
- <MRT_TablePagination instance={instance} />
83
- )}
73
+ <Box
74
+ sx={{
75
+ display: 'flex',
76
+ justifyContent: 'flex-end',
77
+ position: stackAlertBanner ? 'relative' : 'absolute',
78
+ right: 0,
79
+ top: 0,
80
+ }}
81
+ >
82
+ {enablePagination &&
83
+ ['bottom', 'both'].includes(positionPagination ?? '') && (
84
+ <MRT_TablePagination instance={instance} position="bottom" />
85
+ )}
86
+ </Box>
84
87
  </Box>
85
88
  </Toolbar>
86
89
  );
@@ -29,8 +29,8 @@ export const MRT_ToolbarInternalButtons: FC<Props> = ({ instance }) => {
29
29
  return (
30
30
  <Box
31
31
  sx={{
32
- display: 'flex',
33
32
  alignItems: 'center',
33
+ display: 'flex',
34
34
  zIndex: 3,
35
35
  }}
36
36
  >
@@ -15,7 +15,6 @@ export const commonToolbarStyles = ({ theme }: { theme: Theme }) => ({
15
15
  overflow: 'hidden',
16
16
  p: '0 !important',
17
17
  transition: 'all 0.2s ease-in-out',
18
- width: '100%',
19
18
  zIndex: 1,
20
19
  });
21
20
 
@@ -30,13 +29,12 @@ export const MRT_ToolbarTop: FC<Props> = ({ instance }) => {
30
29
  enableGlobalFilter,
31
30
  enablePagination,
32
31
  enableToolbarInternalActions,
33
- tableId,
34
32
  muiTableToolbarTopProps,
35
- positionPagination,
36
33
  positionGlobalFilter,
37
- positionToolbarActions,
34
+ positionPagination,
38
35
  positionToolbarAlertBanner,
39
- renderToolbarCustomActions,
36
+ renderToolbarTopCustomActions,
37
+ tableId,
40
38
  },
41
39
  } = instance;
42
40
 
@@ -52,7 +50,7 @@ export const MRT_ToolbarTop: FC<Props> = ({ instance }) => {
52
50
  const stackAlertBanner =
53
51
  isMobile ||
54
52
  (positionToolbarAlertBanner === 'top' &&
55
- (!!renderToolbarCustomActions || showGlobalFilter));
53
+ (!!renderToolbarTopCustomActions || showGlobalFilter));
56
54
 
57
55
  return (
58
56
  <Toolbar
@@ -77,29 +75,34 @@ export const MRT_ToolbarTop: FC<Props> = ({ instance }) => {
77
75
  <Box
78
76
  sx={{
79
77
  alignItems: 'flex-start',
78
+ boxSizing: 'border-box',
80
79
  display: 'flex',
81
80
  justifyContent: 'space-between',
82
81
  p: '0.5rem',
83
82
  position: stackAlertBanner ? 'relative' : 'absolute',
84
83
  right: 0,
85
84
  top: 0,
86
- width: renderToolbarCustomActions ? '100%' : undefined,
85
+ width: '100%',
87
86
  }}
88
87
  >
89
88
  {enableGlobalFilter && positionGlobalFilter === 'left' && (
90
89
  <MRT_SearchTextField instance={instance} />
91
90
  )}
92
- {renderToolbarCustomActions?.({ instance }) ?? <span />}
93
- {enableToolbarInternalActions && positionToolbarActions === 'top' && (
91
+
92
+ {renderToolbarTopCustomActions?.({ instance }) ?? <span />}
93
+ {enableToolbarInternalActions ? (
94
94
  <MRT_ToolbarInternalButtons instance={instance} />
95
+ ) : (
96
+ enableGlobalFilter &&
97
+ positionGlobalFilter === 'right' && (
98
+ <MRT_SearchTextField instance={instance} />
99
+ )
95
100
  )}
96
101
  </Box>
97
- <div>
98
- {enablePagination &&
99
- ['top', 'both'].includes(positionPagination ?? '') && (
100
- <MRT_TablePagination instance={instance} />
101
- )}
102
- </div>
102
+ {enablePagination &&
103
+ ['top', 'both'].includes(positionPagination ?? '') && (
104
+ <MRT_TablePagination instance={instance} position="top" />
105
+ )}
103
106
  <MRT_LinearProgressBar alignTo="bottom" instance={instance} />
104
107
  </Toolbar>
105
108
  );