@legendapp/list 3.0.0-beta.5 → 3.0.0-beta.50

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