"use client"; import * as React from "react"; import { cn } from "./lib/utils"; export interface PromptHistoryItem { id: string; title: string; preview: string; } export interface PromptHistoryDrawerProps extends React.HTMLAttributes { items?: PromptHistoryItem[]; triggerLabel?: string; onRestore?: (item: PromptHistoryItem) => void; onClear?: () => void; } /** Slide-over drawer listing saved prompts with restore and clear actions. */ export function PromptHistoryDrawer({ items = [ { id: "p1", title: "Festival poster stub", preview: "Design a cream festival stub with red stamp..." }, { id: "p2", title: "Boarding pass print", preview: "Printable boarding pass, night stub theme..." }, ], triggerLabel = "History", onRestore, onClear, className, ...props }: PromptHistoryDrawerProps) { const [open, setOpen] = React.useState(false); React.useEffect(() => { if (!open) return; const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") setOpen(false); }; document.addEventListener("keydown", onKey); return () => document.removeEventListener("keydown", onKey); }, [open ]); return (
{open && (
setOpen(false)} aria-hidden="true" />
)}
); }