material-react-table 0.3.3 → 0.4.1
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 +15 -7
- package/dist/body/MRT_TableBodyCell.d.ts +3 -0
- package/dist/buttons/MRT_FullScreenToggleButton.d.ts +4 -0
- package/dist/buttons/MRT_ToggleSearchButton.d.ts +4 -0
- package/dist/head/MRT_TableHeadCell.d.ts +1 -1
- package/dist/head/MRT_TableHeadCellActions.d.ts +5 -0
- package/dist/inputs/{MRT_EditCellTextfield.d.ts → MRT_EditCellTextField.d.ts} +1 -1
- package/dist/inputs/MRT_FilterTextField.d.ts +1 -1
- package/dist/material-react-table.cjs.development.js +604 -372
- 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 +607 -375
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +2 -2
- package/dist/menus/MRT_RowActionMenu.d.ts +1 -0
- package/dist/table/MRT_TableButtonCell.d.ts +3 -0
- package/dist/toolbar/MRT_ToolbarAlertBanner.d.ts +5 -0
- package/dist/toolbar/MRT_ToolbarInternalButtons.d.ts +5 -0
- package/dist/{useMaterialReactTable.d.ts → useMRT.d.ts} +8 -3
- package/dist/utils/localization.d.ts +8 -0
- package/package.json +21 -19
- package/src/@types/react-table-config.d.ts +37 -34
- package/src/MaterialReactTable.tsx +22 -6
- package/src/body/MRT_TableBody.tsx +2 -3
- package/src/body/MRT_TableBodyCell.tsx +8 -8
- package/src/body/MRT_TableBodyRow.tsx +13 -15
- package/src/body/MRT_TableDetailPanel.tsx +2 -2
- package/src/buttons/MRT_EditActionButtons.tsx +3 -2
- package/src/buttons/MRT_ExpandAllButton.tsx +8 -16
- package/src/buttons/MRT_ExpandButton.tsx +8 -9
- package/src/buttons/MRT_FullScreenToggleButton.tsx +23 -0
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +34 -3
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +5 -5
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +48 -26
- package/src/buttons/MRT_ToggleSearchButton.tsx +33 -0
- package/src/footer/MRT_TableFooter.tsx +2 -2
- package/src/footer/MRT_TableFooterCell.tsx +2 -2
- package/src/footer/MRT_TableFooterRow.tsx +9 -4
- package/src/head/MRT_TableHead.tsx +2 -2
- package/src/head/MRT_TableHeadCell.tsx +20 -16
- package/src/head/MRT_TableHeadCellActions.tsx +18 -0
- package/src/head/MRT_TableHeadRow.tsx +16 -11
- package/src/inputs/MRT_DensePaddingSwitch.tsx +5 -3
- package/src/inputs/{MRT_EditCellTextfield.tsx → MRT_EditCellTextField.tsx} +23 -16
- package/src/inputs/MRT_FilterTextField.tsx +43 -17
- package/src/inputs/MRT_SearchTextField.tsx +39 -34
- package/src/inputs/MRT_SelectAllCheckbox.tsx +9 -13
- package/src/inputs/MRT_SelectCheckbox.tsx +11 -14
- package/src/menus/MRT_ColumnActionMenu.tsx +66 -23
- package/src/menus/MRT_RowActionMenu.tsx +4 -8
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +24 -15
- package/src/table/MRT_Table.tsx +2 -2
- package/src/table/MRT_TableButtonCell.tsx +9 -0
- package/src/table/MRT_TableContainer.tsx +34 -8
- package/src/table/MRT_TableSpacerCell.tsx +2 -2
- package/src/toolbar/MRT_TablePagination.tsx +3 -2
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +102 -0
- package/src/toolbar/MRT_ToolbarBottom.tsx +9 -5
- package/src/toolbar/{MRT_ToolbarButtons.tsx → MRT_ToolbarInternalButtons.tsx} +13 -4
- package/src/toolbar/MRT_ToolbarTop.tsx +14 -15
- package/src/{useMaterialReactTable.tsx → useMRT.tsx} +40 -23
- package/src/utils/localization.ts +22 -6
- package/dist/toolbar/MRT_ToolbarButtons.d.ts +0 -5
- package/dist/utils/useMRTCalcs.d.ts +0 -11
- package/src/utils/useMRTCalcs.tsx +0 -42
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
IconButton,
|
|
5
|
+
Menu,
|
|
6
|
+
Tooltip,
|
|
7
|
+
styled,
|
|
8
|
+
Divider,
|
|
9
|
+
} from '@mui/material';
|
|
3
10
|
import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
|
4
|
-
import {
|
|
11
|
+
import { useMRT } from '../useMRT';
|
|
5
12
|
import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
|
|
6
13
|
|
|
14
|
+
const MenuButtons = styled('div')({
|
|
15
|
+
display: 'flex',
|
|
16
|
+
justifyContent: 'space-between',
|
|
17
|
+
padding: '0 0.5rem 0.5rem 0.5rem',
|
|
18
|
+
});
|
|
19
|
+
|
|
7
20
|
interface Props {}
|
|
8
21
|
|
|
9
22
|
export const MRT_ShowHideColumnsButton: FC<Props> = () => {
|
|
10
|
-
const { tableInstance, localization } =
|
|
23
|
+
const { tableInstance, localization } = useMRT();
|
|
11
24
|
|
|
12
25
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
13
26
|
|
|
@@ -31,6 +44,24 @@ export const MRT_ShowHideColumnsButton: FC<Props> = () => {
|
|
|
31
44
|
open={!!anchorEl}
|
|
32
45
|
onClose={() => setAnchorEl(null)}
|
|
33
46
|
>
|
|
47
|
+
<MenuButtons>
|
|
48
|
+
<Button
|
|
49
|
+
disabled={
|
|
50
|
+
!tableInstance.getToggleHideAllColumnsProps().checked &&
|
|
51
|
+
!tableInstance.getToggleHideAllColumnsProps().indeterminate
|
|
52
|
+
}
|
|
53
|
+
onClick={() => tableInstance.toggleHideAllColumns(true)}
|
|
54
|
+
>
|
|
55
|
+
{localization?.columnShowHideMenuHideAll}
|
|
56
|
+
</Button>
|
|
57
|
+
<Button
|
|
58
|
+
disabled={tableInstance.getToggleHideAllColumnsProps().checked}
|
|
59
|
+
onClick={() => tableInstance.toggleHideAllColumns(false)}
|
|
60
|
+
>
|
|
61
|
+
{localization?.columnShowHideMenuShowAll}
|
|
62
|
+
</Button>
|
|
63
|
+
</MenuButtons>
|
|
64
|
+
<Divider />
|
|
34
65
|
{tableInstance.columns.map((column, index) => (
|
|
35
66
|
<MRT_ShowHideColumnsMenu
|
|
36
67
|
key={`${index}-${column.id}`}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
2
|
import { IconButton as MuiIconButton, styled } from '@mui/material';
|
|
3
3
|
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
4
|
-
import {
|
|
4
|
+
import { useMRT } from '../useMRT';
|
|
5
5
|
import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
|
6
6
|
import { HeaderGroup } from 'react-table';
|
|
7
7
|
|
|
@@ -9,8 +9,8 @@ const IconButton = styled(MuiIconButton)({
|
|
|
9
9
|
opacity: 0.5,
|
|
10
10
|
transition: 'opacity 0.2s',
|
|
11
11
|
marginRight: '2px',
|
|
12
|
-
height: '
|
|
13
|
-
width: '
|
|
12
|
+
height: '1.6rem',
|
|
13
|
+
width: '1.6rem',
|
|
14
14
|
'&:hover': {
|
|
15
15
|
opacity: 1,
|
|
16
16
|
},
|
|
@@ -21,7 +21,7 @@ interface Props {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
24
|
-
const { localization } =
|
|
24
|
+
const { localization } = useMRT();
|
|
25
25
|
|
|
26
26
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
27
27
|
|
|
@@ -35,9 +35,9 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
35
35
|
<>
|
|
36
36
|
<IconButton
|
|
37
37
|
aria-label={localization?.columnActionMenuButtonTitle}
|
|
38
|
-
title={localization?.columnActionMenuButtonTitle}
|
|
39
38
|
onClick={handleClick}
|
|
40
39
|
size="small"
|
|
40
|
+
title={localization?.columnActionMenuButtonTitle}
|
|
41
41
|
>
|
|
42
42
|
<MoreVertIcon />
|
|
43
43
|
</IconButton>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { IconButton, Tooltip } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
4
|
import FilterListIcon from '@mui/icons-material/FilterList';
|
|
5
5
|
import FilterListOffIcon from '@mui/icons-material/FilterListOff';
|
|
6
6
|
|
|
7
7
|
type Props = {};
|
|
8
8
|
|
|
9
9
|
export const MRT_ToggleFiltersButton: FC<Props> = () => {
|
|
10
|
-
const { localization, setShowFilters, showFilters } =
|
|
10
|
+
const { localization, setShowFilters, showFilters } = useMRT();
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
13
|
<Tooltip arrow title={localization?.toggleFilterButtonTitle ?? ''}>
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
-
import { IconButton as MuiIconButton, styled } from '@mui/material';
|
|
2
|
+
import { IconButton as MuiIconButton, styled, Tooltip } from '@mui/material';
|
|
3
3
|
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
|
4
|
-
import
|
|
4
|
+
import EditIcon from '@mui/icons-material/Edit';
|
|
5
|
+
import { useMRT } from '../useMRT';
|
|
5
6
|
import { Row } from 'react-table';
|
|
6
7
|
import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
|
|
7
8
|
import { MRT_EditActionButtons } from './MRT_EditActionButtons';
|
|
9
|
+
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
8
10
|
|
|
9
11
|
const IconButton = styled(MuiIconButton)({
|
|
10
12
|
opacity: 0.5,
|
|
@@ -23,11 +25,15 @@ interface Props {
|
|
|
23
25
|
|
|
24
26
|
export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
25
27
|
const {
|
|
26
|
-
localization,
|
|
27
28
|
currentEditingRow,
|
|
29
|
+
densePadding,
|
|
30
|
+
localization,
|
|
31
|
+
renderRowActionMenuItems,
|
|
32
|
+
enableRowEditing,
|
|
33
|
+
setCurrentEditingRow,
|
|
28
34
|
renderRowActions,
|
|
29
35
|
tableInstance,
|
|
30
|
-
} =
|
|
36
|
+
} = useMRT();
|
|
31
37
|
|
|
32
38
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
33
39
|
|
|
@@ -37,29 +43,45 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
|
37
43
|
setAnchorEl(event.currentTarget);
|
|
38
44
|
};
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (row.id === currentEditingRow?.id) {
|
|
45
|
-
return <MRT_EditActionButtons row={row} />;
|
|
46
|
-
}
|
|
46
|
+
const handleEdit = () => {
|
|
47
|
+
setCurrentEditingRow({ ...row });
|
|
48
|
+
setAnchorEl(null);
|
|
49
|
+
};
|
|
47
50
|
|
|
48
51
|
return (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
<MRT_TableButtonCell densePadding={densePadding}>
|
|
53
|
+
{renderRowActions ? (
|
|
54
|
+
<>{renderRowActions(row, tableInstance)}</>
|
|
55
|
+
) : row.id === currentEditingRow?.id ? (
|
|
56
|
+
<MRT_EditActionButtons row={row} />
|
|
57
|
+
) : !renderRowActionMenuItems && enableRowEditing ? (
|
|
58
|
+
<Tooltip
|
|
59
|
+
placement="right"
|
|
60
|
+
arrow
|
|
61
|
+
title={localization?.rowActionMenuItemEdit ?? ''}
|
|
62
|
+
>
|
|
63
|
+
<IconButton onClick={handleEdit}>
|
|
64
|
+
<EditIcon />
|
|
65
|
+
</IconButton>
|
|
66
|
+
</Tooltip>
|
|
67
|
+
) : renderRowActionMenuItems ? (
|
|
68
|
+
<>
|
|
69
|
+
<IconButton
|
|
70
|
+
aria-label={localization?.rowActionMenuButtonTitle}
|
|
71
|
+
title={localization?.rowActionMenuButtonTitle}
|
|
72
|
+
onClick={handleOpenRowActionMenu}
|
|
73
|
+
size="small"
|
|
74
|
+
>
|
|
75
|
+
<MoreHorizIcon />
|
|
76
|
+
</IconButton>
|
|
77
|
+
<MRT_RowActionMenu
|
|
78
|
+
anchorEl={anchorEl}
|
|
79
|
+
handleEdit={handleEdit}
|
|
80
|
+
row={row}
|
|
81
|
+
setAnchorEl={setAnchorEl}
|
|
82
|
+
/>
|
|
83
|
+
</>
|
|
84
|
+
) : null}
|
|
85
|
+
</MRT_TableButtonCell>
|
|
64
86
|
);
|
|
65
87
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
|
+
import SearchIcon from '@mui/icons-material/Search';
|
|
5
|
+
import SearchOffIcon from '@mui/icons-material/SearchOff';
|
|
6
|
+
|
|
7
|
+
type Props = {};
|
|
8
|
+
|
|
9
|
+
export const MRT_ToggleSearchButton: FC<Props> = () => {
|
|
10
|
+
const { localization, setShowSearch, showSearch, muiSearchTextFieldProps } =
|
|
11
|
+
useMRT();
|
|
12
|
+
|
|
13
|
+
const handleToggleSearch = () => {
|
|
14
|
+
setShowSearch(!showSearch);
|
|
15
|
+
setTimeout(
|
|
16
|
+
() =>
|
|
17
|
+
document
|
|
18
|
+
.getElementById(
|
|
19
|
+
muiSearchTextFieldProps?.id ?? `global-search-text-field`,
|
|
20
|
+
)
|
|
21
|
+
?.focus(),
|
|
22
|
+
200,
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Tooltip arrow title={localization?.toggleSearchButtonTitle ?? ''}>
|
|
28
|
+
<IconButton size="small" onClick={handleToggleSearch}>
|
|
29
|
+
{showSearch ? <SearchOffIcon /> : <SearchIcon />}
|
|
30
|
+
</IconButton>
|
|
31
|
+
</Tooltip>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { TableFooter } from '@mui/material';
|
|
3
3
|
import { MRT_TableFooterRow } from './MRT_TableFooterRow';
|
|
4
|
-
import {
|
|
4
|
+
import { useMRT } from '../useMRT';
|
|
5
5
|
|
|
6
6
|
interface Props {}
|
|
7
7
|
|
|
8
8
|
export const MRT_TableFooter: FC<Props> = () => {
|
|
9
|
-
const { muiTableFooterProps, tableInstance } =
|
|
9
|
+
const { muiTableFooterProps, tableInstance } = useMRT();
|
|
10
10
|
|
|
11
11
|
return (
|
|
12
12
|
<TableFooter {...muiTableFooterProps}>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { styled, TableCell as MuiTableCell } from '@mui/material';
|
|
3
3
|
import { HeaderGroup } from 'react-table';
|
|
4
|
-
import {
|
|
4
|
+
import { useMRT } from '../useMRT';
|
|
5
5
|
|
|
6
6
|
const TableCell = styled(MuiTableCell, {
|
|
7
7
|
shouldForwardProp: (prop) =>
|
|
@@ -21,7 +21,7 @@ interface Props {
|
|
|
21
21
|
|
|
22
22
|
export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
|
|
23
23
|
const { muiTableFooterCellProps, densePadding, enableColumnResizing } =
|
|
24
|
-
|
|
24
|
+
useMRT();
|
|
25
25
|
|
|
26
26
|
const isParentHeader = (column?.columns?.length ?? 0) > 0;
|
|
27
27
|
|
|
@@ -3,7 +3,7 @@ import { TableRow } from '@mui/material';
|
|
|
3
3
|
import { HeaderGroup } from 'react-table';
|
|
4
4
|
import { MRT_TableFooterCell } from './MRT_TableFooterCell';
|
|
5
5
|
import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
|
|
6
|
-
import {
|
|
6
|
+
import { useMRT } from '../useMRT';
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
9
|
footerGroup: HeaderGroup;
|
|
@@ -16,10 +16,11 @@ export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
|
|
|
16
16
|
anyRowsCanExpand,
|
|
17
17
|
enableSelection,
|
|
18
18
|
enableRowActions,
|
|
19
|
+
enableRowNumbers,
|
|
19
20
|
positionActionsColumn,
|
|
20
21
|
tableInstance,
|
|
21
22
|
muiTableFooterRowProps,
|
|
22
|
-
} =
|
|
23
|
+
} = useMRT();
|
|
23
24
|
|
|
24
25
|
//if no content in row, skip row
|
|
25
26
|
if (!columns?.some((c) => c.Footer)) return null;
|
|
@@ -40,6 +41,7 @@ export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
|
|
|
40
41
|
|
|
41
42
|
return (
|
|
42
43
|
<TableRow {...tableRowProps}>
|
|
44
|
+
{enableRowNumbers && <MRT_TableSpacerCell />}
|
|
43
45
|
{enableRowActions && positionActionsColumn === 'first' && (
|
|
44
46
|
<MRT_TableSpacerCell />
|
|
45
47
|
)}
|
|
@@ -51,8 +53,11 @@ export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
|
|
|
51
53
|
/>
|
|
52
54
|
)}
|
|
53
55
|
{enableSelection && <MRT_TableSpacerCell width="1rem" />}
|
|
54
|
-
{footerGroup.headers.map((column
|
|
55
|
-
<MRT_TableFooterCell
|
|
56
|
+
{footerGroup.headers.map((column) => (
|
|
57
|
+
<MRT_TableFooterCell
|
|
58
|
+
key={column.getFooterProps().key}
|
|
59
|
+
column={column}
|
|
60
|
+
/>
|
|
56
61
|
))}
|
|
57
62
|
{enableRowActions && positionActionsColumn === 'last' && (
|
|
58
63
|
<MRT_TableSpacerCell />
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { TableHead } from '@mui/material';
|
|
3
3
|
import { MRT_TableHeadRow } from './MRT_TableHeadRow';
|
|
4
|
-
import {
|
|
4
|
+
import { useMRT } from '../useMRT';
|
|
5
5
|
|
|
6
6
|
interface Props {}
|
|
7
7
|
|
|
8
8
|
export const MRT_TableHead: FC<Props> = () => {
|
|
9
|
-
const { tableInstance, muiTableHeadProps } =
|
|
9
|
+
const { tableInstance, muiTableHeadProps } = useMRT();
|
|
10
10
|
|
|
11
11
|
const tableHeadProps =
|
|
12
12
|
muiTableHeadProps instanceof Function
|
|
@@ -7,36 +7,41 @@ import {
|
|
|
7
7
|
Collapse,
|
|
8
8
|
} from '@mui/material';
|
|
9
9
|
import { HeaderGroup } from 'react-table';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { useMRT } from '../useMRT';
|
|
11
|
+
import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
|
|
12
12
|
import { MRT_ToggleColumnActionMenuButton } from '../buttons/MRT_ToggleColumnActionMenuButton';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const MRT_StyledTableHeadCell = styled(MuiTableCell, {
|
|
15
15
|
shouldForwardProp: (prop) =>
|
|
16
16
|
prop !== 'densePadding' && prop !== 'enableColumnResizing',
|
|
17
17
|
})<{ densePadding?: boolean; enableColumnResizing?: boolean }>(
|
|
18
18
|
({ densePadding, enableColumnResizing }) => ({
|
|
19
19
|
fontWeight: 'bold',
|
|
20
|
-
|
|
20
|
+
height: '100%',
|
|
21
21
|
padding: densePadding ? '0.5rem' : '1rem',
|
|
22
|
+
paddingTop: densePadding ? '0.75rem' : '1.25rem',
|
|
22
23
|
transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
|
|
24
|
+
verticalAlign: 'text-top',
|
|
23
25
|
}),
|
|
24
26
|
);
|
|
25
27
|
|
|
26
|
-
const
|
|
28
|
+
const TableCellWrapper = styled('div')({
|
|
29
|
+
alignContent: 'space-between',
|
|
27
30
|
display: 'grid',
|
|
31
|
+
height: '100%',
|
|
28
32
|
});
|
|
29
33
|
|
|
30
|
-
const
|
|
34
|
+
const TableCellTopContents = styled('div')({
|
|
31
35
|
width: '100%',
|
|
32
36
|
display: 'flex',
|
|
33
37
|
justifyContent: 'space-between',
|
|
38
|
+
alignItems: 'flex-start',
|
|
34
39
|
});
|
|
35
40
|
|
|
36
41
|
const CellFlexItem = styled('span')({
|
|
42
|
+
alignItems: 'center',
|
|
37
43
|
display: 'flex',
|
|
38
44
|
flexWrap: 'nowrap',
|
|
39
|
-
alignItems: 'center',
|
|
40
45
|
});
|
|
41
46
|
|
|
42
47
|
const Divider = styled(MuiDivider)({
|
|
@@ -59,7 +64,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
59
64
|
muiTableHeadCellProps,
|
|
60
65
|
showFilters,
|
|
61
66
|
tableInstance,
|
|
62
|
-
} =
|
|
67
|
+
} = useMRT();
|
|
63
68
|
|
|
64
69
|
const isParentHeader = (column?.columns?.length ?? 0) > 0;
|
|
65
70
|
|
|
@@ -85,14 +90,14 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
85
90
|
};
|
|
86
91
|
|
|
87
92
|
return (
|
|
88
|
-
<
|
|
93
|
+
<MRT_StyledTableHeadCell
|
|
89
94
|
align={isParentHeader ? 'center' : 'left'}
|
|
90
95
|
densePadding={densePadding}
|
|
91
96
|
enableColumnResizing={enableColumnResizing}
|
|
92
97
|
{...tableCellProps}
|
|
93
98
|
>
|
|
94
|
-
<
|
|
95
|
-
<
|
|
99
|
+
<TableCellWrapper>
|
|
100
|
+
<TableCellTopContents
|
|
96
101
|
style={{ justifyContent: isParentHeader ? 'center' : undefined }}
|
|
97
102
|
>
|
|
98
103
|
<CellFlexItem {...column.getSortByToggleProps()}>
|
|
@@ -108,7 +113,6 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
108
113
|
}
|
|
109
114
|
active={column.isSorted}
|
|
110
115
|
direction={column.isSortedDesc ? 'desc' : 'asc'}
|
|
111
|
-
style={{ margin: 0 }}
|
|
112
116
|
/>
|
|
113
117
|
)}
|
|
114
118
|
</CellFlexItem>
|
|
@@ -125,13 +129,13 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
125
129
|
/>
|
|
126
130
|
)}
|
|
127
131
|
</CellFlexItem>
|
|
128
|
-
</
|
|
132
|
+
</TableCellTopContents>
|
|
129
133
|
{!disableFilters && column.canFilter && (
|
|
130
134
|
<Collapse in={showFilters}>
|
|
131
|
-
<
|
|
135
|
+
<MRT_FilterTextField column={column} />
|
|
132
136
|
</Collapse>
|
|
133
137
|
)}
|
|
134
|
-
</
|
|
135
|
-
</
|
|
138
|
+
</TableCellWrapper>
|
|
139
|
+
</MRT_StyledTableHeadCell>
|
|
136
140
|
);
|
|
137
141
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { useMRT } from '../useMRT';
|
|
3
|
+
import { MRT_StyledTableHeadCell } from './MRT_TableHeadCell';
|
|
4
|
+
|
|
5
|
+
interface Props {}
|
|
6
|
+
|
|
7
|
+
export const MRT_TableHeadCellActions: FC<Props> = () => {
|
|
8
|
+
const { densePadding, localization } = useMRT();
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<MRT_StyledTableHeadCell
|
|
12
|
+
densePadding={densePadding}
|
|
13
|
+
style={{ textAlign: 'center' }}
|
|
14
|
+
>
|
|
15
|
+
{localization?.actionsHeadColumnTitle}
|
|
16
|
+
</MRT_StyledTableHeadCell>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import React, { FC, useMemo } from 'react';
|
|
2
2
|
import { TableRow } from '@mui/material';
|
|
3
3
|
import { HeaderGroup } from 'react-table';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
MRT_StyledTableHeadCell,
|
|
6
|
+
MRT_TableHeadCell,
|
|
7
|
+
} from './MRT_TableHeadCell';
|
|
8
|
+
import { useMRT } from '../useMRT';
|
|
6
9
|
import { MRT_SelectAllCheckbox } from '../inputs/MRT_SelectAllCheckbox';
|
|
7
10
|
import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton';
|
|
8
11
|
import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
|
|
12
|
+
import { MRT_TableHeadCellActions } from './MRT_TableHeadCellActions';
|
|
9
13
|
|
|
10
14
|
interface Props {
|
|
11
15
|
headerGroup: HeaderGroup;
|
|
@@ -14,16 +18,15 @@ interface Props {
|
|
|
14
18
|
export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
15
19
|
const {
|
|
16
20
|
anyRowsCanExpand,
|
|
17
|
-
densePadding,
|
|
18
21
|
disableExpandAll,
|
|
22
|
+
enableRowNumbers,
|
|
19
23
|
enableRowActions,
|
|
20
24
|
enableSelection,
|
|
21
|
-
localization,
|
|
22
25
|
muiTableHeadRowProps,
|
|
23
26
|
positionActionsColumn,
|
|
24
27
|
renderDetailPanel,
|
|
25
28
|
tableInstance,
|
|
26
|
-
} =
|
|
29
|
+
} = useMRT();
|
|
27
30
|
|
|
28
31
|
const isParentHeader = useMemo(
|
|
29
32
|
() => headerGroup.headers.some((h) => (h.columns?.length ?? 0) > 0),
|
|
@@ -46,14 +49,18 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
46
49
|
|
|
47
50
|
return (
|
|
48
51
|
<TableRow {...tableRowProps}>
|
|
52
|
+
{enableRowNumbers &&
|
|
53
|
+
(isParentHeader ? (
|
|
54
|
+
<MRT_TableSpacerCell />
|
|
55
|
+
) : (
|
|
56
|
+
<MRT_StyledTableHeadCell>#</MRT_StyledTableHeadCell>
|
|
57
|
+
))}
|
|
49
58
|
{enableRowActions &&
|
|
50
59
|
positionActionsColumn === 'first' &&
|
|
51
60
|
(isParentHeader ? (
|
|
52
61
|
<MRT_TableSpacerCell />
|
|
53
62
|
) : (
|
|
54
|
-
<
|
|
55
|
-
{localization?.actionsHeadColumnTitle}
|
|
56
|
-
</StyledTableHeadCell>
|
|
63
|
+
<MRT_TableHeadCellActions />
|
|
57
64
|
))}
|
|
58
65
|
{anyRowsCanExpand || renderDetailPanel ? (
|
|
59
66
|
!disableExpandAll && !isParentHeader ? (
|
|
@@ -81,9 +88,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
81
88
|
(isParentHeader ? (
|
|
82
89
|
<MRT_TableSpacerCell />
|
|
83
90
|
) : (
|
|
84
|
-
<
|
|
85
|
-
{localization?.actionsHeadColumnTitle}
|
|
86
|
-
</StyledTableHeadCell>
|
|
91
|
+
<MRT_TableHeadCellActions />
|
|
87
92
|
))}
|
|
88
93
|
</TableRow>
|
|
89
94
|
);
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { Switch, Tooltip } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
4
|
|
|
5
5
|
interface Props {}
|
|
6
6
|
|
|
7
7
|
export const MRT_DensePaddingSwitch: FC<Props> = () => {
|
|
8
|
-
const { densePadding, setDensePadding, localization } =
|
|
9
|
-
useMaterialReactTable();
|
|
8
|
+
const { densePadding, setDensePadding, localization } = useMRT();
|
|
10
9
|
|
|
11
10
|
return (
|
|
12
11
|
<Tooltip arrow title={localization?.toggleDensePaddingSwitchTitle ?? ''}>
|
|
13
12
|
<Switch
|
|
13
|
+
inputProps={{
|
|
14
|
+
'aria-label': localization?.toggleDensePaddingSwitchTitle ?? '',
|
|
15
|
+
}}
|
|
14
16
|
color="default"
|
|
15
17
|
checked={densePadding}
|
|
16
18
|
size="small"
|
|
@@ -1,32 +1,43 @@
|
|
|
1
|
-
import { TextField } from '@mui/material';
|
|
2
1
|
import React, { ChangeEvent, FC } from 'react';
|
|
2
|
+
import { TextField } from '@mui/material';
|
|
3
3
|
import { Cell } from 'react-table';
|
|
4
|
-
import {
|
|
4
|
+
import { useMRT } from '../useMRT';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
7
|
cell: Cell;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const
|
|
10
|
+
export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
|
|
11
11
|
const {
|
|
12
|
-
localization,
|
|
13
12
|
currentEditingRow,
|
|
14
|
-
|
|
13
|
+
localization,
|
|
15
14
|
muiTableBodyCellEditTextFieldProps,
|
|
16
|
-
|
|
15
|
+
setCurrentEditingRow,
|
|
16
|
+
} = useMRT();
|
|
17
17
|
|
|
18
18
|
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
19
19
|
if (currentEditingRow) {
|
|
20
|
+
cell.row.values[cell.column.id] = event.target.value;
|
|
20
21
|
setCurrentEditingRow({
|
|
21
22
|
...currentEditingRow,
|
|
22
|
-
values: { ...cell.row.values, [cell.column.id]: event.target.value },
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
+
cell.column.onCellEditChange?.(event, cell);
|
|
25
26
|
};
|
|
26
27
|
|
|
28
|
+
const mTableBodyCellEditTextFieldProps =
|
|
29
|
+
muiTableBodyCellEditTextFieldProps instanceof Function
|
|
30
|
+
? muiTableBodyCellEditTextFieldProps(cell)
|
|
31
|
+
: muiTableBodyCellEditTextFieldProps;
|
|
32
|
+
|
|
33
|
+
const mcTableBodyCellEditTextFieldProps =
|
|
34
|
+
cell.column.muiTableBodyCellEditTextFieldProps instanceof Function
|
|
35
|
+
? cell.column.muiTableBodyCellEditTextFieldProps(cell)
|
|
36
|
+
: cell.column.muiTableBodyCellEditTextFieldProps;
|
|
37
|
+
|
|
27
38
|
const textFieldProps = {
|
|
28
|
-
...
|
|
29
|
-
...
|
|
39
|
+
...mTableBodyCellEditTextFieldProps,
|
|
40
|
+
...mcTableBodyCellEditTextFieldProps,
|
|
30
41
|
style: {
|
|
31
42
|
//@ts-ignore
|
|
32
43
|
...muiTableBodyCellEditTextFieldProps?.style,
|
|
@@ -36,20 +47,16 @@ export const MRT_EditCellTextfield: FC<Props> = ({ cell }) => {
|
|
|
36
47
|
};
|
|
37
48
|
|
|
38
49
|
if (cell.column.editable && cell.column.Edit) {
|
|
39
|
-
return (
|
|
40
|
-
<>
|
|
41
|
-
{cell.column.Edit({ ...textFieldProps, cell, onChange: handleChange })}
|
|
42
|
-
</>
|
|
43
|
-
);
|
|
50
|
+
return <>{cell.column.Edit({ ...textFieldProps, cell })}</>;
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
return (
|
|
47
54
|
<TextField
|
|
48
55
|
margin="dense"
|
|
49
|
-
placeholder={localization?.filterTextFieldPlaceholder}
|
|
50
56
|
onChange={handleChange}
|
|
51
57
|
onClick={(e) => e.stopPropagation()}
|
|
52
|
-
|
|
58
|
+
placeholder={localization?.filterTextFieldPlaceholder}
|
|
59
|
+
value={cell.value}
|
|
53
60
|
variant="standard"
|
|
54
61
|
{...textFieldProps}
|
|
55
62
|
/>
|