material-react-table 0.3.3 → 0.3.4
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 +8 -5
- package/dist/buttons/MRT_ToggleSearchButton.d.ts +4 -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 +250 -160
- 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 +253 -163
- 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/useMaterialReactTable.d.ts +2 -0
- package/dist/utils/localization.d.ts +2 -0
- package/dist/utils/useMRTCalcs.d.ts +1 -1
- package/package.json +8 -6
- package/src/@types/react-table-config.d.ts +33 -55
- package/src/MaterialReactTable.tsx +22 -54
- package/src/body/MRT_TableBody.tsx +1 -2
- package/src/body/MRT_TableBodyCell.tsx +7 -14
- package/src/body/MRT_TableBodyRow.tsx +7 -24
- package/src/body/MRT_TableDetailPanel.tsx +3 -12
- package/src/buttons/MRT_EditActionButtons.tsx +4 -10
- package/src/buttons/MRT_ExpandAllButton.tsx +7 -18
- package/src/buttons/MRT_ExpandButton.tsx +8 -15
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +2 -9
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +4 -8
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +42 -24
- package/src/buttons/MRT_ToggleSearchButton.tsx +29 -0
- package/src/footer/MRT_TableFooter.tsx +1 -4
- package/src/footer/MRT_TableFooterCell.tsx +2 -4
- package/src/footer/MRT_TableFooterRow.tsx +4 -10
- package/src/head/MRT_TableHead.tsx +2 -7
- package/src/head/MRT_TableHeadCell.tsx +15 -15
- package/src/head/MRT_TableHeadRow.tsx +2 -4
- package/src/inputs/MRT_DensePaddingSwitch.tsx +4 -2
- package/src/inputs/{MRT_EditCellTextfield.tsx → MRT_EditCellTextField.tsx} +21 -14
- package/src/inputs/MRT_FilterTextField.tsx +39 -16
- package/src/inputs/MRT_SearchTextField.tsx +40 -43
- package/src/inputs/MRT_SelectAllCheckbox.tsx +8 -13
- package/src/inputs/MRT_SelectCheckbox.tsx +9 -13
- package/src/menus/MRT_ColumnActionMenu.tsx +51 -35
- package/src/menus/MRT_RowActionMenu.tsx +6 -25
- package/src/table/MRT_Table.tsx +1 -2
- package/src/table/MRT_TableButtonCell.tsx +9 -0
- package/src/table/MRT_TableContainer.tsx +2 -7
- package/src/table/MRT_TableSpacerCell.tsx +1 -3
- package/src/toolbar/MRT_TablePagination.tsx +3 -6
- package/src/toolbar/MRT_ToolbarBottom.tsx +4 -6
- package/src/toolbar/MRT_ToolbarButtons.tsx +3 -1
- package/src/toolbar/MRT_ToolbarTop.tsx +8 -17
- package/src/useMaterialReactTable.tsx +14 -21
- package/src/utils/localization.ts +10 -6
- package/src/utils/useMRTCalcs.tsx +1 -3
|
@@ -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>;
|
|
@@ -8,7 +8,9 @@ export interface UseMaterialReactTable<D extends {}> extends MaterialReactTableP
|
|
|
8
8
|
setCurrentEditingRow: (currentRowEditingId: Row<D> | null) => void;
|
|
9
9
|
setDensePadding: (densePadding: boolean) => void;
|
|
10
10
|
setShowFilters: (showFilters: boolean) => void;
|
|
11
|
+
setShowSearch: (showSearch: boolean) => void;
|
|
11
12
|
showFilters: boolean;
|
|
13
|
+
showSearch: boolean;
|
|
12
14
|
tableInstance: TableInstance<D>;
|
|
13
15
|
}
|
|
14
16
|
export declare const MaterialReactTableProvider: <D extends {}>(props: React.PropsWithChildren<MaterialReactTableProps<D>>) => JSX.Element;
|
|
@@ -19,8 +19,10 @@ export interface MRT_Localization {
|
|
|
19
19
|
searchTextFieldClearButtonTitle: string;
|
|
20
20
|
searchTextFieldPlaceholder: string;
|
|
21
21
|
selectAllCheckboxTitle: string;
|
|
22
|
+
selectCheckboxTitle: string;
|
|
22
23
|
showHideColumnsButtonTitle: string;
|
|
23
24
|
toggleDensePaddingSwitchTitle: string;
|
|
24
25
|
toggleFilterButtonTitle: string;
|
|
26
|
+
toggleSearchButtonTitle: string;
|
|
25
27
|
}
|
|
26
28
|
export declare const defaultLocalization: MRT_Localization;
|
|
@@ -7,5 +7,5 @@ export interface UseMRTCalcs {
|
|
|
7
7
|
interface Props<D extends {}> {
|
|
8
8
|
tableInstance: TableInstance<D>;
|
|
9
9
|
}
|
|
10
|
-
export declare const useMRTCalcs: <D extends {}>({ tableInstance
|
|
10
|
+
export declare const useMRTCalcs: <D extends {}>({ tableInstance }: Props<D>) => UseMRTCalcs;
|
|
11
11
|
export {};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.3.
|
|
2
|
+
"version": "0.3.4",
|
|
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",
|
|
@@ -84,6 +85,7 @@
|
|
|
84
85
|
"react-is": "^17.0.2",
|
|
85
86
|
"react-table": "^7.7.0",
|
|
86
87
|
"size-limit": "^7.0.5",
|
|
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,24 @@ import {
|
|
|
50
50
|
UseSortByState,
|
|
51
51
|
} from 'react-table';
|
|
52
52
|
|
|
53
|
+
export type MRT_ColumnInterface<D extends {} = {}> = UseFiltersColumnOptions<D> &
|
|
54
|
+
UseGlobalFiltersColumnOptions<D> &
|
|
55
|
+
UseGroupByColumnOptions<D> &
|
|
56
|
+
UseResizeColumnsColumnOptions<D> &
|
|
57
|
+
UseSortByColumnOptions<D> & {
|
|
58
|
+
disableFilters?: boolean;
|
|
59
|
+
Filter?: ({ column }: { column: HeaderGroup<D> }) => ReactNode;
|
|
60
|
+
editable?: boolean;
|
|
61
|
+
Edit?: ({ cell, onChange }: { cell: Cell<D> }) => ReactNode;
|
|
62
|
+
muiTableBodyCellProps?: TableCellProps | ((cell: Cell<D>) => TableCellProps);
|
|
63
|
+
muiTableHeadCellProps?: TableCellProps | ((column: Column<D>) => TableCellProps);
|
|
64
|
+
muiTableFooterCellProps?: TableCellProps | ((column: Column<D>) => TableCellProps);
|
|
65
|
+
muiTableBodyCellEditTextFieldProps?: TextFieldProps | ((cell: Cell<D>) => TextFieldProps);
|
|
66
|
+
muiTableHeadCellFilterTextFieldProps?: TextFieldProps | ((column: Column<D>) => TextFieldProps);
|
|
67
|
+
onCellEditChange?: (event: ChangeEvent<HTMLInputElement>, cell: Cell<D>) => void;
|
|
68
|
+
onFilterChange?: (event: ChangeEvent<HTMLInputElement>, filterValue: any) => void;
|
|
69
|
+
};
|
|
70
|
+
|
|
53
71
|
declare module 'react-table' {
|
|
54
72
|
export interface TableOptions<D extends Record<string, unknown>>
|
|
55
73
|
extends UseExpandedOptions<D>,
|
|
@@ -63,16 +81,14 @@ declare module 'react-table' {
|
|
|
63
81
|
UseSortByOptions<D>,
|
|
64
82
|
Record<string, any> {}
|
|
65
83
|
|
|
66
|
-
export interface Hooks<
|
|
67
|
-
|
|
68
|
-
> extends UseExpandedHooks<D>,
|
|
84
|
+
export interface Hooks<D extends Record<string, unknown> = Record<string, unknown>>
|
|
85
|
+
extends UseExpandedHooks<D>,
|
|
69
86
|
UseGroupByHooks<D>,
|
|
70
87
|
UseRowSelectHooks<D>,
|
|
71
88
|
UseSortByHooks<D> {}
|
|
72
89
|
|
|
73
|
-
export interface TableInstance<
|
|
74
|
-
|
|
75
|
-
> extends UseColumnOrderInstanceProps<D>,
|
|
90
|
+
export interface TableInstance<D extends Record<string, unknown> = Record<string, unknown>>
|
|
91
|
+
extends UseColumnOrderInstanceProps<D>,
|
|
76
92
|
UseExpandedInstanceProps<D>,
|
|
77
93
|
UseFiltersInstanceProps<D>,
|
|
78
94
|
UseGlobalFiltersInstanceProps<D>,
|
|
@@ -82,9 +98,8 @@ declare module 'react-table' {
|
|
|
82
98
|
UseRowStateInstanceProps<D>,
|
|
83
99
|
UseSortByInstanceProps<D> {}
|
|
84
100
|
|
|
85
|
-
export interface TableState<
|
|
86
|
-
|
|
87
|
-
> extends UseColumnOrderState<D>,
|
|
101
|
+
export interface TableState<D extends Record<string, unknown> = Record<string, unknown>>
|
|
102
|
+
extends UseColumnOrderState<D>,
|
|
88
103
|
UseExpandedState<D>,
|
|
89
104
|
UseFiltersState<D>,
|
|
90
105
|
UseGlobalFiltersState<D>,
|
|
@@ -95,59 +110,22 @@ declare module 'react-table' {
|
|
|
95
110
|
UseRowStateState<D>,
|
|
96
111
|
UseSortByState<D> {}
|
|
97
112
|
|
|
98
|
-
export interface ColumnInterface<
|
|
99
|
-
|
|
100
|
-
> extends UseFiltersColumnOptions<D>,
|
|
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
|
-
}
|
|
113
|
+
export interface ColumnInterface<D extends Record<string, unknown> = Record<string, unknown>>
|
|
114
|
+
extends MRT_ColumnInterface {}
|
|
131
115
|
|
|
132
|
-
export interface ColumnInstance<
|
|
133
|
-
|
|
134
|
-
> extends UseFiltersColumnProps<D>,
|
|
116
|
+
export interface ColumnInstance<D extends Record<string, unknown> = Record<string, unknown>>
|
|
117
|
+
extends UseFiltersColumnProps<D>,
|
|
135
118
|
UseGroupByColumnProps<D>,
|
|
136
119
|
UseResizeColumnsColumnProps<D>,
|
|
137
120
|
UseSortByColumnProps<D> {}
|
|
138
121
|
|
|
139
|
-
export interface Cell<
|
|
140
|
-
|
|
141
|
-
V = any,
|
|
142
|
-
> extends UseGroupByCellProps<D>,
|
|
122
|
+
export interface Cell<D extends Record<string, unknown> = Record<string, unknown>, V = any>
|
|
123
|
+
extends UseGroupByCellProps<D>,
|
|
143
124
|
UseRowStateCellProps<D> {}
|
|
144
125
|
|
|
145
|
-
export interface Row<
|
|
146
|
-
|
|
147
|
-
> extends UseExpandedRowProps<D>,
|
|
126
|
+
export interface Row<D extends Record<string, unknown> = Record<string, unknown>>
|
|
127
|
+
extends UseExpandedRowProps<D>,
|
|
148
128
|
UseGroupByRowProps<D>,
|
|
149
129
|
UseRowSelectRowProps<D>,
|
|
150
130
|
UseRowStateRowProps<D> {}
|
|
151
131
|
}
|
|
152
|
-
|
|
153
|
-
export module 'react-table';
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
TableRowProps,
|
|
11
11
|
TextFieldProps,
|
|
12
12
|
ToolbarProps,
|
|
13
|
-
TypographyProps,
|
|
14
13
|
} from '@mui/material';
|
|
15
14
|
import {
|
|
16
15
|
Cell,
|
|
@@ -28,12 +27,15 @@ import {
|
|
|
28
27
|
UseRowSelectOptions,
|
|
29
28
|
UseRowStateOptions,
|
|
30
29
|
UseSortByOptions,
|
|
30
|
+
UseTableOptions,
|
|
31
31
|
} from 'react-table';
|
|
32
32
|
import { MaterialReactTableProvider } from './useMaterialReactTable';
|
|
33
33
|
import { MRT_TableContainer } from './table/MRT_TableContainer';
|
|
34
34
|
import { defaultLocalization, MRT_Localization } from './utils/localization';
|
|
35
|
+
import { MRT_ColumnInterface } from './@types/react-table-config';
|
|
35
36
|
|
|
36
37
|
export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
38
|
+
UseTableOptions<D> &
|
|
37
39
|
UseExpandedOptions<D> &
|
|
38
40
|
UseFiltersOptions<D> &
|
|
39
41
|
UseGlobalFiltersOptions<D> &
|
|
@@ -43,8 +45,10 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
43
45
|
UseRowSelectOptions<D> &
|
|
44
46
|
UseRowStateOptions<D> &
|
|
45
47
|
UseSortByOptions<D> & {
|
|
48
|
+
columns: (Column<D> & MRT_ColumnInterface)[];
|
|
46
49
|
defaultDensePadding?: boolean;
|
|
47
50
|
defaultShowFilters?: boolean;
|
|
51
|
+
defaultShowSearchTextField?: boolean;
|
|
48
52
|
disableColumnActions?: boolean;
|
|
49
53
|
disableColumnHiding?: boolean;
|
|
50
54
|
disableDensePaddingToggle?: boolean;
|
|
@@ -65,66 +69,33 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
65
69
|
isLoading?: boolean;
|
|
66
70
|
localization?: Partial<MRT_Localization>;
|
|
67
71
|
muiSearchTextFieldProps?: TextFieldProps;
|
|
68
|
-
muiTableBodyCellEditTextFieldProps?:
|
|
69
|
-
|
|
70
|
-
| ((cell?: Cell<D>) => TextFieldProps);
|
|
71
|
-
muiTableBodyCellProps?:
|
|
72
|
-
| TableCellProps
|
|
73
|
-
| ((cell?: Cell<D>) => TableCellProps);
|
|
72
|
+
muiTableBodyCellEditTextFieldProps?: TextFieldProps | ((cell?: Cell<D>) => TextFieldProps);
|
|
73
|
+
muiTableBodyCellProps?: TableCellProps | ((cell?: Cell<D>) => TableCellProps);
|
|
74
74
|
muiTableBodyProps?: TableBodyProps;
|
|
75
75
|
muiTableBodyRowProps?: TableRowProps | ((row: Row<D>) => TableRowProps);
|
|
76
76
|
muiTableContainerProps?: TableContainerProps;
|
|
77
|
-
muiTableDetailPanelProps?:
|
|
78
|
-
|
|
79
|
-
| ((row: Row<D>) => TableCellProps);
|
|
80
|
-
muiTableFooterCellProps?:
|
|
81
|
-
| TableCellProps
|
|
82
|
-
| ((column: Column<D>) => TableCellProps);
|
|
77
|
+
muiTableDetailPanelProps?: TableCellProps | ((row: Row<D>) => TableCellProps);
|
|
78
|
+
muiTableFooterCellProps?: TableCellProps | ((column: Column<D>) => TableCellProps);
|
|
83
79
|
muiTableFooterProps?: TableFooterProps;
|
|
84
|
-
muiTableFooterRowProps?:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
muiTableHeadCellFilterTextFieldProps?:
|
|
88
|
-
| TextFieldProps
|
|
89
|
-
| ((column: Column<D>) => TextFieldProps);
|
|
90
|
-
muiTableHeadCellProps?:
|
|
91
|
-
| TableCellProps
|
|
92
|
-
| ((column: Column<D>) => TableCellProps);
|
|
80
|
+
muiTableFooterRowProps?: TableRowProps | ((footerGroup: HeaderGroup<D>) => TableRowProps);
|
|
81
|
+
muiTableHeadCellFilterTextFieldProps?: TextFieldProps | ((column: Column<D>) => TextFieldProps);
|
|
82
|
+
muiTableHeadCellProps?: TableCellProps | ((column: Column<D>) => TableCellProps);
|
|
93
83
|
muiTableHeadProps?: TableHeadProps;
|
|
94
|
-
muiTableHeadRowProps?:
|
|
95
|
-
| TableRowProps
|
|
96
|
-
| ((row: HeaderGroup<D>) => TableRowProps);
|
|
84
|
+
muiTableHeadRowProps?: TableRowProps | ((row: HeaderGroup<D>) => TableRowProps);
|
|
97
85
|
muiTablePaginationProps?:
|
|
98
86
|
| Partial<TablePaginationProps>
|
|
99
87
|
| ((tableInstance: TableInstance<D>) => Partial<TablePaginationProps>);
|
|
100
88
|
muiTableProps?: TableProps;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
| ToolbarProps
|
|
107
|
-
| ((tableInstance: TableInstance<D>) => ToolbarProps);
|
|
108
|
-
onCellClick?: (
|
|
109
|
-
event: MouseEvent<HTMLTableCellElement>,
|
|
110
|
-
cell: Cell<D>,
|
|
111
|
-
) => void;
|
|
112
|
-
onDetailPanelClick?: (
|
|
113
|
-
event: MouseEvent<HTMLTableCellElement>,
|
|
114
|
-
row: Row<D>,
|
|
115
|
-
) => void;
|
|
89
|
+
muiTableToolbarBottomProps?: ToolbarProps | ((tableInstance: TableInstance<D>) => ToolbarProps);
|
|
90
|
+
muiTableToolbarTopProps?: ToolbarProps | ((tableInstance: TableInstance<D>) => ToolbarProps);
|
|
91
|
+
onCellClick?: (event: MouseEvent<HTMLTableCellElement>, cell: Cell<D>) => void;
|
|
92
|
+
onColumnHide?: (column: Column<D>, visibleColumns: Column<D>[]) => void;
|
|
93
|
+
onDetailPanelClick?: (event: MouseEvent<HTMLTableCellElement>, row: Row<D>) => void;
|
|
116
94
|
onGlobalFilterChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
117
95
|
onRowClick?: (event: MouseEvent<HTMLTableRowElement>, row: Row<D>) => void;
|
|
118
96
|
onRowEditSubmit?: (row: Row<D>) => Promise<void> | void;
|
|
119
|
-
onRowExpandChange?: (
|
|
120
|
-
|
|
121
|
-
row: Row<D>,
|
|
122
|
-
) => void;
|
|
123
|
-
onRowSelectChange?: (
|
|
124
|
-
event: ChangeEvent,
|
|
125
|
-
row: Row<D>,
|
|
126
|
-
selectedRows: Row<D>[],
|
|
127
|
-
) => void;
|
|
97
|
+
onRowExpandChange?: (event: MouseEvent<HTMLButtonElement>, row: Row<D>) => void;
|
|
98
|
+
onRowSelectChange?: (event: ChangeEvent, row: Row<D>, selectedRows: Row<D>[]) => void;
|
|
128
99
|
positionActionsColumn?: 'first' | 'last';
|
|
129
100
|
positionPagination?: 'bottom' | 'top' | 'both';
|
|
130
101
|
positionToolbarActions?: 'bottom' | 'top';
|
|
@@ -134,11 +105,8 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
134
105
|
tableInstance: TableInstance<D>,
|
|
135
106
|
closeMenu: () => void,
|
|
136
107
|
) => ReactNode[];
|
|
137
|
-
renderRowActions?: (
|
|
138
|
-
|
|
139
|
-
tableInstance: TableInstance<D>,
|
|
140
|
-
) => ReactNode;
|
|
141
|
-
title?: string | ReactNode;
|
|
108
|
+
renderRowActions?: (row: Row<D>, tableInstance: TableInstance<D>) => ReactNode;
|
|
109
|
+
renderToolbarActions?: (tableInstance: TableInstance<D>) => ReactNode;
|
|
142
110
|
};
|
|
143
111
|
|
|
144
112
|
export default <D extends {}>({
|
|
@@ -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 } = useMaterialReactTable();
|
|
15
14
|
|
|
16
15
|
const rows = manualPagination ? tableInstance.rows : tableInstance.page;
|
|
17
16
|
|
|
@@ -2,13 +2,14 @@ import React, { FC, MouseEvent } from 'react';
|
|
|
2
2
|
import { styled, TableCell as MuiTableCell } from '@mui/material';
|
|
3
3
|
import { Cell } from 'react-table';
|
|
4
4
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
5
|
-
import {
|
|
5
|
+
import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
|
6
6
|
|
|
7
7
|
const TableCell = 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 {
|
|
@@ -16,17 +17,11 @@ interface Props {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
muiTableBodyCellProps,
|
|
22
|
-
densePadding,
|
|
23
|
-
currentEditingRow,
|
|
24
|
-
} = useMaterialReactTable();
|
|
20
|
+
const { onCellClick, muiTableBodyCellProps, densePadding, currentEditingRow } =
|
|
21
|
+
useMaterialReactTable();
|
|
25
22
|
|
|
26
23
|
const mTableCellBodyProps =
|
|
27
|
-
muiTableBodyCellProps instanceof Function
|
|
28
|
-
? muiTableBodyCellProps(cell)
|
|
29
|
-
: muiTableBodyCellProps;
|
|
24
|
+
muiTableBodyCellProps instanceof Function ? muiTableBodyCellProps(cell) : muiTableBodyCellProps;
|
|
30
25
|
|
|
31
26
|
const mcTableCellBodyProps =
|
|
32
27
|
cell.column.muiTableBodyCellProps instanceof Function
|
|
@@ -47,13 +42,11 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
47
42
|
return (
|
|
48
43
|
<TableCell
|
|
49
44
|
densePadding={densePadding}
|
|
50
|
-
onClick={(event: MouseEvent<HTMLTableCellElement>) =>
|
|
51
|
-
onCellClick?.(event, cell)
|
|
52
|
-
}
|
|
45
|
+
onClick={(event: MouseEvent<HTMLTableCellElement>) => onCellClick?.(event, cell)}
|
|
53
46
|
{...tableCellProps}
|
|
54
47
|
>
|
|
55
48
|
{currentEditingRow?.id === cell.row.id ? (
|
|
56
|
-
<
|
|
49
|
+
<MRT_EditCellTextField cell={cell} />
|
|
57
50
|
) : cell.isPlaceholder ? null : cell.isAggregated ? (
|
|
58
51
|
cell.render('Aggregated')
|
|
59
52
|
) : cell.isGrouped ? (
|
|
@@ -1,10 +1,5 @@
|
|
|
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
4
|
import { MRT_TableBodyCell } from './MRT_TableBodyCell';
|
|
10
5
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
@@ -16,9 +11,7 @@ import { MRT_ToggleRowActionMenuButton } from '../buttons/MRT_ToggleRowActionMen
|
|
|
16
11
|
export const TableRow = styled(MuiTableRow, {
|
|
17
12
|
shouldForwardProp: (prop) => prop !== 'isSelected',
|
|
18
13
|
})<{ isSelected?: boolean }>(({ isSelected, theme }) => ({
|
|
19
|
-
backgroundColor: isSelected
|
|
20
|
-
? alpha(theme.palette.primary.light, 0.1)
|
|
21
|
-
: 'transparent',
|
|
14
|
+
backgroundColor: isSelected ? alpha(theme.palette.primary.light, 0.1) : 'transparent',
|
|
22
15
|
}));
|
|
23
16
|
|
|
24
17
|
interface Props {
|
|
@@ -37,9 +30,7 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
37
30
|
} = useMaterialReactTable();
|
|
38
31
|
|
|
39
32
|
const mTableBodyRowProps =
|
|
40
|
-
muiTableBodyRowProps instanceof Function
|
|
41
|
-
? muiTableBodyRowProps(row)
|
|
42
|
-
: muiTableBodyRowProps;
|
|
33
|
+
muiTableBodyRowProps instanceof Function ? muiTableBodyRowProps(row) : muiTableBodyRowProps;
|
|
43
34
|
|
|
44
35
|
const tableRowProps = {
|
|
45
36
|
...mTableBodyRowProps,
|
|
@@ -55,27 +46,19 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
55
46
|
<TableRow
|
|
56
47
|
isSelected={row.isSelected}
|
|
57
48
|
hover
|
|
58
|
-
onClick={(event: MouseEvent<HTMLTableRowElement>) =>
|
|
59
|
-
onRowClick?.(event, row)
|
|
60
|
-
}
|
|
49
|
+
onClick={(event: MouseEvent<HTMLTableRowElement>) => onRowClick?.(event, row)}
|
|
61
50
|
{...tableRowProps}
|
|
62
51
|
>
|
|
63
52
|
{enableRowActions && positionActionsColumn === 'first' && (
|
|
64
|
-
<
|
|
65
|
-
<MRT_ToggleRowActionMenuButton row={row} />
|
|
66
|
-
</TableCell>
|
|
67
|
-
)}
|
|
68
|
-
{(anyRowsCanExpand || renderDetailPanel) && (
|
|
69
|
-
<MRT_ExpandButton row={row} />
|
|
53
|
+
<MRT_ToggleRowActionMenuButton row={row} />
|
|
70
54
|
)}
|
|
55
|
+
{(anyRowsCanExpand || renderDetailPanel) && <MRT_ExpandButton row={row} />}
|
|
71
56
|
{enableSelection && <MRT_SelectCheckbox row={row} />}
|
|
72
57
|
{row.cells.map((cell) => (
|
|
73
58
|
<MRT_TableBodyCell key={cell.getCellProps().key} cell={cell} />
|
|
74
59
|
))}
|
|
75
60
|
{enableRowActions && positionActionsColumn === 'last' && (
|
|
76
|
-
<
|
|
77
|
-
<MRT_ToggleRowActionMenuButton row={row} />
|
|
78
|
-
</TableCell>
|
|
61
|
+
<MRT_ToggleRowActionMenuButton row={row} />
|
|
79
62
|
)}
|
|
80
63
|
</TableRow>
|
|
81
64
|
{renderDetailPanel && <MRT_TableDetailPanel row={row} />}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Collapse,
|
|
4
|
-
styled,
|
|
5
|
-
TableCell as MuiTableCell,
|
|
6
|
-
TableRow,
|
|
7
|
-
} from '@mui/material';
|
|
2
|
+
import { Collapse, styled, TableCell as MuiTableCell, TableRow } from '@mui/material';
|
|
8
3
|
import { Row } from 'react-table';
|
|
9
4
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
10
5
|
|
|
@@ -31,9 +26,7 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row }) => {
|
|
|
31
26
|
} = useMaterialReactTable();
|
|
32
27
|
|
|
33
28
|
const mTableBodyRowProps =
|
|
34
|
-
muiTableBodyRowProps instanceof Function
|
|
35
|
-
? muiTableBodyRowProps(row)
|
|
36
|
-
: muiTableBodyRowProps;
|
|
29
|
+
muiTableBodyRowProps instanceof Function ? muiTableBodyRowProps(row) : muiTableBodyRowProps;
|
|
37
30
|
|
|
38
31
|
const tableRowProps = {
|
|
39
32
|
...mTableBodyRowProps,
|
|
@@ -61,9 +54,7 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row }) => {
|
|
|
61
54
|
<TableCell
|
|
62
55
|
colSpan={tableInstance.visibleColumns.length + 10}
|
|
63
56
|
isExpanded={row.isExpanded}
|
|
64
|
-
onClick={(event: MouseEvent<HTMLTableCellElement>) =>
|
|
65
|
-
onDetailPanelClick?.(event, row)
|
|
66
|
-
}
|
|
57
|
+
onClick={(event: MouseEvent<HTMLTableCellElement>) => onDetailPanelClick?.(event, row)}
|
|
67
58
|
{...tableCellProps}
|
|
68
59
|
>
|
|
69
60
|
<Collapse in={row.isExpanded}>{renderDetailPanel?.(row)}</Collapse>
|
|
@@ -15,14 +15,11 @@ interface Props {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
setCurrentEditingRow,
|
|
21
|
-
onRowEditSubmit,
|
|
22
|
-
currentEditingRow,
|
|
23
|
-
} = useMaterialReactTable();
|
|
18
|
+
const { localization, setCurrentEditingRow, onRowEditSubmit, currentEditingRow } =
|
|
19
|
+
useMaterialReactTable();
|
|
24
20
|
|
|
25
21
|
const handleCancel = () => {
|
|
22
|
+
row.values = row.original;
|
|
26
23
|
setCurrentEditingRow(null);
|
|
27
24
|
};
|
|
28
25
|
|
|
@@ -34,10 +31,7 @@ export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
|
|
|
34
31
|
return (
|
|
35
32
|
<EditActionButtonWrappers>
|
|
36
33
|
<Tooltip arrow title={localization?.rowActionButtonCancel ?? ''}>
|
|
37
|
-
<IconButton
|
|
38
|
-
aria-label={localization?.rowActionButtonCancel}
|
|
39
|
-
onClick={handleCancel}
|
|
40
|
-
>
|
|
34
|
+
<IconButton aria-label={localization?.rowActionButtonCancel} onClick={handleCancel}>
|
|
41
35
|
<CancelIcon />
|
|
42
36
|
</IconButton>
|
|
43
37
|
</Tooltip>
|
|
@@ -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
4
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
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,13 @@ const ArrowRightIcon = styled(MuiArrowRightIcon, {
|
|
|
13
14
|
interface Props {}
|
|
14
15
|
|
|
15
16
|
export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
16
|
-
const {
|
|
17
|
-
tableInstance,
|
|
18
|
-
localization,
|
|
19
|
-
anyRowsExpanded,
|
|
20
|
-
densePadding,
|
|
21
|
-
renderDetailPanel,
|
|
22
|
-
} = useMaterialReactTable();
|
|
17
|
+
const { tableInstance, localization, anyRowsExpanded, densePadding } = useMaterialReactTable();
|
|
23
18
|
|
|
24
19
|
return (
|
|
25
|
-
<
|
|
20
|
+
<MRT_TableButtonCell
|
|
26
21
|
size="small"
|
|
22
|
+
densePadding={densePadding}
|
|
27
23
|
{...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
24
|
>
|
|
34
25
|
<IconButton
|
|
35
26
|
aria-label={localization?.expandAllButtonTitle}
|
|
@@ -37,11 +28,9 @@ export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
|
37
28
|
>
|
|
38
29
|
<ArrowRightIcon
|
|
39
30
|
fontSize="small"
|
|
40
|
-
rotation={
|
|
41
|
-
tableInstance.isAllRowsExpanded ? -180 : anyRowsExpanded ? -90 : 0
|
|
42
|
-
}
|
|
31
|
+
rotation={tableInstance.isAllRowsExpanded ? -180 : anyRowsExpanded ? -90 : 0}
|
|
43
32
|
/>
|
|
44
33
|
</IconButton>
|
|
45
|
-
</
|
|
34
|
+
</MRT_TableButtonCell>
|
|
46
35
|
);
|
|
47
36
|
};
|
|
@@ -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
5
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
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 } = useMaterialReactTable();
|
|
29
28
|
|
|
30
29
|
return (
|
|
31
30
|
<TableCell size="small" densePadding={densePadding} depth={row.depth}>
|
|
@@ -37,13 +36,7 @@ export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
|
37
36
|
>
|
|
38
37
|
<ExpandMoreIcon
|
|
39
38
|
fontSize={row.canExpand || renderDetailPanel ? 'medium' : 'small'}
|
|
40
|
-
rotation={
|
|
41
|
-
!row.canExpand && !renderDetailPanel
|
|
42
|
-
? -90
|
|
43
|
-
: row.isExpanded
|
|
44
|
-
? -180
|
|
45
|
-
: 0
|
|
46
|
-
}
|
|
39
|
+
rotation={!row.canExpand && !renderDetailPanel ? -90 : row.isExpanded ? -180 : 0}
|
|
47
40
|
/>
|
|
48
41
|
</IconButton>
|
|
49
42
|
</TableCell>
|