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 +25 -20
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/MaterialReactTable.d.ts +3 -0
- package/dist/cjs/types/icons.d.ts +0 -2
- package/dist/cjs/types/table/MRT_TableRoot.d.ts +1 -0
- package/dist/cjs/types/toolbar/MRT_BottomToolbar.d.ts +1 -1
- package/dist/esm/material-react-table.esm.js +25 -18
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/MaterialReactTable.d.ts +3 -0
- package/dist/esm/types/icons.d.ts +0 -2
- package/dist/esm/types/table/MRT_TableRoot.d.ts +1 -0
- package/dist/esm/types/toolbar/MRT_BottomToolbar.d.ts +1 -1
- package/dist/index.d.ts +3 -2
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +3 -0
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +7 -5
- package/src/icons.ts +0 -6
- package/src/inputs/MRT_FilterTextField.tsx +3 -1
- package/src/table/MRT_TableRoot.tsx +5 -0
- package/src/toolbar/MRT_BottomToolbar.tsx +2 -2
- package/src/toolbar/MRT_ToolbarDropZone.tsx +16 -11
@@ -176,6 +176,7 @@ export type MRT_TableInstance<TData extends Record<string, any> = {}> = Omit<Tab
|
|
176
176
|
setShowAlertBanner: Dispatch<SetStateAction<boolean>>;
|
177
177
|
setShowFilters: Dispatch<SetStateAction<boolean>>;
|
178
178
|
setShowGlobalFilter: Dispatch<SetStateAction<boolean>>;
|
179
|
+
setShowToolbarDropZone: Dispatch<SetStateAction<boolean>>;
|
179
180
|
};
|
180
181
|
export type MRT_TableState<TData extends Record<string, any> = {}> = TableState & {
|
181
182
|
columnFilterFns: Record<string, MRT_FilterOption>;
|
@@ -198,6 +199,7 @@ export type MRT_TableState<TData extends Record<string, any> = {}> = TableState
|
|
198
199
|
showGlobalFilter: boolean;
|
199
200
|
showProgressBars: boolean;
|
200
201
|
showSkeletons: boolean;
|
202
|
+
showToolbarDropZone: boolean;
|
201
203
|
};
|
202
204
|
export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<ColumnDef<TData, unknown>, 'accessorKey' | 'aggregatedCell' | 'aggregationFn' | 'cell' | 'columns' | 'filterFn' | 'footer' | 'header' | 'id' | 'sortingFn'> & {
|
203
205
|
AggregatedCell?: ({ cell, column, row, table, }: {
|
@@ -636,6 +638,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> = Om
|
|
636
638
|
onShowAlertBannerChange?: OnChangeFn<boolean>;
|
637
639
|
onShowFiltersChange?: OnChangeFn<boolean>;
|
638
640
|
onShowGlobalFilterChange?: OnChangeFn<boolean>;
|
641
|
+
onShowToolbarDropZoneChange?: OnChangeFn<boolean>;
|
639
642
|
positionActionsColumn?: 'first' | 'last';
|
640
643
|
positionExpandColumn?: 'first' | 'last';
|
641
644
|
positionGlobalFilter?: 'left' | 'right' | 'none';
|
@@ -2,7 +2,6 @@ export interface MRT_Icons {
|
|
2
2
|
ArrowDownwardIcon: any;
|
3
3
|
ArrowRightIcon: any;
|
4
4
|
CancelIcon: any;
|
5
|
-
CheckBoxIcon: any;
|
6
5
|
ClearAllIcon: any;
|
7
6
|
CloseIcon: any;
|
8
7
|
DensityLargeIcon: any;
|
@@ -15,7 +14,6 @@ export interface MRT_Icons {
|
|
15
14
|
ExpandLessIcon: any;
|
16
15
|
ExpandMoreIcon: any;
|
17
16
|
FilterAltIcon: any;
|
18
|
-
FilterAltOffIcon: any;
|
19
17
|
FilterListIcon: any;
|
20
18
|
FilterListOffIcon: any;
|
21
19
|
FullscreenExitIcon: any;
|
@@ -199,6 +199,7 @@ export declare const MRT_TableRoot: <TData extends Record<string, any> = {}>(pro
|
|
199
199
|
onShowAlertBannerChange?: import("@tanstack/react-table").OnChangeFn<boolean> | undefined;
|
200
200
|
onShowFiltersChange?: import("@tanstack/react-table").OnChangeFn<boolean> | undefined;
|
201
201
|
onShowGlobalFilterChange?: import("@tanstack/react-table").OnChangeFn<boolean> | undefined;
|
202
|
+
onShowToolbarDropZoneChange?: import("@tanstack/react-table").OnChangeFn<boolean> | undefined;
|
202
203
|
positionActionsColumn?: "first" | "last" | undefined;
|
203
204
|
positionExpandColumn?: "first" | "last" | undefined;
|
204
205
|
positionGlobalFilter?: "left" | "right" | "none" | undefined;
|
@@ -5,7 +5,6 @@ import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
|
|
5
5
|
import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
|
6
6
|
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
|
7
7
|
import CancelIcon from '@mui/icons-material/Cancel';
|
8
|
-
import CheckBoxIcon from '@mui/icons-material/CheckBox';
|
9
8
|
import ClearAllIcon from '@mui/icons-material/ClearAll';
|
10
9
|
import CloseIcon from '@mui/icons-material/Close';
|
11
10
|
import DensityLargeIcon from '@mui/icons-material/DensityLarge';
|
@@ -17,7 +16,6 @@ import EditIcon from '@mui/icons-material/Edit';
|
|
17
16
|
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
18
17
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
19
18
|
import FilterAltIcon from '@mui/icons-material/FilterAlt';
|
20
|
-
import FilterAltOffIcon from '@mui/icons-material/FilterAltOff';
|
21
19
|
import FilterListIcon from '@mui/icons-material/FilterList';
|
22
20
|
import FilterListOffIcon from '@mui/icons-material/FilterListOff';
|
23
21
|
import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
|
@@ -371,7 +369,6 @@ const MRT_Default_Icons = {
|
|
371
369
|
ArrowDownwardIcon,
|
372
370
|
ArrowRightIcon,
|
373
371
|
CancelIcon,
|
374
|
-
CheckBoxIcon,
|
375
372
|
ClearAllIcon,
|
376
373
|
CloseIcon,
|
377
374
|
DensityLargeIcon,
|
@@ -383,7 +380,6 @@ const MRT_Default_Icons = {
|
|
383
380
|
ExpandLessIcon,
|
384
381
|
ExpandMoreIcon,
|
385
382
|
FilterAltIcon,
|
386
|
-
FilterAltOffIcon,
|
387
383
|
FilterListIcon,
|
388
384
|
FilterListOffIcon,
|
389
385
|
FullscreenExitIcon,
|
@@ -1242,7 +1238,7 @@ const MRT_ShowHideColumnsButton = (_a) => {
|
|
1242
1238
|
React.createElement(Tooltip, { arrow: true, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideColumns },
|
1243
1239
|
React.createElement(IconButton, Object.assign({ "aria-label": localization.showHideColumns, onClick: handleClick }, rest, { title: undefined }),
|
1244
1240
|
React.createElement(ViewColumnIcon, null))),
|
1245
|
-
React.createElement(MRT_ShowHideColumnsMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table })));
|
1241
|
+
anchorEl && (React.createElement(MRT_ShowHideColumnsMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table }))));
|
1246
1242
|
};
|
1247
1243
|
|
1248
1244
|
const MRT_ToggleDensePaddingButton = (_a) => {
|
@@ -1308,15 +1304,21 @@ const MRT_ToolbarInternalButtons = ({ table, }) => {
|
|
1308
1304
|
|
1309
1305
|
const MRT_ToolbarDropZone = ({ table, }) => {
|
1310
1306
|
var _a, _b;
|
1311
|
-
const { getState, options: { enableGrouping, localization }, setHoveredColumn, } = table;
|
1312
|
-
const { draggingColumn, hoveredColumn, grouping } = getState();
|
1307
|
+
const { getState, options: { enableGrouping, localization }, setHoveredColumn, setShowToolbarDropZone, } = table;
|
1308
|
+
const { draggingColumn, hoveredColumn, grouping, showToolbarDropZone } = getState();
|
1313
1309
|
const handleDragEnter = (_event) => {
|
1314
1310
|
setHoveredColumn({ id: 'drop-zone' });
|
1315
1311
|
};
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1312
|
+
useEffect(() => {
|
1313
|
+
var _a;
|
1314
|
+
if (((_a = table.options.state) === null || _a === void 0 ? void 0 : _a.showToolbarDropZone) !== undefined) {
|
1315
|
+
setShowToolbarDropZone(!!enableGrouping &&
|
1316
|
+
!!draggingColumn &&
|
1317
|
+
!grouping.includes(draggingColumn.id));
|
1318
|
+
}
|
1319
|
+
}, [enableGrouping, draggingColumn, grouping]);
|
1320
|
+
return (React.createElement(Fade, { in: showToolbarDropZone },
|
1321
|
+
React.createElement(Box, { className: "Mui-ToolbarDropZone", sx: (theme) => ({
|
1320
1322
|
alignItems: 'center',
|
1321
1323
|
backgroundColor: alpha(theme.palette.info.main, (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone' ? 0.2 : 0.1),
|
1322
1324
|
border: `dashed ${theme.palette.info.main} 2px`,
|
@@ -1553,7 +1555,10 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1553
1555
|
const handleClearEmptyFilterChip = () => {
|
1554
1556
|
setFilterValue('');
|
1555
1557
|
column.setFilterValue(undefined);
|
1556
|
-
setColumnFilterFns((prev) =>
|
1558
|
+
setColumnFilterFns((prev) => {
|
1559
|
+
var _a, _b, _c;
|
1560
|
+
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' }));
|
1561
|
+
});
|
1557
1562
|
};
|
1558
1563
|
const handleFilterMenuOpen = (event) => {
|
1559
1564
|
setAnchorEl(event.currentTarget);
|
@@ -2678,7 +2683,7 @@ const MRT_EditRowModal = ({ open, row, table, }) => {
|
|
2678
2683
|
};
|
2679
2684
|
|
2680
2685
|
const MRT_TableRoot = (props) => {
|
2681
|
-
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;
|
2686
|
+
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;
|
2682
2687
|
const bottomToolbarRef = useRef(null);
|
2683
2688
|
const editInputRefs = useRef({});
|
2684
2689
|
const filterInputRefs = useRef({});
|
@@ -2717,6 +2722,7 @@ const MRT_TableRoot = (props) => {
|
|
2717
2722
|
const [showAlertBanner, setShowAlertBanner] = useState((_o = (_m = props.initialState) === null || _m === void 0 ? void 0 : _m.showAlertBanner) !== null && _o !== void 0 ? _o : false);
|
2718
2723
|
const [showColumnFilters, setShowFilters] = useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _p !== void 0 ? _p : false);
|
2719
2724
|
const [showGlobalFilter, setShowGlobalFilter] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _q !== void 0 ? _q : false);
|
2725
|
+
const [showToolbarDropZone, setShowToolbarDropZone] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _r !== void 0 ? _r : false);
|
2720
2726
|
const displayColumns = useMemo(() => {
|
2721
2727
|
var _a, _b, _c, _d, _e;
|
2722
2728
|
return [
|
@@ -2767,7 +2773,7 @@ const MRT_TableRoot = (props) => {
|
|
2767
2773
|
columnFilterFns,
|
2768
2774
|
displayColumns,
|
2769
2775
|
props.columns,
|
2770
|
-
(
|
2776
|
+
(_s = props.state) === null || _s === void 0 ? void 0 : _s.columnFilterFns,
|
2771
2777
|
]);
|
2772
2778
|
const data = useMemo(() => {
|
2773
2779
|
var _a, _b, _c, _d, _e;
|
@@ -2781,11 +2787,11 @@ const MRT_TableRoot = (props) => {
|
|
2781
2787
|
[getColumnId(col)]: null,
|
2782
2788
|
}))))
|
2783
2789
|
: props.data;
|
2784
|
-
}, [props.data, (
|
2790
|
+
}, [props.data, (_t = props.state) === null || _t === void 0 ? void 0 : _t.isLoading, (_u = props.state) === null || _u === void 0 ? void 0 : _u.showSkeletons]);
|
2785
2791
|
//@ts-ignore
|
2786
2792
|
const table = Object.assign(Object.assign({}, useReactTable(Object.assign(Object.assign({ getCoreRowModel: getCoreRowModel(), getExpandedRowModel: getExpandedRowModel(), getFacetedRowModel: getFacetedRowModel(), getFilteredRowModel: getFilteredRowModel(), getGroupedRowModel: getGroupedRowModel(), getPaginationRowModel: getPaginationRowModel(), getSortedRowModel: getSortedRowModel(), onColumnOrderChange: setColumnOrder, onGroupingChange: setGrouping, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows }, props), {
|
2787
2793
|
//@ts-ignore
|
2788
|
-
columns: columnDefs, data, globalFilterFn: (
|
2794
|
+
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,
|
2789
2795
|
columnOrder,
|
2790
2796
|
density,
|
2791
2797
|
draggingColumn,
|
@@ -2799,7 +2805,8 @@ const MRT_TableRoot = (props) => {
|
|
2799
2805
|
isFullScreen,
|
2800
2806
|
showAlertBanner,
|
2801
2807
|
showColumnFilters,
|
2802
|
-
showGlobalFilter
|
2808
|
+
showGlobalFilter,
|
2809
|
+
showToolbarDropZone }, props.state) }))), { refs: {
|
2803
2810
|
bottomToolbarRef,
|
2804
2811
|
editInputRefs,
|
2805
2812
|
filterInputRefs,
|
@@ -2808,7 +2815,7 @@ const MRT_TableRoot = (props) => {
|
|
2808
2815
|
tableHeadCellRefs,
|
2809
2816
|
tablePaperRef,
|
2810
2817
|
topToolbarRef,
|
2811
|
-
}, setColumnFilterFns: (
|
2818
|
+
}, 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 });
|
2812
2819
|
if (props.tableInstanceRef) {
|
2813
2820
|
props.tableInstanceRef.current = table;
|
2814
2821
|
}
|