material-react-table 0.33.6 → 0.35.0
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/MaterialReactTable.d.ts +45 -53
- package/dist/cjs/buttons/MRT_ColumnPinningButtons.d.ts +4 -5
- package/dist/cjs/buttons/MRT_FullScreenToggleButton.d.ts +3 -4
- package/dist/cjs/buttons/MRT_GrabHandleButton.d.ts +4 -4
- package/dist/cjs/buttons/MRT_ShowHideColumnsButton.d.ts +3 -4
- package/dist/cjs/buttons/MRT_ToggleDensePaddingButton.d.ts +3 -4
- package/dist/cjs/buttons/MRT_ToggleFiltersButton.d.ts +3 -4
- package/dist/cjs/buttons/MRT_ToggleGlobalFilterButton.d.ts +3 -4
- package/dist/cjs/index.d.ts +8 -2
- package/dist/cjs/index.js +651 -140
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/inputs/MRT_GlobalFilterTextField.d.ts +3 -4
- package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +3 -4
- package/dist/cjs/menus/MRT_ShowHideColumnsMenu.d.ts +3 -4
- package/dist/cjs/menus/MRT_ShowHideColumnsMenuItems.d.ts +8 -8
- package/dist/cjs/table/MRT_TableRoot.d.ts +0 -1
- package/dist/cjs/toolbar/MRT_ToolbarInternalButtons.d.ts +1 -1
- package/dist/esm/MaterialReactTable.d.ts +45 -53
- package/dist/esm/buttons/MRT_ColumnPinningButtons.d.ts +4 -5
- package/dist/esm/buttons/MRT_FullScreenToggleButton.d.ts +3 -4
- package/dist/esm/buttons/MRT_GrabHandleButton.d.ts +4 -4
- package/dist/esm/buttons/MRT_ShowHideColumnsButton.d.ts +3 -4
- package/dist/esm/buttons/MRT_ToggleDensePaddingButton.d.ts +3 -4
- package/dist/esm/buttons/MRT_ToggleFiltersButton.d.ts +3 -4
- package/dist/esm/buttons/MRT_ToggleGlobalFilterButton.d.ts +3 -4
- package/dist/esm/index.d.ts +8 -2
- package/dist/esm/inputs/MRT_GlobalFilterTextField.d.ts +3 -4
- package/dist/esm/material-react-table.esm.js +644 -141
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +3 -4
- package/dist/esm/menus/MRT_ShowHideColumnsMenu.d.ts +3 -4
- package/dist/esm/menus/MRT_ShowHideColumnsMenuItems.d.ts +8 -8
- package/dist/esm/table/MRT_TableRoot.d.ts +0 -1
- package/dist/esm/toolbar/MRT_ToolbarInternalButtons.d.ts +1 -1
- package/dist/index.d.ts +76 -54
- package/package.json +5 -5
- package/src/MaterialReactTable.tsx +49 -50
- package/src/body/MRT_TableBody.tsx +30 -11
- package/src/body/MRT_TableBodyCell.tsx +17 -18
- package/src/body/MRT_TableBodyRow.tsx +7 -10
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +5 -5
- package/src/buttons/MRT_ColumnPinningButtons.tsx +10 -5
- package/src/buttons/MRT_EditActionButtons.tsx +10 -6
- package/src/buttons/MRT_FullScreenToggleButton.tsx +10 -4
- package/src/buttons/MRT_GrabHandleButton.tsx +5 -5
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +10 -4
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +10 -4
- package/src/buttons/MRT_ToggleFiltersButton.tsx +10 -4
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +10 -4
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +4 -4
- package/src/head/MRT_TableHeadCell.tsx +11 -16
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +11 -12
- package/src/index.tsx +17 -3
- package/src/inputs/MRT_EditCellTextField.tsx +13 -13
- package/src/inputs/MRT_GlobalFilterTextField.tsx +8 -10
- package/src/menus/MRT_FilterOptionMenu.tsx +5 -5
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +13 -10
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +24 -22
- package/src/table/MRT_TableRoot.tsx +59 -66
- package/src/toolbar/MRT_ToolbarDropZone.tsx +6 -10
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +2 -7
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
2
|
import { Button, Menu, Divider, Box } from '@mui/material';
|
|
3
3
|
import { MRT_ShowHideColumnsMenuItems } from './MRT_ShowHideColumnsMenuItems';
|
|
4
4
|
import type { MRT_Column, MRT_TableInstance } from '..';
|
|
5
5
|
import { getDefaultColumnOrderIds } from '../column.utils';
|
|
6
6
|
|
|
7
|
-
interface Props {
|
|
7
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
8
8
|
anchorEl: HTMLElement | null;
|
|
9
9
|
isSubMenu?: boolean;
|
|
10
10
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
11
|
-
table: MRT_TableInstance
|
|
11
|
+
table: MRT_TableInstance<TData>;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const MRT_ShowHideColumnsMenu
|
|
14
|
+
export const MRT_ShowHideColumnsMenu = <
|
|
15
|
+
TData extends Record<string, any> = {},
|
|
16
|
+
>({
|
|
15
17
|
anchorEl,
|
|
16
18
|
isSubMenu,
|
|
17
19
|
setAnchorEl,
|
|
18
20
|
table,
|
|
19
|
-
}) => {
|
|
21
|
+
}: Props<TData>) => {
|
|
20
22
|
const {
|
|
21
23
|
getAllColumns,
|
|
22
24
|
getAllLeafColumns,
|
|
@@ -60,10 +62,11 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
60
62
|
getCenterLeafColumns(),
|
|
61
63
|
getLeftLeafColumns(),
|
|
62
64
|
getRightLeafColumns(),
|
|
63
|
-
]) as MRT_Column[];
|
|
65
|
+
]) as MRT_Column<TData>[];
|
|
64
66
|
|
|
65
|
-
const [
|
|
66
|
-
|
|
67
|
+
const [hoveredColumn, setHoveredColumn] = useState<MRT_Column<TData> | null>(
|
|
68
|
+
null,
|
|
69
|
+
);
|
|
67
70
|
|
|
68
71
|
return (
|
|
69
72
|
<Menu
|
|
@@ -121,10 +124,10 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
121
124
|
<MRT_ShowHideColumnsMenuItems
|
|
122
125
|
allColumns={allColumns}
|
|
123
126
|
column={column}
|
|
124
|
-
|
|
127
|
+
hoveredColumn={hoveredColumn}
|
|
125
128
|
isSubMenu={isSubMenu}
|
|
126
129
|
key={`${index}-${column.id}`}
|
|
127
|
-
|
|
130
|
+
setHoveredColumn={setHoveredColumn}
|
|
128
131
|
table={table}
|
|
129
132
|
/>
|
|
130
133
|
))}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
Dispatch,
|
|
3
3
|
DragEvent,
|
|
4
|
-
FC,
|
|
5
4
|
SetStateAction,
|
|
5
|
+
useRef,
|
|
6
6
|
useState,
|
|
7
7
|
} from 'react';
|
|
8
8
|
import {
|
|
@@ -18,23 +18,25 @@ import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
|
|
18
18
|
import { reorderColumn } from '../column.utils';
|
|
19
19
|
import type { MRT_Column, MRT_TableInstance } from '..';
|
|
20
20
|
|
|
21
|
-
interface Props {
|
|
22
|
-
allColumns: MRT_Column[];
|
|
23
|
-
column: MRT_Column
|
|
24
|
-
|
|
21
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
22
|
+
allColumns: MRT_Column<TData>[];
|
|
23
|
+
column: MRT_Column<TData>;
|
|
24
|
+
hoveredColumn: MRT_Column<TData> | null;
|
|
25
25
|
isSubMenu?: boolean;
|
|
26
|
-
|
|
27
|
-
table: MRT_TableInstance
|
|
26
|
+
setHoveredColumn: Dispatch<SetStateAction<MRT_Column<TData> | null>>;
|
|
27
|
+
table: MRT_TableInstance<TData>;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export const MRT_ShowHideColumnsMenuItems
|
|
30
|
+
export const MRT_ShowHideColumnsMenuItems = <
|
|
31
|
+
TData extends Record<string, any> = {},
|
|
32
|
+
>({
|
|
31
33
|
allColumns,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
hoveredColumn,
|
|
35
|
+
setHoveredColumn,
|
|
34
36
|
column,
|
|
35
37
|
isSubMenu,
|
|
36
38
|
table,
|
|
37
|
-
}) => {
|
|
39
|
+
}: Props<TData>) => {
|
|
38
40
|
const {
|
|
39
41
|
getState,
|
|
40
42
|
options: {
|
|
@@ -54,9 +56,9 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
54
56
|
(columnDefType === 'group' &&
|
|
55
57
|
column.getLeafColumns().some((col) => col.getIsVisible()));
|
|
56
58
|
|
|
57
|
-
const handleToggleColumnHidden = (column: MRT_Column) => {
|
|
59
|
+
const handleToggleColumnHidden = (column: MRT_Column<TData>) => {
|
|
58
60
|
if (columnDefType === 'group') {
|
|
59
|
-
column?.columns?.forEach?.((childColumn: MRT_Column) => {
|
|
61
|
+
column?.columns?.forEach?.((childColumn: MRT_Column<TData>) => {
|
|
60
62
|
childColumn.toggleVisibility(!switchChecked);
|
|
61
63
|
});
|
|
62
64
|
} else {
|
|
@@ -64,7 +66,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
64
66
|
}
|
|
65
67
|
};
|
|
66
68
|
|
|
67
|
-
const menuItemRef =
|
|
69
|
+
const menuItemRef = useRef<HTMLElement>(null);
|
|
68
70
|
|
|
69
71
|
const [isDragging, setIsDragging] = useState(false);
|
|
70
72
|
|
|
@@ -75,15 +77,15 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
75
77
|
|
|
76
78
|
const handleDragEnd = (_e: DragEvent<HTMLButtonElement>) => {
|
|
77
79
|
setIsDragging(false);
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
setColumnOrder(reorderColumn(column,
|
|
80
|
+
setHoveredColumn(null);
|
|
81
|
+
if (hoveredColumn) {
|
|
82
|
+
setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
|
|
81
83
|
}
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
const handleDragEnter = (_e: DragEvent) => {
|
|
85
87
|
if (!isDragging) {
|
|
86
|
-
|
|
88
|
+
setHoveredColumn(column);
|
|
87
89
|
}
|
|
88
90
|
};
|
|
89
91
|
|
|
@@ -100,7 +102,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
100
102
|
opacity: isDragging ? 0.5 : 1,
|
|
101
103
|
outline: isDragging
|
|
102
104
|
? `1px dashed ${theme.palette.divider}`
|
|
103
|
-
:
|
|
105
|
+
: hoveredColumn?.id === column.id
|
|
104
106
|
? `2px dashed ${theme.palette.primary.main}`
|
|
105
107
|
: 'none',
|
|
106
108
|
pl: `${(column.depth + 0.5) * 2}rem`,
|
|
@@ -172,14 +174,14 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
172
174
|
)}
|
|
173
175
|
</Box>
|
|
174
176
|
</MenuItem>
|
|
175
|
-
{column.columns?.map((c: MRT_Column
|
|
177
|
+
{column.columns?.map((c: MRT_Column<TData>, i) => (
|
|
176
178
|
<MRT_ShowHideColumnsMenuItems
|
|
177
179
|
allColumns={allColumns}
|
|
178
180
|
column={c}
|
|
179
|
-
|
|
181
|
+
hoveredColumn={hoveredColumn}
|
|
180
182
|
isSubMenu={isSubMenu}
|
|
181
183
|
key={`${i}-${c.id}`}
|
|
182
|
-
|
|
184
|
+
setHoveredColumn={setHoveredColumn}
|
|
183
185
|
table={table}
|
|
184
186
|
/>
|
|
185
187
|
))}
|
|
@@ -48,31 +48,57 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
48
48
|
const initState = props.initialState ?? {};
|
|
49
49
|
initState.columnOrder =
|
|
50
50
|
initState.columnOrder ?? getDefaultColumnOrderIds(props);
|
|
51
|
+
initState.columnFilterFns = Object.assign(
|
|
52
|
+
{},
|
|
53
|
+
...getAllLeafColumnDefs(props.columns as MRT_ColumnDef<TData>[]).map(
|
|
54
|
+
(col) => ({
|
|
55
|
+
[col.id?.toString() ?? col.accessorKey?.toString() ?? '']:
|
|
56
|
+
col.filterFn instanceof Function
|
|
57
|
+
? col.filterFn.name ?? 'custom'
|
|
58
|
+
: col.filterFn ??
|
|
59
|
+
initialState?.columnFilterFns?.[
|
|
60
|
+
col.id?.toString() ?? col.accessorKey?.toString() ?? ''
|
|
61
|
+
] ??
|
|
62
|
+
getDefaultColumnFilterFn(col),
|
|
63
|
+
}),
|
|
64
|
+
),
|
|
65
|
+
);
|
|
66
|
+
initState.globalFilterFn =
|
|
67
|
+
props.globalFilterFn instanceof String
|
|
68
|
+
? (props.globalFilterFn as MRT_FilterOption)
|
|
69
|
+
: 'fuzzy';
|
|
51
70
|
return initState;
|
|
52
71
|
}, []);
|
|
53
72
|
|
|
73
|
+
const [columnFilterFns, setColumnFilterFns] = useState<{
|
|
74
|
+
[key: string]: MRT_FilterOption;
|
|
75
|
+
}>(initialState.columnFilterFns ?? {});
|
|
54
76
|
const [columnOrder, setColumnOrder] = useState(
|
|
55
77
|
initialState.columnOrder ?? [],
|
|
56
78
|
);
|
|
57
|
-
const [currentDraggingColumn, setCurrentDraggingColumn] =
|
|
58
|
-
useState<MRT_Column<TData> | null>(
|
|
59
|
-
initialState.currentDraggingColumn ?? null,
|
|
60
|
-
);
|
|
61
|
-
const [currentDraggingRow, setCurrentDraggingRow] =
|
|
62
|
-
useState<MRT_Row<TData> | null>(initialState.currentDraggingRow ?? null);
|
|
63
|
-
const [currentEditingCell, setCurrentEditingCell] =
|
|
64
|
-
useState<MRT_Cell<TData> | null>(initialState.currentEditingCell ?? null);
|
|
65
|
-
const [currentEditingRow, setCurrentEditingRow] =
|
|
66
|
-
useState<MRT_Row<TData> | null>(initialState.currentEditingRow ?? null);
|
|
67
|
-
const [currentHoveredColumn, setCurrentHoveredColumn] = useState<
|
|
68
|
-
MRT_Column<TData> | { id: string } | null
|
|
69
|
-
>(initialState.currentHoveredColumn ?? null);
|
|
70
|
-
const [currentHoveredRow, setCurrentHoveredRow] = useState<
|
|
71
|
-
MRT_Row<TData> | { id: string } | null
|
|
72
|
-
>(initialState.currentHoveredRow ?? null);
|
|
73
79
|
const [density, setDensity] = useState(
|
|
74
80
|
initialState?.density ?? 'comfortable',
|
|
75
81
|
);
|
|
82
|
+
const [draggingColumn, setDraggingColumn] =
|
|
83
|
+
useState<MRT_Column<TData> | null>(initialState.draggingColumn ?? null);
|
|
84
|
+
const [draggingRow, setDraggingRow] = useState<MRT_Row<TData> | null>(
|
|
85
|
+
initialState.draggingRow ?? null,
|
|
86
|
+
);
|
|
87
|
+
const [editingCell, setEditingCell] = useState<MRT_Cell<TData> | null>(
|
|
88
|
+
initialState.editingCell ?? null,
|
|
89
|
+
);
|
|
90
|
+
const [editingRow, setEditingRow] = useState<MRT_Row<TData> | null>(
|
|
91
|
+
initialState.editingRow ?? null,
|
|
92
|
+
);
|
|
93
|
+
const [globalFilterFn, setGlobalFilterFn] = useState<MRT_FilterOption>(
|
|
94
|
+
initialState.globalFilterFn ?? 'fuzzy',
|
|
95
|
+
);
|
|
96
|
+
const [hoveredColumn, setHoveredColumn] = useState<
|
|
97
|
+
MRT_Column<TData> | { id: string } | null
|
|
98
|
+
>(initialState.hoveredColumn ?? null);
|
|
99
|
+
const [hoveredRow, setHoveredRow] = useState<
|
|
100
|
+
MRT_Row<TData> | { id: string } | null
|
|
101
|
+
>(initialState.hoveredRow ?? null);
|
|
76
102
|
const [isFullScreen, setIsFullScreen] = useState(
|
|
77
103
|
initialState?.isFullScreen ?? false,
|
|
78
104
|
);
|
|
@@ -85,30 +111,6 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
85
111
|
const [showGlobalFilter, setShowGlobalFilter] = useState(
|
|
86
112
|
initialState?.showGlobalFilter ?? false,
|
|
87
113
|
);
|
|
88
|
-
const [columnFilterFns, setColumnFilterFns] = useState<{
|
|
89
|
-
[key: string]: MRT_FilterOption;
|
|
90
|
-
}>(() =>
|
|
91
|
-
Object.assign(
|
|
92
|
-
{},
|
|
93
|
-
...getAllLeafColumnDefs(props.columns as MRT_ColumnDef<TData>[]).map(
|
|
94
|
-
(col) => ({
|
|
95
|
-
[col.id?.toString() ?? col.accessorKey?.toString() ?? '']:
|
|
96
|
-
col.filterFn instanceof Function
|
|
97
|
-
? col.filterFn.name ?? 'custom'
|
|
98
|
-
: col.filterFn ??
|
|
99
|
-
initialState?.columnFilterFns?.[
|
|
100
|
-
col.id?.toString() ?? col.accessorKey?.toString() ?? ''
|
|
101
|
-
] ??
|
|
102
|
-
getDefaultColumnFilterFn(col),
|
|
103
|
-
}),
|
|
104
|
-
),
|
|
105
|
-
),
|
|
106
|
-
);
|
|
107
|
-
const [globalFilterFn, setGlobalFilterFn] = useState<MRT_FilterOption>(
|
|
108
|
-
props.globalFilterFn instanceof String
|
|
109
|
-
? (props.globalFilterFn as MRT_FilterOption)
|
|
110
|
-
: 'fuzzy',
|
|
111
|
-
);
|
|
112
114
|
|
|
113
115
|
const displayColumns = useMemo(
|
|
114
116
|
() =>
|
|
@@ -190,8 +192,6 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
190
192
|
props.enableRowSelection,
|
|
191
193
|
props.enableSelectAll,
|
|
192
194
|
props.localization,
|
|
193
|
-
props.muiTableBodyCellProps,
|
|
194
|
-
props.muiTableHeadCellProps,
|
|
195
195
|
props.positionActionsColumn,
|
|
196
196
|
],
|
|
197
197
|
);
|
|
@@ -248,20 +248,19 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
248
248
|
columns: columnDefs,
|
|
249
249
|
data,
|
|
250
250
|
globalFilterFn:
|
|
251
|
-
|
|
252
|
-
props.filterFns[globalFilterFn] ?? props.filterFns.fuzzy,
|
|
251
|
+
props.filterFns?.[globalFilterFn] ?? props.filterFns?.fuzzy,
|
|
253
252
|
initialState,
|
|
254
253
|
state: {
|
|
255
|
-
columnOrder,
|
|
256
|
-
currentDraggingColumn,
|
|
257
|
-
currentDraggingRow,
|
|
258
|
-
currentEditingCell,
|
|
259
|
-
currentEditingRow,
|
|
260
254
|
columnFilterFns,
|
|
261
|
-
|
|
262
|
-
currentHoveredColumn,
|
|
263
|
-
currentHoveredRow,
|
|
255
|
+
columnOrder,
|
|
264
256
|
density,
|
|
257
|
+
draggingColumn,
|
|
258
|
+
draggingRow,
|
|
259
|
+
editingCell,
|
|
260
|
+
editingRow,
|
|
261
|
+
globalFilterFn,
|
|
262
|
+
hoveredColumn,
|
|
263
|
+
hoveredRow,
|
|
265
264
|
isFullScreen,
|
|
266
265
|
showAlertBanner,
|
|
267
266
|
showColumnFilters,
|
|
@@ -270,21 +269,15 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
270
269
|
} as TableState,
|
|
271
270
|
tableId,
|
|
272
271
|
}),
|
|
273
|
-
|
|
274
|
-
props.onCurrentDraggingColumnChange ?? setCurrentDraggingColumn,
|
|
275
|
-
setCurrentDraggingRow:
|
|
276
|
-
props.onCurrentDraggingRowChange ?? setCurrentDraggingRow,
|
|
277
|
-
setCurrentEditingCell:
|
|
278
|
-
props.onCurrentEditingCellChange ?? setCurrentEditingCell,
|
|
279
|
-
setCurrentEditingRow:
|
|
280
|
-
props.onCurrentEditingRowChange ?? setCurrentEditingRow,
|
|
281
|
-
setColumnFilterFns: props.onCurrentFilterFnsChange ?? setColumnFilterFns,
|
|
282
|
-
setGlobalFilterFn: props.onCurrentGlobalFilterFnChange ?? setGlobalFilterFn,
|
|
283
|
-
setCurrentHoveredColumn:
|
|
284
|
-
props.onCurrentHoveredColumnChange ?? setCurrentHoveredColumn,
|
|
285
|
-
setCurrentHoveredRow:
|
|
286
|
-
props.onCurrentHoveredRowChange ?? setCurrentHoveredRow,
|
|
272
|
+
setColumnFilterFns: props.onFilterFnsChange ?? setColumnFilterFns,
|
|
287
273
|
setDensity: props.onDensityChange ?? setDensity,
|
|
274
|
+
setDraggingColumn: props.onDraggingColumnChange ?? setDraggingColumn,
|
|
275
|
+
setDraggingRow: props.onDraggingRowChange ?? setDraggingRow,
|
|
276
|
+
setEditingCell: props.onEditingCellChange ?? setEditingCell,
|
|
277
|
+
setEditingRow: props.onEditingRowChange ?? setEditingRow,
|
|
278
|
+
setGlobalFilterFn: props.onGlobalFilterFnChange ?? setGlobalFilterFn,
|
|
279
|
+
setHoveredColumn: props.onHoveredColumnChange ?? setHoveredColumn,
|
|
280
|
+
setHoveredRow: props.onHoveredRowChange ?? setHoveredRow,
|
|
288
281
|
setIsFullScreen: props.onIsFullScreenChange ?? setIsFullScreen,
|
|
289
282
|
setShowAlertBanner: props.onShowAlertBannerChange ?? setShowAlertBanner,
|
|
290
283
|
setShowFilters: props.onShowFiltersChange ?? setShowFilters,
|
|
@@ -10,27 +10,23 @@ export const MRT_ToolbarDropZone: FC<Props> = ({ table }) => {
|
|
|
10
10
|
const {
|
|
11
11
|
getState,
|
|
12
12
|
options: { enableGrouping, localization },
|
|
13
|
-
|
|
13
|
+
setHoveredColumn,
|
|
14
14
|
} = table;
|
|
15
15
|
|
|
16
|
-
const {
|
|
16
|
+
const { draggingColumn, hoveredColumn } = getState();
|
|
17
17
|
|
|
18
18
|
const handleDragEnter = (_event: DragEvent<HTMLDivElement>) => {
|
|
19
|
-
|
|
19
|
+
setHoveredColumn({ id: 'drop-zone' });
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
|
-
<Fade
|
|
24
|
-
unmountOnExit
|
|
25
|
-
mountOnEnter
|
|
26
|
-
in={!!enableGrouping && !!currentDraggingColumn}
|
|
27
|
-
>
|
|
23
|
+
<Fade unmountOnExit mountOnEnter in={!!enableGrouping && !!draggingColumn}>
|
|
28
24
|
<Box
|
|
29
25
|
sx={(theme) => ({
|
|
30
26
|
alignItems: 'center',
|
|
31
27
|
backgroundColor: alpha(
|
|
32
28
|
theme.palette.info.main,
|
|
33
|
-
|
|
29
|
+
hoveredColumn?.id === 'drop-zone' ? 0.2 : 0.1,
|
|
34
30
|
),
|
|
35
31
|
border: `dashed ${theme.palette.info.main} 2px`,
|
|
36
32
|
display: 'flex',
|
|
@@ -45,7 +41,7 @@ export const MRT_ToolbarDropZone: FC<Props> = ({ table }) => {
|
|
|
45
41
|
<Typography>
|
|
46
42
|
{localization.dropToGroupBy.replace(
|
|
47
43
|
'{column}',
|
|
48
|
-
|
|
44
|
+
draggingColumn?.columnDef?.header ?? '',
|
|
49
45
|
)}
|
|
50
46
|
</Typography>
|
|
51
47
|
</Box>
|
|
@@ -1,12 +1,12 @@
|
|
|
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';
|
|
4
5
|
import { MRT_ShowHideColumnsButton } from '../buttons/MRT_ShowHideColumnsButton';
|
|
5
6
|
import { MRT_ToggleDensePaddingButton } from '../buttons/MRT_ToggleDensePaddingButton';
|
|
6
7
|
import { MRT_ToggleFiltersButton } from '../buttons/MRT_ToggleFiltersButton';
|
|
7
8
|
import { MRT_ToggleGlobalFilterButton } from '../buttons/MRT_ToggleGlobalFilterButton';
|
|
8
|
-
import { MRT_TableInstance } from '..';
|
|
9
|
-
import { MRT_GlobalFilterTextField } from '../inputs/MRT_GlobalFilterTextField';
|
|
9
|
+
import type { MRT_TableInstance } from '..';
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
12
|
table: MRT_TableInstance;
|
|
@@ -37,11 +37,6 @@ export const MRT_ToolbarInternalButtons: FC<Props> = ({ table }) => {
|
|
|
37
37
|
}}
|
|
38
38
|
>
|
|
39
39
|
{renderToolbarInternalActions?.({
|
|
40
|
-
MRT_FullScreenToggleButton,
|
|
41
|
-
MRT_ShowHideColumnsButton,
|
|
42
|
-
MRT_ToggleDensePaddingButton,
|
|
43
|
-
MRT_ToggleFiltersButton,
|
|
44
|
-
MRT_ToggleGlobalFilterButton,
|
|
45
40
|
table,
|
|
46
41
|
}) ?? (
|
|
47
42
|
<>
|