@pdanpdan/virtual-scroll 0.4.0 → 0.5.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/dist/index.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import { AllowedComponentProps } from 'vue';
2
2
  import { ComponentCustomProps } from 'vue';
3
+ import { ComponentOptionsMixin } from 'vue';
4
+ import { ComponentProvideOptions } from 'vue';
3
5
  import { ComputedRef } from 'vue';
6
+ import { DefineComponent } from 'vue';
7
+ import { MaybeRefOrGetter } from 'vue';
4
8
  import { PublicProps } from 'vue';
5
9
  import { Ref } from 'vue';
6
10
  import { ShallowUnwrapRef } from 'vue';
@@ -12,15 +16,31 @@ declare type __VLS_PrettifyLocal<T> = {
12
16
  [K in keyof T]: T[K];
13
17
  } & {};
14
18
 
19
+ /**
20
+ * Maximum size (in pixels) for an element that most browsers can handle reliably.
21
+ * Beyond this size, we use scaling for the scrollable area.
22
+ * @default 10000000
23
+ */
24
+ export declare const BROWSER_MAX_SIZE = 10000000;
25
+
15
26
  /**
16
27
  * Calculates the range of columns to render for bidirectional scroll.
17
28
  *
18
- * @param params - The parameters for calculation.
19
- * @returns The start and end indices and paddings for columns.
29
+ * @param params - Column range parameters.
30
+ * @param params.columnCount - Total column count.
31
+ * @param params.relativeScrollX - Virtual horizontal position (VU).
32
+ * @param params.usableWidth - Usable viewport width (VU).
33
+ * @param params.colBuffer - Column buffer size.
34
+ * @param params.fixedWidth - Fixed column width (VU).
35
+ * @param params.columnGap - Column gap (VU).
36
+ * @param params.findLowerBound - Resolver for column index.
37
+ * @param params.query - Resolver for column offset (VU).
38
+ * @param params.totalColsQuery - Resolver for total width (VU).
39
+ * @returns The start and end indices and paddings for columns (VU).
20
40
  * @see ColumnRangeParams
21
41
  * @see ColumnRange
22
42
  */
23
- export declare function calculateColumnRange(params: ColumnRangeParams): {
43
+ export declare function calculateColumnRange({ columnCount, relativeScrollX, usableWidth, colBuffer, fixedWidth, columnGap, findLowerBound, query, totalColsQuery, }: ColumnRangeParams): {
24
44
  start: number;
25
45
  end: number;
26
46
  padStart: number;
@@ -30,11 +50,24 @@ export declare function calculateColumnRange(params: ColumnRangeParams): {
30
50
  /**
31
51
  * Calculates the position and size of a single item.
32
52
  *
33
- * @param params - The parameters for calculation.
34
- * @returns Item position and size.
53
+ * @param params - Item position parameters.
54
+ * @param params.index - Item index.
55
+ * @param params.direction - Scroll direction.
56
+ * @param params.fixedSize - Fixed item size (VU).
57
+ * @param params.gap - Item gap (VU).
58
+ * @param params.columnGap - Column gap (VU).
59
+ * @param params.usableWidth - Usable viewport width (VU).
60
+ * @param params.usableHeight - Usable viewport height (VU).
61
+ * @param params.totalWidth - Total estimated width (VU).
62
+ * @param params.queryY - Resolver for vertical offset (VU).
63
+ * @param params.queryX - Resolver for horizontal offset (VU).
64
+ * @param params.getSizeY - Resolver for height (VU).
65
+ * @param params.getSizeX - Resolver for width (VU).
66
+ * @param params.columnRange - Current column range (for grid mode).
67
+ * @returns Item position and size (VU).
35
68
  * @see ItemPositionParams
36
69
  */
37
- export declare function calculateItemPosition(params: ItemPositionParams): {
70
+ export declare function calculateItemPosition({ index, direction, fixedSize, gap, columnGap, usableWidth, usableHeight, totalWidth, queryY, queryX, getSizeY, getSizeX, columnRange, }: ItemPositionParams): {
38
71
  height: number;
39
72
  width: number;
40
73
  x: number;
@@ -44,20 +77,43 @@ export declare function calculateItemPosition(params: ItemPositionParams): {
44
77
  /**
45
78
  * Calculates the style object for a rendered item.
46
79
  *
47
- * @param params - The parameters for calculation.
80
+ * @param params - Item style parameters.
81
+ * @param params.item - Rendered item state.
82
+ * @param params.direction - Scroll direction.
83
+ * @param params.itemSize - Virtual item size (VU).
84
+ * @param params.containerTag - Container HTML tag.
85
+ * @param params.paddingStartX - Horizontal virtual padding (DU).
86
+ * @param params.paddingStartY - Vertical virtual padding (DU).
87
+ * @param params.isHydrated - If mounted and hydrated.
88
+ * @param params.isRtl - If in RTL mode.
48
89
  * @returns Style object.
49
90
  * @see ItemStyleParams
50
91
  */
51
- export declare function calculateItemStyle<T = unknown>(params: ItemStyleParams<T>): Record<string, string | number | undefined>;
92
+ export declare function calculateItemStyle<T = unknown>({ item, direction, itemSize, containerTag, paddingStartX, paddingStartY, isHydrated, isRtl, }: ItemStyleParams<T>): Record<string, string | number | undefined>;
52
93
 
53
94
  /**
54
95
  * Calculates the range of items to render based on scroll position and viewport size.
55
96
  *
56
- * @param params - The parameters for calculation.
97
+ * @param params - Range parameters.
98
+ * @param params.direction - Scroll direction.
99
+ * @param params.relativeScrollX - Virtual horizontal position (VU).
100
+ * @param params.relativeScrollY - Virtual vertical position (VU).
101
+ * @param params.usableWidth - Usable viewport width (VU).
102
+ * @param params.usableHeight - Usable viewport height (VU).
103
+ * @param params.itemsLength - Total item count.
104
+ * @param params.bufferBefore - Buffer items before.
105
+ * @param params.bufferAfter - Buffer items after.
106
+ * @param params.gap - Item gap (VU).
107
+ * @param params.columnGap - Column gap (VU).
108
+ * @param params.fixedSize - Fixed item size (VU).
109
+ * @param params.findLowerBoundY - Resolver for vertical index.
110
+ * @param params.findLowerBoundX - Resolver for horizontal index.
111
+ * @param params.queryY - Resolver for vertical offset (VU).
112
+ * @param params.queryX - Resolver for horizontal offset (VU).
57
113
  * @returns The start and end indices of the items to render.
58
114
  * @see RangeParams
59
115
  */
60
- export declare function calculateRange(params: RangeParams): {
116
+ export declare function calculateRange({ direction, relativeScrollX, relativeScrollY, usableWidth, usableHeight, itemsLength, bufferBefore, bufferAfter, gap, columnGap, fixedSize, findLowerBoundY, findLowerBoundX, queryY, queryX, }: RangeParams): {
61
117
  start: number;
62
118
  end: number;
63
119
  };
@@ -65,21 +121,72 @@ export declare function calculateRange(params: RangeParams): {
65
121
  /**
66
122
  * Calculates the target scroll position (relative to content) for a given row/column index and alignment.
67
123
  *
68
- * @param params - The parameters for calculation.
69
- * @returns The target X and Y positions and item dimensions.
124
+ * @param params - Scroll target parameters.
125
+ * @param params.rowIndex - Row index to target.
126
+ * @param params.colIndex - Column index to target.
127
+ * @param params.options - Scroll options including alignment.
128
+ * @param params.direction - Current scroll direction.
129
+ * @param params.viewportWidth - Full viewport width (DU).
130
+ * @param params.viewportHeight - Full viewport height (DU).
131
+ * @param params.totalWidth - Total estimated width (VU).
132
+ * @param params.totalHeight - Total estimated height (VU).
133
+ * @param params.gap - Item gap (VU).
134
+ * @param params.columnGap - Column gap (VU).
135
+ * @param params.fixedSize - Fixed item size (VU).
136
+ * @param params.fixedWidth - Fixed column width (VU).
137
+ * @param params.relativeScrollX - Current relative X scroll (VU).
138
+ * @param params.relativeScrollY - Current relative Y scroll (VU).
139
+ * @param params.getItemSizeY - Resolver for item height (VU).
140
+ * @param params.getItemSizeX - Resolver for item width (VU).
141
+ * @param params.getItemQueryY - Prefix sum resolver for item height (VU).
142
+ * @param params.getItemQueryX - Prefix sum resolver for item width (VU).
143
+ * @param params.getColumnSize - Resolver for column size (VU).
144
+ * @param params.getColumnQuery - Prefix sum resolver for column width (VU).
145
+ * @param params.scaleX - Coordinate scaling factor for X axis.
146
+ * @param params.scaleY - Coordinate scaling factor for Y axis.
147
+ * @param params.hostOffsetX - Display pixels offset of items wrapper on X axis (DU).
148
+ * @param params.hostOffsetY - Display pixels offset of items wrapper on Y axis (DU).
149
+ * @param params.flowPaddingStartX - Display pixels padding at flow start on X axis (DU).
150
+ * @param params.flowPaddingStartY - Display pixels padding at flow start on Y axis (DU).
151
+ * @param params.paddingStartX - Display pixels padding at scroll start on X axis (DU).
152
+ * @param params.paddingStartY - Display pixels padding at scroll start on Y axis (DU).
153
+ * @param params.paddingEndX - Display pixels padding at scroll end on X axis (DU).
154
+ * @param params.paddingEndY - Display pixels padding at scroll end on Y axis (DU).
155
+ * @param params.stickyIndices - List of sticky indices.
156
+ * @param params.stickyStartX - Sticky start offset on X axis (DU).
157
+ * @param params.stickyStartY - Sticky start offset on Y axis (DU).
158
+ * @param params.stickyEndX - Sticky end offset on X axis (DU).
159
+ * @param params.stickyEndY - Sticky end offset on Y axis (DU).
160
+ * @returns The target X and Y positions (VU) and item dimensions (VU).
70
161
  * @see ScrollTargetParams
71
162
  * @see ScrollTargetResult
72
163
  */
73
- export declare function calculateScrollTarget(params: ScrollTargetParams): ScrollTargetResult;
164
+ export declare function calculateScrollTarget({ rowIndex, colIndex, options, direction, viewportWidth, viewportHeight, totalWidth, totalHeight, gap, columnGap, fixedSize, fixedWidth, relativeScrollX, relativeScrollY, getItemSizeY, getItemSizeX, getItemQueryY, getItemQueryX, getColumnSize, getColumnQuery, scaleX, scaleY, hostOffsetX, hostOffsetY, stickyIndices, stickyStartX, stickyStartY, stickyEndX, stickyEndY, flowPaddingStartX, flowPaddingStartY, paddingStartX, paddingStartY, paddingEndX, paddingEndY, }: ScrollTargetParams): ScrollTargetResult;
74
165
 
75
166
  /**
76
167
  * Calculates the sticky state and offset for a single item.
77
168
  *
78
- * @param params - The parameters for calculation.
79
- * @returns Sticky state and offset.
169
+ * @param params - Sticky item parameters.
170
+ * @param params.index - Item index.
171
+ * @param params.isSticky - If configured as sticky.
172
+ * @param params.direction - Scroll direction.
173
+ * @param params.relativeScrollX - Virtual horizontal position (VU).
174
+ * @param params.relativeScrollY - Virtual vertical position (VU).
175
+ * @param params.originalX - Virtual original X position (VU).
176
+ * @param params.originalY - Virtual original Y position (VU).
177
+ * @param params.width - Virtual item width (VU).
178
+ * @param params.height - Virtual item height (VU).
179
+ * @param params.stickyIndices - All sticky indices.
180
+ * @param params.fixedSize - Fixed item size (VU).
181
+ * @param params.fixedWidth - Fixed column width (VU).
182
+ * @param params.gap - Item gap (VU).
183
+ * @param params.columnGap - Column gap (VU).
184
+ * @param params.getItemQueryY - Resolver for vertical offset (VU).
185
+ * @param params.getItemQueryX - Resolver for horizontal offset (VU).
186
+ * @returns Sticky state and offset (VU).
80
187
  * @see StickyParams
81
188
  */
82
- export declare function calculateStickyItem(params: StickyParams): {
189
+ export declare function calculateStickyItem({ index, isSticky, direction, relativeScrollX, relativeScrollY, originalX, originalY, width, height, stickyIndices, fixedSize, fixedWidth, gap, columnGap, getItemQueryY, getItemQueryX, }: StickyParams): {
83
190
  isStickyActive: boolean;
84
191
  stickyOffset: {
85
192
  x: number;
@@ -90,15 +197,39 @@ export declare function calculateStickyItem(params: StickyParams): {
90
197
  /**
91
198
  * Calculates the total width and height of the virtualized content.
92
199
  *
93
- * @param params - The parameters for calculation.
94
- * @returns Total width and height.
200
+ * @param params - Total size parameters.
201
+ * @param params.direction - Scroll direction.
202
+ * @param params.itemsLength - Total item count.
203
+ * @param params.columnCount - Column count.
204
+ * @param params.fixedSize - Fixed item size (VU).
205
+ * @param params.fixedWidth - Fixed column width (VU).
206
+ * @param params.gap - Item gap (VU).
207
+ * @param params.columnGap - Column gap (VU).
208
+ * @param params.usableWidth - Usable viewport width (VU).
209
+ * @param params.usableHeight - Usable viewport height (VU).
210
+ * @param params.queryY - Resolver for vertical offset (VU).
211
+ * @param params.queryX - Resolver for horizontal offset (VU).
212
+ * @param params.queryColumn - Resolver for column offset (VU).
213
+ * @returns Total width and height (VU).
95
214
  * @see TotalSizeParams
96
215
  */
97
- export declare function calculateTotalSize(params: TotalSizeParams): {
216
+ export declare function calculateTotalSize({ direction, itemsLength, columnCount, fixedSize, fixedWidth, gap, columnGap, usableWidth, usableHeight, queryY, queryX, queryColumn, }: TotalSizeParams): {
98
217
  width: number;
99
218
  height: number;
100
219
  };
101
220
 
221
+ /** Information about the currently visible range of columns and their paddings. */
222
+ export declare interface ColumnRange {
223
+ /** Inclusive start index. */
224
+ start: number;
225
+ /** Exclusive end index. */
226
+ end: number;
227
+ /** Pixel padding to maintain at the start of the row in VU. */
228
+ padStart: number;
229
+ /** Pixel padding to maintain at the end of the row in VU. */
230
+ padEnd: number;
231
+ }
232
+
102
233
  /** Parameters for calculating the visible range of columns in grid mode. */
103
234
  export declare interface ColumnRangeParams {
104
235
  /** Column count. */
@@ -127,6 +258,16 @@ export declare const DEFAULT_COLUMN_WIDTH = 100;
127
258
 
128
259
  export declare const DEFAULT_ITEM_SIZE = 40;
129
260
 
261
+ /**
262
+ * Maps a display scroll position to a virtual content position.
263
+ *
264
+ * @param displayPos - Display pixel position (DU).
265
+ * @param hostOffset - Offset of the host element in display pixels (DU).
266
+ * @param scale - Coordinate scaling factor (VU/DU).
267
+ * @returns Virtual content position (VU).
268
+ */
269
+ export declare function displayToVirtual(displayPos: number, hostOffset: number, scale: number): number;
270
+
130
271
  /**
131
272
  * Fenwick Tree (Binary Indexed Tree) implementation for efficient
132
273
  * prefix sum calculations and updates.
@@ -209,6 +350,15 @@ export declare class FenwickTree {
209
350
  shift(offset: number): void;
210
351
  }
211
352
 
353
+ /**
354
+ * Binary search for the previous sticky index before the current index.
355
+ *
356
+ * @param stickyIndices - Sorted array of sticky indices.
357
+ * @param index - Current index.
358
+ * @returns Previous sticky index or undefined.
359
+ */
360
+ export declare function findPrevStickyIndex(stickyIndices: number[], index: number): number | undefined;
361
+
212
362
  /**
213
363
  * Extracts the horizontal padding from a padding configuration.
214
364
  *
@@ -249,6 +399,19 @@ export declare function isBody(container: HTMLElement | Window | null | undefine
249
399
  */
250
400
  export declare function isElement(container: HTMLElement | Window | null | undefined): container is HTMLElement;
251
401
 
402
+ /**
403
+ * Determines if an item is visible within the usable viewport.
404
+ *
405
+ * @param itemPos - Virtual start position of the item (VU).
406
+ * @param itemSize - Virtual size of the item (VU).
407
+ * @param scrollPos - Virtual scroll position (VU).
408
+ * @param viewSize - Full size of the viewport (VU).
409
+ * @param stickyOffsetStart - Dynamic offset from sticky items at start (VU).
410
+ * @param stickyOffsetEnd - Offset from sticky items at end (VU).
411
+ * @returns True if visible.
412
+ */
413
+ export declare function isItemVisible(itemPos: number, itemSize: number, scrollPos: number, viewSize: number, stickyOffsetStart?: number, stickyOffsetEnd?: number): boolean;
414
+
252
415
  /**
253
416
  * Checks if the target is an element that supports scrolling.
254
417
  *
@@ -307,6 +470,8 @@ export declare interface ItemPositionParams {
307
470
  getSizeY: (idx: number) => number;
308
471
  /** Width resolver. */
309
472
  getSizeX: (idx: number) => number;
473
+ /** Current column range (for grid mode). */
474
+ columnRange?: ColumnRange | undefined;
310
475
  }
311
476
 
312
477
  /** Properties passed to the 'item' scoped slot. */
@@ -328,6 +493,10 @@ export declare interface ItemSlotProps<T = unknown> {
328
493
  };
329
494
  /** Helper to get the current calculated width of any column index. */
330
495
  getColumnWidth: (index: number) => number;
496
+ /** Vertical gap between items. */
497
+ gap: number;
498
+ /** Horizontal gap between columns. */
499
+ columnGap: number;
331
500
  /** Whether this item index is configured as sticky. */
332
501
  isSticky?: boolean | undefined;
333
502
  /** Whether this item is currently in a sticky state at the edge. */
@@ -350,178 +519,14 @@ export declare interface ItemStyleParams<T = unknown> {
350
519
  paddingStartY: number;
351
520
  /** Hydration state. */
352
521
  isHydrated: boolean;
522
+ /** Whether the container is in Right-to-Left (RTL) mode. */
523
+ isRtl: boolean;
353
524
  }
354
525
 
355
- declare interface Props<T = unknown> {
356
- /**
357
- * Array of items to be virtualized.
358
- * Required.
359
- */
360
- items: T[];
361
- /**
362
- * Fixed size of each item (in pixels) or a function that returns the size of an item.
363
- * Pass 0, null or undefined for dynamic size detection via ResizeObserver.
364
- * @default 40
365
- */
366
- itemSize?: number | ((item: T, index: number) => number) | null;
367
- /**
368
- * Direction of the scroll.
369
- * - 'vertical': Standard vertical list.
370
- * - 'horizontal': Standard horizontal list.
371
- * - 'both': Grid mode virtualizing both rows and columns.
372
- * @default 'vertical'
373
- */
374
- direction?: 'vertical' | 'horizontal' | 'both';
375
- /**
376
- * Number of items to render before the visible viewport.
377
- * Useful for smoother scrolling and keyboard navigation.
378
- * @default 5
379
- */
380
- bufferBefore?: number;
381
- /**
382
- * Number of items to render after the visible viewport.
383
- * @default 5
384
- */
385
- bufferAfter?: number;
386
- /**
387
- * The scrollable container element or window.
388
- * If not provided, the host element (root of VirtualScroll) is used.
389
- * @default hostRef
390
- */
391
- container?: HTMLElement | Window | null;
392
- /**
393
- * Range of items to render during Server-Side Rendering.
394
- * When provided, these items will be rendered in-flow before hydration.
395
- * @see SSRRange
396
- */
397
- ssrRange?: {
398
- /** First row index to render. */
399
- start: number;
400
- /** Last row index to render (exclusive). */
401
- end: number;
402
- /** First column index to render (for grid mode). */
403
- colStart?: number;
404
- /** Last column index to render (exclusive, for grid mode). */
405
- colEnd?: number;
406
- };
407
- /**
408
- * Number of columns for bidirectional (grid) scroll.
409
- * Only applicable when direction="both".
410
- * @default 0
411
- */
412
- columnCount?: number;
413
- /**
414
- * Fixed width of columns (in pixels), an array of widths, or a function for column widths.
415
- * Pass 0, null or undefined for dynamic width detection via ResizeObserver.
416
- * Only applicable when direction="both".
417
- * @default 100
418
- */
419
- columnWidth?: number | number[] | ((index: number) => number) | null;
420
- /**
421
- * The HTML tag to use for the root container.
422
- * @default 'div'
423
- */
424
- containerTag?: string;
425
- /**
426
- * The HTML tag to use for the items wrapper.
427
- * Useful for <table> integration (e.g. 'tbody').
428
- * @default 'div'
429
- */
430
- wrapperTag?: string;
431
- /**
432
- * The HTML tag to use for each item.
433
- * Useful for <table> integration (e.g. 'tr').
434
- * @default 'div'
435
- */
436
- itemTag?: string;
437
- /**
438
- * Additional padding at the start of the scroll container (top or left).
439
- * Can be a number (applied to current direction) or an object with x/y.
440
- * @default 0
441
- */
442
- scrollPaddingStart?: number | {
443
- x?: number;
444
- y?: number;
445
- };
446
- /**
447
- * Additional padding at the end of the scroll container (bottom or right).
448
- * @default 0
449
- */
450
- scrollPaddingEnd?: number | {
451
- x?: number;
452
- y?: number;
453
- };
454
- /**
455
- * Whether the content in the 'header' slot is sticky.
456
- * If true, the header size is measured and accounted for in scroll padding.
457
- * @default false
458
- */
459
- stickyHeader?: boolean;
460
- /**
461
- * Whether the content in the 'footer' slot is sticky.
462
- * @default false
463
- */
464
- stickyFooter?: boolean;
465
- /**
466
- * Gap between items in pixels (vertical gap in vertical/grid mode, horizontal gap in horizontal mode).
467
- * @default 0
468
- */
469
- gap?: number;
470
- /**
471
- * Gap between columns in pixels. Only applicable when direction="both" or "horizontal".
472
- * @default 0
473
- */
474
- columnGap?: number;
475
- /**
476
- * Indices of items that should stick to the top/start of the viewport.
477
- * Supports iOS-style pushing effect where the next sticky item pushes the previous one.
478
- * @default []
479
- */
480
- stickyIndices?: number[];
481
- /**
482
- * Distance from the end of the scrollable area (in pixels) to trigger the 'load' event.
483
- * @default 200
484
- */
485
- loadDistance?: number;
486
- /**
487
- * Whether items are currently being loaded.
488
- * Prevents multiple 'load' events from triggering and shows the 'loading' slot.
489
- * @default false
490
- */
491
- loading?: boolean;
492
- /**
493
- * Whether to automatically restore and maintain scroll position when items are prepended to the list.
494
- * Perfect for chat applications.
495
- * @default false
496
- */
497
- restoreScrollOnPrepend?: boolean;
498
- /**
499
- * Initial scroll index to jump to immediately after mount.
500
- */
501
- initialScrollIndex?: number;
502
- /**
503
- * Alignment for the initial scroll index.
504
- * @default 'start'
505
- * @see ScrollAlignment
506
- */
507
- initialScrollAlign?: ScrollAlignment | ScrollAlignmentOptions;
508
- /**
509
- * Default size for items before they are measured by ResizeObserver.
510
- * Only used when itemSize is dynamic.
511
- * @default 40
512
- */
513
- defaultItemSize?: number;
514
- /**
515
- * Default width for columns before they are measured by ResizeObserver.
516
- * Only used when columnWidth is dynamic.
517
- * @default 100
518
- */
519
- defaultColumnWidth?: number;
520
- /**
521
- * Whether to show debug information (visible offsets and indices) over items.
522
- * @default false
523
- */
524
- debug?: boolean;
526
+ declare interface Props<T = unknown> extends VirtualScrollComponentProps<T> {
527
+ }
528
+
529
+ declare interface Props_2 extends VirtualScrollbarProps {
525
530
  }
526
531
 
527
532
  /** Parameters for calculating the visible range of items. */
@@ -564,33 +569,33 @@ export declare interface RenderedItem<T = unknown> {
564
569
  item: T;
565
570
  /** The 0-based index of the item in the original array. */
566
571
  index: number;
567
- /** The calculated pixel offset relative to the items wrapper. */
572
+ /** The calculated pixel offset relative to the items wrapper in display pixels (DU). */
568
573
  offset: {
569
- /** Horizontal offset (left). */
574
+ /** Horizontal offset (left) in DU. */
570
575
  x: number;
571
- /** Vertical offset (top). */
576
+ /** Vertical offset (top) in DU. */
572
577
  y: number;
573
578
  };
574
- /** The current measured or estimated size of the item. */
579
+ /** The current measured or estimated size of the item in virtual units (VU). */
575
580
  size: {
576
- /** Pixel width. */
581
+ /** Pixel width in VU. */
577
582
  width: number;
578
- /** Pixel height. */
583
+ /** Pixel height in VU. */
579
584
  height: number;
580
585
  };
581
- /** The original horizontal pixel offset before any sticky adjustments. */
586
+ /** The original horizontal pixel offset before any sticky adjustments in VU. */
582
587
  originalX: number;
583
- /** The original vertical pixel offset before any sticky adjustments. */
588
+ /** The original vertical pixel offset before any sticky adjustments in VU. */
584
589
  originalY: number;
585
590
  /** Whether this item is configured to be sticky via the `stickyIndices` property. */
586
591
  isSticky?: boolean;
587
592
  /** Whether this item is currently in a stuck state at the viewport edge. */
588
593
  isStickyActive?: boolean;
589
- /** The relative translation applied to the item for the sticky pushing effect. */
594
+ /** The relative translation applied to the item for the sticky pushing effect in DU. */
590
595
  stickyOffset: {
591
- /** Horizontal translation. */
596
+ /** Horizontal translation in DU. */
592
597
  x: number;
593
- /** Vertical translation. */
598
+ /** Vertical translation in DU. */
594
599
  y: number;
595
600
  };
596
601
  }
@@ -612,33 +617,83 @@ export declare interface ScrollAlignmentOptions {
612
617
  y?: ScrollAlignment;
613
618
  }
614
619
 
620
+ /** Help provide axis specific information to the scrollbar. */
621
+ export declare type ScrollAxis = 'vertical' | 'horizontal';
622
+
623
+ /** Properties passed to the 'scrollbar' scoped slot. */
624
+ export declare interface ScrollbarSlotProps {
625
+ /** Current scroll position as a percentage (0 to 1). */
626
+ positionPercent: number;
627
+ /** Viewport size as a percentage of total size (0 to 1). */
628
+ viewportPercent: number;
629
+ /** Calculated thumb size as a percentage of the track size (0 to 100). */
630
+ thumbSizePercent: number;
631
+ /** Calculated thumb position as a percentage of the track size (0 to 100). */
632
+ thumbPositionPercent: number;
633
+ /**
634
+ * Attributes and event listeners to be bound to the scrollbar track element.
635
+ * Use `v-bind="trackProps"` on your track element.
636
+ */
637
+ trackProps: Record<string, unknown>;
638
+ /**
639
+ * Attributes and event listeners to be bound to the scrollbar thumb element.
640
+ * Use `v-bind="thumbProps"` on your thumb element.
641
+ */
642
+ thumbProps: Record<string, unknown>;
643
+ /**
644
+ * Grouped props for the `VirtualScrollbar` component.
645
+ * Useful for passing directly to `<VirtualScrollbar v-bind="scrollbarProps" />`.
646
+ */
647
+ scrollbarProps: VirtualScrollbarProps;
648
+ /** Whether the thumb is currently being dragged. */
649
+ isDragging: boolean;
650
+ }
651
+
615
652
  /** Comprehensive state of the virtual scroll system. */
616
653
  export declare interface ScrollDetails<T = unknown> {
617
654
  /** List of items currently rendered in the DOM buffer. */
618
655
  items: RenderedItem<T>[];
619
- /** Index of the first item partially or fully visible in the viewport. */
656
+ /** Index of the first item visible below any sticky header in the viewport. */
620
657
  currentIndex: number;
621
- /** Index of the first column partially or fully visible (grid mode). */
658
+ /** Index of the first column visible after any sticky column in the viewport (grid mode). */
622
659
  currentColIndex: number;
623
- /** Current relative pixel scroll position from the content start. */
660
+ /** Index of the last item visible above any sticky footer in the viewport. */
661
+ currentEndIndex: number;
662
+ /** Index of the last column visible before any sticky end column in the viewport (grid mode). */
663
+ currentEndColIndex: number;
664
+ /** Current relative pixel scroll position from the content start in VU. */
624
665
  scrollOffset: {
625
- /** Horizontal position (X). */
666
+ /** Horizontal position (X) in VU. */
667
+ x: number;
668
+ /** Vertical position (Y) in VU. */
669
+ y: number;
670
+ };
671
+ /** Current display pixel scroll position (before scaling) in DU. */
672
+ displayScrollOffset: {
673
+ /** Horizontal position (X) in DU. */
626
674
  x: number;
627
- /** Vertical position (Y). */
675
+ /** Vertical position (Y) in DU. */
628
676
  y: number;
629
677
  };
630
- /** Current dimensions of the visible viewport area. */
678
+ /** Current dimensions of the visible viewport area in VU. */
631
679
  viewportSize: {
632
- /** Pixel width. */
680
+ /** Pixel width in VU. */
681
+ width: number;
682
+ /** Pixel height in VU. */
683
+ height: number;
684
+ };
685
+ /** Current dimensions of the visible viewport area in display pixels (DU). */
686
+ displayViewportSize: {
687
+ /** Pixel width in DU. */
633
688
  width: number;
634
- /** Pixel height. */
689
+ /** Pixel height in DU. */
635
690
  height: number;
636
691
  };
637
- /** Total calculated or estimated size of all items and gaps. */
692
+ /** Total calculated or estimated size of all items and gaps in VU. */
638
693
  totalSize: {
639
- /** Total pixel width. */
694
+ /** Total pixel width in VU. */
640
695
  width: number;
641
- /** Total pixel height. */
696
+ /** Total pixel height in VU. */
642
697
  height: number;
643
698
  };
644
699
  /** Whether the container is currently being scrolled by the user or an animation. */
@@ -653,16 +708,7 @@ export declare interface ScrollDetails<T = unknown> {
653
708
  end: number;
654
709
  };
655
710
  /** The range of column indices and associated paddings currently being rendered. */
656
- columnRange: {
657
- /** Inclusive start index. */
658
- start: number;
659
- /** Exclusive end index. */
660
- end: number;
661
- /** Pixel padding to maintain at the start of the row. */
662
- padStart: number;
663
- /** Pixel padding to maintain at the end of the row. */
664
- padEnd: number;
665
- };
711
+ columnRange: ColumnRange;
666
712
  }
667
713
 
668
714
  /**
@@ -681,16 +727,12 @@ export declare interface ScrollTargetParams {
681
727
  colIndex: number | null | undefined;
682
728
  /** Scroll options. */
683
729
  options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions | undefined;
684
- /** Total items count. */
685
- itemsLength: number;
686
- /** Total columns count. */
687
- columnCount: number;
688
730
  /** Current scroll direction. */
689
731
  direction: ScrollDirection;
690
- /** Usable viewport width (excluding padding). */
691
- usableWidth: number;
692
- /** Usable viewport height (excluding padding). */
693
- usableHeight: number;
732
+ /** Current viewport width. */
733
+ viewportWidth: number;
734
+ /** Current viewport height. */
735
+ viewportHeight: number;
694
736
  /** Current total estimated width. */
695
737
  totalWidth: number;
696
738
  /** Current total estimated height. */
@@ -719,8 +761,40 @@ export declare interface ScrollTargetParams {
719
761
  getColumnSize: (index: number) => number;
720
762
  /** Prefix sum resolver for column width. */
721
763
  getColumnQuery: (index: number) => number;
764
+ /** Coordinate scaling factor for X axis. */
765
+ scaleX: number;
766
+ /** Coordinate scaling factor for Y axis. */
767
+ scaleY: number;
768
+ /** Host offset on X axis in display pixels. */
769
+ hostOffsetX: number;
770
+ /** Host offset on Y axis in display pixels. */
771
+ hostOffsetY: number;
722
772
  /** List of sticky indices. */
723
773
  stickyIndices?: number[] | undefined;
774
+ /** Sticky start offset on X axis. */
775
+ stickyStartX?: number | undefined;
776
+ /** Sticky start offset on Y axis. */
777
+ stickyStartY?: number | undefined;
778
+ /** Sticky end offset on X axis. */
779
+ stickyEndX?: number | undefined;
780
+ /** Sticky end offset on Y axis. */
781
+ stickyEndY?: number | undefined;
782
+ /** Flow padding start on X axis. */
783
+ flowPaddingStartX?: number | undefined;
784
+ /** Flow padding start on Y axis. */
785
+ flowPaddingStartY?: number | undefined;
786
+ /** Flow padding end on X axis. */
787
+ flowPaddingEndX?: number | undefined;
788
+ /** Flow padding end on Y axis. */
789
+ flowPaddingEndY?: number | undefined;
790
+ /** Scroll padding start on X axis. */
791
+ paddingStartX?: number | undefined;
792
+ /** Scroll padding start on Y axis. */
793
+ paddingStartY?: number | undefined;
794
+ /** Scroll padding end on X axis. */
795
+ paddingEndX?: number | undefined;
796
+ /** Scroll padding end on Y axis. */
797
+ paddingEndY?: number | undefined;
724
798
  }
725
799
 
726
800
  /** Calculated scroll target result. */
@@ -825,29 +899,80 @@ export declare interface TotalSizeParams {
825
899
  * Composable for virtual scrolling logic.
826
900
  * Handles calculation of visible items, scroll events, dynamic item sizes, and programmatic scrolling.
827
901
  *
828
- * @param props - A Ref to the configuration properties.
902
+ * @param propsInput - The configuration properties. Can be a plain object, a Ref, or a getter function.
829
903
  * @see VirtualScrollProps
830
904
  */
831
- export declare function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollProps<T>>): {
905
+ export declare function useVirtualScroll<T = unknown>(propsInput: MaybeRefOrGetter<VirtualScrollProps<T>>): {
832
906
  /**
833
907
  * Array of items currently rendered in the DOM with their calculated offsets and sizes.
908
+ * Offsets are in Display Units (DU), sizes are in Virtual Units (VU).
834
909
  * @see RenderedItem
835
910
  */
836
911
  renderedItems: ComputedRef<RenderedItem<T>[]>;
837
912
  /**
838
- * Total calculated width of all items including gaps (in pixels).
913
+ * Total calculated width of all items including gaps (in VU).
839
914
  */
840
915
  totalWidth: ComputedRef<number>;
841
916
  /**
842
- * Total calculated height of all items including gaps (in pixels).
917
+ * Total calculated height of all items including gaps (in VU).
843
918
  */
844
919
  totalHeight: ComputedRef<number>;
920
+ /**
921
+ * Total width to be rendered in the DOM (clamped to browser limits, in DU).
922
+ */
923
+ renderedWidth: ComputedRef<number>;
924
+ /**
925
+ * Total height to be rendered in the DOM (clamped to browser limits, in DU).
926
+ */
927
+ renderedHeight: ComputedRef<number>;
845
928
  /**
846
929
  * Detailed information about the current scroll state.
847
- * Includes currentIndex, scrollOffset, viewportSize, totalSize, and scrolling status.
930
+ * Includes currentIndex, scrollOffset (VU), displayScrollOffset (DU), viewportSize (DU), totalSize (VU), and scrolling status.
848
931
  * @see ScrollDetails
849
932
  */
850
933
  scrollDetails: ComputedRef<ScrollDetails<T>>;
934
+ /**
935
+ * Helper to get the height of a specific row based on current configuration and measurements.
936
+ *
937
+ * @param index - The row index.
938
+ * @returns The height in VU (excluding gap).
939
+ */
940
+ getRowHeight: (index: number) => number;
941
+ /**
942
+ * Helper to get the width of a specific column based on current configuration and measurements.
943
+ *
944
+ * @param index - The column index.
945
+ * @returns The width in VU (excluding gap).
946
+ */
947
+ getColumnWidth: (index: number) => number;
948
+ /**
949
+ * Helper to get the virtual offset of a specific row.
950
+ *
951
+ * @param index - The row index.
952
+ * @returns The virtual offset in VU.
953
+ */
954
+ getRowOffset: (index: number) => number;
955
+ /**
956
+ * Helper to get the virtual offset of a specific column.
957
+ *
958
+ * @param index - The column index.
959
+ * @returns The virtual offset in VU.
960
+ */
961
+ getColumnOffset: (index: number) => number;
962
+ /**
963
+ * Helper to get the virtual offset of a specific item along the scroll axis.
964
+ *
965
+ * @param index - The item index.
966
+ * @returns The virtual offset in VU.
967
+ */
968
+ getItemOffset: (index: number) => number;
969
+ /**
970
+ * Helper to get the size of a specific item along the scroll axis.
971
+ *
972
+ * @param index - The item index.
973
+ * @returns The size in VU (excluding gap).
974
+ */
975
+ getItemSize: (index: number) => number;
851
976
  /**
852
977
  * Programmatically scroll to a specific row and/or column.
853
978
  *
@@ -861,8 +986,8 @@ export declare function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollPr
861
986
  /**
862
987
  * Programmatically scroll to a specific pixel offset relative to the content start.
863
988
  *
864
- * @param x - The pixel offset to scroll to on the X axis. Pass null to keep current position.
865
- * @param y - The pixel offset to scroll to on the Y axis. Pass null to keep current position.
989
+ * @param x - The pixel offset to scroll to on the X axis (VU). Pass null to keep current position.
990
+ * @param y - The pixel offset to scroll to on the Y axis (VU). Pass null to keep current position.
866
991
  * @param options - Scroll options (behavior).
867
992
  */
868
993
  scrollToOffset: (x?: number | null, y?: number | null, options?: {
@@ -876,15 +1001,15 @@ export declare function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollPr
876
1001
  * Updates the stored size of an item. Should be called when an item is measured (e.g., via ResizeObserver).
877
1002
  *
878
1003
  * @param index - The item index.
879
- * @param width - The measured inlineSize (width).
880
- * @param height - The measured blockSize (height).
1004
+ * @param width - The measured inlineSize (width in DU).
1005
+ * @param height - The measured blockSize (height in DU).
881
1006
  * @param element - The measured element (optional, used for robust grid column detection).
882
1007
  */
883
1008
  updateItemSize: (index: number, inlineSize: number, blockSize: number, element?: HTMLElement) => void;
884
1009
  /**
885
1010
  * Updates the stored size of multiple items simultaneously.
886
1011
  *
887
- * @param updates - Array of measurement updates.
1012
+ * @param updates - Array of measurement updates (sizes in DU).
888
1013
  */
889
1014
  updateItemSizes: (updates: Array<{
890
1015
  index: number;
@@ -897,6 +1022,10 @@ export declare function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollPr
897
1022
  * Useful if the container or host moves without a resize event.
898
1023
  */
899
1024
  updateHostOffset: () => void;
1025
+ /**
1026
+ * Detects the current direction (LTR/RTL) of the scroll container.
1027
+ */
1028
+ updateDirection: () => void;
900
1029
  /**
901
1030
  * Information about the current visible range of columns and their paddings.
902
1031
  * @see ColumnRange
@@ -907,12 +1036,6 @@ export declare function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollPr
907
1036
  padStart: number;
908
1037
  padEnd: number;
909
1038
  }>;
910
- /**
911
- * Helper to get the width of a specific column based on current configuration and measurements.
912
- *
913
- * @param index - The column index.
914
- */
915
- getColumnWidth: (index: number) => number;
916
1039
  /**
917
1040
  * Resets all dynamic measurements and re-initializes from props.
918
1041
  * Useful if item sizes have changed externally.
@@ -922,8 +1045,139 @@ export declare function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollPr
922
1045
  * Whether the component has finished its first client-side mount and hydration.
923
1046
  */
924
1047
  isHydrated: Ref<boolean, boolean>;
1048
+ /**
1049
+ * Whether the container is the window or body.
1050
+ */
1051
+ isWindowContainer: ComputedRef<boolean>;
1052
+ /**
1053
+ * Whether the scroll container is in Right-to-Left (RTL) mode.
1054
+ */
1055
+ isRtl: Ref<boolean, boolean>;
1056
+ /**
1057
+ * Coordinate scaling factor for X axis (VU/DU).
1058
+ */
1059
+ scaleX: ComputedRef<number>;
1060
+ /**
1061
+ * Coordinate scaling factor for Y axis (VU/DU).
1062
+ */
1063
+ scaleY: ComputedRef<number>;
1064
+ /**
1065
+ * Absolute offset of the component within its container (DU).
1066
+ */
1067
+ componentOffset: {
1068
+ x: number;
1069
+ y: number;
1070
+ };
1071
+ /**
1072
+ * Physical width of the items wrapper in the DOM (clamped to browser limits, in DU).
1073
+ */
1074
+ renderedVirtualWidth: ComputedRef<number>;
1075
+ /**
1076
+ * Physical height of the items wrapper in the DOM (clamped to browser limits, in DU).
1077
+ */
1078
+ renderedVirtualHeight: ComputedRef<number>;
1079
+ };
1080
+
1081
+ /**
1082
+ * Composable for virtual scrollbar logic.
1083
+ * Provides attributes and event listeners for track and thumb elements.
1084
+ *
1085
+ * @param props - Configuration properties.
1086
+ */
1087
+ export declare function useVirtualScrollbar(props: UseVirtualScrollbarProps): {
1088
+ /** Viewport size as a percentage of total size (0 to 1). */
1089
+ viewportPercent: ComputedRef<number>;
1090
+ /** Current scroll position as a percentage of the scrollable range (0 to 1). */
1091
+ positionPercent: ComputedRef<number>;
1092
+ /** Calculated thumb size as a percentage of the track size (0 to 100). */
1093
+ thumbSizePercent: ComputedRef<number>;
1094
+ /** Calculated thumb position as a percentage of the track size (0 to 100). */
1095
+ thumbPositionPercent: ComputedRef<number>;
1096
+ /** Reactive style object for the scrollbar track. */
1097
+ trackStyle: ComputedRef< {
1098
+ inlineSize: string;
1099
+ blockSize?: never;
1100
+ } | {
1101
+ blockSize: string;
1102
+ inlineSize?: never;
1103
+ }>;
1104
+ /** Reactive style object for the scrollbar thumb. */
1105
+ thumbStyle: ComputedRef< {
1106
+ inlineSize: string;
1107
+ insetInlineStart: string;
1108
+ blockSize?: never;
1109
+ insetBlockStart?: never;
1110
+ } | {
1111
+ blockSize: string;
1112
+ insetBlockStart: string;
1113
+ inlineSize?: never;
1114
+ insetInlineStart?: never;
1115
+ }>;
1116
+ /** Attributes and event listeners to be bound to the track element. */
1117
+ trackProps: ComputedRef< {
1118
+ class: string[];
1119
+ style: {
1120
+ inlineSize: string;
1121
+ blockSize?: never;
1122
+ } | {
1123
+ blockSize: string;
1124
+ inlineSize?: never;
1125
+ };
1126
+ role: string;
1127
+ 'aria-orientation': ScrollAxis;
1128
+ 'aria-valuenow': number;
1129
+ 'aria-valuemin': number;
1130
+ 'aria-valuemax': number;
1131
+ 'aria-controls': string | undefined;
1132
+ tabindex: number;
1133
+ onMousedown: (event: MouseEvent) => void;
1134
+ }>;
1135
+ /** Attributes and event listeners to be bound to the thumb element. */
1136
+ thumbProps: ComputedRef< {
1137
+ class: (string | {
1138
+ 'virtual-scrollbar-thumb--active': boolean;
1139
+ })[];
1140
+ style: {
1141
+ inlineSize: string;
1142
+ insetInlineStart: string;
1143
+ blockSize?: never;
1144
+ insetBlockStart?: never;
1145
+ } | {
1146
+ blockSize: string;
1147
+ insetBlockStart: string;
1148
+ inlineSize?: never;
1149
+ insetInlineStart?: never;
1150
+ };
1151
+ onPointerdown: (event: PointerEvent) => void;
1152
+ onPointermove: (event: PointerEvent) => void;
1153
+ onPointerup: (event: PointerEvent) => void;
1154
+ onPointercancel: (event: PointerEvent) => void;
1155
+ }>;
1156
+ /** Whether the thumb is currently being dragged. */
1157
+ isDragging: Ref<boolean, boolean>;
925
1158
  };
926
1159
 
1160
+ /** Configuration properties for the `useVirtualScrollbar` composable. */
1161
+ export declare interface UseVirtualScrollbarProps {
1162
+ /** The axis for this scrollbar. */
1163
+ axis: MaybeRefOrGetter<ScrollAxis>;
1164
+ /** Total size of the scrollable content area in display pixels (DU). */
1165
+ totalSize: MaybeRefOrGetter<number>;
1166
+ /** Current scroll position in display pixels (DU). */
1167
+ position: MaybeRefOrGetter<number>;
1168
+ /** Viewport size in display pixels (DU). */
1169
+ viewportSize: MaybeRefOrGetter<number>;
1170
+ /**
1171
+ * Function to scroll to a specific display pixel offset (DU) on this axis.
1172
+ * @param offset - The display pixel offset to scroll to.
1173
+ */
1174
+ scrollToOffset: (offset: number) => void;
1175
+ /** The ID of the container element this scrollbar controls. */
1176
+ containerId?: MaybeRefOrGetter<string | undefined>;
1177
+ /** Whether the scrollbar is in Right-to-Left (RTL) mode. */
1178
+ isRtl?: MaybeRefOrGetter<boolean>;
1179
+ }
1180
+
927
1181
  export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
928
1182
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
929
1183
  readonly onLoad?: (direction: "vertical" | "horizontal") => any;
@@ -960,6 +1214,36 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
960
1214
  */
961
1215
  getColumnWidth: (index: number) => number;
962
1216
  /**
1217
+ * Helper to get the height of a specific row.
1218
+ * @param index - The row index.
1219
+ * @see useVirtualScroll
1220
+ */
1221
+ getRowHeight: (index: number) => number;
1222
+ /**
1223
+ * Helper to get the virtual offset of a specific row.
1224
+ * @param index - The row index.
1225
+ * @see useVirtualScroll
1226
+ */
1227
+ getRowOffset: (index: number) => number;
1228
+ /**
1229
+ * Helper to get the virtual offset of a specific column.
1230
+ * @param index - The column index.
1231
+ * @see useVirtualScroll
1232
+ */
1233
+ getColumnOffset: (index: number) => number;
1234
+ /**
1235
+ * Helper to get the virtual offset of a specific item.
1236
+ * @param index - The item index.
1237
+ * @see useVirtualScroll
1238
+ */
1239
+ getItemOffset: (index: number) => number;
1240
+ /**
1241
+ * Helper to get the size of a specific item along the scroll axis.
1242
+ * @param index - The item index.
1243
+ * @see useVirtualScroll
1244
+ */
1245
+ getItemSize: (index: number) => number;
1246
+ /**
963
1247
  * Programmatically scroll to a specific row and/or column.
964
1248
  *
965
1249
  * @param rowIndex - The row index to scroll to. Pass null to only scroll horizontally.
@@ -991,6 +1275,101 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
991
1275
  * @see useVirtualScroll
992
1276
  */
993
1277
  stopProgrammaticScroll: () => void;
1278
+ /**
1279
+ * Detects the current direction (LTR/RTL) of the scroll container.
1280
+ */
1281
+ updateDirection: () => void;
1282
+ /**
1283
+ * Whether the scroll container is in Right-to-Left (RTL) mode.
1284
+ */
1285
+ isRtl: Ref<boolean, boolean>;
1286
+ /**
1287
+ * Whether the component has finished its first client-side mount and hydration.
1288
+ */
1289
+ isHydrated: Ref<boolean, boolean>;
1290
+ /**
1291
+ * Coordinate scaling factor for X axis.
1292
+ */
1293
+ scaleX: ComputedRef<number>;
1294
+ /**
1295
+ * Coordinate scaling factor for Y axis.
1296
+ */
1297
+ scaleY: ComputedRef<number>;
1298
+ /**
1299
+ * Physical width of the content in the DOM (clamped to browser limits).
1300
+ */
1301
+ renderedWidth: ComputedRef<number>;
1302
+ /**
1303
+ * Physical height of the content in the DOM (clamped to browser limits).
1304
+ */
1305
+ renderedHeight: ComputedRef<number>;
1306
+ /**
1307
+ * Absolute offset of the component within its container.
1308
+ */
1309
+ componentOffset: {
1310
+ x: number;
1311
+ y: number;
1312
+ };
1313
+ /**
1314
+ * Properties for the vertical scrollbar.
1315
+ * Useful when building custom scrollbar interfaces.
1316
+ */
1317
+ scrollbarPropsVertical: ComputedRef<ScrollbarSlotProps | null>;
1318
+ /**
1319
+ * Properties for the horizontal scrollbar.
1320
+ * Useful when building custom scrollbar interfaces.
1321
+ */
1322
+ scrollbarPropsHorizontal: ComputedRef<ScrollbarSlotProps | null>;
1323
+ items: Ref<T[], T[]>;
1324
+ itemSize: Ref<number | ((item: T, index: number) => number) | null | undefined, number | ((item: T, index: number) => number) | null | undefined>;
1325
+ container: Ref<HTMLElement | Window | null | undefined, HTMLElement | Window | null | undefined>;
1326
+ ssrRange: Ref< {
1327
+ start: number;
1328
+ end: number;
1329
+ colStart?: number;
1330
+ colEnd?: number;
1331
+ } | undefined, {
1332
+ start: number;
1333
+ end: number;
1334
+ colStart?: number;
1335
+ colEnd?: number;
1336
+ } | undefined>;
1337
+ columnWidth: Ref<number | number[] | ((index: number) => number) | null | undefined, number | number[] | ((index: number) => number) | null | undefined>;
1338
+ initialScrollIndex: Ref<number | undefined, number | undefined>;
1339
+ initialScrollAlign: Ref<ScrollAlignment | ScrollAlignmentOptions | undefined, ScrollAlignment | ScrollAlignmentOptions | undefined>;
1340
+ defaultItemSize: Ref<number | undefined, number | undefined>;
1341
+ defaultColumnWidth: Ref<number | undefined, number | undefined>;
1342
+ direction: Ref<ScrollDirection, ScrollDirection>;
1343
+ bufferBefore: Ref<number, number>;
1344
+ bufferAfter: Ref<number, number>;
1345
+ columnCount: Ref<number, number>;
1346
+ containerTag: Ref<string, string>;
1347
+ wrapperTag: Ref<string, string>;
1348
+ itemTag: Ref<string, string>;
1349
+ scrollPaddingStart: Ref<number | {
1350
+ x?: number;
1351
+ y?: number;
1352
+ }, number | {
1353
+ x?: number;
1354
+ y?: number;
1355
+ }>;
1356
+ scrollPaddingEnd: Ref<number | {
1357
+ x?: number;
1358
+ y?: number;
1359
+ }, number | {
1360
+ x?: number;
1361
+ y?: number;
1362
+ }>;
1363
+ stickyHeader: Ref<boolean, boolean>;
1364
+ stickyFooter: Ref<boolean, boolean>;
1365
+ gap: Ref<number, number>;
1366
+ columnGap: Ref<number, number>;
1367
+ stickyIndices: Ref<number[], number[]>;
1368
+ loadDistance: Ref<number, number>;
1369
+ loading: Ref<boolean, boolean>;
1370
+ restoreScrollOnPrepend: Ref<boolean, boolean>;
1371
+ debug: Ref<boolean, boolean>;
1372
+ virtualScrollbar: Ref<boolean, boolean>;
994
1373
  }>): void;
995
1374
  attrs: any;
996
1375
  slots: Readonly<{
@@ -1026,6 +1405,10 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
1026
1405
  * Useful for setting consistent widths in grid mode.
1027
1406
  */
1028
1407
  getColumnWidth: (index: number) => number;
1408
+ /** Vertical gap between items. */
1409
+ gap: number;
1410
+ /** Horizontal gap between columns. */
1411
+ columnGap: number;
1029
1412
  /** Whether this item is configured to be sticky via `stickyIndices`. */
1030
1413
  isSticky?: boolean | undefined;
1031
1414
  /** Whether this item is currently in a sticky state (stuck at the top/start). */
@@ -1041,6 +1424,11 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
1041
1424
  * Can be made sticky using the `stickyFooter` prop.
1042
1425
  */
1043
1426
  footer?: (props: Record<string, never>) => VNodeChild;
1427
+ /**
1428
+ * Scoped slot for rendering custom scrollbars.
1429
+ * If provided, the default VirtualScrollbar is not rendered.
1430
+ */
1431
+ scrollbar?: (props: ScrollbarSlotProps) => VNodeChild;
1044
1432
  }> & {
1045
1433
  /**
1046
1434
  * Content rendered at the top of the scrollable area.
@@ -1074,6 +1462,10 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
1074
1462
  * Useful for setting consistent widths in grid mode.
1075
1463
  */
1076
1464
  getColumnWidth: (index: number) => number;
1465
+ /** Vertical gap between items. */
1466
+ gap: number;
1467
+ /** Horizontal gap between columns. */
1468
+ columnGap: number;
1077
1469
  /** Whether this item is configured to be sticky via `stickyIndices`. */
1078
1470
  isSticky?: boolean | undefined;
1079
1471
  /** Whether this item is currently in a sticky state (stuck at the top/start). */
@@ -1089,6 +1481,11 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
1089
1481
  * Can be made sticky using the `stickyFooter` prop.
1090
1482
  */
1091
1483
  footer?: (props: Record<string, never>) => VNodeChild;
1484
+ /**
1485
+ * Scoped slot for rendering custom scrollbars.
1486
+ * If provided, the default VirtualScrollbar is not rendered.
1487
+ */
1488
+ scrollbar?: (props: ScrollbarSlotProps) => VNodeChild;
1092
1489
  };
1093
1490
  emit: {
1094
1491
  (e: "scroll", details: ScrollDetails<T>): void;
@@ -1104,6 +1501,180 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
1104
1501
  __ctx?: Awaited<typeof __VLS_setup>;
1105
1502
  };
1106
1503
 
1504
+ export declare const VirtualScrollbar: DefineComponent<Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
1505
+ scrollToOffset: (offset: number) => any;
1506
+ }, string, PublicProps, Readonly<Props_2> & Readonly<{
1507
+ onScrollToOffset?: (offset: number) => any;
1508
+ }>, {
1509
+ isRtl: boolean;
1510
+ axis: ScrollAxis;
1511
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
1512
+
1513
+ /** Properties for the `VirtualScrollbar` component. */
1514
+ export declare interface VirtualScrollbarProps {
1515
+ /**
1516
+ * The axis for this scrollbar.
1517
+ * - 'vertical': Vertical scrollbar.
1518
+ * - 'horizontal': Horizontal scrollbar.
1519
+ * @default 'vertical'
1520
+ */
1521
+ axis?: ScrollAxis;
1522
+ /**
1523
+ * Total size of the scrollable content in pixels.
1524
+ */
1525
+ totalSize: number;
1526
+ /**
1527
+ * Current scroll position in pixels.
1528
+ */
1529
+ position: number;
1530
+ /**
1531
+ * Viewport size in pixels.
1532
+ */
1533
+ viewportSize: number;
1534
+ /**
1535
+ * Function to scroll to a specific pixel offset on this axis.
1536
+ * @param offset - The pixel offset to scroll to.
1537
+ */
1538
+ scrollToOffset?: (offset: number) => void;
1539
+ /**
1540
+ * The ID of the container element this scrollbar controls.
1541
+ */
1542
+ containerId?: string;
1543
+ /**
1544
+ * Whether the scrollbar is in Right-to-Left (RTL) mode.
1545
+ * @default false
1546
+ */
1547
+ isRtl?: boolean;
1548
+ }
1549
+
1550
+ /** Configuration properties for the `VirtualScroll` component. */
1551
+ export declare interface VirtualScrollComponentProps<T = unknown> {
1552
+ /** Array of items to be virtualized. */
1553
+ items: T[];
1554
+ /** Fixed size of each item (in pixels) or a function that returns the size of an item. */
1555
+ itemSize?: number | ((item: T, index: number) => number) | null;
1556
+ /** Direction of the scroll. */
1557
+ direction?: ScrollDirection;
1558
+ /** Number of items to render before the visible viewport. */
1559
+ bufferBefore?: number;
1560
+ /** Number of items to render after the visible viewport. */
1561
+ bufferAfter?: number;
1562
+ /** The scrollable container element or window. */
1563
+ container?: HTMLElement | Window | null;
1564
+ /** Range of items to render during Server-Side Rendering. */
1565
+ ssrRange?: {
1566
+ /** First row index to render. */
1567
+ start: number;
1568
+ /** Last row index to render (exclusive). */
1569
+ end: number;
1570
+ /** First column index to render (for grid mode). */
1571
+ colStart?: number;
1572
+ /** Last column index to render (exclusive, for grid mode). */
1573
+ colEnd?: number;
1574
+ };
1575
+ /** Number of columns for bidirectional (grid) scroll. */
1576
+ columnCount?: number;
1577
+ /** Fixed width of columns (in pixels), an array of widths, or a function for column widths. */
1578
+ columnWidth?: number | number[] | ((index: number) => number) | null;
1579
+ /** The HTML tag to use for the root container. */
1580
+ containerTag?: string;
1581
+ /** The HTML tag to use for the items wrapper. */
1582
+ wrapperTag?: string;
1583
+ /** The HTML tag to use for each item. */
1584
+ itemTag?: string;
1585
+ /** Additional padding at the start of the scroll container (top or left). */
1586
+ scrollPaddingStart?: number | {
1587
+ x?: number;
1588
+ y?: number;
1589
+ };
1590
+ /** Additional padding at the end of the scroll container (bottom or right). */
1591
+ scrollPaddingEnd?: number | {
1592
+ x?: number;
1593
+ y?: number;
1594
+ };
1595
+ /** Whether the content in the 'header' slot is sticky. */
1596
+ stickyHeader?: boolean;
1597
+ /** Whether the content in the 'footer' slot is sticky. */
1598
+ stickyFooter?: boolean;
1599
+ /** Gap between items in pixels. */
1600
+ gap?: number;
1601
+ /** Gap between columns in pixels. */
1602
+ columnGap?: number;
1603
+ /** Indices of items that should stick to the top/start of the viewport. */
1604
+ stickyIndices?: number[];
1605
+ /** Distance from the end of the scrollable area (in pixels) to trigger the 'load' event. */
1606
+ loadDistance?: number;
1607
+ /** Whether items are currently being loaded. */
1608
+ loading?: boolean;
1609
+ /** Whether to automatically restore and maintain scroll position when items are prepended to the list. */
1610
+ restoreScrollOnPrepend?: boolean;
1611
+ /** Initial scroll index to jump to immediately after mount. */
1612
+ initialScrollIndex?: number;
1613
+ /** Alignment for the initial scroll index. */
1614
+ initialScrollAlign?: ScrollAlignment | ScrollAlignmentOptions;
1615
+ /** Default size for items before they are measured by ResizeObserver. */
1616
+ defaultItemSize?: number;
1617
+ /** Default width for columns before they are measured by ResizeObserver. */
1618
+ defaultColumnWidth?: number;
1619
+ /** Whether to show debug information (visible offsets and indices) over items. */
1620
+ debug?: boolean;
1621
+ /** Whether to use virtual scrollbars for styling purposes. */
1622
+ virtualScrollbar?: boolean;
1623
+ }
1624
+
1625
+ /** Exposed methods and properties of the `VirtualScroll` component instance. */
1626
+ export declare interface VirtualScrollInstance<T = unknown> extends VirtualScrollComponentProps<T> {
1627
+ /** Detailed information about the current scroll state. */
1628
+ scrollDetails: ScrollDetails<T>;
1629
+ /** Information about the current visible range of columns. */
1630
+ columnRange: ScrollDetails<T>['columnRange'];
1631
+ /** Helper to get the width of a specific column. */
1632
+ getColumnWidth: (index: number) => number;
1633
+ /** Helper to get the height of a specific row. */
1634
+ getRowHeight: (index: number) => number;
1635
+ /** Helper to get the virtual offset of a specific row. */
1636
+ getRowOffset: (index: number) => number;
1637
+ /** Helper to get the virtual offset of a specific column. */
1638
+ getColumnOffset: (index: number) => number;
1639
+ /** Helper to get the virtual offset of a specific item. */
1640
+ getItemOffset: (index: number) => number;
1641
+ /** Helper to get the size of a specific item along the scroll axis. */
1642
+ getItemSize: (index: number) => number;
1643
+ /** Programmatically scroll to a specific row and/or column. */
1644
+ scrollToIndex: (rowIndex: number | null | undefined, colIndex: number | null | undefined, options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions) => void;
1645
+ /** Programmatically scroll to a specific pixel offset. */
1646
+ scrollToOffset: (x?: number | null, y?: number | null, options?: {
1647
+ behavior?: 'auto' | 'smooth';
1648
+ }) => void;
1649
+ /** Resets all dynamic measurements and re-initializes from props. */
1650
+ refresh: () => void;
1651
+ /** Immediately stops any currently active smooth scroll animation and clears pending corrections. */
1652
+ stopProgrammaticScroll: () => void;
1653
+ /** Detects the current direction (LTR/RTL) of the scroll container. */
1654
+ updateDirection: () => void;
1655
+ /** Whether the scroll container is in Right-to-Left (RTL) mode. */
1656
+ isRtl: boolean;
1657
+ /** Whether the component has finished its first client - side mount and hydration. */
1658
+ isHydrated: boolean;
1659
+ /** Coordinate scaling factor for X axis. */
1660
+ scaleX: number;
1661
+ /** Coordinate scaling factor for Y axis. */
1662
+ scaleY: number;
1663
+ /** Physical width of the content in the DOM (clamped to browser limits). */
1664
+ renderedWidth: number;
1665
+ /** Physical height of the content in the DOM (clamped to browser limits). */
1666
+ renderedHeight: number;
1667
+ /** Absolute offset of the component within its container. */
1668
+ componentOffset: {
1669
+ x: number;
1670
+ y: number;
1671
+ };
1672
+ /** Properties for the vertical scrollbar. */
1673
+ scrollbarPropsVertical: ScrollbarSlotProps | null;
1674
+ /** Properties for the horizontal scrollbar. */
1675
+ scrollbarPropsHorizontal: ScrollbarSlotProps | null;
1676
+ }
1677
+
1107
1678
  /** Configuration properties for the `useVirtualScroll` composable. */
1108
1679
  export declare interface VirtualScrollProps<T = unknown> {
1109
1680
  /**
@@ -1111,7 +1682,7 @@ export declare interface VirtualScrollProps<T = unknown> {
1111
1682
  */
1112
1683
  items: T[];
1113
1684
  /**
1114
- * Fixed size of each item (in pixels) or a function that returns the size of an item.
1685
+ * Fixed size of each item in virtual units (VU) or a function that returns the size of an item.
1115
1686
  * Pass `0`, `null` or `undefined` for automatic dynamic size detection via `ResizeObserver`.
1116
1687
  */
1117
1688
  itemSize?: number | ((item: T, index: number) => number) | undefined;
@@ -1132,14 +1703,19 @@ export declare interface VirtualScrollProps<T = unknown> {
1132
1703
  bufferAfter?: number | undefined;
1133
1704
  /**
1134
1705
  * The scrollable element or window object.
1135
- * If not provided, virtualization usually happens relative to the `hostElement`.
1706
+ * If not provided, virtualization usually happens relative to the `hostRef`.
1136
1707
  */
1137
1708
  container?: HTMLElement | Window | null | undefined;
1138
1709
  /**
1139
1710
  * The host element that directly wraps the absolute-positioned items.
1140
- * Used for calculating relative offsets.
1711
+ * Used for calculating relative offsets in display pixels (DU).
1141
1712
  */
1142
1713
  hostElement?: HTMLElement | null | undefined;
1714
+ /**
1715
+ * The root element of the VirtualScroll component.
1716
+ * Used for calculating relative offsets in display pixels (DU).
1717
+ */
1718
+ hostRef?: HTMLElement | null | undefined;
1143
1719
  /**
1144
1720
  * Configuration for Server-Side Rendering.
1145
1721
  * Defines which items are rendered statically on the server.
@@ -1159,31 +1735,47 @@ export declare interface VirtualScrollProps<T = unknown> {
1159
1735
  */
1160
1736
  columnCount?: number | undefined;
1161
1737
  /**
1162
- * Fixed width of columns (in pixels), an array of widths, or a function returning widths.
1738
+ * Fixed width of columns in VU, an array of widths, or a function returning widths.
1163
1739
  * Pass `0`, `null` or `undefined` for dynamic column detection.
1164
1740
  */
1165
1741
  columnWidth?: number | number[] | ((index: number) => number) | undefined;
1166
1742
  /**
1167
- * Pixel padding at the start of the scroll container.
1743
+ * Pixel padding at the start of the scroll container in display pixels (DU).
1168
1744
  */
1169
1745
  scrollPaddingStart?: number | {
1170
1746
  x?: number;
1171
1747
  y?: number;
1172
1748
  } | undefined;
1173
1749
  /**
1174
- * Pixel padding at the end of the scroll container.
1750
+ * Pixel padding at the end of the scroll container in DU.
1175
1751
  */
1176
1752
  scrollPaddingEnd?: number | {
1177
1753
  x?: number;
1178
1754
  y?: number;
1179
1755
  } | undefined;
1180
1756
  /**
1181
- * Gap between items in pixels.
1757
+ * Size of sticky elements at the start of the viewport (top or left) in DU.
1758
+ * Used to adjust the visible range and item positioning without increasing content size.
1759
+ */
1760
+ stickyStart?: number | {
1761
+ x?: number;
1762
+ y?: number;
1763
+ } | undefined;
1764
+ /**
1765
+ * Size of sticky elements at the end of the viewport (bottom or right) in DU.
1766
+ * Used to adjust the visible range without increasing content size.
1767
+ */
1768
+ stickyEnd?: number | {
1769
+ x?: number;
1770
+ y?: number;
1771
+ } | undefined;
1772
+ /**
1773
+ * Gap between items in virtual units (VU).
1182
1774
  * Applied vertically in list/grid mode, horizontally in horizontal list mode.
1183
1775
  */
1184
1776
  gap?: number | undefined;
1185
1777
  /**
1186
- * Gap between columns in pixels.
1778
+ * Gap between columns in VU.
1187
1779
  * Applied in horizontal and bidirectional grid modes.
1188
1780
  */
1189
1781
  columnGap?: number | undefined;
@@ -1192,7 +1784,21 @@ export declare interface VirtualScrollProps<T = unknown> {
1192
1784
  */
1193
1785
  stickyIndices?: number[] | undefined;
1194
1786
  /**
1195
- * Threshold distance from the end (in pixels) to emit the 'load' event.
1787
+ * Extra padding (display pixels - DU) at the start of the flow (e.g. non-sticky header).
1788
+ */
1789
+ flowPaddingStart?: number | {
1790
+ x?: number;
1791
+ y?: number;
1792
+ } | undefined;
1793
+ /**
1794
+ * Extra padding (DU) at the end of the flow (e.g. non-sticky footer).
1795
+ */
1796
+ flowPaddingEnd?: number | {
1797
+ x?: number;
1798
+ y?: number;
1799
+ } | undefined;
1800
+ /**
1801
+ * Threshold distance from the end in display pixels (DU) to emit the 'load' event.
1196
1802
  * @default 200
1197
1803
  */
1198
1804
  loadDistance?: number | undefined;
@@ -1201,7 +1807,7 @@ export declare interface VirtualScrollProps<T = unknown> {
1201
1807
  */
1202
1808
  loading?: boolean | undefined;
1203
1809
  /**
1204
- * Whether to automatically restore and lock scroll position when items are prepended to the array.
1810
+ * Whether to automatically restore and maintain scroll position when items are prepended to the array.
1205
1811
  */
1206
1812
  restoreScrollOnPrepend?: boolean | undefined;
1207
1813
  /**
@@ -1214,11 +1820,11 @@ export declare interface VirtualScrollProps<T = unknown> {
1214
1820
  */
1215
1821
  initialScrollAlign?: ScrollAlignment | ScrollAlignmentOptions | undefined;
1216
1822
  /**
1217
- * Default fallback size for items before they are measured.
1823
+ * Default fallback size for items before they are measured in VU.
1218
1824
  */
1219
1825
  defaultItemSize?: number | undefined;
1220
1826
  /**
1221
- * Default fallback width for columns before they are measured.
1827
+ * Default fallback width for columns before they are measured in VU.
1222
1828
  */
1223
1829
  defaultColumnWidth?: number | undefined;
1224
1830
  /**
@@ -1227,4 +1833,14 @@ export declare interface VirtualScrollProps<T = unknown> {
1227
1833
  debug?: boolean | undefined;
1228
1834
  }
1229
1835
 
1836
+ /**
1837
+ * Maps a virtual content position to a display scroll position.
1838
+ *
1839
+ * @param virtualPos - Virtual content position (VU).
1840
+ * @param hostOffset - Offset of the host element in display pixels (DU).
1841
+ * @param scale - Coordinate scaling factor (VU/DU).
1842
+ * @returns Display pixel position (DU).
1843
+ */
1844
+ export declare function virtualToDisplay(virtualPos: number, hostOffset: number, scale: number): number;
1845
+
1230
1846
  export { }