material-react-table 0.6.9 → 0.7.0-alpha.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 +308 -107
- 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/enums.d.ts +2 -1
- package/dist/filtersFNs.d.ts +13 -5
- 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 +9 -2
- package/dist/material-react-table.cjs.development.js +2258 -2470
- 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 +2260 -2472
- 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 +27 -28
- package/src/MaterialReactTable.tsx +598 -295
- package/src/body/MRT_TableBody.tsx +26 -22
- package/src/body/MRT_TableBodyCell.tsx +76 -55
- package/src/body/MRT_TableBodyRow.tsx +37 -67
- package/src/body/MRT_TableDetailPanel.tsx +21 -17
- package/src/buttons/MRT_CopyButton.tsx +36 -11
- package/src/buttons/MRT_EditActionButtons.tsx +16 -13
- package/src/buttons/MRT_ExpandAllButton.tsx +36 -28
- package/src/buttons/MRT_ExpandButton.tsx +35 -41
- 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/enums.ts +2 -1
- package/src/filtersFNs.ts +17 -3
- 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 +185 -142
- package/src/head/MRT_TableHeadRow.tsx +16 -93
- package/src/icons.ts +3 -3
- package/src/inputs/MRT_EditCellTextField.tsx +23 -24
- package/src/inputs/MRT_FilterTextField.tsx +53 -39
- package/src/inputs/MRT_SearchTextField.tsx +71 -25
- package/src/inputs/MRT_SelectCheckbox.tsx +42 -30
- package/src/localization.ts +19 -4
- package/src/menus/MRT_ColumnActionMenu.tsx +129 -69
- package/src/menus/MRT_FilterTypeMenu.tsx +55 -23
- 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 +30 -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 -27
- 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 -215
|
@@ -1,59 +1,53 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import { IconButton
|
|
3
|
-
import {
|
|
4
|
-
import type { MRT_Row } from '..';
|
|
5
|
-
import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
|
|
2
|
+
import { IconButton } from '@mui/material';
|
|
3
|
+
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
6
4
|
|
|
7
5
|
interface Props {
|
|
8
6
|
row: MRT_Row;
|
|
7
|
+
tableInstance: MRT_TableInstance;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
10
|
+
export const MRT_ExpandButton: FC<Props> = ({ row, tableInstance }) => {
|
|
12
11
|
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
getState,
|
|
13
|
+
options: {
|
|
14
|
+
icons: { ExpandMoreIcon },
|
|
15
|
+
localization,
|
|
16
|
+
onRowExpandChange,
|
|
17
|
+
renderDetailPanel,
|
|
19
18
|
},
|
|
20
|
-
} =
|
|
19
|
+
} = tableInstance;
|
|
20
|
+
|
|
21
|
+
const { isDensePadding } = getState();
|
|
21
22
|
|
|
22
23
|
const handleToggleExpand = (event: MouseEvent<HTMLButtonElement>) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
onRowExpandChange?.(event, row);
|
|
24
|
+
row.toggleExpanded();
|
|
25
|
+
onRowExpandChange?.({ event, row, tableInstance });
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
return (
|
|
29
|
-
<
|
|
30
|
-
|
|
29
|
+
<IconButton
|
|
30
|
+
aria-label={localization.expand}
|
|
31
|
+
disabled={!row.getCanExpand() && !renderDetailPanel}
|
|
32
|
+
title={localization.expand}
|
|
33
|
+
onClick={handleToggleExpand}
|
|
31
34
|
sx={{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
textAlign: 'left',
|
|
35
|
+
height: isDensePadding ? '1.75rem' : '2.25rem',
|
|
36
|
+
width: isDensePadding ? '1.75rem' : '2.25rem',
|
|
35
37
|
}}
|
|
36
38
|
>
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
? -180
|
|
51
|
-
: 0
|
|
52
|
-
}deg)`,
|
|
53
|
-
transition: 'transform 0.2s',
|
|
54
|
-
}}
|
|
55
|
-
/>
|
|
56
|
-
</IconButton>
|
|
57
|
-
</TableCell>
|
|
39
|
+
<ExpandMoreIcon
|
|
40
|
+
style={{
|
|
41
|
+
transform: `rotate(${
|
|
42
|
+
!row.getCanExpand() && !renderDetailPanel
|
|
43
|
+
? -90
|
|
44
|
+
: row.getIsExpanded()
|
|
45
|
+
? -180
|
|
46
|
+
: 0
|
|
47
|
+
}deg)`,
|
|
48
|
+
transition: 'transform 0.2s',
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
</IconButton>
|
|
58
52
|
);
|
|
59
53
|
};
|
|
@@ -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,
|
package/src/enums.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export enum MRT_FILTER_TYPE {
|
|
2
|
+
BEST_MATCH = 'bestMatch',
|
|
3
|
+
BEST_MATCH_FIRST = 'bestMatchFirst',
|
|
2
4
|
CONTAINS = 'contains',
|
|
3
5
|
EMPTY = 'empty',
|
|
4
6
|
ENDS_WITH = 'endsWith',
|
|
5
7
|
EQUALS = 'equals',
|
|
6
|
-
FUZZY = 'fuzzy',
|
|
7
8
|
GREATER_THAN = 'greaterThan',
|
|
8
9
|
LESS_THAN = 'lessThan',
|
|
9
10
|
NOT_EMPTY = 'notEmpty',
|
package/src/filtersFNs.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { matchSorter } from 'match-sorter';
|
|
2
2
|
import { MRT_Row } from '.';
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const bestMatchFirst = (
|
|
5
|
+
rows: MRT_Row[],
|
|
6
|
+
columnIds: string[] | string,
|
|
7
|
+
filterValue: string | number,
|
|
8
|
+
) =>
|
|
9
|
+
matchSorter(rows, filterValue.toString().trim(), {
|
|
10
|
+
keys: Array.isArray(columnIds)
|
|
11
|
+
? columnIds.map((c) => `values.${c}`)
|
|
12
|
+
: [`values.${columnIds}`],
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
bestMatchFirst.autoRemove = (val: any) => !val;
|
|
16
|
+
|
|
17
|
+
export const bestMatch = (
|
|
5
18
|
rows: MRT_Row[],
|
|
6
19
|
columnIds: string[] | string,
|
|
7
20
|
filterValue: string | number,
|
|
@@ -13,7 +26,7 @@ export const fuzzy = (
|
|
|
13
26
|
sorter: (rankedItems) => rankedItems,
|
|
14
27
|
});
|
|
15
28
|
|
|
16
|
-
|
|
29
|
+
bestMatch.autoRemove = (val: any) => !val;
|
|
17
30
|
|
|
18
31
|
export const contains = (
|
|
19
32
|
rows: MRT_Row[],
|
|
@@ -131,11 +144,12 @@ export const notEmpty = (
|
|
|
131
144
|
notEmpty.autoRemove = (val: any) => !val;
|
|
132
145
|
|
|
133
146
|
export const defaultFilterFNs = {
|
|
147
|
+
bestMatch,
|
|
148
|
+
bestMatchFirst,
|
|
134
149
|
contains,
|
|
135
150
|
empty,
|
|
136
151
|
endsWith,
|
|
137
152
|
equals,
|
|
138
|
-
fuzzy,
|
|
139
153
|
greaterThan,
|
|
140
154
|
lessThan,
|
|
141
155
|
notEmpty,
|
|
@@ -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
|
};
|