@@ -5,6 +5,8 @@ import { ReactElement, ReactNode, Ref, useId, useMemo, useState } from "react";
55import { generateId } from "../../lib/generate-id" ;
66import { useDragListener } from "../DragDropContext" ;
77import { useDraggableSafe , useDroppableSafe } from "../../lib/dnd/dnd-kit/safe" ;
8+ import { DragOverlay , useDragDropManager } from "@dnd-kit/react" ;
9+ import { useAppContext } from "../Puck/context" ;
810
911const getClassName = getClassNameFactory ( "Drawer" , styles ) ;
1012const getClassNameItem = getClassNameFactory ( "DrawerItem" , styles ) ;
@@ -75,6 +77,7 @@ const DrawerItemDraggable = ({
7577 id,
7678 data : { type : "drawer" , componentType : name } ,
7779 disabled : isDragDisabled ,
80+ type : "new" ,
7881 } ) ;
7982
8083 return (
@@ -153,6 +156,8 @@ export const Drawer = ({
153156 droppableId ?: string ; // TODO deprecate
154157 direction ?: "vertical" | "horizontal" ; // TODO deprecate
155158} ) => {
159+ const appContext = useAppContext ( ) ;
160+
156161 if ( droppableId ) {
157162 console . error (
158163 "Warning: The `droppableId` prop on Drawer is deprecated and no longer required."
@@ -173,15 +178,28 @@ export const Drawer = ({
173178 collisionPriority : 0 , // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
174179 } ) ;
175180
181+ const manager = useDragDropManager ( ) ;
182+
176183 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+ </ >
185203 ) ;
186204} ;
187205
0 commit comments