@legendapp/list 1.0.0-beta.0 → 1.0.0-beta.2
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 +2 -0
- package/index.d.ts +2 -0
- package/index.js +40 -26
- package/index.mjs +40 -26
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -61,6 +61,7 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
|
|
|
61
61
|
* @default (props) => <ScrollView {...props} />
|
|
62
62
|
*/
|
|
63
63
|
renderScrollComponent?: (props: ScrollViewProps) => React.ReactElement<ScrollViewProps>;
|
|
64
|
+
extraData?: any;
|
|
64
65
|
};
|
|
65
66
|
type LegendListProps<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof ScrollView>>;
|
|
66
67
|
interface InternalState {
|
|
@@ -114,6 +115,7 @@ interface InternalState {
|
|
|
114
115
|
top: number;
|
|
115
116
|
bottom: number;
|
|
116
117
|
} | undefined;
|
|
118
|
+
enableScrollForNextCalculateItemsInView: boolean;
|
|
117
119
|
}
|
|
118
120
|
interface ViewableRange<T> {
|
|
119
121
|
startBuffered: number;
|
package/index.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
|
|
|
61
61
|
* @default (props) => <ScrollView {...props} />
|
|
62
62
|
*/
|
|
63
63
|
renderScrollComponent?: (props: ScrollViewProps) => React.ReactElement<ScrollViewProps>;
|
|
64
|
+
extraData?: any;
|
|
64
65
|
};
|
|
65
66
|
type LegendListProps<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof ScrollView>>;
|
|
66
67
|
interface InternalState {
|
|
@@ -114,6 +115,7 @@ interface InternalState {
|
|
|
114
115
|
top: number;
|
|
115
116
|
bottom: number;
|
|
116
117
|
} | undefined;
|
|
118
|
+
enableScrollForNextCalculateItemsInView: boolean;
|
|
117
119
|
}
|
|
118
120
|
interface ViewableRange<T> {
|
|
119
121
|
startBuffered: number;
|
package/index.js
CHANGED
|
@@ -115,7 +115,8 @@ var Container = ({
|
|
|
115
115
|
const lastItemKey = use$("lastItemKey");
|
|
116
116
|
const itemKey = use$(`containerItemKey${id}`);
|
|
117
117
|
const data = use$(`containerItemData${id}`);
|
|
118
|
-
const
|
|
118
|
+
const extraData = use$("extraData");
|
|
119
|
+
const renderedItem = React4.useMemo(() => itemKey !== void 0 && getRenderedItem(itemKey, id), [itemKey, data, extraData]);
|
|
119
120
|
return /* @__PURE__ */ React4__namespace.default.createElement(
|
|
120
121
|
reactNative.View,
|
|
121
122
|
{
|
|
@@ -494,6 +495,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
494
495
|
onItemSizeChanged,
|
|
495
496
|
scrollEventThrottle,
|
|
496
497
|
refScrollView,
|
|
498
|
+
extraData,
|
|
497
499
|
...rest
|
|
498
500
|
} = props;
|
|
499
501
|
const { style, contentContainerStyle } = props;
|
|
@@ -577,7 +579,8 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
577
579
|
rowHeights: /* @__PURE__ */ new Map(),
|
|
578
580
|
startReachedBlockedByTimer: false,
|
|
579
581
|
layoutsPending: /* @__PURE__ */ new Set(),
|
|
580
|
-
scrollForNextCalculateItemsInView: void 0
|
|
582
|
+
scrollForNextCalculateItemsInView: void 0,
|
|
583
|
+
enableScrollForNextCalculateItemsInView: true
|
|
581
584
|
};
|
|
582
585
|
refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
|
|
583
586
|
if (maintainVisibleContentPosition) {
|
|
@@ -596,6 +599,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
596
599
|
}
|
|
597
600
|
}
|
|
598
601
|
set$(ctx, "scrollAdjust", 0);
|
|
602
|
+
set$(ctx, "extraData", extraData);
|
|
599
603
|
}
|
|
600
604
|
const getAnchorElementIndex = () => {
|
|
601
605
|
const state = refState.current;
|
|
@@ -655,7 +659,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
655
659
|
}
|
|
656
660
|
let rowHeight = 0;
|
|
657
661
|
const startEl = n * numColumnsProp;
|
|
658
|
-
for (let i = startEl; i < startEl + numColumnsProp; i++) {
|
|
662
|
+
for (let i = startEl; i < startEl + numColumnsProp && i < data.length; i++) {
|
|
659
663
|
const id = getId(i);
|
|
660
664
|
const size = getItemSize(id, i, data[i]);
|
|
661
665
|
rowHeight = Math.max(rowHeight, size);
|
|
@@ -696,7 +700,6 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
696
700
|
return res;
|
|
697
701
|
};
|
|
698
702
|
const calculateItemsInView = React4.useCallback((speed) => {
|
|
699
|
-
var _a2, _b2, _c2, _d2;
|
|
700
703
|
const state = refState.current;
|
|
701
704
|
const {
|
|
702
705
|
data: data2,
|
|
@@ -719,8 +722,8 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
719
722
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
720
723
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
721
724
|
const scroll = scrollState - previousScrollAdjust - topPad - scrollExtra;
|
|
722
|
-
if (
|
|
723
|
-
const { top: top2, bottom } =
|
|
725
|
+
if (state.scrollForNextCalculateItemsInView) {
|
|
726
|
+
const { top: top2, bottom } = state.scrollForNextCalculateItemsInView;
|
|
724
727
|
if (scroll > top2 && scroll < bottom) {
|
|
725
728
|
return;
|
|
726
729
|
}
|
|
@@ -763,13 +766,13 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
763
766
|
let column = 1;
|
|
764
767
|
let maxSizeInRow = 0;
|
|
765
768
|
const getInitialTop = (i) => {
|
|
766
|
-
var
|
|
769
|
+
var _a2;
|
|
767
770
|
const id = getId(i);
|
|
768
771
|
let topOffset = 0;
|
|
769
772
|
if (positions.get(id)) {
|
|
770
773
|
topOffset = positions.get(id);
|
|
771
774
|
}
|
|
772
|
-
if (id === ((
|
|
775
|
+
if (id === ((_a2 = state.anchorElement) == null ? void 0 : _a2.id)) {
|
|
773
776
|
topOffset = initialContentOffset || 0;
|
|
774
777
|
}
|
|
775
778
|
return topOffset;
|
|
@@ -811,21 +814,23 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
811
814
|
maxSizeInRow = 0;
|
|
812
815
|
}
|
|
813
816
|
}
|
|
814
|
-
Object.assign(
|
|
817
|
+
Object.assign(state, {
|
|
815
818
|
startBuffered,
|
|
816
819
|
startBufferedId,
|
|
817
820
|
startNoBuffer,
|
|
818
821
|
endBuffered,
|
|
819
822
|
endNoBuffer
|
|
820
823
|
});
|
|
821
|
-
const nextTop = Math.ceil(startBuffered ? positions.get(startBufferedId) + scrollBuffer : 0);
|
|
824
|
+
const nextTop = Math.ceil(startBuffered !== null ? positions.get(startBufferedId) + scrollBuffer : 0);
|
|
822
825
|
const nextBottom = Math.floor(
|
|
823
|
-
endBuffered ? (positions.get(getId(endBuffered + 1)) || 0) - scrollLength - scrollBuffer : 0
|
|
826
|
+
endBuffered !== null ? (positions.get(getId(endBuffered + 1)) || 0) - scrollLength - scrollBuffer : 0
|
|
824
827
|
);
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
828
|
+
if (state.enableScrollForNextCalculateItemsInView) {
|
|
829
|
+
state.scrollForNextCalculateItemsInView = nextTop >= 0 && nextBottom >= 0 ? {
|
|
830
|
+
top: nextTop,
|
|
831
|
+
bottom: nextBottom
|
|
832
|
+
} : void 0;
|
|
833
|
+
}
|
|
829
834
|
if (startBuffered !== null && endBuffered !== null) {
|
|
830
835
|
const prevNumContainers = ctx.values.get("numContainers");
|
|
831
836
|
let numContainers = prevNumContainers;
|
|
@@ -849,7 +854,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
849
854
|
furthestIndex = u;
|
|
850
855
|
break;
|
|
851
856
|
}
|
|
852
|
-
const index =
|
|
857
|
+
const index = state.indexByKey.get(key);
|
|
853
858
|
const pos = peek$(ctx, `containerPosition${u}`);
|
|
854
859
|
if (index < startBuffered || index > endBuffered) {
|
|
855
860
|
const distance = Math.abs(pos - top2);
|
|
@@ -861,13 +866,13 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
861
866
|
}
|
|
862
867
|
if (furthestIndex >= 0) {
|
|
863
868
|
set$(ctx, `containerItemKey${furthestIndex}`, id);
|
|
864
|
-
const index =
|
|
869
|
+
const index = state.indexByKey.get(id);
|
|
865
870
|
set$(ctx, `containerItemData${furthestIndex}`, data2[index]);
|
|
866
871
|
} else {
|
|
867
872
|
const containerId = numContainers;
|
|
868
873
|
numContainers++;
|
|
869
874
|
set$(ctx, `containerItemKey${containerId}`, id);
|
|
870
|
-
const index =
|
|
875
|
+
const index = state.indexByKey.get(id);
|
|
871
876
|
set$(ctx, `containerItemData${containerId}`, data2[index]);
|
|
872
877
|
set$(ctx, `containerPosition${containerId}`, POSITION_OUT_OF_VIEW);
|
|
873
878
|
set$(ctx, `containerColumn${containerId}`, -1);
|
|
@@ -888,7 +893,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
888
893
|
}
|
|
889
894
|
for (let i = 0; i < numContainers; i++) {
|
|
890
895
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
891
|
-
const itemIndex =
|
|
896
|
+
const itemIndex = state.indexByKey.get(itemKey);
|
|
892
897
|
const item = data2[itemIndex];
|
|
893
898
|
if (item) {
|
|
894
899
|
const id = getId(itemIndex);
|
|
@@ -924,11 +929,11 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
924
929
|
}
|
|
925
930
|
layoutsPending.clear();
|
|
926
931
|
}
|
|
927
|
-
if (
|
|
932
|
+
if (state.viewabilityConfigCallbackPairs) {
|
|
928
933
|
updateViewableItems(
|
|
929
|
-
|
|
934
|
+
state,
|
|
930
935
|
ctx,
|
|
931
|
-
|
|
936
|
+
state.viewabilityConfigCallbackPairs,
|
|
932
937
|
getId,
|
|
933
938
|
scrollLength,
|
|
934
939
|
startNoBuffer,
|
|
@@ -1066,6 +1071,9 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1066
1071
|
maxSizeInRow = 0;
|
|
1067
1072
|
}
|
|
1068
1073
|
}
|
|
1074
|
+
if (maxSizeInRow > 0) {
|
|
1075
|
+
totalSize += maxSizeInRow;
|
|
1076
|
+
}
|
|
1069
1077
|
addTotalSize(null, totalSize, totalSizeBelowIndex);
|
|
1070
1078
|
}
|
|
1071
1079
|
React4.useEffect(() => {
|
|
@@ -1074,6 +1082,9 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1074
1082
|
!isFirst
|
|
1075
1083
|
);
|
|
1076
1084
|
}, [isFirst, data, numColumnsProp]);
|
|
1085
|
+
React4.useEffect(() => {
|
|
1086
|
+
set$(ctx, "extraData", extraData);
|
|
1087
|
+
}, [extraData]);
|
|
1077
1088
|
refState.current.renderItem = renderItem;
|
|
1078
1089
|
const lastItemKey = getId(data[data.length - 1]);
|
|
1079
1090
|
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;
|
|
@@ -1183,8 +1194,11 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1183
1194
|
}, []);
|
|
1184
1195
|
useInit(() => {
|
|
1185
1196
|
var _a2;
|
|
1186
|
-
refState.current
|
|
1187
|
-
const
|
|
1197
|
+
const state = refState.current;
|
|
1198
|
+
const viewability = setupViewability(props);
|
|
1199
|
+
state.viewabilityConfigCallbackPairs = viewability;
|
|
1200
|
+
state.enableScrollForNextCalculateItemsInView = !viewability;
|
|
1201
|
+
const scrollLength = state.scrollLength;
|
|
1188
1202
|
const averageItemSize = (_a2 = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0])) != null ? _a2 : DEFAULT_ITEM_SIZE;
|
|
1189
1203
|
const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize) * numColumnsProp;
|
|
1190
1204
|
for (let i = 0; i < numContainers; i++) {
|
|
@@ -1193,7 +1207,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1193
1207
|
}
|
|
1194
1208
|
set$(ctx, "numContainers", numContainers);
|
|
1195
1209
|
set$(ctx, "numContainersPooled", numContainers * 2);
|
|
1196
|
-
calculateItemsInView(
|
|
1210
|
+
calculateItemsInView(state.scrollVelocity);
|
|
1197
1211
|
});
|
|
1198
1212
|
const updateItemSize = React4.useCallback((containerId, itemKey, size) => {
|
|
1199
1213
|
var _a2;
|
|
@@ -1219,7 +1233,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1219
1233
|
const column = columns.get(itemKey);
|
|
1220
1234
|
const loopStart = index - (column - 1);
|
|
1221
1235
|
let nextMaxSizeInRow = 0;
|
|
1222
|
-
for (let i = loopStart; i < loopStart + numColumns; i++) {
|
|
1236
|
+
for (let i = loopStart; i < loopStart + numColumns && i < data2.length; i++) {
|
|
1223
1237
|
const id = getId(i);
|
|
1224
1238
|
const size2 = getItemSize(id, i, data2[i]);
|
|
1225
1239
|
nextMaxSizeInRow = Math.max(nextMaxSizeInRow, size2);
|
package/index.mjs
CHANGED
|
@@ -94,7 +94,8 @@ var Container = ({
|
|
|
94
94
|
const lastItemKey = use$("lastItemKey");
|
|
95
95
|
const itemKey = use$(`containerItemKey${id}`);
|
|
96
96
|
const data = use$(`containerItemData${id}`);
|
|
97
|
-
const
|
|
97
|
+
const extraData = use$("extraData");
|
|
98
|
+
const renderedItem = useMemo(() => itemKey !== void 0 && getRenderedItem(itemKey, id), [itemKey, data, extraData]);
|
|
98
99
|
return /* @__PURE__ */ React4__default.createElement(
|
|
99
100
|
View,
|
|
100
101
|
{
|
|
@@ -473,6 +474,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
473
474
|
onItemSizeChanged,
|
|
474
475
|
scrollEventThrottle,
|
|
475
476
|
refScrollView,
|
|
477
|
+
extraData,
|
|
476
478
|
...rest
|
|
477
479
|
} = props;
|
|
478
480
|
const { style, contentContainerStyle } = props;
|
|
@@ -556,7 +558,8 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
556
558
|
rowHeights: /* @__PURE__ */ new Map(),
|
|
557
559
|
startReachedBlockedByTimer: false,
|
|
558
560
|
layoutsPending: /* @__PURE__ */ new Set(),
|
|
559
|
-
scrollForNextCalculateItemsInView: void 0
|
|
561
|
+
scrollForNextCalculateItemsInView: void 0,
|
|
562
|
+
enableScrollForNextCalculateItemsInView: true
|
|
560
563
|
};
|
|
561
564
|
refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
|
|
562
565
|
if (maintainVisibleContentPosition) {
|
|
@@ -575,6 +578,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
575
578
|
}
|
|
576
579
|
}
|
|
577
580
|
set$(ctx, "scrollAdjust", 0);
|
|
581
|
+
set$(ctx, "extraData", extraData);
|
|
578
582
|
}
|
|
579
583
|
const getAnchorElementIndex = () => {
|
|
580
584
|
const state = refState.current;
|
|
@@ -634,7 +638,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
634
638
|
}
|
|
635
639
|
let rowHeight = 0;
|
|
636
640
|
const startEl = n * numColumnsProp;
|
|
637
|
-
for (let i = startEl; i < startEl + numColumnsProp; i++) {
|
|
641
|
+
for (let i = startEl; i < startEl + numColumnsProp && i < data.length; i++) {
|
|
638
642
|
const id = getId(i);
|
|
639
643
|
const size = getItemSize(id, i, data[i]);
|
|
640
644
|
rowHeight = Math.max(rowHeight, size);
|
|
@@ -675,7 +679,6 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
675
679
|
return res;
|
|
676
680
|
};
|
|
677
681
|
const calculateItemsInView = useCallback((speed) => {
|
|
678
|
-
var _a2, _b2, _c2, _d2;
|
|
679
682
|
const state = refState.current;
|
|
680
683
|
const {
|
|
681
684
|
data: data2,
|
|
@@ -698,8 +701,8 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
698
701
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
699
702
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
700
703
|
const scroll = scrollState - previousScrollAdjust - topPad - scrollExtra;
|
|
701
|
-
if (
|
|
702
|
-
const { top: top2, bottom } =
|
|
704
|
+
if (state.scrollForNextCalculateItemsInView) {
|
|
705
|
+
const { top: top2, bottom } = state.scrollForNextCalculateItemsInView;
|
|
703
706
|
if (scroll > top2 && scroll < bottom) {
|
|
704
707
|
return;
|
|
705
708
|
}
|
|
@@ -742,13 +745,13 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
742
745
|
let column = 1;
|
|
743
746
|
let maxSizeInRow = 0;
|
|
744
747
|
const getInitialTop = (i) => {
|
|
745
|
-
var
|
|
748
|
+
var _a2;
|
|
746
749
|
const id = getId(i);
|
|
747
750
|
let topOffset = 0;
|
|
748
751
|
if (positions.get(id)) {
|
|
749
752
|
topOffset = positions.get(id);
|
|
750
753
|
}
|
|
751
|
-
if (id === ((
|
|
754
|
+
if (id === ((_a2 = state.anchorElement) == null ? void 0 : _a2.id)) {
|
|
752
755
|
topOffset = initialContentOffset || 0;
|
|
753
756
|
}
|
|
754
757
|
return topOffset;
|
|
@@ -790,21 +793,23 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
790
793
|
maxSizeInRow = 0;
|
|
791
794
|
}
|
|
792
795
|
}
|
|
793
|
-
Object.assign(
|
|
796
|
+
Object.assign(state, {
|
|
794
797
|
startBuffered,
|
|
795
798
|
startBufferedId,
|
|
796
799
|
startNoBuffer,
|
|
797
800
|
endBuffered,
|
|
798
801
|
endNoBuffer
|
|
799
802
|
});
|
|
800
|
-
const nextTop = Math.ceil(startBuffered ? positions.get(startBufferedId) + scrollBuffer : 0);
|
|
803
|
+
const nextTop = Math.ceil(startBuffered !== null ? positions.get(startBufferedId) + scrollBuffer : 0);
|
|
801
804
|
const nextBottom = Math.floor(
|
|
802
|
-
endBuffered ? (positions.get(getId(endBuffered + 1)) || 0) - scrollLength - scrollBuffer : 0
|
|
805
|
+
endBuffered !== null ? (positions.get(getId(endBuffered + 1)) || 0) - scrollLength - scrollBuffer : 0
|
|
803
806
|
);
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
807
|
+
if (state.enableScrollForNextCalculateItemsInView) {
|
|
808
|
+
state.scrollForNextCalculateItemsInView = nextTop >= 0 && nextBottom >= 0 ? {
|
|
809
|
+
top: nextTop,
|
|
810
|
+
bottom: nextBottom
|
|
811
|
+
} : void 0;
|
|
812
|
+
}
|
|
808
813
|
if (startBuffered !== null && endBuffered !== null) {
|
|
809
814
|
const prevNumContainers = ctx.values.get("numContainers");
|
|
810
815
|
let numContainers = prevNumContainers;
|
|
@@ -828,7 +833,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
828
833
|
furthestIndex = u;
|
|
829
834
|
break;
|
|
830
835
|
}
|
|
831
|
-
const index =
|
|
836
|
+
const index = state.indexByKey.get(key);
|
|
832
837
|
const pos = peek$(ctx, `containerPosition${u}`);
|
|
833
838
|
if (index < startBuffered || index > endBuffered) {
|
|
834
839
|
const distance = Math.abs(pos - top2);
|
|
@@ -840,13 +845,13 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
840
845
|
}
|
|
841
846
|
if (furthestIndex >= 0) {
|
|
842
847
|
set$(ctx, `containerItemKey${furthestIndex}`, id);
|
|
843
|
-
const index =
|
|
848
|
+
const index = state.indexByKey.get(id);
|
|
844
849
|
set$(ctx, `containerItemData${furthestIndex}`, data2[index]);
|
|
845
850
|
} else {
|
|
846
851
|
const containerId = numContainers;
|
|
847
852
|
numContainers++;
|
|
848
853
|
set$(ctx, `containerItemKey${containerId}`, id);
|
|
849
|
-
const index =
|
|
854
|
+
const index = state.indexByKey.get(id);
|
|
850
855
|
set$(ctx, `containerItemData${containerId}`, data2[index]);
|
|
851
856
|
set$(ctx, `containerPosition${containerId}`, POSITION_OUT_OF_VIEW);
|
|
852
857
|
set$(ctx, `containerColumn${containerId}`, -1);
|
|
@@ -867,7 +872,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
867
872
|
}
|
|
868
873
|
for (let i = 0; i < numContainers; i++) {
|
|
869
874
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
870
|
-
const itemIndex =
|
|
875
|
+
const itemIndex = state.indexByKey.get(itemKey);
|
|
871
876
|
const item = data2[itemIndex];
|
|
872
877
|
if (item) {
|
|
873
878
|
const id = getId(itemIndex);
|
|
@@ -903,11 +908,11 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
903
908
|
}
|
|
904
909
|
layoutsPending.clear();
|
|
905
910
|
}
|
|
906
|
-
if (
|
|
911
|
+
if (state.viewabilityConfigCallbackPairs) {
|
|
907
912
|
updateViewableItems(
|
|
908
|
-
|
|
913
|
+
state,
|
|
909
914
|
ctx,
|
|
910
|
-
|
|
915
|
+
state.viewabilityConfigCallbackPairs,
|
|
911
916
|
getId,
|
|
912
917
|
scrollLength,
|
|
913
918
|
startNoBuffer,
|
|
@@ -1045,6 +1050,9 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1045
1050
|
maxSizeInRow = 0;
|
|
1046
1051
|
}
|
|
1047
1052
|
}
|
|
1053
|
+
if (maxSizeInRow > 0) {
|
|
1054
|
+
totalSize += maxSizeInRow;
|
|
1055
|
+
}
|
|
1048
1056
|
addTotalSize(null, totalSize, totalSizeBelowIndex);
|
|
1049
1057
|
}
|
|
1050
1058
|
useEffect(() => {
|
|
@@ -1053,6 +1061,9 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1053
1061
|
!isFirst
|
|
1054
1062
|
);
|
|
1055
1063
|
}, [isFirst, data, numColumnsProp]);
|
|
1064
|
+
useEffect(() => {
|
|
1065
|
+
set$(ctx, "extraData", extraData);
|
|
1066
|
+
}, [extraData]);
|
|
1056
1067
|
refState.current.renderItem = renderItem;
|
|
1057
1068
|
const lastItemKey = getId(data[data.length - 1]);
|
|
1058
1069
|
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;
|
|
@@ -1162,8 +1173,11 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1162
1173
|
}, []);
|
|
1163
1174
|
useInit(() => {
|
|
1164
1175
|
var _a2;
|
|
1165
|
-
refState.current
|
|
1166
|
-
const
|
|
1176
|
+
const state = refState.current;
|
|
1177
|
+
const viewability = setupViewability(props);
|
|
1178
|
+
state.viewabilityConfigCallbackPairs = viewability;
|
|
1179
|
+
state.enableScrollForNextCalculateItemsInView = !viewability;
|
|
1180
|
+
const scrollLength = state.scrollLength;
|
|
1167
1181
|
const averageItemSize = (_a2 = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0])) != null ? _a2 : DEFAULT_ITEM_SIZE;
|
|
1168
1182
|
const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize) * numColumnsProp;
|
|
1169
1183
|
for (let i = 0; i < numContainers; i++) {
|
|
@@ -1172,7 +1186,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1172
1186
|
}
|
|
1173
1187
|
set$(ctx, "numContainers", numContainers);
|
|
1174
1188
|
set$(ctx, "numContainersPooled", numContainers * 2);
|
|
1175
|
-
calculateItemsInView(
|
|
1189
|
+
calculateItemsInView(state.scrollVelocity);
|
|
1176
1190
|
});
|
|
1177
1191
|
const updateItemSize = useCallback((containerId, itemKey, size) => {
|
|
1178
1192
|
var _a2;
|
|
@@ -1198,7 +1212,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1198
1212
|
const column = columns.get(itemKey);
|
|
1199
1213
|
const loopStart = index - (column - 1);
|
|
1200
1214
|
let nextMaxSizeInRow = 0;
|
|
1201
|
-
for (let i = loopStart; i < loopStart + numColumns; i++) {
|
|
1215
|
+
for (let i = loopStart; i < loopStart + numColumns && i < data2.length; i++) {
|
|
1202
1216
|
const id = getId(i);
|
|
1203
1217
|
const size2 = getItemSize(id, i, data2[i]);
|
|
1204
1218
|
nextMaxSizeInRow = Math.max(nextMaxSizeInRow, size2);
|