'use client'; import { useId, useRef } from 'react'; import { FlexBox } from '../../../atoms/flex-box'; import { Typography } from '../../../atoms/typography'; import { Element } from '../../../primitives/element'; import { cn } from '../../../tools/cn'; import { useDismiss } from '../hooks/use-dismiss'; import { useFlip } from '../hooks/use-flip'; import type { SheetPopoverProps } from '../types'; import { SheetHead } from './SheetHead'; /** * A desktop popover, 320px, anchored by its caller in a positioned container next to the * trigger. It hangs under the trigger at the inline end, and flips above or to the inline start * when it would run off the screen. No scrim and not modal: Escape, the ✕ or a press outside * closes it. */ export function SheetPopover({ open, title, icon, children, footer, onClose, closeLabel, className, }: SheetPopoverProps) { const ref = useRef(null); const titleId = useId(); useDismiss(ref, open, onClose); useFlip(ref, open); if (!open) return null; return ( // A non-modal : in place, no scrim, and the page behind stays usable. {icon && {icon}} {children != null && ( {children} )} {footer && ( {footer} )} ); }