material-react-table 0.6.4 → 0.6.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/dist/MaterialReactTable.d.ts +4 -2
- 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 +105 -29
- 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 +106 -30
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +0 -1
- package/package.json +7 -7
- package/src/MaterialReactTable.tsx +4 -2
- package/src/body/MRT_TableBodyCell.tsx +6 -1
- package/src/body/MRT_TableBodyRow.tsx +2 -9
- package/src/buttons/MRT_CopyButton.tsx +50 -0
- package/src/buttons/MRT_ExpandButton.tsx +9 -1
- package/src/head/MRT_TableHeadCell.tsx +12 -1
- package/src/head/MRT_TableHeadCellActions.tsx +6 -1
- package/src/icons.ts +6 -0
- package/src/inputs/MRT_EditCellTextField.tsx +1 -1
- package/src/localization.ts +4 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +25 -11
- package/src/menus/MRT_FilterTypeMenu.tsx +66 -62
- package/src/menus/MRT_RowActionMenu.tsx +11 -4
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +3 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
2
|
+
"version": "0.6.7",
|
|
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,8 +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
|
+
disableEditing?: boolean;
|
|
137
139
|
disableFilters?: boolean;
|
|
138
|
-
editable?: boolean;
|
|
139
140
|
filter?: MRT_FilterType | string | FilterType<D>;
|
|
140
141
|
filterSelectOptions?: (string | { text: string; value: string })[];
|
|
141
142
|
filterTypes?: (MRT_FILTER_TYPE | string)[];
|
|
@@ -232,6 +233,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
232
233
|
disableFullScreenToggle?: boolean;
|
|
233
234
|
disableSelectAll?: boolean;
|
|
234
235
|
disableSubRowTree?: boolean;
|
|
236
|
+
enableClickToCopy?: boolean;
|
|
235
237
|
enableColumnGrouping?: boolean;
|
|
236
238
|
enableColumnResizing?: boolean;
|
|
237
239
|
enableRowActions?: boolean;
|
|
@@ -314,7 +316,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
314
316
|
event: MouseEvent<HTMLTableCellElement>,
|
|
315
317
|
cell: MRT_Cell<D>,
|
|
316
318
|
) => void;
|
|
317
|
-
onColumnHide?: (column: Column<D>,
|
|
319
|
+
onColumnHide?: (column: Column<D>, hiddenColumns?: string[]) => void;
|
|
318
320
|
onDetailPanelClick?: (
|
|
319
321
|
event: MouseEvent<HTMLTableCellElement>,
|
|
320
322
|
row: Row<D>,
|
|
@@ -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,
|
|
@@ -72,7 +74,8 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
72
74
|
width={Math.random() * (120 - 60) + 60}
|
|
73
75
|
{...muiTableBodyCellSkeletonProps}
|
|
74
76
|
/>
|
|
75
|
-
) :
|
|
77
|
+
) : !cell.column.disableEditing &&
|
|
78
|
+
currentEditingRow?.id === cell.row.id ? (
|
|
76
79
|
<MRT_EditCellTextField cell={cell} />
|
|
77
80
|
) : cell.isPlaceholder ? null : cell.isAggregated ? (
|
|
78
81
|
cell.render('Aggregated')
|
|
@@ -80,6 +83,8 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
80
83
|
<span>
|
|
81
84
|
{cell.render('Cell')} ({cell.row.subRows.length})
|
|
82
85
|
</span>
|
|
86
|
+
) : enableClickToCopy && !cell.column.disableClickToCopy ? (
|
|
87
|
+
<MRT_CopyButton cell={cell} />
|
|
83
88
|
) : (
|
|
84
89
|
cell.render('Cell')
|
|
85
90
|
)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TableCell, TableRow } from '@mui/material';
|
|
3
3
|
import {
|
|
4
4
|
commonTableBodyCellStyles,
|
|
5
5
|
MRT_TableBodyCell,
|
|
@@ -52,15 +52,8 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
52
52
|
onClick={(event: MouseEvent<HTMLTableRowElement>) =>
|
|
53
53
|
onRowClick?.(event, row)
|
|
54
54
|
}
|
|
55
|
+
selected={row.isSelected}
|
|
55
56
|
{...tableRowProps}
|
|
56
|
-
sx={(theme) =>
|
|
57
|
-
({
|
|
58
|
-
backgroundColor: row.isSelected
|
|
59
|
-
? alpha(theme.palette.primary.light, 0.1)
|
|
60
|
-
: 'transparent',
|
|
61
|
-
...tableRowProps?.sx,
|
|
62
|
-
} as any)
|
|
63
|
-
}
|
|
64
57
|
>
|
|
65
58
|
{enableRowNumbers && (
|
|
66
59
|
<TableCell sx={{ ...commonTableBodyCellStyles(densePadding) }}>
|
|
@@ -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
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { IconButton, TableCell } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import type { MRT_Row } from '..';
|
|
@@ -12,12 +12,19 @@ export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
|
12
12
|
const {
|
|
13
13
|
icons: { ExpandMoreIcon },
|
|
14
14
|
localization,
|
|
15
|
+
onRowExpandChange,
|
|
15
16
|
renderDetailPanel,
|
|
16
17
|
tableInstance: {
|
|
17
18
|
state: { densePadding },
|
|
18
19
|
},
|
|
19
20
|
} = useMRT();
|
|
20
21
|
|
|
22
|
+
const handleToggleExpand = (event: MouseEvent<HTMLButtonElement>) => {
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
row.getToggleRowExpandedProps()?.onClick(event);
|
|
25
|
+
onRowExpandChange?.(event, row);
|
|
26
|
+
};
|
|
27
|
+
|
|
21
28
|
return (
|
|
22
29
|
<TableCell
|
|
23
30
|
size="small"
|
|
@@ -32,6 +39,7 @@ export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
|
32
39
|
disabled={!row.canExpand && !renderDetailPanel}
|
|
33
40
|
title={localization.expand}
|
|
34
41
|
{...row.getToggleRowExpandedProps()}
|
|
42
|
+
onClick={handleToggleExpand}
|
|
35
43
|
>
|
|
36
44
|
<ExpandMoreIcon
|
|
37
45
|
style={{
|
|
@@ -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
|
}}
|
|
@@ -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>
|
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,
|
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',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC, useState } from 'react';
|
|
2
|
-
import { Box, IconButton, Menu, MenuItem } from '@mui/material';
|
|
2
|
+
import { Box, IconButton, ListItemIcon, Menu, MenuItem } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import type { MRT_HeaderGroup } from '..';
|
|
5
5
|
import { MRT_FilterTypeMenu } from './MRT_FilterTypeMenu';
|
|
@@ -14,7 +14,6 @@ export const commonMenuItemStyles = {
|
|
|
14
14
|
|
|
15
15
|
export const commonListItemStyles = {
|
|
16
16
|
display: 'flex',
|
|
17
|
-
gap: '0.75rem',
|
|
18
17
|
alignItems: 'center',
|
|
19
18
|
};
|
|
20
19
|
|
|
@@ -137,7 +136,9 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
137
136
|
sx={commonMenuItemStyles}
|
|
138
137
|
>
|
|
139
138
|
<Box sx={commonListItemStyles}>
|
|
140
|
-
<
|
|
139
|
+
<ListItemIcon>
|
|
140
|
+
<ClearAllIcon />
|
|
141
|
+
</ListItemIcon>
|
|
141
142
|
{localization.clearSort}
|
|
142
143
|
</Box>
|
|
143
144
|
</MenuItem>,
|
|
@@ -148,7 +149,9 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
148
149
|
sx={commonMenuItemStyles}
|
|
149
150
|
>
|
|
150
151
|
<Box sx={commonListItemStyles}>
|
|
151
|
-
<
|
|
152
|
+
<ListItemIcon>
|
|
153
|
+
<SortIcon />
|
|
154
|
+
</ListItemIcon>
|
|
152
155
|
{localization.sortByColumnAsc?.replace(
|
|
153
156
|
'{column}',
|
|
154
157
|
String(column.Header),
|
|
@@ -165,7 +168,9 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
165
168
|
sx={commonMenuItemStyles}
|
|
166
169
|
>
|
|
167
170
|
<Box sx={commonListItemStyles}>
|
|
168
|
-
<
|
|
171
|
+
<ListItemIcon>
|
|
172
|
+
<SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />
|
|
173
|
+
</ListItemIcon>
|
|
169
174
|
{localization.sortByColumnDesc?.replace(
|
|
170
175
|
'{column}',
|
|
171
176
|
String(column.Header),
|
|
@@ -182,7 +187,9 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
182
187
|
sx={commonMenuItemStyles}
|
|
183
188
|
>
|
|
184
189
|
<Box sx={commonListItemStyles}>
|
|
185
|
-
<
|
|
190
|
+
<ListItemIcon>
|
|
191
|
+
<FilterListOffIcon />
|
|
192
|
+
</ListItemIcon>
|
|
186
193
|
{localization.clearFilter}
|
|
187
194
|
</Box>
|
|
188
195
|
</MenuItem>,
|
|
@@ -193,7 +200,9 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
193
200
|
sx={commonMenuItemStyles}
|
|
194
201
|
>
|
|
195
202
|
<Box sx={commonListItemStyles}>
|
|
196
|
-
<
|
|
203
|
+
<ListItemIcon>
|
|
204
|
+
<FilterListIcon />
|
|
205
|
+
</ListItemIcon>
|
|
197
206
|
{localization.filterByColumn?.replace(
|
|
198
207
|
'{column}',
|
|
199
208
|
String(column.Header),
|
|
@@ -227,7 +236,9 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
227
236
|
sx={commonMenuItemStyles}
|
|
228
237
|
>
|
|
229
238
|
<Box sx={commonListItemStyles}>
|
|
230
|
-
<
|
|
239
|
+
<ListItemIcon>
|
|
240
|
+
<DynamicFeedIcon />
|
|
241
|
+
</ListItemIcon>
|
|
231
242
|
{localization[
|
|
232
243
|
column.isGrouped ? 'ungroupByColumn' : 'groupByColumn'
|
|
233
244
|
]?.replace('{column}', String(column.Header))}
|
|
@@ -237,7 +248,9 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
237
248
|
{!disableColumnHiding && [
|
|
238
249
|
<MenuItem key={0} onClick={handleHideColumn} sx={commonMenuItemStyles}>
|
|
239
250
|
<Box sx={commonListItemStyles}>
|
|
240
|
-
<
|
|
251
|
+
<ListItemIcon>
|
|
252
|
+
<VisibilityOffIcon />
|
|
253
|
+
</ListItemIcon>
|
|
241
254
|
{localization.hideColumn?.replace(
|
|
242
255
|
'{column}',
|
|
243
256
|
String(column.Header),
|
|
@@ -251,8 +264,9 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
251
264
|
sx={commonMenuItemStyles}
|
|
252
265
|
>
|
|
253
266
|
<Box sx={commonListItemStyles}>
|
|
254
|
-
<
|
|
255
|
-
|
|
267
|
+
<ListItemIcon>
|
|
268
|
+
<ViewColumnIcon />
|
|
269
|
+
</ListItemIcon>
|
|
256
270
|
{localization.showAllColumns?.replace(
|
|
257
271
|
'{column}',
|
|
258
272
|
String(column.Header),
|
|
@@ -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
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { Menu, MenuItem } from '@mui/material';
|
|
2
|
+
import { Box, ListItemIcon, Menu, MenuItem } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import type { MRT_Row } from '..';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
commonListItemStyles,
|
|
7
|
+
commonMenuItemStyles,
|
|
8
|
+
} from './MRT_ColumnActionMenu';
|
|
6
9
|
|
|
7
10
|
interface Props {
|
|
8
11
|
anchorEl: HTMLElement | null;
|
|
@@ -36,8 +39,12 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
36
39
|
>
|
|
37
40
|
{enableRowEditing && (
|
|
38
41
|
<MenuItem onClick={handleEdit} sx={commonMenuItemStyles}>
|
|
39
|
-
<
|
|
40
|
-
|
|
42
|
+
<Box sx={commonListItemStyles}>
|
|
43
|
+
<ListItemIcon>
|
|
44
|
+
<EditIcon />
|
|
45
|
+
</ListItemIcon>
|
|
46
|
+
{localization.edit}
|
|
47
|
+
</Box>
|
|
41
48
|
</MenuItem>
|
|
42
49
|
)}
|
|
43
50
|
{renderRowActionMenuItems?.(row, tableInstance, () =>
|
|
@@ -3,6 +3,7 @@ import { FormControlLabel, MenuItem, Switch } from '@mui/material';
|
|
|
3
3
|
import { ColumnInstance } from 'react-table';
|
|
4
4
|
import type { MRT_ColumnInstance } from '..';
|
|
5
5
|
import { commonMenuItemStyles } from './MRT_ColumnActionMenu';
|
|
6
|
+
import { useMRT } from '../useMRT';
|
|
6
7
|
|
|
7
8
|
interface Props {
|
|
8
9
|
column: MRT_ColumnInstance;
|
|
@@ -13,6 +14,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
13
14
|
column,
|
|
14
15
|
isSubMenu,
|
|
15
16
|
}) => {
|
|
17
|
+
const { onColumnHide, tableInstance } = useMRT();
|
|
16
18
|
const isParentHeader = !!column?.columns?.length;
|
|
17
19
|
|
|
18
20
|
const allChildColumnsVisible =
|
|
@@ -29,6 +31,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
29
31
|
} else {
|
|
30
32
|
column.toggleHidden();
|
|
31
33
|
}
|
|
34
|
+
onColumnHide?.(column, tableInstance.state.hiddenColumns);
|
|
32
35
|
};
|
|
33
36
|
|
|
34
37
|
return (
|