Primitives / DOM

foldkit-primitives/dom

Element Mounts that act while attached, and one-shot Commands that run once and report back. Nothing here owns lasting state: a Mount reads and writes the DOM for its element, a Command's result comes back as a Message your union wraps. (source)

NameFormReports or yieldsArgs
copyText(text)CommandCopied, CopyFailed
readText()CommandRead { text }, ReadFailed
share(data)CommandShared, Dismissed, ShareFailed{ title?, text?, url? }
loadScript(src)CommandLoaded, LoadFailed
decodeImage(source)CommandDecoded { src }, DecodeFailed { src, message }{ src, srcset?, sizes? }
Autofocus()MountFocused
InputMask({ pattern })MountInput { value, raw }#, A, * placeholders
KeepInView({ selector })Mountnothing
Measure({ targets })Mountnothing; writes custom properties
DragPreview()Mountnothingshows a popover="manual" element in top layer (PointerDrag)
TrackBox({ name, radius? })MountTrackedTarget { target, found }; writes custom propertiesthe target's id in data-target
FluidHover({ name, item, axis, gapClick, gapReach?, follows?, from? })Mountnothing; writes custom propertiesaxis: x, y, xy
ScrollBars({ idle?, scroller? })Mountnothing; writes custom properties and marksidle in ms, default 600
FocusScope(options)Mountnothing{ contain?, restore?, initialFocus? }
FollowTabStopMountnothing
KeyboardInsetMountnothing; writes --fk-keyboard-inset
FocusRecovery({ fallback })Mountnothingfallback: steps per part slot
FocusReturn()Mountnothingnone
ScrollLock, HideOutsideMountsnothing
PointerPosition({ focus? })MountPointerPressed, PointerMoved, PointerReleasedfocus: a selector
Swipe({ measure?, slop?, scrolls?, touchOnly? })MountSwipeStarted, Swiped, SwipeEndedsee below
ScrollSettle({ item?, axis?, start? })MountScrollSettled { index }see below
Move, Targets, PointerDrag, Marquee, EditableTextMountstheir factseach is in interaction, beside its Behavior
keepScroll(options?)entrynothing
pointedLinks(options?)streamUrlrest: how long a hover or focus rests, default 50 ms
visibleLinks(options?)streamUrlatMost (8), margin
applyMask(value, pattern)function{ value, raw }