material-react-table 0.3.3 → 0.4.1
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 +15 -7
- package/dist/body/MRT_TableBodyCell.d.ts +3 -0
- package/dist/buttons/MRT_FullScreenToggleButton.d.ts +4 -0
- package/dist/buttons/MRT_ToggleSearchButton.d.ts +4 -0
- package/dist/head/MRT_TableHeadCell.d.ts +1 -1
- package/dist/head/MRT_TableHeadCellActions.d.ts +5 -0
- package/dist/inputs/{MRT_EditCellTextfield.d.ts → MRT_EditCellTextField.d.ts} +1 -1
- package/dist/inputs/MRT_FilterTextField.d.ts +1 -1
- package/dist/material-react-table.cjs.development.js +604 -372
- 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 +607 -375
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +2 -2
- package/dist/menus/MRT_RowActionMenu.d.ts +1 -0
- package/dist/table/MRT_TableButtonCell.d.ts +3 -0
- package/dist/toolbar/MRT_ToolbarAlertBanner.d.ts +5 -0
- package/dist/toolbar/MRT_ToolbarInternalButtons.d.ts +5 -0
- package/dist/{useMaterialReactTable.d.ts → useMRT.d.ts} +8 -3
- package/dist/utils/localization.d.ts +8 -0
- package/package.json +21 -19
- package/src/@types/react-table-config.d.ts +37 -34
- package/src/MaterialReactTable.tsx +22 -6
- package/src/body/MRT_TableBody.tsx +2 -3
- package/src/body/MRT_TableBodyCell.tsx +8 -8
- package/src/body/MRT_TableBodyRow.tsx +13 -15
- package/src/body/MRT_TableDetailPanel.tsx +2 -2
- package/src/buttons/MRT_EditActionButtons.tsx +3 -2
- package/src/buttons/MRT_ExpandAllButton.tsx +8 -16
- package/src/buttons/MRT_ExpandButton.tsx +8 -9
- package/src/buttons/MRT_FullScreenToggleButton.tsx +23 -0
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +34 -3
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +5 -5
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +48 -26
- package/src/buttons/MRT_ToggleSearchButton.tsx +33 -0
- package/src/footer/MRT_TableFooter.tsx +2 -2
- package/src/footer/MRT_TableFooterCell.tsx +2 -2
- package/src/footer/MRT_TableFooterRow.tsx +9 -4
- package/src/head/MRT_TableHead.tsx +2 -2
- package/src/head/MRT_TableHeadCell.tsx +20 -16
- package/src/head/MRT_TableHeadCellActions.tsx +18 -0
- package/src/head/MRT_TableHeadRow.tsx +16 -11
- package/src/inputs/MRT_DensePaddingSwitch.tsx +5 -3
- package/src/inputs/{MRT_EditCellTextfield.tsx → MRT_EditCellTextField.tsx} +23 -16
- package/src/inputs/MRT_FilterTextField.tsx +43 -17
- package/src/inputs/MRT_SearchTextField.tsx +39 -34
- package/src/inputs/MRT_SelectAllCheckbox.tsx +9 -13
- package/src/inputs/MRT_SelectCheckbox.tsx +11 -14
- package/src/menus/MRT_ColumnActionMenu.tsx +66 -23
- package/src/menus/MRT_RowActionMenu.tsx +4 -8
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +24 -15
- package/src/table/MRT_Table.tsx +2 -2
- package/src/table/MRT_TableButtonCell.tsx +9 -0
- package/src/table/MRT_TableContainer.tsx +34 -8
- package/src/table/MRT_TableSpacerCell.tsx +2 -2
- package/src/toolbar/MRT_TablePagination.tsx +3 -2
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +102 -0
- package/src/toolbar/MRT_ToolbarBottom.tsx +9 -5
- package/src/toolbar/{MRT_ToolbarButtons.tsx → MRT_ToolbarInternalButtons.tsx} +13 -4
- package/src/toolbar/MRT_ToolbarTop.tsx +14 -15
- package/src/{useMaterialReactTable.tsx → useMRT.tsx} +40 -23
- package/src/utils/localization.ts +22 -6
- package/dist/toolbar/MRT_ToolbarButtons.d.ts +0 -5
- package/dist/utils/useMRTCalcs.d.ts +0 -11
- package/src/utils/useMRTCalcs.tsx +0 -42
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { HeaderGroup } from 'react-table';
|
|
3
3
|
interface Props {
|
|
4
4
|
anchorEl: HTMLElement | null;
|
|
5
|
-
column:
|
|
5
|
+
column: HeaderGroup;
|
|
6
6
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
7
7
|
}
|
|
8
8
|
export declare const MRT_ColumnActionMenu: FC<Props>;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
2
|
import { Row, TableInstance } from 'react-table';
|
|
3
3
|
import { MaterialReactTableProps } from './MaterialReactTable';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export interface UseMRT<D extends {} = {}> extends MaterialReactTableProps<D> {
|
|
5
|
+
anyRowsCanExpand: boolean;
|
|
6
|
+
anyRowsExpanded: boolean;
|
|
6
7
|
currentEditingRow: Row<D> | null;
|
|
7
8
|
densePadding: boolean;
|
|
9
|
+
fullScreen: boolean;
|
|
8
10
|
setCurrentEditingRow: (currentRowEditingId: Row<D> | null) => void;
|
|
9
11
|
setDensePadding: (densePadding: boolean) => void;
|
|
12
|
+
setFullScreen: (fullScreen: boolean) => void;
|
|
10
13
|
setShowFilters: (showFilters: boolean) => void;
|
|
14
|
+
setShowSearch: (showSearch: boolean) => void;
|
|
11
15
|
showFilters: boolean;
|
|
16
|
+
showSearch: boolean;
|
|
12
17
|
tableInstance: TableInstance<D>;
|
|
13
18
|
}
|
|
14
19
|
export declare const MaterialReactTableProvider: <D extends {}>(props: React.PropsWithChildren<MaterialReactTableProps<D>>) => JSX.Element;
|
|
15
|
-
export declare const
|
|
20
|
+
export declare const useMRT: <D extends {}>() => UseMRT<D>;
|
|
@@ -7,6 +7,8 @@ export interface MRT_Localization {
|
|
|
7
7
|
columnActionMenuItemSortAsc: string;
|
|
8
8
|
columnActionMenuItemSortDesc: string;
|
|
9
9
|
columnActionMenuItemUnGroupBy: string;
|
|
10
|
+
columnShowHideMenuHideAll: string;
|
|
11
|
+
columnShowHideMenuShowAll: string;
|
|
10
12
|
expandAllButtonTitle: string;
|
|
11
13
|
expandButtonTitle: string;
|
|
12
14
|
filterTextFieldClearButtonTitle: string;
|
|
@@ -19,8 +21,14 @@ export interface MRT_Localization {
|
|
|
19
21
|
searchTextFieldClearButtonTitle: string;
|
|
20
22
|
searchTextFieldPlaceholder: string;
|
|
21
23
|
selectAllCheckboxTitle: string;
|
|
24
|
+
selectCheckboxTitle: string;
|
|
22
25
|
showHideColumnsButtonTitle: string;
|
|
23
26
|
toggleDensePaddingSwitchTitle: string;
|
|
24
27
|
toggleFilterButtonTitle: string;
|
|
28
|
+
toggleFullScreenButtonTitle: string;
|
|
29
|
+
toggleSearchButtonTitle: string;
|
|
30
|
+
toolbarAlertSelectionMessage: string;
|
|
31
|
+
toolbarAlertGroupedByMessage: string;
|
|
32
|
+
toolbarAlertGroupedThenByMessage: string;
|
|
25
33
|
}
|
|
26
34
|
export declare const defaultLocalization: MRT_Localization;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.4.1",
|
|
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.",
|
|
@@ -27,20 +27,21 @@
|
|
|
27
27
|
"node": ">=12"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
|
-
"
|
|
30
|
+
"analyze": "size-limit --why",
|
|
31
31
|
"build": "tsdx build && size-limit",
|
|
32
|
-
"
|
|
32
|
+
"build-storybook": "build-storybook",
|
|
33
|
+
"format": "prettier -w .",
|
|
33
34
|
"lint": "tsdx lint",
|
|
34
35
|
"prepare": "tsdx build",
|
|
35
36
|
"size": "size-limit",
|
|
36
|
-
"
|
|
37
|
+
"start": "tsdx watch",
|
|
37
38
|
"storybook": "start-storybook -p 6006",
|
|
38
|
-
"
|
|
39
|
+
"test": "tsdx test --passWithNoTests",
|
|
39
40
|
"upgrade": "ncu -u && npm i"
|
|
40
41
|
},
|
|
41
42
|
"husky": {
|
|
42
43
|
"hooks": {
|
|
43
|
-
"pre-commit": "tsdx lint"
|
|
44
|
+
"pre-commit": "tsdx lint && format"
|
|
44
45
|
}
|
|
45
46
|
},
|
|
46
47
|
"module": "dist/material-react-table.esm.js",
|
|
@@ -55,23 +56,23 @@
|
|
|
55
56
|
}
|
|
56
57
|
],
|
|
57
58
|
"devDependencies": {
|
|
58
|
-
"@babel/core": "^7.17.
|
|
59
|
+
"@babel/core": "^7.17.4",
|
|
59
60
|
"@emotion/react": "^11.7.1",
|
|
60
61
|
"@emotion/styled": "^11.6.0",
|
|
61
62
|
"@etchteam/storybook-addon-status": "^4.2.0",
|
|
62
|
-
"@faker-js/faker": "^6.0.0-alpha.
|
|
63
|
-
"@mui/icons-material": "^5.
|
|
64
|
-
"@mui/material": "^5.4.
|
|
65
|
-
"@size-limit/preset-small-lib": "^7.0.
|
|
66
|
-
"@storybook/addon-a11y": "^6.4.
|
|
67
|
-
"@storybook/addon-actions": "^6.4.
|
|
63
|
+
"@faker-js/faker": "^6.0.0-alpha.6",
|
|
64
|
+
"@mui/icons-material": "^5.4.2",
|
|
65
|
+
"@mui/material": "^5.4.2",
|
|
66
|
+
"@size-limit/preset-small-lib": "^7.0.8",
|
|
67
|
+
"@storybook/addon-a11y": "^6.4.19",
|
|
68
|
+
"@storybook/addon-actions": "^6.4.19",
|
|
68
69
|
"@storybook/addon-console": "^1.2.3",
|
|
69
|
-
"@storybook/addon-essentials": "^6.4.
|
|
70
|
+
"@storybook/addon-essentials": "^6.4.19",
|
|
70
71
|
"@storybook/addon-info": "^5.3.21",
|
|
71
|
-
"@storybook/addon-links": "^6.4.
|
|
72
|
-
"@storybook/addon-storysource": "^6.4.
|
|
73
|
-
"@storybook/addons": "^6.4.
|
|
74
|
-
"@storybook/react": "^6.4.
|
|
72
|
+
"@storybook/addon-links": "^6.4.19",
|
|
73
|
+
"@storybook/addon-storysource": "^6.4.19",
|
|
74
|
+
"@storybook/addons": "^6.4.19",
|
|
75
|
+
"@storybook/react": "^6.4.19",
|
|
75
76
|
"@types/faker": "^6.6.8",
|
|
76
77
|
"@types/react": "^17.0.39",
|
|
77
78
|
"@types/react-dom": "^17.0.11",
|
|
@@ -83,7 +84,8 @@
|
|
|
83
84
|
"react-dom": "^17.0.2",
|
|
84
85
|
"react-is": "^17.0.2",
|
|
85
86
|
"react-table": "^7.7.0",
|
|
86
|
-
"size-limit": "^7.0.
|
|
87
|
+
"size-limit": "^7.0.8",
|
|
88
|
+
"storybook-addon-paddings": "^4.2.1",
|
|
87
89
|
"storybook-addon-performance": "^0.16.1",
|
|
88
90
|
"storybook-dark-mode": "^1.0.8",
|
|
89
91
|
"tsdx": "^0.14.1",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ChangeEvent, ReactNode } from 'react';
|
|
1
2
|
import { TableCellProps, TextFieldProps } from '@mui/material';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
3
|
import {
|
|
4
4
|
UseColumnOrderInstanceProps,
|
|
5
5
|
UseColumnOrderState,
|
|
@@ -50,6 +50,41 @@ import {
|
|
|
50
50
|
UseSortByState,
|
|
51
51
|
} from 'react-table';
|
|
52
52
|
|
|
53
|
+
export type MRT_ColumnInterface<D extends {} = {}> =
|
|
54
|
+
UseFiltersColumnOptions<D> &
|
|
55
|
+
UseGlobalFiltersColumnOptions<D> &
|
|
56
|
+
UseGroupByColumnOptions<D> &
|
|
57
|
+
UseResizeColumnsColumnOptions<D> &
|
|
58
|
+
UseSortByColumnOptions<D> & {
|
|
59
|
+
disableFilters?: boolean;
|
|
60
|
+
Filter?: ({ column }: { column: HeaderGroup<D> }) => ReactNode;
|
|
61
|
+
editable?: boolean;
|
|
62
|
+
Edit?: ({ cell, onChange }: { cell: Cell<D> }) => ReactNode;
|
|
63
|
+
muiTableBodyCellProps?:
|
|
64
|
+
| TableCellProps
|
|
65
|
+
| ((cell: Cell<D>) => TableCellProps);
|
|
66
|
+
muiTableHeadCellProps?:
|
|
67
|
+
| TableCellProps
|
|
68
|
+
| ((column: Column<D>) => TableCellProps);
|
|
69
|
+
muiTableFooterCellProps?:
|
|
70
|
+
| TableCellProps
|
|
71
|
+
| ((column: Column<D>) => TableCellProps);
|
|
72
|
+
muiTableBodyCellEditTextFieldProps?:
|
|
73
|
+
| TextFieldProps
|
|
74
|
+
| ((cell: Cell<D>) => TextFieldProps);
|
|
75
|
+
muiTableHeadCellFilterTextFieldProps?:
|
|
76
|
+
| TextFieldProps
|
|
77
|
+
| ((column: Column<D>) => TextFieldProps);
|
|
78
|
+
onCellEditChange?: (
|
|
79
|
+
event: ChangeEvent<HTMLInputElement>,
|
|
80
|
+
cell: Cell<D>,
|
|
81
|
+
) => void;
|
|
82
|
+
onFilterChange?: (
|
|
83
|
+
event: ChangeEvent<HTMLInputElement>,
|
|
84
|
+
filterValue: any,
|
|
85
|
+
) => void;
|
|
86
|
+
};
|
|
87
|
+
|
|
53
88
|
declare module 'react-table' {
|
|
54
89
|
export interface TableOptions<D extends Record<string, unknown>>
|
|
55
90
|
extends UseExpandedOptions<D>,
|
|
@@ -97,37 +132,7 @@ declare module 'react-table' {
|
|
|
97
132
|
|
|
98
133
|
export interface ColumnInterface<
|
|
99
134
|
D extends Record<string, unknown> = Record<string, unknown>,
|
|
100
|
-
> extends
|
|
101
|
-
UseGlobalFiltersColumnOptions<D>,
|
|
102
|
-
UseGroupByColumnOptions<D>,
|
|
103
|
-
UseResizeColumnsColumnOptions<D>,
|
|
104
|
-
UseSortByColumnOptions<D> {
|
|
105
|
-
disableFilters?: boolean;
|
|
106
|
-
Filter?: ({ column }: { column: HeaderGroup<D> }) => ReactNode;
|
|
107
|
-
editable?: boolean;
|
|
108
|
-
Edit?: ({
|
|
109
|
-
cell,
|
|
110
|
-
onChange,
|
|
111
|
-
}: {
|
|
112
|
-
cell: Cell<D>;
|
|
113
|
-
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
114
|
-
}) => ReactNode;
|
|
115
|
-
muiTableBodyCellProps?:
|
|
116
|
-
| TableCellProps
|
|
117
|
-
| ((cell?: Cell<D>) => TableCellProps);
|
|
118
|
-
muiTableHeadCellProps?:
|
|
119
|
-
| TableCellProps
|
|
120
|
-
| ((column: Column<D>) => TableCellProps);
|
|
121
|
-
muiTableFooterCellProps?:
|
|
122
|
-
| TableCellProps
|
|
123
|
-
| ((column: Column<D>) => TableCellProps);
|
|
124
|
-
muiTableBodyCellEditTextFieldProps?:
|
|
125
|
-
| TextFieldProps
|
|
126
|
-
| ((cell?: Cell<D>) => TextFieldProps);
|
|
127
|
-
muiTableHeadCellFilterTextFieldProps?:
|
|
128
|
-
| TextFieldProps
|
|
129
|
-
| ((column: Column<D>) => TextFieldProps);
|
|
130
|
-
}
|
|
135
|
+
> extends MRT_ColumnInterface {}
|
|
131
136
|
|
|
132
137
|
export interface ColumnInstance<
|
|
133
138
|
D extends Record<string, unknown> = Record<string, unknown>,
|
|
@@ -149,5 +154,3 @@ declare module 'react-table' {
|
|
|
149
154
|
UseRowSelectRowProps<D>,
|
|
150
155
|
UseRowStateRowProps<D> {}
|
|
151
156
|
}
|
|
152
|
-
|
|
153
|
-
export module 'react-table';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { ChangeEvent, MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import {
|
|
3
|
+
AlertProps,
|
|
3
4
|
TableBodyProps,
|
|
4
5
|
TableCellProps,
|
|
5
6
|
TableContainerProps,
|
|
@@ -10,7 +11,6 @@ import {
|
|
|
10
11
|
TableRowProps,
|
|
11
12
|
TextFieldProps,
|
|
12
13
|
ToolbarProps,
|
|
13
|
-
TypographyProps,
|
|
14
14
|
} from '@mui/material';
|
|
15
15
|
import {
|
|
16
16
|
Cell,
|
|
@@ -28,12 +28,15 @@ import {
|
|
|
28
28
|
UseRowSelectOptions,
|
|
29
29
|
UseRowStateOptions,
|
|
30
30
|
UseSortByOptions,
|
|
31
|
+
UseTableOptions,
|
|
31
32
|
} from 'react-table';
|
|
32
|
-
import { MaterialReactTableProvider } from './
|
|
33
|
+
import { MaterialReactTableProvider } from './useMRT';
|
|
33
34
|
import { MRT_TableContainer } from './table/MRT_TableContainer';
|
|
34
35
|
import { defaultLocalization, MRT_Localization } from './utils/localization';
|
|
36
|
+
import { MRT_ColumnInterface } from './@types/react-table-config';
|
|
35
37
|
|
|
36
38
|
export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
39
|
+
UseTableOptions<D> &
|
|
37
40
|
UseExpandedOptions<D> &
|
|
38
41
|
UseFiltersOptions<D> &
|
|
39
42
|
UseGlobalFiltersOptions<D> &
|
|
@@ -43,14 +46,19 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
43
46
|
UseRowSelectOptions<D> &
|
|
44
47
|
UseRowStateOptions<D> &
|
|
45
48
|
UseSortByOptions<D> & {
|
|
49
|
+
columns: (Column<D> & MRT_ColumnInterface)[];
|
|
46
50
|
defaultDensePadding?: boolean;
|
|
51
|
+
defaultFullScreen?: boolean;
|
|
47
52
|
defaultShowFilters?: boolean;
|
|
53
|
+
defaultShowSearchTextField?: boolean;
|
|
48
54
|
disableColumnActions?: boolean;
|
|
49
55
|
disableColumnHiding?: boolean;
|
|
50
56
|
disableDensePaddingToggle?: boolean;
|
|
51
57
|
disableExpandAll?: boolean;
|
|
58
|
+
disableFullScreenToggle?: boolean;
|
|
52
59
|
disableSelectAll?: boolean;
|
|
53
60
|
disableSubRowTree?: boolean;
|
|
61
|
+
enableRowNumbers?: boolean;
|
|
54
62
|
enableColumnGrouping?: boolean;
|
|
55
63
|
enableColumnResizing?: boolean;
|
|
56
64
|
enableRowActions?: boolean;
|
|
@@ -73,7 +81,9 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
73
81
|
| ((cell?: Cell<D>) => TableCellProps);
|
|
74
82
|
muiTableBodyProps?: TableBodyProps;
|
|
75
83
|
muiTableBodyRowProps?: TableRowProps | ((row: Row<D>) => TableRowProps);
|
|
76
|
-
muiTableContainerProps?:
|
|
84
|
+
muiTableContainerProps?:
|
|
85
|
+
| TableContainerProps
|
|
86
|
+
| ((table: TableInstance<D>) => TableContainerProps);
|
|
77
87
|
muiTableDetailPanelProps?:
|
|
78
88
|
| TableCellProps
|
|
79
89
|
| ((row: Row<D>) => TableCellProps);
|
|
@@ -98,7 +108,9 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
98
108
|
| Partial<TablePaginationProps>
|
|
99
109
|
| ((tableInstance: TableInstance<D>) => Partial<TablePaginationProps>);
|
|
100
110
|
muiTableProps?: TableProps;
|
|
101
|
-
|
|
111
|
+
muiTableToolbarAlertBannerProps?:
|
|
112
|
+
| AlertProps
|
|
113
|
+
| ((tableInstance: TableInstance<D>) => AlertProps);
|
|
102
114
|
muiTableToolbarBottomProps?:
|
|
103
115
|
| ToolbarProps
|
|
104
116
|
| ((tableInstance: TableInstance<D>) => ToolbarProps);
|
|
@@ -109,6 +121,7 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
109
121
|
event: MouseEvent<HTMLTableCellElement>,
|
|
110
122
|
cell: Cell<D>,
|
|
111
123
|
) => void;
|
|
124
|
+
onColumnHide?: (column: Column<D>, visibleColumns: Column<D>[]) => void;
|
|
112
125
|
onDetailPanelClick?: (
|
|
113
126
|
event: MouseEvent<HTMLTableCellElement>,
|
|
114
127
|
row: Row<D>,
|
|
@@ -128,6 +141,7 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
128
141
|
positionActionsColumn?: 'first' | 'last';
|
|
129
142
|
positionPagination?: 'bottom' | 'top' | 'both';
|
|
130
143
|
positionToolbarActions?: 'bottom' | 'top';
|
|
144
|
+
positionToolbarAlertBanner?: 'bottom' | 'top';
|
|
131
145
|
renderDetailPanel?: (row: Row<D>) => ReactNode;
|
|
132
146
|
renderRowActionMenuItems?: (
|
|
133
147
|
rowData: Row<D>,
|
|
@@ -138,7 +152,7 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
138
152
|
row: Row<D>,
|
|
139
153
|
tableInstance: TableInstance<D>,
|
|
140
154
|
) => ReactNode;
|
|
141
|
-
|
|
155
|
+
renderToolbarCustomActions?: (tableInstance: TableInstance<D>) => ReactNode;
|
|
142
156
|
};
|
|
143
157
|
|
|
144
158
|
export default <D extends {}>({
|
|
@@ -147,14 +161,16 @@ export default <D extends {}>({
|
|
|
147
161
|
positionActionsColumn = 'first',
|
|
148
162
|
positionPagination = 'bottom',
|
|
149
163
|
positionToolbarActions = 'top',
|
|
164
|
+
positionToolbarAlertBanner = 'top',
|
|
150
165
|
...rest
|
|
151
166
|
}: MaterialReactTableProps<D>) => (
|
|
152
167
|
<MaterialReactTableProvider
|
|
153
168
|
defaultColumn={defaultColumn}
|
|
154
169
|
localization={{ ...defaultLocalization, ...localization }}
|
|
155
|
-
positionPagination={positionPagination}
|
|
156
170
|
positionActionsColumn={positionActionsColumn}
|
|
171
|
+
positionPagination={positionPagination}
|
|
157
172
|
positionToolbarActions={positionToolbarActions}
|
|
173
|
+
positionToolbarAlertBanner={positionToolbarAlertBanner}
|
|
158
174
|
{...rest}
|
|
159
175
|
>
|
|
160
176
|
<MRT_TableContainer />
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { styled, TableBody as MuiTableBody } from '@mui/material';
|
|
3
3
|
import { MRT_TableBodyRow } from './MRT_TableBodyRow';
|
|
4
|
-
import {
|
|
4
|
+
import { useMRT } from '../useMRT';
|
|
5
5
|
|
|
6
6
|
const TableBody = styled(MuiTableBody)({
|
|
7
7
|
overflowY: 'hidden',
|
|
@@ -10,8 +10,7 @@ const TableBody = styled(MuiTableBody)({
|
|
|
10
10
|
interface Props {}
|
|
11
11
|
|
|
12
12
|
export const MRT_TableBody: FC<Props> = () => {
|
|
13
|
-
const { tableInstance, muiTableBodyProps, manualPagination } =
|
|
14
|
-
useMaterialReactTable();
|
|
13
|
+
const { tableInstance, muiTableBodyProps, manualPagination } = useMRT();
|
|
15
14
|
|
|
16
15
|
const rows = manualPagination ? tableInstance.rows : tableInstance.page;
|
|
17
16
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { styled, TableCell as MuiTableCell } from '@mui/material';
|
|
3
3
|
import { Cell } from 'react-table';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { useMRT } from '../useMRT';
|
|
5
|
+
import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
export const MRT_StyledTableBodyCell = styled(MuiTableCell, {
|
|
8
8
|
shouldForwardProp: (prop) => prop !== 'densePadding',
|
|
9
9
|
})<{ densePadding?: boolean }>(({ densePadding }) => ({
|
|
10
10
|
padding: densePadding ? '0.5rem' : '1rem',
|
|
11
11
|
transition: 'all 0.2s ease-in-out',
|
|
12
|
+
whiteSpace: densePadding ? 'nowrap' : 'normal',
|
|
12
13
|
}));
|
|
13
14
|
|
|
14
15
|
interface Props {
|
|
@@ -21,7 +22,7 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
21
22
|
muiTableBodyCellProps,
|
|
22
23
|
densePadding,
|
|
23
24
|
currentEditingRow,
|
|
24
|
-
} =
|
|
25
|
+
} = useMRT();
|
|
25
26
|
|
|
26
27
|
const mTableCellBodyProps =
|
|
27
28
|
muiTableBodyCellProps instanceof Function
|
|
@@ -45,7 +46,7 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
return (
|
|
48
|
-
<
|
|
49
|
+
<MRT_StyledTableBodyCell
|
|
49
50
|
densePadding={densePadding}
|
|
50
51
|
onClick={(event: MouseEvent<HTMLTableCellElement>) =>
|
|
51
52
|
onCellClick?.(event, cell)
|
|
@@ -53,7 +54,7 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
53
54
|
{...tableCellProps}
|
|
54
55
|
>
|
|
55
56
|
{currentEditingRow?.id === cell.row.id ? (
|
|
56
|
-
<
|
|
57
|
+
<MRT_EditCellTextField cell={cell} />
|
|
57
58
|
) : cell.isPlaceholder ? null : cell.isAggregated ? (
|
|
58
59
|
cell.render('Aggregated')
|
|
59
60
|
) : cell.isGrouped ? (
|
|
@@ -63,7 +64,6 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
63
64
|
) : (
|
|
64
65
|
cell.render('Cell')
|
|
65
66
|
)}
|
|
66
|
-
|
|
67
|
-
</TableCell>
|
|
67
|
+
</MRT_StyledTableBodyCell>
|
|
68
68
|
);
|
|
69
69
|
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
alpha,
|
|
4
|
-
styled,
|
|
5
|
-
TableCell,
|
|
6
|
-
TableRow as MuiTableRow,
|
|
7
|
-
} from '@mui/material';
|
|
2
|
+
import { alpha, styled, TableRow as MuiTableRow } from '@mui/material';
|
|
8
3
|
import { Row } from 'react-table';
|
|
9
|
-
import {
|
|
10
|
-
|
|
4
|
+
import {
|
|
5
|
+
MRT_StyledTableBodyCell,
|
|
6
|
+
MRT_TableBodyCell,
|
|
7
|
+
} from './MRT_TableBodyCell';
|
|
8
|
+
import { useMRT } from '../useMRT';
|
|
11
9
|
import { MRT_TableDetailPanel } from './MRT_TableDetailPanel';
|
|
12
10
|
import { MRT_ExpandButton } from '../buttons/MRT_ExpandButton';
|
|
13
11
|
import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
|
@@ -29,12 +27,13 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
29
27
|
const {
|
|
30
28
|
anyRowsCanExpand,
|
|
31
29
|
enableRowActions,
|
|
30
|
+
enableRowNumbers,
|
|
32
31
|
enableSelection,
|
|
33
32
|
muiTableBodyRowProps,
|
|
34
33
|
onRowClick,
|
|
35
34
|
positionActionsColumn,
|
|
36
35
|
renderDetailPanel,
|
|
37
|
-
} =
|
|
36
|
+
} = useMRT();
|
|
38
37
|
|
|
39
38
|
const mTableBodyRowProps =
|
|
40
39
|
muiTableBodyRowProps instanceof Function
|
|
@@ -60,10 +59,11 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
60
59
|
}
|
|
61
60
|
{...tableRowProps}
|
|
62
61
|
>
|
|
62
|
+
{enableRowNumbers && (
|
|
63
|
+
<MRT_StyledTableBodyCell>{row.index + 1}</MRT_StyledTableBodyCell>
|
|
64
|
+
)}
|
|
63
65
|
{enableRowActions && positionActionsColumn === 'first' && (
|
|
64
|
-
<
|
|
65
|
-
<MRT_ToggleRowActionMenuButton row={row} />
|
|
66
|
-
</TableCell>
|
|
66
|
+
<MRT_ToggleRowActionMenuButton row={row} />
|
|
67
67
|
)}
|
|
68
68
|
{(anyRowsCanExpand || renderDetailPanel) && (
|
|
69
69
|
<MRT_ExpandButton row={row} />
|
|
@@ -73,9 +73,7 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
73
73
|
<MRT_TableBodyCell key={cell.getCellProps().key} cell={cell} />
|
|
74
74
|
))}
|
|
75
75
|
{enableRowActions && positionActionsColumn === 'last' && (
|
|
76
|
-
<
|
|
77
|
-
<MRT_ToggleRowActionMenuButton row={row} />
|
|
78
|
-
</TableCell>
|
|
76
|
+
<MRT_ToggleRowActionMenuButton row={row} />
|
|
79
77
|
)}
|
|
80
78
|
</TableRow>
|
|
81
79
|
{renderDetailPanel && <MRT_TableDetailPanel row={row} />}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
TableRow,
|
|
7
7
|
} from '@mui/material';
|
|
8
8
|
import { Row } from 'react-table';
|
|
9
|
-
import {
|
|
9
|
+
import { useMRT } from '../useMRT';
|
|
10
10
|
|
|
11
11
|
const TableCell = styled(MuiTableCell, {
|
|
12
12
|
shouldForwardProp: (prop) => prop !== 'isExpanded',
|
|
@@ -28,7 +28,7 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row }) => {
|
|
|
28
28
|
muiTableDetailPanelProps,
|
|
29
29
|
muiTableBodyRowProps,
|
|
30
30
|
onDetailPanelClick,
|
|
31
|
-
} =
|
|
31
|
+
} = useMRT();
|
|
32
32
|
|
|
33
33
|
const mTableBodyRowProps =
|
|
34
34
|
muiTableBodyRowProps instanceof Function
|
|
@@ -2,7 +2,7 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { IconButton, styled, Tooltip } from '@mui/material';
|
|
3
3
|
import SaveIcon from '@mui/icons-material/Save';
|
|
4
4
|
import CancelIcon from '@mui/icons-material/Cancel';
|
|
5
|
-
import {
|
|
5
|
+
import { useMRT } from '../useMRT';
|
|
6
6
|
import { Row } from 'react-table';
|
|
7
7
|
|
|
8
8
|
const EditActionButtonWrappers = styled('div')({
|
|
@@ -20,9 +20,10 @@ export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
|
|
|
20
20
|
setCurrentEditingRow,
|
|
21
21
|
onRowEditSubmit,
|
|
22
22
|
currentEditingRow,
|
|
23
|
-
} =
|
|
23
|
+
} = useMRT();
|
|
24
24
|
|
|
25
25
|
const handleCancel = () => {
|
|
26
|
+
row.values = row.original;
|
|
26
27
|
setCurrentEditingRow(null);
|
|
27
28
|
};
|
|
28
29
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { IconButton, styled
|
|
2
|
+
import { IconButton, styled } from '@mui/material';
|
|
3
3
|
import MuiArrowRightIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
|
|
4
|
-
import {
|
|
4
|
+
import { useMRT } from '../useMRT';
|
|
5
|
+
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
5
6
|
|
|
6
7
|
const ArrowRightIcon = styled(MuiArrowRightIcon, {
|
|
7
8
|
shouldForwardProp: (prop) => prop !== 'rotation',
|
|
@@ -13,23 +14,14 @@ const ArrowRightIcon = styled(MuiArrowRightIcon, {
|
|
|
13
14
|
interface Props {}
|
|
14
15
|
|
|
15
16
|
export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
16
|
-
const {
|
|
17
|
-
|
|
18
|
-
localization,
|
|
19
|
-
anyRowsExpanded,
|
|
20
|
-
densePadding,
|
|
21
|
-
renderDetailPanel,
|
|
22
|
-
} = useMaterialReactTable();
|
|
17
|
+
const { tableInstance, localization, anyRowsExpanded, densePadding } =
|
|
18
|
+
useMRT();
|
|
23
19
|
|
|
24
20
|
return (
|
|
25
|
-
<
|
|
21
|
+
<MRT_TableButtonCell
|
|
26
22
|
size="small"
|
|
23
|
+
densePadding={densePadding}
|
|
27
24
|
{...tableInstance.getToggleAllRowsExpandedProps()}
|
|
28
|
-
style={{
|
|
29
|
-
padding: densePadding ? '0' : '0.5rem 0.5rem',
|
|
30
|
-
transition: 'all 0.2s ease-in-out',
|
|
31
|
-
width: `${renderDetailPanel ? 2 : tableInstance.expandedDepth + 2}rem`,
|
|
32
|
-
}}
|
|
33
25
|
>
|
|
34
26
|
<IconButton
|
|
35
27
|
aria-label={localization?.expandAllButtonTitle}
|
|
@@ -42,6 +34,6 @@ export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
|
42
34
|
}
|
|
43
35
|
/>
|
|
44
36
|
</IconButton>
|
|
45
|
-
</
|
|
37
|
+
</MRT_TableButtonCell>
|
|
46
38
|
);
|
|
47
39
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { IconButton, styled
|
|
2
|
+
import { IconButton, styled } from '@mui/material';
|
|
3
3
|
import { Row } from 'react-table';
|
|
4
4
|
import MuiExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
5
|
-
import {
|
|
5
|
+
import { useMRT } from '../useMRT';
|
|
6
|
+
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
6
7
|
|
|
7
|
-
const TableCell = styled(
|
|
8
|
-
shouldForwardProp: (prop) => prop !== '
|
|
9
|
-
})<{
|
|
10
|
-
padding: densePadding ? '0' : '0.6rem',
|
|
8
|
+
const TableCell = styled(MRT_TableButtonCell, {
|
|
9
|
+
shouldForwardProp: (prop) => prop !== 'depth',
|
|
10
|
+
})<{ depth: number }>(({ depth }) => ({
|
|
11
11
|
paddingLeft: `${depth + 0.5}rem`,
|
|
12
|
-
|
|
12
|
+
textAlign: 'left',
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
15
|
const ExpandMoreIcon = styled(MuiExpandMoreIcon, {
|
|
@@ -24,8 +24,7 @@ interface Props {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
27
|
-
const { localization, densePadding, renderDetailPanel } =
|
|
28
|
-
useMaterialReactTable();
|
|
27
|
+
const { localization, densePadding, renderDetailPanel } = useMRT();
|
|
29
28
|
|
|
30
29
|
return (
|
|
31
30
|
<TableCell size="small" densePadding={densePadding} depth={row.depth}>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
|
+
import FilterListIcon from '@mui/icons-material/Fullscreen';
|
|
5
|
+
import FilterListOffIcon from '@mui/icons-material/FullscreenExit';
|
|
6
|
+
|
|
7
|
+
type Props = {};
|
|
8
|
+
|
|
9
|
+
export const MRT_FullScreenToggleButton: FC<Props> = () => {
|
|
10
|
+
const { localization, setFullScreen, fullScreen } = useMRT();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Tooltip arrow title={localization?.toggleFullScreenButtonTitle ?? ''}>
|
|
14
|
+
<IconButton
|
|
15
|
+
aria-label={localization?.toggleFilterButtonTitle}
|
|
16
|
+
onClick={() => setFullScreen(!fullScreen)}
|
|
17
|
+
size="small"
|
|
18
|
+
>
|
|
19
|
+
{fullScreen ? <FilterListOffIcon /> : <FilterListIcon />}
|
|
20
|
+
</IconButton>
|
|
21
|
+
</Tooltip>
|
|
22
|
+
);
|
|
23
|
+
};
|