@legendapp/list 3.0.0-beta.54 → 3.0.0-beta.56

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.native.mjs CHANGED
@@ -1,13 +1,118 @@
1
1
  import * as React2 from 'react';
2
- import React2__default, { useReducer, useEffect, createContext, useRef, useState, useMemo, useCallback, useLayoutEffect, useImperativeHandle, useContext } from 'react';
2
+ import { useReducer, useEffect, createContext, useRef, useState, useMemo, useCallback, useLayoutEffect, useImperativeHandle, useContext } from 'react';
3
3
  import * as ReactNative from 'react-native';
4
- import { Animated, View as View$1, Text as Text$1, Platform as Platform$1, StyleSheet as StyleSheet$1, RefreshControl, Dimensions } from 'react-native';
4
+ import { Animated, Platform as Platform$1, View as View$1, Text as Text$1, StyleSheet as StyleSheet$1, RefreshControl, Dimensions, I18nManager } from 'react-native';
5
5
  import { useSyncExternalStore } from 'use-sync-external-store/shim';
6
6
 
7
7
  // src/components/LegendList.tsx
8
8
  Animated.View;
9
9
  var View = View$1;
10
10
  var Text = Text$1;
11
+ var Platform = Platform$1;
12
+ var PlatformAdjustBreaksScroll = Platform.OS === "android";
13
+
14
+ // src/utils/rtl.ts
15
+ function clampHorizontalOffset(offset, maxOffset) {
16
+ if (maxOffset === void 0) {
17
+ return offset;
18
+ }
19
+ return Math.max(0, Math.min(maxOffset, offset));
20
+ }
21
+ function getHorizontalMaxOffset(state, contentWidth) {
22
+ if (contentWidth === void 0 || !Number.isFinite(contentWidth) || !Number.isFinite(state.scrollLength) || contentWidth <= state.scrollLength) {
23
+ return contentWidth !== void 0 && Number.isFinite(contentWidth) && Number.isFinite(state.scrollLength) ? 0 : void 0;
24
+ }
25
+ return Math.max(0, contentWidth - state.scrollLength);
26
+ }
27
+ function getDefaultHorizontalRTLScrollType() {
28
+ return Platform.OS === "web" ? "normal" : "inverted";
29
+ }
30
+ function getNativeHorizontalRTLScrollType(state) {
31
+ var _a3;
32
+ return (_a3 = state == null ? void 0 : state.horizontalRTLScrollType) != null ? _a3 : getDefaultHorizontalRTLScrollType();
33
+ }
34
+ function isRTLProps(props) {
35
+ var _a3;
36
+ return (_a3 = props == null ? void 0 : props.rtl) != null ? _a3 : !!I18nManager.isRTL;
37
+ }
38
+ function isHorizontalRTL(state) {
39
+ return isHorizontalRTLProps(state == null ? void 0 : state.props);
40
+ }
41
+ function isHorizontalRTLProps(props) {
42
+ return !!(props == null ? void 0 : props.horizontal) && isRTLProps(props);
43
+ }
44
+ function getLogicalHorizontalMaxOffset(state, contentWidth) {
45
+ var _a3;
46
+ return (_a3 = getHorizontalMaxOffset(state, contentWidth)) != null ? _a3 : 0;
47
+ }
48
+ function getHorizontalInsetEnd(state, inset) {
49
+ if (!inset) {
50
+ return 0;
51
+ }
52
+ return (isHorizontalRTL(state) ? inset.left : inset.right) || 0;
53
+ }
54
+ function toPhysicalHorizontalItemPosition(state, logicalPosition, itemSize, listSize) {
55
+ if (!isHorizontalRTL(state) || listSize === void 0 || !Number.isFinite(listSize)) {
56
+ return logicalPosition;
57
+ }
58
+ return Math.max(0, listSize - logicalPosition - itemSize);
59
+ }
60
+ function toNativeHorizontalOffset(state, logicalOffset, contentWidth) {
61
+ if (!state || !isHorizontalRTL(state)) {
62
+ return logicalOffset;
63
+ }
64
+ const maxOffset = getHorizontalMaxOffset(state, contentWidth);
65
+ const clampedLogicalOffset = clampHorizontalOffset(logicalOffset, maxOffset);
66
+ const mode = getNativeHorizontalRTLScrollType(state);
67
+ if (mode === "negative") {
68
+ return clampedLogicalOffset === 0 ? 0 : -clampedLogicalOffset;
69
+ }
70
+ if (mode === "inverted") {
71
+ if (maxOffset === void 0) {
72
+ return clampedLogicalOffset;
73
+ }
74
+ return clampHorizontalOffset(maxOffset - clampedLogicalOffset, maxOffset);
75
+ }
76
+ return clampedLogicalOffset;
77
+ }
78
+ function toLogicalHorizontalOffset(state, rawOffset, contentWidth) {
79
+ if (!isHorizontalRTL(state)) {
80
+ state.horizontalRTLScrollType = void 0;
81
+ return rawOffset;
82
+ }
83
+ const maxOffset = getHorizontalMaxOffset(state, contentWidth);
84
+ if (rawOffset < 0) {
85
+ state.horizontalRTLScrollType = "negative";
86
+ return clampHorizontalOffset(-rawOffset, maxOffset);
87
+ }
88
+ if (maxOffset === void 0) {
89
+ return rawOffset;
90
+ }
91
+ const normalOffset = rawOffset;
92
+ const invertedOffset = maxOffset - rawOffset;
93
+ if (!Number.isFinite(invertedOffset)) {
94
+ state.horizontalRTLScrollType = "normal";
95
+ return normalOffset;
96
+ }
97
+ const previousMode = state.horizontalRTLScrollType;
98
+ if (previousMode === "inverted") {
99
+ return clampHorizontalOffset(invertedOffset, maxOffset);
100
+ }
101
+ if (previousMode === "normal") {
102
+ return clampHorizontalOffset(normalOffset, maxOffset);
103
+ }
104
+ if (!state.hasScrolled) {
105
+ const defaultMode = getDefaultHorizontalRTLScrollType();
106
+ state.horizontalRTLScrollType = defaultMode;
107
+ return clampHorizontalOffset(defaultMode === "inverted" ? invertedOffset : normalOffset, maxOffset);
108
+ }
109
+ const referenceScroll = state.scroll;
110
+ const distanceNormal = Math.abs(normalOffset - referenceScroll);
111
+ const distanceInverted = Math.abs(invertedOffset - referenceScroll);
112
+ const useInverted = distanceInverted + 0.5 < distanceNormal;
113
+ state.horizontalRTLScrollType = useInverted ? "inverted" : "normal";
114
+ return clampHorizontalOffset(useInverted ? invertedOffset : normalOffset, maxOffset);
115
+ }
11
116
  var createAnimatedValue = (value) => new Animated.Value(value);
12
117
 
13
118
  // src/state/state.tsx
@@ -149,7 +254,7 @@ function getContentInsetEnd(ctx, contentInsetEndAdjustmentOverride) {
149
254
  const horizontal = props.horizontal;
150
255
  const contentInset = props.contentInset;
151
256
  const baseInset = contentInset != null ? contentInset : state.nativeContentInset;
152
- const baseEndInset = (horizontal ? baseInset == null ? void 0 : baseInset.right : baseInset == null ? void 0 : baseInset.bottom) || 0;
257
+ const baseEndInset = (horizontal ? getHorizontalInsetEnd(state, baseInset) : baseInset == null ? void 0 : baseInset.bottom) || 0;
153
258
  const contentInsetEndAdjustment = getContentInsetEndAdjustmentEnd(
154
259
  contentInsetEndAdjustmentOverride != null ? contentInsetEndAdjustmentOverride : props.contentInsetEndAdjustment
155
260
  );
@@ -158,9 +263,9 @@ function getContentInsetEnd(ctx, contentInsetEndAdjustmentOverride) {
158
263
  const overrideInset = (_b = state.contentInsetOverride) != null ? _b : void 0;
159
264
  const adjustedBaseEndInset = baseEndInset + contentInsetEndAdjustment;
160
265
  if (overrideInset) {
161
- const mergedInset = { bottom: 0, right: 0, ...baseInset, ...overrideInset };
266
+ const mergedInset = { bottom: 0, left: 0, right: 0, ...baseInset, ...overrideInset };
162
267
  return Math.max(
163
- ((horizontal ? mergedInset.right : mergedInset.bottom) || 0) + contentInsetEndAdjustment,
268
+ ((horizontal ? getHorizontalInsetEnd(state, mergedInset) : mergedInset.bottom) || 0) + contentInsetEndAdjustment,
164
269
  anchoredEndInset
165
270
  );
166
271
  }
@@ -440,7 +545,8 @@ function comparatorDefault(a, b) {
440
545
  }
441
546
  function getPadding(s, type) {
442
547
  var _a3, _b, _c;
443
- return (_c = (_b = (_a3 = s[`padding${type}`]) != null ? _a3 : s.paddingVertical) != null ? _b : s.padding) != null ? _c : 0;
548
+ const axisPadding = type === "Left" || type === "Right" ? s.paddingHorizontal : s.paddingVertical;
549
+ return (_c = (_b = (_a3 = s[`padding${type}`]) != null ? _a3 : axisPadding) != null ? _b : s.padding) != null ? _c : 0;
444
550
  }
445
551
  function extractPadding(style, contentContainerStyle, type) {
446
552
  return getPadding(style, type) + getPadding(contentContainerStyle, type);
@@ -647,8 +753,6 @@ function useOnLayoutSync({
647
753
  }
648
754
  return { onLayout };
649
755
  }
650
- var Platform = Platform$1;
651
- var PlatformAdjustBreaksScroll = Platform.OS === "android";
652
756
 
653
757
  // src/utils/isInMVCPActiveMode.native.ts
654
758
  function isInMVCPActiveMode(state) {
@@ -660,6 +764,7 @@ function getContainerPositionStyle({
660
764
  columnWrapperStyle,
661
765
  horizontal,
662
766
  hasItemSeparator,
767
+ isHorizontalRTLList,
663
768
  numColumns,
664
769
  otherAxisPos,
665
770
  otherAxisSize
@@ -683,6 +788,7 @@ function getContainerPositionStyle({
683
788
  }
684
789
  return horizontal ? {
685
790
  boxSizing: paddingStyles ? "border-box" : void 0,
791
+ direction: isHorizontalRTLList && Platform.OS === "web" ? "ltr" : void 0,
686
792
  flexDirection: hasItemSeparator ? "row" : void 0,
687
793
  height: otherAxisSize,
688
794
  left: 0,
@@ -711,6 +817,7 @@ var Container = typedMemo(function Container2({
711
817
  }) {
712
818
  const ctx = useStateContext();
713
819
  const { columnWrapperStyle, animatedScrollY } = ctx;
820
+ const isHorizontalRTLList = isHorizontalRTL(ctx.state);
714
821
  const positionComponentInternal = ctx.state.props.positionComponentInternal;
715
822
  const stickyPositionComponentInternal = ctx.state.props.stickyPositionComponentInternal;
716
823
  const [column = 0, span = 1, data, numColumns = 1, extraData, isSticky] = useArr$([
@@ -742,11 +849,20 @@ var Container = typedMemo(function Container2({
742
849
  columnWrapperStyle,
743
850
  hasItemSeparator: !!ItemSeparatorComponent,
744
851
  horizontal,
852
+ isHorizontalRTLList,
745
853
  numColumns,
746
854
  otherAxisPos,
747
855
  otherAxisSize
748
856
  }),
749
- [horizontal, otherAxisPos, otherAxisSize, columnWrapperStyle, numColumns, ItemSeparatorComponent]
857
+ [
858
+ horizontal,
859
+ isHorizontalRTLList,
860
+ otherAxisPos,
861
+ otherAxisSize,
862
+ columnWrapperStyle,
863
+ numColumns,
864
+ ItemSeparatorComponent
865
+ ]
750
866
  );
751
867
  const renderedItemInfo = useMemo(
752
868
  () => itemKey !== void 0 ? getRenderedItem2(itemKey) : null,
@@ -899,9 +1015,13 @@ var ContainersLayer = typedMemo(function ContainersLayer2({ children, horizontal
899
1015
  const ctx = useStateContext();
900
1016
  const columnWrapperStyle = ctx.columnWrapperStyle;
901
1017
  const animSize = useValue$("totalSize");
902
- const otherAxisSize = useValue$("otherAxisSize");
903
- const [readyToRender, numColumns] = useArr$(["readyToRender", "numColumns"]);
904
- const style = horizontal ? { minHeight: otherAxisSize, opacity: readyToRender ? 1 : 0, width: animSize } : { height: animSize, minWidth: otherAxisSize, opacity: readyToRender ? 1 : 0 };
1018
+ const [readyToRender, numColumns, otherAxisSize = 0] = useArr$(["readyToRender", "numColumns", "otherAxisSize"]);
1019
+ const style = horizontal ? {
1020
+ height: otherAxisSize || "100%",
1021
+ minHeight: otherAxisSize,
1022
+ opacity: readyToRender ? 1 : 0,
1023
+ width: animSize
1024
+ } : { height: animSize, minWidth: otherAxisSize, opacity: readyToRender ? 1 : 0 };
905
1025
  if (columnWrapperStyle) {
906
1026
  const { columnGap, rowGap, gap } = columnWrapperStyle;
907
1027
  const gapX = columnGap || gap || 0;
@@ -954,6 +1074,18 @@ var Containers = typedMemo(function Containers2({
954
1074
  return /* @__PURE__ */ React2.createElement(ContainersLayer, { horizontal }, containers);
955
1075
  });
956
1076
  var ListComponentScrollView = Animated.ScrollView;
1077
+
1078
+ // src/components/listComponentStyles.ts
1079
+ function getAutoOtherAxisStyle({
1080
+ horizontal,
1081
+ needsOtherAxisSize,
1082
+ otherAxisSize
1083
+ }) {
1084
+ if (!needsOtherAxisSize || !otherAxisSize || otherAxisSize <= 0) {
1085
+ return void 0;
1086
+ }
1087
+ return horizontal ? { height: otherAxisSize } : { width: otherAxisSize };
1088
+ }
957
1089
  function ScrollAdjust() {
958
1090
  var _a3;
959
1091
  const ctx = useStateContext();
@@ -974,10 +1106,10 @@ function ScrollAdjust() {
974
1106
  }
975
1107
  );
976
1108
  }
977
- function SnapWrapper({ ScrollComponent, ...props }) {
1109
+ var SnapWrapper = React2.forwardRef(function SnapWrapperInner({ ScrollComponent, ...props }, ref) {
978
1110
  const [snapToOffsets] = useArr$(["snapToOffsets"]);
979
- return /* @__PURE__ */ React2.createElement(ScrollComponent, { ...props, snapToOffsets });
980
- }
1111
+ return /* @__PURE__ */ React2.createElement(ScrollComponent, { ...props, ref, snapToOffsets });
1112
+ });
981
1113
  function WebAnchoredEndSpace({ horizontal }) {
982
1114
  const ctx = useStateContext();
983
1115
  const [anchoredEndSpaceSize] = useArr$(["anchoredEndSpaceSize"]);
@@ -988,6 +1120,26 @@ function WebAnchoredEndSpace({ horizontal }) {
988
1120
  const style = horizontal ? { height: "100%", width: anchoredEndSpaceSize || 0 } : { height: anchoredEndSpaceSize || 0 };
989
1121
  return /* @__PURE__ */ React2.createElement("div", { style }, null);
990
1122
  }
1123
+ function useLatestRef(value) {
1124
+ const ref = React2.useRef(value);
1125
+ ref.current = value;
1126
+ return ref;
1127
+ }
1128
+
1129
+ // src/hooks/useStableRenderComponent.tsx
1130
+ function useStableRenderComponent(renderComponent, mapProps) {
1131
+ const renderComponentRef = useLatestRef(renderComponent);
1132
+ const mapPropsRef = useLatestRef(mapProps);
1133
+ return React2.useMemo(
1134
+ () => React2.forwardRef(
1135
+ (props, ref) => {
1136
+ var _a3, _b;
1137
+ return (_b = (_a3 = renderComponentRef.current) == null ? void 0 : _a3.call(renderComponentRef, mapPropsRef.current(props, ref))) != null ? _b : null;
1138
+ }
1139
+ ),
1140
+ [mapPropsRef, renderComponentRef]
1141
+ );
1142
+ }
991
1143
  var LayoutView = ({ onLayoutChange, refView, ...rest }) => {
992
1144
  const localRef = useRef(null);
993
1145
  const ref = refView != null ? refView : localRef;
@@ -1026,14 +1178,17 @@ var ListComponent = typedMemo(function ListComponent2({
1026
1178
  }) {
1027
1179
  const ctx = useStateContext();
1028
1180
  const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
1029
- const ScrollComponent = useMemo(() => {
1030
- if (!renderScrollComponent) {
1031
- return ListComponentScrollView;
1032
- }
1033
- return React2.forwardRef(
1034
- (props, ref) => renderScrollComponent({ ...props, ref })
1035
- );
1036
- }, [renderScrollComponent]);
1181
+ const [otherAxisSize = 0] = useArr$(["otherAxisSize"]);
1182
+ const autoOtherAxisStyle = getAutoOtherAxisStyle({
1183
+ horizontal,
1184
+ needsOtherAxisSize: ctx.state.needsOtherAxisSize,
1185
+ otherAxisSize
1186
+ });
1187
+ const CustomScrollComponent = useStableRenderComponent(
1188
+ renderScrollComponent,
1189
+ (props, ref) => ({ ...props, ref })
1190
+ );
1191
+ const ScrollComponent = renderScrollComponent ? CustomScrollComponent : ListComponentScrollView;
1037
1192
  const SnapOrScroll = snapToIndices ? SnapWrapper : ScrollComponent;
1038
1193
  useLayoutEffect(() => {
1039
1194
  if (!ListHeaderComponent) {
@@ -1064,10 +1219,10 @@ var ListComponent = typedMemo(function ListComponent2({
1064
1219
  ...rest,
1065
1220
  ...ScrollComponent === ListComponentScrollView ? { useWindowScroll } : {},
1066
1221
  contentContainerStyle: [
1067
- contentContainerStyle,
1068
1222
  horizontal ? {
1069
1223
  height: "100%"
1070
- } : {}
1224
+ } : {},
1225
+ contentContainerStyle
1071
1226
  ],
1072
1227
  contentOffset: initialContentOffset !== void 0 ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
1073
1228
  horizontal,
@@ -1076,7 +1231,7 @@ var ListComponent = typedMemo(function ListComponent2({
1076
1231
  onScroll: onScroll2,
1077
1232
  ref: refScrollView,
1078
1233
  ScrollComponent: snapToIndices ? ScrollComponent : void 0,
1079
- style
1234
+ style: autoOtherAxisStyle ? [autoOtherAxisStyle, style] : style
1080
1235
  },
1081
1236
  /* @__PURE__ */ React2.createElement(ScrollAdjust, null),
1082
1237
  ListHeaderComponent && /* @__PURE__ */ React2.createElement(LayoutView, { onLayoutChange: onLayoutHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
@@ -1936,10 +2091,13 @@ function doScrollTo(ctx, params) {
1936
2091
  if (!scroller) {
1937
2092
  return;
1938
2093
  }
2094
+ const isHorizontal = !!horizontal;
2095
+ const contentSize = isHorizontal ? getContentSize(ctx) : void 0;
2096
+ const nativeOffset = toNativeHorizontalOffset(state, offset, contentSize);
1939
2097
  scroller.scrollTo({
1940
2098
  animated: isAnimated,
1941
- x: horizontal ? offset : 0,
1942
- y: horizontal ? 0 : offset
2099
+ x: isHorizontal ? nativeOffset : 0,
2100
+ y: isHorizontal ? 0 : offset
1943
2101
  });
1944
2102
  if (isInitialScroll) {
1945
2103
  initialScrollCompletion.markInitialScrollNativeDispatch(state);
@@ -2511,11 +2669,51 @@ function getObservedBootstrapInitialScrollOffset(state) {
2511
2669
  const observedOffset = (_b = (_a3 = state.refScroller.current) == null ? void 0 : _a3.getCurrentScrollOffset) == null ? void 0 : _b.call(_a3);
2512
2670
  return typeof observedOffset === "number" && Number.isFinite(observedOffset) ? observedOffset : (_d = (_c = state.scrollPending) != null ? _c : state.scroll) != null ? _d : 0;
2513
2671
  }
2672
+ function getPreservedEndAnchorOffsetDiff(ctx) {
2673
+ var _a3;
2674
+ const state = ctx.state;
2675
+ const initialScroll = state.initialScroll;
2676
+ if (!state.didFinishInitialScroll || ((_a3 = state.scrollingTo) == null ? void 0 : _a3.isInitialScroll) || !initialScroll || initialScroll.viewPosition !== 1 || state.props.data.length === 0 || isOffsetInitialScrollSession(state)) {
2677
+ return;
2678
+ }
2679
+ const currentOffset = typeof state.lastNativeScroll === "number" && Number.isFinite(state.lastNativeScroll) ? state.lastNativeScroll : getObservedBootstrapInitialScrollOffset(state);
2680
+ return resolveInitialScrollOffset(ctx, initialScroll) - currentOffset;
2681
+ }
2682
+ function schedulePreservedEndAnchorCorrection(ctx) {
2683
+ if (getPreservedEndAnchorOffsetDiff(ctx) === void 0) {
2684
+ return false;
2685
+ }
2686
+ const correction = {};
2687
+ schedulePreservedEndAnchorCorrectionFrame(ctx, correction);
2688
+ return true;
2689
+ }
2690
+ function schedulePreservedEndAnchorCorrectionFrame(ctx, correction) {
2691
+ const state = ctx.state;
2692
+ state.preservedEndAnchorCorrection = correction;
2693
+ requestAnimationFrame(() => {
2694
+ var _a3;
2695
+ const activeCorrection = state.preservedEndAnchorCorrection;
2696
+ if (activeCorrection !== correction) {
2697
+ return;
2698
+ }
2699
+ const offsetDiff = getPreservedEndAnchorOffsetDiff(ctx);
2700
+ if (offsetDiff === void 0 || Math.abs(offsetDiff) <= DEFAULT_BOOTSTRAP_REVEAL_EPSILON) {
2701
+ state.preservedEndAnchorCorrection = void 0;
2702
+ return;
2703
+ }
2704
+ const hasObservedNativeScrollAfterRequest = !activeCorrection.lastRequestTime || ((_a3 = state.lastNativeScrollTime) != null ? _a3 : 0) > activeCorrection.lastRequestTime;
2705
+ if (hasObservedNativeScrollAfterRequest) {
2706
+ activeCorrection.lastRequestTime = Date.now();
2707
+ requestAdjust(ctx, offsetDiff);
2708
+ }
2709
+ schedulePreservedEndAnchorCorrectionFrame(ctx, correction);
2710
+ });
2711
+ }
2514
2712
  function clearFinishedBootstrapInitialScrollTargetIfMovedAway(ctx) {
2515
2713
  var _a3, _b;
2516
2714
  const state = ctx.state;
2517
2715
  const initialScroll = state.initialScroll;
2518
- if (!state.didFinishInitialScroll || ((_a3 = state.scrollingTo) == null ? void 0 : _a3.isInitialScroll) || (initialScroll == null ? void 0 : initialScroll.viewPosition) !== 1) {
2716
+ if (!state.didFinishInitialScroll || ((_a3 = state.scrollingTo) == null ? void 0 : _a3.isInitialScroll) || (initialScroll == null ? void 0 : initialScroll.viewPosition) !== 1 || state.preservedEndAnchorCorrection) {
2519
2717
  return;
2520
2718
  }
2521
2719
  if (didFinishedInitialScrollMoveAwayFromTarget(ctx, initialScroll)) {
@@ -2672,7 +2870,7 @@ function handleBootstrapInitialScrollFooterLayout(ctx, options) {
2672
2870
  }
2673
2871
  }
2674
2872
  function handleBootstrapInitialScrollLayoutChange(ctx) {
2675
- var _a3, _b, _c, _d;
2873
+ var _a3, _b, _c;
2676
2874
  const state = ctx.state;
2677
2875
  const initialScroll = state.initialScroll;
2678
2876
  const bootstrapInitialScroll = getBootstrapInitialScrollSession(state);
@@ -2683,7 +2881,9 @@ function handleBootstrapInitialScrollLayoutChange(ctx) {
2683
2881
  const currentOffset = scrollingTo ? (_b = scrollingTo.targetOffset) != null ? _b : scrollingTo.offset : getObservedBootstrapInitialScrollOffset(state);
2684
2882
  const offsetDiff = resolvedOffset - currentOffset;
2685
2883
  if (Math.abs(offsetDiff) > DEFAULT_BOOTSTRAP_REVEAL_EPSILON) {
2686
- if (scrollingTo) {
2884
+ if (state.didFinishInitialScroll) {
2885
+ schedulePreservedEndAnchorCorrection(ctx);
2886
+ } else if (scrollingTo) {
2687
2887
  const existingWatchdog = initialScrollWatchdog.get(state);
2688
2888
  scrollingTo.offset = resolvedOffset;
2689
2889
  scrollingTo.targetOffset = resolvedOffset;
@@ -2696,14 +2896,8 @@ function handleBootstrapInitialScrollLayoutChange(ctx) {
2696
2896
  startScroll: (_c = existingWatchdog == null ? void 0 : existingWatchdog.startScroll) != null ? _c : state.scroll,
2697
2897
  targetOffset: resolvedOffset
2698
2898
  });
2899
+ requestAdjust(ctx, offsetDiff);
2699
2900
  }
2700
- requestAdjust(ctx, offsetDiff);
2701
- if (state.didFinishInitialScroll) {
2702
- (_d = state.triggerCalculateItemsInView) == null ? void 0 : _d.call(state, { forceFullItemPositions: true });
2703
- }
2704
- }
2705
- if (state.didFinishInitialScroll) {
2706
- clearFinishedViewportRetargetableInitialScroll(state);
2707
2901
  }
2708
2902
  } else {
2709
2903
  rearmBootstrapInitialScroll(ctx, {
@@ -2820,7 +3014,10 @@ function retargetActiveInitialScrollAtEnd(ctx) {
2820
3014
  var _a3;
2821
3015
  const state = ctx.state;
2822
3016
  const initialScroll = state.initialScroll;
2823
- if (!initialScroll || state.didFinishInitialScroll || ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "offset" || initialScroll.viewPosition !== 1 || state.props.data.length === 0) {
3017
+ if (state.didFinishInitialScroll) {
3018
+ return schedulePreservedEndAnchorCorrection(ctx);
3019
+ }
3020
+ if (!initialScroll || ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "offset" || initialScroll.viewPosition !== 1 || state.props.data.length === 0) {
2824
3021
  return false;
2825
3022
  }
2826
3023
  return advanceCurrentInitialScrollSession(ctx, { forceScroll: true });
@@ -2839,7 +3036,14 @@ function handleInitialScrollLayoutReady(ctx) {
2839
3036
  }
2840
3037
  function initializeInitialScrollOnMount(ctx, options) {
2841
3038
  var _a3, _b;
2842
- const { dataLength, hasFooterComponent, initialContentOffset, initialScrollAtEnd, useBootstrapInitialScroll } = options;
3039
+ const {
3040
+ alwaysDispatchInitialScroll,
3041
+ dataLength,
3042
+ hasFooterComponent,
3043
+ initialContentOffset,
3044
+ initialScrollAtEnd,
3045
+ useBootstrapInitialScroll
3046
+ } = options;
2843
3047
  const state = ctx.state;
2844
3048
  const initialScroll = state.initialScroll;
2845
3049
  const resolvedInitialContentOffset = initialContentOffset != null ? initialContentOffset : 0;
@@ -2859,7 +3063,7 @@ function initializeInitialScrollOnMount(ctx, options) {
2859
3063
  return;
2860
3064
  }
2861
3065
  const hasPendingDataDependentInitialScroll = !!initialScroll && dataLength === 0 && !(resolvedInitialContentOffset === 0 && !initialScrollAtEnd);
2862
- if (!resolvedInitialContentOffset && !hasPendingDataDependentInitialScroll) {
3066
+ if (!alwaysDispatchInitialScroll && !resolvedInitialContentOffset && !hasPendingDataDependentInitialScroll) {
2863
3067
  if (initialScroll && !initialScrollAtEnd) {
2864
3068
  finishInitialScroll(ctx, {
2865
3069
  resolvedOffset: resolvedInitialContentOffset
@@ -3190,9 +3394,18 @@ function prepareMVCP(ctx, dataChanged) {
3190
3394
  }
3191
3395
  }
3192
3396
 
3397
+ // src/core/resetLayoutCachesForDataChange.ts
3398
+ function resetLayoutCachesForDataChange(state) {
3399
+ state.indexByKey.clear();
3400
+ state.idCache.length = 0;
3401
+ state.positions.length = 0;
3402
+ state.columns.length = 0;
3403
+ state.columnSpans.length = 0;
3404
+ }
3405
+
3193
3406
  // src/core/syncMountedContainer.ts
3194
3407
  function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
3195
- var _a3, _b, _c, _d, _e, _f, _g, _h;
3408
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
3196
3409
  const state = ctx.state;
3197
3410
  const {
3198
3411
  columns,
@@ -3204,7 +3417,8 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
3204
3417
  if (item === void 0) {
3205
3418
  return { didChangePosition: false, didRefreshData: false };
3206
3419
  }
3207
- const updateLayout = (_a3 = options == null ? void 0 : options.updateLayout) != null ? _a3 : true;
3420
+ const itemKey = (_a3 = state.idCache[itemIndex]) != null ? _a3 : getId(state, itemIndex);
3421
+ const updateLayout = (_b = options == null ? void 0 : options.updateLayout) != null ? _b : true;
3208
3422
  let didChangePosition = false;
3209
3423
  let didRefreshData = false;
3210
3424
  if (updateLayout) {
@@ -3213,7 +3427,9 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
3213
3427
  set$(ctx, `containerPosition${containerIndex}`, POSITION_OUT_OF_VIEW);
3214
3428
  return { didChangePosition: false, didRefreshData: false };
3215
3429
  }
3216
- const position = (positionValue || 0) - ((_b = options == null ? void 0 : options.scrollAdjustPending) != null ? _b : 0);
3430
+ const logicalPosition = (positionValue || 0) - ((_c = options == null ? void 0 : options.scrollAdjustPending) != null ? _c : 0);
3431
+ const itemSize = (_d = state.sizes.get(itemKey)) != null ? _d : getItemSize(ctx, itemKey, itemIndex, item);
3432
+ const position = toPhysicalHorizontalItemPosition(state, logicalPosition, itemSize, peek$(ctx, "totalSize"));
3217
3433
  const column = columns[itemIndex] || 1;
3218
3434
  const span = columnSpans[itemIndex] || 1;
3219
3435
  const prevPos = peek$(ctx, `containerPosition${containerIndex}`);
@@ -3232,15 +3448,15 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
3232
3448
  }
3233
3449
  const prevData = peek$(ctx, `containerItemData${containerIndex}`);
3234
3450
  if (prevData !== item) {
3235
- const pendingDataComparison = ((_c = state.pendingDataComparison) == null ? void 0 : _c.previousData) === state.previousData && ((_d = state.pendingDataComparison) == null ? void 0 : _d.nextData) === data ? state.pendingDataComparison : void 0;
3236
- const cachedComparison = (_e = pendingDataComparison == null ? void 0 : pendingDataComparison.byIndex[itemIndex]) != null ? _e : 0;
3451
+ const pendingDataComparison = ((_e = state.pendingDataComparison) == null ? void 0 : _e.previousData) === state.previousData && ((_f = state.pendingDataComparison) == null ? void 0 : _f.nextData) === data ? state.pendingDataComparison : void 0;
3452
+ const cachedComparison = (_g = pendingDataComparison == null ? void 0 : pendingDataComparison.byIndex[itemIndex]) != null ? _g : 0;
3237
3453
  if (cachedComparison === 2) {
3238
3454
  set$(ctx, `containerItemData${containerIndex}`, item);
3239
3455
  didRefreshData = true;
3240
3456
  } else if (cachedComparison !== 1) {
3241
- const itemKey = (_g = (_f = peek$(ctx, `containerItemKey${containerIndex}`)) != null ? _f : state.idCache[itemIndex]) != null ? _g : getId(state, itemIndex);
3457
+ const nextItemKey = (_h = peek$(ctx, `containerItemKey${containerIndex}`)) != null ? _h : itemKey;
3242
3458
  const prevKey = keyExtractor == null ? void 0 : keyExtractor(prevData, itemIndex);
3243
- if (prevData === void 0 || !keyExtractor || prevKey !== itemKey) {
3459
+ if (prevData === void 0 || !keyExtractor || prevKey !== nextItemKey) {
3244
3460
  set$(ctx, `containerItemData${containerIndex}`, item);
3245
3461
  didRefreshData = true;
3246
3462
  } else if (!itemsAreEqual) {
@@ -3257,7 +3473,7 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
3257
3473
  };
3258
3474
  }
3259
3475
  }
3260
- if ((_h = state.pendingDataComparison) == null ? void 0 : _h.byIndex) {
3476
+ if ((_i = state.pendingDataComparison) == null ? void 0 : _i.byIndex) {
3261
3477
  state.pendingDataComparison.byIndex[itemIndex] = isEqual ? 1 : 2;
3262
3478
  }
3263
3479
  if (!isEqual) {
@@ -3422,11 +3638,13 @@ function updateSnapToOffsets(ctx) {
3422
3638
  const {
3423
3639
  props: { snapToIndices }
3424
3640
  } = state;
3641
+ const contentSize = state.props.horizontal ? getContentSize(ctx) : void 0;
3425
3642
  const snapToOffsets = Array(snapToIndices.length);
3426
3643
  for (let i = 0; i < snapToIndices.length; i++) {
3427
3644
  const idx = snapToIndices[i];
3428
3645
  getId(state, idx);
3429
- snapToOffsets[i] = state.positions[idx];
3646
+ const logicalOffset = state.positions[idx];
3647
+ snapToOffsets[i] = toNativeHorizontalOffset(state, logicalOffset, contentSize);
3430
3648
  }
3431
3649
  set$(ctx, "snapToOffsets", snapToOffsets);
3432
3650
  }
@@ -4035,7 +4253,6 @@ function calculateItemsInView(ctx, params = {}) {
4035
4253
  var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
4036
4254
  const {
4037
4255
  columns,
4038
- columnSpans,
4039
4256
  containerItemKeys,
4040
4257
  enableScrollForNextCalculateItemsInView,
4041
4258
  idCache,
@@ -4085,8 +4302,10 @@ function calculateItemsInView(ctx, params = {}) {
4085
4302
  let scrollTopBuffered = 0;
4086
4303
  let scrollBottom = 0;
4087
4304
  let scrollBottomBuffered = 0;
4305
+ let nativeScrollState = scrollState;
4088
4306
  const updateScroll2 = (nextScrollState) => {
4089
4307
  var _a4;
4308
+ nativeScrollState = nextScrollState;
4090
4309
  scrollAdjustPending = (_a4 = peek$(ctx, "scrollAdjustPending")) != null ? _a4 : 0;
4091
4310
  scrollAdjustPad = scrollAdjustPending - topPad;
4092
4311
  scroll = Math.round(nextScrollState + scrollExtra + scrollAdjustPad);
@@ -4098,9 +4317,17 @@ function calculateItemsInView(ctx, params = {}) {
4098
4317
  const previousStickyIndex = peek$(ctx, "activeStickyIndex");
4099
4318
  const currentStickyIdx = stickyIndicesArr.length > 0 ? findCurrentStickyIndex(stickyIndicesArr, scroll, state) : -1;
4100
4319
  const nextActiveStickyIndex = currentStickyIdx >= 0 ? stickyIndicesArr[currentStickyIdx] : -1;
4320
+ const stickyIndexDidChange = previousStickyIndex !== nextActiveStickyIndex;
4101
4321
  if (currentStickyIdx >= 0 || previousStickyIndex >= 0) {
4102
4322
  set$(ctx, "activeStickyIndex", nextActiveStickyIndex);
4103
4323
  }
4324
+ const shouldNotifyStickyHeaderChange = !!onStickyHeaderChange && stickyIndicesArr.length > 0 && stickyIndexDidChange;
4325
+ const finishCalculateItemsInView = shouldNotifyStickyHeaderChange ? () => {
4326
+ const item = data[nextActiveStickyIndex];
4327
+ if (item !== void 0) {
4328
+ onStickyHeaderChange == null ? void 0 : onStickyHeaderChange({ index: nextActiveStickyIndex, item });
4329
+ }
4330
+ } : void 0;
4104
4331
  let scrollBufferTop = drawDistance;
4105
4332
  let scrollBufferBottom = drawDistance;
4106
4333
  if (speed > 0 || speed === 0 && scroll < Math.max(50, drawDistance)) {
@@ -4111,8 +4338,10 @@ function calculateItemsInView(ctx, params = {}) {
4111
4338
  scrollBufferBottom = drawDistance * 0.5;
4112
4339
  }
4113
4340
  const updateScrollRange = () => {
4114
- scrollTopBuffered = scroll - scrollBufferTop;
4115
- scrollBottom = scroll + scrollLength + (scroll < 0 ? -scroll : 0);
4341
+ const scrollStart = Math.max(0, scroll);
4342
+ const overscrollBeforeContent = Math.max(0, -nativeScrollState);
4343
+ scrollTopBuffered = scrollStart - scrollBufferTop;
4344
+ scrollBottom = Math.max(scrollStart, scroll + scrollLength + overscrollBeforeContent);
4116
4345
  scrollBottomBuffered = scrollBottom + scrollBufferBottom;
4117
4346
  };
4118
4347
  updateScrollRange();
@@ -4122,17 +4351,14 @@ function calculateItemsInView(ctx, params = {}) {
4122
4351
  state.scrollForNextCalculateItemsInView = void 0;
4123
4352
  } else if ((top === null || scrollTopBuffered > top) && (bottom === null || scrollBottomBuffered < bottom)) {
4124
4353
  if (Platform.OS !== "web" || !isInMVCPActiveMode(state)) {
4354
+ finishCalculateItemsInView == null ? void 0 : finishCalculateItemsInView();
4125
4355
  return;
4126
4356
  }
4127
4357
  }
4128
4358
  }
4129
4359
  const checkMVCP = doMVCP && !suppressInitialScrollSideEffects ? prepareMVCP(ctx, dataChanged) : void 0;
4130
4360
  if (dataChanged) {
4131
- indexByKey.clear();
4132
- idCache.length = 0;
4133
- positions.length = 0;
4134
- columns.length = 0;
4135
- columnSpans.length = 0;
4361
+ resetLayoutCachesForDataChange(state);
4136
4362
  }
4137
4363
  const startIndex = forceFullItemPositions || dataChanged ? 0 : (_c = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _c : 0;
4138
4364
  const optimizeForVisibleWindow = !forceFullItemPositions && !dataChanged && numColumns > 1 && minIndexSizeChanged !== void 0;
@@ -4446,12 +4672,7 @@ function calculateItemsInView(ctx, params = {}) {
4446
4672
  );
4447
4673
  }
4448
4674
  }
4449
- if (onStickyHeaderChange && stickyIndicesArr.length > 0 && nextActiveStickyIndex !== void 0 && nextActiveStickyIndex !== previousStickyIndex) {
4450
- const item = data[nextActiveStickyIndex];
4451
- if (item !== void 0) {
4452
- onStickyHeaderChange({ index: nextActiveStickyIndex, item });
4453
- }
4454
- }
4675
+ finishCalculateItemsInView == null ? void 0 : finishCalculateItemsInView();
4455
4676
  });
4456
4677
  }
4457
4678
 
@@ -4479,11 +4700,22 @@ function doMaintainScrollAtEnd(ctx) {
4479
4700
  if (!state.maintainingScrollAtEnd) {
4480
4701
  state.maintainingScrollAtEnd = true;
4481
4702
  requestAnimationFrame(() => {
4482
- var _a3;
4483
4703
  if (peek$(ctx, "isWithinMaintainScrollAtEndThreshold")) {
4484
- (_a3 = refScroller.current) == null ? void 0 : _a3.scrollToEnd({
4485
- animated: maintainScrollAtEnd.animated
4486
- });
4704
+ const scroller = refScroller.current;
4705
+ if (state.props.horizontal && isHorizontalRTL(state)) {
4706
+ const currentContentSize = getContentSize(ctx);
4707
+ const logicalEndOffset = getLogicalHorizontalMaxOffset(state, currentContentSize);
4708
+ const nativeOffset = toNativeHorizontalOffset(state, logicalEndOffset, currentContentSize);
4709
+ scroller == null ? void 0 : scroller.scrollTo({
4710
+ animated: maintainScrollAtEnd.animated,
4711
+ x: nativeOffset,
4712
+ y: 0
4713
+ });
4714
+ } else {
4715
+ scroller == null ? void 0 : scroller.scrollToEnd({
4716
+ animated: maintainScrollAtEnd.animated
4717
+ });
4718
+ }
4487
4719
  setTimeout(
4488
4720
  () => {
4489
4721
  state.maintainingScrollAtEnd = false;
@@ -4679,7 +4911,8 @@ function handleLayout(ctx, layoutParam, setCanRender) {
4679
4911
  }
4680
4912
  checkThresholds(ctx);
4681
4913
  if (state) {
4682
- state.needsOtherAxisSize = otherAxisSize - (state.props.stylePaddingTop || 0) < 10;
4914
+ const crossAxisPadding = state.props.horizontal ? (state.props.stylePaddingTop || 0) + (state.props.stylePaddingBottom || 0) : (state.props.stylePaddingLeft || 0) + (state.props.stylePaddingRight || 0);
4915
+ state.needsOtherAxisSize = otherAxisSize - crossAxisPadding < 10;
4683
4916
  }
4684
4917
  if (IS_DEV && measuredLength === 0) {
4685
4918
  warnDevOnce(
@@ -4798,7 +5031,7 @@ function cloneScrollEvent(event) {
4798
5031
  };
4799
5032
  }
4800
5033
  function onScroll(ctx, event) {
4801
- var _a3, _b, _c, _d;
5034
+ var _a3, _b, _c, _d, _e, _f;
4802
5035
  const state = ctx.state;
4803
5036
  const { scrollProcessingEnabled } = state;
4804
5037
  if (scrollProcessingEnabled === false) {
@@ -4817,6 +5050,16 @@ function onScroll(ctx, event) {
4817
5050
  }
4818
5051
  }
4819
5052
  let newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
5053
+ if (state.props.horizontal) {
5054
+ newScroll = toLogicalHorizontalOffset(state, newScroll, (_e = event.nativeEvent.contentSize) == null ? void 0 : _e.width);
5055
+ }
5056
+ const isFinishedEndInitialScroll = state.didFinishInitialScroll && ((_f = state.initialScroll) == null ? void 0 : _f.viewPosition) === 1 && state.scroll > state.scrollLength;
5057
+ const shouldIgnoreNegativeInsetChange = Platform.OS !== "web" && insetChanged && newScroll < 0 && isFinishedEndInitialScroll;
5058
+ if (shouldIgnoreNegativeInsetChange) {
5059
+ return;
5060
+ }
5061
+ state.lastNativeScroll = newScroll;
5062
+ state.lastNativeScrollTime = Date.now();
4820
5063
  if (state.scrollingTo && state.scrollingTo.offset >= newScroll) {
4821
5064
  const maxOffset = clampScrollOffset(ctx, newScroll, state.scrollingTo);
4822
5065
  if (newScroll !== maxOffset && Math.abs(newScroll - maxOffset) > 1) {
@@ -4990,6 +5233,16 @@ function runOrScheduleMVCPRecalculate(ctx) {
4990
5233
  calculateItemsInView(ctx, { doMVCP: true });
4991
5234
  }
4992
5235
  }
5236
+ function updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal) {
5237
+ const state = ctx.state;
5238
+ if (state.needsOtherAxisSize) {
5239
+ const otherAxisSize = horizontal ? sizeObj.height : sizeObj.width;
5240
+ const currentOtherAxisSize = peek$(ctx, "otherAxisSize");
5241
+ if (!currentOtherAxisSize || otherAxisSize > currentOtherAxisSize) {
5242
+ set$(ctx, "otherAxisSize", otherAxisSize);
5243
+ }
5244
+ }
5245
+ }
4993
5246
  function updateItemSize(ctx, itemKey, sizeObj) {
4994
5247
  var _a3;
4995
5248
  const state = ctx.state;
@@ -5013,13 +5266,13 @@ function updateItemSize(ctx, itemKey, sizeObj) {
5013
5266
  const type = getItemType ? (_a3 = getItemType(itemData, index)) != null ? _a3 : "" : "";
5014
5267
  const size2 = getFixedItemSize(itemData, index, type);
5015
5268
  if (size2 !== void 0 && size2 === sizesKnown.get(itemKey)) {
5269
+ updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal);
5016
5270
  return;
5017
5271
  }
5018
5272
  }
5019
5273
  let needsRecalculate = !didContainersLayout;
5020
5274
  let shouldMaintainScrollAtEnd = false;
5021
5275
  let minIndexSizeChanged;
5022
- let maxOtherAxisSize = peek$(ctx, "otherAxisSize") || 0;
5023
5276
  const prevSizeKnown = state.sizesKnown.get(itemKey);
5024
5277
  const diff = updateOneItemSize(ctx, itemKey, sizeObj);
5025
5278
  const size = roundSize(horizontal ? sizeObj.width : sizeObj.height);
@@ -5030,10 +5283,6 @@ function updateItemSize(ctx, itemKey, sizeObj) {
5030
5283
  if (!needsRecalculate && state.containerItemKeys.has(itemKey)) {
5031
5284
  needsRecalculate = true;
5032
5285
  }
5033
- if (state.needsOtherAxisSize) {
5034
- const otherAxisSize = horizontal ? sizeObj.height : sizeObj.width;
5035
- maxOtherAxisSize = Math.max(maxOtherAxisSize, otherAxisSize);
5036
- }
5037
5286
  if (prevSizeKnown !== void 0 && Math.abs(prevSizeKnown - size) > 5) {
5038
5287
  shouldMaintainScrollAtEnd = true;
5039
5288
  }
@@ -5049,10 +5298,7 @@ function updateItemSize(ctx, itemKey, sizeObj) {
5049
5298
  if (minIndexSizeChanged !== void 0) {
5050
5299
  state.minIndexSizeChanged = state.minIndexSizeChanged !== void 0 ? Math.min(state.minIndexSizeChanged, minIndexSizeChanged) : minIndexSizeChanged;
5051
5300
  }
5052
- const cur = peek$(ctx, "otherAxisSize");
5053
- if (!cur || maxOtherAxisSize > cur) {
5054
- set$(ctx, "otherAxisSize", maxOtherAxisSize);
5055
- }
5301
+ updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal);
5056
5302
  if (didContainersLayout || checkAllSizesKnown(state, getMountedBufferedIndices(state))) {
5057
5303
  if (needsRecalculate) {
5058
5304
  state.scrollForNextCalculateItemsInView = void 0;
@@ -5454,6 +5700,8 @@ function getAlwaysRenderIndices(config, data, keyExtractor, anchoredEndSpaceAnch
5454
5700
  indices.sort(sortAsc);
5455
5701
  return indices;
5456
5702
  }
5703
+
5704
+ // src/utils/getRenderedItem.ts
5457
5705
  function getRenderedItem(ctx, key) {
5458
5706
  var _a3;
5459
5707
  const state = ctx.state;
@@ -5479,7 +5727,7 @@ function getRenderedItem(ctx, key) {
5479
5727
  item,
5480
5728
  type: getItemType ? (_a3 = getItemType(item, index)) != null ? _a3 : "" : ""
5481
5729
  };
5482
- renderedItem = React2__default.createElement(renderItem, itemProps);
5730
+ renderedItem = renderItem(itemProps);
5483
5731
  }
5484
5732
  return { index, item: data[index], renderedItem };
5485
5733
  }
@@ -5640,7 +5888,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5640
5888
  getFixedItemSize,
5641
5889
  getItemType,
5642
5890
  horizontal,
5891
+ rtl,
5643
5892
  initialContainerPoolRatio = 3,
5893
+ estimatedHeaderSize,
5644
5894
  initialScrollAtEnd = false,
5645
5895
  initialScrollIndex: initialScrollIndexProp,
5646
5896
  initialScrollOffset: initialScrollOffsetProp,
@@ -5708,13 +5958,16 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5708
5958
  const style = { ...StyleSheet.flatten(styleProp) };
5709
5959
  const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
5710
5960
  const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
5961
+ const stylePaddingLeftState = extractPadding(style, contentContainerStyle, "Left");
5962
+ const stylePaddingRightState = extractPadding(style, contentContainerStyle, "Right");
5711
5963
  const maintainScrollAtEndConfig = normalizeMaintainScrollAtEnd(maintainScrollAtEnd);
5712
5964
  const maintainVisibleContentPositionConfig = normalizeMaintainVisibleContentPosition(
5713
5965
  maintainVisibleContentPositionProp
5714
5966
  );
5715
5967
  const hasInitialScrollIndex = initialScrollIndexProp !== void 0 && initialScrollIndexProp !== null;
5716
5968
  const hasInitialScrollOffset = initialScrollOffsetProp !== void 0 && initialScrollOffsetProp !== null;
5717
- const initialScrollUsesOffsetOnly = !initialScrollAtEnd && !hasInitialScrollIndex && hasInitialScrollOffset;
5969
+ const shouldInitializeHorizontalRTL = !initialScrollAtEnd && !hasInitialScrollIndex && !hasInitialScrollOffset && isHorizontalRTLProps({ horizontal, rtl });
5970
+ const initialScrollUsesOffsetOnly = !initialScrollAtEnd && !hasInitialScrollIndex && (hasInitialScrollOffset || shouldInitializeHorizontalRTL);
5718
5971
  const usesBootstrapInitialScroll = initialScrollAtEnd || hasInitialScrollIndex;
5719
5972
  const initialScrollProp = initialScrollAtEnd ? {
5720
5973
  index: Math.max(0, dataProp.length - 1),
@@ -5830,6 +6083,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5830
6083
  internalState.reprocessCurrentScroll = () => updateScroll(ctx, internalState.scroll, true);
5831
6084
  set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPositionConfig);
5832
6085
  set$(ctx, "extraData", extraData);
6086
+ if (estimatedHeaderSize !== void 0) {
6087
+ set$(ctx, "headerSize", estimatedHeaderSize);
6088
+ }
5833
6089
  }
5834
6090
  refState.current = ctx.state;
5835
6091
  }
@@ -5889,11 +6145,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5889
6145
  positionComponentInternal,
5890
6146
  recycleItems: !!recycleItems,
5891
6147
  renderItem,
6148
+ rtl,
5892
6149
  snapToIndices,
5893
6150
  stickyIndicesArr: stickyHeaderIndices != null ? stickyHeaderIndices : [],
5894
6151
  stickyIndicesSet: useMemo(() => new Set(stickyHeaderIndices != null ? stickyHeaderIndices : []), [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(",")]),
5895
6152
  stickyPositionComponentInternal,
5896
6153
  stylePaddingBottom: stylePaddingBottomState,
6154
+ stylePaddingLeft: stylePaddingLeftState,
6155
+ stylePaddingRight: stylePaddingRightState,
5897
6156
  stylePaddingTop: stylePaddingTopState,
5898
6157
  useWindowScroll: useWindowScrollResolved
5899
6158
  };
@@ -5921,6 +6180,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5921
6180
  };
5922
6181
  if (isFirstLocal) {
5923
6182
  initializeStateVars(false);
6183
+ resetLayoutCachesForDataChange(state);
5924
6184
  updateItemPositions(
5925
6185
  ctx,
5926
6186
  /*dataChanged*/
@@ -5938,6 +6198,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5938
6198
  }, [usesBootstrapInitialScroll]);
5939
6199
  useLayoutEffect(() => {
5940
6200
  initializeInitialScrollOnMount(ctx, {
6201
+ alwaysDispatchInitialScroll: shouldInitializeHorizontalRTL,
5941
6202
  dataLength: dataProp.length,
5942
6203
  hasFooterComponent: !!ListFooterComponent,
5943
6204
  initialContentOffset,