/** * How the user last drove the interface. */ type InputModality = 'keyboard' | 'pointer'; /** * Blok paints its own focus cursor (`data-blok-focused`) on popover items. * Those items are never really focused — the cursor is an attribute — so the * browser's `:focus-visible` cannot gate it, and without this signal a menu * opened with the mouse lights up its first row like a keyboard cursor. * * Keyboard is the starting value so a surface opened before any user gesture * (a programmatic `open()`, a test) still exposes the cursor. */ const state: { modality: InputModality } = { modality: 'keyboard' }; /** * Mirrors the modality onto the document so CSS can see it. * * `:focus-visible` alone cannot: Blink keeps a document-level focus-visible * flag that a keypress sets and only a focus-MOVING click clears, and Blok's * controls preventDefault their mousedown to keep the caret — so the flag * survives the click and the ring stays. A `