@legendapp/list 3.0.0-beta.5 → 3.0.0-beta.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/.DS_Store +0 -0
  2. package/CHANGELOG.md +19 -0
  3. package/README.md +9 -2
  4. package/animated.d.ts +657 -5
  5. package/animated.js +2 -2
  6. package/animated.mjs +1 -1
  7. package/index.d.ts +1316 -11
  8. package/index.js +4023 -1277
  9. package/index.mjs +4022 -1278
  10. package/index.native.js +3784 -1333
  11. package/index.native.mjs +3772 -1323
  12. package/keyboard-chat.d.ts +228 -0
  13. package/keyboard-chat.js +105 -0
  14. package/keyboard-chat.mjs +84 -0
  15. package/keyboard-test.d.ts +216 -0
  16. package/keyboard-test.js +52 -0
  17. package/keyboard-test.mjs +31 -0
  18. package/keyboard.d.ts +216 -8
  19. package/keyboard.js +355 -64
  20. package/keyboard.mjs +358 -66
  21. package/package.json +68 -1
  22. package/{types-YNdphn_A.d.mts → react-native.d.ts} +306 -263
  23. package/react-native.js +6019 -0
  24. package/react-native.mjs +5990 -0
  25. package/{types-YNdphn_A.d.ts → react-native.web.d.ts} +367 -261
  26. package/react-native.web.js +6553 -0
  27. package/react-native.web.mjs +6524 -0
  28. package/react.d.ts +776 -0
  29. package/react.js +6553 -0
  30. package/react.mjs +6524 -0
  31. package/reanimated.d.ts +679 -8
  32. package/reanimated.js +226 -29
  33. package/reanimated.mjs +228 -31
  34. package/section-list.d.ts +661 -5
  35. package/section-list.js +50 -3675
  36. package/section-list.mjs +48 -3674
  37. package/animated.d.mts +0 -9
  38. package/index.d.mts +0 -23
  39. package/index.native.d.mts +0 -23
  40. package/index.native.d.ts +0 -23
  41. package/keyboard-controller.d.mts +0 -12
  42. package/keyboard-controller.d.ts +0 -12
  43. package/keyboard-controller.js +0 -69
  44. package/keyboard-controller.mjs +0 -48
  45. package/keyboard.d.mts +0 -13
  46. package/reanimated.d.mts +0 -18
  47. package/section-list.d.mts +0 -113
  48. package/section-list.native.d.mts +0 -113
  49. package/section-list.native.d.ts +0 -113
  50. package/section-list.native.js +0 -3711
  51. package/section-list.native.mjs +0 -3690
@@ -1,42 +1,118 @@
1
- import * as React$1 from 'react';
2
- import { ComponentProps, Key, ReactNode } from 'react';
3
- import { View, ScrollView, Animated, LayoutRectangle, ScrollViewComponent, ScrollResponderMixin, StyleProp, ViewStyle, NativeSyntheticEvent, NativeScrollEvent, ScrollViewProps } from 'react-native';
4
- import Reanimated from 'react-native-reanimated';
1
+ import * as React from 'react';
2
+ import { Key, ReactElement, HTMLAttributes, CSSProperties, Ref, RefAttributes, Dispatch, SetStateAction } from 'react';
5
3
 
6
- type AnimatedValue = number;
4
+ type ScrollEventTarget = Window | HTMLElement;
7
5
 
8
- type ListenerType = "numContainers" | "numContainersPooled" | `containerItemKey${number}` | `containerItemData${number}` | `containerPosition${number}` | `containerColumn${number}` | `containerSticky${number}` | `containerStickyOffset${number}` | "containersDidLayout" | "extraData" | "numColumns" | "lastItemKeys" | "totalSize" | "alignItemsPaddingTop" | "lastPositionUpdate" | "stylePaddingTop" | "scrollAdjust" | "scrollAdjustUserOffset" | "scrollAdjustPending" | "scrollingTo" | "headerSize" | "footerSize" | "maintainVisibleContentPosition" | "debugRawScroll" | "debugComputedScroll" | "otherAxisSize" | "snapToOffsets" | "scrollSize" | "activeStickyIndex";
9
- interface StateContext {
10
- internalState: InternalState | undefined;
11
- listeners: Map<ListenerType, Set<(value: any) => void>>;
12
- values: Map<ListenerType, any>;
13
- mapViewabilityCallbacks: Map<string, ViewabilityCallback>;
14
- mapViewabilityValues: Map<string, ViewToken>;
15
- mapViewabilityAmountCallbacks: Map<number, ViewabilityAmountCallback>;
16
- mapViewabilityAmountValues: Map<number, ViewAmountToken>;
17
- mapViewabilityConfigStates: Map<string, {
18
- viewableItems: ViewToken[];
19
- start: number;
20
- end: number;
21
- previousStart: number;
22
- previousEnd: number;
23
- }>;
24
- columnWrapperStyle: ColumnWrapperStyle | undefined;
25
- viewRefs: Map<number, React$1.RefObject<View>>;
26
- animatedScrollY: AnimatedValue;
6
+ interface ScrollViewMethods {
7
+ getBoundingClientRect(): DOMRect | null | undefined;
8
+ getContentNode(): HTMLElement | null;
9
+ getCurrentScrollOffset(): number;
10
+ getScrollableNode(): HTMLElement;
11
+ getScrollEventTarget(): ScrollEventTarget | null;
12
+ getScrollResponder(): HTMLElement | null;
13
+ isWindowScroll?(): boolean;
14
+ scrollBy(x: number, y: number): void;
15
+ scrollTo(options: {
16
+ x?: number;
17
+ y?: number;
18
+ animated?: boolean;
19
+ }): void;
20
+ scrollToEnd(options?: {
21
+ animated?: boolean;
22
+ }): void;
23
+ scrollToOffset(params: {
24
+ offset: number;
25
+ animated?: boolean;
26
+ }): void;
27
27
  }
28
28
 
29
- declare class ScrollAdjustHandler {
30
- private appliedAdjust;
31
- private pendingAdjust;
32
- private context;
33
- private mounted;
34
- constructor(ctx: StateContext);
35
- requestAdjust(add: number): void;
36
- setMounted(): void;
37
- getAdjust(): number;
29
+ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
30
+ data: boolean;
31
+ size: boolean;
32
+ shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
38
33
  }
39
34
 
35
+ type ListenerType = "activeStickyIndex" | "anchoredEndSpaceSize" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
36
+ type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
37
+ type ListenerTypeValueMap = {
38
+ activeStickyIndex: number;
39
+ anchoredEndSpaceSize: number;
40
+ animatedScrollY: any;
41
+ debugComputedScroll: number;
42
+ debugRawScroll: number;
43
+ extraData: any;
44
+ footerSize: number;
45
+ headerSize: number;
46
+ isAtEnd: boolean;
47
+ isAtStart: boolean;
48
+ isNearEnd: boolean;
49
+ isNearStart: boolean;
50
+ isWithinMaintainScrollAtEndThreshold: boolean;
51
+ lastItemKeys: string[];
52
+ lastPositionUpdate: number;
53
+ maintainVisibleContentPosition: MaintainVisibleContentPositionNormalized;
54
+ numColumns: number;
55
+ numContainers: number;
56
+ numContainersPooled: number;
57
+ otherAxisSize: number;
58
+ readyToRender: boolean;
59
+ scrollAdjust: number;
60
+ scrollAdjustPending: number;
61
+ scrollAdjustUserOffset: number;
62
+ scrollSize: {
63
+ width: number;
64
+ height: number;
65
+ };
66
+ snapToOffsets: number[];
67
+ stylePaddingTop: number;
68
+ totalSize: number;
69
+ } & {
70
+ [K in ListenerType as K extends `containerItemKey${number}` ? K : never]: string;
71
+ } & {
72
+ [K in ListenerType as K extends `containerItemData${number}` ? K : never]: any;
73
+ } & {
74
+ [K in ListenerType as K extends `containerPosition${number}` ? K : never]: number;
75
+ } & {
76
+ [K in ListenerType as K extends `containerColumn${number}` ? K : never]: number;
77
+ } & {
78
+ [K in ListenerType as K extends `containerSpan${number}` ? K : never]: number;
79
+ } & {
80
+ [K in ListenerType as K extends `containerSticky${number}` ? K : never]: boolean;
81
+ };
82
+
83
+ interface Insets {
84
+ top: number;
85
+ left: number;
86
+ bottom: number;
87
+ right: number;
88
+ }
89
+ interface LayoutRectangle {
90
+ x: number;
91
+ y: number;
92
+ width: number;
93
+ height: number;
94
+ }
95
+ interface NativeScrollEvent {
96
+ contentOffset: {
97
+ x: number;
98
+ y: number;
99
+ };
100
+ contentSize: {
101
+ width: number;
102
+ height: number;
103
+ };
104
+ layoutMeasurement: {
105
+ width: number;
106
+ height: number;
107
+ };
108
+ contentInset: Insets;
109
+ zoomScale: number;
110
+ }
111
+ interface NativeSyntheticEvent<T> {
112
+ nativeEvent: T;
113
+ }
114
+ type ViewStyle = Record<string, unknown>;
115
+ type StyleProp<T> = T | T[] | null | undefined | false;
40
116
  type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
41
117
  interface DataModeProps<ItemT, TItemType extends string | undefined> {
42
118
  /**
@@ -51,7 +127,7 @@ interface DataModeProps<ItemT, TItemType extends string | undefined> {
51
127
  * - A React component: React.ComponentType<LegendListRenderItemProps<ItemT>>
52
128
  * @required when using data mode
53
129
  */
54
- renderItem: ((props: LegendListRenderItemProps<ItemT, TItemType>) => ReactNode) | React.ComponentType<LegendListRenderItemProps<ItemT, TItemType>>;
130
+ renderItem: ((props: LegendListRenderItemProps<ItemT, TItemType>) => React.ReactNode) | React.ComponentType<LegendListRenderItemProps<ItemT, TItemType>>;
55
131
  children?: never;
56
132
  }
57
133
  interface ChildrenModeProps {
@@ -60,7 +136,7 @@ interface ChildrenModeProps {
60
136
  * Each child will be treated as an individual list item.
61
137
  * @required when using children mode
62
138
  */
63
- children: ReactNode;
139
+ children: React.ReactNode;
64
140
  data?: never;
65
141
  renderItem?: never;
66
142
  }
@@ -71,14 +147,19 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
71
147
  */
72
148
  alignItemsAtEnd?: boolean;
73
149
  /**
74
- * If true, enables using average sizes for performance optimization.
75
- * @default true
150
+ * Keeps selected items mounted even when they scroll out of view.
151
+ * @default undefined
76
152
  */
77
- enableAverages?: boolean;
153
+ alwaysRender?: AlwaysRenderConfig;
78
154
  /**
79
155
  * Style applied to each column's wrapper view.
80
156
  */
81
157
  columnWrapperStyle?: ColumnWrapperStyle;
158
+ /**
159
+ * Version token that forces the list to treat data as updated even when the array reference is stable.
160
+ * Increment or change this when mutating the data array in place.
161
+ */
162
+ dataVersion?: Key;
82
163
  /**
83
164
  * Distance in pixels to pre-render items ahead of the visible area.
84
165
  * @default 250
@@ -103,25 +184,34 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
103
184
  */
104
185
  extraData?: any;
105
186
  /**
106
- * Version token that forces the list to treat data as updated even when the array reference is stable.
107
- * Increment or change this when mutating the data array in place.
187
+ * In case you have distinct item sizes, you can provide a function to get the size of an item.
108
188
  */
109
- dataVersion?: Key;
189
+ getEstimatedItemSize?: (item: ItemT, index: number, type: TItemType) => number;
110
190
  /**
111
- * In case you have distinct item sizes, you can provide a function to get the size of an item.
112
- * Use instead of FlatList's getItemLayout or FlashList overrideItemLayout if you want to have accurate initialScrollOffset, you should provide this function
191
+ * In case items always have a fixed size, you can provide a function to return it.
113
192
  */
114
- getEstimatedItemSize?: (index: number, item: ItemT, type: TItemType) => number;
193
+ getFixedItemSize?: (item: ItemT, index: number, type: TItemType) => number | undefined;
194
+ /**
195
+ * Returns a stable item type used for pooling and size estimation.
196
+ */
197
+ getItemType?: (item: ItemT, index: number) => TItemType;
198
+ /**
199
+ * Component to render between items, receiving the leading item as prop.
200
+ */
201
+ ItemSeparatorComponent?: React.ComponentType<{
202
+ leadingItem: ItemT;
203
+ }>;
115
204
  /**
116
205
  * Ratio of initial container pool size to data length (e.g., 0.5 for half).
117
206
  * @default 2
118
207
  */
119
208
  initialContainerPoolRatio?: number | undefined;
120
209
  /**
121
- * Initial scroll position in pixels.
122
- * @default 0
210
+ * When true, the list initializes scrolled to the last item.
211
+ * Overrides `initialScrollIndex` and `initialScrollOffset` when data is available.
212
+ * @default false
123
213
  */
124
- initialScrollOffset?: number;
214
+ initialScrollAtEnd?: boolean;
125
215
  /**
126
216
  * Index to scroll to initially.
127
217
  * @default 0
@@ -129,19 +219,17 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
129
219
  initialScrollIndex?: number | {
130
220
  index: number;
131
221
  viewOffset?: number | undefined;
222
+ viewPosition?: number | undefined;
132
223
  };
133
224
  /**
134
- * When true, the list initializes scrolled to the last item.
135
- * Overrides `initialScrollIndex` and `initialScrollOffset` when data is available.
136
- * @default false
225
+ * Initial scroll position in pixels.
226
+ * @default 0
137
227
  */
138
- initialScrollAtEnd?: boolean;
228
+ initialScrollOffset?: number;
139
229
  /**
140
- * Component to render between items, receiving the leading item as prop.
230
+ * Custom equality function to detect semantically unchanged items.
141
231
  */
142
- ItemSeparatorComponent?: React.ComponentType<{
143
- leadingItem: ItemT;
144
- }>;
232
+ itemsAreEqual?: (itemPrevious: ItemT, item: ItemT, index: number, data: readonly ItemT[]) => boolean;
145
233
  /**
146
234
  * Function to extract a unique key for each item.
147
235
  */
@@ -168,6 +256,7 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
168
256
  ListHeaderComponentStyle?: StyleProp<ViewStyle> | undefined;
169
257
  /**
170
258
  * If true, auto-scrolls to end when new items are added.
259
+ * Use an options object to opt into specific triggers and control whether that scroll is animated.
171
260
  * @default false
172
261
  */
173
262
  maintainScrollAtEnd?: boolean | MaintainScrollAtEndOptions;
@@ -177,11 +266,18 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
177
266
  */
178
267
  maintainScrollAtEndThreshold?: number;
179
268
  /**
180
- * If true, maintains visibility of content across data changes (filtering/resorting/insertions).
181
- * Scroll-time stability for measurements is always enabled.
182
- * @default false
269
+ * Maintains visibility of content.
270
+ * - scroll (default: true) stabilizes during size/layout changes while scrolling.
271
+ * - data (default: false) stabilizes when the data array changes; passing true also sets the RN maintainVisibleContentPosition prop.
272
+ * - shouldRestorePosition can opt out specific items from data-change anchoring.
273
+ * - undefined (default) enables scroll stabilization but skips data-change anchoring.
274
+ * - true enables both behaviors; false disables both.
183
275
  */
184
- maintainVisibleContentPosition?: boolean;
276
+ maintainVisibleContentPosition?: boolean | MaintainVisibleContentPositionConfig<ItemT>;
277
+ /**
278
+ * Keeps an item visually anchored to the start by adding trailing space when the content below it underflows.
279
+ */
280
+ anchoredEndSpace?: AnchoredEndSpaceConfig$1;
185
281
  /**
186
282
  * Number of columns to render items in.
187
283
  * @default 1
@@ -208,10 +304,23 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
208
304
  itemKey: string;
209
305
  itemData: ItemT;
210
306
  }) => void;
307
+ /**
308
+ * Called after the initial render work completes.
309
+ */
310
+ onLoad?: (info: {
311
+ elapsedTimeInMs: number;
312
+ }) => void;
313
+ /**
314
+ * Called when list layout metrics change.
315
+ */
316
+ onMetricsChange?: (metrics: LegendListMetrics) => void;
211
317
  /**
212
318
  * Function to call when the user pulls to refresh.
213
319
  */
214
320
  onRefresh?: () => void;
321
+ /**
322
+ * Called when the list scrolls.
323
+ */
215
324
  onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
216
325
  /**
217
326
  * Called when scrolling reaches the start within onStartReachedThreshold.
@@ -235,6 +344,12 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
235
344
  * Called when the viewability of items changes.
236
345
  */
237
346
  onViewableItemsChanged?: OnViewableItemsChanged<ItemT> | undefined;
347
+ /**
348
+ * Customize layout for multi-column lists, such as allowing items to span multiple columns.
349
+ */
350
+ overrideItemLayout?: (layout: {
351
+ span?: number;
352
+ }, item: ItemT, index: number, maxColumns: number, extraData?: any) => void;
238
353
  /**
239
354
  * Offset in pixels for the refresh indicator.
240
355
  * @default 0
@@ -248,7 +363,7 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
248
363
  /**
249
364
  * Ref to the underlying ScrollView component.
250
365
  */
251
- refScrollView?: React.Ref<ScrollView>;
366
+ refScrollView?: React.Ref<any>;
252
367
  /**
253
368
  * If true, shows a refresh indicator.
254
369
  * @default false
@@ -259,7 +374,11 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
259
374
  * Note: When using `stickyHeaderIndices`, you must provide an Animated ScrollView component.
260
375
  * @default (props) => <ScrollView {...props} />
261
376
  */
262
- renderScrollComponent?: (props: ScrollViewProps) => React.ReactElement<ScrollViewProps>;
377
+ renderScrollComponent?: (props: any) => React.ReactElement | null;
378
+ /**
379
+ * Array of item indices to use as snap points.
380
+ */
381
+ snapToIndices?: number[];
263
382
  /**
264
383
  * This will log a suggested estimatedItemSize.
265
384
  * @required
@@ -274,15 +393,6 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
274
393
  * Pairs of viewability configs and their callbacks for tracking visibility.
275
394
  */
276
395
  viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs<ItemT> | undefined;
277
- /**
278
- * If true, delays rendering until initial layout is complete.
279
- * @default false
280
- */
281
- waitForInitialLayout?: boolean;
282
- onLoad?: (info: {
283
- elapsedTimeInMs: number;
284
- }) => void;
285
- snapToIndices?: number[];
286
396
  /**
287
397
  * Array of child indices determining which children get docked to the top of the screen when scrolling.
288
398
  * For example, passing stickyHeaderIndices={[0]} will cause the first child to be fixed to the top of the scroll view.
@@ -294,190 +404,109 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
294
404
  * @deprecated Use stickyHeaderIndices instead for parity with React Native.
295
405
  */
296
406
  stickyIndices?: number[];
297
- getItemType?: (item: ItemT, index: number) => TItemType;
298
- getFixedItemSize?: (index: number, item: ItemT, type: TItemType) => number | undefined;
299
- itemsAreEqual?: (itemPrevious: ItemT, item: ItemT, index: number, data: readonly ItemT[]) => boolean;
407
+ /**
408
+ * Configuration for sticky headers.
409
+ * @default undefined
410
+ */
411
+ stickyHeaderConfig?: StickyHeaderConfig;
412
+ /**
413
+ * Web only: when true, listens to window/body scrolling instead of rendering a scrollable list container.
414
+ * @default false
415
+ */
416
+ useWindowScroll?: boolean;
417
+ }
418
+ type LegendListPropsBase<ItemT, TScrollViewProps = Record<string, any>, TItemType extends string | undefined = string | undefined> = BaseScrollViewProps<TScrollViewProps> & LegendListSpecificProps<ItemT, TItemType> & (DataModeProps<ItemT, TItemType> | ChildrenModeProps);
419
+ interface MaintainVisibleContentPositionConfig<ItemT = any> {
420
+ data?: boolean;
421
+ size?: boolean;
422
+ shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
423
+ }
424
+ interface AnchoredEndSpaceConfig$1 {
425
+ anchorIndex: number;
426
+ anchorOffset?: number;
427
+ anchorMaxSize?: number;
428
+ includeInEndInset?: boolean;
429
+ onSizeChanged?: (size: number) => void;
430
+ }
431
+ interface StickyHeaderConfig {
432
+ /**
433
+ * Specifies how far from the top edge sticky headers should start sticking.
434
+ * Useful for scenarios with a fixed navbar or header, where sticky elements pin below it..
435
+ * @default 0
436
+ */
437
+ offset?: number;
438
+ /**
439
+ * Component to render as a backdrop behind the sticky header.
440
+ * @default undefined
441
+ */
442
+ backdropComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
443
+ }
444
+ interface AlwaysRenderConfig {
445
+ top?: number;
446
+ bottom?: number;
447
+ indices?: number[];
448
+ keys?: string[];
449
+ }
450
+ interface MaintainScrollAtEndOnOptions {
451
+ dataChange?: boolean;
452
+ itemLayout?: boolean;
453
+ layout?: boolean;
300
454
  }
301
- type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof Animated.ScrollView> | ComponentProps<typeof Reanimated.ScrollView>, TItemType extends string | undefined = string | undefined> = BaseScrollViewProps<TScrollView> & LegendListSpecificProps<ItemT, TItemType> & (DataModeProps<ItemT, TItemType> | ChildrenModeProps);
302
455
  interface MaintainScrollAtEndOptions {
303
- onLayout?: boolean;
304
- onItemLayout?: boolean;
305
- onDataChange?: boolean;
456
+ /**
457
+ * Whether maintainScrollAtEnd should animate when it scrolls to the end.
458
+ */
459
+ animated?: boolean;
460
+ /**
461
+ * Which events should keep the list pinned to the end.
462
+ * - If omitted, object values default to all triggers.
463
+ * - If provided, only the keys set to `true` are enabled.
464
+ */
465
+ on?: MaintainScrollAtEndOnOptions;
306
466
  }
307
467
  interface ColumnWrapperStyle {
308
468
  rowGap?: number;
309
469
  gap?: number;
310
470
  columnGap?: number;
311
471
  }
312
- type LegendListProps<ItemT = any> = LegendListPropsBase<ItemT, ComponentProps<typeof ScrollView>>;
313
- interface ThresholdSnapshot {
314
- scrollPosition: number;
315
- contentSize?: number;
316
- dataLength?: number;
317
- atThreshold: boolean;
318
- }
319
- interface ScrollTarget {
320
- offset: number;
321
- index?: number;
322
- viewOffset?: number;
323
- viewPosition?: number;
324
- animated?: boolean;
325
- isInitialScroll?: boolean;
326
- precomputedWithViewOffset?: boolean;
327
- }
328
- interface InternalState {
329
- positions: Map<string, number>;
330
- columns: Map<string, number>;
331
- sizes: Map<string, number>;
332
- sizesKnown: Map<string, number>;
333
- containerItemKeys: Set<string>;
334
- containerItemTypes: Map<number, string>;
335
- isStartReached: boolean;
336
- isEndReached: boolean;
337
- isAtEnd: boolean;
338
- isAtStart: boolean;
339
- hasScrolled?: boolean;
340
- scrollLength: number;
341
- startBuffered: number;
342
- startBufferedId?: string;
343
- startNoBuffer: number;
344
- endBuffered: number;
345
- endNoBuffer: number;
346
- firstFullyOnScreenIndex: number;
347
- idsInView: string[];
348
- scrollPending: number;
349
- scroll: number;
350
- scrollTime: number;
351
- scrollPrev: number;
352
- scrollPrevTime: number;
353
- scrollAdjustHandler: ScrollAdjustHandler;
354
- triggerCalculateItemsInView?: (params?: {
355
- doMVCP?: boolean;
356
- dataChanged?: boolean;
357
- forceFullItemPositions?: boolean;
358
- }) => void;
359
- maintainingScrollAtEnd?: boolean;
360
- totalSize: number;
361
- otherAxisSize?: number;
362
- timeouts: Set<number>;
363
- timeoutSizeMessage: any;
364
- nativeMarginTop: number;
365
- indexByKey: Map<string, number>;
366
- idCache: string[];
367
- viewabilityConfigCallbackPairs: ViewabilityConfigCallbackPairs<any> | undefined;
368
- scrollHistory: Array<{
369
- scroll: number;
370
- time: number;
371
- }>;
372
- lastScrollAdjustForHistory?: number;
373
- startReachedSnapshot: ThresholdSnapshot | undefined;
374
- endReachedSnapshot: ThresholdSnapshot | undefined;
375
- scrollForNextCalculateItemsInView: {
376
- top: number;
377
- bottom: number;
378
- } | undefined;
379
- enableScrollForNextCalculateItemsInView: boolean;
380
- minIndexSizeChanged: number | undefined;
381
- queuedInitialLayout?: boolean | undefined;
382
- queuedCalculateItemsInView: number | undefined;
383
- dataChangeNeedsScrollUpdate: boolean;
384
- previousData?: readonly unknown[];
385
- didColumnsChange?: boolean;
386
- didDataChange?: boolean;
387
- isFirst?: boolean;
388
- lastBatchingAction: number;
389
- ignoreScrollFromMVCP?: {
390
- lt?: number;
391
- gt?: number;
392
- };
393
- ignoreScrollFromMVCPIgnored?: boolean;
394
- ignoreScrollFromMVCPTimeout?: any;
395
- needsOtherAxisSize?: boolean;
396
- averageSizes: Record<string, {
397
- num: number;
398
- avg: number;
399
- }>;
400
- refScroller: React.RefObject<ScrollView>;
401
- loadStartTime: number;
402
- initialScroll: ScrollIndexWithOffsetAndContentOffset | undefined;
403
- initialAnchor?: InitialScrollAnchor;
404
- lastLayout: LayoutRectangle | undefined;
405
- timeoutSetPaddingTop?: any;
406
- activeStickyIndex: number | undefined;
407
- stickyContainers: Map<number, number>;
408
- stickyContainerPool: Set<number>;
409
- scrollProcessingEnabled: boolean;
410
- pendingTotalSize?: number;
411
- adjustingFromInitialMount?: number;
412
- props: {
413
- alignItemsAtEnd: boolean;
414
- data: readonly any[];
415
- dataVersion: Key | undefined;
416
- estimatedItemSize: number | undefined;
417
- getEstimatedItemSize: LegendListProps["getEstimatedItemSize"];
418
- getFixedItemSize: LegendListProps["getFixedItemSize"];
419
- getItemType: LegendListProps["getItemType"];
420
- horizontal: boolean;
421
- keyExtractor: LegendListProps["keyExtractor"];
422
- maintainScrollAtEnd: boolean | MaintainScrollAtEndOptions;
423
- maintainScrollAtEndThreshold: number | undefined;
424
- maintainVisibleContentPosition: boolean;
425
- onEndReached: LegendListProps["onEndReached"];
426
- onEndReachedThreshold: number | null | undefined;
427
- onItemSizeChanged: LegendListProps["onItemSizeChanged"];
428
- onLoad: LegendListProps["onLoad"];
429
- onScroll: LegendListProps["onScroll"];
430
- onStartReached: LegendListProps["onStartReached"];
431
- onStartReachedThreshold: number | null | undefined;
432
- onStickyHeaderChange: LegendListProps["onStickyHeaderChange"];
433
- recycleItems: boolean;
434
- suggestEstimatedItemSize: boolean;
435
- stylePaddingBottom: number | undefined;
436
- renderItem: LegendListProps["renderItem"];
437
- scrollBuffer: number;
438
- numColumns: number;
439
- initialContainerPoolRatio: number;
440
- stylePaddingTop: number | undefined;
441
- snapToIndices: number[] | undefined;
442
- stickyIndicesSet: Set<number>;
443
- stickyIndicesArr: number[];
444
- itemsAreEqual: LegendListProps["itemsAreEqual"];
445
- enableAverages: boolean;
446
- };
447
- }
448
- interface ViewableRange<T> {
449
- startBuffered: number;
450
- start: number;
451
- endBuffered: number;
452
- end: number;
453
- items: T[];
472
+ interface LegendListMetrics {
473
+ headerSize: number;
474
+ footerSize: number;
454
475
  }
455
476
  interface LegendListRenderItemProps<ItemT, TItemType extends string | number | undefined = string | number | undefined> {
456
- item: ItemT;
457
- type: TItemType;
458
- index: number;
459
477
  data: readonly ItemT[];
460
478
  extraData: any;
479
+ index: number;
480
+ item: ItemT;
481
+ type: TItemType;
461
482
  }
462
- type ScrollState = {
463
- activeStickyIndex: number | undefined;
483
+ type LegendListState$1 = {
484
+ activeStickyIndex: number;
464
485
  contentLength: number;
465
486
  data: readonly any[];
466
- elementAtIndex: (index: number) => View | null | undefined;
487
+ elementAtIndex: (index: number) => any;
467
488
  end: number;
468
489
  endBuffered: number;
469
490
  isAtEnd: boolean;
470
491
  isAtStart: boolean;
492
+ isNearEnd: boolean;
493
+ isNearStart: boolean;
494
+ isEndReached: boolean;
495
+ isStartReached: boolean;
496
+ isWithinMaintainScrollAtEndThreshold: boolean;
497
+ listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
498
+ listenToPosition: (key: string, callback: (value: number) => void) => () => void;
471
499
  positionAtIndex: (index: number) => number;
472
- positions: Map<string, number>;
500
+ positionByKey: (key: string) => number | undefined;
473
501
  scroll: number;
474
502
  scrollLength: number;
503
+ scrollVelocity: number;
475
504
  sizeAtIndex: (index: number) => number;
476
505
  sizes: Map<string, number>;
477
506
  start: number;
478
507
  startBuffered: number;
479
508
  };
480
- type LegendListRef = {
509
+ type LegendListRef$1 = {
481
510
  /**
482
511
  * Displays the scroll indicators momentarily.
483
512
  */
@@ -485,7 +514,7 @@ type LegendListRef = {
485
514
  /**
486
515
  * Returns the native ScrollView component reference.
487
516
  */
488
- getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
517
+ getNativeScrollRef(): any;
489
518
  /**
490
519
  * Returns the scroll responder instance for handling scroll events.
491
520
  */
@@ -493,11 +522,11 @@ type LegendListRef = {
493
522
  /**
494
523
  * Returns the ScrollResponderMixin for advanced scroll handling.
495
524
  */
496
- getScrollResponder(): ScrollResponderMixin;
525
+ getScrollResponder(): any;
497
526
  /**
498
527
  * Returns the internal state of the scroll virtualization.
499
528
  */
500
- getState(): ScrollState;
529
+ getState(): LegendListState$1;
501
530
  /**
502
531
  * Scrolls a specific index into view.
503
532
  * @param params - Parameters for scrolling.
@@ -507,7 +536,7 @@ type LegendListRef = {
507
536
  scrollIndexIntoView(params: {
508
537
  animated?: boolean | undefined;
509
538
  index: number;
510
- }): void;
539
+ }): Promise<void>;
511
540
  /**
512
541
  * Scrolls a specific index into view.
513
542
  * @param params - Parameters for scrolling.
@@ -517,7 +546,7 @@ type LegendListRef = {
517
546
  scrollItemIntoView(params: {
518
547
  animated?: boolean | undefined;
519
548
  item: any;
520
- }): void;
549
+ }): Promise<void>;
521
550
  /**
522
551
  * Scrolls to the end of the list.
523
552
  * @param options - Options for scrolling.
@@ -527,7 +556,7 @@ type LegendListRef = {
527
556
  scrollToEnd(options?: {
528
557
  animated?: boolean | undefined;
529
558
  viewOffset?: number | undefined;
530
- }): void;
559
+ }): Promise<void>;
531
560
  /**
532
561
  * Scrolls to a specific index in the list.
533
562
  * @param params - Parameters for scrolling.
@@ -541,7 +570,7 @@ type LegendListRef = {
541
570
  index: number;
542
571
  viewOffset?: number | undefined;
543
572
  viewPosition?: number | undefined;
544
- }): void;
573
+ }): Promise<void>;
545
574
  /**
546
575
  * Scrolls to a specific item in the list.
547
576
  * @param params - Parameters for scrolling.
@@ -555,7 +584,7 @@ type LegendListRef = {
555
584
  item: any;
556
585
  viewOffset?: number | undefined;
557
586
  viewPosition?: number | undefined;
558
- }): void;
587
+ }): Promise<void>;
559
588
  /**
560
589
  * Scrolls to a specific offset in pixels.
561
590
  * @param params - Parameters for scrolling.
@@ -565,42 +594,60 @@ type LegendListRef = {
565
594
  scrollToOffset(params: {
566
595
  offset: number;
567
596
  animated?: boolean | undefined;
568
- }): void;
597
+ }): Promise<void>;
569
598
  /**
570
599
  * Sets or adds to the offset of the visible content anchor.
571
600
  * @param value - The offset to set or add.
572
601
  * @param animated - If true, uses Animated to animate the change.
573
602
  */
574
- setVisibleContentAnchorOffset(value: number | ((value: number) => number)): void;
603
+ setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
575
604
  /**
576
605
  * Sets whether scroll processing is enabled.
577
606
  * @param enabled - If true, scroll processing is enabled.
578
607
  */
579
608
  setScrollProcessingEnabled(enabled: boolean): void;
609
+ /**
610
+ * Clears internal virtualization caches.
611
+ * @param options - Cache clearing options.
612
+ * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
613
+ */
614
+ clearCaches(options?: {
615
+ mode?: "sizes" | "full";
616
+ }): void;
617
+ /**
618
+ * Reports an externally measured content inset. Pass null/undefined to clear.
619
+ * Values are merged on top of props/animated/native insets.
620
+ */
621
+ reportContentInset(inset?: Partial<Insets> | null): void;
580
622
  };
581
623
  interface ViewToken<ItemT = any> {
582
- item: ItemT;
583
- key: string;
624
+ containerId: number;
584
625
  index: number;
585
626
  isViewable: boolean;
586
- containerId: number;
627
+ item: ItemT;
628
+ key: string;
587
629
  }
588
630
  interface ViewAmountToken<ItemT = any> extends ViewToken<ItemT> {
589
- sizeVisible: number;
590
- size: number;
591
- percentVisible: number;
592
631
  percentOfScroller: number;
632
+ percentVisible: number;
593
633
  scrollSize: number;
634
+ size: number;
635
+ sizeVisible: number;
594
636
  }
595
637
  interface ViewabilityConfigCallbackPair<ItemT = any> {
596
- viewabilityConfig: ViewabilityConfig;
597
638
  onViewableItemsChanged?: OnViewableItemsChanged<ItemT>;
639
+ viewabilityConfig: ViewabilityConfig;
598
640
  }
599
641
  type ViewabilityConfigCallbackPairs<ItemT> = ViewabilityConfigCallbackPair<ItemT>[];
600
- type OnViewableItemsChanged<ItemT> = ((info: {
601
- viewableItems: Array<ViewToken<ItemT>>;
642
+ interface OnViewableItemsChangedInfo<ItemT> {
602
643
  changed: Array<ViewToken<ItemT>>;
603
- }) => void) | null;
644
+ end: number;
645
+ endBuffered: number;
646
+ start: number;
647
+ startBuffered: number;
648
+ viewableItems: Array<ViewToken<ItemT>>;
649
+ }
650
+ type OnViewableItemsChanged<ItemT> = ((info: OnViewableItemsChangedInfo<ItemT>) => void) | null;
604
651
  interface ViewabilityConfig {
605
652
  /**
606
653
  * A unique ID to identify this viewability config
@@ -633,17 +680,11 @@ interface ViewabilityConfig {
633
680
  type ViewabilityCallback<ItemT = any> = (viewToken: ViewToken<ItemT>) => void;
634
681
  type ViewabilityAmountCallback<ItemT = any> = (viewToken: ViewAmountToken<ItemT>) => void;
635
682
  interface LegendListRecyclingState<T> {
636
- item: T;
637
- prevItem: T | undefined;
638
683
  index: number;
684
+ item: T;
639
685
  prevIndex: number | undefined;
686
+ prevItem: T | undefined;
640
687
  }
641
- type TypedForwardRef = <T, P = {}>(render: (props: P, ref: React.Ref<T>) => React.ReactNode) => (props: P & React.RefAttributes<T>) => React.ReactNode;
642
- declare const typedForwardRef: TypedForwardRef;
643
- type TypedMemo = <T extends React.ComponentType<any>>(Component: T, propsAreEqual?: (prevProps: Readonly<React.JSXElementConstructor<T>>, nextProps: Readonly<React.JSXElementConstructor<T>>) => boolean) => T & {
644
- displayName?: string;
645
- };
646
- declare const typedMemo: TypedMemo;
647
688
  interface ScrollIndexWithOffset {
648
689
  index: number;
649
690
  viewOffset?: number;
@@ -655,16 +696,81 @@ interface ScrollIndexWithOffsetPosition extends ScrollIndexWithOffset {
655
696
  interface ScrollIndexWithOffsetAndContentOffset extends ScrollIndexWithOffsetPosition {
656
697
  contentOffset?: number;
657
698
  }
699
+ /** @deprecated Kept for backwards compatibility. Use `ScrollIndexWithOffsetPosition`. */
658
700
  interface InitialScrollAnchor extends ScrollIndexWithOffsetPosition {
659
701
  attempts?: number;
660
702
  lastDelta?: number;
661
703
  settledTicks?: number;
662
704
  }
663
- type GetRenderedItemResult<ItemT> = {
664
- index: number;
665
- item: ItemT;
666
- renderedItem: React.ReactNode;
705
+
706
+ type LooseLayoutChangeEvent = {
707
+ nativeEvent: {
708
+ layout: LayoutRectangle;
709
+ };
667
710
  };
668
- type GetRenderedItem = (key: string) => GetRenderedItemResult<any> | null;
711
+ interface LooseScrollViewProps {
712
+ contentContainerClassName?: string;
713
+ contentContainerStyle?: StyleProp<ViewStyle>;
714
+ contentInset?: Insets;
715
+ contentOffset?: {
716
+ x: number;
717
+ y: number;
718
+ };
719
+ horizontal?: boolean;
720
+ maintainVisibleContentPosition?: {
721
+ autoscrollToTopThreshold?: number;
722
+ minIndexForVisible: number;
723
+ };
724
+ onLayout?: (event: LooseLayoutChangeEvent) => void;
725
+ onMomentumScrollBegin?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
726
+ onMomentumScrollEnd?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
727
+ onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
728
+ refreshControl?: ReactElement | null;
729
+ removeClippedSubviews?: boolean;
730
+ scrollEventThrottle?: number;
731
+ showsHorizontalScrollIndicator?: boolean;
732
+ showsVerticalScrollIndicator?: boolean;
733
+ stickyHeaderIndices?: number[];
734
+ style?: StyleProp<ViewStyle>;
735
+ }
736
+
737
+ interface AnchoredEndSpaceConfig extends Omit<AnchoredEndSpaceConfig$1, "includeInEndInset"> {
738
+ }
739
+ type ScrollViewPropsWeb = Omit<LooseScrollViewProps, "style" | "contentContainerStyle" | "onScroll" | "onLayout" | "onMomentumScrollBegin" | "onMomentumScrollEnd" | "pagingEnabled" | "snapToInterval"> & Omit<HTMLAttributes<HTMLDivElement>, "onScroll" | "onLayout" | "style"> & {
740
+ style?: CSSProperties;
741
+ contentContainerClassName?: string;
742
+ contentContainerStyle?: CSSProperties;
743
+ onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
744
+ onLayout?: (event: LooseLayoutChangeEvent) => void;
745
+ };
746
+ type LegendListPropsOverrides<ItemT, TItemType extends string | undefined> = Omit<LegendListPropsBase<ItemT, ScrollViewPropsWeb, TItemType>, "anchoredEndSpace" | "refScrollView" | "renderScrollComponent" | "ListHeaderComponentStyle" | "ListFooterComponentStyle" | "onRefresh" | "progressViewOffset" | "refreshing"> & {
747
+ anchoredEndSpace?: AnchoredEndSpaceConfig;
748
+ refScrollView?: Ref<HTMLElement | ScrollViewMethods>;
749
+ ListHeaderComponentStyle?: CSSProperties | undefined;
750
+ ListFooterComponentStyle?: CSSProperties | undefined;
751
+ };
752
+ type LegendListProps<ItemT = any, TItemType extends string | undefined = string | undefined> = LegendListPropsOverrides<ItemT, TItemType>;
753
+ type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollableNode" | "getScrollResponder"> & {
754
+ getNativeScrollRef(): HTMLElement | ScrollViewMethods;
755
+ getScrollableNode(): HTMLElement;
756
+ getScrollResponder(): HTMLElement | null;
757
+ };
758
+ type LegendListState = Omit<LegendListState$1, "elementAtIndex"> & {
759
+ elementAtIndex: (index: number) => HTMLElement | null | undefined;
760
+ };
761
+ type LegendListComponent = <ItemT = any>(props: LegendListProps<ItemT> & RefAttributes<LegendListRef>) => ReactElement | null;
762
+
763
+ declare function useViewability<ItemT = any>(callback: ViewabilityCallback<ItemT>, configId?: string): void;
764
+ declare function useViewabilityAmount<ItemT = any>(callback: ViewabilityAmountCallback<ItemT>): void;
765
+ declare function useRecyclingEffect(effect: (info: LegendListRecyclingState<unknown>) => void | (() => void)): void;
766
+ declare function useRecyclingState<ItemT>(valueOrFun: ((info: LegendListRecyclingState<ItemT>) => ItemT) | ItemT): readonly [ItemT, Dispatch<SetStateAction<ItemT>>];
767
+ declare function useIsLastItem(): boolean;
768
+ declare function useListScrollSize(): {
769
+ width: number;
770
+ height: number;
771
+ };
772
+ declare function useSyncLayout(): () => void;
773
+
774
+ declare const LegendList: LegendListComponent;
669
775
 
670
- export { type ColumnWrapperStyle as C, type GetRenderedItemResult as G, type InternalState as I, type LegendListProps as L, type MaintainScrollAtEndOptions as M, type OnViewableItemsChanged as O, type ScrollTarget as S, type ThresholdSnapshot as T, type ViewabilityCallback as V, type LegendListRef as a, type ViewabilityAmountCallback as b, type LegendListRecyclingState as c, type LegendListPropsBase as d, type ViewableRange as e, type LegendListRenderItemProps as f, type ScrollState as g, type ViewToken as h, type ViewAmountToken as i, type ViewabilityConfigCallbackPair as j, type ViewabilityConfigCallbackPairs as k, type ViewabilityConfig as l, type TypedForwardRef as m, type TypedMemo as n, typedMemo as o, type ScrollIndexWithOffset as p, type ScrollIndexWithOffsetPosition as q, type ScrollIndexWithOffsetAndContentOffset as r, type InitialScrollAnchor as s, typedForwardRef as t, type GetRenderedItem as u };
776
+ export { type AlwaysRenderConfig, type AnchoredEndSpaceConfig, type ColumnWrapperStyle, type InitialScrollAnchor, type Insets, type LayoutRectangle, LegendList, type LegendListComponent, type LegendListMetrics, type LegendListProps, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type LegendListState, type MaintainScrollAtEndOnOptions, type MaintainScrollAtEndOptions, type MaintainVisibleContentPositionConfig, type NativeScrollEvent, type NativeSyntheticEvent, type OnViewableItemsChanged, type OnViewableItemsChangedInfo, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type StickyHeaderConfig, type StyleProp, type ViewAmountToken, type ViewStyle, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };