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
|
@@ -4,16 +4,16 @@ import { useMRT } from '../useMRT';
|
|
|
4
4
|
import type { MRT_FilterType, MRT_HeaderGroup } from '..';
|
|
5
5
|
import { MRT_FILTER_TYPE } from '../enums';
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
contains,
|
|
8
|
+
empty,
|
|
9
|
+
endsWith,
|
|
10
|
+
equals,
|
|
11
|
+
fuzzy,
|
|
12
|
+
greaterThan,
|
|
13
|
+
lessThan,
|
|
14
|
+
notEmpty,
|
|
15
|
+
notEquals,
|
|
16
|
+
startsWith,
|
|
17
17
|
} from '../filtersFNs';
|
|
18
18
|
|
|
19
19
|
const commonMenuItemStyles = {
|
|
@@ -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 (
|
|
@@ -40,7 +40,7 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
40
40
|
height: fullScreen ? '100%' : undefined,
|
|
41
41
|
left: fullScreen ? '0' : undefined,
|
|
42
42
|
m: fullScreen ? '0' : undefined,
|
|
43
|
-
overflowY: 'hidden',
|
|
43
|
+
overflowY: !fullScreen ? 'hidden' : undefined,
|
|
44
44
|
position: fullScreen ? 'fixed' : undefined,
|
|
45
45
|
right: fullScreen ? '0' : undefined,
|
|
46
46
|
top: fullScreen ? '0' : undefined,
|
package/src/useMRT.tsx
CHANGED
|
@@ -128,7 +128,7 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
|
|
|
128
128
|
() =>
|
|
129
129
|
!props.isLoading || !!props.data.length
|
|
130
130
|
? props.data
|
|
131
|
-
: [...Array(10)].map((_) =>
|
|
131
|
+
: [...Array(10).fill(null)].map((_) =>
|
|
132
132
|
Object.assign(
|
|
133
133
|
{},
|
|
134
134
|
...findLowestLevelCols(props.columns).map((c) => ({
|