@pdanpdan/virtual-scroll 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +268 -275
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1497 -192
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2219 -896
- package/dist/index.mjs.map +1 -1
- package/dist/virtual-scroll.css +1 -2
- package/package.json +5 -1
- package/src/components/VirtualScroll.test.ts +1979 -627
- package/src/components/VirtualScroll.vue +951 -349
- package/src/components/VirtualScrollbar.test.ts +174 -0
- package/src/components/VirtualScrollbar.vue +102 -0
- package/src/composables/useVirtualScroll.test.ts +1160 -1521
- package/src/composables/useVirtualScroll.ts +1135 -791
- package/src/composables/useVirtualScrollbar.test.ts +526 -0
- package/src/composables/useVirtualScrollbar.ts +239 -0
- package/src/index.ts +4 -0
- package/src/types.ts +816 -0
- package/src/utils/fenwick-tree.test.ts +39 -39
- package/src/utils/fenwick-tree.ts +38 -18
- package/src/utils/scroll.test.ts +174 -0
- package/src/utils/scroll.ts +50 -13
- package/src/utils/virtual-scroll-logic.test.ts +2850 -0
- package/src/utils/virtual-scroll-logic.ts +901 -0
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,35 +16,293 @@ 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
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Calculates the range of columns to render for bidirectional scroll.
|
|
28
|
+
*
|
|
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).
|
|
40
|
+
* @see ColumnRangeParams
|
|
41
|
+
* @see ColumnRange
|
|
42
|
+
*/
|
|
43
|
+
export declare function calculateColumnRange({ columnCount, relativeScrollX, usableWidth, colBuffer, fixedWidth, columnGap, findLowerBound, query, totalColsQuery, }: ColumnRangeParams): {
|
|
44
|
+
start: number;
|
|
45
|
+
end: number;
|
|
46
|
+
padStart: number;
|
|
47
|
+
padEnd: number;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Calculates the position and size of a single item.
|
|
52
|
+
*
|
|
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).
|
|
68
|
+
* @see ItemPositionParams
|
|
69
|
+
*/
|
|
70
|
+
export declare function calculateItemPosition({ index, direction, fixedSize, gap, columnGap, usableWidth, usableHeight, totalWidth, queryY, queryX, getSizeY, getSizeX, columnRange, }: ItemPositionParams): {
|
|
71
|
+
height: number;
|
|
72
|
+
width: number;
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Calculates the style object for a rendered item.
|
|
79
|
+
*
|
|
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.
|
|
89
|
+
* @returns Style object.
|
|
90
|
+
* @see ItemStyleParams
|
|
91
|
+
*/
|
|
92
|
+
export declare function calculateItemStyle<T = unknown>({ item, direction, itemSize, containerTag, paddingStartX, paddingStartY, isHydrated, isRtl, }: ItemStyleParams<T>): Record<string, string | number | undefined>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Calculates the range of items to render based on scroll position and viewport size.
|
|
96
|
+
*
|
|
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).
|
|
113
|
+
* @returns The start and end indices of the items to render.
|
|
114
|
+
* @see RangeParams
|
|
115
|
+
*/
|
|
116
|
+
export declare function calculateRange({ direction, relativeScrollX, relativeScrollY, usableWidth, usableHeight, itemsLength, bufferBefore, bufferAfter, gap, columnGap, fixedSize, findLowerBoundY, findLowerBoundX, queryY, queryX, }: RangeParams): {
|
|
117
|
+
start: number;
|
|
118
|
+
end: number;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Calculates the target scroll position (relative to content) for a given row/column index and alignment.
|
|
123
|
+
*
|
|
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).
|
|
161
|
+
* @see ScrollTargetParams
|
|
162
|
+
* @see ScrollTargetResult
|
|
163
|
+
*/
|
|
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;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Calculates the sticky state and offset for a single item.
|
|
168
|
+
*
|
|
169
|
+
* @param params - Sticky item parameters.
|
|
170
|
+
* @param params.index - Item index.
|
|
171
|
+
* @param params.isSticky - If configured as sticky.
|
|
172
|
+
* @param params.direction - Scroll direction.
|
|
173
|
+
* @param params.relativeScrollX - Virtual horizontal position (VU).
|
|
174
|
+
* @param params.relativeScrollY - Virtual vertical position (VU).
|
|
175
|
+
* @param params.originalX - Virtual original X position (VU).
|
|
176
|
+
* @param params.originalY - Virtual original Y position (VU).
|
|
177
|
+
* @param params.width - Virtual item width (VU).
|
|
178
|
+
* @param params.height - Virtual item height (VU).
|
|
179
|
+
* @param params.stickyIndices - All sticky indices.
|
|
180
|
+
* @param params.fixedSize - Fixed item size (VU).
|
|
181
|
+
* @param params.fixedWidth - Fixed column width (VU).
|
|
182
|
+
* @param params.gap - Item gap (VU).
|
|
183
|
+
* @param params.columnGap - Column gap (VU).
|
|
184
|
+
* @param params.getItemQueryY - Resolver for vertical offset (VU).
|
|
185
|
+
* @param params.getItemQueryX - Resolver for horizontal offset (VU).
|
|
186
|
+
* @returns Sticky state and offset (VU).
|
|
187
|
+
* @see StickyParams
|
|
188
|
+
*/
|
|
189
|
+
export declare function calculateStickyItem({ index, isSticky, direction, relativeScrollX, relativeScrollY, originalX, originalY, width, height, stickyIndices, fixedSize, fixedWidth, gap, columnGap, getItemQueryY, getItemQueryX, }: StickyParams): {
|
|
190
|
+
isStickyActive: boolean;
|
|
191
|
+
stickyOffset: {
|
|
192
|
+
x: number;
|
|
193
|
+
y: number;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Calculates the total width and height of the virtualized content.
|
|
199
|
+
*
|
|
200
|
+
* @param params - Total size parameters.
|
|
201
|
+
* @param params.direction - Scroll direction.
|
|
202
|
+
* @param params.itemsLength - Total item count.
|
|
203
|
+
* @param params.columnCount - Column count.
|
|
204
|
+
* @param params.fixedSize - Fixed item size (VU).
|
|
205
|
+
* @param params.fixedWidth - Fixed column width (VU).
|
|
206
|
+
* @param params.gap - Item gap (VU).
|
|
207
|
+
* @param params.columnGap - Column gap (VU).
|
|
208
|
+
* @param params.usableWidth - Usable viewport width (VU).
|
|
209
|
+
* @param params.usableHeight - Usable viewport height (VU).
|
|
210
|
+
* @param params.queryY - Resolver for vertical offset (VU).
|
|
211
|
+
* @param params.queryX - Resolver for horizontal offset (VU).
|
|
212
|
+
* @param params.queryColumn - Resolver for column offset (VU).
|
|
213
|
+
* @returns Total width and height (VU).
|
|
214
|
+
* @see TotalSizeParams
|
|
215
|
+
*/
|
|
216
|
+
export declare function calculateTotalSize({ direction, itemsLength, columnCount, fixedSize, fixedWidth, gap, columnGap, usableWidth, usableHeight, queryY, queryX, queryColumn, }: TotalSizeParams): {
|
|
217
|
+
width: number;
|
|
218
|
+
height: number;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
/** Information about the currently visible range of columns and their paddings. */
|
|
222
|
+
export declare interface ColumnRange {
|
|
223
|
+
/** Inclusive start index. */
|
|
224
|
+
start: number;
|
|
225
|
+
/** Exclusive end index. */
|
|
226
|
+
end: number;
|
|
227
|
+
/** Pixel padding to maintain at the start of the row in VU. */
|
|
228
|
+
padStart: number;
|
|
229
|
+
/** Pixel padding to maintain at the end of the row in VU. */
|
|
230
|
+
padEnd: number;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** Parameters for calculating the visible range of columns in grid mode. */
|
|
234
|
+
export declare interface ColumnRangeParams {
|
|
235
|
+
/** Column count. */
|
|
236
|
+
columnCount: number;
|
|
237
|
+
/** Relative horizontal scroll position. */
|
|
238
|
+
relativeScrollX: number;
|
|
239
|
+
/** Usable viewport width. */
|
|
240
|
+
usableWidth: number;
|
|
241
|
+
/** Column buffer count. */
|
|
242
|
+
colBuffer: number;
|
|
243
|
+
/** Fixed column width. */
|
|
244
|
+
fixedWidth: number | null;
|
|
245
|
+
/** Column gap. */
|
|
246
|
+
columnGap: number;
|
|
247
|
+
/** Binary search for column index. */
|
|
248
|
+
findLowerBound: (offset: number) => number;
|
|
249
|
+
/** Prefix sum for column width. */
|
|
250
|
+
query: (index: number) => number;
|
|
251
|
+
/** Resolver for total column width. */
|
|
252
|
+
totalColsQuery: () => number;
|
|
253
|
+
}
|
|
254
|
+
|
|
15
255
|
export declare const DEFAULT_BUFFER = 5;
|
|
16
256
|
|
|
17
257
|
export declare const DEFAULT_COLUMN_WIDTH = 100;
|
|
18
258
|
|
|
19
259
|
export declare const DEFAULT_ITEM_SIZE = 40;
|
|
20
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Maps a display scroll position to a virtual content position.
|
|
263
|
+
*
|
|
264
|
+
* @param displayPos - Display pixel position (DU).
|
|
265
|
+
* @param hostOffset - Offset of the host element in display pixels (DU).
|
|
266
|
+
* @param scale - Coordinate scaling factor (VU/DU).
|
|
267
|
+
* @returns Virtual content position (VU).
|
|
268
|
+
*/
|
|
269
|
+
export declare function displayToVirtual(displayPos: number, hostOffset: number, scale: number): number;
|
|
270
|
+
|
|
21
271
|
/**
|
|
22
272
|
* Fenwick Tree (Binary Indexed Tree) implementation for efficient
|
|
23
273
|
* prefix sum calculations and updates.
|
|
274
|
+
*
|
|
275
|
+
* Provides O(log n) time complexity for both point updates and prefix sum queries.
|
|
24
276
|
*/
|
|
25
277
|
export declare class FenwickTree {
|
|
26
278
|
private tree;
|
|
27
279
|
private values;
|
|
280
|
+
/**
|
|
281
|
+
* Creates a new Fenwick Tree with the specified size.
|
|
282
|
+
*
|
|
283
|
+
* @param size - The number of elements in the tree.
|
|
284
|
+
*/
|
|
28
285
|
constructor(size: number);
|
|
29
286
|
/**
|
|
30
|
-
* Update the value at a specific index and propagate changes.
|
|
31
|
-
*
|
|
32
|
-
* @param
|
|
287
|
+
* Update the value at a specific index and propagate changes throughout the tree.
|
|
288
|
+
*
|
|
289
|
+
* @param index - The 0-based index to update.
|
|
290
|
+
* @param delta - The change in value (new value - old value).
|
|
33
291
|
*/
|
|
34
292
|
update(index: number, delta: number): void;
|
|
35
293
|
/**
|
|
36
294
|
* Get the prefix sum up to a specific index (exclusive).
|
|
37
|
-
*
|
|
38
|
-
* @returns
|
|
295
|
+
*
|
|
296
|
+
* @param index - 0-based index. `query(n)` returns sum of values from index 0 to n-1.
|
|
297
|
+
* @returns Sum of values in range [0, index).
|
|
39
298
|
*/
|
|
40
299
|
query(index: number): number;
|
|
41
300
|
/**
|
|
42
|
-
* Set the individual value at an index without updating the tree.
|
|
43
|
-
* Call rebuild() after multiple sets to update the tree efficiently.
|
|
301
|
+
* Set the individual value at an index without updating the prefix sum tree.
|
|
302
|
+
* Call `rebuild()` after multiple sets to update the tree efficiently in O(n).
|
|
303
|
+
*
|
|
304
|
+
* @param index - The 0-based index.
|
|
305
|
+
* @param value - The new value.
|
|
44
306
|
*/
|
|
45
307
|
set(index: number, value: number): void;
|
|
46
308
|
/**
|
|
@@ -48,40 +310,57 @@ export declare class FenwickTree {
|
|
|
48
310
|
*/
|
|
49
311
|
get length(): number;
|
|
50
312
|
/**
|
|
51
|
-
* Get the individual value at
|
|
313
|
+
* Get the individual value at a specific index.
|
|
314
|
+
*
|
|
315
|
+
* @param index - The 0-based index.
|
|
316
|
+
* @returns The value at the specified index.
|
|
52
317
|
*/
|
|
53
318
|
get(index: number): number;
|
|
54
319
|
/**
|
|
55
|
-
* Get the underlying values array.
|
|
320
|
+
* Get the underlying values array as a read-only Float64Array.
|
|
321
|
+
*
|
|
322
|
+
* @returns The read-only values array.
|
|
56
323
|
*/
|
|
57
324
|
getValues(): Readonly<Float64Array>;
|
|
58
325
|
/**
|
|
59
326
|
* Find the largest index such that the prefix sum is less than or equal to the given value.
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @
|
|
327
|
+
* Highly efficient search used to find which item is at a specific scroll offset.
|
|
328
|
+
*
|
|
329
|
+
* @param value - The prefix sum value to search for.
|
|
330
|
+
* @returns The 0-based index.
|
|
63
331
|
*/
|
|
64
332
|
findLowerBound(value: number): number;
|
|
65
333
|
/**
|
|
66
|
-
* Rebuild the entire tree from the current values array
|
|
67
|
-
*
|
|
334
|
+
* Rebuild the entire prefix sum tree from the current values array.
|
|
335
|
+
* Time complexity: O(n).
|
|
68
336
|
*/
|
|
69
337
|
rebuild(): void;
|
|
70
338
|
/**
|
|
71
|
-
* Resize the tree while preserving existing values.
|
|
72
|
-
*
|
|
339
|
+
* Resize the tree while preserving existing values and rebuilding the prefix sums.
|
|
340
|
+
*
|
|
341
|
+
* @param size - The new size of the tree.
|
|
73
342
|
*/
|
|
74
343
|
resize(size: number): void;
|
|
75
344
|
/**
|
|
76
345
|
* Shift values by a given offset and rebuild the tree.
|
|
77
|
-
* Useful when items are prepended to the list.
|
|
78
|
-
*
|
|
346
|
+
* Useful when items are prepended to the list to maintain existing measurements.
|
|
347
|
+
*
|
|
348
|
+
* @param offset - Number of positions to shift. Positive for prepending (shifts right).
|
|
79
349
|
*/
|
|
80
350
|
shift(offset: number): void;
|
|
81
351
|
}
|
|
82
352
|
|
|
83
353
|
/**
|
|
84
|
-
*
|
|
354
|
+
* Binary search for the previous sticky index before the current index.
|
|
355
|
+
*
|
|
356
|
+
* @param stickyIndices - Sorted array of sticky indices.
|
|
357
|
+
* @param index - Current index.
|
|
358
|
+
* @returns Previous sticky index or undefined.
|
|
359
|
+
*/
|
|
360
|
+
export declare function findPrevStickyIndex(stickyIndices: number[], index: number): number | undefined;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Extracts the horizontal padding from a padding configuration.
|
|
85
364
|
*
|
|
86
365
|
* @param p - The padding value (number or object with x/y).
|
|
87
366
|
* @param direction - The current scroll direction.
|
|
@@ -93,7 +372,7 @@ export declare function getPaddingX(p: number | {
|
|
|
93
372
|
} | undefined, direction?: ScrollDirection): number;
|
|
94
373
|
|
|
95
374
|
/**
|
|
96
|
-
* Extracts the vertical padding from a padding
|
|
375
|
+
* Extracts the vertical padding from a padding configuration.
|
|
97
376
|
*
|
|
98
377
|
* @param p - The padding value (number or object with x/y).
|
|
99
378
|
* @param direction - The current scroll direction.
|
|
@@ -105,246 +384,632 @@ export declare function getPaddingY(p: number | {
|
|
|
105
384
|
} | undefined, direction?: ScrollDirection): number;
|
|
106
385
|
|
|
107
386
|
/**
|
|
108
|
-
* Checks if the container
|
|
387
|
+
* Checks if the container is the document body element.
|
|
109
388
|
*
|
|
110
389
|
* @param container - The container element or window to check.
|
|
111
|
-
* @returns
|
|
390
|
+
* @returns `true` if the container is the `<body>` element.
|
|
391
|
+
*/
|
|
392
|
+
export declare function isBody(container: HTMLElement | Window | null | undefined): container is HTMLElement;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Checks if the container is a valid HTML Element with bounding rect support.
|
|
396
|
+
*
|
|
397
|
+
* @param container - The container to check.
|
|
398
|
+
* @returns `true` if the container is an `HTMLElement`.
|
|
112
399
|
*/
|
|
113
400
|
export declare function isElement(container: HTMLElement | Window | null | undefined): container is HTMLElement;
|
|
114
401
|
|
|
115
402
|
/**
|
|
116
|
-
*
|
|
403
|
+
* Determines if an item is visible within the usable viewport.
|
|
404
|
+
*
|
|
405
|
+
* @param itemPos - Virtual start position of the item (VU).
|
|
406
|
+
* @param itemSize - Virtual size of the item (VU).
|
|
407
|
+
* @param scrollPos - Virtual scroll position (VU).
|
|
408
|
+
* @param viewSize - Full size of the viewport (VU).
|
|
409
|
+
* @param stickyOffsetStart - Dynamic offset from sticky items at start (VU).
|
|
410
|
+
* @param stickyOffsetEnd - Offset from sticky items at end (VU).
|
|
411
|
+
* @returns True if visible.
|
|
412
|
+
*/
|
|
413
|
+
export declare function isItemVisible(itemPos: number, itemSize: number, scrollPos: number, viewSize: number, stickyOffsetStart?: number, stickyOffsetEnd?: number): boolean;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Checks if the target is an element that supports scrolling.
|
|
117
417
|
*
|
|
118
418
|
* @param target - The event target to check.
|
|
119
|
-
* @returns
|
|
419
|
+
* @returns `true` if the target is an `HTMLElement` with scroll properties.
|
|
120
420
|
*/
|
|
121
421
|
export declare function isScrollableElement(target: EventTarget | null): target is HTMLElement;
|
|
122
422
|
|
|
123
423
|
/**
|
|
124
|
-
* Helper to determine if an options argument is
|
|
424
|
+
* Helper to determine if an options argument is a full `ScrollToIndexOptions` object.
|
|
125
425
|
*
|
|
126
426
|
* @param options - The options object to check.
|
|
127
|
-
* @returns
|
|
427
|
+
* @returns `true` if the options object contains scroll-to-index specific properties.
|
|
128
428
|
*/
|
|
129
429
|
export declare function isScrollToIndexOptions(options: unknown): options is ScrollToIndexOptions;
|
|
130
430
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
431
|
+
/**
|
|
432
|
+
* Checks if the container is the window object.
|
|
433
|
+
*
|
|
434
|
+
* @param container - The container element or window to check.
|
|
435
|
+
* @returns `true` if the container is the global window object.
|
|
436
|
+
*/
|
|
437
|
+
export declare function isWindow(container: HTMLElement | Window | null | undefined): container is Window;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Checks if the container is window-like (global window or document body).
|
|
441
|
+
*
|
|
442
|
+
* @param container - The container element or window to check.
|
|
443
|
+
* @returns `true` if the container is window or body.
|
|
444
|
+
*/
|
|
445
|
+
export declare function isWindowLike(container: HTMLElement | Window | null | undefined): boolean;
|
|
446
|
+
|
|
447
|
+
/** Parameters for calculating an item's position and size. */
|
|
448
|
+
export declare interface ItemPositionParams {
|
|
449
|
+
/** Item index. */
|
|
450
|
+
index: number;
|
|
451
|
+
/** Scroll direction. */
|
|
452
|
+
direction: ScrollDirection;
|
|
453
|
+
/** Fixed item size. */
|
|
454
|
+
fixedSize: number | null;
|
|
455
|
+
/** Item gap. */
|
|
456
|
+
gap: number;
|
|
457
|
+
/** Column gap. */
|
|
458
|
+
columnGap: number;
|
|
459
|
+
/** Usable viewport width. */
|
|
460
|
+
usableWidth: number;
|
|
461
|
+
/** Usable viewport height. */
|
|
462
|
+
usableHeight: number;
|
|
463
|
+
/** Total estimated width. */
|
|
464
|
+
totalWidth: number;
|
|
465
|
+
/** Prefix sum for row height. */
|
|
466
|
+
queryY: (idx: number) => number;
|
|
467
|
+
/** Prefix sum for row width. */
|
|
468
|
+
queryX: (idx: number) => number;
|
|
469
|
+
/** Height resolver. */
|
|
470
|
+
getSizeY: (idx: number) => number;
|
|
471
|
+
/** Width resolver. */
|
|
472
|
+
getSizeX: (idx: number) => number;
|
|
473
|
+
/** Current column range (for grid mode). */
|
|
474
|
+
columnRange?: ColumnRange | undefined;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/** Properties passed to the 'item' scoped slot. */
|
|
478
|
+
export declare interface ItemSlotProps<T = unknown> {
|
|
479
|
+
/** The original data item being rendered. */
|
|
480
|
+
item: T;
|
|
481
|
+
/** The 0-based index of the item. */
|
|
482
|
+
index: number;
|
|
483
|
+
/** Information about the currently visible range of columns. */
|
|
484
|
+
columnRange: {
|
|
485
|
+
/** First rendered column. */
|
|
146
486
|
start: number;
|
|
487
|
+
/** Last rendered column (exclusive). */
|
|
147
488
|
end: number;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
columnCount?: number;
|
|
153
|
-
/** Fixed width of columns or an array/function for column widths. Pass 0, null or undefined for dynamic width. */
|
|
154
|
-
columnWidth?: number | number[] | ((index: number) => number) | null;
|
|
155
|
-
/** The HTML tag to use for the container. */
|
|
156
|
-
containerTag?: string;
|
|
157
|
-
/** The HTML tag to use for the items wrapper. */
|
|
158
|
-
wrapperTag?: string;
|
|
159
|
-
/** The HTML tag to use for each item. */
|
|
160
|
-
itemTag?: string;
|
|
161
|
-
/** Padding at the start of the scroll container. */
|
|
162
|
-
scrollPaddingStart?: number | {
|
|
163
|
-
x?: number;
|
|
164
|
-
y?: number;
|
|
165
|
-
};
|
|
166
|
-
/** Padding at the end of the scroll container. */
|
|
167
|
-
scrollPaddingEnd?: number | {
|
|
168
|
-
x?: number;
|
|
169
|
-
y?: number;
|
|
489
|
+
/** Pixel space before first column. */
|
|
490
|
+
padStart: number;
|
|
491
|
+
/** Pixel space after last column. */
|
|
492
|
+
padEnd: number;
|
|
170
493
|
};
|
|
171
|
-
/**
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
|
|
494
|
+
/** Helper to get the current calculated width of any column index. */
|
|
495
|
+
getColumnWidth: (index: number) => number;
|
|
496
|
+
/** Vertical gap between items. */
|
|
497
|
+
gap: number;
|
|
498
|
+
/** Horizontal gap between columns. */
|
|
499
|
+
columnGap: number;
|
|
500
|
+
/** Whether this item index is configured as sticky. */
|
|
501
|
+
isSticky?: boolean | undefined;
|
|
502
|
+
/** Whether this item is currently in a sticky state at the edge. */
|
|
503
|
+
isStickyActive?: boolean | undefined;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** Parameters for calculating an item's style object. */
|
|
507
|
+
export declare interface ItemStyleParams<T = unknown> {
|
|
508
|
+
/** The rendered item state. */
|
|
509
|
+
item: RenderedItem<T>;
|
|
510
|
+
/** Scroll direction. */
|
|
511
|
+
direction: ScrollDirection;
|
|
512
|
+
/** Configured item size logic. */
|
|
513
|
+
itemSize: number | ((item: T, index: number) => number) | null | undefined;
|
|
514
|
+
/** Parent container tag. */
|
|
515
|
+
containerTag: string;
|
|
516
|
+
/** Padding start on X axis. */
|
|
517
|
+
paddingStartX: number;
|
|
518
|
+
/** Padding start on Y axis. */
|
|
519
|
+
paddingStartY: number;
|
|
520
|
+
/** Hydration state. */
|
|
521
|
+
isHydrated: boolean;
|
|
522
|
+
/** Whether the container is in Right-to-Left (RTL) mode. */
|
|
523
|
+
isRtl: boolean;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
declare interface Props<T = unknown> extends VirtualScrollComponentProps<T> {
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
declare interface Props_2 extends VirtualScrollbarProps {
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/** Parameters for calculating the visible range of items. */
|
|
533
|
+
export declare interface RangeParams {
|
|
534
|
+
/** Scroll direction. */
|
|
535
|
+
direction: ScrollDirection;
|
|
536
|
+
/** Relative horizontal scroll position. */
|
|
537
|
+
relativeScrollX: number;
|
|
538
|
+
/** Relative vertical scroll position. */
|
|
539
|
+
relativeScrollY: number;
|
|
540
|
+
/** Usable viewport width. */
|
|
541
|
+
usableWidth: number;
|
|
542
|
+
/** Usable viewport height. */
|
|
543
|
+
usableHeight: number;
|
|
544
|
+
/** Total item count. */
|
|
545
|
+
itemsLength: number;
|
|
546
|
+
/** Buffer items before. */
|
|
547
|
+
bufferBefore: number;
|
|
548
|
+
/** Buffer items after. */
|
|
549
|
+
bufferAfter: number;
|
|
550
|
+
/** Item gap. */
|
|
551
|
+
gap: number;
|
|
552
|
+
/** Column gap. */
|
|
553
|
+
columnGap: number;
|
|
554
|
+
/** Fixed item size. */
|
|
555
|
+
fixedSize: number | null;
|
|
556
|
+
/** Binary search for row index. */
|
|
557
|
+
findLowerBoundY: (offset: number) => number;
|
|
558
|
+
/** Binary search for row index (horizontal). */
|
|
559
|
+
findLowerBoundX: (offset: number) => number;
|
|
560
|
+
/** Prefix sum for row height. */
|
|
561
|
+
queryY: (index: number) => number;
|
|
562
|
+
/** Prefix sum for row width. */
|
|
563
|
+
queryX: (index: number) => number;
|
|
197
564
|
}
|
|
198
565
|
|
|
199
566
|
/** Represents an item currently rendered in the virtual scroll area. */
|
|
200
567
|
export declare interface RenderedItem<T = unknown> {
|
|
201
|
-
/** The original data item. */
|
|
568
|
+
/** The original data item from the provided source array. */
|
|
202
569
|
item: T;
|
|
203
|
-
/** The index of the item in the original array. */
|
|
570
|
+
/** The 0-based index of the item in the original array. */
|
|
204
571
|
index: number;
|
|
205
|
-
/** The calculated offset relative to the
|
|
572
|
+
/** The calculated pixel offset relative to the items wrapper in display pixels (DU). */
|
|
206
573
|
offset: {
|
|
574
|
+
/** Horizontal offset (left) in DU. */
|
|
207
575
|
x: number;
|
|
576
|
+
/** Vertical offset (top) in DU. */
|
|
208
577
|
y: number;
|
|
209
578
|
};
|
|
210
|
-
/** The current measured or estimated size. */
|
|
579
|
+
/** The current measured or estimated size of the item in virtual units (VU). */
|
|
211
580
|
size: {
|
|
581
|
+
/** Pixel width in VU. */
|
|
212
582
|
width: number;
|
|
583
|
+
/** Pixel height in VU. */
|
|
213
584
|
height: number;
|
|
214
585
|
};
|
|
215
|
-
/** The original
|
|
586
|
+
/** The original horizontal pixel offset before any sticky adjustments in VU. */
|
|
216
587
|
originalX: number;
|
|
217
|
-
/** The original
|
|
588
|
+
/** The original vertical pixel offset before any sticky adjustments in VU. */
|
|
218
589
|
originalY: number;
|
|
219
|
-
/** Whether this item is configured to be sticky. */
|
|
590
|
+
/** Whether this item is configured to be sticky via the `stickyIndices` property. */
|
|
220
591
|
isSticky?: boolean;
|
|
221
|
-
/** Whether this item is currently stuck at the
|
|
592
|
+
/** Whether this item is currently in a stuck state at the viewport edge. */
|
|
222
593
|
isStickyActive?: boolean;
|
|
223
|
-
/** The
|
|
594
|
+
/** The relative translation applied to the item for the sticky pushing effect in DU. */
|
|
224
595
|
stickyOffset: {
|
|
596
|
+
/** Horizontal translation in DU. */
|
|
225
597
|
x: number;
|
|
598
|
+
/** Vertical translation in DU. */
|
|
226
599
|
y: number;
|
|
227
600
|
};
|
|
228
601
|
}
|
|
229
602
|
|
|
603
|
+
/**
|
|
604
|
+
* Alignment of an item within the viewport after a scroll operation.
|
|
605
|
+
* - 'start': Aligns item to the top or left edge.
|
|
606
|
+
* - 'center': Aligns item to the center of the viewport.
|
|
607
|
+
* - 'end': Aligns item to the bottom or right edge.
|
|
608
|
+
* - 'auto': Smart alignment. If visible, stays. If not, aligns to nearest edge.
|
|
609
|
+
*/
|
|
230
610
|
export declare type ScrollAlignment = 'start' | 'center' | 'end' | 'auto';
|
|
231
611
|
|
|
232
612
|
/** Options for scroll alignment in a single axis or both axes. */
|
|
233
613
|
export declare interface ScrollAlignmentOptions {
|
|
234
|
-
/** Alignment on the X axis. */
|
|
614
|
+
/** Alignment on the X (horizontal) axis. */
|
|
235
615
|
x?: ScrollAlignment;
|
|
236
|
-
/** Alignment on the Y axis. */
|
|
616
|
+
/** Alignment on the Y (vertical) axis. */
|
|
237
617
|
y?: ScrollAlignment;
|
|
238
618
|
}
|
|
239
619
|
|
|
620
|
+
/** Help provide axis specific information to the scrollbar. */
|
|
621
|
+
export declare type ScrollAxis = 'vertical' | 'horizontal';
|
|
622
|
+
|
|
623
|
+
/** Properties passed to the 'scrollbar' scoped slot. */
|
|
624
|
+
export declare interface ScrollbarSlotProps {
|
|
625
|
+
/** Current scroll position as a percentage (0 to 1). */
|
|
626
|
+
positionPercent: number;
|
|
627
|
+
/** Viewport size as a percentage of total size (0 to 1). */
|
|
628
|
+
viewportPercent: number;
|
|
629
|
+
/** Calculated thumb size as a percentage of the track size (0 to 100). */
|
|
630
|
+
thumbSizePercent: number;
|
|
631
|
+
/** Calculated thumb position as a percentage of the track size (0 to 100). */
|
|
632
|
+
thumbPositionPercent: number;
|
|
633
|
+
/**
|
|
634
|
+
* Attributes and event listeners to be bound to the scrollbar track element.
|
|
635
|
+
* Use `v-bind="trackProps"` on your track element.
|
|
636
|
+
*/
|
|
637
|
+
trackProps: Record<string, unknown>;
|
|
638
|
+
/**
|
|
639
|
+
* Attributes and event listeners to be bound to the scrollbar thumb element.
|
|
640
|
+
* Use `v-bind="thumbProps"` on your thumb element.
|
|
641
|
+
*/
|
|
642
|
+
thumbProps: Record<string, unknown>;
|
|
643
|
+
/**
|
|
644
|
+
* Grouped props for the `VirtualScrollbar` component.
|
|
645
|
+
* Useful for passing directly to `<VirtualScrollbar v-bind="scrollbarProps" />`.
|
|
646
|
+
*/
|
|
647
|
+
scrollbarProps: VirtualScrollbarProps;
|
|
648
|
+
/** Whether the thumb is currently being dragged. */
|
|
649
|
+
isDragging: boolean;
|
|
650
|
+
}
|
|
651
|
+
|
|
240
652
|
/** Comprehensive state of the virtual scroll system. */
|
|
241
653
|
export declare interface ScrollDetails<T = unknown> {
|
|
242
|
-
/** List of items currently rendered. */
|
|
654
|
+
/** List of items currently rendered in the DOM buffer. */
|
|
243
655
|
items: RenderedItem<T>[];
|
|
244
|
-
/** Index of the first item
|
|
656
|
+
/** Index of the first item visible below any sticky header in the viewport. */
|
|
245
657
|
currentIndex: number;
|
|
246
|
-
/** Index of the first column
|
|
658
|
+
/** Index of the first column visible after any sticky column in the viewport (grid mode). */
|
|
247
659
|
currentColIndex: number;
|
|
248
|
-
/**
|
|
660
|
+
/** Index of the last item visible above any sticky footer in the viewport. */
|
|
661
|
+
currentEndIndex: number;
|
|
662
|
+
/** Index of the last column visible before any sticky end column in the viewport (grid mode). */
|
|
663
|
+
currentEndColIndex: number;
|
|
664
|
+
/** Current relative pixel scroll position from the content start in VU. */
|
|
249
665
|
scrollOffset: {
|
|
666
|
+
/** Horizontal position (X) in VU. */
|
|
667
|
+
x: number;
|
|
668
|
+
/** Vertical position (Y) in VU. */
|
|
669
|
+
y: number;
|
|
670
|
+
};
|
|
671
|
+
/** Current display pixel scroll position (before scaling) in DU. */
|
|
672
|
+
displayScrollOffset: {
|
|
673
|
+
/** Horizontal position (X) in DU. */
|
|
250
674
|
x: number;
|
|
675
|
+
/** Vertical position (Y) in DU. */
|
|
251
676
|
y: number;
|
|
252
677
|
};
|
|
253
|
-
/**
|
|
678
|
+
/** Current dimensions of the visible viewport area in VU. */
|
|
254
679
|
viewportSize: {
|
|
680
|
+
/** Pixel width in VU. */
|
|
255
681
|
width: number;
|
|
682
|
+
/** Pixel height in VU. */
|
|
256
683
|
height: number;
|
|
257
684
|
};
|
|
258
|
-
/**
|
|
685
|
+
/** Current dimensions of the visible viewport area in display pixels (DU). */
|
|
686
|
+
displayViewportSize: {
|
|
687
|
+
/** Pixel width in DU. */
|
|
688
|
+
width: number;
|
|
689
|
+
/** Pixel height in DU. */
|
|
690
|
+
height: number;
|
|
691
|
+
};
|
|
692
|
+
/** Total calculated or estimated size of all items and gaps in VU. */
|
|
259
693
|
totalSize: {
|
|
694
|
+
/** Total pixel width in VU. */
|
|
260
695
|
width: number;
|
|
696
|
+
/** Total pixel height in VU. */
|
|
261
697
|
height: number;
|
|
262
698
|
};
|
|
263
|
-
/** Whether the container is currently being scrolled. */
|
|
699
|
+
/** Whether the container is currently being scrolled by the user or an animation. */
|
|
264
700
|
isScrolling: boolean;
|
|
265
|
-
/** Whether the current scroll was initiated
|
|
701
|
+
/** Whether the current scroll operation was initiated programmatically. */
|
|
266
702
|
isProgrammaticScroll: boolean;
|
|
267
|
-
/**
|
|
703
|
+
/** The range of item indices currently being rendered. */
|
|
268
704
|
range: {
|
|
705
|
+
/** Inclusive start index. */
|
|
269
706
|
start: number;
|
|
707
|
+
/** Exclusive end index. */
|
|
270
708
|
end: number;
|
|
271
709
|
};
|
|
272
|
-
/**
|
|
273
|
-
columnRange:
|
|
274
|
-
start: number;
|
|
275
|
-
end: number;
|
|
276
|
-
padStart: number;
|
|
277
|
-
padEnd: number;
|
|
278
|
-
};
|
|
710
|
+
/** The range of column indices and associated paddings currently being rendered. */
|
|
711
|
+
columnRange: ColumnRange;
|
|
279
712
|
}
|
|
280
713
|
|
|
714
|
+
/**
|
|
715
|
+
* The direction of the virtual scroll.
|
|
716
|
+
* - 'vertical': Single-column vertical scrolling.
|
|
717
|
+
* - 'horizontal': Single-row horizontal scrolling.
|
|
718
|
+
* - 'both': Bidirectional grid-based scrolling.
|
|
719
|
+
*/
|
|
281
720
|
export declare type ScrollDirection = 'vertical' | 'horizontal' | 'both';
|
|
282
721
|
|
|
283
|
-
/**
|
|
722
|
+
/** Parameters for calculating the scroll target position. */
|
|
723
|
+
export declare interface ScrollTargetParams {
|
|
724
|
+
/** Row index to target. */
|
|
725
|
+
rowIndex: number | null | undefined;
|
|
726
|
+
/** Column index to target. */
|
|
727
|
+
colIndex: number | null | undefined;
|
|
728
|
+
/** Scroll options. */
|
|
729
|
+
options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions | undefined;
|
|
730
|
+
/** Current scroll direction. */
|
|
731
|
+
direction: ScrollDirection;
|
|
732
|
+
/** Current viewport width. */
|
|
733
|
+
viewportWidth: number;
|
|
734
|
+
/** Current viewport height. */
|
|
735
|
+
viewportHeight: number;
|
|
736
|
+
/** Current total estimated width. */
|
|
737
|
+
totalWidth: number;
|
|
738
|
+
/** Current total estimated height. */
|
|
739
|
+
totalHeight: number;
|
|
740
|
+
/** Item gap. */
|
|
741
|
+
gap: number;
|
|
742
|
+
/** Column gap. */
|
|
743
|
+
columnGap: number;
|
|
744
|
+
/** Fixed item size. */
|
|
745
|
+
fixedSize: number | null;
|
|
746
|
+
/** Fixed column width. */
|
|
747
|
+
fixedWidth: number | null;
|
|
748
|
+
/** Current relative X scroll. */
|
|
749
|
+
relativeScrollX: number;
|
|
750
|
+
/** Current relative Y scroll. */
|
|
751
|
+
relativeScrollY: number;
|
|
752
|
+
/** Resolver for item height. */
|
|
753
|
+
getItemSizeY: (index: number) => number;
|
|
754
|
+
/** Resolver for item width. */
|
|
755
|
+
getItemSizeX: (index: number) => number;
|
|
756
|
+
/** Prefix sum resolver for item height. */
|
|
757
|
+
getItemQueryY: (index: number) => number;
|
|
758
|
+
/** Prefix sum resolver for item width. */
|
|
759
|
+
getItemQueryX: (index: number) => number;
|
|
760
|
+
/** Resolver for column size. */
|
|
761
|
+
getColumnSize: (index: number) => number;
|
|
762
|
+
/** Prefix sum resolver for column width. */
|
|
763
|
+
getColumnQuery: (index: number) => number;
|
|
764
|
+
/** Coordinate scaling factor for X axis. */
|
|
765
|
+
scaleX: number;
|
|
766
|
+
/** Coordinate scaling factor for Y axis. */
|
|
767
|
+
scaleY: number;
|
|
768
|
+
/** Host offset on X axis in display pixels. */
|
|
769
|
+
hostOffsetX: number;
|
|
770
|
+
/** Host offset on Y axis in display pixels. */
|
|
771
|
+
hostOffsetY: number;
|
|
772
|
+
/** List of sticky indices. */
|
|
773
|
+
stickyIndices?: number[] | undefined;
|
|
774
|
+
/** Sticky start offset on X axis. */
|
|
775
|
+
stickyStartX?: number | undefined;
|
|
776
|
+
/** Sticky start offset on Y axis. */
|
|
777
|
+
stickyStartY?: number | undefined;
|
|
778
|
+
/** Sticky end offset on X axis. */
|
|
779
|
+
stickyEndX?: number | undefined;
|
|
780
|
+
/** Sticky end offset on Y axis. */
|
|
781
|
+
stickyEndY?: number | undefined;
|
|
782
|
+
/** Flow padding start on X axis. */
|
|
783
|
+
flowPaddingStartX?: number | undefined;
|
|
784
|
+
/** Flow padding start on Y axis. */
|
|
785
|
+
flowPaddingStartY?: number | undefined;
|
|
786
|
+
/** Flow padding end on X axis. */
|
|
787
|
+
flowPaddingEndX?: number | undefined;
|
|
788
|
+
/** Flow padding end on Y axis. */
|
|
789
|
+
flowPaddingEndY?: number | undefined;
|
|
790
|
+
/** Scroll padding start on X axis. */
|
|
791
|
+
paddingStartX?: number | undefined;
|
|
792
|
+
/** Scroll padding start on Y axis. */
|
|
793
|
+
paddingStartY?: number | undefined;
|
|
794
|
+
/** Scroll padding end on X axis. */
|
|
795
|
+
paddingEndX?: number | undefined;
|
|
796
|
+
/** Scroll padding end on Y axis. */
|
|
797
|
+
paddingEndY?: number | undefined;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/** Calculated scroll target result. */
|
|
801
|
+
export declare interface ScrollTargetResult {
|
|
802
|
+
/** Target relative horizontal position. */
|
|
803
|
+
targetX: number;
|
|
804
|
+
/** Target relative vertical position. */
|
|
805
|
+
targetY: number;
|
|
806
|
+
/** Resolved width of the target item. */
|
|
807
|
+
itemWidth: number;
|
|
808
|
+
/** Resolved height of the target item. */
|
|
809
|
+
itemHeight: number;
|
|
810
|
+
/** Effective alignment used for X axis. */
|
|
811
|
+
effectiveAlignX: ScrollAlignment;
|
|
812
|
+
/** Effective alignment used for Y axis. */
|
|
813
|
+
effectiveAlignY: ScrollAlignment;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/** Options for the `scrollToIndex` method. */
|
|
284
817
|
export declare interface ScrollToIndexOptions {
|
|
285
|
-
/**
|
|
818
|
+
/**
|
|
819
|
+
* Where to align the item in the viewport.
|
|
820
|
+
* Can be a single value for both axes or an object for individual control.
|
|
821
|
+
* @default 'auto'
|
|
822
|
+
*/
|
|
286
823
|
align?: ScrollAlignment | ScrollAlignmentOptions;
|
|
287
|
-
/**
|
|
824
|
+
/**
|
|
825
|
+
* Scroll behavior.
|
|
826
|
+
* - 'auto': Instant jump.
|
|
827
|
+
* - 'smooth': Animated transition.
|
|
828
|
+
* @default 'smooth'
|
|
829
|
+
*/
|
|
288
830
|
behavior?: 'auto' | 'smooth';
|
|
289
|
-
|
|
290
|
-
|
|
831
|
+
/* Excluded from this release type: isCorrection */
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/** Parameters for calculating sticky item offsets. */
|
|
835
|
+
export declare interface StickyParams {
|
|
836
|
+
/** Item index. */
|
|
837
|
+
index: number;
|
|
838
|
+
/** Is sticky configured. */
|
|
839
|
+
isSticky: boolean;
|
|
840
|
+
/** Scroll direction. */
|
|
841
|
+
direction: ScrollDirection;
|
|
842
|
+
/** Relative horizontal scroll. */
|
|
843
|
+
relativeScrollX: number;
|
|
844
|
+
/** Relative vertical scroll. */
|
|
845
|
+
relativeScrollY: number;
|
|
846
|
+
/** Original X offset. */
|
|
847
|
+
originalX: number;
|
|
848
|
+
/** Original Y offset. */
|
|
849
|
+
originalY: number;
|
|
850
|
+
/** Current width. */
|
|
851
|
+
width: number;
|
|
852
|
+
/** Current height. */
|
|
853
|
+
height: number;
|
|
854
|
+
/** All sticky indices. */
|
|
855
|
+
stickyIndices: number[];
|
|
856
|
+
/** Fixed item size. */
|
|
857
|
+
fixedSize: number | null;
|
|
858
|
+
/** Fixed column width. */
|
|
859
|
+
fixedWidth: number | null;
|
|
860
|
+
/** Item gap. */
|
|
861
|
+
gap: number;
|
|
862
|
+
/** Column gap. */
|
|
863
|
+
columnGap: number;
|
|
864
|
+
/** Prefix sum resolver for rows. */
|
|
865
|
+
getItemQueryY: (index: number) => number;
|
|
866
|
+
/** Prefix sum resolver for rows (horizontal). */
|
|
867
|
+
getItemQueryX: (index: number) => number;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/** Parameters for calculating the total size of the scrollable area. */
|
|
871
|
+
export declare interface TotalSizeParams {
|
|
872
|
+
/** The scroll direction. */
|
|
873
|
+
direction: ScrollDirection;
|
|
874
|
+
/** The number of items in the list. */
|
|
875
|
+
itemsLength: number;
|
|
876
|
+
/** The number of columns (for grid mode). */
|
|
877
|
+
columnCount: number;
|
|
878
|
+
/** The fixed size of items, if applicable. */
|
|
879
|
+
fixedSize: number | null;
|
|
880
|
+
/** The fixed width of columns, if applicable. */
|
|
881
|
+
fixedWidth: number | null;
|
|
882
|
+
/** The gap between items. */
|
|
883
|
+
gap: number;
|
|
884
|
+
/** The gap between columns. */
|
|
885
|
+
columnGap: number;
|
|
886
|
+
/** Usable viewport width. */
|
|
887
|
+
usableWidth: number;
|
|
888
|
+
/** Usable viewport height. */
|
|
889
|
+
usableHeight: number;
|
|
890
|
+
/** Function to query the prefix sum of item heights. */
|
|
891
|
+
queryY: (index: number) => number;
|
|
892
|
+
/** Function to query the prefix sum of item widths. */
|
|
893
|
+
queryX: (index: number) => number;
|
|
894
|
+
/** Function to query the prefix sum of column widths. */
|
|
895
|
+
queryColumn: (index: number) => number;
|
|
291
896
|
}
|
|
292
897
|
|
|
293
898
|
/**
|
|
294
899
|
* Composable for virtual scrolling logic.
|
|
295
|
-
* Handles calculation of visible items, scroll events,
|
|
900
|
+
* Handles calculation of visible items, scroll events, dynamic item sizes, and programmatic scrolling.
|
|
296
901
|
*
|
|
297
|
-
* @param
|
|
902
|
+
* @param propsInput - The configuration properties. Can be a plain object, a Ref, or a getter function.
|
|
903
|
+
* @see VirtualScrollProps
|
|
298
904
|
*/
|
|
299
|
-
export declare function useVirtualScroll<T = unknown>(
|
|
905
|
+
export declare function useVirtualScroll<T = unknown>(propsInput: MaybeRefOrGetter<VirtualScrollProps<T>>): {
|
|
300
906
|
/**
|
|
301
|
-
* Array of items
|
|
907
|
+
* Array of items currently rendered in the DOM with their calculated offsets and sizes.
|
|
908
|
+
* Offsets are in Display Units (DU), sizes are in Virtual Units (VU).
|
|
909
|
+
* @see RenderedItem
|
|
302
910
|
*/
|
|
303
911
|
renderedItems: ComputedRef<RenderedItem<T>[]>;
|
|
304
912
|
/**
|
|
305
|
-
* Total calculated width of all items including gaps.
|
|
913
|
+
* Total calculated width of all items including gaps (in VU).
|
|
306
914
|
*/
|
|
307
915
|
totalWidth: ComputedRef<number>;
|
|
308
916
|
/**
|
|
309
|
-
* Total calculated height of all items including gaps.
|
|
917
|
+
* Total calculated height of all items including gaps (in VU).
|
|
310
918
|
*/
|
|
311
919
|
totalHeight: ComputedRef<number>;
|
|
920
|
+
/**
|
|
921
|
+
* Total width to be rendered in the DOM (clamped to browser limits, in DU).
|
|
922
|
+
*/
|
|
923
|
+
renderedWidth: ComputedRef<number>;
|
|
924
|
+
/**
|
|
925
|
+
* Total height to be rendered in the DOM (clamped to browser limits, in DU).
|
|
926
|
+
*/
|
|
927
|
+
renderedHeight: ComputedRef<number>;
|
|
312
928
|
/**
|
|
313
929
|
* Detailed information about the current scroll state.
|
|
314
|
-
* Includes currentIndex, scrollOffset, viewportSize, totalSize, and
|
|
930
|
+
* Includes currentIndex, scrollOffset (VU), displayScrollOffset (DU), viewportSize (DU), totalSize (VU), and scrolling status.
|
|
931
|
+
* @see ScrollDetails
|
|
315
932
|
*/
|
|
316
933
|
scrollDetails: ComputedRef<ScrollDetails<T>>;
|
|
934
|
+
/**
|
|
935
|
+
* Helper to get the height of a specific row based on current configuration and measurements.
|
|
936
|
+
*
|
|
937
|
+
* @param index - The row index.
|
|
938
|
+
* @returns The height in VU (excluding gap).
|
|
939
|
+
*/
|
|
940
|
+
getRowHeight: (index: number) => number;
|
|
941
|
+
/**
|
|
942
|
+
* Helper to get the width of a specific column based on current configuration and measurements.
|
|
943
|
+
*
|
|
944
|
+
* @param index - The column index.
|
|
945
|
+
* @returns The width in VU (excluding gap).
|
|
946
|
+
*/
|
|
947
|
+
getColumnWidth: (index: number) => number;
|
|
948
|
+
/**
|
|
949
|
+
* Helper to get the virtual offset of a specific row.
|
|
950
|
+
*
|
|
951
|
+
* @param index - The row index.
|
|
952
|
+
* @returns The virtual offset in VU.
|
|
953
|
+
*/
|
|
954
|
+
getRowOffset: (index: number) => number;
|
|
955
|
+
/**
|
|
956
|
+
* Helper to get the virtual offset of a specific column.
|
|
957
|
+
*
|
|
958
|
+
* @param index - The column index.
|
|
959
|
+
* @returns The virtual offset in VU.
|
|
960
|
+
*/
|
|
961
|
+
getColumnOffset: (index: number) => number;
|
|
962
|
+
/**
|
|
963
|
+
* Helper to get the virtual offset of a specific item along the scroll axis.
|
|
964
|
+
*
|
|
965
|
+
* @param index - The item index.
|
|
966
|
+
* @returns The virtual offset in VU.
|
|
967
|
+
*/
|
|
968
|
+
getItemOffset: (index: number) => number;
|
|
969
|
+
/**
|
|
970
|
+
* Helper to get the size of a specific item along the scroll axis.
|
|
971
|
+
*
|
|
972
|
+
* @param index - The item index.
|
|
973
|
+
* @returns The size in VU (excluding gap).
|
|
974
|
+
*/
|
|
975
|
+
getItemSize: (index: number) => number;
|
|
317
976
|
/**
|
|
318
977
|
* Programmatically scroll to a specific row and/or column.
|
|
319
|
-
*
|
|
320
|
-
* @param
|
|
321
|
-
* @param
|
|
978
|
+
*
|
|
979
|
+
* @param rowIndex - The row index to scroll to. Pass null to only scroll horizontally.
|
|
980
|
+
* @param colIndex - The column index to scroll to. Pass null to only scroll vertically.
|
|
981
|
+
* @param options - Alignment and behavior options.
|
|
982
|
+
* @see ScrollAlignment
|
|
983
|
+
* @see ScrollToIndexOptions
|
|
322
984
|
*/
|
|
323
985
|
scrollToIndex: (rowIndex: number | null | undefined, colIndex: number | null | undefined, options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions) => void;
|
|
324
986
|
/**
|
|
325
|
-
* Programmatically scroll to a specific pixel offset.
|
|
326
|
-
*
|
|
327
|
-
* @param
|
|
328
|
-
* @param
|
|
987
|
+
* Programmatically scroll to a specific pixel offset relative to the content start.
|
|
988
|
+
*
|
|
989
|
+
* @param x - The pixel offset to scroll to on the X axis (VU). Pass null to keep current position.
|
|
990
|
+
* @param y - The pixel offset to scroll to on the Y axis (VU). Pass null to keep current position.
|
|
991
|
+
* @param options - Scroll options (behavior).
|
|
329
992
|
*/
|
|
330
993
|
scrollToOffset: (x?: number | null, y?: number | null, options?: {
|
|
331
994
|
behavior?: "auto" | "smooth";
|
|
332
995
|
}) => void;
|
|
333
996
|
/**
|
|
334
|
-
* Stops any currently active
|
|
997
|
+
* Stops any currently active smooth scroll animation and clears pending corrections.
|
|
335
998
|
*/
|
|
336
999
|
stopProgrammaticScroll: () => void;
|
|
337
1000
|
/**
|
|
338
1001
|
* Updates the stored size of an item. Should be called when an item is measured (e.g., via ResizeObserver).
|
|
339
|
-
*
|
|
340
|
-
* @param
|
|
341
|
-
* @param
|
|
342
|
-
* @param
|
|
1002
|
+
*
|
|
1003
|
+
* @param index - The item index.
|
|
1004
|
+
* @param width - The measured inlineSize (width in DU).
|
|
1005
|
+
* @param height - The measured blockSize (height in DU).
|
|
1006
|
+
* @param element - The measured element (optional, used for robust grid column detection).
|
|
343
1007
|
*/
|
|
344
1008
|
updateItemSize: (index: number, inlineSize: number, blockSize: number, element?: HTMLElement) => void;
|
|
345
1009
|
/**
|
|
346
|
-
* Updates the stored size of multiple items
|
|
347
|
-
*
|
|
1010
|
+
* Updates the stored size of multiple items simultaneously.
|
|
1011
|
+
*
|
|
1012
|
+
* @param updates - Array of measurement updates (sizes in DU).
|
|
348
1013
|
*/
|
|
349
1014
|
updateItemSizes: (updates: Array<{
|
|
350
1015
|
index: number;
|
|
@@ -354,10 +1019,16 @@ export declare function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollPr
|
|
|
354
1019
|
}>) => void;
|
|
355
1020
|
/**
|
|
356
1021
|
* Recalculates the host element's offset relative to the scroll container.
|
|
1022
|
+
* Useful if the container or host moves without a resize event.
|
|
357
1023
|
*/
|
|
358
1024
|
updateHostOffset: () => void;
|
|
359
1025
|
/**
|
|
360
|
-
*
|
|
1026
|
+
* Detects the current direction (LTR/RTL) of the scroll container.
|
|
1027
|
+
*/
|
|
1028
|
+
updateDirection: () => void;
|
|
1029
|
+
/**
|
|
1030
|
+
* Information about the current visible range of columns and their paddings.
|
|
1031
|
+
* @see ColumnRange
|
|
361
1032
|
*/
|
|
362
1033
|
columnRange: ComputedRef< {
|
|
363
1034
|
start: number;
|
|
@@ -365,21 +1036,148 @@ export declare function useVirtualScroll<T = unknown>(props: Ref<VirtualScrollPr
|
|
|
365
1036
|
padStart: number;
|
|
366
1037
|
padEnd: number;
|
|
367
1038
|
}>;
|
|
368
|
-
/**
|
|
369
|
-
* Helper to get the width of a specific column based on current configuration.
|
|
370
|
-
* @param index - The column index
|
|
371
|
-
*/
|
|
372
|
-
getColumnWidth: (index: number) => number;
|
|
373
1039
|
/**
|
|
374
1040
|
* Resets all dynamic measurements and re-initializes from props.
|
|
1041
|
+
* Useful if item sizes have changed externally.
|
|
375
1042
|
*/
|
|
376
1043
|
refresh: () => void;
|
|
377
1044
|
/**
|
|
378
1045
|
* Whether the component has finished its first client-side mount and hydration.
|
|
379
1046
|
*/
|
|
380
1047
|
isHydrated: Ref<boolean, boolean>;
|
|
1048
|
+
/**
|
|
1049
|
+
* Whether the container is the window or body.
|
|
1050
|
+
*/
|
|
1051
|
+
isWindowContainer: ComputedRef<boolean>;
|
|
1052
|
+
/**
|
|
1053
|
+
* Whether the scroll container is in Right-to-Left (RTL) mode.
|
|
1054
|
+
*/
|
|
1055
|
+
isRtl: Ref<boolean, boolean>;
|
|
1056
|
+
/**
|
|
1057
|
+
* Coordinate scaling factor for X axis (VU/DU).
|
|
1058
|
+
*/
|
|
1059
|
+
scaleX: ComputedRef<number>;
|
|
1060
|
+
/**
|
|
1061
|
+
* Coordinate scaling factor for Y axis (VU/DU).
|
|
1062
|
+
*/
|
|
1063
|
+
scaleY: ComputedRef<number>;
|
|
1064
|
+
/**
|
|
1065
|
+
* Absolute offset of the component within its container (DU).
|
|
1066
|
+
*/
|
|
1067
|
+
componentOffset: {
|
|
1068
|
+
x: number;
|
|
1069
|
+
y: number;
|
|
1070
|
+
};
|
|
1071
|
+
/**
|
|
1072
|
+
* Physical width of the items wrapper in the DOM (clamped to browser limits, in DU).
|
|
1073
|
+
*/
|
|
1074
|
+
renderedVirtualWidth: ComputedRef<number>;
|
|
1075
|
+
/**
|
|
1076
|
+
* Physical height of the items wrapper in the DOM (clamped to browser limits, in DU).
|
|
1077
|
+
*/
|
|
1078
|
+
renderedVirtualHeight: ComputedRef<number>;
|
|
381
1079
|
};
|
|
382
1080
|
|
|
1081
|
+
/**
|
|
1082
|
+
* Composable for virtual scrollbar logic.
|
|
1083
|
+
* Provides attributes and event listeners for track and thumb elements.
|
|
1084
|
+
*
|
|
1085
|
+
* @param props - Configuration properties.
|
|
1086
|
+
*/
|
|
1087
|
+
export declare function useVirtualScrollbar(props: UseVirtualScrollbarProps): {
|
|
1088
|
+
/** Viewport size as a percentage of total size (0 to 1). */
|
|
1089
|
+
viewportPercent: ComputedRef<number>;
|
|
1090
|
+
/** Current scroll position as a percentage of the scrollable range (0 to 1). */
|
|
1091
|
+
positionPercent: ComputedRef<number>;
|
|
1092
|
+
/** Calculated thumb size as a percentage of the track size (0 to 100). */
|
|
1093
|
+
thumbSizePercent: ComputedRef<number>;
|
|
1094
|
+
/** Calculated thumb position as a percentage of the track size (0 to 100). */
|
|
1095
|
+
thumbPositionPercent: ComputedRef<number>;
|
|
1096
|
+
/** Reactive style object for the scrollbar track. */
|
|
1097
|
+
trackStyle: ComputedRef< {
|
|
1098
|
+
inlineSize: string;
|
|
1099
|
+
blockSize?: never;
|
|
1100
|
+
} | {
|
|
1101
|
+
blockSize: string;
|
|
1102
|
+
inlineSize?: never;
|
|
1103
|
+
}>;
|
|
1104
|
+
/** Reactive style object for the scrollbar thumb. */
|
|
1105
|
+
thumbStyle: ComputedRef< {
|
|
1106
|
+
inlineSize: string;
|
|
1107
|
+
insetInlineStart: string;
|
|
1108
|
+
blockSize?: never;
|
|
1109
|
+
insetBlockStart?: never;
|
|
1110
|
+
} | {
|
|
1111
|
+
blockSize: string;
|
|
1112
|
+
insetBlockStart: string;
|
|
1113
|
+
inlineSize?: never;
|
|
1114
|
+
insetInlineStart?: never;
|
|
1115
|
+
}>;
|
|
1116
|
+
/** Attributes and event listeners to be bound to the track element. */
|
|
1117
|
+
trackProps: ComputedRef< {
|
|
1118
|
+
class: string[];
|
|
1119
|
+
style: {
|
|
1120
|
+
inlineSize: string;
|
|
1121
|
+
blockSize?: never;
|
|
1122
|
+
} | {
|
|
1123
|
+
blockSize: string;
|
|
1124
|
+
inlineSize?: never;
|
|
1125
|
+
};
|
|
1126
|
+
role: string;
|
|
1127
|
+
'aria-orientation': ScrollAxis;
|
|
1128
|
+
'aria-valuenow': number;
|
|
1129
|
+
'aria-valuemin': number;
|
|
1130
|
+
'aria-valuemax': number;
|
|
1131
|
+
'aria-controls': string | undefined;
|
|
1132
|
+
tabindex: number;
|
|
1133
|
+
onMousedown: (event: MouseEvent) => void;
|
|
1134
|
+
}>;
|
|
1135
|
+
/** Attributes and event listeners to be bound to the thumb element. */
|
|
1136
|
+
thumbProps: ComputedRef< {
|
|
1137
|
+
class: (string | {
|
|
1138
|
+
'virtual-scrollbar-thumb--active': boolean;
|
|
1139
|
+
})[];
|
|
1140
|
+
style: {
|
|
1141
|
+
inlineSize: string;
|
|
1142
|
+
insetInlineStart: string;
|
|
1143
|
+
blockSize?: never;
|
|
1144
|
+
insetBlockStart?: never;
|
|
1145
|
+
} | {
|
|
1146
|
+
blockSize: string;
|
|
1147
|
+
insetBlockStart: string;
|
|
1148
|
+
inlineSize?: never;
|
|
1149
|
+
insetInlineStart?: never;
|
|
1150
|
+
};
|
|
1151
|
+
onPointerdown: (event: PointerEvent) => void;
|
|
1152
|
+
onPointermove: (event: PointerEvent) => void;
|
|
1153
|
+
onPointerup: (event: PointerEvent) => void;
|
|
1154
|
+
onPointercancel: (event: PointerEvent) => void;
|
|
1155
|
+
}>;
|
|
1156
|
+
/** Whether the thumb is currently being dragged. */
|
|
1157
|
+
isDragging: Ref<boolean, boolean>;
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
/** Configuration properties for the `useVirtualScrollbar` composable. */
|
|
1161
|
+
export declare interface UseVirtualScrollbarProps {
|
|
1162
|
+
/** The axis for this scrollbar. */
|
|
1163
|
+
axis: MaybeRefOrGetter<ScrollAxis>;
|
|
1164
|
+
/** Total size of the scrollable content area in display pixels (DU). */
|
|
1165
|
+
totalSize: MaybeRefOrGetter<number>;
|
|
1166
|
+
/** Current scroll position in display pixels (DU). */
|
|
1167
|
+
position: MaybeRefOrGetter<number>;
|
|
1168
|
+
/** Viewport size in display pixels (DU). */
|
|
1169
|
+
viewportSize: MaybeRefOrGetter<number>;
|
|
1170
|
+
/**
|
|
1171
|
+
* Function to scroll to a specific display pixel offset (DU) on this axis.
|
|
1172
|
+
* @param offset - The display pixel offset to scroll to.
|
|
1173
|
+
*/
|
|
1174
|
+
scrollToOffset: (offset: number) => void;
|
|
1175
|
+
/** The ID of the container element this scrollbar controls. */
|
|
1176
|
+
containerId?: MaybeRefOrGetter<string | undefined>;
|
|
1177
|
+
/** Whether the scrollbar is in Right-to-Left (RTL) mode. */
|
|
1178
|
+
isRtl?: MaybeRefOrGetter<boolean>;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
383
1181
|
export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
384
1182
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
385
1183
|
readonly onLoad?: (direction: "vertical" | "horizontal") => any;
|
|
@@ -392,76 +1190,302 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
392
1190
|
}) => any;
|
|
393
1191
|
} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, "onLoad" | "onScroll" | "onVisibleRangeChange"> & Props<T> & Partial<{}>> & PublicProps;
|
|
394
1192
|
expose(exposed: ShallowUnwrapRef< {
|
|
1193
|
+
/**
|
|
1194
|
+
* Detailed information about the current scroll state.
|
|
1195
|
+
* @see ScrollDetails
|
|
1196
|
+
* @see useVirtualScroll
|
|
1197
|
+
*/
|
|
395
1198
|
scrollDetails: ComputedRef<ScrollDetails<T>>;
|
|
1199
|
+
/**
|
|
1200
|
+
* Information about the current visible range of columns.
|
|
1201
|
+
* @see ColumnRange
|
|
1202
|
+
* @see useVirtualScroll
|
|
1203
|
+
*/
|
|
396
1204
|
columnRange: ComputedRef< {
|
|
397
1205
|
start: number;
|
|
398
1206
|
end: number;
|
|
399
1207
|
padStart: number;
|
|
400
1208
|
padEnd: number;
|
|
401
1209
|
}>;
|
|
1210
|
+
/**
|
|
1211
|
+
* Helper to get the width of a specific column.
|
|
1212
|
+
* @param index - The column index.
|
|
1213
|
+
* @see useVirtualScroll
|
|
1214
|
+
*/
|
|
402
1215
|
getColumnWidth: (index: number) => number;
|
|
1216
|
+
/**
|
|
1217
|
+
* Helper to get the height of a specific row.
|
|
1218
|
+
* @param index - The row index.
|
|
1219
|
+
* @see useVirtualScroll
|
|
1220
|
+
*/
|
|
1221
|
+
getRowHeight: (index: number) => number;
|
|
1222
|
+
/**
|
|
1223
|
+
* Helper to get the virtual offset of a specific row.
|
|
1224
|
+
* @param index - The row index.
|
|
1225
|
+
* @see useVirtualScroll
|
|
1226
|
+
*/
|
|
1227
|
+
getRowOffset: (index: number) => number;
|
|
1228
|
+
/**
|
|
1229
|
+
* Helper to get the virtual offset of a specific column.
|
|
1230
|
+
* @param index - The column index.
|
|
1231
|
+
* @see useVirtualScroll
|
|
1232
|
+
*/
|
|
1233
|
+
getColumnOffset: (index: number) => number;
|
|
1234
|
+
/**
|
|
1235
|
+
* Helper to get the virtual offset of a specific item.
|
|
1236
|
+
* @param index - The item index.
|
|
1237
|
+
* @see useVirtualScroll
|
|
1238
|
+
*/
|
|
1239
|
+
getItemOffset: (index: number) => number;
|
|
1240
|
+
/**
|
|
1241
|
+
* Helper to get the size of a specific item along the scroll axis.
|
|
1242
|
+
* @param index - The item index.
|
|
1243
|
+
* @see useVirtualScroll
|
|
1244
|
+
*/
|
|
1245
|
+
getItemSize: (index: number) => number;
|
|
1246
|
+
/**
|
|
1247
|
+
* Programmatically scroll to a specific row and/or column.
|
|
1248
|
+
*
|
|
1249
|
+
* @param rowIndex - The row index to scroll to. Pass null to only scroll horizontally.
|
|
1250
|
+
* @param colIndex - The column index to scroll to. Pass null to only scroll vertically.
|
|
1251
|
+
* @param options - Alignment and behavior options. Defaults to { align: 'auto', behavior: 'auto' }.
|
|
1252
|
+
* @see ScrollAlignment
|
|
1253
|
+
* @see ScrollToIndexOptions
|
|
1254
|
+
* @see useVirtualScroll
|
|
1255
|
+
*/
|
|
403
1256
|
scrollToIndex: (rowIndex: number | null | undefined, colIndex: number | null | undefined, options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions) => void;
|
|
1257
|
+
/**
|
|
1258
|
+
* Programmatically scroll to a specific pixel offset.
|
|
1259
|
+
*
|
|
1260
|
+
* @param x - The pixel offset to scroll to on the X axis. Pass null to keep current position.
|
|
1261
|
+
* @param y - The pixel offset to scroll to on the Y axis. Pass null to keep current position.
|
|
1262
|
+
* @param options - Scroll options (behavior). Defaults to { behavior: 'auto' }.
|
|
1263
|
+
* @see useVirtualScroll
|
|
1264
|
+
*/
|
|
404
1265
|
scrollToOffset: (x?: number | null, y?: number | null, options?: {
|
|
405
1266
|
behavior?: "auto" | "smooth";
|
|
406
1267
|
} | undefined) => void;
|
|
1268
|
+
/**
|
|
1269
|
+
* Resets all dynamic measurements and re-initializes from props.
|
|
1270
|
+
* @see useVirtualScroll
|
|
1271
|
+
*/
|
|
407
1272
|
refresh: () => void;
|
|
1273
|
+
/**
|
|
1274
|
+
* Immediately stops any currently active smooth scroll animation and clears pending corrections.
|
|
1275
|
+
* @see useVirtualScroll
|
|
1276
|
+
*/
|
|
408
1277
|
stopProgrammaticScroll: () => void;
|
|
1278
|
+
/**
|
|
1279
|
+
* Detects the current direction (LTR/RTL) of the scroll container.
|
|
1280
|
+
*/
|
|
1281
|
+
updateDirection: () => void;
|
|
1282
|
+
/**
|
|
1283
|
+
* Whether the scroll container is in Right-to-Left (RTL) mode.
|
|
1284
|
+
*/
|
|
1285
|
+
isRtl: Ref<boolean, boolean>;
|
|
1286
|
+
/**
|
|
1287
|
+
* Whether the component has finished its first client-side mount and hydration.
|
|
1288
|
+
*/
|
|
1289
|
+
isHydrated: Ref<boolean, boolean>;
|
|
1290
|
+
/**
|
|
1291
|
+
* Coordinate scaling factor for X axis.
|
|
1292
|
+
*/
|
|
1293
|
+
scaleX: ComputedRef<number>;
|
|
1294
|
+
/**
|
|
1295
|
+
* Coordinate scaling factor for Y axis.
|
|
1296
|
+
*/
|
|
1297
|
+
scaleY: ComputedRef<number>;
|
|
1298
|
+
/**
|
|
1299
|
+
* Physical width of the content in the DOM (clamped to browser limits).
|
|
1300
|
+
*/
|
|
1301
|
+
renderedWidth: ComputedRef<number>;
|
|
1302
|
+
/**
|
|
1303
|
+
* Physical height of the content in the DOM (clamped to browser limits).
|
|
1304
|
+
*/
|
|
1305
|
+
renderedHeight: ComputedRef<number>;
|
|
1306
|
+
/**
|
|
1307
|
+
* Absolute offset of the component within its container.
|
|
1308
|
+
*/
|
|
1309
|
+
componentOffset: {
|
|
1310
|
+
x: number;
|
|
1311
|
+
y: number;
|
|
1312
|
+
};
|
|
1313
|
+
/**
|
|
1314
|
+
* Properties for the vertical scrollbar.
|
|
1315
|
+
* Useful when building custom scrollbar interfaces.
|
|
1316
|
+
*/
|
|
1317
|
+
scrollbarPropsVertical: ComputedRef<ScrollbarSlotProps | null>;
|
|
1318
|
+
/**
|
|
1319
|
+
* Properties for the horizontal scrollbar.
|
|
1320
|
+
* Useful when building custom scrollbar interfaces.
|
|
1321
|
+
*/
|
|
1322
|
+
scrollbarPropsHorizontal: ComputedRef<ScrollbarSlotProps | null>;
|
|
1323
|
+
items: Ref<T[], T[]>;
|
|
1324
|
+
itemSize: Ref<number | ((item: T, index: number) => number) | null | undefined, number | ((item: T, index: number) => number) | null | undefined>;
|
|
1325
|
+
container: Ref<HTMLElement | Window | null | undefined, HTMLElement | Window | null | undefined>;
|
|
1326
|
+
ssrRange: Ref< {
|
|
1327
|
+
start: number;
|
|
1328
|
+
end: number;
|
|
1329
|
+
colStart?: number;
|
|
1330
|
+
colEnd?: number;
|
|
1331
|
+
} | undefined, {
|
|
1332
|
+
start: number;
|
|
1333
|
+
end: number;
|
|
1334
|
+
colStart?: number;
|
|
1335
|
+
colEnd?: number;
|
|
1336
|
+
} | undefined>;
|
|
1337
|
+
columnWidth: Ref<number | number[] | ((index: number) => number) | null | undefined, number | number[] | ((index: number) => number) | null | undefined>;
|
|
1338
|
+
initialScrollIndex: Ref<number | undefined, number | undefined>;
|
|
1339
|
+
initialScrollAlign: Ref<ScrollAlignment | ScrollAlignmentOptions | undefined, ScrollAlignment | ScrollAlignmentOptions | undefined>;
|
|
1340
|
+
defaultItemSize: Ref<number | undefined, number | undefined>;
|
|
1341
|
+
defaultColumnWidth: Ref<number | undefined, number | undefined>;
|
|
1342
|
+
direction: Ref<ScrollDirection, ScrollDirection>;
|
|
1343
|
+
bufferBefore: Ref<number, number>;
|
|
1344
|
+
bufferAfter: Ref<number, number>;
|
|
1345
|
+
columnCount: Ref<number, number>;
|
|
1346
|
+
containerTag: Ref<string, string>;
|
|
1347
|
+
wrapperTag: Ref<string, string>;
|
|
1348
|
+
itemTag: Ref<string, string>;
|
|
1349
|
+
scrollPaddingStart: Ref<number | {
|
|
1350
|
+
x?: number;
|
|
1351
|
+
y?: number;
|
|
1352
|
+
}, number | {
|
|
1353
|
+
x?: number;
|
|
1354
|
+
y?: number;
|
|
1355
|
+
}>;
|
|
1356
|
+
scrollPaddingEnd: Ref<number | {
|
|
1357
|
+
x?: number;
|
|
1358
|
+
y?: number;
|
|
1359
|
+
}, number | {
|
|
1360
|
+
x?: number;
|
|
1361
|
+
y?: number;
|
|
1362
|
+
}>;
|
|
1363
|
+
stickyHeader: Ref<boolean, boolean>;
|
|
1364
|
+
stickyFooter: Ref<boolean, boolean>;
|
|
1365
|
+
gap: Ref<number, number>;
|
|
1366
|
+
columnGap: Ref<number, number>;
|
|
1367
|
+
stickyIndices: Ref<number[], number[]>;
|
|
1368
|
+
loadDistance: Ref<number, number>;
|
|
1369
|
+
loading: Ref<boolean, boolean>;
|
|
1370
|
+
restoreScrollOnPrepend: Ref<boolean, boolean>;
|
|
1371
|
+
debug: Ref<boolean, boolean>;
|
|
1372
|
+
virtualScrollbar: Ref<boolean, boolean>;
|
|
409
1373
|
}>): void;
|
|
410
1374
|
attrs: any;
|
|
411
1375
|
slots: Readonly<{
|
|
412
|
-
/**
|
|
1376
|
+
/**
|
|
1377
|
+
* Content rendered at the top of the scrollable area.
|
|
1378
|
+
* Can be made sticky using the `stickyHeader` prop.
|
|
1379
|
+
*/
|
|
413
1380
|
header?: (props: Record<string, never>) => VNodeChild;
|
|
414
|
-
/**
|
|
1381
|
+
/**
|
|
1382
|
+
* Scoped slot for rendering each individual item.
|
|
1383
|
+
*/
|
|
415
1384
|
item?: (props: {
|
|
416
|
-
/** The data item
|
|
1385
|
+
/** The original data item from the `items` array. */
|
|
417
1386
|
item: T;
|
|
418
|
-
/** The index of the item in the items array. */
|
|
1387
|
+
/** The original index of the item in the `items` array. */
|
|
419
1388
|
index: number;
|
|
420
|
-
/**
|
|
1389
|
+
/**
|
|
1390
|
+
* Information about the current visible range of columns (for grid mode).
|
|
1391
|
+
* @see ColumnRange
|
|
1392
|
+
*/
|
|
421
1393
|
columnRange: {
|
|
1394
|
+
/** Index of the first rendered column. */
|
|
422
1395
|
start: number;
|
|
1396
|
+
/** Index of the last rendered column (exclusive). */
|
|
423
1397
|
end: number;
|
|
1398
|
+
/** Pixel offset from the start of the row to the first rendered cell. */
|
|
424
1399
|
padStart: number;
|
|
1400
|
+
/** Pixel offset from the last rendered cell to the end of the row. */
|
|
425
1401
|
padEnd: number;
|
|
426
1402
|
};
|
|
427
|
-
/**
|
|
1403
|
+
/**
|
|
1404
|
+
* Helper function to get the width of a specific column.
|
|
1405
|
+
* Useful for setting consistent widths in grid mode.
|
|
1406
|
+
*/
|
|
428
1407
|
getColumnWidth: (index: number) => number;
|
|
429
|
-
/**
|
|
1408
|
+
/** Vertical gap between items. */
|
|
1409
|
+
gap: number;
|
|
1410
|
+
/** Horizontal gap between columns. */
|
|
1411
|
+
columnGap: number;
|
|
1412
|
+
/** Whether this item is configured to be sticky via `stickyIndices`. */
|
|
430
1413
|
isSticky?: boolean | undefined;
|
|
431
|
-
/** Whether this item is currently in a sticky state. */
|
|
1414
|
+
/** Whether this item is currently in a sticky state (stuck at the top/start). */
|
|
432
1415
|
isStickyActive?: boolean | undefined;
|
|
433
1416
|
}) => VNodeChild;
|
|
434
|
-
/**
|
|
1417
|
+
/**
|
|
1418
|
+
* Content shown at the end of the list when the `loading` prop is true.
|
|
1419
|
+
* Also prevents additional 'load' events from triggering while visible.
|
|
1420
|
+
*/
|
|
435
1421
|
loading?: (props: Record<string, never>) => VNodeChild;
|
|
436
|
-
/**
|
|
1422
|
+
/**
|
|
1423
|
+
* Content rendered at the bottom of the scrollable area.
|
|
1424
|
+
* Can be made sticky using the `stickyFooter` prop.
|
|
1425
|
+
*/
|
|
437
1426
|
footer?: (props: Record<string, never>) => VNodeChild;
|
|
1427
|
+
/**
|
|
1428
|
+
* Scoped slot for rendering custom scrollbars.
|
|
1429
|
+
* If provided, the default VirtualScrollbar is not rendered.
|
|
1430
|
+
*/
|
|
1431
|
+
scrollbar?: (props: ScrollbarSlotProps) => VNodeChild;
|
|
438
1432
|
}> & {
|
|
439
|
-
/**
|
|
1433
|
+
/**
|
|
1434
|
+
* Content rendered at the top of the scrollable area.
|
|
1435
|
+
* Can be made sticky using the `stickyHeader` prop.
|
|
1436
|
+
*/
|
|
440
1437
|
header?: (props: Record<string, never>) => VNodeChild;
|
|
441
|
-
/**
|
|
1438
|
+
/**
|
|
1439
|
+
* Scoped slot for rendering each individual item.
|
|
1440
|
+
*/
|
|
442
1441
|
item?: (props: {
|
|
443
|
-
/** The data item
|
|
1442
|
+
/** The original data item from the `items` array. */
|
|
444
1443
|
item: T;
|
|
445
|
-
/** The index of the item in the items array. */
|
|
1444
|
+
/** The original index of the item in the `items` array. */
|
|
446
1445
|
index: number;
|
|
447
|
-
/**
|
|
1446
|
+
/**
|
|
1447
|
+
* Information about the current visible range of columns (for grid mode).
|
|
1448
|
+
* @see ColumnRange
|
|
1449
|
+
*/
|
|
448
1450
|
columnRange: {
|
|
1451
|
+
/** Index of the first rendered column. */
|
|
449
1452
|
start: number;
|
|
1453
|
+
/** Index of the last rendered column (exclusive). */
|
|
450
1454
|
end: number;
|
|
1455
|
+
/** Pixel offset from the start of the row to the first rendered cell. */
|
|
451
1456
|
padStart: number;
|
|
1457
|
+
/** Pixel offset from the last rendered cell to the end of the row. */
|
|
452
1458
|
padEnd: number;
|
|
453
1459
|
};
|
|
454
|
-
/**
|
|
1460
|
+
/**
|
|
1461
|
+
* Helper function to get the width of a specific column.
|
|
1462
|
+
* Useful for setting consistent widths in grid mode.
|
|
1463
|
+
*/
|
|
455
1464
|
getColumnWidth: (index: number) => number;
|
|
456
|
-
/**
|
|
1465
|
+
/** Vertical gap between items. */
|
|
1466
|
+
gap: number;
|
|
1467
|
+
/** Horizontal gap between columns. */
|
|
1468
|
+
columnGap: number;
|
|
1469
|
+
/** Whether this item is configured to be sticky via `stickyIndices`. */
|
|
457
1470
|
isSticky?: boolean | undefined;
|
|
458
|
-
/** Whether this item is currently in a sticky state. */
|
|
1471
|
+
/** Whether this item is currently in a sticky state (stuck at the top/start). */
|
|
459
1472
|
isStickyActive?: boolean | undefined;
|
|
460
1473
|
}) => VNodeChild;
|
|
461
|
-
/**
|
|
1474
|
+
/**
|
|
1475
|
+
* Content shown at the end of the list when the `loading` prop is true.
|
|
1476
|
+
* Also prevents additional 'load' events from triggering while visible.
|
|
1477
|
+
*/
|
|
462
1478
|
loading?: (props: Record<string, never>) => VNodeChild;
|
|
463
|
-
/**
|
|
1479
|
+
/**
|
|
1480
|
+
* Content rendered at the bottom of the scrollable area.
|
|
1481
|
+
* Can be made sticky using the `stickyFooter` prop.
|
|
1482
|
+
*/
|
|
464
1483
|
footer?: (props: Record<string, never>) => VNodeChild;
|
|
1484
|
+
/**
|
|
1485
|
+
* Scoped slot for rendering custom scrollbars.
|
|
1486
|
+
* If provided, the default VirtualScrollbar is not rendered.
|
|
1487
|
+
*/
|
|
1488
|
+
scrollbar?: (props: ScrollbarSlotProps) => VNodeChild;
|
|
465
1489
|
};
|
|
466
1490
|
emit: {
|
|
467
1491
|
(e: "scroll", details: ScrollDetails<T>): void;
|
|
@@ -477,65 +1501,346 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
477
1501
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
478
1502
|
};
|
|
479
1503
|
|
|
480
|
-
|
|
481
|
-
|
|
1504
|
+
export declare const VirtualScrollbar: DefineComponent<Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
|
|
1505
|
+
scrollToOffset: (offset: number) => any;
|
|
1506
|
+
}, string, PublicProps, Readonly<Props_2> & Readonly<{
|
|
1507
|
+
onScrollToOffset?: (offset: number) => any;
|
|
1508
|
+
}>, {
|
|
1509
|
+
isRtl: boolean;
|
|
1510
|
+
axis: ScrollAxis;
|
|
1511
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
1512
|
+
|
|
1513
|
+
/** Properties for the `VirtualScrollbar` component. */
|
|
1514
|
+
export declare interface VirtualScrollbarProps {
|
|
1515
|
+
/**
|
|
1516
|
+
* The axis for this scrollbar.
|
|
1517
|
+
* - 'vertical': Vertical scrollbar.
|
|
1518
|
+
* - 'horizontal': Horizontal scrollbar.
|
|
1519
|
+
* @default 'vertical'
|
|
1520
|
+
*/
|
|
1521
|
+
axis?: ScrollAxis;
|
|
1522
|
+
/**
|
|
1523
|
+
* Total size of the scrollable content in pixels.
|
|
1524
|
+
*/
|
|
1525
|
+
totalSize: number;
|
|
1526
|
+
/**
|
|
1527
|
+
* Current scroll position in pixels.
|
|
1528
|
+
*/
|
|
1529
|
+
position: number;
|
|
1530
|
+
/**
|
|
1531
|
+
* Viewport size in pixels.
|
|
1532
|
+
*/
|
|
1533
|
+
viewportSize: number;
|
|
1534
|
+
/**
|
|
1535
|
+
* Function to scroll to a specific pixel offset on this axis.
|
|
1536
|
+
* @param offset - The pixel offset to scroll to.
|
|
1537
|
+
*/
|
|
1538
|
+
scrollToOffset?: (offset: number) => void;
|
|
1539
|
+
/**
|
|
1540
|
+
* The ID of the container element this scrollbar controls.
|
|
1541
|
+
*/
|
|
1542
|
+
containerId?: string;
|
|
1543
|
+
/**
|
|
1544
|
+
* Whether the scrollbar is in Right-to-Left (RTL) mode.
|
|
1545
|
+
* @default false
|
|
1546
|
+
*/
|
|
1547
|
+
isRtl?: boolean;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
/** Configuration properties for the `VirtualScroll` component. */
|
|
1551
|
+
export declare interface VirtualScrollComponentProps<T = unknown> {
|
|
482
1552
|
/** Array of items to be virtualized. */
|
|
483
1553
|
items: T[];
|
|
484
|
-
/** Fixed size of each item or a function that returns the size of an item. */
|
|
1554
|
+
/** Fixed size of each item (in pixels) or a function that returns the size of an item. */
|
|
1555
|
+
itemSize?: number | ((item: T, index: number) => number) | null;
|
|
1556
|
+
/** Direction of the scroll. */
|
|
1557
|
+
direction?: ScrollDirection;
|
|
1558
|
+
/** Number of items to render before the visible viewport. */
|
|
1559
|
+
bufferBefore?: number;
|
|
1560
|
+
/** Number of items to render after the visible viewport. */
|
|
1561
|
+
bufferAfter?: number;
|
|
1562
|
+
/** The scrollable container element or window. */
|
|
1563
|
+
container?: HTMLElement | Window | null;
|
|
1564
|
+
/** Range of items to render during Server-Side Rendering. */
|
|
1565
|
+
ssrRange?: {
|
|
1566
|
+
/** First row index to render. */
|
|
1567
|
+
start: number;
|
|
1568
|
+
/** Last row index to render (exclusive). */
|
|
1569
|
+
end: number;
|
|
1570
|
+
/** First column index to render (for grid mode). */
|
|
1571
|
+
colStart?: number;
|
|
1572
|
+
/** Last column index to render (exclusive, for grid mode). */
|
|
1573
|
+
colEnd?: number;
|
|
1574
|
+
};
|
|
1575
|
+
/** Number of columns for bidirectional (grid) scroll. */
|
|
1576
|
+
columnCount?: number;
|
|
1577
|
+
/** Fixed width of columns (in pixels), an array of widths, or a function for column widths. */
|
|
1578
|
+
columnWidth?: number | number[] | ((index: number) => number) | null;
|
|
1579
|
+
/** The HTML tag to use for the root container. */
|
|
1580
|
+
containerTag?: string;
|
|
1581
|
+
/** The HTML tag to use for the items wrapper. */
|
|
1582
|
+
wrapperTag?: string;
|
|
1583
|
+
/** The HTML tag to use for each item. */
|
|
1584
|
+
itemTag?: string;
|
|
1585
|
+
/** Additional padding at the start of the scroll container (top or left). */
|
|
1586
|
+
scrollPaddingStart?: number | {
|
|
1587
|
+
x?: number;
|
|
1588
|
+
y?: number;
|
|
1589
|
+
};
|
|
1590
|
+
/** Additional padding at the end of the scroll container (bottom or right). */
|
|
1591
|
+
scrollPaddingEnd?: number | {
|
|
1592
|
+
x?: number;
|
|
1593
|
+
y?: number;
|
|
1594
|
+
};
|
|
1595
|
+
/** Whether the content in the 'header' slot is sticky. */
|
|
1596
|
+
stickyHeader?: boolean;
|
|
1597
|
+
/** Whether the content in the 'footer' slot is sticky. */
|
|
1598
|
+
stickyFooter?: boolean;
|
|
1599
|
+
/** Gap between items in pixels. */
|
|
1600
|
+
gap?: number;
|
|
1601
|
+
/** Gap between columns in pixels. */
|
|
1602
|
+
columnGap?: number;
|
|
1603
|
+
/** Indices of items that should stick to the top/start of the viewport. */
|
|
1604
|
+
stickyIndices?: number[];
|
|
1605
|
+
/** Distance from the end of the scrollable area (in pixels) to trigger the 'load' event. */
|
|
1606
|
+
loadDistance?: number;
|
|
1607
|
+
/** Whether items are currently being loaded. */
|
|
1608
|
+
loading?: boolean;
|
|
1609
|
+
/** Whether to automatically restore and maintain scroll position when items are prepended to the list. */
|
|
1610
|
+
restoreScrollOnPrepend?: boolean;
|
|
1611
|
+
/** Initial scroll index to jump to immediately after mount. */
|
|
1612
|
+
initialScrollIndex?: number;
|
|
1613
|
+
/** Alignment for the initial scroll index. */
|
|
1614
|
+
initialScrollAlign?: ScrollAlignment | ScrollAlignmentOptions;
|
|
1615
|
+
/** Default size for items before they are measured by ResizeObserver. */
|
|
1616
|
+
defaultItemSize?: number;
|
|
1617
|
+
/** Default width for columns before they are measured by ResizeObserver. */
|
|
1618
|
+
defaultColumnWidth?: number;
|
|
1619
|
+
/** Whether to show debug information (visible offsets and indices) over items. */
|
|
1620
|
+
debug?: boolean;
|
|
1621
|
+
/** Whether to use virtual scrollbars for styling purposes. */
|
|
1622
|
+
virtualScrollbar?: boolean;
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
/** Exposed methods and properties of the `VirtualScroll` component instance. */
|
|
1626
|
+
export declare interface VirtualScrollInstance<T = unknown> extends VirtualScrollComponentProps<T> {
|
|
1627
|
+
/** Detailed information about the current scroll state. */
|
|
1628
|
+
scrollDetails: ScrollDetails<T>;
|
|
1629
|
+
/** Information about the current visible range of columns. */
|
|
1630
|
+
columnRange: ScrollDetails<T>['columnRange'];
|
|
1631
|
+
/** Helper to get the width of a specific column. */
|
|
1632
|
+
getColumnWidth: (index: number) => number;
|
|
1633
|
+
/** Helper to get the height of a specific row. */
|
|
1634
|
+
getRowHeight: (index: number) => number;
|
|
1635
|
+
/** Helper to get the virtual offset of a specific row. */
|
|
1636
|
+
getRowOffset: (index: number) => number;
|
|
1637
|
+
/** Helper to get the virtual offset of a specific column. */
|
|
1638
|
+
getColumnOffset: (index: number) => number;
|
|
1639
|
+
/** Helper to get the virtual offset of a specific item. */
|
|
1640
|
+
getItemOffset: (index: number) => number;
|
|
1641
|
+
/** Helper to get the size of a specific item along the scroll axis. */
|
|
1642
|
+
getItemSize: (index: number) => number;
|
|
1643
|
+
/** Programmatically scroll to a specific row and/or column. */
|
|
1644
|
+
scrollToIndex: (rowIndex: number | null | undefined, colIndex: number | null | undefined, options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions) => void;
|
|
1645
|
+
/** Programmatically scroll to a specific pixel offset. */
|
|
1646
|
+
scrollToOffset: (x?: number | null, y?: number | null, options?: {
|
|
1647
|
+
behavior?: 'auto' | 'smooth';
|
|
1648
|
+
}) => void;
|
|
1649
|
+
/** Resets all dynamic measurements and re-initializes from props. */
|
|
1650
|
+
refresh: () => void;
|
|
1651
|
+
/** Immediately stops any currently active smooth scroll animation and clears pending corrections. */
|
|
1652
|
+
stopProgrammaticScroll: () => void;
|
|
1653
|
+
/** Detects the current direction (LTR/RTL) of the scroll container. */
|
|
1654
|
+
updateDirection: () => void;
|
|
1655
|
+
/** Whether the scroll container is in Right-to-Left (RTL) mode. */
|
|
1656
|
+
isRtl: boolean;
|
|
1657
|
+
/** Whether the component has finished its first client - side mount and hydration. */
|
|
1658
|
+
isHydrated: boolean;
|
|
1659
|
+
/** Coordinate scaling factor for X axis. */
|
|
1660
|
+
scaleX: number;
|
|
1661
|
+
/** Coordinate scaling factor for Y axis. */
|
|
1662
|
+
scaleY: number;
|
|
1663
|
+
/** Physical width of the content in the DOM (clamped to browser limits). */
|
|
1664
|
+
renderedWidth: number;
|
|
1665
|
+
/** Physical height of the content in the DOM (clamped to browser limits). */
|
|
1666
|
+
renderedHeight: number;
|
|
1667
|
+
/** Absolute offset of the component within its container. */
|
|
1668
|
+
componentOffset: {
|
|
1669
|
+
x: number;
|
|
1670
|
+
y: number;
|
|
1671
|
+
};
|
|
1672
|
+
/** Properties for the vertical scrollbar. */
|
|
1673
|
+
scrollbarPropsVertical: ScrollbarSlotProps | null;
|
|
1674
|
+
/** Properties for the horizontal scrollbar. */
|
|
1675
|
+
scrollbarPropsHorizontal: ScrollbarSlotProps | null;
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
/** Configuration properties for the `useVirtualScroll` composable. */
|
|
1679
|
+
export declare interface VirtualScrollProps<T = unknown> {
|
|
1680
|
+
/**
|
|
1681
|
+
* Array of data items to virtualize.
|
|
1682
|
+
*/
|
|
1683
|
+
items: T[];
|
|
1684
|
+
/**
|
|
1685
|
+
* Fixed size of each item in virtual units (VU) or a function that returns the size of an item.
|
|
1686
|
+
* Pass `0`, `null` or `undefined` for automatic dynamic size detection via `ResizeObserver`.
|
|
1687
|
+
*/
|
|
485
1688
|
itemSize?: number | ((item: T, index: number) => number) | undefined;
|
|
486
|
-
/**
|
|
1689
|
+
/**
|
|
1690
|
+
* Direction of the virtual scroll.
|
|
1691
|
+
* @default 'vertical'
|
|
1692
|
+
*/
|
|
487
1693
|
direction?: ScrollDirection | undefined;
|
|
488
|
-
/**
|
|
1694
|
+
/**
|
|
1695
|
+
* Number of items to render before the visible viewport.
|
|
1696
|
+
* @default 5
|
|
1697
|
+
*/
|
|
489
1698
|
bufferBefore?: number | undefined;
|
|
490
|
-
/**
|
|
1699
|
+
/**
|
|
1700
|
+
* Number of items to render after the visible viewport.
|
|
1701
|
+
* @default 5
|
|
1702
|
+
*/
|
|
491
1703
|
bufferAfter?: number | undefined;
|
|
492
|
-
/**
|
|
1704
|
+
/**
|
|
1705
|
+
* The scrollable element or window object.
|
|
1706
|
+
* If not provided, virtualization usually happens relative to the `hostRef`.
|
|
1707
|
+
*/
|
|
493
1708
|
container?: HTMLElement | Window | null | undefined;
|
|
494
|
-
/**
|
|
1709
|
+
/**
|
|
1710
|
+
* The host element that directly wraps the absolute-positioned items.
|
|
1711
|
+
* Used for calculating relative offsets in display pixels (DU).
|
|
1712
|
+
*/
|
|
495
1713
|
hostElement?: HTMLElement | null | undefined;
|
|
496
|
-
/**
|
|
1714
|
+
/**
|
|
1715
|
+
* The root element of the VirtualScroll component.
|
|
1716
|
+
* Used for calculating relative offsets in display pixels (DU).
|
|
1717
|
+
*/
|
|
1718
|
+
hostRef?: HTMLElement | null | undefined;
|
|
1719
|
+
/**
|
|
1720
|
+
* Configuration for Server-Side Rendering.
|
|
1721
|
+
* Defines which items are rendered statically on the server.
|
|
1722
|
+
*/
|
|
497
1723
|
ssrRange?: {
|
|
1724
|
+
/** First row index. */
|
|
498
1725
|
start: number;
|
|
1726
|
+
/** Exclusive last row index. */
|
|
499
1727
|
end: number;
|
|
1728
|
+
/** First column index (grid mode). */
|
|
500
1729
|
colStart?: number;
|
|
1730
|
+
/** Exclusive last column index (grid mode). */
|
|
501
1731
|
colEnd?: number;
|
|
502
1732
|
} | undefined;
|
|
503
|
-
/**
|
|
1733
|
+
/**
|
|
1734
|
+
* Number of columns for bidirectional grid scrolling.
|
|
1735
|
+
*/
|
|
504
1736
|
columnCount?: number | undefined;
|
|
505
|
-
/**
|
|
1737
|
+
/**
|
|
1738
|
+
* Fixed width of columns in VU, an array of widths, or a function returning widths.
|
|
1739
|
+
* Pass `0`, `null` or `undefined` for dynamic column detection.
|
|
1740
|
+
*/
|
|
506
1741
|
columnWidth?: number | number[] | ((index: number) => number) | undefined;
|
|
507
|
-
/**
|
|
1742
|
+
/**
|
|
1743
|
+
* Pixel padding at the start of the scroll container in display pixels (DU).
|
|
1744
|
+
*/
|
|
508
1745
|
scrollPaddingStart?: number | {
|
|
509
1746
|
x?: number;
|
|
510
1747
|
y?: number;
|
|
511
1748
|
} | undefined;
|
|
512
|
-
/**
|
|
1749
|
+
/**
|
|
1750
|
+
* Pixel padding at the end of the scroll container in DU.
|
|
1751
|
+
*/
|
|
513
1752
|
scrollPaddingEnd?: number | {
|
|
514
1753
|
x?: number;
|
|
515
1754
|
y?: number;
|
|
516
1755
|
} | undefined;
|
|
517
|
-
/**
|
|
1756
|
+
/**
|
|
1757
|
+
* Size of sticky elements at the start of the viewport (top or left) in DU.
|
|
1758
|
+
* Used to adjust the visible range and item positioning without increasing content size.
|
|
1759
|
+
*/
|
|
1760
|
+
stickyStart?: number | {
|
|
1761
|
+
x?: number;
|
|
1762
|
+
y?: number;
|
|
1763
|
+
} | undefined;
|
|
1764
|
+
/**
|
|
1765
|
+
* Size of sticky elements at the end of the viewport (bottom or right) in DU.
|
|
1766
|
+
* Used to adjust the visible range without increasing content size.
|
|
1767
|
+
*/
|
|
1768
|
+
stickyEnd?: number | {
|
|
1769
|
+
x?: number;
|
|
1770
|
+
y?: number;
|
|
1771
|
+
} | undefined;
|
|
1772
|
+
/**
|
|
1773
|
+
* Gap between items in virtual units (VU).
|
|
1774
|
+
* Applied vertically in list/grid mode, horizontally in horizontal list mode.
|
|
1775
|
+
*/
|
|
518
1776
|
gap?: number | undefined;
|
|
519
|
-
/**
|
|
1777
|
+
/**
|
|
1778
|
+
* Gap between columns in VU.
|
|
1779
|
+
* Applied in horizontal and bidirectional grid modes.
|
|
1780
|
+
*/
|
|
520
1781
|
columnGap?: number | undefined;
|
|
521
|
-
/**
|
|
1782
|
+
/**
|
|
1783
|
+
* List of indices that should stick to the viewport edge.
|
|
1784
|
+
*/
|
|
522
1785
|
stickyIndices?: number[] | undefined;
|
|
523
|
-
/**
|
|
1786
|
+
/**
|
|
1787
|
+
* Extra padding (display pixels - DU) at the start of the flow (e.g. non-sticky header).
|
|
1788
|
+
*/
|
|
1789
|
+
flowPaddingStart?: number | {
|
|
1790
|
+
x?: number;
|
|
1791
|
+
y?: number;
|
|
1792
|
+
} | undefined;
|
|
1793
|
+
/**
|
|
1794
|
+
* Extra padding (DU) at the end of the flow (e.g. non-sticky footer).
|
|
1795
|
+
*/
|
|
1796
|
+
flowPaddingEnd?: number | {
|
|
1797
|
+
x?: number;
|
|
1798
|
+
y?: number;
|
|
1799
|
+
} | undefined;
|
|
1800
|
+
/**
|
|
1801
|
+
* Threshold distance from the end in display pixels (DU) to emit the 'load' event.
|
|
1802
|
+
* @default 200
|
|
1803
|
+
*/
|
|
524
1804
|
loadDistance?: number | undefined;
|
|
525
|
-
/**
|
|
1805
|
+
/**
|
|
1806
|
+
* Whether data is currently loading.
|
|
1807
|
+
*/
|
|
526
1808
|
loading?: boolean | undefined;
|
|
527
|
-
/**
|
|
1809
|
+
/**
|
|
1810
|
+
* Whether to automatically restore and maintain scroll position when items are prepended to the array.
|
|
1811
|
+
*/
|
|
528
1812
|
restoreScrollOnPrepend?: boolean | undefined;
|
|
529
|
-
/**
|
|
1813
|
+
/**
|
|
1814
|
+
* Initial row index to jump to on mount.
|
|
1815
|
+
*/
|
|
530
1816
|
initialScrollIndex?: number | undefined;
|
|
531
|
-
/**
|
|
1817
|
+
/**
|
|
1818
|
+
* Initial scroll alignment logic.
|
|
1819
|
+
* @default 'start'
|
|
1820
|
+
*/
|
|
532
1821
|
initialScrollAlign?: ScrollAlignment | ScrollAlignmentOptions | undefined;
|
|
533
|
-
/**
|
|
1822
|
+
/**
|
|
1823
|
+
* Default fallback size for items before they are measured in VU.
|
|
1824
|
+
*/
|
|
534
1825
|
defaultItemSize?: number | undefined;
|
|
535
|
-
/**
|
|
1826
|
+
/**
|
|
1827
|
+
* Default fallback width for columns before they are measured in VU.
|
|
1828
|
+
*/
|
|
536
1829
|
defaultColumnWidth?: number | undefined;
|
|
537
|
-
/**
|
|
1830
|
+
/**
|
|
1831
|
+
* Enable debug visualization of buffers and indices.
|
|
1832
|
+
*/
|
|
538
1833
|
debug?: boolean | undefined;
|
|
539
1834
|
}
|
|
540
1835
|
|
|
1836
|
+
/**
|
|
1837
|
+
* Maps a virtual content position to a display scroll position.
|
|
1838
|
+
*
|
|
1839
|
+
* @param virtualPos - Virtual content position (VU).
|
|
1840
|
+
* @param hostOffset - Offset of the host element in display pixels (DU).
|
|
1841
|
+
* @param scale - Coordinate scaling factor (VU/DU).
|
|
1842
|
+
* @returns Display pixel position (DU).
|
|
1843
|
+
*/
|
|
1844
|
+
export declare function virtualToDisplay(virtualPos: number, hostOffset: number, scale: number): number;
|
|
1845
|
+
|
|
541
1846
|
export { }
|