import { useEffect, useRef } from 'react'; import { Icon } from './Icon.jsx'; /** @typedef {{id: string, open: boolean, title: string, closeLabel: string, onClose: function, * children?: import('react').ReactNode}} SheetProps */ /** * Modal panel built on the native dialog (focus trap and Escape for free). Styled by the * `.info-sheet` rules: a centred card on wide screens, a bottom sheet on phones. * @param {SheetProps} props - Visibility, title, close label and callback, and content. * @returns {import('react').ReactElement} Dialog element. */ export function Sheet({ id, open, title, closeLabel, onClose, children }) { const dialog = useRef(null); // Keep the native dialog in step with `open`; closing by Escape reports back through onClose. useEffect(() => { const element = dialog.current; if (!element) return; if (open && !element.open) element.showModal(); if (!open && element.open) element.close(); }, [open]); return (

{title}

{open && children}
); }