material-react-table 0.4.2 → 0.4.5
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/dist/MaterialReactTable.d.ts +11 -3
- package/dist/buttons/MRT_FullScreenToggleButton.d.ts +3 -1
- package/dist/buttons/MRT_ShowHideColumnsButton.d.ts +2 -1
- package/dist/buttons/MRT_ToggleDensePaddingButton.d.ts +6 -0
- package/dist/buttons/MRT_ToggleFiltersButton.d.ts +3 -1
- package/dist/buttons/MRT_ToggleSearchButton.d.ts +3 -1
- package/dist/inputs/MRT_SelectCheckbox.d.ts +2 -1
- package/dist/material-react-table.cjs.development.js +174 -103
- 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 +174 -103
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +7 -8
- package/src/MaterialReactTable.tsx +20 -2
- package/src/body/MRT_TableBodyRow.tsx +3 -2
- package/src/buttons/MRT_FullScreenToggleButton.tsx +4 -3
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +4 -2
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +14 -8
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +24 -0
- package/src/buttons/MRT_ToggleFiltersButton.tsx +4 -3
- package/src/buttons/MRT_ToggleSearchButton.tsx +4 -4
- package/src/footer/MRT_TableFooterRow.tsx +9 -10
- package/src/head/MRT_TableHeadCell.tsx +21 -12
- package/src/head/MRT_TableHeadRow.tsx +6 -5
- package/src/inputs/MRT_EditCellTextField.tsx +1 -2
- package/src/inputs/MRT_SelectCheckbox.tsx +44 -15
- package/src/table/MRT_TableContainer.tsx +2 -2
- package/src/toolbar/MRT_TablePagination.tsx +1 -0
- package/src/toolbar/MRT_ToolbarBottom.tsx +19 -7
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +18 -2
- package/src/toolbar/MRT_ToolbarTop.tsx +19 -7
- package/src/utils/localization.ts +3 -3
- package/dist/inputs/MRT_DensePaddingSwitch.d.ts +0 -5
- package/dist/inputs/MRT_SelectAllCheckbox.d.ts +0 -2
- package/src/inputs/MRT_DensePaddingSwitch.tsx +0 -23
- package/src/inputs/MRT_SelectAllCheckbox.tsx +0 -22
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.4.
|
|
2
|
+
"version": "0.4.5",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material-UI implementation of react-table, inspired by material-table and the mui DataGrid, written from the ground up in TypeScript.",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
}
|
|
57
57
|
],
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@babel/core": "^7.17.
|
|
60
|
-
"@emotion/react": "^11.
|
|
61
|
-
"@emotion/styled": "^11.
|
|
59
|
+
"@babel/core": "^7.17.5",
|
|
60
|
+
"@emotion/react": "^11.8.1",
|
|
61
|
+
"@emotion/styled": "^11.8.1",
|
|
62
62
|
"@etchteam/storybook-addon-status": "^4.2.0",
|
|
63
|
-
"@faker-js/faker": "^6.0.0-alpha.
|
|
63
|
+
"@faker-js/faker": "^6.0.0-alpha.7",
|
|
64
64
|
"@mui/icons-material": "^5.4.2",
|
|
65
|
-
"@mui/material": "^5.4.
|
|
65
|
+
"@mui/material": "^5.4.3",
|
|
66
66
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
67
67
|
"@storybook/addon-a11y": "^6.4.19",
|
|
68
68
|
"@storybook/addon-actions": "^6.4.19",
|
|
@@ -86,8 +86,7 @@
|
|
|
86
86
|
"react-table": "^7.7.0",
|
|
87
87
|
"size-limit": "^7.0.8",
|
|
88
88
|
"storybook-addon-paddings": "^4.2.1",
|
|
89
|
-
"storybook-
|
|
90
|
-
"storybook-dark-mode": "^1.0.8",
|
|
89
|
+
"storybook-dark-mode": "^1.0.9",
|
|
91
90
|
"tsdx": "^0.14.1",
|
|
92
91
|
"tslib": "^2.3.1",
|
|
93
92
|
"typescript": "^4.5.5"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React, { ChangeEvent, MouseEvent, ReactNode } from 'react';
|
|
1
|
+
import React, { ChangeEvent, FC, MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
AlertProps,
|
|
4
|
+
IconButtonProps,
|
|
4
5
|
TableBodyProps,
|
|
5
6
|
TableCellProps,
|
|
6
7
|
TableContainerProps,
|
|
@@ -66,7 +67,7 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
66
67
|
enableSelection?: boolean;
|
|
67
68
|
hideTableFooter?: boolean;
|
|
68
69
|
hideTableHead?: boolean;
|
|
69
|
-
|
|
70
|
+
hideToolbarInternalActions?: boolean;
|
|
70
71
|
hideToolbarBottom?: boolean;
|
|
71
72
|
hideToolbarTop?: boolean;
|
|
72
73
|
isFetching?: boolean;
|
|
@@ -138,6 +139,7 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
138
139
|
row: Row<D>,
|
|
139
140
|
selectedRows: Row<D>[],
|
|
140
141
|
) => void;
|
|
142
|
+
onSelectAllChange?: (event: ChangeEvent, selectedRows: Row<D>[]) => void;
|
|
141
143
|
positionActionsColumn?: 'first' | 'last';
|
|
142
144
|
positionPagination?: 'bottom' | 'top' | 'both';
|
|
143
145
|
positionToolbarActions?: 'bottom' | 'top';
|
|
@@ -153,6 +155,22 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
153
155
|
tableInstance: TableInstance<D>,
|
|
154
156
|
) => ReactNode;
|
|
155
157
|
renderToolbarCustomActions?: (tableInstance: TableInstance<D>) => ReactNode;
|
|
158
|
+
renderToolbarInternalActions?: (
|
|
159
|
+
tableInstance: TableInstance<D>,
|
|
160
|
+
{
|
|
161
|
+
MRT_ToggleSearchButton,
|
|
162
|
+
MRT_ToggleFiltersButton,
|
|
163
|
+
MRT_ShowHideColumnsButton,
|
|
164
|
+
MRT_ToggleDensePaddingButton,
|
|
165
|
+
MRT_FullScreenToggleButton,
|
|
166
|
+
}: {
|
|
167
|
+
MRT_ToggleSearchButton: FC<IconButtonProps>;
|
|
168
|
+
MRT_ToggleFiltersButton: FC<IconButtonProps>;
|
|
169
|
+
MRT_ShowHideColumnsButton: FC<IconButtonProps>;
|
|
170
|
+
MRT_ToggleDensePaddingButton: FC<IconButtonProps>;
|
|
171
|
+
MRT_FullScreenToggleButton: FC<IconButtonProps>;
|
|
172
|
+
},
|
|
173
|
+
) => ReactNode;
|
|
156
174
|
};
|
|
157
175
|
|
|
158
176
|
export default <D extends {}>({
|
|
@@ -27,6 +27,7 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
27
27
|
const {
|
|
28
28
|
anyRowsCanExpand,
|
|
29
29
|
enableRowActions,
|
|
30
|
+
enableRowEditing,
|
|
30
31
|
enableRowNumbers,
|
|
31
32
|
enableSelection,
|
|
32
33
|
muiTableBodyRowProps,
|
|
@@ -62,7 +63,7 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
62
63
|
{enableRowNumbers && (
|
|
63
64
|
<MRT_StyledTableBodyCell>{row.index + 1}</MRT_StyledTableBodyCell>
|
|
64
65
|
)}
|
|
65
|
-
{enableRowActions && positionActionsColumn === 'first' && (
|
|
66
|
+
{(enableRowActions || enableRowEditing) && positionActionsColumn === 'first' && (
|
|
66
67
|
<MRT_ToggleRowActionMenuButton row={row} />
|
|
67
68
|
)}
|
|
68
69
|
{(anyRowsCanExpand || renderDetailPanel) && (
|
|
@@ -72,7 +73,7 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
72
73
|
{row.cells.map((cell) => (
|
|
73
74
|
<MRT_TableBodyCell key={cell.getCellProps().key} cell={cell} />
|
|
74
75
|
))}
|
|
75
|
-
{enableRowActions && positionActionsColumn === 'last' && (
|
|
76
|
+
{(enableRowActions || enableRowEditing) && positionActionsColumn === 'last' && (
|
|
76
77
|
<MRT_ToggleRowActionMenuButton row={row} />
|
|
77
78
|
)}
|
|
78
79
|
</TableRow>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { IconButton, Tooltip } from '@mui/material';
|
|
2
|
+
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import FilterListIcon from '@mui/icons-material/Fullscreen';
|
|
5
5
|
import FilterListOffIcon from '@mui/icons-material/FullscreenExit';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
interface Props extends IconButtonProps {}
|
|
8
8
|
|
|
9
|
-
export const MRT_FullScreenToggleButton: FC<Props> = () => {
|
|
9
|
+
export const MRT_FullScreenToggleButton: FC<Props> = ({ ...rest }) => {
|
|
10
10
|
const { localization, setFullScreen, fullScreen } = useMRT();
|
|
11
11
|
|
|
12
12
|
return (
|
|
@@ -15,6 +15,7 @@ export const MRT_FullScreenToggleButton: FC<Props> = () => {
|
|
|
15
15
|
aria-label={localization?.toggleFilterButtonTitle}
|
|
16
16
|
onClick={() => setFullScreen(!fullScreen)}
|
|
17
17
|
size="small"
|
|
18
|
+
{...rest}
|
|
18
19
|
>
|
|
19
20
|
{fullScreen ? <FilterListOffIcon /> : <FilterListIcon />}
|
|
20
21
|
</IconButton>
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
Tooltip,
|
|
7
7
|
styled,
|
|
8
8
|
Divider,
|
|
9
|
+
IconButtonProps,
|
|
9
10
|
} from '@mui/material';
|
|
10
11
|
import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
|
11
12
|
import { useMRT } from '../useMRT';
|
|
@@ -17,9 +18,9 @@ const MenuButtons = styled('div')({
|
|
|
17
18
|
padding: '0 0.5rem 0.5rem 0.5rem',
|
|
18
19
|
});
|
|
19
20
|
|
|
20
|
-
interface Props {}
|
|
21
|
+
interface Props extends IconButtonProps {}
|
|
21
22
|
|
|
22
|
-
export const MRT_ShowHideColumnsButton: FC<Props> = () => {
|
|
23
|
+
export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
|
|
23
24
|
const { tableInstance, localization } = useMRT();
|
|
24
25
|
|
|
25
26
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
@@ -35,6 +36,7 @@ export const MRT_ShowHideColumnsButton: FC<Props> = () => {
|
|
|
35
36
|
aria-label={localization?.showHideColumnsButtonTitle}
|
|
36
37
|
onClick={handleClick}
|
|
37
38
|
size="small"
|
|
39
|
+
{...rest}
|
|
38
40
|
>
|
|
39
41
|
<ViewColumnIcon />
|
|
40
42
|
</IconButton>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
-
import { IconButton as MuiIconButton, styled } from '@mui/material';
|
|
2
|
+
import { IconButton as MuiIconButton, styled, Tooltip } from '@mui/material';
|
|
3
3
|
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
4
4
|
import { useMRT } from '../useMRT';
|
|
5
5
|
import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
|
@@ -33,14 +33,20 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
33
33
|
|
|
34
34
|
return (
|
|
35
35
|
<>
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
title={localization?.columnActionMenuButtonTitle}
|
|
36
|
+
<Tooltip
|
|
37
|
+
arrow
|
|
38
|
+
enterDelay={1000}
|
|
39
|
+
enterNextDelay={1000}
|
|
40
|
+
title={localization?.columnActionMenuButtonTitle ?? ''}
|
|
41
41
|
>
|
|
42
|
-
<
|
|
43
|
-
|
|
42
|
+
<IconButton
|
|
43
|
+
aria-label={localization?.columnActionMenuButtonTitle}
|
|
44
|
+
onClick={handleClick}
|
|
45
|
+
size="small"
|
|
46
|
+
>
|
|
47
|
+
<MoreVertIcon />
|
|
48
|
+
</IconButton>
|
|
49
|
+
</Tooltip>
|
|
44
50
|
<MRT_ColumnActionMenu
|
|
45
51
|
anchorEl={anchorEl}
|
|
46
52
|
column={column}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
|
+
import DensityMediumIcon from '@mui/icons-material/DensityMedium';
|
|
5
|
+
import DensitySmallIcon from '@mui/icons-material/DensitySmall';
|
|
6
|
+
|
|
7
|
+
interface Props extends IconButtonProps {}
|
|
8
|
+
|
|
9
|
+
export const MRT_ToggleDensePaddingButton: FC<Props> = ({ ...rest }) => {
|
|
10
|
+
const { densePadding, setDensePadding, localization } = useMRT();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Tooltip arrow title={localization?.toggleDensePaddingSwitchTitle ?? ''}>
|
|
14
|
+
<IconButton
|
|
15
|
+
aria-label={localization?.toggleDensePaddingSwitchTitle}
|
|
16
|
+
onClick={() => setDensePadding(!densePadding)}
|
|
17
|
+
size="small"
|
|
18
|
+
{...rest}
|
|
19
|
+
>
|
|
20
|
+
{densePadding ? <DensitySmallIcon /> : <DensityMediumIcon />}
|
|
21
|
+
</IconButton>
|
|
22
|
+
</Tooltip>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { IconButton, Tooltip } from '@mui/material';
|
|
2
|
+
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import FilterListIcon from '@mui/icons-material/FilterList';
|
|
5
5
|
import FilterListOffIcon from '@mui/icons-material/FilterListOff';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
interface Props extends IconButtonProps {}
|
|
8
8
|
|
|
9
|
-
export const MRT_ToggleFiltersButton: FC<Props> = () => {
|
|
9
|
+
export const MRT_ToggleFiltersButton: FC<Props> = ({ ...rest }) => {
|
|
10
10
|
const { localization, setShowFilters, showFilters } = useMRT();
|
|
11
11
|
|
|
12
12
|
return (
|
|
@@ -15,6 +15,7 @@ export const MRT_ToggleFiltersButton: FC<Props> = () => {
|
|
|
15
15
|
aria-label={localization?.toggleFilterButtonTitle}
|
|
16
16
|
onClick={() => setShowFilters(!showFilters)}
|
|
17
17
|
size="small"
|
|
18
|
+
{...rest}
|
|
18
19
|
>
|
|
19
20
|
{showFilters ? <FilterListOffIcon /> : <FilterListIcon />}
|
|
20
21
|
</IconButton>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { IconButton, Tooltip } from '@mui/material';
|
|
2
|
+
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import SearchIcon from '@mui/icons-material/Search';
|
|
5
5
|
import SearchOffIcon from '@mui/icons-material/SearchOff';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
interface Props extends IconButtonProps {}
|
|
8
8
|
|
|
9
|
-
export const MRT_ToggleSearchButton: FC<Props> = () => {
|
|
9
|
+
export const MRT_ToggleSearchButton: FC<Props> = ({ ...rest }) => {
|
|
10
10
|
const { localization, setShowSearch, showSearch, muiSearchTextFieldProps } =
|
|
11
11
|
useMRT();
|
|
12
12
|
|
|
@@ -25,7 +25,7 @@ export const MRT_ToggleSearchButton: FC<Props> = () => {
|
|
|
25
25
|
|
|
26
26
|
return (
|
|
27
27
|
<Tooltip arrow title={localization?.toggleSearchButtonTitle ?? ''}>
|
|
28
|
-
<IconButton size="small" onClick={handleToggleSearch}>
|
|
28
|
+
<IconButton size="small" onClick={handleToggleSearch} {...rest}>
|
|
29
29
|
{showSearch ? <SearchOffIcon /> : <SearchIcon />}
|
|
30
30
|
</IconButton>
|
|
31
31
|
</Tooltip>
|
|
@@ -11,15 +11,16 @@ interface Props {
|
|
|
11
11
|
|
|
12
12
|
export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
|
|
13
13
|
const {
|
|
14
|
-
renderDetailPanel,
|
|
15
|
-
columns,
|
|
16
14
|
anyRowsCanExpand,
|
|
17
|
-
|
|
15
|
+
columns,
|
|
18
16
|
enableRowActions,
|
|
17
|
+
enableRowEditing,
|
|
19
18
|
enableRowNumbers,
|
|
19
|
+
enableSelection,
|
|
20
|
+
muiTableFooterRowProps,
|
|
20
21
|
positionActionsColumn,
|
|
22
|
+
renderDetailPanel,
|
|
21
23
|
tableInstance,
|
|
22
|
-
muiTableFooterRowProps,
|
|
23
24
|
} = useMRT();
|
|
24
25
|
|
|
25
26
|
//if no content in row, skip row
|
|
@@ -42,9 +43,8 @@ export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
|
|
|
42
43
|
return (
|
|
43
44
|
<TableRow {...tableRowProps}>
|
|
44
45
|
{enableRowNumbers && <MRT_TableSpacerCell />}
|
|
45
|
-
{enableRowActions
|
|
46
|
-
<MRT_TableSpacerCell />
|
|
47
|
-
)}
|
|
46
|
+
{(enableRowActions || enableRowEditing) &&
|
|
47
|
+
positionActionsColumn === 'first' && <MRT_TableSpacerCell />}
|
|
48
48
|
{(anyRowsCanExpand || renderDetailPanel) && (
|
|
49
49
|
<MRT_TableSpacerCell
|
|
50
50
|
width={`${
|
|
@@ -59,9 +59,8 @@ export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
|
|
|
59
59
|
column={column}
|
|
60
60
|
/>
|
|
61
61
|
))}
|
|
62
|
-
{enableRowActions
|
|
63
|
-
<MRT_TableSpacerCell />
|
|
64
|
-
)}
|
|
62
|
+
{(enableRowActions || enableRowEditing) &&
|
|
63
|
+
positionActionsColumn === 'last' && <MRT_TableSpacerCell />}
|
|
65
64
|
</TableRow>
|
|
66
65
|
);
|
|
67
66
|
};
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
styled,
|
|
6
6
|
Divider as MuiDivider,
|
|
7
7
|
Collapse,
|
|
8
|
+
Tooltip,
|
|
8
9
|
} from '@mui/material';
|
|
9
10
|
import { HeaderGroup } from 'react-table';
|
|
10
11
|
import { useMRT } from '../useMRT';
|
|
@@ -89,6 +90,18 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
89
90
|
},
|
|
90
91
|
};
|
|
91
92
|
|
|
93
|
+
const sortTooltip = column.isSorted
|
|
94
|
+
? column.isSortedDesc
|
|
95
|
+
? localization?.columnActionMenuItemClearSort ?? ''
|
|
96
|
+
: localization?.columnActionMenuItemSortDesc?.replace(
|
|
97
|
+
'{column}',
|
|
98
|
+
column.Header as string,
|
|
99
|
+
) ?? ''
|
|
100
|
+
: localization?.columnActionMenuItemSortAsc?.replace(
|
|
101
|
+
'{column}',
|
|
102
|
+
column.Header as string,
|
|
103
|
+
) ?? '';
|
|
104
|
+
|
|
92
105
|
return (
|
|
93
106
|
<MRT_StyledTableHeadCell
|
|
94
107
|
align={isParentHeader ? 'center' : 'left'}
|
|
@@ -100,20 +113,16 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
100
113
|
<TableCellTopContents
|
|
101
114
|
style={{ justifyContent: isParentHeader ? 'center' : undefined }}
|
|
102
115
|
>
|
|
103
|
-
<CellFlexItem {...column.getSortByToggleProps()}>
|
|
116
|
+
<CellFlexItem {...column.getSortByToggleProps()} title={undefined}>
|
|
104
117
|
{column.render('Header')}
|
|
105
118
|
{!isParentHeader && column.canSort && (
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
active={column.isSorted}
|
|
115
|
-
direction={column.isSortedDesc ? 'desc' : 'asc'}
|
|
116
|
-
/>
|
|
119
|
+
<Tooltip arrow title={sortTooltip}>
|
|
120
|
+
<TableSortLabel
|
|
121
|
+
aria-label={sortTooltip}
|
|
122
|
+
active={column.isSorted}
|
|
123
|
+
direction={column.isSortedDesc ? 'desc' : 'asc'}
|
|
124
|
+
/>
|
|
125
|
+
</Tooltip>
|
|
117
126
|
)}
|
|
118
127
|
</CellFlexItem>
|
|
119
128
|
<CellFlexItem>
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
MRT_TableHeadCell,
|
|
7
7
|
} from './MRT_TableHeadCell';
|
|
8
8
|
import { useMRT } from '../useMRT';
|
|
9
|
-
import {
|
|
9
|
+
import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
|
10
10
|
import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton';
|
|
11
11
|
import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
|
|
12
12
|
import { MRT_TableHeadCellActions } from './MRT_TableHeadCellActions';
|
|
@@ -19,8 +19,9 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
19
19
|
const {
|
|
20
20
|
anyRowsCanExpand,
|
|
21
21
|
disableExpandAll,
|
|
22
|
-
enableRowNumbers,
|
|
23
22
|
enableRowActions,
|
|
23
|
+
enableRowEditing,
|
|
24
|
+
enableRowNumbers,
|
|
24
25
|
enableSelection,
|
|
25
26
|
muiTableHeadRowProps,
|
|
26
27
|
positionActionsColumn,
|
|
@@ -55,7 +56,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
55
56
|
) : (
|
|
56
57
|
<MRT_StyledTableHeadCell>#</MRT_StyledTableHeadCell>
|
|
57
58
|
))}
|
|
58
|
-
{enableRowActions &&
|
|
59
|
+
{(enableRowActions || enableRowEditing) &&
|
|
59
60
|
positionActionsColumn === 'first' &&
|
|
60
61
|
(isParentHeader ? (
|
|
61
62
|
<MRT_TableSpacerCell />
|
|
@@ -75,7 +76,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
75
76
|
) : null}
|
|
76
77
|
{enableSelection ? (
|
|
77
78
|
!isParentHeader ? (
|
|
78
|
-
<
|
|
79
|
+
<MRT_SelectCheckbox selectAll />
|
|
79
80
|
) : (
|
|
80
81
|
<MRT_TableSpacerCell width="1rem" />
|
|
81
82
|
)
|
|
@@ -83,7 +84,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
83
84
|
{headerGroup.headers.map((column: HeaderGroup) => (
|
|
84
85
|
<MRT_TableHeadCell key={column.getHeaderProps().key} column={column} />
|
|
85
86
|
))}
|
|
86
|
-
{enableRowActions &&
|
|
87
|
+
{(enableRowActions || enableRowEditing) &&
|
|
87
88
|
positionActionsColumn === 'last' &&
|
|
88
89
|
(isParentHeader ? (
|
|
89
90
|
<MRT_TableSpacerCell />
|
|
@@ -10,7 +10,6 @@ interface Props {
|
|
|
10
10
|
export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
|
|
11
11
|
const {
|
|
12
12
|
currentEditingRow,
|
|
13
|
-
localization,
|
|
14
13
|
muiTableBodyCellEditTextFieldProps,
|
|
15
14
|
setCurrentEditingRow,
|
|
16
15
|
} = useMRT();
|
|
@@ -55,7 +54,7 @@ export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
|
|
|
55
54
|
margin="dense"
|
|
56
55
|
onChange={handleChange}
|
|
57
56
|
onClick={(e) => e.stopPropagation()}
|
|
58
|
-
placeholder={
|
|
57
|
+
placeholder={cell.column.Header as string}
|
|
59
58
|
value={cell.value}
|
|
60
59
|
variant="standard"
|
|
61
60
|
{...textFieldProps}
|
|
@@ -1,31 +1,60 @@
|
|
|
1
1
|
import React, { ChangeEvent, FC } from 'react';
|
|
2
|
-
import { Checkbox } from '@mui/material';
|
|
2
|
+
import { Checkbox, Tooltip } from '@mui/material';
|
|
3
3
|
import { Row } from 'react-table';
|
|
4
4
|
import { useMRT } from '../useMRT';
|
|
5
5
|
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
|
-
row
|
|
8
|
+
row?: Row;
|
|
9
|
+
selectAll?: boolean;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export const MRT_SelectCheckbox: FC<Props> = ({ row }) => {
|
|
12
|
-
const {
|
|
13
|
-
|
|
12
|
+
export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
|
|
13
|
+
const {
|
|
14
|
+
densePadding,
|
|
15
|
+
localization,
|
|
16
|
+
onRowSelectChange,
|
|
17
|
+
onSelectAllChange,
|
|
18
|
+
tableInstance,
|
|
19
|
+
} = useMRT();
|
|
14
20
|
|
|
15
|
-
const onSelectChange = (event: ChangeEvent) => {
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
const onSelectChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
22
|
+
if (selectAll) {
|
|
23
|
+
onSelectAllChange?.(event, tableInstance.selectedFlatRows);
|
|
24
|
+
tableInstance.toggleAllRowsSelected(event.target.checked);
|
|
25
|
+
} else if (row) {
|
|
26
|
+
row?.getToggleRowSelectedProps()?.onChange?.(event);
|
|
27
|
+
onRowSelectChange?.(event, row, tableInstance.selectedFlatRows);
|
|
28
|
+
}
|
|
18
29
|
};
|
|
19
30
|
|
|
31
|
+
const checkboxProps = selectAll
|
|
32
|
+
? tableInstance.getToggleAllRowsSelectedProps()
|
|
33
|
+
: row?.getToggleRowSelectedProps();
|
|
34
|
+
|
|
20
35
|
return (
|
|
21
36
|
<MRT_TableButtonCell densePadding={densePadding}>
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
<Tooltip
|
|
38
|
+
arrow
|
|
39
|
+
enterDelay={1000}
|
|
40
|
+
enterNextDelay={1000}
|
|
41
|
+
title={
|
|
42
|
+
selectAll
|
|
43
|
+
? localization?.selectAllCheckboxTitle ?? ''
|
|
44
|
+
: localization?.selectCheckboxTitle ?? ''
|
|
45
|
+
}
|
|
46
|
+
>
|
|
47
|
+
<Checkbox
|
|
48
|
+
inputProps={{
|
|
49
|
+
'aria-label': selectAll
|
|
50
|
+
? localization?.selectAllCheckboxTitle ?? ''
|
|
51
|
+
: localization?.selectCheckboxTitle ?? '',
|
|
52
|
+
}}
|
|
53
|
+
onChange={onSelectChange}
|
|
54
|
+
{...checkboxProps}
|
|
55
|
+
title={undefined}
|
|
56
|
+
/>
|
|
57
|
+
</Tooltip>
|
|
29
58
|
</MRT_TableButtonCell>
|
|
30
59
|
);
|
|
31
60
|
};
|
|
@@ -14,12 +14,12 @@ import { MRT_ToolbarBottom } from '../toolbar/MRT_ToolbarBottom';
|
|
|
14
14
|
|
|
15
15
|
const TableContainer = styled(MuiTableContainer, {
|
|
16
16
|
shouldForwardProp: (prop) => prop !== 'fullScreen',
|
|
17
|
-
})<{ fullScreen?: boolean; component
|
|
17
|
+
})<{ fullScreen?: boolean; component: any }>(({ fullScreen }) => ({
|
|
18
18
|
bottom: fullScreen ? '0' : undefined,
|
|
19
19
|
height: fullScreen ? '100%' : undefined,
|
|
20
20
|
left: fullScreen ? '0' : undefined,
|
|
21
21
|
margin: fullScreen ? '0' : undefined,
|
|
22
|
-
position: fullScreen ? '
|
|
22
|
+
position: fullScreen ? 'fixed' : undefined,
|
|
23
23
|
right: fullScreen ? '0' : undefined,
|
|
24
24
|
top: fullScreen ? '0' : undefined,
|
|
25
25
|
transition: 'all 0.2s ease-in-out',
|
|
@@ -25,6 +25,7 @@ export const MRT_TablePagination: FC<Props> = () => {
|
|
|
25
25
|
onRowsPerPageChange={handleChangeRowsPerPage}
|
|
26
26
|
page={tableInstance.state.pageIndex}
|
|
27
27
|
rowsPerPage={tableInstance.state.pageSize}
|
|
28
|
+
SelectProps={{ style: { margin: '0 1rem 0 1ch' } }}
|
|
28
29
|
showFirstButton={
|
|
29
30
|
tableInstance.rows.length / tableInstance.state.pageSize > 2
|
|
30
31
|
}
|
|
@@ -1,25 +1,37 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { styled, Toolbar as MuiToolbar } from '@mui/material';
|
|
2
|
+
import { alpha, styled, Toolbar as MuiToolbar } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
5
5
|
import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
|
|
6
6
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
7
7
|
|
|
8
|
-
const Toolbar = styled(MuiToolbar
|
|
8
|
+
const Toolbar = styled(MuiToolbar, {
|
|
9
|
+
shouldForwardProp: (prop) => prop !== 'fullScreen',
|
|
10
|
+
})<{ fullScreen?: boolean }>(({ fullScreen, theme }) => ({
|
|
11
|
+
backgroundColor: theme.palette.background.default,
|
|
12
|
+
backgroundImage: `linear-gradient(${alpha(
|
|
13
|
+
theme.palette.common.white,
|
|
14
|
+
0.05,
|
|
15
|
+
)},${alpha(theme.palette.common.white, 0.05)})`,
|
|
16
|
+
bottom: fullScreen ? '0' : undefined,
|
|
9
17
|
display: 'flex',
|
|
10
18
|
justifyContent: 'space-between',
|
|
11
|
-
padding: '0 0.5rem !important',
|
|
12
19
|
overflowY: 'hidden',
|
|
13
|
-
|
|
20
|
+
padding: '0 0.5rem !important',
|
|
21
|
+
position: fullScreen ? 'fixed' : undefined,
|
|
22
|
+
width: 'calc(100% - 1rem)',
|
|
23
|
+
zIndex: 1,
|
|
24
|
+
}));
|
|
14
25
|
|
|
15
26
|
interface Props {}
|
|
16
27
|
|
|
17
28
|
export const MRT_ToolbarBottom: FC<Props> = () => {
|
|
18
29
|
const {
|
|
19
|
-
|
|
30
|
+
hideToolbarInternalActions,
|
|
20
31
|
manualPagination,
|
|
21
32
|
muiTableToolbarBottomProps,
|
|
22
33
|
positionPagination,
|
|
34
|
+
fullScreen,
|
|
23
35
|
positionToolbarActions,
|
|
24
36
|
positionToolbarAlertBanner,
|
|
25
37
|
tableInstance,
|
|
@@ -31,8 +43,8 @@ export const MRT_ToolbarBottom: FC<Props> = () => {
|
|
|
31
43
|
: muiTableToolbarBottomProps;
|
|
32
44
|
|
|
33
45
|
return (
|
|
34
|
-
<Toolbar variant="dense" {...toolbarProps}>
|
|
35
|
-
{!
|
|
46
|
+
<Toolbar fullScreen={fullScreen} variant="dense" {...toolbarProps}>
|
|
47
|
+
{!hideToolbarInternalActions && positionToolbarActions === 'bottom' ? (
|
|
36
48
|
<MRT_ToolbarInternalButtons />
|
|
37
49
|
) : (
|
|
38
50
|
<span />
|
|
@@ -3,7 +3,7 @@ import { styled } from '@mui/material';
|
|
|
3
3
|
import { MRT_ToggleFiltersButton } from '../buttons/MRT_ToggleFiltersButton';
|
|
4
4
|
import { MRT_ShowHideColumnsButton } from '../buttons/MRT_ShowHideColumnsButton';
|
|
5
5
|
import { useMRT } from '../useMRT';
|
|
6
|
-
import {
|
|
6
|
+
import { MRT_ToggleDensePaddingButton } from '../buttons/MRT_ToggleDensePaddingButton';
|
|
7
7
|
import { MRT_ToggleSearchButton } from '../buttons/MRT_ToggleSearchButton';
|
|
8
8
|
import { MRT_FullScreenToggleButton } from '../buttons/MRT_FullScreenToggleButton';
|
|
9
9
|
|
|
@@ -22,14 +22,30 @@ export const MRT_ToolbarInternalButtons: FC<Props> = () => {
|
|
|
22
22
|
disableDensePaddingToggle,
|
|
23
23
|
disableGlobalFilter,
|
|
24
24
|
disableFullScreenToggle,
|
|
25
|
+
renderToolbarInternalActions,
|
|
26
|
+
tableInstance,
|
|
25
27
|
} = useMRT();
|
|
26
28
|
|
|
29
|
+
if (renderToolbarInternalActions) {
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
{renderToolbarInternalActions(tableInstance, {
|
|
33
|
+
MRT_ToggleSearchButton,
|
|
34
|
+
MRT_ToggleFiltersButton,
|
|
35
|
+
MRT_ShowHideColumnsButton,
|
|
36
|
+
MRT_ToggleDensePaddingButton,
|
|
37
|
+
MRT_FullScreenToggleButton,
|
|
38
|
+
})}
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
27
43
|
return (
|
|
28
44
|
<ToolbarButtonsContainer>
|
|
29
45
|
{!disableGlobalFilter && <MRT_ToggleSearchButton />}
|
|
30
46
|
{!disableFilters && <MRT_ToggleFiltersButton />}
|
|
31
47
|
{!disableColumnHiding && <MRT_ShowHideColumnsButton />}
|
|
32
|
-
{!disableDensePaddingToggle && <
|
|
48
|
+
{!disableDensePaddingToggle && <MRT_ToggleDensePaddingButton />}
|
|
33
49
|
{!disableFullScreenToggle && <MRT_FullScreenToggleButton />}
|
|
34
50
|
</ToolbarButtonsContainer>
|
|
35
51
|
);
|