material-react-table 0.5.0 → 0.5.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/dist/MaterialReactTable.d.ts +10 -9
- package/dist/material-react-table.cjs.development.js +93 -81
- 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 +94 -82
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/useMRT.d.ts +0 -5
- package/package.json +2 -2
- package/src/@types/react-table-config.d.ts +3 -3
- package/src/MaterialReactTable.tsx +16 -9
- package/src/body/MRT_TableBody.tsx +7 -2
- 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_TableFooter.tsx +6 -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_Table.tsx +7 -2
- package/src/table/MRT_TableContainer.tsx +19 -5
- 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.3",
|
|
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.",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"storybook-dark-mode": "^1.0.9",
|
|
90
90
|
"tsdx": "^0.14.1",
|
|
91
91
|
"tslib": "^2.3.1",
|
|
92
|
-
"typescript": "^4.
|
|
92
|
+
"typescript": "^4.6.2"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
95
|
"@emotion/react": ">=11",
|
|
@@ -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> &
|
|
@@ -238,18 +239,22 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
238
239
|
muiTableBodyCellProps?:
|
|
239
240
|
| TableCellProps
|
|
240
241
|
| ((cell?: MRT_Cell<D>) => TableCellProps);
|
|
241
|
-
muiTableBodyProps?:
|
|
242
|
+
muiTableBodyProps?:
|
|
243
|
+
| TableBodyProps
|
|
244
|
+
| ((tableInstance: MRT_TableInstance<D>) => TableBodyProps);
|
|
242
245
|
muiTableBodyRowProps?: TableRowProps | ((row: Row<D>) => TableRowProps);
|
|
243
246
|
muiTableContainerProps?:
|
|
244
247
|
| TableContainerProps
|
|
245
|
-
| ((
|
|
248
|
+
| ((tableInstance: MRT_TableInstance<D>) => TableContainerProps);
|
|
246
249
|
muiTableDetailPanelProps?:
|
|
247
250
|
| TableCellProps
|
|
248
251
|
| ((row: Row<D>) => TableCellProps);
|
|
249
252
|
muiTableFooterCellProps?:
|
|
250
253
|
| TableCellProps
|
|
251
254
|
| ((column: Column<D>) => TableCellProps);
|
|
252
|
-
muiTableFooterProps?:
|
|
255
|
+
muiTableFooterProps?:
|
|
256
|
+
| TableFooterProps
|
|
257
|
+
| ((tableInstance: MRT_TableInstance<D>) => TableFooterProps);
|
|
253
258
|
muiTableFooterRowProps?:
|
|
254
259
|
| TableRowProps
|
|
255
260
|
| ((footerGroup: MRT_HeaderGroup<D>) => TableRowProps);
|
|
@@ -259,7 +264,9 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
259
264
|
muiTableHeadCellProps?:
|
|
260
265
|
| TableCellProps
|
|
261
266
|
| ((column: Column<D>) => TableCellProps);
|
|
262
|
-
muiTableHeadProps?:
|
|
267
|
+
muiTableHeadProps?:
|
|
268
|
+
| TableHeadProps
|
|
269
|
+
| ((tableInstance: MRT_TableInstance<D>) => TableHeadProps);
|
|
263
270
|
muiTableHeadRowProps?:
|
|
264
271
|
| TableRowProps
|
|
265
272
|
| ((row: MRT_HeaderGroup<D>) => TableRowProps);
|
|
@@ -268,7 +275,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
268
275
|
| ((
|
|
269
276
|
tableInstance: MRT_TableInstance<D>,
|
|
270
277
|
) => Partial<TablePaginationProps>);
|
|
271
|
-
muiTableProps?: TableProps;
|
|
278
|
+
muiTableProps?: TableProps | ((tableInstance: MRT_TableInstance<D>) => TableProps);
|
|
272
279
|
muiTableToolbarAlertBannerProps?:
|
|
273
280
|
| AlertProps
|
|
274
281
|
| ((tableInstance: MRT_TableInstance<D>) => AlertProps);
|
|
@@ -11,12 +11,17 @@ export const MRT_TableBody: FC<Props> = () => {
|
|
|
11
11
|
|
|
12
12
|
const rows = manualPagination ? tableInstance.rows : tableInstance.page;
|
|
13
13
|
|
|
14
|
+
const mTableBodyProps =
|
|
15
|
+
muiTableBodyProps instanceof Function
|
|
16
|
+
? muiTableBodyProps(tableInstance)
|
|
17
|
+
: muiTableBodyProps;
|
|
18
|
+
|
|
14
19
|
const tableBodyProps = {
|
|
15
|
-
...
|
|
20
|
+
...mTableBodyProps,
|
|
16
21
|
...tableInstance.getTableBodyProps(),
|
|
17
22
|
style: {
|
|
18
23
|
...tableInstance.getTableBodyProps().style,
|
|
19
|
-
...
|
|
24
|
+
...mTableBodyProps?.style,
|
|
20
25
|
},
|
|
21
26
|
};
|
|
22
27
|
|
|
@@ -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}
|
|
@@ -9,8 +9,13 @@ interface Props {}
|
|
|
9
9
|
export const MRT_TableFooter: FC<Props> = () => {
|
|
10
10
|
const { muiTableFooterProps, tableInstance } = useMRT();
|
|
11
11
|
|
|
12
|
+
const tableFooterProps =
|
|
13
|
+
muiTableFooterProps instanceof Function
|
|
14
|
+
? muiTableFooterProps(tableInstance)
|
|
15
|
+
: muiTableFooterProps;
|
|
16
|
+
|
|
12
17
|
return (
|
|
13
|
-
<TableFooter {...
|
|
18
|
+
<TableFooter {...tableFooterProps}>
|
|
14
19
|
{tableInstance.footerGroups.map((footerGroup: MRT_HeaderGroup) => (
|
|
15
20
|
<MRT_TableFooterRow
|
|
16
21
|
key={footerGroup.getFooterGroupProps().key}
|
|
@@ -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}
|
package/src/table/MRT_Table.tsx
CHANGED
|
@@ -11,12 +11,17 @@ export const MRT_Table: FC<Props> = () => {
|
|
|
11
11
|
const { tableInstance, muiTableProps, hideTableHead, hideTableFooter } =
|
|
12
12
|
useMRT();
|
|
13
13
|
|
|
14
|
+
const mTableProps =
|
|
15
|
+
muiTableProps instanceof Function
|
|
16
|
+
? muiTableProps(tableInstance)
|
|
17
|
+
: muiTableProps;
|
|
18
|
+
|
|
14
19
|
const tableProps = {
|
|
15
|
-
...
|
|
20
|
+
...mTableProps,
|
|
16
21
|
...tableInstance.getTableProps(),
|
|
17
22
|
style: {
|
|
18
23
|
...tableInstance.getTableProps().style,
|
|
19
|
-
...
|
|
24
|
+
...mTableProps?.style,
|
|
20
25
|
},
|
|
21
26
|
};
|
|
22
27
|
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import React, { FC, useEffect, useRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
LinearProgress,
|
|
4
|
+
Paper,
|
|
5
|
+
TableContainer,
|
|
6
|
+
Collapse,
|
|
7
|
+
Box,
|
|
8
|
+
} from '@mui/material';
|
|
3
9
|
import { useMRT } from '../useMRT';
|
|
4
10
|
import { MRT_Table } from './MRT_Table';
|
|
5
11
|
import { MRT_ToolbarTop } from '../toolbar/MRT_ToolbarTop';
|
|
@@ -9,7 +15,6 @@ interface Props {}
|
|
|
9
15
|
|
|
10
16
|
export const MRT_TableContainer: FC<Props> = () => {
|
|
11
17
|
const {
|
|
12
|
-
fullScreen,
|
|
13
18
|
hideToolbarBottom,
|
|
14
19
|
hideToolbarTop,
|
|
15
20
|
isFetching,
|
|
@@ -17,6 +22,7 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
17
22
|
muiTableContainerProps,
|
|
18
23
|
tableInstance,
|
|
19
24
|
} = useMRT();
|
|
25
|
+
const fullScreen = tableInstance.state.fullScreen;
|
|
20
26
|
const originalBodyOverflowStyle = useRef<string | undefined>();
|
|
21
27
|
|
|
22
28
|
useEffect(() => {
|
|
@@ -29,8 +35,9 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
29
35
|
if (typeof window !== 'undefined') {
|
|
30
36
|
if (fullScreen) {
|
|
31
37
|
document.body.style.overflow = 'hidden';
|
|
32
|
-
} else
|
|
33
|
-
document.body.style.overflow =
|
|
38
|
+
} else {
|
|
39
|
+
document.body.style.overflow =
|
|
40
|
+
originalBodyOverflowStyle.current ?? 'auto';
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
}, [fullScreen]);
|
|
@@ -62,7 +69,14 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
62
69
|
<Collapse in={isFetching || isLoading} unmountOnExit>
|
|
63
70
|
<LinearProgress />
|
|
64
71
|
</Collapse>
|
|
65
|
-
<
|
|
72
|
+
<Box
|
|
73
|
+
sx={{
|
|
74
|
+
maxWidth: '100%',
|
|
75
|
+
overflowX: 'auto',
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<MRT_Table />
|
|
79
|
+
</Box>
|
|
66
80
|
{!hideToolbarBottom && <MRT_ToolbarBottom />}
|
|
67
81
|
</TableContainer>
|
|
68
82
|
);
|
|
@@ -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,
|