@legendapp/list 2.1.0-beta.13 → 2.1.0-beta.14

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.native.mjs CHANGED
@@ -811,7 +811,7 @@ var ListComponent = typedMemo(function ListComponent2({
811
811
  scrollAdjustHandler,
812
812
  onLayoutHeader,
813
813
  snapToIndices,
814
- stickyHeaderIndices,
814
+ stickyIndices,
815
815
  ...rest
816
816
  }) {
817
817
  const ctx = useStateContext();
@@ -846,7 +846,7 @@ var ListComponent = typedMemo(function ListComponent2({
846
846
  ScrollComponent: snapToIndices ? ScrollComponent : void 0,
847
847
  style
848
848
  },
849
- /* @__PURE__ */ React2.createElement(ScrollAdjust, null),
849
+ maintainVisibleContentPosition && /* @__PURE__ */ React2.createElement(ScrollAdjust, null),
850
850
  ENABLE_DEVMODE ? /* @__PURE__ */ React2.createElement(PaddingDevMode, null) : /* @__PURE__ */ React2.createElement(Padding, null),
851
851
  ListHeaderComponent && /* @__PURE__ */ React2.createElement(LayoutView, { onLayoutChange: onLayoutHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
852
852
  ListEmptyComponent && getComponent(ListEmptyComponent),
@@ -1039,70 +1039,6 @@ function calculateOffsetWithOffsetPosition(ctx, state, offsetParam, params) {
1039
1039
  return offset;
1040
1040
  }
1041
1041
 
1042
- // src/core/finishScrollTo.ts
1043
- function finishScrollTo(ctx, state) {
1044
- var _a3, _b;
1045
- if (state) {
1046
- state.scrollHistory.length = 0;
1047
- state.initialScroll = void 0;
1048
- state.initialAnchor = void 0;
1049
- set$(ctx, "scrollingTo", void 0);
1050
- if (state.pendingTotalSize !== void 0) {
1051
- addTotalSize(ctx, state, null, state.pendingTotalSize);
1052
- }
1053
- if ((_a3 = state.props) == null ? void 0 : _a3.data) {
1054
- (_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
1055
- }
1056
- }
1057
- }
1058
- var Platform2 = Platform;
1059
-
1060
- // src/core/scrollTo.ts
1061
- function scrollTo(ctx, state, params) {
1062
- var _a3;
1063
- const { noScrollingTo, ...scrollTarget } = params;
1064
- const { animated, isInitialScroll, offset: scrollTargetOffset, precomputedWithViewOffset } = scrollTarget;
1065
- const {
1066
- refScroller,
1067
- props: { horizontal }
1068
- } = state;
1069
- let offset = precomputedWithViewOffset ? scrollTargetOffset : calculateOffsetWithOffsetPosition(ctx, state, scrollTargetOffset, scrollTarget);
1070
- if (Number.isFinite(state.scrollLength) && Number.isFinite(state.totalSize)) {
1071
- const maxOffset = Math.max(0, getContentSize(ctx) - state.scrollLength);
1072
- offset = Math.min(offset, maxOffset);
1073
- }
1074
- state.scrollHistory.length = 0;
1075
- if (!noScrollingTo) {
1076
- set$(ctx, "scrollingTo", scrollTarget);
1077
- }
1078
- state.scrollPending = offset;
1079
- if (!isInitialScroll || Platform2.OS === "android") {
1080
- (_a3 = refScroller.current) == null ? void 0 : _a3.scrollTo({
1081
- animated: !!animated,
1082
- x: horizontal ? offset : 0,
1083
- y: horizontal ? 0 : offset
1084
- });
1085
- }
1086
- if (!animated) {
1087
- state.scroll = offset;
1088
- if (Platform2.OS === "web") {
1089
- const unlisten = listen$(ctx, "containersDidLayout", (value) => {
1090
- if (value && peek$(ctx, "scrollingTo")) {
1091
- finishScrollTo(ctx, state);
1092
- unlisten();
1093
- }
1094
- });
1095
- } else {
1096
- setTimeout(() => finishScrollTo(ctx, state), 100);
1097
- }
1098
- if (isInitialScroll) {
1099
- setTimeout(() => {
1100
- state.initialScroll = void 0;
1101
- }, 500);
1102
- }
1103
- }
1104
- }
1105
-
1106
1042
  // src/utils/checkThreshold.ts
1107
1043
  var HYSTERESIS_MULTIPLIER = 1.3;
1108
1044
  var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot) => {
@@ -1213,7 +1149,24 @@ function checkAtTop(state) {
1213
1149
  );
1214
1150
  }
1215
1151
 
1216
- // src/core/updateScroll.ts
1152
+ // src/core/onScroll.ts
1153
+ function onScroll(ctx, state, event) {
1154
+ var _a3, _b, _c;
1155
+ const {
1156
+ scrollProcessingEnabled,
1157
+ props: { onScroll: onScrollProp }
1158
+ } = state;
1159
+ if (scrollProcessingEnabled === false) {
1160
+ return;
1161
+ }
1162
+ if (((_b = (_a3 = event.nativeEvent) == null ? void 0 : _a3.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
1163
+ return;
1164
+ }
1165
+ const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
1166
+ state.scrollPending = newScroll;
1167
+ updateScroll(ctx, state, newScroll);
1168
+ onScrollProp == null ? void 0 : onScrollProp(event);
1169
+ }
1217
1170
  function updateScroll(ctx, state, newScroll, forceUpdate) {
1218
1171
  var _a3;
1219
1172
  const scrollingTo = peek$(ctx, "scrollingTo");
@@ -1256,6 +1209,70 @@ function updateScroll(ctx, state, newScroll, forceUpdate) {
1256
1209
  }
1257
1210
  }
1258
1211
 
1212
+ // src/core/finishScrollTo.ts
1213
+ function finishScrollTo(ctx, state) {
1214
+ var _a3, _b;
1215
+ if (state) {
1216
+ state.scrollHistory.length = 0;
1217
+ state.initialScroll = void 0;
1218
+ state.initialAnchor = void 0;
1219
+ set$(ctx, "scrollingTo", void 0);
1220
+ if (state.pendingTotalSize !== void 0) {
1221
+ addTotalSize(ctx, state, null, state.pendingTotalSize);
1222
+ }
1223
+ if ((_a3 = state.props) == null ? void 0 : _a3.data) {
1224
+ (_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
1225
+ }
1226
+ }
1227
+ }
1228
+ var Platform2 = Platform;
1229
+
1230
+ // src/core/scrollTo.ts
1231
+ function scrollTo(ctx, state, params) {
1232
+ var _a3;
1233
+ const { noScrollingTo, ...scrollTarget } = params;
1234
+ const { animated, isInitialScroll, offset: scrollTargetOffset, precomputedWithViewOffset } = scrollTarget;
1235
+ const {
1236
+ refScroller,
1237
+ props: { horizontal }
1238
+ } = state;
1239
+ let offset = precomputedWithViewOffset ? scrollTargetOffset : calculateOffsetWithOffsetPosition(ctx, state, scrollTargetOffset, scrollTarget);
1240
+ if (Number.isFinite(state.scrollLength) && Number.isFinite(state.totalSize)) {
1241
+ const maxOffset = Math.max(0, getContentSize(ctx) - state.scrollLength);
1242
+ offset = Math.min(offset, maxOffset);
1243
+ }
1244
+ state.scrollHistory.length = 0;
1245
+ if (!noScrollingTo) {
1246
+ set$(ctx, "scrollingTo", scrollTarget);
1247
+ }
1248
+ state.scrollPending = offset;
1249
+ if (!isInitialScroll || Platform2.OS === "android") {
1250
+ (_a3 = refScroller.current) == null ? void 0 : _a3.scrollTo({
1251
+ animated: !!animated,
1252
+ x: horizontal ? offset : 0,
1253
+ y: horizontal ? 0 : offset
1254
+ });
1255
+ }
1256
+ if (!animated) {
1257
+ state.scroll = offset;
1258
+ if (Platform2.OS === "web") {
1259
+ const unlisten = listen$(ctx, "containersDidLayout", (value) => {
1260
+ if (value) {
1261
+ finishScrollTo(ctx, state);
1262
+ unlisten();
1263
+ }
1264
+ });
1265
+ } else {
1266
+ setTimeout(() => finishScrollTo(ctx, state), 100);
1267
+ }
1268
+ if (isInitialScroll) {
1269
+ setTimeout(() => {
1270
+ state.initialScroll = void 0;
1271
+ }, 500);
1272
+ }
1273
+ }
1274
+ }
1275
+
1259
1276
  // src/utils/requestAdjust.ts
1260
1277
  function requestAdjust(ctx, state, positionDiff, dataChanged) {
1261
1278
  if (Math.abs(positionDiff) > 0.1) {
@@ -1268,9 +1285,6 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
1268
1285
  });
1269
1286
  } else {
1270
1287
  state.scrollAdjustHandler.requestAdjust(positionDiff);
1271
- if (state.adjustingFromInitialMount) {
1272
- state.adjustingFromInitialMount--;
1273
- }
1274
1288
  }
1275
1289
  };
1276
1290
  state.scroll += positionDiff;
@@ -1303,7 +1317,6 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
1303
1317
  }, delay);
1304
1318
  }
1305
1319
  } else {
1306
- state.adjustingFromInitialMount = (state.adjustingFromInitialMount || 0) + 1;
1307
1320
  requestAnimationFrame(doit);
1308
1321
  }
1309
1322
  }
@@ -1363,16 +1376,18 @@ function ensureInitialAnchor(ctx, state) {
1363
1376
 
1364
1377
  // src/core/mvcp.ts
1365
1378
  function prepareMVCP(ctx, state, dataChanged) {
1366
- const { idsInView, positions, props } = state;
1367
- const { maintainVisibleContentPosition } = props;
1379
+ const {
1380
+ idsInView,
1381
+ positions,
1382
+ props: { maintainVisibleContentPosition }
1383
+ } = state;
1368
1384
  const scrollingTo = peek$(ctx, "scrollingTo");
1369
1385
  let prevPosition;
1370
1386
  let targetId;
1371
1387
  const idsInViewWithPositions = [];
1372
1388
  const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
1373
- const shouldMVCP = !dataChanged || maintainVisibleContentPosition;
1374
- const indexByKey = state.indexByKey;
1375
- if (shouldMVCP) {
1389
+ if (maintainVisibleContentPosition) {
1390
+ const indexByKey = state.indexByKey;
1376
1391
  if (scrollTarget !== void 0) {
1377
1392
  if (!IsNewArchitecture && (scrollingTo == null ? void 0 : scrollingTo.isInitialScroll)) {
1378
1393
  return void 0;
@@ -1388,44 +1403,44 @@ function prepareMVCP(ctx, state, dataChanged) {
1388
1403
  }
1389
1404
  }
1390
1405
  } else {
1391
- targetId = idsInView.find((id) => indexByKey.get(id) !== void 0);
1406
+ targetId = state.idsInView.find((id) => indexByKey.get(id) !== void 0);
1392
1407
  }
1393
1408
  }
1394
1409
  if (targetId !== void 0) {
1395
1410
  prevPosition = positions.get(targetId);
1396
1411
  }
1397
- return () => {
1398
- let positionDiff;
1399
- if (dataChanged && targetId === void 0 && maintainVisibleContentPosition) {
1400
- for (let i = 0; i < idsInViewWithPositions.length; i++) {
1401
- const { id, position } = idsInViewWithPositions[i];
1402
- const newPosition = positions.get(id);
1403
- if (newPosition !== void 0) {
1404
- positionDiff = newPosition - position;
1405
- break;
1406
- }
1412
+ }
1413
+ return () => {
1414
+ let positionDiff;
1415
+ if (dataChanged && targetId === void 0) {
1416
+ for (let i = 0; i < idsInViewWithPositions.length; i++) {
1417
+ const { id, position } = idsInViewWithPositions[i];
1418
+ const newPosition = positions.get(id);
1419
+ if (newPosition !== void 0) {
1420
+ positionDiff = newPosition - position;
1421
+ break;
1407
1422
  }
1408
1423
  }
1409
- if (targetId !== void 0 && prevPosition !== void 0) {
1410
- const newPosition = positions.get(targetId);
1411
- if (newPosition !== void 0) {
1412
- const totalSize = getContentSize(ctx);
1413
- let diff = newPosition - prevPosition;
1414
- if (diff !== 0 && state.scroll + state.scrollLength > totalSize) {
1415
- if (diff > 0) {
1416
- diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
1417
- } else {
1418
- diff = 0;
1419
- }
1424
+ }
1425
+ if (targetId !== void 0 && prevPosition !== void 0) {
1426
+ const newPosition = positions.get(targetId);
1427
+ if (newPosition !== void 0) {
1428
+ const totalSize = getContentSize(ctx);
1429
+ let diff = newPosition - prevPosition;
1430
+ if (diff !== 0 && state.scroll + state.scrollLength > totalSize) {
1431
+ if (diff > 0) {
1432
+ diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
1433
+ } else {
1434
+ diff = 0;
1420
1435
  }
1421
- positionDiff = diff;
1422
1436
  }
1437
+ positionDiff = diff;
1423
1438
  }
1424
- if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
1425
- requestAdjust(ctx, state, positionDiff, dataChanged && maintainVisibleContentPosition);
1426
- }
1427
- };
1428
- }
1439
+ }
1440
+ if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
1441
+ requestAdjust(ctx, state, positionDiff, dataChanged);
1442
+ }
1443
+ };
1429
1444
  }
1430
1445
 
1431
1446
  // src/core/prepareColumnStartState.ts
@@ -1567,8 +1582,7 @@ function updateSnapToOffsets(ctx, state) {
1567
1582
  }
1568
1583
 
1569
1584
  // src/core/updateItemPositions.ts
1570
- function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false, doMVCP } = {
1571
- doMVCP: false,
1585
+ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false } = {
1572
1586
  forceFullUpdate: false,
1573
1587
  scrollBottomBuffered: -1,
1574
1588
  startIndex: 0
@@ -1580,7 +1594,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
1580
1594
  positions,
1581
1595
  idCache,
1582
1596
  sizesKnown,
1583
- props: { getEstimatedItemSize, snapToIndices, enableAverages }
1597
+ props: { getEstimatedItemSize, snapToIndices, enableAverages, maintainVisibleContentPosition }
1584
1598
  } = state;
1585
1599
  const data = state.props.data;
1586
1600
  const dataLength = data.length;
@@ -1591,7 +1605,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
1591
1605
  const shouldOptimize = !forceFullUpdate && !dataChanged && Math.abs(getScrollVelocity(state)) > 0;
1592
1606
  const maxVisibleArea = scrollBottomBuffered + 1e3;
1593
1607
  const useAverageSize = enableAverages && !getEstimatedItemSize;
1594
- const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_a3 = peek$(ctx, "scrollAdjustPending")) != null ? _a3 : 0) !== 0;
1608
+ const preferCachedSize = maintainVisibleContentPosition && (dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_a3 = peek$(ctx, "scrollAdjustPending")) != null ? _a3 : 0) !== 0);
1595
1609
  let currentRowTop = 0;
1596
1610
  let column = 1;
1597
1611
  let maxSizeInRow = 0;
@@ -2057,14 +2071,14 @@ function findCurrentStickyIndex(stickyArray, scroll, state) {
2057
2071
  }
2058
2072
  return -1;
2059
2073
  }
2060
- function getActiveStickyIndices(ctx, state, stickyHeaderIndices) {
2074
+ function getActiveStickyIndices(ctx, state, stickyIndices) {
2061
2075
  return new Set(
2062
- Array.from(state.stickyContainerPool).map((i) => peek$(ctx, `containerItemKey${i}`)).map((key) => key ? state.indexByKey.get(key) : void 0).filter((idx) => idx !== void 0 && stickyHeaderIndices.has(idx))
2076
+ Array.from(state.stickyContainerPool).map((i) => peek$(ctx, `containerItemKey${i}`)).map((key) => key ? state.indexByKey.get(key) : void 0).filter((idx) => idx !== void 0 && stickyIndices.has(idx))
2063
2077
  );
2064
2078
  }
2065
- function handleStickyActivation(ctx, state, stickyHeaderIndices, stickyArray, currentStickyIdx, needNewContainers, startBuffered, endBuffered) {
2079
+ function handleStickyActivation(ctx, state, stickyIndices, stickyArray, currentStickyIdx, needNewContainers, startBuffered, endBuffered) {
2066
2080
  var _a3;
2067
- const activeIndices = getActiveStickyIndices(ctx, state, stickyHeaderIndices);
2081
+ const activeIndices = getActiveStickyIndices(ctx, state, stickyIndices);
2068
2082
  state.activeStickyIndex = currentStickyIdx >= 0 ? stickyArray[currentStickyIdx] : void 0;
2069
2083
  for (let offset = 0; offset <= 1; offset++) {
2070
2084
  const idx = currentStickyIdx - offset;
@@ -2200,7 +2214,6 @@ function calculateItemsInView(ctx, state, params = {}) {
2200
2214
  }
2201
2215
  const startIndex = dataChanged ? 0 : (_b = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _b : 0;
2202
2216
  updateItemPositions(ctx, state, dataChanged, {
2203
- doMVCP,
2204
2217
  forceFullUpdate: !!forceFullItemPositions,
2205
2218
  scrollBottomBuffered,
2206
2219
  startIndex
@@ -2495,7 +2508,6 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
2495
2508
  });
2496
2509
  return true;
2497
2510
  }
2498
- return false;
2499
2511
  }
2500
2512
 
2501
2513
  // src/utils/updateAveragesOnDataChange.ts
@@ -2664,25 +2676,6 @@ function handleLayout(ctx, state, layout, setCanRender) {
2664
2676
  setCanRender(true);
2665
2677
  }
2666
2678
 
2667
- // src/core/onScroll.ts
2668
- function onScroll(ctx, state, event) {
2669
- var _a3, _b, _c;
2670
- const {
2671
- scrollProcessingEnabled,
2672
- props: { onScroll: onScrollProp }
2673
- } = state;
2674
- if (scrollProcessingEnabled === false) {
2675
- return;
2676
- }
2677
- if (((_b = (_a3 = event.nativeEvent) == null ? void 0 : _a3.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
2678
- return;
2679
- }
2680
- const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
2681
- state.scrollPending = newScroll;
2682
- updateScroll(ctx, state, newScroll);
2683
- onScrollProp == null ? void 0 : onScrollProp(event);
2684
- }
2685
-
2686
2679
  // src/core/ScrollAdjustHandler.ts
2687
2680
  var ScrollAdjustHandler = class {
2688
2681
  constructor(ctx) {
@@ -2718,7 +2711,12 @@ var ScrollAdjustHandler = class {
2718
2711
  set$(this.context, "scrollAdjustPending", this.pendingAdjust);
2719
2712
  } else {
2720
2713
  this.appliedAdjust += add;
2721
- set$(this.context, "scrollAdjust", this.appliedAdjust);
2714
+ const setter = () => set$(this.context, "scrollAdjust", this.appliedAdjust);
2715
+ if (this.mounted) {
2716
+ setter();
2717
+ } else {
2718
+ requestAnimationFrame(setter);
2719
+ }
2722
2720
  }
2723
2721
  }
2724
2722
  setMounted() {
@@ -2880,9 +2878,9 @@ function getWindowSize() {
2880
2878
  };
2881
2879
  }
2882
2880
  var StyleSheet = StyleSheet$1;
2883
- function useStickyScrollHandler(stickyHeaderIndices, horizontal, ctx, onScroll2) {
2881
+ function useStickyScrollHandler(stickyIndices, horizontal, ctx, onScroll2) {
2884
2882
  return useMemo(() => {
2885
- if (stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.length) {
2883
+ if (stickyIndices == null ? void 0 : stickyIndices.length) {
2886
2884
  const { animatedScrollY } = ctx;
2887
2885
  return Animated.event(
2888
2886
  [
@@ -2899,7 +2897,7 @@ function useStickyScrollHandler(stickyHeaderIndices, horizontal, ctx, onScroll2)
2899
2897
  );
2900
2898
  }
2901
2899
  return onScroll2;
2902
- }, [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(","), horizontal]);
2900
+ }, [stickyIndices == null ? void 0 : stickyIndices.join(","), horizontal]);
2903
2901
  }
2904
2902
 
2905
2903
  // src/utils/createColumnWrapperStyle.ts
@@ -3121,7 +3119,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3121
3119
  ListHeaderComponent,
3122
3120
  maintainScrollAtEnd = false,
3123
3121
  maintainScrollAtEndThreshold = 0.1,
3124
- maintainVisibleContentPosition = false,
3122
+ maintainVisibleContentPosition = true,
3125
3123
  numColumns: numColumnsProp = 1,
3126
3124
  onEndReached,
3127
3125
  onEndReachedThreshold = 0.5,
@@ -3143,8 +3141,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3143
3141
  renderItem,
3144
3142
  scrollEventThrottle,
3145
3143
  snapToIndices,
3146
- stickyHeaderIndices: stickyHeaderIndicesProp,
3147
- stickyIndices: stickyIndicesDeprecated,
3144
+ stickyIndices,
3148
3145
  style: styleProp,
3149
3146
  suggestEstimatedItemSize,
3150
3147
  viewabilityConfig,
@@ -3166,13 +3163,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3166
3163
  const estimatedItemSize = estimatedItemSizeProp != null ? estimatedItemSizeProp : DEFAULT_ITEM_SIZE;
3167
3164
  const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
3168
3165
  const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (_item, index) => index.toString();
3169
- const stickyHeaderIndices = stickyHeaderIndicesProp != null ? stickyHeaderIndicesProp : stickyIndicesDeprecated;
3170
- if (IS_DEV && stickyIndicesDeprecated && !stickyHeaderIndicesProp) {
3171
- warnDevOnce(
3172
- "stickyIndices",
3173
- "stickyIndices has been renamed to stickyHeaderIndices. Please update your props to use stickyHeaderIndices."
3174
- );
3175
- }
3176
3166
  const refState = useRef();
3177
3167
  if (!refState.current) {
3178
3168
  if (!ctx.internalState) {
@@ -3284,8 +3274,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3284
3274
  renderItem,
3285
3275
  scrollBuffer,
3286
3276
  snapToIndices,
3287
- stickyIndicesArr: stickyHeaderIndices != null ? stickyHeaderIndices : [],
3288
- stickyIndicesSet: useMemo(() => new Set(stickyHeaderIndices != null ? stickyHeaderIndices : []), [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(",")]),
3277
+ stickyIndicesArr: stickyIndices != null ? stickyIndices : [],
3278
+ stickyIndicesSet: useMemo(() => new Set(stickyIndices != null ? stickyIndices : []), [stickyIndices == null ? void 0 : stickyIndices.join(",")]),
3289
3279
  stylePaddingBottom: stylePaddingBottomState,
3290
3280
  stylePaddingTop: stylePaddingTopState,
3291
3281
  suggestEstimatedItemSize: !!suggestEstimatedItemSize
@@ -3305,7 +3295,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3305
3295
  setPaddingTop(ctx, state, { stylePaddingTop: stylePaddingTopState });
3306
3296
  refState.current.props.stylePaddingBottom = stylePaddingBottomState;
3307
3297
  let paddingDiff = stylePaddingTopState - prevPaddingTop;
3308
- if (paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
3298
+ if (maintainVisibleContentPosition && paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
3309
3299
  if (state.scroll < 0) {
3310
3300
  paddingDiff += state.scroll;
3311
3301
  }
@@ -3353,7 +3343,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3353
3343
  state.initialScroll = updatedInitialScroll;
3354
3344
  refState.current.isStartReached = clampedOffset < refState.current.scrollLength * onStartReachedThreshold;
3355
3345
  return clampedOffset;
3356
- }, [renderNum]);
3346
+ }, [renderNum, state.initialScroll]);
3357
3347
  if (isFirstLocal || didDataChangeLocal || numColumnsProp !== peek$(ctx, "numColumns")) {
3358
3348
  refState.current.lastBatchingAction = Date.now();
3359
3349
  if (!keyExtractorProp && !isFirstLocal && didDataChangeLocal) {
@@ -3393,7 +3383,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3393
3383
  precomputedWithViewOffset: true
3394
3384
  });
3395
3385
  }
3396
- }, [initialContentOffset]);
3386
+ }, [initialContentOffset, state.initialScroll]);
3397
3387
  const onLayoutChange = useCallback((layout) => {
3398
3388
  doInitialScroll();
3399
3389
  handleLayout(ctx, state, layout, setCanRender);
@@ -3460,7 +3450,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3460
3450
  }),
3461
3451
  []
3462
3452
  );
3463
- const onScrollHandler = useStickyScrollHandler(stickyHeaderIndices, horizontal, ctx, fns.onScroll);
3453
+ const onScrollHandler = useStickyScrollHandler(stickyIndices, horizontal, ctx, fns.onScroll);
3464
3454
  return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
3465
3455
  ListComponent,
3466
3456
  {
@@ -3506,7 +3496,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3506
3496
  scrollAdjustHandler: (_b = refState.current) == null ? void 0 : _b.scrollAdjustHandler,
3507
3497
  scrollEventThrottle: Platform2.OS === "web" ? 16 : void 0,
3508
3498
  snapToIndices,
3509
- stickyHeaderIndices,
3499
+ stickyIndices,
3510
3500
  style,
3511
3501
  updateItemSize: fns.updateItemSize,
3512
3502
  waitForInitialLayout
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "2.1.0-beta.13",
3
+ "version": "2.1.0-beta.14",
4
4
  "description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,
@@ -1,113 +0,0 @@
1
- import * as react_native from 'react-native';
2
- import { SectionListData, SectionBase, SectionListRenderItemInfo, SectionListScrollParams } from 'react-native';
3
- import * as React from 'react';
4
- import { a as LegendListRef, L as LegendListProps } from './types-JPHClxiw.mjs';
5
- import 'react-native-reanimated';
6
-
7
- type SectionListSeparatorProps<ItemT, SectionT> = {
8
- leadingItem?: ItemT;
9
- leadingSection?: SectionListData<ItemT, SectionT>;
10
- section: SectionListData<ItemT, SectionT>;
11
- trailingItem?: ItemT;
12
- trailingSection?: SectionListData<ItemT, SectionT>;
13
- };
14
- type SectionHeaderItem<SectionT> = {
15
- kind: "header";
16
- key: string;
17
- section: SectionT;
18
- sectionIndex: number;
19
- };
20
- type SectionFooterItem<SectionT> = {
21
- kind: "footer";
22
- key: string;
23
- section: SectionT;
24
- sectionIndex: number;
25
- };
26
- type SectionBodyItem<ItemT, SectionT> = {
27
- kind: "item";
28
- key: string;
29
- section: SectionT;
30
- sectionIndex: number;
31
- item: ItemT;
32
- itemIndex: number;
33
- absoluteItemIndex: number;
34
- };
35
- type SectionItemSeparator<ItemT, SectionT> = {
36
- kind: "item-separator";
37
- key: string;
38
- section: SectionT;
39
- sectionIndex: number;
40
- leadingItem: ItemT;
41
- leadingItemIndex: number;
42
- trailingItem?: ItemT;
43
- };
44
- type SectionSeparator<SectionT> = {
45
- kind: "section-separator";
46
- key: string;
47
- leadingSection: SectionT;
48
- leadingSectionIndex: number;
49
- trailingSection?: SectionT;
50
- };
51
- type FlatSectionListItem<ItemT, SectionT> = SectionHeaderItem<SectionT> | SectionFooterItem<SectionT> | SectionBodyItem<ItemT, SectionT> | SectionItemSeparator<ItemT, SectionT> | SectionSeparator<SectionT>;
52
- type SectionMeta = {
53
- header?: number;
54
- footer?: number;
55
- items: number[];
56
- };
57
- type BuildSectionListDataResult<ItemT, SectionT> = {
58
- data: Array<FlatSectionListItem<ItemT, SectionT>>;
59
- sectionMeta: SectionMeta[];
60
- stickyHeaderIndices: number[];
61
- };
62
-
63
- type SectionListViewToken<ItemT, SectionT> = {
64
- item: ItemT;
65
- key: string;
66
- index: number;
67
- isViewable: boolean;
68
- section: SectionListData<ItemT, SectionT>;
69
- };
70
- type SectionListOnViewableItemsChanged<ItemT, SectionT> = ((info: {
71
- viewableItems: Array<SectionListViewToken<ItemT, SectionT>>;
72
- changed: Array<SectionListViewToken<ItemT, SectionT>>;
73
- }) => void) | null;
74
- type SectionListLegendProps<ItemT, SectionT> = Omit<LegendListProps<FlatSectionListItem<ItemT, SectionT>>, "data" | "children" | "renderItem" | "keyExtractor" | "ItemSeparatorComponent" | "getItemType" | "getFixedItemSize" | "stickyHeaderIndices" | "numColumns" | "columnWrapperStyle" | "onViewableItemsChanged">;
75
- type SectionListProps<ItemT, SectionT extends SectionBase<ItemT> = SectionBase<ItemT>> = SectionListLegendProps<ItemT, SectionT> & {
76
- sections: ReadonlyArray<SectionListData<ItemT, SectionT>>;
77
- extraData?: any;
78
- renderItem?: (info: SectionListRenderItemInfo<ItemT, SectionT>) => React.ReactElement | null;
79
- renderSectionHeader?: (info: {
80
- section: SectionListData<ItemT, SectionT>;
81
- }) => React.ReactElement | null;
82
- renderSectionFooter?: (info: {
83
- section: SectionListData<ItemT, SectionT>;
84
- }) => React.ReactElement | null;
85
- ItemSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null;
86
- SectionSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | React.ReactElement | null;
87
- keyExtractor?: (item: ItemT, index: number) => string;
88
- stickySectionHeadersEnabled?: boolean;
89
- onViewableItemsChanged?: SectionListOnViewableItemsChanged<ItemT, SectionT>;
90
- };
91
- type SectionListRef = LegendListRef & {
92
- scrollToLocation(params: SectionListScrollParams): void;
93
- };
94
- declare const SectionList: (<ItemT, SectionT extends SectionBase<ItemT, react_native.DefaultSectionT>>(props: SectionListLegendProps<ItemT, SectionT> & {
95
- sections: readonly SectionListData<ItemT, SectionT>[];
96
- extraData?: any;
97
- renderItem?: ((info: SectionListRenderItemInfo<ItemT, SectionT>) => React.ReactElement | null) | undefined;
98
- renderSectionHeader?: ((info: {
99
- section: SectionListData<ItemT, SectionT>;
100
- }) => React.ReactElement | null) | undefined;
101
- renderSectionFooter?: ((info: {
102
- section: SectionListData<ItemT, SectionT>;
103
- }) => React.ReactElement | null) | undefined;
104
- ItemSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null | undefined;
105
- SectionSeparatorComponent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null | undefined;
106
- keyExtractor?: ((item: ItemT, index: number) => string) | undefined;
107
- stickySectionHeadersEnabled?: boolean;
108
- onViewableItemsChanged?: SectionListOnViewableItemsChanged<ItemT, SectionT> | undefined;
109
- } & React.RefAttributes<SectionListRef>) => React.ReactNode) & {
110
- displayName?: string;
111
- };
112
-
113
- export { type BuildSectionListDataResult, type FlatSectionListItem, SectionList, type SectionListOnViewableItemsChanged, type SectionListProps, type SectionListRef, type SectionListSeparatorProps, type SectionListViewToken, type SectionMeta };