@@ -5,6 +5,8 @@ import { ReactElement, ReactNode, Ref, useId, useMemo, useState } from "react";
5
5
import { generateId } from "../../lib/generate-id" ;
6
6
import { useDragListener } from "../DragDropContext" ;
7
7
import { useDraggableSafe , useDroppableSafe } from "../../lib/dnd/dnd-kit/safe" ;
8
+ import { DragOverlay , useDragDropManager } from "@dnd-kit/react" ;
9
+ import { useAppContext } from "../Puck/context" ;
8
10
9
11
const getClassName = getClassNameFactory ( "Drawer" , styles ) ;
10
12
const getClassNameItem = getClassNameFactory ( "DrawerItem" , styles ) ;
@@ -75,6 +77,7 @@ const DrawerItemDraggable = ({
75
77
id,
76
78
data : { type : "drawer" , componentType : name } ,
77
79
disabled : isDragDisabled ,
80
+ type : "new" ,
78
81
} ) ;
79
82
80
83
return (
@@ -153,6 +156,8 @@ export const Drawer = ({
153
156
droppableId ?: string ; // TODO deprecate
154
157
direction ?: "vertical" | "horizontal" ; // TODO deprecate
155
158
} ) => {
159
+ const appContext = useAppContext ( ) ;
160
+
156
161
if ( droppableId ) {
157
162
console . error (
158
163
"Warning: The `droppableId` prop on Drawer is deprecated and no longer required."
@@ -173,15 +178,28 @@ export const Drawer = ({
173
178
collisionPriority : 0 , // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
174
179
} ) ;
175
180
181
+ const manager = useDragDropManager ( ) ;
182
+
176
183
return (
177
- < div
178
- className = { getClassName ( ) }
179
- ref = { ref }
180
- data-puck-dnd = { id }
181
- data-puck-drawer
182
- >
183
- { children }
184
- </ div >
184
+ < >
185
+ < div
186
+ className = { getClassName ( ) }
187
+ ref = { ref }
188
+ data-puck-dnd = { id }
189
+ data-puck-drawer
190
+ >
191
+ { children }
192
+ </ div >
193
+ { manager ?. dragOperation . source ?. type === "new" && (
194
+ < DragOverlay >
195
+ { ( source ) => (
196
+ < DrawerItemInner name = { source . data . componentType } >
197
+ { appContext . overrides . componentItem }
198
+ </ DrawerItemInner >
199
+ ) }
200
+ </ DragOverlay >
201
+ ) }
202
+ </ >
185
203
) ;
186
204
} ;
187
205
0 commit comments