@legendapp/list 3.0.0-beta.50 → 3.0.0-beta.52

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.
@@ -5082,12 +5082,14 @@ function handleLayout(ctx, layoutParam, setCanRender) {
5082
5082
  }
5083
5083
 
5084
5084
  // src/core/updateScroll.ts
5085
- function updateScroll(ctx, newScroll, forceUpdate) {
5085
+ function updateScroll(ctx, newScroll, forceUpdate, options) {
5086
5086
  var _a3;
5087
5087
  const state = ctx.state;
5088
5088
  const { ignoreScrollFromMVCP, lastScrollAdjustForHistory, scrollAdjustHandler, scrollHistory, scrollingTo } = state;
5089
5089
  const prevScroll = state.scroll;
5090
- state.hasScrolled = true;
5090
+ if ((options == null ? void 0 : options.markHasScrolled) !== false) {
5091
+ state.hasScrolled = true;
5092
+ }
5091
5093
  state.lastBatchingAction = Date.now();
5092
5094
  const currentTime = Date.now();
5093
5095
  const adjust = scrollAdjustHandler.getAdjust();
@@ -5306,13 +5308,12 @@ function maybeUpdateAnchoredEndSpace(ctx) {
5306
5308
  nextSize = Math.max(0, state.scrollLength - contentBelowAnchor - anchorOffset);
5307
5309
  }
5308
5310
  }
5309
- if (previousSize === nextSize) {
5310
- return nextSize;
5311
- }
5312
- set$(ctx, "anchoredEndSpaceSize", nextSize);
5313
- (_a3 = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onSizeChanged) == null ? void 0 : _a3.call(anchoredEndSpace, nextSize);
5314
- if (anchoredEndSpace == null ? void 0 : anchoredEndSpace.includeInEndInset) {
5315
- updateScroll(ctx, state.scroll, true);
5311
+ if (previousSize !== nextSize) {
5312
+ set$(ctx, "anchoredEndSpaceSize", nextSize);
5313
+ (_a3 = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onSizeChanged) == null ? void 0 : _a3.call(anchoredEndSpace, nextSize);
5314
+ if (anchoredEndSpace == null ? void 0 : anchoredEndSpace.includeInEndInset) {
5315
+ updateScroll(ctx, state.scroll, true);
5316
+ }
5316
5317
  }
5317
5318
  return nextSize;
5318
5319
  }
@@ -5541,14 +5542,14 @@ function createImperativeHandle(ctx) {
5541
5542
  const IMPERATIVE_SCROLL_SETTLE_STABLE_FRAMES = 2;
5542
5543
  let imperativeScrollToken = 0;
5543
5544
  const isSettlingAfterDataChange = () => !!state.didDataChange || !!state.didColumnsChange || state.queuedMVCPRecalculate !== void 0 || state.ignoreScrollFromMVCP !== void 0;
5544
- const runWhenSettled = (token, run) => {
5545
+ const runWhenReady = (token, run, isReady) => {
5545
5546
  const startedAt = Date.now();
5546
5547
  let stableFrames = 0;
5547
5548
  const check = () => {
5548
5549
  if (token !== imperativeScrollToken) {
5549
5550
  return;
5550
5551
  }
5551
- if (isSettlingAfterDataChange()) {
5552
+ if (isSettlingAfterDataChange() || !isReady()) {
5552
5553
  stableFrames = 0;
5553
5554
  } else {
5554
5555
  stableFrames += 1;
@@ -5563,10 +5564,10 @@ function createImperativeHandle(ctx) {
5563
5564
  requestAnimationFrame(check);
5564
5565
  };
5565
5566
  const runScrollWithPromise = (run, options) => new Promise((resolve) => {
5566
- var _a3;
5567
+ var _a3, _b;
5567
5568
  const token = ++imperativeScrollToken;
5568
- const shouldWaitOneFrame = !!(options == null ? void 0 : options.shouldWaitOneFrame);
5569
- (_a3 = state.pendingScrollResolve) == null ? void 0 : _a3.call(state);
5569
+ const isReady = (_a3 = options == null ? void 0 : options.isReady) != null ? _a3 : (() => true);
5570
+ (_b = state.pendingScrollResolve) == null ? void 0 : _b.call(state);
5570
5571
  state.pendingScrollResolve = resolve;
5571
5572
  const runNow = () => {
5572
5573
  if (token !== imperativeScrollToken) {
@@ -5580,11 +5581,10 @@ function createImperativeHandle(ctx) {
5580
5581
  resolve();
5581
5582
  }
5582
5583
  };
5583
- const execute = shouldWaitOneFrame ? () => requestAnimationFrame(runNow) : runNow;
5584
- if (isSettlingAfterDataChange()) {
5585
- runWhenSettled(token, execute);
5584
+ if (isSettlingAfterDataChange() || !isReady()) {
5585
+ runWhenReady(token, runNow, isReady);
5586
5586
  } else {
5587
- execute();
5587
+ runNow();
5588
5588
  }
5589
5589
  });
5590
5590
  const scrollIndexIntoView = (options) => {
@@ -5666,7 +5666,7 @@ function createImperativeHandle(ctx) {
5666
5666
  }),
5667
5667
  reportContentInset: (inset) => {
5668
5668
  state.contentInsetOverride = inset != null ? inset : void 0;
5669
- updateScroll(ctx, state.scroll, true);
5669
+ updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
5670
5670
  },
5671
5671
  scrollIndexIntoView: (options) => runScrollWithPromise(() => scrollIndexIntoView(options)),
5672
5672
  scrollItemIntoView: ({ item, ...props }) => runScrollWithPromise(() => {
@@ -5695,15 +5695,24 @@ function createImperativeHandle(ctx) {
5695
5695
  }
5696
5696
  return false;
5697
5697
  }),
5698
- scrollToIndex: (params) => runScrollWithPromise(
5699
- () => {
5698
+ scrollToIndex: (params) => {
5699
+ const shouldWaitForOutOfRangeTarget = params.index >= 0 && params.index >= state.props.data.length;
5700
+ const options = shouldWaitForOutOfRangeTarget ? {
5701
+ isReady: () => {
5702
+ var _a3;
5703
+ const props = state.props;
5704
+ const anchorIndex = (_a3 = props.anchoredEndSpace) == null ? void 0 : _a3.anchorIndex;
5705
+ const lastIndex = props.data.length - 1;
5706
+ const isInRange = params.index < props.data.length;
5707
+ const shouldWaitForAnchorSize = isInRange && anchorIndex !== void 0 && anchorIndex >= 0 && params.index >= anchorIndex && !props.getFixedItemSize && !state.sizesKnown.has(getId(state, lastIndex));
5708
+ return isInRange && !shouldWaitForAnchorSize;
5709
+ }
5710
+ } : void 0;
5711
+ return runScrollWithPromise(() => {
5700
5712
  scrollToIndex(ctx, params);
5701
5713
  return true;
5702
- },
5703
- {
5704
- shouldWaitOneFrame: params.index >= 0 && params.index >= state.props.data.length
5705
- }
5706
- ),
5714
+ }, options);
5715
+ },
5707
5716
  scrollToItem: ({ item, ...props }) => runScrollWithPromise(() => {
5708
5717
  const data = state.props.data;
5709
5718
  const index = data.indexOf(item);
@@ -5735,32 +5744,32 @@ var addIndex = (result, dataLength, index) => {
5735
5744
  result.add(index);
5736
5745
  }
5737
5746
  };
5738
- function getAlwaysRenderIndices(config, data, keyExtractor) {
5747
+ function getAlwaysRenderIndices(config, data, keyExtractor, anchoredEndSpaceAnchorIndex) {
5739
5748
  var _a3, _b;
5740
- if (!config || data.length === 0) {
5749
+ if (data.length === 0) {
5741
5750
  return [];
5742
5751
  }
5743
5752
  const result = /* @__PURE__ */ new Set();
5744
5753
  const dataLength = data.length;
5745
- const topCount = toCount(config.top);
5754
+ const topCount = toCount(config == null ? void 0 : config.top);
5746
5755
  if (topCount > 0) {
5747
5756
  for (let i = 0; i < Math.min(topCount, dataLength); i++) {
5748
5757
  addIndex(result, dataLength, i);
5749
5758
  }
5750
5759
  }
5751
- const bottomCount = toCount(config.bottom);
5760
+ const bottomCount = toCount(config == null ? void 0 : config.bottom);
5752
5761
  if (bottomCount > 0) {
5753
5762
  for (let i = Math.max(0, dataLength - bottomCount); i < dataLength; i++) {
5754
5763
  addIndex(result, dataLength, i);
5755
5764
  }
5756
5765
  }
5757
- if ((_a3 = config.indices) == null ? void 0 : _a3.length) {
5766
+ if ((_a3 = config == null ? void 0 : config.indices) == null ? void 0 : _a3.length) {
5758
5767
  for (const index of config.indices) {
5759
5768
  if (!Number.isFinite(index)) continue;
5760
5769
  addIndex(result, dataLength, Math.floor(index));
5761
5770
  }
5762
5771
  }
5763
- if ((_b = config.keys) == null ? void 0 : _b.length) {
5772
+ if ((_b = config == null ? void 0 : config.keys) == null ? void 0 : _b.length) {
5764
5773
  const keys = new Set(config.keys);
5765
5774
  for (let i = 0; i < dataLength && keys.size > 0; i++) {
5766
5775
  const key = keyExtractor(data[i], i);
@@ -5770,6 +5779,12 @@ function getAlwaysRenderIndices(config, data, keyExtractor) {
5770
5779
  }
5771
5780
  }
5772
5781
  }
5782
+ if (anchoredEndSpaceAnchorIndex !== void 0 && Number.isFinite(anchoredEndSpaceAnchorIndex)) {
5783
+ const anchorIndex = Math.floor(anchoredEndSpaceAnchorIndex);
5784
+ for (let i = anchorIndex >= 0 ? anchorIndex : dataLength; i < dataLength; i++) {
5785
+ addIndex(result, dataLength, i);
5786
+ }
5787
+ }
5773
5788
  const indices = Array.from(result);
5774
5789
  indices.sort(sortAsc);
5775
5790
  return indices;
@@ -5933,7 +5948,7 @@ var LegendList = typedMemo(
5933
5948
  })
5934
5949
  );
5935
5950
  var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
5936
- var _a3, _b, _c, _d, _e, _f, _g, _h;
5951
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
5937
5952
  const noopOnScroll = useCallback((_event) => {
5938
5953
  }, []);
5939
5954
  if (props.recycleItems === void 0) {
@@ -6062,9 +6077,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6062
6077
  const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
6063
6078
  const stickyHeaderIndices = stickyHeaderIndicesProp != null ? stickyHeaderIndicesProp : stickyIndicesDeprecated;
6064
6079
  const alwaysRenderIndices = useMemo(() => {
6065
- const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor);
6080
+ const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
6066
6081
  return { arr: indices, set: new Set(indices) };
6067
6082
  }, [
6083
+ anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
6068
6084
  alwaysRender == null ? void 0 : alwaysRender.top,
6069
6085
  alwaysRender == null ? void 0 : alwaysRender.bottom,
6070
6086
  (_d = alwaysRender == null ? void 0 : alwaysRender.indices) == null ? void 0 : _d.join(","),
@@ -6170,6 +6186,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6170
6186
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
6171
6187
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
6172
6188
  const anchoredEndSpaceResolved = anchoredEndSpace ? { ...anchoredEndSpace, includeInEndInset: true } : anchoredEndSpace;
6189
+ const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_g = state.props.anchoredEndSpace) == null ? void 0 : _g.anchorIndex) !== (anchoredEndSpaceResolved == null ? void 0 : anchoredEndSpaceResolved.anchorIndex);
6173
6190
  state.props = {
6174
6191
  alignItemsAtEnd,
6175
6192
  alwaysRender,
@@ -6279,6 +6296,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6279
6296
  });
6280
6297
  }, [dataProp.length, didDataChangeLocal, initialScrollAtEnd, stylePaddingBottomState, usesBootstrapInitialScroll]);
6281
6298
  useLayoutEffect(() => {
6299
+ var _a4;
6300
+ if (didAnchoredEndSpaceAnchorIndexChange) {
6301
+ state.scrollForNextCalculateItemsInView = void 0;
6302
+ (_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state);
6303
+ }
6282
6304
  maybeUpdateAnchoredEndSpace(ctx);
6283
6305
  }, [
6284
6306
  ctx,
@@ -6287,6 +6309,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6287
6309
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
6288
6310
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorMaxSize,
6289
6311
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorOffset,
6312
+ didAnchoredEndSpaceAnchorIndexChange,
6290
6313
  numColumnsProp
6291
6314
  ]);
6292
6315
  const onLayoutFooter = useCallback(
@@ -6440,7 +6463,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6440
6463
  onScroll: onScrollHandler,
6441
6464
  recycleItems,
6442
6465
  refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React3.cloneElement(refreshControlElement, {
6443
- progressViewOffset: ((_g = refreshControlElement.props.progressViewOffset) != null ? _g : 0) + stylePaddingTopState
6466
+ progressViewOffset: ((_h = refreshControlElement.props.progressViewOffset) != null ? _h : 0) + stylePaddingTopState
6444
6467
  }) : refreshControlElement : onRefresh && /* @__PURE__ */ React3.createElement(
6445
6468
  RefreshControl,
6446
6469
  {
@@ -6451,7 +6474,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6451
6474
  ),
6452
6475
  refScrollView: combinedRef,
6453
6476
  renderScrollComponent,
6454
- scrollAdjustHandler: (_h = refState.current) == null ? void 0 : _h.scrollAdjustHandler,
6477
+ scrollAdjustHandler: (_i = refState.current) == null ? void 0 : _i.scrollAdjustHandler,
6455
6478
  scrollEventThrottle: 0,
6456
6479
  snapToIndices,
6457
6480
  stickyHeaderIndices,
package/react.js CHANGED
@@ -5103,12 +5103,14 @@ function handleLayout(ctx, layoutParam, setCanRender) {
5103
5103
  }
5104
5104
 
5105
5105
  // src/core/updateScroll.ts
5106
- function updateScroll(ctx, newScroll, forceUpdate) {
5106
+ function updateScroll(ctx, newScroll, forceUpdate, options) {
5107
5107
  var _a3;
5108
5108
  const state = ctx.state;
5109
5109
  const { ignoreScrollFromMVCP, lastScrollAdjustForHistory, scrollAdjustHandler, scrollHistory, scrollingTo } = state;
5110
5110
  const prevScroll = state.scroll;
5111
- state.hasScrolled = true;
5111
+ if ((options == null ? void 0 : options.markHasScrolled) !== false) {
5112
+ state.hasScrolled = true;
5113
+ }
5112
5114
  state.lastBatchingAction = Date.now();
5113
5115
  const currentTime = Date.now();
5114
5116
  const adjust = scrollAdjustHandler.getAdjust();
@@ -5327,13 +5329,12 @@ function maybeUpdateAnchoredEndSpace(ctx) {
5327
5329
  nextSize = Math.max(0, state.scrollLength - contentBelowAnchor - anchorOffset);
5328
5330
  }
5329
5331
  }
5330
- if (previousSize === nextSize) {
5331
- return nextSize;
5332
- }
5333
- set$(ctx, "anchoredEndSpaceSize", nextSize);
5334
- (_a3 = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onSizeChanged) == null ? void 0 : _a3.call(anchoredEndSpace, nextSize);
5335
- if (anchoredEndSpace == null ? void 0 : anchoredEndSpace.includeInEndInset) {
5336
- updateScroll(ctx, state.scroll, true);
5332
+ if (previousSize !== nextSize) {
5333
+ set$(ctx, "anchoredEndSpaceSize", nextSize);
5334
+ (_a3 = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onSizeChanged) == null ? void 0 : _a3.call(anchoredEndSpace, nextSize);
5335
+ if (anchoredEndSpace == null ? void 0 : anchoredEndSpace.includeInEndInset) {
5336
+ updateScroll(ctx, state.scroll, true);
5337
+ }
5337
5338
  }
5338
5339
  return nextSize;
5339
5340
  }
@@ -5562,14 +5563,14 @@ function createImperativeHandle(ctx) {
5562
5563
  const IMPERATIVE_SCROLL_SETTLE_STABLE_FRAMES = 2;
5563
5564
  let imperativeScrollToken = 0;
5564
5565
  const isSettlingAfterDataChange = () => !!state.didDataChange || !!state.didColumnsChange || state.queuedMVCPRecalculate !== void 0 || state.ignoreScrollFromMVCP !== void 0;
5565
- const runWhenSettled = (token, run) => {
5566
+ const runWhenReady = (token, run, isReady) => {
5566
5567
  const startedAt = Date.now();
5567
5568
  let stableFrames = 0;
5568
5569
  const check = () => {
5569
5570
  if (token !== imperativeScrollToken) {
5570
5571
  return;
5571
5572
  }
5572
- if (isSettlingAfterDataChange()) {
5573
+ if (isSettlingAfterDataChange() || !isReady()) {
5573
5574
  stableFrames = 0;
5574
5575
  } else {
5575
5576
  stableFrames += 1;
@@ -5584,10 +5585,10 @@ function createImperativeHandle(ctx) {
5584
5585
  requestAnimationFrame(check);
5585
5586
  };
5586
5587
  const runScrollWithPromise = (run, options) => new Promise((resolve) => {
5587
- var _a3;
5588
+ var _a3, _b;
5588
5589
  const token = ++imperativeScrollToken;
5589
- const shouldWaitOneFrame = !!(options == null ? void 0 : options.shouldWaitOneFrame);
5590
- (_a3 = state.pendingScrollResolve) == null ? void 0 : _a3.call(state);
5590
+ const isReady = (_a3 = options == null ? void 0 : options.isReady) != null ? _a3 : (() => true);
5591
+ (_b = state.pendingScrollResolve) == null ? void 0 : _b.call(state);
5591
5592
  state.pendingScrollResolve = resolve;
5592
5593
  const runNow = () => {
5593
5594
  if (token !== imperativeScrollToken) {
@@ -5601,11 +5602,10 @@ function createImperativeHandle(ctx) {
5601
5602
  resolve();
5602
5603
  }
5603
5604
  };
5604
- const execute = shouldWaitOneFrame ? () => requestAnimationFrame(runNow) : runNow;
5605
- if (isSettlingAfterDataChange()) {
5606
- runWhenSettled(token, execute);
5605
+ if (isSettlingAfterDataChange() || !isReady()) {
5606
+ runWhenReady(token, runNow, isReady);
5607
5607
  } else {
5608
- execute();
5608
+ runNow();
5609
5609
  }
5610
5610
  });
5611
5611
  const scrollIndexIntoView = (options) => {
@@ -5687,7 +5687,7 @@ function createImperativeHandle(ctx) {
5687
5687
  }),
5688
5688
  reportContentInset: (inset) => {
5689
5689
  state.contentInsetOverride = inset != null ? inset : void 0;
5690
- updateScroll(ctx, state.scroll, true);
5690
+ updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
5691
5691
  },
5692
5692
  scrollIndexIntoView: (options) => runScrollWithPromise(() => scrollIndexIntoView(options)),
5693
5693
  scrollItemIntoView: ({ item, ...props }) => runScrollWithPromise(() => {
@@ -5716,15 +5716,24 @@ function createImperativeHandle(ctx) {
5716
5716
  }
5717
5717
  return false;
5718
5718
  }),
5719
- scrollToIndex: (params) => runScrollWithPromise(
5720
- () => {
5719
+ scrollToIndex: (params) => {
5720
+ const shouldWaitForOutOfRangeTarget = params.index >= 0 && params.index >= state.props.data.length;
5721
+ const options = shouldWaitForOutOfRangeTarget ? {
5722
+ isReady: () => {
5723
+ var _a3;
5724
+ const props = state.props;
5725
+ const anchorIndex = (_a3 = props.anchoredEndSpace) == null ? void 0 : _a3.anchorIndex;
5726
+ const lastIndex = props.data.length - 1;
5727
+ const isInRange = params.index < props.data.length;
5728
+ const shouldWaitForAnchorSize = isInRange && anchorIndex !== void 0 && anchorIndex >= 0 && params.index >= anchorIndex && !props.getFixedItemSize && !state.sizesKnown.has(getId(state, lastIndex));
5729
+ return isInRange && !shouldWaitForAnchorSize;
5730
+ }
5731
+ } : void 0;
5732
+ return runScrollWithPromise(() => {
5721
5733
  scrollToIndex(ctx, params);
5722
5734
  return true;
5723
- },
5724
- {
5725
- shouldWaitOneFrame: params.index >= 0 && params.index >= state.props.data.length
5726
- }
5727
- ),
5735
+ }, options);
5736
+ },
5728
5737
  scrollToItem: ({ item, ...props }) => runScrollWithPromise(() => {
5729
5738
  const data = state.props.data;
5730
5739
  const index = data.indexOf(item);
@@ -5756,32 +5765,32 @@ var addIndex = (result, dataLength, index) => {
5756
5765
  result.add(index);
5757
5766
  }
5758
5767
  };
5759
- function getAlwaysRenderIndices(config, data, keyExtractor) {
5768
+ function getAlwaysRenderIndices(config, data, keyExtractor, anchoredEndSpaceAnchorIndex) {
5760
5769
  var _a3, _b;
5761
- if (!config || data.length === 0) {
5770
+ if (data.length === 0) {
5762
5771
  return [];
5763
5772
  }
5764
5773
  const result = /* @__PURE__ */ new Set();
5765
5774
  const dataLength = data.length;
5766
- const topCount = toCount(config.top);
5775
+ const topCount = toCount(config == null ? void 0 : config.top);
5767
5776
  if (topCount > 0) {
5768
5777
  for (let i = 0; i < Math.min(topCount, dataLength); i++) {
5769
5778
  addIndex(result, dataLength, i);
5770
5779
  }
5771
5780
  }
5772
- const bottomCount = toCount(config.bottom);
5781
+ const bottomCount = toCount(config == null ? void 0 : config.bottom);
5773
5782
  if (bottomCount > 0) {
5774
5783
  for (let i = Math.max(0, dataLength - bottomCount); i < dataLength; i++) {
5775
5784
  addIndex(result, dataLength, i);
5776
5785
  }
5777
5786
  }
5778
- if ((_a3 = config.indices) == null ? void 0 : _a3.length) {
5787
+ if ((_a3 = config == null ? void 0 : config.indices) == null ? void 0 : _a3.length) {
5779
5788
  for (const index of config.indices) {
5780
5789
  if (!Number.isFinite(index)) continue;
5781
5790
  addIndex(result, dataLength, Math.floor(index));
5782
5791
  }
5783
5792
  }
5784
- if ((_b = config.keys) == null ? void 0 : _b.length) {
5793
+ if ((_b = config == null ? void 0 : config.keys) == null ? void 0 : _b.length) {
5785
5794
  const keys = new Set(config.keys);
5786
5795
  for (let i = 0; i < dataLength && keys.size > 0; i++) {
5787
5796
  const key = keyExtractor(data[i], i);
@@ -5791,6 +5800,12 @@ function getAlwaysRenderIndices(config, data, keyExtractor) {
5791
5800
  }
5792
5801
  }
5793
5802
  }
5803
+ if (anchoredEndSpaceAnchorIndex !== void 0 && Number.isFinite(anchoredEndSpaceAnchorIndex)) {
5804
+ const anchorIndex = Math.floor(anchoredEndSpaceAnchorIndex);
5805
+ for (let i = anchorIndex >= 0 ? anchorIndex : dataLength; i < dataLength; i++) {
5806
+ addIndex(result, dataLength, i);
5807
+ }
5808
+ }
5794
5809
  const indices = Array.from(result);
5795
5810
  indices.sort(sortAsc);
5796
5811
  return indices;
@@ -5954,7 +5969,7 @@ var LegendList = typedMemo(
5954
5969
  })
5955
5970
  );
5956
5971
  var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
5957
- var _a3, _b, _c, _d, _e, _f, _g, _h;
5972
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
5958
5973
  const noopOnScroll = React3.useCallback((_event) => {
5959
5974
  }, []);
5960
5975
  if (props.recycleItems === void 0) {
@@ -6083,9 +6098,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6083
6098
  const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
6084
6099
  const stickyHeaderIndices = stickyHeaderIndicesProp != null ? stickyHeaderIndicesProp : stickyIndicesDeprecated;
6085
6100
  const alwaysRenderIndices = React3.useMemo(() => {
6086
- const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor);
6101
+ const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
6087
6102
  return { arr: indices, set: new Set(indices) };
6088
6103
  }, [
6104
+ anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
6089
6105
  alwaysRender == null ? void 0 : alwaysRender.top,
6090
6106
  alwaysRender == null ? void 0 : alwaysRender.bottom,
6091
6107
  (_d = alwaysRender == null ? void 0 : alwaysRender.indices) == null ? void 0 : _d.join(","),
@@ -6191,6 +6207,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6191
6207
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
6192
6208
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
6193
6209
  const anchoredEndSpaceResolved = anchoredEndSpace ? { ...anchoredEndSpace, includeInEndInset: true } : anchoredEndSpace;
6210
+ const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_g = state.props.anchoredEndSpace) == null ? void 0 : _g.anchorIndex) !== (anchoredEndSpaceResolved == null ? void 0 : anchoredEndSpaceResolved.anchorIndex);
6194
6211
  state.props = {
6195
6212
  alignItemsAtEnd,
6196
6213
  alwaysRender,
@@ -6300,6 +6317,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6300
6317
  });
6301
6318
  }, [dataProp.length, didDataChangeLocal, initialScrollAtEnd, stylePaddingBottomState, usesBootstrapInitialScroll]);
6302
6319
  React3.useLayoutEffect(() => {
6320
+ var _a4;
6321
+ if (didAnchoredEndSpaceAnchorIndexChange) {
6322
+ state.scrollForNextCalculateItemsInView = void 0;
6323
+ (_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state);
6324
+ }
6303
6325
  maybeUpdateAnchoredEndSpace(ctx);
6304
6326
  }, [
6305
6327
  ctx,
@@ -6308,6 +6330,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6308
6330
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
6309
6331
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorMaxSize,
6310
6332
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorOffset,
6333
+ didAnchoredEndSpaceAnchorIndexChange,
6311
6334
  numColumnsProp
6312
6335
  ]);
6313
6336
  const onLayoutFooter = React3.useCallback(
@@ -6461,7 +6484,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6461
6484
  onScroll: onScrollHandler,
6462
6485
  recycleItems,
6463
6486
  refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React3__namespace.cloneElement(refreshControlElement, {
6464
- progressViewOffset: ((_g = refreshControlElement.props.progressViewOffset) != null ? _g : 0) + stylePaddingTopState
6487
+ progressViewOffset: ((_h = refreshControlElement.props.progressViewOffset) != null ? _h : 0) + stylePaddingTopState
6465
6488
  }) : refreshControlElement : onRefresh && /* @__PURE__ */ React3__namespace.createElement(
6466
6489
  RefreshControl,
6467
6490
  {
@@ -6472,7 +6495,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6472
6495
  ),
6473
6496
  refScrollView: combinedRef,
6474
6497
  renderScrollComponent,
6475
- scrollAdjustHandler: (_h = refState.current) == null ? void 0 : _h.scrollAdjustHandler,
6498
+ scrollAdjustHandler: (_i = refState.current) == null ? void 0 : _i.scrollAdjustHandler,
6476
6499
  scrollEventThrottle: 0,
6477
6500
  snapToIndices,
6478
6501
  stickyHeaderIndices,