@legendapp/list 3.0.0-beta.20 → 3.0.0-beta.22

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.mjs CHANGED
@@ -14,7 +14,7 @@ var Text = View;
14
14
 
15
15
  // src/state/getContentInsetEnd.ts
16
16
  function getContentInsetEnd(state) {
17
- var _a3;
17
+ var _a3, _b;
18
18
  const { props } = state;
19
19
  const horizontal = props.horizontal;
20
20
  let contentInset = props.contentInset;
@@ -28,7 +28,16 @@ function getContentInsetEnd(state) {
28
28
  }
29
29
  }
30
30
  }
31
- return (horizontal ? contentInset == null ? void 0 : contentInset.right : contentInset == null ? void 0 : contentInset.bottom) || 0;
31
+ const baseInset = contentInset != null ? contentInset : state.nativeContentInset;
32
+ const overrideInset = (_b = state.contentInsetOverride) != null ? _b : void 0;
33
+ if (overrideInset) {
34
+ const mergedInset = { top: 0, left: 0, right: 0, bottom: 0, ...baseInset, ...overrideInset };
35
+ return (horizontal ? mergedInset.right : mergedInset.bottom) || 0;
36
+ }
37
+ if (baseInset) {
38
+ return (horizontal ? baseInset.right : baseInset.bottom) || 0;
39
+ }
40
+ return 0;
32
41
  }
33
42
 
34
43
  // src/state/getContentSize.ts
@@ -295,7 +304,7 @@ var PositionViewState = typedMemo(function PositionViewState2({
295
304
  };
296
305
  const composed = isArray(style) ? Object.assign({}, ...style) : style;
297
306
  const combinedStyle = horizontal ? { ...base, ...composed, left: position } : { ...base, ...composed, top: position };
298
- const { animatedScrollY, stickyOffset, onLayout, ...webProps } = props;
307
+ const { animatedScrollY, stickyOffset, onLayout, index, ...webProps } = props;
299
308
  return /* @__PURE__ */ React3.createElement("div", { ref: refView, ...webProps, style: combinedStyle });
300
309
  });
301
310
  var PositionViewSticky = typedMemo(function PositionViewSticky2({
@@ -1732,7 +1741,7 @@ function updateScroll(ctx, newScroll, forceUpdate) {
1732
1741
  const scrollDelta = Math.abs(newScroll - prevScroll);
1733
1742
  const scrollLength = state.scrollLength;
1734
1743
  const lastCalculated = state.scrollLastCalculate;
1735
- const shouldUpdate = state.dataChangeNeedsScrollUpdate || state.scrollLastCalculate === void 0 || lastCalculated === void 0 || Math.abs(state.scroll - lastCalculated) > 2;
1744
+ const shouldUpdate = forceUpdate || state.dataChangeNeedsScrollUpdate || state.scrollLastCalculate === void 0 || lastCalculated === void 0 || Math.abs(state.scroll - lastCalculated) > 2;
1736
1745
  if (shouldUpdate) {
1737
1746
  state.scrollLastCalculate = state.scroll;
1738
1747
  state.ignoreScrollFromMVCPIgnored = false;
@@ -2511,7 +2520,7 @@ function getActiveStickyIndices(ctx, stickyHeaderIndices) {
2511
2520
  Array.from(state.stickyContainerPool).map((i) => peek$(ctx, `containerItemKey${i}`)).map((key) => key ? state.indexByKey.get(key) : void 0).filter((idx) => idx !== void 0 && stickyHeaderIndices.has(idx))
2512
2521
  );
2513
2522
  }
2514
- function handleStickyActivation(ctx, stickyHeaderIndices, stickyArray, currentStickyIdx, needNewContainers, startBuffered, endBuffered) {
2523
+ function handleStickyActivation(ctx, stickyHeaderIndices, stickyArray, currentStickyIdx, needNewContainers, needNewContainersSet, startBuffered, endBuffered) {
2515
2524
  var _a3;
2516
2525
  const state = ctx.state;
2517
2526
  const activeIndices = getActiveStickyIndices(ctx, stickyHeaderIndices);
@@ -2521,18 +2530,20 @@ function handleStickyActivation(ctx, stickyHeaderIndices, stickyArray, currentSt
2521
2530
  if (idx < 0 || activeIndices.has(stickyArray[idx])) continue;
2522
2531
  const stickyIndex = stickyArray[idx];
2523
2532
  const stickyId = (_a3 = state.idCache[stickyIndex]) != null ? _a3 : getId(state, stickyIndex);
2524
- if (stickyId && !state.containerItemKeys.has(stickyId) && (stickyIndex < startBuffered || stickyIndex > endBuffered)) {
2533
+ if (stickyId && !state.containerItemKeys.has(stickyId) && (stickyIndex < startBuffered || stickyIndex > endBuffered) && !needNewContainersSet.has(stickyIndex)) {
2534
+ needNewContainersSet.add(stickyIndex);
2525
2535
  needNewContainers.push(stickyIndex);
2526
2536
  }
2527
2537
  }
2528
2538
  }
2529
- function handleStickyRecycling(ctx, stickyArray, scroll, scrollBuffer, currentStickyIdx, pendingRemoval) {
2539
+ function handleStickyRecycling(ctx, stickyArray, scroll, scrollBuffer, currentStickyIdx, pendingRemoval, alwaysRenderIndicesSet) {
2530
2540
  var _a3, _b, _c;
2531
2541
  const state = ctx.state;
2532
2542
  for (const containerIndex of state.stickyContainerPool) {
2533
2543
  const itemKey = peek$(ctx, `containerItemKey${containerIndex}`);
2534
2544
  const itemIndex = itemKey ? state.indexByKey.get(itemKey) : void 0;
2535
2545
  if (itemIndex === void 0) continue;
2546
+ if (alwaysRenderIndicesSet.has(itemIndex)) continue;
2536
2547
  const arrayIdx = stickyArray.indexOf(itemIndex);
2537
2548
  if (arrayIdx === -1) {
2538
2549
  state.stickyContainerPool.delete(containerIndex);
@@ -2564,7 +2575,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, scrollBuffer, currentSt
2564
2575
  function calculateItemsInView(ctx, params = {}) {
2565
2576
  const state = ctx.state;
2566
2577
  unstable_batchedUpdates(() => {
2567
- var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2578
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2568
2579
  const {
2569
2580
  columns,
2570
2581
  containerItemKeys,
@@ -2574,7 +2585,15 @@ function calculateItemsInView(ctx, params = {}) {
2574
2585
  initialScroll,
2575
2586
  minIndexSizeChanged,
2576
2587
  positions,
2577
- props: { getItemType, itemsAreEqual, keyExtractor, onStickyHeaderChange, scrollBuffer },
2588
+ props: {
2589
+ alwaysRenderIndicesArr,
2590
+ alwaysRenderIndicesSet,
2591
+ getItemType,
2592
+ itemsAreEqual,
2593
+ keyExtractor,
2594
+ onStickyHeaderChange,
2595
+ scrollBuffer
2596
+ },
2578
2597
  scrollForNextCalculateItemsInView,
2579
2598
  scrollLength,
2580
2599
  sizes,
@@ -2584,6 +2603,8 @@ function calculateItemsInView(ctx, params = {}) {
2584
2603
  const { data } = state.props;
2585
2604
  const stickyIndicesArr = state.props.stickyIndicesArr || [];
2586
2605
  const stickyIndicesSet = state.props.stickyIndicesSet || /* @__PURE__ */ new Set();
2606
+ const alwaysRenderArr = alwaysRenderIndicesArr || [];
2607
+ const alwaysRenderSet = alwaysRenderIndicesSet || /* @__PURE__ */ new Set();
2587
2608
  const prevNumContainers = peek$(ctx, "numContainers");
2588
2609
  if (!data || scrollLength === 0 || !prevNumContainers) {
2589
2610
  return;
@@ -2760,12 +2781,24 @@ function calculateItemsInView(ctx, params = {}) {
2760
2781
  }
2761
2782
  if (startBuffered !== null && endBuffered !== null) {
2762
2783
  const needNewContainers = [];
2784
+ const needNewContainersSet = /* @__PURE__ */ new Set();
2763
2785
  for (let i = startBuffered; i <= endBuffered; i++) {
2764
2786
  const id = (_h = idCache[i]) != null ? _h : getId(state, i);
2765
2787
  if (!containerItemKeys.has(id)) {
2788
+ needNewContainersSet.add(i);
2766
2789
  needNewContainers.push(i);
2767
2790
  }
2768
2791
  }
2792
+ if (alwaysRenderArr.length > 0) {
2793
+ for (const index of alwaysRenderArr) {
2794
+ if (index < 0 || index >= dataLength) continue;
2795
+ const id = (_i = idCache[index]) != null ? _i : getId(state, index);
2796
+ if (id && !containerItemKeys.has(id) && !needNewContainersSet.has(index)) {
2797
+ needNewContainersSet.add(index);
2798
+ needNewContainers.push(index);
2799
+ }
2800
+ }
2801
+ }
2769
2802
  if (stickyIndicesArr.length > 0) {
2770
2803
  handleStickyActivation(
2771
2804
  ctx,
@@ -2773,6 +2806,7 @@ function calculateItemsInView(ctx, params = {}) {
2773
2806
  stickyIndicesArr,
2774
2807
  currentStickyIdx,
2775
2808
  needNewContainers,
2809
+ needNewContainersSet,
2776
2810
  startBuffered,
2777
2811
  endBuffered
2778
2812
  );
@@ -2796,7 +2830,7 @@ function calculateItemsInView(ctx, params = {}) {
2796
2830
  for (let idx = 0; idx < needNewContainers.length; idx++) {
2797
2831
  const i = needNewContainers[idx];
2798
2832
  const containerIndex = availableContainers[idx];
2799
- const id = (_i = idCache[i]) != null ? _i : getId(state, i);
2833
+ const id = (_j = idCache[i]) != null ? _j : getId(state, i);
2800
2834
  const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
2801
2835
  if (oldKey && oldKey !== id) {
2802
2836
  containerItemKeys.delete(oldKey);
@@ -2808,14 +2842,23 @@ function calculateItemsInView(ctx, params = {}) {
2808
2842
  }
2809
2843
  containerItemKeys.set(id, containerIndex);
2810
2844
  const containerSticky = `containerSticky${containerIndex}`;
2811
- if (stickyIndicesSet.has(i)) {
2845
+ const isSticky = stickyIndicesSet.has(i);
2846
+ const isAlwaysRender = alwaysRenderSet.has(i);
2847
+ if (isSticky) {
2812
2848
  set$(ctx, containerSticky, true);
2813
2849
  const topPadding = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
2814
2850
  set$(ctx, `containerStickyOffset${containerIndex}`, topPadding);
2815
2851
  state.stickyContainerPool.add(containerIndex);
2816
- } else if (peek$(ctx, containerSticky)) {
2817
- set$(ctx, containerSticky, false);
2818
- state.stickyContainerPool.delete(containerIndex);
2852
+ } else {
2853
+ if (peek$(ctx, containerSticky)) {
2854
+ set$(ctx, containerSticky, false);
2855
+ set$(ctx, `containerStickyOffset${containerIndex}`, void 0);
2856
+ }
2857
+ if (isAlwaysRender) {
2858
+ state.stickyContainerPool.add(containerIndex);
2859
+ } else if (state.stickyContainerPool.has(containerIndex)) {
2860
+ state.stickyContainerPool.delete(containerIndex);
2861
+ }
2819
2862
  }
2820
2863
  if (containerIndex >= numContainers) {
2821
2864
  numContainers = containerIndex + 1;
@@ -2828,9 +2871,27 @@ function calculateItemsInView(ctx, params = {}) {
2828
2871
  }
2829
2872
  }
2830
2873
  }
2874
+ if (alwaysRenderArr.length > 0) {
2875
+ for (const index of alwaysRenderArr) {
2876
+ if (index < 0 || index >= dataLength) continue;
2877
+ const id = (_k = idCache[index]) != null ? _k : getId(state, index);
2878
+ const containerIndex = containerItemKeys.get(id);
2879
+ if (containerIndex !== void 0) {
2880
+ state.stickyContainerPool.add(containerIndex);
2881
+ }
2882
+ }
2883
+ }
2831
2884
  }
2832
- if (stickyIndicesArr.length > 0) {
2833
- handleStickyRecycling(ctx, stickyIndicesArr, scroll, scrollBuffer, currentStickyIdx, pendingRemoval);
2885
+ if (state.stickyContainerPool.size > 0) {
2886
+ handleStickyRecycling(
2887
+ ctx,
2888
+ stickyIndicesArr,
2889
+ scroll,
2890
+ scrollBuffer,
2891
+ currentStickyIdx,
2892
+ pendingRemoval,
2893
+ alwaysRenderSet
2894
+ );
2834
2895
  }
2835
2896
  let didChangePositions = false;
2836
2897
  for (let i = 0; i < numContainers; i++) {
@@ -2853,7 +2914,7 @@ function calculateItemsInView(ctx, params = {}) {
2853
2914
  const itemIndex = indexByKey.get(itemKey);
2854
2915
  const item = data[itemIndex];
2855
2916
  if (item !== void 0) {
2856
- const id = (_j = idCache[itemIndex]) != null ? _j : getId(state, itemIndex);
2917
+ const id = (_l = idCache[itemIndex]) != null ? _l : getId(state, itemIndex);
2857
2918
  const positionValue = positions.get(id);
2858
2919
  if (positionValue === void 0) {
2859
2920
  set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
@@ -3170,7 +3231,7 @@ function handleLayout(ctx, layout, setCanRender) {
3170
3231
 
3171
3232
  // src/core/onScroll.ts
3172
3233
  function onScroll(ctx, event) {
3173
- var _a3, _b, _c;
3234
+ var _a3, _b, _c, _d;
3174
3235
  const state = ctx.state;
3175
3236
  const {
3176
3237
  scrollProcessingEnabled,
@@ -3182,6 +3243,15 @@ function onScroll(ctx, event) {
3182
3243
  if (((_b = (_a3 = event.nativeEvent) == null ? void 0 : _a3.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
3183
3244
  return;
3184
3245
  }
3246
+ let insetChanged = false;
3247
+ if ((_d = event.nativeEvent) == null ? void 0 : _d.contentInset) {
3248
+ const { contentInset } = event.nativeEvent;
3249
+ const prevInset = state.nativeContentInset;
3250
+ if (!prevInset || prevInset.top !== contentInset.top || prevInset.bottom !== contentInset.bottom || prevInset.left !== contentInset.left || prevInset.right !== contentInset.right) {
3251
+ state.nativeContentInset = contentInset;
3252
+ insetChanged = true;
3253
+ }
3254
+ }
3185
3255
  let newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
3186
3256
  if (state.scrollingTo) {
3187
3257
  const maxOffset = clampScrollOffset(ctx, newScroll);
@@ -3197,7 +3267,7 @@ function onScroll(ctx, event) {
3197
3267
  }
3198
3268
  }
3199
3269
  state.scrollPending = newScroll;
3200
- updateScroll(ctx, newScroll);
3270
+ updateScroll(ctx, newScroll, insetChanged);
3201
3271
  if (state.scrollingTo) {
3202
3272
  checkFinishedScroll(ctx);
3203
3273
  }
@@ -3370,7 +3440,10 @@ function updateOneItemSize(ctx, itemKey, sizeObj) {
3370
3440
  if (!averages) {
3371
3441
  averages = averageSizes[itemType] = { avg: 0, num: 0 };
3372
3442
  }
3373
- if (prevSizeKnown !== void 0 && prevSizeKnown > 0) {
3443
+ if (averages.num === 0) {
3444
+ averages.avg = size;
3445
+ averages.num++;
3446
+ } else if (prevSizeKnown !== void 0 && prevSizeKnown > 0) {
3374
3447
  averages.avg += (size - prevSizeKnown) / averages.num;
3375
3448
  } else {
3376
3449
  averages.avg = (averages.avg * averages.num + size) / (averages.num + 1);
@@ -3455,7 +3528,7 @@ function createImperativeHandle(ctx) {
3455
3528
  getScrollResponder: () => refScroller.current.getScrollResponder(),
3456
3529
  getState: () => ({
3457
3530
  activeStickyIndex: peek$(ctx, "activeStickyIndex"),
3458
- contentLength: state.totalSize,
3531
+ contentLength: getContentSize(ctx),
3459
3532
  data: state.props.data,
3460
3533
  elementAtIndex: (index) => {
3461
3534
  var _a3;
@@ -3471,6 +3544,7 @@ function createImperativeHandle(ctx) {
3471
3544
  positions: state.positions,
3472
3545
  scroll: state.scroll,
3473
3546
  scrollLength: state.scrollLength,
3547
+ scrollVelocity: getScrollVelocity(state),
3474
3548
  sizeAtIndex: (index) => state.sizesKnown.get(getId(state, index)),
3475
3549
  sizes: state.sizesKnown,
3476
3550
  start: state.startNoBuffer,
@@ -3508,6 +3582,10 @@ function createImperativeHandle(ctx) {
3508
3582
  }
3509
3583
  },
3510
3584
  scrollToOffset: (params) => scrollTo(ctx, params),
3585
+ reportContentInset: (inset) => {
3586
+ state.contentInsetOverride = inset != null ? inset : void 0;
3587
+ updateScroll(ctx, state.scroll, true);
3588
+ },
3511
3589
  setScrollProcessingEnabled: (enabled) => {
3512
3590
  state.scrollProcessingEnabled = enabled;
3513
3591
  },
@@ -3517,6 +3595,54 @@ function createImperativeHandle(ctx) {
3517
3595
  }
3518
3596
  };
3519
3597
  }
3598
+
3599
+ // src/utils/getAlwaysRenderIndices.ts
3600
+ var sortAsc = (a, b) => a - b;
3601
+ var toCount = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : 0;
3602
+ var addIndex = (result, dataLength, index) => {
3603
+ if (index >= 0 && index < dataLength) {
3604
+ result.add(index);
3605
+ }
3606
+ };
3607
+ function getAlwaysRenderIndices(config, data, keyExtractor) {
3608
+ var _a3, _b;
3609
+ if (!config || data.length === 0) {
3610
+ return [];
3611
+ }
3612
+ const result = /* @__PURE__ */ new Set();
3613
+ const dataLength = data.length;
3614
+ const topCount = toCount(config.top);
3615
+ if (topCount > 0) {
3616
+ for (let i = 0; i < Math.min(topCount, dataLength); i++) {
3617
+ addIndex(result, dataLength, i);
3618
+ }
3619
+ }
3620
+ const bottomCount = toCount(config.bottom);
3621
+ if (bottomCount > 0) {
3622
+ for (let i = Math.max(0, dataLength - bottomCount); i < dataLength; i++) {
3623
+ addIndex(result, dataLength, i);
3624
+ }
3625
+ }
3626
+ if ((_a3 = config.indices) == null ? void 0 : _a3.length) {
3627
+ for (const index of config.indices) {
3628
+ if (!Number.isFinite(index)) continue;
3629
+ addIndex(result, dataLength, Math.floor(index));
3630
+ }
3631
+ }
3632
+ if ((_b = config.keys) == null ? void 0 : _b.length) {
3633
+ const keys = new Set(config.keys);
3634
+ for (let i = 0; i < dataLength && keys.size > 0; i++) {
3635
+ const key = keyExtractor(data[i], i);
3636
+ if (keys.has(key)) {
3637
+ addIndex(result, dataLength, i);
3638
+ keys.delete(key);
3639
+ }
3640
+ }
3641
+ }
3642
+ const indices = Array.from(result);
3643
+ indices.sort(sortAsc);
3644
+ return indices;
3645
+ }
3520
3646
  function getRenderedItem(ctx, key) {
3521
3647
  var _a3;
3522
3648
  const state = ctx.state;
@@ -3633,9 +3759,10 @@ var LegendList = typedMemo(
3633
3759
  })
3634
3760
  );
3635
3761
  var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
3636
- var _a3, _b;
3762
+ var _a3, _b, _c, _d;
3637
3763
  const {
3638
3764
  alignItemsAtEnd = false,
3765
+ alwaysRender,
3639
3766
  columnWrapperStyle,
3640
3767
  contentContainerStyle: contentContainerStyleProp,
3641
3768
  contentInset,
@@ -3664,6 +3791,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3664
3791
  onEndReached,
3665
3792
  onEndReachedThreshold = 0.5,
3666
3793
  onItemSizeChanged,
3794
+ onMetricsChange,
3667
3795
  onLayout: onLayoutProp,
3668
3796
  onLoad,
3669
3797
  onMomentumScrollEnd,
@@ -3712,6 +3840,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3712
3840
  const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
3713
3841
  const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (_item, index) => index.toString();
3714
3842
  const stickyHeaderIndices = stickyHeaderIndicesProp != null ? stickyHeaderIndicesProp : stickyIndicesDeprecated;
3843
+ const alwaysRenderIndices = useMemo(() => {
3844
+ const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor);
3845
+ return { arr: indices, set: new Set(indices) };
3846
+ }, [
3847
+ alwaysRender == null ? void 0 : alwaysRender.top,
3848
+ alwaysRender == null ? void 0 : alwaysRender.bottom,
3849
+ (_a3 = alwaysRender == null ? void 0 : alwaysRender.indices) == null ? void 0 : _a3.join(","),
3850
+ (_b = alwaysRender == null ? void 0 : alwaysRender.keys) == null ? void 0 : _b.join(","),
3851
+ dataProp,
3852
+ dataVersion,
3853
+ keyExtractor
3854
+ ]);
3715
3855
  if (IS_DEV && stickyIndicesDeprecated && !stickyHeaderIndicesProp) {
3716
3856
  warnDevOnce(
3717
3857
  "stickyIndices",
@@ -3743,7 +3883,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3743
3883
  attempts: 0,
3744
3884
  index: initialScrollProp.index,
3745
3885
  settledTicks: 0,
3746
- viewOffset: (_a3 = initialScrollProp.viewOffset) != null ? _a3 : 0,
3886
+ viewOffset: (_c = initialScrollProp.viewOffset) != null ? _c : 0,
3747
3887
  viewPosition: initialScrollProp.viewPosition
3748
3888
  } : void 0,
3749
3889
  initialScroll: initialScrollProp,
@@ -3757,6 +3897,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3757
3897
  lastScrollDelta: 0,
3758
3898
  loadStartTime: Date.now(),
3759
3899
  minIndexSizeChanged: 0,
3900
+ contentInsetOverride: void 0,
3901
+ nativeContentInset: void 0,
3760
3902
  nativeMarginTop: 0,
3761
3903
  positions: /* @__PURE__ */ new Map(),
3762
3904
  props: {},
@@ -3803,6 +3945,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3803
3945
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? useThrottledOnScroll(onScrollProp, scrollEventThrottle) : onScrollProp;
3804
3946
  state.props = {
3805
3947
  alignItemsAtEnd,
3948
+ alwaysRender,
3949
+ alwaysRenderIndicesArr: alwaysRenderIndices.arr,
3950
+ alwaysRenderIndicesSet: alwaysRenderIndices.set,
3806
3951
  animatedProps: animatedPropsInternal,
3807
3952
  contentInset,
3808
3953
  data: dataProp,
@@ -3968,6 +4113,34 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3968
4113
  stylePaddingBottomState,
3969
4114
  stylePaddingTopState
3970
4115
  ]);
4116
+ useEffect(() => {
4117
+ if (!onMetricsChange) {
4118
+ return;
4119
+ }
4120
+ let lastMetrics;
4121
+ const emitMetrics = () => {
4122
+ const metrics = {
4123
+ alignItemsAtEndPadding: peek$(ctx, "alignItemsPaddingTop") || 0,
4124
+ footerSize: peek$(ctx, "footerSize") || 0,
4125
+ headerSize: peek$(ctx, "headerSize") || 0
4126
+ };
4127
+ if (!lastMetrics || metrics.alignItemsAtEndPadding !== lastMetrics.alignItemsAtEndPadding || metrics.headerSize !== lastMetrics.headerSize || metrics.footerSize !== lastMetrics.footerSize) {
4128
+ lastMetrics = metrics;
4129
+ onMetricsChange(metrics);
4130
+ }
4131
+ };
4132
+ emitMetrics();
4133
+ const unsubscribe = [
4134
+ listen$(ctx, "alignItemsPaddingTop", emitMetrics),
4135
+ listen$(ctx, "headerSize", emitMetrics),
4136
+ listen$(ctx, "footerSize", emitMetrics)
4137
+ ];
4138
+ return () => {
4139
+ for (const unsub of unsubscribe) {
4140
+ unsub();
4141
+ }
4142
+ };
4143
+ }, [ctx, onMetricsChange]);
3971
4144
  useEffect(() => {
3972
4145
  const viewability = setupViewability({
3973
4146
  onViewableItemsChanged,
@@ -4025,7 +4198,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
4025
4198
  }
4026
4199
  ),
4027
4200
  refScrollView: combinedRef,
4028
- scrollAdjustHandler: (_b = refState.current) == null ? void 0 : _b.scrollAdjustHandler,
4201
+ scrollAdjustHandler: (_d = refState.current) == null ? void 0 : _d.scrollAdjustHandler,
4029
4202
  scrollEventThrottle: 0,
4030
4203
  snapToIndices,
4031
4204
  stickyHeaderConfig,