@office-iss/react-native-win32 0.75.2 → 0.76.0-preview.2

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.
Files changed (178) hide show
  1. package/.eslintrc.js +11 -0
  2. package/.flowconfig +5 -4
  3. package/CHANGELOG.json +191 -47
  4. package/CHANGELOG.md +63 -28
  5. package/Libraries/Alert/Alert.js +3 -0
  6. package/Libraries/Animated/AnimatedEvent.js +1 -1
  7. package/Libraries/Animated/AnimatedImplementation.js +7 -7
  8. package/Libraries/Animated/NativeAnimatedAllowlist.js +111 -0
  9. package/Libraries/Animated/animations/Animation.js +11 -1
  10. package/Libraries/Animated/animations/DecayAnimation.js +1 -1
  11. package/Libraries/Animated/animations/SpringAnimation.js +1 -1
  12. package/Libraries/Animated/animations/TimingAnimation.js +2 -1
  13. package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
  14. package/Libraries/Animated/createAnimatedComponent.js +10 -9
  15. package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
  16. package/Libraries/Animated/nodes/AnimatedInterpolation.js +3 -2
  17. package/Libraries/Animated/nodes/AnimatedNode.js +42 -33
  18. package/Libraries/Animated/nodes/AnimatedObject.js +56 -50
  19. package/Libraries/Animated/nodes/AnimatedProps.js +77 -40
  20. package/Libraries/Animated/nodes/AnimatedStyle.js +103 -59
  21. package/Libraries/Animated/nodes/AnimatedTracking.js +1 -1
  22. package/Libraries/Animated/nodes/AnimatedTransform.js +102 -67
  23. package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
  24. package/Libraries/Animated/nodes/AnimatedWithChildren.js +21 -22
  25. package/Libraries/Animated/useAnimatedProps.js +142 -7
  26. package/Libraries/BatchedBridge/NativeModules.js +2 -0
  27. package/Libraries/Blob/FileReader.js +1 -1
  28. package/Libraries/Blob/URL.js +2 -62
  29. package/Libraries/Blob/URLSearchParams.js +71 -0
  30. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
  31. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +17 -0
  32. package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
  33. package/Libraries/Components/ScrollView/ScrollView.js +131 -169
  34. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +3 -0
  35. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
  36. package/Libraries/Components/StatusBar/StatusBar.js +3 -1
  37. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +10 -0
  38. package/Libraries/Components/TextInput/TextInput.d.ts +32 -2
  39. package/Libraries/Components/TextInput/TextInput.js +230 -94
  40. package/Libraries/Components/TextInput/TextInput.win32.js +230 -100
  41. package/Libraries/Components/View/ReactNativeStyleAttributes.js +23 -1
  42. package/Libraries/Components/View/ReactNativeViewAttributes.js +2 -0
  43. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +2 -0
  44. package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  45. package/Libraries/Components/View/ViewNativeComponent.js +0 -1
  46. package/Libraries/Components/View/ViewPropTypes.js +14 -0
  47. package/Libraries/Components/View/ViewPropTypes.win32.js +14 -0
  48. package/Libraries/Core/ExceptionsManager.js +2 -0
  49. package/Libraries/Core/InitializeCore.js +3 -1
  50. package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
  51. package/Libraries/Core/ReactNativeVersion.js +4 -4
  52. package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -1
  53. package/Libraries/Core/setUpDeveloperTools.js +5 -1
  54. package/Libraries/Core/setUpErrorHandling.js +7 -1
  55. package/Libraries/Core/setUpGlobals.js +1 -0
  56. package/Libraries/Core/setUpReactRefresh.js +0 -4
  57. package/Libraries/Image/AssetSourceResolver.js +28 -1
  58. package/Libraries/Image/Image.android.js +9 -14
  59. package/Libraries/Image/Image.ios.js +11 -22
  60. package/Libraries/Image/Image.win32.js +11 -24
  61. package/Libraries/Image/ImageBackground.js +1 -8
  62. package/Libraries/Image/ImageUtils.js +9 -9
  63. package/Libraries/Image/ImageViewNativeComponent.js +1 -0
  64. package/Libraries/Inspector/Inspector.js +3 -2
  65. package/Libraries/Inspector/Inspector.win32.js +3 -2
  66. package/Libraries/Inspector/InspectorPanel.js +16 -10
  67. package/Libraries/Inspector/NetworkOverlay.js +1 -1
  68. package/Libraries/Interaction/TaskQueue.js +1 -0
  69. package/Libraries/Lists/FlatList.js +1 -1
  70. package/Libraries/Lists/SectionList.js +2 -2
  71. package/Libraries/Lists/SectionListModern.js +3 -3
  72. package/Libraries/LogBox/Data/LogBoxData.js +24 -3
  73. package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -2
  74. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +9 -8
  75. package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +9 -29
  76. package/Libraries/Modal/Modal.js +0 -1
  77. package/Libraries/NativeComponent/BaseViewConfig.android.js +9 -1
  78. package/Libraries/NativeComponent/BaseViewConfig.ios.js +17 -1
  79. package/Libraries/NativeComponent/BaseViewConfig.win32.js +17 -1
  80. package/Libraries/NativeComponent/NativeComponentRegistry.js +22 -22
  81. package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -21
  82. package/Libraries/Network/XMLHttpRequest.js +4 -2
  83. package/Libraries/ReactNative/AppContainer-dev.js +1 -5
  84. package/Libraries/ReactNative/AppContainer-prod.js +1 -5
  85. package/Libraries/ReactNative/AppContainer.js +0 -1
  86. package/Libraries/ReactNative/AppRegistry.js +0 -6
  87. package/Libraries/ReactNative/BridgelessUIManager.js +1 -0
  88. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +1 -1
  89. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +5 -5
  90. package/Libraries/ReactNative/RendererImplementation.js +26 -4
  91. package/Libraries/ReactNative/getNativeComponentAttributes.js +12 -0
  92. package/Libraries/ReactNative/renderApplication.js +0 -2
  93. package/Libraries/Renderer/shims/ReactNativeTypes.js +11 -4
  94. package/Libraries/StyleSheet/StyleSheet.js +1 -1
  95. package/Libraries/StyleSheet/StyleSheet.win32.js +1 -1
  96. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +152 -2
  97. package/Libraries/StyleSheet/StyleSheetTypes.js +60 -5
  98. package/Libraries/StyleSheet/processBackgroundImage.js +384 -0
  99. package/Libraries/StyleSheet/processBoxShadow.js +209 -0
  100. package/Libraries/StyleSheet/processFilter.js +231 -42
  101. package/Libraries/Text/Text.js +394 -196
  102. package/Libraries/Text/Text.win32.js +442 -229
  103. package/Libraries/Text/TextNativeComponent.js +2 -1
  104. package/Libraries/Text/TextNativeComponent.win32.js +1 -1
  105. package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
  106. package/Libraries/Types/CodegenTypes.js +3 -1
  107. package/Libraries/Utilities/Appearance.js +108 -84
  108. package/Libraries/Utilities/DevLoadingView.js +2 -4
  109. package/Libraries/Utilities/HMRClient.js +8 -6
  110. package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
  111. package/Libraries/Utilities/createPerformanceLogger.js +0 -9
  112. package/Libraries/Utilities/stringifyViewConfig.js +22 -0
  113. package/Libraries/Utilities/useColorScheme.js +3 -3
  114. package/Libraries/WebSocket/WebSocket.js +1 -1
  115. package/Libraries/promiseRejectionTrackingOptions.js +1 -1
  116. package/Libraries/vendor/emitter/EventEmitter.js +6 -5
  117. package/flow/jest.js +2 -2
  118. package/index.js +3 -1
  119. package/index.win32.js +3 -1
  120. package/jest/mockComponent.js +4 -1
  121. package/jest/mockModal.js +1 -3
  122. package/jest/mockScrollView.js +1 -1
  123. package/jest/renderer.js +2 -2
  124. package/jest/setup.js +16 -13
  125. package/jest.config.js +1 -2
  126. package/overrides.json +22 -22
  127. package/package.json +32 -30
  128. package/src/private/animated/NativeAnimatedHelper.js +438 -0
  129. package/src/private/animated/NativeAnimatedHelper.win32.js +440 -0
  130. package/src/private/animated/NativeAnimatedValidation.js +64 -0
  131. package/src/private/components/HScrollViewNativeComponents.js +56 -0
  132. package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +29 -0
  133. package/src/private/components/VScrollViewNativeComponents.js +48 -0
  134. package/src/private/components/useSyncOnScroll.js +48 -0
  135. package/src/private/featureflags/ReactNativeFeatureFlags.js +166 -16
  136. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +29 -5
  137. package/src/private/fusebox/FuseboxSessionObserver.js +42 -0
  138. package/{Libraries/Core → src/private/renderer/errorhandling}/ErrorHandlers.js +14 -4
  139. package/src/private/setup/setUpDOM.js +28 -0
  140. package/src/private/setup/setUpIntersectionObserver.js +27 -0
  141. package/src/private/setup/setUpMutationObserver.js +26 -0
  142. package/src/private/setup/setUpPerformanceObserver.js +64 -0
  143. package/src/private/specs/modules/NativeAppearance.js +3 -3
  144. package/src/private/specs/modules/NativeLinkingManager.js +1 -1
  145. package/src/private/specs/modules/NativePlatformConstantsWin.js +7 -0
  146. package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
  147. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -4
  148. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserver.js +5 -3
  149. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverEntry.js +3 -3
  150. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverManager.js +14 -17
  151. package/src/private/{specs/modules → webapis/intersectionobserver/specs}/NativeIntersectionObserver.js +2 -2
  152. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver/specs}/__mocks__/NativeIntersectionObserver.js +4 -4
  153. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserver.js +5 -3
  154. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserverManager.js +24 -15
  155. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationRecord.js +4 -6
  156. package/src/private/{specs/modules → webapis/mutationobserver/specs}/NativeMutationObserver.js +2 -2
  157. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver/specs}/__mocks__/NativeMutationObserver.js +5 -5
  158. package/src/private/webapis/performance/{EventCounts.js → EventTiming.js} +65 -3
  159. package/src/private/webapis/performance/LongTasks.js +39 -0
  160. package/src/private/webapis/performance/Performance.js +22 -9
  161. package/src/private/webapis/performance/PerformanceEntry.js +36 -18
  162. package/src/private/webapis/performance/PerformanceObserver.js +29 -43
  163. package/src/private/webapis/performance/RawPerformanceEntry.js +24 -1
  164. package/src/private/webapis/performance/UserTiming.js +17 -12
  165. package/src/private/webapis/performance/specs/NativePerformanceObserver.js +1 -1
  166. package/src-win/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  167. package/types/experimental.d.ts +12 -98
  168. package/Libraries/Animated/NativeAnimatedHelper.js +0 -615
  169. package/Libraries/Animated/NativeAnimatedHelper.win32.js +0 -617
  170. package/Libraries/Core/setUpIntersectionObserver.js +0 -16
  171. package/Libraries/Core/setUpMutationObserver.js +0 -16
  172. package/Libraries/Core/setUpPerformanceObserver.js +0 -18
  173. package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +0 -13
  174. package/Libraries/MutationObserver/NativeMutationObserver.js +0 -13
  175. package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +0 -135
  176. package/src/private/core/setUpDOM.js +0 -18
  177. package/src/private/webapis/performance/PerformanceEventTiming.js +0 -55
  178. /package/src/private/{core → styles}/composeStyles.js +0 -0
@@ -8,6 +8,10 @@
8
8
  * @flow strict-local
9
9
  */
10
10
 
11
+ import type {
12
+ TScrollViewNativeComponentInstance,
13
+ TScrollViewNativeImperativeHandle,
14
+ } from '../../../src/private/components/useSyncOnScroll';
11
15
  import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
12
16
  import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType';
13
17
  import type {PointProp} from '../../StyleSheet/PointPropType';
@@ -20,9 +24,18 @@ import type {
20
24
  } from '../../Types/CoreEventTypes';
21
25
  import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
22
26
  import type {KeyboardEvent, KeyboardMetrics} from '../Keyboard/Keyboard';
27
+ import typeof View from '../View/View';
23
28
  import type {ViewProps} from '../View/ViewPropTypes';
24
29
  import type {Props as ScrollViewStickyHeaderProps} from './ScrollViewStickyHeader';
25
30
 
31
+ import {
32
+ HScrollContentViewNativeComponent,
33
+ HScrollViewNativeComponent,
34
+ } from '../../../src/private/components/HScrollViewNativeComponents';
35
+ import {
36
+ VScrollContentViewNativeComponent,
37
+ VScrollViewNativeComponent,
38
+ } from '../../../src/private/components/VScrollViewNativeComponents';
26
39
  import AnimatedImplementation from '../../Animated/AnimatedImplementation';
27
40
  import FrameRateLogger from '../../Interaction/FrameRateLogger';
28
41
  import {findNodeHandle} from '../../ReactNative/RendererProxy';
@@ -36,44 +49,15 @@ import Platform from '../../Utilities/Platform';
36
49
  import EventEmitter from '../../vendor/emitter/EventEmitter';
37
50
  import Keyboard from '../Keyboard/Keyboard';
38
51
  import TextInputState from '../TextInput/TextInputState';
39
- import View from '../View/View';
40
- import AndroidHorizontalScrollContentViewNativeComponent from './AndroidHorizontalScrollContentViewNativeComponent';
41
- import AndroidHorizontalScrollViewNativeComponent from './AndroidHorizontalScrollViewNativeComponent';
42
52
  import processDecelerationRate from './processDecelerationRate';
43
- import ScrollContentViewNativeComponent from './ScrollContentViewNativeComponent';
44
53
  import Commands from './ScrollViewCommands';
45
54
  import ScrollViewContext, {HORIZONTAL, VERTICAL} from './ScrollViewContext';
46
- import ScrollViewNativeComponent from './ScrollViewNativeComponent';
47
55
  import ScrollViewStickyHeader from './ScrollViewStickyHeader';
48
56
  import invariant from 'invariant';
49
57
  import memoize from 'memoize-one';
50
58
  import nullthrows from 'nullthrows';
51
59
  import * as React from 'react';
52
60
 
53
- if (Platform.OS === 'ios') {
54
- require('../../Renderer/shims/ReactNative'); // Force side effects to prevent T55744311
55
- }
56
-
57
- const {NativeHorizontalScrollViewTuple, NativeVerticalScrollViewTuple} =
58
- Platform.OS === 'android'
59
- ? {
60
- NativeHorizontalScrollViewTuple: [
61
- AndroidHorizontalScrollViewNativeComponent,
62
- AndroidHorizontalScrollContentViewNativeComponent,
63
- ],
64
- NativeVerticalScrollViewTuple: [ScrollViewNativeComponent, View],
65
- }
66
- : {
67
- NativeHorizontalScrollViewTuple: [
68
- ScrollViewNativeComponent,
69
- ScrollContentViewNativeComponent,
70
- ],
71
- NativeVerticalScrollViewTuple: [
72
- ScrollViewNativeComponent,
73
- ScrollContentViewNativeComponent,
74
- ],
75
- };
76
-
77
61
  /*
78
62
  * iOS scroll event timing nuances:
79
63
  * ===============================
@@ -167,13 +151,12 @@ export type ScrollViewImperativeMethods = $ReadOnly<{|
167
151
  export type DecelerationRateType = 'fast' | 'normal' | number;
168
152
  export type ScrollResponderType = ScrollViewImperativeMethods;
169
153
 
170
- type NativeScrollViewInstance = React.ElementRef<HostComponent<mixed>>;
171
154
  type PublicScrollViewInstance = $ReadOnly<{|
172
- ...$Exact<NativeScrollViewInstance>,
155
+ ...$Exact<TScrollViewNativeComponentInstance>,
173
156
  ...ScrollViewImperativeMethods,
174
157
  |}>;
175
158
 
176
- type InnerViewInstance = React.ElementRef<typeof View>;
159
+ type InnerViewInstance = React.ElementRef<View>;
177
160
 
178
161
  type IOSProps = $ReadOnly<{|
179
162
  /**
@@ -660,26 +643,23 @@ export type Props = $ReadOnly<{|
660
643
  */
661
644
  /* $FlowFixMe[unclear-type] - how to handle generic type without existential
662
645
  * operator? */
663
- refreshControl?: ?React.Element<any>,
646
+ refreshControl?: ?ExactReactElement_DEPRECATED<any>,
664
647
  children?: React.Node,
665
648
  /**
666
649
  * A ref to the inner View element of the ScrollView. This should be used
667
650
  * instead of calling `getInnerViewRef`.
668
651
  */
669
- innerViewRef?: ForwardedRef<InnerViewInstance>,
652
+ innerViewRef?: React.RefSetter<InnerViewInstance>,
670
653
  /**
671
654
  * A ref to the Native ScrollView component. This ref can be used to call
672
655
  * all of ScrollView's public methods, in addition to native methods like
673
656
  * measure, measureLayout, etc.
674
657
  */
675
- scrollViewRef?: ForwardedRef<PublicScrollViewInstance>,
658
+ scrollViewRef?: React.RefSetter<PublicScrollViewInstance>,
676
659
  |}>;
677
660
 
678
661
  type State = {|
679
662
  layoutHeight: ?number,
680
- onScrollEmitter: ?EventEmitter<{
681
- scroll: [{x: number, y: number}],
682
- }>,
683
663
  |};
684
664
 
685
665
  const IS_ANIMATING_TOUCH_START_THRESHOLD_MS = 16;
@@ -763,9 +743,12 @@ class ScrollView extends React.Component<Props, State> {
763
743
  _subscriptionKeyboardDidShow: ?EventSubscription = null;
764
744
  _subscriptionKeyboardDidHide: ?EventSubscription = null;
765
745
 
746
+ #onScrollEmitter: ?EventEmitter<{
747
+ scroll: [{x: number, y: number}],
748
+ }> = null;
749
+
766
750
  state: State = {
767
751
  layoutHeight: null,
768
- onScrollEmitter: null,
769
752
  };
770
753
 
771
754
  componentDidMount() {
@@ -835,7 +818,7 @@ class ScrollView extends React.Component<Props, State> {
835
818
  this._scrollAnimatedValueAttachment.detach();
836
819
  }
837
820
 
838
- this.state.onScrollEmitter?.removeAllListeners();
821
+ this.#onScrollEmitter?.removeAllListeners();
839
822
  }
840
823
 
841
824
  /**
@@ -850,7 +833,7 @@ class ScrollView extends React.Component<Props, State> {
850
833
  };
851
834
 
852
835
  getScrollableNode: () => ?number = () => {
853
- return findNodeHandle(this._scrollView.nativeInstance);
836
+ return findNodeHandle(this.getNativeScrollRef());
854
837
  };
855
838
 
856
839
  getInnerViewNode: () => ?number = () => {
@@ -861,8 +844,9 @@ class ScrollView extends React.Component<Props, State> {
861
844
  return this._innerView.nativeInstance;
862
845
  };
863
846
 
864
- getNativeScrollRef: () => NativeScrollViewInstance | null = () => {
865
- return this._scrollView.nativeInstance;
847
+ getNativeScrollRef: () => TScrollViewNativeComponentInstance | null = () => {
848
+ const {nativeInstance} = this._scrollView;
849
+ return nativeInstance == null ? null : nativeInstance.componentRef.current;
866
850
  };
867
851
 
868
852
  /**
@@ -913,15 +897,11 @@ class ScrollView extends React.Component<Props, State> {
913
897
  x = options.x;
914
898
  animated = options.animated;
915
899
  }
916
- if (this._scrollView.nativeInstance == null) {
900
+ const component = this.getNativeScrollRef();
901
+ if (component == null) {
917
902
  return;
918
903
  }
919
- Commands.scrollTo(
920
- this._scrollView.nativeInstance,
921
- x || 0,
922
- y || 0,
923
- animated !== false,
924
- );
904
+ Commands.scrollTo(component, x || 0, y || 0, animated !== false);
925
905
  };
926
906
 
927
907
  /**
@@ -937,10 +917,11 @@ class ScrollView extends React.Component<Props, State> {
937
917
  ) => {
938
918
  // Default to true
939
919
  const animated = (options && options.animated) !== false;
940
- if (this._scrollView.nativeInstance == null) {
920
+ const component = this.getNativeScrollRef();
921
+ if (component == null) {
941
922
  return;
942
923
  }
943
- Commands.scrollToEnd(this._scrollView.nativeInstance, animated);
924
+ Commands.scrollToEnd(component, animated);
944
925
  };
945
926
 
946
927
  /**
@@ -949,48 +930,25 @@ class ScrollView extends React.Component<Props, State> {
949
930
  * @platform ios
950
931
  */
951
932
  flashScrollIndicators: () => void = () => {
952
- if (this._scrollView.nativeInstance == null) {
933
+ const component = this.getNativeScrollRef();
934
+ if (component == null) {
953
935
  return;
954
936
  }
955
- Commands.flashScrollIndicators(this._scrollView.nativeInstance);
937
+ Commands.flashScrollIndicators(component);
956
938
  };
957
939
 
958
940
  _subscribeToOnScroll: (
959
941
  callback: ({x: number, y: number}) => void,
960
942
  ) => EventSubscription = callback => {
961
- // An undefined value means the listener has not been added, yet.
962
- // A null value means the listener has been removed.
963
- let subscription: ?EventSubscription;
964
-
965
- this.setState(
966
- ({onScrollEmitter}) => {
967
- if (onScrollEmitter) {
968
- return null;
969
- } else {
970
- return {onScrollEmitter: new EventEmitter()};
971
- }
972
- },
973
- () => {
974
- // If `subscription` is null, that means it was removed before we got
975
- // here so do nothing.
976
- if (subscription !== null) {
977
- subscription = nullthrows(this.state.onScrollEmitter).addListener(
978
- 'scroll',
979
- callback,
980
- );
981
- }
982
- },
983
- );
984
-
985
- return {
986
- remove() {
987
- // If `subscription` was created before this invocation, remove it.
988
- subscription?.remove();
989
- // Record this invocation by setting `subscription` to null, in case it
990
- // ends up being created after this invocation.
991
- subscription = null;
992
- },
993
- };
943
+ let onScrollEmitter = this.#onScrollEmitter;
944
+ if (onScrollEmitter == null) {
945
+ onScrollEmitter = new EventEmitter();
946
+ this.#onScrollEmitter = onScrollEmitter;
947
+ // This is the first subscription, so make sure the native component is
948
+ // also configured to output synchronous scroll events.
949
+ this._scrollView.nativeInstance?.unstable_setEnableSyncOnScroll(true);
950
+ }
951
+ return onScrollEmitter.addListener('scroll', callback);
994
952
  };
995
953
 
996
954
  /**
@@ -1072,14 +1030,11 @@ class ScrollView extends React.Component<Props, State> {
1072
1030
  );
1073
1031
  }
1074
1032
 
1075
- if (this._scrollView.nativeInstance == null) {
1033
+ const component = this.getNativeScrollRef();
1034
+ if (component == null) {
1076
1035
  return;
1077
1036
  }
1078
- Commands.zoomToRect(
1079
- this._scrollView.nativeInstance,
1080
- rect,
1081
- animated !== false,
1082
- );
1037
+ Commands.zoomToRect(component, rect, animated !== false);
1083
1038
  };
1084
1039
 
1085
1040
  _textInputFocusError() {
@@ -1152,7 +1107,7 @@ class ScrollView extends React.Component<Props, State> {
1152
1107
  ) {
1153
1108
  this._scrollAnimatedValueAttachment =
1154
1109
  AnimatedImplementation.attachNativeEvent(
1155
- this._scrollView.nativeInstance,
1110
+ this.getNativeScrollRef(),
1156
1111
  'onScroll',
1157
1112
  [{nativeEvent: {contentOffset: {y: this._scrollAnimatedValue}}}],
1158
1113
  );
@@ -1200,7 +1155,7 @@ class ScrollView extends React.Component<Props, State> {
1200
1155
  this._observedScrollSinceBecomingResponder = true;
1201
1156
  this.props.onScroll && this.props.onScroll(e);
1202
1157
 
1203
- this.state.onScrollEmitter?.emit('scroll', {
1158
+ this.#onScrollEmitter?.emit('scroll', {
1204
1159
  x: e.nativeEvent.contentOffset.x,
1205
1160
  y: e.nativeEvent.contentOffset.y,
1206
1161
  });
@@ -1227,41 +1182,44 @@ class ScrollView extends React.Component<Props, State> {
1227
1182
  );
1228
1183
 
1229
1184
  _scrollView: RefForwarder<
1230
- NativeScrollViewInstance,
1231
- PublicScrollViewInstance,
1232
- > = createRefForwarder(
1233
- (nativeInstance: NativeScrollViewInstance): PublicScrollViewInstance => {
1234
- // This is a hack. Ideally we would forwardRef to the underlying
1235
- // host component. However, since ScrollView has it's own methods that can be
1236
- // called as well, if we used the standard forwardRef then these
1237
- // methods wouldn't be accessible and thus be a breaking change.
1238
- //
1239
- // Therefore we edit ref to include ScrollView's public methods so that
1240
- // they are callable from the ref.
1241
-
1242
- // $FlowFixMe[prop-missing] - Known issue with appending custom methods.
1243
- const publicInstance: PublicScrollViewInstance = Object.assign(
1244
- nativeInstance,
1245
- {
1246
- getScrollResponder: this.getScrollResponder,
1247
- getScrollableNode: this.getScrollableNode,
1248
- getInnerViewNode: this.getInnerViewNode,
1249
- getInnerViewRef: this.getInnerViewRef,
1250
- getNativeScrollRef: this.getNativeScrollRef,
1251
- scrollTo: this.scrollTo,
1252
- scrollToEnd: this.scrollToEnd,
1253
- flashScrollIndicators: this.flashScrollIndicators,
1254
- scrollResponderZoomTo: this.scrollResponderZoomTo,
1255
- // TODO: Replace unstable_subscribeToOnScroll once scrollView.addEventListener('scroll', (e: ScrollEvent) => {}, {passive: false});
1256
- unstable_subscribeToOnScroll: this._subscribeToOnScroll,
1257
- scrollResponderScrollNativeHandleToKeyboard:
1258
- this.scrollResponderScrollNativeHandleToKeyboard,
1259
- },
1260
- );
1185
+ TScrollViewNativeImperativeHandle,
1186
+ PublicScrollViewInstance | null,
1187
+ > = createRefForwarder(nativeImperativeHandle => {
1188
+ const nativeInstance = nativeImperativeHandle.componentRef.current;
1189
+ if (nativeInstance == null) {
1190
+ return null;
1191
+ }
1261
1192
 
1262
- return publicInstance;
1263
- },
1264
- );
1193
+ // This is a hack. Ideally we would forwardRef to the underlying
1194
+ // host component. However, since ScrollView has it's own methods that can be
1195
+ // called as well, if we used the standard forwardRef then these
1196
+ // methods wouldn't be accessible and thus be a breaking change.
1197
+ //
1198
+ // Therefore we edit ref to include ScrollView's public methods so that
1199
+ // they are callable from the ref.
1200
+
1201
+ // $FlowFixMe[prop-missing] - Known issue with appending custom methods.
1202
+ const publicInstance: PublicScrollViewInstance = Object.assign(
1203
+ nativeInstance,
1204
+ {
1205
+ getScrollResponder: this.getScrollResponder,
1206
+ getScrollableNode: this.getScrollableNode,
1207
+ getInnerViewNode: this.getInnerViewNode,
1208
+ getInnerViewRef: this.getInnerViewRef,
1209
+ getNativeScrollRef: this.getNativeScrollRef,
1210
+ scrollTo: this.scrollTo,
1211
+ scrollToEnd: this.scrollToEnd,
1212
+ flashScrollIndicators: this.flashScrollIndicators,
1213
+ scrollResponderZoomTo: this.scrollResponderZoomTo,
1214
+ // TODO: Replace unstable_subscribeToOnScroll once scrollView.addEventListener('scroll', (e: ScrollEvent) => {}, {passive: false});
1215
+ unstable_subscribeToOnScroll: this._subscribeToOnScroll,
1216
+ scrollResponderScrollNativeHandleToKeyboard:
1217
+ this.scrollResponderScrollNativeHandleToKeyboard,
1218
+ },
1219
+ );
1220
+
1221
+ return publicInstance;
1222
+ });
1265
1223
 
1266
1224
  /**
1267
1225
  * Warning, this may be called several times for a single keyboard opening.
@@ -1690,14 +1648,19 @@ class ScrollView extends React.Component<Props, State> {
1690
1648
  this.props.onTouchMove && this.props.onTouchMove(e);
1691
1649
  };
1692
1650
 
1693
- render(): React.Node | React.Element<string> {
1694
- const [NativeDirectionalScrollView, NativeDirectionalScrollContentView] =
1695
- this.props.horizontal === true
1696
- ? NativeHorizontalScrollViewTuple
1697
- : NativeVerticalScrollViewTuple;
1651
+ render(): React.Node {
1652
+ const horizontal = this.props.horizontal === true;
1653
+
1654
+ const NativeScrollView = horizontal
1655
+ ? HScrollViewNativeComponent
1656
+ : VScrollViewNativeComponent;
1657
+
1658
+ const NativeScrollContentView = horizontal
1659
+ ? HScrollContentViewNativeComponent
1660
+ : VScrollContentViewNativeComponent;
1698
1661
 
1699
1662
  const contentContainerStyle = [
1700
- this.props.horizontal === true && styles.contentContainerHorizontal,
1663
+ horizontal && styles.contentContainerHorizontal,
1701
1664
  this.props.contentContainerStyle,
1702
1665
  ];
1703
1666
  if (__DEV__ && this.props.style !== undefined) {
@@ -1759,8 +1722,7 @@ class ScrollView extends React.Component<Props, State> {
1759
1722
  });
1760
1723
  }
1761
1724
  children = (
1762
- <ScrollViewContext.Provider
1763
- value={this.props.horizontal === true ? HORIZONTAL : VERTICAL}>
1725
+ <ScrollViewContext.Provider value={horizontal ? HORIZONTAL : VERTICAL}>
1764
1726
  {children}
1765
1727
  </ScrollViewContext.Provider>
1766
1728
  );
@@ -1776,7 +1738,7 @@ class ScrollView extends React.Component<Props, State> {
1776
1738
  (Platform.OS === 'android' && this.props.snapToAlignment != null);
1777
1739
 
1778
1740
  const contentContainer = (
1779
- <NativeDirectionalScrollContentView
1741
+ <NativeScrollContentView
1780
1742
  {...contentSizeChangeProps}
1781
1743
  ref={this._innerView.getForwardingRef(this.props.innerViewRef)}
1782
1744
  style={contentContainerStyle}
@@ -1790,7 +1752,7 @@ class ScrollView extends React.Component<Props, State> {
1790
1752
  collapsable={false}
1791
1753
  collapsableChildren={!preserveChildren}>
1792
1754
  {children}
1793
- </NativeDirectionalScrollContentView>
1755
+ </NativeScrollContentView>
1794
1756
  );
1795
1757
 
1796
1758
  const alwaysBounceHorizontal =
@@ -1803,10 +1765,7 @@ class ScrollView extends React.Component<Props, State> {
1803
1765
  ? this.props.alwaysBounceVertical
1804
1766
  : !this.props.horizontal;
1805
1767
 
1806
- const baseStyle =
1807
- this.props.horizontal === true
1808
- ? styles.baseHorizontal
1809
- : styles.baseVertical;
1768
+ const baseStyle = horizontal ? styles.baseHorizontal : styles.baseVertical;
1810
1769
 
1811
1770
  const {experimental_endDraggingSensitivityMultiplier, ...otherProps} =
1812
1771
  this.props;
@@ -1838,7 +1797,6 @@ class ScrollView extends React.Component<Props, State> {
1838
1797
  onScroll: this._handleScroll,
1839
1798
  endDraggingSensitivityMultiplier:
1840
1799
  experimental_endDraggingSensitivityMultiplier,
1841
- enableSyncOnScroll: this.state.onScrollEmitter ? true : undefined,
1842
1800
  scrollEventThrottle: hasStickyHeaders
1843
1801
  ? 1
1844
1802
  : this.props.scrollEventThrottle,
@@ -1871,18 +1829,18 @@ class ScrollView extends React.Component<Props, State> {
1871
1829
  }
1872
1830
 
1873
1831
  const refreshControl = this.props.refreshControl;
1874
- const scrollViewRef = this._scrollView.getForwardingRef(
1875
- this.props.scrollViewRef,
1876
- );
1832
+ const scrollViewRef: React.RefSetter<TScrollViewNativeImperativeHandle | null> =
1833
+ this._scrollView.getForwardingRef(this.props.scrollViewRef);
1877
1834
 
1878
1835
  if (refreshControl) {
1879
1836
  if (Platform.OS === 'ios') {
1880
1837
  // On iOS the RefreshControl is a child of the ScrollView.
1881
1838
  return (
1882
- <NativeDirectionalScrollView {...props} ref={scrollViewRef}>
1839
+ // $FlowFixMe[incompatible-type] - Flow only knows element refs.
1840
+ <NativeScrollView {...props} ref={scrollViewRef}>
1883
1841
  {refreshControl}
1884
1842
  {contentContainer}
1885
- </NativeDirectionalScrollView>
1843
+ </NativeScrollView>
1886
1844
  );
1887
1845
  } else if (Platform.OS === 'android') {
1888
1846
  // On Android wrap the ScrollView with a AndroidSwipeRefreshLayout.
@@ -1896,19 +1854,21 @@ class ScrollView extends React.Component<Props, State> {
1896
1854
  return React.cloneElement(
1897
1855
  refreshControl,
1898
1856
  {style: StyleSheet.compose(baseStyle, outer)},
1899
- <NativeDirectionalScrollView
1857
+ <NativeScrollView
1900
1858
  {...props}
1901
1859
  style={StyleSheet.compose(baseStyle, inner)}
1860
+ // $FlowFixMe[incompatible-type] - Flow only knows element refs.
1902
1861
  ref={scrollViewRef}>
1903
1862
  {contentContainer}
1904
- </NativeDirectionalScrollView>,
1863
+ </NativeScrollView>,
1905
1864
  );
1906
1865
  }
1907
1866
  }
1908
1867
  return (
1909
- <NativeDirectionalScrollView {...props} ref={scrollViewRef}>
1868
+ // $FlowFixMe[incompatible-type] - Flow only knows element refs.
1869
+ <NativeScrollView {...props} ref={scrollViewRef}>
1910
1870
  {contentContainer}
1911
- </NativeDirectionalScrollView>
1871
+ </NativeScrollView>
1912
1872
  );
1913
1873
  }
1914
1874
  }
@@ -1931,11 +1891,9 @@ const styles = StyleSheet.create({
1931
1891
  },
1932
1892
  });
1933
1893
 
1934
- type ForwardedRef<T> = {current: null | T, ...} | ((null | T) => mixed);
1935
-
1936
1894
  type RefForwarder<TNativeInstance, TPublicInstance> = {
1937
1895
  getForwardingRef: (
1938
- ?ForwardedRef<TPublicInstance>,
1896
+ ?React.RefSetter<TPublicInstance>,
1939
1897
  ) => (TNativeInstance | null) => void,
1940
1898
  nativeInstance: TNativeInstance | null,
1941
1899
  publicInstance: TPublicInstance | null,
@@ -1973,21 +1931,25 @@ function createRefForwarder<TNativeInstance, TPublicInstance>(
1973
1931
  return state;
1974
1932
  }
1975
1933
 
1976
- /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
1977
- * LTI update could not be added via codemod */
1978
- function Wrapper(props, ref: (mixed => mixed) | {current: mixed, ...}) {
1979
- return <ScrollView {...props} scrollViewRef={ref} />;
1980
- }
1934
+ // TODO: After upgrading to React 19, remove `forwardRef` from this component.
1935
+ // NOTE: This wrapper component is necessary because `ScrollView` is a class
1936
+ // component and we need to map `ref` to a differently named prop. This can be
1937
+ // removed when `ScrollView` is a functional component.
1938
+ const Wrapper = React.forwardRef(function Wrapper(
1939
+ props: Props,
1940
+ ref: ?React.RefSetter<PublicScrollViewInstance>,
1941
+ ): React.Node {
1942
+ return ref == null ? (
1943
+ <ScrollView {...props} />
1944
+ ) : (
1945
+ <ScrollView {...props} scrollViewRef={ref} />
1946
+ );
1947
+ });
1981
1948
  Wrapper.displayName = 'ScrollView';
1982
- // $FlowFixMe[incompatible-call]
1983
- const ForwardedScrollView = React.forwardRef(Wrapper);
1984
-
1985
- // $FlowFixMe[prop-missing] Add static context to ForwardedScrollView
1986
- ForwardedScrollView.Context = ScrollViewContext;
1987
-
1988
- ForwardedScrollView.displayName = 'ScrollView';
1949
+ // $FlowExpectedError[prop-missing]
1950
+ Wrapper.Context = ScrollViewContext;
1989
1951
 
1990
- module.exports = ((ForwardedScrollView: $FlowFixMe): React.AbstractComponent<
1952
+ module.exports = ((Wrapper: $FlowFixMe): React.AbstractComponent<
1991
1953
  React.ElementConfig<typeof ScrollView>,
1992
1954
  PublicScrollViewInstance,
1993
1955
  > &
@@ -160,6 +160,9 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig =
160
160
  snapToInterval: true,
161
161
  snapToOffsets: true,
162
162
  snapToStart: true,
163
+ verticalScrollIndicatorInsets: {
164
+ diff: require('../../Utilities/differ/insetsDiffer'),
165
+ },
163
166
  zoomScale: true,
164
167
  ...ConditionallyIgnoredEventHandlers({
165
168
  onScrollBeginDrag: true,
@@ -19,7 +19,7 @@ import * as React from 'react';
19
19
  import {useCallback, useEffect, useMemo, useRef, useState} from 'react';
20
20
 
21
21
  export type Props = $ReadOnly<{
22
- children?: React.Element<$FlowFixMe>,
22
+ children?: ExactReactElement_DEPRECATED<$FlowFixMe>,
23
23
  nextHeaderLayoutY: ?number,
24
24
  onLayout: (event: LayoutEvent) => void,
25
25
  scrollAnimatedValue: Animated.Value,
@@ -272,8 +272,10 @@ class StatusBar extends React.Component<Props> {
272
272
  }
273
273
 
274
274
  /**
275
- * Control the visibility of the network activity indicator
275
+ * DEPRECATED - The status bar network activity indicator is not supported in iOS 13 and later. This will be removed in a future release.
276
276
  * @param visible Show the indicator.
277
+ *
278
+ * @deprecated
277
279
  */
278
280
  static setNetworkActivityIndicatorVisible(visible: boolean) {
279
281
  if (Platform.OS !== 'ios') {
@@ -85,8 +85,15 @@ const RCTTextInputViewConfig = {
85
85
  topContentSizeChange: {
86
86
  registrationName: 'onContentSizeChange',
87
87
  },
88
+ topChangeSync: {
89
+ registrationName: 'onChangeSync',
90
+ },
91
+ topKeyPressSync: {
92
+ registrationName: 'onKeyPressSync',
93
+ },
88
94
  },
89
95
  validAttributes: {
96
+ dynamicTypeRamp: true,
90
97
  fontSize: true,
91
98
  fontWeight: true,
92
99
  fontVariant: true,
@@ -97,6 +104,7 @@ const RCTTextInputViewConfig = {
97
104
  textTransform: true,
98
105
  textAlign: true,
99
106
  fontFamily: true,
107
+ lineBreakModeIOS: true,
100
108
  lineHeight: true,
101
109
  isHighlighted: true,
102
110
  writingDirection: true,
@@ -150,6 +158,8 @@ const RCTTextInputViewConfig = {
150
158
  onSelectionChange: true,
151
159
  onContentSizeChange: true,
152
160
  onScroll: true,
161
+ onChangeSync: true,
162
+ onKeyPressSync: true,
153
163
  }),
154
164
  },
155
165
  };
@@ -90,6 +90,8 @@ type DataDetectorTypes =
90
90
  | 'none'
91
91
  | 'all';
92
92
 
93
+ export type SubmitBehavior = 'submit' | 'blurAndSubmit' | 'newline';
94
+
93
95
  /**
94
96
  * DocumentSelectionState is responsible for maintaining selection information
95
97
  * for a document.
@@ -649,11 +651,39 @@ export interface TextInputProps
649
651
  autoFocus?: boolean | undefined;
650
652
 
651
653
  /**
652
- * If true, the text field will blur when submitted.
653
- * The default value is true.
654
+ * If `true`, the text field will blur when submitted.
655
+ * The default value is true for single-line fields and false for
656
+ * multiline fields. Note that for multiline fields, setting `blurOnSubmit`
657
+ * to `true` means that pressing return will blur the field and trigger the
658
+ * `onSubmitEditing` event instead of inserting a newline into the field.
659
+ *
660
+ * @deprecated
661
+ * Note that `submitBehavior` now takes the place of `blurOnSubmit` and will
662
+ * override any behavior defined by `blurOnSubmit`.
663
+ * @see submitBehavior
654
664
  */
655
665
  blurOnSubmit?: boolean | undefined;
656
666
 
667
+ /**
668
+ * When the return key is pressed,
669
+ *
670
+ * For single line inputs:
671
+ *
672
+ * - `'newline`' defaults to `'blurAndSubmit'`
673
+ * - `undefined` defaults to `'blurAndSubmit'`
674
+ *
675
+ * For multiline inputs:
676
+ *
677
+ * - `'newline'` adds a newline
678
+ * - `undefined` defaults to `'newline'`
679
+ *
680
+ * For both single line and multiline inputs:
681
+ *
682
+ * - `'submit'` will only send a submit event and not blur the input
683
+ * - `'blurAndSubmit`' will both blur the input and send a submit event
684
+ */
685
+ submitBehavior?: SubmitBehavior | undefined;
686
+
657
687
  /**
658
688
  * If true, caret is hidden. The default value is false.
659
689
  */