@office-iss/react-native-win32 0.0.0-canary.291 → 0.0.0-canary.293

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 (191) hide show
  1. package/.flowconfig +1 -1
  2. package/CHANGELOG.json +43 -1
  3. package/CHANGELOG.md +22 -4
  4. package/Libraries/Alert/RCTAlertManager.js +17 -0
  5. package/Libraries/Animated/AnimatedEvent.js +4 -3
  6. package/Libraries/Animated/AnimatedExports.js.flow +2 -0
  7. package/Libraries/Animated/AnimatedImplementation.js +2 -2
  8. package/Libraries/Animated/components/AnimatedScrollView.js +48 -43
  9. package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
  10. package/Libraries/BatchedBridge/MessageQueue.js +2 -2
  11. package/Libraries/Blob/FileReader.js +219 -8
  12. package/Libraries/Blob/URL.js +13 -1
  13. package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js +17 -0
  14. package/Libraries/Components/Button.js +1 -1
  15. package/Libraries/Components/Button.win32.js +1 -1
  16. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -3
  17. package/Libraries/{Utilities/__mocks__/GlobalPerformanceLogger.js → Components/DrawerAndroid/DrawerLayoutAndroid.ios.js} +3 -4
  18. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +6 -66
  19. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js.flow +18 -0
  20. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidFallback.js +71 -0
  21. package/Libraries/Components/Keyboard/Keyboard.js +4 -2
  22. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +6 -3
  23. package/Libraries/Components/Pressable/Pressable.js +6 -1
  24. package/Libraries/Components/Pressable/Pressable.win32.js +6 -1
  25. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +12 -2
  26. package/Libraries/Components/RefreshControl/RefreshControl.js +1 -1
  27. package/Libraries/Components/ScrollView/ScrollView.d.ts +1 -1
  28. package/Libraries/Components/ScrollView/ScrollView.js +128 -116
  29. package/Libraries/Components/StaticRenderer.js +1 -1
  30. package/Libraries/Components/Switch/Switch.js +7 -3
  31. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +2 -1
  32. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +2 -4
  33. package/Libraries/Components/TextInput/TextInput.flow.js +59 -42
  34. package/Libraries/Components/TextInput/TextInput.flow.win32.js +1208 -0
  35. package/Libraries/Components/TextInput/TextInput.js +67 -1005
  36. package/Libraries/Components/TextInput/TextInput.win32.js +69 -1037
  37. package/Libraries/{Blob/__mocks__/BlobModule.js → Components/ToastAndroid/ToastAndroid.ios.js} +3 -6
  38. package/Libraries/Components/ToastAndroid/ToastAndroid.js +4 -32
  39. package/Libraries/Components/ToastAndroid/ToastAndroid.js.flow +109 -0
  40. package/Libraries/Components/ToastAndroid/ToastAndroid.win32.js +4 -32
  41. package/Libraries/Components/ToastAndroid/ToastAndroidFallback.js +45 -0
  42. package/Libraries/Components/Touchable/Touchable.js +5 -5
  43. package/Libraries/Components/Touchable/Touchable.win32.js +5 -5
  44. package/Libraries/Components/Touchable/TouchableBounce.js +12 -6
  45. package/Libraries/Components/Touchable/TouchableHighlight.js +9 -6
  46. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +4 -4
  47. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +4 -4
  48. package/Libraries/Components/Touchable/TouchableOpacity.js +11 -5
  49. package/Libraries/Components/View/View.js +18 -21
  50. package/Libraries/Components/View/View.win32.js +21 -24
  51. package/Libraries/Components/View/ViewAccessibility.js +7 -0
  52. package/Libraries/Components/View/ViewAccessibility.win32.js +7 -0
  53. package/Libraries/Components/View/ViewPropTypes.js +1 -1
  54. package/Libraries/Components/View/ViewPropTypes.win32.js +1 -1
  55. package/Libraries/Core/ReactNativeVersion.js +1 -1
  56. package/Libraries/Core/setUpReactDevTools.js +5 -5
  57. package/Libraries/EventEmitter/NativeEventEmitter.js +4 -1
  58. package/Libraries/Image/Image.js +17 -0
  59. package/Libraries/Image/Image.js.flow +2 -2
  60. package/Libraries/Image/ImageInjection.js +1 -1
  61. package/Libraries/Image/ImageProps.js +5 -5
  62. package/Libraries/Image/ImageSource.js +3 -1
  63. package/Libraries/Image/ImageSourceUtils.js +4 -2
  64. package/Libraries/Image/ImageTypes.flow.js +1 -1
  65. package/Libraries/Lists/FlatList.d.ts +2 -2
  66. package/Libraries/Lists/FlatList.js +1 -1
  67. package/Libraries/Lists/SectionList.js +1 -1
  68. package/Libraries/Lists/SectionListModern.js +3 -3
  69. package/Libraries/LogBox/Data/LogBoxData.js +1 -1
  70. package/Libraries/LogBox/LogBoxNotificationContainer.js +1 -1
  71. package/Libraries/Modal/Modal.js +3 -3
  72. package/Libraries/NativeComponent/BaseViewConfig.js +17 -0
  73. package/Libraries/NativeComponent/PlatformBaseViewConfig.js +2 -2
  74. package/Libraries/NativeModules/specs/NativeDevMenu.js +2 -2
  75. package/Libraries/Network/RCTNetworking.js +17 -0
  76. package/Libraries/Network/XMLHttpRequest.js +781 -10
  77. package/Libraries/NewAppScreen/components/DebugInstructions.js +1 -1
  78. package/Libraries/NewAppScreen/components/Header.js +1 -1
  79. package/Libraries/NewAppScreen/components/HermesBadge.js +1 -1
  80. package/Libraries/NewAppScreen/components/LearnMoreLinks.js +3 -3
  81. package/Libraries/NewAppScreen/components/ReloadInstructions.js +1 -1
  82. package/Libraries/Performance/Systrace.js +7 -7
  83. package/Libraries/ReactNative/AppContainer-dev.js +3 -2
  84. package/Libraries/ReactNative/RendererImplementation.js +6 -5
  85. package/Libraries/ReactNative/renderApplication.js +9 -0
  86. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +2 -2
  87. package/Libraries/Renderer/implementations/ReactFabric-dev.js +4840 -4748
  88. package/Libraries/Renderer/implementations/ReactFabric-prod.js +4947 -4829
  89. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3998 -3888
  90. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +5005 -4948
  91. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +2744 -2652
  92. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +5020 -4933
  93. package/Libraries/Renderer/shims/ReactFabric.js +3 -1
  94. package/Libraries/Renderer/shims/ReactFeatureFlags.js +3 -1
  95. package/Libraries/Renderer/shims/ReactNative.js +3 -1
  96. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -1
  97. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +3 -1
  98. package/Libraries/Settings/Settings.js +13 -19
  99. package/Libraries/Settings/Settings.win32.js +19 -20
  100. package/Libraries/Settings/SettingsFallback.js +33 -0
  101. package/Libraries/StyleSheet/PlatformColorValueTypes.js +15 -0
  102. package/Libraries/StyleSheet/Rect.js +1 -0
  103. package/Libraries/StyleSheet/StyleSheet.js.flow +3 -3
  104. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -1
  105. package/Libraries/StyleSheet/StyleSheetTypes.js +75 -33
  106. package/Libraries/StyleSheet/flattenStyle.js +7 -1
  107. package/Libraries/StyleSheet/processBackgroundImage.js +670 -214
  108. package/Libraries/Text/Text.js +3 -3
  109. package/Libraries/Text/Text.win32.js +3 -3
  110. package/Libraries/Text/TextNativeComponent.js +0 -4
  111. package/Libraries/Text/TextNativeComponent.win32.js +0 -4
  112. package/Libraries/Text/TextProps.js +1 -1
  113. package/Libraries/Text/TextProps.win32.js +1 -1
  114. package/Libraries/Utilities/Appearance.js +2 -0
  115. package/Libraries/Utilities/BackHandler.js +17 -0
  116. package/Libraries/Utilities/Platform.js +17 -0
  117. package/Libraries/Utilities/PlatformTypes.js +2 -0
  118. package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
  119. package/Libraries/WebSocket/WebSocket.js +313 -8
  120. package/flow/global.js +0 -2
  121. package/index.js +1 -288
  122. package/index.win32.js +8 -297
  123. package/overrides.json +29 -23
  124. package/package.json +16 -16
  125. package/src/private/animated/NativeAnimatedHelper.js +1 -1
  126. package/src/private/animated/NativeAnimatedHelper.win32.js +1 -1
  127. package/src/private/animated/createAnimatedPropsHook.js +2 -27
  128. package/src/private/components/{SafeAreaView_INTERNAL_DO_NOT_USE.js → safeareaview/SafeAreaView_INTERNAL_DO_NOT_USE.js} +6 -6
  129. package/src/private/components/{HScrollViewNativeComponents.js → scrollview/HScrollViewNativeComponents.js} +8 -8
  130. package/src/private/components/scrollview/VScrollViewNativeComponents.js +25 -0
  131. package/src/private/{devmenu → devsupport/devmenu}/DevMenu.js +1 -1
  132. package/src/private/{inspector → devsupport/devmenu/elementinspector}/BorderBox.js +3 -3
  133. package/src/private/{inspector → devsupport/devmenu/elementinspector}/BoxInspector.js +6 -5
  134. package/src/private/{inspector → devsupport/devmenu/elementinspector}/ElementBox.js +8 -6
  135. package/src/private/{inspector → devsupport/devmenu/elementinspector}/ElementProperties.js +11 -10
  136. package/src/private/{inspector → devsupport/devmenu/elementinspector}/Inspector.js +14 -12
  137. package/src/private/{inspector → devsupport/devmenu/elementinspector}/InspectorOverlay.js +5 -4
  138. package/src/private/{inspector → devsupport/devmenu/elementinspector}/InspectorPanel.js +9 -8
  139. package/src/private/{inspector → devsupport/devmenu/elementinspector}/NetworkOverlay.js +10 -9
  140. package/src/private/{inspector → devsupport/devmenu/elementinspector}/ReactDevToolsOverlay.js +7 -7
  141. package/src/private/{inspector → devsupport/devmenu/elementinspector}/StyleInspector.js +7 -6
  142. package/src/private/{inspector → devsupport/devmenu/elementinspector}/XHRInterceptor.js +2 -2
  143. package/src/private/{inspector → devsupport/devmenu/elementinspector}/getInspectorDataForViewAtPoint.js +2 -2
  144. package/src/private/{inspector → devsupport/devmenu/elementinspector}/resolveBoxStyle.js +1 -1
  145. package/src/private/{inspector → devsupport/devmenu/perfmonitor}/PerformanceOverlay.js +6 -5
  146. package/src/private/{specs_DEPRECATED/modules → devsupport/devmenu/specs}/NativeDevMenu.js +2 -2
  147. package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.android.js +1 -1
  148. package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.ios.js +1 -1
  149. package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.win32.js +1 -1
  150. package/src/private/{debugging → devsupport/rndevtools}/setUpFuseboxReactDevToolsDispatcher.js +1 -1
  151. package/src/private/{fusebox → devsupport/rndevtools}/specs/NativeReactDevToolsRuntimeSettingsModule.js +2 -2
  152. package/src/private/{specs_DEPRECATED/modules → devsupport/rndevtools/specs}/NativeReactDevToolsSettingsManager.js +2 -2
  153. package/src/private/featureflags/ReactNativeFeatureFlags.js +37 -43
  154. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +8 -8
  155. package/src/private/renderer/errorhandling/ErrorHandlers.js +2 -2
  156. package/src/private/specs_DEPRECATED/modules/NativeSampleTurboModule.js +3 -0
  157. package/src/private/types/HostComponent.js +1 -1
  158. package/src/private/types/HostInstance.js +12 -4
  159. package/src/private/webapis/performance/Performance.js +1 -3
  160. package/types/index.d.ts +1 -1
  161. package/types/public/ReactNativeTypes.d.ts +2 -2
  162. package/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js +0 -38
  163. package/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js +0 -22
  164. package/Libraries/Blob/FileReader_new.js +0 -231
  165. package/Libraries/Blob/FileReader_old.js +0 -186
  166. package/Libraries/Blob/__mocks__/FileReaderModule.js +0 -20
  167. package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +0 -32
  168. package/Libraries/Core/__mocks__/ErrorUtils.js +0 -33
  169. package/Libraries/Core/__mocks__/NativeExceptionsManager.js +0 -19
  170. package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +0 -49
  171. package/Libraries/Events/CustomEvent.js +0 -32
  172. package/Libraries/Events/EventPolyfill.js +0 -239
  173. package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +0 -118
  174. package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +0 -134
  175. package/Libraries/Network/XMLHttpRequest_new.js +0 -794
  176. package/Libraries/Network/XMLHttpRequest_old.js +0 -701
  177. package/Libraries/StyleSheet/__flowtests__/StyleSheet-flowtest.js +0 -58
  178. package/Libraries/Utilities/__mocks__/BackHandler.js +0 -45
  179. package/Libraries/Utilities/__mocks__/PixelRatio.js +0 -25
  180. package/Libraries/WebSocket/WebSocketEvent.js +0 -30
  181. package/Libraries/WebSocket/WebSocket_new.js +0 -325
  182. package/Libraries/WebSocket/WebSocket_old.js +0 -297
  183. package/Libraries/WebSocket/__mocks__/event-target-shim.js +0 -27
  184. package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +0 -30
  185. package/Libraries/vendor/emitter/__flowtests__/EventEmitter-flowtest.js +0 -81
  186. package/jest/__tests__/setup-test.js +0 -18
  187. package/src/private/components/VScrollViewNativeComponents.js +0 -25
  188. package/src/private/webapis/performance/specs/__mocks__/NativePerformanceMock.js +0 -267
  189. package/src/types/third_party/event-target-shim.d.ts +0 -392
  190. /package/src/private/{devmenu → devsupport/devmenu}/DevMenu.d.ts +0 -0
  191. /package/src/private/{debugging → devsupport/rndevtools}/FuseboxSessionObserver.js +0 -0
@@ -20,18 +20,17 @@ import type {
20
20
  } from '../../Types/CoreEventTypes';
21
21
  import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
22
22
  import type {KeyboardEvent, KeyboardMetrics} from '../Keyboard/Keyboard';
23
- import typeof View from '../View/View';
24
23
  import type {ViewProps} from '../View/ViewPropTypes';
25
24
  import type {ScrollViewStickyHeaderProps} from './ScrollViewStickyHeader';
26
25
 
27
26
  import {
28
27
  HScrollContentViewNativeComponent,
29
28
  HScrollViewNativeComponent,
30
- } from '../../../src/private/components/HScrollViewNativeComponents';
29
+ } from '../../../src/private/components/scrollview/HScrollViewNativeComponents';
31
30
  import {
32
31
  VScrollContentViewNativeComponent,
33
32
  VScrollViewNativeComponent,
34
- } from '../../../src/private/components/VScrollViewNativeComponents';
33
+ } from '../../../src/private/components/scrollview/VScrollViewNativeComponents';
35
34
  import AnimatedImplementation from '../../Animated/AnimatedImplementation';
36
35
  import FrameRateLogger from '../../Interaction/FrameRateLogger';
37
36
  import {findNodeHandle} from '../../ReactNative/RendererProxy';
@@ -44,6 +43,7 @@ import dismissKeyboard from '../../Utilities/dismissKeyboard';
44
43
  import Platform from '../../Utilities/Platform';
45
44
  import Keyboard from '../Keyboard/Keyboard';
46
45
  import TextInputState from '../TextInput/TextInputState';
46
+ import View from '../View/View';
47
47
  import processDecelerationRate from './processDecelerationRate';
48
48
  import Commands from './ScrollViewCommands';
49
49
  import ScrollViewContext, {HORIZONTAL, VERTICAL} from './ScrollViewContext';
@@ -134,16 +134,33 @@ export interface ScrollViewScrollToOptions {
134
134
 
135
135
  // Public methods for ScrollView
136
136
  export interface ScrollViewImperativeMethods {
137
- +getScrollResponder: ScrollView['getScrollResponder'];
138
- +getScrollableNode: ScrollView['getScrollableNode'];
139
- +getInnerViewNode: ScrollView['getInnerViewNode'];
140
- +getInnerViewRef: ScrollView['getInnerViewRef'];
141
- +getNativeScrollRef: ScrollView['getNativeScrollRef'];
142
- +scrollTo: ScrollView['scrollTo'];
143
- +scrollToEnd: ScrollView['scrollToEnd'];
144
- +flashScrollIndicators: ScrollView['flashScrollIndicators'];
145
- +scrollResponderZoomTo: ScrollView['scrollResponderZoomTo'];
146
- +scrollResponderScrollNativeHandleToKeyboard: ScrollView['scrollResponderScrollNativeHandleToKeyboard'];
137
+ +getScrollResponder: () => ScrollResponderType;
138
+ +getScrollableNode: () => ?number;
139
+ +getInnerViewNode: () => ?number;
140
+ +getInnerViewRef: () => InnerViewInstance | null;
141
+ +getNativeScrollRef: () => HostInstance | null;
142
+ +scrollTo: (
143
+ options?: ScrollViewScrollToOptions | number,
144
+ deprecatedX?: number,
145
+ deprecatedAnimated?: boolean,
146
+ ) => void;
147
+ +scrollToEnd: (options?: ?ScrollViewScrollToOptions) => void;
148
+ +flashScrollIndicators: () => void;
149
+ +scrollResponderZoomTo: (
150
+ rect: {
151
+ x: number,
152
+ y: number,
153
+ width: number,
154
+ height: number,
155
+ animated?: boolean,
156
+ },
157
+ animated?: boolean, // deprecated, put this inside the rect argument instead
158
+ ) => void;
159
+ +scrollResponderScrollNativeHandleToKeyboard: (
160
+ nodeHandle: number | HostInstance,
161
+ additionalOffset?: number,
162
+ preventNegativeScrollOffset?: boolean,
163
+ ) => void;
147
164
  }
148
165
 
149
166
  export type DecelerationRateType = 'fast' | 'normal' | number;
@@ -153,7 +170,7 @@ export interface PublicScrollViewInstance
153
170
  extends HostInstance,
154
171
  ScrollViewImperativeMethods {}
155
172
 
156
- type InnerViewInstance = React.ElementRef<View>;
173
+ type InnerViewInstance = React.ElementRef<typeof View>;
157
174
 
158
175
  export type ScrollViewPropsIOS = $ReadOnly<{
159
176
  /**
@@ -373,11 +390,7 @@ type StickyHeaderComponentType = component(
373
390
  ...ScrollViewStickyHeaderProps
374
391
  );
375
392
 
376
- export type ScrollViewProps = $ReadOnly<{
377
- ...ViewProps,
378
- ...ScrollViewPropsIOS,
379
- ...ScrollViewPropsAndroid,
380
-
393
+ type ScrollViewBaseProps = $ReadOnly<{
381
394
  /**
382
395
  * These styles will be applied to the scroll view content container which
383
396
  * wraps all of the child views. Example:
@@ -640,7 +653,7 @@ export type ScrollViewProps = $ReadOnly<{
640
653
  */
641
654
  /* $FlowFixMe[unclear-type] - how to handle generic type without existential
642
655
  * operator? */
643
- refreshControl?: ?React.Node,
656
+ refreshControl?: ?React.MixedElement,
644
657
  children?: React.Node,
645
658
  /**
646
659
  * A ref to the inner View element of the ScrollView. This should be used
@@ -655,7 +668,14 @@ export type ScrollViewProps = $ReadOnly<{
655
668
  scrollViewRef?: React.RefSetter<PublicScrollViewInstance>,
656
669
  }>;
657
670
 
658
- type State = {
671
+ export type ScrollViewProps = $ReadOnly<{
672
+ ...ViewProps,
673
+ ...ScrollViewPropsIOS,
674
+ ...ScrollViewPropsAndroid,
675
+ ...ScrollViewBaseProps,
676
+ }>;
677
+
678
+ type ScrollViewState = {
659
679
  layoutHeight: ?number,
660
680
  };
661
681
 
@@ -700,7 +720,7 @@ export type ScrollViewComponentStatics = $ReadOnly<{
700
720
  * multiple columns, infinite scroll loading, or any number of other features it
701
721
  * supports out of the box.
702
722
  */
703
- class ScrollView extends React.Component<ScrollViewProps, State> {
723
+ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
704
724
  static Context: typeof ScrollViewContext = ScrollViewContext;
705
725
 
706
726
  constructor(props: ScrollViewProps) {
@@ -742,7 +762,7 @@ class ScrollView extends React.Component<ScrollViewProps, State> {
742
762
  _subscriptionKeyboardDidShow: ?EventSubscription = null;
743
763
  _subscriptionKeyboardDidHide: ?EventSubscription = null;
744
764
 
745
- state: State = {
765
+ state: ScrollViewState = {
746
766
  layoutHeight: null,
747
767
  };
748
768
 
@@ -820,26 +840,28 @@ class ScrollView extends React.Component<ScrollViewProps, State> {
820
840
  * implement this method so that they can be composed while providing access
821
841
  * to the underlying scroll responder's methods.
822
842
  */
823
- getScrollResponder: () => ScrollResponderType = () => {
824
- // $FlowFixMe[unclear-type]
825
- return ((this: any): ScrollResponderType);
826
- };
843
+ getScrollResponder: ScrollViewImperativeMethods['getScrollResponder'] =
844
+ () => {
845
+ // $FlowFixMe[unclear-type]
846
+ return ((this: any): ScrollResponderType);
847
+ };
827
848
 
828
- getScrollableNode: () => ?number = () => {
849
+ getScrollableNode: ScrollViewImperativeMethods['getScrollableNode'] = () => {
829
850
  return findNodeHandle<$FlowFixMe>(this.getNativeScrollRef());
830
851
  };
831
852
 
832
- getInnerViewNode: () => ?number = () => {
853
+ getInnerViewNode: ScrollViewImperativeMethods['getInnerViewNode'] = () => {
833
854
  return findNodeHandle<$FlowFixMe>(this._innerView.nativeInstance);
834
855
  };
835
856
 
836
- getInnerViewRef: () => InnerViewInstance | null = () => {
857
+ getInnerViewRef: ScrollViewImperativeMethods['getInnerViewRef'] = () => {
837
858
  return this._innerView.nativeInstance;
838
859
  };
839
860
 
840
- getNativeScrollRef: () => HostInstance | null = () => {
841
- return this._scrollView.nativeInstance;
842
- };
861
+ getNativeScrollRef: ScrollViewImperativeMethods['getNativeScrollRef'] =
862
+ () => {
863
+ return this._scrollView.nativeInstance;
864
+ };
843
865
 
844
866
  /**
845
867
  * Scrolls to a given x, y offset, either immediately or with a smooth animation.
@@ -852,11 +874,11 @@ class ScrollView extends React.Component<ScrollViewProps, State> {
852
874
  * the function also accepts separate arguments as an alternative to the options object.
853
875
  * This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
854
876
  */
855
- scrollTo: (
856
- options?: ScrollViewScrollToOptions | number,
857
- deprecatedX?: number,
858
- deprecatedAnimated?: boolean,
859
- ) => void = (options, deprecatedX, deprecatedAnimated) => {
877
+ scrollTo: ScrollViewImperativeMethods['scrollTo'] = (
878
+ options,
879
+ deprecatedX,
880
+ deprecatedAnimated,
881
+ ) => {
860
882
  let x, y, animated;
861
883
  if (typeof options === 'number') {
862
884
  console.warn(
@@ -886,7 +908,7 @@ class ScrollView extends React.Component<ScrollViewProps, State> {
886
908
  * `scrollToEnd({animated: false})` for immediate scrolling.
887
909
  * If no options are passed, `animated` defaults to true.
888
910
  */
889
- scrollToEnd: (options?: ?ScrollViewScrollToOptions) => void = options => {
911
+ scrollToEnd: ScrollViewImperativeMethods['scrollToEnd'] = options => {
890
912
  // Default to true
891
913
  const animated = (options && options.animated) !== false;
892
914
  const component = this.getNativeScrollRef();
@@ -901,13 +923,14 @@ class ScrollView extends React.Component<ScrollViewProps, State> {
901
923
  *
902
924
  * @platform ios
903
925
  */
904
- flashScrollIndicators: () => void = () => {
905
- const component = this.getNativeScrollRef();
906
- if (component == null) {
907
- return;
908
- }
909
- Commands.flashScrollIndicators(component);
910
- };
926
+ flashScrollIndicators: ScrollViewImperativeMethods['flashScrollIndicators'] =
927
+ () => {
928
+ const component = this.getNativeScrollRef();
929
+ if (component == null) {
930
+ return;
931
+ }
932
+ Commands.flashScrollIndicators(component);
933
+ };
911
934
 
912
935
  /**
913
936
  * This method should be used as the callback to onFocus in a TextInputs'
@@ -919,39 +942,36 @@ class ScrollView extends React.Component<ScrollViewProps, State> {
919
942
  * @param {bool} preventNegativeScrolling Whether to allow pulling the content
920
943
  * down to make it meet the keyboard's top. Default is false.
921
944
  */
922
- scrollResponderScrollNativeHandleToKeyboard: (
923
- nodeHandle: number | HostInstance,
924
- additionalOffset?: number,
925
- preventNegativeScrollOffset?: boolean,
926
- ) => void = (
927
- nodeHandle: number | HostInstance,
928
- additionalOffset?: number,
929
- preventNegativeScrollOffset?: boolean,
930
- ) => {
931
- this._additionalScrollOffset = additionalOffset || 0;
932
- this._preventNegativeScrollOffset = !!preventNegativeScrollOffset;
933
-
934
- if (this._innerView.nativeInstance == null) {
935
- return;
936
- }
945
+ scrollResponderScrollNativeHandleToKeyboard: ScrollViewImperativeMethods['scrollResponderScrollNativeHandleToKeyboard'] =
946
+ (
947
+ nodeHandle: number | HostInstance,
948
+ additionalOffset?: number,
949
+ preventNegativeScrollOffset?: boolean,
950
+ ) => {
951
+ this._additionalScrollOffset = additionalOffset || 0;
952
+ this._preventNegativeScrollOffset = !!preventNegativeScrollOffset;
953
+
954
+ if (this._innerView.nativeInstance == null) {
955
+ return;
956
+ }
937
957
 
938
- if (typeof nodeHandle === 'number') {
939
- UIManager.measureLayout(
940
- nodeHandle,
941
- nullthrows(findNodeHandle<$FlowFixMe>(this)),
942
- // $FlowFixMe[method-unbinding] added when improving typing for this parameters
943
- this._textInputFocusError,
944
- this._inputMeasureAndScrollToKeyboard,
945
- );
946
- } else {
947
- nodeHandle.measureLayout(
948
- this._innerView.nativeInstance,
949
- this._inputMeasureAndScrollToKeyboard,
950
- // $FlowFixMe[method-unbinding] added when improving typing for this parameters
951
- this._textInputFocusError,
952
- );
953
- }
954
- };
958
+ if (typeof nodeHandle === 'number') {
959
+ UIManager.measureLayout(
960
+ nodeHandle,
961
+ nullthrows(findNodeHandle<$FlowFixMe>(this)),
962
+ // $FlowFixMe[method-unbinding] added when improving typing for this parameters
963
+ this._textInputFocusError,
964
+ this._inputMeasureAndScrollToKeyboard,
965
+ );
966
+ } else {
967
+ nodeHandle.measureLayout(
968
+ this._innerView.nativeInstance,
969
+ this._inputMeasureAndScrollToKeyboard,
970
+ // $FlowFixMe[method-unbinding] added when improving typing for this parameters
971
+ this._textInputFocusError,
972
+ );
973
+ }
974
+ };
955
975
 
956
976
  /**
957
977
  * A helper function to zoom to a specific rect in the scrollview. The argument has the shape
@@ -959,41 +979,33 @@ class ScrollView extends React.Component<ScrollViewProps, State> {
959
979
  *
960
980
  * @platform ios
961
981
  */
962
- scrollResponderZoomTo: (
963
- rect: {
964
- x: number,
965
- y: number,
966
- width: number,
967
- height: number,
968
- animated?: boolean,
969
- },
970
- animated?: boolean, // deprecated, put this inside the rect argument instead
971
- ) => void = (
972
- rect: {
973
- x: number,
974
- y: number,
975
- width: number,
976
- height: number,
977
- animated?: boolean,
978
- },
979
- animated?: boolean, // deprecated, put this inside the rect argument instead
980
- ) => {
981
- invariant(Platform.OS === 'ios', 'zoomToRect is not implemented');
982
- if ('animated' in rect) {
983
- this._animated = rect.animated;
984
- delete rect.animated;
985
- } else if (typeof animated !== 'undefined') {
986
- console.warn(
987
- '`scrollResponderZoomTo` `animated` argument is deprecated. Use `options.animated` instead',
988
- );
989
- }
982
+ scrollResponderZoomTo: ScrollViewImperativeMethods['scrollResponderZoomTo'] =
983
+ (
984
+ rect: {
985
+ x: number,
986
+ y: number,
987
+ width: number,
988
+ height: number,
989
+ animated?: boolean,
990
+ },
991
+ animated?: boolean, // deprecated, put this inside the rect argument instead
992
+ ) => {
993
+ invariant(Platform.OS === 'ios', 'zoomToRect is not implemented');
994
+ if ('animated' in rect) {
995
+ this._animated = rect.animated;
996
+ delete rect.animated;
997
+ } else if (typeof animated !== 'undefined') {
998
+ console.warn(
999
+ '`scrollResponderZoomTo` `animated` argument is deprecated. Use `options.animated` instead',
1000
+ );
1001
+ }
990
1002
 
991
- const component = this.getNativeScrollRef();
992
- if (component == null) {
993
- return;
994
- }
995
- Commands.zoomToRect(component, rect, animated !== false);
996
- };
1003
+ const component = this.getNativeScrollRef();
1004
+ if (component == null) {
1005
+ return;
1006
+ }
1007
+ Commands.zoomToRect(component, rect, animated !== false);
1008
+ };
997
1009
 
998
1010
  _textInputFocusError() {
999
1011
  console.warn('Error measuring text field.');
@@ -1898,7 +1910,7 @@ function createRefForwarder<TNativeInstance, TPublicInstance>(
1898
1910
  // NOTE: This wrapper component is necessary because `ScrollView` is a class
1899
1911
  // component and we need to map `ref` to a differently named prop. This can be
1900
1912
  // removed when `ScrollView` is a functional component.
1901
- const Wrapper: component(
1913
+ const ScrollViewWrapper: component(
1902
1914
  ref?: React.RefSetter<PublicScrollViewInstance>,
1903
1915
  ...props: ScrollViewProps
1904
1916
  ) = React.forwardRef(function Wrapper(
@@ -1911,9 +1923,9 @@ const Wrapper: component(
1911
1923
  <ScrollView {...props} scrollViewRef={ref} />
1912
1924
  );
1913
1925
  });
1914
- Wrapper.displayName = 'ScrollView';
1926
+ ScrollViewWrapper.displayName = 'ScrollView';
1915
1927
  // $FlowExpectedError[prop-missing]
1916
- Wrapper.Context = ScrollViewContext;
1928
+ ScrollViewWrapper.Context = ScrollViewContext;
1917
1929
 
1918
- export default ((Wrapper: $FlowFixMe): typeof Wrapper &
1930
+ export default ((ScrollViewWrapper: $FlowFixMe): typeof ScrollViewWrapper &
1919
1931
  ScrollViewComponentStatics);
@@ -10,7 +10,7 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- import React from 'react';
13
+ import * as React from 'react';
14
14
 
15
15
  type Props = $ReadOnly<{
16
16
  /**
@@ -22,6 +22,7 @@ import SwitchNativeComponent, {
22
22
  Commands as SwitchCommands,
23
23
  } from './SwitchNativeComponent';
24
24
  import * as React from 'react';
25
+ import {useLayoutEffect, useRef, useState} from 'react';
25
26
 
26
27
  export type SwitchPropsIOS = {
27
28
  /**
@@ -179,13 +180,16 @@ const Switch: component(
179
180
  const trackColorForFalse = trackColor?.false;
180
181
  const trackColorForTrue = trackColor?.true;
181
182
 
182
- const nativeSwitchRef = React.useRef<React.ElementRef<
183
+ const nativeSwitchRef = useRef<React.ElementRef<
183
184
  typeof SwitchNativeComponent | typeof AndroidSwitchNativeComponent,
184
185
  > | null>(null);
185
186
 
186
187
  const ref = useMergeRefs(nativeSwitchRef, forwardedRef);
187
188
 
188
- const [native, setNative] = React.useState({value: (null: ?boolean)});
189
+ // We wrap the native state in an object to force the layout-effect
190
+ // below to re-run whenever we get an update from native, even if it's
191
+ // not different from the previous native state.
192
+ const [native, setNative] = useState({value: (null: ?boolean)});
189
193
 
190
194
  const handleChange = (event: SwitchChangeEvent) => {
191
195
  // $FlowFixMe[unused-promise]
@@ -195,7 +199,7 @@ const Switch: component(
195
199
  setNative({value: event.nativeEvent.value});
196
200
  };
197
201
 
198
- React.useLayoutEffect(() => {
202
+ useLayoutEffect(() => {
199
203
  // This is necessary in case native updates the switch and JS decides
200
204
  // that the update should be ignored and we should stick with the value
201
205
  // that we have in JS.
@@ -70,7 +70,7 @@ export type SubmitBehavior = 'submit' | 'blurAndSubmit' | 'newline';
70
70
  export type NativeProps = $ReadOnly<{
71
71
  // This allows us to inherit everything from ViewProps except for style (see below)
72
72
  // This must be commented for Fabric codegen to work.
73
- ...$Diff<ViewProps, $ReadOnly<{style: ?ViewStyleProp}>>,
73
+ ...Omit<ViewProps, 'style'>,
74
74
 
75
75
  /**
76
76
  * Android props after this
@@ -658,6 +658,7 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = {
658
658
  },
659
659
  },
660
660
  validAttributes: {
661
+ acceptDragAndDropTypes: true,
661
662
  maxFontSizeMultiplier: true,
662
663
  adjustsFontSizeToFit: true,
663
664
  minimumFontScale: true,
@@ -12,10 +12,7 @@ import type {PartialViewConfig} from '../../Renderer/shims/ReactNativeTypes';
12
12
 
13
13
  import {ConditionallyIgnoredEventHandlers} from '../../NativeComponent/ViewConfigIgnore';
14
14
 
15
- type PartialViewConfigWithoutName = $Rest<
16
- PartialViewConfig,
17
- {uiViewClassName: string},
18
- >;
15
+ type PartialViewConfigWithoutName = Omit<PartialViewConfig, 'uiViewClassName'>;
19
16
 
20
17
  const RCTTextInputViewConfig = {
21
18
  bubblingEventTypes: {
@@ -93,6 +90,7 @@ const RCTTextInputViewConfig = {
93
90
  },
94
91
  },
95
92
  validAttributes: {
93
+ acceptDragAndDropTypes: true,
96
94
  dynamicTypeRamp: true,
97
95
  fontSize: true,
98
96
  fontWeight: true,
@@ -23,13 +23,17 @@ import {
23
23
  } from '../../StyleSheet/StyleSheet';
24
24
  import * as React from 'react';
25
25
 
26
+ /**
27
+ * @see TextInputProps.onChange
28
+ */
26
29
  type TextInputChangeEventData = $ReadOnly<{
27
30
  eventCount: number,
28
31
  target: number,
29
32
  text: string,
30
33
  }>;
31
34
 
32
- type TextInputChangeEvent = NativeSyntheticEvent<TextInputChangeEventData>;
35
+ export type TextInputChangeEvent =
36
+ NativeSyntheticEvent<TextInputChangeEventData>;
33
37
 
34
38
  export type TextInputEvent = NativeSyntheticEvent<
35
39
  $ReadOnly<{
@@ -52,19 +56,30 @@ type TextInputContentSizeChangeEventData = $ReadOnly<{
52
56
  }>,
53
57
  }>;
54
58
 
59
+ /**
60
+ * @see TextInputProps.onContentSizeChange
61
+ */
55
62
  export type TextInputContentSizeChangeEvent =
56
63
  NativeSyntheticEvent<TextInputContentSizeChangeEventData>;
57
64
 
58
65
  type TargetEvent = $ReadOnly<{
59
66
  target: number,
67
+ ...
60
68
  }>;
61
69
 
62
70
  type TextInputFocusEventData = TargetEvent;
63
71
 
72
+ /**
73
+ * @see TextInputProps.onBlur
74
+ */
64
75
  export type TextInputBlurEvent = NativeSyntheticEvent<TextInputFocusEventData>;
76
+
77
+ /**
78
+ * @see TextInputProps.onFocus
79
+ */
65
80
  export type TextInputFocusEvent = NativeSyntheticEvent<TextInputFocusEventData>;
66
81
 
67
- type Selection = $ReadOnly<{
82
+ export type Selection = $ReadOnly<{
68
83
  start: number,
69
84
  end: number,
70
85
  }>;
@@ -72,8 +87,12 @@ type Selection = $ReadOnly<{
72
87
  type TextInputSelectionChangeEventData = $ReadOnly<{
73
88
  ...TargetEvent,
74
89
  selection: Selection,
90
+ ...
75
91
  }>;
76
92
 
93
+ /**
94
+ * @see TextInputProps.onSelectionChange
95
+ */
77
96
  export type TextInputSelectionChangeEvent =
78
97
  NativeSyntheticEvent<TextInputSelectionChangeEventData>;
79
98
 
@@ -82,8 +101,12 @@ type TextInputKeyPressEventData = $ReadOnly<{
82
101
  key: string,
83
102
  target?: ?number,
84
103
  eventCount: number,
104
+ ...
85
105
  }>;
86
106
 
107
+ /**
108
+ * @see TextInputProps.onKeyPress
109
+ */
87
110
  export type TextInputKeyPressEvent =
88
111
  NativeSyntheticEvent<TextInputKeyPressEventData>;
89
112
 
@@ -91,6 +114,7 @@ type TextInputEndEditingEventData = $ReadOnly<{
91
114
  ...TargetEvent,
92
115
  eventCount: number,
93
116
  text: string,
117
+ ...
94
118
  }>;
95
119
 
96
120
  /**
@@ -103,6 +127,7 @@ type TextInputSubmitEditingEventData = $ReadOnly<{
103
127
  ...TargetEvent,
104
128
  eventCount: number,
105
129
  text: string,
130
+ ...
106
131
  }>;
107
132
 
108
133
  /**
@@ -488,10 +513,26 @@ export type TextInputAndroidProps = $ReadOnly<{
488
513
  underlineColorAndroid?: ?ColorValue,
489
514
  }>;
490
515
 
491
- export type TextInputProps = $ReadOnly<{
492
- ...$Diff<ViewProps, $ReadOnly<{style: ?ViewStyleProp}>>,
493
- ...TextInputIOSProps,
494
- ...TextInputAndroidProps,
516
+ type TextInputBaseProps = $ReadOnly<{
517
+ /**
518
+ * When provided, the text input will only accept drag and drop events for the specified
519
+ * types. If null or not provided, the text input will accept all types of drag and drop events.
520
+ * An empty array will accept no drag and drop events.
521
+ * Defaults to null.
522
+ *
523
+ * On Android, types must correspond to MIME types from ClipData:
524
+ * https://developer.android.com/reference/android/content/ClipData
525
+ * (e.g. "text/plain" or "image/*")
526
+ *
527
+ * On iOS, types must correspond to UTIs:
528
+ * https://developer.apple.com/documentation/uniformtypeidentifiers
529
+ * (e.g. "public.plain-text" or "public.image")
530
+ *
531
+ * *NOTE*: This prop is experimental and its API may change in the future. Use at your own risk.
532
+ *
533
+ * @see https://developer.android.com/reference/android/content/ClipData for more information on MIME types
534
+ */
535
+ experimental_acceptDragAndDropTypes?: ?$ReadOnlyArray<string>,
495
536
 
496
537
  /**
497
538
  * Can tell `TextInput` to automatically capitalize certain characters.
@@ -776,33 +817,12 @@ export type TextInputProps = $ReadOnly<{
776
817
  */
777
818
  onChange?: ?(e: TextInputChangeEvent) => mixed,
778
819
 
779
- /**
780
- * DANGER: this API is not stable and will change in the future.
781
- *
782
- * Callback will be called on the main thread and may result in dropped frames.
783
- * Callback that is called when the text input's text changes.
784
- *
785
- * @platform ios
786
- */
787
- unstable_onChangeSync?: ?(e: TextInputChangeEvent) => mixed,
788
-
789
820
  /**
790
821
  * Callback that is called when the text input's text changes.
791
822
  * Changed text is passed as an argument to the callback handler.
792
823
  */
793
824
  onChangeText?: ?(text: string) => mixed,
794
825
 
795
- /**
796
- * DANGER: this API is not stable and will change in the future.
797
- *
798
- * Callback will be called on the main thread and may result in dropped frames.
799
- * Callback that is called when the text input's text changes.
800
- * Changed text is passed as an argument to the callback handler.
801
- *
802
- * @platform ios
803
- */
804
- unstable_onChangeTextSync?: ?(text: string) => mixed,
805
-
806
826
  /**
807
827
  * Callback that is called when the text input's content size changes.
808
828
  * This will be called with
@@ -831,21 +851,6 @@ export type TextInputProps = $ReadOnly<{
831
851
  */
832
852
  onKeyPress?: ?(e: TextInputKeyPressEvent) => mixed,
833
853
 
834
- /**
835
- * DANGER: this API is not stable and will change in the future.
836
- *
837
- * Callback will be called on the main thread and may result in dropped frames.
838
- *
839
- * Callback that is called when a key is pressed.
840
- * This will be called with `{ nativeEvent: { key: keyValue } }`
841
- * where `keyValue` is `'Enter'` or `'Backspace'` for respective keys and
842
- * the typed-in character otherwise including `' '` for space.
843
- * Fires before `onChange` callbacks.
844
- *
845
- * @platform ios
846
- */
847
- unstable_onKeyPressSync?: ?(e: TextInputKeyPressEvent) => mixed,
848
-
849
854
  /**
850
855
  * Called when a single tap gesture is detected.
851
856
  */
@@ -1020,6 +1025,18 @@ export type TextInputProps = $ReadOnly<{
1020
1025
  * unwanted edits without flicker.
1021
1026
  */
1022
1027
  value?: ?Stringish,
1028
+
1029
+ /**
1030
+ * Align the input text to the left, center, or right sides of the input field.
1031
+ */
1032
+ textAlign?: ?('left' | 'center' | 'right'),
1033
+ }>;
1034
+
1035
+ export type TextInputProps = $ReadOnly<{
1036
+ ...Omit<ViewProps, 'style'>,
1037
+ ...TextInputIOSProps,
1038
+ ...TextInputAndroidProps,
1039
+ ...TextInputBaseProps,
1023
1040
  }>;
1024
1041
 
1025
1042
  export interface TextInputInstance extends HostInstance {