import { createPortal } from "react-dom"; import { useId, useRef } from "react"; import { NavigationFocusScope } from "./navigation-focus"; import type { ReactNode, RefObject } from "react"; import type { TransitionPresence } from "@chopin/editor/transition-presence"; export type NavigationDialogMotion = Pick< Exclude, { phase: "closed" }>, "className" | "phase" >; /** A small modal primitive that owns the browser-only focus contract for navigation flows. */ export function NavigationDialog( { children, initialFocus, motion, onDismiss, palette = false, title, }: { children: ReactNode; initialFocus?: RefObject; motion: NavigationDialogMotion; onDismiss: () => void; /** A command palette: its search field is the visible header, so the title is only named. */ palette?: boolean; title: string; }, ) { let dialog = useRef(null); let titleId = useId(); let active = motion.phase !== "closing"; return createPortal(
, document.body, ); }