@office-iss/react-native-win32 0.72.8 → 0.73.0-preview.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/.flowconfig +15 -5
  2. package/CHANGELOG.json +530 -101
  3. package/CHANGELOG.md +213 -56
  4. package/IntegrationTests/PromiseTest.js +1 -0
  5. package/IntegrationTests/websocket_integration_test_server.js +1 -1
  6. package/Libraries/Animated/Animated.js +1 -1
  7. package/Libraries/Animated/AnimatedImplementation.js +1 -1
  8. package/Libraries/Animated/NativeAnimatedHelper.js +14 -10
  9. package/Libraries/Animated/NativeAnimatedHelper.win32.js +16 -12
  10. package/Libraries/Animated/NativeAnimatedModule.js +6 -2
  11. package/Libraries/Animated/NativeAnimatedTurboModule.js +7 -4
  12. package/Libraries/Animated/animations/Animation.js +57 -3
  13. package/Libraries/Animated/animations/DecayAnimation.js +9 -0
  14. package/Libraries/Animated/animations/SpringAnimation.js +8 -0
  15. package/Libraries/Animated/animations/TimingAnimation.js +8 -0
  16. package/Libraries/Animated/components/AnimatedFlatList.js +2 -1
  17. package/Libraries/Animated/components/AnimatedScrollView.js +2 -0
  18. package/Libraries/Animated/components/AnimatedSectionList.js +2 -1
  19. package/Libraries/Animated/createAnimatedComponent.js +1 -0
  20. package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
  21. package/Libraries/Animated/nodes/AnimatedObject.js +146 -0
  22. package/Libraries/Animated/nodes/AnimatedProps.js +19 -7
  23. package/Libraries/Animated/nodes/AnimatedStyle.js +29 -55
  24. package/Libraries/Animated/nodes/AnimatedValueXY.js +3 -17
  25. package/Libraries/Animated/shouldUseTurboAnimatedModule.js +17 -0
  26. package/Libraries/Animated/useAnimatedProps.js +9 -10
  27. package/Libraries/AppState/AppState.d.ts +1 -1
  28. package/Libraries/AppState/NativeAppState.js +8 -4
  29. package/Libraries/BatchedBridge/MessageQueue.js +45 -36
  30. package/Libraries/Blob/Blob.js +6 -2
  31. package/Libraries/Blob/BlobManager.js +9 -10
  32. package/Libraries/Blob/BlobRegistry.js +14 -9
  33. package/Libraries/Blob/File.js +1 -1
  34. package/Libraries/Blob/FileReader.js +1 -2
  35. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +1 -5
  36. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +7 -48
  37. package/Libraries/Components/Button/ButtonWin32.Props.d.ts +1 -1
  38. package/Libraries/Components/Button/ButtonWin32.Props.js.map +1 -1
  39. package/Libraries/Components/Button/ButtonWin32.d.ts +1 -1
  40. package/Libraries/Components/Button/ButtonWin32.js +1 -4
  41. package/Libraries/Components/Button/ButtonWin32.js.map +1 -1
  42. package/Libraries/Components/Clipboard/Clipboard.d.ts +4 -4
  43. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +3 -1
  44. package/Libraries/Components/EnterString.win32.d.ts +1 -1
  45. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +26 -6
  46. package/Libraries/Components/Pressable/Pressable.js +3 -2
  47. package/Libraries/Components/Pressable/Pressable.win32.js +4 -3
  48. package/Libraries/Components/Pressable/useAndroidRippleForView.js +1 -1
  49. package/Libraries/Components/SafeAreaView/SafeAreaView.js +7 -7
  50. package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +7 -8
  51. package/Libraries/Components/ScrollView/ScrollView.js +3 -1
  52. package/Libraries/Components/ScrollView/ScrollView.win32.js +3 -1
  53. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +39 -46
  54. package/Libraries/Components/Switch/Switch.js +1 -0
  55. package/Libraries/Components/Text/TextWin32.d.ts +1 -1
  56. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  57. package/Libraries/Components/TextInput/TextInput.d.ts +49 -7
  58. package/Libraries/Components/TextInput/TextInput.flow.js +43 -10
  59. package/Libraries/Components/TextInput/TextInput.js +62 -10
  60. package/Libraries/Components/TextInput/TextInput.win32.js +953 -206
  61. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +23 -0
  62. package/Libraries/Components/ToastAndroid/{ToastAndroid.ios.js → ToastAndroid.js} +9 -1
  63. package/Libraries/Components/ToastAndroid/ToastAndroid.win32.js +9 -1
  64. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js +2 -2
  65. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  66. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  67. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  68. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
  69. package/Libraries/Components/Touchable/TouchableOpacity.js +4 -1
  70. package/Libraries/Components/Touchable/TouchableWin32.d.ts +1 -1
  71. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  72. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -0
  73. package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js +16 -6
  74. package/Libraries/Components/View/ReactNativeStyleAttributes.js +9 -0
  75. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  76. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -0
  77. package/Libraries/Components/View/View.js +46 -32
  78. package/Libraries/Components/View/View.win32.js +37 -6
  79. package/Libraries/Components/View/ViewAccessibility.d.ts +8 -2
  80. package/Libraries/Components/View/ViewNativeComponent.js +1 -0
  81. package/Libraries/Components/View/ViewPropTypes.js +18 -3
  82. package/Libraries/Components/View/ViewPropTypes.win32.js +30 -4
  83. package/Libraries/Components/View/ViewWin32.js +3 -2
  84. package/Libraries/Core/Devtools/loadBundleFromServer.js +152 -0
  85. package/Libraries/Core/Devtools/symbolicateStackTrace.js +2 -1
  86. package/Libraries/Core/ExceptionsManager.js +16 -7
  87. package/Libraries/Core/ExtendedError.js +12 -0
  88. package/Libraries/Core/ReactNativeVersion.js +3 -3
  89. package/Libraries/Core/ReactNativeVersionCheck.js +0 -2
  90. package/Libraries/Core/ReactNativeVersionCheck.win32.js +0 -2
  91. package/Libraries/Core/__mocks__/NativeExceptionsManager.js +20 -0
  92. package/Libraries/Core/setUpDeveloperTools.js +5 -1
  93. package/Libraries/Core/setUpIntersectionObserver.js +16 -0
  94. package/Libraries/{Components/ProgressBarAndroid/ProgressBarAndroid.ios.js → Core/setUpMutationObserver.js} +6 -2
  95. package/Libraries/Core/setUpPerformance.js +6 -13
  96. package/Libraries/Core/setUpPerformanceObserver.js +16 -0
  97. package/Libraries/Core/setUpRegeneratorRuntime.js +4 -2
  98. package/Libraries/DOM/Nodes/ReactNativeElement.js +135 -18
  99. package/Libraries/DOM/Nodes/ReadOnlyCharacterData.js +72 -0
  100. package/Libraries/DOM/Nodes/ReadOnlyElement.js +209 -21
  101. package/Libraries/DOM/Nodes/ReadOnlyNode.js +206 -17
  102. package/Libraries/DOM/Nodes/ReadOnlyText.js +30 -0
  103. package/Libraries/DOM/Nodes/Utilities/Traversal.js +54 -0
  104. package/Libraries/EventEmitter/NativeEventEmitter.d.ts +0 -6
  105. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +15 -4
  106. package/Libraries/Image/Image.android.js +8 -2
  107. package/Libraries/Image/Image.d.ts +1 -1
  108. package/Libraries/Image/Image.ios.js +4 -1
  109. package/Libraries/Image/Image.win32.js +6 -3
  110. package/Libraries/Image/ImageBackground.js +3 -0
  111. package/Libraries/Image/resolveAssetSource.win32.js +1 -1
  112. package/Libraries/Inspector/DevtoolsOverlay.js +6 -3
  113. package/Libraries/Inspector/NetworkOverlay.js +2 -2
  114. package/Libraries/Interaction/JSEventLoopWatchdog.js +1 -5
  115. package/Libraries/Interaction/PanResponder.js +1 -4
  116. package/Libraries/IntersectionObserver/IntersectionObserver.js +252 -0
  117. package/Libraries/IntersectionObserver/IntersectionObserverEntry.js +140 -0
  118. package/Libraries/IntersectionObserver/IntersectionObserverManager.js +221 -0
  119. package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +41 -0
  120. package/Libraries/IntersectionObserver/__mocks__/NativeIntersectionObserver.js +162 -0
  121. package/Libraries/LayoutAnimation/LayoutAnimation.js +1 -1
  122. package/Libraries/Lists/FlatList.d.ts +2 -1
  123. package/Libraries/Lists/FlatList.js +15 -5
  124. package/Libraries/Lists/SectionList.js +4 -0
  125. package/Libraries/LogBox/Data/LogBoxData.js +2 -1
  126. package/Libraries/LogBox/Data/LogBoxLog.js +4 -1
  127. package/Libraries/LogBox/Data/LogBoxSymbolication.js +5 -2
  128. package/Libraries/LogBox/Data/parseLogBoxLog.js +57 -20
  129. package/Libraries/LogBox/UI/AnsiHighlight.js +1 -1
  130. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +24 -31
  131. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +1 -1
  132. package/Libraries/LogBox/UI/LogBoxMessage.js +4 -7
  133. package/Libraries/MutationObserver/MutationObserver.js +184 -0
  134. package/Libraries/MutationObserver/MutationObserverManager.js +218 -0
  135. package/Libraries/MutationObserver/MutationRecord.js +82 -0
  136. package/Libraries/MutationObserver/NativeMutationObserver.js +58 -0
  137. package/Libraries/MutationObserver/__mocks__/NativeMutationObserver.js +327 -0
  138. package/Libraries/NativeComponent/BaseViewConfig.android.js +18 -3
  139. package/Libraries/NativeComponent/BaseViewConfig.ios.js +33 -0
  140. package/Libraries/NativeComponent/BaseViewConfig.win32.js +33 -0
  141. package/Libraries/NativeComponent/NativeComponentRegistry.js +13 -9
  142. package/Libraries/NativeModules/specs/NativeSourceCode.js +6 -6
  143. package/Libraries/Network/RCTNetworking.android.js +2 -1
  144. package/Libraries/Network/XMLHttpRequest.js +1 -1
  145. package/Libraries/NewAppScreen/components/DebugInstructions.js +4 -4
  146. package/Libraries/NewAppScreen/components/LearnMoreLinks.js +9 -2
  147. package/Libraries/Performance/QuickPerformanceLogger.js +1 -1
  148. package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +1 -0
  149. package/Libraries/PermissionsAndroid/PermissionsAndroid.d.ts +1 -0
  150. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -1
  151. package/Libraries/Pressability/Pressability.js +28 -3
  152. package/Libraries/Pressability/Pressability.win32.js +30 -5
  153. package/Libraries/ReactNative/AppContainer.js +2 -3
  154. package/Libraries/ReactNative/AppRegistry.d.ts +0 -5
  155. package/Libraries/ReactNative/AppRegistry.js +66 -53
  156. package/Libraries/ReactNative/BridgelessUIManager.js +38 -9
  157. package/Libraries/ReactNative/FabricUIManager.js +143 -34
  158. package/Libraries/ReactNative/I18nManager.js +5 -11
  159. package/Libraries/ReactNative/NativeI18nManager.js +7 -5
  160. package/Libraries/ReactNative/PaperUIManager.win32.js +2 -2
  161. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +151 -0
  162. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +81 -0
  163. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js +492 -0
  164. package/Libraries/ReactNative/ReactFabricPublicInstance/warnForStyleProps.js +32 -0
  165. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +19 -3
  166. package/Libraries/ReactNative/UIManager.js +8 -0
  167. package/Libraries/ReactNative/__mocks__/FabricUIManager.js +648 -0
  168. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +38 -2
  169. package/Libraries/Renderer/implementations/ReactFabric-dev.js +27 -27
  170. package/Libraries/Renderer/implementations/ReactFabric-prod.js +3 -3
  171. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3 -3
  172. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +27 -27
  173. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3 -3
  174. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3 -3
  175. package/Libraries/Renderer/shims/ReactFabric.js +5 -6
  176. package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -3
  177. package/Libraries/Renderer/shims/ReactNative.js +2 -3
  178. package/Libraries/Renderer/shims/ReactNativeTypes.js +35 -17
  179. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -3
  180. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -3
  181. package/Libraries/Settings/{Settings.android.js → Settings.js} +4 -4
  182. package/Libraries/Share/Share.d.ts +3 -9
  183. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +9 -4
  184. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +28 -13
  185. package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +14 -4
  186. package/Libraries/StyleSheet/PlatformColorValueTypesIOS.ios.js +1 -1
  187. package/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
  188. package/Libraries/StyleSheet/StyleSheet.d.ts +10 -1
  189. package/Libraries/StyleSheet/StyleSheet.js +3 -0
  190. package/Libraries/StyleSheet/StyleSheet.win32.js +3 -0
  191. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +31 -17
  192. package/Libraries/StyleSheet/StyleSheetTypes.js +90 -6
  193. package/Libraries/StyleSheet/flattenStyle.js +4 -0
  194. package/Libraries/StyleSheet/private/_TransformStyle.js +16 -2
  195. package/Libraries/StyleSheet/processColor.js +1 -2
  196. package/Libraries/StyleSheet/processTransformOrigin.js +136 -0
  197. package/Libraries/StyleSheet/splitLayoutProps.js +1 -0
  198. package/Libraries/Text/Text.d.ts +5 -5
  199. package/Libraries/Text/Text.js +17 -10
  200. package/Libraries/Text/Text.win32.js +354 -0
  201. package/Libraries/Text/TextProps.win32.js +281 -0
  202. package/Libraries/TurboModule/TurboModuleRegistry.js +47 -7
  203. package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +6 -0
  204. package/Libraries/Types/CoreEventTypes.d.ts +5 -2
  205. package/Libraries/Utilities/GlobalPerformanceLogger.js +2 -12
  206. package/Libraries/Utilities/NativeDeviceInfo.js +8 -9
  207. package/Libraries/Utilities/NativePlatformConstantsAndroid.js +23 -18
  208. package/Libraries/Utilities/NativePlatformConstantsIOS.js +16 -13
  209. package/Libraries/Utilities/NativePlatformConstantsWin.js +13 -10
  210. package/Libraries/Utilities/PerformanceLoggerContext.js +1 -1
  211. package/Libraries/Utilities/Platform.android.js +12 -8
  212. package/Libraries/Utilities/Platform.d.ts +1 -0
  213. package/Libraries/Utilities/Platform.flow.js +84 -0
  214. package/Libraries/Utilities/Platform.flow.win32.js +111 -0
  215. package/Libraries/Utilities/Platform.ios.js +12 -8
  216. package/Libraries/Utilities/Platform.win32.js +12 -8
  217. package/Libraries/Utilities/PolyfillFunctions.js +1 -1
  218. package/Libraries/Utilities/ReactNativeTestTools.js +1 -2
  219. package/Libraries/Utilities/SceneTracker.js +1 -1
  220. package/Libraries/Utilities/createPerformanceLogger.js +63 -32
  221. package/Libraries/Utilities/useColorScheme.js +7 -8
  222. package/Libraries/WebPerformance/MemoryInfo.js +1 -1
  223. package/Libraries/WebPerformance/NativePerformance.js +3 -8
  224. package/Libraries/WebPerformance/NativePerformanceObserver.js +4 -0
  225. package/Libraries/WebPerformance/Performance.js +42 -15
  226. package/Libraries/WebPerformance/PerformanceEntry.js +14 -6
  227. package/Libraries/WebPerformance/PerformanceEventTiming.js +18 -1
  228. package/Libraries/WebPerformance/ReactNativeStartupTiming.js +40 -14
  229. package/Libraries/WebPerformance/__mocks__/NativePerformance.js +4 -2
  230. package/Libraries/WebPerformance/__mocks__/NativePerformanceObserver.js +21 -3
  231. package/Libraries/promiseRejectionTrackingOptions.js +21 -9
  232. package/Libraries/vendor/emitter/EventEmitter.js +17 -17
  233. package/flow/global.js +1 -3
  234. package/flow/jest.js +5 -1
  235. package/{Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js → jest/ReactNativeInternalFeatureFlagsMock.js} +2 -1
  236. package/jest/__tests__/setup-test.js +18 -0
  237. package/jest/mockModal.js +6 -4
  238. package/jest/setup.js +61 -30
  239. package/jest.config.js +1 -1
  240. package/just-task.js +1 -0
  241. package/overrides.json +54 -60
  242. package/package.json +35 -33
  243. package/src/Libraries/Components/Button/ButtonWin32.Props.ts +1 -1
  244. package/src/Libraries/Components/Button/ButtonWin32.tsx +0 -2
  245. package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +2 -2
  246. package/src/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
  247. package/src/Libraries/Components/View/ViewAccessibility.d.ts +8 -2
  248. package/src/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
  249. package/types/experimental.d.ts +44 -0
  250. package/types/index.d.ts +2 -1
  251. package/types/modules/Devtools.d.ts +1 -0
  252. package/types/modules/globals.d.ts +16 -1
  253. package/IntegrationTests/BUCK +0 -32
  254. package/IntegrationTests/PropertiesUpdateTest.js +0 -29
  255. package/IntegrationTests/RCTRootViewIntegrationTestApp.js +0 -86
  256. package/IntegrationTests/ReactContentSizeUpdateTest.js +0 -89
  257. package/IntegrationTests/SizeFlexibilityUpdateTest.js +0 -106
  258. package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfoWin32.js +0 -37
  259. package/Libraries/Components/TextInput/TextInput.Types.win32.d.ts +0 -51
  260. package/Libraries/Components/TextInput/TextInput.Types.win32.js +0 -3
  261. package/Libraries/Components/TextInput/TextInput.Types.win32.js.map +0 -1
  262. package/Libraries/Utilities/AcessibilityMapping.js +0 -154
  263. package/Libraries/Utilities/AcessibilityMapping.win32.js +0 -156
  264. package/Libraries/Utilities/NativeDevSplitBundleLoader.js +0 -19
  265. package/Libraries/Utilities/useColorScheme.win32.js +0 -26
  266. package/flow/use-sync-external-store.js +0 -20
  267. package/flow-typed/npm/base64-js_v1.x.x.js +0 -12
  268. package/flow-typed/npm/glob_v7.x.x.js +0 -79
  269. package/flow-typed/npm/pretty-format_v26.x.x.js +0 -49
  270. package/flow-typed/npm/promise_v8.x.x.js +0 -30
  271. package/flow-typed/npm/react-dom_v17.x.x.js +0 -139
  272. package/flow-typed/npm/react-test-renderer_v16.x.x.js +0 -79
  273. package/flow-typed/npm/stacktrace-parser_v0.1.x.js +0 -17
  274. package/flow-typed/npm/yargs_v17.x.x.js +0 -341
  275. package/src/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +0 -161
  276. package/src/Libraries/Components/TextInput/TextInput.Types.win32.ts +0 -68
  277. /package/Libraries/{Renderer/public → ReactNative/ReactFabricPublicInstance}/ReactFabricPublicInstanceUtils.js +0 -0
@@ -1,44 +1,38 @@
1
1
  /**
2
- * This is a forked and slightly modified version of React Native's TextInput.
3
- * The fork is necessary as platform checks in the base implementation made the
4
- * control unusable on win32. In addition to cleaning up some of the code, this
5
- * fork also uses Typescript rather than Flow for type safety.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
3
  *
7
- * More general documentation on this control can be found at
8
- * https://facebook.github.io/react-native/docs/textinput.html
9
- *
10
- * The original implementation can be found at
11
- * https://github.com/facebook/react-native/blob/1013a010492a7bef5ff58073a088ac924a986e9e/Libraries/Components/TextInput/TextInput.js
12
- *
13
- * This control does not support the full React Native TextInput interface yet.
14
- * Most of the work necessary to make that happen needs to happen on the native side.
15
- * Future work on the JS side may include:
16
- * 1. Expanded typings for some of the events
17
- * 2. Additional work to manage selection
18
- * 3. Any base/default styling work
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
19
6
  *
20
7
  * @flow strict-local
21
8
  * @format
22
9
  */
23
10
 
24
11
  import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
25
- import {findNodeHandle} from '../../ReactNative/RendererProxy';
26
- import UIManager from '../../ReactNative/UIManager';
27
- import requireNativeComponent from '../../ReactNative/requireNativeComponent';
28
- import * as React from 'react';
29
- import TextAncestor from '../../Text/TextAncestor';
30
- import TextInputState from './TextInputState';
31
- import type {ViewProps} from '../View/ViewPropTypes';
32
12
  import type {
33
13
  PressEvent,
34
14
  ScrollEvent,
35
15
  SyntheticEvent,
36
16
  } from '../../Types/CoreEventTypes';
17
+ import type {ViewProps} from '../View/ViewPropTypes';
18
+ import type {TextInputType} from './TextInput.flow';
19
+
20
+ import usePressability from '../../Pressability/usePressability';
21
+ import flattenStyle from '../../StyleSheet/flattenStyle';
37
22
  import StyleSheet, {
38
23
  type ColorValue,
39
24
  type TextStyleProp,
40
25
  type ViewStyleProp,
41
26
  } from '../../StyleSheet/StyleSheet';
27
+ import Text from '../../Text/Text';
28
+ import TextAncestor from '../../Text/TextAncestor';
29
+ import Platform from '../../Utilities/Platform';
30
+ import useMergeRefs from '../../Utilities/useMergeRefs';
31
+ import TextInputState from './TextInputState';
32
+ import invariant from 'invariant';
33
+ import nullthrows from 'nullthrows';
34
+ import * as React from 'react';
35
+ import {useCallback, useLayoutEffect, useRef, useState} from 'react';
42
36
 
43
37
  type ReactRefSetter<T> = {current: null | T, ...} | ((ref: null | T) => mixed);
44
38
  type TextInputInstance = React.ElementRef<HostComponent<mixed>> & {
@@ -48,6 +42,39 @@ type TextInputInstance = React.ElementRef<HostComponent<mixed>> & {
48
42
  +setSelection: (start: number, end: number) => void,
49
43
  };
50
44
 
45
+ let AndroidTextInput;
46
+ let AndroidTextInputCommands;
47
+ let RCTSinglelineTextInputView;
48
+ let RCTSinglelineTextInputNativeCommands;
49
+ let RCTMultilineTextInputView;
50
+ let RCTMultilineTextInputNativeCommands;
51
+ let WindowsTextInput; // [Windows]
52
+ let WindowsTextInputCommands; // [Windows]
53
+ import type {KeyEvent} from '../../Types/CoreEventTypes'; // [Windows]
54
+
55
+ // [Windows
56
+ if (Platform.OS === 'android') {
57
+ AndroidTextInput = require('./AndroidTextInputNativeComponent').default;
58
+ AndroidTextInputCommands =
59
+ require('./AndroidTextInputNativeComponent').Commands;
60
+ } else if (Platform.OS === 'ios') {
61
+ RCTSinglelineTextInputView =
62
+ require('./RCTSingelineTextInputNativeComponent').default;
63
+ RCTSinglelineTextInputNativeCommands =
64
+ require('./RCTSingelineTextInputNativeComponent').Commands;
65
+ RCTMultilineTextInputView =
66
+ require('./RCTMultilineTextInputNativeComponent').default;
67
+ RCTMultilineTextInputNativeCommands =
68
+ require('./RCTMultilineTextInputNativeComponent').Commands;
69
+ }
70
+ // [Windows
71
+ else if (Platform.OS === 'win32') {
72
+ WindowsTextInput = require('./Win32TextInputNativeComponent').default;
73
+ WindowsTextInputCommands =
74
+ require('./Win32TextInputNativeComponent').Commands;
75
+ }
76
+ // Windows]
77
+
51
78
  export type ChangeEvent = SyntheticEvent<
52
79
  $ReadOnly<{|
53
80
  eventCount: number,
@@ -184,6 +211,15 @@ export type TextContentType =
184
211
  | 'addressState'
185
212
  | 'countryName'
186
213
  | 'creditCardNumber'
214
+ | 'creditCardExpiration'
215
+ | 'creditCardExpirationMonth'
216
+ | 'creditCardExpirationYear'
217
+ | 'creditCardSecurityCode'
218
+ | 'creditCardType'
219
+ | 'creditCardName'
220
+ | 'creditCardGivenName'
221
+ | 'creditCardMiddleName'
222
+ | 'creditCardFamilyName'
187
223
  | 'emailAddress'
188
224
  | 'familyName'
189
225
  | 'fullStreetAddress'
@@ -204,7 +240,11 @@ export type TextContentType =
204
240
  | 'username'
205
241
  | 'password'
206
242
  | 'newPassword'
207
- | 'oneTimeCode';
243
+ | 'oneTimeCode'
244
+ | 'birthdate'
245
+ | 'birthdateDay'
246
+ | 'birthdateMonth'
247
+ | 'birthdateYear';
208
248
 
209
249
  export type enterKeyHintType =
210
250
  // Cross Platform
@@ -320,6 +360,16 @@ type IOSProps = $ReadOnly<{|
320
360
  * @platform ios
321
361
  */
322
362
  lineBreakStrategyIOS?: ?('none' | 'standard' | 'hangul-word' | 'push-out'),
363
+
364
+ /**
365
+ * If `false`, the iOS system will not insert an extra space after a paste operation
366
+ * neither delete one or two spaces after a cut or delete operation.
367
+ *
368
+ * The default value is `true`.
369
+ *
370
+ * @platform ios
371
+ */
372
+ smartInsertDelete?: ?boolean,
323
373
  |}>;
324
374
 
325
375
  type AndroidProps = $ReadOnly<{|
@@ -408,10 +458,37 @@ type AndroidProps = $ReadOnly<{|
408
458
  underlineColorAndroid?: ?ColorValue,
409
459
  |}>;
410
460
 
461
+ // [Windows
462
+
463
+ type SubmitKeyEvent = $ReadOnly<{|
464
+ altKey?: ?boolean,
465
+ ctrlKey?: ?boolean,
466
+ metaKey?: ?boolean,
467
+ shiftKey?: ?boolean,
468
+ code: string,
469
+ |}>;
470
+
471
+ type WindowsProps = $ReadOnly<{|
472
+ /**
473
+ * If `true`, clears the text field synchronously before `onSubmitEditing` is emitted.
474
+ * @platform windows
475
+ */
476
+ clearTextOnSubmit?: ?boolean,
477
+
478
+ /**
479
+ * Configures keys that can be used to submit editing for the TextInput.
480
+ * @platform windows
481
+ */
482
+ submitKeyEvents?: ?$ReadOnlyArray<SubmitKeyEvent>,
483
+ |}>;
484
+
485
+ // Windows]
486
+
411
487
  export type Props = $ReadOnly<{|
412
488
  ...$Diff<ViewProps, $ReadOnly<{|style: ?ViewStyleProp|}>>,
413
489
  ...IOSProps,
414
490
  ...AndroidProps,
491
+ ...WindowsProps, // [Windows]
415
492
 
416
493
  /**
417
494
  * String to be read by screenreaders to indicate an error state. The acceptable parameters
@@ -441,7 +518,16 @@ export type Props = $ReadOnly<{|
441
518
  * - `additional-name`
442
519
  * - `address-line1`
443
520
  * - `address-line2`
521
+ * - `birthdate-day` (iOS 17+)
522
+ * - `birthdate-full` (iOS 17+)
523
+ * - `birthdate-month` (iOS 17+)
524
+ * - `birthdate-year` (iOS 17+)
444
525
  * - `cc-number`
526
+ * - `cc-csc` (iOS 17+)
527
+ * - `cc-exp` (iOS 17+)
528
+ * - `cc-exp-day` (iOS 17+)
529
+ * - `cc-exp-month` (iOS 17+)
530
+ * - `cc-exp-year` (iOS 17+)
445
531
  * - `country`
446
532
  * - `current-password`
447
533
  * - `email`
@@ -460,6 +546,11 @@ export type Props = $ReadOnly<{|
460
546
  *
461
547
  * The following values work on iOS only:
462
548
  *
549
+ * - `cc-name` (iOS 17+)
550
+ * - `cc-given-name` (iOS 17+)
551
+ * - `cc-middle-name` (iOS 17+)
552
+ * - `cc-family-name` (iOS 17+)
553
+ * - `cc-type` (iOS 17+)
463
554
  * - `nickname`
464
555
  * - `organization`
465
556
  * - `organization-title`
@@ -467,15 +558,6 @@ export type Props = $ReadOnly<{|
467
558
  *
468
559
  * The following values work on Android only:
469
560
  *
470
- * - `birthdate-day`
471
- * - `birthdate-full`
472
- * - `birthdate-month`
473
- * - `birthdate-year`
474
- * - `cc-csc`
475
- * - `cc-exp`
476
- * - `cc-exp-day`
477
- * - `cc-exp-month`
478
- * - `cc-exp-year`
479
561
  * - `gender`
480
562
  * - `name-family`
481
563
  * - `name-given`
@@ -511,6 +593,11 @@ export type Props = $ReadOnly<{|
511
593
  | 'cc-exp-month'
512
594
  | 'cc-exp-year'
513
595
  | 'cc-number'
596
+ | 'cc-name'
597
+ | 'cc-given-name'
598
+ | 'cc-middle-name'
599
+ | 'cc-family-name'
600
+ | 'cc-type'
514
601
  | 'country'
515
602
  | 'current-password'
516
603
  | 'email'
@@ -575,7 +662,7 @@ export type Props = $ReadOnly<{|
575
662
  * On Android devices manufactured by Xiaomi with Android Q,
576
663
  * when keyboardType equals 'email-address'this will be set
577
664
  * in native to 'true' to prevent a system related crash. This
578
- * will cause cursor to be diabled as a side-effect.
665
+ * will cause cursor to be disabled as a side-effect.
579
666
  *
580
667
  */
581
668
  caretHidden?: ?boolean,
@@ -933,215 +1020,875 @@ export type Props = $ReadOnly<{|
933
1020
  * unwanted edits without flicker.
934
1021
  */
935
1022
  value?: ?Stringish,
936
-
937
- text?: ?Stringish, // Win32
938
1023
  |}>;
939
1024
 
940
- /*
941
- import {
942
- TextInputProps,
943
- NativeMethods,
944
- } from 'react-native';
945
- import {
946
- IBlurEvent,
947
- IChangeEvent,
948
- IFocusEvent,
949
- } from './TextInput.Types.win32';
950
- import React from 'react'
951
-
952
- type RCTTextInputProps = TextInputProps & {
953
- text: string;
954
- };
955
- */
956
-
957
- // RCTTextInput is the native component that win32 understands
958
- const RCTTextInput = requireNativeComponent<Props>('RCTTextInput');
1025
+ const emptyFunctionThatReturnsTrue = () => true;
959
1026
 
960
- // Adding typings on ViewManagers is problematic as available functionality is not known until
961
- // registration at runtime and would require native and js to always be in sync.
962
- const TextInputViewManager = UIManager.getViewManagerConfig('RCTTextInput');
1027
+ /**
1028
+ * A foundational component for inputting text into the app via a
1029
+ * keyboard. Props provide configurability for several features, such as
1030
+ * auto-correction, auto-capitalization, placeholder text, and different keyboard
1031
+ * types, such as a numeric keypad.
1032
+ *
1033
+ * The simplest use case is to plop down a `TextInput` and subscribe to the
1034
+ * `onChangeText` events to read the user input. There are also other events,
1035
+ * such as `onSubmitEditing` and `onFocus` that can be subscribed to. A simple
1036
+ * example:
1037
+ *
1038
+ * ```ReactNativeWebPlayer
1039
+ * import React, { Component } from 'react';
1040
+ * import { AppRegistry, TextInput } from 'react-native';
1041
+ *
1042
+ * export default class UselessTextInput extends Component {
1043
+ * constructor(props) {
1044
+ * super(props);
1045
+ * this.state = { text: 'Useless Placeholder' };
1046
+ * }
1047
+ *
1048
+ * render() {
1049
+ * return (
1050
+ * <TextInput
1051
+ * style={{height: 40, borderColor: 'gray', borderWidth: 1}}
1052
+ * onChangeText={(text) => this.setState({text})}
1053
+ * value={this.state.text}
1054
+ * />
1055
+ * );
1056
+ * }
1057
+ * }
1058
+ *
1059
+ * // skip this line if using Create React Native App
1060
+ * AppRegistry.registerComponent('AwesomeProject', () => UselessTextInput);
1061
+ * ```
1062
+ *
1063
+ * Two methods exposed via the native element are .focus() and .blur() that
1064
+ * will focus or blur the TextInput programmatically.
1065
+ *
1066
+ * Note that some props are only available with `multiline={true/false}`.
1067
+ * Additionally, border styles that apply to only one side of the element
1068
+ * (e.g., `borderBottomColor`, `borderLeftWidth`, etc.) will not be applied if
1069
+ * `multiline=false`. To achieve the same effect, you can wrap your `TextInput`
1070
+ * in a `View`:
1071
+ *
1072
+ * ```ReactNativeWebPlayer
1073
+ * import React, { Component } from 'react';
1074
+ * import { AppRegistry, View, TextInput } from 'react-native';
1075
+ *
1076
+ * class UselessTextInput extends Component {
1077
+ * render() {
1078
+ * return (
1079
+ * <TextInput
1080
+ * {...this.props} // Inherit any props passed to it; e.g., multiline, numberOfLines below
1081
+ * editable = {true}
1082
+ * maxLength = {40}
1083
+ * />
1084
+ * );
1085
+ * }
1086
+ * }
1087
+ *
1088
+ * export default class UselessTextInputMultiline extends Component {
1089
+ * constructor(props) {
1090
+ * super(props);
1091
+ * this.state = {
1092
+ * text: 'Useless Multiline Placeholder',
1093
+ * };
1094
+ * }
1095
+ *
1096
+ * // If you type something in the text box that is a color, the background will change to that
1097
+ * // color.
1098
+ * render() {
1099
+ * return (
1100
+ * <View style={{
1101
+ * backgroundColor: this.state.text,
1102
+ * borderBottomColor: '#000000',
1103
+ * borderBottomWidth: 1 }}
1104
+ * >
1105
+ * <UselessTextInput
1106
+ * multiline = {true}
1107
+ * numberOfLines = {4}
1108
+ * onChangeText={(text) => this.setState({text})}
1109
+ * value={this.state.text}
1110
+ * />
1111
+ * </View>
1112
+ * );
1113
+ * }
1114
+ * }
1115
+ *
1116
+ * // skip these lines if using Create React Native App
1117
+ * AppRegistry.registerComponent(
1118
+ * 'AwesomeProject',
1119
+ * () => UselessTextInputMultiline
1120
+ * );
1121
+ * ```
1122
+ *
1123
+ * `TextInput` has by default a border at the bottom of its view. This border
1124
+ * has its padding set by the background image provided by the system, and it
1125
+ * cannot be changed. Solutions to avoid this is to either not set height
1126
+ * explicitly, case in which the system will take care of displaying the border
1127
+ * in the correct position, or to not display the border by setting
1128
+ * `underlineColorAndroid` to transparent.
1129
+ *
1130
+ * Note that on Android performing text selection in input can change
1131
+ * app's activity `windowSoftInputMode` param to `adjustResize`.
1132
+ * This may cause issues with components that have position: 'absolute'
1133
+ * while keyboard is active. To avoid this behavior either specify `windowSoftInputMode`
1134
+ * in AndroidManifest.xml ( https://developer.android.com/guide/topics/manifest/activity-element.html )
1135
+ * or control this param programmatically with native code.
1136
+ *
1137
+ */
1138
+ function InternalTextInput(props: Props): React.Node {
1139
+ const {
1140
+ 'aria-busy': ariaBusy,
1141
+ 'aria-checked': ariaChecked,
1142
+ 'aria-disabled': ariaDisabled,
1143
+ 'aria-expanded': ariaExpanded,
1144
+ 'aria-selected': ariaSelected,
1145
+ 'aria-multiselectable': ariaMultiselectable, // Win32
1146
+ 'aria-required': ariaRequired, // Win32
1147
+ accessibilityState,
1148
+ id,
1149
+ tabIndex,
1150
+ selection: propsSelection,
1151
+ ...otherProps
1152
+ } = props;
1153
+
1154
+ const inputRef = useRef<null | React.ElementRef<HostComponent<mixed>>>(null);
1155
+
1156
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1157
+ const selection: ?Selection =
1158
+ propsSelection == null
1159
+ ? null
1160
+ : {
1161
+ start: propsSelection.start,
1162
+ end: propsSelection.end ?? propsSelection.start,
1163
+ };
1164
+
1165
+ const [mostRecentEventCount, setMostRecentEventCount] = useState<number>(0);
1166
+
1167
+ const [lastNativeText, setLastNativeText] = useState<?Stringish>(props.value);
1168
+ const [lastNativeSelectionState, setLastNativeSelection] = useState<{|
1169
+ selection: ?Selection,
1170
+ mostRecentEventCount: number,
1171
+ |}>({selection, mostRecentEventCount});
1172
+
1173
+ const lastNativeSelection = lastNativeSelectionState.selection;
1174
+
1175
+ let viewCommands;
1176
+ if (AndroidTextInputCommands) {
1177
+ viewCommands = AndroidTextInputCommands;
1178
+ }
1179
+ // [Windows
1180
+ else if (WindowsTextInputCommands) {
1181
+ viewCommands = WindowsTextInputCommands;
1182
+ }
1183
+ // Windows]
1184
+ else {
1185
+ viewCommands =
1186
+ props.multiline === true
1187
+ ? RCTMultilineTextInputNativeCommands
1188
+ : RCTSinglelineTextInputNativeCommands;
1189
+ }
963
1190
 
964
- class TextInput extends React.Component<Props, {}> {
965
- // TODO: Once the native side begins supporting programmatic selection
966
- // this will become important for selection management
967
- // private _lastNativeTextSelection: any;
1191
+ const text =
1192
+ typeof props.value === 'string'
1193
+ ? props.value
1194
+ : typeof props.defaultValue === 'string'
1195
+ ? props.defaultValue
1196
+ : '';
1197
+
1198
+ // This is necessary in case native updates the text and JS decides
1199
+ // that the update should be ignored and we should stick with the value
1200
+ // that we have in JS.
1201
+ useLayoutEffect(() => {
1202
+ const nativeUpdate: {text?: string, selection?: Selection} = {};
1203
+
1204
+ if (lastNativeText !== props.value && typeof props.value === 'string') {
1205
+ nativeUpdate.text = props.value;
1206
+ setLastNativeText(props.value);
1207
+ }
968
1208
 
969
- _rafID: AnimationFrameID;
1209
+ if (
1210
+ selection &&
1211
+ lastNativeSelection &&
1212
+ (lastNativeSelection.start !== selection.start ||
1213
+ lastNativeSelection.end !== selection.end)
1214
+ ) {
1215
+ nativeUpdate.selection = selection;
1216
+ setLastNativeSelection({selection, mostRecentEventCount});
1217
+ }
970
1218
 
971
- _lastNativeText: ?Stringish;
972
- _eventCount: number = 0;
1219
+ if (Object.keys(nativeUpdate).length === 0) {
1220
+ return;
1221
+ }
973
1222
 
974
- constructor(props: Props) {
975
- super(props);
976
- }
1223
+ if (inputRef.current != null) {
1224
+ viewCommands.setTextAndSelection(
1225
+ inputRef.current,
1226
+ mostRecentEventCount,
1227
+ text,
1228
+ selection?.start ?? -1,
1229
+ selection?.end ?? -1,
1230
+ );
1231
+ }
1232
+ }, [
1233
+ mostRecentEventCount,
1234
+ inputRef,
1235
+ props.value,
1236
+ props.defaultValue,
1237
+ lastNativeText,
1238
+ selection,
1239
+ lastNativeSelection,
1240
+ text,
1241
+ viewCommands,
1242
+ ]);
1243
+
1244
+ useLayoutEffect(() => {
1245
+ const inputRefValue = inputRef.current;
1246
+
1247
+ if (inputRefValue != null) {
1248
+ TextInputState.registerInput(inputRefValue);
1249
+
1250
+ return () => {
1251
+ TextInputState.unregisterInput(inputRefValue);
1252
+
1253
+ if (TextInputState.currentlyFocusedInput() === inputRefValue) {
1254
+ nullthrows(inputRefValue).blur();
1255
+ }
1256
+ };
1257
+ }
1258
+ }, [inputRef]);
1259
+
1260
+ const setLocalRef = useCallback(
1261
+ (instance: TextInputInstance | null) => {
1262
+ inputRef.current = instance;
1263
+
1264
+ /*
1265
+ Hi reader from the future. I'm sorry for this.
1266
+
1267
+ This is a hack. Ideally we would forwardRef to the underlying
1268
+ host component. However, since TextInput has it's own methods that can be
1269
+ called as well, if we used the standard forwardRef then these
1270
+ methods wouldn't be accessible and thus be a breaking change.
1271
+
1272
+ We have a couple of options of how to handle this:
1273
+ - Return a new ref with everything we methods from both. This is problematic
1274
+ because we need React to also know it is a host component which requires
1275
+ internals of the class implementation of the ref.
1276
+ - Break the API and have some other way to call one set of the methods or
1277
+ the other. This is our long term approach as we want to eventually
1278
+ get the methods on host components off the ref. So instead of calling
1279
+ ref.measure() you might call ReactNative.measure(ref). This would hopefully
1280
+ let the ref for TextInput then have the methods like `.clear`. Or we do it
1281
+ the other way and make it TextInput.clear(textInputRef) which would be fine
1282
+ too. Either way though is a breaking change that is longer term.
1283
+ - Mutate this ref. :( Gross, but accomplishes what we need in the meantime
1284
+ before we can get to the long term breaking change.
1285
+ */
1286
+ if (instance != null) {
1287
+ // $FlowFixMe[incompatible-use] - See the explanation above.
1288
+ Object.assign(instance, {
1289
+ clear(): void {
1290
+ if (inputRef.current != null) {
1291
+ viewCommands.setTextAndSelection(
1292
+ inputRef.current,
1293
+ mostRecentEventCount,
1294
+ '',
1295
+ 0,
1296
+ 0,
1297
+ );
1298
+ }
1299
+ },
1300
+ // TODO: Fix this returning true on null === null, when no input is focused
1301
+ isFocused(): boolean {
1302
+ return TextInputState.currentlyFocusedInput() === inputRef.current;
1303
+ },
1304
+ getNativeRef(): ?React.ElementRef<HostComponent<mixed>> {
1305
+ return inputRef.current;
1306
+ },
1307
+ setSelection(start: number, end: number): void {
1308
+ if (inputRef.current != null) {
1309
+ viewCommands.setTextAndSelection(
1310
+ inputRef.current,
1311
+ mostRecentEventCount,
1312
+ null,
1313
+ start,
1314
+ end,
1315
+ );
1316
+ }
1317
+ },
1318
+ });
1319
+ }
1320
+ },
1321
+ [mostRecentEventCount, viewCommands],
1322
+ );
1323
+
1324
+ const ref = useMergeRefs<TextInputInstance | null>(
1325
+ setLocalRef,
1326
+ props.forwardedRef,
1327
+ );
1328
+
1329
+ const _onChange = (event: ChangeEvent) => {
1330
+ const currentText = event.nativeEvent.text;
1331
+ props.onChange && props.onChange(event);
1332
+ props.onChangeText && props.onChangeText(currentText);
1333
+
1334
+ if (inputRef.current == null) {
1335
+ // calling `props.onChange` or `props.onChangeText`
1336
+ // may clean up the input itself. Exits here.
1337
+ return;
1338
+ }
977
1339
 
978
- /**
979
- * On mount TextInput needs to register itself with TextInputState
980
- * and conditionally request an animation frame for focus.
981
- */
982
- componentDidMount() {
983
- this._lastNativeText = this.props.value;
1340
+ setLastNativeText(currentText);
1341
+ // This must happen last, after we call setLastNativeText.
1342
+ // Different ordering can cause bugs when editing AndroidTextInputs
1343
+ // with multiple Fragments.
1344
+ // We must update this so that controlled input updates work.
1345
+ setMostRecentEventCount(event.nativeEvent.eventCount);
1346
+ };
984
1347
 
985
- // $FlowFixMe - // Win32
986
- TextInputState.registerInput(this);
1348
+ const _onChangeSync = (event: ChangeEvent) => {
1349
+ const currentText = event.nativeEvent.text;
1350
+ props.unstable_onChangeSync && props.unstable_onChangeSync(event);
1351
+ props.unstable_onChangeTextSync &&
1352
+ props.unstable_onChangeTextSync(currentText);
987
1353
 
988
- if (this.props.autoFocus === true) {
989
- this._rafID = requestAnimationFrame(this.focus);
1354
+ if (inputRef.current == null) {
1355
+ // calling `props.onChange` or `props.onChangeText`
1356
+ // may clean up the input itself. Exits here.
1357
+ return;
990
1358
  }
991
- }
992
1359
 
993
- /**
994
- * This is an unfortunate consequence of having controlled TextInputs.
995
- * Tree diffing reconciliation will not always send down text values
996
- * This sets text explicitly.
997
- */
998
- componentDidUpdate() {
999
- if (this._lastNativeText !== this._getText()) {
1000
- this._getText() && this.setNativeText(this._getText());
1001
- }
1360
+ setLastNativeText(currentText);
1361
+ // This must happen last, after we call setLastNativeText.
1362
+ // Different ordering can cause bugs when editing AndroidTextInputs
1363
+ // with multiple Fragments.
1364
+ // We must update this so that controlled input updates work.
1365
+ setMostRecentEventCount(event.nativeEvent.eventCount);
1366
+ };
1002
1367
 
1003
- return;
1004
- }
1368
+ const _onSelectionChange = (event: SelectionChangeEvent) => {
1369
+ props.onSelectionChange && props.onSelectionChange(event);
1005
1370
 
1006
- /**
1007
- * Pre-unmoun the TextInput should blur, unregister and clean up
1008
- * the animation frame for focus (edge cases)
1009
- */
1010
- componentWillUnmount() {
1011
- // blur
1012
- if (this.isFocused()) {
1013
- this.blur();
1371
+ if (inputRef.current == null) {
1372
+ // calling `props.onSelectionChange`
1373
+ // may clean up the input itself. Exits here.
1374
+ return;
1014
1375
  }
1015
1376
 
1016
- // unregister
1017
- // $FlowFixMe - // Win32
1018
- TextInputState.unregisterInput(this);
1377
+ setLastNativeSelection({
1378
+ selection: event.nativeEvent.selection,
1379
+ mostRecentEventCount,
1380
+ });
1381
+ };
1019
1382
 
1020
- // cancel animationFrame
1021
- if (this._rafID !== null) {
1022
- cancelAnimationFrame(this._rafID);
1383
+ const _onFocus = (event: FocusEvent) => {
1384
+ TextInputState.focusInput(inputRef.current);
1385
+ if (props.onFocus) {
1386
+ props.onFocus(event);
1023
1387
  }
1024
- if (this._rafID) {
1025
- return;
1388
+ };
1389
+
1390
+ const _onBlur = (event: BlurEvent) => {
1391
+ TextInputState.blurInput(inputRef.current);
1392
+ if (props.onBlur) {
1393
+ props.onBlur(event);
1026
1394
  }
1027
- return;
1028
- }
1395
+ };
1029
1396
 
1030
- render(): React.Node {
1031
- let {allowFontScaling, ...otherProps} = this.props;
1032
-
1033
- allowFontScaling =
1034
- this.props.allowFontScaling === null ||
1035
- this.props.allowFontScaling === undefined
1036
- ? true
1037
- : this.props.allowFontScaling;
1038
-
1039
- return (
1040
- <TextAncestor.Provider value={true}>
1041
- <RCTTextInput
1042
- {...otherProps}
1043
- allowFontScaling={allowFontScaling}
1044
- text={this._getText()}
1045
- onFocus={this._onFocus}
1046
- onBlur={this._onBlur}
1047
- onChange={this._onChange}
1048
- />
1049
- </TextAncestor.Provider>
1050
- );
1051
- }
1397
+ const _onScroll = (event: ScrollEvent) => {
1398
+ props.onScroll && props.onScroll(event);
1399
+ };
1052
1400
 
1053
- /**
1054
- * Returns true if the TextInput is focused
1055
- */
1056
- isFocused(): boolean {
1057
- return TextInputState.currentlyFocusedInput() === this;
1401
+ let textInput = null;
1402
+
1403
+ const multiline = props.multiline ?? false;
1404
+
1405
+ let submitBehavior: SubmitBehavior;
1406
+ if (props.submitBehavior != null) {
1407
+ // `submitBehavior` is set explicitly
1408
+ if (!multiline && props.submitBehavior === 'newline') {
1409
+ // For single line text inputs, `'newline'` is not a valid option
1410
+ submitBehavior = 'blurAndSubmit';
1411
+ } else {
1412
+ submitBehavior = props.submitBehavior;
1413
+ }
1414
+ } else if (multiline) {
1415
+ if (props.blurOnSubmit === true) {
1416
+ submitBehavior = 'blurAndSubmit';
1417
+ } else {
1418
+ submitBehavior = 'newline';
1419
+ }
1420
+ } else {
1421
+ // Single line
1422
+ if (props.blurOnSubmit !== false) {
1423
+ submitBehavior = 'blurAndSubmit';
1424
+ } else {
1425
+ submitBehavior = 'submit';
1426
+ }
1058
1427
  }
1059
1428
 
1060
- /**
1061
- * Focuses the TextInput
1062
- */
1063
- focus: () => void = (): void => {
1064
- // $FlowFixMe - // Win32
1065
- TextInputState.setFocusedTextInput(this);
1066
- UIManager.dispatchViewManagerCommand(
1067
- findNodeHandle(this),
1068
- TextInputViewManager.Commands.focus,
1069
- null,
1070
- );
1071
- };
1429
+ const accessible = props.accessible !== false;
1430
+
1431
+ const accessibilityErrorMessage =
1432
+ props.accessibilityInvalid === true
1433
+ ? props.accessibilityErrorMessage
1434
+ : null;
1435
+
1436
+ const focusable = props.focusable !== false;
1437
+
1438
+ const config = React.useMemo(
1439
+ () => ({
1440
+ hitSlop: props.hitSlop,
1441
+ onPress: (event: PressEvent) => {
1442
+ if (props.editable !== false) {
1443
+ if (inputRef.current != null) {
1444
+ inputRef.current.focus();
1445
+ }
1446
+ }
1447
+ },
1448
+ onPressIn: props.onPressIn,
1449
+ onPressOut: props.onPressOut,
1450
+ cancelable:
1451
+ Platform.OS === 'ios' ? !props.rejectResponderTermination : null,
1452
+ }),
1453
+ [
1454
+ props.editable,
1455
+ props.hitSlop,
1456
+ props.onPressIn,
1457
+ props.onPressOut,
1458
+ props.rejectResponderTermination,
1459
+ ],
1460
+ );
1461
+
1462
+ // Hide caret during test runs due to a flashing caret
1463
+ // makes screenshot tests flakey
1464
+ let caretHidden = props.caretHidden;
1465
+ if (Platform.isTesting) {
1466
+ caretHidden = true;
1467
+ }
1072
1468
 
1073
- /**
1074
- * Blurs the TextInput
1075
- */
1076
- blur: () => void = (): void => {
1077
- // $FlowFixMe - // Win32
1078
- TextInputState.blurTextInput(this);
1079
- UIManager.dispatchViewManagerCommand(
1080
- findNodeHandle(this),
1081
- TextInputViewManager.Commands.blur,
1082
- null,
1083
- );
1469
+ // TextInput handles onBlur and onFocus events
1470
+ // so omitting onBlur and onFocus pressability handlers here.
1471
+ const {onBlur, onFocus, ...eventHandlers} = usePressability(config) || {};
1472
+ const eventPhase = Object.freeze({Capturing: 1, Bubbling: 3});
1473
+ const _keyDown = (event: KeyEvent) => {
1474
+ if (props.keyDownEvents && event.isPropagationStopped() !== true) {
1475
+ // $FlowFixMe - keyDownEvents was already checked to not be undefined
1476
+ for (const el of props.keyDownEvents) {
1477
+ if (
1478
+ event.nativeEvent.code == el.code &&
1479
+ el.handledEventPhase == eventPhase.Bubbling
1480
+ ) {
1481
+ event.stopPropagation();
1482
+ }
1483
+ }
1484
+ }
1485
+ props.onKeyDown && props.onKeyDown(event);
1084
1486
  };
1085
1487
 
1086
- /**
1087
- * Use clear for programmatic clearing of the text
1088
- */
1089
- clear: () => void = (): void => {
1090
- this.setNativeText('');
1488
+ const _keyUp = (event: KeyEvent) => {
1489
+ if (props.keyUpEvents && event.isPropagationStopped() !== true) {
1490
+ // $FlowFixMe - keyDownEvents was already checked to not be undefined
1491
+ for (const el of props.keyUpEvents) {
1492
+ if (event.nativeEvent.code == el.code && el.handledEventPhase == 3) {
1493
+ event.stopPropagation();
1494
+ }
1495
+ }
1496
+ }
1497
+ props.onKeyUp && props.onKeyUp(event);
1091
1498
  };
1092
1499
 
1093
- setEventCount: () => void = (): void => {
1094
- UIManager.dispatchViewManagerCommand(
1095
- findNodeHandle(this),
1096
- TextInputViewManager.Commands.setEventCount,
1097
- [this._eventCount],
1098
- );
1500
+ const _keyDownCapture = (event: KeyEvent) => {
1501
+ if (props.keyDownEvents && event.isPropagationStopped() !== true) {
1502
+ // $FlowFixMe - keyDownEvents was already checked to not be undefined
1503
+ for (const el of props.keyDownEvents) {
1504
+ if (event.nativeEvent.code == el.code && el.handledEventPhase == 1) {
1505
+ event.stopPropagation();
1506
+ }
1507
+ }
1508
+ }
1509
+ props.onKeyDownCapture && props.onKeyDownCapture(event);
1099
1510
  };
1100
1511
 
1101
- setNativeText: (val: ?Stringish) => void = (val: ?Stringish): void => {
1102
- if (this._lastNativeText !== val) {
1103
- UIManager.dispatchViewManagerCommand(
1104
- findNodeHandle(this),
1105
- TextInputViewManager.Commands.setNativeText,
1106
- [val],
1107
- );
1512
+ const _keyUpCapture = (event: KeyEvent) => {
1513
+ if (props.keyUpEvents && event.isPropagationStopped() !== true) {
1514
+ // $FlowFixMe - keyDownEvents was already checked to not be undefined
1515
+ for (const el of props.keyUpEvents) {
1516
+ if (event.nativeEvent.code == el.code && el.handledEventPhase == 1) {
1517
+ event.stopPropagation();
1518
+ }
1519
+ }
1108
1520
  }
1521
+ props.onKeyUpCapture && props.onKeyUpCapture(event);
1109
1522
  };
1110
1523
 
1111
- _getText = (): string | null => {
1112
- if (this.props.value != null && this.props.value != undefined) {
1113
- return this.props.value;
1114
- }
1115
- if (
1116
- this.props.defaultValue != null &&
1117
- this.props.defaultValue != undefined
1118
- ) {
1119
- return this.props.defaultValue;
1524
+ let _accessibilityState;
1525
+ if (
1526
+ accessibilityState != null ||
1527
+ ariaBusy != null ||
1528
+ ariaChecked != null ||
1529
+ ariaDisabled != null ||
1530
+ ariaExpanded != null ||
1531
+ ariaMultiselectable != null ||
1532
+ ariaRequired != null ||
1533
+ ariaSelected != null
1534
+ ) {
1535
+ _accessibilityState = {
1536
+ busy: ariaBusy ?? accessibilityState?.busy,
1537
+ checked: ariaChecked ?? accessibilityState?.checked,
1538
+ disabled: ariaDisabled ?? accessibilityState?.disabled,
1539
+ expanded: ariaExpanded ?? accessibilityState?.expanded,
1540
+ multiselectable:
1541
+ ariaMultiselectable ?? accessibilityState?.multiselectable, // Win32
1542
+ required: ariaRequired ?? accessibilityState?.required, // Win32
1543
+ selected: ariaSelected ?? accessibilityState?.selected,
1544
+ };
1545
+ }
1546
+
1547
+ // $FlowFixMe[underconstrained-implicit-instantiation]
1548
+ let style = flattenStyle(props.style);
1549
+
1550
+ if (Platform.OS === 'ios') {
1551
+ const RCTTextInputView =
1552
+ props.multiline === true
1553
+ ? RCTMultilineTextInputView
1554
+ : RCTSinglelineTextInputView;
1555
+
1556
+ style = props.multiline === true ? [styles.multilineInput, style] : style;
1557
+
1558
+ const useOnChangeSync =
1559
+ (props.unstable_onChangeSync || props.unstable_onChangeTextSync) &&
1560
+ !(props.onChange || props.onChangeText);
1561
+
1562
+ textInput = (
1563
+ <RCTTextInputView
1564
+ // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1565
+ ref={ref}
1566
+ {...otherProps}
1567
+ {...eventHandlers}
1568
+ accessibilityErrorMessage={accessibilityErrorMessage}
1569
+ accessibilityState={_accessibilityState}
1570
+ accessible={accessible}
1571
+ submitBehavior={submitBehavior}
1572
+ caretHidden={caretHidden}
1573
+ dataDetectorTypes={props.dataDetectorTypes}
1574
+ focusable={tabIndex !== undefined ? !tabIndex : focusable}
1575
+ mostRecentEventCount={mostRecentEventCount}
1576
+ nativeID={id ?? props.nativeID}
1577
+ onBlur={_onBlur}
1578
+ onKeyPressSync={props.unstable_onKeyPressSync}
1579
+ onChange={_onChange}
1580
+ onChangeSync={useOnChangeSync === true ? _onChangeSync : null}
1581
+ onContentSizeChange={props.onContentSizeChange}
1582
+ onFocus={_onFocus}
1583
+ onScroll={_onScroll}
1584
+ onSelectionChange={_onSelectionChange}
1585
+ onSelectionChangeShouldSetResponder={emptyFunctionThatReturnsTrue}
1586
+ selection={selection}
1587
+ style={style}
1588
+ text={text}
1589
+ />
1590
+ );
1591
+ } else if (Platform.OS === 'android') {
1592
+ const autoCapitalize = props.autoCapitalize || 'sentences';
1593
+ const _accessibilityLabelledBy =
1594
+ props?.['aria-labelledby'] ?? props?.accessibilityLabelledBy;
1595
+ const placeholder = props.placeholder ?? '';
1596
+ let children = props.children;
1597
+ const childCount = React.Children.count(children);
1598
+ invariant(
1599
+ !(props.value != null && childCount),
1600
+ 'Cannot specify both value and children.',
1601
+ );
1602
+ if (childCount > 1) {
1603
+ children = <Text>{children}</Text>;
1120
1604
  }
1121
- return null;
1122
- };
1123
1605
 
1124
- _onChange = (e: ChangeEvent): void => {
1125
- const text = e.nativeEvent.text;
1126
- this._eventCount = e.nativeEvent.eventCount;
1127
- this.setEventCount();
1606
+ textInput = (
1607
+ /* $FlowFixMe[prop-missing] the types for AndroidTextInput don't match up
1608
+ * exactly with the props for TextInput. This will need to get fixed */
1609
+ /* $FlowFixMe[incompatible-type] the types for AndroidTextInput don't
1610
+ * match up exactly with the props for TextInput. This will need to get
1611
+ * fixed */
1612
+ /* $FlowFixMe[incompatible-type-arg] the types for AndroidTextInput don't
1613
+ * match up exactly with the props for TextInput. This will need to get
1614
+ * fixed */
1615
+ <AndroidTextInput
1616
+ // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1617
+ ref={ref}
1618
+ {...otherProps}
1619
+ {...eventHandlers}
1620
+ accessibilityErrorMessage={accessibilityErrorMessage}
1621
+ accessibilityState={_accessibilityState}
1622
+ accessibilityLabelledBy={_accessibilityLabelledBy}
1623
+ accessible={accessible}
1624
+ autoCapitalize={autoCapitalize}
1625
+ submitBehavior={submitBehavior}
1626
+ caretHidden={caretHidden}
1627
+ children={children}
1628
+ disableFullscreenUI={props.disableFullscreenUI}
1629
+ focusable={tabIndex !== undefined ? !tabIndex : focusable}
1630
+ mostRecentEventCount={mostRecentEventCount}
1631
+ nativeID={id ?? props.nativeID}
1632
+ numberOfLines={props.rows ?? props.numberOfLines}
1633
+ onBlur={_onBlur}
1634
+ onChange={_onChange}
1635
+ onFocus={_onFocus}
1636
+ /* $FlowFixMe[prop-missing] the types for AndroidTextInput don't match
1637
+ * up exactly with the props for TextInput. This will need to get fixed
1638
+ */
1639
+ /* $FlowFixMe[incompatible-type-arg] the types for AndroidTextInput
1640
+ * don't match up exactly with the props for TextInput. This will need
1641
+ * to get fixed */
1642
+ onScroll={_onScroll}
1643
+ onSelectionChange={_onSelectionChange}
1644
+ placeholder={placeholder}
1645
+ style={style}
1646
+ text={text}
1647
+ textBreakStrategy={props.textBreakStrategy}
1648
+ />
1649
+ );
1650
+ } // [Windows
1651
+ else if (Platform.OS === 'win32') {
1652
+ textInput = (
1653
+ <WindowsTextInput
1654
+ // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1655
+ ref={ref}
1656
+ {...props}
1657
+ accessible={accessible}
1658
+ focusable={focusable}
1659
+ dataDetectorTypes={props.dataDetectorTypes}
1660
+ mostRecentEventCount={mostRecentEventCount}
1661
+ onBlur={_onBlur}
1662
+ onChange={_onChange}
1663
+ onContentSizeChange={props.onContentSizeChange}
1664
+ onFocus={_onFocus}
1665
+ onScroll={_onScroll}
1666
+ onSelectionChange={_onSelectionChange}
1667
+ onSelectionChangeShouldSetResponder={emptyFunctionThatReturnsTrue}
1668
+ selection={selection}
1669
+ text={text}
1670
+ onKeyDown={_keyDown}
1671
+ onKeyDownCapture={_keyDownCapture}
1672
+ onKeyUp={_keyUp}
1673
+ onKeyUpCapture={_keyUpCapture}
1674
+ />
1675
+ );
1676
+ } // Windows]
1677
+ return (
1678
+ <TextAncestor.Provider value={true}>{textInput}</TextAncestor.Provider>
1679
+ );
1680
+ }
1128
1681
 
1129
- this.props.onChange && this.props.onChange(e);
1130
- this.props.onChangeText && this.props.onChangeText(text);
1131
- this._lastNativeText = text;
1682
+ const enterKeyHintToReturnTypeMap = {
1683
+ enter: 'default',
1684
+ done: 'done',
1685
+ go: 'go',
1686
+ next: 'next',
1687
+ previous: 'previous',
1688
+ search: 'search',
1689
+ send: 'send',
1690
+ };
1132
1691
 
1133
- this.forceUpdate();
1134
- return;
1135
- };
1692
+ const inputModeToKeyboardTypeMap = {
1693
+ none: 'default',
1694
+ text: 'default',
1695
+ decimal: 'decimal-pad',
1696
+ numeric: 'number-pad',
1697
+ tel: 'phone-pad',
1698
+ search: Platform.OS === 'ios' ? 'web-search' : 'default',
1699
+ email: 'email-address',
1700
+ url: 'url',
1701
+ };
1136
1702
 
1137
- _onFocus = (e: FocusEvent): void => {
1138
- this.focus();
1139
- this.props.onFocus && this.props.onFocus(e);
1140
- };
1703
+ // Map HTML autocomplete values to Android autoComplete values
1704
+ const autoCompleteWebToAutoCompleteAndroidMap = {
1705
+ 'address-line1': 'postal-address-region',
1706
+ 'address-line2': 'postal-address-locality',
1707
+ bday: 'birthdate-full',
1708
+ 'bday-day': 'birthdate-day',
1709
+ 'bday-month': 'birthdate-month',
1710
+ 'bday-year': 'birthdate-year',
1711
+ 'cc-csc': 'cc-csc',
1712
+ 'cc-exp': 'cc-exp',
1713
+ 'cc-exp-month': 'cc-exp-month',
1714
+ 'cc-exp-year': 'cc-exp-year',
1715
+ 'cc-number': 'cc-number',
1716
+ country: 'postal-address-country',
1717
+ 'current-password': 'password',
1718
+ email: 'email',
1719
+ 'honorific-prefix': 'name-prefix',
1720
+ 'honorific-suffix': 'name-suffix',
1721
+ name: 'name',
1722
+ 'additional-name': 'name-middle',
1723
+ 'family-name': 'name-family',
1724
+ 'given-name': 'name-given',
1725
+ 'new-password': 'password-new',
1726
+ off: 'off',
1727
+ 'one-time-code': 'sms-otp',
1728
+ 'postal-code': 'postal-code',
1729
+ sex: 'gender',
1730
+ 'street-address': 'street-address',
1731
+ tel: 'tel',
1732
+ 'tel-country-code': 'tel-country-code',
1733
+ 'tel-national': 'tel-national',
1734
+ username: 'username',
1735
+ };
1141
1736
 
1142
- _onBlur = (e: BlurEvent): void => {
1143
- this.props.onBlur && this.props.onBlur(e);
1144
- };
1145
- }
1737
+ // Map HTML autocomplete values to iOS textContentType values
1738
+ const autoCompleteWebToTextContentTypeMap = {
1739
+ 'address-line1': 'streetAddressLine1',
1740
+ 'address-line2': 'streetAddressLine2',
1741
+ bday: 'birthdate',
1742
+ 'bday-day': 'birthdateDay',
1743
+ 'bday-month': 'birthdateMonth',
1744
+ 'bday-year': 'birthdateYear',
1745
+ 'cc-csc': 'creditCardSecurityCode',
1746
+ 'cc-exp-month': 'creditCardExpirationMonth',
1747
+ 'cc-exp-year': 'creditCardExpirationYear',
1748
+ 'cc-exp': 'creditCardExpiration',
1749
+ 'cc-given-name': 'creditCardGivenName',
1750
+ 'cc-additional-name': 'creditCardMiddleName',
1751
+ 'cc-family-name': 'creditCardFamilyName',
1752
+ 'cc-name': 'creditCardName',
1753
+ 'cc-number': 'creditCardNumber',
1754
+ 'cc-type': 'creditCardType',
1755
+ 'current-password': 'password',
1756
+ country: 'countryName',
1757
+ email: 'emailAddress',
1758
+ name: 'name',
1759
+ 'additional-name': 'middleName',
1760
+ 'family-name': 'familyName',
1761
+ 'given-name': 'givenName',
1762
+ nickname: 'nickname',
1763
+ 'honorific-prefix': 'namePrefix',
1764
+ 'honorific-suffix': 'nameSuffix',
1765
+ 'new-password': 'newPassword',
1766
+ off: 'none',
1767
+ 'one-time-code': 'oneTimeCode',
1768
+ organization: 'organizationName',
1769
+ 'organization-title': 'jobTitle',
1770
+ 'postal-code': 'postalCode',
1771
+ 'street-address': 'fullStreetAddress',
1772
+ tel: 'telephoneNumber',
1773
+ url: 'URL',
1774
+ username: 'username',
1775
+ };
1776
+
1777
+ const ExportedForwardRef: React.AbstractComponent<
1778
+ React.ElementConfig<typeof InternalTextInput>,
1779
+ TextInputInstance,
1780
+ // $FlowFixMe[incompatible-call]
1781
+ > = React.forwardRef(function TextInput(
1782
+ {
1783
+ allowFontScaling = true,
1784
+ rejectResponderTermination = true,
1785
+ underlineColorAndroid = 'transparent',
1786
+ autoComplete,
1787
+ textContentType,
1788
+ readOnly,
1789
+ editable,
1790
+ enterKeyHint,
1791
+ returnKeyType,
1792
+ inputMode,
1793
+ showSoftInputOnFocus,
1794
+ keyboardType,
1795
+ ...restProps
1796
+ },
1797
+ forwardedRef: ReactRefSetter<TextInputInstance>,
1798
+ ) {
1799
+ // $FlowFixMe[underconstrained-implicit-instantiation]
1800
+ let style = flattenStyle(restProps.style);
1801
+
1802
+ if (style?.verticalAlign != null) {
1803
+ // $FlowFixMe[prop-missing]
1804
+ // $FlowFixMe[cannot-write]
1805
+ style.textAlignVertical =
1806
+ // $FlowFixMe[invalid-computed-prop]
1807
+ verticalAlignToTextAlignVerticalMap[style.verticalAlign];
1808
+ // $FlowFixMe[prop-missing]
1809
+ // $FlowFixMe[cannot-write]
1810
+ delete style.verticalAlign;
1811
+ }
1812
+
1813
+ return (
1814
+ <InternalTextInput
1815
+ allowFontScaling={allowFontScaling}
1816
+ rejectResponderTermination={rejectResponderTermination}
1817
+ underlineColorAndroid={underlineColorAndroid}
1818
+ editable={readOnly !== undefined ? !readOnly : editable}
1819
+ returnKeyType={
1820
+ enterKeyHint ? enterKeyHintToReturnTypeMap[enterKeyHint] : returnKeyType
1821
+ }
1822
+ keyboardType={
1823
+ inputMode ? inputModeToKeyboardTypeMap[inputMode] : keyboardType
1824
+ }
1825
+ showSoftInputOnFocus={
1826
+ inputMode == null ? showSoftInputOnFocus : inputMode !== 'none'
1827
+ }
1828
+ autoComplete={
1829
+ Platform.OS === 'android'
1830
+ ? // $FlowFixMe
1831
+ autoCompleteWebToAutoCompleteAndroidMap[autoComplete] ??
1832
+ autoComplete
1833
+ : undefined
1834
+ }
1835
+ textContentType={
1836
+ Platform.OS === 'ios' &&
1837
+ autoComplete &&
1838
+ autoComplete in autoCompleteWebToTextContentTypeMap
1839
+ ? // $FlowFixMe
1840
+ autoCompleteWebToTextContentTypeMap[autoComplete]
1841
+ : textContentType
1842
+ }
1843
+ {...restProps}
1844
+ forwardedRef={forwardedRef}
1845
+ style={style}
1846
+ />
1847
+ );
1848
+ });
1849
+
1850
+ ExportedForwardRef.displayName = 'TextInput';
1851
+
1852
+ /**
1853
+ * Switch to `deprecated-react-native-prop-types` for compatibility with future
1854
+ * releases. This is deprecated and will be removed in the future.
1855
+ */
1856
+ ExportedForwardRef.propTypes =
1857
+ require('deprecated-react-native-prop-types').TextInputPropTypes;
1858
+
1859
+ // $FlowFixMe[prop-missing]
1860
+ ExportedForwardRef.State = {
1861
+ currentlyFocusedInput: TextInputState.currentlyFocusedInput,
1862
+
1863
+ currentlyFocusedField: TextInputState.currentlyFocusedField,
1864
+ focusTextInput: TextInputState.focusTextInput,
1865
+ blurTextInput: TextInputState.blurTextInput,
1866
+ };
1867
+
1868
+ export type TextInputComponentStatics = $ReadOnly<{|
1869
+ State: $ReadOnly<{|
1870
+ currentlyFocusedInput: typeof TextInputState.currentlyFocusedInput,
1871
+ currentlyFocusedField: typeof TextInputState.currentlyFocusedField,
1872
+ focusTextInput: typeof TextInputState.focusTextInput,
1873
+ blurTextInput: typeof TextInputState.blurTextInput,
1874
+ |}>,
1875
+ |}>;
1876
+
1877
+ const styles = StyleSheet.create({
1878
+ multilineInput: {
1879
+ // This default top inset makes RCTMultilineTextInputView seem as close as possible
1880
+ // to single-line RCTSinglelineTextInputView defaults, using the system defaults
1881
+ // of font size 17 and a height of 31 points.
1882
+ paddingTop: 5,
1883
+ },
1884
+ });
1885
+
1886
+ const verticalAlignToTextAlignVerticalMap = {
1887
+ auto: 'auto',
1888
+ top: 'top',
1889
+ bottom: 'bottom',
1890
+ middle: 'center',
1891
+ };
1146
1892
 
1147
- module.exports = TextInput;
1893
+ // $FlowFixMe[unclear-type] Unclear type. Using `any` type is not safe.
1894
+ module.exports = ((ExportedForwardRef: any): TextInputType);