vlist 2.2.0 → 2.4.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.github.md +33 -15
- package/README.md +14 -12
- package/dist/constants.d.ts +28 -0
- package/dist/core/adapter.d.ts +92 -0
- package/dist/core/pipeline.d.ts +2 -0
- package/dist/core/runway.d.ts +82 -0
- package/dist/core/state.d.ts +6 -2
- package/dist/core/types.d.ts +31 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +1 -1
- package/dist/internals.d.ts +2 -2
- package/dist/internals.js +1 -1
- package/dist/plugins/a11y/plugin.d.ts +10 -1
- package/dist/plugins/carousel/engine.d.ts +56 -0
- package/dist/plugins/carousel/index.d.ts +7 -0
- package/dist/plugins/carousel/plugin.d.ts +44 -0
- package/dist/plugins/carousel/presets.d.ts +18 -0
- package/dist/plugins/grid/renderer.d.ts +1 -4
- package/dist/plugins/groups/sticky.d.ts +1 -1
- package/dist/plugins/masonry/renderer.d.ts +1 -1
- package/dist/plugins/scale/index.d.ts +0 -3
- package/dist/plugins/scale/plugin.d.ts +1 -18
- package/dist/plugins/scrollbar/index.d.ts +0 -1
- package/dist/plugins/search/index.d.ts +8 -0
- package/dist/plugins/search/match.d.ts +34 -0
- package/dist/plugins/search/plugin.d.ts +84 -0
- package/dist/plugins/search/searchbar.d.ts +57 -0
- package/dist/plugins/selection/plugin.d.ts +7 -0
- package/dist/plugins/table/renderer.d.ts +2 -5
- package/dist/rendering/index.d.ts +1 -6
- package/dist/size.json +1 -1
- package/dist/types.d.ts +31 -9
- package/dist/vlist-search.css +1 -0
- package/package.json +2 -1
- package/dist/plugins/scrollbar/controller.d.ts +0 -121
- package/dist/rendering/measured.d.ts +0 -52
- package/dist/rendering/renderer.d.ts +0 -113
- package/dist/rendering/scale.d.ts +0 -121
- package/dist/rendering/scroll.d.ts +0 -23
- package/dist/rendering/viewport.d.ts +0 -139
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist - Compression Module
|
|
3
|
-
* Pure functions for handling large lists that exceed browser size limits
|
|
4
|
-
*
|
|
5
|
-
* When a list's total size (sum of all item sizes) exceeds the browser's
|
|
6
|
-
* maximum element size (~16.7M pixels), we "compress" the virtual scroll space.
|
|
7
|
-
*
|
|
8
|
-
* Key concepts:
|
|
9
|
-
* - actualSize: The true size if all items were rendered
|
|
10
|
-
* - virtualSize: The capped size used for the scroll container (≤ MAX_VIRTUAL_SIZE)
|
|
11
|
-
* - compressionRatio: virtualSize / actualSize (1 = no compression, <1 = compressed)
|
|
12
|
-
*
|
|
13
|
-
* When compressed:
|
|
14
|
-
* - Scroll position maps to item index via ratio, not pixel math
|
|
15
|
-
* - Item positions are calculated relative to a "virtual index" at current scroll
|
|
16
|
-
* - Near-bottom interpolation ensures the last items are reachable
|
|
17
|
-
*/
|
|
18
|
-
import type { Range } from "../types";
|
|
19
|
-
import { MAX_VIRTUAL_SIZE } from "../constants";
|
|
20
|
-
import type { SizeCache } from "./sizes";
|
|
21
|
-
export { MAX_VIRTUAL_SIZE };
|
|
22
|
-
/** Compression calculation result */
|
|
23
|
-
export interface CompressionState {
|
|
24
|
-
/** Whether compression is active */
|
|
25
|
-
isCompressed: boolean;
|
|
26
|
-
/** The actual total size (uncompressed) */
|
|
27
|
-
actualSize: number;
|
|
28
|
-
/** The virtual size (capped at MAX_VIRTUAL_SIZE) */
|
|
29
|
-
virtualSize: number;
|
|
30
|
-
/** Compression ratio (1 = no compression, <1 = compressed) */
|
|
31
|
-
ratio: number;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Calculate compression state for a list
|
|
35
|
-
* Pure function - no side effects
|
|
36
|
-
*
|
|
37
|
-
* @param _totalItems - Total number of items
|
|
38
|
-
* @param sizeCache - Size cache for item sizes/offsets
|
|
39
|
-
* @param force - When true, enables compressed mode even if total size is under the limit.
|
|
40
|
-
* Useful for testing, consistent UX, or preemptively enabling compression
|
|
41
|
-
* before the list grows past the browser limit.
|
|
42
|
-
*/
|
|
43
|
-
export declare const getCompressionState: (_totalItems: number, sizeCache: SizeCache, force?: boolean) => CompressionState;
|
|
44
|
-
/**
|
|
45
|
-
* Calculate visible range with compression support
|
|
46
|
-
* Pure function - no side effects
|
|
47
|
-
*
|
|
48
|
-
* @param scrollTop - Current scroll position
|
|
49
|
-
* @param containerHeight - Viewport container height
|
|
50
|
-
* @param sizeCache - Size cache for item sizes/offsets
|
|
51
|
-
* @param totalItems - Total number of items
|
|
52
|
-
* @param compression - Compression state
|
|
53
|
-
* @param out - Output range to mutate (avoids allocation on hot path)
|
|
54
|
-
*/
|
|
55
|
-
export declare const calculateCompressedVisibleRange: (scrollPosition: number, containerHeight: number, sizeCache: SizeCache, totalItems: number, compression: CompressionState, out: Range) => Range;
|
|
56
|
-
/**
|
|
57
|
-
* Calculate render range with compression support (adds overscan)
|
|
58
|
-
* Pure function - no side effects
|
|
59
|
-
*
|
|
60
|
-
* @param out - Output range to mutate (avoids allocation on hot path)
|
|
61
|
-
*/
|
|
62
|
-
export declare const calculateCompressedRenderRange: (visibleRange: Range, overscan: number, totalItems: number, out: Range) => Range;
|
|
63
|
-
/**
|
|
64
|
-
* Calculate item position (translateY) with compression support
|
|
65
|
-
* Pure function - no side effects
|
|
66
|
-
*
|
|
67
|
-
* In compressed mode (manual wheel scrolling, overflow: hidden), items are
|
|
68
|
-
* positioned RELATIVE TO THE VIEWPORT. The scroll container doesn't actually
|
|
69
|
-
* scroll - we intercept wheel events and manually position items.
|
|
70
|
-
*
|
|
71
|
-
* Key insight:
|
|
72
|
-
* - Calculate a "virtual scroll index" from the scroll ratio
|
|
73
|
-
* - Items are positioned relative to this virtual index using actual heights
|
|
74
|
-
* - Each item keeps its full height for proper rendering
|
|
75
|
-
*
|
|
76
|
-
* @param index - Item index
|
|
77
|
-
* @param scrollTop - Current (virtual) scroll position
|
|
78
|
-
* @param sizeCache - Size cache for item sizes/offsets
|
|
79
|
-
* @param totalItems - Total number of items
|
|
80
|
-
* @param containerHeight - Viewport container height
|
|
81
|
-
* @param compression - Compression state
|
|
82
|
-
*/
|
|
83
|
-
export declare const calculateCompressedItemPosition: (index: number, scrollPosition: number, sizeCache: SizeCache, totalItems: number, _containerHeight: number, compression: CompressionState, _rangeStart?: number) => number;
|
|
84
|
-
/**
|
|
85
|
-
* Calculate scroll position to bring an index into view (with compression)
|
|
86
|
-
* Pure function - no side effects
|
|
87
|
-
*
|
|
88
|
-
* @param index - Target item index
|
|
89
|
-
* @param sizeCache - Size cache for item sizes/offsets
|
|
90
|
-
* @param containerHeight - Viewport container height
|
|
91
|
-
* @param totalItems - Total number of items
|
|
92
|
-
* @param compression - Compression state
|
|
93
|
-
* @param align - Alignment within viewport
|
|
94
|
-
*/
|
|
95
|
-
export declare const calculateCompressedScrollToIndex: (index: number, sizeCache: SizeCache, containerHeight: number, totalItems: number, compression: CompressionState, align?: "start" | "center" | "end") => number;
|
|
96
|
-
/**
|
|
97
|
-
* Calculate the approximate item index at a given scroll position
|
|
98
|
-
* Useful for debugging and scroll position restoration
|
|
99
|
-
* Pure function - no side effects
|
|
100
|
-
*/
|
|
101
|
-
export declare const calculateIndexFromScrollPosition: (scrollPosition: number, sizeCache: SizeCache, totalItems: number, compression: CompressionState) => number;
|
|
102
|
-
/**
|
|
103
|
-
* Check if compression is needed for a list configuration
|
|
104
|
-
* Pure function - no side effects
|
|
105
|
-
*
|
|
106
|
-
* Note: This overload accepts a HeightCache for variable heights.
|
|
107
|
-
* For simple fixed-height checks, use needsCompressionFixed().
|
|
108
|
-
*/
|
|
109
|
-
export declare const needsCompression: (totalItems: number, heightOrCache: number | SizeCache) => boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Calculate maximum items supported without compression
|
|
112
|
-
* Only meaningful for fixed-height items
|
|
113
|
-
* Pure function - no side effects
|
|
114
|
-
*/
|
|
115
|
-
export declare const getMaxItemsWithoutCompression: (itemSize: number) => number;
|
|
116
|
-
/**
|
|
117
|
-
* Get human-readable compression info for debugging
|
|
118
|
-
* Pure function - no side effects
|
|
119
|
-
*/
|
|
120
|
-
export declare const getCompressionInfo: (totalItems: number, sizeCache: SizeCache, force?: boolean) => string;
|
|
121
|
-
//# sourceMappingURL=scale.d.ts.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist - Smart Edge Scroll
|
|
3
|
-
* Shared scroll utility used by both core baseline and withSelection feature.
|
|
4
|
-
* Only scrolls when the target item is outside the viewport; aligns to nearest edge.
|
|
5
|
-
*
|
|
6
|
-
* Split into two functions for tree-shaking:
|
|
7
|
-
* - scrollToFocusSimple: normal mode only (used by base builder)
|
|
8
|
-
* - scrollToFocus: handles both normal and compressed modes (used by features)
|
|
9
|
-
*/
|
|
10
|
-
import type { SizeCache } from "./sizes";
|
|
11
|
-
import type { CompressionState } from "./scale";
|
|
12
|
-
import type { Range } from "../types";
|
|
13
|
-
/**
|
|
14
|
-
* Simple scroll-to-focus: normal (non-compressed) mode only.
|
|
15
|
-
* Padding-aware: accounts for CSS padding on the content element.
|
|
16
|
-
*/
|
|
17
|
-
export declare const scrollToFocusSimple: (index: number, sizeCache: SizeCache, scrollPosition: number, containerSize: number, startPadding?: number, endPadding?: number) => number;
|
|
18
|
-
/**
|
|
19
|
-
* Full scroll-to-focus: handles both normal and compressed (withScale) modes.
|
|
20
|
-
* Used by withSelection feature which must work with compression.
|
|
21
|
-
*/
|
|
22
|
-
export declare const scrollToFocus: (index: number, sizeCache: SizeCache, scrollPosition: number, containerSize: number, startPadding?: number, endPadding?: number, compression?: CompressionState | null, totalItems?: number, visibleRange?: Range | null) => number;
|
|
23
|
-
//# sourceMappingURL=scroll.d.ts.map
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vlist - Virtual Scrolling Core
|
|
3
|
-
* Pure functions for virtual scroll calculations
|
|
4
|
-
*
|
|
5
|
-
* Compression support is NOT imported here — it's injected via
|
|
6
|
-
* CompressionState parameters. When compression is inactive
|
|
7
|
-
* (the common case), all calculations use simple size-cache math
|
|
8
|
-
* with zero dependency on the compression module.
|
|
9
|
-
*
|
|
10
|
-
* This keeps the builder core lightweight. The withCompression feature
|
|
11
|
-
* and the monolithic createVList entry point import compression
|
|
12
|
-
* separately and pass the state in.
|
|
13
|
-
*/
|
|
14
|
-
import type { Range, ViewportState } from "../types";
|
|
15
|
-
import type { SizeCache } from "./sizes";
|
|
16
|
-
/** Compression calculation result */
|
|
17
|
-
export interface CompressionState {
|
|
18
|
-
/** Whether compression is active */
|
|
19
|
-
isCompressed: boolean;
|
|
20
|
-
/** The actual total size (uncompressed) */
|
|
21
|
-
actualSize: number;
|
|
22
|
-
/** The virtual size (capped at MAX_VIRTUAL_SIZE) */
|
|
23
|
-
virtualSize: number;
|
|
24
|
-
/** Compression ratio (1 = no compression, <1 = compressed) */
|
|
25
|
-
ratio: number;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* A "no compression" state for lists that don't need it.
|
|
29
|
-
* Used by the builder core when withCompression is not installed.
|
|
30
|
-
*/
|
|
31
|
-
export declare const NO_COMPRESSION: CompressionState;
|
|
32
|
-
/**
|
|
33
|
-
* Create a trivial compression state from a size cache.
|
|
34
|
-
* No compression logic — just reads the total height.
|
|
35
|
-
* For use when the full compression module is not loaded.
|
|
36
|
-
*/
|
|
37
|
-
export declare const getSimpleCompressionState: (_totalItems: number, sizeCache: SizeCache) => CompressionState;
|
|
38
|
-
/**
|
|
39
|
-
* Signature for the function that calculates the visible item range.
|
|
40
|
-
* The compression module provides a version that handles compressed scroll;
|
|
41
|
-
* virtual.ts provides a simple fallback for non-compressed lists.
|
|
42
|
-
*/
|
|
43
|
-
export type VisibleRangeFn = (scrollPosition: number, containerHeight: number, sizeCache: SizeCache, totalItems: number, compression: CompressionState, out: Range) => Range;
|
|
44
|
-
/**
|
|
45
|
-
* Signature for the scroll-to-index calculator.
|
|
46
|
-
*/
|
|
47
|
-
export type ScrollToIndexFn = (index: number, sizeCache: SizeCache, containerHeight: number, totalItems: number, compression: CompressionState, align: "start" | "center" | "end") => number;
|
|
48
|
-
/**
|
|
49
|
-
* Calculate visible range using size cache lookups.
|
|
50
|
-
* Fast path for lists that don't need compression (< ~350 000 items at 48px).
|
|
51
|
-
* Mutates `out` to avoid allocation on the scroll hot path.
|
|
52
|
-
*/
|
|
53
|
-
export declare const simpleVisibleRange: VisibleRangeFn;
|
|
54
|
-
/**
|
|
55
|
-
* Calculate render range (adds overscan around visible range).
|
|
56
|
-
* This function is compression-agnostic — works for both paths.
|
|
57
|
-
* Mutates `out` to avoid allocation on the scroll hot path.
|
|
58
|
-
*/
|
|
59
|
-
export declare const calculateRenderRange: (visibleRange: Range, overscan: number, totalItems: number, out: Range) => Range;
|
|
60
|
-
/**
|
|
61
|
-
* Simple scroll-to-index calculation (non-compressed).
|
|
62
|
-
* Uses size cache offsets directly.
|
|
63
|
-
*/
|
|
64
|
-
export declare const simpleScrollToIndex: ScrollToIndexFn;
|
|
65
|
-
/**
|
|
66
|
-
* Calculate total content height.
|
|
67
|
-
* Uses compression's virtualSize when compressed, raw height otherwise.
|
|
68
|
-
*/
|
|
69
|
-
export declare const calculateTotalSize: (_totalItems: number, sizeCache: SizeCache, compression?: CompressionState | null) => number;
|
|
70
|
-
/**
|
|
71
|
-
* Calculate actual total size (without compression cap)
|
|
72
|
-
*/
|
|
73
|
-
export declare const calculateActualSize: (_totalItems: number, sizeCache: SizeCache) => number;
|
|
74
|
-
/**
|
|
75
|
-
* Calculate the offset (translateY) for an item
|
|
76
|
-
* For non-compressed lists only
|
|
77
|
-
*/
|
|
78
|
-
export declare const calculateItemOffset: (index: number, sizeCache: SizeCache) => number;
|
|
79
|
-
/**
|
|
80
|
-
* Clamp scroll position to valid range
|
|
81
|
-
*/
|
|
82
|
-
export declare const clampScrollPosition: (scrollPosition: number, totalHeight: number, containerHeight: number) => number;
|
|
83
|
-
/**
|
|
84
|
-
* Determine scroll direction
|
|
85
|
-
*/
|
|
86
|
-
export declare const getScrollDirection: (currentScrollTop: number, previousScrollTop: number, isX?: boolean) => "up" | "down" | "left" | "right";
|
|
87
|
-
/**
|
|
88
|
-
* Create initial viewport state.
|
|
89
|
-
*
|
|
90
|
-
* Accepts an optional `visibleRangeFn` so that compression-aware callers
|
|
91
|
-
* can inject the compressed version. Defaults to `simpleVisibleRange`.
|
|
92
|
-
*/
|
|
93
|
-
export declare const createViewportState: (containerHeight: number, sizeCache: SizeCache, totalItems: number, overscan: number, compression: CompressionState, visibleRangeFn?: VisibleRangeFn) => ViewportState;
|
|
94
|
-
/**
|
|
95
|
-
* Update viewport state after scroll.
|
|
96
|
-
* Mutates state in place for performance on the scroll hot path.
|
|
97
|
-
*/
|
|
98
|
-
export declare const updateViewportState: (state: ViewportState, scrollPosition: number, sizeCache: SizeCache, totalItems: number, overscan: number, compression: CompressionState, visibleRangeFn?: VisibleRangeFn) => ViewportState;
|
|
99
|
-
/**
|
|
100
|
-
* Update viewport state when container resizes.
|
|
101
|
-
* Mutates state in place for performance.
|
|
102
|
-
*/
|
|
103
|
-
export declare const updateViewportSize: (state: ViewportState, containerHeight: number, sizeCache: SizeCache, totalItems: number, overscan: number, compression: CompressionState, visibleRangeFn?: VisibleRangeFn) => ViewportState;
|
|
104
|
-
/**
|
|
105
|
-
* Update viewport state when total items changes.
|
|
106
|
-
* Mutates state in place for performance.
|
|
107
|
-
*/
|
|
108
|
-
export declare const updateViewportItems: (state: ViewportState, sizeCache: SizeCache, totalItems: number, overscan: number, compression: CompressionState, visibleRangeFn?: VisibleRangeFn) => ViewportState;
|
|
109
|
-
/**
|
|
110
|
-
* Calculate scroll position to bring an index into view.
|
|
111
|
-
*
|
|
112
|
-
* Accepts an optional `scrollToIndexFn` so that compression-aware callers
|
|
113
|
-
* can inject the compressed version. Defaults to `simpleScrollToIndex`.
|
|
114
|
-
*/
|
|
115
|
-
export declare const calculateScrollToIndex: (index: number, sizeCache: SizeCache, containerHeight: number, totalItems: number, align: "start" | "center" | "end" | undefined, compression: CompressionState, scrollToIndexFn?: ScrollToIndexFn) => number;
|
|
116
|
-
/**
|
|
117
|
-
* Check if two ranges are equal
|
|
118
|
-
*/
|
|
119
|
-
export declare const rangesEqual: (a: Range, b: Range) => boolean;
|
|
120
|
-
/**
|
|
121
|
-
* Check if an index is within a range
|
|
122
|
-
*/
|
|
123
|
-
export declare const isInRange: (index: number, range: Range) => boolean;
|
|
124
|
-
/**
|
|
125
|
-
* Get the count of items in a range
|
|
126
|
-
*/
|
|
127
|
-
export declare const getRangeCount: (range: Range) => number;
|
|
128
|
-
/**
|
|
129
|
-
* Create an array of indices from a range
|
|
130
|
-
*/
|
|
131
|
-
export declare const rangeToIndices: (range: Range) => number[];
|
|
132
|
-
/**
|
|
133
|
-
* Calculate which indices need to be added/removed when range changes
|
|
134
|
-
*/
|
|
135
|
-
export declare const diffRanges: (oldRange: Range, newRange: Range) => {
|
|
136
|
-
add: number[];
|
|
137
|
-
remove: number[];
|
|
138
|
-
};
|
|
139
|
-
//# sourceMappingURL=viewport.d.ts.map
|