@legendapp/list 0.6.1 → 0.6.3
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/index.d.mts +5 -0
- package/index.d.ts +5 -0
- package/index.js +85 -44
- package/index.mjs +86 -45
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -101,6 +101,11 @@ interface InternalState {
|
|
|
101
101
|
}>;
|
|
102
102
|
scrollTimer: Timer | undefined;
|
|
103
103
|
startReachedBlockedByTimer: boolean;
|
|
104
|
+
layoutsPending: Set<number>;
|
|
105
|
+
scrollForNextCalculateItemsInView: {
|
|
106
|
+
top: number;
|
|
107
|
+
bottom: number;
|
|
108
|
+
} | undefined;
|
|
104
109
|
}
|
|
105
110
|
interface ViewableRange<T> {
|
|
106
111
|
startBuffered: number;
|
package/index.d.ts
CHANGED
|
@@ -101,6 +101,11 @@ interface InternalState {
|
|
|
101
101
|
}>;
|
|
102
102
|
scrollTimer: Timer | undefined;
|
|
103
103
|
startReachedBlockedByTimer: boolean;
|
|
104
|
+
layoutsPending: Set<number>;
|
|
105
|
+
scrollForNextCalculateItemsInView: {
|
|
106
|
+
top: number;
|
|
107
|
+
bottom: number;
|
|
108
|
+
} | undefined;
|
|
104
109
|
}
|
|
105
110
|
interface ViewableRange<T> {
|
|
106
111
|
startBuffered: number;
|
package/index.js
CHANGED
|
@@ -39,12 +39,16 @@ function StateProvider({ children }) {
|
|
|
39
39
|
function useStateContext() {
|
|
40
40
|
return React4__namespace.useContext(ContextState);
|
|
41
41
|
}
|
|
42
|
+
function createSelectorFunctions(ctx, signalName) {
|
|
43
|
+
return {
|
|
44
|
+
subscribe: (cb) => listen$(ctx, signalName, cb),
|
|
45
|
+
get: () => peek$(ctx, signalName)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
42
48
|
function use$(signalName) {
|
|
43
49
|
const ctx = React4__namespace.useContext(ContextState);
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
() => ctx.values.get(signalName)
|
|
47
|
-
);
|
|
50
|
+
const { subscribe, get } = React4__namespace.useMemo(() => createSelectorFunctions(ctx, signalName), []);
|
|
51
|
+
const value = React4.useSyncExternalStore(subscribe, get);
|
|
48
52
|
return value;
|
|
49
53
|
}
|
|
50
54
|
function listen$(ctx, signalName, cb) {
|
|
@@ -118,14 +122,6 @@ var Container = ({
|
|
|
118
122
|
if (key !== void 0) {
|
|
119
123
|
const size = Math.floor(event.nativeEvent.layout[horizontal ? "width" : "height"] * 8) / 8;
|
|
120
124
|
updateItemSize(id, key, size);
|
|
121
|
-
const otherAxisSize2 = horizontal ? event.nativeEvent.layout.width : event.nativeEvent.layout.height;
|
|
122
|
-
set$(ctx, "otherAxisSize", Math.max(otherAxisSize2, peek$(ctx, "otherAxisSize") || 0));
|
|
123
|
-
const measured = peek$(ctx, `containerDidLayout${id}`);
|
|
124
|
-
if (!measured) {
|
|
125
|
-
requestAnimationFrame(() => {
|
|
126
|
-
set$(ctx, `containerDidLayout${id}`, true);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
125
|
}
|
|
130
126
|
}
|
|
131
127
|
},
|
|
@@ -460,7 +456,7 @@ var LegendList = React4.forwardRef(function LegendList2(props, forwardedRef) {
|
|
|
460
456
|
return /* @__PURE__ */ React4__namespace.createElement(StateProvider, null, /* @__PURE__ */ React4__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
|
|
461
457
|
});
|
|
462
458
|
var LegendListInner = React4.forwardRef(function LegendListInner2(props, forwardedRef) {
|
|
463
|
-
var _a, _b, _c, _d
|
|
459
|
+
var _a, _b, _c, _d;
|
|
464
460
|
const {
|
|
465
461
|
data,
|
|
466
462
|
initialScrollIndex,
|
|
@@ -567,7 +563,9 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
567
563
|
scrollTimer: void 0,
|
|
568
564
|
belowAnchorElementPositions: void 0,
|
|
569
565
|
rowHeights: /* @__PURE__ */ new Map(),
|
|
570
|
-
startReachedBlockedByTimer: false
|
|
566
|
+
startReachedBlockedByTimer: false,
|
|
567
|
+
layoutsPending: /* @__PURE__ */ new Set(),
|
|
568
|
+
scrollForNextCalculateItemsInView: void 0
|
|
571
569
|
};
|
|
572
570
|
refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
|
|
573
571
|
if (maintainVisibleContentPosition) {
|
|
@@ -698,7 +696,8 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
698
696
|
startBufferedId: startBufferedIdOrig,
|
|
699
697
|
positions,
|
|
700
698
|
columns,
|
|
701
|
-
scrollAdjustHandler
|
|
699
|
+
scrollAdjustHandler,
|
|
700
|
+
layoutsPending
|
|
702
701
|
} = state;
|
|
703
702
|
if (state.animFrameLayout) {
|
|
704
703
|
cancelAnimationFrame(state.animFrameLayout);
|
|
@@ -711,6 +710,12 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
711
710
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
712
711
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
713
712
|
const scroll = scrollState - previousScrollAdjust - topPad - scrollExtra;
|
|
713
|
+
if (refState.current.scrollForNextCalculateItemsInView) {
|
|
714
|
+
const { top: top2, bottom } = refState.current.scrollForNextCalculateItemsInView;
|
|
715
|
+
if (scroll > top2 && scroll < bottom) {
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
714
719
|
const scrollBottom = scroll + scrollLength;
|
|
715
720
|
let startNoBuffer = null;
|
|
716
721
|
let startBuffered = null;
|
|
@@ -804,6 +809,14 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
804
809
|
endBuffered,
|
|
805
810
|
endNoBuffer
|
|
806
811
|
});
|
|
812
|
+
const nextTop = Math.ceil(startBuffered ? positions.get(startBufferedId) + scrollBuffer : 0);
|
|
813
|
+
const nextBottom = Math.floor(
|
|
814
|
+
endBuffered ? (positions.get(getId(endBuffered + 1)) || 0) - scrollLength - scrollBuffer : 0
|
|
815
|
+
);
|
|
816
|
+
refState.current.scrollForNextCalculateItemsInView = nextTop >= 0 && nextBottom >= 0 ? {
|
|
817
|
+
top: nextTop,
|
|
818
|
+
bottom: nextBottom
|
|
819
|
+
} : void 0;
|
|
807
820
|
if (startBuffered !== null && endBuffered !== null) {
|
|
808
821
|
const prevNumContainers = ctx.values.get("numContainers");
|
|
809
822
|
let numContainers = prevNumContainers;
|
|
@@ -846,7 +859,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
846
859
|
numContainers++;
|
|
847
860
|
set$(ctx, `containerItemKey${containerId}`, id);
|
|
848
861
|
const index = (_c2 = refState.current) == null ? void 0 : _c2.indexByKey.get(id);
|
|
849
|
-
set$(ctx, `containerItemData${
|
|
862
|
+
set$(ctx, `containerItemData${containerId}`, data2[index]);
|
|
850
863
|
set$(ctx, `containerPosition${containerId}`, POSITION_OUT_OF_VIEW);
|
|
851
864
|
set$(ctx, `containerColumn${containerId}`, -1);
|
|
852
865
|
if (__DEV__ && numContainers > peek$(ctx, "numContainersPooled")) {
|
|
@@ -896,6 +909,12 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
896
909
|
}
|
|
897
910
|
}
|
|
898
911
|
}
|
|
912
|
+
if (layoutsPending.size > 0) {
|
|
913
|
+
for (const containerId of layoutsPending) {
|
|
914
|
+
set$(ctx, `containerDidLayout${containerId}`, true);
|
|
915
|
+
}
|
|
916
|
+
layoutsPending.clear();
|
|
917
|
+
}
|
|
899
918
|
if (refState.current.viewabilityConfigCallbackPairs) {
|
|
900
919
|
updateViewableItems(
|
|
901
920
|
refState.current,
|
|
@@ -977,6 +996,33 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
977
996
|
}
|
|
978
997
|
}
|
|
979
998
|
};
|
|
999
|
+
const resetContainers = () => {
|
|
1000
|
+
const state = refState.current;
|
|
1001
|
+
if (state) {
|
|
1002
|
+
if (data.length > state.data.length) {
|
|
1003
|
+
state.isEndReached = false;
|
|
1004
|
+
}
|
|
1005
|
+
refState.current.scrollForNextCalculateItemsInView = void 0;
|
|
1006
|
+
state.data = data;
|
|
1007
|
+
const numContainers = peek$(ctx, "numContainers");
|
|
1008
|
+
for (let i = 0; i < numContainers; i++) {
|
|
1009
|
+
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1010
|
+
if (!keyExtractorProp || itemKey && state.indexByKey.get(itemKey) === void 0) {
|
|
1011
|
+
set$(ctx, `containerItemKey${i}`, void 0);
|
|
1012
|
+
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
1013
|
+
set$(ctx, `containerColumn${i}`, -1);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
if (!keyExtractorProp) {
|
|
1017
|
+
state.sizes.clear();
|
|
1018
|
+
state.positions;
|
|
1019
|
+
}
|
|
1020
|
+
calculateItemsInView(state.scrollVelocity);
|
|
1021
|
+
doMaintainScrollAtEnd(false);
|
|
1022
|
+
checkAtTop();
|
|
1023
|
+
checkAtBottom();
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
980
1026
|
const isFirst = !refState.current.renderItem;
|
|
981
1027
|
if (isFirst || data !== refState.current.data || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
982
1028
|
if (!keyExtractorProp && !isFirst && data !== refState.current.data) {
|
|
@@ -1010,36 +1056,24 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1010
1056
|
}
|
|
1011
1057
|
}
|
|
1012
1058
|
addTotalSize(null, totalSize, totalSizeBelowIndex);
|
|
1059
|
+
}
|
|
1060
|
+
React4.useEffect(() => {
|
|
1013
1061
|
if (!isFirst) {
|
|
1014
|
-
|
|
1015
|
-
for (let i = 0; i < numContainers; i++) {
|
|
1016
|
-
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1017
|
-
if (!keyExtractorProp || itemKey && ((_a = refState.current) == null ? void 0 : _a.indexByKey.get(itemKey)) === void 0) {
|
|
1018
|
-
set$(ctx, `containerItemKey${i}`, void 0);
|
|
1019
|
-
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
1020
|
-
set$(ctx, `containerColumn${i}`, -1);
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
if (!keyExtractorProp) {
|
|
1024
|
-
refState.current.sizes.clear();
|
|
1025
|
-
refState.current.positions;
|
|
1026
|
-
}
|
|
1027
|
-
setTimeout(() => {
|
|
1028
|
-
calculateItemsInView(refState.current.scrollVelocity);
|
|
1029
|
-
doMaintainScrollAtEnd(false);
|
|
1030
|
-
checkAtTop();
|
|
1031
|
-
checkAtBottom();
|
|
1032
|
-
}, 0);
|
|
1062
|
+
resetContainers();
|
|
1033
1063
|
}
|
|
1034
|
-
}
|
|
1064
|
+
}, [isFirst, data, numColumnsProp]);
|
|
1035
1065
|
refState.current.renderItem = renderItem;
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
ctx,
|
|
1040
|
-
"
|
|
1041
|
-
(
|
|
1042
|
-
|
|
1066
|
+
const lastItemKey = getId(data[data.length - 1]);
|
|
1067
|
+
const stylePaddingTop = (_d = (_c = (_a = reactNative.StyleSheet.flatten(style)) == null ? void 0 : _a.paddingTop) != null ? _c : (_b = reactNative.StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _b.paddingTop) != null ? _d : 0;
|
|
1068
|
+
const initalizeStateVars = () => {
|
|
1069
|
+
set$(ctx, "lastItemKey", lastItemKey);
|
|
1070
|
+
set$(ctx, "numColumns", numColumnsProp);
|
|
1071
|
+
set$(ctx, "stylePaddingTop", stylePaddingTop);
|
|
1072
|
+
};
|
|
1073
|
+
if (isFirst) {
|
|
1074
|
+
initalizeStateVars();
|
|
1075
|
+
}
|
|
1076
|
+
React4.useEffect(initalizeStateVars, [lastItemKey, numColumnsProp, stylePaddingTop]);
|
|
1043
1077
|
const getRenderedItem = React4.useCallback((key, containerId) => {
|
|
1044
1078
|
var _a2, _b2;
|
|
1045
1079
|
const state = refState.current;
|
|
@@ -1107,7 +1141,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1107
1141
|
}
|
|
1108
1142
|
};
|
|
1109
1143
|
run();
|
|
1110
|
-
listen$(ctx, signal, run);
|
|
1144
|
+
return listen$(ctx, signal, run);
|
|
1111
1145
|
}, []);
|
|
1112
1146
|
};
|
|
1113
1147
|
const useRecyclingState = (valueOrFun) => {
|
|
@@ -1161,6 +1195,10 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1161
1195
|
const numColumns = peek$(ctx, "numColumns");
|
|
1162
1196
|
const row = Math.floor(index / numColumns);
|
|
1163
1197
|
const prevSize = getRowHeight(row);
|
|
1198
|
+
const measured = peek$(ctx, `containerDidLayout${containerId}`);
|
|
1199
|
+
if (!measured) {
|
|
1200
|
+
state.layoutsPending.add(containerId);
|
|
1201
|
+
}
|
|
1164
1202
|
if (!prevSize || Math.abs(prevSize - size) > 0.5) {
|
|
1165
1203
|
let diff;
|
|
1166
1204
|
if (numColumns > 1) {
|
|
@@ -1198,6 +1236,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1198
1236
|
);
|
|
1199
1237
|
}, 1e3);
|
|
1200
1238
|
}
|
|
1239
|
+
refState.current.scrollForNextCalculateItemsInView = void 0;
|
|
1201
1240
|
addTotalSize(itemKey, diff, 0);
|
|
1202
1241
|
doMaintainScrollAtEnd(true);
|
|
1203
1242
|
const scrollVelocity = state.scrollVelocity;
|
|
@@ -1211,6 +1250,8 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1211
1250
|
calculateItemsInView(state.scrollVelocity);
|
|
1212
1251
|
}
|
|
1213
1252
|
}
|
|
1253
|
+
} else {
|
|
1254
|
+
set$(ctx, `containerDidLayout${containerId}`, true);
|
|
1214
1255
|
}
|
|
1215
1256
|
}, []);
|
|
1216
1257
|
const handleScrollDebounced = React4.useCallback((velocity) => {
|
package/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React4 from 'react';
|
|
2
|
-
import React4__default, { forwardRef, useRef, useMemo, useCallback, useImperativeHandle, useSyncExternalStore,
|
|
2
|
+
import React4__default, { forwardRef, useRef, useMemo, useCallback, useEffect, useImperativeHandle, useSyncExternalStore, useState } from 'react';
|
|
3
3
|
import { Animated, ScrollView, View, Dimensions, StyleSheet, useAnimatedValue as useAnimatedValue$1 } from 'react-native';
|
|
4
4
|
|
|
5
5
|
// src/LegendList.tsx
|
|
@@ -18,12 +18,16 @@ function StateProvider({ children }) {
|
|
|
18
18
|
function useStateContext() {
|
|
19
19
|
return React4.useContext(ContextState);
|
|
20
20
|
}
|
|
21
|
+
function createSelectorFunctions(ctx, signalName) {
|
|
22
|
+
return {
|
|
23
|
+
subscribe: (cb) => listen$(ctx, signalName, cb),
|
|
24
|
+
get: () => peek$(ctx, signalName)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
21
27
|
function use$(signalName) {
|
|
22
28
|
const ctx = React4.useContext(ContextState);
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
() => ctx.values.get(signalName)
|
|
26
|
-
);
|
|
29
|
+
const { subscribe, get } = React4.useMemo(() => createSelectorFunctions(ctx, signalName), []);
|
|
30
|
+
const value = useSyncExternalStore(subscribe, get);
|
|
27
31
|
return value;
|
|
28
32
|
}
|
|
29
33
|
function listen$(ctx, signalName, cb) {
|
|
@@ -97,14 +101,6 @@ var Container = ({
|
|
|
97
101
|
if (key !== void 0) {
|
|
98
102
|
const size = Math.floor(event.nativeEvent.layout[horizontal ? "width" : "height"] * 8) / 8;
|
|
99
103
|
updateItemSize(id, key, size);
|
|
100
|
-
const otherAxisSize2 = horizontal ? event.nativeEvent.layout.width : event.nativeEvent.layout.height;
|
|
101
|
-
set$(ctx, "otherAxisSize", Math.max(otherAxisSize2, peek$(ctx, "otherAxisSize") || 0));
|
|
102
|
-
const measured = peek$(ctx, `containerDidLayout${id}`);
|
|
103
|
-
if (!measured) {
|
|
104
|
-
requestAnimationFrame(() => {
|
|
105
|
-
set$(ctx, `containerDidLayout${id}`, true);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
104
|
}
|
|
109
105
|
}
|
|
110
106
|
},
|
|
@@ -439,7 +435,7 @@ var LegendList = forwardRef(function LegendList2(props, forwardedRef) {
|
|
|
439
435
|
return /* @__PURE__ */ React4.createElement(StateProvider, null, /* @__PURE__ */ React4.createElement(LegendListInner, { ...props, ref: forwardedRef }));
|
|
440
436
|
});
|
|
441
437
|
var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef) {
|
|
442
|
-
var _a, _b, _c, _d
|
|
438
|
+
var _a, _b, _c, _d;
|
|
443
439
|
const {
|
|
444
440
|
data,
|
|
445
441
|
initialScrollIndex,
|
|
@@ -546,7 +542,9 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
546
542
|
scrollTimer: void 0,
|
|
547
543
|
belowAnchorElementPositions: void 0,
|
|
548
544
|
rowHeights: /* @__PURE__ */ new Map(),
|
|
549
|
-
startReachedBlockedByTimer: false
|
|
545
|
+
startReachedBlockedByTimer: false,
|
|
546
|
+
layoutsPending: /* @__PURE__ */ new Set(),
|
|
547
|
+
scrollForNextCalculateItemsInView: void 0
|
|
550
548
|
};
|
|
551
549
|
refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
|
|
552
550
|
if (maintainVisibleContentPosition) {
|
|
@@ -677,7 +675,8 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
677
675
|
startBufferedId: startBufferedIdOrig,
|
|
678
676
|
positions,
|
|
679
677
|
columns,
|
|
680
|
-
scrollAdjustHandler
|
|
678
|
+
scrollAdjustHandler,
|
|
679
|
+
layoutsPending
|
|
681
680
|
} = state;
|
|
682
681
|
if (state.animFrameLayout) {
|
|
683
682
|
cancelAnimationFrame(state.animFrameLayout);
|
|
@@ -690,6 +689,12 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
690
689
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
691
690
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
692
691
|
const scroll = scrollState - previousScrollAdjust - topPad - scrollExtra;
|
|
692
|
+
if (refState.current.scrollForNextCalculateItemsInView) {
|
|
693
|
+
const { top: top2, bottom } = refState.current.scrollForNextCalculateItemsInView;
|
|
694
|
+
if (scroll > top2 && scroll < bottom) {
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
693
698
|
const scrollBottom = scroll + scrollLength;
|
|
694
699
|
let startNoBuffer = null;
|
|
695
700
|
let startBuffered = null;
|
|
@@ -783,6 +788,14 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
783
788
|
endBuffered,
|
|
784
789
|
endNoBuffer
|
|
785
790
|
});
|
|
791
|
+
const nextTop = Math.ceil(startBuffered ? positions.get(startBufferedId) + scrollBuffer : 0);
|
|
792
|
+
const nextBottom = Math.floor(
|
|
793
|
+
endBuffered ? (positions.get(getId(endBuffered + 1)) || 0) - scrollLength - scrollBuffer : 0
|
|
794
|
+
);
|
|
795
|
+
refState.current.scrollForNextCalculateItemsInView = nextTop >= 0 && nextBottom >= 0 ? {
|
|
796
|
+
top: nextTop,
|
|
797
|
+
bottom: nextBottom
|
|
798
|
+
} : void 0;
|
|
786
799
|
if (startBuffered !== null && endBuffered !== null) {
|
|
787
800
|
const prevNumContainers = ctx.values.get("numContainers");
|
|
788
801
|
let numContainers = prevNumContainers;
|
|
@@ -825,7 +838,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
825
838
|
numContainers++;
|
|
826
839
|
set$(ctx, `containerItemKey${containerId}`, id);
|
|
827
840
|
const index = (_c2 = refState.current) == null ? void 0 : _c2.indexByKey.get(id);
|
|
828
|
-
set$(ctx, `containerItemData${
|
|
841
|
+
set$(ctx, `containerItemData${containerId}`, data2[index]);
|
|
829
842
|
set$(ctx, `containerPosition${containerId}`, POSITION_OUT_OF_VIEW);
|
|
830
843
|
set$(ctx, `containerColumn${containerId}`, -1);
|
|
831
844
|
if (__DEV__ && numContainers > peek$(ctx, "numContainersPooled")) {
|
|
@@ -875,6 +888,12 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
875
888
|
}
|
|
876
889
|
}
|
|
877
890
|
}
|
|
891
|
+
if (layoutsPending.size > 0) {
|
|
892
|
+
for (const containerId of layoutsPending) {
|
|
893
|
+
set$(ctx, `containerDidLayout${containerId}`, true);
|
|
894
|
+
}
|
|
895
|
+
layoutsPending.clear();
|
|
896
|
+
}
|
|
878
897
|
if (refState.current.viewabilityConfigCallbackPairs) {
|
|
879
898
|
updateViewableItems(
|
|
880
899
|
refState.current,
|
|
@@ -956,6 +975,33 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
956
975
|
}
|
|
957
976
|
}
|
|
958
977
|
};
|
|
978
|
+
const resetContainers = () => {
|
|
979
|
+
const state = refState.current;
|
|
980
|
+
if (state) {
|
|
981
|
+
if (data.length > state.data.length) {
|
|
982
|
+
state.isEndReached = false;
|
|
983
|
+
}
|
|
984
|
+
refState.current.scrollForNextCalculateItemsInView = void 0;
|
|
985
|
+
state.data = data;
|
|
986
|
+
const numContainers = peek$(ctx, "numContainers");
|
|
987
|
+
for (let i = 0; i < numContainers; i++) {
|
|
988
|
+
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
989
|
+
if (!keyExtractorProp || itemKey && state.indexByKey.get(itemKey) === void 0) {
|
|
990
|
+
set$(ctx, `containerItemKey${i}`, void 0);
|
|
991
|
+
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
992
|
+
set$(ctx, `containerColumn${i}`, -1);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
if (!keyExtractorProp) {
|
|
996
|
+
state.sizes.clear();
|
|
997
|
+
state.positions;
|
|
998
|
+
}
|
|
999
|
+
calculateItemsInView(state.scrollVelocity);
|
|
1000
|
+
doMaintainScrollAtEnd(false);
|
|
1001
|
+
checkAtTop();
|
|
1002
|
+
checkAtBottom();
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
959
1005
|
const isFirst = !refState.current.renderItem;
|
|
960
1006
|
if (isFirst || data !== refState.current.data || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
961
1007
|
if (!keyExtractorProp && !isFirst && data !== refState.current.data) {
|
|
@@ -989,36 +1035,24 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
989
1035
|
}
|
|
990
1036
|
}
|
|
991
1037
|
addTotalSize(null, totalSize, totalSizeBelowIndex);
|
|
1038
|
+
}
|
|
1039
|
+
useEffect(() => {
|
|
992
1040
|
if (!isFirst) {
|
|
993
|
-
|
|
994
|
-
for (let i = 0; i < numContainers; i++) {
|
|
995
|
-
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
996
|
-
if (!keyExtractorProp || itemKey && ((_a = refState.current) == null ? void 0 : _a.indexByKey.get(itemKey)) === void 0) {
|
|
997
|
-
set$(ctx, `containerItemKey${i}`, void 0);
|
|
998
|
-
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
999
|
-
set$(ctx, `containerColumn${i}`, -1);
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
if (!keyExtractorProp) {
|
|
1003
|
-
refState.current.sizes.clear();
|
|
1004
|
-
refState.current.positions;
|
|
1005
|
-
}
|
|
1006
|
-
setTimeout(() => {
|
|
1007
|
-
calculateItemsInView(refState.current.scrollVelocity);
|
|
1008
|
-
doMaintainScrollAtEnd(false);
|
|
1009
|
-
checkAtTop();
|
|
1010
|
-
checkAtBottom();
|
|
1011
|
-
}, 0);
|
|
1041
|
+
resetContainers();
|
|
1012
1042
|
}
|
|
1013
|
-
}
|
|
1043
|
+
}, [isFirst, data, numColumnsProp]);
|
|
1014
1044
|
refState.current.renderItem = renderItem;
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
ctx,
|
|
1019
|
-
"
|
|
1020
|
-
(
|
|
1021
|
-
|
|
1045
|
+
const lastItemKey = getId(data[data.length - 1]);
|
|
1046
|
+
const stylePaddingTop = (_d = (_c = (_a = StyleSheet.flatten(style)) == null ? void 0 : _a.paddingTop) != null ? _c : (_b = StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _b.paddingTop) != null ? _d : 0;
|
|
1047
|
+
const initalizeStateVars = () => {
|
|
1048
|
+
set$(ctx, "lastItemKey", lastItemKey);
|
|
1049
|
+
set$(ctx, "numColumns", numColumnsProp);
|
|
1050
|
+
set$(ctx, "stylePaddingTop", stylePaddingTop);
|
|
1051
|
+
};
|
|
1052
|
+
if (isFirst) {
|
|
1053
|
+
initalizeStateVars();
|
|
1054
|
+
}
|
|
1055
|
+
useEffect(initalizeStateVars, [lastItemKey, numColumnsProp, stylePaddingTop]);
|
|
1022
1056
|
const getRenderedItem = useCallback((key, containerId) => {
|
|
1023
1057
|
var _a2, _b2;
|
|
1024
1058
|
const state = refState.current;
|
|
@@ -1086,7 +1120,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1086
1120
|
}
|
|
1087
1121
|
};
|
|
1088
1122
|
run();
|
|
1089
|
-
listen$(ctx, signal, run);
|
|
1123
|
+
return listen$(ctx, signal, run);
|
|
1090
1124
|
}, []);
|
|
1091
1125
|
};
|
|
1092
1126
|
const useRecyclingState = (valueOrFun) => {
|
|
@@ -1140,6 +1174,10 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1140
1174
|
const numColumns = peek$(ctx, "numColumns");
|
|
1141
1175
|
const row = Math.floor(index / numColumns);
|
|
1142
1176
|
const prevSize = getRowHeight(row);
|
|
1177
|
+
const measured = peek$(ctx, `containerDidLayout${containerId}`);
|
|
1178
|
+
if (!measured) {
|
|
1179
|
+
state.layoutsPending.add(containerId);
|
|
1180
|
+
}
|
|
1143
1181
|
if (!prevSize || Math.abs(prevSize - size) > 0.5) {
|
|
1144
1182
|
let diff;
|
|
1145
1183
|
if (numColumns > 1) {
|
|
@@ -1177,6 +1215,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1177
1215
|
);
|
|
1178
1216
|
}, 1e3);
|
|
1179
1217
|
}
|
|
1218
|
+
refState.current.scrollForNextCalculateItemsInView = void 0;
|
|
1180
1219
|
addTotalSize(itemKey, diff, 0);
|
|
1181
1220
|
doMaintainScrollAtEnd(true);
|
|
1182
1221
|
const scrollVelocity = state.scrollVelocity;
|
|
@@ -1190,6 +1229,8 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1190
1229
|
calculateItemsInView(state.scrollVelocity);
|
|
1191
1230
|
}
|
|
1192
1231
|
}
|
|
1232
|
+
} else {
|
|
1233
|
+
set$(ctx, `containerDidLayout${containerId}`, true);
|
|
1193
1234
|
}
|
|
1194
1235
|
}, []);
|
|
1195
1236
|
const handleScrollDebounced = useCallback((velocity) => {
|