import * as React from "react"; import { motion, AnimatePresence } from "framer-motion"; interface CommandDialogProps { trigger: React.ReactNode; title: string; description?: string; command: string; footnote?: React.ReactNode; } export function CommandDialog({ trigger, title, description, command, footnote, }: CommandDialogProps) { const [open, setOpen] = React.useState(false); const ref = React.useRef(null); React.useEffect(() => { function handleClickOutside(e: MouseEvent) { if (ref.current && !ref.current.contains(e.target as Node)) { setOpen(false); } } function handleKeyDown(e: KeyboardEvent) { if (e.key === "Escape") setOpen(false); } document.addEventListener("mousedown", handleClickOutside); document.addEventListener("keydown", handleKeyDown); return () => { document.removeEventListener("mousedown", handleClickOutside); document.removeEventListener("keydown", handleKeyDown); }; }, []); return (
{open && ( <> setOpen(false)} />

{title}

{description &&

{description}

}
{command} {footnote &&

{footnote}

}
)}
); } function CodeBlock({ children }: { children: string }) { const [copied, setCopied] = React.useState(false); function handleCopy() { navigator.clipboard.writeText(children); setCopied(true); setTimeout(() => setCopied(false), 2000); } return (
$ {children}
); }