material-react-table 0.6.5 → 0.6.8
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 +6 -0
- package/dist/buttons/MRT_CopyButton.d.ts +7 -0
- package/dist/head/MRT_TableHeadCell.d.ts +9 -2
- package/dist/icons.d.ts +2 -0
- package/dist/localization.d.ts +2 -0
- package/dist/material-react-table.cjs.development.js +103 -34
- 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 +103 -34
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/package.json +7 -7
- package/src/MaterialReactTable.tsx +10 -0
- package/src/body/MRT_TableBodyCell.tsx +4 -0
- package/src/buttons/MRT_CopyButton.tsx +50 -0
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +19 -1
- package/src/head/MRT_TableHeadCell.tsx +17 -4
- package/src/head/MRT_TableHeadCellActions.tsx +6 -1
- package/src/head/MRT_TableHeadRow.tsx +2 -1
- package/src/icons.ts +6 -0
- package/src/inputs/MRT_EditCellTextField.tsx +0 -6
- package/src/inputs/MRT_FilterTextField.tsx +0 -4
- package/src/inputs/MRT_SelectCheckbox.tsx +5 -1
- package/src/localization.ts +4 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +6 -1
- package/src/menus/MRT_FilterTypeMenu.tsx +66 -62
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +12 -1
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +1 -1
- package/src/table/MRT_TableSpacerCell.tsx +1 -8
- package/src/utils.ts +8 -4
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MRT_ColumnInterface } from '.';
|
|
2
|
-
export declare const findLowestLevelCols: (columns: MRT_ColumnInterface[]) => MRT_ColumnInterface<{}>[];
|
|
1
|
+
import { MRT_ColumnInstance, MRT_ColumnInterface } from '.';
|
|
2
|
+
export declare const findLowestLevelCols: (columns: MRT_ColumnInterface[] | MRT_ColumnInstance[]) => MRT_ColumnInterface<{}>[];
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
2
|
+
"version": "0.6.8",
|
|
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.",
|
|
@@ -55,13 +55,13 @@
|
|
|
55
55
|
}
|
|
56
56
|
],
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@babel/core": "^7.17.
|
|
58
|
+
"@babel/core": "^7.17.7",
|
|
59
59
|
"@emotion/react": "^11.8.2",
|
|
60
60
|
"@emotion/styled": "^11.8.1",
|
|
61
61
|
"@etchteam/storybook-addon-status": "^4.2.0",
|
|
62
|
-
"@faker-js/faker": "^6.0.0
|
|
63
|
-
"@mui/icons-material": "^5.5.
|
|
64
|
-
"@mui/material": "^5.5.
|
|
62
|
+
"@faker-js/faker": "^6.0.0",
|
|
63
|
+
"@mui/icons-material": "^5.5.1",
|
|
64
|
+
"@mui/material": "^5.5.1",
|
|
65
65
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
66
66
|
"@storybook/addon-a11y": "^6.4.19",
|
|
67
67
|
"@storybook/addon-actions": "^6.4.19",
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
"@types/faker": "^6.6.8",
|
|
76
76
|
"@types/react": "^17.0.40",
|
|
77
77
|
"@types/react-dom": "^17.0.13",
|
|
78
|
-
"@types/react-table": "^7.7.
|
|
78
|
+
"@types/react-table": "^7.7.10",
|
|
79
79
|
"babel-loader": "^8.2.3",
|
|
80
80
|
"husky": "^7.0.4",
|
|
81
|
-
"prettier": "^2.
|
|
81
|
+
"prettier": "^2.6.0",
|
|
82
82
|
"react": "^17.0.2",
|
|
83
83
|
"react-dom": "^17.0.2",
|
|
84
84
|
"react-is": "^17.0.2",
|
|
@@ -134,6 +134,9 @@ export type MRT_ColumnInterface<D extends {} = {}> = ColumnInterface<D> &
|
|
|
134
134
|
Header?: string;
|
|
135
135
|
accessor?: string;
|
|
136
136
|
columns?: MRT_ColumnInterface<D>[];
|
|
137
|
+
disableClickToCopy?: boolean;
|
|
138
|
+
disableColumnActions?: boolean;
|
|
139
|
+
disableColumnHiding?: boolean;
|
|
137
140
|
disableEditing?: boolean;
|
|
138
141
|
disableFilters?: boolean;
|
|
139
142
|
filter?: MRT_FilterType | string | FilterType<D>;
|
|
@@ -151,6 +154,9 @@ export type MRT_ColumnInterface<D extends {} = {}> = ColumnInterface<D> &
|
|
|
151
154
|
muiTableHeadCellFilterTextFieldProps?:
|
|
152
155
|
| TextFieldProps
|
|
153
156
|
| ((column: Column<D>) => TextFieldProps);
|
|
157
|
+
muiTableHeadCellColumnActionsButtonProps?:
|
|
158
|
+
| IconButtonProps
|
|
159
|
+
| ((column: Column<D>) => IconButtonProps);
|
|
154
160
|
muiTableHeadCellProps?:
|
|
155
161
|
| TableCellProps
|
|
156
162
|
| ((column: Column<D>) => TableCellProps);
|
|
@@ -232,6 +238,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
232
238
|
disableFullScreenToggle?: boolean;
|
|
233
239
|
disableSelectAll?: boolean;
|
|
234
240
|
disableSubRowTree?: boolean;
|
|
241
|
+
enableClickToCopy?: boolean;
|
|
235
242
|
enableColumnGrouping?: boolean;
|
|
236
243
|
enableColumnResizing?: boolean;
|
|
237
244
|
enableRowActions?: boolean;
|
|
@@ -275,6 +282,9 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
275
282
|
muiTableFooterCellProps?:
|
|
276
283
|
| TableCellProps
|
|
277
284
|
| ((column: Column<D>) => TableCellProps);
|
|
285
|
+
muiTableHeadCellColumnActionsButtonProps?:
|
|
286
|
+
| IconButtonProps
|
|
287
|
+
| ((column: Column<D>) => IconButtonProps);
|
|
278
288
|
muiTableFooterProps?:
|
|
279
289
|
| TableFooterProps
|
|
280
290
|
| ((tableInstance: MRT_TableInstance<D>) => TableFooterProps);
|
|
@@ -3,6 +3,7 @@ import { Skeleton, TableCell, TableCellProps } from '@mui/material';
|
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
|
5
5
|
import type { MRT_Cell } from '..';
|
|
6
|
+
import { MRT_CopyButton } from '../buttons/MRT_CopyButton';
|
|
6
7
|
|
|
7
8
|
export const commonTableBodyCellStyles = (densePadding: boolean) => ({
|
|
8
9
|
p: densePadding ? '0.5rem' : '1rem',
|
|
@@ -22,6 +23,7 @@ interface Props {
|
|
|
22
23
|
|
|
23
24
|
export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
24
25
|
const {
|
|
26
|
+
enableClickToCopy,
|
|
25
27
|
isLoading,
|
|
26
28
|
muiTableBodyCellProps,
|
|
27
29
|
muiTableBodyCellSkeletonProps,
|
|
@@ -81,6 +83,8 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
81
83
|
<span>
|
|
82
84
|
{cell.render('Cell')} ({cell.row.subRows.length})
|
|
83
85
|
</span>
|
|
86
|
+
) : enableClickToCopy && !cell.column.disableClickToCopy ? (
|
|
87
|
+
<MRT_CopyButton cell={cell} />
|
|
84
88
|
) : (
|
|
85
89
|
cell.render('Cell')
|
|
86
90
|
)}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { FC, useState } from 'react';
|
|
2
|
+
import { Button, Tooltip } from '@mui/material';
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
|
+
import { MRT_Cell } from '..';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
cell: MRT_Cell;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const MRT_CopyButton: FC<Props> = ({ cell }) => {
|
|
11
|
+
const { localization } = useMRT();
|
|
12
|
+
|
|
13
|
+
const [copied, setCopied] = useState(false);
|
|
14
|
+
|
|
15
|
+
const handleCopy = (text: string) => {
|
|
16
|
+
navigator.clipboard.writeText(text);
|
|
17
|
+
setCopied(true);
|
|
18
|
+
setTimeout(() => setCopied(false), 4000);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Tooltip
|
|
23
|
+
arrow
|
|
24
|
+
enterDelay={1000}
|
|
25
|
+
enterNextDelay={1000}
|
|
26
|
+
placement="top"
|
|
27
|
+
title={copied ? localization.copiedToClipboard : localization.clickToCopy}
|
|
28
|
+
>
|
|
29
|
+
<Button
|
|
30
|
+
aria-label={localization.clickToCopy}
|
|
31
|
+
onClick={() => handleCopy(cell.value)}
|
|
32
|
+
size="small"
|
|
33
|
+
sx={{
|
|
34
|
+
backgroundColor: 'transparent',
|
|
35
|
+
color: 'inherit',
|
|
36
|
+
letterSpacing: 'inherit',
|
|
37
|
+
fontFamily: 'inherit',
|
|
38
|
+
fontSize: 'inherit',
|
|
39
|
+
m: '-0.25rem',
|
|
40
|
+
textTransform: 'inherit',
|
|
41
|
+
textAlign: 'inherit',
|
|
42
|
+
minWidth: 'unset',
|
|
43
|
+
}}
|
|
44
|
+
variant="text"
|
|
45
|
+
>
|
|
46
|
+
{cell.render('Cell')}
|
|
47
|
+
</Button>
|
|
48
|
+
</Tooltip>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
@@ -10,8 +10,9 @@ interface Props {
|
|
|
10
10
|
|
|
11
11
|
export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
12
12
|
const {
|
|
13
|
-
localization,
|
|
14
13
|
icons: { MoreVertIcon },
|
|
14
|
+
localization,
|
|
15
|
+
muiTableHeadCellColumnActionsButtonProps,
|
|
15
16
|
} = useMRT();
|
|
16
17
|
|
|
17
18
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
@@ -22,6 +23,21 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
22
23
|
setAnchorEl(event.currentTarget);
|
|
23
24
|
};
|
|
24
25
|
|
|
26
|
+
const mTableHeadCellColumnActionsButtonProps =
|
|
27
|
+
muiTableHeadCellColumnActionsButtonProps instanceof Function
|
|
28
|
+
? muiTableHeadCellColumnActionsButtonProps(column)
|
|
29
|
+
: muiTableHeadCellColumnActionsButtonProps;
|
|
30
|
+
|
|
31
|
+
const mcTableHeadCellColumnActionsButtonProps =
|
|
32
|
+
column.muiTableHeadCellColumnActionsButtonProps instanceof Function
|
|
33
|
+
? column.muiTableHeadCellColumnActionsButtonProps(column)
|
|
34
|
+
: column.muiTableHeadCellColumnActionsButtonProps;
|
|
35
|
+
|
|
36
|
+
const iconButtonProps = {
|
|
37
|
+
...mTableHeadCellColumnActionsButtonProps,
|
|
38
|
+
...mcTableHeadCellColumnActionsButtonProps,
|
|
39
|
+
};
|
|
40
|
+
|
|
25
41
|
return (
|
|
26
42
|
<>
|
|
27
43
|
<Tooltip
|
|
@@ -35,6 +51,7 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
35
51
|
aria-label={localization.columnActions}
|
|
36
52
|
onClick={handleClick}
|
|
37
53
|
size="small"
|
|
54
|
+
{...iconButtonProps}
|
|
38
55
|
sx={{
|
|
39
56
|
height: '2rem',
|
|
40
57
|
mr: '2px',
|
|
@@ -45,6 +62,7 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
45
62
|
'&:hover': {
|
|
46
63
|
opacity: 1,
|
|
47
64
|
},
|
|
65
|
+
...iconButtonProps.sx,
|
|
48
66
|
}}
|
|
49
67
|
>
|
|
50
68
|
<MoreVertIcon />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { CSSProperties, FC } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
TableCell,
|
|
4
4
|
TableSortLabel,
|
|
@@ -16,6 +16,11 @@ import type { MRT_HeaderGroup } from '..';
|
|
|
16
16
|
export const commonTableHeadCellStyles = (
|
|
17
17
|
densePadding: boolean,
|
|
18
18
|
enableColumnResizing?: boolean,
|
|
19
|
+
widths?: {
|
|
20
|
+
maxWidth?: CSSProperties['maxWidth'];
|
|
21
|
+
minWidth?: CSSProperties['minWidth'];
|
|
22
|
+
width?: CSSProperties['width'];
|
|
23
|
+
},
|
|
19
24
|
) => ({
|
|
20
25
|
fontWeight: 'bold',
|
|
21
26
|
height: '100%',
|
|
@@ -23,6 +28,7 @@ export const commonTableHeadCellStyles = (
|
|
|
23
28
|
pt: densePadding ? '0.75rem' : '1.25rem',
|
|
24
29
|
transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
|
|
25
30
|
verticalAlign: 'text-top',
|
|
31
|
+
...widths,
|
|
26
32
|
});
|
|
27
33
|
|
|
28
34
|
interface Props {
|
|
@@ -105,6 +111,11 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
105
111
|
...commonTableHeadCellStyles(
|
|
106
112
|
tableInstance.state.densePadding,
|
|
107
113
|
enableColumnResizing,
|
|
114
|
+
{
|
|
115
|
+
maxWidth: column.maxWidth,
|
|
116
|
+
minWidth: column.minWidth,
|
|
117
|
+
width: column.width,
|
|
118
|
+
},
|
|
108
119
|
),
|
|
109
120
|
...tableCellProps?.sx,
|
|
110
121
|
}}
|
|
@@ -167,9 +178,11 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
167
178
|
)}
|
|
168
179
|
</Box>
|
|
169
180
|
<Box sx={{ alignItems: 'center', display: 'flex', flexWrap: 'nowrap' }}>
|
|
170
|
-
{!disableColumnActions &&
|
|
171
|
-
|
|
172
|
-
|
|
181
|
+
{!disableColumnActions &&
|
|
182
|
+
!column.disableColumnActions &&
|
|
183
|
+
!isParentHeader && (
|
|
184
|
+
<MRT_ToggleColumnActionMenuButton column={column} />
|
|
185
|
+
)}
|
|
173
186
|
{enableColumnResizing && !isParentHeader && (
|
|
174
187
|
<Divider
|
|
175
188
|
flexItem
|
|
@@ -16,7 +16,12 @@ export const MRT_TableHeadCellActions: FC<Props> = () => {
|
|
|
16
16
|
return (
|
|
17
17
|
<TableCell
|
|
18
18
|
style={{ textAlign: 'center' }}
|
|
19
|
-
sx={{
|
|
19
|
+
sx={{
|
|
20
|
+
...commonTableHeadCellStyles(densePadding),
|
|
21
|
+
textAlign: 'center',
|
|
22
|
+
maxWidth: '4rem',
|
|
23
|
+
width: '4rem',
|
|
24
|
+
}}
|
|
20
25
|
>
|
|
21
26
|
{localization.actions}
|
|
22
27
|
</TableCell>
|
|
@@ -19,6 +19,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
19
19
|
const {
|
|
20
20
|
anyRowsCanExpand,
|
|
21
21
|
disableExpandAll,
|
|
22
|
+
disableSelectAll,
|
|
22
23
|
enableRowActions,
|
|
23
24
|
enableRowEditing,
|
|
24
25
|
enableRowNumbers,
|
|
@@ -81,7 +82,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
81
82
|
)
|
|
82
83
|
) : null}
|
|
83
84
|
{enableSelection ? (
|
|
84
|
-
!isParentHeader ? (
|
|
85
|
+
!isParentHeader && !disableSelectAll ? (
|
|
85
86
|
<MRT_SelectCheckbox selectAll />
|
|
86
87
|
) : (
|
|
87
88
|
<MRT_TableSpacerCell width="1rem" />
|
package/src/icons.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
|
|
2
2
|
import CancelIcon from '@mui/icons-material/Cancel';
|
|
3
|
+
import CheckBoxIcon from '@mui/icons-material/CheckBox';
|
|
3
4
|
import ClearAllIcon from '@mui/icons-material/ClearAll';
|
|
4
5
|
import CloseIcon from '@mui/icons-material/Close';
|
|
6
|
+
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
|
5
7
|
import DensityMediumIcon from '@mui/icons-material/DensityMedium';
|
|
6
8
|
import DensitySmallIcon from '@mui/icons-material/DensitySmall';
|
|
7
9
|
import DoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
|
|
@@ -27,8 +29,10 @@ import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
|
|
27
29
|
export interface MRT_Icons {
|
|
28
30
|
ArrowRightIcon: any;
|
|
29
31
|
CancelIcon: any;
|
|
32
|
+
CheckBoxIcon: any;
|
|
30
33
|
ClearAllIcon: any;
|
|
31
34
|
CloseIcon: any;
|
|
35
|
+
ContentCopyIcon: any;
|
|
32
36
|
DensityMediumIcon: any;
|
|
33
37
|
DensitySmallIcon: any;
|
|
34
38
|
DoubleArrowDownIcon: any;
|
|
@@ -55,8 +59,10 @@ export interface MRT_Icons {
|
|
|
55
59
|
export const MRT_Default_Icons: MRT_Icons = {
|
|
56
60
|
ArrowRightIcon,
|
|
57
61
|
CancelIcon,
|
|
62
|
+
CheckBoxIcon,
|
|
58
63
|
ClearAllIcon,
|
|
59
64
|
CloseIcon,
|
|
65
|
+
ContentCopyIcon,
|
|
60
66
|
DensityMediumIcon,
|
|
61
67
|
DensitySmallIcon,
|
|
62
68
|
DoubleArrowDownIcon,
|
|
@@ -39,12 +39,6 @@ export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
|
|
|
39
39
|
const textFieldProps = {
|
|
40
40
|
...mTableBodyCellEditTextFieldProps,
|
|
41
41
|
...mcTableBodyCellEditTextFieldProps,
|
|
42
|
-
style: {
|
|
43
|
-
//@ts-ignore
|
|
44
|
-
...muiTableBodyCellEditTextFieldProps?.style,
|
|
45
|
-
//@ts-ignore
|
|
46
|
-
...cell.column.muiTableBodyCellEditTextFieldProps?.style,
|
|
47
|
-
},
|
|
48
42
|
};
|
|
49
43
|
|
|
50
44
|
if (!cell.column.disableEditing && cell.column.Edit) {
|
|
@@ -43,10 +43,6 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
43
43
|
const textFieldProps = {
|
|
44
44
|
...mTableHeadCellFilterTextFieldProps,
|
|
45
45
|
...mcTableHeadCellFilterTextFieldProps,
|
|
46
|
-
style: {
|
|
47
|
-
...mTableHeadCellFilterTextFieldProps?.style,
|
|
48
|
-
...mcTableHeadCellFilterTextFieldProps?.style,
|
|
49
|
-
},
|
|
50
46
|
} as TextFieldProps;
|
|
51
47
|
|
|
52
48
|
const [filterValue, setFilterValue] = useState('');
|
|
@@ -29,7 +29,11 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
|
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
31
|
<TableCell
|
|
32
|
-
sx={
|
|
32
|
+
sx={{
|
|
33
|
+
...commonTableBodyButtonCellStyles(tableInstance.state.densePadding),
|
|
34
|
+
maxWidth: '2rem',
|
|
35
|
+
width: '2rem',
|
|
36
|
+
}}
|
|
33
37
|
>
|
|
34
38
|
<Tooltip
|
|
35
39
|
arrow
|
package/src/localization.ts
CHANGED
|
@@ -5,7 +5,9 @@ export interface MRT_Localization {
|
|
|
5
5
|
clearFilter: string;
|
|
6
6
|
clearSearch: string;
|
|
7
7
|
clearSort: string;
|
|
8
|
+
clickToCopy: string;
|
|
8
9
|
columnActions: string;
|
|
10
|
+
copiedToClipboard: string;
|
|
9
11
|
edit: string;
|
|
10
12
|
expand: string;
|
|
11
13
|
expandAll: string;
|
|
@@ -52,7 +54,9 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
|
52
54
|
clearFilter: 'Clear filter',
|
|
53
55
|
clearSearch: 'Clear search',
|
|
54
56
|
clearSort: 'Clear sort',
|
|
57
|
+
clickToCopy: 'Click to copy',
|
|
55
58
|
columnActions: 'Column Actions',
|
|
59
|
+
copiedToClipboard: 'Copied to clipboard',
|
|
56
60
|
edit: 'Edit',
|
|
57
61
|
expand: 'Expand',
|
|
58
62
|
expandAll: 'Expand all',
|
|
@@ -246,7 +246,12 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
246
246
|
</MenuItem>,
|
|
247
247
|
]}
|
|
248
248
|
{!disableColumnHiding && [
|
|
249
|
-
<MenuItem
|
|
249
|
+
<MenuItem
|
|
250
|
+
disabled={column.disableColumnHiding}
|
|
251
|
+
key={0}
|
|
252
|
+
onClick={handleHideColumn}
|
|
253
|
+
sx={commonMenuItemStyles}
|
|
254
|
+
>
|
|
250
255
|
<Box sx={commonListItemStyles}>
|
|
251
256
|
<ListItemIcon>
|
|
252
257
|
<VisibilityOffIcon />
|
|
@@ -43,68 +43,72 @@ export const MRT_FilterTypeMenu: FC<Props> = ({
|
|
|
43
43
|
divider: boolean;
|
|
44
44
|
fn: Function;
|
|
45
45
|
}[] = useMemo(
|
|
46
|
-
() =>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
46
|
+
() =>
|
|
47
|
+
[
|
|
48
|
+
{
|
|
49
|
+
type: MRT_FILTER_TYPE.FUZZY,
|
|
50
|
+
label: localization.filterFuzzy,
|
|
51
|
+
divider: false,
|
|
52
|
+
fn: fuzzy,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: MRT_FILTER_TYPE.CONTAINS,
|
|
56
|
+
label: localization.filterContains,
|
|
57
|
+
divider: true,
|
|
58
|
+
fn: contains,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: MRT_FILTER_TYPE.STARTS_WITH,
|
|
62
|
+
label: localization.filterStartsWith,
|
|
63
|
+
divider: false,
|
|
64
|
+
fn: startsWith,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: MRT_FILTER_TYPE.ENDS_WITH,
|
|
68
|
+
label: localization.filterEndsWith,
|
|
69
|
+
divider: true,
|
|
70
|
+
fn: endsWith,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: MRT_FILTER_TYPE.EQUALS,
|
|
74
|
+
label: localization.filterEquals,
|
|
75
|
+
divider: false,
|
|
76
|
+
fn: equals,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: MRT_FILTER_TYPE.NOT_EQUALS,
|
|
80
|
+
label: localization.filterNotEquals,
|
|
81
|
+
divider: true,
|
|
82
|
+
fn: notEquals,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: MRT_FILTER_TYPE.GREATER_THAN,
|
|
86
|
+
label: localization.filterGreaterThan,
|
|
87
|
+
divider: false,
|
|
88
|
+
fn: greaterThan,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: MRT_FILTER_TYPE.LESS_THAN,
|
|
92
|
+
label: localization.filterLessThan,
|
|
93
|
+
divider: true,
|
|
94
|
+
fn: lessThan,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
type: MRT_FILTER_TYPE.EMPTY,
|
|
98
|
+
label: localization.filterEmpty,
|
|
99
|
+
divider: false,
|
|
100
|
+
fn: empty,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: MRT_FILTER_TYPE.NOT_EMPTY,
|
|
104
|
+
label: localization.filterNotEmpty,
|
|
105
|
+
divider: false,
|
|
106
|
+
fn: notEmpty,
|
|
107
|
+
},
|
|
108
|
+
].filter(
|
|
109
|
+
(filterType) =>
|
|
110
|
+
!column.filterTypes || column.filterTypes.includes(filterType.type),
|
|
111
|
+
),
|
|
108
112
|
[],
|
|
109
113
|
);
|
|
110
114
|
|
|
@@ -3,6 +3,7 @@ import { Button, Menu, Divider, Box } from '@mui/material';
|
|
|
3
3
|
import type { MRT_ColumnInstance } from '..';
|
|
4
4
|
import { useMRT } from '../useMRT';
|
|
5
5
|
import { MRT_ShowHideColumnsMenuItems } from './MRT_ShowHideColumnsMenuItems';
|
|
6
|
+
import { findLowestLevelCols } from '../utils';
|
|
6
7
|
|
|
7
8
|
interface Props {
|
|
8
9
|
anchorEl: HTMLElement | null;
|
|
@@ -17,6 +18,16 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
17
18
|
}) => {
|
|
18
19
|
const { localization, tableInstance } = useMRT();
|
|
19
20
|
|
|
21
|
+
const hideAllColumns = () => {
|
|
22
|
+
(
|
|
23
|
+
findLowestLevelCols(
|
|
24
|
+
tableInstance.columns as MRT_ColumnInstance[],
|
|
25
|
+
) as MRT_ColumnInstance[]
|
|
26
|
+
)
|
|
27
|
+
.filter((col: MRT_ColumnInstance) => !col.disableColumnHiding)
|
|
28
|
+
.forEach((col: MRT_ColumnInstance) => col.toggleHidden(true));
|
|
29
|
+
};
|
|
30
|
+
|
|
20
31
|
return (
|
|
21
32
|
<Menu
|
|
22
33
|
anchorEl={anchorEl}
|
|
@@ -40,7 +51,7 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
40
51
|
!tableInstance.getToggleHideAllColumnsProps().checked &&
|
|
41
52
|
!tableInstance.getToggleHideAllColumnsProps().indeterminate
|
|
42
53
|
}
|
|
43
|
-
onClick={
|
|
54
|
+
onClick={hideAllColumns}
|
|
44
55
|
>
|
|
45
56
|
{localization.hideAll}
|
|
46
57
|
</Button>
|
|
@@ -43,7 +43,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
43
43
|
componentsProps={{ typography: { sx: { marginBottom: 0 } } }}
|
|
44
44
|
checked={switchChecked}
|
|
45
45
|
control={<Switch />}
|
|
46
|
-
disabled={isSubMenu && switchChecked}
|
|
46
|
+
disabled={(isSubMenu && switchChecked) || column.disableColumnHiding}
|
|
47
47
|
label={column.Header as string}
|
|
48
48
|
onChange={() => handleToggleColumnHidden(column)}
|
|
49
49
|
/>
|
|
@@ -9,18 +9,11 @@ interface Props {
|
|
|
9
9
|
export const MRT_TableSpacerCell: FC<Props> = ({ width }) => {
|
|
10
10
|
const { muiTableBodyCellProps } = useMRT();
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const tableCellProps =
|
|
13
13
|
muiTableBodyCellProps instanceof Function
|
|
14
14
|
? muiTableBodyCellProps()
|
|
15
15
|
: muiTableBodyCellProps;
|
|
16
16
|
|
|
17
|
-
const tableCellProps = {
|
|
18
|
-
...mTableBodyCellrops,
|
|
19
|
-
style: {
|
|
20
|
-
...mTableBodyCellrops?.style,
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
17
|
return (
|
|
25
18
|
<TableCell {...tableCellProps} sx={{ width, ...tableCellProps?.sx }} />
|
|
26
19
|
);
|
package/src/utils.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { MRT_ColumnInterface } from '.';
|
|
1
|
+
import { MRT_ColumnInstance, MRT_ColumnInterface } from '.';
|
|
2
2
|
|
|
3
|
-
export const findLowestLevelCols = (
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export const findLowestLevelCols = (
|
|
4
|
+
columns: MRT_ColumnInterface[] | MRT_ColumnInstance[],
|
|
5
|
+
) => {
|
|
6
|
+
let lowestLevelColumns: MRT_ColumnInterface[] | MRT_ColumnInstance[] =
|
|
7
|
+
columns;
|
|
8
|
+
let currentCols: MRT_ColumnInterface[] | MRT_ColumnInstance[] | undefined =
|
|
9
|
+
columns;
|
|
6
10
|
while (!!currentCols?.length && currentCols.some((col) => col.columns)) {
|
|
7
11
|
const nextCols: MRT_ColumnInterface[] = currentCols
|
|
8
12
|
.filter((col) => !!col.columns)
|