material-react-table 0.40.12 → 1.0.0-beta.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/README.md +2 -0
- package/dist/cjs/index.js +17 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/material-react-table.esm.js +17 -8
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/inputs/MRT_FilterTextField.tsx +7 -4
- package/src/inputs/MRT_GlobalFilterTextField.tsx +6 -1
- package/src/toolbar/MRT_BottomToolbar.tsx +3 -0
- package/src/toolbar/MRT_TablePagination.tsx +1 -2
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +6 -8
- package/src/toolbar/MRT_TopToolbar.tsx +6 -2
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import React, {
|
|
|
3
3
|
FC,
|
|
4
4
|
MouseEvent,
|
|
5
5
|
useCallback,
|
|
6
|
+
useEffect,
|
|
6
7
|
useState,
|
|
7
8
|
} from 'react';
|
|
8
9
|
import {
|
|
@@ -17,8 +18,8 @@ import {
|
|
|
17
18
|
TextFieldProps,
|
|
18
19
|
Tooltip,
|
|
19
20
|
} from '@mui/material';
|
|
20
|
-
import { MRT_FilterOptionMenu } from '../menus/MRT_FilterOptionMenu';
|
|
21
21
|
import type { MRT_Header, MRT_TableInstance } from '..';
|
|
22
|
+
import { MRT_FilterOptionMenu } from '../menus/MRT_FilterOptionMenu';
|
|
22
23
|
|
|
23
24
|
interface Props {
|
|
24
25
|
header: MRT_Header;
|
|
@@ -169,6 +170,10 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
169
170
|
setAnchorEl(event.currentTarget);
|
|
170
171
|
};
|
|
171
172
|
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
handleClear();
|
|
175
|
+
}, [columnDef._filterFn]);
|
|
176
|
+
|
|
172
177
|
if (columnDef.Filter) {
|
|
173
178
|
return <>{columnDef.Filter?.({ column, header, table })}</>;
|
|
174
179
|
}
|
|
@@ -241,9 +246,7 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
241
246
|
/>
|
|
242
247
|
)}
|
|
243
248
|
</InputAdornment>
|
|
244
|
-
) :
|
|
245
|
-
<FilterListIcon style={{ marginRight: '4px' }} />
|
|
246
|
-
),
|
|
249
|
+
) : null,
|
|
247
250
|
endAdornment: !filterChipLabel && (
|
|
248
251
|
<InputAdornment position="end">
|
|
249
252
|
<Tooltip
|
|
@@ -62,7 +62,12 @@ export const MRT_GlobalFilterTextField = <
|
|
|
62
62
|
: muiSearchTextFieldProps;
|
|
63
63
|
|
|
64
64
|
return (
|
|
65
|
-
<Collapse
|
|
65
|
+
<Collapse
|
|
66
|
+
in={showGlobalFilter}
|
|
67
|
+
orientation="horizontal"
|
|
68
|
+
unmountOnExit
|
|
69
|
+
mountOnEnter
|
|
70
|
+
>
|
|
66
71
|
<TextField
|
|
67
72
|
placeholder={localization.search}
|
|
68
73
|
onChange={handleChange}
|
|
@@ -53,13 +53,12 @@ export const MRT_TablePagination: FC<Props> = ({ table, position }) => {
|
|
|
53
53
|
showLastButton={showFirstLastPageButtons}
|
|
54
54
|
{...tablePaginationProps}
|
|
55
55
|
sx={(theme) => ({
|
|
56
|
-
m: '0 0.5rem',
|
|
57
56
|
mt:
|
|
58
57
|
position === 'top' &&
|
|
59
58
|
enableToolbarInternalActions &&
|
|
60
59
|
!showGlobalFilter
|
|
61
60
|
? '3.5rem'
|
|
62
|
-
:
|
|
61
|
+
: '-0.25rem',
|
|
63
62
|
position: 'relative',
|
|
64
63
|
zIndex: 2,
|
|
65
64
|
...(tablePaginationProps?.sx instanceof Function
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { Box } from '@mui/material';
|
|
3
3
|
import { MRT_FullScreenToggleButton } from '../buttons/MRT_FullScreenToggleButton';
|
|
4
|
-
import { MRT_GlobalFilterTextField } from '../inputs/MRT_GlobalFilterTextField';
|
|
5
4
|
import { MRT_ShowHideColumnsButton } from '../buttons/MRT_ShowHideColumnsButton';
|
|
6
5
|
import { MRT_ToggleDensePaddingButton } from '../buttons/MRT_ToggleDensePaddingButton';
|
|
7
6
|
import { MRT_ToggleFiltersButton } from '../buttons/MRT_ToggleFiltersButton';
|
|
@@ -23,7 +22,7 @@ export const MRT_ToolbarInternalButtons: FC<Props> = ({ table }) => {
|
|
|
23
22
|
enableGlobalFilter,
|
|
24
23
|
enableHiding,
|
|
25
24
|
enablePinning,
|
|
26
|
-
|
|
25
|
+
initialState,
|
|
27
26
|
renderToolbarInternalActions,
|
|
28
27
|
},
|
|
29
28
|
} = table;
|
|
@@ -40,12 +39,11 @@ export const MRT_ToolbarInternalButtons: FC<Props> = ({ table }) => {
|
|
|
40
39
|
table,
|
|
41
40
|
}) ?? (
|
|
42
41
|
<>
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
)}
|
|
42
|
+
{enableFilters &&
|
|
43
|
+
enableGlobalFilter &&
|
|
44
|
+
!initialState?.showGlobalFilter && (
|
|
45
|
+
<MRT_ToggleGlobalFilterButton table={table} />
|
|
46
|
+
)}
|
|
49
47
|
{enableFilters && enableColumnFilters && (
|
|
50
48
|
<MRT_ToggleFiltersButton table={table} />
|
|
51
49
|
)}
|
|
@@ -100,10 +100,14 @@ export const MRT_TopToolbar: FC<Props> = ({ table }) => {
|
|
|
100
100
|
{enableGlobalFilter && positionGlobalFilter === 'left' && (
|
|
101
101
|
<MRT_GlobalFilterTextField table={table} />
|
|
102
102
|
)}
|
|
103
|
-
|
|
104
103
|
{renderTopToolbarCustomActions?.({ table }) ?? <span />}
|
|
105
104
|
{enableToolbarInternalActions ? (
|
|
106
|
-
<
|
|
105
|
+
<Box sx={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
106
|
+
{enableGlobalFilter && positionGlobalFilter === 'right' && (
|
|
107
|
+
<MRT_GlobalFilterTextField table={table} />
|
|
108
|
+
)}
|
|
109
|
+
<MRT_ToolbarInternalButtons table={table} />
|
|
110
|
+
</Box>
|
|
107
111
|
) : (
|
|
108
112
|
enableGlobalFilter &&
|
|
109
113
|
positionGlobalFilter === 'right' && (
|