@legendapp/list 2.0.0-next.5 → 2.0.0-next.7
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 +9 -1
- package/index.d.ts +9 -1
- package/index.js +280 -284
- package/index.mjs +281 -285
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React3 from 'react';
|
|
2
|
-
import React3__default, { useReducer, useEffect, createContext,
|
|
3
|
-
import { View, Text, Platform, Animated, ScrollView, StyleSheet, Dimensions, RefreshControl } from 'react-native';
|
|
2
|
+
import React3__default, { useReducer, useEffect, createContext, useRef, useState, useMemo, useLayoutEffect, useCallback, useImperativeHandle, useContext, forwardRef, memo } from 'react';
|
|
3
|
+
import { View, Text, Platform, Animated, ScrollView, StyleSheet, Dimensions, RefreshControl, unstable_batchedUpdates } from 'react-native';
|
|
4
4
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
5
5
|
|
|
6
6
|
// src/components/LazyLegendList.tsx
|
|
@@ -311,16 +311,18 @@ function useListScrollSize() {
|
|
|
311
311
|
const [scrollSize] = useArr$(["scrollSize"]);
|
|
312
312
|
return scrollSize;
|
|
313
313
|
}
|
|
314
|
+
var typedForwardRef = forwardRef;
|
|
315
|
+
var typedMemo = memo;
|
|
314
316
|
|
|
315
317
|
// src/components/Container.tsx
|
|
316
|
-
var Container = ({
|
|
318
|
+
var Container = typedMemo(function Container2({
|
|
317
319
|
id,
|
|
318
320
|
recycleItems,
|
|
319
321
|
horizontal,
|
|
320
322
|
getRenderedItem: getRenderedItem2,
|
|
321
323
|
updateItemSize: updateItemSize2,
|
|
322
324
|
ItemSeparatorComponent
|
|
323
|
-
})
|
|
325
|
+
}) {
|
|
324
326
|
const ctx = useStateContext();
|
|
325
327
|
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
326
328
|
const [column = 0, data, itemKey, position = POSITION_OUT_OF_VIEW, numColumns, extraData] = useArr$([
|
|
@@ -372,12 +374,17 @@ var Container = ({
|
|
|
372
374
|
[itemKey, data, extraData]
|
|
373
375
|
);
|
|
374
376
|
const { index, renderedItem } = renderedItemInfo || {};
|
|
375
|
-
const triggerLayout = useCallback(() => {
|
|
376
|
-
forceLayoutRender((v) => v + 1);
|
|
377
|
-
}, []);
|
|
378
377
|
const contextValue = useMemo(() => {
|
|
379
378
|
ctx.viewRefs.set(id, ref);
|
|
380
|
-
return {
|
|
379
|
+
return {
|
|
380
|
+
containerId: id,
|
|
381
|
+
index,
|
|
382
|
+
itemKey,
|
|
383
|
+
triggerLayout: () => {
|
|
384
|
+
forceLayoutRender((v) => v + 1);
|
|
385
|
+
},
|
|
386
|
+
value: data
|
|
387
|
+
};
|
|
381
388
|
}, [id, itemKey, index, data]);
|
|
382
389
|
const onLayout = (event) => {
|
|
383
390
|
var _a, _b;
|
|
@@ -434,7 +441,7 @@ var Container = ({
|
|
|
434
441
|
leadingItem: renderedItemInfo.item
|
|
435
442
|
}
|
|
436
443
|
)));
|
|
437
|
-
};
|
|
444
|
+
});
|
|
438
445
|
var useAnimatedValue = (initialValue) => {
|
|
439
446
|
return useRef(new Animated.Value(initialValue)).current;
|
|
440
447
|
};
|
|
@@ -475,8 +482,6 @@ function useValue$(key, params) {
|
|
|
475
482
|
}, []);
|
|
476
483
|
return animValue;
|
|
477
484
|
}
|
|
478
|
-
var typedForwardRef = forwardRef;
|
|
479
|
-
var typedMemo = memo;
|
|
480
485
|
|
|
481
486
|
// src/components/Containers.tsx
|
|
482
487
|
var Containers = typedMemo(function Containers2({
|
|
@@ -569,13 +574,15 @@ function useSyncLayout({
|
|
|
569
574
|
},
|
|
570
575
|
[onChange]
|
|
571
576
|
);
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
ref.current
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
577
|
+
if (IsNewArchitecture) {
|
|
578
|
+
useLayoutEffect(() => {
|
|
579
|
+
if (ref.current) {
|
|
580
|
+
ref.current.measure((x, y, width, height) => {
|
|
581
|
+
onChange({ height, width, x, y }, true);
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
}, []);
|
|
585
|
+
}
|
|
579
586
|
return { onLayout, ref };
|
|
580
587
|
}
|
|
581
588
|
|
|
@@ -742,7 +749,7 @@ function getItemSize(state, key, index, data, useAverageSize) {
|
|
|
742
749
|
return sizeKnown;
|
|
743
750
|
}
|
|
744
751
|
let size;
|
|
745
|
-
if (
|
|
752
|
+
if (useAverageSize !== void 0 && sizeKnown === void 0 && !getEstimatedItemSize && !scrollingTo) {
|
|
746
753
|
size = useAverageSize;
|
|
747
754
|
}
|
|
748
755
|
if (size === void 0) {
|
|
@@ -1458,266 +1465,267 @@ function setDidLayout(ctx, state) {
|
|
|
1458
1465
|
|
|
1459
1466
|
// src/core/calculateItemsInView.ts
|
|
1460
1467
|
function calculateItemsInView(ctx, state, params = {}) {
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
}
|
|
1480
|
-
const totalSize = peek$(ctx, "totalSize");
|
|
1481
|
-
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1482
|
-
const numColumns = peek$(ctx, "numColumns");
|
|
1483
|
-
const previousScrollAdjust = 0;
|
|
1484
|
-
const { dataChanged, doMVCP } = params;
|
|
1485
|
-
const speed = getScrollVelocity(state);
|
|
1486
|
-
if (doMVCP || dataChanged) {
|
|
1487
|
-
const checkMVCP = doMVCP ? prepareMVCP(ctx, state) : void 0;
|
|
1488
|
-
updateAllPositions(ctx, state, dataChanged);
|
|
1489
|
-
checkMVCP == null ? void 0 : checkMVCP();
|
|
1490
|
-
}
|
|
1491
|
-
const scrollExtra = 0;
|
|
1492
|
-
const { queuedInitialLayout } = state;
|
|
1493
|
-
let { scroll: scrollState } = state;
|
|
1494
|
-
const initialScroll = state.props.initialScroll;
|
|
1495
|
-
if (!queuedInitialLayout && initialScroll) {
|
|
1496
|
-
const updatedOffset = calculateOffsetWithOffsetPosition(
|
|
1497
|
-
state,
|
|
1498
|
-
calculateOffsetForIndex(ctx, state, initialScroll.index),
|
|
1499
|
-
initialScroll
|
|
1500
|
-
);
|
|
1501
|
-
scrollState = updatedOffset;
|
|
1502
|
-
}
|
|
1503
|
-
const scrollAdjustPad = -previousScrollAdjust - topPad;
|
|
1504
|
-
let scroll = scrollState + scrollExtra + scrollAdjustPad;
|
|
1505
|
-
if (scroll + scrollLength > totalSize) {
|
|
1506
|
-
scroll = totalSize - scrollLength;
|
|
1507
|
-
}
|
|
1508
|
-
if (ENABLE_DEBUG_VIEW) {
|
|
1509
|
-
set$(ctx, "debugRawScroll", scrollState);
|
|
1510
|
-
set$(ctx, "debugComputedScroll", scroll);
|
|
1511
|
-
}
|
|
1512
|
-
const scrollBuffer = state.props.scrollBuffer;
|
|
1513
|
-
let scrollBufferTop = scrollBuffer;
|
|
1514
|
-
let scrollBufferBottom = scrollBuffer;
|
|
1515
|
-
if (speed > 0) {
|
|
1516
|
-
scrollBufferTop = scrollBuffer * 0.5;
|
|
1517
|
-
scrollBufferBottom = scrollBuffer * 1.5;
|
|
1518
|
-
} else {
|
|
1519
|
-
scrollBufferTop = scrollBuffer * 1.5;
|
|
1520
|
-
scrollBufferBottom = scrollBuffer * 0.5;
|
|
1521
|
-
}
|
|
1522
|
-
const scrollTopBuffered = scroll - scrollBufferTop;
|
|
1523
|
-
const scrollBottom = scroll + scrollLength;
|
|
1524
|
-
const scrollBottomBuffered = scrollBottom + scrollBufferBottom;
|
|
1525
|
-
if (scrollForNextCalculateItemsInView) {
|
|
1526
|
-
const { top, bottom } = scrollForNextCalculateItemsInView;
|
|
1527
|
-
if (scrollTopBuffered > top && scrollBottomBuffered < bottom) {
|
|
1468
|
+
unstable_batchedUpdates(() => {
|
|
1469
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1470
|
+
const {
|
|
1471
|
+
scrollLength,
|
|
1472
|
+
startBufferedId: startBufferedIdOrig,
|
|
1473
|
+
positions,
|
|
1474
|
+
columns,
|
|
1475
|
+
containerItemKeys,
|
|
1476
|
+
idCache,
|
|
1477
|
+
sizes,
|
|
1478
|
+
indexByKey,
|
|
1479
|
+
scrollForNextCalculateItemsInView,
|
|
1480
|
+
enableScrollForNextCalculateItemsInView,
|
|
1481
|
+
minIndexSizeChanged
|
|
1482
|
+
} = state;
|
|
1483
|
+
const data = state.props.data;
|
|
1484
|
+
const prevNumContainers = peek$(ctx, "numContainers");
|
|
1485
|
+
if (!data || scrollLength === 0 || !prevNumContainers) {
|
|
1528
1486
|
return;
|
|
1529
1487
|
}
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
const
|
|
1543
|
-
|
|
1544
|
-
const
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1488
|
+
const totalSize = peek$(ctx, "totalSize");
|
|
1489
|
+
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1490
|
+
const numColumns = peek$(ctx, "numColumns");
|
|
1491
|
+
const previousScrollAdjust = 0;
|
|
1492
|
+
const { dataChanged, doMVCP } = params;
|
|
1493
|
+
const speed = getScrollVelocity(state);
|
|
1494
|
+
if (doMVCP || dataChanged) {
|
|
1495
|
+
const checkMVCP = doMVCP ? prepareMVCP(ctx, state) : void 0;
|
|
1496
|
+
updateAllPositions(ctx, state, dataChanged);
|
|
1497
|
+
checkMVCP == null ? void 0 : checkMVCP();
|
|
1498
|
+
}
|
|
1499
|
+
const scrollExtra = 0;
|
|
1500
|
+
const { queuedInitialLayout } = state;
|
|
1501
|
+
let { scroll: scrollState } = state;
|
|
1502
|
+
const initialScroll = state.props.initialScroll;
|
|
1503
|
+
if (!queuedInitialLayout && initialScroll) {
|
|
1504
|
+
const updatedOffset = calculateOffsetWithOffsetPosition(
|
|
1505
|
+
state,
|
|
1506
|
+
calculateOffsetForIndex(ctx, state, initialScroll.index),
|
|
1507
|
+
initialScroll
|
|
1508
|
+
);
|
|
1509
|
+
scrollState = updatedOffset;
|
|
1510
|
+
}
|
|
1511
|
+
const scrollAdjustPad = -previousScrollAdjust - topPad;
|
|
1512
|
+
let scroll = scrollState + scrollExtra + scrollAdjustPad;
|
|
1513
|
+
if (scroll + scrollLength > totalSize) {
|
|
1514
|
+
scroll = totalSize - scrollLength;
|
|
1515
|
+
}
|
|
1516
|
+
if (ENABLE_DEBUG_VIEW) {
|
|
1517
|
+
set$(ctx, "debugRawScroll", scrollState);
|
|
1518
|
+
set$(ctx, "debugComputedScroll", scroll);
|
|
1519
|
+
}
|
|
1520
|
+
const scrollBuffer = state.props.scrollBuffer;
|
|
1521
|
+
let scrollBufferTop = scrollBuffer;
|
|
1522
|
+
let scrollBufferBottom = scrollBuffer;
|
|
1523
|
+
if (speed > 0) {
|
|
1524
|
+
scrollBufferTop = scrollBuffer * 0.5;
|
|
1525
|
+
scrollBufferBottom = scrollBuffer * 1.5;
|
|
1548
1526
|
} else {
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
let maxIndexRendered = 0;
|
|
1560
|
-
for (let i = 0; i < prevNumContainers; i++) {
|
|
1561
|
-
const key = peek$(ctx, `containerItemKey${i}`);
|
|
1562
|
-
if (key !== void 0) {
|
|
1563
|
-
const index = indexByKey.get(key);
|
|
1564
|
-
maxIndexRendered = Math.max(maxIndexRendered, index);
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
let firstFullyOnScreenIndex;
|
|
1568
|
-
const dataLength = data.length;
|
|
1569
|
-
for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
|
|
1570
|
-
const id = (_c = idCache.get(i)) != null ? _c : getId(state, i);
|
|
1571
|
-
const size = (_d = sizes.get(id)) != null ? _d : getItemSize(state, id, i, data[i]);
|
|
1572
|
-
const top = positions.get(id);
|
|
1573
|
-
if (!foundEnd) {
|
|
1574
|
-
if (startNoBuffer === null && top + size > scroll) {
|
|
1575
|
-
startNoBuffer = i;
|
|
1576
|
-
}
|
|
1577
|
-
if (firstFullyOnScreenIndex === void 0 && top >= scroll - 10) {
|
|
1578
|
-
firstFullyOnScreenIndex = i;
|
|
1579
|
-
}
|
|
1580
|
-
if (startBuffered === null && top + size > scrollTopBuffered) {
|
|
1581
|
-
startBuffered = i;
|
|
1582
|
-
startBufferedId = id;
|
|
1583
|
-
nextTop = top;
|
|
1584
|
-
}
|
|
1585
|
-
if (startNoBuffer !== null) {
|
|
1586
|
-
if (top <= scrollBottom) {
|
|
1587
|
-
endNoBuffer = i;
|
|
1588
|
-
}
|
|
1589
|
-
if (top <= scrollBottomBuffered) {
|
|
1590
|
-
endBuffered = i;
|
|
1591
|
-
nextBottom = top + size;
|
|
1592
|
-
} else {
|
|
1593
|
-
foundEnd = true;
|
|
1594
|
-
}
|
|
1527
|
+
scrollBufferTop = scrollBuffer * 1.5;
|
|
1528
|
+
scrollBufferBottom = scrollBuffer * 0.5;
|
|
1529
|
+
}
|
|
1530
|
+
const scrollTopBuffered = scroll - scrollBufferTop;
|
|
1531
|
+
const scrollBottom = scroll + scrollLength;
|
|
1532
|
+
const scrollBottomBuffered = scrollBottom + scrollBufferBottom;
|
|
1533
|
+
if (scrollForNextCalculateItemsInView) {
|
|
1534
|
+
const { top, bottom } = scrollForNextCalculateItemsInView;
|
|
1535
|
+
if (scrollTopBuffered > top && scrollBottomBuffered < bottom) {
|
|
1536
|
+
return;
|
|
1595
1537
|
}
|
|
1596
1538
|
}
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
} : void 0;
|
|
1617
|
-
}
|
|
1618
|
-
const numContainers = peek$(ctx, "numContainers");
|
|
1619
|
-
const pendingRemoval = [];
|
|
1620
|
-
if (dataChanged) {
|
|
1621
|
-
for (let i = 0; i < numContainers; i++) {
|
|
1622
|
-
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1623
|
-
if (!state.props.keyExtractor || itemKey && indexByKey.get(itemKey) === void 0) {
|
|
1624
|
-
pendingRemoval.push(i);
|
|
1539
|
+
let startNoBuffer = null;
|
|
1540
|
+
let startBuffered = null;
|
|
1541
|
+
let startBufferedId = null;
|
|
1542
|
+
let endNoBuffer = null;
|
|
1543
|
+
let endBuffered = null;
|
|
1544
|
+
let loopStart = startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
|
|
1545
|
+
if (minIndexSizeChanged !== void 0) {
|
|
1546
|
+
loopStart = Math.min(minIndexSizeChanged, loopStart);
|
|
1547
|
+
state.minIndexSizeChanged = void 0;
|
|
1548
|
+
}
|
|
1549
|
+
for (let i = loopStart; i >= 0; i--) {
|
|
1550
|
+
const id = (_a = idCache.get(i)) != null ? _a : getId(state, i);
|
|
1551
|
+
const top = positions.get(id);
|
|
1552
|
+
const size = (_b = sizes.get(id)) != null ? _b : getItemSize(state, id, i, data[i]);
|
|
1553
|
+
const bottom = top + size;
|
|
1554
|
+
if (bottom > scroll - scrollBuffer) {
|
|
1555
|
+
loopStart = i;
|
|
1556
|
+
} else {
|
|
1557
|
+
break;
|
|
1625
1558
|
}
|
|
1626
1559
|
}
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1560
|
+
const loopStartMod = loopStart % numColumns;
|
|
1561
|
+
if (loopStartMod > 0) {
|
|
1562
|
+
loopStart -= loopStartMod;
|
|
1563
|
+
}
|
|
1564
|
+
let foundEnd = false;
|
|
1565
|
+
let nextTop;
|
|
1566
|
+
let nextBottom;
|
|
1567
|
+
let maxIndexRendered = 0;
|
|
1568
|
+
for (let i = 0; i < prevNumContainers; i++) {
|
|
1569
|
+
const key = peek$(ctx, `containerItemKey${i}`);
|
|
1570
|
+
if (key !== void 0) {
|
|
1571
|
+
const index = indexByKey.get(key);
|
|
1572
|
+
maxIndexRendered = Math.max(maxIndexRendered, index);
|
|
1635
1573
|
}
|
|
1636
1574
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
const id = (_g = idCache.get(i)) != null ? _g : getId(state, i);
|
|
1650
|
-
const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
1651
|
-
if (oldKey && oldKey !== id) {
|
|
1652
|
-
containerItemKeys.delete(oldKey);
|
|
1575
|
+
let firstFullyOnScreenIndex;
|
|
1576
|
+
const dataLength = data.length;
|
|
1577
|
+
for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
|
|
1578
|
+
const id = (_c = idCache.get(i)) != null ? _c : getId(state, i);
|
|
1579
|
+
const size = (_d = sizes.get(id)) != null ? _d : getItemSize(state, id, i, data[i]);
|
|
1580
|
+
const top = positions.get(id);
|
|
1581
|
+
if (!foundEnd) {
|
|
1582
|
+
if (startNoBuffer === null && top + size > scroll) {
|
|
1583
|
+
startNoBuffer = i;
|
|
1584
|
+
}
|
|
1585
|
+
if (firstFullyOnScreenIndex === void 0 && top >= scroll - 10) {
|
|
1586
|
+
firstFullyOnScreenIndex = i;
|
|
1653
1587
|
}
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1588
|
+
if (startBuffered === null && top + size > scrollTopBuffered) {
|
|
1589
|
+
startBuffered = i;
|
|
1590
|
+
startBufferedId = id;
|
|
1591
|
+
nextTop = top;
|
|
1592
|
+
}
|
|
1593
|
+
if (startNoBuffer !== null) {
|
|
1594
|
+
if (top <= scrollBottom) {
|
|
1595
|
+
endNoBuffer = i;
|
|
1596
|
+
}
|
|
1597
|
+
if (top <= scrollBottomBuffered) {
|
|
1598
|
+
endBuffered = i;
|
|
1599
|
+
nextBottom = top + size;
|
|
1600
|
+
} else {
|
|
1601
|
+
foundEnd = true;
|
|
1602
|
+
}
|
|
1659
1603
|
}
|
|
1660
1604
|
}
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1605
|
+
}
|
|
1606
|
+
const idsInView = [];
|
|
1607
|
+
for (let i = firstFullyOnScreenIndex; i <= endNoBuffer; i++) {
|
|
1608
|
+
const id = (_e = idCache.get(i)) != null ? _e : getId(state, i);
|
|
1609
|
+
idsInView.push(id);
|
|
1610
|
+
}
|
|
1611
|
+
Object.assign(state, {
|
|
1612
|
+
endBuffered,
|
|
1613
|
+
endNoBuffer,
|
|
1614
|
+
firstFullyOnScreenIndex,
|
|
1615
|
+
idsInView,
|
|
1616
|
+
startBuffered,
|
|
1617
|
+
startBufferedId,
|
|
1618
|
+
startNoBuffer
|
|
1619
|
+
});
|
|
1620
|
+
if (enableScrollForNextCalculateItemsInView && nextTop !== void 0 && nextBottom !== void 0) {
|
|
1621
|
+
state.scrollForNextCalculateItemsInView = nextTop !== void 0 && nextBottom !== void 0 ? {
|
|
1622
|
+
bottom: nextBottom,
|
|
1623
|
+
top: nextTop
|
|
1624
|
+
} : void 0;
|
|
1625
|
+
}
|
|
1626
|
+
const numContainers = peek$(ctx, "numContainers");
|
|
1627
|
+
const pendingRemoval = [];
|
|
1628
|
+
if (dataChanged) {
|
|
1629
|
+
for (let i = 0; i < numContainers; i++) {
|
|
1630
|
+
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1631
|
+
if (!state.props.keyExtractor || itemKey && indexByKey.get(itemKey) === void 0) {
|
|
1632
|
+
pendingRemoval.push(i);
|
|
1665
1633
|
}
|
|
1666
1634
|
}
|
|
1667
1635
|
}
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
containerItemKeys.
|
|
1636
|
+
if (startBuffered !== null && endBuffered !== null) {
|
|
1637
|
+
let numContainers2 = prevNumContainers;
|
|
1638
|
+
const needNewContainers = [];
|
|
1639
|
+
for (let i = startBuffered; i <= endBuffered; i++) {
|
|
1640
|
+
const id = (_f = idCache.get(i)) != null ? _f : getId(state, i);
|
|
1641
|
+
if (!containerItemKeys.has(id)) {
|
|
1642
|
+
needNewContainers.push(i);
|
|
1643
|
+
}
|
|
1674
1644
|
}
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
const
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
const prevColumn = peek$(ctx, `containerColumn${i}`);
|
|
1692
|
-
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
1693
|
-
if (!prevPos || pos > POSITION_OUT_OF_VIEW && pos !== prevPos) {
|
|
1694
|
-
set$(ctx, `containerPosition${i}`, pos);
|
|
1645
|
+
if (needNewContainers.length > 0) {
|
|
1646
|
+
const availableContainers = findAvailableContainers(
|
|
1647
|
+
ctx,
|
|
1648
|
+
state,
|
|
1649
|
+
needNewContainers.length,
|
|
1650
|
+
startBuffered,
|
|
1651
|
+
endBuffered,
|
|
1652
|
+
pendingRemoval
|
|
1653
|
+
);
|
|
1654
|
+
for (let idx = 0; idx < needNewContainers.length; idx++) {
|
|
1655
|
+
const i = needNewContainers[idx];
|
|
1656
|
+
const containerIndex = availableContainers[idx];
|
|
1657
|
+
const id = (_g = idCache.get(i)) != null ? _g : getId(state, i);
|
|
1658
|
+
const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
1659
|
+
if (oldKey && oldKey !== id) {
|
|
1660
|
+
containerItemKeys.delete(oldKey);
|
|
1695
1661
|
}
|
|
1696
|
-
|
|
1697
|
-
|
|
1662
|
+
set$(ctx, `containerItemKey${containerIndex}`, id);
|
|
1663
|
+
set$(ctx, `containerItemData${containerIndex}`, data[i]);
|
|
1664
|
+
containerItemKeys.add(id);
|
|
1665
|
+
if (containerIndex >= numContainers2) {
|
|
1666
|
+
numContainers2 = containerIndex + 1;
|
|
1698
1667
|
}
|
|
1699
|
-
|
|
1700
|
-
|
|
1668
|
+
}
|
|
1669
|
+
if (numContainers2 !== prevNumContainers) {
|
|
1670
|
+
set$(ctx, "numContainers", numContainers2);
|
|
1671
|
+
if (numContainers2 > peek$(ctx, "numContainersPooled")) {
|
|
1672
|
+
set$(ctx, "numContainersPooled", Math.ceil(numContainers2 * 1.5));
|
|
1701
1673
|
}
|
|
1702
1674
|
}
|
|
1703
1675
|
}
|
|
1704
1676
|
}
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1677
|
+
for (let i = 0; i < numContainers; i++) {
|
|
1678
|
+
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1679
|
+
if (pendingRemoval.includes(i)) {
|
|
1680
|
+
if (itemKey) {
|
|
1681
|
+
containerItemKeys.delete(itemKey);
|
|
1682
|
+
}
|
|
1683
|
+
set$(ctx, `containerItemKey${i}`, void 0);
|
|
1684
|
+
set$(ctx, `containerItemData${i}`, void 0);
|
|
1685
|
+
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
1686
|
+
set$(ctx, `containerColumn${i}`, -1);
|
|
1687
|
+
} else {
|
|
1688
|
+
const itemIndex = indexByKey.get(itemKey);
|
|
1689
|
+
const item = data[itemIndex];
|
|
1690
|
+
if (item !== void 0) {
|
|
1691
|
+
const id = (_h = idCache.get(itemIndex)) != null ? _h : getId(state, itemIndex);
|
|
1692
|
+
const position = positions.get(id);
|
|
1693
|
+
if (position === void 0) {
|
|
1694
|
+
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
1695
|
+
} else {
|
|
1696
|
+
const column = columns.get(id) || 1;
|
|
1697
|
+
const prevPos = peek$(ctx, `containerPosition${i}`);
|
|
1698
|
+
const prevColumn = peek$(ctx, `containerColumn${i}`);
|
|
1699
|
+
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
1700
|
+
if (position > POSITION_OUT_OF_VIEW && position !== prevPos) {
|
|
1701
|
+
set$(ctx, `containerPosition${i}`, position);
|
|
1702
|
+
}
|
|
1703
|
+
if (column >= 0 && column !== prevColumn) {
|
|
1704
|
+
set$(ctx, `containerColumn${i}`, column);
|
|
1705
|
+
}
|
|
1706
|
+
if (prevData !== item) {
|
|
1707
|
+
set$(ctx, `containerItemData${i}`, data[itemIndex]);
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1709
1712
|
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1713
|
+
if (!queuedInitialLayout && endBuffered !== null) {
|
|
1714
|
+
if (checkAllSizesKnown(state)) {
|
|
1715
|
+
setDidLayout(ctx, state);
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
if (state.props.viewabilityConfigCallbackPairs) {
|
|
1719
|
+
updateViewableItems(
|
|
1720
|
+
state,
|
|
1721
|
+
ctx,
|
|
1722
|
+
state.props.viewabilityConfigCallbackPairs,
|
|
1723
|
+
scrollLength,
|
|
1724
|
+
startNoBuffer,
|
|
1725
|
+
endNoBuffer
|
|
1726
|
+
);
|
|
1727
|
+
}
|
|
1728
|
+
});
|
|
1721
1729
|
}
|
|
1722
1730
|
|
|
1723
1731
|
// src/core/doInitialAllocateContainers.ts
|
|
@@ -1991,32 +1999,20 @@ function updateItemSizes(ctx, state, itemUpdates) {
|
|
|
1991
1999
|
}
|
|
1992
2000
|
}
|
|
1993
2001
|
function updateItemSize(ctx, state, itemKey, sizeObj) {
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
let measured;
|
|
2006
|
-
containerRef.current.measure((x, y, width, height) => {
|
|
2007
|
-
measured = { height, width, x, y };
|
|
2008
|
-
});
|
|
2009
|
-
if (measured) {
|
|
2010
|
-
changes.push({ itemKey: containerItemKey, sizeObj: measured });
|
|
2011
|
-
}
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
}
|
|
2015
|
-
if (changes.length > 0) {
|
|
2016
|
-
updateItemSizes(ctx, state, changes);
|
|
2002
|
+
const { queuedItemSizeUpdates, queuedItemSizeUpdatesWaiting } = state;
|
|
2003
|
+
const containersDidLayout = peek$(ctx, "containersDidLayout");
|
|
2004
|
+
if (!containersDidLayout || !queuedItemSizeUpdatesWaiting) {
|
|
2005
|
+
updateItemSizes(ctx, state, [{ itemKey, sizeObj }]);
|
|
2006
|
+
if (containersDidLayout) {
|
|
2007
|
+
state.queuedItemSizeUpdatesWaiting = true;
|
|
2008
|
+
requestAnimationFrame(() => {
|
|
2009
|
+
state.queuedItemSizeUpdatesWaiting = false;
|
|
2010
|
+
updateItemSizes(ctx, state, queuedItemSizeUpdates);
|
|
2011
|
+
queuedItemSizeUpdates.length = 0;
|
|
2012
|
+
});
|
|
2017
2013
|
}
|
|
2018
2014
|
} else {
|
|
2019
|
-
|
|
2015
|
+
queuedItemSizeUpdates.push({ itemKey, sizeObj });
|
|
2020
2016
|
}
|
|
2021
2017
|
}
|
|
2022
2018
|
function updateOneItemSize(state, itemKey, sizeObj) {
|
|
@@ -2197,6 +2193,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2197
2193
|
positions: /* @__PURE__ */ new Map(),
|
|
2198
2194
|
props: {},
|
|
2199
2195
|
queuedCalculateItemsInView: 0,
|
|
2196
|
+
queuedItemSizeUpdates: [],
|
|
2200
2197
|
refScroller: void 0,
|
|
2201
2198
|
scroll: 0,
|
|
2202
2199
|
scrollAdjustHandler: new ScrollAdjustHandler(ctx),
|
|
@@ -2277,20 +2274,19 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2277
2274
|
(_, i) => getId(state, dataProp.length - 1 - i)
|
|
2278
2275
|
);
|
|
2279
2276
|
}, [dataProp, numColumnsProp]);
|
|
2280
|
-
const
|
|
2277
|
+
const initializeStateVars = () => {
|
|
2281
2278
|
set$(ctx, "lastItemKeys", memoizedLastItemKeys);
|
|
2282
2279
|
set$(ctx, "numColumns", numColumnsProp);
|
|
2283
2280
|
const prevPaddingTop = peek$(ctx, "stylePaddingTop");
|
|
2284
2281
|
setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
|
|
2285
2282
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
2286
2283
|
const paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
2287
|
-
if (paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
2288
|
-
calculateItemsInView(ctx, state, { doMVCP: true });
|
|
2284
|
+
if (maintainVisibleContentPosition && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
2289
2285
|
requestAdjust(ctx, state, paddingDiff);
|
|
2290
2286
|
}
|
|
2291
2287
|
};
|
|
2292
2288
|
if (isFirst) {
|
|
2293
|
-
|
|
2289
|
+
initializeStateVars();
|
|
2294
2290
|
updateAllPositions(ctx, state);
|
|
2295
2291
|
}
|
|
2296
2292
|
const initialContentOffset = useMemo(() => {
|
|
@@ -2361,7 +2357,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2361
2357
|
useLayoutEffect(() => {
|
|
2362
2358
|
set$(ctx, "extraData", extraData);
|
|
2363
2359
|
}, [extraData]);
|
|
2364
|
-
useLayoutEffect(
|
|
2360
|
+
useLayoutEffect(initializeStateVars, [
|
|
2365
2361
|
memoizedLastItemKeys.join(","),
|
|
2366
2362
|
numColumnsProp,
|
|
2367
2363
|
stylePaddingTopState,
|