@legendapp/list 3.0.0-beta.4 → 3.0.0-beta.41

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 +19 -0
  3. package/README.md +9 -2
  4. package/animated.d.ts +620 -5
  5. package/animated.js +2 -2
  6. package/animated.mjs +1 -1
  7. package/index.d.ts +1227 -11
  8. package/index.js +2594 -1023
  9. package/index.mjs +2593 -1024
  10. package/index.native.js +2347 -961
  11. package/index.native.mjs +2327 -943
  12. package/keyboard-test.d.ts +206 -0
  13. package/keyboard-test.js +34 -0
  14. package/keyboard-test.mjs +13 -0
  15. package/keyboard.d.ts +206 -8
  16. package/keyboard.js +340 -32
  17. package/keyboard.mjs +343 -34
  18. package/package.json +62 -1
  19. package/{types-JPHClxiw.d.mts → react-native.d.ts} +436 -158
  20. package/react-native.js +4942 -0
  21. package/react-native.mjs +4911 -0
  22. package/{types-JPHClxiw.d.ts → react-native.web.d.ts} +493 -158
  23. package/react-native.web.js +5357 -0
  24. package/react-native.web.mjs +5326 -0
  25. package/{types-YNdphn_A.d.mts → react.d.ts} +493 -158
  26. package/react.js +5357 -0
  27. package/react.mjs +5326 -0
  28. package/reanimated.d.ts +631 -7
  29. package/reanimated.js +156 -30
  30. package/reanimated.mjs +155 -29
  31. package/section-list.d.ts +620 -5
  32. package/section-list.js +38 -3679
  33. package/section-list.mjs +34 -3676
  34. package/animated.d.mts +0 -9
  35. package/index.d.mts +0 -23
  36. package/index.native.d.mts +0 -23
  37. package/index.native.d.ts +0 -23
  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 -3700
  48. package/section-list.native.mjs +0 -3679
  49. package/types-YNdphn_A.d.ts +0 -670
package/reanimated.js CHANGED
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
- var Animated = require('react-native-reanimated');
5
- var list = require('@legendapp/list');
4
+ var reactNative$1 = require('react-native');
5
+ var Reanimated = require('react-native-reanimated');
6
+ var reactNative = require('@legendapp/list/react-native');
6
7
 
7
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
9
 
@@ -25,53 +26,178 @@ function _interopNamespace(e) {
25
26
  }
26
27
 
27
28
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
- var Animated__default = /*#__PURE__*/_interopDefault(Animated);
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 { POSITION_OUT_OF_VIEW, IsNewArchitecture, useArr$, useCombinedRef, getComponent } = reactNative.internal;
33
+ var { peek$, useStateContext } = reactNative.internal;
34
+ var typedMemo = React.memo;
35
+ var ReanimatedScrollBridge = typedMemo(function ReanimatedScrollBridgeComponent({
36
+ forwardedRef,
37
+ scrollOffset,
38
+ renderScrollComponent,
39
+ ...props
40
+ }) {
41
+ const animatedScrollRef = Reanimated.useAnimatedRef();
42
+ Reanimated.useScrollViewOffset(animatedScrollRef, scrollOffset);
43
+ const combinedRef = useCombinedRef(animatedScrollRef, forwardedRef);
44
+ const ScrollComponent = React__namespace.useMemo(
45
+ () => renderScrollComponent ? React__namespace.forwardRef(
46
+ (scrollViewProps, ref) => renderScrollComponent({ ...scrollViewProps, ref })
47
+ ) : Reanimated__default.default.ScrollView,
48
+ [renderScrollComponent]
49
+ );
50
+ return /* @__PURE__ */ React__namespace.createElement(ScrollComponent, { ...props, ref: combinedRef });
51
+ });
52
+ var StickyOverlay = typedMemo(function StickyOverlayComponent({ stickyHeaderConfig }) {
53
+ if (!(stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent)) {
54
+ return null;
55
+ }
56
+ return /* @__PURE__ */ React__namespace.createElement(
57
+ reactNative$1.View,
58
+ {
59
+ style: {
60
+ inset: 0,
61
+ pointerEvents: "none",
62
+ position: "absolute"
48
63
  }
64
+ },
65
+ getComponent(stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent)
66
+ );
67
+ });
68
+ var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStickyComponent(props) {
69
+ var _a;
70
+ const { id, horizontal, style, refView, stickyScrollOffset, stickyHeaderConfig, index, children, ...rest } = props;
71
+ const [position = POSITION_OUT_OF_VIEW, headerSize = 0, stylePaddingTop = 0] = useArr$([
72
+ `containerPosition${id}`,
73
+ "headerSize",
74
+ "stylePaddingTop"
75
+ ]);
76
+ const stickyOffset = (_a = stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.offset) != null ? _a : 0;
77
+ const stickyStart = position + headerSize + stylePaddingTop - stickyOffset;
78
+ const transformStyle = Reanimated.useAnimatedStyle(() => {
79
+ const delta = Math.max(0, stickyScrollOffset.value - stickyStart);
80
+ return horizontal ? { transform: [{ translateX: position + delta }] } : { transform: [{ translateY: position + delta }] };
81
+ }, [horizontal, position, stickyStart]);
82
+ const viewStyle = React__namespace.useMemo(
83
+ () => [style, { zIndex: index + 1e3 }, transformStyle],
84
+ [index, style, transformStyle]
85
+ );
86
+ return /* @__PURE__ */ React__namespace.createElement(Reanimated__default.default.View, { ref: refView, style: viewStyle, ...rest }, /* @__PURE__ */ React__namespace.createElement(StickyOverlay, { stickyHeaderConfig }), children);
87
+ });
88
+ var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(props) {
89
+ const ctx = useStateContext();
90
+ const { id, horizontal, style, refView, children, recycleItems, layoutTransition, ...rest } = props;
91
+ const [positionValue = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
92
+ const prevItemKeyRef = React__namespace.useRef(void 0);
93
+ let shouldSkipTransitionForRecycleReuse = false;
94
+ if (recycleItems && layoutTransition) {
95
+ const itemKeySignal = `containerItemKey${id}`;
96
+ const itemKey = peek$(ctx, itemKeySignal);
97
+ shouldSkipTransitionForRecycleReuse = itemKey !== void 0 && prevItemKeyRef.current !== void 0 && prevItemKeyRef.current !== itemKey;
98
+ if (itemKey !== void 0) {
99
+ prevItemKeyRef.current = itemKey;
49
100
  }
50
- }, refs);
51
- return callback;
52
- };
53
-
54
- // src/integrations/reanimated.tsx
55
- var typedMemo = React.memo;
101
+ } else {
102
+ prevItemKeyRef.current = void 0;
103
+ }
104
+ const viewStyle = React__namespace.useMemo(
105
+ () => [style, horizontal ? { left: positionValue } : { top: positionValue }],
106
+ [horizontal, positionValue, style]
107
+ );
108
+ return /* @__PURE__ */ React__namespace.createElement(
109
+ Reanimated__default.default.View,
110
+ {
111
+ layout: shouldSkipTransitionForRecycleReuse ? void 0 : layoutTransition,
112
+ ref: refView,
113
+ style: viewStyle,
114
+ ...rest
115
+ },
116
+ children
117
+ );
118
+ });
56
119
  var LegendListForwardedRef = typedMemo(
120
+ // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
57
121
  React__namespace.forwardRef(function LegendListForwardedRef2(props, ref) {
58
- const { refLegendList, ...rest } = props;
122
+ const { itemLayoutAnimation, recycleItems, refLegendList, renderScrollComponent, ...rest } = props;
59
123
  const refFn = React.useCallback(
60
124
  (r) => {
61
125
  refLegendList(r);
62
126
  },
63
127
  [refLegendList]
64
128
  );
65
- return /* @__PURE__ */ React__namespace.createElement(list.LegendList, { ref: refFn, refScrollView: ref, ...rest });
129
+ const stickyScrollOffset = Reanimated.useSharedValue(0);
130
+ const shouldUseReanimatedScrollView = IsNewArchitecture;
131
+ const renderScrollComponentForBridge = React__namespace.useMemo(
132
+ () => renderScrollComponent ? (scrollViewProps) => renderScrollComponent(scrollViewProps) : void 0,
133
+ [renderScrollComponent]
134
+ );
135
+ const renderReanimatedScrollComponent = React.useCallback(
136
+ (scrollViewProps) => {
137
+ const { ref: forwardedRef, ...restScrollViewProps } = scrollViewProps;
138
+ return /* @__PURE__ */ React__namespace.createElement(
139
+ ReanimatedScrollBridge,
140
+ {
141
+ ...restScrollViewProps,
142
+ forwardedRef,
143
+ renderScrollComponent: renderScrollComponentForBridge,
144
+ scrollOffset: stickyScrollOffset
145
+ }
146
+ );
147
+ },
148
+ [renderScrollComponentForBridge, stickyScrollOffset]
149
+ );
150
+ const stickyPositionComponentInternal = React__namespace.useMemo(
151
+ () => function StickyPositionComponent(stickyProps) {
152
+ return /* @__PURE__ */ React__namespace.createElement(ReanimatedPositionViewSticky, { ...stickyProps, stickyScrollOffset });
153
+ },
154
+ [stickyScrollOffset]
155
+ );
156
+ const itemLayoutAnimationRef = React__namespace.useRef(itemLayoutAnimation);
157
+ itemLayoutAnimationRef.current = itemLayoutAnimation;
158
+ const hasItemLayoutAnimation = !!itemLayoutAnimation;
159
+ const positionComponentInternal = React__namespace.useMemo(() => {
160
+ if (!hasItemLayoutAnimation) {
161
+ return void 0;
162
+ }
163
+ return function PositionComponent(positionProps) {
164
+ return /* @__PURE__ */ React__namespace.createElement(
165
+ ReanimatedPositionView,
166
+ {
167
+ ...positionProps,
168
+ layoutTransition: itemLayoutAnimationRef.current,
169
+ recycleItems
170
+ }
171
+ );
172
+ };
173
+ }, [hasItemLayoutAnimation, recycleItems]);
174
+ const legendListProps = {
175
+ ...rest,
176
+ positionComponentInternal,
177
+ recycleItems,
178
+ ...shouldUseReanimatedScrollView ? {
179
+ renderScrollComponent: renderReanimatedScrollComponent,
180
+ stickyPositionComponentInternal
181
+ } : {}
182
+ };
183
+ return /* @__PURE__ */ React__namespace.createElement(reactNative.LegendList, { ref: refFn, refScrollView: ref, ...legendListProps });
66
184
  })
67
185
  );
68
- var AnimatedLegendListComponent = Animated__default.default.createAnimatedComponent(LegendListForwardedRef);
186
+ var AnimatedLegendListComponent = Reanimated__default.default.createAnimatedComponent(LegendListForwardedRef);
187
+ var AnimatedLegendListComponentTyped = AnimatedLegendListComponent;
69
188
  var AnimatedLegendList = typedMemo(
189
+ // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
70
190
  React__namespace.forwardRef(function AnimatedLegendList2(props, ref) {
71
191
  const { refScrollView, ...rest } = props;
192
+ const { animatedProps } = props;
72
193
  const refLegendList = React__namespace.useRef(null);
73
194
  const combinedRef = useCombinedRef(refLegendList, ref);
74
- return /* @__PURE__ */ React__namespace.createElement(AnimatedLegendListComponent, { ref: refScrollView, refLegendList: combinedRef, ...rest });
195
+ const forwardedProps = {
196
+ ...rest,
197
+ animatedPropsInternal: animatedProps,
198
+ refLegendList: combinedRef
199
+ };
200
+ return /* @__PURE__ */ React__namespace.createElement(AnimatedLegendListComponentTyped, { ...forwardedProps, ref: refScrollView });
75
201
  })
76
202
  );
77
203
 
package/reanimated.mjs CHANGED
@@ -1,53 +1,179 @@
1
1
  import * as React from 'react';
2
2
  import { useCallback, memo } from 'react';
3
- import Animated from 'react-native-reanimated';
4
- import { LegendList } from '@legendapp/list';
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 { POSITION_OUT_OF_VIEW, IsNewArchitecture, useArr$, useCombinedRef, getComponent } = internal;
9
+ var { peek$, useStateContext } = internal;
10
+ var typedMemo = memo;
11
+ var ReanimatedScrollBridge = typedMemo(function ReanimatedScrollBridgeComponent({
12
+ forwardedRef,
13
+ scrollOffset,
14
+ renderScrollComponent,
15
+ ...props
16
+ }) {
17
+ const animatedScrollRef = useAnimatedRef();
18
+ useScrollViewOffset(animatedScrollRef, scrollOffset);
19
+ const combinedRef = useCombinedRef(animatedScrollRef, forwardedRef);
20
+ const ScrollComponent = React.useMemo(
21
+ () => renderScrollComponent ? React.forwardRef(
22
+ (scrollViewProps, ref) => renderScrollComponent({ ...scrollViewProps, ref })
23
+ ) : Reanimated.ScrollView,
24
+ [renderScrollComponent]
25
+ );
26
+ return /* @__PURE__ */ React.createElement(ScrollComponent, { ...props, ref: combinedRef });
27
+ });
28
+ var StickyOverlay = typedMemo(function StickyOverlayComponent({ stickyHeaderConfig }) {
29
+ if (!(stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent)) {
30
+ return null;
31
+ }
32
+ return /* @__PURE__ */ React.createElement(
33
+ View,
34
+ {
35
+ style: {
36
+ inset: 0,
37
+ pointerEvents: "none",
38
+ position: "absolute"
24
39
  }
40
+ },
41
+ getComponent(stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent)
42
+ );
43
+ });
44
+ var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStickyComponent(props) {
45
+ var _a;
46
+ const { id, horizontal, style, refView, stickyScrollOffset, stickyHeaderConfig, index, children, ...rest } = props;
47
+ const [position = POSITION_OUT_OF_VIEW, headerSize = 0, stylePaddingTop = 0] = useArr$([
48
+ `containerPosition${id}`,
49
+ "headerSize",
50
+ "stylePaddingTop"
51
+ ]);
52
+ const stickyOffset = (_a = stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.offset) != null ? _a : 0;
53
+ const stickyStart = position + headerSize + stylePaddingTop - stickyOffset;
54
+ const transformStyle = useAnimatedStyle(() => {
55
+ const delta = Math.max(0, stickyScrollOffset.value - stickyStart);
56
+ return horizontal ? { transform: [{ translateX: position + delta }] } : { transform: [{ translateY: position + delta }] };
57
+ }, [horizontal, position, stickyStart]);
58
+ const viewStyle = React.useMemo(
59
+ () => [style, { zIndex: index + 1e3 }, transformStyle],
60
+ [index, style, transformStyle]
61
+ );
62
+ return /* @__PURE__ */ React.createElement(Reanimated.View, { ref: refView, style: viewStyle, ...rest }, /* @__PURE__ */ React.createElement(StickyOverlay, { stickyHeaderConfig }), children);
63
+ });
64
+ var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(props) {
65
+ const ctx = useStateContext();
66
+ const { id, horizontal, style, refView, children, recycleItems, layoutTransition, ...rest } = props;
67
+ const [positionValue = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
68
+ const prevItemKeyRef = React.useRef(void 0);
69
+ let shouldSkipTransitionForRecycleReuse = false;
70
+ if (recycleItems && layoutTransition) {
71
+ const itemKeySignal = `containerItemKey${id}`;
72
+ const itemKey = peek$(ctx, itemKeySignal);
73
+ shouldSkipTransitionForRecycleReuse = itemKey !== void 0 && prevItemKeyRef.current !== void 0 && prevItemKeyRef.current !== itemKey;
74
+ if (itemKey !== void 0) {
75
+ prevItemKeyRef.current = itemKey;
25
76
  }
26
- }, refs);
27
- return callback;
28
- };
29
-
30
- // src/integrations/reanimated.tsx
31
- var typedMemo = memo;
77
+ } else {
78
+ prevItemKeyRef.current = void 0;
79
+ }
80
+ const viewStyle = React.useMemo(
81
+ () => [style, horizontal ? { left: positionValue } : { top: positionValue }],
82
+ [horizontal, positionValue, style]
83
+ );
84
+ return /* @__PURE__ */ React.createElement(
85
+ Reanimated.View,
86
+ {
87
+ layout: shouldSkipTransitionForRecycleReuse ? void 0 : layoutTransition,
88
+ ref: refView,
89
+ style: viewStyle,
90
+ ...rest
91
+ },
92
+ children
93
+ );
94
+ });
32
95
  var LegendListForwardedRef = typedMemo(
96
+ // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
33
97
  React.forwardRef(function LegendListForwardedRef2(props, ref) {
34
- const { refLegendList, ...rest } = props;
98
+ const { itemLayoutAnimation, recycleItems, refLegendList, renderScrollComponent, ...rest } = props;
35
99
  const refFn = useCallback(
36
100
  (r) => {
37
101
  refLegendList(r);
38
102
  },
39
103
  [refLegendList]
40
104
  );
41
- return /* @__PURE__ */ React.createElement(LegendList, { ref: refFn, refScrollView: ref, ...rest });
105
+ const stickyScrollOffset = useSharedValue(0);
106
+ const shouldUseReanimatedScrollView = IsNewArchitecture;
107
+ const renderScrollComponentForBridge = React.useMemo(
108
+ () => renderScrollComponent ? (scrollViewProps) => renderScrollComponent(scrollViewProps) : void 0,
109
+ [renderScrollComponent]
110
+ );
111
+ const renderReanimatedScrollComponent = useCallback(
112
+ (scrollViewProps) => {
113
+ const { ref: forwardedRef, ...restScrollViewProps } = scrollViewProps;
114
+ return /* @__PURE__ */ React.createElement(
115
+ ReanimatedScrollBridge,
116
+ {
117
+ ...restScrollViewProps,
118
+ forwardedRef,
119
+ renderScrollComponent: renderScrollComponentForBridge,
120
+ scrollOffset: stickyScrollOffset
121
+ }
122
+ );
123
+ },
124
+ [renderScrollComponentForBridge, stickyScrollOffset]
125
+ );
126
+ const stickyPositionComponentInternal = React.useMemo(
127
+ () => function StickyPositionComponent(stickyProps) {
128
+ return /* @__PURE__ */ React.createElement(ReanimatedPositionViewSticky, { ...stickyProps, stickyScrollOffset });
129
+ },
130
+ [stickyScrollOffset]
131
+ );
132
+ const itemLayoutAnimationRef = React.useRef(itemLayoutAnimation);
133
+ itemLayoutAnimationRef.current = itemLayoutAnimation;
134
+ const hasItemLayoutAnimation = !!itemLayoutAnimation;
135
+ const positionComponentInternal = React.useMemo(() => {
136
+ if (!hasItemLayoutAnimation) {
137
+ return void 0;
138
+ }
139
+ return function PositionComponent(positionProps) {
140
+ return /* @__PURE__ */ React.createElement(
141
+ ReanimatedPositionView,
142
+ {
143
+ ...positionProps,
144
+ layoutTransition: itemLayoutAnimationRef.current,
145
+ recycleItems
146
+ }
147
+ );
148
+ };
149
+ }, [hasItemLayoutAnimation, recycleItems]);
150
+ const legendListProps = {
151
+ ...rest,
152
+ positionComponentInternal,
153
+ recycleItems,
154
+ ...shouldUseReanimatedScrollView ? {
155
+ renderScrollComponent: renderReanimatedScrollComponent,
156
+ stickyPositionComponentInternal
157
+ } : {}
158
+ };
159
+ return /* @__PURE__ */ React.createElement(LegendList, { ref: refFn, refScrollView: ref, ...legendListProps });
42
160
  })
43
161
  );
44
- var AnimatedLegendListComponent = Animated.createAnimatedComponent(LegendListForwardedRef);
162
+ var AnimatedLegendListComponent = Reanimated.createAnimatedComponent(LegendListForwardedRef);
163
+ var AnimatedLegendListComponentTyped = AnimatedLegendListComponent;
45
164
  var AnimatedLegendList = typedMemo(
165
+ // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
46
166
  React.forwardRef(function AnimatedLegendList2(props, ref) {
47
167
  const { refScrollView, ...rest } = props;
168
+ const { animatedProps } = props;
48
169
  const refLegendList = React.useRef(null);
49
170
  const combinedRef = useCombinedRef(refLegendList, ref);
50
- return /* @__PURE__ */ React.createElement(AnimatedLegendListComponent, { ref: refScrollView, refLegendList: combinedRef, ...rest });
171
+ const forwardedProps = {
172
+ ...rest,
173
+ animatedPropsInternal: animatedProps,
174
+ refLegendList: combinedRef
175
+ };
176
+ return /* @__PURE__ */ React.createElement(AnimatedLegendListComponentTyped, { ...forwardedProps, ref: refScrollView });
51
177
  })
52
178
  );
53
179