material-react-table 0.4.4 → 0.4.7
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 +3 -2
- package/dist/MaterialReactTable.d.ts +13 -10
- 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/icons.d.ts +25 -0
- package/dist/inputs/MRT_SelectCheckbox.d.ts +2 -1
- package/dist/{utils/localization.d.ts → localization.d.ts} +1 -1
- package/dist/material-react-table.cjs.development.js +273 -209
- 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 +274 -210
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/useMRT.d.ts +6 -2
- package/package.json +5 -6
- package/src/MaterialReactTable.tsx +16 -10
- package/src/body/MRT_TableBodyRow.tsx +9 -6
- package/src/body/MRT_TableDetailPanel.tsx +6 -13
- package/src/buttons/MRT_EditActionButtons.tsx +5 -6
- package/src/buttons/MRT_ExpandAllButton.tsx +17 -18
- package/src/buttons/MRT_ExpandButton.tsx +18 -19
- package/src/buttons/MRT_FullScreenToggleButton.tsx +13 -9
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +13 -8
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +18 -10
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +12 -8
- package/src/buttons/MRT_ToggleFiltersButton.tsx +12 -8
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +6 -7
- package/src/buttons/MRT_ToggleSearchButton.tsx +12 -9
- package/src/footer/MRT_TableFooterRow.tsx +9 -10
- package/src/head/MRT_TableHeadCell.tsx +21 -12
- package/src/head/MRT_TableHeadCellActions.tsx +1 -1
- package/src/head/MRT_TableHeadRow.tsx +6 -5
- package/src/icons.tsx +72 -0
- package/src/inputs/MRT_EditCellTextField.tsx +1 -2
- package/src/inputs/MRT_FilterTextField.tsx +12 -13
- package/src/inputs/MRT_SearchTextField.tsx +4 -5
- package/src/inputs/MRT_SelectCheckbox.tsx +44 -15
- package/src/{utils/localization.ts → localization.ts} +4 -4
- package/src/menus/MRT_ColumnActionMenu.tsx +14 -12
- package/src/menus/MRT_RowActionMenu.tsx +2 -2
- package/src/table/MRT_TableContainer.tsx +15 -5
- package/src/toolbar/MRT_TablePagination.tsx +1 -0
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +3 -3
- package/src/useMRT.tsx +6 -2
- 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
|
@@ -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 />
|
package/src/icons.tsx
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import CancelIcon from '@mui/icons-material/Cancel';
|
|
2
|
+
import ClearAllIcon from '@mui/icons-material/ClearAll';
|
|
3
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
4
|
+
import DensityMediumIcon from '@mui/icons-material/DensityMedium';
|
|
5
|
+
import DensitySmallIcon from '@mui/icons-material/DensitySmall';
|
|
6
|
+
import DoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
|
|
7
|
+
import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
|
|
8
|
+
import EditIcon from '@mui/icons-material/Edit';
|
|
9
|
+
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
|
10
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
11
|
+
import FilterListIcon from '@mui/icons-material/FilterList';
|
|
12
|
+
import FilterListOffIcon from '@mui/icons-material/FilterListOff';
|
|
13
|
+
import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
|
|
14
|
+
import FullscreenIcon from '@mui/icons-material/Fullscreen';
|
|
15
|
+
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
|
16
|
+
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
17
|
+
import SaveIcon from '@mui/icons-material/Save';
|
|
18
|
+
import SearchIcon from '@mui/icons-material/Search';
|
|
19
|
+
import SearchOffIcon from '@mui/icons-material/SearchOff';
|
|
20
|
+
import SortIcon from '@mui/icons-material/Sort';
|
|
21
|
+
import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
|
22
|
+
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
|
23
|
+
|
|
24
|
+
export interface MRT_Icons {
|
|
25
|
+
CancelIcon: any;
|
|
26
|
+
ClearAllIcon: any;
|
|
27
|
+
CloseIcon: any;
|
|
28
|
+
DensityMediumIcon: any;
|
|
29
|
+
DensitySmallIcon: any;
|
|
30
|
+
DoubleArrowDownIcon: any;
|
|
31
|
+
DynamicFeedIcon: any;
|
|
32
|
+
EditIcon: any;
|
|
33
|
+
ExpandLessIcon: any;
|
|
34
|
+
ExpandMoreIcon: any;
|
|
35
|
+
FilterListIcon: any;
|
|
36
|
+
FilterListOffIcon: any;
|
|
37
|
+
FullscreenExitIcon: any;
|
|
38
|
+
FullscreenIcon: any;
|
|
39
|
+
MoreHorizIcon: any;
|
|
40
|
+
MoreVertIcon: any;
|
|
41
|
+
SaveIcon: any;
|
|
42
|
+
SearchIcon: any;
|
|
43
|
+
SearchOffIcon: any;
|
|
44
|
+
SortIcon: any;
|
|
45
|
+
ViewColumnIcon: any;
|
|
46
|
+
VisibilityOffIcon: any;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const MRT_Default_Icons: MRT_Icons = {
|
|
50
|
+
CancelIcon,
|
|
51
|
+
ClearAllIcon,
|
|
52
|
+
CloseIcon,
|
|
53
|
+
DensityMediumIcon,
|
|
54
|
+
DensitySmallIcon,
|
|
55
|
+
DoubleArrowDownIcon,
|
|
56
|
+
DynamicFeedIcon,
|
|
57
|
+
EditIcon,
|
|
58
|
+
ExpandLessIcon,
|
|
59
|
+
ExpandMoreIcon,
|
|
60
|
+
FilterListIcon,
|
|
61
|
+
FilterListOffIcon,
|
|
62
|
+
FullscreenExitIcon,
|
|
63
|
+
FullscreenIcon,
|
|
64
|
+
MoreHorizIcon,
|
|
65
|
+
MoreVertIcon,
|
|
66
|
+
SaveIcon,
|
|
67
|
+
SearchIcon,
|
|
68
|
+
SearchOffIcon,
|
|
69
|
+
SortIcon,
|
|
70
|
+
ViewColumnIcon,
|
|
71
|
+
VisibilityOffIcon,
|
|
72
|
+
};
|
|
@@ -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,7 +1,5 @@
|
|
|
1
1
|
import React, { ChangeEvent, FC, useState } from 'react';
|
|
2
2
|
import { IconButton, InputAdornment, TextField, Tooltip } from '@mui/material';
|
|
3
|
-
import CloseIcon from '@mui/icons-material/Close';
|
|
4
|
-
import FilterIcon from '@mui/icons-material/FilterList';
|
|
5
3
|
import { HeaderGroup, useAsyncDebounce } from 'react-table';
|
|
6
4
|
import { useMRT } from '../useMRT';
|
|
7
5
|
|
|
@@ -10,7 +8,10 @@ interface Props {
|
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
13
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
icons: { FilterListIcon, CloseIcon },
|
|
13
|
+
localization,
|
|
14
|
+
} = useMRT();
|
|
14
15
|
|
|
15
16
|
const [filterValue, setFilterValue] = useState('');
|
|
16
17
|
|
|
@@ -37,7 +38,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
37
38
|
},
|
|
38
39
|
}}
|
|
39
40
|
margin="dense"
|
|
40
|
-
placeholder={localization
|
|
41
|
+
placeholder={localization.filterTextFieldPlaceholder?.replace(
|
|
41
42
|
'{column}',
|
|
42
43
|
String(column.Header),
|
|
43
44
|
)}
|
|
@@ -52,15 +53,13 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
52
53
|
startAdornment: (
|
|
53
54
|
<Tooltip
|
|
54
55
|
arrow
|
|
55
|
-
title={
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
) ?? ''
|
|
60
|
-
}
|
|
56
|
+
title={localization.filterTextFieldPlaceholder?.replace(
|
|
57
|
+
'{column}',
|
|
58
|
+
String(column.Header),
|
|
59
|
+
)}
|
|
61
60
|
>
|
|
62
61
|
<InputAdornment position="start">
|
|
63
|
-
<
|
|
62
|
+
<FilterListIcon />
|
|
64
63
|
</InputAdornment>
|
|
65
64
|
</Tooltip>
|
|
66
65
|
),
|
|
@@ -68,11 +67,11 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
68
67
|
<InputAdornment position="end">
|
|
69
68
|
<Tooltip
|
|
70
69
|
arrow
|
|
71
|
-
title={localization
|
|
70
|
+
title={localization.filterTextFieldClearButtonTitle ?? ''}
|
|
72
71
|
>
|
|
73
72
|
<span>
|
|
74
73
|
<IconButton
|
|
75
|
-
aria-label={localization
|
|
74
|
+
aria-label={localization.filterTextFieldClearButtonTitle}
|
|
76
75
|
disabled={filterValue?.length === 0}
|
|
77
76
|
onClick={handleClear}
|
|
78
77
|
size="small"
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
styled,
|
|
7
7
|
TextField as MuiTextField,
|
|
8
8
|
} from '@mui/material';
|
|
9
|
-
import SearchIcon from '@mui/icons-material/Search';
|
|
10
|
-
import CloseIcon from '@mui/icons-material/Close';
|
|
11
9
|
import { useMRT } from '../useMRT';
|
|
12
10
|
import { useAsyncDebounce } from 'react-table';
|
|
13
11
|
|
|
@@ -19,6 +17,7 @@ interface Props {}
|
|
|
19
17
|
|
|
20
18
|
export const MRT_SearchTextField: FC<Props> = () => {
|
|
21
19
|
const {
|
|
20
|
+
icons: { SearchIcon, CloseIcon },
|
|
22
21
|
showSearch,
|
|
23
22
|
localization,
|
|
24
23
|
muiSearchTextFieldProps,
|
|
@@ -45,7 +44,7 @@ export const MRT_SearchTextField: FC<Props> = () => {
|
|
|
45
44
|
<Collapse in={showSearch} orientation="horizontal">
|
|
46
45
|
<TextField
|
|
47
46
|
id="global-search-text-field"
|
|
48
|
-
placeholder={localization
|
|
47
|
+
placeholder={localization.searchTextFieldPlaceholder}
|
|
49
48
|
onChange={(event: ChangeEvent<HTMLInputElement>) => {
|
|
50
49
|
setSearchValue(event.target.value);
|
|
51
50
|
handleChange(event);
|
|
@@ -61,11 +60,11 @@ export const MRT_SearchTextField: FC<Props> = () => {
|
|
|
61
60
|
endAdornment: (
|
|
62
61
|
<InputAdornment position="end">
|
|
63
62
|
<IconButton
|
|
64
|
-
aria-label={localization
|
|
63
|
+
aria-label={localization.searchTextFieldClearButtonTitle}
|
|
65
64
|
disabled={searchValue?.length === 0}
|
|
66
65
|
onClick={handleClear}
|
|
67
66
|
size="small"
|
|
68
|
-
title={localization
|
|
67
|
+
title={localization.searchTextFieldClearButtonTitle}
|
|
69
68
|
>
|
|
70
69
|
<CloseIcon fontSize="small" />
|
|
71
70
|
</IconButton>
|
|
@@ -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
|
+
tableInstance?.getToggleAllRowsSelectedProps?.()?.onChange?.(event);
|
|
24
|
+
onSelectAllChange?.(event, tableInstance.selectedFlatRows);
|
|
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
|
};
|
|
@@ -32,10 +32,10 @@ export interface MRT_Localization {
|
|
|
32
32
|
toolbarAlertGroupedThenByMessage: string;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export const
|
|
35
|
+
export const MRT_DefaultLocalization_EN: 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',
|
|
@@ -2,11 +2,6 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { Divider, Menu, MenuItem as MuiMenuItem, styled } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { HeaderGroup } from 'react-table';
|
|
5
|
-
import ClearAllIcon from '@mui/icons-material/ClearAll';
|
|
6
|
-
import SortIcon from '@mui/icons-material/Sort';
|
|
7
|
-
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
|
8
|
-
import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
|
|
9
|
-
import FilterIcon from '@mui/icons-material/FilterList';
|
|
10
5
|
|
|
11
6
|
const MenuItem = styled(MuiMenuItem)({
|
|
12
7
|
display: 'flex',
|
|
@@ -31,6 +26,13 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
31
26
|
enableColumnGrouping,
|
|
32
27
|
localization,
|
|
33
28
|
setShowFilters,
|
|
29
|
+
icons: {
|
|
30
|
+
FilterListIcon,
|
|
31
|
+
SortIcon,
|
|
32
|
+
ClearAllIcon,
|
|
33
|
+
DynamicFeedIcon,
|
|
34
|
+
VisibilityOffIcon,
|
|
35
|
+
},
|
|
34
36
|
} = useMRT();
|
|
35
37
|
|
|
36
38
|
const handleClearSort = () => {
|
|
@@ -87,7 +89,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
87
89
|
disabled={!column.isSorted}
|
|
88
90
|
onClick={handleClearSort}
|
|
89
91
|
>
|
|
90
|
-
<ClearAllIcon /> {localization
|
|
92
|
+
<ClearAllIcon /> {localization.columnActionMenuItemClearSort}
|
|
91
93
|
</MenuItem>,
|
|
92
94
|
<MenuItem
|
|
93
95
|
key={2}
|
|
@@ -95,7 +97,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
95
97
|
onClick={handleSortAsc}
|
|
96
98
|
>
|
|
97
99
|
<SortIcon />{' '}
|
|
98
|
-
{localization
|
|
100
|
+
{localization.columnActionMenuItemSortAsc?.replace(
|
|
99
101
|
'{column}',
|
|
100
102
|
String(column.Header),
|
|
101
103
|
)}
|
|
@@ -106,7 +108,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
106
108
|
onClick={handleSortDesc}
|
|
107
109
|
>
|
|
108
110
|
<SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />{' '}
|
|
109
|
-
{localization
|
|
111
|
+
{localization.columnActionMenuItemSortDesc?.replace(
|
|
110
112
|
'{column}',
|
|
111
113
|
String(column.Header),
|
|
112
114
|
)}
|
|
@@ -116,8 +118,8 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
116
118
|
column.canFilter && [
|
|
117
119
|
<Divider key={0} />,
|
|
118
120
|
<MenuItem key={1} onClick={handleFilterByColumn}>
|
|
119
|
-
<
|
|
120
|
-
{localization
|
|
121
|
+
<FilterListIcon />{' '}
|
|
122
|
+
{localization.filterTextFieldPlaceholder?.replace(
|
|
121
123
|
'{column}',
|
|
122
124
|
String(column.Header),
|
|
123
125
|
)}
|
|
@@ -128,7 +130,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
128
130
|
<Divider key={1} />,
|
|
129
131
|
<MenuItem key={2} onClick={handleGroupByColumn}>
|
|
130
132
|
<DynamicFeedIcon />{' '}
|
|
131
|
-
{localization
|
|
133
|
+
{localization[
|
|
132
134
|
column.isGrouped
|
|
133
135
|
? 'columnActionMenuItemUnGroupBy'
|
|
134
136
|
: 'columnActionMenuItemGroupBy'
|
|
@@ -139,7 +141,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
139
141
|
<Divider key={0} />,
|
|
140
142
|
<MenuItem key={1} onClick={handleHideColumn}>
|
|
141
143
|
<VisibilityOffIcon />{' '}
|
|
142
|
-
{localization
|
|
144
|
+
{localization.columnActionMenuItemHideColumn?.replace(
|
|
143
145
|
'{column}',
|
|
144
146
|
String(column.Header),
|
|
145
147
|
)}
|
|
@@ -2,7 +2,6 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { Menu, MenuItem as MuiMenuItem, styled } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { Row } from 'react-table';
|
|
5
|
-
import EditIcon from '@mui/icons-material/Edit';
|
|
6
5
|
|
|
7
6
|
const MenuItem = styled(MuiMenuItem)({
|
|
8
7
|
display: 'flex',
|
|
@@ -23,6 +22,7 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
23
22
|
setAnchorEl,
|
|
24
23
|
}) => {
|
|
25
24
|
const {
|
|
25
|
+
icons: { EditIcon },
|
|
26
26
|
enableRowEditing,
|
|
27
27
|
localization,
|
|
28
28
|
renderRowActionMenuItems,
|
|
@@ -37,7 +37,7 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
37
37
|
>
|
|
38
38
|
{enableRowEditing && (
|
|
39
39
|
<MenuItem onClick={handleEdit}>
|
|
40
|
-
<EditIcon /> {localization
|
|
40
|
+
<EditIcon /> {localization.rowActionMenuItemEdit}
|
|
41
41
|
</MenuItem>
|
|
42
42
|
)}
|
|
43
43
|
{renderRowActionMenuItems?.(row, tableInstance, () =>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC, useEffect } from 'react';
|
|
1
|
+
import React, { FC, useEffect, useRef } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
CircularProgress,
|
|
4
4
|
LinearProgress,
|
|
@@ -50,12 +50,22 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
50
50
|
muiTableContainerProps,
|
|
51
51
|
tableInstance,
|
|
52
52
|
} = useMRT();
|
|
53
|
+
const originalBodyOverflowStyle = useRef<string | undefined>();
|
|
53
54
|
|
|
54
55
|
useEffect(() => {
|
|
55
|
-
if (
|
|
56
|
-
document
|
|
57
|
-
}
|
|
58
|
-
|
|
56
|
+
if (typeof window !== 'undefined') {
|
|
57
|
+
originalBodyOverflowStyle.current = document?.body?.style?.overflow;
|
|
58
|
+
}
|
|
59
|
+
}, []);
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (typeof window !== 'undefined') {
|
|
63
|
+
if (fullScreen) {
|
|
64
|
+
document.body.style.overflow = 'hidden';
|
|
65
|
+
} else {
|
|
66
|
+
document.body.style.overflow =
|
|
67
|
+
originalBodyOverflowStyle.current ?? 'auto';
|
|
68
|
+
}
|
|
59
69
|
}
|
|
60
70
|
}, [fullScreen]);
|
|
61
71
|
|
|
@@ -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
|
}
|
|
@@ -47,7 +47,7 @@ export const MRT_ToolbarAlertBanner: FC<Props> = () => {
|
|
|
47
47
|
|
|
48
48
|
const selectMessage =
|
|
49
49
|
tableInstance.selectedFlatRows.length > 0
|
|
50
|
-
? localization
|
|
50
|
+
? localization.toolbarAlertSelectionMessage
|
|
51
51
|
?.replace(
|
|
52
52
|
'{selectedCount}',
|
|
53
53
|
tableInstance.selectedFlatRows.length.toString(),
|
|
@@ -58,10 +58,10 @@ export const MRT_ToolbarAlertBanner: FC<Props> = () => {
|
|
|
58
58
|
const groupedByMessage =
|
|
59
59
|
tableInstance.state.groupBy.length > 0 ? (
|
|
60
60
|
<span>
|
|
61
|
-
{localization
|
|
61
|
+
{localization.toolbarAlertGroupedByMessage}{' '}
|
|
62
62
|
{tableInstance.state.groupBy.map((columnId, index) => (
|
|
63
63
|
<Fragment key={`${index}-${columnId}`}>
|
|
64
|
-
{index > 0 ? localization
|
|
64
|
+
{index > 0 ? localization.toolbarAlertGroupedThenByMessage : ''}
|
|
65
65
|
<Chip
|
|
66
66
|
color="secondary"
|
|
67
67
|
label={
|
package/src/useMRT.tsx
CHANGED
|
@@ -21,14 +21,18 @@ import {
|
|
|
21
21
|
useSortBy,
|
|
22
22
|
useTable,
|
|
23
23
|
} from 'react-table';
|
|
24
|
+
import { MRT_Icons } from './icons';
|
|
25
|
+
import { MRT_Localization } from './localization';
|
|
24
26
|
import { MaterialReactTableProps } from './MaterialReactTable';
|
|
25
27
|
|
|
26
|
-
export
|
|
28
|
+
export type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
|
|
27
29
|
anyRowsCanExpand: boolean;
|
|
28
30
|
anyRowsExpanded: boolean;
|
|
29
31
|
currentEditingRow: Row<D> | null;
|
|
30
32
|
densePadding: boolean;
|
|
31
33
|
fullScreen: boolean;
|
|
34
|
+
icons: MRT_Icons;
|
|
35
|
+
localization: MRT_Localization;
|
|
32
36
|
setCurrentEditingRow: (currentRowEditingId: Row<D> | null) => void;
|
|
33
37
|
setDensePadding: (densePadding: boolean) => void;
|
|
34
38
|
setFullScreen: (fullScreen: boolean) => void;
|
|
@@ -37,7 +41,7 @@ export interface UseMRT<D extends {} = {}> extends MaterialReactTableProps<D> {
|
|
|
37
41
|
showFilters: boolean;
|
|
38
42
|
showSearch: boolean;
|
|
39
43
|
tableInstance: TableInstance<D>;
|
|
40
|
-
}
|
|
44
|
+
};
|
|
41
45
|
|
|
42
46
|
const MaterialReactTableContext = (<D extends {}>() =>
|
|
43
47
|
createContext<UseMRT<D>>({} as UseMRT<D>) as Context<UseMRT<D>>)();
|