material-react-table 0.8.0-alpha.2 → 0.8.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.
- package/README.md +1 -1
- package/dist/MaterialReactTable.d.ts +3 -2
- package/dist/material-react-table.cjs.development.js +177 -168
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +178 -169
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -0
- package/dist/toolbar/MRT_ToolbarTop.d.ts +2 -0
- package/package.json +5 -4
- package/src/MaterialReactTable.tsx +4 -0
- package/src/body/MRT_TableBodyCell.tsx +7 -4
- package/src/buttons/MRT_CopyButton.tsx +2 -1
- package/src/buttons/MRT_ExpandAllButton.tsx +3 -0
- package/src/footer/MRT_TableFooterCell.tsx +1 -0
- package/src/head/MRT_TableHeadCell.tsx +11 -8
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +11 -27
- package/src/toolbar/MRT_ToolbarBottom.tsx +23 -5
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +30 -29
- package/src/toolbar/MRT_ToolbarTop.tsx +21 -20
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.8.0
|
|
2
|
+
"version": "0.8.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
|
-
"description": "A fully featured Material UI implementation of react-table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
|
|
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.",
|
|
6
6
|
"author": "Kevin Vandy",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"react-table",
|
|
9
9
|
"material-ui",
|
|
10
|
-
"material-table"
|
|
10
|
+
"material-table",
|
|
11
|
+
"tanstack table"
|
|
11
12
|
],
|
|
12
13
|
"repository": {
|
|
13
14
|
"type": "git",
|
|
@@ -94,6 +95,6 @@
|
|
|
94
95
|
},
|
|
95
96
|
"dependencies": {
|
|
96
97
|
"@tanstack/match-sorter-utils": "^8.0.0-alpha.83",
|
|
97
|
-
"@tanstack/react-table": "^8.0.0-
|
|
98
|
+
"@tanstack/react-table": "^8.0.0-alpha.89"
|
|
98
99
|
}
|
|
99
100
|
}
|
|
@@ -80,6 +80,7 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
|
|
|
80
80
|
>,
|
|
81
81
|
| 'getAllColumns'
|
|
82
82
|
| 'getAllLeafColumns'
|
|
83
|
+
| 'getColumn'
|
|
83
84
|
| 'getExpandedRowModel'
|
|
84
85
|
| 'getPaginationRowModel'
|
|
85
86
|
| 'getPrePaginationRowModel'
|
|
@@ -90,6 +91,7 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
|
|
|
90
91
|
> & {
|
|
91
92
|
getAllColumns: () => MRT_Column<D>[];
|
|
92
93
|
getAllLeafColumns: () => MRT_Column<D>[];
|
|
94
|
+
getColumn: (columnId: string) => MRT_Column<D>;
|
|
93
95
|
getExpandedRowModel: () => MRT_RowModel<D>;
|
|
94
96
|
getPaginationRowModel: () => MRT_RowModel<D>;
|
|
95
97
|
getPrePaginationRowModel: () => MRT_RowModel<D>;
|
|
@@ -757,6 +759,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
757
759
|
export default <D extends Record<string, any> = {}>({
|
|
758
760
|
autoResetExpanded = false,
|
|
759
761
|
columnResizeMode = 'onEnd',
|
|
762
|
+
defaultColumn = { minSize: 50, maxSize: 1000, size: 150 },
|
|
760
763
|
editingMode = 'row',
|
|
761
764
|
enableColumnActions = true,
|
|
762
765
|
enableColumnFilters = true,
|
|
@@ -790,6 +793,7 @@ export default <D extends Record<string, any> = {}>({
|
|
|
790
793
|
<MRT_TableRoot
|
|
791
794
|
autoResetExpanded={autoResetExpanded}
|
|
792
795
|
columnResizeMode={columnResizeMode}
|
|
796
|
+
defaultColumn={defaultColumn}
|
|
793
797
|
editingMode={editingMode}
|
|
794
798
|
enableColumnActions={enableColumnActions}
|
|
795
799
|
enableColumnFilters={enableColumnFilters}
|
|
@@ -132,8 +132,6 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
132
132
|
column.getIsPinned() === 'left'
|
|
133
133
|
? `${column.getStart('left')}px`
|
|
134
134
|
: undefined,
|
|
135
|
-
maxWidth: `min(${column.getSize()}px, fit-content)`,
|
|
136
|
-
minWidth: `max${column.getSize()}px, ${column.minSize}px`,
|
|
137
135
|
p: isDensePadding
|
|
138
136
|
? column.columnDefType === 'display'
|
|
139
137
|
? '0 0.5rem'
|
|
@@ -150,7 +148,6 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
150
148
|
column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined,
|
|
151
149
|
transition: 'all 0.2s ease-in-out',
|
|
152
150
|
whiteSpace: isDensePadding ? 'nowrap' : 'normal',
|
|
153
|
-
width: column.getSize(),
|
|
154
151
|
zIndex: column.getIsPinned() ? 1 : undefined,
|
|
155
152
|
'&:hover': {
|
|
156
153
|
backgroundColor: enableHover
|
|
@@ -161,6 +158,11 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
161
158
|
},
|
|
162
159
|
...(tableCellProps?.sx as any),
|
|
163
160
|
})}
|
|
161
|
+
style={{
|
|
162
|
+
maxWidth: `min(${column.getSize()}px, fit-content)`,
|
|
163
|
+
minWidth: `max(${column.getSize()}px, ${column.minSize ?? 30}px)`,
|
|
164
|
+
width: column.getSize(),
|
|
165
|
+
}}
|
|
164
166
|
>
|
|
165
167
|
<>
|
|
166
168
|
{isLoading || showSkeletons ? (
|
|
@@ -192,7 +194,8 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
192
194
|
</>
|
|
193
195
|
) : (
|
|
194
196
|
<>
|
|
195
|
-
{cell.column.columnDef?.Cell?.({ cell, tableInstance }) ??
|
|
197
|
+
{cell.column.columnDef?.Cell?.({ cell, tableInstance }) ??
|
|
198
|
+
cell.renderCell()}
|
|
196
199
|
{row.getIsGrouped() && <> ({row.subRows?.length ?? ''})</>}
|
|
197
200
|
</>
|
|
198
201
|
)}
|
|
@@ -52,6 +52,8 @@ export const MRT_CopyButton: FC<Props> = ({
|
|
|
52
52
|
aria-label={localization.clickToCopy}
|
|
53
53
|
onClick={() => handleCopy(cell.getValue())}
|
|
54
54
|
size="small"
|
|
55
|
+
type="button"
|
|
56
|
+
variant="text"
|
|
55
57
|
{...buttonProps}
|
|
56
58
|
sx={{
|
|
57
59
|
backgroundColor: 'transparent',
|
|
@@ -67,7 +69,6 @@ export const MRT_CopyButton: FC<Props> = ({
|
|
|
67
69
|
textTransform: 'inherit',
|
|
68
70
|
...buttonProps?.sx,
|
|
69
71
|
}}
|
|
70
|
-
variant="text"
|
|
71
72
|
>
|
|
72
73
|
{children}
|
|
73
74
|
</Button>
|
|
@@ -10,10 +10,12 @@ export const MRT_ExpandAllButton: FC<Props> = ({ tableInstance }) => {
|
|
|
10
10
|
const {
|
|
11
11
|
getIsAllRowsExpanded,
|
|
12
12
|
getIsSomeRowsExpanded,
|
|
13
|
+
getCanSomeRowsExpand,
|
|
13
14
|
getState,
|
|
14
15
|
options: {
|
|
15
16
|
icons: { DoubleArrowDownIcon },
|
|
16
17
|
localization,
|
|
18
|
+
renderDetailPanel,
|
|
17
19
|
},
|
|
18
20
|
toggleAllRowsExpanded,
|
|
19
21
|
} = tableInstance;
|
|
@@ -29,6 +31,7 @@ export const MRT_ExpandAllButton: FC<Props> = ({ tableInstance }) => {
|
|
|
29
31
|
>
|
|
30
32
|
<IconButton
|
|
31
33
|
aria-label={localization.expandAll}
|
|
34
|
+
disabled={!getCanSomeRowsExpand() && !renderDetailPanel}
|
|
32
35
|
onClick={() => toggleAllRowsExpanded(!getIsAllRowsExpanded())}
|
|
33
36
|
sx={{
|
|
34
37
|
height: isDensePadding ? '1.75rem' : '2.25rem',
|
|
@@ -141,8 +141,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
141
141
|
column.getIsPinned() === 'left'
|
|
142
142
|
? `${column.getStart('left')}px`
|
|
143
143
|
: undefined,
|
|
144
|
-
|
|
145
|
-
minWidth: `max(${column.getSize()}px, ${column.minSize}px)`,
|
|
144
|
+
|
|
146
145
|
overflow: 'visible',
|
|
147
146
|
p: isDensePadding
|
|
148
147
|
? column.columnDefType === 'display'
|
|
@@ -166,7 +165,6 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
166
165
|
column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined,
|
|
167
166
|
transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`,
|
|
168
167
|
verticalAlign: 'text-top',
|
|
169
|
-
width: header.getSize(),
|
|
170
168
|
zIndex: column.getIsResizing()
|
|
171
169
|
? 3
|
|
172
170
|
: column.getIsPinned() && column.columnDefType !== 'group'
|
|
@@ -174,6 +172,11 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
174
172
|
: 1,
|
|
175
173
|
...(tableCellProps?.sx as any),
|
|
176
174
|
})}
|
|
175
|
+
style={{
|
|
176
|
+
maxWidth: `min(${column.getSize()}px, fit-content)`,
|
|
177
|
+
minWidth: `max(${column.getSize()}px, ${column.minSize ?? 30}px)`,
|
|
178
|
+
width: header.getSize(),
|
|
179
|
+
}}
|
|
177
180
|
>
|
|
178
181
|
{header.isPlaceholder ? null : column.columnDefType === 'display' ? (
|
|
179
182
|
headerElement
|
|
@@ -273,7 +276,9 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
273
276
|
position: 'absolute',
|
|
274
277
|
right: '1px',
|
|
275
278
|
touchAction: 'none',
|
|
276
|
-
transition:
|
|
279
|
+
transition: column.getIsResizing()
|
|
280
|
+
? undefined
|
|
281
|
+
: 'all 0.2s ease-in-out',
|
|
277
282
|
userSelect: 'none',
|
|
278
283
|
zIndex: 2000,
|
|
279
284
|
'&:active': {
|
|
@@ -281,10 +286,8 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
281
286
|
opacity: 1,
|
|
282
287
|
},
|
|
283
288
|
})}
|
|
284
|
-
{
|
|
285
|
-
|
|
286
|
-
onTouchStart: header.getResizeHandler,
|
|
287
|
-
}}
|
|
289
|
+
onMouseDown={header.getResizeHandler()}
|
|
290
|
+
onTouchStart={header.getResizeHandler()}
|
|
288
291
|
style={{
|
|
289
292
|
transform: column.getIsResizing()
|
|
290
293
|
? `translateX(${getState().columnSizingInfo.deltaOffset}px)`
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
import React, { FC, Fragment } from 'react';
|
|
2
|
-
import { Alert, Box, Chip, Collapse
|
|
2
|
+
import { Alert, Box, Chip, Collapse } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
|
+
stackAlertBanner?: boolean;
|
|
6
7
|
tableInstance: MRT_TableInstance;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export const MRT_ToolbarAlertBanner: FC<Props> = ({
|
|
10
|
+
export const MRT_ToolbarAlertBanner: FC<Props> = ({
|
|
11
|
+
stackAlertBanner,
|
|
12
|
+
tableInstance,
|
|
13
|
+
}) => {
|
|
10
14
|
const {
|
|
11
15
|
getPrePaginationRowModel,
|
|
12
16
|
getSelectedRowModel,
|
|
13
17
|
getState,
|
|
14
|
-
options: {
|
|
15
|
-
localization,
|
|
16
|
-
muiTableToolbarAlertBannerProps,
|
|
17
|
-
positionToolbarActions,
|
|
18
|
-
positionToolbarAlertBanner,
|
|
19
|
-
renderToolbarCustomActions,
|
|
20
|
-
},
|
|
18
|
+
options: { localization, muiTableToolbarAlertBannerProps },
|
|
21
19
|
} = tableInstance;
|
|
22
20
|
|
|
23
21
|
const { grouping } = getState();
|
|
24
22
|
|
|
25
|
-
const isMobile = useMediaQuery('(max-width:720px)');
|
|
26
|
-
|
|
27
23
|
const alertProps =
|
|
28
24
|
muiTableToolbarAlertBannerProps instanceof Function
|
|
29
25
|
? muiTableToolbarAlertBannerProps({ tableInstance })
|
|
@@ -51,11 +47,7 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({ tableInstance }) => {
|
|
|
51
47
|
{index > 0 ? localization.thenBy : ''}
|
|
52
48
|
<Chip
|
|
53
49
|
color="secondary"
|
|
54
|
-
label={
|
|
55
|
-
tableInstance
|
|
56
|
-
.getAllColumns()
|
|
57
|
-
.find((column) => column.id === columnId)?.header
|
|
58
|
-
}
|
|
50
|
+
label={tableInstance.getColumn(columnId).columnDef.header}
|
|
59
51
|
onDelete={() =>
|
|
60
52
|
tableInstance.getColumn(columnId).toggleGrouping()
|
|
61
53
|
}
|
|
@@ -65,17 +57,10 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({ tableInstance }) => {
|
|
|
65
57
|
</span>
|
|
66
58
|
) : null;
|
|
67
59
|
|
|
68
|
-
const displayAbsolute = !(
|
|
69
|
-
isMobile ||
|
|
70
|
-
(positionToolbarAlertBanner === 'bottom' &&
|
|
71
|
-
positionToolbarActions === 'bottom') ||
|
|
72
|
-
(positionToolbarAlertBanner === 'top' && !!renderToolbarCustomActions)
|
|
73
|
-
);
|
|
74
|
-
|
|
75
60
|
return (
|
|
76
61
|
<Collapse
|
|
77
62
|
in={!!selectMessage || !!groupedByMessage}
|
|
78
|
-
timeout={
|
|
63
|
+
timeout={stackAlertBanner ? 200 : 0}
|
|
79
64
|
>
|
|
80
65
|
<Alert
|
|
81
66
|
color="info"
|
|
@@ -85,9 +70,8 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({ tableInstance }) => {
|
|
|
85
70
|
fontSize: '1rem',
|
|
86
71
|
left: 0,
|
|
87
72
|
p: 0,
|
|
88
|
-
position:
|
|
73
|
+
position: 'relative',
|
|
89
74
|
right: 0,
|
|
90
|
-
minHeight: '3.5rem',
|
|
91
75
|
top: 0,
|
|
92
76
|
width: '100%',
|
|
93
77
|
zIndex: 2,
|
|
@@ -97,7 +81,7 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({ tableInstance }) => {
|
|
|
97
81
|
>
|
|
98
82
|
<Box sx={{ p: '0.5rem 1rem' }}>
|
|
99
83
|
{selectMessage}
|
|
100
|
-
<br />
|
|
84
|
+
{selectMessage && groupedByMessage && <br />}
|
|
101
85
|
{groupedByMessage}
|
|
102
86
|
</Box>
|
|
103
87
|
</Alert>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { alpha, Box, Toolbar } from '@mui/material';
|
|
2
|
+
import { alpha, Box, Toolbar, useMediaQuery } from '@mui/material';
|
|
3
3
|
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
4
4
|
import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
|
|
5
5
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
@@ -22,16 +22,27 @@ export const MRT_ToolbarBottom: FC<Props> = ({ tableInstance }) => {
|
|
|
22
22
|
positionPagination,
|
|
23
23
|
positionToolbarActions,
|
|
24
24
|
positionToolbarAlertBanner,
|
|
25
|
+
renderToolbarCustomActions,
|
|
25
26
|
},
|
|
26
27
|
} = tableInstance;
|
|
27
28
|
|
|
28
29
|
const { isFullScreen } = getState();
|
|
29
30
|
|
|
31
|
+
const isMobile = useMediaQuery('(max-width:720px)');
|
|
32
|
+
|
|
30
33
|
const toolbarProps =
|
|
31
34
|
muiTableToolbarBottomProps instanceof Function
|
|
32
35
|
? muiTableToolbarBottomProps({ tableInstance })
|
|
33
36
|
: muiTableToolbarBottomProps;
|
|
34
37
|
|
|
38
|
+
const stackAlertBanner =
|
|
39
|
+
isMobile ||
|
|
40
|
+
(positionToolbarAlertBanner === 'bottom' &&
|
|
41
|
+
positionToolbarActions === 'bottom') ||
|
|
42
|
+
(positionToolbarAlertBanner === 'bottom' &&
|
|
43
|
+
!!renderToolbarCustomActions &&
|
|
44
|
+
positionToolbarActions === 'bottom');
|
|
45
|
+
|
|
35
46
|
return (
|
|
36
47
|
<Toolbar
|
|
37
48
|
id={`mrt-${idPrefix}-toolbar-bottom`}
|
|
@@ -48,17 +59,24 @@ export const MRT_ToolbarBottom: FC<Props> = ({ tableInstance }) => {
|
|
|
48
59
|
}
|
|
49
60
|
>
|
|
50
61
|
<MRT_LinearProgressBar tableInstance={tableInstance} />
|
|
62
|
+
{positionToolbarAlertBanner === 'bottom' && (
|
|
63
|
+
<MRT_ToolbarAlertBanner tableInstance={tableInstance} />
|
|
64
|
+
)}
|
|
51
65
|
<Box
|
|
52
|
-
sx={{
|
|
66
|
+
sx={{
|
|
67
|
+
display: 'flex',
|
|
68
|
+
justifyContent: 'space-between',
|
|
69
|
+
width: '100%',
|
|
70
|
+
position: stackAlertBanner ? 'relative' : 'absolute',
|
|
71
|
+
right: 0,
|
|
72
|
+
top: 0,
|
|
73
|
+
}}
|
|
53
74
|
>
|
|
54
75
|
{enableToolbarInternalActions && positionToolbarActions === 'bottom' ? (
|
|
55
76
|
<MRT_ToolbarInternalButtons tableInstance={tableInstance} />
|
|
56
77
|
) : (
|
|
57
78
|
<span />
|
|
58
79
|
)}
|
|
59
|
-
{positionToolbarAlertBanner === 'bottom' && (
|
|
60
|
-
<MRT_ToolbarAlertBanner tableInstance={tableInstance} />
|
|
61
|
-
)}
|
|
62
80
|
{enablePagination &&
|
|
63
81
|
['bottom', 'both'].includes(positionPagination ?? '') && (
|
|
64
82
|
<MRT_TablePagination tableInstance={tableInstance} />
|
|
@@ -6,6 +6,7 @@ import { MRT_ToggleDensePaddingButton } from '../buttons/MRT_ToggleDensePaddingB
|
|
|
6
6
|
import { MRT_ToggleFiltersButton } from '../buttons/MRT_ToggleFiltersButton';
|
|
7
7
|
import { MRT_ToggleGlobalFilterButton } from '../buttons/MRT_ToggleGlobalFilterButton';
|
|
8
8
|
import { MRT_TableInstance } from '..';
|
|
9
|
+
import { MRT_SearchTextField } from '../inputs/MRT_SearchTextField';
|
|
9
10
|
|
|
10
11
|
interface Props {
|
|
11
12
|
tableInstance: MRT_TableInstance;
|
|
@@ -24,42 +25,42 @@ export const MRT_ToolbarInternalButtons: FC<Props> = ({ tableInstance }) => {
|
|
|
24
25
|
},
|
|
25
26
|
} = tableInstance;
|
|
26
27
|
|
|
27
|
-
if (renderToolbarInternalActions) {
|
|
28
|
-
return (
|
|
29
|
-
<>
|
|
30
|
-
{renderToolbarInternalActions({
|
|
31
|
-
MRT_FullScreenToggleButton,
|
|
32
|
-
MRT_ShowHideColumnsButton,
|
|
33
|
-
MRT_ToggleDensePaddingButton,
|
|
34
|
-
MRT_ToggleFiltersButton,
|
|
35
|
-
MRT_ToggleGlobalFilterButton,
|
|
36
|
-
tableInstance,
|
|
37
|
-
})}
|
|
38
|
-
</>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
28
|
return (
|
|
43
29
|
<Box
|
|
44
30
|
sx={{
|
|
45
31
|
display: 'flex',
|
|
46
32
|
alignItems: 'center',
|
|
33
|
+
zIndex: 3,
|
|
47
34
|
}}
|
|
48
35
|
>
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
36
|
+
{renderToolbarInternalActions?.({
|
|
37
|
+
MRT_FullScreenToggleButton,
|
|
38
|
+
MRT_ShowHideColumnsButton,
|
|
39
|
+
MRT_ToggleDensePaddingButton,
|
|
40
|
+
MRT_ToggleFiltersButton,
|
|
41
|
+
MRT_ToggleGlobalFilterButton,
|
|
42
|
+
tableInstance,
|
|
43
|
+
}) ?? (
|
|
44
|
+
<>
|
|
45
|
+
{enableGlobalFilter && (
|
|
46
|
+
<MRT_SearchTextField tableInstance={tableInstance} />
|
|
47
|
+
)}
|
|
48
|
+
{enableFilters && enableGlobalFilter && (
|
|
49
|
+
<MRT_ToggleGlobalFilterButton tableInstance={tableInstance} />
|
|
50
|
+
)}
|
|
51
|
+
{enableFilters && enableColumnFilters && (
|
|
52
|
+
<MRT_ToggleFiltersButton tableInstance={tableInstance} />
|
|
53
|
+
)}
|
|
54
|
+
{enableHiding && (
|
|
55
|
+
<MRT_ShowHideColumnsButton tableInstance={tableInstance} />
|
|
56
|
+
)}
|
|
57
|
+
{enableDensePaddingToggle && (
|
|
58
|
+
<MRT_ToggleDensePaddingButton tableInstance={tableInstance} />
|
|
59
|
+
)}
|
|
60
|
+
{enableFullScreenToggle && (
|
|
61
|
+
<MRT_FullScreenToggleButton tableInstance={tableInstance} />
|
|
62
|
+
)}
|
|
63
|
+
</>
|
|
63
64
|
)}
|
|
64
65
|
</Box>
|
|
65
66
|
);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { Box, lighten, Theme, Toolbar } from '@mui/material';
|
|
3
|
-
import { MRT_SearchTextField } from '../inputs/MRT_SearchTextField';
|
|
2
|
+
import { Box, lighten, Theme, Toolbar, useMediaQuery } from '@mui/material';
|
|
4
3
|
import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
|
|
5
4
|
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
6
5
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
@@ -11,6 +10,8 @@ export const commonToolbarStyles = ({ theme }: { theme: Theme }) => ({
|
|
|
11
10
|
backgroundColor: lighten(theme.palette.background.default, 0.04),
|
|
12
11
|
backgroundImage: 'none',
|
|
13
12
|
display: 'grid',
|
|
13
|
+
minHeight: '3.5rem',
|
|
14
|
+
overflow: 'hidden',
|
|
14
15
|
p: '0 !important',
|
|
15
16
|
transition: 'all 0.2s ease-in-out',
|
|
16
17
|
width: '100%',
|
|
@@ -25,7 +26,6 @@ export const MRT_ToolbarTop: FC<Props> = ({ tableInstance }) => {
|
|
|
25
26
|
const {
|
|
26
27
|
getState,
|
|
27
28
|
options: {
|
|
28
|
-
enableGlobalFilter,
|
|
29
29
|
enablePagination,
|
|
30
30
|
enableToolbarInternalActions,
|
|
31
31
|
idPrefix,
|
|
@@ -39,11 +39,17 @@ export const MRT_ToolbarTop: FC<Props> = ({ tableInstance }) => {
|
|
|
39
39
|
|
|
40
40
|
const { isFullScreen } = getState();
|
|
41
41
|
|
|
42
|
+
const isMobile = useMediaQuery('(max-width:720px)');
|
|
43
|
+
|
|
42
44
|
const toolbarProps =
|
|
43
45
|
muiTableToolbarTopProps instanceof Function
|
|
44
46
|
? muiTableToolbarTopProps({ tableInstance })
|
|
45
47
|
: muiTableToolbarTopProps;
|
|
46
48
|
|
|
49
|
+
const stackAlertBanner =
|
|
50
|
+
isMobile ||
|
|
51
|
+
(positionToolbarAlertBanner === 'top' && !!renderToolbarCustomActions);
|
|
52
|
+
|
|
47
53
|
return (
|
|
48
54
|
<Toolbar
|
|
49
55
|
id={`mrt-${idPrefix}-toolbar-top`}
|
|
@@ -59,31 +65,26 @@ export const MRT_ToolbarTop: FC<Props> = ({ tableInstance }) => {
|
|
|
59
65
|
}
|
|
60
66
|
>
|
|
61
67
|
{positionToolbarAlertBanner === 'top' && (
|
|
62
|
-
<MRT_ToolbarAlertBanner
|
|
68
|
+
<MRT_ToolbarAlertBanner
|
|
69
|
+
stackAlertBanner={stackAlertBanner}
|
|
70
|
+
tableInstance={tableInstance}
|
|
71
|
+
/>
|
|
63
72
|
)}
|
|
64
73
|
<Box
|
|
65
74
|
sx={{
|
|
66
|
-
p: '0.5rem',
|
|
67
75
|
display: 'flex',
|
|
68
76
|
justifyContent: 'space-between',
|
|
77
|
+
p: '0.5rem',
|
|
78
|
+
position: stackAlertBanner ? 'relative' : 'absolute',
|
|
79
|
+
right: 0,
|
|
80
|
+
top: 0,
|
|
81
|
+
width: 'calc(100% - 1rem)',
|
|
69
82
|
}}
|
|
70
83
|
>
|
|
71
84
|
{renderToolbarCustomActions?.({ tableInstance }) ?? <span />}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
gap: '0.5rem',
|
|
76
|
-
position: 'relative',
|
|
77
|
-
zIndex: 3,
|
|
78
|
-
}}
|
|
79
|
-
>
|
|
80
|
-
{enableGlobalFilter && (
|
|
81
|
-
<MRT_SearchTextField tableInstance={tableInstance} />
|
|
82
|
-
)}
|
|
83
|
-
{enableToolbarInternalActions && positionToolbarActions === 'top' && (
|
|
84
|
-
<MRT_ToolbarInternalButtons tableInstance={tableInstance} />
|
|
85
|
-
)}
|
|
86
|
-
</Box>
|
|
85
|
+
{enableToolbarInternalActions && positionToolbarActions === 'top' && (
|
|
86
|
+
<MRT_ToolbarInternalButtons tableInstance={tableInstance} />
|
|
87
|
+
)}
|
|
87
88
|
</Box>
|
|
88
89
|
<div>
|
|
89
90
|
{enablePagination &&
|