@legendapp/list 1.0.0-beta.0 → 1.0.0-beta.1
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 +1 -0
- package/index.d.ts +1 -0
- package/index.js +31 -23
- package/index.mjs +31 -23
- package/package.json +1 -1
package/index.d.mts
CHANGED
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -577,7 +577,8 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
577
577
|
rowHeights: /* @__PURE__ */ new Map(),
|
|
578
578
|
startReachedBlockedByTimer: false,
|
|
579
579
|
layoutsPending: /* @__PURE__ */ new Set(),
|
|
580
|
-
scrollForNextCalculateItemsInView: void 0
|
|
580
|
+
scrollForNextCalculateItemsInView: void 0,
|
|
581
|
+
enableScrollForNextCalculateItemsInView: true
|
|
581
582
|
};
|
|
582
583
|
refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
|
|
583
584
|
if (maintainVisibleContentPosition) {
|
|
@@ -655,7 +656,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
655
656
|
}
|
|
656
657
|
let rowHeight = 0;
|
|
657
658
|
const startEl = n * numColumnsProp;
|
|
658
|
-
for (let i = startEl; i < startEl + numColumnsProp; i++) {
|
|
659
|
+
for (let i = startEl; i < startEl + numColumnsProp && i < data.length; i++) {
|
|
659
660
|
const id = getId(i);
|
|
660
661
|
const size = getItemSize(id, i, data[i]);
|
|
661
662
|
rowHeight = Math.max(rowHeight, size);
|
|
@@ -696,7 +697,6 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
696
697
|
return res;
|
|
697
698
|
};
|
|
698
699
|
const calculateItemsInView = React4.useCallback((speed) => {
|
|
699
|
-
var _a2, _b2, _c2, _d2;
|
|
700
700
|
const state = refState.current;
|
|
701
701
|
const {
|
|
702
702
|
data: data2,
|
|
@@ -719,8 +719,8 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
719
719
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
720
720
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
721
721
|
const scroll = scrollState - previousScrollAdjust - topPad - scrollExtra;
|
|
722
|
-
if (
|
|
723
|
-
const { top: top2, bottom } =
|
|
722
|
+
if (state.scrollForNextCalculateItemsInView) {
|
|
723
|
+
const { top: top2, bottom } = state.scrollForNextCalculateItemsInView;
|
|
724
724
|
if (scroll > top2 && scroll < bottom) {
|
|
725
725
|
return;
|
|
726
726
|
}
|
|
@@ -763,13 +763,13 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
763
763
|
let column = 1;
|
|
764
764
|
let maxSizeInRow = 0;
|
|
765
765
|
const getInitialTop = (i) => {
|
|
766
|
-
var
|
|
766
|
+
var _a2;
|
|
767
767
|
const id = getId(i);
|
|
768
768
|
let topOffset = 0;
|
|
769
769
|
if (positions.get(id)) {
|
|
770
770
|
topOffset = positions.get(id);
|
|
771
771
|
}
|
|
772
|
-
if (id === ((
|
|
772
|
+
if (id === ((_a2 = state.anchorElement) == null ? void 0 : _a2.id)) {
|
|
773
773
|
topOffset = initialContentOffset || 0;
|
|
774
774
|
}
|
|
775
775
|
return topOffset;
|
|
@@ -811,7 +811,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
811
811
|
maxSizeInRow = 0;
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
|
-
Object.assign(
|
|
814
|
+
Object.assign(state, {
|
|
815
815
|
startBuffered,
|
|
816
816
|
startBufferedId,
|
|
817
817
|
startNoBuffer,
|
|
@@ -822,10 +822,12 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
822
822
|
const nextBottom = Math.floor(
|
|
823
823
|
endBuffered ? (positions.get(getId(endBuffered + 1)) || 0) - scrollLength - scrollBuffer : 0
|
|
824
824
|
);
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
825
|
+
if (state.enableScrollForNextCalculateItemsInView) {
|
|
826
|
+
state.scrollForNextCalculateItemsInView = nextTop >= 0 && nextBottom >= 0 ? {
|
|
827
|
+
top: nextTop,
|
|
828
|
+
bottom: nextBottom
|
|
829
|
+
} : void 0;
|
|
830
|
+
}
|
|
829
831
|
if (startBuffered !== null && endBuffered !== null) {
|
|
830
832
|
const prevNumContainers = ctx.values.get("numContainers");
|
|
831
833
|
let numContainers = prevNumContainers;
|
|
@@ -849,7 +851,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
849
851
|
furthestIndex = u;
|
|
850
852
|
break;
|
|
851
853
|
}
|
|
852
|
-
const index =
|
|
854
|
+
const index = state.indexByKey.get(key);
|
|
853
855
|
const pos = peek$(ctx, `containerPosition${u}`);
|
|
854
856
|
if (index < startBuffered || index > endBuffered) {
|
|
855
857
|
const distance = Math.abs(pos - top2);
|
|
@@ -861,13 +863,13 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
861
863
|
}
|
|
862
864
|
if (furthestIndex >= 0) {
|
|
863
865
|
set$(ctx, `containerItemKey${furthestIndex}`, id);
|
|
864
|
-
const index =
|
|
866
|
+
const index = state.indexByKey.get(id);
|
|
865
867
|
set$(ctx, `containerItemData${furthestIndex}`, data2[index]);
|
|
866
868
|
} else {
|
|
867
869
|
const containerId = numContainers;
|
|
868
870
|
numContainers++;
|
|
869
871
|
set$(ctx, `containerItemKey${containerId}`, id);
|
|
870
|
-
const index =
|
|
872
|
+
const index = state.indexByKey.get(id);
|
|
871
873
|
set$(ctx, `containerItemData${containerId}`, data2[index]);
|
|
872
874
|
set$(ctx, `containerPosition${containerId}`, POSITION_OUT_OF_VIEW);
|
|
873
875
|
set$(ctx, `containerColumn${containerId}`, -1);
|
|
@@ -888,7 +890,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
888
890
|
}
|
|
889
891
|
for (let i = 0; i < numContainers; i++) {
|
|
890
892
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
891
|
-
const itemIndex =
|
|
893
|
+
const itemIndex = state.indexByKey.get(itemKey);
|
|
892
894
|
const item = data2[itemIndex];
|
|
893
895
|
if (item) {
|
|
894
896
|
const id = getId(itemIndex);
|
|
@@ -924,11 +926,11 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
924
926
|
}
|
|
925
927
|
layoutsPending.clear();
|
|
926
928
|
}
|
|
927
|
-
if (
|
|
929
|
+
if (state.viewabilityConfigCallbackPairs) {
|
|
928
930
|
updateViewableItems(
|
|
929
|
-
|
|
931
|
+
state,
|
|
930
932
|
ctx,
|
|
931
|
-
|
|
933
|
+
state.viewabilityConfigCallbackPairs,
|
|
932
934
|
getId,
|
|
933
935
|
scrollLength,
|
|
934
936
|
startNoBuffer,
|
|
@@ -1066,6 +1068,9 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1066
1068
|
maxSizeInRow = 0;
|
|
1067
1069
|
}
|
|
1068
1070
|
}
|
|
1071
|
+
if (maxSizeInRow > 0) {
|
|
1072
|
+
totalSize += maxSizeInRow;
|
|
1073
|
+
}
|
|
1069
1074
|
addTotalSize(null, totalSize, totalSizeBelowIndex);
|
|
1070
1075
|
}
|
|
1071
1076
|
React4.useEffect(() => {
|
|
@@ -1183,8 +1188,11 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1183
1188
|
}, []);
|
|
1184
1189
|
useInit(() => {
|
|
1185
1190
|
var _a2;
|
|
1186
|
-
refState.current
|
|
1187
|
-
const
|
|
1191
|
+
const state = refState.current;
|
|
1192
|
+
const viewability = setupViewability(props);
|
|
1193
|
+
state.viewabilityConfigCallbackPairs = viewability;
|
|
1194
|
+
state.enableScrollForNextCalculateItemsInView = !viewability;
|
|
1195
|
+
const scrollLength = state.scrollLength;
|
|
1188
1196
|
const averageItemSize = (_a2 = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0])) != null ? _a2 : DEFAULT_ITEM_SIZE;
|
|
1189
1197
|
const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize) * numColumnsProp;
|
|
1190
1198
|
for (let i = 0; i < numContainers; i++) {
|
|
@@ -1193,7 +1201,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1193
1201
|
}
|
|
1194
1202
|
set$(ctx, "numContainers", numContainers);
|
|
1195
1203
|
set$(ctx, "numContainersPooled", numContainers * 2);
|
|
1196
|
-
calculateItemsInView(
|
|
1204
|
+
calculateItemsInView(state.scrollVelocity);
|
|
1197
1205
|
});
|
|
1198
1206
|
const updateItemSize = React4.useCallback((containerId, itemKey, size) => {
|
|
1199
1207
|
var _a2;
|
|
@@ -1219,7 +1227,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1219
1227
|
const column = columns.get(itemKey);
|
|
1220
1228
|
const loopStart = index - (column - 1);
|
|
1221
1229
|
let nextMaxSizeInRow = 0;
|
|
1222
|
-
for (let i = loopStart; i < loopStart + numColumns; i++) {
|
|
1230
|
+
for (let i = loopStart; i < loopStart + numColumns && i < data2.length; i++) {
|
|
1223
1231
|
const id = getId(i);
|
|
1224
1232
|
const size2 = getItemSize(id, i, data2[i]);
|
|
1225
1233
|
nextMaxSizeInRow = Math.max(nextMaxSizeInRow, size2);
|
package/index.mjs
CHANGED
|
@@ -556,7 +556,8 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
556
556
|
rowHeights: /* @__PURE__ */ new Map(),
|
|
557
557
|
startReachedBlockedByTimer: false,
|
|
558
558
|
layoutsPending: /* @__PURE__ */ new Set(),
|
|
559
|
-
scrollForNextCalculateItemsInView: void 0
|
|
559
|
+
scrollForNextCalculateItemsInView: void 0,
|
|
560
|
+
enableScrollForNextCalculateItemsInView: true
|
|
560
561
|
};
|
|
561
562
|
refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
|
|
562
563
|
if (maintainVisibleContentPosition) {
|
|
@@ -634,7 +635,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
634
635
|
}
|
|
635
636
|
let rowHeight = 0;
|
|
636
637
|
const startEl = n * numColumnsProp;
|
|
637
|
-
for (let i = startEl; i < startEl + numColumnsProp; i++) {
|
|
638
|
+
for (let i = startEl; i < startEl + numColumnsProp && i < data.length; i++) {
|
|
638
639
|
const id = getId(i);
|
|
639
640
|
const size = getItemSize(id, i, data[i]);
|
|
640
641
|
rowHeight = Math.max(rowHeight, size);
|
|
@@ -675,7 +676,6 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
675
676
|
return res;
|
|
676
677
|
};
|
|
677
678
|
const calculateItemsInView = useCallback((speed) => {
|
|
678
|
-
var _a2, _b2, _c2, _d2;
|
|
679
679
|
const state = refState.current;
|
|
680
680
|
const {
|
|
681
681
|
data: data2,
|
|
@@ -698,8 +698,8 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
698
698
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
699
699
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
700
700
|
const scroll = scrollState - previousScrollAdjust - topPad - scrollExtra;
|
|
701
|
-
if (
|
|
702
|
-
const { top: top2, bottom } =
|
|
701
|
+
if (state.scrollForNextCalculateItemsInView) {
|
|
702
|
+
const { top: top2, bottom } = state.scrollForNextCalculateItemsInView;
|
|
703
703
|
if (scroll > top2 && scroll < bottom) {
|
|
704
704
|
return;
|
|
705
705
|
}
|
|
@@ -742,13 +742,13 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
742
742
|
let column = 1;
|
|
743
743
|
let maxSizeInRow = 0;
|
|
744
744
|
const getInitialTop = (i) => {
|
|
745
|
-
var
|
|
745
|
+
var _a2;
|
|
746
746
|
const id = getId(i);
|
|
747
747
|
let topOffset = 0;
|
|
748
748
|
if (positions.get(id)) {
|
|
749
749
|
topOffset = positions.get(id);
|
|
750
750
|
}
|
|
751
|
-
if (id === ((
|
|
751
|
+
if (id === ((_a2 = state.anchorElement) == null ? void 0 : _a2.id)) {
|
|
752
752
|
topOffset = initialContentOffset || 0;
|
|
753
753
|
}
|
|
754
754
|
return topOffset;
|
|
@@ -790,7 +790,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
790
790
|
maxSizeInRow = 0;
|
|
791
791
|
}
|
|
792
792
|
}
|
|
793
|
-
Object.assign(
|
|
793
|
+
Object.assign(state, {
|
|
794
794
|
startBuffered,
|
|
795
795
|
startBufferedId,
|
|
796
796
|
startNoBuffer,
|
|
@@ -801,10 +801,12 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
801
801
|
const nextBottom = Math.floor(
|
|
802
802
|
endBuffered ? (positions.get(getId(endBuffered + 1)) || 0) - scrollLength - scrollBuffer : 0
|
|
803
803
|
);
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
804
|
+
if (state.enableScrollForNextCalculateItemsInView) {
|
|
805
|
+
state.scrollForNextCalculateItemsInView = nextTop >= 0 && nextBottom >= 0 ? {
|
|
806
|
+
top: nextTop,
|
|
807
|
+
bottom: nextBottom
|
|
808
|
+
} : void 0;
|
|
809
|
+
}
|
|
808
810
|
if (startBuffered !== null && endBuffered !== null) {
|
|
809
811
|
const prevNumContainers = ctx.values.get("numContainers");
|
|
810
812
|
let numContainers = prevNumContainers;
|
|
@@ -828,7 +830,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
828
830
|
furthestIndex = u;
|
|
829
831
|
break;
|
|
830
832
|
}
|
|
831
|
-
const index =
|
|
833
|
+
const index = state.indexByKey.get(key);
|
|
832
834
|
const pos = peek$(ctx, `containerPosition${u}`);
|
|
833
835
|
if (index < startBuffered || index > endBuffered) {
|
|
834
836
|
const distance = Math.abs(pos - top2);
|
|
@@ -840,13 +842,13 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
840
842
|
}
|
|
841
843
|
if (furthestIndex >= 0) {
|
|
842
844
|
set$(ctx, `containerItemKey${furthestIndex}`, id);
|
|
843
|
-
const index =
|
|
845
|
+
const index = state.indexByKey.get(id);
|
|
844
846
|
set$(ctx, `containerItemData${furthestIndex}`, data2[index]);
|
|
845
847
|
} else {
|
|
846
848
|
const containerId = numContainers;
|
|
847
849
|
numContainers++;
|
|
848
850
|
set$(ctx, `containerItemKey${containerId}`, id);
|
|
849
|
-
const index =
|
|
851
|
+
const index = state.indexByKey.get(id);
|
|
850
852
|
set$(ctx, `containerItemData${containerId}`, data2[index]);
|
|
851
853
|
set$(ctx, `containerPosition${containerId}`, POSITION_OUT_OF_VIEW);
|
|
852
854
|
set$(ctx, `containerColumn${containerId}`, -1);
|
|
@@ -867,7 +869,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
867
869
|
}
|
|
868
870
|
for (let i = 0; i < numContainers; i++) {
|
|
869
871
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
870
|
-
const itemIndex =
|
|
872
|
+
const itemIndex = state.indexByKey.get(itemKey);
|
|
871
873
|
const item = data2[itemIndex];
|
|
872
874
|
if (item) {
|
|
873
875
|
const id = getId(itemIndex);
|
|
@@ -903,11 +905,11 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
903
905
|
}
|
|
904
906
|
layoutsPending.clear();
|
|
905
907
|
}
|
|
906
|
-
if (
|
|
908
|
+
if (state.viewabilityConfigCallbackPairs) {
|
|
907
909
|
updateViewableItems(
|
|
908
|
-
|
|
910
|
+
state,
|
|
909
911
|
ctx,
|
|
910
|
-
|
|
912
|
+
state.viewabilityConfigCallbackPairs,
|
|
911
913
|
getId,
|
|
912
914
|
scrollLength,
|
|
913
915
|
startNoBuffer,
|
|
@@ -1045,6 +1047,9 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1045
1047
|
maxSizeInRow = 0;
|
|
1046
1048
|
}
|
|
1047
1049
|
}
|
|
1050
|
+
if (maxSizeInRow > 0) {
|
|
1051
|
+
totalSize += maxSizeInRow;
|
|
1052
|
+
}
|
|
1048
1053
|
addTotalSize(null, totalSize, totalSizeBelowIndex);
|
|
1049
1054
|
}
|
|
1050
1055
|
useEffect(() => {
|
|
@@ -1162,8 +1167,11 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1162
1167
|
}, []);
|
|
1163
1168
|
useInit(() => {
|
|
1164
1169
|
var _a2;
|
|
1165
|
-
refState.current
|
|
1166
|
-
const
|
|
1170
|
+
const state = refState.current;
|
|
1171
|
+
const viewability = setupViewability(props);
|
|
1172
|
+
state.viewabilityConfigCallbackPairs = viewability;
|
|
1173
|
+
state.enableScrollForNextCalculateItemsInView = !viewability;
|
|
1174
|
+
const scrollLength = state.scrollLength;
|
|
1167
1175
|
const averageItemSize = (_a2 = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0])) != null ? _a2 : DEFAULT_ITEM_SIZE;
|
|
1168
1176
|
const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize) * numColumnsProp;
|
|
1169
1177
|
for (let i = 0; i < numContainers; i++) {
|
|
@@ -1172,7 +1180,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1172
1180
|
}
|
|
1173
1181
|
set$(ctx, "numContainers", numContainers);
|
|
1174
1182
|
set$(ctx, "numContainersPooled", numContainers * 2);
|
|
1175
|
-
calculateItemsInView(
|
|
1183
|
+
calculateItemsInView(state.scrollVelocity);
|
|
1176
1184
|
});
|
|
1177
1185
|
const updateItemSize = useCallback((containerId, itemKey, size) => {
|
|
1178
1186
|
var _a2;
|
|
@@ -1198,7 +1206,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1198
1206
|
const column = columns.get(itemKey);
|
|
1199
1207
|
const loopStart = index - (column - 1);
|
|
1200
1208
|
let nextMaxSizeInRow = 0;
|
|
1201
|
-
for (let i = loopStart; i < loopStart + numColumns; i++) {
|
|
1209
|
+
for (let i = loopStart; i < loopStart + numColumns && i < data2.length; i++) {
|
|
1202
1210
|
const id = getId(i);
|
|
1203
1211
|
const size2 = getItemSize(id, i, data2[i]);
|
|
1204
1212
|
nextMaxSizeInRow = Math.max(nextMaxSizeInRow, size2);
|