@legendapp/list 3.0.0-beta.2 → 3.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +1 -0
- package/animated.native.d.mts +9 -0
- package/animated.native.d.ts +9 -0
- package/animated.native.js +9 -0
- package/animated.native.mjs +7 -0
- package/index.d.mts +781 -10
- package/index.d.ts +781 -10
- package/index.js +973 -530
- package/index.mjs +973 -532
- package/index.native.d.mts +781 -10
- package/index.native.d.ts +781 -10
- package/index.native.js +981 -494
- package/index.native.mjs +980 -495
- package/keyboard-controller.native.d.mts +12 -0
- package/keyboard-controller.native.d.ts +12 -0
- package/keyboard-controller.native.js +69 -0
- package/keyboard-controller.native.mjs +48 -0
- package/keyboard.d.mts +5 -2
- package/keyboard.d.ts +5 -2
- package/keyboard.js +232 -28
- package/keyboard.mjs +235 -31
- package/keyboard.native.d.mts +16 -0
- package/keyboard.native.d.ts +16 -0
- package/keyboard.native.js +318 -0
- package/keyboard.native.mjs +296 -0
- package/package.json +1 -1
- package/reanimated.d.mts +3 -3
- package/reanimated.d.ts +3 -3
- package/reanimated.js +15 -4
- package/reanimated.mjs +14 -3
- package/reanimated.native.d.mts +18 -0
- package/reanimated.native.d.ts +18 -0
- package/reanimated.native.js +89 -0
- package/reanimated.native.mjs +65 -0
- package/section-list.d.mts +1 -2
- package/section-list.d.ts +1 -2
- package/section-list.js +36 -3670
- package/section-list.mjs +34 -3669
- package/section-list.native.d.mts +1 -2
- package/section-list.native.d.ts +1 -2
- package/section-list.native.js +36 -3449
- package/section-list.native.mjs +33 -3447
- package/types-JPHClxiw.d.mts +0 -670
- package/types-JPHClxiw.d.ts +0 -670
- package/types-YNdphn_A.d.mts +0 -670
- package/types-YNdphn_A.d.ts +0 -670
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { forwardRef, useRef, useCallback } from 'react';
|
|
3
|
+
import { StyleSheet, Platform } from 'react-native';
|
|
4
|
+
import { useKeyboardHandler } from 'react-native-keyboard-controller';
|
|
5
|
+
import { useAnimatedRef, useSharedValue, useAnimatedScrollHandler, runOnJS, runOnUI, useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
|
|
6
|
+
import { AnimatedLegendList } from '@legendapp/list/reanimated';
|
|
7
|
+
|
|
8
|
+
// src/integrations/keyboard.tsx
|
|
9
|
+
|
|
10
|
+
// src/constants-platform.native.ts
|
|
11
|
+
var f = global.nativeFabricUIManager;
|
|
12
|
+
var IsNewArchitecture = f !== void 0 && f != null;
|
|
13
|
+
|
|
14
|
+
// src/utils/helpers.ts
|
|
15
|
+
function isFunction(obj) {
|
|
16
|
+
return typeof obj === "function";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/hooks/useCombinedRef.ts
|
|
20
|
+
var useCombinedRef = (...refs) => {
|
|
21
|
+
const callback = useCallback((element) => {
|
|
22
|
+
for (const ref of refs) {
|
|
23
|
+
if (!ref) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (isFunction(ref)) {
|
|
27
|
+
ref(element);
|
|
28
|
+
} else {
|
|
29
|
+
ref.current = element;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}, refs);
|
|
33
|
+
return callback;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// src/integrations/keyboard.tsx
|
|
37
|
+
var clampProgress = (progress) => {
|
|
38
|
+
"worklet";
|
|
39
|
+
return Math.min(1, Math.max(0, progress));
|
|
40
|
+
};
|
|
41
|
+
var calculateKeyboardInset = (height, safeAreaInsetBottom, isNewArchitecture) => {
|
|
42
|
+
"worklet";
|
|
43
|
+
return isNewArchitecture ? Math.max(0, height - safeAreaInsetBottom) : Math.max(isNewArchitecture ? 0 : -safeAreaInsetBottom, height - safeAreaInsetBottom * 2);
|
|
44
|
+
};
|
|
45
|
+
var calculateEndPaddingInset = (keyboardHeight, alignItemsAtEndPadding) => {
|
|
46
|
+
"worklet";
|
|
47
|
+
return Math.min(keyboardHeight, alignItemsAtEndPadding);
|
|
48
|
+
};
|
|
49
|
+
var calculateTopInset = (safeAreaInsetTop, isNewArchitecture, extraTopInset) => {
|
|
50
|
+
"worklet";
|
|
51
|
+
return (isNewArchitecture ? 0 : safeAreaInsetTop * 2) + extraTopInset;
|
|
52
|
+
};
|
|
53
|
+
var calculateKeyboardTargetOffset = (startOffset, keyboardHeight, isOpening, progress) => {
|
|
54
|
+
"worklet";
|
|
55
|
+
const normalizedProgress = isOpening ? progress : 1 - progress;
|
|
56
|
+
const delta = (isOpening ? keyboardHeight : -keyboardHeight) * normalizedProgress;
|
|
57
|
+
return Math.max(0, startOffset + delta);
|
|
58
|
+
};
|
|
59
|
+
var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
|
|
60
|
+
const {
|
|
61
|
+
contentInset: contentInsetProp,
|
|
62
|
+
horizontal,
|
|
63
|
+
onMetricsChange: onMetricsChangeProp,
|
|
64
|
+
onScroll: onScrollProp,
|
|
65
|
+
safeAreaInsets = { bottom: 0, top: 0 },
|
|
66
|
+
style: styleProp,
|
|
67
|
+
...rest
|
|
68
|
+
} = props;
|
|
69
|
+
const styleFlattened = StyleSheet.flatten(styleProp);
|
|
70
|
+
const refLegendList = useRef(null);
|
|
71
|
+
const combinedRef = useCombinedRef(forwardedRef, refLegendList);
|
|
72
|
+
const isIos = Platform.OS === "ios";
|
|
73
|
+
const isAndroid = Platform.OS === "android";
|
|
74
|
+
const scrollViewRef = useAnimatedRef();
|
|
75
|
+
const scrollOffsetY = useSharedValue(0);
|
|
76
|
+
const animatedOffsetY = useSharedValue(null);
|
|
77
|
+
const scrollOffsetAtKeyboardStart = useSharedValue(0);
|
|
78
|
+
const mode = useSharedValue("idle");
|
|
79
|
+
const keyboardInset = useSharedValue({ bottom: 0, top: 0 });
|
|
80
|
+
const keyboardHeight = useSharedValue(0);
|
|
81
|
+
const alignItemsAtEndPadding = useSharedValue(0);
|
|
82
|
+
const isOpening = useSharedValue(false);
|
|
83
|
+
const didInteractive = useSharedValue(false);
|
|
84
|
+
const { top: safeAreaInsetTop, bottom: safeAreaInsetBottom } = safeAreaInsets;
|
|
85
|
+
const isKeyboardOpen = useSharedValue(false);
|
|
86
|
+
const scrollHandler = useAnimatedScrollHandler(
|
|
87
|
+
(event) => {
|
|
88
|
+
scrollOffsetY.set(event.contentOffset[horizontal ? "x" : "y"]);
|
|
89
|
+
if (onScrollProp) {
|
|
90
|
+
runOnJS(onScrollProp)(event);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
[onScrollProp, horizontal]
|
|
94
|
+
);
|
|
95
|
+
const setScrollProcessingEnabled = useCallback(
|
|
96
|
+
(enabled) => {
|
|
97
|
+
var _a;
|
|
98
|
+
return (_a = refLegendList.current) == null ? void 0 : _a.setScrollProcessingEnabled(enabled);
|
|
99
|
+
},
|
|
100
|
+
[refLegendList]
|
|
101
|
+
);
|
|
102
|
+
const handleMetricsChange = useCallback(
|
|
103
|
+
(metrics) => {
|
|
104
|
+
const nextPadding = metrics.alignItemsAtEndPadding || 0;
|
|
105
|
+
alignItemsAtEndPadding.set(nextPadding);
|
|
106
|
+
if (!horizontal) {
|
|
107
|
+
runOnUI((padding, safeInsetTop, isNewArchitecture) => {
|
|
108
|
+
"worklet";
|
|
109
|
+
if (!isKeyboardOpen.get()) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const vKeyboardHeight = keyboardHeight.get();
|
|
113
|
+
const vTopInset = calculateEndPaddingInset(vKeyboardHeight, padding);
|
|
114
|
+
const topInset = calculateTopInset(safeInsetTop, isNewArchitecture, vTopInset);
|
|
115
|
+
keyboardInset.set({
|
|
116
|
+
bottom: keyboardInset.get().bottom,
|
|
117
|
+
top: topInset
|
|
118
|
+
});
|
|
119
|
+
})(nextPadding, safeAreaInsetTop, IsNewArchitecture);
|
|
120
|
+
}
|
|
121
|
+
onMetricsChangeProp == null ? void 0 : onMetricsChangeProp(metrics);
|
|
122
|
+
},
|
|
123
|
+
[
|
|
124
|
+
alignItemsAtEndPadding,
|
|
125
|
+
horizontal,
|
|
126
|
+
isKeyboardOpen,
|
|
127
|
+
keyboardHeight,
|
|
128
|
+
keyboardInset,
|
|
129
|
+
onMetricsChangeProp,
|
|
130
|
+
safeAreaInsetTop
|
|
131
|
+
]
|
|
132
|
+
);
|
|
133
|
+
useKeyboardHandler(
|
|
134
|
+
// biome-ignore assist/source/useSortedKeys: prefer start/move/end
|
|
135
|
+
{
|
|
136
|
+
onStart: (event) => {
|
|
137
|
+
"worklet";
|
|
138
|
+
mode.set("running");
|
|
139
|
+
const progress = clampProgress(event.progress);
|
|
140
|
+
if (isKeyboardOpen.get() && progress >= 1 && event.height > 0) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!didInteractive.get()) {
|
|
144
|
+
if (event.height > 0) {
|
|
145
|
+
keyboardHeight.set(event.height - safeAreaInsetBottom);
|
|
146
|
+
}
|
|
147
|
+
isOpening.set(progress > 0);
|
|
148
|
+
scrollOffsetAtKeyboardStart.set(scrollOffsetY.get());
|
|
149
|
+
animatedOffsetY.set(scrollOffsetY.get());
|
|
150
|
+
runOnJS(setScrollProcessingEnabled)(false);
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
onInteractive: (event) => {
|
|
154
|
+
"worklet";
|
|
155
|
+
if (mode.get() !== "running") {
|
|
156
|
+
runOnJS(setScrollProcessingEnabled)(false);
|
|
157
|
+
}
|
|
158
|
+
mode.set("running");
|
|
159
|
+
if (!didInteractive.get()) {
|
|
160
|
+
if (!isAndroid && !IsNewArchitecture) {
|
|
161
|
+
keyboardInset.set({
|
|
162
|
+
bottom: keyboardInset.get().bottom,
|
|
163
|
+
// Legacy iOS uses a doubled top inset to keep content below the status bar.
|
|
164
|
+
top: calculateTopInset(safeAreaInsetTop, IsNewArchitecture, 0)
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
didInteractive.set(true);
|
|
168
|
+
}
|
|
169
|
+
if (isAndroid && !horizontal) {
|
|
170
|
+
const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom, IsNewArchitecture);
|
|
171
|
+
keyboardInset.set({ bottom: newInset, top: safeAreaInsetTop * 2 });
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
onMove: (event) => {
|
|
175
|
+
"worklet";
|
|
176
|
+
if (!didInteractive.get()) {
|
|
177
|
+
const progress = clampProgress(event.progress);
|
|
178
|
+
const vIsOpening = isOpening.get();
|
|
179
|
+
const vKeyboardHeight = keyboardHeight.get();
|
|
180
|
+
const vAlignItemsPadding = alignItemsAtEndPadding.get();
|
|
181
|
+
const vTopInset = calculateEndPaddingInset(vKeyboardHeight, vAlignItemsPadding);
|
|
182
|
+
const targetOffset = calculateKeyboardTargetOffset(
|
|
183
|
+
scrollOffsetAtKeyboardStart.get(),
|
|
184
|
+
vKeyboardHeight,
|
|
185
|
+
vIsOpening,
|
|
186
|
+
progress
|
|
187
|
+
);
|
|
188
|
+
scrollOffsetY.set(targetOffset);
|
|
189
|
+
animatedOffsetY.set(targetOffset);
|
|
190
|
+
if (!horizontal) {
|
|
191
|
+
const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom, IsNewArchitecture);
|
|
192
|
+
const topInset = calculateTopInset(
|
|
193
|
+
safeAreaInsetTop,
|
|
194
|
+
IsNewArchitecture,
|
|
195
|
+
vIsOpening ? vTopInset : 0
|
|
196
|
+
);
|
|
197
|
+
keyboardInset.set({
|
|
198
|
+
bottom: newInset,
|
|
199
|
+
// Add top padding only while opening to keep end-aligned items visible.
|
|
200
|
+
top: topInset
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
onEnd: (event) => {
|
|
206
|
+
"worklet";
|
|
207
|
+
const wasInteractive = didInteractive.get();
|
|
208
|
+
const vMode = mode.get();
|
|
209
|
+
mode.set("idle");
|
|
210
|
+
if (vMode === "running") {
|
|
211
|
+
const progress = clampProgress(event.progress);
|
|
212
|
+
const vKeyboardHeight = keyboardHeight.get();
|
|
213
|
+
const vAlignItemsPadding = alignItemsAtEndPadding.get();
|
|
214
|
+
const vTopInset = calculateEndPaddingInset(vKeyboardHeight, vAlignItemsPadding);
|
|
215
|
+
const vIsOpening = isOpening.get();
|
|
216
|
+
if (!wasInteractive) {
|
|
217
|
+
const targetOffset = calculateKeyboardTargetOffset(
|
|
218
|
+
scrollOffsetAtKeyboardStart.get(),
|
|
219
|
+
vKeyboardHeight,
|
|
220
|
+
vIsOpening,
|
|
221
|
+
progress
|
|
222
|
+
);
|
|
223
|
+
scrollOffsetY.set(targetOffset);
|
|
224
|
+
animatedOffsetY.set(targetOffset);
|
|
225
|
+
}
|
|
226
|
+
runOnJS(setScrollProcessingEnabled)(true);
|
|
227
|
+
didInteractive.set(false);
|
|
228
|
+
isKeyboardOpen.set(event.height > 0);
|
|
229
|
+
if (!horizontal) {
|
|
230
|
+
const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom, IsNewArchitecture);
|
|
231
|
+
const topInset = calculateTopInset(
|
|
232
|
+
safeAreaInsetTop,
|
|
233
|
+
IsNewArchitecture,
|
|
234
|
+
event.height > 0 ? vTopInset : 0
|
|
235
|
+
);
|
|
236
|
+
keyboardInset.set({
|
|
237
|
+
bottom: newInset,
|
|
238
|
+
// Preserve end-aligned padding only while the keyboard is visible.
|
|
239
|
+
top: topInset
|
|
240
|
+
});
|
|
241
|
+
if (newInset <= 0) {
|
|
242
|
+
animatedOffsetY.set(scrollOffsetY.get());
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
[scrollViewRef, safeAreaInsetBottom]
|
|
249
|
+
);
|
|
250
|
+
const animatedProps = useAnimatedProps(() => {
|
|
251
|
+
"worklet";
|
|
252
|
+
var _a, _b, _c, _d;
|
|
253
|
+
const vAnimatedOffsetY = animatedOffsetY.get();
|
|
254
|
+
const baseProps = {
|
|
255
|
+
contentOffset: vAnimatedOffsetY === null ? void 0 : {
|
|
256
|
+
x: 0,
|
|
257
|
+
y: vAnimatedOffsetY
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const { top: keyboardInsetTop, bottom: keyboardInsetBottom } = keyboardInset.get();
|
|
261
|
+
return isIos ? Object.assign(baseProps, {
|
|
262
|
+
contentInset: {
|
|
263
|
+
bottom: ((_a = contentInsetProp == null ? void 0 : contentInsetProp.bottom) != null ? _a : 0) + (horizontal ? 0 : keyboardInsetBottom),
|
|
264
|
+
left: (_b = contentInsetProp == null ? void 0 : contentInsetProp.left) != null ? _b : 0,
|
|
265
|
+
right: (_c = contentInsetProp == null ? void 0 : contentInsetProp.right) != null ? _c : 0,
|
|
266
|
+
top: ((_d = contentInsetProp == null ? void 0 : contentInsetProp.top) != null ? _d : 0) - keyboardInsetTop
|
|
267
|
+
}
|
|
268
|
+
}) : baseProps;
|
|
269
|
+
});
|
|
270
|
+
const style = isAndroid ? useAnimatedStyle(
|
|
271
|
+
() => {
|
|
272
|
+
var _a;
|
|
273
|
+
return {
|
|
274
|
+
...styleFlattened || {},
|
|
275
|
+
marginBottom: (_a = keyboardInset.get().bottom) != null ? _a : 0
|
|
276
|
+
};
|
|
277
|
+
},
|
|
278
|
+
[styleProp, keyboardInset]
|
|
279
|
+
) : void 0;
|
|
280
|
+
return /* @__PURE__ */ React.createElement(
|
|
281
|
+
AnimatedLegendList,
|
|
282
|
+
{
|
|
283
|
+
...rest,
|
|
284
|
+
animatedProps,
|
|
285
|
+
keyboardDismissMode: "interactive",
|
|
286
|
+
onMetricsChange: handleMetricsChange,
|
|
287
|
+
onScroll: scrollHandler,
|
|
288
|
+
ref: combinedRef,
|
|
289
|
+
refScrollView: scrollViewRef,
|
|
290
|
+
scrollIndicatorInsets: { bottom: 0, top: 0 },
|
|
291
|
+
style
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
export { KeyboardAvoidingLegendList, KeyboardAvoidingLegendList as LegendList };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/list",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.21",
|
|
4
4
|
"description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"private": false,
|
package/reanimated.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ComponentProps } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import Reanimated from 'react-native-reanimated';
|
|
4
4
|
import { LegendListPropsBase, LegendListRef } from '@legendapp/list';
|
|
5
5
|
|
|
6
6
|
type KeysToOmit = "getEstimatedItemSize" | "getFixedItemSize" | "getItemType" | "keyExtractor" | "animatedProps" | "renderItem" | "onItemSizeChanged" | "itemsAreEqual" | "ItemSeparatorComponent";
|
|
7
|
-
type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof
|
|
7
|
+
type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof Reanimated.ScrollView>>;
|
|
8
8
|
interface AnimatedLegendListPropsBase<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit> {
|
|
9
|
-
refScrollView?: React.Ref<
|
|
9
|
+
refScrollView?: React.Ref<Reanimated.ScrollView>;
|
|
10
10
|
}
|
|
11
11
|
type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
|
|
12
12
|
type AnimatedLegendListProps<ItemT> = Omit<AnimatedLegendListPropsBase<ItemT>, "refLegendList" | "ref"> & OtherAnimatedLegendListProps<ItemT>;
|
package/reanimated.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ComponentProps } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import Reanimated from 'react-native-reanimated';
|
|
4
4
|
import { LegendListPropsBase, LegendListRef } from '@legendapp/list';
|
|
5
5
|
|
|
6
6
|
type KeysToOmit = "getEstimatedItemSize" | "getFixedItemSize" | "getItemType" | "keyExtractor" | "animatedProps" | "renderItem" | "onItemSizeChanged" | "itemsAreEqual" | "ItemSeparatorComponent";
|
|
7
|
-
type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof
|
|
7
|
+
type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof Reanimated.ScrollView>>;
|
|
8
8
|
interface AnimatedLegendListPropsBase<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit> {
|
|
9
|
-
refScrollView?: React.Ref<
|
|
9
|
+
refScrollView?: React.Ref<Reanimated.ScrollView>;
|
|
10
10
|
}
|
|
11
11
|
type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
|
|
12
12
|
type AnimatedLegendListProps<ItemT> = Omit<AnimatedLegendListPropsBase<ItemT>, "refLegendList" | "ref"> & OtherAnimatedLegendListProps<ItemT>;
|
package/reanimated.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var
|
|
4
|
+
var Reanimated = require('react-native-reanimated');
|
|
5
5
|
var list = require('@legendapp/list');
|
|
6
6
|
|
|
7
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -25,7 +25,7 @@ function _interopNamespace(e) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
|
-
var
|
|
28
|
+
var Reanimated__default = /*#__PURE__*/_interopDefault(Reanimated);
|
|
29
29
|
|
|
30
30
|
// src/integrations/reanimated.tsx
|
|
31
31
|
|
|
@@ -54,6 +54,7 @@ var useCombinedRef = (...refs) => {
|
|
|
54
54
|
// src/integrations/reanimated.tsx
|
|
55
55
|
var typedMemo = React.memo;
|
|
56
56
|
var LegendListForwardedRef = typedMemo(
|
|
57
|
+
// biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
|
|
57
58
|
React__namespace.forwardRef(function LegendListForwardedRef2(props, ref) {
|
|
58
59
|
const { refLegendList, ...rest } = props;
|
|
59
60
|
const refFn = React.useCallback(
|
|
@@ -65,13 +66,23 @@ var LegendListForwardedRef = typedMemo(
|
|
|
65
66
|
return /* @__PURE__ */ React__namespace.createElement(list.LegendList, { ref: refFn, refScrollView: ref, ...rest });
|
|
66
67
|
})
|
|
67
68
|
);
|
|
68
|
-
var AnimatedLegendListComponent =
|
|
69
|
+
var AnimatedLegendListComponent = Reanimated__default.default.createAnimatedComponent(LegendListForwardedRef);
|
|
69
70
|
var AnimatedLegendList = typedMemo(
|
|
71
|
+
// biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
|
|
70
72
|
React__namespace.forwardRef(function AnimatedLegendList2(props, ref) {
|
|
71
73
|
const { refScrollView, ...rest } = props;
|
|
74
|
+
const { animatedProps } = props;
|
|
72
75
|
const refLegendList = React__namespace.useRef(null);
|
|
73
76
|
const combinedRef = useCombinedRef(refLegendList, ref);
|
|
74
|
-
return /* @__PURE__ */ React__namespace.createElement(
|
|
77
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
78
|
+
AnimatedLegendListComponent,
|
|
79
|
+
{
|
|
80
|
+
animatedPropsInternal: animatedProps,
|
|
81
|
+
ref: refScrollView,
|
|
82
|
+
refLegendList: combinedRef,
|
|
83
|
+
...rest
|
|
84
|
+
}
|
|
85
|
+
);
|
|
75
86
|
})
|
|
76
87
|
);
|
|
77
88
|
|
package/reanimated.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useCallback, memo } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import Reanimated from 'react-native-reanimated';
|
|
4
4
|
import { LegendList } from '@legendapp/list';
|
|
5
5
|
|
|
6
6
|
// src/integrations/reanimated.tsx
|
|
@@ -30,6 +30,7 @@ var useCombinedRef = (...refs) => {
|
|
|
30
30
|
// src/integrations/reanimated.tsx
|
|
31
31
|
var typedMemo = memo;
|
|
32
32
|
var LegendListForwardedRef = typedMemo(
|
|
33
|
+
// biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
|
|
33
34
|
React.forwardRef(function LegendListForwardedRef2(props, ref) {
|
|
34
35
|
const { refLegendList, ...rest } = props;
|
|
35
36
|
const refFn = useCallback(
|
|
@@ -41,13 +42,23 @@ var LegendListForwardedRef = typedMemo(
|
|
|
41
42
|
return /* @__PURE__ */ React.createElement(LegendList, { ref: refFn, refScrollView: ref, ...rest });
|
|
42
43
|
})
|
|
43
44
|
);
|
|
44
|
-
var AnimatedLegendListComponent =
|
|
45
|
+
var AnimatedLegendListComponent = Reanimated.createAnimatedComponent(LegendListForwardedRef);
|
|
45
46
|
var AnimatedLegendList = typedMemo(
|
|
47
|
+
// biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
|
|
46
48
|
React.forwardRef(function AnimatedLegendList2(props, ref) {
|
|
47
49
|
const { refScrollView, ...rest } = props;
|
|
50
|
+
const { animatedProps } = props;
|
|
48
51
|
const refLegendList = React.useRef(null);
|
|
49
52
|
const combinedRef = useCombinedRef(refLegendList, ref);
|
|
50
|
-
return /* @__PURE__ */ React.createElement(
|
|
53
|
+
return /* @__PURE__ */ React.createElement(
|
|
54
|
+
AnimatedLegendListComponent,
|
|
55
|
+
{
|
|
56
|
+
animatedPropsInternal: animatedProps,
|
|
57
|
+
ref: refScrollView,
|
|
58
|
+
refLegendList: combinedRef,
|
|
59
|
+
...rest
|
|
60
|
+
}
|
|
61
|
+
);
|
|
51
62
|
})
|
|
52
63
|
);
|
|
53
64
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import Reanimated from 'react-native-reanimated';
|
|
4
|
+
import { LegendListPropsBase, LegendListRef } from '@legendapp/list';
|
|
5
|
+
|
|
6
|
+
type KeysToOmit = "getEstimatedItemSize" | "getFixedItemSize" | "getItemType" | "keyExtractor" | "animatedProps" | "renderItem" | "onItemSizeChanged" | "itemsAreEqual" | "ItemSeparatorComponent";
|
|
7
|
+
type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof Reanimated.ScrollView>>;
|
|
8
|
+
interface AnimatedLegendListPropsBase<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit> {
|
|
9
|
+
refScrollView?: React.Ref<Reanimated.ScrollView>;
|
|
10
|
+
}
|
|
11
|
+
type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
|
|
12
|
+
type AnimatedLegendListProps<ItemT> = Omit<AnimatedLegendListPropsBase<ItemT>, "refLegendList" | "ref"> & OtherAnimatedLegendListProps<ItemT>;
|
|
13
|
+
type AnimatedLegendListDefinition = <ItemT>(props: AnimatedLegendListProps<ItemT> & {
|
|
14
|
+
ref?: React.Ref<LegendListRef>;
|
|
15
|
+
}) => React.ReactElement | null;
|
|
16
|
+
declare const AnimatedLegendList: AnimatedLegendListDefinition;
|
|
17
|
+
|
|
18
|
+
export { AnimatedLegendList, type AnimatedLegendListProps, type AnimatedLegendListPropsBase };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import Reanimated from 'react-native-reanimated';
|
|
4
|
+
import { LegendListPropsBase, LegendListRef } from '@legendapp/list';
|
|
5
|
+
|
|
6
|
+
type KeysToOmit = "getEstimatedItemSize" | "getFixedItemSize" | "getItemType" | "keyExtractor" | "animatedProps" | "renderItem" | "onItemSizeChanged" | "itemsAreEqual" | "ItemSeparatorComponent";
|
|
7
|
+
type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof Reanimated.ScrollView>>;
|
|
8
|
+
interface AnimatedLegendListPropsBase<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit> {
|
|
9
|
+
refScrollView?: React.Ref<Reanimated.ScrollView>;
|
|
10
|
+
}
|
|
11
|
+
type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
|
|
12
|
+
type AnimatedLegendListProps<ItemT> = Omit<AnimatedLegendListPropsBase<ItemT>, "refLegendList" | "ref"> & OtherAnimatedLegendListProps<ItemT>;
|
|
13
|
+
type AnimatedLegendListDefinition = <ItemT>(props: AnimatedLegendListProps<ItemT> & {
|
|
14
|
+
ref?: React.Ref<LegendListRef>;
|
|
15
|
+
}) => React.ReactElement | null;
|
|
16
|
+
declare const AnimatedLegendList: AnimatedLegendListDefinition;
|
|
17
|
+
|
|
18
|
+
export { AnimatedLegendList, type AnimatedLegendListProps, type AnimatedLegendListPropsBase };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var Reanimated = require('react-native-reanimated');
|
|
5
|
+
var list = require('@legendapp/list');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
|
+
var Reanimated__default = /*#__PURE__*/_interopDefault(Reanimated);
|
|
29
|
+
|
|
30
|
+
// 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;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, refs);
|
|
51
|
+
return callback;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/integrations/reanimated.tsx
|
|
55
|
+
var typedMemo = React.memo;
|
|
56
|
+
var LegendListForwardedRef = typedMemo(
|
|
57
|
+
// biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
|
|
58
|
+
React__namespace.forwardRef(function LegendListForwardedRef2(props, ref) {
|
|
59
|
+
const { refLegendList, ...rest } = props;
|
|
60
|
+
const refFn = React.useCallback(
|
|
61
|
+
(r) => {
|
|
62
|
+
refLegendList(r);
|
|
63
|
+
},
|
|
64
|
+
[refLegendList]
|
|
65
|
+
);
|
|
66
|
+
return /* @__PURE__ */ React__namespace.createElement(list.LegendList, { ref: refFn, refScrollView: ref, ...rest });
|
|
67
|
+
})
|
|
68
|
+
);
|
|
69
|
+
var AnimatedLegendListComponent = Reanimated__default.default.createAnimatedComponent(LegendListForwardedRef);
|
|
70
|
+
var AnimatedLegendList = typedMemo(
|
|
71
|
+
// biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
|
|
72
|
+
React__namespace.forwardRef(function AnimatedLegendList2(props, ref) {
|
|
73
|
+
const { refScrollView, ...rest } = props;
|
|
74
|
+
const { animatedProps } = props;
|
|
75
|
+
const refLegendList = React__namespace.useRef(null);
|
|
76
|
+
const combinedRef = useCombinedRef(refLegendList, ref);
|
|
77
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
78
|
+
AnimatedLegendListComponent,
|
|
79
|
+
{
|
|
80
|
+
animatedPropsInternal: animatedProps,
|
|
81
|
+
ref: refScrollView,
|
|
82
|
+
refLegendList: combinedRef,
|
|
83
|
+
...rest
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
exports.AnimatedLegendList = AnimatedLegendList;
|
|
@@ -0,0 +1,65 @@
|
|
|
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';
|
|
5
|
+
|
|
6
|
+
// 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;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}, refs);
|
|
27
|
+
return callback;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/integrations/reanimated.tsx
|
|
31
|
+
var typedMemo = memo;
|
|
32
|
+
var LegendListForwardedRef = typedMemo(
|
|
33
|
+
// biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
|
|
34
|
+
React.forwardRef(function LegendListForwardedRef2(props, ref) {
|
|
35
|
+
const { refLegendList, ...rest } = props;
|
|
36
|
+
const refFn = useCallback(
|
|
37
|
+
(r) => {
|
|
38
|
+
refLegendList(r);
|
|
39
|
+
},
|
|
40
|
+
[refLegendList]
|
|
41
|
+
);
|
|
42
|
+
return /* @__PURE__ */ React.createElement(LegendList, { ref: refFn, refScrollView: ref, ...rest });
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
var AnimatedLegendListComponent = Reanimated.createAnimatedComponent(LegendListForwardedRef);
|
|
46
|
+
var AnimatedLegendList = typedMemo(
|
|
47
|
+
// biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
|
|
48
|
+
React.forwardRef(function AnimatedLegendList2(props, ref) {
|
|
49
|
+
const { refScrollView, ...rest } = props;
|
|
50
|
+
const { animatedProps } = props;
|
|
51
|
+
const refLegendList = React.useRef(null);
|
|
52
|
+
const combinedRef = useCombinedRef(refLegendList, ref);
|
|
53
|
+
return /* @__PURE__ */ React.createElement(
|
|
54
|
+
AnimatedLegendListComponent,
|
|
55
|
+
{
|
|
56
|
+
animatedPropsInternal: animatedProps,
|
|
57
|
+
ref: refScrollView,
|
|
58
|
+
refLegendList: combinedRef,
|
|
59
|
+
...rest
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export { AnimatedLegendList };
|
package/section-list.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as react_native from 'react-native';
|
|
2
2
|
import { SectionListData, SectionBase, SectionListRenderItemInfo, SectionListScrollParams } from 'react-native';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import 'react-native-reanimated';
|
|
4
|
+
import { LegendListRef, LegendListProps } from '@legendapp/list';
|
|
6
5
|
|
|
7
6
|
type SectionListSeparatorProps<ItemT, SectionT> = {
|
|
8
7
|
leadingItem?: ItemT;
|
package/section-list.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as react_native from 'react-native';
|
|
2
2
|
import { SectionListData, SectionBase, SectionListRenderItemInfo, SectionListScrollParams } from 'react-native';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import 'react-native-reanimated';
|
|
4
|
+
import { LegendListRef, LegendListProps } from '@legendapp/list';
|
|
6
5
|
|
|
7
6
|
type SectionListSeparatorProps<ItemT, SectionT> = {
|
|
8
7
|
leadingItem?: ItemT;
|