Expand description
The WINDOWED List: the core lays out only the visible range plus
overscan, reports the content extent, and memoizes item extents per key
so a scroll step is constant work.
Round 2 (docs/round-2-contract.md §4–5, src/list.ts): the LIST numbers
every renderer shares — template item keys and instance suffixes
(duplicates and empty keys → #<index>, suffixes ACCUMULATE through
nested templates), Table row keys, the one-axis virtual window
(vertical OR horizontal), scrollToIndex offsets, sections and the
sticky header. fixtures/template-items.json and
fixtures/virtual-list.json lock them.
Structs§
- List
Section - Consecutive items sharing a
sectionByvalue. - List
Window - Sticky
Header - The pinned header at a scroll offset:
row(a flat row index) drawn atoffseton the list’s axis. - Template
Instance - One item a template renders.
- Visible
Range - Window
Range - The window over a list: items
start..endrender,before/after= the spacers,total= the content length.
Enums§
- Scroll
Align - How
scrollToIndexaligns the item. - Section
Row - A flat row of a sectioned list: a section header or a data item.
Constants§
- DEFAULT_
ESTIMATED_ ITEM_ HEIGHT - The extent an unmeasured item takes when no theme says
$control.row. - DEFAULT_
OVERSCAN - Items rendered beyond each viewport edge (
layout.json windowOverscan). - WINDOW_
THRESHOLD - Lists and Tables with more items than this window (
layout.json windowThreshold).
Functions§
- instance_
segment - A key as one instance-suffix segment:
~→~0,.→~1(as JSON pointer escapes/), so dotted keys never collide across nesting levels (a.b+cvsa+b.c). The reference’sinstanceSegment. - item_
extents - Every item’s extent on the list’s axis: a measured item (
Some) keeps its extent; an unmeasured one takes the MEAN measured extent once any item is measured (the content length stays stable while rows measure in), elserow(the theme’s$control.row).ListWindowapplies the same rule. MirrorsitemExtents(round 2 §5,virtual-list.json). - item_
offsets - Start offsets of items laid end to end with
gapbetween them (adividedlist adds$control.hairlineto the gap):offsets[i]= where item i starts,offsets[count]= the content length. - list_
sections - Consecutive items with the same
section_byvalue (a pointer relative to each item) form a section; the data order is kept. - scroll_
offset_ at scroll_offset_for_indexfor an item attopwith extentsizein content of lengthtotal(O(1) over cached offsets).- scroll_
offset_ for_ index - The scroll offset that brings item
indexinto a viewport atscroll(scrollToIndex):start= its start at the viewport start afterinset(the pinned header),end,center,nearest= the smallest move (none when visible). Clamped to[0, max(0, total - viewport)]. - scroll_
offset_ for_ item scrollToIndexon a SECTIONED list: the DATA index → its flat row (section_rows; absent →scroll, no move), thenscroll_offset_for_indexover the rows’ extents withinset= the extent of the item’s own section header when headers are sticky (it pins over the item), else 0. The reference’sscrollOffsetForItem.- section_
rows - The flat ROW list a sectioned list windows: a header before each section’s items.
- sticky_
header - The LAST header row starting at or before
scrollpins at the viewport start, pushed back by the next header (min(scroll, nextStart − extent)).row_offsets=item_offsetsof the flat rows,header_rowsascending.Nonebefore the first header. - sticky_
header_ by sticky_headerover accessors: only the header rows are read (binary search; O(log headers)).- table_
row_ keys - Table row keys: the
row_keyFIELD (defaultid) under the same rules. - template_
instances - The items a
templaterenders in a data scope: one per array item attemplate.path(relative toscope), keyed bytemplate.key;instance= the suffix of the item the template sits in (`` at the top). The key is escaped byinstance_segment. - template_
item_ keys - The instance key of every item: the value at
key_pointer(relative to the item; objects as their JSON) —#<index>when that value is missing, null, `` or a DUPLICATE of an earlier item’s key (more#s until unique); without a pointer, the index.templateItemKeys. - virtual_
window - The items to render for a viewport
[scroll, scroll + viewport)on the list’s axis (relative to its content start): every item intersecting it (an item ending exactly atscrollcounts) plusoverscanon each side.virtualWindow.