@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.js CHANGED
@@ -24,21 +24,22 @@ function _interopNamespace(e) {
24
24
 
25
25
  var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
26
26
 
27
- // src/LegendList.tsx
27
+ // src/components/LazyLegendList.tsx
28
28
  var ContextState = React3__namespace.createContext(null);
29
29
  function StateProvider({ children }) {
30
30
  const [value] = React3__namespace.useState(() => ({
31
+ columnWrapperStyle: void 0,
31
32
  listeners: /* @__PURE__ */ new Map(),
33
+ mapViewabilityAmountCallbacks: /* @__PURE__ */ new Map(),
34
+ mapViewabilityAmountValues: /* @__PURE__ */ new Map(),
35
+ mapViewabilityCallbacks: /* @__PURE__ */ new Map(),
36
+ mapViewabilityValues: /* @__PURE__ */ new Map(),
32
37
  values: /* @__PURE__ */ new Map([
33
38
  ["alignItemsPaddingTop", 0],
34
39
  ["stylePaddingTop", 0],
35
- ["headerSize", 0]
40
+ ["headerSize", 0],
41
+ ["numContainers", 0]
36
42
  ]),
37
- mapViewabilityCallbacks: /* @__PURE__ */ new Map(),
38
- mapViewabilityValues: /* @__PURE__ */ new Map(),
39
- mapViewabilityAmountCallbacks: /* @__PURE__ */ new Map(),
40
- mapViewabilityAmountValues: /* @__PURE__ */ new Map(),
41
- columnWrapperStyle: void 0,
42
43
  viewRefs: /* @__PURE__ */ new Map()
43
44
  }));
44
45
  return /* @__PURE__ */ React3__namespace.createElement(ContextState.Provider, { value }, children);
@@ -50,17 +51,6 @@ function createSelectorFunctionsArr(ctx, signalNames) {
50
51
  let lastValues = [];
51
52
  let lastSignalValues = [];
52
53
  return {
53
- subscribe: (cb) => {
54
- const listeners = [];
55
- for (const signalName of signalNames) {
56
- listeners.push(listen$(ctx, signalName, cb));
57
- }
58
- return () => {
59
- for (const listener of listeners) {
60
- listener();
61
- }
62
- };
63
- },
64
54
  get: () => {
65
55
  const currentValues = [];
66
56
  let hasChanged = false;
@@ -76,6 +66,17 @@ function createSelectorFunctionsArr(ctx, signalNames) {
76
66
  lastValues = currentValues;
77
67
  }
78
68
  return lastValues;
69
+ },
70
+ subscribe: (cb) => {
71
+ const listeners = [];
72
+ for (const signalName of signalNames) {
73
+ listeners.push(listen$(ctx, signalName, cb));
74
+ }
75
+ return () => {
76
+ for (const listener of listeners) {
77
+ listener();
78
+ }
79
+ };
79
80
  }
80
81
  };
81
82
  }
@@ -126,13 +127,13 @@ function useSelector$(signalName, selector) {
126
127
  return value;
127
128
  }
128
129
 
129
- // src/DebugView.tsx
130
+ // src/components/DebugView.tsx
130
131
  var DebugRow = ({ children }) => {
131
- return /* @__PURE__ */ React3__namespace.createElement(reactNative.View, { style: { flexDirection: "row", alignItems: "center", justifyContent: "space-between" } }, children);
132
+ return /* @__PURE__ */ React3__namespace.createElement(reactNative.View, { style: { alignItems: "center", flexDirection: "row", justifyContent: "space-between" } }, children);
132
133
  };
133
134
  var DebugView = React3__namespace.memo(function DebugView2({ state }) {
134
135
  const ctx = useStateContext();
135
- const [totalSize = 0, scrollAdjust = 0, rawScroll = 0, scroll = 0, numContainers = 0, numContainersPooled = 0] = useArr$([
136
+ const [totalSize = 0, scrollAdjust = 0, rawScroll = 0, scroll = 0, _numContainers = 0, _numContainersPooled = 0] = useArr$([
136
137
  "totalSize",
137
138
  "scrollAdjust",
138
139
  "debugRawScroll",
@@ -148,18 +149,18 @@ var DebugView = React3__namespace.memo(function DebugView2({ state }) {
148
149
  return /* @__PURE__ */ React3__namespace.createElement(
149
150
  reactNative.View,
150
151
  {
152
+ pointerEvents: "none",
151
153
  style: {
152
- position: "absolute",
153
- top: 0,
154
- right: 0,
155
- paddingLeft: 4,
156
- paddingBottom: 4,
157
154
  // height: 100,
158
155
  backgroundColor: "#FFFFFFCC",
156
+ borderRadius: 4,
159
157
  padding: 4,
160
- borderRadius: 4
161
- },
162
- pointerEvents: "none"
158
+ paddingBottom: 4,
159
+ paddingLeft: 4,
160
+ position: "absolute",
161
+ right: 0,
162
+ top: 0
163
+ }
163
164
  },
164
165
  /* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, "TotalSize:"), /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, totalSize.toFixed(2))),
165
166
  /* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, "ContentSize:"), /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, contentSize.toFixed(2))),
@@ -177,8 +178,34 @@ function useInterval(callback, delay) {
177
178
  return () => clearInterval(interval);
178
179
  }, [delay]);
179
180
  }
181
+ var LeanViewComponent = React3__namespace.forwardRef((props, ref) => {
182
+ return React3__namespace.createElement("RCTView", { ...props, ref });
183
+ });
184
+ LeanViewComponent.displayName = "RCTView";
185
+ var LeanView = reactNative.Platform.OS === "android" || reactNative.Platform.OS === "ios" ? LeanViewComponent : reactNative.View;
186
+
187
+ // src/components/Separator.tsx
188
+ function Separator({ ItemSeparatorComponent, itemKey, leadingItem }) {
189
+ const [lastItemKeys] = useArr$(["lastItemKeys"]);
190
+ const isALastItem = lastItemKeys.includes(itemKey);
191
+ return isALastItem ? null : /* @__PURE__ */ React.createElement(ItemSeparatorComponent, { leadingItem });
192
+ }
193
+
194
+ // src/constants.ts
195
+ var POSITION_OUT_OF_VIEW = -1e7;
196
+ var ENABLE_DEVMODE = __DEV__ && false;
197
+ var ENABLE_DEBUG_VIEW = __DEV__ && false;
198
+ var IsNewArchitecture = global.nativeFabricUIManager != null;
199
+ var symbolFirst = Symbol();
200
+ function useInit(cb) {
201
+ const refValue = React3.useRef(symbolFirst);
202
+ if (refValue.current === symbolFirst) {
203
+ refValue.current = cb();
204
+ }
205
+ return refValue.current;
206
+ }
180
207
 
181
- // src/helpers.ts
208
+ // src/utils/helpers.ts
182
209
  function isFunction(obj) {
183
210
  return typeof obj === "function";
184
211
  }
@@ -208,16 +235,8 @@ function getPadding(s, type) {
208
235
  function extractPadding(style, contentContainerStyle, type) {
209
236
  return getPadding(style, type) + getPadding(contentContainerStyle, type);
210
237
  }
211
- var symbolFirst = Symbol();
212
- function useInit(cb) {
213
- const refValue = React3.useRef(symbolFirst);
214
- if (refValue.current === symbolFirst) {
215
- refValue.current = cb();
216
- }
217
- return refValue.current;
218
- }
219
238
 
220
- // src/ContextContainer.ts
239
+ // src/state/ContextContainer.ts
221
240
  var ContextContainer = React3.createContext(null);
222
241
  function useViewability(callback, configId) {
223
242
  const ctx = useStateContext();
@@ -261,7 +280,7 @@ function useRecyclingEffect(effect) {
261
280
  prevItem: void 0
262
281
  });
263
282
  React3.useEffect(() => {
264
- let ret = void 0;
283
+ let ret;
265
284
  if (prevValues.current.prevIndex !== void 0 && prevValues.current.prevItem !== void 0) {
266
285
  ret = effect({
267
286
  index,
@@ -275,7 +294,7 @@ function useRecyclingEffect(effect) {
275
294
  prevItem: value
276
295
  };
277
296
  return ret;
278
- }, [index, value]);
297
+ }, [index, value, effect]);
279
298
  }
280
299
  function useRecyclingState(valueOrFun) {
281
300
  const { index, value, itemKey, triggerLayout } = React3.useContext(ContextContainer);
@@ -313,26 +332,8 @@ function useListScrollSize() {
313
332
  const [scrollSize] = useArr$(["scrollSize"]);
314
333
  return scrollSize;
315
334
  }
316
- var LeanViewComponent = React3__namespace.forwardRef((props, ref) => {
317
- return React3__namespace.createElement("RCTView", { ...props, ref });
318
- });
319
- LeanViewComponent.displayName = "RCTView";
320
- var LeanView = reactNative.Platform.OS === "android" || reactNative.Platform.OS === "ios" ? LeanViewComponent : reactNative.View;
321
-
322
- // src/Separator.tsx
323
- function Separator({ ItemSeparatorComponent, itemKey, leadingItem }) {
324
- const [lastItemKeys] = useArr$(["lastItemKeys"]);
325
- const isALastItem = lastItemKeys.includes(itemKey);
326
- return isALastItem ? null : /* @__PURE__ */ React.createElement(ItemSeparatorComponent, { leadingItem });
327
- }
328
-
329
- // src/constants.ts
330
- var POSITION_OUT_OF_VIEW = -1e7;
331
- var ENABLE_DEVMODE = __DEV__ && false;
332
- var ENABLE_DEBUG_VIEW = __DEV__ && false;
333
- var IsNewArchitecture = global.nativeFabricUIManager != null;
334
335
 
335
- // src/Container.tsx
336
+ // src/components/Container.tsx
336
337
  var Container = ({
337
338
  id,
338
339
  recycleItems,
@@ -374,17 +375,17 @@ var Container = ({
374
375
  }
375
376
  const style = horizontal ? {
376
377
  flexDirection: ItemSeparatorComponent ? "row" : void 0,
377
- position: "absolute",
378
- top: otherAxisPos,
379
378
  height: otherAxisSize,
380
379
  left: position,
380
+ position: "absolute",
381
+ top: otherAxisPos,
381
382
  ...paddingStyles || {}
382
383
  } : {
383
- position: "absolute",
384
384
  left: otherAxisPos,
385
+ position: "absolute",
385
386
  right: numColumns > 1 ? null : 0,
386
- width: otherAxisSize,
387
387
  top: position,
388
+ width: otherAxisSize,
388
389
  ...paddingStyles || {}
389
390
  };
390
391
  const renderedItemInfo = React3.useMemo(
@@ -397,7 +398,7 @@ var Container = ({
397
398
  }, []);
398
399
  const contextValue = React3.useMemo(() => {
399
400
  ctx.viewRefs.set(id, ref);
400
- return { containerId: id, itemKey, index, value: data, triggerLayout };
401
+ return { containerId: id, index, itemKey, triggerLayout, value: data };
401
402
  }, [id, itemKey, index, data]);
402
403
  const onLayout = (event) => {
403
404
  var _a, _b;
@@ -406,14 +407,14 @@ var Container = ({
406
407
  let layout = event.nativeEvent.layout;
407
408
  const size = layout[horizontal ? "width" : "height"];
408
409
  const doUpdate = () => {
409
- refLastSize.current = { width: layout.width, height: layout.height };
410
+ refLastSize.current = { height: layout.height, width: layout.width };
410
411
  updateItemSize2(itemKey, layout);
411
412
  };
412
413
  if (IsNewArchitecture || size > 0) {
413
414
  doUpdate();
414
415
  } else {
415
- (_b = (_a = ref.current) == null ? void 0 : _a.measure) == null ? void 0 : _b.call(_a, (x, y, width, height) => {
416
- layout = { width, height };
416
+ (_b = (_a = ref.current) == null ? void 0 : _a.measure) == null ? void 0 : _b.call(_a, (_x, _y, width, height) => {
417
+ layout = { height, width };
417
418
  doUpdate();
418
419
  });
419
420
  }
@@ -446,30 +447,28 @@ var Container = ({
446
447
  }
447
448
  }, [itemKey]);
448
449
  }
449
- return /* @__PURE__ */ React3__namespace.createElement(LeanView, { style, onLayout, ref, key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React3__namespace.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && /* @__PURE__ */ React3__namespace.createElement(
450
+ return /* @__PURE__ */ React3__namespace.createElement(LeanView, { key: recycleItems ? void 0 : itemKey, onLayout, ref, style }, /* @__PURE__ */ React3__namespace.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && /* @__PURE__ */ React3__namespace.createElement(
450
451
  Separator,
451
452
  {
452
- itemKey,
453
453
  ItemSeparatorComponent,
454
+ itemKey,
454
455
  leadingItem: renderedItemInfo.item
455
456
  }
456
457
  )));
457
458
  };
458
- var typedForwardRef = React3.forwardRef;
459
- var typedMemo = React3.memo;
460
459
  var useAnimatedValue = (initialValue) => {
461
460
  return React3.useRef(new reactNative.Animated.Value(initialValue)).current;
462
461
  };
463
462
 
464
- // src/useValue$.ts
463
+ // src/hooks/useValue$.ts
465
464
  function useValue$(key, params) {
466
465
  var _a;
467
466
  const { getValue, delay } = params || {};
468
467
  const ctx = useStateContext();
469
468
  const animValue = useAnimatedValue((_a = getValue ? getValue(peek$(ctx, key)) : peek$(ctx, key)) != null ? _a : 0);
470
469
  React3.useMemo(() => {
471
- let newValue = void 0;
472
- let prevValue = void 0;
470
+ let newValue;
471
+ let prevValue;
473
472
  let didQueueTask = false;
474
473
  listen$(ctx, key, (v) => {
475
474
  newValue = getValue ? getValue(v) : v;
@@ -497,8 +496,10 @@ function useValue$(key, params) {
497
496
  }, []);
498
497
  return animValue;
499
498
  }
499
+ var typedForwardRef = React3.forwardRef;
500
+ var typedMemo = React3.memo;
500
501
 
501
- // src/Containers.tsx
502
+ // src/components/Containers.tsx
502
503
  var Containers = typedMemo(function Containers2({
503
504
  horizontal,
504
505
  recycleItems,
@@ -522,18 +523,18 @@ var Containers = typedMemo(function Containers2({
522
523
  /* @__PURE__ */ React3__namespace.createElement(
523
524
  Container,
524
525
  {
526
+ getRenderedItem: getRenderedItem2,
527
+ horizontal,
528
+ ItemSeparatorComponent,
525
529
  id: i,
526
530
  key: i,
527
531
  recycleItems,
528
- horizontal,
529
- getRenderedItem: getRenderedItem2,
530
- updateItemSize: updateItemSize2,
531
- ItemSeparatorComponent
532
+ updateItemSize: updateItemSize2
532
533
  }
533
534
  )
534
535
  );
535
536
  }
536
- const style = horizontal ? { width: animSize, opacity: animOpacity, minHeight: otherAxisSize } : { height: animSize, opacity: animOpacity, minWidth: otherAxisSize };
537
+ const style = horizontal ? { minHeight: otherAxisSize, opacity: animOpacity, width: animSize } : { height: animSize, minWidth: otherAxisSize, opacity: animOpacity };
537
538
  if (columnWrapperStyle && numColumns > 1) {
538
539
  const { columnGap, rowGap, gap } = columnWrapperStyle;
539
540
  const gapX = columnGap || gap || 0;
@@ -564,20 +565,19 @@ function ScrollAdjust() {
564
565
  reactNative.View,
565
566
  {
566
567
  style: {
567
- position: "absolute",
568
568
  height: 0,
569
- width: 0,
569
+ left: 0,
570
+ position: "absolute",
570
571
  top: scrollOffset,
571
- left: 0
572
+ width: 0
572
573
  }
573
574
  }
574
575
  );
575
576
  }
576
577
 
577
- // src/SnapWrapper.tsx
578
+ // src/components/SnapWrapper.tsx
578
579
  function SnapWrapper({ ScrollComponent, ...props }) {
579
580
  const [snapToOffsets] = useArr$(["snapToOffsets"]);
580
- console.log("snapToOffsets", snapToOffsets);
581
581
  return /* @__PURE__ */ React.createElement(ScrollComponent, { ...props, snapToOffsets });
582
582
  }
583
583
  function useSyncLayout({
@@ -593,14 +593,14 @@ function useSyncLayout({
593
593
  React3.useLayoutEffect(() => {
594
594
  if (ref.current) {
595
595
  ref.current.measure((x, y, width, height) => {
596
- onChange({ x, y, width, height }, true);
596
+ onChange({ height, width, x, y }, true);
597
597
  });
598
598
  }
599
599
  }, []);
600
600
  return { onLayout, ref };
601
601
  }
602
602
 
603
- // src/ListComponent.tsx
603
+ // src/components/ListComponent.tsx
604
604
  var getComponent = (Component) => {
605
605
  if (React3__namespace.isValidElement(Component)) {
606
606
  return Component;
@@ -620,12 +620,12 @@ var PaddingDevMode = () => {
620
620
  reactNative.Animated.View,
621
621
  {
622
622
  style: {
623
- position: "absolute",
624
- top: 0,
623
+ backgroundColor: "green",
625
624
  height: animPaddingTop,
626
625
  left: 0,
626
+ position: "absolute",
627
627
  right: 0,
628
- backgroundColor: "green"
628
+ top: 0
629
629
  }
630
630
  }
631
631
  ));
@@ -677,73 +677,51 @@ var ListComponent = typedMemo(function ListComponent2({
677
677
  SnapOrScroll,
678
678
  {
679
679
  ...rest,
680
- ScrollComponent: snapToIndices ? ScrollComponent : void 0,
681
- style,
682
- maintainVisibleContentPosition: maintainVisibleContentPosition && !ListEmptyComponent ? { minIndexForVisible: 0 } : void 0,
683
680
  contentContainerStyle: [
684
681
  contentContainerStyle,
685
682
  horizontal ? {
686
683
  height: "100%"
687
684
  } : {}
688
685
  ],
689
- onScroll: onScroll2,
690
- onLayout,
691
- horizontal,
692
686
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
693
- ref: refScrollView
687
+ horizontal,
688
+ maintainVisibleContentPosition: maintainVisibleContentPosition && !ListEmptyComponent ? { minIndexForVisible: 0 } : void 0,
689
+ onLayout,
690
+ onScroll: onScroll2,
691
+ ref: refScrollView,
692
+ ScrollComponent: snapToIndices ? ScrollComponent : void 0,
693
+ style
694
694
  },
695
695
  maintainVisibleContentPosition && /* @__PURE__ */ React3__namespace.createElement(ScrollAdjust, null),
696
696
  ENABLE_DEVMODE ? /* @__PURE__ */ React3__namespace.createElement(PaddingDevMode, null) : /* @__PURE__ */ React3__namespace.createElement(Padding, null),
697
- ListHeaderComponent && /* @__PURE__ */ React3__namespace.createElement(reactNative.View, { style: ListHeaderComponentStyle, onLayout: onLayoutHeaderSync, ref: refHeader }, getComponent(ListHeaderComponent)),
697
+ ListHeaderComponent && /* @__PURE__ */ React3__namespace.createElement(reactNative.View, { onLayout: onLayoutHeaderSync, ref: refHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
698
698
  ListEmptyComponent && getComponent(ListEmptyComponent),
699
699
  canRender && /* @__PURE__ */ React3__namespace.createElement(
700
700
  Containers,
701
701
  {
702
- horizontal,
703
- recycleItems,
704
- waitForInitialLayout,
705
702
  getRenderedItem: getRenderedItem2,
703
+ horizontal,
706
704
  ItemSeparatorComponent,
707
- updateItemSize: updateItemSize2
705
+ recycleItems,
706
+ updateItemSize: updateItemSize2,
707
+ waitForInitialLayout
708
708
  }
709
709
  ),
710
710
  ListFooterComponent && /* @__PURE__ */ React3__namespace.createElement(
711
711
  reactNative.View,
712
712
  {
713
- style: ListFooterComponentStyle,
714
713
  onLayout: (event) => {
715
714
  const size = event.nativeEvent.layout[horizontal ? "width" : "height"];
716
715
  set$(ctx, "footerSize", size);
717
- }
716
+ },
717
+ style: ListFooterComponentStyle
718
718
  },
719
719
  getComponent(ListFooterComponent)
720
720
  )
721
721
  );
722
722
  });
723
723
 
724
- // src/ScrollAdjustHandler.ts
725
- var ScrollAdjustHandler = class {
726
- constructor(ctx) {
727
- this.appliedAdjust = 0;
728
- this.mounted = false;
729
- this.context = ctx;
730
- }
731
- requestAdjust(add) {
732
- const oldAdjustTop = peek$(this.context, "scrollAdjust") || 0;
733
- this.appliedAdjust = add + oldAdjustTop;
734
- const set = () => set$(this.context, "scrollAdjust", this.appliedAdjust);
735
- if (this.mounted) {
736
- set();
737
- } else {
738
- requestAnimationFrame(set);
739
- }
740
- }
741
- setMounted() {
742
- this.mounted = true;
743
- }
744
- };
745
-
746
- // src/getId.ts
724
+ // src/utils/getId.ts
747
725
  function getId(state, index) {
748
726
  const { data, keyExtractor } = state.props;
749
727
  if (!data) {
@@ -755,7 +733,7 @@ function getId(state, index) {
755
733
  return id;
756
734
  }
757
735
 
758
- // src/calculateOffsetForIndex.ts
736
+ // src/core/calculateOffsetForIndex.ts
759
737
  function calculateOffsetForIndex(ctx, state, index) {
760
738
  let position = 0;
761
739
  if (index !== void 0) {
@@ -772,7 +750,7 @@ function calculateOffsetForIndex(ctx, state, index) {
772
750
  return position;
773
751
  }
774
752
 
775
- // src/getItemSize.ts
753
+ // src/utils/getItemSize.ts
776
754
  function getItemSize(state, key, index, data, useAverageSize) {
777
755
  const {
778
756
  sizesKnown,
@@ -801,7 +779,7 @@ function getItemSize(state, key, index, data, useAverageSize) {
801
779
  return size;
802
780
  }
803
781
 
804
- // src/calculateOffsetWithOffsetPosition.ts
782
+ // src/core/calculateOffsetWithOffsetPosition.ts
805
783
  function calculateOffsetWithOffsetPosition(state, offsetParam, params) {
806
784
  const { index, viewOffset, viewPosition } = params;
807
785
  let offset = offsetParam;
@@ -814,338 +792,76 @@ function calculateOffsetWithOffsetPosition(state, offsetParam, params) {
814
792
  return offset;
815
793
  }
816
794
 
817
- // src/checkAllSizesKnown.ts
818
- function checkAllSizesKnown(state) {
819
- const { startBuffered, endBuffered, sizesKnown } = state;
820
- if (endBuffered !== null) {
821
- let areAllKnown = true;
822
- for (let i = startBuffered; areAllKnown && i <= endBuffered; i++) {
823
- const key = getId(state, i);
824
- areAllKnown && (areAllKnown = sizesKnown.has(key));
795
+ // src/utils/requestAdjust.ts
796
+ function requestAdjust(ctx, state, positionDiff) {
797
+ if (Math.abs(positionDiff) > 0.1) {
798
+ const doit = () => {
799
+ state.scrollAdjustHandler.requestAdjust(positionDiff);
800
+ };
801
+ state.scroll += positionDiff;
802
+ state.scrollForNextCalculateItemsInView = void 0;
803
+ const didLayout = peek$(ctx, "containersDidLayout");
804
+ if (didLayout) {
805
+ doit();
806
+ const threshold = state.scroll - positionDiff / 2;
807
+ if (!state.ignoreScrollFromMVCP) {
808
+ state.ignoreScrollFromMVCP = {};
809
+ }
810
+ if (positionDiff > 0) {
811
+ state.ignoreScrollFromMVCP.lt = threshold;
812
+ } else {
813
+ state.ignoreScrollFromMVCP.gt = threshold;
814
+ }
815
+ if (state.ignoreScrollFromMVCPTimeout) {
816
+ clearTimeout(state.ignoreScrollFromMVCPTimeout);
817
+ }
818
+ state.ignoreScrollFromMVCPTimeout = setTimeout(() => {
819
+ state.ignoreScrollFromMVCP = void 0;
820
+ }, 100);
821
+ } else {
822
+ requestAnimationFrame(doit);
825
823
  }
826
- return areAllKnown;
827
824
  }
828
- return false;
829
825
  }
830
826
 
831
- // src/findAvailableContainers.ts
832
- function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffered, pendingRemoval) {
833
- const numContainers = peek$(ctx, "numContainers");
834
- const result = [];
835
- const availableContainers = [];
836
- for (let u = 0; u < numContainers; u++) {
837
- const key = peek$(ctx, `containerItemKey${u}`);
838
- let isOk = key === void 0;
839
- if (!isOk) {
840
- const index = pendingRemoval.indexOf(u);
841
- if (index !== -1) {
842
- pendingRemoval.splice(index, 1);
843
- isOk = true;
844
- }
845
- }
846
- if (isOk) {
847
- result.push(u);
848
- if (result.length >= numNeeded) {
849
- return result;
850
- }
827
+ // src/core/prepareMVCP.ts
828
+ function prepareMVCP(ctx, state) {
829
+ const {
830
+ positions,
831
+ scrollingTo,
832
+ props: { maintainVisibleContentPosition }
833
+ } = state;
834
+ let prevPosition;
835
+ let targetId;
836
+ let targetIndex;
837
+ const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
838
+ if (maintainVisibleContentPosition) {
839
+ const indexByKey = state.indexByKey;
840
+ if (scrollTarget !== void 0) {
841
+ targetId = getId(state, scrollTarget);
842
+ targetIndex = scrollTarget;
843
+ } else if (state.idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
844
+ targetId = state.idsInView.find((id) => indexByKey.get(id) !== void 0);
845
+ targetIndex = indexByKey.get(targetId);
851
846
  }
852
- }
853
- for (let u = 0; u < numContainers; u++) {
854
- const key = peek$(ctx, `containerItemKey${u}`);
855
- if (key === void 0) continue;
856
- const index = state.indexByKey.get(key);
857
- if (index < startBuffered) {
858
- availableContainers.push({ index: u, distance: startBuffered - index });
859
- } else if (index > endBuffered) {
860
- availableContainers.push({ index: u, distance: index - endBuffered });
847
+ if (targetId !== void 0 && targetIndex !== void 0) {
848
+ prevPosition = positions.get(targetId);
861
849
  }
862
850
  }
863
- const remaining = numNeeded - result.length;
864
- if (remaining > 0) {
865
- if (availableContainers.length > 0) {
866
- if (availableContainers.length > remaining) {
867
- availableContainers.sort(comparatorByDistance);
868
- availableContainers.length = remaining;
869
- }
870
- for (const container of availableContainers) {
871
- result.push(container.index);
872
- }
873
- }
874
- const stillNeeded = numNeeded - result.length;
875
- if (stillNeeded > 0) {
876
- for (let i = 0; i < stillNeeded; i++) {
877
- result.push(numContainers + i);
878
- }
879
- if (__DEV__ && numContainers + stillNeeded > peek$(ctx, "numContainersPooled")) {
880
- console.warn(
881
- "[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.",
882
- {
883
- debugInfo: {
884
- numContainers,
885
- numNeeded,
886
- stillNeeded,
887
- numContainersPooled: peek$(ctx, "numContainersPooled")
888
- }
889
- }
890
- );
891
- }
892
- }
893
- }
894
- return result.sort(comparatorDefault);
895
- }
896
- function comparatorByDistance(a, b) {
897
- return b.distance - a.distance;
898
- }
899
-
900
- // src/getScrollVelocity.ts
901
- var getScrollVelocity = (state) => {
902
- const { scrollHistory } = state;
903
- let velocity = 0;
904
- if (scrollHistory.length >= 1) {
905
- const newest = scrollHistory[scrollHistory.length - 1];
906
- let oldest;
907
- let start = 0;
908
- for (let i = 0; i < scrollHistory.length - 1; i++) {
909
- const entry = scrollHistory[i];
910
- const nextEntry = scrollHistory[i + 1];
911
- if (i > 0) {
912
- const prevEntry = scrollHistory[i - 1];
913
- const prevDirection = entry.scroll - prevEntry.scroll;
914
- const currentDirection = nextEntry.scroll - entry.scroll;
915
- if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
916
- start = i;
917
- break;
918
- }
919
- }
920
- }
921
- for (let i = start; i < scrollHistory.length - 1; i++) {
922
- const entry = scrollHistory[i];
923
- if (newest.time - entry.time <= 1e3) {
924
- oldest = entry;
925
- break;
926
- }
927
- }
928
- if (oldest) {
929
- const scrollDiff = newest.scroll - oldest.scroll;
930
- const timeDiff = newest.time - oldest.time;
931
- velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
932
- }
933
- }
934
- return velocity;
935
- };
936
-
937
- // src/requestAdjust.ts
938
- function requestAdjust(ctx, state, positionDiff) {
939
- if (Math.abs(positionDiff) > 0.1) {
940
- const doit = () => {
941
- state.scrollAdjustHandler.requestAdjust(positionDiff);
942
- };
943
- state.scroll += positionDiff;
944
- state.scrollForNextCalculateItemsInView = void 0;
945
- const didLayout = peek$(ctx, "containersDidLayout");
946
- if (didLayout) {
947
- doit();
948
- const threshold = state.scroll - positionDiff / 2;
949
- if (!state.ignoreScrollFromMVCP) {
950
- state.ignoreScrollFromMVCP = {};
951
- }
952
- if (positionDiff > 0) {
953
- state.ignoreScrollFromMVCP.lt = threshold;
954
- } else {
955
- state.ignoreScrollFromMVCP.gt = threshold;
956
- }
957
- if (state.ignoreScrollFromMVCPTimeout) {
958
- clearTimeout(state.ignoreScrollFromMVCPTimeout);
959
- }
960
- state.ignoreScrollFromMVCPTimeout = setTimeout(() => {
961
- state.ignoreScrollFromMVCP = void 0;
962
- }, 100);
963
- } else {
964
- requestAnimationFrame(doit);
965
- }
966
- }
967
- }
968
-
969
- // src/prepareMVCP.ts
970
- function prepareMVCP(ctx, state) {
971
- const {
972
- positions,
973
- scrollingTo,
974
- props: { maintainVisibleContentPosition }
975
- } = state;
976
- let prevPosition;
977
- let targetId;
978
- let targetIndex;
979
- const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
980
- if (maintainVisibleContentPosition) {
981
- const indexByKey = state.indexByKey;
982
- if (scrollTarget !== void 0) {
983
- targetId = getId(state, scrollTarget);
984
- targetIndex = scrollTarget;
985
- } else if (state.idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
986
- targetId = state.idsInView.find((id) => indexByKey.get(id) !== void 0);
987
- targetIndex = indexByKey.get(targetId);
988
- }
989
- if (targetId !== void 0 && targetIndex !== void 0) {
990
- prevPosition = positions.get(targetId);
991
- }
992
- }
993
- return () => {
994
- if (targetId !== void 0 && prevPosition !== void 0) {
995
- const newPosition = positions.get(targetId);
996
- if (newPosition !== void 0) {
997
- const positionDiff = newPosition - prevPosition;
998
- if (Math.abs(positionDiff) > 0.1) {
999
- requestAdjust(ctx, state, positionDiff);
1000
- }
851
+ return () => {
852
+ if (targetId !== void 0 && prevPosition !== void 0) {
853
+ const newPosition = positions.get(targetId);
854
+ if (newPosition !== void 0) {
855
+ const positionDiff = newPosition - prevPosition;
856
+ if (Math.abs(positionDiff) > 0.1) {
857
+ requestAdjust(ctx, state, positionDiff);
858
+ }
1001
859
  }
1002
860
  }
1003
861
  };
1004
862
  }
1005
863
 
1006
- // src/checkThreshold.ts
1007
- var checkThreshold = (distance, atThreshold, threshold, isReached, isBlockedByTimer, onReached, blockTimer) => {
1008
- const distanceAbs = Math.abs(distance);
1009
- const isAtThreshold = atThreshold || distanceAbs < threshold;
1010
- if (!isReached && !isBlockedByTimer) {
1011
- if (isAtThreshold) {
1012
- onReached == null ? void 0 : onReached(distance);
1013
- blockTimer == null ? void 0 : blockTimer(true);
1014
- setTimeout(() => {
1015
- blockTimer == null ? void 0 : blockTimer(false);
1016
- }, 700);
1017
- return true;
1018
- }
1019
- } else {
1020
- if (distance >= 1.3 * threshold) {
1021
- return false;
1022
- }
1023
- }
1024
- return isReached;
1025
- };
1026
-
1027
- // src/checkAtBottom.ts
1028
- function checkAtBottom(ctx, state) {
1029
- if (!state) {
1030
- return;
1031
- }
1032
- const {
1033
- queuedInitialLayout,
1034
- scrollLength,
1035
- scroll,
1036
- maintainingScrollAtEnd,
1037
- props: { maintainScrollAtEndThreshold, onEndReachedThreshold }
1038
- } = state;
1039
- const contentSize = getContentSize(ctx);
1040
- if (contentSize > 0 && queuedInitialLayout && !maintainingScrollAtEnd) {
1041
- const distanceFromEnd = contentSize - scroll - scrollLength;
1042
- const isContentLess = contentSize < scrollLength;
1043
- state.isAtEnd = isContentLess || distanceFromEnd < scrollLength * maintainScrollAtEndThreshold;
1044
- state.isEndReached = checkThreshold(
1045
- distanceFromEnd,
1046
- isContentLess,
1047
- onEndReachedThreshold * scrollLength,
1048
- state.isEndReached,
1049
- state.endReachedBlockedByTimer,
1050
- (distance) => {
1051
- var _a, _b;
1052
- return (_b = (_a = state.props).onEndReached) == null ? void 0 : _b.call(_a, { distanceFromEnd: distance });
1053
- },
1054
- (block) => {
1055
- state.endReachedBlockedByTimer = block;
1056
- }
1057
- );
1058
- }
1059
- }
1060
-
1061
- // src/finishScrollTo.ts
1062
- var finishScrollTo = (state) => {
1063
- if (state) {
1064
- state.scrollingTo = void 0;
1065
- state.scrollHistory.length = 0;
1066
- }
1067
- };
1068
-
1069
- // src/scrollTo.ts
1070
- function scrollTo(state, params = {}) {
1071
- var _a;
1072
- const { animated } = params;
1073
- const {
1074
- refScroller,
1075
- props: { horizontal }
1076
- } = state;
1077
- const offset = calculateOffsetWithOffsetPosition(state, params.offset, params);
1078
- state.scrollHistory.length = 0;
1079
- state.scrollingTo = params;
1080
- state.scrollPending = offset;
1081
- (_a = refScroller.current) == null ? void 0 : _a.scrollTo({
1082
- x: horizontal ? offset : 0,
1083
- y: horizontal ? 0 : offset,
1084
- animated: !!animated
1085
- });
1086
- if (!animated) {
1087
- state.scroll = offset;
1088
- setTimeout(() => finishScrollTo(state), 100);
1089
- }
1090
- }
1091
-
1092
- // src/scrollToIndex.ts
1093
- function scrollToIndex(ctx, state, { index, viewOffset = 0, animated = true, viewPosition }) {
1094
- if (index >= state.props.data.length) {
1095
- index = state.props.data.length - 1;
1096
- } else if (index < 0) {
1097
- index = 0;
1098
- }
1099
- const firstIndexOffset = calculateOffsetForIndex(ctx, state, index);
1100
- const isLast = index === state.props.data.length - 1;
1101
- if (isLast && viewPosition === void 0) {
1102
- viewPosition = 1;
1103
- }
1104
- const firstIndexScrollPostion = firstIndexOffset - viewOffset;
1105
- state.scrollForNextCalculateItemsInView = void 0;
1106
- scrollTo(state, {
1107
- offset: firstIndexScrollPostion,
1108
- animated,
1109
- index,
1110
- viewPosition: viewPosition != null ? viewPosition : 0,
1111
- viewOffset
1112
- });
1113
- }
1114
-
1115
- // src/setDidLayout.ts
1116
- function setDidLayout(ctx, state) {
1117
- const {
1118
- loadStartTime,
1119
- initialScroll,
1120
- props: { onLoad }
1121
- } = state;
1122
- state.queuedInitialLayout = true;
1123
- checkAtBottom(ctx, state);
1124
- if (!IsNewArchitecture && initialScroll) {
1125
- scrollToIndex(ctx, state, { ...initialScroll, animated: false });
1126
- }
1127
- set$(ctx, "containersDidLayout", true);
1128
- if (onLoad) {
1129
- onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
1130
- }
1131
- }
1132
-
1133
- // src/updateSnapToOffsets.ts
1134
- function updateSnapToOffsets(ctx, state) {
1135
- const {
1136
- positions,
1137
- props: { snapToIndices }
1138
- } = state;
1139
- const snapToOffsets = Array(snapToIndices.length);
1140
- for (let i = 0; i < snapToIndices.length; i++) {
1141
- const idx = snapToIndices[i];
1142
- const key = getId(state, idx);
1143
- snapToOffsets[i] = positions.get(key);
1144
- }
1145
- set$(ctx, "snapToOffsets", snapToOffsets);
1146
- }
1147
-
1148
- // src/setPaddingTop.ts
864
+ // src/utils/setPaddingTop.ts
1149
865
  function setPaddingTop(ctx, { stylePaddingTop, alignItemsPaddingTop }) {
1150
866
  if (stylePaddingTop !== void 0) {
1151
867
  const prevStylePaddingTop = peek$(ctx, "stylePaddingTop") || 0;
@@ -1163,7 +879,7 @@ function setPaddingTop(ctx, { stylePaddingTop, alignItemsPaddingTop }) {
1163
879
  }
1164
880
  }
1165
881
 
1166
- // src/updateAlignItemsPaddingTop.ts
882
+ // src/utils/updateAlignItemsPaddingTop.ts
1167
883
  function updateAlignItemsPaddingTop(ctx, state) {
1168
884
  const {
1169
885
  scrollLength,
@@ -1179,7 +895,7 @@ function updateAlignItemsPaddingTop(ctx, state) {
1179
895
  }
1180
896
  }
1181
897
 
1182
- // src/updateTotalSize.ts
898
+ // src/core/updateTotalSize.ts
1183
899
  function updateTotalSize(ctx, state) {
1184
900
  const {
1185
901
  positions,
@@ -1212,7 +928,59 @@ function addTotalSize(ctx, state, key, add) {
1212
928
  }
1213
929
  }
1214
930
 
1215
- // src/updateAllPositions.ts
931
+ // src/utils/getScrollVelocity.ts
932
+ var getScrollVelocity = (state) => {
933
+ const { scrollHistory } = state;
934
+ let velocity = 0;
935
+ if (scrollHistory.length >= 1) {
936
+ const newest = scrollHistory[scrollHistory.length - 1];
937
+ let oldest;
938
+ let start = 0;
939
+ for (let i = 0; i < scrollHistory.length - 1; i++) {
940
+ const entry = scrollHistory[i];
941
+ const nextEntry = scrollHistory[i + 1];
942
+ if (i > 0) {
943
+ const prevEntry = scrollHistory[i - 1];
944
+ const prevDirection = entry.scroll - prevEntry.scroll;
945
+ const currentDirection = nextEntry.scroll - entry.scroll;
946
+ if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
947
+ start = i;
948
+ break;
949
+ }
950
+ }
951
+ }
952
+ for (let i = start; i < scrollHistory.length - 1; i++) {
953
+ const entry = scrollHistory[i];
954
+ if (newest.time - entry.time <= 1e3) {
955
+ oldest = entry;
956
+ break;
957
+ }
958
+ }
959
+ if (oldest) {
960
+ const scrollDiff = newest.scroll - oldest.scroll;
961
+ const timeDiff = newest.time - oldest.time;
962
+ velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
963
+ }
964
+ }
965
+ return velocity;
966
+ };
967
+
968
+ // src/utils/updateSnapToOffsets.ts
969
+ function updateSnapToOffsets(ctx, state) {
970
+ const {
971
+ positions,
972
+ props: { snapToIndices }
973
+ } = state;
974
+ const snapToOffsets = Array(snapToIndices.length);
975
+ for (let i = 0; i < snapToIndices.length; i++) {
976
+ const idx = snapToIndices[i];
977
+ const key = getId(state, idx);
978
+ snapToOffsets[i] = positions.get(key);
979
+ }
980
+ set$(ctx, "snapToOffsets", snapToOffsets);
981
+ }
982
+
983
+ // src/core/updateAllPositions.ts
1216
984
  function updateAllPositions(ctx, state, dataChanged) {
1217
985
  var _a, _b, _c, _d, _e;
1218
986
  const {
@@ -1309,7 +1077,7 @@ function updateAllPositions(ctx, state, dataChanged) {
1309
1077
  }
1310
1078
  }
1311
1079
 
1312
- // src/viewability.ts
1080
+ // src/core/viewability.ts
1313
1081
  var mapViewabilityConfigCallbackPairs = /* @__PURE__ */ new Map();
1314
1082
  function setupViewability(props) {
1315
1083
  let { viewabilityConfig, viewabilityConfigCallbackPairs, onViewableItemsChanged } = props;
@@ -1317,27 +1085,31 @@ function setupViewability(props) {
1317
1085
  viewabilityConfigCallbackPairs = [
1318
1086
  ...viewabilityConfigCallbackPairs || [],
1319
1087
  {
1088
+ onViewableItemsChanged,
1320
1089
  viewabilityConfig: viewabilityConfig || {
1321
1090
  viewAreaCoveragePercentThreshold: 0
1322
- },
1323
- onViewableItemsChanged
1091
+ }
1324
1092
  }
1325
1093
  ];
1326
1094
  }
1327
1095
  if (viewabilityConfigCallbackPairs) {
1328
1096
  for (const pair of viewabilityConfigCallbackPairs) {
1329
1097
  mapViewabilityConfigCallbackPairs.set(pair.viewabilityConfig.id, {
1330
- viewableItems: [],
1331
- start: -1,
1332
1098
  end: -1,
1099
+ previousEnd: -1,
1333
1100
  previousStart: -1,
1334
- previousEnd: -1
1101
+ start: -1,
1102
+ viewableItems: []
1335
1103
  });
1336
1104
  }
1337
1105
  }
1338
1106
  return viewabilityConfigCallbackPairs;
1339
1107
  }
1340
1108
  function updateViewableItems(state, ctx, viewabilityConfigCallbackPairs, scrollSize, start, end) {
1109
+ const {
1110
+ timeouts,
1111
+ props: { data }
1112
+ } = state;
1341
1113
  for (const viewabilityConfigCallbackPair of viewabilityConfigCallbackPairs) {
1342
1114
  const viewabilityState = mapViewabilityConfigCallbackPairs.get(
1343
1115
  viewabilityConfigCallbackPair.viewabilityConfig.id
@@ -1346,12 +1118,12 @@ function updateViewableItems(state, ctx, viewabilityConfigCallbackPairs, scrollS
1346
1118
  viewabilityState.end = end;
1347
1119
  if (viewabilityConfigCallbackPair.viewabilityConfig.minimumViewTime) {
1348
1120
  const timer = setTimeout(() => {
1349
- state.timeouts.delete(timer);
1350
- updateViewableItemsWithConfig(state.data, viewabilityConfigCallbackPair, state, ctx, scrollSize);
1121
+ timeouts.delete(timer);
1122
+ updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, state, ctx, scrollSize);
1351
1123
  }, viewabilityConfigCallbackPair.viewabilityConfig.minimumViewTime);
1352
- state.timeouts.add(timer);
1124
+ timeouts.add(timer);
1353
1125
  } else {
1354
- updateViewableItemsWithConfig(state.data, viewabilityConfigCallbackPair, state, ctx, scrollSize);
1126
+ updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, state, ctx, scrollSize);
1355
1127
  }
1356
1128
  }
1357
1129
  }
@@ -1403,11 +1175,11 @@ function updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, stat
1403
1175
  const containerId = findContainerId(ctx, key);
1404
1176
  if (isViewable(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, i)) {
1405
1177
  const viewToken = {
1406
- item,
1407
- key,
1178
+ containerId,
1408
1179
  index: i,
1409
1180
  isViewable: true,
1410
- containerId
1181
+ item,
1182
+ key
1411
1183
  };
1412
1184
  viewableItems.push(viewToken);
1413
1185
  if (!(previousViewableItems == null ? void 0 : previousViewableItems.find((v) => v.key === viewToken.key))) {
@@ -1417,9 +1189,9 @@ function updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, stat
1417
1189
  }
1418
1190
  }
1419
1191
  Object.assign(viewabilityState, {
1420
- viewableItems,
1192
+ previousEnd: end,
1421
1193
  previousStart: start,
1422
- previousEnd: end
1194
+ viewableItems
1423
1195
  });
1424
1196
  if (changed.length > 0) {
1425
1197
  viewabilityState.viewableItems = viewableItems;
@@ -1428,74 +1200,284 @@ function updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, stat
1428
1200
  maybeUpdateViewabilityCallback(ctx, configId, change.containerId, change);
1429
1201
  }
1430
1202
  if (onViewableItemsChanged) {
1431
- onViewableItemsChanged({ viewableItems, changed });
1203
+ onViewableItemsChanged({ changed, viewableItems });
1204
+ }
1205
+ }
1206
+ for (const [containerId, value] of ctx.mapViewabilityAmountValues) {
1207
+ if (value.sizeVisible < 0) {
1208
+ ctx.mapViewabilityAmountValues.delete(containerId);
1209
+ }
1210
+ }
1211
+ }
1212
+ function computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
1213
+ const { sizes, positions, scroll: scrollState } = state;
1214
+ const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
1215
+ const { itemVisiblePercentThreshold, viewAreaCoveragePercentThreshold } = viewabilityConfig;
1216
+ const viewAreaMode = viewAreaCoveragePercentThreshold != null;
1217
+ const viewablePercentThreshold = viewAreaMode ? viewAreaCoveragePercentThreshold : itemVisiblePercentThreshold;
1218
+ const scroll = scrollState - topPad;
1219
+ const top = positions.get(key) - scroll;
1220
+ const size = sizes.get(key) || 0;
1221
+ const bottom = top + size;
1222
+ const isEntirelyVisible = top >= 0 && bottom <= scrollSize && bottom > top;
1223
+ const sizeVisible = isEntirelyVisible ? size : Math.min(bottom, scrollSize) - Math.max(top, 0);
1224
+ const percentVisible = size ? isEntirelyVisible ? 100 : 100 * (sizeVisible / size) : 0;
1225
+ const percentOfScroller = size ? 100 * (sizeVisible / scrollSize) : 0;
1226
+ const percent = isEntirelyVisible ? 100 : viewAreaMode ? percentOfScroller : percentVisible;
1227
+ const isViewable2 = percent >= viewablePercentThreshold;
1228
+ const value = {
1229
+ containerId,
1230
+ index,
1231
+ isViewable: isViewable2,
1232
+ item,
1233
+ key,
1234
+ percentOfScroller,
1235
+ percentVisible,
1236
+ scrollSize,
1237
+ size,
1238
+ sizeVisible
1239
+ };
1240
+ if (JSON.stringify(value) !== JSON.stringify(ctx.mapViewabilityAmountValues.get(containerId))) {
1241
+ ctx.mapViewabilityAmountValues.set(containerId, value);
1242
+ const cb = ctx.mapViewabilityAmountCallbacks.get(containerId);
1243
+ if (cb) {
1244
+ cb(value);
1245
+ }
1246
+ }
1247
+ return value;
1248
+ }
1249
+ function isViewable(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
1250
+ const value = ctx.mapViewabilityAmountValues.get(containerId) || computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index);
1251
+ return value.isViewable;
1252
+ }
1253
+ function findContainerId(ctx, key) {
1254
+ const numContainers = peek$(ctx, "numContainers");
1255
+ for (let i = 0; i < numContainers; i++) {
1256
+ const itemKey = peek$(ctx, `containerItemKey${i}`);
1257
+ if (itemKey === key) {
1258
+ return i;
1259
+ }
1260
+ }
1261
+ return -1;
1262
+ }
1263
+ function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
1264
+ const key = containerId + configId;
1265
+ ctx.mapViewabilityValues.set(key, viewToken);
1266
+ const cb = ctx.mapViewabilityCallbacks.get(key);
1267
+ cb == null ? void 0 : cb(viewToken);
1268
+ }
1269
+
1270
+ // src/utils/checkAllSizesKnown.ts
1271
+ function checkAllSizesKnown(state) {
1272
+ const { startBuffered, endBuffered, sizesKnown } = state;
1273
+ if (endBuffered !== null) {
1274
+ let areAllKnown = true;
1275
+ for (let i = startBuffered; areAllKnown && i <= endBuffered; i++) {
1276
+ const key = getId(state, i);
1277
+ areAllKnown && (areAllKnown = sizesKnown.has(key));
1278
+ }
1279
+ return areAllKnown;
1280
+ }
1281
+ return false;
1282
+ }
1283
+
1284
+ // src/utils/findAvailableContainers.ts
1285
+ function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffered, pendingRemoval) {
1286
+ const numContainers = peek$(ctx, "numContainers");
1287
+ const result = [];
1288
+ const availableContainers = [];
1289
+ for (let u = 0; u < numContainers; u++) {
1290
+ const key = peek$(ctx, `containerItemKey${u}`);
1291
+ let isOk = key === void 0;
1292
+ if (!isOk) {
1293
+ const index = pendingRemoval.indexOf(u);
1294
+ if (index !== -1) {
1295
+ pendingRemoval.splice(index, 1);
1296
+ isOk = true;
1297
+ }
1298
+ }
1299
+ if (isOk) {
1300
+ result.push(u);
1301
+ if (result.length >= numNeeded) {
1302
+ return result;
1303
+ }
1304
+ }
1305
+ }
1306
+ for (let u = 0; u < numContainers; u++) {
1307
+ const key = peek$(ctx, `containerItemKey${u}`);
1308
+ if (key === void 0) continue;
1309
+ const index = state.indexByKey.get(key);
1310
+ if (index < startBuffered) {
1311
+ availableContainers.push({ distance: startBuffered - index, index: u });
1312
+ } else if (index > endBuffered) {
1313
+ availableContainers.push({ distance: index - endBuffered, index: u });
1432
1314
  }
1433
1315
  }
1434
- for (const [containerId, value] of ctx.mapViewabilityAmountValues) {
1435
- if (value.sizeVisible < 0) {
1436
- ctx.mapViewabilityAmountValues.delete(containerId);
1316
+ const remaining = numNeeded - result.length;
1317
+ if (remaining > 0) {
1318
+ if (availableContainers.length > 0) {
1319
+ if (availableContainers.length > remaining) {
1320
+ availableContainers.sort(comparatorByDistance);
1321
+ availableContainers.length = remaining;
1322
+ }
1323
+ for (const container of availableContainers) {
1324
+ result.push(container.index);
1325
+ }
1326
+ }
1327
+ const stillNeeded = numNeeded - result.length;
1328
+ if (stillNeeded > 0) {
1329
+ for (let i = 0; i < stillNeeded; i++) {
1330
+ result.push(numContainers + i);
1331
+ }
1332
+ if (__DEV__ && numContainers + stillNeeded > peek$(ctx, "numContainersPooled")) {
1333
+ console.warn(
1334
+ "[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.",
1335
+ {
1336
+ debugInfo: {
1337
+ numContainers,
1338
+ numContainersPooled: peek$(ctx, "numContainersPooled"),
1339
+ numNeeded,
1340
+ stillNeeded
1341
+ }
1342
+ }
1343
+ );
1344
+ }
1437
1345
  }
1438
1346
  }
1347
+ return result.sort(comparatorDefault);
1439
1348
  }
1440
- function computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
1441
- const { sizes, positions, scroll: scrollState } = state;
1442
- const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
1443
- const { itemVisiblePercentThreshold, viewAreaCoveragePercentThreshold } = viewabilityConfig;
1444
- const viewAreaMode = viewAreaCoveragePercentThreshold != null;
1445
- const viewablePercentThreshold = viewAreaMode ? viewAreaCoveragePercentThreshold : itemVisiblePercentThreshold;
1446
- const scroll = scrollState - topPad;
1447
- const top = positions.get(key) - scroll;
1448
- const size = sizes.get(key) || 0;
1449
- const bottom = top + size;
1450
- const isEntirelyVisible = top >= 0 && bottom <= scrollSize && bottom > top;
1451
- const sizeVisible = isEntirelyVisible ? size : Math.min(bottom, scrollSize) - Math.max(top, 0);
1452
- const percentVisible = size ? isEntirelyVisible ? 100 : 100 * (sizeVisible / size) : 0;
1453
- const percentOfScroller = size ? 100 * (sizeVisible / scrollSize) : 0;
1454
- const percent = isEntirelyVisible ? 100 : viewAreaMode ? percentOfScroller : percentVisible;
1455
- const isViewable2 = percent >= viewablePercentThreshold;
1456
- const value = {
1457
- index,
1458
- isViewable: isViewable2,
1459
- item,
1460
- key,
1461
- percentVisible,
1462
- percentOfScroller,
1463
- sizeVisible,
1464
- size,
1465
- scrollSize,
1466
- containerId
1467
- };
1468
- if (JSON.stringify(value) !== JSON.stringify(ctx.mapViewabilityAmountValues.get(containerId))) {
1469
- ctx.mapViewabilityAmountValues.set(containerId, value);
1470
- const cb = ctx.mapViewabilityAmountCallbacks.get(containerId);
1471
- if (cb) {
1472
- cb(value);
1473
- }
1349
+ function comparatorByDistance(a, b) {
1350
+ return b.distance - a.distance;
1351
+ }
1352
+
1353
+ // src/core/finishScrollTo.ts
1354
+ var finishScrollTo = (state) => {
1355
+ if (state) {
1356
+ state.scrollingTo = void 0;
1357
+ state.scrollHistory.length = 0;
1358
+ }
1359
+ };
1360
+
1361
+ // src/core/scrollTo.ts
1362
+ function scrollTo(state, params = {}) {
1363
+ var _a;
1364
+ const { animated } = params;
1365
+ const {
1366
+ refScroller,
1367
+ props: { horizontal }
1368
+ } = state;
1369
+ const offset = calculateOffsetWithOffsetPosition(state, params.offset, params);
1370
+ state.scrollHistory.length = 0;
1371
+ state.scrollingTo = params;
1372
+ state.scrollPending = offset;
1373
+ (_a = refScroller.current) == null ? void 0 : _a.scrollTo({
1374
+ animated: !!animated,
1375
+ x: horizontal ? offset : 0,
1376
+ y: horizontal ? 0 : offset
1377
+ });
1378
+ if (!animated) {
1379
+ state.scroll = offset;
1380
+ setTimeout(() => finishScrollTo(state), 100);
1474
1381
  }
1475
- return value;
1476
1382
  }
1477
- function isViewable(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
1478
- const value = ctx.mapViewabilityAmountValues.get(containerId) || computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index);
1479
- return value.isViewable;
1383
+
1384
+ // src/core/scrollToIndex.ts
1385
+ function scrollToIndex(ctx, state, { index, viewOffset = 0, animated = true, viewPosition }) {
1386
+ if (index >= state.props.data.length) {
1387
+ index = state.props.data.length - 1;
1388
+ } else if (index < 0) {
1389
+ index = 0;
1390
+ }
1391
+ const firstIndexOffset = calculateOffsetForIndex(ctx, state, index);
1392
+ const isLast = index === state.props.data.length - 1;
1393
+ if (isLast && viewPosition === void 0) {
1394
+ viewPosition = 1;
1395
+ }
1396
+ const firstIndexScrollPostion = firstIndexOffset - viewOffset;
1397
+ state.scrollForNextCalculateItemsInView = void 0;
1398
+ scrollTo(state, {
1399
+ animated,
1400
+ index,
1401
+ offset: firstIndexScrollPostion,
1402
+ viewOffset,
1403
+ viewPosition: viewPosition != null ? viewPosition : 0
1404
+ });
1480
1405
  }
1481
- function findContainerId(ctx, key) {
1482
- const numContainers = peek$(ctx, "numContainers");
1483
- for (let i = 0; i < numContainers; i++) {
1484
- const itemKey = peek$(ctx, `containerItemKey${i}`);
1485
- if (itemKey === key) {
1486
- return i;
1406
+
1407
+ // src/utils/checkThreshold.ts
1408
+ var checkThreshold = (distance, atThreshold, threshold, isReached, isBlockedByTimer, onReached, blockTimer) => {
1409
+ const distanceAbs = Math.abs(distance);
1410
+ const isAtThreshold = atThreshold || distanceAbs < threshold;
1411
+ if (!isReached && !isBlockedByTimer) {
1412
+ if (isAtThreshold) {
1413
+ onReached == null ? void 0 : onReached(distance);
1414
+ blockTimer == null ? void 0 : blockTimer(true);
1415
+ setTimeout(() => {
1416
+ blockTimer == null ? void 0 : blockTimer(false);
1417
+ }, 700);
1418
+ return true;
1419
+ }
1420
+ } else {
1421
+ if (distance >= 1.3 * threshold) {
1422
+ return false;
1487
1423
  }
1488
1424
  }
1489
- return -1;
1425
+ return isReached;
1426
+ };
1427
+
1428
+ // src/utils/checkAtBottom.ts
1429
+ function checkAtBottom(ctx, state) {
1430
+ if (!state) {
1431
+ return;
1432
+ }
1433
+ const {
1434
+ queuedInitialLayout,
1435
+ scrollLength,
1436
+ scroll,
1437
+ maintainingScrollAtEnd,
1438
+ props: { maintainScrollAtEndThreshold, onEndReachedThreshold }
1439
+ } = state;
1440
+ const contentSize = getContentSize(ctx);
1441
+ if (contentSize > 0 && queuedInitialLayout && !maintainingScrollAtEnd) {
1442
+ const distanceFromEnd = contentSize - scroll - scrollLength;
1443
+ const isContentLess = contentSize < scrollLength;
1444
+ state.isAtEnd = isContentLess || distanceFromEnd < scrollLength * maintainScrollAtEndThreshold;
1445
+ state.isEndReached = checkThreshold(
1446
+ distanceFromEnd,
1447
+ isContentLess,
1448
+ onEndReachedThreshold * scrollLength,
1449
+ state.isEndReached,
1450
+ state.endReachedBlockedByTimer,
1451
+ (distance) => {
1452
+ var _a, _b;
1453
+ return (_b = (_a = state.props).onEndReached) == null ? void 0 : _b.call(_a, { distanceFromEnd: distance });
1454
+ },
1455
+ (block) => {
1456
+ state.endReachedBlockedByTimer = block;
1457
+ }
1458
+ );
1459
+ }
1490
1460
  }
1491
- function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
1492
- const key = containerId + configId;
1493
- ctx.mapViewabilityValues.set(key, viewToken);
1494
- const cb = ctx.mapViewabilityCallbacks.get(key);
1495
- cb == null ? void 0 : cb(viewToken);
1461
+
1462
+ // src/utils/setDidLayout.ts
1463
+ function setDidLayout(ctx, state) {
1464
+ const {
1465
+ loadStartTime,
1466
+ initialScroll,
1467
+ props: { onLoad }
1468
+ } = state;
1469
+ state.queuedInitialLayout = true;
1470
+ checkAtBottom(ctx, state);
1471
+ if (!IsNewArchitecture && initialScroll) {
1472
+ scrollToIndex(ctx, state, { ...initialScroll, animated: false });
1473
+ }
1474
+ set$(ctx, "containersDidLayout", true);
1475
+ if (onLoad) {
1476
+ onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
1477
+ }
1496
1478
  }
1497
1479
 
1498
- // src/calculateItemsInView.ts
1480
+ // src/core/calculateItemsInView.ts
1499
1481
  function calculateItemsInView(ctx, state, params = {}) {
1500
1482
  var _a, _b, _c, _d, _e, _f, _g, _h;
1501
1483
  const {
@@ -1512,7 +1494,8 @@ function calculateItemsInView(ctx, state, params = {}) {
1512
1494
  minIndexSizeChanged
1513
1495
  } = state;
1514
1496
  const data = state.props.data;
1515
- if (!data || scrollLength === 0) {
1497
+ const prevNumContainers = peek$(ctx, "numContainers");
1498
+ if (!data || scrollLength === 0 || !prevNumContainers) {
1516
1499
  return;
1517
1500
  }
1518
1501
  const totalSize = peek$(ctx, "totalSize");
@@ -1594,7 +1577,6 @@ function calculateItemsInView(ctx, state, params = {}) {
1594
1577
  let foundEnd = false;
1595
1578
  let nextTop;
1596
1579
  let nextBottom;
1597
- const prevNumContainers = ctx.values.get("numContainers");
1598
1580
  let maxIndexRendered = 0;
1599
1581
  for (let i = 0; i < prevNumContainers; i++) {
1600
1582
  const key = peek$(ctx, `containerItemKey${i}`);
@@ -1640,18 +1622,18 @@ function calculateItemsInView(ctx, state, params = {}) {
1640
1622
  idsInView.push(id);
1641
1623
  }
1642
1624
  Object.assign(state, {
1643
- startBuffered,
1644
- startBufferedId,
1645
- startNoBuffer,
1646
1625
  endBuffered,
1647
1626
  endNoBuffer,
1627
+ firstFullyOnScreenIndex,
1648
1628
  idsInView,
1649
- firstFullyOnScreenIndex
1629
+ startBuffered,
1630
+ startBufferedId,
1631
+ startNoBuffer
1650
1632
  });
1651
1633
  if (enableScrollForNextCalculateItemsInView && nextTop !== void 0 && nextBottom !== void 0) {
1652
1634
  state.scrollForNextCalculateItemsInView = nextTop !== void 0 && nextBottom !== void 0 ? {
1653
- top: nextTop,
1654
- bottom: nextBottom
1635
+ bottom: nextBottom,
1636
+ top: nextTop
1655
1637
  } : void 0;
1656
1638
  }
1657
1639
  const numContainers = peek$(ctx, "numContainers");
@@ -1739,70 +1721,27 @@ function calculateItemsInView(ctx, state, params = {}) {
1739
1721
  set$(ctx, `containerItemData${i}`, data[itemIndex]);
1740
1722
  }
1741
1723
  }
1742
- }
1743
- }
1744
- }
1745
- if (!queuedInitialLayout && endBuffered !== null) {
1746
- if (checkAllSizesKnown(state)) {
1747
- setDidLayout(ctx, state);
1748
- }
1749
- }
1750
- if (state.props.viewabilityConfigCallbackPairs) {
1751
- updateViewableItems(
1752
- state,
1753
- ctx,
1754
- state.props.viewabilityConfigCallbackPairs,
1755
- scrollLength,
1756
- startNoBuffer,
1757
- endNoBuffer
1758
- );
1759
- }
1760
- }
1761
-
1762
- // src/checkAtTop.ts
1763
- function checkAtTop(state) {
1764
- if (!state) {
1765
- return;
1766
- }
1767
- const {
1768
- scrollLength,
1769
- scroll,
1770
- props: { onStartReachedThreshold }
1771
- } = state;
1772
- const distanceFromTop = scroll;
1773
- state.isAtStart = distanceFromTop <= 0;
1774
- state.isStartReached = checkThreshold(
1775
- distanceFromTop,
1776
- false,
1777
- onStartReachedThreshold * scrollLength,
1778
- state.isStartReached,
1779
- state.startReachedBlockedByTimer,
1780
- (distance) => {
1781
- var _a, _b;
1782
- return (_b = (_a = state.props).onStartReached) == null ? void 0 : _b.call(_a, { distanceFromStart: distance });
1783
- },
1784
- (block) => {
1785
- state.startReachedBlockedByTimer = block;
1786
- }
1787
- );
1788
- }
1789
-
1790
- // src/createColumnWrapperStyle.ts
1791
- function createColumnWrapperStyle(contentContainerStyle) {
1792
- const { gap, columnGap, rowGap } = contentContainerStyle;
1793
- if (gap || columnGap || rowGap) {
1794
- contentContainerStyle.gap = void 0;
1795
- contentContainerStyle.columnGap = void 0;
1796
- contentContainerStyle.rowGap = void 0;
1797
- return {
1798
- gap,
1799
- columnGap,
1800
- rowGap
1801
- };
1724
+ }
1725
+ }
1726
+ }
1727
+ if (!queuedInitialLayout && endBuffered !== null) {
1728
+ if (checkAllSizesKnown(state)) {
1729
+ setDidLayout(ctx, state);
1730
+ }
1731
+ }
1732
+ if (state.props.viewabilityConfigCallbackPairs) {
1733
+ updateViewableItems(
1734
+ state,
1735
+ ctx,
1736
+ state.props.viewabilityConfigCallbackPairs,
1737
+ scrollLength,
1738
+ startNoBuffer,
1739
+ endNoBuffer
1740
+ );
1802
1741
  }
1803
1742
  }
1804
1743
 
1805
- // src/doInitialAllocateContainers.ts
1744
+ // src/core/doInitialAllocateContainers.ts
1806
1745
  function doInitialAllocateContainers(ctx, state) {
1807
1746
  const { scrollLength } = state;
1808
1747
  const data = state.props.data;
@@ -1831,7 +1770,7 @@ function doInitialAllocateContainers(ctx, state) {
1831
1770
  }
1832
1771
  }
1833
1772
 
1834
- // src/doMaintainScrollAtEnd.ts
1773
+ // src/core/doMaintainScrollAtEnd.ts
1835
1774
  function doMaintainScrollAtEnd(ctx, state, animated) {
1836
1775
  const {
1837
1776
  refScroller,
@@ -1858,31 +1797,36 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
1858
1797
  return true;
1859
1798
  }
1860
1799
  }
1861
- function getRenderedItem(ctx, state, key) {
1800
+
1801
+ // src/utils/checkAtTop.ts
1802
+ function checkAtTop(state) {
1862
1803
  if (!state) {
1863
- return null;
1804
+ return;
1864
1805
  }
1865
1806
  const {
1866
- indexByKey,
1867
- props: { data, renderItem: renderItem2 }
1807
+ scrollLength,
1808
+ scroll,
1809
+ props: { onStartReachedThreshold }
1868
1810
  } = state;
1869
- const index = indexByKey.get(key);
1870
- if (index === void 0) {
1871
- return null;
1872
- }
1873
- let renderedItem = null;
1874
- if (renderItem2) {
1875
- const itemProps = {
1876
- item: data[index],
1877
- index,
1878
- extraData: peek$(ctx, "extraData")
1879
- };
1880
- renderedItem = React3__namespace.default.createElement(renderItem2, itemProps);
1881
- }
1882
- return { index, item: data[index], renderedItem };
1811
+ const distanceFromTop = scroll;
1812
+ state.isAtStart = distanceFromTop <= 0;
1813
+ state.isStartReached = checkThreshold(
1814
+ distanceFromTop,
1815
+ false,
1816
+ onStartReachedThreshold * scrollLength,
1817
+ state.isStartReached,
1818
+ state.startReachedBlockedByTimer,
1819
+ (distance) => {
1820
+ var _a, _b;
1821
+ return (_b = (_a = state.props).onStartReached) == null ? void 0 : _b.call(_a, { distanceFromStart: distance });
1822
+ },
1823
+ (block) => {
1824
+ state.startReachedBlockedByTimer = block;
1825
+ }
1826
+ );
1883
1827
  }
1884
1828
 
1885
- // src/handleLayout.ts
1829
+ // src/core/handleLayout.ts
1886
1830
  function handleLayout(ctx, state, layout, setCanRender) {
1887
1831
  const { maintainScrollAtEnd } = state.props;
1888
1832
  const scrollLength = layout[state.props.horizontal ? "width" : "height"];
@@ -1900,7 +1844,7 @@ function handleLayout(ctx, state, layout, setCanRender) {
1900
1844
  calculateItemsInView(ctx, state, { doMVCP: true });
1901
1845
  }
1902
1846
  if (didChange || otherAxisSize !== prevOtherAxisSize) {
1903
- set$(ctx, "scrollSize", { width: layout.width, height: layout.height });
1847
+ set$(ctx, "scrollSize", { height: layout.height, width: layout.width });
1904
1848
  }
1905
1849
  if (maintainScrollAtEnd === true || maintainScrollAtEnd.onLayout) {
1906
1850
  doMaintainScrollAtEnd(ctx, state, false);
@@ -1920,7 +1864,7 @@ function handleLayout(ctx, state, layout, setCanRender) {
1920
1864
  setCanRender(true);
1921
1865
  }
1922
1866
 
1923
- // src/onScroll.ts
1867
+ // src/core/onScroll.ts
1924
1868
  function onScroll(ctx, state, event) {
1925
1869
  var _a, _b, _c, _d, _e;
1926
1870
  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) {
@@ -1958,7 +1902,29 @@ function updateScroll(ctx, state, newScroll) {
1958
1902
  checkAtTop(state);
1959
1903
  }
1960
1904
 
1961
- // src/updateItemSize.ts
1905
+ // src/core/ScrollAdjustHandler.ts
1906
+ var ScrollAdjustHandler = class {
1907
+ constructor(ctx) {
1908
+ this.appliedAdjust = 0;
1909
+ this.mounted = false;
1910
+ this.context = ctx;
1911
+ }
1912
+ requestAdjust(add) {
1913
+ const oldAdjustTop = peek$(this.context, "scrollAdjust") || 0;
1914
+ this.appliedAdjust = add + oldAdjustTop;
1915
+ const set = () => set$(this.context, "scrollAdjust", this.appliedAdjust);
1916
+ if (this.mounted) {
1917
+ set();
1918
+ } else {
1919
+ requestAnimationFrame(set);
1920
+ }
1921
+ }
1922
+ setMounted() {
1923
+ this.mounted = true;
1924
+ }
1925
+ };
1926
+
1927
+ // src/core/updateItemSize.ts
1962
1928
  function updateItemSizes(ctx, state, itemUpdates) {
1963
1929
  var _a;
1964
1930
  const {
@@ -1972,7 +1938,8 @@ function updateItemSizes(ctx, state, itemUpdates) {
1972
1938
  }
1973
1939
  } = state;
1974
1940
  if (!data) return;
1975
- let needsRecalculate = false;
1941
+ const containersDidLayout = peek$(ctx, "containersDidLayout");
1942
+ let needsRecalculate = !containersDidLayout;
1976
1943
  let shouldMaintainScrollAtEnd = false;
1977
1944
  let minIndexSizeChanged;
1978
1945
  let maxOtherAxisSize = peek$(ctx, "otherAxisSize") || 0;
@@ -1983,7 +1950,7 @@ function updateItemSizes(ctx, state, itemUpdates) {
1983
1950
  const size = Math.floor((horizontal ? sizeObj.width : sizeObj.height) * 8) / 8;
1984
1951
  if (diff !== 0) {
1985
1952
  minIndexSizeChanged = minIndexSizeChanged !== void 0 ? Math.min(minIndexSizeChanged, index) : index;
1986
- if (((_a = state.scrollingTo) == null ? void 0 : _a.viewPosition) && maintainVisibleContentPosition && index === state.scrollingTo.index) {
1953
+ if (((_a = state.scrollingTo) == null ? void 0 : _a.viewPosition) && maintainVisibleContentPosition && index === state.scrollingTo.index && diff > 0) {
1987
1954
  requestAdjust(ctx, state, diff * state.scrollingTo.viewPosition);
1988
1955
  }
1989
1956
  const { startBuffered, endBuffered } = state;
@@ -2005,11 +1972,11 @@ function updateItemSizes(ctx, state, itemUpdates) {
2005
1972
  shouldMaintainScrollAtEnd = true;
2006
1973
  }
2007
1974
  onItemSizeChanged == null ? void 0 : onItemSizeChanged({
2008
- size,
2009
- previous: size - diff,
2010
1975
  index,
1976
+ itemData: state.props.data[index],
2011
1977
  itemKey,
2012
- itemData: state.props.data[index]
1978
+ previous: size - diff,
1979
+ size
2013
1980
  });
2014
1981
  }
2015
1982
  }
@@ -2032,7 +1999,6 @@ function updateItemSizes(ctx, state, itemUpdates) {
2032
1999
  if (!cur || maxOtherAxisSize > cur) {
2033
2000
  set$(ctx, "otherAxisSize", maxOtherAxisSize);
2034
2001
  }
2035
- const containersDidLayout = peek$(ctx, "containersDidLayout");
2036
2002
  if (containersDidLayout || checkAllSizesKnown(state)) {
2037
2003
  if (needsRecalculate) {
2038
2004
  state.scrollForNextCalculateItemsInView = void 0;
@@ -2048,7 +2014,7 @@ function updateItemSizes(ctx, state, itemUpdates) {
2048
2014
  function updateItemSize(ctx, state, itemKey, sizeObj) {
2049
2015
  if (IsNewArchitecture) {
2050
2016
  const { sizesKnown } = state;
2051
- const numContainers = ctx.values.get("numContainers");
2017
+ const numContainers = peek$(ctx, "numContainers");
2052
2018
  const changes = [];
2053
2019
  for (let i = 0; i < numContainers; i++) {
2054
2020
  const containerItemKey = peek$(ctx, `containerItemKey${i}`);
@@ -2059,7 +2025,7 @@ function updateItemSize(ctx, state, itemKey, sizeObj) {
2059
2025
  if (containerRef == null ? void 0 : containerRef.current) {
2060
2026
  let measured;
2061
2027
  containerRef.current.measure((x, y, width, height) => {
2062
- measured = { x, y, width, height };
2028
+ measured = { height, width, x, y };
2063
2029
  });
2064
2030
  if (measured) {
2065
2031
  changes.push({ itemKey: containerItemKey, sizeObj: measured });
@@ -2090,7 +2056,7 @@ function updateOneItemSize(state, itemKey, sizeObj) {
2090
2056
  const itemType = "";
2091
2057
  let averages = averageSizes[itemType];
2092
2058
  if (!averages) {
2093
- averages = averageSizes[itemType] = { num: 0, avg: 0 };
2059
+ averages = averageSizes[itemType] = { avg: 0, num: 0 };
2094
2060
  }
2095
2061
  averages.avg = (averages.avg * averages.num + size) / (averages.num + 1);
2096
2062
  averages.num++;
@@ -2116,7 +2082,45 @@ var useCombinedRef = (...refs) => {
2116
2082
  return callback;
2117
2083
  };
2118
2084
 
2119
- // src/LegendList.tsx
2085
+ // src/utils/createColumnWrapperStyle.ts
2086
+ function createColumnWrapperStyle(contentContainerStyle) {
2087
+ const { gap, columnGap, rowGap } = contentContainerStyle;
2088
+ if (gap || columnGap || rowGap) {
2089
+ contentContainerStyle.gap = void 0;
2090
+ contentContainerStyle.columnGap = void 0;
2091
+ contentContainerStyle.rowGap = void 0;
2092
+ return {
2093
+ columnGap,
2094
+ gap,
2095
+ rowGap
2096
+ };
2097
+ }
2098
+ }
2099
+ function getRenderedItem(ctx, state, key) {
2100
+ if (!state) {
2101
+ return null;
2102
+ }
2103
+ const {
2104
+ indexByKey,
2105
+ props: { data, renderItem: renderItem2 }
2106
+ } = state;
2107
+ const index = indexByKey.get(key);
2108
+ if (index === void 0) {
2109
+ return null;
2110
+ }
2111
+ let renderedItem = null;
2112
+ if (renderItem2) {
2113
+ const itemProps = {
2114
+ extraData: peek$(ctx, "extraData"),
2115
+ index,
2116
+ item: data[index]
2117
+ };
2118
+ renderedItem = React3__namespace.default.createElement(renderItem2, itemProps);
2119
+ }
2120
+ return { index, item: data[index], renderedItem };
2121
+ }
2122
+
2123
+ // src/components/LegendList.tsx
2120
2124
  var DEFAULT_DRAW_DISTANCE = 250;
2121
2125
  var DEFAULT_ITEM_SIZE = 100;
2122
2126
  var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
@@ -2184,55 +2188,55 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2184
2188
  const combinedRef = useCombinedRef(refScroller, refScrollView);
2185
2189
  const estimatedItemSize = estimatedItemSizeProp != null ? estimatedItemSizeProp : DEFAULT_ITEM_SIZE;
2186
2190
  const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
2187
- const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (item, index) => index.toString();
2191
+ const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (_item, index) => index.toString();
2188
2192
  const refState = React3.useRef();
2189
2193
  if (!refState.current) {
2190
- const initialScrollLength = (estimatedListSize != null ? estimatedListSize : IsNewArchitecture ? { width: 0, height: 0 } : reactNative.Dimensions.get("window"))[horizontal ? "width" : "height"];
2194
+ const initialScrollLength = (estimatedListSize != null ? estimatedListSize : IsNewArchitecture ? { height: 0, width: 0 } : reactNative.Dimensions.get("window"))[horizontal ? "width" : "height"];
2191
2195
  refState.current = {
2192
- sizes: /* @__PURE__ */ new Map(),
2193
- positions: /* @__PURE__ */ new Map(),
2196
+ averageSizes: {},
2194
2197
  columns: /* @__PURE__ */ new Map(),
2195
- pendingAdjust: 0,
2196
- isStartReached: false,
2197
- isEndReached: false,
2198
- isAtEnd: false,
2199
- isAtStart: false,
2200
- scrollLength: initialScrollLength,
2201
- startBuffered: -1,
2202
- startNoBuffer: -1,
2198
+ containerItemKeys: /* @__PURE__ */ new Set(),
2199
+ enableScrollForNextCalculateItemsInView: true,
2203
2200
  endBuffered: -1,
2204
2201
  endNoBuffer: -1,
2202
+ endReachedBlockedByTimer: false,
2205
2203
  firstFullyOnScreenIndex: -1,
2204
+ idCache: /* @__PURE__ */ new Map(),
2205
+ idsInView: [],
2206
+ indexByKey: /* @__PURE__ */ new Map(),
2207
+ initialScroll,
2208
+ isAtEnd: false,
2209
+ isAtStart: false,
2210
+ isEndReached: false,
2211
+ isStartReached: false,
2212
+ lastBatchingAction: Date.now(),
2213
+ lastLayout: void 0,
2214
+ loadStartTime: Date.now(),
2215
+ minIndexSizeChanged: 0,
2216
+ nativeMarginTop: 0,
2217
+ pendingAdjust: 0,
2218
+ positions: /* @__PURE__ */ new Map(),
2219
+ props: {},
2220
+ queuedCalculateItemsInView: 0,
2221
+ refScroller: void 0,
2206
2222
  scroll: 0,
2207
- totalSize: 0,
2208
- timeouts: /* @__PURE__ */ new Set(),
2209
- viewabilityConfigCallbackPairs: void 0,
2210
2223
  scrollAdjustHandler: new ScrollAdjustHandler(ctx),
2211
- nativeMarginTop: 0,
2224
+ scrollForNextCalculateItemsInView: void 0,
2225
+ scrollHistory: [],
2226
+ scrollLength: initialScrollLength,
2227
+ scrollPending: 0,
2212
2228
  scrollPrev: 0,
2213
2229
  scrollPrevTime: 0,
2214
2230
  scrollTime: 0,
2215
- scrollPending: 0,
2216
- indexByKey: /* @__PURE__ */ new Map(),
2217
- scrollHistory: [],
2231
+ sizes: /* @__PURE__ */ new Map(),
2218
2232
  sizesKnown: /* @__PURE__ */ new Map(),
2219
- timeoutSizeMessage: 0,
2233
+ startBuffered: -1,
2234
+ startNoBuffer: -1,
2220
2235
  startReachedBlockedByTimer: false,
2221
- endReachedBlockedByTimer: false,
2222
- scrollForNextCalculateItemsInView: void 0,
2223
- enableScrollForNextCalculateItemsInView: true,
2224
- minIndexSizeChanged: 0,
2225
- queuedCalculateItemsInView: 0,
2226
- lastBatchingAction: Date.now(),
2227
- averageSizes: {},
2228
- idsInView: [],
2229
- containerItemKeys: /* @__PURE__ */ new Set(),
2230
- idCache: /* @__PURE__ */ new Map(),
2231
- props: {},
2232
- refScroller: void 0,
2233
- loadStartTime: Date.now(),
2234
- initialScroll,
2235
- lastLayout: void 0
2236
+ timeoutSizeMessage: 0,
2237
+ timeouts: /* @__PURE__ */ new Set(),
2238
+ totalSize: 0,
2239
+ viewabilityConfigCallbackPairs: void 0
2236
2240
  };
2237
2241
  set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPosition);
2238
2242
  set$(ctx, "extraData", extraData);
@@ -2244,29 +2248,29 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2244
2248
  alignItemsAtEnd,
2245
2249
  data: dataProp,
2246
2250
  estimatedItemSize,
2251
+ getEstimatedItemSize,
2252
+ horizontal: !!horizontal,
2253
+ initialContainerPoolRatio,
2254
+ initialScroll,
2255
+ keyExtractor,
2247
2256
  maintainScrollAtEnd,
2248
2257
  maintainScrollAtEndThreshold,
2249
- onEndReachedThreshold,
2250
- onStartReachedThreshold,
2251
- stylePaddingBottom: stylePaddingBottomState,
2252
- horizontal: !!horizontal,
2253
2258
  maintainVisibleContentPosition,
2259
+ numColumns: numColumnsProp,
2260
+ onEndReached,
2261
+ onEndReachedThreshold,
2254
2262
  onItemSizeChanged,
2255
- suggestEstimatedItemSize: !!suggestEstimatedItemSize,
2256
- keyExtractor,
2263
+ onLoad,
2257
2264
  onScroll: onScrollProp,
2258
- getEstimatedItemSize,
2259
2265
  onStartReached,
2260
- onEndReached,
2261
- onLoad,
2266
+ onStartReachedThreshold,
2262
2267
  renderItem: renderItem2,
2263
- initialScroll,
2264
2268
  scrollBuffer,
2265
- viewabilityConfigCallbackPairs: void 0,
2266
- numColumns: numColumnsProp,
2267
- initialContainerPoolRatio,
2269
+ snapToIndices,
2270
+ stylePaddingBottom: stylePaddingBottomState,
2268
2271
  stylePaddingTop: stylePaddingTopState,
2269
- snapToIndices
2272
+ suggestEstimatedItemSize: !!suggestEstimatedItemSize,
2273
+ viewabilityConfigCallbackPairs: void 0
2270
2274
  };
2271
2275
  state.refScroller = refScroller;
2272
2276
  const checkResetContainers = (isFirst2) => {
@@ -2314,7 +2318,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2314
2318
  const initialContentOffset2 = initialScrollOffset || calculateOffsetForIndex(ctx, state, initialScrollIndex);
2315
2319
  refState.current.isStartReached = initialContentOffset2 < refState.current.scrollLength * onStartReachedThreshold;
2316
2320
  if (initialContentOffset2 > 0) {
2317
- scrollTo(state, { offset: initialContentOffset2, animated: false, index: initialScrollIndex });
2321
+ scrollTo(state, { animated: false, index: initialScrollIndex, offset: initialContentOffset2 });
2318
2322
  }
2319
2323
  return initialContentOffset2;
2320
2324
  }, [renderNum]);
@@ -2333,7 +2337,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2333
2337
  if (IsNewArchitecture) {
2334
2338
  let measured;
2335
2339
  refScroller.current.measure((x, y, width, height) => {
2336
- measured = { x, y, width, height };
2340
+ measured = { height, width, x, y };
2337
2341
  });
2338
2342
  if (measured) {
2339
2343
  const size = Math.floor(measured[horizontal ? "width" : "height"] * 8) / 8;
@@ -2389,9 +2393,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2389
2393
  };
2390
2394
  React3.useEffect(() => {
2391
2395
  const viewability = setupViewability({
2396
+ onViewableItemsChanged,
2392
2397
  viewabilityConfig,
2393
- viewabilityConfigCallbackPairs,
2394
- onViewableItemsChanged
2398
+ viewabilityConfigCallbackPairs
2395
2399
  });
2396
2400
  state.viewabilityConfigCallbackPairs = viewability;
2397
2401
  state.props.viewabilityConfigCallbackPairs = viewability;
@@ -2409,98 +2413,94 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2409
2413
  onLayoutProp(event);
2410
2414
  }
2411
2415
  }, []);
2412
- React3.useImperativeHandle(
2413
- forwardedRef,
2414
- () => {
2415
- const scrollIndexIntoView = (options) => {
2416
+ React3.useImperativeHandle(forwardedRef, () => {
2417
+ const scrollIndexIntoView = (options) => {
2418
+ const state2 = refState.current;
2419
+ if (state2) {
2420
+ const { index, ...rest2 } = options;
2421
+ const { startNoBuffer, endNoBuffer } = state2;
2422
+ if (index < startNoBuffer || index > endNoBuffer) {
2423
+ const viewPosition = index < startNoBuffer ? 0 : 1;
2424
+ scrollToIndex(ctx, state2, {
2425
+ ...rest2,
2426
+ index,
2427
+ viewPosition
2428
+ });
2429
+ }
2430
+ }
2431
+ };
2432
+ return {
2433
+ flashScrollIndicators: () => refScroller.current.flashScrollIndicators(),
2434
+ getNativeScrollRef: () => refScroller.current,
2435
+ getScrollableNode: () => refScroller.current.getScrollableNode(),
2436
+ getScrollResponder: () => refScroller.current.getScrollResponder(),
2437
+ getState: () => {
2416
2438
  const state2 = refState.current;
2417
- if (state2) {
2418
- const { index, ...rest2 } = options;
2419
- const { startNoBuffer, endNoBuffer } = state2;
2420
- if (index < startNoBuffer || index > endNoBuffer) {
2421
- const viewPosition = index < startNoBuffer ? 0 : 1;
2422
- scrollToIndex(ctx, state2, {
2423
- ...rest2,
2424
- viewPosition,
2425
- index
2426
- });
2427
- }
2439
+ return state2 ? {
2440
+ contentLength: state2.totalSize,
2441
+ end: state2.endNoBuffer,
2442
+ endBuffered: state2.endBuffered,
2443
+ isAtEnd: state2.isAtEnd,
2444
+ isAtStart: state2.isAtStart,
2445
+ positions: state2.positions,
2446
+ scroll: state2.scroll,
2447
+ scrollLength: state2.scrollLength,
2448
+ sizeAtIndex: (index) => state2.sizesKnown.get(getId(state2, index)),
2449
+ sizes: state2.sizesKnown,
2450
+ start: state2.startNoBuffer,
2451
+ startBuffered: state2.startBuffered
2452
+ } : {};
2453
+ },
2454
+ scrollIndexIntoView,
2455
+ scrollItemIntoView: ({ item, ...props2 }) => {
2456
+ const data = refState.current.props.data;
2457
+ const index = data.indexOf(item);
2458
+ if (index !== -1) {
2459
+ scrollIndexIntoView({ index, ...props2 });
2428
2460
  }
2429
- };
2430
- return {
2431
- flashScrollIndicators: () => refScroller.current.flashScrollIndicators(),
2432
- getNativeScrollRef: () => refScroller.current,
2433
- getScrollableNode: () => refScroller.current.getScrollableNode(),
2434
- getScrollResponder: () => refScroller.current.getScrollResponder(),
2435
- getState: () => {
2436
- const state2 = refState.current;
2437
- return state2 ? {
2438
- contentLength: state2.totalSize,
2439
- end: state2.endNoBuffer,
2440
- endBuffered: state2.endBuffered,
2441
- isAtEnd: state2.isAtEnd,
2442
- isAtStart: state2.isAtStart,
2443
- positions: state2.positions,
2444
- scroll: state2.scroll,
2445
- scrollLength: state2.scrollLength,
2446
- start: state2.startNoBuffer,
2447
- startBuffered: state2.startBuffered,
2448
- sizes: state2.sizesKnown,
2449
- sizeAtIndex: (index) => state2.sizesKnown.get(getId(state2, index))
2450
- } : {};
2451
- },
2452
- scrollIndexIntoView,
2453
- scrollItemIntoView: ({ item, ...props2 }) => {
2454
- const data = refState.current.props.data;
2455
- const index = data.indexOf(item);
2456
- if (index !== -1) {
2457
- scrollIndexIntoView({ index, ...props2 });
2458
- }
2459
- },
2460
- scrollToIndex: (params) => scrollToIndex(ctx, state, params),
2461
- scrollToItem: ({ item, ...props2 }) => {
2462
- const data = refState.current.props.data;
2463
- const index = data.indexOf(item);
2464
- if (index !== -1) {
2465
- scrollToIndex(ctx, state, { index, ...props2 });
2466
- }
2467
- },
2468
- scrollToOffset: (params) => scrollTo(state, params),
2469
- scrollToEnd: (options) => {
2470
- const data = refState.current.props.data;
2471
- const stylePaddingBottom = refState.current.props.stylePaddingBottom;
2472
- const index = data.length - 1;
2473
- if (index !== -1) {
2474
- const paddingBottom = stylePaddingBottom || 0;
2475
- const footerSize = peek$(ctx, "footerSize") || 0;
2476
- scrollToIndex(ctx, state, {
2477
- index,
2478
- viewPosition: 1,
2479
- viewOffset: -paddingBottom - footerSize,
2480
- ...options
2481
- });
2482
- }
2483
- },
2484
- setVisibleContentAnchorOffset: (value) => {
2485
- const val = typeof value === "function" ? value(peek$(ctx, "scrollAdjustUserOffset") || 0) : value;
2486
- set$(ctx, "scrollAdjustUserOffset", val);
2461
+ },
2462
+ scrollToEnd: (options) => {
2463
+ const data = refState.current.props.data;
2464
+ const stylePaddingBottom = refState.current.props.stylePaddingBottom;
2465
+ const index = data.length - 1;
2466
+ if (index !== -1) {
2467
+ const paddingBottom = stylePaddingBottom || 0;
2468
+ const footerSize = peek$(ctx, "footerSize") || 0;
2469
+ scrollToIndex(ctx, state, {
2470
+ index,
2471
+ viewOffset: -paddingBottom - footerSize,
2472
+ viewPosition: 1,
2473
+ ...options
2474
+ });
2487
2475
  }
2488
- };
2489
- },
2490
- []
2491
- );
2476
+ },
2477
+ scrollToIndex: (params) => scrollToIndex(ctx, state, params),
2478
+ scrollToItem: ({ item, ...props2 }) => {
2479
+ const data = refState.current.props.data;
2480
+ const index = data.indexOf(item);
2481
+ if (index !== -1) {
2482
+ scrollToIndex(ctx, state, { index, ...props2 });
2483
+ }
2484
+ },
2485
+ scrollToOffset: (params) => scrollTo(state, params),
2486
+ setVisibleContentAnchorOffset: (value) => {
2487
+ const val = typeof value === "function" ? value(peek$(ctx, "scrollAdjustUserOffset") || 0) : value;
2488
+ set$(ctx, "scrollAdjustUserOffset", val);
2489
+ }
2490
+ };
2491
+ }, []);
2492
2492
  if (reactNative.Platform.OS === "web") {
2493
2493
  React3.useEffect(() => {
2494
2494
  if (initialContentOffset) {
2495
- scrollTo(state, { offset: initialContentOffset, animated: false });
2495
+ scrollTo(state, { animated: false, offset: initialContentOffset });
2496
2496
  }
2497
2497
  }, []);
2498
2498
  }
2499
2499
  const fns = React3.useMemo(
2500
2500
  () => ({
2501
- updateItemSize: (itemKey, sizeObj) => updateItemSize(ctx, state, itemKey, sizeObj),
2502
2501
  getRenderedItem: (key) => getRenderedItem(ctx, state, key),
2503
- onScroll: (event) => onScroll(ctx, state, event)
2502
+ onScroll: (event) => onScroll(ctx, state, event),
2503
+ updateItemSize: (itemKey, sizeObj) => updateItemSize(ctx, state, itemKey, sizeObj)
2504
2504
  }),
2505
2505
  []
2506
2506
  );
@@ -2508,13 +2508,17 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2508
2508
  ListComponent,
2509
2509
  {
2510
2510
  ...rest,
2511
+ alignItemsAtEnd,
2511
2512
  canRender,
2513
+ contentContainerStyle,
2514
+ getRenderedItem: fns.getRenderedItem,
2512
2515
  horizontal,
2513
- refScrollView: combinedRef,
2514
2516
  initialContentOffset,
2515
- getRenderedItem: fns.getRenderedItem,
2516
- updateItemSize: fns.updateItemSize,
2517
- onScroll: fns.onScroll,
2517
+ ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
2518
+ ListHeaderComponent,
2519
+ maintainVisibleContentPosition,
2520
+ onLayout,
2521
+ onLayoutHeader,
2518
2522
  onMomentumScrollEnd: (event) => {
2519
2523
  requestAnimationFrame(() => {
2520
2524
  finishScrollTo(refState.current);
@@ -2523,32 +2527,30 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2523
2527
  onMomentumScrollEnd(event);
2524
2528
  }
2525
2529
  },
2526
- onLayout,
2530
+ onScroll: fns.onScroll,
2527
2531
  recycleItems,
2528
- alignItemsAtEnd,
2529
- ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
2530
- ListHeaderComponent,
2531
- maintainVisibleContentPosition,
2532
- scrollEventThrottle: reactNative.Platform.OS === "web" ? 16 : void 0,
2533
- waitForInitialLayout,
2534
2532
  refreshControl: refreshControl ? stylePaddingTopState > 0 ? React3__namespace.cloneElement(refreshControl, {
2535
2533
  progressViewOffset: (refreshControl.props.progressViewOffset || 0) + stylePaddingTopState
2536
2534
  }) : refreshControl : onRefresh && /* @__PURE__ */ React3__namespace.createElement(
2537
2535
  reactNative.RefreshControl,
2538
2536
  {
2539
- refreshing: !!refreshing,
2540
2537
  onRefresh,
2541
- progressViewOffset: (progressViewOffset || 0) + stylePaddingTopState
2538
+ progressViewOffset: (progressViewOffset || 0) + stylePaddingTopState,
2539
+ refreshing: !!refreshing
2542
2540
  }
2543
2541
  ),
2544
- style,
2545
- contentContainerStyle,
2542
+ refScrollView: combinedRef,
2546
2543
  scrollAdjustHandler: (_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler,
2547
- onLayoutHeader,
2548
- snapToIndices
2544
+ scrollEventThrottle: reactNative.Platform.OS === "web" ? 16 : void 0,
2545
+ snapToIndices,
2546
+ style,
2547
+ updateItemSize: fns.updateItemSize,
2548
+ waitForInitialLayout
2549
2549
  }
2550
2550
  ), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React3__namespace.createElement(DebugView, { state: refState.current }));
2551
2551
  });
2552
+
2553
+ // src/components/LazyLegendList.tsx
2552
2554
  var typedForwardRef2 = React3.forwardRef;
2553
2555
  var renderItem = ({ item }) => item;
2554
2556
  var LazyLegendList = typedForwardRef2(function LazyLegendList2(props, forwardedRef) {
@@ -2557,7 +2559,7 @@ var LazyLegendList = typedForwardRef2(function LazyLegendList2(props, forwardedR
2557
2559
  const data = (isArray(children) ? children : React3__namespace.Children.toArray(children)).flat(1);
2558
2560
  return (
2559
2561
  // @ts-expect-error TODO: Fix this type
2560
- /* @__PURE__ */ React3__namespace.createElement(LegendListComponent, { ...rest, data, renderItem, ref: forwardedRef })
2562
+ /* @__PURE__ */ React3__namespace.createElement(LegendListComponent, { ...rest, data, ref: forwardedRef, renderItem })
2561
2563
  );
2562
2564
  });
2563
2565