material-react-table 1.0.0-beta.10 → 1.0.0-beta.11

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.
@@ -1,4 +1,4 @@
1
- import React, { useMemo, useRef, useState, useCallback, Fragment, memo, useEffect, useLayoutEffect } from 'react';
1
+ import React, { useMemo, useRef, useState, useCallback, useEffect, Fragment, memo, useLayoutEffect } from 'react';
2
2
  import { aggregationFns, filterFns, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
3
3
  import { ArrowRight, Cancel, CheckBox, ClearAll, Close, DensityLarge, DensityMedium, DensitySmall, DragHandle, DynamicFeed, Edit, ExpandLess, ExpandMore, FilterAlt, FilterAltOff, FilterList, FilterListOff, FullscreenExit, Fullscreen, KeyboardDoubleArrowDown, MoreHoriz, MoreVert, PushPin, RestartAlt, Save, Search, SearchOff, Sort, ViewColumn, VisibilityOff } from '@mui/icons-material';
4
4
  import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
@@ -1043,6 +1043,9 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
1043
1043
  var _a;
1044
1044
  const { getState, setGlobalFilter, options: { enableGlobalFilterModes, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps, }, refs: { searchInputRef }, } = table;
1045
1045
  const { globalFilter, showGlobalFilter } = getState();
1046
+ const textFieldProps = muiSearchTextFieldProps instanceof Function
1047
+ ? muiSearchTextFieldProps({ table })
1048
+ : muiSearchTextFieldProps;
1046
1049
  const [anchorEl, setAnchorEl] = useState(null);
1047
1050
  const [searchValue, setSearchValue] = useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
1048
1051
  const handleChangeDebounced = useCallback(debounce((event) => {
@@ -1060,9 +1063,11 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
1060
1063
  setSearchValue('');
1061
1064
  setGlobalFilter(undefined);
1062
1065
  };
1063
- const textFieldProps = muiSearchTextFieldProps instanceof Function
1064
- ? muiSearchTextFieldProps({ table })
1065
- : muiSearchTextFieldProps;
1066
+ useEffect(() => {
1067
+ if (globalFilter === undefined) {
1068
+ handleClear();
1069
+ }
1070
+ }, [globalFilter]);
1066
1071
  return (React.createElement(Collapse, { in: showGlobalFilter, orientation: "horizontal", unmountOnExit: true, mountOnEnter: true },
1067
1072
  React.createElement(TextField, Object.assign({ placeholder: localization.search, onChange: handleChange, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard", InputProps: {
1068
1073
  startAdornment: enableGlobalFilterModes ? (React.createElement(InputAdornment, { position: "start" },
@@ -1495,6 +1500,11 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1495
1500
  const handleFilterMenuOpen = (event) => {
1496
1501
  setAnchorEl(event.currentTarget);
1497
1502
  };
1503
+ useEffect(() => {
1504
+ if (column.getFilterValue() === undefined) {
1505
+ handleClear();
1506
+ }
1507
+ }, [column.getFilterValue()]);
1498
1508
  if (columnDef.Filter) {
1499
1509
  return React.createElement(React.Fragment, null, (_e = columnDef.Filter) === null || _e === void 0 ? void 0 : _e.call(columnDef, { column, header, table }));
1500
1510
  }
@@ -1556,7 +1566,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1556
1566
  ? '90px'
1557
1567
  : !filterChipLabel
1558
1568
  ? '120px'
1559
- : 'auto', width: '100%', '& .MuiSelect-icon': {
1569
+ : 'auto', width: '100%', '& .MuiSelect-icon': {
1560
1570
  mr: '1.5rem',
1561
1571
  } }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
1562
1572
  ? textFieldProps.sx(theme)