@bimetal/overlay-headless
v0.38.0
Published
Canonical, framework-agnostic overlay controller (open/close + dismiss policy) shared by Dialog/Popover/Tooltip/Menu/Drawer.
Maintainers
Readme
@bimetal/overlay-headless
Canonical, framework-agnostic overlay controller — the shared core for the overlay
family (Dialog first; Popover / Tooltip / Menu / Drawer to follow). It owns the open/close
state and the dismiss policy (whether an Esc or backdrop dismiss is honored); it is
deliberately DOM-free. The render-layer bindings install the focus trap
(@bimetal/a11y-dom), the scroll lock and the backdrop, and feed dismiss gestures back via
requestClose(reason).
import { createOverlayController } from '@bimetal/overlay-headless';
const dialog = createOverlayController({ onOpenChange: (open) => {} });
dialog.open();
dialog.requestClose('esc'); // closes iff config.closeOnEsc
dialog.requestClose('backdrop'); // closes iff config.closeOnBackdrop
dialog.close(); // force-close (a close button / app action)open()/close()/toggle()— drive the state (close()bypasses policy).requestClose('esc' | 'backdrop' | 'programmatic')— the single place the dismiss decision lives, so no binding diverges.getSnapshot()/subscribe()— identity-stable snapshot foruseSyncExternalStore.
Part of the BIMETAL component family. Apache-2.0.
