@pdanpdan/virtual-scroll 0.4.0 → 0.6.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 +172 -324
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +836 -376
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1334 -741
- package/dist/index.mjs.map +1 -1
- package/dist/virtual-scroll.css +1 -1
- package/package.json +8 -2
- package/src/components/VirtualScroll.test.ts +1921 -325
- package/src/components/VirtualScroll.vue +829 -386
- package/src/components/VirtualScrollbar.test.ts +174 -0
- package/src/components/VirtualScrollbar.vue +102 -0
- package/src/composables/useVirtualScroll.test.ts +1506 -228
- package/src/composables/useVirtualScroll.ts +869 -517
- package/src/composables/useVirtualScrollbar.test.ts +526 -0
- package/src/composables/useVirtualScrollbar.ts +244 -0
- package/src/index.ts +9 -0
- package/src/types.ts +353 -110
- package/src/utils/fenwick-tree.test.ts +39 -39
- package/src/utils/scroll.test.ts +181 -101
- package/src/utils/scroll.ts +43 -5
- package/src/utils/virtual-scroll-logic.test.ts +673 -323
- package/src/utils/virtual-scroll-logic.ts +759 -430
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 -
|
|
19
|
-
* @
|
|
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(
|
|
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 -
|
|
34
|
-
* @
|
|
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(
|
|
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 -
|
|
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>(
|
|
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 -
|
|
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(
|
|
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,73 @@ 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 -
|
|
69
|
-
* @
|
|
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(
|
|
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 -
|
|
79
|
-
* @
|
|
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.gap - Item gap (VU).
|
|
182
|
+
* @param params.columnGap - Column gap (VU).
|
|
183
|
+
* @param params.getItemQueryY - Resolver for vertical offset (VU).
|
|
184
|
+
* @param params.getItemQueryX - Resolver for horizontal offset (VU).
|
|
185
|
+
* @returns Sticky state and offset (VU).
|
|
80
186
|
* @see StickyParams
|
|
81
187
|
*/
|
|
82
|
-
export declare function calculateStickyItem(
|
|
188
|
+
export declare function calculateStickyItem({ index, isSticky, direction, relativeScrollX, relativeScrollY, originalX, originalY, width, height, stickyIndices, fixedSize, gap, columnGap, getItemQueryY, getItemQueryX, }: StickyParams): {
|
|
189
|
+
isStickyActiveX: boolean;
|
|
190
|
+
isStickyActiveY: boolean;
|
|
83
191
|
isStickyActive: boolean;
|
|
84
192
|
stickyOffset: {
|
|
85
193
|
x: number;
|
|
@@ -90,15 +198,39 @@ export declare function calculateStickyItem(params: StickyParams): {
|
|
|
90
198
|
/**
|
|
91
199
|
* Calculates the total width and height of the virtualized content.
|
|
92
200
|
*
|
|
93
|
-
* @param params -
|
|
94
|
-
* @
|
|
201
|
+
* @param params - Total size parameters.
|
|
202
|
+
* @param params.direction - Scroll direction.
|
|
203
|
+
* @param params.itemsLength - Total item count.
|
|
204
|
+
* @param params.columnCount - Column count.
|
|
205
|
+
* @param params.fixedSize - Fixed item size (VU).
|
|
206
|
+
* @param params.fixedWidth - Fixed column width (VU).
|
|
207
|
+
* @param params.gap - Item gap (VU).
|
|
208
|
+
* @param params.columnGap - Column gap (VU).
|
|
209
|
+
* @param params.usableWidth - Usable viewport width (VU).
|
|
210
|
+
* @param params.usableHeight - Usable viewport height (VU).
|
|
211
|
+
* @param params.queryY - Resolver for vertical offset (VU).
|
|
212
|
+
* @param params.queryX - Resolver for horizontal offset (VU).
|
|
213
|
+
* @param params.queryColumn - Resolver for column offset (VU).
|
|
214
|
+
* @returns Total width and height (VU).
|
|
95
215
|
* @see TotalSizeParams
|
|
96
216
|
*/
|
|
97
|
-
export declare function calculateTotalSize(
|
|
217
|
+
export declare function calculateTotalSize({ direction, itemsLength, columnCount, fixedSize, fixedWidth, gap, columnGap, usableWidth, usableHeight, queryY, queryX, queryColumn, }: TotalSizeParams): {
|
|
98
218
|
width: number;
|
|
99
219
|
height: number;
|
|
100
220
|
};
|
|
101
221
|
|
|
222
|
+
/** Information about the currently visible range of columns and their paddings. */
|
|
223
|
+
export declare interface ColumnRange {
|
|
224
|
+
/** Inclusive start index. */
|
|
225
|
+
start: number;
|
|
226
|
+
/** Exclusive end index. */
|
|
227
|
+
end: number;
|
|
228
|
+
/** Pixel padding to maintain at the start of the row in VU. */
|
|
229
|
+
padStart: number;
|
|
230
|
+
/** Pixel padding to maintain at the end of the row in VU. */
|
|
231
|
+
padEnd: number;
|
|
232
|
+
}
|
|
233
|
+
|
|
102
234
|
/** Parameters for calculating the visible range of columns in grid mode. */
|
|
103
235
|
export declare interface ColumnRangeParams {
|
|
104
236
|
/** Column count. */
|
|
@@ -121,12 +253,28 @@ export declare interface ColumnRangeParams {
|
|
|
121
253
|
totalColsQuery: () => number;
|
|
122
254
|
}
|
|
123
255
|
|
|
256
|
+
/** Default number of items to render outside the viewport. */
|
|
124
257
|
export declare const DEFAULT_BUFFER = 5;
|
|
125
258
|
|
|
259
|
+
/** Default fallback width for columns (VU). */
|
|
126
260
|
export declare const DEFAULT_COLUMN_WIDTH = 100;
|
|
127
261
|
|
|
262
|
+
/** Default fallback size for items (VU). */
|
|
128
263
|
export declare const DEFAULT_ITEM_SIZE = 40;
|
|
129
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Maps a display scroll position to a virtual content position.
|
|
267
|
+
*
|
|
268
|
+
* @param displayPos - Display pixel position (DU).
|
|
269
|
+
* @param hostOffset - Offset of the host element in display pixels (DU).
|
|
270
|
+
* @param scale - Coordinate scaling factor (VU/DU).
|
|
271
|
+
* @returns Virtual content position (VU).
|
|
272
|
+
*/
|
|
273
|
+
export declare function displayToVirtual(displayPos: number, hostOffset: number, scale: number): number;
|
|
274
|
+
|
|
275
|
+
/** Initial empty state for scroll details. */
|
|
276
|
+
export declare const EMPTY_SCROLL_DETAILS: ScrollDetails<unknown>;
|
|
277
|
+
|
|
130
278
|
/**
|
|
131
279
|
* Fenwick Tree (Binary Indexed Tree) implementation for efficient
|
|
132
280
|
* prefix sum calculations and updates.
|
|
@@ -209,6 +357,15 @@ export declare class FenwickTree {
|
|
|
209
357
|
shift(offset: number): void;
|
|
210
358
|
}
|
|
211
359
|
|
|
360
|
+
/**
|
|
361
|
+
* Binary search for the previous sticky index before the current index.
|
|
362
|
+
*
|
|
363
|
+
* @param stickyIndices - Sorted array of sticky indices.
|
|
364
|
+
* @param index - Current index.
|
|
365
|
+
* @returns Previous sticky index or undefined.
|
|
366
|
+
*/
|
|
367
|
+
export declare function findPrevStickyIndex(stickyIndices: number[], index: number): number | undefined;
|
|
368
|
+
|
|
212
369
|
/**
|
|
213
370
|
* Extracts the horizontal padding from a padding configuration.
|
|
214
371
|
*
|
|
@@ -249,6 +406,19 @@ export declare function isBody(container: HTMLElement | Window | null | undefine
|
|
|
249
406
|
*/
|
|
250
407
|
export declare function isElement(container: HTMLElement | Window | null | undefined): container is HTMLElement;
|
|
251
408
|
|
|
409
|
+
/**
|
|
410
|
+
* Determines if an item is visible within the usable viewport.
|
|
411
|
+
*
|
|
412
|
+
* @param itemPos - Virtual start position of the item (VU).
|
|
413
|
+
* @param itemSize - Virtual size of the item (VU).
|
|
414
|
+
* @param scrollPos - Virtual scroll position (VU).
|
|
415
|
+
* @param viewSize - Full size of the viewport (VU).
|
|
416
|
+
* @param stickyOffsetStart - Dynamic offset from sticky items at start (VU).
|
|
417
|
+
* @param stickyOffsetEnd - Offset from sticky items at end (VU).
|
|
418
|
+
* @returns True if visible.
|
|
419
|
+
*/
|
|
420
|
+
export declare function isItemVisible(itemPos: number, itemSize: number, scrollPos: number, viewSize: number, stickyOffsetStart?: number, stickyOffsetEnd?: number): boolean;
|
|
421
|
+
|
|
252
422
|
/**
|
|
253
423
|
* Checks if the target is an element that supports scrolling.
|
|
254
424
|
*
|
|
@@ -307,6 +477,8 @@ export declare interface ItemPositionParams {
|
|
|
307
477
|
getSizeY: (idx: number) => number;
|
|
308
478
|
/** Width resolver. */
|
|
309
479
|
getSizeX: (idx: number) => number;
|
|
480
|
+
/** Current column range (for grid mode). */
|
|
481
|
+
columnRange?: ColumnRange | undefined;
|
|
310
482
|
}
|
|
311
483
|
|
|
312
484
|
/** Properties passed to the 'item' scoped slot. */
|
|
@@ -316,22 +488,28 @@ export declare interface ItemSlotProps<T = unknown> {
|
|
|
316
488
|
/** The 0-based index of the item. */
|
|
317
489
|
index: number;
|
|
318
490
|
/** Information about the currently visible range of columns. */
|
|
319
|
-
columnRange:
|
|
320
|
-
/** First rendered column. */
|
|
321
|
-
start: number;
|
|
322
|
-
/** Last rendered column (exclusive). */
|
|
323
|
-
end: number;
|
|
324
|
-
/** Pixel space before first column. */
|
|
325
|
-
padStart: number;
|
|
326
|
-
/** Pixel space after last column. */
|
|
327
|
-
padEnd: number;
|
|
328
|
-
};
|
|
491
|
+
columnRange: ColumnRange;
|
|
329
492
|
/** Helper to get the current calculated width of any column index. */
|
|
330
493
|
getColumnWidth: (index: number) => number;
|
|
494
|
+
/** Vertical gap between items. */
|
|
495
|
+
gap: number;
|
|
496
|
+
/** Horizontal gap between columns. */
|
|
497
|
+
columnGap: number;
|
|
331
498
|
/** Whether this item index is configured as sticky. */
|
|
332
499
|
isSticky?: boolean | undefined;
|
|
333
500
|
/** Whether this item is currently in a sticky state at the edge. */
|
|
334
501
|
isStickyActive?: boolean | undefined;
|
|
502
|
+
/** Whether this item is currently in a sticky state at the horizontal edge. */
|
|
503
|
+
isStickyActiveX?: boolean | undefined;
|
|
504
|
+
/** Whether this item is currently in a sticky state at the vertical edge. */
|
|
505
|
+
isStickyActiveY?: boolean | undefined;
|
|
506
|
+
/** The calculated pixel offset relative to the items wrapper in display pixels (DU). */
|
|
507
|
+
offset: {
|
|
508
|
+
/** Horizontal offset (left) in DU. */
|
|
509
|
+
x: number;
|
|
510
|
+
/** Vertical offset (top) in DU. */
|
|
511
|
+
y: number;
|
|
512
|
+
};
|
|
335
513
|
}
|
|
336
514
|
|
|
337
515
|
/** Parameters for calculating an item's style object. */
|
|
@@ -350,178 +528,28 @@ export declare interface ItemStyleParams<T = unknown> {
|
|
|
350
528
|
paddingStartY: number;
|
|
351
529
|
/** Hydration state. */
|
|
352
530
|
isHydrated: boolean;
|
|
531
|
+
/** Whether the container is in Right-to-Left (RTL) mode. */
|
|
532
|
+
isRtl: boolean;
|
|
353
533
|
}
|
|
354
534
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
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;
|
|
535
|
+
/** Pixel padding configuration in display pixels (DU). */
|
|
536
|
+
export declare type PaddingValue = number | {
|
|
537
|
+
x?: number;
|
|
538
|
+
y?: number;
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
/** Represents a point in 2D space. */
|
|
542
|
+
export declare interface Point {
|
|
543
|
+
/** X coordinate. */
|
|
544
|
+
x: number;
|
|
545
|
+
/** Y coordinate. */
|
|
546
|
+
y: number;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
declare interface Props<T = unknown> extends VirtualScrollComponentProps<T> {
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
declare interface Props_2 extends VirtualScrollbarProps {
|
|
525
553
|
}
|
|
526
554
|
|
|
527
555
|
/** Parameters for calculating the visible range of items. */
|
|
@@ -564,35 +592,24 @@ export declare interface RenderedItem<T = unknown> {
|
|
|
564
592
|
item: T;
|
|
565
593
|
/** The 0-based index of the item in the original array. */
|
|
566
594
|
index: number;
|
|
567
|
-
/** The calculated pixel offset relative to the items wrapper. */
|
|
568
|
-
offset:
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
y: number;
|
|
573
|
-
};
|
|
574
|
-
/** The current measured or estimated size of the item. */
|
|
575
|
-
size: {
|
|
576
|
-
/** Pixel width. */
|
|
577
|
-
width: number;
|
|
578
|
-
/** Pixel height. */
|
|
579
|
-
height: number;
|
|
580
|
-
};
|
|
581
|
-
/** The original horizontal pixel offset before any sticky adjustments. */
|
|
595
|
+
/** The calculated pixel offset relative to the items wrapper in display pixels (DU). */
|
|
596
|
+
offset: Point;
|
|
597
|
+
/** The current measured or estimated size of the item in virtual units (VU). */
|
|
598
|
+
size: Size;
|
|
599
|
+
/** The original horizontal pixel offset before any sticky adjustments in VU. */
|
|
582
600
|
originalX: number;
|
|
583
|
-
/** The original vertical pixel offset before any sticky adjustments. */
|
|
601
|
+
/** The original vertical pixel offset before any sticky adjustments in VU. */
|
|
584
602
|
originalY: number;
|
|
585
603
|
/** Whether this item is configured to be sticky via the `stickyIndices` property. */
|
|
586
604
|
isSticky?: boolean;
|
|
587
605
|
/** Whether this item is currently in a stuck state at the viewport edge. */
|
|
588
606
|
isStickyActive?: boolean;
|
|
589
|
-
/**
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
};
|
|
607
|
+
/** Whether this item is currently in a stuck state at the horizontal viewport edge. */
|
|
608
|
+
isStickyActiveX?: boolean;
|
|
609
|
+
/** Whether this item is currently in a stuck state at the vertical viewport edge. */
|
|
610
|
+
isStickyActiveY?: boolean;
|
|
611
|
+
/** The relative translation applied to the item for the sticky pushing effect in DU. */
|
|
612
|
+
stickyOffset: Point;
|
|
596
613
|
}
|
|
597
614
|
|
|
598
615
|
/**
|
|
@@ -612,35 +629,62 @@ export declare interface ScrollAlignmentOptions {
|
|
|
612
629
|
y?: ScrollAlignment;
|
|
613
630
|
}
|
|
614
631
|
|
|
632
|
+
/** Help provide axis specific information to the scrollbar. */
|
|
633
|
+
export declare type ScrollAxis = 'vertical' | 'horizontal';
|
|
634
|
+
|
|
635
|
+
/** Properties passed to the 'scrollbar' scoped slot. */
|
|
636
|
+
export declare interface ScrollbarSlotProps {
|
|
637
|
+
/** The axis for this scrollbar. */
|
|
638
|
+
axis: ScrollAxis;
|
|
639
|
+
/** Current scroll position as a percentage (0 to 1). */
|
|
640
|
+
positionPercent: number;
|
|
641
|
+
/** Viewport size as a percentage of total size (0 to 1). */
|
|
642
|
+
viewportPercent: number;
|
|
643
|
+
/** Calculated thumb size as a percentage of the track size (0 to 100). */
|
|
644
|
+
thumbSizePercent: number;
|
|
645
|
+
/** Calculated thumb position as a percentage of the track size (0 to 100). */
|
|
646
|
+
thumbPositionPercent: number;
|
|
647
|
+
/**
|
|
648
|
+
* Attributes and event listeners to be bound to the scrollbar track element.
|
|
649
|
+
* Use `v-bind="trackProps"` on your track element.
|
|
650
|
+
*/
|
|
651
|
+
trackProps: Record<string, unknown>;
|
|
652
|
+
/**
|
|
653
|
+
* Attributes and event listeners to be bound to the scrollbar thumb element.
|
|
654
|
+
* Use `v-bind="thumbProps"` on your thumb element.
|
|
655
|
+
*/
|
|
656
|
+
thumbProps: Record<string, unknown>;
|
|
657
|
+
/**
|
|
658
|
+
* Grouped props for the `VirtualScrollbar` component.
|
|
659
|
+
* Useful for passing directly to `<VirtualScrollbar v-bind="scrollbarProps" />`.
|
|
660
|
+
*/
|
|
661
|
+
scrollbarProps: VirtualScrollbarProps;
|
|
662
|
+
/** Whether the thumb is currently being dragged. */
|
|
663
|
+
isDragging: boolean;
|
|
664
|
+
}
|
|
665
|
+
|
|
615
666
|
/** Comprehensive state of the virtual scroll system. */
|
|
616
667
|
export declare interface ScrollDetails<T = unknown> {
|
|
617
668
|
/** List of items currently rendered in the DOM buffer. */
|
|
618
669
|
items: RenderedItem<T>[];
|
|
619
|
-
/** Index of the first item
|
|
670
|
+
/** Index of the first item visible below any sticky header in the viewport. */
|
|
620
671
|
currentIndex: number;
|
|
621
|
-
/** Index of the first column
|
|
672
|
+
/** Index of the first column visible after any sticky column in the viewport (grid mode). */
|
|
622
673
|
currentColIndex: number;
|
|
623
|
-
/**
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
/** Total calculated or estimated size of all items and gaps. */
|
|
638
|
-
totalSize: {
|
|
639
|
-
/** Total pixel width. */
|
|
640
|
-
width: number;
|
|
641
|
-
/** Total pixel height. */
|
|
642
|
-
height: number;
|
|
643
|
-
};
|
|
674
|
+
/** Index of the last item visible above any sticky footer in the viewport. */
|
|
675
|
+
currentEndIndex: number;
|
|
676
|
+
/** Index of the last column visible before any sticky end column in the viewport (grid mode). */
|
|
677
|
+
currentEndColIndex: number;
|
|
678
|
+
/** Current relative pixel scroll position from the content start in VU. */
|
|
679
|
+
scrollOffset: Point;
|
|
680
|
+
/** Current display pixel scroll position (before scaling) in DU. */
|
|
681
|
+
displayScrollOffset: Point;
|
|
682
|
+
/** Current dimensions of the visible viewport area in VU. */
|
|
683
|
+
viewportSize: Size;
|
|
684
|
+
/** Current dimensions of the visible viewport area in display pixels (DU). */
|
|
685
|
+
displayViewportSize: Size;
|
|
686
|
+
/** Total calculated or estimated size of all items and gaps in VU. */
|
|
687
|
+
totalSize: Size;
|
|
644
688
|
/** Whether the container is currently being scrolled by the user or an animation. */
|
|
645
689
|
isScrolling: boolean;
|
|
646
690
|
/** Whether the current scroll operation was initiated programmatically. */
|
|
@@ -653,16 +697,7 @@ export declare interface ScrollDetails<T = unknown> {
|
|
|
653
697
|
end: number;
|
|
654
698
|
};
|
|
655
699
|
/** 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
|
-
};
|
|
700
|
+
columnRange: ColumnRange;
|
|
666
701
|
}
|
|
667
702
|
|
|
668
703
|
/**
|
|
@@ -681,16 +716,12 @@ export declare interface ScrollTargetParams {
|
|
|
681
716
|
colIndex: number | null | undefined;
|
|
682
717
|
/** Scroll options. */
|
|
683
718
|
options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions | undefined;
|
|
684
|
-
/** Total items count. */
|
|
685
|
-
itemsLength: number;
|
|
686
|
-
/** Total columns count. */
|
|
687
|
-
columnCount: number;
|
|
688
719
|
/** Current scroll direction. */
|
|
689
720
|
direction: ScrollDirection;
|
|
690
|
-
/**
|
|
691
|
-
|
|
692
|
-
/**
|
|
693
|
-
|
|
721
|
+
/** Current viewport width. */
|
|
722
|
+
viewportWidth: number;
|
|
723
|
+
/** Current viewport height. */
|
|
724
|
+
viewportHeight: number;
|
|
694
725
|
/** Current total estimated width. */
|
|
695
726
|
totalWidth: number;
|
|
696
727
|
/** Current total estimated height. */
|
|
@@ -719,8 +750,36 @@ export declare interface ScrollTargetParams {
|
|
|
719
750
|
getColumnSize: (index: number) => number;
|
|
720
751
|
/** Prefix sum resolver for column width. */
|
|
721
752
|
getColumnQuery: (index: number) => number;
|
|
753
|
+
/** Coordinate scaling factor for X axis. */
|
|
754
|
+
scaleX: number;
|
|
755
|
+
/** Coordinate scaling factor for Y axis. */
|
|
756
|
+
scaleY: number;
|
|
757
|
+
/** Host offset on X axis in display pixels. */
|
|
758
|
+
hostOffsetX: number;
|
|
759
|
+
/** Host offset on Y axis in display pixels. */
|
|
760
|
+
hostOffsetY: number;
|
|
722
761
|
/** List of sticky indices. */
|
|
723
762
|
stickyIndices?: number[] | undefined;
|
|
763
|
+
/** Sticky start offset on X axis. */
|
|
764
|
+
stickyStartX?: number | undefined;
|
|
765
|
+
/** Sticky start offset on Y axis. */
|
|
766
|
+
stickyStartY?: number | undefined;
|
|
767
|
+
/** Sticky end offset on X axis. */
|
|
768
|
+
stickyEndX?: number | undefined;
|
|
769
|
+
/** Sticky end offset on Y axis. */
|
|
770
|
+
stickyEndY?: number | undefined;
|
|
771
|
+
/** Flow padding start on X axis. */
|
|
772
|
+
flowPaddingStartX?: number | undefined;
|
|
773
|
+
/** Flow padding start on Y axis. */
|
|
774
|
+
flowPaddingStartY?: number | undefined;
|
|
775
|
+
/** Scroll padding start on X axis. */
|
|
776
|
+
paddingStartX?: number | undefined;
|
|
777
|
+
/** Scroll padding start on Y axis. */
|
|
778
|
+
paddingStartY?: number | undefined;
|
|
779
|
+
/** Scroll padding end on X axis. */
|
|
780
|
+
paddingEndX?: number | undefined;
|
|
781
|
+
/** Scroll padding end on Y axis. */
|
|
782
|
+
paddingEndY?: number | undefined;
|
|
724
783
|
}
|
|
725
784
|
|
|
726
785
|
/** Calculated scroll target result. */
|
|
@@ -739,6 +798,15 @@ export declare interface ScrollTargetResult {
|
|
|
739
798
|
effectiveAlignY: ScrollAlignment;
|
|
740
799
|
}
|
|
741
800
|
|
|
801
|
+
/**
|
|
802
|
+
* Universal scroll function that handles both Window and HTMLElements.
|
|
803
|
+
*
|
|
804
|
+
* @param container - The container to scroll.
|
|
805
|
+
* @param options - Scroll options.
|
|
806
|
+
*/
|
|
807
|
+
declare function scrollTo_2(container: HTMLElement | Window | null | undefined, options: ScrollToOptions): void;
|
|
808
|
+
export { scrollTo_2 as scrollTo }
|
|
809
|
+
|
|
742
810
|
/** Options for the `scrollToIndex` method. */
|
|
743
811
|
export declare interface ScrollToIndexOptions {
|
|
744
812
|
/**
|
|
@@ -757,6 +825,29 @@ export declare interface ScrollToIndexOptions {
|
|
|
757
825
|
/* Excluded from this release type: isCorrection */
|
|
758
826
|
}
|
|
759
827
|
|
|
828
|
+
/** Represents dimensions in 2D space. */
|
|
829
|
+
export declare interface Size {
|
|
830
|
+
/** Width dimension. */
|
|
831
|
+
width: number;
|
|
832
|
+
/** Height dimension. */
|
|
833
|
+
height: number;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Configuration for Server-Side Rendering.
|
|
838
|
+
* Defines which items are rendered statically on the server.
|
|
839
|
+
*/
|
|
840
|
+
export declare interface SSRRange {
|
|
841
|
+
/** First row index (for list or grid). */
|
|
842
|
+
start: number;
|
|
843
|
+
/** Exclusive last row index (for list or grid). */
|
|
844
|
+
end: number;
|
|
845
|
+
/** First column index (for grid mode). */
|
|
846
|
+
colStart?: number;
|
|
847
|
+
/** Exclusive last column index (for grid mode). */
|
|
848
|
+
colEnd?: number;
|
|
849
|
+
}
|
|
850
|
+
|
|
760
851
|
/** Parameters for calculating sticky item offsets. */
|
|
761
852
|
export declare interface StickyParams {
|
|
762
853
|
/** Item index. */
|
|
@@ -825,29 +916,80 @@ export declare interface TotalSizeParams {
|
|
|
825
916
|
* Composable for virtual scrolling logic.
|
|
826
917
|
* Handles calculation of visible items, scroll events, dynamic item sizes, and programmatic scrolling.
|
|
827
918
|
*
|
|
828
|
-
* @param
|
|
919
|
+
* @param propsInput - The configuration properties. Can be a plain object, a Ref, or a getter function.
|
|
829
920
|
* @see VirtualScrollProps
|
|
830
921
|
*/
|
|
831
|
-
export declare function useVirtualScroll<T = unknown>(
|
|
922
|
+
export declare function useVirtualScroll<T = unknown>(propsInput: MaybeRefOrGetter<VirtualScrollProps<T>>): {
|
|
832
923
|
/**
|
|
833
924
|
* Array of items currently rendered in the DOM with their calculated offsets and sizes.
|
|
925
|
+
* Offsets are in Display Units (DU), sizes are in Virtual Units (VU).
|
|
834
926
|
* @see RenderedItem
|
|
835
927
|
*/
|
|
836
928
|
renderedItems: ComputedRef<RenderedItem<T>[]>;
|
|
837
929
|
/**
|
|
838
|
-
* Total calculated width of all items including gaps (in
|
|
930
|
+
* Total calculated width of all items including gaps (in VU).
|
|
839
931
|
*/
|
|
840
932
|
totalWidth: ComputedRef<number>;
|
|
841
933
|
/**
|
|
842
|
-
* Total calculated height of all items including gaps (in
|
|
934
|
+
* Total calculated height of all items including gaps (in VU).
|
|
843
935
|
*/
|
|
844
936
|
totalHeight: ComputedRef<number>;
|
|
937
|
+
/**
|
|
938
|
+
* Total width to be rendered in the DOM (clamped to browser limits, in DU).
|
|
939
|
+
*/
|
|
940
|
+
renderedWidth: ComputedRef<number>;
|
|
941
|
+
/**
|
|
942
|
+
* Total height to be rendered in the DOM (clamped to browser limits, in DU).
|
|
943
|
+
*/
|
|
944
|
+
renderedHeight: ComputedRef<number>;
|
|
845
945
|
/**
|
|
846
946
|
* Detailed information about the current scroll state.
|
|
847
|
-
* Includes currentIndex, scrollOffset, viewportSize, totalSize, and scrolling status.
|
|
947
|
+
* Includes currentIndex, scrollOffset (VU), displayScrollOffset (DU), viewportSize (DU), totalSize (VU), and scrolling status.
|
|
848
948
|
* @see ScrollDetails
|
|
849
949
|
*/
|
|
850
950
|
scrollDetails: ComputedRef<ScrollDetails<T>>;
|
|
951
|
+
/**
|
|
952
|
+
* Helper to get the height of a specific row based on current configuration and measurements.
|
|
953
|
+
*
|
|
954
|
+
* @param index - The row index.
|
|
955
|
+
* @returns The height in VU (excluding gap).
|
|
956
|
+
*/
|
|
957
|
+
getRowHeight: (index: number) => number;
|
|
958
|
+
/**
|
|
959
|
+
* Helper to get the width of a specific column based on current configuration and measurements.
|
|
960
|
+
*
|
|
961
|
+
* @param index - The column index.
|
|
962
|
+
* @returns The width in VU (excluding gap).
|
|
963
|
+
*/
|
|
964
|
+
getColumnWidth: (index: number) => number;
|
|
965
|
+
/**
|
|
966
|
+
* Helper to get the virtual offset of a specific row.
|
|
967
|
+
*
|
|
968
|
+
* @param index - The row index.
|
|
969
|
+
* @returns The virtual offset in VU.
|
|
970
|
+
*/
|
|
971
|
+
getRowOffset: (index: number) => number;
|
|
972
|
+
/**
|
|
973
|
+
* Helper to get the virtual offset of a specific column.
|
|
974
|
+
*
|
|
975
|
+
* @param index - The column index.
|
|
976
|
+
* @returns The virtual offset in VU.
|
|
977
|
+
*/
|
|
978
|
+
getColumnOffset: (index: number) => number;
|
|
979
|
+
/**
|
|
980
|
+
* Helper to get the virtual offset of a specific item along the scroll axis.
|
|
981
|
+
*
|
|
982
|
+
* @param index - The item index.
|
|
983
|
+
* @returns The virtual offset in VU.
|
|
984
|
+
*/
|
|
985
|
+
getItemOffset: (index: number) => number;
|
|
986
|
+
/**
|
|
987
|
+
* Helper to get the size of a specific item along the scroll axis.
|
|
988
|
+
*
|
|
989
|
+
* @param index - The item index.
|
|
990
|
+
* @returns The size in VU (excluding gap).
|
|
991
|
+
*/
|
|
992
|
+
getItemSize: (index: number) => number;
|
|
851
993
|
/**
|
|
852
994
|
* Programmatically scroll to a specific row and/or column.
|
|
853
995
|
*
|
|
@@ -861,8 +1003,8 @@ export declare function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollPr
|
|
|
861
1003
|
/**
|
|
862
1004
|
* Programmatically scroll to a specific pixel offset relative to the content start.
|
|
863
1005
|
*
|
|
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.
|
|
1006
|
+
* @param x - The pixel offset to scroll to on the X axis (VU). Pass null to keep current position.
|
|
1007
|
+
* @param y - The pixel offset to scroll to on the Y axis (VU). Pass null to keep current position.
|
|
866
1008
|
* @param options - Scroll options (behavior).
|
|
867
1009
|
*/
|
|
868
1010
|
scrollToOffset: (x?: number | null, y?: number | null, options?: {
|
|
@@ -876,15 +1018,15 @@ export declare function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollPr
|
|
|
876
1018
|
* Updates the stored size of an item. Should be called when an item is measured (e.g., via ResizeObserver).
|
|
877
1019
|
*
|
|
878
1020
|
* @param index - The item index.
|
|
879
|
-
* @param width - The measured inlineSize (width).
|
|
880
|
-
* @param height - The measured blockSize (height).
|
|
1021
|
+
* @param width - The measured inlineSize (width in DU).
|
|
1022
|
+
* @param height - The measured blockSize (height in DU).
|
|
881
1023
|
* @param element - The measured element (optional, used for robust grid column detection).
|
|
882
1024
|
*/
|
|
883
1025
|
updateItemSize: (index: number, inlineSize: number, blockSize: number, element?: HTMLElement) => void;
|
|
884
1026
|
/**
|
|
885
1027
|
* Updates the stored size of multiple items simultaneously.
|
|
886
1028
|
*
|
|
887
|
-
* @param updates - Array of measurement updates.
|
|
1029
|
+
* @param updates - Array of measurement updates (sizes in DU).
|
|
888
1030
|
*/
|
|
889
1031
|
updateItemSizes: (updates: Array<{
|
|
890
1032
|
index: number;
|
|
@@ -897,6 +1039,10 @@ export declare function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollPr
|
|
|
897
1039
|
* Useful if the container or host moves without a resize event.
|
|
898
1040
|
*/
|
|
899
1041
|
updateHostOffset: () => void;
|
|
1042
|
+
/**
|
|
1043
|
+
* Detects the current direction (LTR/RTL) of the scroll container.
|
|
1044
|
+
*/
|
|
1045
|
+
updateDirection: () => void;
|
|
900
1046
|
/**
|
|
901
1047
|
* Information about the current visible range of columns and their paddings.
|
|
902
1048
|
* @see ColumnRange
|
|
@@ -907,12 +1053,6 @@ export declare function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollPr
|
|
|
907
1053
|
padStart: number;
|
|
908
1054
|
padEnd: number;
|
|
909
1055
|
}>;
|
|
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
1056
|
/**
|
|
917
1057
|
* Resets all dynamic measurements and re-initializes from props.
|
|
918
1058
|
* Useful if item sizes have changed externally.
|
|
@@ -922,8 +1062,139 @@ export declare function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollPr
|
|
|
922
1062
|
* Whether the component has finished its first client-side mount and hydration.
|
|
923
1063
|
*/
|
|
924
1064
|
isHydrated: Ref<boolean, boolean>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Whether the container is the window or body.
|
|
1067
|
+
*/
|
|
1068
|
+
isWindowContainer: ComputedRef<boolean>;
|
|
1069
|
+
/**
|
|
1070
|
+
* Whether the scroll container is in Right-to-Left (RTL) mode.
|
|
1071
|
+
*/
|
|
1072
|
+
isRtl: Ref<boolean, boolean>;
|
|
1073
|
+
/**
|
|
1074
|
+
* Coordinate scaling factor for X axis (VU/DU).
|
|
1075
|
+
*/
|
|
1076
|
+
scaleX: ComputedRef<number>;
|
|
1077
|
+
/**
|
|
1078
|
+
* Coordinate scaling factor for Y axis (VU/DU).
|
|
1079
|
+
*/
|
|
1080
|
+
scaleY: ComputedRef<number>;
|
|
1081
|
+
/**
|
|
1082
|
+
* Absolute offset of the component within its container (DU).
|
|
1083
|
+
*/
|
|
1084
|
+
componentOffset: {
|
|
1085
|
+
x: number;
|
|
1086
|
+
y: number;
|
|
1087
|
+
};
|
|
1088
|
+
/**
|
|
1089
|
+
* Physical width of the items wrapper in the DOM (clamped to browser limits, in DU).
|
|
1090
|
+
*/
|
|
1091
|
+
renderedVirtualWidth: ComputedRef<number>;
|
|
1092
|
+
/**
|
|
1093
|
+
* Physical height of the items wrapper in the DOM (clamped to browser limits, in DU).
|
|
1094
|
+
*/
|
|
1095
|
+
renderedVirtualHeight: ComputedRef<number>;
|
|
925
1096
|
};
|
|
926
1097
|
|
|
1098
|
+
/**
|
|
1099
|
+
* Composable for virtual scrollbar logic.
|
|
1100
|
+
* Provides attributes and event listeners for track and thumb elements.
|
|
1101
|
+
*
|
|
1102
|
+
* @param props - Configuration properties.
|
|
1103
|
+
*/
|
|
1104
|
+
export declare function useVirtualScrollbar(props: UseVirtualScrollbarProps): {
|
|
1105
|
+
/** Viewport size as a percentage of total size (0 to 1). */
|
|
1106
|
+
viewportPercent: ComputedRef<number>;
|
|
1107
|
+
/** Current scroll position as a percentage of the scrollable range (0 to 1). */
|
|
1108
|
+
positionPercent: ComputedRef<number>;
|
|
1109
|
+
/** Calculated thumb size as a percentage of the track size (0 to 100). */
|
|
1110
|
+
thumbSizePercent: ComputedRef<number>;
|
|
1111
|
+
/** Calculated thumb position as a percentage of the track size (0 to 100). */
|
|
1112
|
+
thumbPositionPercent: ComputedRef<number>;
|
|
1113
|
+
/** Reactive style object for the scrollbar track. */
|
|
1114
|
+
trackStyle: ComputedRef< {
|
|
1115
|
+
inlineSize: string;
|
|
1116
|
+
blockSize?: never;
|
|
1117
|
+
} | {
|
|
1118
|
+
blockSize: string;
|
|
1119
|
+
inlineSize?: never;
|
|
1120
|
+
}>;
|
|
1121
|
+
/** Reactive style object for the scrollbar thumb. */
|
|
1122
|
+
thumbStyle: ComputedRef< {
|
|
1123
|
+
inlineSize: string;
|
|
1124
|
+
insetInlineStart: string;
|
|
1125
|
+
blockSize?: never;
|
|
1126
|
+
insetBlockStart?: never;
|
|
1127
|
+
} | {
|
|
1128
|
+
blockSize: string;
|
|
1129
|
+
insetBlockStart: string;
|
|
1130
|
+
inlineSize?: never;
|
|
1131
|
+
insetInlineStart?: never;
|
|
1132
|
+
}>;
|
|
1133
|
+
/** Attributes and event listeners to be bound to the track element. */
|
|
1134
|
+
trackProps: ComputedRef< {
|
|
1135
|
+
class: string[];
|
|
1136
|
+
style: {
|
|
1137
|
+
inlineSize: string;
|
|
1138
|
+
blockSize?: never;
|
|
1139
|
+
} | {
|
|
1140
|
+
blockSize: string;
|
|
1141
|
+
inlineSize?: never;
|
|
1142
|
+
};
|
|
1143
|
+
role: string;
|
|
1144
|
+
'aria-orientation': ScrollAxis;
|
|
1145
|
+
'aria-valuenow': number;
|
|
1146
|
+
'aria-valuemin': number;
|
|
1147
|
+
'aria-valuemax': number;
|
|
1148
|
+
'aria-controls': string | undefined;
|
|
1149
|
+
tabindex: number;
|
|
1150
|
+
onMousedown: (event: MouseEvent) => void;
|
|
1151
|
+
}>;
|
|
1152
|
+
/** Attributes and event listeners to be bound to the thumb element. */
|
|
1153
|
+
thumbProps: ComputedRef< {
|
|
1154
|
+
class: (string | {
|
|
1155
|
+
'virtual-scrollbar-thumb--active': boolean;
|
|
1156
|
+
})[];
|
|
1157
|
+
style: {
|
|
1158
|
+
inlineSize: string;
|
|
1159
|
+
insetInlineStart: string;
|
|
1160
|
+
blockSize?: never;
|
|
1161
|
+
insetBlockStart?: never;
|
|
1162
|
+
} | {
|
|
1163
|
+
blockSize: string;
|
|
1164
|
+
insetBlockStart: string;
|
|
1165
|
+
inlineSize?: never;
|
|
1166
|
+
insetInlineStart?: never;
|
|
1167
|
+
};
|
|
1168
|
+
onPointerdown: (event: PointerEvent) => void;
|
|
1169
|
+
onPointermove: (event: PointerEvent) => void;
|
|
1170
|
+
onPointerup: (event: PointerEvent) => void;
|
|
1171
|
+
onPointercancel: (event: PointerEvent) => void;
|
|
1172
|
+
}>;
|
|
1173
|
+
/** Whether the thumb is currently being dragged. */
|
|
1174
|
+
isDragging: Ref<boolean, boolean>;
|
|
1175
|
+
};
|
|
1176
|
+
|
|
1177
|
+
/** Configuration properties for the `useVirtualScrollbar` composable. */
|
|
1178
|
+
export declare interface UseVirtualScrollbarProps {
|
|
1179
|
+
/** The axis for this scrollbar. */
|
|
1180
|
+
axis: MaybeRefOrGetter<ScrollAxis>;
|
|
1181
|
+
/** Total size of the scrollable content area in display pixels (DU). */
|
|
1182
|
+
totalSize: MaybeRefOrGetter<number>;
|
|
1183
|
+
/** Current scroll position in display pixels (DU). */
|
|
1184
|
+
position: MaybeRefOrGetter<number>;
|
|
1185
|
+
/** Viewport size in display pixels (DU). */
|
|
1186
|
+
viewportSize: MaybeRefOrGetter<number>;
|
|
1187
|
+
/**
|
|
1188
|
+
* Function to scroll to a specific display pixel offset (DU) on this axis.
|
|
1189
|
+
* @param offset - The display pixel offset to scroll to.
|
|
1190
|
+
*/
|
|
1191
|
+
scrollToOffset: (offset: number) => void;
|
|
1192
|
+
/** The ID of the container element this scrollbar controls. */
|
|
1193
|
+
containerId?: MaybeRefOrGetter<string | undefined>;
|
|
1194
|
+
/** Whether the scrollbar is in Right-to-Left (RTL) mode. */
|
|
1195
|
+
isRtl?: MaybeRefOrGetter<boolean>;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
927
1198
|
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
1199
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
929
1200
|
readonly onLoad?: (direction: "vertical" | "horizontal") => any;
|
|
@@ -960,6 +1231,36 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
960
1231
|
*/
|
|
961
1232
|
getColumnWidth: (index: number) => number;
|
|
962
1233
|
/**
|
|
1234
|
+
* Helper to get the height of a specific row.
|
|
1235
|
+
* @param index - The row index.
|
|
1236
|
+
* @see useVirtualScroll
|
|
1237
|
+
*/
|
|
1238
|
+
getRowHeight: (index: number) => number;
|
|
1239
|
+
/**
|
|
1240
|
+
* Helper to get the virtual offset of a specific row.
|
|
1241
|
+
* @param index - The row index.
|
|
1242
|
+
* @see useVirtualScroll
|
|
1243
|
+
*/
|
|
1244
|
+
getRowOffset: (index: number) => number;
|
|
1245
|
+
/**
|
|
1246
|
+
* Helper to get the virtual offset of a specific column.
|
|
1247
|
+
* @param index - The column index.
|
|
1248
|
+
* @see useVirtualScroll
|
|
1249
|
+
*/
|
|
1250
|
+
getColumnOffset: (index: number) => number;
|
|
1251
|
+
/**
|
|
1252
|
+
* Helper to get the virtual offset of a specific item.
|
|
1253
|
+
* @param index - The item index.
|
|
1254
|
+
* @see useVirtualScroll
|
|
1255
|
+
*/
|
|
1256
|
+
getItemOffset: (index: number) => number;
|
|
1257
|
+
/**
|
|
1258
|
+
* Helper to get the size of a specific item along the scroll axis.
|
|
1259
|
+
* @param index - The item index.
|
|
1260
|
+
* @see useVirtualScroll
|
|
1261
|
+
*/
|
|
1262
|
+
getItemSize: (index: number) => number;
|
|
1263
|
+
/**
|
|
963
1264
|
* Programmatically scroll to a specific row and/or column.
|
|
964
1265
|
*
|
|
965
1266
|
* @param rowIndex - The row index to scroll to. Pass null to only scroll horizontally.
|
|
@@ -991,6 +1292,79 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
991
1292
|
* @see useVirtualScroll
|
|
992
1293
|
*/
|
|
993
1294
|
stopProgrammaticScroll: () => void;
|
|
1295
|
+
/**
|
|
1296
|
+
* Detects the current direction (LTR/RTL) of the scroll container.
|
|
1297
|
+
*/
|
|
1298
|
+
updateDirection: () => void;
|
|
1299
|
+
/**
|
|
1300
|
+
* Whether the scroll container is in Right-to-Left (RTL) mode.
|
|
1301
|
+
*/
|
|
1302
|
+
isRtl: Ref<boolean, boolean>;
|
|
1303
|
+
/**
|
|
1304
|
+
* Whether the component has finished its first client-side mount and hydration.
|
|
1305
|
+
*/
|
|
1306
|
+
isHydrated: Ref<boolean, boolean>;
|
|
1307
|
+
/**
|
|
1308
|
+
* Coordinate scaling factor for X axis.
|
|
1309
|
+
*/
|
|
1310
|
+
scaleX: ComputedRef<number>;
|
|
1311
|
+
/**
|
|
1312
|
+
* Coordinate scaling factor for Y axis.
|
|
1313
|
+
*/
|
|
1314
|
+
scaleY: ComputedRef<number>;
|
|
1315
|
+
/**
|
|
1316
|
+
* Physical width of the content in the DOM (clamped to browser limits).
|
|
1317
|
+
*/
|
|
1318
|
+
renderedWidth: ComputedRef<number>;
|
|
1319
|
+
/**
|
|
1320
|
+
* Physical height of the content in the DOM (clamped to browser limits).
|
|
1321
|
+
*/
|
|
1322
|
+
renderedHeight: ComputedRef<number>;
|
|
1323
|
+
/**
|
|
1324
|
+
* Absolute offset of the component within its container.
|
|
1325
|
+
*/
|
|
1326
|
+
componentOffset: {
|
|
1327
|
+
x: number;
|
|
1328
|
+
y: number;
|
|
1329
|
+
};
|
|
1330
|
+
/**
|
|
1331
|
+
* Properties for the vertical scrollbar.
|
|
1332
|
+
* Useful when building custom scrollbar interfaces.
|
|
1333
|
+
*/
|
|
1334
|
+
scrollbarPropsVertical: ComputedRef<ScrollbarSlotProps | null>;
|
|
1335
|
+
/**
|
|
1336
|
+
* Properties for the horizontal scrollbar.
|
|
1337
|
+
* Useful when building custom scrollbar interfaces.
|
|
1338
|
+
*/
|
|
1339
|
+
scrollbarPropsHorizontal: ComputedRef<ScrollbarSlotProps | null>;
|
|
1340
|
+
items: Ref<T[], T[]>;
|
|
1341
|
+
itemSize: Ref<number | ((item: T, index: number) => number) | null | undefined, number | ((item: T, index: number) => number) | null | undefined>;
|
|
1342
|
+
container: Ref<HTMLElement | Window | null | undefined, HTMLElement | Window | null | undefined>;
|
|
1343
|
+
ssrRange: Ref<SSRRange | undefined, SSRRange | undefined>;
|
|
1344
|
+
columnWidth: Ref<number | number[] | ((index: number) => number) | null | undefined, number | number[] | ((index: number) => number) | null | undefined>;
|
|
1345
|
+
initialScrollIndex: Ref<number | undefined, number | undefined>;
|
|
1346
|
+
initialScrollAlign: Ref<ScrollAlignment | ScrollAlignmentOptions | undefined, ScrollAlignment | ScrollAlignmentOptions | undefined>;
|
|
1347
|
+
defaultItemSize: Ref<number | undefined, number | undefined>;
|
|
1348
|
+
defaultColumnWidth: Ref<number | undefined, number | undefined>;
|
|
1349
|
+
direction: Ref<ScrollDirection, ScrollDirection>;
|
|
1350
|
+
bufferBefore: Ref<number, number>;
|
|
1351
|
+
bufferAfter: Ref<number, number>;
|
|
1352
|
+
columnCount: Ref<number, number>;
|
|
1353
|
+
containerTag: Ref<string, string>;
|
|
1354
|
+
wrapperTag: Ref<string, string>;
|
|
1355
|
+
itemTag: Ref<string, string>;
|
|
1356
|
+
scrollPaddingStart: Ref<PaddingValue, PaddingValue>;
|
|
1357
|
+
scrollPaddingEnd: Ref<PaddingValue, PaddingValue>;
|
|
1358
|
+
stickyHeader: Ref<boolean, boolean>;
|
|
1359
|
+
stickyFooter: Ref<boolean, boolean>;
|
|
1360
|
+
gap: Ref<number, number>;
|
|
1361
|
+
columnGap: Ref<number, number>;
|
|
1362
|
+
stickyIndices: Ref<number[], number[]>;
|
|
1363
|
+
loadDistance: Ref<number, number>;
|
|
1364
|
+
loading: Ref<boolean, boolean>;
|
|
1365
|
+
restoreScrollOnPrepend: Ref<boolean, boolean>;
|
|
1366
|
+
debug: Ref<boolean, boolean>;
|
|
1367
|
+
virtualScrollbar: Ref<boolean, boolean>;
|
|
994
1368
|
}>): void;
|
|
995
1369
|
attrs: any;
|
|
996
1370
|
slots: Readonly<{
|
|
@@ -1002,35 +1376,7 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1002
1376
|
/**
|
|
1003
1377
|
* Scoped slot for rendering each individual item.
|
|
1004
1378
|
*/
|
|
1005
|
-
item?: (props:
|
|
1006
|
-
/** The original data item from the `items` array. */
|
|
1007
|
-
item: T;
|
|
1008
|
-
/** The original index of the item in the `items` array. */
|
|
1009
|
-
index: number;
|
|
1010
|
-
/**
|
|
1011
|
-
* Information about the current visible range of columns (for grid mode).
|
|
1012
|
-
* @see ColumnRange
|
|
1013
|
-
*/
|
|
1014
|
-
columnRange: {
|
|
1015
|
-
/** Index of the first rendered column. */
|
|
1016
|
-
start: number;
|
|
1017
|
-
/** Index of the last rendered column (exclusive). */
|
|
1018
|
-
end: number;
|
|
1019
|
-
/** Pixel offset from the start of the row to the first rendered cell. */
|
|
1020
|
-
padStart: number;
|
|
1021
|
-
/** Pixel offset from the last rendered cell to the end of the row. */
|
|
1022
|
-
padEnd: number;
|
|
1023
|
-
};
|
|
1024
|
-
/**
|
|
1025
|
-
* Helper function to get the width of a specific column.
|
|
1026
|
-
* Useful for setting consistent widths in grid mode.
|
|
1027
|
-
*/
|
|
1028
|
-
getColumnWidth: (index: number) => number;
|
|
1029
|
-
/** Whether this item is configured to be sticky via `stickyIndices`. */
|
|
1030
|
-
isSticky?: boolean | undefined;
|
|
1031
|
-
/** Whether this item is currently in a sticky state (stuck at the top/start). */
|
|
1032
|
-
isStickyActive?: boolean | undefined;
|
|
1033
|
-
}) => VNodeChild;
|
|
1379
|
+
item?: (props: ItemSlotProps<T>) => VNodeChild;
|
|
1034
1380
|
/**
|
|
1035
1381
|
* Content shown at the end of the list when the `loading` prop is true.
|
|
1036
1382
|
* Also prevents additional 'load' events from triggering while visible.
|
|
@@ -1041,6 +1387,11 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1041
1387
|
* Can be made sticky using the `stickyFooter` prop.
|
|
1042
1388
|
*/
|
|
1043
1389
|
footer?: (props: Record<string, never>) => VNodeChild;
|
|
1390
|
+
/**
|
|
1391
|
+
* Scoped slot for rendering custom scrollbars.
|
|
1392
|
+
* If provided, the default VirtualScrollbar is not rendered.
|
|
1393
|
+
*/
|
|
1394
|
+
scrollbar?: (props: ScrollbarSlotProps) => VNodeChild;
|
|
1044
1395
|
}> & {
|
|
1045
1396
|
/**
|
|
1046
1397
|
* Content rendered at the top of the scrollable area.
|
|
@@ -1050,35 +1401,7 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1050
1401
|
/**
|
|
1051
1402
|
* Scoped slot for rendering each individual item.
|
|
1052
1403
|
*/
|
|
1053
|
-
item?: (props:
|
|
1054
|
-
/** The original data item from the `items` array. */
|
|
1055
|
-
item: T;
|
|
1056
|
-
/** The original index of the item in the `items` array. */
|
|
1057
|
-
index: number;
|
|
1058
|
-
/**
|
|
1059
|
-
* Information about the current visible range of columns (for grid mode).
|
|
1060
|
-
* @see ColumnRange
|
|
1061
|
-
*/
|
|
1062
|
-
columnRange: {
|
|
1063
|
-
/** Index of the first rendered column. */
|
|
1064
|
-
start: number;
|
|
1065
|
-
/** Index of the last rendered column (exclusive). */
|
|
1066
|
-
end: number;
|
|
1067
|
-
/** Pixel offset from the start of the row to the first rendered cell. */
|
|
1068
|
-
padStart: number;
|
|
1069
|
-
/** Pixel offset from the last rendered cell to the end of the row. */
|
|
1070
|
-
padEnd: number;
|
|
1071
|
-
};
|
|
1072
|
-
/**
|
|
1073
|
-
* Helper function to get the width of a specific column.
|
|
1074
|
-
* Useful for setting consistent widths in grid mode.
|
|
1075
|
-
*/
|
|
1076
|
-
getColumnWidth: (index: number) => number;
|
|
1077
|
-
/** Whether this item is configured to be sticky via `stickyIndices`. */
|
|
1078
|
-
isSticky?: boolean | undefined;
|
|
1079
|
-
/** Whether this item is currently in a sticky state (stuck at the top/start). */
|
|
1080
|
-
isStickyActive?: boolean | undefined;
|
|
1081
|
-
}) => VNodeChild;
|
|
1404
|
+
item?: (props: ItemSlotProps<T>) => VNodeChild;
|
|
1082
1405
|
/**
|
|
1083
1406
|
* Content shown at the end of the list when the `loading` prop is true.
|
|
1084
1407
|
* Also prevents additional 'load' events from triggering while visible.
|
|
@@ -1089,6 +1412,11 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1089
1412
|
* Can be made sticky using the `stickyFooter` prop.
|
|
1090
1413
|
*/
|
|
1091
1414
|
footer?: (props: Record<string, never>) => VNodeChild;
|
|
1415
|
+
/**
|
|
1416
|
+
* Scoped slot for rendering custom scrollbars.
|
|
1417
|
+
* If provided, the default VirtualScrollbar is not rendered.
|
|
1418
|
+
*/
|
|
1419
|
+
scrollbar?: (props: ScrollbarSlotProps) => VNodeChild;
|
|
1092
1420
|
};
|
|
1093
1421
|
emit: {
|
|
1094
1422
|
(e: "scroll", details: ScrollDetails<T>): void;
|
|
@@ -1104,17 +1432,61 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1104
1432
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
1105
1433
|
};
|
|
1106
1434
|
|
|
1107
|
-
|
|
1108
|
-
|
|
1435
|
+
export declare const VirtualScrollbar: DefineComponent<Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
|
|
1436
|
+
scrollToOffset: (offset: number) => any;
|
|
1437
|
+
}, string, PublicProps, Readonly<Props_2> & Readonly<{
|
|
1438
|
+
onScrollToOffset?: (offset: number) => any;
|
|
1439
|
+
}>, {
|
|
1440
|
+
isRtl: boolean;
|
|
1441
|
+
axis: ScrollAxis;
|
|
1442
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
1443
|
+
|
|
1444
|
+
/** Properties for the `VirtualScrollbar` component. */
|
|
1445
|
+
export declare interface VirtualScrollbarProps {
|
|
1446
|
+
/**
|
|
1447
|
+
* The axis for this scrollbar.
|
|
1448
|
+
* - 'vertical': Vertical scrollbar.
|
|
1449
|
+
* - 'horizontal': Horizontal scrollbar.
|
|
1450
|
+
* @default 'vertical'
|
|
1451
|
+
*/
|
|
1452
|
+
axis?: ScrollAxis;
|
|
1453
|
+
/**
|
|
1454
|
+
* Total size of the scrollable content in pixels.
|
|
1455
|
+
*/
|
|
1456
|
+
totalSize: number;
|
|
1457
|
+
/**
|
|
1458
|
+
* Current scroll position in pixels.
|
|
1459
|
+
*/
|
|
1460
|
+
position: number;
|
|
1461
|
+
/**
|
|
1462
|
+
* Viewport size in pixels.
|
|
1463
|
+
*/
|
|
1464
|
+
viewportSize: number;
|
|
1465
|
+
/**
|
|
1466
|
+
* Function to scroll to a specific pixel offset on this axis.
|
|
1467
|
+
* @param offset - The pixel offset to scroll to.
|
|
1468
|
+
*/
|
|
1469
|
+
scrollToOffset?: (offset: number) => void;
|
|
1470
|
+
/**
|
|
1471
|
+
* The ID of the container element this scrollbar controls.
|
|
1472
|
+
*/
|
|
1473
|
+
containerId?: string;
|
|
1109
1474
|
/**
|
|
1110
|
-
*
|
|
1475
|
+
* Whether the scrollbar is in Right-to-Left (RTL) mode.
|
|
1476
|
+
* @default false
|
|
1111
1477
|
*/
|
|
1478
|
+
isRtl?: boolean;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
/** Base configuration properties shared between the component and the composable. */
|
|
1482
|
+
export declare interface VirtualScrollBaseProps<T = unknown> {
|
|
1483
|
+
/** Array of data items to virtualize. */
|
|
1112
1484
|
items: T[];
|
|
1113
1485
|
/**
|
|
1114
|
-
* Fixed size of each item
|
|
1486
|
+
* Fixed size of each item in virtual units (VU) or a function that returns the size of an item.
|
|
1115
1487
|
* Pass `0`, `null` or `undefined` for automatic dynamic size detection via `ResizeObserver`.
|
|
1116
1488
|
*/
|
|
1117
|
-
itemSize?: number | ((item: T, index: number) => number) | undefined;
|
|
1489
|
+
itemSize?: number | ((item: T, index: number) => number) | null | undefined;
|
|
1118
1490
|
/**
|
|
1119
1491
|
* Direction of the virtual scroll.
|
|
1120
1492
|
* @default 'vertical'
|
|
@@ -1132,58 +1504,38 @@ export declare interface VirtualScrollProps<T = unknown> {
|
|
|
1132
1504
|
bufferAfter?: number | undefined;
|
|
1133
1505
|
/**
|
|
1134
1506
|
* The scrollable element or window object.
|
|
1135
|
-
* If not provided, virtualization usually happens relative to the `
|
|
1507
|
+
* If not provided, virtualization usually happens relative to the `hostRef`.
|
|
1136
1508
|
*/
|
|
1137
1509
|
container?: HTMLElement | Window | null | undefined;
|
|
1138
|
-
/**
|
|
1139
|
-
* The host element that directly wraps the absolute-positioned items.
|
|
1140
|
-
* Used for calculating relative offsets.
|
|
1141
|
-
*/
|
|
1142
|
-
hostElement?: HTMLElement | null | undefined;
|
|
1143
1510
|
/**
|
|
1144
1511
|
* Configuration for Server-Side Rendering.
|
|
1145
1512
|
* Defines which items are rendered statically on the server.
|
|
1146
1513
|
*/
|
|
1147
|
-
ssrRange?:
|
|
1148
|
-
/** First row index. */
|
|
1149
|
-
start: number;
|
|
1150
|
-
/** Exclusive last row index. */
|
|
1151
|
-
end: number;
|
|
1152
|
-
/** First column index (grid mode). */
|
|
1153
|
-
colStart?: number;
|
|
1154
|
-
/** Exclusive last column index (grid mode). */
|
|
1155
|
-
colEnd?: number;
|
|
1156
|
-
} | undefined;
|
|
1514
|
+
ssrRange?: SSRRange | undefined;
|
|
1157
1515
|
/**
|
|
1158
1516
|
* Number of columns for bidirectional grid scrolling.
|
|
1159
1517
|
*/
|
|
1160
1518
|
columnCount?: number | undefined;
|
|
1161
1519
|
/**
|
|
1162
|
-
* Fixed width of columns
|
|
1520
|
+
* Fixed width of columns in VU, an array of widths, or a function returning widths.
|
|
1163
1521
|
* Pass `0`, `null` or `undefined` for dynamic column detection.
|
|
1164
1522
|
*/
|
|
1165
|
-
columnWidth?: number | number[] | ((index: number) => number) | undefined;
|
|
1523
|
+
columnWidth?: number | number[] | ((index: number) => number) | null | undefined;
|
|
1166
1524
|
/**
|
|
1167
|
-
* Pixel padding at the start of the scroll container.
|
|
1525
|
+
* Pixel padding at the start of the scroll container in display pixels (DU).
|
|
1168
1526
|
*/
|
|
1169
|
-
scrollPaddingStart?:
|
|
1170
|
-
x?: number;
|
|
1171
|
-
y?: number;
|
|
1172
|
-
} | undefined;
|
|
1527
|
+
scrollPaddingStart?: PaddingValue | undefined;
|
|
1173
1528
|
/**
|
|
1174
|
-
* Pixel padding at the end of the scroll container.
|
|
1529
|
+
* Pixel padding at the end of the scroll container in DU.
|
|
1175
1530
|
*/
|
|
1176
|
-
scrollPaddingEnd?:
|
|
1177
|
-
x?: number;
|
|
1178
|
-
y?: number;
|
|
1179
|
-
} | undefined;
|
|
1531
|
+
scrollPaddingEnd?: PaddingValue | undefined;
|
|
1180
1532
|
/**
|
|
1181
|
-
* Gap between items in
|
|
1533
|
+
* Gap between items in virtual units (VU).
|
|
1182
1534
|
* Applied vertically in list/grid mode, horizontally in horizontal list mode.
|
|
1183
1535
|
*/
|
|
1184
1536
|
gap?: number | undefined;
|
|
1185
1537
|
/**
|
|
1186
|
-
* Gap between columns in
|
|
1538
|
+
* Gap between columns in VU.
|
|
1187
1539
|
* Applied in horizontal and bidirectional grid modes.
|
|
1188
1540
|
*/
|
|
1189
1541
|
columnGap?: number | undefined;
|
|
@@ -1192,7 +1544,7 @@ export declare interface VirtualScrollProps<T = unknown> {
|
|
|
1192
1544
|
*/
|
|
1193
1545
|
stickyIndices?: number[] | undefined;
|
|
1194
1546
|
/**
|
|
1195
|
-
* Threshold distance from the end
|
|
1547
|
+
* Threshold distance from the end in display pixels (DU) to emit the 'load' event.
|
|
1196
1548
|
* @default 200
|
|
1197
1549
|
*/
|
|
1198
1550
|
loadDistance?: number | undefined;
|
|
@@ -1201,7 +1553,7 @@ export declare interface VirtualScrollProps<T = unknown> {
|
|
|
1201
1553
|
*/
|
|
1202
1554
|
loading?: boolean | undefined;
|
|
1203
1555
|
/**
|
|
1204
|
-
* Whether to automatically restore and
|
|
1556
|
+
* Whether to automatically restore and maintain scroll position when items are prepended to the array.
|
|
1205
1557
|
*/
|
|
1206
1558
|
restoreScrollOnPrepend?: boolean | undefined;
|
|
1207
1559
|
/**
|
|
@@ -1214,11 +1566,11 @@ export declare interface VirtualScrollProps<T = unknown> {
|
|
|
1214
1566
|
*/
|
|
1215
1567
|
initialScrollAlign?: ScrollAlignment | ScrollAlignmentOptions | undefined;
|
|
1216
1568
|
/**
|
|
1217
|
-
* Default fallback size for items before they are measured.
|
|
1569
|
+
* Default fallback size for items before they are measured in VU.
|
|
1218
1570
|
*/
|
|
1219
1571
|
defaultItemSize?: number | undefined;
|
|
1220
1572
|
/**
|
|
1221
|
-
* Default fallback width for columns before they are measured.
|
|
1573
|
+
* Default fallback width for columns before they are measured in VU.
|
|
1222
1574
|
*/
|
|
1223
1575
|
defaultColumnWidth?: number | undefined;
|
|
1224
1576
|
/**
|
|
@@ -1227,4 +1579,112 @@ export declare interface VirtualScrollProps<T = unknown> {
|
|
|
1227
1579
|
debug?: boolean | undefined;
|
|
1228
1580
|
}
|
|
1229
1581
|
|
|
1582
|
+
/** Configuration properties for the `VirtualScroll` component. */
|
|
1583
|
+
export declare interface VirtualScrollComponentProps<T = unknown> extends VirtualScrollBaseProps<T> {
|
|
1584
|
+
/** The HTML tag to use for the root container. */
|
|
1585
|
+
containerTag?: string;
|
|
1586
|
+
/** The HTML tag to use for the items wrapper. */
|
|
1587
|
+
wrapperTag?: string;
|
|
1588
|
+
/** The HTML tag to use for each item. */
|
|
1589
|
+
itemTag?: string;
|
|
1590
|
+
/** Whether the content in the 'header' slot is sticky. */
|
|
1591
|
+
stickyHeader?: boolean;
|
|
1592
|
+
/** Whether the content in the 'footer' slot is sticky. */
|
|
1593
|
+
stickyFooter?: boolean;
|
|
1594
|
+
/** Whether to use virtual scrollbars for styling purposes. */
|
|
1595
|
+
virtualScrollbar?: boolean;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
/** Exposed methods and properties of the `VirtualScroll` component instance. */
|
|
1599
|
+
export declare interface VirtualScrollInstance<T = unknown> extends VirtualScrollComponentProps<T> {
|
|
1600
|
+
/** Detailed information about the current scroll state. */
|
|
1601
|
+
scrollDetails: ScrollDetails<T>;
|
|
1602
|
+
/** Information about the current visible range of columns. */
|
|
1603
|
+
columnRange: ScrollDetails<T>['columnRange'];
|
|
1604
|
+
/** Helper to get the width of a specific column. */
|
|
1605
|
+
getColumnWidth: (index: number) => number;
|
|
1606
|
+
/** Helper to get the height of a specific row. */
|
|
1607
|
+
getRowHeight: (index: number) => number;
|
|
1608
|
+
/** Helper to get the virtual offset of a specific row. */
|
|
1609
|
+
getRowOffset: (index: number) => number;
|
|
1610
|
+
/** Helper to get the virtual offset of a specific column. */
|
|
1611
|
+
getColumnOffset: (index: number) => number;
|
|
1612
|
+
/** Helper to get the virtual offset of a specific item. */
|
|
1613
|
+
getItemOffset: (index: number) => number;
|
|
1614
|
+
/** Helper to get the size of a specific item along the scroll axis. */
|
|
1615
|
+
getItemSize: (index: number) => number;
|
|
1616
|
+
/** Programmatically scroll to a specific row and/or column. */
|
|
1617
|
+
scrollToIndex: (rowIndex: number | null | undefined, colIndex: number | null | undefined, options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions) => void;
|
|
1618
|
+
/** Programmatically scroll to a specific pixel offset. */
|
|
1619
|
+
scrollToOffset: (x?: number | null, y?: number | null, options?: {
|
|
1620
|
+
behavior?: 'auto' | 'smooth';
|
|
1621
|
+
}) => void;
|
|
1622
|
+
/** Resets all dynamic measurements and re-initializes from props. */
|
|
1623
|
+
refresh: () => void;
|
|
1624
|
+
/** Immediately stops any currently active smooth scroll animation and clears pending corrections. */
|
|
1625
|
+
stopProgrammaticScroll: () => void;
|
|
1626
|
+
/** Detects the current direction (LTR/RTL) of the scroll container. */
|
|
1627
|
+
updateDirection: () => void;
|
|
1628
|
+
/** Whether the scroll container is in Right-to-Left (RTL) mode. */
|
|
1629
|
+
isRtl: boolean;
|
|
1630
|
+
/** Whether the component has finished its first client - side mount and hydration. */
|
|
1631
|
+
isHydrated: boolean;
|
|
1632
|
+
/** Coordinate scaling factor for X axis. */
|
|
1633
|
+
scaleX: number;
|
|
1634
|
+
/** Coordinate scaling factor for Y axis. */
|
|
1635
|
+
scaleY: number;
|
|
1636
|
+
/** Physical width of the content in the DOM (clamped to browser limits). */
|
|
1637
|
+
renderedWidth: number;
|
|
1638
|
+
/** Physical height of the content in the DOM (clamped to browser limits). */
|
|
1639
|
+
renderedHeight: number;
|
|
1640
|
+
/** Absolute offset of the component within its container. */
|
|
1641
|
+
componentOffset: Point;
|
|
1642
|
+
/** Properties for the vertical scrollbar. */
|
|
1643
|
+
scrollbarPropsVertical: ScrollbarSlotProps | null;
|
|
1644
|
+
/** Properties for the horizontal scrollbar. */
|
|
1645
|
+
scrollbarPropsHorizontal: ScrollbarSlotProps | null;
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
/** Configuration properties for the `useVirtualScroll` composable. */
|
|
1649
|
+
export declare interface VirtualScrollProps<T = unknown> extends VirtualScrollBaseProps<T> {
|
|
1650
|
+
/**
|
|
1651
|
+
* The host element that directly wraps the absolute-positioned items.
|
|
1652
|
+
* Used for calculating relative offsets in display pixels (DU).
|
|
1653
|
+
*/
|
|
1654
|
+
hostElement?: HTMLElement | null | undefined;
|
|
1655
|
+
/**
|
|
1656
|
+
* The root element of the VirtualScroll component.
|
|
1657
|
+
* Used for calculating relative offsets in display pixels (DU).
|
|
1658
|
+
*/
|
|
1659
|
+
hostRef?: HTMLElement | null | undefined;
|
|
1660
|
+
/**
|
|
1661
|
+
* Size of sticky elements at the start of the viewport (top or left) in DU.
|
|
1662
|
+
* Used to adjust the visible range and item positioning without increasing content size.
|
|
1663
|
+
*/
|
|
1664
|
+
stickyStart?: PaddingValue | undefined;
|
|
1665
|
+
/**
|
|
1666
|
+
* Size of sticky elements at the end of the viewport (bottom or right) in DU.
|
|
1667
|
+
* Used to adjust the visible range without increasing content size.
|
|
1668
|
+
*/
|
|
1669
|
+
stickyEnd?: PaddingValue | undefined;
|
|
1670
|
+
/**
|
|
1671
|
+
* Extra padding (display pixels - DU) at the start of the flow (e.g. non-sticky header).
|
|
1672
|
+
*/
|
|
1673
|
+
flowPaddingStart?: PaddingValue | undefined;
|
|
1674
|
+
/**
|
|
1675
|
+
* Extra padding (DU) at the end of the flow (e.g. non-sticky footer).
|
|
1676
|
+
*/
|
|
1677
|
+
flowPaddingEnd?: PaddingValue | undefined;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
/**
|
|
1681
|
+
* Maps a virtual content position to a display scroll position.
|
|
1682
|
+
*
|
|
1683
|
+
* @param virtualPos - Virtual content position (VU).
|
|
1684
|
+
* @param hostOffset - Offset of the host element in display pixels (DU).
|
|
1685
|
+
* @param scale - Coordinate scaling factor (VU/DU).
|
|
1686
|
+
* @returns Display pixel position (DU).
|
|
1687
|
+
*/
|
|
1688
|
+
export declare function virtualToDisplay(virtualPos: number, hostOffset: number, scale: number): number;
|
|
1689
|
+
|
|
1230
1690
|
export { }
|