@legendapp/list 3.2.0 → 3.3.0

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.
@@ -1069,32 +1069,34 @@ function scheduleAdaptiveRenderExit(ctx, exitDelay) {
1069
1069
  const state = ctx.state;
1070
1070
  clearAdaptiveRenderExitTimeout(ctx);
1071
1071
  if (exitDelay <= 0) {
1072
- setAdaptiveRender(ctx, "normal");
1072
+ setAdaptiveRender(ctx, "normal", "scroll");
1073
1073
  } else {
1074
1074
  const timeout = setTimeout(() => {
1075
1075
  state.timeouts.delete(timeout);
1076
1076
  state.timeoutAdaptiveRender = void 0;
1077
- setAdaptiveRender(ctx, "normal");
1077
+ setAdaptiveRender(ctx, "normal", "scroll");
1078
1078
  }, exitDelay);
1079
1079
  state.timeoutAdaptiveRender = timeout;
1080
1080
  state.timeouts.add(timeout);
1081
1081
  }
1082
1082
  }
1083
- function setAdaptiveRender(ctx, mode) {
1083
+ function setAdaptiveRender(ctx, mode, reason) {
1084
1084
  var _a3, _b;
1085
1085
  const previousMode = peek$(ctx, "adaptiveRender");
1086
1086
  if (previousMode !== mode) {
1087
1087
  set$(ctx, "adaptiveRender", mode);
1088
- (_b = (_a3 = ctx.state.props.adaptiveRender) == null ? void 0 : _a3.onChange) == null ? void 0 : _b.call(_a3, mode);
1088
+ (_b = (_a3 = ctx.state.props.adaptiveRender) == null ? void 0 : _a3.onChange) == null ? void 0 : _b.call(_a3, mode, reason);
1089
1089
  }
1090
1090
  }
1091
1091
  function resetAdaptiveRender(ctx) {
1092
+ var _a3, _b;
1092
1093
  clearAdaptiveRenderExitTimeout(ctx);
1093
- if (peek$(ctx, "adaptiveRender") !== "normal") {
1094
- setAdaptiveRender(ctx, "normal");
1094
+ const mode = (_b = (_a3 = ctx.state.props.adaptiveRender) == null ? void 0 : _a3.initialMode) != null ? _b : "normal";
1095
+ if (peek$(ctx, "adaptiveRender") !== mode) {
1096
+ setAdaptiveRender(ctx, mode, "initial");
1095
1097
  }
1096
1098
  }
1097
- function updateAdaptiveRender(ctx, scrollVelocity) {
1099
+ function updateAdaptiveRender(ctx, scrollVelocity, options) {
1098
1100
  var _a3, _b, _c;
1099
1101
  const state = ctx.state;
1100
1102
  const adaptiveRender = state.props.adaptiveRender;
@@ -1105,11 +1107,11 @@ function updateAdaptiveRender(ctx, scrollVelocity) {
1105
1107
  const exitVelocity = (_b = adaptiveRender.exitVelocity) != null ? _b : DEFAULT_WEB_ADAPTIVE_RENDER_EXIT_VELOCITY ;
1106
1108
  const exitDelay = (_c = adaptiveRender.exitDelay) != null ? _c : DEFAULT_WEB_ADAPTIVE_RENDER_EXIT_DELAY ;
1107
1109
  const threshold = currentMode === "light" ? exitVelocity : enterVelocity;
1108
- const nextMode = Math.abs(scrollVelocity) > threshold ? "light" : "normal";
1110
+ const nextMode = (options == null ? void 0 : options.forceLight) || Math.abs(scrollVelocity) > threshold ? "light" : "normal";
1109
1111
  const previousMode = state.timeoutAdaptiveRender !== void 0 ? "normal" : currentMode;
1110
1112
  if (nextMode !== previousMode) {
1111
1113
  if (nextMode === "light") {
1112
- setAdaptiveRender(ctx, "light");
1114
+ setAdaptiveRender(ctx, "light", "scroll");
1113
1115
  scheduleAdaptiveRenderExit(ctx, exitDelay);
1114
1116
  } else if (currentMode === "light") {
1115
1117
  scheduleAdaptiveRenderExit(ctx, exitDelay);
@@ -1122,16 +1124,43 @@ function updateAdaptiveRender(ctx, scrollVelocity) {
1122
1124
  }
1123
1125
 
1124
1126
  // src/utils/getEffectiveDrawDistance.ts
1125
- var INITIAL_DRAW_DISTANCE = 100;
1126
- function getEffectiveDrawDistance(ctx) {
1127
+ var INITIAL_DRAW_DISTANCE = 50;
1128
+ function getEffectiveDrawDistance(ctx, mode) {
1127
1129
  var _a3;
1128
1130
  const drawDistance = ctx.state.props.drawDistance;
1129
1131
  const initialScroll = ctx.state.initialScroll;
1130
1132
  const needsFullInitialDrawDistance = initialScroll !== void 0 && ((_a3 = initialScroll.viewPosition) != null ? _a3 : 0) > 0;
1131
- return peek$(ctx, "readyToRender") || needsFullInitialDrawDistance ? drawDistance : Math.min(drawDistance, INITIAL_DRAW_DISTANCE);
1133
+ const shouldCapDrawDistance = mode === "visible-first" || mode !== "full" && !peek$(ctx, "readyToRender") && !needsFullInitialDrawDistance;
1134
+ return shouldCapDrawDistance ? Math.min(drawDistance, INITIAL_DRAW_DISTANCE) : drawDistance;
1135
+ }
1136
+ function scheduleFullDrawDistancePrewarm(ctx) {
1137
+ const { state } = ctx;
1138
+ if (state.props.drawDistance <= INITIAL_DRAW_DISTANCE || state.queuedFullDrawDistancePrewarm !== void 0) {
1139
+ return;
1140
+ }
1141
+ state.queuedFullDrawDistancePrewarm = requestAnimationFrame(() => {
1142
+ var _a3;
1143
+ state.queuedFullDrawDistancePrewarm = void 0;
1144
+ (_a3 = state.triggerCalculateItemsInView) == null ? void 0 : _a3.call(state);
1145
+ });
1132
1146
  }
1133
1147
 
1134
1148
  // src/utils/setInitialRenderState.ts
1149
+ function resetInitialRenderState(ctx, {
1150
+ resetLayout,
1151
+ resetInitialScroll
1152
+ }) {
1153
+ const { state } = ctx;
1154
+ if (resetLayout) {
1155
+ state.didContainersLayout = false;
1156
+ state.queuedInitialLayout = false;
1157
+ }
1158
+ if (resetInitialScroll) {
1159
+ state.didFinishInitialScroll = false;
1160
+ }
1161
+ set$(ctx, "readyToRender", false);
1162
+ resetAdaptiveRender(ctx);
1163
+ }
1135
1164
  function setInitialRenderState(ctx, {
1136
1165
  didLayout,
1137
1166
  didInitialScroll
@@ -1150,15 +1179,15 @@ function setInitialRenderState(ctx, {
1150
1179
  const isReadyToRender = Boolean(state.didContainersLayout && state.didFinishInitialScroll);
1151
1180
  if (isReadyToRender && !peek$(ctx, "readyToRender")) {
1152
1181
  set$(ctx, "readyToRender", true);
1153
- setAdaptiveRender(ctx, "normal");
1182
+ setAdaptiveRender(ctx, "normal", "ready");
1154
1183
  if (state.props.drawDistance > INITIAL_DRAW_DISTANCE) {
1155
- requestAnimationFrame(() => {
1156
- var _a3;
1157
- (_a3 = state.triggerCalculateItemsInView) == null ? void 0 : _a3.call(state);
1158
- });
1184
+ scheduleFullDrawDistancePrewarm(ctx);
1159
1185
  }
1160
- if (onLoad) {
1161
- onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
1186
+ if (!state.didLoad) {
1187
+ state.didLoad = true;
1188
+ if (onLoad) {
1189
+ onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
1190
+ }
1162
1191
  }
1163
1192
  }
1164
1193
  }
@@ -1582,8 +1611,8 @@ function doMaintainScrollAtEnd(ctx) {
1582
1611
  state.pendingMaintainScrollAtEnd = shouldMaintainScrollAtEnd;
1583
1612
  return false;
1584
1613
  }
1585
- state.pendingMaintainScrollAtEnd = false;
1586
1614
  if (shouldMaintainScrollAtEnd) {
1615
+ state.pendingMaintainScrollAtEnd = false;
1587
1616
  const contentSize = getContentSize(ctx);
1588
1617
  if (contentSize < state.scrollLength) {
1589
1618
  state.scroll = 0;
@@ -1614,6 +1643,9 @@ function doMaintainScrollAtEnd(ctx) {
1614
1643
  () => {
1615
1644
  if (state.maintainingScrollAtEnd === activeState) {
1616
1645
  state.maintainingScrollAtEnd = void 0;
1646
+ if (state.pendingMaintainScrollAtEnd) {
1647
+ doMaintainScrollAtEnd(ctx);
1648
+ }
1617
1649
  }
1618
1650
  },
1619
1651
  maintainScrollAtEnd.animated ? 500 : 0
@@ -1622,9 +1654,12 @@ function doMaintainScrollAtEnd(ctx) {
1622
1654
  state.maintainingScrollAtEnd = void 0;
1623
1655
  }
1624
1656
  });
1657
+ } else {
1658
+ state.pendingMaintainScrollAtEnd = true;
1625
1659
  }
1626
1660
  return true;
1627
1661
  }
1662
+ state.pendingMaintainScrollAtEnd = false;
1628
1663
  return false;
1629
1664
  }
1630
1665
 
@@ -2005,8 +2040,6 @@ function updateScroll(ctx, newScroll, forceUpdate, options) {
2005
2040
  if (scrollHistory.length > 5) {
2006
2041
  scrollHistory.shift();
2007
2042
  }
2008
- const scrollVelocity = getScrollVelocity(state);
2009
- updateAdaptiveRender(ctx, scrollVelocity);
2010
2043
  if (ignoreScrollFromMVCP && !scrollingTo) {
2011
2044
  const { lt, gt } = ignoreScrollFromMVCP;
2012
2045
  if (lt && newScroll < lt || gt && newScroll > gt) {
@@ -2021,6 +2054,9 @@ function updateScroll(ctx, newScroll, forceUpdate, options) {
2021
2054
  const scrollDelta = Math.abs(newScroll - prevScroll);
2022
2055
  const didResolvePendingNativeMVCPAdjust = resolvePendingNativeMVCPAdjust(ctx, newScroll);
2023
2056
  const scrollLength = state.scrollLength;
2057
+ const isLargeUserScrollJump = scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength && !state.pendingNativeMVCPAdjust;
2058
+ const scrollVelocity = getScrollVelocity(state);
2059
+ updateAdaptiveRender(ctx, scrollVelocity, { forceLight: isLargeUserScrollJump });
2024
2060
  const lastCalculated = state.scrollLastCalculate;
2025
2061
  const useAggressiveItemRecalculation = isInMVCPActiveMode(state);
2026
2062
  const shouldUpdate = useAggressiveItemRecalculation || didResolvePendingNativeMVCPAdjust || forceUpdate || lastCalculated === void 0 || Math.abs(state.scroll - lastCalculated) > 2;
@@ -2030,10 +2066,17 @@ function updateScroll(ctx, newScroll, forceUpdate, options) {
2030
2066
  state.lastScrollDelta = scrollDelta;
2031
2067
  const runCalculateItems = () => {
2032
2068
  var _a4;
2033
- (_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state, { doMVCP: scrollingTo !== void 0, scrollVelocity });
2069
+ const calculateItemsParams = {
2070
+ doMVCP: scrollingTo !== void 0,
2071
+ scrollVelocity
2072
+ };
2073
+ if (isLargeUserScrollJump) {
2074
+ calculateItemsParams.drawDistanceMode = "visible-first";
2075
+ }
2076
+ (_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state, calculateItemsParams);
2034
2077
  checkThresholds(ctx);
2035
2078
  };
2036
- if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength && !state.pendingNativeMVCPAdjust) {
2079
+ if (isLargeUserScrollJump) {
2037
2080
  state.mvcpAnchorLock = void 0;
2038
2081
  state.pendingNativeMVCPAdjust = void 0;
2039
2082
  state.userScrollAnchorReset = { keys: /* @__PURE__ */ new Set() };
@@ -2042,6 +2085,7 @@ function updateScroll(ctx, newScroll, forceUpdate, options) {
2042
2085
  state.queuedMVCPRecalculate = void 0;
2043
2086
  }
2044
2087
  ReactDOM.flushSync(runCalculateItems);
2088
+ scheduleFullDrawDistancePrewarm(ctx);
2045
2089
  } else {
2046
2090
  runCalculateItems();
2047
2091
  }
@@ -2196,16 +2240,17 @@ function dispatchInitialScroll(ctx, params) {
2196
2240
  waitForInitialScrollCompletionFrame: waitForCompletionFrame
2197
2241
  });
2198
2242
  }
2199
- function setInitialScrollTarget(state, target, options) {
2243
+ function setInitialScrollTarget(ctx, target, options) {
2200
2244
  var _a3;
2245
+ const { state } = ctx;
2201
2246
  state.clearPreservedInitialScrollOnNextFinish = void 0;
2202
2247
  if (state.timeoutPreservedInitialScrollClear !== void 0) {
2203
2248
  clearTimeout(state.timeoutPreservedInitialScrollClear);
2204
2249
  state.timeoutPreservedInitialScrollClear = void 0;
2205
2250
  }
2206
2251
  state.initialScroll = target;
2207
- if ((options == null ? void 0 : options.resetDidFinish) && state.didFinishInitialScroll) {
2208
- state.didFinishInitialScroll = false;
2252
+ if (options == null ? void 0 : options.resetDidFinish) {
2253
+ resetInitialRenderState(ctx, { resetInitialScroll: true });
2209
2254
  }
2210
2255
  setInitialScrollSession(state, {
2211
2256
  kind: ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "offset" ? "offset" : "bootstrap"
@@ -2259,7 +2304,7 @@ function advanceMeasuredInitialScroll(ctx, options) {
2259
2304
  return false;
2260
2305
  }
2261
2306
  if (didOffsetChange && ((_b = state.initialScrollSession) == null ? void 0 : _b.kind) !== "offset") {
2262
- setInitialScrollTarget(state, { ...initialScroll, contentOffset: resolvedOffset });
2307
+ setInitialScrollTarget(ctx, { ...initialScroll, contentOffset: resolvedOffset });
2263
2308
  }
2264
2309
  const forceScroll = (_c = options == null ? void 0 : options.forceScroll) != null ? _c : !!queuedInitialLayout || isInitialScrollInProgress && didOffsetChange;
2265
2310
  dispatchInitialScroll(ctx, {
@@ -2532,7 +2577,6 @@ function areEquivalentBootstrapInitialScrollTargets(current, next) {
2532
2577
  }
2533
2578
  function clearPendingInitialScrollFooterLayout(ctx, options) {
2534
2579
  const { dataLength, stylePaddingBottom, target } = options;
2535
- const state = ctx.state;
2536
2580
  if (!shouldPreserveInitialScrollForFooterLayout(target)) {
2537
2581
  return;
2538
2582
  }
@@ -2542,7 +2586,7 @@ function clearPendingInitialScrollFooterLayout(ctx, options) {
2542
2586
  preserveForFooterLayout: void 0,
2543
2587
  stylePaddingBottom
2544
2588
  });
2545
- setInitialScrollTarget(state, clearedFooterTarget);
2589
+ setInitialScrollTarget(ctx, clearedFooterTarget);
2546
2590
  }
2547
2591
  function clearFinishedViewportRetargetableInitialScroll(state) {
2548
2592
  clearPreservedInitialScrollTarget(state);
@@ -2689,7 +2733,7 @@ function handleBootstrapInitialScrollDataChange(ctx, options) {
2689
2733
  return;
2690
2734
  }
2691
2735
  if (!areEquivalentBootstrapInitialScrollTargets(initialScroll, updatedInitialScroll) || !!bootstrapInitialScroll || shouldResetDidFinish || didDataChange) {
2692
- setInitialScrollTarget(state, updatedInitialScroll, {
2736
+ setInitialScrollTarget(ctx, updatedInitialScroll, {
2693
2737
  resetDidFinish: shouldResetDidFinish
2694
2738
  });
2695
2739
  rearmBootstrapInitialScroll(ctx, {
@@ -2704,7 +2748,7 @@ function handleBootstrapInitialScrollDataChange(ctx, options) {
2704
2748
  return;
2705
2749
  }
2706
2750
  if (bootstrapInitialScroll || shouldResetDidFinish) {
2707
- setInitialScrollTarget(state, initialScroll, {
2751
+ setInitialScrollTarget(ctx, initialScroll, {
2708
2752
  resetDidFinish: shouldResetDidFinish
2709
2753
  });
2710
2754
  rearmBootstrapInitialScroll(ctx, {
@@ -2750,7 +2794,7 @@ function handleBootstrapInitialScrollFooterLayout(ctx, options) {
2750
2794
  });
2751
2795
  } else {
2752
2796
  const didFinishInitialScroll = !!state.didFinishInitialScroll;
2753
- setInitialScrollTarget(state, updatedInitialScroll, {
2797
+ setInitialScrollTarget(ctx, updatedInitialScroll, {
2754
2798
  resetDidFinish: didFinishInitialScroll
2755
2799
  });
2756
2800
  rearmBootstrapInitialScroll(ctx, {
@@ -3084,7 +3128,7 @@ function initializeInitialScrollOnMount(ctx, options) {
3084
3128
  const resolvedInitialContentOffset = initialContentOffset != null ? initialContentOffset : 0;
3085
3129
  const preserveForFooterLayout = useBootstrapInitialScroll && initialScrollAtEnd && hasFooterComponent;
3086
3130
  if (initialScroll && (initialScroll.contentOffset === void 0 || !!initialScroll.preserveForFooterLayout !== preserveForFooterLayout && ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) !== "offset")) {
3087
- setInitialScrollTarget(state, {
3131
+ setInitialScrollTarget(ctx, {
3088
3132
  ...initialScroll,
3089
3133
  contentOffset: resolvedInitialContentOffset,
3090
3134
  preserveForFooterLayout
@@ -3113,6 +3157,7 @@ function handleInitialScrollDataChange(ctx, options) {
3113
3157
  const {
3114
3158
  dataLength,
3115
3159
  didDataChange,
3160
+ didStartFreshData,
3116
3161
  initialScrollAtEnd,
3117
3162
  latestInitialScroll,
3118
3163
  latestInitialScrollSessionKind,
@@ -3120,17 +3165,17 @@ function handleInitialScrollDataChange(ctx, options) {
3120
3165
  useBootstrapInitialScroll
3121
3166
  } = options;
3122
3167
  const state = ctx.state;
3123
- const previousDataLength = (_b = (_a3 = state.initialScrollSession) == null ? void 0 : _a3.previousDataLength) != null ? _b : 0;
3124
- const isFirstNonEmptyData = !state.hasHadNonEmptyData && dataLength > 0;
3168
+ const previousInitialScrollDataLength = (_b = (_a3 = state.initialScrollSession) == null ? void 0 : _a3.previousDataLength) != null ? _b : 0;
3169
+ const shouldUseLatestInitialScroll = dataLength > 0 && (!state.hasHadNonEmptyData || didStartFreshData);
3125
3170
  if (dataLength > 0) {
3126
3171
  state.hasHadNonEmptyData = true;
3127
3172
  }
3128
- if (isFirstNonEmptyData) {
3173
+ if (shouldUseLatestInitialScroll) {
3129
3174
  if (latestInitialScroll) {
3130
- setInitialScrollTarget(state, latestInitialScroll);
3175
+ setInitialScrollTarget(ctx, latestInitialScroll);
3131
3176
  setInitialScrollSession(state, {
3132
3177
  kind: latestInitialScrollSessionKind,
3133
- previousDataLength
3178
+ previousDataLength: previousInitialScrollDataLength
3134
3179
  });
3135
3180
  } else {
3136
3181
  clearPreservedInitialScrollTarget(state);
@@ -3145,17 +3190,17 @@ function handleInitialScrollDataChange(ctx, options) {
3145
3190
  dataLength,
3146
3191
  didDataChange,
3147
3192
  initialScrollAtEnd,
3148
- previousDataLength,
3193
+ previousDataLength: previousInitialScrollDataLength,
3149
3194
  stylePaddingBottom
3150
3195
  });
3151
3196
  return;
3152
3197
  }
3153
- const shouldReplayFinishedOffsetInitialScroll = previousDataLength === 0 && dataLength > 0 && !!state.initialScroll && ((_c = ctx.state.initialScrollSession) == null ? void 0 : _c.kind) === "offset" && !!state.didFinishInitialScroll;
3154
- if (previousDataLength !== 0 || dataLength === 0 || !state.initialScroll || !state.queuedInitialLayout || state.didFinishInitialScroll && !shouldReplayFinishedOffsetInitialScroll) {
3198
+ const shouldReplayFinishedOffsetInitialScroll = previousInitialScrollDataLength === 0 && dataLength > 0 && !!state.initialScroll && ((_c = ctx.state.initialScrollSession) == null ? void 0 : _c.kind) === "offset" && !!state.didFinishInitialScroll;
3199
+ if (previousInitialScrollDataLength !== 0 || dataLength === 0 || !state.initialScroll || !state.queuedInitialLayout || state.didFinishInitialScroll && !shouldReplayFinishedOffsetInitialScroll) {
3155
3200
  return;
3156
3201
  }
3157
3202
  if (shouldReplayFinishedOffsetInitialScroll) {
3158
- state.didFinishInitialScroll = false;
3203
+ resetInitialRenderState(ctx, { resetInitialScroll: true });
3159
3204
  }
3160
3205
  advanceCurrentInitialScrollSession(ctx);
3161
3206
  }
@@ -4154,7 +4199,7 @@ function calculateItemsInView(ctx, params = {}) {
4154
4199
  const stickyHeaderIndicesSet = state.props.stickyHeaderIndicesSet || /* @__PURE__ */ new Set();
4155
4200
  const alwaysRenderArr = alwaysRenderIndicesArr || [];
4156
4201
  const alwaysRenderSet = alwaysRenderIndicesSet || /* @__PURE__ */ new Set();
4157
- const drawDistance = getEffectiveDrawDistance(ctx);
4202
+ const drawDistance = getEffectiveDrawDistance(ctx, params.drawDistanceMode);
4158
4203
  const { dataChanged, doMVCP, forceFullItemPositions } = params;
4159
4204
  const bootstrapInitialScrollState = ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "bootstrap" ? state.initialScrollSession.bootstrap : void 0;
4160
4205
  const suppressInitialScrollSideEffects = !!bootstrapInitialScrollState;
@@ -7067,7 +7112,7 @@ var LegendList = typedMemo(
7067
7112
  })
7068
7113
  );
7069
7114
  var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
7070
- var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
7115
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
7071
7116
  const noopOnScroll = React3.useCallback((_event) => {
7072
7117
  }, []);
7073
7118
  if (props.recycleItems === void 0) {
@@ -7084,6 +7129,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7084
7129
  contentContainerStyle: contentContainerStyleProp,
7085
7130
  contentInset,
7086
7131
  data: dataProp = [],
7132
+ dataKey,
7087
7133
  dataVersion,
7088
7134
  drawDistance = 250,
7089
7135
  contentInsetEndAdjustment,
@@ -7214,6 +7260,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7214
7260
  (_j = alwaysRender == null ? void 0 : alwaysRender.indices) == null ? void 0 : _j.join(","),
7215
7261
  (_k = alwaysRender == null ? void 0 : alwaysRender.keys) == null ? void 0 : _k.join(","),
7216
7262
  dataProp,
7263
+ dataKey,
7217
7264
  dataVersion,
7218
7265
  keyExtractor
7219
7266
  ]);
@@ -7236,6 +7283,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7236
7283
  dataChangeNeedsScrollUpdate: false,
7237
7284
  didColumnsChange: false,
7238
7285
  didDataChange: false,
7286
+ didLoad: false,
7239
7287
  enableScrollForNextCalculateItemsInView: true,
7240
7288
  endBuffered: -1,
7241
7289
  endNoBuffer: -1,
@@ -7265,6 +7313,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7265
7313
  positions: [],
7266
7314
  props: {},
7267
7315
  queuedCalculateItemsInView: 0,
7316
+ queuedFullDrawDistancePrewarm: void 0,
7268
7317
  refScroller: { current: null },
7269
7318
  scroll: 0,
7270
7319
  scrollAdjustHandler: new ScrollAdjustHandler(ctx),
@@ -7307,10 +7356,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7307
7356
  const didScrollAxisGapChange = !isFirstLocal && ctx.scrollAxisGap !== nextScrollAxisGap;
7308
7357
  ctx.scrollAxisGap = nextScrollAxisGap;
7309
7358
  state.didColumnsChange = numColumnsProp !== previousNumColumnsProp || didScrollAxisGapChange;
7359
+ const previousDataLength = (_n = (_m = state.props.data) == null ? void 0 : _m.length) != null ? _n : 0;
7310
7360
  const didDataReferenceChangeLocal = state.props.data !== dataProp;
7361
+ const didDataKeyChangeLocal = state.props.dataKey !== dataKey;
7311
7362
  const didDataVersionChangeLocal = state.props.dataVersion !== dataVersion;
7312
- const didDataChangeLocal = didDataVersionChangeLocal || didDataReferenceChangeLocal && checkStructuralDataChange(state, dataProp, state.props.data);
7313
- if (didDataChangeLocal && !initialScrollAtEnd && state.didFinishInitialScroll && ((_m = state.initialScroll) == null ? void 0 : _m.viewPosition) === 1 && state.props.data.length > 0) {
7363
+ const didDataChangeLocal = didDataKeyChangeLocal || didDataVersionChangeLocal || didDataReferenceChangeLocal && checkStructuralDataChange(state, dataProp, state.props.data);
7364
+ const shouldResetFreshDataLayout = !isFirstLocal && didDataChangeLocal && state.hasHadNonEmptyData && (didDataKeyChangeLocal || previousDataLength === 0) && dataProp.length > 0;
7365
+ if (didDataChangeLocal && !initialScrollAtEnd && state.didFinishInitialScroll && ((_o = state.initialScroll) == null ? void 0 : _o.viewPosition) === 1 && state.props.data.length > 0) {
7314
7366
  clearPreservedInitialScrollTarget(state);
7315
7367
  }
7316
7368
  if (didDataChangeLocal) {
@@ -7322,7 +7374,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7322
7374
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
7323
7375
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
7324
7376
  const anchoredEndSpaceResolved = anchoredEndSpace ? { ...anchoredEndSpace, includeInEndInset: true } : anchoredEndSpace;
7325
- const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_n = state.props.anchoredEndSpace) == null ? void 0 : _n.anchorIndex) !== (anchoredEndSpaceResolved == null ? void 0 : anchoredEndSpaceResolved.anchorIndex);
7377
+ const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_p = state.props.anchoredEndSpace) == null ? void 0 : _p.anchorIndex) !== (anchoredEndSpaceResolved == null ? void 0 : anchoredEndSpaceResolved.anchorIndex);
7326
7378
  state.props = {
7327
7379
  adaptiveRender: experimental_adaptiveRender,
7328
7380
  alignItemsAtEnd,
@@ -7336,6 +7388,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7336
7388
  contentInset,
7337
7389
  contentInsetEndAdjustment: contentInsetEndAdjustmentResolved,
7338
7390
  data: dataProp,
7391
+ dataKey,
7339
7392
  dataVersion,
7340
7393
  drawDistance,
7341
7394
  estimatedItemSize,
@@ -7376,13 +7429,19 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7376
7429
  if (!isFirstLocal && previousAdaptiveRender && !experimental_adaptiveRender) {
7377
7430
  resetAdaptiveRender(ctx);
7378
7431
  }
7432
+ if (shouldResetFreshDataLayout) {
7433
+ resetInitialRenderState(ctx, {
7434
+ resetInitialScroll: !!initialScrollProp,
7435
+ resetLayout: true
7436
+ });
7437
+ }
7379
7438
  const memoizedLastItemKeys = React3.useMemo(() => {
7380
7439
  if (!dataProp.length) return [];
7381
7440
  return Array.from(
7382
7441
  { length: Math.min(numColumnsProp, dataProp.length) },
7383
7442
  (_, i) => getId(state, dataProp.length - 1 - i)
7384
7443
  );
7385
- }, [dataProp, dataVersion, numColumnsProp]);
7444
+ }, [dataProp, dataKey, dataVersion, numColumnsProp]);
7386
7445
  const initializeStateVars = (shouldAdjustPadding) => {
7387
7446
  set$(ctx, "lastItemKeys", memoizedLastItemKeys);
7388
7447
  set$(ctx, "numColumns", numColumnsProp);
@@ -7437,13 +7496,22 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7437
7496
  handleInitialScrollDataChange(ctx, {
7438
7497
  dataLength: dataProp.length,
7439
7498
  didDataChange: didDataChangeLocal,
7499
+ didStartFreshData: shouldResetFreshDataLayout,
7440
7500
  initialScrollAtEnd,
7441
7501
  latestInitialScroll: initialScrollProp,
7442
7502
  latestInitialScrollSessionKind: initialScrollUsesOffsetOnly ? "offset" : "bootstrap",
7443
7503
  stylePaddingBottom: stylePaddingBottomState,
7444
7504
  useBootstrapInitialScroll: usesBootstrapInitialScroll
7445
7505
  });
7446
- }, [dataProp.length, didDataChangeLocal, initialScrollAtEnd, stylePaddingBottomState, usesBootstrapInitialScroll]);
7506
+ }, [
7507
+ dataProp.length,
7508
+ dataKey,
7509
+ didDataChangeLocal,
7510
+ shouldResetFreshDataLayout,
7511
+ initialScrollAtEnd,
7512
+ stylePaddingBottomState,
7513
+ usesBootstrapInitialScroll
7514
+ ]);
7447
7515
  React3.useLayoutEffect(() => {
7448
7516
  var _a4;
7449
7517
  if (didAnchoredEndSpaceAnchorIndexChange) {
@@ -7511,6 +7579,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7511
7579
  React3.useLayoutEffect(
7512
7580
  () => initializeStateVars(true),
7513
7581
  [
7582
+ dataKey,
7514
7583
  dataVersion,
7515
7584
  memoizedLastItemKeys.join(","),
7516
7585
  numColumnsProp,
@@ -7537,7 +7606,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7537
7606
  state.didColumnsChange = false;
7538
7607
  state.didDataChange = false;
7539
7608
  state.isFirst = false;
7540
- }, [dataProp, dataVersion, numColumnsProp, nextScrollAxisGap]);
7609
+ }, [dataProp, dataKey, dataVersion, numColumnsProp, nextScrollAxisGap]);
7541
7610
  React3.useLayoutEffect(() => {
7542
7611
  var _a4;
7543
7612
  set$(ctx, "extraData", extraData);
@@ -7587,6 +7656,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7587
7656
  React3.useImperativeHandle(forwardedRef, () => createImperativeHandle(ctx, scheduleImperativeScrollCommit), []);
7588
7657
  React3.useEffect(() => {
7589
7658
  return () => {
7659
+ if (state.queuedFullDrawDistancePrewarm !== void 0) {
7660
+ cancelAnimationFrame(state.queuedFullDrawDistancePrewarm);
7661
+ state.queuedFullDrawDistancePrewarm = void 0;
7662
+ }
7590
7663
  for (const timeout of state.timeouts) {
7591
7664
  clearTimeout(timeout);
7592
7665
  }
@@ -7639,7 +7712,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7639
7712
  onScroll: onScrollHandler,
7640
7713
  recycleItems,
7641
7714
  refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React3__namespace.cloneElement(refreshControlElement, {
7642
- progressViewOffset: ((_o = refreshControlElement.props.progressViewOffset) != null ? _o : 0) + stylePaddingTopState
7715
+ progressViewOffset: ((_q = refreshControlElement.props.progressViewOffset) != null ? _q : 0) + stylePaddingTopState
7643
7716
  }) : refreshControlElement : onRefresh && /* @__PURE__ */ React3__namespace.createElement(
7644
7717
  RefreshControl,
7645
7718
  {
@@ -7650,7 +7723,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7650
7723
  ),
7651
7724
  refScrollView: combinedRef,
7652
7725
  renderScrollComponent,
7653
- scrollAdjustHandler: (_p = refState.current) == null ? void 0 : _p.scrollAdjustHandler,
7726
+ scrollAdjustHandler: (_r = refState.current) == null ? void 0 : _r.scrollAdjustHandler,
7654
7727
  scrollEventThrottle: 0,
7655
7728
  snapToIndices,
7656
7729
  stickyHeaderIndices,