import React, { useEffect, useRef, useState } from 'react'; import { Download, Table2, FileText, FileCode, FileSpreadsheet, History } from 'lucide-react'; /** * Header dropdown that consolidates every "view this conversation as…" * and "download this conversation as…" action behind a single Download * icon. The same chat-as-.txt / .md / .csv items are *also* listed in * the Settings menu's Downloads section (intentional duplication, per * UX request); the only item that lives *exclusively* here is * "Download full API history". * * Mirrors the open/close + outside-mousedown pattern used by DevMenu so * both dropdowns feel and behave identically. */ export default function DownloadMenu({ hasChat, hasApiLog, onShowTableView, onDownloadChatTxt, onDownloadChatMd, onDownloadCsvTable, onDownloadApiLog, }) { const [open, setOpen] = useState(false); const wrapRef = useRef(null); useEffect(() => { function handleClickOutside(e) { if (wrapRef.current && !wrapRef.current.contains(e.target)) { setOpen(false); } } document.addEventListener('mousedown', handleClickOutside); return () => document.removeEventListener('mousedown', handleClickOutside); }, []); const fire = (fn) => () => { fn?.(); setOpen(false); }; return (