material-react-table 0.6.4 → 0.6.5
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 +2 -2
- package/dist/material-react-table.cjs.development.js +36 -22
- 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 +37 -23
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +0 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +2 -2
- package/src/body/MRT_TableBodyCell.tsx +2 -1
- package/src/body/MRT_TableBodyRow.tsx +2 -9
- package/src/buttons/MRT_ExpandButton.tsx +9 -1
- package/src/inputs/MRT_EditCellTextField.tsx +1 -1
- package/src/menus/MRT_ColumnActionMenu.tsx +25 -11
- 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.5",
|
|
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.",
|
|
@@ -134,8 +134,8 @@ 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
|
-
editable?: boolean;
|
|
139
139
|
filter?: MRT_FilterType | string | FilterType<D>;
|
|
140
140
|
filterSelectOptions?: (string | { text: string; value: string })[];
|
|
141
141
|
filterTypes?: (MRT_FILTER_TYPE | string)[];
|
|
@@ -314,7 +314,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
314
314
|
event: MouseEvent<HTMLTableCellElement>,
|
|
315
315
|
cell: MRT_Cell<D>,
|
|
316
316
|
) => void;
|
|
317
|
-
onColumnHide?: (column: Column<D>,
|
|
317
|
+
onColumnHide?: (column: Column<D>, hiddenColumns?: string[]) => void;
|
|
318
318
|
onDetailPanelClick?: (
|
|
319
319
|
event: MouseEvent<HTMLTableCellElement>,
|
|
320
320
|
row: Row<D>,
|
|
@@ -72,7 +72,8 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
72
72
|
width={Math.random() * (120 - 60) + 60}
|
|
73
73
|
{...muiTableBodyCellSkeletonProps}
|
|
74
74
|
/>
|
|
75
|
-
) :
|
|
75
|
+
) : !cell.column.disableEditing &&
|
|
76
|
+
currentEditingRow?.id === cell.row.id ? (
|
|
76
77
|
<MRT_EditCellTextField cell={cell} />
|
|
77
78
|
) : cell.isPlaceholder ? null : cell.isAggregated ? (
|
|
78
79
|
cell.render('Aggregated')
|
|
@@ -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) }}>
|
|
@@ -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,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),
|
|
@@ -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 (
|