material-react-table 0.6.3 → 0.6.6
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 +5 -3
- package/dist/buttons/MRT_CopyButton.d.ts +7 -0
- package/dist/filtersFNs.d.ts +10 -10
- package/dist/icons.d.ts +2 -0
- package/dist/localization.d.ts +2 -0
- package/dist/material-react-table.cjs.development.js +149 -70
- 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 +150 -71
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +0 -1
- package/package.json +4 -4
- package/src/MaterialReactTable.tsx +5 -3
- package/src/body/MRT_TableBodyCell.tsx +10 -2
- 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/filtersFNs.ts +30 -30
- package/src/icons.ts +6 -0
- package/src/inputs/MRT_EditCellTextField.tsx +1 -1
- package/src/inputs/MRT_FilterTextField.tsx +24 -12
- package/src/localization.ts +4 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +25 -11
- package/src/menus/MRT_FilterTypeMenu.tsx +76 -72
- package/src/menus/MRT_RowActionMenu.tsx +11 -4
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +3 -0
- package/src/table/MRT_TableContainer.tsx +1 -1
- package/src/useMRT.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
2
|
+
"version": "0.6.6",
|
|
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
62
|
"@faker-js/faker": "^6.0.0-beta.0",
|
|
63
|
-
"@mui/icons-material": "^5.5.
|
|
64
|
-
"@mui/material": "^5.5.
|
|
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",
|
|
@@ -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
|
+
disableEditing?: boolean;
|
|
137
138
|
disableFilters?: boolean;
|
|
138
|
-
|
|
139
|
+
disableCellCopyButton?: 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
|
+
enableCellCopyButtons?: 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>,
|
|
@@ -367,7 +369,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
367
369
|
) => ReactNode;
|
|
368
370
|
};
|
|
369
371
|
|
|
370
|
-
export default <D extends {}>({
|
|
372
|
+
export default <D extends {} = {}>({
|
|
371
373
|
defaultColumn = { minWidth: 50, maxWidth: 1000 },
|
|
372
374
|
filterTypes,
|
|
373
375
|
globalFilter = 'fuzzy',
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import { Skeleton, TableCell, TableCellProps } from '@mui/material';
|
|
2
|
+
import { Box, 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
|
+
enableCellCopyButtons,
|
|
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,11 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
80
83
|
<span>
|
|
81
84
|
{cell.render('Cell')} ({cell.row.subRows.length})
|
|
82
85
|
</span>
|
|
86
|
+
) : enableCellCopyButtons && !cell.column.disableCellCopyButton ? (
|
|
87
|
+
<Box sx={{ whiteSpace: 'nowrap' }}>
|
|
88
|
+
{cell.render('Cell')}
|
|
89
|
+
{<MRT_CopyButton cell={cell} />}
|
|
90
|
+
</Box>
|
|
83
91
|
) : (
|
|
84
92
|
cell.render('Cell')
|
|
85
93
|
)}
|
|
@@ -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 { IconButton, 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 {
|
|
12
|
+
icons: { CheckBoxIcon, ContentCopyIcon },
|
|
13
|
+
localization,
|
|
14
|
+
} = useMRT();
|
|
15
|
+
|
|
16
|
+
const [copied, setCopied] = useState(false);
|
|
17
|
+
|
|
18
|
+
const handleCopy = (text: string) => {
|
|
19
|
+
navigator.clipboard.writeText(text);
|
|
20
|
+
setCopied(true);
|
|
21
|
+
setTimeout(() => setCopied(false), 2000);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Tooltip
|
|
26
|
+
arrow
|
|
27
|
+
title={copied ? localization.copiedToClipboard : localization.clickToCopy}
|
|
28
|
+
>
|
|
29
|
+
<IconButton
|
|
30
|
+
aria-label={localization.clickToCopy}
|
|
31
|
+
onClick={() => handleCopy(cell.value)}
|
|
32
|
+
size="small"
|
|
33
|
+
sx={{
|
|
34
|
+
opacity: 0.05,
|
|
35
|
+
m: '0 0.5rem',
|
|
36
|
+
transition: 'all 0.2s ease-in-out',
|
|
37
|
+
'&:hover': {
|
|
38
|
+
opacity: 1,
|
|
39
|
+
},
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
{copied ? (
|
|
43
|
+
<CheckBoxIcon color="success" fontSize="small" />
|
|
44
|
+
) : (
|
|
45
|
+
<ContentCopyIcon fontSize="small" />
|
|
46
|
+
)}
|
|
47
|
+
</IconButton>
|
|
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={{
|
package/src/filtersFNs.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { matchSorter } from 'match-sorter';
|
|
2
2
|
import { MRT_Row } from '.';
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const fuzzy = (
|
|
5
5
|
rows: MRT_Row[],
|
|
6
6
|
columnIds: string[] | string,
|
|
7
7
|
filterValue: string | number,
|
|
@@ -13,9 +13,9 @@ export const fuzzyFilterFN = (
|
|
|
13
13
|
sorter: (rankedItems) => rankedItems,
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
fuzzy.autoRemove = (val: any) => !val;
|
|
17
17
|
|
|
18
|
-
export const
|
|
18
|
+
export const contains = (
|
|
19
19
|
rows: MRT_Row[],
|
|
20
20
|
id: string,
|
|
21
21
|
filterValue: string | number,
|
|
@@ -28,9 +28,9 @@ export const containsFilterFN = (
|
|
|
28
28
|
.includes(filterValue.toString().toLowerCase().trim()),
|
|
29
29
|
);
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
contains.autoRemove = (val: any) => !val;
|
|
32
32
|
|
|
33
|
-
export const
|
|
33
|
+
export const startsWith = (
|
|
34
34
|
rows: MRT_Row[],
|
|
35
35
|
id: string,
|
|
36
36
|
filterValue: string | number,
|
|
@@ -43,9 +43,9 @@ export const startsWithFilterFN = (
|
|
|
43
43
|
.startsWith(filterValue.toString().toLowerCase().trim()),
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
startsWith.autoRemove = (val: any) => !val;
|
|
47
47
|
|
|
48
|
-
export const
|
|
48
|
+
export const endsWith = (
|
|
49
49
|
rows: MRT_Row[],
|
|
50
50
|
id: string,
|
|
51
51
|
filterValue: string | number,
|
|
@@ -58,9 +58,9 @@ export const endsWithFilterFN = (
|
|
|
58
58
|
.endsWith(filterValue.toString().toLowerCase().trim()),
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
endsWith.autoRemove = (val: any) => !val;
|
|
62
62
|
|
|
63
|
-
export const
|
|
63
|
+
export const equals = (
|
|
64
64
|
rows: MRT_Row[],
|
|
65
65
|
id: string,
|
|
66
66
|
filterValue: string | number,
|
|
@@ -71,9 +71,9 @@ export const equalsFilterFN = (
|
|
|
71
71
|
filterValue.toString().toLowerCase().trim(),
|
|
72
72
|
);
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
equals.autoRemove = (val: any) => !val;
|
|
75
75
|
|
|
76
|
-
export const
|
|
76
|
+
export const notEquals = (
|
|
77
77
|
rows: MRT_Row[],
|
|
78
78
|
id: string,
|
|
79
79
|
filterValue: string | number,
|
|
@@ -84,9 +84,9 @@ export const notEqualsFilterFN = (
|
|
|
84
84
|
filterValue.toString().toLowerCase().trim(),
|
|
85
85
|
);
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
notEquals.autoRemove = (val: any) => !val;
|
|
88
88
|
|
|
89
|
-
export const
|
|
89
|
+
export const greaterThan = (
|
|
90
90
|
rows: MRT_Row[],
|
|
91
91
|
id: string,
|
|
92
92
|
filterValue: string | number,
|
|
@@ -98,9 +98,9 @@ export const greaterThanFilterFN = (
|
|
|
98
98
|
filterValue.toString().toLowerCase().trim(),
|
|
99
99
|
);
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
greaterThan.autoRemove = (val: any) => !val;
|
|
102
102
|
|
|
103
|
-
export const
|
|
103
|
+
export const lessThan = (
|
|
104
104
|
rows: MRT_Row[],
|
|
105
105
|
id: string,
|
|
106
106
|
filterValue: string | number,
|
|
@@ -112,33 +112,33 @@ export const lessThanFilterFN = (
|
|
|
112
112
|
filterValue.toString().toLowerCase().trim(),
|
|
113
113
|
);
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
lessThan.autoRemove = (val: any) => !val;
|
|
116
116
|
|
|
117
|
-
export const
|
|
117
|
+
export const empty = (
|
|
118
118
|
rows: MRT_Row[],
|
|
119
119
|
id: string,
|
|
120
120
|
_filterValue: string | number,
|
|
121
121
|
) => rows.filter((row) => !row.values[id].toString().toLowerCase().trim());
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
empty.autoRemove = (val: any) => !val;
|
|
124
124
|
|
|
125
|
-
export const
|
|
125
|
+
export const notEmpty = (
|
|
126
126
|
rows: MRT_Row[],
|
|
127
127
|
id: string,
|
|
128
128
|
_filterValue: string | number,
|
|
129
129
|
) => rows.filter((row) => !!row.values[id].toString().toLowerCase().trim());
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
notEmpty.autoRemove = (val: any) => !val;
|
|
132
132
|
|
|
133
133
|
export const defaultFilterFNs = {
|
|
134
|
-
contains
|
|
135
|
-
empty
|
|
136
|
-
endsWith
|
|
137
|
-
equals
|
|
138
|
-
fuzzy
|
|
139
|
-
greaterThan
|
|
140
|
-
lessThan
|
|
141
|
-
notEmpty
|
|
142
|
-
notEquals
|
|
143
|
-
startsWith
|
|
134
|
+
contains,
|
|
135
|
+
empty,
|
|
136
|
+
endsWith,
|
|
137
|
+
equals,
|
|
138
|
+
fuzzy,
|
|
139
|
+
greaterThan,
|
|
140
|
+
lessThan,
|
|
141
|
+
notEmpty,
|
|
142
|
+
notEquals,
|
|
143
|
+
startsWith,
|
|
144
144
|
};
|
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,
|
|
@@ -77,6 +77,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
77
77
|
return <>{column.Filter?.({ column })}</>;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
const filterId = `mrt-${idPrefix}-${column.id}-filter-text-field`;
|
|
80
81
|
const filterType = tableInstance.state.currentFilterTypes[column.id];
|
|
81
82
|
const isSelectFilter = !!column.filterSelectOptions;
|
|
82
83
|
const filterChipLabel =
|
|
@@ -98,7 +99,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
98
99
|
<>
|
|
99
100
|
<TextField
|
|
100
101
|
fullWidth
|
|
101
|
-
id={
|
|
102
|
+
id={filterId}
|
|
102
103
|
inputProps={{
|
|
103
104
|
disabled: !!filterChipLabel,
|
|
104
105
|
sx: {
|
|
@@ -108,17 +109,28 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
108
109
|
title: filterPlaceholder,
|
|
109
110
|
}}
|
|
110
111
|
helperText={
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
112
|
+
<label htmlFor={filterId}>
|
|
113
|
+
{filterType instanceof Function
|
|
114
|
+
? localization.filterMode.replace(
|
|
115
|
+
'{filterType}',
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
localization[
|
|
118
|
+
`filter${
|
|
119
|
+
filterType.name.charAt(0).toUpperCase() +
|
|
120
|
+
filterType.name.slice(1)
|
|
121
|
+
}`
|
|
122
|
+
] ?? '',
|
|
123
|
+
) ?? ''
|
|
124
|
+
: localization.filterMode.replace(
|
|
125
|
+
'{filterType}',
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
localization[
|
|
128
|
+
`filter${
|
|
129
|
+
filterType.charAt(0).toUpperCase() + filterType.slice(1)
|
|
130
|
+
}`
|
|
131
|
+
],
|
|
132
|
+
)}
|
|
133
|
+
</label>
|
|
122
134
|
}
|
|
123
135
|
FormHelperTextProps={{
|
|
124
136
|
sx: { fontSize: '0.6rem', lineHeight: '0.8rem' },
|
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),
|