react-virtuoso 4.17.0 → 4.18.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/README.md +264 -4
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +811 -58
- package/dist/index.mjs +257 -257
- package/package.json +24 -31
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { default as default_2 } from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Obtains the internal size state of the component, so that it can be restored later. This does not include the data items.
|
|
6
|
-
*/
|
|
7
|
-
getState(stateCb: StateCallback): void;
|
|
8
|
-
scrollBy(location: ScrollToOptions): void;
|
|
9
|
-
scrollTo(location: ScrollToOptions): void;
|
|
10
|
-
}
|
|
3
|
+
/* Excluded from this release type: BaseTableVirtuosoHandle */
|
|
11
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @group Common
|
|
7
|
+
*/
|
|
12
8
|
export declare type CalculateViewLocation = (params: CalculateViewLocationParams) => IndexLocationWithAlign | null | number;
|
|
13
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @group Common
|
|
12
|
+
*/
|
|
14
13
|
export declare interface CalculateViewLocationParams {
|
|
14
|
+
/** The bottom edge position of the item in pixels */
|
|
15
15
|
itemBottom: number;
|
|
16
|
+
/** The top edge position of the item in pixels */
|
|
16
17
|
itemTop: number;
|
|
18
|
+
/** The scroll location parameters including alignment and behavior options */
|
|
17
19
|
locationParams: {
|
|
18
20
|
align?: 'center' | 'end' | 'start';
|
|
19
21
|
behavior?: 'auto' | 'smooth';
|
|
@@ -22,12 +24,30 @@ export declare interface CalculateViewLocationParams {
|
|
|
22
24
|
} | {
|
|
23
25
|
index: number;
|
|
24
26
|
});
|
|
27
|
+
/** The bottom edge position of the viewport in pixels */
|
|
25
28
|
viewportBottom: number;
|
|
29
|
+
/** The top edge position of the viewport in pixels */
|
|
26
30
|
viewportTop: number;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
/**
|
|
30
34
|
* Customize the Virtuoso rendering by passing a set of custom components.
|
|
35
|
+
*
|
|
36
|
+
* @typeParam Data - The type of data items in the list
|
|
37
|
+
* @typeParam Context - The type of additional context passed to components
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* const components: Components<User, AppContext> = {
|
|
42
|
+
* Item: ({ children, context }) => <div className="item">{children}</div>,
|
|
43
|
+
* Header: ({ context }) => <div>Header</div>,
|
|
44
|
+
* Footer: ({ context }) => <div>Footer</div>,
|
|
45
|
+
* }
|
|
46
|
+
* <Virtuoso components={components} />
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @see {@link VirtuosoProps.components} for usage in Virtuoso
|
|
50
|
+
* @group Virtuoso
|
|
31
51
|
*/
|
|
32
52
|
export declare interface Components<Data = unknown, Context = unknown> {
|
|
33
53
|
/**
|
|
@@ -72,28 +92,83 @@ export declare interface Components<Data = unknown, Context = unknown> {
|
|
|
72
92
|
TopItemList?: default_2.ComponentType<TopItemListProps & ContextProp<Context>>;
|
|
73
93
|
}
|
|
74
94
|
|
|
75
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Callback type for computing unique keys for list items.
|
|
97
|
+
*
|
|
98
|
+
* @typeParam Data - The type of the data item
|
|
99
|
+
* @typeParam Context - The type of context passed from the component
|
|
100
|
+
*
|
|
101
|
+
* @see {@link VirtuosoProps.computeItemKey} for usage in Virtuoso
|
|
102
|
+
* @group Common
|
|
103
|
+
*/
|
|
104
|
+
export declare type ComputeItemKey<Data, Context> = (index: number, item: Data, context: Context) => default_2.Key;
|
|
76
105
|
|
|
77
|
-
|
|
78
|
-
|
|
106
|
+
/**
|
|
107
|
+
* @group Common
|
|
108
|
+
*/
|
|
109
|
+
export declare interface ContextProp<Context> {
|
|
110
|
+
/** The context value passed from the parent component */
|
|
111
|
+
context: Context;
|
|
79
112
|
}
|
|
80
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Dimensions of an element in pixels.
|
|
116
|
+
*
|
|
117
|
+
* @group VirtuosoGrid
|
|
118
|
+
*/
|
|
81
119
|
export declare interface ElementDimensions {
|
|
120
|
+
/** Height in pixels */
|
|
82
121
|
height: number;
|
|
122
|
+
/** Width in pixels */
|
|
83
123
|
width: number;
|
|
84
124
|
}
|
|
85
125
|
|
|
86
126
|
/**
|
|
87
127
|
* Passed to the Components.FillerRow custom component
|
|
128
|
+
* @group TableVirtuoso
|
|
88
129
|
*/
|
|
89
130
|
export declare interface FillerRowProps {
|
|
131
|
+
/** The height of the filler row in pixels */
|
|
90
132
|
height: number;
|
|
91
133
|
}
|
|
92
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Callback type for rendering fixed footer content in a table.
|
|
137
|
+
* The footer remains visible at the bottom of the viewport.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```tsx
|
|
141
|
+
* const fixedFooterContent: FixedFooterContent = () => (
|
|
142
|
+
* <tr><td>Total: 100 items</td></tr>
|
|
143
|
+
* )
|
|
144
|
+
* <TableVirtuoso fixedFooterContent={fixedFooterContent} />
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
147
|
+
* @see {@link TableVirtuosoProps.fixedFooterContent} for usage
|
|
148
|
+
* @group TableVirtuoso
|
|
149
|
+
*/
|
|
93
150
|
export declare type FixedFooterContent = (() => default_2.ReactNode) | null;
|
|
94
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Callback type for rendering fixed header content in a table.
|
|
154
|
+
* The header remains visible at the top of the viewport.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```tsx
|
|
158
|
+
* const fixedHeaderContent: FixedHeaderContent = () => (
|
|
159
|
+
* <tr><th>Name</th><th>Email</th></tr>
|
|
160
|
+
* )
|
|
161
|
+
* <TableVirtuoso fixedHeaderContent={fixedHeaderContent} />
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @see {@link TableVirtuosoProps.fixedHeaderContent} for usage
|
|
165
|
+
* @group TableVirtuoso
|
|
166
|
+
*/
|
|
95
167
|
export declare type FixedHeaderContent = (() => default_2.ReactNode) | null;
|
|
96
168
|
|
|
169
|
+
/**
|
|
170
|
+
* @group Common
|
|
171
|
+
*/
|
|
97
172
|
export declare interface FlatIndexLocationWithAlign extends LocationOptions {
|
|
98
173
|
/**
|
|
99
174
|
* The index of the item to scroll to.
|
|
@@ -101,21 +176,58 @@ export declare interface FlatIndexLocationWithAlign extends LocationOptions {
|
|
|
101
176
|
index: 'LAST' | number;
|
|
102
177
|
}
|
|
103
178
|
|
|
179
|
+
/**
|
|
180
|
+
* @group Common
|
|
181
|
+
*/
|
|
104
182
|
export declare interface FlatScrollIntoViewLocation extends ScrollIntoViewLocationOptions {
|
|
183
|
+
/** The index of the item to scroll into view */
|
|
105
184
|
index: number;
|
|
106
185
|
}
|
|
107
186
|
|
|
187
|
+
/**
|
|
188
|
+
* @group Common
|
|
189
|
+
*/
|
|
108
190
|
export declare type FollowOutput = FollowOutputCallback | FollowOutputScalarType;
|
|
109
191
|
|
|
192
|
+
/**
|
|
193
|
+
* @group Common
|
|
194
|
+
*/
|
|
110
195
|
export declare type FollowOutputCallback = (isAtBottom: boolean) => FollowOutputScalarType;
|
|
111
196
|
|
|
197
|
+
/**
|
|
198
|
+
* @group Common
|
|
199
|
+
*/
|
|
112
200
|
export declare type FollowOutputScalarType = 'auto' | 'smooth' | boolean;
|
|
113
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Gap between grid items in pixels.
|
|
204
|
+
*
|
|
205
|
+
* @group VirtuosoGrid
|
|
206
|
+
*/
|
|
114
207
|
export declare interface Gap {
|
|
208
|
+
/** Horizontal gap between columns */
|
|
115
209
|
column: number;
|
|
210
|
+
/** Vertical gap between rows */
|
|
116
211
|
row: number;
|
|
117
212
|
}
|
|
118
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Customize the VirtuosoGrid rendering by passing a set of custom components.
|
|
216
|
+
*
|
|
217
|
+
* @typeParam Context - The type of additional context passed to components
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```tsx
|
|
221
|
+
* const components: GridComponents<AppContext> = {
|
|
222
|
+
* Item: ({ children, className }) => <div className={className}>{children}</div>,
|
|
223
|
+
* Header: ({ context }) => <div>Header</div>,
|
|
224
|
+
* }
|
|
225
|
+
* <VirtuosoGrid components={components} />
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
228
|
+
* @see {@link VirtuosoGridProps.components} for usage in VirtuosoGrid
|
|
229
|
+
* @group VirtuosoGrid
|
|
230
|
+
*/
|
|
119
231
|
export declare interface GridComponents<Context = any> {
|
|
120
232
|
/**
|
|
121
233
|
* Set to render a component at the bottom of the list.
|
|
@@ -147,65 +259,197 @@ export declare interface GridComponents<Context = any> {
|
|
|
147
259
|
ScrollSeekPlaceholder?: default_2.ComponentType<GridScrollSeekPlaceholderProps & ContextProp<Context>>;
|
|
148
260
|
}
|
|
149
261
|
|
|
150
|
-
|
|
262
|
+
/**
|
|
263
|
+
* Callback type for computing unique keys for grid items.
|
|
264
|
+
*
|
|
265
|
+
* @typeParam Data - The type of the data item
|
|
266
|
+
* @typeParam Context - The type of context passed from the component
|
|
267
|
+
*
|
|
268
|
+
* @see {@link VirtuosoGridProps.computeItemKey} for usage
|
|
269
|
+
* @group VirtuosoGrid
|
|
270
|
+
*/
|
|
271
|
+
export declare type GridComputeItemKey<Data, Context> = (index: number, item: Data, context: Context) => default_2.Key;
|
|
151
272
|
|
|
273
|
+
/**
|
|
274
|
+
* @group VirtuosoGrid
|
|
275
|
+
*/
|
|
152
276
|
export declare type GridIndexLocation = FlatIndexLocationWithAlign | number;
|
|
153
277
|
|
|
154
|
-
|
|
155
|
-
|
|
278
|
+
/**
|
|
279
|
+
* @group VirtuosoGrid
|
|
280
|
+
*/
|
|
281
|
+
export declare interface GridItem<Data> {
|
|
282
|
+
/** The data associated with this grid item */
|
|
283
|
+
data?: Data;
|
|
284
|
+
/** The index of the item in the grid */
|
|
156
285
|
index: number;
|
|
157
286
|
}
|
|
158
287
|
|
|
159
|
-
|
|
288
|
+
/**
|
|
289
|
+
* Callback type for rendering item content in a VirtuosoGrid.
|
|
290
|
+
*
|
|
291
|
+
* @typeParam Data - The type of the data item
|
|
292
|
+
* @typeParam Context - The type of context passed from the component
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```tsx
|
|
296
|
+
* const itemContent: GridItemContent<Product, AppContext> = (index, product, context) => (
|
|
297
|
+
* <div className="grid-item">{product.name}</div>
|
|
298
|
+
* )
|
|
299
|
+
* <VirtuosoGrid itemContent={itemContent} data={products} />
|
|
300
|
+
* ```
|
|
301
|
+
*
|
|
302
|
+
* @see {@link VirtuosoGridProps.itemContent} for usage
|
|
303
|
+
* @group VirtuosoGrid
|
|
304
|
+
*/
|
|
305
|
+
export declare type GridItemContent<Data, Context> = (index: number, data: Data, context: Context) => default_2.ReactNode;
|
|
160
306
|
|
|
161
307
|
/**
|
|
162
|
-
* Passed to the
|
|
308
|
+
* Passed to the GridComponents.Item custom component
|
|
309
|
+
* @group VirtuosoGrid
|
|
163
310
|
*/
|
|
164
311
|
export declare type GridItemProps = Pick<default_2.ComponentProps<'div'>, 'children' | 'className' | 'style'> & default_2.RefAttributes<HTMLDivElement> & {
|
|
165
312
|
'data-index': number;
|
|
166
313
|
};
|
|
167
314
|
|
|
168
315
|
/**
|
|
169
|
-
* Passed to the
|
|
316
|
+
* Passed to the GridComponents.List custom component
|
|
317
|
+
* @group VirtuosoGrid
|
|
170
318
|
*/
|
|
171
319
|
export declare type GridListProps = Pick<default_2.ComponentProps<'div'>, 'children' | 'className' | 'style'> & default_2.RefAttributes<HTMLDivElement> & {
|
|
172
320
|
'data-testid': string;
|
|
173
321
|
};
|
|
174
322
|
|
|
323
|
+
/**
|
|
324
|
+
* @group VirtuosoGrid
|
|
325
|
+
*/
|
|
175
326
|
export declare type GridRootProps = Omit<default_2.HTMLProps<HTMLDivElement>, 'data' | 'ref'>;
|
|
176
327
|
|
|
177
328
|
/**
|
|
178
329
|
* Passed to the GridComponents.ScrollSeekPlaceholder custom component
|
|
330
|
+
* @group VirtuosoGrid
|
|
179
331
|
*/
|
|
180
332
|
export declare interface GridScrollSeekPlaceholderProps {
|
|
333
|
+
/** The height of the placeholder in pixels */
|
|
181
334
|
height: number;
|
|
335
|
+
/** The index of the item being replaced by the placeholder */
|
|
182
336
|
index: number;
|
|
337
|
+
/** The width of the placeholder in pixels */
|
|
183
338
|
width: number;
|
|
184
339
|
}
|
|
185
340
|
|
|
341
|
+
/**
|
|
342
|
+
* A snapshot of the VirtuosoGrid state that can be saved and restored.
|
|
343
|
+
* Use this to persist scroll position and layout across page reloads.
|
|
344
|
+
*
|
|
345
|
+
* @see {@link VirtuosoGridProps.restoreStateFrom} for restoring state
|
|
346
|
+
* @see {@link VirtuosoGridProps.stateChanged} for capturing state
|
|
347
|
+
* @group VirtuosoGrid
|
|
348
|
+
*/
|
|
186
349
|
export declare interface GridStateSnapshot {
|
|
350
|
+
/** Gap between items */
|
|
187
351
|
gap: Gap;
|
|
352
|
+
/** Item dimensions */
|
|
188
353
|
item: ElementDimensions;
|
|
354
|
+
/** Scroll position in pixels */
|
|
189
355
|
scrollTop: number;
|
|
356
|
+
/** Viewport dimensions */
|
|
190
357
|
viewport: ElementDimensions;
|
|
191
358
|
}
|
|
192
359
|
|
|
193
|
-
|
|
360
|
+
/**
|
|
361
|
+
* Callback type for rendering group header content in GroupedVirtuoso.
|
|
362
|
+
*
|
|
363
|
+
* @typeParam Context - The type of context passed from the component
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```tsx
|
|
367
|
+
* const groupContent: GroupContent<AppContext> = (index, context) => (
|
|
368
|
+
* <div className="group-header">Group {index}</div>
|
|
369
|
+
* )
|
|
370
|
+
* <GroupedVirtuoso groupContent={groupContent} />
|
|
371
|
+
* ```
|
|
372
|
+
*
|
|
373
|
+
* @see {@link GroupedVirtuosoProps.groupContent} for usage
|
|
374
|
+
* @group GroupedVirtuoso
|
|
375
|
+
*/
|
|
376
|
+
export declare type GroupContent<Context> = (index: number, context: Context) => default_2.ReactNode;
|
|
194
377
|
|
|
378
|
+
/**
|
|
379
|
+
* @group GroupedVirtuoso
|
|
380
|
+
*/
|
|
195
381
|
export declare interface GroupedScrollIntoViewLocation extends ScrollIntoViewLocationOptions {
|
|
382
|
+
/** The index of the group to scroll into view */
|
|
196
383
|
groupIndex: number;
|
|
197
384
|
}
|
|
198
385
|
|
|
386
|
+
/**
|
|
387
|
+
* A virtualized table component for rendering grouped tabular data with sticky group headers.
|
|
388
|
+
* Combines TableVirtuoso functionality with group support for hierarchical data.
|
|
389
|
+
*
|
|
390
|
+
* @typeParam ItemData - The type of data items in the table
|
|
391
|
+
* @typeParam Context - The type of additional context passed to callbacks
|
|
392
|
+
*
|
|
393
|
+
* @param props - {@link GroupedTableVirtuosoProps}
|
|
394
|
+
*
|
|
395
|
+
* @function
|
|
396
|
+
* @group GroupedTableVirtuoso
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* ```tsx
|
|
400
|
+
* <GroupedTableVirtuoso
|
|
401
|
+
* groupCounts={[10, 20, 15]}
|
|
402
|
+
* groupContent={(index) => (
|
|
403
|
+
* <td colSpan={2}>Group {index}</td>
|
|
404
|
+
* )}
|
|
405
|
+
* itemContent={(index, groupIndex) => (
|
|
406
|
+
* <>
|
|
407
|
+
* <td>Item {index}</td>
|
|
408
|
+
* <td>Group {groupIndex}</td>
|
|
409
|
+
* </>
|
|
410
|
+
* )}
|
|
411
|
+
* />
|
|
412
|
+
* ```
|
|
413
|
+
*
|
|
414
|
+
* @see {@link GroupedTableVirtuosoProps} for available props
|
|
415
|
+
* @see {@link GroupedTableVirtuosoHandle} for imperative methods
|
|
416
|
+
*/
|
|
199
417
|
export declare const GroupedTableVirtuoso: <ItemData = any, Context = any>(props: GroupedTableVirtuosoProps<ItemData, Context> & {
|
|
200
418
|
ref?: default_2.Ref<GroupedTableVirtuosoHandle>;
|
|
201
419
|
}) => default_2.ReactElement;
|
|
202
420
|
|
|
421
|
+
/**
|
|
422
|
+
* Exposes the GroupedTableVirtuoso component methods for imperative control.
|
|
423
|
+
* Access via ref on the GroupedTableVirtuoso component.
|
|
424
|
+
*
|
|
425
|
+
* @see {@link GroupedTableVirtuoso} for the component
|
|
426
|
+
* @see {@link GroupedTableVirtuosoProps} for available props
|
|
427
|
+
* @group GroupedTableVirtuoso
|
|
428
|
+
*/
|
|
203
429
|
export declare interface GroupedTableVirtuosoHandle extends BaseTableVirtuosoHandle {
|
|
430
|
+
/**
|
|
431
|
+
* Scrolls the specified item into view if it's not already visible.
|
|
432
|
+
* @param location - The scroll into view location options
|
|
433
|
+
*/
|
|
204
434
|
scrollIntoView(location: ScrollIntoViewLocationOptions): void;
|
|
435
|
+
/**
|
|
436
|
+
* Scrolls the component to the specified item index.
|
|
437
|
+
* @param location - The item index or location with alignment options
|
|
438
|
+
*/
|
|
205
439
|
scrollToIndex(location: IndexLocationWithAlign | number): void;
|
|
206
440
|
}
|
|
207
441
|
|
|
208
|
-
|
|
442
|
+
/**
|
|
443
|
+
* The props for the GroupedTableVirtuoso component.
|
|
444
|
+
*
|
|
445
|
+
* @typeParam Data - The type of data items in the table
|
|
446
|
+
* @typeParam Context - The type of additional context passed to callbacks
|
|
447
|
+
*
|
|
448
|
+
* @see {@link GroupedTableVirtuoso} for the component
|
|
449
|
+
* @see {@link GroupedTableVirtuosoHandle} for imperative methods
|
|
450
|
+
* @group GroupedTableVirtuoso
|
|
451
|
+
*/
|
|
452
|
+
export declare interface GroupedTableVirtuosoProps<Data, Context> extends Omit<TableVirtuosoProps<Data, Context>, 'itemContent' | 'totalCount'> {
|
|
209
453
|
/**
|
|
210
454
|
* Use when implementing inverse infinite scrolling, decrease the value this property
|
|
211
455
|
* in combination with a change in `groupCounts` to prepend groups items to the top of the list.
|
|
@@ -223,7 +467,7 @@ export declare interface GroupedTableVirtuosoProps<D, C> extends Omit<TableVirtu
|
|
|
223
467
|
/**
|
|
224
468
|
* Specifies how each each group header gets rendered. The callback receives the zero-based index of the group.
|
|
225
469
|
*/
|
|
226
|
-
groupContent?: GroupContent<
|
|
470
|
+
groupContent?: GroupContent<Context>;
|
|
227
471
|
/**
|
|
228
472
|
* Specifies the amount of items in each group (and, actually, how many groups are there).
|
|
229
473
|
* For example, passing [20, 30] will display 2 groups with 20 and 30 items each.
|
|
@@ -232,26 +476,88 @@ export declare interface GroupedTableVirtuosoProps<D, C> extends Omit<TableVirtu
|
|
|
232
476
|
/**
|
|
233
477
|
* Specifies how each each item gets rendered.
|
|
234
478
|
*/
|
|
235
|
-
itemContent?: GroupItemContent<
|
|
479
|
+
itemContent?: GroupItemContent<Data, Context>;
|
|
236
480
|
}
|
|
237
481
|
|
|
482
|
+
/**
|
|
483
|
+
* A virtualized list component for rendering grouped data with sticky group headers.
|
|
484
|
+
* Extends Virtuoso with support for collapsible groups and group-level navigation.
|
|
485
|
+
*
|
|
486
|
+
* @typeParam ItemData - The type of data items in the list
|
|
487
|
+
* @typeParam Context - The type of additional context passed to callbacks
|
|
488
|
+
*
|
|
489
|
+
* @param props - {@link GroupedVirtuosoProps}
|
|
490
|
+
*
|
|
491
|
+
* @function
|
|
492
|
+
* @group GroupedVirtuoso
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* ```tsx
|
|
496
|
+
* <GroupedVirtuoso
|
|
497
|
+
* groupCounts={[10, 20, 15]}
|
|
498
|
+
* groupContent={(index) => <div>Group {index}</div>}
|
|
499
|
+
* itemContent={(index, groupIndex) => <div>Item {index} in group {groupIndex}</div>}
|
|
500
|
+
* />
|
|
501
|
+
* ```
|
|
502
|
+
*
|
|
503
|
+
* @see {@link GroupedVirtuosoProps} for available props
|
|
504
|
+
* @see {@link GroupedVirtuosoHandle} for imperative methods
|
|
505
|
+
*/
|
|
238
506
|
export declare const GroupedVirtuoso: <ItemData = any, Context = any>(props: GroupedVirtuosoProps<ItemData, Context> & {
|
|
239
507
|
ref?: default_2.Ref<GroupedVirtuosoHandle>;
|
|
240
508
|
}) => default_2.ReactElement;
|
|
241
509
|
|
|
510
|
+
/**
|
|
511
|
+
* Exposes the GroupedVirtuoso component methods for imperative control.
|
|
512
|
+
* Access via ref on the GroupedVirtuoso component.
|
|
513
|
+
*
|
|
514
|
+
* @see {@link GroupedVirtuoso} for the component
|
|
515
|
+
* @see {@link GroupedVirtuosoProps} for available props
|
|
516
|
+
* @group GroupedVirtuoso
|
|
517
|
+
*/
|
|
242
518
|
export declare interface GroupedVirtuosoHandle {
|
|
519
|
+
/**
|
|
520
|
+
* Scrolls to the bottom of the list if follow output is active. Useful when images load in the list.
|
|
521
|
+
*/
|
|
243
522
|
autoscrollToBottom(): void;
|
|
244
523
|
/**
|
|
245
524
|
* Obtains the internal size state of the component, so that it can be restored later. This does not include the data items.
|
|
525
|
+
* @param stateCb - Callback that receives the state snapshot
|
|
246
526
|
*/
|
|
247
527
|
getState(stateCb: StateCallback): void;
|
|
528
|
+
/**
|
|
529
|
+
* Scrolls the component by the specified amount.
|
|
530
|
+
* @param location - The scroll offset options
|
|
531
|
+
*/
|
|
248
532
|
scrollBy(location: ScrollToOptions): void;
|
|
533
|
+
/**
|
|
534
|
+
* Scrolls the specified item into view if it's not already visible.
|
|
535
|
+
* @param location - The item index or scroll location options
|
|
536
|
+
*/
|
|
249
537
|
scrollIntoView(location: number | ScrollIntoViewLocation): void;
|
|
538
|
+
/**
|
|
539
|
+
* Scrolls the component to the specified position.
|
|
540
|
+
* @param location - The scroll position options
|
|
541
|
+
*/
|
|
250
542
|
scrollTo(location: ScrollToOptions): void;
|
|
543
|
+
/**
|
|
544
|
+
* Scrolls the component to the specified item index.
|
|
545
|
+
* @param location - The item index or location with alignment options
|
|
546
|
+
*/
|
|
251
547
|
scrollToIndex(location: IndexLocationWithAlign | number): void;
|
|
252
548
|
}
|
|
253
549
|
|
|
254
|
-
|
|
550
|
+
/**
|
|
551
|
+
* The props for the GroupedVirtuoso component.
|
|
552
|
+
*
|
|
553
|
+
* @typeParam Data - The type of data items in the list
|
|
554
|
+
* @typeParam Context - The type of additional context passed to callbacks
|
|
555
|
+
*
|
|
556
|
+
* @see {@link GroupedVirtuoso} for the component
|
|
557
|
+
* @see {@link GroupedVirtuosoHandle} for imperative methods
|
|
558
|
+
* @group GroupedVirtuoso
|
|
559
|
+
*/
|
|
560
|
+
export declare interface GroupedVirtuosoProps<Data, Context> extends Omit<VirtuosoProps<Data, Context>, 'itemContent' | 'totalCount'> {
|
|
255
561
|
/**
|
|
256
562
|
* Use when implementing inverse infinite scrolling, decrease the value this property
|
|
257
563
|
* in combination with a change in `groupCounts` to prepend groups items to the top of the list.
|
|
@@ -269,7 +575,7 @@ export declare interface GroupedVirtuosoProps<D, C> extends Omit<VirtuosoProps<D
|
|
|
269
575
|
/**
|
|
270
576
|
* Specifies how each each group header gets rendered. The callback receives the zero-based index of the group.
|
|
271
577
|
*/
|
|
272
|
-
groupContent?: GroupContent<
|
|
578
|
+
groupContent?: GroupContent<Context>;
|
|
273
579
|
/**
|
|
274
580
|
* Specifies the amount of items in each group (and, actually, how many groups are there).
|
|
275
581
|
* For example, passing [20, 30] will display 2 groups with 20 and 30 items each.
|
|
@@ -278,9 +584,12 @@ export declare interface GroupedVirtuosoProps<D, C> extends Omit<VirtuosoProps<D
|
|
|
278
584
|
/**
|
|
279
585
|
* Specifies how each each item gets rendered.
|
|
280
586
|
*/
|
|
281
|
-
itemContent?: GroupItemContent<
|
|
587
|
+
itemContent?: GroupItemContent<Data, Context>;
|
|
282
588
|
}
|
|
283
589
|
|
|
590
|
+
/**
|
|
591
|
+
* @group GroupedVirtuoso
|
|
592
|
+
*/
|
|
284
593
|
export declare interface GroupIndexLocationWithAlign extends LocationOptions {
|
|
285
594
|
/**
|
|
286
595
|
* The group index of the item to scroll to.
|
|
@@ -288,54 +597,143 @@ export declare interface GroupIndexLocationWithAlign extends LocationOptions {
|
|
|
288
597
|
groupIndex: number;
|
|
289
598
|
}
|
|
290
599
|
|
|
291
|
-
|
|
600
|
+
/**
|
|
601
|
+
* @group GroupedVirtuoso
|
|
602
|
+
*/
|
|
603
|
+
export declare interface GroupItem<Data> extends Item<Data> {
|
|
604
|
+
/** The original index before any transformations were applied */
|
|
292
605
|
originalIndex?: number;
|
|
606
|
+
/** Identifies this as a group header item */
|
|
293
607
|
type: 'group';
|
|
294
608
|
}
|
|
295
609
|
|
|
296
|
-
|
|
610
|
+
/**
|
|
611
|
+
* Callback type for rendering item content in a GroupedVirtuoso list.
|
|
612
|
+
* Similar to ItemContent but includes the group index.
|
|
613
|
+
*
|
|
614
|
+
* @typeParam Data - The type of the data item
|
|
615
|
+
* @typeParam Context - The type of context passed from the component
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* ```tsx
|
|
619
|
+
* const itemContent: GroupItemContent<User, AppContext> = (index, groupIndex, user, context) => (
|
|
620
|
+
* <div>{user.name} (Group {groupIndex})</div>
|
|
621
|
+
* )
|
|
622
|
+
* <GroupedVirtuoso itemContent={itemContent} />
|
|
623
|
+
* ```
|
|
624
|
+
*
|
|
625
|
+
* @see {@link GroupedVirtuosoProps.itemContent} for usage
|
|
626
|
+
* @see {@link ItemContent} for non-grouped list variant
|
|
627
|
+
* @group GroupedVirtuoso
|
|
628
|
+
*/
|
|
629
|
+
export declare type GroupItemContent<Data, Context> = (index: number, groupIndex: number, data: Data, context: Context) => default_2.ReactNode;
|
|
297
630
|
|
|
631
|
+
/**
|
|
632
|
+
* Passed to the Components.Group custom component
|
|
633
|
+
* @group GroupedVirtuoso
|
|
634
|
+
*/
|
|
298
635
|
export declare type GroupProps = Pick<default_2.ComponentProps<'div'>, 'children' | 'style'> & {
|
|
636
|
+
/** The index of the group */
|
|
299
637
|
'data-index': number;
|
|
638
|
+
/** The item index within the flattened list */
|
|
300
639
|
'data-item-index': number;
|
|
640
|
+
/** The measured size of the group header in pixels */
|
|
301
641
|
'data-known-size': number;
|
|
302
642
|
};
|
|
303
643
|
|
|
644
|
+
/**
|
|
645
|
+
* @group Common
|
|
646
|
+
*/
|
|
304
647
|
export declare type IndexLocationWithAlign = FlatIndexLocationWithAlign | GroupIndexLocationWithAlign;
|
|
305
648
|
|
|
306
|
-
|
|
307
|
-
|
|
649
|
+
/**
|
|
650
|
+
* Base interface for list items with position and size information.
|
|
651
|
+
* @group Common
|
|
652
|
+
*/
|
|
653
|
+
export declare interface Item<Data> {
|
|
654
|
+
/** The data associated with this item */
|
|
655
|
+
data?: Data;
|
|
656
|
+
/** The index of the item in the list */
|
|
308
657
|
index: number;
|
|
658
|
+
/** The offset position of the item from the start of the list in pixels */
|
|
309
659
|
offset: number;
|
|
660
|
+
/** The measured size of the item in pixels */
|
|
310
661
|
size: number;
|
|
311
662
|
}
|
|
312
663
|
|
|
313
|
-
|
|
664
|
+
/**
|
|
665
|
+
* Callback type for rendering item content in a Virtuoso list.
|
|
666
|
+
*
|
|
667
|
+
* @typeParam Data - The type of the data item
|
|
668
|
+
* @typeParam Context - The type of context passed from the component
|
|
669
|
+
*
|
|
670
|
+
* @example
|
|
671
|
+
* ```tsx
|
|
672
|
+
* const itemContent: ItemContent<User, AppContext> = (index, user, context) => (
|
|
673
|
+
* <div>{user.name}</div>
|
|
674
|
+
* )
|
|
675
|
+
* <Virtuoso itemContent={itemContent} data={users} />
|
|
676
|
+
* ```
|
|
677
|
+
*
|
|
678
|
+
* @see {@link VirtuosoProps.itemContent} for usage in Virtuoso
|
|
679
|
+
* @see {@link GroupItemContent} for grouped list variant
|
|
680
|
+
* @group Virtuoso
|
|
681
|
+
*/
|
|
682
|
+
export declare type ItemContent<Data, Context> = (index: number, data: Data, context: Context) => default_2.ReactNode;
|
|
314
683
|
|
|
315
|
-
|
|
684
|
+
/**
|
|
685
|
+
* Passed to the Components.Item custom component
|
|
686
|
+
* @group Virtuoso
|
|
687
|
+
*/
|
|
688
|
+
export declare type ItemProps<Data> = Pick<default_2.ComponentProps<'div'>, 'children' | 'style'> & {
|
|
316
689
|
'data-index': number;
|
|
317
690
|
'data-item-group-index'?: number;
|
|
318
691
|
'data-item-index': number;
|
|
319
692
|
'data-known-size': number;
|
|
320
|
-
item:
|
|
693
|
+
item: Data;
|
|
321
694
|
};
|
|
322
695
|
|
|
323
|
-
|
|
696
|
+
/**
|
|
697
|
+
* Union type representing either a regular item or a group header item in the list.
|
|
698
|
+
*
|
|
699
|
+
* @typeParam Data - The type of the data item
|
|
700
|
+
*
|
|
701
|
+
* @see {@link RecordItem} for regular items
|
|
702
|
+
* @see {@link GroupItem} for group header items
|
|
703
|
+
* @group Common
|
|
704
|
+
*/
|
|
705
|
+
export declare type ListItem<Data> = GroupItem<Data> | RecordItem<Data>;
|
|
324
706
|
|
|
325
707
|
/**
|
|
326
708
|
* Passed to the Components.List custom component
|
|
709
|
+
* @group Virtuoso
|
|
327
710
|
*/
|
|
328
711
|
export declare type ListProps = Pick<default_2.ComponentProps<'div'>, 'children' | 'style'> & default_2.RefAttributes<HTMLDivElement> & {
|
|
329
712
|
'data-testid': string;
|
|
330
713
|
};
|
|
331
714
|
|
|
715
|
+
/**
|
|
716
|
+
* Represents a range of items in the list by their indices.
|
|
717
|
+
* Used to track which items are currently visible in the viewport.
|
|
718
|
+
*
|
|
719
|
+
* @see {@link VirtuosoProps.rangeChanged} for visibility change events
|
|
720
|
+
* @group Common
|
|
721
|
+
*/
|
|
332
722
|
export declare interface ListRange {
|
|
723
|
+
/** The index of the last visible item */
|
|
333
724
|
endIndex: number;
|
|
725
|
+
/** The index of the first visible item */
|
|
334
726
|
startIndex: number;
|
|
335
727
|
}
|
|
336
728
|
|
|
729
|
+
/**
|
|
730
|
+
* @group Virtuoso
|
|
731
|
+
*/
|
|
337
732
|
export declare type ListRootProps = Omit<default_2.HTMLProps<HTMLDivElement>, 'data' | 'ref'>;
|
|
338
733
|
|
|
734
|
+
/**
|
|
735
|
+
* @group Common
|
|
736
|
+
*/
|
|
339
737
|
export declare interface LocationOptions {
|
|
340
738
|
/**
|
|
341
739
|
* How to position the item in the viewport.
|
|
@@ -351,38 +749,84 @@ export declare interface LocationOptions {
|
|
|
351
749
|
offset?: number;
|
|
352
750
|
}
|
|
353
751
|
|
|
752
|
+
/**
|
|
753
|
+
* Log levels for controlling virtuoso diagnostic output.
|
|
754
|
+
* Use with the `logLevel` prop to enable debugging information.
|
|
755
|
+
*
|
|
756
|
+
* @example
|
|
757
|
+
* ```tsx
|
|
758
|
+
* import { Virtuoso, LogLevel } from 'react-virtuoso'
|
|
759
|
+
*
|
|
760
|
+
* <Virtuoso
|
|
761
|
+
* totalCount={1000}
|
|
762
|
+
* logLevel={LogLevel.DEBUG}
|
|
763
|
+
* itemContent={(index) => <div>Item {index}</div>}
|
|
764
|
+
* />
|
|
765
|
+
* ```
|
|
766
|
+
*
|
|
767
|
+
* @group Common
|
|
768
|
+
*/
|
|
354
769
|
export declare enum LogLevel {
|
|
770
|
+
/** Detailed debugging information including item measurements */
|
|
355
771
|
DEBUG = 0,
|
|
772
|
+
/** General informational messages */
|
|
356
773
|
INFO = 1,
|
|
774
|
+
/** Warning messages for potential issues */
|
|
357
775
|
WARN = 2,
|
|
776
|
+
/** Error messages for failures (default level) */
|
|
358
777
|
ERROR = 3
|
|
359
778
|
}
|
|
360
779
|
|
|
361
|
-
|
|
362
|
-
|
|
780
|
+
/**
|
|
781
|
+
* Represents a regular data item (not a group header) in the list.
|
|
782
|
+
* @group Common
|
|
783
|
+
*/
|
|
784
|
+
export declare interface RecordItem<Data> extends Item<Data> {
|
|
785
|
+
/** The data associated with this item */
|
|
786
|
+
data?: Data;
|
|
787
|
+
/** The index of the group this item belongs to (if in a grouped list) */
|
|
363
788
|
groupIndex?: number;
|
|
789
|
+
/** The original index before any transformations were applied */
|
|
364
790
|
originalIndex?: number;
|
|
791
|
+
/** Undefined for regular items (used to distinguish from group items) */
|
|
365
792
|
type?: undefined;
|
|
366
793
|
}
|
|
367
794
|
|
|
795
|
+
/**
|
|
796
|
+
* Represents the current scroll state of the container.
|
|
797
|
+
* @group Common
|
|
798
|
+
*/
|
|
368
799
|
export declare interface ScrollContainerState {
|
|
800
|
+
/** The total scrollable height of the content in pixels */
|
|
369
801
|
scrollHeight: number;
|
|
802
|
+
/** The current scroll position from the top in pixels */
|
|
370
803
|
scrollTop: number;
|
|
804
|
+
/** The visible height of the viewport in pixels */
|
|
371
805
|
viewportHeight: number;
|
|
372
806
|
}
|
|
373
807
|
|
|
374
808
|
/**
|
|
375
809
|
* Passed to the Components.Scroller custom component
|
|
810
|
+
* @group Common
|
|
376
811
|
*/
|
|
377
812
|
export declare type ScrollerProps = Pick<default_2.ComponentProps<'div'>, 'children' | 'style' | 'tabIndex'> & default_2.RefAttributes<HTMLDivElement> & {
|
|
378
813
|
'data-testid'?: string;
|
|
379
814
|
'data-virtuoso-scroller'?: boolean;
|
|
380
815
|
};
|
|
381
816
|
|
|
817
|
+
/**
|
|
818
|
+
* @group Common
|
|
819
|
+
*/
|
|
382
820
|
export declare type ScrollIntoViewLocation = FlatScrollIntoViewLocation | GroupedScrollIntoViewLocation;
|
|
383
821
|
|
|
822
|
+
/**
|
|
823
|
+
* Options for scrolling an item into view.
|
|
824
|
+
* @group Common
|
|
825
|
+
*/
|
|
384
826
|
export declare interface ScrollIntoViewLocationOptions {
|
|
827
|
+
/** How to align the item within the viewport */
|
|
385
828
|
align?: 'center' | 'end' | 'start';
|
|
829
|
+
/** The scroll behavior - 'smooth' for animated scrolling, 'auto' for instant */
|
|
386
830
|
behavior?: 'auto' | 'smooth';
|
|
387
831
|
/**
|
|
388
832
|
* Use this function to fine-tune the scrollIntoView behavior.
|
|
@@ -414,9 +858,27 @@ export declare interface ScrollIntoViewLocationOptions {
|
|
|
414
858
|
done?: () => void;
|
|
415
859
|
}
|
|
416
860
|
|
|
861
|
+
/**
|
|
862
|
+
* Configuration for scroll seek mode, which renders placeholders during fast scrolling.
|
|
863
|
+
* This improves performance when users scroll rapidly through large lists.
|
|
864
|
+
*
|
|
865
|
+
* @example
|
|
866
|
+
* ```tsx
|
|
867
|
+
* const scrollSeekConfiguration: ScrollSeekConfiguration = {
|
|
868
|
+
* enter: (velocity) => Math.abs(velocity) > 200,
|
|
869
|
+
* exit: (velocity) => Math.abs(velocity) < 30,
|
|
870
|
+
* change: (velocity, range) => console.log('Scrolling', range),
|
|
871
|
+
* }
|
|
872
|
+
* <Virtuoso scrollSeekConfiguration={scrollSeekConfiguration} />
|
|
873
|
+
* ```
|
|
874
|
+
*
|
|
875
|
+
* @see {@link VirtuosoProps.scrollSeekConfiguration} for usage
|
|
876
|
+
* @see {@link Components.ScrollSeekPlaceholder} for custom placeholder rendering
|
|
877
|
+
* @group Common
|
|
878
|
+
*/
|
|
417
879
|
export declare interface ScrollSeekConfiguration {
|
|
418
880
|
/**
|
|
419
|
-
*
|
|
881
|
+
* Called during scrolling in scroll seek mode - use to display a hint where the list is.
|
|
420
882
|
*/
|
|
421
883
|
change?: (velocity: number, range: ListRange) => void;
|
|
422
884
|
/**
|
|
@@ -431,34 +893,73 @@ export declare interface ScrollSeekConfiguration {
|
|
|
431
893
|
|
|
432
894
|
/**
|
|
433
895
|
* Passed to the Components.ScrollSeekPlaceholder custom component
|
|
896
|
+
* @group Virtuoso
|
|
434
897
|
*/
|
|
435
898
|
export declare interface ScrollSeekPlaceholderProps {
|
|
899
|
+
/** The group index if this placeholder represents a group header */
|
|
436
900
|
groupIndex?: number;
|
|
901
|
+
/** The height of the placeholder in pixels */
|
|
437
902
|
height: number;
|
|
903
|
+
/** The index of the item being replaced by the placeholder */
|
|
438
904
|
index: number;
|
|
905
|
+
/** Whether this placeholder represents a group header or a regular item */
|
|
439
906
|
type: 'group' | 'item';
|
|
440
907
|
}
|
|
441
908
|
|
|
909
|
+
/**
|
|
910
|
+
* @group Common
|
|
911
|
+
*/
|
|
442
912
|
export declare type ScrollSeekToggle = (velocity: number, range: ListRange) => boolean;
|
|
443
913
|
|
|
444
|
-
/**
|
|
914
|
+
/**
|
|
915
|
+
* Custom function for calculating item sizes.
|
|
916
|
+
* Override to account for margins, padding, or other layout considerations.
|
|
917
|
+
*
|
|
918
|
+
* @see {@link VirtuosoProps.itemSize} for usage
|
|
919
|
+
* @group Common
|
|
920
|
+
*/
|
|
445
921
|
export declare type SizeFunction = (el: HTMLElement, field: 'offsetHeight' | 'offsetWidth') => number;
|
|
446
922
|
|
|
923
|
+
/**
|
|
924
|
+
* Represents a range of items that share the same size.
|
|
925
|
+
* @group Common
|
|
926
|
+
*/
|
|
447
927
|
export declare interface SizeRange {
|
|
928
|
+
/** The ending index of items in this size range (inclusive) */
|
|
448
929
|
endIndex: number;
|
|
930
|
+
/** The size in pixels shared by items in this range */
|
|
449
931
|
size: number;
|
|
932
|
+
/** The starting index of items in this size range */
|
|
450
933
|
startIndex: number;
|
|
451
934
|
}
|
|
452
935
|
|
|
936
|
+
/**
|
|
937
|
+
* Callback type for receiving state snapshots for persistence.
|
|
938
|
+
*
|
|
939
|
+
* @see {@link VirtuosoProps.getState} for usage
|
|
940
|
+
* @see {@link StateSnapshot} for the snapshot structure
|
|
941
|
+
* @group Common
|
|
942
|
+
*/
|
|
453
943
|
export declare type StateCallback = (state: StateSnapshot) => void;
|
|
454
944
|
|
|
945
|
+
/**
|
|
946
|
+
* A snapshot of the virtuoso state that can be saved and restored.
|
|
947
|
+
* Use this to persist scroll position and item sizes across page reloads.
|
|
948
|
+
*
|
|
949
|
+
* @see {@link VirtuosoProps.restoreStateFrom} for restoring state
|
|
950
|
+
* @see {@link VirtuosoHandle.getState} for capturing state
|
|
951
|
+
* @group Common
|
|
952
|
+
*/
|
|
455
953
|
export declare interface StateSnapshot {
|
|
954
|
+
/** The measured size ranges of items */
|
|
456
955
|
ranges: SizeRange[];
|
|
956
|
+
/** The scroll position in pixels */
|
|
457
957
|
scrollTop: number;
|
|
458
958
|
}
|
|
459
959
|
|
|
460
960
|
/**
|
|
461
|
-
* Passed to the
|
|
961
|
+
* Passed to the TableComponents.TableBody custom component
|
|
962
|
+
* @group TableVirtuoso
|
|
462
963
|
*/
|
|
463
964
|
export declare type TableBodyProps = Pick<default_2.ComponentProps<'tbody'>, 'children' | 'className' | 'style'> & default_2.RefAttributes<HTMLTableSectionElement> & {
|
|
464
965
|
'data-testid': string;
|
|
@@ -466,6 +967,21 @@ export declare type TableBodyProps = Pick<default_2.ComponentProps<'tbody'>, 'ch
|
|
|
466
967
|
|
|
467
968
|
/**
|
|
468
969
|
* Customize the TableVirtuoso rendering by passing a set of custom components.
|
|
970
|
+
*
|
|
971
|
+
* @typeParam Data - The type of data items in the table
|
|
972
|
+
* @typeParam Context - The type of additional context passed to components
|
|
973
|
+
*
|
|
974
|
+
* @example
|
|
975
|
+
* ```tsx
|
|
976
|
+
* const components: TableComponents<User, AppContext> = {
|
|
977
|
+
* Table: ({ children, style }) => <table style={style}>{children}</table>,
|
|
978
|
+
* TableRow: ({ children, item }) => <tr>{children}</tr>,
|
|
979
|
+
* }
|
|
980
|
+
* <TableVirtuoso components={components} />
|
|
981
|
+
* ```
|
|
982
|
+
*
|
|
983
|
+
* @see {@link TableVirtuosoProps.components} for usage in TableVirtuoso
|
|
984
|
+
* @group TableVirtuoso
|
|
469
985
|
*/
|
|
470
986
|
export declare interface TableComponents<Data = unknown, Context = unknown> {
|
|
471
987
|
/**
|
|
@@ -513,20 +1029,88 @@ export declare interface TableComponents<Data = unknown, Context = unknown> {
|
|
|
513
1029
|
TableRow?: default_2.ComponentType<ItemProps<Data> & ContextProp<Context>>;
|
|
514
1030
|
}
|
|
515
1031
|
|
|
1032
|
+
/**
|
|
1033
|
+
* @group TableVirtuoso
|
|
1034
|
+
*/
|
|
516
1035
|
export declare type TableProps = Pick<default_2.ComponentProps<'table'>, 'children' | 'style'>;
|
|
517
1036
|
|
|
1037
|
+
/**
|
|
1038
|
+
* @group TableVirtuoso
|
|
1039
|
+
*/
|
|
518
1040
|
export declare type TableRootProps = Omit<default_2.HTMLProps<HTMLTableElement>, 'data' | 'ref'>;
|
|
519
1041
|
|
|
1042
|
+
/**
|
|
1043
|
+
* A virtualized table component for efficiently rendering large tabular datasets.
|
|
1044
|
+
* Renders semantic HTML table markup with support for fixed headers and footers.
|
|
1045
|
+
*
|
|
1046
|
+
* @typeParam ItemData - The type of data items in the table
|
|
1047
|
+
* @typeParam Context - The type of additional context passed to callbacks
|
|
1048
|
+
*
|
|
1049
|
+
* @param props - {@link TableVirtuosoProps}
|
|
1050
|
+
*
|
|
1051
|
+
* @function
|
|
1052
|
+
* @group TableVirtuoso
|
|
1053
|
+
*
|
|
1054
|
+
* @example
|
|
1055
|
+
* ```tsx
|
|
1056
|
+
* <TableVirtuoso
|
|
1057
|
+
* totalCount={1000}
|
|
1058
|
+
* fixedHeaderContent={() => (
|
|
1059
|
+
* <tr>
|
|
1060
|
+
* <th>Name</th>
|
|
1061
|
+
* <th>Description</th>
|
|
1062
|
+
* </tr>
|
|
1063
|
+
* )}
|
|
1064
|
+
* itemContent={(index) => (
|
|
1065
|
+
* <>
|
|
1066
|
+
* <td>Item {index}</td>
|
|
1067
|
+
* <td>Description {index}</td>
|
|
1068
|
+
* </>
|
|
1069
|
+
* )}
|
|
1070
|
+
* />
|
|
1071
|
+
* ```
|
|
1072
|
+
*
|
|
1073
|
+
* @see {@link TableVirtuosoProps} for available props
|
|
1074
|
+
* @see {@link TableVirtuosoHandle} for imperative methods
|
|
1075
|
+
* @see {@link TableComponents} for customizing table elements
|
|
1076
|
+
*/
|
|
520
1077
|
export declare const TableVirtuoso: <ItemData = any, Context = any>(props: TableVirtuosoProps<ItemData, Context> & {
|
|
521
1078
|
ref?: default_2.Ref<TableVirtuosoHandle>;
|
|
522
1079
|
}) => default_2.ReactElement;
|
|
523
1080
|
|
|
1081
|
+
/**
|
|
1082
|
+
* Exposes the TableVirtuoso component methods for imperative control.
|
|
1083
|
+
* Access via ref on the TableVirtuoso component.
|
|
1084
|
+
*
|
|
1085
|
+
* @see {@link TableVirtuoso} for the component
|
|
1086
|
+
* @see {@link TableVirtuosoProps} for available props
|
|
1087
|
+
* @group TableVirtuoso
|
|
1088
|
+
*/
|
|
524
1089
|
export declare interface TableVirtuosoHandle extends BaseTableVirtuosoHandle {
|
|
1090
|
+
/**
|
|
1091
|
+
* Scrolls the specified item into view if it's not already visible.
|
|
1092
|
+
* @param location - The item index or scroll into view location options
|
|
1093
|
+
*/
|
|
525
1094
|
scrollIntoView(location: FlatScrollIntoViewLocation | number): void;
|
|
1095
|
+
/**
|
|
1096
|
+
* Scrolls the component to the specified item index.
|
|
1097
|
+
* @param location - The item index or location with alignment options
|
|
1098
|
+
*/
|
|
526
1099
|
scrollToIndex(location: FlatIndexLocationWithAlign | number): void;
|
|
527
1100
|
}
|
|
528
1101
|
|
|
529
|
-
|
|
1102
|
+
/**
|
|
1103
|
+
* The props for the TableVirtuoso component.
|
|
1104
|
+
*
|
|
1105
|
+
* @typeParam Data - The type of data items in the table
|
|
1106
|
+
* @typeParam Context - The type of additional context passed to callbacks
|
|
1107
|
+
*
|
|
1108
|
+
* @see {@link TableVirtuoso} for the component
|
|
1109
|
+
* @see {@link TableVirtuosoHandle} for imperative methods
|
|
1110
|
+
* @see {@link TableComponents} for customizing table elements
|
|
1111
|
+
* @group TableVirtuoso
|
|
1112
|
+
*/
|
|
1113
|
+
export declare interface TableVirtuosoProps<Data, Context> extends Omit<VirtuosoProps<Data, Context>, 'components' | 'headerFooterTag'> {
|
|
530
1114
|
/**
|
|
531
1115
|
* Setting `alignToBottom` to `true` aligns the items to the bottom of the list if the list is shorter than the viewport.
|
|
532
1116
|
* Use `followOutput` property to keep the list aligned when new items are appended.
|
|
@@ -552,11 +1136,11 @@ export declare interface TableVirtuosoProps<D, C> extends Omit<VirtuosoProps<D,
|
|
|
552
1136
|
/**
|
|
553
1137
|
* Use the `components` property for advanced customization of the elements rendered by the table.
|
|
554
1138
|
*/
|
|
555
|
-
components?: TableComponents<
|
|
1139
|
+
components?: TableComponents<Data, Context>;
|
|
556
1140
|
/**
|
|
557
1141
|
* If specified, the component will use the function to generate the `key` property for each list item.
|
|
558
1142
|
*/
|
|
559
|
-
computeItemKey?: ComputeItemKey<
|
|
1143
|
+
computeItemKey?: ComputeItemKey<Data, Context>;
|
|
560
1144
|
/**
|
|
561
1145
|
* Pass a reference to a scrollable parent element, so that the table won't wrap in its own.
|
|
562
1146
|
*/
|
|
@@ -564,7 +1148,7 @@ export declare interface TableVirtuosoProps<D, C> extends Omit<VirtuosoProps<D,
|
|
|
564
1148
|
/**
|
|
565
1149
|
* The data items to be rendered. If data is set, the total count will be inferred from the length of the array.
|
|
566
1150
|
*/
|
|
567
|
-
data?: readonly
|
|
1151
|
+
data?: readonly Data[];
|
|
568
1152
|
/**
|
|
569
1153
|
* By default, the component assumes the default item height from the first rendered item (rendering it as a "probe").
|
|
570
1154
|
*
|
|
@@ -661,7 +1245,7 @@ export declare interface TableVirtuosoProps<D, C> extends Omit<VirtuosoProps<D,
|
|
|
661
1245
|
/**
|
|
662
1246
|
* Set the callback to specify the contents of the item.
|
|
663
1247
|
*/
|
|
664
|
-
itemContent?: ItemContent<
|
|
1248
|
+
itemContent?: ItemContent<Data, Context>;
|
|
665
1249
|
/**
|
|
666
1250
|
* Allows customizing the height/width calculation of `Item` elements.
|
|
667
1251
|
*
|
|
@@ -671,7 +1255,7 @@ export declare interface TableVirtuosoProps<D, C> extends Omit<VirtuosoProps<D,
|
|
|
671
1255
|
/**
|
|
672
1256
|
* Called with the new set of items each time the list items are rendered due to scrolling.
|
|
673
1257
|
*/
|
|
674
|
-
itemsRendered?: (items: ListItem<
|
|
1258
|
+
itemsRendered?: (items: ListItem<Data>[]) => void;
|
|
675
1259
|
/**
|
|
676
1260
|
* Set the overscan property to make the component "chunk" the rendering of new items on scroll.
|
|
677
1261
|
* The property causes the component to render more items than the necessary, but reduces the re-renders on scroll.
|
|
@@ -724,32 +1308,140 @@ export declare interface TableVirtuosoProps<D, C> extends Omit<VirtuosoProps<D,
|
|
|
724
1308
|
useWindowScroll?: boolean;
|
|
725
1309
|
}
|
|
726
1310
|
|
|
1311
|
+
/**
|
|
1312
|
+
* @group Virtuoso
|
|
1313
|
+
*/
|
|
727
1314
|
export declare type TopItemListProps = Pick<default_2.ComponentProps<'div'>, 'children' | 'style'>;
|
|
728
1315
|
|
|
1316
|
+
/**
|
|
1317
|
+
* A virtualized list component for efficiently rendering large datasets.
|
|
1318
|
+
* Automatically measures and handles variable-sized items without configuration.
|
|
1319
|
+
*
|
|
1320
|
+
* @typeParam ItemData - The type of data items in the list
|
|
1321
|
+
* @typeParam Context - The type of additional context passed to callbacks
|
|
1322
|
+
*
|
|
1323
|
+
* @param props - {@link VirtuosoProps}
|
|
1324
|
+
*
|
|
1325
|
+
* @function
|
|
1326
|
+
* @group Virtuoso
|
|
1327
|
+
*
|
|
1328
|
+
* @example
|
|
1329
|
+
* ```tsx
|
|
1330
|
+
* <Virtuoso
|
|
1331
|
+
* totalCount={1000}
|
|
1332
|
+
* itemContent={(index) => <div>Item {index}</div>}
|
|
1333
|
+
* />
|
|
1334
|
+
* ```
|
|
1335
|
+
*
|
|
1336
|
+
* @see {@link VirtuosoProps} for available props
|
|
1337
|
+
* @see {@link VirtuosoHandle} for imperative methods
|
|
1338
|
+
*/
|
|
729
1339
|
export declare const Virtuoso: <ItemData = any, Context = any>(props: VirtuosoProps<ItemData, Context> & {
|
|
730
1340
|
ref?: default_2.Ref<VirtuosoHandle>;
|
|
731
1341
|
}) => default_2.ReactElement;
|
|
732
1342
|
|
|
1343
|
+
/**
|
|
1344
|
+
* A virtualized grid component for efficiently rendering large datasets in a grid/masonry layout.
|
|
1345
|
+
* Automatically calculates visible items based on container and item dimensions.
|
|
1346
|
+
*
|
|
1347
|
+
* @typeParam ItemData - The type of data items in the grid
|
|
1348
|
+
* @typeParam Context - The type of additional context passed to callbacks
|
|
1349
|
+
*
|
|
1350
|
+
* @param props - {@link VirtuosoGridProps}
|
|
1351
|
+
*
|
|
1352
|
+
* @function
|
|
1353
|
+
* @group VirtuosoGrid
|
|
1354
|
+
*
|
|
1355
|
+
* @example
|
|
1356
|
+
* ```tsx
|
|
1357
|
+
* <VirtuosoGrid
|
|
1358
|
+
* totalCount={1000}
|
|
1359
|
+
* itemContent={(index) => <div className="grid-item">Item {index}</div>}
|
|
1360
|
+
* listClassName="grid-container"
|
|
1361
|
+
* />
|
|
1362
|
+
* ```
|
|
1363
|
+
*
|
|
1364
|
+
* @see {@link VirtuosoGridProps} for available props
|
|
1365
|
+
* @see {@link VirtuosoGridHandle} for imperative methods
|
|
1366
|
+
* @see {@link GridComponents} for customizing grid elements
|
|
1367
|
+
*/
|
|
733
1368
|
export declare const VirtuosoGrid: <ItemData = any, Context = any>(props: VirtuosoGridProps<ItemData, Context> & {
|
|
734
1369
|
ref?: default_2.Ref<VirtuosoGridHandle>;
|
|
735
1370
|
}) => default_2.ReactElement;
|
|
736
1371
|
|
|
1372
|
+
/**
|
|
1373
|
+
* Exposes the VirtuosoGrid component methods for imperative control.
|
|
1374
|
+
* Access via ref on the VirtuosoGrid component.
|
|
1375
|
+
*
|
|
1376
|
+
* @see {@link VirtuosoGrid} for the component
|
|
1377
|
+
* @see {@link VirtuosoGridProps} for available props
|
|
1378
|
+
* @group VirtuosoGrid
|
|
1379
|
+
*/
|
|
737
1380
|
export declare interface VirtuosoGridHandle {
|
|
1381
|
+
/**
|
|
1382
|
+
* Scrolls the component by the specified amount.
|
|
1383
|
+
* @param location - The scroll offset options
|
|
1384
|
+
*/
|
|
738
1385
|
scrollBy(location: ScrollToOptions): void;
|
|
1386
|
+
/**
|
|
1387
|
+
* Scrolls the component to the specified position.
|
|
1388
|
+
* @param location - The scroll position options
|
|
1389
|
+
*/
|
|
739
1390
|
scrollTo(location: ScrollToOptions): void;
|
|
1391
|
+
/**
|
|
1392
|
+
* Scrolls the component to the specified item index.
|
|
1393
|
+
* @param location - The item index or location with alignment options
|
|
1394
|
+
*/
|
|
740
1395
|
scrollToIndex(location: GridIndexLocation): void;
|
|
741
1396
|
}
|
|
742
1397
|
|
|
1398
|
+
/**
|
|
1399
|
+
* React context for mocking VirtuosoGrid component measurements in tests.
|
|
1400
|
+
* Wrap your VirtuosoGrid component with this provider to bypass DOM measurements.
|
|
1401
|
+
*
|
|
1402
|
+
* @example
|
|
1403
|
+
* ```tsx
|
|
1404
|
+
* import { VirtuosoGridMockContext } from 'react-virtuoso'
|
|
1405
|
+
*
|
|
1406
|
+
* <VirtuosoGridMockContext.Provider
|
|
1407
|
+
* value={{ viewportHeight: 300, viewportWidth: 400, itemHeight: 100, itemWidth: 100 }}
|
|
1408
|
+
* >
|
|
1409
|
+
* <VirtuosoGrid totalCount={100} />
|
|
1410
|
+
* </VirtuosoGridMockContext.Provider>
|
|
1411
|
+
* ```
|
|
1412
|
+
*
|
|
1413
|
+
* @group VirtuosoGrid
|
|
1414
|
+
*/
|
|
743
1415
|
export declare const VirtuosoGridMockContext: default_2.Context<VirtuosoGridMockContextValue | undefined>;
|
|
744
1416
|
|
|
1417
|
+
/**
|
|
1418
|
+
* Mock context value for testing VirtuosoGrid components.
|
|
1419
|
+
* Provides fixed dimensions to bypass DOM measurements.
|
|
1420
|
+
*
|
|
1421
|
+
* @group VirtuosoGrid
|
|
1422
|
+
*/
|
|
745
1423
|
export declare interface VirtuosoGridMockContextValue {
|
|
1424
|
+
/** Fixed height for each grid item in pixels */
|
|
746
1425
|
itemHeight: number;
|
|
1426
|
+
/** Fixed width for each grid item in pixels */
|
|
747
1427
|
itemWidth: number;
|
|
1428
|
+
/** Fixed viewport height in pixels */
|
|
748
1429
|
viewportHeight: number;
|
|
1430
|
+
/** Fixed viewport width in pixels */
|
|
749
1431
|
viewportWidth: number;
|
|
750
1432
|
}
|
|
751
1433
|
|
|
752
|
-
|
|
1434
|
+
/**
|
|
1435
|
+
* The props for the VirtuosoGrid component.
|
|
1436
|
+
*
|
|
1437
|
+
* @typeParam Data - The type of data items in the grid
|
|
1438
|
+
* @typeParam Context - The type of additional context passed to callbacks
|
|
1439
|
+
*
|
|
1440
|
+
* @see {@link VirtuosoGrid} for the component
|
|
1441
|
+
* @see {@link VirtuosoGridHandle} for imperative methods
|
|
1442
|
+
* @group VirtuosoGrid
|
|
1443
|
+
*/
|
|
1444
|
+
export declare interface VirtuosoGridProps<Data, Context = unknown> extends GridRootProps {
|
|
753
1445
|
/**
|
|
754
1446
|
* Called with true / false when the list has reached the bottom / gets scrolled up.
|
|
755
1447
|
* Can be used to load newer items, like `tail -f`.
|
|
@@ -762,15 +1454,15 @@ export declare interface VirtuosoGridProps<D, C = unknown> extends GridRootProps
|
|
|
762
1454
|
/**
|
|
763
1455
|
* Use the `components` property for advanced customization of the elements rendered by the list.
|
|
764
1456
|
*/
|
|
765
|
-
components?: GridComponents<
|
|
1457
|
+
components?: GridComponents<Context>;
|
|
766
1458
|
/**
|
|
767
1459
|
* If specified, the component will use the function to generate the `key` property for each list item.
|
|
768
1460
|
*/
|
|
769
|
-
computeItemKey?: GridComputeItemKey<
|
|
1461
|
+
computeItemKey?: GridComputeItemKey<Data, Context>;
|
|
770
1462
|
/**
|
|
771
1463
|
* Additional context available in the custom components and content callbacks
|
|
772
1464
|
*/
|
|
773
|
-
context?:
|
|
1465
|
+
context?: Context;
|
|
774
1466
|
/**
|
|
775
1467
|
* Pass a reference to a scrollable parent element, so that the grid won't wrap in its own.
|
|
776
1468
|
*/
|
|
@@ -778,7 +1470,7 @@ export declare interface VirtuosoGridProps<D, C = unknown> extends GridRootProps
|
|
|
778
1470
|
/**
|
|
779
1471
|
* The data items to be rendered. If data is set, the total count will be inferred from the length of the array.
|
|
780
1472
|
*/
|
|
781
|
-
data?: readonly
|
|
1473
|
+
data?: readonly Data[];
|
|
782
1474
|
/**
|
|
783
1475
|
* Gets called when the user scrolls to the end of the list.
|
|
784
1476
|
* Receives the last item index as an argument. Can be used to implement endless scrolling.
|
|
@@ -802,6 +1494,10 @@ export declare interface VirtuosoGridProps<D, C = unknown> extends GridRootProps
|
|
|
802
1494
|
* regardless of the container / item size.
|
|
803
1495
|
*/
|
|
804
1496
|
initialItemCount?: number;
|
|
1497
|
+
/**
|
|
1498
|
+
* Set to a value between 0 and totalCount - 1 to make the grid start scrolled to that item.
|
|
1499
|
+
* Pass in an object to achieve additional effects similar to `scrollToIndex`.
|
|
1500
|
+
*/
|
|
805
1501
|
initialTopMostItemIndex?: GridIndexLocation;
|
|
806
1502
|
/**
|
|
807
1503
|
* Called when the list starts/stops scrolling.
|
|
@@ -814,7 +1510,7 @@ export declare interface VirtuosoGridProps<D, C = unknown> extends GridRootProps
|
|
|
814
1510
|
/**
|
|
815
1511
|
* Set the callback to specify the contents of the item.
|
|
816
1512
|
*/
|
|
817
|
-
itemContent?: GridItemContent<
|
|
1513
|
+
itemContent?: GridItemContent<Data, Context>;
|
|
818
1514
|
/**
|
|
819
1515
|
* Sets the className for the list DOM element
|
|
820
1516
|
*/
|
|
@@ -843,6 +1539,10 @@ export declare interface VirtuosoGridProps<D, C = unknown> extends GridRootProps
|
|
|
843
1539
|
* invoked with true after the grid has done the initial render and the items have been measured.
|
|
844
1540
|
*/
|
|
845
1541
|
readyStateChanged?: (ready: boolean) => void;
|
|
1542
|
+
/**
|
|
1543
|
+
* Pass a state obtained from the `stateChanged` callback to restore the grid state.
|
|
1544
|
+
* This includes scroll position and item measurements.
|
|
1545
|
+
*/
|
|
846
1546
|
restoreStateFrom?: GridStateSnapshot | null | undefined;
|
|
847
1547
|
/**
|
|
848
1548
|
* Provides access to the root DOM element
|
|
@@ -872,6 +1572,14 @@ export declare interface VirtuosoGridProps<D, C = unknown> extends GridRootProps
|
|
|
872
1572
|
useWindowScroll?: boolean;
|
|
873
1573
|
}
|
|
874
1574
|
|
|
1575
|
+
/**
|
|
1576
|
+
* Exposes the Virtuoso component methods for imperative control.
|
|
1577
|
+
* Access via ref on the Virtuoso component.
|
|
1578
|
+
*
|
|
1579
|
+
* @see {@link Virtuoso} for the component
|
|
1580
|
+
* @see {@link VirtuosoProps} for available props
|
|
1581
|
+
* @group Virtuoso
|
|
1582
|
+
*/
|
|
875
1583
|
export declare interface VirtuosoHandle {
|
|
876
1584
|
/**
|
|
877
1585
|
* Use this with combination with follow output if you have images loading in the list. Listen to the image loading and call the method.
|
|
@@ -879,34 +1587,72 @@ export declare interface VirtuosoHandle {
|
|
|
879
1587
|
autoscrollToBottom(): void;
|
|
880
1588
|
/**
|
|
881
1589
|
* Obtains the internal size state of the component, so that it can be restored later. This does not include the data items.
|
|
1590
|
+
* @param stateCb - Callback that receives the state snapshot
|
|
882
1591
|
*/
|
|
883
1592
|
getState(stateCb: StateCallback): void;
|
|
884
1593
|
/**
|
|
885
1594
|
* Scrolls the component with the specified amount. See [ScrollToOptions (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions)
|
|
1595
|
+
* @param location - The scroll offset options
|
|
886
1596
|
*/
|
|
887
1597
|
scrollBy(location: ScrollToOptions): void;
|
|
888
1598
|
/**
|
|
889
1599
|
* Scrolls the item into view if necessary. See [the website example](http://virtuoso.dev/keyboard-navigation/) for an implementation.
|
|
1600
|
+
* @param location - The scroll into view location options
|
|
890
1601
|
*/
|
|
891
1602
|
scrollIntoView(location: FlatScrollIntoViewLocation): void;
|
|
892
1603
|
/**
|
|
893
1604
|
* Scrolls the component to the specified location. See [ScrollToOptions (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions)
|
|
1605
|
+
* @param location - The scroll position options
|
|
894
1606
|
*/
|
|
895
1607
|
scrollTo(location: ScrollToOptions): void;
|
|
896
1608
|
/**
|
|
897
1609
|
* Scrolls the component to the specified item index. See {@link IndexLocationWithAlign} for more options.
|
|
1610
|
+
* @param location - The item index or location with alignment options
|
|
898
1611
|
*/
|
|
899
1612
|
scrollToIndex(location: FlatIndexLocationWithAlign | number): void;
|
|
900
1613
|
}
|
|
901
1614
|
|
|
1615
|
+
/**
|
|
1616
|
+
* React context for mocking Virtuoso component measurements in tests.
|
|
1617
|
+
* Wrap your Virtuoso component with this provider to bypass DOM measurements.
|
|
1618
|
+
*
|
|
1619
|
+
* @example
|
|
1620
|
+
* ```tsx
|
|
1621
|
+
* import { VirtuosoMockContext } from 'react-virtuoso'
|
|
1622
|
+
*
|
|
1623
|
+
* <VirtuosoMockContext.Provider value={{ viewportHeight: 300, itemHeight: 30 }}>
|
|
1624
|
+
* <Virtuoso totalCount={100} />
|
|
1625
|
+
* </VirtuosoMockContext.Provider>
|
|
1626
|
+
* ```
|
|
1627
|
+
*
|
|
1628
|
+
* @group Virtuoso
|
|
1629
|
+
*/
|
|
902
1630
|
export declare const VirtuosoMockContext: default_2.Context<VirtuosoMockContextValue | undefined>;
|
|
903
1631
|
|
|
1632
|
+
/**
|
|
1633
|
+
* Mock context value for testing Virtuoso components.
|
|
1634
|
+
* Provides fixed dimensions to bypass DOM measurements.
|
|
1635
|
+
*
|
|
1636
|
+
* @group Virtuoso
|
|
1637
|
+
*/
|
|
904
1638
|
export declare interface VirtuosoMockContextValue {
|
|
1639
|
+
/** Fixed height for each item in pixels */
|
|
905
1640
|
itemHeight: number;
|
|
1641
|
+
/** Fixed viewport height in pixels */
|
|
906
1642
|
viewportHeight: number;
|
|
907
1643
|
}
|
|
908
1644
|
|
|
909
|
-
|
|
1645
|
+
/**
|
|
1646
|
+
* The props for the Virtuoso component.
|
|
1647
|
+
*
|
|
1648
|
+
* @typeParam Data - The type of data items in the list
|
|
1649
|
+
* @typeParam Context - The type of additional context passed to callbacks
|
|
1650
|
+
*
|
|
1651
|
+
* @see {@link Virtuoso} for the component
|
|
1652
|
+
* @see {@link VirtuosoHandle} for imperative methods
|
|
1653
|
+
* @group Virtuoso
|
|
1654
|
+
*/
|
|
1655
|
+
export declare interface VirtuosoProps<Data, Context> extends ListRootProps {
|
|
910
1656
|
/**
|
|
911
1657
|
* Setting `alignToBottom` to `true` aligns the items to the bottom of the list if the list is shorter than the viewport.
|
|
912
1658
|
* Use `followOutput` property to keep the list aligned when new items are appended.
|
|
@@ -936,15 +1682,15 @@ export declare interface VirtuosoProps<D, C> extends ListRootProps {
|
|
|
936
1682
|
/**
|
|
937
1683
|
* Use the `components` property for advanced customization of the elements rendered by the list.
|
|
938
1684
|
*/
|
|
939
|
-
components?: Components<
|
|
1685
|
+
components?: Components<Data, Context>;
|
|
940
1686
|
/**
|
|
941
1687
|
* If specified, the component will use the function to generate the `key` property for each list item.
|
|
942
1688
|
*/
|
|
943
|
-
computeItemKey?: ComputeItemKey<
|
|
1689
|
+
computeItemKey?: ComputeItemKey<Data, Context>;
|
|
944
1690
|
/**
|
|
945
1691
|
* Additional context available in the custom components and content callbacks
|
|
946
1692
|
*/
|
|
947
|
-
context?:
|
|
1693
|
+
context?: Context;
|
|
948
1694
|
/**
|
|
949
1695
|
* Pass a reference to a scrollable parent element, so that the list won't wrap in its own.
|
|
950
1696
|
*/
|
|
@@ -952,7 +1698,7 @@ export declare interface VirtuosoProps<D, C> extends ListRootProps {
|
|
|
952
1698
|
/**
|
|
953
1699
|
* The data items to be rendered. If data is set, the total count will be inferred from the length of the array.
|
|
954
1700
|
*/
|
|
955
|
-
data?: readonly
|
|
1701
|
+
data?: readonly Data[];
|
|
956
1702
|
/**
|
|
957
1703
|
* By default, the component assumes the default item height from the first rendered item (rendering it as a "probe").
|
|
958
1704
|
*
|
|
@@ -1030,10 +1776,10 @@ export declare interface VirtuosoProps<D, C> extends ListRootProps {
|
|
|
1030
1776
|
* Use the context contents if you need to implement custom logic based on the current state of the list.
|
|
1031
1777
|
*/
|
|
1032
1778
|
scrollIntoViewOnChange?: (params: {
|
|
1033
|
-
context:
|
|
1779
|
+
context: Context;
|
|
1034
1780
|
totalCount: number;
|
|
1035
1781
|
scrollingInProgress: boolean;
|
|
1036
|
-
}) => ScrollIntoViewLocation | null | undefined | false
|
|
1782
|
+
}) => ScrollIntoViewLocation | null | undefined | false;
|
|
1037
1783
|
/**
|
|
1038
1784
|
* Set to customize the wrapper tag for the header and footer components (default is `div`).
|
|
1039
1785
|
*/
|
|
@@ -1088,7 +1834,7 @@ export declare interface VirtuosoProps<D, C> extends ListRootProps {
|
|
|
1088
1834
|
/**
|
|
1089
1835
|
* Set the callback to specify the contents of the item.
|
|
1090
1836
|
*/
|
|
1091
|
-
itemContent?: ItemContent<
|
|
1837
|
+
itemContent?: ItemContent<Data, Context>;
|
|
1092
1838
|
/**
|
|
1093
1839
|
* Allows customizing the height/width calculation of `Item` elements.
|
|
1094
1840
|
*
|
|
@@ -1098,7 +1844,7 @@ export declare interface VirtuosoProps<D, C> extends ListRootProps {
|
|
|
1098
1844
|
/**
|
|
1099
1845
|
* Called with the new set of items each time the list items are rendered due to scrolling.
|
|
1100
1846
|
*/
|
|
1101
|
-
itemsRendered?: (items: ListItem<
|
|
1847
|
+
itemsRendered?: (items: ListItem<Data>[]) => void;
|
|
1102
1848
|
/**
|
|
1103
1849
|
* set to LogLevel.DEBUG to enable various diagnostics in the console, the most useful being the item measurement reports.
|
|
1104
1850
|
*
|
|
@@ -1168,9 +1914,16 @@ export declare interface VirtuosoProps<D, C> extends ListRootProps {
|
|
|
1168
1914
|
useWindowScroll?: boolean;
|
|
1169
1915
|
}
|
|
1170
1916
|
|
|
1917
|
+
/**
|
|
1918
|
+
* Information about the window viewport when using window scrolling mode.
|
|
1919
|
+
* @group Common
|
|
1920
|
+
*/
|
|
1171
1921
|
export declare interface WindowViewportInfo {
|
|
1922
|
+
/** The offset from the top of the document to the list container in pixels */
|
|
1172
1923
|
offsetTop: number;
|
|
1924
|
+
/** The visible height of the window viewport in pixels */
|
|
1173
1925
|
visibleHeight: number;
|
|
1926
|
+
/** The visible width of the window viewport in pixels */
|
|
1174
1927
|
visibleWidth: number;
|
|
1175
1928
|
}
|
|
1176
1929
|
|