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 |
SpatialNavigation | { current } | freely placed items: a board, a canvas, a dashboard of cards |
TreeNavigation | { current, toggled } | a tree: a file explorer, a layers panel |
FocusScope | nothing (a Mount) | keep focus inside an overlay |
FocusRecovery | nothing (a Mount) | keep focus when its part is removed or hidden |
InlineEdit | { editing }; out Committed | edit a plain value where it is shown, in an <input> |
Presence | nothing (draws the Model's phase) | a leaving row that takes no click, Tab or focus |
Press | { pressed, … }; out Pressed | pointer, touch, Enter, Space, and AT clicks as one fact |
LongPress | { … }; out LongPressed | holding for a threshold |
SwipeActions | { open }; out FullSwiped | which side of a row is open, what a swipe's release means, and its keys |
Repeat | { holding, count, … }; out Stepped, Ended | a held stepper button |
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 |
Marquee | nothing (a Mount) | a lasso over the marked descendants, from a press on empty space |
Reorder | { held, over }; out Moved, PickedUp, PassedOver, PutBack | moving an item in a list or tree, by keys and by pointer |
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, ranged } | selected items with aria-selected and Shift ranges |
LiveAnnounce | the live regions' text | speak to assistive technology |
Overlay, Placing | nothing (Behaviors) | one policy for an overlay's dismissal, focus and locks; keep a panel in the viewport |
BundleBehavior | nothing | write the Behavior half of a Bundle you author |
The pure rule behind each (move, match, nearest, between, toDismiss,
targetOf, zoneOf) is exported beside it, for a view that wires its own.