@office-iss/react-native-win32 0.0.0-canary.286 → 0.0.0-canary.288

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 (148) hide show
  1. package/.flowconfig +4 -1
  2. package/CHANGELOG.json +57 -1
  3. package/CHANGELOG.md +23 -4
  4. package/Libraries/Alert/RCTAlertManager.js.flow +18 -0
  5. package/Libraries/Animated/Animated.js +8 -37
  6. package/Libraries/Animated/Animated.js.flow +15 -0
  7. package/Libraries/Animated/AnimatedExports.js +47 -0
  8. package/Libraries/Animated/AnimatedExports.js.flow +48 -0
  9. package/Libraries/Animated/useAnimatedValue.js +1 -3
  10. package/Libraries/Blob/URLSearchParams.js.flow +23 -0
  11. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +1 -1
  12. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +1 -1
  13. package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js.flow +20 -0
  14. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +8 -8
  15. package/Libraries/Components/Button.js +2 -2
  16. package/Libraries/Components/Button.win32.js +2 -2
  17. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +14 -100
  18. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +64 -4
  19. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js +138 -0
  20. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +7 -4
  21. package/Libraries/Components/LayoutConformance/LayoutConformance.js +6 -4
  22. package/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js +1 -1
  23. package/Libraries/Components/Pressable/Pressable.js +18 -63
  24. package/Libraries/Components/Pressable/Pressable.win32.js +19 -65
  25. package/Libraries/Components/Pressable/useAndroidRippleForView.js +2 -2
  26. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +4 -46
  27. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +10 -4
  28. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js +54 -0
  29. package/Libraries/Components/RefreshControl/RefreshControl.js +10 -7
  30. package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +2 -1
  31. package/Libraries/Components/SafeAreaView/SafeAreaView.js +1 -1
  32. package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +1 -1
  33. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +2 -4
  34. package/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +2 -4
  35. package/Libraries/Components/ScrollView/ScrollView.js +43 -59
  36. package/Libraries/Components/ScrollView/ScrollViewCommands.js +1 -1
  37. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +2 -4
  38. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +6 -7
  39. package/Libraries/Components/StatusBar/StatusBar.js +33 -22
  40. package/Libraries/Components/Switch/Switch.js +70 -41
  41. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +2 -4
  42. package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +2 -4
  43. package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +2 -4
  44. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  45. package/Libraries/Components/TextInput/TextInput.flow.js +10 -12
  46. package/Libraries/Components/TextInput/TextInput.js +22 -28
  47. package/Libraries/Components/TextInput/TextInput.win32.js +22 -28
  48. package/Libraries/Components/TextInput/TextInputState.js +2 -18
  49. package/Libraries/Components/TextInput/TextInputState.win32.js +2 -18
  50. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +1 -1
  51. package/Libraries/Components/Touchable/Touchable.js +7 -7
  52. package/Libraries/Components/Touchable/Touchable.win32.js +7 -7
  53. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  54. package/Libraries/Components/Touchable/TouchableHighlight.js +35 -14
  55. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +95 -47
  56. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +248 -43
  57. package/Libraries/Components/Touchable/TouchableOpacity.js +52 -10
  58. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +112 -59
  59. package/Libraries/Components/View/View.js +1 -1
  60. package/Libraries/Components/View/View.win32.js +1 -1
  61. package/Libraries/Components/View/ViewNativeComponent.js +2 -4
  62. package/Libraries/Components/View/ViewPropTypes.js +15 -12
  63. package/Libraries/Components/View/ViewPropTypes.win32.js +74 -71
  64. package/Libraries/Core/ReactNativeVersion.js +1 -1
  65. package/Libraries/Core/setUpReactDevTools.js +2 -0
  66. package/Libraries/Debugging/DebuggingOverlayRegistry.js +10 -7
  67. package/Libraries/Image/Image.android.js +1 -1
  68. package/Libraries/Image/Image.js.flow +27 -0
  69. package/Libraries/Image/ImageBackground.js +1 -1
  70. package/Libraries/Image/ImageProps.js +97 -30
  71. package/Libraries/Image/ImageTypes.flow.js +16 -6
  72. package/Libraries/Image/ImageViewNativeComponent.js +3 -5
  73. package/Libraries/Image/TextInlineImageNativeComponent.js +2 -4
  74. package/Libraries/Interaction/InteractionManager.js +9 -1
  75. package/Libraries/Interaction/PanResponder.js +11 -11
  76. package/Libraries/Interaction/TaskQueue.js +2 -2
  77. package/Libraries/Lists/FlatList.js +8 -7
  78. package/Libraries/LogBox/LogBox.js +1 -1
  79. package/Libraries/NativeComponent/BaseViewConfig.js.flow +14 -0
  80. package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
  81. package/Libraries/Network/RCTNetworking.js.flow +44 -0
  82. package/Libraries/Network/XMLHttpRequest_new.js +3 -0
  83. package/Libraries/Network/XMLHttpRequest_old.js +3 -0
  84. package/Libraries/Pressability/HoverState.js +1 -0
  85. package/Libraries/Pressability/HoverState.win32.js +1 -0
  86. package/Libraries/Pressability/Pressability.js +2 -2
  87. package/Libraries/Pressability/Pressability.win32.js +3 -3
  88. package/Libraries/ReactNative/FabricUIManager.js +5 -3
  89. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +7 -5
  90. package/Libraries/ReactNative/RendererImplementation.js +3 -5
  91. package/Libraries/ReactNative/requireNativeComponent.js +1 -1
  92. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +12 -0
  93. package/Libraries/Renderer/shims/ReactNativeTypes.js +39 -91
  94. package/Libraries/StyleSheet/PlatformColorValueTypes.js.flow +22 -0
  95. package/Libraries/Text/Text.d.ts +1 -1
  96. package/Libraries/Text/Text.js +3 -1
  97. package/Libraries/Text/Text.win32.js +3 -1
  98. package/Libraries/Text/TextNativeComponent.js +1 -1
  99. package/Libraries/Text/TextNativeComponent.win32.js +1 -1
  100. package/Libraries/Text/TextProps.js +124 -84
  101. package/Libraries/Text/TextProps.win32.js +124 -84
  102. package/Libraries/Types/CoreEventTypes.js +1 -1
  103. package/Libraries/Types/CoreEventTypes.win32.js +1 -1
  104. package/Libraries/Types/ReactDevToolsTypes.js +4 -8
  105. package/Libraries/Utilities/BackHandler.js.flow +25 -0
  106. package/Libraries/Utilities/DevSettings.js +14 -0
  107. package/Libraries/Utilities/Dimensions.js +5 -0
  108. package/Libraries/Utilities/Dimensions.win32.js +5 -0
  109. package/{flow/Position.js → Libraries/Utilities/Platform.js.flow} +3 -6
  110. package/Libraries/Utilities/PlatformTypes.js +97 -7
  111. package/Libraries/Utilities/codegenNativeComponent.js +1 -1
  112. package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +2 -4
  113. package/index.win32.js +3 -4
  114. package/overrides.json +24 -24
  115. package/package.json +15 -16
  116. package/src/private/components/HScrollViewNativeComponents.js +1 -1
  117. package/src/private/components/VScrollViewNativeComponents.js +1 -1
  118. package/src/private/featureflags/ReactNativeFeatureFlags.js +11 -6
  119. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +3 -2
  120. package/src/private/inspector/getInspectorDataForViewAtPoint.js +2 -4
  121. package/src/private/setup/setUpDOM.js +36 -1
  122. package/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js +1 -1
  123. package/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js +1 -1
  124. package/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js +1 -1
  125. package/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js +1 -1
  126. package/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js +1 -1
  127. package/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js +1 -1
  128. package/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js +1 -1
  129. package/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js +1 -1
  130. package/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js +1 -1
  131. package/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js +1 -1
  132. package/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js +1 -1
  133. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +1 -1
  134. package/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js +1 -1
  135. package/src/private/types/HostComponent.js +16 -0
  136. package/src/private/types/HostInstance.js +50 -0
  137. package/src/private/webapis/dom/nodes/ReactNativeDocument.js +1 -0
  138. package/src/private/webapis/dom/nodes/ReactNativeElement.js +40 -32
  139. package/src/private/webapis/dom/nodes/ReadOnlyCharacterData.js +1 -1
  140. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +1 -1
  141. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +1 -1
  142. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +4 -4
  143. package/src/private/webapis/mutationobserver/MutationObserver.js +9 -9
  144. package/src/private/webapis/performance/PerformanceObserver.js +6 -6
  145. package/src/types/globals.d.ts +628 -0
  146. package/src-win/Libraries/Text/Text.d.ts +1 -1
  147. package/types/index.d.ts +2 -53
  148. package/types/modules/globals.d.ts +0 -599
@@ -23,16 +23,37 @@ import SwitchNativeComponent, {
23
23
  } from './SwitchNativeComponent';
24
24
  import * as React from 'react';
25
25
 
26
- type SwitchChangeEvent = NativeSyntheticEvent<
27
- $ReadOnly<{
28
- value: boolean,
29
- target: number,
30
- }>,
31
- >;
26
+ export type SwitchPropsIOS = {
27
+ /**
28
+ * Background color when the switch is turned on.
29
+ *
30
+ * @deprecated use trackColor instead
31
+ */
32
+ onTintColor?: ?ColorValue,
32
33
 
33
- export type Props = $ReadOnly<{
34
- ...ViewProps,
34
+ /**
35
+ * Color of the foreground switch grip.
36
+ *
37
+ * @deprecated use thumbColor instead
38
+ */
39
+ thumbTintColor?: ?ColorValue,
35
40
 
41
+ /**
42
+ * Background color when the switch is turned off.
43
+ *
44
+ * @deprecated use trackColor instead
45
+ */
46
+ tintColor?: ?ColorValue,
47
+ };
48
+
49
+ export type SwitchChangeEventData = $ReadOnly<{
50
+ target: number,
51
+ value: boolean,
52
+ }>;
53
+
54
+ export type SwitchChangeEvent = NativeSyntheticEvent<SwitchChangeEventData>;
55
+
56
+ type SwitchPropsBase = {
36
57
  /**
37
58
  If true the user won't be able to toggle the switch.
38
59
 
@@ -41,53 +62,64 @@ export type Props = $ReadOnly<{
41
62
  disabled?: ?boolean,
42
63
 
43
64
  /**
44
- The value of the switch. If true the switch will be turned on.
65
+ The value of the switch. If true the switch will be turned on.
45
66
 
46
- @default false
47
- */
67
+ @default false
68
+ */
48
69
  value?: ?boolean,
49
70
 
50
71
  /**
51
- Color of the foreground switch grip. If this is set on iOS, the switch grip will lose its drop shadow.
52
- */
72
+ Color of the foreground switch grip. If this is set on iOS, the switch grip will lose its drop shadow.
73
+ */
53
74
  thumbColor?: ?ColorValue,
54
75
 
55
76
  /**
56
- Custom colors for the switch track.
77
+ Custom colors for the switch track.
57
78
 
58
- _iOS_: When the switch value is false, the track shrinks into the border. If you want to change the
59
- color of the background exposed by the shrunken track, use
60
- [`ios_backgroundColor`](https://reactnative.dev/docs/switch#ios_backgroundColor).
61
- */
79
+ _iOS_: When the switch value is false, the track shrinks into the border. If you want to change the
80
+ color of the background exposed by the shrunken track, use
81
+ [`ios_backgroundColor`](https://reactnative.dev/docs/switch#ios_backgroundColor).
82
+ */
62
83
  trackColor?: ?$ReadOnly<{
63
84
  false?: ?ColorValue,
64
85
  true?: ?ColorValue,
65
86
  }>,
66
87
 
67
88
  /**
68
- On iOS, custom color for the background. This background color can be
69
- seen either when the switch value is false or when the switch is
70
- disabled (and the switch is translucent).
71
- */
89
+ On iOS, custom color for the background. This background color can be
90
+ seen either when the switch value is false or when the switch is
91
+ disabled (and the switch is translucent).
92
+ */
72
93
  ios_backgroundColor?: ?ColorValue,
73
94
 
74
95
  /**
75
- Invoked when the user tries to change the value of the switch. Receives
76
- the change event as an argument. If you want to only receive the new
77
- value, use `onValueChange` instead.
78
- */
96
+ Invoked when the user tries to change the value of the switch. Receives
97
+ the change event as an argument. If you want to only receive the new
98
+ value, use `onValueChange` instead.
99
+ */
79
100
  onChange?: ?(event: SwitchChangeEvent) => Promise<void> | void,
80
101
 
81
102
  /**
82
- Invoked when the user tries to change the value of the switch. Receives
83
- the new value as an argument. If you want to instead receive an event,
84
- use `onChange`.
85
- */
103
+ Invoked when the user tries to change the value of the switch. Receives
104
+ the new value as an argument. If you want to instead receive an event,
105
+ use `onChange`.
106
+ */
86
107
  onValueChange?: ?(value: boolean) => Promise<void> | void,
108
+ };
109
+
110
+ export type SwitchProps = $ReadOnly<{
111
+ ...ViewProps,
112
+ ...SwitchPropsIOS,
113
+ ...SwitchPropsBase,
87
114
  }>;
115
+
88
116
  const returnsFalse = () => false;
89
117
  const returnsTrue = () => true;
90
118
 
119
+ type SwitchRef = React.ElementRef<
120
+ typeof SwitchNativeComponent | typeof AndroidSwitchNativeComponent,
121
+ >;
122
+
91
123
  /**
92
124
  Renders a boolean input.
93
125
 
@@ -129,14 +161,9 @@ const returnsTrue = () => true;
129
161
  export default App;
130
162
  ```
131
163
  */
132
-
133
- type SwitchRef = React.ElementRef<
134
- typeof SwitchNativeComponent | typeof AndroidSwitchNativeComponent,
135
- >;
136
-
137
- const SwitchWithForwardedRef: component(
138
- ref: React.RefSetter<SwitchRef>,
139
- ...props: Props
164
+ const Switch: component(
165
+ ref?: React.RefSetter<SwitchRef>,
166
+ ...props: SwitchProps
140
167
  ) = React.forwardRef(function Switch(props, forwardedRef): React.Node {
141
168
  const {
142
169
  disabled,
@@ -177,6 +204,7 @@ const SwitchWithForwardedRef: component(
177
204
  native.value != null && native.value !== jsValue;
178
205
  if (
179
206
  shouldUpdateNativeSwitch &&
207
+ // $FlowIssue[method-unbinding]
180
208
  nativeSwitchRef.current?.setNativeProps != null
181
209
  ) {
182
210
  if (Platform.OS === 'android') {
@@ -188,7 +216,8 @@ const SwitchWithForwardedRef: component(
188
216
  }, [value, native]);
189
217
 
190
218
  if (Platform.OS === 'android') {
191
- const {accessibilityState} = restProps;
219
+ const {onTintColor, tintColor, ...androidProps} = restProps;
220
+ const {accessibilityState} = androidProps;
192
221
  const _disabled =
193
222
  disabled != null ? disabled : accessibilityState?.disabled;
194
223
 
@@ -210,7 +239,7 @@ const SwitchWithForwardedRef: component(
210
239
 
211
240
  return (
212
241
  <AndroidSwitchNativeComponent
213
- {...restProps}
242
+ {...androidProps}
214
243
  {...platformProps}
215
244
  accessibilityRole={props.accessibilityRole ?? 'switch'}
216
245
  onChange={handleChange}
@@ -254,4 +283,4 @@ const SwitchWithForwardedRef: component(
254
283
  }
255
284
  });
256
285
 
257
- export default SwitchWithForwardedRef;
286
+ export default Switch;
@@ -8,10 +8,8 @@
8
8
  * @format
9
9
  */
10
10
 
11
- import type {
12
- HostComponent,
13
- PartialViewConfig,
14
- } from '../../Renderer/shims/ReactNativeTypes';
11
+ import type {HostComponent} from '../../../src/private/types/HostComponent';
12
+ import type {PartialViewConfig} from '../../Renderer/shims/ReactNativeTypes';
15
13
  import type {
16
14
  ColorValue,
17
15
  TextStyleProp,
@@ -8,10 +8,8 @@
8
8
  * @format
9
9
  */
10
10
 
11
- import type {
12
- HostComponent,
13
- PartialViewConfig,
14
- } from '../../Renderer/shims/ReactNativeTypes';
11
+ import type {HostComponent} from '../../../src/private/types/HostComponent';
12
+ import type {PartialViewConfig} from '../../Renderer/shims/ReactNativeTypes';
15
13
  import type {TextInputNativeCommands} from './TextInputNativeCommands';
16
14
 
17
15
  import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry';
@@ -8,10 +8,8 @@
8
8
  * @format
9
9
  */
10
10
 
11
- import type {
12
- HostComponent,
13
- PartialViewConfig,
14
- } from '../../Renderer/shims/ReactNativeTypes';
11
+ import type {HostComponent} from '../../../src/private/types/HostComponent';
12
+ import type {PartialViewConfig} from '../../Renderer/shims/ReactNativeTypes';
15
13
  import type {TextInputNativeCommands} from './TextInputNativeCommands';
16
14
 
17
15
  import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry';
@@ -142,6 +142,7 @@ const RCTTextInputViewConfig = {
142
142
  placeholder: true,
143
143
  autoCorrect: true,
144
144
  multiline: true,
145
+ numberOfLines: true,
145
146
  textContentType: true,
146
147
  maxLength: true,
147
148
  autoCapitalize: true,
@@ -8,11 +8,11 @@
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 {
13
13
  GestureResponderEvent,
14
- ScrollEvent,
15
14
  NativeSyntheticEvent,
15
+ ScrollEvent,
16
16
  } from '../../Types/CoreEventTypes';
17
17
  import type {ViewProps} from '../View/ViewPropTypes';
18
18
 
@@ -23,8 +23,6 @@ import {
23
23
  } from '../../StyleSheet/StyleSheet';
24
24
  import * as React from 'react';
25
25
 
26
- type ReactRefSetter<T> = {current: null | T, ...} | ((ref: null | T) => mixed);
27
-
28
26
  export type TextInputChangeEventData = $ReadOnly<{
29
27
  eventCount: number,
30
28
  target: number,
@@ -649,7 +647,7 @@ export type TextInputProps = $ReadOnly<{
649
647
  */
650
648
  editable?: ?boolean,
651
649
 
652
- forwardedRef?: ?ReactRefSetter<HostInstance & ImperativeMethods>,
650
+ forwardedRef?: ?React.RefSetter<TextInputInstance>,
653
651
 
654
652
  /**
655
653
  * `enterKeyHint` defines what action label (or icon) to present for the enter key on virtual keyboards.
@@ -992,12 +990,12 @@ export type TextInputProps = $ReadOnly<{
992
990
  value?: ?Stringish,
993
991
  }>;
994
992
 
995
- type ImperativeMethods = $ReadOnly<{
996
- clear: () => void,
997
- isFocused: () => boolean,
998
- getNativeRef: () => ?HostInstance,
999
- setSelection: (start: number, end: number) => void,
1000
- }>;
993
+ export interface TextInputInstance extends HostInstance {
994
+ +clear: () => void;
995
+ +isFocused: () => boolean;
996
+ +getNativeRef: () => ?HostInstance;
997
+ +setSelection: (start: number, end: number) => void;
998
+ }
1001
999
 
1002
1000
  /**
1003
1001
  * A foundational component for inputting text into the app via a
@@ -1111,7 +1109,7 @@ type ImperativeMethods = $ReadOnly<{
1111
1109
  *
1112
1110
  */
1113
1111
  type InternalTextInput = component(
1114
- ref: React.RefSetter<$ReadOnly<{...HostInstance, ...ImperativeMethods}>>,
1112
+ ref: React.RefSetter<TextInputInstance>,
1115
1113
  ...TextInputProps
1116
1114
  );
1117
1115
 
@@ -8,15 +8,15 @@
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
21
  import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
22
22
  import usePressability from '../../Pressability/usePressability';
@@ -36,14 +36,6 @@ import nullthrows from 'nullthrows';
36
36
  import * as React from 'react';
37
37
  import {useCallback, useLayoutEffect, useRef, useState} from 'react';
38
38
 
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
39
  let AndroidTextInput;
48
40
  let AndroidTextInputCommands;
49
41
  let RCTSinglelineTextInputView;
@@ -685,7 +677,7 @@ export type TextInputProps = $ReadOnly<{
685
677
  */
686
678
  editable?: ?boolean,
687
679
 
688
- forwardedRef?: ?ReactRefSetter<TextInputInstance>,
680
+ forwardedRef?: ?React.RefSetter<TextInputInstance>,
689
681
 
690
682
  /**
691
683
  * `enterKeyHint` defines what action label (or icon) to present for the enter key on virtual keyboards.
@@ -1027,8 +1019,8 @@ function useTextInputStateSynchronization_STATE({
1027
1019
  props: TextInputProps,
1028
1020
  mostRecentEventCount: number,
1029
1021
  selection: ?Selection,
1030
- inputRef: React.RefObject<null | HostInstance>,
1031
- text: string,
1022
+ inputRef: React.RefObject<null | TextInputInstance>,
1023
+ text?: string,
1032
1024
  viewCommands: ViewCommands,
1033
1025
  }): {
1034
1026
  setLastNativeText: string => void,
@@ -1108,8 +1100,8 @@ function useTextInputStateSynchronization_REFS({
1108
1100
  props: TextInputProps,
1109
1101
  mostRecentEventCount: number,
1110
1102
  selection: ?Selection,
1111
- inputRef: React.RefObject<null | HostInstance>,
1112
- text: string,
1103
+ inputRef: React.RefObject<null | TextInputInstance>,
1104
+ text?: string,
1113
1105
  viewCommands: ViewCommands,
1114
1106
  }): {
1115
1107
  setLastNativeText: string => void,
@@ -1308,7 +1300,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
1308
1300
  ...otherProps
1309
1301
  } = props;
1310
1302
 
1311
- const inputRef = useRef<null | HostInstance>(null);
1303
+ const inputRef = useRef<null | TextInputInstance>(null);
1312
1304
 
1313
1305
  const selection: ?Selection =
1314
1306
  propsSelection == null
@@ -1323,7 +1315,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
1323
1315
  ? props.value
1324
1316
  : typeof props.defaultValue === 'string'
1325
1317
  ? props.defaultValue
1326
- : '';
1318
+ : undefined;
1327
1319
 
1328
1320
  const viewCommands =
1329
1321
  AndroidTextInputCommands ||
@@ -1363,7 +1355,8 @@ function InternalTextInput(props: TextInputProps): React.Node {
1363
1355
  }, []);
1364
1356
 
1365
1357
  const setLocalRef = useCallback(
1366
- (instance: TextInputInstance | null) => {
1358
+ (instance: HostInstance | null) => {
1359
+ // $FlowExpectedError[incompatible-type]
1367
1360
  inputRef.current = instance;
1368
1361
 
1369
1362
  /*
@@ -1389,7 +1382,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
1389
1382
  before we can get to the long term breaking change.
1390
1383
  */
1391
1384
  if (instance != null) {
1392
- // $FlowFixMe[incompatible-use] - See the explanation above.
1385
+ // $FlowFixMe[prop-missing] - See the explanation above.
1393
1386
  Object.assign(instance, {
1394
1387
  clear(): void {
1395
1388
  if (inputRef.current != null) {
@@ -1406,7 +1399,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
1406
1399
  isFocused(): boolean {
1407
1400
  return TextInputState.currentlyFocusedInput() === inputRef.current;
1408
1401
  },
1409
- getNativeRef(): ?HostInstance {
1402
+ getNativeRef(): ?TextInputInstance {
1410
1403
  return inputRef.current;
1411
1404
  },
1412
1405
  setSelection(start: number, end: number): void {
@@ -1426,7 +1419,8 @@ function InternalTextInput(props: TextInputProps): React.Node {
1426
1419
  [mostRecentEventCount, viewCommands],
1427
1420
  );
1428
1421
 
1429
- const ref = useMergeRefs<TextInputInstance>(setLocalRef, props.forwardedRef);
1422
+ // $FlowExpectedError[incompatible-call]
1423
+ const ref = useMergeRefs<HostInstance>(setLocalRef, props.forwardedRef);
1430
1424
 
1431
1425
  const _onChange = (event: TextInputChangeEvent) => {
1432
1426
  const currentText = event.nativeEvent.text;
@@ -1614,8 +1608,8 @@ function InternalTextInput(props: TextInputProps): React.Node {
1614
1608
 
1615
1609
  textInput = (
1616
1610
  <RCTTextInputView
1617
- // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1618
- ref={ref}
1611
+ // Figure out imperative + forward refs.
1612
+ ref={(ref: $FlowFixMe)}
1619
1613
  {...otherProps}
1620
1614
  {...eventHandlers}
1621
1615
  accessibilityState={_accessibilityState}
@@ -1626,6 +1620,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
1626
1620
  focusable={tabIndex !== undefined ? !tabIndex : focusable}
1627
1621
  mostRecentEventCount={mostRecentEventCount}
1628
1622
  nativeID={id ?? props.nativeID}
1623
+ numberOfLines={props.rows ?? props.numberOfLines}
1629
1624
  onBlur={_onBlur}
1630
1625
  onChange={_onChange}
1631
1626
  onContentSizeChange={props.onContentSizeChange}
@@ -1675,8 +1670,8 @@ function InternalTextInput(props: TextInputProps): React.Node {
1675
1670
  * match up exactly with the props for TextInput. This will need to get
1676
1671
  * fixed */
1677
1672
  <AndroidTextInput
1678
- // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1679
- ref={ref}
1673
+ // Figure out imperative + forward refs.
1674
+ ref={(ref: $FlowFixMe)}
1680
1675
  {...otherProps}
1681
1676
  {...colorProps}
1682
1677
  {...eventHandlers}
@@ -1813,7 +1808,6 @@ const autoCompleteWebToTextContentTypeMap = {
1813
1808
  const ExportedForwardRef: component(
1814
1809
  ref: React.RefSetter<TextInputInstance>,
1815
1810
  ...props: React.ElementConfig<typeof InternalTextInput>
1816
- // $FlowFixMe[incompatible-call]
1817
1811
  ) = React.forwardRef(function TextInput(
1818
1812
  {
1819
1813
  allowFontScaling = true,
@@ -1830,7 +1824,7 @@ const ExportedForwardRef: component(
1830
1824
  keyboardType,
1831
1825
  ...restProps
1832
1826
  },
1833
- forwardedRef: ReactRefSetter<TextInputInstance>,
1827
+ forwardedRef: React.RefSetter<TextInputInstance>,
1834
1828
  ) {
1835
1829
  return (
1836
1830
  <InternalTextInput
@@ -8,15 +8,15 @@
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
21
  import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
22
22
  import usePressability from '../../Pressability/usePressability';
@@ -36,14 +36,6 @@ import nullthrows from 'nullthrows';
36
36
  import * as React from 'react';
37
37
  import {useCallback, useLayoutEffect, useRef, useState} from 'react';
38
38
 
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
39
  let AndroidTextInput;
48
40
  let AndroidTextInputCommands;
49
41
  let RCTSinglelineTextInputView;
@@ -728,7 +720,7 @@ export type TextInputProps = $ReadOnly<{
728
720
  */
729
721
  editable?: ?boolean,
730
722
 
731
- forwardedRef?: ?ReactRefSetter<TextInputInstance>,
723
+ forwardedRef?: ?React.RefSetter<TextInputInstance>,
732
724
 
733
725
  /**
734
726
  * `enterKeyHint` defines what action label (or icon) to present for the enter key on virtual keyboards.
@@ -1070,8 +1062,8 @@ function useTextInputStateSynchronization_STATE({
1070
1062
  props: TextInputProps,
1071
1063
  mostRecentEventCount: number,
1072
1064
  selection: ?Selection,
1073
- inputRef: React.RefObject<null | HostInstance>,
1074
- text: string,
1065
+ inputRef: React.RefObject<null | TextInputInstance>,
1066
+ text?: string,
1075
1067
  viewCommands: ViewCommands,
1076
1068
  }): {
1077
1069
  setLastNativeText: string => void,
@@ -1151,8 +1143,8 @@ function useTextInputStateSynchronization_REFS({
1151
1143
  props: TextInputProps,
1152
1144
  mostRecentEventCount: number,
1153
1145
  selection: ?Selection,
1154
- inputRef: React.RefObject<null | HostInstance>,
1155
- text: string,
1146
+ inputRef: React.RefObject<null | TextInputInstance>,
1147
+ text?: string,
1156
1148
  viewCommands: ViewCommands,
1157
1149
  }): {
1158
1150
  setLastNativeText: string => void,
@@ -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]
@@ -1410,7 +1402,8 @@ function InternalTextInput(props: TextInputProps): React.Node {
1410
1402
  }, []);
1411
1403
 
1412
1404
  const setLocalRef = useCallback(
1413
- (instance: TextInputInstance | null) => {
1405
+ (instance: HostInstance | null) => {
1406
+ // $FlowExpectedError[incompatible-type]
1414
1407
  inputRef.current = instance;
1415
1408
 
1416
1409
  /*
@@ -1436,7 +1429,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
1436
1429
  before we can get to the long term breaking change.
1437
1430
  */
1438
1431
  if (instance != null) {
1439
- // $FlowFixMe[incompatible-use] - See the explanation above.
1432
+ // $FlowFixMe[prop-missing] - See the explanation above.
1440
1433
  Object.assign(instance, {
1441
1434
  clear(): void {
1442
1435
  if (inputRef.current != null) {
@@ -1457,7 +1450,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
1457
1450
  currentlyFocusedInput === inputRef.current
1458
1451
  );
1459
1452
  },
1460
- getNativeRef(): ?HostInstance {
1453
+ getNativeRef(): ?TextInputInstance {
1461
1454
  return inputRef.current;
1462
1455
  },
1463
1456
  setSelection(start: number, end: number): void {
@@ -1477,7 +1470,8 @@ function InternalTextInput(props: TextInputProps): React.Node {
1477
1470
  [mostRecentEventCount, viewCommands],
1478
1471
  );
1479
1472
 
1480
- const ref = useMergeRefs<TextInputInstance>(setLocalRef, props.forwardedRef);
1473
+ // $FlowExpectedError[incompatible-call]
1474
+ const ref = useMergeRefs<HostInstance>(setLocalRef, props.forwardedRef);
1481
1475
 
1482
1476
  const _onChange = (event: TextInputChangeEvent) => {
1483
1477
  const currentText = event.nativeEvent.text;
@@ -1727,8 +1721,8 @@ function InternalTextInput(props: TextInputProps): React.Node {
1727
1721
 
1728
1722
  textInput = (
1729
1723
  <RCTTextInputView
1730
- // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1731
- ref={ref}
1724
+ // Figure out imperative + forward refs.
1725
+ ref={(ref: $FlowFixMe)}
1732
1726
  {...otherProps}
1733
1727
  {...eventHandlers}
1734
1728
  accessibilityErrorMessage={accessibilityErrorMessage}
@@ -1740,6 +1734,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
1740
1734
  focusable={tabIndex !== undefined ? !tabIndex : focusable}
1741
1735
  mostRecentEventCount={mostRecentEventCount}
1742
1736
  nativeID={id ?? props.nativeID}
1737
+ numberOfLines={props.rows ?? props.numberOfLines}
1743
1738
  onBlur={_onBlur}
1744
1739
  onChange={_onChange}
1745
1740
  onContentSizeChange={props.onContentSizeChange}
@@ -1789,8 +1784,8 @@ function InternalTextInput(props: TextInputProps): React.Node {
1789
1784
  * match up exactly with the props for TextInput. This will need to get
1790
1785
  * fixed */
1791
1786
  <AndroidTextInput
1792
- // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1793
- ref={ref}
1787
+ // Figure out imperative + forward refs.
1788
+ ref={(ref: $FlowFixMe)}
1794
1789
  {...otherProps}
1795
1790
  {...colorProps}
1796
1791
  {...eventHandlers}
@@ -1954,7 +1949,6 @@ const autoCompleteWebToTextContentTypeMap = {
1954
1949
  const ExportedForwardRef: component(
1955
1950
  ref: React.RefSetter<TextInputInstance>,
1956
1951
  ...props: React.ElementConfig<typeof InternalTextInput>
1957
- // $FlowFixMe[incompatible-call]
1958
1952
  ) = React.forwardRef(function TextInput(
1959
1953
  {
1960
1954
  allowFontScaling = true,
@@ -1971,7 +1965,7 @@ const ExportedForwardRef: component(
1971
1965
  keyboardType,
1972
1966
  ...restProps
1973
1967
  },
1974
- forwardedRef: ReactRefSetter<TextInputInstance>,
1968
+ forwardedRef: React.RefSetter<TextInputInstance>,
1975
1969
  ) {
1976
1970
  return (
1977
1971
  <InternalTextInput
@@ -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;