@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.
package/react-native.mjs CHANGED
@@ -1095,32 +1095,34 @@ function scheduleAdaptiveRenderExit(ctx, exitDelay) {
1095
1095
  const state = ctx.state;
1096
1096
  clearAdaptiveRenderExitTimeout(ctx);
1097
1097
  if (exitDelay <= 0) {
1098
- setAdaptiveRender(ctx, "normal");
1098
+ setAdaptiveRender(ctx, "normal", "scroll");
1099
1099
  } else {
1100
1100
  const timeout = setTimeout(() => {
1101
1101
  state.timeouts.delete(timeout);
1102
1102
  state.timeoutAdaptiveRender = void 0;
1103
- setAdaptiveRender(ctx, "normal");
1103
+ setAdaptiveRender(ctx, "normal", "scroll");
1104
1104
  }, exitDelay);
1105
1105
  state.timeoutAdaptiveRender = timeout;
1106
1106
  state.timeouts.add(timeout);
1107
1107
  }
1108
1108
  }
1109
- function setAdaptiveRender(ctx, mode) {
1109
+ function setAdaptiveRender(ctx, mode, reason) {
1110
1110
  var _a3, _b;
1111
1111
  const previousMode = peek$(ctx, "adaptiveRender");
1112
1112
  if (previousMode !== mode) {
1113
1113
  set$(ctx, "adaptiveRender", mode);
1114
- (_b = (_a3 = ctx.state.props.adaptiveRender) == null ? void 0 : _a3.onChange) == null ? void 0 : _b.call(_a3, mode);
1114
+ (_b = (_a3 = ctx.state.props.adaptiveRender) == null ? void 0 : _a3.onChange) == null ? void 0 : _b.call(_a3, mode, reason);
1115
1115
  }
1116
1116
  }
1117
1117
  function resetAdaptiveRender(ctx) {
1118
+ var _a3, _b;
1118
1119
  clearAdaptiveRenderExitTimeout(ctx);
1119
- if (peek$(ctx, "adaptiveRender") !== "normal") {
1120
- setAdaptiveRender(ctx, "normal");
1120
+ const mode = (_b = (_a3 = ctx.state.props.adaptiveRender) == null ? void 0 : _a3.initialMode) != null ? _b : "normal";
1121
+ if (peek$(ctx, "adaptiveRender") !== mode) {
1122
+ setAdaptiveRender(ctx, mode, "initial");
1121
1123
  }
1122
1124
  }
1123
- function updateAdaptiveRender(ctx, scrollVelocity) {
1125
+ function updateAdaptiveRender(ctx, scrollVelocity, options) {
1124
1126
  var _a3, _b, _c;
1125
1127
  const state = ctx.state;
1126
1128
  const adaptiveRender = state.props.adaptiveRender;
@@ -1132,11 +1134,11 @@ function updateAdaptiveRender(ctx, scrollVelocity) {
1132
1134
  const exitVelocity = (_b = adaptiveRender.exitVelocity) != null ? _b : isWeb ? DEFAULT_WEB_ADAPTIVE_RENDER_EXIT_VELOCITY : DEFAULT_ADAPTIVE_RENDER_EXIT_VELOCITY;
1133
1135
  const exitDelay = (_c = adaptiveRender.exitDelay) != null ? _c : isWeb ? DEFAULT_WEB_ADAPTIVE_RENDER_EXIT_DELAY : DEFAULT_ADAPTIVE_RENDER_EXIT_DELAY;
1134
1136
  const threshold = currentMode === "light" ? exitVelocity : enterVelocity;
1135
- const nextMode = Math.abs(scrollVelocity) > threshold ? "light" : "normal";
1137
+ const nextMode = (options == null ? void 0 : options.forceLight) || Math.abs(scrollVelocity) > threshold ? "light" : "normal";
1136
1138
  const previousMode = state.timeoutAdaptiveRender !== void 0 ? "normal" : currentMode;
1137
1139
  if (nextMode !== previousMode) {
1138
1140
  if (nextMode === "light") {
1139
- setAdaptiveRender(ctx, "light");
1141
+ setAdaptiveRender(ctx, "light", "scroll");
1140
1142
  scheduleAdaptiveRenderExit(ctx, exitDelay);
1141
1143
  } else if (currentMode === "light") {
1142
1144
  scheduleAdaptiveRenderExit(ctx, exitDelay);
@@ -1149,16 +1151,43 @@ function updateAdaptiveRender(ctx, scrollVelocity) {
1149
1151
  }
1150
1152
 
1151
1153
  // src/utils/getEffectiveDrawDistance.ts
1152
- var INITIAL_DRAW_DISTANCE = 100;
1153
- function getEffectiveDrawDistance(ctx) {
1154
+ var INITIAL_DRAW_DISTANCE = 50;
1155
+ function getEffectiveDrawDistance(ctx, mode) {
1154
1156
  var _a3;
1155
1157
  const drawDistance = ctx.state.props.drawDistance;
1156
1158
  const initialScroll = ctx.state.initialScroll;
1157
1159
  const needsFullInitialDrawDistance = initialScroll !== void 0 && ((_a3 = initialScroll.viewPosition) != null ? _a3 : 0) > 0;
1158
- return peek$(ctx, "readyToRender") || needsFullInitialDrawDistance ? drawDistance : Math.min(drawDistance, INITIAL_DRAW_DISTANCE);
1160
+ const shouldCapDrawDistance = mode === "visible-first" || mode !== "full" && !peek$(ctx, "readyToRender") && !needsFullInitialDrawDistance;
1161
+ return shouldCapDrawDistance ? Math.min(drawDistance, INITIAL_DRAW_DISTANCE) : drawDistance;
1162
+ }
1163
+ function scheduleFullDrawDistancePrewarm(ctx) {
1164
+ const { state } = ctx;
1165
+ if (state.props.drawDistance <= INITIAL_DRAW_DISTANCE || state.queuedFullDrawDistancePrewarm !== void 0) {
1166
+ return;
1167
+ }
1168
+ state.queuedFullDrawDistancePrewarm = requestAnimationFrame(() => {
1169
+ var _a3;
1170
+ state.queuedFullDrawDistancePrewarm = void 0;
1171
+ (_a3 = state.triggerCalculateItemsInView) == null ? void 0 : _a3.call(state);
1172
+ });
1159
1173
  }
1160
1174
 
1161
1175
  // src/utils/setInitialRenderState.ts
1176
+ function resetInitialRenderState(ctx, {
1177
+ resetLayout,
1178
+ resetInitialScroll
1179
+ }) {
1180
+ const { state } = ctx;
1181
+ if (resetLayout) {
1182
+ state.didContainersLayout = false;
1183
+ state.queuedInitialLayout = false;
1184
+ }
1185
+ if (resetInitialScroll) {
1186
+ state.didFinishInitialScroll = false;
1187
+ }
1188
+ set$(ctx, "readyToRender", false);
1189
+ resetAdaptiveRender(ctx);
1190
+ }
1162
1191
  function setInitialRenderState(ctx, {
1163
1192
  didLayout,
1164
1193
  didInitialScroll
@@ -1177,15 +1206,15 @@ function setInitialRenderState(ctx, {
1177
1206
  const isReadyToRender = Boolean(state.didContainersLayout && state.didFinishInitialScroll);
1178
1207
  if (isReadyToRender && !peek$(ctx, "readyToRender")) {
1179
1208
  set$(ctx, "readyToRender", true);
1180
- setAdaptiveRender(ctx, "normal");
1209
+ setAdaptiveRender(ctx, "normal", "ready");
1181
1210
  if (state.props.drawDistance > INITIAL_DRAW_DISTANCE) {
1182
- requestAnimationFrame(() => {
1183
- var _a3;
1184
- (_a3 = state.triggerCalculateItemsInView) == null ? void 0 : _a3.call(state);
1185
- });
1211
+ scheduleFullDrawDistancePrewarm(ctx);
1186
1212
  }
1187
- if (onLoad) {
1188
- onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
1213
+ if (!state.didLoad) {
1214
+ state.didLoad = true;
1215
+ if (onLoad) {
1216
+ onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
1217
+ }
1189
1218
  }
1190
1219
  }
1191
1220
  }
@@ -1714,8 +1743,8 @@ function doMaintainScrollAtEnd(ctx) {
1714
1743
  state.pendingMaintainScrollAtEnd = shouldMaintainScrollAtEnd;
1715
1744
  return false;
1716
1745
  }
1717
- state.pendingMaintainScrollAtEnd = false;
1718
1746
  if (shouldMaintainScrollAtEnd) {
1747
+ state.pendingMaintainScrollAtEnd = false;
1719
1748
  const contentSize = getContentSize(ctx);
1720
1749
  if (contentSize < state.scrollLength) {
1721
1750
  state.scroll = 0;
@@ -1746,6 +1775,9 @@ function doMaintainScrollAtEnd(ctx) {
1746
1775
  () => {
1747
1776
  if (state.maintainingScrollAtEnd === activeState) {
1748
1777
  state.maintainingScrollAtEnd = void 0;
1778
+ if (state.pendingMaintainScrollAtEnd) {
1779
+ doMaintainScrollAtEnd(ctx);
1780
+ }
1749
1781
  }
1750
1782
  },
1751
1783
  maintainScrollAtEnd.animated ? 500 : 0
@@ -1754,9 +1786,12 @@ function doMaintainScrollAtEnd(ctx) {
1754
1786
  state.maintainingScrollAtEnd = void 0;
1755
1787
  }
1756
1788
  });
1789
+ } else {
1790
+ state.pendingMaintainScrollAtEnd = true;
1757
1791
  }
1758
1792
  return true;
1759
1793
  }
1794
+ state.pendingMaintainScrollAtEnd = false;
1760
1795
  return false;
1761
1796
  }
1762
1797
 
@@ -2180,8 +2215,6 @@ function updateScroll(ctx, newScroll, forceUpdate, options) {
2180
2215
  if (scrollHistory.length > 5) {
2181
2216
  scrollHistory.shift();
2182
2217
  }
2183
- const scrollVelocity = getScrollVelocity(state);
2184
- updateAdaptiveRender(ctx, scrollVelocity);
2185
2218
  if (ignoreScrollFromMVCP && !scrollingTo) {
2186
2219
  const { lt, gt } = ignoreScrollFromMVCP;
2187
2220
  if (lt && newScroll < lt || gt && newScroll > gt) {
@@ -2196,6 +2229,9 @@ function updateScroll(ctx, newScroll, forceUpdate, options) {
2196
2229
  const scrollDelta = Math.abs(newScroll - prevScroll);
2197
2230
  const didResolvePendingNativeMVCPAdjust = resolvePendingNativeMVCPAdjust(ctx, newScroll);
2198
2231
  const scrollLength = state.scrollLength;
2232
+ const isLargeUserScrollJump = scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength && !state.pendingNativeMVCPAdjust;
2233
+ const scrollVelocity = getScrollVelocity(state);
2234
+ updateAdaptiveRender(ctx, scrollVelocity, { forceLight: isLargeUserScrollJump });
2199
2235
  const lastCalculated = state.scrollLastCalculate;
2200
2236
  const useAggressiveItemRecalculation = isInMVCPActiveMode(state);
2201
2237
  const shouldUpdate = useAggressiveItemRecalculation || didResolvePendingNativeMVCPAdjust || forceUpdate || lastCalculated === void 0 || Math.abs(state.scroll - lastCalculated) > 2;
@@ -2205,10 +2241,17 @@ function updateScroll(ctx, newScroll, forceUpdate, options) {
2205
2241
  state.lastScrollDelta = scrollDelta;
2206
2242
  const runCalculateItems = () => {
2207
2243
  var _a4;
2208
- (_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state, { doMVCP: scrollingTo !== void 0, scrollVelocity });
2244
+ const calculateItemsParams = {
2245
+ doMVCP: scrollingTo !== void 0,
2246
+ scrollVelocity
2247
+ };
2248
+ if (isLargeUserScrollJump) {
2249
+ calculateItemsParams.drawDistanceMode = "visible-first";
2250
+ }
2251
+ (_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state, calculateItemsParams);
2209
2252
  checkThresholds(ctx);
2210
2253
  };
2211
- if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength && !state.pendingNativeMVCPAdjust) {
2254
+ if (isLargeUserScrollJump) {
2212
2255
  state.mvcpAnchorLock = void 0;
2213
2256
  state.pendingNativeMVCPAdjust = void 0;
2214
2257
  state.userScrollAnchorReset = { keys: /* @__PURE__ */ new Set() };
@@ -2217,6 +2260,7 @@ function updateScroll(ctx, newScroll, forceUpdate, options) {
2217
2260
  state.queuedMVCPRecalculate = void 0;
2218
2261
  }
2219
2262
  flushSync(runCalculateItems);
2263
+ scheduleFullDrawDistancePrewarm(ctx);
2220
2264
  } else {
2221
2265
  runCalculateItems();
2222
2266
  }
@@ -2371,16 +2415,17 @@ function dispatchInitialScroll(ctx, params) {
2371
2415
  waitForInitialScrollCompletionFrame: waitForCompletionFrame
2372
2416
  });
2373
2417
  }
2374
- function setInitialScrollTarget(state, target, options) {
2418
+ function setInitialScrollTarget(ctx, target, options) {
2375
2419
  var _a3;
2420
+ const { state } = ctx;
2376
2421
  state.clearPreservedInitialScrollOnNextFinish = void 0;
2377
2422
  if (state.timeoutPreservedInitialScrollClear !== void 0) {
2378
2423
  clearTimeout(state.timeoutPreservedInitialScrollClear);
2379
2424
  state.timeoutPreservedInitialScrollClear = void 0;
2380
2425
  }
2381
2426
  state.initialScroll = target;
2382
- if ((options == null ? void 0 : options.resetDidFinish) && state.didFinishInitialScroll) {
2383
- state.didFinishInitialScroll = false;
2427
+ if (options == null ? void 0 : options.resetDidFinish) {
2428
+ resetInitialRenderState(ctx, { resetInitialScroll: true });
2384
2429
  }
2385
2430
  setInitialScrollSession(state, {
2386
2431
  kind: ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "offset" ? "offset" : "bootstrap"
@@ -2434,7 +2479,7 @@ function advanceMeasuredInitialScroll(ctx, options) {
2434
2479
  return false;
2435
2480
  }
2436
2481
  if (didOffsetChange && ((_b = state.initialScrollSession) == null ? void 0 : _b.kind) !== "offset") {
2437
- setInitialScrollTarget(state, { ...initialScroll, contentOffset: resolvedOffset });
2482
+ setInitialScrollTarget(ctx, { ...initialScroll, contentOffset: resolvedOffset });
2438
2483
  }
2439
2484
  const forceScroll = (_c = options == null ? void 0 : options.forceScroll) != null ? _c : !!queuedInitialLayout || isInitialScrollInProgress && didOffsetChange;
2440
2485
  dispatchInitialScroll(ctx, {
@@ -2707,7 +2752,6 @@ function areEquivalentBootstrapInitialScrollTargets(current, next) {
2707
2752
  }
2708
2753
  function clearPendingInitialScrollFooterLayout(ctx, options) {
2709
2754
  const { dataLength, stylePaddingBottom, target } = options;
2710
- const state = ctx.state;
2711
2755
  if (!shouldPreserveInitialScrollForFooterLayout(target)) {
2712
2756
  return;
2713
2757
  }
@@ -2717,7 +2761,7 @@ function clearPendingInitialScrollFooterLayout(ctx, options) {
2717
2761
  preserveForFooterLayout: void 0,
2718
2762
  stylePaddingBottom
2719
2763
  });
2720
- setInitialScrollTarget(state, clearedFooterTarget);
2764
+ setInitialScrollTarget(ctx, clearedFooterTarget);
2721
2765
  }
2722
2766
  function clearFinishedViewportRetargetableInitialScroll(state) {
2723
2767
  clearPreservedInitialScrollTarget(state);
@@ -2864,7 +2908,7 @@ function handleBootstrapInitialScrollDataChange(ctx, options) {
2864
2908
  return;
2865
2909
  }
2866
2910
  if (!areEquivalentBootstrapInitialScrollTargets(initialScroll, updatedInitialScroll) || !!bootstrapInitialScroll || shouldResetDidFinish || didDataChange) {
2867
- setInitialScrollTarget(state, updatedInitialScroll, {
2911
+ setInitialScrollTarget(ctx, updatedInitialScroll, {
2868
2912
  resetDidFinish: shouldResetDidFinish
2869
2913
  });
2870
2914
  rearmBootstrapInitialScroll(ctx, {
@@ -2879,7 +2923,7 @@ function handleBootstrapInitialScrollDataChange(ctx, options) {
2879
2923
  return;
2880
2924
  }
2881
2925
  if (bootstrapInitialScroll || shouldResetDidFinish) {
2882
- setInitialScrollTarget(state, initialScroll, {
2926
+ setInitialScrollTarget(ctx, initialScroll, {
2883
2927
  resetDidFinish: shouldResetDidFinish
2884
2928
  });
2885
2929
  rearmBootstrapInitialScroll(ctx, {
@@ -2925,7 +2969,7 @@ function handleBootstrapInitialScrollFooterLayout(ctx, options) {
2925
2969
  });
2926
2970
  } else {
2927
2971
  const didFinishInitialScroll = !!state.didFinishInitialScroll;
2928
- setInitialScrollTarget(state, updatedInitialScroll, {
2972
+ setInitialScrollTarget(ctx, updatedInitialScroll, {
2929
2973
  resetDidFinish: didFinishInitialScroll
2930
2974
  });
2931
2975
  rearmBootstrapInitialScroll(ctx, {
@@ -3114,7 +3158,7 @@ function initializeInitialScrollOnMount(ctx, options) {
3114
3158
  const resolvedInitialContentOffset = initialContentOffset != null ? initialContentOffset : 0;
3115
3159
  const preserveForFooterLayout = useBootstrapInitialScroll && initialScrollAtEnd && hasFooterComponent;
3116
3160
  if (initialScroll && (initialScroll.contentOffset === void 0 || !!initialScroll.preserveForFooterLayout !== preserveForFooterLayout && ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) !== "offset")) {
3117
- setInitialScrollTarget(state, {
3161
+ setInitialScrollTarget(ctx, {
3118
3162
  ...initialScroll,
3119
3163
  contentOffset: resolvedInitialContentOffset,
3120
3164
  preserveForFooterLayout
@@ -3143,6 +3187,7 @@ function handleInitialScrollDataChange(ctx, options) {
3143
3187
  const {
3144
3188
  dataLength,
3145
3189
  didDataChange,
3190
+ didStartFreshData,
3146
3191
  initialScrollAtEnd,
3147
3192
  latestInitialScroll,
3148
3193
  latestInitialScrollSessionKind,
@@ -3150,17 +3195,17 @@ function handleInitialScrollDataChange(ctx, options) {
3150
3195
  useBootstrapInitialScroll
3151
3196
  } = options;
3152
3197
  const state = ctx.state;
3153
- const previousDataLength = (_b = (_a3 = state.initialScrollSession) == null ? void 0 : _a3.previousDataLength) != null ? _b : 0;
3154
- const isFirstNonEmptyData = !state.hasHadNonEmptyData && dataLength > 0;
3198
+ const previousInitialScrollDataLength = (_b = (_a3 = state.initialScrollSession) == null ? void 0 : _a3.previousDataLength) != null ? _b : 0;
3199
+ const shouldUseLatestInitialScroll = dataLength > 0 && (!state.hasHadNonEmptyData || didStartFreshData);
3155
3200
  if (dataLength > 0) {
3156
3201
  state.hasHadNonEmptyData = true;
3157
3202
  }
3158
- if (isFirstNonEmptyData) {
3203
+ if (shouldUseLatestInitialScroll) {
3159
3204
  if (latestInitialScroll) {
3160
- setInitialScrollTarget(state, latestInitialScroll);
3205
+ setInitialScrollTarget(ctx, latestInitialScroll);
3161
3206
  setInitialScrollSession(state, {
3162
3207
  kind: latestInitialScrollSessionKind,
3163
- previousDataLength
3208
+ previousDataLength: previousInitialScrollDataLength
3164
3209
  });
3165
3210
  } else {
3166
3211
  clearPreservedInitialScrollTarget(state);
@@ -3175,17 +3220,17 @@ function handleInitialScrollDataChange(ctx, options) {
3175
3220
  dataLength,
3176
3221
  didDataChange,
3177
3222
  initialScrollAtEnd,
3178
- previousDataLength,
3223
+ previousDataLength: previousInitialScrollDataLength,
3179
3224
  stylePaddingBottom
3180
3225
  });
3181
3226
  return;
3182
3227
  }
3183
- const shouldReplayFinishedOffsetInitialScroll = previousDataLength === 0 && dataLength > 0 && !!state.initialScroll && ((_c = ctx.state.initialScrollSession) == null ? void 0 : _c.kind) === "offset" && !!state.didFinishInitialScroll;
3184
- if (previousDataLength !== 0 || dataLength === 0 || !state.initialScroll || !state.queuedInitialLayout || state.didFinishInitialScroll && !shouldReplayFinishedOffsetInitialScroll) {
3228
+ const shouldReplayFinishedOffsetInitialScroll = previousInitialScrollDataLength === 0 && dataLength > 0 && !!state.initialScroll && ((_c = ctx.state.initialScrollSession) == null ? void 0 : _c.kind) === "offset" && !!state.didFinishInitialScroll;
3229
+ if (previousInitialScrollDataLength !== 0 || dataLength === 0 || !state.initialScroll || !state.queuedInitialLayout || state.didFinishInitialScroll && !shouldReplayFinishedOffsetInitialScroll) {
3185
3230
  return;
3186
3231
  }
3187
3232
  if (shouldReplayFinishedOffsetInitialScroll) {
3188
- state.didFinishInitialScroll = false;
3233
+ resetInitialRenderState(ctx, { resetInitialScroll: true });
3189
3234
  }
3190
3235
  advanceCurrentInitialScrollSession(ctx);
3191
3236
  }
@@ -4184,7 +4229,7 @@ function calculateItemsInView(ctx, params = {}) {
4184
4229
  const stickyHeaderIndicesSet = state.props.stickyHeaderIndicesSet || /* @__PURE__ */ new Set();
4185
4230
  const alwaysRenderArr = alwaysRenderIndicesArr || [];
4186
4231
  const alwaysRenderSet = alwaysRenderIndicesSet || /* @__PURE__ */ new Set();
4187
- const drawDistance = getEffectiveDrawDistance(ctx);
4232
+ const drawDistance = getEffectiveDrawDistance(ctx, params.drawDistanceMode);
4188
4233
  const { dataChanged, doMVCP, forceFullItemPositions } = params;
4189
4234
  const bootstrapInitialScrollState = ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "bootstrap" ? state.initialScrollSession.bootstrap : void 0;
4190
4235
  const suppressInitialScrollSideEffects = !!bootstrapInitialScrollState;
@@ -6421,7 +6466,7 @@ var LegendList = typedMemo(
6421
6466
  })
6422
6467
  );
6423
6468
  var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
6424
- var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
6469
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
6425
6470
  const noopOnScroll = useCallback((_event) => {
6426
6471
  }, []);
6427
6472
  if (props.recycleItems === void 0) {
@@ -6438,6 +6483,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6438
6483
  contentContainerStyle: contentContainerStyleProp,
6439
6484
  contentInset,
6440
6485
  data: dataProp = [],
6486
+ dataKey,
6441
6487
  dataVersion,
6442
6488
  drawDistance = 250,
6443
6489
  contentInsetEndAdjustment,
@@ -6568,6 +6614,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6568
6614
  (_j = alwaysRender == null ? void 0 : alwaysRender.indices) == null ? void 0 : _j.join(","),
6569
6615
  (_k = alwaysRender == null ? void 0 : alwaysRender.keys) == null ? void 0 : _k.join(","),
6570
6616
  dataProp,
6617
+ dataKey,
6571
6618
  dataVersion,
6572
6619
  keyExtractor
6573
6620
  ]);
@@ -6590,6 +6637,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6590
6637
  dataChangeNeedsScrollUpdate: false,
6591
6638
  didColumnsChange: false,
6592
6639
  didDataChange: false,
6640
+ didLoad: false,
6593
6641
  enableScrollForNextCalculateItemsInView: true,
6594
6642
  endBuffered: -1,
6595
6643
  endNoBuffer: -1,
@@ -6619,6 +6667,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6619
6667
  positions: [],
6620
6668
  props: {},
6621
6669
  queuedCalculateItemsInView: 0,
6670
+ queuedFullDrawDistancePrewarm: void 0,
6622
6671
  refScroller: { current: null },
6623
6672
  scroll: 0,
6624
6673
  scrollAdjustHandler: new ScrollAdjustHandler(ctx),
@@ -6661,10 +6710,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6661
6710
  const didScrollAxisGapChange = !isFirstLocal && ctx.scrollAxisGap !== nextScrollAxisGap;
6662
6711
  ctx.scrollAxisGap = nextScrollAxisGap;
6663
6712
  state.didColumnsChange = numColumnsProp !== previousNumColumnsProp || didScrollAxisGapChange;
6713
+ const previousDataLength = (_n = (_m = state.props.data) == null ? void 0 : _m.length) != null ? _n : 0;
6664
6714
  const didDataReferenceChangeLocal = state.props.data !== dataProp;
6715
+ const didDataKeyChangeLocal = state.props.dataKey !== dataKey;
6665
6716
  const didDataVersionChangeLocal = state.props.dataVersion !== dataVersion;
6666
- const didDataChangeLocal = didDataVersionChangeLocal || didDataReferenceChangeLocal && checkStructuralDataChange(state, dataProp, state.props.data);
6667
- if (didDataChangeLocal && !initialScrollAtEnd && state.didFinishInitialScroll && ((_m = state.initialScroll) == null ? void 0 : _m.viewPosition) === 1 && state.props.data.length > 0) {
6717
+ const didDataChangeLocal = didDataKeyChangeLocal || didDataVersionChangeLocal || didDataReferenceChangeLocal && checkStructuralDataChange(state, dataProp, state.props.data);
6718
+ const shouldResetFreshDataLayout = !isFirstLocal && didDataChangeLocal && state.hasHadNonEmptyData && (didDataKeyChangeLocal || previousDataLength === 0) && dataProp.length > 0;
6719
+ if (didDataChangeLocal && !initialScrollAtEnd && state.didFinishInitialScroll && ((_o = state.initialScroll) == null ? void 0 : _o.viewPosition) === 1 && state.props.data.length > 0) {
6668
6720
  clearPreservedInitialScrollTarget(state);
6669
6721
  }
6670
6722
  if (didDataChangeLocal) {
@@ -6676,7 +6728,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6676
6728
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
6677
6729
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
6678
6730
  const anchoredEndSpaceResolved = Platform.OS === "web" && anchoredEndSpace ? { ...anchoredEndSpace, includeInEndInset: true } : anchoredEndSpace;
6679
- const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_n = state.props.anchoredEndSpace) == null ? void 0 : _n.anchorIndex) !== (anchoredEndSpaceResolved == null ? void 0 : anchoredEndSpaceResolved.anchorIndex);
6731
+ const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_p = state.props.anchoredEndSpace) == null ? void 0 : _p.anchorIndex) !== (anchoredEndSpaceResolved == null ? void 0 : anchoredEndSpaceResolved.anchorIndex);
6680
6732
  state.props = {
6681
6733
  adaptiveRender: experimental_adaptiveRender,
6682
6734
  alignItemsAtEnd,
@@ -6690,6 +6742,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6690
6742
  contentInset,
6691
6743
  contentInsetEndAdjustment: contentInsetEndAdjustmentResolved,
6692
6744
  data: dataProp,
6745
+ dataKey,
6693
6746
  dataVersion,
6694
6747
  drawDistance,
6695
6748
  estimatedItemSize,
@@ -6730,13 +6783,19 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6730
6783
  if (!isFirstLocal && previousAdaptiveRender && !experimental_adaptiveRender) {
6731
6784
  resetAdaptiveRender(ctx);
6732
6785
  }
6786
+ if (shouldResetFreshDataLayout) {
6787
+ resetInitialRenderState(ctx, {
6788
+ resetInitialScroll: !!initialScrollProp,
6789
+ resetLayout: true
6790
+ });
6791
+ }
6733
6792
  const memoizedLastItemKeys = useMemo(() => {
6734
6793
  if (!dataProp.length) return [];
6735
6794
  return Array.from(
6736
6795
  { length: Math.min(numColumnsProp, dataProp.length) },
6737
6796
  (_, i) => getId(state, dataProp.length - 1 - i)
6738
6797
  );
6739
- }, [dataProp, dataVersion, numColumnsProp]);
6798
+ }, [dataProp, dataKey, dataVersion, numColumnsProp]);
6740
6799
  const initializeStateVars = (shouldAdjustPadding) => {
6741
6800
  set$(ctx, "lastItemKeys", memoizedLastItemKeys);
6742
6801
  set$(ctx, "numColumns", numColumnsProp);
@@ -6796,13 +6855,22 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6796
6855
  handleInitialScrollDataChange(ctx, {
6797
6856
  dataLength: dataProp.length,
6798
6857
  didDataChange: didDataChangeLocal,
6858
+ didStartFreshData: shouldResetFreshDataLayout,
6799
6859
  initialScrollAtEnd,
6800
6860
  latestInitialScroll: initialScrollProp,
6801
6861
  latestInitialScrollSessionKind: initialScrollUsesOffsetOnly ? "offset" : "bootstrap",
6802
6862
  stylePaddingBottom: stylePaddingBottomState,
6803
6863
  useBootstrapInitialScroll: usesBootstrapInitialScroll
6804
6864
  });
6805
- }, [dataProp.length, didDataChangeLocal, initialScrollAtEnd, stylePaddingBottomState, usesBootstrapInitialScroll]);
6865
+ }, [
6866
+ dataProp.length,
6867
+ dataKey,
6868
+ didDataChangeLocal,
6869
+ shouldResetFreshDataLayout,
6870
+ initialScrollAtEnd,
6871
+ stylePaddingBottomState,
6872
+ usesBootstrapInitialScroll
6873
+ ]);
6806
6874
  useLayoutEffect(() => {
6807
6875
  var _a4;
6808
6876
  if (didAnchoredEndSpaceAnchorIndexChange) {
@@ -6870,6 +6938,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6870
6938
  useLayoutEffect(
6871
6939
  () => initializeStateVars(true),
6872
6940
  [
6941
+ dataKey,
6873
6942
  dataVersion,
6874
6943
  memoizedLastItemKeys.join(","),
6875
6944
  numColumnsProp,
@@ -6896,7 +6965,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6896
6965
  state.didColumnsChange = false;
6897
6966
  state.didDataChange = false;
6898
6967
  state.isFirst = false;
6899
- }, [dataProp, dataVersion, numColumnsProp, nextScrollAxisGap]);
6968
+ }, [dataProp, dataKey, dataVersion, numColumnsProp, nextScrollAxisGap]);
6900
6969
  useLayoutEffect(() => {
6901
6970
  var _a4;
6902
6971
  set$(ctx, "extraData", extraData);
@@ -6949,6 +7018,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6949
7018
  useImperativeHandle(forwardedRef, () => createImperativeHandle(ctx, scheduleImperativeScrollCommit), []);
6950
7019
  useEffect(() => {
6951
7020
  return () => {
7021
+ if (state.queuedFullDrawDistancePrewarm !== void 0) {
7022
+ cancelAnimationFrame(state.queuedFullDrawDistancePrewarm);
7023
+ state.queuedFullDrawDistancePrewarm = void 0;
7024
+ }
6952
7025
  for (const timeout of state.timeouts) {
6953
7026
  clearTimeout(timeout);
6954
7027
  }
@@ -7001,7 +7074,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7001
7074
  onScroll: onScrollHandler,
7002
7075
  recycleItems,
7003
7076
  refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React2.cloneElement(refreshControlElement, {
7004
- progressViewOffset: ((_o = refreshControlElement.props.progressViewOffset) != null ? _o : 0) + stylePaddingTopState
7077
+ progressViewOffset: ((_q = refreshControlElement.props.progressViewOffset) != null ? _q : 0) + stylePaddingTopState
7005
7078
  }) : refreshControlElement : onRefresh && /* @__PURE__ */ React2.createElement(
7006
7079
  RefreshControl,
7007
7080
  {
@@ -7012,7 +7085,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7012
7085
  ),
7013
7086
  refScrollView: combinedRef,
7014
7087
  renderScrollComponent,
7015
- scrollAdjustHandler: (_p = refState.current) == null ? void 0 : _p.scrollAdjustHandler,
7088
+ scrollAdjustHandler: (_r = refState.current) == null ? void 0 : _r.scrollAdjustHandler,
7016
7089
  scrollEventThrottle: 0,
7017
7090
  snapToIndices,
7018
7091
  stickyHeaderIndices,
@@ -115,6 +115,7 @@ interface NativeSyntheticEvent<T> {
115
115
  type ViewStyle = Record<string, unknown>;
116
116
  type StyleProp<T> = T | T[] | null | undefined | false;
117
117
  type AdaptiveRender = "normal" | "light";
118
+ type AdaptiveRenderChangeReason = "initial" | "ready" | "scroll";
118
119
  interface AdaptiveRenderConfig {
119
120
  /**
120
121
  * Mode to use before the list is ready to render.
@@ -139,7 +140,7 @@ interface AdaptiveRenderConfig {
139
140
  /**
140
141
  * Called when the list-level adaptive render changes.
141
142
  */
142
- onChange?: (mode: AdaptiveRender) => void;
143
+ onChange?: (mode: AdaptiveRender, reason: AdaptiveRenderChangeReason) => void;
143
144
  }
144
145
  type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
145
146
  interface DataModeProps<ItemT, TItemType extends string | undefined> {
@@ -181,6 +182,11 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
181
182
  * Style applied to each column's wrapper view.
182
183
  */
183
184
  columnWrapperStyle?: ColumnWrapperStyle;
185
+ /**
186
+ * Identity token for the dataset represented by `data`.
187
+ * Change this when replacing the current dataset with a different logical dataset.
188
+ */
189
+ dataKey?: Key;
184
190
  /**
185
191
  * Version token that forces the list to treat data as updated even when the array reference is stable.
186
192
  * Increment or change this when mutating the data array in place.
@@ -826,4 +832,4 @@ declare function useSyncLayout(): () => void;
826
832
 
827
833
  declare const LegendList: LegendListComponent;
828
834
 
829
- export { type AdaptiveRender, type AdaptiveRenderConfig, type AlwaysRenderConfig, type AnchoredEndSpaceConfig, type ColumnWrapperStyle, type Insets, type LayoutRectangle, LegendList, type LegendListAverageItemSize, type LegendListComponent, type LegendListMetrics, type LegendListProps, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type LegendListState, type MaintainScrollAtEndOnOptions, type MaintainScrollAtEndOptions, type MaintainVisibleContentPositionConfig, type NativeScrollEvent, type NativeSyntheticEvent, type OnViewableItemsChanged, type OnViewableItemsChangedInfo, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type StickyHeaderConfig, type StyleProp, type ViewAmountToken, type ViewStyle, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, useAdaptiveRender, useAdaptiveRenderChange, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
835
+ export { type AdaptiveRender, type AdaptiveRenderChangeReason, type AdaptiveRenderConfig, type AlwaysRenderConfig, type AnchoredEndSpaceConfig, type ColumnWrapperStyle, type Insets, type LayoutRectangle, LegendList, type LegendListAverageItemSize, type LegendListComponent, type LegendListMetrics, type LegendListProps, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type LegendListState, type MaintainScrollAtEndOnOptions, type MaintainScrollAtEndOptions, type MaintainVisibleContentPositionConfig, type NativeScrollEvent, type NativeSyntheticEvent, type OnViewableItemsChanged, type OnViewableItemsChangedInfo, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type StickyHeaderConfig, type StyleProp, type ViewAmountToken, type ViewStyle, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, useAdaptiveRender, useAdaptiveRenderChange, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };