material-react-table 0.4.9 → 0.5.2
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 -4
- package/dist/body/MRT_TableBodyCell.d.ts +10 -3
- package/dist/body/MRT_TableBodyRow.d.ts +1 -16
- package/dist/head/MRT_TableHeadCell.d.ts +8 -4
- package/dist/material-react-table.cjs.development.js +448 -518
- 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 +453 -523
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/useMRT.d.ts +0 -5
- package/package.json +4 -4
- package/src/@types/react-table-config.d.ts +3 -3
- package/src/MaterialReactTable.tsx +5 -4
- package/src/body/MRT_TableBody.tsx +6 -7
- package/src/body/MRT_TableBodyCell.tsx +23 -13
- package/src/body/MRT_TableBodyRow.tsx +17 -13
- package/src/body/MRT_TableDetailPanel.tsx +9 -26
- package/src/buttons/MRT_EditActionButtons.tsx +5 -10
- package/src/buttons/MRT_ExpandAllButton.tsx +7 -8
- package/src/buttons/MRT_ExpandButton.tsx +13 -11
- package/src/buttons/MRT_FullScreenToggleButton.tsx +3 -1
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +9 -9
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +11 -12
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +3 -1
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +23 -16
- package/src/buttons/MRT_ToggleSearchButton.tsx +1 -1
- package/src/footer/MRT_TableFooterCell.tsx +17 -19
- package/src/footer/MRT_TableFooterRow.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +51 -57
- package/src/head/MRT_TableHeadCellActions.tsx +11 -5
- package/src/head/MRT_TableHeadRow.tsx +10 -4
- package/src/inputs/MRT_EditCellTextField.tsx +3 -1
- package/src/inputs/MRT_SearchTextField.tsx +3 -13
- package/src/inputs/MRT_SelectCheckbox.tsx +4 -5
- package/src/menus/MRT_ColumnActionMenu.tsx +17 -6
- package/src/menus/MRT_RowActionMenu.tsx +2 -7
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +1 -1
- package/src/table/MRT_Table.tsx +1 -1
- package/src/table/MRT_TableContainer.tsx +18 -42
- package/src/table/MRT_TableSpacerCell.tsx +4 -3
- package/src/toolbar/MRT_TablePagination.tsx +6 -1
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +19 -29
- package/src/toolbar/MRT_ToolbarBottom.tsx +23 -21
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +13 -12
- package/src/toolbar/MRT_ToolbarTop.tsx +38 -36
- package/src/useMRT.tsx +38 -23
- package/dist/table/MRT_TableButtonCell.d.ts +0 -3
- package/src/table/MRT_TableButtonCell.tsx +0 -9
package/dist/useMRT.d.ts
CHANGED
|
@@ -6,9 +6,6 @@ import { MaterialReactTableProps } from './MaterialReactTable';
|
|
|
6
6
|
export declare type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
|
|
7
7
|
anyRowsCanExpand: boolean;
|
|
8
8
|
anyRowsExpanded: boolean;
|
|
9
|
-
currentEditingRow: MRT_Row<D> | null;
|
|
10
|
-
densePadding: boolean;
|
|
11
|
-
fullScreen: boolean;
|
|
12
9
|
icons: MRT_Icons;
|
|
13
10
|
localization: MRT_Localization;
|
|
14
11
|
setCurrentEditingRow: (currentRowEditingId: MRT_Row<D> | null) => void;
|
|
@@ -16,8 +13,6 @@ export declare type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
|
|
|
16
13
|
setFullScreen: (fullScreen: boolean) => void;
|
|
17
14
|
setShowFilters: (showFilters: boolean) => void;
|
|
18
15
|
setShowSearch: (showSearch: boolean) => void;
|
|
19
|
-
showFilters: boolean;
|
|
20
|
-
showSearch: boolean;
|
|
21
16
|
tableInstance: MRT_TableInstance<D>;
|
|
22
17
|
};
|
|
23
18
|
export declare const MaterialReactTableProvider: <D extends {}>(props: React.PropsWithChildren<MaterialReactTableProps<D>>) => JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.5.2",
|
|
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.",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"@emotion/styled": "^11.8.1",
|
|
62
62
|
"@etchteam/storybook-addon-status": "^4.2.0",
|
|
63
63
|
"@faker-js/faker": "^6.0.0-alpha.7",
|
|
64
|
-
"@mui/icons-material": "^5.4.
|
|
65
|
-
"@mui/material": "^5.4.
|
|
64
|
+
"@mui/icons-material": "^5.4.4",
|
|
65
|
+
"@mui/material": "^5.4.4",
|
|
66
66
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
67
67
|
"@storybook/addon-a11y": "^6.4.19",
|
|
68
68
|
"@storybook/addon-actions": "^6.4.19",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"storybook-dark-mode": "^1.0.9",
|
|
90
90
|
"tsdx": "^0.14.1",
|
|
91
91
|
"tslib": "^2.3.1",
|
|
92
|
-
"typescript": "^4.
|
|
92
|
+
"typescript": "^4.6.2"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
95
|
"@emotion/react": ">=11",
|
|
@@ -14,8 +14,6 @@ import {
|
|
|
14
14
|
} from '..';
|
|
15
15
|
|
|
16
16
|
declare module 'react-table' {
|
|
17
|
-
// take this file as-is, or comment out the sections that don't apply to your plugin configuration
|
|
18
|
-
|
|
19
17
|
export interface TableOptions<D extends Record<string, unknown>>
|
|
20
18
|
extends MRT_TableOptions<D> {}
|
|
21
19
|
|
|
@@ -28,7 +26,9 @@ declare module 'react-table' {
|
|
|
28
26
|
|
|
29
27
|
export interface TableInstance<
|
|
30
28
|
D extends Record<string, unknown> = Record<string, unknown>,
|
|
31
|
-
> extends MRT_TableInstance<D> {
|
|
29
|
+
> extends MRT_TableInstance<D> {
|
|
30
|
+
rows: MRT_Row<D>[];
|
|
31
|
+
}
|
|
32
32
|
|
|
33
33
|
export interface TableState<
|
|
34
34
|
D extends Record<string, unknown> = Record<string, unknown>,
|
|
@@ -192,10 +192,11 @@ export type MRT_TableState<D extends {} = {}> = TableState<D> &
|
|
|
192
192
|
UseRowSelectState<D> &
|
|
193
193
|
UseRowStateState<D> &
|
|
194
194
|
UseSortByState<D> & {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
currentEditingRow: MRT_Row<D> | null;
|
|
196
|
+
densePadding: boolean;
|
|
197
|
+
fullScreen: boolean;
|
|
198
|
+
showFilters: boolean;
|
|
199
|
+
showSearch: boolean;
|
|
199
200
|
};
|
|
200
201
|
|
|
201
202
|
export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TableBody } from '@mui/material';
|
|
3
3
|
import { MRT_TableBodyRow } from './MRT_TableBodyRow';
|
|
4
4
|
import { useMRT } from '../useMRT';
|
|
5
5
|
import { MRT_Row } from '..';
|
|
6
6
|
|
|
7
|
-
const TableBody = styled(MuiTableBody)({
|
|
8
|
-
overflowY: 'hidden',
|
|
9
|
-
});
|
|
10
|
-
|
|
11
7
|
interface Props {}
|
|
12
8
|
|
|
13
9
|
export const MRT_TableBody: FC<Props> = () => {
|
|
@@ -20,12 +16,15 @@ export const MRT_TableBody: FC<Props> = () => {
|
|
|
20
16
|
...tableInstance.getTableBodyProps(),
|
|
21
17
|
style: {
|
|
22
18
|
...tableInstance.getTableBodyProps().style,
|
|
23
|
-
...
|
|
19
|
+
...muiTableBodyProps?.style,
|
|
24
20
|
},
|
|
25
21
|
};
|
|
26
22
|
|
|
27
23
|
return (
|
|
28
|
-
<TableBody
|
|
24
|
+
<TableBody
|
|
25
|
+
{...tableBodyProps}
|
|
26
|
+
sx={{ overflowY: 'hidden', ...tableBodyProps?.sx }}
|
|
27
|
+
>
|
|
29
28
|
{rows.map((row: MRT_Row) => {
|
|
30
29
|
tableInstance.prepareRow(row);
|
|
31
30
|
return <MRT_TableBodyRow key={row.getRowProps().key} row={row} />;
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TableCell, TableCellProps } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
|
5
5
|
import { MRT_Cell } from '..';
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
})<{ densePadding?: boolean }>(({ densePadding }) => ({
|
|
10
|
-
padding: densePadding ? '0.5rem' : '1rem',
|
|
7
|
+
export const commonTableBodyCellStyles = (densePadding: boolean) => ({
|
|
8
|
+
p: densePadding ? '0.5rem' : '1rem',
|
|
11
9
|
transition: 'all 0.2s ease-in-out',
|
|
12
10
|
whiteSpace: densePadding ? 'nowrap' : 'normal',
|
|
13
|
-
})
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const commonTableBodyButtonCellStyles = (densePadding: boolean) => ({
|
|
14
|
+
p: densePadding ? '1px' : '0.6rem',
|
|
15
|
+
textAlign: 'center',
|
|
16
|
+
transition: 'all 0.2s ease-in-out',
|
|
17
|
+
});
|
|
14
18
|
|
|
15
19
|
interface Props {
|
|
16
20
|
cell: MRT_Cell;
|
|
@@ -20,8 +24,9 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
20
24
|
const {
|
|
21
25
|
onCellClick,
|
|
22
26
|
muiTableBodyCellProps,
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
tableInstance: {
|
|
28
|
+
state: { currentEditingRow, densePadding },
|
|
29
|
+
},
|
|
25
30
|
} = useMRT();
|
|
26
31
|
|
|
27
32
|
const mTableCellBodyProps =
|
|
@@ -40,18 +45,23 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
40
45
|
...cell.getCellProps(),
|
|
41
46
|
style: {
|
|
42
47
|
...cell.getCellProps().style,
|
|
43
|
-
...
|
|
44
|
-
...
|
|
48
|
+
...mTableCellBodyProps?.style,
|
|
49
|
+
...mcTableCellBodyProps?.style,
|
|
45
50
|
},
|
|
46
51
|
};
|
|
47
52
|
|
|
48
53
|
return (
|
|
49
|
-
<
|
|
50
|
-
densePadding={densePadding}
|
|
54
|
+
<TableCell
|
|
51
55
|
onClick={(event: MouseEvent<HTMLTableCellElement>) =>
|
|
52
56
|
onCellClick?.(event, cell)
|
|
53
57
|
}
|
|
54
58
|
{...tableCellProps}
|
|
59
|
+
sx={
|
|
60
|
+
{
|
|
61
|
+
...commonTableBodyCellStyles(densePadding),
|
|
62
|
+
...tableCellProps?.sx,
|
|
63
|
+
} as TableCellProps['sx']
|
|
64
|
+
}
|
|
55
65
|
>
|
|
56
66
|
{currentEditingRow?.id === cell.row.id ? (
|
|
57
67
|
<MRT_EditCellTextField cell={cell} />
|
|
@@ -64,6 +74,6 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
64
74
|
) : (
|
|
65
75
|
cell.render('Cell')
|
|
66
76
|
)}
|
|
67
|
-
</
|
|
77
|
+
</TableCell>
|
|
68
78
|
);
|
|
69
79
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import { alpha,
|
|
2
|
+
import { alpha, TableCell, TableRow } from '@mui/material';
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
commonTableBodyCellStyles,
|
|
5
5
|
MRT_TableBodyCell,
|
|
6
6
|
} from './MRT_TableBodyCell';
|
|
7
7
|
import { useMRT } from '../useMRT';
|
|
@@ -11,14 +11,6 @@ import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
|
|
11
11
|
import { MRT_ToggleRowActionMenuButton } from '../buttons/MRT_ToggleRowActionMenuButton';
|
|
12
12
|
import { MRT_Cell, MRT_Row } from '..';
|
|
13
13
|
|
|
14
|
-
export const TableRow = styled(MuiTableRow, {
|
|
15
|
-
shouldForwardProp: (prop) => prop !== 'isSelected',
|
|
16
|
-
})<{ isSelected?: boolean }>(({ isSelected, theme }) => ({
|
|
17
|
-
backgroundColor: isSelected
|
|
18
|
-
? alpha(theme.palette.primary.light, 0.1)
|
|
19
|
-
: 'transparent',
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
14
|
interface Props {
|
|
23
15
|
row: MRT_Row;
|
|
24
16
|
}
|
|
@@ -34,6 +26,9 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
34
26
|
onRowClick,
|
|
35
27
|
positionActionsColumn,
|
|
36
28
|
renderDetailPanel,
|
|
29
|
+
tableInstance: {
|
|
30
|
+
state: { densePadding },
|
|
31
|
+
},
|
|
37
32
|
} = useMRT();
|
|
38
33
|
|
|
39
34
|
const mTableBodyRowProps =
|
|
@@ -46,22 +41,31 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
46
41
|
...row.getRowProps(),
|
|
47
42
|
style: {
|
|
48
43
|
...row.getRowProps().style,
|
|
49
|
-
...
|
|
44
|
+
...mTableBodyRowProps?.style,
|
|
50
45
|
},
|
|
51
46
|
};
|
|
52
47
|
|
|
53
48
|
return (
|
|
54
49
|
<>
|
|
55
50
|
<TableRow
|
|
56
|
-
isSelected={row.isSelected}
|
|
57
51
|
hover
|
|
58
52
|
onClick={(event: MouseEvent<HTMLTableRowElement>) =>
|
|
59
53
|
onRowClick?.(event, row)
|
|
60
54
|
}
|
|
61
55
|
{...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
|
+
}
|
|
62
64
|
>
|
|
63
65
|
{enableRowNumbers && (
|
|
64
|
-
<
|
|
66
|
+
<TableCell sx={{ ...commonTableBodyCellStyles(densePadding) }}>
|
|
67
|
+
{row.index + 1}
|
|
68
|
+
</TableCell>
|
|
65
69
|
)}
|
|
66
70
|
{(enableRowActions || enableRowEditing) &&
|
|
67
71
|
positionActionsColumn === 'first' && (
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Collapse,
|
|
4
|
-
styled,
|
|
5
|
-
TableCell as MuiTableCell,
|
|
6
|
-
TableRow,
|
|
7
|
-
} from '@mui/material';
|
|
2
|
+
import { Collapse, TableCell, TableRow } from '@mui/material';
|
|
8
3
|
import { useMRT } from '../useMRT';
|
|
9
4
|
import { MRT_Row } from '..';
|
|
10
5
|
|
|
11
|
-
const TableCell = styled(MuiTableCell, {
|
|
12
|
-
shouldForwardProp: (prop) => prop !== 'isExpanded',
|
|
13
|
-
})<{ isExpanded?: boolean }>(({ isExpanded }) => ({
|
|
14
|
-
borderBottom: !isExpanded ? 'none' : undefined,
|
|
15
|
-
paddingBottom: isExpanded ? '1rem' : 0,
|
|
16
|
-
paddingTop: isExpanded ? '1rem' : 0,
|
|
17
|
-
transition: 'all 0.2s ease-in-out',
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
6
|
interface Props {
|
|
21
7
|
row: MRT_Row;
|
|
22
8
|
}
|
|
@@ -30,20 +16,11 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row }) => {
|
|
|
30
16
|
tableInstance,
|
|
31
17
|
} = useMRT();
|
|
32
18
|
|
|
33
|
-
const
|
|
19
|
+
const tableRowProps =
|
|
34
20
|
muiTableBodyRowProps instanceof Function
|
|
35
21
|
? muiTableBodyRowProps(row)
|
|
36
22
|
: muiTableBodyRowProps;
|
|
37
23
|
|
|
38
|
-
const tableRowProps = {
|
|
39
|
-
...mTableBodyRowProps,
|
|
40
|
-
...row.getRowProps(),
|
|
41
|
-
style: {
|
|
42
|
-
...row.getRowProps().style,
|
|
43
|
-
...(mTableBodyRowProps?.style ?? {}),
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
24
|
const tableCellProps =
|
|
48
25
|
muiTableDetailPanelProps instanceof Function
|
|
49
26
|
? muiTableDetailPanelProps(row)
|
|
@@ -53,11 +30,17 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row }) => {
|
|
|
53
30
|
<TableRow {...tableRowProps}>
|
|
54
31
|
<TableCell
|
|
55
32
|
colSpan={tableInstance.visibleColumns.length + 10}
|
|
56
|
-
isExpanded={row.isExpanded}
|
|
57
33
|
onClick={(event: MouseEvent<HTMLTableCellElement>) =>
|
|
58
34
|
onDetailPanelClick?.(event, row)
|
|
59
35
|
}
|
|
60
36
|
{...tableCellProps}
|
|
37
|
+
sx={{
|
|
38
|
+
borderBottom: !row.isExpanded ? 'none' : undefined,
|
|
39
|
+
pb: row.isExpanded ? '1rem' : 0,
|
|
40
|
+
pt: row.isExpanded ? '1rem' : 0,
|
|
41
|
+
transition: 'all 0.2s ease-in-out',
|
|
42
|
+
...tableCellProps?.sx,
|
|
43
|
+
}}
|
|
61
44
|
>
|
|
62
45
|
<Collapse in={row.isExpanded}>{renderDetailPanel?.(row)}</Collapse>
|
|
63
46
|
</TableCell>
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Box, IconButton, Tooltip } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_Row } from '..';
|
|
5
5
|
|
|
6
|
-
const EditActionButtonWrappers = styled('div')({
|
|
7
|
-
display: 'flex',
|
|
8
|
-
gap: '0.75rem',
|
|
9
|
-
});
|
|
10
|
-
|
|
11
6
|
interface Props {
|
|
12
7
|
row: MRT_Row;
|
|
13
8
|
}
|
|
@@ -16,9 +11,9 @@ export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
|
|
|
16
11
|
const {
|
|
17
12
|
icons: { CancelIcon, SaveIcon },
|
|
18
13
|
localization,
|
|
19
|
-
setCurrentEditingRow,
|
|
20
14
|
onRowEditSubmit,
|
|
21
|
-
|
|
15
|
+
setCurrentEditingRow,
|
|
16
|
+
tableInstance: { state: { currentEditingRow } },
|
|
22
17
|
} = useMRT();
|
|
23
18
|
|
|
24
19
|
const handleCancel = () => {
|
|
@@ -32,7 +27,7 @@ export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
|
|
|
32
27
|
};
|
|
33
28
|
|
|
34
29
|
return (
|
|
35
|
-
<
|
|
30
|
+
<Box sx={{ display: 'flex', gap: '0.75rem' }}>
|
|
36
31
|
<Tooltip arrow title={localization.rowActionButtonCancel}>
|
|
37
32
|
<IconButton
|
|
38
33
|
aria-label={localization.rowActionButtonCancel}
|
|
@@ -50,6 +45,6 @@ export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
|
|
|
50
45
|
<SaveIcon />
|
|
51
46
|
</IconButton>
|
|
52
47
|
</Tooltip>
|
|
53
|
-
</
|
|
48
|
+
</Box>
|
|
54
49
|
);
|
|
55
50
|
};
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { IconButton } from '@mui/material';
|
|
2
|
+
import { IconButton, TableCell } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
|
-
import {
|
|
4
|
+
import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
|
|
5
5
|
|
|
6
6
|
interface Props {}
|
|
7
7
|
|
|
8
8
|
export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
9
9
|
const {
|
|
10
|
-
tableInstance,
|
|
11
|
-
localization,
|
|
12
10
|
anyRowsExpanded,
|
|
13
|
-
densePadding,
|
|
14
11
|
icons: { DoubleArrowDownIcon },
|
|
12
|
+
localization,
|
|
13
|
+
tableInstance,
|
|
15
14
|
} = useMRT();
|
|
16
15
|
|
|
17
16
|
return (
|
|
18
|
-
<
|
|
17
|
+
<TableCell
|
|
19
18
|
size="small"
|
|
20
|
-
densePadding={densePadding}
|
|
21
19
|
{...tableInstance.getToggleAllRowsExpandedProps()}
|
|
20
|
+
sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)}
|
|
22
21
|
>
|
|
23
22
|
<IconButton
|
|
24
23
|
aria-label={localization.expandAllButtonTitle}
|
|
@@ -33,6 +32,6 @@ export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
|
33
32
|
}}
|
|
34
33
|
/>
|
|
35
34
|
</IconButton>
|
|
36
|
-
</
|
|
35
|
+
</TableCell>
|
|
37
36
|
);
|
|
38
37
|
};
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { IconButton,
|
|
2
|
+
import { IconButton, TableCell } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
|
-
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
5
4
|
import { MRT_Row } from '..';
|
|
6
|
-
|
|
7
|
-
const TableCell = styled(MRT_TableButtonCell, {
|
|
8
|
-
shouldForwardProp: (prop) => prop !== 'depth',
|
|
9
|
-
})<{ depth: number }>(({ depth }) => ({
|
|
10
|
-
paddingLeft: `${depth + 0.5}rem`,
|
|
11
|
-
textAlign: 'left',
|
|
12
|
-
}));
|
|
5
|
+
import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
|
|
13
6
|
|
|
14
7
|
interface Props {
|
|
15
8
|
row: MRT_Row;
|
|
@@ -17,14 +10,23 @@ interface Props {
|
|
|
17
10
|
|
|
18
11
|
export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
19
12
|
const {
|
|
20
|
-
densePadding,
|
|
21
13
|
icons: { ExpandMoreIcon },
|
|
22
14
|
localization,
|
|
23
15
|
renderDetailPanel,
|
|
16
|
+
tableInstance: {
|
|
17
|
+
state: { densePadding },
|
|
18
|
+
},
|
|
24
19
|
} = useMRT();
|
|
25
20
|
|
|
26
21
|
return (
|
|
27
|
-
<TableCell
|
|
22
|
+
<TableCell
|
|
23
|
+
size="small"
|
|
24
|
+
sx={{
|
|
25
|
+
...commonTableBodyButtonCellStyles(densePadding),
|
|
26
|
+
pl: `${row.depth + 0.5}rem`,
|
|
27
|
+
textAlign: 'left',
|
|
28
|
+
}}
|
|
29
|
+
>
|
|
28
30
|
<IconButton
|
|
29
31
|
aria-label={localization.expandButtonTitle}
|
|
30
32
|
disabled={!row.canExpand && !renderDetailPanel}
|
|
@@ -6,10 +6,12 @@ interface Props extends IconButtonProps {}
|
|
|
6
6
|
|
|
7
7
|
export const MRT_FullScreenToggleButton: FC<Props> = ({ ...rest }) => {
|
|
8
8
|
const {
|
|
9
|
-
fullScreen,
|
|
10
9
|
icons: { FullscreenExitIcon, FullscreenIcon },
|
|
11
10
|
localization,
|
|
12
11
|
setFullScreen,
|
|
12
|
+
tableInstance: {
|
|
13
|
+
state: { fullScreen },
|
|
14
|
+
},
|
|
13
15
|
} = useMRT();
|
|
14
16
|
|
|
15
17
|
return (
|
|
@@ -4,20 +4,14 @@ import {
|
|
|
4
4
|
IconButton,
|
|
5
5
|
Menu,
|
|
6
6
|
Tooltip,
|
|
7
|
-
styled,
|
|
8
7
|
Divider,
|
|
9
8
|
IconButtonProps,
|
|
9
|
+
Box,
|
|
10
10
|
} from '@mui/material';
|
|
11
11
|
import { useMRT } from '../useMRT';
|
|
12
12
|
import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
|
|
13
13
|
import { MRT_ColumnInstance } from '..';
|
|
14
14
|
|
|
15
|
-
const MenuButtons = styled('div')({
|
|
16
|
-
display: 'flex',
|
|
17
|
-
justifyContent: 'space-between',
|
|
18
|
-
padding: '0 0.5rem 0.5rem 0.5rem',
|
|
19
|
-
});
|
|
20
|
-
|
|
21
15
|
interface Props extends IconButtonProps {}
|
|
22
16
|
|
|
23
17
|
export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
|
|
@@ -50,7 +44,13 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
|
|
|
50
44
|
open={!!anchorEl}
|
|
51
45
|
onClose={() => setAnchorEl(null)}
|
|
52
46
|
>
|
|
53
|
-
<
|
|
47
|
+
<Box
|
|
48
|
+
sx={{
|
|
49
|
+
display: 'flex',
|
|
50
|
+
justifyContent: 'space-between',
|
|
51
|
+
p: '0 0.5rem 0.5rem 0.5rem',
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
54
|
<Button
|
|
55
55
|
disabled={
|
|
56
56
|
!tableInstance.getToggleHideAllColumnsProps().checked &&
|
|
@@ -66,7 +66,7 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
|
|
|
66
66
|
>
|
|
67
67
|
{localization.columnShowHideMenuShowAll}
|
|
68
68
|
</Button>
|
|
69
|
-
</
|
|
69
|
+
</Box>
|
|
70
70
|
<Divider />
|
|
71
71
|
{tableInstance.columns.map((column: MRT_ColumnInstance, index) => (
|
|
72
72
|
<MRT_ShowHideColumnsMenu
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
-
import { IconButton
|
|
2
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
|
5
5
|
import { MRT_HeaderGroup } from '..';
|
|
6
6
|
|
|
7
|
-
const IconButton = styled(MuiIconButton)({
|
|
8
|
-
opacity: 0.5,
|
|
9
|
-
transition: 'opacity 0.2s',
|
|
10
|
-
marginRight: '2px',
|
|
11
|
-
height: '1.6rem',
|
|
12
|
-
width: '1.6rem',
|
|
13
|
-
'&:hover': {
|
|
14
|
-
opacity: 1,
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
|
|
18
7
|
interface Props {
|
|
19
8
|
column: MRT_HeaderGroup;
|
|
20
9
|
}
|
|
@@ -45,6 +34,16 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
45
34
|
aria-label={localization.columnActionMenuButtonTitle}
|
|
46
35
|
onClick={handleClick}
|
|
47
36
|
size="small"
|
|
37
|
+
sx={{
|
|
38
|
+
opacity: 0.5,
|
|
39
|
+
transition: 'opacity 0.2s',
|
|
40
|
+
marginRight: '2px',
|
|
41
|
+
height: '1.6rem',
|
|
42
|
+
width: '1.6rem',
|
|
43
|
+
'&:hover': {
|
|
44
|
+
opacity: 1,
|
|
45
|
+
},
|
|
46
|
+
}}
|
|
48
47
|
>
|
|
49
48
|
<MoreVertIcon />
|
|
50
49
|
</IconButton>
|
|
@@ -6,10 +6,12 @@ interface Props extends IconButtonProps {}
|
|
|
6
6
|
|
|
7
7
|
export const MRT_ToggleDensePaddingButton: FC<Props> = ({ ...rest }) => {
|
|
8
8
|
const {
|
|
9
|
-
densePadding,
|
|
10
9
|
setDensePadding,
|
|
11
10
|
localization,
|
|
12
11
|
icons: { DensityMediumIcon, DensitySmallIcon },
|
|
12
|
+
tableInstance: {
|
|
13
|
+
state: { densePadding },
|
|
14
|
+
},
|
|
13
15
|
} = useMRT();
|
|
14
16
|
|
|
15
17
|
return (
|
|
@@ -6,10 +6,10 @@ interface Props extends IconButtonProps {}
|
|
|
6
6
|
|
|
7
7
|
export const MRT_ToggleFiltersButton: FC<Props> = ({ ...rest }) => {
|
|
8
8
|
const {
|
|
9
|
+
icons: { FilterListIcon, FilterListOffIcon },
|
|
9
10
|
localization,
|
|
10
11
|
setShowFilters,
|
|
11
|
-
showFilters,
|
|
12
|
-
icons: { FilterListIcon, FilterListOffIcon },
|
|
12
|
+
tableInstance: { state: { showFilters } },
|
|
13
13
|
} = useMRT();
|
|
14
14
|
|
|
15
15
|
return (
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
-
import { IconButton
|
|
2
|
+
import { IconButton, TableCell, Tooltip } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
|
|
5
5
|
import { MRT_EditActionButtons } from './MRT_EditActionButtons';
|
|
6
|
-
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
7
6
|
import { MRT_Row } from '..';
|
|
7
|
+
import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const commonIconButtonStyles = {
|
|
10
10
|
opacity: 0.5,
|
|
11
11
|
transition: 'opacity 0.2s',
|
|
12
12
|
marginRight: '2px',
|
|
@@ -15,7 +15,7 @@ const IconButton = styled(MuiIconButton)({
|
|
|
15
15
|
'&:hover': {
|
|
16
16
|
opacity: 1,
|
|
17
17
|
},
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
19
|
|
|
20
20
|
interface Props {
|
|
21
21
|
row: MRT_Row;
|
|
@@ -23,8 +23,6 @@ interface Props {
|
|
|
23
23
|
|
|
24
24
|
export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
25
25
|
const {
|
|
26
|
-
currentEditingRow,
|
|
27
|
-
densePadding,
|
|
28
26
|
enableRowEditing,
|
|
29
27
|
icons: { EditIcon, MoreHorizIcon },
|
|
30
28
|
localization,
|
|
@@ -48,10 +46,12 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
|
48
46
|
};
|
|
49
47
|
|
|
50
48
|
return (
|
|
51
|
-
<
|
|
49
|
+
<TableCell
|
|
50
|
+
sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)}
|
|
51
|
+
>
|
|
52
52
|
{renderRowActions ? (
|
|
53
53
|
<>{renderRowActions(row, tableInstance)}</>
|
|
54
|
-
) : row.id === currentEditingRow?.id ? (
|
|
54
|
+
) : row.id === tableInstance.state.currentEditingRow?.id ? (
|
|
55
55
|
<MRT_EditActionButtons row={row} />
|
|
56
56
|
) : !renderRowActionMenuItems && enableRowEditing ? (
|
|
57
57
|
<Tooltip
|
|
@@ -59,20 +59,27 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
|
59
59
|
arrow
|
|
60
60
|
title={localization.rowActionMenuItemEdit}
|
|
61
61
|
>
|
|
62
|
-
<IconButton onClick={handleEdit}>
|
|
62
|
+
<IconButton sx={commonIconButtonStyles} onClick={handleEdit}>
|
|
63
63
|
<EditIcon />
|
|
64
64
|
</IconButton>
|
|
65
65
|
</Tooltip>
|
|
66
66
|
) : renderRowActionMenuItems ? (
|
|
67
67
|
<>
|
|
68
|
-
<
|
|
69
|
-
|
|
68
|
+
<Tooltip
|
|
69
|
+
arrow
|
|
70
|
+
enterDelay={1000}
|
|
71
|
+
enterNextDelay={1000}
|
|
70
72
|
title={localization.rowActionMenuButtonTitle}
|
|
71
|
-
onClick={handleOpenRowActionMenu}
|
|
72
|
-
size="small"
|
|
73
73
|
>
|
|
74
|
-
<
|
|
75
|
-
|
|
74
|
+
<IconButton
|
|
75
|
+
aria-label={localization.rowActionMenuButtonTitle}
|
|
76
|
+
onClick={handleOpenRowActionMenu}
|
|
77
|
+
size="small"
|
|
78
|
+
sx={commonIconButtonStyles}
|
|
79
|
+
>
|
|
80
|
+
<MoreHorizIcon />
|
|
81
|
+
</IconButton>
|
|
82
|
+
</Tooltip>
|
|
76
83
|
<MRT_RowActionMenu
|
|
77
84
|
anchorEl={anchorEl}
|
|
78
85
|
handleEdit={handleEdit}
|
|
@@ -81,6 +88,6 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
|
81
88
|
/>
|
|
82
89
|
</>
|
|
83
90
|
) : null}
|
|
84
|
-
</
|
|
91
|
+
</TableCell>
|
|
85
92
|
);
|
|
86
93
|
};
|