The state a trigger and a Dialog share: const d = useDialog(); <button onClick={d.show}> and <Dialog {...d.props}>. Focus goes back to the button that was focused when show ran.
rememberOpener
(dialog: HTMLDialogElement, opener?: Element | null): void
Remembers what had focus before the dialog opened, to hand focus back on close.
Hands focus back after a dialog closes. After the next frame, so whatever the action changed has rendered first (a revoked agent's row, and its button, may be gone). Only when focus is lost: if the browser already restored it, or a command opened another dialog, that focus stands.
True when a mouse event landed on the dialog's backdrop rather than its content.
errorText
(e: unknown): string
The text of a thrown value, for the error shown inside a dialog.
isBusy
(dialog: HTMLDialogElement): boolean
A dialog is busy while its action runs: aria-busy on the dialog. Esc, Close, Cancel and the backdrop all refuse until it is cleared.
setDialogBusy
(dialog: HTMLDialogElement, on: boolean): void
Sets or clears busy. The Close and Cancel parts say so with aria-disabled (not disabled, so focus stays where it was).
syncClosedBy
(dialog: HTMLDialogElement): void
isLocked
(dialog: HTMLDialogElement): boolean
True when a click outside the dialog must not close it: it is locked, it is an alert dialog (one that asks a question the person must answer), or it is busy.
historyHash
(dialog: HTMLDialogElement): string
The address a history-entry dialog pushes: data-cap-history may name the prefix ("detail" gives #detail-<id>); the id is data-cap-history-id, data-cap-detail-id or the dialog's id.
Puts focus where a person starts: the given element, the [autofocus] one, Cancel when the dialog is an alert or marked destructive (Enter on arrival must not do the damage), else the first control that is not the Close button or the scrolling body, else Close, the body, the dialog itself.
syncScroll
(dialog: HTMLDialogElement): void
A body that scrolls must be reachable by keyboard: it takes tabindex="0" while it overflows (and gives it back when it does not), so arrow keys scroll it.
Wires one dialog: a click on a Close or Cancel part, a click on the backdrop, Esc held while busy, and what happens on close (the address entry, focus back to the opener). Returns a function that unwires it. Idempotent for a dialog that is already wired.
openDialog
(dialog: HTMLDialogElement, opener?: Element | null, opts?: DialogOptions): void
Opens a dialog from the control that asked for it, remembering that control. Focus is placed (see focusInitial); with history, "#<prefix>-<id>" is pushed so Back closes it.
Wires every dialog under root ([data-cap="dialog"]) and every trigger [data-cap-dialog-open="<dialog id>"]. A dialog with data-cap-open (or the specimens' data-specimen-open) opens now. A dialog with data-cap-inline and open is in the page until this runs, then closed (see the markup on the doc page). A trigger that is a link keeps its href for a new tab; a plain click opens the dialog. Returns a function that detaches them all.