Primitives / foldkit-primitives

Which form a primitive takes

Every primitive is one of five things, chosen by what it has to own:

It needs to ownFormJoins the application byExamples
A fact that outlives the moment: a match, a count, a page, a positionbundleplacing it in the parent, as a field and a wrapper MessageMediaQuery, Timer, Pagination, websocket
Interaction state a view's slots must reflectbundle + Behaviorplacing it, then attaching its Behavior to the view's slotsRovingTabindex, Press, DismissLayer
Nothing: a stream you react toentrylifting it into your Subscriptions, mapped to your MessagekeyboardEvents, ticks, broadcastMessages
Nothing: observation bound to one elementMountattaching it in the view with h.OnMountResize, Autofocus, KeepInView
Nothing: work done once that reports backCommandreturning it from updatecopyText, share, enterFullscreen
Nothing: a value computed from what you havefunctioncalling itrange, matchHotkey, formatRelativeTime

The lighter form wins when in doubt. Promote to a bundle the day the state needs a name in the Model.

The one dependency is foldkit-bundle, whose placement mechanism every bundle here uses. interaction additionally needs foldkit-mixins, an optional peer, because its Behaviors write to a view's slots.

Install

bash
pnpm add foldkit-primitives foldkit-bundle effect foldkit

effect and foldkit are peer dependencies. Import by subpath (/media, /net, /time, /state, /motion, /interaction, /device, /events, /observers, /dom) so a bundler drops what you never import.