Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

1.0 KB
Raw Blame
import { DragDropOverlay } from '@librechat/chat/components';
import DragDropModal from '~/components/Chat/Input/Files/DragDropModal';
import { DragDropProvider, UploadModalProvider } from '~/Providers';
import { useDragHelpers } from '~/hooks';
import { cn } from '~/utils';

interface DragDropWrapperProps {
  children: React.ReactNode;
  className?: string;
}

function DragDropArea({ children, className }: DragDropWrapperProps) {
  const { isOver, canDrop, drop } = 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} />
      <DragDropModal />
    </div>
  );
}

export default function DragDropWrapper({ children, className }: DragDropWrapperProps) {
  return (
    <DragDropProvider>
      <UploadModalProvider>
        <DragDropArea className={className}>{children}</DragDropArea>
      </UploadModalProvider>
    </DragDropProvider>
  );
}