@legendapp/list 3.0.0-beta.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/.DS_Store +0 -0
  2. package/CHANGELOG.md +21 -1
  3. package/README.md +8 -2
  4. package/animated.d.ts +659 -5
  5. package/animated.js +2 -2
  6. package/animated.mjs +1 -1
  7. package/keyboard-legacy.d.ts +226 -0
  8. package/keyboard-legacy.js +456 -0
  9. package/keyboard-legacy.mjs +435 -0
  10. package/keyboard.d.ts +261 -9
  11. package/keyboard.js +114 -135
  12. package/keyboard.mjs +115 -137
  13. package/package.json +55 -5
  14. package/{types-DjNeqVEk.d.mts → react-native.d.ts} +318 -278
  15. package/react-native.js +6453 -0
  16. package/react-native.mjs +6424 -0
  17. package/react-native.web.d.ts +771 -0
  18. package/react-native.web.js +7111 -0
  19. package/react-native.web.mjs +7082 -0
  20. package/react.d.ts +771 -0
  21. package/react.js +7111 -0
  22. package/react.mjs +7082 -0
  23. package/reanimated.d.ts +681 -8
  24. package/reanimated.js +225 -29
  25. package/reanimated.mjs +227 -31
  26. package/section-list.d.ts +663 -5
  27. package/section-list.js +39 -3720
  28. package/section-list.mjs +37 -3719
  29. package/animated.d.mts +0 -9
  30. package/index.d.mts +0 -23
  31. package/index.d.ts +0 -23
  32. package/index.js +0 -3826
  33. package/index.mjs +0 -3798
  34. package/index.native.d.mts +0 -23
  35. package/index.native.d.ts +0 -23
  36. package/index.native.js +0 -3580
  37. package/index.native.mjs +0 -3552
  38. package/keyboard-controller.d.mts +0 -12
  39. package/keyboard-controller.d.ts +0 -12
  40. package/keyboard-controller.js +0 -69
  41. package/keyboard-controller.mjs +0 -48
  42. package/keyboard.d.mts +0 -13
  43. package/reanimated.d.mts +0 -18
  44. package/section-list.d.mts +0 -113
  45. package/section-list.native.d.mts +0 -113
  46. package/section-list.native.d.ts +0 -113
  47. package/section-list.native.js +0 -3738
  48. package/section-list.native.mjs +0 -3717
  49. package/types-DjNeqVEk.d.ts +0 -669
package/reanimated.js CHANGED
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
+ var reactNative$1 = require('react-native');
4
5
  var Reanimated = require('react-native-reanimated');
5
- var list = require('@legendapp/list');
6
+ var reactNative = require('@legendapp/list/react-native');
6
7
 
7
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
9
 
@@ -28,52 +29,247 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
29
  var Reanimated__default = /*#__PURE__*/_interopDefault(Reanimated);
29
30
 
30
31
  // src/integrations/reanimated.tsx
31
-
32
- // src/utils/helpers.ts
33
- function isFunction(obj) {
34
- return typeof obj === "function";
35
- }
36
-
37
- // src/hooks/useCombinedRef.ts
38
- var useCombinedRef = (...refs) => {
39
- const callback = React.useCallback((element) => {
40
- for (const ref of refs) {
41
- if (!ref) {
42
- continue;
43
- }
44
- if (isFunction(ref)) {
45
- ref(element);
46
- } else {
47
- ref.current = element;
32
+ var {
33
+ POSITION_OUT_OF_VIEW,
34
+ IsNewArchitecture,
35
+ getStickyPushLimit,
36
+ typedMemo,
37
+ useArr$,
38
+ useCombinedRef,
39
+ useLatestRef,
40
+ useStableRenderComponent,
41
+ getComponent
42
+ } = reactNative.internal;
43
+ var { peek$, useStateContext } = reactNative.internal;
44
+ var ReanimatedScrollBridge = typedMemo(function ReanimatedScrollBridgeComponent({
45
+ forwardedRef,
46
+ scrollOffset,
47
+ renderScrollComponent,
48
+ ...props
49
+ }) {
50
+ const animatedScrollRef = Reanimated.useAnimatedRef();
51
+ Reanimated.useScrollViewOffset(animatedScrollRef, scrollOffset);
52
+ const combinedRef = useCombinedRef(animatedScrollRef, forwardedRef);
53
+ const CustomScrollComponent = useStableRenderComponent(renderScrollComponent, (scrollViewProps, ref) => ({
54
+ ...scrollViewProps,
55
+ ref,
56
+ scrollEventThrottle: 1
57
+ }));
58
+ const ScrollComponent = renderScrollComponent ? CustomScrollComponent : Reanimated__default.default.ScrollView;
59
+ return /* @__PURE__ */ React__namespace.createElement(ScrollComponent, { ...props, ref: combinedRef });
60
+ });
61
+ var StickyOverlay = typedMemo(function StickyOverlayComponent({ stickyHeaderConfig }) {
62
+ if (!(stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent)) {
63
+ return null;
64
+ }
65
+ return /* @__PURE__ */ React__namespace.createElement(
66
+ reactNative$1.View,
67
+ {
68
+ style: {
69
+ inset: 0,
70
+ pointerEvents: "none",
71
+ position: "absolute"
48
72
  }
73
+ },
74
+ getComponent(stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent)
75
+ );
76
+ });
77
+ var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStickyComponent(props) {
78
+ var _a;
79
+ 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$([
82
+ `containerPosition${id}`,
83
+ "headerSize",
84
+ "stylePaddingTop",
85
+ `containerItemKey${id}`,
86
+ "totalSize"
87
+ ]);
88
+ const pushLimit = React__namespace.useMemo(
89
+ () => getStickyPushLimit(ctx.state, index, itemKey),
90
+ [ctx.state, index, itemKey, _totalSize]
91
+ );
92
+ const stickyOffset = (_a = stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.offset) != null ? _a : 0;
93
+ const stickyStart = position + headerSize + stylePaddingTop - stickyOffset;
94
+ const stickyPositionStyle = Reanimated.useAnimatedStyle(() => {
95
+ const delta = Math.max(0, stickyScrollOffset.value - stickyStart);
96
+ const stickyPosition = position + delta;
97
+ const resolvedPosition = pushLimit !== void 0 ? Math.min(stickyPosition, pushLimit) : stickyPosition;
98
+ return horizontal ? { transform: [{ translateX: resolvedPosition }] } : { transform: [{ translateY: resolvedPosition }] };
99
+ }, [horizontal, position, pushLimit, stickyStart]);
100
+ const viewStyle = React__namespace.useMemo(
101
+ () => [style, { zIndex: index + 1e3 }, stickyPositionStyle],
102
+ [index, stickyPositionStyle, style]
103
+ );
104
+ return /* @__PURE__ */ React__namespace.createElement(Reanimated__default.default.View, { ref: refView, style: viewStyle, ...rest }, /* @__PURE__ */ React__namespace.createElement(StickyOverlay, { stickyHeaderConfig }), children);
105
+ });
106
+ var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(props) {
107
+ const ctx = useStateContext();
108
+ const { id, horizontal, style, refView, children, recycleItems, layoutTransition, ...rest } = props;
109
+ const [positionValue = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
110
+ const prevItemKeyRef = React__namespace.useRef(void 0);
111
+ let shouldSkipTransitionForRecycleReuse = false;
112
+ if (recycleItems && layoutTransition) {
113
+ const itemKeySignal = `containerItemKey${id}`;
114
+ const itemKey = peek$(ctx, itemKeySignal);
115
+ shouldSkipTransitionForRecycleReuse = itemKey !== void 0 && prevItemKeyRef.current !== void 0 && prevItemKeyRef.current !== itemKey;
116
+ if (itemKey !== void 0) {
117
+ prevItemKeyRef.current = itemKey;
49
118
  }
50
- }, refs);
51
- return callback;
52
- };
53
-
54
- // src/integrations/reanimated.tsx
55
- var typedMemo = React.memo;
119
+ } else {
120
+ prevItemKeyRef.current = void 0;
121
+ }
122
+ const viewStyle = React__namespace.useMemo(
123
+ () => [style, horizontal ? { left: positionValue } : { top: positionValue }],
124
+ [horizontal, positionValue, style]
125
+ );
126
+ return /* @__PURE__ */ React__namespace.createElement(
127
+ Reanimated__default.default.View,
128
+ {
129
+ layout: shouldSkipTransitionForRecycleReuse ? void 0 : layoutTransition,
130
+ ref: refView,
131
+ style: viewStyle,
132
+ ...rest
133
+ },
134
+ children
135
+ );
136
+ });
137
+ function setSharedValueValue(sharedValue, value) {
138
+ if (!sharedValue) {
139
+ return;
140
+ }
141
+ const sharedValueWithMethods = sharedValue;
142
+ if (typeof sharedValueWithMethods.set === "function") {
143
+ sharedValueWithMethods.set(value);
144
+ } else {
145
+ sharedValueWithMethods.value = value;
146
+ }
147
+ }
148
+ function useAnimatedLegendListSharedValuesSync(legendList, sharedValues) {
149
+ React__namespace.useEffect(() => {
150
+ if (!legendList || !sharedValues) {
151
+ return;
152
+ }
153
+ const state = legendList.getState();
154
+ setSharedValueValue(sharedValues.activeStickyIndex, state.activeStickyIndex);
155
+ setSharedValueValue(sharedValues.isAtEnd, state.isAtEnd);
156
+ setSharedValueValue(sharedValues.isAtStart, state.isAtStart);
157
+ setSharedValueValue(sharedValues.isNearEnd, state.isNearEnd);
158
+ setSharedValueValue(sharedValues.isNearStart, state.isNearStart);
159
+ setSharedValueValue(
160
+ sharedValues.isWithinMaintainScrollAtEndThreshold,
161
+ state.isWithinMaintainScrollAtEndThreshold
162
+ );
163
+ setSharedValueValue(sharedValues.scrollOffset, state.scroll);
164
+ const unsubscribers = [
165
+ sharedValues.activeStickyIndex ? state.listen(
166
+ "activeStickyIndex",
167
+ (value) => setSharedValueValue(sharedValues.activeStickyIndex, value)
168
+ ) : void 0,
169
+ sharedValues.isAtEnd ? state.listen("isAtEnd", (value) => setSharedValueValue(sharedValues.isAtEnd, value)) : void 0,
170
+ sharedValues.isAtStart ? state.listen("isAtStart", (value) => setSharedValueValue(sharedValues.isAtStart, value)) : void 0,
171
+ sharedValues.isNearEnd ? state.listen("isNearEnd", (value) => setSharedValueValue(sharedValues.isNearEnd, value)) : void 0,
172
+ sharedValues.isNearStart ? state.listen("isNearStart", (value) => setSharedValueValue(sharedValues.isNearStart, value)) : void 0,
173
+ sharedValues.isWithinMaintainScrollAtEndThreshold ? state.listen(
174
+ "isWithinMaintainScrollAtEndThreshold",
175
+ (value) => setSharedValueValue(sharedValues.isWithinMaintainScrollAtEndThreshold, value)
176
+ ) : void 0
177
+ ];
178
+ return () => {
179
+ for (const unsubscribe of unsubscribers) {
180
+ unsubscribe == null ? void 0 : unsubscribe();
181
+ }
182
+ };
183
+ }, [legendList, sharedValues]);
184
+ }
56
185
  var LegendListForwardedRef = typedMemo(
57
186
  // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
58
187
  React__namespace.forwardRef(function LegendListForwardedRef2(props, ref) {
59
- const { refLegendList, ...rest } = props;
188
+ var _a;
189
+ const { itemLayoutAnimation, recycleItems, refLegendList, renderScrollComponent, sharedValues, ...rest } = props;
60
190
  const refFn = React.useCallback(
61
191
  (r) => {
62
192
  refLegendList(r);
63
193
  },
64
194
  [refLegendList]
65
195
  );
66
- return /* @__PURE__ */ React__namespace.createElement(list.LegendList, { ref: refFn, refScrollView: ref, ...rest });
196
+ const internalScrollOffset = Reanimated.useSharedValue(0);
197
+ const scrollOffset = (_a = sharedValues == null ? void 0 : sharedValues.scrollOffset) != null ? _a : internalScrollOffset;
198
+ const renderScrollComponentForBridge = React__namespace.useMemo(
199
+ () => renderScrollComponent ? (scrollViewProps) => renderScrollComponent(scrollViewProps) : void 0,
200
+ [renderScrollComponent]
201
+ );
202
+ const renderReanimatedScrollComponent = React.useCallback(
203
+ (scrollViewProps) => {
204
+ const { ref: forwardedRef, ...restScrollViewProps } = scrollViewProps;
205
+ return /* @__PURE__ */ React__namespace.createElement(
206
+ ReanimatedScrollBridge,
207
+ {
208
+ ...restScrollViewProps,
209
+ forwardedRef,
210
+ renderScrollComponent: renderScrollComponentForBridge,
211
+ scrollOffset
212
+ }
213
+ );
214
+ },
215
+ [renderScrollComponentForBridge, scrollOffset]
216
+ );
217
+ const stickyPositionComponentInternal = React__namespace.useMemo(
218
+ () => function StickyPositionComponent(stickyProps) {
219
+ return /* @__PURE__ */ React__namespace.createElement(ReanimatedPositionViewSticky, { ...stickyProps, stickyScrollOffset: scrollOffset });
220
+ },
221
+ [scrollOffset]
222
+ );
223
+ const itemLayoutAnimationRef = useLatestRef(itemLayoutAnimation);
224
+ const hasItemLayoutAnimation = !!itemLayoutAnimation;
225
+ const positionComponentInternal = React__namespace.useMemo(() => {
226
+ if (!hasItemLayoutAnimation) {
227
+ return void 0;
228
+ }
229
+ return function PositionComponent(positionProps) {
230
+ return /* @__PURE__ */ React__namespace.createElement(
231
+ ReanimatedPositionView,
232
+ {
233
+ ...positionProps,
234
+ layoutTransition: itemLayoutAnimationRef.current,
235
+ recycleItems
236
+ }
237
+ );
238
+ };
239
+ }, [hasItemLayoutAnimation, recycleItems]);
240
+ const legendListProps = {
241
+ ...rest,
242
+ positionComponentInternal,
243
+ recycleItems,
244
+ ...{
245
+ renderScrollComponent: renderReanimatedScrollComponent,
246
+ ...IsNewArchitecture ? { stickyPositionComponentInternal } : {}
247
+ }
248
+ };
249
+ return /* @__PURE__ */ React__namespace.createElement(reactNative.LegendList, { ref: refFn, refScrollView: ref, ...legendListProps });
67
250
  })
68
251
  );
69
252
  var AnimatedLegendListComponent = Reanimated__default.default.createAnimatedComponent(LegendListForwardedRef);
253
+ var AnimatedLegendListComponentTyped = AnimatedLegendListComponent;
70
254
  var AnimatedLegendList = typedMemo(
71
255
  // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
72
256
  React__namespace.forwardRef(function AnimatedLegendList2(props, ref) {
73
257
  const { refScrollView, ...rest } = props;
74
- const refLegendList = React__namespace.useRef(null);
75
- const combinedRef = useCombinedRef(refLegendList, ref);
76
- return /* @__PURE__ */ React__namespace.createElement(AnimatedLegendListComponent, { ref: refScrollView, refLegendList: combinedRef, ...rest });
258
+ const { animatedProps, sharedValues } = props;
259
+ const [legendList, setLegendList] = React__namespace.useState(null);
260
+ const combinedRef = useCombinedRef(
261
+ React__namespace.useCallback((instance) => {
262
+ setLegendList((prev) => prev === instance ? prev : instance);
263
+ }, []),
264
+ ref
265
+ );
266
+ useAnimatedLegendListSharedValuesSync(legendList, sharedValues);
267
+ const forwardedProps = {
268
+ ...rest,
269
+ animatedPropsInternal: animatedProps,
270
+ refLegendList: combinedRef
271
+ };
272
+ return /* @__PURE__ */ React__namespace.createElement(AnimatedLegendListComponentTyped, { ...forwardedProps, ref: refScrollView });
77
273
  })
78
274
  );
79
275
 
package/reanimated.mjs CHANGED
@@ -1,55 +1,251 @@
1
1
  import * as React from 'react';
2
- import { useCallback, memo } from 'react';
3
- import Reanimated from 'react-native-reanimated';
4
- import { LegendList } from '@legendapp/list';
2
+ import { useCallback } from 'react';
3
+ import { View } from 'react-native';
4
+ import Reanimated, { useAnimatedRef, useScrollViewOffset, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
5
+ import { internal, LegendList } from '@legendapp/list/react-native';
5
6
 
6
7
  // src/integrations/reanimated.tsx
7
-
8
- // src/utils/helpers.ts
9
- function isFunction(obj) {
10
- return typeof obj === "function";
11
- }
12
-
13
- // src/hooks/useCombinedRef.ts
14
- var useCombinedRef = (...refs) => {
15
- const callback = useCallback((element) => {
16
- for (const ref of refs) {
17
- if (!ref) {
18
- continue;
19
- }
20
- if (isFunction(ref)) {
21
- ref(element);
22
- } else {
23
- ref.current = element;
8
+ var {
9
+ POSITION_OUT_OF_VIEW,
10
+ IsNewArchitecture,
11
+ getStickyPushLimit,
12
+ typedMemo,
13
+ useArr$,
14
+ useCombinedRef,
15
+ useLatestRef,
16
+ useStableRenderComponent,
17
+ getComponent
18
+ } = internal;
19
+ var { peek$, useStateContext } = internal;
20
+ var ReanimatedScrollBridge = typedMemo(function ReanimatedScrollBridgeComponent({
21
+ forwardedRef,
22
+ scrollOffset,
23
+ renderScrollComponent,
24
+ ...props
25
+ }) {
26
+ const animatedScrollRef = useAnimatedRef();
27
+ useScrollViewOffset(animatedScrollRef, scrollOffset);
28
+ const combinedRef = useCombinedRef(animatedScrollRef, forwardedRef);
29
+ const CustomScrollComponent = useStableRenderComponent(renderScrollComponent, (scrollViewProps, ref) => ({
30
+ ...scrollViewProps,
31
+ ref,
32
+ scrollEventThrottle: 1
33
+ }));
34
+ const ScrollComponent = renderScrollComponent ? CustomScrollComponent : Reanimated.ScrollView;
35
+ return /* @__PURE__ */ React.createElement(ScrollComponent, { ...props, ref: combinedRef });
36
+ });
37
+ var StickyOverlay = typedMemo(function StickyOverlayComponent({ stickyHeaderConfig }) {
38
+ if (!(stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent)) {
39
+ return null;
40
+ }
41
+ return /* @__PURE__ */ React.createElement(
42
+ View,
43
+ {
44
+ style: {
45
+ inset: 0,
46
+ pointerEvents: "none",
47
+ position: "absolute"
24
48
  }
49
+ },
50
+ getComponent(stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent)
51
+ );
52
+ });
53
+ var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStickyComponent(props) {
54
+ var _a;
55
+ 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$([
58
+ `containerPosition${id}`,
59
+ "headerSize",
60
+ "stylePaddingTop",
61
+ `containerItemKey${id}`,
62
+ "totalSize"
63
+ ]);
64
+ const pushLimit = React.useMemo(
65
+ () => getStickyPushLimit(ctx.state, index, itemKey),
66
+ [ctx.state, index, itemKey, _totalSize]
67
+ );
68
+ const stickyOffset = (_a = stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.offset) != null ? _a : 0;
69
+ const stickyStart = position + headerSize + stylePaddingTop - stickyOffset;
70
+ const stickyPositionStyle = useAnimatedStyle(() => {
71
+ const delta = Math.max(0, stickyScrollOffset.value - stickyStart);
72
+ const stickyPosition = position + delta;
73
+ const resolvedPosition = pushLimit !== void 0 ? Math.min(stickyPosition, pushLimit) : stickyPosition;
74
+ return horizontal ? { transform: [{ translateX: resolvedPosition }] } : { transform: [{ translateY: resolvedPosition }] };
75
+ }, [horizontal, position, pushLimit, stickyStart]);
76
+ const viewStyle = React.useMemo(
77
+ () => [style, { zIndex: index + 1e3 }, stickyPositionStyle],
78
+ [index, stickyPositionStyle, style]
79
+ );
80
+ return /* @__PURE__ */ React.createElement(Reanimated.View, { ref: refView, style: viewStyle, ...rest }, /* @__PURE__ */ React.createElement(StickyOverlay, { stickyHeaderConfig }), children);
81
+ });
82
+ var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(props) {
83
+ const ctx = useStateContext();
84
+ const { id, horizontal, style, refView, children, recycleItems, layoutTransition, ...rest } = props;
85
+ const [positionValue = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
86
+ const prevItemKeyRef = React.useRef(void 0);
87
+ let shouldSkipTransitionForRecycleReuse = false;
88
+ if (recycleItems && layoutTransition) {
89
+ const itemKeySignal = `containerItemKey${id}`;
90
+ const itemKey = peek$(ctx, itemKeySignal);
91
+ shouldSkipTransitionForRecycleReuse = itemKey !== void 0 && prevItemKeyRef.current !== void 0 && prevItemKeyRef.current !== itemKey;
92
+ if (itemKey !== void 0) {
93
+ prevItemKeyRef.current = itemKey;
25
94
  }
26
- }, refs);
27
- return callback;
28
- };
29
-
30
- // src/integrations/reanimated.tsx
31
- var typedMemo = memo;
95
+ } else {
96
+ prevItemKeyRef.current = void 0;
97
+ }
98
+ const viewStyle = React.useMemo(
99
+ () => [style, horizontal ? { left: positionValue } : { top: positionValue }],
100
+ [horizontal, positionValue, style]
101
+ );
102
+ return /* @__PURE__ */ React.createElement(
103
+ Reanimated.View,
104
+ {
105
+ layout: shouldSkipTransitionForRecycleReuse ? void 0 : layoutTransition,
106
+ ref: refView,
107
+ style: viewStyle,
108
+ ...rest
109
+ },
110
+ children
111
+ );
112
+ });
113
+ function setSharedValueValue(sharedValue, value) {
114
+ if (!sharedValue) {
115
+ return;
116
+ }
117
+ const sharedValueWithMethods = sharedValue;
118
+ if (typeof sharedValueWithMethods.set === "function") {
119
+ sharedValueWithMethods.set(value);
120
+ } else {
121
+ sharedValueWithMethods.value = value;
122
+ }
123
+ }
124
+ function useAnimatedLegendListSharedValuesSync(legendList, sharedValues) {
125
+ React.useEffect(() => {
126
+ if (!legendList || !sharedValues) {
127
+ return;
128
+ }
129
+ const state = legendList.getState();
130
+ setSharedValueValue(sharedValues.activeStickyIndex, state.activeStickyIndex);
131
+ setSharedValueValue(sharedValues.isAtEnd, state.isAtEnd);
132
+ setSharedValueValue(sharedValues.isAtStart, state.isAtStart);
133
+ setSharedValueValue(sharedValues.isNearEnd, state.isNearEnd);
134
+ setSharedValueValue(sharedValues.isNearStart, state.isNearStart);
135
+ setSharedValueValue(
136
+ sharedValues.isWithinMaintainScrollAtEndThreshold,
137
+ state.isWithinMaintainScrollAtEndThreshold
138
+ );
139
+ setSharedValueValue(sharedValues.scrollOffset, state.scroll);
140
+ const unsubscribers = [
141
+ sharedValues.activeStickyIndex ? state.listen(
142
+ "activeStickyIndex",
143
+ (value) => setSharedValueValue(sharedValues.activeStickyIndex, value)
144
+ ) : void 0,
145
+ sharedValues.isAtEnd ? state.listen("isAtEnd", (value) => setSharedValueValue(sharedValues.isAtEnd, value)) : void 0,
146
+ sharedValues.isAtStart ? state.listen("isAtStart", (value) => setSharedValueValue(sharedValues.isAtStart, value)) : void 0,
147
+ sharedValues.isNearEnd ? state.listen("isNearEnd", (value) => setSharedValueValue(sharedValues.isNearEnd, value)) : void 0,
148
+ sharedValues.isNearStart ? state.listen("isNearStart", (value) => setSharedValueValue(sharedValues.isNearStart, value)) : void 0,
149
+ sharedValues.isWithinMaintainScrollAtEndThreshold ? state.listen(
150
+ "isWithinMaintainScrollAtEndThreshold",
151
+ (value) => setSharedValueValue(sharedValues.isWithinMaintainScrollAtEndThreshold, value)
152
+ ) : void 0
153
+ ];
154
+ return () => {
155
+ for (const unsubscribe of unsubscribers) {
156
+ unsubscribe == null ? void 0 : unsubscribe();
157
+ }
158
+ };
159
+ }, [legendList, sharedValues]);
160
+ }
32
161
  var LegendListForwardedRef = typedMemo(
33
162
  // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
34
163
  React.forwardRef(function LegendListForwardedRef2(props, ref) {
35
- const { refLegendList, ...rest } = props;
164
+ var _a;
165
+ const { itemLayoutAnimation, recycleItems, refLegendList, renderScrollComponent, sharedValues, ...rest } = props;
36
166
  const refFn = useCallback(
37
167
  (r) => {
38
168
  refLegendList(r);
39
169
  },
40
170
  [refLegendList]
41
171
  );
42
- return /* @__PURE__ */ React.createElement(LegendList, { ref: refFn, refScrollView: ref, ...rest });
172
+ const internalScrollOffset = useSharedValue(0);
173
+ const scrollOffset = (_a = sharedValues == null ? void 0 : sharedValues.scrollOffset) != null ? _a : internalScrollOffset;
174
+ const renderScrollComponentForBridge = React.useMemo(
175
+ () => renderScrollComponent ? (scrollViewProps) => renderScrollComponent(scrollViewProps) : void 0,
176
+ [renderScrollComponent]
177
+ );
178
+ const renderReanimatedScrollComponent = useCallback(
179
+ (scrollViewProps) => {
180
+ const { ref: forwardedRef, ...restScrollViewProps } = scrollViewProps;
181
+ return /* @__PURE__ */ React.createElement(
182
+ ReanimatedScrollBridge,
183
+ {
184
+ ...restScrollViewProps,
185
+ forwardedRef,
186
+ renderScrollComponent: renderScrollComponentForBridge,
187
+ scrollOffset
188
+ }
189
+ );
190
+ },
191
+ [renderScrollComponentForBridge, scrollOffset]
192
+ );
193
+ const stickyPositionComponentInternal = React.useMemo(
194
+ () => function StickyPositionComponent(stickyProps) {
195
+ return /* @__PURE__ */ React.createElement(ReanimatedPositionViewSticky, { ...stickyProps, stickyScrollOffset: scrollOffset });
196
+ },
197
+ [scrollOffset]
198
+ );
199
+ const itemLayoutAnimationRef = useLatestRef(itemLayoutAnimation);
200
+ const hasItemLayoutAnimation = !!itemLayoutAnimation;
201
+ const positionComponentInternal = React.useMemo(() => {
202
+ if (!hasItemLayoutAnimation) {
203
+ return void 0;
204
+ }
205
+ return function PositionComponent(positionProps) {
206
+ return /* @__PURE__ */ React.createElement(
207
+ ReanimatedPositionView,
208
+ {
209
+ ...positionProps,
210
+ layoutTransition: itemLayoutAnimationRef.current,
211
+ recycleItems
212
+ }
213
+ );
214
+ };
215
+ }, [hasItemLayoutAnimation, recycleItems]);
216
+ const legendListProps = {
217
+ ...rest,
218
+ positionComponentInternal,
219
+ recycleItems,
220
+ ...{
221
+ renderScrollComponent: renderReanimatedScrollComponent,
222
+ ...IsNewArchitecture ? { stickyPositionComponentInternal } : {}
223
+ }
224
+ };
225
+ return /* @__PURE__ */ React.createElement(LegendList, { ref: refFn, refScrollView: ref, ...legendListProps });
43
226
  })
44
227
  );
45
228
  var AnimatedLegendListComponent = Reanimated.createAnimatedComponent(LegendListForwardedRef);
229
+ var AnimatedLegendListComponentTyped = AnimatedLegendListComponent;
46
230
  var AnimatedLegendList = typedMemo(
47
231
  // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
48
232
  React.forwardRef(function AnimatedLegendList2(props, ref) {
49
233
  const { refScrollView, ...rest } = props;
50
- const refLegendList = React.useRef(null);
51
- const combinedRef = useCombinedRef(refLegendList, ref);
52
- return /* @__PURE__ */ React.createElement(AnimatedLegendListComponent, { ref: refScrollView, refLegendList: combinedRef, ...rest });
234
+ const { animatedProps, sharedValues } = props;
235
+ const [legendList, setLegendList] = React.useState(null);
236
+ const combinedRef = useCombinedRef(
237
+ React.useCallback((instance) => {
238
+ setLegendList((prev) => prev === instance ? prev : instance);
239
+ }, []),
240
+ ref
241
+ );
242
+ useAnimatedLegendListSharedValuesSync(legendList, sharedValues);
243
+ const forwardedProps = {
244
+ ...rest,
245
+ animatedPropsInternal: animatedProps,
246
+ refLegendList: combinedRef
247
+ };
248
+ return /* @__PURE__ */ React.createElement(AnimatedLegendListComponentTyped, { ...forwardedProps, ref: refScrollView });
53
249
  })
54
250
  );
55
251