material-react-table 0.8.0-alpha.1 → 0.8.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.
- package/README.md +1 -1
- package/dist/MaterialReactTable.d.ts +8 -2
- package/dist/head/MRT_DraggableTableHeadCell.d.ts +8 -0
- package/dist/head/MRT_TableHeadCell.d.ts +5 -1
- package/dist/head/MRT_TableHeadCellFilterContainer.d.ts +8 -0
- package/dist/head/MRT_TableHeadCellFilterLabel.d.ts +8 -0
- package/dist/head/MRT_TableHeadCellGrabHandle.d.ts +9 -0
- package/dist/head/MRT_TableHeadCellResizeHandle.d.ts +8 -0
- package/dist/head/MRT_TableHeadCellSortLabel.d.ts +8 -0
- package/dist/icons.d.ts +1 -0
- package/dist/inputs/MRT_FilterRangeFields.d.ts +2 -2
- package/dist/localization.d.ts +1 -0
- package/dist/material-react-table.cjs.development.js +514 -313
- 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 +516 -315
- 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/dist/utils.d.ts +1 -1
- package/package.json +13 -13
- package/src/MaterialReactTable.tsx +13 -0
- package/src/body/MRT_TableBodyCell.tsx +10 -7
- package/src/buttons/MRT_CopyButton.tsx +3 -2
- package/src/buttons/MRT_ExpandAllButton.tsx +26 -18
- package/src/buttons/MRT_ExpandButton.tsx +27 -21
- package/src/footer/MRT_TableFooterCell.tsx +11 -8
- package/src/footer/MRT_TableFooterRow.tsx +3 -2
- package/src/head/MRT_DraggableTableHeadCell.tsx +52 -0
- package/src/head/MRT_TableHeadCell.tsx +75 -156
- package/src/head/MRT_TableHeadCellFilterContainer.tsx +32 -0
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +82 -0
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +52 -0
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +52 -0
- package/src/head/MRT_TableHeadCellSortLabel.tsx +45 -0
- package/src/head/MRT_TableHeadRow.tsx +17 -8
- package/src/icons.ts +3 -0
- package/src/inputs/MRT_EditCellTextField.tsx +1 -1
- package/src/inputs/MRT_FilterRangeFields.tsx +1 -3
- package/src/inputs/MRT_FilterTextField.tsx +4 -1
- package/src/inputs/MRT_SelectCheckbox.tsx +1 -2
- package/src/localization.ts +2 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +6 -6
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +1 -1
- package/src/table/MRT_TablePaper.tsx +26 -22
- package/src/table/MRT_TableRoot.tsx +9 -9
- 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
|
@@ -130,7 +130,10 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
130
130
|
: '';
|
|
131
131
|
const filterPlaceholder =
|
|
132
132
|
inputIndex === undefined
|
|
133
|
-
? localization.filterByColumn?.replace(
|
|
133
|
+
? localization.filterByColumn?.replace(
|
|
134
|
+
'{column}',
|
|
135
|
+
String(column.columnDef.header),
|
|
136
|
+
)
|
|
134
137
|
: inputIndex === 0
|
|
135
138
|
? localization.min
|
|
136
139
|
: inputIndex === 1
|
|
@@ -25,7 +25,7 @@ export const MRT_SelectCheckbox: FC<Props> = ({
|
|
|
25
25
|
},
|
|
26
26
|
} = tableInstance;
|
|
27
27
|
|
|
28
|
-
const { isDensePadding
|
|
28
|
+
const { isDensePadding } = getState();
|
|
29
29
|
|
|
30
30
|
const handleSelectChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
31
31
|
if (selectAll) {
|
|
@@ -70,7 +70,6 @@ export const MRT_SelectCheckbox: FC<Props> = ({
|
|
|
70
70
|
? tableInstance.getIsAllRowsSelected()
|
|
71
71
|
: row?.getIsSelected()
|
|
72
72
|
}
|
|
73
|
-
disabled={isLoading}
|
|
74
73
|
indeterminate={
|
|
75
74
|
selectAll
|
|
76
75
|
? tableInstance.getIsSomeRowsSelected()
|
package/src/localization.ts
CHANGED
|
@@ -27,6 +27,7 @@ export interface MRT_Localization {
|
|
|
27
27
|
filterNotEquals: string;
|
|
28
28
|
filterStartsWith: string;
|
|
29
29
|
filteringByColumn: string;
|
|
30
|
+
grab: string;
|
|
30
31
|
groupByColumn: string;
|
|
31
32
|
groupedBy: string;
|
|
32
33
|
hideAll: string;
|
|
@@ -93,6 +94,7 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
|
93
94
|
filterNotEquals: 'Not Equals',
|
|
94
95
|
filterStartsWith: 'Starts With',
|
|
95
96
|
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
|
97
|
+
grab: 'Grab',
|
|
96
98
|
groupByColumn: 'Group by {column}',
|
|
97
99
|
groupedBy: 'Grouped by ',
|
|
98
100
|
hideAll: 'Hide all',
|
|
@@ -178,7 +178,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
178
178
|
</ListItemIcon>
|
|
179
179
|
{localization.sortByColumnAsc?.replace(
|
|
180
180
|
'{column}',
|
|
181
|
-
String(column.header),
|
|
181
|
+
String(column.columnDef.header),
|
|
182
182
|
)}
|
|
183
183
|
</Box>
|
|
184
184
|
</MenuItem>,
|
|
@@ -195,7 +195,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
195
195
|
</ListItemIcon>
|
|
196
196
|
{localization.sortByColumnDesc?.replace(
|
|
197
197
|
'{column}',
|
|
198
|
-
String(column.header),
|
|
198
|
+
String(column.columnDef.header),
|
|
199
199
|
)}
|
|
200
200
|
</Box>
|
|
201
201
|
</MenuItem>,
|
|
@@ -227,7 +227,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
227
227
|
</ListItemIcon>
|
|
228
228
|
{localization.filterByColumn?.replace(
|
|
229
229
|
'{column}',
|
|
230
|
-
String(column.header),
|
|
230
|
+
String(column.columnDef.header),
|
|
231
231
|
)}
|
|
232
232
|
</Box>
|
|
233
233
|
{!column.filterSelectOptions && (
|
|
@@ -264,7 +264,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
264
264
|
</ListItemIcon>
|
|
265
265
|
{localization[
|
|
266
266
|
column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn'
|
|
267
|
-
]?.replace('{column}', String(column.header))}
|
|
267
|
+
]?.replace('{column}', String(column.columnDef.header))}
|
|
268
268
|
</Box>
|
|
269
269
|
</MenuItem>,
|
|
270
270
|
]}
|
|
@@ -339,7 +339,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
339
339
|
</ListItemIcon>
|
|
340
340
|
{localization.hideColumn?.replace(
|
|
341
341
|
'{column}',
|
|
342
|
-
String(column.header),
|
|
342
|
+
String(column.columnDef.header),
|
|
343
343
|
)}
|
|
344
344
|
</Box>
|
|
345
345
|
</MenuItem>,
|
|
@@ -358,7 +358,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
358
358
|
</ListItemIcon>
|
|
359
359
|
{localization.showAllColumns?.replace(
|
|
360
360
|
'{column}',
|
|
361
|
-
String(column.header),
|
|
361
|
+
String(column.columnDef.header),
|
|
362
362
|
)}
|
|
363
363
|
</Box>
|
|
364
364
|
<IconButton
|
|
@@ -63,7 +63,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
63
63
|
checked={switchChecked}
|
|
64
64
|
control={<Switch />}
|
|
65
65
|
disabled={(isSubMenu && switchChecked) || !column.getCanHide()}
|
|
66
|
-
label={column.header}
|
|
66
|
+
label={column.columnDef.header}
|
|
67
67
|
onChange={() => handleToggleColumnHidden(column)}
|
|
68
68
|
/>
|
|
69
69
|
</MenuItem>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { FC, useEffect } from 'react';
|
|
2
2
|
import { Paper } from '@mui/material';
|
|
3
|
+
import { DndProvider } from 'react-dnd';
|
|
4
|
+
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
3
5
|
import { MRT_ToolbarTop } from '../toolbar/MRT_ToolbarTop';
|
|
4
6
|
import { MRT_ToolbarBottom } from '../toolbar/MRT_ToolbarBottom';
|
|
5
7
|
import { MRT_TableContainer } from './MRT_TableContainer';
|
|
@@ -35,27 +37,29 @@ export const MRT_TablePaper: FC<Props> = ({ tableInstance }) => {
|
|
|
35
37
|
: muiTablePaperProps;
|
|
36
38
|
|
|
37
39
|
return (
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
40
|
+
<DndProvider backend={HTML5Backend}>
|
|
41
|
+
<Paper
|
|
42
|
+
elevation={2}
|
|
43
|
+
{...tablePaperProps}
|
|
44
|
+
sx={{
|
|
45
|
+
transition: 'all 0.2s ease-in-out',
|
|
46
|
+
...tablePaperProps?.sx,
|
|
47
|
+
}}
|
|
48
|
+
style={{
|
|
49
|
+
height: isFullScreen ? '100vh' : undefined,
|
|
50
|
+
margin: isFullScreen ? '0' : undefined,
|
|
51
|
+
maxHeight: isFullScreen ? '100vh' : undefined,
|
|
52
|
+
maxWidth: isFullScreen ? '100vw' : undefined,
|
|
53
|
+
padding: isFullScreen ? '0' : undefined,
|
|
54
|
+
width: isFullScreen ? '100vw' : undefined,
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
{enableToolbarTop && <MRT_ToolbarTop tableInstance={tableInstance} />}
|
|
58
|
+
<MRT_TableContainer tableInstance={tableInstance} />
|
|
59
|
+
{enableToolbarBottom && (
|
|
60
|
+
<MRT_ToolbarBottom tableInstance={tableInstance} />
|
|
61
|
+
)}
|
|
62
|
+
</Paper>
|
|
63
|
+
</DndProvider>
|
|
60
64
|
);
|
|
61
65
|
};
|
|
@@ -222,29 +222,28 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
222
222
|
[props.data, props.state?.isLoading, props.state?.showSkeletons],
|
|
223
223
|
);
|
|
224
224
|
|
|
225
|
+
const [columnOrder, setColumnOrder] = useState<string[]>(() =>
|
|
226
|
+
initialState?.columnOrder ?? props.enableColumnOrdering
|
|
227
|
+
? getAllLeafColumnDefs(columns as MRT_ColumnDef[]).map((c) => c.id)
|
|
228
|
+
: [],
|
|
229
|
+
);
|
|
230
|
+
|
|
225
231
|
//@ts-ignore
|
|
226
232
|
const tableInstance = {
|
|
227
233
|
//@ts-ignore
|
|
228
234
|
...useTableInstance(table, {
|
|
229
235
|
filterFns: defaultFilterFNs,
|
|
230
|
-
//@ts-ignore
|
|
231
236
|
getCoreRowModel: getCoreRowModel(),
|
|
232
|
-
//@ts-ignore
|
|
233
237
|
getExpandedRowModel: getExpandedRowModel(),
|
|
234
|
-
//@ts-ignore
|
|
235
238
|
getFacetedRowModel: getFacetedRowModel(),
|
|
236
|
-
//@ts-ignore
|
|
237
239
|
getFilteredRowModel: getFilteredRowModel(),
|
|
238
|
-
//@ts-ignore
|
|
239
240
|
getGroupedRowModel: getGroupedRowModel(),
|
|
240
|
-
//@ts-ignore
|
|
241
241
|
getPaginationRowModel: getPaginationRowModel(),
|
|
242
|
-
//@ts-ignore
|
|
243
242
|
getSortedRowModel: getSortedRowModel(),
|
|
244
|
-
|
|
245
|
-
getSubRows: (row) => row?.subRows,
|
|
243
|
+
getSubRows: (row) => (row as MRT_Row)?.subRows,
|
|
246
244
|
//@ts-ignore
|
|
247
245
|
globalFilterFn: currentGlobalFilterFn,
|
|
246
|
+
onColumnOrderChange: setColumnOrder,
|
|
248
247
|
onPaginationChange: (updater: any) =>
|
|
249
248
|
setPagination((old) => functionalUpdate(updater, old)),
|
|
250
249
|
...props,
|
|
@@ -254,6 +253,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
254
253
|
idPrefix,
|
|
255
254
|
initialState,
|
|
256
255
|
state: {
|
|
256
|
+
columnOrder,
|
|
257
257
|
currentEditingCell,
|
|
258
258
|
currentEditingRow,
|
|
259
259
|
currentFilterFns,
|
|
@@ -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 &&
|