react-virtuoso 2.5.2 → 2.8.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.
- package/dist/AATree.d.ts +40 -40
- package/dist/Grid.d.ts +482 -433
- package/dist/List.d.ts +6041 -5736
- package/dist/Table.d.ts +5875 -5605
- package/dist/TableVirtuoso.js +2 -0
- package/dist/TableVirtuoso.js.map +1 -0
- package/dist/TableVirtuoso.mjs +2 -0
- package/dist/TableVirtuoso.mjs.map +1 -0
- package/dist/VirtuosoGrid.js +2 -0
- package/dist/VirtuosoGrid.js.map +1 -0
- package/dist/VirtuosoGrid.mjs +2 -0
- package/dist/VirtuosoGrid.mjs.map +1 -0
- package/dist/alignToBottomSystem.d.ts +529 -519
- package/dist/comparators.d.ts +3 -3
- package/dist/components/CompProps.d.ts +2 -0
- package/dist/components/GroupedVirtuoso.d.ts +27 -0
- package/dist/components/TableVirtuoso.d.ts +5717 -0
- package/dist/components/Virtuoso.d.ts +205 -0
- package/dist/components/VirtuosoGrid.d.ts +93 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components.d.ts +1145 -56
- package/dist/domIOSystem.d.ts +15 -15
- package/dist/followOutputSystem.d.ts +362 -354
- package/dist/gridSystem.d.ts +281 -278
- package/dist/groupedListSystem.d.ts +71 -69
- package/dist/hooks/__mocks__/useChangedChildSizes.d.ts +4 -4
- package/dist/hooks/__mocks__/useScrollTop.d.ts +7 -7
- package/dist/hooks/__mocks__/useSize.d.ts +3 -3
- package/dist/hooks/useChangedChildSizes.d.ts +3 -3
- package/dist/hooks/useIsomorphicLayoutEffect.d.ts +3 -3
- package/dist/hooks/useScrollTop.d.ts +6 -6
- package/dist/hooks/useSize.d.ts +6 -6
- package/dist/hooks/useWindowViewportRect.d.ts +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.m.js.map +1 -1
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/initialItemCountSystem.d.ts +518 -506
- package/dist/initialScrollTopSystem.d.ts +540 -530
- package/dist/initialTopMostItemIndexSystem.d.ts +153 -149
- package/dist/interfaces.d.ts +279 -239
- package/dist/listStateSystem.d.ts +469 -459
- package/dist/listSystem.d.ts +5214 -5102
- package/dist/loggerSystem.d.ts +17 -17
- package/dist/propsReadySystem.d.ts +12 -12
- package/dist/scrollIntoViewSystem.d.ts +617 -603
- package/dist/scrollSeekSystem.d.ts +57 -57
- package/dist/scrollToIndexSystem.d.ts +77 -75
- package/dist/shared.js +2 -0
- package/dist/shared.js.map +1 -0
- package/dist/shared.mjs +2 -0
- package/dist/shared.mjs.map +1 -0
- package/dist/sizeRangeSystem.d.ts +50 -50
- package/dist/sizeSystem.d.ts +66 -65
- package/dist/stateFlagsSystem.d.ts +65 -65
- package/dist/topItemCountSystem.d.ts +469 -459
- package/dist/totalListHeightSystem.d.ts +497 -487
- package/dist/upwardScrollFixSystem.d.ts +590 -578
- package/dist/utils/binaryArraySearch.d.ts +6 -6
- package/dist/utils/correctItemSize.d.ts +1 -1
- package/dist/utils/positionStickyCssValue.d.ts +1 -1
- package/dist/utils/simpleMemoize.d.ts +1 -1
- package/dist/windowScrollerSystem.d.ts +35 -34
- package/package.json +15 -5
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { ReactElement, Ref } from 'react';
|
|
2
|
+
import { Components, ComputeItemKey, FollowOutput, IndexLocationWithAlign, ItemContent, ListItem, ListRange, ScrollSeekConfiguration } from '../interfaces';
|
|
3
|
+
import { List, ListHandle } from '../List';
|
|
4
|
+
import { ScrollIntoViewLocation } from '../scrollIntoViewSystem';
|
|
5
|
+
import { CompProps } from './CompProps';
|
|
6
|
+
export declare type ListProps = CompProps<typeof List>;
|
|
7
|
+
export interface VirtuosoProps<D, C> extends Omit<ListProps, 'groupCounts' | 'groupContent' | 'itemsRendered'> {
|
|
8
|
+
/**
|
|
9
|
+
* The total amount of items to be rendered.
|
|
10
|
+
*/
|
|
11
|
+
totalCount?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The data items to be rendered. If data is set, the total count will be inferred from the length of the array.
|
|
14
|
+
*/
|
|
15
|
+
data?: readonly D[];
|
|
16
|
+
/**
|
|
17
|
+
* Additional context available in the custom components and content callbacks
|
|
18
|
+
*/
|
|
19
|
+
context?: C;
|
|
20
|
+
/**
|
|
21
|
+
* Set the overscan property to make the component "chunk" the rendering of new items on scroll.
|
|
22
|
+
* The property causes the component to render more items than the necessary, but reduces the re-renders on scroll.
|
|
23
|
+
* Setting `{ main: number, reverse: number }` lets you extend the list in both the main and the reverse scrollable directions.
|
|
24
|
+
* See the `increaseViewportBy` property for a similar behavior (equivalent to the `overscan` in `react-window`).
|
|
25
|
+
*/
|
|
26
|
+
overscan?: number | {
|
|
27
|
+
main: number;
|
|
28
|
+
reverse: number;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Set the increaseViewportBy property to artificially increase the viewport size, causing items to be rendered before outside of the viewport.
|
|
32
|
+
* The property causes the component to render more items than the necessary, but can help with slow loading content.
|
|
33
|
+
* Using `{ top?: number, bottom?: number }` lets you set the increase for each end separately.
|
|
34
|
+
*/
|
|
35
|
+
increaseViewportBy?: number | {
|
|
36
|
+
top: number;
|
|
37
|
+
bottom: number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Set the amount of items to remain fixed at the top of the list.
|
|
41
|
+
*
|
|
42
|
+
* For a header that scrolls away when scrolling, check the `components.Header` property.
|
|
43
|
+
*/
|
|
44
|
+
topItemCount?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Set to a value between 0 and totalCount - 1 to make the list start scrolled to that item.
|
|
47
|
+
*/
|
|
48
|
+
initialTopMostItemIndex?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Set this value to offset the initial location of the list.
|
|
51
|
+
* Warning: using this property will still run a render cycle at the scrollTop: 0 list window.
|
|
52
|
+
* If possible, avoid using it and stick to `initialTopMostItemIndex` instead.
|
|
53
|
+
*/
|
|
54
|
+
initialScrollTop?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Use for server-side rendering - if set, the list will render the specified amount of items
|
|
57
|
+
* regardless of the container / item size.
|
|
58
|
+
*/
|
|
59
|
+
initialItemCount?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Use the `components` property for advanced customization of the elements rendered by the list.
|
|
62
|
+
*/
|
|
63
|
+
components?: Components<C>;
|
|
64
|
+
/**
|
|
65
|
+
* Set the callback to specify the contents of the item.
|
|
66
|
+
*/
|
|
67
|
+
itemContent?: ItemContent<D, C>;
|
|
68
|
+
/**
|
|
69
|
+
* If specified, the component will use the function to generate the `key` property for each list item.
|
|
70
|
+
*/
|
|
71
|
+
computeItemKey?: ComputeItemKey<D, C>;
|
|
72
|
+
/**
|
|
73
|
+
* By default, the component assumes the default item height from the first rendered item (rendering it as a "probe").
|
|
74
|
+
*
|
|
75
|
+
* If the first item turns out to be an outlier (very short or tall), the rest of the rendering will be slower,
|
|
76
|
+
* as multiple passes of rendering should happen for the list to fill the viewport.
|
|
77
|
+
*
|
|
78
|
+
* Setting `defaultItemHeight` causes the component to skip the "probe" rendering and use the property
|
|
79
|
+
* value as default height instead.
|
|
80
|
+
*/
|
|
81
|
+
defaultItemHeight?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Allows customizing the height/width calculation of `Item` elements.
|
|
84
|
+
*
|
|
85
|
+
* The default implementation reads `el.getBoundingClientRect().height` and `el.getBoundingClientRect().width`.
|
|
86
|
+
*/
|
|
87
|
+
itemSize?: (el: HTMLElement, field: 'offsetHeight' | 'offsetWidth') => number;
|
|
88
|
+
/**
|
|
89
|
+
* Can be used to improve performance if the rendered items are of known size.
|
|
90
|
+
* Setting it causes the component to skip item measurements.
|
|
91
|
+
*/
|
|
92
|
+
fixedItemHeight?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Use to display placeholders if the user scrolls fast through the list.
|
|
95
|
+
*
|
|
96
|
+
* Set `components.ScrollSeekPlaceholder` to change the placeholder content.
|
|
97
|
+
*/
|
|
98
|
+
scrollSeekConfiguration?: ScrollSeekConfiguration | false;
|
|
99
|
+
/**
|
|
100
|
+
* If set to `true`, the list automatically scrolls to bottom if the total count is changed.
|
|
101
|
+
* Set to `"smooth"` for an animated scrolling.
|
|
102
|
+
*
|
|
103
|
+
* By default, `followOutput` scrolls down only if the list is already at the bottom.
|
|
104
|
+
* To implement an arbitrary logic behind that, pass a function:
|
|
105
|
+
*
|
|
106
|
+
* ```tsx
|
|
107
|
+
* <Virtuoso
|
|
108
|
+
* followOutput={(isAtBottom: boolean) => {
|
|
109
|
+
* if (expression) {
|
|
110
|
+
* return 'smooth' // can be 'auto' or false to avoid scrolling
|
|
111
|
+
* } else {
|
|
112
|
+
* return false
|
|
113
|
+
* }
|
|
114
|
+
* }} />
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
followOutput?: FollowOutput;
|
|
118
|
+
/**
|
|
119
|
+
* Set to customize the wrapper tag for the header and footer components (default is `div`).
|
|
120
|
+
*/
|
|
121
|
+
headerFooterTag?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Use when implementing inverse infinite scrolling - decrease the value this property
|
|
124
|
+
* in combination with `data` or `totalCount` to prepend items to the top of the list.
|
|
125
|
+
*
|
|
126
|
+
* Warning: the firstItemIndex should **be a positive number**, based on the total amount of items to be displayed.
|
|
127
|
+
*/
|
|
128
|
+
firstItemIndex?: number;
|
|
129
|
+
/**
|
|
130
|
+
* Called when the list starts/stops scrolling.
|
|
131
|
+
*/
|
|
132
|
+
isScrolling?: (isScrolling: boolean) => void;
|
|
133
|
+
/**
|
|
134
|
+
* Gets called when the user scrolls to the end of the list.
|
|
135
|
+
* Receives the last item index as an argument. Can be used to implement endless scrolling.
|
|
136
|
+
*/
|
|
137
|
+
endReached?: (index: number) => void;
|
|
138
|
+
/**
|
|
139
|
+
* Called when the user scrolls to the start of the list.
|
|
140
|
+
*/
|
|
141
|
+
startReached?: (index: number) => void;
|
|
142
|
+
/**
|
|
143
|
+
* Called with the new set of items each time the list items are rendered due to scrolling.
|
|
144
|
+
*/
|
|
145
|
+
rangeChanged?: (range: ListRange) => void;
|
|
146
|
+
/**
|
|
147
|
+
* Called with true / false when the list has reached the bottom / gets scrolled up.
|
|
148
|
+
* Can be used to load newer items, like `tail -f`.
|
|
149
|
+
*/
|
|
150
|
+
atBottomStateChange?: (atBottom: boolean) => void;
|
|
151
|
+
/**
|
|
152
|
+
* Called with `true` / `false` when the list has reached the top / gets scrolled down.
|
|
153
|
+
*/
|
|
154
|
+
atTopStateChange?: (atTop: boolean) => void;
|
|
155
|
+
/**
|
|
156
|
+
* Called when the total list height is changed due to new items or viewport resize.
|
|
157
|
+
*/
|
|
158
|
+
totalListHeightChanged?: (height: number) => void;
|
|
159
|
+
/**
|
|
160
|
+
* Called with the new set of items each time the list items are rendered due to scrolling.
|
|
161
|
+
*/
|
|
162
|
+
itemsRendered?: (items: ListItem<D>[]) => void;
|
|
163
|
+
/**
|
|
164
|
+
* Setting `alignToBottom` to `true` aligns the items to the bottom of the list if the list is shorter than the viewport.
|
|
165
|
+
* Use `followOutput` property to keep the list aligned when new items are appended.
|
|
166
|
+
*/
|
|
167
|
+
alignToBottom?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Uses the document scroller rather than wrapping the list in its own.
|
|
170
|
+
*/
|
|
171
|
+
useWindowScroll?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Pass a reference to a scrollable parent element, so that the list won't wrap in its own.
|
|
174
|
+
*/
|
|
175
|
+
customScrollParent?: HTMLElement;
|
|
176
|
+
/**
|
|
177
|
+
* Provides access to the root DOM element
|
|
178
|
+
*/
|
|
179
|
+
scrollerRef?: (ref: HTMLElement | Window | null) => any;
|
|
180
|
+
/**
|
|
181
|
+
* 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.
|
|
182
|
+
*/
|
|
183
|
+
atBottomThreshold?: number;
|
|
184
|
+
}
|
|
185
|
+
export interface VirtuosoHandle extends ListHandle {
|
|
186
|
+
/**
|
|
187
|
+
* Scrolls the component to the specified item index. See {{IndexLocationWithAlign}} for more options.
|
|
188
|
+
*/
|
|
189
|
+
scrollToIndex(location: number | IndexLocationWithAlign): void;
|
|
190
|
+
/**
|
|
191
|
+
* Scrolls the item into view if necessary. See [the website example](http://virtuoso.dev/keyboard-navigation/) for an implementation.
|
|
192
|
+
*/
|
|
193
|
+
scrollIntoView(location: ScrollIntoViewLocation): void;
|
|
194
|
+
/**
|
|
195
|
+
* Scrolls the component to the specified location. See [ScrollToOptions (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions)
|
|
196
|
+
*/
|
|
197
|
+
scrollTo(location: ScrollToOptions): void;
|
|
198
|
+
/**
|
|
199
|
+
* Scrolls the component with the specified amount. See [ScrollToOptions (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions)
|
|
200
|
+
*/
|
|
201
|
+
scrollBy(location: ScrollToOptions): void;
|
|
202
|
+
}
|
|
203
|
+
export declare const Virtuoso: <ItemData extends unknown = any, Context extends unknown = any>(props: VirtuosoProps<ItemData, Context> & {
|
|
204
|
+
ref?: Ref<VirtuosoHandle> | undefined;
|
|
205
|
+
}) => ReactElement;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ReactElement, Ref } from 'react';
|
|
2
|
+
import { Grid, GridHandle } from '../Grid';
|
|
3
|
+
import { GridComponents, GridComputeItemKey, GridItemContent, IndexLocationWithAlign, ListRange, ScrollSeekConfiguration } from '../interfaces';
|
|
4
|
+
import { CompProps } from './CompProps';
|
|
5
|
+
declare type GridProps = CompProps<typeof Grid>;
|
|
6
|
+
export interface VirtuosoGridProps<C extends unknown = unknown> extends GridProps {
|
|
7
|
+
/**
|
|
8
|
+
* The total amount of items to be rendered.
|
|
9
|
+
*/
|
|
10
|
+
totalCount: number;
|
|
11
|
+
/**
|
|
12
|
+
* Set the callback to specify the contents of the item.
|
|
13
|
+
*/
|
|
14
|
+
itemContent?: GridItemContent<C>;
|
|
15
|
+
/**
|
|
16
|
+
* Use the `components` property for advanced customization of the elements rendered by the list.
|
|
17
|
+
*/
|
|
18
|
+
components?: GridComponents<C>;
|
|
19
|
+
/**
|
|
20
|
+
* Set the overscan property to make the component "chunk" the rendering of new items on scroll.
|
|
21
|
+
* The property causes the component to render more items than the necessary, but reduces the re-renders on scroll.
|
|
22
|
+
* Setting `{ main: number, reverse: number }` lets you extend the list in both the main and the reverse scrollable directions.
|
|
23
|
+
*/
|
|
24
|
+
overscan?: number | {
|
|
25
|
+
main: number;
|
|
26
|
+
reverse: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* If specified, the component will use the function to generate the `key` property for each list item.
|
|
30
|
+
*/
|
|
31
|
+
computeItemKey?: GridComputeItemKey;
|
|
32
|
+
/**
|
|
33
|
+
* Use to display placeholders if the user scrolls fast through the list.
|
|
34
|
+
*
|
|
35
|
+
* Set `components.ScrollSeekPlaceholder` to change the placeholder content.
|
|
36
|
+
*/
|
|
37
|
+
scrollSeekConfiguration?: ScrollSeekConfiguration | false;
|
|
38
|
+
/**
|
|
39
|
+
* Called when the list starts/stops scrolling.
|
|
40
|
+
*/
|
|
41
|
+
isScrolling?: (isScrolling: boolean) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Gets called when the user scrolls to the end of the list.
|
|
44
|
+
* Receives the last item index as an argument. Can be used to implement endless scrolling.
|
|
45
|
+
*/
|
|
46
|
+
endReached?: (index: number) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Called when the user scrolls to the start of the list.
|
|
49
|
+
*/
|
|
50
|
+
startReached?: (index: number) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Called with the new set of items each time the list items are rendered due to scrolling.
|
|
53
|
+
*/
|
|
54
|
+
rangeChanged?: (range: ListRange) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Called with true / false when the list has reached the bottom / gets scrolled up.
|
|
57
|
+
* Can be used to load newer items, like `tail -f`.
|
|
58
|
+
*/
|
|
59
|
+
atBottomStateChange?: (atBottom: boolean) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Called with `true` / `false` when the list has reached the top / gets scrolled down.
|
|
62
|
+
*/
|
|
63
|
+
atTopStateChange?: (atTop: boolean) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Provides access to the root DOM element
|
|
66
|
+
*/
|
|
67
|
+
scrollerRef?: (ref: HTMLElement | null) => any;
|
|
68
|
+
/**
|
|
69
|
+
* Sets the className for the list DOM element
|
|
70
|
+
*/
|
|
71
|
+
listClassName?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Sets the grid items' className
|
|
74
|
+
*/
|
|
75
|
+
itemClassName?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Uses the document scroller rather than wrapping the grid in its own.
|
|
78
|
+
*/
|
|
79
|
+
useWindowScroll?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Pass a reference to a scrollable parent element, so that the grid won't wrap in its own.
|
|
82
|
+
*/
|
|
83
|
+
customScrollParent?: HTMLElement;
|
|
84
|
+
}
|
|
85
|
+
export interface VirtuosoGridHandle extends GridHandle {
|
|
86
|
+
scrollToIndex(location: number | IndexLocationWithAlign): void;
|
|
87
|
+
scrollTo(location: ScrollToOptions): void;
|
|
88
|
+
scrollBy(location: ScrollToOptions): void;
|
|
89
|
+
}
|
|
90
|
+
export declare const VirtuosoGrid: <Context extends unknown = any>(props: VirtuosoGridProps<Context> & {
|
|
91
|
+
ref?: Ref<VirtuosoGridHandle> | undefined;
|
|
92
|
+
}) => ReactElement;
|
|
93
|
+
export {};
|