material-react-table 0.6.10 → 0.7.0-alpha.3
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/README.md +27 -17
- package/dist/MaterialReactTable.d.ts +306 -109
- package/dist/body/MRT_TableBody.d.ts +3 -0
- package/dist/body/MRT_TableBodyCell.d.ts +2 -11
- package/dist/body/MRT_TableBodyRow.d.ts +3 -1
- package/dist/body/MRT_TableDetailPanel.d.ts +2 -1
- package/dist/buttons/MRT_CopyButton.d.ts +4 -2
- package/dist/buttons/MRT_EditActionButtons.d.ts +2 -1
- package/dist/buttons/MRT_ExpandAllButton.d.ts +2 -0
- package/dist/buttons/MRT_ExpandButton.d.ts +2 -1
- package/dist/buttons/MRT_FullScreenToggleButton.d.ts +2 -0
- package/dist/buttons/MRT_ShowHideColumnsButton.d.ts +2 -0
- package/dist/buttons/MRT_ToggleColumnActionMenuButton.d.ts +3 -2
- package/dist/buttons/MRT_ToggleDensePaddingButton.d.ts +2 -0
- package/dist/buttons/MRT_ToggleFiltersButton.d.ts +2 -0
- package/dist/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -1
- package/dist/buttons/MRT_ToggleSearchButton.d.ts +2 -0
- package/dist/footer/MRT_TableFooter.d.ts +3 -0
- package/dist/footer/MRT_TableFooterCell.d.ts +3 -2
- package/dist/footer/MRT_TableFooterRow.d.ts +2 -1
- package/dist/head/MRT_TableHead.d.ts +3 -0
- package/dist/head/MRT_TableHeadCell.d.ts +4 -18
- package/dist/head/MRT_TableHeadRow.d.ts +2 -1
- package/dist/icons.d.ts +1 -1
- package/dist/inputs/MRT_EditCellTextField.d.ts +2 -1
- package/dist/inputs/MRT_FilterTextField.d.ts +3 -2
- package/dist/inputs/MRT_SearchTextField.d.ts +2 -0
- package/dist/inputs/MRT_SelectCheckbox.d.ts +2 -1
- package/dist/localization.d.ts +7 -2
- package/dist/material-react-table.cjs.development.js +2209 -2483
- 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 +2210 -2484
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +3 -2
- package/dist/menus/MRT_FilterTypeMenu.d.ts +4 -3
- package/dist/menus/MRT_RowActionMenu.d.ts +3 -2
- package/dist/menus/MRT_ShowHideColumnsMenu.d.ts +2 -0
- package/dist/menus/MRT_ShowHideColumnsMenuItems.d.ts +2 -1
- package/dist/table/MRT_Table.d.ts +3 -0
- package/dist/table/MRT_TableContainer.d.ts +2 -0
- package/dist/table/MRT_TablePaper.d.ts +7 -0
- package/dist/table/MRT_TableRoot.d.ts +3 -0
- package/dist/toolbar/MRT_LinearProgressBar.d.ts +2 -0
- package/dist/toolbar/MRT_TablePagination.d.ts +2 -0
- package/dist/toolbar/MRT_ToolbarAlertBanner.d.ts +2 -0
- package/dist/toolbar/MRT_ToolbarBottom.d.ts +2 -0
- package/dist/toolbar/MRT_ToolbarInternalButtons.d.ts +2 -0
- package/dist/toolbar/MRT_ToolbarTop.d.ts +4 -2
- package/dist/utils.d.ts +12 -2
- package/package.json +28 -29
- package/src/MaterialReactTable.tsx +594 -300
- package/src/body/MRT_TableBody.tsx +26 -22
- package/src/body/MRT_TableBodyCell.tsx +75 -60
- package/src/body/MRT_TableBodyRow.tsx +37 -76
- package/src/body/MRT_TableDetailPanel.tsx +21 -17
- package/src/buttons/MRT_CopyButton.tsx +16 -9
- package/src/buttons/MRT_EditActionButtons.tsx +16 -13
- package/src/buttons/MRT_ExpandAllButton.tsx +24 -9
- package/src/buttons/MRT_ExpandButton.tsx +22 -15
- package/src/buttons/MRT_FullScreenToggleButton.tsx +18 -11
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +18 -7
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +22 -11
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +18 -11
- package/src/buttons/MRT_ToggleFiltersButton.tsx +16 -9
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +27 -22
- package/src/buttons/MRT_ToggleSearchButton.tsx +24 -12
- package/src/footer/MRT_TableFooter.tsx +24 -8
- package/src/footer/MRT_TableFooterCell.tsx +34 -26
- package/src/footer/MRT_TableFooterRow.tsx +21 -39
- package/src/head/MRT_TableHead.tsx +24 -8
- package/src/head/MRT_TableHeadCell.tsx +184 -142
- package/src/head/MRT_TableHeadRow.tsx +16 -104
- package/src/icons.ts +3 -3
- package/src/inputs/MRT_EditCellTextField.tsx +23 -24
- package/src/inputs/MRT_FilterTextField.tsx +53 -32
- package/src/inputs/MRT_SearchTextField.tsx +46 -24
- package/src/inputs/MRT_SelectCheckbox.tsx +42 -30
- package/src/localization.ts +13 -2
- package/src/menus/MRT_ColumnActionMenu.tsx +129 -69
- package/src/menus/MRT_FilterTypeMenu.tsx +28 -22
- package/src/menus/MRT_RowActionMenu.tsx +21 -14
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +52 -20
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +27 -17
- package/src/table/MRT_Table.tsx +25 -15
- package/src/table/MRT_TableContainer.tsx +106 -45
- package/src/table/MRT_TablePaper.tsx +65 -0
- package/src/table/MRT_TableRoot.tsx +236 -0
- package/src/toolbar/MRT_LinearProgressBar.tsx +10 -7
- package/src/toolbar/MRT_TablePagination.tsx +33 -19
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +33 -20
- package/src/toolbar/MRT_ToolbarBottom.tsx +32 -21
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +34 -20
- package/src/toolbar/MRT_ToolbarTop.tsx +36 -29
- package/src/utils.ts +37 -8
- package/dist/head/MRT_TableHeadCellActions.d.ts +0 -5
- package/dist/table/MRT_TableSpacerCell.d.ts +0 -6
- package/dist/useMRT.d.ts +0 -28
- package/src/@types/faker.d.ts +0 -4
- package/src/@types/react-table-config.d.ts +0 -53
- package/src/head/MRT_TableHeadCellActions.tsx +0 -29
- package/src/table/MRT_TableSpacerCell.tsx +0 -20
- package/src/useMRT.tsx +0 -226
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
|
-
interface Props extends IconButtonProps {
|
|
5
|
+
interface Props extends IconButtonProps {
|
|
6
|
+
tableInstance: MRT_TableInstance;
|
|
7
|
+
}
|
|
6
8
|
|
|
7
|
-
export const MRT_FullScreenToggleButton: FC<Props> = ({
|
|
9
|
+
export const MRT_FullScreenToggleButton: FC<Props> = ({
|
|
10
|
+
tableInstance,
|
|
11
|
+
...rest
|
|
12
|
+
}) => {
|
|
8
13
|
const {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
getState,
|
|
15
|
+
options: {
|
|
16
|
+
icons: { FullscreenExitIcon, FullscreenIcon },
|
|
17
|
+
localization,
|
|
18
|
+
setIsFullScreen,
|
|
14
19
|
},
|
|
15
|
-
} =
|
|
20
|
+
} = tableInstance;
|
|
21
|
+
|
|
22
|
+
const { isFullScreen } = getState();
|
|
16
23
|
|
|
17
24
|
return (
|
|
18
25
|
<Tooltip arrow title={localization.toggleFullScreen}>
|
|
19
26
|
<IconButton
|
|
20
27
|
aria-label={localization.showHideFilters}
|
|
21
|
-
onClick={() =>
|
|
28
|
+
onClick={() => setIsFullScreen(!isFullScreen)}
|
|
22
29
|
size="small"
|
|
23
30
|
{...rest}
|
|
24
31
|
>
|
|
25
|
-
{
|
|
32
|
+
{isFullScreen ? <FullscreenExitIcon /> : <FullscreenIcon />}
|
|
26
33
|
</IconButton>
|
|
27
34
|
</Tooltip>
|
|
28
35
|
);
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
2
|
import { IconButton, Tooltip, IconButtonProps } from '@mui/material';
|
|
3
|
-
import { useMRT } from '../useMRT';
|
|
4
3
|
import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
|
|
4
|
+
import { MRT_TableInstance } from '..';
|
|
5
5
|
|
|
6
|
-
interface Props extends IconButtonProps {
|
|
6
|
+
interface Props extends IconButtonProps {
|
|
7
|
+
tableInstance: MRT_TableInstance;
|
|
8
|
+
}
|
|
7
9
|
|
|
8
|
-
export const MRT_ShowHideColumnsButton: FC<Props> = ({
|
|
10
|
+
export const MRT_ShowHideColumnsButton: FC<Props> = ({
|
|
11
|
+
tableInstance,
|
|
12
|
+
...rest
|
|
13
|
+
}) => {
|
|
9
14
|
const {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
options: {
|
|
16
|
+
icons: { ViewColumnIcon },
|
|
17
|
+
localization,
|
|
18
|
+
},
|
|
19
|
+
} = tableInstance;
|
|
13
20
|
|
|
14
21
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
15
22
|
|
|
@@ -29,7 +36,11 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
|
|
|
29
36
|
<ViewColumnIcon />
|
|
30
37
|
</IconButton>
|
|
31
38
|
</Tooltip>
|
|
32
|
-
<MRT_ShowHideColumnsMenu
|
|
39
|
+
<MRT_ShowHideColumnsMenu
|
|
40
|
+
anchorEl={anchorEl}
|
|
41
|
+
setAnchorEl={setAnchorEl}
|
|
42
|
+
tableInstance={tableInstance}
|
|
43
|
+
/>
|
|
33
44
|
</>
|
|
34
45
|
);
|
|
35
46
|
};
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
2
|
import { IconButton, Tooltip } from '@mui/material';
|
|
3
|
-
import { useMRT } from '../useMRT';
|
|
4
3
|
import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
|
5
|
-
import type {
|
|
4
|
+
import type { MRT_Header, MRT_TableInstance } from '..';
|
|
6
5
|
|
|
7
6
|
interface Props {
|
|
8
|
-
|
|
7
|
+
header: MRT_Header;
|
|
8
|
+
tableInstance: MRT_TableInstance;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({
|
|
11
|
+
export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({
|
|
12
|
+
header,
|
|
13
|
+
tableInstance,
|
|
14
|
+
}) => {
|
|
12
15
|
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
options: {
|
|
17
|
+
icons: { MoreVertIcon },
|
|
18
|
+
localization,
|
|
19
|
+
muiTableHeadCellColumnActionsButtonProps,
|
|
20
|
+
},
|
|
21
|
+
} = tableInstance;
|
|
22
|
+
|
|
23
|
+
const { column } = header;
|
|
17
24
|
|
|
18
25
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
19
26
|
|
|
@@ -25,12 +32,15 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
25
32
|
|
|
26
33
|
const mTableHeadCellColumnActionsButtonProps =
|
|
27
34
|
muiTableHeadCellColumnActionsButtonProps instanceof Function
|
|
28
|
-
? muiTableHeadCellColumnActionsButtonProps(column)
|
|
35
|
+
? muiTableHeadCellColumnActionsButtonProps({ column, tableInstance })
|
|
29
36
|
: muiTableHeadCellColumnActionsButtonProps;
|
|
30
37
|
|
|
31
38
|
const mcTableHeadCellColumnActionsButtonProps =
|
|
32
39
|
column.muiTableHeadCellColumnActionsButtonProps instanceof Function
|
|
33
|
-
? column.muiTableHeadCellColumnActionsButtonProps(
|
|
40
|
+
? column.muiTableHeadCellColumnActionsButtonProps({
|
|
41
|
+
column,
|
|
42
|
+
tableInstance,
|
|
43
|
+
})
|
|
34
44
|
: column.muiTableHeadCellColumnActionsButtonProps;
|
|
35
45
|
|
|
36
46
|
const iconButtonProps = {
|
|
@@ -70,8 +80,9 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
70
80
|
</Tooltip>
|
|
71
81
|
<MRT_ColumnActionMenu
|
|
72
82
|
anchorEl={anchorEl}
|
|
73
|
-
|
|
83
|
+
header={header}
|
|
74
84
|
setAnchorEl={setAnchorEl}
|
|
85
|
+
tableInstance={tableInstance}
|
|
75
86
|
/>
|
|
76
87
|
</>
|
|
77
88
|
);
|
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
|
-
interface Props extends IconButtonProps {
|
|
5
|
+
interface Props extends IconButtonProps {
|
|
6
|
+
tableInstance: MRT_TableInstance;
|
|
7
|
+
}
|
|
6
8
|
|
|
7
|
-
export const MRT_ToggleDensePaddingButton: FC<Props> = ({
|
|
9
|
+
export const MRT_ToggleDensePaddingButton: FC<Props> = ({
|
|
10
|
+
tableInstance,
|
|
11
|
+
...rest
|
|
12
|
+
}) => {
|
|
8
13
|
const {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
getState,
|
|
15
|
+
options: {
|
|
16
|
+
icons: { DensityMediumIcon, DensitySmallIcon },
|
|
17
|
+
localization,
|
|
18
|
+
setIsDensePadding,
|
|
14
19
|
},
|
|
15
|
-
} =
|
|
20
|
+
} = tableInstance;
|
|
21
|
+
|
|
22
|
+
const { isDensePadding } = getState();
|
|
16
23
|
|
|
17
24
|
return (
|
|
18
25
|
<Tooltip arrow title={localization.toggleDensePadding}>
|
|
19
26
|
<IconButton
|
|
20
27
|
aria-label={localization.toggleDensePadding}
|
|
21
|
-
onClick={() =>
|
|
28
|
+
onClick={() => setIsDensePadding(!isDensePadding)}
|
|
22
29
|
size="small"
|
|
23
30
|
{...rest}
|
|
24
31
|
>
|
|
25
|
-
{
|
|
32
|
+
{isDensePadding ? <DensitySmallIcon /> : <DensityMediumIcon />}
|
|
26
33
|
</IconButton>
|
|
27
34
|
</Tooltip>
|
|
28
35
|
);
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
|
-
interface Props extends IconButtonProps {
|
|
5
|
+
interface Props extends IconButtonProps {
|
|
6
|
+
tableInstance: MRT_TableInstance;
|
|
7
|
+
}
|
|
6
8
|
|
|
7
|
-
export const MRT_ToggleFiltersButton: FC<Props> = ({
|
|
9
|
+
export const MRT_ToggleFiltersButton: FC<Props> = ({
|
|
10
|
+
tableInstance,
|
|
11
|
+
...rest
|
|
12
|
+
}) => {
|
|
8
13
|
const {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
getState,
|
|
15
|
+
options: {
|
|
16
|
+
icons: { FilterListIcon, FilterListOffIcon },
|
|
17
|
+
localization,
|
|
18
|
+
setShowFilters,
|
|
14
19
|
},
|
|
15
|
-
} =
|
|
20
|
+
} = tableInstance;
|
|
21
|
+
|
|
22
|
+
const { showFilters } = getState();
|
|
16
23
|
|
|
17
24
|
return (
|
|
18
25
|
<Tooltip arrow title={localization.showHideFilters}>
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
-
import { IconButton,
|
|
3
|
-
import { useMRT } from '../useMRT';
|
|
2
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
4
3
|
import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
|
|
5
4
|
import { MRT_EditActionButtons } from './MRT_EditActionButtons';
|
|
6
|
-
import type { MRT_Row } from '..';
|
|
7
|
-
import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
|
|
5
|
+
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
8
6
|
|
|
9
7
|
const commonIconButtonStyles = {
|
|
8
|
+
height: '2rem',
|
|
9
|
+
ml: '10px',
|
|
10
10
|
opacity: 0.5,
|
|
11
11
|
transition: 'opacity 0.2s',
|
|
12
|
-
marginRight: '2px',
|
|
13
|
-
height: '2rem',
|
|
14
12
|
width: '2rem',
|
|
15
13
|
'&:hover': {
|
|
16
14
|
opacity: 1,
|
|
@@ -19,18 +17,26 @@ const commonIconButtonStyles = {
|
|
|
19
17
|
|
|
20
18
|
interface Props {
|
|
21
19
|
row: MRT_Row;
|
|
20
|
+
tableInstance: MRT_TableInstance;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
export const MRT_ToggleRowActionMenuButton: FC<Props> = ({
|
|
23
|
+
export const MRT_ToggleRowActionMenuButton: FC<Props> = ({
|
|
24
|
+
row,
|
|
25
|
+
tableInstance,
|
|
26
|
+
}) => {
|
|
25
27
|
const {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
getState,
|
|
29
|
+
options: {
|
|
30
|
+
enableRowEditing,
|
|
31
|
+
icons: { EditIcon, MoreHorizIcon },
|
|
32
|
+
localization,
|
|
33
|
+
renderRowActionMenuItems,
|
|
34
|
+
renderRowActions,
|
|
35
|
+
setCurrentEditingRow,
|
|
36
|
+
},
|
|
37
|
+
} = tableInstance;
|
|
38
|
+
|
|
39
|
+
const { currentEditingRow } = getState();
|
|
34
40
|
|
|
35
41
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
36
42
|
|
|
@@ -46,13 +52,11 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
|
46
52
|
};
|
|
47
53
|
|
|
48
54
|
return (
|
|
49
|
-
|
|
50
|
-
sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)}
|
|
51
|
-
>
|
|
55
|
+
<>
|
|
52
56
|
{renderRowActions ? (
|
|
53
|
-
<>{renderRowActions(row, tableInstance)}</>
|
|
54
|
-
) : row.id ===
|
|
55
|
-
<MRT_EditActionButtons row={row} />
|
|
57
|
+
<>{renderRowActions({ row, tableInstance })}</>
|
|
58
|
+
) : row.id === currentEditingRow?.id ? (
|
|
59
|
+
<MRT_EditActionButtons row={row} tableInstance={tableInstance} />
|
|
56
60
|
) : !renderRowActionMenuItems && enableRowEditing ? (
|
|
57
61
|
<Tooltip placement="right" arrow title={localization.edit}>
|
|
58
62
|
<IconButton sx={commonIconButtonStyles} onClick={handleEdit}>
|
|
@@ -81,9 +85,10 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
|
81
85
|
handleEdit={handleEdit}
|
|
82
86
|
row={row}
|
|
83
87
|
setAnchorEl={setAnchorEl}
|
|
88
|
+
tableInstance={tableInstance}
|
|
84
89
|
/>
|
|
85
90
|
</>
|
|
86
91
|
) : null}
|
|
87
|
-
|
|
92
|
+
</>
|
|
88
93
|
);
|
|
89
94
|
};
|
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
|
-
interface Props extends IconButtonProps {
|
|
5
|
+
interface Props extends IconButtonProps {
|
|
6
|
+
tableInstance: MRT_TableInstance;
|
|
7
|
+
}
|
|
6
8
|
|
|
7
|
-
export const MRT_ToggleSearchButton: FC<Props> = ({
|
|
9
|
+
export const MRT_ToggleSearchButton: FC<Props> = ({
|
|
10
|
+
tableInstance,
|
|
11
|
+
...rest
|
|
12
|
+
}) => {
|
|
8
13
|
const {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
getState,
|
|
15
|
+
options: {
|
|
16
|
+
icons: { SearchIcon, SearchOffIcon },
|
|
17
|
+
idPrefix,
|
|
18
|
+
localization,
|
|
19
|
+
muiSearchTextFieldProps,
|
|
20
|
+
setShowSearch,
|
|
16
21
|
},
|
|
17
|
-
} =
|
|
22
|
+
} = tableInstance;
|
|
23
|
+
|
|
24
|
+
const { showSearch } = getState();
|
|
25
|
+
|
|
26
|
+
const textFieldProps =
|
|
27
|
+
muiSearchTextFieldProps instanceof Function
|
|
28
|
+
? muiSearchTextFieldProps({ tableInstance })
|
|
29
|
+
: muiSearchTextFieldProps;
|
|
18
30
|
|
|
19
31
|
const handleToggleSearch = () => {
|
|
20
32
|
setShowSearch(!showSearch);
|
|
@@ -22,7 +34,7 @@ export const MRT_ToggleSearchButton: FC<Props> = ({ ...rest }) => {
|
|
|
22
34
|
() =>
|
|
23
35
|
document
|
|
24
36
|
.getElementById(
|
|
25
|
-
|
|
37
|
+
textFieldProps?.id ?? `mrt-${idPrefix}-search-text-field`,
|
|
26
38
|
)
|
|
27
39
|
?.focus(),
|
|
28
40
|
200,
|
|
@@ -1,25 +1,41 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { TableFooter } from '@mui/material';
|
|
3
3
|
import { MRT_TableFooterRow } from './MRT_TableFooterRow';
|
|
4
|
-
import {
|
|
5
|
-
import type { MRT_HeaderGroup } from '..';
|
|
4
|
+
import type { MRT_HeaderGroup, MRT_TableInstance } from '..';
|
|
6
5
|
|
|
7
|
-
interface Props {
|
|
6
|
+
interface Props {
|
|
7
|
+
pinned: 'left' | 'center' | 'right' | 'none';
|
|
8
|
+
tableInstance: MRT_TableInstance;
|
|
9
|
+
}
|
|
8
10
|
|
|
9
|
-
export const MRT_TableFooter: FC<Props> = () => {
|
|
10
|
-
const {
|
|
11
|
+
export const MRT_TableFooter: FC<Props> = ({ pinned, tableInstance }) => {
|
|
12
|
+
const {
|
|
13
|
+
getCenterFooterGroups,
|
|
14
|
+
getFooterGroups,
|
|
15
|
+
getLeftFooterGroups,
|
|
16
|
+
getRightFooterGroups,
|
|
17
|
+
options: { muiTableFooterProps },
|
|
18
|
+
} = tableInstance;
|
|
11
19
|
|
|
12
20
|
const tableFooterProps =
|
|
13
21
|
muiTableFooterProps instanceof Function
|
|
14
|
-
? muiTableFooterProps(tableInstance)
|
|
22
|
+
? muiTableFooterProps({ tableInstance })
|
|
15
23
|
: muiTableFooterProps;
|
|
16
24
|
|
|
25
|
+
const getFooterGroupsMap = {
|
|
26
|
+
center: getCenterFooterGroups,
|
|
27
|
+
left: getLeftFooterGroups,
|
|
28
|
+
none: getFooterGroups,
|
|
29
|
+
right: getRightFooterGroups,
|
|
30
|
+
};
|
|
31
|
+
|
|
17
32
|
return (
|
|
18
33
|
<TableFooter {...tableFooterProps}>
|
|
19
|
-
{
|
|
34
|
+
{getFooterGroupsMap[pinned]().map((footerGroup) => (
|
|
20
35
|
<MRT_TableFooterRow
|
|
36
|
+
footerGroup={footerGroup as MRT_HeaderGroup}
|
|
21
37
|
key={footerGroup.getFooterGroupProps().key}
|
|
22
|
-
|
|
38
|
+
tableInstance={tableInstance}
|
|
23
39
|
/>
|
|
24
40
|
))}
|
|
25
41
|
</TableFooter>
|
|
@@ -1,58 +1,66 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { TableCell } from '@mui/material';
|
|
3
|
-
import {
|
|
4
|
-
import type { MRT_HeaderGroup } from '..';
|
|
2
|
+
import { alpha, TableCell } from '@mui/material';
|
|
3
|
+
import type { MRT_Header, MRT_TableInstance } from '..';
|
|
5
4
|
|
|
6
5
|
interface Props {
|
|
7
|
-
|
|
6
|
+
footer: MRT_Header;
|
|
7
|
+
tableInstance: MRT_TableInstance;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const MRT_TableFooterCell: FC<Props> = ({
|
|
10
|
+
export const MRT_TableFooterCell: FC<Props> = ({ footer, tableInstance }) => {
|
|
11
11
|
const {
|
|
12
|
-
|
|
13
|
-
enableColumnResizing,
|
|
14
|
-
|
|
15
|
-
state: { densePadding },
|
|
16
|
-
},
|
|
17
|
-
} = useMRT();
|
|
12
|
+
getState,
|
|
13
|
+
options: { muiTableFooterCellProps, enableColumnResizing },
|
|
14
|
+
} = tableInstance;
|
|
18
15
|
|
|
19
|
-
const
|
|
16
|
+
const { isDensePadding } = getState();
|
|
17
|
+
|
|
18
|
+
const { column } = footer;
|
|
20
19
|
|
|
21
20
|
const mTableFooterCellProps =
|
|
22
21
|
muiTableFooterCellProps instanceof Function
|
|
23
|
-
? muiTableFooterCellProps(column)
|
|
22
|
+
? muiTableFooterCellProps({ column, tableInstance })
|
|
24
23
|
: muiTableFooterCellProps;
|
|
25
24
|
|
|
26
25
|
const mcTableFooterCellProps =
|
|
27
26
|
column.muiTableFooterCellProps instanceof Function
|
|
28
|
-
? column.muiTableFooterCellProps(column)
|
|
27
|
+
? column.muiTableFooterCellProps({ column, tableInstance })
|
|
29
28
|
: column.muiTableFooterCellProps;
|
|
30
29
|
|
|
31
30
|
const tableCellProps = {
|
|
31
|
+
...footer.getFooterProps(),
|
|
32
32
|
...mTableFooterCellProps,
|
|
33
33
|
...mcTableFooterCellProps,
|
|
34
|
-
...column.getFooterProps(),
|
|
35
|
-
style: {
|
|
36
|
-
...column.getFooterProps().style,
|
|
37
|
-
...mTableFooterCellProps?.style,
|
|
38
|
-
...mcTableFooterCellProps?.style,
|
|
39
|
-
},
|
|
40
34
|
};
|
|
41
35
|
|
|
42
36
|
return (
|
|
43
37
|
<TableCell
|
|
44
|
-
align={
|
|
38
|
+
align={column.columnDefType === 'group' ? 'center' : 'left'}
|
|
45
39
|
variant="head"
|
|
46
40
|
{...tableCellProps}
|
|
47
|
-
|
|
41
|
+
//@ts-ignore
|
|
42
|
+
sx={(theme) => ({
|
|
43
|
+
backgroundColor: theme.palette.background.default,
|
|
44
|
+
backgroundImage: `linear-gradient(${alpha(
|
|
45
|
+
theme.palette.common.white,
|
|
46
|
+
0.05,
|
|
47
|
+
)},${alpha(theme.palette.common.white, 0.05)})`,
|
|
48
48
|
fontWeight: 'bold',
|
|
49
|
-
|
|
50
|
-
p: densePadding ? '0.5rem' : '1rem',
|
|
49
|
+
p: isDensePadding ? '0.5rem' : '1rem',
|
|
51
50
|
transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
|
|
51
|
+
verticalAlign: 'text-top',
|
|
52
|
+
//@ts-ignore
|
|
52
53
|
...tableCellProps?.sx,
|
|
53
|
-
}}
|
|
54
|
+
})}
|
|
54
55
|
>
|
|
55
|
-
{
|
|
56
|
+
{footer.isPlaceholder
|
|
57
|
+
? null
|
|
58
|
+
: column.Footer?.({
|
|
59
|
+
footer,
|
|
60
|
+
tableInstance,
|
|
61
|
+
}) ??
|
|
62
|
+
column.footer ??
|
|
63
|
+
null}
|
|
56
64
|
</TableCell>
|
|
57
65
|
);
|
|
58
66
|
};
|
|
@@ -1,66 +1,48 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { TableRow } from '@mui/material';
|
|
3
3
|
import { MRT_TableFooterCell } from './MRT_TableFooterCell';
|
|
4
|
-
import {
|
|
5
|
-
import { useMRT } from '../useMRT';
|
|
6
|
-
import type { MRT_HeaderGroup } from '..';
|
|
4
|
+
import type { MRT_Header, MRT_HeaderGroup, MRT_TableInstance } from '..';
|
|
7
5
|
|
|
8
6
|
interface Props {
|
|
9
7
|
footerGroup: MRT_HeaderGroup;
|
|
8
|
+
tableInstance: MRT_TableInstance;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
export const MRT_TableFooterRow: FC<Props> = ({
|
|
11
|
+
export const MRT_TableFooterRow: FC<Props> = ({
|
|
12
|
+
footerGroup,
|
|
13
|
+
tableInstance,
|
|
14
|
+
}) => {
|
|
13
15
|
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
enableRowActions,
|
|
17
|
-
enableRowEditing,
|
|
18
|
-
enableRowNumbers,
|
|
19
|
-
enableSelection,
|
|
20
|
-
muiTableFooterRowProps,
|
|
21
|
-
positionActionsColumn,
|
|
22
|
-
renderDetailPanel,
|
|
23
|
-
tableInstance,
|
|
24
|
-
} = useMRT();
|
|
16
|
+
options: { muiTableFooterRowProps },
|
|
17
|
+
} = tableInstance;
|
|
25
18
|
|
|
26
|
-
//if no content in row, skip row
|
|
27
|
-
if (
|
|
19
|
+
// if no content in row, skip row
|
|
20
|
+
if (
|
|
21
|
+
!footerGroup.headers?.some(
|
|
22
|
+
(h) => h.column.columnDef.footer || h.column.Footer,
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
return null;
|
|
28
26
|
|
|
29
27
|
const mTableFooterRowProps =
|
|
30
28
|
muiTableFooterRowProps instanceof Function
|
|
31
|
-
? muiTableFooterRowProps(footerGroup)
|
|
29
|
+
? muiTableFooterRowProps({ footerGroup, tableInstance })
|
|
32
30
|
: muiTableFooterRowProps;
|
|
33
31
|
|
|
34
32
|
const tableRowProps = {
|
|
35
|
-
...mTableFooterRowProps,
|
|
36
33
|
...footerGroup.getFooterGroupProps(),
|
|
37
|
-
|
|
38
|
-
...footerGroup.getFooterGroupProps().style,
|
|
39
|
-
...mTableFooterRowProps?.style,
|
|
40
|
-
},
|
|
34
|
+
...mTableFooterRowProps,
|
|
41
35
|
};
|
|
42
36
|
|
|
43
37
|
return (
|
|
44
38
|
<TableRow {...tableRowProps}>
|
|
45
|
-
{
|
|
46
|
-
{(enableRowActions || enableRowEditing) &&
|
|
47
|
-
positionActionsColumn === 'first' && <MRT_TableSpacerCell />}
|
|
48
|
-
{(anyRowsCanExpand || renderDetailPanel) && (
|
|
49
|
-
<MRT_TableSpacerCell
|
|
50
|
-
width={`${
|
|
51
|
-
renderDetailPanel ? 2 : tableInstance.expandedDepth + 0.5
|
|
52
|
-
}rem`}
|
|
53
|
-
/>
|
|
54
|
-
)}
|
|
55
|
-
{enableSelection && <MRT_TableSpacerCell width="1rem" />}
|
|
56
|
-
{footerGroup.headers.map((column: MRT_HeaderGroup) => (
|
|
39
|
+
{footerGroup.headers.map((footer: MRT_Header) => (
|
|
57
40
|
<MRT_TableFooterCell
|
|
58
|
-
|
|
59
|
-
|
|
41
|
+
footer={footer}
|
|
42
|
+
key={footer.getFooterProps().key}
|
|
43
|
+
tableInstance={tableInstance}
|
|
60
44
|
/>
|
|
61
45
|
))}
|
|
62
|
-
{(enableRowActions || enableRowEditing) &&
|
|
63
|
-
positionActionsColumn === 'last' && <MRT_TableSpacerCell />}
|
|
64
46
|
</TableRow>
|
|
65
47
|
);
|
|
66
48
|
};
|
|
@@ -1,25 +1,41 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { TableHead } from '@mui/material';
|
|
3
3
|
import { MRT_TableHeadRow } from './MRT_TableHeadRow';
|
|
4
|
-
import {
|
|
5
|
-
import type { MRT_HeaderGroup } from '..';
|
|
4
|
+
import type { MRT_HeaderGroup, MRT_TableInstance } from '..';
|
|
6
5
|
|
|
7
|
-
interface Props {
|
|
6
|
+
interface Props {
|
|
7
|
+
pinned: 'left' | 'center' | 'right' | 'none';
|
|
8
|
+
tableInstance: MRT_TableInstance;
|
|
9
|
+
}
|
|
8
10
|
|
|
9
|
-
export const MRT_TableHead: FC<Props> = () => {
|
|
10
|
-
const {
|
|
11
|
+
export const MRT_TableHead: FC<Props> = ({ pinned, tableInstance }) => {
|
|
12
|
+
const {
|
|
13
|
+
getCenterHeaderGroups,
|
|
14
|
+
getHeaderGroups,
|
|
15
|
+
getLeftHeaderGroups,
|
|
16
|
+
getRightHeaderGroups,
|
|
17
|
+
options: { muiTableHeadProps },
|
|
18
|
+
} = tableInstance;
|
|
11
19
|
|
|
12
20
|
const tableHeadProps =
|
|
13
21
|
muiTableHeadProps instanceof Function
|
|
14
|
-
? muiTableHeadProps(tableInstance)
|
|
22
|
+
? muiTableHeadProps({ tableInstance })
|
|
15
23
|
: muiTableHeadProps;
|
|
16
24
|
|
|
25
|
+
const getHeaderGroupsMap = {
|
|
26
|
+
center: getCenterHeaderGroups,
|
|
27
|
+
left: getLeftHeaderGroups,
|
|
28
|
+
none: getHeaderGroups,
|
|
29
|
+
right: getRightHeaderGroups,
|
|
30
|
+
};
|
|
31
|
+
|
|
17
32
|
return (
|
|
18
33
|
<TableHead {...tableHeadProps}>
|
|
19
|
-
{
|
|
34
|
+
{getHeaderGroupsMap[pinned]().map((headerGroup) => (
|
|
20
35
|
<MRT_TableHeadRow
|
|
36
|
+
headerGroup={headerGroup as MRT_HeaderGroup}
|
|
21
37
|
key={headerGroup.getHeaderGroupProps().key}
|
|
22
|
-
|
|
38
|
+
tableInstance={tableInstance}
|
|
23
39
|
/>
|
|
24
40
|
))}
|
|
25
41
|
</TableHead>
|