@legendapp/list 3.0.0-beta.32 → 3.0.0-beta.34
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/README.md +7 -1
- package/animated.d.ts +605 -6
- package/animated.js +2 -2
- package/animated.mjs +1 -1
- package/index.d.ts +503 -118
- package/index.js +607 -275
- package/index.mjs +607 -275
- package/index.native.js +348 -189
- package/index.native.mjs +347 -188
- package/keyboard-controller.d.ts +616 -6
- package/keyboard-controller.js +2 -2
- package/keyboard-controller.mjs +1 -1
- package/keyboard.d.ts +204 -8
- package/keyboard.js +68 -53
- package/keyboard.mjs +71 -55
- package/{index.d.mts → list-react-native.d.ts} +138 -42
- package/list-react-native.js +4348 -0
- package/list-react-native.mjs +4318 -0
- package/{index.native.d.mts → list-react.d.ts} +195 -42
- package/list-react.js +4709 -0
- package/list-react.mjs +4679 -0
- package/package.json +52 -1
- package/reanimated.d.ts +605 -7
- package/reanimated.js +180 -12
- package/reanimated.mjs +177 -9
- package/section-list.d.ts +615 -14
- package/section-list.js +6 -6
- package/section-list.mjs +1 -1
- package/animated.d.mts +0 -9
- package/animated.native.d.mts +0 -9
- package/animated.native.d.ts +0 -9
- package/animated.native.js +0 -9
- package/animated.native.mjs +0 -7
- package/index.native.d.ts +0 -817
- package/keyboard-controller.d.mts +0 -12
- package/keyboard-controller.native.d.mts +0 -12
- package/keyboard-controller.native.d.ts +0 -12
- package/keyboard-controller.native.js +0 -69
- package/keyboard-controller.native.mjs +0 -48
- package/keyboard.d.mts +0 -13
- package/keyboard.native.d.mts +0 -13
- package/keyboard.native.d.ts +0 -13
- package/keyboard.native.js +0 -399
- package/keyboard.native.mjs +0 -377
- package/reanimated.d.mts +0 -18
- package/reanimated.native.d.mts +0 -18
- package/reanimated.native.d.ts +0 -18
- package/reanimated.native.js +0 -89
- package/reanimated.native.mjs +0 -65
- package/section-list.d.mts +0 -112
- package/section-list.native.d.mts +0 -112
- package/section-list.native.d.ts +0 -112
- package/section-list.native.js +0 -293
- package/section-list.native.mjs +0 -271
package/keyboard.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useRef, useState, useMemo, useCallback, useEffect, forwardRef } from 'react';
|
|
3
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
6
|
import { AnimatedLegendList } from '@legendapp/list/reanimated';
|
|
7
7
|
|
|
8
8
|
// src/integrations/keyboard.tsx
|
|
@@ -28,6 +28,7 @@ var useCombinedRef = (...refs) => {
|
|
|
28
28
|
}, refs);
|
|
29
29
|
return callback;
|
|
30
30
|
};
|
|
31
|
+
var typedForwardRef = forwardRef;
|
|
31
32
|
|
|
32
33
|
// src/integrations/keyboard.tsx
|
|
33
34
|
var clampProgress = (progress) => {
|
|
@@ -53,7 +54,7 @@ var calculateKeyboardTargetOffset = (startOffset, keyboardHeight, isOpening, pro
|
|
|
53
54
|
const delta = (isOpening ? keyboardHeight : -keyboardHeight) * normalizedProgress;
|
|
54
55
|
return Math.max(0, startOffset + delta);
|
|
55
56
|
};
|
|
56
|
-
var KeyboardAvoidingLegendList =
|
|
57
|
+
var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
|
|
57
58
|
const {
|
|
58
59
|
contentContainerStyle: contentContainerStyleProp,
|
|
59
60
|
contentInset: contentInsetProp,
|
|
@@ -74,7 +75,7 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
74
75
|
const scrollOffsetY = useSharedValue(0);
|
|
75
76
|
const animatedOffsetY = useSharedValue(null);
|
|
76
77
|
const scrollOffsetAtKeyboardStart = useSharedValue(0);
|
|
77
|
-
const
|
|
78
|
+
const animationMode = useSharedValue("idle");
|
|
78
79
|
const keyboardInset = useSharedValue(0);
|
|
79
80
|
const keyboardHeight = useSharedValue(0);
|
|
80
81
|
const contentLength = useSharedValue(0);
|
|
@@ -85,17 +86,33 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
85
86
|
const isKeyboardOpen = useSharedValue(false);
|
|
86
87
|
const keyboardInsetRef = useRef(0);
|
|
87
88
|
const [alignItemsAtEndMinSize, setAlignItemsAtEndMinSize] = useState(void 0);
|
|
89
|
+
const onScrollValue = onScrollProp;
|
|
90
|
+
const onScrollCallback = typeof onScrollValue === "function" ? onScrollValue : void 0;
|
|
91
|
+
const onScrollProcessed = onScrollValue && typeof onScrollValue === "object" && "workletEventHandler" in onScrollValue ? onScrollValue : null;
|
|
92
|
+
const onScrollCallbackIsWorklet = useMemo(
|
|
93
|
+
() => onScrollCallback ? isWorkletFunction(onScrollCallback) : false,
|
|
94
|
+
[onScrollCallback]
|
|
95
|
+
);
|
|
88
96
|
const scrollHandler = useAnimatedScrollHandler(
|
|
89
97
|
(event) => {
|
|
90
|
-
if (
|
|
98
|
+
if (animationMode.get() !== "running" || didInteractive.get()) {
|
|
91
99
|
scrollOffsetY.set(event.contentOffset[horizontal ? "x" : "y"]);
|
|
92
100
|
}
|
|
93
|
-
if (
|
|
94
|
-
|
|
101
|
+
if (onScrollCallback) {
|
|
102
|
+
if (onScrollCallbackIsWorklet) {
|
|
103
|
+
onScrollCallback(event);
|
|
104
|
+
} else {
|
|
105
|
+
runOnJS(onScrollCallback)(event);
|
|
106
|
+
}
|
|
95
107
|
}
|
|
96
108
|
},
|
|
97
|
-
[
|
|
109
|
+
[horizontal, onScrollCallback, onScrollCallbackIsWorklet]
|
|
98
110
|
);
|
|
111
|
+
const composedScrollHandler = useComposedEventHandler([
|
|
112
|
+
scrollHandler,
|
|
113
|
+
onScrollProcessed
|
|
114
|
+
]);
|
|
115
|
+
const finalScrollHandler = onScrollProcessed ? composedScrollHandler : scrollHandler;
|
|
99
116
|
const setScrollProcessingEnabled = useCallback(
|
|
100
117
|
(enabled) => {
|
|
101
118
|
var _a;
|
|
@@ -163,19 +180,39 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
163
180
|
useEffect(() => {
|
|
164
181
|
updateAlignItemsAtEndMinSize();
|
|
165
182
|
}, [updateAlignItemsAtEndMinSize]);
|
|
183
|
+
const getEffectiveKeyboardHeightFromInset = useCallback(
|
|
184
|
+
(nextKeyboardInset) => {
|
|
185
|
+
"worklet";
|
|
186
|
+
return calculateEffectiveKeyboardHeight(
|
|
187
|
+
nextKeyboardInset,
|
|
188
|
+
contentLength.get(),
|
|
189
|
+
scrollLength.get(),
|
|
190
|
+
alignItemsAtEnd
|
|
191
|
+
);
|
|
192
|
+
},
|
|
193
|
+
[alignItemsAtEnd, contentLength, scrollLength]
|
|
194
|
+
);
|
|
195
|
+
const getEffectiveKeyboardHeightFromEvent = useCallback(
|
|
196
|
+
(eventHeight) => {
|
|
197
|
+
"worklet";
|
|
198
|
+
const nextKeyboardInset = calculateKeyboardInset(eventHeight, safeAreaInsetBottom);
|
|
199
|
+
return getEffectiveKeyboardHeightFromInset(nextKeyboardInset);
|
|
200
|
+
},
|
|
201
|
+
[getEffectiveKeyboardHeightFromInset, safeAreaInsetBottom]
|
|
202
|
+
);
|
|
166
203
|
useKeyboardHandler(
|
|
167
204
|
// biome-ignore assist/source/useSortedKeys: prefer start/move/end
|
|
168
205
|
{
|
|
169
206
|
onStart: (event) => {
|
|
170
207
|
"worklet";
|
|
171
|
-
|
|
208
|
+
animationMode.set("running");
|
|
172
209
|
const progress = clampProgress(event.progress);
|
|
173
210
|
if (isKeyboardOpen.get() && progress >= 1 && event.height > 0) {
|
|
174
211
|
return;
|
|
175
212
|
}
|
|
176
213
|
if (!didInteractive.get()) {
|
|
177
214
|
if (event.height > 0) {
|
|
178
|
-
keyboardHeight.set(event.height
|
|
215
|
+
keyboardHeight.set(calculateKeyboardInset(event.height, safeAreaInsetBottom));
|
|
179
216
|
}
|
|
180
217
|
const vIsOpening = progress > 0;
|
|
181
218
|
isOpening.set(vIsOpening);
|
|
@@ -188,15 +225,7 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
188
225
|
const vScrollOffset = scrollOffsetY.get();
|
|
189
226
|
scrollOffsetAtKeyboardStart.set(vScrollOffset);
|
|
190
227
|
if (isIos) {
|
|
191
|
-
const
|
|
192
|
-
const vScrollLength = scrollLength.get();
|
|
193
|
-
const vKeyboardHeight = keyboardHeight.get();
|
|
194
|
-
const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
|
|
195
|
-
vKeyboardHeight,
|
|
196
|
-
vContentLength,
|
|
197
|
-
vScrollLength,
|
|
198
|
-
alignItemsAtEnd
|
|
199
|
-
);
|
|
228
|
+
const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromInset(keyboardHeight.get());
|
|
200
229
|
const targetOffset = Math.max(
|
|
201
230
|
0,
|
|
202
231
|
vIsOpening ? vScrollOffset + vEffectiveKeyboardHeight : vScrollOffset - vEffectiveKeyboardHeight
|
|
@@ -213,10 +242,10 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
213
242
|
},
|
|
214
243
|
onInteractive: (event) => {
|
|
215
244
|
"worklet";
|
|
216
|
-
if (
|
|
245
|
+
if (animationMode.get() !== "running") {
|
|
217
246
|
runOnJS(setScrollProcessingEnabled)(false);
|
|
218
247
|
}
|
|
219
|
-
|
|
248
|
+
animationMode.set("running");
|
|
220
249
|
if (!didInteractive.get()) {
|
|
221
250
|
didInteractive.set(true);
|
|
222
251
|
}
|
|
@@ -225,13 +254,7 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
225
254
|
keyboardInset.set(newInset);
|
|
226
255
|
}
|
|
227
256
|
if (shouldUpdateAlignItemsAtEndMinSize.get() && !horizontal && alignItemsAtEnd) {
|
|
228
|
-
const
|
|
229
|
-
const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
|
|
230
|
-
vKeyboardHeight,
|
|
231
|
-
contentLength.get(),
|
|
232
|
-
scrollLength.get(),
|
|
233
|
-
alignItemsAtEnd
|
|
234
|
-
);
|
|
257
|
+
const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromEvent(event.height);
|
|
235
258
|
runOnJS(updateAlignItemsAtEndMinSize)(vEffectiveKeyboardHeight);
|
|
236
259
|
}
|
|
237
260
|
},
|
|
@@ -241,13 +264,7 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
241
264
|
if (isAndroid) {
|
|
242
265
|
if (!didInteractive.get()) {
|
|
243
266
|
const progress = clampProgress(event.progress);
|
|
244
|
-
const
|
|
245
|
-
const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
|
|
246
|
-
vKeyboardHeight,
|
|
247
|
-
contentLength.get(),
|
|
248
|
-
scrollLength.get(),
|
|
249
|
-
alignItemsAtEnd
|
|
250
|
-
);
|
|
267
|
+
const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromInset(keyboardHeight.get());
|
|
251
268
|
const targetOffset = calculateKeyboardTargetOffset(
|
|
252
269
|
scrollOffsetAtKeyboardStart.get(),
|
|
253
270
|
vEffectiveKeyboardHeight,
|
|
@@ -263,30 +280,18 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
263
280
|
}
|
|
264
281
|
}
|
|
265
282
|
if (!horizontal && alignItemsAtEnd && !vIsOpening && shouldUpdateAlignItemsAtEndMinSize.get()) {
|
|
266
|
-
const
|
|
267
|
-
const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
|
|
268
|
-
vKeyboardHeight,
|
|
269
|
-
contentLength.get(),
|
|
270
|
-
scrollLength.get(),
|
|
271
|
-
alignItemsAtEnd
|
|
272
|
-
);
|
|
283
|
+
const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromEvent(event.height);
|
|
273
284
|
runOnJS(updateAlignItemsAtEndMinSize)(vEffectiveKeyboardHeight);
|
|
274
285
|
}
|
|
275
286
|
},
|
|
276
287
|
onEnd: (event) => {
|
|
277
288
|
"worklet";
|
|
278
289
|
const wasInteractive = didInteractive.get();
|
|
279
|
-
const vMode =
|
|
280
|
-
|
|
290
|
+
const vMode = animationMode.get();
|
|
291
|
+
animationMode.set("idle");
|
|
281
292
|
if (vMode === "running") {
|
|
282
293
|
const progress = clampProgress(event.progress);
|
|
283
|
-
const
|
|
284
|
-
const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
|
|
285
|
-
vKeyboardHeight,
|
|
286
|
-
contentLength.get(),
|
|
287
|
-
scrollLength.get(),
|
|
288
|
-
alignItemsAtEnd
|
|
289
|
-
);
|
|
294
|
+
const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromInset(keyboardHeight.get());
|
|
290
295
|
const vIsOpening = isOpening.get();
|
|
291
296
|
if (!wasInteractive) {
|
|
292
297
|
const targetOffset = calculateKeyboardTargetOffset(
|
|
@@ -315,7 +320,18 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
315
320
|
}
|
|
316
321
|
}
|
|
317
322
|
},
|
|
318
|
-
[
|
|
323
|
+
[
|
|
324
|
+
alignItemsAtEnd,
|
|
325
|
+
clearAlignItemsAtEndMinSize,
|
|
326
|
+
getEffectiveKeyboardHeightFromEvent,
|
|
327
|
+
getEffectiveKeyboardHeightFromInset,
|
|
328
|
+
horizontal,
|
|
329
|
+
reportContentInset,
|
|
330
|
+
safeAreaInsetBottom,
|
|
331
|
+
scrollViewRef,
|
|
332
|
+
setScrollProcessingEnabled,
|
|
333
|
+
updateAlignItemsAtEndMinSize
|
|
334
|
+
]
|
|
319
335
|
);
|
|
320
336
|
const animatedProps = useAnimatedProps(() => {
|
|
321
337
|
"worklet";
|
|
@@ -348,7 +364,7 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
348
364
|
marginBottom: keyboardInset.get()
|
|
349
365
|
}),
|
|
350
366
|
[styleProp, keyboardInset]
|
|
351
|
-
) :
|
|
367
|
+
) : styleProp;
|
|
352
368
|
const contentContainerStyle = useMemo(() => {
|
|
353
369
|
if (alignItemsAtEndMinSize === void 0) {
|
|
354
370
|
return contentContainerStyleProp;
|
|
@@ -365,7 +381,7 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
365
381
|
contentContainerStyle,
|
|
366
382
|
keyboardDismissMode: "interactive",
|
|
367
383
|
onMetricsChange: handleMetricsChange,
|
|
368
|
-
onScroll:
|
|
384
|
+
onScroll: finalScrollHandler,
|
|
369
385
|
ref: combinedRef,
|
|
370
386
|
refScrollView: scrollViewRef,
|
|
371
387
|
scrollIndicatorInsets: { bottom: 0, top: 0 },
|
|
@@ -374,4 +390,4 @@ var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2
|
|
|
374
390
|
);
|
|
375
391
|
});
|
|
376
392
|
|
|
377
|
-
export { KeyboardAvoidingLegendList
|
|
393
|
+
export { KeyboardAvoidingLegendList };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
|
-
import { Key,
|
|
3
|
-
import {
|
|
4
|
-
import Reanimated from 'react-native-reanimated';
|
|
2
|
+
import { Key, ReactNode, ReactElement, Dispatch, SetStateAction } from 'react';
|
|
3
|
+
import { ScrollViewProps, NativeSyntheticEvent as NativeSyntheticEvent$1, NativeScrollEvent as NativeScrollEvent$1, ScrollView, StyleProp as StyleProp$1, ViewStyle as ViewStyle$1, ScrollViewComponent, ScrollResponderMixin, Insets as Insets$1, View } from 'react-native';
|
|
5
4
|
|
|
6
5
|
type AnimatedValue = number;
|
|
7
6
|
|
|
7
|
+
type LooseMeasureCallback = (x: number, y: number, width: number, height: number, pageX: number, pageY: number) => void;
|
|
8
|
+
interface LooseView {
|
|
9
|
+
measure?: (callback: LooseMeasureCallback) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
type ListenerType = "activeStickyIndex" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
|
|
9
13
|
type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
|
|
10
14
|
type ListenerTypeValueMap = {
|
|
@@ -65,7 +69,7 @@ interface StateContext {
|
|
|
65
69
|
positionListeners: Map<string, Set<(value: any) => void>>;
|
|
66
70
|
state: InternalState;
|
|
67
71
|
values: Map<ListenerType, any>;
|
|
68
|
-
viewRefs: Map<number, React$1.RefObject<
|
|
72
|
+
viewRefs: Map<number, React$1.RefObject<LooseView>>;
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
declare class ScrollAdjustHandler {
|
|
@@ -85,6 +89,62 @@ type StylesAsSharedValue<Style> = {
|
|
|
85
89
|
[key in keyof Style]: Style[key] | BaseSharedValue<Style[key]>;
|
|
86
90
|
};
|
|
87
91
|
|
|
92
|
+
interface Insets {
|
|
93
|
+
top: number;
|
|
94
|
+
left: number;
|
|
95
|
+
bottom: number;
|
|
96
|
+
right: number;
|
|
97
|
+
}
|
|
98
|
+
interface LayoutRectangle {
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
width: number;
|
|
102
|
+
height: number;
|
|
103
|
+
}
|
|
104
|
+
interface NativeScrollEvent {
|
|
105
|
+
contentOffset: {
|
|
106
|
+
x: number;
|
|
107
|
+
y: number;
|
|
108
|
+
};
|
|
109
|
+
contentSize: {
|
|
110
|
+
width: number;
|
|
111
|
+
height: number;
|
|
112
|
+
};
|
|
113
|
+
layoutMeasurement: {
|
|
114
|
+
width: number;
|
|
115
|
+
height: number;
|
|
116
|
+
};
|
|
117
|
+
contentInset: Insets;
|
|
118
|
+
zoomScale: number;
|
|
119
|
+
}
|
|
120
|
+
interface NativeSyntheticEvent<T> {
|
|
121
|
+
nativeEvent: T;
|
|
122
|
+
}
|
|
123
|
+
type ViewStyle = Record<string, unknown>;
|
|
124
|
+
type StyleProp<T> = T | T[] | null | undefined | false;
|
|
125
|
+
interface ScrollEventTargetLike {
|
|
126
|
+
addEventListener(type: string, listener: (...args: any[]) => void): void;
|
|
127
|
+
removeEventListener(type: string, listener: (...args: any[]) => void): void;
|
|
128
|
+
}
|
|
129
|
+
interface ScrollableNodeLike {
|
|
130
|
+
scrollLeft?: number;
|
|
131
|
+
scrollTop?: number;
|
|
132
|
+
}
|
|
133
|
+
interface LegendListScrollerRef {
|
|
134
|
+
flashScrollIndicators(): void;
|
|
135
|
+
getCurrentScrollOffset?(): number;
|
|
136
|
+
getScrollEventTarget(): ScrollEventTargetLike | null;
|
|
137
|
+
getScrollableNode(): ScrollableNodeLike | null;
|
|
138
|
+
getScrollResponder(): unknown;
|
|
139
|
+
scrollTo(options: {
|
|
140
|
+
animated?: boolean;
|
|
141
|
+
x?: number;
|
|
142
|
+
y?: number;
|
|
143
|
+
}): void;
|
|
144
|
+
scrollToEnd(options?: {
|
|
145
|
+
animated?: boolean;
|
|
146
|
+
}): void;
|
|
147
|
+
}
|
|
88
148
|
type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
|
|
89
149
|
interface DataModeProps<ItemT, TItemType extends string | undefined> {
|
|
90
150
|
/**
|
|
@@ -241,6 +301,11 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
|
|
|
241
301
|
* - true enables both behaviors; false disables both.
|
|
242
302
|
*/
|
|
243
303
|
maintainVisibleContentPosition?: boolean | MaintainVisibleContentPositionConfig<ItemT>;
|
|
304
|
+
/**
|
|
305
|
+
* Web only: when true, listens to window/body scrolling instead of rendering a scrollable list container.
|
|
306
|
+
* @default false
|
|
307
|
+
*/
|
|
308
|
+
useWindowScroll?: boolean;
|
|
244
309
|
/**
|
|
245
310
|
* Number of columns to render items in.
|
|
246
311
|
* @default 1
|
|
@@ -311,7 +376,7 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
|
|
|
311
376
|
/**
|
|
312
377
|
* Ref to the underlying ScrollView component.
|
|
313
378
|
*/
|
|
314
|
-
refScrollView?: React.Ref<
|
|
379
|
+
refScrollView?: React.Ref<any>;
|
|
315
380
|
/**
|
|
316
381
|
* If true, shows a refresh indicator.
|
|
317
382
|
* @default false
|
|
@@ -322,7 +387,7 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
|
|
|
322
387
|
* Note: When using `stickyHeaderIndices`, you must provide an Animated ScrollView component.
|
|
323
388
|
* @default (props) => <ScrollView {...props} />
|
|
324
389
|
*/
|
|
325
|
-
renderScrollComponent?: (props:
|
|
390
|
+
renderScrollComponent?: (props: any) => React.ReactElement | null;
|
|
326
391
|
/**
|
|
327
392
|
* This will log a suggested estimatedItemSize.
|
|
328
393
|
* @required
|
|
@@ -366,7 +431,8 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
|
|
|
366
431
|
getFixedItemSize?: (item: ItemT, index: number, type: TItemType) => number | undefined;
|
|
367
432
|
itemsAreEqual?: (itemPrevious: ItemT, item: ItemT, index: number, data: readonly ItemT[]) => boolean;
|
|
368
433
|
}
|
|
369
|
-
type LegendListPropsBase<ItemT,
|
|
434
|
+
type LegendListPropsBase<ItemT, TScrollViewProps = Record<string, any>, TItemType extends string | undefined = string | undefined> = BaseScrollViewProps<TScrollViewProps> & LegendListSpecificProps<ItemT, TItemType> & (DataModeProps<ItemT, TItemType> | ChildrenModeProps);
|
|
435
|
+
type LegendListPropsInternal = LegendListSpecificProps<any, string | undefined> & DataModeProps<any, string | undefined>;
|
|
370
436
|
interface MaintainVisibleContentPositionConfig<ItemT = any> {
|
|
371
437
|
data?: boolean;
|
|
372
438
|
size?: boolean;
|
|
@@ -410,7 +476,6 @@ interface LegendListMetrics {
|
|
|
410
476
|
headerSize: number;
|
|
411
477
|
footerSize: number;
|
|
412
478
|
}
|
|
413
|
-
type LegendListProps<ItemT = any> = LegendListPropsBase<ItemT, ComponentProps<typeof ScrollView>>;
|
|
414
479
|
interface ThresholdSnapshot {
|
|
415
480
|
scrollPosition: number;
|
|
416
481
|
contentSize?: number;
|
|
@@ -435,10 +500,11 @@ interface InternalState {
|
|
|
435
500
|
num: number;
|
|
436
501
|
avg: number;
|
|
437
502
|
}>;
|
|
438
|
-
columns:
|
|
439
|
-
columnSpans:
|
|
503
|
+
columns: Array<number | undefined>;
|
|
504
|
+
columnSpans: Array<number | undefined>;
|
|
440
505
|
containerItemKeys: Map<string, number>;
|
|
441
506
|
containerItemTypes: Map<number, string>;
|
|
507
|
+
dataChangeEpoch: number;
|
|
442
508
|
dataChangeNeedsScrollUpdate: boolean;
|
|
443
509
|
didColumnsChange?: boolean;
|
|
444
510
|
didDataChange?: boolean;
|
|
@@ -485,12 +551,13 @@ interface InternalState {
|
|
|
485
551
|
needsOtherAxisSize?: boolean;
|
|
486
552
|
otherAxisSize?: number;
|
|
487
553
|
pendingTotalSize?: number;
|
|
488
|
-
|
|
554
|
+
pendingScrollResolve?: (() => void) | undefined;
|
|
555
|
+
positions: Array<number | undefined>;
|
|
489
556
|
previousData?: readonly unknown[];
|
|
490
557
|
queuedCalculateItemsInView: number | undefined;
|
|
491
558
|
queuedMVCPRecalculate?: number;
|
|
492
559
|
queuedInitialLayout?: boolean | undefined;
|
|
493
|
-
refScroller: React.RefObject<
|
|
560
|
+
refScroller: React.RefObject<LegendListScrollerRef | null>;
|
|
494
561
|
scroll: number;
|
|
495
562
|
scrollAdjustHandler: ScrollAdjustHandler;
|
|
496
563
|
scrollForNextCalculateItemsInView: {
|
|
@@ -514,6 +581,7 @@ interface InternalState {
|
|
|
514
581
|
startBuffered: number;
|
|
515
582
|
startBufferedId?: string;
|
|
516
583
|
startNoBuffer: number;
|
|
584
|
+
startReachedSnapshotDataChangeEpoch: number | undefined;
|
|
517
585
|
startReachedSnapshot: ThresholdSnapshot | undefined;
|
|
518
586
|
stickyContainerPool: Set<number>;
|
|
519
587
|
stickyContainers: Map<number, number>;
|
|
@@ -530,7 +598,7 @@ interface InternalState {
|
|
|
530
598
|
viewabilityConfigCallbackPairs: ViewabilityConfigCallbackPairs<any> | undefined;
|
|
531
599
|
props: {
|
|
532
600
|
alignItemsAtEnd: boolean;
|
|
533
|
-
animatedProps: StylesAsSharedValue<
|
|
601
|
+
animatedProps: StylesAsSharedValue<Record<string, any>>;
|
|
534
602
|
alwaysRender: AlwaysRenderConfig | undefined;
|
|
535
603
|
alwaysRenderIndicesArr: number[];
|
|
536
604
|
alwaysRenderIndicesSet: Set<number>;
|
|
@@ -539,34 +607,38 @@ interface InternalState {
|
|
|
539
607
|
dataVersion: Key | undefined;
|
|
540
608
|
drawDistance: number;
|
|
541
609
|
estimatedItemSize: number | undefined;
|
|
542
|
-
getEstimatedItemSize:
|
|
543
|
-
getFixedItemSize:
|
|
544
|
-
getItemType:
|
|
610
|
+
getEstimatedItemSize: LegendListPropsInternal["getEstimatedItemSize"];
|
|
611
|
+
getFixedItemSize: LegendListPropsInternal["getFixedItemSize"];
|
|
612
|
+
getItemType: LegendListPropsInternal["getItemType"];
|
|
545
613
|
horizontal: boolean;
|
|
546
614
|
initialContainerPoolRatio: number;
|
|
547
|
-
itemsAreEqual:
|
|
548
|
-
keyExtractor:
|
|
615
|
+
itemsAreEqual: LegendListPropsInternal["itemsAreEqual"];
|
|
616
|
+
keyExtractor: LegendListPropsInternal["keyExtractor"];
|
|
549
617
|
maintainScrollAtEnd: boolean | MaintainScrollAtEndOptions;
|
|
550
618
|
maintainScrollAtEndThreshold: number | undefined;
|
|
551
619
|
maintainVisibleContentPosition: MaintainVisibleContentPositionNormalized;
|
|
552
620
|
numColumns: number;
|
|
553
|
-
onEndReached:
|
|
621
|
+
onEndReached: LegendListPropsInternal["onEndReached"];
|
|
554
622
|
onEndReachedThreshold: number | null | undefined;
|
|
555
|
-
onItemSizeChanged:
|
|
556
|
-
onLoad:
|
|
557
|
-
onScroll:
|
|
558
|
-
onStartReached:
|
|
623
|
+
onItemSizeChanged: LegendListPropsInternal["onItemSizeChanged"];
|
|
624
|
+
onLoad: LegendListPropsInternal["onLoad"];
|
|
625
|
+
onScroll: LegendListPropsInternal["onScroll"];
|
|
626
|
+
onStartReached: LegendListPropsInternal["onStartReached"];
|
|
559
627
|
onStartReachedThreshold: number | null | undefined;
|
|
560
|
-
onStickyHeaderChange:
|
|
561
|
-
overrideItemLayout:
|
|
628
|
+
onStickyHeaderChange: LegendListPropsInternal["onStickyHeaderChange"];
|
|
629
|
+
overrideItemLayout: LegendListPropsInternal["overrideItemLayout"];
|
|
562
630
|
recycleItems: boolean;
|
|
563
|
-
renderItem:
|
|
631
|
+
renderItem: LegendListPropsInternal["renderItem"];
|
|
632
|
+
scrollBuffer?: number;
|
|
564
633
|
snapToIndices: number[] | undefined;
|
|
634
|
+
positionComponentInternal: React.ComponentType<any> | undefined;
|
|
635
|
+
stickyPositionComponentInternal: React.ComponentType<any> | undefined;
|
|
565
636
|
stickyIndicesArr: number[];
|
|
566
637
|
stickyIndicesSet: Set<number>;
|
|
567
638
|
stylePaddingBottom: number | undefined;
|
|
568
639
|
stylePaddingTop: number | undefined;
|
|
569
640
|
suggestEstimatedItemSize: boolean;
|
|
641
|
+
useWindowScroll: boolean;
|
|
570
642
|
};
|
|
571
643
|
}
|
|
572
644
|
interface ViewableRange<T> {
|
|
@@ -583,11 +655,11 @@ interface LegendListRenderItemProps<ItemT, TItemType extends string | number | u
|
|
|
583
655
|
item: ItemT;
|
|
584
656
|
type: TItemType;
|
|
585
657
|
}
|
|
586
|
-
type LegendListState = {
|
|
658
|
+
type LegendListState$1 = {
|
|
587
659
|
activeStickyIndex: number;
|
|
588
660
|
contentLength: number;
|
|
589
661
|
data: readonly any[];
|
|
590
|
-
elementAtIndex: (index: number) =>
|
|
662
|
+
elementAtIndex: (index: number) => any;
|
|
591
663
|
end: number;
|
|
592
664
|
endBuffered: number;
|
|
593
665
|
isAtEnd: boolean;
|
|
@@ -595,7 +667,7 @@ type LegendListState = {
|
|
|
595
667
|
listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
|
|
596
668
|
listenToPosition: (key: string, callback: (value: number) => void) => () => void;
|
|
597
669
|
positionAtIndex: (index: number) => number;
|
|
598
|
-
|
|
670
|
+
positionByKey: (key: string) => number | undefined;
|
|
599
671
|
scroll: number;
|
|
600
672
|
scrollLength: number;
|
|
601
673
|
scrollVelocity: number;
|
|
@@ -604,7 +676,7 @@ type LegendListState = {
|
|
|
604
676
|
start: number;
|
|
605
677
|
startBuffered: number;
|
|
606
678
|
};
|
|
607
|
-
type LegendListRef = {
|
|
679
|
+
type LegendListRef$1 = {
|
|
608
680
|
/**
|
|
609
681
|
* Displays the scroll indicators momentarily.
|
|
610
682
|
*/
|
|
@@ -612,7 +684,7 @@ type LegendListRef = {
|
|
|
612
684
|
/**
|
|
613
685
|
* Returns the native ScrollView component reference.
|
|
614
686
|
*/
|
|
615
|
-
getNativeScrollRef():
|
|
687
|
+
getNativeScrollRef(): any;
|
|
616
688
|
/**
|
|
617
689
|
* Returns the scroll responder instance for handling scroll events.
|
|
618
690
|
*/
|
|
@@ -620,11 +692,11 @@ type LegendListRef = {
|
|
|
620
692
|
/**
|
|
621
693
|
* Returns the ScrollResponderMixin for advanced scroll handling.
|
|
622
694
|
*/
|
|
623
|
-
getScrollResponder():
|
|
695
|
+
getScrollResponder(): any;
|
|
624
696
|
/**
|
|
625
697
|
* Returns the internal state of the scroll virtualization.
|
|
626
698
|
*/
|
|
627
|
-
getState(): LegendListState;
|
|
699
|
+
getState(): LegendListState$1;
|
|
628
700
|
/**
|
|
629
701
|
* Scrolls a specific index into view.
|
|
630
702
|
* @param params - Parameters for scrolling.
|
|
@@ -634,7 +706,7 @@ type LegendListRef = {
|
|
|
634
706
|
scrollIndexIntoView(params: {
|
|
635
707
|
animated?: boolean | undefined;
|
|
636
708
|
index: number;
|
|
637
|
-
}): void
|
|
709
|
+
}): Promise<void>;
|
|
638
710
|
/**
|
|
639
711
|
* Scrolls a specific index into view.
|
|
640
712
|
* @param params - Parameters for scrolling.
|
|
@@ -644,7 +716,7 @@ type LegendListRef = {
|
|
|
644
716
|
scrollItemIntoView(params: {
|
|
645
717
|
animated?: boolean | undefined;
|
|
646
718
|
item: any;
|
|
647
|
-
}): void
|
|
719
|
+
}): Promise<void>;
|
|
648
720
|
/**
|
|
649
721
|
* Scrolls to the end of the list.
|
|
650
722
|
* @param options - Options for scrolling.
|
|
@@ -654,7 +726,7 @@ type LegendListRef = {
|
|
|
654
726
|
scrollToEnd(options?: {
|
|
655
727
|
animated?: boolean | undefined;
|
|
656
728
|
viewOffset?: number | undefined;
|
|
657
|
-
}): void
|
|
729
|
+
}): Promise<void>;
|
|
658
730
|
/**
|
|
659
731
|
* Scrolls to a specific index in the list.
|
|
660
732
|
* @param params - Parameters for scrolling.
|
|
@@ -668,7 +740,7 @@ type LegendListRef = {
|
|
|
668
740
|
index: number;
|
|
669
741
|
viewOffset?: number | undefined;
|
|
670
742
|
viewPosition?: number | undefined;
|
|
671
|
-
}): void
|
|
743
|
+
}): Promise<void>;
|
|
672
744
|
/**
|
|
673
745
|
* Scrolls to a specific item in the list.
|
|
674
746
|
* @param params - Parameters for scrolling.
|
|
@@ -682,7 +754,7 @@ type LegendListRef = {
|
|
|
682
754
|
item: any;
|
|
683
755
|
viewOffset?: number | undefined;
|
|
684
756
|
viewPosition?: number | undefined;
|
|
685
|
-
}): void
|
|
757
|
+
}): Promise<void>;
|
|
686
758
|
/**
|
|
687
759
|
* Scrolls to a specific offset in pixels.
|
|
688
760
|
* @param params - Parameters for scrolling.
|
|
@@ -692,7 +764,7 @@ type LegendListRef = {
|
|
|
692
764
|
scrollToOffset(params: {
|
|
693
765
|
offset: number;
|
|
694
766
|
animated?: boolean | undefined;
|
|
695
|
-
}): void
|
|
767
|
+
}): Promise<void>;
|
|
696
768
|
/**
|
|
697
769
|
* Sets or adds to the offset of the visible content anchor.
|
|
698
770
|
* @param value - The offset to set or add.
|
|
@@ -704,6 +776,14 @@ type LegendListRef = {
|
|
|
704
776
|
* @param enabled - If true, scroll processing is enabled.
|
|
705
777
|
*/
|
|
706
778
|
setScrollProcessingEnabled(enabled: boolean): void;
|
|
779
|
+
/**
|
|
780
|
+
* Clears internal virtualization caches.
|
|
781
|
+
* @param options - Cache clearing options.
|
|
782
|
+
* @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
|
|
783
|
+
*/
|
|
784
|
+
clearCaches(options?: {
|
|
785
|
+
mode?: "sizes" | "full";
|
|
786
|
+
}): void;
|
|
707
787
|
/**
|
|
708
788
|
* Reports an externally measured content inset. Pass null/undefined to clear.
|
|
709
789
|
* Values are merged on top of props/animated/native insets.
|
|
@@ -799,9 +879,23 @@ type GetRenderedItemResult<ItemT> = {
|
|
|
799
879
|
};
|
|
800
880
|
type GetRenderedItem = (key: string) => GetRenderedItemResult<any> | null;
|
|
801
881
|
|
|
802
|
-
|
|
803
|
-
|
|
882
|
+
type LegendListPropsOverrides<ItemT, TItemType extends string | undefined> = Omit<LegendListPropsBase<ItemT, ScrollViewProps, TItemType>, "onScroll" | "refScrollView" | "renderScrollComponent" | "ListHeaderComponentStyle" | "ListFooterComponentStyle"> & {
|
|
883
|
+
onScroll?: (event: NativeSyntheticEvent$1<NativeScrollEvent$1>) => void;
|
|
884
|
+
refScrollView?: React.Ref<ScrollView>;
|
|
885
|
+
renderScrollComponent?: (props: ScrollViewProps) => ReactElement<ScrollViewProps>;
|
|
886
|
+
ListHeaderComponentStyle?: StyleProp$1<ViewStyle$1> | undefined;
|
|
887
|
+
ListFooterComponentStyle?: StyleProp$1<ViewStyle$1> | undefined;
|
|
804
888
|
};
|
|
889
|
+
type LegendListProps<ItemT = any, TItemType extends string | undefined = string | undefined> = LegendListPropsOverrides<ItemT, TItemType>;
|
|
890
|
+
type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
|
|
891
|
+
getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
|
|
892
|
+
getScrollResponder(): ScrollResponderMixin;
|
|
893
|
+
reportContentInset(inset?: Partial<Insets$1> | null): void;
|
|
894
|
+
};
|
|
895
|
+
type LegendListState = Omit<LegendListState$1, "elementAtIndex"> & {
|
|
896
|
+
elementAtIndex: (index: number) => View | null | undefined;
|
|
897
|
+
};
|
|
898
|
+
type LegendListComponent = <ItemT = any>(props: LegendListProps<ItemT> & React.RefAttributes<LegendListRef>) => React.ReactElement | null;
|
|
805
899
|
|
|
806
900
|
declare function useViewability<ItemT = any>(callback: ViewabilityCallback<ItemT>, configId?: string): void;
|
|
807
901
|
declare function useViewabilityAmount<ItemT = any>(callback: ViewabilityAmountCallback<ItemT>): void;
|
|
@@ -814,4 +908,6 @@ declare function useListScrollSize(): {
|
|
|
814
908
|
};
|
|
815
909
|
declare function useSyncLayout(): () => void;
|
|
816
910
|
|
|
817
|
-
|
|
911
|
+
declare const LegendList: LegendListComponent;
|
|
912
|
+
|
|
913
|
+
export { type AlwaysRenderConfig, type BaseScrollViewProps, type ColumnWrapperStyle, type GetRenderedItem, type GetRenderedItemResult, type InitialScrollAnchor, type Insets, type InternalState, type LayoutRectangle, LegendList, type LegendListComponent, type LegendListMetrics, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type LegendListScrollerRef, type LegendListState, type MaintainScrollAtEndOptions, type MaintainVisibleContentPositionConfig, type MaintainVisibleContentPositionNormalized, type NativeScrollEvent, type NativeSyntheticEvent, type OnViewableItemsChanged, type ScrollEventTargetLike, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type ScrollTarget, type ScrollableNodeLike, type StickyHeaderConfig, type StyleProp, type ThresholdSnapshot, type TypedForwardRef, type TypedMemo, type ViewAmountToken, type ViewStyle, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange, typedForwardRef, typedMemo, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
|