@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/react-native.js CHANGED
@@ -29,6 +29,111 @@ var ReactNative__namespace = /*#__PURE__*/_interopNamespace(ReactNative);
29
29
  ReactNative.Animated.View;
30
30
  var View = ReactNative.View;
31
31
  var Text = ReactNative.Text;
32
+ var Platform = ReactNative.Platform;
33
+ var PlatformAdjustBreaksScroll = Platform.OS === "android";
34
+
35
+ // src/utils/rtl.ts
36
+ function clampHorizontalOffset(offset, maxOffset) {
37
+ if (maxOffset === void 0) {
38
+ return offset;
39
+ }
40
+ return Math.max(0, Math.min(maxOffset, offset));
41
+ }
42
+ function getHorizontalMaxOffset(state, contentWidth) {
43
+ if (contentWidth === void 0 || !Number.isFinite(contentWidth) || !Number.isFinite(state.scrollLength) || contentWidth <= state.scrollLength) {
44
+ return contentWidth !== void 0 && Number.isFinite(contentWidth) && Number.isFinite(state.scrollLength) ? 0 : void 0;
45
+ }
46
+ return Math.max(0, contentWidth - state.scrollLength);
47
+ }
48
+ function getDefaultHorizontalRTLScrollType() {
49
+ return Platform.OS === "web" ? "normal" : "inverted";
50
+ }
51
+ function getNativeHorizontalRTLScrollType(state) {
52
+ var _a3;
53
+ return (_a3 = state == null ? void 0 : state.horizontalRTLScrollType) != null ? _a3 : getDefaultHorizontalRTLScrollType();
54
+ }
55
+ function isRTLProps(props) {
56
+ var _a3;
57
+ return (_a3 = props == null ? void 0 : props.rtl) != null ? _a3 : !!ReactNative.I18nManager.isRTL;
58
+ }
59
+ function isHorizontalRTL(state) {
60
+ return isHorizontalRTLProps(state == null ? void 0 : state.props);
61
+ }
62
+ function isHorizontalRTLProps(props) {
63
+ return !!(props == null ? void 0 : props.horizontal) && isRTLProps(props);
64
+ }
65
+ function getLogicalHorizontalMaxOffset(state, contentWidth) {
66
+ var _a3;
67
+ return (_a3 = getHorizontalMaxOffset(state, contentWidth)) != null ? _a3 : 0;
68
+ }
69
+ function getHorizontalInsetEnd(state, inset) {
70
+ if (!inset) {
71
+ return 0;
72
+ }
73
+ return (isHorizontalRTL(state) ? inset.left : inset.right) || 0;
74
+ }
75
+ function toPhysicalHorizontalItemPosition(state, logicalPosition, itemSize, listSize) {
76
+ if (!isHorizontalRTL(state) || listSize === void 0 || !Number.isFinite(listSize)) {
77
+ return logicalPosition;
78
+ }
79
+ return Math.max(0, listSize - logicalPosition - itemSize);
80
+ }
81
+ function toNativeHorizontalOffset(state, logicalOffset, contentWidth) {
82
+ if (!state || !isHorizontalRTL(state)) {
83
+ return logicalOffset;
84
+ }
85
+ const maxOffset = getHorizontalMaxOffset(state, contentWidth);
86
+ const clampedLogicalOffset = clampHorizontalOffset(logicalOffset, maxOffset);
87
+ const mode = getNativeHorizontalRTLScrollType(state);
88
+ if (mode === "negative") {
89
+ return clampedLogicalOffset === 0 ? 0 : -clampedLogicalOffset;
90
+ }
91
+ if (mode === "inverted") {
92
+ if (maxOffset === void 0) {
93
+ return clampedLogicalOffset;
94
+ }
95
+ return clampHorizontalOffset(maxOffset - clampedLogicalOffset, maxOffset);
96
+ }
97
+ return clampedLogicalOffset;
98
+ }
99
+ function toLogicalHorizontalOffset(state, rawOffset, contentWidth) {
100
+ if (!isHorizontalRTL(state)) {
101
+ state.horizontalRTLScrollType = void 0;
102
+ return rawOffset;
103
+ }
104
+ const maxOffset = getHorizontalMaxOffset(state, contentWidth);
105
+ if (rawOffset < 0) {
106
+ state.horizontalRTLScrollType = "negative";
107
+ return clampHorizontalOffset(-rawOffset, maxOffset);
108
+ }
109
+ if (maxOffset === void 0) {
110
+ return rawOffset;
111
+ }
112
+ const normalOffset = rawOffset;
113
+ const invertedOffset = maxOffset - rawOffset;
114
+ if (!Number.isFinite(invertedOffset)) {
115
+ state.horizontalRTLScrollType = "normal";
116
+ return normalOffset;
117
+ }
118
+ const previousMode = state.horizontalRTLScrollType;
119
+ if (previousMode === "inverted") {
120
+ return clampHorizontalOffset(invertedOffset, maxOffset);
121
+ }
122
+ if (previousMode === "normal") {
123
+ return clampHorizontalOffset(normalOffset, maxOffset);
124
+ }
125
+ if (!state.hasScrolled) {
126
+ const defaultMode = getDefaultHorizontalRTLScrollType();
127
+ state.horizontalRTLScrollType = defaultMode;
128
+ return clampHorizontalOffset(defaultMode === "inverted" ? invertedOffset : normalOffset, maxOffset);
129
+ }
130
+ const referenceScroll = state.scroll;
131
+ const distanceNormal = Math.abs(normalOffset - referenceScroll);
132
+ const distanceInverted = Math.abs(invertedOffset - referenceScroll);
133
+ const useInverted = distanceInverted + 0.5 < distanceNormal;
134
+ state.horizontalRTLScrollType = useInverted ? "inverted" : "normal";
135
+ return clampHorizontalOffset(useInverted ? invertedOffset : normalOffset, maxOffset);
136
+ }
32
137
  var createAnimatedValue = (value) => new ReactNative.Animated.Value(value);
33
138
 
34
139
  // src/state/state.tsx
@@ -170,7 +275,7 @@ function getContentInsetEnd(ctx, contentInsetEndAdjustmentOverride) {
170
275
  const horizontal = props.horizontal;
171
276
  const contentInset = props.contentInset;
172
277
  const baseInset = contentInset != null ? contentInset : state.nativeContentInset;
173
- const baseEndInset = (horizontal ? baseInset == null ? void 0 : baseInset.right : baseInset == null ? void 0 : baseInset.bottom) || 0;
278
+ const baseEndInset = (horizontal ? getHorizontalInsetEnd(state, baseInset) : baseInset == null ? void 0 : baseInset.bottom) || 0;
174
279
  const contentInsetEndAdjustment = getContentInsetEndAdjustmentEnd(
175
280
  contentInsetEndAdjustmentOverride != null ? contentInsetEndAdjustmentOverride : props.contentInsetEndAdjustment
176
281
  );
@@ -179,9 +284,9 @@ function getContentInsetEnd(ctx, contentInsetEndAdjustmentOverride) {
179
284
  const overrideInset = (_b = state.contentInsetOverride) != null ? _b : void 0;
180
285
  const adjustedBaseEndInset = baseEndInset + contentInsetEndAdjustment;
181
286
  if (overrideInset) {
182
- const mergedInset = { bottom: 0, right: 0, ...baseInset, ...overrideInset };
287
+ const mergedInset = { bottom: 0, left: 0, right: 0, ...baseInset, ...overrideInset };
183
288
  return Math.max(
184
- ((horizontal ? mergedInset.right : mergedInset.bottom) || 0) + contentInsetEndAdjustment,
289
+ ((horizontal ? getHorizontalInsetEnd(state, mergedInset) : mergedInset.bottom) || 0) + contentInsetEndAdjustment,
185
290
  anchoredEndInset
186
291
  );
187
292
  }
@@ -461,7 +566,8 @@ function comparatorDefault(a, b) {
461
566
  }
462
567
  function getPadding(s, type) {
463
568
  var _a3, _b, _c;
464
- return (_c = (_b = (_a3 = s[`padding${type}`]) != null ? _a3 : s.paddingVertical) != null ? _b : s.padding) != null ? _c : 0;
569
+ const axisPadding = type === "Left" || type === "Right" ? s.paddingHorizontal : s.paddingVertical;
570
+ return (_c = (_b = (_a3 = s[`padding${type}`]) != null ? _a3 : axisPadding) != null ? _b : s.padding) != null ? _c : 0;
465
571
  }
466
572
  function extractPadding(style, contentContainerStyle, type) {
467
573
  return getPadding(style, type) + getPadding(contentContainerStyle, type);
@@ -668,8 +774,6 @@ function useOnLayoutSync({
668
774
  }
669
775
  return { onLayout };
670
776
  }
671
- var Platform = ReactNative.Platform;
672
- var PlatformAdjustBreaksScroll = Platform.OS === "android";
673
777
 
674
778
  // src/utils/isInMVCPActiveMode.native.ts
675
779
  function isInMVCPActiveMode(state) {
@@ -681,6 +785,7 @@ function getContainerPositionStyle({
681
785
  columnWrapperStyle,
682
786
  horizontal,
683
787
  hasItemSeparator,
788
+ isHorizontalRTLList,
684
789
  numColumns,
685
790
  otherAxisPos,
686
791
  otherAxisSize
@@ -704,6 +809,7 @@ function getContainerPositionStyle({
704
809
  }
705
810
  return horizontal ? {
706
811
  boxSizing: paddingStyles ? "border-box" : void 0,
812
+ direction: isHorizontalRTLList && Platform.OS === "web" ? "ltr" : void 0,
707
813
  flexDirection: hasItemSeparator ? "row" : void 0,
708
814
  height: otherAxisSize,
709
815
  left: 0,
@@ -732,6 +838,7 @@ var Container = typedMemo(function Container2({
732
838
  }) {
733
839
  const ctx = useStateContext();
734
840
  const { columnWrapperStyle, animatedScrollY } = ctx;
841
+ const isHorizontalRTLList = isHorizontalRTL(ctx.state);
735
842
  const positionComponentInternal = ctx.state.props.positionComponentInternal;
736
843
  const stickyPositionComponentInternal = ctx.state.props.stickyPositionComponentInternal;
737
844
  const [column = 0, span = 1, data, numColumns = 1, extraData, isSticky] = useArr$([
@@ -763,11 +870,20 @@ var Container = typedMemo(function Container2({
763
870
  columnWrapperStyle,
764
871
  hasItemSeparator: !!ItemSeparatorComponent,
765
872
  horizontal,
873
+ isHorizontalRTLList,
766
874
  numColumns,
767
875
  otherAxisPos,
768
876
  otherAxisSize
769
877
  }),
770
- [horizontal, otherAxisPos, otherAxisSize, columnWrapperStyle, numColumns, ItemSeparatorComponent]
878
+ [
879
+ horizontal,
880
+ isHorizontalRTLList,
881
+ otherAxisPos,
882
+ otherAxisSize,
883
+ columnWrapperStyle,
884
+ numColumns,
885
+ ItemSeparatorComponent
886
+ ]
771
887
  );
772
888
  const renderedItemInfo = React2.useMemo(
773
889
  () => itemKey !== void 0 ? getRenderedItem2(itemKey) : null,
@@ -920,9 +1036,13 @@ var ContainersLayer = typedMemo(function ContainersLayer2({ children, horizontal
920
1036
  const ctx = useStateContext();
921
1037
  const columnWrapperStyle = ctx.columnWrapperStyle;
922
1038
  const animSize = useValue$("totalSize");
923
- const otherAxisSize = useValue$("otherAxisSize");
924
- const [readyToRender, numColumns] = useArr$(["readyToRender", "numColumns"]);
925
- const style = horizontal ? { minHeight: otherAxisSize, opacity: readyToRender ? 1 : 0, width: animSize } : { height: animSize, minWidth: otherAxisSize, opacity: readyToRender ? 1 : 0 };
1039
+ const [readyToRender, numColumns, otherAxisSize = 0] = useArr$(["readyToRender", "numColumns", "otherAxisSize"]);
1040
+ const style = horizontal ? {
1041
+ height: otherAxisSize || "100%",
1042
+ minHeight: otherAxisSize,
1043
+ opacity: readyToRender ? 1 : 0,
1044
+ width: animSize
1045
+ } : { height: animSize, minWidth: otherAxisSize, opacity: readyToRender ? 1 : 0 };
926
1046
  if (columnWrapperStyle) {
927
1047
  const { columnGap, rowGap, gap } = columnWrapperStyle;
928
1048
  const gapX = columnGap || gap || 0;
@@ -975,6 +1095,18 @@ var Containers = typedMemo(function Containers2({
975
1095
  return /* @__PURE__ */ React2__namespace.createElement(ContainersLayer, { horizontal }, containers);
976
1096
  });
977
1097
  var ListComponentScrollView = ReactNative.Animated.ScrollView;
1098
+
1099
+ // src/components/listComponentStyles.ts
1100
+ function getAutoOtherAxisStyle({
1101
+ horizontal,
1102
+ needsOtherAxisSize,
1103
+ otherAxisSize
1104
+ }) {
1105
+ if (!needsOtherAxisSize || !otherAxisSize || otherAxisSize <= 0) {
1106
+ return void 0;
1107
+ }
1108
+ return horizontal ? { height: otherAxisSize } : { width: otherAxisSize };
1109
+ }
978
1110
  function ScrollAdjust() {
979
1111
  var _a3;
980
1112
  const ctx = useStateContext();
@@ -995,10 +1127,10 @@ function ScrollAdjust() {
995
1127
  }
996
1128
  );
997
1129
  }
998
- function SnapWrapper({ ScrollComponent, ...props }) {
1130
+ var SnapWrapper = React2__namespace.forwardRef(function SnapWrapperInner({ ScrollComponent, ...props }, ref) {
999
1131
  const [snapToOffsets] = useArr$(["snapToOffsets"]);
1000
- return /* @__PURE__ */ React2__namespace.createElement(ScrollComponent, { ...props, snapToOffsets });
1001
- }
1132
+ return /* @__PURE__ */ React2__namespace.createElement(ScrollComponent, { ...props, ref, snapToOffsets });
1133
+ });
1002
1134
  function WebAnchoredEndSpace({ horizontal }) {
1003
1135
  const ctx = useStateContext();
1004
1136
  const [anchoredEndSpaceSize] = useArr$(["anchoredEndSpaceSize"]);
@@ -1009,6 +1141,26 @@ function WebAnchoredEndSpace({ horizontal }) {
1009
1141
  const style = horizontal ? { height: "100%", width: anchoredEndSpaceSize || 0 } : { height: anchoredEndSpaceSize || 0 };
1010
1142
  return /* @__PURE__ */ React2__namespace.createElement("div", { style }, null);
1011
1143
  }
1144
+ function useLatestRef(value) {
1145
+ const ref = React2__namespace.useRef(value);
1146
+ ref.current = value;
1147
+ return ref;
1148
+ }
1149
+
1150
+ // src/hooks/useStableRenderComponent.tsx
1151
+ function useStableRenderComponent(renderComponent, mapProps) {
1152
+ const renderComponentRef = useLatestRef(renderComponent);
1153
+ const mapPropsRef = useLatestRef(mapProps);
1154
+ return React2__namespace.useMemo(
1155
+ () => React2__namespace.forwardRef(
1156
+ (props, ref) => {
1157
+ var _a3, _b;
1158
+ return (_b = (_a3 = renderComponentRef.current) == null ? void 0 : _a3.call(renderComponentRef, mapPropsRef.current(props, ref))) != null ? _b : null;
1159
+ }
1160
+ ),
1161
+ [mapPropsRef, renderComponentRef]
1162
+ );
1163
+ }
1012
1164
  var LayoutView = ({ onLayoutChange, refView, ...rest }) => {
1013
1165
  const localRef = React2.useRef(null);
1014
1166
  const ref = refView != null ? refView : localRef;
@@ -1047,14 +1199,17 @@ var ListComponent = typedMemo(function ListComponent2({
1047
1199
  }) {
1048
1200
  const ctx = useStateContext();
1049
1201
  const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
1050
- const ScrollComponent = React2.useMemo(() => {
1051
- if (!renderScrollComponent) {
1052
- return ListComponentScrollView;
1053
- }
1054
- return React2__namespace.forwardRef(
1055
- (props, ref) => renderScrollComponent({ ...props, ref })
1056
- );
1057
- }, [renderScrollComponent]);
1202
+ const [otherAxisSize = 0] = useArr$(["otherAxisSize"]);
1203
+ const autoOtherAxisStyle = getAutoOtherAxisStyle({
1204
+ horizontal,
1205
+ needsOtherAxisSize: ctx.state.needsOtherAxisSize,
1206
+ otherAxisSize
1207
+ });
1208
+ const CustomScrollComponent = useStableRenderComponent(
1209
+ renderScrollComponent,
1210
+ (props, ref) => ({ ...props, ref })
1211
+ );
1212
+ const ScrollComponent = renderScrollComponent ? CustomScrollComponent : ListComponentScrollView;
1058
1213
  const SnapOrScroll = snapToIndices ? SnapWrapper : ScrollComponent;
1059
1214
  React2.useLayoutEffect(() => {
1060
1215
  if (!ListHeaderComponent) {
@@ -1085,10 +1240,10 @@ var ListComponent = typedMemo(function ListComponent2({
1085
1240
  ...rest,
1086
1241
  ...ScrollComponent === ListComponentScrollView ? { useWindowScroll } : {},
1087
1242
  contentContainerStyle: [
1088
- contentContainerStyle,
1089
1243
  horizontal ? {
1090
1244
  height: "100%"
1091
- } : {}
1245
+ } : {},
1246
+ contentContainerStyle
1092
1247
  ],
1093
1248
  contentOffset: initialContentOffset !== void 0 ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
1094
1249
  horizontal,
@@ -1097,7 +1252,7 @@ var ListComponent = typedMemo(function ListComponent2({
1097
1252
  onScroll: onScroll2,
1098
1253
  ref: refScrollView,
1099
1254
  ScrollComponent: snapToIndices ? ScrollComponent : void 0,
1100
- style
1255
+ style: autoOtherAxisStyle ? [autoOtherAxisStyle, style] : style
1101
1256
  },
1102
1257
  /* @__PURE__ */ React2__namespace.createElement(ScrollAdjust, null),
1103
1258
  ListHeaderComponent && /* @__PURE__ */ React2__namespace.createElement(LayoutView, { onLayoutChange: onLayoutHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
@@ -1957,10 +2112,13 @@ function doScrollTo(ctx, params) {
1957
2112
  if (!scroller) {
1958
2113
  return;
1959
2114
  }
2115
+ const isHorizontal = !!horizontal;
2116
+ const contentSize = isHorizontal ? getContentSize(ctx) : void 0;
2117
+ const nativeOffset = toNativeHorizontalOffset(state, offset, contentSize);
1960
2118
  scroller.scrollTo({
1961
2119
  animated: isAnimated,
1962
- x: horizontal ? offset : 0,
1963
- y: horizontal ? 0 : offset
2120
+ x: isHorizontal ? nativeOffset : 0,
2121
+ y: isHorizontal ? 0 : offset
1964
2122
  });
1965
2123
  if (isInitialScroll) {
1966
2124
  initialScrollCompletion.markInitialScrollNativeDispatch(state);
@@ -2532,11 +2690,51 @@ function getObservedBootstrapInitialScrollOffset(state) {
2532
2690
  const observedOffset = (_b = (_a3 = state.refScroller.current) == null ? void 0 : _a3.getCurrentScrollOffset) == null ? void 0 : _b.call(_a3);
2533
2691
  return typeof observedOffset === "number" && Number.isFinite(observedOffset) ? observedOffset : (_d = (_c = state.scrollPending) != null ? _c : state.scroll) != null ? _d : 0;
2534
2692
  }
2693
+ function getPreservedEndAnchorOffsetDiff(ctx) {
2694
+ var _a3;
2695
+ const state = ctx.state;
2696
+ const initialScroll = state.initialScroll;
2697
+ if (!state.didFinishInitialScroll || ((_a3 = state.scrollingTo) == null ? void 0 : _a3.isInitialScroll) || !initialScroll || initialScroll.viewPosition !== 1 || state.props.data.length === 0 || isOffsetInitialScrollSession(state)) {
2698
+ return;
2699
+ }
2700
+ const currentOffset = typeof state.lastNativeScroll === "number" && Number.isFinite(state.lastNativeScroll) ? state.lastNativeScroll : getObservedBootstrapInitialScrollOffset(state);
2701
+ return resolveInitialScrollOffset(ctx, initialScroll) - currentOffset;
2702
+ }
2703
+ function schedulePreservedEndAnchorCorrection(ctx) {
2704
+ if (getPreservedEndAnchorOffsetDiff(ctx) === void 0) {
2705
+ return false;
2706
+ }
2707
+ const correction = {};
2708
+ schedulePreservedEndAnchorCorrectionFrame(ctx, correction);
2709
+ return true;
2710
+ }
2711
+ function schedulePreservedEndAnchorCorrectionFrame(ctx, correction) {
2712
+ const state = ctx.state;
2713
+ state.preservedEndAnchorCorrection = correction;
2714
+ requestAnimationFrame(() => {
2715
+ var _a3;
2716
+ const activeCorrection = state.preservedEndAnchorCorrection;
2717
+ if (activeCorrection !== correction) {
2718
+ return;
2719
+ }
2720
+ const offsetDiff = getPreservedEndAnchorOffsetDiff(ctx);
2721
+ if (offsetDiff === void 0 || Math.abs(offsetDiff) <= DEFAULT_BOOTSTRAP_REVEAL_EPSILON) {
2722
+ state.preservedEndAnchorCorrection = void 0;
2723
+ return;
2724
+ }
2725
+ const hasObservedNativeScrollAfterRequest = !activeCorrection.lastRequestTime || ((_a3 = state.lastNativeScrollTime) != null ? _a3 : 0) > activeCorrection.lastRequestTime;
2726
+ if (hasObservedNativeScrollAfterRequest) {
2727
+ activeCorrection.lastRequestTime = Date.now();
2728
+ requestAdjust(ctx, offsetDiff);
2729
+ }
2730
+ schedulePreservedEndAnchorCorrectionFrame(ctx, correction);
2731
+ });
2732
+ }
2535
2733
  function clearFinishedBootstrapInitialScrollTargetIfMovedAway(ctx) {
2536
2734
  var _a3, _b;
2537
2735
  const state = ctx.state;
2538
2736
  const initialScroll = state.initialScroll;
2539
- if (!state.didFinishInitialScroll || ((_a3 = state.scrollingTo) == null ? void 0 : _a3.isInitialScroll) || (initialScroll == null ? void 0 : initialScroll.viewPosition) !== 1) {
2737
+ if (!state.didFinishInitialScroll || ((_a3 = state.scrollingTo) == null ? void 0 : _a3.isInitialScroll) || (initialScroll == null ? void 0 : initialScroll.viewPosition) !== 1 || state.preservedEndAnchorCorrection) {
2540
2738
  return;
2541
2739
  }
2542
2740
  if (didFinishedInitialScrollMoveAwayFromTarget(ctx, initialScroll)) {
@@ -2693,7 +2891,7 @@ function handleBootstrapInitialScrollFooterLayout(ctx, options) {
2693
2891
  }
2694
2892
  }
2695
2893
  function handleBootstrapInitialScrollLayoutChange(ctx) {
2696
- var _a3, _b, _c, _d;
2894
+ var _a3, _b, _c;
2697
2895
  const state = ctx.state;
2698
2896
  const initialScroll = state.initialScroll;
2699
2897
  const bootstrapInitialScroll = getBootstrapInitialScrollSession(state);
@@ -2704,7 +2902,9 @@ function handleBootstrapInitialScrollLayoutChange(ctx) {
2704
2902
  const currentOffset = scrollingTo ? (_b = scrollingTo.targetOffset) != null ? _b : scrollingTo.offset : getObservedBootstrapInitialScrollOffset(state);
2705
2903
  const offsetDiff = resolvedOffset - currentOffset;
2706
2904
  if (Math.abs(offsetDiff) > DEFAULT_BOOTSTRAP_REVEAL_EPSILON) {
2707
- if (scrollingTo) {
2905
+ if (state.didFinishInitialScroll) {
2906
+ schedulePreservedEndAnchorCorrection(ctx);
2907
+ } else if (scrollingTo) {
2708
2908
  const existingWatchdog = initialScrollWatchdog.get(state);
2709
2909
  scrollingTo.offset = resolvedOffset;
2710
2910
  scrollingTo.targetOffset = resolvedOffset;
@@ -2717,14 +2917,8 @@ function handleBootstrapInitialScrollLayoutChange(ctx) {
2717
2917
  startScroll: (_c = existingWatchdog == null ? void 0 : existingWatchdog.startScroll) != null ? _c : state.scroll,
2718
2918
  targetOffset: resolvedOffset
2719
2919
  });
2920
+ requestAdjust(ctx, offsetDiff);
2720
2921
  }
2721
- requestAdjust(ctx, offsetDiff);
2722
- if (state.didFinishInitialScroll) {
2723
- (_d = state.triggerCalculateItemsInView) == null ? void 0 : _d.call(state, { forceFullItemPositions: true });
2724
- }
2725
- }
2726
- if (state.didFinishInitialScroll) {
2727
- clearFinishedViewportRetargetableInitialScroll(state);
2728
2922
  }
2729
2923
  } else {
2730
2924
  rearmBootstrapInitialScroll(ctx, {
@@ -2841,7 +3035,10 @@ function retargetActiveInitialScrollAtEnd(ctx) {
2841
3035
  var _a3;
2842
3036
  const state = ctx.state;
2843
3037
  const initialScroll = state.initialScroll;
2844
- if (!initialScroll || state.didFinishInitialScroll || ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "offset" || initialScroll.viewPosition !== 1 || state.props.data.length === 0) {
3038
+ if (state.didFinishInitialScroll) {
3039
+ return schedulePreservedEndAnchorCorrection(ctx);
3040
+ }
3041
+ if (!initialScroll || ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "offset" || initialScroll.viewPosition !== 1 || state.props.data.length === 0) {
2845
3042
  return false;
2846
3043
  }
2847
3044
  return advanceCurrentInitialScrollSession(ctx, { forceScroll: true });
@@ -2860,7 +3057,14 @@ function handleInitialScrollLayoutReady(ctx) {
2860
3057
  }
2861
3058
  function initializeInitialScrollOnMount(ctx, options) {
2862
3059
  var _a3, _b;
2863
- const { dataLength, hasFooterComponent, initialContentOffset, initialScrollAtEnd, useBootstrapInitialScroll } = options;
3060
+ const {
3061
+ alwaysDispatchInitialScroll,
3062
+ dataLength,
3063
+ hasFooterComponent,
3064
+ initialContentOffset,
3065
+ initialScrollAtEnd,
3066
+ useBootstrapInitialScroll
3067
+ } = options;
2864
3068
  const state = ctx.state;
2865
3069
  const initialScroll = state.initialScroll;
2866
3070
  const resolvedInitialContentOffset = initialContentOffset != null ? initialContentOffset : 0;
@@ -2880,7 +3084,7 @@ function initializeInitialScrollOnMount(ctx, options) {
2880
3084
  return;
2881
3085
  }
2882
3086
  const hasPendingDataDependentInitialScroll = !!initialScroll && dataLength === 0 && !(resolvedInitialContentOffset === 0 && !initialScrollAtEnd);
2883
- if (!resolvedInitialContentOffset && !hasPendingDataDependentInitialScroll) {
3087
+ if (!alwaysDispatchInitialScroll && !resolvedInitialContentOffset && !hasPendingDataDependentInitialScroll) {
2884
3088
  if (initialScroll && !initialScrollAtEnd) {
2885
3089
  finishInitialScroll(ctx, {
2886
3090
  resolvedOffset: resolvedInitialContentOffset
@@ -3211,9 +3415,18 @@ function prepareMVCP(ctx, dataChanged) {
3211
3415
  }
3212
3416
  }
3213
3417
 
3418
+ // src/core/resetLayoutCachesForDataChange.ts
3419
+ function resetLayoutCachesForDataChange(state) {
3420
+ state.indexByKey.clear();
3421
+ state.idCache.length = 0;
3422
+ state.positions.length = 0;
3423
+ state.columns.length = 0;
3424
+ state.columnSpans.length = 0;
3425
+ }
3426
+
3214
3427
  // src/core/syncMountedContainer.ts
3215
3428
  function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
3216
- var _a3, _b, _c, _d, _e, _f, _g, _h;
3429
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
3217
3430
  const state = ctx.state;
3218
3431
  const {
3219
3432
  columns,
@@ -3225,7 +3438,8 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
3225
3438
  if (item === void 0) {
3226
3439
  return { didChangePosition: false, didRefreshData: false };
3227
3440
  }
3228
- const updateLayout = (_a3 = options == null ? void 0 : options.updateLayout) != null ? _a3 : true;
3441
+ const itemKey = (_a3 = state.idCache[itemIndex]) != null ? _a3 : getId(state, itemIndex);
3442
+ const updateLayout = (_b = options == null ? void 0 : options.updateLayout) != null ? _b : true;
3229
3443
  let didChangePosition = false;
3230
3444
  let didRefreshData = false;
3231
3445
  if (updateLayout) {
@@ -3234,7 +3448,9 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
3234
3448
  set$(ctx, `containerPosition${containerIndex}`, POSITION_OUT_OF_VIEW);
3235
3449
  return { didChangePosition: false, didRefreshData: false };
3236
3450
  }
3237
- const position = (positionValue || 0) - ((_b = options == null ? void 0 : options.scrollAdjustPending) != null ? _b : 0);
3451
+ const logicalPosition = (positionValue || 0) - ((_c = options == null ? void 0 : options.scrollAdjustPending) != null ? _c : 0);
3452
+ const itemSize = (_d = state.sizes.get(itemKey)) != null ? _d : getItemSize(ctx, itemKey, itemIndex, item);
3453
+ const position = toPhysicalHorizontalItemPosition(state, logicalPosition, itemSize, peek$(ctx, "totalSize"));
3238
3454
  const column = columns[itemIndex] || 1;
3239
3455
  const span = columnSpans[itemIndex] || 1;
3240
3456
  const prevPos = peek$(ctx, `containerPosition${containerIndex}`);
@@ -3253,15 +3469,15 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
3253
3469
  }
3254
3470
  const prevData = peek$(ctx, `containerItemData${containerIndex}`);
3255
3471
  if (prevData !== item) {
3256
- 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;
3257
- const cachedComparison = (_e = pendingDataComparison == null ? void 0 : pendingDataComparison.byIndex[itemIndex]) != null ? _e : 0;
3472
+ 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;
3473
+ const cachedComparison = (_g = pendingDataComparison == null ? void 0 : pendingDataComparison.byIndex[itemIndex]) != null ? _g : 0;
3258
3474
  if (cachedComparison === 2) {
3259
3475
  set$(ctx, `containerItemData${containerIndex}`, item);
3260
3476
  didRefreshData = true;
3261
3477
  } else if (cachedComparison !== 1) {
3262
- const itemKey = (_g = (_f = peek$(ctx, `containerItemKey${containerIndex}`)) != null ? _f : state.idCache[itemIndex]) != null ? _g : getId(state, itemIndex);
3478
+ const nextItemKey = (_h = peek$(ctx, `containerItemKey${containerIndex}`)) != null ? _h : itemKey;
3263
3479
  const prevKey = keyExtractor == null ? void 0 : keyExtractor(prevData, itemIndex);
3264
- if (prevData === void 0 || !keyExtractor || prevKey !== itemKey) {
3480
+ if (prevData === void 0 || !keyExtractor || prevKey !== nextItemKey) {
3265
3481
  set$(ctx, `containerItemData${containerIndex}`, item);
3266
3482
  didRefreshData = true;
3267
3483
  } else if (!itemsAreEqual) {
@@ -3278,7 +3494,7 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
3278
3494
  };
3279
3495
  }
3280
3496
  }
3281
- if ((_h = state.pendingDataComparison) == null ? void 0 : _h.byIndex) {
3497
+ if ((_i = state.pendingDataComparison) == null ? void 0 : _i.byIndex) {
3282
3498
  state.pendingDataComparison.byIndex[itemIndex] = isEqual ? 1 : 2;
3283
3499
  }
3284
3500
  if (!isEqual) {
@@ -3443,11 +3659,13 @@ function updateSnapToOffsets(ctx) {
3443
3659
  const {
3444
3660
  props: { snapToIndices }
3445
3661
  } = state;
3662
+ const contentSize = state.props.horizontal ? getContentSize(ctx) : void 0;
3446
3663
  const snapToOffsets = Array(snapToIndices.length);
3447
3664
  for (let i = 0; i < snapToIndices.length; i++) {
3448
3665
  const idx = snapToIndices[i];
3449
3666
  getId(state, idx);
3450
- snapToOffsets[i] = state.positions[idx];
3667
+ const logicalOffset = state.positions[idx];
3668
+ snapToOffsets[i] = toNativeHorizontalOffset(state, logicalOffset, contentSize);
3451
3669
  }
3452
3670
  set$(ctx, "snapToOffsets", snapToOffsets);
3453
3671
  }
@@ -4056,7 +4274,6 @@ function calculateItemsInView(ctx, params = {}) {
4056
4274
  var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
4057
4275
  const {
4058
4276
  columns,
4059
- columnSpans,
4060
4277
  containerItemKeys,
4061
4278
  enableScrollForNextCalculateItemsInView,
4062
4279
  idCache,
@@ -4106,8 +4323,10 @@ function calculateItemsInView(ctx, params = {}) {
4106
4323
  let scrollTopBuffered = 0;
4107
4324
  let scrollBottom = 0;
4108
4325
  let scrollBottomBuffered = 0;
4326
+ let nativeScrollState = scrollState;
4109
4327
  const updateScroll2 = (nextScrollState) => {
4110
4328
  var _a4;
4329
+ nativeScrollState = nextScrollState;
4111
4330
  scrollAdjustPending = (_a4 = peek$(ctx, "scrollAdjustPending")) != null ? _a4 : 0;
4112
4331
  scrollAdjustPad = scrollAdjustPending - topPad;
4113
4332
  scroll = Math.round(nextScrollState + scrollExtra + scrollAdjustPad);
@@ -4119,9 +4338,17 @@ function calculateItemsInView(ctx, params = {}) {
4119
4338
  const previousStickyIndex = peek$(ctx, "activeStickyIndex");
4120
4339
  const currentStickyIdx = stickyIndicesArr.length > 0 ? findCurrentStickyIndex(stickyIndicesArr, scroll, state) : -1;
4121
4340
  const nextActiveStickyIndex = currentStickyIdx >= 0 ? stickyIndicesArr[currentStickyIdx] : -1;
4341
+ const stickyIndexDidChange = previousStickyIndex !== nextActiveStickyIndex;
4122
4342
  if (currentStickyIdx >= 0 || previousStickyIndex >= 0) {
4123
4343
  set$(ctx, "activeStickyIndex", nextActiveStickyIndex);
4124
4344
  }
4345
+ const shouldNotifyStickyHeaderChange = !!onStickyHeaderChange && stickyIndicesArr.length > 0 && stickyIndexDidChange;
4346
+ const finishCalculateItemsInView = shouldNotifyStickyHeaderChange ? () => {
4347
+ const item = data[nextActiveStickyIndex];
4348
+ if (item !== void 0) {
4349
+ onStickyHeaderChange == null ? void 0 : onStickyHeaderChange({ index: nextActiveStickyIndex, item });
4350
+ }
4351
+ } : void 0;
4125
4352
  let scrollBufferTop = drawDistance;
4126
4353
  let scrollBufferBottom = drawDistance;
4127
4354
  if (speed > 0 || speed === 0 && scroll < Math.max(50, drawDistance)) {
@@ -4132,8 +4359,10 @@ function calculateItemsInView(ctx, params = {}) {
4132
4359
  scrollBufferBottom = drawDistance * 0.5;
4133
4360
  }
4134
4361
  const updateScrollRange = () => {
4135
- scrollTopBuffered = scroll - scrollBufferTop;
4136
- scrollBottom = scroll + scrollLength + (scroll < 0 ? -scroll : 0);
4362
+ const scrollStart = Math.max(0, scroll);
4363
+ const overscrollBeforeContent = Math.max(0, -nativeScrollState);
4364
+ scrollTopBuffered = scrollStart - scrollBufferTop;
4365
+ scrollBottom = Math.max(scrollStart, scroll + scrollLength + overscrollBeforeContent);
4137
4366
  scrollBottomBuffered = scrollBottom + scrollBufferBottom;
4138
4367
  };
4139
4368
  updateScrollRange();
@@ -4143,17 +4372,14 @@ function calculateItemsInView(ctx, params = {}) {
4143
4372
  state.scrollForNextCalculateItemsInView = void 0;
4144
4373
  } else if ((top === null || scrollTopBuffered > top) && (bottom === null || scrollBottomBuffered < bottom)) {
4145
4374
  if (Platform.OS !== "web" || !isInMVCPActiveMode(state)) {
4375
+ finishCalculateItemsInView == null ? void 0 : finishCalculateItemsInView();
4146
4376
  return;
4147
4377
  }
4148
4378
  }
4149
4379
  }
4150
4380
  const checkMVCP = doMVCP && !suppressInitialScrollSideEffects ? prepareMVCP(ctx, dataChanged) : void 0;
4151
4381
  if (dataChanged) {
4152
- indexByKey.clear();
4153
- idCache.length = 0;
4154
- positions.length = 0;
4155
- columns.length = 0;
4156
- columnSpans.length = 0;
4382
+ resetLayoutCachesForDataChange(state);
4157
4383
  }
4158
4384
  const startIndex = forceFullItemPositions || dataChanged ? 0 : (_c = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _c : 0;
4159
4385
  const optimizeForVisibleWindow = !forceFullItemPositions && !dataChanged && numColumns > 1 && minIndexSizeChanged !== void 0;
@@ -4467,12 +4693,7 @@ function calculateItemsInView(ctx, params = {}) {
4467
4693
  );
4468
4694
  }
4469
4695
  }
4470
- if (onStickyHeaderChange && stickyIndicesArr.length > 0 && nextActiveStickyIndex !== void 0 && nextActiveStickyIndex !== previousStickyIndex) {
4471
- const item = data[nextActiveStickyIndex];
4472
- if (item !== void 0) {
4473
- onStickyHeaderChange({ index: nextActiveStickyIndex, item });
4474
- }
4475
- }
4696
+ finishCalculateItemsInView == null ? void 0 : finishCalculateItemsInView();
4476
4697
  });
4477
4698
  }
4478
4699
 
@@ -4500,11 +4721,22 @@ function doMaintainScrollAtEnd(ctx) {
4500
4721
  if (!state.maintainingScrollAtEnd) {
4501
4722
  state.maintainingScrollAtEnd = true;
4502
4723
  requestAnimationFrame(() => {
4503
- var _a3;
4504
4724
  if (peek$(ctx, "isWithinMaintainScrollAtEndThreshold")) {
4505
- (_a3 = refScroller.current) == null ? void 0 : _a3.scrollToEnd({
4506
- animated: maintainScrollAtEnd.animated
4507
- });
4725
+ const scroller = refScroller.current;
4726
+ if (state.props.horizontal && isHorizontalRTL(state)) {
4727
+ const currentContentSize = getContentSize(ctx);
4728
+ const logicalEndOffset = getLogicalHorizontalMaxOffset(state, currentContentSize);
4729
+ const nativeOffset = toNativeHorizontalOffset(state, logicalEndOffset, currentContentSize);
4730
+ scroller == null ? void 0 : scroller.scrollTo({
4731
+ animated: maintainScrollAtEnd.animated,
4732
+ x: nativeOffset,
4733
+ y: 0
4734
+ });
4735
+ } else {
4736
+ scroller == null ? void 0 : scroller.scrollToEnd({
4737
+ animated: maintainScrollAtEnd.animated
4738
+ });
4739
+ }
4508
4740
  setTimeout(
4509
4741
  () => {
4510
4742
  state.maintainingScrollAtEnd = false;
@@ -4700,7 +4932,8 @@ function handleLayout(ctx, layoutParam, setCanRender) {
4700
4932
  }
4701
4933
  checkThresholds(ctx);
4702
4934
  if (state) {
4703
- state.needsOtherAxisSize = otherAxisSize - (state.props.stylePaddingTop || 0) < 10;
4935
+ const crossAxisPadding = state.props.horizontal ? (state.props.stylePaddingTop || 0) + (state.props.stylePaddingBottom || 0) : (state.props.stylePaddingLeft || 0) + (state.props.stylePaddingRight || 0);
4936
+ state.needsOtherAxisSize = otherAxisSize - crossAxisPadding < 10;
4704
4937
  }
4705
4938
  if (IS_DEV && measuredLength === 0) {
4706
4939
  warnDevOnce(
@@ -4819,7 +5052,7 @@ function cloneScrollEvent(event) {
4819
5052
  };
4820
5053
  }
4821
5054
  function onScroll(ctx, event) {
4822
- var _a3, _b, _c, _d;
5055
+ var _a3, _b, _c, _d, _e, _f;
4823
5056
  const state = ctx.state;
4824
5057
  const { scrollProcessingEnabled } = state;
4825
5058
  if (scrollProcessingEnabled === false) {
@@ -4838,6 +5071,16 @@ function onScroll(ctx, event) {
4838
5071
  }
4839
5072
  }
4840
5073
  let newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
5074
+ if (state.props.horizontal) {
5075
+ newScroll = toLogicalHorizontalOffset(state, newScroll, (_e = event.nativeEvent.contentSize) == null ? void 0 : _e.width);
5076
+ }
5077
+ const isFinishedEndInitialScroll = state.didFinishInitialScroll && ((_f = state.initialScroll) == null ? void 0 : _f.viewPosition) === 1 && state.scroll > state.scrollLength;
5078
+ const shouldIgnoreNegativeInsetChange = Platform.OS !== "web" && insetChanged && newScroll < 0 && isFinishedEndInitialScroll;
5079
+ if (shouldIgnoreNegativeInsetChange) {
5080
+ return;
5081
+ }
5082
+ state.lastNativeScroll = newScroll;
5083
+ state.lastNativeScrollTime = Date.now();
4841
5084
  if (state.scrollingTo && state.scrollingTo.offset >= newScroll) {
4842
5085
  const maxOffset = clampScrollOffset(ctx, newScroll, state.scrollingTo);
4843
5086
  if (newScroll !== maxOffset && Math.abs(newScroll - maxOffset) > 1) {
@@ -5011,6 +5254,16 @@ function runOrScheduleMVCPRecalculate(ctx) {
5011
5254
  calculateItemsInView(ctx, { doMVCP: true });
5012
5255
  }
5013
5256
  }
5257
+ function updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal) {
5258
+ const state = ctx.state;
5259
+ if (state.needsOtherAxisSize) {
5260
+ const otherAxisSize = horizontal ? sizeObj.height : sizeObj.width;
5261
+ const currentOtherAxisSize = peek$(ctx, "otherAxisSize");
5262
+ if (!currentOtherAxisSize || otherAxisSize > currentOtherAxisSize) {
5263
+ set$(ctx, "otherAxisSize", otherAxisSize);
5264
+ }
5265
+ }
5266
+ }
5014
5267
  function updateItemSize(ctx, itemKey, sizeObj) {
5015
5268
  var _a3;
5016
5269
  const state = ctx.state;
@@ -5034,13 +5287,13 @@ function updateItemSize(ctx, itemKey, sizeObj) {
5034
5287
  const type = getItemType ? (_a3 = getItemType(itemData, index)) != null ? _a3 : "" : "";
5035
5288
  const size2 = getFixedItemSize(itemData, index, type);
5036
5289
  if (size2 !== void 0 && size2 === sizesKnown.get(itemKey)) {
5290
+ updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal);
5037
5291
  return;
5038
5292
  }
5039
5293
  }
5040
5294
  let needsRecalculate = !didContainersLayout;
5041
5295
  let shouldMaintainScrollAtEnd = false;
5042
5296
  let minIndexSizeChanged;
5043
- let maxOtherAxisSize = peek$(ctx, "otherAxisSize") || 0;
5044
5297
  const prevSizeKnown = state.sizesKnown.get(itemKey);
5045
5298
  const diff = updateOneItemSize(ctx, itemKey, sizeObj);
5046
5299
  const size = roundSize(horizontal ? sizeObj.width : sizeObj.height);
@@ -5051,10 +5304,6 @@ function updateItemSize(ctx, itemKey, sizeObj) {
5051
5304
  if (!needsRecalculate && state.containerItemKeys.has(itemKey)) {
5052
5305
  needsRecalculate = true;
5053
5306
  }
5054
- if (state.needsOtherAxisSize) {
5055
- const otherAxisSize = horizontal ? sizeObj.height : sizeObj.width;
5056
- maxOtherAxisSize = Math.max(maxOtherAxisSize, otherAxisSize);
5057
- }
5058
5307
  if (prevSizeKnown !== void 0 && Math.abs(prevSizeKnown - size) > 5) {
5059
5308
  shouldMaintainScrollAtEnd = true;
5060
5309
  }
@@ -5070,10 +5319,7 @@ function updateItemSize(ctx, itemKey, sizeObj) {
5070
5319
  if (minIndexSizeChanged !== void 0) {
5071
5320
  state.minIndexSizeChanged = state.minIndexSizeChanged !== void 0 ? Math.min(state.minIndexSizeChanged, minIndexSizeChanged) : minIndexSizeChanged;
5072
5321
  }
5073
- const cur = peek$(ctx, "otherAxisSize");
5074
- if (!cur || maxOtherAxisSize > cur) {
5075
- set$(ctx, "otherAxisSize", maxOtherAxisSize);
5076
- }
5322
+ updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal);
5077
5323
  if (didContainersLayout || checkAllSizesKnown(state, getMountedBufferedIndices(state))) {
5078
5324
  if (needsRecalculate) {
5079
5325
  state.scrollForNextCalculateItemsInView = void 0;
@@ -5475,6 +5721,8 @@ function getAlwaysRenderIndices(config, data, keyExtractor, anchoredEndSpaceAnch
5475
5721
  indices.sort(sortAsc);
5476
5722
  return indices;
5477
5723
  }
5724
+
5725
+ // src/utils/getRenderedItem.ts
5478
5726
  function getRenderedItem(ctx, key) {
5479
5727
  var _a3;
5480
5728
  const state = ctx.state;
@@ -5500,7 +5748,7 @@ function getRenderedItem(ctx, key) {
5500
5748
  item,
5501
5749
  type: getItemType ? (_a3 = getItemType(item, index)) != null ? _a3 : "" : ""
5502
5750
  };
5503
- renderedItem = React2__namespace.default.createElement(renderItem, itemProps);
5751
+ renderedItem = renderItem(itemProps);
5504
5752
  }
5505
5753
  return { index, item: data[index], renderedItem };
5506
5754
  }
@@ -5661,7 +5909,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5661
5909
  getFixedItemSize,
5662
5910
  getItemType,
5663
5911
  horizontal,
5912
+ rtl,
5664
5913
  initialContainerPoolRatio = 3,
5914
+ estimatedHeaderSize,
5665
5915
  initialScrollAtEnd = false,
5666
5916
  initialScrollIndex: initialScrollIndexProp,
5667
5917
  initialScrollOffset: initialScrollOffsetProp,
@@ -5729,13 +5979,16 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5729
5979
  const style = { ...StyleSheet.flatten(styleProp) };
5730
5980
  const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
5731
5981
  const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
5982
+ const stylePaddingLeftState = extractPadding(style, contentContainerStyle, "Left");
5983
+ const stylePaddingRightState = extractPadding(style, contentContainerStyle, "Right");
5732
5984
  const maintainScrollAtEndConfig = normalizeMaintainScrollAtEnd(maintainScrollAtEnd);
5733
5985
  const maintainVisibleContentPositionConfig = normalizeMaintainVisibleContentPosition(
5734
5986
  maintainVisibleContentPositionProp
5735
5987
  );
5736
5988
  const hasInitialScrollIndex = initialScrollIndexProp !== void 0 && initialScrollIndexProp !== null;
5737
5989
  const hasInitialScrollOffset = initialScrollOffsetProp !== void 0 && initialScrollOffsetProp !== null;
5738
- const initialScrollUsesOffsetOnly = !initialScrollAtEnd && !hasInitialScrollIndex && hasInitialScrollOffset;
5990
+ const shouldInitializeHorizontalRTL = !initialScrollAtEnd && !hasInitialScrollIndex && !hasInitialScrollOffset && isHorizontalRTLProps({ horizontal, rtl });
5991
+ const initialScrollUsesOffsetOnly = !initialScrollAtEnd && !hasInitialScrollIndex && (hasInitialScrollOffset || shouldInitializeHorizontalRTL);
5739
5992
  const usesBootstrapInitialScroll = initialScrollAtEnd || hasInitialScrollIndex;
5740
5993
  const initialScrollProp = initialScrollAtEnd ? {
5741
5994
  index: Math.max(0, dataProp.length - 1),
@@ -5851,6 +6104,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5851
6104
  internalState.reprocessCurrentScroll = () => updateScroll(ctx, internalState.scroll, true);
5852
6105
  set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPositionConfig);
5853
6106
  set$(ctx, "extraData", extraData);
6107
+ if (estimatedHeaderSize !== void 0) {
6108
+ set$(ctx, "headerSize", estimatedHeaderSize);
6109
+ }
5854
6110
  }
5855
6111
  refState.current = ctx.state;
5856
6112
  }
@@ -5910,11 +6166,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5910
6166
  positionComponentInternal,
5911
6167
  recycleItems: !!recycleItems,
5912
6168
  renderItem,
6169
+ rtl,
5913
6170
  snapToIndices,
5914
6171
  stickyIndicesArr: stickyHeaderIndices != null ? stickyHeaderIndices : [],
5915
6172
  stickyIndicesSet: React2.useMemo(() => new Set(stickyHeaderIndices != null ? stickyHeaderIndices : []), [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(",")]),
5916
6173
  stickyPositionComponentInternal,
5917
6174
  stylePaddingBottom: stylePaddingBottomState,
6175
+ stylePaddingLeft: stylePaddingLeftState,
6176
+ stylePaddingRight: stylePaddingRightState,
5918
6177
  stylePaddingTop: stylePaddingTopState,
5919
6178
  useWindowScroll: useWindowScrollResolved
5920
6179
  };
@@ -5942,6 +6201,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5942
6201
  };
5943
6202
  if (isFirstLocal) {
5944
6203
  initializeStateVars(false);
6204
+ resetLayoutCachesForDataChange(state);
5945
6205
  updateItemPositions(
5946
6206
  ctx,
5947
6207
  /*dataChanged*/
@@ -5959,6 +6219,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
5959
6219
  }, [usesBootstrapInitialScroll]);
5960
6220
  React2.useLayoutEffect(() => {
5961
6221
  initializeInitialScrollOnMount(ctx, {
6222
+ alwaysDispatchInitialScroll: shouldInitializeHorizontalRTL,
5962
6223
  dataLength: dataProp.length,
5963
6224
  hasFooterComponent: !!ListFooterComponent,
5964
6225
  initialContentOffset,
@@ -6197,6 +6458,8 @@ var internal = {
6197
6458
  typedMemo,
6198
6459
  useArr$,
6199
6460
  useCombinedRef,
6461
+ useLatestRef,
6462
+ useStableRenderComponent,
6200
6463
  useStateContext
6201
6464
  };
6202
6465