@legendapp/list 3.0.0-beta.2 → 3.0.0-beta.20
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/index.d.mts +758 -10
- package/index.d.ts +758 -10
- package/index.js +818 -520
- package/index.mjs +818 -522
- package/index.native.js +824 -483
- package/index.native.mjs +823 -484
- package/keyboard.d.mts +5 -2
- package/keyboard.d.ts +5 -2
- package/keyboard.js +142 -28
- package/keyboard.mjs +145 -31
- 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/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/index.native.d.mts +0 -23
- package/index.native.d.ts +0 -23
- package/section-list.native.d.mts +0 -113
- package/section-list.native.d.ts +0 -113
- package/section-list.native.js +0 -3706
- package/section-list.native.mjs +0 -3685
- 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
package/keyboard.d.mts
CHANGED
|
@@ -6,8 +6,11 @@ import { AnimatedLegendListProps } from '@legendapp/list/reanimated';
|
|
|
6
6
|
|
|
7
7
|
declare const KeyboardAvoidingLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "onScroll" | "contentInset"> & {
|
|
8
8
|
onScroll?: (event: ReanimatedScrollEvent) => void;
|
|
9
|
-
contentInset?: Insets;
|
|
10
|
-
|
|
9
|
+
contentInset?: Insets | undefined;
|
|
10
|
+
safeAreaInsets?: {
|
|
11
|
+
top: number;
|
|
12
|
+
bottom: number;
|
|
13
|
+
};
|
|
11
14
|
} & React.RefAttributes<LegendListRef>) => React.ReactNode;
|
|
12
15
|
|
|
13
16
|
export { KeyboardAvoidingLegendList, KeyboardAvoidingLegendList as LegendList };
|
package/keyboard.d.ts
CHANGED
|
@@ -6,8 +6,11 @@ import { AnimatedLegendListProps } from '@legendapp/list/reanimated';
|
|
|
6
6
|
|
|
7
7
|
declare const KeyboardAvoidingLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "onScroll" | "contentInset"> & {
|
|
8
8
|
onScroll?: (event: ReanimatedScrollEvent) => void;
|
|
9
|
-
contentInset?: Insets;
|
|
10
|
-
|
|
9
|
+
contentInset?: Insets | undefined;
|
|
10
|
+
safeAreaInsets?: {
|
|
11
|
+
top: number;
|
|
12
|
+
bottom: number;
|
|
13
|
+
};
|
|
11
14
|
} & React.RefAttributes<LegendListRef>) => React.ReactNode;
|
|
12
15
|
|
|
13
16
|
export { KeyboardAvoidingLegendList, KeyboardAvoidingLegendList as LegendList };
|
package/keyboard.js
CHANGED
|
@@ -27,72 +27,187 @@ function _interopNamespace(e) {
|
|
|
27
27
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
28
|
|
|
29
29
|
// src/integrations/keyboard.tsx
|
|
30
|
+
|
|
31
|
+
// src/utils/helpers.ts
|
|
32
|
+
function isFunction(obj) {
|
|
33
|
+
return typeof obj === "function";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/hooks/useCombinedRef.ts
|
|
37
|
+
var useCombinedRef = (...refs) => {
|
|
38
|
+
const callback = React.useCallback((element) => {
|
|
39
|
+
for (const ref of refs) {
|
|
40
|
+
if (!ref) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (isFunction(ref)) {
|
|
44
|
+
ref(element);
|
|
45
|
+
} else {
|
|
46
|
+
ref.current = element;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, refs);
|
|
50
|
+
return callback;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/integrations/keyboard.tsx
|
|
54
|
+
var calculateKeyboardInset = (height, safeAreaInsetBottom, isNewArchitecture) => {
|
|
55
|
+
"worklet";
|
|
56
|
+
return Math.max(0, height - safeAreaInsetBottom) ;
|
|
57
|
+
};
|
|
30
58
|
var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
|
|
31
59
|
const {
|
|
32
60
|
contentInset: contentInsetProp,
|
|
33
61
|
horizontal,
|
|
34
62
|
onScroll: onScrollProp,
|
|
35
|
-
|
|
36
|
-
|
|
63
|
+
safeAreaInsets = { bottom: 0, top: 0 },
|
|
64
|
+
style: styleProp,
|
|
37
65
|
...rest
|
|
38
66
|
} = props;
|
|
39
|
-
const
|
|
67
|
+
const styleFlattened = reactNative.StyleSheet.flatten(styleProp);
|
|
68
|
+
const refLegendList = React.useRef(null);
|
|
69
|
+
const combinedRef = useCombinedRef(forwardedRef, refLegendList);
|
|
70
|
+
const isIos = reactNative.Platform.OS === "ios";
|
|
71
|
+
const isAndroid = reactNative.Platform.OS === "android";
|
|
40
72
|
const scrollViewRef = reactNativeReanimated.useAnimatedRef();
|
|
41
73
|
const scrollOffsetY = reactNativeReanimated.useSharedValue(0);
|
|
74
|
+
const animatedOffsetY = reactNativeReanimated.useSharedValue(null);
|
|
42
75
|
const scrollOffsetAtKeyboardStart = reactNativeReanimated.useSharedValue(0);
|
|
43
|
-
const
|
|
76
|
+
const mode = reactNativeReanimated.useSharedValue("idle");
|
|
77
|
+
const keyboardInset = reactNativeReanimated.useSharedValue({ bottom: 0, top: 0 });
|
|
78
|
+
const keyboardHeight = reactNativeReanimated.useSharedValue(0);
|
|
79
|
+
const isOpening = reactNativeReanimated.useSharedValue(false);
|
|
80
|
+
const didInteractive = reactNativeReanimated.useSharedValue(false);
|
|
81
|
+
const { top: safeAreaInsetTop, bottom: safeAreaInsetBottom } = safeAreaInsets;
|
|
82
|
+
const isKeyboardOpen = reactNativeReanimated.useSharedValue(false);
|
|
44
83
|
const scrollHandler = reactNativeReanimated.useAnimatedScrollHandler(
|
|
45
84
|
(event) => {
|
|
46
|
-
scrollOffsetY.
|
|
85
|
+
scrollOffsetY.set(event.contentOffset[horizontal ? "x" : "y"]);
|
|
47
86
|
if (onScrollProp) {
|
|
48
87
|
reactNativeReanimated.runOnJS(onScrollProp)(event);
|
|
49
88
|
}
|
|
50
89
|
},
|
|
51
90
|
[onScrollProp, horizontal]
|
|
52
91
|
);
|
|
92
|
+
const setScrollProcessingEnabled = React.useCallback(
|
|
93
|
+
(enabled) => {
|
|
94
|
+
var _a;
|
|
95
|
+
return (_a = refLegendList.current) == null ? void 0 : _a.setScrollProcessingEnabled(enabled);
|
|
96
|
+
},
|
|
97
|
+
[refLegendList]
|
|
98
|
+
);
|
|
53
99
|
reactNativeKeyboardController.useKeyboardHandler(
|
|
54
100
|
// biome-ignore assist/source/useSortedKeys: prefer start/move/end
|
|
55
101
|
{
|
|
56
|
-
onStart: () => {
|
|
102
|
+
onStart: (event) => {
|
|
57
103
|
"worklet";
|
|
58
|
-
|
|
104
|
+
mode.set("running");
|
|
105
|
+
if (isKeyboardOpen.get() && event.progress === 1 && event.height > 0) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (!didInteractive.get()) {
|
|
109
|
+
if (event.height > 0) {
|
|
110
|
+
keyboardHeight.set(event.height - safeAreaInsetBottom);
|
|
111
|
+
}
|
|
112
|
+
isOpening.set(event.progress > 0);
|
|
113
|
+
scrollOffsetAtKeyboardStart.set(scrollOffsetY.get());
|
|
114
|
+
animatedOffsetY.set(scrollOffsetY.get());
|
|
115
|
+
reactNativeReanimated.runOnJS(setScrollProcessingEnabled)(false);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
onInteractive: (event) => {
|
|
119
|
+
"worklet";
|
|
120
|
+
if (mode.get() !== "running") {
|
|
121
|
+
reactNativeReanimated.runOnJS(setScrollProcessingEnabled)(false);
|
|
122
|
+
}
|
|
123
|
+
mode.set("running");
|
|
124
|
+
if (!didInteractive.get()) {
|
|
125
|
+
didInteractive.set(true);
|
|
126
|
+
}
|
|
127
|
+
if (isAndroid && !horizontal) {
|
|
128
|
+
const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
|
|
129
|
+
keyboardInset.set({ bottom: newInset, top: safeAreaInsetTop * 2 });
|
|
130
|
+
}
|
|
59
131
|
},
|
|
60
132
|
onMove: (event) => {
|
|
61
133
|
"worklet";
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
134
|
+
if (!didInteractive.get()) {
|
|
135
|
+
const vIsOpening = isOpening.get();
|
|
136
|
+
const vKeyboardHeight = keyboardHeight.get();
|
|
137
|
+
const vProgress = vIsOpening ? event.progress : 1 - event.progress;
|
|
138
|
+
const targetOffset = Math.max(
|
|
139
|
+
0,
|
|
140
|
+
scrollOffsetAtKeyboardStart.get() + (vIsOpening ? vKeyboardHeight : -vKeyboardHeight) * vProgress
|
|
141
|
+
);
|
|
142
|
+
scrollOffsetY.set(targetOffset);
|
|
143
|
+
animatedOffsetY.set(targetOffset);
|
|
144
|
+
if (!horizontal) {
|
|
145
|
+
const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
|
|
146
|
+
keyboardInset.set({ bottom: newInset, top: 0 });
|
|
147
|
+
}
|
|
67
148
|
}
|
|
68
149
|
},
|
|
69
150
|
onEnd: (event) => {
|
|
70
151
|
"worklet";
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
|
|
152
|
+
const wasInteractive = didInteractive.get();
|
|
153
|
+
const vMode = mode.get();
|
|
154
|
+
mode.set("idle");
|
|
155
|
+
if (vMode === "running") {
|
|
156
|
+
if (!wasInteractive) {
|
|
157
|
+
const vIsOpening = isOpening.get();
|
|
158
|
+
const vKeyboardHeight = keyboardHeight.get();
|
|
159
|
+
const targetOffset = Math.max(
|
|
160
|
+
0,
|
|
161
|
+
scrollOffsetAtKeyboardStart.get() + (vIsOpening ? vKeyboardHeight : -vKeyboardHeight) * (vIsOpening ? event.progress : 1 - event.progress)
|
|
162
|
+
);
|
|
163
|
+
scrollOffsetY.set(targetOffset);
|
|
164
|
+
animatedOffsetY.set(targetOffset);
|
|
165
|
+
}
|
|
166
|
+
reactNativeReanimated.runOnJS(setScrollProcessingEnabled)(true);
|
|
167
|
+
didInteractive.set(false);
|
|
168
|
+
isKeyboardOpen.set(event.height > 0);
|
|
169
|
+
if (!horizontal) {
|
|
170
|
+
const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
|
|
171
|
+
keyboardInset.set({ bottom: newInset, top: 0 });
|
|
172
|
+
if (newInset <= 0) {
|
|
173
|
+
animatedOffsetY.set(scrollOffsetY.get());
|
|
174
|
+
}
|
|
175
|
+
}
|
|
76
176
|
}
|
|
77
177
|
}
|
|
78
178
|
},
|
|
79
179
|
[scrollViewRef, safeAreaInsetBottom]
|
|
80
180
|
);
|
|
81
|
-
const animatedProps =
|
|
181
|
+
const animatedProps = reactNativeReanimated.useAnimatedProps(() => {
|
|
82
182
|
"worklet";
|
|
83
183
|
var _a, _b, _c, _d;
|
|
84
|
-
|
|
184
|
+
const vAnimatedOffsetY = animatedOffsetY.get();
|
|
185
|
+
const baseProps = {
|
|
186
|
+
contentOffset: vAnimatedOffsetY === null ? void 0 : {
|
|
187
|
+
x: 0,
|
|
188
|
+
y: vAnimatedOffsetY
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const { top: keyboardInsetTop, bottom: keyboardInsetBottom } = keyboardInset.get();
|
|
192
|
+
return isIos ? Object.assign(baseProps, {
|
|
85
193
|
contentInset: {
|
|
86
|
-
bottom: ((_a = contentInsetProp == null ? void 0 : contentInsetProp.bottom) != null ? _a : 0) + (horizontal ? 0 :
|
|
194
|
+
bottom: ((_a = contentInsetProp == null ? void 0 : contentInsetProp.bottom) != null ? _a : 0) + (horizontal ? 0 : keyboardInsetBottom),
|
|
87
195
|
left: (_b = contentInsetProp == null ? void 0 : contentInsetProp.left) != null ? _b : 0,
|
|
88
196
|
right: (_c = contentInsetProp == null ? void 0 : contentInsetProp.right) != null ? _c : 0,
|
|
89
|
-
top: (_d = contentInsetProp == null ? void 0 : contentInsetProp.top) != null ? _d : 0
|
|
197
|
+
top: ((_d = contentInsetProp == null ? void 0 : contentInsetProp.top) != null ? _d : 0) - keyboardInsetTop
|
|
90
198
|
}
|
|
91
|
-
};
|
|
92
|
-
})
|
|
93
|
-
const style =
|
|
94
|
-
|
|
95
|
-
|
|
199
|
+
}) : baseProps;
|
|
200
|
+
});
|
|
201
|
+
const style = isAndroid ? reactNativeReanimated.useAnimatedStyle(
|
|
202
|
+
() => {
|
|
203
|
+
var _a;
|
|
204
|
+
return {
|
|
205
|
+
...styleFlattened || {},
|
|
206
|
+
marginBottom: (_a = keyboardInset.get().bottom) != null ? _a : 0
|
|
207
|
+
};
|
|
208
|
+
},
|
|
209
|
+
[styleProp, keyboardInset]
|
|
210
|
+
) : void 0;
|
|
96
211
|
return /* @__PURE__ */ React__namespace.createElement(
|
|
97
212
|
reanimated.AnimatedLegendList,
|
|
98
213
|
{
|
|
@@ -100,9 +215,8 @@ var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegen
|
|
|
100
215
|
animatedProps,
|
|
101
216
|
keyboardDismissMode: "interactive",
|
|
102
217
|
onScroll: scrollHandler,
|
|
103
|
-
ref:
|
|
218
|
+
ref: combinedRef,
|
|
104
219
|
refScrollView: scrollViewRef,
|
|
105
|
-
scrollEventThrottle: resolvedScrollEventThrottle,
|
|
106
220
|
scrollIndicatorInsets: { bottom: 0, top: 0 },
|
|
107
221
|
style
|
|
108
222
|
}
|
package/keyboard.mjs
CHANGED
|
@@ -1,77 +1,192 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import { Platform } from 'react-native';
|
|
2
|
+
import { forwardRef, useRef, useCallback } from 'react';
|
|
3
|
+
import { StyleSheet, Platform } from 'react-native';
|
|
4
4
|
import { useKeyboardHandler } from 'react-native-keyboard-controller';
|
|
5
|
-
import { useAnimatedRef, useSharedValue, useAnimatedScrollHandler, runOnJS,
|
|
5
|
+
import { useAnimatedRef, useSharedValue, useAnimatedScrollHandler, runOnJS, useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
|
|
6
6
|
import { AnimatedLegendList } from '@legendapp/list/reanimated';
|
|
7
7
|
|
|
8
8
|
// src/integrations/keyboard.tsx
|
|
9
|
+
|
|
10
|
+
// src/utils/helpers.ts
|
|
11
|
+
function isFunction(obj) {
|
|
12
|
+
return typeof obj === "function";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/hooks/useCombinedRef.ts
|
|
16
|
+
var useCombinedRef = (...refs) => {
|
|
17
|
+
const callback = useCallback((element) => {
|
|
18
|
+
for (const ref of refs) {
|
|
19
|
+
if (!ref) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (isFunction(ref)) {
|
|
23
|
+
ref(element);
|
|
24
|
+
} else {
|
|
25
|
+
ref.current = element;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}, refs);
|
|
29
|
+
return callback;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// src/integrations/keyboard.tsx
|
|
33
|
+
var calculateKeyboardInset = (height, safeAreaInsetBottom, isNewArchitecture) => {
|
|
34
|
+
"worklet";
|
|
35
|
+
return Math.max(0, height - safeAreaInsetBottom) ;
|
|
36
|
+
};
|
|
9
37
|
var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
|
|
10
38
|
const {
|
|
11
39
|
contentInset: contentInsetProp,
|
|
12
40
|
horizontal,
|
|
13
41
|
onScroll: onScrollProp,
|
|
14
|
-
|
|
15
|
-
|
|
42
|
+
safeAreaInsets = { bottom: 0, top: 0 },
|
|
43
|
+
style: styleProp,
|
|
16
44
|
...rest
|
|
17
45
|
} = props;
|
|
18
|
-
const
|
|
46
|
+
const styleFlattened = StyleSheet.flatten(styleProp);
|
|
47
|
+
const refLegendList = useRef(null);
|
|
48
|
+
const combinedRef = useCombinedRef(forwardedRef, refLegendList);
|
|
49
|
+
const isIos = Platform.OS === "ios";
|
|
50
|
+
const isAndroid = Platform.OS === "android";
|
|
19
51
|
const scrollViewRef = useAnimatedRef();
|
|
20
52
|
const scrollOffsetY = useSharedValue(0);
|
|
53
|
+
const animatedOffsetY = useSharedValue(null);
|
|
21
54
|
const scrollOffsetAtKeyboardStart = useSharedValue(0);
|
|
22
|
-
const
|
|
55
|
+
const mode = useSharedValue("idle");
|
|
56
|
+
const keyboardInset = useSharedValue({ bottom: 0, top: 0 });
|
|
57
|
+
const keyboardHeight = useSharedValue(0);
|
|
58
|
+
const isOpening = useSharedValue(false);
|
|
59
|
+
const didInteractive = useSharedValue(false);
|
|
60
|
+
const { top: safeAreaInsetTop, bottom: safeAreaInsetBottom } = safeAreaInsets;
|
|
61
|
+
const isKeyboardOpen = useSharedValue(false);
|
|
23
62
|
const scrollHandler = useAnimatedScrollHandler(
|
|
24
63
|
(event) => {
|
|
25
|
-
scrollOffsetY.
|
|
64
|
+
scrollOffsetY.set(event.contentOffset[horizontal ? "x" : "y"]);
|
|
26
65
|
if (onScrollProp) {
|
|
27
66
|
runOnJS(onScrollProp)(event);
|
|
28
67
|
}
|
|
29
68
|
},
|
|
30
69
|
[onScrollProp, horizontal]
|
|
31
70
|
);
|
|
71
|
+
const setScrollProcessingEnabled = useCallback(
|
|
72
|
+
(enabled) => {
|
|
73
|
+
var _a;
|
|
74
|
+
return (_a = refLegendList.current) == null ? void 0 : _a.setScrollProcessingEnabled(enabled);
|
|
75
|
+
},
|
|
76
|
+
[refLegendList]
|
|
77
|
+
);
|
|
32
78
|
useKeyboardHandler(
|
|
33
79
|
// biome-ignore assist/source/useSortedKeys: prefer start/move/end
|
|
34
80
|
{
|
|
35
|
-
onStart: () => {
|
|
81
|
+
onStart: (event) => {
|
|
82
|
+
"worklet";
|
|
83
|
+
mode.set("running");
|
|
84
|
+
if (isKeyboardOpen.get() && event.progress === 1 && event.height > 0) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (!didInteractive.get()) {
|
|
88
|
+
if (event.height > 0) {
|
|
89
|
+
keyboardHeight.set(event.height - safeAreaInsetBottom);
|
|
90
|
+
}
|
|
91
|
+
isOpening.set(event.progress > 0);
|
|
92
|
+
scrollOffsetAtKeyboardStart.set(scrollOffsetY.get());
|
|
93
|
+
animatedOffsetY.set(scrollOffsetY.get());
|
|
94
|
+
runOnJS(setScrollProcessingEnabled)(false);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
onInteractive: (event) => {
|
|
36
98
|
"worklet";
|
|
37
|
-
|
|
99
|
+
if (mode.get() !== "running") {
|
|
100
|
+
runOnJS(setScrollProcessingEnabled)(false);
|
|
101
|
+
}
|
|
102
|
+
mode.set("running");
|
|
103
|
+
if (!didInteractive.get()) {
|
|
104
|
+
didInteractive.set(true);
|
|
105
|
+
}
|
|
106
|
+
if (isAndroid && !horizontal) {
|
|
107
|
+
const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
|
|
108
|
+
keyboardInset.set({ bottom: newInset, top: safeAreaInsetTop * 2 });
|
|
109
|
+
}
|
|
38
110
|
},
|
|
39
111
|
onMove: (event) => {
|
|
40
112
|
"worklet";
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
113
|
+
if (!didInteractive.get()) {
|
|
114
|
+
const vIsOpening = isOpening.get();
|
|
115
|
+
const vKeyboardHeight = keyboardHeight.get();
|
|
116
|
+
const vProgress = vIsOpening ? event.progress : 1 - event.progress;
|
|
117
|
+
const targetOffset = Math.max(
|
|
118
|
+
0,
|
|
119
|
+
scrollOffsetAtKeyboardStart.get() + (vIsOpening ? vKeyboardHeight : -vKeyboardHeight) * vProgress
|
|
120
|
+
);
|
|
121
|
+
scrollOffsetY.set(targetOffset);
|
|
122
|
+
animatedOffsetY.set(targetOffset);
|
|
123
|
+
if (!horizontal) {
|
|
124
|
+
const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
|
|
125
|
+
keyboardInset.set({ bottom: newInset, top: 0 });
|
|
126
|
+
}
|
|
46
127
|
}
|
|
47
128
|
},
|
|
48
129
|
onEnd: (event) => {
|
|
49
130
|
"worklet";
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
|
|
131
|
+
const wasInteractive = didInteractive.get();
|
|
132
|
+
const vMode = mode.get();
|
|
133
|
+
mode.set("idle");
|
|
134
|
+
if (vMode === "running") {
|
|
135
|
+
if (!wasInteractive) {
|
|
136
|
+
const vIsOpening = isOpening.get();
|
|
137
|
+
const vKeyboardHeight = keyboardHeight.get();
|
|
138
|
+
const targetOffset = Math.max(
|
|
139
|
+
0,
|
|
140
|
+
scrollOffsetAtKeyboardStart.get() + (vIsOpening ? vKeyboardHeight : -vKeyboardHeight) * (vIsOpening ? event.progress : 1 - event.progress)
|
|
141
|
+
);
|
|
142
|
+
scrollOffsetY.set(targetOffset);
|
|
143
|
+
animatedOffsetY.set(targetOffset);
|
|
144
|
+
}
|
|
145
|
+
runOnJS(setScrollProcessingEnabled)(true);
|
|
146
|
+
didInteractive.set(false);
|
|
147
|
+
isKeyboardOpen.set(event.height > 0);
|
|
148
|
+
if (!horizontal) {
|
|
149
|
+
const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
|
|
150
|
+
keyboardInset.set({ bottom: newInset, top: 0 });
|
|
151
|
+
if (newInset <= 0) {
|
|
152
|
+
animatedOffsetY.set(scrollOffsetY.get());
|
|
153
|
+
}
|
|
154
|
+
}
|
|
55
155
|
}
|
|
56
156
|
}
|
|
57
157
|
},
|
|
58
158
|
[scrollViewRef, safeAreaInsetBottom]
|
|
59
159
|
);
|
|
60
|
-
const animatedProps =
|
|
160
|
+
const animatedProps = useAnimatedProps(() => {
|
|
61
161
|
"worklet";
|
|
62
162
|
var _a, _b, _c, _d;
|
|
63
|
-
|
|
163
|
+
const vAnimatedOffsetY = animatedOffsetY.get();
|
|
164
|
+
const baseProps = {
|
|
165
|
+
contentOffset: vAnimatedOffsetY === null ? void 0 : {
|
|
166
|
+
x: 0,
|
|
167
|
+
y: vAnimatedOffsetY
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const { top: keyboardInsetTop, bottom: keyboardInsetBottom } = keyboardInset.get();
|
|
171
|
+
return isIos ? Object.assign(baseProps, {
|
|
64
172
|
contentInset: {
|
|
65
|
-
bottom: ((_a = contentInsetProp == null ? void 0 : contentInsetProp.bottom) != null ? _a : 0) + (horizontal ? 0 :
|
|
173
|
+
bottom: ((_a = contentInsetProp == null ? void 0 : contentInsetProp.bottom) != null ? _a : 0) + (horizontal ? 0 : keyboardInsetBottom),
|
|
66
174
|
left: (_b = contentInsetProp == null ? void 0 : contentInsetProp.left) != null ? _b : 0,
|
|
67
175
|
right: (_c = contentInsetProp == null ? void 0 : contentInsetProp.right) != null ? _c : 0,
|
|
68
|
-
top: (_d = contentInsetProp == null ? void 0 : contentInsetProp.top) != null ? _d : 0
|
|
176
|
+
top: ((_d = contentInsetProp == null ? void 0 : contentInsetProp.top) != null ? _d : 0) - keyboardInsetTop
|
|
69
177
|
}
|
|
70
|
-
};
|
|
71
|
-
})
|
|
72
|
-
const style =
|
|
73
|
-
|
|
74
|
-
|
|
178
|
+
}) : baseProps;
|
|
179
|
+
});
|
|
180
|
+
const style = isAndroid ? useAnimatedStyle(
|
|
181
|
+
() => {
|
|
182
|
+
var _a;
|
|
183
|
+
return {
|
|
184
|
+
...styleFlattened || {},
|
|
185
|
+
marginBottom: (_a = keyboardInset.get().bottom) != null ? _a : 0
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
[styleProp, keyboardInset]
|
|
189
|
+
) : void 0;
|
|
75
190
|
return /* @__PURE__ */ React.createElement(
|
|
76
191
|
AnimatedLegendList,
|
|
77
192
|
{
|
|
@@ -79,9 +194,8 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
79
194
|
animatedProps,
|
|
80
195
|
keyboardDismissMode: "interactive",
|
|
81
196
|
onScroll: scrollHandler,
|
|
82
|
-
ref:
|
|
197
|
+
ref: combinedRef,
|
|
83
198
|
refScrollView: scrollViewRef,
|
|
84
|
-
scrollEventThrottle: resolvedScrollEventThrottle,
|
|
85
199
|
scrollIndicatorInsets: { bottom: 0, top: 0 },
|
|
86
200
|
style
|
|
87
201
|
}
|
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.20",
|
|
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
|
|
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;
|