// --------------------------------------------------------------------------- // ui/ConfirmDialog.tsx — W51-T01, the wave-51 base kit. // // THE app's confirm dialog. One shape for every irreversible act, so a delete in // the view rail, a delete in the field rail and a discard in the sheet all read // as the same promise. DESIGN.md section 4: a second control shape for the same // act is a new shape joining no rhythm. // // ⚠ IT CARRIES ITS OWN SURFACE, AND THAT IS NOT DECORATION. This renders through // `BodyPortal`, so it is a direct child of
and every descendant-scoped rule // in the app ("#something .child") is dead to it. `.cg-pop` shipped transparent // over the canvas for exactly this reason. Every class here is top-level and lives // in styles/wave51/kit.css, which index.css imports GLOBALLY — a per-component CSS // import would put the sheet in one lazy chunk and leave the dialog unstyled on // every page that does not load that chunk, with tsc and the build both green. // // Not adopted anywhere yet, on purpose: the lanes adopt it in their own files. // --------------------------------------------------------------------------- import { useCallback, useId, useRef } from "react"; import type { ReactNode } from "react"; import { BodyPortal, useOverlayLayer } from "../customer-grid/OverlaySurface"; export interface ConfirmDialogProps { open: boolean; /** A short noun phrase, sentence case. Not a question, not a sentence. */ title: string; body?: ReactNode; confirmLabel: string; cancelLabel?: string; tone: "destructive" | "primary"; onConfirm: () => void; onCancel: () => void; /** The action is in flight: both buttons lock, and the dialog stops dismissing. */ busy?: boolean; /** The host layer must name this surface in `outsideElements` or a press here dismisses it. */ surfaceRef?: (element: HTMLElement | null) => void; } export function ConfirmDialog({ open, title, body, confirmLabel, cancelLabel = "Cancel", tone, onConfirm, onCancel, busy = false, surfaceRef, }: ConfirmDialogProps) { if (!open) return null; return (