@legendapp/list 1.0.0-beta.11 → 1.0.0-beta.12

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
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var React5 = require('react');
3
+ var React6 = require('react');
4
4
  var reactNative = require('react-native');
5
5
 
6
6
  function _interopNamespace(e) {
@@ -21,12 +21,12 @@ function _interopNamespace(e) {
21
21
  return Object.freeze(n);
22
22
  }
23
23
 
24
- var React5__namespace = /*#__PURE__*/_interopNamespace(React5);
24
+ var React6__namespace = /*#__PURE__*/_interopNamespace(React6);
25
25
 
26
26
  // src/LegendList.tsx
27
- var ContextState = React5__namespace.createContext(null);
27
+ var ContextState = React6__namespace.createContext(null);
28
28
  function StateProvider({ children }) {
29
- const [value] = React5__namespace.useState(() => ({
29
+ const [value] = React6__namespace.useState(() => ({
30
30
  listeners: /* @__PURE__ */ new Map(),
31
31
  values: /* @__PURE__ */ new Map(),
32
32
  mapViewabilityCallbacks: /* @__PURE__ */ new Map(),
@@ -34,10 +34,10 @@ function StateProvider({ children }) {
34
34
  mapViewabilityAmountCallbacks: /* @__PURE__ */ new Map(),
35
35
  mapViewabilityAmountValues: /* @__PURE__ */ new Map()
36
36
  }));
37
- return /* @__PURE__ */ React5__namespace.createElement(ContextState.Provider, { value }, children);
37
+ return /* @__PURE__ */ React6__namespace.createElement(ContextState.Provider, { value }, children);
38
38
  }
39
39
  function useStateContext() {
40
- return React5__namespace.useContext(ContextState);
40
+ return React6__namespace.useContext(ContextState);
41
41
  }
42
42
  function createSelectorFunctions(ctx, signalName) {
43
43
  return {
@@ -46,9 +46,9 @@ function createSelectorFunctions(ctx, signalName) {
46
46
  };
47
47
  }
48
48
  function use$(signalName) {
49
- const ctx = React5__namespace.useContext(ContextState);
50
- const { subscribe, get } = React5__namespace.useMemo(() => createSelectorFunctions(ctx, signalName), []);
51
- const value = React5.useSyncExternalStore(subscribe, get);
49
+ const ctx = React6__namespace.useContext(ContextState);
50
+ const { subscribe, get } = React6__namespace.useMemo(() => createSelectorFunctions(ctx, signalName), []);
51
+ const value = React6.useSyncExternalStore(subscribe, get);
52
52
  return value;
53
53
  }
54
54
  function listen$(ctx, signalName, cb) {
@@ -79,7 +79,7 @@ function set$(ctx, signalName, value) {
79
79
  }
80
80
  var symbolFirst = Symbol();
81
81
  function useInit(cb) {
82
- const refValue = React5.useRef(symbolFirst);
82
+ const refValue = React6.useRef(symbolFirst);
83
83
  if (refValue.current === symbolFirst) {
84
84
  refValue.current = cb();
85
85
  }
@@ -87,10 +87,10 @@ function useInit(cb) {
87
87
  }
88
88
 
89
89
  // src/ContextContainer.ts
90
- var ContextContainer = React5.createContext(null);
90
+ var ContextContainer = React6.createContext(null);
91
91
  function useViewability(configId, callback) {
92
92
  const ctx = useStateContext();
93
- const { containerId } = React5.useContext(ContextContainer);
93
+ const { containerId } = React6.useContext(ContextContainer);
94
94
  const key = containerId + configId;
95
95
  useInit(() => {
96
96
  const value = ctx.mapViewabilityValues.get(key);
@@ -99,7 +99,7 @@ function useViewability(configId, callback) {
99
99
  }
100
100
  });
101
101
  ctx.mapViewabilityCallbacks.set(key, callback);
102
- React5.useEffect(
102
+ React6.useEffect(
103
103
  () => () => {
104
104
  ctx.mapViewabilityCallbacks.delete(key);
105
105
  },
@@ -108,7 +108,7 @@ function useViewability(configId, callback) {
108
108
  }
109
109
  function useViewabilityAmount(callback) {
110
110
  const ctx = useStateContext();
111
- const { containerId } = React5.useContext(ContextContainer);
111
+ const { containerId } = React6.useContext(ContextContainer);
112
112
  useInit(() => {
113
113
  const value = ctx.mapViewabilityAmountValues.get(containerId);
114
114
  if (value) {
@@ -116,7 +116,7 @@ function useViewabilityAmount(callback) {
116
116
  }
117
117
  });
118
118
  ctx.mapViewabilityAmountCallbacks.set(containerId, callback);
119
- React5.useEffect(
119
+ React6.useEffect(
120
120
  () => () => {
121
121
  ctx.mapViewabilityAmountCallbacks.delete(containerId);
122
122
  },
@@ -124,12 +124,12 @@ function useViewabilityAmount(callback) {
124
124
  );
125
125
  }
126
126
  function useRecyclingEffect(effect) {
127
- const { index, value } = React5.useContext(ContextContainer);
128
- const prevValues = React5.useRef({
127
+ const { index, value } = React6.useContext(ContextContainer);
128
+ const prevValues = React6.useRef({
129
129
  prevIndex: void 0,
130
130
  prevItem: void 0
131
131
  });
132
- React5.useEffect(() => {
132
+ React6.useEffect(() => {
133
133
  let ret = void 0;
134
134
  if (prevValues.current.prevIndex !== void 0 && prevValues.current.prevItem !== void 0) {
135
135
  ret = effect({
@@ -147,8 +147,8 @@ function useRecyclingEffect(effect) {
147
147
  }, [index, value]);
148
148
  }
149
149
  function useRecyclingState(valueOrFun) {
150
- const { index, value } = React5.useContext(ContextContainer);
151
- const stateInfo = React5.useState(
150
+ const { index, value } = React6.useContext(ContextContainer);
151
+ const stateInfo = React6.useState(
152
152
  () => typeof valueOrFun === "function" ? valueOrFun({
153
153
  index,
154
154
  item: value,
@@ -162,8 +162,37 @@ function useRecyclingState(valueOrFun) {
162
162
  });
163
163
  return stateInfo;
164
164
  }
165
- var LeanView = React5__namespace.forwardRef((props, ref) => {
166
- return React5__namespace.createElement("RCTView", { ...props, ref });
165
+ var DebugView = React6.memo(function DebugView2({ state }) {
166
+ const paddingTop = use$("paddingTop");
167
+ const [, forceUpdate] = React6.useReducer((x) => x + 1, 0);
168
+ useInterval(() => {
169
+ forceUpdate();
170
+ }, 100);
171
+ return /* @__PURE__ */ React.createElement(
172
+ reactNative.View,
173
+ {
174
+ style: {
175
+ position: "absolute",
176
+ top: 0,
177
+ right: 0,
178
+ paddingLeft: 4,
179
+ paddingBottom: 4,
180
+ // height: 100,
181
+ backgroundColor: "#FFFFFFCC"
182
+ }
183
+ },
184
+ /* @__PURE__ */ React.createElement(reactNative.Text, null, "PaddingTop: ", paddingTop),
185
+ /* @__PURE__ */ React.createElement(reactNative.Text, null, "At end: ", String(state.isAtBottom))
186
+ );
187
+ });
188
+ function useInterval(callback, delay) {
189
+ React6.useEffect(() => {
190
+ const interval = setInterval(callback, delay);
191
+ return () => clearInterval(interval);
192
+ }, [delay]);
193
+ }
194
+ var LeanView = React6__namespace.forwardRef((props, ref) => {
195
+ return React6__namespace.createElement("RCTView", { ...props, ref });
167
196
  });
168
197
  LeanView.displayName = "RCTView";
169
198
 
@@ -174,6 +203,8 @@ var ANCHORED_POSITION_OUT_OF_VIEW = {
174
203
  relativeCoordinate: POSITION_OUT_OF_VIEW,
175
204
  top: POSITION_OUT_OF_VIEW
176
205
  };
206
+ var ENABLE_DEVMODE = __DEV__ && false;
207
+ var ENABLE_DEBUG_VIEW = __DEV__ && false;
177
208
 
178
209
  // src/Container.tsx
179
210
  var isNewArchitecture = global.nativeFabricUIManager != null;
@@ -185,7 +216,6 @@ var Container = ({
185
216
  updateItemSize,
186
217
  ItemSeparatorComponent
187
218
  }) => {
188
- useStateContext();
189
219
  const maintainVisibleContentPosition = use$("maintainVisibleContentPosition");
190
220
  const position = use$(`containerPosition${id}`) || ANCHORED_POSITION_OUT_OF_VIEW;
191
221
  const column = use$(`containerColumn${id}`) || 0;
@@ -210,7 +240,7 @@ var Container = ({
210
240
  const itemKey = use$(`containerItemKey${id}`);
211
241
  const data = use$(`containerItemData${id}`);
212
242
  const extraData = use$("extraData");
213
- const renderedItemInfo = React5.useMemo(
243
+ const renderedItemInfo = React6.useMemo(
214
244
  () => itemKey !== void 0 && getRenderedItem(itemKey),
215
245
  [itemKey, data, extraData]
216
246
  );
@@ -225,9 +255,9 @@ var Container = ({
225
255
  updateItemSize(id, itemKey, size);
226
256
  }
227
257
  };
228
- const ref = React5.useRef(null);
258
+ const ref = React6.useRef(null);
229
259
  if (isNewArchitecture) {
230
- React5.useLayoutEffect(() => {
260
+ React6.useLayoutEffect(() => {
231
261
  var _a, _b;
232
262
  if (itemKey !== void 0) {
233
263
  const measured = (_b = (_a = ref.current) == null ? void 0 : _a.unstable_getBoundingClientRect) == null ? void 0 : _b.call(_a);
@@ -240,25 +270,29 @@ var Container = ({
240
270
  }
241
271
  }, [itemKey]);
242
272
  }
243
- const contextValue = React5.useMemo(
273
+ const contextValue = React6.useMemo(
244
274
  () => ({ containerId: id, itemKey, index, value: data }),
245
275
  [id, itemKey, index, data]
246
276
  );
247
- const contentFragment = /* @__PURE__ */ React5__namespace.default.createElement(React5__namespace.default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React5__namespace.default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItem && ItemSeparatorComponent && itemKey !== lastItemKey && ItemSeparatorComponent));
277
+ const contentFragment = /* @__PURE__ */ React6__namespace.default.createElement(React6__namespace.default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React6__namespace.default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItem && ItemSeparatorComponent && itemKey !== lastItemKey && ItemSeparatorComponent));
248
278
  if (maintainVisibleContentPosition) {
249
279
  const anchorStyle = position.type === "top" ? { position: "absolute", top: 0, left: 0, right: 0 } : { position: "absolute", bottom: 0, left: 0, right: 0 };
250
- return /* @__PURE__ */ React5__namespace.default.createElement(LeanView, { style }, /* @__PURE__ */ React5__namespace.default.createElement(LeanView, { style: anchorStyle, onLayout, ref }, contentFragment));
280
+ if (ENABLE_DEVMODE) {
281
+ anchorStyle.borderColor = position.type === "top" ? "red" : "blue";
282
+ anchorStyle.borderWidth = 1;
283
+ }
284
+ return /* @__PURE__ */ React6__namespace.default.createElement(LeanView, { style }, /* @__PURE__ */ React6__namespace.default.createElement(LeanView, { style: anchorStyle, onLayout, ref }, contentFragment, ENABLE_DEVMODE && /* @__PURE__ */ React6__namespace.default.createElement(reactNative.Text, { style: { position: "absolute", top: 0, left: 0, zIndex: 1e3 } }, position.top)));
251
285
  }
252
- return /* @__PURE__ */ React5__namespace.default.createElement(LeanView, { style, onLayout, ref }, contentFragment);
286
+ return /* @__PURE__ */ React6__namespace.default.createElement(LeanView, { style, onLayout, ref }, contentFragment);
253
287
  };
254
288
  var useAnimatedValue = reactNative.useAnimatedValue || ((initialValue) => {
255
- return React5.useRef(new reactNative.Animated.Value(initialValue)).current;
289
+ return React6.useRef(new reactNative.Animated.Value(initialValue)).current;
256
290
  });
257
291
  function useValue$(key, getValue, useMicrotask) {
258
292
  var _a;
259
293
  const ctx = useStateContext();
260
294
  const animValue = useAnimatedValue((_a = getValue ? getValue(peek$(ctx, key)) : peek$(ctx, key)) != null ? _a : 0);
261
- React5.useMemo(() => {
295
+ React6.useMemo(() => {
262
296
  let newValue = void 0;
263
297
  listen$(ctx, key, (v) => {
264
298
  if (useMicrotask && newValue === void 0) {
@@ -277,7 +311,7 @@ function useValue$(key, getValue, useMicrotask) {
277
311
  }
278
312
 
279
313
  // src/Containers.tsx
280
- var Containers = React5__namespace.memo(function Containers2({
314
+ var Containers = React6__namespace.memo(function Containers2({
281
315
  horizontal,
282
316
  recycleItems,
283
317
  ItemSeparatorComponent,
@@ -296,7 +330,7 @@ var Containers = React5__namespace.memo(function Containers2({
296
330
  const containers = [];
297
331
  for (let i = 0; i < numContainers; i++) {
298
332
  containers.push(
299
- /* @__PURE__ */ React5__namespace.createElement(
333
+ /* @__PURE__ */ React6__namespace.createElement(
300
334
  Container,
301
335
  {
302
336
  id: i,
@@ -311,20 +345,71 @@ var Containers = React5__namespace.memo(function Containers2({
311
345
  );
312
346
  }
313
347
  const style = horizontal ? { width: animSize, opacity: animOpacity } : { height: animSize, opacity: animOpacity };
314
- return /* @__PURE__ */ React5__namespace.createElement(reactNative.Animated.View, { style }, containers);
348
+ return /* @__PURE__ */ React6__namespace.createElement(reactNative.Animated.View, { style }, containers);
315
349
  });
316
350
 
317
351
  // src/ListComponent.tsx
318
352
  var getComponent = (Component) => {
319
- if (React5__namespace.isValidElement(Component)) {
353
+ if (React6__namespace.isValidElement(Component)) {
320
354
  return Component;
321
355
  }
322
356
  if (Component) {
323
- return /* @__PURE__ */ React5__namespace.createElement(Component, null);
357
+ return /* @__PURE__ */ React6__namespace.createElement(Component, null);
324
358
  }
325
359
  return null;
326
360
  };
327
- var ListComponent = React5__namespace.memo(function ListComponent2({
361
+ var PaddingAndAdjust = () => {
362
+ const animPaddingTop = useValue$("paddingTop", (v) => v, true);
363
+ const animScrollAdjust = useValue$("scrollAdjust", (v) => v, true);
364
+ const additionalSize = { marginTop: animScrollAdjust, paddingTop: animPaddingTop };
365
+ return /* @__PURE__ */ React6__namespace.createElement(reactNative.Animated.View, { style: additionalSize });
366
+ };
367
+ var PaddingAndAdjustDevMode = () => {
368
+ const animPaddingTop = useValue$("paddingTop", (v) => v, true);
369
+ const animScrollAdjust = useValue$("scrollAdjust", (v) => v, true);
370
+ return /* @__PURE__ */ React6__namespace.createElement(React6__namespace.Fragment, null, /* @__PURE__ */ React6__namespace.createElement(reactNative.Animated.View, { style: { marginTop: animScrollAdjust } }), /* @__PURE__ */ React6__namespace.createElement(reactNative.Animated.View, { style: { paddingTop: animPaddingTop } }), /* @__PURE__ */ React6__namespace.createElement(
371
+ reactNative.Animated.View,
372
+ {
373
+ style: {
374
+ position: "absolute",
375
+ top: reactNative.Animated.add(animScrollAdjust, reactNative.Animated.multiply(animScrollAdjust, -1)),
376
+ height: animPaddingTop,
377
+ left: 0,
378
+ right: 0,
379
+ backgroundColor: "green"
380
+ }
381
+ }
382
+ ), /* @__PURE__ */ React6__namespace.createElement(
383
+ reactNative.Animated.View,
384
+ {
385
+ style: {
386
+ position: "absolute",
387
+ top: animPaddingTop,
388
+ height: animScrollAdjust,
389
+ left: -16,
390
+ right: -16,
391
+ backgroundColor: "lightblue"
392
+ }
393
+ }
394
+ ), /* @__PURE__ */ React6__namespace.createElement(
395
+ reactNative.Animated.View,
396
+ {
397
+ style: {
398
+ position: "absolute",
399
+ top: animPaddingTop,
400
+ height: reactNative.Animated.multiply(animScrollAdjust, -1),
401
+ width: 8,
402
+ right: 4,
403
+ borderStyle: "dashed",
404
+ borderColor: "blue",
405
+ borderWidth: 1,
406
+ backgroundColor: "lightblue"
407
+ //backgroundColor: "blue",
408
+ }
409
+ }
410
+ ));
411
+ };
412
+ var ListComponent = React6__namespace.memo(function ListComponent2({
328
413
  style,
329
414
  contentContainerStyle,
330
415
  horizontal,
@@ -348,14 +433,11 @@ var ListComponent = React5__namespace.memo(function ListComponent2({
348
433
  ...rest
349
434
  }) {
350
435
  const ctx = useStateContext();
351
- const animPaddingTop = useValue$("paddingTop");
352
- const animScrollAdjust = useValue$("scrollAdjust");
353
- const ScrollComponent = renderScrollComponent ? React5.useMemo(
354
- () => React5__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
436
+ const ScrollComponent = renderScrollComponent ? React6.useMemo(
437
+ () => React6__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
355
438
  [renderScrollComponent]
356
439
  ) : reactNative.ScrollView;
357
- const additionalSize = { marginTop: animScrollAdjust, paddingTop: animPaddingTop };
358
- return /* @__PURE__ */ React5__namespace.createElement(
440
+ return /* @__PURE__ */ React6__namespace.createElement(
359
441
  ScrollComponent,
360
442
  {
361
443
  ...rest,
@@ -373,8 +455,8 @@ var ListComponent = React5__namespace.memo(function ListComponent2({
373
455
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
374
456
  ref: refScrollView
375
457
  },
376
- /* @__PURE__ */ React5__namespace.createElement(reactNative.Animated.View, { style: additionalSize }),
377
- ListHeaderComponent && /* @__PURE__ */ React5__namespace.createElement(
458
+ ENABLE_DEVMODE ? /* @__PURE__ */ React6__namespace.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React6__namespace.createElement(PaddingAndAdjust, null),
459
+ ListHeaderComponent && /* @__PURE__ */ React6__namespace.createElement(
378
460
  reactNative.Animated.View,
379
461
  {
380
462
  style: ListHeaderComponentStyle,
@@ -389,7 +471,7 @@ var ListComponent = React5__namespace.memo(function ListComponent2({
389
471
  getComponent(ListHeaderComponent)
390
472
  ),
391
473
  ListEmptyComponent && getComponent(ListEmptyComponent),
392
- /* @__PURE__ */ React5__namespace.createElement(
474
+ /* @__PURE__ */ React6__namespace.createElement(
393
475
  Containers,
394
476
  {
395
477
  horizontal,
@@ -400,7 +482,7 @@ var ListComponent = React5__namespace.memo(function ListComponent2({
400
482
  updateItemSize
401
483
  }
402
484
  ),
403
- ListFooterComponent && /* @__PURE__ */ React5__namespace.createElement(reactNative.View, { style: ListFooterComponentStyle }, getComponent(ListFooterComponent))
485
+ ListFooterComponent && /* @__PURE__ */ React6__namespace.createElement(reactNative.View, { style: ListFooterComponentStyle }, getComponent(ListFooterComponent))
404
486
  );
405
487
  });
406
488
 
@@ -411,7 +493,6 @@ var ScrollAdjustHandler = class {
411
493
  this.appliedAdjust = 0;
412
494
  this.pendingAdjust = 0;
413
495
  this.busy = false;
414
- this.firstAdjust = true;
415
496
  this.context = ctx;
416
497
  }
417
498
  requestAdjust(adjust, onAdjusted) {
@@ -428,20 +509,16 @@ var ScrollAdjustHandler = class {
428
509
  };
429
510
  if (!this.busy) {
430
511
  this.busy = true;
431
- if (this.firstAdjust) {
432
- this.firstAdjust = false;
433
- setTimeout(doAjdust, 50);
434
- } else {
435
- doAjdust();
436
- }
512
+ doAjdust();
437
513
  }
438
514
  }
439
515
  getAppliedAdjust() {
440
516
  return this.appliedAdjust;
441
517
  }
442
518
  };
519
+ var typedForwardRef = React6.forwardRef;
443
520
  var useCombinedRef = (...refs) => {
444
- const callback = React5.useCallback((element) => {
521
+ const callback = React6.useCallback((element) => {
445
522
  for (const ref of refs) {
446
523
  if (!ref) {
447
524
  continue;
@@ -606,13 +683,13 @@ function maybeUpdateViewabilityCallback(ctx, configId, viewToken) {
606
683
  // src/LegendList.tsx
607
684
  var DEFAULT_DRAW_DISTANCE = 250;
608
685
  var DEFAULT_ITEM_SIZE = 100;
609
- var LegendList = React5.forwardRef(function LegendList2(props, forwardedRef) {
610
- return /* @__PURE__ */ React5__namespace.createElement(StateProvider, null, /* @__PURE__ */ React5__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
686
+ var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
687
+ return /* @__PURE__ */ React6__namespace.createElement(StateProvider, null, /* @__PURE__ */ React6__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
611
688
  });
612
- var LegendListInner = React5.forwardRef(function LegendListInner2(props, forwardedRef) {
689
+ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
613
690
  var _a, _b, _c, _d, _e, _f, _g;
614
691
  const {
615
- data,
692
+ data: dataProp,
616
693
  initialScrollIndex,
617
694
  initialScrollOffset,
618
695
  horizontal,
@@ -640,38 +717,39 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
640
717
  ...rest
641
718
  } = props;
642
719
  const { style, contentContainerStyle } = props;
643
- const callbacks = React5.useRef({
720
+ const callbacks = React6.useRef({
644
721
  onStartReached: rest.onStartReached,
645
722
  onEndReached: rest.onEndReached
646
723
  });
647
724
  callbacks.current.onStartReached = rest.onStartReached;
648
725
  callbacks.current.onEndReached = rest.onEndReached;
649
726
  const ctx = useStateContext();
650
- const refScroller = React5.useRef(null);
727
+ const refScroller = React6.useRef(null);
651
728
  const combinedRef = useCombinedRef(refScroller, refScrollView);
652
729
  const scrollBuffer = drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE;
653
730
  const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (item, index) => index.toString();
654
- const refState = React5.useRef();
731
+ const refState = React6.useRef();
655
732
  const getId = (index) => {
656
733
  var _a2;
657
- const data2 = (_a2 = refState.current) == null ? void 0 : _a2.data;
658
- if (!data2) {
734
+ const data = (_a2 = refState.current) == null ? void 0 : _a2.data;
735
+ if (!data) {
659
736
  return "";
660
737
  }
661
- const ret = index < data2.length ? keyExtractor ? keyExtractor(data2[index], index) : index : null;
738
+ const ret = index < data.length ? keyExtractor ? keyExtractor(data[index], index) : index : null;
662
739
  return `${ret}`;
663
740
  };
664
- const getItemSize = (key, index, data2) => {
741
+ const getItemSize = (key, index, data) => {
665
742
  var _a2;
666
743
  const sizeKnown = refState.current.sizes.get(key);
667
744
  if (sizeKnown !== void 0) {
668
745
  return sizeKnown;
669
746
  }
670
- const size = (_a2 = getEstimatedItemSize ? getEstimatedItemSize(index, data2) : estimatedItemSize) != null ? _a2 : DEFAULT_ITEM_SIZE;
747
+ const size = (_a2 = getEstimatedItemSize ? getEstimatedItemSize(index, data) : estimatedItemSize) != null ? _a2 : DEFAULT_ITEM_SIZE;
671
748
  refState.current.sizes.set(key, size);
672
749
  return size;
673
750
  };
674
751
  const calculateInitialOffset = (index = initialScrollIndex) => {
752
+ const data = dataProp;
675
753
  if (index) {
676
754
  let offset = 0;
677
755
  if (getEstimatedItemSize) {
@@ -685,7 +763,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
685
763
  }
686
764
  return 0;
687
765
  };
688
- const initialContentOffset = initialScrollOffset != null ? initialScrollOffset : React5.useMemo(calculateInitialOffset, []);
766
+ const initialContentOffset = initialScrollOffset != null ? initialScrollOffset : React6.useMemo(calculateInitialOffset, []);
689
767
  if (!refState.current) {
690
768
  const initialScrollLength = reactNative.Dimensions.get("window")[horizontal ? "width" : "height"];
691
769
  refState.current = {
@@ -698,7 +776,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
698
776
  isEndReached: false,
699
777
  isAtBottom: false,
700
778
  isAtTop: false,
701
- data,
779
+ data: dataProp,
702
780
  idsInFirstRender: void 0,
703
781
  hasScrolled: false,
704
782
  scrollLength: initialScrollLength,
@@ -730,14 +808,14 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
730
808
  enableScrollForNextCalculateItemsInView: true,
731
809
  minIndexSizeChanged: 0
732
810
  };
733
- refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
811
+ refState.current.idsInFirstRender = new Set(dataProp.map((_, i) => getId(i)));
734
812
  if (maintainVisibleContentPosition) {
735
813
  if (initialScrollIndex) {
736
814
  refState.current.anchorElement = {
737
815
  coordinate: initialContentOffset,
738
816
  id: getId(initialScrollIndex)
739
817
  };
740
- } else if (data.length) {
818
+ } else if (dataProp.length) {
741
819
  refState.current.anchorElement = {
742
820
  coordinate: initialContentOffset,
743
821
  id: getId(0)
@@ -758,9 +836,9 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
758
836
  }
759
837
  return void 0;
760
838
  };
761
- const addTotalSize = React5.useCallback((key, add, totalSizeBelowAnchor) => {
839
+ const addTotalSize = React6.useCallback((key, add, totalSizeBelowAnchor) => {
762
840
  const state = refState.current;
763
- const { scrollLength, indexByKey, anchorElement } = state;
841
+ const { indexByKey, anchorElement } = state;
764
842
  const index = key === null ? 0 : indexByKey.get(key);
765
843
  let isAboveAnchor = false;
766
844
  if (maintainVisibleContentPosition) {
@@ -777,10 +855,9 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
777
855
  state.totalSizeBelowAnchor += add;
778
856
  }
779
857
  }
780
- let applyAdjustValue = void 0;
781
- const totalSize = state.totalSize;
782
- let resultSize = totalSize;
783
- if (maintainVisibleContentPosition) {
858
+ let applyAdjustValue = 0;
859
+ let resultSize = state.totalSize;
860
+ if (maintainVisibleContentPosition && anchorElement !== void 0) {
784
861
  const newAdjust = anchorElement.coordinate - state.totalSizeBelowAnchor;
785
862
  applyAdjustValue = -newAdjust;
786
863
  state.belowAnchorElementPositions = buildElementPositionsBelowAnchor();
@@ -798,7 +875,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
798
875
  }
799
876
  }, []);
800
877
  const getRowHeight = (n) => {
801
- const { rowHeights } = refState.current;
878
+ const { rowHeights, data } = refState.current;
802
879
  if (numColumnsProp === 1) {
803
880
  const id = getId(n);
804
881
  return getItemSize(id, n, data[n]);
@@ -848,10 +925,10 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
848
925
  }
849
926
  return res;
850
927
  };
851
- const calculateItemsInView = React5.useCallback((speed) => {
928
+ const calculateItemsInView = React6.useCallback((speed) => {
852
929
  const state = refState.current;
853
930
  const {
854
- data: data2,
931
+ data,
855
932
  scrollLength,
856
933
  scroll: scrollState,
857
934
  startBufferedId: startBufferedIdOrig,
@@ -862,7 +939,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
862
939
  if (state.waitingForMicrotask) {
863
940
  state.waitingForMicrotask = false;
864
941
  }
865
- if (!data2) {
942
+ if (!data) {
866
943
  return;
867
944
  }
868
945
  const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
@@ -908,7 +985,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
908
985
  }
909
986
  const top2 = newPosition || positions.get(id);
910
987
  if (top2 !== void 0) {
911
- const size = getItemSize(id, i, data2[i]);
988
+ const size = getItemSize(id, i, data[i]);
912
989
  const bottom = top2 + size;
913
990
  if (bottom > scroll - scrollBuffer) {
914
991
  loopStart = i;
@@ -937,9 +1014,9 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
937
1014
  }
938
1015
  return topOffset;
939
1016
  };
940
- for (let i = loopStart; i < data2.length; i++) {
1017
+ for (let i = loopStart; i < data.length; i++) {
941
1018
  const id = getId(i);
942
- const size = getItemSize(id, i, data2[i]);
1019
+ const size = getItemSize(id, i, data[i]);
943
1020
  maxSizeInRow = Math.max(maxSizeInRow, size);
944
1021
  if (top === void 0) {
945
1022
  top = getInitialTop(i);
@@ -1027,13 +1104,13 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1027
1104
  if (furthestIndex >= 0) {
1028
1105
  set$(ctx, `containerItemKey${furthestIndex}`, id);
1029
1106
  const index = state.indexByKey.get(id);
1030
- set$(ctx, `containerItemData${furthestIndex}`, data2[index]);
1107
+ set$(ctx, `containerItemData${furthestIndex}`, data[index]);
1031
1108
  } else {
1032
1109
  const containerId = numContainers;
1033
1110
  numContainers++;
1034
1111
  set$(ctx, `containerItemKey${containerId}`, id);
1035
1112
  const index = state.indexByKey.get(id);
1036
- set$(ctx, `containerItemData${containerId}`, data2[index]);
1113
+ set$(ctx, `containerItemData${containerId}`, data[index]);
1037
1114
  set$(ctx, `containerPosition${containerId}`, ANCHORED_POSITION_OUT_OF_VIEW);
1038
1115
  set$(ctx, `containerColumn${containerId}`, -1);
1039
1116
  if (__DEV__ && numContainers > peek$(ctx, "numContainersPooled")) {
@@ -1054,13 +1131,13 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1054
1131
  for (let i = 0; i < numContainers; i++) {
1055
1132
  const itemKey = peek$(ctx, `containerItemKey${i}`);
1056
1133
  const itemIndex = state.indexByKey.get(itemKey);
1057
- const item = data2[itemIndex];
1134
+ const item = data[itemIndex];
1058
1135
  if (item) {
1059
1136
  const id = getId(itemIndex);
1060
1137
  if (itemKey !== id || itemIndex < startBuffered || itemIndex > endBuffered) {
1061
1138
  const prevPos = peek$(ctx, `containerPosition${i}`).top;
1062
1139
  const pos = positions.get(id) || 0;
1063
- const size = getItemSize(id, itemIndex, data2[i]);
1140
+ const size = getItemSize(id, itemIndex, data[i]);
1064
1141
  if (pos + size >= scroll && pos <= scrollBottom || prevPos + size >= scroll && prevPos <= scrollBottom) {
1065
1142
  set$(ctx, `containerPosition${i}`, ANCHORED_POSITION_OUT_OF_VIEW);
1066
1143
  }
@@ -1074,7 +1151,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1074
1151
  if (maintainVisibleContentPosition && itemIndex < anchorElementIndex) {
1075
1152
  const currentRow = Math.floor(itemIndex / numColumnsProp);
1076
1153
  const rowHeight = getRowHeight(currentRow);
1077
- const elementHeight = getItemSize(id, itemIndex, data2[i]);
1154
+ const elementHeight = getItemSize(id, itemIndex, data[i]);
1078
1155
  const diff = rowHeight - elementHeight;
1079
1156
  pos.relativeCoordinate = pos.top + getRowHeight(currentRow) - diff;
1080
1157
  pos.type = "bottom";
@@ -1089,7 +1166,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1089
1166
  set$(ctx, `containerColumn${i}`, column2);
1090
1167
  }
1091
1168
  if (prevData !== item) {
1092
- set$(ctx, `containerItemData${i}`, data2[itemIndex]);
1169
+ set$(ctx, `containerItemData${i}`, data[itemIndex]);
1093
1170
  }
1094
1171
  }
1095
1172
  }
@@ -1119,7 +1196,10 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1119
1196
  const doMaintainScrollAtEnd = (animated) => {
1120
1197
  const state = refState.current;
1121
1198
  if ((state == null ? void 0 : state.isAtBottom) && maintainScrollAtEnd) {
1122
- state.scroll = state.totalSize - state.scrollLength + peek$(ctx, "paddingTop");
1199
+ const paddingTop = peek$(ctx, "paddingTop") || 0;
1200
+ if (paddingTop > 0) {
1201
+ state.scroll = 0;
1202
+ }
1123
1203
  requestAnimationFrame(() => {
1124
1204
  var _a2;
1125
1205
  (_a2 = refScroller.current) == null ? void 0 : _a2.scrollToEnd({
@@ -1135,21 +1215,19 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1135
1215
  }
1136
1216
  const { scrollLength, scroll, totalSize } = refState.current;
1137
1217
  if (totalSize > 0) {
1138
- const distanceFromEnd = totalSize - scroll - scrollLength;
1218
+ const distanceFromEnd = totalSize - scroll - scrollLength + (peek$(ctx, "paddingTop") || 0);
1139
1219
  if (refState.current) {
1140
1220
  refState.current.isAtBottom = distanceFromEnd < scrollLength * maintainScrollAtEndThreshold;
1141
1221
  }
1142
- const { onEndReached } = callbacks.current;
1143
- if (onEndReached) {
1144
- if (!refState.current.isEndReached) {
1145
- if (distanceFromEnd < onEndReachedThreshold * scrollLength) {
1146
- refState.current.isEndReached = true;
1147
- onEndReached({ distanceFromEnd });
1148
- }
1149
- } else {
1150
- if (distanceFromEnd >= onEndReachedThreshold * scrollLength) {
1151
- refState.current.isEndReached = false;
1152
- }
1222
+ if (!refState.current.isEndReached) {
1223
+ if (distanceFromEnd < onEndReachedThreshold * scrollLength) {
1224
+ refState.current.isEndReached = true;
1225
+ const { onEndReached } = callbacks.current;
1226
+ onEndReached == null ? void 0 : onEndReached({ distanceFromEnd });
1227
+ }
1228
+ } else {
1229
+ if (distanceFromEnd >= onEndReachedThreshold * scrollLength) {
1230
+ refState.current.isEndReached = false;
1153
1231
  }
1154
1232
  }
1155
1233
  }
@@ -1161,29 +1239,27 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1161
1239
  const { scrollLength, scroll } = refState.current;
1162
1240
  const distanceFromTop = scroll;
1163
1241
  refState.current.isAtTop = distanceFromTop < 0;
1164
- const { onStartReached } = callbacks.current;
1165
- if (onStartReached) {
1166
- if (!refState.current.isStartReached && !refState.current.startReachedBlockedByTimer) {
1167
- if (distanceFromTop < onStartReachedThreshold * scrollLength) {
1168
- refState.current.isStartReached = true;
1169
- onStartReached({ distanceFromStart: scroll });
1170
- refState.current.startReachedBlockedByTimer = true;
1171
- setTimeout(() => {
1172
- refState.current.startReachedBlockedByTimer = false;
1173
- }, 700);
1174
- }
1175
- } else {
1176
- if (distanceFromTop >= 1.3 * onStartReachedThreshold * scrollLength) {
1177
- refState.current.isStartReached = false;
1178
- }
1242
+ if (!refState.current.isStartReached && !refState.current.startReachedBlockedByTimer) {
1243
+ if (distanceFromTop < onStartReachedThreshold * scrollLength) {
1244
+ refState.current.isStartReached = true;
1245
+ const { onStartReached } = callbacks.current;
1246
+ onStartReached == null ? void 0 : onStartReached({ distanceFromStart: scroll });
1247
+ refState.current.startReachedBlockedByTimer = true;
1248
+ setTimeout(() => {
1249
+ refState.current.startReachedBlockedByTimer = false;
1250
+ }, 700);
1251
+ }
1252
+ } else {
1253
+ if (distanceFromTop >= 1.3 * onStartReachedThreshold * scrollLength) {
1254
+ refState.current.isStartReached = false;
1179
1255
  }
1180
1256
  }
1181
1257
  };
1182
- const checkResetContainers = (reset) => {
1258
+ const checkResetContainers = (isFirst2) => {
1183
1259
  const state = refState.current;
1184
1260
  if (state) {
1185
- state.data = data;
1186
- if (reset) {
1261
+ state.data = dataProp;
1262
+ if (!isFirst2) {
1187
1263
  refState.current.scrollForNextCalculateItemsInView = void 0;
1188
1264
  const numContainers = peek$(ctx, "numContainers");
1189
1265
  for (let i = 0; i < numContainers; i++) {
@@ -1199,28 +1275,28 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1199
1275
  state.positions.clear();
1200
1276
  }
1201
1277
  calculateItemsInView(state.scrollVelocity);
1278
+ const didMaintainScrollAtEnd = doMaintainScrollAtEnd(false);
1279
+ if (!didMaintainScrollAtEnd && dataProp.length > state.data.length) {
1280
+ state.isEndReached = false;
1281
+ }
1282
+ checkAtTop();
1283
+ checkAtBottom();
1202
1284
  }
1203
- const didMaintainScrollAtEnd = doMaintainScrollAtEnd(false);
1204
- if (!didMaintainScrollAtEnd && data.length > state.data.length) {
1205
- state.isEndReached = false;
1206
- }
1207
- checkAtTop();
1208
- checkAtBottom();
1209
1285
  }
1210
1286
  };
1211
1287
  const isFirst = !refState.current.renderItem;
1212
- if (isFirst || data !== refState.current.data || numColumnsProp !== peek$(ctx, "numColumns")) {
1213
- if (!keyExtractorProp && !isFirst && data !== refState.current.data) {
1288
+ if (isFirst || dataProp !== refState.current.data || numColumnsProp !== peek$(ctx, "numColumns")) {
1289
+ if (!keyExtractorProp && !isFirst && dataProp !== refState.current.data) {
1214
1290
  refState.current.positions.clear();
1215
1291
  }
1216
- refState.current.data = data;
1292
+ refState.current.data = dataProp;
1217
1293
  let totalSize = 0;
1218
1294
  let totalSizeBelowIndex = 0;
1219
1295
  const indexByKey = /* @__PURE__ */ new Map();
1220
1296
  const newPositions = /* @__PURE__ */ new Map();
1221
1297
  let column = 1;
1222
1298
  let maxSizeInRow = 0;
1223
- for (let i = 0; i < data.length; i++) {
1299
+ for (let i = 0; i < dataProp.length; i++) {
1224
1300
  const key = getId(i);
1225
1301
  if (__DEV__) {
1226
1302
  if (indexByKey.has(key)) {
@@ -1239,7 +1315,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1239
1315
  if (!isFirst) {
1240
1316
  if (maintainVisibleContentPosition) {
1241
1317
  if (refState.current.anchorElement == null || indexByKey.get(refState.current.anchorElement.id) == null) {
1242
- if (data.length) {
1318
+ if (dataProp.length) {
1243
1319
  const newAnchorElement = {
1244
1320
  coordinate: 0,
1245
1321
  id: getId(0)
@@ -1256,7 +1332,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1256
1332
  }
1257
1333
  } else {
1258
1334
  if (refState.current.startBufferedId != null && newPositions.get(refState.current.startBufferedId) == null) {
1259
- if (data.length) {
1335
+ if (dataProp.length) {
1260
1336
  refState.current.startBufferedId = getId(0);
1261
1337
  } else {
1262
1338
  refState.current.startBufferedId = void 0;
@@ -1269,9 +1345,9 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1269
1345
  }
1270
1346
  }
1271
1347
  const anchorElementIndex = getAnchorElementIndex();
1272
- for (let i = 0; i < data.length; i++) {
1348
+ for (let i = 0; i < dataProp.length; i++) {
1273
1349
  const key = getId(i);
1274
- const size = getItemSize(key, i, data[i]);
1350
+ const size = getItemSize(key, i, dataProp[i]);
1275
1351
  maxSizeInRow = Math.max(maxSizeInRow, size);
1276
1352
  column++;
1277
1353
  if (column > numColumnsProp) {
@@ -1288,17 +1364,17 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1288
1364
  }
1289
1365
  addTotalSize(null, totalSize, totalSizeBelowIndex);
1290
1366
  }
1291
- React5.useEffect(() => {
1367
+ React6.useEffect(() => {
1292
1368
  checkResetContainers(
1293
- /*reset*/
1294
- !isFirst
1369
+ /*isFirst*/
1370
+ isFirst
1295
1371
  );
1296
- }, [isFirst, data, numColumnsProp]);
1297
- React5.useEffect(() => {
1372
+ }, [isFirst, dataProp, numColumnsProp]);
1373
+ React6.useEffect(() => {
1298
1374
  set$(ctx, "extraData", extraData);
1299
1375
  }, [extraData]);
1300
1376
  refState.current.renderItem = renderItem;
1301
- const lastItemKey = data.length > 0 ? getId(data.length - 1) : void 0;
1377
+ const lastItemKey = dataProp.length > 0 ? getId(dataProp.length - 1) : void 0;
1302
1378
  const stylePaddingTop = (_g = (_f = (_d = reactNative.StyleSheet.flatten(style)) == null ? void 0 : _d.paddingTop) != null ? _f : (_e = reactNative.StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _e.paddingTop) != null ? _g : 0;
1303
1379
  const initalizeStateVars = () => {
1304
1380
  set$(ctx, "lastItemKey", lastItemKey);
@@ -1308,14 +1384,14 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1308
1384
  if (isFirst) {
1309
1385
  initalizeStateVars();
1310
1386
  }
1311
- React5.useEffect(initalizeStateVars, [lastItemKey, numColumnsProp, stylePaddingTop]);
1312
- const getRenderedItem = React5.useCallback((key) => {
1387
+ React6.useEffect(initalizeStateVars, [lastItemKey, numColumnsProp, stylePaddingTop]);
1388
+ const getRenderedItem = React6.useCallback((key) => {
1313
1389
  var _a2, _b2;
1314
1390
  const state = refState.current;
1315
1391
  if (!state) {
1316
1392
  return null;
1317
1393
  }
1318
- const { data: data2, indexByKey } = state;
1394
+ const { data, indexByKey } = state;
1319
1395
  const index = indexByKey.get(key);
1320
1396
  if (index === void 0) {
1321
1397
  return null;
@@ -1333,7 +1409,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1333
1409
  return useRecyclingState(valueOrFun);
1334
1410
  };
1335
1411
  const renderedItem = (_b2 = (_a2 = refState.current).renderItem) == null ? void 0 : _b2.call(_a2, {
1336
- item: data2[index],
1412
+ item: data[index],
1337
1413
  index,
1338
1414
  useViewability: useViewability2,
1339
1415
  useViewabilityAmount: useViewabilityAmount2,
@@ -1349,7 +1425,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1349
1425
  state.viewabilityConfigCallbackPairs = viewability;
1350
1426
  state.enableScrollForNextCalculateItemsInView = !viewability;
1351
1427
  const scrollLength = state.scrollLength;
1352
- const averageItemSize = (_a2 = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0])) != null ? _a2 : DEFAULT_ITEM_SIZE;
1428
+ const averageItemSize = (_a2 = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, dataProp[0])) != null ? _a2 : DEFAULT_ITEM_SIZE;
1353
1429
  const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize) * numColumnsProp;
1354
1430
  for (let i = 0; i < numContainers; i++) {
1355
1431
  set$(ctx, `containerPosition${i}`, ANCHORED_POSITION_OUT_OF_VIEW);
@@ -1357,31 +1433,33 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1357
1433
  }
1358
1434
  set$(ctx, "numContainers", numContainers);
1359
1435
  set$(ctx, "numContainersPooled", numContainers * 2);
1360
- calculateItemsInView(state.scrollVelocity);
1436
+ if (initialScrollIndex) {
1437
+ requestAnimationFrame(() => {
1438
+ calculateItemsInView(state.scrollVelocity);
1439
+ });
1440
+ } else {
1441
+ calculateItemsInView(state.scrollVelocity);
1442
+ }
1361
1443
  });
1362
- const updateItemSize = React5.useCallback((containerId, itemKey, size) => {
1444
+ const updateItemSize = React6.useCallback((containerId, itemKey, size) => {
1363
1445
  const state = refState.current;
1364
- const { sizes, indexByKey, columns, sizesLaidOut, data: data2 } = state;
1365
- if (!data2) {
1446
+ const { sizes, indexByKey, columns, sizesLaidOut, data, rowHeights } = state;
1447
+ if (!data) {
1366
1448
  return;
1367
1449
  }
1368
1450
  const index = indexByKey.get(itemKey);
1369
1451
  const numColumns = peek$(ctx, "numColumns");
1370
1452
  state.minIndexSizeChanged = state.minIndexSizeChanged !== void 0 ? Math.min(state.minIndexSizeChanged, index) : index;
1371
- const prevSize = getItemSize(itemKey, index, data2);
1453
+ const prevSize = getItemSize(itemKey, index, data);
1372
1454
  if (!prevSize || Math.abs(prevSize - size) > 0.5) {
1373
1455
  let diff;
1374
1456
  if (numColumns > 1) {
1457
+ const rowNumber = Math.floor(index / numColumnsProp);
1458
+ const prevSizeInRow = getRowHeight(rowNumber);
1375
1459
  sizes.set(itemKey, size);
1376
- const column = columns.get(itemKey);
1377
- const loopStart = index - (column - 1);
1378
- let nextMaxSizeInRow = 0;
1379
- for (let i = loopStart; i < loopStart + numColumns && i < data2.length; i++) {
1380
- const id = getId(i);
1381
- const size2 = getItemSize(id, i, data2[i]);
1382
- nextMaxSizeInRow = Math.max(nextMaxSizeInRow, size2);
1383
- }
1384
- diff = nextMaxSizeInRow - prevSize;
1460
+ rowHeights.delete(rowNumber);
1461
+ const sizeInRow = getRowHeight(rowNumber);
1462
+ diff = sizeInRow - prevSizeInRow;
1385
1463
  } else {
1386
1464
  sizes.set(itemKey, size);
1387
1465
  diff = size - prevSize;
@@ -1423,16 +1501,16 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1423
1501
  }
1424
1502
  }
1425
1503
  if (onItemSizeChanged) {
1426
- onItemSizeChanged({ size, previous: prevSize, index, itemKey, itemData: data2[index] });
1504
+ onItemSizeChanged({ size, previous: prevSize, index, itemKey, itemData: data[index] });
1427
1505
  }
1428
1506
  }
1429
1507
  }, []);
1430
- const handleScrollDebounced = React5.useCallback((velocity) => {
1508
+ const handleScrollDebounced = React6.useCallback((velocity) => {
1431
1509
  calculateItemsInView(velocity);
1432
1510
  checkAtBottom();
1433
1511
  checkAtTop();
1434
1512
  }, []);
1435
- const onLayout = React5.useCallback((event) => {
1513
+ const onLayout = React6.useCallback((event) => {
1436
1514
  const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
1437
1515
  const didChange = scrollLength !== refState.current.scrollLength;
1438
1516
  refState.current.scrollLength = scrollLength;
@@ -1456,7 +1534,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1456
1534
  onLayoutProp(event);
1457
1535
  }
1458
1536
  }, []);
1459
- const handleScroll = React5.useCallback(
1537
+ const handleScroll = React6.useCallback(
1460
1538
  (event, fromSelf) => {
1461
1539
  var _a2, _b2, _c2;
1462
1540
  if (((_b2 = (_a2 = event.nativeEvent) == null ? void 0 : _a2.contentSize) == null ? void 0 : _b2.height) === 0 && ((_c2 = event.nativeEvent.contentSize) == null ? void 0 : _c2.width) === 0) {
@@ -1498,7 +1576,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1498
1576
  },
1499
1577
  []
1500
1578
  );
1501
- React5.useImperativeHandle(
1579
+ React6.useImperativeHandle(
1502
1580
  forwardedRef,
1503
1581
  () => {
1504
1582
  const scrollToIndex = ({ index, animated }) => {
@@ -1517,6 +1595,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1517
1595
  refScroller.current.scrollTo({ ...offsetObj, animated });
1518
1596
  },
1519
1597
  scrollToItem: ({ item, animated }) => {
1598
+ const { data } = refState.current;
1520
1599
  const index = data.indexOf(item);
1521
1600
  if (index !== -1) {
1522
1601
  scrollToIndex({ index, animated });
@@ -1527,7 +1606,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1527
1606
  },
1528
1607
  []
1529
1608
  );
1530
- return /* @__PURE__ */ React5__namespace.createElement(
1609
+ return /* @__PURE__ */ React6__namespace.createElement(React6__namespace.Fragment, null, /* @__PURE__ */ React6__namespace.createElement(
1531
1610
  ListComponent,
1532
1611
  {
1533
1612
  ...rest,
@@ -1540,13 +1619,13 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
1540
1619
  onLayout,
1541
1620
  recycleItems,
1542
1621
  alignItemsAtEnd,
1543
- ListEmptyComponent: data.length === 0 ? ListEmptyComponent : void 0,
1622
+ ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
1544
1623
  maintainVisibleContentPosition,
1545
1624
  scrollEventThrottle: scrollEventThrottle != null ? scrollEventThrottle : reactNative.Platform.OS === "web" ? 16 : void 0,
1546
1625
  waitForInitialLayout,
1547
1626
  style
1548
1627
  }
1549
- );
1628
+ ), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React6__namespace.createElement(DebugView, { state: refState.current }));
1550
1629
  });
1551
1630
 
1552
1631
  exports.LegendList = LegendList;