@legendapp/list 3.0.0-beta.45 → 3.0.0-beta.47

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/react-native.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React2 from 'react';
2
2
  import React2__default, { useReducer, useEffect, createContext, useRef, useState, useMemo, useCallback, useLayoutEffect, useImperativeHandle, useContext } from 'react';
3
3
  import * as ReactNative from 'react-native';
4
- import { Animated, View as View$1, Text as Text$1, Platform, StyleSheet as StyleSheet$1, RefreshControl, Dimensions } from 'react-native';
4
+ import { Animated, View as View$1, Text as Text$1, Platform as Platform$1, StyleSheet as StyleSheet$1, RefreshControl, Dimensions } from 'react-native';
5
5
  import { useSyncExternalStore } from 'use-sync-external-store/shim';
6
6
 
7
7
  // src/components/LegendList.tsx
@@ -327,12 +327,7 @@ var PositionViewAnimated = typedMemo(function PositionViewAnimated2({
327
327
  const position$ = useValue$(`containerPosition${id}`, {
328
328
  getValue: (v) => v != null ? v : POSITION_OUT_OF_VIEW
329
329
  });
330
- let position;
331
- if (Platform.OS === "ios" || Platform.OS === "android") {
332
- position = horizontal ? { transform: [{ translateX: position$ }] } : { transform: [{ translateY: position$ }] };
333
- } else {
334
- position = horizontal ? { left: position$ } : { top: position$ };
335
- }
330
+ const position = horizontal ? { left: position$ } : { top: position$ };
336
331
  return /* @__PURE__ */ React2.createElement(Animated.View, { ref: refView, style: [style, position], ...rest });
337
332
  });
338
333
  var PositionViewSticky = typedMemo(function PositionViewSticky2({
@@ -363,12 +358,12 @@ var PositionViewSticky = typedMemo(function PositionViewSticky2({
363
358
  if (animatedScrollY) {
364
359
  const stickyConfigOffset = (_a3 = stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.offset) != null ? _a3 : 0;
365
360
  const stickyStart = position + headerSize + stylePaddingTop - stickyConfigOffset;
366
- let stickyPosition;
361
+ let nextStickyPosition;
367
362
  if (pushLimit !== void 0) {
368
363
  if (pushLimit <= position) {
369
- stickyPosition = pushLimit;
364
+ nextStickyPosition = pushLimit;
370
365
  } else {
371
- stickyPosition = animatedScrollY.interpolate({
366
+ nextStickyPosition = animatedScrollY.interpolate({
372
367
  extrapolateLeft: "clamp",
373
368
  extrapolateRight: "clamp",
374
369
  inputRange: [stickyStart, stickyStart + (pushLimit - position)],
@@ -376,16 +371,16 @@ var PositionViewSticky = typedMemo(function PositionViewSticky2({
376
371
  });
377
372
  }
378
373
  } else {
379
- stickyPosition = animatedScrollY.interpolate({
374
+ nextStickyPosition = animatedScrollY.interpolate({
380
375
  extrapolateLeft: "clamp",
381
376
  extrapolateRight: "extend",
382
377
  inputRange: [stickyStart, stickyStart + 5e3],
383
378
  outputRange: [position, position + 5e3]
384
379
  });
385
380
  }
386
- return horizontal ? [{ translateX: stickyPosition }] : [{ translateY: stickyPosition }];
381
+ return horizontal ? [{ translateX: nextStickyPosition }] : [{ translateY: nextStickyPosition }];
387
382
  }
388
- }, [animatedScrollY, headerSize, horizontal, position, pushLimit, stylePaddingTop, stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.offset]);
383
+ }, [animatedScrollY, headerSize, position, pushLimit, stylePaddingTop, stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.offset]);
389
384
  const viewStyle = React2.useMemo(() => [style, { zIndex: index + 1e3 }, { transform }], [style, transform]);
390
385
  const renderStickyHeaderBackdrop = React2.useMemo(() => {
391
386
  if (!(stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent)) {
@@ -642,8 +637,8 @@ function useOnLayoutSync({
642
637
  }
643
638
  return { onLayout };
644
639
  }
645
- var Platform2 = Platform;
646
- var PlatformAdjustBreaksScroll = Platform2.OS === "android";
640
+ var Platform = Platform$1;
641
+ var PlatformAdjustBreaksScroll = Platform.OS === "android";
647
642
 
648
643
  // src/utils/isInMVCPActiveMode.native.ts
649
644
  function isInMVCPActiveMode(state) {
@@ -764,7 +759,7 @@ var Container = typedMemo(function Container2({
764
759
  updateItemSizeFn(currentItemKey, layout);
765
760
  itemLayoutRef.current.didLayout = true;
766
761
  };
767
- const shouldDeferWebShrinkLayoutUpdate = Platform2.OS === "web" && !isInMVCPActiveMode(ctx.state) && prevSize !== void 0 && size + 1 < prevSize;
762
+ const shouldDeferWebShrinkLayoutUpdate = Platform.OS === "web" && !isInMVCPActiveMode(ctx.state) && prevSize !== void 0 && size + 1 < prevSize;
768
763
  if (shouldDeferWebShrinkLayoutUpdate) {
769
764
  const token = pendingShrinkToken + 1;
770
765
  itemLayoutRef.current.pendingShrinkToken = token;
@@ -1034,7 +1029,7 @@ var ListComponent = typedMemo(function ListComponent2({
1034
1029
  }
1035
1030
  ),
1036
1031
  ListFooterComponent && /* @__PURE__ */ React2.createElement(LayoutView, { onLayoutChange: onLayoutFooterInternal, style: ListFooterComponentStyle }, getComponent(ListFooterComponent)),
1037
- Platform2.OS === "web" && /* @__PURE__ */ React2.createElement(WebAnchoredEndSpace, { horizontal }),
1032
+ Platform.OS === "web" && /* @__PURE__ */ React2.createElement(WebAnchoredEndSpace, { horizontal }),
1038
1033
  IS_DEV && ENABLE_DEVMODE
1039
1034
  );
1040
1035
  });
@@ -1072,7 +1067,7 @@ function useDevChecksImpl(props) {
1072
1067
  const state = ctx.state;
1073
1068
  const dataLength = state.props.data.length;
1074
1069
  const useWindowScrollResolved = state.props.useWindowScroll;
1075
- if (Platform2.OS !== "web" || useWindowScrollResolved || dataLength < WEB_UNBOUNDED_HEIGHT_MIN_DATA_LENGTH) {
1070
+ if (Platform.OS !== "web" || useWindowScrollResolved || dataLength < WEB_UNBOUNDED_HEIGHT_MIN_DATA_LENGTH) {
1076
1071
  return;
1077
1072
  }
1078
1073
  const warnIfUnboundedOuterSize = () => {
@@ -1478,7 +1473,7 @@ function finishInitialScroll(ctx, options) {
1478
1473
  }
1479
1474
  const complete = () => {
1480
1475
  var _a4, _b2, _c2, _d, _e;
1481
- const shouldReleaseDeferredPublicOnScroll = Platform2.OS === "web" && ((_a4 = state.initialScrollSession) == null ? void 0 : _a4.kind) === "bootstrap";
1476
+ const shouldReleaseDeferredPublicOnScroll = Platform.OS === "web" && ((_a4 = state.initialScrollSession) == null ? void 0 : _a4.kind) === "bootstrap";
1482
1477
  const finalScrollOffset = (_d = (_c2 = (_b2 = options == null ? void 0 : options.resolvedOffset) != null ? _b2 : state.scrollPending) != null ? _c2 : state.scroll) != null ? _d : 0;
1483
1478
  initialScrollWatchdog.clear(state);
1484
1479
  if ((options == null ? void 0 : options.preserveTarget) && state.initialScroll) {
@@ -1670,7 +1665,7 @@ function clampScrollOffset(ctx, offset, scrollTarget) {
1670
1665
  const state = ctx.state;
1671
1666
  const contentSize = getContentSize(ctx);
1672
1667
  let clampedOffset = offset;
1673
- if (Number.isFinite(contentSize) && Number.isFinite(state.scrollLength) && (Platform2.OS !== "android" || state.lastLayout)) {
1668
+ if (Number.isFinite(contentSize) && Number.isFinite(state.scrollLength) && (Platform.OS !== "android" || state.lastLayout)) {
1674
1669
  const baseMaxOffset = Math.max(0, contentSize - state.scrollLength);
1675
1670
  const viewOffset = scrollTarget == null ? void 0 : scrollTarget.viewOffset;
1676
1671
  const extraEndOffset = typeof viewOffset === "number" && viewOffset < 0 ? -viewOffset : 0;
@@ -1837,7 +1832,7 @@ function checkFinishedScrollFallback(ctx) {
1837
1832
  );
1838
1833
  const completionState = getResolvedScrollCompletionState(ctx, isStillScrollingTo);
1839
1834
  const canFinishAfterSilentNativeDispatch = silentInitialDispatch && completionState.isAtResolvedTarget && numChecks >= 1;
1840
- const shouldRetrySilentInitialNativeScroll = Platform2.OS === "android" && canFinishAfterSilentNativeDispatch && !initialScrollCompletion.didRetrySilentInitialScroll(state);
1835
+ const shouldRetrySilentInitialNativeScroll = Platform.OS === "android" && canFinishAfterSilentNativeDispatch && !initialScrollCompletion.didRetrySilentInitialScroll(state);
1841
1836
  if (shouldRetrySilentInitialNativeScroll) {
1842
1837
  const targetOffset = (_b = (_a3 = getInitialScrollWatchdogTargetOffset(state)) != null ? _a3 : isStillScrollingTo.targetOffset) != null ? _b : 0;
1843
1838
  const jiggleOffset = targetOffset >= SILENT_INITIAL_SCROLL_TARGET_EPSILON ? targetOffset - SILENT_INITIAL_SCROLL_TARGET_EPSILON : targetOffset + SILENT_INITIAL_SCROLL_TARGET_EPSILON;
@@ -1955,7 +1950,7 @@ function scrollTo(ctx, params) {
1955
1950
  }
1956
1951
  state.scrollPending = targetOffset;
1957
1952
  syncInitialScrollNativeWatchdog(state, { isInitialScroll, requestedOffset: offset, targetOffset });
1958
- if (forceScroll || !isInitialScroll || Platform2.OS === "android") {
1953
+ if (forceScroll || !isInitialScroll || Platform.OS === "android") {
1959
1954
  doScrollTo(ctx, { animated, horizontal, isInitialScroll, offset });
1960
1955
  } else {
1961
1956
  state.scroll = offset;
@@ -2432,7 +2427,7 @@ function startBootstrapInitialScrollOnMount(ctx, options) {
2432
2427
  } else {
2433
2428
  startBootstrapInitialScrollSession(state, {
2434
2429
  scroll: offset,
2435
- seedContentOffset: Platform2.OS === "web" ? 0 : offset,
2430
+ seedContentOffset: Platform.OS === "web" ? 0 : offset,
2436
2431
  targetIndexSeed: target.index
2437
2432
  });
2438
2433
  ensureBootstrapInitialScrollFrameTicker(ctx);
@@ -2629,7 +2624,7 @@ function evaluateBootstrapInitialScroll(ctx) {
2629
2624
  queueBootstrapInitialScrollReevaluation(state);
2630
2625
  return;
2631
2626
  }
2632
- if (Platform2.OS !== "web" && Platform2.OS !== "android" && Math.abs(bootstrapInitialScroll.seedContentOffset - resolvedOffset) <= 1 && Math.abs(getObservedBootstrapInitialScrollOffset(state) - resolvedOffset) <= 1) {
2627
+ if (Platform.OS !== "web" && Platform.OS !== "android" && Math.abs(bootstrapInitialScroll.seedContentOffset - resolvedOffset) <= 1 && Math.abs(getObservedBootstrapInitialScrollOffset(state) - resolvedOffset) <= 1) {
2633
2628
  finishBootstrapInitialScrollWithoutScroll(ctx, resolvedOffset);
2634
2629
  } else {
2635
2630
  clearBootstrapInitialScrollSession(state);
@@ -2637,7 +2632,7 @@ function evaluateBootstrapInitialScroll(ctx) {
2637
2632
  forceScroll: true,
2638
2633
  resolvedOffset,
2639
2634
  target: initialScroll,
2640
- waitForCompletionFrame: Platform2.OS === "web"
2635
+ waitForCompletionFrame: Platform.OS === "web"
2641
2636
  });
2642
2637
  }
2643
2638
  }
@@ -2664,7 +2659,7 @@ function abortBootstrapInitialScroll(ctx) {
2664
2659
  forceScroll: true,
2665
2660
  resolvedOffset: bootstrapInitialScroll.scroll,
2666
2661
  target: initialScroll,
2667
- waitForCompletionFrame: Platform2.OS === "web"
2662
+ waitForCompletionFrame: Platform.OS === "web"
2668
2663
  });
2669
2664
  } else {
2670
2665
  finishBootstrapInitialScrollWithoutScroll(
@@ -2752,7 +2747,7 @@ function handleInitialScrollDataChange(ctx, options) {
2752
2747
  function requestAdjust(ctx, positionDiff, dataChanged) {
2753
2748
  const state = ctx.state;
2754
2749
  if (Math.abs(positionDiff) > 0.1) {
2755
- const needsScrollWorkaround = Platform2.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
2750
+ const needsScrollWorkaround = Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
2756
2751
  const doit = () => {
2757
2752
  if (needsScrollWorkaround) {
2758
2753
  scrollTo(ctx, {
@@ -2771,7 +2766,7 @@ function requestAdjust(ctx, positionDiff, dataChanged) {
2771
2766
  const readyToRender = peek$(ctx, "readyToRender");
2772
2767
  if (readyToRender) {
2773
2768
  doit();
2774
- if (Platform2.OS !== "web") {
2769
+ if (Platform.OS !== "web") {
2775
2770
  const threshold = state.scroll - positionDiff / 2;
2776
2771
  if (!state.ignoreScrollFromMVCP) {
2777
2772
  state.ignoreScrollFromMVCP = {};
@@ -2826,7 +2821,7 @@ function resolveAnchorLock(state, enableMVCPAnchorLock, mvcpData, now) {
2826
2821
  return lock;
2827
2822
  }
2828
2823
  function updateAnchorLock(state, params) {
2829
- if (Platform2.OS === "web") {
2824
+ if (Platform.OS === "web") {
2830
2825
  const { anchorId, anchorPosition, dataChanged, now, positionDiff } = params;
2831
2826
  const enableMVCPAnchorLock = !!dataChanged || !!state.mvcpAnchorLock;
2832
2827
  const mvcpData = state.props.maintainVisibleContentPosition.data;
@@ -2848,7 +2843,7 @@ function updateAnchorLock(state, params) {
2848
2843
  }
2849
2844
  }
2850
2845
  function shouldQueueNativeMVCPAdjust(dataChanged, state, positionDiff, prevTotalSize, prevScroll, scrollTarget) {
2851
- if (!dataChanged || Platform2.OS === "web" || !state.props.maintainVisibleContentPosition.data || scrollTarget !== void 0 || positionDiff >= -MVCP_POSITION_EPSILON) {
2846
+ if (!dataChanged || Platform.OS === "web" || !state.props.maintainVisibleContentPosition.data || scrollTarget !== void 0 || positionDiff >= -MVCP_POSITION_EPSILON) {
2852
2847
  return false;
2853
2848
  }
2854
2849
  const distanceFromEnd = prevTotalSize - prevScroll - state.scrollLength;
@@ -2947,7 +2942,7 @@ function prepareMVCP(ctx, dataChanged) {
2947
2942
  const {
2948
2943
  maintainVisibleContentPosition: { data: mvcpData, size: mvcpScroll, shouldRestorePosition }
2949
2944
  } = props;
2950
- const isWeb = Platform2.OS === "web";
2945
+ const isWeb = Platform.OS === "web";
2951
2946
  const now = Date.now();
2952
2947
  const enableMVCPAnchorLock = isWeb && (!!dataChanged || !!state.mvcpAnchorLock);
2953
2948
  const scrollingTo = state.scrollingTo;
@@ -3362,7 +3357,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
3362
3357
  const layoutConfig = overrideItemLayout ? { span: 1 } : void 0;
3363
3358
  const lastScrollDelta = state.lastScrollDelta;
3364
3359
  const velocity = getScrollVelocity(state);
3365
- const shouldOptimize = !forceFullUpdate && !dataChanged && (optimizeForVisibleWindow || Math.abs(velocity) > 0 || Platform2.OS === "web" && state.scrollLength > 0 && lastScrollDelta > state.scrollLength);
3360
+ const shouldOptimize = !forceFullUpdate && !dataChanged && (optimizeForVisibleWindow || Math.abs(velocity) > 0 || Platform.OS === "web" && state.scrollLength > 0 && lastScrollDelta > state.scrollLength);
3366
3361
  const maxVisibleArea = scrollBottomBuffered + 1e3;
3367
3362
  const useAverageSize = !getEstimatedItemSize;
3368
3363
  const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_b = peek$(ctx, "scrollAdjustPending")) != null ? _b : 0) !== 0;
@@ -3701,6 +3696,7 @@ function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pen
3701
3696
  const numContainers = peek$(ctx, "numContainers");
3702
3697
  const state = ctx.state;
3703
3698
  const { stickyContainerPool, containerItemTypes } = state;
3699
+ const shouldAvoidAssignedContainerReuse = state.props.recycleItems && !!state.props.positionComponentInternal;
3704
3700
  const result = [];
3705
3701
  const availableContainers = [];
3706
3702
  const pendingRemovalSet = new Set(pendingRemoval);
@@ -3757,18 +3753,20 @@ function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pen
3757
3753
  }
3758
3754
  }
3759
3755
  }
3760
- for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
3761
- if (stickyContainerPool.has(u)) {
3762
- continue;
3763
- }
3764
- const key = peek$(ctx, `containerItemKey${u}`);
3765
- if (key === void 0) continue;
3766
- const index = state.indexByKey.get(key);
3767
- const isOutOfView = index < startBuffered || index > endBuffered;
3768
- if (isOutOfView) {
3769
- const distance = index < startBuffered ? startBuffered - index : index - endBuffered;
3770
- if (!requiredItemTypes || typeIndex < neededTypes.length && canReuseContainer(u, neededTypes[typeIndex])) {
3771
- availableContainers.push({ distance, index: u });
3756
+ if (!shouldAvoidAssignedContainerReuse) {
3757
+ for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
3758
+ if (stickyContainerPool.has(u)) {
3759
+ continue;
3760
+ }
3761
+ const key = peek$(ctx, `containerItemKey${u}`);
3762
+ if (key === void 0) continue;
3763
+ const index = state.indexByKey.get(key);
3764
+ const isOutOfView = index < startBuffered || index > endBuffered;
3765
+ if (isOutOfView) {
3766
+ const distance = index < startBuffered ? startBuffered - index : index - endBuffered;
3767
+ if (!requiredItemTypes || typeIndex < neededTypes.length && canReuseContainer(u, neededTypes[typeIndex])) {
3768
+ availableContainers.push({ distance, index: u });
3769
+ }
3772
3770
  }
3773
3771
  }
3774
3772
  }
@@ -3973,7 +3971,7 @@ function calculateItemsInView(ctx, params = {}) {
3973
3971
  if (top === null && bottom === null) {
3974
3972
  state.scrollForNextCalculateItemsInView = void 0;
3975
3973
  } else if ((top === null || scrollTopBuffered > top) && (bottom === null || scrollBottomBuffered < bottom)) {
3976
- if (Platform2.OS !== "web" || !isInMVCPActiveMode(state)) {
3974
+ if (Platform.OS !== "web" || !isInMVCPActiveMode(state)) {
3977
3975
  return;
3978
3976
  }
3979
3977
  }
@@ -4247,7 +4245,7 @@ function calculateItemsInView(ctx, params = {}) {
4247
4245
  }
4248
4246
  }
4249
4247
  }
4250
- if (Platform2.OS === "web" && didChangePositions) {
4248
+ if (Platform.OS === "web" && didChangePositions) {
4251
4249
  set$(ctx, "lastPositionUpdate", Date.now());
4252
4250
  }
4253
4251
  if (suppressInitialScrollSideEffects) {
@@ -4561,7 +4559,7 @@ function updateScroll(ctx, newScroll, forceUpdate) {
4561
4559
  (_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state, { doMVCP: scrollingTo !== void 0 });
4562
4560
  checkThresholds(ctx);
4563
4561
  };
4564
- if (Platform2.OS === "web" && scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength) {
4562
+ if (Platform.OS === "web" && scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength) {
4565
4563
  flushSync(runCalculateItems);
4566
4564
  } else {
4567
4565
  runCalculateItems();
@@ -4594,7 +4592,7 @@ function trackInitialScrollNativeProgress(state, newScroll) {
4594
4592
  }
4595
4593
  function shouldDeferPublicOnScroll(state) {
4596
4594
  var _a3;
4597
- return Platform2.OS === "web" && !!state.initialScroll && ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "bootstrap" && !state.didFinishInitialScroll;
4595
+ return Platform.OS === "web" && !!state.initialScroll && ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "bootstrap" && !state.didFinishInitialScroll;
4598
4596
  }
4599
4597
  function cloneScrollEvent(event) {
4600
4598
  return {
@@ -4744,7 +4742,7 @@ function maybeUpdateAnchoredEndSpace(ctx) {
4744
4742
  // src/core/updateItemSize.ts
4745
4743
  function runOrScheduleMVCPRecalculate(ctx) {
4746
4744
  const state = ctx.state;
4747
- if (Platform2.OS === "web") {
4745
+ if (Platform.OS === "web") {
4748
4746
  if (!state.mvcpAnchorLock) {
4749
4747
  if (state.queuedMVCPRecalculate !== void 0) {
4750
4748
  cancelAnimationFrame(state.queuedMVCPRecalculate);
@@ -4870,7 +4868,7 @@ function updateOneItemSize(ctx, itemKey, sizeObj) {
4870
4868
  const index = indexByKey.get(itemKey);
4871
4869
  const prevSize = getItemSize(ctx, itemKey, index, data[index]);
4872
4870
  const rawSize = horizontal ? sizeObj.width : sizeObj.height;
4873
- const size = Platform2.OS === "web" ? Math.round(rawSize) : roundSize(rawSize);
4871
+ const size = Platform.OS === "web" ? Math.round(rawSize) : roundSize(rawSize);
4874
4872
  const prevSizeKnown = sizesKnown.get(itemKey);
4875
4873
  sizesKnown.set(itemKey, size);
4876
4874
  if (!getEstimatedItemSize && !getFixedItemSize && size > 0) {
@@ -5494,7 +5492,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5494
5492
  dataVersion,
5495
5493
  keyExtractor
5496
5494
  ]);
5497
- const useWindowScrollResolved = Platform2.OS === "web" && !!useWindowScroll && !renderScrollComponent;
5495
+ const useWindowScrollResolved = Platform.OS === "web" && !!useWindowScroll && !renderScrollComponent;
5498
5496
  const refState = useRef(void 0);
5499
5497
  const hasOverrideItemLayout = !!overrideItemLayout;
5500
5498
  const prevHasOverrideItemLayout = useRef(hasOverrideItemLayout);
@@ -5590,7 +5588,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5590
5588
  }
5591
5589
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
5592
5590
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
5593
- const anchoredEndSpaceResolved = Platform2.OS === "web" && anchoredEndSpace ? { ...anchoredEndSpace, includeInEndInset: true } : anchoredEndSpace;
5591
+ const anchoredEndSpaceResolved = Platform.OS === "web" && anchoredEndSpace ? { ...anchoredEndSpace, includeInEndInset: true } : anchoredEndSpace;
5594
5592
  state.props = {
5595
5593
  alignItemsAtEnd,
5596
5594
  alwaysRender,
@@ -5650,7 +5648,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5650
5648
  setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
5651
5649
  refState.current.props.stylePaddingBottom = stylePaddingBottomState;
5652
5650
  let paddingDiff = stylePaddingTopState - prevPaddingTop;
5653
- if (shouldAdjustPadding && maintainVisibleContentPositionConfig.size && paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
5651
+ if (shouldAdjustPadding && maintainVisibleContentPositionConfig.size && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
5654
5652
  if (state.scroll < 0) {
5655
5653
  paddingDiff += state.scroll;
5656
5654
  }
@@ -5672,7 +5670,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5672
5670
  return void 0;
5673
5671
  }
5674
5672
  const resolvedOffset = (_a4 = initialScroll.contentOffset) != null ? _a4 : resolveInitialScrollOffset(ctx, initialScroll);
5675
- return usesBootstrapInitialScroll && ((_b2 = state.initialScrollSession) == null ? void 0 : _b2.kind) === "bootstrap" && Platform2.OS === "web" ? void 0 : resolvedOffset;
5673
+ return usesBootstrapInitialScroll && ((_b2 = state.initialScrollSession) == null ? void 0 : _b2.kind) === "bootstrap" && Platform.OS === "web" ? void 0 : resolvedOffset;
5676
5674
  }, [usesBootstrapInitialScroll]);
5677
5675
  useLayoutEffect(() => {
5678
5676
  initializeInitialScrollOnMount(ctx, {
@@ -5827,7 +5825,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5827
5825
  });
5828
5826
  useImperativeHandle(forwardedRef, () => createImperativeHandle(ctx), []);
5829
5827
  useEffect(() => {
5830
- if (Platform2.OS !== "web" || usesBootstrapInitialScroll) {
5828
+ if (Platform.OS !== "web" || usesBootstrapInitialScroll) {
5831
5829
  return;
5832
5830
  }
5833
5831
  advanceCurrentInitialScrollSession(ctx);
@@ -4251,6 +4251,7 @@ function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pen
4251
4251
  const numContainers = peek$(ctx, "numContainers");
4252
4252
  const state = ctx.state;
4253
4253
  const { stickyContainerPool, containerItemTypes } = state;
4254
+ const shouldAvoidAssignedContainerReuse = state.props.recycleItems && !!state.props.positionComponentInternal;
4254
4255
  const result = [];
4255
4256
  const availableContainers = [];
4256
4257
  const pendingRemovalSet = new Set(pendingRemoval);
@@ -4307,18 +4308,20 @@ function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pen
4307
4308
  }
4308
4309
  }
4309
4310
  }
4310
- for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
4311
- if (stickyContainerPool.has(u)) {
4312
- continue;
4313
- }
4314
- const key = peek$(ctx, `containerItemKey${u}`);
4315
- if (key === void 0) continue;
4316
- const index = state.indexByKey.get(key);
4317
- const isOutOfView = index < startBuffered || index > endBuffered;
4318
- if (isOutOfView) {
4319
- const distance = index < startBuffered ? startBuffered - index : index - endBuffered;
4320
- if (!requiredItemTypes || typeIndex < neededTypes.length && canReuseContainer(u, neededTypes[typeIndex])) {
4321
- availableContainers.push({ distance, index: u });
4311
+ if (!shouldAvoidAssignedContainerReuse) {
4312
+ for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
4313
+ if (stickyContainerPool.has(u)) {
4314
+ continue;
4315
+ }
4316
+ const key = peek$(ctx, `containerItemKey${u}`);
4317
+ if (key === void 0) continue;
4318
+ const index = state.indexByKey.get(key);
4319
+ const isOutOfView = index < startBuffered || index > endBuffered;
4320
+ if (isOutOfView) {
4321
+ const distance = index < startBuffered ? startBuffered - index : index - endBuffered;
4322
+ if (!requiredItemTypes || typeIndex < neededTypes.length && canReuseContainer(u, neededTypes[typeIndex])) {
4323
+ availableContainers.push({ distance, index: u });
4324
+ }
4322
4325
  }
4323
4326
  }
4324
4327
  }
@@ -4230,6 +4230,7 @@ function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pen
4230
4230
  const numContainers = peek$(ctx, "numContainers");
4231
4231
  const state = ctx.state;
4232
4232
  const { stickyContainerPool, containerItemTypes } = state;
4233
+ const shouldAvoidAssignedContainerReuse = state.props.recycleItems && !!state.props.positionComponentInternal;
4233
4234
  const result = [];
4234
4235
  const availableContainers = [];
4235
4236
  const pendingRemovalSet = new Set(pendingRemoval);
@@ -4286,18 +4287,20 @@ function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pen
4286
4287
  }
4287
4288
  }
4288
4289
  }
4289
- for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
4290
- if (stickyContainerPool.has(u)) {
4291
- continue;
4292
- }
4293
- const key = peek$(ctx, `containerItemKey${u}`);
4294
- if (key === void 0) continue;
4295
- const index = state.indexByKey.get(key);
4296
- const isOutOfView = index < startBuffered || index > endBuffered;
4297
- if (isOutOfView) {
4298
- const distance = index < startBuffered ? startBuffered - index : index - endBuffered;
4299
- if (!requiredItemTypes || typeIndex < neededTypes.length && canReuseContainer(u, neededTypes[typeIndex])) {
4300
- availableContainers.push({ distance, index: u });
4290
+ if (!shouldAvoidAssignedContainerReuse) {
4291
+ for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
4292
+ if (stickyContainerPool.has(u)) {
4293
+ continue;
4294
+ }
4295
+ const key = peek$(ctx, `containerItemKey${u}`);
4296
+ if (key === void 0) continue;
4297
+ const index = state.indexByKey.get(key);
4298
+ const isOutOfView = index < startBuffered || index > endBuffered;
4299
+ if (isOutOfView) {
4300
+ const distance = index < startBuffered ? startBuffered - index : index - endBuffered;
4301
+ if (!requiredItemTypes || typeIndex < neededTypes.length && canReuseContainer(u, neededTypes[typeIndex])) {
4302
+ availableContainers.push({ distance, index: u });
4303
+ }
4301
4304
  }
4302
4305
  }
4303
4306
  }
package/react.js CHANGED
@@ -4251,6 +4251,7 @@ function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pen
4251
4251
  const numContainers = peek$(ctx, "numContainers");
4252
4252
  const state = ctx.state;
4253
4253
  const { stickyContainerPool, containerItemTypes } = state;
4254
+ const shouldAvoidAssignedContainerReuse = state.props.recycleItems && !!state.props.positionComponentInternal;
4254
4255
  const result = [];
4255
4256
  const availableContainers = [];
4256
4257
  const pendingRemovalSet = new Set(pendingRemoval);
@@ -4307,18 +4308,20 @@ function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pen
4307
4308
  }
4308
4309
  }
4309
4310
  }
4310
- for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
4311
- if (stickyContainerPool.has(u)) {
4312
- continue;
4313
- }
4314
- const key = peek$(ctx, `containerItemKey${u}`);
4315
- if (key === void 0) continue;
4316
- const index = state.indexByKey.get(key);
4317
- const isOutOfView = index < startBuffered || index > endBuffered;
4318
- if (isOutOfView) {
4319
- const distance = index < startBuffered ? startBuffered - index : index - endBuffered;
4320
- if (!requiredItemTypes || typeIndex < neededTypes.length && canReuseContainer(u, neededTypes[typeIndex])) {
4321
- availableContainers.push({ distance, index: u });
4311
+ if (!shouldAvoidAssignedContainerReuse) {
4312
+ for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
4313
+ if (stickyContainerPool.has(u)) {
4314
+ continue;
4315
+ }
4316
+ const key = peek$(ctx, `containerItemKey${u}`);
4317
+ if (key === void 0) continue;
4318
+ const index = state.indexByKey.get(key);
4319
+ const isOutOfView = index < startBuffered || index > endBuffered;
4320
+ if (isOutOfView) {
4321
+ const distance = index < startBuffered ? startBuffered - index : index - endBuffered;
4322
+ if (!requiredItemTypes || typeIndex < neededTypes.length && canReuseContainer(u, neededTypes[typeIndex])) {
4323
+ availableContainers.push({ distance, index: u });
4324
+ }
4322
4325
  }
4323
4326
  }
4324
4327
  }
package/react.mjs CHANGED
@@ -4230,6 +4230,7 @@ function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pen
4230
4230
  const numContainers = peek$(ctx, "numContainers");
4231
4231
  const state = ctx.state;
4232
4232
  const { stickyContainerPool, containerItemTypes } = state;
4233
+ const shouldAvoidAssignedContainerReuse = state.props.recycleItems && !!state.props.positionComponentInternal;
4233
4234
  const result = [];
4234
4235
  const availableContainers = [];
4235
4236
  const pendingRemovalSet = new Set(pendingRemoval);
@@ -4286,18 +4287,20 @@ function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pen
4286
4287
  }
4287
4288
  }
4288
4289
  }
4289
- for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
4290
- if (stickyContainerPool.has(u)) {
4291
- continue;
4292
- }
4293
- const key = peek$(ctx, `containerItemKey${u}`);
4294
- if (key === void 0) continue;
4295
- const index = state.indexByKey.get(key);
4296
- const isOutOfView = index < startBuffered || index > endBuffered;
4297
- if (isOutOfView) {
4298
- const distance = index < startBuffered ? startBuffered - index : index - endBuffered;
4299
- if (!requiredItemTypes || typeIndex < neededTypes.length && canReuseContainer(u, neededTypes[typeIndex])) {
4300
- availableContainers.push({ distance, index: u });
4290
+ if (!shouldAvoidAssignedContainerReuse) {
4291
+ for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
4292
+ if (stickyContainerPool.has(u)) {
4293
+ continue;
4294
+ }
4295
+ const key = peek$(ctx, `containerItemKey${u}`);
4296
+ if (key === void 0) continue;
4297
+ const index = state.indexByKey.get(key);
4298
+ const isOutOfView = index < startBuffered || index > endBuffered;
4299
+ if (isOutOfView) {
4300
+ const distance = index < startBuffered ? startBuffered - index : index - endBuffered;
4301
+ if (!requiredItemTypes || typeIndex < neededTypes.length && canReuseContainer(u, neededTypes[typeIndex])) {
4302
+ availableContainers.push({ distance, index: u });
4303
+ }
4301
4304
  }
4302
4305
  }
4303
4306
  }
package/reanimated.js CHANGED
@@ -89,15 +89,15 @@ var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStic
89
89
  );
90
90
  const stickyOffset = (_a = stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.offset) != null ? _a : 0;
91
91
  const stickyStart = position + headerSize + stylePaddingTop - stickyOffset;
92
- const transformStyle = Reanimated.useAnimatedStyle(() => {
92
+ const stickyPositionStyle = Reanimated.useAnimatedStyle(() => {
93
93
  const delta = Math.max(0, stickyScrollOffset.value - stickyStart);
94
94
  const stickyPosition = position + delta;
95
95
  const resolvedPosition = pushLimit !== void 0 ? Math.min(stickyPosition, pushLimit) : stickyPosition;
96
96
  return horizontal ? { transform: [{ translateX: resolvedPosition }] } : { transform: [{ translateY: resolvedPosition }] };
97
97
  }, [horizontal, position, pushLimit, stickyStart]);
98
98
  const viewStyle = React__namespace.useMemo(
99
- () => [style, { zIndex: index + 1e3 }, transformStyle],
100
- [index, style, transformStyle]
99
+ () => [style, { zIndex: index + 1e3 }, stickyPositionStyle],
100
+ [index, stickyPositionStyle, style]
101
101
  );
102
102
  return /* @__PURE__ */ React__namespace.createElement(Reanimated__default.default.View, { ref: refView, style: viewStyle, ...rest }, /* @__PURE__ */ React__namespace.createElement(StickyOverlay, { stickyHeaderConfig }), children);
103
103
  });
package/reanimated.mjs CHANGED
@@ -65,15 +65,15 @@ var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStic
65
65
  );
66
66
  const stickyOffset = (_a = stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.offset) != null ? _a : 0;
67
67
  const stickyStart = position + headerSize + stylePaddingTop - stickyOffset;
68
- const transformStyle = useAnimatedStyle(() => {
68
+ const stickyPositionStyle = useAnimatedStyle(() => {
69
69
  const delta = Math.max(0, stickyScrollOffset.value - stickyStart);
70
70
  const stickyPosition = position + delta;
71
71
  const resolvedPosition = pushLimit !== void 0 ? Math.min(stickyPosition, pushLimit) : stickyPosition;
72
72
  return horizontal ? { transform: [{ translateX: resolvedPosition }] } : { transform: [{ translateY: resolvedPosition }] };
73
73
  }, [horizontal, position, pushLimit, stickyStart]);
74
74
  const viewStyle = React.useMemo(
75
- () => [style, { zIndex: index + 1e3 }, transformStyle],
76
- [index, style, transformStyle]
75
+ () => [style, { zIndex: index + 1e3 }, stickyPositionStyle],
76
+ [index, stickyPositionStyle, style]
77
77
  );
78
78
  return /* @__PURE__ */ React.createElement(Reanimated.View, { ref: refView, style: viewStyle, ...rest }, /* @__PURE__ */ React.createElement(StickyOverlay, { stickyHeaderConfig }), children);
79
79
  });