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

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
- stickyIndices,
814
+ stickyHeaderIndices,
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
- maintainVisibleContentPosition && /* @__PURE__ */ React2.createElement(ScrollAdjust, null),
849
+ /* @__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,6 +1039,70 @@ 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
+
1042
1106
  // src/utils/checkThreshold.ts
1043
1107
  var HYSTERESIS_MULTIPLIER = 1.3;
1044
1108
  var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot) => {
@@ -1149,24 +1213,7 @@ function checkAtTop(state) {
1149
1213
  );
1150
1214
  }
1151
1215
 
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
- }
1216
+ // src/core/updateScroll.ts
1170
1217
  function updateScroll(ctx, state, newScroll, forceUpdate) {
1171
1218
  var _a3;
1172
1219
  const scrollingTo = peek$(ctx, "scrollingTo");
@@ -1209,70 +1256,6 @@ function updateScroll(ctx, state, newScroll, forceUpdate) {
1209
1256
  }
1210
1257
  }
1211
1258
 
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
-
1276
1259
  // src/utils/requestAdjust.ts
1277
1260
  function requestAdjust(ctx, state, positionDiff, dataChanged) {
1278
1261
  if (Math.abs(positionDiff) > 0.1) {
@@ -1285,6 +1268,9 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
1285
1268
  });
1286
1269
  } else {
1287
1270
  state.scrollAdjustHandler.requestAdjust(positionDiff);
1271
+ if (state.adjustingFromInitialMount) {
1272
+ state.adjustingFromInitialMount--;
1273
+ }
1288
1274
  }
1289
1275
  };
1290
1276
  state.scroll += positionDiff;
@@ -1317,6 +1303,7 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
1317
1303
  }, delay);
1318
1304
  }
1319
1305
  } else {
1306
+ state.adjustingFromInitialMount = (state.adjustingFromInitialMount || 0) + 1;
1320
1307
  requestAnimationFrame(doit);
1321
1308
  }
1322
1309
  }
@@ -1376,18 +1363,16 @@ function ensureInitialAnchor(ctx, state) {
1376
1363
 
1377
1364
  // src/core/mvcp.ts
1378
1365
  function prepareMVCP(ctx, state, dataChanged) {
1379
- const {
1380
- idsInView,
1381
- positions,
1382
- props: { maintainVisibleContentPosition }
1383
- } = state;
1366
+ const { idsInView, positions, props } = state;
1367
+ const { maintainVisibleContentPosition } = props;
1384
1368
  const scrollingTo = peek$(ctx, "scrollingTo");
1385
1369
  let prevPosition;
1386
1370
  let targetId;
1387
1371
  const idsInViewWithPositions = [];
1388
1372
  const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
1389
- if (maintainVisibleContentPosition) {
1390
- const indexByKey = state.indexByKey;
1373
+ const shouldMVCP = !dataChanged || maintainVisibleContentPosition;
1374
+ const indexByKey = state.indexByKey;
1375
+ if (shouldMVCP) {
1391
1376
  if (scrollTarget !== void 0) {
1392
1377
  if (!IsNewArchitecture && (scrollingTo == null ? void 0 : scrollingTo.isInitialScroll)) {
1393
1378
  return void 0;
@@ -1403,44 +1388,44 @@ function prepareMVCP(ctx, state, dataChanged) {
1403
1388
  }
1404
1389
  }
1405
1390
  } else {
1406
- targetId = state.idsInView.find((id) => indexByKey.get(id) !== void 0);
1391
+ targetId = idsInView.find((id) => indexByKey.get(id) !== void 0);
1407
1392
  }
1408
1393
  }
1409
1394
  if (targetId !== void 0) {
1410
1395
  prevPosition = positions.get(targetId);
1411
1396
  }
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;
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
+ }
1422
1407
  }
1423
1408
  }
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;
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
+ }
1435
1420
  }
1421
+ positionDiff = diff;
1436
1422
  }
1437
- positionDiff = diff;
1438
1423
  }
1439
- }
1440
- if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
1441
- requestAdjust(ctx, state, positionDiff, dataChanged);
1442
- }
1443
- };
1424
+ if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
1425
+ requestAdjust(ctx, state, positionDiff, dataChanged && maintainVisibleContentPosition);
1426
+ }
1427
+ };
1428
+ }
1444
1429
  }
1445
1430
 
1446
1431
  // src/core/prepareColumnStartState.ts
@@ -1582,7 +1567,8 @@ function updateSnapToOffsets(ctx, state) {
1582
1567
  }
1583
1568
 
1584
1569
  // src/core/updateItemPositions.ts
1585
- function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false } = {
1570
+ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false, doMVCP } = {
1571
+ doMVCP: false,
1586
1572
  forceFullUpdate: false,
1587
1573
  scrollBottomBuffered: -1,
1588
1574
  startIndex: 0
@@ -1594,7 +1580,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
1594
1580
  positions,
1595
1581
  idCache,
1596
1582
  sizesKnown,
1597
- props: { getEstimatedItemSize, snapToIndices, enableAverages, maintainVisibleContentPosition }
1583
+ props: { getEstimatedItemSize, snapToIndices, enableAverages }
1598
1584
  } = state;
1599
1585
  const data = state.props.data;
1600
1586
  const dataLength = data.length;
@@ -1605,7 +1591,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
1605
1591
  const shouldOptimize = !forceFullUpdate && !dataChanged && Math.abs(getScrollVelocity(state)) > 0;
1606
1592
  const maxVisibleArea = scrollBottomBuffered + 1e3;
1607
1593
  const useAverageSize = enableAverages && !getEstimatedItemSize;
1608
- const preferCachedSize = maintainVisibleContentPosition && (dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_a3 = peek$(ctx, "scrollAdjustPending")) != null ? _a3 : 0) !== 0);
1594
+ const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_a3 = peek$(ctx, "scrollAdjustPending")) != null ? _a3 : 0) !== 0;
1609
1595
  let currentRowTop = 0;
1610
1596
  let column = 1;
1611
1597
  let maxSizeInRow = 0;
@@ -2071,14 +2057,14 @@ function findCurrentStickyIndex(stickyArray, scroll, state) {
2071
2057
  }
2072
2058
  return -1;
2073
2059
  }
2074
- function getActiveStickyIndices(ctx, state, stickyIndices) {
2060
+ function getActiveStickyIndices(ctx, state, stickyHeaderIndices) {
2075
2061
  return new Set(
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))
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))
2077
2063
  );
2078
2064
  }
2079
- function handleStickyActivation(ctx, state, stickyIndices, stickyArray, currentStickyIdx, needNewContainers, startBuffered, endBuffered) {
2065
+ function handleStickyActivation(ctx, state, stickyHeaderIndices, stickyArray, currentStickyIdx, needNewContainers, startBuffered, endBuffered) {
2080
2066
  var _a3;
2081
- const activeIndices = getActiveStickyIndices(ctx, state, stickyIndices);
2067
+ const activeIndices = getActiveStickyIndices(ctx, state, stickyHeaderIndices);
2082
2068
  state.activeStickyIndex = currentStickyIdx >= 0 ? stickyArray[currentStickyIdx] : void 0;
2083
2069
  for (let offset = 0; offset <= 1; offset++) {
2084
2070
  const idx = currentStickyIdx - offset;
@@ -2214,6 +2200,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2214
2200
  }
2215
2201
  const startIndex = dataChanged ? 0 : (_b = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _b : 0;
2216
2202
  updateItemPositions(ctx, state, dataChanged, {
2203
+ doMVCP,
2217
2204
  forceFullUpdate: !!forceFullItemPositions,
2218
2205
  scrollBottomBuffered,
2219
2206
  startIndex
@@ -2508,6 +2495,7 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
2508
2495
  });
2509
2496
  return true;
2510
2497
  }
2498
+ return false;
2511
2499
  }
2512
2500
 
2513
2501
  // src/utils/updateAveragesOnDataChange.ts
@@ -2676,6 +2664,25 @@ function handleLayout(ctx, state, layout, setCanRender) {
2676
2664
  setCanRender(true);
2677
2665
  }
2678
2666
 
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
+
2679
2686
  // src/core/ScrollAdjustHandler.ts
2680
2687
  var ScrollAdjustHandler = class {
2681
2688
  constructor(ctx) {
@@ -2711,12 +2718,7 @@ var ScrollAdjustHandler = class {
2711
2718
  set$(this.context, "scrollAdjustPending", this.pendingAdjust);
2712
2719
  } else {
2713
2720
  this.appliedAdjust += add;
2714
- const setter = () => set$(this.context, "scrollAdjust", this.appliedAdjust);
2715
- if (this.mounted) {
2716
- setter();
2717
- } else {
2718
- requestAnimationFrame(setter);
2719
- }
2721
+ set$(this.context, "scrollAdjust", this.appliedAdjust);
2720
2722
  }
2721
2723
  }
2722
2724
  setMounted() {
@@ -2878,9 +2880,9 @@ function getWindowSize() {
2878
2880
  };
2879
2881
  }
2880
2882
  var StyleSheet = StyleSheet$1;
2881
- function useStickyScrollHandler(stickyIndices, horizontal, ctx, onScroll2) {
2883
+ function useStickyScrollHandler(stickyHeaderIndices, horizontal, ctx, onScroll2) {
2882
2884
  return useMemo(() => {
2883
- if (stickyIndices == null ? void 0 : stickyIndices.length) {
2885
+ if (stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.length) {
2884
2886
  const { animatedScrollY } = ctx;
2885
2887
  return Animated.event(
2886
2888
  [
@@ -2897,7 +2899,7 @@ function useStickyScrollHandler(stickyIndices, horizontal, ctx, onScroll2) {
2897
2899
  );
2898
2900
  }
2899
2901
  return onScroll2;
2900
- }, [stickyIndices == null ? void 0 : stickyIndices.join(","), horizontal]);
2902
+ }, [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(","), horizontal]);
2901
2903
  }
2902
2904
 
2903
2905
  // src/utils/createColumnWrapperStyle.ts
@@ -3119,7 +3121,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3119
3121
  ListHeaderComponent,
3120
3122
  maintainScrollAtEnd = false,
3121
3123
  maintainScrollAtEndThreshold = 0.1,
3122
- maintainVisibleContentPosition = true,
3124
+ maintainVisibleContentPosition = false,
3123
3125
  numColumns: numColumnsProp = 1,
3124
3126
  onEndReached,
3125
3127
  onEndReachedThreshold = 0.5,
@@ -3141,7 +3143,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3141
3143
  renderItem,
3142
3144
  scrollEventThrottle,
3143
3145
  snapToIndices,
3144
- stickyIndices,
3146
+ stickyHeaderIndices: stickyHeaderIndicesProp,
3147
+ stickyIndices: stickyIndicesDeprecated,
3145
3148
  style: styleProp,
3146
3149
  suggestEstimatedItemSize,
3147
3150
  viewabilityConfig,
@@ -3163,6 +3166,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3163
3166
  const estimatedItemSize = estimatedItemSizeProp != null ? estimatedItemSizeProp : DEFAULT_ITEM_SIZE;
3164
3167
  const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
3165
3168
  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
+ }
3166
3176
  const refState = useRef();
3167
3177
  if (!refState.current) {
3168
3178
  if (!ctx.internalState) {
@@ -3274,8 +3284,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3274
3284
  renderItem,
3275
3285
  scrollBuffer,
3276
3286
  snapToIndices,
3277
- stickyIndicesArr: stickyIndices != null ? stickyIndices : [],
3278
- stickyIndicesSet: useMemo(() => new Set(stickyIndices != null ? stickyIndices : []), [stickyIndices == null ? void 0 : stickyIndices.join(",")]),
3287
+ stickyIndicesArr: stickyHeaderIndices != null ? stickyHeaderIndices : [],
3288
+ stickyIndicesSet: useMemo(() => new Set(stickyHeaderIndices != null ? stickyHeaderIndices : []), [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(",")]),
3279
3289
  stylePaddingBottom: stylePaddingBottomState,
3280
3290
  stylePaddingTop: stylePaddingTopState,
3281
3291
  suggestEstimatedItemSize: !!suggestEstimatedItemSize
@@ -3295,7 +3305,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3295
3305
  setPaddingTop(ctx, state, { stylePaddingTop: stylePaddingTopState });
3296
3306
  refState.current.props.stylePaddingBottom = stylePaddingBottomState;
3297
3307
  let paddingDiff = stylePaddingTopState - prevPaddingTop;
3298
- if (maintainVisibleContentPosition && paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
3308
+ if (paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
3299
3309
  if (state.scroll < 0) {
3300
3310
  paddingDiff += state.scroll;
3301
3311
  }
@@ -3343,7 +3353,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3343
3353
  state.initialScroll = updatedInitialScroll;
3344
3354
  refState.current.isStartReached = clampedOffset < refState.current.scrollLength * onStartReachedThreshold;
3345
3355
  return clampedOffset;
3346
- }, [renderNum, state.initialScroll]);
3356
+ }, [renderNum]);
3347
3357
  if (isFirstLocal || didDataChangeLocal || numColumnsProp !== peek$(ctx, "numColumns")) {
3348
3358
  refState.current.lastBatchingAction = Date.now();
3349
3359
  if (!keyExtractorProp && !isFirstLocal && didDataChangeLocal) {
@@ -3383,7 +3393,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3383
3393
  precomputedWithViewOffset: true
3384
3394
  });
3385
3395
  }
3386
- }, [initialContentOffset, state.initialScroll]);
3396
+ }, [initialContentOffset]);
3387
3397
  const onLayoutChange = useCallback((layout) => {
3388
3398
  doInitialScroll();
3389
3399
  handleLayout(ctx, state, layout, setCanRender);
@@ -3450,7 +3460,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3450
3460
  }),
3451
3461
  []
3452
3462
  );
3453
- const onScrollHandler = useStickyScrollHandler(stickyIndices, horizontal, ctx, fns.onScroll);
3463
+ const onScrollHandler = useStickyScrollHandler(stickyHeaderIndices, horizontal, ctx, fns.onScroll);
3454
3464
  return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
3455
3465
  ListComponent,
3456
3466
  {
@@ -3496,7 +3506,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3496
3506
  scrollAdjustHandler: (_b = refState.current) == null ? void 0 : _b.scrollAdjustHandler,
3497
3507
  scrollEventThrottle: Platform2.OS === "web" ? 16 : void 0,
3498
3508
  snapToIndices,
3499
- stickyIndices,
3509
+ stickyHeaderIndices,
3500
3510
  style,
3501
3511
  updateItemSize: fns.updateItemSize,
3502
3512
  waitForInitialLayout
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "2.1.0-beta.12",
3
+ "version": "2.1.0-beta.13",
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,
@@ -0,0 +1,113 @@
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 };