material-react-table 0.4.4 → 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 +7 -6
- 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 +2 -1
- 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 +107 -85
- 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 +108 -86
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +5 -6
- package/src/MaterialReactTable.tsx +7 -5
- 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 +4 -3
- 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 +1 -9
- package/src/toolbar/MRT_TablePagination.tsx +1 -0
- 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.",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
],
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@babel/core": "^7.17.5",
|
|
60
|
-
"@emotion/react": "^11.8.
|
|
61
|
-
"@emotion/styled": "^11.8.
|
|
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,7 +86,6 @@
|
|
|
86
86
|
"react-table": "^7.7.0",
|
|
87
87
|
"size-limit": "^7.0.8",
|
|
88
88
|
"storybook-addon-paddings": "^4.2.1",
|
|
89
|
-
"storybook-addon-performance": "^0.16.1",
|
|
90
89
|
"storybook-dark-mode": "^1.0.9",
|
|
91
90
|
"tsdx": "^0.14.1",
|
|
92
91
|
"tslib": "^2.3.1",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
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,
|
|
@@ -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';
|
|
@@ -162,11 +164,11 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
162
164
|
MRT_ToggleDensePaddingButton,
|
|
163
165
|
MRT_FullScreenToggleButton,
|
|
164
166
|
}: {
|
|
165
|
-
MRT_ToggleSearchButton: FC
|
|
166
|
-
MRT_ToggleFiltersButton: FC
|
|
167
|
-
MRT_ShowHideColumnsButton: FC
|
|
168
|
-
MRT_ToggleDensePaddingButton: FC
|
|
169
|
-
MRT_FullScreenToggleButton: FC
|
|
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>;
|
|
170
172
|
},
|
|
171
173
|
) => ReactNode;
|
|
172
174
|
};
|
|
@@ -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}
|
|
@@ -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 DensityMediumIcon from '@mui/icons-material/DensityMedium';
|
|
5
5
|
import DensitySmallIcon from '@mui/icons-material/DensitySmall';
|
|
6
6
|
|
|
7
|
-
interface Props {}
|
|
7
|
+
interface Props extends IconButtonProps {}
|
|
8
8
|
|
|
9
|
-
export const MRT_ToggleDensePaddingButton: FC<Props> = () => {
|
|
9
|
+
export const MRT_ToggleDensePaddingButton: FC<Props> = ({ ...rest }) => {
|
|
10
10
|
const { densePadding, setDensePadding, localization } = useMRT();
|
|
11
11
|
|
|
12
12
|
return (
|
|
@@ -15,6 +15,7 @@ export const MRT_ToggleDensePaddingButton: FC<Props> = () => {
|
|
|
15
15
|
aria-label={localization?.toggleDensePaddingSwitchTitle}
|
|
16
16
|
onClick={() => setDensePadding(!densePadding)}
|
|
17
17
|
size="small"
|
|
18
|
+
{...rest}
|
|
18
19
|
>
|
|
19
20
|
{densePadding ? <DensitySmallIcon /> : <DensityMediumIcon />}
|
|
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 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
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
CircularProgress,
|
|
4
4
|
LinearProgress,
|
|
@@ -51,14 +51,6 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
51
51
|
tableInstance,
|
|
52
52
|
} = useMRT();
|
|
53
53
|
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (fullScreen) {
|
|
56
|
-
document.body.style.overflow = 'hidden';
|
|
57
|
-
} else {
|
|
58
|
-
document.body.style.overflow = 'auto';
|
|
59
|
-
}
|
|
60
|
-
}, [fullScreen]);
|
|
61
|
-
|
|
62
54
|
const tableContainerProps =
|
|
63
55
|
muiTableContainerProps instanceof Function
|
|
64
56
|
? muiTableContainerProps(tableInstance)
|
|
@@ -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
|
}
|
|
@@ -35,7 +35,7 @@ export interface MRT_Localization {
|
|
|
35
35
|
export const defaultLocalization: MRT_Localization = {
|
|
36
36
|
actionsHeadColumnTitle: 'Actions',
|
|
37
37
|
columnActionMenuButtonTitle: 'Column Actions',
|
|
38
|
-
columnActionMenuItemClearSort: 'Clear
|
|
38
|
+
columnActionMenuItemClearSort: 'Clear sort',
|
|
39
39
|
columnActionMenuItemGroupBy: 'Group by {column}',
|
|
40
40
|
columnActionMenuItemHideColumn: 'Hide {column} column',
|
|
41
41
|
columnActionMenuItemSortAsc: 'Sort by {column} ascending',
|
|
@@ -54,8 +54,8 @@ export const defaultLocalization: MRT_Localization = {
|
|
|
54
54
|
rowActionsColumnTitle: 'Actions',
|
|
55
55
|
searchTextFieldClearButtonTitle: 'Clear search',
|
|
56
56
|
searchTextFieldPlaceholder: 'Search',
|
|
57
|
-
selectAllCheckboxTitle: '
|
|
58
|
-
selectCheckboxTitle: '
|
|
57
|
+
selectAllCheckboxTitle: 'Toggle select all',
|
|
58
|
+
selectCheckboxTitle: 'Toggle select row',
|
|
59
59
|
showHideColumnsButtonTitle: 'Show/Hide columns',
|
|
60
60
|
toggleDensePaddingSwitchTitle: 'Toggle dense padding',
|
|
61
61
|
toggleFilterButtonTitle: 'Toggle filters',
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
import { Switch, Tooltip } from '@mui/material';
|
|
3
|
-
import { useMRT } from '../useMRT';
|
|
4
|
-
|
|
5
|
-
interface Props {}
|
|
6
|
-
|
|
7
|
-
export const MRT_DensePaddingSwitch: FC<Props> = () => {
|
|
8
|
-
const { densePadding, setDensePadding, localization } = useMRT();
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<Tooltip arrow title={localization?.toggleDensePaddingSwitchTitle ?? ''}>
|
|
12
|
-
<Switch
|
|
13
|
-
inputProps={{
|
|
14
|
-
'aria-label': localization?.toggleDensePaddingSwitchTitle ?? '',
|
|
15
|
-
}}
|
|
16
|
-
color="default"
|
|
17
|
-
checked={densePadding}
|
|
18
|
-
size="small"
|
|
19
|
-
onChange={() => setDensePadding(!densePadding)}
|
|
20
|
-
/>
|
|
21
|
-
</Tooltip>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Checkbox } from '@mui/material';
|
|
3
|
-
import { useMRT } from '../useMRT';
|
|
4
|
-
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
5
|
-
|
|
6
|
-
export const MRT_SelectAllCheckbox = () => {
|
|
7
|
-
const { tableInstance, disableSelectAll, densePadding, localization } =
|
|
8
|
-
useMRT();
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<MRT_TableButtonCell densePadding={densePadding} variant="head">
|
|
12
|
-
{!disableSelectAll ? (
|
|
13
|
-
<Checkbox
|
|
14
|
-
inputProps={{
|
|
15
|
-
'aria-label': localization?.selectAllCheckboxTitle ?? '',
|
|
16
|
-
}}
|
|
17
|
-
{...tableInstance.getToggleAllPageRowsSelectedProps()}
|
|
18
|
-
/>
|
|
19
|
-
) : null}
|
|
20
|
-
</MRT_TableButtonCell>
|
|
21
|
-
);
|
|
22
|
-
};
|