react-virtuoso 2.8.4 → 2.8.5

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.
Files changed (47) hide show
  1. package/dist/index.d.ts +847 -3
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.m.js +1 -1
  5. package/dist/index.m.js.map +1 -1
  6. package/package.json +6 -2
  7. package/dist/AATree.d.ts +0 -40
  8. package/dist/Grid.d.ts +0 -482
  9. package/dist/List.d.ts +0 -6253
  10. package/dist/Table.d.ts +0 -6085
  11. package/dist/alignToBottomSystem.d.ts +0 -549
  12. package/dist/comparators.d.ts +0 -3
  13. package/dist/components.d.ts +0 -503
  14. package/dist/domIOSystem.d.ts +0 -15
  15. package/dist/followOutputSystem.d.ts +0 -378
  16. package/dist/gridSystem.d.ts +0 -281
  17. package/dist/groupedListSystem.d.ts +0 -75
  18. package/dist/hooks/__mocks__/useChangedChildSizes.d.ts +0 -4
  19. package/dist/hooks/__mocks__/useScrollTop.d.ts +0 -7
  20. package/dist/hooks/__mocks__/useSize.d.ts +0 -3
  21. package/dist/hooks/useChangedChildSizes.d.ts +0 -3
  22. package/dist/hooks/useIsomorphicLayoutEffect.d.ts +0 -3
  23. package/dist/hooks/useScrollTop.d.ts +0 -6
  24. package/dist/hooks/useSize.d.ts +0 -6
  25. package/dist/hooks/useWindowViewportRect.d.ts +0 -2
  26. package/dist/initialItemCountSystem.d.ts +0 -542
  27. package/dist/initialScrollTopSystem.d.ts +0 -560
  28. package/dist/initialTopMostItemIndexSystem.d.ts +0 -163
  29. package/dist/interfaces.d.ts +0 -285
  30. package/dist/listStateSystem.d.ts +0 -489
  31. package/dist/listSystem.d.ts +0 -5426
  32. package/dist/loggerSystem.d.ts +0 -17
  33. package/dist/propsReadySystem.d.ts +0 -12
  34. package/dist/scrollIntoViewSystem.d.ts +0 -645
  35. package/dist/scrollSeekSystem.d.ts +0 -57
  36. package/dist/scrollToIndexSystem.d.ts +0 -81
  37. package/dist/sizeRangeSystem.d.ts +0 -50
  38. package/dist/sizeSystem.d.ts +0 -68
  39. package/dist/stateFlagsSystem.d.ts +0 -65
  40. package/dist/topItemCountSystem.d.ts +0 -489
  41. package/dist/totalListHeightSystem.d.ts +0 -517
  42. package/dist/upwardScrollFixSystem.d.ts +0 -614
  43. package/dist/utils/binaryArraySearch.d.ts +0 -6
  44. package/dist/utils/correctItemSize.d.ts +0 -1
  45. package/dist/utils/positionStickyCssValue.d.ts +0 -1
  46. package/dist/utils/simpleMemoize.d.ts +0 -1
  47. package/dist/windowScrollerSystem.d.ts +0 -35
package/dist/index.d.ts CHANGED
@@ -1,3 +1,847 @@
1
- export * from './components';
2
- export * from './interfaces';
3
- export { LogLevel } from './loggerSystem';
1
+ import { ComponentPropsWithRef } from 'react';
2
+ import { ComponentType } from 'react';
3
+ import { Key } from 'react';
4
+ import { ReactElement } from 'react';
5
+ import { ReactNode } from 'react';
6
+ import { Ref } from 'react';
7
+
8
+ /**
9
+ * Customize the Virtuoso rendering by passing a set of custom components.
10
+ */
11
+ export declare interface Components<Context = unknown> {
12
+ /**
13
+ * Set to render a component at the top of the list.
14
+ *
15
+ * The header remains above the top items and does not remain sticky.
16
+ */
17
+ Header?: ComponentType<{
18
+ context?: Context;
19
+ }>;
20
+ /**
21
+ * Set to render a component at the bottom of the list.
22
+ */
23
+ Footer?: ComponentType<{
24
+ context?: Context;
25
+ }>;
26
+ /**
27
+ * Set to customize the item wrapping element. Use only if you would like to render list from elements different than a `div`.
28
+ */
29
+ Item?: ComponentType<ItemProps & {
30
+ context?: Context;
31
+ }>;
32
+ /**
33
+ * Set to customize the group item wrapping element. Use only if you would like to render list from elements different than a `div`.
34
+ */
35
+ Group?: ComponentType<GroupProps & {
36
+ context?: Context;
37
+ }>;
38
+ /**
39
+ * Set to customize the top list item wrapping element. Use if you would like to render list from elements different than a `div`
40
+ * or you want to set a custom z-index for the sticky position.
41
+ */
42
+ TopItemList?: ComponentType<TopItemListProps & {
43
+ context?: Context;
44
+ }>;
45
+ /**
46
+ * Set to customize the outermost scrollable element. This should not be necessary in general,
47
+ * as the component passes its HTML attribute props to it.
48
+ */
49
+ Scroller?: ComponentType<ScrollerProps & {
50
+ context?: Context;
51
+ }>;
52
+ /**
53
+ * Set to customize the items wrapper. Use only if you would like to render list from elements different than a `div`.
54
+ */
55
+ List?: ComponentType<ListProps & {
56
+ context?: Context;
57
+ }>;
58
+ /**
59
+ * Set to render a custom UI when the list is empty.
60
+ */
61
+ EmptyPlaceholder?: ComponentType<{
62
+ context?: Context;
63
+ }>;
64
+ /**
65
+ * Set to render an item placeholder when the user scrolls fast. See the `scrollSeek` property for more details.
66
+ */
67
+ ScrollSeekPlaceholder?: ComponentType<ScrollSeekPlaceholderProps & {
68
+ context?: Context;
69
+ }>;
70
+ }
71
+
72
+ export declare interface ComputeItemKey<D, C> {
73
+ (index: number, item: D, context: C): Key;
74
+ }
75
+
76
+ export declare type FixedHeaderContent = (() => React.ReactChildren | React.ReactNode) | null;
77
+
78
+ export declare type FollowOutput = FollowOutputCallback | FollowOutputScalarType;
79
+
80
+ export declare type FollowOutputCallback = (isAtBottom: boolean) => FollowOutputScalarType;
81
+
82
+ export declare type FollowOutputScalarType = boolean | 'smooth' | 'auto';
83
+
84
+ export declare interface GridComponents<Context = any> {
85
+ /**
86
+ * Set to customize the item wrapping element. Use only if you would like to render list from elements different than a `div`.
87
+ */
88
+ Item?: ComponentType<GridItem & {
89
+ context?: Context;
90
+ }>;
91
+ /**
92
+ * Set to customize the outermost scrollable element. This should not be necessary in general,
93
+ * as the component passes its HTML attribute props to it.
94
+ */
95
+ Scroller?: ComponentType<ScrollerProps & {
96
+ context?: Context;
97
+ }>;
98
+ /**
99
+ * Set to customize the items wrapper. Use only if you would like to render list from elements different than a `div`.
100
+ */
101
+ List?: ComponentType<GridListProps & {
102
+ context?: Context;
103
+ }>;
104
+ /**
105
+ * Set to render an item placeholder when the user scrolls fast.
106
+ * See the `scrollSeekConfiguration` property for more details.
107
+ */
108
+ ScrollSeekPlaceholder?: ComponentType<GridScrollSeekPlaceholderProps & {
109
+ context?: Context;
110
+ }>;
111
+ }
112
+
113
+ export declare interface GridComputeItemKey {
114
+ (index: number): Key;
115
+ }
116
+
117
+ export declare interface GridItem {
118
+ 'data-index': number;
119
+ className?: string;
120
+ }
121
+
122
+ export declare interface GridItemContent<C> {
123
+ (index: number, context: C): ReactNode;
124
+ }
125
+
126
+ /**
127
+ * Passed to the Components.List custom component
128
+ */
129
+ export declare type GridListProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children' | 'ref' | 'className'>;
130
+
131
+ export declare type GridRootProps = Omit<React.HTMLProps<'div'>, 'ref' | 'data'>;
132
+
133
+ /**
134
+ * Passed to the GridComponents.ScrollSeekPlaceholder custom component
135
+ */
136
+ export declare interface GridScrollSeekPlaceholderProps {
137
+ index: number;
138
+ height: number;
139
+ width: number;
140
+ }
141
+
142
+ export declare interface GroupContent {
143
+ (index: number): ReactNode;
144
+ }
145
+
146
+ export declare const GroupedVirtuoso: <ItemData extends unknown = any, Context extends unknown = any>(props: GroupedVirtuosoProps<ItemData, Context> & {
147
+ ref?: Ref<GroupedVirtuosoHandle> | undefined;
148
+ }) => ReactElement;
149
+
150
+ export declare interface GroupedVirtuosoHandle {
151
+ scrollToIndex(location: number | IndexLocationWithAlign): void;
152
+ scrollTo(location: ScrollToOptions): void;
153
+ scrollBy(location: ScrollToOptions): void;
154
+ }
155
+
156
+ export declare interface GroupedVirtuosoProps<D, C> extends Omit<VirtuosoProps<D, C>, 'totalCount' | 'itemContent'> {
157
+ /**
158
+ * Specifies the amount of items in each group (and, actually, how many groups are there).
159
+ * For example, passing [20, 30] will display 2 groups with 20 and 30 items each.
160
+ */
161
+ groupCounts?: number[];
162
+ /**
163
+ * Specifies how each each group header gets rendered. The callback receives the zero-based index of the group.
164
+ */
165
+ groupContent?: GroupContent;
166
+ /**
167
+ * Specifies how each each item gets rendered.
168
+ */
169
+ itemContent?: GroupItemContent<D, C>;
170
+ }
171
+
172
+ export declare interface GroupItem<D> extends Item<D> {
173
+ type: 'group';
174
+ originalIndex?: number;
175
+ }
176
+
177
+ export declare interface GroupItemContent<D, C> {
178
+ (index: number, groupIndex: number, data: D, context: C): ReactNode;
179
+ }
180
+
181
+ export declare interface GroupProps {
182
+ 'data-index': number;
183
+ 'data-item-index': number;
184
+ 'data-known-size': number;
185
+ }
186
+
187
+ export declare interface IndexLocationWithAlign {
188
+ /**
189
+ * The index of the item to scroll to.
190
+ */
191
+ index: number | 'LAST';
192
+ /**
193
+ * How to position the item in the viewport.
194
+ */
195
+ align?: 'start' | 'center' | 'end';
196
+ /**
197
+ * Set 'smooth' to have an animated transition to the specified location.
198
+ */
199
+ behavior?: 'smooth' | 'auto';
200
+ /**
201
+ * The offset to scroll.
202
+ */
203
+ offset?: number;
204
+ }
205
+
206
+ export declare interface Item<D> {
207
+ index: number;
208
+ offset: number;
209
+ size: number;
210
+ data?: D;
211
+ }
212
+
213
+ export declare interface ItemContent<D, C> {
214
+ (index: number, data: D, context: C): ReactNode;
215
+ }
216
+
217
+ export declare interface ItemProps {
218
+ 'data-index': number;
219
+ 'data-item-index': number;
220
+ 'data-item-group-index'?: number;
221
+ 'data-known-size': number;
222
+ }
223
+
224
+ export declare type ListItem<D> = RecordItem<D> | GroupItem<D>;
225
+
226
+ /**
227
+ * Passed to the Components.List custom component
228
+ */
229
+ export declare type ListProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children' | 'ref'> & {
230
+ 'data-test-id': string;
231
+ };
232
+
233
+ export declare interface ListRange {
234
+ startIndex: number;
235
+ endIndex: number;
236
+ }
237
+
238
+ export declare type ListRootProps = Omit<React.HTMLProps<'div'>, 'ref' | 'data'>;
239
+
240
+ export declare enum LogLevel {
241
+ DEBUG = 0,
242
+ INFO = 1,
243
+ WARN = 2,
244
+ ERROR = 3
245
+ }
246
+
247
+ export declare interface RecordItem<D> extends Item<D> {
248
+ type?: undefined;
249
+ groupIndex?: number;
250
+ originalIndex?: number;
251
+ data?: D;
252
+ }
253
+
254
+ /**
255
+ * Passed to the Components.Scroller custom component
256
+ */
257
+ export declare type ScrollerProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children' | 'tabIndex' | 'ref'> & {
258
+ 'data-test-id'?: string;
259
+ 'data-virtuoso-scroller'?: boolean;
260
+ };
261
+
262
+ export declare interface ScrollIntoViewLocation {
263
+ index: number;
264
+ behavior?: 'auto' | 'smooth';
265
+ done?: () => void;
266
+ }
267
+
268
+ export declare interface ScrollSeekConfiguration {
269
+ /**
270
+ * Callback to determine if the list should enter "scroll seek" mode.
271
+ */
272
+ enter: ScrollSeekToggle;
273
+ /**
274
+ * called during scrolling in scroll seek mode - use to display a hint where the list is.
275
+ */
276
+ change?: (velocity: number, range: ListRange) => void;
277
+ /**
278
+ * Callback to determine if the list should enter "scroll seek" mode.
279
+ */
280
+ exit: ScrollSeekToggle;
281
+ }
282
+
283
+ /**
284
+ * Passed to the Components.ScrollSeekPlaceholder custom component
285
+ */
286
+ export declare interface ScrollSeekPlaceholderProps {
287
+ index: number;
288
+ height: number;
289
+ groupIndex?: number;
290
+ type: 'group' | 'item';
291
+ }
292
+
293
+ export declare interface ScrollSeekToggle {
294
+ (velocity: number, range: ListRange): boolean;
295
+ }
296
+
297
+ /**
298
+ * Passed to the Components.TableBody custom component
299
+ */
300
+ export declare type TableBodyProps = Pick<ComponentPropsWithRef<'tbody'>, 'style' | 'children' | 'ref' | 'className'> & {
301
+ 'data-test-id': string;
302
+ };
303
+
304
+ /**
305
+ * Customize the TableVirtuoso rendering by passing a set of custom components.
306
+ */
307
+ export declare interface TableComponents<Context = unknown> {
308
+ /**
309
+ * Set to customize the wrapping `table` element.
310
+ *
311
+ */
312
+ Table?: ComponentType<TableProps & {
313
+ context?: Context;
314
+ }>;
315
+ /**
316
+ * Set to render a fixed header at the top of the table (`thead`). use [[fixedHeaderHeight]] to set the contents
317
+ *
318
+ */
319
+ TableHead?: ComponentType<{
320
+ context?: Context;
321
+ }>;
322
+ /**
323
+ * Set to customize the item wrapping element. Default is `tr`.
324
+ */
325
+ TableRow?: ComponentType<ItemProps & {
326
+ context?: Context;
327
+ }>;
328
+ /**
329
+ * Set to customize the outermost scrollable element. This should not be necessary in general,
330
+ * as the component passes its HTML attribute props to it.
331
+ */
332
+ Scroller?: ComponentType<ScrollerProps & {
333
+ context?: Context;
334
+ }>;
335
+ /**
336
+ * Set to customize the items wrapper. Default is `tbody`.
337
+ */
338
+ TableBody?: ComponentType<TableBodyProps & {
339
+ context?: Context;
340
+ }>;
341
+ /**
342
+ * Set to render a custom UI when the list is empty.
343
+ */
344
+ EmptyPlaceholder?: ComponentType<{
345
+ context?: Context;
346
+ }>;
347
+ /**
348
+ * Set to render an item placeholder when the user scrolls fast. See the `scrollSeek` property for more details.
349
+ */
350
+ ScrollSeekPlaceholder?: ComponentType<ScrollSeekPlaceholderProps & {
351
+ context?: Context;
352
+ }>;
353
+ }
354
+
355
+ export declare type TableProps = Pick<ComponentPropsWithRef<'table'>, 'style'>;
356
+
357
+ export declare type TableRootProps = Omit<React.HTMLProps<'table'>, 'ref' | 'data'>;
358
+
359
+ export declare const TableVirtuoso: <ItemData extends unknown = any, Context extends unknown = any>(props: TableVirtuosoProps<ItemData, Context> & {
360
+ ref?: Ref<TableVirtuosoHandle> | undefined;
361
+ }) => ReactElement;
362
+
363
+ export declare interface TableVirtuosoHandle {
364
+ scrollIntoView(location: ScrollIntoViewLocation): void;
365
+ scrollToIndex(location: number | IndexLocationWithAlign): void;
366
+ scrollTo(location: ScrollToOptions): void;
367
+ scrollBy(location: ScrollToOptions): void;
368
+ }
369
+
370
+ export declare interface TableVirtuosoProps<D, C> extends Omit<VirtuosoProps<D, C>, 'components' | 'headerFooterTag' | 'topItemCount'> {
371
+ /**
372
+ * Use the `components` property for advanced customization of the elements rendered by the table.
373
+ */
374
+ components?: TableComponents<C>;
375
+ /**
376
+ * Set the contents of the table header.
377
+ */
378
+ fixedHeaderContent?: FixedHeaderContent;
379
+ /**
380
+ * The total amount of items to be rendered.
381
+ */
382
+ totalCount?: number;
383
+ /**
384
+ * The data items to be rendered. If data is set, the total count will be inferred from the length of the array.
385
+ */
386
+ data?: readonly D[];
387
+ /**
388
+ * Set the overscan property to make the component "chunk" the rendering of new items on scroll.
389
+ * The property causes the component to render more items than the necessary, but reduces the re-renders on scroll.
390
+ * Setting `{ main: number, reverse: number }` lets you extend the list in both the main and the reverse scrollable directions.
391
+ * See the `increaseViewportBy` property for a similar behavior (equivalent to the `overscan` in `react-window`).
392
+ */
393
+ overscan?: number | {
394
+ main: number;
395
+ reverse: number;
396
+ };
397
+ /**
398
+ * Set the increaseViewportBy property to artificially increase the viewport size, causing items to be rendered before outside of the viewport.
399
+ * The property causes the component to render more items than the necessary, but can help with slow loading content.
400
+ * Using `{ top?: number, bottom?: number }` lets you set the increase for each end separately.
401
+ */
402
+ increaseViewportBy?: number | {
403
+ top: number;
404
+ bottom: number;
405
+ };
406
+ /**
407
+ * Set to a value between 0 and totalCount - 1 to make the list start scrolled to that item.
408
+ */
409
+ initialTopMostItemIndex?: number;
410
+ /**
411
+ * Set this value to offset the initial location of the list.
412
+ * Warning: using this property will still run a render cycle at the scrollTop: 0 list window.
413
+ * If possible, avoid using it and stick to `initialTopMostItemIndex` instead.
414
+ */
415
+ initialScrollTop?: number;
416
+ /**
417
+ * Use for server-side rendering - if set, the list will render the specified amount of items
418
+ * regardless of the container / item size.
419
+ */
420
+ initialItemCount?: number;
421
+ /**
422
+ * Set the callback to specify the contents of the item.
423
+ */
424
+ itemContent?: ItemContent<D, C>;
425
+ /**
426
+ * If specified, the component will use the function to generate the `key` property for each list item.
427
+ */
428
+ computeItemKey?: ComputeItemKey<D, C>;
429
+ /**
430
+ * By default, the component assumes the default item height from the first rendered item (rendering it as a "probe").
431
+ *
432
+ * If the first item turns out to be an outlier (very short or tall), the rest of the rendering will be slower,
433
+ * as multiple passes of rendering should happen for the list to fill the viewport.
434
+ *
435
+ * Setting `defaultItemHeight` causes the component to skip the "probe" rendering and use the property
436
+ * value as default height instead.
437
+ */
438
+ defaultItemHeight?: number;
439
+ /**
440
+ * Allows customizing the height/width calculation of `Item` elements.
441
+ *
442
+ * The default implementation reads `el.getBoundingClientRect().height` and `el.getBoundingClientRect().width`.
443
+ */
444
+ itemSize?: (el: HTMLElement, field: 'offsetHeight' | 'offsetWidth') => number;
445
+ /**
446
+ * Can be used to improve performance if the rendered items are of known size.
447
+ * Setting it causes the component to skip item measurements.
448
+ */
449
+ fixedItemHeight?: number;
450
+ /**
451
+ * Use to display placeholders if the user scrolls fast through the list.
452
+ *
453
+ * Set `components.ScrollSeekPlaceholder` to change the placeholder content.
454
+ */
455
+ scrollSeekConfiguration?: ScrollSeekConfiguration | false;
456
+ /**
457
+ * If set to `true`, the list automatically scrolls to bottom if the total count is changed.
458
+ * Set to `"smooth"` for an animated scrolling.
459
+ *
460
+ * By default, `followOutput` scrolls down only if the list is already at the bottom.
461
+ * To implement an arbitrary logic behind that, pass a function:
462
+ *
463
+ * ```tsx
464
+ * <Virtuoso
465
+ * followOutput={(isAtBottom: boolean) => {
466
+ * if (expression) {
467
+ * return 'smooth' // can be 'auto' or false to avoid scrolling
468
+ * } else {
469
+ * return false
470
+ * }
471
+ * }} />
472
+ * ```
473
+ */
474
+ followOutput?: FollowOutput;
475
+ /**
476
+ * Use when implementing inverse infinite scrolling - decrease the value this property
477
+ * in combination with `data` or `totalCount` to prepend items to the top of the list.
478
+ *
479
+ * Warning: the firstItemIndex should **be a positive number**, based on the total amount of items to be displayed.
480
+ */
481
+ firstItemIndex?: number;
482
+ /**
483
+ * Called when the list starts/stops scrolling.
484
+ */
485
+ isScrolling?: (isScrolling: boolean) => void;
486
+ /**
487
+ * Gets called when the user scrolls to the end of the list.
488
+ * Receives the last item index as an argument. Can be used to implement endless scrolling.
489
+ */
490
+ endReached?: (index: number) => void;
491
+ /**
492
+ * Called when the user scrolls to the start of the list.
493
+ */
494
+ startReached?: (index: number) => void;
495
+ /**
496
+ * Called with the new set of items each time the list items are rendered due to scrolling.
497
+ */
498
+ rangeChanged?: (range: ListRange) => void;
499
+ /**
500
+ * Called with true / false when the list has reached the bottom / gets scrolled up.
501
+ * Can be used to load newer items, like `tail -f`.
502
+ */
503
+ atBottomStateChange?: (atBottom: boolean) => void;
504
+ /**
505
+ * Called with `true` / `false` when the list has reached the top / gets scrolled down.
506
+ */
507
+ atTopStateChange?: (atTop: boolean) => void;
508
+ /**
509
+ * Called when the total list height is changed due to new items or viewport resize.
510
+ */
511
+ totalListHeightChanged?: (height: number) => void;
512
+ /**
513
+ * Called with the new set of items each time the list items are rendered due to scrolling.
514
+ */
515
+ itemsRendered?: (items: ListItem<D>[]) => void;
516
+ /**
517
+ * Setting `alignToBottom` to `true` aligns the items to the bottom of the list if the list is shorter than the viewport.
518
+ * Use `followOutput` property to keep the list aligned when new items are appended.
519
+ */
520
+ alignToBottom?: boolean;
521
+ /**
522
+ * Uses the document scroller rather than wrapping the list in its own.
523
+ */
524
+ useWindowScroll?: boolean;
525
+ /**
526
+ * Pass a reference to a scrollable parent element, so that the table won't wrap in its own.
527
+ */
528
+ customScrollParent?: HTMLElement;
529
+ /**
530
+ * Provides access to the root DOM element
531
+ */
532
+ scrollerRef?: (ref: HTMLElement | Window | null) => any;
533
+ /**
534
+ * By default `4`. Redefine to change how much away from the bottom the scroller can be before the list is not considered not at bottom.
535
+ */
536
+ atBottomThreshold?: number;
537
+ }
538
+
539
+ export declare type TopItemListProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children'>;
540
+
541
+ export declare const Virtuoso: <ItemData extends unknown = any, Context extends unknown = any>(props: VirtuosoProps<ItemData, Context> & {
542
+ ref?: Ref<VirtuosoHandle> | undefined;
543
+ }) => ReactElement;
544
+
545
+ export declare const VirtuosoGrid: <Context extends unknown = any>(props: VirtuosoGridProps<Context> & {
546
+ ref?: Ref<VirtuosoGridHandle> | undefined;
547
+ }) => ReactElement;
548
+
549
+ export declare interface VirtuosoGridHandle {
550
+ scrollToIndex(location: number | IndexLocationWithAlign): void;
551
+ scrollTo(location: ScrollToOptions): void;
552
+ scrollBy(location: ScrollToOptions): void;
553
+ }
554
+
555
+ export declare interface VirtuosoGridProps<C extends unknown = unknown> {
556
+ /**
557
+ * The total amount of items to be rendered.
558
+ */
559
+ totalCount: number;
560
+ /**
561
+ * Set the callback to specify the contents of the item.
562
+ */
563
+ itemContent?: GridItemContent<C>;
564
+ /**
565
+ * Use the `components` property for advanced customization of the elements rendered by the list.
566
+ */
567
+ components?: GridComponents<C>;
568
+ /**
569
+ * Set the overscan property to make the component "chunk" the rendering of new items on scroll.
570
+ * The property causes the component to render more items than the necessary, but reduces the re-renders on scroll.
571
+ * Setting `{ main: number, reverse: number }` lets you extend the list in both the main and the reverse scrollable directions.
572
+ */
573
+ overscan?: number | {
574
+ main: number;
575
+ reverse: number;
576
+ };
577
+ /**
578
+ * If specified, the component will use the function to generate the `key` property for each list item.
579
+ */
580
+ computeItemKey?: GridComputeItemKey;
581
+ /**
582
+ * Use to display placeholders if the user scrolls fast through the list.
583
+ *
584
+ * Set `components.ScrollSeekPlaceholder` to change the placeholder content.
585
+ */
586
+ scrollSeekConfiguration?: ScrollSeekConfiguration | false;
587
+ /**
588
+ * Called when the list starts/stops scrolling.
589
+ */
590
+ isScrolling?: (isScrolling: boolean) => void;
591
+ /**
592
+ * Gets called when the user scrolls to the end of the list.
593
+ * Receives the last item index as an argument. Can be used to implement endless scrolling.
594
+ */
595
+ endReached?: (index: number) => void;
596
+ /**
597
+ * Called when the user scrolls to the start of the list.
598
+ */
599
+ startReached?: (index: number) => void;
600
+ /**
601
+ * Called with the new set of items each time the list items are rendered due to scrolling.
602
+ */
603
+ rangeChanged?: (range: ListRange) => void;
604
+ /**
605
+ * Called with true / false when the list has reached the bottom / gets scrolled up.
606
+ * Can be used to load newer items, like `tail -f`.
607
+ */
608
+ atBottomStateChange?: (atBottom: boolean) => void;
609
+ /**
610
+ * Called with `true` / `false` when the list has reached the top / gets scrolled down.
611
+ */
612
+ atTopStateChange?: (atTop: boolean) => void;
613
+ /**
614
+ * Provides access to the root DOM element
615
+ */
616
+ scrollerRef?: (ref: HTMLElement | null) => any;
617
+ /**
618
+ * Sets the className for the list DOM element
619
+ */
620
+ listClassName?: string;
621
+ /**
622
+ * Sets the grid items' className
623
+ */
624
+ itemClassName?: string;
625
+ /**
626
+ * Uses the document scroller rather than wrapping the grid in its own.
627
+ */
628
+ useWindowScroll?: boolean;
629
+ /**
630
+ * Pass a reference to a scrollable parent element, so that the grid won't wrap in its own.
631
+ */
632
+ customScrollParent?: HTMLElement;
633
+ }
634
+
635
+ export declare interface VirtuosoHandle {
636
+ /**
637
+ * Scrolls the component to the specified item index. See {@link IndexLocationWithAlign} for more options.
638
+ */
639
+ scrollToIndex(location: number | IndexLocationWithAlign): void;
640
+ /**
641
+ * Scrolls the item into view if necessary. See [the website example](http://virtuoso.dev/keyboard-navigation/) for an implementation.
642
+ */
643
+ scrollIntoView(location: ScrollIntoViewLocation): void;
644
+ /**
645
+ * Scrolls the component to the specified location. See [ScrollToOptions (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions)
646
+ */
647
+ scrollTo(location: ScrollToOptions): void;
648
+ /**
649
+ * Scrolls the component with the specified amount. See [ScrollToOptions (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions)
650
+ */
651
+ scrollBy(location: ScrollToOptions): void;
652
+ }
653
+
654
+ export declare interface VirtuosoProps<D, C> {
655
+ /**
656
+ * The total amount of items to be rendered.
657
+ */
658
+ totalCount?: number;
659
+ /**
660
+ * The data items to be rendered. If data is set, the total count will be inferred from the length of the array.
661
+ */
662
+ data?: readonly D[];
663
+ /**
664
+ * Additional context available in the custom components and content callbacks
665
+ */
666
+ context?: C;
667
+ /**
668
+ * *The property accepts pixel values.*
669
+ *
670
+ * Set the overscan property to make the component "chunk" the rendering of new items on scroll.
671
+ * The property causes the component to render more items than the necessary, but reduces the re-renders on scroll.
672
+ * Setting `{ main: number, reverse: number }` lets you extend the list in both the main and the reverse scrollable directions.
673
+ * See the `increaseViewportBy` property for a similar behavior (equivalent to the `overscan` in react-window).
674
+ *
675
+ */
676
+ overscan?: number | {
677
+ main: number;
678
+ reverse: number;
679
+ };
680
+ /**
681
+ *
682
+ * *The property accepts pixel values.*
683
+ *
684
+ * Set the increaseViewportBy property to artificially increase the viewport size, causing items to be rendered before outside of the viewport.
685
+ * The property causes the component to render more items than the necessary, but can help with slow loading content.
686
+ * Using `{ top?: number, bottom?: number }` lets you set the increase for each end separately.
687
+ *
688
+ */
689
+ increaseViewportBy?: number | {
690
+ top: number;
691
+ bottom: number;
692
+ };
693
+ /**
694
+ * Set the amount of items to remain fixed at the top of the list.
695
+ *
696
+ * For a header that scrolls away when scrolling, check the `components.Header` property.
697
+ */
698
+ topItemCount?: number;
699
+ /**
700
+ * Set to a value between 0 and totalCount - 1 to make the list start scrolled to that item.
701
+ * Pass in an object to achieve additional effects similar to `scrollToIndex`.
702
+ */
703
+ initialTopMostItemIndex?: number | IndexLocationWithAlign;
704
+ /**
705
+ * Set this value to offset the initial location of the list.
706
+ * Warning: using this property will still run a render cycle at the scrollTop: 0 list window.
707
+ * If possible, avoid using it and stick to `initialTopMostItemIndex` instead.
708
+ */
709
+ initialScrollTop?: number;
710
+ /**
711
+ * Use for server-side rendering - if set, the list will render the specified amount of items
712
+ * regardless of the container / item size.
713
+ */
714
+ initialItemCount?: number;
715
+ /**
716
+ * Use the `components` property for advanced customization of the elements rendered by the list.
717
+ */
718
+ components?: Components<C>;
719
+ /**
720
+ * Set the callback to specify the contents of the item.
721
+ */
722
+ itemContent?: ItemContent<D, C>;
723
+ /**
724
+ * If specified, the component will use the function to generate the `key` property for each list item.
725
+ */
726
+ computeItemKey?: ComputeItemKey<D, C>;
727
+ /**
728
+ * By default, the component assumes the default item height from the first rendered item (rendering it as a "probe").
729
+ *
730
+ * If the first item turns out to be an outlier (very short or tall), the rest of the rendering will be slower,
731
+ * as multiple passes of rendering should happen for the list to fill the viewport.
732
+ *
733
+ * Setting `defaultItemHeight` causes the component to skip the "probe" rendering and use the property
734
+ * value as default height instead.
735
+ */
736
+ defaultItemHeight?: number;
737
+ /**
738
+ * Allows customizing the height/width calculation of `Item` elements.
739
+ *
740
+ * The default implementation reads `el.getBoundingClientRect().height` and `el.getBoundingClientRect().width`.
741
+ */
742
+ itemSize?: (el: HTMLElement, field: 'offsetHeight' | 'offsetWidth') => number;
743
+ /**
744
+ * Can be used to improve performance if the rendered items are of known size.
745
+ * Setting it causes the component to skip item measurements.
746
+ */
747
+ fixedItemHeight?: number;
748
+ /**
749
+ * Use to display placeholders if the user scrolls fast through the list.
750
+ *
751
+ * Set `components.ScrollSeekPlaceholder` to change the placeholder content.
752
+ */
753
+ scrollSeekConfiguration?: ScrollSeekConfiguration | false;
754
+ /**
755
+ * If set to `true`, the list automatically scrolls to bottom if the total count is changed.
756
+ * Set to `"smooth"` for an animated scrolling.
757
+ *
758
+ * By default, `followOutput` scrolls down only if the list is already at the bottom.
759
+ * To implement an arbitrary logic behind that, pass a function:
760
+ *
761
+ * ```tsx
762
+ * <Virtuoso
763
+ * followOutput={(isAtBottom: boolean) => {
764
+ * if (expression) {
765
+ * return 'smooth' // can be 'auto' or false to avoid scrolling
766
+ * } else {
767
+ * return false
768
+ * }
769
+ * }} />
770
+ * ```
771
+ */
772
+ followOutput?: FollowOutput;
773
+ /**
774
+ * Set to customize the wrapper tag for the header and footer components (default is `div`).
775
+ */
776
+ headerFooterTag?: string;
777
+ /**
778
+ * Use when implementing inverse infinite scrolling - decrease the value this property
779
+ * in combination with `data` or `totalCount` to prepend items to the top of the list.
780
+ *
781
+ * Warning: the firstItemIndex should **be a positive number**, based on the total amount of items to be displayed.
782
+ */
783
+ firstItemIndex?: number;
784
+ /**
785
+ * Called when the list starts/stops scrolling.
786
+ */
787
+ isScrolling?: (isScrolling: boolean) => void;
788
+ /**
789
+ * Gets called when the user scrolls to the end of the list.
790
+ * Receives the last item index as an argument. Can be used to implement endless scrolling.
791
+ */
792
+ endReached?: (index: number) => void;
793
+ /**
794
+ * Called when the user scrolls to the start of the list.
795
+ */
796
+ startReached?: (index: number) => void;
797
+ /**
798
+ * Called with the new set of items each time the list items are rendered due to scrolling.
799
+ */
800
+ rangeChanged?: (range: ListRange) => void;
801
+ /**
802
+ * Called with true / false when the list has reached the bottom / gets scrolled up.
803
+ * Can be used to load newer items, like `tail -f`.
804
+ */
805
+ atBottomStateChange?: (atBottom: boolean) => void;
806
+ /**
807
+ * Called with `true` / `false` when the list has reached the top / gets scrolled down.
808
+ */
809
+ atTopStateChange?: (atTop: boolean) => void;
810
+ /**
811
+ * Called when the total list height is changed due to new items or viewport resize.
812
+ */
813
+ totalListHeightChanged?: (height: number) => void;
814
+ /**
815
+ * Called with the new set of items each time the list items are rendered due to scrolling.
816
+ */
817
+ itemsRendered?: (items: ListItem<D>[]) => void;
818
+ /**
819
+ * Setting `alignToBottom` to `true` aligns the items to the bottom of the list if the list is shorter than the viewport.
820
+ * Use `followOutput` property to keep the list aligned when new items are appended.
821
+ */
822
+ alignToBottom?: boolean;
823
+ /**
824
+ * Uses the document scroller rather than wrapping the list in its own.
825
+ */
826
+ useWindowScroll?: boolean;
827
+ /**
828
+ * Pass a reference to a scrollable parent element, so that the list won't wrap in its own.
829
+ */
830
+ customScrollParent?: HTMLElement;
831
+ /**
832
+ * Provides access to the root DOM element
833
+ */
834
+ scrollerRef?: (ref: HTMLElement | Window | null) => any;
835
+ /**
836
+ * By default `4`. Redefine to change how much away from the bottom the scroller can be before the list is not considered not at bottom.
837
+ */
838
+ atBottomThreshold?: number;
839
+ }
840
+
841
+ export declare interface WindowViewportInfo {
842
+ offsetTop: number;
843
+ visibleHeight: number;
844
+ visibleWidth: number;
845
+ }
846
+
847
+ export { }