@tanstack/react-virtual 3.0.0-alpha.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/build/cjs/_virtual/_rollupPluginBabelHelpers.js +50 -0
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/build/cjs/packages/react-virtual/src/index.js +371 -0
- package/build/cjs/packages/react-virtual/src/index.js.map +1 -0
- package/build/cjs/packages/react-virtual/src/useIsomorphicLayoutEffect.js +40 -0
- package/build/cjs/packages/react-virtual/src/useIsomorphicLayoutEffect.js.map +1 -0
- package/build/cjs/packages/react-virtual/src/useRect.js +85 -0
- package/build/cjs/packages/react-virtual/src/useRect.js.map +1 -0
- package/build/esm/index.js +510 -0
- package/build/esm/index.js.map +1 -0
- package/build/stats-html.html +2689 -0
- package/build/stats-react.json +185 -0
- package/build/types/index.d.ts +53 -0
- package/build/types/useIsomorphicLayoutEffect.d.ts +2 -0
- package/build/types/useRect.d.ts +6 -0
- package/build/umd/index.development.js +541 -0
- package/build/umd/index.development.js.map +1 -0
- package/build/umd/index.production.js +12 -0
- package/build/umd/index.production.js.map +1 -0
- package/package.json +43 -0
- package/src/index.tsx +400 -0
- package/src/useIsomorphicLayoutEffect.ts +4 -0
- package/src/useRect.ts +58 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"tree": {
|
|
4
|
+
"name": "root",
|
|
5
|
+
"children": [
|
|
6
|
+
{
|
|
7
|
+
"name": "index.production.js",
|
|
8
|
+
"children": [
|
|
9
|
+
{
|
|
10
|
+
"uid": "5394-12",
|
|
11
|
+
"name": "\u0000rollupPluginBabelHelpers.js"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "node_modules/@reach/observe-rect/dist/observe-rect.esm.js",
|
|
15
|
+
"uid": "5394-14"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "packages/react-virtual/src",
|
|
19
|
+
"children": [
|
|
20
|
+
{
|
|
21
|
+
"uid": "5394-16",
|
|
22
|
+
"name": "useIsomorphicLayoutEffect.ts"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"uid": "5394-18",
|
|
26
|
+
"name": "useRect.ts"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"uid": "5394-20",
|
|
30
|
+
"name": "index.tsx"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"isRoot": true
|
|
38
|
+
},
|
|
39
|
+
"nodeParts": {
|
|
40
|
+
"5394-12": {
|
|
41
|
+
"renderedLength": 771,
|
|
42
|
+
"gzipLength": 353,
|
|
43
|
+
"brotliLength": 0,
|
|
44
|
+
"mainUid": "5394-11"
|
|
45
|
+
},
|
|
46
|
+
"5394-14": {
|
|
47
|
+
"renderedLength": 1732,
|
|
48
|
+
"gzipLength": 652,
|
|
49
|
+
"brotliLength": 0,
|
|
50
|
+
"mainUid": "5394-13"
|
|
51
|
+
},
|
|
52
|
+
"5394-16": {
|
|
53
|
+
"renderedLength": 128,
|
|
54
|
+
"gzipLength": 113,
|
|
55
|
+
"brotliLength": 0,
|
|
56
|
+
"mainUid": "5394-15"
|
|
57
|
+
},
|
|
58
|
+
"5394-18": {
|
|
59
|
+
"renderedLength": 1508,
|
|
60
|
+
"gzipLength": 486,
|
|
61
|
+
"brotliLength": 0,
|
|
62
|
+
"mainUid": "5394-17"
|
|
63
|
+
},
|
|
64
|
+
"5394-20": {
|
|
65
|
+
"renderedLength": 11074,
|
|
66
|
+
"gzipLength": 2710,
|
|
67
|
+
"brotliLength": 0,
|
|
68
|
+
"mainUid": "5394-19"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"nodeMetas": {
|
|
72
|
+
"5394-11": {
|
|
73
|
+
"id": "\u0000rollupPluginBabelHelpers.js",
|
|
74
|
+
"moduleParts": {
|
|
75
|
+
"index.production.js": "5394-12"
|
|
76
|
+
},
|
|
77
|
+
"imported": [],
|
|
78
|
+
"importedBy": [
|
|
79
|
+
{
|
|
80
|
+
"uid": "5394-19"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"5394-13": {
|
|
85
|
+
"id": "/node_modules/@reach/observe-rect/dist/observe-rect.esm.js",
|
|
86
|
+
"moduleParts": {
|
|
87
|
+
"index.production.js": "5394-14"
|
|
88
|
+
},
|
|
89
|
+
"imported": [],
|
|
90
|
+
"importedBy": [
|
|
91
|
+
{
|
|
92
|
+
"uid": "5394-17"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"5394-15": {
|
|
97
|
+
"id": "/packages/react-virtual/src/useIsomorphicLayoutEffect.ts",
|
|
98
|
+
"moduleParts": {
|
|
99
|
+
"index.production.js": "5394-16"
|
|
100
|
+
},
|
|
101
|
+
"imported": [
|
|
102
|
+
{
|
|
103
|
+
"uid": "5394-21"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"importedBy": [
|
|
107
|
+
{
|
|
108
|
+
"uid": "5394-19"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"uid": "5394-17"
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
"5394-17": {
|
|
116
|
+
"id": "/packages/react-virtual/src/useRect.ts",
|
|
117
|
+
"moduleParts": {
|
|
118
|
+
"index.production.js": "5394-18"
|
|
119
|
+
},
|
|
120
|
+
"imported": [
|
|
121
|
+
{
|
|
122
|
+
"uid": "5394-21"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"uid": "5394-13"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"uid": "5394-15"
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"importedBy": [
|
|
132
|
+
{
|
|
133
|
+
"uid": "5394-19"
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
"5394-19": {
|
|
138
|
+
"id": "/packages/react-virtual/src/index.tsx",
|
|
139
|
+
"moduleParts": {
|
|
140
|
+
"index.production.js": "5394-20"
|
|
141
|
+
},
|
|
142
|
+
"imported": [
|
|
143
|
+
{
|
|
144
|
+
"uid": "5394-11"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"uid": "5394-21"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"uid": "5394-17"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"uid": "5394-15"
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"importedBy": [],
|
|
157
|
+
"isEntry": true
|
|
158
|
+
},
|
|
159
|
+
"5394-21": {
|
|
160
|
+
"id": "react",
|
|
161
|
+
"moduleParts": {},
|
|
162
|
+
"imported": [],
|
|
163
|
+
"importedBy": [
|
|
164
|
+
{
|
|
165
|
+
"uid": "5394-19"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"uid": "5394-17"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"uid": "5394-15"
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
"isExternal": true
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"env": {
|
|
178
|
+
"rollup": "2.66.1"
|
|
179
|
+
},
|
|
180
|
+
"options": {
|
|
181
|
+
"gzip": true,
|
|
182
|
+
"brotli": false,
|
|
183
|
+
"sourcemap": false
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Rect } from './useRect';
|
|
3
|
+
declare type ScrollAlignment = 'start' | 'center' | 'end' | 'auto';
|
|
4
|
+
interface ScrollToOptions {
|
|
5
|
+
align: ScrollAlignment;
|
|
6
|
+
}
|
|
7
|
+
interface ScrollToOffsetOptions extends ScrollToOptions {
|
|
8
|
+
}
|
|
9
|
+
interface ScrollToIndexOptions extends ScrollToOptions {
|
|
10
|
+
}
|
|
11
|
+
export interface Range {
|
|
12
|
+
start: number;
|
|
13
|
+
end: number;
|
|
14
|
+
overscan: number;
|
|
15
|
+
size: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const defaultRangeExtractor: (range: Range) => number[];
|
|
18
|
+
declare type Key = number | string;
|
|
19
|
+
interface Item {
|
|
20
|
+
key: Key;
|
|
21
|
+
index: number;
|
|
22
|
+
start: number;
|
|
23
|
+
end: number;
|
|
24
|
+
size: number;
|
|
25
|
+
}
|
|
26
|
+
export interface VirtualItem extends Item {
|
|
27
|
+
measureRef: (el: HTMLElement | null) => void;
|
|
28
|
+
}
|
|
29
|
+
export interface Options<T> {
|
|
30
|
+
size: number;
|
|
31
|
+
parentRef: React.RefObject<T>;
|
|
32
|
+
estimateSize?: (index: number) => number;
|
|
33
|
+
overscan?: number;
|
|
34
|
+
horizontal?: boolean;
|
|
35
|
+
scrollToFn?: (offset: number, defaultScrollToFn?: (offset: number) => void) => void;
|
|
36
|
+
paddingStart?: number;
|
|
37
|
+
paddingEnd?: number;
|
|
38
|
+
useObserver?: (ref: React.RefObject<T>, initialRect?: Rect) => Rect;
|
|
39
|
+
initialRect?: Rect;
|
|
40
|
+
keyExtractor?: (index: number) => Key;
|
|
41
|
+
onScrollElement?: React.RefObject<HTMLElement>;
|
|
42
|
+
scrollOffsetFn?: (event?: Event) => number;
|
|
43
|
+
rangeExtractor?: (range: Range) => number[];
|
|
44
|
+
measureSize?: (el: HTMLElement, horizontal: boolean) => number;
|
|
45
|
+
}
|
|
46
|
+
export declare const useVirtual: <T extends HTMLElement>({ size, estimateSize, overscan, paddingStart, paddingEnd, parentRef, horizontal, scrollToFn, useObserver, initialRect, onScrollElement, scrollOffsetFn, keyExtractor, measureSize, rangeExtractor, }: Options<T>) => {
|
|
47
|
+
virtualItems: VirtualItem[];
|
|
48
|
+
totalSize: number;
|
|
49
|
+
scrollToOffset: (toOffset: number, { align }?: ScrollToOffsetOptions) => void;
|
|
50
|
+
scrollToIndex: (index: number, options?: ScrollToIndexOptions | undefined) => void;
|
|
51
|
+
measure: () => void;
|
|
52
|
+
};
|
|
53
|
+
export {};
|