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| Name | Keeps in the Model | For |
|---|---|---|
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 |
FocusScope | nothing (a Mount) | keep focus inside an overlay |
Press | { pressed, … }; out Pressed | pointer, touch, Enter, Space, and AT clicks as one fact |
LongPress | { … }; out LongPressed | holding for a threshold |
Move | nothing (a Mount) | pointer drag deltas |
Targets | nothing (a Mount) | which marked descendant is hovered or pressed |
PointerDrag | nothing (a Mount) | dragging one marked descendant onto another |
EditableText | nothing (a Mount) | text typed into a contenteditable field |
FocusVisible | InputModality's { modality } | a focus ring for keyboard users only |
DismissLayer | { layers }; out Dismiss { ids } | close overlays on Escape or an outside press |
Layers | nothing (Mounts) | scroll lock and inert-outside for an overlay |
Selection | { selected, anchor } | selected items with aria-selected and Shift ranges |
LiveAnnounce | the live regions' text | speak 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.