react-virtuoso 4.0.4 → 4.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,13 +1,4 @@
1
- /// <reference types="react" />
2
-
3
- import { ComponentPropsWithRef } from 'react';
4
- import { ComponentType } from 'react';
5
- import { Context } from 'react';
6
- import { HTMLProps } from 'react';
7
- import { Key } from 'react';
8
- import { ReactElement } from 'react';
9
- import { ReactNode } from 'react';
10
- import { Ref } from 'react';
1
+ import { default as React_2 } from 'react';
11
2
 
12
3
  /**
13
4
  * Customize the Virtuoso rendering by passing a set of custom components.
@@ -18,63 +9,63 @@ export declare interface Components<Data = unknown, Context = unknown> {
18
9
  *
19
10
  * The header remains above the top items and does not remain sticky.
20
11
  */
21
- Header?: ComponentType<{
12
+ Header?: React_2.ComponentType<{
22
13
  context?: Context;
23
14
  }>;
24
15
  /**
25
16
  * Set to render a component at the bottom of the list.
26
17
  */
27
- Footer?: ComponentType<{
18
+ Footer?: React_2.ComponentType<{
28
19
  context?: Context;
29
20
  }>;
30
21
  /**
31
22
  * Set to customize the item wrapping element. Use only if you would like to render list from elements different than a `div`.
32
23
  */
33
- Item?: ComponentType<ItemProps<Data> & {
24
+ Item?: React_2.ComponentType<ItemProps<Data> & {
34
25
  context?: Context;
35
26
  }>;
36
27
  /**
37
28
  * Set to customize the group item wrapping element. Use only if you would like to render list from elements different than a `div`.
38
29
  */
39
- Group?: ComponentType<GroupProps & {
30
+ Group?: React_2.ComponentType<GroupProps & {
40
31
  context?: Context;
41
32
  }>;
42
33
  /**
43
34
  * Set to customize the top list item wrapping element. Use if you would like to render list from elements different than a `div`
44
35
  * or you want to set a custom z-index for the sticky position.
45
36
  */
46
- TopItemList?: ComponentType<TopItemListProps & {
37
+ TopItemList?: React_2.ComponentType<TopItemListProps & {
47
38
  context?: Context;
48
39
  }>;
49
40
  /**
50
41
  * Set to customize the outermost scrollable element. This should not be necessary in general,
51
42
  * as the component passes its HTML attribute props to it.
52
43
  */
53
- Scroller?: ComponentType<ScrollerProps & {
44
+ Scroller?: React_2.ComponentType<ScrollerProps & {
54
45
  context?: Context;
55
46
  }>;
56
47
  /**
57
48
  * Set to customize the items wrapper. Use only if you would like to render list from elements different than a `div`.
58
49
  */
59
- List?: ComponentType<ListProps & {
50
+ List?: React_2.ComponentType<ListProps & {
60
51
  context?: Context;
61
52
  }>;
62
53
  /**
63
54
  * Set to render a custom UI when the list is empty.
64
55
  */
65
- EmptyPlaceholder?: ComponentType<{
56
+ EmptyPlaceholder?: React_2.ComponentType<{
66
57
  context?: Context;
67
58
  }>;
68
59
  /**
69
60
  * Set to render an item placeholder when the user scrolls fast. See the `scrollSeek` property for more details.
70
61
  */
71
- ScrollSeekPlaceholder?: ComponentType<ScrollSeekPlaceholderProps & {
62
+ ScrollSeekPlaceholder?: React_2.ComponentType<ScrollSeekPlaceholderProps & {
72
63
  context?: Context;
73
64
  }>;
74
65
  }
75
66
 
76
67
  export declare interface ComputeItemKey<D, C> {
77
- (index: number, item: D, context: C): Key;
68
+ (index: number, item: D, context: C): React_2.Key;
78
69
  }
79
70
 
80
71
  /**
@@ -84,9 +75,9 @@ export declare interface FillerRowProps {
84
75
  height: number;
85
76
  }
86
77
 
87
- export declare type FixedFooterContent = (() => ReactNode) | null;
78
+ export declare type FixedFooterContent = (() => React_2.ReactNode) | null;
88
79
 
89
- export declare type FixedHeaderContent = (() => ReactNode) | null;
80
+ export declare type FixedHeaderContent = (() => React_2.ReactNode) | null;
90
81
 
91
82
  export declare interface FlatIndexLocationWithAlign extends LocationOptions {
92
83
  /**
@@ -109,20 +100,20 @@ export declare interface GridComponents<Context = any> {
109
100
  /**
110
101
  * Set to customize the item wrapping element. Use only if you would like to render list from elements different than a `div`.
111
102
  */
112
- Item?: ComponentType<GridItemProps & {
103
+ Item?: React_2.ComponentType<GridItemProps & {
113
104
  context?: Context;
114
105
  }>;
115
106
  /**
116
107
  * Set to customize the outermost scrollable element. This should not be necessary in general,
117
108
  * as the component passes its HTML attribute props to it.
118
109
  */
119
- Scroller?: ComponentType<ScrollerProps & {
110
+ Scroller?: React_2.ComponentType<ScrollerProps & {
120
111
  context?: Context;
121
112
  }>;
122
113
  /**
123
114
  * Set to customize the items wrapper. Use only if you would like to render list from elements different than a `div`.
124
115
  */
125
- List?: ComponentType<GridListProps & {
116
+ List?: React_2.ComponentType<GridListProps & {
126
117
  context?: Context;
127
118
  }>;
128
119
  /**
@@ -130,26 +121,26 @@ export declare interface GridComponents<Context = any> {
130
121
  *
131
122
  * The header remains above the top items and does not remain sticky.
132
123
  */
133
- Header?: ComponentType<{
124
+ Header?: React_2.ComponentType<{
134
125
  context?: Context;
135
126
  }>;
136
127
  /**
137
128
  * Set to render a component at the bottom of the list.
138
129
  */
139
- Footer?: ComponentType<{
130
+ Footer?: React_2.ComponentType<{
140
131
  context?: Context;
141
132
  }>;
142
133
  /**
143
134
  * Set to render an item placeholder when the user scrolls fast.
144
135
  * See the `scrollSeekConfiguration` property for more details.
145
136
  */
146
- ScrollSeekPlaceholder?: ComponentType<GridScrollSeekPlaceholderProps & {
137
+ ScrollSeekPlaceholder?: React_2.ComponentType<GridScrollSeekPlaceholderProps & {
147
138
  context?: Context;
148
139
  }>;
149
140
  }
150
141
 
151
142
  export declare interface GridComputeItemKey<D, C> {
152
- (index: number, item: D, context: C): Key;
143
+ (index: number, item: D, context: C): React_2.Key;
153
144
  }
154
145
 
155
146
  export declare interface GridItem<D> {
@@ -158,7 +149,7 @@ export declare interface GridItem<D> {
158
149
  }
159
150
 
160
151
  export declare interface GridItemContent<D, C> {
161
- (index: number, data: D, context: C): ReactNode;
152
+ (index: number, data: D, context: C): React_2.ReactNode;
162
153
  }
163
154
 
164
155
  export declare interface GridItemProps {
@@ -169,11 +160,11 @@ export declare interface GridItemProps {
169
160
  /**
170
161
  * Passed to the Components.List custom component
171
162
  */
172
- export declare type GridListProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children' | 'ref' | 'className'> & {
163
+ export declare type GridListProps = Pick<React_2.ComponentPropsWithRef<'div'>, 'style' | 'children' | 'ref' | 'className'> & {
173
164
  'data-test-id': string;
174
165
  };
175
166
 
176
- export declare type GridRootProps = Omit<HTMLProps<HTMLDivElement>, 'ref' | 'data'>;
167
+ export declare type GridRootProps = Omit<React_2.HTMLProps<HTMLDivElement>, 'ref' | 'data'>;
177
168
 
178
169
  /**
179
170
  * Passed to the GridComponents.ScrollSeekPlaceholder custom component
@@ -185,7 +176,7 @@ export declare interface GridScrollSeekPlaceholderProps {
185
176
  }
186
177
 
187
178
  export declare interface GroupContent {
188
- (index: number): ReactNode;
179
+ (index: number): React_2.ReactNode;
189
180
  }
190
181
 
191
182
  export declare interface GroupedScrollIntoViewLocation extends ScrollIntoViewLocationOptions {
@@ -193,8 +184,8 @@ export declare interface GroupedScrollIntoViewLocation extends ScrollIntoViewLoc
193
184
  }
194
185
 
195
186
  export declare const GroupedVirtuoso: <ItemData = any, Context = any>(props: GroupedVirtuosoProps<ItemData, Context> & {
196
- ref?: Ref<GroupedVirtuosoHandle> | undefined;
197
- }) => ReactElement;
187
+ ref?: React_2.Ref<GroupedVirtuosoHandle> | undefined;
188
+ }) => React_2.ReactElement;
198
189
 
199
190
  export declare interface GroupedVirtuosoHandle {
200
191
  scrollToIndex(location: number | IndexLocationWithAlign): void;
@@ -233,10 +224,10 @@ export declare interface GroupItem<D> extends Item<D> {
233
224
  }
234
225
 
235
226
  export declare interface GroupItemContent<D, C> {
236
- (index: number, groupIndex: number, data: D, context: C): ReactNode;
227
+ (index: number, groupIndex: number, data: D, context: C): React_2.ReactNode;
237
228
  }
238
229
 
239
- export declare type GroupProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children'> & {
230
+ export declare type GroupProps = Pick<React_2.ComponentPropsWithRef<'div'>, 'style' | 'children'> & {
240
231
  'data-index': number;
241
232
  'data-item-index': number;
242
233
  'data-known-size': number;
@@ -252,10 +243,10 @@ export declare interface Item<D> {
252
243
  }
253
244
 
254
245
  export declare interface ItemContent<D, C> {
255
- (index: number, data: D, context: C): ReactNode;
246
+ (index: number, data: D, context: C): React_2.ReactNode;
256
247
  }
257
248
 
258
- export declare type ItemProps<D> = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children'> & {
249
+ export declare type ItemProps<D> = Pick<React_2.ComponentPropsWithRef<'div'>, 'style' | 'children'> & {
259
250
  'data-index': number;
260
251
  'data-item-index': number;
261
252
  'data-item-group-index'?: number;
@@ -268,7 +259,7 @@ export declare type ListItem<D> = RecordItem<D> | GroupItem<D>;
268
259
  /**
269
260
  * Passed to the Components.List custom component
270
261
  */
271
- export declare type ListProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children' | 'ref'> & {
262
+ export declare type ListProps = Pick<React_2.ComponentPropsWithRef<'div'>, 'style' | 'children' | 'ref'> & {
272
263
  'data-test-id': string;
273
264
  };
274
265
 
@@ -277,7 +268,7 @@ export declare interface ListRange {
277
268
  endIndex: number;
278
269
  }
279
270
 
280
- export declare type ListRootProps = Omit<HTMLProps<HTMLDivElement>, 'ref' | 'data'>;
271
+ export declare type ListRootProps = Omit<React_2.HTMLProps<HTMLDivElement>, 'ref' | 'data'>;
281
272
 
282
273
  export declare interface LocationOptions {
283
274
  /**
@@ -317,7 +308,7 @@ export declare interface ScrollContainerState {
317
308
  /**
318
309
  * Passed to the Components.Scroller custom component
319
310
  */
320
- export declare type ScrollerProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children' | 'tabIndex' | 'ref'> & {
311
+ export declare type ScrollerProps = Pick<React_2.ComponentPropsWithRef<'div'>, 'style' | 'children' | 'tabIndex' | 'ref'> & {
321
312
  'data-test-id'?: string;
322
313
  'data-virtuoso-scroller'?: boolean;
323
314
  };
@@ -365,7 +356,7 @@ export declare type SizeFunction = (el: HTMLElement, field: 'offsetHeight' | 'of
365
356
  /**
366
357
  * Passed to the Components.TableBody custom component
367
358
  */
368
- export declare type TableBodyProps = Pick<ComponentPropsWithRef<'tbody'>, 'style' | 'children' | 'ref' | 'className'> & {
359
+ export declare type TableBodyProps = Pick<React_2.ComponentPropsWithRef<'tbody'>, 'style' | 'children' | 'ref' | 'className'> & {
369
360
  'data-test-id': string;
370
361
  };
371
362
 
@@ -377,68 +368,68 @@ export declare interface TableComponents<Data = unknown, Context = unknown> {
377
368
  * Set to customize the wrapping `table` element.
378
369
  *
379
370
  */
380
- Table?: ComponentType<TableProps & {
371
+ Table?: React_2.ComponentType<TableProps & {
381
372
  context?: Context;
382
373
  }>;
383
374
  /**
384
375
  * Set to render a fixed header at the top of the table (`thead`). use [[fixedHeaderHeight]] to set the contents
385
376
  *
386
377
  */
387
- TableHead?: ComponentType<Pick<ComponentPropsWithRef<'thead'>, 'style' | 'ref'> & {
378
+ TableHead?: React_2.ComponentType<Pick<React_2.ComponentPropsWithRef<'thead'>, 'style' | 'ref'> & {
388
379
  context?: Context;
389
380
  }>;
390
381
  /**
391
382
  * Set to render a fixed footer at the bottom of the table (`tfoot`). use [[fixedFooterContent]] to set the contents
392
383
  */
393
- TableFoot?: ComponentType<Pick<ComponentPropsWithRef<'tfoot'>, 'style' | 'ref'> & {
384
+ TableFoot?: React_2.ComponentType<Pick<React_2.ComponentPropsWithRef<'tfoot'>, 'style' | 'ref'> & {
394
385
  context?: Context;
395
386
  }>;
396
387
  /**
397
388
  * Set to customize the item wrapping element. Default is `tr`.
398
389
  */
399
- TableRow?: ComponentType<ItemProps<Data> & {
390
+ TableRow?: React_2.ComponentType<ItemProps<Data> & {
400
391
  context?: Context;
401
392
  }>;
402
393
  /**
403
394
  * Set to customize the outermost scrollable element. This should not be necessary in general,
404
395
  * as the component passes its HTML attribute props to it.
405
396
  */
406
- Scroller?: ComponentType<ScrollerProps & {
397
+ Scroller?: React_2.ComponentType<ScrollerProps & {
407
398
  context?: Context;
408
399
  }>;
409
400
  /**
410
401
  * Set to customize the items wrapper. Default is `tbody`.
411
402
  */
412
- TableBody?: ComponentType<TableBodyProps & {
403
+ TableBody?: React_2.ComponentType<TableBodyProps & {
413
404
  context?: Context;
414
405
  }>;
415
406
  /**
416
407
  * Set to render a custom UI when the list is empty.
417
408
  */
418
- EmptyPlaceholder?: ComponentType<{
409
+ EmptyPlaceholder?: React_2.ComponentType<{
419
410
  context?: Context;
420
411
  }>;
421
412
  /**
422
413
  * Set to render an item placeholder when the user scrolls fast. See the `scrollSeek` property for more details.
423
414
  */
424
- ScrollSeekPlaceholder?: ComponentType<ScrollSeekPlaceholderProps & {
415
+ ScrollSeekPlaceholder?: React_2.ComponentType<ScrollSeekPlaceholderProps & {
425
416
  context?: Context;
426
417
  }>;
427
418
  /**
428
419
  * Set to render an empty item placeholder.
429
420
  */
430
- FillerRow?: ComponentType<FillerRowProps & {
421
+ FillerRow?: React_2.ComponentType<FillerRowProps & {
431
422
  context?: Context;
432
423
  }>;
433
424
  }
434
425
 
435
- export declare type TableProps = Pick<ComponentPropsWithRef<'table'>, 'style' | 'children'>;
426
+ export declare type TableProps = Pick<React_2.ComponentPropsWithRef<'table'>, 'style' | 'children'>;
436
427
 
437
- export declare type TableRootProps = Omit<HTMLProps<HTMLTableElement>, 'ref' | 'data'>;
428
+ export declare type TableRootProps = Omit<React_2.HTMLProps<HTMLTableElement>, 'ref' | 'data'>;
438
429
 
439
430
  export declare const TableVirtuoso: <ItemData = any, Context = any>(props: TableVirtuosoProps<ItemData, Context> & {
440
- ref?: Ref<TableVirtuosoHandle> | undefined;
441
- }) => ReactElement;
431
+ ref?: React_2.Ref<TableVirtuosoHandle> | undefined;
432
+ }) => React_2.ReactElement;
442
433
 
443
434
  export declare interface TableVirtuosoHandle {
444
435
  scrollIntoView(location: number | FlatScrollIntoViewLocation): void;
@@ -456,6 +447,10 @@ export declare interface TableVirtuosoProps<D, C> extends Omit<VirtuosoProps<D,
456
447
  * Set the contents of the table header.
457
448
  */
458
449
  fixedHeaderContent?: FixedHeaderContent;
450
+ /**
451
+ * Set the contents of the table footer.
452
+ */
453
+ fixedFooterContent?: FixedFooterContent;
459
454
  /**
460
455
  * The total amount of items to be rendered.
461
456
  */
@@ -620,15 +615,15 @@ export declare interface TableVirtuosoProps<D, C> extends Omit<VirtuosoProps<D,
620
615
  atBottomThreshold?: number;
621
616
  }
622
617
 
623
- export declare type TopItemListProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children'>;
618
+ export declare type TopItemListProps = Pick<React_2.ComponentPropsWithRef<'div'>, 'style' | 'children'>;
624
619
 
625
620
  export declare const Virtuoso: <ItemData = any, Context = any>(props: VirtuosoProps<ItemData, Context> & {
626
- ref?: Ref<VirtuosoHandle> | undefined;
627
- }) => ReactElement;
621
+ ref?: React_2.Ref<VirtuosoHandle> | undefined;
622
+ }) => React_2.ReactElement;
628
623
 
629
- export declare const VirtuosoGrid: <Context = any>(props: VirtuosoGridProps<Context, unknown> & {
630
- ref?: Ref<VirtuosoGridHandle> | undefined;
631
- }) => ReactElement;
624
+ export declare const VirtuosoGrid: <ItemData = any, Context = any>(props: VirtuosoGridProps<ItemData, Context> & {
625
+ ref?: React_2.Ref<VirtuosoGridHandle> | undefined;
626
+ }) => React_2.ReactElement;
632
627
 
633
628
  export declare interface VirtuosoGridHandle {
634
629
  scrollToIndex(location: number | IndexLocationWithAlign): void;
@@ -636,7 +631,7 @@ export declare interface VirtuosoGridHandle {
636
631
  scrollBy(location: ScrollToOptions): void;
637
632
  }
638
633
 
639
- export declare const VirtuosoGridMockContext: Context<VirtuosoGridMockContextValue | undefined>;
634
+ export declare const VirtuosoGridMockContext: React_2.Context<VirtuosoGridMockContextValue | undefined>;
640
635
 
641
636
  export declare interface VirtuosoGridMockContextValue {
642
637
  viewportHeight: number;
@@ -654,6 +649,10 @@ export declare interface VirtuosoGridProps<D, C = unknown> extends GridRootProps
654
649
  * The data items to be rendered. If data is set, the total count will be inferred from the length of the array.
655
650
  */
656
651
  data?: readonly D[];
652
+ /**
653
+ * Additional context available in the custom components and content callbacks
654
+ */
655
+ context?: C;
657
656
  /**
658
657
  * Use for server-side rendering - if set, the list will render the specified amount of items
659
658
  * regardless of the container / item size.
@@ -757,7 +756,7 @@ export declare interface VirtuosoHandle {
757
756
  autoscrollToBottom(): void;
758
757
  }
759
758
 
760
- export declare const VirtuosoMockContext: Context<VirtuosoMockContextValue | undefined>;
759
+ export declare const VirtuosoMockContext: React_2.Context<VirtuosoMockContextValue | undefined>;
761
760
 
762
761
  export declare interface VirtuosoMockContextValue {
763
762
  viewportHeight: number;