@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.
package/react-native.mjs CHANGED
@@ -4549,12 +4549,14 @@ var flushSync = (fn) => {
4549
4549
  };
4550
4550
 
4551
4551
  // src/core/updateScroll.ts
4552
- function updateScroll(ctx, newScroll, forceUpdate) {
4552
+ function updateScroll(ctx, newScroll, forceUpdate, options) {
4553
4553
  var _a3;
4554
4554
  const state = ctx.state;
4555
4555
  const { ignoreScrollFromMVCP, lastScrollAdjustForHistory, scrollAdjustHandler, scrollHistory, scrollingTo } = state;
4556
4556
  const prevScroll = state.scroll;
4557
- state.hasScrolled = true;
4557
+ if ((options == null ? void 0 : options.markHasScrolled) !== false) {
4558
+ state.hasScrolled = true;
4559
+ }
4558
4560
  state.lastBatchingAction = Date.now();
4559
4561
  const currentTime = Date.now();
4560
4562
  const adjust = scrollAdjustHandler.getAdjust();
@@ -4773,13 +4775,12 @@ function maybeUpdateAnchoredEndSpace(ctx) {
4773
4775
  nextSize = Math.max(0, state.scrollLength - contentBelowAnchor - anchorOffset);
4774
4776
  }
4775
4777
  }
4776
- if (previousSize === nextSize) {
4777
- return nextSize;
4778
- }
4779
- set$(ctx, "anchoredEndSpaceSize", nextSize);
4780
- (_a3 = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onSizeChanged) == null ? void 0 : _a3.call(anchoredEndSpace, nextSize);
4781
- if (anchoredEndSpace == null ? void 0 : anchoredEndSpace.includeInEndInset) {
4782
- updateScroll(ctx, state.scroll, true);
4778
+ if (previousSize !== nextSize) {
4779
+ set$(ctx, "anchoredEndSpaceSize", nextSize);
4780
+ (_a3 = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onSizeChanged) == null ? void 0 : _a3.call(anchoredEndSpace, nextSize);
4781
+ if (anchoredEndSpace == null ? void 0 : anchoredEndSpace.includeInEndInset) {
4782
+ updateScroll(ctx, state.scroll, true);
4783
+ }
4783
4784
  }
4784
4785
  return nextSize;
4785
4786
  }
@@ -5023,14 +5024,14 @@ function createImperativeHandle(ctx) {
5023
5024
  const IMPERATIVE_SCROLL_SETTLE_STABLE_FRAMES = 2;
5024
5025
  let imperativeScrollToken = 0;
5025
5026
  const isSettlingAfterDataChange = () => !!state.didDataChange || !!state.didColumnsChange || state.queuedMVCPRecalculate !== void 0 || state.ignoreScrollFromMVCP !== void 0;
5026
- const runWhenSettled = (token, run) => {
5027
+ const runWhenReady = (token, run, isReady) => {
5027
5028
  const startedAt = Date.now();
5028
5029
  let stableFrames = 0;
5029
5030
  const check = () => {
5030
5031
  if (token !== imperativeScrollToken) {
5031
5032
  return;
5032
5033
  }
5033
- if (isSettlingAfterDataChange()) {
5034
+ if (isSettlingAfterDataChange() || !isReady()) {
5034
5035
  stableFrames = 0;
5035
5036
  } else {
5036
5037
  stableFrames += 1;
@@ -5045,10 +5046,10 @@ function createImperativeHandle(ctx) {
5045
5046
  requestAnimationFrame(check);
5046
5047
  };
5047
5048
  const runScrollWithPromise = (run, options) => new Promise((resolve) => {
5048
- var _a3;
5049
+ var _a3, _b;
5049
5050
  const token = ++imperativeScrollToken;
5050
- const shouldWaitOneFrame = !!(options == null ? void 0 : options.shouldWaitOneFrame);
5051
- (_a3 = state.pendingScrollResolve) == null ? void 0 : _a3.call(state);
5051
+ const isReady = (_a3 = options == null ? void 0 : options.isReady) != null ? _a3 : (() => true);
5052
+ (_b = state.pendingScrollResolve) == null ? void 0 : _b.call(state);
5052
5053
  state.pendingScrollResolve = resolve;
5053
5054
  const runNow = () => {
5054
5055
  if (token !== imperativeScrollToken) {
@@ -5062,11 +5063,10 @@ function createImperativeHandle(ctx) {
5062
5063
  resolve();
5063
5064
  }
5064
5065
  };
5065
- const execute = shouldWaitOneFrame ? () => requestAnimationFrame(runNow) : runNow;
5066
- if (isSettlingAfterDataChange()) {
5067
- runWhenSettled(token, execute);
5066
+ if (isSettlingAfterDataChange() || !isReady()) {
5067
+ runWhenReady(token, runNow, isReady);
5068
5068
  } else {
5069
- execute();
5069
+ runNow();
5070
5070
  }
5071
5071
  });
5072
5072
  const scrollIndexIntoView = (options) => {
@@ -5148,7 +5148,7 @@ function createImperativeHandle(ctx) {
5148
5148
  }),
5149
5149
  reportContentInset: (inset) => {
5150
5150
  state.contentInsetOverride = inset != null ? inset : void 0;
5151
- updateScroll(ctx, state.scroll, true);
5151
+ updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
5152
5152
  },
5153
5153
  scrollIndexIntoView: (options) => runScrollWithPromise(() => scrollIndexIntoView(options)),
5154
5154
  scrollItemIntoView: ({ item, ...props }) => runScrollWithPromise(() => {
@@ -5177,15 +5177,24 @@ function createImperativeHandle(ctx) {
5177
5177
  }
5178
5178
  return false;
5179
5179
  }),
5180
- scrollToIndex: (params) => runScrollWithPromise(
5181
- () => {
5180
+ scrollToIndex: (params) => {
5181
+ const shouldWaitForOutOfRangeTarget = params.index >= 0 && params.index >= state.props.data.length;
5182
+ const options = shouldWaitForOutOfRangeTarget ? {
5183
+ isReady: () => {
5184
+ var _a3;
5185
+ const props = state.props;
5186
+ const anchorIndex = (_a3 = props.anchoredEndSpace) == null ? void 0 : _a3.anchorIndex;
5187
+ const lastIndex = props.data.length - 1;
5188
+ const isInRange = params.index < props.data.length;
5189
+ const shouldWaitForAnchorSize = isInRange && anchorIndex !== void 0 && anchorIndex >= 0 && params.index >= anchorIndex && !props.getFixedItemSize && !state.sizesKnown.has(getId(state, lastIndex));
5190
+ return isInRange && !shouldWaitForAnchorSize;
5191
+ }
5192
+ } : void 0;
5193
+ return runScrollWithPromise(() => {
5182
5194
  scrollToIndex(ctx, params);
5183
5195
  return true;
5184
- },
5185
- {
5186
- shouldWaitOneFrame: params.index >= 0 && params.index >= state.props.data.length
5187
- }
5188
- ),
5196
+ }, options);
5197
+ },
5189
5198
  scrollToItem: ({ item, ...props }) => runScrollWithPromise(() => {
5190
5199
  const data = state.props.data;
5191
5200
  const index = data.indexOf(item);
@@ -5217,32 +5226,32 @@ var addIndex = (result, dataLength, index) => {
5217
5226
  result.add(index);
5218
5227
  }
5219
5228
  };
5220
- function getAlwaysRenderIndices(config, data, keyExtractor) {
5229
+ function getAlwaysRenderIndices(config, data, keyExtractor, anchoredEndSpaceAnchorIndex) {
5221
5230
  var _a3, _b;
5222
- if (!config || data.length === 0) {
5231
+ if (data.length === 0) {
5223
5232
  return [];
5224
5233
  }
5225
5234
  const result = /* @__PURE__ */ new Set();
5226
5235
  const dataLength = data.length;
5227
- const topCount = toCount(config.top);
5236
+ const topCount = toCount(config == null ? void 0 : config.top);
5228
5237
  if (topCount > 0) {
5229
5238
  for (let i = 0; i < Math.min(topCount, dataLength); i++) {
5230
5239
  addIndex(result, dataLength, i);
5231
5240
  }
5232
5241
  }
5233
- const bottomCount = toCount(config.bottom);
5242
+ const bottomCount = toCount(config == null ? void 0 : config.bottom);
5234
5243
  if (bottomCount > 0) {
5235
5244
  for (let i = Math.max(0, dataLength - bottomCount); i < dataLength; i++) {
5236
5245
  addIndex(result, dataLength, i);
5237
5246
  }
5238
5247
  }
5239
- if ((_a3 = config.indices) == null ? void 0 : _a3.length) {
5248
+ if ((_a3 = config == null ? void 0 : config.indices) == null ? void 0 : _a3.length) {
5240
5249
  for (const index of config.indices) {
5241
5250
  if (!Number.isFinite(index)) continue;
5242
5251
  addIndex(result, dataLength, Math.floor(index));
5243
5252
  }
5244
5253
  }
5245
- if ((_b = config.keys) == null ? void 0 : _b.length) {
5254
+ if ((_b = config == null ? void 0 : config.keys) == null ? void 0 : _b.length) {
5246
5255
  const keys = new Set(config.keys);
5247
5256
  for (let i = 0; i < dataLength && keys.size > 0; i++) {
5248
5257
  const key = keyExtractor(data[i], i);
@@ -5252,6 +5261,12 @@ function getAlwaysRenderIndices(config, data, keyExtractor) {
5252
5261
  }
5253
5262
  }
5254
5263
  }
5264
+ if (anchoredEndSpaceAnchorIndex !== void 0 && Number.isFinite(anchoredEndSpaceAnchorIndex)) {
5265
+ const anchorIndex = Math.floor(anchoredEndSpaceAnchorIndex);
5266
+ for (let i = anchorIndex >= 0 ? anchorIndex : dataLength; i < dataLength; i++) {
5267
+ addIndex(result, dataLength, i);
5268
+ }
5269
+ }
5255
5270
  const indices = Array.from(result);
5256
5271
  indices.sort(sortAsc);
5257
5272
  return indices;
@@ -5415,7 +5430,7 @@ var LegendList = typedMemo(
5415
5430
  })
5416
5431
  );
5417
5432
  var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
5418
- var _a3, _b, _c, _d, _e, _f, _g, _h;
5433
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
5419
5434
  const noopOnScroll = useCallback((_event) => {
5420
5435
  }, []);
5421
5436
  if (props.recycleItems === void 0) {
@@ -5544,9 +5559,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5544
5559
  const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
5545
5560
  const stickyHeaderIndices = stickyHeaderIndicesProp != null ? stickyHeaderIndicesProp : stickyIndicesDeprecated;
5546
5561
  const alwaysRenderIndices = useMemo(() => {
5547
- const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor);
5562
+ const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
5548
5563
  return { arr: indices, set: new Set(indices) };
5549
5564
  }, [
5565
+ anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
5550
5566
  alwaysRender == null ? void 0 : alwaysRender.top,
5551
5567
  alwaysRender == null ? void 0 : alwaysRender.bottom,
5552
5568
  (_d = alwaysRender == null ? void 0 : alwaysRender.indices) == null ? void 0 : _d.join(","),
@@ -5652,6 +5668,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5652
5668
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
5653
5669
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
5654
5670
  const anchoredEndSpaceResolved = Platform.OS === "web" && anchoredEndSpace ? { ...anchoredEndSpace, includeInEndInset: true } : anchoredEndSpace;
5671
+ const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_g = state.props.anchoredEndSpace) == null ? void 0 : _g.anchorIndex) !== (anchoredEndSpaceResolved == null ? void 0 : anchoredEndSpaceResolved.anchorIndex);
5655
5672
  state.props = {
5656
5673
  alignItemsAtEnd,
5657
5674
  alwaysRender,
@@ -5766,6 +5783,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5766
5783
  });
5767
5784
  }, [dataProp.length, didDataChangeLocal, initialScrollAtEnd, stylePaddingBottomState, usesBootstrapInitialScroll]);
5768
5785
  useLayoutEffect(() => {
5786
+ var _a4;
5787
+ if (didAnchoredEndSpaceAnchorIndexChange) {
5788
+ state.scrollForNextCalculateItemsInView = void 0;
5789
+ (_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state);
5790
+ }
5769
5791
  maybeUpdateAnchoredEndSpace(ctx);
5770
5792
  }, [
5771
5793
  ctx,
@@ -5774,6 +5796,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5774
5796
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
5775
5797
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorMaxSize,
5776
5798
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorOffset,
5799
+ didAnchoredEndSpaceAnchorIndexChange,
5777
5800
  numColumnsProp
5778
5801
  ]);
5779
5802
  const onLayoutFooter = useCallback(
@@ -5930,7 +5953,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5930
5953
  onScroll: onScrollHandler,
5931
5954
  recycleItems,
5932
5955
  refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React2.cloneElement(refreshControlElement, {
5933
- progressViewOffset: ((_g = refreshControlElement.props.progressViewOffset) != null ? _g : 0) + stylePaddingTopState
5956
+ progressViewOffset: ((_h = refreshControlElement.props.progressViewOffset) != null ? _h : 0) + stylePaddingTopState
5934
5957
  }) : refreshControlElement : onRefresh && /* @__PURE__ */ React2.createElement(
5935
5958
  RefreshControl,
5936
5959
  {
@@ -5941,7 +5964,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5941
5964
  ),
5942
5965
  refScrollView: combinedRef,
5943
5966
  renderScrollComponent,
5944
- scrollAdjustHandler: (_h = refState.current) == null ? void 0 : _h.scrollAdjustHandler,
5967
+ scrollAdjustHandler: (_i = refState.current) == null ? void 0 : _i.scrollAdjustHandler,
5945
5968
  scrollEventThrottle: 0,
5946
5969
  snapToIndices,
5947
5970
  stickyHeaderIndices,
@@ -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,