material-react-table 0.8.0-alpha.2 → 0.8.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.
- package/README.md +2 -2
- package/dist/MaterialReactTable.d.ts +5 -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 +498 -294
- 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 +500 -296
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/table/MRT_TableContainer.d.ts +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 +9 -6
- package/src/MaterialReactTable.tsx +10 -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_DraggableTableHeadCell.tsx +52 -0
- package/src/head/MRT_TableHeadCell.tsx +66 -155
- 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_FilterRangeFields.tsx +1 -3
- package/src/localization.ts +2 -0
- package/src/table/MRT_TableContainer.tsx +1 -1
- package/src/table/MRT_TablePaper.tsx +26 -22
- package/src/table/MRT_TableRoot.tsx +8 -0
- 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
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
3
|
+
import { MRT_Header, MRT_TableInstance } from '..';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
header: MRT_Header;
|
|
7
|
+
tableInstance: MRT_TableInstance;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const MRT_TableHeadCellFilterLabel: FC<Props> = ({
|
|
11
|
+
header,
|
|
12
|
+
tableInstance,
|
|
13
|
+
}) => {
|
|
14
|
+
const {
|
|
15
|
+
getState,
|
|
16
|
+
options: {
|
|
17
|
+
icons: { FilterAltIcon, FilterAltOff },
|
|
18
|
+
localization,
|
|
19
|
+
},
|
|
20
|
+
setShowFilters,
|
|
21
|
+
} = tableInstance;
|
|
22
|
+
|
|
23
|
+
const { showFilters } = getState();
|
|
24
|
+
|
|
25
|
+
const { column } = header;
|
|
26
|
+
|
|
27
|
+
const filterFn = getState()?.currentFilterFns?.[header.id];
|
|
28
|
+
|
|
29
|
+
const filterTooltip = !!column.getFilterValue()
|
|
30
|
+
? localization.filteringByColumn
|
|
31
|
+
.replace('{column}', String(column.columnDef.header))
|
|
32
|
+
.replace(
|
|
33
|
+
'{filterType}',
|
|
34
|
+
filterFn instanceof Function
|
|
35
|
+
? ''
|
|
36
|
+
: // @ts-ignore
|
|
37
|
+
localization[
|
|
38
|
+
`filter${filterFn.charAt(0).toUpperCase() + filterFn.slice(1)}`
|
|
39
|
+
],
|
|
40
|
+
)
|
|
41
|
+
.replace(
|
|
42
|
+
'{filterValue}',
|
|
43
|
+
`"${
|
|
44
|
+
Array.isArray(column.getFilterValue())
|
|
45
|
+
? (column.getFilterValue() as [string, string]).join(
|
|
46
|
+
`" ${localization.and} "`,
|
|
47
|
+
)
|
|
48
|
+
: (column.getFilterValue() as string)
|
|
49
|
+
}"`,
|
|
50
|
+
)
|
|
51
|
+
.replace('" "', '')
|
|
52
|
+
: localization.showHideFilters;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Tooltip arrow placement="top" title={filterTooltip}>
|
|
56
|
+
<IconButton
|
|
57
|
+
disableRipple
|
|
58
|
+
onClick={(event: MouseEvent<HTMLButtonElement>) => {
|
|
59
|
+
event.stopPropagation();
|
|
60
|
+
setShowFilters(!showFilters);
|
|
61
|
+
}}
|
|
62
|
+
size="small"
|
|
63
|
+
sx={{
|
|
64
|
+
m: 0,
|
|
65
|
+
opacity: !!column.getFilterValue() || showFilters ? 0.8 : 0,
|
|
66
|
+
p: '2px',
|
|
67
|
+
transition: 'all 0.2s ease-in-out',
|
|
68
|
+
'&:hover': {
|
|
69
|
+
backgroundColor: 'transparent',
|
|
70
|
+
opacity: 0.8,
|
|
71
|
+
},
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
{showFilters && !column.getFilterValue() ? (
|
|
75
|
+
<FilterAltOff />
|
|
76
|
+
) : (
|
|
77
|
+
<FilterAltIcon />
|
|
78
|
+
)}
|
|
79
|
+
</IconButton>
|
|
80
|
+
</Tooltip>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
2
|
+
import React, { FC, forwardRef, Ref } from 'react';
|
|
3
|
+
import { MRT_Header, MRT_TableInstance } from '..';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
header: MRT_Header;
|
|
7
|
+
ref: Ref<HTMLButtonElement>;
|
|
8
|
+
tableInstance: MRT_TableInstance;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const MRT_TableHeadCellGrabHandle: FC<Props> = forwardRef(
|
|
12
|
+
({ tableInstance }, ref) => {
|
|
13
|
+
const {
|
|
14
|
+
options: {
|
|
15
|
+
icons: { DragHandleIcon },
|
|
16
|
+
localization,
|
|
17
|
+
},
|
|
18
|
+
} = tableInstance;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Tooltip
|
|
22
|
+
arrow
|
|
23
|
+
enterDelay={1000}
|
|
24
|
+
enterNextDelay={1000}
|
|
25
|
+
placement="top"
|
|
26
|
+
title={localization.grab}
|
|
27
|
+
>
|
|
28
|
+
<IconButton
|
|
29
|
+
disableRipple
|
|
30
|
+
ref={ref}
|
|
31
|
+
size="small"
|
|
32
|
+
sx={{
|
|
33
|
+
cursor: 'grab',
|
|
34
|
+
m: 0,
|
|
35
|
+
opacity: 0.5,
|
|
36
|
+
p: '2px',
|
|
37
|
+
transition: 'all 0.2s ease-in-out',
|
|
38
|
+
'&:hover': {
|
|
39
|
+
backgroundColor: 'transparent',
|
|
40
|
+
opacity: 1,
|
|
41
|
+
},
|
|
42
|
+
'&:active': {
|
|
43
|
+
cursor: 'grabbing',
|
|
44
|
+
},
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<DragHandleIcon />
|
|
48
|
+
</IconButton>
|
|
49
|
+
</Tooltip>
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { Divider, Theme } from '@mui/material';
|
|
3
|
+
import { MRT_Header, MRT_TableInstance } from '..';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
header: MRT_Header;
|
|
7
|
+
tableInstance: MRT_TableInstance;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const MRT_TableHeadCellResizeHandle: FC<Props> = ({
|
|
11
|
+
header,
|
|
12
|
+
tableInstance,
|
|
13
|
+
}) => {
|
|
14
|
+
const { getState } = tableInstance;
|
|
15
|
+
|
|
16
|
+
const { showFilters } = getState();
|
|
17
|
+
|
|
18
|
+
const { column } = header;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Divider
|
|
22
|
+
flexItem
|
|
23
|
+
orientation="vertical"
|
|
24
|
+
onDoubleClick={() => column.resetSize()}
|
|
25
|
+
sx={(theme: Theme) => ({
|
|
26
|
+
borderRadius: '2px',
|
|
27
|
+
borderRightWidth: '2px',
|
|
28
|
+
cursor: 'col-resize',
|
|
29
|
+
height:
|
|
30
|
+
showFilters && column.columnDefType === 'data' ? '4rem' : '2rem',
|
|
31
|
+
opacity: 0.8,
|
|
32
|
+
position: 'absolute',
|
|
33
|
+
right: '1px',
|
|
34
|
+
touchAction: 'none',
|
|
35
|
+
transition: column.getIsResizing() ? undefined : 'all 0.2s ease-in-out',
|
|
36
|
+
userSelect: 'none',
|
|
37
|
+
zIndex: 2000,
|
|
38
|
+
'&:active': {
|
|
39
|
+
backgroundColor: theme.palette.info.main,
|
|
40
|
+
opacity: 1,
|
|
41
|
+
},
|
|
42
|
+
})}
|
|
43
|
+
onMouseDown={header.getResizeHandler()}
|
|
44
|
+
onTouchStart={header.getResizeHandler()}
|
|
45
|
+
style={{
|
|
46
|
+
transform: column.getIsResizing()
|
|
47
|
+
? `translateX(${getState().columnSizingInfo.deltaOffset}px)`
|
|
48
|
+
: 'none',
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { TableSortLabel, Tooltip } from '@mui/material';
|
|
3
|
+
import { MRT_Header, MRT_TableInstance } from '..';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
header: MRT_Header;
|
|
7
|
+
tableInstance: MRT_TableInstance;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const MRT_TableHeadCellSortLabel: FC<Props> = ({
|
|
11
|
+
header,
|
|
12
|
+
tableInstance,
|
|
13
|
+
}) => {
|
|
14
|
+
const {
|
|
15
|
+
options: { localization },
|
|
16
|
+
} = tableInstance;
|
|
17
|
+
|
|
18
|
+
const { column } = header;
|
|
19
|
+
|
|
20
|
+
const sortTooltip = !!column.getIsSorted()
|
|
21
|
+
? column.getIsSorted() === 'desc'
|
|
22
|
+
? localization.sortedByColumnDesc.replace(
|
|
23
|
+
'{column}',
|
|
24
|
+
column.columnDef.header,
|
|
25
|
+
)
|
|
26
|
+
: localization.sortedByColumnAsc.replace(
|
|
27
|
+
'{column}',
|
|
28
|
+
column.columnDef.header,
|
|
29
|
+
)
|
|
30
|
+
: localization.unsorted;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Tooltip arrow placement="top" title={sortTooltip}>
|
|
34
|
+
<TableSortLabel
|
|
35
|
+
aria-label={sortTooltip}
|
|
36
|
+
active={!!column.getIsSorted()}
|
|
37
|
+
direction={
|
|
38
|
+
column.getIsSorted()
|
|
39
|
+
? (column.getIsSorted() as 'asc' | 'desc')
|
|
40
|
+
: undefined
|
|
41
|
+
}
|
|
42
|
+
/>
|
|
43
|
+
</Tooltip>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { alpha, lighten, TableRow } from '@mui/material';
|
|
3
3
|
import { MRT_TableHeadCell } from './MRT_TableHeadCell';
|
|
4
|
+
import { MRT_DraggableTableHeadCell } from './MRT_DraggableTableHeadCell';
|
|
4
5
|
import type { MRT_Header, MRT_HeaderGroup, MRT_TableInstance } from '..';
|
|
5
6
|
|
|
6
7
|
interface Props {
|
|
@@ -10,7 +11,7 @@ interface Props {
|
|
|
10
11
|
|
|
11
12
|
export const MRT_TableHeadRow: FC<Props> = ({ headerGroup, tableInstance }) => {
|
|
12
13
|
const {
|
|
13
|
-
options: { muiTableHeadRowProps },
|
|
14
|
+
options: { enableColumnOrdering, enableGrouping, muiTableHeadRowProps },
|
|
14
15
|
} = tableInstance;
|
|
15
16
|
|
|
16
17
|
const tableRowProps =
|
|
@@ -27,13 +28,21 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup, tableInstance }) => {
|
|
|
27
28
|
...(tableRowProps?.sx as any),
|
|
28
29
|
})}
|
|
29
30
|
>
|
|
30
|
-
{headerGroup.headers.map((header: MRT_Header, index) =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
{headerGroup.headers.map((header: MRT_Header, index) =>
|
|
32
|
+
enableColumnOrdering || enableGrouping ? (
|
|
33
|
+
<MRT_DraggableTableHeadCell
|
|
34
|
+
header={header}
|
|
35
|
+
key={header.id || index}
|
|
36
|
+
tableInstance={tableInstance}
|
|
37
|
+
/>
|
|
38
|
+
) : (
|
|
39
|
+
<MRT_TableHeadCell
|
|
40
|
+
header={header}
|
|
41
|
+
key={header.id || index}
|
|
42
|
+
tableInstance={tableInstance}
|
|
43
|
+
/>
|
|
44
|
+
),
|
|
45
|
+
)}
|
|
37
46
|
</TableRow>
|
|
38
47
|
);
|
|
39
48
|
};
|
package/src/icons.ts
CHANGED
|
@@ -6,6 +6,7 @@ import CloseIcon from '@mui/icons-material/Close';
|
|
|
6
6
|
import DensityMediumIcon from '@mui/icons-material/DensityMedium';
|
|
7
7
|
import DensitySmallIcon from '@mui/icons-material/DensitySmall';
|
|
8
8
|
import DoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
|
|
9
|
+
import DragHandleIcon from '@mui/icons-material/DragHandle';
|
|
9
10
|
import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
|
|
10
11
|
import EditIcon from '@mui/icons-material/Edit';
|
|
11
12
|
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
|
@@ -36,6 +37,7 @@ export interface MRT_Icons {
|
|
|
36
37
|
DensityMediumIcon: any;
|
|
37
38
|
DensitySmallIcon: any;
|
|
38
39
|
DoubleArrowDownIcon: any;
|
|
40
|
+
DragHandleIcon: any;
|
|
39
41
|
DynamicFeedIcon: any;
|
|
40
42
|
EditIcon: any;
|
|
41
43
|
ExpandLessIcon: any;
|
|
@@ -67,6 +69,7 @@ export const MRT_Default_Icons: MRT_Icons = {
|
|
|
67
69
|
DensityMediumIcon,
|
|
68
70
|
DensitySmallIcon,
|
|
69
71
|
DoubleArrowDownIcon,
|
|
72
|
+
DragHandleIcon,
|
|
70
73
|
DynamicFeedIcon,
|
|
71
74
|
EditIcon,
|
|
72
75
|
ExpandLessIcon,
|
|
@@ -8,7 +8,7 @@ interface Props {
|
|
|
8
8
|
tableInstance: MRT_TableInstance;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const MRT_FilterRangeFields: FC<Props> = ({ header, tableInstance }) => {
|
|
11
|
+
export const MRT_FilterRangeFields: FC<Props> = ({ header, tableInstance }) => {
|
|
12
12
|
const {
|
|
13
13
|
options: { localization },
|
|
14
14
|
} = tableInstance;
|
|
@@ -37,5 +37,3 @@ const MRT_FilterRangeFields: FC<Props> = ({ header, tableInstance }) => {
|
|
|
37
37
|
</Box>
|
|
38
38
|
);
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
export default MRT_FilterRangeFields;
|
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',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC, useEffect, useLayoutEffect, useState } from 'react';
|
|
2
2
|
import { TableContainer } from '@mui/material';
|
|
3
|
-
import { MRT_TableInstance } from '..';
|
|
4
3
|
import { MRT_Table } from './MRT_Table';
|
|
4
|
+
import type { MRT_TableInstance } from '..';
|
|
5
5
|
|
|
6
6
|
const useIsomorphicLayoutEffect =
|
|
7
7
|
typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
@@ -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,6 +222,12 @@ 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
|
|
@@ -237,6 +243,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
237
243
|
getSubRows: (row) => (row as MRT_Row)?.subRows,
|
|
238
244
|
//@ts-ignore
|
|
239
245
|
globalFilterFn: currentGlobalFilterFn,
|
|
246
|
+
onColumnOrderChange: setColumnOrder,
|
|
240
247
|
onPaginationChange: (updater: any) =>
|
|
241
248
|
setPagination((old) => functionalUpdate(updater, old)),
|
|
242
249
|
...props,
|
|
@@ -246,6 +253,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
246
253
|
idPrefix,
|
|
247
254
|
initialState,
|
|
248
255
|
state: {
|
|
256
|
+
columnOrder,
|
|
249
257
|
currentEditingCell,
|
|
250
258
|
currentEditingRow,
|
|
251
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
|
);
|