@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.
- package/.DS_Store +0 -0
- package/CHANGELOG.md +19 -0
- package/README.md +9 -2
- package/animated.d.ts +657 -5
- package/animated.js +2 -2
- package/animated.mjs +1 -1
- package/index.d.ts +1316 -11
- package/index.js +4009 -1279
- package/index.mjs +4008 -1280
- package/index.native.js +3772 -1337
- package/index.native.mjs +3758 -1325
- package/keyboard-chat.d.ts +228 -0
- package/keyboard-chat.js +97 -0
- package/keyboard-chat.mjs +76 -0
- package/keyboard-test.d.ts +216 -0
- package/keyboard-test.js +39 -0
- package/keyboard-test.mjs +18 -0
- package/keyboard.d.ts +216 -8
- package/keyboard.js +355 -64
- package/keyboard.mjs +358 -66
- package/package.json +68 -1
- package/{types-YNdphn_A.d.mts → react-native.d.ts} +306 -263
- package/react-native.js +6003 -0
- package/react-native.mjs +5974 -0
- package/{types-YNdphn_A.d.ts → react-native.web.d.ts} +367 -261
- package/react-native.web.js +6537 -0
- package/react-native.web.mjs +6508 -0
- package/react.d.ts +776 -0
- package/react.js +6537 -0
- package/react.mjs +6508 -0
- package/reanimated.d.ts +679 -8
- package/reanimated.js +230 -29
- package/reanimated.mjs +232 -31
- package/section-list.d.ts +661 -5
- package/section-list.js +50 -3675
- package/section-list.mjs +48 -3674
- package/animated.d.mts +0 -9
- package/index.d.mts +0 -23
- package/index.native.d.mts +0 -23
- package/index.native.d.ts +0 -23
- package/keyboard-controller.d.mts +0 -12
- package/keyboard-controller.d.ts +0 -12
- package/keyboard-controller.js +0 -69
- package/keyboard-controller.mjs +0 -48
- package/keyboard.d.mts +0 -13
- package/reanimated.d.mts +0 -18
- package/section-list.d.mts +0 -113
- package/section-list.native.d.mts +0 -113
- package/section-list.native.d.ts +0 -113
- package/section-list.native.js +0 -3711
- package/section-list.native.mjs +0 -3690
package/keyboard.mjs
CHANGED
|
@@ -1,136 +1,428 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { Platform } from 'react-native';
|
|
2
|
+
import { useRef, useState, useMemo, useCallback, useEffect } from 'react';
|
|
3
|
+
import { StyleSheet, Platform } from 'react-native';
|
|
4
4
|
import { useKeyboardHandler } from 'react-native-keyboard-controller';
|
|
5
|
-
import { useAnimatedRef, useSharedValue, useAnimatedScrollHandler, runOnJS, useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
|
|
5
|
+
import { useAnimatedRef, useSharedValue, isWorkletFunction, useAnimatedScrollHandler, runOnJS, useComposedEventHandler, useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
|
|
6
|
+
import { internal } from '@legendapp/list/react-native';
|
|
6
7
|
import { AnimatedLegendList } from '@legendapp/list/reanimated';
|
|
7
8
|
|
|
8
9
|
// src/integrations/keyboard.tsx
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return
|
|
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;
|
|
10
|
+
var { typedForwardRef, useCombinedRef } = internal;
|
|
11
|
+
var clampProgress = (progress) => {
|
|
12
|
+
"worklet";
|
|
13
|
+
return Math.min(1, Math.max(0, progress));
|
|
30
14
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
var calculateKeyboardInset = (height, safeAreaInsetBottom) => {
|
|
16
|
+
"worklet";
|
|
17
|
+
return Math.max(0, height - safeAreaInsetBottom);
|
|
18
|
+
};
|
|
19
|
+
var calculateEffectiveKeyboardHeight = (keyboardHeight, contentLength, scrollLength, alignItemsAtEnd) => {
|
|
20
|
+
"worklet";
|
|
21
|
+
if (alignItemsAtEnd) {
|
|
22
|
+
return keyboardHeight;
|
|
23
|
+
} else {
|
|
24
|
+
const availableSpace = Math.max(0, scrollLength - contentLength);
|
|
25
|
+
return Math.max(0, keyboardHeight - availableSpace);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var calculateKeyboardTargetOffset = (startOffset, keyboardHeight, isOpening, progress) => {
|
|
29
|
+
"worklet";
|
|
30
|
+
const normalizedProgress = isOpening ? progress : 1 - progress;
|
|
31
|
+
const delta = (isOpening ? keyboardHeight : -keyboardHeight) * normalizedProgress;
|
|
32
|
+
return Math.max(0, startOffset + delta);
|
|
33
|
+
};
|
|
34
|
+
var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
|
|
34
35
|
const {
|
|
36
|
+
contentContainerStyle: contentContainerStyleProp,
|
|
35
37
|
contentInset: contentInsetProp,
|
|
36
38
|
horizontal,
|
|
39
|
+
onMetricsChange: onMetricsChangeProp,
|
|
40
|
+
onContentSizeChange: onContentSizeChangeProp,
|
|
41
|
+
onLayout: onLayoutProp,
|
|
37
42
|
onScroll: onScrollProp,
|
|
38
43
|
safeAreaInsetBottom = 0,
|
|
44
|
+
style: styleProp,
|
|
39
45
|
...rest
|
|
40
46
|
} = props;
|
|
47
|
+
const { alignItemsAtEnd } = props;
|
|
48
|
+
const styleFlattened = StyleSheet.flatten(styleProp);
|
|
41
49
|
const refLegendList = useRef(null);
|
|
42
50
|
const combinedRef = useCombinedRef(forwardedRef, refLegendList);
|
|
51
|
+
const isIos = Platform.OS === "ios";
|
|
52
|
+
const isAndroid = Platform.OS === "android";
|
|
43
53
|
const scrollViewRef = useAnimatedRef();
|
|
44
54
|
const scrollOffsetY = useSharedValue(0);
|
|
45
55
|
const animatedOffsetY = useSharedValue(null);
|
|
46
56
|
const scrollOffsetAtKeyboardStart = useSharedValue(0);
|
|
57
|
+
const animationMode = useSharedValue("idle");
|
|
47
58
|
const keyboardInset = useSharedValue(0);
|
|
48
59
|
const keyboardHeight = useSharedValue(0);
|
|
60
|
+
const contentLength = useSharedValue(0);
|
|
61
|
+
const scrollLength = useSharedValue(0);
|
|
49
62
|
const isOpening = useSharedValue(false);
|
|
63
|
+
const didInteractive = useSharedValue(false);
|
|
64
|
+
const shouldUpdateAlignItemsAtEndMinSize = useSharedValue(false);
|
|
65
|
+
const isKeyboardOpen = useSharedValue(false);
|
|
66
|
+
const hasSeenKeyboardTransition = useSharedValue(false);
|
|
67
|
+
const skipKeyboardAnimationForCurrentTransition = useSharedValue(false);
|
|
68
|
+
const keyboardInsetRef = useRef(0);
|
|
69
|
+
const [alignItemsAtEndMinSize, setAlignItemsAtEndMinSize] = useState(void 0);
|
|
70
|
+
const onScrollValue = onScrollProp;
|
|
71
|
+
const onScrollCallback = typeof onScrollValue === "function" ? onScrollValue : void 0;
|
|
72
|
+
const onScrollProcessed = onScrollValue && typeof onScrollValue === "object" && "workletEventHandler" in onScrollValue ? onScrollValue : null;
|
|
73
|
+
const onScrollCallbackIsWorklet = useMemo(
|
|
74
|
+
() => onScrollCallback ? isWorkletFunction(onScrollCallback) : false,
|
|
75
|
+
[onScrollCallback]
|
|
76
|
+
);
|
|
77
|
+
const handleContentSizeChange = useCallback(
|
|
78
|
+
(width, height) => {
|
|
79
|
+
const nextContentLength = horizontal ? width : height;
|
|
80
|
+
if (Number.isFinite(nextContentLength) && nextContentLength > 0) {
|
|
81
|
+
contentLength.set(nextContentLength);
|
|
82
|
+
}
|
|
83
|
+
onContentSizeChangeProp == null ? void 0 : onContentSizeChangeProp(width, height);
|
|
84
|
+
},
|
|
85
|
+
[contentLength, horizontal, onContentSizeChangeProp]
|
|
86
|
+
);
|
|
87
|
+
const handleLayout = useCallback(
|
|
88
|
+
(event) => {
|
|
89
|
+
const nextScrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
90
|
+
if (Number.isFinite(nextScrollLength) && nextScrollLength > 0) {
|
|
91
|
+
scrollLength.set(nextScrollLength);
|
|
92
|
+
}
|
|
93
|
+
onLayoutProp == null ? void 0 : onLayoutProp(event);
|
|
94
|
+
},
|
|
95
|
+
[horizontal, onLayoutProp, scrollLength]
|
|
96
|
+
);
|
|
50
97
|
const scrollHandler = useAnimatedScrollHandler(
|
|
51
98
|
(event) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
99
|
+
if (animationMode.get() !== "running" || didInteractive.get()) {
|
|
100
|
+
scrollOffsetY.set(event.contentOffset[horizontal ? "x" : "y"]);
|
|
101
|
+
}
|
|
102
|
+
if (onScrollCallback) {
|
|
103
|
+
if (onScrollCallbackIsWorklet) {
|
|
104
|
+
onScrollCallback(event);
|
|
105
|
+
} else {
|
|
106
|
+
runOnJS(onScrollCallback)(event);
|
|
107
|
+
}
|
|
55
108
|
}
|
|
56
109
|
},
|
|
57
|
-
[
|
|
110
|
+
[horizontal, onScrollCallback, onScrollCallbackIsWorklet]
|
|
58
111
|
);
|
|
112
|
+
const composedScrollHandler = useComposedEventHandler([
|
|
113
|
+
scrollHandler,
|
|
114
|
+
onScrollProcessed
|
|
115
|
+
]);
|
|
116
|
+
const finalScrollHandler = onScrollProcessed ? composedScrollHandler : scrollHandler;
|
|
59
117
|
const setScrollProcessingEnabled = useCallback(
|
|
60
118
|
(enabled) => {
|
|
61
119
|
var _a;
|
|
62
|
-
(_a = refLegendList.current) == null ? void 0 : _a.setScrollProcessingEnabled(enabled);
|
|
120
|
+
return (_a = refLegendList.current) == null ? void 0 : _a.setScrollProcessingEnabled(enabled);
|
|
121
|
+
},
|
|
122
|
+
[refLegendList]
|
|
123
|
+
);
|
|
124
|
+
const reportContentInset = useCallback(
|
|
125
|
+
(bottom) => {
|
|
126
|
+
var _a;
|
|
127
|
+
return (_a = refLegendList.current) == null ? void 0 : _a.reportContentInset({ bottom });
|
|
63
128
|
},
|
|
64
129
|
[refLegendList]
|
|
65
130
|
);
|
|
131
|
+
const clearAlignItemsAtEndMinSize = useCallback(() => {
|
|
132
|
+
setAlignItemsAtEndMinSize((prev) => prev === void 0 ? prev : void 0);
|
|
133
|
+
}, []);
|
|
134
|
+
const updateAlignItemsAtEndMinSize = useCallback(
|
|
135
|
+
(nextKeyboardInset) => {
|
|
136
|
+
var _a;
|
|
137
|
+
if (isAndroid) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (nextKeyboardInset !== void 0) {
|
|
141
|
+
keyboardInsetRef.current = nextKeyboardInset;
|
|
142
|
+
}
|
|
143
|
+
if (!alignItemsAtEnd || horizontal) {
|
|
144
|
+
clearAlignItemsAtEndMinSize();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const state = (_a = refLegendList.current) == null ? void 0 : _a.getState();
|
|
148
|
+
if (!state) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const currentInset = keyboardInsetRef.current;
|
|
152
|
+
if (currentInset <= 0) {
|
|
153
|
+
clearAlignItemsAtEndMinSize();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (state.scrollLength <= 0) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const nextMinSize = Math.max(0, state.scrollLength - currentInset);
|
|
160
|
+
setAlignItemsAtEndMinSize((prev) => prev === nextMinSize ? prev : nextMinSize);
|
|
161
|
+
},
|
|
162
|
+
[alignItemsAtEnd, clearAlignItemsAtEndMinSize, horizontal]
|
|
163
|
+
);
|
|
164
|
+
const updateScrollMetrics = useCallback(() => {
|
|
165
|
+
var _a;
|
|
166
|
+
const state = (_a = refLegendList.current) == null ? void 0 : _a.getState();
|
|
167
|
+
if (!state) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
contentLength.set(state.contentLength);
|
|
171
|
+
if (animationMode.get() !== "running") {
|
|
172
|
+
scrollOffsetY.set(state.scroll);
|
|
173
|
+
}
|
|
174
|
+
scrollLength.set(state.scrollLength);
|
|
175
|
+
updateAlignItemsAtEndMinSize();
|
|
176
|
+
}, [animationMode, contentLength, scrollLength, scrollOffsetY, updateAlignItemsAtEndMinSize]);
|
|
177
|
+
const handleMetricsChange = useCallback(
|
|
178
|
+
(metrics) => {
|
|
179
|
+
updateScrollMetrics();
|
|
180
|
+
onMetricsChangeProp == null ? void 0 : onMetricsChangeProp(metrics);
|
|
181
|
+
},
|
|
182
|
+
[onMetricsChangeProp, updateScrollMetrics]
|
|
183
|
+
);
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
updateScrollMetrics();
|
|
186
|
+
}, [updateScrollMetrics]);
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
updateAlignItemsAtEndMinSize();
|
|
189
|
+
}, [updateAlignItemsAtEndMinSize]);
|
|
190
|
+
const getEffectiveKeyboardHeightFromInset = useCallback(
|
|
191
|
+
(nextKeyboardInset) => {
|
|
192
|
+
"worklet";
|
|
193
|
+
return calculateEffectiveKeyboardHeight(
|
|
194
|
+
nextKeyboardInset,
|
|
195
|
+
contentLength.get(),
|
|
196
|
+
scrollLength.get(),
|
|
197
|
+
alignItemsAtEnd
|
|
198
|
+
);
|
|
199
|
+
},
|
|
200
|
+
[alignItemsAtEnd, contentLength, scrollLength]
|
|
201
|
+
);
|
|
202
|
+
const getEffectiveKeyboardHeightFromEvent = useCallback(
|
|
203
|
+
(eventHeight) => {
|
|
204
|
+
"worklet";
|
|
205
|
+
const nextKeyboardInset = calculateKeyboardInset(eventHeight, safeAreaInsetBottom);
|
|
206
|
+
return getEffectiveKeyboardHeightFromInset(nextKeyboardInset);
|
|
207
|
+
},
|
|
208
|
+
[getEffectiveKeyboardHeightFromInset, safeAreaInsetBottom]
|
|
209
|
+
);
|
|
66
210
|
useKeyboardHandler(
|
|
67
211
|
// biome-ignore assist/source/useSortedKeys: prefer start/move/end
|
|
68
212
|
{
|
|
69
213
|
onStart: (event) => {
|
|
70
214
|
"worklet";
|
|
71
|
-
|
|
72
|
-
|
|
215
|
+
const progress = clampProgress(event.progress);
|
|
216
|
+
const shouldSkipInitialCloseAnimation = !hasSeenKeyboardTransition.get() && !isKeyboardOpen.get() && keyboardHeight.get() <= 0 && progress <= 0 && event.height <= 0;
|
|
217
|
+
skipKeyboardAnimationForCurrentTransition.set(shouldSkipInitialCloseAnimation);
|
|
218
|
+
hasSeenKeyboardTransition.set(true);
|
|
219
|
+
if (isKeyboardOpen.get() && progress >= 1 && event.height > 0) {
|
|
220
|
+
didInteractive.set(false);
|
|
221
|
+
animationMode.set("idle");
|
|
222
|
+
runOnJS(setScrollProcessingEnabled)(true);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (shouldSkipInitialCloseAnimation) {
|
|
226
|
+
isOpening.set(false);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
animationMode.set("running");
|
|
230
|
+
if (!didInteractive.get()) {
|
|
231
|
+
if (event.height > 0) {
|
|
232
|
+
keyboardHeight.set(calculateKeyboardInset(event.height, safeAreaInsetBottom));
|
|
233
|
+
}
|
|
234
|
+
const vIsOpening = progress > 0;
|
|
235
|
+
isOpening.set(vIsOpening);
|
|
236
|
+
shouldUpdateAlignItemsAtEndMinSize.set(
|
|
237
|
+
!!alignItemsAtEnd && !horizontal && contentLength.get() < scrollLength.get()
|
|
238
|
+
);
|
|
239
|
+
if (!shouldUpdateAlignItemsAtEndMinSize.get()) {
|
|
240
|
+
runOnJS(clearAlignItemsAtEndMinSize)();
|
|
241
|
+
}
|
|
242
|
+
const vScrollOffset = scrollOffsetY.get();
|
|
243
|
+
scrollOffsetAtKeyboardStart.set(vScrollOffset);
|
|
244
|
+
if (isIos) {
|
|
245
|
+
const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromInset(keyboardHeight.get());
|
|
246
|
+
const targetOffset = Math.max(
|
|
247
|
+
0,
|
|
248
|
+
vIsOpening ? vScrollOffset + vEffectiveKeyboardHeight : vScrollOffset - vEffectiveKeyboardHeight
|
|
249
|
+
);
|
|
250
|
+
scrollOffsetY.set(targetOffset);
|
|
251
|
+
animatedOffsetY.set(targetOffset);
|
|
252
|
+
keyboardInset.set(vEffectiveKeyboardHeight);
|
|
253
|
+
runOnJS(updateAlignItemsAtEndMinSize)(vEffectiveKeyboardHeight);
|
|
254
|
+
} else if (isAndroid) {
|
|
255
|
+
animatedOffsetY.set(vScrollOffset);
|
|
256
|
+
}
|
|
257
|
+
runOnJS(setScrollProcessingEnabled)(false);
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
onInteractive: (event) => {
|
|
261
|
+
"worklet";
|
|
262
|
+
if (animationMode.get() !== "running") {
|
|
263
|
+
runOnJS(setScrollProcessingEnabled)(false);
|
|
264
|
+
}
|
|
265
|
+
animationMode.set("running");
|
|
266
|
+
if (!didInteractive.get()) {
|
|
267
|
+
didInteractive.set(true);
|
|
268
|
+
}
|
|
269
|
+
if (isAndroid && !horizontal) {
|
|
270
|
+
const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
|
|
271
|
+
keyboardInset.set(newInset);
|
|
272
|
+
}
|
|
273
|
+
if (shouldUpdateAlignItemsAtEndMinSize.get() && !horizontal && alignItemsAtEnd) {
|
|
274
|
+
const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromEvent(event.height);
|
|
275
|
+
runOnJS(updateAlignItemsAtEndMinSize)(vEffectiveKeyboardHeight);
|
|
73
276
|
}
|
|
74
|
-
isOpening.set(event.progress > 0);
|
|
75
|
-
scrollOffsetAtKeyboardStart.value = scrollOffsetY.value;
|
|
76
|
-
animatedOffsetY.set(scrollOffsetY.value);
|
|
77
|
-
runOnJS(setScrollProcessingEnabled)(false);
|
|
78
277
|
},
|
|
79
278
|
onMove: (event) => {
|
|
80
279
|
"worklet";
|
|
81
280
|
const vIsOpening = isOpening.get();
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
|
|
281
|
+
const progress = clampProgress(event.progress);
|
|
282
|
+
const skipKeyboardAnimation = skipKeyboardAnimationForCurrentTransition.get();
|
|
283
|
+
if (skipKeyboardAnimation) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (isAndroid) {
|
|
287
|
+
if (!didInteractive.get()) {
|
|
288
|
+
const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromInset(keyboardHeight.get());
|
|
289
|
+
const targetOffset = calculateKeyboardTargetOffset(
|
|
290
|
+
scrollOffsetAtKeyboardStart.get(),
|
|
291
|
+
vEffectiveKeyboardHeight,
|
|
292
|
+
vIsOpening,
|
|
293
|
+
progress
|
|
294
|
+
);
|
|
295
|
+
scrollOffsetY.set(targetOffset);
|
|
296
|
+
animatedOffsetY.set(targetOffset);
|
|
297
|
+
}
|
|
298
|
+
if (!horizontal) {
|
|
299
|
+
const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
|
|
300
|
+
keyboardInset.set(newInset);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (!horizontal && alignItemsAtEnd && !vIsOpening && shouldUpdateAlignItemsAtEndMinSize.get()) {
|
|
304
|
+
const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromEvent(event.height);
|
|
305
|
+
runOnJS(updateAlignItemsAtEndMinSize)(vEffectiveKeyboardHeight);
|
|
89
306
|
}
|
|
90
307
|
},
|
|
91
308
|
onEnd: (event) => {
|
|
92
309
|
"worklet";
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
310
|
+
const wasInteractive = didInteractive.get();
|
|
311
|
+
const skipKeyboardAnimation = skipKeyboardAnimationForCurrentTransition.get();
|
|
312
|
+
const vMode = animationMode.get();
|
|
313
|
+
animationMode.set("idle");
|
|
314
|
+
if (skipKeyboardAnimation) {
|
|
315
|
+
skipKeyboardAnimationForCurrentTransition.set(false);
|
|
316
|
+
didInteractive.set(false);
|
|
317
|
+
isOpening.set(false);
|
|
318
|
+
isKeyboardOpen.set(false);
|
|
319
|
+
keyboardHeight.set(0);
|
|
320
|
+
if (!horizontal) {
|
|
321
|
+
keyboardInset.set(0);
|
|
322
|
+
runOnJS(reportContentInset)(0);
|
|
323
|
+
runOnJS(updateAlignItemsAtEndMinSize)(0);
|
|
324
|
+
}
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (vMode === "running") {
|
|
328
|
+
const progress = clampProgress(event.progress);
|
|
329
|
+
const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromInset(keyboardHeight.get());
|
|
330
|
+
const vIsOpening = isOpening.get();
|
|
331
|
+
if (!wasInteractive) {
|
|
332
|
+
const targetOffset = calculateKeyboardTargetOffset(
|
|
333
|
+
scrollOffsetAtKeyboardStart.get(),
|
|
334
|
+
vEffectiveKeyboardHeight,
|
|
335
|
+
vIsOpening,
|
|
336
|
+
progress
|
|
337
|
+
);
|
|
338
|
+
scrollOffsetY.set(targetOffset);
|
|
339
|
+
animatedOffsetY.set(targetOffset);
|
|
340
|
+
}
|
|
341
|
+
runOnJS(setScrollProcessingEnabled)(true);
|
|
342
|
+
didInteractive.set(false);
|
|
343
|
+
isKeyboardOpen.set(event.height > 0);
|
|
344
|
+
if (event.height > 0) {
|
|
345
|
+
keyboardHeight.set(calculateKeyboardInset(event.height, safeAreaInsetBottom));
|
|
346
|
+
}
|
|
347
|
+
if (!horizontal) {
|
|
348
|
+
const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
|
|
349
|
+
keyboardInset.set(newInset);
|
|
350
|
+
runOnJS(reportContentInset)(newInset);
|
|
351
|
+
if (!vIsOpening) {
|
|
352
|
+
runOnJS(updateAlignItemsAtEndMinSize)(newInset);
|
|
353
|
+
}
|
|
354
|
+
if (newInset <= 0) {
|
|
355
|
+
animatedOffsetY.set(scrollOffsetY.get());
|
|
356
|
+
}
|
|
357
|
+
}
|
|
100
358
|
}
|
|
101
|
-
runOnJS(setScrollProcessingEnabled)(true);
|
|
102
359
|
}
|
|
103
360
|
},
|
|
104
|
-
[
|
|
361
|
+
[
|
|
362
|
+
alignItemsAtEnd,
|
|
363
|
+
clearAlignItemsAtEndMinSize,
|
|
364
|
+
getEffectiveKeyboardHeightFromEvent,
|
|
365
|
+
getEffectiveKeyboardHeightFromInset,
|
|
366
|
+
horizontal,
|
|
367
|
+
reportContentInset,
|
|
368
|
+
safeAreaInsetBottom,
|
|
369
|
+
scrollViewRef,
|
|
370
|
+
setScrollProcessingEnabled,
|
|
371
|
+
updateAlignItemsAtEndMinSize
|
|
372
|
+
]
|
|
105
373
|
);
|
|
106
374
|
const animatedProps = useAnimatedProps(() => {
|
|
107
375
|
"worklet";
|
|
108
376
|
var _a, _b, _c, _d;
|
|
377
|
+
const vAnimatedOffsetY = animatedOffsetY.get();
|
|
109
378
|
const baseProps = {
|
|
110
|
-
contentOffset:
|
|
379
|
+
contentOffset: vAnimatedOffsetY === null ? void 0 : {
|
|
111
380
|
x: 0,
|
|
112
|
-
y:
|
|
381
|
+
y: vAnimatedOffsetY
|
|
113
382
|
}
|
|
114
383
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
384
|
+
if (isIos) {
|
|
385
|
+
const keyboardInsetBottom = keyboardInset.get();
|
|
386
|
+
const contentInset = {
|
|
387
|
+
bottom: ((_a = contentInsetProp == null ? void 0 : contentInsetProp.bottom) != null ? _a : 0) + (horizontal ? 0 : keyboardInsetBottom),
|
|
118
388
|
left: (_b = contentInsetProp == null ? void 0 : contentInsetProp.left) != null ? _b : 0,
|
|
119
389
|
right: (_c = contentInsetProp == null ? void 0 : contentInsetProp.right) != null ? _c : 0,
|
|
120
390
|
top: (_d = contentInsetProp == null ? void 0 : contentInsetProp.top) != null ? _d : 0
|
|
121
|
-
}
|
|
122
|
-
|
|
391
|
+
};
|
|
392
|
+
return Object.assign(baseProps, {
|
|
393
|
+
contentInset
|
|
394
|
+
});
|
|
395
|
+
} else {
|
|
396
|
+
return baseProps;
|
|
397
|
+
}
|
|
123
398
|
});
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
399
|
+
const androidAnimatedStyle = useAnimatedStyle(
|
|
400
|
+
() => ({
|
|
401
|
+
...styleFlattened || {},
|
|
402
|
+
marginBottom: keyboardInset.get()
|
|
403
|
+
}),
|
|
404
|
+
[styleProp, keyboardInset]
|
|
405
|
+
);
|
|
406
|
+
const style = isAndroid ? androidAnimatedStyle : styleProp;
|
|
407
|
+
const contentContainerStyle = useMemo(() => {
|
|
408
|
+
if (alignItemsAtEndMinSize === void 0) {
|
|
409
|
+
return contentContainerStyleProp;
|
|
410
|
+
}
|
|
411
|
+
const minSizeStyle = horizontal ? { minWidth: alignItemsAtEndMinSize } : { minHeight: alignItemsAtEndMinSize };
|
|
412
|
+
return contentContainerStyleProp ? [contentContainerStyleProp, minSizeStyle] : minSizeStyle;
|
|
413
|
+
}, [alignItemsAtEndMinSize, contentContainerStyleProp, horizontal]);
|
|
127
414
|
return /* @__PURE__ */ React.createElement(
|
|
128
415
|
AnimatedLegendList,
|
|
129
416
|
{
|
|
130
417
|
...rest,
|
|
131
418
|
animatedProps,
|
|
419
|
+
automaticallyAdjustContentInsets: false,
|
|
420
|
+
contentContainerStyle,
|
|
132
421
|
keyboardDismissMode: "interactive",
|
|
133
|
-
|
|
422
|
+
onContentSizeChange: handleContentSizeChange,
|
|
423
|
+
onLayout: handleLayout,
|
|
424
|
+
onMetricsChange: handleMetricsChange,
|
|
425
|
+
onScroll: finalScrollHandler,
|
|
134
426
|
ref: combinedRef,
|
|
135
427
|
refScrollView: scrollViewRef,
|
|
136
428
|
scrollIndicatorInsets: { bottom: 0, top: 0 },
|
|
@@ -139,4 +431,4 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
139
431
|
);
|
|
140
432
|
});
|
|
141
433
|
|
|
142
|
-
export { KeyboardAvoidingLegendList
|
|
434
|
+
export { KeyboardAvoidingLegendList };
|
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.50",
|
|
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,
|
|
@@ -8,6 +8,73 @@
|
|
|
8
8
|
"module": "./index.mjs",
|
|
9
9
|
"types": "./index.d.ts",
|
|
10
10
|
"react-native": "./index.native.js",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./index.d.ts",
|
|
14
|
+
"react-native": "./index.native.js",
|
|
15
|
+
"import": "./index.mjs",
|
|
16
|
+
"require": "./index.js",
|
|
17
|
+
"default": "./index.js"
|
|
18
|
+
},
|
|
19
|
+
"./animated": {
|
|
20
|
+
"types": "./animated.d.ts",
|
|
21
|
+
"import": "./animated.mjs",
|
|
22
|
+
"require": "./animated.js",
|
|
23
|
+
"default": "./animated.js"
|
|
24
|
+
},
|
|
25
|
+
"./keyboard": {
|
|
26
|
+
"types": "./keyboard.d.ts",
|
|
27
|
+
"import": "./keyboard.mjs",
|
|
28
|
+
"require": "./keyboard.js",
|
|
29
|
+
"default": "./keyboard.js"
|
|
30
|
+
},
|
|
31
|
+
"./keyboard-chat": {
|
|
32
|
+
"types": "./keyboard-chat.d.ts",
|
|
33
|
+
"import": "./keyboard-chat.mjs",
|
|
34
|
+
"require": "./keyboard-chat.js",
|
|
35
|
+
"default": "./keyboard-chat.js"
|
|
36
|
+
},
|
|
37
|
+
"./keyboard-test": {
|
|
38
|
+
"types": "./keyboard-test.d.ts",
|
|
39
|
+
"import": "./keyboard-test.mjs",
|
|
40
|
+
"require": "./keyboard-test.js",
|
|
41
|
+
"default": "./keyboard-test.js"
|
|
42
|
+
},
|
|
43
|
+
"./reanimated": {
|
|
44
|
+
"types": "./reanimated.d.ts",
|
|
45
|
+
"import": "./reanimated.mjs",
|
|
46
|
+
"require": "./reanimated.js",
|
|
47
|
+
"default": "./reanimated.js"
|
|
48
|
+
},
|
|
49
|
+
"./react-native": {
|
|
50
|
+
"types": "./react-native.d.ts",
|
|
51
|
+
"browser": {
|
|
52
|
+
"import": "./react-native.web.mjs",
|
|
53
|
+
"require": "./react-native.web.js",
|
|
54
|
+
"default": "./react-native.web.js"
|
|
55
|
+
},
|
|
56
|
+
"react-native": {
|
|
57
|
+
"import": "./react-native.mjs",
|
|
58
|
+
"require": "./react-native.js",
|
|
59
|
+
"default": "./react-native.js"
|
|
60
|
+
},
|
|
61
|
+
"import": "./react-native.web.mjs",
|
|
62
|
+
"require": "./react-native.web.js",
|
|
63
|
+
"default": "./react-native.web.js"
|
|
64
|
+
},
|
|
65
|
+
"./section-list": {
|
|
66
|
+
"types": "./section-list.d.ts",
|
|
67
|
+
"import": "./section-list.mjs",
|
|
68
|
+
"require": "./section-list.js",
|
|
69
|
+
"default": "./section-list.js"
|
|
70
|
+
},
|
|
71
|
+
"./react": {
|
|
72
|
+
"types": "./react.d.ts",
|
|
73
|
+
"import": "./react.mjs",
|
|
74
|
+
"require": "./react.js",
|
|
75
|
+
"default": "./react.js"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
11
78
|
"files": [
|
|
12
79
|
"**"
|
|
13
80
|
],
|