material-react-table 1.5.1 → 1.5.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/cjs/index.js CHANGED
@@ -9,7 +9,6 @@ var matchSorterUtils = require('@tanstack/match-sorter-utils');
9
9
  var ArrowDownwardIcon = require('@mui/icons-material/ArrowDownward');
10
10
  var ArrowRightIcon = require('@mui/icons-material/ArrowRight');
11
11
  var CancelIcon = require('@mui/icons-material/Cancel');
12
- var CheckBoxIcon = require('@mui/icons-material/CheckBox');
13
12
  var ClearAllIcon = require('@mui/icons-material/ClearAll');
14
13
  var CloseIcon = require('@mui/icons-material/Close');
15
14
  var DensityLargeIcon = require('@mui/icons-material/DensityLarge');
@@ -21,7 +20,6 @@ var EditIcon = require('@mui/icons-material/Edit');
21
20
  var ExpandLessIcon = require('@mui/icons-material/ExpandLess');
22
21
  var ExpandMoreIcon = require('@mui/icons-material/ExpandMore');
23
22
  var FilterAltIcon = require('@mui/icons-material/FilterAlt');
24
- var FilterAltOffIcon = require('@mui/icons-material/FilterAltOff');
25
23
  var FilterListIcon = require('@mui/icons-material/FilterList');
26
24
  var FilterListOffIcon = require('@mui/icons-material/FilterListOff');
27
25
  var FullscreenExitIcon = require('@mui/icons-material/FullscreenExit');
@@ -86,7 +84,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
86
84
  var ArrowDownwardIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowDownwardIcon);
87
85
  var ArrowRightIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowRightIcon);
88
86
  var CancelIcon__default = /*#__PURE__*/_interopDefaultLegacy(CancelIcon);
89
- var CheckBoxIcon__default = /*#__PURE__*/_interopDefaultLegacy(CheckBoxIcon);
90
87
  var ClearAllIcon__default = /*#__PURE__*/_interopDefaultLegacy(ClearAllIcon);
91
88
  var CloseIcon__default = /*#__PURE__*/_interopDefaultLegacy(CloseIcon);
92
89
  var DensityLargeIcon__default = /*#__PURE__*/_interopDefaultLegacy(DensityLargeIcon);
@@ -98,7 +95,6 @@ var EditIcon__default = /*#__PURE__*/_interopDefaultLegacy(EditIcon);
98
95
  var ExpandLessIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExpandLessIcon);
99
96
  var ExpandMoreIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExpandMoreIcon);
100
97
  var FilterAltIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterAltIcon);
101
- var FilterAltOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterAltOffIcon);
102
98
  var FilterListIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterListIcon);
103
99
  var FilterListOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterListOffIcon);
104
100
  var FullscreenExitIcon__default = /*#__PURE__*/_interopDefaultLegacy(FullscreenExitIcon);
@@ -450,7 +446,6 @@ const MRT_Default_Icons = {
450
446
  ArrowDownwardIcon: ArrowDownwardIcon__default["default"],
451
447
  ArrowRightIcon: ArrowRightIcon__default["default"],
452
448
  CancelIcon: CancelIcon__default["default"],
453
- CheckBoxIcon: CheckBoxIcon__default["default"],
454
449
  ClearAllIcon: ClearAllIcon__default["default"],
455
450
  CloseIcon: CloseIcon__default["default"],
456
451
  DensityLargeIcon: DensityLargeIcon__default["default"],
@@ -462,7 +457,6 @@ const MRT_Default_Icons = {
462
457
  ExpandLessIcon: ExpandLessIcon__default["default"],
463
458
  ExpandMoreIcon: ExpandMoreIcon__default["default"],
464
459
  FilterAltIcon: FilterAltIcon__default["default"],
465
- FilterAltOffIcon: FilterAltOffIcon__default["default"],
466
460
  FilterListIcon: FilterListIcon__default["default"],
467
461
  FilterListOffIcon: FilterListOffIcon__default["default"],
468
462
  FullscreenExitIcon: FullscreenExitIcon__default["default"],
@@ -1321,7 +1315,7 @@ const MRT_ShowHideColumnsButton = (_a) => {
1321
1315
  React__default["default"].createElement(Tooltip__default["default"], { arrow: true, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideColumns },
1322
1316
  React__default["default"].createElement(IconButton__default["default"], Object.assign({ "aria-label": localization.showHideColumns, onClick: handleClick }, rest, { title: undefined }),
1323
1317
  React__default["default"].createElement(ViewColumnIcon, null))),
1324
- React__default["default"].createElement(MRT_ShowHideColumnsMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table })));
1318
+ anchorEl && (React__default["default"].createElement(MRT_ShowHideColumnsMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table }))));
1325
1319
  };
1326
1320
 
1327
1321
  const MRT_ToggleDensePaddingButton = (_a) => {
@@ -1387,15 +1381,21 @@ const MRT_ToolbarInternalButtons = ({ table, }) => {
1387
1381
 
1388
1382
  const MRT_ToolbarDropZone = ({ table, }) => {
1389
1383
  var _a, _b;
1390
- const { getState, options: { enableGrouping, localization }, setHoveredColumn, } = table;
1391
- const { draggingColumn, hoveredColumn, grouping } = getState();
1384
+ const { getState, options: { enableGrouping, localization }, setHoveredColumn, setShowToolbarDropZone, } = table;
1385
+ const { draggingColumn, hoveredColumn, grouping, showToolbarDropZone } = getState();
1392
1386
  const handleDragEnter = (_event) => {
1393
1387
  setHoveredColumn({ id: 'drop-zone' });
1394
1388
  };
1395
- return (React__default["default"].createElement(Fade__default["default"], { unmountOnExit: true, mountOnEnter: true, in: !!enableGrouping &&
1396
- !!draggingColumn &&
1397
- !grouping.includes(draggingColumn.id) },
1398
- React__default["default"].createElement(Box__default["default"], { sx: (theme) => ({
1389
+ React.useEffect(() => {
1390
+ var _a;
1391
+ if (((_a = table.options.state) === null || _a === void 0 ? void 0 : _a.showToolbarDropZone) !== undefined) {
1392
+ setShowToolbarDropZone(!!enableGrouping &&
1393
+ !!draggingColumn &&
1394
+ !grouping.includes(draggingColumn.id));
1395
+ }
1396
+ }, [enableGrouping, draggingColumn, grouping]);
1397
+ return (React__default["default"].createElement(Fade__default["default"], { in: showToolbarDropZone },
1398
+ React__default["default"].createElement(Box__default["default"], { className: "Mui-ToolbarDropZone", sx: (theme) => ({
1399
1399
  alignItems: 'center',
1400
1400
  backgroundColor: styles.alpha(theme.palette.info.main, (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone' ? 0.2 : 0.1),
1401
1401
  border: `dashed ${theme.palette.info.main} 2px`,
@@ -1632,7 +1632,10 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1632
1632
  const handleClearEmptyFilterChip = () => {
1633
1633
  setFilterValue('');
1634
1634
  column.setFilterValue(undefined);
1635
- setColumnFilterFns((prev) => (Object.assign(Object.assign({}, prev), { [header.id]: 'fuzzy' })));
1635
+ setColumnFilterFns((prev) => {
1636
+ var _a, _b, _c;
1637
+ return (Object.assign(Object.assign({}, prev), { [header.id]: (_c = (_b = (_a = columnDef.columnFilterModeOptions) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : columnFilterModeOptions === null || columnFilterModeOptions === void 0 ? void 0 : columnFilterModeOptions[0]) !== null && _c !== void 0 ? _c : 'fuzzy' }));
1638
+ });
1636
1639
  };
1637
1640
  const handleFilterMenuOpen = (event) => {
1638
1641
  setAnchorEl(event.currentTarget);
@@ -2757,7 +2760,7 @@ const MRT_EditRowModal = ({ open, row, table, }) => {
2757
2760
  };
2758
2761
 
2759
2762
  const MRT_TableRoot = (props) => {
2760
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
2763
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
2761
2764
  const bottomToolbarRef = React.useRef(null);
2762
2765
  const editInputRefs = React.useRef({});
2763
2766
  const filterInputRefs = React.useRef({});
@@ -2796,6 +2799,7 @@ const MRT_TableRoot = (props) => {
2796
2799
  const [showAlertBanner, setShowAlertBanner] = React.useState((_o = (_m = props.initialState) === null || _m === void 0 ? void 0 : _m.showAlertBanner) !== null && _o !== void 0 ? _o : false);
2797
2800
  const [showColumnFilters, setShowFilters] = React.useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _p !== void 0 ? _p : false);
2798
2801
  const [showGlobalFilter, setShowGlobalFilter] = React.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _q !== void 0 ? _q : false);
2802
+ const [showToolbarDropZone, setShowToolbarDropZone] = React.useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _r !== void 0 ? _r : false);
2799
2803
  const displayColumns = React.useMemo(() => {
2800
2804
  var _a, _b, _c, _d, _e;
2801
2805
  return [
@@ -2846,7 +2850,7 @@ const MRT_TableRoot = (props) => {
2846
2850
  columnFilterFns,
2847
2851
  displayColumns,
2848
2852
  props.columns,
2849
- (_r = props.state) === null || _r === void 0 ? void 0 : _r.columnFilterFns,
2853
+ (_s = props.state) === null || _s === void 0 ? void 0 : _s.columnFilterFns,
2850
2854
  ]);
2851
2855
  const data = React.useMemo(() => {
2852
2856
  var _a, _b, _c, _d, _e;
@@ -2860,11 +2864,11 @@ const MRT_TableRoot = (props) => {
2860
2864
  [getColumnId(col)]: null,
2861
2865
  }))))
2862
2866
  : props.data;
2863
- }, [props.data, (_s = props.state) === null || _s === void 0 ? void 0 : _s.isLoading, (_t = props.state) === null || _t === void 0 ? void 0 : _t.showSkeletons]);
2867
+ }, [props.data, (_t = props.state) === null || _t === void 0 ? void 0 : _t.isLoading, (_u = props.state) === null || _u === void 0 ? void 0 : _u.showSkeletons]);
2864
2868
  //@ts-ignore
2865
2869
  const table = Object.assign(Object.assign({}, reactTable.useReactTable(Object.assign(Object.assign({ getCoreRowModel: reactTable.getCoreRowModel(), getExpandedRowModel: reactTable.getExpandedRowModel(), getFacetedRowModel: reactTable.getFacetedRowModel(), getFilteredRowModel: reactTable.getFilteredRowModel(), getGroupedRowModel: reactTable.getGroupedRowModel(), getPaginationRowModel: reactTable.getPaginationRowModel(), getSortedRowModel: reactTable.getSortedRowModel(), onColumnOrderChange: setColumnOrder, onGroupingChange: setGrouping, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows }, props), {
2866
2870
  //@ts-ignore
2867
- columns: columnDefs, data, globalFilterFn: (_v = (_u = props.filterFns) === null || _u === void 0 ? void 0 : _u[globalFilterFn]) !== null && _v !== void 0 ? _v : (_w = props.filterFns) === null || _w === void 0 ? void 0 : _w.fuzzy, initialState, state: Object.assign({ columnFilterFns,
2871
+ columns: columnDefs, data, globalFilterFn: (_w = (_v = props.filterFns) === null || _v === void 0 ? void 0 : _v[globalFilterFn]) !== null && _w !== void 0 ? _w : (_x = props.filterFns) === null || _x === void 0 ? void 0 : _x.fuzzy, initialState, state: Object.assign({ columnFilterFns,
2868
2872
  columnOrder,
2869
2873
  density,
2870
2874
  draggingColumn,
@@ -2878,7 +2882,8 @@ const MRT_TableRoot = (props) => {
2878
2882
  isFullScreen,
2879
2883
  showAlertBanner,
2880
2884
  showColumnFilters,
2881
- showGlobalFilter }, props.state) }))), { refs: {
2885
+ showGlobalFilter,
2886
+ showToolbarDropZone }, props.state) }))), { refs: {
2882
2887
  bottomToolbarRef,
2883
2888
  editInputRefs,
2884
2889
  filterInputRefs,
@@ -2887,7 +2892,7 @@ const MRT_TableRoot = (props) => {
2887
2892
  tableHeadCellRefs,
2888
2893
  tablePaperRef,
2889
2894
  topToolbarRef,
2890
- }, setColumnFilterFns: (_x = props.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns, setDensity: (_y = props.onDensityChange) !== null && _y !== void 0 ? _y : setDensity, setDraggingColumn: (_z = props.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn, setDraggingRow: (_0 = props.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow, setEditingCell: (_1 = props.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell, setEditingRow: (_2 = props.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow, setGlobalFilterFn: (_3 = props.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn, setHoveredColumn: (_4 = props.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn, setHoveredRow: (_5 = props.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow, setIsFullScreen: (_6 = props.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen, setShowAlertBanner: (_7 = props.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner, setShowFilters: (_8 = props.onShowFiltersChange) !== null && _8 !== void 0 ? _8 : setShowFilters, setShowGlobalFilter: (_9 = props.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter });
2895
+ }, setColumnFilterFns: (_y = props.onColumnFilterFnsChange) !== null && _y !== void 0 ? _y : setColumnFilterFns, setDensity: (_z = props.onDensityChange) !== null && _z !== void 0 ? _z : setDensity, setDraggingColumn: (_0 = props.onDraggingColumnChange) !== null && _0 !== void 0 ? _0 : setDraggingColumn, setDraggingRow: (_1 = props.onDraggingRowChange) !== null && _1 !== void 0 ? _1 : setDraggingRow, setEditingCell: (_2 = props.onEditingCellChange) !== null && _2 !== void 0 ? _2 : setEditingCell, setEditingRow: (_3 = props.onEditingRowChange) !== null && _3 !== void 0 ? _3 : setEditingRow, setGlobalFilterFn: (_4 = props.onGlobalFilterFnChange) !== null && _4 !== void 0 ? _4 : setGlobalFilterFn, setHoveredColumn: (_5 = props.onHoveredColumnChange) !== null && _5 !== void 0 ? _5 : setHoveredColumn, setHoveredRow: (_6 = props.onHoveredRowChange) !== null && _6 !== void 0 ? _6 : setHoveredRow, setIsFullScreen: (_7 = props.onIsFullScreenChange) !== null && _7 !== void 0 ? _7 : setIsFullScreen, setShowAlertBanner: (_8 = props.onShowAlertBannerChange) !== null && _8 !== void 0 ? _8 : setShowAlertBanner, setShowFilters: (_9 = props.onShowFiltersChange) !== null && _9 !== void 0 ? _9 : setShowFilters, setShowGlobalFilter: (_10 = props.onShowGlobalFilterChange) !== null && _10 !== void 0 ? _10 : setShowGlobalFilter, setShowToolbarDropZone: (_11 = props.onShowToolbarDropZoneChange) !== null && _11 !== void 0 ? _11 : setShowToolbarDropZone });
2891
2896
  if (props.tableInstanceRef) {
2892
2897
  props.tableInstanceRef.current = table;
2893
2898
  }