@primitiv-ui/core
v0.2.15
Published
The framework-free behaviour core shared by every Primitiv surface — keyboard maps, roving-focus targets, id derivation and per-component policy, as pure functions with no DOM and no dependencies.
Readme
@primitiv-ui/core
The framework-free behaviour core shared by every Primitiv surface. Pure TypeScript functions with no DOM, no framework and no dependencies: keyboard maps, roving-focus targets, id derivation and, as components move over, each component's keyboard and state policy.
You do not normally install this package yourself. It arrives as a dependency
of the surface you chose: @primitiv-ui/react today, and
@primitiv-ui/web (standard custom elements) as it lands. Both surfaces import
the same functions, so they cannot disagree about how a component behaves. See
RFC 0033 for the design.
Exports
| Export | What it does |
| --- | --- |
| getKeyToActionMap(options) | Builds the key → roving action map ("next", "prev", "first", "last", "activate") for an orientation, reading direction, Home/End and Enter/Space. |
| RovingKeyAction | The action vocabulary those maps return. |
| resolveRovingTarget({ action, navigable, currentKey }) | Resolves which item a roving action lands on (wrapping, Home/End, Enter/Space), as { target } or null. |
| deriveId(rootId, suffix, value) | Builds the paired ids (aria-controls, aria-labelledby) a compound component wires between its parts. |
| tabsKeydown(state, focused, key) | Tabs' keyboard contract: which tab to focus and which, if any, to activate. |
| tabsClick(state, value) | The tab a click activates, or null when it is disabled or already active. |
| tabsTabStop(state) | The tab that takes part in the page's Tab order. |
| TabsState, TabsKeyOutcome, TabsOrientation, TabsReadingDirection, TabsActivationMode | The plain data those functions read and return. |
Rules for this package
- No DOM.
tsconfig.jsonleavesDOMout oflib, so a DOM type in a signature is a compile error. - 100% coverage and 100% mutation score, both gated:
pnpm qa:unitsandpnpm mutate. - Versioned in lockstep with every other Primitiv package
(
scripts/bump-version.mjs).
