@legendapp/list 3.3.2 → 3.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## 3.3.4
2
+
3
+ - Feat: `getState().indexByKey(key)` looks up an item’s current index by key.
4
+ - Feat: `anchoredEndSpace` now works with standard React Native `LegendList`, including horizontal and RTL lists, and stays accurate after content measurements change. It supports single-column lists only.
5
+ - Fix: `maintainScrollAtEnd` continues following content growth unless the user scrolls away.
6
+ - Fix: Changing `dataKey` no longer briefly displays stale rows from the previous dataset.
7
+ - Fix: Initial scrolling and `scrollToIndex` correctly account for padding, direction, and final-item gaps.
8
+ - Fix: Web content-container sizing remains correct when callers provide padding or `content-box` styles.
9
+ - Fix: `useRecyclingEffect` and `useRecyclingState` no longer crash outside a `LegendList`. #498
10
+ - Fix: Programmatic scrolls settle reliably when superseded, already aligned on iOS, or interrupted by unmounting. #508
11
+ -
12
+ ## 3.3.3
13
+
14
+ - Fix: Row measurements are applied together in a batch, so item positions don't sometimes move after rendering.
15
+ - Fix: `onStartReached` and `onEndReached` no longer bounce between opposite edges during the same scroll gesture after data changes, MVCP adjustments, or residual scroll events.
16
+ - Fix: Prepending items with `maintainVisibleContentPosition` was sometimes flashing the wrong items for one frame
17
+ - Fix: SectionList sticky headers follow their current positions after section data changes. #445
18
+ - Fix: `LegendList` can now be wrapped with `Animated.createAnimatedComponent`.
19
+ - Fix: Horizontal web lists keep their calculated content width, so item containers do not shrink when the content is wider than the viewport.
20
+ - Perf: Lists reuse inactive containers across item types before creating more, preventing the container pool from growing for every previously seen item type.
21
+ - Perf: Reanimated lists skip scroll-offset tracking when neither shared scroll values nor sticky headers need it.
22
+
1
23
  ## 3.3.2
2
24
 
3
25
  - Perf: Recycled rows update their current item without changing the container context, so recycling hooks avoid extra rerenders during scroll.
package/animated.d.ts CHANGED
@@ -8,12 +8,13 @@ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
8
8
  shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
9
9
  }
10
10
 
11
- type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "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" | "adaptiveRender" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemInfo${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
11
+ type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "anchoredEndSpaceSize" | "containerLayoutEpoch" | "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" | "adaptiveRender" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemIndex${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
12
12
  type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
13
13
  type ListenerTypeValueMap = {
14
14
  activeStickyIndex: number;
15
15
  alignItemsAtEndPadding: number;
16
16
  anchoredEndSpaceSize: number;
17
+ containerLayoutEpoch: number;
17
18
  animatedScrollY: any;
18
19
  debugComputedScroll: number;
19
20
  debugRawScroll: number;
@@ -49,7 +50,7 @@ type ListenerTypeValueMap = {
49
50
  } & {
50
51
  [K in ListenerType as K extends `containerItemData${number}` ? K : never]: any;
51
52
  } & {
52
- [K in ListenerType as K extends `containerItemInfo${number}` ? K : never]: ContainerItemInfo;
53
+ [K in ListenerType as K extends `containerItemIndex${number}` ? K : never]: number;
53
54
  } & {
54
55
  [K in ListenerType as K extends `containerPosition${number}` ? K : never]: number;
55
56
  } & {
@@ -59,11 +60,6 @@ type ListenerTypeValueMap = {
59
60
  } & {
60
61
  [K in ListenerType as K extends `containerSticky${number}` ? K : never]: boolean;
61
62
  };
62
- interface ContainerItemInfo {
63
- index: number;
64
- itemKey: string;
65
- value: any;
66
- }
67
63
 
68
64
  interface Insets {
69
65
  top: number;
@@ -459,11 +455,15 @@ interface ScrollToEndOptions {
459
455
  viewOffset?: number;
460
456
  }
461
457
  interface AnchoredEndSpaceConfig {
458
+ /** Index of the item whose row should remain anchored when trailing space is added. */
462
459
  anchorIndex: number;
460
+ /** Desired distance from the viewport's start edge to the anchored row. */
463
461
  anchorOffset?: number;
462
+ /** Optional cap for the anchor item's contribution to its row size. */
464
463
  anchorMaxSize?: number;
465
- includeInEndInset?: boolean;
464
+ /** Called whenever the resolved trailing space changes. */
466
465
  onSizeChanged?: (size: number) => void;
466
+ /** Called once the anchor and every row after it have authoritative sizes. */
467
467
  onReady?: (info: AnchoredEndSpaceReadyInfo) => void;
468
468
  }
469
469
  interface StickyHeaderConfig {
@@ -538,6 +538,7 @@ type LegendListState = {
538
538
  isStartReached: boolean;
539
539
  isWithinMaintainScrollAtEndThreshold: boolean;
540
540
  getAverageItemSizes: () => Record<string, LegendListAverageItemSize>;
541
+ indexByKey: (key: string) => number | undefined;
541
542
  listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
542
543
  listenToPosition: (key: string, callback: (value: number) => void) => () => void;
543
544
  positionAtIndex: (index: number) => number;
@@ -567,6 +568,10 @@ type LegendListRef$1 = {
567
568
  * Returns the native ScrollView component reference.
568
569
  */
569
570
  getNativeScrollRef(): any;
571
+ /**
572
+ * Returns the underlying animatable scroll component reference.
573
+ */
574
+ getAnimatableRef(): any;
570
575
  /**
571
576
  * Returns the scroll responder instance for handling scroll events.
572
577
  */
@@ -719,6 +724,7 @@ interface ViewabilityConfig {
719
724
  }
720
725
 
721
726
  type LegendListPropsOverrides<ItemT, TItemType extends string | undefined> = Omit<LegendListPropsBase<ItemT, ScrollViewProps, TItemType>, "anchoredEndSpace" | "contentInsetEndAdjustment" | "onScroll" | "refScrollView" | "renderScrollComponent" | "ListHeaderComponentStyle" | "ListFooterComponentStyle"> & {
727
+ anchoredEndSpace?: AnchoredEndSpaceConfig;
722
728
  onScroll?: (event: NativeSyntheticEvent$1<NativeScrollEvent$1>) => void;
723
729
  refScrollView?: React.Ref<ScrollView>;
724
730
  renderScrollComponent?: (props: ScrollViewProps) => React.ReactElement<ScrollViewProps>;
@@ -726,7 +732,8 @@ type LegendListPropsOverrides<ItemT, TItemType extends string | undefined> = Omi
726
732
  ListFooterComponentStyle?: StyleProp$1<ViewStyle$1> | undefined;
727
733
  };
728
734
  type LegendListProps<ItemT = any, TItemType extends string | undefined = string | undefined> = LegendListPropsOverrides<ItemT, TItemType>;
729
- type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
735
+ type LegendListRef = Omit<LegendListRef$1, "getAnimatableRef" | "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
736
+ getAnimatableRef(): React.ElementRef<typeof ScrollViewComponent>;
730
737
  getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
731
738
  getScrollResponder(): ScrollResponderMixin;
732
739
  reportContentInset(inset?: Partial<Insets$1> | null): void;
@@ -9,12 +9,13 @@ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
9
9
  shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
10
10
  }
11
11
 
12
- type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "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" | "adaptiveRender" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemInfo${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
12
+ type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "anchoredEndSpaceSize" | "containerLayoutEpoch" | "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" | "adaptiveRender" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemIndex${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
13
13
  type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
14
14
  type ListenerTypeValueMap = {
15
15
  activeStickyIndex: number;
16
16
  alignItemsAtEndPadding: number;
17
17
  anchoredEndSpaceSize: number;
18
+ containerLayoutEpoch: number;
18
19
  animatedScrollY: any;
19
20
  debugComputedScroll: number;
20
21
  debugRawScroll: number;
@@ -50,7 +51,7 @@ type ListenerTypeValueMap = {
50
51
  } & {
51
52
  [K in ListenerType as K extends `containerItemData${number}` ? K : never]: any;
52
53
  } & {
53
- [K in ListenerType as K extends `containerItemInfo${number}` ? K : never]: ContainerItemInfo;
54
+ [K in ListenerType as K extends `containerItemIndex${number}` ? K : never]: number;
54
55
  } & {
55
56
  [K in ListenerType as K extends `containerPosition${number}` ? K : never]: number;
56
57
  } & {
@@ -60,11 +61,6 @@ type ListenerTypeValueMap = {
60
61
  } & {
61
62
  [K in ListenerType as K extends `containerSticky${number}` ? K : never]: boolean;
62
63
  };
63
- interface ContainerItemInfo {
64
- index: number;
65
- itemKey: string;
66
- value: any;
67
- }
68
64
 
69
65
  interface Insets {
70
66
  top: number;
@@ -101,6 +97,7 @@ type LegendListState = {
101
97
  isStartReached: boolean;
102
98
  isWithinMaintainScrollAtEndThreshold: boolean;
103
99
  getAverageItemSizes: () => Record<string, LegendListAverageItemSize>;
100
+ indexByKey: (key: string) => number | undefined;
104
101
  listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
105
102
  listenToPosition: (key: string, callback: (value: number) => void) => () => void;
106
103
  positionAtIndex: (index: number) => number;
@@ -130,6 +127,10 @@ type LegendListRef$1 = {
130
127
  * Returns the native ScrollView component reference.
131
128
  */
132
129
  getNativeScrollRef(): any;
130
+ /**
131
+ * Returns the underlying animatable scroll component reference.
132
+ */
133
+ getAnimatableRef(): any;
133
134
  /**
134
135
  * Returns the scroll responder instance for handling scroll events.
135
136
  */
@@ -231,7 +232,8 @@ type LegendListRef$1 = {
231
232
  setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
232
233
  };
233
234
 
234
- type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
235
+ type LegendListRef = Omit<LegendListRef$1, "getAnimatableRef" | "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
236
+ getAnimatableRef(): React.ElementRef<typeof ScrollViewComponent>;
235
237
  getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
236
238
  getScrollResponder(): ScrollResponderMixin;
237
239
  reportContentInset(inset?: Partial<Insets$1> | null): void;
package/keyboard.d.ts CHANGED
@@ -10,12 +10,13 @@ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
10
10
  shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
11
11
  }
12
12
 
13
- type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "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" | "adaptiveRender" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemInfo${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
13
+ type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "anchoredEndSpaceSize" | "containerLayoutEpoch" | "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" | "adaptiveRender" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemIndex${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
14
14
  type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
15
15
  type ListenerTypeValueMap = {
16
16
  activeStickyIndex: number;
17
17
  alignItemsAtEndPadding: number;
18
18
  anchoredEndSpaceSize: number;
19
+ containerLayoutEpoch: number;
19
20
  animatedScrollY: any;
20
21
  debugComputedScroll: number;
21
22
  debugRawScroll: number;
@@ -51,7 +52,7 @@ type ListenerTypeValueMap = {
51
52
  } & {
52
53
  [K in ListenerType as K extends `containerItemData${number}` ? K : never]: any;
53
54
  } & {
54
- [K in ListenerType as K extends `containerItemInfo${number}` ? K : never]: ContainerItemInfo;
55
+ [K in ListenerType as K extends `containerItemIndex${number}` ? K : never]: number;
55
56
  } & {
56
57
  [K in ListenerType as K extends `containerPosition${number}` ? K : never]: number;
57
58
  } & {
@@ -61,11 +62,6 @@ type ListenerTypeValueMap = {
61
62
  } & {
62
63
  [K in ListenerType as K extends `containerSticky${number}` ? K : never]: boolean;
63
64
  };
64
- interface ContainerItemInfo {
65
- index: number;
66
- itemKey: string;
67
- value: any;
68
- }
69
65
 
70
66
  interface Insets {
71
67
  top: number;
@@ -88,12 +84,16 @@ interface ScrollToEndOptions {
88
84
  animated?: boolean;
89
85
  viewOffset?: number;
90
86
  }
91
- interface AnchoredEndSpaceConfig$1 {
87
+ interface AnchoredEndSpaceConfig {
88
+ /** Index of the item whose row should remain anchored when trailing space is added. */
92
89
  anchorIndex: number;
90
+ /** Desired distance from the viewport's start edge to the anchored row. */
93
91
  anchorOffset?: number;
92
+ /** Optional cap for the anchor item's contribution to its row size. */
94
93
  anchorMaxSize?: number;
95
- includeInEndInset?: boolean;
94
+ /** Called whenever the resolved trailing space changes. */
96
95
  onSizeChanged?: (size: number) => void;
96
+ /** Called once the anchor and every row after it have authoritative sizes. */
97
97
  onReady?: (info: AnchoredEndSpaceReadyInfo) => void;
98
98
  }
99
99
  interface LegendListAverageItemSize {
@@ -115,6 +115,7 @@ type LegendListState = {
115
115
  isStartReached: boolean;
116
116
  isWithinMaintainScrollAtEndThreshold: boolean;
117
117
  getAverageItemSizes: () => Record<string, LegendListAverageItemSize>;
118
+ indexByKey: (key: string) => number | undefined;
118
119
  listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
119
120
  listenToPosition: (key: string, callback: (value: number) => void) => () => void;
120
121
  positionAtIndex: (index: number) => number;
@@ -144,6 +145,10 @@ type LegendListRef$1 = {
144
145
  * Returns the native ScrollView component reference.
145
146
  */
146
147
  getNativeScrollRef(): any;
148
+ /**
149
+ * Returns the underlying animatable scroll component reference.
150
+ */
151
+ getAnimatableRef(): any;
147
152
  /**
148
153
  * Returns the scroll responder instance for handling scroll events.
149
154
  */
@@ -245,10 +250,8 @@ type LegendListRef$1 = {
245
250
  setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
246
251
  };
247
252
 
248
- interface AnchoredEndSpaceConfig extends Omit<AnchoredEndSpaceConfig$1, "includeInEndInset"> {
249
- }
250
-
251
- type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
253
+ type LegendListRef = Omit<LegendListRef$1, "getAnimatableRef" | "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
254
+ getAnimatableRef(): React.ElementRef<typeof ScrollViewComponent>;
252
255
  getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
253
256
  getScrollResponder(): ScrollResponderMixin;
254
257
  reportContentInset(inset?: Partial<Insets$1> | null): void;
package/keyboard.js CHANGED
@@ -106,7 +106,6 @@ var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(
106
106
  }
107
107
  return {
108
108
  ...anchoredEndSpace,
109
- includeInEndInset: true,
110
109
  onSizeChanged: (size) => {
111
110
  var _a;
112
111
  blankSpace.value = size;
@@ -149,6 +148,7 @@ var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(
149
148
  AnimatedLegendListInternal,
150
149
  {
151
150
  anchoredEndSpace: anchoredEndSpaceWithBlankSpace,
151
+ anchoredEndSpaceOwnerInternal: "scroll",
152
152
  ref: combinedRef,
153
153
  renderScrollComponent: memoList,
154
154
  ...rest
package/keyboard.mjs CHANGED
@@ -85,7 +85,6 @@ var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(
85
85
  }
86
86
  return {
87
87
  ...anchoredEndSpace,
88
- includeInEndInset: true,
89
88
  onSizeChanged: (size) => {
90
89
  var _a;
91
90
  blankSpace.value = size;
@@ -128,6 +127,7 @@ var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(
128
127
  AnimatedLegendListInternal,
129
128
  {
130
129
  anchoredEndSpace: anchoredEndSpaceWithBlankSpace,
130
+ anchoredEndSpaceOwnerInternal: "scroll",
131
131
  ref: combinedRef,
132
132
  renderScrollComponent: memoList,
133
133
  ...rest
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "3.3.2",
3
+ "version": "3.3.4",
4
4
  "description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,
package/react-native.d.ts CHANGED
@@ -8,12 +8,13 @@ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
8
8
  shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
9
9
  }
10
10
 
11
- type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "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" | "adaptiveRender" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemInfo${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
11
+ type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "anchoredEndSpaceSize" | "containerLayoutEpoch" | "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" | "adaptiveRender" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemIndex${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
12
12
  type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
13
13
  type ListenerTypeValueMap = {
14
14
  activeStickyIndex: number;
15
15
  alignItemsAtEndPadding: number;
16
16
  anchoredEndSpaceSize: number;
17
+ containerLayoutEpoch: number;
17
18
  animatedScrollY: any;
18
19
  debugComputedScroll: number;
19
20
  debugRawScroll: number;
@@ -49,7 +50,7 @@ type ListenerTypeValueMap = {
49
50
  } & {
50
51
  [K in ListenerType as K extends `containerItemData${number}` ? K : never]: any;
51
52
  } & {
52
- [K in ListenerType as K extends `containerItemInfo${number}` ? K : never]: ContainerItemInfo;
53
+ [K in ListenerType as K extends `containerItemIndex${number}` ? K : never]: number;
53
54
  } & {
54
55
  [K in ListenerType as K extends `containerPosition${number}` ? K : never]: number;
55
56
  } & {
@@ -59,11 +60,6 @@ type ListenerTypeValueMap = {
59
60
  } & {
60
61
  [K in ListenerType as K extends `containerSticky${number}` ? K : never]: boolean;
61
62
  };
62
- interface ContainerItemInfo {
63
- index: number;
64
- itemKey: string;
65
- value: any;
66
- }
67
63
 
68
64
  interface Insets {
69
65
  top: number;
@@ -459,11 +455,15 @@ interface ScrollToEndOptions {
459
455
  viewOffset?: number;
460
456
  }
461
457
  interface AnchoredEndSpaceConfig {
458
+ /** Index of the item whose row should remain anchored when trailing space is added. */
462
459
  anchorIndex: number;
460
+ /** Desired distance from the viewport's start edge to the anchored row. */
463
461
  anchorOffset?: number;
462
+ /** Optional cap for the anchor item's contribution to its row size. */
464
463
  anchorMaxSize?: number;
465
- includeInEndInset?: boolean;
464
+ /** Called whenever the resolved trailing space changes. */
466
465
  onSizeChanged?: (size: number) => void;
466
+ /** Called once the anchor and every row after it have authoritative sizes. */
467
467
  onReady?: (info: AnchoredEndSpaceReadyInfo) => void;
468
468
  }
469
469
  interface StickyHeaderConfig {
@@ -538,6 +538,7 @@ type LegendListState$1 = {
538
538
  isStartReached: boolean;
539
539
  isWithinMaintainScrollAtEndThreshold: boolean;
540
540
  getAverageItemSizes: () => Record<string, LegendListAverageItemSize>;
541
+ indexByKey: (key: string) => number | undefined;
541
542
  listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
542
543
  listenToPosition: (key: string, callback: (value: number) => void) => () => void;
543
544
  positionAtIndex: (index: number) => number;
@@ -567,6 +568,10 @@ type LegendListRef$1 = {
567
568
  * Returns the native ScrollView component reference.
568
569
  */
569
570
  getNativeScrollRef(): any;
571
+ /**
572
+ * Returns the underlying animatable scroll component reference.
573
+ */
574
+ getAnimatableRef(): any;
570
575
  /**
571
576
  * Returns the scroll responder instance for handling scroll events.
572
577
  */
@@ -745,6 +750,7 @@ interface ScrollIndexWithOffsetAndContentOffset extends ScrollIndexWithOffsetPos
745
750
  }
746
751
 
747
752
  type LegendListPropsOverrides<ItemT, TItemType extends string | undefined> = Omit<LegendListPropsBase<ItemT, ScrollViewProps, TItemType>, "anchoredEndSpace" | "contentInsetEndAdjustment" | "onScroll" | "refScrollView" | "renderScrollComponent" | "ListHeaderComponentStyle" | "ListFooterComponentStyle"> & {
753
+ anchoredEndSpace?: AnchoredEndSpaceConfig;
748
754
  onScroll?: (event: NativeSyntheticEvent$1<NativeScrollEvent$1>) => void;
749
755
  refScrollView?: React.Ref<ScrollView>;
750
756
  renderScrollComponent?: (props: ScrollViewProps) => React.ReactElement<ScrollViewProps>;
@@ -752,7 +758,8 @@ type LegendListPropsOverrides<ItemT, TItemType extends string | undefined> = Omi
752
758
  ListFooterComponentStyle?: StyleProp$1<ViewStyle$1> | undefined;
753
759
  };
754
760
  type LegendListProps<ItemT = any, TItemType extends string | undefined = string | undefined> = LegendListPropsOverrides<ItemT, TItemType>;
755
- type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
761
+ type LegendListRef = Omit<LegendListRef$1, "getAnimatableRef" | "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
762
+ getAnimatableRef(): React.ElementRef<typeof ScrollViewComponent>;
756
763
  getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
757
764
  getScrollResponder(): ScrollResponderMixin;
758
765
  reportContentInset(inset?: Partial<Insets$1> | null): void;
@@ -777,4 +784,4 @@ declare function useSyncLayout(): () => void;
777
784
 
778
785
  declare const LegendList: LegendListComponent;
779
786
 
780
- export { type AdaptiveRender, type AdaptiveRenderChangeReason, type AdaptiveRenderConfig, 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, useAdaptiveRender, useAdaptiveRenderChange, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
787
+ export { type AdaptiveRender, type AdaptiveRenderChangeReason, type AdaptiveRenderConfig, type AlwaysRenderConfig, type AnchoredEndSpaceConfig, 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, useAdaptiveRender, useAdaptiveRenderChange, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };