File size: 1,075 Bytes
f0743f4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import { useDragHelpers } from '~/hooks';
import DragDropOverlay from '~/components/Chat/Input/Files/DragDropOverlay';
import DragDropModal from '~/components/Chat/Input/Files/DragDropModal';
import { DragDropProvider } from '~/Providers';
import { cn } from '~/utils';
interface DragDropWrapperProps {
children: React.ReactNode;
className?: string;
}
export default function DragDropWrapper({ children, className }: DragDropWrapperProps) {
const { isOver, canDrop, drop, showModal, setShowModal, draggedFiles, handleOptionSelect } =
useDragHelpers();
const isActive = canDrop && isOver;
return (
<div ref={drop} className={cn('relative flex h-full w-full', className)}>
{children}
{/** Always render overlay to avoid mount/unmount overhead */}
<DragDropOverlay isActive={isActive} />
<DragDropProvider>
<DragDropModal
files={draggedFiles}
isVisible={showModal}
setShowModal={setShowModal}
onOptionSelect={handleOptionSelect}
/>
</DragDropProvider>
</div>
);
}
|