/** * TableOfContents — slide-in drawer for epub.js navigation tree. */ import type { KeyboardEvent } from "react"; import { useTranslation } from "react-i18n-lite"; import { PanelCloseButton } from "./PanelCloseButton"; export interface EpubTocItem { label: string; href: string; subitems?: EpubTocItem[]; } interface TableOfContentsProps { items: EpubTocItem[]; isOpen: boolean; onClose: () => void; onNavigate: (href: string) => void; } function TocEntry({ item, depth, onNavigate, }: { item: EpubTocItem; depth: number; onNavigate: (href: string) => void; }) { return ( <> {item.subitems?.map((sub) => ( ))} ); } export default function TableOfContents({ items, isOpen, onClose, onNavigate, }: TableOfContentsProps) { const { t } = useTranslation(); const handleNavigate = (href: string) => { onNavigate(href); onClose(); }; return ( <> {isOpen && (
{ if (e.key === "Escape") onClose(); }} role="presentation" /> )} ); }