material-react-table 0.6.0 → 0.6.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 +18 -10
- package/dist/filtersFNs.d.ts +6 -10
- package/dist/material-react-table.cjs.development.js +231 -200
- 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 +232 -201
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/toolbar/MRT_LinearProgressBar.d.ts +5 -0
- package/dist/toolbar/MRT_ToolbarTop.d.ts +11 -0
- package/dist/useMRT.d.ts +5 -1
- package/dist/utils.d.ts +2 -0
- package/package.json +3 -3
- package/src/MaterialReactTable.tsx +66 -52
- package/src/body/MRT_TableBody.tsx +3 -1
- package/src/filtersFNs.ts +6 -16
- package/src/inputs/MRT_FilterTextField.tsx +1 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +5 -4
- package/src/table/MRT_TableContainer.tsx +4 -28
- package/src/toolbar/MRT_LinearProgressBar.tsx +25 -0
- package/src/toolbar/MRT_TablePagination.tsx +1 -1
- package/src/toolbar/MRT_ToolbarBottom.tsx +18 -21
- package/src/toolbar/MRT_ToolbarTop.tsx +21 -10
- package/src/useMRT.tsx +53 -48
- package/src/utils.ts +17 -0
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { Theme } from '@mui/material';
|
|
3
|
+
import { MRT_TableInstance } from '..';
|
|
4
|
+
export declare const commonToolbarStyles: (theme: Theme, tableInstance: MRT_TableInstance) => {
|
|
5
|
+
backgroundColor: string;
|
|
6
|
+
backgroundImage: string;
|
|
7
|
+
display: string;
|
|
8
|
+
opacity: number;
|
|
9
|
+
p: string;
|
|
10
|
+
width: string;
|
|
11
|
+
zIndex: number;
|
|
12
|
+
};
|
|
2
13
|
interface Props {
|
|
3
14
|
}
|
|
4
15
|
export declare const MRT_ToolbarTop: FC<Props>;
|
package/dist/useMRT.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { Dispatch, PropsWithChildren, SetStateAction } from 'react';
|
|
2
2
|
import type { MRT_FilterType, MRT_Row, MRT_TableInstance } from '.';
|
|
3
|
+
import { MRT_FILTER_TYPE } from './enums';
|
|
3
4
|
import { MRT_Icons } from './icons';
|
|
4
5
|
import { MRT_Localization } from './localization';
|
|
5
6
|
import { MaterialReactTableProps } from './MaterialReactTable';
|
|
@@ -8,6 +9,9 @@ export declare type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
|
|
|
8
9
|
anyRowsExpanded: boolean;
|
|
9
10
|
icons: MRT_Icons;
|
|
10
11
|
idPrefix: string;
|
|
12
|
+
filterTypes: {
|
|
13
|
+
[key in MRT_FILTER_TYPE]: any;
|
|
14
|
+
};
|
|
11
15
|
localization: MRT_Localization;
|
|
12
16
|
setCurrentEditingRow: Dispatch<SetStateAction<MRT_Row<D> | null>>;
|
|
13
17
|
setCurrentFilterTypes: Dispatch<SetStateAction<{
|
package/dist/utils.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
2
|
+
"version": "0.6.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.",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
],
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@babel/core": "^7.17.5",
|
|
59
|
-
"@emotion/react": "^11.8.
|
|
59
|
+
"@emotion/react": "^11.8.2",
|
|
60
60
|
"@emotion/styled": "^11.8.1",
|
|
61
61
|
"@etchteam/storybook-addon-status": "^4.2.0",
|
|
62
62
|
"@faker-js/faker": "^6.0.0-beta.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@storybook/addons": "^6.4.19",
|
|
74
74
|
"@storybook/react": "^6.4.19",
|
|
75
75
|
"@types/faker": "^6.6.8",
|
|
76
|
-
"@types/react": "^17.0.
|
|
76
|
+
"@types/react": "^17.0.40",
|
|
77
77
|
"@types/react-dom": "^17.0.13",
|
|
78
78
|
"@types/react-table": "^7.7.9",
|
|
79
79
|
"babel-loader": "^8.2.3",
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
Column,
|
|
21
21
|
ColumnInstance,
|
|
22
22
|
FilterType,
|
|
23
|
-
|
|
23
|
+
ColumnInterface,
|
|
24
24
|
HeaderGroup,
|
|
25
25
|
Row,
|
|
26
26
|
TableInstance,
|
|
@@ -78,6 +78,7 @@ import { MRT_TableContainer } from './table/MRT_TableContainer';
|
|
|
78
78
|
import { MRT_Localization, MRT_DefaultLocalization_EN } from './localization';
|
|
79
79
|
import { MRT_Default_Icons, MRT_Icons } from './icons';
|
|
80
80
|
import { MRT_FILTER_TYPE } from './enums';
|
|
81
|
+
import { defaultFilterFNs } from './filtersFNs';
|
|
81
82
|
|
|
82
83
|
export type MRT_TableOptions<D extends {} = {}> = TableOptions<D> &
|
|
83
84
|
UseExpandedOptions<D> &
|
|
@@ -89,7 +90,7 @@ export type MRT_TableOptions<D extends {} = {}> = TableOptions<D> &
|
|
|
89
90
|
UseRowSelectOptions<D> &
|
|
90
91
|
UseRowStateOptions<D> &
|
|
91
92
|
UseSortByOptions<D> & {
|
|
92
|
-
columns:
|
|
93
|
+
columns: MRT_ColumnInterface[];
|
|
93
94
|
data: D[];
|
|
94
95
|
initialState?: Partial<MRT_TableState>;
|
|
95
96
|
};
|
|
@@ -106,66 +107,69 @@ export type MRT_TableInstance<D extends {} = {}> = TableInstance<D> &
|
|
|
106
107
|
UseRowStateInstanceProps<D> &
|
|
107
108
|
UseSortByInstanceProps<D> & {
|
|
108
109
|
columns: (Column<D> & MRT_ColumnInstance<D>)[];
|
|
109
|
-
headerGroups: MRT_HeaderGroup<D>[];
|
|
110
110
|
footerGroups: MRT_HeaderGroup<D>[];
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
getToggleAllRowsExpandedProps: () => void;
|
|
112
|
+
headerGroups: MRT_HeaderGroup<D>[];
|
|
113
113
|
page: MRT_Row<D>[];
|
|
114
114
|
resetResizing: () => void;
|
|
115
|
-
|
|
115
|
+
rows: MRT_Row<D>[];
|
|
116
|
+
state: MRT_TableState<D>;
|
|
116
117
|
};
|
|
117
118
|
|
|
118
|
-
export type MRT_ColumnInterface<D extends {} = {}> =
|
|
119
|
-
// ColumnInterface<D> &
|
|
119
|
+
export type MRT_ColumnInterface<D extends {} = {}> = ColumnInterface<D> &
|
|
120
120
|
UseFiltersColumnOptions<D> &
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
121
|
+
UseGlobalFiltersColumnOptions<D> &
|
|
122
|
+
UseGroupByColumnOptions<D> &
|
|
123
|
+
UseResizeColumnsColumnOptions<D> &
|
|
124
|
+
UseSortByColumnOptions<D> & {
|
|
125
|
+
Edit?: ({
|
|
126
|
+
cell,
|
|
127
|
+
onChange,
|
|
128
|
+
}: {
|
|
129
|
+
cell: MRT_Cell<D>;
|
|
130
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
131
|
+
}) => ReactNode;
|
|
132
|
+
Filter?: ({ column }: { column: MRT_HeaderGroup<D> }) => ReactNode;
|
|
133
|
+
Footer?: string;
|
|
134
|
+
Header?: string;
|
|
135
|
+
accessor?: string;
|
|
136
|
+
columns?: MRT_ColumnInterface<D>[];
|
|
137
|
+
disableFilters?: boolean;
|
|
138
|
+
editable?: boolean;
|
|
139
|
+
filter?: MRT_FilterType | string | FilterType<D>;
|
|
140
|
+
filterSelectOptions?: (string | { text: string; value: string })[];
|
|
141
|
+
filterTypes?: (MRT_FILTER_TYPE | string)[];
|
|
142
|
+
muiTableBodyCellEditTextFieldProps?:
|
|
143
|
+
| TextFieldProps
|
|
144
|
+
| ((cell: MRT_Cell<D>) => TextFieldProps);
|
|
145
|
+
muiTableBodyCellProps?:
|
|
146
|
+
| TableCellProps
|
|
147
|
+
| ((cell: MRT_Cell<D>) => TableCellProps);
|
|
148
|
+
muiTableFooterCellProps?:
|
|
149
|
+
| TableCellProps
|
|
150
|
+
| ((column: Column<D>) => TableCellProps);
|
|
151
|
+
muiTableHeadCellFilterTextFieldProps?:
|
|
152
|
+
| TextFieldProps
|
|
153
|
+
| ((column: Column<D>) => TextFieldProps);
|
|
154
|
+
muiTableHeadCellProps?:
|
|
155
|
+
| TableCellProps
|
|
156
|
+
| ((column: Column<D>) => TableCellProps);
|
|
157
|
+
onCellEditChange?: (
|
|
158
|
+
event: ChangeEvent<HTMLInputElement>,
|
|
159
|
+
cell: MRT_Cell<D>,
|
|
160
|
+
) => void;
|
|
161
|
+
onFilterChange?: (
|
|
162
|
+
event: ChangeEvent<HTMLInputElement>,
|
|
163
|
+
filterValue: any,
|
|
164
|
+
) => void;
|
|
165
|
+
};
|
|
163
166
|
|
|
164
167
|
export type MRT_ColumnInstance<D extends {} = {}> = ColumnInstance<D> &
|
|
165
168
|
UseFiltersColumnProps<D> &
|
|
166
169
|
UseGroupByColumnProps<D> &
|
|
167
170
|
UseResizeColumnsColumnProps<D> &
|
|
168
|
-
UseSortByColumnProps<D> &
|
|
171
|
+
UseSortByColumnProps<D> &
|
|
172
|
+
MRT_ColumnInterface<D> & {
|
|
169
173
|
columns?: MRT_ColumnInstance<D>[];
|
|
170
174
|
};
|
|
171
175
|
|
|
@@ -185,7 +189,9 @@ export type MRT_Row<D extends {} = {}> = Row<D> &
|
|
|
185
189
|
|
|
186
190
|
export type MRT_Cell<D extends {} = {}, _V = any> = Cell<D> &
|
|
187
191
|
UseGroupByCellProps<D> &
|
|
188
|
-
UseRowStateCellProps<D> & {
|
|
192
|
+
UseRowStateCellProps<D> & {
|
|
193
|
+
column: MRT_ColumnInstance<D>;
|
|
194
|
+
};
|
|
189
195
|
|
|
190
196
|
export type MRT_FilterType = MRT_FILTER_TYPE | Function;
|
|
191
197
|
|
|
@@ -232,6 +238,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
232
238
|
enableRowEditing?: boolean;
|
|
233
239
|
enableRowNumbers?: boolean;
|
|
234
240
|
enableSelection?: boolean;
|
|
241
|
+
filterTypes?: { [key in MRT_FILTER_TYPE]: any };
|
|
235
242
|
hideTableFooter?: boolean;
|
|
236
243
|
hideTableHead?: boolean;
|
|
237
244
|
hideToolbarBottom?: boolean;
|
|
@@ -362,6 +369,8 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
362
369
|
|
|
363
370
|
export default <D extends {}>({
|
|
364
371
|
defaultColumn = { minWidth: 50, maxWidth: 1000 },
|
|
372
|
+
filterTypes,
|
|
373
|
+
globalFilter = 'fuzzy',
|
|
365
374
|
icons,
|
|
366
375
|
localization,
|
|
367
376
|
positionActionsColumn = 'first',
|
|
@@ -371,7 +380,12 @@ export default <D extends {}>({
|
|
|
371
380
|
...rest
|
|
372
381
|
}: MaterialReactTableProps<D>) => (
|
|
373
382
|
<MaterialReactTableProvider
|
|
383
|
+
//@ts-ignore
|
|
374
384
|
defaultColumn={defaultColumn}
|
|
385
|
+
//@ts-ignore
|
|
386
|
+
filterTypes={{ ...defaultFilterFNs, ...filterTypes }}
|
|
387
|
+
//@ts-ignore
|
|
388
|
+
globalFilter={globalFilter}
|
|
375
389
|
icons={{ ...MRT_Default_Icons, ...icons }}
|
|
376
390
|
localization={{ ...MRT_DefaultLocalization_EN, ...localization }}
|
|
377
391
|
positionActionsColumn={positionActionsColumn}
|
|
@@ -28,7 +28,9 @@ export const MRT_TableBody: FC<Props> = () => {
|
|
|
28
28
|
return (
|
|
29
29
|
<TableBody
|
|
30
30
|
{...tableBodyProps}
|
|
31
|
-
sx={{
|
|
31
|
+
sx={{
|
|
32
|
+
...tableBodyProps?.sx,
|
|
33
|
+
}}
|
|
32
34
|
>
|
|
33
35
|
{rows.map((row: MRT_Row) => {
|
|
34
36
|
tableInstance.prepareRow(row);
|
package/src/filtersFNs.ts
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
import { matchSorter } from 'match-sorter';
|
|
2
2
|
import { MRT_Row } from '.';
|
|
3
3
|
|
|
4
|
-
export const fuzzySearchFN = (
|
|
5
|
-
rows: MRT_Row[],
|
|
6
|
-
columnIds: string[],
|
|
7
|
-
filterValue: string | number,
|
|
8
|
-
) =>
|
|
9
|
-
matchSorter(rows, filterValue.toString().trim(), {
|
|
10
|
-
keys: columnIds.map((c) => `values.${c}`),
|
|
11
|
-
sorter: (rankedItems) => rankedItems,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
fuzzySearchFN.autoRemove = (val: any) => !val;
|
|
15
|
-
|
|
16
4
|
export const fuzzyFilterFN = (
|
|
17
5
|
rows: MRT_Row[],
|
|
18
|
-
|
|
6
|
+
columnIds: string[] | string,
|
|
19
7
|
filterValue: string | number,
|
|
20
8
|
) =>
|
|
21
9
|
matchSorter(rows, filterValue.toString().trim(), {
|
|
22
|
-
keys:
|
|
10
|
+
keys: Array.isArray(columnIds)
|
|
11
|
+
? columnIds.map((c) => `values.${c}`)
|
|
12
|
+
: [`values.${columnIds}`],
|
|
23
13
|
sorter: (rankedItems) => rankedItems,
|
|
24
14
|
});
|
|
25
15
|
|
|
@@ -144,10 +134,10 @@ export const defaultFilterFNs = {
|
|
|
144
134
|
contains: containsFilterFN,
|
|
145
135
|
empty: emptyFilterFN,
|
|
146
136
|
endsWith: endsWithFilterFN,
|
|
147
|
-
greaterThan: greaterThanFilterFN,
|
|
148
|
-
lessThan: lessThanFilterFN,
|
|
149
137
|
equals: equalsFilterFN,
|
|
150
138
|
fuzzy: fuzzyFilterFN,
|
|
139
|
+
greaterThan: greaterThanFilterFN,
|
|
140
|
+
lessThan: lessThanFilterFN,
|
|
151
141
|
notEmpty: notEmptyFilterFN,
|
|
152
142
|
notEquals: notEqualsFilterFN,
|
|
153
143
|
startsWith: startsWithFilterFN,
|
|
@@ -149,6 +149,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
149
149
|
<Tooltip arrow title={localization.changeFilterMode}>
|
|
150
150
|
<span>
|
|
151
151
|
<IconButton
|
|
152
|
+
aria-label={localization.changeFilterMode}
|
|
152
153
|
onClick={handleFilterMenuOpen}
|
|
153
154
|
size="small"
|
|
154
155
|
sx={{ height: '1.75rem', width: '1.75rem' }}
|
|
@@ -102,15 +102,16 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
102
102
|
setAnchorEl(null);
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
+
const handleShowAllColumns = () => {
|
|
106
|
+
tableInstance.toggleHideAllColumns(false);
|
|
107
|
+
setAnchorEl(null);
|
|
108
|
+
};
|
|
109
|
+
|
|
105
110
|
const handleOpenFilterModeMenu = (event: React.MouseEvent<HTMLElement>) => {
|
|
106
111
|
event.stopPropagation();
|
|
107
112
|
setFilterMenuAnchorEl(event.currentTarget);
|
|
108
113
|
};
|
|
109
114
|
|
|
110
|
-
const handleShowAllColumns = () => {
|
|
111
|
-
tableInstance.toggleHideAllColumns(false);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
115
|
const handleOpenShowHideColumnsMenu = (
|
|
115
116
|
event: React.MouseEvent<HTMLElement>,
|
|
116
117
|
) => {
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import React, { FC, useEffect
|
|
2
|
-
import {
|
|
3
|
-
LinearProgress,
|
|
4
|
-
Paper,
|
|
5
|
-
TableContainer,
|
|
6
|
-
Collapse,
|
|
7
|
-
Box,
|
|
8
|
-
} from '@mui/material';
|
|
1
|
+
import React, { FC, useEffect } from 'react';
|
|
2
|
+
import { Paper, TableContainer, Box } from '@mui/material';
|
|
9
3
|
import { useMRT } from '../useMRT';
|
|
10
4
|
import { MRT_Table } from './MRT_Table';
|
|
11
5
|
import { MRT_ToolbarTop } from '../toolbar/MRT_ToolbarTop';
|
|
@@ -17,28 +11,17 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
17
11
|
const {
|
|
18
12
|
hideToolbarBottom,
|
|
19
13
|
hideToolbarTop,
|
|
20
|
-
isFetching,
|
|
21
|
-
isLoading,
|
|
22
|
-
muiLinearProgressProps,
|
|
23
14
|
muiTableContainerProps,
|
|
24
15
|
tableInstance,
|
|
25
16
|
} = useMRT();
|
|
26
17
|
const fullScreen = tableInstance.state.fullScreen;
|
|
27
|
-
const originalBodyOverflowStyle = useRef<string | undefined>();
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (typeof window !== 'undefined') {
|
|
31
|
-
originalBodyOverflowStyle.current = document?.body?.style?.overflow;
|
|
32
|
-
}
|
|
33
|
-
}, []);
|
|
34
18
|
|
|
35
19
|
useEffect(() => {
|
|
36
20
|
if (typeof window !== 'undefined') {
|
|
37
21
|
if (fullScreen) {
|
|
38
22
|
document.body.style.overflow = 'hidden';
|
|
39
23
|
} else {
|
|
40
|
-
document.body.style.overflow =
|
|
41
|
-
originalBodyOverflowStyle.current ?? 'auto';
|
|
24
|
+
document.body.style.overflow = 'auto';
|
|
42
25
|
}
|
|
43
26
|
}
|
|
44
27
|
}, [fullScreen]);
|
|
@@ -48,11 +31,6 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
48
31
|
? muiTableContainerProps(tableInstance)
|
|
49
32
|
: muiTableContainerProps;
|
|
50
33
|
|
|
51
|
-
const linearProgressProps =
|
|
52
|
-
muiLinearProgressProps instanceof Function
|
|
53
|
-
? muiLinearProgressProps(tableInstance)
|
|
54
|
-
: muiLinearProgressProps;
|
|
55
|
-
|
|
56
34
|
return (
|
|
57
35
|
<TableContainer
|
|
58
36
|
component={Paper}
|
|
@@ -62,6 +40,7 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
62
40
|
height: fullScreen ? '100%' : undefined,
|
|
63
41
|
left: fullScreen ? '0' : undefined,
|
|
64
42
|
m: fullScreen ? '0' : undefined,
|
|
43
|
+
overflowY: 'hidden',
|
|
65
44
|
position: fullScreen ? 'fixed' : undefined,
|
|
66
45
|
right: fullScreen ? '0' : undefined,
|
|
67
46
|
top: fullScreen ? '0' : undefined,
|
|
@@ -72,9 +51,6 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
72
51
|
}}
|
|
73
52
|
>
|
|
74
53
|
{!hideToolbarTop && <MRT_ToolbarTop />}
|
|
75
|
-
<Collapse in={isFetching || isLoading} unmountOnExit>
|
|
76
|
-
<LinearProgress {...linearProgressProps} />
|
|
77
|
-
</Collapse>
|
|
78
54
|
<Box
|
|
79
55
|
sx={{
|
|
80
56
|
maxWidth: '100%',
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { Collapse, LinearProgress } from '@mui/material';
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
|
+
|
|
5
|
+
interface Props {}
|
|
6
|
+
|
|
7
|
+
export const MRT_LinearProgressBar: FC<Props> = () => {
|
|
8
|
+
const { muiLinearProgressProps, isFetching, isLoading, tableInstance } =
|
|
9
|
+
useMRT();
|
|
10
|
+
|
|
11
|
+
const linearProgressProps =
|
|
12
|
+
muiLinearProgressProps instanceof Function
|
|
13
|
+
? muiLinearProgressProps(tableInstance)
|
|
14
|
+
: muiLinearProgressProps;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Collapse in={isFetching || isLoading} unmountOnExit>
|
|
18
|
+
<LinearProgress
|
|
19
|
+
aria-label="Loading"
|
|
20
|
+
aria-busy="true"
|
|
21
|
+
{...linearProgressProps}
|
|
22
|
+
/>
|
|
23
|
+
</Collapse>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Box, Toolbar } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
5
5
|
import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
|
|
6
6
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
7
|
+
import { MRT_LinearProgressBar } from './MRT_LinearProgressBar';
|
|
8
|
+
import { commonToolbarStyles } from './MRT_ToolbarTop';
|
|
7
9
|
|
|
8
10
|
interface Props {}
|
|
9
11
|
|
|
@@ -29,33 +31,28 @@ export const MRT_ToolbarBottom: FC<Props> = () => {
|
|
|
29
31
|
{...toolbarProps}
|
|
30
32
|
sx={(theme) =>
|
|
31
33
|
({
|
|
32
|
-
backgroundColor: theme.palette.background.default,
|
|
33
|
-
backgroundImage: `linear-gradient(${alpha(
|
|
34
|
-
theme.palette.common.white,
|
|
35
|
-
0.05,
|
|
36
|
-
)},${alpha(theme.palette.common.white, 0.05)})`,
|
|
37
34
|
bottom: tableInstance.state.fullScreen ? '0' : undefined,
|
|
38
|
-
display: 'flex',
|
|
39
|
-
justifyContent: 'space-between',
|
|
40
|
-
overflowY: 'hidden',
|
|
41
|
-
p: '0 0.5rem !important',
|
|
42
35
|
position: tableInstance.state.fullScreen ? 'fixed' : undefined,
|
|
43
|
-
|
|
44
|
-
zIndex: 1,
|
|
36
|
+
...commonToolbarStyles(theme, tableInstance),
|
|
45
37
|
...toolbarProps?.sx,
|
|
46
38
|
} as any)
|
|
47
39
|
}
|
|
48
40
|
>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<MRT_TablePagination />
|
|
41
|
+
<MRT_LinearProgressBar />
|
|
42
|
+
<Box
|
|
43
|
+
sx={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}
|
|
44
|
+
>
|
|
45
|
+
{!hideToolbarInternalActions && positionToolbarActions === 'bottom' ? (
|
|
46
|
+
<MRT_ToolbarInternalButtons />
|
|
47
|
+
) : (
|
|
48
|
+
<span />
|
|
58
49
|
)}
|
|
50
|
+
{positionToolbarAlertBanner === 'bottom' && <MRT_ToolbarAlertBanner />}
|
|
51
|
+
{!manualPagination &&
|
|
52
|
+
['bottom', 'both'].includes(positionPagination ?? '') && (
|
|
53
|
+
<MRT_TablePagination />
|
|
54
|
+
)}
|
|
55
|
+
</Box>
|
|
59
56
|
</Toolbar>
|
|
60
57
|
);
|
|
61
58
|
};
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { alpha, Box, Toolbar } from '@mui/material';
|
|
2
|
+
import { alpha, Box, Theme, Toolbar } from '@mui/material';
|
|
3
3
|
import { MRT_SearchTextField } from '../inputs/MRT_SearchTextField';
|
|
4
4
|
import { useMRT } from '../useMRT';
|
|
5
5
|
import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
|
|
6
6
|
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
7
7
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
8
|
+
import { MRT_LinearProgressBar } from './MRT_LinearProgressBar';
|
|
9
|
+
import { MRT_TableInstance } from '..';
|
|
10
|
+
|
|
11
|
+
export const commonToolbarStyles = (
|
|
12
|
+
theme: Theme,
|
|
13
|
+
tableInstance: MRT_TableInstance,
|
|
14
|
+
) => ({
|
|
15
|
+
backgroundColor: theme.palette.background.default,
|
|
16
|
+
backgroundImage: `linear-gradient(${alpha(
|
|
17
|
+
theme.palette.common.white,
|
|
18
|
+
0.05,
|
|
19
|
+
)},${alpha(theme.palette.common.white, 0.05)})`,
|
|
20
|
+
display: 'grid',
|
|
21
|
+
opacity: tableInstance.state.fullScreen ? 0.95 : 1,
|
|
22
|
+
p: '0 !important',
|
|
23
|
+
width: '100%',
|
|
24
|
+
zIndex: 1,
|
|
25
|
+
});
|
|
8
26
|
|
|
9
27
|
interface Props {}
|
|
10
28
|
|
|
@@ -32,17 +50,9 @@ export const MRT_ToolbarTop: FC<Props> = () => {
|
|
|
32
50
|
{...toolbarProps}
|
|
33
51
|
sx={(theme) =>
|
|
34
52
|
({
|
|
35
|
-
backgroundColor: theme.palette.background.default,
|
|
36
|
-
backgroundImage: `linear-gradient(${alpha(
|
|
37
|
-
theme.palette.common.white,
|
|
38
|
-
0.05,
|
|
39
|
-
)},${alpha(theme.palette.common.white, 0.05)})`,
|
|
40
|
-
display: 'grid',
|
|
41
|
-
p: '0 !important',
|
|
42
53
|
position: tableInstance.state.fullScreen ? 'sticky' : undefined,
|
|
43
54
|
top: tableInstance.state.fullScreen ? '0' : undefined,
|
|
44
|
-
|
|
45
|
-
zIndex: 1,
|
|
55
|
+
...commonToolbarStyles(theme, tableInstance),
|
|
46
56
|
...toolbarProps?.sx,
|
|
47
57
|
} as any)
|
|
48
58
|
}
|
|
@@ -76,6 +86,7 @@ export const MRT_ToolbarTop: FC<Props> = () => {
|
|
|
76
86
|
<MRT_TablePagination />
|
|
77
87
|
)}
|
|
78
88
|
</div>
|
|
89
|
+
<MRT_LinearProgressBar />
|
|
79
90
|
</Toolbar>
|
|
80
91
|
);
|
|
81
92
|
};
|