Primitives / API

foldkit-primitives/state

Namespaces

HistoryThe steps of a history as pure functions of its Model.

Functions

canRedoWhether Redo would move: the future is non-empty.
canUndoWhether Undo would move: the past is non-empty.
distanceToEndPixels from the viewport's bottom edge to the content's end: negative past it, zero exactly there. Prefetch thresholds want this number ("load when within…
historyUndo/redo as a bundle factory: the past, present, and future of one value live in the Model, so every step replays. Pushing records, even an unchanged…
HistoryModel
isAtEndWhether the viewport rests at (or past) the end, within threshold pixels: the infinite-scroll check. An empty list counts as ended — there is nothing to…
isSelectedWhether the id is currently selected.
masonryMasonry layout as a pure function: fixed column count and width, each item packed into the currently shortest column. Unmeasured items use the estimate;…
offsetThe offset of the first item on the page, for a slice or a query.
offsetForPixel offset of a row's top edge: padding plus the prefix before it.
pageCountThe number of pages, or null while the total is unknown.
rangeA numeric range as an array: range(1, 4) is [1, 2, 3], inclusive of the start and exclusive of the end, like Array.from length math. The pagination…
stickyHeaderWhich section header sticks for a window: the last section starting at or before the first rendered row, or null above the first section. Order independent…
totalHeightTotal scrollable height: padding, measured rows, estimates, and gaps.
visibleRangeWhich rows to render for a scroll position: the rows intersecting [scrollTop, scrollTop + viewportHeight), widened by overscan on both sides and clamped to…
windowForThe rows to render plus the spacer height, from the Model, the key order, and the viewport height. Layout and overscan come from the Model, so the call…

Values

LocaleLocale as a bundle: the current locale string in the Model. Starts from navigator.language where available, falling back to the configured default; changes…
LocaleMessage
LocaleModel
MeasureRowOne row's height, reported on every resize starting with the current one. The key is the application's row identity, echoed back so the parent files the…
PaginationPagination as a bundle: the page, page size, and total live in the Model, so page changes replay and every transition clamps into range. Pure logic, no…
PaginationMessage
PaginationModel
RowMeasured
SelectionSetA selection set as a bundle: the selected ids in the Model, changed one at a time or replaced whole. Order follows first selection; toggling moves a…
SelectionSetMessage
SelectionSetModel
ViewportThe scroll container's position, reported on its own scrolls starting with the current one. Attach to the scrolling element — viewport scrolls arrive…
ViewportScrolled
VirtualWindowing math for virtualized lists as pure functions: which rows to render, how tall the scrollable area is, and where each row starts. Row heights come…
VirtualMessage
VirtualModel

Interfaces

MasonryPlacementWhere masonry puts one item: its column and its box, in pixels.
VirtualLayoutLayout constants: per-row estimate, inter-row gap, and end padding.
VirtualWindowThe rows to draw: a half-open range of indexes.