@tanstack/virtual-core 3.0.0-alpha.1

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.
@@ -0,0 +1,101 @@
1
+ {
2
+ "version": 2,
3
+ "tree": {
4
+ "name": "root",
5
+ "children": [
6
+ {
7
+ "name": "index.production.js",
8
+ "children": [
9
+ {
10
+ "name": "node_modules/@reach/observe-rect/dist/observe-rect.esm.js",
11
+ "uid": "3f78-7"
12
+ },
13
+ {
14
+ "name": "packages/virtual-core/src",
15
+ "children": [
16
+ {
17
+ "uid": "3f78-9",
18
+ "name": "utils.ts"
19
+ },
20
+ {
21
+ "uid": "3f78-11",
22
+ "name": "index.ts"
23
+ }
24
+ ]
25
+ }
26
+ ]
27
+ }
28
+ ],
29
+ "isRoot": true
30
+ },
31
+ "nodeParts": {
32
+ "3f78-7": {
33
+ "renderedLength": 1732,
34
+ "gzipLength": 652,
35
+ "brotliLength": 0,
36
+ "mainUid": "3f78-6"
37
+ },
38
+ "3f78-9": {
39
+ "renderedLength": 1432,
40
+ "gzipLength": 544,
41
+ "brotliLength": 0,
42
+ "mainUid": "3f78-8"
43
+ },
44
+ "3f78-11": {
45
+ "renderedLength": 12529,
46
+ "gzipLength": 2895,
47
+ "brotliLength": 0,
48
+ "mainUid": "3f78-10"
49
+ }
50
+ },
51
+ "nodeMetas": {
52
+ "3f78-6": {
53
+ "id": "/node_modules/@reach/observe-rect/dist/observe-rect.esm.js",
54
+ "moduleParts": {
55
+ "index.production.js": "3f78-7"
56
+ },
57
+ "imported": [],
58
+ "importedBy": [
59
+ {
60
+ "uid": "3f78-10"
61
+ }
62
+ ]
63
+ },
64
+ "3f78-8": {
65
+ "id": "/packages/virtual-core/src/utils.ts",
66
+ "moduleParts": {
67
+ "index.production.js": "3f78-9"
68
+ },
69
+ "imported": [],
70
+ "importedBy": [
71
+ {
72
+ "uid": "3f78-10"
73
+ }
74
+ ]
75
+ },
76
+ "3f78-10": {
77
+ "id": "/packages/virtual-core/src/index.ts",
78
+ "moduleParts": {
79
+ "index.production.js": "3f78-11"
80
+ },
81
+ "imported": [
82
+ {
83
+ "uid": "3f78-6"
84
+ },
85
+ {
86
+ "uid": "3f78-8"
87
+ }
88
+ ],
89
+ "importedBy": [],
90
+ "isEntry": true
91
+ }
92
+ },
93
+ "env": {
94
+ "rollup": "2.75.4"
95
+ },
96
+ "options": {
97
+ "gzip": true,
98
+ "brotli": false,
99
+ "sourcemap": false
100
+ }
101
+ }
@@ -0,0 +1,87 @@
1
+ export * from './utils';
2
+ declare type ScrollAlignment = 'start' | 'center' | 'end' | 'auto';
3
+ interface ScrollToOptions {
4
+ align: ScrollAlignment;
5
+ }
6
+ declare type ScrollToOffsetOptions = ScrollToOptions;
7
+ declare type ScrollToIndexOptions = ScrollToOptions;
8
+ export interface Range {
9
+ startIndex: number;
10
+ endIndex: number;
11
+ overscan: number;
12
+ count: number;
13
+ }
14
+ declare type Key = number | string;
15
+ interface Item {
16
+ key: Key;
17
+ index: number;
18
+ start: number;
19
+ end: number;
20
+ size: number;
21
+ }
22
+ interface Rect {
23
+ width: number;
24
+ height: number;
25
+ }
26
+ export interface VirtualItem<TItemElement> extends Item {
27
+ measureElement: (el: TItemElement | null) => void;
28
+ }
29
+ export declare const defaultEstimateSize: () => number;
30
+ export declare const defaultKeyExtractor: (index: number) => number;
31
+ export declare const defaultRangeExtractor: (range: Range) => number[];
32
+ export declare const observeElementRect: (instance: Virtualizer<any, any>, cb: (rect: Rect) => void) => (() => void) | undefined;
33
+ export declare const observeWindowRect: (instance: Virtualizer<any, any>, cb: (rect: Rect) => void) => (() => void) | undefined;
34
+ export declare const observeElementOffset: (instance: Virtualizer<any, any>, cb: (offset: number) => void) => (() => void) | undefined;
35
+ export declare const observeWindowOffset: (instance: Virtualizer<any, any>, cb: (offset: number) => void) => (() => void) | undefined;
36
+ export declare const defaultMeasureElement: (element: unknown, instance: Virtualizer<any, any>) => number;
37
+ export declare const windowScroll: (offset: number, canSmooth: boolean, instance: Virtualizer<any, any>) => void;
38
+ export declare const elementScroll: (offset: number, canSmooth: boolean, instance: Virtualizer<any, any>) => void;
39
+ export interface VirtualizerOptions<TScrollElement = unknown, TItemElement = unknown> {
40
+ count: number;
41
+ scrollToFn: (offset: number, canSmooth: boolean, instance: Virtualizer<TScrollElement, TItemElement>) => void;
42
+ getScrollElement: () => TScrollElement;
43
+ observeElementRect: (instance: Virtualizer<TScrollElement, TItemElement>, cb: (rect: Rect) => void) => void | (() => void);
44
+ observeElementOffset: (instance: Virtualizer<TScrollElement, TItemElement>, cb: (offset: number) => void) => void | (() => void);
45
+ debug?: any;
46
+ initialRect?: Rect;
47
+ onChange?: (instance: Virtualizer<TScrollElement, TItemElement>) => void;
48
+ measureElement?: (el: TItemElement, instance: Virtualizer<TScrollElement, TItemElement>) => number;
49
+ estimateSize?: (index: number) => number;
50
+ overscan?: number;
51
+ horizontal?: boolean;
52
+ paddingStart?: number;
53
+ paddingEnd?: number;
54
+ initialOffset?: number;
55
+ keyExtractor?: (index: number) => Key;
56
+ rangeExtractor?: (range: Range) => number[];
57
+ enableSmoothScroll?: boolean;
58
+ }
59
+ export declare class Virtualizer<TScrollElement = unknown, TItemElement = unknown> {
60
+ unsubs: (void | (() => void))[];
61
+ options: Required<VirtualizerOptions<TScrollElement, TItemElement>>;
62
+ scrollElement: TScrollElement | null;
63
+ private measurementsCache;
64
+ private itemMeasurementsCache;
65
+ private pendingMeasuredCacheIndexes;
66
+ private scrollRect;
67
+ private scrollOffset;
68
+ constructor(opts: VirtualizerOptions<TScrollElement, TItemElement>);
69
+ setOptions: (opts: VirtualizerOptions<TScrollElement, TItemElement>) => void;
70
+ private notify;
71
+ private cleanup;
72
+ _didMount: () => () => void;
73
+ _willUpdate: () => void;
74
+ private getSize;
75
+ private getMeasurements;
76
+ private calculateRange;
77
+ private getIndexes;
78
+ getVirtualItems: () => VirtualItem<TItemElement>[];
79
+ scrollToOffset: (toOffset: number, { align }?: ScrollToOffsetOptions) => void;
80
+ private tryScrollToIndex;
81
+ scrollToIndex: (index: number, options?: ScrollToIndexOptions) => void;
82
+ getTotalSize: () => number;
83
+ getSizeKey: () => "width" | "height";
84
+ private _scrollToOffset;
85
+ private getEstimateSizeFn;
86
+ measure: () => void;
87
+ }
@@ -0,0 +1,7 @@
1
+ export declare type NoInfer<A extends any> = [A][A extends any ? 0 : never];
2
+ export declare type PartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
3
+ export declare function memo<TDeps extends readonly any[], TResult>(getDeps: () => [...TDeps], fn: (...args: NoInfer<[...TDeps]>) => TResult, opts: {
4
+ key: any;
5
+ debug?: () => any;
6
+ onChange?: (result: TResult) => void;
7
+ }): () => TResult;