@context-action/interactions
v0.1.0
Published
Framework-neutral headless UI and ARIA interaction primitives (roving focus, typeahead, pointer gestures, LIFO dismiss layers) for Context-Action
Maintainers
Readme
@context-action/interactions
Zero-dependency, framework-neutral headless UI and ARIA interaction primitives for Context-Action.
This Foundation package separates UI/ARIA mechanics from @context-action/core (action pipelines & DOM element transport) so consumers using only action pipelines or custom-element bindings pay zero bundle or concept overhead for interactive widget engines.
Primitives
createRovingFocusController(options)— WAI-ARIA composite focus helper supporting'horizontal','vertical', and'both'orientations,Arrow*/Home/End, disabled-item skipping, looping, virtualgetActiveDescendant(idPrefix), explicitmove(direction, currentId?), and multi-character / cyclic labeltypeahead.createPointerGestureSession(options)— Pointer-capture drag/gesture lifecycle manager tracking primary-button filtering,onStartguard admission,setPointerCapture/releasePointerCapture,deltaX/deltaYand keyboard modifier snapshots, andEscapecancellation.createDismissLayer(options)— Per-DocumentLIFO overlay stack managing capture-phaseEscapeand multi-container outsidepointerdowndismissal with zero listener leaks when all layers close.
Example
import {
createDismissLayer,
createPointerGestureSession,
createRovingFocusController,
} from '@context-action/interactions';
const roving = createRovingFocusController({
orientation: 'vertical',
typeahead: true,
getItems: () => [
{ id: 'save', label: 'Save' },
{ id: 'delete', label: 'Delete' },
],
getActiveId: () => 'save',
});
const gesture = createPointerGestureSession({
onMove: snapshot => {
void snapshot.deltaX;
},
});
const layer = createDismissLayer({
enabled: false,
getContainers: () => [],
onDismiss: () => {},
});
void [roving.getActiveDescendant('item-'), gesture.isActive(), layer.isTopMost];