material-react-table 0.3.4 → 0.4.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 +9 -4
- package/dist/body/MRT_TableBodyCell.d.ts +3 -0
- package/dist/buttons/MRT_FullScreenToggleButton.d.ts +4 -0
- package/dist/head/MRT_TableHeadCell.d.ts +1 -1
- package/dist/head/MRT_TableHeadCellActions.d.ts +5 -0
- package/dist/material-react-table.cjs.development.js +420 -278
- 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 +424 -282
- package/dist/material-react-table.esm.js.map +1 -1
- 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} +6 -3
- package/dist/utils/localization.d.ts +6 -0
- package/package.json +14 -14
- package/src/@types/react-table-config.d.ts +56 -31
- package/src/MaterialReactTable.tsx +67 -19
- package/src/body/MRT_TableBody.tsx +2 -2
- package/src/body/MRT_TableBodyCell.tsx +16 -9
- package/src/body/MRT_TableBodyRow.tsx +22 -7
- package/src/body/MRT_TableDetailPanel.tsx +14 -5
- package/src/buttons/MRT_EditActionButtons.tsx +11 -4
- package/src/buttons/MRT_ExpandAllButton.tsx +6 -3
- package/src/buttons/MRT_ExpandButton.tsx +9 -3
- package/src/buttons/MRT_FullScreenToggleButton.tsx +23 -0
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +43 -5
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +7 -3
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +7 -3
- package/src/buttons/MRT_ToggleSearchButton.tsx +7 -3
- package/src/footer/MRT_TableFooter.tsx +6 -3
- package/src/footer/MRT_TableFooterCell.tsx +5 -3
- package/src/footer/MRT_TableFooterRow.tsx +17 -6
- package/src/head/MRT_TableHead.tsx +9 -4
- package/src/head/MRT_TableHeadCell.tsx +11 -7
- package/src/head/MRT_TableHeadCellActions.tsx +18 -0
- package/src/head/MRT_TableHeadRow.tsx +19 -12
- package/src/inputs/MRT_DensePaddingSwitch.tsx +2 -2
- package/src/inputs/MRT_EditCellTextField.tsx +2 -2
- package/src/inputs/MRT_FilterTextField.tsx +6 -3
- package/src/inputs/MRT_SearchTextField.tsx +15 -7
- package/src/inputs/MRT_SelectAllCheckbox.tsx +3 -2
- package/src/inputs/MRT_SelectCheckbox.tsx +3 -2
- package/src/menus/MRT_ColumnActionMenu.tsx +40 -13
- package/src/menus/MRT_RowActionMenu.tsx +21 -6
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +24 -15
- package/src/table/MRT_Table.tsx +3 -2
- package/src/table/MRT_TableContainer.tsx +37 -6
- package/src/table/MRT_TableSpacerCell.tsx +5 -3
- package/src/toolbar/MRT_TablePagination.tsx +9 -5
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +102 -0
- package/src/toolbar/MRT_ToolbarBottom.tsx +14 -8
- package/src/toolbar/{MRT_ToolbarButtons.tsx → MRT_ToolbarInternalButtons.tsx} +11 -4
- package/src/toolbar/MRT_ToolbarTop.tsx +19 -11
- package/src/{useMaterialReactTable.tsx → useMRT.tsx} +43 -19
- package/src/utils/localization.ts +14 -2
- package/dist/toolbar/MRT_ToolbarButtons.d.ts +0 -5
- package/dist/utils/useMRTCalcs.d.ts +0 -11
- package/src/utils/useMRTCalcs.tsx +0 -40
|
@@ -2,7 +2,7 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { IconButton, styled } from '@mui/material';
|
|
3
3
|
import { Row } from 'react-table';
|
|
4
4
|
import MuiExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
5
|
-
import {
|
|
5
|
+
import { useMRT } from '../useMRT';
|
|
6
6
|
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
7
7
|
|
|
8
8
|
const TableCell = styled(MRT_TableButtonCell, {
|
|
@@ -24,7 +24,7 @@ interface Props {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
27
|
-
const { localization, densePadding, renderDetailPanel } =
|
|
27
|
+
const { localization, densePadding, renderDetailPanel } = useMRT();
|
|
28
28
|
|
|
29
29
|
return (
|
|
30
30
|
<TableCell size="small" densePadding={densePadding} depth={row.depth}>
|
|
@@ -36,7 +36,13 @@ export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
|
36
36
|
>
|
|
37
37
|
<ExpandMoreIcon
|
|
38
38
|
fontSize={row.canExpand || renderDetailPanel ? 'medium' : 'small'}
|
|
39
|
-
rotation={
|
|
39
|
+
rotation={
|
|
40
|
+
!row.canExpand && !renderDetailPanel
|
|
41
|
+
? -90
|
|
42
|
+
: row.isExpanded
|
|
43
|
+
? -180
|
|
44
|
+
: 0
|
|
45
|
+
}
|
|
40
46
|
/>
|
|
41
47
|
</IconButton>
|
|
42
48
|
</TableCell>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
|
+
import FilterListIcon from '@mui/icons-material/Fullscreen';
|
|
5
|
+
import FilterListOffIcon from '@mui/icons-material/FullscreenExit';
|
|
6
|
+
|
|
7
|
+
type Props = {};
|
|
8
|
+
|
|
9
|
+
export const MRT_FullScreenToggleButton: FC<Props> = () => {
|
|
10
|
+
const { localization, setFullScreen, fullScreen } = useMRT();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Tooltip arrow title={localization?.toggleFullScreenButtonTitle ?? ''}>
|
|
14
|
+
<IconButton
|
|
15
|
+
aria-label={localization?.toggleFilterButtonTitle}
|
|
16
|
+
onClick={() => setFullScreen(!fullScreen)}
|
|
17
|
+
size="small"
|
|
18
|
+
>
|
|
19
|
+
{fullScreen ? <FilterListOffIcon /> : <FilterListIcon />}
|
|
20
|
+
</IconButton>
|
|
21
|
+
</Tooltip>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -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
|
|
|
@@ -26,9 +39,34 @@ export const MRT_ShowHideColumnsButton: FC<Props> = () => {
|
|
|
26
39
|
<ViewColumnIcon />
|
|
27
40
|
</IconButton>
|
|
28
41
|
</Tooltip>
|
|
29
|
-
<Menu
|
|
42
|
+
<Menu
|
|
43
|
+
anchorEl={anchorEl}
|
|
44
|
+
open={!!anchorEl}
|
|
45
|
+
onClose={() => setAnchorEl(null)}
|
|
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 />
|
|
30
65
|
{tableInstance.columns.map((column, index) => (
|
|
31
|
-
<MRT_ShowHideColumnsMenu
|
|
66
|
+
<MRT_ShowHideColumnsMenu
|
|
67
|
+
key={`${index}-${column.id}`}
|
|
68
|
+
column={column}
|
|
69
|
+
/>
|
|
32
70
|
))}
|
|
33
71
|
</Menu>
|
|
34
72
|
</>
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -41,7 +41,11 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
41
41
|
>
|
|
42
42
|
<MoreVertIcon />
|
|
43
43
|
</IconButton>
|
|
44
|
-
<MRT_ColumnActionMenu
|
|
44
|
+
<MRT_ColumnActionMenu
|
|
45
|
+
anchorEl={anchorEl}
|
|
46
|
+
column={column}
|
|
47
|
+
setAnchorEl={setAnchorEl}
|
|
48
|
+
/>
|
|
45
49
|
</>
|
|
46
50
|
);
|
|
47
51
|
};
|
|
@@ -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 ?? ''}>
|
|
@@ -2,7 +2,7 @@ import React, { FC, MouseEvent, useState } from 'react';
|
|
|
2
2
|
import { IconButton as MuiIconButton, styled, Tooltip } from '@mui/material';
|
|
3
3
|
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
|
4
4
|
import EditIcon from '@mui/icons-material/Edit';
|
|
5
|
-
import {
|
|
5
|
+
import { useMRT } from '../useMRT';
|
|
6
6
|
import { Row } from 'react-table';
|
|
7
7
|
import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
|
|
8
8
|
import { MRT_EditActionButtons } from './MRT_EditActionButtons';
|
|
@@ -33,7 +33,7 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
|
33
33
|
setCurrentEditingRow,
|
|
34
34
|
renderRowActions,
|
|
35
35
|
tableInstance,
|
|
36
|
-
} =
|
|
36
|
+
} = useMRT();
|
|
37
37
|
|
|
38
38
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
39
39
|
|
|
@@ -55,7 +55,11 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
|
55
55
|
) : row.id === currentEditingRow?.id ? (
|
|
56
56
|
<MRT_EditActionButtons row={row} />
|
|
57
57
|
) : !renderRowActionMenuItems && enableRowEditing ? (
|
|
58
|
-
<Tooltip
|
|
58
|
+
<Tooltip
|
|
59
|
+
placement="right"
|
|
60
|
+
arrow
|
|
61
|
+
title={localization?.rowActionMenuItemEdit ?? ''}
|
|
62
|
+
>
|
|
59
63
|
<IconButton onClick={handleEdit}>
|
|
60
64
|
<EditIcon />
|
|
61
65
|
</IconButton>
|
|
@@ -1,6 +1,6 @@
|
|
|
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 SearchIcon from '@mui/icons-material/Search';
|
|
5
5
|
import SearchOffIcon from '@mui/icons-material/SearchOff';
|
|
6
6
|
|
|
@@ -8,13 +8,17 @@ type Props = {};
|
|
|
8
8
|
|
|
9
9
|
export const MRT_ToggleSearchButton: FC<Props> = () => {
|
|
10
10
|
const { localization, setShowSearch, showSearch, muiSearchTextFieldProps } =
|
|
11
|
-
|
|
11
|
+
useMRT();
|
|
12
12
|
|
|
13
13
|
const handleToggleSearch = () => {
|
|
14
14
|
setShowSearch(!showSearch);
|
|
15
15
|
setTimeout(
|
|
16
16
|
() =>
|
|
17
|
-
document
|
|
17
|
+
document
|
|
18
|
+
.getElementById(
|
|
19
|
+
muiSearchTextFieldProps?.id ?? `global-search-text-field`,
|
|
20
|
+
)
|
|
21
|
+
?.focus(),
|
|
18
22
|
200,
|
|
19
23
|
);
|
|
20
24
|
};
|
|
@@ -1,17 +1,20 @@
|
|
|
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}>
|
|
13
13
|
{tableInstance.footerGroups.map((footerGroup) => (
|
|
14
|
-
<MRT_TableFooterRow
|
|
14
|
+
<MRT_TableFooterRow
|
|
15
|
+
key={footerGroup.getFooterGroupProps().key}
|
|
16
|
+
footerGroup={footerGroup}
|
|
17
|
+
/>
|
|
15
18
|
))}
|
|
16
19
|
</TableFooter>
|
|
17
20
|
);
|
|
@@ -1,10 +1,11 @@
|
|
|
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
|
-
shouldForwardProp: (prop) =>
|
|
7
|
+
shouldForwardProp: (prop) =>
|
|
8
|
+
prop !== 'densePadding' && prop !== 'enableColumnResizing',
|
|
8
9
|
})<{ densePadding?: boolean; enableColumnResizing?: boolean }>(
|
|
9
10
|
({ densePadding, enableColumnResizing }) => ({
|
|
10
11
|
fontWeight: 'bold',
|
|
@@ -19,7 +20,8 @@ interface Props {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
|
|
22
|
-
const { muiTableFooterCellProps, densePadding, enableColumnResizing } =
|
|
23
|
+
const { muiTableFooterCellProps, densePadding, enableColumnResizing } =
|
|
24
|
+
useMRT();
|
|
23
25
|
|
|
24
26
|
const isParentHeader = (column?.columns?.length ?? 0) > 0;
|
|
25
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,17 +41,27 @@ export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
|
|
|
40
41
|
|
|
41
42
|
return (
|
|
42
43
|
<TableRow {...tableRowProps}>
|
|
43
|
-
{
|
|
44
|
+
{enableRowNumbers && <MRT_TableSpacerCell />}
|
|
45
|
+
{enableRowActions && positionActionsColumn === 'first' && (
|
|
46
|
+
<MRT_TableSpacerCell />
|
|
47
|
+
)}
|
|
44
48
|
{(anyRowsCanExpand || renderDetailPanel) && (
|
|
45
49
|
<MRT_TableSpacerCell
|
|
46
|
-
width={`${
|
|
50
|
+
width={`${
|
|
51
|
+
renderDetailPanel ? 2 : tableInstance.expandedDepth + 0.5
|
|
52
|
+
}rem`}
|
|
47
53
|
/>
|
|
48
54
|
)}
|
|
49
55
|
{enableSelection && <MRT_TableSpacerCell width="1rem" />}
|
|
50
56
|
{footerGroup.headers.map((column) => (
|
|
51
|
-
<MRT_TableFooterCell
|
|
57
|
+
<MRT_TableFooterCell
|
|
58
|
+
key={column.getFooterProps().key}
|
|
59
|
+
column={column}
|
|
60
|
+
/>
|
|
52
61
|
))}
|
|
53
|
-
{enableRowActions && positionActionsColumn === 'last' &&
|
|
62
|
+
{enableRowActions && positionActionsColumn === 'last' && (
|
|
63
|
+
<MRT_TableSpacerCell />
|
|
64
|
+
)}
|
|
54
65
|
</TableRow>
|
|
55
66
|
);
|
|
56
67
|
};
|
|
@@ -1,20 +1,25 @@
|
|
|
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
|
-
muiTableHeadProps instanceof Function
|
|
12
|
+
muiTableHeadProps instanceof Function
|
|
13
|
+
? muiTableHeadProps(tableInstance)
|
|
14
|
+
: muiTableHeadProps;
|
|
13
15
|
|
|
14
16
|
return (
|
|
15
17
|
<TableHead {...tableHeadProps}>
|
|
16
18
|
{tableInstance.headerGroups.map((headerGroup) => (
|
|
17
|
-
<MRT_TableHeadRow
|
|
19
|
+
<MRT_TableHeadRow
|
|
20
|
+
key={headerGroup.getHeaderGroupProps().key}
|
|
21
|
+
headerGroup={headerGroup}
|
|
22
|
+
/>
|
|
18
23
|
))}
|
|
19
24
|
</TableHead>
|
|
20
25
|
);
|
|
@@ -7,17 +7,19 @@ import {
|
|
|
7
7
|
Collapse,
|
|
8
8
|
} from '@mui/material';
|
|
9
9
|
import { HeaderGroup } from 'react-table';
|
|
10
|
-
import {
|
|
10
|
+
import { useMRT } from '../useMRT';
|
|
11
11
|
import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
|
|
12
12
|
import { MRT_ToggleColumnActionMenuButton } from '../buttons/MRT_ToggleColumnActionMenuButton';
|
|
13
13
|
|
|
14
|
-
export const
|
|
15
|
-
shouldForwardProp: (prop) =>
|
|
14
|
+
export const MRT_StyledTableHeadCell = styled(MuiTableCell, {
|
|
15
|
+
shouldForwardProp: (prop) =>
|
|
16
|
+
prop !== 'densePadding' && prop !== 'enableColumnResizing',
|
|
16
17
|
})<{ densePadding?: boolean; enableColumnResizing?: boolean }>(
|
|
17
18
|
({ densePadding, enableColumnResizing }) => ({
|
|
18
19
|
fontWeight: 'bold',
|
|
19
20
|
height: '100%',
|
|
20
21
|
padding: densePadding ? '0.5rem' : '1rem',
|
|
22
|
+
paddingTop: densePadding ? '0.75rem' : '1.25rem',
|
|
21
23
|
transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
|
|
22
24
|
verticalAlign: 'text-top',
|
|
23
25
|
}),
|
|
@@ -62,7 +64,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
62
64
|
muiTableHeadCellProps,
|
|
63
65
|
showFilters,
|
|
64
66
|
tableInstance,
|
|
65
|
-
} =
|
|
67
|
+
} = useMRT();
|
|
66
68
|
|
|
67
69
|
const isParentHeader = (column?.columns?.length ?? 0) > 0;
|
|
68
70
|
|
|
@@ -88,14 +90,16 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
88
90
|
};
|
|
89
91
|
|
|
90
92
|
return (
|
|
91
|
-
<
|
|
93
|
+
<MRT_StyledTableHeadCell
|
|
92
94
|
align={isParentHeader ? 'center' : 'left'}
|
|
93
95
|
densePadding={densePadding}
|
|
94
96
|
enableColumnResizing={enableColumnResizing}
|
|
95
97
|
{...tableCellProps}
|
|
96
98
|
>
|
|
97
99
|
<TableCellWrapper>
|
|
98
|
-
<TableCellTopContents
|
|
100
|
+
<TableCellTopContents
|
|
101
|
+
style={{ justifyContent: isParentHeader ? 'center' : undefined }}
|
|
102
|
+
>
|
|
99
103
|
<CellFlexItem {...column.getSortByToggleProps()}>
|
|
100
104
|
{column.render('Header')}
|
|
101
105
|
{!isParentHeader && column.canSort && (
|
|
@@ -132,6 +136,6 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
132
136
|
</Collapse>
|
|
133
137
|
)}
|
|
134
138
|
</TableCellWrapper>
|
|
135
|
-
</
|
|
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,21 +49,27 @@ 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 ? (
|
|
60
67
|
<MRT_ExpandAllButton />
|
|
61
68
|
) : (
|
|
62
69
|
<MRT_TableSpacerCell
|
|
63
|
-
width={`${
|
|
70
|
+
width={`${
|
|
71
|
+
renderDetailPanel ? 2 : tableInstance.expandedDepth + 0.5
|
|
72
|
+
}rem`}
|
|
64
73
|
/>
|
|
65
74
|
)
|
|
66
75
|
) : null}
|
|
@@ -79,9 +88,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
79
88
|
(isParentHeader ? (
|
|
80
89
|
<MRT_TableSpacerCell />
|
|
81
90
|
) : (
|
|
82
|
-
<
|
|
83
|
-
{localization?.actionsHeadColumnTitle}
|
|
84
|
-
</StyledTableHeadCell>
|
|
91
|
+
<MRT_TableHeadCellActions />
|
|
85
92
|
))}
|
|
86
93
|
</TableRow>
|
|
87
94
|
);
|
|
@@ -1,11 +1,11 @@
|
|
|
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 } =
|
|
8
|
+
const { densePadding, setDensePadding, localization } = useMRT();
|
|
9
9
|
|
|
10
10
|
return (
|
|
11
11
|
<Tooltip arrow title={localization?.toggleDensePaddingSwitchTitle ?? ''}>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ChangeEvent, FC } from 'react';
|
|
2
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;
|
|
@@ -13,7 +13,7 @@ export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
|
|
|
13
13
|
localization,
|
|
14
14
|
muiTableBodyCellEditTextFieldProps,
|
|
15
15
|
setCurrentEditingRow,
|
|
16
|
-
} =
|
|
16
|
+
} = useMRT();
|
|
17
17
|
|
|
18
18
|
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
19
19
|
if (currentEditingRow) {
|
|
@@ -3,14 +3,14 @@ import { IconButton, InputAdornment, TextField, Tooltip } from '@mui/material';
|
|
|
3
3
|
import CloseIcon from '@mui/icons-material/Close';
|
|
4
4
|
import FilterIcon from '@mui/icons-material/FilterList';
|
|
5
5
|
import { HeaderGroup, useAsyncDebounce } from 'react-table';
|
|
6
|
-
import {
|
|
6
|
+
import { useMRT } from '../useMRT';
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
9
|
column: HeaderGroup;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
13
|
-
const { localization } =
|
|
13
|
+
const { localization } = useMRT();
|
|
14
14
|
|
|
15
15
|
const [filterValue, setFilterValue] = useState('');
|
|
16
16
|
|
|
@@ -66,7 +66,10 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
66
66
|
),
|
|
67
67
|
endAdornment: (
|
|
68
68
|
<InputAdornment position="end">
|
|
69
|
-
<Tooltip
|
|
69
|
+
<Tooltip
|
|
70
|
+
arrow
|
|
71
|
+
title={localization?.filterTextFieldClearButtonTitle ?? ''}
|
|
72
|
+
>
|
|
70
73
|
<span>
|
|
71
74
|
<IconButton
|
|
72
75
|
aria-label={localization?.filterTextFieldClearButtonTitle}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '@mui/material';
|
|
9
9
|
import SearchIcon from '@mui/icons-material/Search';
|
|
10
10
|
import CloseIcon from '@mui/icons-material/Close';
|
|
11
|
-
import {
|
|
11
|
+
import { useMRT } from '../useMRT';
|
|
12
12
|
import { useAsyncDebounce } from 'react-table';
|
|
13
13
|
|
|
14
14
|
const TextField = styled(MuiTextField)({
|
|
@@ -18,15 +18,23 @@ const TextField = styled(MuiTextField)({
|
|
|
18
18
|
interface Props {}
|
|
19
19
|
|
|
20
20
|
export const MRT_SearchTextField: FC<Props> = () => {
|
|
21
|
-
const {
|
|
22
|
-
|
|
21
|
+
const {
|
|
22
|
+
showSearch,
|
|
23
|
+
localization,
|
|
24
|
+
muiSearchTextFieldProps,
|
|
25
|
+
onGlobalFilterChange,
|
|
26
|
+
tableInstance,
|
|
27
|
+
} = useMRT();
|
|
23
28
|
|
|
24
29
|
const [searchValue, setSearchValue] = useState('');
|
|
25
30
|
|
|
26
|
-
const handleChange = useAsyncDebounce(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
const handleChange = useAsyncDebounce(
|
|
32
|
+
(event: ChangeEvent<HTMLInputElement>) => {
|
|
33
|
+
tableInstance.setGlobalFilter(event.target.value ?? undefined);
|
|
34
|
+
onGlobalFilterChange?.(event);
|
|
35
|
+
},
|
|
36
|
+
200,
|
|
37
|
+
);
|
|
30
38
|
|
|
31
39
|
const handleClear = () => {
|
|
32
40
|
setSearchValue('');
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Checkbox } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
5
5
|
|
|
6
6
|
export const MRT_SelectAllCheckbox = () => {
|
|
7
|
-
const { tableInstance, disableSelectAll, densePadding, localization } =
|
|
7
|
+
const { tableInstance, disableSelectAll, densePadding, localization } =
|
|
8
|
+
useMRT();
|
|
8
9
|
|
|
9
10
|
return (
|
|
10
11
|
<MRT_TableButtonCell densePadding={densePadding} variant="head">
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ChangeEvent, FC } from 'react';
|
|
2
2
|
import { Checkbox } from '@mui/material';
|
|
3
3
|
import { Row } from 'react-table';
|
|
4
|
-
import {
|
|
4
|
+
import { useMRT } from '../useMRT';
|
|
5
5
|
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
@@ -9,7 +9,8 @@ interface Props {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export const MRT_SelectCheckbox: FC<Props> = ({ row }) => {
|
|
12
|
-
const { tableInstance, onRowSelectChange, densePadding, localization } =
|
|
12
|
+
const { tableInstance, onRowSelectChange, densePadding, localization } =
|
|
13
|
+
useMRT();
|
|
13
14
|
|
|
14
15
|
const onSelectChange = (event: ChangeEvent) => {
|
|
15
16
|
row.getToggleRowSelectedProps()?.onChange?.(event);
|