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