@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.
@@ -653,6 +653,7 @@ var Container = typedMemo2(function Container2({
653
653
  }) {
654
654
  const ctx = useStateContext();
655
655
  const { columnWrapperStyle, animatedScrollY } = ctx;
656
+ const positionComponentInternal = ctx.state.props.positionComponentInternal;
656
657
  const stickyPositionComponentInternal = ctx.state.props.stickyPositionComponentInternal;
657
658
  const [column = 0, span = 1, data, itemKey, numColumns = 1, extraData, isSticky] = useArr$([
658
659
  `containerColumn${id}`,
@@ -806,7 +807,7 @@ var Container = typedMemo2(function Container2({
806
807
  }
807
808
  }, [itemKey]);
808
809
  }
809
- const PositionComponent = isSticky ? stickyPositionComponentInternal ? stickyPositionComponentInternal : PositionViewSticky : PositionView;
810
+ const PositionComponent = isSticky ? stickyPositionComponentInternal ? stickyPositionComponentInternal : PositionViewSticky : positionComponentInternal ? positionComponentInternal : PositionView;
810
811
  return /* @__PURE__ */ React2__namespace.createElement(
811
812
  PositionComponent,
812
813
  {
@@ -943,6 +944,7 @@ var ListComponent = typedMemo2(function ListComponent2({
943
944
  snapToIndices,
944
945
  stickyHeaderConfig,
945
946
  stickyHeaderIndices,
947
+ useWindowScroll = false,
946
948
  ...rest
947
949
  }) {
948
950
  const ctx = useStateContext();
@@ -966,6 +968,7 @@ var ListComponent = typedMemo2(function ListComponent2({
966
968
  SnapOrScroll,
967
969
  {
968
970
  ...rest,
971
+ ...ScrollComponent === ListComponentScrollView ? { useWindowScroll } : {},
969
972
  contentContainerStyle: [
970
973
  contentContainerStyle,
971
974
  horizontal ? {
@@ -1011,24 +1014,12 @@ var ListComponent = typedMemo2(function ListComponent2({
1011
1014
  );
1012
1015
  });
1013
1016
 
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
-
1026
1017
  // src/core/calculateOffsetForIndex.ts
1027
1018
  function calculateOffsetForIndex(ctx, index) {
1028
1019
  const state = ctx.state;
1029
1020
  let position = 0;
1030
1021
  if (index !== void 0) {
1031
- position = state.positions.get(getId(state, index)) || 0;
1022
+ position = state.positions[index] || 0;
1032
1023
  const paddingTop = peek$(ctx, "stylePaddingTop");
1033
1024
  if (paddingTop) {
1034
1025
  position += paddingTop;
@@ -1041,6 +1032,18 @@ function calculateOffsetForIndex(ctx, index) {
1041
1032
  return position;
1042
1033
  }
1043
1034
 
1035
+ // src/utils/getId.ts
1036
+ function getId(state, index) {
1037
+ const { data, keyExtractor } = state.props;
1038
+ if (!data) {
1039
+ return "";
1040
+ }
1041
+ const ret = index < data.length ? keyExtractor ? keyExtractor(data[index], index) : index : null;
1042
+ const id = ret;
1043
+ state.idCache[index] = id;
1044
+ return id;
1045
+ }
1046
+
1044
1047
  // src/core/addTotalSize.ts
1045
1048
  function addTotalSize(ctx, key, add) {
1046
1049
  const state = ctx.state;
@@ -1094,13 +1097,13 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
1094
1097
  return sizeKnown;
1095
1098
  }
1096
1099
  let size;
1097
- const itemType = getItemType ? (_a3 = getItemType(data, index)) != null ? _a3 : "" : "";
1098
1100
  if (preferCachedSize) {
1099
1101
  const cachedSize = sizes.get(key);
1100
1102
  if (cachedSize !== void 0) {
1101
1103
  return cachedSize;
1102
1104
  }
1103
1105
  }
1106
+ const itemType = getItemType ? (_a3 = getItemType(data, index)) != null ? _a3 : "" : "";
1104
1107
  if (getFixedItemSize) {
1105
1108
  size = getFixedItemSize(data, index, itemType);
1106
1109
  if (size !== void 0) {
@@ -1244,37 +1247,54 @@ function checkAtBottom(ctx) {
1244
1247
 
1245
1248
  // src/utils/checkAtTop.ts
1246
1249
  function checkAtTop(ctx) {
1247
- var _a3;
1248
1250
  const state = ctx == null ? void 0 : ctx.state;
1249
1251
  if (!state || state.initialScroll || state.scrollingTo) {
1250
1252
  return;
1251
1253
  }
1252
1254
  const {
1253
- scrollLength,
1255
+ dataChangeEpoch,
1256
+ isStartReached,
1257
+ props: { data, onStartReachedThreshold },
1254
1258
  scroll,
1255
- props: { onStartReachedThreshold }
1259
+ scrollLength,
1260
+ startReachedSnapshot,
1261
+ startReachedSnapshotDataChangeEpoch,
1262
+ totalSize
1256
1263
  } = state;
1257
- const distanceFromTop = scroll;
1258
- state.isAtStart = distanceFromTop <= 0;
1264
+ const dataLength = data.length;
1265
+ const threshold = onStartReachedThreshold * scrollLength;
1266
+ const dataChanged = startReachedSnapshotDataChangeEpoch !== dataChangeEpoch;
1267
+ const withinThreshold = threshold > 0 && Math.abs(scroll) <= threshold;
1268
+ const allowReentryOnDataChange = !!isStartReached && withinThreshold && !!dataChanged && !isInMVCPActiveMode(state);
1269
+ if (isStartReached && threshold > 0 && scroll > threshold && startReachedSnapshot && (dataChanged || startReachedSnapshot.contentSize !== totalSize || startReachedSnapshot.dataLength !== dataLength)) {
1270
+ state.isStartReached = false;
1271
+ state.startReachedSnapshot = void 0;
1272
+ state.startReachedSnapshotDataChangeEpoch = void 0;
1273
+ }
1274
+ state.isAtStart = scroll <= 0;
1275
+ if (isStartReached && withinThreshold && dataChanged && !allowReentryOnDataChange) {
1276
+ return;
1277
+ }
1259
1278
  state.isStartReached = checkThreshold(
1260
- distanceFromTop,
1279
+ scroll,
1261
1280
  false,
1262
- onStartReachedThreshold * scrollLength,
1281
+ threshold,
1263
1282
  state.isStartReached,
1264
- state.startReachedSnapshot,
1283
+ allowReentryOnDataChange ? void 0 : startReachedSnapshot,
1265
1284
  {
1266
- contentSize: state.totalSize,
1267
- dataLength: (_a3 = state.props.data) == null ? void 0 : _a3.length,
1285
+ contentSize: totalSize,
1286
+ dataLength,
1268
1287
  scrollPosition: scroll
1269
1288
  },
1270
1289
  (distance) => {
1271
- var _a4, _b;
1272
- return (_b = (_a4 = state.props).onStartReached) == null ? void 0 : _b.call(_a4, { distanceFromStart: distance });
1290
+ var _a3, _b;
1291
+ return (_b = (_a3 = state.props).onStartReached) == null ? void 0 : _b.call(_a3, { distanceFromStart: distance });
1273
1292
  },
1274
1293
  (snapshot) => {
1275
1294
  state.startReachedSnapshot = snapshot;
1295
+ state.startReachedSnapshotDataChangeEpoch = snapshot ? dataChangeEpoch : void 0;
1276
1296
  },
1277
- false
1297
+ allowReentryOnDataChange
1278
1298
  );
1279
1299
  }
1280
1300
 
@@ -1314,6 +1334,8 @@ function finishScrollTo(ctx) {
1314
1334
  var _a3, _b;
1315
1335
  const state = ctx.state;
1316
1336
  if (state == null ? void 0 : state.scrollingTo) {
1337
+ const resolvePendingScroll = state.pendingScrollResolve;
1338
+ state.pendingScrollResolve = void 0;
1317
1339
  const scrollingTo = state.scrollingTo;
1318
1340
  state.scrollHistory.length = 0;
1319
1341
  state.initialScroll = void 0;
@@ -1330,6 +1352,7 @@ function finishScrollTo(ctx) {
1330
1352
  }
1331
1353
  setInitialRenderState(ctx, { didInitialScroll: true });
1332
1354
  checkThresholds(ctx);
1355
+ resolvePendingScroll == null ? void 0 : resolvePendingScroll();
1333
1356
  }
1334
1357
  }
1335
1358
 
@@ -1386,16 +1409,20 @@ function checkFinishedScrollFallback(ctx) {
1386
1409
 
1387
1410
  // src/core/doScrollTo.native.ts
1388
1411
  function doScrollTo(ctx, params) {
1389
- var _a3;
1390
1412
  const state = ctx.state;
1391
1413
  const { animated, horizontal, offset } = params;
1414
+ const isAnimated = !!animated;
1392
1415
  const { refScroller } = state;
1393
- (_a3 = refScroller.current) == null ? void 0 : _a3.scrollTo({
1394
- animated: !!animated,
1416
+ const scroller = refScroller.current;
1417
+ if (!scroller) {
1418
+ return;
1419
+ }
1420
+ scroller.scrollTo({
1421
+ animated: isAnimated,
1395
1422
  x: horizontal ? offset : 0,
1396
1423
  y: horizontal ? 0 : offset
1397
1424
  });
1398
- if (!animated) {
1425
+ if (!isAnimated) {
1399
1426
  state.scroll = offset;
1400
1427
  checkFinishedScrollFallback(ctx);
1401
1428
  }
@@ -1437,7 +1464,7 @@ var flushSync = (fn) => {
1437
1464
  // src/core/updateScroll.ts
1438
1465
  function updateScroll(ctx, newScroll, forceUpdate) {
1439
1466
  const state = ctx.state;
1440
- const { scrollingTo, scrollAdjustHandler, lastScrollAdjustForHistory } = state;
1467
+ const { ignoreScrollFromMVCP, lastScrollAdjustForHistory, scrollAdjustHandler, scrollHistory, scrollingTo } = state;
1441
1468
  const prevScroll = state.scroll;
1442
1469
  state.hasScrolled = true;
1443
1470
  state.lastBatchingAction = Date.now();
@@ -1445,22 +1472,17 @@ function updateScroll(ctx, newScroll, forceUpdate) {
1445
1472
  const adjust = scrollAdjustHandler.getAdjust();
1446
1473
  const adjustChanged = lastScrollAdjustForHistory !== void 0 && Math.abs(adjust - lastScrollAdjustForHistory) > 0.1;
1447
1474
  if (adjustChanged) {
1448
- state.scrollHistory.length = 0;
1475
+ scrollHistory.length = 0;
1449
1476
  }
1450
1477
  state.lastScrollAdjustForHistory = adjust;
1451
- if (scrollingTo === void 0 && !(state.scrollHistory.length === 0 && newScroll === state.scroll)) {
1478
+ if (scrollingTo === void 0 && !(scrollHistory.length === 0 && newScroll === state.scroll)) {
1452
1479
  if (!adjustChanged) {
1453
- state.scrollHistory.push({ scroll: newScroll, time: currentTime });
1480
+ scrollHistory.push({ scroll: newScroll, time: currentTime });
1454
1481
  }
1455
1482
  }
1456
- if (state.scrollHistory.length > 5) {
1457
- state.scrollHistory.shift();
1483
+ if (scrollHistory.length > 5) {
1484
+ scrollHistory.shift();
1458
1485
  }
1459
- state.scrollPrev = prevScroll;
1460
- state.scrollPrevTime = state.scrollTime;
1461
- state.scroll = newScroll;
1462
- state.scrollTime = currentTime;
1463
- const ignoreScrollFromMVCP = state.ignoreScrollFromMVCP;
1464
1486
  if (ignoreScrollFromMVCP && !scrollingTo) {
1465
1487
  const { lt, gt } = ignoreScrollFromMVCP;
1466
1488
  if (lt && newScroll < lt || gt && newScroll > gt) {
@@ -1468,6 +1490,10 @@ function updateScroll(ctx, newScroll, forceUpdate) {
1468
1490
  return;
1469
1491
  }
1470
1492
  }
1493
+ state.scrollPrev = prevScroll;
1494
+ state.scrollPrevTime = state.scrollTime;
1495
+ state.scroll = newScroll;
1496
+ state.scrollTime = currentTime;
1471
1497
  const scrollDelta = Math.abs(newScroll - prevScroll);
1472
1498
  const scrollLength = state.scrollLength;
1473
1499
  const lastCalculated = state.scrollLastCalculate;
@@ -1553,14 +1579,14 @@ var INITIAL_ANCHOR_SETTLED_TICKS = 2;
1553
1579
  function ensureInitialAnchor(ctx) {
1554
1580
  var _a3, _b, _c, _d, _e;
1555
1581
  const state = ctx.state;
1556
- const { initialAnchor, didContainersLayout, positions, scroll, scrollLength } = state;
1582
+ const { initialAnchor, didContainersLayout, scroll, scrollLength } = state;
1557
1583
  const anchor = initialAnchor;
1558
1584
  const item = state.props.data[anchor.index];
1559
1585
  if (!didContainersLayout) {
1560
1586
  return;
1561
1587
  }
1562
1588
  const id = getId(state, anchor.index);
1563
- if (positions.get(id) === void 0) {
1589
+ if (state.positions[anchor.index] === void 0) {
1564
1590
  return;
1565
1591
  }
1566
1592
  const size = getItemSize(ctx, id, anchor.index, item, true, true);
@@ -1676,12 +1702,18 @@ function prepareMVCP(ctx, dataChanged) {
1676
1702
  const id = idsInView[i];
1677
1703
  const index = indexByKey.get(id);
1678
1704
  if (index !== void 0) {
1679
- idsInViewWithPositions.push({ id, position: positions.get(id) });
1705
+ const position = positions[index];
1706
+ if (position !== void 0) {
1707
+ idsInViewWithPositions.push({ id, position });
1708
+ }
1680
1709
  }
1681
1710
  }
1682
1711
  }
1683
1712
  if (targetId !== void 0 && prevPosition === void 0) {
1684
- prevPosition = positions.get(targetId);
1713
+ const targetIndex = indexByKey.get(targetId);
1714
+ if (targetIndex !== void 0) {
1715
+ prevPosition = positions[targetIndex];
1716
+ }
1685
1717
  }
1686
1718
  return () => {
1687
1719
  let positionDiff = 0;
@@ -1700,7 +1732,13 @@ function prepareMVCP(ctx, dataChanged) {
1700
1732
  }
1701
1733
  }
1702
1734
  }
1703
- const shouldUseFallbackVisibleAnchor = dataChanged && mvcpData && scrollTarget === void 0 && (targetId === void 0 || positions.get(targetId) === void 0 || skipTargetAnchor);
1735
+ const shouldUseFallbackVisibleAnchor = dataChanged && mvcpData && scrollTarget === void 0 && (() => {
1736
+ if (targetId === void 0 || skipTargetAnchor) {
1737
+ return true;
1738
+ }
1739
+ const targetIndex = indexByKey.get(targetId);
1740
+ return targetIndex === void 0 || positions[targetIndex] === void 0;
1741
+ })();
1704
1742
  if (shouldUseFallbackVisibleAnchor) {
1705
1743
  for (let i = 0; i < idsInViewWithPositions.length; i++) {
1706
1744
  const { id, position } = idsInViewWithPositions[i];
@@ -1711,7 +1749,7 @@ function prepareMVCP(ctx, dataChanged) {
1711
1749
  continue;
1712
1750
  }
1713
1751
  }
1714
- const newPosition = positions.get(id);
1752
+ const newPosition = index !== void 0 ? positions[index] : void 0;
1715
1753
  if (newPosition !== void 0) {
1716
1754
  positionDiff = newPosition - position;
1717
1755
  anchorIdForLock = id;
@@ -1721,7 +1759,8 @@ function prepareMVCP(ctx, dataChanged) {
1721
1759
  }
1722
1760
  }
1723
1761
  if (!skipTargetAnchor && targetId !== void 0 && prevPosition !== void 0) {
1724
- const newPosition = positions.get(targetId);
1762
+ const targetIndex = indexByKey.get(targetId);
1763
+ const newPosition = targetIndex !== void 0 ? positions[targetIndex] : void 0;
1725
1764
  if (newPosition !== void 0) {
1726
1765
  const totalSize = getContentSize(ctx);
1727
1766
  let diff = newPosition - prevPosition;
@@ -1768,17 +1807,15 @@ function prepareColumnStartState(ctx, startIndex, useAverageSize) {
1768
1807
  const state = ctx.state;
1769
1808
  const numColumns = peek$(ctx, "numColumns");
1770
1809
  let rowStartIndex = startIndex;
1771
- const columnAtStart = state.columns.get(state.idCache[startIndex]);
1810
+ const columnAtStart = state.columns[startIndex];
1772
1811
  if (columnAtStart !== 1) {
1773
1812
  rowStartIndex = findRowStartIndex(state, numColumns, startIndex);
1774
1813
  }
1775
1814
  let currentRowTop = 0;
1776
- const curId = state.idCache[rowStartIndex];
1777
- const column = state.columns.get(curId);
1815
+ const column = state.columns[rowStartIndex];
1778
1816
  if (rowStartIndex > 0) {
1779
1817
  const prevIndex = rowStartIndex - 1;
1780
- const prevId = state.idCache[prevIndex];
1781
- const prevPosition = (_a3 = state.positions.get(prevId)) != null ? _a3 : 0;
1818
+ const prevPosition = (_a3 = state.positions[prevIndex]) != null ? _a3 : 0;
1782
1819
  const prevRowStart = findRowStartIndex(state, numColumns, prevIndex);
1783
1820
  const prevRowHeight = calculateRowMaxSize(ctx, prevRowStart, prevIndex, useAverageSize);
1784
1821
  currentRowTop = prevPosition + prevRowHeight;
@@ -1795,7 +1832,7 @@ function findRowStartIndex(state, numColumns, index) {
1795
1832
  }
1796
1833
  let rowStart = Math.max(0, index);
1797
1834
  while (rowStart > 0) {
1798
- const columnForIndex = state.columns.get(state.idCache[rowStart]);
1835
+ const columnForIndex = state.columns[rowStart];
1799
1836
  if (columnForIndex === 1) {
1800
1837
  break;
1801
1838
  }
@@ -1828,7 +1865,7 @@ function calculateRowMaxSize(ctx, startIndex, endIndex, useAverageSize) {
1828
1865
 
1829
1866
  // src/core/updateTotalSize.ts
1830
1867
  function updateTotalSize(ctx) {
1831
- var _a3, _b, _c;
1868
+ var _a3, _b;
1832
1869
  const state = ctx.state;
1833
1870
  const {
1834
1871
  positions,
@@ -1838,36 +1875,34 @@ function updateTotalSize(ctx) {
1838
1875
  if (data.length === 0) {
1839
1876
  addTotalSize(ctx, null, 0);
1840
1877
  } else {
1841
- const lastId = getId(state, data.length - 1);
1842
- if (lastId !== void 0) {
1843
- const lastPosition = positions.get(lastId);
1844
- if (lastPosition !== void 0) {
1845
- if (numColumns > 1) {
1846
- let rowStart = data.length - 1;
1847
- while (rowStart > 0) {
1848
- const rowId = (_b = state.idCache[rowStart]) != null ? _b : getId(state, rowStart);
1849
- const column = state.columns.get(rowId);
1850
- if (column === 1 || column === void 0) {
1851
- break;
1852
- }
1853
- rowStart -= 1;
1854
- }
1855
- let maxSize = 0;
1856
- for (let i = rowStart; i < data.length; i++) {
1857
- const rowId = (_c = state.idCache[i]) != null ? _c : getId(state, i);
1858
- const size = getItemSize(ctx, rowId, i, data[i]);
1859
- if (size > maxSize) {
1860
- maxSize = size;
1861
- }
1878
+ const lastIndex = data.length - 1;
1879
+ const lastId = getId(state, lastIndex);
1880
+ const lastPosition = positions[lastIndex];
1881
+ if (lastId !== void 0 && lastPosition !== void 0) {
1882
+ if (numColumns > 1) {
1883
+ let rowStart = lastIndex;
1884
+ while (rowStart > 0) {
1885
+ const column = state.columns[rowStart];
1886
+ if (column === 1 || column === void 0) {
1887
+ break;
1862
1888
  }
1863
- addTotalSize(ctx, null, lastPosition + maxSize);
1864
- } else {
1865
- const lastSize = getItemSize(ctx, lastId, data.length - 1, data[data.length - 1]);
1866
- if (lastSize !== void 0) {
1867
- const totalSize = lastPosition + lastSize;
1868
- addTotalSize(ctx, null, totalSize);
1889
+ rowStart -= 1;
1890
+ }
1891
+ let maxSize = 0;
1892
+ for (let i = rowStart; i <= lastIndex; i++) {
1893
+ const rowId = (_b = state.idCache[i]) != null ? _b : getId(state, i);
1894
+ const size = getItemSize(ctx, rowId, i, data[i]);
1895
+ if (size > maxSize) {
1896
+ maxSize = size;
1869
1897
  }
1870
1898
  }
1899
+ addTotalSize(ctx, null, lastPosition + maxSize);
1900
+ } else {
1901
+ const lastSize = getItemSize(ctx, lastId, lastIndex, data[lastIndex]);
1902
+ if (lastSize !== void 0) {
1903
+ const totalSize = lastPosition + lastSize;
1904
+ addTotalSize(ctx, null, totalSize);
1905
+ }
1871
1906
  }
1872
1907
  }
1873
1908
  }
@@ -1916,14 +1951,13 @@ var getScrollVelocity = (state) => {
1916
1951
  function updateSnapToOffsets(ctx) {
1917
1952
  const state = ctx.state;
1918
1953
  const {
1919
- positions,
1920
1954
  props: { snapToIndices }
1921
1955
  } = state;
1922
1956
  const snapToOffsets = Array(snapToIndices.length);
1923
1957
  for (let i = 0; i < snapToIndices.length; i++) {
1924
1958
  const idx = snapToIndices[i];
1925
- const key = getId(state, idx);
1926
- snapToOffsets[i] = positions.get(key);
1959
+ getId(state, idx);
1960
+ snapToOffsets[i] = state.positions[idx];
1927
1961
  }
1928
1962
  set$(ctx, "snapToOffsets", snapToOffsets);
1929
1963
  }
@@ -1935,8 +1969,9 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
1935
1969
  scrollBottomBuffered: -1,
1936
1970
  startIndex: 0
1937
1971
  }) {
1938
- var _a3, _b, _c, _d, _e, _f;
1972
+ var _a3, _b, _c, _d, _e;
1939
1973
  const state = ctx.state;
1974
+ const hasPositionListeners = ctx.positionListeners.size > 0;
1940
1975
  const {
1941
1976
  columns,
1942
1977
  columnSpans,
@@ -1963,7 +1998,15 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
1963
1998
  let column = 1;
1964
1999
  let maxSizeInRow = 0;
1965
2000
  if (dataChanged) {
1966
- columnSpans.clear();
2001
+ columnSpans.length = 0;
2002
+ }
2003
+ if (!hasColumns) {
2004
+ if (columns.length) {
2005
+ columns.length = 0;
2006
+ }
2007
+ if (columnSpans.length) {
2008
+ columnSpans.length = 0;
2009
+ }
1967
2010
  }
1968
2011
  if (startIndex > 0) {
1969
2012
  if (hasColumns) {
@@ -1977,12 +2020,13 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
1977
2020
  } else if (startIndex < dataLength) {
1978
2021
  const prevIndex = startIndex - 1;
1979
2022
  const prevId = getId(state, prevIndex);
1980
- const prevPosition = (_c = positions.get(prevId)) != null ? _c : 0;
2023
+ const prevPosition = (_c = positions[prevIndex]) != null ? _c : 0;
1981
2024
  const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(ctx, prevId, prevIndex, data[prevIndex], useAverageSize, preferCachedSize);
1982
2025
  currentRowTop = prevPosition + prevSize;
1983
2026
  }
1984
2027
  }
1985
2028
  const needsIndexByKey = dataChanged || indexByKey.size === 0;
2029
+ const canOverrideSpan = hasColumns && !!overrideItemLayout && !!layoutConfig;
1986
2030
  let didBreakEarly = false;
1987
2031
  let breakAt;
1988
2032
  for (let i = startIndex; i < dataLength; i++) {
@@ -1996,7 +2040,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
1996
2040
  }
1997
2041
  const id = (_e = idCache[i]) != null ? _e : getId(state, i);
1998
2042
  let span = 1;
1999
- if (hasColumns && overrideItemLayout && layoutConfig) {
2043
+ if (canOverrideSpan) {
2000
2044
  layoutConfig.span = 1;
2001
2045
  overrideItemLayout(layoutConfig, data[i], i, numColumns, extraData);
2002
2046
  const requestedSpan = layoutConfig.span;
@@ -2009,7 +2053,8 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
2009
2053
  column = 1;
2010
2054
  maxSizeInRow = 0;
2011
2055
  }
2012
- const size = (_f = sizesKnown.get(id)) != null ? _f : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize);
2056
+ const knownSize = sizesKnown.get(id);
2057
+ const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize);
2013
2058
  if (IS_DEV && needsIndexByKey) {
2014
2059
  if (indexByKeyForChecking.has(id)) {
2015
2060
  console.error(
@@ -2018,16 +2063,20 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
2018
2063
  }
2019
2064
  indexByKeyForChecking.set(id, i);
2020
2065
  }
2021
- if (currentRowTop !== positions.get(id)) {
2022
- positions.set(id, currentRowTop);
2023
- notifyPosition$(ctx, id, currentRowTop);
2066
+ if (currentRowTop !== positions[i]) {
2067
+ positions[i] = currentRowTop;
2068
+ if (hasPositionListeners) {
2069
+ notifyPosition$(ctx, id, currentRowTop);
2070
+ }
2024
2071
  }
2025
2072
  if (needsIndexByKey) {
2026
2073
  indexByKey.set(id, i);
2027
2074
  }
2028
- columns.set(id, column);
2029
- columnSpans.set(id, span);
2030
- if (hasColumns) {
2075
+ if (!hasColumns) {
2076
+ currentRowTop += size;
2077
+ } else {
2078
+ columns[i] = column;
2079
+ columnSpans[i] = span;
2031
2080
  if (size > maxSizeInRow) {
2032
2081
  maxSizeInRow = size;
2033
2082
  }
@@ -2037,8 +2086,6 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
2037
2086
  column = 1;
2038
2087
  maxSizeInRow = 0;
2039
2088
  }
2040
- } else {
2041
- currentRowTop += size;
2042
2089
  }
2043
2090
  }
2044
2091
  if (!didBreakEarly) {
@@ -2190,14 +2237,38 @@ function shallowEqual(prev, next) {
2190
2237
  return true;
2191
2238
  }
2192
2239
  function computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
2193
- const { sizes, positions, scroll: scrollState } = state;
2240
+ const { sizes, scroll: scrollState } = state;
2194
2241
  const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
2195
2242
  const { itemVisiblePercentThreshold, viewAreaCoveragePercentThreshold } = viewabilityConfig;
2196
2243
  const viewAreaMode = viewAreaCoveragePercentThreshold != null;
2197
2244
  const viewablePercentThreshold = viewAreaMode ? viewAreaCoveragePercentThreshold : itemVisiblePercentThreshold;
2198
2245
  const scroll = scrollState - topPad;
2199
- const top = positions.get(key) - scroll;
2246
+ const position = state.positions[index];
2200
2247
  const size = sizes.get(key) || 0;
2248
+ if (position === void 0) {
2249
+ const value2 = {
2250
+ containerId,
2251
+ index,
2252
+ isViewable: false,
2253
+ item,
2254
+ key,
2255
+ percentOfScroller: 0,
2256
+ percentVisible: 0,
2257
+ scrollSize,
2258
+ size,
2259
+ sizeVisible: -1
2260
+ };
2261
+ const prev2 = ctx.mapViewabilityAmountValues.get(containerId);
2262
+ if (!shallowEqual(prev2, value2)) {
2263
+ ctx.mapViewabilityAmountValues.set(containerId, value2);
2264
+ const cb = ctx.mapViewabilityAmountCallbacks.get(containerId);
2265
+ if (cb) {
2266
+ cb(value2);
2267
+ }
2268
+ }
2269
+ return value2;
2270
+ }
2271
+ const top = position - scroll;
2201
2272
  const bottom = top + size;
2202
2273
  const isEntirelyVisible = top >= 0 && bottom <= scrollSize && bottom > top;
2203
2274
  const sizeVisible = isEntirelyVisible ? size : Math.min(bottom, scrollSize) - Math.max(top, 0);
@@ -2424,13 +2495,10 @@ function setDidLayout(ctx) {
2424
2495
 
2425
2496
  // src/core/calculateItemsInView.ts
2426
2497
  function findCurrentStickyIndex(stickyArray, scroll, state) {
2427
- var _a3;
2428
- const idCache = state.idCache;
2429
2498
  const positions = state.positions;
2430
2499
  for (let i = stickyArray.length - 1; i >= 0; i--) {
2431
2500
  const stickyIndex = stickyArray[i];
2432
- const stickyId = (_a3 = idCache[stickyIndex]) != null ? _a3 : getId(state, stickyIndex);
2433
- const stickyPos = stickyId ? positions.get(stickyId) : void 0;
2501
+ const stickyPos = positions[stickyIndex];
2434
2502
  if (stickyPos !== void 0 && scroll >= stickyPos) {
2435
2503
  return i;
2436
2504
  }
@@ -2460,7 +2528,7 @@ function handleStickyActivation(ctx, stickyHeaderIndices, stickyArray, currentSt
2460
2528
  }
2461
2529
  }
2462
2530
  function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentStickyIdx, pendingRemoval, alwaysRenderIndicesSet) {
2463
- var _a3, _b, _c;
2531
+ var _a3, _b;
2464
2532
  const state = ctx.state;
2465
2533
  for (const containerIndex of state.stickyContainerPool) {
2466
2534
  const itemKey = peek$(ctx, `containerItemKey${containerIndex}`);
@@ -2478,14 +2546,13 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
2478
2546
  const nextIndex = stickyArray[arrayIdx + 1];
2479
2547
  let shouldRecycle = false;
2480
2548
  if (nextIndex) {
2481
- const nextId = (_a3 = state.idCache[nextIndex]) != null ? _a3 : getId(state, nextIndex);
2482
- const nextPos = nextId ? state.positions.get(nextId) : void 0;
2549
+ const nextPos = state.positions[nextIndex];
2483
2550
  shouldRecycle = nextPos !== void 0 && scroll > nextPos + drawDistance * 2;
2484
2551
  } else {
2485
- const currentId = (_b = state.idCache[itemIndex]) != null ? _b : getId(state, itemIndex);
2552
+ const currentId = (_a3 = state.idCache[itemIndex]) != null ? _a3 : getId(state, itemIndex);
2486
2553
  if (currentId) {
2487
- const currentPos = state.positions.get(currentId);
2488
- const currentSize = (_c = state.sizes.get(currentId)) != null ? _c : getItemSize(ctx, currentId, itemIndex, state.props.data[itemIndex]);
2554
+ const currentPos = state.positions[itemIndex];
2555
+ const currentSize = (_b = state.sizes.get(currentId)) != null ? _b : getItemSize(ctx, currentId, itemIndex, state.props.data[itemIndex]);
2489
2556
  shouldRecycle = currentPos !== void 0 && scroll > currentPos + currentSize + drawDistance * 3;
2490
2557
  }
2491
2558
  }
@@ -2497,7 +2564,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
2497
2564
  function calculateItemsInView(ctx, params = {}) {
2498
2565
  const state = ctx.state;
2499
2566
  reactNative.unstable_batchedUpdates(() => {
2500
- var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2567
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2501
2568
  const {
2502
2569
  columns,
2503
2570
  columnSpans,
@@ -2592,7 +2659,9 @@ function calculateItemsInView(ctx, params = {}) {
2592
2659
  if (dataChanged) {
2593
2660
  indexByKey.clear();
2594
2661
  idCache.length = 0;
2595
- positions.clear();
2662
+ positions.length = 0;
2663
+ columns.length = 0;
2664
+ columnSpans.length = 0;
2596
2665
  }
2597
2666
  const startIndex = forceFullItemPositions || dataChanged ? 0 : (_b = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _b : 0;
2598
2667
  updateItemPositions(ctx, dataChanged, {
@@ -2613,7 +2682,7 @@ function calculateItemsInView(ctx, params = {}) {
2613
2682
  let loopStart = !dataChanged && startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
2614
2683
  for (let i = loopStart; i >= 0; i--) {
2615
2684
  const id = (_c = idCache[i]) != null ? _c : getId(state, i);
2616
- const top = positions.get(id);
2685
+ const top = positions[i];
2617
2686
  const size = (_d = sizes.get(id)) != null ? _d : getItemSize(ctx, id, i, data[i]);
2618
2687
  const bottom = top + size;
2619
2688
  if (bottom > scroll - scrollBufferTop) {
@@ -2624,8 +2693,7 @@ function calculateItemsInView(ctx, params = {}) {
2624
2693
  }
2625
2694
  if (numColumns > 1) {
2626
2695
  while (loopStart > 0) {
2627
- const loopId = (_e = idCache[loopStart]) != null ? _e : getId(state, loopStart);
2628
- const loopColumn = columns.get(loopId);
2696
+ const loopColumn = columns[loopStart];
2629
2697
  if (loopColumn === 1 || loopColumn === void 0) {
2630
2698
  break;
2631
2699
  }
@@ -2646,9 +2714,9 @@ function calculateItemsInView(ctx, params = {}) {
2646
2714
  let firstFullyOnScreenIndex;
2647
2715
  const dataLength = data.length;
2648
2716
  for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
2649
- const id = (_f = idCache[i]) != null ? _f : getId(state, i);
2650
- const size = (_g = sizes.get(id)) != null ? _g : getItemSize(ctx, id, i, data[i]);
2651
- const top = positions.get(id);
2717
+ const id = (_e = idCache[i]) != null ? _e : getId(state, i);
2718
+ const size = (_f = sizes.get(id)) != null ? _f : getItemSize(ctx, id, i, data[i]);
2719
+ const top = positions[i];
2652
2720
  if (!foundEnd) {
2653
2721
  if (startNoBuffer === null && top + size > scroll) {
2654
2722
  startNoBuffer = i;
@@ -2684,7 +2752,7 @@ function calculateItemsInView(ctx, params = {}) {
2684
2752
  }
2685
2753
  const idsInView = [];
2686
2754
  for (let i = firstFullyOnScreenIndex; i <= endNoBuffer; i++) {
2687
- const id = (_h = idCache[i]) != null ? _h : getId(state, i);
2755
+ const id = (_g = idCache[i]) != null ? _g : getId(state, i);
2688
2756
  idsInView.push(id);
2689
2757
  }
2690
2758
  Object.assign(state, {
@@ -2716,7 +2784,7 @@ function calculateItemsInView(ctx, params = {}) {
2716
2784
  const needNewContainers = [];
2717
2785
  const needNewContainersSet = /* @__PURE__ */ new Set();
2718
2786
  for (let i = startBuffered; i <= endBuffered; i++) {
2719
- const id = (_i = idCache[i]) != null ? _i : getId(state, i);
2787
+ const id = (_h = idCache[i]) != null ? _h : getId(state, i);
2720
2788
  if (!containerItemKeys.has(id)) {
2721
2789
  needNewContainersSet.add(i);
2722
2790
  needNewContainers.push(i);
@@ -2725,7 +2793,7 @@ function calculateItemsInView(ctx, params = {}) {
2725
2793
  if (alwaysRenderArr.length > 0) {
2726
2794
  for (const index of alwaysRenderArr) {
2727
2795
  if (index < 0 || index >= dataLength) continue;
2728
- const id = (_j = idCache[index]) != null ? _j : getId(state, index);
2796
+ const id = (_i = idCache[index]) != null ? _i : getId(state, index);
2729
2797
  if (id && !containerItemKeys.has(id) && !needNewContainersSet.has(index)) {
2730
2798
  needNewContainersSet.add(index);
2731
2799
  needNewContainers.push(index);
@@ -2763,7 +2831,7 @@ function calculateItemsInView(ctx, params = {}) {
2763
2831
  for (let idx = 0; idx < needNewContainers.length; idx++) {
2764
2832
  const i = needNewContainers[idx];
2765
2833
  const containerIndex = availableContainers[idx];
2766
- const id = (_k = idCache[i]) != null ? _k : getId(state, i);
2834
+ const id = (_j = idCache[i]) != null ? _j : getId(state, i);
2767
2835
  const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
2768
2836
  if (oldKey && oldKey !== id) {
2769
2837
  containerItemKeys.delete(oldKey);
@@ -2804,7 +2872,7 @@ function calculateItemsInView(ctx, params = {}) {
2804
2872
  if (alwaysRenderArr.length > 0) {
2805
2873
  for (const index of alwaysRenderArr) {
2806
2874
  if (index < 0 || index >= dataLength) continue;
2807
- const id = (_l = idCache[index]) != null ? _l : getId(state, index);
2875
+ const id = (_k = idCache[index]) != null ? _k : getId(state, index);
2808
2876
  const containerIndex = containerItemKeys.get(id);
2809
2877
  if (containerIndex !== void 0) {
2810
2878
  state.stickyContainerPool.add(containerIndex);
@@ -2844,14 +2912,13 @@ function calculateItemsInView(ctx, params = {}) {
2844
2912
  const itemIndex = indexByKey.get(itemKey);
2845
2913
  const item = data[itemIndex];
2846
2914
  if (item !== void 0) {
2847
- const id = (_m = idCache[itemIndex]) != null ? _m : getId(state, itemIndex);
2848
- const positionValue = positions.get(id);
2915
+ const positionValue = positions[itemIndex];
2849
2916
  if (positionValue === void 0) {
2850
2917
  set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
2851
2918
  } else {
2852
2919
  const position = (positionValue || 0) - scrollAdjustPending;
2853
- const column = columns.get(id) || 1;
2854
- const span = columnSpans.get(id) || 1;
2920
+ const column = columns[itemIndex] || 1;
2921
+ const span = columnSpans[itemIndex] || 1;
2855
2922
  const prevPos = peek$(ctx, `containerPosition${i}`);
2856
2923
  const prevColumn = peek$(ctx, `containerColumn${i}`);
2857
2924
  const prevSpan = peek$(ctx, `containerSpan${i}`);
@@ -3438,6 +3505,18 @@ function createColumnWrapperStyle(contentContainerStyle) {
3438
3505
  // src/utils/createImperativeHandle.ts
3439
3506
  function createImperativeHandle(ctx) {
3440
3507
  const state = ctx.state;
3508
+ const runScrollWithPromise = (run) => new Promise((resolve) => {
3509
+ var _a3;
3510
+ (_a3 = state.pendingScrollResolve) == null ? void 0 : _a3.call(state);
3511
+ state.pendingScrollResolve = resolve;
3512
+ const didStartScroll = run();
3513
+ if (!didStartScroll || !state.scrollingTo) {
3514
+ if (state.pendingScrollResolve === resolve) {
3515
+ state.pendingScrollResolve = void 0;
3516
+ }
3517
+ resolve();
3518
+ }
3519
+ });
3441
3520
  const scrollIndexIntoView = (options) => {
3442
3521
  if (state) {
3443
3522
  const { index, ...rest } = options;
@@ -3449,8 +3528,10 @@ function createImperativeHandle(ctx) {
3449
3528
  index,
3450
3529
  viewPosition
3451
3530
  });
3531
+ return true;
3452
3532
  }
3453
3533
  }
3534
+ return false;
3454
3535
  };
3455
3536
  const refScroller = state.refScroller;
3456
3537
  const clearCaches = (options) => {
@@ -3469,9 +3550,9 @@ function createImperativeHandle(ctx) {
3469
3550
  if (mode === "full") {
3470
3551
  state.indexByKey.clear();
3471
3552
  state.idCache.length = 0;
3472
- state.positions.clear();
3473
- state.columns.clear();
3474
- state.columnSpans.clear();
3553
+ state.positions.length = 0;
3554
+ state.columns.length = 0;
3555
+ state.columnSpans.length = 0;
3475
3556
  }
3476
3557
  (_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
3477
3558
  };
@@ -3495,8 +3576,11 @@ function createImperativeHandle(ctx) {
3495
3576
  isAtStart: state.isAtStart,
3496
3577
  listen: (signalName, cb) => listen$(ctx, signalName, cb),
3497
3578
  listenToPosition: (key, cb) => listenPosition$(ctx, key, cb),
3498
- positionAtIndex: (index) => state.positions.get(getId(state, index)),
3499
- positions: state.positions,
3579
+ positionAtIndex: (index) => state.positions[index],
3580
+ positionByKey: (key) => {
3581
+ const index = state.indexByKey.get(key);
3582
+ return index === void 0 ? void 0 : state.positions[index];
3583
+ },
3500
3584
  scroll: state.scroll,
3501
3585
  scrollLength: state.scrollLength,
3502
3586
  scrollVelocity: getScrollVelocity(state),
@@ -3509,15 +3593,17 @@ function createImperativeHandle(ctx) {
3509
3593
  state.contentInsetOverride = inset != null ? inset : void 0;
3510
3594
  updateScroll(ctx, state.scroll, true);
3511
3595
  },
3512
- scrollIndexIntoView,
3513
- scrollItemIntoView: ({ item, ...props }) => {
3596
+ scrollIndexIntoView: (options) => runScrollWithPromise(() => scrollIndexIntoView(options)),
3597
+ scrollItemIntoView: ({ item, ...props }) => runScrollWithPromise(() => {
3514
3598
  const data = state.props.data;
3515
3599
  const index = data.indexOf(item);
3516
3600
  if (index !== -1) {
3517
3601
  scrollIndexIntoView({ index, ...props });
3602
+ return true;
3518
3603
  }
3519
- },
3520
- scrollToEnd: (options) => {
3604
+ return false;
3605
+ }),
3606
+ scrollToEnd: (options) => runScrollWithPromise(() => {
3521
3607
  const data = state.props.data;
3522
3608
  const stylePaddingBottom = state.props.stylePaddingBottom;
3523
3609
  const index = data.length - 1;
@@ -3530,17 +3616,27 @@ function createImperativeHandle(ctx) {
3530
3616
  viewOffset: -paddingBottom - footerSize + ((options == null ? void 0 : options.viewOffset) || 0),
3531
3617
  viewPosition: 1
3532
3618
  });
3619
+ return true;
3533
3620
  }
3534
- },
3535
- scrollToIndex: (params) => scrollToIndex(ctx, params),
3536
- scrollToItem: ({ item, ...props }) => {
3621
+ return false;
3622
+ }),
3623
+ scrollToIndex: (params) => runScrollWithPromise(() => {
3624
+ scrollToIndex(ctx, params);
3625
+ return true;
3626
+ }),
3627
+ scrollToItem: ({ item, ...props }) => runScrollWithPromise(() => {
3537
3628
  const data = state.props.data;
3538
3629
  const index = data.indexOf(item);
3539
3630
  if (index !== -1) {
3540
3631
  scrollToIndex(ctx, { index, ...props });
3632
+ return true;
3541
3633
  }
3542
- },
3543
- scrollToOffset: (params) => scrollTo(ctx, params),
3634
+ return false;
3635
+ }),
3636
+ scrollToOffset: (params) => runScrollWithPromise(() => {
3637
+ scrollTo(ctx, params);
3638
+ return true;
3639
+ }),
3544
3640
  setScrollProcessingEnabled: (enabled) => {
3545
3641
  state.scrollProcessingEnabled = enabled;
3546
3642
  },
@@ -3777,6 +3873,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3777
3873
  refreshControl,
3778
3874
  refreshing,
3779
3875
  refScrollView,
3876
+ renderScrollComponent,
3780
3877
  renderItem,
3781
3878
  scrollEventThrottle,
3782
3879
  snapToIndices,
@@ -3785,15 +3882,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3785
3882
  // TODOV3: Remove from v3 release
3786
3883
  style: styleProp,
3787
3884
  suggestEstimatedItemSize,
3885
+ useWindowScroll = false,
3788
3886
  viewabilityConfig,
3789
3887
  viewabilityConfigCallbackPairs,
3790
3888
  waitForInitialLayout = true,
3791
3889
  ...rest
3792
3890
  } = props;
3793
3891
  const animatedPropsInternal = props.animatedPropsInternal;
3892
+ const positionComponentInternal = props.positionComponentInternal;
3794
3893
  const stickyPositionComponentInternal = props.stickyPositionComponentInternal;
3795
3894
  const {
3796
3895
  childrenMode,
3896
+ positionComponentInternal: _positionComponentInternal,
3797
3897
  stickyPositionComponentInternal: _stickyPositionComponentInternal,
3798
3898
  ...restProps
3799
3899
  } = rest;
@@ -3848,6 +3948,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3848
3948
  "stickyIndices has been renamed to stickyHeaderIndices. Please update your props to use stickyHeaderIndices."
3849
3949
  );
3850
3950
  }
3951
+ if (IS_DEV && useWindowScroll && renderScrollComponent) {
3952
+ warnDevOnce(
3953
+ "useWindowScrollRenderScrollComponent",
3954
+ "useWindowScroll is not supported when renderScrollComponent is provided."
3955
+ );
3956
+ }
3957
+ const useWindowScrollResolved = Platform2.OS === "web" && !!useWindowScroll && !renderScrollComponent;
3851
3958
  const refState = React2.useRef();
3852
3959
  const hasOverrideItemLayout = !!overrideItemLayout;
3853
3960
  const prevHasOverrideItemLayout = React2.useRef(hasOverrideItemLayout);
@@ -3857,11 +3964,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3857
3964
  ctx.state = {
3858
3965
  activeStickyIndex: -1,
3859
3966
  averageSizes: {},
3860
- columnSpans: /* @__PURE__ */ new Map(),
3861
- columns: /* @__PURE__ */ new Map(),
3967
+ columnSpans: [],
3968
+ columns: [],
3862
3969
  containerItemKeys: /* @__PURE__ */ new Map(),
3863
3970
  containerItemTypes: /* @__PURE__ */ new Map(),
3864
3971
  contentInsetOverride: void 0,
3972
+ dataChangeEpoch: 0,
3865
3973
  dataChangeNeedsScrollUpdate: false,
3866
3974
  didColumnsChange: false,
3867
3975
  didDataChange: false,
@@ -3893,10 +4001,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3893
4001
  minIndexSizeChanged: 0,
3894
4002
  nativeContentInset: void 0,
3895
4003
  nativeMarginTop: 0,
3896
- positions: /* @__PURE__ */ new Map(),
4004
+ positions: [],
3897
4005
  props: {},
3898
4006
  queuedCalculateItemsInView: 0,
3899
- refScroller: void 0,
4007
+ refScroller: { current: null },
3900
4008
  scroll: 0,
3901
4009
  scrollAdjustHandler: new ScrollAdjustHandler(ctx),
3902
4010
  scrollForNextCalculateItemsInView: void 0,
@@ -3912,6 +4020,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3912
4020
  startBuffered: -1,
3913
4021
  startNoBuffer: -1,
3914
4022
  startReachedSnapshot: void 0,
4023
+ startReachedSnapshotDataChangeEpoch: void 0,
3915
4024
  stickyContainerPool: /* @__PURE__ */ new Set(),
3916
4025
  stickyContainers: /* @__PURE__ */ new Map(),
3917
4026
  timeoutSizeMessage: 0,
@@ -3931,6 +4040,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3931
4040
  state.didColumnsChange = numColumnsProp !== state.props.numColumns;
3932
4041
  const didDataChangeLocal = state.props.dataVersion !== dataVersion || state.props.data !== dataProp && checkActualChange(state, dataProp, state.props.data);
3933
4042
  if (didDataChangeLocal) {
4043
+ state.dataChangeEpoch += 1;
3934
4044
  state.dataChangeNeedsScrollUpdate = true;
3935
4045
  state.didDataChange = true;
3936
4046
  state.previousData = state.props.data;
@@ -3967,6 +4077,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3967
4077
  onStartReachedThreshold,
3968
4078
  onStickyHeaderChange,
3969
4079
  overrideItemLayout,
4080
+ positionComponentInternal,
3970
4081
  recycleItems: !!recycleItems,
3971
4082
  renderItem,
3972
4083
  snapToIndices,
@@ -3975,7 +4086,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3975
4086
  stickyPositionComponentInternal,
3976
4087
  stylePaddingBottom: stylePaddingBottomState,
3977
4088
  stylePaddingTop: stylePaddingTopState,
3978
- suggestEstimatedItemSize: !!suggestEstimatedItemSize
4089
+ suggestEstimatedItemSize: !!suggestEstimatedItemSize,
4090
+ useWindowScroll: useWindowScrollResolved
3979
4091
  };
3980
4092
  state.refScroller = refScroller;
3981
4093
  const memoizedLastItemKeys = React2.useMemo(() => {
@@ -4049,7 +4161,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
4049
4161
  "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."
4050
4162
  );
4051
4163
  refState.current.sizes.clear();
4052
- refState.current.positions.clear();
4164
+ refState.current.positions.length = 0;
4053
4165
  refState.current.totalSize = 0;
4054
4166
  set$(ctx, "totalSize", 0);
4055
4167
  }
@@ -4208,12 +4320,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
4208
4320
  }
4209
4321
  ),
4210
4322
  refScrollView: combinedRef,
4323
+ renderScrollComponent,
4211
4324
  scrollAdjustHandler: (_d = refState.current) == null ? void 0 : _d.scrollAdjustHandler,
4212
4325
  scrollEventThrottle: 0,
4213
4326
  snapToIndices,
4214
4327
  stickyHeaderIndices,
4215
4328
  style,
4216
4329
  updateItemSize: fns.updateItemSize,
4330
+ useWindowScroll: useWindowScrollResolved,
4217
4331
  waitForInitialLayout
4218
4332
  }
4219
4333
  ), IS_DEV && ENABLE_DEBUG_VIEW);