@pdanpdan/virtual-scroll 0.2.0 → 0.3.0
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/README.md +182 -88
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +100 -35
- package/dist/index.js +1 -823
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +902 -0
- package/dist/index.mjs.map +1 -0
- package/dist/virtual-scroll.css +2 -0
- package/package.json +9 -6
- package/src/components/VirtualScroll.test.ts +397 -329
- package/src/components/VirtualScroll.vue +107 -25
- package/src/composables/useVirtualScroll.test.ts +1029 -255
- package/src/composables/useVirtualScroll.ts +176 -88
- package/src/utils/fenwick-tree.test.ts +80 -65
- package/dist/index.css +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["scrollTimeout: ReturnType<typeof setTimeout> | undefined","lastItems: T[]","align: ScrollAlignment | ScrollAlignmentOptions | undefined","behavior: 'auto' | 'smooth' | undefined","scrollOptions: ScrollToOptions","items: RenderedItem<T>[]","prevStickyIdx: number | undefined","nextStickyIdx: number | undefined","correctionOptions: ScrollToIndexOptions","resizeObserver: ResizeObserver | null","cleanup: (() => void) | undefined"],"sources":["../src/utils/fenwick-tree.ts","../src/utils/scroll.ts","../src/composables/useVirtualScroll.ts","../src/components/VirtualScroll.vue","../src/components/VirtualScroll.vue"],"sourcesContent":["/**\n * Fenwick Tree (Binary Indexed Tree) implementation for efficient\n * prefix sum calculations and updates.\n */\nexport class FenwickTree {\n private tree: Float64Array;\n private values: Float64Array;\n\n constructor(size: number) {\n this.tree = new Float64Array(size + 1);\n this.values = new Float64Array(size);\n }\n\n /**\n * Update the value at a specific index and propagate changes.\n * @param index 0-based index\n * @param delta The change in value (new value - old value)\n */\n update(index: number, delta: number): void {\n if (index < 0 || index >= this.values.length) {\n return;\n }\n this.values[ index ] = this.values[ index ]! + delta;\n\n index++; // 1-based index\n while (index < this.tree.length) {\n this.tree[ index ] = this.tree[ index ]! + delta;\n index += index & -index;\n }\n }\n\n /**\n * Get the prefix sum up to a specific index (exclusive).\n * @param index 0-based index. query(n) returns sum of values from 0 to n-1.\n * @returns Sum of values in range [0, index)\n */\n query(index: number): number {\n let sum = 0;\n while (index > 0) {\n sum += this.tree[ index ] || 0;\n index -= index & -index;\n }\n return sum;\n }\n\n /**\n * Set the individual value at an index without updating the tree.\n * Call rebuild() after multiple sets to update the tree efficiently.\n */\n set(index: number, value: number): void {\n if (index < 0 || index >= this.values.length) {\n return;\n }\n this.values[ index ] = value;\n }\n\n /**\n * Get the number of items in the tree.\n */\n get length(): number {\n return this.values.length;\n }\n\n /**\n * Get the individual value at an index.\n */\n get(index: number): number {\n return this.values[ index ] || 0;\n }\n\n /**\n * Get the underlying values array.\n */\n getValues(): Readonly<Float64Array> {\n return this.values;\n }\n\n /**\n * Find the largest index such that the prefix sum is less than or equal to the given value.\n * Useful for finding which item is at a specific scroll offset.\n * @param value The prefix sum value to search for\n * @returns The 0-based index\n */\n findLowerBound(value: number): number {\n let index = 0;\n const len = this.tree.length;\n let power = 1 << Math.floor(Math.log2(len - 1));\n\n while (power > 0) {\n const nextIndex = index + power;\n if (nextIndex < len) {\n const treeVal = this.tree[ nextIndex ] || 0;\n if (treeVal <= value) {\n index = nextIndex;\n value -= treeVal;\n }\n }\n power >>= 1;\n }\n return index;\n }\n\n /**\n * Rebuild the entire tree from the current values array in O(N).\n * Useful after bulk updates to the values array.\n */\n rebuild(): void {\n this.tree.fill(0);\n for (let i = 0; i < this.values.length; i++) {\n this.tree[ i + 1 ] = this.values[ i ] || 0;\n }\n for (let i = 1; i < this.tree.length; i++) {\n const j = i + (i & -i);\n if (j < this.tree.length) {\n this.tree[ j ] = this.tree[ j ]! + this.tree[ i ]!;\n }\n }\n }\n\n /**\n * Resize the tree while preserving existing values.\n * @param size New size of the tree\n */\n resize(size: number): void {\n if (size === this.values.length) {\n return;\n }\n const newValues = new Float64Array(size);\n newValues.set(this.values.subarray(0, Math.min(size, this.values.length)));\n\n this.values = newValues;\n this.tree = new Float64Array(size + 1);\n this.rebuild();\n }\n\n /**\n * Shift values by a given offset and rebuild the tree.\n * Useful when items are prepended to the list.\n * @param offset Number of positions to shift (positive for prepending)\n */\n shift(offset: number): void {\n if (offset === 0) {\n return;\n }\n const size = this.values.length;\n const newValues = new Float64Array(size);\n if (offset > 0) {\n newValues.set(this.values.subarray(0, Math.min(size - offset, this.values.length)), offset);\n } else {\n newValues.set(this.values.subarray(-offset));\n }\n this.values = newValues;\n this.rebuild();\n }\n}\n","import type { ScrollDirection, ScrollToIndexOptions } from '../composables/useVirtualScroll';\n\n/**\n * Checks if the container has a bounding client rect method.\n *\n * @param container - The container element or window to check.\n * @returns True if the container is an HTMLElement with getBoundingClientRect.\n */\nexport function isElement(container: HTMLElement | Window | null | undefined): container is HTMLElement {\n return !!container && 'getBoundingClientRect' in container;\n}\n\n/**\n * Checks if the target is an element with scroll properties.\n *\n * @param target - The event target to check.\n * @returns True if the target is an HTMLElement with scroll properties.\n */\nexport function isScrollableElement(target: EventTarget | null): target is HTMLElement {\n return !!target && 'scrollLeft' in target;\n}\n\n/**\n * Helper to determine if an options argument is the full ScrollToIndexOptions object.\n *\n * @param options - The options object to check.\n * @returns True if the options object contains scroll-to-index specific properties.\n */\nexport function isScrollToIndexOptions(options: unknown): options is ScrollToIndexOptions {\n return typeof options === 'object' && options !== null && ('align' in options || 'behavior' in options || 'isCorrection' in options);\n}\n\n/**\n * Extracts the horizontal padding from a padding value or object.\n *\n * @param p - The padding value (number or object with x/y).\n * @param direction - The current scroll direction.\n * @returns The horizontal padding in pixels.\n */\nexport function getPaddingX(p: number | { x?: number; y?: number; } | undefined, direction?: ScrollDirection) {\n if (typeof p === 'object' && p !== null) {\n return p.x || 0;\n }\n return direction === 'horizontal' ? (p || 0) : 0;\n}\n\n/**\n * Extracts the vertical padding from a padding value or object.\n *\n * @param p - The padding value (number or object with x/y).\n * @param direction - The current scroll direction.\n * @returns The vertical padding in pixels.\n */\nexport function getPaddingY(p: number | { x?: number; y?: number; } | undefined, direction?: ScrollDirection) {\n if (typeof p === 'object' && p !== null) {\n return p.y || 0;\n }\n return (direction === 'vertical' || direction === 'both') ? (p || 0) : 0;\n}\n","import type { Ref } from 'vue';\n\n/* global ScrollToOptions */\nimport { computed, getCurrentInstance, nextTick, onMounted, onUnmounted, reactive, ref, watch } from 'vue';\n\nimport { FenwickTree } from '../utils/fenwick-tree';\nimport { getPaddingX, getPaddingY, isElement, isScrollableElement, isScrollToIndexOptions } from '../utils/scroll';\n\nexport const DEFAULT_ITEM_SIZE = 40;\nexport const DEFAULT_COLUMN_WIDTH = 100;\nexport const DEFAULT_BUFFER = 5;\n\nexport type ScrollDirection = 'vertical' | 'horizontal' | 'both';\nexport type ScrollAlignment = 'start' | 'center' | 'end' | 'auto';\n\n/** Options for scroll alignment in a single axis or both axes. */\nexport interface ScrollAlignmentOptions {\n /** Alignment on the X axis. */\n x?: ScrollAlignment;\n /** Alignment on the Y axis. */\n y?: ScrollAlignment;\n}\n\n/** Options for the scrollToIndex method. */\nexport interface ScrollToIndexOptions {\n /** Where to align the item in the viewport. */\n align?: ScrollAlignment | ScrollAlignmentOptions;\n /** Scroll behavior. */\n behavior?: 'auto' | 'smooth';\n /** Internal flag for recursive correction calls. */\n isCorrection?: boolean;\n}\n\n/** Configuration properties for the useVirtualScroll composable. */\nexport interface VirtualScrollProps<T = unknown> {\n /** Array of items to be virtualized. */\n items: T[];\n /** Fixed size of each item or a function that returns the size of an item. */\n itemSize?: number | ((item: T, index: number) => number) | undefined;\n /** Direction of the scroll: 'vertical', 'horizontal', or 'both'. */\n direction?: ScrollDirection | undefined;\n /** Number of items to render before the visible viewport. */\n bufferBefore?: number | undefined;\n /** Number of items to render after the visible viewport. */\n bufferAfter?: number | undefined;\n /** The scrollable container element or window. */\n container?: HTMLElement | Window | null | undefined;\n /** The host element that contains the items. */\n hostElement?: HTMLElement | null | undefined;\n /** Range of items to render for SSR. */\n ssrRange?: {\n start: number;\n end: number;\n colStart?: number;\n colEnd?: number;\n } | undefined;\n /** Number of columns for bidirectional scroll. */\n columnCount?: number | undefined;\n /** Fixed width of columns or an array/function for column widths. */\n columnWidth?: number | number[] | ((index: number) => number) | undefined;\n /** Padding at the start of the scroll container. */\n scrollPaddingStart?: number | { x?: number; y?: number; } | undefined;\n /** Padding at the end of the scroll container. */\n scrollPaddingEnd?: number | { x?: number; y?: number; } | undefined;\n /** Gap between items in pixels (vertical). */\n gap?: number | undefined;\n /** Gap between columns in pixels (horizontal/grid). */\n columnGap?: number | undefined;\n /** Indices of items that should stick to the top/start. */\n stickyIndices?: number[] | undefined;\n /** Distance from the end of the scrollable area to trigger 'load' event. */\n loadDistance?: number | undefined;\n /** Whether items are currently being loaded. */\n loading?: boolean | undefined;\n /** Whether to restore scroll position when items are prepended. */\n restoreScrollOnPrepend?: boolean | undefined;\n /** Initial scroll index to jump to on mount. */\n initialScrollIndex?: number | undefined;\n /** Alignment for the initial scroll index. */\n initialScrollAlign?: ScrollAlignment | ScrollAlignmentOptions | undefined;\n /** Default size for items before they are measured. */\n defaultItemSize?: number | undefined;\n /** Default width for columns before they are measured. */\n defaultColumnWidth?: number | undefined;\n /** Whether to enable debug mode. */\n debug?: boolean | undefined;\n}\n\n/** Represents an item currently rendered in the virtual scroll area. */\nexport interface RenderedItem<T = unknown> {\n /** The original data item. */\n item: T;\n /** The index of the item in the original array. */\n index: number;\n /** The calculated offset relative to the host element. */\n offset: { x: number; y: number; };\n /** The current measured or estimated size. */\n size: { width: number; height: number; };\n /** The original X offset before sticky adjustments. */\n originalX: number;\n /** The original Y offset before sticky adjustments. */\n originalY: number;\n /** Whether this item is configured to be sticky. */\n isSticky?: boolean;\n /** Whether this item is currently stuck at the threshold. */\n isStickyActive?: boolean;\n /** The offset applied for the sticky pushing effect. */\n stickyOffset: { x: number; y: number; };\n}\n\n/** Comprehensive state of the virtual scroll system. */\nexport interface ScrollDetails<T = unknown> {\n /** List of items currently rendered. */\n items: RenderedItem<T>[];\n /** Index of the first item partially or fully visible in the viewport. */\n currentIndex: number;\n /** Index of the first column partially or fully visible. */\n currentColIndex: number;\n /** Current scroll position relative to content start. */\n scrollOffset: { x: number; y: number; };\n /** Dimensions of the visible viewport. */\n viewportSize: { width: number; height: number; };\n /** Total calculated size of all items and gaps. */\n totalSize: { width: number; height: number; };\n /** Whether the container is currently being scrolled. */\n isScrolling: boolean;\n /** Whether the current scroll was initiated by a method call. */\n isProgrammaticScroll: boolean;\n /** Range of items currently being rendered. */\n range: { start: number; end: number; };\n /** Range of columns currently being rendered (for grid mode). */\n columnRange: { start: number; end: number; padStart: number; padEnd: number; };\n}\n\n/**\n * Composable for virtual scrolling logic.\n * Handles calculation of visible items, scroll events, and dynamic item sizes.\n *\n * @param props - Reactive properties for virtual scroll configuration\n */\nexport function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollProps<T>>) {\n // --- State ---\n const scrollX = ref(0);\n const scrollY = ref(0);\n const isScrolling = ref(false);\n const isHydrated = ref(false);\n const isHydrating = ref(false);\n const isMounted = ref(false);\n const viewportWidth = ref(0);\n const viewportHeight = ref(0);\n const hostOffset = reactive({ x: 0, y: 0 });\n let scrollTimeout: ReturnType<typeof setTimeout> | undefined;\n\n const isProgrammaticScroll = ref(false);\n\n // --- Fenwick Trees for efficient size and offset management ---\n const itemSizesX = new FenwickTree(props.value.items.length);\n const itemSizesY = new FenwickTree(props.value.items.length);\n const columnSizes = new FenwickTree(props.value.columnCount || 0);\n\n const treeUpdateFlag = ref(0);\n\n let measuredColumns = new Uint8Array(0);\n let measuredItemsX = new Uint8Array(0);\n let measuredItemsY = new Uint8Array(0);\n\n // --- Scroll Queue / Correction ---\n const pendingScroll = ref<{\n rowIndex: number | null | undefined;\n colIndex: number | null | undefined;\n options: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions | undefined;\n } | null>(null);\n\n // Track if sizes are initialized\n const sizesInitialized = ref(false);\n let lastItems: T[] = [];\n\n // --- Computed Config ---\n const isDynamicItemSize = computed(() =>\n props.value.itemSize === undefined || props.value.itemSize === null || props.value.itemSize === 0,\n );\n\n const isDynamicColumnWidth = computed(() =>\n props.value.columnWidth === undefined || props.value.columnWidth === null || props.value.columnWidth === 0,\n );\n\n const fixedItemSize = computed(() =>\n (typeof props.value.itemSize === 'number' && props.value.itemSize > 0) ? props.value.itemSize : null,\n );\n\n const defaultSize = computed(() => props.value.defaultItemSize || fixedItemSize.value || DEFAULT_ITEM_SIZE);\n\n const sortedStickyIndices = computed(() =>\n [ ...(props.value.stickyIndices || []) ].sort((a, b) => a - b),\n );\n\n // --- Size Calculations ---\n /**\n * Total width of all items in the scrollable area.\n */\n const totalWidth = computed(() => {\n // eslint-disable-next-line ts/no-unused-expressions\n treeUpdateFlag.value;\n\n if (!isHydrated.value && props.value.ssrRange && !isMounted.value) {\n const { start = 0, end = 0, colStart = 0, colEnd = 0 } = props.value.ssrRange;\n const colCount = props.value.columnCount || 0;\n if (props.value.direction === 'both') {\n if (colCount <= 0) {\n return 0;\n }\n const effectiveColEnd = colEnd || colCount;\n const total = columnSizes.query(effectiveColEnd) - columnSizes.query(colStart);\n return Math.max(0, total - (effectiveColEnd > colStart ? (props.value.columnGap || 0) : 0));\n }\n /* v8 ignore else -- @preserve */\n if (props.value.direction === 'horizontal') {\n if (fixedItemSize.value !== null) {\n const len = end - start;\n return Math.max(0, len * (fixedItemSize.value + (props.value.columnGap || 0)) - (len > 0 ? (props.value.columnGap || 0) : 0));\n }\n const total = itemSizesX.query(end) - itemSizesX.query(start);\n return Math.max(0, total - (end > start ? (props.value.columnGap || 0) : 0));\n }\n }\n\n if (props.value.direction === 'both') {\n const colCount = props.value.columnCount || 0;\n if (colCount <= 0) {\n return 0;\n }\n const total = columnSizes.query(colCount);\n return Math.max(0, total - (props.value.columnGap || 0));\n }\n if (props.value.direction === 'vertical') {\n return 0;\n }\n if (fixedItemSize.value !== null) {\n const len = props.value.items.length;\n return Math.max(0, len * (fixedItemSize.value + (props.value.columnGap || 0)) - (len > 0 ? (props.value.columnGap || 0) : 0));\n }\n const total = itemSizesX.query(props.value.items.length);\n return Math.max(0, total - (props.value.items.length > 0 ? (props.value.columnGap || 0) : 0));\n });\n\n /**\n * Total height of all items in the scrollable area.\n */\n const totalHeight = computed(() => {\n // eslint-disable-next-line ts/no-unused-expressions\n treeUpdateFlag.value;\n\n if (!isHydrated.value && props.value.ssrRange && !isMounted.value) {\n const { start, end } = props.value.ssrRange;\n /* v8 ignore else -- @preserve */\n if (props.value.direction === 'vertical' || props.value.direction === 'both') {\n if (fixedItemSize.value !== null) {\n const len = end - start;\n return Math.max(0, len * (fixedItemSize.value + (props.value.gap || 0)) - (len > 0 ? (props.value.gap || 0) : 0));\n }\n const total = itemSizesY.query(end) - itemSizesY.query(start);\n return Math.max(0, total - (end > start ? (props.value.gap || 0) : 0));\n }\n }\n\n if (props.value.direction === 'horizontal') {\n return 0;\n }\n if (fixedItemSize.value !== null) {\n const len = props.value.items.length;\n return Math.max(0, len * (fixedItemSize.value + (props.value.gap || 0)) - (len > 0 ? (props.value.gap || 0) : 0));\n }\n const total = itemSizesY.query(props.value.items.length);\n return Math.max(0, total - (props.value.items.length > 0 ? (props.value.gap || 0) : 0));\n });\n\n const relativeScrollX = computed(() => {\n const isHorizontal = props.value.direction === 'horizontal' || props.value.direction === 'both';\n const padding = isHorizontal ? getPaddingX(props.value.scrollPaddingStart, props.value.direction) : 0;\n return Math.max(0, scrollX.value + padding - hostOffset.x);\n });\n const relativeScrollY = computed(() => {\n const isVertical = props.value.direction === 'vertical' || props.value.direction === 'both';\n const padding = isVertical ? getPaddingY(props.value.scrollPaddingStart, props.value.direction) : 0;\n return Math.max(0, scrollY.value + padding - hostOffset.y);\n });\n\n // --- Scroll Helpers ---\n const getColumnWidth = (index: number) => {\n // eslint-disable-next-line ts/no-unused-expressions\n treeUpdateFlag.value;\n\n const cw = props.value.columnWidth;\n if (typeof cw === 'number' && cw > 0) {\n return cw;\n }\n if (Array.isArray(cw) && cw.length > 0) {\n const val = cw[ index % cw.length ];\n return (val != null && val > 0) ? val : (props.value.defaultColumnWidth || DEFAULT_COLUMN_WIDTH);\n }\n /* v8 ignore else -- @preserve */\n if (typeof cw === 'function') {\n return cw(index);\n }\n return columnSizes.get(index) || props.value.defaultColumnWidth || DEFAULT_COLUMN_WIDTH;\n };\n\n // --- Public Scroll API ---\n /**\n * Scrolls to a specific row and column index.\n *\n * @param rowIndex - The row index to scroll to. Pass null to only scroll horizontally.\n * @param colIndex - The column index to scroll to. Pass null to only scroll vertically.\n * @param options - Scroll options including alignment ('start', 'center', 'end', 'auto') and behavior ('auto', 'smooth').\n */\n const scrollToIndex = (\n rowIndex: number | null | undefined,\n colIndex: number | null | undefined,\n options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions,\n ) => {\n const isCorrection = typeof options === 'object' && options !== null && 'isCorrection' in options\n ? options.isCorrection\n : false;\n\n if (!isCorrection) {\n pendingScroll.value = { rowIndex, colIndex, options };\n }\n\n const container = props.value.container || window;\n const fixedSize = fixedItemSize.value;\n const gap = props.value.gap || 0;\n const columnGap = props.value.columnGap || 0;\n\n let align: ScrollAlignment | ScrollAlignmentOptions | undefined;\n let behavior: 'auto' | 'smooth' | undefined;\n\n if (isScrollToIndexOptions(options)) {\n align = options.align;\n behavior = options.behavior;\n } else {\n align = options as ScrollAlignment | ScrollAlignmentOptions;\n }\n\n const alignX = (typeof align === 'object' ? align.x : align) || 'auto';\n const alignY = (typeof align === 'object' ? align.y : align) || 'auto';\n\n const paddingStartX = getPaddingX(props.value.scrollPaddingStart, props.value.direction);\n const paddingEndX = getPaddingX(props.value.scrollPaddingEnd, props.value.direction);\n const paddingStartY = getPaddingY(props.value.scrollPaddingStart, props.value.direction);\n const paddingEndY = getPaddingY(props.value.scrollPaddingEnd, props.value.direction);\n\n const isVertical = props.value.direction === 'vertical' || props.value.direction === 'both';\n const isHorizontal = props.value.direction === 'horizontal' || props.value.direction === 'both';\n\n const usableWidth = viewportWidth.value - (isHorizontal ? (paddingStartX + paddingEndX) : 0);\n const usableHeight = viewportHeight.value - (isVertical ? (paddingStartY + paddingEndY) : 0);\n\n let targetX = relativeScrollX.value;\n let targetY = relativeScrollY.value;\n let itemWidth = 0;\n let itemHeight = 0;\n\n // Y calculation\n if (rowIndex !== null && rowIndex !== undefined) {\n if (rowIndex >= props.value.items.length) {\n targetY = totalHeight.value;\n itemHeight = 0;\n } else {\n targetY = fixedSize !== null ? rowIndex * (fixedSize + gap) : itemSizesY.query(rowIndex);\n itemHeight = fixedSize !== null ? fixedSize : itemSizesY.get(rowIndex) - gap;\n }\n\n // Apply Y Alignment\n if (alignY === 'start') {\n // targetY is already at the start of the list\n } else if (alignY === 'center') {\n targetY -= (usableHeight - itemHeight) / 2;\n } else if (alignY === 'end') {\n targetY -= (usableHeight - itemHeight);\n } else {\n const isVisibleY = targetY >= relativeScrollY.value && (targetY + itemHeight) <= (relativeScrollY.value + usableHeight);\n if (!isVisibleY) {\n if (targetY < relativeScrollY.value) {\n // keep targetY at start\n } else {\n targetY -= (usableHeight - itemHeight);\n }\n }\n }\n }\n\n // X calculation\n if (colIndex !== null && colIndex !== undefined) {\n const totalCols = props.value.columnCount || 0;\n if (colIndex >= totalCols && totalCols > 0) {\n targetX = totalWidth.value;\n itemWidth = 0;\n } else if (props.value.direction === 'horizontal') {\n targetX = fixedSize !== null ? colIndex * (fixedSize + columnGap) : itemSizesX.query(colIndex);\n itemWidth = fixedSize !== null ? fixedSize : itemSizesX.get(colIndex) - columnGap;\n } else {\n targetX = columnSizes.query(colIndex);\n itemWidth = columnSizes.get(colIndex) - columnGap;\n }\n\n // Apply X Alignment\n if (alignX === 'start') {\n // targetX is already at the start of the list\n } else if (alignX === 'center') {\n targetX -= (usableWidth - itemWidth) / 2;\n } else if (alignX === 'end') {\n targetX -= (usableWidth - itemWidth);\n } else {\n const isVisibleX = targetX >= relativeScrollX.value && (targetX + itemWidth) <= (relativeScrollX.value + usableWidth);\n if (!isVisibleX) {\n /* v8 ignore if -- @preserve */\n if (targetX < relativeScrollX.value) {\n // keep targetX at start\n } else {\n targetX -= (usableWidth - itemWidth);\n }\n }\n }\n }\n\n // Clamp to valid range\n targetX = Math.max(0, Math.min(targetX, Math.max(0, totalWidth.value - usableWidth)));\n targetY = Math.max(0, Math.min(targetY, Math.max(0, totalHeight.value - usableHeight)));\n\n const finalX = targetX + hostOffset.x - (isHorizontal ? paddingStartX : 0);\n const finalY = targetY + hostOffset.y - (isVertical ? paddingStartY : 0);\n\n // Check if we reached the target\n const tolerance = 1;\n let reachedX = (colIndex === null || colIndex === undefined) || Math.abs(relativeScrollX.value - targetX) < tolerance;\n let reachedY = (rowIndex === null || rowIndex === undefined) || Math.abs(relativeScrollY.value - targetY) < tolerance;\n\n if (!reachedX || !reachedY) {\n let curX = 0;\n let curY = 0;\n let maxW = 0;\n let maxH = 0;\n let viewW = 0;\n let viewH = 0;\n\n /* v8 ignore else -- @preserve */\n if (typeof window !== 'undefined') {\n if (container === window) {\n curX = window.scrollX;\n curY = window.scrollY;\n maxW = document.documentElement.scrollWidth;\n maxH = document.documentElement.scrollHeight;\n viewW = window.innerWidth;\n viewH = window.innerHeight;\n } else if (isElement(container)) {\n curX = container.scrollLeft;\n curY = container.scrollTop;\n maxW = container.scrollWidth;\n maxH = container.scrollHeight;\n viewW = container.clientWidth;\n viewH = container.clientHeight;\n }\n\n if (!reachedX && colIndex !== null && colIndex !== undefined) {\n const atLeft = curX <= tolerance && finalX <= tolerance;\n const atRight = curX >= maxW - viewW - tolerance && finalX >= maxW - viewW - tolerance;\n /* v8 ignore else -- @preserve */\n if (atLeft || atRight) {\n reachedX = true;\n }\n }\n\n if (!reachedY && rowIndex !== null && rowIndex !== undefined) {\n const atTop = curY <= tolerance && finalY <= tolerance;\n const atBottom = curY >= maxH - viewH - tolerance && finalY >= maxH - viewH - tolerance;\n if (atTop || atBottom) {\n reachedY = true;\n }\n }\n }\n }\n\n const scrollBehavior = isCorrection ? 'auto' : (behavior || 'smooth');\n isProgrammaticScroll.value = true;\n\n if (typeof window !== 'undefined' && container === window) {\n window.scrollTo({\n left: (colIndex === null || colIndex === undefined) ? undefined : Math.max(0, finalX),\n top: (rowIndex === null || rowIndex === undefined) ? undefined : Math.max(0, finalY),\n behavior: scrollBehavior,\n } as ScrollToOptions);\n } else if (isScrollableElement(container)) {\n const scrollOptions: ScrollToOptions = {\n behavior: scrollBehavior,\n };\n\n if (colIndex !== null && colIndex !== undefined) {\n scrollOptions.left = Math.max(0, finalX);\n }\n if (rowIndex !== null && rowIndex !== undefined) {\n scrollOptions.top = Math.max(0, finalY);\n }\n\n if (typeof container.scrollTo === 'function') {\n container.scrollTo(scrollOptions);\n } else {\n if (scrollOptions.left !== undefined) {\n container.scrollLeft = scrollOptions.left;\n }\n if (scrollOptions.top !== undefined) {\n container.scrollTop = scrollOptions.top;\n }\n }\n }\n\n if (scrollBehavior === 'auto' || scrollBehavior === undefined) {\n if (colIndex !== null && colIndex !== undefined) {\n scrollX.value = Math.max(0, finalX);\n }\n if (rowIndex !== null && rowIndex !== undefined) {\n scrollY.value = Math.max(0, finalY);\n }\n }\n\n if (reachedX && reachedY && !isScrolling.value) {\n pendingScroll.value = null;\n }\n };\n\n /**\n * Programmatically scroll to a specific pixel offset relative to the content start.\n *\n * @param x - The pixel offset to scroll to on the X axis. Pass null to keep current position.\n * @param y - The pixel offset to scroll to on the Y axis. Pass null to keep current position.\n * @param options - Scroll options (behavior)\n * @param options.behavior - The scroll behavior ('auto' | 'smooth')\n */\n const scrollToOffset = (x?: number | null, y?: number | null, options?: { behavior?: 'auto' | 'smooth'; }) => {\n const container = props.value.container || window;\n isProgrammaticScroll.value = true;\n\n const isVertical = props.value.direction === 'vertical' || props.value.direction === 'both';\n const isHorizontal = props.value.direction === 'horizontal' || props.value.direction === 'both';\n\n const paddingStartX = getPaddingX(props.value.scrollPaddingStart, props.value.direction);\n const paddingStartY = getPaddingY(props.value.scrollPaddingStart, props.value.direction);\n const paddingEndX = getPaddingX(props.value.scrollPaddingEnd, props.value.direction);\n const paddingEndY = getPaddingY(props.value.scrollPaddingEnd, props.value.direction);\n\n const usableWidth = viewportWidth.value - (isHorizontal ? (paddingStartX + paddingEndX) : 0);\n const usableHeight = viewportHeight.value - (isVertical ? (paddingStartY + paddingEndY) : 0);\n\n const clampedX = (x !== null && x !== undefined)\n ? (isHorizontal ? Math.max(0, Math.min(x, Math.max(0, totalWidth.value - usableWidth))) : Math.max(0, x))\n : null;\n const clampedY = (y !== null && y !== undefined)\n ? (isVertical ? Math.max(0, Math.min(y, Math.max(0, totalHeight.value - usableHeight))) : Math.max(0, y))\n : null;\n\n const currentX = (typeof window !== 'undefined' && container === window ? window.scrollX : (container as HTMLElement).scrollLeft);\n const currentY = (typeof window !== 'undefined' && container === window ? window.scrollY : (container as HTMLElement).scrollTop);\n\n const targetX = (clampedX !== null) ? clampedX + hostOffset.x - (isHorizontal ? paddingStartX : 0) : currentX;\n const targetY = (clampedY !== null) ? clampedY + hostOffset.y - (isVertical ? paddingStartY : 0) : currentY;\n\n if (typeof window !== 'undefined' && container === window) {\n window.scrollTo({\n left: (x !== null && x !== undefined) ? targetX : undefined,\n top: (y !== null && y !== undefined) ? targetY : undefined,\n behavior: options?.behavior || 'auto',\n } as ScrollToOptions);\n } else if (isScrollableElement(container)) {\n const scrollOptions: ScrollToOptions = {\n behavior: options?.behavior || 'auto',\n };\n\n if (x !== null && x !== undefined) {\n scrollOptions.left = targetX;\n }\n if (y !== null && y !== undefined) {\n scrollOptions.top = targetY;\n }\n\n if (typeof container.scrollTo === 'function') {\n container.scrollTo(scrollOptions);\n } else {\n if (scrollOptions.left !== undefined) {\n container.scrollLeft = scrollOptions.left;\n }\n if (scrollOptions.top !== undefined) {\n container.scrollTop = scrollOptions.top;\n }\n }\n }\n\n if (options?.behavior === 'auto' || options?.behavior === undefined) {\n if (x !== null && x !== undefined) {\n scrollX.value = targetX;\n }\n if (y !== null && y !== undefined) {\n scrollY.value = targetY;\n }\n }\n };\n\n // --- Measurement & Initialization ---\n const initializeSizes = () => {\n const newItems = props.value.items;\n const len = newItems.length;\n const colCount = props.value.columnCount || 0;\n\n itemSizesX.resize(len);\n itemSizesY.resize(len);\n columnSizes.resize(colCount);\n\n if (measuredItemsX.length !== len) {\n const newMeasuredX = new Uint8Array(len);\n newMeasuredX.set(measuredItemsX.subarray(0, Math.min(len, measuredItemsX.length)));\n measuredItemsX = newMeasuredX;\n }\n if (measuredItemsY.length !== len) {\n const newMeasuredY = new Uint8Array(len);\n newMeasuredY.set(measuredItemsY.subarray(0, Math.min(len, measuredItemsY.length)));\n measuredItemsY = newMeasuredY;\n }\n if (measuredColumns.length !== colCount) {\n const newMeasuredCols = new Uint8Array(colCount);\n newMeasuredCols.set(measuredColumns.subarray(0, Math.min(colCount, measuredColumns.length)));\n measuredColumns = newMeasuredCols;\n }\n\n let prependCount = 0;\n if (props.value.restoreScrollOnPrepend && lastItems.length > 0 && len > lastItems.length) {\n const oldFirstItem = lastItems[ 0 ];\n /* v8 ignore else -- @preserve */\n if (oldFirstItem !== undefined) {\n for (let i = 1; i <= len - lastItems.length; i++) {\n if (newItems[ i ] === oldFirstItem) {\n prependCount = i;\n break;\n }\n }\n }\n }\n\n if (prependCount > 0) {\n itemSizesX.shift(prependCount);\n itemSizesY.shift(prependCount);\n\n if (pendingScroll.value && pendingScroll.value.rowIndex !== null && pendingScroll.value.rowIndex !== undefined) {\n pendingScroll.value.rowIndex += prependCount;\n }\n\n const newMeasuredX = new Uint8Array(len);\n const newMeasuredY = new Uint8Array(len);\n newMeasuredX.set(measuredItemsX.subarray(0, Math.min(len - prependCount, measuredItemsX.length)), prependCount);\n newMeasuredY.set(measuredItemsY.subarray(0, Math.min(len - prependCount, measuredItemsY.length)), prependCount);\n measuredItemsX = newMeasuredX;\n measuredItemsY = newMeasuredY;\n\n // Calculate added size\n const gap = props.value.gap || 0;\n const columnGap = props.value.columnGap || 0;\n let addedX = 0;\n let addedY = 0;\n\n for (let i = 0; i < prependCount; i++) {\n const size = typeof props.value.itemSize === 'function'\n ? props.value.itemSize(newItems[ i ] as T, i)\n : defaultSize.value;\n\n if (props.value.direction === 'horizontal') {\n addedX += size + columnGap;\n } else {\n addedY += size + gap;\n }\n }\n\n /* v8 ignore else -- @preserve */\n if (addedX > 0 || addedY > 0) {\n nextTick(() => {\n scrollToOffset(\n addedX > 0 ? relativeScrollX.value + addedX : null,\n addedY > 0 ? relativeScrollY.value + addedY : null,\n { behavior: 'auto' },\n );\n });\n }\n }\n\n // Initialize columns if fixed width is provided\n if (colCount > 0) {\n const columnGap = props.value.columnGap || 0;\n let colNeedsRebuild = false;\n for (let i = 0; i < colCount; i++) {\n const width = getColumnWidth(i);\n const currentW = columnSizes.get(i);\n const isMeasured = measuredColumns[ i ] === 1;\n\n // If fixed/function, or if dynamic but not measured yet\n if (!isDynamicColumnWidth.value || !isMeasured || currentW === 0) {\n const targetW = width + columnGap;\n if (Math.abs(currentW - targetW) > 0.5) {\n columnSizes.set(i, targetW);\n measuredColumns[ i ] = isDynamicColumnWidth.value ? 0 : 1;\n colNeedsRebuild = true;\n } else if (!isDynamicColumnWidth.value) {\n measuredColumns[ i ] = 1;\n }\n }\n }\n if (colNeedsRebuild) {\n columnSizes.rebuild();\n }\n }\n\n const gap = props.value.gap || 0;\n const columnGap = props.value.columnGap || 0;\n let itemsNeedRebuild = false;\n\n for (let i = 0; i < len; i++) {\n const item = props.value.items[ i ];\n const currentX = itemSizesX.get(i);\n const currentY = itemSizesY.get(i);\n\n const size = typeof props.value.itemSize === 'function'\n ? props.value.itemSize(item as T, i)\n : defaultSize.value;\n\n const isVertical = props.value.direction === 'vertical';\n const isHorizontal = props.value.direction === 'horizontal';\n const isBoth = props.value.direction === 'both';\n\n const targetX = isHorizontal ? size + columnGap : 0;\n const targetY = (isVertical || isBoth) ? size + gap : 0;\n\n const isMeasuredX = measuredItemsX[ i ] === 1;\n const isMeasuredY = measuredItemsY[ i ] === 1;\n\n // Logic for X\n if (isHorizontal) {\n // If fixed/function, or if dynamic but not measured yet\n if (!isDynamicItemSize.value || !isMeasuredX || currentX === 0) {\n if (Math.abs(currentX - targetX) > 0.5) {\n itemSizesX.set(i, targetX);\n measuredItemsX[ i ] = isDynamicItemSize.value ? 0 : 1;\n itemsNeedRebuild = true;\n } else if (!isDynamicItemSize.value) {\n measuredItemsX[ i ] = 1;\n }\n }\n } else if (currentX !== 0) {\n itemSizesX.set(i, 0);\n measuredItemsX[ i ] = 0;\n itemsNeedRebuild = true;\n }\n\n // Logic for Y\n if (isVertical || isBoth) {\n if (!isDynamicItemSize.value || !isMeasuredY || currentY === 0) {\n if (Math.abs(currentY - targetY) > 0.5) {\n itemSizesY.set(i, targetY);\n measuredItemsY[ i ] = isDynamicItemSize.value ? 0 : 1;\n itemsNeedRebuild = true;\n } else if (!isDynamicItemSize.value) {\n measuredItemsY[ i ] = 1;\n }\n }\n } else if (currentY !== 0) {\n itemSizesY.set(i, 0);\n measuredItemsY[ i ] = 0;\n itemsNeedRebuild = true;\n }\n }\n\n if (itemsNeedRebuild) {\n itemSizesX.rebuild();\n itemSizesY.rebuild();\n }\n\n lastItems = [ ...newItems ];\n sizesInitialized.value = true;\n treeUpdateFlag.value++;\n };\n\n /**\n * Updates the host element's offset relative to the scroll container.\n */\n const updateHostOffset = () => {\n if (props.value.hostElement && typeof window !== 'undefined') {\n const rect = props.value.hostElement.getBoundingClientRect();\n const container = props.value.container || window;\n\n let newX = 0;\n let newY = 0;\n\n if (container === window) {\n newX = rect.left + window.scrollX;\n newY = rect.top + window.scrollY;\n } else if (container === props.value.hostElement) {\n newX = 0;\n newY = 0;\n } else if (isElement(container)) {\n const containerRect = container.getBoundingClientRect();\n newX = rect.left - containerRect.left + container.scrollLeft;\n newY = rect.top - containerRect.top + container.scrollTop;\n }\n\n if (Math.abs(hostOffset.x - newX) > 0.1 || Math.abs(hostOffset.y - newY) > 0.1) {\n hostOffset.x = newX;\n hostOffset.y = newY;\n }\n }\n };\n\n watch([\n () => props.value.items,\n () => props.value.direction,\n () => props.value.columnCount,\n () => props.value.columnWidth,\n () => props.value.itemSize,\n () => props.value.gap,\n () => props.value.columnGap,\n () => props.value.defaultItemSize,\n () => props.value.defaultColumnWidth,\n ], initializeSizes, { immediate: true });\n\n watch(() => [ props.value.container, props.value.hostElement ], () => {\n updateHostOffset();\n });\n\n // --- Range & Visible Items ---\n /**\n * Current range of items that should be rendered.\n */\n const range = computed(() => {\n // eslint-disable-next-line ts/no-unused-expressions\n treeUpdateFlag.value;\n\n if ((!isHydrated.value || isHydrating.value) && props.value.ssrRange) {\n return {\n start: props.value.ssrRange.start,\n end: props.value.ssrRange.end,\n };\n }\n\n const direction = props.value.direction || 'vertical';\n const bufferBefore = (props.value.ssrRange && !isScrolling.value) ? 0 : (props.value.bufferBefore ?? DEFAULT_BUFFER);\n const bufferAfter = props.value.bufferAfter ?? DEFAULT_BUFFER;\n const gap = props.value.gap || 0;\n const columnGap = props.value.columnGap || 0;\n const fixedSize = fixedItemSize.value;\n const paddingStartX = getPaddingX(props.value.scrollPaddingStart, direction);\n const paddingEndX = getPaddingX(props.value.scrollPaddingEnd, direction);\n const paddingStartY = getPaddingY(props.value.scrollPaddingStart, direction);\n const paddingEndY = getPaddingY(props.value.scrollPaddingEnd, direction);\n\n const isVertical = direction === 'vertical' || direction === 'both';\n const isHorizontal = direction === 'horizontal' || direction === 'both';\n\n const usableWidth = viewportWidth.value - (isHorizontal ? (paddingStartX + paddingEndX) : 0);\n const usableHeight = viewportHeight.value - (isVertical ? (paddingStartY + paddingEndY) : 0);\n\n let start = 0;\n let end = props.value.items.length;\n\n if (isVertical) {\n if (fixedSize !== null) {\n start = Math.floor(relativeScrollY.value / (fixedSize + gap));\n end = Math.ceil((relativeScrollY.value + usableHeight) / (fixedSize + gap));\n } else {\n start = itemSizesY.findLowerBound(relativeScrollY.value);\n let currentY = itemSizesY.query(start);\n let i = start;\n while (i < props.value.items.length && currentY < relativeScrollY.value + usableHeight) {\n currentY = itemSizesY.query(++i);\n }\n end = i;\n }\n } else {\n if (fixedSize !== null) {\n start = Math.floor(relativeScrollX.value / (fixedSize + columnGap));\n end = Math.ceil((relativeScrollX.value + usableWidth) / (fixedSize + columnGap));\n } else {\n start = itemSizesX.findLowerBound(relativeScrollX.value);\n let currentX = itemSizesX.query(start);\n let i = start;\n while (i < props.value.items.length && currentX < relativeScrollX.value + usableWidth) {\n currentX = itemSizesX.query(++i);\n }\n end = i;\n }\n }\n\n return {\n start: Math.max(0, start - bufferBefore),\n end: Math.min(props.value.items.length, end + bufferAfter),\n };\n });\n\n /**\n * Index of the first visible item in the viewport.\n */\n const currentIndex = computed(() => {\n // eslint-disable-next-line ts/no-unused-expressions\n treeUpdateFlag.value;\n\n const fixedSize = fixedItemSize.value;\n const gap = props.value.gap || 0;\n const columnGap = props.value.columnGap || 0;\n\n if (props.value.direction === 'horizontal') {\n if (fixedSize !== null) {\n return Math.floor(relativeScrollX.value / (fixedSize + columnGap));\n }\n return itemSizesX.findLowerBound(relativeScrollX.value);\n }\n if (fixedSize !== null) {\n return Math.floor(relativeScrollY.value / (fixedSize + gap));\n }\n return itemSizesY.findLowerBound(relativeScrollY.value);\n });\n\n /**\n * List of items to be rendered with their calculated offsets and sizes.\n */\n const renderedItems = computed<RenderedItem<T>[]>(() => {\n // eslint-disable-next-line ts/no-unused-expressions\n treeUpdateFlag.value;\n\n const { start, end } = range.value;\n const items: RenderedItem<T>[] = [];\n const fixedSize = fixedItemSize.value;\n const gap = props.value.gap || 0;\n const columnGap = props.value.columnGap || 0;\n const stickyIndices = sortedStickyIndices.value;\n\n // Always include relevant sticky items\n const indicesToRender = new Set<number>();\n for (let i = start; i < end; i++) {\n indicesToRender.add(i);\n }\n\n if (isHydrated.value || !props.value.ssrRange) {\n const activeIdx = currentIndex.value;\n // find the largest index in stickyIndices that is < activeIdx\n let prevStickyIdx: number | undefined;\n let low = 0;\n let high = stickyIndices.length - 1;\n while (low <= high) {\n const mid = (low + high) >>> 1;\n if (stickyIndices[ mid ]! < activeIdx) {\n prevStickyIdx = stickyIndices[ mid ];\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n\n if (prevStickyIdx !== undefined) {\n indicesToRender.add(prevStickyIdx);\n }\n\n for (const idx of stickyIndices) {\n if (idx >= start && idx < end) {\n indicesToRender.add(idx);\n }\n }\n }\n\n const sortedIndices = Array.from(indicesToRender).sort((a, b) => a - b);\n\n const ssrStartRow = props.value.ssrRange?.start || 0;\n const ssrStartCol = props.value.ssrRange?.colStart || 0;\n\n let ssrOffsetX = 0;\n let ssrOffsetY = 0;\n\n if (!isHydrated.value && props.value.ssrRange) {\n ssrOffsetY = (props.value.direction === 'vertical' || props.value.direction === 'both')\n ? (fixedSize !== null ? ssrStartRow * (fixedSize + gap) : itemSizesY.query(ssrStartRow))\n : 0;\n\n if (props.value.direction === 'horizontal') {\n ssrOffsetX = fixedSize !== null ? ssrStartCol * (fixedSize + columnGap) : itemSizesX.query(ssrStartCol);\n } else if (props.value.direction === 'both') {\n ssrOffsetX = columnSizes.query(ssrStartCol);\n }\n }\n\n for (const i of sortedIndices) {\n const item = props.value.items[ i ];\n if (item === undefined) {\n continue;\n }\n\n let x = 0;\n let y = 0;\n let width = 0;\n let height = 0;\n\n if (props.value.direction === 'horizontal') {\n x = fixedSize !== null ? i * (fixedSize + columnGap) : itemSizesX.query(i);\n width = fixedSize !== null ? fixedSize : itemSizesX.get(i) - columnGap;\n height = viewportHeight.value;\n } else {\n // vertical or both\n y = (props.value.direction === 'vertical' || props.value.direction === 'both') && fixedSize !== null ? i * (fixedSize + gap) : itemSizesY.query(i);\n height = fixedSize !== null ? fixedSize : itemSizesY.get(i) - gap;\n width = props.value.direction === 'both' ? totalWidth.value : viewportWidth.value;\n }\n\n const isSticky = stickyIndices.includes(i);\n const originalX = x;\n const originalY = y;\n let isStickyActive = false;\n const stickyOffset = { x: 0, y: 0 };\n\n if (isSticky) {\n if (props.value.direction === 'vertical' || props.value.direction === 'both') {\n if (relativeScrollY.value > originalY) {\n isStickyActive = true;\n // Check if next sticky item pushes this one\n let nextStickyIdx: number | undefined;\n let low = 0;\n let high = stickyIndices.length - 1;\n while (low <= high) {\n const mid = (low + high) >>> 1;\n if (stickyIndices[ mid ]! > i) {\n nextStickyIdx = stickyIndices[ mid ];\n high = mid - 1;\n } else {\n low = mid + 1;\n }\n }\n\n if (nextStickyIdx !== undefined) {\n const nextStickyY = fixedSize !== null ? nextStickyIdx * (fixedSize + gap) : itemSizesY.query(nextStickyIdx);\n const distance = nextStickyY - relativeScrollY.value;\n /* v8 ignore else -- @preserve */\n if (distance < height) {\n stickyOffset.y = -(height - distance);\n }\n }\n }\n } else if (props.value.direction === 'horizontal') {\n if (relativeScrollX.value > originalX) {\n isStickyActive = true;\n // Check if next sticky item pushes this one\n let nextStickyIdx: number | undefined;\n let low = 0;\n let high = stickyIndices.length - 1;\n while (low <= high) {\n const mid = (low + high) >>> 1;\n if (stickyIndices[ mid ]! > i) {\n nextStickyIdx = stickyIndices[ mid ];\n high = mid - 1;\n } else {\n low = mid + 1;\n }\n }\n\n if (nextStickyIdx !== undefined) {\n const nextStickyX = fixedSize !== null ? nextStickyIdx * (fixedSize + columnGap) : itemSizesX.query(nextStickyIdx);\n const distance = nextStickyX - relativeScrollX.value;\n /* v8 ignore else -- @preserve */\n if (distance < width) {\n stickyOffset.x = -(width - distance);\n }\n }\n }\n }\n }\n\n items.push({\n item,\n index: i,\n offset: { x: originalX - ssrOffsetX, y: originalY - ssrOffsetY },\n size: { width, height },\n originalX,\n originalY,\n isSticky,\n isStickyActive,\n stickyOffset,\n });\n }\n return items;\n });\n\n const columnRange = computed(() => {\n // eslint-disable-next-line ts/no-unused-expressions\n treeUpdateFlag.value;\n\n const totalCols = props.value.columnCount || 0;\n\n if (!totalCols) {\n return { start: 0, end: 0, padStart: 0, padEnd: 0 };\n }\n\n if ((!isHydrated.value || isHydrating.value) && props.value.ssrRange) {\n const { colStart = 0, colEnd = 0 } = props.value.ssrRange;\n const safeStart = Math.max(0, colStart);\n const safeEnd = Math.min(totalCols, colEnd || totalCols);\n return {\n start: safeStart,\n end: safeEnd,\n padStart: 0,\n padEnd: 0,\n };\n }\n\n const start = columnSizes.findLowerBound(relativeScrollX.value);\n let currentX = columnSizes.query(start);\n let end = start;\n\n while (end < totalCols && currentX < relativeScrollX.value + viewportWidth.value) {\n currentX = columnSizes.query(++end);\n }\n\n const colBuffer = (props.value.ssrRange && !isScrolling.value) ? 0 : 2;\n\n // Add buffer of columns\n const safeStart = Math.max(0, start - colBuffer);\n const safeEnd = Math.min(totalCols, end + colBuffer);\n\n const padStart = columnSizes.query(safeStart);\n\n return {\n start: safeStart,\n end: safeEnd,\n padStart,\n padEnd: columnSizes.query(totalCols) - columnSizes.query(safeEnd),\n };\n });\n\n /**\n * Detailed information about the current scroll state.\n */\n const scrollDetails = computed<ScrollDetails<T>>(() => {\n // eslint-disable-next-line ts/no-unused-expressions\n treeUpdateFlag.value;\n\n const fixedSize = fixedItemSize.value;\n const columnGap = props.value.columnGap || 0;\n\n let currentColIndex = 0;\n if (props.value.direction === 'horizontal' || props.value.direction === 'both') {\n if (fixedSize !== null) {\n currentColIndex = Math.floor(relativeScrollX.value / (fixedSize + columnGap));\n } else {\n currentColIndex = itemSizesX.findLowerBound(relativeScrollX.value);\n }\n }\n\n return {\n items: renderedItems.value,\n currentIndex: currentIndex.value,\n currentColIndex,\n scrollOffset: { x: relativeScrollX.value, y: relativeScrollY.value },\n viewportSize: { width: viewportWidth.value, height: viewportHeight.value },\n totalSize: { width: totalWidth.value, height: totalHeight.value },\n isScrolling: isScrolling.value,\n isProgrammaticScroll: isProgrammaticScroll.value,\n range: range.value,\n columnRange: columnRange.value,\n };\n });\n\n // --- Event Handlers & Lifecycle ---\n /**\n * Stops any currently active programmatic scroll and clears pending corrections.\n */\n const stopProgrammaticScroll = () => {\n isProgrammaticScroll.value = false;\n pendingScroll.value = null;\n };\n\n /**\n * Event handler for scroll events.\n */\n const handleScroll = (e: Event) => {\n const target = e.target;\n if (typeof window === 'undefined') {\n return;\n }\n\n if (target === window || target === document) {\n scrollX.value = window.scrollX;\n scrollY.value = window.scrollY;\n } else if (isScrollableElement(target)) {\n scrollX.value = target.scrollLeft;\n scrollY.value = target.scrollTop;\n }\n\n if (!isScrolling.value) {\n if (!isProgrammaticScroll.value) {\n pendingScroll.value = null;\n }\n isScrolling.value = true;\n }\n clearTimeout(scrollTimeout);\n scrollTimeout = setTimeout(() => {\n isScrolling.value = false;\n isProgrammaticScroll.value = false;\n }, 250);\n };\n\n /**\n * Updates the size of multiple items in the Fenwick tree.\n *\n * @param updates - Array of updates\n */\n const updateItemSizes = (updates: Array<{ index: number; inlineSize: number; blockSize: number; element?: HTMLElement | undefined; }>) => {\n let needUpdate = false;\n const gap = props.value.gap || 0;\n const columnGap = props.value.columnGap || 0;\n\n for (const { index, inlineSize, blockSize, element } of updates) {\n const isMeasurable = isDynamicItemSize.value || typeof props.value.itemSize === 'function';\n if (isMeasurable && index >= 0) {\n if (props.value.direction === 'horizontal') {\n const oldWidth = itemSizesX.get(index);\n const targetWidth = inlineSize + columnGap;\n // Apply if:\n // 1. It's the first measurement (measuredItemsX[index] is 0)\n // 2. It's a significant change (> 0.5px)\n /* v8 ignore else -- @preserve */\n if (!measuredItemsX[ index ] || Math.abs(targetWidth - oldWidth) > 0.5) {\n itemSizesX.update(index, targetWidth - oldWidth);\n measuredItemsX[ index ] = 1;\n needUpdate = true;\n }\n }\n if (props.value.direction === 'vertical' || props.value.direction === 'both') {\n const oldHeight = itemSizesY.get(index);\n const targetHeight = blockSize + gap;\n\n if (props.value.direction === 'both') {\n // For grid, we should be careful with decreases because a row height is the max of all its cells.\n /* v8 ignore else -- @preserve */\n if (!measuredItemsY[ index ] || Math.abs(targetHeight - oldHeight) > 0.5) {\n itemSizesY.update(index, targetHeight - oldHeight);\n measuredItemsY[ index ] = 1;\n needUpdate = true;\n }\n } else if (!measuredItemsY[ index ] || Math.abs(targetHeight - oldHeight) > 0.5) {\n itemSizesY.update(index, targetHeight - oldHeight);\n measuredItemsY[ index ] = 1;\n needUpdate = true;\n }\n }\n }\n\n // Dynamic column width measurement\n const isColMeasurable = isDynamicColumnWidth.value || typeof props.value.columnWidth === 'function';\n if (\n props.value.direction === 'both'\n && element\n && props.value.columnCount\n && isColMeasurable\n ) {\n const cells = element.dataset.colIndex !== undefined\n ? [ element ]\n : Array.from(element.querySelectorAll('[data-col-index]')) as HTMLElement[];\n\n for (const child of cells) {\n const colIndex = Number.parseInt(child.dataset.colIndex!, 10);\n\n /* v8 ignore else -- @preserve */\n if (colIndex >= 0 && colIndex < (props.value.columnCount || 0)) {\n const w = child.offsetWidth;\n const oldW = columnSizes.get(colIndex);\n const targetW = w + columnGap;\n if (Math.abs(oldW - targetW) > 0.5) {\n columnSizes.update(colIndex, targetW - oldW);\n measuredColumns[ colIndex ] = 1;\n needUpdate = true;\n }\n }\n }\n }\n }\n\n if (needUpdate) {\n treeUpdateFlag.value++;\n }\n };\n\n /**\n * Updates the size of a specific item in the Fenwick tree.\n *\n * @param index - Index of the item\n * @param inlineSize - New inlineSize\n * @param blockSize - New blockSize\n * @param element - The element that was measured (optional)\n */\n const updateItemSize = (index: number, inlineSize: number, blockSize: number, element?: HTMLElement) => {\n updateItemSizes([ { index, inlineSize, blockSize, element } ]);\n };\n\n // --- Scroll Queue / Correction Watchers ---\n const checkPendingScroll = () => {\n if (pendingScroll.value && !isHydrating.value) {\n const { rowIndex, colIndex, options } = pendingScroll.value;\n const correctionOptions: ScrollToIndexOptions = isScrollToIndexOptions(options)\n ? { ...options, isCorrection: true }\n : { align: options as ScrollAlignment | ScrollAlignmentOptions, isCorrection: true };\n scrollToIndex(rowIndex, colIndex, correctionOptions);\n }\n };\n\n watch(treeUpdateFlag, checkPendingScroll);\n\n watch(isScrolling, (scrolling) => {\n if (!scrolling) {\n checkPendingScroll();\n }\n });\n\n let resizeObserver: ResizeObserver | null = null;\n\n const attachEvents = (container: HTMLElement | Window | null) => {\n if (!container || typeof window === 'undefined') {\n return;\n }\n const scrollTarget = container === window ? document : container;\n scrollTarget.addEventListener('scroll', handleScroll, { passive: true });\n\n if (container === window) {\n viewportWidth.value = window.innerWidth;\n viewportHeight.value = window.innerHeight;\n scrollX.value = window.scrollX;\n scrollY.value = window.scrollY;\n\n const onResize = () => {\n viewportWidth.value = window.innerWidth;\n viewportHeight.value = window.innerHeight;\n updateHostOffset();\n };\n window.addEventListener('resize', onResize);\n return () => {\n scrollTarget.removeEventListener('scroll', handleScroll);\n window.removeEventListener('resize', onResize);\n };\n } else {\n viewportWidth.value = (container as HTMLElement).clientWidth;\n viewportHeight.value = (container as HTMLElement).clientHeight;\n scrollX.value = (container as HTMLElement).scrollLeft;\n scrollY.value = (container as HTMLElement).scrollTop;\n\n resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n /* v8 ignore else -- @preserve */\n if (entry.target === container) {\n viewportWidth.value = (container as HTMLElement).clientWidth;\n viewportHeight.value = (container as HTMLElement).clientHeight;\n updateHostOffset();\n }\n }\n });\n resizeObserver.observe(container as HTMLElement);\n return () => {\n scrollTarget.removeEventListener('scroll', handleScroll);\n resizeObserver?.disconnect();\n };\n }\n };\n\n let cleanup: (() => void) | undefined;\n\n if (getCurrentInstance()) {\n onMounted(() => {\n isMounted.value = true;\n\n watch(() => props.value.container, (newContainer) => {\n cleanup?.();\n cleanup = attachEvents(newContainer || null);\n }, { immediate: true });\n\n updateHostOffset();\n\n if (props.value.ssrRange || props.value.initialScrollIndex !== undefined) {\n nextTick(() => {\n updateHostOffset();\n const initialIndex = props.value.initialScrollIndex !== undefined\n ? props.value.initialScrollIndex\n : props.value.ssrRange?.start;\n const initialAlign = props.value.initialScrollAlign || 'start';\n\n /* v8 ignore else -- @preserve */\n if (initialIndex !== undefined && initialIndex !== null) {\n scrollToIndex(initialIndex, props.value.ssrRange?.colStart, { align: initialAlign, behavior: 'auto' });\n }\n\n isHydrated.value = true;\n isHydrating.value = true;\n nextTick(() => {\n isHydrating.value = false;\n });\n });\n } else {\n isHydrated.value = true;\n }\n });\n\n onUnmounted(() => {\n cleanup?.();\n });\n }\n\n /**\n * The list of items currently rendered in the DOM.\n */\n const refresh = () => {\n itemSizesX.resize(0);\n itemSizesY.resize(0);\n columnSizes.resize(0);\n measuredColumns.fill(0);\n measuredItemsX.fill(0);\n measuredItemsY.fill(0);\n initializeSizes();\n };\n\n return {\n /**\n * Array of items to be rendered with their calculated offsets and sizes.\n */\n renderedItems,\n /**\n * Total calculated width of all items including gaps.\n */\n totalWidth,\n /**\n * Total calculated height of all items including gaps.\n */\n totalHeight,\n /**\n * Detailed information about the current scroll state.\n * Includes currentIndex, scrollOffset, viewportSize, totalSize, and isScrolling.\n */\n scrollDetails,\n /**\n * Programmatically scroll to a specific row and/or column.\n * @param rowIndex - The row index to scroll to\n * @param colIndex - The column index to scroll to\n * @param options - Alignment and behavior options\n */\n scrollToIndex,\n /**\n * Programmatically scroll to a specific pixel offset.\n * @param x - The pixel offset to scroll to on the X axis\n * @param y - The pixel offset to scroll to on the Y axis\n * @param options - Behavior options\n */\n scrollToOffset,\n /**\n * Stops any currently active programmatic scroll and clears pending corrections.\n */\n stopProgrammaticScroll,\n /**\n * Updates the stored size of an item. Should be called when an item is measured (e.g., via ResizeObserver).\n * @param index - The item index\n * @param width - The measured width\n * @param height - The measured height\n * @param element - The measured element (optional, used for grid column detection)\n */\n updateItemSize,\n /**\n * Updates the stored size of multiple items. Should be called when items are measured (e.g., via ResizeObserver).\n * @param updates - Array of item updates\n */\n updateItemSizes,\n /**\n * Recalculates the host element's offset relative to the scroll container.\n */\n updateHostOffset,\n /**\n * Information about the current visible range of columns.\n */\n columnRange,\n /**\n * Helper to get the width of a specific column based on current configuration.\n * @param index - The column index\n */\n getColumnWidth,\n /**\n * Resets all dynamic measurements and re-initializes from props.\n */\n refresh,\n /**\n * Whether the component has finished its first client-side mount and hydration.\n */\n isHydrated,\n };\n}\n","<script setup lang=\"ts\" generic=\"T\">\nimport type {\n RenderedItem,\n ScrollAlignment,\n ScrollAlignmentOptions,\n ScrollDetails,\n VirtualScrollProps,\n} from '../composables/useVirtualScroll';\nimport type { VNodeChild } from 'vue';\n\nimport { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';\n\nimport {\n DEFAULT_ITEM_SIZE,\n useVirtualScroll,\n} from '../composables/useVirtualScroll';\nimport { getPaddingX, getPaddingY } from '../utils/scroll';\n\nexport interface Props<T = unknown> {\n /** Array of items to be virtualized. */\n items: T[];\n /** Fixed size of each item or a function that returns the size of an item. Pass 0, null or undefined for dynamic size detection. */\n itemSize?: number | ((item: T, index: number) => number) | null;\n /** Direction of the scroll: 'vertical', 'horizontal', or 'both' (grid). */\n direction?: 'vertical' | 'horizontal' | 'both';\n /** Number of items to render before the visible viewport. */\n bufferBefore?: number;\n /** Number of items to render after the visible viewport. */\n bufferAfter?: number;\n /** The scrollable container element or window. If not provided, the host element is used. */\n container?: HTMLElement | Window | null;\n /** Range of items to render for SSR. */\n ssrRange?: {\n start: number;\n end: number;\n colStart?: number;\n colEnd?: number;\n };\n /** Number of columns for bidirectional (grid) scroll. */\n columnCount?: number;\n /** Fixed width of columns or an array/function for column widths. Pass 0, null or undefined for dynamic width. */\n columnWidth?: number | number[] | ((index: number) => number) | null;\n /** The HTML tag to use for the container. */\n containerTag?: string;\n /** The HTML tag to use for the items wrapper. */\n wrapperTag?: string;\n /** The HTML tag to use for each item. */\n itemTag?: string;\n /** Padding at the start of the scroll container. */\n scrollPaddingStart?: number | { x?: number; y?: number; };\n /** Padding at the end of the scroll container. */\n scrollPaddingEnd?: number | { x?: number; y?: number; };\n /** Whether the header slot content is sticky and should be accounted for in scroll padding. If true, header size is automatically measured. */\n stickyHeader?: boolean;\n /** Whether the footer slot content is sticky and should be accounted for in scroll padding. If true, footer size is automatically measured. */\n stickyFooter?: boolean;\n /** Gap between items in pixels (vertical). */\n gap?: number;\n /** Gap between columns in pixels (horizontal/grid). */\n columnGap?: number;\n /** Indices of items that should stick to the top/start. Supports iOS-style pushing effect. */\n stickyIndices?: number[];\n /** Distance from the end of the scrollable area to trigger 'load' event in pixels. */\n loadDistance?: number;\n /** Whether items are currently being loaded. Prevents multiple 'load' events and shows 'loading' slot. */\n loading?: boolean;\n /** Whether to automatically restore scroll position when items are prepended to the list. */\n restoreScrollOnPrepend?: boolean;\n /** Initial scroll index to jump to on mount. */\n initialScrollIndex?: number;\n /** Alignment for the initial scroll index. */\n initialScrollAlign?: ScrollAlignment | ScrollAlignmentOptions;\n /** Default size for items before they are measured. */\n defaultItemSize?: number;\n /** Default width for columns before they are measured. */\n defaultColumnWidth?: number;\n /** Whether to show debug information (buffers and offsets). */\n debug?: boolean;\n}\n\nconst props = withDefaults(defineProps<Props<T>>(), {\n direction: 'vertical',\n bufferBefore: 5,\n bufferAfter: 5,\n columnCount: 0,\n containerTag: 'div',\n wrapperTag: 'div',\n itemTag: 'div',\n scrollPaddingStart: 0,\n scrollPaddingEnd: 0,\n stickyHeader: false,\n stickyFooter: false,\n gap: 0,\n columnGap: 0,\n stickyIndices: () => [],\n loadDistance: 200,\n loading: false,\n restoreScrollOnPrepend: false,\n debug: false,\n});\n\nconst emit = defineEmits<{\n (e: 'scroll', details: ScrollDetails<T>): void;\n (e: 'load', direction: 'vertical' | 'horizontal'): void;\n (e: 'visibleRangeChange', range: { start: number; end: number; colStart: number; colEnd: number; }): void;\n}>();\n\nconst slots = defineSlots<{\n /** Content rendered at the top of the scrollable area. Can be made sticky. */\n header?: (props: Record<string, never>) => VNodeChild;\n /** Slot for rendering each individual item. */\n item?: (props: {\n /** The data item being rendered. */\n item: T;\n /** The index of the item in the items array. */\n index: number;\n /** The current visible range of columns (for grid mode). */\n columnRange: { start: number; end: number; padStart: number; padEnd: number; };\n /** Function to get the width of a specific column. */\n getColumnWidth: (index: number) => number;\n /** Whether this item is configured to be sticky. */\n isSticky?: boolean | undefined;\n /** Whether this item is currently in a sticky state. */\n isStickyActive?: boolean | undefined;\n }) => VNodeChild;\n /** Content shown when `loading` prop is true. */\n loading?: (props: Record<string, never>) => VNodeChild;\n /** Content rendered at the bottom of the scrollable area. Can be made sticky. */\n footer?: (props: Record<string, never>) => VNodeChild;\n}>();\n\nconst hostRef = ref<HTMLElement | null>(null);\nconst wrapperRef = ref<HTMLElement | null>(null);\nconst headerRef = ref<HTMLElement | null>(null);\nconst footerRef = ref<HTMLElement | null>(null);\nconst itemRefs = new Map<number, HTMLElement>();\n\nconst measuredPaddingStart = ref(0);\nconst measuredPaddingEnd = ref(0);\n\nconst isHeaderFooterInsideContainer = computed(() => {\n const container = props.container === undefined\n ? hostRef.value\n : props.container;\n\n return container === hostRef.value\n || (typeof window !== 'undefined' && (container === window || container === null));\n});\n\nconst virtualScrollProps = computed(() => {\n const pStart = props.scrollPaddingStart;\n const pEnd = props.scrollPaddingEnd;\n\n /* v8 ignore start -- @preserve */\n const startX = typeof pStart === 'object'\n ? (pStart.x || 0)\n : (props.direction === 'horizontal' ? (pStart || 0) : 0);\n const startY = typeof pStart === 'object'\n ? (pStart.y || 0)\n : (props.direction !== 'horizontal' ? (pStart || 0) : 0);\n\n const endX = typeof pEnd === 'object'\n ? (pEnd.x || 0)\n : (props.direction === 'horizontal' ? (pEnd || 0) : 0);\n const endY = typeof pEnd === 'object'\n ? (pEnd.y || 0)\n : (props.direction !== 'horizontal' ? (pEnd || 0) : 0);\n /* v8 ignore stop -- @preserve */\n\n return {\n items: props.items,\n itemSize: props.itemSize,\n direction: props.direction,\n bufferBefore: props.bufferBefore,\n bufferAfter: props.bufferAfter,\n container: props.container === undefined\n ? hostRef.value\n : props.container,\n hostElement: wrapperRef.value,\n ssrRange: props.ssrRange,\n columnCount: props.columnCount,\n columnWidth: props.columnWidth,\n scrollPaddingStart: {\n x: startX,\n y: startY + (props.stickyHeader && isHeaderFooterInsideContainer.value ? measuredPaddingStart.value : 0),\n },\n scrollPaddingEnd: {\n x: endX,\n y: endY + (props.stickyFooter && isHeaderFooterInsideContainer.value ? measuredPaddingEnd.value : 0),\n },\n gap: props.gap,\n columnGap: props.columnGap,\n stickyIndices: props.stickyIndices,\n loadDistance: props.loadDistance,\n loading: props.loading,\n restoreScrollOnPrepend: props.restoreScrollOnPrepend,\n initialScrollIndex: props.initialScrollIndex,\n initialScrollAlign: props.initialScrollAlign,\n defaultItemSize: props.defaultItemSize,\n defaultColumnWidth: props.defaultColumnWidth,\n debug: props.debug,\n } as VirtualScrollProps<T>;\n});\n\nconst {\n isHydrated,\n columnRange,\n renderedItems,\n scrollDetails,\n totalHeight,\n totalWidth,\n getColumnWidth,\n scrollToIndex,\n scrollToOffset,\n updateHostOffset,\n updateItemSizes,\n refresh: coreRefresh,\n stopProgrammaticScroll,\n} = useVirtualScroll(virtualScrollProps);\n\n/**\n * Resets all dynamic measurements and re-initializes from props.\n * Also triggers manual re-measurement of all currently rendered items.\n */\nfunction refresh() {\n coreRefresh();\n nextTick(() => {\n const updates: { index: number; inlineSize: number; blockSize: number; element?: HTMLElement; }[] = [];\n\n for (const [ index, el ] of itemRefs.entries()) {\n /* v8 ignore else -- @preserve */\n if (el) {\n updates.push({\n index,\n inlineSize: el.offsetWidth,\n blockSize: el.offsetHeight,\n element: el,\n });\n }\n }\n\n if (updates.length > 0) {\n updateItemSizes(updates);\n }\n });\n}\n\n// Watch for scroll details and emit event\nwatch(scrollDetails, (details, oldDetails) => {\n if (!isHydrated.value) {\n return;\n }\n emit('scroll', details);\n\n if (\n !oldDetails\n || details.range.start !== oldDetails.range.start\n || details.range.end !== oldDetails.range.end\n || details.columnRange.start !== oldDetails.columnRange.start\n || details.columnRange.end !== oldDetails.columnRange.end\n ) {\n emit('visibleRangeChange', {\n start: details.range.start,\n end: details.range.end,\n colStart: details.columnRange.start,\n colEnd: details.columnRange.end,\n });\n }\n\n if (props.loading) {\n return;\n }\n\n // vertical or both\n if (props.direction !== 'horizontal') {\n const remaining = details.totalSize.height - (details.scrollOffset.y + details.viewportSize.height);\n if (remaining <= props.loadDistance) {\n emit('load', 'vertical');\n }\n }\n // horizontal or both\n if (props.direction !== 'vertical') {\n const remaining = details.totalSize.width - (details.scrollOffset.x + details.viewportSize.width);\n if (remaining <= props.loadDistance) {\n emit('load', 'horizontal');\n }\n }\n});\n\nwatch(isHydrated, (hydrated) => {\n /* v8 ignore else -- @preserve */\n if (hydrated) {\n emit('visibleRangeChange', {\n start: scrollDetails.value.range.start,\n end: scrollDetails.value.range.end,\n colStart: scrollDetails.value.columnRange.start,\n colEnd: scrollDetails.value.columnRange.end,\n });\n }\n}, { once: true });\n\n/* v8 ignore next 2 -- @preserve */\nconst hostResizeObserver = typeof window === 'undefined'\n ? null\n : new ResizeObserver(updateHostOffset);\n\n/* v8 ignore next 2 -- @preserve */\nconst itemResizeObserver = typeof window === 'undefined'\n ? null\n : new ResizeObserver((entries) => {\n const updates: { index: number; inlineSize: number; blockSize: number; element?: HTMLElement; }[] = [];\n\n for (const entry of entries) {\n const target = entry.target as HTMLElement;\n const index = Number(target.dataset.index);\n const colIndex = target.dataset.colIndex;\n\n if (colIndex !== undefined) {\n // It's a cell measurement. row index is not strictly needed for column width.\n // We use -1 as a placeholder for row index if it's a cell measurement.\n updates.push({ index: -1, inlineSize: 0, blockSize: 0, element: target });\n } else if (!Number.isNaN(index)) {\n let inlineSize = entry.contentRect.width;\n let blockSize = entry.contentRect.height;\n\n if (entry.borderBoxSize && entry.borderBoxSize.length > 0) {\n inlineSize = entry.borderBoxSize[ 0 ]!.inlineSize;\n blockSize = entry.borderBoxSize[ 0 ]!.blockSize;\n } else {\n // Fallback for older browsers or if borderBoxSize is missing\n inlineSize = target.offsetWidth;\n blockSize = target.offsetHeight;\n }\n\n updates.push({ index, inlineSize, blockSize, element: target });\n }\n }\n\n /* v8 ignore else -- @preserve */\n if (updates.length > 0) {\n updateItemSizes(updates);\n }\n });\n\n/* v8 ignore next 2 -- @preserve */\nconst extraResizeObserver = typeof window === 'undefined'\n ? null\n : new ResizeObserver(() => {\n measuredPaddingStart.value = headerRef.value?.offsetHeight || 0;\n measuredPaddingEnd.value = footerRef.value?.offsetHeight || 0;\n updateHostOffset();\n });\n\nwatch(headerRef, (newEl, oldEl) => {\n /* v8 ignore if -- @preserve */\n if (oldEl) {\n extraResizeObserver?.unobserve(oldEl);\n }\n if (newEl) {\n extraResizeObserver?.observe(newEl);\n }\n}, { immediate: true });\n\nwatch(footerRef, (newEl, oldEl) => {\n /* v8 ignore if -- @preserve */\n if (oldEl) {\n extraResizeObserver?.unobserve(oldEl);\n }\n if (newEl) {\n extraResizeObserver?.observe(newEl);\n }\n}, { immediate: true });\n\nconst firstRenderedIndex = computed(() => renderedItems.value[ 0 ]?.index);\nwatch(firstRenderedIndex, (newIdx, oldIdx) => {\n if (props.direction === 'both') {\n /* v8 ignore else -- @preserve */\n if (oldIdx !== undefined) {\n const oldEl = itemRefs.get(oldIdx);\n if (oldEl) {\n oldEl.querySelectorAll('[data-col-index]').forEach((c) => itemResizeObserver?.unobserve(c));\n }\n }\n if (newIdx !== undefined) {\n const newEl = itemRefs.get(newIdx);\n /* v8 ignore else -- @preserve */\n if (newEl) {\n newEl.querySelectorAll('[data-col-index]').forEach((c) => itemResizeObserver?.observe(c));\n }\n }\n }\n}, { flush: 'post' });\n\nonMounted(() => {\n /* v8 ignore else -- @preserve */\n if (hostRef.value) {\n hostResizeObserver?.observe(hostRef.value);\n }\n\n // Re-observe items that were set before observer was ready\n for (const el of itemRefs.values()) {\n itemResizeObserver?.observe(el);\n }\n\n // Observe cells of the first rendered item\n /* v8 ignore else -- @preserve */\n if (firstRenderedIndex.value !== undefined) {\n const el = itemRefs.get(firstRenderedIndex.value);\n /* v8 ignore else -- @preserve */\n if (el) {\n el.querySelectorAll('[data-col-index]').forEach((c) => itemResizeObserver?.observe(c));\n }\n }\n});\n\nwatch([ hostRef, wrapperRef ], ([ newHost ], [ oldHost ]) => {\n if (oldHost) {\n hostResizeObserver?.unobserve(oldHost);\n }\n if (newHost) {\n hostResizeObserver?.observe(newHost);\n }\n});\n\nfunction setItemRef(el: unknown, index: number) {\n if (el) {\n itemRefs.set(index, el as HTMLElement);\n itemResizeObserver?.observe(el as HTMLElement);\n } else {\n const oldEl = itemRefs.get(index);\n /* v8 ignore else -- @preserve */\n if (oldEl) {\n itemResizeObserver?.unobserve(oldEl);\n itemRefs.delete(index);\n }\n }\n}\n\nfunction handleKeyDown(event: KeyboardEvent) {\n stopProgrammaticScroll();\n const { viewportSize, scrollOffset } = scrollDetails.value;\n const isHorizontal = props.direction !== 'vertical';\n const isVertical = props.direction !== 'horizontal';\n\n if (event.key === 'Home') {\n event.preventDefault();\n scrollToIndex(0, 0, 'start');\n return;\n }\n if (event.key === 'End') {\n event.preventDefault();\n const lastItemIndex = props.items.length - 1;\n const lastColIndex = (props.columnCount || 0) > 0 ? props.columnCount - 1 : 0;\n\n if (isHorizontal) {\n if (isVertical) {\n scrollToIndex(lastItemIndex, lastColIndex, 'end');\n } else {\n scrollToIndex(0, lastItemIndex, 'end');\n }\n } else {\n scrollToIndex(lastItemIndex, 0, 'end');\n }\n return;\n }\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n scrollToOffset(null, scrollOffset.y - DEFAULT_ITEM_SIZE);\n return;\n }\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n scrollToOffset(null, scrollOffset.y + DEFAULT_ITEM_SIZE);\n return;\n }\n if (event.key === 'ArrowLeft') {\n event.preventDefault();\n scrollToOffset(scrollOffset.x - DEFAULT_ITEM_SIZE, null);\n return;\n }\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n scrollToOffset(scrollOffset.x + DEFAULT_ITEM_SIZE, null);\n return;\n }\n if (event.key === 'PageUp') {\n event.preventDefault();\n scrollToOffset(\n !isVertical && isHorizontal ? scrollOffset.x - viewportSize.width : null,\n isVertical ? scrollOffset.y - viewportSize.height : null,\n );\n return;\n }\n if (event.key === 'PageDown') {\n event.preventDefault();\n scrollToOffset(\n !isVertical && isHorizontal ? scrollOffset.x + viewportSize.width : null,\n isVertical ? scrollOffset.y + viewportSize.height : null,\n );\n }\n}\n\nonUnmounted(() => {\n hostResizeObserver?.disconnect();\n itemResizeObserver?.disconnect();\n extraResizeObserver?.disconnect();\n});\n\nconst isWindowContainer = computed(() => {\n const c = props.container;\n if (\n c === null\n // window\n || (typeof window !== 'undefined' && c === window)\n ) {\n return true;\n }\n\n // body\n if (c && typeof c === 'object' && 'tagName' in c) {\n return (c as HTMLElement).tagName === 'BODY';\n }\n\n return false;\n});\n\nconst containerStyle = computed(() => {\n if (isWindowContainer.value) {\n return {\n ...(props.direction !== 'vertical' ? { whiteSpace: 'nowrap' as const } : {}),\n };\n }\n\n if (props.containerTag === 'table') {\n return {\n minInlineSize: props.direction === 'vertical' ? '100%' : 'auto',\n };\n }\n\n return {\n ...(props.direction !== 'vertical' ? { whiteSpace: 'nowrap' as const } : {}),\n };\n});\n\nconst wrapperStyle = computed(() => ({\n inlineSize: props.direction === 'vertical' ? '100%' : `${ totalWidth.value }px`,\n blockSize: props.direction === 'horizontal' ? '100%' : `${ totalHeight.value }px`,\n}));\n\nconst loadingStyle = computed(() => {\n const isHorizontal = props.direction === 'horizontal';\n\n return {\n display: isHorizontal ? 'inline-block' : 'block',\n ...(isHorizontal ? { blockSize: '100%', verticalAlign: 'top' } : { inlineSize: '100%' }),\n };\n});\n\nconst spacerStyle = computed(() => ({\n inlineSize: props.direction === 'vertical' ? '1px' : `${ totalWidth.value }px`,\n blockSize: props.direction === 'horizontal' ? '1px' : `${ totalHeight.value }px`,\n}));\n\nfunction getItemStyle(item: RenderedItem<T>) {\n const isVertical = props.direction === 'vertical';\n const isHorizontal = props.direction === 'horizontal';\n const isBoth = props.direction === 'both';\n const isDynamic = props.itemSize === undefined || props.itemSize === null || props.itemSize === 0;\n\n const style: Record<string, string | number | undefined> = {\n blockSize: isHorizontal ? '100%' : (!isDynamic ? `${ item.size.height }px` : 'auto'),\n };\n\n if (isVertical && props.containerTag === 'table') {\n style.minInlineSize = '100%';\n } else {\n style.inlineSize = isVertical ? '100%' : (!isDynamic ? `${ item.size.width }px` : 'auto');\n }\n\n if (isDynamic) {\n if (!isVertical) {\n style.minInlineSize = '1px';\n }\n if (!isHorizontal) {\n style.minBlockSize = '1px';\n }\n }\n\n if (isHydrated.value) {\n if (item.isStickyActive) {\n if (isVertical || isBoth) {\n style.insetBlockStart = `${ getPaddingY(props.scrollPaddingStart, props.direction) }px`;\n }\n\n if (isHorizontal || isBoth) {\n style.insetInlineStart = `${ getPaddingX(props.scrollPaddingStart, props.direction) }px`;\n }\n\n style.transform = `translate(${ item.stickyOffset.x }px, ${ item.stickyOffset.y }px)`;\n } else {\n style.transform = `translate(${ item.offset.x }px, ${ item.offset.y }px)`;\n }\n }\n\n return style;\n}\n\nconst isDebug = computed(() => props.debug);\nconst isTable = computed(() => props.containerTag === 'table');\nconst headerTag = computed(() => isTable.value ? 'thead' : 'div');\nconst footerTag = computed(() => isTable.value ? 'tfoot' : 'div');\n\ndefineExpose({\n scrollDetails,\n columnRange,\n getColumnWidth,\n scrollToIndex,\n scrollToOffset,\n refresh,\n stopProgrammaticScroll,\n});\n</script>\n\n<template>\n <component\n :is=\"containerTag\"\n ref=\"hostRef\"\n class=\"virtual-scroll-container\"\n :class=\"[\n `virtual-scroll--${ direction }`,\n {\n 'virtual-scroll--hydrated': isHydrated,\n 'virtual-scroll--window': isWindowContainer,\n 'virtual-scroll--table': isTable,\n },\n ]\"\n :style=\"containerStyle\"\n tabindex=\"0\"\n @keydown=\"handleKeyDown\"\n @wheel.passive=\"stopProgrammaticScroll\"\n @pointerdown.passive=\"stopProgrammaticScroll\"\n @touchstart.passive=\"stopProgrammaticScroll\"\n >\n <!-- v8 ignore start -->\n <component\n :is=\"headerTag\"\n v-if=\"slots.header\"\n ref=\"headerRef\"\n class=\"virtual-scroll-header\"\n :class=\"{ 'virtual-scroll--sticky': stickyHeader }\"\n >\n <slot name=\"header\" />\n </component>\n <!-- v8 ignore stop -->\n\n <component\n :is=\"wrapperTag\"\n ref=\"wrapperRef\"\n class=\"virtual-scroll-wrapper\"\n :style=\"wrapperStyle\"\n >\n <!-- Phantom element to push scroll height -->\n <!-- v8 ignore start -->\n <component\n :is=\"itemTag\"\n v-if=\"isTable\"\n class=\"virtual-scroll-spacer\"\n :style=\"spacerStyle\"\n >\n <td style=\"padding: 0; border: none; block-size: inherit;\" />\n </component>\n <!-- v8 ignore stop -->\n\n <component\n :is=\"itemTag\"\n v-for=\"renderedItem in renderedItems\"\n :key=\"renderedItem.index\"\n :ref=\"(el: unknown) => setItemRef(el, renderedItem.index)\"\n :data-index=\"renderedItem.index\"\n class=\"virtual-scroll-item\"\n :class=\"{\n 'virtual-scroll--sticky': renderedItem.isStickyActive,\n 'virtual-scroll--debug': isDebug,\n }\"\n :style=\"getItemStyle(renderedItem)\"\n >\n <slot\n name=\"item\"\n :item=\"renderedItem.item\"\n :index=\"renderedItem.index\"\n :column-range=\"columnRange\"\n :get-column-width=\"getColumnWidth\"\n :is-sticky=\"renderedItem.isSticky\"\n :is-sticky-active=\"renderedItem.isStickyActive\"\n />\n <div v-if=\"isDebug\" class=\"virtual-scroll-debug-info\">\n #{{ renderedItem.index }} ({{ Math.round(renderedItem.offset.x) }}, {{ Math.round(renderedItem.offset.y) }})\n </div>\n </component>\n </component>\n\n <!-- v8 ignore start -->\n <div\n v-if=\"loading && slots.loading\"\n class=\"virtual-scroll-loading\"\n :style=\"loadingStyle\"\n >\n <slot name=\"loading\" />\n </div>\n\n <component\n :is=\"footerTag\"\n v-if=\"slots.footer\"\n ref=\"footerRef\"\n class=\"virtual-scroll-footer\"\n :class=\"{ 'virtual-scroll--sticky': stickyFooter }\"\n >\n <slot name=\"footer\" />\n </component>\n <!-- v8 ignore stop -->\n </component>\n</template>\n\n<style scoped>\n.virtual-scroll-container {\n position: relative;\n block-size: 100%;\n inline-size: 100%;\n outline-offset: 1px;\n\n &:not(.virtual-scroll--window) {\n overflow: auto;\n overscroll-behavior: contain;\n }\n\n &.virtual-scroll--table {\n display: block;\n }\n}\n\n.virtual-scroll--horizontal {\n white-space: nowrap;\n}\n\n.virtual-scroll-wrapper {\n contain: layout;\n position: relative;\n\n :where(.virtual-scroll--hydrated > & > .virtual-scroll-item) {\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n }\n}\n\n.virtual-scroll-item {\n box-sizing: border-box;\n will-change: transform;\n\n &:where(.virtual-scroll--debug) {\n outline: 1px dashed rgba(255, 0, 0, 0.5);\n background-color: rgba(255, 0, 0, 0.05);\n\n &:where(:hover) {\n background-color: rgba(255, 0, 0, 0.1);\n z-index: 100;\n }\n }\n}\n\n.virtual-scroll-debug-info {\n position: absolute;\n inset-block-start: 2px;\n inset-inline-end: 2px;\n background: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 10px;\n padding: 2px 4px;\n border-radius: 4px;\n pointer-events: none;\n z-index: 100;\n font-family: monospace;\n}\n\n.virtual-scroll-spacer {\n pointer-events: none;\n}\n\n.virtual-scroll-header,\n.virtual-scroll-footer {\n position: relative;\n z-index: 20;\n}\n\n.virtual-scroll--sticky {\n position: sticky;\n\n &:where(.virtual-scroll-header) {\n inset-block-start: 0;\n inset-inline-start: 0;\n min-inline-size: 100%;\n box-sizing: border-box;\n }\n\n &:where(.virtual-scroll-footer) {\n inset-block-end: 0;\n inset-inline-start: 0;\n min-inline-size: 100%;\n box-sizing: border-box;\n }\n\n &:where(.virtual-scroll-item) {\n z-index: 10;\n }\n}\n\n:is(tbody.virtual-scroll-wrapper, thead.virtual-scroll-header, tfoot.virtual-scroll-footer) {\n display: inline-flex;\n min-inline-size: 100%;\n & > :deep(tr) {\n display: inline-flex;\n min-inline-size: 100%;\n\n & > :is(td, th) {\n display: inline-block;\n align-items: center;\n }\n }\n}\n</style>\n","<script setup lang=\"ts\" generic=\"T\">\nimport type {\n RenderedItem,\n ScrollAlignment,\n ScrollAlignmentOptions,\n ScrollDetails,\n VirtualScrollProps,\n} from '../composables/useVirtualScroll';\nimport type { VNodeChild } from 'vue';\n\nimport { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';\n\nimport {\n DEFAULT_ITEM_SIZE,\n useVirtualScroll,\n} from '../composables/useVirtualScroll';\nimport { getPaddingX, getPaddingY } from '../utils/scroll';\n\nexport interface Props<T = unknown> {\n /** Array of items to be virtualized. */\n items: T[];\n /** Fixed size of each item or a function that returns the size of an item. Pass 0, null or undefined for dynamic size detection. */\n itemSize?: number | ((item: T, index: number) => number) | null;\n /** Direction of the scroll: 'vertical', 'horizontal', or 'both' (grid). */\n direction?: 'vertical' | 'horizontal' | 'both';\n /** Number of items to render before the visible viewport. */\n bufferBefore?: number;\n /** Number of items to render after the visible viewport. */\n bufferAfter?: number;\n /** The scrollable container element or window. If not provided, the host element is used. */\n container?: HTMLElement | Window | null;\n /** Range of items to render for SSR. */\n ssrRange?: {\n start: number;\n end: number;\n colStart?: number;\n colEnd?: number;\n };\n /** Number of columns for bidirectional (grid) scroll. */\n columnCount?: number;\n /** Fixed width of columns or an array/function for column widths. Pass 0, null or undefined for dynamic width. */\n columnWidth?: number | number[] | ((index: number) => number) | null;\n /** The HTML tag to use for the container. */\n containerTag?: string;\n /** The HTML tag to use for the items wrapper. */\n wrapperTag?: string;\n /** The HTML tag to use for each item. */\n itemTag?: string;\n /** Padding at the start of the scroll container. */\n scrollPaddingStart?: number | { x?: number; y?: number; };\n /** Padding at the end of the scroll container. */\n scrollPaddingEnd?: number | { x?: number; y?: number; };\n /** Whether the header slot content is sticky and should be accounted for in scroll padding. If true, header size is automatically measured. */\n stickyHeader?: boolean;\n /** Whether the footer slot content is sticky and should be accounted for in scroll padding. If true, footer size is automatically measured. */\n stickyFooter?: boolean;\n /** Gap between items in pixels (vertical). */\n gap?: number;\n /** Gap between columns in pixels (horizontal/grid). */\n columnGap?: number;\n /** Indices of items that should stick to the top/start. Supports iOS-style pushing effect. */\n stickyIndices?: number[];\n /** Distance from the end of the scrollable area to trigger 'load' event in pixels. */\n loadDistance?: number;\n /** Whether items are currently being loaded. Prevents multiple 'load' events and shows 'loading' slot. */\n loading?: boolean;\n /** Whether to automatically restore scroll position when items are prepended to the list. */\n restoreScrollOnPrepend?: boolean;\n /** Initial scroll index to jump to on mount. */\n initialScrollIndex?: number;\n /** Alignment for the initial scroll index. */\n initialScrollAlign?: ScrollAlignment | ScrollAlignmentOptions;\n /** Default size for items before they are measured. */\n defaultItemSize?: number;\n /** Default width for columns before they are measured. */\n defaultColumnWidth?: number;\n /** Whether to show debug information (buffers and offsets). */\n debug?: boolean;\n}\n\nconst props = withDefaults(defineProps<Props<T>>(), {\n direction: 'vertical',\n bufferBefore: 5,\n bufferAfter: 5,\n columnCount: 0,\n containerTag: 'div',\n wrapperTag: 'div',\n itemTag: 'div',\n scrollPaddingStart: 0,\n scrollPaddingEnd: 0,\n stickyHeader: false,\n stickyFooter: false,\n gap: 0,\n columnGap: 0,\n stickyIndices: () => [],\n loadDistance: 200,\n loading: false,\n restoreScrollOnPrepend: false,\n debug: false,\n});\n\nconst emit = defineEmits<{\n (e: 'scroll', details: ScrollDetails<T>): void;\n (e: 'load', direction: 'vertical' | 'horizontal'): void;\n (e: 'visibleRangeChange', range: { start: number; end: number; colStart: number; colEnd: number; }): void;\n}>();\n\nconst slots = defineSlots<{\n /** Content rendered at the top of the scrollable area. Can be made sticky. */\n header?: (props: Record<string, never>) => VNodeChild;\n /** Slot for rendering each individual item. */\n item?: (props: {\n /** The data item being rendered. */\n item: T;\n /** The index of the item in the items array. */\n index: number;\n /** The current visible range of columns (for grid mode). */\n columnRange: { start: number; end: number; padStart: number; padEnd: number; };\n /** Function to get the width of a specific column. */\n getColumnWidth: (index: number) => number;\n /** Whether this item is configured to be sticky. */\n isSticky?: boolean | undefined;\n /** Whether this item is currently in a sticky state. */\n isStickyActive?: boolean | undefined;\n }) => VNodeChild;\n /** Content shown when `loading` prop is true. */\n loading?: (props: Record<string, never>) => VNodeChild;\n /** Content rendered at the bottom of the scrollable area. Can be made sticky. */\n footer?: (props: Record<string, never>) => VNodeChild;\n}>();\n\nconst hostRef = ref<HTMLElement | null>(null);\nconst wrapperRef = ref<HTMLElement | null>(null);\nconst headerRef = ref<HTMLElement | null>(null);\nconst footerRef = ref<HTMLElement | null>(null);\nconst itemRefs = new Map<number, HTMLElement>();\n\nconst measuredPaddingStart = ref(0);\nconst measuredPaddingEnd = ref(0);\n\nconst isHeaderFooterInsideContainer = computed(() => {\n const container = props.container === undefined\n ? hostRef.value\n : props.container;\n\n return container === hostRef.value\n || (typeof window !== 'undefined' && (container === window || container === null));\n});\n\nconst virtualScrollProps = computed(() => {\n const pStart = props.scrollPaddingStart;\n const pEnd = props.scrollPaddingEnd;\n\n /* v8 ignore start -- @preserve */\n const startX = typeof pStart === 'object'\n ? (pStart.x || 0)\n : (props.direction === 'horizontal' ? (pStart || 0) : 0);\n const startY = typeof pStart === 'object'\n ? (pStart.y || 0)\n : (props.direction !== 'horizontal' ? (pStart || 0) : 0);\n\n const endX = typeof pEnd === 'object'\n ? (pEnd.x || 0)\n : (props.direction === 'horizontal' ? (pEnd || 0) : 0);\n const endY = typeof pEnd === 'object'\n ? (pEnd.y || 0)\n : (props.direction !== 'horizontal' ? (pEnd || 0) : 0);\n /* v8 ignore stop -- @preserve */\n\n return {\n items: props.items,\n itemSize: props.itemSize,\n direction: props.direction,\n bufferBefore: props.bufferBefore,\n bufferAfter: props.bufferAfter,\n container: props.container === undefined\n ? hostRef.value\n : props.container,\n hostElement: wrapperRef.value,\n ssrRange: props.ssrRange,\n columnCount: props.columnCount,\n columnWidth: props.columnWidth,\n scrollPaddingStart: {\n x: startX,\n y: startY + (props.stickyHeader && isHeaderFooterInsideContainer.value ? measuredPaddingStart.value : 0),\n },\n scrollPaddingEnd: {\n x: endX,\n y: endY + (props.stickyFooter && isHeaderFooterInsideContainer.value ? measuredPaddingEnd.value : 0),\n },\n gap: props.gap,\n columnGap: props.columnGap,\n stickyIndices: props.stickyIndices,\n loadDistance: props.loadDistance,\n loading: props.loading,\n restoreScrollOnPrepend: props.restoreScrollOnPrepend,\n initialScrollIndex: props.initialScrollIndex,\n initialScrollAlign: props.initialScrollAlign,\n defaultItemSize: props.defaultItemSize,\n defaultColumnWidth: props.defaultColumnWidth,\n debug: props.debug,\n } as VirtualScrollProps<T>;\n});\n\nconst {\n isHydrated,\n columnRange,\n renderedItems,\n scrollDetails,\n totalHeight,\n totalWidth,\n getColumnWidth,\n scrollToIndex,\n scrollToOffset,\n updateHostOffset,\n updateItemSizes,\n refresh: coreRefresh,\n stopProgrammaticScroll,\n} = useVirtualScroll(virtualScrollProps);\n\n/**\n * Resets all dynamic measurements and re-initializes from props.\n * Also triggers manual re-measurement of all currently rendered items.\n */\nfunction refresh() {\n coreRefresh();\n nextTick(() => {\n const updates: { index: number; inlineSize: number; blockSize: number; element?: HTMLElement; }[] = [];\n\n for (const [ index, el ] of itemRefs.entries()) {\n /* v8 ignore else -- @preserve */\n if (el) {\n updates.push({\n index,\n inlineSize: el.offsetWidth,\n blockSize: el.offsetHeight,\n element: el,\n });\n }\n }\n\n if (updates.length > 0) {\n updateItemSizes(updates);\n }\n });\n}\n\n// Watch for scroll details and emit event\nwatch(scrollDetails, (details, oldDetails) => {\n if (!isHydrated.value) {\n return;\n }\n emit('scroll', details);\n\n if (\n !oldDetails\n || details.range.start !== oldDetails.range.start\n || details.range.end !== oldDetails.range.end\n || details.columnRange.start !== oldDetails.columnRange.start\n || details.columnRange.end !== oldDetails.columnRange.end\n ) {\n emit('visibleRangeChange', {\n start: details.range.start,\n end: details.range.end,\n colStart: details.columnRange.start,\n colEnd: details.columnRange.end,\n });\n }\n\n if (props.loading) {\n return;\n }\n\n // vertical or both\n if (props.direction !== 'horizontal') {\n const remaining = details.totalSize.height - (details.scrollOffset.y + details.viewportSize.height);\n if (remaining <= props.loadDistance) {\n emit('load', 'vertical');\n }\n }\n // horizontal or both\n if (props.direction !== 'vertical') {\n const remaining = details.totalSize.width - (details.scrollOffset.x + details.viewportSize.width);\n if (remaining <= props.loadDistance) {\n emit('load', 'horizontal');\n }\n }\n});\n\nwatch(isHydrated, (hydrated) => {\n /* v8 ignore else -- @preserve */\n if (hydrated) {\n emit('visibleRangeChange', {\n start: scrollDetails.value.range.start,\n end: scrollDetails.value.range.end,\n colStart: scrollDetails.value.columnRange.start,\n colEnd: scrollDetails.value.columnRange.end,\n });\n }\n}, { once: true });\n\n/* v8 ignore next 2 -- @preserve */\nconst hostResizeObserver = typeof window === 'undefined'\n ? null\n : new ResizeObserver(updateHostOffset);\n\n/* v8 ignore next 2 -- @preserve */\nconst itemResizeObserver = typeof window === 'undefined'\n ? null\n : new ResizeObserver((entries) => {\n const updates: { index: number; inlineSize: number; blockSize: number; element?: HTMLElement; }[] = [];\n\n for (const entry of entries) {\n const target = entry.target as HTMLElement;\n const index = Number(target.dataset.index);\n const colIndex = target.dataset.colIndex;\n\n if (colIndex !== undefined) {\n // It's a cell measurement. row index is not strictly needed for column width.\n // We use -1 as a placeholder for row index if it's a cell measurement.\n updates.push({ index: -1, inlineSize: 0, blockSize: 0, element: target });\n } else if (!Number.isNaN(index)) {\n let inlineSize = entry.contentRect.width;\n let blockSize = entry.contentRect.height;\n\n if (entry.borderBoxSize && entry.borderBoxSize.length > 0) {\n inlineSize = entry.borderBoxSize[ 0 ]!.inlineSize;\n blockSize = entry.borderBoxSize[ 0 ]!.blockSize;\n } else {\n // Fallback for older browsers or if borderBoxSize is missing\n inlineSize = target.offsetWidth;\n blockSize = target.offsetHeight;\n }\n\n updates.push({ index, inlineSize, blockSize, element: target });\n }\n }\n\n /* v8 ignore else -- @preserve */\n if (updates.length > 0) {\n updateItemSizes(updates);\n }\n });\n\n/* v8 ignore next 2 -- @preserve */\nconst extraResizeObserver = typeof window === 'undefined'\n ? null\n : new ResizeObserver(() => {\n measuredPaddingStart.value = headerRef.value?.offsetHeight || 0;\n measuredPaddingEnd.value = footerRef.value?.offsetHeight || 0;\n updateHostOffset();\n });\n\nwatch(headerRef, (newEl, oldEl) => {\n /* v8 ignore if -- @preserve */\n if (oldEl) {\n extraResizeObserver?.unobserve(oldEl);\n }\n if (newEl) {\n extraResizeObserver?.observe(newEl);\n }\n}, { immediate: true });\n\nwatch(footerRef, (newEl, oldEl) => {\n /* v8 ignore if -- @preserve */\n if (oldEl) {\n extraResizeObserver?.unobserve(oldEl);\n }\n if (newEl) {\n extraResizeObserver?.observe(newEl);\n }\n}, { immediate: true });\n\nconst firstRenderedIndex = computed(() => renderedItems.value[ 0 ]?.index);\nwatch(firstRenderedIndex, (newIdx, oldIdx) => {\n if (props.direction === 'both') {\n /* v8 ignore else -- @preserve */\n if (oldIdx !== undefined) {\n const oldEl = itemRefs.get(oldIdx);\n if (oldEl) {\n oldEl.querySelectorAll('[data-col-index]').forEach((c) => itemResizeObserver?.unobserve(c));\n }\n }\n if (newIdx !== undefined) {\n const newEl = itemRefs.get(newIdx);\n /* v8 ignore else -- @preserve */\n if (newEl) {\n newEl.querySelectorAll('[data-col-index]').forEach((c) => itemResizeObserver?.observe(c));\n }\n }\n }\n}, { flush: 'post' });\n\nonMounted(() => {\n /* v8 ignore else -- @preserve */\n if (hostRef.value) {\n hostResizeObserver?.observe(hostRef.value);\n }\n\n // Re-observe items that were set before observer was ready\n for (const el of itemRefs.values()) {\n itemResizeObserver?.observe(el);\n }\n\n // Observe cells of the first rendered item\n /* v8 ignore else -- @preserve */\n if (firstRenderedIndex.value !== undefined) {\n const el = itemRefs.get(firstRenderedIndex.value);\n /* v8 ignore else -- @preserve */\n if (el) {\n el.querySelectorAll('[data-col-index]').forEach((c) => itemResizeObserver?.observe(c));\n }\n }\n});\n\nwatch([ hostRef, wrapperRef ], ([ newHost ], [ oldHost ]) => {\n if (oldHost) {\n hostResizeObserver?.unobserve(oldHost);\n }\n if (newHost) {\n hostResizeObserver?.observe(newHost);\n }\n});\n\nfunction setItemRef(el: unknown, index: number) {\n if (el) {\n itemRefs.set(index, el as HTMLElement);\n itemResizeObserver?.observe(el as HTMLElement);\n } else {\n const oldEl = itemRefs.get(index);\n /* v8 ignore else -- @preserve */\n if (oldEl) {\n itemResizeObserver?.unobserve(oldEl);\n itemRefs.delete(index);\n }\n }\n}\n\nfunction handleKeyDown(event: KeyboardEvent) {\n stopProgrammaticScroll();\n const { viewportSize, scrollOffset } = scrollDetails.value;\n const isHorizontal = props.direction !== 'vertical';\n const isVertical = props.direction !== 'horizontal';\n\n if (event.key === 'Home') {\n event.preventDefault();\n scrollToIndex(0, 0, 'start');\n return;\n }\n if (event.key === 'End') {\n event.preventDefault();\n const lastItemIndex = props.items.length - 1;\n const lastColIndex = (props.columnCount || 0) > 0 ? props.columnCount - 1 : 0;\n\n if (isHorizontal) {\n if (isVertical) {\n scrollToIndex(lastItemIndex, lastColIndex, 'end');\n } else {\n scrollToIndex(0, lastItemIndex, 'end');\n }\n } else {\n scrollToIndex(lastItemIndex, 0, 'end');\n }\n return;\n }\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n scrollToOffset(null, scrollOffset.y - DEFAULT_ITEM_SIZE);\n return;\n }\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n scrollToOffset(null, scrollOffset.y + DEFAULT_ITEM_SIZE);\n return;\n }\n if (event.key === 'ArrowLeft') {\n event.preventDefault();\n scrollToOffset(scrollOffset.x - DEFAULT_ITEM_SIZE, null);\n return;\n }\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n scrollToOffset(scrollOffset.x + DEFAULT_ITEM_SIZE, null);\n return;\n }\n if (event.key === 'PageUp') {\n event.preventDefault();\n scrollToOffset(\n !isVertical && isHorizontal ? scrollOffset.x - viewportSize.width : null,\n isVertical ? scrollOffset.y - viewportSize.height : null,\n );\n return;\n }\n if (event.key === 'PageDown') {\n event.preventDefault();\n scrollToOffset(\n !isVertical && isHorizontal ? scrollOffset.x + viewportSize.width : null,\n isVertical ? scrollOffset.y + viewportSize.height : null,\n );\n }\n}\n\nonUnmounted(() => {\n hostResizeObserver?.disconnect();\n itemResizeObserver?.disconnect();\n extraResizeObserver?.disconnect();\n});\n\nconst isWindowContainer = computed(() => {\n const c = props.container;\n if (\n c === null\n // window\n || (typeof window !== 'undefined' && c === window)\n ) {\n return true;\n }\n\n // body\n if (c && typeof c === 'object' && 'tagName' in c) {\n return (c as HTMLElement).tagName === 'BODY';\n }\n\n return false;\n});\n\nconst containerStyle = computed(() => {\n if (isWindowContainer.value) {\n return {\n ...(props.direction !== 'vertical' ? { whiteSpace: 'nowrap' as const } : {}),\n };\n }\n\n if (props.containerTag === 'table') {\n return {\n minInlineSize: props.direction === 'vertical' ? '100%' : 'auto',\n };\n }\n\n return {\n ...(props.direction !== 'vertical' ? { whiteSpace: 'nowrap' as const } : {}),\n };\n});\n\nconst wrapperStyle = computed(() => ({\n inlineSize: props.direction === 'vertical' ? '100%' : `${ totalWidth.value }px`,\n blockSize: props.direction === 'horizontal' ? '100%' : `${ totalHeight.value }px`,\n}));\n\nconst loadingStyle = computed(() => {\n const isHorizontal = props.direction === 'horizontal';\n\n return {\n display: isHorizontal ? 'inline-block' : 'block',\n ...(isHorizontal ? { blockSize: '100%', verticalAlign: 'top' } : { inlineSize: '100%' }),\n };\n});\n\nconst spacerStyle = computed(() => ({\n inlineSize: props.direction === 'vertical' ? '1px' : `${ totalWidth.value }px`,\n blockSize: props.direction === 'horizontal' ? '1px' : `${ totalHeight.value }px`,\n}));\n\nfunction getItemStyle(item: RenderedItem<T>) {\n const isVertical = props.direction === 'vertical';\n const isHorizontal = props.direction === 'horizontal';\n const isBoth = props.direction === 'both';\n const isDynamic = props.itemSize === undefined || props.itemSize === null || props.itemSize === 0;\n\n const style: Record<string, string | number | undefined> = {\n blockSize: isHorizontal ? '100%' : (!isDynamic ? `${ item.size.height }px` : 'auto'),\n };\n\n if (isVertical && props.containerTag === 'table') {\n style.minInlineSize = '100%';\n } else {\n style.inlineSize = isVertical ? '100%' : (!isDynamic ? `${ item.size.width }px` : 'auto');\n }\n\n if (isDynamic) {\n if (!isVertical) {\n style.minInlineSize = '1px';\n }\n if (!isHorizontal) {\n style.minBlockSize = '1px';\n }\n }\n\n if (isHydrated.value) {\n if (item.isStickyActive) {\n if (isVertical || isBoth) {\n style.insetBlockStart = `${ getPaddingY(props.scrollPaddingStart, props.direction) }px`;\n }\n\n if (isHorizontal || isBoth) {\n style.insetInlineStart = `${ getPaddingX(props.scrollPaddingStart, props.direction) }px`;\n }\n\n style.transform = `translate(${ item.stickyOffset.x }px, ${ item.stickyOffset.y }px)`;\n } else {\n style.transform = `translate(${ item.offset.x }px, ${ item.offset.y }px)`;\n }\n }\n\n return style;\n}\n\nconst isDebug = computed(() => props.debug);\nconst isTable = computed(() => props.containerTag === 'table');\nconst headerTag = computed(() => isTable.value ? 'thead' : 'div');\nconst footerTag = computed(() => isTable.value ? 'tfoot' : 'div');\n\ndefineExpose({\n scrollDetails,\n columnRange,\n getColumnWidth,\n scrollToIndex,\n scrollToOffset,\n refresh,\n stopProgrammaticScroll,\n});\n</script>\n\n<template>\n <component\n :is=\"containerTag\"\n ref=\"hostRef\"\n class=\"virtual-scroll-container\"\n :class=\"[\n `virtual-scroll--${ direction }`,\n {\n 'virtual-scroll--hydrated': isHydrated,\n 'virtual-scroll--window': isWindowContainer,\n 'virtual-scroll--table': isTable,\n },\n ]\"\n :style=\"containerStyle\"\n tabindex=\"0\"\n @keydown=\"handleKeyDown\"\n @wheel.passive=\"stopProgrammaticScroll\"\n @pointerdown.passive=\"stopProgrammaticScroll\"\n @touchstart.passive=\"stopProgrammaticScroll\"\n >\n <!-- v8 ignore start -->\n <component\n :is=\"headerTag\"\n v-if=\"slots.header\"\n ref=\"headerRef\"\n class=\"virtual-scroll-header\"\n :class=\"{ 'virtual-scroll--sticky': stickyHeader }\"\n >\n <slot name=\"header\" />\n </component>\n <!-- v8 ignore stop -->\n\n <component\n :is=\"wrapperTag\"\n ref=\"wrapperRef\"\n class=\"virtual-scroll-wrapper\"\n :style=\"wrapperStyle\"\n >\n <!-- Phantom element to push scroll height -->\n <!-- v8 ignore start -->\n <component\n :is=\"itemTag\"\n v-if=\"isTable\"\n class=\"virtual-scroll-spacer\"\n :style=\"spacerStyle\"\n >\n <td style=\"padding: 0; border: none; block-size: inherit;\" />\n </component>\n <!-- v8 ignore stop -->\n\n <component\n :is=\"itemTag\"\n v-for=\"renderedItem in renderedItems\"\n :key=\"renderedItem.index\"\n :ref=\"(el: unknown) => setItemRef(el, renderedItem.index)\"\n :data-index=\"renderedItem.index\"\n class=\"virtual-scroll-item\"\n :class=\"{\n 'virtual-scroll--sticky': renderedItem.isStickyActive,\n 'virtual-scroll--debug': isDebug,\n }\"\n :style=\"getItemStyle(renderedItem)\"\n >\n <slot\n name=\"item\"\n :item=\"renderedItem.item\"\n :index=\"renderedItem.index\"\n :column-range=\"columnRange\"\n :get-column-width=\"getColumnWidth\"\n :is-sticky=\"renderedItem.isSticky\"\n :is-sticky-active=\"renderedItem.isStickyActive\"\n />\n <div v-if=\"isDebug\" class=\"virtual-scroll-debug-info\">\n #{{ renderedItem.index }} ({{ Math.round(renderedItem.offset.x) }}, {{ Math.round(renderedItem.offset.y) }})\n </div>\n </component>\n </component>\n\n <!-- v8 ignore start -->\n <div\n v-if=\"loading && slots.loading\"\n class=\"virtual-scroll-loading\"\n :style=\"loadingStyle\"\n >\n <slot name=\"loading\" />\n </div>\n\n <component\n :is=\"footerTag\"\n v-if=\"slots.footer\"\n ref=\"footerRef\"\n class=\"virtual-scroll-footer\"\n :class=\"{ 'virtual-scroll--sticky': stickyFooter }\"\n >\n <slot name=\"footer\" />\n </component>\n <!-- v8 ignore stop -->\n </component>\n</template>\n\n<style scoped>\n.virtual-scroll-container {\n position: relative;\n block-size: 100%;\n inline-size: 100%;\n outline-offset: 1px;\n\n &:not(.virtual-scroll--window) {\n overflow: auto;\n overscroll-behavior: contain;\n }\n\n &.virtual-scroll--table {\n display: block;\n }\n}\n\n.virtual-scroll--horizontal {\n white-space: nowrap;\n}\n\n.virtual-scroll-wrapper {\n contain: layout;\n position: relative;\n\n :where(.virtual-scroll--hydrated > & > .virtual-scroll-item) {\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n }\n}\n\n.virtual-scroll-item {\n box-sizing: border-box;\n will-change: transform;\n\n &:where(.virtual-scroll--debug) {\n outline: 1px dashed rgba(255, 0, 0, 0.5);\n background-color: rgba(255, 0, 0, 0.05);\n\n &:where(:hover) {\n background-color: rgba(255, 0, 0, 0.1);\n z-index: 100;\n }\n }\n}\n\n.virtual-scroll-debug-info {\n position: absolute;\n inset-block-start: 2px;\n inset-inline-end: 2px;\n background: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 10px;\n padding: 2px 4px;\n border-radius: 4px;\n pointer-events: none;\n z-index: 100;\n font-family: monospace;\n}\n\n.virtual-scroll-spacer {\n pointer-events: none;\n}\n\n.virtual-scroll-header,\n.virtual-scroll-footer {\n position: relative;\n z-index: 20;\n}\n\n.virtual-scroll--sticky {\n position: sticky;\n\n &:where(.virtual-scroll-header) {\n inset-block-start: 0;\n inset-inline-start: 0;\n min-inline-size: 100%;\n box-sizing: border-box;\n }\n\n &:where(.virtual-scroll-footer) {\n inset-block-end: 0;\n inset-inline-start: 0;\n min-inline-size: 100%;\n box-sizing: border-box;\n }\n\n &:where(.virtual-scroll-item) {\n z-index: 10;\n }\n}\n\n:is(tbody.virtual-scroll-wrapper, thead.virtual-scroll-header, tfoot.virtual-scroll-footer) {\n display: inline-flex;\n min-inline-size: 100%;\n & > :deep(tr) {\n display: inline-flex;\n min-inline-size: 100%;\n\n & > :is(td, th) {\n display: inline-block;\n align-items: center;\n }\n }\n}\n</style>\n"],"mappings":"wFAIA,IAAa,EAAb,KAAyB,CACvB,KACA,OAEA,YAAY,EAAc,CACxB,KAAK,KAAO,IAAI,aAAa,EAAO,EAAE,CACtC,KAAK,OAAS,IAAI,aAAa,EAAK,CAQtC,OAAO,EAAe,EAAqB,CACrC,OAAQ,GAAK,GAAS,KAAK,OAAO,QAMtC,IAHA,KAAK,OAAQ,GAAU,KAAK,OAAQ,GAAW,EAE/C,IACO,EAAQ,KAAK,KAAK,QACvB,KAAK,KAAM,GAAU,KAAK,KAAM,GAAW,EAC3C,GAAS,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