@pdanpdan/virtual-scroll 0.7.0 → 0.9.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 +99 -6
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +295 -31
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +954 -878
- package/dist/index.mjs.map +1 -1
- package/dist/virtual-scroll.css +1 -1
- package/package.json +7 -2
- package/src/components/VirtualScroll.vue +301 -209
- package/src/components/VirtualScrollbar.vue +8 -8
- package/src/composables/useVirtualScroll.ts +261 -521
- package/src/composables/useVirtualScrollSizes.ts +448 -0
- package/src/composables/useVirtualScrollbar.ts +30 -35
- package/src/index.ts +1 -0
- package/src/types.ts +25 -2
- package/src/utils/scroll.ts +14 -14
- package/src/utils/virtual-scroll-logic.ts +305 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { DefineComponent } from 'vue';
|
|
|
7
7
|
import { MaybeRefOrGetter } from 'vue';
|
|
8
8
|
import { PublicProps } from 'vue';
|
|
9
9
|
import { Ref } from 'vue';
|
|
10
|
+
import { ShallowRef } from 'vue';
|
|
10
11
|
import { ShallowUnwrapRef } from 'vue';
|
|
11
12
|
import { VNode } from 'vue';
|
|
12
13
|
import { VNodeChild } from 'vue';
|
|
@@ -23,6 +24,17 @@ declare type __VLS_PrettifyLocal<T> = {
|
|
|
23
24
|
*/
|
|
24
25
|
export declare const BROWSER_MAX_SIZE = 10000000;
|
|
25
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Helper to calculate total size for a single axis.
|
|
29
|
+
*
|
|
30
|
+
* @param count - Item count.
|
|
31
|
+
* @param fixedSize - Fixed size if any.
|
|
32
|
+
* @param gap - Gap size.
|
|
33
|
+
* @param query - Prefix sum resolver.
|
|
34
|
+
* @returns Total size.
|
|
35
|
+
*/
|
|
36
|
+
export declare function calculateAxisSize(count: number, fixedSize: number | null, gap: number, query: (index: number) => number): number;
|
|
37
|
+
|
|
26
38
|
/**
|
|
27
39
|
* Calculates the range of columns to render for bidirectional scroll.
|
|
28
40
|
*
|
|
@@ -47,6 +59,64 @@ export declare function calculateColumnRange({ columnCount, relativeScrollX, usa
|
|
|
47
59
|
padEnd: number;
|
|
48
60
|
};
|
|
49
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Helper to get the index at a virtual offset.
|
|
64
|
+
*
|
|
65
|
+
* @param offset - Virtual offset.
|
|
66
|
+
* @param fixedSize - Fixed size if any.
|
|
67
|
+
* @param gap - Gap size.
|
|
68
|
+
* @param findLowerBound - Binary search resolver.
|
|
69
|
+
* @returns Index at offset.
|
|
70
|
+
*/
|
|
71
|
+
export declare function calculateIndexAt(offset: number, fixedSize: number | null, gap: number, findLowerBound: (offset: number) => number): number;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Calculates the next step in an inertia animation.
|
|
75
|
+
*
|
|
76
|
+
* @param velocity - Current velocity.
|
|
77
|
+
* @param velocity.x - Horizontal velocity.
|
|
78
|
+
* @param velocity.y - Vertical velocity.
|
|
79
|
+
* @param friction - Friction coefficient (0-1).
|
|
80
|
+
* @param frameTime - Time elapsed since last frame in ms (default 16ms).
|
|
81
|
+
* @returns Next velocity and distance to move.
|
|
82
|
+
*/
|
|
83
|
+
export declare function calculateInertiaStep(velocity: {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
}, friction: number, frameTime?: number): {
|
|
87
|
+
nextVelocity: {
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
};
|
|
91
|
+
delta: {
|
|
92
|
+
x: number;
|
|
93
|
+
y: number;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Calculates instantaneous velocity from position change.
|
|
99
|
+
*
|
|
100
|
+
* @param lastPos - Previous position.
|
|
101
|
+
* @param lastPos.x - Horizontal position.
|
|
102
|
+
* @param lastPos.y - Vertical position.
|
|
103
|
+
* @param currentPos - Current position.
|
|
104
|
+
* @param currentPos.x - Horizontal position.
|
|
105
|
+
* @param currentPos.y - Vertical position.
|
|
106
|
+
* @param dt - Time delta in ms.
|
|
107
|
+
* @returns Calculated velocity {x, y}.
|
|
108
|
+
*/
|
|
109
|
+
export declare function calculateInstantaneousVelocity(lastPos: {
|
|
110
|
+
x: number;
|
|
111
|
+
y: number;
|
|
112
|
+
}, currentPos: {
|
|
113
|
+
x: number;
|
|
114
|
+
y: number;
|
|
115
|
+
}, dt: number): {
|
|
116
|
+
x: number;
|
|
117
|
+
y: number;
|
|
118
|
+
};
|
|
119
|
+
|
|
50
120
|
/**
|
|
51
121
|
* Calculates the position and size of a single item.
|
|
52
122
|
*
|
|
@@ -91,6 +161,26 @@ export declare function calculateItemPosition({ index, direction, fixedSize, gap
|
|
|
91
161
|
*/
|
|
92
162
|
export declare function calculateItemStyle<T = unknown>({ item, direction, itemSize, containerTag, paddingStartX, paddingStartY, isHydrated, isRtl, }: ItemStyleParams<T>): Record<string, string | number | undefined>;
|
|
93
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Helper to calculate offset at a specific index.
|
|
166
|
+
*
|
|
167
|
+
* @param index - Item index.
|
|
168
|
+
* @param fixedSize - Fixed size if any.
|
|
169
|
+
* @param gap - Gap size.
|
|
170
|
+
* @param query - Prefix sum resolver.
|
|
171
|
+
* @returns Offset at index.
|
|
172
|
+
*/
|
|
173
|
+
export declare function calculateOffsetAt(index: number, fixedSize: number | null, gap: number, query: (index: number) => number): number;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Detects how many items were prepended to the list based on item identity.
|
|
177
|
+
*
|
|
178
|
+
* @param oldItems - Previous items list.
|
|
179
|
+
* @param newItems - Current items list.
|
|
180
|
+
* @returns Number of prepended items.
|
|
181
|
+
*/
|
|
182
|
+
export declare function calculatePrependCount<T>(oldItems: T[], newItems: T[]): number;
|
|
183
|
+
|
|
94
184
|
/**
|
|
95
185
|
* Calculates the range of items to render based on scroll position and viewport size.
|
|
96
186
|
*
|
|
@@ -118,6 +208,37 @@ export declare function calculateRange({ direction, relativeScrollX, relativeScr
|
|
|
118
208
|
end: number;
|
|
119
209
|
};
|
|
120
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Helper to calculate size for a range on a single axis.
|
|
213
|
+
*
|
|
214
|
+
* @param start - Start index.
|
|
215
|
+
* @param end - End index.
|
|
216
|
+
* @param fixedSize - Fixed size if any.
|
|
217
|
+
* @param gap - Gap size.
|
|
218
|
+
* @param query - Prefix sum resolver.
|
|
219
|
+
* @returns Range size.
|
|
220
|
+
*/
|
|
221
|
+
export declare function calculateRangeSize(start: number, end: number, fixedSize: number | null, gap: number, query: (index: number) => number): number;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Calculates the physical size to be rendered in the DOM.
|
|
225
|
+
*
|
|
226
|
+
* @param isWindow - If the container is the window.
|
|
227
|
+
* @param totalSize - Total virtual size (VU).
|
|
228
|
+
* @returns Physical size (DU).
|
|
229
|
+
*/
|
|
230
|
+
export declare function calculateRenderedSize(isWindow: boolean, totalSize: number): number;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Calculates the coordinate scaling factor between virtual and display units.
|
|
234
|
+
*
|
|
235
|
+
* @param isWindow - If the container is the window.
|
|
236
|
+
* @param totalSize - Total virtual size (VU).
|
|
237
|
+
* @param viewportSize - Viewport size (DU).
|
|
238
|
+
* @returns Scaling factor (VU/DU).
|
|
239
|
+
*/
|
|
240
|
+
export declare function calculateScale(isWindow: boolean, totalSize: number, viewportSize: number): number;
|
|
241
|
+
|
|
121
242
|
/**
|
|
122
243
|
* Calculates the target scroll position (relative to content) for a given row/column index and alignment.
|
|
123
244
|
*
|
|
@@ -163,6 +284,25 @@ export declare function calculateRange({ direction, relativeScrollX, relativeScr
|
|
|
163
284
|
*/
|
|
164
285
|
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;
|
|
165
286
|
|
|
287
|
+
/**
|
|
288
|
+
* Calculates the SSR offsets for items based on the configured SSR range and direction.
|
|
289
|
+
*
|
|
290
|
+
* @param direction - Scroll direction.
|
|
291
|
+
* @param ssrRange - SSR configuration.
|
|
292
|
+
* @param fixedItemSize - Fixed item size (VU).
|
|
293
|
+
* @param fixedColumnWidth - Fixed column width (VU).
|
|
294
|
+
* @param gap - Item gap (VU).
|
|
295
|
+
* @param columnGap - Column gap (VU).
|
|
296
|
+
* @param queryY - Resolver for vertical offset (VU).
|
|
297
|
+
* @param queryX - Resolver for horizontal offset (VU).
|
|
298
|
+
* @param queryColumn - Resolver for column offset (VU).
|
|
299
|
+
* @returns Offset X and Y (VU).
|
|
300
|
+
*/
|
|
301
|
+
export declare function calculateSSROffsets(direction: ScrollDirection, ssrRange: SSRRange, fixedItemSize: number | null, fixedColumnWidth: number | null, gap: number, columnGap: number, queryY: (index: number) => number, queryX: (index: number) => number, queryColumn: (index: number) => number): {
|
|
302
|
+
x: number;
|
|
303
|
+
y: number;
|
|
304
|
+
};
|
|
305
|
+
|
|
166
306
|
/**
|
|
167
307
|
* Calculates the sticky state and offset for a single item.
|
|
168
308
|
*
|
|
@@ -372,42 +512,42 @@ export declare type GetItemAriaProps = (index: number) => Record<string, string
|
|
|
372
512
|
/**
|
|
373
513
|
* Extracts the horizontal padding from a padding configuration.
|
|
374
514
|
*
|
|
375
|
-
* @param p - The padding value (number or object with x/y).
|
|
515
|
+
* @param p - The padding value (number or object with x/y). Optional.
|
|
376
516
|
* @param direction - The current scroll direction.
|
|
377
517
|
* @returns The horizontal padding in pixels.
|
|
378
518
|
*/
|
|
379
|
-
export declare function getPaddingX(p
|
|
519
|
+
export declare function getPaddingX(p?: number | {
|
|
380
520
|
x?: number;
|
|
381
521
|
y?: number;
|
|
382
|
-
} |
|
|
522
|
+
} | null, direction?: ScrollDirection): number;
|
|
383
523
|
|
|
384
524
|
/**
|
|
385
525
|
* Extracts the vertical padding from a padding configuration.
|
|
386
526
|
*
|
|
387
|
-
* @param p - The padding value (number or object with x/y).
|
|
527
|
+
* @param p - The padding value (number or object with x/y). Optional.
|
|
388
528
|
* @param direction - The current scroll direction.
|
|
389
529
|
* @returns The vertical padding in pixels.
|
|
390
530
|
*/
|
|
391
|
-
export declare function getPaddingY(p
|
|
531
|
+
export declare function getPaddingY(p?: number | {
|
|
392
532
|
x?: number;
|
|
393
533
|
y?: number;
|
|
394
|
-
} |
|
|
534
|
+
} | null, direction?: ScrollDirection): number;
|
|
395
535
|
|
|
396
536
|
/**
|
|
397
537
|
* Checks if the container is the document body element.
|
|
398
538
|
*
|
|
399
|
-
* @param container - The container element or window to check.
|
|
539
|
+
* @param container - The container element or window to check. Optional.
|
|
400
540
|
* @returns `true` if the container is the `<body>` element.
|
|
401
541
|
*/
|
|
402
|
-
export declare function isBody(container
|
|
542
|
+
export declare function isBody(container?: HTMLElement | Window | null): container is HTMLElement;
|
|
403
543
|
|
|
404
544
|
/**
|
|
405
545
|
* Checks if the container is a valid HTML Element with bounding rect support.
|
|
406
546
|
*
|
|
407
|
-
* @param container - The container to check.
|
|
547
|
+
* @param container - The container to check. Optional.
|
|
408
548
|
* @returns `true` if the container is an `HTMLElement`.
|
|
409
549
|
*/
|
|
410
|
-
export declare function isElement(container
|
|
550
|
+
export declare function isElement(container?: HTMLElement | Window | null): container is HTMLElement;
|
|
411
551
|
|
|
412
552
|
/**
|
|
413
553
|
* Determines if an item is visible within the usable viewport.
|
|
@@ -425,10 +565,10 @@ export declare function isItemVisible(itemPos: number, itemSize: number, scrollP
|
|
|
425
565
|
/**
|
|
426
566
|
* Checks if the target is an element that supports scrolling.
|
|
427
567
|
*
|
|
428
|
-
* @param target - The event target to check.
|
|
568
|
+
* @param target - The event target to check. Optional.
|
|
429
569
|
* @returns `true` if the target is an `HTMLElement` with scroll properties.
|
|
430
570
|
*/
|
|
431
|
-
export declare function isScrollableElement(target
|
|
571
|
+
export declare function isScrollableElement(target?: EventTarget | null): target is HTMLElement;
|
|
432
572
|
|
|
433
573
|
/**
|
|
434
574
|
* Helper to determine if an options argument is a full `ScrollToIndexOptions` object.
|
|
@@ -441,18 +581,18 @@ export declare function isScrollToIndexOptions(options: unknown): options is Scr
|
|
|
441
581
|
/**
|
|
442
582
|
* Checks if the container is the window object.
|
|
443
583
|
*
|
|
444
|
-
* @param container - The container element or window to check.
|
|
584
|
+
* @param container - The container element or window to check. Optional.
|
|
445
585
|
* @returns `true` if the container is the global window object.
|
|
446
586
|
*/
|
|
447
|
-
export declare function isWindow(container
|
|
587
|
+
export declare function isWindow(container?: HTMLElement | Window | null): container is Window;
|
|
448
588
|
|
|
449
589
|
/**
|
|
450
590
|
* Checks if the container is window-like (global window or document body).
|
|
451
591
|
*
|
|
452
|
-
* @param container - The container element or window to check.
|
|
592
|
+
* @param container - The container element or window to check. Optional.
|
|
453
593
|
* @returns `true` if the container is window or body.
|
|
454
594
|
*/
|
|
455
|
-
export declare function isWindowLike(container
|
|
595
|
+
export declare function isWindowLike(container?: HTMLElement | Window | null): boolean;
|
|
456
596
|
|
|
457
597
|
/** Parameters for calculating an item's position and size. */
|
|
458
598
|
export declare interface ItemPositionParams {
|
|
@@ -619,6 +759,23 @@ export declare interface RenderedItem<T = unknown> {
|
|
|
619
759
|
stickyOffset: Point;
|
|
620
760
|
}
|
|
621
761
|
|
|
762
|
+
/**
|
|
763
|
+
* Resolves the target index and alignment for snapping on a single axis.
|
|
764
|
+
*
|
|
765
|
+
* @param mode - The snap mode ('start', 'center', 'end', 'auto').
|
|
766
|
+
* @param dir - The scroll direction on this axis.
|
|
767
|
+
* @param currentIdx - The current first visible index.
|
|
768
|
+
* @param currentEndIdx - The current last visible index.
|
|
769
|
+
* @param relScroll - The current virtual scroll offset.
|
|
770
|
+
* @param viewSize - The viewport dimension.
|
|
771
|
+
* @param count - Total number of items/columns.
|
|
772
|
+
* @param getSize - Resolver for item size.
|
|
773
|
+
* @param getQuery - Resolver for item prefix sum.
|
|
774
|
+
* @param getIndexAt - Resolver for index at a virtual offset.
|
|
775
|
+
* @returns Snap result or null.
|
|
776
|
+
*/
|
|
777
|
+
export declare function resolveSnap(mode: SnapMode, dir: 'start' | 'end' | null, currentIdx: number, currentEndIdx: number, relScroll: number, viewSize: number, count: number, getSize: (i: number) => number, getQuery: (i: number) => number, getIndexAt: (o: number) => number): SnapResult | null;
|
|
778
|
+
|
|
622
779
|
/**
|
|
623
780
|
* Alignment of an item within the viewport after a scroll operation.
|
|
624
781
|
* - 'start': Aligns item to the top or left edge.
|
|
@@ -840,6 +997,25 @@ export declare interface Size {
|
|
|
840
997
|
height: number;
|
|
841
998
|
}
|
|
842
999
|
|
|
1000
|
+
/**
|
|
1001
|
+
* Snap mode for automatic alignment after scrolling stops.
|
|
1002
|
+
* - `false`: No snapping.
|
|
1003
|
+
* - `true`: Same as 'auto'.
|
|
1004
|
+
* - 'start': Aligns the first visible item to the viewport start if at least 50% visible, otherwise aligns the next item.
|
|
1005
|
+
* - 'center': Aligns the item that intersects the viewport center to the center.
|
|
1006
|
+
* - 'end': Aligns the last visible item to the viewport end if at least 50% visible, otherwise aligns the previous item.
|
|
1007
|
+
* - 'auto': Intelligent snapping based on scroll direction. Acts as 'end' when scrolling towards start, and 'start' when scrolling towards end.
|
|
1008
|
+
*/
|
|
1009
|
+
export declare type SnapMode = boolean | 'start' | 'center' | 'end' | 'auto';
|
|
1010
|
+
|
|
1011
|
+
/** Snap result. */
|
|
1012
|
+
export declare interface SnapResult {
|
|
1013
|
+
/** Target index. */
|
|
1014
|
+
index: number;
|
|
1015
|
+
/** Alignment. */
|
|
1016
|
+
align: 'start' | 'center' | 'end';
|
|
1017
|
+
}
|
|
1018
|
+
|
|
843
1019
|
/**
|
|
844
1020
|
* Configuration for Server-Side Rendering.
|
|
845
1021
|
* Defines which items are rendered statically on the server.
|
|
@@ -1006,7 +1182,7 @@ export declare function useVirtualScroll<T = unknown>(propsInput: MaybeRefOrGett
|
|
|
1006
1182
|
* @see ScrollAlignment
|
|
1007
1183
|
* @see ScrollToIndexOptions
|
|
1008
1184
|
*/
|
|
1009
|
-
scrollToIndex: (rowIndex
|
|
1185
|
+
scrollToIndex: (rowIndex?: number | null, colIndex?: number | null, options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions) => void;
|
|
1010
1186
|
/**
|
|
1011
1187
|
* Programmatically scroll to a specific pixel offset relative to the content start.
|
|
1012
1188
|
*
|
|
@@ -1100,15 +1276,23 @@ export declare function useVirtualScroll<T = unknown>(propsInput: MaybeRefOrGett
|
|
|
1100
1276
|
* Physical height of the items wrapper in the DOM (clamped to browser limits, in DU).
|
|
1101
1277
|
*/
|
|
1102
1278
|
renderedVirtualHeight: ComputedRef<number>;
|
|
1279
|
+
/**
|
|
1280
|
+
* Helper to get the row index at a specific virtual offset.
|
|
1281
|
+
*/
|
|
1282
|
+
getRowIndexAt: (offset: number) => number;
|
|
1283
|
+
/**
|
|
1284
|
+
* Helper to get the column index at a specific virtual offset.
|
|
1285
|
+
*/
|
|
1286
|
+
getColIndexAt: (offset: number) => number;
|
|
1103
1287
|
};
|
|
1104
1288
|
|
|
1105
1289
|
/**
|
|
1106
1290
|
* Composable for virtual scrollbar logic.
|
|
1107
1291
|
* Provides attributes and event listeners for track and thumb elements.
|
|
1108
1292
|
*
|
|
1109
|
-
* @param
|
|
1293
|
+
* @param propsInput - Configuration properties.
|
|
1110
1294
|
*/
|
|
1111
|
-
export declare function useVirtualScrollbar(
|
|
1295
|
+
export declare function useVirtualScrollbar(propsInput: MaybeRefOrGetter<UseVirtualScrollbarProps>): {
|
|
1112
1296
|
/** Viewport size as a percentage of total size (0 to 1). */
|
|
1113
1297
|
viewportPercent: ComputedRef<number>;
|
|
1114
1298
|
/** Current scroll position as a percentage of the scrollable range (0 to 1). */
|
|
@@ -1185,24 +1369,80 @@ export declare function useVirtualScrollbar(props: UseVirtualScrollbarProps): {
|
|
|
1185
1369
|
/** Configuration properties for the `useVirtualScrollbar` composable. */
|
|
1186
1370
|
export declare interface UseVirtualScrollbarProps {
|
|
1187
1371
|
/** The axis for this scrollbar. */
|
|
1188
|
-
axis:
|
|
1372
|
+
axis: ScrollAxis;
|
|
1189
1373
|
/** Total size of the scrollable content area in display pixels (DU). */
|
|
1190
|
-
totalSize:
|
|
1374
|
+
totalSize: number;
|
|
1191
1375
|
/** Current scroll position in display pixels (DU). */
|
|
1192
|
-
position:
|
|
1376
|
+
position: number;
|
|
1193
1377
|
/** Viewport size in display pixels (DU). */
|
|
1194
|
-
viewportSize:
|
|
1378
|
+
viewportSize: number;
|
|
1195
1379
|
/**
|
|
1196
1380
|
* Function to scroll to a specific display pixel offset (DU) on this axis.
|
|
1197
1381
|
* @param offset - The display pixel offset to scroll to.
|
|
1198
1382
|
*/
|
|
1199
1383
|
scrollToOffset: (offset: number) => void;
|
|
1200
1384
|
/** The ID of the container element this scrollbar controls. */
|
|
1201
|
-
containerId?:
|
|
1385
|
+
containerId?: string | undefined;
|
|
1202
1386
|
/** Whether the scrollbar is in Right-to-Left (RTL) mode. */
|
|
1203
|
-
isRtl?:
|
|
1387
|
+
isRtl?: boolean;
|
|
1204
1388
|
/** Accessible label for the scrollbar. */
|
|
1205
|
-
ariaLabel?:
|
|
1389
|
+
ariaLabel?: string | undefined;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
/**
|
|
1393
|
+
* Composable for managing item and column sizes using Fenwick Trees.
|
|
1394
|
+
* Handles prefix sum calculations, size updates, and scroll correction adjustments.
|
|
1395
|
+
*/
|
|
1396
|
+
export declare function useVirtualScrollSizes<T>(propsInput: MaybeRefOrGetter<UseVirtualScrollSizesProps<T>>): {
|
|
1397
|
+
/** Fenwick Tree for horizontal item sizes. */
|
|
1398
|
+
itemSizesX: FenwickTree;
|
|
1399
|
+
/** Fenwick Tree for vertical item sizes. */
|
|
1400
|
+
itemSizesY: FenwickTree;
|
|
1401
|
+
/** Fenwick Tree for column widths. */
|
|
1402
|
+
columnSizes: FenwickTree;
|
|
1403
|
+
/** Measured item widths. */
|
|
1404
|
+
measuredItemsX: ShallowRef<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
1405
|
+
/** Measured item heights. */
|
|
1406
|
+
measuredItemsY: ShallowRef<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
1407
|
+
/** Measured column widths. */
|
|
1408
|
+
measuredColumns: ShallowRef<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
1409
|
+
/** Flag that updates when any tree changes. */
|
|
1410
|
+
treeUpdateFlag: Ref<number, number>;
|
|
1411
|
+
/** Whether sizes have been initialized. */
|
|
1412
|
+
sizesInitialized: Ref<boolean, boolean>;
|
|
1413
|
+
/** Base size of an item from props. */
|
|
1414
|
+
getItemBaseSize: (item: T, index: number) => number;
|
|
1415
|
+
/** Helper to get current size at index. */
|
|
1416
|
+
getSizeAt: (index: number, sizeProp: number | number[] | ((...args: any[]) => number) | null | undefined, defaultSize: number, gap: number, tree: FenwickTree, isX: boolean) => number;
|
|
1417
|
+
/** Initialize or update sizes from props. */
|
|
1418
|
+
initializeSizes: (onScrollCorrection?: (addedX: number, addedY: number) => void) => void;
|
|
1419
|
+
/** Update sizes of multiple items from measurements. */
|
|
1420
|
+
updateItemSizes: (updates: Array<{
|
|
1421
|
+
index: number;
|
|
1422
|
+
inlineSize: number;
|
|
1423
|
+
blockSize: number;
|
|
1424
|
+
element?: HTMLElement | undefined;
|
|
1425
|
+
}>, getRowIndexAt: (offset: number) => number, getColIndexAt: (offset: number) => number, relativeScrollX: number, relativeScrollY: number, onScrollCorrection: (deltaX: number, deltaY: number) => void) => void;
|
|
1426
|
+
/** Reset all measurements. */
|
|
1427
|
+
refresh: (onScrollCorrection?: (addedX: number, addedY: number) => void) => void;
|
|
1428
|
+
};
|
|
1429
|
+
|
|
1430
|
+
/**
|
|
1431
|
+
* Configuration properties for the `useVirtualScrollSizes` composable.
|
|
1432
|
+
*/
|
|
1433
|
+
export declare interface UseVirtualScrollSizesProps<T> {
|
|
1434
|
+
/** Reactive reference to the virtual scroll configuration. */
|
|
1435
|
+
props: VirtualScrollProps<T>;
|
|
1436
|
+
/** Whether items have dynamic heights/widths. */
|
|
1437
|
+
isDynamicItemSize: boolean;
|
|
1438
|
+
/** Whether columns have dynamic widths. */
|
|
1439
|
+
isDynamicColumnWidth: boolean;
|
|
1440
|
+
/** Fallback size for items before they are measured. */
|
|
1441
|
+
defaultSize: number;
|
|
1442
|
+
/** Fixed item size if applicable. */
|
|
1443
|
+
fixedItemSize: number | null;
|
|
1444
|
+
/** Scroll direction. */
|
|
1445
|
+
direction: 'vertical' | 'horizontal' | 'both';
|
|
1206
1446
|
}
|
|
1207
1447
|
|
|
1208
1448
|
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<{
|
|
@@ -1281,16 +1521,28 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1281
1521
|
*/
|
|
1282
1522
|
getItemSize: (index: number) => number;
|
|
1283
1523
|
/**
|
|
1524
|
+
* Helper to get the row (or item) index at a specific vertical (or horizontal in horizontal mode) virtual offset (VU).
|
|
1525
|
+
* @param offset - The virtual pixel offset.
|
|
1526
|
+
* @see useVirtualScroll
|
|
1527
|
+
*/
|
|
1528
|
+
getRowIndexAt: (offset: number) => number;
|
|
1529
|
+
/**
|
|
1530
|
+
* Helper to get the column index at a specific horizontal virtual offset (VU).
|
|
1531
|
+
* @param offset - The virtual pixel offset.
|
|
1532
|
+
* @see useVirtualScroll
|
|
1533
|
+
*/
|
|
1534
|
+
getColIndexAt: (offset: number) => number;
|
|
1535
|
+
/**
|
|
1284
1536
|
* Programmatically scroll to a specific row and/or column.
|
|
1285
1537
|
*
|
|
1286
|
-
* @param rowIndex - The row index to scroll to. Pass null to only scroll horizontally.
|
|
1287
|
-
* @param colIndex - The column index to scroll to. Pass null to only scroll vertically.
|
|
1538
|
+
* @param rowIndex - The row index to scroll to. Pass null to only scroll horizontally. Optional.
|
|
1539
|
+
* @param colIndex - The column index to scroll to. Pass null to only scroll vertically. Optional.
|
|
1288
1540
|
* @param options - Alignment and behavior options. Defaults to { align: 'auto', behavior: 'auto' }.
|
|
1289
1541
|
* @see ScrollAlignment
|
|
1290
1542
|
* @see ScrollToIndexOptions
|
|
1291
1543
|
* @see useVirtualScroll
|
|
1292
1544
|
*/
|
|
1293
|
-
scrollToIndex: (rowIndex
|
|
1545
|
+
scrollToIndex: (rowIndex?: number | null, colIndex?: number | null, options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions) => void;
|
|
1294
1546
|
/**
|
|
1295
1547
|
* Programmatically scroll to a specific pixel offset.
|
|
1296
1548
|
*
|
|
@@ -1369,6 +1621,7 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1369
1621
|
role: Ref<string | undefined, string | undefined>;
|
|
1370
1622
|
ariaLabel: Ref<string | undefined, string | undefined>;
|
|
1371
1623
|
ariaLabelledby: Ref<string | undefined, string | undefined>;
|
|
1624
|
+
snap: Ref<SnapMode | undefined, SnapMode | undefined>;
|
|
1372
1625
|
direction: Ref<ScrollDirection, ScrollDirection>;
|
|
1373
1626
|
bufferBefore: Ref<number, number>;
|
|
1374
1627
|
bufferAfter: Ref<number, number>;
|
|
@@ -1563,7 +1816,7 @@ export declare interface VirtualScrollBaseProps<T = unknown> {
|
|
|
1563
1816
|
*/
|
|
1564
1817
|
gap?: number | undefined;
|
|
1565
1818
|
/**
|
|
1566
|
-
* Gap between columns in VU.
|
|
1819
|
+
* Gap between columns in virtual units (VU).
|
|
1567
1820
|
* Applied in horizontal and bidirectional grid modes.
|
|
1568
1821
|
*/
|
|
1569
1822
|
columnGap?: number | undefined;
|
|
@@ -1624,6 +1877,11 @@ export declare interface VirtualScrollBaseProps<T = unknown> {
|
|
|
1624
1877
|
* Set to 'none' or 'presentation' to disable automatic role assignment on the wrapper.
|
|
1625
1878
|
*/
|
|
1626
1879
|
itemRole?: string | undefined;
|
|
1880
|
+
/**
|
|
1881
|
+
* Whether to snap to items after scrolling stops.
|
|
1882
|
+
* @default false
|
|
1883
|
+
*/
|
|
1884
|
+
snap?: SnapMode | undefined;
|
|
1627
1885
|
}
|
|
1628
1886
|
|
|
1629
1887
|
/** Configuration properties for the `VirtualScroll` component. */
|
|
@@ -1654,6 +1912,12 @@ export declare interface VirtualScrollInstance<T = unknown> extends VirtualScrol
|
|
|
1654
1912
|
getRowHeight: (index: number) => number;
|
|
1655
1913
|
/** Helper to get ARIA attributes for a cell. */
|
|
1656
1914
|
getCellAriaProps: (colIndex: number) => Record<string, string | number | undefined>;
|
|
1915
|
+
/** Helper to get ARIA attributes for an item. */
|
|
1916
|
+
getItemAriaProps: (index: number) => Record<string, string | number | undefined>;
|
|
1917
|
+
/** The ARIA role of the items wrapper. */
|
|
1918
|
+
wrapperRole: string | null;
|
|
1919
|
+
/** The ARIA role of each cell. */
|
|
1920
|
+
cellRole: string | null;
|
|
1657
1921
|
/** Helper to get the virtual offset of a specific row. */
|
|
1658
1922
|
getRowOffset: (index: number) => number;
|
|
1659
1923
|
/** Helper to get the virtual offset of a specific column. */
|
|
@@ -1663,7 +1927,7 @@ export declare interface VirtualScrollInstance<T = unknown> extends VirtualScrol
|
|
|
1663
1927
|
/** Helper to get the size of a specific item along the scroll axis. */
|
|
1664
1928
|
getItemSize: (index: number) => number;
|
|
1665
1929
|
/** Programmatically scroll to a specific row and/or column. */
|
|
1666
|
-
scrollToIndex: (rowIndex
|
|
1930
|
+
scrollToIndex: (rowIndex?: number | null, colIndex?: number | null, options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions) => void;
|
|
1667
1931
|
/** Programmatically scroll to a specific pixel offset. */
|
|
1668
1932
|
scrollToOffset: (x?: number | null, y?: number | null, options?: {
|
|
1669
1933
|
behavior?: 'auto' | 'smooth';
|