@pdanpdan/virtual-scroll 0.9.0 → 0.10.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 +90 -12
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +174 -154
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +863 -742
- package/dist/index.mjs.map +1 -1
- package/dist/virtual-scroll.css +1 -1
- package/package.json +1 -1
- package/src/components/VirtualScroll.vue +30 -20
- package/src/composables/useVirtualScroll.ts +374 -800
- package/src/composables/useVirtualScrollSizes.ts +144 -142
- package/src/composables/useVirtualScrollbar.ts +16 -0
- package/src/extensions/all.ts +7 -0
- package/src/extensions/coordinate-scaling.ts +30 -0
- package/src/extensions/index.ts +88 -0
- package/src/extensions/infinite-loading.ts +47 -0
- package/src/extensions/prepend-restoration.ts +49 -0
- package/src/extensions/rtl.ts +42 -0
- package/src/extensions/snapping.ts +82 -0
- package/src/extensions/sticky.ts +43 -0
- package/src/types.ts +27 -7
- package/src/utils/scroll.ts +1 -1
- package/src/utils/virtual-scroll-logic.ts +44 -2
package/dist/index.d.ts
CHANGED
|
@@ -322,10 +322,13 @@ export declare function calculateSSROffsets(direction: ScrollDirection, ssrRange
|
|
|
322
322
|
* @param params.columnGap - Column gap (VU).
|
|
323
323
|
* @param params.getItemQueryY - Resolver for vertical offset (VU).
|
|
324
324
|
* @param params.getItemQueryX - Resolver for horizontal offset (VU).
|
|
325
|
+
* @param params.nextStickyIndex - Optional pre-calculated next sticky index.
|
|
325
326
|
* @returns Sticky state and offset (VU).
|
|
326
327
|
* @see StickyParams
|
|
327
328
|
*/
|
|
328
|
-
export declare function calculateStickyItem({ index, isSticky, direction, relativeScrollX, relativeScrollY, originalX, originalY, width, height, stickyIndices, fixedSize, gap, columnGap, getItemQueryY, getItemQueryX, }: StickyParams
|
|
329
|
+
export declare function calculateStickyItem({ index, isSticky, direction, relativeScrollX, relativeScrollY, originalX, originalY, width, height, stickyIndices, fixedSize, gap, columnGap, getItemQueryY, getItemQueryX, nextStickyIndex, }: StickyParams & {
|
|
330
|
+
nextStickyIndex?: number | undefined;
|
|
331
|
+
}): {
|
|
329
332
|
isStickyActiveX: boolean;
|
|
330
333
|
isStickyActiveY: boolean;
|
|
331
334
|
isStickyActive: boolean;
|
|
@@ -415,6 +418,81 @@ export declare function displayToVirtual(displayPos: number, hostOffset: number,
|
|
|
415
418
|
/** Initial empty state for scroll details. */
|
|
416
419
|
export declare const EMPTY_SCROLL_DETAILS: ScrollDetails<unknown>;
|
|
417
420
|
|
|
421
|
+
/**
|
|
422
|
+
* Hook context provided to extensions.
|
|
423
|
+
*/
|
|
424
|
+
declare interface ExtensionContext<T = unknown> {
|
|
425
|
+
/** Reactive reference to the component props. */
|
|
426
|
+
props: Ref<VirtualScrollProps<T>>;
|
|
427
|
+
/** Reactive reference to the current scroll details. */
|
|
428
|
+
scrollDetails: Ref<ScrollDetails<T>>;
|
|
429
|
+
/** Total calculated or estimated size of the scrollable area (DU). */
|
|
430
|
+
totalSize: Ref<Size>;
|
|
431
|
+
/** Reactive reference to the current rendered item range. */
|
|
432
|
+
range: Ref<{
|
|
433
|
+
start: number;
|
|
434
|
+
end: number;
|
|
435
|
+
}>;
|
|
436
|
+
/** Reactive reference to the first visible item index. */
|
|
437
|
+
currentIndex: Ref<number>;
|
|
438
|
+
/** Reactive references to internal component state variables. */
|
|
439
|
+
internalState: {
|
|
440
|
+
/** Horizontal display scroll position (DU). */
|
|
441
|
+
scrollX: Ref<number>;
|
|
442
|
+
/** Vertical display scroll position (DU). */
|
|
443
|
+
scrollY: Ref<number>;
|
|
444
|
+
/** Horizontal virtual scroll position (VU). */
|
|
445
|
+
internalScrollX: Ref<number>;
|
|
446
|
+
/** Vertical virtual scroll position (VU). */
|
|
447
|
+
internalScrollY: Ref<number>;
|
|
448
|
+
/** Right-to-Left text direction state. */
|
|
449
|
+
isRtl: Ref<boolean>;
|
|
450
|
+
/** Scrolling activity state. */
|
|
451
|
+
isScrolling: Ref<boolean>;
|
|
452
|
+
/** Programmatic scroll activity state. */
|
|
453
|
+
isProgrammaticScroll: Ref<boolean>;
|
|
454
|
+
/** Viewport width (DU). */
|
|
455
|
+
viewportWidth: Ref<number>;
|
|
456
|
+
/** Viewport height (DU). */
|
|
457
|
+
viewportHeight: Ref<number>;
|
|
458
|
+
/** Coordinate scale factor for X axis. */
|
|
459
|
+
scaleX: Ref<number>;
|
|
460
|
+
/** Coordinate scale factor for Y axis. */
|
|
461
|
+
scaleY: Ref<number>;
|
|
462
|
+
/** Horizontal scroll direction. */
|
|
463
|
+
scrollDirectionX: Ref<'start' | 'end' | null>;
|
|
464
|
+
/** Vertical scroll direction. */
|
|
465
|
+
scrollDirectionY: Ref<'start' | 'end' | null>;
|
|
466
|
+
/** Relative horizontal virtual scroll position (VU). */
|
|
467
|
+
relativeScrollX: Ref<number>;
|
|
468
|
+
/** Relative vertical virtual scroll position (VU). */
|
|
469
|
+
relativeScrollY: Ref<number>;
|
|
470
|
+
};
|
|
471
|
+
/** Direct access to core component methods. */
|
|
472
|
+
methods: {
|
|
473
|
+
/** Scroll to a specific row and/or column. */
|
|
474
|
+
scrollToIndex: (rowIndex?: number | null, colIndex?: number | null, options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions) => void;
|
|
475
|
+
/** Scroll to a specific virtual pixel offset. */
|
|
476
|
+
scrollToOffset: (x?: number | null, y?: number | null, options?: {
|
|
477
|
+
behavior?: 'auto' | 'smooth';
|
|
478
|
+
}) => void;
|
|
479
|
+
/** Detect and update text direction. */
|
|
480
|
+
updateDirection: () => void;
|
|
481
|
+
/** Get row index at virtual offset. */
|
|
482
|
+
getRowIndexAt: (offset: number) => number;
|
|
483
|
+
/** Get column index at virtual offset. */
|
|
484
|
+
getColIndexAt: (offset: number) => number;
|
|
485
|
+
/** Get actual size of item (measured or estimated). */
|
|
486
|
+
getItemSize: (index: number) => number;
|
|
487
|
+
/** Get base configuration size of item. */
|
|
488
|
+
getItemBaseSize: (item: T, index: number) => number;
|
|
489
|
+
/** Get virtual offset of item. */
|
|
490
|
+
getItemOffset: (index: number) => number;
|
|
491
|
+
/** Adjust scroll position for measurement changes. */
|
|
492
|
+
handleScrollCorrection: (addedX: number, addedY: number) => void;
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
|
|
418
496
|
/**
|
|
419
497
|
* Fenwick Tree (Binary Indexed Tree) implementation for efficient
|
|
420
498
|
* prefix sum calculations and updates.
|
|
@@ -666,7 +744,7 @@ export declare interface ItemStyleParams<T = unknown> {
|
|
|
666
744
|
/** Scroll direction. */
|
|
667
745
|
direction: ScrollDirection;
|
|
668
746
|
/** Configured item size logic. */
|
|
669
|
-
itemSize: number | ((item: T, index: number) => number) | null | undefined;
|
|
747
|
+
itemSize: number | (number | null | undefined)[] | ((item: T, index: number) => number) | null | undefined;
|
|
670
748
|
/** Parent container tag. */
|
|
671
749
|
containerTag: string;
|
|
672
750
|
/** Padding start on X axis. */
|
|
@@ -713,6 +791,8 @@ export declare interface RangeParams {
|
|
|
713
791
|
usableHeight: number;
|
|
714
792
|
/** Total item count. */
|
|
715
793
|
itemsLength: number;
|
|
794
|
+
/** Column count (for grid mode). */
|
|
795
|
+
columnCount?: number;
|
|
716
796
|
/** Buffer items before. */
|
|
717
797
|
bufferBefore: number;
|
|
718
798
|
/** Buffer items after. */
|
|
@@ -1004,9 +1084,10 @@ export declare interface Size {
|
|
|
1004
1084
|
* - 'start': Aligns the first visible item to the viewport start if at least 50% visible, otherwise aligns the next item.
|
|
1005
1085
|
* - 'center': Aligns the item that intersects the viewport center to the center.
|
|
1006
1086
|
* - 'end': Aligns the last visible item to the viewport end if at least 50% visible, otherwise aligns the previous item.
|
|
1087
|
+
* - 'next': Snaps to the next (closest) snap position in the direction of the scroll.
|
|
1007
1088
|
* - 'auto': Intelligent snapping based on scroll direction. Acts as 'end' when scrolling towards start, and 'start' when scrolling towards end.
|
|
1008
1089
|
*/
|
|
1009
|
-
export declare type SnapMode = boolean | 'start' | 'center' | 'end' | 'auto';
|
|
1090
|
+
export declare type SnapMode = boolean | 'start' | 'center' | 'end' | 'next' | 'auto';
|
|
1010
1091
|
|
|
1011
1092
|
/** Snap result. */
|
|
1012
1093
|
export declare interface SnapResult {
|
|
@@ -1100,189 +1181,88 @@ export declare interface TotalSizeParams {
|
|
|
1100
1181
|
* Handles calculation of visible items, scroll events, dynamic item sizes, and programmatic scrolling.
|
|
1101
1182
|
*
|
|
1102
1183
|
* @param propsInput - The configuration properties. Can be a plain object, a Ref, or a getter function.
|
|
1184
|
+
* @param extensions - Optional list of extensions to enhance functionality (RTL, Snapping, Sticky, etc.).
|
|
1103
1185
|
* @see VirtualScrollProps
|
|
1104
1186
|
*/
|
|
1105
|
-
export declare function useVirtualScroll<T = unknown>(propsInput:
|
|
1106
|
-
/**
|
|
1107
|
-
* Array of items currently rendered in the DOM with their calculated offsets and sizes.
|
|
1108
|
-
* Offsets are in Display Units (DU), sizes are in Virtual Units (VU).
|
|
1109
|
-
* @see RenderedItem
|
|
1110
|
-
*/
|
|
1187
|
+
export declare function useVirtualScroll<T = unknown>(propsInput: Ref<VirtualScrollProps<T>> | (() => VirtualScrollProps<T>), extensions?: VirtualScrollExtension<T>[]): {
|
|
1188
|
+
/** Reactive list of items to render in the current viewport. */
|
|
1111
1189
|
renderedItems: ComputedRef<RenderedItem<T>[]>;
|
|
1112
|
-
/**
|
|
1113
|
-
* Total calculated width of all items including gaps (in VU).
|
|
1114
|
-
*/
|
|
1190
|
+
/** Total calculated width of the scrollable content area (DU). */
|
|
1115
1191
|
totalWidth: ComputedRef<number>;
|
|
1116
|
-
/**
|
|
1117
|
-
* Total calculated height of all items including gaps (in VU).
|
|
1118
|
-
*/
|
|
1192
|
+
/** Total calculated height of the scrollable content area (DU). */
|
|
1119
1193
|
totalHeight: ComputedRef<number>;
|
|
1120
|
-
/**
|
|
1121
|
-
* Total width to be rendered in the DOM (clamped to browser limits, in DU).
|
|
1122
|
-
*/
|
|
1194
|
+
/** Physical width of the content in the DOM (clamped to browser limits). */
|
|
1123
1195
|
renderedWidth: ComputedRef<number>;
|
|
1124
|
-
/**
|
|
1125
|
-
* Total height to be rendered in the DOM (clamped to browser limits, in DU).
|
|
1126
|
-
*/
|
|
1196
|
+
/** Physical height of the content in the DOM (clamped to browser limits). */
|
|
1127
1197
|
renderedHeight: ComputedRef<number>;
|
|
1128
|
-
/**
|
|
1129
|
-
* Detailed information about the current scroll state.
|
|
1130
|
-
* Includes currentIndex, scrollOffset (VU), displayScrollOffset (DU), viewportSize (DU), totalSize (VU), and scrolling status.
|
|
1131
|
-
* @see ScrollDetails
|
|
1132
|
-
*/
|
|
1198
|
+
/** Detailed information about the current scroll state. */
|
|
1133
1199
|
scrollDetails: ComputedRef<ScrollDetails<T>>;
|
|
1134
|
-
/**
|
|
1135
|
-
* Helper to get the height of a specific row based on current configuration and measurements.
|
|
1136
|
-
*
|
|
1137
|
-
* @param index - The row index.
|
|
1138
|
-
* @returns The height in VU (excluding gap).
|
|
1139
|
-
*/
|
|
1200
|
+
/** Helper to get the height of a specific row. */
|
|
1140
1201
|
getRowHeight: (index: number) => number;
|
|
1141
|
-
/**
|
|
1142
|
-
* Helper to get the width of a specific column based on current configuration and measurements.
|
|
1143
|
-
*
|
|
1144
|
-
* @param index - The column index.
|
|
1145
|
-
* @returns The width in VU (excluding gap).
|
|
1146
|
-
*/
|
|
1202
|
+
/** Helper to get the width of a specific column. */
|
|
1147
1203
|
getColumnWidth: (index: number) => number;
|
|
1148
|
-
/**
|
|
1149
|
-
* Helper to get the virtual offset of a specific row.
|
|
1150
|
-
*
|
|
1151
|
-
* @param index - The row index.
|
|
1152
|
-
* @returns The virtual offset in VU.
|
|
1153
|
-
*/
|
|
1204
|
+
/** Helper to get the virtual offset of a specific row. */
|
|
1154
1205
|
getRowOffset: (index: number) => number;
|
|
1155
|
-
/**
|
|
1156
|
-
* Helper to get the virtual offset of a specific column.
|
|
1157
|
-
*
|
|
1158
|
-
* @param index - The column index.
|
|
1159
|
-
* @returns The virtual offset in VU.
|
|
1160
|
-
*/
|
|
1206
|
+
/** Helper to get the virtual offset of a specific column. */
|
|
1161
1207
|
getColumnOffset: (index: number) => number;
|
|
1162
|
-
/**
|
|
1163
|
-
* Helper to get the virtual offset of a specific item along the scroll axis.
|
|
1164
|
-
*
|
|
1165
|
-
* @param index - The item index.
|
|
1166
|
-
* @returns The virtual offset in VU.
|
|
1167
|
-
*/
|
|
1208
|
+
/** Helper to get the virtual offset of a specific item. */
|
|
1168
1209
|
getItemOffset: (index: number) => number;
|
|
1169
|
-
/**
|
|
1170
|
-
* Helper to get the size of a specific item along the scroll axis.
|
|
1171
|
-
*
|
|
1172
|
-
* @param index - The item index.
|
|
1173
|
-
* @returns The size in VU (excluding gap).
|
|
1174
|
-
*/
|
|
1210
|
+
/** Helper to get the size of a specific item along the scroll axis. */
|
|
1175
1211
|
getItemSize: (index: number) => number;
|
|
1176
|
-
/**
|
|
1177
|
-
* Programmatically scroll to a specific row and/or column.
|
|
1178
|
-
*
|
|
1179
|
-
* @param rowIndex - The row index to scroll to. Pass null to only scroll horizontally.
|
|
1180
|
-
* @param colIndex - The column index to scroll to. Pass null to only scroll vertically.
|
|
1181
|
-
* @param options - Alignment and behavior options.
|
|
1182
|
-
* @see ScrollAlignment
|
|
1183
|
-
* @see ScrollToIndexOptions
|
|
1184
|
-
*/
|
|
1212
|
+
/** Programmatically scroll to a specific row and/or column. */
|
|
1185
1213
|
scrollToIndex: (rowIndex?: number | null, colIndex?: number | null, options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions) => void;
|
|
1186
|
-
/**
|
|
1187
|
-
* Programmatically scroll to a specific pixel offset relative to the content start.
|
|
1188
|
-
*
|
|
1189
|
-
* @param x - The pixel offset to scroll to on the X axis (VU). Pass null to keep current position.
|
|
1190
|
-
* @param y - The pixel offset to scroll to on the Y axis (VU). Pass null to keep current position.
|
|
1191
|
-
* @param options - Scroll options (behavior).
|
|
1192
|
-
*/
|
|
1214
|
+
/** Programmatically scroll to a specific virtual pixel offset. */
|
|
1193
1215
|
scrollToOffset: (x?: number | null, y?: number | null, options?: {
|
|
1194
1216
|
behavior?: "auto" | "smooth";
|
|
1195
1217
|
}) => void;
|
|
1196
|
-
/**
|
|
1197
|
-
* Stops any currently active smooth scroll animation and clears pending corrections.
|
|
1198
|
-
*/
|
|
1218
|
+
/** Immediately stops any currently active smooth scroll animation and clears pending corrections. */
|
|
1199
1219
|
stopProgrammaticScroll: () => void;
|
|
1200
|
-
/**
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
* @param index - The item index.
|
|
1204
|
-
* @param width - The measured inlineSize (width in DU).
|
|
1205
|
-
* @param height - The measured blockSize (height in DU).
|
|
1206
|
-
* @param element - The measured element (optional, used for robust grid column detection).
|
|
1207
|
-
*/
|
|
1220
|
+
/** Adjusts the scroll position to compensate for measurement changes. */
|
|
1221
|
+
handleScrollCorrection: (addedX: number, addedY: number) => void;
|
|
1222
|
+
/** Updates the size of a single item from measurements. */
|
|
1208
1223
|
updateItemSize: (index: number, inlineSize: number, blockSize: number, element?: HTMLElement) => void;
|
|
1209
|
-
/**
|
|
1210
|
-
* Updates the stored size of multiple items simultaneously.
|
|
1211
|
-
*
|
|
1212
|
-
* @param updates - Array of measurement updates (sizes in DU).
|
|
1213
|
-
*/
|
|
1224
|
+
/** Updates the size of multiple items from measurements. */
|
|
1214
1225
|
updateItemSizes: (updates: Array<{
|
|
1215
1226
|
index: number;
|
|
1216
1227
|
inlineSize: number;
|
|
1217
1228
|
blockSize: number;
|
|
1218
1229
|
element?: HTMLElement | undefined;
|
|
1219
1230
|
}>) => void;
|
|
1220
|
-
/**
|
|
1221
|
-
* Recalculates the host element's offset relative to the scroll container.
|
|
1222
|
-
* Useful if the container or host moves without a resize event.
|
|
1223
|
-
*/
|
|
1231
|
+
/** Updates the physical offset of the component relative to its scroll container. */
|
|
1224
1232
|
updateHostOffset: () => void;
|
|
1225
|
-
/**
|
|
1226
|
-
* Detects the current direction (LTR/RTL) of the scroll container.
|
|
1227
|
-
*/
|
|
1233
|
+
/** Detects the current direction (LTR/RTL) of the scroll container. */
|
|
1228
1234
|
updateDirection: () => void;
|
|
1229
|
-
/**
|
|
1230
|
-
* Information about the current visible range of columns and their paddings.
|
|
1231
|
-
* @see ColumnRange
|
|
1232
|
-
*/
|
|
1235
|
+
/** Information about the currently visible range of columns. */
|
|
1233
1236
|
columnRange: ComputedRef< {
|
|
1234
1237
|
start: number;
|
|
1235
1238
|
end: number;
|
|
1236
1239
|
padStart: number;
|
|
1237
1240
|
padEnd: number;
|
|
1238
1241
|
}>;
|
|
1239
|
-
/**
|
|
1240
|
-
* Resets all dynamic measurements and re-initializes from props.
|
|
1241
|
-
* Useful if item sizes have changed externally.
|
|
1242
|
-
*/
|
|
1242
|
+
/** Resets all dynamic measurements and re-initializes from current props. */
|
|
1243
1243
|
refresh: () => void;
|
|
1244
|
-
/**
|
|
1245
|
-
* Whether the component has finished its first client-side mount and hydration.
|
|
1246
|
-
*/
|
|
1244
|
+
/** Whether the component has finished its first client-side mount. */
|
|
1247
1245
|
isHydrated: Ref<boolean, boolean>;
|
|
1248
|
-
/**
|
|
1249
|
-
* Whether the container is the window or body.
|
|
1250
|
-
*/
|
|
1246
|
+
/** Whether the scroll container is the window object. */
|
|
1251
1247
|
isWindowContainer: ComputedRef<boolean>;
|
|
1252
|
-
/**
|
|
1253
|
-
* Whether the scroll container is in Right-to-Left (RTL) mode.
|
|
1254
|
-
*/
|
|
1248
|
+
/** Whether the scroll container is in Right-to-Left (RTL) mode. */
|
|
1255
1249
|
isRtl: Ref<boolean, boolean>;
|
|
1256
|
-
/**
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
/**
|
|
1261
|
-
* Coordinate scaling factor for Y axis (VU/DU).
|
|
1262
|
-
*/
|
|
1263
|
-
scaleY: ComputedRef<number>;
|
|
1264
|
-
/**
|
|
1265
|
-
* Absolute offset of the component within its container (DU).
|
|
1266
|
-
*/
|
|
1250
|
+
/** Coordinate scaling factor for X axis. */
|
|
1251
|
+
scaleX: Ref<number, number>;
|
|
1252
|
+
/** Coordinate scaling factor for Y axis. */
|
|
1253
|
+
scaleY: Ref<number, number>;
|
|
1254
|
+
/** Absolute offset of the component within its container. */
|
|
1267
1255
|
componentOffset: {
|
|
1268
1256
|
x: number;
|
|
1269
1257
|
y: number;
|
|
1270
1258
|
};
|
|
1271
|
-
/**
|
|
1272
|
-
* Physical width of the items wrapper in the DOM (clamped to browser limits, in DU).
|
|
1273
|
-
*/
|
|
1259
|
+
/** Physical width of the virtualized content area (clamped). */
|
|
1274
1260
|
renderedVirtualWidth: ComputedRef<number>;
|
|
1275
|
-
/**
|
|
1276
|
-
* Physical height of the items wrapper in the DOM (clamped to browser limits, in DU).
|
|
1277
|
-
*/
|
|
1261
|
+
/** Physical height of the virtualized content area (clamped). */
|
|
1278
1262
|
renderedVirtualHeight: ComputedRef<number>;
|
|
1279
|
-
/**
|
|
1280
|
-
* Helper to get the row index at a specific virtual offset.
|
|
1281
|
-
*/
|
|
1263
|
+
/** Helper to get the row (or item) index at a specific virtual offset (VU). */
|
|
1282
1264
|
getRowIndexAt: (offset: number) => number;
|
|
1283
|
-
/**
|
|
1284
|
-
* Helper to get the column index at a specific virtual offset.
|
|
1285
|
-
*/
|
|
1265
|
+
/** Helper to get the column index at a specific virtual offset (VU). */
|
|
1286
1266
|
getColIndexAt: (offset: number) => number;
|
|
1287
1267
|
};
|
|
1288
1268
|
|
|
@@ -1413,9 +1393,9 @@ export declare function useVirtualScrollSizes<T>(propsInput: MaybeRefOrGetter<Us
|
|
|
1413
1393
|
/** Base size of an item from props. */
|
|
1414
1394
|
getItemBaseSize: (item: T, index: number) => number;
|
|
1415
1395
|
/** Helper to get current size at index. */
|
|
1416
|
-
getSizeAt: (index: number, sizeProp: number | number[] | ((...args: any[]) => number) | null | undefined, defaultSize: number, gap: number, tree: FenwickTree, isX: boolean) => number;
|
|
1396
|
+
getSizeAt: (index: number, sizeProp: number | (number | null | undefined)[] | ((...args: any[]) => number) | null | undefined, defaultSize: number, gap: number, tree: FenwickTree, isX: boolean) => number;
|
|
1417
1397
|
/** Initialize or update sizes from props. */
|
|
1418
|
-
initializeSizes: (
|
|
1398
|
+
initializeSizes: () => void;
|
|
1419
1399
|
/** Update sizes of multiple items from measurements. */
|
|
1420
1400
|
updateItemSizes: (updates: Array<{
|
|
1421
1401
|
index: number;
|
|
@@ -1424,7 +1404,7 @@ export declare function useVirtualScrollSizes<T>(propsInput: MaybeRefOrGetter<Us
|
|
|
1424
1404
|
element?: HTMLElement | undefined;
|
|
1425
1405
|
}>, getRowIndexAt: (offset: number) => number, getColIndexAt: (offset: number) => number, relativeScrollX: number, relativeScrollY: number, onScrollCorrection: (deltaX: number, deltaY: number) => void) => void;
|
|
1426
1406
|
/** Reset all measurements. */
|
|
1427
|
-
refresh: (
|
|
1407
|
+
refresh: () => void;
|
|
1428
1408
|
};
|
|
1429
1409
|
|
|
1430
1410
|
/**
|
|
@@ -1521,6 +1501,14 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1521
1501
|
*/
|
|
1522
1502
|
getItemSize: (index: number) => number;
|
|
1523
1503
|
/**
|
|
1504
|
+
* Whether the component is in table mode.
|
|
1505
|
+
*/
|
|
1506
|
+
isTable: ComputedRef<boolean>;
|
|
1507
|
+
/**
|
|
1508
|
+
* The tag used for rendering items.
|
|
1509
|
+
*/
|
|
1510
|
+
itemTag: ComputedRef<string>;
|
|
1511
|
+
/**
|
|
1524
1512
|
* Helper to get the row (or item) index at a specific vertical (or horizontal in horizontal mode) virtual offset (VU).
|
|
1525
1513
|
* @param offset - The virtual pixel offset.
|
|
1526
1514
|
* @see useVirtualScroll
|
|
@@ -1579,11 +1567,11 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1579
1567
|
/**
|
|
1580
1568
|
* Coordinate scaling factor for X axis.
|
|
1581
1569
|
*/
|
|
1582
|
-
scaleX:
|
|
1570
|
+
scaleX: Ref<number, number>;
|
|
1583
1571
|
/**
|
|
1584
1572
|
* Coordinate scaling factor for Y axis.
|
|
1585
1573
|
*/
|
|
1586
|
-
scaleY:
|
|
1574
|
+
scaleY: Ref<number, number>;
|
|
1587
1575
|
/**
|
|
1588
1576
|
* Physical width of the content in the DOM (clamped to browser limits).
|
|
1589
1577
|
*/
|
|
@@ -1610,10 +1598,10 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1610
1598
|
*/
|
|
1611
1599
|
scrollbarPropsHorizontal: ComputedRef<ScrollbarSlotProps | null>;
|
|
1612
1600
|
items: Ref<T[], T[]>;
|
|
1613
|
-
itemSize: Ref<number | ((item: T, index: number) => number) | null | undefined, number | ((item: T, index: number) => number) | null | undefined>;
|
|
1601
|
+
itemSize: Ref<number | (number | null | undefined)[] | ((item: T, index: number) => number) | null | undefined, number | (number | null | undefined)[] | ((item: T, index: number) => number) | null | undefined>;
|
|
1614
1602
|
container: Ref<HTMLElement | Window | null | undefined, HTMLElement | Window | null | undefined>;
|
|
1615
1603
|
ssrRange: Ref<SSRRange | undefined, SSRRange | undefined>;
|
|
1616
|
-
columnWidth: Ref<number | number[] | ((index: number) => number) | null | undefined, number | number[] | ((index: number) => number) | null | undefined>;
|
|
1604
|
+
columnWidth: Ref<number | (number | null | undefined)[] | ((index: number) => number) | null | undefined, number | (number | null | undefined)[] | ((index: number) => number) | null | undefined>;
|
|
1617
1605
|
initialScrollIndex: Ref<number | undefined, number | undefined>;
|
|
1618
1606
|
initialScrollAlign: Ref<ScrollAlignment | ScrollAlignmentOptions | undefined, ScrollAlignment | ScrollAlignmentOptions | undefined>;
|
|
1619
1607
|
defaultItemSize: Ref<number | undefined, number | undefined>;
|
|
@@ -1628,7 +1616,6 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1628
1616
|
columnCount: Ref<number, number>;
|
|
1629
1617
|
containerTag: Ref<string, string>;
|
|
1630
1618
|
wrapperTag: Ref<string, string>;
|
|
1631
|
-
itemTag: Ref<string, string>;
|
|
1632
1619
|
scrollPaddingStart: Ref<PaddingValue, PaddingValue>;
|
|
1633
1620
|
scrollPaddingEnd: Ref<PaddingValue, PaddingValue>;
|
|
1634
1621
|
stickyHeader: Ref<boolean, boolean>;
|
|
@@ -1767,7 +1754,7 @@ export declare interface VirtualScrollBaseProps<T = unknown> {
|
|
|
1767
1754
|
* Fixed size of each item in virtual units (VU) or a function that returns the size of an item.
|
|
1768
1755
|
* Pass `0`, `null` or `undefined` for automatic dynamic size detection via `ResizeObserver`.
|
|
1769
1756
|
*/
|
|
1770
|
-
itemSize?: number | ((item: T, index: number) => number) | null | undefined;
|
|
1757
|
+
itemSize?: number | (number | null | undefined)[] | ((item: T, index: number) => number) | null | undefined;
|
|
1771
1758
|
/**
|
|
1772
1759
|
* Direction of the virtual scroll.
|
|
1773
1760
|
* @default 'vertical'
|
|
@@ -1801,7 +1788,7 @@ export declare interface VirtualScrollBaseProps<T = unknown> {
|
|
|
1801
1788
|
* Fixed width of columns in VU, an array of widths, or a function returning widths.
|
|
1802
1789
|
* Pass `0`, `null` or `undefined` for dynamic column detection.
|
|
1803
1790
|
*/
|
|
1804
|
-
columnWidth?: number | number[] | ((index: number) => number) | null | undefined;
|
|
1791
|
+
columnWidth?: number | (number | null | undefined)[] | ((index: number) => number) | null | undefined;
|
|
1805
1792
|
/**
|
|
1806
1793
|
* Pixel padding at the start of the scroll container in display pixels (DU).
|
|
1807
1794
|
*/
|
|
@@ -1831,10 +1818,12 @@ export declare interface VirtualScrollBaseProps<T = unknown> {
|
|
|
1831
1818
|
loadDistance?: number | undefined;
|
|
1832
1819
|
/**
|
|
1833
1820
|
* Whether data is currently loading.
|
|
1821
|
+
* While true, the loading slot is shown and `load` events are suppressed.
|
|
1834
1822
|
*/
|
|
1835
1823
|
loading?: boolean | undefined;
|
|
1836
1824
|
/**
|
|
1837
|
-
* Whether to automatically
|
|
1825
|
+
* Whether to automatically maintain scroll position when items are prepended to the array.
|
|
1826
|
+
* Useful for "load more" chat interfaces.
|
|
1838
1827
|
*/
|
|
1839
1828
|
restoreScrollOnPrepend?: boolean | undefined;
|
|
1840
1829
|
/**
|
|
@@ -1879,6 +1868,7 @@ export declare interface VirtualScrollBaseProps<T = unknown> {
|
|
|
1879
1868
|
itemRole?: string | undefined;
|
|
1880
1869
|
/**
|
|
1881
1870
|
* Whether to snap to items after scrolling stops.
|
|
1871
|
+
* Options: false, true, 'auto', 'next', 'start', 'center', 'end'.
|
|
1882
1872
|
* @default false
|
|
1883
1873
|
*/
|
|
1884
1874
|
snap?: SnapMode | undefined;
|
|
@@ -1893,13 +1883,39 @@ export declare interface VirtualScrollComponentProps<T = unknown> extends Virtua
|
|
|
1893
1883
|
/** The HTML tag to use for each item. */
|
|
1894
1884
|
itemTag?: string;
|
|
1895
1885
|
/** Whether the content in the 'header' slot is sticky. */
|
|
1886
|
+
/**
|
|
1887
|
+
* If true, measures the header slot size and adds it to the scroll padding.
|
|
1888
|
+
* Can be combined with CSS for sticky headers.
|
|
1889
|
+
*/
|
|
1896
1890
|
stickyHeader?: boolean;
|
|
1897
|
-
/**
|
|
1891
|
+
/**
|
|
1892
|
+
* If true, measures the footer slot size and adds it to the scroll padding.
|
|
1893
|
+
* Can be combined with CSS for sticky footers.
|
|
1894
|
+
*/
|
|
1898
1895
|
stickyFooter?: boolean;
|
|
1899
|
-
/**
|
|
1896
|
+
/**
|
|
1897
|
+
* Whether to use virtual scrollbars.
|
|
1898
|
+
* Automatically enabled when content size exceeds browser limits.
|
|
1899
|
+
*/
|
|
1900
1900
|
virtualScrollbar?: boolean;
|
|
1901
1901
|
}
|
|
1902
1902
|
|
|
1903
|
+
/**
|
|
1904
|
+
* Base interface for Virtual Scroll extensions.
|
|
1905
|
+
*/
|
|
1906
|
+
declare interface VirtualScrollExtension<T = unknown> {
|
|
1907
|
+
/** Unique name of the extension. */
|
|
1908
|
+
name: string;
|
|
1909
|
+
/** Called when the component is initialized. */
|
|
1910
|
+
onInit?: (ctx: ExtensionContext<T>) => void;
|
|
1911
|
+
/** Called on every scroll event. */
|
|
1912
|
+
onScroll?: (ctx: ExtensionContext<T>, event: Event) => void;
|
|
1913
|
+
/** Called when scrolling activity stops. */
|
|
1914
|
+
onScrollEnd?: (ctx: ExtensionContext<T>) => void;
|
|
1915
|
+
/** Post-processor for the list of rendered items. */
|
|
1916
|
+
transformRenderedItems?: (items: RenderedItem<T>[], ctx: ExtensionContext<T>) => RenderedItem<T>[];
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1903
1919
|
/** Exposed methods and properties of the `VirtualScroll` component instance. */
|
|
1904
1920
|
export declare interface VirtualScrollInstance<T = unknown> extends VirtualScrollComponentProps<T> {
|
|
1905
1921
|
/** Detailed information about the current scroll state. */
|
|
@@ -1926,6 +1942,10 @@ export declare interface VirtualScrollInstance<T = unknown> extends VirtualScrol
|
|
|
1926
1942
|
getItemOffset: (index: number) => number;
|
|
1927
1943
|
/** Helper to get the size of a specific item along the scroll axis. */
|
|
1928
1944
|
getItemSize: (index: number) => number;
|
|
1945
|
+
/** Whether the component is in table mode. */
|
|
1946
|
+
isTable: boolean;
|
|
1947
|
+
/** The tag used for rendering items. */
|
|
1948
|
+
itemTag: string;
|
|
1929
1949
|
/** Programmatically scroll to a specific row and/or column. */
|
|
1930
1950
|
scrollToIndex: (rowIndex?: number | null, colIndex?: number | null, options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions) => void;
|
|
1931
1951
|
/** Programmatically scroll to a specific pixel offset. */
|