@legendapp/list 2.0.0-next.3 → 2.0.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.mjs CHANGED
@@ -3,21 +3,22 @@ import React3__default, { useReducer, useEffect, createContext, useMemo, useStat
3
3
  import { View, Text, Platform, Animated, ScrollView, StyleSheet, Dimensions, RefreshControl } from 'react-native';
4
4
  import { useSyncExternalStore } from 'use-sync-external-store/shim';
5
5
 
6
- // src/LegendList.tsx
6
+ // src/components/LazyLegendList.tsx
7
7
  var ContextState = React3.createContext(null);
8
8
  function StateProvider({ children }) {
9
9
  const [value] = React3.useState(() => ({
10
+ columnWrapperStyle: void 0,
10
11
  listeners: /* @__PURE__ */ new Map(),
12
+ mapViewabilityAmountCallbacks: /* @__PURE__ */ new Map(),
13
+ mapViewabilityAmountValues: /* @__PURE__ */ new Map(),
14
+ mapViewabilityCallbacks: /* @__PURE__ */ new Map(),
15
+ mapViewabilityValues: /* @__PURE__ */ new Map(),
11
16
  values: /* @__PURE__ */ new Map([
12
17
  ["alignItemsPaddingTop", 0],
13
18
  ["stylePaddingTop", 0],
14
- ["headerSize", 0]
19
+ ["headerSize", 0],
20
+ ["numContainers", 0]
15
21
  ]),
16
- mapViewabilityCallbacks: /* @__PURE__ */ new Map(),
17
- mapViewabilityValues: /* @__PURE__ */ new Map(),
18
- mapViewabilityAmountCallbacks: /* @__PURE__ */ new Map(),
19
- mapViewabilityAmountValues: /* @__PURE__ */ new Map(),
20
- columnWrapperStyle: void 0,
21
22
  viewRefs: /* @__PURE__ */ new Map()
22
23
  }));
23
24
  return /* @__PURE__ */ React3.createElement(ContextState.Provider, { value }, children);
@@ -29,17 +30,6 @@ function createSelectorFunctionsArr(ctx, signalNames) {
29
30
  let lastValues = [];
30
31
  let lastSignalValues = [];
31
32
  return {
32
- subscribe: (cb) => {
33
- const listeners = [];
34
- for (const signalName of signalNames) {
35
- listeners.push(listen$(ctx, signalName, cb));
36
- }
37
- return () => {
38
- for (const listener of listeners) {
39
- listener();
40
- }
41
- };
42
- },
43
33
  get: () => {
44
34
  const currentValues = [];
45
35
  let hasChanged = false;
@@ -55,6 +45,17 @@ function createSelectorFunctionsArr(ctx, signalNames) {
55
45
  lastValues = currentValues;
56
46
  }
57
47
  return lastValues;
48
+ },
49
+ subscribe: (cb) => {
50
+ const listeners = [];
51
+ for (const signalName of signalNames) {
52
+ listeners.push(listen$(ctx, signalName, cb));
53
+ }
54
+ return () => {
55
+ for (const listener of listeners) {
56
+ listener();
57
+ }
58
+ };
58
59
  }
59
60
  };
60
61
  }
@@ -105,13 +106,13 @@ function useSelector$(signalName, selector) {
105
106
  return value;
106
107
  }
107
108
 
108
- // src/DebugView.tsx
109
+ // src/components/DebugView.tsx
109
110
  var DebugRow = ({ children }) => {
110
- return /* @__PURE__ */ React3.createElement(View, { style: { flexDirection: "row", alignItems: "center", justifyContent: "space-between" } }, children);
111
+ return /* @__PURE__ */ React3.createElement(View, { style: { alignItems: "center", flexDirection: "row", justifyContent: "space-between" } }, children);
111
112
  };
112
113
  var DebugView = React3.memo(function DebugView2({ state }) {
113
114
  const ctx = useStateContext();
114
- const [totalSize = 0, scrollAdjust = 0, rawScroll = 0, scroll = 0, numContainers = 0, numContainersPooled = 0] = useArr$([
115
+ const [totalSize = 0, scrollAdjust = 0, rawScroll = 0, scroll = 0, _numContainers = 0, _numContainersPooled = 0] = useArr$([
115
116
  "totalSize",
116
117
  "scrollAdjust",
117
118
  "debugRawScroll",
@@ -127,18 +128,18 @@ var DebugView = React3.memo(function DebugView2({ state }) {
127
128
  return /* @__PURE__ */ React3.createElement(
128
129
  View,
129
130
  {
131
+ pointerEvents: "none",
130
132
  style: {
131
- position: "absolute",
132
- top: 0,
133
- right: 0,
134
- paddingLeft: 4,
135
- paddingBottom: 4,
136
133
  // height: 100,
137
134
  backgroundColor: "#FFFFFFCC",
135
+ borderRadius: 4,
138
136
  padding: 4,
139
- borderRadius: 4
140
- },
141
- pointerEvents: "none"
137
+ paddingBottom: 4,
138
+ paddingLeft: 4,
139
+ position: "absolute",
140
+ right: 0,
141
+ top: 0
142
+ }
142
143
  },
143
144
  /* @__PURE__ */ React3.createElement(DebugRow, null, /* @__PURE__ */ React3.createElement(Text, null, "TotalSize:"), /* @__PURE__ */ React3.createElement(Text, null, totalSize.toFixed(2))),
144
145
  /* @__PURE__ */ React3.createElement(DebugRow, null, /* @__PURE__ */ React3.createElement(Text, null, "ContentSize:"), /* @__PURE__ */ React3.createElement(Text, null, contentSize.toFixed(2))),
@@ -156,8 +157,34 @@ function useInterval(callback, delay) {
156
157
  return () => clearInterval(interval);
157
158
  }, [delay]);
158
159
  }
160
+ var LeanViewComponent = React3.forwardRef((props, ref) => {
161
+ return React3.createElement("RCTView", { ...props, ref });
162
+ });
163
+ LeanViewComponent.displayName = "RCTView";
164
+ var LeanView = Platform.OS === "android" || Platform.OS === "ios" ? LeanViewComponent : View;
165
+
166
+ // src/components/Separator.tsx
167
+ function Separator({ ItemSeparatorComponent, itemKey, leadingItem }) {
168
+ const [lastItemKeys] = useArr$(["lastItemKeys"]);
169
+ const isALastItem = lastItemKeys.includes(itemKey);
170
+ return isALastItem ? null : /* @__PURE__ */ React.createElement(ItemSeparatorComponent, { leadingItem });
171
+ }
172
+
173
+ // src/constants.ts
174
+ var POSITION_OUT_OF_VIEW = -1e7;
175
+ var ENABLE_DEVMODE = __DEV__ && false;
176
+ var ENABLE_DEBUG_VIEW = __DEV__ && false;
177
+ var IsNewArchitecture = global.nativeFabricUIManager != null;
178
+ var symbolFirst = Symbol();
179
+ function useInit(cb) {
180
+ const refValue = useRef(symbolFirst);
181
+ if (refValue.current === symbolFirst) {
182
+ refValue.current = cb();
183
+ }
184
+ return refValue.current;
185
+ }
159
186
 
160
- // src/helpers.ts
187
+ // src/utils/helpers.ts
161
188
  function isFunction(obj) {
162
189
  return typeof obj === "function";
163
190
  }
@@ -187,16 +214,8 @@ function getPadding(s, type) {
187
214
  function extractPadding(style, contentContainerStyle, type) {
188
215
  return getPadding(style, type) + getPadding(contentContainerStyle, type);
189
216
  }
190
- var symbolFirst = Symbol();
191
- function useInit(cb) {
192
- const refValue = useRef(symbolFirst);
193
- if (refValue.current === symbolFirst) {
194
- refValue.current = cb();
195
- }
196
- return refValue.current;
197
- }
198
217
 
199
- // src/ContextContainer.ts
218
+ // src/state/ContextContainer.ts
200
219
  var ContextContainer = createContext(null);
201
220
  function useViewability(callback, configId) {
202
221
  const ctx = useStateContext();
@@ -240,7 +259,7 @@ function useRecyclingEffect(effect) {
240
259
  prevItem: void 0
241
260
  });
242
261
  useEffect(() => {
243
- let ret = void 0;
262
+ let ret;
244
263
  if (prevValues.current.prevIndex !== void 0 && prevValues.current.prevItem !== void 0) {
245
264
  ret = effect({
246
265
  index,
@@ -254,7 +273,7 @@ function useRecyclingEffect(effect) {
254
273
  prevItem: value
255
274
  };
256
275
  return ret;
257
- }, [index, value]);
276
+ }, [index, value, effect]);
258
277
  }
259
278
  function useRecyclingState(valueOrFun) {
260
279
  const { index, value, itemKey, triggerLayout } = useContext(ContextContainer);
@@ -292,26 +311,8 @@ function useListScrollSize() {
292
311
  const [scrollSize] = useArr$(["scrollSize"]);
293
312
  return scrollSize;
294
313
  }
295
- var LeanViewComponent = React3.forwardRef((props, ref) => {
296
- return React3.createElement("RCTView", { ...props, ref });
297
- });
298
- LeanViewComponent.displayName = "RCTView";
299
- var LeanView = Platform.OS === "android" || Platform.OS === "ios" ? LeanViewComponent : View;
300
-
301
- // src/Separator.tsx
302
- function Separator({ ItemSeparatorComponent, itemKey, leadingItem }) {
303
- const [lastItemKeys] = useArr$(["lastItemKeys"]);
304
- const isALastItem = lastItemKeys.includes(itemKey);
305
- return isALastItem ? null : /* @__PURE__ */ React.createElement(ItemSeparatorComponent, { leadingItem });
306
- }
307
-
308
- // src/constants.ts
309
- var POSITION_OUT_OF_VIEW = -1e7;
310
- var ENABLE_DEVMODE = __DEV__ && false;
311
- var ENABLE_DEBUG_VIEW = __DEV__ && false;
312
- var IsNewArchitecture = global.nativeFabricUIManager != null;
313
314
 
314
- // src/Container.tsx
315
+ // src/components/Container.tsx
315
316
  var Container = ({
316
317
  id,
317
318
  recycleItems,
@@ -353,17 +354,17 @@ var Container = ({
353
354
  }
354
355
  const style = horizontal ? {
355
356
  flexDirection: ItemSeparatorComponent ? "row" : void 0,
356
- position: "absolute",
357
- top: otherAxisPos,
358
357
  height: otherAxisSize,
359
358
  left: position,
359
+ position: "absolute",
360
+ top: otherAxisPos,
360
361
  ...paddingStyles || {}
361
362
  } : {
362
- position: "absolute",
363
363
  left: otherAxisPos,
364
+ position: "absolute",
364
365
  right: numColumns > 1 ? null : 0,
365
- width: otherAxisSize,
366
366
  top: position,
367
+ width: otherAxisSize,
367
368
  ...paddingStyles || {}
368
369
  };
369
370
  const renderedItemInfo = useMemo(
@@ -376,7 +377,7 @@ var Container = ({
376
377
  }, []);
377
378
  const contextValue = useMemo(() => {
378
379
  ctx.viewRefs.set(id, ref);
379
- return { containerId: id, itemKey, index, value: data, triggerLayout };
380
+ return { containerId: id, index, itemKey, triggerLayout, value: data };
380
381
  }, [id, itemKey, index, data]);
381
382
  const onLayout = (event) => {
382
383
  var _a, _b;
@@ -385,14 +386,14 @@ var Container = ({
385
386
  let layout = event.nativeEvent.layout;
386
387
  const size = layout[horizontal ? "width" : "height"];
387
388
  const doUpdate = () => {
388
- refLastSize.current = { width: layout.width, height: layout.height };
389
+ refLastSize.current = { height: layout.height, width: layout.width };
389
390
  updateItemSize2(itemKey, layout);
390
391
  };
391
392
  if (IsNewArchitecture || size > 0) {
392
393
  doUpdate();
393
394
  } else {
394
- (_b = (_a = ref.current) == null ? void 0 : _a.measure) == null ? void 0 : _b.call(_a, (x, y, width, height) => {
395
- layout = { width, height };
395
+ (_b = (_a = ref.current) == null ? void 0 : _a.measure) == null ? void 0 : _b.call(_a, (_x, _y, width, height) => {
396
+ layout = { height, width };
396
397
  doUpdate();
397
398
  });
398
399
  }
@@ -425,30 +426,28 @@ var Container = ({
425
426
  }
426
427
  }, [itemKey]);
427
428
  }
428
- return /* @__PURE__ */ React3.createElement(LeanView, { style, onLayout, ref, key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React3.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && /* @__PURE__ */ React3.createElement(
429
+ return /* @__PURE__ */ React3.createElement(LeanView, { key: recycleItems ? void 0 : itemKey, onLayout, ref, style }, /* @__PURE__ */ React3.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && /* @__PURE__ */ React3.createElement(
429
430
  Separator,
430
431
  {
431
- itemKey,
432
432
  ItemSeparatorComponent,
433
+ itemKey,
433
434
  leadingItem: renderedItemInfo.item
434
435
  }
435
436
  )));
436
437
  };
437
- var typedForwardRef = forwardRef;
438
- var typedMemo = memo;
439
438
  var useAnimatedValue = (initialValue) => {
440
439
  return useRef(new Animated.Value(initialValue)).current;
441
440
  };
442
441
 
443
- // src/useValue$.ts
442
+ // src/hooks/useValue$.ts
444
443
  function useValue$(key, params) {
445
444
  var _a;
446
445
  const { getValue, delay } = params || {};
447
446
  const ctx = useStateContext();
448
447
  const animValue = useAnimatedValue((_a = getValue ? getValue(peek$(ctx, key)) : peek$(ctx, key)) != null ? _a : 0);
449
448
  useMemo(() => {
450
- let newValue = void 0;
451
- let prevValue = void 0;
449
+ let newValue;
450
+ let prevValue;
452
451
  let didQueueTask = false;
453
452
  listen$(ctx, key, (v) => {
454
453
  newValue = getValue ? getValue(v) : v;
@@ -476,8 +475,10 @@ function useValue$(key, params) {
476
475
  }, []);
477
476
  return animValue;
478
477
  }
478
+ var typedForwardRef = forwardRef;
479
+ var typedMemo = memo;
479
480
 
480
- // src/Containers.tsx
481
+ // src/components/Containers.tsx
481
482
  var Containers = typedMemo(function Containers2({
482
483
  horizontal,
483
484
  recycleItems,
@@ -501,18 +502,18 @@ var Containers = typedMemo(function Containers2({
501
502
  /* @__PURE__ */ React3.createElement(
502
503
  Container,
503
504
  {
505
+ getRenderedItem: getRenderedItem2,
506
+ horizontal,
507
+ ItemSeparatorComponent,
504
508
  id: i,
505
509
  key: i,
506
510
  recycleItems,
507
- horizontal,
508
- getRenderedItem: getRenderedItem2,
509
- updateItemSize: updateItemSize2,
510
- ItemSeparatorComponent
511
+ updateItemSize: updateItemSize2
511
512
  }
512
513
  )
513
514
  );
514
515
  }
515
- const style = horizontal ? { width: animSize, opacity: animOpacity, minHeight: otherAxisSize } : { height: animSize, opacity: animOpacity, minWidth: otherAxisSize };
516
+ const style = horizontal ? { minHeight: otherAxisSize, opacity: animOpacity, width: animSize } : { height: animSize, minWidth: otherAxisSize, opacity: animOpacity };
516
517
  if (columnWrapperStyle && numColumns > 1) {
517
518
  const { columnGap, rowGap, gap } = columnWrapperStyle;
518
519
  const gapX = columnGap || gap || 0;
@@ -543,20 +544,19 @@ function ScrollAdjust() {
543
544
  View,
544
545
  {
545
546
  style: {
546
- position: "absolute",
547
547
  height: 0,
548
- width: 0,
548
+ left: 0,
549
+ position: "absolute",
549
550
  top: scrollOffset,
550
- left: 0
551
+ width: 0
551
552
  }
552
553
  }
553
554
  );
554
555
  }
555
556
 
556
- // src/SnapWrapper.tsx
557
+ // src/components/SnapWrapper.tsx
557
558
  function SnapWrapper({ ScrollComponent, ...props }) {
558
559
  const [snapToOffsets] = useArr$(["snapToOffsets"]);
559
- console.log("snapToOffsets", snapToOffsets);
560
560
  return /* @__PURE__ */ React.createElement(ScrollComponent, { ...props, snapToOffsets });
561
561
  }
562
562
  function useSyncLayout({
@@ -572,14 +572,14 @@ function useSyncLayout({
572
572
  useLayoutEffect(() => {
573
573
  if (ref.current) {
574
574
  ref.current.measure((x, y, width, height) => {
575
- onChange({ x, y, width, height }, true);
575
+ onChange({ height, width, x, y }, true);
576
576
  });
577
577
  }
578
578
  }, []);
579
579
  return { onLayout, ref };
580
580
  }
581
581
 
582
- // src/ListComponent.tsx
582
+ // src/components/ListComponent.tsx
583
583
  var getComponent = (Component) => {
584
584
  if (React3.isValidElement(Component)) {
585
585
  return Component;
@@ -599,12 +599,12 @@ var PaddingDevMode = () => {
599
599
  Animated.View,
600
600
  {
601
601
  style: {
602
- position: "absolute",
603
- top: 0,
602
+ backgroundColor: "green",
604
603
  height: animPaddingTop,
605
604
  left: 0,
605
+ position: "absolute",
606
606
  right: 0,
607
- backgroundColor: "green"
607
+ top: 0
608
608
  }
609
609
  }
610
610
  ));
@@ -656,73 +656,51 @@ var ListComponent = typedMemo(function ListComponent2({
656
656
  SnapOrScroll,
657
657
  {
658
658
  ...rest,
659
- ScrollComponent: snapToIndices ? ScrollComponent : void 0,
660
- style,
661
- maintainVisibleContentPosition: maintainVisibleContentPosition && !ListEmptyComponent ? { minIndexForVisible: 0 } : void 0,
662
659
  contentContainerStyle: [
663
660
  contentContainerStyle,
664
661
  horizontal ? {
665
662
  height: "100%"
666
663
  } : {}
667
664
  ],
668
- onScroll: onScroll2,
669
- onLayout,
670
- horizontal,
671
665
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
672
- ref: refScrollView
666
+ horizontal,
667
+ maintainVisibleContentPosition: maintainVisibleContentPosition && !ListEmptyComponent ? { minIndexForVisible: 0 } : void 0,
668
+ onLayout,
669
+ onScroll: onScroll2,
670
+ ref: refScrollView,
671
+ ScrollComponent: snapToIndices ? ScrollComponent : void 0,
672
+ style
673
673
  },
674
674
  maintainVisibleContentPosition && /* @__PURE__ */ React3.createElement(ScrollAdjust, null),
675
675
  ENABLE_DEVMODE ? /* @__PURE__ */ React3.createElement(PaddingDevMode, null) : /* @__PURE__ */ React3.createElement(Padding, null),
676
- ListHeaderComponent && /* @__PURE__ */ React3.createElement(View, { style: ListHeaderComponentStyle, onLayout: onLayoutHeaderSync, ref: refHeader }, getComponent(ListHeaderComponent)),
676
+ ListHeaderComponent && /* @__PURE__ */ React3.createElement(View, { onLayout: onLayoutHeaderSync, ref: refHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
677
677
  ListEmptyComponent && getComponent(ListEmptyComponent),
678
678
  canRender && /* @__PURE__ */ React3.createElement(
679
679
  Containers,
680
680
  {
681
- horizontal,
682
- recycleItems,
683
- waitForInitialLayout,
684
681
  getRenderedItem: getRenderedItem2,
682
+ horizontal,
685
683
  ItemSeparatorComponent,
686
- updateItemSize: updateItemSize2
684
+ recycleItems,
685
+ updateItemSize: updateItemSize2,
686
+ waitForInitialLayout
687
687
  }
688
688
  ),
689
689
  ListFooterComponent && /* @__PURE__ */ React3.createElement(
690
690
  View,
691
691
  {
692
- style: ListFooterComponentStyle,
693
692
  onLayout: (event) => {
694
693
  const size = event.nativeEvent.layout[horizontal ? "width" : "height"];
695
694
  set$(ctx, "footerSize", size);
696
- }
695
+ },
696
+ style: ListFooterComponentStyle
697
697
  },
698
698
  getComponent(ListFooterComponent)
699
699
  )
700
700
  );
701
701
  });
702
702
 
703
- // src/ScrollAdjustHandler.ts
704
- var ScrollAdjustHandler = class {
705
- constructor(ctx) {
706
- this.appliedAdjust = 0;
707
- this.mounted = false;
708
- this.context = ctx;
709
- }
710
- requestAdjust(add) {
711
- const oldAdjustTop = peek$(this.context, "scrollAdjust") || 0;
712
- this.appliedAdjust = add + oldAdjustTop;
713
- const set = () => set$(this.context, "scrollAdjust", this.appliedAdjust);
714
- if (this.mounted) {
715
- set();
716
- } else {
717
- requestAnimationFrame(set);
718
- }
719
- }
720
- setMounted() {
721
- this.mounted = true;
722
- }
723
- };
724
-
725
- // src/getId.ts
703
+ // src/utils/getId.ts
726
704
  function getId(state, index) {
727
705
  const { data, keyExtractor } = state.props;
728
706
  if (!data) {
@@ -734,7 +712,7 @@ function getId(state, index) {
734
712
  return id;
735
713
  }
736
714
 
737
- // src/calculateOffsetForIndex.ts
715
+ // src/core/calculateOffsetForIndex.ts
738
716
  function calculateOffsetForIndex(ctx, state, index) {
739
717
  let position = 0;
740
718
  if (index !== void 0) {
@@ -751,7 +729,7 @@ function calculateOffsetForIndex(ctx, state, index) {
751
729
  return position;
752
730
  }
753
731
 
754
- // src/getItemSize.ts
732
+ // src/utils/getItemSize.ts
755
733
  function getItemSize(state, key, index, data, useAverageSize) {
756
734
  const {
757
735
  sizesKnown,
@@ -780,7 +758,7 @@ function getItemSize(state, key, index, data, useAverageSize) {
780
758
  return size;
781
759
  }
782
760
 
783
- // src/calculateOffsetWithOffsetPosition.ts
761
+ // src/core/calculateOffsetWithOffsetPosition.ts
784
762
  function calculateOffsetWithOffsetPosition(state, offsetParam, params) {
785
763
  const { index, viewOffset, viewPosition } = params;
786
764
  let offset = offsetParam;
@@ -793,338 +771,76 @@ function calculateOffsetWithOffsetPosition(state, offsetParam, params) {
793
771
  return offset;
794
772
  }
795
773
 
796
- // src/checkAllSizesKnown.ts
797
- function checkAllSizesKnown(state) {
798
- const { startBuffered, endBuffered, sizesKnown } = state;
799
- if (endBuffered !== null) {
800
- let areAllKnown = true;
801
- for (let i = startBuffered; areAllKnown && i <= endBuffered; i++) {
802
- const key = getId(state, i);
803
- areAllKnown && (areAllKnown = sizesKnown.has(key));
774
+ // src/utils/requestAdjust.ts
775
+ function requestAdjust(ctx, state, positionDiff) {
776
+ if (Math.abs(positionDiff) > 0.1) {
777
+ const doit = () => {
778
+ state.scrollAdjustHandler.requestAdjust(positionDiff);
779
+ };
780
+ state.scroll += positionDiff;
781
+ state.scrollForNextCalculateItemsInView = void 0;
782
+ const didLayout = peek$(ctx, "containersDidLayout");
783
+ if (didLayout) {
784
+ doit();
785
+ const threshold = state.scroll - positionDiff / 2;
786
+ if (!state.ignoreScrollFromMVCP) {
787
+ state.ignoreScrollFromMVCP = {};
788
+ }
789
+ if (positionDiff > 0) {
790
+ state.ignoreScrollFromMVCP.lt = threshold;
791
+ } else {
792
+ state.ignoreScrollFromMVCP.gt = threshold;
793
+ }
794
+ if (state.ignoreScrollFromMVCPTimeout) {
795
+ clearTimeout(state.ignoreScrollFromMVCPTimeout);
796
+ }
797
+ state.ignoreScrollFromMVCPTimeout = setTimeout(() => {
798
+ state.ignoreScrollFromMVCP = void 0;
799
+ }, 100);
800
+ } else {
801
+ requestAnimationFrame(doit);
804
802
  }
805
- return areAllKnown;
806
803
  }
807
- return false;
808
804
  }
809
805
 
810
- // src/findAvailableContainers.ts
811
- function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffered, pendingRemoval) {
812
- const numContainers = peek$(ctx, "numContainers");
813
- const result = [];
814
- const availableContainers = [];
815
- for (let u = 0; u < numContainers; u++) {
816
- const key = peek$(ctx, `containerItemKey${u}`);
817
- let isOk = key === void 0;
818
- if (!isOk) {
819
- const index = pendingRemoval.indexOf(u);
820
- if (index !== -1) {
821
- pendingRemoval.splice(index, 1);
822
- isOk = true;
823
- }
824
- }
825
- if (isOk) {
826
- result.push(u);
827
- if (result.length >= numNeeded) {
828
- return result;
829
- }
806
+ // src/core/prepareMVCP.ts
807
+ function prepareMVCP(ctx, state) {
808
+ const {
809
+ positions,
810
+ scrollingTo,
811
+ props: { maintainVisibleContentPosition }
812
+ } = state;
813
+ let prevPosition;
814
+ let targetId;
815
+ let targetIndex;
816
+ const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
817
+ if (maintainVisibleContentPosition) {
818
+ const indexByKey = state.indexByKey;
819
+ if (scrollTarget !== void 0) {
820
+ targetId = getId(state, scrollTarget);
821
+ targetIndex = scrollTarget;
822
+ } else if (state.idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
823
+ targetId = state.idsInView.find((id) => indexByKey.get(id) !== void 0);
824
+ targetIndex = indexByKey.get(targetId);
830
825
  }
831
- }
832
- for (let u = 0; u < numContainers; u++) {
833
- const key = peek$(ctx, `containerItemKey${u}`);
834
- if (key === void 0) continue;
835
- const index = state.indexByKey.get(key);
836
- if (index < startBuffered) {
837
- availableContainers.push({ index: u, distance: startBuffered - index });
838
- } else if (index > endBuffered) {
839
- availableContainers.push({ index: u, distance: index - endBuffered });
826
+ if (targetId !== void 0 && targetIndex !== void 0) {
827
+ prevPosition = positions.get(targetId);
840
828
  }
841
829
  }
842
- const remaining = numNeeded - result.length;
843
- if (remaining > 0) {
844
- if (availableContainers.length > 0) {
845
- if (availableContainers.length > remaining) {
846
- availableContainers.sort(comparatorByDistance);
847
- availableContainers.length = remaining;
848
- }
849
- for (const container of availableContainers) {
850
- result.push(container.index);
851
- }
852
- }
853
- const stillNeeded = numNeeded - result.length;
854
- if (stillNeeded > 0) {
855
- for (let i = 0; i < stillNeeded; i++) {
856
- result.push(numContainers + i);
857
- }
858
- if (__DEV__ && numContainers + stillNeeded > peek$(ctx, "numContainersPooled")) {
859
- console.warn(
860
- "[legend-list] No unused container available, so creating one on demand. This can be a minor performance issue and is likely caused by the estimatedItemSize being too large. Consider decreasing estimatedItemSize or increasing initialContainerPoolRatio.",
861
- {
862
- debugInfo: {
863
- numContainers,
864
- numNeeded,
865
- stillNeeded,
866
- numContainersPooled: peek$(ctx, "numContainersPooled")
867
- }
868
- }
869
- );
870
- }
871
- }
872
- }
873
- return result.sort(comparatorDefault);
874
- }
875
- function comparatorByDistance(a, b) {
876
- return b.distance - a.distance;
877
- }
878
-
879
- // src/getScrollVelocity.ts
880
- var getScrollVelocity = (state) => {
881
- const { scrollHistory } = state;
882
- let velocity = 0;
883
- if (scrollHistory.length >= 1) {
884
- const newest = scrollHistory[scrollHistory.length - 1];
885
- let oldest;
886
- let start = 0;
887
- for (let i = 0; i < scrollHistory.length - 1; i++) {
888
- const entry = scrollHistory[i];
889
- const nextEntry = scrollHistory[i + 1];
890
- if (i > 0) {
891
- const prevEntry = scrollHistory[i - 1];
892
- const prevDirection = entry.scroll - prevEntry.scroll;
893
- const currentDirection = nextEntry.scroll - entry.scroll;
894
- if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
895
- start = i;
896
- break;
897
- }
898
- }
899
- }
900
- for (let i = start; i < scrollHistory.length - 1; i++) {
901
- const entry = scrollHistory[i];
902
- if (newest.time - entry.time <= 1e3) {
903
- oldest = entry;
904
- break;
905
- }
906
- }
907
- if (oldest) {
908
- const scrollDiff = newest.scroll - oldest.scroll;
909
- const timeDiff = newest.time - oldest.time;
910
- velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
911
- }
912
- }
913
- return velocity;
914
- };
915
-
916
- // src/requestAdjust.ts
917
- function requestAdjust(ctx, state, positionDiff) {
918
- if (Math.abs(positionDiff) > 0.1) {
919
- const doit = () => {
920
- state.scrollAdjustHandler.requestAdjust(positionDiff);
921
- };
922
- state.scroll += positionDiff;
923
- state.scrollForNextCalculateItemsInView = void 0;
924
- const didLayout = peek$(ctx, "containersDidLayout");
925
- if (didLayout) {
926
- doit();
927
- const threshold = state.scroll - positionDiff / 2;
928
- if (!state.ignoreScrollFromMVCP) {
929
- state.ignoreScrollFromMVCP = {};
930
- }
931
- if (positionDiff > 0) {
932
- state.ignoreScrollFromMVCP.lt = threshold;
933
- } else {
934
- state.ignoreScrollFromMVCP.gt = threshold;
935
- }
936
- if (state.ignoreScrollFromMVCPTimeout) {
937
- clearTimeout(state.ignoreScrollFromMVCPTimeout);
938
- }
939
- state.ignoreScrollFromMVCPTimeout = setTimeout(() => {
940
- state.ignoreScrollFromMVCP = void 0;
941
- }, 100);
942
- } else {
943
- requestAnimationFrame(doit);
944
- }
945
- }
946
- }
947
-
948
- // src/prepareMVCP.ts
949
- function prepareMVCP(ctx, state) {
950
- const {
951
- positions,
952
- scrollingTo,
953
- props: { maintainVisibleContentPosition }
954
- } = state;
955
- let prevPosition;
956
- let targetId;
957
- let targetIndex;
958
- const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
959
- if (maintainVisibleContentPosition) {
960
- const indexByKey = state.indexByKey;
961
- if (scrollTarget !== void 0) {
962
- targetId = getId(state, scrollTarget);
963
- targetIndex = scrollTarget;
964
- } else if (state.idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
965
- targetId = state.idsInView.find((id) => indexByKey.get(id) !== void 0);
966
- targetIndex = indexByKey.get(targetId);
967
- }
968
- if (targetId !== void 0 && targetIndex !== void 0) {
969
- prevPosition = positions.get(targetId);
970
- }
971
- }
972
- return () => {
973
- if (targetId !== void 0 && prevPosition !== void 0) {
974
- const newPosition = positions.get(targetId);
975
- if (newPosition !== void 0) {
976
- const positionDiff = newPosition - prevPosition;
977
- if (Math.abs(positionDiff) > 0.1) {
978
- requestAdjust(ctx, state, positionDiff);
979
- }
830
+ return () => {
831
+ if (targetId !== void 0 && prevPosition !== void 0) {
832
+ const newPosition = positions.get(targetId);
833
+ if (newPosition !== void 0) {
834
+ const positionDiff = newPosition - prevPosition;
835
+ if (Math.abs(positionDiff) > 0.1) {
836
+ requestAdjust(ctx, state, positionDiff);
837
+ }
980
838
  }
981
839
  }
982
840
  };
983
841
  }
984
842
 
985
- // src/checkThreshold.ts
986
- var checkThreshold = (distance, atThreshold, threshold, isReached, isBlockedByTimer, onReached, blockTimer) => {
987
- const distanceAbs = Math.abs(distance);
988
- const isAtThreshold = atThreshold || distanceAbs < threshold;
989
- if (!isReached && !isBlockedByTimer) {
990
- if (isAtThreshold) {
991
- onReached == null ? void 0 : onReached(distance);
992
- blockTimer == null ? void 0 : blockTimer(true);
993
- setTimeout(() => {
994
- blockTimer == null ? void 0 : blockTimer(false);
995
- }, 700);
996
- return true;
997
- }
998
- } else {
999
- if (distance >= 1.3 * threshold) {
1000
- return false;
1001
- }
1002
- }
1003
- return isReached;
1004
- };
1005
-
1006
- // src/checkAtBottom.ts
1007
- function checkAtBottom(ctx, state) {
1008
- if (!state) {
1009
- return;
1010
- }
1011
- const {
1012
- queuedInitialLayout,
1013
- scrollLength,
1014
- scroll,
1015
- maintainingScrollAtEnd,
1016
- props: { maintainScrollAtEndThreshold, onEndReachedThreshold }
1017
- } = state;
1018
- const contentSize = getContentSize(ctx);
1019
- if (contentSize > 0 && queuedInitialLayout && !maintainingScrollAtEnd) {
1020
- const distanceFromEnd = contentSize - scroll - scrollLength;
1021
- const isContentLess = contentSize < scrollLength;
1022
- state.isAtEnd = isContentLess || distanceFromEnd < scrollLength * maintainScrollAtEndThreshold;
1023
- state.isEndReached = checkThreshold(
1024
- distanceFromEnd,
1025
- isContentLess,
1026
- onEndReachedThreshold * scrollLength,
1027
- state.isEndReached,
1028
- state.endReachedBlockedByTimer,
1029
- (distance) => {
1030
- var _a, _b;
1031
- return (_b = (_a = state.props).onEndReached) == null ? void 0 : _b.call(_a, { distanceFromEnd: distance });
1032
- },
1033
- (block) => {
1034
- state.endReachedBlockedByTimer = block;
1035
- }
1036
- );
1037
- }
1038
- }
1039
-
1040
- // src/finishScrollTo.ts
1041
- var finishScrollTo = (state) => {
1042
- if (state) {
1043
- state.scrollingTo = void 0;
1044
- state.scrollHistory.length = 0;
1045
- }
1046
- };
1047
-
1048
- // src/scrollTo.ts
1049
- function scrollTo(state, params = {}) {
1050
- var _a;
1051
- const { animated } = params;
1052
- const {
1053
- refScroller,
1054
- props: { horizontal }
1055
- } = state;
1056
- const offset = calculateOffsetWithOffsetPosition(state, params.offset, params);
1057
- state.scrollHistory.length = 0;
1058
- state.scrollingTo = params;
1059
- state.scrollPending = offset;
1060
- (_a = refScroller.current) == null ? void 0 : _a.scrollTo({
1061
- x: horizontal ? offset : 0,
1062
- y: horizontal ? 0 : offset,
1063
- animated: !!animated
1064
- });
1065
- if (!animated) {
1066
- state.scroll = offset;
1067
- setTimeout(() => finishScrollTo(state), 100);
1068
- }
1069
- }
1070
-
1071
- // src/scrollToIndex.ts
1072
- function scrollToIndex(ctx, state, { index, viewOffset = 0, animated = true, viewPosition }) {
1073
- if (index >= state.props.data.length) {
1074
- index = state.props.data.length - 1;
1075
- } else if (index < 0) {
1076
- index = 0;
1077
- }
1078
- const firstIndexOffset = calculateOffsetForIndex(ctx, state, index);
1079
- const isLast = index === state.props.data.length - 1;
1080
- if (isLast && viewPosition === void 0) {
1081
- viewPosition = 1;
1082
- }
1083
- const firstIndexScrollPostion = firstIndexOffset - viewOffset;
1084
- state.scrollForNextCalculateItemsInView = void 0;
1085
- scrollTo(state, {
1086
- offset: firstIndexScrollPostion,
1087
- animated,
1088
- index,
1089
- viewPosition: viewPosition != null ? viewPosition : 0,
1090
- viewOffset
1091
- });
1092
- }
1093
-
1094
- // src/setDidLayout.ts
1095
- function setDidLayout(ctx, state) {
1096
- const {
1097
- loadStartTime,
1098
- initialScroll,
1099
- props: { onLoad }
1100
- } = state;
1101
- state.queuedInitialLayout = true;
1102
- checkAtBottom(ctx, state);
1103
- if (!IsNewArchitecture && initialScroll) {
1104
- scrollToIndex(ctx, state, { ...initialScroll, animated: false });
1105
- }
1106
- set$(ctx, "containersDidLayout", true);
1107
- if (onLoad) {
1108
- onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
1109
- }
1110
- }
1111
-
1112
- // src/updateSnapToOffsets.ts
1113
- function updateSnapToOffsets(ctx, state) {
1114
- const {
1115
- positions,
1116
- props: { snapToIndices }
1117
- } = state;
1118
- const snapToOffsets = Array(snapToIndices.length);
1119
- for (let i = 0; i < snapToIndices.length; i++) {
1120
- const idx = snapToIndices[i];
1121
- const key = getId(state, idx);
1122
- snapToOffsets[i] = positions.get(key);
1123
- }
1124
- set$(ctx, "snapToOffsets", snapToOffsets);
1125
- }
1126
-
1127
- // src/setPaddingTop.ts
843
+ // src/utils/setPaddingTop.ts
1128
844
  function setPaddingTop(ctx, { stylePaddingTop, alignItemsPaddingTop }) {
1129
845
  if (stylePaddingTop !== void 0) {
1130
846
  const prevStylePaddingTop = peek$(ctx, "stylePaddingTop") || 0;
@@ -1142,7 +858,7 @@ function setPaddingTop(ctx, { stylePaddingTop, alignItemsPaddingTop }) {
1142
858
  }
1143
859
  }
1144
860
 
1145
- // src/updateAlignItemsPaddingTop.ts
861
+ // src/utils/updateAlignItemsPaddingTop.ts
1146
862
  function updateAlignItemsPaddingTop(ctx, state) {
1147
863
  const {
1148
864
  scrollLength,
@@ -1158,7 +874,7 @@ function updateAlignItemsPaddingTop(ctx, state) {
1158
874
  }
1159
875
  }
1160
876
 
1161
- // src/updateTotalSize.ts
877
+ // src/core/updateTotalSize.ts
1162
878
  function updateTotalSize(ctx, state) {
1163
879
  const {
1164
880
  positions,
@@ -1191,7 +907,59 @@ function addTotalSize(ctx, state, key, add) {
1191
907
  }
1192
908
  }
1193
909
 
1194
- // src/updateAllPositions.ts
910
+ // src/utils/getScrollVelocity.ts
911
+ var getScrollVelocity = (state) => {
912
+ const { scrollHistory } = state;
913
+ let velocity = 0;
914
+ if (scrollHistory.length >= 1) {
915
+ const newest = scrollHistory[scrollHistory.length - 1];
916
+ let oldest;
917
+ let start = 0;
918
+ for (let i = 0; i < scrollHistory.length - 1; i++) {
919
+ const entry = scrollHistory[i];
920
+ const nextEntry = scrollHistory[i + 1];
921
+ if (i > 0) {
922
+ const prevEntry = scrollHistory[i - 1];
923
+ const prevDirection = entry.scroll - prevEntry.scroll;
924
+ const currentDirection = nextEntry.scroll - entry.scroll;
925
+ if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
926
+ start = i;
927
+ break;
928
+ }
929
+ }
930
+ }
931
+ for (let i = start; i < scrollHistory.length - 1; i++) {
932
+ const entry = scrollHistory[i];
933
+ if (newest.time - entry.time <= 1e3) {
934
+ oldest = entry;
935
+ break;
936
+ }
937
+ }
938
+ if (oldest) {
939
+ const scrollDiff = newest.scroll - oldest.scroll;
940
+ const timeDiff = newest.time - oldest.time;
941
+ velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
942
+ }
943
+ }
944
+ return velocity;
945
+ };
946
+
947
+ // src/utils/updateSnapToOffsets.ts
948
+ function updateSnapToOffsets(ctx, state) {
949
+ const {
950
+ positions,
951
+ props: { snapToIndices }
952
+ } = state;
953
+ const snapToOffsets = Array(snapToIndices.length);
954
+ for (let i = 0; i < snapToIndices.length; i++) {
955
+ const idx = snapToIndices[i];
956
+ const key = getId(state, idx);
957
+ snapToOffsets[i] = positions.get(key);
958
+ }
959
+ set$(ctx, "snapToOffsets", snapToOffsets);
960
+ }
961
+
962
+ // src/core/updateAllPositions.ts
1195
963
  function updateAllPositions(ctx, state, dataChanged) {
1196
964
  var _a, _b, _c, _d, _e;
1197
965
  const {
@@ -1288,7 +1056,7 @@ function updateAllPositions(ctx, state, dataChanged) {
1288
1056
  }
1289
1057
  }
1290
1058
 
1291
- // src/viewability.ts
1059
+ // src/core/viewability.ts
1292
1060
  var mapViewabilityConfigCallbackPairs = /* @__PURE__ */ new Map();
1293
1061
  function setupViewability(props) {
1294
1062
  let { viewabilityConfig, viewabilityConfigCallbackPairs, onViewableItemsChanged } = props;
@@ -1296,27 +1064,31 @@ function setupViewability(props) {
1296
1064
  viewabilityConfigCallbackPairs = [
1297
1065
  ...viewabilityConfigCallbackPairs || [],
1298
1066
  {
1067
+ onViewableItemsChanged,
1299
1068
  viewabilityConfig: viewabilityConfig || {
1300
1069
  viewAreaCoveragePercentThreshold: 0
1301
- },
1302
- onViewableItemsChanged
1070
+ }
1303
1071
  }
1304
1072
  ];
1305
1073
  }
1306
1074
  if (viewabilityConfigCallbackPairs) {
1307
1075
  for (const pair of viewabilityConfigCallbackPairs) {
1308
1076
  mapViewabilityConfigCallbackPairs.set(pair.viewabilityConfig.id, {
1309
- viewableItems: [],
1310
- start: -1,
1311
1077
  end: -1,
1078
+ previousEnd: -1,
1312
1079
  previousStart: -1,
1313
- previousEnd: -1
1080
+ start: -1,
1081
+ viewableItems: []
1314
1082
  });
1315
1083
  }
1316
1084
  }
1317
1085
  return viewabilityConfigCallbackPairs;
1318
1086
  }
1319
1087
  function updateViewableItems(state, ctx, viewabilityConfigCallbackPairs, scrollSize, start, end) {
1088
+ const {
1089
+ timeouts,
1090
+ props: { data }
1091
+ } = state;
1320
1092
  for (const viewabilityConfigCallbackPair of viewabilityConfigCallbackPairs) {
1321
1093
  const viewabilityState = mapViewabilityConfigCallbackPairs.get(
1322
1094
  viewabilityConfigCallbackPair.viewabilityConfig.id
@@ -1325,12 +1097,12 @@ function updateViewableItems(state, ctx, viewabilityConfigCallbackPairs, scrollS
1325
1097
  viewabilityState.end = end;
1326
1098
  if (viewabilityConfigCallbackPair.viewabilityConfig.minimumViewTime) {
1327
1099
  const timer = setTimeout(() => {
1328
- state.timeouts.delete(timer);
1329
- updateViewableItemsWithConfig(state.data, viewabilityConfigCallbackPair, state, ctx, scrollSize);
1100
+ timeouts.delete(timer);
1101
+ updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, state, ctx, scrollSize);
1330
1102
  }, viewabilityConfigCallbackPair.viewabilityConfig.minimumViewTime);
1331
- state.timeouts.add(timer);
1103
+ timeouts.add(timer);
1332
1104
  } else {
1333
- updateViewableItemsWithConfig(state.data, viewabilityConfigCallbackPair, state, ctx, scrollSize);
1105
+ updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, state, ctx, scrollSize);
1334
1106
  }
1335
1107
  }
1336
1108
  }
@@ -1382,11 +1154,11 @@ function updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, stat
1382
1154
  const containerId = findContainerId(ctx, key);
1383
1155
  if (isViewable(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, i)) {
1384
1156
  const viewToken = {
1385
- item,
1386
- key,
1157
+ containerId,
1387
1158
  index: i,
1388
1159
  isViewable: true,
1389
- containerId
1160
+ item,
1161
+ key
1390
1162
  };
1391
1163
  viewableItems.push(viewToken);
1392
1164
  if (!(previousViewableItems == null ? void 0 : previousViewableItems.find((v) => v.key === viewToken.key))) {
@@ -1396,9 +1168,9 @@ function updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, stat
1396
1168
  }
1397
1169
  }
1398
1170
  Object.assign(viewabilityState, {
1399
- viewableItems,
1171
+ previousEnd: end,
1400
1172
  previousStart: start,
1401
- previousEnd: end
1173
+ viewableItems
1402
1174
  });
1403
1175
  if (changed.length > 0) {
1404
1176
  viewabilityState.viewableItems = viewableItems;
@@ -1407,74 +1179,284 @@ function updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, stat
1407
1179
  maybeUpdateViewabilityCallback(ctx, configId, change.containerId, change);
1408
1180
  }
1409
1181
  if (onViewableItemsChanged) {
1410
- onViewableItemsChanged({ viewableItems, changed });
1182
+ onViewableItemsChanged({ changed, viewableItems });
1183
+ }
1184
+ }
1185
+ for (const [containerId, value] of ctx.mapViewabilityAmountValues) {
1186
+ if (value.sizeVisible < 0) {
1187
+ ctx.mapViewabilityAmountValues.delete(containerId);
1188
+ }
1189
+ }
1190
+ }
1191
+ function computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
1192
+ const { sizes, positions, scroll: scrollState } = state;
1193
+ const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
1194
+ const { itemVisiblePercentThreshold, viewAreaCoveragePercentThreshold } = viewabilityConfig;
1195
+ const viewAreaMode = viewAreaCoveragePercentThreshold != null;
1196
+ const viewablePercentThreshold = viewAreaMode ? viewAreaCoveragePercentThreshold : itemVisiblePercentThreshold;
1197
+ const scroll = scrollState - topPad;
1198
+ const top = positions.get(key) - scroll;
1199
+ const size = sizes.get(key) || 0;
1200
+ const bottom = top + size;
1201
+ const isEntirelyVisible = top >= 0 && bottom <= scrollSize && bottom > top;
1202
+ const sizeVisible = isEntirelyVisible ? size : Math.min(bottom, scrollSize) - Math.max(top, 0);
1203
+ const percentVisible = size ? isEntirelyVisible ? 100 : 100 * (sizeVisible / size) : 0;
1204
+ const percentOfScroller = size ? 100 * (sizeVisible / scrollSize) : 0;
1205
+ const percent = isEntirelyVisible ? 100 : viewAreaMode ? percentOfScroller : percentVisible;
1206
+ const isViewable2 = percent >= viewablePercentThreshold;
1207
+ const value = {
1208
+ containerId,
1209
+ index,
1210
+ isViewable: isViewable2,
1211
+ item,
1212
+ key,
1213
+ percentOfScroller,
1214
+ percentVisible,
1215
+ scrollSize,
1216
+ size,
1217
+ sizeVisible
1218
+ };
1219
+ if (JSON.stringify(value) !== JSON.stringify(ctx.mapViewabilityAmountValues.get(containerId))) {
1220
+ ctx.mapViewabilityAmountValues.set(containerId, value);
1221
+ const cb = ctx.mapViewabilityAmountCallbacks.get(containerId);
1222
+ if (cb) {
1223
+ cb(value);
1224
+ }
1225
+ }
1226
+ return value;
1227
+ }
1228
+ function isViewable(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
1229
+ const value = ctx.mapViewabilityAmountValues.get(containerId) || computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index);
1230
+ return value.isViewable;
1231
+ }
1232
+ function findContainerId(ctx, key) {
1233
+ const numContainers = peek$(ctx, "numContainers");
1234
+ for (let i = 0; i < numContainers; i++) {
1235
+ const itemKey = peek$(ctx, `containerItemKey${i}`);
1236
+ if (itemKey === key) {
1237
+ return i;
1238
+ }
1239
+ }
1240
+ return -1;
1241
+ }
1242
+ function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
1243
+ const key = containerId + configId;
1244
+ ctx.mapViewabilityValues.set(key, viewToken);
1245
+ const cb = ctx.mapViewabilityCallbacks.get(key);
1246
+ cb == null ? void 0 : cb(viewToken);
1247
+ }
1248
+
1249
+ // src/utils/checkAllSizesKnown.ts
1250
+ function checkAllSizesKnown(state) {
1251
+ const { startBuffered, endBuffered, sizesKnown } = state;
1252
+ if (endBuffered !== null) {
1253
+ let areAllKnown = true;
1254
+ for (let i = startBuffered; areAllKnown && i <= endBuffered; i++) {
1255
+ const key = getId(state, i);
1256
+ areAllKnown && (areAllKnown = sizesKnown.has(key));
1257
+ }
1258
+ return areAllKnown;
1259
+ }
1260
+ return false;
1261
+ }
1262
+
1263
+ // src/utils/findAvailableContainers.ts
1264
+ function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffered, pendingRemoval) {
1265
+ const numContainers = peek$(ctx, "numContainers");
1266
+ const result = [];
1267
+ const availableContainers = [];
1268
+ for (let u = 0; u < numContainers; u++) {
1269
+ const key = peek$(ctx, `containerItemKey${u}`);
1270
+ let isOk = key === void 0;
1271
+ if (!isOk) {
1272
+ const index = pendingRemoval.indexOf(u);
1273
+ if (index !== -1) {
1274
+ pendingRemoval.splice(index, 1);
1275
+ isOk = true;
1276
+ }
1277
+ }
1278
+ if (isOk) {
1279
+ result.push(u);
1280
+ if (result.length >= numNeeded) {
1281
+ return result;
1282
+ }
1283
+ }
1284
+ }
1285
+ for (let u = 0; u < numContainers; u++) {
1286
+ const key = peek$(ctx, `containerItemKey${u}`);
1287
+ if (key === void 0) continue;
1288
+ const index = state.indexByKey.get(key);
1289
+ if (index < startBuffered) {
1290
+ availableContainers.push({ distance: startBuffered - index, index: u });
1291
+ } else if (index > endBuffered) {
1292
+ availableContainers.push({ distance: index - endBuffered, index: u });
1411
1293
  }
1412
1294
  }
1413
- for (const [containerId, value] of ctx.mapViewabilityAmountValues) {
1414
- if (value.sizeVisible < 0) {
1415
- ctx.mapViewabilityAmountValues.delete(containerId);
1295
+ const remaining = numNeeded - result.length;
1296
+ if (remaining > 0) {
1297
+ if (availableContainers.length > 0) {
1298
+ if (availableContainers.length > remaining) {
1299
+ availableContainers.sort(comparatorByDistance);
1300
+ availableContainers.length = remaining;
1301
+ }
1302
+ for (const container of availableContainers) {
1303
+ result.push(container.index);
1304
+ }
1305
+ }
1306
+ const stillNeeded = numNeeded - result.length;
1307
+ if (stillNeeded > 0) {
1308
+ for (let i = 0; i < stillNeeded; i++) {
1309
+ result.push(numContainers + i);
1310
+ }
1311
+ if (__DEV__ && numContainers + stillNeeded > peek$(ctx, "numContainersPooled")) {
1312
+ console.warn(
1313
+ "[legend-list] No unused container available, so creating one on demand. This can be a minor performance issue and is likely caused by the estimatedItemSize being too large. Consider decreasing estimatedItemSize or increasing initialContainerPoolRatio.",
1314
+ {
1315
+ debugInfo: {
1316
+ numContainers,
1317
+ numContainersPooled: peek$(ctx, "numContainersPooled"),
1318
+ numNeeded,
1319
+ stillNeeded
1320
+ }
1321
+ }
1322
+ );
1323
+ }
1416
1324
  }
1417
1325
  }
1326
+ return result.sort(comparatorDefault);
1418
1327
  }
1419
- function computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
1420
- const { sizes, positions, scroll: scrollState } = state;
1421
- const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
1422
- const { itemVisiblePercentThreshold, viewAreaCoveragePercentThreshold } = viewabilityConfig;
1423
- const viewAreaMode = viewAreaCoveragePercentThreshold != null;
1424
- const viewablePercentThreshold = viewAreaMode ? viewAreaCoveragePercentThreshold : itemVisiblePercentThreshold;
1425
- const scroll = scrollState - topPad;
1426
- const top = positions.get(key) - scroll;
1427
- const size = sizes.get(key) || 0;
1428
- const bottom = top + size;
1429
- const isEntirelyVisible = top >= 0 && bottom <= scrollSize && bottom > top;
1430
- const sizeVisible = isEntirelyVisible ? size : Math.min(bottom, scrollSize) - Math.max(top, 0);
1431
- const percentVisible = size ? isEntirelyVisible ? 100 : 100 * (sizeVisible / size) : 0;
1432
- const percentOfScroller = size ? 100 * (sizeVisible / scrollSize) : 0;
1433
- const percent = isEntirelyVisible ? 100 : viewAreaMode ? percentOfScroller : percentVisible;
1434
- const isViewable2 = percent >= viewablePercentThreshold;
1435
- const value = {
1436
- index,
1437
- isViewable: isViewable2,
1438
- item,
1439
- key,
1440
- percentVisible,
1441
- percentOfScroller,
1442
- sizeVisible,
1443
- size,
1444
- scrollSize,
1445
- containerId
1446
- };
1447
- if (JSON.stringify(value) !== JSON.stringify(ctx.mapViewabilityAmountValues.get(containerId))) {
1448
- ctx.mapViewabilityAmountValues.set(containerId, value);
1449
- const cb = ctx.mapViewabilityAmountCallbacks.get(containerId);
1450
- if (cb) {
1451
- cb(value);
1452
- }
1328
+ function comparatorByDistance(a, b) {
1329
+ return b.distance - a.distance;
1330
+ }
1331
+
1332
+ // src/core/finishScrollTo.ts
1333
+ var finishScrollTo = (state) => {
1334
+ if (state) {
1335
+ state.scrollingTo = void 0;
1336
+ state.scrollHistory.length = 0;
1337
+ }
1338
+ };
1339
+
1340
+ // src/core/scrollTo.ts
1341
+ function scrollTo(state, params = {}) {
1342
+ var _a;
1343
+ const { animated } = params;
1344
+ const {
1345
+ refScroller,
1346
+ props: { horizontal }
1347
+ } = state;
1348
+ const offset = calculateOffsetWithOffsetPosition(state, params.offset, params);
1349
+ state.scrollHistory.length = 0;
1350
+ state.scrollingTo = params;
1351
+ state.scrollPending = offset;
1352
+ (_a = refScroller.current) == null ? void 0 : _a.scrollTo({
1353
+ animated: !!animated,
1354
+ x: horizontal ? offset : 0,
1355
+ y: horizontal ? 0 : offset
1356
+ });
1357
+ if (!animated) {
1358
+ state.scroll = offset;
1359
+ setTimeout(() => finishScrollTo(state), 100);
1453
1360
  }
1454
- return value;
1455
1361
  }
1456
- function isViewable(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
1457
- const value = ctx.mapViewabilityAmountValues.get(containerId) || computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index);
1458
- return value.isViewable;
1362
+
1363
+ // src/core/scrollToIndex.ts
1364
+ function scrollToIndex(ctx, state, { index, viewOffset = 0, animated = true, viewPosition }) {
1365
+ if (index >= state.props.data.length) {
1366
+ index = state.props.data.length - 1;
1367
+ } else if (index < 0) {
1368
+ index = 0;
1369
+ }
1370
+ const firstIndexOffset = calculateOffsetForIndex(ctx, state, index);
1371
+ const isLast = index === state.props.data.length - 1;
1372
+ if (isLast && viewPosition === void 0) {
1373
+ viewPosition = 1;
1374
+ }
1375
+ const firstIndexScrollPostion = firstIndexOffset - viewOffset;
1376
+ state.scrollForNextCalculateItemsInView = void 0;
1377
+ scrollTo(state, {
1378
+ animated,
1379
+ index,
1380
+ offset: firstIndexScrollPostion,
1381
+ viewOffset,
1382
+ viewPosition: viewPosition != null ? viewPosition : 0
1383
+ });
1459
1384
  }
1460
- function findContainerId(ctx, key) {
1461
- const numContainers = peek$(ctx, "numContainers");
1462
- for (let i = 0; i < numContainers; i++) {
1463
- const itemKey = peek$(ctx, `containerItemKey${i}`);
1464
- if (itemKey === key) {
1465
- return i;
1385
+
1386
+ // src/utils/checkThreshold.ts
1387
+ var checkThreshold = (distance, atThreshold, threshold, isReached, isBlockedByTimer, onReached, blockTimer) => {
1388
+ const distanceAbs = Math.abs(distance);
1389
+ const isAtThreshold = atThreshold || distanceAbs < threshold;
1390
+ if (!isReached && !isBlockedByTimer) {
1391
+ if (isAtThreshold) {
1392
+ onReached == null ? void 0 : onReached(distance);
1393
+ blockTimer == null ? void 0 : blockTimer(true);
1394
+ setTimeout(() => {
1395
+ blockTimer == null ? void 0 : blockTimer(false);
1396
+ }, 700);
1397
+ return true;
1398
+ }
1399
+ } else {
1400
+ if (distance >= 1.3 * threshold) {
1401
+ return false;
1466
1402
  }
1467
1403
  }
1468
- return -1;
1404
+ return isReached;
1405
+ };
1406
+
1407
+ // src/utils/checkAtBottom.ts
1408
+ function checkAtBottom(ctx, state) {
1409
+ if (!state) {
1410
+ return;
1411
+ }
1412
+ const {
1413
+ queuedInitialLayout,
1414
+ scrollLength,
1415
+ scroll,
1416
+ maintainingScrollAtEnd,
1417
+ props: { maintainScrollAtEndThreshold, onEndReachedThreshold }
1418
+ } = state;
1419
+ const contentSize = getContentSize(ctx);
1420
+ if (contentSize > 0 && queuedInitialLayout && !maintainingScrollAtEnd) {
1421
+ const distanceFromEnd = contentSize - scroll - scrollLength;
1422
+ const isContentLess = contentSize < scrollLength;
1423
+ state.isAtEnd = isContentLess || distanceFromEnd < scrollLength * maintainScrollAtEndThreshold;
1424
+ state.isEndReached = checkThreshold(
1425
+ distanceFromEnd,
1426
+ isContentLess,
1427
+ onEndReachedThreshold * scrollLength,
1428
+ state.isEndReached,
1429
+ state.endReachedBlockedByTimer,
1430
+ (distance) => {
1431
+ var _a, _b;
1432
+ return (_b = (_a = state.props).onEndReached) == null ? void 0 : _b.call(_a, { distanceFromEnd: distance });
1433
+ },
1434
+ (block) => {
1435
+ state.endReachedBlockedByTimer = block;
1436
+ }
1437
+ );
1438
+ }
1469
1439
  }
1470
- function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
1471
- const key = containerId + configId;
1472
- ctx.mapViewabilityValues.set(key, viewToken);
1473
- const cb = ctx.mapViewabilityCallbacks.get(key);
1474
- cb == null ? void 0 : cb(viewToken);
1440
+
1441
+ // src/utils/setDidLayout.ts
1442
+ function setDidLayout(ctx, state) {
1443
+ const {
1444
+ loadStartTime,
1445
+ initialScroll,
1446
+ props: { onLoad }
1447
+ } = state;
1448
+ state.queuedInitialLayout = true;
1449
+ checkAtBottom(ctx, state);
1450
+ if (!IsNewArchitecture && initialScroll) {
1451
+ scrollToIndex(ctx, state, { ...initialScroll, animated: false });
1452
+ }
1453
+ set$(ctx, "containersDidLayout", true);
1454
+ if (onLoad) {
1455
+ onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
1456
+ }
1475
1457
  }
1476
1458
 
1477
- // src/calculateItemsInView.ts
1459
+ // src/core/calculateItemsInView.ts
1478
1460
  function calculateItemsInView(ctx, state, params = {}) {
1479
1461
  var _a, _b, _c, _d, _e, _f, _g, _h;
1480
1462
  const {
@@ -1491,7 +1473,8 @@ function calculateItemsInView(ctx, state, params = {}) {
1491
1473
  minIndexSizeChanged
1492
1474
  } = state;
1493
1475
  const data = state.props.data;
1494
- if (!data || scrollLength === 0) {
1476
+ const prevNumContainers = peek$(ctx, "numContainers");
1477
+ if (!data || scrollLength === 0 || !prevNumContainers) {
1495
1478
  return;
1496
1479
  }
1497
1480
  const totalSize = peek$(ctx, "totalSize");
@@ -1573,7 +1556,6 @@ function calculateItemsInView(ctx, state, params = {}) {
1573
1556
  let foundEnd = false;
1574
1557
  let nextTop;
1575
1558
  let nextBottom;
1576
- const prevNumContainers = ctx.values.get("numContainers");
1577
1559
  let maxIndexRendered = 0;
1578
1560
  for (let i = 0; i < prevNumContainers; i++) {
1579
1561
  const key = peek$(ctx, `containerItemKey${i}`);
@@ -1619,18 +1601,18 @@ function calculateItemsInView(ctx, state, params = {}) {
1619
1601
  idsInView.push(id);
1620
1602
  }
1621
1603
  Object.assign(state, {
1622
- startBuffered,
1623
- startBufferedId,
1624
- startNoBuffer,
1625
1604
  endBuffered,
1626
1605
  endNoBuffer,
1606
+ firstFullyOnScreenIndex,
1627
1607
  idsInView,
1628
- firstFullyOnScreenIndex
1608
+ startBuffered,
1609
+ startBufferedId,
1610
+ startNoBuffer
1629
1611
  });
1630
1612
  if (enableScrollForNextCalculateItemsInView && nextTop !== void 0 && nextBottom !== void 0) {
1631
1613
  state.scrollForNextCalculateItemsInView = nextTop !== void 0 && nextBottom !== void 0 ? {
1632
- top: nextTop,
1633
- bottom: nextBottom
1614
+ bottom: nextBottom,
1615
+ top: nextTop
1634
1616
  } : void 0;
1635
1617
  }
1636
1618
  const numContainers = peek$(ctx, "numContainers");
@@ -1718,70 +1700,27 @@ function calculateItemsInView(ctx, state, params = {}) {
1718
1700
  set$(ctx, `containerItemData${i}`, data[itemIndex]);
1719
1701
  }
1720
1702
  }
1721
- }
1722
- }
1723
- }
1724
- if (!queuedInitialLayout && endBuffered !== null) {
1725
- if (checkAllSizesKnown(state)) {
1726
- setDidLayout(ctx, state);
1727
- }
1728
- }
1729
- if (state.props.viewabilityConfigCallbackPairs) {
1730
- updateViewableItems(
1731
- state,
1732
- ctx,
1733
- state.props.viewabilityConfigCallbackPairs,
1734
- scrollLength,
1735
- startNoBuffer,
1736
- endNoBuffer
1737
- );
1738
- }
1739
- }
1740
-
1741
- // src/checkAtTop.ts
1742
- function checkAtTop(state) {
1743
- if (!state) {
1744
- return;
1745
- }
1746
- const {
1747
- scrollLength,
1748
- scroll,
1749
- props: { onStartReachedThreshold }
1750
- } = state;
1751
- const distanceFromTop = scroll;
1752
- state.isAtStart = distanceFromTop <= 0;
1753
- state.isStartReached = checkThreshold(
1754
- distanceFromTop,
1755
- false,
1756
- onStartReachedThreshold * scrollLength,
1757
- state.isStartReached,
1758
- state.startReachedBlockedByTimer,
1759
- (distance) => {
1760
- var _a, _b;
1761
- return (_b = (_a = state.props).onStartReached) == null ? void 0 : _b.call(_a, { distanceFromStart: distance });
1762
- },
1763
- (block) => {
1764
- state.startReachedBlockedByTimer = block;
1765
- }
1766
- );
1767
- }
1768
-
1769
- // src/createColumnWrapperStyle.ts
1770
- function createColumnWrapperStyle(contentContainerStyle) {
1771
- const { gap, columnGap, rowGap } = contentContainerStyle;
1772
- if (gap || columnGap || rowGap) {
1773
- contentContainerStyle.gap = void 0;
1774
- contentContainerStyle.columnGap = void 0;
1775
- contentContainerStyle.rowGap = void 0;
1776
- return {
1777
- gap,
1778
- columnGap,
1779
- rowGap
1780
- };
1703
+ }
1704
+ }
1705
+ }
1706
+ if (!queuedInitialLayout && endBuffered !== null) {
1707
+ if (checkAllSizesKnown(state)) {
1708
+ setDidLayout(ctx, state);
1709
+ }
1710
+ }
1711
+ if (state.props.viewabilityConfigCallbackPairs) {
1712
+ updateViewableItems(
1713
+ state,
1714
+ ctx,
1715
+ state.props.viewabilityConfigCallbackPairs,
1716
+ scrollLength,
1717
+ startNoBuffer,
1718
+ endNoBuffer
1719
+ );
1781
1720
  }
1782
1721
  }
1783
1722
 
1784
- // src/doInitialAllocateContainers.ts
1723
+ // src/core/doInitialAllocateContainers.ts
1785
1724
  function doInitialAllocateContainers(ctx, state) {
1786
1725
  const { scrollLength } = state;
1787
1726
  const data = state.props.data;
@@ -1810,7 +1749,7 @@ function doInitialAllocateContainers(ctx, state) {
1810
1749
  }
1811
1750
  }
1812
1751
 
1813
- // src/doMaintainScrollAtEnd.ts
1752
+ // src/core/doMaintainScrollAtEnd.ts
1814
1753
  function doMaintainScrollAtEnd(ctx, state, animated) {
1815
1754
  const {
1816
1755
  refScroller,
@@ -1837,31 +1776,36 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
1837
1776
  return true;
1838
1777
  }
1839
1778
  }
1840
- function getRenderedItem(ctx, state, key) {
1779
+
1780
+ // src/utils/checkAtTop.ts
1781
+ function checkAtTop(state) {
1841
1782
  if (!state) {
1842
- return null;
1783
+ return;
1843
1784
  }
1844
1785
  const {
1845
- indexByKey,
1846
- props: { data, renderItem: renderItem2 }
1786
+ scrollLength,
1787
+ scroll,
1788
+ props: { onStartReachedThreshold }
1847
1789
  } = state;
1848
- const index = indexByKey.get(key);
1849
- if (index === void 0) {
1850
- return null;
1851
- }
1852
- let renderedItem = null;
1853
- if (renderItem2) {
1854
- const itemProps = {
1855
- item: data[index],
1856
- index,
1857
- extraData: peek$(ctx, "extraData")
1858
- };
1859
- renderedItem = React3__default.createElement(renderItem2, itemProps);
1860
- }
1861
- return { index, item: data[index], renderedItem };
1790
+ const distanceFromTop = scroll;
1791
+ state.isAtStart = distanceFromTop <= 0;
1792
+ state.isStartReached = checkThreshold(
1793
+ distanceFromTop,
1794
+ false,
1795
+ onStartReachedThreshold * scrollLength,
1796
+ state.isStartReached,
1797
+ state.startReachedBlockedByTimer,
1798
+ (distance) => {
1799
+ var _a, _b;
1800
+ return (_b = (_a = state.props).onStartReached) == null ? void 0 : _b.call(_a, { distanceFromStart: distance });
1801
+ },
1802
+ (block) => {
1803
+ state.startReachedBlockedByTimer = block;
1804
+ }
1805
+ );
1862
1806
  }
1863
1807
 
1864
- // src/handleLayout.ts
1808
+ // src/core/handleLayout.ts
1865
1809
  function handleLayout(ctx, state, layout, setCanRender) {
1866
1810
  const { maintainScrollAtEnd } = state.props;
1867
1811
  const scrollLength = layout[state.props.horizontal ? "width" : "height"];
@@ -1879,7 +1823,7 @@ function handleLayout(ctx, state, layout, setCanRender) {
1879
1823
  calculateItemsInView(ctx, state, { doMVCP: true });
1880
1824
  }
1881
1825
  if (didChange || otherAxisSize !== prevOtherAxisSize) {
1882
- set$(ctx, "scrollSize", { width: layout.width, height: layout.height });
1826
+ set$(ctx, "scrollSize", { height: layout.height, width: layout.width });
1883
1827
  }
1884
1828
  if (maintainScrollAtEnd === true || maintainScrollAtEnd.onLayout) {
1885
1829
  doMaintainScrollAtEnd(ctx, state, false);
@@ -1899,7 +1843,7 @@ function handleLayout(ctx, state, layout, setCanRender) {
1899
1843
  setCanRender(true);
1900
1844
  }
1901
1845
 
1902
- // src/onScroll.ts
1846
+ // src/core/onScroll.ts
1903
1847
  function onScroll(ctx, state, event) {
1904
1848
  var _a, _b, _c, _d, _e;
1905
1849
  if (((_b = (_a = event.nativeEvent) == null ? void 0 : _a.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
@@ -1937,7 +1881,29 @@ function updateScroll(ctx, state, newScroll) {
1937
1881
  checkAtTop(state);
1938
1882
  }
1939
1883
 
1940
- // src/updateItemSize.ts
1884
+ // src/core/ScrollAdjustHandler.ts
1885
+ var ScrollAdjustHandler = class {
1886
+ constructor(ctx) {
1887
+ this.appliedAdjust = 0;
1888
+ this.mounted = false;
1889
+ this.context = ctx;
1890
+ }
1891
+ requestAdjust(add) {
1892
+ const oldAdjustTop = peek$(this.context, "scrollAdjust") || 0;
1893
+ this.appliedAdjust = add + oldAdjustTop;
1894
+ const set = () => set$(this.context, "scrollAdjust", this.appliedAdjust);
1895
+ if (this.mounted) {
1896
+ set();
1897
+ } else {
1898
+ requestAnimationFrame(set);
1899
+ }
1900
+ }
1901
+ setMounted() {
1902
+ this.mounted = true;
1903
+ }
1904
+ };
1905
+
1906
+ // src/core/updateItemSize.ts
1941
1907
  function updateItemSizes(ctx, state, itemUpdates) {
1942
1908
  var _a;
1943
1909
  const {
@@ -1951,7 +1917,8 @@ function updateItemSizes(ctx, state, itemUpdates) {
1951
1917
  }
1952
1918
  } = state;
1953
1919
  if (!data) return;
1954
- let needsRecalculate = false;
1920
+ const containersDidLayout = peek$(ctx, "containersDidLayout");
1921
+ let needsRecalculate = !containersDidLayout;
1955
1922
  let shouldMaintainScrollAtEnd = false;
1956
1923
  let minIndexSizeChanged;
1957
1924
  let maxOtherAxisSize = peek$(ctx, "otherAxisSize") || 0;
@@ -1962,7 +1929,7 @@ function updateItemSizes(ctx, state, itemUpdates) {
1962
1929
  const size = Math.floor((horizontal ? sizeObj.width : sizeObj.height) * 8) / 8;
1963
1930
  if (diff !== 0) {
1964
1931
  minIndexSizeChanged = minIndexSizeChanged !== void 0 ? Math.min(minIndexSizeChanged, index) : index;
1965
- if (((_a = state.scrollingTo) == null ? void 0 : _a.viewPosition) && maintainVisibleContentPosition && index === state.scrollingTo.index) {
1932
+ if (((_a = state.scrollingTo) == null ? void 0 : _a.viewPosition) && maintainVisibleContentPosition && index === state.scrollingTo.index && diff > 0) {
1966
1933
  requestAdjust(ctx, state, diff * state.scrollingTo.viewPosition);
1967
1934
  }
1968
1935
  const { startBuffered, endBuffered } = state;
@@ -1984,11 +1951,11 @@ function updateItemSizes(ctx, state, itemUpdates) {
1984
1951
  shouldMaintainScrollAtEnd = true;
1985
1952
  }
1986
1953
  onItemSizeChanged == null ? void 0 : onItemSizeChanged({
1987
- size,
1988
- previous: size - diff,
1989
1954
  index,
1955
+ itemData: state.props.data[index],
1990
1956
  itemKey,
1991
- itemData: state.props.data[index]
1957
+ previous: size - diff,
1958
+ size
1992
1959
  });
1993
1960
  }
1994
1961
  }
@@ -2011,7 +1978,6 @@ function updateItemSizes(ctx, state, itemUpdates) {
2011
1978
  if (!cur || maxOtherAxisSize > cur) {
2012
1979
  set$(ctx, "otherAxisSize", maxOtherAxisSize);
2013
1980
  }
2014
- const containersDidLayout = peek$(ctx, "containersDidLayout");
2015
1981
  if (containersDidLayout || checkAllSizesKnown(state)) {
2016
1982
  if (needsRecalculate) {
2017
1983
  state.scrollForNextCalculateItemsInView = void 0;
@@ -2027,7 +1993,7 @@ function updateItemSizes(ctx, state, itemUpdates) {
2027
1993
  function updateItemSize(ctx, state, itemKey, sizeObj) {
2028
1994
  if (IsNewArchitecture) {
2029
1995
  const { sizesKnown } = state;
2030
- const numContainers = ctx.values.get("numContainers");
1996
+ const numContainers = peek$(ctx, "numContainers");
2031
1997
  const changes = [];
2032
1998
  for (let i = 0; i < numContainers; i++) {
2033
1999
  const containerItemKey = peek$(ctx, `containerItemKey${i}`);
@@ -2038,7 +2004,7 @@ function updateItemSize(ctx, state, itemKey, sizeObj) {
2038
2004
  if (containerRef == null ? void 0 : containerRef.current) {
2039
2005
  let measured;
2040
2006
  containerRef.current.measure((x, y, width, height) => {
2041
- measured = { x, y, width, height };
2007
+ measured = { height, width, x, y };
2042
2008
  });
2043
2009
  if (measured) {
2044
2010
  changes.push({ itemKey: containerItemKey, sizeObj: measured });
@@ -2069,7 +2035,7 @@ function updateOneItemSize(state, itemKey, sizeObj) {
2069
2035
  const itemType = "";
2070
2036
  let averages = averageSizes[itemType];
2071
2037
  if (!averages) {
2072
- averages = averageSizes[itemType] = { num: 0, avg: 0 };
2038
+ averages = averageSizes[itemType] = { avg: 0, num: 0 };
2073
2039
  }
2074
2040
  averages.avg = (averages.avg * averages.num + size) / (averages.num + 1);
2075
2041
  averages.num++;
@@ -2095,7 +2061,45 @@ var useCombinedRef = (...refs) => {
2095
2061
  return callback;
2096
2062
  };
2097
2063
 
2098
- // src/LegendList.tsx
2064
+ // src/utils/createColumnWrapperStyle.ts
2065
+ function createColumnWrapperStyle(contentContainerStyle) {
2066
+ const { gap, columnGap, rowGap } = contentContainerStyle;
2067
+ if (gap || columnGap || rowGap) {
2068
+ contentContainerStyle.gap = void 0;
2069
+ contentContainerStyle.columnGap = void 0;
2070
+ contentContainerStyle.rowGap = void 0;
2071
+ return {
2072
+ columnGap,
2073
+ gap,
2074
+ rowGap
2075
+ };
2076
+ }
2077
+ }
2078
+ function getRenderedItem(ctx, state, key) {
2079
+ if (!state) {
2080
+ return null;
2081
+ }
2082
+ const {
2083
+ indexByKey,
2084
+ props: { data, renderItem: renderItem2 }
2085
+ } = state;
2086
+ const index = indexByKey.get(key);
2087
+ if (index === void 0) {
2088
+ return null;
2089
+ }
2090
+ let renderedItem = null;
2091
+ if (renderItem2) {
2092
+ const itemProps = {
2093
+ extraData: peek$(ctx, "extraData"),
2094
+ index,
2095
+ item: data[index]
2096
+ };
2097
+ renderedItem = React3__default.createElement(renderItem2, itemProps);
2098
+ }
2099
+ return { index, item: data[index], renderedItem };
2100
+ }
2101
+
2102
+ // src/components/LegendList.tsx
2099
2103
  var DEFAULT_DRAW_DISTANCE = 250;
2100
2104
  var DEFAULT_ITEM_SIZE = 100;
2101
2105
  var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
@@ -2163,55 +2167,55 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2163
2167
  const combinedRef = useCombinedRef(refScroller, refScrollView);
2164
2168
  const estimatedItemSize = estimatedItemSizeProp != null ? estimatedItemSizeProp : DEFAULT_ITEM_SIZE;
2165
2169
  const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
2166
- const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (item, index) => index.toString();
2170
+ const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (_item, index) => index.toString();
2167
2171
  const refState = useRef();
2168
2172
  if (!refState.current) {
2169
- const initialScrollLength = (estimatedListSize != null ? estimatedListSize : IsNewArchitecture ? { width: 0, height: 0 } : Dimensions.get("window"))[horizontal ? "width" : "height"];
2173
+ const initialScrollLength = (estimatedListSize != null ? estimatedListSize : IsNewArchitecture ? { height: 0, width: 0 } : Dimensions.get("window"))[horizontal ? "width" : "height"];
2170
2174
  refState.current = {
2171
- sizes: /* @__PURE__ */ new Map(),
2172
- positions: /* @__PURE__ */ new Map(),
2175
+ averageSizes: {},
2173
2176
  columns: /* @__PURE__ */ new Map(),
2174
- pendingAdjust: 0,
2175
- isStartReached: false,
2176
- isEndReached: false,
2177
- isAtEnd: false,
2178
- isAtStart: false,
2179
- scrollLength: initialScrollLength,
2180
- startBuffered: -1,
2181
- startNoBuffer: -1,
2177
+ containerItemKeys: /* @__PURE__ */ new Set(),
2178
+ enableScrollForNextCalculateItemsInView: true,
2182
2179
  endBuffered: -1,
2183
2180
  endNoBuffer: -1,
2181
+ endReachedBlockedByTimer: false,
2184
2182
  firstFullyOnScreenIndex: -1,
2183
+ idCache: /* @__PURE__ */ new Map(),
2184
+ idsInView: [],
2185
+ indexByKey: /* @__PURE__ */ new Map(),
2186
+ initialScroll,
2187
+ isAtEnd: false,
2188
+ isAtStart: false,
2189
+ isEndReached: false,
2190
+ isStartReached: false,
2191
+ lastBatchingAction: Date.now(),
2192
+ lastLayout: void 0,
2193
+ loadStartTime: Date.now(),
2194
+ minIndexSizeChanged: 0,
2195
+ nativeMarginTop: 0,
2196
+ pendingAdjust: 0,
2197
+ positions: /* @__PURE__ */ new Map(),
2198
+ props: {},
2199
+ queuedCalculateItemsInView: 0,
2200
+ refScroller: void 0,
2185
2201
  scroll: 0,
2186
- totalSize: 0,
2187
- timeouts: /* @__PURE__ */ new Set(),
2188
- viewabilityConfigCallbackPairs: void 0,
2189
2202
  scrollAdjustHandler: new ScrollAdjustHandler(ctx),
2190
- nativeMarginTop: 0,
2203
+ scrollForNextCalculateItemsInView: void 0,
2204
+ scrollHistory: [],
2205
+ scrollLength: initialScrollLength,
2206
+ scrollPending: 0,
2191
2207
  scrollPrev: 0,
2192
2208
  scrollPrevTime: 0,
2193
2209
  scrollTime: 0,
2194
- scrollPending: 0,
2195
- indexByKey: /* @__PURE__ */ new Map(),
2196
- scrollHistory: [],
2210
+ sizes: /* @__PURE__ */ new Map(),
2197
2211
  sizesKnown: /* @__PURE__ */ new Map(),
2198
- timeoutSizeMessage: 0,
2212
+ startBuffered: -1,
2213
+ startNoBuffer: -1,
2199
2214
  startReachedBlockedByTimer: false,
2200
- endReachedBlockedByTimer: false,
2201
- scrollForNextCalculateItemsInView: void 0,
2202
- enableScrollForNextCalculateItemsInView: true,
2203
- minIndexSizeChanged: 0,
2204
- queuedCalculateItemsInView: 0,
2205
- lastBatchingAction: Date.now(),
2206
- averageSizes: {},
2207
- idsInView: [],
2208
- containerItemKeys: /* @__PURE__ */ new Set(),
2209
- idCache: /* @__PURE__ */ new Map(),
2210
- props: {},
2211
- refScroller: void 0,
2212
- loadStartTime: Date.now(),
2213
- initialScroll,
2214
- lastLayout: void 0
2215
+ timeoutSizeMessage: 0,
2216
+ timeouts: /* @__PURE__ */ new Set(),
2217
+ totalSize: 0,
2218
+ viewabilityConfigCallbackPairs: void 0
2215
2219
  };
2216
2220
  set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPosition);
2217
2221
  set$(ctx, "extraData", extraData);
@@ -2223,29 +2227,29 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2223
2227
  alignItemsAtEnd,
2224
2228
  data: dataProp,
2225
2229
  estimatedItemSize,
2230
+ getEstimatedItemSize,
2231
+ horizontal: !!horizontal,
2232
+ initialContainerPoolRatio,
2233
+ initialScroll,
2234
+ keyExtractor,
2226
2235
  maintainScrollAtEnd,
2227
2236
  maintainScrollAtEndThreshold,
2228
- onEndReachedThreshold,
2229
- onStartReachedThreshold,
2230
- stylePaddingBottom: stylePaddingBottomState,
2231
- horizontal: !!horizontal,
2232
2237
  maintainVisibleContentPosition,
2238
+ numColumns: numColumnsProp,
2239
+ onEndReached,
2240
+ onEndReachedThreshold,
2233
2241
  onItemSizeChanged,
2234
- suggestEstimatedItemSize: !!suggestEstimatedItemSize,
2235
- keyExtractor,
2242
+ onLoad,
2236
2243
  onScroll: onScrollProp,
2237
- getEstimatedItemSize,
2238
2244
  onStartReached,
2239
- onEndReached,
2240
- onLoad,
2245
+ onStartReachedThreshold,
2241
2246
  renderItem: renderItem2,
2242
- initialScroll,
2243
2247
  scrollBuffer,
2244
- viewabilityConfigCallbackPairs: void 0,
2245
- numColumns: numColumnsProp,
2246
- initialContainerPoolRatio,
2248
+ snapToIndices,
2249
+ stylePaddingBottom: stylePaddingBottomState,
2247
2250
  stylePaddingTop: stylePaddingTopState,
2248
- snapToIndices
2251
+ suggestEstimatedItemSize: !!suggestEstimatedItemSize,
2252
+ viewabilityConfigCallbackPairs: void 0
2249
2253
  };
2250
2254
  state.refScroller = refScroller;
2251
2255
  const checkResetContainers = (isFirst2) => {
@@ -2293,7 +2297,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2293
2297
  const initialContentOffset2 = initialScrollOffset || calculateOffsetForIndex(ctx, state, initialScrollIndex);
2294
2298
  refState.current.isStartReached = initialContentOffset2 < refState.current.scrollLength * onStartReachedThreshold;
2295
2299
  if (initialContentOffset2 > 0) {
2296
- scrollTo(state, { offset: initialContentOffset2, animated: false, index: initialScrollIndex });
2300
+ scrollTo(state, { animated: false, index: initialScrollIndex, offset: initialContentOffset2 });
2297
2301
  }
2298
2302
  return initialContentOffset2;
2299
2303
  }, [renderNum]);
@@ -2312,7 +2316,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2312
2316
  if (IsNewArchitecture) {
2313
2317
  let measured;
2314
2318
  refScroller.current.measure((x, y, width, height) => {
2315
- measured = { x, y, width, height };
2319
+ measured = { height, width, x, y };
2316
2320
  });
2317
2321
  if (measured) {
2318
2322
  const size = Math.floor(measured[horizontal ? "width" : "height"] * 8) / 8;
@@ -2368,9 +2372,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2368
2372
  };
2369
2373
  useEffect(() => {
2370
2374
  const viewability = setupViewability({
2375
+ onViewableItemsChanged,
2371
2376
  viewabilityConfig,
2372
- viewabilityConfigCallbackPairs,
2373
- onViewableItemsChanged
2377
+ viewabilityConfigCallbackPairs
2374
2378
  });
2375
2379
  state.viewabilityConfigCallbackPairs = viewability;
2376
2380
  state.props.viewabilityConfigCallbackPairs = viewability;
@@ -2388,98 +2392,94 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2388
2392
  onLayoutProp(event);
2389
2393
  }
2390
2394
  }, []);
2391
- useImperativeHandle(
2392
- forwardedRef,
2393
- () => {
2394
- const scrollIndexIntoView = (options) => {
2395
+ useImperativeHandle(forwardedRef, () => {
2396
+ const scrollIndexIntoView = (options) => {
2397
+ const state2 = refState.current;
2398
+ if (state2) {
2399
+ const { index, ...rest2 } = options;
2400
+ const { startNoBuffer, endNoBuffer } = state2;
2401
+ if (index < startNoBuffer || index > endNoBuffer) {
2402
+ const viewPosition = index < startNoBuffer ? 0 : 1;
2403
+ scrollToIndex(ctx, state2, {
2404
+ ...rest2,
2405
+ index,
2406
+ viewPosition
2407
+ });
2408
+ }
2409
+ }
2410
+ };
2411
+ return {
2412
+ flashScrollIndicators: () => refScroller.current.flashScrollIndicators(),
2413
+ getNativeScrollRef: () => refScroller.current,
2414
+ getScrollableNode: () => refScroller.current.getScrollableNode(),
2415
+ getScrollResponder: () => refScroller.current.getScrollResponder(),
2416
+ getState: () => {
2395
2417
  const state2 = refState.current;
2396
- if (state2) {
2397
- const { index, ...rest2 } = options;
2398
- const { startNoBuffer, endNoBuffer } = state2;
2399
- if (index < startNoBuffer || index > endNoBuffer) {
2400
- const viewPosition = index < startNoBuffer ? 0 : 1;
2401
- scrollToIndex(ctx, state2, {
2402
- ...rest2,
2403
- viewPosition,
2404
- index
2405
- });
2406
- }
2418
+ return state2 ? {
2419
+ contentLength: state2.totalSize,
2420
+ end: state2.endNoBuffer,
2421
+ endBuffered: state2.endBuffered,
2422
+ isAtEnd: state2.isAtEnd,
2423
+ isAtStart: state2.isAtStart,
2424
+ positions: state2.positions,
2425
+ scroll: state2.scroll,
2426
+ scrollLength: state2.scrollLength,
2427
+ sizeAtIndex: (index) => state2.sizesKnown.get(getId(state2, index)),
2428
+ sizes: state2.sizesKnown,
2429
+ start: state2.startNoBuffer,
2430
+ startBuffered: state2.startBuffered
2431
+ } : {};
2432
+ },
2433
+ scrollIndexIntoView,
2434
+ scrollItemIntoView: ({ item, ...props2 }) => {
2435
+ const data = refState.current.props.data;
2436
+ const index = data.indexOf(item);
2437
+ if (index !== -1) {
2438
+ scrollIndexIntoView({ index, ...props2 });
2407
2439
  }
2408
- };
2409
- return {
2410
- flashScrollIndicators: () => refScroller.current.flashScrollIndicators(),
2411
- getNativeScrollRef: () => refScroller.current,
2412
- getScrollableNode: () => refScroller.current.getScrollableNode(),
2413
- getScrollResponder: () => refScroller.current.getScrollResponder(),
2414
- getState: () => {
2415
- const state2 = refState.current;
2416
- return state2 ? {
2417
- contentLength: state2.totalSize,
2418
- end: state2.endNoBuffer,
2419
- endBuffered: state2.endBuffered,
2420
- isAtEnd: state2.isAtEnd,
2421
- isAtStart: state2.isAtStart,
2422
- positions: state2.positions,
2423
- scroll: state2.scroll,
2424
- scrollLength: state2.scrollLength,
2425
- start: state2.startNoBuffer,
2426
- startBuffered: state2.startBuffered,
2427
- sizes: state2.sizesKnown,
2428
- sizeAtIndex: (index) => state2.sizesKnown.get(getId(state2, index))
2429
- } : {};
2430
- },
2431
- scrollIndexIntoView,
2432
- scrollItemIntoView: ({ item, ...props2 }) => {
2433
- const data = refState.current.props.data;
2434
- const index = data.indexOf(item);
2435
- if (index !== -1) {
2436
- scrollIndexIntoView({ index, ...props2 });
2437
- }
2438
- },
2439
- scrollToIndex: (params) => scrollToIndex(ctx, state, params),
2440
- scrollToItem: ({ item, ...props2 }) => {
2441
- const data = refState.current.props.data;
2442
- const index = data.indexOf(item);
2443
- if (index !== -1) {
2444
- scrollToIndex(ctx, state, { index, ...props2 });
2445
- }
2446
- },
2447
- scrollToOffset: (params) => scrollTo(state, params),
2448
- scrollToEnd: (options) => {
2449
- const data = refState.current.props.data;
2450
- const stylePaddingBottom = refState.current.props.stylePaddingBottom;
2451
- const index = data.length - 1;
2452
- if (index !== -1) {
2453
- const paddingBottom = stylePaddingBottom || 0;
2454
- const footerSize = peek$(ctx, "footerSize") || 0;
2455
- scrollToIndex(ctx, state, {
2456
- index,
2457
- viewPosition: 1,
2458
- viewOffset: -paddingBottom - footerSize,
2459
- ...options
2460
- });
2461
- }
2462
- },
2463
- setVisibleContentAnchorOffset: (value) => {
2464
- const val = typeof value === "function" ? value(peek$(ctx, "scrollAdjustUserOffset") || 0) : value;
2465
- set$(ctx, "scrollAdjustUserOffset", val);
2440
+ },
2441
+ scrollToEnd: (options) => {
2442
+ const data = refState.current.props.data;
2443
+ const stylePaddingBottom = refState.current.props.stylePaddingBottom;
2444
+ const index = data.length - 1;
2445
+ if (index !== -1) {
2446
+ const paddingBottom = stylePaddingBottom || 0;
2447
+ const footerSize = peek$(ctx, "footerSize") || 0;
2448
+ scrollToIndex(ctx, state, {
2449
+ index,
2450
+ viewOffset: -paddingBottom - footerSize,
2451
+ viewPosition: 1,
2452
+ ...options
2453
+ });
2466
2454
  }
2467
- };
2468
- },
2469
- []
2470
- );
2455
+ },
2456
+ scrollToIndex: (params) => scrollToIndex(ctx, state, params),
2457
+ scrollToItem: ({ item, ...props2 }) => {
2458
+ const data = refState.current.props.data;
2459
+ const index = data.indexOf(item);
2460
+ if (index !== -1) {
2461
+ scrollToIndex(ctx, state, { index, ...props2 });
2462
+ }
2463
+ },
2464
+ scrollToOffset: (params) => scrollTo(state, params),
2465
+ setVisibleContentAnchorOffset: (value) => {
2466
+ const val = typeof value === "function" ? value(peek$(ctx, "scrollAdjustUserOffset") || 0) : value;
2467
+ set$(ctx, "scrollAdjustUserOffset", val);
2468
+ }
2469
+ };
2470
+ }, []);
2471
2471
  if (Platform.OS === "web") {
2472
2472
  useEffect(() => {
2473
2473
  if (initialContentOffset) {
2474
- scrollTo(state, { offset: initialContentOffset, animated: false });
2474
+ scrollTo(state, { animated: false, offset: initialContentOffset });
2475
2475
  }
2476
2476
  }, []);
2477
2477
  }
2478
2478
  const fns = useMemo(
2479
2479
  () => ({
2480
- updateItemSize: (itemKey, sizeObj) => updateItemSize(ctx, state, itemKey, sizeObj),
2481
2480
  getRenderedItem: (key) => getRenderedItem(ctx, state, key),
2482
- onScroll: (event) => onScroll(ctx, state, event)
2481
+ onScroll: (event) => onScroll(ctx, state, event),
2482
+ updateItemSize: (itemKey, sizeObj) => updateItemSize(ctx, state, itemKey, sizeObj)
2483
2483
  }),
2484
2484
  []
2485
2485
  );
@@ -2487,13 +2487,17 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2487
2487
  ListComponent,
2488
2488
  {
2489
2489
  ...rest,
2490
+ alignItemsAtEnd,
2490
2491
  canRender,
2492
+ contentContainerStyle,
2493
+ getRenderedItem: fns.getRenderedItem,
2491
2494
  horizontal,
2492
- refScrollView: combinedRef,
2493
2495
  initialContentOffset,
2494
- getRenderedItem: fns.getRenderedItem,
2495
- updateItemSize: fns.updateItemSize,
2496
- onScroll: fns.onScroll,
2496
+ ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
2497
+ ListHeaderComponent,
2498
+ maintainVisibleContentPosition,
2499
+ onLayout,
2500
+ onLayoutHeader,
2497
2501
  onMomentumScrollEnd: (event) => {
2498
2502
  requestAnimationFrame(() => {
2499
2503
  finishScrollTo(refState.current);
@@ -2502,32 +2506,30 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2502
2506
  onMomentumScrollEnd(event);
2503
2507
  }
2504
2508
  },
2505
- onLayout,
2509
+ onScroll: fns.onScroll,
2506
2510
  recycleItems,
2507
- alignItemsAtEnd,
2508
- ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
2509
- ListHeaderComponent,
2510
- maintainVisibleContentPosition,
2511
- scrollEventThrottle: Platform.OS === "web" ? 16 : void 0,
2512
- waitForInitialLayout,
2513
2511
  refreshControl: refreshControl ? stylePaddingTopState > 0 ? React3.cloneElement(refreshControl, {
2514
2512
  progressViewOffset: (refreshControl.props.progressViewOffset || 0) + stylePaddingTopState
2515
2513
  }) : refreshControl : onRefresh && /* @__PURE__ */ React3.createElement(
2516
2514
  RefreshControl,
2517
2515
  {
2518
- refreshing: !!refreshing,
2519
2516
  onRefresh,
2520
- progressViewOffset: (progressViewOffset || 0) + stylePaddingTopState
2517
+ progressViewOffset: (progressViewOffset || 0) + stylePaddingTopState,
2518
+ refreshing: !!refreshing
2521
2519
  }
2522
2520
  ),
2523
- style,
2524
- contentContainerStyle,
2521
+ refScrollView: combinedRef,
2525
2522
  scrollAdjustHandler: (_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler,
2526
- onLayoutHeader,
2527
- snapToIndices
2523
+ scrollEventThrottle: Platform.OS === "web" ? 16 : void 0,
2524
+ snapToIndices,
2525
+ style,
2526
+ updateItemSize: fns.updateItemSize,
2527
+ waitForInitialLayout
2528
2528
  }
2529
2529
  ), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React3.createElement(DebugView, { state: refState.current }));
2530
2530
  });
2531
+
2532
+ // src/components/LazyLegendList.tsx
2531
2533
  var typedForwardRef2 = forwardRef;
2532
2534
  var renderItem = ({ item }) => item;
2533
2535
  var LazyLegendList = typedForwardRef2(function LazyLegendList2(props, forwardedRef) {
@@ -2536,7 +2538,7 @@ var LazyLegendList = typedForwardRef2(function LazyLegendList2(props, forwardedR
2536
2538
  const data = (isArray(children) ? children : React3.Children.toArray(children)).flat(1);
2537
2539
  return (
2538
2540
  // @ts-expect-error TODO: Fix this type
2539
- /* @__PURE__ */ React3.createElement(LegendListComponent, { ...rest, data, renderItem, ref: forwardedRef })
2541
+ /* @__PURE__ */ React3.createElement(LegendListComponent, { ...rest, data, ref: forwardedRef, renderItem })
2540
2542
  );
2541
2543
  });
2542
2544