@legendapp/list 3.0.0-beta.33 → 3.0.0-beta.35

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.
@@ -632,6 +632,7 @@ var Container = typedMemo2(function Container2({
632
632
  }) {
633
633
  const ctx = useStateContext();
634
634
  const { columnWrapperStyle, animatedScrollY } = ctx;
635
+ const positionComponentInternal = ctx.state.props.positionComponentInternal;
635
636
  const stickyPositionComponentInternal = ctx.state.props.stickyPositionComponentInternal;
636
637
  const [column = 0, span = 1, data, itemKey, numColumns = 1, extraData, isSticky] = useArr$([
637
638
  `containerColumn${id}`,
@@ -785,7 +786,7 @@ var Container = typedMemo2(function Container2({
785
786
  }
786
787
  }, [itemKey]);
787
788
  }
788
- const PositionComponent = isSticky ? stickyPositionComponentInternal ? stickyPositionComponentInternal : PositionViewSticky : PositionView;
789
+ const PositionComponent = isSticky ? stickyPositionComponentInternal ? stickyPositionComponentInternal : PositionViewSticky : positionComponentInternal ? positionComponentInternal : PositionView;
789
790
  return /* @__PURE__ */ React2.createElement(
790
791
  PositionComponent,
791
792
  {
@@ -922,6 +923,7 @@ var ListComponent = typedMemo2(function ListComponent2({
922
923
  snapToIndices,
923
924
  stickyHeaderConfig,
924
925
  stickyHeaderIndices,
926
+ useWindowScroll = false,
925
927
  ...rest
926
928
  }) {
927
929
  const ctx = useStateContext();
@@ -945,6 +947,7 @@ var ListComponent = typedMemo2(function ListComponent2({
945
947
  SnapOrScroll,
946
948
  {
947
949
  ...rest,
950
+ ...ScrollComponent === ListComponentScrollView ? { useWindowScroll } : {},
948
951
  contentContainerStyle: [
949
952
  contentContainerStyle,
950
953
  horizontal ? {
@@ -990,24 +993,12 @@ var ListComponent = typedMemo2(function ListComponent2({
990
993
  );
991
994
  });
992
995
 
993
- // src/utils/getId.ts
994
- function getId(state, index) {
995
- const { data, keyExtractor } = state.props;
996
- if (!data) {
997
- return "";
998
- }
999
- const ret = index < data.length ? keyExtractor ? keyExtractor(data[index], index) : index : null;
1000
- const id = ret;
1001
- state.idCache[index] = id;
1002
- return id;
1003
- }
1004
-
1005
996
  // src/core/calculateOffsetForIndex.ts
1006
997
  function calculateOffsetForIndex(ctx, index) {
1007
998
  const state = ctx.state;
1008
999
  let position = 0;
1009
1000
  if (index !== void 0) {
1010
- position = state.positions.get(getId(state, index)) || 0;
1001
+ position = state.positions[index] || 0;
1011
1002
  const paddingTop = peek$(ctx, "stylePaddingTop");
1012
1003
  if (paddingTop) {
1013
1004
  position += paddingTop;
@@ -1020,6 +1011,18 @@ function calculateOffsetForIndex(ctx, index) {
1020
1011
  return position;
1021
1012
  }
1022
1013
 
1014
+ // src/utils/getId.ts
1015
+ function getId(state, index) {
1016
+ const { data, keyExtractor } = state.props;
1017
+ if (!data) {
1018
+ return "";
1019
+ }
1020
+ const ret = index < data.length ? keyExtractor ? keyExtractor(data[index], index) : index : null;
1021
+ const id = ret;
1022
+ state.idCache[index] = id;
1023
+ return id;
1024
+ }
1025
+
1023
1026
  // src/core/addTotalSize.ts
1024
1027
  function addTotalSize(ctx, key, add) {
1025
1028
  const state = ctx.state;
@@ -1073,13 +1076,13 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
1073
1076
  return sizeKnown;
1074
1077
  }
1075
1078
  let size;
1076
- const itemType = getItemType ? (_a3 = getItemType(data, index)) != null ? _a3 : "" : "";
1077
1079
  if (preferCachedSize) {
1078
1080
  const cachedSize = sizes.get(key);
1079
1081
  if (cachedSize !== void 0) {
1080
1082
  return cachedSize;
1081
1083
  }
1082
1084
  }
1085
+ const itemType = getItemType ? (_a3 = getItemType(data, index)) != null ? _a3 : "" : "";
1083
1086
  if (getFixedItemSize) {
1084
1087
  size = getFixedItemSize(data, index, itemType);
1085
1088
  if (size !== void 0) {
@@ -1223,37 +1226,54 @@ function checkAtBottom(ctx) {
1223
1226
 
1224
1227
  // src/utils/checkAtTop.ts
1225
1228
  function checkAtTop(ctx) {
1226
- var _a3;
1227
1229
  const state = ctx == null ? void 0 : ctx.state;
1228
1230
  if (!state || state.initialScroll || state.scrollingTo) {
1229
1231
  return;
1230
1232
  }
1231
1233
  const {
1232
- scrollLength,
1234
+ dataChangeEpoch,
1235
+ isStartReached,
1236
+ props: { data, onStartReachedThreshold },
1233
1237
  scroll,
1234
- props: { onStartReachedThreshold }
1238
+ scrollLength,
1239
+ startReachedSnapshot,
1240
+ startReachedSnapshotDataChangeEpoch,
1241
+ totalSize
1235
1242
  } = state;
1236
- const distanceFromTop = scroll;
1237
- state.isAtStart = distanceFromTop <= 0;
1243
+ const dataLength = data.length;
1244
+ const threshold = onStartReachedThreshold * scrollLength;
1245
+ const dataChanged = startReachedSnapshotDataChangeEpoch !== dataChangeEpoch;
1246
+ const withinThreshold = threshold > 0 && Math.abs(scroll) <= threshold;
1247
+ const allowReentryOnDataChange = !!isStartReached && withinThreshold && !!dataChanged && !isInMVCPActiveMode(state);
1248
+ if (isStartReached && threshold > 0 && scroll > threshold && startReachedSnapshot && (dataChanged || startReachedSnapshot.contentSize !== totalSize || startReachedSnapshot.dataLength !== dataLength)) {
1249
+ state.isStartReached = false;
1250
+ state.startReachedSnapshot = void 0;
1251
+ state.startReachedSnapshotDataChangeEpoch = void 0;
1252
+ }
1253
+ state.isAtStart = scroll <= 0;
1254
+ if (isStartReached && withinThreshold && dataChanged && !allowReentryOnDataChange) {
1255
+ return;
1256
+ }
1238
1257
  state.isStartReached = checkThreshold(
1239
- distanceFromTop,
1258
+ scroll,
1240
1259
  false,
1241
- onStartReachedThreshold * scrollLength,
1260
+ threshold,
1242
1261
  state.isStartReached,
1243
- state.startReachedSnapshot,
1262
+ allowReentryOnDataChange ? void 0 : startReachedSnapshot,
1244
1263
  {
1245
- contentSize: state.totalSize,
1246
- dataLength: (_a3 = state.props.data) == null ? void 0 : _a3.length,
1264
+ contentSize: totalSize,
1265
+ dataLength,
1247
1266
  scrollPosition: scroll
1248
1267
  },
1249
1268
  (distance) => {
1250
- var _a4, _b;
1251
- return (_b = (_a4 = state.props).onStartReached) == null ? void 0 : _b.call(_a4, { distanceFromStart: distance });
1269
+ var _a3, _b;
1270
+ return (_b = (_a3 = state.props).onStartReached) == null ? void 0 : _b.call(_a3, { distanceFromStart: distance });
1252
1271
  },
1253
1272
  (snapshot) => {
1254
1273
  state.startReachedSnapshot = snapshot;
1274
+ state.startReachedSnapshotDataChangeEpoch = snapshot ? dataChangeEpoch : void 0;
1255
1275
  },
1256
- false
1276
+ allowReentryOnDataChange
1257
1277
  );
1258
1278
  }
1259
1279
 
@@ -1293,6 +1313,8 @@ function finishScrollTo(ctx) {
1293
1313
  var _a3, _b;
1294
1314
  const state = ctx.state;
1295
1315
  if (state == null ? void 0 : state.scrollingTo) {
1316
+ const resolvePendingScroll = state.pendingScrollResolve;
1317
+ state.pendingScrollResolve = void 0;
1296
1318
  const scrollingTo = state.scrollingTo;
1297
1319
  state.scrollHistory.length = 0;
1298
1320
  state.initialScroll = void 0;
@@ -1309,6 +1331,7 @@ function finishScrollTo(ctx) {
1309
1331
  }
1310
1332
  setInitialRenderState(ctx, { didInitialScroll: true });
1311
1333
  checkThresholds(ctx);
1334
+ resolvePendingScroll == null ? void 0 : resolvePendingScroll();
1312
1335
  }
1313
1336
  }
1314
1337
 
@@ -1365,16 +1388,20 @@ function checkFinishedScrollFallback(ctx) {
1365
1388
 
1366
1389
  // src/core/doScrollTo.native.ts
1367
1390
  function doScrollTo(ctx, params) {
1368
- var _a3;
1369
1391
  const state = ctx.state;
1370
1392
  const { animated, horizontal, offset } = params;
1393
+ const isAnimated = !!animated;
1371
1394
  const { refScroller } = state;
1372
- (_a3 = refScroller.current) == null ? void 0 : _a3.scrollTo({
1373
- animated: !!animated,
1395
+ const scroller = refScroller.current;
1396
+ if (!scroller) {
1397
+ return;
1398
+ }
1399
+ scroller.scrollTo({
1400
+ animated: isAnimated,
1374
1401
  x: horizontal ? offset : 0,
1375
1402
  y: horizontal ? 0 : offset
1376
1403
  });
1377
- if (!animated) {
1404
+ if (!isAnimated) {
1378
1405
  state.scroll = offset;
1379
1406
  checkFinishedScrollFallback(ctx);
1380
1407
  }
@@ -1416,7 +1443,7 @@ var flushSync = (fn) => {
1416
1443
  // src/core/updateScroll.ts
1417
1444
  function updateScroll(ctx, newScroll, forceUpdate) {
1418
1445
  const state = ctx.state;
1419
- const { scrollingTo, scrollAdjustHandler, lastScrollAdjustForHistory } = state;
1446
+ const { ignoreScrollFromMVCP, lastScrollAdjustForHistory, scrollAdjustHandler, scrollHistory, scrollingTo } = state;
1420
1447
  const prevScroll = state.scroll;
1421
1448
  state.hasScrolled = true;
1422
1449
  state.lastBatchingAction = Date.now();
@@ -1424,22 +1451,17 @@ function updateScroll(ctx, newScroll, forceUpdate) {
1424
1451
  const adjust = scrollAdjustHandler.getAdjust();
1425
1452
  const adjustChanged = lastScrollAdjustForHistory !== void 0 && Math.abs(adjust - lastScrollAdjustForHistory) > 0.1;
1426
1453
  if (adjustChanged) {
1427
- state.scrollHistory.length = 0;
1454
+ scrollHistory.length = 0;
1428
1455
  }
1429
1456
  state.lastScrollAdjustForHistory = adjust;
1430
- if (scrollingTo === void 0 && !(state.scrollHistory.length === 0 && newScroll === state.scroll)) {
1457
+ if (scrollingTo === void 0 && !(scrollHistory.length === 0 && newScroll === state.scroll)) {
1431
1458
  if (!adjustChanged) {
1432
- state.scrollHistory.push({ scroll: newScroll, time: currentTime });
1459
+ scrollHistory.push({ scroll: newScroll, time: currentTime });
1433
1460
  }
1434
1461
  }
1435
- if (state.scrollHistory.length > 5) {
1436
- state.scrollHistory.shift();
1462
+ if (scrollHistory.length > 5) {
1463
+ scrollHistory.shift();
1437
1464
  }
1438
- state.scrollPrev = prevScroll;
1439
- state.scrollPrevTime = state.scrollTime;
1440
- state.scroll = newScroll;
1441
- state.scrollTime = currentTime;
1442
- const ignoreScrollFromMVCP = state.ignoreScrollFromMVCP;
1443
1465
  if (ignoreScrollFromMVCP && !scrollingTo) {
1444
1466
  const { lt, gt } = ignoreScrollFromMVCP;
1445
1467
  if (lt && newScroll < lt || gt && newScroll > gt) {
@@ -1447,6 +1469,10 @@ function updateScroll(ctx, newScroll, forceUpdate) {
1447
1469
  return;
1448
1470
  }
1449
1471
  }
1472
+ state.scrollPrev = prevScroll;
1473
+ state.scrollPrevTime = state.scrollTime;
1474
+ state.scroll = newScroll;
1475
+ state.scrollTime = currentTime;
1450
1476
  const scrollDelta = Math.abs(newScroll - prevScroll);
1451
1477
  const scrollLength = state.scrollLength;
1452
1478
  const lastCalculated = state.scrollLastCalculate;
@@ -1532,14 +1558,14 @@ var INITIAL_ANCHOR_SETTLED_TICKS = 2;
1532
1558
  function ensureInitialAnchor(ctx) {
1533
1559
  var _a3, _b, _c, _d, _e;
1534
1560
  const state = ctx.state;
1535
- const { initialAnchor, didContainersLayout, positions, scroll, scrollLength } = state;
1561
+ const { initialAnchor, didContainersLayout, scroll, scrollLength } = state;
1536
1562
  const anchor = initialAnchor;
1537
1563
  const item = state.props.data[anchor.index];
1538
1564
  if (!didContainersLayout) {
1539
1565
  return;
1540
1566
  }
1541
1567
  const id = getId(state, anchor.index);
1542
- if (positions.get(id) === void 0) {
1568
+ if (state.positions[anchor.index] === void 0) {
1543
1569
  return;
1544
1570
  }
1545
1571
  const size = getItemSize(ctx, id, anchor.index, item, true, true);
@@ -1655,12 +1681,18 @@ function prepareMVCP(ctx, dataChanged) {
1655
1681
  const id = idsInView[i];
1656
1682
  const index = indexByKey.get(id);
1657
1683
  if (index !== void 0) {
1658
- idsInViewWithPositions.push({ id, position: positions.get(id) });
1684
+ const position = positions[index];
1685
+ if (position !== void 0) {
1686
+ idsInViewWithPositions.push({ id, position });
1687
+ }
1659
1688
  }
1660
1689
  }
1661
1690
  }
1662
1691
  if (targetId !== void 0 && prevPosition === void 0) {
1663
- prevPosition = positions.get(targetId);
1692
+ const targetIndex = indexByKey.get(targetId);
1693
+ if (targetIndex !== void 0) {
1694
+ prevPosition = positions[targetIndex];
1695
+ }
1664
1696
  }
1665
1697
  return () => {
1666
1698
  let positionDiff = 0;
@@ -1679,7 +1711,13 @@ function prepareMVCP(ctx, dataChanged) {
1679
1711
  }
1680
1712
  }
1681
1713
  }
1682
- const shouldUseFallbackVisibleAnchor = dataChanged && mvcpData && scrollTarget === void 0 && (targetId === void 0 || positions.get(targetId) === void 0 || skipTargetAnchor);
1714
+ const shouldUseFallbackVisibleAnchor = dataChanged && mvcpData && scrollTarget === void 0 && (() => {
1715
+ if (targetId === void 0 || skipTargetAnchor) {
1716
+ return true;
1717
+ }
1718
+ const targetIndex = indexByKey.get(targetId);
1719
+ return targetIndex === void 0 || positions[targetIndex] === void 0;
1720
+ })();
1683
1721
  if (shouldUseFallbackVisibleAnchor) {
1684
1722
  for (let i = 0; i < idsInViewWithPositions.length; i++) {
1685
1723
  const { id, position } = idsInViewWithPositions[i];
@@ -1690,7 +1728,7 @@ function prepareMVCP(ctx, dataChanged) {
1690
1728
  continue;
1691
1729
  }
1692
1730
  }
1693
- const newPosition = positions.get(id);
1731
+ const newPosition = index !== void 0 ? positions[index] : void 0;
1694
1732
  if (newPosition !== void 0) {
1695
1733
  positionDiff = newPosition - position;
1696
1734
  anchorIdForLock = id;
@@ -1700,7 +1738,8 @@ function prepareMVCP(ctx, dataChanged) {
1700
1738
  }
1701
1739
  }
1702
1740
  if (!skipTargetAnchor && targetId !== void 0 && prevPosition !== void 0) {
1703
- const newPosition = positions.get(targetId);
1741
+ const targetIndex = indexByKey.get(targetId);
1742
+ const newPosition = targetIndex !== void 0 ? positions[targetIndex] : void 0;
1704
1743
  if (newPosition !== void 0) {
1705
1744
  const totalSize = getContentSize(ctx);
1706
1745
  let diff = newPosition - prevPosition;
@@ -1747,17 +1786,15 @@ function prepareColumnStartState(ctx, startIndex, useAverageSize) {
1747
1786
  const state = ctx.state;
1748
1787
  const numColumns = peek$(ctx, "numColumns");
1749
1788
  let rowStartIndex = startIndex;
1750
- const columnAtStart = state.columns.get(state.idCache[startIndex]);
1789
+ const columnAtStart = state.columns[startIndex];
1751
1790
  if (columnAtStart !== 1) {
1752
1791
  rowStartIndex = findRowStartIndex(state, numColumns, startIndex);
1753
1792
  }
1754
1793
  let currentRowTop = 0;
1755
- const curId = state.idCache[rowStartIndex];
1756
- const column = state.columns.get(curId);
1794
+ const column = state.columns[rowStartIndex];
1757
1795
  if (rowStartIndex > 0) {
1758
1796
  const prevIndex = rowStartIndex - 1;
1759
- const prevId = state.idCache[prevIndex];
1760
- const prevPosition = (_a3 = state.positions.get(prevId)) != null ? _a3 : 0;
1797
+ const prevPosition = (_a3 = state.positions[prevIndex]) != null ? _a3 : 0;
1761
1798
  const prevRowStart = findRowStartIndex(state, numColumns, prevIndex);
1762
1799
  const prevRowHeight = calculateRowMaxSize(ctx, prevRowStart, prevIndex, useAverageSize);
1763
1800
  currentRowTop = prevPosition + prevRowHeight;
@@ -1774,7 +1811,7 @@ function findRowStartIndex(state, numColumns, index) {
1774
1811
  }
1775
1812
  let rowStart = Math.max(0, index);
1776
1813
  while (rowStart > 0) {
1777
- const columnForIndex = state.columns.get(state.idCache[rowStart]);
1814
+ const columnForIndex = state.columns[rowStart];
1778
1815
  if (columnForIndex === 1) {
1779
1816
  break;
1780
1817
  }
@@ -1807,7 +1844,7 @@ function calculateRowMaxSize(ctx, startIndex, endIndex, useAverageSize) {
1807
1844
 
1808
1845
  // src/core/updateTotalSize.ts
1809
1846
  function updateTotalSize(ctx) {
1810
- var _a3, _b, _c;
1847
+ var _a3, _b;
1811
1848
  const state = ctx.state;
1812
1849
  const {
1813
1850
  positions,
@@ -1817,36 +1854,34 @@ function updateTotalSize(ctx) {
1817
1854
  if (data.length === 0) {
1818
1855
  addTotalSize(ctx, null, 0);
1819
1856
  } else {
1820
- const lastId = getId(state, data.length - 1);
1821
- if (lastId !== void 0) {
1822
- const lastPosition = positions.get(lastId);
1823
- if (lastPosition !== void 0) {
1824
- if (numColumns > 1) {
1825
- let rowStart = data.length - 1;
1826
- while (rowStart > 0) {
1827
- const rowId = (_b = state.idCache[rowStart]) != null ? _b : getId(state, rowStart);
1828
- const column = state.columns.get(rowId);
1829
- if (column === 1 || column === void 0) {
1830
- break;
1831
- }
1832
- rowStart -= 1;
1833
- }
1834
- let maxSize = 0;
1835
- for (let i = rowStart; i < data.length; i++) {
1836
- const rowId = (_c = state.idCache[i]) != null ? _c : getId(state, i);
1837
- const size = getItemSize(ctx, rowId, i, data[i]);
1838
- if (size > maxSize) {
1839
- maxSize = size;
1840
- }
1857
+ const lastIndex = data.length - 1;
1858
+ const lastId = getId(state, lastIndex);
1859
+ const lastPosition = positions[lastIndex];
1860
+ if (lastId !== void 0 && lastPosition !== void 0) {
1861
+ if (numColumns > 1) {
1862
+ let rowStart = lastIndex;
1863
+ while (rowStart > 0) {
1864
+ const column = state.columns[rowStart];
1865
+ if (column === 1 || column === void 0) {
1866
+ break;
1841
1867
  }
1842
- addTotalSize(ctx, null, lastPosition + maxSize);
1843
- } else {
1844
- const lastSize = getItemSize(ctx, lastId, data.length - 1, data[data.length - 1]);
1845
- if (lastSize !== void 0) {
1846
- const totalSize = lastPosition + lastSize;
1847
- addTotalSize(ctx, null, totalSize);
1868
+ rowStart -= 1;
1869
+ }
1870
+ let maxSize = 0;
1871
+ for (let i = rowStart; i <= lastIndex; i++) {
1872
+ const rowId = (_b = state.idCache[i]) != null ? _b : getId(state, i);
1873
+ const size = getItemSize(ctx, rowId, i, data[i]);
1874
+ if (size > maxSize) {
1875
+ maxSize = size;
1848
1876
  }
1849
1877
  }
1878
+ addTotalSize(ctx, null, lastPosition + maxSize);
1879
+ } else {
1880
+ const lastSize = getItemSize(ctx, lastId, lastIndex, data[lastIndex]);
1881
+ if (lastSize !== void 0) {
1882
+ const totalSize = lastPosition + lastSize;
1883
+ addTotalSize(ctx, null, totalSize);
1884
+ }
1850
1885
  }
1851
1886
  }
1852
1887
  }
@@ -1895,14 +1930,13 @@ var getScrollVelocity = (state) => {
1895
1930
  function updateSnapToOffsets(ctx) {
1896
1931
  const state = ctx.state;
1897
1932
  const {
1898
- positions,
1899
1933
  props: { snapToIndices }
1900
1934
  } = state;
1901
1935
  const snapToOffsets = Array(snapToIndices.length);
1902
1936
  for (let i = 0; i < snapToIndices.length; i++) {
1903
1937
  const idx = snapToIndices[i];
1904
- const key = getId(state, idx);
1905
- snapToOffsets[i] = positions.get(key);
1938
+ getId(state, idx);
1939
+ snapToOffsets[i] = state.positions[idx];
1906
1940
  }
1907
1941
  set$(ctx, "snapToOffsets", snapToOffsets);
1908
1942
  }
@@ -1914,8 +1948,9 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
1914
1948
  scrollBottomBuffered: -1,
1915
1949
  startIndex: 0
1916
1950
  }) {
1917
- var _a3, _b, _c, _d, _e, _f;
1951
+ var _a3, _b, _c, _d, _e;
1918
1952
  const state = ctx.state;
1953
+ const hasPositionListeners = ctx.positionListeners.size > 0;
1919
1954
  const {
1920
1955
  columns,
1921
1956
  columnSpans,
@@ -1942,7 +1977,15 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
1942
1977
  let column = 1;
1943
1978
  let maxSizeInRow = 0;
1944
1979
  if (dataChanged) {
1945
- columnSpans.clear();
1980
+ columnSpans.length = 0;
1981
+ }
1982
+ if (!hasColumns) {
1983
+ if (columns.length) {
1984
+ columns.length = 0;
1985
+ }
1986
+ if (columnSpans.length) {
1987
+ columnSpans.length = 0;
1988
+ }
1946
1989
  }
1947
1990
  if (startIndex > 0) {
1948
1991
  if (hasColumns) {
@@ -1956,12 +1999,13 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
1956
1999
  } else if (startIndex < dataLength) {
1957
2000
  const prevIndex = startIndex - 1;
1958
2001
  const prevId = getId(state, prevIndex);
1959
- const prevPosition = (_c = positions.get(prevId)) != null ? _c : 0;
2002
+ const prevPosition = (_c = positions[prevIndex]) != null ? _c : 0;
1960
2003
  const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(ctx, prevId, prevIndex, data[prevIndex], useAverageSize, preferCachedSize);
1961
2004
  currentRowTop = prevPosition + prevSize;
1962
2005
  }
1963
2006
  }
1964
2007
  const needsIndexByKey = dataChanged || indexByKey.size === 0;
2008
+ const canOverrideSpan = hasColumns && !!overrideItemLayout && !!layoutConfig;
1965
2009
  let didBreakEarly = false;
1966
2010
  let breakAt;
1967
2011
  for (let i = startIndex; i < dataLength; i++) {
@@ -1975,7 +2019,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
1975
2019
  }
1976
2020
  const id = (_e = idCache[i]) != null ? _e : getId(state, i);
1977
2021
  let span = 1;
1978
- if (hasColumns && overrideItemLayout && layoutConfig) {
2022
+ if (canOverrideSpan) {
1979
2023
  layoutConfig.span = 1;
1980
2024
  overrideItemLayout(layoutConfig, data[i], i, numColumns, extraData);
1981
2025
  const requestedSpan = layoutConfig.span;
@@ -1988,7 +2032,8 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
1988
2032
  column = 1;
1989
2033
  maxSizeInRow = 0;
1990
2034
  }
1991
- const size = (_f = sizesKnown.get(id)) != null ? _f : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize);
2035
+ const knownSize = sizesKnown.get(id);
2036
+ const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize);
1992
2037
  if (IS_DEV && needsIndexByKey) {
1993
2038
  if (indexByKeyForChecking.has(id)) {
1994
2039
  console.error(
@@ -1997,16 +2042,20 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
1997
2042
  }
1998
2043
  indexByKeyForChecking.set(id, i);
1999
2044
  }
2000
- if (currentRowTop !== positions.get(id)) {
2001
- positions.set(id, currentRowTop);
2002
- notifyPosition$(ctx, id, currentRowTop);
2045
+ if (currentRowTop !== positions[i]) {
2046
+ positions[i] = currentRowTop;
2047
+ if (hasPositionListeners) {
2048
+ notifyPosition$(ctx, id, currentRowTop);
2049
+ }
2003
2050
  }
2004
2051
  if (needsIndexByKey) {
2005
2052
  indexByKey.set(id, i);
2006
2053
  }
2007
- columns.set(id, column);
2008
- columnSpans.set(id, span);
2009
- if (hasColumns) {
2054
+ if (!hasColumns) {
2055
+ currentRowTop += size;
2056
+ } else {
2057
+ columns[i] = column;
2058
+ columnSpans[i] = span;
2010
2059
  if (size > maxSizeInRow) {
2011
2060
  maxSizeInRow = size;
2012
2061
  }
@@ -2016,8 +2065,6 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
2016
2065
  column = 1;
2017
2066
  maxSizeInRow = 0;
2018
2067
  }
2019
- } else {
2020
- currentRowTop += size;
2021
2068
  }
2022
2069
  }
2023
2070
  if (!didBreakEarly) {
@@ -2169,14 +2216,38 @@ function shallowEqual(prev, next) {
2169
2216
  return true;
2170
2217
  }
2171
2218
  function computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
2172
- const { sizes, positions, scroll: scrollState } = state;
2219
+ const { sizes, scroll: scrollState } = state;
2173
2220
  const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
2174
2221
  const { itemVisiblePercentThreshold, viewAreaCoveragePercentThreshold } = viewabilityConfig;
2175
2222
  const viewAreaMode = viewAreaCoveragePercentThreshold != null;
2176
2223
  const viewablePercentThreshold = viewAreaMode ? viewAreaCoveragePercentThreshold : itemVisiblePercentThreshold;
2177
2224
  const scroll = scrollState - topPad;
2178
- const top = positions.get(key) - scroll;
2225
+ const position = state.positions[index];
2179
2226
  const size = sizes.get(key) || 0;
2227
+ if (position === void 0) {
2228
+ const value2 = {
2229
+ containerId,
2230
+ index,
2231
+ isViewable: false,
2232
+ item,
2233
+ key,
2234
+ percentOfScroller: 0,
2235
+ percentVisible: 0,
2236
+ scrollSize,
2237
+ size,
2238
+ sizeVisible: -1
2239
+ };
2240
+ const prev2 = ctx.mapViewabilityAmountValues.get(containerId);
2241
+ if (!shallowEqual(prev2, value2)) {
2242
+ ctx.mapViewabilityAmountValues.set(containerId, value2);
2243
+ const cb = ctx.mapViewabilityAmountCallbacks.get(containerId);
2244
+ if (cb) {
2245
+ cb(value2);
2246
+ }
2247
+ }
2248
+ return value2;
2249
+ }
2250
+ const top = position - scroll;
2180
2251
  const bottom = top + size;
2181
2252
  const isEntirelyVisible = top >= 0 && bottom <= scrollSize && bottom > top;
2182
2253
  const sizeVisible = isEntirelyVisible ? size : Math.min(bottom, scrollSize) - Math.max(top, 0);
@@ -2403,13 +2474,10 @@ function setDidLayout(ctx) {
2403
2474
 
2404
2475
  // src/core/calculateItemsInView.ts
2405
2476
  function findCurrentStickyIndex(stickyArray, scroll, state) {
2406
- var _a3;
2407
- const idCache = state.idCache;
2408
2477
  const positions = state.positions;
2409
2478
  for (let i = stickyArray.length - 1; i >= 0; i--) {
2410
2479
  const stickyIndex = stickyArray[i];
2411
- const stickyId = (_a3 = idCache[stickyIndex]) != null ? _a3 : getId(state, stickyIndex);
2412
- const stickyPos = stickyId ? positions.get(stickyId) : void 0;
2480
+ const stickyPos = positions[stickyIndex];
2413
2481
  if (stickyPos !== void 0 && scroll >= stickyPos) {
2414
2482
  return i;
2415
2483
  }
@@ -2439,7 +2507,7 @@ function handleStickyActivation(ctx, stickyHeaderIndices, stickyArray, currentSt
2439
2507
  }
2440
2508
  }
2441
2509
  function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentStickyIdx, pendingRemoval, alwaysRenderIndicesSet) {
2442
- var _a3, _b, _c;
2510
+ var _a3, _b;
2443
2511
  const state = ctx.state;
2444
2512
  for (const containerIndex of state.stickyContainerPool) {
2445
2513
  const itemKey = peek$(ctx, `containerItemKey${containerIndex}`);
@@ -2457,14 +2525,13 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
2457
2525
  const nextIndex = stickyArray[arrayIdx + 1];
2458
2526
  let shouldRecycle = false;
2459
2527
  if (nextIndex) {
2460
- const nextId = (_a3 = state.idCache[nextIndex]) != null ? _a3 : getId(state, nextIndex);
2461
- const nextPos = nextId ? state.positions.get(nextId) : void 0;
2528
+ const nextPos = state.positions[nextIndex];
2462
2529
  shouldRecycle = nextPos !== void 0 && scroll > nextPos + drawDistance * 2;
2463
2530
  } else {
2464
- const currentId = (_b = state.idCache[itemIndex]) != null ? _b : getId(state, itemIndex);
2531
+ const currentId = (_a3 = state.idCache[itemIndex]) != null ? _a3 : getId(state, itemIndex);
2465
2532
  if (currentId) {
2466
- const currentPos = state.positions.get(currentId);
2467
- const currentSize = (_c = state.sizes.get(currentId)) != null ? _c : getItemSize(ctx, currentId, itemIndex, state.props.data[itemIndex]);
2533
+ const currentPos = state.positions[itemIndex];
2534
+ const currentSize = (_b = state.sizes.get(currentId)) != null ? _b : getItemSize(ctx, currentId, itemIndex, state.props.data[itemIndex]);
2468
2535
  shouldRecycle = currentPos !== void 0 && scroll > currentPos + currentSize + drawDistance * 3;
2469
2536
  }
2470
2537
  }
@@ -2476,7 +2543,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
2476
2543
  function calculateItemsInView(ctx, params = {}) {
2477
2544
  const state = ctx.state;
2478
2545
  unstable_batchedUpdates(() => {
2479
- var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2546
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2480
2547
  const {
2481
2548
  columns,
2482
2549
  columnSpans,
@@ -2571,7 +2638,9 @@ function calculateItemsInView(ctx, params = {}) {
2571
2638
  if (dataChanged) {
2572
2639
  indexByKey.clear();
2573
2640
  idCache.length = 0;
2574
- positions.clear();
2641
+ positions.length = 0;
2642
+ columns.length = 0;
2643
+ columnSpans.length = 0;
2575
2644
  }
2576
2645
  const startIndex = forceFullItemPositions || dataChanged ? 0 : (_b = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _b : 0;
2577
2646
  updateItemPositions(ctx, dataChanged, {
@@ -2592,7 +2661,7 @@ function calculateItemsInView(ctx, params = {}) {
2592
2661
  let loopStart = !dataChanged && startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
2593
2662
  for (let i = loopStart; i >= 0; i--) {
2594
2663
  const id = (_c = idCache[i]) != null ? _c : getId(state, i);
2595
- const top = positions.get(id);
2664
+ const top = positions[i];
2596
2665
  const size = (_d = sizes.get(id)) != null ? _d : getItemSize(ctx, id, i, data[i]);
2597
2666
  const bottom = top + size;
2598
2667
  if (bottom > scroll - scrollBufferTop) {
@@ -2603,8 +2672,7 @@ function calculateItemsInView(ctx, params = {}) {
2603
2672
  }
2604
2673
  if (numColumns > 1) {
2605
2674
  while (loopStart > 0) {
2606
- const loopId = (_e = idCache[loopStart]) != null ? _e : getId(state, loopStart);
2607
- const loopColumn = columns.get(loopId);
2675
+ const loopColumn = columns[loopStart];
2608
2676
  if (loopColumn === 1 || loopColumn === void 0) {
2609
2677
  break;
2610
2678
  }
@@ -2625,9 +2693,9 @@ function calculateItemsInView(ctx, params = {}) {
2625
2693
  let firstFullyOnScreenIndex;
2626
2694
  const dataLength = data.length;
2627
2695
  for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
2628
- const id = (_f = idCache[i]) != null ? _f : getId(state, i);
2629
- const size = (_g = sizes.get(id)) != null ? _g : getItemSize(ctx, id, i, data[i]);
2630
- const top = positions.get(id);
2696
+ const id = (_e = idCache[i]) != null ? _e : getId(state, i);
2697
+ const size = (_f = sizes.get(id)) != null ? _f : getItemSize(ctx, id, i, data[i]);
2698
+ const top = positions[i];
2631
2699
  if (!foundEnd) {
2632
2700
  if (startNoBuffer === null && top + size > scroll) {
2633
2701
  startNoBuffer = i;
@@ -2663,7 +2731,7 @@ function calculateItemsInView(ctx, params = {}) {
2663
2731
  }
2664
2732
  const idsInView = [];
2665
2733
  for (let i = firstFullyOnScreenIndex; i <= endNoBuffer; i++) {
2666
- const id = (_h = idCache[i]) != null ? _h : getId(state, i);
2734
+ const id = (_g = idCache[i]) != null ? _g : getId(state, i);
2667
2735
  idsInView.push(id);
2668
2736
  }
2669
2737
  Object.assign(state, {
@@ -2695,7 +2763,7 @@ function calculateItemsInView(ctx, params = {}) {
2695
2763
  const needNewContainers = [];
2696
2764
  const needNewContainersSet = /* @__PURE__ */ new Set();
2697
2765
  for (let i = startBuffered; i <= endBuffered; i++) {
2698
- const id = (_i = idCache[i]) != null ? _i : getId(state, i);
2766
+ const id = (_h = idCache[i]) != null ? _h : getId(state, i);
2699
2767
  if (!containerItemKeys.has(id)) {
2700
2768
  needNewContainersSet.add(i);
2701
2769
  needNewContainers.push(i);
@@ -2704,7 +2772,7 @@ function calculateItemsInView(ctx, params = {}) {
2704
2772
  if (alwaysRenderArr.length > 0) {
2705
2773
  for (const index of alwaysRenderArr) {
2706
2774
  if (index < 0 || index >= dataLength) continue;
2707
- const id = (_j = idCache[index]) != null ? _j : getId(state, index);
2775
+ const id = (_i = idCache[index]) != null ? _i : getId(state, index);
2708
2776
  if (id && !containerItemKeys.has(id) && !needNewContainersSet.has(index)) {
2709
2777
  needNewContainersSet.add(index);
2710
2778
  needNewContainers.push(index);
@@ -2742,7 +2810,7 @@ function calculateItemsInView(ctx, params = {}) {
2742
2810
  for (let idx = 0; idx < needNewContainers.length; idx++) {
2743
2811
  const i = needNewContainers[idx];
2744
2812
  const containerIndex = availableContainers[idx];
2745
- const id = (_k = idCache[i]) != null ? _k : getId(state, i);
2813
+ const id = (_j = idCache[i]) != null ? _j : getId(state, i);
2746
2814
  const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
2747
2815
  if (oldKey && oldKey !== id) {
2748
2816
  containerItemKeys.delete(oldKey);
@@ -2783,7 +2851,7 @@ function calculateItemsInView(ctx, params = {}) {
2783
2851
  if (alwaysRenderArr.length > 0) {
2784
2852
  for (const index of alwaysRenderArr) {
2785
2853
  if (index < 0 || index >= dataLength) continue;
2786
- const id = (_l = idCache[index]) != null ? _l : getId(state, index);
2854
+ const id = (_k = idCache[index]) != null ? _k : getId(state, index);
2787
2855
  const containerIndex = containerItemKeys.get(id);
2788
2856
  if (containerIndex !== void 0) {
2789
2857
  state.stickyContainerPool.add(containerIndex);
@@ -2823,14 +2891,13 @@ function calculateItemsInView(ctx, params = {}) {
2823
2891
  const itemIndex = indexByKey.get(itemKey);
2824
2892
  const item = data[itemIndex];
2825
2893
  if (item !== void 0) {
2826
- const id = (_m = idCache[itemIndex]) != null ? _m : getId(state, itemIndex);
2827
- const positionValue = positions.get(id);
2894
+ const positionValue = positions[itemIndex];
2828
2895
  if (positionValue === void 0) {
2829
2896
  set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
2830
2897
  } else {
2831
2898
  const position = (positionValue || 0) - scrollAdjustPending;
2832
- const column = columns.get(id) || 1;
2833
- const span = columnSpans.get(id) || 1;
2899
+ const column = columns[itemIndex] || 1;
2900
+ const span = columnSpans[itemIndex] || 1;
2834
2901
  const prevPos = peek$(ctx, `containerPosition${i}`);
2835
2902
  const prevColumn = peek$(ctx, `containerColumn${i}`);
2836
2903
  const prevSpan = peek$(ctx, `containerSpan${i}`);
@@ -3417,6 +3484,18 @@ function createColumnWrapperStyle(contentContainerStyle) {
3417
3484
  // src/utils/createImperativeHandle.ts
3418
3485
  function createImperativeHandle(ctx) {
3419
3486
  const state = ctx.state;
3487
+ const runScrollWithPromise = (run) => new Promise((resolve) => {
3488
+ var _a3;
3489
+ (_a3 = state.pendingScrollResolve) == null ? void 0 : _a3.call(state);
3490
+ state.pendingScrollResolve = resolve;
3491
+ const didStartScroll = run();
3492
+ if (!didStartScroll || !state.scrollingTo) {
3493
+ if (state.pendingScrollResolve === resolve) {
3494
+ state.pendingScrollResolve = void 0;
3495
+ }
3496
+ resolve();
3497
+ }
3498
+ });
3420
3499
  const scrollIndexIntoView = (options) => {
3421
3500
  if (state) {
3422
3501
  const { index, ...rest } = options;
@@ -3428,8 +3507,10 @@ function createImperativeHandle(ctx) {
3428
3507
  index,
3429
3508
  viewPosition
3430
3509
  });
3510
+ return true;
3431
3511
  }
3432
3512
  }
3513
+ return false;
3433
3514
  };
3434
3515
  const refScroller = state.refScroller;
3435
3516
  const clearCaches = (options) => {
@@ -3448,9 +3529,9 @@ function createImperativeHandle(ctx) {
3448
3529
  if (mode === "full") {
3449
3530
  state.indexByKey.clear();
3450
3531
  state.idCache.length = 0;
3451
- state.positions.clear();
3452
- state.columns.clear();
3453
- state.columnSpans.clear();
3532
+ state.positions.length = 0;
3533
+ state.columns.length = 0;
3534
+ state.columnSpans.length = 0;
3454
3535
  }
3455
3536
  (_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
3456
3537
  };
@@ -3474,8 +3555,11 @@ function createImperativeHandle(ctx) {
3474
3555
  isAtStart: state.isAtStart,
3475
3556
  listen: (signalName, cb) => listen$(ctx, signalName, cb),
3476
3557
  listenToPosition: (key, cb) => listenPosition$(ctx, key, cb),
3477
- positionAtIndex: (index) => state.positions.get(getId(state, index)),
3478
- positions: state.positions,
3558
+ positionAtIndex: (index) => state.positions[index],
3559
+ positionByKey: (key) => {
3560
+ const index = state.indexByKey.get(key);
3561
+ return index === void 0 ? void 0 : state.positions[index];
3562
+ },
3479
3563
  scroll: state.scroll,
3480
3564
  scrollLength: state.scrollLength,
3481
3565
  scrollVelocity: getScrollVelocity(state),
@@ -3488,15 +3572,17 @@ function createImperativeHandle(ctx) {
3488
3572
  state.contentInsetOverride = inset != null ? inset : void 0;
3489
3573
  updateScroll(ctx, state.scroll, true);
3490
3574
  },
3491
- scrollIndexIntoView,
3492
- scrollItemIntoView: ({ item, ...props }) => {
3575
+ scrollIndexIntoView: (options) => runScrollWithPromise(() => scrollIndexIntoView(options)),
3576
+ scrollItemIntoView: ({ item, ...props }) => runScrollWithPromise(() => {
3493
3577
  const data = state.props.data;
3494
3578
  const index = data.indexOf(item);
3495
3579
  if (index !== -1) {
3496
3580
  scrollIndexIntoView({ index, ...props });
3581
+ return true;
3497
3582
  }
3498
- },
3499
- scrollToEnd: (options) => {
3583
+ return false;
3584
+ }),
3585
+ scrollToEnd: (options) => runScrollWithPromise(() => {
3500
3586
  const data = state.props.data;
3501
3587
  const stylePaddingBottom = state.props.stylePaddingBottom;
3502
3588
  const index = data.length - 1;
@@ -3509,17 +3595,27 @@ function createImperativeHandle(ctx) {
3509
3595
  viewOffset: -paddingBottom - footerSize + ((options == null ? void 0 : options.viewOffset) || 0),
3510
3596
  viewPosition: 1
3511
3597
  });
3598
+ return true;
3512
3599
  }
3513
- },
3514
- scrollToIndex: (params) => scrollToIndex(ctx, params),
3515
- scrollToItem: ({ item, ...props }) => {
3600
+ return false;
3601
+ }),
3602
+ scrollToIndex: (params) => runScrollWithPromise(() => {
3603
+ scrollToIndex(ctx, params);
3604
+ return true;
3605
+ }),
3606
+ scrollToItem: ({ item, ...props }) => runScrollWithPromise(() => {
3516
3607
  const data = state.props.data;
3517
3608
  const index = data.indexOf(item);
3518
3609
  if (index !== -1) {
3519
3610
  scrollToIndex(ctx, { index, ...props });
3611
+ return true;
3520
3612
  }
3521
- },
3522
- scrollToOffset: (params) => scrollTo(ctx, params),
3613
+ return false;
3614
+ }),
3615
+ scrollToOffset: (params) => runScrollWithPromise(() => {
3616
+ scrollTo(ctx, params);
3617
+ return true;
3618
+ }),
3523
3619
  setScrollProcessingEnabled: (enabled) => {
3524
3620
  state.scrollProcessingEnabled = enabled;
3525
3621
  },
@@ -3756,6 +3852,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3756
3852
  refreshControl,
3757
3853
  refreshing,
3758
3854
  refScrollView,
3855
+ renderScrollComponent,
3759
3856
  renderItem,
3760
3857
  scrollEventThrottle,
3761
3858
  snapToIndices,
@@ -3764,15 +3861,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3764
3861
  // TODOV3: Remove from v3 release
3765
3862
  style: styleProp,
3766
3863
  suggestEstimatedItemSize,
3864
+ useWindowScroll = false,
3767
3865
  viewabilityConfig,
3768
3866
  viewabilityConfigCallbackPairs,
3769
3867
  waitForInitialLayout = true,
3770
3868
  ...rest
3771
3869
  } = props;
3772
3870
  const animatedPropsInternal = props.animatedPropsInternal;
3871
+ const positionComponentInternal = props.positionComponentInternal;
3773
3872
  const stickyPositionComponentInternal = props.stickyPositionComponentInternal;
3774
3873
  const {
3775
3874
  childrenMode,
3875
+ positionComponentInternal: _positionComponentInternal,
3776
3876
  stickyPositionComponentInternal: _stickyPositionComponentInternal,
3777
3877
  ...restProps
3778
3878
  } = rest;
@@ -3827,6 +3927,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3827
3927
  "stickyIndices has been renamed to stickyHeaderIndices. Please update your props to use stickyHeaderIndices."
3828
3928
  );
3829
3929
  }
3930
+ if (IS_DEV && useWindowScroll && renderScrollComponent) {
3931
+ warnDevOnce(
3932
+ "useWindowScrollRenderScrollComponent",
3933
+ "useWindowScroll is not supported when renderScrollComponent is provided."
3934
+ );
3935
+ }
3936
+ const useWindowScrollResolved = Platform2.OS === "web" && !!useWindowScroll && !renderScrollComponent;
3830
3937
  const refState = useRef();
3831
3938
  const hasOverrideItemLayout = !!overrideItemLayout;
3832
3939
  const prevHasOverrideItemLayout = useRef(hasOverrideItemLayout);
@@ -3836,11 +3943,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3836
3943
  ctx.state = {
3837
3944
  activeStickyIndex: -1,
3838
3945
  averageSizes: {},
3839
- columnSpans: /* @__PURE__ */ new Map(),
3840
- columns: /* @__PURE__ */ new Map(),
3946
+ columnSpans: [],
3947
+ columns: [],
3841
3948
  containerItemKeys: /* @__PURE__ */ new Map(),
3842
3949
  containerItemTypes: /* @__PURE__ */ new Map(),
3843
3950
  contentInsetOverride: void 0,
3951
+ dataChangeEpoch: 0,
3844
3952
  dataChangeNeedsScrollUpdate: false,
3845
3953
  didColumnsChange: false,
3846
3954
  didDataChange: false,
@@ -3872,10 +3980,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3872
3980
  minIndexSizeChanged: 0,
3873
3981
  nativeContentInset: void 0,
3874
3982
  nativeMarginTop: 0,
3875
- positions: /* @__PURE__ */ new Map(),
3983
+ positions: [],
3876
3984
  props: {},
3877
3985
  queuedCalculateItemsInView: 0,
3878
- refScroller: void 0,
3986
+ refScroller: { current: null },
3879
3987
  scroll: 0,
3880
3988
  scrollAdjustHandler: new ScrollAdjustHandler(ctx),
3881
3989
  scrollForNextCalculateItemsInView: void 0,
@@ -3891,6 +3999,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3891
3999
  startBuffered: -1,
3892
4000
  startNoBuffer: -1,
3893
4001
  startReachedSnapshot: void 0,
4002
+ startReachedSnapshotDataChangeEpoch: void 0,
3894
4003
  stickyContainerPool: /* @__PURE__ */ new Set(),
3895
4004
  stickyContainers: /* @__PURE__ */ new Map(),
3896
4005
  timeoutSizeMessage: 0,
@@ -3910,6 +4019,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3910
4019
  state.didColumnsChange = numColumnsProp !== state.props.numColumns;
3911
4020
  const didDataChangeLocal = state.props.dataVersion !== dataVersion || state.props.data !== dataProp && checkActualChange(state, dataProp, state.props.data);
3912
4021
  if (didDataChangeLocal) {
4022
+ state.dataChangeEpoch += 1;
3913
4023
  state.dataChangeNeedsScrollUpdate = true;
3914
4024
  state.didDataChange = true;
3915
4025
  state.previousData = state.props.data;
@@ -3946,6 +4056,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3946
4056
  onStartReachedThreshold,
3947
4057
  onStickyHeaderChange,
3948
4058
  overrideItemLayout,
4059
+ positionComponentInternal,
3949
4060
  recycleItems: !!recycleItems,
3950
4061
  renderItem,
3951
4062
  snapToIndices,
@@ -3954,7 +4065,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3954
4065
  stickyPositionComponentInternal,
3955
4066
  stylePaddingBottom: stylePaddingBottomState,
3956
4067
  stylePaddingTop: stylePaddingTopState,
3957
- suggestEstimatedItemSize: !!suggestEstimatedItemSize
4068
+ suggestEstimatedItemSize: !!suggestEstimatedItemSize,
4069
+ useWindowScroll: useWindowScrollResolved
3958
4070
  };
3959
4071
  state.refScroller = refScroller;
3960
4072
  const memoizedLastItemKeys = useMemo(() => {
@@ -4028,7 +4140,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
4028
4140
  "Changing data without a keyExtractor can cause slow performance and resetting scroll. If your list data can change you should use a keyExtractor with a unique id for best performance and behavior."
4029
4141
  );
4030
4142
  refState.current.sizes.clear();
4031
- refState.current.positions.clear();
4143
+ refState.current.positions.length = 0;
4032
4144
  refState.current.totalSize = 0;
4033
4145
  set$(ctx, "totalSize", 0);
4034
4146
  }
@@ -4187,12 +4299,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
4187
4299
  }
4188
4300
  ),
4189
4301
  refScrollView: combinedRef,
4302
+ renderScrollComponent,
4190
4303
  scrollAdjustHandler: (_d = refState.current) == null ? void 0 : _d.scrollAdjustHandler,
4191
4304
  scrollEventThrottle: 0,
4192
4305
  snapToIndices,
4193
4306
  stickyHeaderIndices,
4194
4307
  style,
4195
4308
  updateItemSize: fns.updateItemSize,
4309
+ useWindowScroll: useWindowScrollResolved,
4196
4310
  waitForInitialLayout
4197
4311
  }
4198
4312
  ), IS_DEV && ENABLE_DEBUG_VIEW);