@legendapp/list 3.3.1 → 3.3.3

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/reanimated.d.ts CHANGED
@@ -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}` | `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;
@@ -49,6 +50,8 @@ type ListenerTypeValueMap = {
49
50
  [K in ListenerType as K extends `containerItemKey${number}` ? K : never]: string;
50
51
  } & {
51
52
  [K in ListenerType as K extends `containerItemData${number}` ? K : never]: any;
53
+ } & {
54
+ [K in ListenerType as K extends `containerItemIndex${number}` ? K : never]: number;
52
55
  } & {
53
56
  [K in ListenerType as K extends `containerPosition${number}` ? K : never]: number;
54
57
  } & {
@@ -561,6 +564,10 @@ type LegendListRef$1 = {
561
564
  * Returns the native ScrollView component reference.
562
565
  */
563
566
  getNativeScrollRef(): any;
567
+ /**
568
+ * Returns the underlying animatable scroll component reference.
569
+ */
570
+ getAnimatableRef(): any;
564
571
  /**
565
572
  * Returns the scroll responder instance for handling scroll events.
566
573
  */
@@ -720,7 +727,8 @@ type LegendListPropsOverrides<ItemT, TItemType extends string | undefined> = Omi
720
727
  ListFooterComponentStyle?: StyleProp$1<ViewStyle$1> | undefined;
721
728
  };
722
729
  type LegendListProps<ItemT = any, TItemType extends string | undefined = string | undefined> = LegendListPropsOverrides<ItemT, TItemType>;
723
- type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
730
+ type LegendListRef = Omit<LegendListRef$1, "getAnimatableRef" | "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
731
+ getAnimatableRef(): React.ElementRef<typeof ScrollViewComponent>;
724
732
  getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
725
733
  getScrollResponder(): ScrollResponderMixin;
726
734
  reportContentInset(inset?: Partial<Insets$1> | null): void;
package/reanimated.js CHANGED
@@ -41,6 +41,13 @@ var {
41
41
  getComponent
42
42
  } = reactNative.internal;
43
43
  var { peek$, useStateContext } = reactNative.internal;
44
+ var ReanimatedScrollOffsetTracker = ({
45
+ animatedScrollRef,
46
+ scrollOffset
47
+ }) => {
48
+ Reanimated.useScrollViewOffset(animatedScrollRef, scrollOffset);
49
+ return null;
50
+ };
44
51
  var ReanimatedScrollBridge = typedMemo(function ReanimatedScrollBridgeComponent({
45
52
  forwardedRef,
46
53
  scrollOffset,
@@ -48,7 +55,6 @@ var ReanimatedScrollBridge = typedMemo(function ReanimatedScrollBridgeComponent(
48
55
  ...props
49
56
  }) {
50
57
  const animatedScrollRef = Reanimated.useAnimatedRef();
51
- Reanimated.useScrollViewOffset(animatedScrollRef, scrollOffset);
52
58
  const combinedRef = useCombinedRef(animatedScrollRef, forwardedRef);
53
59
  const CustomScrollComponent = useStableRenderComponent(renderScrollComponent, (scrollViewProps, ref) => ({
54
60
  ...scrollViewProps,
@@ -56,7 +62,7 @@ var ReanimatedScrollBridge = typedMemo(function ReanimatedScrollBridgeComponent(
56
62
  scrollEventThrottle: 1
57
63
  }));
58
64
  const ScrollComponent = renderScrollComponent ? CustomScrollComponent : Reanimated__default.default.ScrollView;
59
- return /* @__PURE__ */ React__namespace.createElement(ScrollComponent, { ...props, ref: combinedRef });
65
+ return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, scrollOffset && /* @__PURE__ */ React__namespace.createElement(ReanimatedScrollOffsetTracker, { animatedScrollRef, scrollOffset }), /* @__PURE__ */ React__namespace.createElement(ScrollComponent, { ...props, ref: combinedRef }));
60
66
  });
61
67
  var StickyOverlay = typedMemo(function StickyOverlayComponent({ stickyHeaderConfig }) {
62
68
  if (!(stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent)) {
@@ -77,17 +83,18 @@ var StickyOverlay = typedMemo(function StickyOverlayComponent({ stickyHeaderConf
77
83
  var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStickyComponent(props) {
78
84
  var _a;
79
85
  const ctx = useStateContext();
80
- const { id, horizontal, style, refView, stickyScrollOffset, stickyHeaderConfig, index, children, ...rest } = props;
81
- const [position = POSITION_OUT_OF_VIEW, headerSize = 0, stylePaddingTop = 0, itemKey, _totalSize = 0] = useArr$([
86
+ const { id, horizontal, style, refView, stickyScrollOffset, stickyHeaderConfig, children, ...rest } = props;
87
+ const [position = POSITION_OUT_OF_VIEW, headerSize = 0, stylePaddingTop = 0, itemKey, itemIndex, _totalSize = 0] = useArr$([
82
88
  `containerPosition${id}`,
83
89
  "headerSize",
84
90
  "stylePaddingTop",
85
91
  `containerItemKey${id}`,
92
+ `containerItemIndex${id}`,
86
93
  "totalSize"
87
94
  ]);
88
95
  const pushLimit = React__namespace.useMemo(
89
- () => getStickyPushLimit(ctx.state, index, itemKey),
90
- [ctx.state, index, itemKey, _totalSize]
96
+ () => getStickyPushLimit(ctx.state, itemIndex, itemKey),
97
+ [ctx.state, itemIndex, itemKey, _totalSize]
91
98
  );
92
99
  const stickyOffset = (_a = stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.offset) != null ? _a : 0;
93
100
  const stickyStart = position + headerSize + stylePaddingTop - stickyOffset;
@@ -98,8 +105,8 @@ var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStic
98
105
  return horizontal ? { transform: [{ translateX: resolvedPosition }] } : { transform: [{ translateY: resolvedPosition }] };
99
106
  }, [horizontal, position, pushLimit, stickyStart]);
100
107
  const viewStyle = React__namespace.useMemo(
101
- () => [style, { zIndex: index + 1e3 }, stickyPositionStyle],
102
- [index, stickyPositionStyle, style]
108
+ () => [style, { zIndex: itemIndex + 1e3 }, stickyPositionStyle],
109
+ [itemIndex, stickyPositionStyle, style]
103
110
  );
104
111
  return /* @__PURE__ */ React__namespace.createElement(Reanimated__default.default.View, { ref: refView, style: viewStyle, ...rest }, /* @__PURE__ */ React__namespace.createElement(StickyOverlay, { stickyHeaderConfig }), children);
105
112
  });
@@ -185,7 +192,7 @@ function useAnimatedLegendListSharedValuesSync(legendList, sharedValues) {
185
192
  var LegendListForwardedRef = typedMemo(
186
193
  // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
187
194
  React__namespace.forwardRef(function LegendListForwardedRef2(props, ref) {
188
- var _a;
195
+ var _a, _b;
189
196
  const { itemLayoutAnimation, recycleItems, refLegendList, renderScrollComponent, sharedValues, ...rest } = props;
190
197
  const refFn = React.useCallback(
191
198
  (r) => {
@@ -195,6 +202,7 @@ var LegendListForwardedRef = typedMemo(
195
202
  );
196
203
  const internalScrollOffset = Reanimated.useSharedValue(0);
197
204
  const scrollOffset = (_a = sharedValues == null ? void 0 : sharedValues.scrollOffset) != null ? _a : internalScrollOffset;
205
+ const trackedScrollOffset = (sharedValues == null ? void 0 : sharedValues.scrollOffset) !== void 0 || ((_b = rest.stickyHeaderIndices) == null ? void 0 : _b.length) ? scrollOffset : void 0;
198
206
  const renderScrollComponentForBridge = React__namespace.useMemo(
199
207
  () => renderScrollComponent ? (scrollViewProps) => renderScrollComponent(scrollViewProps) : void 0,
200
208
  [renderScrollComponent]
@@ -208,11 +216,11 @@ var LegendListForwardedRef = typedMemo(
208
216
  ...restScrollViewProps,
209
217
  forwardedRef,
210
218
  renderScrollComponent: renderScrollComponentForBridge,
211
- scrollOffset
219
+ scrollOffset: trackedScrollOffset
212
220
  }
213
221
  );
214
222
  },
215
- [renderScrollComponentForBridge, scrollOffset]
223
+ [renderScrollComponentForBridge, trackedScrollOffset]
216
224
  );
217
225
  const stickyPositionComponentInternal = React__namespace.useMemo(
218
226
  () => function StickyPositionComponent(stickyProps) {
package/reanimated.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useCallback } from 'react';
3
3
  import { View } from 'react-native';
4
- import Reanimated, { useAnimatedRef, useScrollViewOffset, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
4
+ import Reanimated, { useAnimatedRef, useAnimatedStyle, useSharedValue, useScrollViewOffset } from 'react-native-reanimated';
5
5
  import { internal, LegendList } from '@legendapp/list/react-native';
6
6
 
7
7
  // src/integrations/reanimated.tsx
@@ -17,6 +17,13 @@ var {
17
17
  getComponent
18
18
  } = internal;
19
19
  var { peek$, useStateContext } = internal;
20
+ var ReanimatedScrollOffsetTracker = ({
21
+ animatedScrollRef,
22
+ scrollOffset
23
+ }) => {
24
+ useScrollViewOffset(animatedScrollRef, scrollOffset);
25
+ return null;
26
+ };
20
27
  var ReanimatedScrollBridge = typedMemo(function ReanimatedScrollBridgeComponent({
21
28
  forwardedRef,
22
29
  scrollOffset,
@@ -24,7 +31,6 @@ var ReanimatedScrollBridge = typedMemo(function ReanimatedScrollBridgeComponent(
24
31
  ...props
25
32
  }) {
26
33
  const animatedScrollRef = useAnimatedRef();
27
- useScrollViewOffset(animatedScrollRef, scrollOffset);
28
34
  const combinedRef = useCombinedRef(animatedScrollRef, forwardedRef);
29
35
  const CustomScrollComponent = useStableRenderComponent(renderScrollComponent, (scrollViewProps, ref) => ({
30
36
  ...scrollViewProps,
@@ -32,7 +38,7 @@ var ReanimatedScrollBridge = typedMemo(function ReanimatedScrollBridgeComponent(
32
38
  scrollEventThrottle: 1
33
39
  }));
34
40
  const ScrollComponent = renderScrollComponent ? CustomScrollComponent : Reanimated.ScrollView;
35
- return /* @__PURE__ */ React.createElement(ScrollComponent, { ...props, ref: combinedRef });
41
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, scrollOffset && /* @__PURE__ */ React.createElement(ReanimatedScrollOffsetTracker, { animatedScrollRef, scrollOffset }), /* @__PURE__ */ React.createElement(ScrollComponent, { ...props, ref: combinedRef }));
36
42
  });
37
43
  var StickyOverlay = typedMemo(function StickyOverlayComponent({ stickyHeaderConfig }) {
38
44
  if (!(stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent)) {
@@ -53,17 +59,18 @@ var StickyOverlay = typedMemo(function StickyOverlayComponent({ stickyHeaderConf
53
59
  var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStickyComponent(props) {
54
60
  var _a;
55
61
  const ctx = useStateContext();
56
- const { id, horizontal, style, refView, stickyScrollOffset, stickyHeaderConfig, index, children, ...rest } = props;
57
- const [position = POSITION_OUT_OF_VIEW, headerSize = 0, stylePaddingTop = 0, itemKey, _totalSize = 0] = useArr$([
62
+ const { id, horizontal, style, refView, stickyScrollOffset, stickyHeaderConfig, children, ...rest } = props;
63
+ const [position = POSITION_OUT_OF_VIEW, headerSize = 0, stylePaddingTop = 0, itemKey, itemIndex, _totalSize = 0] = useArr$([
58
64
  `containerPosition${id}`,
59
65
  "headerSize",
60
66
  "stylePaddingTop",
61
67
  `containerItemKey${id}`,
68
+ `containerItemIndex${id}`,
62
69
  "totalSize"
63
70
  ]);
64
71
  const pushLimit = React.useMemo(
65
- () => getStickyPushLimit(ctx.state, index, itemKey),
66
- [ctx.state, index, itemKey, _totalSize]
72
+ () => getStickyPushLimit(ctx.state, itemIndex, itemKey),
73
+ [ctx.state, itemIndex, itemKey, _totalSize]
67
74
  );
68
75
  const stickyOffset = (_a = stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.offset) != null ? _a : 0;
69
76
  const stickyStart = position + headerSize + stylePaddingTop - stickyOffset;
@@ -74,8 +81,8 @@ var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStic
74
81
  return horizontal ? { transform: [{ translateX: resolvedPosition }] } : { transform: [{ translateY: resolvedPosition }] };
75
82
  }, [horizontal, position, pushLimit, stickyStart]);
76
83
  const viewStyle = React.useMemo(
77
- () => [style, { zIndex: index + 1e3 }, stickyPositionStyle],
78
- [index, stickyPositionStyle, style]
84
+ () => [style, { zIndex: itemIndex + 1e3 }, stickyPositionStyle],
85
+ [itemIndex, stickyPositionStyle, style]
79
86
  );
80
87
  return /* @__PURE__ */ React.createElement(Reanimated.View, { ref: refView, style: viewStyle, ...rest }, /* @__PURE__ */ React.createElement(StickyOverlay, { stickyHeaderConfig }), children);
81
88
  });
@@ -161,7 +168,7 @@ function useAnimatedLegendListSharedValuesSync(legendList, sharedValues) {
161
168
  var LegendListForwardedRef = typedMemo(
162
169
  // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
163
170
  React.forwardRef(function LegendListForwardedRef2(props, ref) {
164
- var _a;
171
+ var _a, _b;
165
172
  const { itemLayoutAnimation, recycleItems, refLegendList, renderScrollComponent, sharedValues, ...rest } = props;
166
173
  const refFn = useCallback(
167
174
  (r) => {
@@ -171,6 +178,7 @@ var LegendListForwardedRef = typedMemo(
171
178
  );
172
179
  const internalScrollOffset = useSharedValue(0);
173
180
  const scrollOffset = (_a = sharedValues == null ? void 0 : sharedValues.scrollOffset) != null ? _a : internalScrollOffset;
181
+ const trackedScrollOffset = (sharedValues == null ? void 0 : sharedValues.scrollOffset) !== void 0 || ((_b = rest.stickyHeaderIndices) == null ? void 0 : _b.length) ? scrollOffset : void 0;
174
182
  const renderScrollComponentForBridge = React.useMemo(
175
183
  () => renderScrollComponent ? (scrollViewProps) => renderScrollComponent(scrollViewProps) : void 0,
176
184
  [renderScrollComponent]
@@ -184,11 +192,11 @@ var LegendListForwardedRef = typedMemo(
184
192
  ...restScrollViewProps,
185
193
  forwardedRef,
186
194
  renderScrollComponent: renderScrollComponentForBridge,
187
- scrollOffset
195
+ scrollOffset: trackedScrollOffset
188
196
  }
189
197
  );
190
198
  },
191
- [renderScrollComponentForBridge, scrollOffset]
199
+ [renderScrollComponentForBridge, trackedScrollOffset]
192
200
  );
193
201
  const stickyPositionComponentInternal = React.useMemo(
194
202
  () => function StickyPositionComponent(stickyProps) {
package/section-list.d.ts CHANGED
@@ -65,12 +65,13 @@ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
65
65
  shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
66
66
  }
67
67
 
68
- 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}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
68
+ 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}`;
69
69
  type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
70
70
  type ListenerTypeValueMap = {
71
71
  activeStickyIndex: number;
72
72
  alignItemsAtEndPadding: number;
73
73
  anchoredEndSpaceSize: number;
74
+ containerLayoutEpoch: number;
74
75
  animatedScrollY: any;
75
76
  debugComputedScroll: number;
76
77
  debugRawScroll: number;
@@ -105,6 +106,8 @@ type ListenerTypeValueMap = {
105
106
  [K in ListenerType as K extends `containerItemKey${number}` ? K : never]: string;
106
107
  } & {
107
108
  [K in ListenerType as K extends `containerItemData${number}` ? K : never]: any;
109
+ } & {
110
+ [K in ListenerType as K extends `containerItemIndex${number}` ? K : never]: number;
108
111
  } & {
109
112
  [K in ListenerType as K extends `containerPosition${number}` ? K : never]: number;
110
113
  } & {
@@ -617,6 +620,10 @@ type LegendListRef$1 = {
617
620
  * Returns the native ScrollView component reference.
618
621
  */
619
622
  getNativeScrollRef(): any;
623
+ /**
624
+ * Returns the underlying animatable scroll component reference.
625
+ */
626
+ getAnimatableRef(): any;
620
627
  /**
621
628
  * Returns the scroll responder instance for handling scroll events.
622
629
  */
@@ -776,7 +783,8 @@ type LegendListPropsOverrides<ItemT, TItemType extends string | undefined> = Omi
776
783
  ListFooterComponentStyle?: StyleProp$1<ViewStyle$1> | undefined;
777
784
  };
778
785
  type LegendListProps<ItemT = any, TItemType extends string | undefined = string | undefined> = LegendListPropsOverrides<ItemT, TItemType>;
779
- type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
786
+ type LegendListRef = Omit<LegendListRef$1, "getAnimatableRef" | "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
787
+ getAnimatableRef(): React.ElementRef<typeof ScrollViewComponent>;
780
788
  getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
781
789
  getScrollResponder(): ScrollResponderMixin;
782
790
  reportContentInset(inset?: Partial<Insets$1> | null): void;