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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.40.12",
2
+ "version": "1.0.0-beta.1",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
@@ -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 in={showGlobalFilter} orientation="horizontal">
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}
@@ -69,8 +69,11 @@ export const MRT_BottomToolbar: FC<Props> = ({ table }) => {
69
69
  )}
70
70
  <Box
71
71
  sx={{
72
+ alignItems: 'flex-start',
73
+ boxSizing: 'border-box',
72
74
  display: 'flex',
73
75
  justifyContent: 'space-between',
76
+ p: '0.5rem',
74
77
  width: '100%',
75
78
  }}
76
79
  >
@@ -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
- : undefined,
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
- positionGlobalFilter,
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
- {enableGlobalFilter && positionGlobalFilter === 'right' && (
44
- <MRT_GlobalFilterTextField table={table} />
45
- )}
46
- {enableFilters && enableGlobalFilter && (
47
- <MRT_ToggleGlobalFilterButton table={table} />
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
- <MRT_ToolbarInternalButtons table={table} />
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' && (