@pdanpdan/virtual-scroll 0.9.1 → 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 +82 -4
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +170 -153
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +833 -692
- 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 +365 -804
- package/src/composables/useVirtualScrollSizes.ts +28 -37
- 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 +33 -0
package/dist/index.d.ts
CHANGED
|
@@ -418,6 +418,81 @@ export declare function displayToVirtual(displayPos: number, hostOffset: number,
|
|
|
418
418
|
/** Initial empty state for scroll details. */
|
|
419
419
|
export declare const EMPTY_SCROLL_DETAILS: ScrollDetails<unknown>;
|
|
420
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
|
+
|
|
421
496
|
/**
|
|
422
497
|
* Fenwick Tree (Binary Indexed Tree) implementation for efficient
|
|
423
498
|
* prefix sum calculations and updates.
|
|
@@ -669,7 +744,7 @@ export declare interface ItemStyleParams<T = unknown> {
|
|
|
669
744
|
/** Scroll direction. */
|
|
670
745
|
direction: ScrollDirection;
|
|
671
746
|
/** Configured item size logic. */
|
|
672
|
-
itemSize: number | ((item: T, index: number) => number) | null | undefined;
|
|
747
|
+
itemSize: number | (number | null | undefined)[] | ((item: T, index: number) => number) | null | undefined;
|
|
673
748
|
/** Parent container tag. */
|
|
674
749
|
containerTag: string;
|
|
675
750
|
/** Padding start on X axis. */
|
|
@@ -716,6 +791,8 @@ export declare interface RangeParams {
|
|
|
716
791
|
usableHeight: number;
|
|
717
792
|
/** Total item count. */
|
|
718
793
|
itemsLength: number;
|
|
794
|
+
/** Column count (for grid mode). */
|
|
795
|
+
columnCount?: number;
|
|
719
796
|
/** Buffer items before. */
|
|
720
797
|
bufferBefore: number;
|
|
721
798
|
/** Buffer items after. */
|
|
@@ -1007,9 +1084,10 @@ export declare interface Size {
|
|
|
1007
1084
|
* - 'start': Aligns the first visible item to the viewport start if at least 50% visible, otherwise aligns the next item.
|
|
1008
1085
|
* - 'center': Aligns the item that intersects the viewport center to the center.
|
|
1009
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.
|
|
1010
1088
|
* - 'auto': Intelligent snapping based on scroll direction. Acts as 'end' when scrolling towards start, and 'start' when scrolling towards end.
|
|
1011
1089
|
*/
|
|
1012
|
-
export declare type SnapMode = boolean | 'start' | 'center' | 'end' | 'auto';
|
|
1090
|
+
export declare type SnapMode = boolean | 'start' | 'center' | 'end' | 'next' | 'auto';
|
|
1013
1091
|
|
|
1014
1092
|
/** Snap result. */
|
|
1015
1093
|
export declare interface SnapResult {
|
|
@@ -1103,189 +1181,88 @@ export declare interface TotalSizeParams {
|
|
|
1103
1181
|
* Handles calculation of visible items, scroll events, dynamic item sizes, and programmatic scrolling.
|
|
1104
1182
|
*
|
|
1105
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.).
|
|
1106
1185
|
* @see VirtualScrollProps
|
|
1107
1186
|
*/
|
|
1108
|
-
export declare function useVirtualScroll<T = unknown>(propsInput:
|
|
1109
|
-
/**
|
|
1110
|
-
* Array of items currently rendered in the DOM with their calculated offsets and sizes.
|
|
1111
|
-
* Offsets are in Display Units (DU), sizes are in Virtual Units (VU).
|
|
1112
|
-
* @see RenderedItem
|
|
1113
|
-
*/
|
|
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. */
|
|
1114
1189
|
renderedItems: ComputedRef<RenderedItem<T>[]>;
|
|
1115
|
-
/**
|
|
1116
|
-
* Total calculated width of all items including gaps (in VU).
|
|
1117
|
-
*/
|
|
1190
|
+
/** Total calculated width of the scrollable content area (DU). */
|
|
1118
1191
|
totalWidth: ComputedRef<number>;
|
|
1119
|
-
/**
|
|
1120
|
-
* Total calculated height of all items including gaps (in VU).
|
|
1121
|
-
*/
|
|
1192
|
+
/** Total calculated height of the scrollable content area (DU). */
|
|
1122
1193
|
totalHeight: ComputedRef<number>;
|
|
1123
|
-
/**
|
|
1124
|
-
* Total width to be rendered in the DOM (clamped to browser limits, in DU).
|
|
1125
|
-
*/
|
|
1194
|
+
/** Physical width of the content in the DOM (clamped to browser limits). */
|
|
1126
1195
|
renderedWidth: ComputedRef<number>;
|
|
1127
|
-
/**
|
|
1128
|
-
* Total height to be rendered in the DOM (clamped to browser limits, in DU).
|
|
1129
|
-
*/
|
|
1196
|
+
/** Physical height of the content in the DOM (clamped to browser limits). */
|
|
1130
1197
|
renderedHeight: ComputedRef<number>;
|
|
1131
|
-
/**
|
|
1132
|
-
* Detailed information about the current scroll state.
|
|
1133
|
-
* Includes currentIndex, scrollOffset (VU), displayScrollOffset (DU), viewportSize (DU), totalSize (VU), and scrolling status.
|
|
1134
|
-
* @see ScrollDetails
|
|
1135
|
-
*/
|
|
1198
|
+
/** Detailed information about the current scroll state. */
|
|
1136
1199
|
scrollDetails: ComputedRef<ScrollDetails<T>>;
|
|
1137
|
-
/**
|
|
1138
|
-
* Helper to get the height of a specific row based on current configuration and measurements.
|
|
1139
|
-
*
|
|
1140
|
-
* @param index - The row index.
|
|
1141
|
-
* @returns The height in VU (excluding gap).
|
|
1142
|
-
*/
|
|
1200
|
+
/** Helper to get the height of a specific row. */
|
|
1143
1201
|
getRowHeight: (index: number) => number;
|
|
1144
|
-
/**
|
|
1145
|
-
* Helper to get the width of a specific column based on current configuration and measurements.
|
|
1146
|
-
*
|
|
1147
|
-
* @param index - The column index.
|
|
1148
|
-
* @returns The width in VU (excluding gap).
|
|
1149
|
-
*/
|
|
1202
|
+
/** Helper to get the width of a specific column. */
|
|
1150
1203
|
getColumnWidth: (index: number) => number;
|
|
1151
|
-
/**
|
|
1152
|
-
* Helper to get the virtual offset of a specific row.
|
|
1153
|
-
*
|
|
1154
|
-
* @param index - The row index.
|
|
1155
|
-
* @returns The virtual offset in VU.
|
|
1156
|
-
*/
|
|
1204
|
+
/** Helper to get the virtual offset of a specific row. */
|
|
1157
1205
|
getRowOffset: (index: number) => number;
|
|
1158
|
-
/**
|
|
1159
|
-
* Helper to get the virtual offset of a specific column.
|
|
1160
|
-
*
|
|
1161
|
-
* @param index - The column index.
|
|
1162
|
-
* @returns The virtual offset in VU.
|
|
1163
|
-
*/
|
|
1206
|
+
/** Helper to get the virtual offset of a specific column. */
|
|
1164
1207
|
getColumnOffset: (index: number) => number;
|
|
1165
|
-
/**
|
|
1166
|
-
* Helper to get the virtual offset of a specific item along the scroll axis.
|
|
1167
|
-
*
|
|
1168
|
-
* @param index - The item index.
|
|
1169
|
-
* @returns The virtual offset in VU.
|
|
1170
|
-
*/
|
|
1208
|
+
/** Helper to get the virtual offset of a specific item. */
|
|
1171
1209
|
getItemOffset: (index: number) => number;
|
|
1172
|
-
/**
|
|
1173
|
-
* Helper to get the size of a specific item along the scroll axis.
|
|
1174
|
-
*
|
|
1175
|
-
* @param index - The item index.
|
|
1176
|
-
* @returns The size in VU (excluding gap).
|
|
1177
|
-
*/
|
|
1210
|
+
/** Helper to get the size of a specific item along the scroll axis. */
|
|
1178
1211
|
getItemSize: (index: number) => number;
|
|
1179
|
-
/**
|
|
1180
|
-
* Programmatically scroll to a specific row and/or column.
|
|
1181
|
-
*
|
|
1182
|
-
* @param rowIndex - The row index to scroll to. Pass null to only scroll horizontally.
|
|
1183
|
-
* @param colIndex - The column index to scroll to. Pass null to only scroll vertically.
|
|
1184
|
-
* @param options - Alignment and behavior options.
|
|
1185
|
-
* @see ScrollAlignment
|
|
1186
|
-
* @see ScrollToIndexOptions
|
|
1187
|
-
*/
|
|
1212
|
+
/** Programmatically scroll to a specific row and/or column. */
|
|
1188
1213
|
scrollToIndex: (rowIndex?: number | null, colIndex?: number | null, options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions) => void;
|
|
1189
|
-
/**
|
|
1190
|
-
* Programmatically scroll to a specific pixel offset relative to the content start.
|
|
1191
|
-
*
|
|
1192
|
-
* @param x - The pixel offset to scroll to on the X axis (VU). Pass null to keep current position.
|
|
1193
|
-
* @param y - The pixel offset to scroll to on the Y axis (VU). Pass null to keep current position.
|
|
1194
|
-
* @param options - Scroll options (behavior).
|
|
1195
|
-
*/
|
|
1214
|
+
/** Programmatically scroll to a specific virtual pixel offset. */
|
|
1196
1215
|
scrollToOffset: (x?: number | null, y?: number | null, options?: {
|
|
1197
1216
|
behavior?: "auto" | "smooth";
|
|
1198
1217
|
}) => void;
|
|
1199
|
-
/**
|
|
1200
|
-
* Stops any currently active smooth scroll animation and clears pending corrections.
|
|
1201
|
-
*/
|
|
1218
|
+
/** Immediately stops any currently active smooth scroll animation and clears pending corrections. */
|
|
1202
1219
|
stopProgrammaticScroll: () => void;
|
|
1203
|
-
/**
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
* @param index - The item index.
|
|
1207
|
-
* @param width - The measured inlineSize (width in DU).
|
|
1208
|
-
* @param height - The measured blockSize (height in DU).
|
|
1209
|
-
* @param element - The measured element (optional, used for robust grid column detection).
|
|
1210
|
-
*/
|
|
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. */
|
|
1211
1223
|
updateItemSize: (index: number, inlineSize: number, blockSize: number, element?: HTMLElement) => void;
|
|
1212
|
-
/**
|
|
1213
|
-
* Updates the stored size of multiple items simultaneously.
|
|
1214
|
-
*
|
|
1215
|
-
* @param updates - Array of measurement updates (sizes in DU).
|
|
1216
|
-
*/
|
|
1224
|
+
/** Updates the size of multiple items from measurements. */
|
|
1217
1225
|
updateItemSizes: (updates: Array<{
|
|
1218
1226
|
index: number;
|
|
1219
1227
|
inlineSize: number;
|
|
1220
1228
|
blockSize: number;
|
|
1221
1229
|
element?: HTMLElement | undefined;
|
|
1222
1230
|
}>) => void;
|
|
1223
|
-
/**
|
|
1224
|
-
* Recalculates the host element's offset relative to the scroll container.
|
|
1225
|
-
* Useful if the container or host moves without a resize event.
|
|
1226
|
-
*/
|
|
1231
|
+
/** Updates the physical offset of the component relative to its scroll container. */
|
|
1227
1232
|
updateHostOffset: () => void;
|
|
1228
|
-
/**
|
|
1229
|
-
* Detects the current direction (LTR/RTL) of the scroll container.
|
|
1230
|
-
*/
|
|
1233
|
+
/** Detects the current direction (LTR/RTL) of the scroll container. */
|
|
1231
1234
|
updateDirection: () => void;
|
|
1232
|
-
/**
|
|
1233
|
-
* Information about the current visible range of columns and their paddings.
|
|
1234
|
-
* @see ColumnRange
|
|
1235
|
-
*/
|
|
1235
|
+
/** Information about the currently visible range of columns. */
|
|
1236
1236
|
columnRange: ComputedRef< {
|
|
1237
1237
|
start: number;
|
|
1238
1238
|
end: number;
|
|
1239
1239
|
padStart: number;
|
|
1240
1240
|
padEnd: number;
|
|
1241
1241
|
}>;
|
|
1242
|
-
/**
|
|
1243
|
-
* Resets all dynamic measurements and re-initializes from props.
|
|
1244
|
-
* Useful if item sizes have changed externally.
|
|
1245
|
-
*/
|
|
1242
|
+
/** Resets all dynamic measurements and re-initializes from current props. */
|
|
1246
1243
|
refresh: () => void;
|
|
1247
|
-
/**
|
|
1248
|
-
* Whether the component has finished its first client-side mount and hydration.
|
|
1249
|
-
*/
|
|
1244
|
+
/** Whether the component has finished its first client-side mount. */
|
|
1250
1245
|
isHydrated: Ref<boolean, boolean>;
|
|
1251
|
-
/**
|
|
1252
|
-
* Whether the container is the window or body.
|
|
1253
|
-
*/
|
|
1246
|
+
/** Whether the scroll container is the window object. */
|
|
1254
1247
|
isWindowContainer: ComputedRef<boolean>;
|
|
1255
|
-
/**
|
|
1256
|
-
* Whether the scroll container is in Right-to-Left (RTL) mode.
|
|
1257
|
-
*/
|
|
1248
|
+
/** Whether the scroll container is in Right-to-Left (RTL) mode. */
|
|
1258
1249
|
isRtl: Ref<boolean, boolean>;
|
|
1259
|
-
/**
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
/**
|
|
1264
|
-
* Coordinate scaling factor for Y axis (VU/DU).
|
|
1265
|
-
*/
|
|
1266
|
-
scaleY: ComputedRef<number>;
|
|
1267
|
-
/**
|
|
1268
|
-
* Absolute offset of the component within its container (DU).
|
|
1269
|
-
*/
|
|
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. */
|
|
1270
1255
|
componentOffset: {
|
|
1271
1256
|
x: number;
|
|
1272
1257
|
y: number;
|
|
1273
1258
|
};
|
|
1274
|
-
/**
|
|
1275
|
-
* Physical width of the items wrapper in the DOM (clamped to browser limits, in DU).
|
|
1276
|
-
*/
|
|
1259
|
+
/** Physical width of the virtualized content area (clamped). */
|
|
1277
1260
|
renderedVirtualWidth: ComputedRef<number>;
|
|
1278
|
-
/**
|
|
1279
|
-
* Physical height of the items wrapper in the DOM (clamped to browser limits, in DU).
|
|
1280
|
-
*/
|
|
1261
|
+
/** Physical height of the virtualized content area (clamped). */
|
|
1281
1262
|
renderedVirtualHeight: ComputedRef<number>;
|
|
1282
|
-
/**
|
|
1283
|
-
* Helper to get the row index at a specific virtual offset.
|
|
1284
|
-
*/
|
|
1263
|
+
/** Helper to get the row (or item) index at a specific virtual offset (VU). */
|
|
1285
1264
|
getRowIndexAt: (offset: number) => number;
|
|
1286
|
-
/**
|
|
1287
|
-
* Helper to get the column index at a specific virtual offset.
|
|
1288
|
-
*/
|
|
1265
|
+
/** Helper to get the column index at a specific virtual offset (VU). */
|
|
1289
1266
|
getColIndexAt: (offset: number) => number;
|
|
1290
1267
|
};
|
|
1291
1268
|
|
|
@@ -1416,9 +1393,9 @@ export declare function useVirtualScrollSizes<T>(propsInput: MaybeRefOrGetter<Us
|
|
|
1416
1393
|
/** Base size of an item from props. */
|
|
1417
1394
|
getItemBaseSize: (item: T, index: number) => number;
|
|
1418
1395
|
/** Helper to get current size at index. */
|
|
1419
|
-
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;
|
|
1420
1397
|
/** Initialize or update sizes from props. */
|
|
1421
|
-
initializeSizes: (
|
|
1398
|
+
initializeSizes: () => void;
|
|
1422
1399
|
/** Update sizes of multiple items from measurements. */
|
|
1423
1400
|
updateItemSizes: (updates: Array<{
|
|
1424
1401
|
index: number;
|
|
@@ -1427,7 +1404,7 @@ export declare function useVirtualScrollSizes<T>(propsInput: MaybeRefOrGetter<Us
|
|
|
1427
1404
|
element?: HTMLElement | undefined;
|
|
1428
1405
|
}>, getRowIndexAt: (offset: number) => number, getColIndexAt: (offset: number) => number, relativeScrollX: number, relativeScrollY: number, onScrollCorrection: (deltaX: number, deltaY: number) => void) => void;
|
|
1429
1406
|
/** Reset all measurements. */
|
|
1430
|
-
refresh: (
|
|
1407
|
+
refresh: () => void;
|
|
1431
1408
|
};
|
|
1432
1409
|
|
|
1433
1410
|
/**
|
|
@@ -1524,6 +1501,14 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1524
1501
|
*/
|
|
1525
1502
|
getItemSize: (index: number) => number;
|
|
1526
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
|
+
/**
|
|
1527
1512
|
* Helper to get the row (or item) index at a specific vertical (or horizontal in horizontal mode) virtual offset (VU).
|
|
1528
1513
|
* @param offset - The virtual pixel offset.
|
|
1529
1514
|
* @see useVirtualScroll
|
|
@@ -1582,11 +1567,11 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1582
1567
|
/**
|
|
1583
1568
|
* Coordinate scaling factor for X axis.
|
|
1584
1569
|
*/
|
|
1585
|
-
scaleX:
|
|
1570
|
+
scaleX: Ref<number, number>;
|
|
1586
1571
|
/**
|
|
1587
1572
|
* Coordinate scaling factor for Y axis.
|
|
1588
1573
|
*/
|
|
1589
|
-
scaleY:
|
|
1574
|
+
scaleY: Ref<number, number>;
|
|
1590
1575
|
/**
|
|
1591
1576
|
* Physical width of the content in the DOM (clamped to browser limits).
|
|
1592
1577
|
*/
|
|
@@ -1613,10 +1598,10 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1613
1598
|
*/
|
|
1614
1599
|
scrollbarPropsHorizontal: ComputedRef<ScrollbarSlotProps | null>;
|
|
1615
1600
|
items: Ref<T[], T[]>;
|
|
1616
|
-
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>;
|
|
1617
1602
|
container: Ref<HTMLElement | Window | null | undefined, HTMLElement | Window | null | undefined>;
|
|
1618
1603
|
ssrRange: Ref<SSRRange | undefined, SSRRange | undefined>;
|
|
1619
|
-
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>;
|
|
1620
1605
|
initialScrollIndex: Ref<number | undefined, number | undefined>;
|
|
1621
1606
|
initialScrollAlign: Ref<ScrollAlignment | ScrollAlignmentOptions | undefined, ScrollAlignment | ScrollAlignmentOptions | undefined>;
|
|
1622
1607
|
defaultItemSize: Ref<number | undefined, number | undefined>;
|
|
@@ -1631,7 +1616,6 @@ export declare const VirtualScroll: <T>(__VLS_props: NonNullable<Awaited<typeof
|
|
|
1631
1616
|
columnCount: Ref<number, number>;
|
|
1632
1617
|
containerTag: Ref<string, string>;
|
|
1633
1618
|
wrapperTag: Ref<string, string>;
|
|
1634
|
-
itemTag: Ref<string, string>;
|
|
1635
1619
|
scrollPaddingStart: Ref<PaddingValue, PaddingValue>;
|
|
1636
1620
|
scrollPaddingEnd: Ref<PaddingValue, PaddingValue>;
|
|
1637
1621
|
stickyHeader: Ref<boolean, boolean>;
|
|
@@ -1770,7 +1754,7 @@ export declare interface VirtualScrollBaseProps<T = unknown> {
|
|
|
1770
1754
|
* Fixed size of each item in virtual units (VU) or a function that returns the size of an item.
|
|
1771
1755
|
* Pass `0`, `null` or `undefined` for automatic dynamic size detection via `ResizeObserver`.
|
|
1772
1756
|
*/
|
|
1773
|
-
itemSize?: number | ((item: T, index: number) => number) | null | undefined;
|
|
1757
|
+
itemSize?: number | (number | null | undefined)[] | ((item: T, index: number) => number) | null | undefined;
|
|
1774
1758
|
/**
|
|
1775
1759
|
* Direction of the virtual scroll.
|
|
1776
1760
|
* @default 'vertical'
|
|
@@ -1804,7 +1788,7 @@ export declare interface VirtualScrollBaseProps<T = unknown> {
|
|
|
1804
1788
|
* Fixed width of columns in VU, an array of widths, or a function returning widths.
|
|
1805
1789
|
* Pass `0`, `null` or `undefined` for dynamic column detection.
|
|
1806
1790
|
*/
|
|
1807
|
-
columnWidth?: number | number[] | ((index: number) => number) | null | undefined;
|
|
1791
|
+
columnWidth?: number | (number | null | undefined)[] | ((index: number) => number) | null | undefined;
|
|
1808
1792
|
/**
|
|
1809
1793
|
* Pixel padding at the start of the scroll container in display pixels (DU).
|
|
1810
1794
|
*/
|
|
@@ -1834,10 +1818,12 @@ export declare interface VirtualScrollBaseProps<T = unknown> {
|
|
|
1834
1818
|
loadDistance?: number | undefined;
|
|
1835
1819
|
/**
|
|
1836
1820
|
* Whether data is currently loading.
|
|
1821
|
+
* While true, the loading slot is shown and `load` events are suppressed.
|
|
1837
1822
|
*/
|
|
1838
1823
|
loading?: boolean | undefined;
|
|
1839
1824
|
/**
|
|
1840
|
-
* Whether to automatically
|
|
1825
|
+
* Whether to automatically maintain scroll position when items are prepended to the array.
|
|
1826
|
+
* Useful for "load more" chat interfaces.
|
|
1841
1827
|
*/
|
|
1842
1828
|
restoreScrollOnPrepend?: boolean | undefined;
|
|
1843
1829
|
/**
|
|
@@ -1882,6 +1868,7 @@ export declare interface VirtualScrollBaseProps<T = unknown> {
|
|
|
1882
1868
|
itemRole?: string | undefined;
|
|
1883
1869
|
/**
|
|
1884
1870
|
* Whether to snap to items after scrolling stops.
|
|
1871
|
+
* Options: false, true, 'auto', 'next', 'start', 'center', 'end'.
|
|
1885
1872
|
* @default false
|
|
1886
1873
|
*/
|
|
1887
1874
|
snap?: SnapMode | undefined;
|
|
@@ -1896,13 +1883,39 @@ export declare interface VirtualScrollComponentProps<T = unknown> extends Virtua
|
|
|
1896
1883
|
/** The HTML tag to use for each item. */
|
|
1897
1884
|
itemTag?: string;
|
|
1898
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
|
+
*/
|
|
1899
1890
|
stickyHeader?: boolean;
|
|
1900
|
-
/**
|
|
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
|
+
*/
|
|
1901
1895
|
stickyFooter?: boolean;
|
|
1902
|
-
/**
|
|
1896
|
+
/**
|
|
1897
|
+
* Whether to use virtual scrollbars.
|
|
1898
|
+
* Automatically enabled when content size exceeds browser limits.
|
|
1899
|
+
*/
|
|
1903
1900
|
virtualScrollbar?: boolean;
|
|
1904
1901
|
}
|
|
1905
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
|
+
|
|
1906
1919
|
/** Exposed methods and properties of the `VirtualScroll` component instance. */
|
|
1907
1920
|
export declare interface VirtualScrollInstance<T = unknown> extends VirtualScrollComponentProps<T> {
|
|
1908
1921
|
/** Detailed information about the current scroll state. */
|
|
@@ -1929,6 +1942,10 @@ export declare interface VirtualScrollInstance<T = unknown> extends VirtualScrol
|
|
|
1929
1942
|
getItemOffset: (index: number) => number;
|
|
1930
1943
|
/** Helper to get the size of a specific item along the scroll axis. */
|
|
1931
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;
|
|
1932
1949
|
/** Programmatically scroll to a specific row and/or column. */
|
|
1933
1950
|
scrollToIndex: (rowIndex?: number | null, colIndex?: number | null, options?: ScrollAlignment | ScrollAlignmentOptions | ScrollToIndexOptions) => void;
|
|
1934
1951
|
/** Programmatically scroll to a specific pixel offset. */
|