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

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.js CHANGED
@@ -5100,12 +5100,14 @@ function handleLayout(ctx, layoutParam, setCanRender) {
5100
5100
  }
5101
5101
 
5102
5102
  // src/core/updateScroll.ts
5103
- function updateScroll(ctx, newScroll, forceUpdate) {
5103
+ function updateScroll(ctx, newScroll, forceUpdate, options) {
5104
5104
  var _a3;
5105
5105
  const state = ctx.state;
5106
5106
  const { ignoreScrollFromMVCP, lastScrollAdjustForHistory, scrollAdjustHandler, scrollHistory, scrollingTo } = state;
5107
5107
  const prevScroll = state.scroll;
5108
- state.hasScrolled = true;
5108
+ if ((options == null ? void 0 : options.markHasScrolled) !== false) {
5109
+ state.hasScrolled = true;
5110
+ }
5109
5111
  state.lastBatchingAction = Date.now();
5110
5112
  const currentTime = Date.now();
5111
5113
  const adjust = scrollAdjustHandler.getAdjust();
@@ -5684,7 +5686,7 @@ function createImperativeHandle(ctx) {
5684
5686
  }),
5685
5687
  reportContentInset: (inset) => {
5686
5688
  state.contentInsetOverride = inset != null ? inset : void 0;
5687
- updateScroll(ctx, state.scroll, true);
5689
+ updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
5688
5690
  },
5689
5691
  scrollIndexIntoView: (options) => runScrollWithPromise(() => scrollIndexIntoView(options)),
5690
5692
  scrollItemIntoView: ({ item, ...props }) => runScrollWithPromise(() => {
@@ -5753,32 +5755,32 @@ var addIndex = (result, dataLength, index) => {
5753
5755
  result.add(index);
5754
5756
  }
5755
5757
  };
5756
- function getAlwaysRenderIndices(config, data, keyExtractor) {
5758
+ function getAlwaysRenderIndices(config, data, keyExtractor, anchoredEndSpaceAnchorIndex) {
5757
5759
  var _a3, _b;
5758
- if (!config || data.length === 0) {
5760
+ if (data.length === 0) {
5759
5761
  return [];
5760
5762
  }
5761
5763
  const result = /* @__PURE__ */ new Set();
5762
5764
  const dataLength = data.length;
5763
- const topCount = toCount(config.top);
5765
+ const topCount = toCount(config == null ? void 0 : config.top);
5764
5766
  if (topCount > 0) {
5765
5767
  for (let i = 0; i < Math.min(topCount, dataLength); i++) {
5766
5768
  addIndex(result, dataLength, i);
5767
5769
  }
5768
5770
  }
5769
- const bottomCount = toCount(config.bottom);
5771
+ const bottomCount = toCount(config == null ? void 0 : config.bottom);
5770
5772
  if (bottomCount > 0) {
5771
5773
  for (let i = Math.max(0, dataLength - bottomCount); i < dataLength; i++) {
5772
5774
  addIndex(result, dataLength, i);
5773
5775
  }
5774
5776
  }
5775
- if ((_a3 = config.indices) == null ? void 0 : _a3.length) {
5777
+ if ((_a3 = config == null ? void 0 : config.indices) == null ? void 0 : _a3.length) {
5776
5778
  for (const index of config.indices) {
5777
5779
  if (!Number.isFinite(index)) continue;
5778
5780
  addIndex(result, dataLength, Math.floor(index));
5779
5781
  }
5780
5782
  }
5781
- if ((_b = config.keys) == null ? void 0 : _b.length) {
5783
+ if ((_b = config == null ? void 0 : config.keys) == null ? void 0 : _b.length) {
5782
5784
  const keys = new Set(config.keys);
5783
5785
  for (let i = 0; i < dataLength && keys.size > 0; i++) {
5784
5786
  const key = keyExtractor(data[i], i);
@@ -5788,6 +5790,12 @@ function getAlwaysRenderIndices(config, data, keyExtractor) {
5788
5790
  }
5789
5791
  }
5790
5792
  }
5793
+ if (anchoredEndSpaceAnchorIndex !== void 0 && Number.isFinite(anchoredEndSpaceAnchorIndex)) {
5794
+ const anchorIndex = Math.floor(anchoredEndSpaceAnchorIndex);
5795
+ for (let i = anchorIndex >= 0 ? anchorIndex : dataLength; i < dataLength; i++) {
5796
+ addIndex(result, dataLength, i);
5797
+ }
5798
+ }
5791
5799
  const indices = Array.from(result);
5792
5800
  indices.sort(sortAsc);
5793
5801
  return indices;
@@ -5951,7 +5959,7 @@ var LegendList = typedMemo(
5951
5959
  })
5952
5960
  );
5953
5961
  var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
5954
- var _a3, _b, _c, _d, _e, _f, _g, _h;
5962
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
5955
5963
  const noopOnScroll = React3.useCallback((_event) => {
5956
5964
  }, []);
5957
5965
  if (props.recycleItems === void 0) {
@@ -6080,9 +6088,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6080
6088
  const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
6081
6089
  const stickyHeaderIndices = stickyHeaderIndicesProp != null ? stickyHeaderIndicesProp : stickyIndicesDeprecated;
6082
6090
  const alwaysRenderIndices = React3.useMemo(() => {
6083
- const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor);
6091
+ const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
6084
6092
  return { arr: indices, set: new Set(indices) };
6085
6093
  }, [
6094
+ anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
6086
6095
  alwaysRender == null ? void 0 : alwaysRender.top,
6087
6096
  alwaysRender == null ? void 0 : alwaysRender.bottom,
6088
6097
  (_d = alwaysRender == null ? void 0 : alwaysRender.indices) == null ? void 0 : _d.join(","),
@@ -6188,6 +6197,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6188
6197
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
6189
6198
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
6190
6199
  const anchoredEndSpaceResolved = anchoredEndSpace ? { ...anchoredEndSpace, includeInEndInset: true } : anchoredEndSpace;
6200
+ const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_g = state.props.anchoredEndSpace) == null ? void 0 : _g.anchorIndex) !== (anchoredEndSpaceResolved == null ? void 0 : anchoredEndSpaceResolved.anchorIndex);
6191
6201
  state.props = {
6192
6202
  alignItemsAtEnd,
6193
6203
  alwaysRender,
@@ -6297,6 +6307,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6297
6307
  });
6298
6308
  }, [dataProp.length, didDataChangeLocal, initialScrollAtEnd, stylePaddingBottomState, usesBootstrapInitialScroll]);
6299
6309
  React3.useLayoutEffect(() => {
6310
+ var _a4;
6311
+ if (didAnchoredEndSpaceAnchorIndexChange) {
6312
+ state.scrollForNextCalculateItemsInView = void 0;
6313
+ (_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state);
6314
+ }
6300
6315
  maybeUpdateAnchoredEndSpace(ctx);
6301
6316
  }, [
6302
6317
  ctx,
@@ -6305,6 +6320,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6305
6320
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
6306
6321
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorMaxSize,
6307
6322
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorOffset,
6323
+ didAnchoredEndSpaceAnchorIndexChange,
6308
6324
  numColumnsProp
6309
6325
  ]);
6310
6326
  const onLayoutFooter = React3.useCallback(
@@ -6458,7 +6474,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6458
6474
  onScroll: onScrollHandler,
6459
6475
  recycleItems,
6460
6476
  refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React3__namespace.cloneElement(refreshControlElement, {
6461
- progressViewOffset: ((_g = refreshControlElement.props.progressViewOffset) != null ? _g : 0) + stylePaddingTopState
6477
+ progressViewOffset: ((_h = refreshControlElement.props.progressViewOffset) != null ? _h : 0) + stylePaddingTopState
6462
6478
  }) : refreshControlElement : onRefresh && /* @__PURE__ */ React3__namespace.createElement(
6463
6479
  RefreshControl,
6464
6480
  {
@@ -6469,7 +6485,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6469
6485
  ),
6470
6486
  refScrollView: combinedRef,
6471
6487
  renderScrollComponent,
6472
- scrollAdjustHandler: (_h = refState.current) == null ? void 0 : _h.scrollAdjustHandler,
6488
+ scrollAdjustHandler: (_i = refState.current) == null ? void 0 : _i.scrollAdjustHandler,
6473
6489
  scrollEventThrottle: 0,
6474
6490
  snapToIndices,
6475
6491
  stickyHeaderIndices,
package/index.mjs CHANGED
@@ -5079,12 +5079,14 @@ function handleLayout(ctx, layoutParam, setCanRender) {
5079
5079
  }
5080
5080
 
5081
5081
  // src/core/updateScroll.ts
5082
- function updateScroll(ctx, newScroll, forceUpdate) {
5082
+ function updateScroll(ctx, newScroll, forceUpdate, options) {
5083
5083
  var _a3;
5084
5084
  const state = ctx.state;
5085
5085
  const { ignoreScrollFromMVCP, lastScrollAdjustForHistory, scrollAdjustHandler, scrollHistory, scrollingTo } = state;
5086
5086
  const prevScroll = state.scroll;
5087
- state.hasScrolled = true;
5087
+ if ((options == null ? void 0 : options.markHasScrolled) !== false) {
5088
+ state.hasScrolled = true;
5089
+ }
5088
5090
  state.lastBatchingAction = Date.now();
5089
5091
  const currentTime = Date.now();
5090
5092
  const adjust = scrollAdjustHandler.getAdjust();
@@ -5663,7 +5665,7 @@ function createImperativeHandle(ctx) {
5663
5665
  }),
5664
5666
  reportContentInset: (inset) => {
5665
5667
  state.contentInsetOverride = inset != null ? inset : void 0;
5666
- updateScroll(ctx, state.scroll, true);
5668
+ updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
5667
5669
  },
5668
5670
  scrollIndexIntoView: (options) => runScrollWithPromise(() => scrollIndexIntoView(options)),
5669
5671
  scrollItemIntoView: ({ item, ...props }) => runScrollWithPromise(() => {
@@ -5732,32 +5734,32 @@ var addIndex = (result, dataLength, index) => {
5732
5734
  result.add(index);
5733
5735
  }
5734
5736
  };
5735
- function getAlwaysRenderIndices(config, data, keyExtractor) {
5737
+ function getAlwaysRenderIndices(config, data, keyExtractor, anchoredEndSpaceAnchorIndex) {
5736
5738
  var _a3, _b;
5737
- if (!config || data.length === 0) {
5739
+ if (data.length === 0) {
5738
5740
  return [];
5739
5741
  }
5740
5742
  const result = /* @__PURE__ */ new Set();
5741
5743
  const dataLength = data.length;
5742
- const topCount = toCount(config.top);
5744
+ const topCount = toCount(config == null ? void 0 : config.top);
5743
5745
  if (topCount > 0) {
5744
5746
  for (let i = 0; i < Math.min(topCount, dataLength); i++) {
5745
5747
  addIndex(result, dataLength, i);
5746
5748
  }
5747
5749
  }
5748
- const bottomCount = toCount(config.bottom);
5750
+ const bottomCount = toCount(config == null ? void 0 : config.bottom);
5749
5751
  if (bottomCount > 0) {
5750
5752
  for (let i = Math.max(0, dataLength - bottomCount); i < dataLength; i++) {
5751
5753
  addIndex(result, dataLength, i);
5752
5754
  }
5753
5755
  }
5754
- if ((_a3 = config.indices) == null ? void 0 : _a3.length) {
5756
+ if ((_a3 = config == null ? void 0 : config.indices) == null ? void 0 : _a3.length) {
5755
5757
  for (const index of config.indices) {
5756
5758
  if (!Number.isFinite(index)) continue;
5757
5759
  addIndex(result, dataLength, Math.floor(index));
5758
5760
  }
5759
5761
  }
5760
- if ((_b = config.keys) == null ? void 0 : _b.length) {
5762
+ if ((_b = config == null ? void 0 : config.keys) == null ? void 0 : _b.length) {
5761
5763
  const keys = new Set(config.keys);
5762
5764
  for (let i = 0; i < dataLength && keys.size > 0; i++) {
5763
5765
  const key = keyExtractor(data[i], i);
@@ -5767,6 +5769,12 @@ function getAlwaysRenderIndices(config, data, keyExtractor) {
5767
5769
  }
5768
5770
  }
5769
5771
  }
5772
+ if (anchoredEndSpaceAnchorIndex !== void 0 && Number.isFinite(anchoredEndSpaceAnchorIndex)) {
5773
+ const anchorIndex = Math.floor(anchoredEndSpaceAnchorIndex);
5774
+ for (let i = anchorIndex >= 0 ? anchorIndex : dataLength; i < dataLength; i++) {
5775
+ addIndex(result, dataLength, i);
5776
+ }
5777
+ }
5770
5778
  const indices = Array.from(result);
5771
5779
  indices.sort(sortAsc);
5772
5780
  return indices;
@@ -5930,7 +5938,7 @@ var LegendList = typedMemo(
5930
5938
  })
5931
5939
  );
5932
5940
  var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
5933
- var _a3, _b, _c, _d, _e, _f, _g, _h;
5941
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
5934
5942
  const noopOnScroll = useCallback((_event) => {
5935
5943
  }, []);
5936
5944
  if (props.recycleItems === void 0) {
@@ -6059,9 +6067,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6059
6067
  const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
6060
6068
  const stickyHeaderIndices = stickyHeaderIndicesProp != null ? stickyHeaderIndicesProp : stickyIndicesDeprecated;
6061
6069
  const alwaysRenderIndices = useMemo(() => {
6062
- const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor);
6070
+ const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
6063
6071
  return { arr: indices, set: new Set(indices) };
6064
6072
  }, [
6073
+ anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
6065
6074
  alwaysRender == null ? void 0 : alwaysRender.top,
6066
6075
  alwaysRender == null ? void 0 : alwaysRender.bottom,
6067
6076
  (_d = alwaysRender == null ? void 0 : alwaysRender.indices) == null ? void 0 : _d.join(","),
@@ -6167,6 +6176,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6167
6176
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
6168
6177
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
6169
6178
  const anchoredEndSpaceResolved = anchoredEndSpace ? { ...anchoredEndSpace, includeInEndInset: true } : anchoredEndSpace;
6179
+ const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_g = state.props.anchoredEndSpace) == null ? void 0 : _g.anchorIndex) !== (anchoredEndSpaceResolved == null ? void 0 : anchoredEndSpaceResolved.anchorIndex);
6170
6180
  state.props = {
6171
6181
  alignItemsAtEnd,
6172
6182
  alwaysRender,
@@ -6276,6 +6286,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6276
6286
  });
6277
6287
  }, [dataProp.length, didDataChangeLocal, initialScrollAtEnd, stylePaddingBottomState, usesBootstrapInitialScroll]);
6278
6288
  useLayoutEffect(() => {
6289
+ var _a4;
6290
+ if (didAnchoredEndSpaceAnchorIndexChange) {
6291
+ state.scrollForNextCalculateItemsInView = void 0;
6292
+ (_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state);
6293
+ }
6279
6294
  maybeUpdateAnchoredEndSpace(ctx);
6280
6295
  }, [
6281
6296
  ctx,
@@ -6284,6 +6299,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6284
6299
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
6285
6300
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorMaxSize,
6286
6301
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorOffset,
6302
+ didAnchoredEndSpaceAnchorIndexChange,
6287
6303
  numColumnsProp
6288
6304
  ]);
6289
6305
  const onLayoutFooter = useCallback(
@@ -6437,7 +6453,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6437
6453
  onScroll: onScrollHandler,
6438
6454
  recycleItems,
6439
6455
  refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React3.cloneElement(refreshControlElement, {
6440
- progressViewOffset: ((_g = refreshControlElement.props.progressViewOffset) != null ? _g : 0) + stylePaddingTopState
6456
+ progressViewOffset: ((_h = refreshControlElement.props.progressViewOffset) != null ? _h : 0) + stylePaddingTopState
6441
6457
  }) : refreshControlElement : onRefresh && /* @__PURE__ */ React3.createElement(
6442
6458
  RefreshControl,
6443
6459
  {
@@ -6448,7 +6464,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6448
6464
  ),
6449
6465
  refScrollView: combinedRef,
6450
6466
  renderScrollComponent,
6451
- scrollAdjustHandler: (_h = refState.current) == null ? void 0 : _h.scrollAdjustHandler,
6467
+ scrollAdjustHandler: (_i = refState.current) == null ? void 0 : _i.scrollAdjustHandler,
6452
6468
  scrollEventThrottle: 0,
6453
6469
  snapToIndices,
6454
6470
  stickyHeaderIndices,
package/index.native.js CHANGED
@@ -4570,12 +4570,14 @@ var flushSync = (fn) => {
4570
4570
  };
4571
4571
 
4572
4572
  // src/core/updateScroll.ts
4573
- function updateScroll(ctx, newScroll, forceUpdate) {
4573
+ function updateScroll(ctx, newScroll, forceUpdate, options) {
4574
4574
  var _a3;
4575
4575
  const state = ctx.state;
4576
4576
  const { ignoreScrollFromMVCP, lastScrollAdjustForHistory, scrollAdjustHandler, scrollHistory, scrollingTo } = state;
4577
4577
  const prevScroll = state.scroll;
4578
- state.hasScrolled = true;
4578
+ if ((options == null ? void 0 : options.markHasScrolled) !== false) {
4579
+ state.hasScrolled = true;
4580
+ }
4579
4581
  state.lastBatchingAction = Date.now();
4580
4582
  const currentTime = Date.now();
4581
4583
  const adjust = scrollAdjustHandler.getAdjust();
@@ -5169,7 +5171,7 @@ function createImperativeHandle(ctx) {
5169
5171
  }),
5170
5172
  reportContentInset: (inset) => {
5171
5173
  state.contentInsetOverride = inset != null ? inset : void 0;
5172
- updateScroll(ctx, state.scroll, true);
5174
+ updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
5173
5175
  },
5174
5176
  scrollIndexIntoView: (options) => runScrollWithPromise(() => scrollIndexIntoView(options)),
5175
5177
  scrollItemIntoView: ({ item, ...props }) => runScrollWithPromise(() => {
@@ -5238,32 +5240,32 @@ var addIndex = (result, dataLength, index) => {
5238
5240
  result.add(index);
5239
5241
  }
5240
5242
  };
5241
- function getAlwaysRenderIndices(config, data, keyExtractor) {
5243
+ function getAlwaysRenderIndices(config, data, keyExtractor, anchoredEndSpaceAnchorIndex) {
5242
5244
  var _a3, _b;
5243
- if (!config || data.length === 0) {
5245
+ if (data.length === 0) {
5244
5246
  return [];
5245
5247
  }
5246
5248
  const result = /* @__PURE__ */ new Set();
5247
5249
  const dataLength = data.length;
5248
- const topCount = toCount(config.top);
5250
+ const topCount = toCount(config == null ? void 0 : config.top);
5249
5251
  if (topCount > 0) {
5250
5252
  for (let i = 0; i < Math.min(topCount, dataLength); i++) {
5251
5253
  addIndex(result, dataLength, i);
5252
5254
  }
5253
5255
  }
5254
- const bottomCount = toCount(config.bottom);
5256
+ const bottomCount = toCount(config == null ? void 0 : config.bottom);
5255
5257
  if (bottomCount > 0) {
5256
5258
  for (let i = Math.max(0, dataLength - bottomCount); i < dataLength; i++) {
5257
5259
  addIndex(result, dataLength, i);
5258
5260
  }
5259
5261
  }
5260
- if ((_a3 = config.indices) == null ? void 0 : _a3.length) {
5262
+ if ((_a3 = config == null ? void 0 : config.indices) == null ? void 0 : _a3.length) {
5261
5263
  for (const index of config.indices) {
5262
5264
  if (!Number.isFinite(index)) continue;
5263
5265
  addIndex(result, dataLength, Math.floor(index));
5264
5266
  }
5265
5267
  }
5266
- if ((_b = config.keys) == null ? void 0 : _b.length) {
5268
+ if ((_b = config == null ? void 0 : config.keys) == null ? void 0 : _b.length) {
5267
5269
  const keys = new Set(config.keys);
5268
5270
  for (let i = 0; i < dataLength && keys.size > 0; i++) {
5269
5271
  const key = keyExtractor(data[i], i);
@@ -5273,6 +5275,12 @@ function getAlwaysRenderIndices(config, data, keyExtractor) {
5273
5275
  }
5274
5276
  }
5275
5277
  }
5278
+ if (anchoredEndSpaceAnchorIndex !== void 0 && Number.isFinite(anchoredEndSpaceAnchorIndex)) {
5279
+ const anchorIndex = Math.floor(anchoredEndSpaceAnchorIndex);
5280
+ for (let i = anchorIndex >= 0 ? anchorIndex : dataLength; i < dataLength; i++) {
5281
+ addIndex(result, dataLength, i);
5282
+ }
5283
+ }
5276
5284
  const indices = Array.from(result);
5277
5285
  indices.sort(sortAsc);
5278
5286
  return indices;
@@ -5436,7 +5444,7 @@ var LegendList = typedMemo(
5436
5444
  })
5437
5445
  );
5438
5446
  var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
5439
- var _a3, _b, _c, _d, _e, _f, _g, _h;
5447
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
5440
5448
  const noopOnScroll = React2.useCallback((_event) => {
5441
5449
  }, []);
5442
5450
  if (props.recycleItems === void 0) {
@@ -5565,9 +5573,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5565
5573
  const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
5566
5574
  const stickyHeaderIndices = stickyHeaderIndicesProp != null ? stickyHeaderIndicesProp : stickyIndicesDeprecated;
5567
5575
  const alwaysRenderIndices = React2.useMemo(() => {
5568
- const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor);
5576
+ const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
5569
5577
  return { arr: indices, set: new Set(indices) };
5570
5578
  }, [
5579
+ anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
5571
5580
  alwaysRender == null ? void 0 : alwaysRender.top,
5572
5581
  alwaysRender == null ? void 0 : alwaysRender.bottom,
5573
5582
  (_d = alwaysRender == null ? void 0 : alwaysRender.indices) == null ? void 0 : _d.join(","),
@@ -5673,6 +5682,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5673
5682
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
5674
5683
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
5675
5684
  const anchoredEndSpaceResolved = Platform.OS === "web" && anchoredEndSpace ? { ...anchoredEndSpace, includeInEndInset: true } : anchoredEndSpace;
5685
+ const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_g = state.props.anchoredEndSpace) == null ? void 0 : _g.anchorIndex) !== (anchoredEndSpaceResolved == null ? void 0 : anchoredEndSpaceResolved.anchorIndex);
5676
5686
  state.props = {
5677
5687
  alignItemsAtEnd,
5678
5688
  alwaysRender,
@@ -5787,6 +5797,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5787
5797
  });
5788
5798
  }, [dataProp.length, didDataChangeLocal, initialScrollAtEnd, stylePaddingBottomState, usesBootstrapInitialScroll]);
5789
5799
  React2.useLayoutEffect(() => {
5800
+ var _a4;
5801
+ if (didAnchoredEndSpaceAnchorIndexChange) {
5802
+ state.scrollForNextCalculateItemsInView = void 0;
5803
+ (_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state);
5804
+ }
5790
5805
  maybeUpdateAnchoredEndSpace(ctx);
5791
5806
  }, [
5792
5807
  ctx,
@@ -5795,6 +5810,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5795
5810
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
5796
5811
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorMaxSize,
5797
5812
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorOffset,
5813
+ didAnchoredEndSpaceAnchorIndexChange,
5798
5814
  numColumnsProp
5799
5815
  ]);
5800
5816
  const onLayoutFooter = React2.useCallback(
@@ -5951,7 +5967,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5951
5967
  onScroll: onScrollHandler,
5952
5968
  recycleItems,
5953
5969
  refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React2__namespace.cloneElement(refreshControlElement, {
5954
- progressViewOffset: ((_g = refreshControlElement.props.progressViewOffset) != null ? _g : 0) + stylePaddingTopState
5970
+ progressViewOffset: ((_h = refreshControlElement.props.progressViewOffset) != null ? _h : 0) + stylePaddingTopState
5955
5971
  }) : refreshControlElement : onRefresh && /* @__PURE__ */ React2__namespace.createElement(
5956
5972
  ReactNative.RefreshControl,
5957
5973
  {
@@ -5962,7 +5978,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5962
5978
  ),
5963
5979
  refScrollView: combinedRef,
5964
5980
  renderScrollComponent,
5965
- scrollAdjustHandler: (_h = refState.current) == null ? void 0 : _h.scrollAdjustHandler,
5981
+ scrollAdjustHandler: (_i = refState.current) == null ? void 0 : _i.scrollAdjustHandler,
5966
5982
  scrollEventThrottle: 0,
5967
5983
  snapToIndices,
5968
5984
  stickyHeaderIndices,
package/index.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();
@@ -5148,7 +5150,7 @@ function createImperativeHandle(ctx) {
5148
5150
  }),
5149
5151
  reportContentInset: (inset) => {
5150
5152
  state.contentInsetOverride = inset != null ? inset : void 0;
5151
- updateScroll(ctx, state.scroll, true);
5153
+ updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
5152
5154
  },
5153
5155
  scrollIndexIntoView: (options) => runScrollWithPromise(() => scrollIndexIntoView(options)),
5154
5156
  scrollItemIntoView: ({ item, ...props }) => runScrollWithPromise(() => {
@@ -5217,32 +5219,32 @@ var addIndex = (result, dataLength, index) => {
5217
5219
  result.add(index);
5218
5220
  }
5219
5221
  };
5220
- function getAlwaysRenderIndices(config, data, keyExtractor) {
5222
+ function getAlwaysRenderIndices(config, data, keyExtractor, anchoredEndSpaceAnchorIndex) {
5221
5223
  var _a3, _b;
5222
- if (!config || data.length === 0) {
5224
+ if (data.length === 0) {
5223
5225
  return [];
5224
5226
  }
5225
5227
  const result = /* @__PURE__ */ new Set();
5226
5228
  const dataLength = data.length;
5227
- const topCount = toCount(config.top);
5229
+ const topCount = toCount(config == null ? void 0 : config.top);
5228
5230
  if (topCount > 0) {
5229
5231
  for (let i = 0; i < Math.min(topCount, dataLength); i++) {
5230
5232
  addIndex(result, dataLength, i);
5231
5233
  }
5232
5234
  }
5233
- const bottomCount = toCount(config.bottom);
5235
+ const bottomCount = toCount(config == null ? void 0 : config.bottom);
5234
5236
  if (bottomCount > 0) {
5235
5237
  for (let i = Math.max(0, dataLength - bottomCount); i < dataLength; i++) {
5236
5238
  addIndex(result, dataLength, i);
5237
5239
  }
5238
5240
  }
5239
- if ((_a3 = config.indices) == null ? void 0 : _a3.length) {
5241
+ if ((_a3 = config == null ? void 0 : config.indices) == null ? void 0 : _a3.length) {
5240
5242
  for (const index of config.indices) {
5241
5243
  if (!Number.isFinite(index)) continue;
5242
5244
  addIndex(result, dataLength, Math.floor(index));
5243
5245
  }
5244
5246
  }
5245
- if ((_b = config.keys) == null ? void 0 : _b.length) {
5247
+ if ((_b = config == null ? void 0 : config.keys) == null ? void 0 : _b.length) {
5246
5248
  const keys = new Set(config.keys);
5247
5249
  for (let i = 0; i < dataLength && keys.size > 0; i++) {
5248
5250
  const key = keyExtractor(data[i], i);
@@ -5252,6 +5254,12 @@ function getAlwaysRenderIndices(config, data, keyExtractor) {
5252
5254
  }
5253
5255
  }
5254
5256
  }
5257
+ if (anchoredEndSpaceAnchorIndex !== void 0 && Number.isFinite(anchoredEndSpaceAnchorIndex)) {
5258
+ const anchorIndex = Math.floor(anchoredEndSpaceAnchorIndex);
5259
+ for (let i = anchorIndex >= 0 ? anchorIndex : dataLength; i < dataLength; i++) {
5260
+ addIndex(result, dataLength, i);
5261
+ }
5262
+ }
5255
5263
  const indices = Array.from(result);
5256
5264
  indices.sort(sortAsc);
5257
5265
  return indices;
@@ -5415,7 +5423,7 @@ var LegendList = typedMemo(
5415
5423
  })
5416
5424
  );
5417
5425
  var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
5418
- var _a3, _b, _c, _d, _e, _f, _g, _h;
5426
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
5419
5427
  const noopOnScroll = useCallback((_event) => {
5420
5428
  }, []);
5421
5429
  if (props.recycleItems === void 0) {
@@ -5544,9 +5552,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5544
5552
  const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
5545
5553
  const stickyHeaderIndices = stickyHeaderIndicesProp != null ? stickyHeaderIndicesProp : stickyIndicesDeprecated;
5546
5554
  const alwaysRenderIndices = useMemo(() => {
5547
- const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor);
5555
+ const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
5548
5556
  return { arr: indices, set: new Set(indices) };
5549
5557
  }, [
5558
+ anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
5550
5559
  alwaysRender == null ? void 0 : alwaysRender.top,
5551
5560
  alwaysRender == null ? void 0 : alwaysRender.bottom,
5552
5561
  (_d = alwaysRender == null ? void 0 : alwaysRender.indices) == null ? void 0 : _d.join(","),
@@ -5652,6 +5661,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5652
5661
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
5653
5662
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
5654
5663
  const anchoredEndSpaceResolved = Platform.OS === "web" && anchoredEndSpace ? { ...anchoredEndSpace, includeInEndInset: true } : anchoredEndSpace;
5664
+ const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_g = state.props.anchoredEndSpace) == null ? void 0 : _g.anchorIndex) !== (anchoredEndSpaceResolved == null ? void 0 : anchoredEndSpaceResolved.anchorIndex);
5655
5665
  state.props = {
5656
5666
  alignItemsAtEnd,
5657
5667
  alwaysRender,
@@ -5766,6 +5776,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5766
5776
  });
5767
5777
  }, [dataProp.length, didDataChangeLocal, initialScrollAtEnd, stylePaddingBottomState, usesBootstrapInitialScroll]);
5768
5778
  useLayoutEffect(() => {
5779
+ var _a4;
5780
+ if (didAnchoredEndSpaceAnchorIndexChange) {
5781
+ state.scrollForNextCalculateItemsInView = void 0;
5782
+ (_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state);
5783
+ }
5769
5784
  maybeUpdateAnchoredEndSpace(ctx);
5770
5785
  }, [
5771
5786
  ctx,
@@ -5774,6 +5789,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5774
5789
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex,
5775
5790
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorMaxSize,
5776
5791
  anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorOffset,
5792
+ didAnchoredEndSpaceAnchorIndexChange,
5777
5793
  numColumnsProp
5778
5794
  ]);
5779
5795
  const onLayoutFooter = useCallback(
@@ -5930,7 +5946,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5930
5946
  onScroll: onScrollHandler,
5931
5947
  recycleItems,
5932
5948
  refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React2.cloneElement(refreshControlElement, {
5933
- progressViewOffset: ((_g = refreshControlElement.props.progressViewOffset) != null ? _g : 0) + stylePaddingTopState
5949
+ progressViewOffset: ((_h = refreshControlElement.props.progressViewOffset) != null ? _h : 0) + stylePaddingTopState
5934
5950
  }) : refreshControlElement : onRefresh && /* @__PURE__ */ React2.createElement(
5935
5951
  RefreshControl,
5936
5952
  {
@@ -5941,7 +5957,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5941
5957
  ),
5942
5958
  refScrollView: combinedRef,
5943
5959
  renderScrollComponent,
5944
- scrollAdjustHandler: (_h = refState.current) == null ? void 0 : _h.scrollAdjustHandler,
5960
+ scrollAdjustHandler: (_i = refState.current) == null ? void 0 : _i.scrollAdjustHandler,
5945
5961
  scrollEventThrottle: 0,
5946
5962
  snapToIndices,
5947
5963
  stickyHeaderIndices,
@@ -220,7 +220,7 @@ type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResp
220
220
  reportContentInset(inset?: Partial<Insets$1> | null): void;
221
221
  };
222
222
 
223
- type KeyboardChatScrollViewPropsUnique = Omit<KeyboardChatScrollViewProps, keyof ScrollViewProps | "inverted" | "ScrollViewComponent" | "blankSpace">;
223
+ type KeyboardChatScrollViewPropsUnique = Omit<KeyboardChatScrollViewProps, keyof ScrollViewProps | "inverted" | "ScrollViewComponent" | "blankSpace" | "onContentInsetChange">;
224
224
  declare const KeyboardChatLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "anchoredEndSpace" | "renderScrollComponent"> & KeyboardChatScrollViewPropsUnique & {
225
225
  anchoredEndSpace?: AnchoredEndSpaceConfig;
226
226
  } & React.RefAttributes<LegendListRef>) => React.ReactElement | null;
package/keyboard-chat.js CHANGED
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
27
27
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
28
 
29
29
  // src/integrations/keyboard-chat.tsx
30
- var { typedForwardRef } = reactNative.internal;
30
+ var { typedForwardRef, useCombinedRef } = reactNative.internal;
31
31
  var KeyboardChatLegendList = typedForwardRef(function KeyboardChatLegendList2(props, forwardedRef) {
32
32
  const {
33
33
  anchoredEndSpace,
@@ -38,6 +38,8 @@ var KeyboardChatLegendList = typedForwardRef(function KeyboardChatLegendList2(pr
38
38
  offset,
39
39
  ...rest
40
40
  } = props;
41
+ const refLegendList = React.useRef(null);
42
+ const combinedRef = useCombinedRef(forwardedRef, refLegendList);
41
43
  const blankSpace = reactNativeReanimated.useSharedValue(0);
42
44
  React.useEffect(() => {
43
45
  if (!anchoredEndSpace) {
@@ -58,6 +60,10 @@ var KeyboardChatLegendList = typedForwardRef(function KeyboardChatLegendList2(pr
58
60
  }
59
61
  };
60
62
  }, [anchoredEndSpace, blankSpace]);
63
+ const onContentInsetChange = React.useCallback((insets) => {
64
+ var _a;
65
+ (_a = refLegendList.current) == null ? void 0 : _a.reportContentInset(insets);
66
+ }, []);
61
67
  const memoList = React.useCallback(
62
68
  (scrollProps) => {
63
69
  return /* @__PURE__ */ React__namespace.createElement(
@@ -69,7 +75,8 @@ var KeyboardChatLegendList = typedForwardRef(function KeyboardChatLegendList2(pr
69
75
  extraContentPadding,
70
76
  freeze,
71
77
  keyboardLiftBehavior,
72
- offset
78
+ offset,
79
+ onContentInsetChange
73
80
  }
74
81
  );
75
82
  },
@@ -79,6 +86,7 @@ var KeyboardChatLegendList = typedForwardRef(function KeyboardChatLegendList2(pr
79
86
  extraContentPadding,
80
87
  freeze,
81
88
  keyboardLiftBehavior,
89
+ onContentInsetChange,
82
90
  offset
83
91
  ]
84
92
  );
@@ -87,7 +95,7 @@ var KeyboardChatLegendList = typedForwardRef(function KeyboardChatLegendList2(pr
87
95
  AnimatedLegendListInternal,
88
96
  {
89
97
  anchoredEndSpace: anchoredEndSpaceWithBlankSpace,
90
- ref: forwardedRef,
98
+ ref: combinedRef,
91
99
  renderScrollComponent: memoList,
92
100
  ...rest
93
101
  }