@candidstartup/react-virtual-scroll 0.5.0 → 0.6.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/dist/index.d.ts +428 -141
- package/dist/index.js +350 -140
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,106 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React$1 from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Props that an implementation of {@link VirtualContainerRender} must accept.
|
|
6
|
+
*
|
|
7
|
+
* Includes all the props that a {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLDivElement | HTMLDivElement} would accept.
|
|
8
|
+
*/
|
|
9
|
+
type VirtualContainerRenderProps = React$1.ComponentPropsWithoutRef<'div'>;
|
|
10
|
+
/**
|
|
11
|
+
* Render prop for a {@link VirtualContainer}
|
|
12
|
+
*
|
|
13
|
+
* Can be passed to {@link VirtualContainer} to replace default implementation.
|
|
14
|
+
* Function must render a div and forward {@link VirtualContainerRenderProps}
|
|
15
|
+
* and any `ref` to it.
|
|
16
|
+
*
|
|
17
|
+
* @example Minimal compliant implementation
|
|
18
|
+
* ```
|
|
19
|
+
* const containerRender: VirtualContainerRender = ({...rest}, ref) => (
|
|
20
|
+
* <div ref={ref} {...rest} />
|
|
21
|
+
* )
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
type VirtualContainerRender = (props: VirtualContainerRenderProps, ref?: React$1.ForwardedRef<HTMLDivElement>) => JSX.Element;
|
|
25
|
+
/**
|
|
26
|
+
* Props that {@link VirtualContainer} accepts.
|
|
27
|
+
*/
|
|
28
|
+
interface VirtualContainerComponentProps extends VirtualContainerRenderProps {
|
|
29
|
+
/** Render prop implementing {@link VirtualContainerRender}. Used to customize {@link VirtualContainer}. */
|
|
30
|
+
render?: VirtualContainerRender;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Wrapper around a div used by other components in {@link @candidstartup/react-virtual-scroll!}. Most props are passed through to the div. Use the
|
|
34
|
+
* {@link VirtualContainerComponentProps.render} prop to override the default behavior.
|
|
35
|
+
*
|
|
36
|
+
* @group Components
|
|
37
|
+
*/
|
|
38
|
+
declare const VirtualContainer: React$1.ForwardRefExoticComponent<VirtualContainerComponentProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Props that an implementation of {@link AutoSizerRender} must accept.
|
|
42
|
+
*/
|
|
43
|
+
interface AutoSizerRenderProps {
|
|
44
|
+
/** Computed height */
|
|
45
|
+
height: number;
|
|
46
|
+
/** Computed width */
|
|
47
|
+
width: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Render prop for content in an {@link AutoSizer}
|
|
51
|
+
*
|
|
52
|
+
* Function renders content and forwards `width` and `height`
|
|
53
|
+
* to whatever needs it.
|
|
54
|
+
*
|
|
55
|
+
* @example Simple implementation
|
|
56
|
+
* ```
|
|
57
|
+
* const autoSizeRender: AutoSizeRender = ({width, height}) => (
|
|
58
|
+
* <VirtualList width={width} height={height} {...props} />
|
|
59
|
+
* )
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
type AutoSizerRender = (props: AutoSizerRenderProps) => JSX.Element;
|
|
63
|
+
/**
|
|
64
|
+
* Props accepted by {@link AutoSizer}
|
|
65
|
+
*/
|
|
66
|
+
interface AutoSizerProps {
|
|
67
|
+
/** Function implementing {@link AutoSizerRender} that renders the content that needs explicit sizing */
|
|
68
|
+
children: AutoSizerRender;
|
|
69
|
+
/** The `className` applied to the container element */
|
|
70
|
+
className?: string;
|
|
71
|
+
/** Inline style to apply to the container element */
|
|
72
|
+
style?: React$1.CSSProperties;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* HOC that calculates the size available to it and makes the computed size available to children.
|
|
76
|
+
* The size available depends on DOM layout and style applied wherever the AutoSizer finds itself.
|
|
77
|
+
* You will probably want to pass something appropriate via the `className` or `style` props.
|
|
78
|
+
*
|
|
79
|
+
* Accepts props defined by {@link AutoSizerProps}.
|
|
80
|
+
* You must pass a single instance of {@link AutoSizerRender} as a child.
|
|
81
|
+
* @group Components
|
|
5
82
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
83
|
+
declare function AutoSizer(props: AutoSizerProps): react_jsx_runtime.JSX.Element;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Common props for {@link DisplayListItem} and {@link DisplayGridItem}
|
|
87
|
+
*/
|
|
88
|
+
interface DisplayBaseItemProps {
|
|
89
|
+
/** Value of {@link DisplayBaseProps.itemData} from owning component */
|
|
8
90
|
data: unknown;
|
|
9
91
|
/**
|
|
10
92
|
* Is the owning component being actively scrolled? Used to change how the item is rendered depending on scroll state.
|
|
11
93
|
*
|
|
12
|
-
*
|
|
94
|
+
* Value passed through from {@link DisplayBaseProps.isScrolling}.
|
|
13
95
|
* */
|
|
14
96
|
isScrolling?: boolean;
|
|
15
97
|
/** Style that should be applied to each item rendered. Positions the item within the inner container. */
|
|
16
|
-
style: React.CSSProperties;
|
|
98
|
+
style: React$1.CSSProperties;
|
|
17
99
|
}
|
|
18
100
|
/**
|
|
19
|
-
* Common props for
|
|
101
|
+
* Common props for all components
|
|
20
102
|
*/
|
|
21
|
-
interface
|
|
103
|
+
interface ComponentProps {
|
|
22
104
|
/** The `className` applied to the outer container element. Use when styling the entire component. */
|
|
23
105
|
className?: string;
|
|
24
106
|
/** The `className` applied to the inner container element. Use for special cases when styling only the inner container and items. */
|
|
@@ -27,11 +109,39 @@ interface VirtualBaseProps {
|
|
|
27
109
|
height: number;
|
|
28
110
|
/** Component width */
|
|
29
111
|
width: number;
|
|
30
|
-
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Common props for {@link DisplayList} and {@link DisplayGrid}
|
|
115
|
+
*/
|
|
116
|
+
interface DisplayBaseProps extends ComponentProps {
|
|
117
|
+
/** Passed as {@link DisplayBaseItemProps.data} to each child item */
|
|
31
118
|
itemData?: unknown;
|
|
119
|
+
/** Passed as {@link DisplayBaseItemProps.isScrolling} to each child item
|
|
120
|
+
*
|
|
121
|
+
* Provided as a convenience when combining display components with {@link VirtualScroll}
|
|
122
|
+
* Not interpreted by the display component itself
|
|
123
|
+
*/
|
|
124
|
+
isScrolling?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Renders the outer viewport div which provides a window onto the inner grid div
|
|
127
|
+
*
|
|
128
|
+
* Render prop implementing {@link VirtualContainerRender}. Used to customize display component outer container.
|
|
129
|
+
*/
|
|
130
|
+
outerRender?: VirtualContainerRender;
|
|
131
|
+
/**
|
|
132
|
+
* Renders the inner grid div containing all the list items
|
|
133
|
+
*
|
|
134
|
+
* Render prop implementing {@link VirtualContainerRender}. Used to customize display component inner container.
|
|
135
|
+
*/
|
|
136
|
+
innerRender?: VirtualContainerRender;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Common props for all virtual scrollable components
|
|
140
|
+
*/
|
|
141
|
+
interface VirtualScrollableProps extends ComponentProps {
|
|
32
142
|
/**
|
|
33
143
|
* Determines whether the component should track whether it's being actively scrolled
|
|
34
|
-
* and pass
|
|
144
|
+
* and pass through when rendering its content.
|
|
35
145
|
*
|
|
36
146
|
* @defaultValue false
|
|
37
147
|
* */
|
|
@@ -44,7 +154,7 @@ interface VirtualBaseProps {
|
|
|
44
154
|
* */
|
|
45
155
|
maxCssSize?: number;
|
|
46
156
|
/**
|
|
47
|
-
* The minimum number of virtual pages to use when inner container would otherwise be more than {@link
|
|
157
|
+
* The minimum number of virtual pages to use when inner container would otherwise be more than {@link VirtualScrollableProps.maxCssSize} big.
|
|
48
158
|
* You should never normally need to change this.
|
|
49
159
|
*
|
|
50
160
|
* @defaultValue 100
|
|
@@ -52,59 +162,12 @@ interface VirtualBaseProps {
|
|
|
52
162
|
minNumPages?: number;
|
|
53
163
|
}
|
|
54
164
|
/**
|
|
55
|
-
*
|
|
56
|
-
*/
|
|
57
|
-
interface VirtualInnerProps {
|
|
58
|
-
/** The `className` to apply to the inner container div. Passed through from {@link VirtualBaseProps.innerClassName} */
|
|
59
|
-
className: string | undefined;
|
|
60
|
-
/** The visible child items rendered into the inner container div */
|
|
61
|
-
children: React.ReactNode;
|
|
62
|
-
/** Style to apply to the inner container div */
|
|
63
|
-
style: React.CSSProperties;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Render prop for inner container in a virtual scrolling component
|
|
67
|
-
*
|
|
68
|
-
* Can be passed to {@link VirtualList} or {@link VirtualGrid} to replace default
|
|
69
|
-
* implementation. Function must render a div and forward {@link VirtualInnerProps}
|
|
70
|
-
* and any `ref` to it.
|
|
71
|
-
*
|
|
72
|
-
* @example Minimal compliant implementation
|
|
73
|
-
* ```
|
|
74
|
-
* const innerRender: VirtualInnerRender = ({...rest}, ref) => (
|
|
75
|
-
* <div ref={ref} {...rest} />
|
|
76
|
-
* )
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
type VirtualInnerRender = (props: VirtualInnerProps, ref?: React.ForwardedRef<HTMLDivElement>) => JSX.Element;
|
|
80
|
-
/**
|
|
81
|
-
* Props that an implementation of {@link VirtualOuterRender} must accept.
|
|
165
|
+
* Common props for {@link VirtualList} and {@link VirtualGrid}
|
|
82
166
|
*/
|
|
83
|
-
interface
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
/** The child inner container rendered into the outer container div */
|
|
87
|
-
children: React.ReactNode;
|
|
88
|
-
/** Style to apply to the outer container div */
|
|
89
|
-
style: React.CSSProperties;
|
|
90
|
-
/** Scroll callback that should be applied to the outer container div */
|
|
91
|
-
onScroll: (event: ScrollEvent) => void;
|
|
167
|
+
interface VirtualBaseProps extends VirtualScrollableProps {
|
|
168
|
+
/** Passed as {@link DisplayBaseItemProps.data} to each child item */
|
|
169
|
+
itemData?: unknown;
|
|
92
170
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Render prop for outer container in a virtual scrolling component
|
|
95
|
-
*
|
|
96
|
-
* Can be passed to {@link VirtualList} or {@link VirtualGrid} to replace default
|
|
97
|
-
* implementation. Function must render a div and forward {@link VirtualOuterProps}
|
|
98
|
-
* and any `ref` to it.
|
|
99
|
-
*
|
|
100
|
-
* @example Minimal compliant implementation
|
|
101
|
-
* ```
|
|
102
|
-
* const outerRender: VirtualOuterRender = ({style, ...rest}, ref) => (
|
|
103
|
-
* <div ref={ref} {...rest} />
|
|
104
|
-
* )
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
type VirtualOuterRender = (props: VirtualOuterProps, ref?: React.ForwardedRef<HTMLDivElement>) => JSX.Element;
|
|
108
171
|
/**
|
|
109
172
|
* Interface that {@link VirtualList} and {@link VirtualGrid} use to determine size and
|
|
110
173
|
* positioning offset for items in a single dimension.
|
|
@@ -123,7 +186,18 @@ interface ItemOffsetMapping {
|
|
|
123
186
|
offsetToItem(offset: number): [itemIndex: number, startOffset: number];
|
|
124
187
|
}
|
|
125
188
|
/** Alias for type of event that React passes to a `div` element's `OnScroll` handler. */
|
|
126
|
-
type ScrollEvent = React.SyntheticEvent<HTMLDivElement>;
|
|
189
|
+
type ScrollEvent = React$1.SyntheticEvent<HTMLDivElement>;
|
|
190
|
+
/**
|
|
191
|
+
* Option for {@link VirtualGridProxy.scrollToItem} and {@link VirtualListProxy.scrollToItem}
|
|
192
|
+
*
|
|
193
|
+
* * `topleft` scrolls the item as far to the top and left as possible
|
|
194
|
+
* * `visible` scrolls the item the minimum amount needed to ensure that it's visible
|
|
195
|
+
*
|
|
196
|
+
* @defaultValue `topleft`
|
|
197
|
+
*/
|
|
198
|
+
type ScrollToOption = 'topleft' | 'visible';
|
|
199
|
+
/** Specifies the direction over which lists should implement virtual scrolling */
|
|
200
|
+
type ScrollLayout = "horizontal" | "vertical";
|
|
127
201
|
|
|
128
202
|
/** Direction of scrolling */
|
|
129
203
|
type ScrollDirection = "forward" | "backward";
|
|
@@ -142,37 +216,203 @@ interface ScrollState {
|
|
|
142
216
|
}
|
|
143
217
|
|
|
144
218
|
/**
|
|
145
|
-
*
|
|
219
|
+
* Custom ref handle returned by {@link VirtualScroll} that exposes imperative methods
|
|
220
|
+
*
|
|
221
|
+
* Use `React.useRef<VirtualScrollProxy>(null)` to create a ref.
|
|
222
|
+
*/
|
|
223
|
+
interface VirtualScrollProxy {
|
|
224
|
+
/**
|
|
225
|
+
* Scrolls to the specified vertical and horizontal offset in pixels
|
|
226
|
+
* Either offset can be left undefined to scroll in one dimension only
|
|
227
|
+
* @param verticalOffset - Offset to scroll to vertically
|
|
228
|
+
* @param horizontalOffset - Offset to scroll to horizontally
|
|
229
|
+
*/
|
|
230
|
+
scrollTo(verticalOffset?: number, horizontalOffset?: number): void;
|
|
231
|
+
/**
|
|
232
|
+
* Scrolls to the specified area
|
|
233
|
+
* Either offset/size pair can be left undefined to scroll in one dimension only
|
|
234
|
+
* @param verticalOffset - Offset to scroll to vertically
|
|
235
|
+
* @param verticalSize - Size of target area vertically
|
|
236
|
+
* @param horizontalOffset - Offset to scroll to horizontally
|
|
237
|
+
* @param horizontalSize - Size of target area horizontally
|
|
238
|
+
* @param option - Where to {@link ScrollToOption | position} the area within the viewport
|
|
239
|
+
*/
|
|
240
|
+
scrollToArea(verticalOffset?: number, verticalSize?: number, horizontalOffset?: number, horizontalSize?: number, option?: ScrollToOption): void;
|
|
241
|
+
/** Exposes DOM clientWidth property */
|
|
242
|
+
get clientWidth(): number;
|
|
243
|
+
/** Exposes DOM clientHeight property */
|
|
244
|
+
get clientHeight(): number;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Returns the offset needed to scroll in one dimension for a specified range
|
|
248
|
+
*
|
|
249
|
+
* Used internally to implement {@link VirtualScrollProxy.scrollToArea}. Can be used directly for
|
|
250
|
+
* advanced customization scenarios.
|
|
251
|
+
*/
|
|
252
|
+
declare function getOffsetToScrollRange(offset: number | undefined, size: number | undefined, clientExtent: number, scrollOffset: number, option?: ScrollToOption): number | undefined;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Props that an implementation of {@link VirtualContentRender} must accept.
|
|
256
|
+
*/
|
|
257
|
+
interface VirtualContentProps {
|
|
258
|
+
/**
|
|
259
|
+
* Is the owning component being actively scrolled? Used to change how the content is rendered depending on scroll state.
|
|
260
|
+
*
|
|
261
|
+
* Only defined if {@link VirtualScrollableProps.useIsScrolling} is true.
|
|
262
|
+
* */
|
|
263
|
+
isScrolling?: boolean;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Render prop for content container in {@link VirtualScroll}
|
|
267
|
+
*
|
|
268
|
+
* Pass to {@link VirtualScroll} to render content into the viewport
|
|
269
|
+
* implementation. Function must render a div and forward {@link VirtualContentProps}
|
|
270
|
+
* and any `ref` to it.
|
|
271
|
+
*
|
|
272
|
+
* @example Minimal compliant implementation
|
|
273
|
+
* ```
|
|
274
|
+
* const contentRender: VirtualContentRender = ({isScrolling, ...rest}, ref) => (
|
|
275
|
+
* <div ref={ref} {...rest} />
|
|
276
|
+
* )
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
type VirtualContentRender = (props: VirtualContentProps, ref?: React$1.ForwardedRef<HTMLDivElement>) => JSX.Element;
|
|
280
|
+
/**
|
|
281
|
+
* Props accepted by {@link VirtualScroll}
|
|
282
|
+
*/
|
|
283
|
+
interface VirtualScrollProps extends VirtualScrollableProps {
|
|
284
|
+
/** Function implementing {@link VirtualContentRender} that renders the content that needs to respond to scrolling */
|
|
285
|
+
children: VirtualContentRender;
|
|
286
|
+
/**
|
|
287
|
+
* Height of area to scroll over
|
|
288
|
+
*
|
|
289
|
+
* @defaultValue 0
|
|
290
|
+
*/
|
|
291
|
+
scrollHeight?: number;
|
|
292
|
+
/**
|
|
293
|
+
* Width of area to scroll over
|
|
294
|
+
*
|
|
295
|
+
* @defaultValue 0
|
|
296
|
+
*/
|
|
297
|
+
scrollWidth?: number;
|
|
298
|
+
/**
|
|
299
|
+
* Callback after a scroll event has been processed and state updated but before rendering
|
|
300
|
+
* @param verticalOffset - Resulting overall vertical offset.
|
|
301
|
+
* @param horizontalOffset - Resulting overall horizontal offset.
|
|
302
|
+
* @param newVerticalScrollState - New vertical {@link ScrollState} that will be used for rendering.
|
|
303
|
+
* @param newHorizontalScrollState - New horizontal {@link ScrollState} that will be used for rendering.
|
|
304
|
+
*/
|
|
305
|
+
onScroll?: (verticalOffset: number, horizontalOffset: number, newVerticalScrollState: ScrollState, newHorizontalScrollState: ScrollState) => void;
|
|
306
|
+
/** Render prop implementing {@link VirtualContainerRender}. Used to customize {@link VirtualScroll} outer container. */
|
|
307
|
+
outerRender?: VirtualContainerRender;
|
|
308
|
+
/** Render prop implementing {@link VirtualContainerRender}. Used to customize {@link VirtualScroll} inner container. */
|
|
309
|
+
innerRender?: VirtualContainerRender;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Customizable Virtual Scrolling Component
|
|
313
|
+
*
|
|
314
|
+
* Allows user to scroll over a virtual area `scrollHeight` x `scrollWidth` pixels.
|
|
315
|
+
* Use `onScroll` to track scroll state and `innerRender` to render scroll state specific content into the viewport
|
|
316
|
+
*
|
|
317
|
+
* Accepts props defined by {@link VirtualScrollProps}.
|
|
318
|
+
* Refs are forwarded to {@link VirtualScrollProxy}.
|
|
319
|
+
* @group Components
|
|
320
|
+
*/
|
|
321
|
+
declare const VirtualScroll: React$1.ForwardRefExoticComponent<VirtualScrollProps & React$1.RefAttributes<VirtualScrollProxy>>;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Props accepted by {@link DisplayListItem}
|
|
325
|
+
*/
|
|
326
|
+
interface DisplayListItemProps extends DisplayBaseItemProps {
|
|
327
|
+
/** Index of item in the list being rendered */
|
|
328
|
+
index: number;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Type of item in a {@link DisplayList}
|
|
332
|
+
*
|
|
333
|
+
* Must be passed as a child to {@link DisplayList}.
|
|
334
|
+
* Accepts props defined by {@link DisplayListItemProps}.
|
|
335
|
+
* Component must pass {@link DisplayBaseItemProps.style} to whatever it renders.
|
|
336
|
+
*
|
|
337
|
+
* @example Basic implementation
|
|
338
|
+
* ```
|
|
339
|
+
* const Row = ({ index, style }: { index: number, style: React.CSSProperties }) => (
|
|
340
|
+
* <div className="row" style={style}>
|
|
341
|
+
* { index }
|
|
342
|
+
* </div>
|
|
343
|
+
* );
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
type DisplayListItem = React$1.ComponentType<DisplayListItemProps>;
|
|
347
|
+
/**
|
|
348
|
+
* Props accepted by {@link DisplayList}
|
|
349
|
+
*/
|
|
350
|
+
interface DisplayListProps extends DisplayBaseProps {
|
|
351
|
+
/** Component used as a template to render items in the list. Must implement {@link DisplayListItem} interface. */
|
|
352
|
+
children: DisplayListItem;
|
|
353
|
+
/** Number of items in the list */
|
|
354
|
+
itemCount: number;
|
|
355
|
+
/** Offset to start of displayed content */
|
|
356
|
+
offset: number;
|
|
357
|
+
/**
|
|
358
|
+
* Implementation of {@link ItemOffsetMapping} interface that defines size and offset to each item in the list
|
|
359
|
+
*
|
|
360
|
+
* Use {@link useFixedSizeItemOffsetMapping} or {@link useVariableSizeItemOffsetMapping} to create implementations
|
|
361
|
+
* for common cases.
|
|
362
|
+
*/
|
|
363
|
+
itemOffsetMapping: ItemOffsetMapping;
|
|
364
|
+
/**
|
|
365
|
+
* Function that defines the key to use for each item given item index and value of {@link DisplayBaseProps.itemData}.
|
|
366
|
+
* @defaultValue `(index, _data) => index`
|
|
367
|
+
*/
|
|
368
|
+
itemKey?: (index: number, data: unknown) => React$1.Key;
|
|
369
|
+
/**
|
|
370
|
+
* Choice of 'vertical' or 'horizontal' layouts
|
|
371
|
+
* @defaultValue 'vertical'
|
|
372
|
+
*/
|
|
373
|
+
layout?: ScrollLayout;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Displays a window onto the contents of a virtualized list starting from `offset`.
|
|
377
|
+
*
|
|
378
|
+
* Accepts props defined by {@link DisplayListProps}.
|
|
379
|
+
* You must pass a single instance of {@link DisplayListItem} as a child.
|
|
380
|
+
* @group Components
|
|
381
|
+
*/
|
|
382
|
+
declare function DisplayList(props: DisplayListProps): react_jsx_runtime.JSX.Element;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Props accepted by {@link DisplayGridItem}
|
|
146
386
|
*/
|
|
147
|
-
interface
|
|
387
|
+
interface DisplayGridItemProps extends DisplayBaseItemProps {
|
|
148
388
|
/** Row index of item in the grid being rendered */
|
|
149
389
|
rowIndex: number;
|
|
150
390
|
/** Column index of item in the grid being rendered */
|
|
151
391
|
columnIndex: number;
|
|
152
392
|
}
|
|
153
393
|
/**
|
|
154
|
-
* Type of item in a {@link
|
|
394
|
+
* Type of item in a {@link DisplayGrid}
|
|
155
395
|
*
|
|
156
|
-
* Must be passed as a child to {@link
|
|
157
|
-
* Accepts props defined by {@link
|
|
158
|
-
* Component must pass {@link
|
|
396
|
+
* Must be passed as a child to {@link DisplayGrid}.
|
|
397
|
+
* Accepts props defined by {@link DisplayGridItemProps}.
|
|
398
|
+
* Component must pass {@link DisplayBaseItemProps.style} to whatever it renders.
|
|
159
399
|
*
|
|
160
400
|
* @example Basic implementation
|
|
161
401
|
* ```
|
|
162
|
-
* const
|
|
163
|
-
* <div className="
|
|
164
|
-
* {
|
|
402
|
+
* const Row = ({ index, style }: { index: number, style: React.CSSProperties }) => (
|
|
403
|
+
* <div className="row" style={style}>
|
|
404
|
+
* { index }
|
|
165
405
|
* </div>
|
|
166
406
|
* );
|
|
167
407
|
* ```
|
|
168
408
|
*/
|
|
169
|
-
type
|
|
409
|
+
type DisplayGridItem = React$1.ComponentType<DisplayGridItemProps>;
|
|
170
410
|
/**
|
|
171
|
-
* Props accepted by {@link
|
|
411
|
+
* Props accepted by {@link DisplayGrid}
|
|
172
412
|
*/
|
|
173
|
-
interface
|
|
174
|
-
/** Component used as a template to render items in the
|
|
175
|
-
children:
|
|
413
|
+
interface DisplayGridProps extends DisplayBaseProps {
|
|
414
|
+
/** Component used as a template to render items in the list. Must implement {@link DisplayGridItem} interface. */
|
|
415
|
+
children: DisplayGridItem;
|
|
176
416
|
/** Number of rows in the grid */
|
|
177
417
|
rowCount: number;
|
|
178
418
|
/**
|
|
@@ -191,27 +431,28 @@ interface VirtualGridProps extends VirtualBaseProps {
|
|
|
191
431
|
* for common cases.
|
|
192
432
|
*/
|
|
193
433
|
columnOffsetMapping: ItemOffsetMapping;
|
|
434
|
+
/** Vertical offset to start of displayed content */
|
|
435
|
+
rowOffset: number;
|
|
436
|
+
/** Horizontal offset to start of displayed content */
|
|
437
|
+
columnOffset: number;
|
|
194
438
|
/**
|
|
195
|
-
* Function that defines the key to use for each item given row and column index and value of {@link
|
|
439
|
+
* Function that defines the key to use for each item given row and column index and value of {@link DisplayBaseProps.itemData}.
|
|
196
440
|
* @defaultValue
|
|
197
441
|
* ```ts
|
|
198
442
|
* (rowIndex, columnIndex, _data) => `${rowIndex}:${columnIndex}`
|
|
199
443
|
* ```
|
|
200
444
|
*/
|
|
201
|
-
itemKey?: (rowIndex: number, columnIndex: number, data: unknown) => React.Key;
|
|
202
|
-
/**
|
|
203
|
-
* Callback after a scroll event has been processed and state updated but before rendering
|
|
204
|
-
* @param rowOffset - Resulting overall row offset. Can be passed to {@link ItemOffsetMapping} to determine first row.
|
|
205
|
-
* @param columnOffset - Resulting overall column offset. Can be passed to {@link ItemOffsetMapping} to determine first column.
|
|
206
|
-
* @param newRowScrollState - New {@link ScrollState} for rows that will be used for rendering.
|
|
207
|
-
* @param newColumnScrollState - New {@link ScrollState} for columns that will be used for rendering.
|
|
208
|
-
*/
|
|
209
|
-
onScroll?: (rowOffset: number, columnOffset: number, newRowScrollState: ScrollState, newColumnScrollState: ScrollState) => void;
|
|
210
|
-
/** Render prop implementing {@link VirtualOuterRender}. Used to customize {@link VirtualGrid}. */
|
|
211
|
-
outerRender?: VirtualOuterRender;
|
|
212
|
-
/** Render prop implementing {@link VirtualInnerRender}. Used to customize {@link VirtualGrid}. */
|
|
213
|
-
innerRender?: VirtualInnerRender;
|
|
445
|
+
itemKey?: (rowIndex: number, columnIndex: number, data: unknown) => React$1.Key;
|
|
214
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* Displays a window onto the contents of a virtualized grid starting from `rowOffset`, `columnOffset`.
|
|
449
|
+
*
|
|
450
|
+
* Accepts props defined by {@link DisplayGridProps}.
|
|
451
|
+
* You must pass a single instance of {@link DisplayGridItem} as a child.
|
|
452
|
+
* @group Components
|
|
453
|
+
*/
|
|
454
|
+
declare function DisplayGrid(props: DisplayGridProps): react_jsx_runtime.JSX.Element;
|
|
455
|
+
|
|
215
456
|
/**
|
|
216
457
|
* Custom ref handle returned by {@link VirtualGrid} that exposes imperative methods
|
|
217
458
|
*
|
|
@@ -226,55 +467,118 @@ interface VirtualGridProxy {
|
|
|
226
467
|
* Scrolls the list so that the specified item is visible
|
|
227
468
|
* @param rowIndex - Row of item to scroll to
|
|
228
469
|
* @param columnIndex - Column of item to scroll to
|
|
470
|
+
* @param option - Where to {@link ScrollToOption | position} the item within the viewport
|
|
229
471
|
*/
|
|
230
|
-
scrollToItem(rowIndex?: number, columnIndex?: number): void;
|
|
472
|
+
scrollToItem(rowIndex?: number, columnIndex?: number, option?: ScrollToOption): void;
|
|
231
473
|
/** Exposes DOM clientWidth property */
|
|
232
474
|
get clientWidth(): number;
|
|
233
475
|
/** Exposes DOM clientHeight property */
|
|
234
476
|
get clientHeight(): number;
|
|
235
477
|
}
|
|
478
|
+
/** Range to scroll to in one dimension specified as (offset,size). May be undefined if no need to scroll. */
|
|
479
|
+
type ScrollRange = [offset: number | undefined, size: number | undefined];
|
|
480
|
+
/**
|
|
481
|
+
* Returns the {@link ScrollRange} corresponding to a specified item.
|
|
482
|
+
*
|
|
483
|
+
* Used internally to implement {@link VirtualGridProxy.scrollToItem}. Can be used directly for
|
|
484
|
+
* advanced customization scenarios.
|
|
485
|
+
*/
|
|
486
|
+
declare function getRangeToScroll(index: number | undefined, mapping: ItemOffsetMapping): ScrollRange;
|
|
487
|
+
/**
|
|
488
|
+
* Same logic as {@link VirtualGridProxy.scrollToItem} usable with your own {@link VirtualScroll}
|
|
489
|
+
*
|
|
490
|
+
* You're encouraged to put together your own combination of {@link VirtualScroll} and {@link DisplayGrid} for
|
|
491
|
+
* advanced customization scenarios. This function provides `ScrollToItem` functionality for use with your own {@link VirtualScroll}.
|
|
492
|
+
*/
|
|
493
|
+
declare function virtualGridScrollToItem(scrollRef: React.RefObject<VirtualScrollProxy>, rowOffsetMapping: ItemOffsetMapping, columnOffsetMapping: ItemOffsetMapping, rowIndex?: number, columnIndex?: number, option?: ScrollToOption): void;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Props accepted by {@link VirtualGrid}
|
|
497
|
+
*/
|
|
498
|
+
interface VirtualGridProps extends VirtualBaseProps {
|
|
499
|
+
/** Component used as a template to render items in the grid. Must implement {@link DisplayGridItem} interface. */
|
|
500
|
+
children: DisplayGridItem;
|
|
501
|
+
/** Number of rows in the grid */
|
|
502
|
+
rowCount: number;
|
|
503
|
+
/**
|
|
504
|
+
* Implementation of {@link ItemOffsetMapping} interface that defines size and offset to each row in the grid
|
|
505
|
+
*
|
|
506
|
+
* Use {@link useFixedSizeItemOffsetMapping} or {@link useVariableSizeItemOffsetMapping} to create implementations
|
|
507
|
+
* for common cases.
|
|
508
|
+
*/
|
|
509
|
+
rowOffsetMapping: ItemOffsetMapping;
|
|
510
|
+
/** Number of columns in the grid */
|
|
511
|
+
columnCount: number;
|
|
512
|
+
/**
|
|
513
|
+
* Implementation of {@link ItemOffsetMapping} interface that defines size and offset to each column in the grid
|
|
514
|
+
*
|
|
515
|
+
* Use {@link useFixedSizeItemOffsetMapping} or {@link useVariableSizeItemOffsetMapping} to create implementations
|
|
516
|
+
* for common cases.
|
|
517
|
+
*/
|
|
518
|
+
columnOffsetMapping: ItemOffsetMapping;
|
|
519
|
+
/**
|
|
520
|
+
* Function that defines the key to use for each item given row and column index and value of {@link VirtualBaseProps.itemData}.
|
|
521
|
+
* @defaultValue
|
|
522
|
+
* ```ts
|
|
523
|
+
* (rowIndex, columnIndex, _data) => `${rowIndex}:${columnIndex}`
|
|
524
|
+
* ```
|
|
525
|
+
*/
|
|
526
|
+
itemKey?: (rowIndex: number, columnIndex: number, data: unknown) => React$1.Key;
|
|
527
|
+
/**
|
|
528
|
+
* Callback after a scroll event has been processed and state updated but before rendering
|
|
529
|
+
* @param rowOffset - Resulting overall row offset. Can be passed to {@link ItemOffsetMapping} to determine first row.
|
|
530
|
+
* @param columnOffset - Resulting overall column offset. Can be passed to {@link ItemOffsetMapping} to determine first column.
|
|
531
|
+
* @param newRowScrollState - New {@link ScrollState} for rows that will be used for rendering.
|
|
532
|
+
* @param newColumnScrollState - New {@link ScrollState} for columns that will be used for rendering.
|
|
533
|
+
*/
|
|
534
|
+
onScroll?: (rowOffset: number, columnOffset: number, newRowScrollState: ScrollState, newColumnScrollState: ScrollState) => void;
|
|
535
|
+
/** Render prop implementing {@link VirtualContainerRender}. Used to customize {@link VirtualGrid} outer container. */
|
|
536
|
+
outerRender?: VirtualContainerRender;
|
|
537
|
+
/** Render prop implementing {@link VirtualContainerRender}. Used to customize {@link DisplayGrid} within {@link VirtualGrid} inner container. */
|
|
538
|
+
innerRender?: VirtualContainerRender;
|
|
539
|
+
}
|
|
236
540
|
/**
|
|
237
541
|
* Virtual Scrolling Grid
|
|
238
542
|
*
|
|
239
543
|
* Accepts props defined by {@link VirtualGridProps}.
|
|
240
544
|
* Refs are forwarded to {@link VirtualGridProxy}.
|
|
241
|
-
* You must pass a single instance of {@link
|
|
545
|
+
* You must pass a single instance of {@link DisplayGridItem} as a child.
|
|
242
546
|
* @group Components
|
|
243
547
|
*/
|
|
244
|
-
declare const VirtualGrid: React.ForwardRefExoticComponent<VirtualGridProps & React.RefAttributes<VirtualGridProxy>>;
|
|
548
|
+
declare const VirtualGrid: React$1.ForwardRefExoticComponent<VirtualGridProps & React$1.RefAttributes<VirtualGridProxy>>;
|
|
245
549
|
|
|
246
|
-
/** Specifies the direction over which the list should implement virtual scrolling */
|
|
247
|
-
type ScrollLayout = "horizontal" | "vertical";
|
|
248
550
|
/**
|
|
249
|
-
*
|
|
551
|
+
* Custom ref handle returned by {@link VirtualList} that exposes imperative methods
|
|
552
|
+
*
|
|
553
|
+
* Use `React.useRef<VirtualListProxy>(null)` to create a ref.
|
|
250
554
|
*/
|
|
251
|
-
interface
|
|
252
|
-
/**
|
|
253
|
-
|
|
555
|
+
interface VirtualListProxy {
|
|
556
|
+
/**
|
|
557
|
+
* Scrolls the list to the specified offset in pixels
|
|
558
|
+
* @param offset - Offset to scroll to
|
|
559
|
+
*/
|
|
560
|
+
scrollTo(offset: number): void;
|
|
561
|
+
/**
|
|
562
|
+
* Scrolls the list so that the specified item is visible
|
|
563
|
+
* @param index - Index of item to scroll to
|
|
564
|
+
* @param option - Where to {@link ScrollToOption | position} the item within the viewport
|
|
565
|
+
*/
|
|
566
|
+
scrollToItem(index: number, option?: ScrollToOption): void;
|
|
254
567
|
}
|
|
255
568
|
/**
|
|
256
|
-
*
|
|
569
|
+
* Same logic as {@link VirtualListProxy.scrollToItem} usable with your own {@link VirtualScroll}
|
|
257
570
|
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
* Component must pass {@link VirtualBaseItemProps.style} to whatever it renders.
|
|
261
|
-
*
|
|
262
|
-
* @example Basic implementation
|
|
263
|
-
* ```
|
|
264
|
-
* const Row = ({ index, style }: { index: number, style: React.CSSProperties }) => (
|
|
265
|
-
* <div className="row" style={style}>
|
|
266
|
-
* { index }
|
|
267
|
-
* </div>
|
|
268
|
-
* );
|
|
269
|
-
* ```
|
|
571
|
+
* You're encouraged to put together your own combination of {@link VirtualScroll} and {@link DisplayList} for
|
|
572
|
+
* advanced customization scenarios. This function provides `ScrollToItem` functionality for use with your own {@link VirtualScroll}.
|
|
270
573
|
*/
|
|
271
|
-
|
|
574
|
+
declare function virtualListScrollToItem(scrollRef: React.RefObject<VirtualScrollProxy>, itemOffsetMapping: ItemOffsetMapping, isVertical: boolean, index: number, option?: ScrollToOption): void;
|
|
575
|
+
|
|
272
576
|
/**
|
|
273
577
|
* Props accepted by {@link VirtualList}
|
|
274
578
|
*/
|
|
275
579
|
interface VirtualListProps extends VirtualBaseProps {
|
|
276
|
-
/** Component used as a template to render items in the list. Must implement {@link
|
|
277
|
-
children:
|
|
580
|
+
/** Component used as a template to render items in the list. Must implement {@link DisplayListItem} interface. */
|
|
581
|
+
children: DisplayListItem;
|
|
278
582
|
/** Number of items in the list */
|
|
279
583
|
itemCount: number;
|
|
280
584
|
/**
|
|
@@ -288,7 +592,7 @@ interface VirtualListProps extends VirtualBaseProps {
|
|
|
288
592
|
* Function that defines the key to use for each item given item index and value of {@link VirtualBaseProps.itemData}.
|
|
289
593
|
* @defaultValue `(index, _data) => index`
|
|
290
594
|
*/
|
|
291
|
-
itemKey?: (index: number, data: unknown) => React.Key;
|
|
595
|
+
itemKey?: (index: number, data: unknown) => React$1.Key;
|
|
292
596
|
/**
|
|
293
597
|
* Choice of 'vertical' or 'horizontal' layouts
|
|
294
598
|
* @defaultValue 'vertical'
|
|
@@ -300,37 +604,20 @@ interface VirtualListProps extends VirtualBaseProps {
|
|
|
300
604
|
* @param newScrollState - New {@link ScrollState} that will be used for rendering.
|
|
301
605
|
*/
|
|
302
606
|
onScroll?: (offset: number, newScrollState: ScrollState) => void;
|
|
303
|
-
/** Render prop implementing {@link
|
|
304
|
-
outerRender?:
|
|
305
|
-
/** Render prop implementing {@link
|
|
306
|
-
innerRender?:
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Custom ref handle returned by {@link VirtualList} that exposes imperative methods
|
|
310
|
-
*
|
|
311
|
-
* Use `React.useRef<VirtualListProxy>(null)` to create a ref.
|
|
312
|
-
*/
|
|
313
|
-
interface VirtualListProxy {
|
|
314
|
-
/**
|
|
315
|
-
* Scrolls the list to the specified offset in pixels
|
|
316
|
-
* @param offset - Offset to scroll to
|
|
317
|
-
*/
|
|
318
|
-
scrollTo(offset: number): void;
|
|
319
|
-
/**
|
|
320
|
-
* Scrolls the list so that the specified item is visible
|
|
321
|
-
* @param index - Index of item to scroll to
|
|
322
|
-
*/
|
|
323
|
-
scrollToItem(index: number): void;
|
|
607
|
+
/** Render prop implementing {@link VirtualContainerRender}. Used to customize {@link VirtualList} outer container. */
|
|
608
|
+
outerRender?: VirtualContainerRender;
|
|
609
|
+
/** Render prop implementing {@link VirtualContainerRender}. Used to customize {@link DisplayList} within {@link VirtualList} inner container. */
|
|
610
|
+
innerRender?: VirtualContainerRender;
|
|
324
611
|
}
|
|
325
612
|
/**
|
|
326
613
|
* Virtual Scrolling List
|
|
327
614
|
*
|
|
328
615
|
* Accepts props defined by {@link VirtualListProps}.
|
|
329
616
|
* Refs are forwarded to {@link VirtualListProxy}.
|
|
330
|
-
* You must pass a single instance of {@link
|
|
617
|
+
* You must pass a single instance of {@link DisplayListItem} as a child.
|
|
331
618
|
* @group Components
|
|
332
619
|
*/
|
|
333
|
-
declare const VirtualList: React.ForwardRefExoticComponent<VirtualListProps & React.RefAttributes<VirtualListProxy>>;
|
|
620
|
+
declare const VirtualList: React$1.ForwardRefExoticComponent<VirtualListProps & React$1.RefAttributes<VirtualListProxy>>;
|
|
334
621
|
|
|
335
622
|
/**
|
|
336
623
|
* Returns an instance of {@link ItemOffsetMapping} suitable for use when all items have a fixed size.
|
|
@@ -347,4 +634,4 @@ declare function useFixedSizeItemOffsetMapping(itemSize: number): ItemOffsetMapp
|
|
|
347
634
|
*/
|
|
348
635
|
declare function useVariableSizeItemOffsetMapping(defaultItemSize: number, sizes?: number[]): ItemOffsetMapping;
|
|
349
636
|
|
|
350
|
-
export { type ItemOffsetMapping, type ScrollDirection, type ScrollEvent, type ScrollLayout, type ScrollState, type
|
|
637
|
+
export { AutoSizer, type AutoSizerProps, type AutoSizerRender, type AutoSizerRenderProps, type ComponentProps, type DisplayBaseItemProps, type DisplayBaseProps, DisplayGrid, type DisplayGridItem, type DisplayGridItemProps, type DisplayGridProps, DisplayList, type DisplayListItem, type DisplayListItemProps, type DisplayListProps, type ItemOffsetMapping, type ScrollDirection, type ScrollEvent, type ScrollLayout, type ScrollRange, type ScrollState, type ScrollToOption, type VirtualBaseProps, VirtualContainer, type VirtualContainerComponentProps, type VirtualContainerRender, type VirtualContainerRenderProps, type VirtualContentProps, type VirtualContentRender, VirtualGrid, type VirtualGridProps, type VirtualGridProxy, VirtualList, type VirtualListProps, type VirtualListProxy, VirtualScroll, type VirtualScrollProps, type VirtualScrollProxy, type VirtualScrollableProps, getOffsetToScrollRange, getRangeToScroll, useFixedSizeItemOffsetMapping, useVariableSizeItemOffsetMapping, virtualGridScrollToItem, virtualListScrollToItem };
|