material-react-table 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MaterialReactTable.d.ts +5 -4
- package/dist/material-react-table.cjs.development.js +74 -73
- 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 +75 -74
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/useMRT.d.ts +0 -5
- package/package.json +1 -1
- package/src/@types/react-table-config.d.ts +3 -3
- package/src/MaterialReactTable.tsx +5 -4
- package/src/body/MRT_TableBodyCell.tsx +3 -2
- package/src/body/MRT_TableBodyRow.tsx +11 -8
- package/src/buttons/MRT_EditActionButtons.tsx +2 -2
- package/src/buttons/MRT_ExpandAllButton.tsx +3 -4
- package/src/buttons/MRT_ExpandButton.tsx +3 -1
- package/src/buttons/MRT_FullScreenToggleButton.tsx +3 -1
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +3 -1
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +17 -11
- package/src/buttons/MRT_ToggleSearchButton.tsx +1 -1
- package/src/footer/MRT_TableFooterCell.tsx +7 -2
- package/src/head/MRT_TableHeadCell.tsx +5 -4
- package/src/head/MRT_TableHeadCellActions.tsx +6 -1
- package/src/head/MRT_TableHeadRow.tsx +7 -2
- package/src/inputs/MRT_EditCellTextField.tsx +3 -1
- package/src/inputs/MRT_SearchTextField.tsx +1 -2
- package/src/inputs/MRT_SelectCheckbox.tsx +1 -2
- package/src/table/MRT_TableContainer.tsx +1 -1
- package/src/toolbar/MRT_ToolbarBottom.tsx +2 -3
- package/src/toolbar/MRT_ToolbarTop.tsx +2 -3
- package/src/useMRT.tsx +38 -23
package/dist/useMRT.d.ts
CHANGED
|
@@ -6,9 +6,6 @@ import { MaterialReactTableProps } from './MaterialReactTable';
|
|
|
6
6
|
export declare type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
|
|
7
7
|
anyRowsCanExpand: boolean;
|
|
8
8
|
anyRowsExpanded: boolean;
|
|
9
|
-
currentEditingRow: MRT_Row<D> | null;
|
|
10
|
-
densePadding: boolean;
|
|
11
|
-
fullScreen: boolean;
|
|
12
9
|
icons: MRT_Icons;
|
|
13
10
|
localization: MRT_Localization;
|
|
14
11
|
setCurrentEditingRow: (currentRowEditingId: MRT_Row<D> | null) => void;
|
|
@@ -16,8 +13,6 @@ export declare type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
|
|
|
16
13
|
setFullScreen: (fullScreen: boolean) => void;
|
|
17
14
|
setShowFilters: (showFilters: boolean) => void;
|
|
18
15
|
setShowSearch: (showSearch: boolean) => void;
|
|
19
|
-
showFilters: boolean;
|
|
20
|
-
showSearch: boolean;
|
|
21
16
|
tableInstance: MRT_TableInstance<D>;
|
|
22
17
|
};
|
|
23
18
|
export declare const MaterialReactTableProvider: <D extends {}>(props: React.PropsWithChildren<MaterialReactTableProps<D>>) => JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.5.
|
|
2
|
+
"version": "0.5.2",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material-UI implementation of react-table, inspired by material-table and the mui DataGrid, written from the ground up in TypeScript.",
|
|
@@ -14,8 +14,6 @@ import {
|
|
|
14
14
|
} from '..';
|
|
15
15
|
|
|
16
16
|
declare module 'react-table' {
|
|
17
|
-
// take this file as-is, or comment out the sections that don't apply to your plugin configuration
|
|
18
|
-
|
|
19
17
|
export interface TableOptions<D extends Record<string, unknown>>
|
|
20
18
|
extends MRT_TableOptions<D> {}
|
|
21
19
|
|
|
@@ -28,7 +26,9 @@ declare module 'react-table' {
|
|
|
28
26
|
|
|
29
27
|
export interface TableInstance<
|
|
30
28
|
D extends Record<string, unknown> = Record<string, unknown>,
|
|
31
|
-
> extends MRT_TableInstance<D> {
|
|
29
|
+
> extends MRT_TableInstance<D> {
|
|
30
|
+
rows: MRT_Row<D>[];
|
|
31
|
+
}
|
|
32
32
|
|
|
33
33
|
export interface TableState<
|
|
34
34
|
D extends Record<string, unknown> = Record<string, unknown>,
|
|
@@ -192,10 +192,11 @@ export type MRT_TableState<D extends {} = {}> = TableState<D> &
|
|
|
192
192
|
UseRowSelectState<D> &
|
|
193
193
|
UseRowStateState<D> &
|
|
194
194
|
UseSortByState<D> & {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
currentEditingRow: MRT_Row<D> | null;
|
|
196
|
+
densePadding: boolean;
|
|
197
|
+
fullScreen: boolean;
|
|
198
|
+
showFilters: boolean;
|
|
199
|
+
showSearch: boolean;
|
|
199
200
|
};
|
|
200
201
|
|
|
201
202
|
export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
@@ -24,8 +24,9 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
24
24
|
const {
|
|
25
25
|
onCellClick,
|
|
26
26
|
muiTableBodyCellProps,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
tableInstance: {
|
|
28
|
+
state: { currentEditingRow, densePadding },
|
|
29
|
+
},
|
|
29
30
|
} = useMRT();
|
|
30
31
|
|
|
31
32
|
const mTableCellBodyProps =
|
|
@@ -18,7 +18,6 @@ interface Props {
|
|
|
18
18
|
export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
19
19
|
const {
|
|
20
20
|
anyRowsCanExpand,
|
|
21
|
-
densePadding,
|
|
22
21
|
enableRowActions,
|
|
23
22
|
enableRowEditing,
|
|
24
23
|
enableRowNumbers,
|
|
@@ -27,6 +26,9 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
27
26
|
onRowClick,
|
|
28
27
|
positionActionsColumn,
|
|
29
28
|
renderDetailPanel,
|
|
29
|
+
tableInstance: {
|
|
30
|
+
state: { densePadding },
|
|
31
|
+
},
|
|
30
32
|
} = useMRT();
|
|
31
33
|
|
|
32
34
|
const mTableBodyRowProps =
|
|
@@ -51,13 +53,14 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
51
53
|
onRowClick?.(event, row)
|
|
52
54
|
}
|
|
53
55
|
{...tableRowProps}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
sx={(theme) =>
|
|
57
|
+
({
|
|
58
|
+
backgroundColor: row.isSelected
|
|
59
|
+
? alpha(theme.palette.primary.light, 0.1)
|
|
60
|
+
: 'transparent',
|
|
61
|
+
...tableRowProps?.sx,
|
|
62
|
+
} as any)
|
|
63
|
+
}
|
|
61
64
|
>
|
|
62
65
|
{enableRowNumbers && (
|
|
63
66
|
<TableCell sx={{ ...commonTableBodyCellStyles(densePadding) }}>
|
|
@@ -11,9 +11,9 @@ export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
|
|
|
11
11
|
const {
|
|
12
12
|
icons: { CancelIcon, SaveIcon },
|
|
13
13
|
localization,
|
|
14
|
-
setCurrentEditingRow,
|
|
15
14
|
onRowEditSubmit,
|
|
16
|
-
|
|
15
|
+
setCurrentEditingRow,
|
|
16
|
+
tableInstance: { state: { currentEditingRow } },
|
|
17
17
|
} = useMRT();
|
|
18
18
|
|
|
19
19
|
const handleCancel = () => {
|
|
@@ -7,18 +7,17 @@ interface Props {}
|
|
|
7
7
|
|
|
8
8
|
export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
9
9
|
const {
|
|
10
|
-
tableInstance,
|
|
11
|
-
localization,
|
|
12
10
|
anyRowsExpanded,
|
|
13
|
-
densePadding,
|
|
14
11
|
icons: { DoubleArrowDownIcon },
|
|
12
|
+
localization,
|
|
13
|
+
tableInstance,
|
|
15
14
|
} = useMRT();
|
|
16
15
|
|
|
17
16
|
return (
|
|
18
17
|
<TableCell
|
|
19
18
|
size="small"
|
|
20
19
|
{...tableInstance.getToggleAllRowsExpandedProps()}
|
|
21
|
-
sx={commonTableBodyButtonCellStyles(densePadding)}
|
|
20
|
+
sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)}
|
|
22
21
|
>
|
|
23
22
|
<IconButton
|
|
24
23
|
aria-label={localization.expandAllButtonTitle}
|
|
@@ -10,10 +10,12 @@ interface Props {
|
|
|
10
10
|
|
|
11
11
|
export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
12
12
|
const {
|
|
13
|
-
densePadding,
|
|
14
13
|
icons: { ExpandMoreIcon },
|
|
15
14
|
localization,
|
|
16
15
|
renderDetailPanel,
|
|
16
|
+
tableInstance: {
|
|
17
|
+
state: { densePadding },
|
|
18
|
+
},
|
|
17
19
|
} = useMRT();
|
|
18
20
|
|
|
19
21
|
return (
|
|
@@ -6,10 +6,12 @@ interface Props extends IconButtonProps {}
|
|
|
6
6
|
|
|
7
7
|
export const MRT_FullScreenToggleButton: FC<Props> = ({ ...rest }) => {
|
|
8
8
|
const {
|
|
9
|
-
fullScreen,
|
|
10
9
|
icons: { FullscreenExitIcon, FullscreenIcon },
|
|
11
10
|
localization,
|
|
12
11
|
setFullScreen,
|
|
12
|
+
tableInstance: {
|
|
13
|
+
state: { fullScreen },
|
|
14
|
+
},
|
|
13
15
|
} = useMRT();
|
|
14
16
|
|
|
15
17
|
return (
|
|
@@ -6,10 +6,12 @@ interface Props extends IconButtonProps {}
|
|
|
6
6
|
|
|
7
7
|
export const MRT_ToggleDensePaddingButton: FC<Props> = ({ ...rest }) => {
|
|
8
8
|
const {
|
|
9
|
-
densePadding,
|
|
10
9
|
setDensePadding,
|
|
11
10
|
localization,
|
|
12
11
|
icons: { DensityMediumIcon, DensitySmallIcon },
|
|
12
|
+
tableInstance: {
|
|
13
|
+
state: { densePadding },
|
|
14
|
+
},
|
|
13
15
|
} = useMRT();
|
|
14
16
|
|
|
15
17
|
return (
|
|
@@ -6,10 +6,10 @@ interface Props extends IconButtonProps {}
|
|
|
6
6
|
|
|
7
7
|
export const MRT_ToggleFiltersButton: FC<Props> = ({ ...rest }) => {
|
|
8
8
|
const {
|
|
9
|
+
icons: { FilterListIcon, FilterListOffIcon },
|
|
9
10
|
localization,
|
|
10
11
|
setShowFilters,
|
|
11
|
-
showFilters,
|
|
12
|
-
icons: { FilterListIcon, FilterListOffIcon },
|
|
12
|
+
tableInstance: { state: { showFilters } },
|
|
13
13
|
} = useMRT();
|
|
14
14
|
|
|
15
15
|
return (
|
|
@@ -23,8 +23,6 @@ interface Props {
|
|
|
23
23
|
|
|
24
24
|
export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
25
25
|
const {
|
|
26
|
-
currentEditingRow,
|
|
27
|
-
densePadding,
|
|
28
26
|
enableRowEditing,
|
|
29
27
|
icons: { EditIcon, MoreHorizIcon },
|
|
30
28
|
localization,
|
|
@@ -48,10 +46,12 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
|
48
46
|
};
|
|
49
47
|
|
|
50
48
|
return (
|
|
51
|
-
<TableCell
|
|
49
|
+
<TableCell
|
|
50
|
+
sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)}
|
|
51
|
+
>
|
|
52
52
|
{renderRowActions ? (
|
|
53
53
|
<>{renderRowActions(row, tableInstance)}</>
|
|
54
|
-
) : row.id === currentEditingRow?.id ? (
|
|
54
|
+
) : row.id === tableInstance.state.currentEditingRow?.id ? (
|
|
55
55
|
<MRT_EditActionButtons row={row} />
|
|
56
56
|
) : !renderRowActionMenuItems && enableRowEditing ? (
|
|
57
57
|
<Tooltip
|
|
@@ -65,15 +65,21 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
|
65
65
|
</Tooltip>
|
|
66
66
|
) : renderRowActionMenuItems ? (
|
|
67
67
|
<>
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
sx={commonIconButtonStyles}
|
|
68
|
+
<Tooltip
|
|
69
|
+
arrow
|
|
70
|
+
enterDelay={1000}
|
|
71
|
+
enterNextDelay={1000}
|
|
73
72
|
title={localization.rowActionMenuButtonTitle}
|
|
74
73
|
>
|
|
75
|
-
<
|
|
76
|
-
|
|
74
|
+
<IconButton
|
|
75
|
+
aria-label={localization.rowActionMenuButtonTitle}
|
|
76
|
+
onClick={handleOpenRowActionMenu}
|
|
77
|
+
size="small"
|
|
78
|
+
sx={commonIconButtonStyles}
|
|
79
|
+
>
|
|
80
|
+
<MoreHorizIcon />
|
|
81
|
+
</IconButton>
|
|
82
|
+
</Tooltip>
|
|
77
83
|
<MRT_RowActionMenu
|
|
78
84
|
anchorEl={anchorEl}
|
|
79
85
|
handleEdit={handleEdit}
|
|
@@ -8,8 +8,13 @@ interface Props {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
|
|
11
|
-
const {
|
|
12
|
-
|
|
11
|
+
const {
|
|
12
|
+
muiTableFooterCellProps,
|
|
13
|
+
enableColumnResizing,
|
|
14
|
+
tableInstance: {
|
|
15
|
+
state: { densePadding },
|
|
16
|
+
},
|
|
17
|
+
} = useMRT();
|
|
13
18
|
|
|
14
19
|
const isParentHeader = (column?.columns?.length ?? 0) > 0;
|
|
15
20
|
|
|
@@ -30,13 +30,11 @@ interface Props {
|
|
|
30
30
|
|
|
31
31
|
export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
32
32
|
const {
|
|
33
|
-
densePadding,
|
|
34
33
|
disableColumnActions,
|
|
35
34
|
disableFilters,
|
|
36
35
|
enableColumnResizing,
|
|
37
36
|
localization,
|
|
38
37
|
muiTableHeadCellProps,
|
|
39
|
-
showFilters,
|
|
40
38
|
tableInstance,
|
|
41
39
|
} = useMRT();
|
|
42
40
|
|
|
@@ -80,7 +78,10 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
80
78
|
align={isParentHeader ? 'center' : 'left'}
|
|
81
79
|
{...tableCellProps}
|
|
82
80
|
sx={{
|
|
83
|
-
...commonTableHeadCellStyles(
|
|
81
|
+
...commonTableHeadCellStyles(
|
|
82
|
+
tableInstance.state.densePadding,
|
|
83
|
+
enableColumnResizing,
|
|
84
|
+
),
|
|
84
85
|
...tableCellProps?.sx,
|
|
85
86
|
}}
|
|
86
87
|
>
|
|
@@ -133,7 +134,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
133
134
|
</Box>
|
|
134
135
|
</Box>
|
|
135
136
|
{!disableFilters && column.canFilter && (
|
|
136
|
-
<Collapse in={showFilters}>
|
|
137
|
+
<Collapse in={tableInstance.state.showFilters}>
|
|
137
138
|
<MRT_FilterTextField column={column} />
|
|
138
139
|
</Collapse>
|
|
139
140
|
)}
|
|
@@ -6,7 +6,12 @@ import { commonTableHeadCellStyles } from './MRT_TableHeadCell';
|
|
|
6
6
|
interface Props {}
|
|
7
7
|
|
|
8
8
|
export const MRT_TableHeadCellActions: FC<Props> = () => {
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
localization,
|
|
11
|
+
tableInstance: {
|
|
12
|
+
state: { densePadding },
|
|
13
|
+
},
|
|
14
|
+
} = useMRT();
|
|
10
15
|
|
|
11
16
|
return (
|
|
12
17
|
<TableCell
|
|
@@ -18,7 +18,6 @@ interface Props {
|
|
|
18
18
|
export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
19
19
|
const {
|
|
20
20
|
anyRowsCanExpand,
|
|
21
|
-
densePadding,
|
|
22
21
|
disableExpandAll,
|
|
23
22
|
enableRowActions,
|
|
24
23
|
enableRowEditing,
|
|
@@ -55,7 +54,13 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
55
54
|
(isParentHeader ? (
|
|
56
55
|
<MRT_TableSpacerCell />
|
|
57
56
|
) : (
|
|
58
|
-
<TableCell
|
|
57
|
+
<TableCell
|
|
58
|
+
sx={{
|
|
59
|
+
...commonTableHeadCellStyles(tableInstance.state.densePadding),
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
#
|
|
63
|
+
</TableCell>
|
|
59
64
|
))}
|
|
60
65
|
{(enableRowActions || enableRowEditing) &&
|
|
61
66
|
positionActionsColumn === 'first' &&
|
|
@@ -9,9 +9,11 @@ interface Props {
|
|
|
9
9
|
|
|
10
10
|
export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
|
|
11
11
|
const {
|
|
12
|
-
currentEditingRow,
|
|
13
12
|
muiTableBodyCellEditTextFieldProps,
|
|
14
13
|
setCurrentEditingRow,
|
|
14
|
+
tableInstance: {
|
|
15
|
+
state: { currentEditingRow },
|
|
16
|
+
},
|
|
15
17
|
} = useMRT();
|
|
16
18
|
|
|
17
19
|
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
@@ -8,7 +8,6 @@ interface Props {}
|
|
|
8
8
|
export const MRT_SearchTextField: FC<Props> = () => {
|
|
9
9
|
const {
|
|
10
10
|
icons: { SearchIcon, CloseIcon },
|
|
11
|
-
showSearch,
|
|
12
11
|
localization,
|
|
13
12
|
muiSearchTextFieldProps,
|
|
14
13
|
onGlobalFilterChange,
|
|
@@ -31,7 +30,7 @@ export const MRT_SearchTextField: FC<Props> = () => {
|
|
|
31
30
|
};
|
|
32
31
|
|
|
33
32
|
return (
|
|
34
|
-
<Collapse in={showSearch} orientation="horizontal">
|
|
33
|
+
<Collapse in={tableInstance.state.showSearch} orientation="horizontal">
|
|
35
34
|
<TextField
|
|
36
35
|
id="global-search-text-field"
|
|
37
36
|
placeholder={localization.searchTextFieldPlaceholder}
|
|
@@ -11,7 +11,6 @@ interface Props {
|
|
|
11
11
|
|
|
12
12
|
export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
|
|
13
13
|
const {
|
|
14
|
-
densePadding,
|
|
15
14
|
localization,
|
|
16
15
|
onRowSelectChange,
|
|
17
16
|
onSelectAllChange,
|
|
@@ -33,7 +32,7 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
|
|
|
33
32
|
: row?.getToggleRowSelectedProps();
|
|
34
33
|
|
|
35
34
|
return (
|
|
36
|
-
<TableCell sx={commonTableBodyButtonCellStyles(densePadding)} >
|
|
35
|
+
<TableCell sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)} >
|
|
37
36
|
<Tooltip
|
|
38
37
|
arrow
|
|
39
38
|
enterDelay={1000}
|
|
@@ -9,7 +9,6 @@ interface Props {}
|
|
|
9
9
|
|
|
10
10
|
export const MRT_TableContainer: FC<Props> = () => {
|
|
11
11
|
const {
|
|
12
|
-
fullScreen,
|
|
13
12
|
hideToolbarBottom,
|
|
14
13
|
hideToolbarTop,
|
|
15
14
|
isFetching,
|
|
@@ -17,6 +16,7 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
17
16
|
muiTableContainerProps,
|
|
18
17
|
tableInstance,
|
|
19
18
|
} = useMRT();
|
|
19
|
+
const fullScreen = tableInstance.state.fullScreen;
|
|
20
20
|
const originalBodyOverflowStyle = useRef<string | undefined>();
|
|
21
21
|
|
|
22
22
|
useEffect(() => {
|
|
@@ -13,7 +13,6 @@ export const MRT_ToolbarBottom: FC<Props> = () => {
|
|
|
13
13
|
manualPagination,
|
|
14
14
|
muiTableToolbarBottomProps,
|
|
15
15
|
positionPagination,
|
|
16
|
-
fullScreen,
|
|
17
16
|
positionToolbarActions,
|
|
18
17
|
positionToolbarAlertBanner,
|
|
19
18
|
tableInstance,
|
|
@@ -35,12 +34,12 @@ export const MRT_ToolbarBottom: FC<Props> = () => {
|
|
|
35
34
|
theme.palette.common.white,
|
|
36
35
|
0.05,
|
|
37
36
|
)},${alpha(theme.palette.common.white, 0.05)})`,
|
|
38
|
-
bottom: fullScreen ? '0' : undefined,
|
|
37
|
+
bottom: tableInstance.state.fullScreen ? '0' : undefined,
|
|
39
38
|
display: 'flex',
|
|
40
39
|
justifyContent: 'space-between',
|
|
41
40
|
overflowY: 'hidden',
|
|
42
41
|
p: '0 0.5rem !important',
|
|
43
|
-
position: fullScreen ? 'fixed' : undefined,
|
|
42
|
+
position: tableInstance.state.fullScreen ? 'fixed' : undefined,
|
|
44
43
|
width: 'calc(100% - 1rem)',
|
|
45
44
|
zIndex: 1,
|
|
46
45
|
...toolbarProps?.sx,
|
|
@@ -16,7 +16,6 @@ export const MRT_ToolbarTop: FC<Props> = () => {
|
|
|
16
16
|
muiTableToolbarTopProps,
|
|
17
17
|
positionPagination,
|
|
18
18
|
positionToolbarActions,
|
|
19
|
-
fullScreen,
|
|
20
19
|
positionToolbarAlertBanner,
|
|
21
20
|
renderToolbarCustomActions,
|
|
22
21
|
tableInstance,
|
|
@@ -40,8 +39,8 @@ export const MRT_ToolbarTop: FC<Props> = () => {
|
|
|
40
39
|
)},${alpha(theme.palette.common.white, 0.05)})`,
|
|
41
40
|
display: 'grid',
|
|
42
41
|
p: '0 !important',
|
|
43
|
-
position: fullScreen ? 'sticky' : undefined,
|
|
44
|
-
top: fullScreen ? '0' : undefined,
|
|
42
|
+
position: tableInstance.state.fullScreen ? 'sticky' : undefined,
|
|
43
|
+
top: tableInstance.state.fullScreen ? '0' : undefined,
|
|
45
44
|
width: '100%',
|
|
46
45
|
zIndex: 1,
|
|
47
46
|
...toolbarProps?.sx,
|
package/src/useMRT.tsx
CHANGED
|
@@ -27,9 +27,6 @@ import { MaterialReactTableProps } from './MaterialReactTable';
|
|
|
27
27
|
export type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
|
|
28
28
|
anyRowsCanExpand: boolean;
|
|
29
29
|
anyRowsExpanded: boolean;
|
|
30
|
-
currentEditingRow: MRT_Row<D> | null;
|
|
31
|
-
densePadding: boolean;
|
|
32
|
-
fullScreen: boolean;
|
|
33
30
|
icons: MRT_Icons;
|
|
34
31
|
localization: MRT_Localization;
|
|
35
32
|
setCurrentEditingRow: (currentRowEditingId: MRT_Row<D> | null) => void;
|
|
@@ -37,8 +34,6 @@ export type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
|
|
|
37
34
|
setFullScreen: (fullScreen: boolean) => void;
|
|
38
35
|
setShowFilters: (showFilters: boolean) => void;
|
|
39
36
|
setShowSearch: (showSearch: boolean) => void;
|
|
40
|
-
showFilters: boolean;
|
|
41
|
-
showSearch: boolean;
|
|
42
37
|
tableInstance: MRT_TableInstance<D>;
|
|
43
38
|
};
|
|
44
39
|
|
|
@@ -61,18 +56,6 @@ export const MaterialReactTableProvider = <D extends {}>(
|
|
|
61
56
|
if (props.enableColumnResizing)
|
|
62
57
|
hooks.unshift(useResizeColumns, useFlexLayout);
|
|
63
58
|
|
|
64
|
-
const tableInstance = useTable<D>(props, ...hooks) as MRT_TableInstance<D>;
|
|
65
|
-
|
|
66
|
-
const anyRowsCanExpand = useMemo(
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
() => tableInstance.rows.some((row: MRT_Row) => row.canExpand),
|
|
69
|
-
[tableInstance.rows],
|
|
70
|
-
);
|
|
71
|
-
const anyRowsExpanded = useMemo(
|
|
72
|
-
// @ts-ignore
|
|
73
|
-
() => tableInstance.rows.some((row: MRT_Row) => row.isExpanded),
|
|
74
|
-
[tableInstance.rows],
|
|
75
|
-
);
|
|
76
59
|
const [currentEditingRow, setCurrentEditingRow] = useState<MRT_Row | null>(
|
|
77
60
|
null,
|
|
78
61
|
);
|
|
@@ -86,7 +69,44 @@ export const MaterialReactTableProvider = <D extends {}>(
|
|
|
86
69
|
props.initialState?.showFilters ?? false,
|
|
87
70
|
);
|
|
88
71
|
const [showSearch, setShowSearch] = useState(
|
|
89
|
-
props.initialState?.
|
|
72
|
+
props.initialState?.showSearch ?? false,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const tableInstance = useTable<D>(
|
|
76
|
+
{
|
|
77
|
+
...props,
|
|
78
|
+
useControlledState: (state) =>
|
|
79
|
+
useMemo(
|
|
80
|
+
() => ({
|
|
81
|
+
...state,
|
|
82
|
+
currentEditingRow,
|
|
83
|
+
densePadding,
|
|
84
|
+
fullScreen,
|
|
85
|
+
showFilters,
|
|
86
|
+
showSearch,
|
|
87
|
+
//@ts-ignore
|
|
88
|
+
...props?.useControlledState?.(state),
|
|
89
|
+
}),
|
|
90
|
+
[
|
|
91
|
+
currentEditingRow,
|
|
92
|
+
densePadding,
|
|
93
|
+
fullScreen,
|
|
94
|
+
showFilters,
|
|
95
|
+
showSearch,
|
|
96
|
+
state,
|
|
97
|
+
],
|
|
98
|
+
),
|
|
99
|
+
},
|
|
100
|
+
...hooks,
|
|
101
|
+
) as MRT_TableInstance<D>;
|
|
102
|
+
|
|
103
|
+
const anyRowsCanExpand = useMemo(
|
|
104
|
+
() => tableInstance.rows.some((row) => row.canExpand),
|
|
105
|
+
[tableInstance.rows],
|
|
106
|
+
);
|
|
107
|
+
const anyRowsExpanded = useMemo(
|
|
108
|
+
() => tableInstance.rows.some((row) => row.isExpanded),
|
|
109
|
+
[tableInstance.rows],
|
|
90
110
|
);
|
|
91
111
|
|
|
92
112
|
return (
|
|
@@ -95,16 +115,11 @@ export const MaterialReactTableProvider = <D extends {}>(
|
|
|
95
115
|
...props,
|
|
96
116
|
anyRowsCanExpand,
|
|
97
117
|
anyRowsExpanded,
|
|
98
|
-
currentEditingRow,
|
|
99
|
-
densePadding,
|
|
100
118
|
setCurrentEditingRow,
|
|
101
119
|
setDensePadding,
|
|
102
|
-
fullScreen,
|
|
103
120
|
setFullScreen,
|
|
104
121
|
setShowFilters,
|
|
105
122
|
setShowSearch,
|
|
106
|
-
showFilters,
|
|
107
|
-
showSearch,
|
|
108
123
|
//@ts-ignore
|
|
109
124
|
tableInstance,
|
|
110
125
|
}}
|