Primitives / Interaction

foldkit-primitives/interaction

Keyboard, pointer, and focus patterns whose state a view's slots must reflect: which item holds the tab stop, what the user has typed to find, whether a button is pressed, which overlays are open, what is selected. Each is a Bundle that keeps that state in the Model and a matching foldkit-mixins Behavior that writes the attributes and handlers onto the view's slots. Importing this subpath needs foldkit-mixins; the other subpaths do not. (source)

place the Bundle          →  the Model holds the fact (current id, query, pressed, …)
attach its Behavior       →  the slots get tabindex, aria-*, data-*, and key handlers
the handler dispatches    →  update moves the fact; the view redraws from it
NameKeeps in the ModelFor
RovingTabindex{ current }one tab stop for a set of items, arrows between them
Typeahead{ query, generation }type-to-find, for a host whose focus is managed elsewhere
ListNavigation{ current, query, generation }a list host that wants both, in one placement
GridNavigation{ current }cells in rows: a calendar, a swatch picker
TreeNavigation{ current, toggled }a tree: a file explorer, a layers panel
FocusScopenothing (a Mount)keep focus inside an overlay
Press{ pressed, … }; out Pressedpointer, touch, Enter, Space, and AT clicks as one fact
LongPress{ … }; out LongPressedholding for a threshold
Movenothing (a Mount)pointer drag deltas
Targetsnothing (a Mount)which marked descendant is hovered or pressed
PointerDragnothing (a Mount)dragging one marked descendant onto another
EditableTextnothing (a Mount)text typed into a contenteditable field
FocusVisibleInputModality's { modality }a focus ring for keyboard users only
DismissLayer{ layers }; out Dismiss { ids }close overlays on Escape or an outside press
Layersnothing (Mounts)scroll lock and inert-outside for an overlay
Selection{ selected, anchor }selected items with aria-selected and Shift ranges
LiveAnnouncethe live regions' textspeak to assistive technology

The pure rule behind each (move, match, between, toDismiss, targetOf, zoneOf) is exported beside it, for a view that wires its own.