@legendapp/list 2.0.10 → 2.0.12
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 +7 -0
- package/animated.d.mts +2 -2
- package/animated.d.ts +2 -2
- package/index.d.mts +1 -0
- package/index.d.ts +1 -0
- package/index.js +132 -126
- package/index.mjs +77 -71
- package/package.json +1 -1
- package/reanimated.d.mts +5 -4
- package/reanimated.d.ts +5 -4
- package/reanimated.js +24 -6
- package/reanimated.mjs +2 -1
package/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as React2 from 'react';
|
|
2
|
+
import React2__default, { useReducer, useEffect, createContext, useRef, useState, useMemo, useCallback, useLayoutEffect, useImperativeHandle, forwardRef, memo, useContext } from 'react';
|
|
3
3
|
import { View, Text, Platform, Animated, StyleSheet, Dimensions, RefreshControl, unstable_batchedUpdates } from 'react-native';
|
|
4
4
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
5
5
|
|
|
6
6
|
// src/components/LegendList.tsx
|
|
7
|
-
var ContextState =
|
|
7
|
+
var ContextState = React2.createContext(null);
|
|
8
8
|
function StateProvider({ children }) {
|
|
9
|
-
const [value] =
|
|
9
|
+
const [value] = React2.useState(() => ({
|
|
10
10
|
animatedScrollY: new Animated.Value(0),
|
|
11
11
|
columnWrapperStyle: void 0,
|
|
12
12
|
internalState: void 0,
|
|
@@ -25,10 +25,10 @@ function StateProvider({ children }) {
|
|
|
25
25
|
]),
|
|
26
26
|
viewRefs: /* @__PURE__ */ new Map()
|
|
27
27
|
}));
|
|
28
|
-
return /* @__PURE__ */
|
|
28
|
+
return /* @__PURE__ */ React2.createElement(ContextState.Provider, { value }, children);
|
|
29
29
|
}
|
|
30
30
|
function useStateContext() {
|
|
31
|
-
return
|
|
31
|
+
return React2.useContext(ContextState);
|
|
32
32
|
}
|
|
33
33
|
function createSelectorFunctionsArr(ctx, signalNames) {
|
|
34
34
|
let lastValues = [];
|
|
@@ -98,23 +98,23 @@ function getContentSize(ctx) {
|
|
|
98
98
|
return headerSize + footerSize + totalSize + stylePaddingTop;
|
|
99
99
|
}
|
|
100
100
|
function useArr$(signalNames) {
|
|
101
|
-
const ctx =
|
|
102
|
-
const { subscribe, get } =
|
|
101
|
+
const ctx = React2.useContext(ContextState);
|
|
102
|
+
const { subscribe, get } = React2.useMemo(() => createSelectorFunctionsArr(ctx, signalNames), [ctx, signalNames]);
|
|
103
103
|
const value = useSyncExternalStore(subscribe, get);
|
|
104
104
|
return value;
|
|
105
105
|
}
|
|
106
106
|
function useSelector$(signalName, selector) {
|
|
107
|
-
const ctx =
|
|
108
|
-
const { subscribe, get } =
|
|
107
|
+
const ctx = React2.useContext(ContextState);
|
|
108
|
+
const { subscribe, get } = React2.useMemo(() => createSelectorFunctionsArr(ctx, [signalName]), [ctx, signalName]);
|
|
109
109
|
const value = useSyncExternalStore(subscribe, () => selector(get()[0]));
|
|
110
110
|
return value;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
// src/components/DebugView.tsx
|
|
114
114
|
var DebugRow = ({ children }) => {
|
|
115
|
-
return /* @__PURE__ */
|
|
115
|
+
return /* @__PURE__ */ React2.createElement(View, { style: { alignItems: "center", flexDirection: "row", justifyContent: "space-between" } }, children);
|
|
116
116
|
};
|
|
117
|
-
var DebugView =
|
|
117
|
+
var DebugView = React2.memo(function DebugView2({ state }) {
|
|
118
118
|
const ctx = useStateContext();
|
|
119
119
|
const [totalSize = 0, scrollAdjust = 0, rawScroll = 0, scroll = 0, _numContainers = 0, _numContainersPooled = 0] = useArr$([
|
|
120
120
|
"totalSize",
|
|
@@ -129,7 +129,7 @@ var DebugView = React3.memo(function DebugView2({ state }) {
|
|
|
129
129
|
useInterval(() => {
|
|
130
130
|
forceUpdate();
|
|
131
131
|
}, 100);
|
|
132
|
-
return /* @__PURE__ */
|
|
132
|
+
return /* @__PURE__ */ React2.createElement(
|
|
133
133
|
View,
|
|
134
134
|
{
|
|
135
135
|
pointerEvents: "none",
|
|
@@ -145,14 +145,14 @@ var DebugView = React3.memo(function DebugView2({ state }) {
|
|
|
145
145
|
top: 0
|
|
146
146
|
}
|
|
147
147
|
},
|
|
148
|
-
/* @__PURE__ */
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
/* @__PURE__ */
|
|
152
|
-
/* @__PURE__ */
|
|
153
|
-
/* @__PURE__ */
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
/* @__PURE__ */
|
|
148
|
+
/* @__PURE__ */ React2.createElement(DebugRow, null, /* @__PURE__ */ React2.createElement(Text, null, "TotalSize:"), /* @__PURE__ */ React2.createElement(Text, null, totalSize.toFixed(2))),
|
|
149
|
+
/* @__PURE__ */ React2.createElement(DebugRow, null, /* @__PURE__ */ React2.createElement(Text, null, "ContentSize:"), /* @__PURE__ */ React2.createElement(Text, null, contentSize.toFixed(2))),
|
|
150
|
+
/* @__PURE__ */ React2.createElement(DebugRow, null, /* @__PURE__ */ React2.createElement(Text, null, "At end:"), /* @__PURE__ */ React2.createElement(Text, null, String(state.isAtEnd))),
|
|
151
|
+
/* @__PURE__ */ React2.createElement(Text, null),
|
|
152
|
+
/* @__PURE__ */ React2.createElement(DebugRow, null, /* @__PURE__ */ React2.createElement(Text, null, "ScrollAdjust:"), /* @__PURE__ */ React2.createElement(Text, null, scrollAdjust.toFixed(2))),
|
|
153
|
+
/* @__PURE__ */ React2.createElement(Text, null),
|
|
154
|
+
/* @__PURE__ */ React2.createElement(DebugRow, null, /* @__PURE__ */ React2.createElement(Text, null, "RawScroll: "), /* @__PURE__ */ React2.createElement(Text, null, rawScroll.toFixed(2))),
|
|
155
|
+
/* @__PURE__ */ React2.createElement(DebugRow, null, /* @__PURE__ */ React2.createElement(Text, null, "ComputedScroll: "), /* @__PURE__ */ React2.createElement(Text, null, scroll.toFixed(2)))
|
|
156
156
|
);
|
|
157
157
|
});
|
|
158
158
|
function useInterval(callback, delay) {
|
|
@@ -221,7 +221,7 @@ var PositionViewState = typedMemo(function PositionView({
|
|
|
221
221
|
...rest
|
|
222
222
|
}) {
|
|
223
223
|
const [position = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
|
|
224
|
-
return /* @__PURE__ */
|
|
224
|
+
return /* @__PURE__ */ React2.createElement(
|
|
225
225
|
View,
|
|
226
226
|
{
|
|
227
227
|
ref: refView,
|
|
@@ -249,7 +249,7 @@ var PositionViewAnimated = typedMemo(function PositionView2({
|
|
|
249
249
|
} else {
|
|
250
250
|
position = horizontal ? { left: position$ } : { top: position$ };
|
|
251
251
|
}
|
|
252
|
-
return /* @__PURE__ */
|
|
252
|
+
return /* @__PURE__ */ React2.createElement(Animated.View, { ref: refView, style: [style, position], ...rest });
|
|
253
253
|
});
|
|
254
254
|
var PositionViewSticky = typedMemo(function PositionViewSticky2({
|
|
255
255
|
id,
|
|
@@ -262,7 +262,7 @@ var PositionViewSticky = typedMemo(function PositionViewSticky2({
|
|
|
262
262
|
...rest
|
|
263
263
|
}) {
|
|
264
264
|
const [position = POSITION_OUT_OF_VIEW, headerSize] = useArr$([`containerPosition${id}`, "headerSize"]);
|
|
265
|
-
const transform =
|
|
265
|
+
const transform = React2.useMemo(() => {
|
|
266
266
|
if (animatedScrollY && stickyOffset !== void 0) {
|
|
267
267
|
const stickyPosition = animatedScrollY.interpolate({
|
|
268
268
|
extrapolate: "clamp",
|
|
@@ -272,8 +272,8 @@ var PositionViewSticky = typedMemo(function PositionViewSticky2({
|
|
|
272
272
|
return horizontal ? [{ translateX: stickyPosition }] : [{ translateY: stickyPosition }];
|
|
273
273
|
}
|
|
274
274
|
}, [animatedScrollY, headerSize, horizontal, stickyOffset, position]);
|
|
275
|
-
const viewStyle =
|
|
276
|
-
return /* @__PURE__ */
|
|
275
|
+
const viewStyle = React2.useMemo(() => [style, { zIndex: index + 1e3 }, { transform }], [style, transform]);
|
|
276
|
+
return /* @__PURE__ */ React2.createElement(Animated.View, { ref: refView, style: viewStyle, ...rest });
|
|
277
277
|
});
|
|
278
278
|
var PositionView3 = IsNewArchitecture ? PositionViewState : PositionViewAnimated;
|
|
279
279
|
var symbolFirst = Symbol();
|
|
@@ -426,7 +426,7 @@ function useSyncLayout() {
|
|
|
426
426
|
// src/components/Separator.tsx
|
|
427
427
|
function Separator({ ItemSeparatorComponent, leadingItem }) {
|
|
428
428
|
const isLastItem = useIsLastItem();
|
|
429
|
-
return isLastItem ? null : /* @__PURE__ */
|
|
429
|
+
return isLastItem ? null : /* @__PURE__ */ React2.createElement(ItemSeparatorComponent, { leadingItem });
|
|
430
430
|
}
|
|
431
431
|
function useOnLayoutSync({
|
|
432
432
|
ref,
|
|
@@ -571,7 +571,7 @@ var Container = typedMemo(function Container2({
|
|
|
571
571
|
}, [itemKey]);
|
|
572
572
|
}
|
|
573
573
|
const PositionComponent = isSticky ? PositionViewSticky : PositionView3;
|
|
574
|
-
return /* @__PURE__ */
|
|
574
|
+
return /* @__PURE__ */ React2.createElement(
|
|
575
575
|
PositionComponent,
|
|
576
576
|
{
|
|
577
577
|
animatedScrollY: isSticky ? animatedScrollY : void 0,
|
|
@@ -584,7 +584,7 @@ var Container = typedMemo(function Container2({
|
|
|
584
584
|
stickyOffset: isSticky ? stickyOffset : void 0,
|
|
585
585
|
style
|
|
586
586
|
},
|
|
587
|
-
/* @__PURE__ */
|
|
587
|
+
/* @__PURE__ */ React2.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && /* @__PURE__ */ React2.createElement(Separator, { ItemSeparatorComponent, leadingItem: renderedItemInfo.item }))
|
|
588
588
|
);
|
|
589
589
|
});
|
|
590
590
|
|
|
@@ -613,7 +613,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
613
613
|
const containers = [];
|
|
614
614
|
for (let i = 0; i < numContainers; i++) {
|
|
615
615
|
containers.push(
|
|
616
|
-
/* @__PURE__ */
|
|
616
|
+
/* @__PURE__ */ React2.createElement(
|
|
617
617
|
Container,
|
|
618
618
|
{
|
|
619
619
|
getRenderedItem: getRenderedItem2,
|
|
@@ -648,18 +648,18 @@ var Containers = typedMemo(function Containers2({
|
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
|
-
return /* @__PURE__ */
|
|
651
|
+
return /* @__PURE__ */ React2.createElement(Animated.View, { style }, containers);
|
|
652
652
|
});
|
|
653
653
|
var LayoutView = ({ onLayoutChange, refView, ...rest }) => {
|
|
654
654
|
const ref = refView != null ? refView : useRef();
|
|
655
655
|
const { onLayout } = useOnLayoutSync({ onLayoutChange, ref });
|
|
656
|
-
return /* @__PURE__ */
|
|
656
|
+
return /* @__PURE__ */ React2.createElement(View, { ...rest, onLayout, ref });
|
|
657
657
|
};
|
|
658
658
|
function ScrollAdjust() {
|
|
659
659
|
const bias = 1e7;
|
|
660
660
|
const [scrollAdjust, scrollAdjustUserOffset] = useArr$(["scrollAdjust", "scrollAdjustUserOffset"]);
|
|
661
661
|
const scrollOffset = (scrollAdjust || 0) + (scrollAdjustUserOffset || 0) + bias;
|
|
662
|
-
return /* @__PURE__ */
|
|
662
|
+
return /* @__PURE__ */ React2.createElement(
|
|
663
663
|
View,
|
|
664
664
|
{
|
|
665
665
|
style: {
|
|
@@ -674,26 +674,26 @@ function ScrollAdjust() {
|
|
|
674
674
|
}
|
|
675
675
|
function SnapWrapper({ ScrollComponent, ...props }) {
|
|
676
676
|
const [snapToOffsets] = useArr$(["snapToOffsets"]);
|
|
677
|
-
return /* @__PURE__ */
|
|
677
|
+
return /* @__PURE__ */ React2.createElement(ScrollComponent, { ...props, snapToOffsets });
|
|
678
678
|
}
|
|
679
679
|
|
|
680
680
|
// src/components/ListComponent.tsx
|
|
681
681
|
var getComponent = (Component) => {
|
|
682
|
-
if (
|
|
682
|
+
if (React2.isValidElement(Component)) {
|
|
683
683
|
return Component;
|
|
684
684
|
}
|
|
685
685
|
if (Component) {
|
|
686
|
-
return /* @__PURE__ */
|
|
686
|
+
return /* @__PURE__ */ React2.createElement(Component, null);
|
|
687
687
|
}
|
|
688
688
|
return null;
|
|
689
689
|
};
|
|
690
690
|
var Padding = () => {
|
|
691
691
|
const animPaddingTop = useValue$("alignItemsPaddingTop", { delay: 0 });
|
|
692
|
-
return /* @__PURE__ */
|
|
692
|
+
return /* @__PURE__ */ React2.createElement(Animated.View, { style: { paddingTop: animPaddingTop } });
|
|
693
693
|
};
|
|
694
694
|
var PaddingDevMode = () => {
|
|
695
695
|
const animPaddingTop = useValue$("alignItemsPaddingTop", { delay: 0 });
|
|
696
|
-
return /* @__PURE__ */
|
|
696
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Animated.View, { style: { paddingTop: animPaddingTop } }), /* @__PURE__ */ React2.createElement(
|
|
697
697
|
Animated.View,
|
|
698
698
|
{
|
|
699
699
|
style: {
|
|
@@ -737,10 +737,10 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
737
737
|
}) {
|
|
738
738
|
const ctx = useStateContext();
|
|
739
739
|
const ScrollComponent = renderScrollComponent ? useMemo(
|
|
740
|
-
() =>
|
|
740
|
+
() => React2.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
|
|
741
741
|
[renderScrollComponent]
|
|
742
742
|
) : Animated.ScrollView;
|
|
743
|
-
|
|
743
|
+
React2.useEffect(() => {
|
|
744
744
|
if (canRender) {
|
|
745
745
|
setTimeout(() => {
|
|
746
746
|
scrollAdjustHandler.setMounted();
|
|
@@ -748,7 +748,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
748
748
|
}
|
|
749
749
|
}, [canRender]);
|
|
750
750
|
const SnapOrScroll = snapToIndices ? SnapWrapper : ScrollComponent;
|
|
751
|
-
return /* @__PURE__ */
|
|
751
|
+
return /* @__PURE__ */ React2.createElement(
|
|
752
752
|
SnapOrScroll,
|
|
753
753
|
{
|
|
754
754
|
...rest,
|
|
@@ -767,11 +767,11 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
767
767
|
ScrollComponent: snapToIndices ? ScrollComponent : void 0,
|
|
768
768
|
style
|
|
769
769
|
},
|
|
770
|
-
maintainVisibleContentPosition && /* @__PURE__ */
|
|
771
|
-
ENABLE_DEVMODE ? /* @__PURE__ */
|
|
772
|
-
ListHeaderComponent && /* @__PURE__ */
|
|
770
|
+
maintainVisibleContentPosition && /* @__PURE__ */ React2.createElement(ScrollAdjust, null),
|
|
771
|
+
ENABLE_DEVMODE ? /* @__PURE__ */ React2.createElement(PaddingDevMode, null) : /* @__PURE__ */ React2.createElement(Padding, null),
|
|
772
|
+
ListHeaderComponent && /* @__PURE__ */ React2.createElement(LayoutView, { onLayoutChange: onLayoutHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
|
|
773
773
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
774
|
-
canRender && !ListEmptyComponent && /* @__PURE__ */
|
|
774
|
+
canRender && !ListEmptyComponent && /* @__PURE__ */ React2.createElement(
|
|
775
775
|
Containers,
|
|
776
776
|
{
|
|
777
777
|
getRenderedItem: getRenderedItem2,
|
|
@@ -782,7 +782,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
782
782
|
waitForInitialLayout
|
|
783
783
|
}
|
|
784
784
|
),
|
|
785
|
-
ListFooterComponent && /* @__PURE__ */
|
|
785
|
+
ListFooterComponent && /* @__PURE__ */ React2.createElement(
|
|
786
786
|
LayoutView,
|
|
787
787
|
{
|
|
788
788
|
onLayoutChange: (layout) => {
|
|
@@ -793,11 +793,11 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
793
793
|
},
|
|
794
794
|
getComponent(ListFooterComponent)
|
|
795
795
|
),
|
|
796
|
-
__DEV__ && ENABLE_DEVMODE && /* @__PURE__ */
|
|
796
|
+
__DEV__ && ENABLE_DEVMODE && /* @__PURE__ */ React2.createElement(DevNumbers, null)
|
|
797
797
|
);
|
|
798
798
|
});
|
|
799
|
-
var DevNumbers = __DEV__ &&
|
|
800
|
-
return Array.from({ length: 100 }).map((_, index) => /* @__PURE__ */
|
|
799
|
+
var DevNumbers = __DEV__ && React2.memo(function DevNumbers2() {
|
|
800
|
+
return Array.from({ length: 100 }).map((_, index) => /* @__PURE__ */ React2.createElement(
|
|
801
801
|
View,
|
|
802
802
|
{
|
|
803
803
|
key: index,
|
|
@@ -809,7 +809,7 @@ var DevNumbers = __DEV__ && React3.memo(function DevNumbers2() {
|
|
|
809
809
|
width: "100%"
|
|
810
810
|
}
|
|
811
811
|
},
|
|
812
|
-
/* @__PURE__ */
|
|
812
|
+
/* @__PURE__ */ React2.createElement(Text, { style: { color: "red" } }, index * 100)
|
|
813
813
|
));
|
|
814
814
|
});
|
|
815
815
|
|
|
@@ -1868,7 +1868,6 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1868
1868
|
const totalSize = peek$(ctx, "totalSize");
|
|
1869
1869
|
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1870
1870
|
const numColumns = peek$(ctx, "numColumns");
|
|
1871
|
-
const previousScrollAdjust = 0;
|
|
1872
1871
|
const { dataChanged, doMVCP } = params;
|
|
1873
1872
|
const speed = getScrollVelocity(state);
|
|
1874
1873
|
const scrollExtra = 0;
|
|
@@ -1882,7 +1881,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1882
1881
|
);
|
|
1883
1882
|
scrollState = updatedOffset;
|
|
1884
1883
|
}
|
|
1885
|
-
const scrollAdjustPad = -
|
|
1884
|
+
const scrollAdjustPad = -topPad;
|
|
1886
1885
|
let scroll = scrollState + scrollExtra + scrollAdjustPad;
|
|
1887
1886
|
if (scroll + scrollLength > totalSize) {
|
|
1888
1887
|
scroll = Math.max(0, totalSize - scrollLength);
|
|
@@ -2394,13 +2393,6 @@ function onScroll(ctx, state, event) {
|
|
|
2394
2393
|
return;
|
|
2395
2394
|
}
|
|
2396
2395
|
const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
2397
|
-
const ignoreScrollFromMVCP = state.ignoreScrollFromMVCP;
|
|
2398
|
-
if (ignoreScrollFromMVCP && !state.scrollingTo) {
|
|
2399
|
-
const { lt, gt } = ignoreScrollFromMVCP;
|
|
2400
|
-
if (lt && newScroll < lt || gt && newScroll > gt) {
|
|
2401
|
-
return;
|
|
2402
|
-
}
|
|
2403
|
-
}
|
|
2404
2396
|
state.scrollPending = newScroll;
|
|
2405
2397
|
updateScroll(ctx, state, newScroll);
|
|
2406
2398
|
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
@@ -2410,9 +2402,17 @@ function updateScroll(ctx, state, newScroll) {
|
|
|
2410
2402
|
state.hasScrolled = true;
|
|
2411
2403
|
state.lastBatchingAction = Date.now();
|
|
2412
2404
|
const currentTime = Date.now();
|
|
2405
|
+
const adjust = state.scrollAdjustHandler.getAdjust();
|
|
2406
|
+
const lastHistoryAdjust = state.lastScrollAdjustForHistory;
|
|
2407
|
+
const adjustChanged = lastHistoryAdjust !== void 0 && Math.abs(adjust - lastHistoryAdjust) > 0.1;
|
|
2408
|
+
if (adjustChanged) {
|
|
2409
|
+
state.scrollHistory.length = 0;
|
|
2410
|
+
}
|
|
2411
|
+
state.lastScrollAdjustForHistory = adjust;
|
|
2413
2412
|
if (scrollingTo === void 0 && !(state.scrollHistory.length === 0 && newScroll === state.scroll)) {
|
|
2414
|
-
|
|
2415
|
-
|
|
2413
|
+
if (!adjustChanged) {
|
|
2414
|
+
state.scrollHistory.push({ scroll: newScroll, time: currentTime });
|
|
2415
|
+
}
|
|
2416
2416
|
}
|
|
2417
2417
|
if (state.scrollHistory.length > 5) {
|
|
2418
2418
|
state.scrollHistory.shift();
|
|
@@ -2421,8 +2421,15 @@ function updateScroll(ctx, state, newScroll) {
|
|
|
2421
2421
|
state.scrollPrevTime = state.scrollTime;
|
|
2422
2422
|
state.scroll = newScroll;
|
|
2423
2423
|
state.scrollTime = currentTime;
|
|
2424
|
+
const ignoreScrollFromMVCP = state.ignoreScrollFromMVCP;
|
|
2425
|
+
if (ignoreScrollFromMVCP && !state.scrollingTo) {
|
|
2426
|
+
const { lt, gt } = ignoreScrollFromMVCP;
|
|
2427
|
+
if (lt && newScroll < lt || gt && newScroll > gt) {
|
|
2428
|
+
return;
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2424
2431
|
if (state.dataChangeNeedsScrollUpdate || Math.abs(state.scroll - state.scrollPrev) > 2) {
|
|
2425
|
-
calculateItemsInView(ctx, state);
|
|
2432
|
+
calculateItemsInView(ctx, state, { doMVCP: state.scrollingTo !== void 0 });
|
|
2426
2433
|
checkAtBottom(ctx, state);
|
|
2427
2434
|
checkAtTop(state);
|
|
2428
2435
|
state.dataChangeNeedsScrollUpdate = false;
|
|
@@ -2463,7 +2470,6 @@ function updateItemSize(ctx, state, itemKey, sizeObj) {
|
|
|
2463
2470
|
getFixedItemSize,
|
|
2464
2471
|
getItemType,
|
|
2465
2472
|
horizontal,
|
|
2466
|
-
maintainVisibleContentPosition,
|
|
2467
2473
|
suggestEstimatedItemSize,
|
|
2468
2474
|
onItemSizeChanged,
|
|
2469
2475
|
data,
|
|
@@ -2637,7 +2643,7 @@ function getRenderedItem(ctx, state, key) {
|
|
|
2637
2643
|
item,
|
|
2638
2644
|
type: getItemType ? (_a = getItemType(item, index)) != null ? _a : "" : ""
|
|
2639
2645
|
};
|
|
2640
|
-
renderedItem = isFunction(renderItem) ? renderItem(itemProps) :
|
|
2646
|
+
renderedItem = isFunction(renderItem) ? renderItem(itemProps) : React2__default.createElement(renderItem, itemProps);
|
|
2641
2647
|
}
|
|
2642
2648
|
return { index, item: data[index], renderedItem };
|
|
2643
2649
|
}
|
|
@@ -2696,14 +2702,14 @@ var LegendList = typedMemo(
|
|
|
2696
2702
|
const isChildrenMode = children !== void 0 && dataProp === void 0;
|
|
2697
2703
|
const processedProps = isChildrenMode ? {
|
|
2698
2704
|
...restProps,
|
|
2699
|
-
data: (isArray(children) ? children :
|
|
2705
|
+
data: (isArray(children) ? children : React2.Children.toArray(children)).flat(1),
|
|
2700
2706
|
renderItem: ({ item }) => item
|
|
2701
2707
|
} : {
|
|
2702
2708
|
...restProps,
|
|
2703
2709
|
data: dataProp || [],
|
|
2704
2710
|
renderItem: renderItemProp
|
|
2705
2711
|
};
|
|
2706
|
-
return /* @__PURE__ */
|
|
2712
|
+
return /* @__PURE__ */ React2.createElement(StateProvider, null, /* @__PURE__ */ React2.createElement(LegendListInner, { ...processedProps, ref: forwardedRef }));
|
|
2707
2713
|
})
|
|
2708
2714
|
);
|
|
2709
2715
|
var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
|
|
@@ -2763,7 +2769,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2763
2769
|
} = props;
|
|
2764
2770
|
const [renderNum, setRenderNum] = useState(0);
|
|
2765
2771
|
const initialScroll = initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
|
|
2766
|
-
const [canRender, setCanRender] =
|
|
2772
|
+
const [canRender, setCanRender] = React2.useState(!IsNewArchitecture);
|
|
2767
2773
|
const contentContainerStyle = { ...StyleSheet.flatten(contentContainerStyleProp) };
|
|
2768
2774
|
const style = { ...StyleSheet.flatten(styleProp) };
|
|
2769
2775
|
const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
|
|
@@ -3112,7 +3118,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3112
3118
|
}
|
|
3113
3119
|
return onScrollFn;
|
|
3114
3120
|
}, [stickyIndices == null ? void 0 : stickyIndices.length, horizontal, scrollEventThrottle]);
|
|
3115
|
-
return /* @__PURE__ */
|
|
3121
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
3116
3122
|
ListComponent,
|
|
3117
3123
|
{
|
|
3118
3124
|
...rest,
|
|
@@ -3143,9 +3149,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3143
3149
|
},
|
|
3144
3150
|
onScroll: onScrollHandler,
|
|
3145
3151
|
recycleItems,
|
|
3146
|
-
refreshControl: refreshControl ? stylePaddingTopState > 0 ?
|
|
3152
|
+
refreshControl: refreshControl ? stylePaddingTopState > 0 ? React2.cloneElement(refreshControl, {
|
|
3147
3153
|
progressViewOffset: (refreshControl.props.progressViewOffset || 0) + stylePaddingTopState
|
|
3148
|
-
}) : refreshControl : onRefresh && /* @__PURE__ */
|
|
3154
|
+
}) : refreshControl : onRefresh && /* @__PURE__ */ React2.createElement(
|
|
3149
3155
|
RefreshControl,
|
|
3150
3156
|
{
|
|
3151
3157
|
onRefresh,
|
|
@@ -3162,7 +3168,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3162
3168
|
updateItemSize: fns.updateItemSize,
|
|
3163
3169
|
waitForInitialLayout
|
|
3164
3170
|
}
|
|
3165
|
-
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */
|
|
3171
|
+
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React2.createElement(DebugView, { state: refState.current }));
|
|
3166
3172
|
});
|
|
3167
3173
|
|
|
3168
3174
|
export { LegendList, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
|
package/package.json
CHANGED
package/reanimated.d.mts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
2
3
|
import Animated from 'react-native-reanimated';
|
|
3
4
|
import { LegendListPropsBase, LegendListRef } from '@legendapp/list';
|
|
4
5
|
|
|
5
6
|
type KeysToOmit = "getEstimatedItemSize" | "getFixedItemSize" | "getItemType" | "keyExtractor" | "animatedProps" | "renderItem" | "onItemSizeChanged" | "itemsAreEqual" | "ItemSeparatorComponent";
|
|
6
7
|
type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof Animated.ScrollView>>;
|
|
7
8
|
interface AnimatedLegendListPropsBase<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit> {
|
|
8
|
-
refScrollView?:
|
|
9
|
+
refScrollView?: React.Ref<Animated.ScrollView>;
|
|
9
10
|
}
|
|
10
11
|
type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
|
|
11
12
|
type AnimatedLegendListProps<ItemT> = Omit<AnimatedLegendListPropsBase<ItemT>, "refLegendList" | "ref"> & OtherAnimatedLegendListProps<ItemT>;
|
|
12
13
|
type AnimatedLegendListDefinition = <ItemT>(props: AnimatedLegendListProps<ItemT> & {
|
|
13
|
-
ref?:
|
|
14
|
-
}) =>
|
|
14
|
+
ref?: React.Ref<LegendListRef>;
|
|
15
|
+
}) => React.ReactElement | null;
|
|
15
16
|
declare const AnimatedLegendList: AnimatedLegendListDefinition;
|
|
16
17
|
|
|
17
18
|
export { AnimatedLegendList, type AnimatedLegendListProps, type AnimatedLegendListPropsBase };
|
package/reanimated.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
2
3
|
import Animated from 'react-native-reanimated';
|
|
3
4
|
import { LegendListPropsBase, LegendListRef } from '@legendapp/list';
|
|
4
5
|
|
|
5
6
|
type KeysToOmit = "getEstimatedItemSize" | "getFixedItemSize" | "getItemType" | "keyExtractor" | "animatedProps" | "renderItem" | "onItemSizeChanged" | "itemsAreEqual" | "ItemSeparatorComponent";
|
|
6
7
|
type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof Animated.ScrollView>>;
|
|
7
8
|
interface AnimatedLegendListPropsBase<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit> {
|
|
8
|
-
refScrollView?:
|
|
9
|
+
refScrollView?: React.Ref<Animated.ScrollView>;
|
|
9
10
|
}
|
|
10
11
|
type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
|
|
11
12
|
type AnimatedLegendListProps<ItemT> = Omit<AnimatedLegendListPropsBase<ItemT>, "refLegendList" | "ref"> & OtherAnimatedLegendListProps<ItemT>;
|
|
12
13
|
type AnimatedLegendListDefinition = <ItemT>(props: AnimatedLegendListProps<ItemT> & {
|
|
13
|
-
ref?:
|
|
14
|
-
}) =>
|
|
14
|
+
ref?: React.Ref<LegendListRef>;
|
|
15
|
+
}) => React.ReactElement | null;
|
|
15
16
|
declare const AnimatedLegendList: AnimatedLegendListDefinition;
|
|
16
17
|
|
|
17
18
|
export { AnimatedLegendList, type AnimatedLegendListProps, type AnimatedLegendListPropsBase };
|
package/reanimated.js
CHANGED
|
@@ -6,7 +6,25 @@ var list = require('@legendapp/list');
|
|
|
6
6
|
|
|
7
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
8
|
|
|
9
|
-
|
|
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);
|
|
10
28
|
var Animated__default = /*#__PURE__*/_interopDefault(Animated);
|
|
11
29
|
|
|
12
30
|
// src/integrations/reanimated.tsx
|
|
@@ -36,7 +54,7 @@ var useCombinedRef = (...refs) => {
|
|
|
36
54
|
// src/integrations/reanimated.tsx
|
|
37
55
|
var typedMemo = React.memo;
|
|
38
56
|
var LegendListForwardedRef = typedMemo(
|
|
39
|
-
|
|
57
|
+
React__namespace.forwardRef(function LegendListForwardedRef2(props, ref) {
|
|
40
58
|
const { refLegendList, ...rest } = props;
|
|
41
59
|
const refFn = React.useCallback(
|
|
42
60
|
(r) => {
|
|
@@ -44,16 +62,16 @@ var LegendListForwardedRef = typedMemo(
|
|
|
44
62
|
},
|
|
45
63
|
[refLegendList]
|
|
46
64
|
);
|
|
47
|
-
return /* @__PURE__ */
|
|
65
|
+
return /* @__PURE__ */ React__namespace.createElement(list.LegendList, { ref: refFn, refScrollView: ref, ...rest });
|
|
48
66
|
})
|
|
49
67
|
);
|
|
50
68
|
var AnimatedLegendListComponent = Animated__default.default.createAnimatedComponent(LegendListForwardedRef);
|
|
51
69
|
var AnimatedLegendList = typedMemo(
|
|
52
|
-
|
|
70
|
+
React__namespace.forwardRef(function AnimatedLegendList2(props, ref) {
|
|
53
71
|
const { refScrollView, ...rest } = props;
|
|
54
|
-
const refLegendList =
|
|
72
|
+
const refLegendList = React__namespace.useRef(null);
|
|
55
73
|
const combinedRef = useCombinedRef(refLegendList, ref);
|
|
56
|
-
return /* @__PURE__ */
|
|
74
|
+
return /* @__PURE__ */ React__namespace.createElement(AnimatedLegendListComponent, { ref: refScrollView, refLegendList: combinedRef, ...rest });
|
|
57
75
|
})
|
|
58
76
|
);
|
|
59
77
|
|
package/reanimated.mjs
CHANGED