@legendapp/list 1.0.14 → 1.0.15
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/animated.d.mts +4 -1
- package/animated.d.ts +4 -1
- package/index.d.mts +10 -2
- package/index.d.ts +10 -2
- package/index.js +186 -137
- package/index.mjs +187 -139
- package/keyboard-controller.d.mts +145 -133
- package/keyboard-controller.d.ts +145 -133
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React2 from 'react';
|
|
2
|
-
import React2__default, { useReducer, useEffect, createContext, useMemo, useRef, useCallback, useImperativeHandle, useContext, useState, forwardRef, memo
|
|
2
|
+
import React2__default, { useReducer, useEffect, createContext, useMemo, useRef, useCallback, useLayoutEffect, useImperativeHandle, useContext, useState, forwardRef, memo } from 'react';
|
|
3
3
|
import { View, Text, Platform, Animated, ScrollView, StyleSheet, Dimensions, RefreshControl } from 'react-native';
|
|
4
4
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
5
5
|
|
|
@@ -99,6 +99,12 @@ function useArr$(signalNames) {
|
|
|
99
99
|
const value = useSyncExternalStore(subscribe, get);
|
|
100
100
|
return value;
|
|
101
101
|
}
|
|
102
|
+
function useSelector$(signalName, selector) {
|
|
103
|
+
const ctx = React2.useContext(ContextState);
|
|
104
|
+
const { subscribe, get } = React2.useMemo(() => createSelectorFunctionsArr(ctx, [signalName]), [ctx, signalName]);
|
|
105
|
+
const value = useSyncExternalStore(subscribe, () => selector(get()[0]));
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
102
108
|
|
|
103
109
|
// src/DebugView.tsx
|
|
104
110
|
var DebugRow = ({ children }) => {
|
|
@@ -287,6 +293,11 @@ function useRecyclingState(valueOrFun) {
|
|
|
287
293
|
);
|
|
288
294
|
return [refState.current.value, setState];
|
|
289
295
|
}
|
|
296
|
+
function useIsLastItem() {
|
|
297
|
+
const { itemKey } = useContext(ContextContainer);
|
|
298
|
+
const isLast = useSelector$("lastItemKeys", (lastItemKeys) => (lastItemKeys == null ? void 0 : lastItemKeys.includes(itemKey)) || false);
|
|
299
|
+
return isLast;
|
|
300
|
+
}
|
|
290
301
|
var LeanViewComponent = React2.forwardRef((props, ref) => {
|
|
291
302
|
return React2.createElement("RCTView", { ...props, ref });
|
|
292
303
|
});
|
|
@@ -345,12 +356,12 @@ var Container = ({
|
|
|
345
356
|
if (horizontal) {
|
|
346
357
|
paddingStyles = {
|
|
347
358
|
paddingRight: !lastItemKeys.includes(itemKey) ? columnGap || gap || void 0 : void 0,
|
|
348
|
-
paddingVertical: (rowGap || gap || 0) / 2
|
|
359
|
+
paddingVertical: numColumns > 1 ? (rowGap || gap || 0) / 2 : void 0
|
|
349
360
|
};
|
|
350
361
|
} else {
|
|
351
362
|
paddingStyles = {
|
|
352
363
|
paddingBottom: !lastItemKeys.includes(itemKey) ? rowGap || gap || void 0 : void 0,
|
|
353
|
-
paddingHorizontal: (columnGap || gap || 0) / 2
|
|
364
|
+
paddingHorizontal: numColumns > 1 ? (columnGap || gap || 0) / 2 : void 0
|
|
354
365
|
};
|
|
355
366
|
}
|
|
356
367
|
}
|
|
@@ -358,7 +369,6 @@ var Container = ({
|
|
|
358
369
|
flexDirection: ItemSeparatorComponent ? "row" : void 0,
|
|
359
370
|
position: "absolute",
|
|
360
371
|
top: otherAxisPos,
|
|
361
|
-
bottom: numColumns > 1 ? null : 0,
|
|
362
372
|
height: otherAxisSize,
|
|
363
373
|
left: position.relativeCoordinate,
|
|
364
374
|
...paddingStyles || {}
|
|
@@ -381,17 +391,17 @@ var Container = ({
|
|
|
381
391
|
const onLayout = (event) => {
|
|
382
392
|
var _a, _b;
|
|
383
393
|
if (!isNullOrUndefined(itemKey)) {
|
|
384
|
-
|
|
385
|
-
|
|
394
|
+
let layout = event.nativeEvent.layout;
|
|
395
|
+
const size = layout[horizontal ? "width" : "height"];
|
|
386
396
|
const doUpdate = () => {
|
|
387
|
-
refLastSize.current =
|
|
388
|
-
updateItemSize(itemKey,
|
|
397
|
+
refLastSize.current = { width: layout.width, height: layout.height };
|
|
398
|
+
updateItemSize(itemKey, layout);
|
|
389
399
|
};
|
|
390
400
|
if (IsNewArchitecture || size > 0) {
|
|
391
401
|
doUpdate();
|
|
392
402
|
} else {
|
|
393
403
|
(_b = (_a = ref.current) == null ? void 0 : _a.measure) == null ? void 0 : _b.call(_a, (x, y, width, height) => {
|
|
394
|
-
|
|
404
|
+
layout = { width, height };
|
|
395
405
|
doUpdate();
|
|
396
406
|
});
|
|
397
407
|
}
|
|
@@ -405,7 +415,7 @@ var Container = ({
|
|
|
405
415
|
if (measured) {
|
|
406
416
|
const size = Math.floor(measured[horizontal ? "width" : "height"] * 8) / 8;
|
|
407
417
|
if (size) {
|
|
408
|
-
updateItemSize(itemKey,
|
|
418
|
+
updateItemSize(itemKey, measured);
|
|
409
419
|
}
|
|
410
420
|
}
|
|
411
421
|
}
|
|
@@ -430,7 +440,7 @@ var Container = ({
|
|
|
430
440
|
}, [id, itemKey, index, data]);
|
|
431
441
|
const contentFragment = /* @__PURE__ */ React2__default.createElement(React2__default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React2__default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && !lastItemKeys.includes(itemKey) && /* @__PURE__ */ React2__default.createElement(ItemSeparatorComponent, { leadingItem: renderedItemInfo.item })));
|
|
432
442
|
if (maintainVisibleContentPosition) {
|
|
433
|
-
const anchorStyle = position.type === "top" ? { position: "absolute", top: 0, left: 0, right: 0 } : { position: "absolute", bottom: 0, left: 0, right: 0 };
|
|
443
|
+
const anchorStyle = horizontal ? position.type === "top" ? { position: "absolute", left: 0, top: 0, bottom: 0, flexDirection: "row", alignItems: "stretch" } : { position: "absolute", right: 0, top: 0, bottom: 0, flexDirection: "row", alignItems: "stretch" } : position.type === "top" ? { position: "absolute", top: 0, left: 0, right: 0 } : { position: "absolute", bottom: 0, left: 0, right: 0 };
|
|
434
444
|
if (__DEV__ && ENABLE_DEVMODE) {
|
|
435
445
|
anchorStyle.borderColor = position.type === "top" ? "red" : "blue";
|
|
436
446
|
anchorStyle.borderWidth = 1;
|
|
@@ -479,7 +489,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
479
489
|
}) {
|
|
480
490
|
const ctx = useStateContext();
|
|
481
491
|
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
482
|
-
const [numContainers] = useArr$(["numContainersPooled"]);
|
|
492
|
+
const [numContainers, numColumns] = useArr$(["numContainersPooled", "numColumns"]);
|
|
483
493
|
const animSize = useValue$(
|
|
484
494
|
"totalSizeWithScrollAdjust",
|
|
485
495
|
void 0,
|
|
@@ -487,6 +497,12 @@ var Containers = typedMemo(function Containers2({
|
|
|
487
497
|
true
|
|
488
498
|
);
|
|
489
499
|
const animOpacity = waitForInitialLayout ? useValue$("containersDidLayout", (value) => value ? 1 : 0) : void 0;
|
|
500
|
+
const otherAxisSize = useValue$(
|
|
501
|
+
"otherAxisSize",
|
|
502
|
+
void 0,
|
|
503
|
+
/*useMicrotask*/
|
|
504
|
+
true
|
|
505
|
+
);
|
|
490
506
|
const containers = [];
|
|
491
507
|
for (let i = 0; i < numContainers; i++) {
|
|
492
508
|
containers.push(
|
|
@@ -504,8 +520,8 @@ var Containers = typedMemo(function Containers2({
|
|
|
504
520
|
)
|
|
505
521
|
);
|
|
506
522
|
}
|
|
507
|
-
const style = horizontal ? { width: animSize, opacity: animOpacity } : { height: animSize, opacity: animOpacity };
|
|
508
|
-
if (columnWrapperStyle) {
|
|
523
|
+
const style = horizontal ? { width: animSize, opacity: animOpacity, minHeight: otherAxisSize } : { height: animSize, opacity: animOpacity, minWidth: otherAxisSize };
|
|
524
|
+
if (columnWrapperStyle && numColumns > 1) {
|
|
509
525
|
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
510
526
|
if (horizontal) {
|
|
511
527
|
const my = (rowGap || gap || 0) / 2;
|
|
@@ -1005,6 +1021,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1005
1021
|
onViewableItemsChanged,
|
|
1006
1022
|
...rest
|
|
1007
1023
|
} = props;
|
|
1024
|
+
const refLoadStartTime = useRef(Date.now());
|
|
1008
1025
|
const callbacks = useRef({
|
|
1009
1026
|
onStartReached: rest.onStartReached,
|
|
1010
1027
|
onEndReached: rest.onEndReached
|
|
@@ -1209,6 +1226,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1209
1226
|
const setDidLayout = () => {
|
|
1210
1227
|
refState.current.queuedInitialLayout = true;
|
|
1211
1228
|
checkAtBottom();
|
|
1229
|
+
const setIt = () => {
|
|
1230
|
+
set$(ctx, "containersDidLayout", true);
|
|
1231
|
+
if (props.onLoad) {
|
|
1232
|
+
props.onLoad({ elapsedTimeInMs: Date.now() - refLoadStartTime.current });
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1212
1235
|
if (initialScrollIndex) {
|
|
1213
1236
|
queueMicrotask(() => {
|
|
1214
1237
|
scrollToIndex({ index: initialScrollIndex, animated: false });
|
|
@@ -1216,13 +1239,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1216
1239
|
if (!IsNewArchitecture) {
|
|
1217
1240
|
scrollToIndex({ index: initialScrollIndex, animated: false });
|
|
1218
1241
|
}
|
|
1219
|
-
|
|
1242
|
+
setIt();
|
|
1220
1243
|
});
|
|
1221
1244
|
});
|
|
1222
1245
|
} else {
|
|
1223
|
-
queueMicrotask(
|
|
1224
|
-
set$(ctx, "containersDidLayout", true);
|
|
1225
|
-
});
|
|
1246
|
+
queueMicrotask(setIt);
|
|
1226
1247
|
}
|
|
1227
1248
|
};
|
|
1228
1249
|
const addTotalSize = useCallback((key, add, totalSizeBelowAnchor) => {
|
|
@@ -1354,10 +1375,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1354
1375
|
});
|
|
1355
1376
|
numMeasurements++;
|
|
1356
1377
|
if (measured) {
|
|
1357
|
-
const size = Math.floor(measured[horizontal ? "width" : "height"] * 8) / 8;
|
|
1358
1378
|
updateItemSize(
|
|
1359
1379
|
itemKey,
|
|
1360
|
-
|
|
1380
|
+
measured,
|
|
1361
1381
|
/*fromFixGaps*/
|
|
1362
1382
|
true
|
|
1363
1383
|
);
|
|
@@ -1455,13 +1475,15 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1455
1475
|
scrollBufferBottom = scrollBuffer * 0.1;
|
|
1456
1476
|
}
|
|
1457
1477
|
}
|
|
1478
|
+
const scrollTopBuffered = scroll - scrollBufferTop;
|
|
1479
|
+
const scrollBottom = scroll + scrollLength;
|
|
1480
|
+
const scrollBottomBuffered = scrollBottom + scrollBufferBottom;
|
|
1458
1481
|
if (state.scrollForNextCalculateItemsInView) {
|
|
1459
1482
|
const { top: top2, bottom } = state.scrollForNextCalculateItemsInView;
|
|
1460
|
-
if (
|
|
1483
|
+
if (scrollTopBuffered > top2 && scrollBottomBuffered < bottom) {
|
|
1461
1484
|
return;
|
|
1462
1485
|
}
|
|
1463
1486
|
}
|
|
1464
|
-
const scrollBottom = scroll + scrollLength;
|
|
1465
1487
|
let startNoBuffer = null;
|
|
1466
1488
|
let startBuffered = null;
|
|
1467
1489
|
let startBufferedId = null;
|
|
@@ -1541,7 +1563,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1541
1563
|
if (startNoBuffer === null && top + size > scroll) {
|
|
1542
1564
|
startNoBuffer = i;
|
|
1543
1565
|
}
|
|
1544
|
-
if (startBuffered === null && top + size >
|
|
1566
|
+
if (startBuffered === null && top + size > scrollTopBuffered) {
|
|
1545
1567
|
startBuffered = i;
|
|
1546
1568
|
startBufferedId = id;
|
|
1547
1569
|
nextTop = top;
|
|
@@ -1550,7 +1572,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1550
1572
|
if (top <= scrollBottom) {
|
|
1551
1573
|
endNoBuffer = i;
|
|
1552
1574
|
}
|
|
1553
|
-
if (top <=
|
|
1575
|
+
if (top <= scrollBottomBuffered) {
|
|
1554
1576
|
endBuffered = i;
|
|
1555
1577
|
nextBottom = top + maxSizeInRow - scrollLength;
|
|
1556
1578
|
} else {
|
|
@@ -1839,8 +1861,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1839
1861
|
for (let i = 0; i < numContainers; i++) {
|
|
1840
1862
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1841
1863
|
if (!keyExtractorProp || itemKey && state.indexByKey.get(itemKey) === void 0) {
|
|
1842
|
-
set$(ctx, `containerItemKey${i}`,
|
|
1843
|
-
set$(ctx, `containerItemData${i}`,
|
|
1864
|
+
set$(ctx, `containerItemKey${i}`, void 0);
|
|
1865
|
+
set$(ctx, `containerItemData${i}`, void 0);
|
|
1844
1866
|
set$(ctx, `containerPosition${i}`, ANCHORED_POSITION_OUT_OF_VIEW);
|
|
1845
1867
|
set$(ctx, `containerColumn${i}`, -1);
|
|
1846
1868
|
}
|
|
@@ -2121,120 +2143,130 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2121
2143
|
useInit(() => {
|
|
2122
2144
|
doInitialAllocateContainers();
|
|
2123
2145
|
});
|
|
2124
|
-
const updateItemSize = useCallback(
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
averages = averageSizes[itemType]
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
averages.num++;
|
|
2159
|
-
if (!prevSize || Math.abs(prevSize - size) > 0.1) {
|
|
2160
|
-
let diff;
|
|
2161
|
-
needsCalculate = true;
|
|
2162
|
-
if (numColumns > 1) {
|
|
2163
|
-
const rowNumber = Math.floor(index / numColumnsProp);
|
|
2164
|
-
const prevSizeInRow = getRowHeight(rowNumber);
|
|
2165
|
-
sizes.set(itemKey, size);
|
|
2166
|
-
rowHeights.delete(rowNumber);
|
|
2167
|
-
const sizeInRow = getRowHeight(rowNumber);
|
|
2168
|
-
diff = sizeInRow - prevSizeInRow;
|
|
2169
|
-
} else {
|
|
2170
|
-
sizes.set(itemKey, size);
|
|
2171
|
-
diff = size - prevSize;
|
|
2146
|
+
const updateItemSize = useCallback(
|
|
2147
|
+
(itemKey, sizeObj, fromFixGaps) => {
|
|
2148
|
+
const state = refState.current;
|
|
2149
|
+
const {
|
|
2150
|
+
sizes,
|
|
2151
|
+
indexByKey,
|
|
2152
|
+
sizesKnown,
|
|
2153
|
+
data,
|
|
2154
|
+
rowHeights,
|
|
2155
|
+
startBuffered,
|
|
2156
|
+
endBuffered,
|
|
2157
|
+
averageSizes,
|
|
2158
|
+
queuedInitialLayout
|
|
2159
|
+
} = state;
|
|
2160
|
+
if (!data) {
|
|
2161
|
+
return;
|
|
2162
|
+
}
|
|
2163
|
+
const index = indexByKey.get(itemKey);
|
|
2164
|
+
const numColumns = peek$(ctx, "numColumns");
|
|
2165
|
+
state.scrollForNextCalculateItemsInView = void 0;
|
|
2166
|
+
state.minIndexSizeChanged = state.minIndexSizeChanged !== void 0 ? Math.min(state.minIndexSizeChanged, index) : index;
|
|
2167
|
+
const prevSize = getItemSize(itemKey, index, data);
|
|
2168
|
+
const prevSizeKnown = sizesKnown.get(itemKey);
|
|
2169
|
+
let needsCalculate = false;
|
|
2170
|
+
let needsUpdateContainersDidLayout = false;
|
|
2171
|
+
const size = Math.floor((horizontal ? sizeObj.width : sizeObj.height) * 8) / 8;
|
|
2172
|
+
sizesKnown.set(itemKey, size);
|
|
2173
|
+
const itemType = "";
|
|
2174
|
+
let averages = averageSizes[itemType];
|
|
2175
|
+
if (!averages) {
|
|
2176
|
+
averages = averageSizes[itemType] = {
|
|
2177
|
+
num: 0,
|
|
2178
|
+
avg: 0
|
|
2179
|
+
};
|
|
2172
2180
|
}
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2181
|
+
averages.avg = (averages.avg * averages.num + size) / (averages.num + 1);
|
|
2182
|
+
averages.num++;
|
|
2183
|
+
if (!prevSize || Math.abs(prevSize - size) > 0.1) {
|
|
2184
|
+
let diff;
|
|
2185
|
+
needsCalculate = true;
|
|
2186
|
+
if (numColumns > 1) {
|
|
2187
|
+
const rowNumber = Math.floor(index / numColumnsProp);
|
|
2188
|
+
const prevSizeInRow = getRowHeight(rowNumber);
|
|
2189
|
+
sizes.set(itemKey, size);
|
|
2190
|
+
rowHeights.delete(rowNumber);
|
|
2191
|
+
const sizeInRow = getRowHeight(rowNumber);
|
|
2192
|
+
diff = sizeInRow - prevSizeInRow;
|
|
2193
|
+
} else {
|
|
2194
|
+
sizes.set(itemKey, size);
|
|
2195
|
+
diff = size - prevSize;
|
|
2196
|
+
}
|
|
2197
|
+
if (__DEV__ && suggestEstimatedItemSize) {
|
|
2198
|
+
if (state.timeoutSizeMessage) {
|
|
2199
|
+
clearTimeout(state.timeoutSizeMessage);
|
|
2200
|
+
}
|
|
2201
|
+
state.timeoutSizeMessage = setTimeout(() => {
|
|
2202
|
+
state.timeoutSizeMessage = void 0;
|
|
2203
|
+
const num = sizesKnown.size;
|
|
2204
|
+
const avg = state.averageSizes[""].avg;
|
|
2205
|
+
console.warn(
|
|
2206
|
+
`[legend-list] estimatedItemSize or getEstimatedItemSize are not defined. Based on the ${num} items rendered so far, the optimal estimated size is ${avg}.`
|
|
2207
|
+
);
|
|
2208
|
+
}, 1e3);
|
|
2209
|
+
}
|
|
2210
|
+
state.scrollForNextCalculateItemsInView = void 0;
|
|
2211
|
+
addTotalSize(itemKey, diff, 0);
|
|
2212
|
+
if (prevSizeKnown !== void 0 && Math.abs(prevSizeKnown - size) > 5) {
|
|
2213
|
+
doMaintainScrollAtEnd(false);
|
|
2214
|
+
}
|
|
2215
|
+
if (onItemSizeChanged) {
|
|
2216
|
+
onItemSizeChanged({
|
|
2217
|
+
size,
|
|
2218
|
+
previous: prevSize,
|
|
2219
|
+
index,
|
|
2220
|
+
itemKey,
|
|
2221
|
+
itemData: data[index]
|
|
2222
|
+
});
|
|
2176
2223
|
}
|
|
2177
|
-
state.timeoutSizeMessage = setTimeout(() => {
|
|
2178
|
-
state.timeoutSizeMessage = void 0;
|
|
2179
|
-
const num = sizesKnown.size;
|
|
2180
|
-
const avg = state.averageSizes[""].avg;
|
|
2181
|
-
console.warn(
|
|
2182
|
-
`[legend-list] estimatedItemSize or getEstimatedItemSize are not defined. Based on the ${num} items rendered so far, the optimal estimated size is ${avg}.`
|
|
2183
|
-
);
|
|
2184
|
-
}, 1e3);
|
|
2185
2224
|
}
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
if (prevSizeKnown !== void 0 && Math.abs(prevSizeKnown - size) > 5) {
|
|
2189
|
-
doMaintainScrollAtEnd(false);
|
|
2190
|
-
}
|
|
2191
|
-
if (onItemSizeChanged) {
|
|
2192
|
-
onItemSizeChanged({
|
|
2193
|
-
size,
|
|
2194
|
-
previous: prevSize,
|
|
2195
|
-
index,
|
|
2196
|
-
itemKey,
|
|
2197
|
-
itemData: data[index]
|
|
2198
|
-
});
|
|
2225
|
+
if (!queuedInitialLayout && checkAllSizesKnown()) {
|
|
2226
|
+
needsUpdateContainersDidLayout = true;
|
|
2199
2227
|
}
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
if (peek$(ctx, `containerItemKey${i}`) === itemKey) {
|
|
2209
|
-
isInView = true;
|
|
2210
|
-
break;
|
|
2228
|
+
let isInView = index >= startBuffered && index <= endBuffered;
|
|
2229
|
+
if (!isInView) {
|
|
2230
|
+
const numContainers = ctx.values.get("numContainers");
|
|
2231
|
+
for (let i = 0; i < numContainers; i++) {
|
|
2232
|
+
if (peek$(ctx, `containerItemKey${i}`) === itemKey) {
|
|
2233
|
+
isInView = true;
|
|
2234
|
+
break;
|
|
2235
|
+
}
|
|
2211
2236
|
}
|
|
2212
2237
|
}
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
}
|
|
2238
|
+
if (needsUpdateContainersDidLayout || !fromFixGaps && needsCalculate && (isInView || !queuedInitialLayout)) {
|
|
2239
|
+
const scrollVelocity = state.scrollVelocity;
|
|
2240
|
+
let didCalculate = false;
|
|
2241
|
+
if ((Number.isNaN(scrollVelocity) || Math.abs(scrollVelocity) < 1 || state.scrollingToOffset !== void 0) && (!waitForInitialLayout || needsUpdateContainersDidLayout || queuedInitialLayout)) {
|
|
2242
|
+
if (Date.now() - state.lastBatchingAction < 500) {
|
|
2243
|
+
if (!state.queuedCalculateItemsInView) {
|
|
2244
|
+
state.queuedCalculateItemsInView = requestAnimationFrame(() => {
|
|
2245
|
+
state.queuedCalculateItemsInView = void 0;
|
|
2246
|
+
calculateItemsInView();
|
|
2247
|
+
});
|
|
2248
|
+
}
|
|
2249
|
+
} else {
|
|
2250
|
+
calculateItemsInView();
|
|
2251
|
+
didCalculate = true;
|
|
2224
2252
|
}
|
|
2225
|
-
}
|
|
2226
|
-
|
|
2227
|
-
|
|
2253
|
+
}
|
|
2254
|
+
if (!didCalculate && !needsUpdateContainersDidLayout && IsNewArchitecture) {
|
|
2255
|
+
fixGaps();
|
|
2228
2256
|
}
|
|
2229
2257
|
}
|
|
2230
|
-
if (
|
|
2231
|
-
|
|
2258
|
+
if (state.needsOtherAxisSize) {
|
|
2259
|
+
const otherAxisSize = horizontal ? sizeObj.height : sizeObj.width;
|
|
2260
|
+
const cur = peek$(ctx, "otherAxisSize");
|
|
2261
|
+
if (!cur || otherAxisSize > cur) {
|
|
2262
|
+
set$(ctx, "otherAxisSize", otherAxisSize);
|
|
2263
|
+
}
|
|
2232
2264
|
}
|
|
2233
|
-
}
|
|
2234
|
-
|
|
2235
|
-
|
|
2265
|
+
},
|
|
2266
|
+
[]
|
|
2267
|
+
);
|
|
2268
|
+
const handleLayout = useCallback((scrollLength) => {
|
|
2236
2269
|
const state = refState.current;
|
|
2237
|
-
const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
2238
2270
|
const didChange = scrollLength !== state.scrollLength;
|
|
2239
2271
|
state.scrollLength = scrollLength;
|
|
2240
2272
|
state.lastBatchingAction = Date.now();
|
|
@@ -2247,20 +2279,36 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2247
2279
|
if (didChange) {
|
|
2248
2280
|
calculateItemsInView();
|
|
2249
2281
|
}
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2282
|
+
}, []);
|
|
2283
|
+
const onLayout = useCallback((event) => {
|
|
2284
|
+
const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
2285
|
+
handleLayout(scrollLength);
|
|
2286
|
+
const otherAxisSize = event.nativeEvent.layout[horizontal ? "height" : "width"];
|
|
2287
|
+
if (refState.current) {
|
|
2288
|
+
refState.current.needsOtherAxisSize = otherAxisSize - (stylePaddingTopState || 0) < 10;
|
|
2289
|
+
}
|
|
2290
|
+
if (__DEV__ && scrollLength === 0) {
|
|
2291
|
+
warnDevOnce(
|
|
2292
|
+
"height0",
|
|
2293
|
+
`List ${horizontal ? "width" : "height"} is 0. You may need to set a style or \`flex: \` for the list, because children are absolutely positioned.`
|
|
2294
|
+
);
|
|
2259
2295
|
}
|
|
2260
2296
|
if (onLayoutProp) {
|
|
2261
2297
|
onLayoutProp(event);
|
|
2262
2298
|
}
|
|
2263
2299
|
}, []);
|
|
2300
|
+
if (IsNewArchitecture) {
|
|
2301
|
+
useLayoutEffect(() => {
|
|
2302
|
+
var _a, _b;
|
|
2303
|
+
const measured = (_b = (_a = refScroller.current) == null ? void 0 : _a.unstable_getBoundingClientRect) == null ? void 0 : _b.call(_a);
|
|
2304
|
+
if (measured) {
|
|
2305
|
+
const size = Math.floor(measured[horizontal ? "width" : "height"] * 8) / 8;
|
|
2306
|
+
if (size) {
|
|
2307
|
+
handleLayout(size);
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
}, []);
|
|
2311
|
+
}
|
|
2264
2312
|
const handleScroll = useCallback(
|
|
2265
2313
|
(event) => {
|
|
2266
2314
|
var _a, _b, _c, _d;
|
|
@@ -2458,4 +2506,4 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2458
2506
|
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React2.createElement(DebugView, { state: refState.current }));
|
|
2459
2507
|
});
|
|
2460
2508
|
|
|
2461
|
-
export { LegendList, useRecyclingEffect, useRecyclingState, useViewability, useViewabilityAmount };
|
|
2509
|
+
export { LegendList, useIsLastItem, useRecyclingEffect, useRecyclingState, useViewability, useViewabilityAmount };
|