virtua 0.52.0 → 0.52.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/angular/VGrid.d.ts +20 -20
- package/lib/angular/index.d.ts +1 -1
- package/lib/angular/index.js +287 -269
- package/lib/angular/index.js.map +1 -1
- package/lib/core/grid.d.ts +3 -3
- package/lib/core/index.cjs +286 -268
- package/lib/core/index.cjs.map +1 -1
- package/lib/core/index.d.ts +4 -4
- package/lib/core/index.js +258 -240
- package/lib/core/index.js.map +1 -1
- package/lib/core/layouts/grid.d.ts +8 -6
- package/lib/core/scroll-to.d.ts +1 -1
- package/lib/index.cjs +429 -411
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +444 -426
- package/lib/index.js.map +1 -1
- package/lib/react/VGrid.d.ts +16 -16
- package/lib/react/index.d.ts +1 -1
- package/lib/solid/VGrid.d.ts +16 -16
- package/lib/solid/index.cjs +436 -418
- package/lib/solid/index.cjs.map +1 -1
- package/lib/solid/index.d.ts +1 -1
- package/lib/solid/index.js +466 -448
- package/lib/solid/index.js.map +1 -1
- package/lib/solid/index.jsx +206 -191
- package/lib/solid/index.jsx.map +1 -1
- package/lib/svelte/GridCell.svelte +2 -2
- package/lib/svelte/GridRow.svelte +4 -4
- package/lib/svelte/GridRowGroup.svelte +5 -5
- package/lib/svelte/VGrid.svelte +20 -10
- package/lib/svelte/VGrid.type.d.ts +16 -16
- package/lib/svelte/index.d.ts +1 -1
- package/lib/vue/VGrid.d.ts +16 -16
- package/lib/vue/index.cjs +431 -413
- package/lib/vue/index.cjs.map +1 -1
- package/lib/vue/index.d.ts +1 -1
- package/lib/vue/index.js +450 -432
- package/lib/vue/index.js.map +1 -1
- package/package.json +1 -1
package/lib/vue/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["ref","defineComponent","watch","computed","mergeProps","_mergeProps","createVNode","_createVNode","ListItem","props","elementRef","offset","_stateVersion","value","_store","$getItemOffset","_index","hide","$isUnmeasuredItem","children","_slot","item","_item","index","_","__","onCleanup","_resizer","flush","_isHorizontal","isHorizontal","_isSSR","isSSR","_as","Element","isHide","style","styleProp","rest","_itemProps","contain","position","undefined","visibility","display","default","ref","onMounted","defineComponent","onUnmounted","watch","computed","createVNode","_createVNode","isVNode","_isVNode","UPDATE_SCROLL_EVENT","UPDATE_SCROLL_END_EVENT","UPDATE_VIRTUAL_STATE","createVirtualStore","createListLayout","ACTION_ITEMS_LENGTH_CHANGE","getScrollSize","ACTION_START_OFFSET_CHANGE","createContainerDriver","scrollTo","scrollBy","scrollToIndex","sort","ListItem","getKey","isSameRange","_isSlot","s","Object","prototype","toString","call","Virtualizer","props","data","type","Array","required","bufferSize","Number","itemSize","shift","Boolean","horizontal","startMargin","default","ssrCount","scrollRef","as","String","item","itemProps","Function","keepMounted","cache","emits","setup","emit","expose","slots","isSSR","isHorizontal","containerRef","layout","length","store","driver","stateVersion","$getStateVersion","$subscribe","value","$getScrollOffset","range","prev","next","$getRange","isScrolling","$isScrolling","totalSize","$getTotalSize","container","raf","requestAnimationFrame","$observe","cancelAnimationFrame","$dispose","count","$update","immediate","$effect","flush","$snapshot","scrollOffset","scrollSize","viewportSize","$getViewportSize","findItemIndex","$findItemIndex","getItemOffset","$getItemOffset","getItemSize","$getItemSize","index","opts","offset","Element","ItemElement","total","items","renderItem","i","e","$observeItem","len","mounted","Set","j","add","forEach","push","contain","overflowAnchor","flex","position","width","height","pointerEvents","undefined","_","defineComponent","ref","isVNode","_isVNode","createVNode","_createVNode","Virtualizer","_isSlot","s","Object","prototype","toString","call","VList","props","data","type","Array","required","bufferSize","Number","itemSize","shift","Boolean","horizontal","ssrCount","itemProps","Function","keepMounted","cache","emits","setup","emit","expose","slots","onScroll","offset","onScrollEnd","handle","value","scrollOffset","scrollSize","viewportSize","findItemIndex","args","getItemOffset","getItemSize","scrollToIndex","scrollTo","scrollBy","display","contain","width","height","default","_","ref","onMounted","defineComponent","onUnmounted","watch","computed","createVNode","_createVNode","isVNode","_isVNode","UPDATE_SCROLL_END_EVENT","UPDATE_VIRTUAL_STATE","createVirtualStore","createListLayout","ACTION_ITEMS_LENGTH_CHANGE","UPDATE_SCROLL_EVENT","createWindowDriver","scrollToIndex","ListItem","getKey","isSameRange","_isSlot","s","Object","prototype","toString","call","WindowVirtualizer","props","data","type","Array","required","bufferSize","Number","itemSize","ssrCount","shift","Boolean","horizontal","as","String","default","item","cache","emits","setup","emit","slots","expose","isSSR","isHorizontal","containerRef","layout","length","store","driver","stateVersion","$getStateVersion","$subscribe","value","range","prev","next","$getRange","isScrolling","$isScrolling","totalSize","$getTotalSize","el","$observe","$dispose","count","$update","$effect","flush","$snapshot","scrollOffset","$getScrollOffset","viewportSize","$getViewportSize","findItemIndex","$findItemIndex","getItemOffset","$getItemOffset","getItemSize","$getItemSize","index","opts","Element","ItemElement","total","items","i","j","e","push","$observeItem","contain","overflowAnchor","flex","position","width","height","pointerEvents","undefined","_","defineComponent","onMounted","onUnmounted","ref","watch","computed","watchEffect","createVNode","_createVNode","UPDATE_SCROLL_END_EVENT","UPDATE_SCROLL_EVENT","UPDATE_VIRTUAL_STATE","createContainerGridDriver","createGridLayout","createVirtualStore","getAxisItem","getScrollSize","gridScrollBy","gridScrollTo","gridScrollToIndex","updateGridAxis","createGridPlan","GridCell","props","elementRef","_state","$measureRow","$measureCol","element","rowIndex","colIndex","_","onCleanup","_resizer","flush","$col","$rowSpan","$colSpan","$role","$sort","$style","_slot","row","_row","col","_col","cell","_rowIndex","GridRow","$row","$cells","map","_cols","GridRowGroup","$rows","state","_rows","VGrid","rows","type","Number","Array","required","cols","rowHeight","String","colWidth","headerRows","sectionRows","footerRows","headerCols","footerCols","spans","keepMounted","bufferSize","gap","default","ariaSort","Object","emits","setup","emit","expose","slots","containerRef","rowLayout","colLayout","rowStore","colStore","driver","stateVersion","$getStateVersion","rerender","value","$subscribe","scrolled","$getScrollOffset","notifyScrollEnd","$isScrolling","rowCount","$getItemsLength","colCount","plan","$getRange","isScrolling","$observe","$dispose","$effect","verticalScrollOffset","horizontalScrollOffset","scrollHeight","scrollWidth","viewportHeight","$getViewportSize","viewportWidth","findRowIndex","$findItemIndex","findColIndex","getRowOffset","$getItemOffset","getColOffset","getRowSize","$getItemSize","getColSize","scrollToIndex","opts","scrollTo","vertical","horizontal","scrollBy","$rowTemplate","$colTemplate","$groups","marginTop","marginInlineStart","containerStyle","contain","overflowAnchor","flex","display","gridTemplateRows","gridTemplateColumns","height","pointerEvents","undefined","overflow","width","$key","$observeItem"],"sources":["../../src/core/utils.ts","../../src/core/environment.ts","../../src/core/store.ts","../../src/core/cache.ts","../../src/core/layouts/list.ts","../../src/core/layouts/grid.ts","../../src/core/grid.ts","../../src/core/observer.ts","../../src/core/driver.ts","../../src/core/scroll-to.ts","../../src/vue/ListItem.tsx","../../src/vue/utils.ts","../../src/vue/Virtualizer.tsx","../../src/vue/VList.tsx","../../src/vue/WindowVirtualizer.tsx","../../src/vue/VGrid.tsx"],"sourcesContent":["/** @internal */\nexport const NULL = null;\n\n/**\n * @internal\n */\nexport const EMPTY: readonly never[] = [];\n\n/** @internal */\nexport const { min, max, abs, floor } = Math;\n\n/**\n * @internal\n */\nexport const clamp = (\n value: number,\n minValue: number,\n maxValue: number,\n): number => min(maxValue, max(minValue, value));\n\n/**\n * @internal\n */\nexport const sort = <T extends number>(arr: T[]): T[] => {\n return arr.sort((a, b) => a - b);\n};\n\n/**\n * @internal\n */\nexport const timeout = setTimeout;\n/**\n * @internal\n */\nexport const cancelTimeout = clearTimeout;\n\n/**\n * @internal\n */\nexport const microtask: (fn: () => void) => void =\n typeof queueMicrotask === \"function\"\n ? queueMicrotask\n : (fn) => {\n Promise.resolve().then(fn);\n };\n\n/**\n * @internal\n */\nexport const createPromise = <T = void>(): [Promise<T>, (arg: T) => void] => {\n let resolve: ((arg: T) => void) | undefined;\n const promise = new Promise<T>((res) => {\n resolve = res;\n });\n return [promise, resolve!];\n};\n","import { NULL } from \"./utils.js\";\n\n/**\n * @internal\n */\nexport const isBrowser = typeof window !== \"undefined\";\n\n/**\n * @internal\n */\nexport const getCurrentDocument = (node: HTMLElement): Document =>\n node.ownerDocument;\n\n/**\n * @internal\n */\nexport const getCurrentWindow = (doc: Document) => doc.defaultView!;\n\nlet isIOS: boolean | undefined;\n\n/**\n * Currently, all browsers on iOS/iPadOS are WebKit, including WebView.\n * @internal\n */\nexport const isIOSWebKit = (): boolean => {\n if (isIOS == NULL) {\n isIOS =\n /iP(hone|od|ad)/.test(navigator.userAgent) ||\n // Modern iPad detection (iPadOS 13+)\n // iPadOS 13+ reports the same userAgent/platform information as macOS, to enable desktop sites.\n // So we treat devices that have macOS like information but with touch support as iPadOS.\n // https://stackoverflow.com/questions/57776001/how-to-detect-ipad-pro-as-ipad-using-javascript\n (navigator.platform === \"MacIntel\" && navigator.maxTouchPoints > 0);\n }\n return isIOS;\n};\n","import { isIOSWebKit } from \"./environment.js\";\nimport type { Layout } from \"./layouts/types.js\";\nimport type { ItemResize, ItemsRange } from \"./types.js\";\nimport { abs, max, min, NULL } from \"./utils.js\";\n\nconst MAX_INT_32 = 0x7fffffff;\n\nconst SCROLL_IDLE = 0;\nconst SCROLL_DOWN = 1;\nconst SCROLL_UP = 2;\ntype ScrollDirection =\n typeof SCROLL_IDLE | typeof SCROLL_DOWN | typeof SCROLL_UP;\n\nconst SCROLL_BY_NATIVE = 0;\nconst SCROLL_BY_MANUAL_SCROLL = 1;\nconst SCROLL_BY_SHIFT = 2;\ntype ScrollMode =\n | typeof SCROLL_BY_NATIVE\n | typeof SCROLL_BY_MANUAL_SCROLL\n | typeof SCROLL_BY_SHIFT;\n\n/** @internal */\nexport const ACTION_SCROLL = 1;\n/** @internal */\nexport const ACTION_SCROLL_END = 2;\n/** @internal */\nexport const ACTION_ITEM_RESIZE = 3;\n/** @internal */\nexport const ACTION_VIEWPORT_RESIZE = 4;\n/** @internal */\nexport const ACTION_ITEMS_LENGTH_CHANGE = 5;\n/** @internal */\nexport const ACTION_START_OFFSET_CHANGE = 6;\n/** @internal */\nexport const ACTION_MANUAL_SCROLL = 7;\n/** @internal */\nexport const ACTION_BEFORE_MANUAL_SMOOTH_SCROLL = 8;\n/** @internal */\nexport const ACTION_RELAYOUT = 9;\n\ntype Actions =\n | [type: typeof ACTION_SCROLL, offset: number]\n | [type: typeof ACTION_SCROLL_END, dummy?: void]\n | [type: typeof ACTION_ITEM_RESIZE, entries: ItemResize[]]\n | [type: typeof ACTION_VIEWPORT_RESIZE, size: number]\n | [\n type: typeof ACTION_ITEMS_LENGTH_CHANGE,\n arg: [length: number, isShift?: boolean | undefined],\n ]\n | [type: typeof ACTION_START_OFFSET_CHANGE, offset: number]\n | [type: typeof ACTION_MANUAL_SCROLL, dummy?: void]\n | [type: typeof ACTION_BEFORE_MANUAL_SMOOTH_SCROLL, offset: number]\n | [type: typeof ACTION_RELAYOUT, jump: number];\n\n/** @internal */\nexport const UPDATE_VIRTUAL_STATE = 0b0001;\n/** @internal */\nexport const UPDATE_SIZE_EVENT = 0b0010;\n/** @internal */\nexport const UPDATE_SCROLL_EVENT = 0b0100;\n/** @internal */\nexport const UPDATE_SCROLL_END_EVENT = 0b1000;\n\n/**\n * @internal\n */\nexport const getScrollSize = (store: VirtualStore): number => {\n return max(store.$getTotalSize(), store.$getViewportSize());\n};\n\ntype Subscriber = (sync?: boolean) => void;\n\n/** @internal */\nexport type StateVersion =\n number & {}; /* hack for typescript to pretend as not falsy */\n\n/**\n * @internal\n */\nexport type VirtualStore = {\n $dispose(): void;\n $getStateVersion(): StateVersion;\n $getRange(bufferSize?: number): ItemsRange;\n $findItemIndex(offset: number): number;\n $isUnmeasuredItem(index: number): boolean;\n $getItemOffset(index: number): number;\n $getItemSize(index: number): number;\n $getItemsLength(): number;\n $getScrollOffset(): number;\n $isScrolling(): boolean;\n $getViewportSize(): number;\n $getStartSpacerSize(): number;\n $getTotalSize(): number;\n _flushJump(): [number, boolean];\n $subscribe(target: number, cb: Subscriber): () => void;\n $update(...action: Actions): void;\n};\n\n/**\n * @internal\n */\nexport const createVirtualStore = (\n {\n $getRange: getRange,\n $findIndex: findIndex,\n $getItemOffset: getOffset,\n $getItemSize: getItemSize,\n $setItemSize: setItemSize,\n $isSizeEqual: isSizeEqual,\n $getTotalSize: getTotalSize,\n $getLength: getLength,\n $setLength: setLength,\n $estimateDefaultSize: estimateDefaultSize,\n }: Layout,\n ssrCount: number = 0,\n): VirtualStore => {\n let shouldAutoEstimateItemSize = !!estimateDefaultSize;\n let isSSR = !!ssrCount;\n let stateVersion: StateVersion = 1;\n let viewportSize = 0;\n let startSpacerSize = 0;\n let scrollOffset = 0;\n let jump = 0;\n let pendingJump = 0;\n let _flushedJump = 0;\n let _scrollDirection: ScrollDirection = SCROLL_IDLE;\n let _scrollMode: ScrollMode = SCROLL_BY_NATIVE;\n let _frozenRange: ItemsRange | null = NULL;\n let _prevRange: ItemsRange = [0, isSSR ? max(ssrCount - 1, 0) : -1];\n let _totalMeasuredSize = 0;\n let _isViewportMeasured = false;\n\n const subscribers = new Set<[number, Subscriber]>();\n const getRelativeScrollOffset = () => scrollOffset - startSpacerSize;\n const getVisibleOffset = () => getRelativeScrollOffset() + pendingJump + jump;\n const getItemOffset = (index: number): number => {\n return getOffset(index) - pendingJump;\n };\n\n const applyJump = (j: number) => {\n if (j) {\n if (\n // In iOS WebKit browsers, updating scroll position will stop scrolling so it have to be deferred during scrolling.\n (isIOSWebKit() && _scrollDirection !== SCROLL_IDLE) ||\n // Before imperative smooth scrolling, we measure all items which may be visible during scrolling.\n // However, especially in Firefox, there are rare cases where items resize while scrolling, which can stop smooth scrolling.\n (_frozenRange && _scrollMode === SCROLL_BY_MANUAL_SCROLL)\n ) {\n pendingJump += j;\n } else {\n jump += j;\n }\n }\n };\n\n return {\n $dispose: () => {\n subscribers.clear();\n },\n $getStateVersion: () => stateVersion,\n $getRange: (bufferSize = 200) => {\n if (!_isViewportMeasured || isSSR) {\n // Return range for SSR, or return [0, -1] to render nothing, until the scroll offset and viewport size are determined.\n // https://github.com/inokawa/virtua/issues/415\n // https://github.com/inokawa/virtua/pull/818\n return _prevRange;\n }\n let startIndex: number;\n let endIndex: number;\n if (_flushedJump) {\n // Return previous range for consistent render until next scroll event comes in.\n // And it must be clamped. https://github.com/inokawa/virtua/issues/597\n [startIndex, endIndex] = _prevRange;\n } else {\n let startOffset = max(0, getVisibleOffset());\n let endOffset = startOffset + viewportSize;\n\n // For faster initial render pass, returns without buffer if measurement seems to be in progress.\n if (!shouldAutoEstimateItemSize) {\n bufferSize = max(0, bufferSize);\n\n if (_scrollDirection !== SCROLL_DOWN) {\n startOffset -= bufferSize;\n }\n if (_scrollDirection !== SCROLL_UP) {\n endOffset += bufferSize;\n }\n }\n\n [startIndex, endIndex] = _prevRange = getRange(\n max(0, startOffset),\n max(0, endOffset),\n );\n if (_frozenRange) {\n startIndex = min(startIndex, _frozenRange[0]);\n endIndex = max(endIndex, _frozenRange[1]);\n }\n }\n\n return [max(startIndex, 0), min(endIndex, getLength() - 1)];\n },\n $findItemIndex: (offset) => findIndex(offset - startSpacerSize),\n $isUnmeasuredItem: isSizeEqual,\n $getItemOffset: getItemOffset,\n $getItemSize: getItemSize,\n $getItemsLength: getLength,\n $getScrollOffset: () => scrollOffset,\n $isScrolling: () => _scrollDirection !== SCROLL_IDLE,\n $getViewportSize: () => viewportSize,\n $getStartSpacerSize: () => startSpacerSize,\n $getTotalSize: getTotalSize,\n _flushJump: () => {\n _flushedJump = jump;\n jump = 0;\n return [_flushedJump, _scrollMode === SCROLL_BY_SHIFT];\n },\n $subscribe: (target, cb) => {\n const sub: [number, Subscriber] = [target, cb];\n subscribers.add(sub);\n return () => {\n subscribers.delete(sub);\n };\n },\n $update: (type, payload): void => {\n let shouldFlushPendingJump: boolean | undefined;\n let shouldSync: boolean | undefined;\n let mutated = 0;\n\n switch (type) {\n case ACTION_SCROLL: {\n if (payload === scrollOffset && _scrollMode === SCROLL_BY_NATIVE) {\n // Ignore scroll events from different direction\n break;\n }\n\n const flushedJump = _flushedJump;\n _flushedJump = 0;\n\n const delta = payload - scrollOffset;\n const distance = abs(delta);\n\n // Scroll event after jump compensation is not reliable because it may result in the opposite direction.\n // The delta of artificial scroll may not be equal with the jump because it may be batched with other scrolls.\n // And at least in latest Chrome/Firefox/Safari in 2023, setting value to scrollTop/scrollLeft can lose subpixel because its integer (sometimes float probably depending on dpr).\n const isJustJumped = flushedJump && distance < abs(flushedJump) + 1;\n\n // Scroll events are dispatched enough so it's ok to skip some of them.\n if (\n !isJustJumped &&\n // Ignore until manual scrolling\n _scrollMode === SCROLL_BY_NATIVE\n ) {\n _scrollDirection = delta < 0 ? SCROLL_UP : SCROLL_DOWN;\n }\n\n // TODO This will cause glitch in reverse infinite scrolling. Disable this until better solution is found.\n // if (\n // pendingJump &&\n // ((_scrollDirection === SCROLL_UP &&\n // payload - max(pendingJump, 0) <= 0) ||\n // (_scrollDirection === SCROLL_DOWN &&\n // payload - min(pendingJump, 0) >= getScrollOffsetMax()))\n // ) {\n // // Flush if almost reached to start or end\n // shouldFlushPendingJump = true;\n // }\n\n if (isSSR) {\n isSSR = false;\n }\n\n scrollOffset = payload;\n mutated = UPDATE_SCROLL_EVENT;\n\n // Skip if offset is not changed\n // Scroll offset may exceed min or max especially in Safari's elastic scrolling.\n const relativeOffset = getRelativeScrollOffset();\n if (\n relativeOffset >= -viewportSize &&\n relativeOffset <= getTotalSize()\n ) {\n mutated += UPDATE_VIRTUAL_STATE;\n\n // Update synchronously if scrolled a lot\n shouldSync = distance > viewportSize;\n }\n break;\n }\n case ACTION_SCROLL_END: {\n mutated = UPDATE_SCROLL_END_EVENT;\n if (_scrollDirection !== SCROLL_IDLE) {\n shouldFlushPendingJump = true;\n mutated += UPDATE_VIRTUAL_STATE;\n }\n _scrollDirection = SCROLL_IDLE;\n _scrollMode = SCROLL_BY_NATIVE;\n _frozenRange = NULL;\n break;\n }\n case ACTION_ITEM_RESIZE: {\n const updated = payload.filter(\n ([index, size]) => !isSizeEqual(index, size),\n );\n\n // Skip if all items are cached and not updated\n if (!updated.length) {\n break;\n }\n\n // Calculate jump by resize to minimize junks in appearance\n applyJump(\n updated.reduce((acc, [index, size]) => {\n let shouldKeep: boolean;\n if (\n // Keep distance from end during shifting\n _scrollMode === SCROLL_BY_SHIFT\n ) {\n shouldKeep = true;\n } else if (\n _frozenRange &&\n _scrollMode === SCROLL_BY_MANUAL_SCROLL\n ) {\n // https://github.com/inokawa/virtua/issues/380\n // https://github.com/inokawa/virtua/issues/758\n shouldKeep = index < _frozenRange[0];\n } else {\n // Otherwise we should maintain visible position\n const start = getRelativeScrollOffset();\n const itemOffset = getItemOffset(index);\n const itemSize = getItemSize(index);\n shouldKeep =\n _scrollDirection !== SCROLL_DOWN &&\n _scrollMode === SCROLL_BY_NATIVE\n ? // https://github.com/inokawa/virtua/issues/385\n // https://github.com/inokawa/virtua/discussions/865\n // https://github.com/inokawa/virtua/issues/893\n // Use \"<=\" instead of \"<\" here so the item whose bottom rests exactly on the viewport top (the row directly above an item anchored to the top) is compensated too.\n itemOffset + itemSize <= start\n : // https://github.com/inokawa/virtua/pull/868\n itemOffset < start &&\n itemOffset + itemSize < start + viewportSize;\n }\n\n if (shouldKeep) {\n acc += size - getItemSize(index);\n }\n return acc;\n }, 0),\n );\n\n // Update item sizes\n for (const [index, size] of updated) {\n const prevSize = getItemSize(index);\n const isInitialMeasurement = setItemSize(index, size);\n\n if (shouldAutoEstimateItemSize) {\n _totalMeasuredSize += isInitialMeasurement\n ? size\n : size - prevSize;\n }\n }\n\n // Estimate initial item size from measured sizes\n if (\n shouldAutoEstimateItemSize &&\n viewportSize &&\n // If the total size is lower than the viewport, the item may be a empty state\n _totalMeasuredSize > viewportSize\n ) {\n applyJump(estimateDefaultSize!(findIndex(getVisibleOffset())));\n shouldAutoEstimateItemSize = false;\n }\n\n mutated = UPDATE_VIRTUAL_STATE + UPDATE_SIZE_EVENT;\n\n // Synchronous update is necessary in current design to minimize visible glitch in concurrent rendering.\n // However this seems to be the main cause of the errors from ResizeObserver.\n // https://github.com/inokawa/virtua/issues/470\n //\n // And in React, synchronous update with flushSync after asynchronous update will overtake the asynchronous one.\n // If items resize happens just after scroll, race condition can occur depending on implementation.\n shouldSync = true;\n break;\n }\n case ACTION_VIEWPORT_RESIZE: {\n if (viewportSize !== payload) {\n if (!viewportSize) {\n _isViewportMeasured = shouldSync = true;\n }\n viewportSize = payload;\n mutated = UPDATE_VIRTUAL_STATE + UPDATE_SIZE_EVENT;\n }\n break;\n }\n case ACTION_ITEMS_LENGTH_CHANGE: {\n if (payload[1]) {\n applyJump(setLength(payload[0], true));\n _scrollMode = SCROLL_BY_SHIFT;\n mutated = UPDATE_VIRTUAL_STATE;\n } else {\n setLength(payload[0]);\n // https://github.com/inokawa/virtua/issues/552\n // https://github.com/inokawa/virtua/issues/557\n mutated = UPDATE_VIRTUAL_STATE;\n }\n break;\n }\n case ACTION_START_OFFSET_CHANGE: {\n startSpacerSize = payload;\n break;\n }\n case ACTION_MANUAL_SCROLL: {\n _scrollMode = SCROLL_BY_MANUAL_SCROLL;\n break;\n }\n case ACTION_RELAYOUT: {\n // It never requests a synchronous update, so it's safe to dispatch during render.\n applyJump(payload);\n mutated = UPDATE_VIRTUAL_STATE + UPDATE_SIZE_EVENT;\n break;\n }\n case ACTION_BEFORE_MANUAL_SMOOTH_SCROLL: {\n _frozenRange = getRange(payload, payload + viewportSize);\n mutated = UPDATE_VIRTUAL_STATE;\n break;\n }\n }\n\n if (mutated) {\n stateVersion = (stateVersion & MAX_INT_32) + 1;\n\n if (shouldFlushPendingJump && pendingJump) {\n jump += pendingJump;\n pendingJump = 0;\n }\n\n subscribers.forEach(([target, cb]) => {\n // Early return to skip React's computation\n if (!(mutated & target)) {\n return;\n }\n // https://github.com/facebook/react/issues/25191\n // https://github.com/facebook/react/blob/a5fc797db14c6e05d4d5c4dbb22a0dd70d41f5d5/packages/react-reconciler/src/ReactFiberWorkLoop.js#L1443-L1447\n cb(shouldSync);\n });\n }\n },\n };\n};\n","import { clamp, floor } from \"./utils.js\";\n\n/** @internal */\nexport const UNCACHED = -1;\n\n/**\n * Finds the index of an item in the cache whose computed offset is closest to the specified offset.\n *\n * @internal\n */\nexport const findIndex = (\n getOffset: (index: number) => number,\n length: number,\n offset: number,\n low: number = 0,\n high: number = length - 1,\n): number => {\n // Find with binary search\n let found: number = low;\n while (low <= high) {\n const mid = floor((low + high) / 2);\n if (getOffset(mid) <= offset) {\n found = mid;\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n return clamp(found, 0, length - 1);\n};\n","import { UNCACHED, findIndex } from \"../cache.js\";\nimport type { Layout } from \"./types.js\";\nimport type { CacheSnapshot } from \"../types.js\";\nimport { max, min, sort } from \"../utils.js\";\n\nconst fill = (array: number[], length: number, prepend?: boolean): number[] => {\n const key = prepend ? \"unshift\" : \"push\";\n for (let i = 0; i < length; i++) {\n array[key](UNCACHED);\n }\n return array;\n};\n\n/**\n * @internal\n */\nexport interface ListLayout extends Layout {\n $snapshot(): CacheSnapshot;\n}\n\n/**\n * @internal\n */\nexport const createListLayout = (\n length: number,\n itemSize?: number | undefined,\n snapshot?: CacheSnapshot | undefined,\n): ListLayout => {\n let defaultItemSize = (snapshot && snapshot[1]) || itemSize || 40;\n\n let computedOffsetIndex = -1;\n let prevStartIndex = 0;\n\n const restoredSizes = snapshot && snapshot[0];\n\n const sizes: number[] = restoredSizes\n ? // https://github.com/inokawa/virtua/issues/441\n fill(\n restoredSizes.slice(0, min(length, restoredSizes.length)),\n max(0, length - restoredSizes.length),\n )\n : fill([], length);\n const offsets: number[] = fill([], length + 1);\n\n const getSize = (index: number): number => {\n const size = sizes[index]!;\n return size === UNCACHED ? defaultItemSize : size;\n };\n\n const getOffset = (index: number): number => {\n if (!length) return 0;\n if (computedOffsetIndex >= index) {\n return offsets[index]!;\n }\n\n if (computedOffsetIndex < 0) {\n // first offset must be 0 to avoid returning NaN, which can cause infinite rerender.\n // https://github.com/inokawa/virtua/pull/160\n offsets[0] = 0;\n computedOffsetIndex = 0;\n }\n let i = computedOffsetIndex;\n let top = offsets[i]!;\n while (i < index) {\n top += getSize(i);\n offsets[++i] = top;\n }\n // mark as measured\n computedOffsetIndex = index;\n return top;\n };\n\n return {\n $getRange: (startOffset, endOffset) => {\n // Clamp because prevStartIndex may exceed the limit when children decreased a lot after scrolling\n prevStartIndex = min(prevStartIndex, length - 1);\n\n let start: number;\n let end: number;\n if (getOffset(prevStartIndex) <= startOffset) {\n // search forward\n // start <= end, prevStartIndex <= start\n end = findIndex(getOffset, length, endOffset, prevStartIndex);\n start = findIndex(getOffset, length, startOffset, prevStartIndex, end);\n } else {\n // search backward\n // start <= end, start <= prevStartIndex\n start = findIndex(\n getOffset,\n length,\n startOffset,\n undefined,\n prevStartIndex,\n );\n end = findIndex(getOffset, length, endOffset, start);\n }\n prevStartIndex = start;\n return [start, end];\n },\n $findIndex: (offset) => findIndex(getOffset, length, offset),\n $getItemOffset: getOffset,\n $getItemSize: getSize,\n $setItemSize: (index, size) => {\n const isInitialMeasurement = sizes[index] === UNCACHED;\n sizes[index] = size;\n // mark as dirty\n computedOffsetIndex = min(index, computedOffsetIndex);\n return isInitialMeasurement;\n },\n $isSizeEqual: (index, size = UNCACHED) => sizes[index] === size,\n $getTotalSize: () => getOffset(length),\n $getLength: () => length,\n $setLength: (nextLength, isShift) => {\n const diff = nextLength - length;\n\n computedOffsetIndex = isShift\n ? // Discard cache for now\n -1\n : min(nextLength - 1, computedOffsetIndex);\n length = nextLength;\n\n if (diff > 0) {\n // Added\n fill(offsets, diff);\n fill(sizes, diff, isShift);\n return defaultItemSize * diff;\n } else {\n // Removed\n offsets.splice(diff);\n return (isShift ? sizes.splice(0, -diff) : sizes.splice(diff)).reduce(\n (acc, removed) =>\n acc - (removed === UNCACHED ? defaultItemSize : removed),\n 0,\n );\n }\n },\n $estimateDefaultSize: itemSize\n ? undefined\n : (startIndex) => {\n let measuredCountBeforeStart = 0;\n // This function will be called after measurement so measured size array must be longer than 0\n const measuredSizes: number[] = [];\n sizes.forEach((s, i) => {\n if (s !== UNCACHED) {\n // https://github.com/inokawa/virtua/issues/907\n if (s) {\n measuredSizes.push(s);\n }\n if (i < startIndex) {\n measuredCountBeforeStart++;\n }\n }\n });\n\n // Discard cache for now\n computedOffsetIndex = -1;\n\n // Calculate median\n sort(measuredSizes);\n const len = measuredSizes.length;\n const mid = (len / 2) | 0;\n const median =\n len % 2 === 0\n ? (measuredSizes[mid - 1]! + measuredSizes[mid]!) / 2\n : measuredSizes[mid]!;\n\n const prevDefaultItemSize = defaultItemSize;\n\n // Calculate diff of unmeasured items before start\n return (\n ((defaultItemSize = median) - prevDefaultItemSize) *\n max(startIndex - measuredCountBeforeStart, 0)\n );\n },\n $snapshot: () => [sizes.slice(), defaultItemSize],\n };\n};\n","import { UNCACHED } from \"../cache.js\";\nimport { createListLayout } from \"./list.js\";\nimport type { Layout } from \"./types.js\";\nimport { clamp, floor, NULL } from \"../utils.js\";\n\nexport type VGridTrackSize = number | \"auto\";\n\n/**\n * The rows or the columns of the grid.\n *\n * - If a number is set, the grid has that many rows/columns, and the cells receive their indexes.\n * - If an array is set, the grid has one row/column per item, and the cells receive the items.\n */\nexport type VGridAxis<T = number> = number | readonly T[];\n\nexport type VGridSizeKey<T> = [T] extends [object]\n ? {\n [K in keyof T]-?: K extends string\n ? T[K] extends VGridTrackSize | null | undefined\n ? K\n : never\n : never;\n }[keyof T]\n : never;\n\n/**\n * The sizes of the rows or the columns in pixels.\n *\n * - A number is used as is, and never measured.\n * - `\"auto\"` fits the largest rendered cell. The auto columns also share the space left in the viewport, as the columns of a table.\n * - A key reads the size, a number or `\"auto\"`, from the item of each row/column, and a missing size is `\"auto\"`.\n *\n * The form of the size, a number, `\"auto\"` or a key, must not be changed after mount. To switch it, remount the grid.\n */\nexport type VGridSize<T = number> = VGridTrackSize | VGridSizeKey<T>;\n\n/**\n * @internal\n */\nexport const getAxisLength = (axis: VGridAxis<unknown>): number =>\n typeof axis === \"number\" ? axis : axis.length;\n\n/**\n * @internal\n */\nexport const getAxisItem = <T>(axis: VGridAxis<T>, index: number): T =>\n typeof axis === \"number\" ? (index as T) : axis[index]!;\n\n/**\n * @internal\n */\nexport interface GridLayout extends Layout {\n $isMeasurable(index: number): boolean;\n $setAxis(\n axis: VGridAxis<unknown>,\n size: VGridTrackSize | string,\n scrollOffset: number,\n mutable?: boolean,\n ): number | undefined;\n}\n\n/**\n * @internal\n */\nexport const createGridLayout = (\n axis: VGridAxis<unknown>,\n size: VGridTrackSize | string,\n gap = 0,\n): GridLayout => {\n if (typeof size === \"number\") {\n let length = getAxisLength(axis);\n let itemSize = size;\n const findIndex = (offset: number): number =>\n // 0 / 0 is NaN, which can cause infinite rerender\n itemSize + gap\n ? clamp(floor(offset / (itemSize + gap)), 0, length - 1)\n : 0;\n\n return {\n $getRange: (startOffset, endOffset) => [\n findIndex(startOffset),\n findIndex(endOffset),\n ],\n $findIndex: findIndex,\n $getItemOffset: (index) => index * (itemSize + gap),\n $getItemSize: () => itemSize,\n // The cells of a uniform axis are not measured\n $setItemSize: () => false,\n $isSizeEqual: () => false,\n $getTotalSize: () => (length ? length * (itemSize + gap) - gap : 0),\n $getLength: () => length,\n $setLength: (nextLength) => {\n length = nextLength;\n // The grid doesn't shift the items\n return 0;\n },\n $isMeasurable: () => false,\n $setAxis: (_axis, nextSize, scrollOffset) => {\n if (typeof nextSize !== \"number\" || nextSize === itemSize) {\n return;\n }\n const jump = findIndex(scrollOffset) * (nextSize - itemSize);\n itemSize = nextSize;\n return jump;\n },\n };\n }\n const isAuto = size === \"auto\";\n let currentAxis: VGridAxis<unknown> | undefined;\n let currentSize: VGridTrackSize | string = size;\n const length = getAxisLength(axis);\n\n // Whether each item was auto when the axis was set, as the items may be mutated after that.\n const autos: boolean[] = [];\n // The sizes inside include the gap after the track, and so does the default size.\n // The default size is given as a snapshot, because a size given to the layout would fix it and drop the estimation.\n const inner = createListLayout(length, undefined, [[], 40 + gap]);\n\n const isMeasurable = (index: number): boolean => isAuto || !!autos[index];\n\n const layout: GridLayout = {\n $getRange: inner.$getRange,\n $findIndex: inner.$findIndex,\n $getItemOffset: inner.$getItemOffset,\n $getItemSize: (index) => inner.$getItemSize(index) - gap,\n // A measurement may come for an item given a size after it's rendered.\n $setItemSize: (index, s) =>\n isMeasurable(index) && inner.$setItemSize(index, s + gap),\n $isSizeEqual: (index, s) => inner.$isSizeEqual(index, s! + gap),\n $getTotalSize: () => (inner.$getLength() ? inner.$getTotalSize() - gap : 0),\n $getLength: inner.$getLength,\n $setLength: inner.$setLength,\n $estimateDefaultSize: isAuto ? inner.$estimateDefaultSize : undefined,\n $isMeasurable: isMeasurable,\n $setAxis: (nextAxis, requestedSize, scrollOffset, mutable) => {\n if (isAuto) {\n return;\n }\n // The form of the size is fixed at mount, so a size of another form is ignored.\n const nextSize =\n typeof requestedSize === \"number\" || requestedSize === \"auto\"\n ? currentSize\n : requestedSize;\n const length = inner.$getLength();\n // The items of the same axis are the same, unless they may be mutated in place.\n if (\n !mutable &&\n nextAxis === currentAxis &&\n nextSize === currentSize &&\n length === autos.length\n ) {\n return;\n }\n currentAxis = nextAxis;\n currentSize = nextSize;\n autos.length = length;\n\n const anchorIndex = inner.$findIndex(scrollOffset);\n const prevOffset = inner.$getItemOffset(anchorIndex);\n let changed: boolean | undefined;\n for (let i = 0; i < length; i++) {\n const item = (nextAxis as readonly unknown[])[i];\n // An item which isn't an object, such as a placeholder of a header row, has no size.\n const itemSize =\n item !== NULL && typeof item === \"object\"\n ? (item as Record<string, VGridTrackSize | null | undefined>)[\n nextSize as string\n ]\n : NULL;\n const isAutoItem = typeof itemSize !== \"number\";\n // An item which was auto keeps its measured size.\n if (!isAutoItem || !autos[i]) {\n autos[i] = isAutoItem;\n const target = isAutoItem ? UNCACHED : itemSize + gap;\n if (!inner.$isSizeEqual(i, target)) {\n inner.$setItemSize(i, target);\n changed = true;\n }\n }\n }\n if (!changed) {\n return;\n }\n return inner.$getItemOffset(anchorIndex) - prevOffset;\n },\n };\n layout.$setAxis(axis, size, 0);\n return layout;\n};\n","import {\n getAxisLength,\n type GridLayout,\n type VGridAxis,\n type VGridTrackSize,\n} from \"./layouts/grid.js\";\nimport {\n ACTION_ITEMS_LENGTH_CHANGE,\n ACTION_RELAYOUT,\n type VirtualStore,\n} from \"./store.js\";\nimport { type ItemsRange } from \"./types.js\";\nimport { clamp, EMPTY, max, min, NULL, sort } from \"./utils.js\";\n\n/**\n * A cell position in the grid.\n */\nexport interface VGridCell {\n /**\n * The row index of the cell.\n */\n rowIndex: number;\n /**\n * The column index of the cell.\n */\n colIndex: number;\n}\n\n/**\n * A cell merged over multiple rows and/or columns in the grid.\n *\n * {@link VGridCell.rowIndex} and {@link VGridCell.colIndex} point to the origin cell (top row, start column) of the merged area.\n */\nexport interface VGridSpan extends VGridCell {\n /**\n * The number of rows the cell spans.\n * @defaultValue 1\n */\n rowSpan?: number;\n /**\n * The number of columns the cell spans.\n * @defaultValue 1\n */\n colSpan?: number;\n}\n\n/**\n * @internal\n */\nexport const updateGridAxis = (\n store: VirtualStore,\n layout: GridLayout,\n axis: VGridAxis<unknown>,\n size: VGridTrackSize | string,\n mutable?: boolean,\n) => {\n const length = getAxisLength(axis);\n if (length !== store.$getItemsLength()) {\n store.$update(ACTION_ITEMS_LENGTH_CHANGE, [length]);\n }\n // The tracks are shifted by the jump deferred during scrolling, which the layout doesn't include.\n const jump = layout.$setAxis(\n axis,\n size,\n store.$getScrollOffset() - store.$getItemOffset(0),\n mutable,\n );\n // undefined means nothing changed, and 0 means the tracks changed without a jump.\n if (jump != NULL) {\n store.$update(ACTION_RELAYOUT, jump);\n }\n};\n\n// The states of the previous plan of each grid, keyed by its row layout which is created once\nconst rowStatesCache = /*#__PURE__*/ new WeakMap<\n GridLayout,\n ReadonlyMap<number, GridRowState>\n>();\n\nconst hasTrackIn = (\n extras: readonly number[],\n from: number,\n to: number,\n pinnedStart: number,\n start: number,\n end: number,\n trailStart: number,\n): boolean => {\n if (\n from < pinnedStart ||\n max(from, start) < min(to, end + 1) ||\n trailStart < to\n ) {\n return true;\n }\n for (const i of extras) {\n if (i >= from && i < to) {\n return true;\n }\n }\n return false;\n};\n\n/**\n * The sections start at the section rows between the pinned rows.\n * @internal\n */\nexport const getSectionStarts = (\n sectionRows: readonly number[],\n pinnedStart: number,\n trailStart: number,\n): number[] => {\n const starts: number[] = [];\n for (const rowIndex of sectionRows) {\n if (rowIndex >= pinnedStart && rowIndex < trailStart) {\n starts.push(rowIndex);\n }\n }\n return sort(starts);\n};\n\n/**\n * The section of the row, or -1. The last section ends at the rows pinned to the end.\n * @internal\n */\nexport const getSection = (\n starts: readonly number[],\n rowIndex: number,\n trailStart: number,\n): number => {\n if (rowIndex >= trailStart) {\n return -1;\n }\n let lo = 0;\n let hi = starts.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (starts[mid]! <= rowIndex) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n return lo - 1;\n};\n\nconst addSectionHeader = (\n extras: number[],\n sectionStarts: readonly number[],\n rowIndex: number,\n trailStart: number,\n): void => {\n const section = getSection(sectionStarts, rowIndex, trailStart);\n if (section >= 0) {\n extras.push(sectionStarts[section]!);\n }\n};\n\n// The rendered tracks in order: the pinned tracks, the range, and the sorted extras which may repeat or fall in them.\nconst getTrackIndexes = (\n extras: readonly number[],\n count: number,\n pinnedStart: number,\n start: number,\n end: number,\n trailStart: number,\n): number[] => {\n const indexes: number[] = [];\n for (let i = 0; i < pinnedStart; i++) {\n indexes.push(i);\n }\n const extrasLength = extras.length;\n let e = 0;\n let last = pinnedStart - 1;\n for (; e < extrasLength && extras[e]! < start; e++) {\n const i = extras[e]!;\n if (i > last) {\n indexes.push(i);\n last = i;\n }\n }\n for (let i = start; i <= end; i++) {\n indexes.push(i);\n }\n last = end;\n for (; e < extrasLength && extras[e]! < trailStart; e++) {\n const i = extras[e]!;\n if (i > last) {\n indexes.push(i);\n last = i;\n }\n }\n for (let i = trailStart; i < count; i++) {\n indexes.push(i);\n }\n return indexes;\n};\n\nconst getSpanRowEnd = (span: Readonly<VGridSpan>, rowCount: number): number =>\n min(span.rowIndex + (span.rowSpan || 1), rowCount);\nconst getSpanColEnd = (span: Readonly<VGridSpan>, colCount: number): number =>\n min(span.colIndex + (span.colSpan || 1), colCount);\n\nconst getTemplate = (\n layout: GridLayout,\n indexes: readonly number[],\n measured: readonly (boolean | null)[],\n sortedCuts: readonly number[],\n measuredSize: string,\n count: number,\n): string => {\n const indexesLength = indexes.length;\n const cutsLength = sortedCuts.length;\n // The lines are named by the index, so the cells keep their grid-area while the range moves.\n // https://drafts.csswg.org/css-grid-2/#subgrid-line-name-inheritance\n let template = \"[l0]\";\n let line = 0;\n let i = 0;\n let c = 0;\n while (i < indexesLength || c < cutsLength) {\n const index = i < indexesLength ? indexes[i]! : count;\n const cut = c < cutsLength ? sortedCuts[c]! : count;\n if (cut <= line) {\n c++;\n } else {\n let to: number;\n let size: string;\n if (index === line) {\n to = line + 1;\n // The cells in the rows size the max-content tracks of the container.\n // https://drafts.csswg.org/css-grid-2/#subgrid-item-contribution\n // An auto track without a cell measuring it keeps the size of the layout as the min, as the spanning cells don't give the size.\n const m = measured[i];\n size =\n m == NULL\n ? layout.$getItemSize(line) + \"px\"\n : m\n ? measuredSize\n : \"minmax(\" + layout.$getItemSize(line) + \"px,auto)\";\n i++;\n } else {\n // The tracks without rendered cells are merged until the next rendered track or the end of a span.\n to = min(index, cut);\n // A fixed track this large makes WebKit misplace the cells after one of them is focused, so the size is given as the min.\n size =\n \"minmax(\" +\n (layout.$getItemOffset(to - 1) +\n layout.$getItemSize(to - 1) -\n layout.$getItemOffset(line)) +\n \"px,auto)\";\n }\n template += \" \" + size + \" [l\" + to + \"]\";\n line = to;\n }\n }\n // The tracks after the last rendered one extend the scrollable overflow to the end, as the container is not sized on the inline axis.\n // https://drafts.csswg.org/css-overflow-3/#scrollable-overflow-region\n if (line < count) {\n template +=\n \" minmax(\" +\n (layout.$getTotalSize() - layout.$getItemOffset(line)) +\n \"px,auto) [l\" +\n count +\n \"]\";\n }\n return template;\n};\n\ntype GridRole = \"cell\" | \"columnheader\" | \"rowheader\";\n\ntype GridSort = VGridCell & {\n order: \"ascending\" | \"descending\" | \"other\";\n};\n\n/**\n * The inline style of an element of the grid, whose keys are the property names in camelCase and whose lengths are in px.\n */\ntype GridStyle = Readonly<Record<string, string | number>>;\n\n/**\n * @internal\n */\nexport const gridStyleToString = (style: GridStyle): string => {\n let css = \"\";\n for (const key in style) {\n css +=\n key.replace(/[A-Z]/g, (c) => \"-\" + c.toLowerCase()) +\n \":\" +\n style[key] +\n \";\";\n }\n return css;\n};\n\n/**\n * @internal\n */\nexport interface GridPlan {\n readonly $rowTemplate: string;\n readonly $colTemplate: string;\n readonly $groups: readonly (GridRowGroupState | GridRowState)[];\n}\n\n/**\n * Creates the templates and the states of the rendered rows and cells. The rows and the cells whose values are unchanged keep the states of the previous plan of the grid, so the components skip them by identity.\n * @internal\n */\nexport const createGridPlan = (\n rowLayout: Readonly<GridLayout>,\n colLayout: Readonly<GridLayout>,\n rowRange: Readonly<ItemsRange>,\n colRange: Readonly<ItemsRange>,\n headerRows = 0,\n sectionRows: readonly number[] = EMPTY,\n footerRows = 0,\n headerCols = 0,\n footerCols = 0,\n spans: readonly Readonly<VGridSpan>[] = EMPTY,\n kept: readonly Readonly<VGridCell>[] = EMPTY,\n sortedCell?: Readonly<GridSort>,\n): GridPlan => {\n const rowCount = rowLayout.$getLength();\n const colCount = colLayout.$getLength();\n const rowPinnedStart = min(headerRows, rowCount);\n const rowTrailStart = max(rowCount - footerRows, rowPinnedStart);\n const colPinnedStart = min(headerCols, colCount);\n const colTrailStart = max(colCount - footerCols, colPinnedStart);\n const rowRangeStart = clamp(rowRange[0], rowPinnedStart, rowTrailStart);\n const rowRangeEnd = min(rowRange[1], rowTrailStart - 1);\n const colRangeStart = clamp(colRange[0], colPinnedStart, colTrailStart);\n const colRangeEnd = min(colRange[1], colTrailStart - 1);\n const sectionStarts = getSectionStarts(\n sectionRows,\n rowPinnedStart,\n rowTrailStart,\n );\n // The header column next to the body labels the rows\n const rowHeaderCol = max(colPinnedStart - 1, 0);\n\n // The headers label the cells, so they are rendered even out of the ranges.\n // https://www.w3.org/TR/wai-aria-1.2/#columnheader\n // https://www.w3.org/TR/wai-aria-1.2/#rowheader\n const extraRows: number[] = [];\n const extraCols: number[] = [];\n // The cells rendered even out of the ranges, which render their rows, the headers of their sections and their columns. A kept cell is a span over itself.\n const extraCells: Readonly<VGridSpan>[] = [];\n for (const cell of kept) {\n // A kept cell may be left out of the grid after the rows or the columns are removed.\n if (cell.rowIndex < rowCount && cell.colIndex < colCount) {\n extraCells.push(cell);\n }\n }\n const sectionLength = sectionStarts.length;\n if (sectionLength) {\n addSectionHeader(extraRows, sectionStarts, rowRangeStart, rowTrailStart);\n extraCols.push(rowHeaderCol);\n }\n // The spans over the rendered tracks are laid. The spans only over the headers wait for the headers rendered for the origins of the laid spans, until no span is laid.\n let waiting = spans;\n let l = 0;\n do {\n for (; l < extraCells.length; l++) {\n const { rowIndex, colIndex } = extraCells[l]!;\n extraRows.push(rowIndex);\n addSectionHeader(extraRows, sectionStarts, rowIndex, rowTrailStart);\n extraCols.push(colIndex);\n }\n const rest: Readonly<VGridSpan>[] = [];\n for (const span of waiting) {\n const row = span.rowIndex;\n const col = span.colIndex;\n const rowTo = getSpanRowEnd(span, rowCount);\n const colTo = getSpanColEnd(span, colCount);\n // A span may be left out of the grid after the rows or the columns are removed.\n if (\n row < rowCount &&\n col < colCount &&\n (rowTo - row > 1 || colTo - col > 1)\n ) {\n if (\n hasTrackIn(\n extraRows,\n row,\n rowTo,\n rowPinnedStart,\n rowRangeStart,\n rowRangeEnd,\n rowTrailStart,\n )\n ) {\n if (\n hasTrackIn(\n extraCols,\n col,\n colTo,\n colPinnedStart,\n colRangeStart,\n colRangeEnd,\n colTrailStart,\n )\n ) {\n extraCells.push(span);\n } else {\n const section = getSection(sectionStarts, rowTo - 1, rowTrailStart);\n if (\n row < rowPinnedStart ||\n (section >= 0 && sectionStarts[section]! >= row)\n ) {\n rest.push(span);\n }\n }\n } else if (col < colPinnedStart) {\n rest.push(span);\n }\n }\n }\n waiting = rest;\n } while (l < extraCells.length);\n // The tracks are all known now.\n sort(extraRows);\n sort(extraCols);\n const rowIndexes = getTrackIndexes(\n extraRows,\n rowCount,\n rowPinnedStart,\n rowRangeStart,\n rowRangeEnd,\n rowTrailStart,\n );\n const cols = getTrackIndexes(\n extraCols,\n colCount,\n colPinnedStart,\n colRangeStart,\n colRangeEnd,\n colTrailStart,\n );\n const rowLength = rowIndexes.length;\n const colLength = cols.length;\n\n // The spans over the cells, whose origins are the cells at their positions\n const spanCells = new Map<number, Readonly<VGridSpan>>();\n // The lines at the ends of the spans and the sections are in the templates, as a missing named line is found in the implicit grid.\n // https://drafts.csswg.org/css-grid-2/#grid-placement-int\n const rowCuts: number[] = [];\n const colCuts: number[] = [];\n // The kept cells are before the spans, so a span is over the kept cells under it.\n for (const span of extraCells) {\n const rowTo = getSpanRowEnd(span, rowCount);\n const colTo = getSpanColEnd(span, colCount);\n rowCuts.push(rowTo);\n colCuts.push(colTo);\n // The tracks are in order, so the covered ones start at the origin of the span.\n const colStart = cols.indexOf(span.colIndex);\n for (\n let i = rowIndexes.indexOf(span.rowIndex);\n i < rowLength && rowIndexes[i]! < rowTo;\n i++\n ) {\n const rowKey = rowIndexes[i]! * colCount;\n for (let j = colStart; j < colLength && cols[j]! < colTo; j++) {\n spanCells.set(rowKey + cols[j]!, span);\n }\n }\n }\n\n // A track is measured by its first rendered cell which doesn't span over the other tracks, and is null if its size is given.\n const measuredCols: (boolean | null)[] = [];\n for (const colIndex of cols) {\n measuredCols.push(colLayout.$isMeasurable(colIndex) ? false : NULL);\n }\n const measuredRows: (boolean | null)[] = [];\n // The section headers stick where the first row after the pinned rows is laid.\n const stickyTop = rowLayout.$getItemOffset(rowPinnedStart);\n\n // The rows out of the pinned rows and the sections are not grouped, as Firefox on macOS keeps the stale columns of the table when the rows in a group change.\n const groups: (GridRowGroupState | GridRowState)[] = [];\n let groupRows: (GridRowGroupState | GridRowState)[] = groups;\n const prev = rowStatesCache.get(rowLayout);\n const rowStates = new Map<number, GridRowState>();\n // TODO optimize: the rows and the columns out of the ranges are crossed with each other, which is quadratic for many cells kept far away from each other.\n for (const rowIndex of rowIndexes) {\n const pinnedTop = rowIndex < rowPinnedStart;\n const pinnedBottom = rowIndex >= rowTrailStart;\n const rowInRangeOrPinnedToEnd =\n pinnedBottom || (rowIndex >= rowRangeStart && rowIndex <= rowRangeEnd);\n const section = getSection(sectionStarts, rowIndex, rowTrailStart);\n // The first row of the group of the row, or -1\n const groupStart = pinnedTop\n ? 0\n : pinnedBottom\n ? rowTrailStart\n : section < 0\n ? -1\n : sectionStarts[section]!;\n // A group starts at its first row, which is rendered whenever the other rows of the group are.\n if (rowIndex === groupStart) {\n const groupEnd = pinnedTop\n ? rowPinnedStart\n : pinnedBottom\n ? rowCount\n : // A section ends at the next section which may not be rendered, or at the rows pinned to the end\n section + 1 < sectionLength\n ? sectionStarts[section + 1]!\n : rowTrailStart;\n rowCuts.push(groupEnd);\n const rows: GridRowState[] = [];\n groups.push({\n // The rows pinned to the end keep the key while the rows before them are added or removed\n $key: pinnedTop ? -1 : pinnedBottom ? -2 : -3 - groupStart,\n $rows: rows,\n // The pinned rows at each edge are sticky together over the section headers and the cells of the other rows, so the cells spanning over them are stacked over the next rows as in the other rows.\n $style: getBoxStyle(\n groupStart,\n groupEnd,\n pinnedTop || pinnedBottom ? 0 : NULL,\n pinnedBottom ? \"bottom\" : \"top\",\n 4,\n ),\n });\n groupRows = rows;\n } else if (groupStart < 0) {\n groupRows = groups;\n }\n const isSectionHeaderRow = section >= 0 && rowIndex === groupStart;\n const rowTop = isSectionHeaderRow ? stickyTop : NULL;\n const rowKey = rowIndex * colCount;\n const prevRow = prev && prev.get(rowIndex);\n const prevCells = prevRow && prevRow.$cells;\n const rowCells: GridCellState[] = [];\n // The cells are in the order of the columns, so the previous cell of a column is found by walking them once.\n let p = 0;\n let measuredRow = rowLayout.$isMeasurable(rowIndex) ? false : NULL;\n let rowEnd = rowIndex + 1;\n let changed = false;\n for (let i = 0; i < colLength; i++) {\n const colIndex = cols[i]!;\n const startPinned = colIndex < colPinnedStart;\n const endPinned = colIndex >= colTrailStart;\n const colInRangeOrPinnedToEnd =\n endPinned || (colIndex >= colRangeStart && colIndex <= colRangeEnd);\n const span = spanCells.get(rowKey + colIndex);\n if (\n span\n ? span.rowIndex !== rowIndex || span.colIndex !== colIndex\n : !(rowInRangeOrPinnedToEnd && colInRangeOrPinnedToEnd) &&\n !pinnedTop &&\n !isSectionHeaderRow &&\n !startPinned\n ) {\n continue;\n }\n const rowTo = span ? getSpanRowEnd(span, rowCount) : rowIndex + 1;\n const colTo = span ? getSpanColEnd(span, colCount) : colIndex + 1;\n const spansRows = rowTo - rowIndex > 1;\n const spansCols = colTo - colIndex > 1;\n const spanning = spansRows || spansCols;\n const rowSpan = spanning ? rowTo - rowIndex : undefined;\n const colSpan = spanning ? colTo - colIndex : undefined;\n let measureRowIndex: number | undefined;\n let measureColIndex: number | undefined;\n rowEnd = max(rowEnd, rowTo);\n // A sticky box keeps its edges in the scrollport, so the end inset is from the end of the track.\n // https://drafts.csswg.org/css-position-3/#stickypos-insets\n // https://wpt.fyi/results/css/css-position/sticky/position-sticky-grid.html\n const stickyStart = startPinned\n ? colLayout.$getItemOffset(colIndex)\n : NULL;\n // The end inset of a span is from its last column.\n const stickyEnd = endPinned\n ? colLayout.$getTotalSize() -\n colLayout.$getItemOffset(colTo - 1) -\n colLayout.$getItemSize(colTo - 1)\n : NULL;\n if (measuredRow === false && !spansRows) {\n measureRowIndex = rowIndex;\n measuredRow = true;\n }\n if (measuredCols[i] === false && !spansCols) {\n measureColIndex = colIndex;\n measuredCols[i] = true;\n }\n const role: GridRole = pinnedTop\n ? \"columnheader\"\n : colIndex === rowHeaderCol && (startPinned || isSectionHeaderRow)\n ? \"rowheader\"\n : \"cell\";\n // aria-sort is allowed only on the headers\n // https://www.w3.org/TR/wai-aria-1.2/#aria-sort\n const sortOrder =\n role !== \"cell\" &&\n sortedCell &&\n sortedCell.rowIndex === rowIndex &&\n sortedCell.colIndex === colIndex\n ? sortedCell.order\n : undefined;\n let cell: GridCellState | undefined;\n if (prevCells) {\n while (p < prevCells.length && prevCells[p]!.$col < colIndex) {\n p++;\n }\n if (p < prevCells.length) {\n cell = prevCells[p];\n }\n }\n if (\n !cell ||\n cell.$col !== colIndex ||\n cell.$rowSpan !== rowSpan ||\n cell.$colSpan !== colSpan ||\n cell.$start !== stickyStart ||\n cell.$end !== stickyEnd ||\n cell.$measureRow !== measureRowIndex ||\n cell.$measureCol !== measureColIndex ||\n cell.$role !== role ||\n cell.$sort !== sortOrder\n ) {\n const style: Record<string, string | number> = {\n contain: \"layout style\",\n display: \"grid\",\n // A span ends at the named line instead of the number of tracks, because the unrendered rows/columns are merged into one track.\n gridArea: spanning\n ? \"1/l\" + colIndex + \"/l\" + rowTo + \"/l\" + colTo\n : \"1/l\" + colIndex,\n };\n // A spanning cell fills the tracks it spans without giving their sizes.\n // https://drafts.csswg.org/css-sizing-3/#cyclic-percentage-contribution\n // https://drafts.csswg.org/css-grid-2/#min-size-contribution\n if (spansRows) {\n style[\"height\"] = \"0px\";\n style[\"minHeight\"] = \"100%\";\n // Over the rows it spans over, which are painted later\n // https://drafts.csswg.org/css-grid-2/#z-order\n style[\"zIndex\"] = 1;\n }\n if (spansCols) {\n style[\"width\"] = \"0px\";\n style[\"minWidth\"] = \"100%\";\n }\n if (startPinned || endPinned) {\n if (startPinned) {\n style[\"insetInlineStart\"] = stickyStart + \"px\";\n } else {\n style[\"insetInlineEnd\"] = stickyEnd + \"px\";\n }\n style[\"position\"] = \"sticky\";\n // Over the spanning cells, which may be painted later\n style[\"zIndex\"] = 2;\n }\n cell = {\n $col: colIndex,\n $rowSpan: rowSpan,\n $colSpan: colSpan,\n $measureRow: measureRowIndex,\n $measureCol: measureColIndex,\n $role: role,\n $sort: sortOrder,\n $style: style,\n $start: stickyStart,\n $end: stickyEnd,\n };\n changed = true;\n }\n rowCells.push(cell);\n }\n // Aligned with rowIndexes for the template, so it's pushed before the rows without cells are skipped.\n measuredRows.push(measuredRow);\n if (!rowCells.length) {\n continue;\n }\n // A column rendered anew has no previous cell and marks the row changed, so the lengths tell the columns are the same.\n // A change of the span end changes a cell, so the row end is not compared.\n const row: GridRowState =\n prevRow &&\n !changed &&\n prevRow.$cells.length === rowCells.length &&\n prevRow.$top === rowTop\n ? prevRow\n : {\n $row: rowIndex,\n $cells: rowCells,\n // A subgrid clamps its items to its tracks, so the row spans to the end of its cells.\n // https://drafts.csswg.org/css-grid-2/#subgrid-implicit\n // A section header sticks in the box of its section over the sticky and spanning cells of the other rows, so it's pushed out at the end of the section.\n // https://drafts.csswg.org/css-position-3/#stickypos-insets\n $style: getBoxStyle(rowIndex, rowEnd, rowTop, \"top\", 3),\n $top: rowTop,\n };\n rowStates.set(rowIndex, row);\n groupRows.push(row);\n }\n\n rowStatesCache.set(rowLayout, rowStates);\n\n return {\n $rowTemplate: getTemplate(\n rowLayout,\n rowIndexes,\n measuredRows,\n sort(rowCuts),\n \"max-content\",\n rowCount,\n ),\n // The auto columns share the space left in the viewport, as the columns of a table.\n // https://drafts.csswg.org/css-grid-2/#algo-stretch\n $colTemplate: getTemplate(\n colLayout,\n cols,\n measuredCols,\n sort(colCuts),\n \"minmax(max-content,auto)\",\n colCount,\n ),\n $groups: groups,\n };\n};\n\n// The box of a row or a group of the rows between the lines, which sticks at the inset from the edge if given\nconst getBoxStyle = (\n from: number,\n to: number,\n inset: number | null,\n edge: \"top\" | \"bottom\",\n zIndex: number,\n): GridStyle => {\n const style: Record<string, string | number> = {\n display: \"grid\",\n gridTemplateRows: \"subgrid\",\n gridTemplateColumns: \"subgrid\",\n gridColumn: \"1/-1\",\n gridRow: \"l\" + from + \"/l\" + to,\n };\n if (inset != NULL) {\n style[\"position\"] = \"sticky\";\n style[edge] = inset + \"px\";\n style[\"zIndex\"] = zIndex;\n }\n return style;\n};\n\n/**\n * @internal\n */\nexport interface GridCellState {\n readonly $col: number;\n readonly $rowSpan: number | undefined;\n readonly $colSpan: number | undefined;\n readonly $measureRow: number | undefined;\n readonly $measureCol: number | undefined;\n readonly $role: GridRole;\n readonly $sort: GridSort[\"order\"] | undefined;\n readonly $style: GridStyle;\n // The fields below are not rendered. They are in the style, and compared with the next plan to keep the state.\n readonly $start: number | null;\n readonly $end: number | null;\n}\n\n/**\n * @internal\n */\nexport interface GridRowState {\n readonly $row: number;\n readonly $cells: readonly GridCellState[];\n readonly $style: GridStyle;\n // The fields below are not rendered. They are in the style, and compared with the next plan to keep the state.\n readonly $top: number | null;\n}\n\n/**\n * @internal\n */\nexport interface GridRowGroupState {\n // Negative, not to collide with the indexes keying the rows beside the groups\n readonly $key: number;\n readonly $rows: readonly GridRowState[];\n readonly $style: GridStyle;\n}\n","import {\n getCurrentDocument,\n getCurrentWindow,\n isIOSWebKit,\n} from \"./environment.js\";\nimport {\n ACTION_SCROLL,\n type VirtualStore,\n ACTION_SCROLL_END,\n ACTION_START_OFFSET_CHANGE,\n ACTION_MANUAL_SCROLL,\n ACTION_BEFORE_MANUAL_SMOOTH_SCROLL,\n UPDATE_SIZE_EVENT,\n} from \"./store.js\";\nimport { cancelTimeout, microtask, timeout } from \"./utils.js\";\n\n/**\n * @internal\n */\nexport const createResizeObserver = (cb: ResizeObserverCallback) => {\n let ro: ResizeObserver | undefined;\n\n return {\n _observe(e: HTMLElement) {\n // Initialize ResizeObserver lazily for SSR\n // https://www.w3.org/TR/resize-observer/#intro\n (\n ro ||\n // https://bugs.chromium.org/p/chromium/issues/detail?id=1491739\n (ro = new (getCurrentWindow(getCurrentDocument(e)).ResizeObserver)(cb))\n ).observe(e);\n },\n _unobserve(e: HTMLElement) {\n ro!.unobserve(e);\n },\n _dispose() {\n ro && ro.disconnect();\n },\n };\n};\n\n/**\n * @internal\n */\nexport const createScrollObserver = (\n store: VirtualStore,\n viewport: HTMLElement | Window,\n scroller: HTMLElement,\n isHorizontal: boolean,\n isRtl: boolean,\n onMomentumJump?: (() => void) | null,\n getStartOffset?: () => number,\n) => {\n let lastScrollTime = 0;\n let wheeling = false;\n let touching = false;\n let justTouchEnded = false;\n let stillMomentumScrolling = false;\n let cancelScroll: (() => void) | undefined;\n\n let scrollEndTimer: ReturnType<typeof timeout> | undefined;\n\n const now = Date.now;\n const scrollOffsetKey = isHorizontal ? \"scrollLeft\" : \"scrollTop\";\n const scrollToKey = isHorizontal ? \"left\" : \"top\";\n\n /**\n * scrollTop/scrollLeft can be negative value under certain styles.\n * - direction: rtl https://github.com/othree/jquery.rtl-scroll-type\n * - writing-mode https://people.igalia.com/fwang/scrollable-elements-in-non-default-writing-modes/\n * - flex-direction: column-reverse/row-reverse\n *\n * top/left bottom/right\n * 0 100 spec compliant bottom/right overflow, or possibly top/left overflow in Chrome earlier than v85\n * -100 0 spec compliant top/left overflow\n * https://drafts.csswg.org/cssom-view/#scroll-an-element\n */\n const normalizeScrollOffset = (offset: number): number => {\n return isRtl ? -offset : offset;\n };\n\n const getScrollOffset = () =>\n normalizeScrollOffset(scroller[scrollOffsetKey]);\n\n // The given offset will be clamped by browser\n // https://drafts.csswg.org/cssom-view/#dom-element-scrolltop\n const scrollTo = (offset: number, smooth?: boolean) => {\n scroller.scrollTo({\n [scrollToKey]: normalizeScrollOffset(offset),\n behavior: smooth ? \"smooth\" : \"instant\",\n });\n };\n\n // Debounce scroll end detection\n const onScrollEnd = () => {\n if (wheeling || touching) {\n wheeling = false;\n\n // Wait while wheeling or touching\n scheduleScrollEnd();\n return;\n }\n\n justTouchEnded = false;\n\n store.$update(ACTION_SCROLL_END);\n };\n const scheduleScrollEnd = () => {\n cancelTimeout(scrollEndTimer);\n scrollEndTimer = timeout(onScrollEnd, 150);\n };\n\n const onScroll = () => {\n lastScrollTime = now();\n\n if (justTouchEnded) {\n stillMomentumScrolling = true;\n }\n\n if (getStartOffset) {\n store.$update(ACTION_START_OFFSET_CHANGE, getStartOffset());\n }\n store.$update(ACTION_SCROLL, getScrollOffset());\n\n scheduleScrollEnd();\n };\n\n // Infer scroll state also from wheel events\n // Sometimes scroll events do not fire when frame dropped even if the visual have been already scrolled\n const onWheel = ((e: WheelEvent) => {\n if (\n wheeling ||\n // Scroll start should be detected with scroll event\n !store.$isScrolling() ||\n // Probably a pinch-to-zoom gesture\n e.ctrlKey\n ) {\n return;\n }\n\n const timeDelta = now() - lastScrollTime;\n if (\n // Check if wheel event occurs some time after scrolling\n 150 > timeDelta &&\n 50 < timeDelta &&\n // Get delta before checking deltaMode for firefox behavior\n // https://github.com/w3c/uievents/issues/181#issuecomment-392648065\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1392460#c34\n (isHorizontal ? e.deltaX : e.deltaY)\n ) {\n wheeling = true;\n }\n }) as (e: Event) => void; // FIXME type error. why only here?\n\n const onTouchStart = () => {\n touching = true;\n justTouchEnded = stillMomentumScrolling = false;\n };\n const onTouchEnd = () => {\n touching = false;\n if (isIOSWebKit()) {\n justTouchEnded = true;\n }\n };\n\n viewport.addEventListener(\"scroll\", onScroll);\n viewport.addEventListener(\"wheel\", onWheel, { passive: true });\n viewport.addEventListener(\"touchstart\", onTouchStart, { passive: true });\n viewport.addEventListener(\"touchend\", onTouchEnd, { passive: true });\n\n return {\n _dispose: () => {\n viewport.removeEventListener(\"scroll\", onScroll);\n viewport.removeEventListener(\"wheel\", onWheel);\n viewport.removeEventListener(\"touchstart\", onTouchStart);\n viewport.removeEventListener(\"touchend\", onTouchEnd);\n cancelTimeout(scrollEndTimer);\n },\n _fixScrollJump: () => {\n const [jump, shift] = store._flushJump();\n if (!jump) return;\n\n if (stillMomentumScrolling && onMomentumJump) {\n onMomentumJump();\n }\n stillMomentumScrolling = false;\n\n const target = store.$getScrollOffset() + jump;\n if (\n target <= 0 ||\n target >=\n store.$getStartSpacerSize() +\n store.$getTotalSize() -\n store.$getViewportSize()\n ) {\n // Use absolute position at the edges not to exceed scrollable bounds\n // https://github.com/inokawa/virtua/discussions/475\n scrollTo(target);\n } else {\n // Use relative position not to overwrite concurrent scrolling\n // https://github.com/inokawa/virtua/issues/898\n scroller.scrollBy({\n [scrollToKey]: normalizeScrollOffset(jump),\n behavior: \"instant\",\n });\n }\n\n if (shift) {\n // https://github.com/inokawa/virtua/issues/357\n cancelScroll && cancelScroll();\n\n if (store.$getViewportSize() > store.$getTotalSize()) {\n // In this case applying jump may not cause scroll.\n // Current logic expects scroll event occurs after applying jump so we dispatch it manually.\n store.$update(ACTION_SCROLL, getScrollOffset());\n }\n }\n },\n _scroll: (getTargetOffset: () => number, smooth?: boolean) => {\n if (cancelScroll) {\n // Cancel waiting scrollTo\n cancelScroll();\n }\n\n let stopped: boolean | undefined;\n let timerId: ReturnType<typeof timeout> | undefined;\n let unsubscribe: (() => void) | undefined;\n\n // Stopping is kept as a state, not delivered as an event, so it can never be missed by a race with measurement\n // https://github.com/inokawa/virtua/issues/715\n const stop = (cancelScroll = () => {\n stopped = true;\n cancelTimeout(timerId);\n unsubscribe && unsubscribe();\n });\n\n // The scroll destination is not fixed until the items on the way are measured and the timing is not predictable\n const onMeasured = () => {\n if (stopped) {\n return;\n }\n\n // Resize event may not happen when the window/tab is not visible, or during browser back in Safari.\n // We have to wait for the initial measurement to avoid failing imperative scroll on mount.\n // https://github.com/inokawa/virtua/issues/450\n if (store.$getViewportSize()) {\n // Stop when items around scroll destination completely measured\n cancelTimeout(timerId);\n timerId = timeout(stop, 150);\n }\n\n if (smooth) {\n // Smooth scrolling can be started only once, so wait for all the items on the way to be measured.\n for (let [i, end] = store.$getRange(0); i <= end; i++) {\n if (store.$isUnmeasuredItem(i)) {\n return;\n }\n }\n stop();\n }\n\n store.$update(ACTION_MANUAL_SCROLL);\n scrollTo(getTargetOffset(), smooth);\n };\n\n const start = () => {\n if (stopped) {\n return;\n }\n // Batch the measurements in the same task to scroll only once\n let queued: boolean | undefined;\n unsubscribe = store.$subscribe(UPDATE_SIZE_EVENT, () => {\n if (queued) {\n return;\n }\n queued = true;\n microtask(() => {\n queued = false;\n onMeasured();\n });\n });\n onMeasured();\n };\n\n if (smooth) {\n store.$update(ACTION_BEFORE_MANUAL_SMOOTH_SCROLL, getTargetOffset());\n // https://github.com/inokawa/virtua/issues/590\n microtask(start);\n } else {\n start();\n }\n },\n };\n};\n\n/**\n * @internal\n */\nexport type ScrollObserver = ReturnType<typeof createScrollObserver>;\n","import {\n ACTION_ITEM_RESIZE,\n ACTION_VIEWPORT_RESIZE,\n type VirtualStore,\n} from \"./store.js\";\nimport {\n createResizeObserver,\n createScrollObserver,\n type ScrollObserver,\n} from \"./observer.js\";\nimport { type ItemResize } from \"./types.js\";\nimport { createPromise, NULL, timeout } from \"./utils.js\";\nimport { getCurrentDocument, getCurrentWindow } from \"./environment.js\";\n\n/**\n * @internal\n */\nexport interface Driver {\n $observe(containerElement: HTMLElement, viewport?: HTMLElement): void;\n $dispose(): void;\n $observeItem(el: HTMLElement, index: number): () => void;\n $scroll(getTargetOffset: () => number, smooth?: boolean): void;\n $effect(): void;\n $getBaseOffset(): number;\n}\n\n/**\n * @internal\n */\nexport type DriverFactory = (\n store: VirtualStore,\n isHorizontal: boolean,\n) => Driver;\n\n/**\n * @internal\n */\nexport const createContainerDriver: DriverFactory = (store, isHorizontal) => {\n let viewportElement: HTMLElement | undefined;\n let scrollObserver: ScrollObserver | undefined;\n let initialized = createPromise<boolean>();\n\n const mountedIndexes = new WeakMap<Element, number>();\n\n const resizeObserver = createResizeObserver((entries) => {\n const resizes: ItemResize[] = [];\n for (const {\n target,\n contentRect: { width, height },\n } of entries) {\n if (target === viewportElement) {\n // https://github.com/inokawa/virtua/issues/964\n if (width || height) {\n store.$update(ACTION_VIEWPORT_RESIZE, isHorizontal ? width : height);\n }\n // Skip zero-sized rects that may be observed under `display: none` style\n } else if ((target as HTMLElement).offsetParent) {\n const index = mountedIndexes.get(target);\n if (index != NULL) {\n resizes.push([index, isHorizontal ? width : height]);\n }\n }\n }\n\n if (resizes.length) {\n store.$update(ACTION_ITEM_RESIZE, resizes);\n }\n });\n\n return {\n $observe(containerElement, viewport = containerElement.parentElement!) {\n resizeObserver._observe((viewportElement = viewport));\n\n scrollObserver = createScrollObserver(\n store,\n viewport,\n viewport,\n isHorizontal,\n isHorizontal && getComputedStyle(viewport).direction === \"rtl\",\n () => {\n const overflowKey = isHorizontal ? \"overflowX\" : \"overflowY\";\n // If we update scroll position while touching on iOS, the position will be reverted.\n // However iOS WebKit fires touch events only once at the beginning of momentum scrolling.\n // That means we have no reliable way to confirm still touched or not if user touches more than once during momentum scrolling...\n // This is a hack for the suspectable situations, inspired by https://github.com/prud/ios-overflow-scroll-to-top\n const style = viewport.style;\n const prev = style[overflowKey];\n style[overflowKey] = \"hidden\";\n timeout(() => {\n style[overflowKey] = prev;\n });\n },\n );\n\n initialized[1](true);\n },\n $dispose() {\n resizeObserver._dispose();\n scrollObserver && scrollObserver._dispose();\n initialized[1](false);\n // https://github.com/inokawa/virtua/pull/765\n initialized = createPromise();\n },\n $observeItem(el, index) {\n mountedIndexes.set(el, index);\n resizeObserver._observe(el);\n return () => {\n mountedIndexes.delete(el);\n resizeObserver._unobserve(el);\n };\n },\n async $scroll(getTargetOffset, smooth) {\n // Wait for element assign. The element may be undefined if scrollRef prop is used and scroll is scheduled on mount.\n // https://github.com/inokawa/virtua/pull/733\n // https://github.com/inokawa/virtua/pull/750\n if (await initialized[0]) {\n scrollObserver!._scroll(getTargetOffset, smooth);\n }\n },\n $effect() {\n scrollObserver && scrollObserver._fixScrollJump();\n },\n $getBaseOffset: store.$getStartSpacerSize,\n };\n};\n\n/**\n * @internal\n */\nexport const createWindowDriver: DriverFactory = (store, isHorizontal) => {\n let viewportElement: HTMLElement | undefined;\n let scrollObserver: ScrollObserver | undefined;\n let cleanupOnWindowResize: (() => void) | undefined;\n let getBaseOffset: (() => number) | undefined;\n let onViewportResize: (() => void) | undefined;\n let initialized = createPromise<boolean>();\n\n const mountedIndexes = new WeakMap<Element, number>();\n\n const resizeObserver = createResizeObserver((entries) => {\n const resizes: ItemResize[] = [];\n for (const {\n target,\n contentRect: { width, height },\n } of entries) {\n if (target === viewportElement) {\n // Scrollbar appearance/disappearance changes client size without firing window resize events\n onViewportResize && onViewportResize();\n // Skip zero-sized rects that may be observed under `display: none` style\n } else if ((target as HTMLElement).offsetParent) {\n const index = mountedIndexes.get(target);\n if (index != NULL) {\n resizes.push([index, isHorizontal ? width : height]);\n }\n }\n }\n\n if (resizes.length) {\n store.$update(ACTION_ITEM_RESIZE, resizes);\n }\n });\n\n return {\n $observe(container) {\n const document = getCurrentDocument(container);\n const window = getCurrentWindow(document);\n const viewport = (viewportElement =\n document.scrollingElement! as HTMLElement);\n // Detect RTL document\n const isRtl =\n isHorizontal && getComputedStyle(viewport).direction === \"rtl\";\n\n const calcOffsetToViewport = (\n node: HTMLElement,\n viewport: HTMLElement,\n until: HTMLElement,\n isHorizontal: boolean,\n offset: number = 0,\n ): number => {\n // TODO calc offset only when it changes (maybe impossible)\n const offsetKey = isHorizontal ? \"offsetLeft\" : \"offsetTop\";\n const offsetSum =\n offset +\n (isRtl\n ? viewport.clientWidth - node[offsetKey] - node.offsetWidth\n : node[offsetKey]);\n\n const parent = node.offsetParent;\n if (node === until || !parent) {\n return offsetSum;\n }\n\n return calcOffsetToViewport(\n parent as HTMLElement,\n viewport,\n until,\n isHorizontal,\n offsetSum,\n );\n };\n\n const baseOffset = (getBaseOffset = () => {\n return calcOffsetToViewport(\n container,\n viewport,\n document.body,\n isHorizontal,\n );\n });\n\n const onWindowResize = (onViewportResize = () => {\n store.$update(\n ACTION_VIEWPORT_RESIZE,\n viewport[isHorizontal ? \"clientWidth\" : \"clientHeight\"],\n );\n });\n window.addEventListener(\"resize\", onWindowResize);\n\n // https://github.com/inokawa/virtua/issues/792\n resizeObserver._observe(viewport);\n\n cleanupOnWindowResize = () => {\n window.removeEventListener(\"resize\", onWindowResize);\n };\n\n // TODO support case two window scrollers exist in the same view\n scrollObserver = createScrollObserver(\n store,\n window,\n viewport,\n isHorizontal,\n isRtl,\n NULL,\n baseOffset,\n );\n\n initialized[1](true);\n },\n $dispose() {\n cleanupOnWindowResize && cleanupOnWindowResize();\n resizeObserver._dispose();\n scrollObserver && scrollObserver._dispose();\n initialized[1](false);\n // https://github.com/inokawa/virtua/pull/765\n initialized = createPromise();\n },\n $observeItem(el, index) {\n mountedIndexes.set(el, index);\n resizeObserver._observe(el);\n return () => {\n mountedIndexes.delete(el);\n resizeObserver._unobserve(el);\n };\n },\n async $scroll(getTargetOffset, smooth) {\n // Wait for element assign. The element may be undefined if scroll is scheduled on mount.\n // https://github.com/inokawa/virtua/pull/733\n // https://github.com/inokawa/virtua/pull/750\n if (await initialized[0]) {\n scrollObserver!._scroll(getTargetOffset, smooth);\n }\n },\n $effect() {\n scrollObserver && scrollObserver._fixScrollJump();\n },\n $getBaseOffset() {\n // Calculate target scroll position including container's offset from document\n return getBaseOffset!();\n },\n };\n};\n\n/**\n * @internal\n */\nexport type GridDriver = {\n $scroll(isHorizontal: boolean, getTargetOffset: () => number): void;\n $observe(containerElement: HTMLElement): void;\n $dispose(): void;\n $observeItem(\n el: HTMLElement,\n rowIndex: number | undefined,\n colIndex: number | undefined,\n ): () => void;\n $effect(): void;\n};\n\n/**\n * @internal\n */\nexport const createContainerGridDriver = (\n rowStore: VirtualStore,\n colStore: VirtualStore,\n): GridDriver => {\n let viewportElement: HTMLElement | undefined;\n let rowScrollObserver: ScrollObserver | undefined;\n let colScrollObserver: ScrollObserver | undefined;\n let initialized = createPromise<boolean>();\n\n const mountedRowIndexes = new WeakMap<Element, number>();\n const mountedColIndexes = new WeakMap<Element, number>();\n\n const resizeObserver = createResizeObserver((entries) => {\n const rowResizes: ItemResize[] = [];\n const colResizes: ItemResize[] = [];\n for (const {\n target,\n contentRect: { width, height },\n } of entries) {\n if (target === viewportElement) {\n // https://github.com/inokawa/virtua/issues/964\n if (width || height) {\n rowStore.$update(ACTION_VIEWPORT_RESIZE, height);\n colStore.$update(ACTION_VIEWPORT_RESIZE, width);\n }\n // Skip zero-sized rects that may be observed under `display: none` style\n } else if ((target as HTMLElement).offsetParent) {\n const rowIndex = mountedRowIndexes.get(target);\n const colIndex = mountedColIndexes.get(target);\n if (rowIndex != NULL) {\n rowResizes.push([rowIndex, height]);\n }\n if (colIndex != NULL) {\n colResizes.push([colIndex, width]);\n }\n }\n }\n\n if (rowResizes.length) {\n rowStore.$update(ACTION_ITEM_RESIZE, rowResizes);\n }\n if (colResizes.length) {\n colStore.$update(ACTION_ITEM_RESIZE, colResizes);\n }\n });\n\n return {\n async $scroll(isHorizontal, getTargetOffset) {\n // Wait for element assign. The element may be undefined if scroll is scheduled on mount.\n // https://github.com/inokawa/virtua/pull/733\n // https://github.com/inokawa/virtua/pull/750\n if (await initialized[0]) {\n (isHorizontal ? colScrollObserver : rowScrollObserver)!._scroll(\n getTargetOffset,\n );\n }\n },\n $observe(containerElement) {\n const viewport = (viewportElement = containerElement.parentElement!);\n resizeObserver._observe(viewport);\n\n const observe = (store: VirtualStore, isHorizontal: boolean) =>\n createScrollObserver(\n store,\n viewport,\n viewport,\n isHorizontal,\n isHorizontal && getComputedStyle(viewport).direction === \"rtl\",\n () => {\n const overflowKey = isHorizontal ? \"overflowX\" : \"overflowY\";\n // If we update scroll position while touching on iOS, the position will be reverted.\n // However iOS WebKit fires touch events only once at the beginning of momentum scrolling.\n // That means we have no reliable way to confirm still touched or not if user touches more than once during momentum scrolling...\n // This is a hack for the suspectable situations, inspired by https://github.com/prud/ios-overflow-scroll-to-top\n const style = viewport.style;\n const prev = style[overflowKey];\n style[overflowKey] = \"hidden\";\n timeout(() => {\n style[overflowKey] = prev;\n });\n },\n );\n rowScrollObserver = observe(rowStore, false);\n colScrollObserver = observe(colStore, true);\n\n initialized[1](true);\n },\n $dispose() {\n resizeObserver._dispose();\n rowScrollObserver && rowScrollObserver._dispose();\n colScrollObserver && colScrollObserver._dispose();\n initialized[1](false);\n // https://github.com/inokawa/virtua/pull/765\n initialized = createPromise();\n },\n $observeItem(el, rowIndex, colIndex) {\n // An undefined index skips reporting the size of that axis, for cells whose row/column size is given instead of measured.\n if (rowIndex != NULL) {\n mountedRowIndexes.set(el, rowIndex);\n }\n if (colIndex != NULL) {\n mountedColIndexes.set(el, colIndex);\n }\n resizeObserver._observe(el);\n return () => {\n mountedRowIndexes.delete(el);\n mountedColIndexes.delete(el);\n resizeObserver._unobserve(el);\n };\n },\n $effect() {\n rowScrollObserver && rowScrollObserver._fixScrollJump();\n colScrollObserver && colScrollObserver._fixScrollJump();\n },\n };\n};\n","import { type VirtualStore } from \"./store.js\";\nimport { clamp, EMPTY, max, min, NULL } from \"./utils.js\";\nimport { type Driver, type GridDriver } from \"./driver.js\";\nimport { getSection, getSectionStarts } from \"./grid.js\";\n\n/**\n * Alignment of item in the viewport.\n *\n * - `start`: Align the item to the start.\n * - `center`: Align the item to the center.\n * - `end`: Align the item to the end.\n * - `nearest`: If the item is already completely visible, don't scroll. Otherwise scroll until it becomes visible. That is similar behavior to [`nearest` option of scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView).\n */\nexport type ScrollToIndexAlign = \"start\" | \"center\" | \"end\" | \"nearest\";\n\nexport interface ScrollToIndexOpts {\n /**\n * Alignment of item in the viewport. See {@link ScrollToIndexAlign} for the values.\n * @defaultValue \"start\"\n */\n align?: ScrollToIndexAlign;\n /**\n * If true, scrolling animates smoothly with [`behavior: smooth` of scrollTo](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo#behavior).\n *\n * **Using smooth scrolling over many items can kill performance benefit of virtual scroll. Do not overuse it.**\n */\n smooth?: boolean;\n /**\n * Additional offset from the scrolled position.\n * @defaultValue 0\n */\n offset?: number;\n}\n\n/**\n * The cell to scroll to and the options of the scroll. The axis whose index is omitted is not scrolled.\n */\nexport interface VGridScrollToIndexOpts {\n /**\n * The row index of the cell.\n */\n rowIndex?: number;\n /**\n * The column index of the cell.\n */\n colIndex?: number;\n /**\n * Alignment of the cell in the viewport, excluding the rows sticking over it. See {@link ScrollToIndexAlign} for the values.\n * @defaultValue \"start\"\n */\n rowAlign?: ScrollToIndexAlign;\n /**\n * Alignment of the cell in the viewport, excluding the columns sticking over it. See {@link ScrollToIndexAlign} for the values.\n * @defaultValue \"start\"\n */\n colAlign?: ScrollToIndexAlign;\n}\n\n/**\n * @internal\n */\nexport const scrollTo = (driver: Driver, offset: number) => {\n driver.$scroll(() => offset);\n};\n\n/**\n * @internal\n */\nexport const scrollBy = (\n driver: Driver,\n store: VirtualStore,\n offset: number,\n) => {\n scrollTo(driver, offset + store.$getScrollOffset());\n};\n\n/**\n * @internal\n */\nexport const scrollToIndex = (\n driver: Driver,\n store: VirtualStore,\n index: number,\n { align, smooth, offset = 0 }: ScrollToIndexOpts = {},\n) => {\n index = clamp(index, 0, store.$getItemsLength() - 1);\n\n if (align === \"nearest\") {\n const itemOffset = store.$getItemOffset(index);\n const scrollOffset = store.$getScrollOffset();\n\n if (itemOffset < scrollOffset) {\n align = \"start\";\n } else if (\n itemOffset + store.$getItemSize(index) >\n scrollOffset + store.$getViewportSize()\n ) {\n align = \"end\";\n } else {\n // already completely visible\n return;\n }\n }\n\n driver.$scroll(() => {\n return (\n offset +\n driver.$getBaseOffset() +\n store.$getItemOffset(index) +\n (align === \"end\"\n ? store.$getItemSize(index) - store.$getViewportSize()\n : align === \"center\"\n ? (store.$getItemSize(index) - store.$getViewportSize()) / 2\n : 0)\n );\n }, smooth);\n};\n\n/**\n * @internal\n */\nexport const gridScrollTo = (\n driver: GridDriver,\n vertical: number | undefined,\n horizontal: number | undefined,\n) => {\n if (vertical != NULL) {\n driver.$scroll(false, () => vertical);\n }\n if (horizontal != NULL) {\n driver.$scroll(true, () => horizontal);\n }\n};\n\n/**\n * @internal\n */\nexport const gridScrollBy = (\n driver: GridDriver,\n rowStore: VirtualStore,\n colStore: VirtualStore,\n vertical: number | undefined,\n horizontal: number | undefined,\n) => {\n if (vertical != NULL) {\n const offset = vertical + rowStore.$getScrollOffset();\n driver.$scroll(false, () => offset);\n }\n if (horizontal != NULL) {\n const offset = horizontal + colStore.$getScrollOffset();\n driver.$scroll(true, () => offset);\n }\n};\n\nconst scrollGridAxisToIndex = (\n driver: GridDriver,\n store: VirtualStore,\n header: number,\n sections: readonly number[],\n footer: number,\n index: number,\n align: ScrollToIndexAlign | undefined,\n isHorizontal: boolean,\n) => {\n const count = store.$getItemsLength();\n const pinnedStart = min(header, count);\n const trailStart = max(count - footer, pinnedStart);\n index = clamp(index, 0, count - 1);\n const starts = getSectionStarts(sections, pinnedStart, trailStart);\n const section = getSection(starts, index, trailStart);\n const sectionHeader = section < 0 ? -1 : starts[section]!;\n // Read when scrolling, as the pinned items may be measured after the call. The offsets from the first item exclude the jump deferred during scrolling.\n // The header of the section of the item sticks under the pinned items, so the item is below it unless it's the header itself.\n const getInsets = (): [start: number, end: number] => [\n store.$getItemOffset(pinnedStart) -\n store.$getItemOffset(0) +\n (sectionHeader < 0 || sectionHeader === index\n ? 0\n : store.$getItemOffset(sectionHeader + 1) -\n store.$getItemOffset(sectionHeader)),\n store.$getItemOffset(count) - store.$getItemOffset(trailStart),\n ];\n\n if (align === \"nearest\") {\n if (index < pinnedStart || index >= trailStart) {\n // A pinned item is always visible\n return;\n }\n const [insetStart, insetEnd] = getInsets();\n const scrollOffset = store.$getScrollOffset();\n const itemSize = store.$getItemSize(index);\n let itemOffset = store.$getItemOffset(index);\n if (sectionHeader === index) {\n // A section header is where it sticks, until the end of its section pushes it out\n const lastIndex =\n (section + 1 < starts.length ? starts[section + 1]! : trailStart) - 1;\n itemOffset = max(\n itemOffset,\n min(\n scrollOffset + insetStart,\n store.$getItemOffset(lastIndex) +\n store.$getItemSize(lastIndex) -\n itemSize,\n ),\n );\n }\n if (itemOffset < scrollOffset + insetStart) {\n align = \"start\";\n } else if (\n itemOffset + itemSize >\n scrollOffset + store.$getViewportSize() - insetEnd\n ) {\n align = \"end\";\n } else {\n return;\n }\n }\n\n driver.$scroll(isHorizontal, () => {\n const [insetStart, insetEnd] = getInsets();\n const rest = store.$getItemSize(index) - store.$getViewportSize();\n return (\n store.$getItemOffset(index) +\n (align === \"end\"\n ? rest + insetEnd\n : align === \"center\"\n ? (rest + insetEnd - insetStart) / 2\n : -insetStart)\n );\n });\n};\n\n/**\n * @internal\n */\nexport const gridScrollToIndex = (\n driver: GridDriver,\n rowStore: VirtualStore,\n colStore: VirtualStore,\n headerRows = 0,\n sectionRows: readonly number[] = EMPTY,\n footerRows = 0,\n headerCols = 0,\n footerCols = 0,\n { rowIndex, colIndex, rowAlign, colAlign }: VGridScrollToIndexOpts,\n) => {\n // TODO support smooth scroll, removed because scrolling both axes smoothly freezes their ranges and the page\n if (rowIndex != NULL) {\n scrollGridAxisToIndex(\n driver,\n rowStore,\n headerRows,\n sectionRows,\n footerRows,\n rowIndex,\n rowAlign,\n false,\n );\n }\n if (colIndex != NULL) {\n scrollGridAxisToIndex(\n driver,\n colStore,\n headerCols,\n EMPTY,\n footerCols,\n colIndex,\n colAlign,\n true,\n );\n }\n};\n","/** @jsxImportSource vue */\nimport {\n ref,\n defineComponent,\n watch,\n type StyleValue,\n type VNode,\n type NativeElements,\n computed,\n type Ref,\n} from \"vue\";\nimport {\n type Driver,\n type StateVersion,\n type VirtualStore,\n} from \"../core/index.js\";\nimport { type ItemProps } from \"./utils.js\";\n\ninterface ListItemProps {\n _stateVersion: Ref<StateVersion>;\n _store: VirtualStore;\n _slot: (arg: { item: unknown; index: number }) => VNode[];\n _item: unknown;\n _resizer: Driver[\"$observeItem\"];\n _index: number;\n _isHorizontal: boolean;\n _isSSR: boolean;\n _as: keyof NativeElements;\n _itemProps?: ItemProps;\n}\n\n/**\n * @internal\n */\nexport const ListItem = /*#__PURE__*/ defineComponent(\n (props: ListItemProps) => {\n const elementRef = ref<HTMLDivElement>();\n\n const offset = computed(\n () =>\n props._stateVersion.value && props._store.$getItemOffset(props._index),\n );\n const hide = computed(\n () =>\n props._stateVersion.value &&\n props._store.$isUnmeasuredItem(props._index),\n );\n const children = computed(() =>\n props._slot({ item: props._item, index: props._index }),\n );\n\n // The index may be changed if elements are inserted to or removed from the start of props.children\n watch(\n () => elementRef.value && props._index,\n (_, __, onCleanup) => {\n onCleanup(props._resizer(elementRef.value!, props._index));\n },\n {\n flush: \"post\",\n },\n );\n\n return () => {\n const {\n _isHorizontal: isHorizontal,\n _isSSR: isSSR,\n _as: Element,\n _index: index,\n _item: item,\n } = props;\n const isHide = hide.value;\n\n const { style: styleProp, ...rest } =\n props._itemProps?.({ item, index }) || {};\n\n const style: StyleValue = {\n contain: \"layout style\",\n position: isHide && isSSR ? undefined : \"absolute\",\n [isHorizontal ? \"height\" : \"width\"]: \"100%\",\n [isHorizontal ? \"top\" : \"left\"]: \"0px\",\n [isHorizontal ? \"insetInlineStart\" : \"top\"]: offset.value + \"px\",\n visibility: !isHide || isSSR ? undefined : \"hidden\",\n ...styleProp,\n };\n if (isHorizontal) {\n style.display = \"inline-flex\";\n }\n\n return (\n <Element ref={elementRef} style={style} {...rest}>\n {children.value}\n </Element>\n );\n };\n },\n {\n // Required to split props from attrs. Object form keeps the keys manglable.\n props: {\n _stateVersion: null,\n _store: null,\n _slot: null,\n _item: null,\n _resizer: null,\n _index: null,\n _isHorizontal: null,\n _isSSR: null,\n _as: null,\n _itemProps: null,\n } satisfies Record<keyof ListItemProps, null>,\n },\n);\n","import { type CSSProperties, type VNode } from \"vue\";\nimport { type ItemsRange } from \"../core/index.js\";\n\n/**\n * @internal\n */\nexport const getKey = (e: VNode[], i: number): Exclude<VNode[\"key\"], null> => {\n // https://github.com/inokawa/virtua/pull/846\n if (e.length === 1) {\n const key = e[0]!.key;\n if (key != null) {\n return key;\n }\n }\n return \"_\" + i;\n};\n\n/**\n * @internal\n */\nexport const isSameRange = (prev: ItemsRange, next: ItemsRange): boolean => {\n return prev[0] === next[0] && prev[1] === next[1];\n};\n\nexport type ItemProps<T = unknown> = (payload: {\n item: T;\n index: number;\n}) => { [key: string]: any; style?: CSSProperties; class?: string } | undefined;\n","/** @jsxImportSource vue */\nimport {\n ref,\n onMounted,\n defineComponent,\n onUnmounted,\n type VNode,\n watch,\n type PublicProps,\n type PropType,\n type NativeElements,\n computed,\n} from \"vue\";\nimport {\n UPDATE_SCROLL_EVENT,\n UPDATE_SCROLL_END_EVENT,\n UPDATE_VIRTUAL_STATE,\n createVirtualStore,\n createListLayout,\n ACTION_ITEMS_LENGTH_CHANGE,\n getScrollSize,\n ACTION_START_OFFSET_CHANGE,\n createContainerDriver,\n scrollTo,\n scrollBy,\n scrollToIndex,\n type ItemsRange,\n type ScrollToIndexOpts,\n sort,\n type CacheSnapshot,\n} from \"../core/index.js\";\nimport { ListItem } from \"./ListItem.js\";\nimport { getKey, isSameRange, type ItemProps } from \"./utils.js\";\n\n/**\n * Props of {@link Virtualizer}.\n */\nexport interface VirtualizerProps<T = unknown> extends PublicProps {\n /**\n * The data items rendered by this component.\n */\n data: T[];\n /**\n * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.\n * @defaultValue 200\n */\n bufferSize?: number;\n /**\n * Item size hint for unmeasured items in pixels. It will help to reduce scroll jump when items are measured if used properly.\n *\n * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.\n * - If set, you can opt out estimation and use the value as initial item size.\n */\n itemSize?: number;\n /**\n * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.\n */\n shift?: boolean;\n /**\n * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.\n */\n horizontal?: boolean;\n /**\n * The offset to the scrollable parent before virtualizer in pixels. If you put an element before virtualizer, you have to set its height to this prop.\n */\n startMargin?: number;\n /**\n * A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated. The minimum value is 0.\n */\n ssrCount?: number;\n /**\n * Reference to the scrollable element. The default will get the direct parent element of virtualizer.\n */\n scrollRef?: HTMLElement;\n /**\n * Component or element type for container element.\n * @defaultValue \"div\"\n */\n as?: keyof NativeElements;\n /**\n * Component or element type for item element.\n * @defaultValue \"div\"\n */\n item?: keyof NativeElements;\n /**\n * A function that provides properties/attributes for item element\n *\n * **This prop will be merged into `item` prop in the future**\n */\n itemProps?: ItemProps<T>;\n /**\n * List of indexes that should be always mounted, even when off screen.\n */\n keepMounted?: readonly number[];\n /**\n * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link VirtualizerHandle.cache}.\n *\n * **The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.**\n */\n cache?: CacheSnapshot;\n /**\n * Callback invoked whenever scroll offset changes.\n * @param offset Current scrollTop, or scrollLeft if horizontal: true.\n */\n onScroll?: (offset: number) => void;\n /**\n * Callback invoked when scrolling stops.\n */\n onScrollEnd?: () => void;\n}\n\ninterface VirtualizerInstance<T = unknown> extends VirtualizerHandle {\n $props: VirtualizerProps<T>;\n $slots: { default: (arg: { item: T; index: number }) => VNode[] };\n}\n\n/**\n * Methods of {@link Virtualizer}.\n */\nexport interface VirtualizerHandle {\n /**\n * Get current {@link CacheSnapshot}.\n */\n readonly cache: CacheSnapshot;\n /**\n * Get current scrollTop, or scrollLeft if horizontal: true. Always positive even in RTL.\n */\n readonly scrollOffset: number;\n /**\n * Get current scrollHeight, or scrollWidth if horizontal: true.\n */\n readonly scrollSize: number;\n /**\n * Get current clientHeight, or clientWidth if horizontal: true.\n */\n readonly viewportSize: number;\n /**\n * Find nearest item index from offset.\n * @param offset offset in pixels from the start of the scroll container\n */\n findItemIndex(offset: number): number;\n /**\n * Get item offset from start.\n * @param index index of item\n */\n getItemOffset(index: number): number;\n /**\n * Get item size.\n * @param index index of item\n */\n getItemSize(index: number): number;\n /**\n * Scroll to the item specified by index.\n * @param index index of item\n * @param opts options\n */\n scrollToIndex(index: number, opts?: ScrollToIndexOpts): void;\n /**\n * Scroll to the given offset.\n * @param offset offset from start\n */\n scrollTo(offset: number): void;\n /**\n * Scroll by the given offset.\n * @param offset offset from current position\n */\n scrollBy(offset: number): void;\n}\n\n/**\n * Customizable list virtualizer for advanced usage. See {@link VirtualizerProps} and {@link VirtualizerHandle}.\n */\nexport const Virtualizer = /*#__PURE__*/ defineComponent({\n props: {\n data: { type: Array, required: true },\n bufferSize: Number,\n itemSize: Number,\n shift: Boolean,\n horizontal: Boolean,\n startMargin: { type: Number, default: 0 },\n ssrCount: Number,\n scrollRef: Object as PropType<VirtualizerProps[\"scrollRef\"]>,\n as: { type: String as PropType<VirtualizerProps[\"as\"]>, default: \"div\" },\n item: {\n type: String as PropType<VirtualizerProps[\"item\"]>,\n default: \"div\",\n },\n itemProps: Function as PropType<VirtualizerProps[\"itemProps\"]>,\n keepMounted: Array as PropType<VirtualizerProps[\"keepMounted\"]>,\n cache: Object as PropType<VirtualizerProps[\"cache\"]>,\n },\n emits: [\"scroll\", \"scrollEnd\"],\n setup(props, { emit, expose, slots }) {\n let isSSR = !!props.ssrCount;\n\n const isHorizontal = props.horizontal;\n const containerRef = ref<HTMLDivElement>();\n const layout = createListLayout(\n props.data.length,\n props.itemSize,\n props.cache,\n );\n const store = createVirtualStore(layout, props.ssrCount);\n const driver = createContainerDriver(store, isHorizontal);\n\n const stateVersion = ref(store.$getStateVersion());\n store.$subscribe(UPDATE_VIRTUAL_STATE, () => {\n stateVersion.value = store.$getStateVersion();\n });\n store.$subscribe(UPDATE_SCROLL_EVENT, () => {\n emit(\"scroll\", store.$getScrollOffset());\n });\n store.$subscribe(UPDATE_SCROLL_END_EVENT, () => {\n emit(\"scrollEnd\");\n });\n\n const range = computed<ItemsRange>((prev) => {\n stateVersion.value;\n const next = store.$getRange(props.bufferSize);\n if (prev && isSameRange(prev, next)) {\n return prev;\n }\n return next;\n });\n const isScrolling = computed(\n () => stateVersion.value && store.$isScrolling(),\n );\n const totalSize = computed(\n () => stateVersion.value && store.$getTotalSize(),\n );\n\n onMounted(() => {\n isSSR = false;\n\n // https://github.com/inokawa/virtua/issues/784\n const container = containerRef.value!;\n const raf = requestAnimationFrame(() => {\n // parent's ref doesn't exist when onMounted is called\n driver.$observe(container, props.scrollRef);\n });\n\n onUnmounted(() => {\n cancelAnimationFrame(raf);\n });\n });\n onUnmounted(() => {\n store.$dispose();\n driver.$dispose();\n });\n\n watch(\n () => props.data.length,\n (count) => {\n store.$update(ACTION_ITEMS_LENGTH_CHANGE, [count, props.shift]);\n },\n );\n watch(\n () => props.startMargin,\n (value) => {\n store.$update(ACTION_START_OFFSET_CHANGE, value);\n },\n { immediate: true },\n );\n\n watch(\n [stateVersion],\n () => {\n driver.$effect();\n },\n { flush: \"post\" },\n );\n\n expose({\n get cache() {\n return layout.$snapshot();\n },\n get scrollOffset() {\n return store.$getScrollOffset();\n },\n get scrollSize() {\n return getScrollSize(store);\n },\n get viewportSize() {\n return store.$getViewportSize();\n },\n findItemIndex: store.$findItemIndex,\n getItemOffset: store.$getItemOffset,\n getItemSize: store.$getItemSize,\n scrollToIndex: (index, opts) => scrollToIndex(driver, store, index, opts),\n scrollTo: (offset) => scrollTo(driver, offset),\n scrollBy: (offset) => scrollBy(driver, store, offset),\n } satisfies VirtualizerHandle);\n\n return () => {\n const Element = props.as;\n const ItemElement = props.item;\n\n const total = totalSize.value;\n\n const items: VNode[] = [];\n\n const renderItem = (i: number) => {\n const e = slots[\"default\"]!({ item: props.data![i]!, index: i });\n return (\n <ListItem\n key={getKey(e, i)}\n _stateVersion={stateVersion}\n _store={store}\n _resizer={driver.$observeItem}\n _index={i}\n _slot={slots[\"default\"]!}\n _item={props.data![i]!}\n _isHorizontal={isHorizontal}\n _isSSR={isSSR}\n _as={ItemElement}\n _itemProps={props.itemProps}\n />\n );\n };\n\n if (props.keepMounted) {\n const len = props.data.length;\n const mounted = new Set(props.keepMounted);\n for (let [i, j] = range.value; i <= j; i++) {\n mounted.add(i);\n }\n sort([...mounted]).forEach((index) => {\n if (index < len) {\n items.push(renderItem(index));\n }\n });\n } else {\n for (let [i, j] = range.value; i <= j; i++) {\n items.push(renderItem(i));\n }\n }\n\n return (\n <Element\n ref={containerRef}\n style={{\n contain: \"size style\", // https://github.com/inokawa/virtua/pull/775 https://github.com/inokawa/virtua/issues/800\n overflowAnchor: \"none\", // opt out browser's scroll anchoring because it will conflict to scroll anchoring of virtualizer\n flex: \"none\", // flex style can break layout\n position: \"relative\",\n width: isHorizontal ? total + \"px\" : \"100%\",\n height: isHorizontal ? \"100%\" : total + \"px\",\n pointerEvents: isScrolling.value ? \"none\" : undefined,\n }}\n >\n {items}\n </Element>\n );\n };\n },\n}) as unknown as {\n new <T = unknown>(props: VirtualizerProps<T>): VirtualizerInstance<T>;\n};\n","/** @jsxImportSource vue */\nimport {\n defineComponent,\n ref,\n type VNode,\n type PropType,\n type PublicProps,\n} from \"vue\";\nimport {\n Virtualizer,\n VirtualizerProps,\n type VirtualizerHandle,\n} from \"./Virtualizer.js\";\n\n/**\n * Methods of {@link VList}.\n */\nexport interface VListHandle extends VirtualizerHandle {}\n\n/**\n * Props of {@link VList}.\n */\nexport interface VListProps<T = unknown>\n extends\n PublicProps,\n Pick<\n VirtualizerProps<T>,\n | \"data\"\n | \"bufferSize\"\n | \"itemSize\"\n | \"shift\"\n | \"horizontal\"\n | \"cache\"\n | \"ssrCount\"\n | \"itemProps\"\n | \"onScroll\"\n | \"onScrollEnd\"\n | \"keepMounted\"\n > {}\n\ninterface VListInstance<T = unknown> extends VListHandle {\n $props: VListProps<T>;\n $slots: { default: (arg: { item: T; index: number }) => VNode[] };\n}\n\n/**\n * Virtualized list component. See {@link VListProps} and {@link VListHandle}.\n */\nexport const VList = /*#__PURE__*/ defineComponent({\n props: {\n data: { type: Array, required: true },\n bufferSize: Number,\n itemSize: Number,\n shift: Boolean,\n horizontal: Boolean,\n ssrCount: Number,\n itemProps: Function as PropType<VListProps[\"itemProps\"]>,\n keepMounted: Array as PropType<VListProps[\"keepMounted\"]>,\n cache: Object as PropType<VListProps[\"cache\"]>,\n },\n emits: [\"scroll\", \"scrollEnd\"],\n setup(props, { emit, expose, slots }) {\n const horizontal = props.horizontal;\n\n const onScroll = (offset: number) => {\n emit(\"scroll\", offset);\n };\n const onScrollEnd = () => {\n emit(\"scrollEnd\");\n };\n\n const handle = ref<InstanceType<typeof Virtualizer>>();\n\n expose({\n get cache() {\n return handle.value!.cache;\n },\n get scrollOffset() {\n return handle.value!.scrollOffset;\n },\n get scrollSize() {\n return handle.value!.scrollSize;\n },\n get viewportSize() {\n return handle.value!.viewportSize;\n },\n findItemIndex: (...args) => handle.value!.findItemIndex(...args),\n getItemOffset: (...args) => handle.value!.getItemOffset(...args),\n getItemSize: (...args) => handle.value!.getItemSize(...args),\n scrollToIndex: (...args) => handle.value!.scrollToIndex(...args),\n scrollTo: (...args) => handle.value!.scrollTo(...args),\n scrollBy: (...args) => handle.value!.scrollBy(...args),\n } satisfies VListHandle);\n\n return () => {\n return (\n <div\n style={{\n display: horizontal ? \"inline-block\" : \"block\",\n [horizontal ? \"overflowX\" : \"overflowY\"]: \"auto\",\n contain: \"strict\",\n width: \"100%\",\n height: \"100%\",\n }}\n >\n <Virtualizer\n ref={handle}\n data={props.data}\n bufferSize={props.bufferSize}\n itemSize={props.itemSize}\n itemProps={props.itemProps}\n shift={props.shift}\n ssrCount={props.ssrCount}\n horizontal={horizontal}\n keepMounted={props.keepMounted}\n cache={props.cache}\n onScroll={onScroll}\n onScrollEnd={onScrollEnd}\n >\n {slots}\n </Virtualizer>\n </div>\n );\n };\n },\n}) as unknown as {\n new <T = unknown>(props: VListProps<T>): VListInstance<T>;\n};\n","/** @jsxImportSource vue */\nimport {\n ref,\n onMounted,\n defineComponent,\n onUnmounted,\n type VNode,\n watch,\n type PropType,\n type NativeElements,\n computed,\n type PublicProps,\n} from \"vue\";\nimport {\n UPDATE_SCROLL_END_EVENT,\n UPDATE_VIRTUAL_STATE,\n createVirtualStore,\n createListLayout,\n ACTION_ITEMS_LENGTH_CHANGE,\n UPDATE_SCROLL_EVENT,\n createWindowDriver,\n scrollToIndex,\n type ItemsRange,\n type ScrollToIndexOpts,\n type CacheSnapshot,\n} from \"../core/index.js\";\nimport { ListItem } from \"./ListItem.js\";\nimport { getKey, isSameRange } from \"./utils.js\";\n\n/**\n * Props of {@link WindowVirtualizer}.\n */\nexport interface WindowVirtualizerProps<T = unknown> extends PublicProps {\n /**\n * The data items rendered by this component.\n */\n data: T[];\n /**\n * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.\n * @defaultValue 200\n */\n bufferSize?: number;\n /**\n * Item size hint for unmeasured items in pixels. It will help to reduce scroll jump when items are measured if used properly.\n *\n * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.\n * - If set, you can opt out estimation and use the value as initial item size.\n */\n itemSize?: number;\n /**\n * A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated. The minimum value is 0.\n */\n ssrCount?: number;\n /**\n * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.\n */\n shift?: boolean;\n /**\n * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.\n */\n horizontal?: boolean;\n /**\n * Component or element type for container element.\n * @defaultValue \"div\"\n */\n as?: keyof NativeElements;\n /**\n * Component or element type for item element.\n * @defaultValue \"div\"\n */\n item?: keyof NativeElements;\n /**\n * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link WindowVirtualizerHandle.cache}.\n *\n * **The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.**\n */\n cache?: CacheSnapshot;\n /**\n * Callback invoked whenever scroll offset changes.\n */\n onScroll?: () => void;\n /**\n * Callback invoked when scrolling stops.\n */\n onScrollEnd?: () => void;\n}\n\ninterface WindowVirtualizerInstance<\n T = unknown,\n> extends WindowVirtualizerHandle {\n $props: WindowVirtualizerProps<T>;\n $slots: { default: (arg: { item: T; index: number }) => VNode[] };\n}\n\n/**\n * Methods of {@link WindowVirtualizer}.\n */\nexport interface WindowVirtualizerHandle {\n /**\n * Get current {@link CacheSnapshot}.\n */\n readonly cache: CacheSnapshot;\n /**\n * Get current scrollTop, or scrollLeft if horizontal: true. Always positive even in RTL.\n */\n readonly scrollOffset: number;\n /**\n * Get current clientHeight of the document, or clientWidth if horizontal: true.\n */\n readonly viewportSize: number;\n /**\n * Find nearest item index from offset.\n * @param offset offset in pixels from the start of the scroll container\n */\n findItemIndex(offset: number): number;\n /**\n * Get item offset from start.\n * @param index index of item\n */\n getItemOffset(index: number): number;\n /**\n * Get item size.\n * @param index index of item\n */\n getItemSize(index: number): number;\n /**\n * Scroll to the item specified by index.\n * @param index index of item\n * @param opts options\n */\n scrollToIndex(index: number, opts?: ScrollToIndexOpts): void;\n}\n\n/**\n * {@link Virtualizer} controlled by the window scrolling. See {@link WindowVirtualizerProps} and {@link WindowVirtualizerHandle}.\n */\nexport const WindowVirtualizer = /*#__PURE__*/ defineComponent({\n props: {\n data: { type: Array, required: true },\n bufferSize: Number,\n itemSize: Number,\n ssrCount: Number,\n shift: Boolean,\n horizontal: Boolean,\n as: {\n type: String as PropType<WindowVirtualizerProps[\"as\"]>,\n default: \"div\",\n },\n item: {\n type: String as PropType<WindowVirtualizerProps[\"item\"]>,\n default: \"div\",\n },\n cache: Object as PropType<WindowVirtualizerProps[\"cache\"]>,\n },\n emits: [\"scroll\", \"scrollEnd\"],\n setup(props, { emit, slots, expose }) {\n let isSSR = !!props.ssrCount;\n\n const isHorizontal = props.horizontal;\n const containerRef = ref<HTMLDivElement>();\n const layout = createListLayout(\n props.data.length,\n props.itemSize,\n props.cache,\n );\n const store = createVirtualStore(layout, props.ssrCount);\n const driver = createWindowDriver(store, isHorizontal);\n\n const stateVersion = ref(store.$getStateVersion());\n store.$subscribe(UPDATE_VIRTUAL_STATE, () => {\n stateVersion.value = store.$getStateVersion();\n });\n store.$subscribe(UPDATE_SCROLL_EVENT, () => {\n // https://github.com/inokawa/virtua/discussions/580\n emit(\"scroll\");\n });\n store.$subscribe(UPDATE_SCROLL_END_EVENT, () => {\n emit(\"scrollEnd\");\n });\n\n const range = computed<ItemsRange>((prev) => {\n stateVersion.value;\n const next = store.$getRange(props.bufferSize);\n if (prev && isSameRange(prev, next)) {\n return prev;\n }\n return next;\n });\n const isScrolling = computed(\n () => stateVersion.value && store.$isScrolling(),\n );\n const totalSize = computed(\n () => stateVersion.value && store.$getTotalSize(),\n );\n\n onMounted(() => {\n isSSR = false;\n\n const el = containerRef.value;\n if (!el) return;\n driver.$observe(el);\n });\n onUnmounted(() => {\n store.$dispose();\n driver.$dispose();\n });\n\n watch(\n () => props.data.length,\n (count) => {\n store.$update(ACTION_ITEMS_LENGTH_CHANGE, [count, props.shift]);\n },\n );\n\n watch(\n [stateVersion],\n () => {\n driver.$effect();\n },\n { flush: \"post\" },\n );\n\n expose({\n get cache() {\n return layout.$snapshot();\n },\n get scrollOffset() {\n return store.$getScrollOffset();\n },\n get viewportSize() {\n return store.$getViewportSize();\n },\n findItemIndex: store.$findItemIndex,\n getItemOffset: store.$getItemOffset,\n getItemSize: store.$getItemSize,\n scrollToIndex: (index, opts) => scrollToIndex(driver, store, index, opts),\n } satisfies WindowVirtualizerHandle);\n\n return () => {\n const Element = props.as;\n const ItemElement = props.item;\n\n const total = totalSize.value;\n\n const items: VNode[] = [];\n for (let [i, j] = range.value; i <= j; i++) {\n const e = slots[\"default\"]!({ item: props.data![i]!, index: i });\n items.push(\n <ListItem\n key={getKey(e, i)}\n _stateVersion={stateVersion}\n _store={store}\n _resizer={driver.$observeItem}\n _index={i}\n _slot={slots[\"default\"]!}\n _item={props.data![i]!}\n _isHorizontal={isHorizontal}\n _isSSR={isSSR}\n _as={ItemElement}\n />,\n );\n }\n\n return (\n <Element\n ref={containerRef}\n style={{\n contain: \"size style\", // https://github.com/inokawa/virtua/pull/775 https://github.com/inokawa/virtua/issues/800\n overflowAnchor: \"none\", // opt out browser's scroll anchoring because it will conflict to scroll anchoring of virtualizer\n flex: \"none\", // flex style can break layout\n position: \"relative\",\n width: isHorizontal ? total + \"px\" : \"100%\",\n height: isHorizontal ? \"100%\" : total + \"px\",\n pointerEvents: isScrolling.value ? \"none\" : undefined,\n }}\n >\n {items}\n </Element>\n );\n };\n },\n}) as unknown as {\n new <T = unknown>(\n props: WindowVirtualizerProps<T>,\n ): WindowVirtualizerInstance<T>;\n};\n","/** @jsxImportSource vue */\nimport {\n defineComponent,\n onMounted,\n onUnmounted,\n ref,\n watch,\n computed,\n type VNode,\n type PropType,\n type PublicProps,\n type StyleValue,\n watchEffect,\n} from \"vue\";\nimport {\n UPDATE_SCROLL_END_EVENT,\n UPDATE_SCROLL_EVENT,\n UPDATE_VIRTUAL_STATE,\n createContainerGridDriver,\n createGridLayout,\n createVirtualStore,\n getAxisItem,\n getScrollSize,\n gridScrollBy,\n gridScrollTo,\n gridScrollToIndex,\n updateGridAxis,\n type GridDriver,\n type VGridScrollToIndexOpts,\n type VGridAxis,\n type VGridCell,\n type VGridSize,\n type VGridTrackSize,\n type VGridSpan,\n createGridPlan,\n type GridCellState,\n type GridRowGroupState,\n type GridRowState,\n} from \"../core/index.js\";\n\n/**\n * Props of {@link VGrid}.\n */\nexport interface VGridProps<R = number, C = number> extends PublicProps {\n /**\n * The rows of the grid. See {@link VGridAxis} for the accepted values.\n */\n rows: VGridAxis<R>;\n /**\n * The columns of the grid. See {@link VGridAxis} for the accepted values.\n */\n cols: VGridAxis<C>;\n /**\n * The heights of the rows. See {@link VGridSize} for the accepted values.\n */\n rowHeight: NoInfer<VGridSize<R>>;\n /**\n * The widths of the columns. See {@link VGridSize} for the accepted values.\n */\n colWidth: NoInfer<VGridSize<C>>;\n /**\n * The number of the leading rows pinned to the start, which are the column headers (`role=\"columnheader\"`).\n *\n * **The pinned cells are rendered over the other cells, so give them an opaque background.**\n * @defaultValue 0\n */\n headerRows?: number;\n /**\n * Indexes of the rows which start sections. A section lasts until the next section row or the footer rows, and its first row sticks below the header rows while the section is scrolled through.\n *\n * **The section rows are rendered over the other cells while they stick, so give them an opaque background.**\n */\n sectionRows?: readonly number[];\n /**\n * The number of the trailing rows pinned to the end.\n *\n * **The pinned cells are rendered over the other cells, so give them an opaque background.**\n * @defaultValue 0\n */\n footerRows?: number;\n /**\n * The number of the leading columns pinned to the start, the last of which is the row header (`role=\"rowheader\"`).\n *\n * **The pinned cells are rendered over the other cells, so give them an opaque background.**\n * @defaultValue 0\n */\n headerCols?: number;\n /**\n * The number of the trailing columns pinned to the end.\n *\n * **The pinned cells are rendered over the other cells, so give them an opaque background.**\n * @defaultValue 0\n */\n footerCols?: number;\n /**\n * Cells merged over multiple rows and/or columns. See {@link VGridSpan} for the accepted values.\n *\n * The cell at the origin is stretched over the merged area, and the other cells in it are not rendered. Spans must not overlap each other or cross the boundaries of the pinned rows/columns or the sections. A spanning cell is not measured for `\"auto\"` sizes on the axes it spans, and doesn't enlarge those tracks.\n */\n spans?: readonly VGridSpan[];\n /**\n * List of cells that should be always mounted, even when off screen.\n */\n keepMounted?: readonly VGridCell[];\n /**\n * Extra space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank cells in fast scrolling.\n * @defaultValue 200\n */\n bufferSize?: number;\n /**\n * The gap between the rows and the columns in pixels, which is not included in the sizes. Must not be changed after mount.\n * @defaultValue 0\n */\n gap?: number;\n /**\n * The header cell of the sorted column or row, and the sort order (`aria-sort`).\n */\n ariaSort?: VGridCell & { order: \"ascending\" | \"descending\" | \"other\" };\n /**\n * Callback invoked whenever the vertical scroll offset changes.\n * @param offset Current scrollTop.\n */\n onVerticalScroll?: (offset: number) => void;\n /**\n * Callback invoked whenever the horizontal scroll offset changes.\n * @param offset Current scrollLeft. Always positive even in RTL.\n */\n onHorizontalScroll?: (offset: number) => void;\n /**\n * Callback invoked when scrolling stops.\n */\n onScrollEnd?: () => void;\n}\n\n/**\n * Methods of {@link VGrid}.\n */\nexport interface VGridHandle {\n /**\n * Get current scrollTop.\n */\n readonly verticalScrollOffset: number;\n /**\n * Get current scrollLeft. Always positive even in RTL.\n */\n readonly horizontalScrollOffset: number;\n /**\n * Get current scrollHeight.\n */\n readonly scrollHeight: number;\n /**\n * Get current scrollWidth.\n */\n readonly scrollWidth: number;\n /**\n * Get current clientHeight.\n */\n readonly viewportHeight: number;\n /**\n * Get current clientWidth.\n */\n readonly viewportWidth: number;\n /**\n * Find nearest row index from offset.\n * @param offset offset in pixels from the top of the scroll container\n */\n findRowIndex(offset: number): number;\n /**\n * Find nearest column index from offset.\n * @param offset offset in pixels from the start of the scroll container\n */\n findColIndex(offset: number): number;\n /**\n * Get offset of the row from the top.\n * @param index index of row\n */\n getRowOffset(index: number): number;\n /**\n * Get offset of the column from the start.\n * @param index index of column\n */\n getColOffset(index: number): number;\n /**\n * Get size of the row.\n * @param index index of row\n */\n getRowSize(index: number): number;\n /**\n * Get size of the column.\n * @param index index of column\n */\n getColSize(index: number): number;\n /**\n * Scroll to the cell specified by the indexes. The cell is not hidden behind the rows and the columns sticking over it.\n * @param opts the indexes of the cell and the options. See {@link VGridScrollToIndexOpts}.\n */\n scrollToIndex(opts: VGridScrollToIndexOpts): void;\n /**\n * Scroll to the given offsets from the top/start of the scroll container.\n * @param offset the offsets. The axis whose offset is omitted is not scrolled.\n */\n scrollTo(offset: { vertical?: number; horizontal?: number }): void;\n /**\n * Scroll by the given offsets from the current position.\n * @param offset the offsets. The axis whose offset is omitted is not scrolled.\n */\n scrollBy(offset: { vertical?: number; horizontal?: number }): void;\n}\n\ninterface VGridInstance<R = number, C = number> extends VGridHandle {\n $props: VGridProps<R, C>;\n $slots: {\n default: (arg: { row: R; col: C; cell: Readonly<VGridCell> }) => VNode[];\n };\n}\n\ninterface GridCellProps {\n _state: GridCellState;\n _slot: (arg: {\n row: unknown;\n col: unknown;\n cell: Readonly<VGridCell>;\n }) => VNode[];\n _row: unknown;\n _col: unknown;\n _rowIndex: number;\n _resizer: GridDriver[\"$observeItem\"];\n}\n\nconst GridCell = /*#__PURE__*/ defineComponent(\n (props: GridCellProps) => {\n const elementRef = ref<HTMLDivElement>();\n\n watch(\n [\n elementRef,\n () => props._state.$measureRow,\n () => props._state.$measureCol,\n ],\n ([element, rowIndex, colIndex], _, onCleanup) => {\n if (!element || (rowIndex == null && colIndex == null)) return;\n onCleanup(props._resizer(element, rowIndex, colIndex));\n },\n { flush: \"post\" },\n );\n\n return () => {\n const {\n $col: colIndex,\n $rowSpan,\n $colSpan,\n $role,\n $sort,\n $style,\n } = props._state;\n return (\n <div\n ref={elementRef}\n role={$role}\n aria-colindex={colIndex + 1}\n aria-rowspan={$rowSpan}\n aria-colspan={$colSpan}\n aria-sort={$sort}\n style={$style as StyleValue}\n >\n {props._slot({\n row: props._row,\n col: props._col,\n cell: { rowIndex: props._rowIndex, colIndex },\n })}\n </div>\n );\n };\n },\n {\n // Required to split props from attrs. Object form keeps the keys manglable.\n props: {\n _state: null,\n _slot: null,\n _row: null,\n _col: null,\n _rowIndex: null,\n _resizer: null,\n } satisfies Record<keyof GridCellProps, null>,\n },\n);\n\ninterface GridRowProps {\n _state: GridRowState;\n _slot: (arg: {\n row: unknown;\n col: unknown;\n cell: Readonly<VGridCell>;\n }) => VNode[];\n _row: unknown;\n _cols: VGridAxis<unknown>;\n _resizer: GridDriver[\"$observeItem\"];\n}\n\nconst GridRow = /*#__PURE__*/ defineComponent(\n (props: GridRowProps) => {\n return () => {\n const { $row: rowIndex, $cells, $style } = props._state;\n return (\n <div\n role=\"row\"\n aria-rowindex={rowIndex + 1}\n style={$style as StyleValue}\n >\n {$cells.map((cell) => (\n <GridCell\n key={cell.$col}\n _state={cell}\n _slot={props._slot}\n _row={props._row}\n _col={getAxisItem(props._cols, cell.$col)}\n _rowIndex={rowIndex}\n _resizer={props._resizer}\n />\n ))}\n </div>\n );\n };\n },\n {\n // Required to split props from attrs. Object form keeps the keys manglable.\n props: {\n _state: null,\n _slot: null,\n _row: null,\n _cols: null,\n _resizer: null,\n } satisfies Record<keyof GridRowProps, null>,\n },\n);\n\ninterface GridRowGroupProps {\n _state: GridRowGroupState;\n _slot: (props: {\n row: unknown;\n col: unknown;\n cell: Readonly<VGridCell>;\n }) => VNode[];\n _rows: VGridAxis<unknown>;\n _cols: VGridAxis<unknown>;\n _resizer: GridDriver[\"$observeItem\"];\n}\n\nconst GridRowGroup = /*#__PURE__*/ defineComponent(\n (props: GridRowGroupProps) => {\n return () => {\n const { $rows, $style } = props._state;\n return (\n // https://www.w3.org/TR/wai-aria-1.2/#rowgroup\n <div role=\"rowgroup\" style={$style as StyleValue}>\n {$rows.map((state) => (\n <GridRow\n key={state.$row}\n _state={state}\n _slot={props._slot}\n _row={getAxisItem(props._rows, state.$row)}\n _cols={props._cols}\n _resizer={props._resizer}\n />\n ))}\n </div>\n );\n };\n },\n {\n // Required to split props from attrs. Object form keeps the keys manglable.\n props: {\n _state: null,\n _slot: null,\n _rows: null,\n _cols: null,\n _resizer: null,\n } satisfies Record<keyof GridRowGroupProps, null>,\n },\n);\n\n/**\n * Virtualized grid component for tabular data. See {@link VGridProps} and {@link VGridHandle}.\n */\nexport const VGrid = /*#__PURE__*/ defineComponent({\n props: {\n rows: {\n type: [Number, Array] as PropType<VGridAxis<unknown>>,\n required: true,\n },\n cols: {\n type: [Number, Array] as PropType<VGridAxis<unknown>>,\n required: true,\n },\n rowHeight: {\n type: [Number, String] as PropType<VGridTrackSize | string>,\n required: true,\n },\n colWidth: {\n type: [Number, String] as PropType<VGridTrackSize | string>,\n required: true,\n },\n headerRows: Number,\n sectionRows: Array as PropType<VGridProps[\"sectionRows\"]>,\n footerRows: Number,\n headerCols: Number,\n footerCols: Number,\n spans: Array as PropType<VGridProps[\"spans\"]>,\n keepMounted: Array as PropType<VGridProps[\"keepMounted\"]>,\n bufferSize: Number,\n gap: { type: Number, default: 0 },\n ariaSort: Object as PropType<VGridProps[\"ariaSort\"]>,\n },\n emits: [\"verticalScroll\", \"horizontalScroll\", \"scrollEnd\"],\n setup(props, { emit, expose, slots }) {\n const containerRef = ref<HTMLDivElement>();\n\n const rowLayout = createGridLayout(props.rows, props.rowHeight, props.gap);\n const colLayout = createGridLayout(props.cols, props.colWidth, props.gap);\n const rowStore = createVirtualStore(rowLayout);\n const colStore = createVirtualStore(colLayout);\n const driver = createContainerGridDriver(rowStore, colStore);\n\n const stateVersion = ref(\n rowStore.$getStateVersion() + colStore.$getStateVersion(),\n );\n const rerender = () => {\n stateVersion.value =\n rowStore.$getStateVersion() + colStore.$getStateVersion();\n };\n rowStore.$subscribe(UPDATE_VIRTUAL_STATE, rerender);\n colStore.$subscribe(UPDATE_VIRTUAL_STATE, rerender);\n\n // Both stores observe both axes, so the end is notified once after both have ended.\n let scrolled = false;\n rowStore.$subscribe(UPDATE_SCROLL_EVENT, () => {\n scrolled = true;\n emit(\"verticalScroll\", rowStore.$getScrollOffset());\n });\n colStore.$subscribe(UPDATE_SCROLL_EVENT, () => {\n scrolled = true;\n emit(\"horizontalScroll\", colStore.$getScrollOffset());\n });\n const notifyScrollEnd = () => {\n if (scrolled && !rowStore.$isScrolling() && !colStore.$isScrolling()) {\n scrolled = false;\n emit(\"scrollEnd\");\n }\n };\n rowStore.$subscribe(UPDATE_SCROLL_END_EVENT, notifyScrollEnd);\n colStore.$subscribe(UPDATE_SCROLL_END_EVENT, notifyScrollEnd);\n\n // The sizes read from the items are tracked, so the items mutated in place are followed.\n watchEffect(() => {\n updateGridAxis(rowStore, rowLayout, props.rows, props.rowHeight, true);\n });\n watchEffect(() => {\n updateGridAxis(colStore, colLayout, props.cols, props.colWidth, true);\n });\n\n const rowCount = computed(\n () => stateVersion.value && rowStore.$getItemsLength(),\n );\n const colCount = computed(\n () => stateVersion.value && colStore.$getItemsLength(),\n );\n const plan = computed(() => {\n stateVersion.value;\n return createGridPlan(\n rowLayout,\n colLayout,\n rowStore.$getRange(props.bufferSize),\n colStore.$getRange(props.bufferSize),\n props.headerRows,\n props.sectionRows,\n props.footerRows,\n props.headerCols,\n props.footerCols,\n props.spans,\n props.keepMounted,\n props.ariaSort,\n );\n });\n const isScrolling = computed(\n () =>\n stateVersion.value &&\n (rowStore.$isScrolling() || colStore.$isScrolling()),\n );\n\n onMounted(() => {\n driver.$observe(containerRef.value!);\n });\n onUnmounted(() => {\n rowStore.$dispose();\n colStore.$dispose();\n driver.$dispose();\n });\n\n watch(\n [stateVersion],\n () => {\n driver.$effect();\n },\n { flush: \"post\" },\n );\n\n expose({\n get verticalScrollOffset() {\n return rowStore.$getScrollOffset();\n },\n get horizontalScrollOffset() {\n return colStore.$getScrollOffset();\n },\n get scrollHeight() {\n return getScrollSize(rowStore);\n },\n get scrollWidth() {\n return getScrollSize(colStore);\n },\n get viewportHeight() {\n return rowStore.$getViewportSize();\n },\n get viewportWidth() {\n return colStore.$getViewportSize();\n },\n findRowIndex: rowStore.$findItemIndex,\n findColIndex: colStore.$findItemIndex,\n getRowOffset: rowStore.$getItemOffset,\n getColOffset: colStore.$getItemOffset,\n getRowSize: rowStore.$getItemSize,\n getColSize: colStore.$getItemSize,\n scrollToIndex: (opts) =>\n gridScrollToIndex(\n driver,\n rowStore,\n colStore,\n props.headerRows,\n props.sectionRows,\n props.footerRows,\n props.headerCols,\n props.footerCols,\n opts,\n ),\n scrollTo: ({ vertical, horizontal }) =>\n gridScrollTo(driver, vertical, horizontal),\n scrollBy: ({ vertical, horizontal }) =>\n gridScrollBy(driver, rowStore, colStore, vertical, horizontal),\n } satisfies VGridHandle);\n\n return () => {\n const { $rowTemplate, $colTemplate, $groups } = plan.value;\n // A jump deferred during scrolling shifts the tracks, as it shifts the items of the lists.\n const marginTop = rowStore.$getItemOffset(0);\n const marginInlineStart = colStore.$getItemOffset(0);\n\n const containerStyle: StyleValue = {\n // https://github.com/inokawa/virtua/pull/775 https://github.com/inokawa/virtua/issues/800\n contain: \"size style\",\n overflowAnchor: \"none\", // opt out browser's scroll anchoring because it will conflict to scroll anchoring of virtualizer\n flex: \"none\", // flex style can break layout\n display: \"grid\",\n gridTemplateRows: $rowTemplate,\n gridTemplateColumns: $colTemplate,\n gap: props.gap + \"px\",\n marginTop: marginTop + \"px\",\n marginInlineStart: marginInlineStart + \"px\",\n // The width is left to the viewport, so the auto columns fill it as the columns of a table.\n height: getScrollSize(rowStore) - marginTop + \"px\",\n pointerEvents: isScrolling.value ? \"none\" : undefined,\n };\n\n return (\n <div\n // https://www.w3.org/WAI/ARIA/apg/patterns/table/\n // https://www.w3.org/TR/wai-aria-1.2/#table\n // https://www.w3.org/TR/wai-aria-1.2/#aria-rowcount\n role=\"table\"\n aria-rowcount={rowCount.value}\n aria-colcount={colCount.value}\n style={{\n overflow: \"auto\",\n contain: \"strict\",\n width: \"100%\",\n height: \"100%\",\n }}\n >\n <div ref={containerRef} style={containerStyle}>\n {$groups.map((state) =>\n \"$rows\" in state ? (\n <GridRowGroup\n key={state.$key}\n _state={state}\n _slot={slots[\"default\"]!}\n _rows={props.rows}\n _cols={props.cols}\n _resizer={driver.$observeItem}\n />\n ) : (\n <GridRow\n key={state.$row}\n _state={state}\n _slot={slots[\"default\"]!}\n _row={getAxisItem(props.rows, state.$row)}\n _cols={props.cols}\n _resizer={driver.$observeItem}\n />\n ),\n )}\n </div>\n </div>\n );\n };\n },\n}) as unknown as {\n new <R = number, C = number>(props: VGridProps<R, C>): VGridInstance<R, C>;\n};\n"],"mappings":";;;;;;AAMA,ICYI,GDZS,IAA0B,KAG1B,KAAE,GAAA,KAAK,GAAA,KAAK,GAAA,OAAK,KAAU,MAK3B,IAAA,CACX,GACA,GACA,MACW,EAAI,GAAU,EAAI,GAAU,KAK5B,IAA0B,KAC9B,EAAI,KAAA,CAAM,GAAG,MAAM,IAAI,IAMnB,IAAU,YAIV,IAAgB,cAKhB,IACe,qBAAnB,iBACH,iBACC;IACC,QAAQ,UAAU,KAAK;GAMlB,IAAA;IACX,IAA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AAWA,KAAAA,GAAK/C,EAAAA,aAAA6C,GAAA;gBAAA,KAEPE,EAAM4F;gBAAI,IACP5F;gBAAK,GACN4B,EAAM;gBAAU,IAChB5D,EAAMmC;gBAAI,IACVnC,EAAMwC;gBAAI,IACP0B,EAAO2D;eAAY,MAAA,GAAA,EAAA,MAAA,KAAA,MAAA,MAAA,WAAA,GAAA5I,EAAAA,aAAAwC,GAAA;gBAAA,KAIxBO,EAAMN;gBAAI,IACPM;gBAAK,GACN4B,EAAM;gBAAU,IACjBpE,EAAYQ,EAAMmC,MAAMH,EAAMN;gBAAK,IAClC1B,EAAMwC;gBAAI,IACP0B,EAAO2D;eAAY,MAAA,GAAA,EAAA,MAAA,KAAA,MAAA,MAAA,YAGlC,MAAA,GAAA,EAAA,iBAAA;;AAKX"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["ref","defineComponent","watch","computed","mergeProps","_mergeProps","createVNode","_createVNode","ListItem","props","elementRef","offset","_stateVersion","value","_store","$getItemOffset","_index","hide","$isUnmeasuredItem","children","_slot","item","_item","index","_","__","onCleanup","_resizer","flush","_isHorizontal","isHorizontal","_isSSR","isSSR","_as","Element","isHide","style","styleProp","rest","_itemProps","contain","position","undefined","visibility","display","default","ref","onMounted","defineComponent","onUnmounted","watch","computed","createVNode","_createVNode","isVNode","_isVNode","UPDATE_SCROLL_EVENT","UPDATE_SCROLL_END_EVENT","UPDATE_VIRTUAL_STATE","createVirtualStore","createListLayout","ACTION_ITEMS_LENGTH_CHANGE","getScrollSize","ACTION_START_OFFSET_CHANGE","createContainerDriver","scrollTo","scrollBy","scrollToIndex","sort","ListItem","getKey","isSameRange","_isSlot","s","Object","prototype","toString","call","Virtualizer","props","data","type","Array","required","bufferSize","Number","itemSize","shift","Boolean","horizontal","startMargin","default","ssrCount","scrollRef","as","String","item","itemProps","Function","keepMounted","cache","emits","setup","emit","expose","slots","isSSR","isHorizontal","containerRef","layout","length","store","driver","stateVersion","$getStateVersion","$subscribe","value","$getScrollOffset","range","prev","next","$getRange","isScrolling","$isScrolling","totalSize","$getTotalSize","container","raf","requestAnimationFrame","$observe","cancelAnimationFrame","$dispose","count","$update","immediate","$effect","flush","$snapshot","scrollOffset","scrollSize","viewportSize","$getViewportSize","findItemIndex","$findItemIndex","getItemOffset","$getItemOffset","getItemSize","$getItemSize","index","opts","offset","Element","ItemElement","total","items","renderItem","i","e","$observeItem","len","mounted","Set","j","add","forEach","push","contain","overflowAnchor","flex","position","width","height","pointerEvents","undefined","_","defineComponent","ref","isVNode","_isVNode","createVNode","_createVNode","Virtualizer","_isSlot","s","Object","prototype","toString","call","VList","props","data","type","Array","required","bufferSize","Number","itemSize","shift","Boolean","horizontal","ssrCount","itemProps","Function","keepMounted","cache","emits","setup","emit","expose","slots","onScroll","offset","onScrollEnd","handle","value","scrollOffset","scrollSize","viewportSize","findItemIndex","args","getItemOffset","getItemSize","scrollToIndex","scrollTo","scrollBy","display","contain","width","height","default","_","ref","onMounted","defineComponent","onUnmounted","watch","computed","createVNode","_createVNode","isVNode","_isVNode","UPDATE_SCROLL_END_EVENT","UPDATE_VIRTUAL_STATE","createVirtualStore","createListLayout","ACTION_ITEMS_LENGTH_CHANGE","UPDATE_SCROLL_EVENT","createWindowDriver","scrollToIndex","ListItem","getKey","isSameRange","_isSlot","s","Object","prototype","toString","call","WindowVirtualizer","props","data","type","Array","required","bufferSize","Number","itemSize","ssrCount","shift","Boolean","horizontal","as","String","default","item","cache","emits","setup","emit","slots","expose","isSSR","isHorizontal","containerRef","layout","length","store","driver","stateVersion","$getStateVersion","$subscribe","value","range","prev","next","$getRange","isScrolling","$isScrolling","totalSize","$getTotalSize","el","$observe","$dispose","count","$update","$effect","flush","$snapshot","scrollOffset","$getScrollOffset","viewportSize","$getViewportSize","findItemIndex","$findItemIndex","getItemOffset","$getItemOffset","getItemSize","$getItemSize","index","opts","Element","ItemElement","total","items","i","j","e","push","$observeItem","contain","overflowAnchor","flex","position","width","height","pointerEvents","undefined","_","defineComponent","onMounted","onUnmounted","ref","watch","computed","watchEffect","createVNode","_createVNode","UPDATE_SCROLL_END_EVENT","UPDATE_SCROLL_EVENT","UPDATE_VIRTUAL_STATE","createContainerGridDriver","createGridLayout","createVirtualStore","getAxisItem","getScrollSize","gridScrollBy","gridScrollTo","gridScrollToIndex","updateGridAxis","createGridPlan","GridCell","props","elementRef","_state","$measureRow","$measureCol","element","rowIndex","colIndex","_","onCleanup","_resizer","flush","$col","$rowSpan","$colSpan","$role","$sort","$style","_slot","row","_row","col","_col","cell","_rowIndex","GridRow","$row","$cells","map","_cols","GridRowGroup","$rows","state","_rows","VGrid","rows","type","Number","Array","required","cols","rowHeight","String","colWidth","headerRows","sectionRows","footerRows","headerCols","footerCols","spans","keepMounted","bufferSize","gap","default","ariaSort","Object","emits","setup","emit","expose","slots","containerRef","rowLayout","colLayout","rowStore","colStore","driver","stateVersion","$getStateVersion","rerender","value","$subscribe","scrolled","$getScrollOffset","notifyScrollEnd","$isScrolling","rowCount","$getItemsLength","colCount","plan","$getRange","isScrolling","$observe","$dispose","$effect","verticalScrollOffset","horizontalScrollOffset","scrollHeight","scrollWidth","viewportHeight","$getViewportSize","viewportWidth","findRowIndex","$findItemIndex","findColIndex","getRowOffset","$getItemOffset","getColOffset","getRowSize","$getItemSize","getColSize","scrollToIndex","opts","scrollTo","vertical","horizontal","scrollBy","$rowTemplate","$colTemplate","$groups","marginTop","marginInlineStart","containerStyle","contain","overflowAnchor","flex","display","gridTemplateRows","gridTemplateColumns","height","pointerEvents","undefined","overflow","width","$key","$observeItem"],"sources":["../../src/core/utils.ts","../../src/core/environment.ts","../../src/core/store.ts","../../src/core/cache.ts","../../src/core/layouts/list.ts","../../src/core/layouts/grid.ts","../../src/core/grid.ts","../../src/core/observer.ts","../../src/core/driver.ts","../../src/core/scroll-to.ts","../../src/vue/ListItem.tsx","../../src/vue/utils.ts","../../src/vue/Virtualizer.tsx","../../src/vue/VList.tsx","../../src/vue/WindowVirtualizer.tsx","../../src/vue/VGrid.tsx"],"sourcesContent":["/** @internal */\nexport const NULL = null;\n\n/**\n * @internal\n */\nexport const EMPTY: readonly never[] = [];\n\n/** @internal */\nexport const { min, max, abs, floor } = Math;\n\n/**\n * @internal\n */\nexport const clamp = (\n value: number,\n minValue: number,\n maxValue: number,\n): number => min(maxValue, max(minValue, value));\n\n/**\n * @internal\n */\nexport const sort = <T extends number>(arr: T[]): T[] => {\n return arr.sort((a, b) => a - b);\n};\n\n/**\n * @internal\n */\nexport const timeout = setTimeout;\n/**\n * @internal\n */\nexport const cancelTimeout = clearTimeout;\n\n/**\n * @internal\n */\nexport const microtask: (fn: () => void) => void =\n typeof queueMicrotask === \"function\"\n ? queueMicrotask\n : (fn) => {\n Promise.resolve().then(fn);\n };\n\n/**\n * @internal\n */\nexport const createPromise = <T = void>(): [Promise<T>, (arg: T) => void] => {\n let resolve: ((arg: T) => void) | undefined;\n const promise = new Promise<T>((res) => {\n resolve = res;\n });\n return [promise, resolve!];\n};\n","import { NULL } from \"./utils.js\";\n\n/**\n * @internal\n */\nexport const isBrowser = typeof window !== \"undefined\";\n\n/**\n * @internal\n */\nexport const getCurrentDocument = (node: HTMLElement): Document =>\n node.ownerDocument;\n\n/**\n * @internal\n */\nexport const getCurrentWindow = (doc: Document) => doc.defaultView!;\n\nlet isIOS: boolean | undefined;\n\n/**\n * Currently, all browsers on iOS/iPadOS are WebKit, including WebView.\n * @internal\n */\nexport const isIOSWebKit = (): boolean => {\n if (isIOS == NULL) {\n isIOS =\n /iP(hone|od|ad)/.test(navigator.userAgent) ||\n // Modern iPad detection (iPadOS 13+)\n // iPadOS 13+ reports the same userAgent/platform information as macOS, to enable desktop sites.\n // So we treat devices that have macOS like information but with touch support as iPadOS.\n // https://stackoverflow.com/questions/57776001/how-to-detect-ipad-pro-as-ipad-using-javascript\n (navigator.platform === \"MacIntel\" && navigator.maxTouchPoints > 0);\n }\n return isIOS;\n};\n","import { isIOSWebKit } from \"./environment.js\";\nimport type { Layout } from \"./layouts/types.js\";\nimport type { ItemResize, ItemsRange } from \"./types.js\";\nimport { abs, max, min, NULL } from \"./utils.js\";\n\nconst MAX_INT_32 = 0x7fffffff;\n\nconst SCROLL_IDLE = 0;\nconst SCROLL_DOWN = 1;\nconst SCROLL_UP = 2;\ntype ScrollDirection =\n typeof SCROLL_IDLE | typeof SCROLL_DOWN | typeof SCROLL_UP;\n\nconst SCROLL_BY_NATIVE = 0;\nconst SCROLL_BY_MANUAL_SCROLL = 1;\nconst SCROLL_BY_SHIFT = 2;\ntype ScrollMode =\n | typeof SCROLL_BY_NATIVE\n | typeof SCROLL_BY_MANUAL_SCROLL\n | typeof SCROLL_BY_SHIFT;\n\n/** @internal */\nexport const ACTION_SCROLL = 1;\n/** @internal */\nexport const ACTION_SCROLL_END = 2;\n/** @internal */\nexport const ACTION_ITEM_RESIZE = 3;\n/** @internal */\nexport const ACTION_VIEWPORT_RESIZE = 4;\n/** @internal */\nexport const ACTION_ITEMS_LENGTH_CHANGE = 5;\n/** @internal */\nexport const ACTION_START_OFFSET_CHANGE = 6;\n/** @internal */\nexport const ACTION_MANUAL_SCROLL = 7;\n/** @internal */\nexport const ACTION_BEFORE_MANUAL_SMOOTH_SCROLL = 8;\n/** @internal */\nexport const ACTION_RELAYOUT = 9;\n\ntype Actions =\n | [type: typeof ACTION_SCROLL, offset: number]\n | [type: typeof ACTION_SCROLL_END, dummy?: void]\n | [type: typeof ACTION_ITEM_RESIZE, entries: ItemResize[]]\n | [type: typeof ACTION_VIEWPORT_RESIZE, size: number]\n | [\n type: typeof ACTION_ITEMS_LENGTH_CHANGE,\n arg: [length: number, isShift?: boolean | undefined],\n ]\n | [type: typeof ACTION_START_OFFSET_CHANGE, offset: number]\n | [type: typeof ACTION_MANUAL_SCROLL, dummy?: void]\n | [type: typeof ACTION_BEFORE_MANUAL_SMOOTH_SCROLL, offset: number]\n | [type: typeof ACTION_RELAYOUT, jump: number];\n\n/** @internal */\nexport const UPDATE_VIRTUAL_STATE = 0b0001;\n/** @internal */\nexport const UPDATE_SIZE_EVENT = 0b0010;\n/** @internal */\nexport const UPDATE_SCROLL_EVENT = 0b0100;\n/** @internal */\nexport const UPDATE_SCROLL_END_EVENT = 0b1000;\n\n/**\n * @internal\n */\nexport const getScrollSize = (store: VirtualStore): number => {\n return max(store.$getTotalSize(), store.$getViewportSize());\n};\n\ntype Subscriber = (sync?: boolean) => void;\n\n/** @internal */\nexport type StateVersion =\n number & {}; /* hack for typescript to pretend as not falsy */\n\n/**\n * @internal\n */\nexport type VirtualStore = {\n $dispose(): void;\n $getStateVersion(): StateVersion;\n $getRange(bufferSize?: number): ItemsRange;\n $findItemIndex(offset: number): number;\n $isUnmeasuredItem(index: number): boolean;\n $getItemOffset(index: number): number;\n $getItemSize(index: number): number;\n $getItemsLength(): number;\n $getScrollOffset(): number;\n $isScrolling(): boolean;\n $getViewportSize(): number;\n $getStartSpacerSize(): number;\n $getTotalSize(): number;\n _flushJump(): [number, boolean];\n $subscribe(target: number, cb: Subscriber): () => void;\n $update(...action: Actions): void;\n};\n\n/**\n * @internal\n */\nexport const createVirtualStore = (\n {\n $getRange: getRange,\n $findIndex: findIndex,\n $getItemOffset: getOffset,\n $getItemSize: getItemSize,\n $setItemSize: setItemSize,\n $isSizeEqual: isSizeEqual,\n $getTotalSize: getTotalSize,\n $getLength: getLength,\n $setLength: setLength,\n $estimateDefaultSize: estimateDefaultSize,\n }: Layout,\n ssrCount: number = 0,\n): VirtualStore => {\n let shouldAutoEstimateItemSize = !!estimateDefaultSize;\n let isSSR = !!ssrCount;\n let stateVersion: StateVersion = 1;\n let viewportSize = 0;\n let startSpacerSize = 0;\n let scrollOffset = 0;\n let jump = 0;\n let pendingJump = 0;\n let _flushedJump = 0;\n let _scrollDirection: ScrollDirection = SCROLL_IDLE;\n let _scrollMode: ScrollMode = SCROLL_BY_NATIVE;\n let _frozenRange: ItemsRange | null = NULL;\n let _prevRange: ItemsRange = [0, isSSR ? max(ssrCount - 1, 0) : -1];\n let _totalMeasuredSize = 0;\n let _isViewportMeasured = false;\n\n const subscribers = new Set<[number, Subscriber]>();\n const getRelativeScrollOffset = () => scrollOffset - startSpacerSize;\n const getVisibleOffset = () => getRelativeScrollOffset() + pendingJump + jump;\n const getItemOffset = (index: number): number => {\n return getOffset(index) - pendingJump;\n };\n\n const applyJump = (j: number) => {\n if (j) {\n if (\n // In iOS WebKit browsers, updating scroll position will stop scrolling so it have to be deferred during scrolling.\n (isIOSWebKit() && _scrollDirection !== SCROLL_IDLE) ||\n // Before imperative smooth scrolling, we measure all items which may be visible during scrolling.\n // However, especially in Firefox, there are rare cases where items resize while scrolling, which can stop smooth scrolling.\n (_frozenRange && _scrollMode === SCROLL_BY_MANUAL_SCROLL)\n ) {\n pendingJump += j;\n } else {\n jump += j;\n }\n }\n };\n\n return {\n $dispose: () => {\n subscribers.clear();\n },\n $getStateVersion: () => stateVersion,\n $getRange: (bufferSize = 200) => {\n if (!_isViewportMeasured || isSSR) {\n // Return range for SSR, or return [0, -1] to render nothing, until the scroll offset and viewport size are determined.\n // https://github.com/inokawa/virtua/issues/415\n // https://github.com/inokawa/virtua/pull/818\n return _prevRange;\n }\n let startIndex: number;\n let endIndex: number;\n if (_flushedJump) {\n // Return previous range for consistent render until next scroll event comes in.\n // And it must be clamped. https://github.com/inokawa/virtua/issues/597\n [startIndex, endIndex] = _prevRange;\n } else {\n let startOffset = max(0, getVisibleOffset());\n let endOffset = startOffset + viewportSize;\n\n // For faster initial render pass, returns without buffer if measurement seems to be in progress.\n if (!shouldAutoEstimateItemSize) {\n bufferSize = max(0, bufferSize);\n\n if (_scrollDirection !== SCROLL_DOWN) {\n startOffset -= bufferSize;\n }\n if (_scrollDirection !== SCROLL_UP) {\n endOffset += bufferSize;\n }\n }\n\n [startIndex, endIndex] = _prevRange = getRange(\n max(0, startOffset),\n max(0, endOffset),\n );\n if (_frozenRange) {\n startIndex = min(startIndex, _frozenRange[0]);\n endIndex = max(endIndex, _frozenRange[1]);\n }\n }\n\n return [max(startIndex, 0), min(endIndex, getLength() - 1)];\n },\n $findItemIndex: (offset) => findIndex(offset - startSpacerSize),\n $isUnmeasuredItem: isSizeEqual,\n $getItemOffset: getItemOffset,\n $getItemSize: getItemSize,\n $getItemsLength: getLength,\n $getScrollOffset: () => scrollOffset,\n $isScrolling: () => _scrollDirection !== SCROLL_IDLE,\n $getViewportSize: () => viewportSize,\n $getStartSpacerSize: () => startSpacerSize,\n $getTotalSize: getTotalSize,\n _flushJump: () => {\n _flushedJump = jump;\n jump = 0;\n return [_flushedJump, _scrollMode === SCROLL_BY_SHIFT];\n },\n $subscribe: (target, cb) => {\n const sub: [number, Subscriber] = [target, cb];\n subscribers.add(sub);\n return () => {\n subscribers.delete(sub);\n };\n },\n $update: (type, payload): void => {\n let shouldFlushPendingJump: boolean | undefined;\n let shouldSync: boolean | undefined;\n let mutated = 0;\n\n switch (type) {\n case ACTION_SCROLL: {\n if (payload === scrollOffset && _scrollMode === SCROLL_BY_NATIVE) {\n // Ignore scroll events from different direction\n break;\n }\n\n const flushedJump = _flushedJump;\n _flushedJump = 0;\n\n const delta = payload - scrollOffset;\n const distance = abs(delta);\n\n // Scroll event after jump compensation is not reliable because it may result in the opposite direction.\n // The delta of artificial scroll may not be equal with the jump because it may be batched with other scrolls.\n // And at least in latest Chrome/Firefox/Safari in 2023, setting value to scrollTop/scrollLeft can lose subpixel because its integer (sometimes float probably depending on dpr).\n const isJustJumped = flushedJump && distance < abs(flushedJump) + 1;\n\n // Scroll events are dispatched enough so it's ok to skip some of them.\n if (\n !isJustJumped &&\n // Ignore until manual scrolling\n _scrollMode === SCROLL_BY_NATIVE\n ) {\n _scrollDirection = delta < 0 ? SCROLL_UP : SCROLL_DOWN;\n }\n\n // TODO This will cause glitch in reverse infinite scrolling. Disable this until better solution is found.\n // if (\n // pendingJump &&\n // ((_scrollDirection === SCROLL_UP &&\n // payload - max(pendingJump, 0) <= 0) ||\n // (_scrollDirection === SCROLL_DOWN &&\n // payload - min(pendingJump, 0) >= getScrollOffsetMax()))\n // ) {\n // // Flush if almost reached to start or end\n // shouldFlushPendingJump = true;\n // }\n\n if (isSSR) {\n isSSR = false;\n }\n\n scrollOffset = payload;\n mutated = UPDATE_SCROLL_EVENT;\n\n // Skip if offset is not changed\n // Scroll offset may exceed min or max especially in Safari's elastic scrolling.\n const relativeOffset = getRelativeScrollOffset();\n if (\n relativeOffset >= -viewportSize &&\n relativeOffset <= getTotalSize()\n ) {\n mutated += UPDATE_VIRTUAL_STATE;\n\n // Update synchronously if scrolled a lot\n shouldSync = distance > viewportSize;\n }\n break;\n }\n case ACTION_SCROLL_END: {\n mutated = UPDATE_SCROLL_END_EVENT;\n if (_scrollDirection !== SCROLL_IDLE) {\n shouldFlushPendingJump = true;\n mutated += UPDATE_VIRTUAL_STATE;\n }\n _scrollDirection = SCROLL_IDLE;\n _scrollMode = SCROLL_BY_NATIVE;\n _frozenRange = NULL;\n break;\n }\n case ACTION_ITEM_RESIZE: {\n const updated = payload.filter(\n ([index, size]) => !isSizeEqual(index, size),\n );\n\n // Skip if all items are cached and not updated\n if (!updated.length) {\n break;\n }\n\n // Calculate jump by resize to minimize junks in appearance\n applyJump(\n updated.reduce((acc, [index, size]) => {\n let shouldKeep: boolean;\n if (\n // Keep distance from end during shifting\n _scrollMode === SCROLL_BY_SHIFT\n ) {\n shouldKeep = true;\n } else if (\n _frozenRange &&\n _scrollMode === SCROLL_BY_MANUAL_SCROLL\n ) {\n // https://github.com/inokawa/virtua/issues/380\n // https://github.com/inokawa/virtua/issues/758\n shouldKeep = index < _frozenRange[0];\n } else {\n // Otherwise we should maintain visible position\n const start = getRelativeScrollOffset();\n const itemOffset = getItemOffset(index);\n const itemSize = getItemSize(index);\n shouldKeep =\n _scrollDirection !== SCROLL_DOWN &&\n _scrollMode === SCROLL_BY_NATIVE\n ? // https://github.com/inokawa/virtua/issues/385\n // https://github.com/inokawa/virtua/discussions/865\n // https://github.com/inokawa/virtua/issues/893\n // Use \"<=\" instead of \"<\" here so the item whose bottom rests exactly on the viewport top (the row directly above an item anchored to the top) is compensated too.\n itemOffset + itemSize <= start\n : // https://github.com/inokawa/virtua/pull/868\n itemOffset < start &&\n itemOffset + itemSize < start + viewportSize;\n }\n\n if (shouldKeep) {\n acc += size - getItemSize(index);\n }\n return acc;\n }, 0),\n );\n\n // Update item sizes\n for (const [index, size] of updated) {\n const prevSize = getItemSize(index);\n const isInitialMeasurement = setItemSize(index, size);\n\n if (shouldAutoEstimateItemSize) {\n _totalMeasuredSize += isInitialMeasurement\n ? size\n : size - prevSize;\n }\n }\n\n // Estimate initial item size from measured sizes\n if (\n shouldAutoEstimateItemSize &&\n viewportSize &&\n // If the total size is lower than the viewport, the item may be a empty state\n _totalMeasuredSize > viewportSize\n ) {\n applyJump(estimateDefaultSize!(findIndex(getVisibleOffset())));\n shouldAutoEstimateItemSize = false;\n }\n\n mutated = UPDATE_VIRTUAL_STATE + UPDATE_SIZE_EVENT;\n\n // Synchronous update is necessary in current design to minimize visible glitch in concurrent rendering.\n // However this seems to be the main cause of the errors from ResizeObserver.\n // https://github.com/inokawa/virtua/issues/470\n //\n // And in React, synchronous update with flushSync after asynchronous update will overtake the asynchronous one.\n // If items resize happens just after scroll, race condition can occur depending on implementation.\n shouldSync = true;\n break;\n }\n case ACTION_VIEWPORT_RESIZE: {\n if (viewportSize !== payload) {\n if (!viewportSize) {\n _isViewportMeasured = shouldSync = true;\n }\n viewportSize = payload;\n mutated = UPDATE_VIRTUAL_STATE + UPDATE_SIZE_EVENT;\n }\n break;\n }\n case ACTION_ITEMS_LENGTH_CHANGE: {\n if (payload[1]) {\n applyJump(setLength(payload[0], true));\n _scrollMode = SCROLL_BY_SHIFT;\n mutated = UPDATE_VIRTUAL_STATE;\n } else {\n setLength(payload[0]);\n // https://github.com/inokawa/virtua/issues/552\n // https://github.com/inokawa/virtua/issues/557\n mutated = UPDATE_VIRTUAL_STATE;\n }\n break;\n }\n case ACTION_START_OFFSET_CHANGE: {\n startSpacerSize = payload;\n break;\n }\n case ACTION_MANUAL_SCROLL: {\n _scrollMode = SCROLL_BY_MANUAL_SCROLL;\n break;\n }\n case ACTION_RELAYOUT: {\n // It never requests a synchronous update, so it's safe to dispatch during render.\n applyJump(payload);\n mutated = UPDATE_VIRTUAL_STATE + UPDATE_SIZE_EVENT;\n break;\n }\n case ACTION_BEFORE_MANUAL_SMOOTH_SCROLL: {\n _frozenRange = getRange(payload, payload + viewportSize);\n mutated = UPDATE_VIRTUAL_STATE;\n break;\n }\n }\n\n if (mutated) {\n stateVersion = (stateVersion & MAX_INT_32) + 1;\n\n if (shouldFlushPendingJump && pendingJump) {\n jump += pendingJump;\n pendingJump = 0;\n }\n\n subscribers.forEach(([target, cb]) => {\n // Early return to skip React's computation\n if (!(mutated & target)) {\n return;\n }\n // https://github.com/facebook/react/issues/25191\n // https://github.com/facebook/react/blob/a5fc797db14c6e05d4d5c4dbb22a0dd70d41f5d5/packages/react-reconciler/src/ReactFiberWorkLoop.js#L1443-L1447\n cb(shouldSync);\n });\n }\n },\n };\n};\n","import { clamp, floor } from \"./utils.js\";\n\n/** @internal */\nexport const UNCACHED = -1;\n\n/**\n * Finds the index of an item in the cache whose computed offset is closest to the specified offset.\n *\n * @internal\n */\nexport const findIndex = (\n getOffset: (index: number) => number,\n length: number,\n offset: number,\n low: number = 0,\n high: number = length - 1,\n): number => {\n // Find with binary search\n let found: number = low;\n while (low <= high) {\n const mid = floor((low + high) / 2);\n if (getOffset(mid) <= offset) {\n found = mid;\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n return clamp(found, 0, length - 1);\n};\n","import { UNCACHED, findIndex } from \"../cache.js\";\nimport type { Layout } from \"./types.js\";\nimport type { CacheSnapshot } from \"../types.js\";\nimport { max, min, sort } from \"../utils.js\";\n\nconst fill = (array: number[], length: number, prepend?: boolean): number[] => {\n const key = prepend ? \"unshift\" : \"push\";\n for (let i = 0; i < length; i++) {\n array[key](UNCACHED);\n }\n return array;\n};\n\n/**\n * @internal\n */\nexport interface ListLayout extends Layout {\n $snapshot(): CacheSnapshot;\n}\n\n/**\n * @internal\n */\nexport const createListLayout = (\n length: number,\n itemSize?: number | undefined,\n snapshot?: CacheSnapshot | undefined,\n): ListLayout => {\n let defaultItemSize = (snapshot && snapshot[1]) || itemSize || 40;\n\n let computedOffsetIndex = -1;\n let prevStartIndex = 0;\n\n const restoredSizes = snapshot && snapshot[0];\n\n const sizes: number[] = restoredSizes\n ? // https://github.com/inokawa/virtua/issues/441\n fill(\n restoredSizes.slice(0, min(length, restoredSizes.length)),\n max(0, length - restoredSizes.length),\n )\n : fill([], length);\n const offsets: number[] = fill([], length + 1);\n\n const getSize = (index: number): number => {\n const size = sizes[index]!;\n return size === UNCACHED ? defaultItemSize : size;\n };\n\n const getOffset = (index: number): number => {\n if (!length) return 0;\n if (computedOffsetIndex >= index) {\n return offsets[index]!;\n }\n\n if (computedOffsetIndex < 0) {\n // first offset must be 0 to avoid returning NaN, which can cause infinite rerender.\n // https://github.com/inokawa/virtua/pull/160\n offsets[0] = 0;\n computedOffsetIndex = 0;\n }\n let i = computedOffsetIndex;\n let top = offsets[i]!;\n while (i < index) {\n top += getSize(i);\n offsets[++i] = top;\n }\n // mark as measured\n computedOffsetIndex = index;\n return top;\n };\n\n return {\n $getRange: (startOffset, endOffset) => {\n // Clamp because prevStartIndex may exceed the limit when children decreased a lot after scrolling\n prevStartIndex = min(prevStartIndex, length - 1);\n\n let start: number;\n let end: number;\n if (getOffset(prevStartIndex) <= startOffset) {\n // search forward\n // start <= end, prevStartIndex <= start\n end = findIndex(getOffset, length, endOffset, prevStartIndex);\n start = findIndex(getOffset, length, startOffset, prevStartIndex, end);\n } else {\n // search backward\n // start <= end, start <= prevStartIndex\n start = findIndex(\n getOffset,\n length,\n startOffset,\n undefined,\n prevStartIndex,\n );\n end = findIndex(getOffset, length, endOffset, start);\n }\n prevStartIndex = start;\n return [start, end];\n },\n $findIndex: (offset) => findIndex(getOffset, length, offset),\n $getItemOffset: getOffset,\n $getItemSize: getSize,\n $setItemSize: (index, size) => {\n const isInitialMeasurement = sizes[index] === UNCACHED;\n sizes[index] = size;\n // mark as dirty\n computedOffsetIndex = min(index, computedOffsetIndex);\n return isInitialMeasurement;\n },\n $isSizeEqual: (index, size = UNCACHED) => sizes[index] === size,\n $getTotalSize: () => getOffset(length),\n $getLength: () => length,\n $setLength: (nextLength, isShift) => {\n const diff = nextLength - length;\n\n computedOffsetIndex = isShift\n ? // Discard cache for now\n -1\n : min(nextLength - 1, computedOffsetIndex);\n length = nextLength;\n\n if (diff > 0) {\n // Added\n fill(offsets, diff);\n fill(sizes, diff, isShift);\n return defaultItemSize * diff;\n } else {\n // Removed\n offsets.splice(diff);\n return (isShift ? sizes.splice(0, -diff) : sizes.splice(diff)).reduce(\n (acc, removed) =>\n acc - (removed === UNCACHED ? defaultItemSize : removed),\n 0,\n );\n }\n },\n $estimateDefaultSize: itemSize\n ? undefined\n : (startIndex) => {\n let measuredCountBeforeStart = 0;\n // This function will be called after measurement so measured size array must be longer than 0\n const measuredSizes: number[] = [];\n sizes.forEach((s, i) => {\n if (s !== UNCACHED) {\n // https://github.com/inokawa/virtua/issues/907\n if (s) {\n measuredSizes.push(s);\n }\n if (i < startIndex) {\n measuredCountBeforeStart++;\n }\n }\n });\n\n // Discard cache for now\n computedOffsetIndex = -1;\n\n // Calculate median\n sort(measuredSizes);\n const len = measuredSizes.length;\n const mid = (len / 2) | 0;\n const median =\n len % 2 === 0\n ? (measuredSizes[mid - 1]! + measuredSizes[mid]!) / 2\n : measuredSizes[mid]!;\n\n const prevDefaultItemSize = defaultItemSize;\n\n // Calculate diff of unmeasured items before start\n return (\n ((defaultItemSize = median) - prevDefaultItemSize) *\n max(startIndex - measuredCountBeforeStart, 0)\n );\n },\n $snapshot: () => [sizes.slice(), defaultItemSize],\n };\n};\n","import { UNCACHED } from \"../cache.js\";\nimport { createListLayout } from \"./list.js\";\nimport type { Layout } from \"./types.js\";\nimport type { ItemsRange } from \"../types.js\";\nimport { clamp, floor, max, min, NULL } from \"../utils.js\";\n\nexport type GridTrackSize = number | \"auto\";\n\n/**\n * The rows or the columns of the grid.\n *\n * - If a number is set, the grid has that many rows/columns, and the cells receive their indexes.\n * - If an array is set, the grid has one row/column per item, and the cells receive the items.\n */\nexport type GridAxis<T = number> = number | readonly T[];\n\ntype GridSizeFields<T> = {\n [\n K in Extract<keyof T, string> as T[K] extends\n GridTrackSize | null | undefined\n ? K\n : never\n ]: 0;\n};\n\nexport type GridSizeKey<T> = [T] extends [object]\n ? keyof GridSizeFields<T>\n : never;\n\n/**\n * The sizes of the rows or the columns in pixels.\n *\n * - A number is used as is, and never measured.\n * - `\"auto\"` fits the largest rendered cell. The auto columns also share the space left in the viewport, as the columns of a table.\n * - A key reads the size, a number or `\"auto\"`, from the item of each row/column, and a missing size is `\"auto\"`.\n *\n * The form of the size, a number, `\"auto\"` or a key, must not be changed after mount. To switch it, remount the grid.\n */\nexport type GridSize<T = number> = GridTrackSize | GridSizeKey<T>;\n\n/**\n * @internal\n */\nexport const getAxisLength = (axis: GridAxis<unknown>): number =>\n typeof axis === \"number\" ? axis : axis.length;\n\n/**\n * @internal\n */\nexport const getAxisItem = <T>(axis: GridAxis<T>, index: number): T =>\n typeof axis === \"number\" ? (index as T) : axis[index]!;\n\n/**\n * @internal\n */\nexport interface GridLayout extends Layout {\n $isMeasurable(index: number): boolean;\n $setPinned(header?: number, footer?: number): void;\n $getPinnedStart(): number;\n $getTrailStart(): number;\n $setAxis(\n axis: GridAxis<unknown>,\n size: GridTrackSize | string,\n scrollOffset: number,\n mutable?: boolean,\n ): number | undefined;\n}\n\n/**\n * @internal\n */\nexport const createGridLayout = (\n axis: GridAxis<unknown>,\n size: GridTrackSize | string,\n gap: number = 0,\n): GridLayout => {\n let header = 0;\n let footer = 0;\n const setPinned = (nextHeader: number = 0, nextFooter: number = 0) => {\n header = nextHeader;\n footer = nextFooter;\n };\n const getPinnedStart = (length: number): number => min(header, length);\n const getTrailStart = (length: number): number =>\n max(length - footer, getPinnedStart(length));\n const pinRange = (\n getRange: Layout[\"$getRange\"],\n getOffset: Layout[\"$getItemOffset\"],\n length: number,\n startOffset: number,\n endOffset: number,\n ): ItemsRange => {\n // The tracks pinned to the edges stick over the viewport, so the tracks behind them are never seen and the range covers only the tracks between them.\n const insetStart = getOffset(getPinnedStart(length));\n const insetEnd = getOffset(length) - getOffset(getTrailStart(length));\n // The bands of the pinned tracks don't cover the gaps after them, so the gap the insets include is given back.\n const start = startOffset + (insetStart ? insetStart - gap : 0);\n return getRange(\n start,\n // The range covers one track if the pinned tracks are thicker than the viewport.\n max(start, endOffset - (insetEnd ? insetEnd - gap : 0)),\n );\n };\n\n if (typeof size === \"number\") {\n let length = getAxisLength(axis);\n let itemSize = size;\n const findIndex = (offset: number): number =>\n // 0 / 0 is NaN, which can cause infinite rerender\n itemSize + gap\n ? clamp(floor(offset / (itemSize + gap)), 0, length - 1)\n : 0;\n const getItemOffset = (index: number): number => index * (itemSize + gap);\n const findRange: Layout[\"$getRange\"] = (startOffset, endOffset) => [\n findIndex(startOffset),\n findIndex(endOffset),\n ];\n return {\n $getRange: (startOffset, endOffset) =>\n pinRange(findRange, getItemOffset, length, startOffset, endOffset),\n $findIndex: findIndex,\n $getItemOffset: getItemOffset,\n $getItemSize: () => itemSize,\n // The cells of a uniform axis are not measured\n $setItemSize: () => false,\n $isSizeEqual: () => false,\n $getTotalSize: () => (length ? length * (itemSize + gap) - gap : 0),\n $getLength: () => length,\n $setLength: (nextLength) => {\n length = nextLength;\n // The grid doesn't shift the items\n return 0;\n },\n $isMeasurable: () => false,\n $setPinned: setPinned,\n $getPinnedStart: () => getPinnedStart(length),\n $getTrailStart: () => getTrailStart(length),\n $setAxis: (_axis, nextSize, scrollOffset) => {\n if (typeof nextSize !== \"number\" || nextSize === itemSize) {\n return;\n }\n const jump = findIndex(scrollOffset) * (nextSize - itemSize);\n itemSize = nextSize;\n return jump;\n },\n };\n }\n const isAuto = size === \"auto\";\n let currentAxis: GridAxis<unknown> | undefined;\n let currentSize: GridTrackSize | string = size;\n const length = getAxisLength(axis);\n\n // Whether each item was auto when the axis was set, as the items may be mutated after that.\n const autos: boolean[] = [];\n // The sizes inside include the gap after the track, and so does the default size.\n // The default size is given as a snapshot, because a size given to the layout would fix it and drop the estimation.\n const inner = createListLayout(length, undefined, [[], 40 + gap]);\n\n const isMeasurable = (index: number): boolean => isAuto || !!autos[index];\n const layout: GridLayout = {\n $getRange: (startOffset, endOffset) =>\n pinRange(\n inner.$getRange,\n inner.$getItemOffset,\n inner.$getLength(),\n startOffset,\n endOffset,\n ),\n $findIndex: inner.$findIndex,\n $getItemOffset: inner.$getItemOffset,\n $getItemSize: (index) => inner.$getItemSize(index) - gap,\n // A measurement may come for an item given a size after it's rendered.\n $setItemSize: (index, s) =>\n isMeasurable(index) && inner.$setItemSize(index, s + gap),\n $isSizeEqual: (index, s) => inner.$isSizeEqual(index, s! + gap),\n $getTotalSize: () => (inner.$getLength() ? inner.$getTotalSize() - gap : 0),\n $getLength: inner.$getLength,\n $setLength: inner.$setLength,\n $estimateDefaultSize: isAuto ? inner.$estimateDefaultSize : undefined,\n $isMeasurable: isMeasurable,\n $setPinned: setPinned,\n $getPinnedStart: () => getPinnedStart(inner.$getLength()),\n $getTrailStart: () => getTrailStart(inner.$getLength()),\n $setAxis: (nextAxis, requestedSize, scrollOffset, mutable) => {\n if (isAuto) {\n return;\n }\n // The form of the size is fixed at mount, so a size of another form is ignored.\n const nextSize =\n typeof requestedSize === \"number\" || requestedSize === \"auto\"\n ? currentSize\n : requestedSize;\n const length = inner.$getLength();\n // The items of the same axis are the same, unless they may be mutated in place.\n if (\n !mutable &&\n nextAxis === currentAxis &&\n nextSize === currentSize &&\n length === autos.length\n ) {\n return;\n }\n currentAxis = nextAxis;\n currentSize = nextSize;\n autos.length = length;\n\n const anchorIndex = inner.$findIndex(scrollOffset);\n const prevOffset = inner.$getItemOffset(anchorIndex);\n let changed: boolean | undefined;\n for (let i = 0; i < length; i++) {\n const item = (nextAxis as readonly unknown[])[i];\n // An item which isn't an object, such as a placeholder of a header row, has no size.\n const itemSize =\n item !== NULL && typeof item === \"object\"\n ? (item as Record<string, GridTrackSize | null | undefined>)[\n nextSize as string\n ]\n : NULL;\n const isAutoItem = typeof itemSize !== \"number\";\n // An item which was auto keeps its measured size.\n if (!isAutoItem || !autos[i]) {\n autos[i] = isAutoItem;\n const target = isAutoItem ? UNCACHED : itemSize + gap;\n if (!inner.$isSizeEqual(i, target)) {\n inner.$setItemSize(i, target);\n changed = true;\n }\n }\n }\n if (!changed) {\n return;\n }\n return inner.$getItemOffset(anchorIndex) - prevOffset;\n },\n };\n layout.$setAxis(axis, size, 0);\n return layout;\n};\n","import {\n getAxisLength,\n type GridLayout,\n type GridAxis,\n type GridTrackSize,\n} from \"./layouts/grid.js\";\nimport {\n ACTION_ITEMS_LENGTH_CHANGE,\n ACTION_RELAYOUT,\n type VirtualStore,\n} from \"./store.js\";\nimport { type ItemsRange } from \"./types.js\";\nimport { clamp, EMPTY, max, min, NULL, sort } from \"./utils.js\";\n\n/**\n * A cell position in the grid.\n */\nexport interface GridCell {\n /**\n * The row index of the cell.\n */\n rowIndex: number;\n /**\n * The column index of the cell.\n */\n colIndex: number;\n}\n\n/**\n * A cell merged over multiple rows and/or columns in the grid.\n *\n * {@link GridCell.rowIndex} and {@link GridCell.colIndex} point to the origin cell (top row, start column) of the merged area.\n */\nexport interface GridSpan extends GridCell {\n /**\n * The number of rows the cell spans.\n * @defaultValue 1\n */\n rowSpan?: number;\n /**\n * The number of columns the cell spans.\n * @defaultValue 1\n */\n colSpan?: number;\n}\n\n/**\n * @internal\n */\nexport const updateGridAxis = (\n store: VirtualStore,\n layout: GridLayout,\n axis: GridAxis<unknown>,\n size: GridTrackSize | string,\n header?: number,\n footer?: number,\n mutable?: boolean,\n) => {\n const length = getAxisLength(axis);\n layout.$setPinned(header, footer);\n if (length !== store.$getItemsLength()) {\n store.$update(ACTION_ITEMS_LENGTH_CHANGE, [length]);\n }\n // The tracks are shifted by the jump deferred during scrolling, which the layout doesn't include.\n const jump = layout.$setAxis(\n axis,\n size,\n store.$getScrollOffset() - store.$getItemOffset(0),\n mutable,\n );\n // undefined means nothing changed, and 0 means the tracks changed without a jump.\n if (jump != NULL) {\n store.$update(ACTION_RELAYOUT, jump);\n }\n};\n\n// The states of the previous plan of each grid, keyed by its row layout which is created once\nconst rowStatesCache = /*#__PURE__*/ new WeakMap<\n GridLayout,\n ReadonlyMap<number, GridRowState>\n>();\n\nconst hasTrackIn = (\n extras: readonly number[],\n from: number,\n to: number,\n pinnedStart: number,\n start: number,\n end: number,\n trailStart: number,\n): boolean => {\n if (\n from < pinnedStart ||\n max(from, start) < min(to, end + 1) ||\n trailStart < to\n ) {\n return true;\n }\n for (const i of extras) {\n if (i >= from && i < to) {\n return true;\n }\n }\n return false;\n};\n\n/**\n * The sections start at the section rows between the pinned rows.\n * @internal\n */\nexport const getSectionStarts = (\n sectionRows: readonly number[],\n pinnedStart: number,\n trailStart: number,\n): number[] => {\n const starts: number[] = [];\n for (const rowIndex of sectionRows) {\n if (rowIndex >= pinnedStart && rowIndex < trailStart) {\n starts.push(rowIndex);\n }\n }\n return sort(starts);\n};\n\n/**\n * The index of the section of the row, or -1. The last section ends at the rows pinned to the end.\n * @internal\n */\nexport const getSectionIndex = (\n starts: readonly number[],\n rowIndex: number,\n trailStart: number,\n): number => {\n if (rowIndex >= trailStart) {\n return -1;\n }\n let lo = 0;\n let hi = starts.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (starts[mid]! <= rowIndex) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n return lo - 1;\n};\n\nconst addSectionHeader = (\n extras: number[],\n sectionStarts: readonly number[],\n rowIndex: number,\n trailStart: number,\n): void => {\n const section = getSectionIndex(sectionStarts, rowIndex, trailStart);\n if (section >= 0) {\n extras.push(sectionStarts[section]!);\n }\n};\n\nconst addExtras = (\n indexes: number[],\n extras: readonly number[],\n e: number,\n bound: number,\n lastRendered: number,\n): number => {\n const extrasLength = extras.length;\n for (; e < extrasLength && extras[e]! < bound; e++) {\n const i = extras[e]!;\n if (i > lastRendered) {\n indexes.push(i);\n lastRendered = i;\n }\n }\n return e;\n};\n\n// The rendered tracks in order: the pinned tracks, the range, and the sorted extras which may repeat or fall in them.\nconst getTrackIndexes = (\n extras: readonly number[],\n count: number,\n pinnedStart: number,\n start: number,\n end: number,\n trailStart: number,\n): number[] => {\n const indexes: number[] = [];\n for (let i = 0; i < pinnedStart; i++) {\n indexes.push(i);\n }\n const e = addExtras(indexes, extras, 0, start, pinnedStart - 1);\n for (let i = start; i <= end; i++) {\n indexes.push(i);\n }\n addExtras(indexes, extras, e, trailStart, end);\n for (let i = trailStart; i < count; i++) {\n indexes.push(i);\n }\n return indexes;\n};\n\nconst getSpanRowEnd = (span: Readonly<GridSpan>, rowCount: number): number =>\n min(span.rowIndex + (span.rowSpan || 1), rowCount);\nconst getSpanColEnd = (span: Readonly<GridSpan>, colCount: number): number =>\n min(span.colIndex + (span.colSpan || 1), colCount);\n\nconst getTemplate = (\n layout: GridLayout,\n indexes: readonly number[],\n measured: readonly (boolean | null)[],\n sortedCuts: readonly number[],\n measuredSize: string,\n count: number,\n): string => {\n const indexesLength = indexes.length;\n const cutsLength = sortedCuts.length;\n // The lines are named by the index, so the cells keep their grid-area while the range moves.\n // https://drafts.csswg.org/css-grid-2/#subgrid-line-name-inheritance\n let template = \"[l0]\";\n let line = 0;\n let i = 0;\n let c = 0;\n // The tracks after the last rendered one extend the scrollable overflow to the end, as the container is not sized on the inline axis.\n // https://drafts.csswg.org/css-overflow-3/#scrollable-overflow-region\n while (line < count) {\n while (c < cutsLength && sortedCuts[c]! <= line) {\n c++;\n }\n const index = i < indexesLength ? indexes[i]! : count;\n let to: number;\n let size: string;\n if (index === line) {\n to = line + 1;\n // The cells in the rows size the max-content tracks of the container.\n // https://drafts.csswg.org/css-grid-2/#subgrid-item-contribution\n // An auto track without a cell measuring it keeps the size of the layout as the min, as the spanning cells don't give the size.\n const m = measured[i];\n size =\n m == NULL\n ? layout.$getItemSize(line) + \"px\"\n : m\n ? measuredSize\n : \"minmax(\" + layout.$getItemSize(line) + \"px,auto)\";\n i++;\n } else {\n // The tracks without rendered cells are merged until the next rendered track or the end of a span.\n to = min(index, c < cutsLength ? sortedCuts[c]! : count);\n // A fixed track this large makes WebKit misplace the cells after one of them is focused, so the size is given as the min.\n size =\n \"minmax(\" +\n (layout.$getItemOffset(to - 1) +\n layout.$getItemSize(to - 1) -\n layout.$getItemOffset(line)) +\n \"px,auto)\";\n }\n template += \" \" + size + \" [l\" + to + \"]\";\n line = to;\n }\n return template;\n};\n\ntype GridCellRole = \"cell\" | \"columnheader\" | \"rowheader\";\n\ntype GridSort = GridCell & {\n order: \"ascending\" | \"descending\" | \"other\";\n};\n\n/**\n * The inline style of an element of the grid, whose keys are the property names in camelCase and whose lengths are in px.\n */\ntype GridStyle = Readonly<Record<string, string | number>>;\n\n/**\n * @internal\n */\nexport const gridStyleToString = (style: GridStyle): string => {\n let css = \"\";\n for (const key in style) {\n css +=\n key.replace(/[A-Z]/g, (c) => \"-\" + c.toLowerCase()) +\n \":\" +\n style[key] +\n \";\";\n }\n return css;\n};\n\n/**\n * @internal\n */\nexport interface GridPlan {\n readonly $rowTemplate: string;\n readonly $colTemplate: string;\n readonly $groups: readonly (GridRowGroupState | GridRowState)[];\n}\n\n/**\n * Creates the templates and the states of the rendered rows and cells. The rows and the cells whose values are unchanged keep the states of the previous plan of the grid, so the components skip them by identity.\n * @internal\n */\nexport const createGridPlan = (\n rowLayout: Readonly<GridLayout>,\n colLayout: Readonly<GridLayout>,\n rowRange: Readonly<ItemsRange>,\n colRange: Readonly<ItemsRange>,\n sectionRows: readonly number[] = EMPTY,\n spans: readonly Readonly<GridSpan>[] = EMPTY,\n kept: readonly Readonly<GridCell>[] = EMPTY,\n sortedCell?: Readonly<GridSort>,\n): GridPlan => {\n const totalRowCount = rowLayout.$getLength();\n const totalColCount = colLayout.$getLength();\n const rowPinnedStart = rowLayout.$getPinnedStart();\n const rowTrailStart = rowLayout.$getTrailStart();\n const colPinnedStart = colLayout.$getPinnedStart();\n const colTrailStart = colLayout.$getTrailStart();\n const rowRangeStart = clamp(rowRange[0], rowPinnedStart, rowTrailStart);\n const rowRangeEnd = min(rowRange[1], rowTrailStart - 1);\n const colRangeStart = clamp(colRange[0], colPinnedStart, colTrailStart);\n const colRangeEnd = min(colRange[1], colTrailStart - 1);\n const sectionStarts = getSectionStarts(\n sectionRows,\n rowPinnedStart,\n rowTrailStart,\n );\n // The header column next to the body labels the rows\n const rowHeaderCol = max(colPinnedStart - 1, 0);\n\n // The headers label the cells, so they are rendered even out of the ranges.\n // https://www.w3.org/TR/wai-aria-1.2/#columnheader\n // https://www.w3.org/TR/wai-aria-1.2/#rowheader\n const extraRows: number[] = [];\n const extraCols: number[] = [];\n // The cells rendered even out of the ranges, which render their rows, the headers of their sections and their columns. A kept cell is a span over itself.\n const extraCells: Readonly<GridSpan>[] = [];\n for (const cell of kept) {\n // A kept cell may be left out of the grid after the rows or the columns are removed.\n if (cell.rowIndex < totalRowCount && cell.colIndex < totalColCount) {\n extraCells.push(cell);\n }\n }\n const sectionLength = sectionStarts.length;\n if (sectionLength) {\n addSectionHeader(extraRows, sectionStarts, rowRangeStart, rowTrailStart);\n extraCols.push(rowHeaderCol);\n }\n // The spans over the rendered tracks are laid. The spans only over the headers wait for the headers rendered for the origins of the laid spans, until no span is laid.\n let waiting = spans;\n let l = 0;\n do {\n for (; l < extraCells.length; l++) {\n const { rowIndex, colIndex } = extraCells[l]!;\n extraRows.push(rowIndex);\n addSectionHeader(extraRows, sectionStarts, rowIndex, rowTrailStart);\n extraCols.push(colIndex);\n }\n const rest: Readonly<GridSpan>[] = [];\n for (const span of waiting) {\n const row = span.rowIndex;\n const col = span.colIndex;\n const rowTo = getSpanRowEnd(span, totalRowCount);\n const colTo = getSpanColEnd(span, totalColCount);\n // A span may be left out of the grid after the rows or the columns are removed.\n if (\n row < totalRowCount &&\n col < totalColCount &&\n (rowTo - row > 1 || colTo - col > 1)\n ) {\n const hasRenderedRow = hasTrackIn(\n extraRows,\n row,\n rowTo,\n rowPinnedStart,\n rowRangeStart,\n rowRangeEnd,\n rowTrailStart,\n );\n if (\n hasRenderedRow &&\n hasTrackIn(\n extraCols,\n col,\n colTo,\n colPinnedStart,\n colRangeStart,\n colRangeEnd,\n colTrailStart,\n )\n ) {\n extraCells.push(span);\n } else if (hasRenderedRow) {\n const section = getSectionIndex(\n sectionStarts,\n rowTo - 1,\n rowTrailStart,\n );\n if (\n row < rowPinnedStart ||\n (section >= 0 && sectionStarts[section]! >= row)\n ) {\n rest.push(span);\n }\n } else if (col < colPinnedStart) {\n rest.push(span);\n }\n }\n }\n waiting = rest;\n } while (l < extraCells.length);\n // The tracks are all known now.\n sort(extraRows);\n sort(extraCols);\n const rows = getTrackIndexes(\n extraRows,\n totalRowCount,\n rowPinnedStart,\n rowRangeStart,\n rowRangeEnd,\n rowTrailStart,\n );\n const cols = getTrackIndexes(\n extraCols,\n totalColCount,\n colPinnedStart,\n colRangeStart,\n colRangeEnd,\n colTrailStart,\n );\n const rowsLength = rows.length;\n const colsLength = cols.length;\n\n // The spans over the cells, whose origins are the cells at their positions\n const spanCells = new Map<number, Readonly<GridSpan>>();\n // The lines at the ends of the spans and the sections are in the templates, as a missing named line is found in the implicit grid.\n // https://drafts.csswg.org/css-grid-2/#grid-placement-int\n const rowCuts: number[] = [];\n const colCuts: number[] = [];\n // The kept cells are before the spans, so a span is over the kept cells under it.\n for (const span of extraCells) {\n const rowTo = getSpanRowEnd(span, totalRowCount);\n const colTo = getSpanColEnd(span, totalColCount);\n rowCuts.push(rowTo);\n colCuts.push(colTo);\n // The tracks are in order, so the covered ones start at the origin of the span.\n const colStart = cols.indexOf(span.colIndex);\n for (\n let i = rows.indexOf(span.rowIndex);\n i < rowsLength && rows[i]! < rowTo;\n i++\n ) {\n const rowKey = rows[i]! * totalColCount;\n for (let j = colStart; j < colsLength && cols[j]! < colTo; j++) {\n spanCells.set(rowKey + cols[j]!, span);\n }\n }\n }\n\n // A track is measured by its first rendered cell which doesn't span over the other tracks, and is null if its size is given.\n const measuredCols: (boolean | null)[] = [];\n for (const colIndex of cols) {\n measuredCols.push(colLayout.$isMeasurable(colIndex) ? false : NULL);\n }\n const measuredRows: (boolean | null)[] = [];\n // The section headers stick where the first row after the pinned rows is laid.\n const sectionHeaderTop = rowLayout.$getItemOffset(rowPinnedStart);\n\n // The rows out of the pinned rows and the sections are not grouped, as Firefox on macOS keeps the stale columns of the table when the rows in a group change.\n const groups: (GridRowGroupState | GridRowState)[] = [];\n let groupRows: (GridRowGroupState | GridRowState)[] = groups;\n const prev = rowStatesCache.get(rowLayout);\n const rowStates = new Map<number, GridRowState>();\n // TODO optimize: the rows and the columns out of the ranges are crossed with each other, which is quadratic for many cells kept far away from each other.\n for (const rowIndex of rows) {\n const isRowPinnedStart = rowIndex < rowPinnedStart;\n const isRowPinnedEnd = rowIndex >= rowTrailStart;\n const isRowInRangeOrPinnedToEnd =\n isRowPinnedEnd || (rowIndex >= rowRangeStart && rowIndex <= rowRangeEnd);\n const section = getSectionIndex(sectionStarts, rowIndex, rowTrailStart);\n // The first row of the group of the row, or -1\n const groupStart = isRowPinnedStart\n ? 0\n : isRowPinnedEnd\n ? rowTrailStart\n : section < 0\n ? -1\n : sectionStarts[section]!;\n // A group starts at its first row, which is rendered whenever the other rows of the group are.\n if (rowIndex === groupStart) {\n const groupEnd = isRowPinnedStart\n ? rowPinnedStart\n : isRowPinnedEnd\n ? totalRowCount\n : // A section ends at the next section which may not be rendered, or at the rows pinned to the end\n section + 1 < sectionLength\n ? sectionStarts[section + 1]!\n : rowTrailStart;\n rowCuts.push(groupEnd);\n const groupedRows: GridRowState[] = [];\n groups.push({\n // The rows pinned to the end keep the key while the rows before them are added or removed\n $key: isRowPinnedStart ? -1 : isRowPinnedEnd ? -2 : -3 - groupStart,\n $rows: groupedRows,\n // The pinned rows at each edge are sticky together over the section headers and the cells of the other rows, so the cells spanning over them are stacked over the next rows as in the other rows.\n $style: getBoxStyle(\n groupStart,\n groupEnd,\n isRowPinnedStart || isRowPinnedEnd ? 0 : NULL,\n isRowPinnedEnd ? \"bottom\" : \"top\",\n 4,\n ),\n });\n groupRows = groupedRows;\n } else if (groupStart < 0) {\n groupRows = groups;\n }\n const isSectionHeaderRow = section >= 0 && rowIndex === groupStart;\n const rowTop = isSectionHeaderRow ? sectionHeaderTop : NULL;\n const rowKey = rowIndex * totalColCount;\n const prevRow = prev && prev.get(rowIndex);\n const prevCells = prevRow && prevRow.$cells;\n const rowCells: GridCellState[] = [];\n // The cells are in the order of the columns, so the previous cell of a column is found by walking them once.\n let p = 0;\n let measuredRow = rowLayout.$isMeasurable(rowIndex) ? false : NULL;\n let rowEnd = rowIndex + 1;\n let hasChanged = false;\n for (let i = 0; i < colsLength; i++) {\n const colIndex = cols[i]!;\n const isColPinnedStart = colIndex < colPinnedStart;\n const isColPinnedEnd = colIndex >= colTrailStart;\n const isColInRangeOrPinnedToEnd =\n isColPinnedEnd ||\n (colIndex >= colRangeStart && colIndex <= colRangeEnd);\n const span = spanCells.get(rowKey + colIndex);\n if (\n span\n ? span.rowIndex === rowIndex && span.colIndex === colIndex\n : (isRowInRangeOrPinnedToEnd && isColInRangeOrPinnedToEnd) ||\n isRowPinnedStart ||\n isSectionHeaderRow ||\n isColPinnedStart\n ) {\n const rowTo = span ? getSpanRowEnd(span, totalRowCount) : rowIndex + 1;\n const colTo = span ? getSpanColEnd(span, totalColCount) : colIndex + 1;\n const rowSpan = rowTo - rowIndex;\n const colSpan = colTo - colIndex;\n const isSpanningRows = rowSpan > 1;\n const isSpanningCols = colSpan > 1;\n const isSpanning = isSpanningRows || isSpanningCols;\n let measureRowIndex: number | undefined;\n let measureColIndex: number | undefined;\n rowEnd = max(rowEnd, rowTo);\n // A sticky box keeps its edges in the scrollport, so the end inset is from the end of the track.\n // https://drafts.csswg.org/css-position-3/#stickypos-insets\n // https://wpt.fyi/results/css/css-position/sticky/position-sticky-grid.html\n const stickyStart = isColPinnedStart\n ? colLayout.$getItemOffset(colIndex)\n : NULL;\n // The end inset of a span is from its last column.\n const stickyEnd = isColPinnedEnd\n ? colLayout.$getTotalSize() -\n colLayout.$getItemOffset(colTo - 1) -\n colLayout.$getItemSize(colTo - 1)\n : NULL;\n if (measuredRow === false && !isSpanningRows) {\n measureRowIndex = rowIndex;\n measuredRow = true;\n }\n if (measuredCols[i] === false && !isSpanningCols) {\n measureColIndex = colIndex;\n measuredCols[i] = true;\n }\n const role: GridCellRole = isRowPinnedStart\n ? \"columnheader\"\n : colIndex === rowHeaderCol &&\n (isColPinnedStart || isSectionHeaderRow)\n ? \"rowheader\"\n : \"cell\";\n // A merged cell gives both spans, 1 on the axis it doesn't span\n // https://www.w3.org/TR/wai-aria-1.2/#aria-rowspan\n // https://www.w3.org/TR/wai-aria-1.2/#aria-colspan\n const ariaRowSpan = isSpanning ? rowSpan : undefined;\n const ariaColSpan = isSpanning ? colSpan : undefined;\n // aria-sort is allowed only on the headers\n // https://www.w3.org/TR/wai-aria-1.2/#aria-sort\n const ariaSort =\n role !== \"cell\" &&\n sortedCell &&\n sortedCell.rowIndex === rowIndex &&\n sortedCell.colIndex === colIndex\n ? sortedCell.order\n : undefined;\n let cell: GridCellState | undefined;\n if (prevCells) {\n const prevCellsLength = prevCells.length;\n while (p < prevCellsLength && prevCells[p]!.$col < colIndex) {\n p++;\n }\n if (p < prevCellsLength && prevCells[p]!.$col === colIndex) {\n cell = prevCells[p];\n }\n }\n if (\n !cell ||\n cell.$rowSpan !== ariaRowSpan ||\n cell.$colSpan !== ariaColSpan ||\n cell.$start !== stickyStart ||\n cell.$end !== stickyEnd ||\n cell.$measureRow !== measureRowIndex ||\n cell.$measureCol !== measureColIndex ||\n cell.$role !== role ||\n cell.$sort !== ariaSort\n ) {\n let gridArea = \"1/l\" + colIndex;\n if (isSpanning) {\n // A span ends at the named line instead of the number of tracks, because the unrendered rows/columns are merged into one track.\n gridArea += \"/l\" + rowTo + \"/l\" + colTo;\n }\n const style: Record<string, string | number> = {\n contain: \"layout style\",\n display: \"grid\",\n gridArea,\n };\n // A spanning cell fills the tracks it spans without giving their sizes.\n // https://drafts.csswg.org/css-sizing-3/#cyclic-percentage-contribution\n // https://drafts.csswg.org/css-grid-2/#min-size-contribution\n if (isSpanningRows) {\n style[\"height\"] = \"0px\";\n style[\"minHeight\"] = \"100%\";\n // Over the rows it spans over, which are painted later\n // https://drafts.csswg.org/css-grid-2/#z-order\n style[\"zIndex\"] = 1;\n }\n if (isSpanningCols) {\n style[\"width\"] = \"0px\";\n style[\"minWidth\"] = \"100%\";\n }\n if (isColPinnedStart || isColPinnedEnd) {\n style[isColPinnedStart ? \"insetInlineStart\" : \"insetInlineEnd\"] =\n (isColPinnedStart ? stickyStart : stickyEnd) + \"px\";\n style[\"position\"] = \"sticky\";\n // Over the spanning cells, which may be painted later\n style[\"zIndex\"] = 2;\n }\n cell = {\n $col: colIndex,\n $rowSpan: ariaRowSpan,\n $colSpan: ariaColSpan,\n $measureRow: measureRowIndex,\n $measureCol: measureColIndex,\n $role: role,\n $sort: ariaSort,\n $style: style,\n $start: stickyStart,\n $end: stickyEnd,\n };\n hasChanged = true;\n }\n rowCells.push(cell);\n }\n }\n // Aligned with rows for the template, so it's pushed before the rows without cells are skipped.\n measuredRows.push(measuredRow);\n if (rowCells.length) {\n // A column rendered anew has no previous cell and marks the row changed, so the lengths tell the columns are the same.\n // A change of the span end changes a cell, so the row end is not compared.\n const row: GridRowState =\n prevRow &&\n !hasChanged &&\n prevRow.$cells.length === rowCells.length &&\n prevRow.$top === rowTop\n ? prevRow\n : {\n $row: rowIndex,\n $cells: rowCells,\n // A subgrid clamps its items to its tracks, so the row spans to the end of its cells.\n // https://drafts.csswg.org/css-grid-2/#subgrid-implicit\n // A section header sticks in the box of its section over the sticky and spanning cells of the other rows, so it's pushed out at the end of the section.\n // https://drafts.csswg.org/css-position-3/#stickypos-insets\n $style: getBoxStyle(rowIndex, rowEnd, rowTop, \"top\", 3),\n $top: rowTop,\n };\n rowStates.set(rowIndex, row);\n groupRows.push(row);\n }\n }\n\n rowStatesCache.set(rowLayout, rowStates);\n\n return {\n $rowTemplate: getTemplate(\n rowLayout,\n rows,\n measuredRows,\n sort(rowCuts),\n \"max-content\",\n totalRowCount,\n ),\n $colTemplate: getTemplate(\n colLayout,\n cols,\n measuredCols,\n sort(colCuts),\n // The auto columns share the space left in the viewport, as the columns of a table.\n // https://drafts.csswg.org/css-grid-2/#algo-stretch\n \"minmax(max-content,auto)\",\n totalColCount,\n ),\n $groups: groups,\n };\n};\n\n// The box of a row or a group of the rows between the lines, which sticks at the inset from the edge if given\nconst getBoxStyle = (\n from: number,\n to: number,\n inset: number | null,\n edge: \"top\" | \"bottom\",\n zIndex: number,\n): GridStyle => {\n const style: Record<string, string | number> = {\n display: \"grid\",\n gridTemplateRows: \"subgrid\",\n gridTemplateColumns: \"subgrid\",\n gridColumn: \"1/-1\",\n gridRow: \"l\" + from + \"/l\" + to,\n };\n if (inset != NULL) {\n style[\"position\"] = \"sticky\";\n style[edge] = inset + \"px\";\n style[\"zIndex\"] = zIndex;\n }\n return style;\n};\n\n/**\n * @internal\n */\nexport interface GridCellState {\n readonly $col: number;\n readonly $rowSpan: number | undefined;\n readonly $colSpan: number | undefined;\n readonly $measureRow: number | undefined;\n readonly $measureCol: number | undefined;\n readonly $role: GridCellRole;\n readonly $sort: GridSort[\"order\"] | undefined;\n readonly $style: GridStyle;\n // The fields below are not rendered. They are in the style, and compared with the next plan to keep the state.\n readonly $start: number | null;\n readonly $end: number | null;\n}\n\n/**\n * @internal\n */\nexport interface GridRowState {\n readonly $row: number;\n readonly $cells: readonly GridCellState[];\n readonly $style: GridStyle;\n // The fields below are not rendered. They are in the style, and compared with the next plan to keep the state.\n readonly $top: number | null;\n}\n\n/**\n * @internal\n */\nexport interface GridRowGroupState {\n // Negative, not to collide with the indexes keying the rows beside the groups\n readonly $key: number;\n readonly $rows: readonly GridRowState[];\n readonly $style: GridStyle;\n}\n","import {\n getCurrentDocument,\n getCurrentWindow,\n isIOSWebKit,\n} from \"./environment.js\";\nimport {\n ACTION_SCROLL,\n type VirtualStore,\n ACTION_SCROLL_END,\n ACTION_START_OFFSET_CHANGE,\n ACTION_MANUAL_SCROLL,\n ACTION_BEFORE_MANUAL_SMOOTH_SCROLL,\n UPDATE_SIZE_EVENT,\n} from \"./store.js\";\nimport { cancelTimeout, microtask, timeout } from \"./utils.js\";\n\n/**\n * @internal\n */\nexport const createResizeObserver = (cb: ResizeObserverCallback) => {\n let ro: ResizeObserver | undefined;\n\n return {\n _observe(e: HTMLElement) {\n // Initialize ResizeObserver lazily for SSR\n // https://www.w3.org/TR/resize-observer/#intro\n (\n ro ||\n // https://bugs.chromium.org/p/chromium/issues/detail?id=1491739\n (ro = new (getCurrentWindow(getCurrentDocument(e)).ResizeObserver)(cb))\n ).observe(e);\n },\n _unobserve(e: HTMLElement) {\n ro!.unobserve(e);\n },\n _dispose() {\n ro && ro.disconnect();\n },\n };\n};\n\n/**\n * @internal\n */\nexport const createScrollObserver = (\n store: VirtualStore,\n viewport: HTMLElement | Window,\n scroller: HTMLElement,\n isHorizontal: boolean,\n isRtl: boolean,\n onMomentumJump?: (() => void) | null,\n getStartOffset?: () => number,\n) => {\n let lastScrollTime = 0;\n let wheeling = false;\n let touching = false;\n let justTouchEnded = false;\n let stillMomentumScrolling = false;\n let cancelScroll: (() => void) | undefined;\n\n let scrollEndTimer: ReturnType<typeof timeout> | undefined;\n\n const now = Date.now;\n const scrollOffsetKey = isHorizontal ? \"scrollLeft\" : \"scrollTop\";\n const scrollToKey = isHorizontal ? \"left\" : \"top\";\n\n /**\n * scrollTop/scrollLeft can be negative value under certain styles.\n * - direction: rtl https://github.com/othree/jquery.rtl-scroll-type\n * - writing-mode https://people.igalia.com/fwang/scrollable-elements-in-non-default-writing-modes/\n * - flex-direction: column-reverse/row-reverse\n *\n * top/left bottom/right\n * 0 100 spec compliant bottom/right overflow, or possibly top/left overflow in Chrome earlier than v85\n * -100 0 spec compliant top/left overflow\n * https://drafts.csswg.org/cssom-view/#scroll-an-element\n */\n const normalizeScrollOffset = (offset: number): number => {\n return isRtl ? -offset : offset;\n };\n\n const getScrollOffset = () =>\n normalizeScrollOffset(scroller[scrollOffsetKey]);\n\n // The given offset will be clamped by browser\n // https://drafts.csswg.org/cssom-view/#dom-element-scrolltop\n const scrollTo = (offset: number, smooth?: boolean) => {\n scroller.scrollTo({\n [scrollToKey]: normalizeScrollOffset(offset),\n behavior: smooth ? \"smooth\" : \"instant\",\n });\n };\n\n // Debounce scroll end detection\n const onScrollEnd = () => {\n if (wheeling || touching) {\n wheeling = false;\n\n // Wait while wheeling or touching\n scheduleScrollEnd();\n return;\n }\n\n justTouchEnded = false;\n\n store.$update(ACTION_SCROLL_END);\n };\n const scheduleScrollEnd = () => {\n cancelTimeout(scrollEndTimer);\n scrollEndTimer = timeout(onScrollEnd, 150);\n };\n\n const onScroll = () => {\n lastScrollTime = now();\n\n if (justTouchEnded) {\n stillMomentumScrolling = true;\n }\n\n if (getStartOffset) {\n store.$update(ACTION_START_OFFSET_CHANGE, getStartOffset());\n }\n store.$update(ACTION_SCROLL, getScrollOffset());\n\n scheduleScrollEnd();\n };\n\n // Infer scroll state also from wheel events\n // Sometimes scroll events do not fire when frame dropped even if the visual have been already scrolled\n const onWheel = ((e: WheelEvent) => {\n if (\n wheeling ||\n // Scroll start should be detected with scroll event\n !store.$isScrolling() ||\n // Probably a pinch-to-zoom gesture\n e.ctrlKey\n ) {\n return;\n }\n\n const timeDelta = now() - lastScrollTime;\n if (\n // Check if wheel event occurs some time after scrolling\n 150 > timeDelta &&\n 50 < timeDelta &&\n // Get delta before checking deltaMode for firefox behavior\n // https://github.com/w3c/uievents/issues/181#issuecomment-392648065\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1392460#c34\n (isHorizontal ? e.deltaX : e.deltaY)\n ) {\n wheeling = true;\n }\n }) as (e: Event) => void; // FIXME type error. why only here?\n\n const onTouchStart = () => {\n touching = true;\n justTouchEnded = stillMomentumScrolling = false;\n };\n const onTouchEnd = () => {\n touching = false;\n if (isIOSWebKit()) {\n justTouchEnded = true;\n }\n };\n\n viewport.addEventListener(\"scroll\", onScroll);\n viewport.addEventListener(\"wheel\", onWheel, { passive: true });\n viewport.addEventListener(\"touchstart\", onTouchStart, { passive: true });\n viewport.addEventListener(\"touchend\", onTouchEnd, { passive: true });\n\n return {\n _dispose: () => {\n viewport.removeEventListener(\"scroll\", onScroll);\n viewport.removeEventListener(\"wheel\", onWheel);\n viewport.removeEventListener(\"touchstart\", onTouchStart);\n viewport.removeEventListener(\"touchend\", onTouchEnd);\n cancelTimeout(scrollEndTimer);\n },\n _fixScrollJump: () => {\n const [jump, shift] = store._flushJump();\n if (!jump) return;\n\n if (stillMomentumScrolling && onMomentumJump) {\n onMomentumJump();\n }\n stillMomentumScrolling = false;\n\n const target = store.$getScrollOffset() + jump;\n if (\n target <= 0 ||\n target >=\n store.$getStartSpacerSize() +\n store.$getTotalSize() -\n store.$getViewportSize()\n ) {\n // Use absolute position at the edges not to exceed scrollable bounds\n // https://github.com/inokawa/virtua/discussions/475\n scrollTo(target);\n } else {\n // Use relative position not to overwrite concurrent scrolling\n // https://github.com/inokawa/virtua/issues/898\n scroller.scrollBy({\n [scrollToKey]: normalizeScrollOffset(jump),\n behavior: \"instant\",\n });\n }\n\n if (shift) {\n // https://github.com/inokawa/virtua/issues/357\n cancelScroll && cancelScroll();\n\n if (store.$getViewportSize() > store.$getTotalSize()) {\n // In this case applying jump may not cause scroll.\n // Current logic expects scroll event occurs after applying jump so we dispatch it manually.\n store.$update(ACTION_SCROLL, getScrollOffset());\n }\n }\n },\n _scroll: (getTargetOffset: () => number, smooth?: boolean) => {\n if (cancelScroll) {\n // Cancel waiting scrollTo\n cancelScroll();\n }\n\n let stopped: boolean | undefined;\n let timerId: ReturnType<typeof timeout> | undefined;\n let unsubscribe: (() => void) | undefined;\n\n // Stopping is kept as a state, not delivered as an event, so it can never be missed by a race with measurement\n // https://github.com/inokawa/virtua/issues/715\n const stop = (cancelScroll = () => {\n stopped = true;\n cancelTimeout(timerId);\n unsubscribe && unsubscribe();\n });\n\n // The scroll destination is not fixed until the items on the way are measured and the timing is not predictable\n const onMeasured = () => {\n if (stopped) {\n return;\n }\n\n // Resize event may not happen when the window/tab is not visible, or during browser back in Safari.\n // We have to wait for the initial measurement to avoid failing imperative scroll on mount.\n // https://github.com/inokawa/virtua/issues/450\n if (store.$getViewportSize()) {\n // Stop when items around scroll destination completely measured\n cancelTimeout(timerId);\n timerId = timeout(stop, 150);\n }\n\n if (smooth) {\n // Smooth scrolling can be started only once, so wait for all the items on the way to be measured.\n for (let [i, end] = store.$getRange(0); i <= end; i++) {\n if (store.$isUnmeasuredItem(i)) {\n return;\n }\n }\n stop();\n }\n\n store.$update(ACTION_MANUAL_SCROLL);\n scrollTo(getTargetOffset(), smooth);\n };\n\n const start = () => {\n if (stopped) {\n return;\n }\n // Batch the measurements in the same task to scroll only once\n let queued: boolean | undefined;\n unsubscribe = store.$subscribe(UPDATE_SIZE_EVENT, () => {\n if (queued) {\n return;\n }\n queued = true;\n microtask(() => {\n queued = false;\n onMeasured();\n });\n });\n onMeasured();\n };\n\n if (smooth) {\n store.$update(ACTION_BEFORE_MANUAL_SMOOTH_SCROLL, getTargetOffset());\n // https://github.com/inokawa/virtua/issues/590\n microtask(start);\n } else {\n start();\n }\n },\n };\n};\n\n/**\n * @internal\n */\nexport type ScrollObserver = ReturnType<typeof createScrollObserver>;\n","import {\n ACTION_ITEM_RESIZE,\n ACTION_VIEWPORT_RESIZE,\n type VirtualStore,\n} from \"./store.js\";\nimport {\n createResizeObserver,\n createScrollObserver,\n type ScrollObserver,\n} from \"./observer.js\";\nimport { type ItemResize } from \"./types.js\";\nimport { createPromise, NULL, timeout } from \"./utils.js\";\nimport { getCurrentDocument, getCurrentWindow } from \"./environment.js\";\n\n/**\n * @internal\n */\nexport interface Driver {\n $observe(containerElement: HTMLElement, viewport?: HTMLElement): void;\n $dispose(): void;\n $observeItem(el: HTMLElement, index: number): () => void;\n $scroll(getTargetOffset: () => number, smooth?: boolean): void;\n $effect(): void;\n $getBaseOffset(): number;\n}\n\n/**\n * @internal\n */\nexport type DriverFactory = (\n store: VirtualStore,\n isHorizontal: boolean,\n) => Driver;\n\n/**\n * @internal\n */\nexport const createContainerDriver: DriverFactory = (store, isHorizontal) => {\n let viewportElement: HTMLElement | undefined;\n let scrollObserver: ScrollObserver | undefined;\n let initialized = createPromise<boolean>();\n\n const mountedIndexes = new WeakMap<Element, number>();\n\n const resizeObserver = createResizeObserver((entries) => {\n const resizes: ItemResize[] = [];\n for (const {\n target,\n contentRect: { width, height },\n } of entries) {\n if (target === viewportElement) {\n // https://github.com/inokawa/virtua/issues/964\n if (width || height) {\n store.$update(ACTION_VIEWPORT_RESIZE, isHorizontal ? width : height);\n }\n // Skip zero-sized rects that may be observed under `display: none` style\n } else if ((target as HTMLElement).offsetParent) {\n const index = mountedIndexes.get(target);\n if (index != NULL) {\n resizes.push([index, isHorizontal ? width : height]);\n }\n }\n }\n\n if (resizes.length) {\n store.$update(ACTION_ITEM_RESIZE, resizes);\n }\n });\n\n return {\n $observe(containerElement, viewport = containerElement.parentElement!) {\n resizeObserver._observe((viewportElement = viewport));\n\n scrollObserver = createScrollObserver(\n store,\n viewport,\n viewport,\n isHorizontal,\n isHorizontal && getComputedStyle(viewport).direction === \"rtl\",\n () => {\n const overflowKey = isHorizontal ? \"overflowX\" : \"overflowY\";\n // If we update scroll position while touching on iOS, the position will be reverted.\n // However iOS WebKit fires touch events only once at the beginning of momentum scrolling.\n // That means we have no reliable way to confirm still touched or not if user touches more than once during momentum scrolling...\n // This is a hack for the suspectable situations, inspired by https://github.com/prud/ios-overflow-scroll-to-top\n const style = viewport.style;\n const prev = style[overflowKey];\n style[overflowKey] = \"hidden\";\n timeout(() => {\n style[overflowKey] = prev;\n });\n },\n );\n\n initialized[1](true);\n },\n $dispose() {\n resizeObserver._dispose();\n scrollObserver && scrollObserver._dispose();\n initialized[1](false);\n // https://github.com/inokawa/virtua/pull/765\n initialized = createPromise();\n },\n $observeItem(el, index) {\n mountedIndexes.set(el, index);\n resizeObserver._observe(el);\n return () => {\n mountedIndexes.delete(el);\n resizeObserver._unobserve(el);\n };\n },\n async $scroll(getTargetOffset, smooth) {\n // Wait for element assign. The element may be undefined if scrollRef prop is used and scroll is scheduled on mount.\n // https://github.com/inokawa/virtua/pull/733\n // https://github.com/inokawa/virtua/pull/750\n if (await initialized[0]) {\n scrollObserver!._scroll(getTargetOffset, smooth);\n }\n },\n $effect() {\n scrollObserver && scrollObserver._fixScrollJump();\n },\n $getBaseOffset: store.$getStartSpacerSize,\n };\n};\n\n/**\n * @internal\n */\nexport const createWindowDriver: DriverFactory = (store, isHorizontal) => {\n let viewportElement: HTMLElement | undefined;\n let scrollObserver: ScrollObserver | undefined;\n let cleanupOnWindowResize: (() => void) | undefined;\n let getBaseOffset: (() => number) | undefined;\n let onViewportResize: (() => void) | undefined;\n let initialized = createPromise<boolean>();\n\n const mountedIndexes = new WeakMap<Element, number>();\n\n const resizeObserver = createResizeObserver((entries) => {\n const resizes: ItemResize[] = [];\n for (const {\n target,\n contentRect: { width, height },\n } of entries) {\n if (target === viewportElement) {\n // Scrollbar appearance/disappearance changes client size without firing window resize events\n onViewportResize && onViewportResize();\n // Skip zero-sized rects that may be observed under `display: none` style\n } else if ((target as HTMLElement).offsetParent) {\n const index = mountedIndexes.get(target);\n if (index != NULL) {\n resizes.push([index, isHorizontal ? width : height]);\n }\n }\n }\n\n if (resizes.length) {\n store.$update(ACTION_ITEM_RESIZE, resizes);\n }\n });\n\n return {\n $observe(container) {\n const document = getCurrentDocument(container);\n const window = getCurrentWindow(document);\n const viewport = (viewportElement =\n document.scrollingElement! as HTMLElement);\n // Detect RTL document\n const isRtl =\n isHorizontal && getComputedStyle(viewport).direction === \"rtl\";\n\n const calcOffsetToViewport = (\n node: HTMLElement,\n viewport: HTMLElement,\n until: HTMLElement,\n isHorizontal: boolean,\n offset: number = 0,\n ): number => {\n // TODO calc offset only when it changes (maybe impossible)\n const offsetKey = isHorizontal ? \"offsetLeft\" : \"offsetTop\";\n const offsetSum =\n offset +\n (isRtl\n ? viewport.clientWidth - node[offsetKey] - node.offsetWidth\n : node[offsetKey]);\n\n const parent = node.offsetParent;\n if (node === until || !parent) {\n return offsetSum;\n }\n\n return calcOffsetToViewport(\n parent as HTMLElement,\n viewport,\n until,\n isHorizontal,\n offsetSum,\n );\n };\n\n const baseOffset = (getBaseOffset = () => {\n return calcOffsetToViewport(\n container,\n viewport,\n document.body,\n isHorizontal,\n );\n });\n\n const onWindowResize = (onViewportResize = () => {\n store.$update(\n ACTION_VIEWPORT_RESIZE,\n viewport[isHorizontal ? \"clientWidth\" : \"clientHeight\"],\n );\n });\n window.addEventListener(\"resize\", onWindowResize);\n\n // https://github.com/inokawa/virtua/issues/792\n resizeObserver._observe(viewport);\n\n cleanupOnWindowResize = () => {\n window.removeEventListener(\"resize\", onWindowResize);\n };\n\n // TODO support case two window scrollers exist in the same view\n scrollObserver = createScrollObserver(\n store,\n window,\n viewport,\n isHorizontal,\n isRtl,\n NULL,\n baseOffset,\n );\n\n initialized[1](true);\n },\n $dispose() {\n cleanupOnWindowResize && cleanupOnWindowResize();\n resizeObserver._dispose();\n scrollObserver && scrollObserver._dispose();\n initialized[1](false);\n // https://github.com/inokawa/virtua/pull/765\n initialized = createPromise();\n },\n $observeItem(el, index) {\n mountedIndexes.set(el, index);\n resizeObserver._observe(el);\n return () => {\n mountedIndexes.delete(el);\n resizeObserver._unobserve(el);\n };\n },\n async $scroll(getTargetOffset, smooth) {\n // Wait for element assign. The element may be undefined if scroll is scheduled on mount.\n // https://github.com/inokawa/virtua/pull/733\n // https://github.com/inokawa/virtua/pull/750\n if (await initialized[0]) {\n scrollObserver!._scroll(getTargetOffset, smooth);\n }\n },\n $effect() {\n scrollObserver && scrollObserver._fixScrollJump();\n },\n $getBaseOffset() {\n // Calculate target scroll position including container's offset from document\n return getBaseOffset!();\n },\n };\n};\n\n/**\n * @internal\n */\nexport type GridDriver = {\n $scroll(isHorizontal: boolean, getTargetOffset: () => number): void;\n $observe(containerElement: HTMLElement): void;\n $dispose(): void;\n $observeItem(\n el: HTMLElement,\n rowIndex: number | undefined,\n colIndex: number | undefined,\n ): () => void;\n $effect(): void;\n};\n\n/**\n * @internal\n */\nexport const createContainerGridDriver = (\n rowStore: VirtualStore,\n colStore: VirtualStore,\n): GridDriver => {\n let viewportElement: HTMLElement | undefined;\n let rowScrollObserver: ScrollObserver | undefined;\n let colScrollObserver: ScrollObserver | undefined;\n let initialized = createPromise<boolean>();\n\n const mountedRowIndexes = new WeakMap<Element, number>();\n const mountedColIndexes = new WeakMap<Element, number>();\n\n const resizeObserver = createResizeObserver((entries) => {\n const rowResizes: ItemResize[] = [];\n const colResizes: ItemResize[] = [];\n for (const {\n target,\n contentRect: { width, height },\n } of entries) {\n if (target === viewportElement) {\n // https://github.com/inokawa/virtua/issues/964\n if (width || height) {\n rowStore.$update(ACTION_VIEWPORT_RESIZE, height);\n colStore.$update(ACTION_VIEWPORT_RESIZE, width);\n }\n // Skip zero-sized rects that may be observed under `display: none` style\n } else if ((target as HTMLElement).offsetParent) {\n const rowIndex = mountedRowIndexes.get(target);\n const colIndex = mountedColIndexes.get(target);\n if (rowIndex != NULL) {\n rowResizes.push([rowIndex, height]);\n }\n if (colIndex != NULL) {\n colResizes.push([colIndex, width]);\n }\n }\n }\n\n if (rowResizes.length) {\n rowStore.$update(ACTION_ITEM_RESIZE, rowResizes);\n }\n if (colResizes.length) {\n colStore.$update(ACTION_ITEM_RESIZE, colResizes);\n }\n });\n\n return {\n async $scroll(isHorizontal, getTargetOffset) {\n // Wait for element assign. The element may be undefined if scroll is scheduled on mount.\n // https://github.com/inokawa/virtua/pull/733\n // https://github.com/inokawa/virtua/pull/750\n if (await initialized[0]) {\n (isHorizontal ? colScrollObserver : rowScrollObserver)!._scroll(\n getTargetOffset,\n );\n }\n },\n $observe(containerElement) {\n const viewport = (viewportElement = containerElement.parentElement!);\n resizeObserver._observe(viewport);\n\n const observe = (store: VirtualStore, isHorizontal: boolean) =>\n createScrollObserver(\n store,\n viewport,\n viewport,\n isHorizontal,\n isHorizontal && getComputedStyle(viewport).direction === \"rtl\",\n () => {\n const overflowKey = isHorizontal ? \"overflowX\" : \"overflowY\";\n // If we update scroll position while touching on iOS, the position will be reverted.\n // However iOS WebKit fires touch events only once at the beginning of momentum scrolling.\n // That means we have no reliable way to confirm still touched or not if user touches more than once during momentum scrolling...\n // This is a hack for the suspectable situations, inspired by https://github.com/prud/ios-overflow-scroll-to-top\n const style = viewport.style;\n const prev = style[overflowKey];\n style[overflowKey] = \"hidden\";\n timeout(() => {\n style[overflowKey] = prev;\n });\n },\n );\n rowScrollObserver = observe(rowStore, false);\n colScrollObserver = observe(colStore, true);\n\n initialized[1](true);\n },\n $dispose() {\n resizeObserver._dispose();\n rowScrollObserver && rowScrollObserver._dispose();\n colScrollObserver && colScrollObserver._dispose();\n initialized[1](false);\n // https://github.com/inokawa/virtua/pull/765\n initialized = createPromise();\n },\n $observeItem(el, rowIndex, colIndex) {\n // An undefined index skips reporting the size of that axis, for cells whose row/column size is given instead of measured.\n if (rowIndex != NULL) {\n mountedRowIndexes.set(el, rowIndex);\n }\n if (colIndex != NULL) {\n mountedColIndexes.set(el, colIndex);\n }\n resizeObserver._observe(el);\n return () => {\n mountedRowIndexes.delete(el);\n mountedColIndexes.delete(el);\n resizeObserver._unobserve(el);\n };\n },\n $effect() {\n rowScrollObserver && rowScrollObserver._fixScrollJump();\n colScrollObserver && colScrollObserver._fixScrollJump();\n },\n };\n};\n","import { type VirtualStore } from \"./store.js\";\nimport { clamp, EMPTY, max, min, NULL } from \"./utils.js\";\nimport { type Driver, type GridDriver } from \"./driver.js\";\nimport { getSectionIndex, getSectionStarts } from \"./grid.js\";\nimport { type GridLayout } from \"./layouts/grid.js\";\n\n/**\n * Alignment of item in the viewport.\n *\n * - `start`: Align the item to the start.\n * - `center`: Align the item to the center.\n * - `end`: Align the item to the end.\n * - `nearest`: If the item is already completely visible, don't scroll. Otherwise scroll until it becomes visible. That is similar behavior to [`nearest` option of scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView).\n */\nexport type ScrollToIndexAlign = \"start\" | \"center\" | \"end\" | \"nearest\";\n\nexport interface ScrollToIndexOpts {\n /**\n * Alignment of item in the viewport. See {@link ScrollToIndexAlign} for the values.\n * @defaultValue \"start\"\n */\n align?: ScrollToIndexAlign;\n /**\n * If true, scrolling animates smoothly with [`behavior: smooth` of scrollTo](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo#behavior).\n *\n * **Using smooth scrolling over many items can kill performance benefit of virtual scroll. Do not overuse it.**\n */\n smooth?: boolean;\n /**\n * Additional offset from the scrolled position.\n * @defaultValue 0\n */\n offset?: number;\n}\n\n/**\n * The cell to scroll to and the options of the scroll. The axis whose index is omitted is not scrolled.\n */\nexport interface GridScrollToIndexOpts {\n /**\n * The row index of the cell.\n */\n rowIndex?: number;\n /**\n * The column index of the cell.\n */\n colIndex?: number;\n /**\n * Alignment of the cell in the viewport, excluding the rows sticking over it. See {@link ScrollToIndexAlign} for the values.\n * @defaultValue \"start\"\n */\n rowAlign?: ScrollToIndexAlign;\n /**\n * Alignment of the cell in the viewport, excluding the columns sticking over it. See {@link ScrollToIndexAlign} for the values.\n * @defaultValue \"start\"\n */\n colAlign?: ScrollToIndexAlign;\n}\n\n/**\n * @internal\n */\nexport const scrollTo = (driver: Driver, offset: number) => {\n driver.$scroll(() => offset);\n};\n\n/**\n * @internal\n */\nexport const scrollBy = (\n driver: Driver,\n store: VirtualStore,\n offset: number,\n) => {\n scrollTo(driver, offset + store.$getScrollOffset());\n};\n\n/**\n * @internal\n */\nexport const scrollToIndex = (\n driver: Driver,\n store: VirtualStore,\n index: number,\n { align, smooth, offset = 0 }: ScrollToIndexOpts = {},\n) => {\n index = clamp(index, 0, store.$getItemsLength() - 1);\n\n if (align === \"nearest\") {\n const itemOffset = store.$getItemOffset(index);\n const scrollOffset = store.$getScrollOffset();\n\n if (itemOffset < scrollOffset) {\n align = \"start\";\n } else if (\n itemOffset + store.$getItemSize(index) >\n scrollOffset + store.$getViewportSize()\n ) {\n align = \"end\";\n } else {\n // already completely visible\n return;\n }\n }\n\n driver.$scroll(() => {\n return (\n offset +\n driver.$getBaseOffset() +\n store.$getItemOffset(index) +\n (align === \"end\"\n ? store.$getItemSize(index) - store.$getViewportSize()\n : align === \"center\"\n ? (store.$getItemSize(index) - store.$getViewportSize()) / 2\n : 0)\n );\n }, smooth);\n};\n\n/**\n * @internal\n */\nexport const gridScrollTo = (\n driver: GridDriver,\n vertical: number | undefined,\n horizontal: number | undefined,\n) => {\n if (vertical != NULL) {\n driver.$scroll(false, () => vertical);\n }\n if (horizontal != NULL) {\n driver.$scroll(true, () => horizontal);\n }\n};\n\n/**\n * @internal\n */\nexport const gridScrollBy = (\n driver: GridDriver,\n rowStore: VirtualStore,\n colStore: VirtualStore,\n vertical: number | undefined,\n horizontal: number | undefined,\n) => {\n if (vertical != NULL) {\n const offset = vertical + rowStore.$getScrollOffset();\n driver.$scroll(false, () => offset);\n }\n if (horizontal != NULL) {\n const offset = horizontal + colStore.$getScrollOffset();\n driver.$scroll(true, () => offset);\n }\n};\n\nconst scrollGridAxisToIndex = (\n driver: GridDriver,\n store: VirtualStore,\n layout: GridLayout,\n sections: readonly number[],\n index: number,\n align: ScrollToIndexAlign | undefined,\n isHorizontal: boolean,\n) => {\n const count = store.$getItemsLength();\n const pinnedStart = layout.$getPinnedStart();\n const trailStart = layout.$getTrailStart();\n index = clamp(index, 0, count - 1);\n const starts = getSectionStarts(sections, pinnedStart, trailStart);\n const section = getSectionIndex(starts, index, trailStart);\n const sectionHeader = section < 0 ? -1 : starts[section]!;\n // Read when scrolling, as the pinned items may be measured after the call.\n // The header of the section of the item sticks under the pinned items, so the item is below it unless it's the header itself.\n const getInsetStart = (): number =>\n layout.$getItemOffset(pinnedStart) +\n (sectionHeader < 0 || sectionHeader === index\n ? 0\n : store.$getItemOffset(sectionHeader + 1) -\n store.$getItemOffset(sectionHeader));\n const getInsetEnd = (): number =>\n layout.$getItemOffset(count) - layout.$getItemOffset(trailStart);\n\n if (align === \"nearest\") {\n if (index < pinnedStart || index >= trailStart) {\n // A pinned item is always visible\n return;\n }\n const insetStart = getInsetStart();\n const scrollOffset = store.$getScrollOffset() + insetStart;\n const viewportSize = store.$getViewportSize() - insetStart - getInsetEnd();\n const itemSize = store.$getItemSize(index);\n let itemOffset = store.$getItemOffset(index);\n if (sectionHeader === index) {\n // A section header is where it sticks, until the end of its section pushes it out\n const lastIndex =\n (section + 1 < starts.length ? starts[section + 1]! : trailStart) - 1;\n itemOffset = max(\n itemOffset,\n min(\n scrollOffset,\n store.$getItemOffset(lastIndex) +\n store.$getItemSize(lastIndex) -\n itemSize,\n ),\n );\n }\n if (itemOffset < scrollOffset) {\n align = \"start\";\n } else if (itemOffset + itemSize > scrollOffset + viewportSize) {\n align = \"end\";\n } else {\n return;\n }\n }\n\n driver.$scroll(isHorizontal, () => {\n const insetStart = getInsetStart();\n const rest =\n store.$getItemSize(index) -\n (store.$getViewportSize() - insetStart - getInsetEnd());\n return (\n store.$getItemOffset(index) -\n insetStart +\n (align === \"end\" ? rest : align === \"center\" ? rest / 2 : 0)\n );\n });\n};\n\n/**\n * @internal\n */\nexport const gridScrollToIndex = (\n driver: GridDriver,\n rowStore: VirtualStore,\n colStore: VirtualStore,\n rowLayout: GridLayout,\n colLayout: GridLayout,\n sectionRows: readonly number[] = EMPTY,\n { rowIndex, colIndex, rowAlign, colAlign }: GridScrollToIndexOpts,\n) => {\n // TODO support smooth scroll, removed because scrolling both axes smoothly freezes their ranges and the page\n if (rowIndex != NULL) {\n scrollGridAxisToIndex(\n driver,\n rowStore,\n rowLayout,\n sectionRows,\n rowIndex,\n rowAlign,\n false,\n );\n }\n if (colIndex != NULL) {\n scrollGridAxisToIndex(\n driver,\n colStore,\n colLayout,\n EMPTY,\n colIndex,\n colAlign,\n true,\n );\n }\n};\n","/** @jsxImportSource vue */\nimport {\n ref,\n defineComponent,\n watch,\n type StyleValue,\n type VNode,\n type NativeElements,\n computed,\n type Ref,\n} from \"vue\";\nimport {\n type Driver,\n type StateVersion,\n type VirtualStore,\n} from \"../core/index.js\";\nimport { type ItemProps } from \"./utils.js\";\n\ninterface ListItemProps {\n _stateVersion: Ref<StateVersion>;\n _store: VirtualStore;\n _slot: (arg: { item: unknown; index: number }) => VNode[];\n _item: unknown;\n _resizer: Driver[\"$observeItem\"];\n _index: number;\n _isHorizontal: boolean;\n _isSSR: boolean;\n _as: keyof NativeElements;\n _itemProps?: ItemProps;\n}\n\n/**\n * @internal\n */\nexport const ListItem = /*#__PURE__*/ defineComponent(\n (props: ListItemProps) => {\n const elementRef = ref<HTMLDivElement>();\n\n const offset = computed(\n () =>\n props._stateVersion.value && props._store.$getItemOffset(props._index),\n );\n const hide = computed(\n () =>\n props._stateVersion.value &&\n props._store.$isUnmeasuredItem(props._index),\n );\n const children = computed(() =>\n props._slot({ item: props._item, index: props._index }),\n );\n\n // The index may be changed if elements are inserted to or removed from the start of props.children\n watch(\n () => elementRef.value && props._index,\n (_, __, onCleanup) => {\n onCleanup(props._resizer(elementRef.value!, props._index));\n },\n {\n flush: \"post\",\n },\n );\n\n return () => {\n const {\n _isHorizontal: isHorizontal,\n _isSSR: isSSR,\n _as: Element,\n _index: index,\n _item: item,\n } = props;\n const isHide = hide.value;\n\n const { style: styleProp, ...rest } =\n props._itemProps?.({ item, index }) || {};\n\n const style: StyleValue = {\n contain: \"layout style\",\n position: isHide && isSSR ? undefined : \"absolute\",\n [isHorizontal ? \"height\" : \"width\"]: \"100%\",\n [isHorizontal ? \"top\" : \"left\"]: \"0px\",\n [isHorizontal ? \"insetInlineStart\" : \"top\"]: offset.value + \"px\",\n visibility: !isHide || isSSR ? undefined : \"hidden\",\n ...styleProp,\n };\n if (isHorizontal) {\n style.display = \"inline-flex\";\n }\n\n return (\n <Element ref={elementRef} style={style} {...rest}>\n {children.value}\n </Element>\n );\n };\n },\n {\n // Required to split props from attrs. Object form keeps the keys manglable.\n props: {\n _stateVersion: null,\n _store: null,\n _slot: null,\n _item: null,\n _resizer: null,\n _index: null,\n _isHorizontal: null,\n _isSSR: null,\n _as: null,\n _itemProps: null,\n } satisfies Record<keyof ListItemProps, null>,\n },\n);\n","import { type CSSProperties, type VNode } from \"vue\";\nimport { type ItemsRange } from \"../core/index.js\";\n\n/**\n * @internal\n */\nexport const getKey = (e: VNode[], i: number): Exclude<VNode[\"key\"], null> => {\n // https://github.com/inokawa/virtua/pull/846\n if (e.length === 1) {\n const key = e[0]!.key;\n if (key != null) {\n return key;\n }\n }\n return \"_\" + i;\n};\n\n/**\n * @internal\n */\nexport const isSameRange = (prev: ItemsRange, next: ItemsRange): boolean => {\n return prev[0] === next[0] && prev[1] === next[1];\n};\n\nexport type ItemProps<T = unknown> = (payload: {\n item: T;\n index: number;\n}) => { [key: string]: any; style?: CSSProperties; class?: string } | undefined;\n","/** @jsxImportSource vue */\nimport {\n ref,\n onMounted,\n defineComponent,\n onUnmounted,\n type VNode,\n watch,\n type PublicProps,\n type PropType,\n type NativeElements,\n computed,\n} from \"vue\";\nimport {\n UPDATE_SCROLL_EVENT,\n UPDATE_SCROLL_END_EVENT,\n UPDATE_VIRTUAL_STATE,\n createVirtualStore,\n createListLayout,\n ACTION_ITEMS_LENGTH_CHANGE,\n getScrollSize,\n ACTION_START_OFFSET_CHANGE,\n createContainerDriver,\n scrollTo,\n scrollBy,\n scrollToIndex,\n type ItemsRange,\n type ScrollToIndexOpts,\n sort,\n type CacheSnapshot,\n} from \"../core/index.js\";\nimport { ListItem } from \"./ListItem.js\";\nimport { getKey, isSameRange, type ItemProps } from \"./utils.js\";\n\n/**\n * Props of {@link Virtualizer}.\n */\nexport interface VirtualizerProps<T = unknown> extends PublicProps {\n /**\n * The data items rendered by this component.\n */\n data: T[];\n /**\n * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.\n * @defaultValue 200\n */\n bufferSize?: number;\n /**\n * Item size hint for unmeasured items in pixels. It will help to reduce scroll jump when items are measured if used properly.\n *\n * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.\n * - If set, you can opt out estimation and use the value as initial item size.\n */\n itemSize?: number;\n /**\n * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.\n */\n shift?: boolean;\n /**\n * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.\n */\n horizontal?: boolean;\n /**\n * The offset to the scrollable parent before virtualizer in pixels. If you put an element before virtualizer, you have to set its height to this prop.\n */\n startMargin?: number;\n /**\n * A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated. The minimum value is 0.\n */\n ssrCount?: number;\n /**\n * Reference to the scrollable element. The default will get the direct parent element of virtualizer.\n */\n scrollRef?: HTMLElement;\n /**\n * Component or element type for container element.\n * @defaultValue \"div\"\n */\n as?: keyof NativeElements;\n /**\n * Component or element type for item element.\n * @defaultValue \"div\"\n */\n item?: keyof NativeElements;\n /**\n * A function that provides properties/attributes for item element\n *\n * **This prop will be merged into `item` prop in the future**\n */\n itemProps?: ItemProps<T>;\n /**\n * List of indexes that should be always mounted, even when off screen.\n */\n keepMounted?: readonly number[];\n /**\n * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link VirtualizerHandle.cache}.\n *\n * **The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.**\n */\n cache?: CacheSnapshot;\n /**\n * Callback invoked whenever scroll offset changes.\n * @param offset Current scrollTop, or scrollLeft if horizontal: true.\n */\n onScroll?: (offset: number) => void;\n /**\n * Callback invoked when scrolling stops.\n */\n onScrollEnd?: () => void;\n}\n\ninterface VirtualizerInstance<T = unknown> extends VirtualizerHandle {\n $props: VirtualizerProps<T>;\n $slots: { default: (arg: { item: T; index: number }) => VNode[] };\n}\n\n/**\n * Methods of {@link Virtualizer}.\n */\nexport interface VirtualizerHandle {\n /**\n * Get current {@link CacheSnapshot}.\n */\n readonly cache: CacheSnapshot;\n /**\n * Get current scrollTop, or scrollLeft if horizontal: true. Always positive even in RTL.\n */\n readonly scrollOffset: number;\n /**\n * Get current scrollHeight, or scrollWidth if horizontal: true.\n */\n readonly scrollSize: number;\n /**\n * Get current clientHeight, or clientWidth if horizontal: true.\n */\n readonly viewportSize: number;\n /**\n * Find nearest item index from offset.\n * @param offset offset in pixels from the start of the scroll container\n */\n findItemIndex(offset: number): number;\n /**\n * Get item offset from start.\n * @param index index of item\n */\n getItemOffset(index: number): number;\n /**\n * Get item size.\n * @param index index of item\n */\n getItemSize(index: number): number;\n /**\n * Scroll to the item specified by index.\n * @param index index of item\n * @param opts options\n */\n scrollToIndex(index: number, opts?: ScrollToIndexOpts): void;\n /**\n * Scroll to the given offset.\n * @param offset offset from start\n */\n scrollTo(offset: number): void;\n /**\n * Scroll by the given offset.\n * @param offset offset from current position\n */\n scrollBy(offset: number): void;\n}\n\n/**\n * Customizable list virtualizer for advanced usage. See {@link VirtualizerProps} and {@link VirtualizerHandle}.\n */\nexport const Virtualizer = /*#__PURE__*/ defineComponent({\n props: {\n data: { type: Array, required: true },\n bufferSize: Number,\n itemSize: Number,\n shift: Boolean,\n horizontal: Boolean,\n startMargin: { type: Number, default: 0 },\n ssrCount: Number,\n scrollRef: Object as PropType<VirtualizerProps[\"scrollRef\"]>,\n as: { type: String as PropType<VirtualizerProps[\"as\"]>, default: \"div\" },\n item: {\n type: String as PropType<VirtualizerProps[\"item\"]>,\n default: \"div\",\n },\n itemProps: Function as PropType<VirtualizerProps[\"itemProps\"]>,\n keepMounted: Array as PropType<VirtualizerProps[\"keepMounted\"]>,\n cache: Object as PropType<VirtualizerProps[\"cache\"]>,\n },\n emits: [\"scroll\", \"scrollEnd\"],\n setup(props, { emit, expose, slots }) {\n let isSSR = !!props.ssrCount;\n\n const isHorizontal = props.horizontal;\n const containerRef = ref<HTMLDivElement>();\n const layout = createListLayout(\n props.data.length,\n props.itemSize,\n props.cache,\n );\n const store = createVirtualStore(layout, props.ssrCount);\n const driver = createContainerDriver(store, isHorizontal);\n\n const stateVersion = ref(store.$getStateVersion());\n store.$subscribe(UPDATE_VIRTUAL_STATE, () => {\n stateVersion.value = store.$getStateVersion();\n });\n store.$subscribe(UPDATE_SCROLL_EVENT, () => {\n emit(\"scroll\", store.$getScrollOffset());\n });\n store.$subscribe(UPDATE_SCROLL_END_EVENT, () => {\n emit(\"scrollEnd\");\n });\n\n const range = computed<ItemsRange>((prev) => {\n stateVersion.value;\n const next = store.$getRange(props.bufferSize);\n if (prev && isSameRange(prev, next)) {\n return prev;\n }\n return next;\n });\n const isScrolling = computed(\n () => stateVersion.value && store.$isScrolling(),\n );\n const totalSize = computed(\n () => stateVersion.value && store.$getTotalSize(),\n );\n\n onMounted(() => {\n isSSR = false;\n\n // https://github.com/inokawa/virtua/issues/784\n const container = containerRef.value!;\n const raf = requestAnimationFrame(() => {\n // parent's ref doesn't exist when onMounted is called\n driver.$observe(container, props.scrollRef);\n });\n\n onUnmounted(() => {\n cancelAnimationFrame(raf);\n });\n });\n onUnmounted(() => {\n store.$dispose();\n driver.$dispose();\n });\n\n watch(\n () => props.data.length,\n (count) => {\n store.$update(ACTION_ITEMS_LENGTH_CHANGE, [count, props.shift]);\n },\n );\n watch(\n () => props.startMargin,\n (value) => {\n store.$update(ACTION_START_OFFSET_CHANGE, value);\n },\n { immediate: true },\n );\n\n watch(\n [stateVersion],\n () => {\n driver.$effect();\n },\n { flush: \"post\" },\n );\n\n expose({\n get cache() {\n return layout.$snapshot();\n },\n get scrollOffset() {\n return store.$getScrollOffset();\n },\n get scrollSize() {\n return getScrollSize(store);\n },\n get viewportSize() {\n return store.$getViewportSize();\n },\n findItemIndex: store.$findItemIndex,\n getItemOffset: store.$getItemOffset,\n getItemSize: store.$getItemSize,\n scrollToIndex: (index, opts) => scrollToIndex(driver, store, index, opts),\n scrollTo: (offset) => scrollTo(driver, offset),\n scrollBy: (offset) => scrollBy(driver, store, offset),\n } satisfies VirtualizerHandle);\n\n return () => {\n const Element = props.as;\n const ItemElement = props.item;\n\n const total = totalSize.value;\n\n const items: VNode[] = [];\n\n const renderItem = (i: number) => {\n const e = slots[\"default\"]!({ item: props.data![i]!, index: i });\n return (\n <ListItem\n key={getKey(e, i)}\n _stateVersion={stateVersion}\n _store={store}\n _resizer={driver.$observeItem}\n _index={i}\n _slot={slots[\"default\"]!}\n _item={props.data![i]!}\n _isHorizontal={isHorizontal}\n _isSSR={isSSR}\n _as={ItemElement}\n _itemProps={props.itemProps}\n />\n );\n };\n\n if (props.keepMounted) {\n const len = props.data.length;\n const mounted = new Set(props.keepMounted);\n for (let [i, j] = range.value; i <= j; i++) {\n mounted.add(i);\n }\n sort([...mounted]).forEach((index) => {\n if (index < len) {\n items.push(renderItem(index));\n }\n });\n } else {\n for (let [i, j] = range.value; i <= j; i++) {\n items.push(renderItem(i));\n }\n }\n\n return (\n <Element\n ref={containerRef}\n style={{\n contain: \"size style\", // https://github.com/inokawa/virtua/pull/775 https://github.com/inokawa/virtua/issues/800\n overflowAnchor: \"none\", // opt out browser's scroll anchoring because it will conflict to scroll anchoring of virtualizer\n flex: \"none\", // flex style can break layout\n position: \"relative\",\n width: isHorizontal ? total + \"px\" : \"100%\",\n height: isHorizontal ? \"100%\" : total + \"px\",\n pointerEvents: isScrolling.value ? \"none\" : undefined,\n }}\n >\n {items}\n </Element>\n );\n };\n },\n}) as unknown as {\n new <T = unknown>(props: VirtualizerProps<T>): VirtualizerInstance<T>;\n};\n","/** @jsxImportSource vue */\nimport {\n defineComponent,\n ref,\n type VNode,\n type PropType,\n type PublicProps,\n} from \"vue\";\nimport {\n Virtualizer,\n VirtualizerProps,\n type VirtualizerHandle,\n} from \"./Virtualizer.js\";\n\n/**\n * Methods of {@link VList}.\n */\nexport interface VListHandle extends VirtualizerHandle {}\n\n/**\n * Props of {@link VList}.\n */\nexport interface VListProps<T = unknown>\n extends\n PublicProps,\n Pick<\n VirtualizerProps<T>,\n | \"data\"\n | \"bufferSize\"\n | \"itemSize\"\n | \"shift\"\n | \"horizontal\"\n | \"cache\"\n | \"ssrCount\"\n | \"itemProps\"\n | \"onScroll\"\n | \"onScrollEnd\"\n | \"keepMounted\"\n > {}\n\ninterface VListInstance<T = unknown> extends VListHandle {\n $props: VListProps<T>;\n $slots: { default: (arg: { item: T; index: number }) => VNode[] };\n}\n\n/**\n * Virtualized list component. See {@link VListProps} and {@link VListHandle}.\n */\nexport const VList = /*#__PURE__*/ defineComponent({\n props: {\n data: { type: Array, required: true },\n bufferSize: Number,\n itemSize: Number,\n shift: Boolean,\n horizontal: Boolean,\n ssrCount: Number,\n itemProps: Function as PropType<VListProps[\"itemProps\"]>,\n keepMounted: Array as PropType<VListProps[\"keepMounted\"]>,\n cache: Object as PropType<VListProps[\"cache\"]>,\n },\n emits: [\"scroll\", \"scrollEnd\"],\n setup(props, { emit, expose, slots }) {\n const horizontal = props.horizontal;\n\n const onScroll = (offset: number) => {\n emit(\"scroll\", offset);\n };\n const onScrollEnd = () => {\n emit(\"scrollEnd\");\n };\n\n const handle = ref<InstanceType<typeof Virtualizer>>();\n\n expose({\n get cache() {\n return handle.value!.cache;\n },\n get scrollOffset() {\n return handle.value!.scrollOffset;\n },\n get scrollSize() {\n return handle.value!.scrollSize;\n },\n get viewportSize() {\n return handle.value!.viewportSize;\n },\n findItemIndex: (...args) => handle.value!.findItemIndex(...args),\n getItemOffset: (...args) => handle.value!.getItemOffset(...args),\n getItemSize: (...args) => handle.value!.getItemSize(...args),\n scrollToIndex: (...args) => handle.value!.scrollToIndex(...args),\n scrollTo: (...args) => handle.value!.scrollTo(...args),\n scrollBy: (...args) => handle.value!.scrollBy(...args),\n } satisfies VListHandle);\n\n return () => {\n return (\n <div\n style={{\n display: horizontal ? \"inline-block\" : \"block\",\n [horizontal ? \"overflowX\" : \"overflowY\"]: \"auto\",\n contain: \"strict\",\n width: \"100%\",\n height: \"100%\",\n }}\n >\n <Virtualizer\n ref={handle}\n data={props.data}\n bufferSize={props.bufferSize}\n itemSize={props.itemSize}\n itemProps={props.itemProps}\n shift={props.shift}\n ssrCount={props.ssrCount}\n horizontal={horizontal}\n keepMounted={props.keepMounted}\n cache={props.cache}\n onScroll={onScroll}\n onScrollEnd={onScrollEnd}\n >\n {slots}\n </Virtualizer>\n </div>\n );\n };\n },\n}) as unknown as {\n new <T = unknown>(props: VListProps<T>): VListInstance<T>;\n};\n","/** @jsxImportSource vue */\nimport {\n ref,\n onMounted,\n defineComponent,\n onUnmounted,\n type VNode,\n watch,\n type PropType,\n type NativeElements,\n computed,\n type PublicProps,\n} from \"vue\";\nimport {\n UPDATE_SCROLL_END_EVENT,\n UPDATE_VIRTUAL_STATE,\n createVirtualStore,\n createListLayout,\n ACTION_ITEMS_LENGTH_CHANGE,\n UPDATE_SCROLL_EVENT,\n createWindowDriver,\n scrollToIndex,\n type ItemsRange,\n type ScrollToIndexOpts,\n type CacheSnapshot,\n} from \"../core/index.js\";\nimport { ListItem } from \"./ListItem.js\";\nimport { getKey, isSameRange } from \"./utils.js\";\n\n/**\n * Props of {@link WindowVirtualizer}.\n */\nexport interface WindowVirtualizerProps<T = unknown> extends PublicProps {\n /**\n * The data items rendered by this component.\n */\n data: T[];\n /**\n * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.\n * @defaultValue 200\n */\n bufferSize?: number;\n /**\n * Item size hint for unmeasured items in pixels. It will help to reduce scroll jump when items are measured if used properly.\n *\n * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.\n * - If set, you can opt out estimation and use the value as initial item size.\n */\n itemSize?: number;\n /**\n * A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated. The minimum value is 0.\n */\n ssrCount?: number;\n /**\n * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.\n */\n shift?: boolean;\n /**\n * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.\n */\n horizontal?: boolean;\n /**\n * Component or element type for container element.\n * @defaultValue \"div\"\n */\n as?: keyof NativeElements;\n /**\n * Component or element type for item element.\n * @defaultValue \"div\"\n */\n item?: keyof NativeElements;\n /**\n * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link WindowVirtualizerHandle.cache}.\n *\n * **The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.**\n */\n cache?: CacheSnapshot;\n /**\n * Callback invoked whenever scroll offset changes.\n */\n onScroll?: () => void;\n /**\n * Callback invoked when scrolling stops.\n */\n onScrollEnd?: () => void;\n}\n\ninterface WindowVirtualizerInstance<\n T = unknown,\n> extends WindowVirtualizerHandle {\n $props: WindowVirtualizerProps<T>;\n $slots: { default: (arg: { item: T; index: number }) => VNode[] };\n}\n\n/**\n * Methods of {@link WindowVirtualizer}.\n */\nexport interface WindowVirtualizerHandle {\n /**\n * Get current {@link CacheSnapshot}.\n */\n readonly cache: CacheSnapshot;\n /**\n * Get current scrollTop, or scrollLeft if horizontal: true. Always positive even in RTL.\n */\n readonly scrollOffset: number;\n /**\n * Get current clientHeight of the document, or clientWidth if horizontal: true.\n */\n readonly viewportSize: number;\n /**\n * Find nearest item index from offset.\n * @param offset offset in pixels from the start of the scroll container\n */\n findItemIndex(offset: number): number;\n /**\n * Get item offset from start.\n * @param index index of item\n */\n getItemOffset(index: number): number;\n /**\n * Get item size.\n * @param index index of item\n */\n getItemSize(index: number): number;\n /**\n * Scroll to the item specified by index.\n * @param index index of item\n * @param opts options\n */\n scrollToIndex(index: number, opts?: ScrollToIndexOpts): void;\n}\n\n/**\n * {@link Virtualizer} controlled by the window scrolling. See {@link WindowVirtualizerProps} and {@link WindowVirtualizerHandle}.\n */\nexport const WindowVirtualizer = /*#__PURE__*/ defineComponent({\n props: {\n data: { type: Array, required: true },\n bufferSize: Number,\n itemSize: Number,\n ssrCount: Number,\n shift: Boolean,\n horizontal: Boolean,\n as: {\n type: String as PropType<WindowVirtualizerProps[\"as\"]>,\n default: \"div\",\n },\n item: {\n type: String as PropType<WindowVirtualizerProps[\"item\"]>,\n default: \"div\",\n },\n cache: Object as PropType<WindowVirtualizerProps[\"cache\"]>,\n },\n emits: [\"scroll\", \"scrollEnd\"],\n setup(props, { emit, slots, expose }) {\n let isSSR = !!props.ssrCount;\n\n const isHorizontal = props.horizontal;\n const containerRef = ref<HTMLDivElement>();\n const layout = createListLayout(\n props.data.length,\n props.itemSize,\n props.cache,\n );\n const store = createVirtualStore(layout, props.ssrCount);\n const driver = createWindowDriver(store, isHorizontal);\n\n const stateVersion = ref(store.$getStateVersion());\n store.$subscribe(UPDATE_VIRTUAL_STATE, () => {\n stateVersion.value = store.$getStateVersion();\n });\n store.$subscribe(UPDATE_SCROLL_EVENT, () => {\n // https://github.com/inokawa/virtua/discussions/580\n emit(\"scroll\");\n });\n store.$subscribe(UPDATE_SCROLL_END_EVENT, () => {\n emit(\"scrollEnd\");\n });\n\n const range = computed<ItemsRange>((prev) => {\n stateVersion.value;\n const next = store.$getRange(props.bufferSize);\n if (prev && isSameRange(prev, next)) {\n return prev;\n }\n return next;\n });\n const isScrolling = computed(\n () => stateVersion.value && store.$isScrolling(),\n );\n const totalSize = computed(\n () => stateVersion.value && store.$getTotalSize(),\n );\n\n onMounted(() => {\n isSSR = false;\n\n const el = containerRef.value;\n if (!el) return;\n driver.$observe(el);\n });\n onUnmounted(() => {\n store.$dispose();\n driver.$dispose();\n });\n\n watch(\n () => props.data.length,\n (count) => {\n store.$update(ACTION_ITEMS_LENGTH_CHANGE, [count, props.shift]);\n },\n );\n\n watch(\n [stateVersion],\n () => {\n driver.$effect();\n },\n { flush: \"post\" },\n );\n\n expose({\n get cache() {\n return layout.$snapshot();\n },\n get scrollOffset() {\n return store.$getScrollOffset();\n },\n get viewportSize() {\n return store.$getViewportSize();\n },\n findItemIndex: store.$findItemIndex,\n getItemOffset: store.$getItemOffset,\n getItemSize: store.$getItemSize,\n scrollToIndex: (index, opts) => scrollToIndex(driver, store, index, opts),\n } satisfies WindowVirtualizerHandle);\n\n return () => {\n const Element = props.as;\n const ItemElement = props.item;\n\n const total = totalSize.value;\n\n const items: VNode[] = [];\n for (let [i, j] = range.value; i <= j; i++) {\n const e = slots[\"default\"]!({ item: props.data![i]!, index: i });\n items.push(\n <ListItem\n key={getKey(e, i)}\n _stateVersion={stateVersion}\n _store={store}\n _resizer={driver.$observeItem}\n _index={i}\n _slot={slots[\"default\"]!}\n _item={props.data![i]!}\n _isHorizontal={isHorizontal}\n _isSSR={isSSR}\n _as={ItemElement}\n />,\n );\n }\n\n return (\n <Element\n ref={containerRef}\n style={{\n contain: \"size style\", // https://github.com/inokawa/virtua/pull/775 https://github.com/inokawa/virtua/issues/800\n overflowAnchor: \"none\", // opt out browser's scroll anchoring because it will conflict to scroll anchoring of virtualizer\n flex: \"none\", // flex style can break layout\n position: \"relative\",\n width: isHorizontal ? total + \"px\" : \"100%\",\n height: isHorizontal ? \"100%\" : total + \"px\",\n pointerEvents: isScrolling.value ? \"none\" : undefined,\n }}\n >\n {items}\n </Element>\n );\n };\n },\n}) as unknown as {\n new <T = unknown>(\n props: WindowVirtualizerProps<T>,\n ): WindowVirtualizerInstance<T>;\n};\n","/** @jsxImportSource vue */\nimport {\n defineComponent,\n onMounted,\n onUnmounted,\n ref,\n watch,\n computed,\n type VNode,\n type PropType,\n type PublicProps,\n type StyleValue,\n watchEffect,\n} from \"vue\";\nimport {\n UPDATE_SCROLL_END_EVENT,\n UPDATE_SCROLL_EVENT,\n UPDATE_VIRTUAL_STATE,\n createContainerGridDriver,\n createGridLayout,\n createVirtualStore,\n getAxisItem,\n getScrollSize,\n gridScrollBy,\n gridScrollTo,\n gridScrollToIndex,\n updateGridAxis,\n type GridDriver,\n type GridScrollToIndexOpts,\n type GridAxis,\n type GridCell as GridCellType,\n type GridSize,\n type GridTrackSize,\n type GridSpan,\n createGridPlan,\n type GridCellState,\n type GridRowGroupState,\n type GridRowState,\n} from \"../core/index.js\";\n\n/**\n * Props of {@link VGrid}.\n */\nexport interface VGridProps<R = number, C = number> extends PublicProps {\n /**\n * The rows of the grid. See {@link GridAxis} for the accepted values.\n */\n rows: GridAxis<R>;\n /**\n * The columns of the grid. See {@link GridAxis} for the accepted values.\n */\n cols: GridAxis<C>;\n /**\n * The heights of the rows. See {@link GridSize} for the accepted values.\n */\n rowHeight: GridSize<R>;\n /**\n * The widths of the columns. See {@link GridSize} for the accepted values.\n */\n colWidth: GridSize<C>;\n /**\n * The number of the leading rows pinned to the start, which are the column headers (`role=\"columnheader\"`).\n *\n * **The pinned cells are rendered over the other cells, so give them an opaque background.**\n * @defaultValue 0\n */\n headerRows?: number;\n /**\n * Indexes of the rows which start sections. A section lasts until the next section row or the footer rows, and its first row sticks below the header rows while the section is scrolled through.\n *\n * **The section rows are rendered over the other cells while they stick, so give them an opaque background.**\n */\n sectionRows?: readonly number[];\n /**\n * The number of the trailing rows pinned to the end.\n *\n * **The pinned cells are rendered over the other cells, so give them an opaque background.**\n * @defaultValue 0\n */\n footerRows?: number;\n /**\n * The number of the leading columns pinned to the start, the last of which is the row header (`role=\"rowheader\"`).\n *\n * **The pinned cells are rendered over the other cells, so give them an opaque background.**\n * @defaultValue 0\n */\n headerCols?: number;\n /**\n * The number of the trailing columns pinned to the end.\n *\n * **The pinned cells are rendered over the other cells, so give them an opaque background.**\n * @defaultValue 0\n */\n footerCols?: number;\n /**\n * Cells merged over multiple rows and/or columns. See {@link GridSpan} for the accepted values.\n *\n * The cell at the origin is stretched over the merged area, and the other cells in it are not rendered. Spans must not overlap each other or cross the boundaries of the pinned rows/columns or the sections. A spanning cell is not measured for `\"auto\"` sizes on the axes it spans, and doesn't enlarge those tracks.\n */\n spans?: readonly GridSpan[];\n /**\n * List of cells that should be always mounted, even when off screen.\n */\n keepMounted?: readonly GridCellType[];\n /**\n * Extra space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank cells in fast scrolling.\n * @defaultValue 200\n */\n bufferSize?: number;\n /**\n * The gap between the rows and the columns in pixels, which is not included in the sizes. Must not be changed after mount.\n * @defaultValue 0\n */\n gap?: number;\n /**\n * The header cell of the sorted column or row, and the sort order (`aria-sort`).\n */\n ariaSort?: GridCellType & { order: \"ascending\" | \"descending\" | \"other\" };\n /**\n * Callback invoked whenever the vertical scroll offset changes.\n * @param offset Current scrollTop.\n */\n onVerticalScroll?: (offset: number) => void;\n /**\n * Callback invoked whenever the horizontal scroll offset changes.\n * @param offset Current scrollLeft. Always positive even in RTL.\n */\n onHorizontalScroll?: (offset: number) => void;\n /**\n * Callback invoked when scrolling stops.\n */\n onScrollEnd?: () => void;\n}\n\n/**\n * Methods of {@link VGrid}.\n */\nexport interface VGridHandle {\n /**\n * Get current scrollTop.\n */\n readonly verticalScrollOffset: number;\n /**\n * Get current scrollLeft. Always positive even in RTL.\n */\n readonly horizontalScrollOffset: number;\n /**\n * Get current scrollHeight.\n */\n readonly scrollHeight: number;\n /**\n * Get current scrollWidth.\n */\n readonly scrollWidth: number;\n /**\n * Get current clientHeight.\n */\n readonly viewportHeight: number;\n /**\n * Get current clientWidth.\n */\n readonly viewportWidth: number;\n /**\n * Find nearest row index from offset.\n * @param offset offset in pixels from the top of the scroll container\n */\n findRowIndex(offset: number): number;\n /**\n * Find nearest column index from offset.\n * @param offset offset in pixels from the start of the scroll container\n */\n findColIndex(offset: number): number;\n /**\n * Get offset of the row from the top.\n * @param index index of row\n */\n getRowOffset(index: number): number;\n /**\n * Get offset of the column from the start.\n * @param index index of column\n */\n getColOffset(index: number): number;\n /**\n * Get size of the row.\n * @param index index of row\n */\n getRowSize(index: number): number;\n /**\n * Get size of the column.\n * @param index index of column\n */\n getColSize(index: number): number;\n /**\n * Scroll to the cell specified by the indexes. The cell is not hidden behind the rows and the columns sticking over it.\n * @param opts the indexes of the cell and the options. See {@link GridScrollToIndexOpts}.\n */\n scrollToIndex(opts: GridScrollToIndexOpts): void;\n /**\n * Scroll to the given offsets from the top/start of the scroll container.\n * @param offset the offsets. The axis whose offset is omitted is not scrolled.\n */\n scrollTo(offset: { vertical?: number; horizontal?: number }): void;\n /**\n * Scroll by the given offsets from the current position.\n * @param offset the offsets. The axis whose offset is omitted is not scrolled.\n */\n scrollBy(offset: { vertical?: number; horizontal?: number }): void;\n}\n\ninterface VGridInstance<R = number, C = number> extends VGridHandle {\n $props: VGridProps<R, C>;\n $slots: {\n default: (arg: { row: R; col: C; cell: Readonly<GridCellType> }) => VNode[];\n };\n}\n\ninterface GridCellProps {\n _state: GridCellState;\n _slot: (arg: {\n row: unknown;\n col: unknown;\n cell: Readonly<GridCellType>;\n }) => VNode[];\n _row: unknown;\n _col: unknown;\n _rowIndex: number;\n _resizer: GridDriver[\"$observeItem\"];\n}\n\nconst GridCell = /*#__PURE__*/ defineComponent(\n (props: GridCellProps) => {\n const elementRef = ref<HTMLDivElement>();\n\n watch(\n [\n elementRef,\n () => props._state.$measureRow,\n () => props._state.$measureCol,\n ],\n ([element, rowIndex, colIndex], _, onCleanup) => {\n if (!element || (rowIndex == null && colIndex == null)) return;\n onCleanup(props._resizer(element, rowIndex, colIndex));\n },\n { flush: \"post\" },\n );\n\n return () => {\n const {\n $col: colIndex,\n $rowSpan,\n $colSpan,\n $role,\n $sort,\n $style,\n } = props._state;\n return (\n <div\n ref={elementRef}\n role={$role}\n aria-colindex={colIndex + 1}\n aria-rowspan={$rowSpan}\n aria-colspan={$colSpan}\n aria-sort={$sort}\n style={$style as StyleValue}\n >\n {props._slot({\n row: props._row,\n col: props._col,\n cell: { rowIndex: props._rowIndex, colIndex },\n })}\n </div>\n );\n };\n },\n {\n // Required to split props from attrs. Object form keeps the keys manglable.\n props: {\n _state: null,\n _slot: null,\n _row: null,\n _col: null,\n _rowIndex: null,\n _resizer: null,\n } satisfies Record<keyof GridCellProps, null>,\n },\n);\n\ninterface GridRowProps {\n _state: GridRowState;\n _slot: (arg: {\n row: unknown;\n col: unknown;\n cell: Readonly<GridCellType>;\n }) => VNode[];\n _row: unknown;\n _cols: GridAxis<unknown>;\n _resizer: GridDriver[\"$observeItem\"];\n}\n\nconst GridRow = /*#__PURE__*/ defineComponent(\n (props: GridRowProps) => {\n return () => {\n const { $row: rowIndex, $cells, $style } = props._state;\n return (\n <div\n role=\"row\"\n aria-rowindex={rowIndex + 1}\n style={$style as StyleValue}\n >\n {$cells.map((cell) => (\n <GridCell\n key={cell.$col}\n _state={cell}\n _slot={props._slot}\n _row={props._row}\n _col={getAxisItem(props._cols, cell.$col)}\n _rowIndex={rowIndex}\n _resizer={props._resizer}\n />\n ))}\n </div>\n );\n };\n },\n {\n // Required to split props from attrs. Object form keeps the keys manglable.\n props: {\n _state: null,\n _slot: null,\n _row: null,\n _cols: null,\n _resizer: null,\n } satisfies Record<keyof GridRowProps, null>,\n },\n);\n\ninterface GridRowGroupProps {\n _state: GridRowGroupState;\n _slot: (props: {\n row: unknown;\n col: unknown;\n cell: Readonly<GridCellType>;\n }) => VNode[];\n _rows: GridAxis<unknown>;\n _cols: GridAxis<unknown>;\n _resizer: GridDriver[\"$observeItem\"];\n}\n\nconst GridRowGroup = /*#__PURE__*/ defineComponent(\n (props: GridRowGroupProps) => {\n return () => {\n const { $rows, $style } = props._state;\n return (\n // https://www.w3.org/TR/wai-aria-1.2/#rowgroup\n <div role=\"rowgroup\" style={$style as StyleValue}>\n {$rows.map((state) => (\n <GridRow\n key={state.$row}\n _state={state}\n _slot={props._slot}\n _row={getAxisItem(props._rows, state.$row)}\n _cols={props._cols}\n _resizer={props._resizer}\n />\n ))}\n </div>\n );\n };\n },\n {\n // Required to split props from attrs. Object form keeps the keys manglable.\n props: {\n _state: null,\n _slot: null,\n _rows: null,\n _cols: null,\n _resizer: null,\n } satisfies Record<keyof GridRowGroupProps, null>,\n },\n);\n\n/**\n * Virtualized grid component for tabular data. See {@link VGridProps} and {@link VGridHandle}.\n */\nexport const VGrid = /*#__PURE__*/ defineComponent({\n props: {\n rows: {\n type: [Number, Array] as PropType<GridAxis<unknown>>,\n required: true,\n },\n cols: {\n type: [Number, Array] as PropType<GridAxis<unknown>>,\n required: true,\n },\n rowHeight: {\n type: [Number, String] as PropType<GridTrackSize | string>,\n required: true,\n },\n colWidth: {\n type: [Number, String] as PropType<GridTrackSize | string>,\n required: true,\n },\n headerRows: Number,\n sectionRows: Array as PropType<VGridProps[\"sectionRows\"]>,\n footerRows: Number,\n headerCols: Number,\n footerCols: Number,\n spans: Array as PropType<VGridProps[\"spans\"]>,\n keepMounted: Array as PropType<VGridProps[\"keepMounted\"]>,\n bufferSize: Number,\n gap: { type: Number, default: 0 },\n ariaSort: Object as PropType<VGridProps[\"ariaSort\"]>,\n },\n emits: [\"verticalScroll\", \"horizontalScroll\", \"scrollEnd\"],\n setup(props, { emit, expose, slots }) {\n const containerRef = ref<HTMLDivElement>();\n\n const rowLayout = createGridLayout(props.rows, props.rowHeight, props.gap);\n const colLayout = createGridLayout(props.cols, props.colWidth, props.gap);\n const rowStore = createVirtualStore(rowLayout);\n const colStore = createVirtualStore(colLayout);\n const driver = createContainerGridDriver(rowStore, colStore);\n\n const stateVersion = ref(\n rowStore.$getStateVersion() + colStore.$getStateVersion(),\n );\n const rerender = () => {\n stateVersion.value =\n rowStore.$getStateVersion() + colStore.$getStateVersion();\n };\n rowStore.$subscribe(UPDATE_VIRTUAL_STATE, rerender);\n colStore.$subscribe(UPDATE_VIRTUAL_STATE, rerender);\n\n // Both stores observe both axes, so the end is notified once after both have ended.\n let scrolled = false;\n rowStore.$subscribe(UPDATE_SCROLL_EVENT, () => {\n scrolled = true;\n emit(\"verticalScroll\", rowStore.$getScrollOffset());\n });\n colStore.$subscribe(UPDATE_SCROLL_EVENT, () => {\n scrolled = true;\n emit(\"horizontalScroll\", colStore.$getScrollOffset());\n });\n const notifyScrollEnd = () => {\n if (scrolled && !rowStore.$isScrolling() && !colStore.$isScrolling()) {\n scrolled = false;\n emit(\"scrollEnd\");\n }\n };\n rowStore.$subscribe(UPDATE_SCROLL_END_EVENT, notifyScrollEnd);\n colStore.$subscribe(UPDATE_SCROLL_END_EVENT, notifyScrollEnd);\n\n // The sizes read from the items are tracked, so the items mutated in place are followed.\n watchEffect(() => {\n updateGridAxis(\n rowStore,\n rowLayout,\n props.rows,\n props.rowHeight,\n props.headerRows,\n props.footerRows,\n true,\n );\n });\n watchEffect(() => {\n updateGridAxis(\n colStore,\n colLayout,\n props.cols,\n props.colWidth,\n props.headerCols,\n props.footerCols,\n true,\n );\n });\n\n const rowCount = computed(\n () => stateVersion.value && rowStore.$getItemsLength(),\n );\n const colCount = computed(\n () => stateVersion.value && colStore.$getItemsLength(),\n );\n const plan = computed(() => {\n stateVersion.value;\n return createGridPlan(\n rowLayout,\n colLayout,\n rowStore.$getRange(props.bufferSize),\n colStore.$getRange(props.bufferSize),\n props.sectionRows,\n props.spans,\n props.keepMounted,\n props.ariaSort,\n );\n });\n const isScrolling = computed(\n () =>\n stateVersion.value &&\n (rowStore.$isScrolling() || colStore.$isScrolling()),\n );\n\n onMounted(() => {\n driver.$observe(containerRef.value!);\n });\n onUnmounted(() => {\n rowStore.$dispose();\n colStore.$dispose();\n driver.$dispose();\n });\n\n watch(\n [stateVersion],\n () => {\n driver.$effect();\n },\n { flush: \"post\" },\n );\n\n expose({\n get verticalScrollOffset() {\n return rowStore.$getScrollOffset();\n },\n get horizontalScrollOffset() {\n return colStore.$getScrollOffset();\n },\n get scrollHeight() {\n return getScrollSize(rowStore);\n },\n get scrollWidth() {\n return getScrollSize(colStore);\n },\n get viewportHeight() {\n return rowStore.$getViewportSize();\n },\n get viewportWidth() {\n return colStore.$getViewportSize();\n },\n findRowIndex: rowStore.$findItemIndex,\n findColIndex: colStore.$findItemIndex,\n getRowOffset: rowStore.$getItemOffset,\n getColOffset: colStore.$getItemOffset,\n getRowSize: rowStore.$getItemSize,\n getColSize: colStore.$getItemSize,\n scrollToIndex: (opts) =>\n gridScrollToIndex(\n driver,\n rowStore,\n colStore,\n rowLayout,\n colLayout,\n props.sectionRows,\n opts,\n ),\n scrollTo: ({ vertical, horizontal }) =>\n gridScrollTo(driver, vertical, horizontal),\n scrollBy: ({ vertical, horizontal }) =>\n gridScrollBy(driver, rowStore, colStore, vertical, horizontal),\n } satisfies VGridHandle);\n\n return () => {\n const { $rowTemplate, $colTemplate, $groups } = plan.value;\n // A jump deferred during scrolling shifts the tracks, as it shifts the items of the lists.\n const marginTop = rowStore.$getItemOffset(0);\n const marginInlineStart = colStore.$getItemOffset(0);\n\n const containerStyle: StyleValue = {\n // https://github.com/inokawa/virtua/pull/775 https://github.com/inokawa/virtua/issues/800\n contain: \"size style\",\n overflowAnchor: \"none\", // opt out browser's scroll anchoring because it will conflict to scroll anchoring of virtualizer\n flex: \"none\", // flex style can break layout\n display: \"grid\",\n gridTemplateRows: $rowTemplate,\n gridTemplateColumns: $colTemplate,\n gap: props.gap + \"px\",\n marginTop: marginTop + \"px\",\n marginInlineStart: marginInlineStart + \"px\",\n // The width is left to the viewport, so the auto columns fill it as the columns of a table.\n height: getScrollSize(rowStore) - marginTop + \"px\",\n pointerEvents: isScrolling.value ? \"none\" : undefined,\n };\n\n return (\n <div\n // https://www.w3.org/WAI/ARIA/apg/patterns/table/\n // https://www.w3.org/TR/wai-aria-1.2/#table\n // https://www.w3.org/TR/wai-aria-1.2/#aria-rowcount\n role=\"table\"\n aria-rowcount={rowCount.value}\n aria-colcount={colCount.value}\n style={{\n overflow: \"auto\",\n contain: \"strict\",\n width: \"100%\",\n height: \"100%\",\n }}\n >\n <div ref={containerRef} style={containerStyle}>\n {$groups.map((state) =>\n \"$rows\" in state ? (\n <GridRowGroup\n key={state.$key}\n _state={state}\n _slot={slots[\"default\"]!}\n _rows={props.rows}\n _cols={props.cols}\n _resizer={driver.$observeItem}\n />\n ) : (\n <GridRow\n key={state.$row}\n _state={state}\n _slot={slots[\"default\"]!}\n _row={getAxisItem(props.rows, state.$row)}\n _cols={props.cols}\n _resizer={driver.$observeItem}\n />\n ),\n )}\n </div>\n </div>\n );\n };\n },\n}) as unknown as {\n new <R = number, C = number>(props: VGridProps<R, C>): VGridInstance<R, C>;\n};\n"],"mappings":";;;;;;AAMA,ICYI,GDZS,IAA0B,KAG1B,KAAE,GAAA,KAAK,GAAA,KAAK,GAAA,OAAK,KAAU,MAK3B,IAAA,CACX,GACA,GACA,MACW,EAAI,GAAU,EAAI,GAAU,KAK5B,IAA0B,KAC9B,EAAI,KAAA,CAAM,GAAG,MAAM,IAAI,IAMnB,IAAU,YAIV,IAAgB,cAKhB,IACe,qBAAnB,iBACH,iBACC;IACC,QAAQ,UAAU,KAAK;GAMlB,IAAA;IACX,IAAI;IAIJ,OAAO,EAAC,IAHY,QAAY;QAC9B,IAAU;QAEK;GC5CN,IAAsB,KACjC,EAAK,eAKM,IAAoB,KAAkB,EAAI,aAQ1C,IAAA,OACP,QAAA,MACF,IACE,iBAAiB,KAAK,UAAU,cAKR,eAAvB,UAAU,YAA2B,UAAU,iBAAiB;AAE9D,ICgCI,IAAiB,KACrB,EAAI,EAAM,KAAiB,EAAM,MAkC7B,IAAA,EAET,GAAW,GACX,GAAY,GACZ,GAAgB,GAChB,GAAc,GACd,GAAc,GACd,GAAc,GACd,GAAe,GACf,GAAY,GACZ,GAAY,GACZ,GAAsB,IAExB,IAAmB;IAEnB,IAAI,MAA+B,GAC/B,MAAU,GACV,IAA6B,GAC7B,IAAe,GACf,IAAkB,GAClB,IAAe,GACf,IAAO,GACP,IAAc,GACd,IAAe,GACf,IAtHc,GAuHd,IAjHmB,GAkHnB,IAAA,MACA,IAAyB,EAAC,GAAG,IAAQ,EAAI,IAAW,GAAG,MAAK,KAC5D,IAAqB,GAC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