import { FileDown } from "lucide-react"; import { useRef, useState } from "react"; import { SUPPORTED_EXTENSIONS } from "../constants"; interface FileDropZoneProps { onFileSelected: (file: File) => void; } export function FileDropZone({ onFileSelected }: FileDropZoneProps) { const [isDragging, setIsDragging] = useState(false); const fileInputRef = useRef(null); const handleDragEnter = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); setIsDragging(true); }; const handleDragLeave = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); setIsDragging(false); }; const handleDragOver = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); }; const handleDrop = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); setIsDragging(false); const files = Array.from(e.dataTransfer.files); if (files.length > 0) { onFileSelected(files[0]); } }; const handleFileInput = (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (file) { onFileSelected(file); } }; const handleClick = () => { fileInputRef.current?.click(); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" || e.key === " ") { handleClick(); } }; return (

{isDragging ? "Drop file now" : "Select File"}

Drag & drop or click to browse ({SUPPORTED_EXTENSIONS.join(", ")})

); }