@legendapp/list 3.0.0-beta.9 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/.DS_Store +0 -0
  2. package/CHANGELOG.md +27 -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-1Hgg1rTO.d.mts → react-native.d.ts} +269 -284
  15. package/react-native.js +6471 -0
  16. package/react-native.mjs +6442 -0
  17. package/{types-1Hgg1rTO.d.ts → react-native.web.d.ts} +330 -283
  18. package/react-native.web.js +7125 -0
  19. package/react-native.web.mjs +7096 -0
  20. package/react.d.ts +771 -0
  21. package/react.js +7125 -0
  22. package/react.mjs +7096 -0
  23. package/reanimated.d.ts +681 -8
  24. package/reanimated.js +225 -38
  25. package/reanimated.mjs +227 -40
  26. package/section-list.d.ts +682 -7
  27. package/section-list.js +85 -3854
  28. package/section-list.mjs +83 -3853
  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 -3935
  33. package/index.mjs +0 -3907
  34. package/index.native.d.mts +0 -23
  35. package/index.native.d.ts +0 -23
  36. package/index.native.js +0 -3739
  37. package/index.native.mjs +0 -3711
  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 -3897
  48. package/section-list.native.mjs +0 -3876
@@ -1,24 +1,32 @@
1
- import * as React$1 from 'react';
2
- import { ComponentProps, Key, ReactNode } from 'react';
3
- import { View, ScrollView, Animated, LayoutRectangle, ScrollViewProps, Insets, ScrollViewComponent, ScrollResponderMixin, StyleProp, ViewStyle, NativeSyntheticEvent, NativeScrollEvent } 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;
5
+ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
6
+ data: boolean;
7
+ size: boolean;
8
+ shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
9
+ }
7
10
 
8
- type ListenerType = "activeStickyIndex" | "alignItemsPaddingTop" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | `containerColumn${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}` | `containerStickyOffset${number}`;
9
- type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
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">;
10
13
  type ListenerTypeValueMap = {
11
14
  activeStickyIndex: number;
12
- alignItemsPaddingTop: number;
15
+ anchoredEndSpaceSize: number;
13
16
  animatedScrollY: any;
14
17
  debugComputedScroll: number;
15
18
  debugRawScroll: number;
16
19
  extraData: any;
17
20
  footerSize: number;
18
21
  headerSize: number;
22
+ isAtEnd: boolean;
23
+ isAtStart: boolean;
24
+ isNearEnd: boolean;
25
+ isNearStart: boolean;
26
+ isWithinMaintainScrollAtEndThreshold: boolean;
19
27
  lastItemKeys: string[];
20
28
  lastPositionUpdate: number;
21
- maintainVisibleContentPosition: boolean;
29
+ maintainVisibleContentPosition: MaintainVisibleContentPositionNormalized;
22
30
  numColumns: number;
23
31
  numContainers: number;
24
32
  numContainersPooled: number;
@@ -43,49 +51,44 @@ type ListenerTypeValueMap = {
43
51
  } & {
44
52
  [K in ListenerType as K extends `containerColumn${number}` ? K : never]: number;
45
53
  } & {
46
- [K in ListenerType as K extends `containerSticky${number}` ? K : never]: boolean;
54
+ [K in ListenerType as K extends `containerSpan${number}` ? K : never]: number;
47
55
  } & {
48
- [K in ListenerType as K extends `containerStickyOffset${number}` ? K : never]: number;
56
+ [K in ListenerType as K extends `containerSticky${number}` ? K : never]: boolean;
49
57
  };
50
- interface StateContext {
51
- animatedScrollY: AnimatedValue;
52
- columnWrapperStyle: ColumnWrapperStyle | undefined;
53
- contextNum: number;
54
- listeners: Map<ListenerType, Set<(value: any) => void>>;
55
- mapViewabilityCallbacks: Map<string, ViewabilityCallback>;
56
- mapViewabilityValues: Map<string, ViewToken>;
57
- mapViewabilityAmountCallbacks: Map<number, ViewabilityAmountCallback>;
58
- mapViewabilityAmountValues: Map<number, ViewAmountToken>;
59
- mapViewabilityConfigStates: Map<string, {
60
- viewableItems: ViewToken[];
61
- start: number;
62
- end: number;
63
- previousStart: number;
64
- previousEnd: number;
65
- }>;
66
- positionListeners: Map<string, Set<(value: any) => void>>;
67
- state: InternalState;
68
- values: Map<ListenerType, any>;
69
- viewRefs: Map<number, React$1.RefObject<View>>;
70
- }
71
58
 
72
- declare class ScrollAdjustHandler {
73
- private appliedAdjust;
74
- private pendingAdjust;
75
- private ctx;
76
- constructor(ctx: StateContext);
77
- requestAdjust(add: number): void;
78
- getAdjust(): number;
79
- commitPendingAdjust(): void;
59
+ interface Insets {
60
+ top: number;
61
+ left: number;
62
+ bottom: number;
63
+ right: number;
80
64
  }
81
-
82
- type BaseSharedValue<T = number> = {
83
- get: () => T;
84
- };
85
- type StylesAsSharedValue<Style> = {
86
- [key in keyof Style]: Style[key] | BaseSharedValue<Style[key]>;
87
- };
88
-
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;
89
92
  type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
90
93
  interface DataModeProps<ItemT, TItemType extends string | undefined> {
91
94
  /**
@@ -94,13 +97,11 @@ interface DataModeProps<ItemT, TItemType extends string | undefined> {
94
97
  */
95
98
  data: ReadonlyArray<ItemT>;
96
99
  /**
97
- * Function or React component to render each item in the list.
98
- * Can be either:
99
- * - A function: (props: LegendListRenderItemProps<ItemT>) => ReactNode
100
- * - 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.
101
102
  * @required when using data mode
102
103
  */
103
- renderItem: ((props: LegendListRenderItemProps<ItemT, TItemType>) => ReactNode) | React.ComponentType<LegendListRenderItemProps<ItemT, TItemType>>;
104
+ renderItem: (props: LegendListRenderItemProps<ItemT, TItemType>) => React.ReactNode;
104
105
  children?: never;
105
106
  }
106
107
  interface ChildrenModeProps {
@@ -109,7 +110,7 @@ interface ChildrenModeProps {
109
110
  * Each child will be treated as an individual list item.
110
111
  * @required when using children mode
111
112
  */
112
- children: ReactNode;
113
+ children: React.ReactNode;
113
114
  data?: never;
114
115
  renderItem?: never;
115
116
  }
@@ -119,10 +120,20 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
119
120
  * @default false
120
121
  */
121
122
  alignItemsAtEnd?: boolean;
123
+ /**
124
+ * Keeps selected items mounted even when they scroll out of view.
125
+ * @default undefined
126
+ */
127
+ alwaysRender?: AlwaysRenderConfig;
122
128
  /**
123
129
  * Style applied to each column's wrapper view.
124
130
  */
125
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;
126
137
  /**
127
138
  * Distance in pixels to pre-render items ahead of the visible area.
128
139
  * @default 250
@@ -147,25 +158,25 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
147
158
  */
148
159
  extraData?: any;
149
160
  /**
150
- * Version token that forces the list to treat data as updated even when the array reference is stable.
151
- * 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.
152
162
  */
153
- dataVersion?: Key;
163
+ getFixedItemSize?: (item: ItemT, index: number, type: TItemType) => number | undefined;
154
164
  /**
155
- * In case you have distinct item sizes, you can provide a function to get the size of an item.
156
- * 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.
157
166
  */
158
- getEstimatedItemSize?: (index: number, item: ItemT, type: TItemType) => number;
167
+ getItemType?: (item: ItemT, index: number) => TItemType;
159
168
  /**
160
- * Ratio of initial container pool size to data length (e.g., 0.5 for half).
161
- * @default 2
169
+ * Component to render between items, receiving the leading item as prop.
162
170
  */
163
- initialContainerPoolRatio?: number | undefined;
171
+ ItemSeparatorComponent?: React.ComponentType<{
172
+ leadingItem: ItemT;
173
+ }>;
164
174
  /**
165
- * Initial scroll position in pixels.
166
- * @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
167
178
  */
168
- initialScrollOffset?: number;
179
+ initialScrollAtEnd?: boolean;
169
180
  /**
170
181
  * Index to scroll to initially.
171
182
  * @default 0
@@ -173,19 +184,17 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
173
184
  initialScrollIndex?: number | {
174
185
  index: number;
175
186
  viewOffset?: number | undefined;
187
+ viewPosition?: number | undefined;
176
188
  };
177
189
  /**
178
- * When true, the list initializes scrolled to the last item.
179
- * Overrides `initialScrollIndex` and `initialScrollOffset` when data is available.
180
- * @default false
190
+ * Initial scroll position in pixels.
191
+ * @default 0
181
192
  */
182
- initialScrollAtEnd?: boolean;
193
+ initialScrollOffset?: number;
183
194
  /**
184
- * Component to render between items, receiving the leading item as prop.
195
+ * Custom equality function to detect semantically unchanged items.
185
196
  */
186
- ItemSeparatorComponent?: React.ComponentType<{
187
- leadingItem: ItemT;
188
- }>;
197
+ itemsAreEqual?: (itemPrevious: ItemT, item: ItemT, index: number, data: readonly ItemT[]) => boolean;
189
198
  /**
190
199
  * Function to extract a unique key for each item.
191
200
  */
@@ -210,8 +219,16 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
210
219
  * Style for the header component.
211
220
  */
212
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;
213
229
  /**
214
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.
215
232
  * @default false
216
233
  */
217
234
  maintainScrollAtEnd?: boolean | MaintainScrollAtEndOptions;
@@ -221,16 +238,34 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
221
238
  */
222
239
  maintainScrollAtEndThreshold?: number;
223
240
  /**
224
- * If true, maintains visibility of content across data changes (filtering/resorting/insertions).
225
- * Scroll-time stability for measurements is always enabled.
226
- * @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.
227
247
  */
228
- maintainVisibleContentPosition?: boolean;
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.
256
+ */
257
+ contentInsetEndAdjustment?: number;
229
258
  /**
230
259
  * Number of columns to render items in.
231
260
  * @default 1
232
261
  */
233
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;
234
269
  /**
235
270
  * Called when scrolling reaches the end within onEndReachedThreshold.
236
271
  */
@@ -252,10 +287,23 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
252
287
  itemKey: string;
253
288
  itemData: ItemT;
254
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;
255
300
  /**
256
301
  * Function to call when the user pulls to refresh.
257
302
  */
258
303
  onRefresh?: () => void;
304
+ /**
305
+ * Called when the list scrolls.
306
+ */
259
307
  onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
260
308
  /**
261
309
  * Called when scrolling reaches the start within onStartReachedThreshold.
@@ -279,6 +327,12 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
279
327
  * Called when the viewability of items changes.
280
328
  */
281
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;
282
336
  /**
283
337
  * Offset in pixels for the refresh indicator.
284
338
  * @default 0
@@ -292,7 +346,7 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
292
346
  /**
293
347
  * Ref to the underlying ScrollView component.
294
348
  */
295
- refScrollView?: React.Ref<ScrollView>;
349
+ refScrollView?: React.Ref<any>;
296
350
  /**
297
351
  * If true, shows a refresh indicator.
298
352
  * @default false
@@ -303,13 +357,11 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
303
357
  * Note: When using `stickyHeaderIndices`, you must provide an Animated ScrollView component.
304
358
  * @default (props) => <ScrollView {...props} />
305
359
  */
306
- renderScrollComponent?: (props: ScrollViewProps) => React.ReactElement<ScrollViewProps>;
360
+ renderScrollComponent?: (props: any) => React.ReactElement | null;
307
361
  /**
308
- * This will log a suggested estimatedItemSize.
309
- * @required
310
- * @default false
362
+ * Array of item indices to use as snap points.
311
363
  */
312
- suggestEstimatedItemSize?: boolean;
364
+ snapToIndices?: number[];
313
365
  /**
314
366
  * Configuration for determining item viewability.
315
367
  */
@@ -318,15 +370,6 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
318
370
  * Pairs of viewability configs and their callbacks for tracking visibility.
319
371
  */
320
372
  viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs<ItemT> | undefined;
321
- /**
322
- * If true, delays rendering until initial layout is complete.
323
- * @default false
324
- */
325
- waitForInitialLayout?: boolean;
326
- onLoad?: (info: {
327
- elapsedTimeInMs: number;
328
- }) => void;
329
- snapToIndices?: number[];
330
373
  /**
331
374
  * Array of child indices determining which children get docked to the top of the screen when scrolling.
332
375
  * For example, passing stickyHeaderIndices={[0]} will cause the first child to be fixed to the top of the scroll view.
@@ -335,174 +378,77 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
335
378
  */
336
379
  stickyHeaderIndices?: number[];
337
380
  /**
338
- * @deprecated Use stickyHeaderIndices instead for parity with React Native.
381
+ * Configuration for sticky headers.
382
+ * @default undefined
339
383
  */
340
- stickyIndices?: number[];
341
- getItemType?: (item: ItemT, index: number) => TItemType;
342
- getFixedItemSize?: (index: number, item: ItemT, type: TItemType) => number | undefined;
343
- 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;
344
427
  }
345
- 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);
346
428
  interface MaintainScrollAtEndOptions {
347
- onLayout?: boolean;
348
- onItemLayout?: boolean;
349
- 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;
350
439
  }
351
440
  interface ColumnWrapperStyle {
352
441
  rowGap?: number;
353
442
  gap?: number;
354
443
  columnGap?: number;
355
444
  }
356
- type LegendListProps<ItemT = any> = LegendListPropsBase<ItemT, ComponentProps<typeof ScrollView>>;
357
- interface ThresholdSnapshot {
358
- scrollPosition: number;
359
- contentSize?: number;
360
- dataLength?: number;
361
- atThreshold: boolean;
362
- }
363
- interface ScrollTarget {
364
- animated?: boolean;
365
- index?: number;
366
- isInitialScroll?: boolean;
367
- itemSize?: number;
368
- offset: number;
369
- precomputedWithViewOffset?: boolean;
370
- viewOffset?: number;
371
- viewPosition?: number;
372
- }
373
- interface InternalState {
374
- activeStickyIndex: number | undefined;
375
- adjustingFromInitialMount?: number;
376
- animFrameCheckFinishedScroll?: any;
377
- averageSizes: Record<string, {
378
- num: number;
379
- avg: number;
380
- }>;
381
- columns: Map<string, number>;
382
- containerItemKeys: Set<string>;
383
- containerItemTypes: Map<number, string>;
384
- dataChangeNeedsScrollUpdate: boolean;
385
- didColumnsChange?: boolean;
386
- didDataChange?: boolean;
387
- didFinishInitialScroll?: boolean;
388
- didContainersLayout?: boolean;
389
- enableScrollForNextCalculateItemsInView: boolean;
390
- endBuffered: number;
391
- endNoBuffer: number;
392
- endReachedSnapshot: ThresholdSnapshot | undefined;
393
- firstFullyOnScreenIndex: number;
394
- hasScrolled?: boolean;
395
- idCache: string[];
396
- idsInView: string[];
397
- ignoreScrollFromMVCP?: {
398
- lt?: number;
399
- gt?: number;
400
- };
401
- ignoreScrollFromMVCPIgnored?: boolean;
402
- ignoreScrollFromMVCPTimeout?: any;
403
- indexByKey: Map<string, number>;
404
- initialAnchor?: InitialScrollAnchor;
405
- initialScroll: ScrollIndexWithOffsetAndContentOffset | undefined;
406
- isAtEnd: boolean;
407
- isAtStart: boolean;
408
- isEndReached: boolean | null;
409
- isFirst?: boolean;
410
- isStartReached: boolean | null;
411
- lastBatchingAction: number;
412
- lastLayout: LayoutRectangle | undefined;
413
- lastScrollAdjustForHistory?: number;
414
- loadStartTime: number;
415
- maintainingScrollAtEnd?: boolean;
416
- minIndexSizeChanged: number | undefined;
417
- nativeMarginTop: number;
418
- needsOtherAxisSize?: boolean;
419
- otherAxisSize?: number;
420
- pendingTotalSize?: number;
421
- positions: Map<string, number>;
422
- previousData?: readonly unknown[];
423
- queuedCalculateItemsInView: number | undefined;
424
- queuedInitialLayout?: boolean | undefined;
425
- refScroller: React.RefObject<ScrollView>;
426
- scroll: number;
427
- scrollAdjustHandler: ScrollAdjustHandler;
428
- scrollForNextCalculateItemsInView: {
429
- top: number | null;
430
- bottom: number | null;
431
- } | undefined;
432
- scrollHistory: Array<{
433
- scroll: number;
434
- time: number;
435
- }>;
436
- scrollingTo?: ScrollTarget | undefined;
437
- scrollLastCalculate?: number;
438
- scrollLength: number;
439
- scrollPending: number;
440
- scrollPrev: number;
441
- scrollPrevTime: number;
442
- scrollProcessingEnabled: boolean;
443
- scrollTime: number;
444
- sizes: Map<string, number>;
445
- sizesKnown: Map<string, number>;
446
- startBuffered: number;
447
- startBufferedId?: string;
448
- startNoBuffer: number;
449
- startReachedSnapshot: ThresholdSnapshot | undefined;
450
- stickyContainerPool: Set<number>;
451
- stickyContainers: Map<number, number>;
452
- timeouts: Set<number>;
453
- timeoutSetPaddingTop?: any;
454
- timeoutSizeMessage: any;
455
- timeoutCheckFinishedScrollFallback?: any;
456
- totalSize: number;
457
- triggerCalculateItemsInView?: (params?: {
458
- doMVCP?: boolean;
459
- dataChanged?: boolean;
460
- forceFullItemPositions?: boolean;
461
- }) => void;
462
- viewabilityConfigCallbackPairs: ViewabilityConfigCallbackPairs<any> | undefined;
463
- props: {
464
- alignItemsAtEnd: boolean;
465
- animatedProps: StylesAsSharedValue<ScrollViewProps>;
466
- contentInset: Insets | undefined;
467
- data: readonly any[];
468
- dataVersion: Key | undefined;
469
- estimatedItemSize: number | undefined;
470
- getEstimatedItemSize: LegendListProps["getEstimatedItemSize"];
471
- getFixedItemSize: LegendListProps["getFixedItemSize"];
472
- getItemType: LegendListProps["getItemType"];
473
- horizontal: boolean;
474
- initialContainerPoolRatio: number;
475
- itemsAreEqual: LegendListProps["itemsAreEqual"];
476
- keyExtractor: LegendListProps["keyExtractor"];
477
- maintainScrollAtEnd: boolean | MaintainScrollAtEndOptions;
478
- maintainScrollAtEndThreshold: number | undefined;
479
- maintainVisibleContentPosition: boolean;
480
- numColumns: number;
481
- onEndReached: LegendListProps["onEndReached"];
482
- onEndReachedThreshold: number | null | undefined;
483
- onItemSizeChanged: LegendListProps["onItemSizeChanged"];
484
- onLoad: LegendListProps["onLoad"];
485
- onScroll: LegendListProps["onScroll"];
486
- onStartReached: LegendListProps["onStartReached"];
487
- onStartReachedThreshold: number | null | undefined;
488
- onStickyHeaderChange: LegendListProps["onStickyHeaderChange"];
489
- recycleItems: boolean;
490
- renderItem: LegendListProps["renderItem"];
491
- scrollBuffer: number;
492
- snapToIndices: number[] | undefined;
493
- stickyIndicesArr: number[];
494
- stickyIndicesSet: Set<number>;
495
- stylePaddingBottom: number | undefined;
496
- stylePaddingTop: number | undefined;
497
- suggestEstimatedItemSize: boolean;
498
- };
445
+ interface LegendListMetrics {
446
+ headerSize: number;
447
+ footerSize: number;
499
448
  }
500
- interface ViewableRange<T> {
501
- end: number;
502
- endBuffered: number;
503
- items: T[];
504
- start: number;
505
- startBuffered: number;
449
+ interface LegendListAverageItemSize {
450
+ average: number;
451
+ count: number;
506
452
  }
507
453
  interface LegendListRenderItemProps<ItemT, TItemType extends string | number | undefined = string | number | undefined> {
508
454
  data: readonly ItemT[];
@@ -511,27 +457,34 @@ interface LegendListRenderItemProps<ItemT, TItemType extends string | number | u
511
457
  item: ItemT;
512
458
  type: TItemType;
513
459
  }
514
- type LegendListState = {
460
+ type LegendListState$1 = {
515
461
  activeStickyIndex: number;
516
462
  contentLength: number;
517
463
  data: readonly any[];
518
- elementAtIndex: (index: number) => View | null | undefined;
464
+ elementAtIndex: (index: number) => any;
519
465
  end: number;
520
466
  endBuffered: number;
521
467
  isAtEnd: boolean;
522
468
  isAtStart: boolean;
469
+ isNearEnd: boolean;
470
+ isNearStart: boolean;
471
+ isEndReached: boolean;
472
+ isStartReached: boolean;
473
+ isWithinMaintainScrollAtEndThreshold: boolean;
474
+ getAverageItemSizes: () => Record<string, LegendListAverageItemSize>;
523
475
  listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
524
476
  listenToPosition: (key: string, callback: (value: number) => void) => () => void;
525
477
  positionAtIndex: (index: number) => number;
526
- positions: Map<string, number>;
478
+ positionByKey: (key: string) => number | undefined;
527
479
  scroll: number;
528
480
  scrollLength: number;
481
+ scrollVelocity: number;
529
482
  sizeAtIndex: (index: number) => number;
530
483
  sizes: Map<string, number>;
531
484
  start: number;
532
485
  startBuffered: number;
533
486
  };
534
- type LegendListRef = {
487
+ type LegendListRef$1 = {
535
488
  /**
536
489
  * Displays the scroll indicators momentarily.
537
490
  */
@@ -539,7 +492,7 @@ type LegendListRef = {
539
492
  /**
540
493
  * Returns the native ScrollView component reference.
541
494
  */
542
- getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
495
+ getNativeScrollRef(): any;
543
496
  /**
544
497
  * Returns the scroll responder instance for handling scroll events.
545
498
  */
@@ -547,11 +500,11 @@ type LegendListRef = {
547
500
  /**
548
501
  * Returns the ScrollResponderMixin for advanced scroll handling.
549
502
  */
550
- getScrollResponder(): ScrollResponderMixin;
503
+ getScrollResponder(): any;
551
504
  /**
552
505
  * Returns the internal state of the scroll virtualization.
553
506
  */
554
- getState(): LegendListState;
507
+ getState(): LegendListState$1;
555
508
  /**
556
509
  * Scrolls a specific index into view.
557
510
  * @param params - Parameters for scrolling.
@@ -561,7 +514,7 @@ type LegendListRef = {
561
514
  scrollIndexIntoView(params: {
562
515
  animated?: boolean | undefined;
563
516
  index: number;
564
- }): void;
517
+ }): Promise<void>;
565
518
  /**
566
519
  * Scrolls a specific index into view.
567
520
  * @param params - Parameters for scrolling.
@@ -571,7 +524,7 @@ type LegendListRef = {
571
524
  scrollItemIntoView(params: {
572
525
  animated?: boolean | undefined;
573
526
  item: any;
574
- }): void;
527
+ }): Promise<void>;
575
528
  /**
576
529
  * Scrolls to the end of the list.
577
530
  * @param options - Options for scrolling.
@@ -581,7 +534,7 @@ type LegendListRef = {
581
534
  scrollToEnd(options?: {
582
535
  animated?: boolean | undefined;
583
536
  viewOffset?: number | undefined;
584
- }): void;
537
+ }): Promise<void>;
585
538
  /**
586
539
  * Scrolls to a specific index in the list.
587
540
  * @param params - Parameters for scrolling.
@@ -595,7 +548,7 @@ type LegendListRef = {
595
548
  index: number;
596
549
  viewOffset?: number | undefined;
597
550
  viewPosition?: number | undefined;
598
- }): void;
551
+ }): Promise<void>;
599
552
  /**
600
553
  * Scrolls to a specific item in the list.
601
554
  * @param params - Parameters for scrolling.
@@ -609,7 +562,7 @@ type LegendListRef = {
609
562
  item: any;
610
563
  viewOffset?: number | undefined;
611
564
  viewPosition?: number | undefined;
612
- }): void;
565
+ }): Promise<void>;
613
566
  /**
614
567
  * Scrolls to a specific offset in pixels.
615
568
  * @param params - Parameters for scrolling.
@@ -619,7 +572,7 @@ type LegendListRef = {
619
572
  scrollToOffset(params: {
620
573
  offset: number;
621
574
  animated?: boolean | undefined;
622
- }): void;
575
+ }): Promise<void>;
623
576
  /**
624
577
  * Sets or adds to the offset of the visible content anchor.
625
578
  * @param value - The offset to set or add.
@@ -631,6 +584,19 @@ type LegendListRef = {
631
584
  * @param enabled - If true, scroll processing is enabled.
632
585
  */
633
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;
634
600
  };
635
601
  interface ViewToken<ItemT = any> {
636
602
  containerId: number;
@@ -651,10 +617,15 @@ interface ViewabilityConfigCallbackPair<ItemT = any> {
651
617
  viewabilityConfig: ViewabilityConfig;
652
618
  }
653
619
  type ViewabilityConfigCallbackPairs<ItemT> = ViewabilityConfigCallbackPair<ItemT>[];
654
- type OnViewableItemsChanged<ItemT> = ((info: {
655
- viewableItems: Array<ViewToken<ItemT>>;
620
+ interface OnViewableItemsChangedInfo<ItemT> {
656
621
  changed: Array<ViewToken<ItemT>>;
657
- }) => 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;
658
629
  interface ViewabilityConfig {
659
630
  /**
660
631
  * A unique ID to identify this viewability config
@@ -692,12 +663,6 @@ interface LegendListRecyclingState<T> {
692
663
  prevIndex: number | undefined;
693
664
  prevItem: T | undefined;
694
665
  }
695
- type TypedForwardRef = <T, P = {}>(render: (props: P, ref: React.Ref<T>) => React.ReactNode) => (props: P & React.RefAttributes<T>) => React.ReactNode;
696
- declare const typedForwardRef: TypedForwardRef;
697
- type TypedMemo = <T extends React.ComponentType<any>>(Component: T, propsAreEqual?: (prevProps: Readonly<React.JSXElementConstructor<T>>, nextProps: Readonly<React.JSXElementConstructor<T>>) => boolean) => T & {
698
- displayName?: string;
699
- };
700
- declare const typedMemo: TypedMemo;
701
666
  interface ScrollIndexWithOffset {
702
667
  index: number;
703
668
  viewOffset?: number;
@@ -709,16 +674,36 @@ interface ScrollIndexWithOffsetPosition extends ScrollIndexWithOffset {
709
674
  interface ScrollIndexWithOffsetAndContentOffset extends ScrollIndexWithOffsetPosition {
710
675
  contentOffset?: number;
711
676
  }
712
- interface InitialScrollAnchor extends ScrollIndexWithOffsetPosition {
713
- attempts?: number;
714
- lastDelta?: number;
715
- settledTicks?: number;
716
- }
717
- type GetRenderedItemResult<ItemT> = {
718
- index: number;
719
- item: ItemT;
720
- 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;
721
690
  };
722
- type GetRenderedItem = (key: string) => GetRenderedItemResult<any> | null;
691
+ type LegendListState = Omit<LegendListState$1, "elementAtIndex"> & {
692
+ elementAtIndex: (index: number) => View | null | undefined;
693
+ };
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;
723
708
 
724
- 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 LegendListState 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 };