@legendapp/list 1.0.0-beta.41 → 1.0.0-beta.43

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.js CHANGED
@@ -28,7 +28,12 @@ var ContextState = React6__namespace.createContext(null);
28
28
  function StateProvider({ children }) {
29
29
  const [value] = React6__namespace.useState(() => ({
30
30
  listeners: /* @__PURE__ */ new Map(),
31
- values: /* @__PURE__ */ new Map(),
31
+ values: /* @__PURE__ */ new Map([
32
+ ["paddingTop", 0],
33
+ ["alignItemsPaddingTop", 0],
34
+ ["stylePaddingTop", 0],
35
+ ["headerSize", 0]
36
+ ]),
32
37
  mapViewabilityCallbacks: /* @__PURE__ */ new Map(),
33
38
  mapViewabilityValues: /* @__PURE__ */ new Map(),
34
39
  mapViewabilityAmountCallbacks: /* @__PURE__ */ new Map(),
@@ -837,7 +842,6 @@ var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
837
842
  return /* @__PURE__ */ React6__namespace.createElement(StateProvider, null, /* @__PURE__ */ React6__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
838
843
  });
839
844
  var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
840
- var _a, _b, _c, _d;
841
845
  const {
842
846
  data: dataProp = [],
843
847
  initialScrollIndex,
@@ -884,9 +888,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
884
888
  });
885
889
  callbacks.current.onStartReached = rest.onStartReached;
886
890
  callbacks.current.onEndReached = rest.onEndReached;
887
- const contentContainerStyle = reactNative.StyleSheet.flatten(contentContainerStyleProp);
888
- const style = reactNative.StyleSheet.flatten(styleProp);
889
- const stylePaddingTop = (_d = (_c = (_a = reactNative.StyleSheet.flatten(style)) == null ? void 0 : _a.paddingTop) != null ? _c : (_b = reactNative.StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _b.paddingTop) != null ? _d : 0;
891
+ const contentContainerStyle = { ...reactNative.StyleSheet.flatten(contentContainerStyleProp) };
892
+ const style = { ...reactNative.StyleSheet.flatten(styleProp) };
893
+ const stylePaddingTopState = ((style == null ? void 0 : style.paddingTop) || 0) + ((contentContainerStyle == null ? void 0 : contentContainerStyle.paddingTop) || 0);
890
894
  if (style == null ? void 0 : style.paddingTop) {
891
895
  style.paddingTop = void 0;
892
896
  }
@@ -901,8 +905,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
901
905
  const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (item, index) => index.toString();
902
906
  const refState = React6.useRef();
903
907
  const getId = (index) => {
904
- var _a2;
905
- const data = (_a2 = refState.current) == null ? void 0 : _a2.data;
908
+ var _a;
909
+ const data = (_a = refState.current) == null ? void 0 : _a.data;
906
910
  if (!data) {
907
911
  return "";
908
912
  }
@@ -910,17 +914,17 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
910
914
  return `${ret}`;
911
915
  };
912
916
  const getItemSize = (key, index, data) => {
913
- var _a2;
917
+ var _a;
914
918
  const sizeKnown = refState.current.sizes.get(key);
915
919
  if (sizeKnown !== void 0) {
916
920
  return sizeKnown;
917
921
  }
918
- const size = (_a2 = getEstimatedItemSize ? getEstimatedItemSize(index, data) : estimatedItemSize) != null ? _a2 : DEFAULT_ITEM_SIZE;
922
+ const size = (_a = getEstimatedItemSize ? getEstimatedItemSize(index, data) : estimatedItemSize) != null ? _a : DEFAULT_ITEM_SIZE;
919
923
  refState.current.sizes.set(key, size);
920
924
  return size;
921
925
  };
922
926
  const calculateOffsetForIndex = (index = initialScrollIndex) => {
923
- var _a2;
927
+ var _a;
924
928
  const data = dataProp;
925
929
  if (index !== void 0) {
926
930
  let offset = 0;
@@ -938,7 +942,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
938
942
  } else if (estimatedItemSize) {
939
943
  offset = index * estimatedItemSize;
940
944
  }
941
- return offset / numColumnsProp - (((_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.getAppliedAdjust()) || 0);
945
+ return offset / numColumnsProp - (((_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.getAppliedAdjust()) || 0);
942
946
  }
943
947
  return 0;
944
948
  };
@@ -1021,18 +1025,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1021
1025
  return void 0;
1022
1026
  };
1023
1027
  const setDidLayout = () => {
1024
- var _a2;
1028
+ var _a;
1025
1029
  refState.current.queuedInitialLayout = true;
1026
1030
  checkAtBottom();
1027
1031
  if (initialScrollIndex) {
1028
1032
  const updatedOffset = calculateOffsetForIndex(initialScrollIndex);
1029
- (_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(true);
1033
+ (_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
1030
1034
  queueMicrotask(() => {
1031
1035
  scrollTo(updatedOffset, false);
1032
1036
  requestAnimationFrame(() => {
1033
- var _a3;
1037
+ var _a2;
1034
1038
  set$(ctx, "containersDidLayout", true);
1035
- (_a3 = refState.current) == null ? void 0 : _a3.scrollAdjustHandler.setDisableAdjust(false);
1039
+ (_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(false);
1036
1040
  });
1037
1041
  });
1038
1042
  } else {
@@ -1077,7 +1081,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1077
1081
  set$(ctx, "totalSize", state.totalSize);
1078
1082
  set$(ctx, "totalSizeWithScrollAdjust", resultSize);
1079
1083
  if (alignItemsAtEnd) {
1080
- doUpdatePaddingTop();
1084
+ updateAlignItemsPaddingTop();
1081
1085
  }
1082
1086
  }, []);
1083
1087
  const getRowHeight = (n) => {
@@ -1105,13 +1109,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1105
1109
  if (!state.anchorElement) {
1106
1110
  return /* @__PURE__ */ new Map();
1107
1111
  }
1108
- let top = state.anchorElement.coordinate;
1109
1112
  const anchorIndex = state.indexByKey.get(state.anchorElement.id);
1110
1113
  if (anchorIndex === 0) {
1111
1114
  return /* @__PURE__ */ new Map();
1112
1115
  }
1113
1116
  const map = state.belowAnchorElementPositions || /* @__PURE__ */ new Map();
1114
1117
  const numColumns = peek$(ctx, "numColumns");
1118
+ let top = state.anchorElement.coordinate;
1115
1119
  for (let i = anchorIndex - 1; i >= 0; i--) {
1116
1120
  const id = getId(i);
1117
1121
  const rowNumber = Math.floor(i / numColumns);
@@ -1123,20 +1127,20 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1123
1127
  return map;
1124
1128
  };
1125
1129
  const getElementPositionBelowAchor = (id) => {
1126
- var _a2;
1130
+ var _a;
1127
1131
  const state = refState.current;
1128
1132
  if (!refState.current.belowAnchorElementPositions) {
1129
1133
  state.belowAnchorElementPositions = buildElementPositionsBelowAnchor();
1130
1134
  }
1131
1135
  const res = state.belowAnchorElementPositions.get(id);
1132
1136
  if (res === void 0) {
1133
- console.warn(`Undefined position below achor ${id} ${(_a2 = state.anchorElement) == null ? void 0 : _a2.id}`);
1137
+ console.warn(`Undefined position below anchor ${id} ${(_a = state.anchorElement) == null ? void 0 : _a.id}`);
1134
1138
  return 0;
1135
1139
  }
1136
1140
  return res;
1137
1141
  };
1138
1142
  const calculateItemsInView = React6.useCallback(() => {
1139
- var _a2;
1143
+ var _a;
1140
1144
  const state = refState.current;
1141
1145
  const {
1142
1146
  data,
@@ -1151,7 +1155,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1151
1155
  return;
1152
1156
  }
1153
1157
  const totalSize = peek$(ctx, "totalSizeWithScrollAdjust");
1154
- const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
1158
+ const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
1155
1159
  const numColumns = peek$(ctx, "numColumns");
1156
1160
  const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
1157
1161
  const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
@@ -1224,22 +1228,22 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1224
1228
  let column = 1;
1225
1229
  let maxSizeInRow = 0;
1226
1230
  const getInitialTop = (i) => {
1227
- var _a3;
1231
+ var _a2;
1228
1232
  const id = getId(i);
1229
1233
  let topOffset = 0;
1230
1234
  if (positions.get(id)) {
1231
1235
  topOffset = positions.get(id);
1232
1236
  }
1233
- if (id === ((_a3 = state.anchorElement) == null ? void 0 : _a3.id)) {
1237
+ if (id === ((_a2 = state.anchorElement) == null ? void 0 : _a2.id)) {
1234
1238
  topOffset = state.anchorElement.coordinate;
1235
1239
  }
1236
1240
  return topOffset;
1237
1241
  };
1238
- for (let i = loopStart; i < data.length; i++) {
1242
+ for (let i = Math.max(0, loopStart); i < data.length; i++) {
1239
1243
  const id = getId(i);
1240
1244
  const size = getItemSize(id, i, data[i]);
1241
1245
  maxSizeInRow = Math.max(maxSizeInRow, size);
1242
- if (top === void 0 || id === ((_a2 = state.anchorElement) == null ? void 0 : _a2.id)) {
1246
+ if (top === void 0 || id === ((_a = state.anchorElement) == null ? void 0 : _a.id)) {
1243
1247
  top = getInitialTop(i);
1244
1248
  }
1245
1249
  if (positions.get(id) !== top) {
@@ -1420,17 +1424,33 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1420
1424
  );
1421
1425
  }
1422
1426
  }, []);
1423
- const doUpdatePaddingTop = () => {
1427
+ const setPaddingTop = ({
1428
+ stylePaddingTop,
1429
+ alignItemsPaddingTop
1430
+ }) => {
1431
+ if (stylePaddingTop !== void 0) {
1432
+ set$(ctx, "stylePaddingTop", stylePaddingTop);
1433
+ }
1434
+ if (alignItemsPaddingTop !== void 0) {
1435
+ set$(ctx, "alignItemsPaddingTop", alignItemsPaddingTop);
1436
+ }
1437
+ set$(
1438
+ ctx,
1439
+ "paddingTop",
1440
+ (stylePaddingTop != null ? stylePaddingTop : peek$(ctx, "stylePaddingTop")) + (alignItemsPaddingTop != null ? alignItemsPaddingTop : peek$(ctx, "alignItemsPaddingTop"))
1441
+ );
1442
+ };
1443
+ const updateAlignItemsPaddingTop = () => {
1424
1444
  if (alignItemsAtEnd) {
1425
1445
  const { scrollLength } = refState.current;
1426
1446
  const contentSize = getContentSize(ctx);
1427
1447
  const paddingTop = Math.max(0, Math.floor(scrollLength - contentSize));
1428
- set$(ctx, "paddingTop", paddingTop);
1448
+ setPaddingTop({ alignItemsPaddingTop: paddingTop });
1429
1449
  }
1430
1450
  };
1431
1451
  const scrollTo = (offset, animated) => {
1432
- var _a2;
1433
- (_a2 = refScroller.current) == null ? void 0 : _a2.scrollTo({
1452
+ var _a;
1453
+ (_a = refScroller.current) == null ? void 0 : _a.scrollTo({
1434
1454
  x: horizontal ? offset : 0,
1435
1455
  y: horizontal ? 0 : offset,
1436
1456
  animated: !!animated
@@ -1439,13 +1459,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1439
1459
  const doMaintainScrollAtEnd = (animated) => {
1440
1460
  const state = refState.current;
1441
1461
  if ((state == null ? void 0 : state.isAtBottom) && maintainScrollAtEnd && peek$(ctx, "containersDidLayout")) {
1442
- const paddingTop = peek$(ctx, "paddingTop") || 0;
1462
+ const paddingTop = peek$(ctx, "alignItemsPaddingTop");
1443
1463
  if (paddingTop > 0) {
1444
1464
  state.scroll = 0;
1445
1465
  }
1446
1466
  requestAnimationFrame(() => {
1447
- var _a2;
1448
- (_a2 = refScroller.current) == null ? void 0 : _a2.scrollToEnd({
1467
+ var _a;
1468
+ (_a = refScroller.current) == null ? void 0 : _a.scrollToEnd({
1449
1469
  animated
1450
1470
  });
1451
1471
  });
@@ -1489,8 +1509,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1489
1509
  refState.current.isEndReached,
1490
1510
  refState.current.endReachedBlockedByTimer,
1491
1511
  (distance) => {
1492
- var _a2, _b2;
1493
- return (_b2 = (_a2 = callbacks.current).onEndReached) == null ? void 0 : _b2.call(_a2, { distanceFromEnd: distance });
1512
+ var _a, _b;
1513
+ return (_b = (_a = callbacks.current).onEndReached) == null ? void 0 : _b.call(_a, { distanceFromEnd: distance });
1494
1514
  },
1495
1515
  (block) => {
1496
1516
  refState.current.endReachedBlockedByTimer = block;
@@ -1513,8 +1533,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1513
1533
  refState.current.isStartReached,
1514
1534
  refState.current.startReachedBlockedByTimer,
1515
1535
  (distance) => {
1516
- var _a2, _b2;
1517
- return (_b2 = (_a2 = callbacks.current).onStartReached) == null ? void 0 : _b2.call(_a2, { distanceFromStart: distance });
1536
+ var _a, _b;
1537
+ return (_b = (_a = callbacks.current).onStartReached) == null ? void 0 : _b.call(_a, { distanceFromStart: distance });
1518
1538
  },
1519
1539
  (block) => {
1520
1540
  refState.current.startReachedBlockedByTimer = block;
@@ -1551,14 +1571,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1551
1571
  }
1552
1572
  };
1553
1573
  const calcTotalSizesAndPositions = ({ forgetPositions = false }) => {
1554
- var _a2, _b2;
1574
+ var _a, _b;
1555
1575
  let totalSize = 0;
1556
1576
  let totalSizeBelowIndex = 0;
1557
1577
  const indexByKey = /* @__PURE__ */ new Map();
1558
1578
  const newPositions = /* @__PURE__ */ new Map();
1559
1579
  let column = 1;
1560
1580
  let maxSizeInRow = 0;
1561
- const numColumns = (_a2 = peek$(ctx, "numColumns")) != null ? _a2 : numColumnsProp;
1581
+ const numColumns = (_a = peek$(ctx, "numColumns")) != null ? _a : numColumnsProp;
1562
1582
  if (!refState.current) {
1563
1583
  return;
1564
1584
  }
@@ -1587,7 +1607,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1587
1607
  id: getId(0)
1588
1608
  };
1589
1609
  refState.current.anchorElement = newAnchorElement;
1590
- (_b2 = refState.current.belowAnchorElementPositions) == null ? void 0 : _b2.clear();
1610
+ (_b = refState.current.belowAnchorElementPositions) == null ? void 0 : _b.clear();
1591
1611
  scrollTo(0, false);
1592
1612
  setTimeout(() => {
1593
1613
  calculateItemsInView();
@@ -1646,20 +1666,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1646
1666
  const initalizeStateVars = () => {
1647
1667
  set$(ctx, "lastItemKeys", memoizedLastItemKeys);
1648
1668
  set$(ctx, "numColumns", numColumnsProp);
1649
- if (maintainVisibleContentPosition) {
1650
- const prevPaddingTop = peek$(ctx, "stylePaddingTop");
1651
- set$(ctx, "stylePaddingTop", stylePaddingTop);
1652
- if (prevPaddingTop !== void 0) {
1653
- const paddingDiff = stylePaddingTop - prevPaddingTop;
1654
- if (paddingDiff) {
1655
- set$(ctx, "paddingTop", peek$(ctx, "paddingTop") + paddingDiff);
1656
- if (reactNative.Platform.OS === "ios") {
1657
- queueMicrotask(() => {
1658
- scrollTo(refState.current.scroll + paddingDiff, false);
1659
- });
1660
- }
1661
- }
1662
- }
1669
+ const prevPaddingTop = peek$(ctx, "stylePaddingTop");
1670
+ setPaddingTop({ stylePaddingTop: stylePaddingTopState });
1671
+ const paddingDiff = stylePaddingTopState - prevPaddingTop;
1672
+ if (paddingDiff && prevPaddingTop !== void 0 && reactNative.Platform.OS === "ios") {
1673
+ queueMicrotask(() => {
1674
+ scrollTo(refState.current.scroll + paddingDiff, false);
1675
+ });
1663
1676
  }
1664
1677
  };
1665
1678
  if (isFirst) {
@@ -1686,9 +1699,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1686
1699
  set$(ctx, "extraData", extraData);
1687
1700
  }, [extraData]);
1688
1701
  refState.current.renderItem = renderItem;
1689
- React6.useEffect(initalizeStateVars, [memoizedLastItemKeys.join(","), numColumnsProp, stylePaddingTop]);
1702
+ React6.useEffect(initalizeStateVars, [memoizedLastItemKeys.join(","), numColumnsProp, stylePaddingTopState]);
1690
1703
  const getRenderedItem = React6.useCallback((key) => {
1691
- var _a2, _b2;
1704
+ var _a, _b;
1692
1705
  const state = refState.current;
1693
1706
  if (!state) {
1694
1707
  return null;
@@ -1718,7 +1731,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1718
1731
  `[legend-list] useRecyclingState has been moved from a render prop to a regular import: import { useRecyclingState } from "@legendapp/list";`
1719
1732
  );
1720
1733
  } : void 0;
1721
- const renderedItem = (_b2 = (_a2 = refState.current).renderItem) == null ? void 0 : _b2.call(_a2, {
1734
+ const renderedItem = (_b = (_a = refState.current).renderItem) == null ? void 0 : _b.call(_a, {
1722
1735
  item: data[index],
1723
1736
  index,
1724
1737
  extraData: peek$(ctx, "extraData"),
@@ -1731,11 +1744,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1731
1744
  return { index, item: data[index], renderedItem };
1732
1745
  }, []);
1733
1746
  const doInitialAllocateContainers = () => {
1734
- var _a2;
1747
+ var _a;
1735
1748
  const state = refState.current;
1736
1749
  const { scrollLength, data } = state;
1737
1750
  if (scrollLength > 0 && data.length > 0 && !peek$(ctx, "numContainers")) {
1738
- const averageItemSize = (_a2 = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0])) != null ? _a2 : DEFAULT_ITEM_SIZE;
1751
+ const averageItemSize = (_a = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0])) != null ? _a : DEFAULT_ITEM_SIZE;
1739
1752
  const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize) * numColumnsProp;
1740
1753
  for (let i = 0; i < numContainers; i++) {
1741
1754
  set$(ctx, `containerPosition${i}`, ANCHORED_POSITION_OUT_OF_VIEW);
@@ -1855,7 +1868,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1855
1868
  state.scrollForNextCalculateItemsInView = void 0;
1856
1869
  doInitialAllocateContainers();
1857
1870
  doMaintainScrollAtEnd(false);
1858
- doUpdatePaddingTop();
1871
+ updateAlignItemsPaddingTop();
1859
1872
  checkAtBottom();
1860
1873
  checkAtTop();
1861
1874
  if (didChange) {
@@ -1876,8 +1889,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1876
1889
  }, []);
1877
1890
  const handleScroll = React6.useCallback(
1878
1891
  (event, fromSelf) => {
1879
- var _a2, _b2, _c2, _d2;
1880
- if (((_b2 = (_a2 = event.nativeEvent) == null ? void 0 : _a2.contentSize) == null ? void 0 : _b2.height) === 0 && ((_c2 = event.nativeEvent.contentSize) == null ? void 0 : _c2.width) === 0) {
1892
+ var _a, _b, _c, _d;
1893
+ if (((_b = (_a = event.nativeEvent) == null ? void 0 : _a.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
1881
1894
  return;
1882
1895
  }
1883
1896
  const state = refState.current;
@@ -1917,7 +1930,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1917
1930
  checkAtBottom();
1918
1931
  checkAtTop();
1919
1932
  if (!fromSelf) {
1920
- (_d2 = state.onScroll) == null ? void 0 : _d2.call(state, event);
1933
+ (_d = state.onScroll) == null ? void 0 : _d.call(state, event);
1921
1934
  }
1922
1935
  },
1923
1936
  []
@@ -1931,7 +1944,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1931
1944
  animated = true,
1932
1945
  viewPosition = 0
1933
1946
  }) => {
1934
- var _a2;
1947
+ var _a;
1935
1948
  const state = refState.current;
1936
1949
  const firstIndexOffset = calculateOffsetForIndex(index);
1937
1950
  let firstIndexScrollPostion = firstIndexOffset - viewOffset;
@@ -1941,7 +1954,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1941
1954
  if (needsReanchoring) {
1942
1955
  const id = getId(index);
1943
1956
  state.anchorElement = { id, coordinate: firstIndexOffset };
1944
- (_a2 = state.belowAnchorElementPositions) == null ? void 0 : _a2.clear();
1957
+ (_a = state.belowAnchorElementPositions) == null ? void 0 : _a.clear();
1945
1958
  state.positions.clear();
1946
1959
  calcTotalSizesAndPositions({ forgetPositions: true });
1947
1960
  state.startBufferedId = id;
@@ -2014,13 +2027,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2014
2027
  );
2015
2028
  if (reactNative.Platform.OS === "web") {
2016
2029
  React6.useEffect(() => {
2017
- var _a2;
2030
+ var _a;
2018
2031
  if (initialContentOffset) {
2019
- (_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(true);
2032
+ (_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
2020
2033
  scrollTo(initialContentOffset, false);
2021
2034
  setTimeout(() => {
2022
- var _a3;
2023
- (_a3 = refState.current) == null ? void 0 : _a3.scrollAdjustHandler.setDisableAdjust(false);
2035
+ var _a2;
2036
+ (_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(false);
2024
2037
  }, 0);
2025
2038
  }
2026
2039
  }, []);
@@ -2036,8 +2049,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2036
2049
  updateItemSize,
2037
2050
  handleScroll,
2038
2051
  onMomentumScrollEnd: (event) => {
2039
- var _a2;
2040
- const scrollingToOffset = (_a2 = refState.current) == null ? void 0 : _a2.scrollingToOffset;
2052
+ var _a;
2053
+ const scrollingToOffset = (_a = refState.current) == null ? void 0 : _a.scrollingToOffset;
2041
2054
  if (scrollingToOffset !== void 0) {
2042
2055
  requestAnimationFrame(() => {
2043
2056
  scrollTo(scrollingToOffset, false);
package/index.mjs CHANGED
@@ -7,7 +7,12 @@ var ContextState = React6.createContext(null);
7
7
  function StateProvider({ children }) {
8
8
  const [value] = React6.useState(() => ({
9
9
  listeners: /* @__PURE__ */ new Map(),
10
- values: /* @__PURE__ */ new Map(),
10
+ values: /* @__PURE__ */ new Map([
11
+ ["paddingTop", 0],
12
+ ["alignItemsPaddingTop", 0],
13
+ ["stylePaddingTop", 0],
14
+ ["headerSize", 0]
15
+ ]),
11
16
  mapViewabilityCallbacks: /* @__PURE__ */ new Map(),
12
17
  mapViewabilityValues: /* @__PURE__ */ new Map(),
13
18
  mapViewabilityAmountCallbacks: /* @__PURE__ */ new Map(),
@@ -816,7 +821,6 @@ var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
816
821
  return /* @__PURE__ */ React6.createElement(StateProvider, null, /* @__PURE__ */ React6.createElement(LegendListInner, { ...props, ref: forwardedRef }));
817
822
  });
818
823
  var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
819
- var _a, _b, _c, _d;
820
824
  const {
821
825
  data: dataProp = [],
822
826
  initialScrollIndex,
@@ -863,9 +867,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
863
867
  });
864
868
  callbacks.current.onStartReached = rest.onStartReached;
865
869
  callbacks.current.onEndReached = rest.onEndReached;
866
- const contentContainerStyle = StyleSheet.flatten(contentContainerStyleProp);
867
- const style = StyleSheet.flatten(styleProp);
868
- const stylePaddingTop = (_d = (_c = (_a = StyleSheet.flatten(style)) == null ? void 0 : _a.paddingTop) != null ? _c : (_b = StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _b.paddingTop) != null ? _d : 0;
870
+ const contentContainerStyle = { ...StyleSheet.flatten(contentContainerStyleProp) };
871
+ const style = { ...StyleSheet.flatten(styleProp) };
872
+ const stylePaddingTopState = ((style == null ? void 0 : style.paddingTop) || 0) + ((contentContainerStyle == null ? void 0 : contentContainerStyle.paddingTop) || 0);
869
873
  if (style == null ? void 0 : style.paddingTop) {
870
874
  style.paddingTop = void 0;
871
875
  }
@@ -880,8 +884,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
880
884
  const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (item, index) => index.toString();
881
885
  const refState = useRef();
882
886
  const getId = (index) => {
883
- var _a2;
884
- const data = (_a2 = refState.current) == null ? void 0 : _a2.data;
887
+ var _a;
888
+ const data = (_a = refState.current) == null ? void 0 : _a.data;
885
889
  if (!data) {
886
890
  return "";
887
891
  }
@@ -889,17 +893,17 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
889
893
  return `${ret}`;
890
894
  };
891
895
  const getItemSize = (key, index, data) => {
892
- var _a2;
896
+ var _a;
893
897
  const sizeKnown = refState.current.sizes.get(key);
894
898
  if (sizeKnown !== void 0) {
895
899
  return sizeKnown;
896
900
  }
897
- const size = (_a2 = getEstimatedItemSize ? getEstimatedItemSize(index, data) : estimatedItemSize) != null ? _a2 : DEFAULT_ITEM_SIZE;
901
+ const size = (_a = getEstimatedItemSize ? getEstimatedItemSize(index, data) : estimatedItemSize) != null ? _a : DEFAULT_ITEM_SIZE;
898
902
  refState.current.sizes.set(key, size);
899
903
  return size;
900
904
  };
901
905
  const calculateOffsetForIndex = (index = initialScrollIndex) => {
902
- var _a2;
906
+ var _a;
903
907
  const data = dataProp;
904
908
  if (index !== void 0) {
905
909
  let offset = 0;
@@ -917,7 +921,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
917
921
  } else if (estimatedItemSize) {
918
922
  offset = index * estimatedItemSize;
919
923
  }
920
- return offset / numColumnsProp - (((_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.getAppliedAdjust()) || 0);
924
+ return offset / numColumnsProp - (((_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.getAppliedAdjust()) || 0);
921
925
  }
922
926
  return 0;
923
927
  };
@@ -1000,18 +1004,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1000
1004
  return void 0;
1001
1005
  };
1002
1006
  const setDidLayout = () => {
1003
- var _a2;
1007
+ var _a;
1004
1008
  refState.current.queuedInitialLayout = true;
1005
1009
  checkAtBottom();
1006
1010
  if (initialScrollIndex) {
1007
1011
  const updatedOffset = calculateOffsetForIndex(initialScrollIndex);
1008
- (_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(true);
1012
+ (_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
1009
1013
  queueMicrotask(() => {
1010
1014
  scrollTo(updatedOffset, false);
1011
1015
  requestAnimationFrame(() => {
1012
- var _a3;
1016
+ var _a2;
1013
1017
  set$(ctx, "containersDidLayout", true);
1014
- (_a3 = refState.current) == null ? void 0 : _a3.scrollAdjustHandler.setDisableAdjust(false);
1018
+ (_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(false);
1015
1019
  });
1016
1020
  });
1017
1021
  } else {
@@ -1056,7 +1060,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1056
1060
  set$(ctx, "totalSize", state.totalSize);
1057
1061
  set$(ctx, "totalSizeWithScrollAdjust", resultSize);
1058
1062
  if (alignItemsAtEnd) {
1059
- doUpdatePaddingTop();
1063
+ updateAlignItemsPaddingTop();
1060
1064
  }
1061
1065
  }, []);
1062
1066
  const getRowHeight = (n) => {
@@ -1084,13 +1088,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1084
1088
  if (!state.anchorElement) {
1085
1089
  return /* @__PURE__ */ new Map();
1086
1090
  }
1087
- let top = state.anchorElement.coordinate;
1088
1091
  const anchorIndex = state.indexByKey.get(state.anchorElement.id);
1089
1092
  if (anchorIndex === 0) {
1090
1093
  return /* @__PURE__ */ new Map();
1091
1094
  }
1092
1095
  const map = state.belowAnchorElementPositions || /* @__PURE__ */ new Map();
1093
1096
  const numColumns = peek$(ctx, "numColumns");
1097
+ let top = state.anchorElement.coordinate;
1094
1098
  for (let i = anchorIndex - 1; i >= 0; i--) {
1095
1099
  const id = getId(i);
1096
1100
  const rowNumber = Math.floor(i / numColumns);
@@ -1102,20 +1106,20 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1102
1106
  return map;
1103
1107
  };
1104
1108
  const getElementPositionBelowAchor = (id) => {
1105
- var _a2;
1109
+ var _a;
1106
1110
  const state = refState.current;
1107
1111
  if (!refState.current.belowAnchorElementPositions) {
1108
1112
  state.belowAnchorElementPositions = buildElementPositionsBelowAnchor();
1109
1113
  }
1110
1114
  const res = state.belowAnchorElementPositions.get(id);
1111
1115
  if (res === void 0) {
1112
- console.warn(`Undefined position below achor ${id} ${(_a2 = state.anchorElement) == null ? void 0 : _a2.id}`);
1116
+ console.warn(`Undefined position below anchor ${id} ${(_a = state.anchorElement) == null ? void 0 : _a.id}`);
1113
1117
  return 0;
1114
1118
  }
1115
1119
  return res;
1116
1120
  };
1117
1121
  const calculateItemsInView = useCallback(() => {
1118
- var _a2;
1122
+ var _a;
1119
1123
  const state = refState.current;
1120
1124
  const {
1121
1125
  data,
@@ -1130,7 +1134,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1130
1134
  return;
1131
1135
  }
1132
1136
  const totalSize = peek$(ctx, "totalSizeWithScrollAdjust");
1133
- const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
1137
+ const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
1134
1138
  const numColumns = peek$(ctx, "numColumns");
1135
1139
  const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
1136
1140
  const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
@@ -1203,22 +1207,22 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1203
1207
  let column = 1;
1204
1208
  let maxSizeInRow = 0;
1205
1209
  const getInitialTop = (i) => {
1206
- var _a3;
1210
+ var _a2;
1207
1211
  const id = getId(i);
1208
1212
  let topOffset = 0;
1209
1213
  if (positions.get(id)) {
1210
1214
  topOffset = positions.get(id);
1211
1215
  }
1212
- if (id === ((_a3 = state.anchorElement) == null ? void 0 : _a3.id)) {
1216
+ if (id === ((_a2 = state.anchorElement) == null ? void 0 : _a2.id)) {
1213
1217
  topOffset = state.anchorElement.coordinate;
1214
1218
  }
1215
1219
  return topOffset;
1216
1220
  };
1217
- for (let i = loopStart; i < data.length; i++) {
1221
+ for (let i = Math.max(0, loopStart); i < data.length; i++) {
1218
1222
  const id = getId(i);
1219
1223
  const size = getItemSize(id, i, data[i]);
1220
1224
  maxSizeInRow = Math.max(maxSizeInRow, size);
1221
- if (top === void 0 || id === ((_a2 = state.anchorElement) == null ? void 0 : _a2.id)) {
1225
+ if (top === void 0 || id === ((_a = state.anchorElement) == null ? void 0 : _a.id)) {
1222
1226
  top = getInitialTop(i);
1223
1227
  }
1224
1228
  if (positions.get(id) !== top) {
@@ -1399,17 +1403,33 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1399
1403
  );
1400
1404
  }
1401
1405
  }, []);
1402
- const doUpdatePaddingTop = () => {
1406
+ const setPaddingTop = ({
1407
+ stylePaddingTop,
1408
+ alignItemsPaddingTop
1409
+ }) => {
1410
+ if (stylePaddingTop !== void 0) {
1411
+ set$(ctx, "stylePaddingTop", stylePaddingTop);
1412
+ }
1413
+ if (alignItemsPaddingTop !== void 0) {
1414
+ set$(ctx, "alignItemsPaddingTop", alignItemsPaddingTop);
1415
+ }
1416
+ set$(
1417
+ ctx,
1418
+ "paddingTop",
1419
+ (stylePaddingTop != null ? stylePaddingTop : peek$(ctx, "stylePaddingTop")) + (alignItemsPaddingTop != null ? alignItemsPaddingTop : peek$(ctx, "alignItemsPaddingTop"))
1420
+ );
1421
+ };
1422
+ const updateAlignItemsPaddingTop = () => {
1403
1423
  if (alignItemsAtEnd) {
1404
1424
  const { scrollLength } = refState.current;
1405
1425
  const contentSize = getContentSize(ctx);
1406
1426
  const paddingTop = Math.max(0, Math.floor(scrollLength - contentSize));
1407
- set$(ctx, "paddingTop", paddingTop);
1427
+ setPaddingTop({ alignItemsPaddingTop: paddingTop });
1408
1428
  }
1409
1429
  };
1410
1430
  const scrollTo = (offset, animated) => {
1411
- var _a2;
1412
- (_a2 = refScroller.current) == null ? void 0 : _a2.scrollTo({
1431
+ var _a;
1432
+ (_a = refScroller.current) == null ? void 0 : _a.scrollTo({
1413
1433
  x: horizontal ? offset : 0,
1414
1434
  y: horizontal ? 0 : offset,
1415
1435
  animated: !!animated
@@ -1418,13 +1438,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1418
1438
  const doMaintainScrollAtEnd = (animated) => {
1419
1439
  const state = refState.current;
1420
1440
  if ((state == null ? void 0 : state.isAtBottom) && maintainScrollAtEnd && peek$(ctx, "containersDidLayout")) {
1421
- const paddingTop = peek$(ctx, "paddingTop") || 0;
1441
+ const paddingTop = peek$(ctx, "alignItemsPaddingTop");
1422
1442
  if (paddingTop > 0) {
1423
1443
  state.scroll = 0;
1424
1444
  }
1425
1445
  requestAnimationFrame(() => {
1426
- var _a2;
1427
- (_a2 = refScroller.current) == null ? void 0 : _a2.scrollToEnd({
1446
+ var _a;
1447
+ (_a = refScroller.current) == null ? void 0 : _a.scrollToEnd({
1428
1448
  animated
1429
1449
  });
1430
1450
  });
@@ -1468,8 +1488,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1468
1488
  refState.current.isEndReached,
1469
1489
  refState.current.endReachedBlockedByTimer,
1470
1490
  (distance) => {
1471
- var _a2, _b2;
1472
- return (_b2 = (_a2 = callbacks.current).onEndReached) == null ? void 0 : _b2.call(_a2, { distanceFromEnd: distance });
1491
+ var _a, _b;
1492
+ return (_b = (_a = callbacks.current).onEndReached) == null ? void 0 : _b.call(_a, { distanceFromEnd: distance });
1473
1493
  },
1474
1494
  (block) => {
1475
1495
  refState.current.endReachedBlockedByTimer = block;
@@ -1492,8 +1512,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1492
1512
  refState.current.isStartReached,
1493
1513
  refState.current.startReachedBlockedByTimer,
1494
1514
  (distance) => {
1495
- var _a2, _b2;
1496
- return (_b2 = (_a2 = callbacks.current).onStartReached) == null ? void 0 : _b2.call(_a2, { distanceFromStart: distance });
1515
+ var _a, _b;
1516
+ return (_b = (_a = callbacks.current).onStartReached) == null ? void 0 : _b.call(_a, { distanceFromStart: distance });
1497
1517
  },
1498
1518
  (block) => {
1499
1519
  refState.current.startReachedBlockedByTimer = block;
@@ -1530,14 +1550,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1530
1550
  }
1531
1551
  };
1532
1552
  const calcTotalSizesAndPositions = ({ forgetPositions = false }) => {
1533
- var _a2, _b2;
1553
+ var _a, _b;
1534
1554
  let totalSize = 0;
1535
1555
  let totalSizeBelowIndex = 0;
1536
1556
  const indexByKey = /* @__PURE__ */ new Map();
1537
1557
  const newPositions = /* @__PURE__ */ new Map();
1538
1558
  let column = 1;
1539
1559
  let maxSizeInRow = 0;
1540
- const numColumns = (_a2 = peek$(ctx, "numColumns")) != null ? _a2 : numColumnsProp;
1560
+ const numColumns = (_a = peek$(ctx, "numColumns")) != null ? _a : numColumnsProp;
1541
1561
  if (!refState.current) {
1542
1562
  return;
1543
1563
  }
@@ -1566,7 +1586,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1566
1586
  id: getId(0)
1567
1587
  };
1568
1588
  refState.current.anchorElement = newAnchorElement;
1569
- (_b2 = refState.current.belowAnchorElementPositions) == null ? void 0 : _b2.clear();
1589
+ (_b = refState.current.belowAnchorElementPositions) == null ? void 0 : _b.clear();
1570
1590
  scrollTo(0, false);
1571
1591
  setTimeout(() => {
1572
1592
  calculateItemsInView();
@@ -1625,20 +1645,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1625
1645
  const initalizeStateVars = () => {
1626
1646
  set$(ctx, "lastItemKeys", memoizedLastItemKeys);
1627
1647
  set$(ctx, "numColumns", numColumnsProp);
1628
- if (maintainVisibleContentPosition) {
1629
- const prevPaddingTop = peek$(ctx, "stylePaddingTop");
1630
- set$(ctx, "stylePaddingTop", stylePaddingTop);
1631
- if (prevPaddingTop !== void 0) {
1632
- const paddingDiff = stylePaddingTop - prevPaddingTop;
1633
- if (paddingDiff) {
1634
- set$(ctx, "paddingTop", peek$(ctx, "paddingTop") + paddingDiff);
1635
- if (Platform.OS === "ios") {
1636
- queueMicrotask(() => {
1637
- scrollTo(refState.current.scroll + paddingDiff, false);
1638
- });
1639
- }
1640
- }
1641
- }
1648
+ const prevPaddingTop = peek$(ctx, "stylePaddingTop");
1649
+ setPaddingTop({ stylePaddingTop: stylePaddingTopState });
1650
+ const paddingDiff = stylePaddingTopState - prevPaddingTop;
1651
+ if (paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
1652
+ queueMicrotask(() => {
1653
+ scrollTo(refState.current.scroll + paddingDiff, false);
1654
+ });
1642
1655
  }
1643
1656
  };
1644
1657
  if (isFirst) {
@@ -1665,9 +1678,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1665
1678
  set$(ctx, "extraData", extraData);
1666
1679
  }, [extraData]);
1667
1680
  refState.current.renderItem = renderItem;
1668
- useEffect(initalizeStateVars, [memoizedLastItemKeys.join(","), numColumnsProp, stylePaddingTop]);
1681
+ useEffect(initalizeStateVars, [memoizedLastItemKeys.join(","), numColumnsProp, stylePaddingTopState]);
1669
1682
  const getRenderedItem = useCallback((key) => {
1670
- var _a2, _b2;
1683
+ var _a, _b;
1671
1684
  const state = refState.current;
1672
1685
  if (!state) {
1673
1686
  return null;
@@ -1697,7 +1710,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1697
1710
  `[legend-list] useRecyclingState has been moved from a render prop to a regular import: import { useRecyclingState } from "@legendapp/list";`
1698
1711
  );
1699
1712
  } : void 0;
1700
- const renderedItem = (_b2 = (_a2 = refState.current).renderItem) == null ? void 0 : _b2.call(_a2, {
1713
+ const renderedItem = (_b = (_a = refState.current).renderItem) == null ? void 0 : _b.call(_a, {
1701
1714
  item: data[index],
1702
1715
  index,
1703
1716
  extraData: peek$(ctx, "extraData"),
@@ -1710,11 +1723,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1710
1723
  return { index, item: data[index], renderedItem };
1711
1724
  }, []);
1712
1725
  const doInitialAllocateContainers = () => {
1713
- var _a2;
1726
+ var _a;
1714
1727
  const state = refState.current;
1715
1728
  const { scrollLength, data } = state;
1716
1729
  if (scrollLength > 0 && data.length > 0 && !peek$(ctx, "numContainers")) {
1717
- const averageItemSize = (_a2 = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0])) != null ? _a2 : DEFAULT_ITEM_SIZE;
1730
+ const averageItemSize = (_a = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0])) != null ? _a : DEFAULT_ITEM_SIZE;
1718
1731
  const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize) * numColumnsProp;
1719
1732
  for (let i = 0; i < numContainers; i++) {
1720
1733
  set$(ctx, `containerPosition${i}`, ANCHORED_POSITION_OUT_OF_VIEW);
@@ -1834,7 +1847,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1834
1847
  state.scrollForNextCalculateItemsInView = void 0;
1835
1848
  doInitialAllocateContainers();
1836
1849
  doMaintainScrollAtEnd(false);
1837
- doUpdatePaddingTop();
1850
+ updateAlignItemsPaddingTop();
1838
1851
  checkAtBottom();
1839
1852
  checkAtTop();
1840
1853
  if (didChange) {
@@ -1855,8 +1868,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1855
1868
  }, []);
1856
1869
  const handleScroll = useCallback(
1857
1870
  (event, fromSelf) => {
1858
- var _a2, _b2, _c2, _d2;
1859
- if (((_b2 = (_a2 = event.nativeEvent) == null ? void 0 : _a2.contentSize) == null ? void 0 : _b2.height) === 0 && ((_c2 = event.nativeEvent.contentSize) == null ? void 0 : _c2.width) === 0) {
1871
+ var _a, _b, _c, _d;
1872
+ if (((_b = (_a = event.nativeEvent) == null ? void 0 : _a.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
1860
1873
  return;
1861
1874
  }
1862
1875
  const state = refState.current;
@@ -1896,7 +1909,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1896
1909
  checkAtBottom();
1897
1910
  checkAtTop();
1898
1911
  if (!fromSelf) {
1899
- (_d2 = state.onScroll) == null ? void 0 : _d2.call(state, event);
1912
+ (_d = state.onScroll) == null ? void 0 : _d.call(state, event);
1900
1913
  }
1901
1914
  },
1902
1915
  []
@@ -1910,7 +1923,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1910
1923
  animated = true,
1911
1924
  viewPosition = 0
1912
1925
  }) => {
1913
- var _a2;
1926
+ var _a;
1914
1927
  const state = refState.current;
1915
1928
  const firstIndexOffset = calculateOffsetForIndex(index);
1916
1929
  let firstIndexScrollPostion = firstIndexOffset - viewOffset;
@@ -1920,7 +1933,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1920
1933
  if (needsReanchoring) {
1921
1934
  const id = getId(index);
1922
1935
  state.anchorElement = { id, coordinate: firstIndexOffset };
1923
- (_a2 = state.belowAnchorElementPositions) == null ? void 0 : _a2.clear();
1936
+ (_a = state.belowAnchorElementPositions) == null ? void 0 : _a.clear();
1924
1937
  state.positions.clear();
1925
1938
  calcTotalSizesAndPositions({ forgetPositions: true });
1926
1939
  state.startBufferedId = id;
@@ -1993,13 +2006,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1993
2006
  );
1994
2007
  if (Platform.OS === "web") {
1995
2008
  useEffect(() => {
1996
- var _a2;
2009
+ var _a;
1997
2010
  if (initialContentOffset) {
1998
- (_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(true);
2011
+ (_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
1999
2012
  scrollTo(initialContentOffset, false);
2000
2013
  setTimeout(() => {
2001
- var _a3;
2002
- (_a3 = refState.current) == null ? void 0 : _a3.scrollAdjustHandler.setDisableAdjust(false);
2014
+ var _a2;
2015
+ (_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(false);
2003
2016
  }, 0);
2004
2017
  }
2005
2018
  }, []);
@@ -2015,8 +2028,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2015
2028
  updateItemSize,
2016
2029
  handleScroll,
2017
2030
  onMomentumScrollEnd: (event) => {
2018
- var _a2;
2019
- const scrollingToOffset = (_a2 = refState.current) == null ? void 0 : _a2.scrollingToOffset;
2031
+ var _a;
2032
+ const scrollingToOffset = (_a = refState.current) == null ? void 0 : _a.scrollingToOffset;
2020
2033
  if (scrollingToOffset !== void 0) {
2021
2034
  requestAnimationFrame(() => {
2022
2035
  scrollTo(scrollingToOffset, false);
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ var list = require('@legendapp/list');
3
4
  var React = require('react');
5
+ var reactNative = require('react-native');
4
6
  var reactNativeKeyboardController = require('react-native-keyboard-controller');
5
7
  var reactNativeReanimated = require('react-native-reanimated');
6
8
 
@@ -27,7 +29,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
27
29
  // src/keyboard-controller.tsx
28
30
  var typedForwardRef = React.forwardRef;
29
31
  var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
30
- const { LegendList: LegendListProp, ...rest } = props;
32
+ const { LegendList: LegendListProp, style: styleProp, ...rest } = props;
31
33
  const [padding, setPadding] = React.useState(0);
32
34
  const updatePadding = (height) => {
33
35
  setPadding(height);
@@ -38,8 +40,10 @@ var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
38
40
  reactNativeReanimated.runOnJS(updatePadding)(e.height);
39
41
  }
40
42
  });
41
- const LegendListComponent = LegendListProp != null ? LegendListProp : LegendList2;
42
- return /* @__PURE__ */ React__namespace.createElement(LegendListComponent, { style: { paddingTop: padding }, ...rest, ref: forwardedRef });
43
+ const LegendListComponent = LegendListProp != null ? LegendListProp : list.LegendList;
44
+ const styleFlattened = reactNative.StyleSheet.flatten(styleProp) || {};
45
+ const style = { ...styleFlattened, paddingTop: padding + (styleFlattened.paddingTop || 0) };
46
+ return /* @__PURE__ */ React__namespace.createElement(LegendListComponent, { ...rest, style, ref: forwardedRef });
43
47
  });
44
48
 
45
49
  exports.LegendList = LegendList;
@@ -1,12 +1,14 @@
1
+ import { LegendList as LegendList$1 } from '@legendapp/list';
1
2
  import * as React from 'react';
2
3
  import { useState, forwardRef } from 'react';
4
+ import { StyleSheet } from 'react-native';
3
5
  import { useKeyboardHandler } from 'react-native-keyboard-controller';
4
6
  import { runOnJS } from 'react-native-reanimated';
5
7
 
6
8
  // src/keyboard-controller.tsx
7
9
  var typedForwardRef = forwardRef;
8
10
  var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
9
- const { LegendList: LegendListProp, ...rest } = props;
11
+ const { LegendList: LegendListProp, style: styleProp, ...rest } = props;
10
12
  const [padding, setPadding] = useState(0);
11
13
  const updatePadding = (height) => {
12
14
  setPadding(height);
@@ -17,8 +19,10 @@ var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
17
19
  runOnJS(updatePadding)(e.height);
18
20
  }
19
21
  });
20
- const LegendListComponent = LegendListProp != null ? LegendListProp : LegendList2;
21
- return /* @__PURE__ */ React.createElement(LegendListComponent, { style: { paddingTop: padding }, ...rest, ref: forwardedRef });
22
+ const LegendListComponent = LegendListProp != null ? LegendListProp : LegendList$1;
23
+ const styleFlattened = StyleSheet.flatten(styleProp) || {};
24
+ const style = { ...styleFlattened, paddingTop: padding + (styleFlattened.paddingTop || 0) };
25
+ return /* @__PURE__ */ React.createElement(LegendListComponent, { ...rest, style, ref: forwardedRef });
22
26
  });
23
27
 
24
28
  export { LegendList };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "1.0.0-beta.41",
3
+ "version": "1.0.0-beta.43",
4
4
  "description": "Legend List aims to be a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,