@office-iss/react-native-win32 0.0.0-canary.287 → 0.0.0-canary.289

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 (192) hide show
  1. package/.flowconfig +6 -2
  2. package/CHANGELOG.json +63 -1
  3. package/CHANGELOG.md +24 -4
  4. package/Libraries/Alert/Alert.d.ts +4 -1
  5. package/Libraries/Alert/Alert.js +3 -0
  6. package/Libraries/{Modal/ModalInjection.js → Alert/RCTAlertManager.js.flow} +7 -4
  7. package/Libraries/Animated/Animated.js +8 -37
  8. package/Libraries/Animated/Animated.js.flow +15 -0
  9. package/Libraries/Animated/AnimatedExports.js +47 -0
  10. package/Libraries/Animated/AnimatedExports.js.flow +48 -0
  11. package/Libraries/Animated/Easing.js +13 -15
  12. package/Libraries/Animated/createAnimatedComponent.js +24 -12
  13. package/Libraries/Animated/nodes/AnimatedNode.js +2 -1
  14. package/Libraries/Animated/nodes/AnimatedProps.js +18 -1
  15. package/Libraries/Animated/nodes/AnimatedValue.js +6 -2
  16. package/Libraries/Animated/useAnimatedValue.js +1 -3
  17. package/Libraries/Blob/URL.js +23 -10
  18. package/Libraries/Blob/URLSearchParams.js.flow +23 -0
  19. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +1 -1
  20. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +1 -1
  21. package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js.flow +20 -0
  22. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +8 -8
  23. package/Libraries/Components/Button.js +2 -2
  24. package/Libraries/Components/Button.win32.js +2 -2
  25. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +14 -100
  26. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +64 -4
  27. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js +138 -0
  28. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +7 -4
  29. package/Libraries/Components/LayoutConformance/LayoutConformance.js +6 -4
  30. package/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js +1 -1
  31. package/Libraries/Components/Pressable/Pressable.js +18 -63
  32. package/Libraries/Components/Pressable/Pressable.win32.js +19 -65
  33. package/Libraries/Components/Pressable/useAndroidRippleForView.js +2 -2
  34. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +4 -46
  35. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +10 -4
  36. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js +54 -0
  37. package/Libraries/Components/RefreshControl/RefreshControl.js +10 -7
  38. package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +2 -1
  39. package/Libraries/Components/SafeAreaView/SafeAreaView.js +1 -1
  40. package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +1 -1
  41. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +2 -4
  42. package/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +2 -4
  43. package/Libraries/Components/ScrollView/ScrollView.js +43 -59
  44. package/Libraries/Components/ScrollView/ScrollViewCommands.js +1 -1
  45. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +2 -4
  46. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +6 -7
  47. package/Libraries/Components/StatusBar/StatusBar.js +33 -22
  48. package/Libraries/Components/Switch/Switch.js +70 -41
  49. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +2 -4
  50. package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +2 -4
  51. package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +2 -4
  52. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  53. package/Libraries/Components/TextInput/Tests/TextInputTest.d.ts +2 -1
  54. package/Libraries/Components/TextInput/Tests/TextInputTest.js.map +1 -1
  55. package/Libraries/Components/TextInput/TextInput.d.ts +6 -0
  56. package/Libraries/Components/TextInput/TextInput.flow.js +45 -14
  57. package/Libraries/Components/TextInput/TextInput.js +121 -136
  58. package/Libraries/Components/TextInput/TextInput.win32.js +122 -137
  59. package/Libraries/Components/TextInput/TextInputState.js +2 -18
  60. package/Libraries/Components/TextInput/TextInputState.win32.js +2 -18
  61. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +1 -1
  62. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.d.ts +2 -1
  63. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  64. package/Libraries/Components/Touchable/Touchable.js +7 -7
  65. package/Libraries/Components/Touchable/Touchable.win32.js +7 -7
  66. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  67. package/Libraries/Components/Touchable/TouchableHighlight.js +35 -14
  68. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +95 -47
  69. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +248 -43
  70. package/Libraries/Components/Touchable/TouchableOpacity.js +52 -10
  71. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +112 -59
  72. package/Libraries/Components/View/View.js +1 -1
  73. package/Libraries/Components/View/View.win32.js +1 -1
  74. package/Libraries/Components/View/ViewNativeComponent.js +2 -4
  75. package/Libraries/Components/View/ViewPropTypes.js +15 -12
  76. package/Libraries/Components/View/ViewPropTypes.win32.js +74 -71
  77. package/Libraries/Core/ReactNativeVersion.js +2 -2
  78. package/Libraries/Core/setUpReactDevTools.js +2 -0
  79. package/Libraries/Debugging/DebuggingOverlayRegistry.js +10 -7
  80. package/Libraries/Image/Image.android.js +1 -1
  81. package/Libraries/Image/Image.js.flow +27 -0
  82. package/Libraries/Image/ImageBackground.js +1 -1
  83. package/Libraries/Image/ImageProps.js +97 -30
  84. package/Libraries/Image/ImageTypes.flow.js +16 -6
  85. package/Libraries/Image/ImageViewNativeComponent.js +3 -5
  86. package/Libraries/Image/Tests/ImageWin32Test.d.ts +2 -1
  87. package/Libraries/Image/Tests/ImageWin32Test.js.map +1 -1
  88. package/Libraries/Image/TextInlineImageNativeComponent.js +2 -4
  89. package/Libraries/Interaction/InteractionManager.js +9 -1
  90. package/Libraries/Interaction/PanResponder.js +11 -11
  91. package/Libraries/Interaction/TaskQueue.js +3 -2
  92. package/Libraries/Lists/FlatList.js +8 -7
  93. package/Libraries/LogBox/LogBox.js +1 -1
  94. package/Libraries/Modal/Modal.js +30 -4
  95. package/Libraries/NativeComponent/BaseViewConfig.js.flow +14 -0
  96. package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
  97. package/Libraries/Network/RCTNetworking.js.flow +44 -0
  98. package/Libraries/Network/XMLHttpRequest_new.js +3 -0
  99. package/Libraries/Network/XMLHttpRequest_old.js +3 -0
  100. package/Libraries/Pressability/HoverState.js +1 -0
  101. package/Libraries/Pressability/HoverState.win32.js +1 -0
  102. package/Libraries/Pressability/Pressability.js +2 -2
  103. package/Libraries/Pressability/Pressability.win32.js +3 -3
  104. package/Libraries/ReactNative/AppRegistry.flow.js +49 -0
  105. package/Libraries/ReactNative/AppRegistry.js +2 -322
  106. package/Libraries/ReactNative/AppRegistry.js.flow +23 -0
  107. package/Libraries/ReactNative/AppRegistryImpl.js +316 -0
  108. package/Libraries/ReactNative/FabricUIManager.js +5 -3
  109. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +7 -5
  110. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +1 -4
  111. package/Libraries/ReactNative/RendererImplementation.js +3 -5
  112. package/Libraries/ReactNative/requireNativeComponent.js +1 -1
  113. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +12 -0
  114. package/Libraries/Renderer/shims/ReactNativeTypes.js +39 -91
  115. package/Libraries/StyleSheet/PlatformColorValueTypes.js.flow +22 -0
  116. package/Libraries/StyleSheet/PlatformColorValueTypesIOS.js +6 -0
  117. package/Libraries/StyleSheet/StyleSheet.js +5 -197
  118. package/Libraries/StyleSheet/StyleSheet.js.flow +166 -0
  119. package/Libraries/StyleSheet/{StyleSheet.win32.js → StyleSheetExports.js} +2 -151
  120. package/Libraries/StyleSheet/StyleSheetExports.js.flow +110 -0
  121. package/Libraries/StyleSheet/StyleSheetTypes.js +42 -18
  122. package/Libraries/Text/Text.d.ts +1 -1
  123. package/Libraries/Text/Text.js +3 -1
  124. package/Libraries/Text/Text.win32.js +3 -1
  125. package/Libraries/Text/TextNativeComponent.js +1 -1
  126. package/Libraries/Text/TextNativeComponent.win32.js +1 -1
  127. package/Libraries/Text/TextProps.js +124 -84
  128. package/Libraries/Text/TextProps.win32.js +124 -84
  129. package/Libraries/Types/CodegenTypesNamespace.d.ts +45 -0
  130. package/Libraries/Types/CodegenTypesNamespace.js +14 -0
  131. package/Libraries/Types/CoreEventTypes.js +1 -1
  132. package/Libraries/Types/CoreEventTypes.win32.js +1 -1
  133. package/Libraries/Types/ReactDevToolsTypes.js +4 -8
  134. package/Libraries/Utilities/BackHandler.js.flow +25 -0
  135. package/Libraries/Utilities/DevSettings.js +14 -0
  136. package/Libraries/Utilities/Dimensions.js +5 -0
  137. package/Libraries/Utilities/Dimensions.win32.js +5 -0
  138. package/{flow/Position.js → Libraries/Utilities/Platform.js.flow} +3 -6
  139. package/Libraries/Utilities/PlatformTypes.js +97 -7
  140. package/Libraries/Utilities/codegenNativeCommands.d.ts +18 -0
  141. package/Libraries/Utilities/codegenNativeComponent.d.ts +26 -0
  142. package/Libraries/Utilities/codegenNativeComponent.js +1 -1
  143. package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +2 -4
  144. package/Libraries/vendor/emitter/EventEmitter.js +6 -2
  145. package/flow/global.js +1 -0
  146. package/flow/jest.js +4 -2
  147. package/index.js +47 -43
  148. package/index.win32.js +63 -59
  149. package/overrides.json +27 -35
  150. package/package.json +18 -18
  151. package/src/private/animated/NativeAnimatedHelper.js +18 -7
  152. package/src/private/animated/NativeAnimatedHelper.win32.js +18 -7
  153. package/src/private/animated/createAnimatedPropsHook.js +34 -15
  154. package/src/private/components/HScrollViewNativeComponents.js +1 -1
  155. package/src/private/components/VScrollViewNativeComponents.js +1 -1
  156. package/src/private/featureflags/ReactNativeFeatureFlags.js +24 -36
  157. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +9 -1
  158. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +4 -4
  159. package/src/private/inspector/getInspectorDataForViewAtPoint.js +2 -4
  160. package/src/private/setup/setUpDOM.js +36 -1
  161. package/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js +1 -1
  162. package/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js +1 -1
  163. package/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js +1 -1
  164. package/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js +1 -1
  165. package/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js +1 -1
  166. package/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js +1 -1
  167. package/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js +1 -1
  168. package/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js +1 -1
  169. package/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js +1 -1
  170. package/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js +1 -1
  171. package/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js +1 -1
  172. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +1 -1
  173. package/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js +1 -1
  174. package/src/private/types/HostComponent.js +16 -0
  175. package/src/private/types/HostInstance.js +50 -0
  176. package/src/private/webapis/dom/nodes/ReactNativeDocument.js +1 -0
  177. package/src/private/webapis/dom/nodes/ReactNativeElement.js +40 -32
  178. package/src/private/webapis/dom/nodes/ReadOnlyCharacterData.js +1 -1
  179. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +1 -1
  180. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -19
  181. package/src/private/webapis/dom/nodes/internals/NodeInternals.js +6 -0
  182. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +4 -4
  183. package/src/private/webapis/mutationobserver/MutationObserver.js +9 -9
  184. package/src/private/webapis/performance/PerformanceObserver.js +6 -6
  185. package/src/types/globals.d.ts +628 -0
  186. package/src/types/third_party/event-target-shim.d.ts +392 -0
  187. package/src-win/Libraries/Components/TextInput/Tests/TextInputTest.tsx +7 -7
  188. package/src-win/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +3 -3
  189. package/src-win/Libraries/Image/Tests/ImageWin32Test.tsx +1 -1
  190. package/src-win/Libraries/Text/Text.d.ts +1 -1
  191. package/types/index.d.ts +5 -52
  192. package/types/modules/globals.d.ts +0 -599
@@ -8,17 +8,16 @@
8
8
  * @format
9
9
  */
10
10
 
11
- import type {HostInstance} from '../../Renderer/shims/ReactNativeTypes';
11
+ import type {HostInstance} from '../../../src/private/types/HostInstance';
12
12
  import type {____TextStyle_Internal as TextStyleInternal} from '../../StyleSheet/StyleSheetTypes';
13
13
  import type {
14
14
  GestureResponderEvent,
15
- ScrollEvent,
16
15
  NativeSyntheticEvent,
16
+ ScrollEvent,
17
17
  } from '../../Types/CoreEventTypes';
18
18
  import type {ViewProps} from '../View/ViewPropTypes';
19
- import type {TextInputType} from './TextInput.flow';
19
+ import type {TextInputInstance, TextInputType} from './TextInput.flow';
20
20
 
21
- import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
22
21
  import usePressability from '../../Pressability/usePressability';
23
22
  import flattenStyle from '../../StyleSheet/flattenStyle';
24
23
  import StyleSheet, {
@@ -36,14 +35,6 @@ import nullthrows from 'nullthrows';
36
35
  import * as React from 'react';
37
36
  import {useCallback, useLayoutEffect, useRef, useState} from 'react';
38
37
 
39
- type ReactRefSetter<T> = {current: null | T, ...} | ((ref: null | T) => mixed);
40
- type TextInputInstance = HostInstance & {
41
- +clear: () => void,
42
- +isFocused: () => boolean,
43
- +getNativeRef: () => ?HostInstance,
44
- +setSelection: (start: number, end: number) => void,
45
- };
46
-
47
38
  let AndroidTextInput;
48
39
  let AndroidTextInputCommands;
49
40
  let RCTSinglelineTextInputView;
@@ -77,6 +68,9 @@ else if (Platform.OS === 'win32') {
77
68
  }
78
69
  // Windows]
79
70
 
71
+ /**
72
+ * @see TextInputProps.onChange
73
+ */
80
74
  export type TextInputChangeEventData = $ReadOnly<{
81
75
  eventCount: number,
82
76
  target: number,
@@ -99,6 +93,9 @@ export type TextInputEvent = NativeSyntheticEvent<
99
93
  }>,
100
94
  >;
101
95
 
96
+ /**
97
+ * @see TextInputProps.onContentSizeChange
98
+ */
102
99
  export type TextInputContentSizeChangeEventData = $ReadOnly<{
103
100
  target: number,
104
101
  contentSize: $ReadOnly<{
@@ -114,16 +111,29 @@ export type TargetEvent = $ReadOnly<{
114
111
  target: number,
115
112
  }>;
116
113
 
114
+ /**
115
+ * @see TextInputProps.onFocus
116
+ */
117
117
  export type TextInputFocusEventData = TargetEvent;
118
118
 
119
119
  export type TextInputBlurEvent = NativeSyntheticEvent<TextInputFocusEventData>;
120
120
  export type TextInputFocusEvent = NativeSyntheticEvent<TextInputFocusEventData>;
121
121
 
122
+ /**
123
+ * @see TextInputProps.onScroll
124
+ */
125
+ export type TextInputScrollEventData = {
126
+ contentOffset: {x: number, y: number},
127
+ };
128
+
122
129
  type Selection = $ReadOnly<{
123
130
  start: number,
124
131
  end: number,
125
132
  }>;
126
133
 
134
+ /**
135
+ * @see TextInputProps.onSelectionChange
136
+ */
127
137
  export type TextInputSelectionChangeEventData = $ReadOnly<{
128
138
  ...TargetEvent,
129
139
  selection: Selection,
@@ -132,7 +142,10 @@ export type TextInputSelectionChangeEventData = $ReadOnly<{
132
142
  export type TextInputSelectionChangeEvent =
133
143
  NativeSyntheticEvent<TextInputSelectionChangeEventData>;
134
144
 
135
- type TextInputKeyPressEventData = $ReadOnly<{
145
+ /**
146
+ * @see TextInputProps.onKeyPress
147
+ */
148
+ export type TextInputKeyPressEventData = $ReadOnly<{
136
149
  ...TargetEvent,
137
150
  key: string,
138
151
  target?: ?number,
@@ -142,12 +155,30 @@ type TextInputKeyPressEventData = $ReadOnly<{
142
155
  export type TextInputKeyPressEvent =
143
156
  NativeSyntheticEvent<TextInputKeyPressEventData>;
144
157
 
158
+ /**
159
+ * @see TextInputProps.onEndEditing
160
+ */
145
161
  export type TextInputEndEditingEventData = $ReadOnly<{
146
162
  ...TargetEvent,
147
163
  eventCount: number,
148
164
  text: string,
149
165
  }>;
150
166
 
167
+ export type TextInputEndEditingEvent =
168
+ NativeSyntheticEvent<TextInputEndEditingEventData>;
169
+
170
+ /**
171
+ * @see TextInputProps.onSubmitEditing
172
+ */
173
+ export type TextInputSubmitEditingEventData = $ReadOnly<{
174
+ ...TargetEvent,
175
+ eventCount: number,
176
+ text: string,
177
+ }>;
178
+
179
+ export type TextInputSubmitEditingEvent =
180
+ NativeSyntheticEvent<TextInputSubmitEditingEventData>;
181
+
151
182
  export type TextInputEditingEvent =
152
183
  NativeSyntheticEvent<TextInputEndEditingEventData>;
153
184
 
@@ -435,6 +466,21 @@ export type TextInputAndroidProps = $ReadOnly<{
435
466
  */
436
467
  disableFullscreenUI?: ?boolean,
437
468
 
469
+ /**
470
+ * Determines whether the individual fields in your app should be included in a
471
+ * view structure for autofill purposes on Android API Level 26+. Defaults to auto.
472
+ * To disable auto complete, use `off`.
473
+ *
474
+ * *Android Only*
475
+ *
476
+ * The following values work on Android only:
477
+ *
478
+ * - `auto` - let Android decide
479
+ * - `no` - not important for autofill
480
+ * - `noExcludeDescendants` - this view and its children aren't important for autofill
481
+ * - `yes` - is important for autofill
482
+ * - `yesExcludeDescendants` - this view is important for autofill but its children aren't
483
+ */
438
484
  importantForAutofill?: ?(
439
485
  | 'auto'
440
486
  | 'no'
@@ -528,12 +574,7 @@ type TextInputWindowsProps = $ReadOnly<{|
528
574
 
529
575
  // Windows]
530
576
 
531
- export type TextInputProps = $ReadOnly<{
532
- ...$Diff<ViewProps, $ReadOnly<{style: ?ViewStyleProp}>>,
533
- ...TextInputIOSProps,
534
- ...TextInputAndroidProps,
535
- ...TextInputWindowsProps, // [Windows]
536
-
577
+ type TextInputBaseProps = $ReadOnly<{
537
578
  /**
538
579
  * String to be read by screenreaders to indicate an error state. The acceptable parameters
539
580
  * of accessibilityErrorMessage is a string. Setting accessibilityInvalid to true activates
@@ -728,7 +769,7 @@ export type TextInputProps = $ReadOnly<{
728
769
  */
729
770
  editable?: ?boolean,
730
771
 
731
- forwardedRef?: ?ReactRefSetter<TextInputInstance>,
772
+ forwardedRef?: ?React.RefSetter<TextInputInstance>,
732
773
 
733
774
  /**
734
775
  * `enterKeyHint` defines what action label (or icon) to present for the enter key on virtual keyboards.
@@ -843,7 +884,7 @@ export type TextInputProps = $ReadOnly<{
843
884
  /**
844
885
  * Callback that is called when text input ends.
845
886
  */
846
- onEndEditing?: ?(e: TextInputEditingEvent) => mixed,
887
+ onEndEditing?: ?(e: TextInputEndEditingEvent) => mixed,
847
888
 
848
889
  /**
849
890
  * Callback that is called when the text input is focused.
@@ -885,7 +926,7 @@ export type TextInputProps = $ReadOnly<{
885
926
  * Callback that is called when the text input's submit button is pressed.
886
927
  * Invalid if `multiline={true}` is specified.
887
928
  */
888
- onSubmitEditing?: ?(e: TextInputEditingEvent) => mixed,
929
+ onSubmitEditing?: ?(e: TextInputSubmitEditingEvent) => mixed,
889
930
 
890
931
  /**
891
932
  * Invoked on content scroll with `{ nativeEvent: { contentOffset: { x, y } } }`.
@@ -966,7 +1007,9 @@ export type TextInputProps = $ReadOnly<{
966
1007
  selectionColor?: ?ColorValue,
967
1008
 
968
1009
  /**
969
- * The text selection handle color.
1010
+ * When provided it will set the color of the selection handles when highlighting text.
1011
+ * Unlike the behavior of `selectionColor` the handle color will be set independently
1012
+ * from the color of the text selection box.
970
1013
  * @platform android
971
1014
  */
972
1015
  selectionHandleColor?: ?ColorValue,
@@ -1041,6 +1084,43 @@ export type TextInputProps = $ReadOnly<{
1041
1084
  value?: ?Stringish,
1042
1085
  }>;
1043
1086
 
1087
+ export type TextInputProps = $ReadOnly<{
1088
+ ...$Diff<ViewProps, $ReadOnly<{style: ?ViewStyleProp}>>,
1089
+ ...TextInputIOSProps,
1090
+ ...TextInputAndroidProps,
1091
+ ...TextInputBaseProps,
1092
+ ...TextInputWindowsProps, // [Windows]
1093
+ }>;
1094
+
1095
+ type TextInputStateType = $ReadOnly<{
1096
+ /**
1097
+ * @deprecated Use currentlyFocusedInput
1098
+ * Returns the ID of the currently focused text field, if one exists
1099
+ * If no text field is focused it returns null
1100
+ */
1101
+ currentlyFocusedField: () => ?number,
1102
+
1103
+ /**
1104
+ * Returns the ref of the currently focused text field, if one exists
1105
+ * If no text field is focused it returns null
1106
+ */
1107
+ currentlyFocusedInput: () => ?HostInstance,
1108
+
1109
+ /**
1110
+ * @param textField ref of the text field to focus
1111
+ * Focuses the specified text field
1112
+ * noop if the text field was already focused
1113
+ */
1114
+ focusTextInput: (textField: ?HostInstance) => void,
1115
+
1116
+ /**
1117
+ * @param textField ref of the text field to focus
1118
+ * Unfocuses the specified text field
1119
+ * noop if it wasn't focused
1120
+ */
1121
+ blurTextInput: (textField: ?HostInstance) => void,
1122
+ }>;
1123
+
1044
1124
  type ViewCommands = $NonMaybeType<
1045
1125
  | typeof AndroidTextInputCommands
1046
1126
  | typeof RCTMultilineTextInputNativeCommands
@@ -1059,7 +1139,7 @@ const emptyFunctionThatReturnsTrue = () => true;
1059
1139
  * in native and in JavaScript. This is necessary due to the asynchronous nature
1060
1140
  * of text input events.
1061
1141
  */
1062
- function useTextInputStateSynchronization_STATE({
1142
+ function useTextInputStateSynchronization({
1063
1143
  props,
1064
1144
  mostRecentEventCount,
1065
1145
  selection,
@@ -1070,8 +1150,8 @@ function useTextInputStateSynchronization_STATE({
1070
1150
  props: TextInputProps,
1071
1151
  mostRecentEventCount: number,
1072
1152
  selection: ?Selection,
1073
- inputRef: React.RefObject<null | HostInstance>,
1074
- text: string,
1153
+ inputRef: React.RefObject<null | TextInputInstance>,
1154
+ text?: string,
1075
1155
  viewCommands: ViewCommands,
1076
1156
  }): {
1077
1157
  setLastNativeText: string => void,
@@ -1135,94 +1215,6 @@ function useTextInputStateSynchronization_STATE({
1135
1215
  return {setLastNativeText, setLastNativeSelection};
1136
1216
  }
1137
1217
 
1138
- /**
1139
- * This hook handles the synchronization between the state of the text input
1140
- * in native and in JavaScript. This is necessary due to the asynchronous nature
1141
- * of text input events.
1142
- */
1143
- function useTextInputStateSynchronization_REFS({
1144
- props,
1145
- mostRecentEventCount,
1146
- selection,
1147
- inputRef,
1148
- text,
1149
- viewCommands,
1150
- }: {
1151
- props: TextInputProps,
1152
- mostRecentEventCount: number,
1153
- selection: ?Selection,
1154
- inputRef: React.RefObject<null | HostInstance>,
1155
- text: string,
1156
- viewCommands: ViewCommands,
1157
- }): {
1158
- setLastNativeText: string => void,
1159
- setLastNativeSelection: LastNativeSelection => void,
1160
- } {
1161
- const lastNativeTextRef = useRef<?Stringish>(props.value);
1162
- const lastNativeSelectionRef = useRef<LastNativeSelection>({
1163
- selection: {start: -1, end: -1},
1164
- mostRecentEventCount: mostRecentEventCount,
1165
- });
1166
-
1167
- // This is necessary in case native updates the text and JS decides
1168
- // that the update should be ignored and we should stick with the value
1169
- // that we have in JS.
1170
- useLayoutEffect(() => {
1171
- const nativeUpdate: {text?: string, selection?: Selection} = {};
1172
-
1173
- const lastNativeSelection = lastNativeSelectionRef.current.selection;
1174
-
1175
- if (
1176
- lastNativeTextRef.current !== props.value &&
1177
- typeof props.value === 'string'
1178
- ) {
1179
- nativeUpdate.text = props.value;
1180
- lastNativeTextRef.current = props.value;
1181
- }
1182
-
1183
- if (
1184
- selection &&
1185
- lastNativeSelection &&
1186
- (lastNativeSelection.start !== selection.start ||
1187
- lastNativeSelection.end !== selection.end)
1188
- ) {
1189
- nativeUpdate.selection = selection;
1190
- lastNativeSelectionRef.current = {selection, mostRecentEventCount};
1191
- }
1192
-
1193
- if (Object.keys(nativeUpdate).length === 0) {
1194
- return;
1195
- }
1196
-
1197
- if (inputRef.current != null) {
1198
- viewCommands.setTextAndSelection(
1199
- inputRef.current,
1200
- mostRecentEventCount,
1201
- text,
1202
- selection?.start ?? -1,
1203
- selection?.end ?? -1,
1204
- );
1205
- }
1206
- }, [
1207
- mostRecentEventCount,
1208
- inputRef,
1209
- props.value,
1210
- props.defaultValue,
1211
- selection,
1212
- text,
1213
- viewCommands,
1214
- ]);
1215
-
1216
- return {
1217
- setLastNativeText: lastNativeText => {
1218
- lastNativeTextRef.current = lastNativeText;
1219
- },
1220
- setLastNativeSelection: lastNativeSelection => {
1221
- lastNativeSelectionRef.current = lastNativeSelection;
1222
- },
1223
- };
1224
- }
1225
-
1226
1218
  /**
1227
1219
  * A foundational component for inputting text into the app via a
1228
1220
  * keyboard. Props provide configurability for several features, such as
@@ -1353,7 +1345,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
1353
1345
  ...otherProps
1354
1346
  } = props;
1355
1347
 
1356
- const inputRef = useRef<null | HostInstance>(null);
1348
+ const inputRef = useRef<null | TextInputInstance>(null);
1357
1349
 
1358
1350
  const selection: ?Selection =
1359
1351
  propsSelection == null
@@ -1368,7 +1360,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
1368
1360
  ? props.value
1369
1361
  : typeof props.defaultValue === 'string'
1370
1362
  ? props.defaultValue
1371
- : '';
1363
+ : undefined;
1372
1364
 
1373
1365
  const viewCommands =
1374
1366
  WindowsTextInputCommands || // [Windows]
@@ -1378,10 +1370,6 @@ function InternalTextInput(props: TextInputProps): React.Node {
1378
1370
  : RCTSinglelineTextInputNativeCommands);
1379
1371
 
1380
1372
  const [mostRecentEventCount, setMostRecentEventCount] = useState<number>(0);
1381
- const useTextInputStateSynchronization =
1382
- ReactNativeFeatureFlags.useRefsForTextInputState()
1383
- ? useTextInputStateSynchronization_REFS
1384
- : useTextInputStateSynchronization_STATE;
1385
1373
  const {setLastNativeText, setLastNativeSelection} =
1386
1374
  useTextInputStateSynchronization({
1387
1375
  props,
@@ -1410,7 +1398,8 @@ function InternalTextInput(props: TextInputProps): React.Node {
1410
1398
  }, []);
1411
1399
 
1412
1400
  const setLocalRef = useCallback(
1413
- (instance: TextInputInstance | null) => {
1401
+ (instance: HostInstance | null) => {
1402
+ // $FlowExpectedError[incompatible-type]
1414
1403
  inputRef.current = instance;
1415
1404
 
1416
1405
  /*
@@ -1436,7 +1425,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
1436
1425
  before we can get to the long term breaking change.
1437
1426
  */
1438
1427
  if (instance != null) {
1439
- // $FlowFixMe[incompatible-use] - See the explanation above.
1428
+ // $FlowFixMe[prop-missing] - See the explanation above.
1440
1429
  Object.assign(instance, {
1441
1430
  clear(): void {
1442
1431
  if (inputRef.current != null) {
@@ -1457,7 +1446,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
1457
1446
  currentlyFocusedInput === inputRef.current
1458
1447
  );
1459
1448
  },
1460
- getNativeRef(): ?HostInstance {
1449
+ getNativeRef(): ?TextInputInstance {
1461
1450
  return inputRef.current;
1462
1451
  },
1463
1452
  setSelection(start: number, end: number): void {
@@ -1477,7 +1466,8 @@ function InternalTextInput(props: TextInputProps): React.Node {
1477
1466
  [mostRecentEventCount, viewCommands],
1478
1467
  );
1479
1468
 
1480
- const ref = useMergeRefs<TextInputInstance>(setLocalRef, props.forwardedRef);
1469
+ // $FlowExpectedError[incompatible-call]
1470
+ const ref = useMergeRefs<HostInstance>(setLocalRef, props.forwardedRef);
1481
1471
 
1482
1472
  const _onChange = (event: TextInputChangeEvent) => {
1483
1473
  const currentText = event.nativeEvent.text;
@@ -1727,8 +1717,8 @@ function InternalTextInput(props: TextInputProps): React.Node {
1727
1717
 
1728
1718
  textInput = (
1729
1719
  <RCTTextInputView
1730
- // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1731
- ref={ref}
1720
+ // Figure out imperative + forward refs.
1721
+ ref={(ref: $FlowFixMe)}
1732
1722
  {...otherProps}
1733
1723
  {...eventHandlers}
1734
1724
  accessibilityErrorMessage={accessibilityErrorMessage}
@@ -1740,6 +1730,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
1740
1730
  focusable={tabIndex !== undefined ? !tabIndex : focusable}
1741
1731
  mostRecentEventCount={mostRecentEventCount}
1742
1732
  nativeID={id ?? props.nativeID}
1733
+ numberOfLines={props.rows ?? props.numberOfLines}
1743
1734
  onBlur={_onBlur}
1744
1735
  onChange={_onChange}
1745
1736
  onContentSizeChange={props.onContentSizeChange}
@@ -1789,8 +1780,8 @@ function InternalTextInput(props: TextInputProps): React.Node {
1789
1780
  * match up exactly with the props for TextInput. This will need to get
1790
1781
  * fixed */
1791
1782
  <AndroidTextInput
1792
- // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1793
- ref={ref}
1783
+ // Figure out imperative + forward refs.
1784
+ ref={(ref: $FlowFixMe)}
1794
1785
  {...otherProps}
1795
1786
  {...colorProps}
1796
1787
  {...eventHandlers}
@@ -1952,9 +1943,8 @@ const autoCompleteWebToTextContentTypeMap = {
1952
1943
  };
1953
1944
 
1954
1945
  const ExportedForwardRef: component(
1955
- ref: React.RefSetter<TextInputInstance>,
1946
+ ref?: React.RefSetter<TextInputInstance>,
1956
1947
  ...props: React.ElementConfig<typeof InternalTextInput>
1957
- // $FlowFixMe[incompatible-call]
1958
1948
  ) = React.forwardRef(function TextInput(
1959
1949
  {
1960
1950
  allowFontScaling = true,
@@ -1971,7 +1961,7 @@ const ExportedForwardRef: component(
1971
1961
  keyboardType,
1972
1962
  ...restProps
1973
1963
  },
1974
- forwardedRef: ReactRefSetter<TextInputInstance>,
1964
+ forwardedRef: React.RefSetter<TextInputInstance>,
1975
1965
  ) {
1976
1966
  return (
1977
1967
  <InternalTextInput
@@ -2024,12 +2014,7 @@ ExportedForwardRef.State = {
2024
2014
  };
2025
2015
 
2026
2016
  export type TextInputComponentStatics = $ReadOnly<{
2027
- State: $ReadOnly<{
2028
- currentlyFocusedInput: typeof TextInputState.currentlyFocusedInput,
2029
- currentlyFocusedField: typeof TextInputState.currentlyFocusedField,
2030
- focusTextInput: typeof TextInputState.focusTextInput,
2031
- blurTextInput: typeof TextInputState.blurTextInput,
2032
- }>,
2017
+ State: TextInputStateType,
2033
2018
  }>;
2034
2019
 
2035
2020
  const styles = StyleSheet.create({
@@ -12,12 +12,7 @@
12
12
  // TextInputs. All calls relating to the keyboard should be funneled
13
13
  // through here.
14
14
 
15
- import type {
16
- HostInstance,
17
- MeasureInWindowOnSuccessCallback,
18
- MeasureLayoutOnSuccessCallback,
19
- MeasureOnSuccessCallback,
20
- } from '../../Renderer/shims/ReactNativeTypes';
15
+ import type {HostInstance} from '../../../src/private/types/HostInstance';
21
16
 
22
17
  import {Commands as AndroidTextInputCommands} from '../../Components/TextInput/AndroidTextInputNativeComponent';
23
18
  import {Commands as iOSTextInputCommands} from '../../Components/TextInput/RCTSingelineTextInputNativeComponent';
@@ -26,18 +21,7 @@ const {findNodeHandle} = require('../../ReactNative/RendererProxy');
26
21
  const Platform = require('../../Utilities/Platform').default;
27
22
 
28
23
  let currentlyFocusedInputRef: ?HostInstance = null;
29
- const inputs = new Set<{
30
- blur(): void,
31
- focus(): void,
32
- measure(callback: MeasureOnSuccessCallback): void,
33
- measureInWindow(callback: MeasureInWindowOnSuccessCallback): void,
34
- measureLayout(
35
- relativeToNativeNode: number | HostInstance,
36
- onSuccess: MeasureLayoutOnSuccessCallback,
37
- onFail?: () => void,
38
- ): void,
39
- setNativeProps(nativeProps: {...}): void,
40
- }>();
24
+ const inputs = new Set<HostInstance>();
41
25
 
42
26
  function currentlyFocusedInput(): ?HostInstance {
43
27
  return currentlyFocusedInputRef;
@@ -12,12 +12,7 @@
12
12
  // TextInputs. All calls relating to the keyboard should be funneled
13
13
  // through here.
14
14
 
15
- import type {
16
- HostInstance,
17
- MeasureInWindowOnSuccessCallback,
18
- MeasureLayoutOnSuccessCallback,
19
- MeasureOnSuccessCallback,
20
- } from '../../Renderer/shims/ReactNativeTypes';
15
+ import type {HostInstance} from '../../../src/private/types/HostInstance';
21
16
 
22
17
  import {Commands as AndroidTextInputCommands} from '../../Components/TextInput/AndroidTextInputNativeComponent';
23
18
  import {Commands as iOSTextInputCommands} from '../../Components/TextInput/RCTSingelineTextInputNativeComponent';
@@ -27,18 +22,7 @@ const {findNodeHandle} = require('../../ReactNative/RendererProxy');
27
22
  const Platform = require('../../Utilities/Platform').default;
28
23
 
29
24
  let currentlyFocusedInputRef: ?HostInstance = null;
30
- const inputs = new Set<{
31
- blur(): void,
32
- focus(): void,
33
- measure(callback: MeasureOnSuccessCallback): void,
34
- measureInWindow(callback: MeasureInWindowOnSuccessCallback): void,
35
- measureLayout(
36
- relativeToNativeNode: number | HostInstance,
37
- onSuccess: MeasureLayoutOnSuccessCallback,
38
- onFail?: () => void,
39
- ): void,
40
- setNativeProps(nativeProps: {...}): void,
41
- }>();
25
+ const inputs = new Set<HostInstance>();
42
26
 
43
27
  function currentlyFocusedInput(): ?HostInstance {
44
28
  return currentlyFocusedInputRef;
@@ -3,7 +3,7 @@
3
3
  * @format
4
4
  */
5
5
 
6
- import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
6
+ import type {HostComponent} from '../../../src/private/types/HostComponent';
7
7
 
8
8
  import requireNativeComponent from '../../ReactNative/requireNativeComponent';
9
9
  import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
@@ -1,8 +1,9 @@
1
+ import React from 'react';
1
2
  export declare const displayName = "TouchableWin32 Examples";
2
3
  export declare const title = "TouchableWin32";
3
4
  export declare const description = "Demonstration of touchable + focus + hover behavior all in one component";
4
5
  export declare const examples: {
5
6
  title: string;
6
7
  description: string;
7
- render(): JSX.Element;
8
+ render(): React.JSX.Element;
8
9
  }[];