[{"data":1,"prerenderedAt":717},["ShallowReactive",2],{"navigation_docs":3,"-getting-started-architecture":107,"-getting-started-architecture-surround":712},[4,26,57,87,97],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":25},"Getting Started","i-lucide-rocket","\u002Fgetting-started","1.getting-started",[10,15,20],{"title":11,"path":12,"stem":13,"icon":14},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F1.introduction","i-lucide-book-open",{"title":16,"path":17,"stem":18,"icon":19},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F2.installation","i-lucide-download",{"title":21,"path":22,"stem":23,"icon":24},"Architecture","\u002Fgetting-started\u002Farchitecture","1.getting-started\u002F3.architecture","i-lucide-workflow",false,{"title":27,"icon":28,"path":29,"stem":30,"children":31,"page":25},"Reference","i-lucide-layers","\u002Freference","2.reference",[32,37,42,47,52],{"title":33,"path":34,"stem":35,"icon":36},"VirtualGrid","\u002Freference\u002Fvirtual-grid","2.reference\u002F1.virtual-grid","i-lucide-table-2",{"title":38,"path":39,"stem":40,"icon":41},"Primitives","\u002Freference\u002Fprimitives","2.reference\u002F2.primitives","i-lucide-crosshair",{"title":43,"path":44,"stem":45,"icon":46},"Utilities","\u002Freference\u002Futilities","2.reference\u002F3.utilities","i-lucide-wrench",{"title":48,"path":49,"stem":50,"icon":51},"Benchmarks","\u002Freference\u002Fbenchmarks","2.reference\u002F4.benchmarks","i-lucide-timer",{"title":53,"path":54,"stem":55,"icon":56},"ARIA patterns","\u002Freference\u002Faria-patterns","2.reference\u002F6.aria-patterns","i-lucide-accessibility",{"title":58,"icon":59,"path":60,"stem":61,"children":62,"page":25},"Guides","i-lucide-compass","\u002Fguides","3.guides",[63,67,72,77,82],{"title":64,"path":65,"stem":66,"icon":56},"Accessibility","\u002Fguides\u002Faccessibility","3.guides\u002F1.accessibility",{"title":68,"path":69,"stem":70,"icon":71},"Popovers and overlays","\u002Fguides\u002Fpopovers","3.guides\u002F2.popovers","i-lucide-message-square",{"title":73,"path":74,"stem":75,"icon":76},"Floating UI","\u002Fguides\u002Ffloating-ui","3.guides\u002F3.floating-ui","i-lucide-layers-2",{"title":78,"path":79,"stem":80,"icon":81},"Sizing and direction","\u002Fguides\u002Fsizing-and-direction","3.guides\u002F4.sizing-and-direction","i-lucide-move",{"title":83,"path":84,"stem":85,"icon":86},"Performance","\u002Fguides\u002Fperformance","3.guides\u002F5.performance","i-lucide-gauge",{"title":88,"icon":89,"path":90,"stem":91,"children":92,"page":25},"Examples","i-lucide-flask-conical","\u002Fexamples","4.examples",[93],{"title":94,"path":95,"stem":96,"icon":56},"ARIA examples","\u002Fexamples\u002Faria","4.examples\u002F1.aria",{"title":98,"icon":99,"path":100,"stem":101,"children":102,"page":25},"Changes","i-lucide-history","\u002Fchanges","5.changes",[103],{"title":104,"path":105,"stem":106,"icon":99},"Changelog","\u002Fchanges\u002Fchangelog","5.changes\u002F1.changelog",{"id":108,"title":21,"body":109,"description":705,"extension":706,"links":707,"meta":708,"navigation":709,"path":22,"seo":710,"stem":23,"__hash__":711},"docs\u002F1.getting-started\u002F3.architecture.md",{"type":110,"value":111,"toc":694},"minimark",[112,116,140,150,155,161,203,226,265,269,278,316,326,343,347,354,384,387,391,400,448,459,463,484,524,542,559,568,572,591,605,608,612,640,660,664,682],[113,114,115],"p",{},"This page follows one update through the grid, in the order the data flows. It is for contributors and for users who need to know why the grid behaves the way it does. You do not need it to use the grid.",[113,117,118,119,123,124,127,128,131,132,135,136,139],{},"The code lives in ",[120,121,122],"code",{},"core\u002Fsrc",". ",[120,125,126],{},"Grid.vue"," creates the inputs and renders the result. ",[120,129,130],{},"pipeline.ts"," holds the RxJS pipeline between them. ",[120,133,134],{},"utilites.ts"," and ",[120,137,138],{},"composables\u002F"," hold the helpers that turn props, resizes and scrolls into streams.",[141,142,148],"pre",{"className":143,"code":145,"language":146,"meta":147},[144],"language-text","props ─────────────┐\ngrid + probe size ─┼─> measurement ─┐\nscroll parents ────┘                ├─> buffer window ─> page numbers ─> pageProvider\n                                    │                                        │\n                                    │                                  loaded pages\n                                    │                                        │\n                                    └────────────> items in the DOM \u003C────────┘\n","text","",[120,149,145],{"__ignoreMap":147},[151,152,154],"h2",{"id":153},"inputs","Inputs",[113,156,157,160],{},[120,158,159],{},"pipeline()"," takes nine streams. Three kinds feed it.",[113,162,163,167,168,171,172,174,175,178,179,182,183,186,187,186,190,186,193,186,196,135,199,202],{},[164,165,166],"strong",{},"Props."," ",[120,169,170],{},"fromProp(props, \"length\")"," in ",[120,173,134],{}," creates an RxJS ",[120,176,177],{},"Observable"," from a prop. It emits the current value at once and again whenever a Vue ",[120,180,181],{},"watchEffect"," sees the prop change. The grid does this for ",[120,184,185],{},"length",", ",[120,188,189],{},"pageProvider",[120,191,192],{},"pageProviderDebounceTime",[120,194,195],{},"pageSize",[120,197,198],{},"scrollTo",[120,200,201],{},"respectScrollToOnResize",".",[113,204,205,167,208,211,212,215,216,219,220,222,223,202],{},[164,206,207],{},"Sizes.",[120,209,210],{},"fromResizeObserver"," wraps VueUse's ",[120,213,214],{},"useResizeObserver"," and delivers entries on an animation frame. The grid observes two elements. The grid element yields the element itself, and the probe element yields its ",[120,217,218],{},"contentRect",". On the server ",[120,221,210],{}," returns an empty stream, because there is no ",[120,224,225],{},"window",[113,227,228,167,231,171,234,237,238,241,242,245,246,249,250,253,254,245,257,249,259,261,262,202],{},[164,229,230],{},"Scrolling.",[120,232,233],{},"fromScrollParent",[120,235,236],{},"composables\u002FuseFromScrollParent.ts"," calls ",[120,239,240],{},"getElementScrollParents"," to find the nearest ancestor with ",[120,243,244],{},"overflow-y"," of ",[120,247,248],{},"auto"," or ",[120,251,252],{},"scroll",", and the nearest with ",[120,255,256],{},"overflow-x",[120,258,248],{},[120,260,252],{},". If none exists, it falls back to the page. It then adds a passive scroll listener to each, with capture on, and emits the grid element on every scroll event. A fixed-position grid scrolls against ",[120,263,264],{},"document.body",[151,266,268],{"id":267},"measurement","Measurement",[113,270,271,272,171,275,202],{},"The grid combines the latest grid element and the latest probe size into one ",[120,273,274],{},"ResizeMeasurement",[120,276,277],{},"getResizeMeasurement",[279,280,281,301,307],"ul",{},[282,283,284,285,186,288,186,291,294,295,135,298,202],"li",{},"From the grid's computed style it reads ",[120,286,287],{},"row-gap",[120,289,290],{},"column-gap",[120,292,293],{},"grid-auto-flow",", and the number of tracks in ",[120,296,297],{},"grid-template-columns",[120,299,300],{},"grid-template-rows",[282,302,303,304,306],{},"From the probe's ",[120,305,218],{}," it reads the item width and height.",[282,308,309,310,135,313,202],{},"It adds the gap to each size, giving ",[120,311,312],{},"itemWidthWithGap",[120,314,315],{},"itemHeightWithGap",[113,317,318,319,321,322,325],{},"Because the column count is the number of tracks in the computed ",[120,320,297],{},", a ",[120,323,324],{},"repeat(auto-fill, ...)"," grid reports the number of columns that fit at that moment.",[113,327,328,329,332,333,336,337,339,340,202],{},"The measurement passes through ",[120,330,331],{},"distinctUntilChanged",", which compares the fields, and ",[120,334,335],{},"shareReplay",", so every consumer reads one measurement, and nothing downstream runs when a resize leaves it unchanged. The same stream is exposed as ",[120,338,267],{},", and a change to it emits ",[120,341,342],{},"layout-change",[151,344,346],{"id":345},"the-buffer-window","The buffer window",[113,348,349,350,353],{},"The grid renders more items than the screen shows, so a fast scroll does not reveal empty space. ",[120,351,352],{},"computeBufferMeta"," works in lines. A line is a row in row flow and a column in column flow.",[355,356,357,364,367,378,381],"ol",{},[282,358,359,360,363],{},"It measures how far the grid's top (or left) edge has moved above the browser window with ",[120,361,362],{},"getBoundingClientRect",". The result is the space scrolled past.",[282,365,366],{},"It divides that space by the item size plus gap, which gives the number of lines before the viewport. Multiplying by the tracks across gives the index of the first visible item.",[282,368,369,370,373,374,377],{},"It counts the lines that fit in ",[120,371,372],{},"window.innerHeight"," (or ",[120,375,376],{},"innerWidth","), adds one, and multiplies by the tracks across. This is the visible count.",[282,379,380],{},"The buffer starts half a visible count before the first visible item, and never before index 0.",[282,382,383],{},"The buffer is twice the visible count long.",[113,385,386],{},"The window comes from index arithmetic only. The grid keeps no per-item state and reads no item's size, which is why all items must share the probe's size.",[151,388,390],{"id":389},"page-requests","Page requests",[113,392,393,396,397,399],{},[120,394,395],{},"getObservableOfVisiblePageNumbers"," turns the buffer window into page numbers. It divides the window's start and end by ",[120,398,195],{},", which gives a range of pages.",[355,401,402,408,419,426,436],{},[282,403,404,405,407],{},"With a non-zero ",[120,406,192],{},", the stream of page ranges is debounced, so pages skimmed past during a fast scroll are never requested.",[282,409,410,411,413,414,186,416,418],{},"Each page number goes to a memoized ",[120,412,189],{},". The memo key is the length, the page number, the page size and a version counter. A page already requested is not requested again, and a change of ",[120,415,185],{},[120,417,195],{}," or the provider function starts a fresh memo.",[282,420,421,422,425],{},"The ",[120,423,424],{},"recompute"," function in the pipeline bumps the version counter to drop the memo on demand.",[282,427,428,431,432,435],{},[120,429,430],{},"callPageProvider"," wraps the result in ",[120,433,434],{},"Promise.resolve",", so a provider can return an array or a promise.",[282,437,438,441,442,444,445,447],{},[120,439,440],{},"accumulateItemStore"," keeps each page in a map under its page number, so memory grows with the pages loaded and not with ",[120,443,185],{},". A change of ",[120,446,195],{}," empties the map.",[113,449,450,451,454,455,458],{},"The map is internal. An item whose page is not in the map is ",[120,452,453],{},"undefined",", and the grid renders it through the ",[120,456,457],{},"placeholder"," slot.",[151,460,462],{"id":461},"rendering","Rendering",[113,464,465,468,469,472,473,476,477,480,481,202],{},[120,466,467],{},"createVisibleItemsGetter"," takes the buffer window, the measurement and the loaded pages, and returns one ",[120,470,471],{},"InternalItem"," per index in the window. An item holds its ",[120,474,475],{},"index",", its ",[120,478,479],{},"value"," and a ",[120,482,483],{},"style",[279,485,486,512,515],{},[282,487,421,488,490,491,480,494,497,498,135,501,504,505,135,508,511],{},[120,489,483],{}," is ",[120,492,493],{},"grid-area: 1\u002F1",[120,495,496],{},"translate(x, y)"," transform. The grid computes ",[120,499,500],{},"x",[120,502,503],{},"y"," from the index, the measurement and the flow: row flow uses ",[120,506,507],{},"index % columns",[120,509,510],{},"floor(index \u002F columns)",", column flow uses the rows.",[282,513,514],{},"The getter reuses the previous items whose value and position did not change. It returns the same array when nothing changed.",[282,516,517,520,521,523],{},[120,518,519],{},"accumulateBuffer"," goes one step further. An item that left the window gives its slot to an item that entered it, so the list of rendered elements keeps its length. A loaded item is never replaced by a placeholder when a stale ",[120,522,453],{}," arrives.",[113,525,526,527,530,531,373,534,537,538,541],{},"All items sit in grid cell 1\u002F1, and the ",[120,528,529],{},"transform"," moves each to its position. The browser does not lay out the items on scroll. The grid element's ",[120,532,533],{},"height",[120,535,536],{},"width"," in column flow) is set to the size of the whole list, computed in ",[120,539,540],{},"getContentSize"," as the line count times the item size plus gap, minus the last gap. That height is what gives the scroll parent its scrollbar.",[113,543,544,545,548,549,123,552,555,556,558],{},"The grid keys items with ",[120,546,547],{},"\u003CkeyPrefix>.\u003Cindex>"," when you do not provide ",[120,550,551],{},"getKey",[120,553,554],{},"keyPrefix"," changes when ",[120,557,189],{}," changes, so elements are recreated for a new provider.",[113,560,561,563,564,567],{},[120,562,198],{}," takes the same arithmetic. ",[120,565,566],{},"getItemOffsetByIndex"," converts the index to an offset, and the pipeline adds the grid's padding, border and distance from its scroll parent, then scrolls that parent.",[151,569,571],{"id":570},"server-rendering","Server rendering",[113,573,574,576,577,579,580,583,584,587,588,590],{},[120,575,159],{}," is asynchronous, and ",[120,578,126],{}," awaits it in ",[120,581,582],{},"\u003Cscript setup>",". Before it builds any stream, the pipeline calls ",[120,585,586],{},"pageProvider(0, pageSize)"," once. The result is the first buffer, with no ",[120,589,483],{},", so the server renders the first page with no positions.",[113,592,593,594,597,598,601,602,604],{},"The probe also moves. While ",[120,595,596],{},"ready"," is false, the probe is rendered after the items, with no ",[120,599,600],{},"grid-area",". Once the first measurement produces items, ",[120,603,596],{}," becomes true and the probe renders first, in cell 1\u002F1.",[113,606,607],{},"The client builds the same first buffer, so hydration matches the server HTML. After mount, the observers measure the probe, the pipeline emits real items with positions, and the grid replaces the first buffer.",[151,609,611],{"id":610},"exposed-refs-and-events","Exposed refs and events",[113,613,614,135,616,618,619,622,623,626,627,630,631,633,634,636,637,639],{},[120,615,596],{},[120,617,267],{}," are ",[120,620,621],{},"shallowRef"," values created before the ",[120,624,625],{},"await"," and passed to ",[120,628,629],{},"defineExpose",". A template ref binds to the component when it mounts. If the component exposes values only after the ",[120,632,625],{},", the parent's ref points at the instance from before the ",[120,635,625],{}," and sees no exposed values until the parent renders again. Exposing the refs before the ",[120,638,625],{}," means they exist on the first render.",[113,641,642,644,645,186,648,135,651,653,654,659],{},[120,643,126],{}," emits ",[120,646,647],{},"render",[120,649,650],{},"viewport-scroll",[120,652,342],{}," from the buffer, scroll and measurement streams. The ",[655,656,658],"a",{"href":657},"\u002Freference\u002Fvirtual-grid#events","VirtualGrid events table"," says when each one fires and what to do in a handler.",[151,661,663],{"id":662},"where-the-primitives-fit","Where the primitives fit",[113,665,666,669,670,673,674,676,677,249,679,681],{},[120,667,668],{},"vvirtual-grid\u002Fprimitives"," is separate from the grid. ",[120,671,672],{},"primitives.ts"," imports only the ",[120,675,274],{}," type, and nothing in ",[120,678,126],{},[120,680,130],{}," imports it. The primitives are pure functions of a measurement and an index, so the same formulas that place items in the DOM place items that are not rendered.",[113,683,684,685,687,688,123,691,693],{},"You pass the exposed ",[120,686,267],{}," to them as ",[120,689,690],{},"layout",[655,692,38],{"href":39}," lists each function.",{"title":147,"searchDepth":695,"depth":695,"links":696},2,[697,698,699,700,701,702,703,704],{"id":153,"depth":695,"text":154},{"id":267,"depth":695,"text":268},{"id":345,"depth":695,"text":346},{"id":389,"depth":695,"text":390},{"id":461,"depth":695,"text":462},{"id":570,"depth":695,"text":571},{"id":610,"depth":695,"text":611},{"id":662,"depth":695,"text":663},"How data flows through the grid, from props and scrolling to the items in the DOM.","md",null,{},{"icon":24},{"title":21,"description":705},"TIVtDQBWMKVuMvkIxcyNaKvTuXd_WIzJ0g6_xjGs40k",[713,715],{"title":16,"path":17,"stem":18,"description":714,"icon":19,"children":-1},"Add vvirtual-grid to a Vue or Nuxt project and render a first grid.",{"title":33,"path":34,"stem":35,"description":716,"icon":36,"children":-1},"Props, events, slots and exposed refs of the VirtualGrid component.",1794785668767]