@office-iss/react-native-win32 0.71.2 → 0.71.4

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 (29) hide show
  1. package/CHANGELOG.json +12709 -12667
  2. package/CHANGELOG.md +24 -6
  3. package/Libraries/Alert/Alert.d.ts +1 -0
  4. package/Libraries/Blob/Blob.js +6 -0
  5. package/Libraries/Components/TextInput/TextInput.d.ts +15 -0
  6. package/Libraries/Components/TextInput/TextInput.js +12 -5
  7. package/Libraries/Components/TextInput/TextInput.win32.js +890 -194
  8. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +23 -0
  9. package/Libraries/Components/Touchable/TouchableOpacity.js +2 -3
  10. package/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +2 -2
  11. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +3 -3
  12. package/Libraries/Components/View/ViewAccessibility.d.ts +13 -0
  13. package/Libraries/Components/View/ViewWin32.d.ts +1 -1
  14. package/Libraries/Core/ReactNativeVersion.js +1 -1
  15. package/Libraries/Lists/FlatList.d.ts +6 -6
  16. package/Libraries/Lists/FlatList.js +20 -7
  17. package/Libraries/Lists/VirtualizedList.js +13 -10
  18. package/Libraries/StyleSheet/processAspectRatio.js +12 -2
  19. package/Libraries/TurboModule/TurboModuleRegistry.d.ts +2 -4
  20. package/Libraries/platform-types.d.ts +1 -0
  21. package/overrides.json +7 -7
  22. package/package.json +13 -16
  23. package/src/Libraries/Components/View/ViewWin32.d.ts +1 -1
  24. package/src/Libraries/platform-types.d.ts +1 -0
  25. package/types/index.d.ts +1 -1
  26. package/Libraries/Components/TextInput/TextInput.Types.win32.d.ts +0 -51
  27. package/Libraries/Components/TextInput/TextInput.Types.win32.js +0 -3
  28. package/Libraries/Components/TextInput/TextInput.Types.win32.js.map +0 -1
  29. package/src/Libraries/Components/TextInput/TextInput.Types.win32.ts +0 -68
@@ -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,
@@ -338,6 +365,9 @@ type IOSProps = $ReadOnly<{|
338
365
  /**
339
366
  * Give the keyboard and the system information about the
340
367
  * expected semantic meaning for the content that users enter.
368
+ * `autoComplete` property accomplishes same behavior and is recommended as its supported by both platforms.
369
+ * Avoid using both `autoComplete` and `textContentType`, you can use `Platform.select` for differing platform behaviors.
370
+ * For backwards compatibility, when both set, `textContentType` takes precedence on iOS.
341
371
  * @platform ios
342
372
  */
343
373
  textContentType?: ?TextContentType,
@@ -540,10 +570,37 @@ type AndroidProps = $ReadOnly<{|
540
570
  underlineColorAndroid?: ?ColorValue,
541
571
  |}>;
542
572
 
573
+ // [Windows
574
+
575
+ type SubmitKeyEvent = $ReadOnly<{|
576
+ altKey?: ?boolean,
577
+ ctrlKey?: ?boolean,
578
+ metaKey?: ?boolean,
579
+ shiftKey?: ?boolean,
580
+ code: string,
581
+ |}>;
582
+
583
+ type WindowsProps = $ReadOnly<{|
584
+ /**
585
+ * If `true`, clears the text field synchronously before `onSubmitEditing` is emitted.
586
+ * @platform windows
587
+ */
588
+ clearTextOnSubmit?: ?boolean,
589
+
590
+ /**
591
+ * Configures keys that can be used to submit editing for the TextInput.
592
+ * @platform windows
593
+ */
594
+ submitKeyEvents?: ?$ReadOnlyArray<SubmitKeyEvent>,
595
+ |}>;
596
+
597
+ // Windows]
598
+
543
599
  export type Props = $ReadOnly<{|
544
600
  ...$Diff<ViewProps, $ReadOnly<{|style: ?ViewStyleProp|}>>,
545
601
  ...IOSProps,
546
602
  ...AndroidProps,
603
+ ...WindowsProps, // [Windows]
547
604
 
548
605
  /**
549
606
  * Can tell `TextInput` to automatically capitalize certain characters.
@@ -936,215 +993,854 @@ export type Props = $ReadOnly<{|
936
993
  * unwanted edits without flicker.
937
994
  */
938
995
  value?: ?Stringish,
939
-
940
- text?: ?Stringish, // Win32
941
996
  |}>;
942
997
 
943
- /*
944
- import {
945
- TextInputProps,
946
- NativeMethods,
947
- } from 'react-native';
948
- import {
949
- IBlurEvent,
950
- IChangeEvent,
951
- IFocusEvent,
952
- } from './TextInput.Types.win32';
953
- import React from 'react'
954
-
955
- type RCTTextInputProps = TextInputProps & {
956
- text: string;
957
- };
958
- */
998
+ const emptyFunctionThatReturnsTrue = () => true;
959
999
 
960
- // RCTTextInput is the native component that win32 understands
961
- const RCTTextInput = requireNativeComponent<Props>('RCTTextInput');
1000
+ /**
1001
+ * A foundational component for inputting text into the app via a
1002
+ * keyboard. Props provide configurability for several features, such as
1003
+ * auto-correction, auto-capitalization, placeholder text, and different keyboard
1004
+ * types, such as a numeric keypad.
1005
+ *
1006
+ * The simplest use case is to plop down a `TextInput` and subscribe to the
1007
+ * `onChangeText` events to read the user input. There are also other events,
1008
+ * such as `onSubmitEditing` and `onFocus` that can be subscribed to. A simple
1009
+ * example:
1010
+ *
1011
+ * ```ReactNativeWebPlayer
1012
+ * import React, { Component } from 'react';
1013
+ * import { AppRegistry, TextInput } from 'react-native';
1014
+ *
1015
+ * export default class UselessTextInput extends Component {
1016
+ * constructor(props) {
1017
+ * super(props);
1018
+ * this.state = { text: 'Useless Placeholder' };
1019
+ * }
1020
+ *
1021
+ * render() {
1022
+ * return (
1023
+ * <TextInput
1024
+ * style={{height: 40, borderColor: 'gray', borderWidth: 1}}
1025
+ * onChangeText={(text) => this.setState({text})}
1026
+ * value={this.state.text}
1027
+ * />
1028
+ * );
1029
+ * }
1030
+ * }
1031
+ *
1032
+ * // skip this line if using Create React Native App
1033
+ * AppRegistry.registerComponent('AwesomeProject', () => UselessTextInput);
1034
+ * ```
1035
+ *
1036
+ * Two methods exposed via the native element are .focus() and .blur() that
1037
+ * will focus or blur the TextInput programmatically.
1038
+ *
1039
+ * Note that some props are only available with `multiline={true/false}`.
1040
+ * Additionally, border styles that apply to only one side of the element
1041
+ * (e.g., `borderBottomColor`, `borderLeftWidth`, etc.) will not be applied if
1042
+ * `multiline=false`. To achieve the same effect, you can wrap your `TextInput`
1043
+ * in a `View`:
1044
+ *
1045
+ * ```ReactNativeWebPlayer
1046
+ * import React, { Component } from 'react';
1047
+ * import { AppRegistry, View, TextInput } from 'react-native';
1048
+ *
1049
+ * class UselessTextInput extends Component {
1050
+ * render() {
1051
+ * return (
1052
+ * <TextInput
1053
+ * {...this.props} // Inherit any props passed to it; e.g., multiline, numberOfLines below
1054
+ * editable = {true}
1055
+ * maxLength = {40}
1056
+ * />
1057
+ * );
1058
+ * }
1059
+ * }
1060
+ *
1061
+ * export default class UselessTextInputMultiline extends Component {
1062
+ * constructor(props) {
1063
+ * super(props);
1064
+ * this.state = {
1065
+ * text: 'Useless Multiline Placeholder',
1066
+ * };
1067
+ * }
1068
+ *
1069
+ * // If you type something in the text box that is a color, the background will change to that
1070
+ * // color.
1071
+ * render() {
1072
+ * return (
1073
+ * <View style={{
1074
+ * backgroundColor: this.state.text,
1075
+ * borderBottomColor: '#000000',
1076
+ * borderBottomWidth: 1 }}
1077
+ * >
1078
+ * <UselessTextInput
1079
+ * multiline = {true}
1080
+ * numberOfLines = {4}
1081
+ * onChangeText={(text) => this.setState({text})}
1082
+ * value={this.state.text}
1083
+ * />
1084
+ * </View>
1085
+ * );
1086
+ * }
1087
+ * }
1088
+ *
1089
+ * // skip these lines if using Create React Native App
1090
+ * AppRegistry.registerComponent(
1091
+ * 'AwesomeProject',
1092
+ * () => UselessTextInputMultiline
1093
+ * );
1094
+ * ```
1095
+ *
1096
+ * `TextInput` has by default a border at the bottom of its view. This border
1097
+ * has its padding set by the background image provided by the system, and it
1098
+ * cannot be changed. Solutions to avoid this is to either not set height
1099
+ * explicitly, case in which the system will take care of displaying the border
1100
+ * in the correct position, or to not display the border by setting
1101
+ * `underlineColorAndroid` to transparent.
1102
+ *
1103
+ * Note that on Android performing text selection in input can change
1104
+ * app's activity `windowSoftInputMode` param to `adjustResize`.
1105
+ * This may cause issues with components that have position: 'absolute'
1106
+ * while keyboard is active. To avoid this behavior either specify `windowSoftInputMode`
1107
+ * in AndroidManifest.xml ( https://developer.android.com/guide/topics/manifest/activity-element.html )
1108
+ * or control this param programmatically with native code.
1109
+ *
1110
+ */
1111
+ function InternalTextInput(props: Props): React.Node {
1112
+ const {
1113
+ 'aria-busy': ariaBusy,
1114
+ 'aria-checked': ariaChecked,
1115
+ 'aria-disabled': ariaDisabled,
1116
+ 'aria-expanded': ariaExpanded,
1117
+ 'aria-selected': ariaSelected,
1118
+ accessibilityState,
1119
+ id,
1120
+ tabIndex,
1121
+ ...otherProps
1122
+ } = props;
1123
+
1124
+ const inputRef = useRef<null | React.ElementRef<HostComponent<mixed>>>(null);
1125
+
1126
+ // Android sends a "onTextChanged" event followed by a "onSelectionChanged" event, for
1127
+ // the same "most recent event count".
1128
+ // For controlled selection, that means that immediately after text is updated,
1129
+ // a controlled component will pass in the *previous* selection, even if the controlled
1130
+ // component didn't mean to modify the selection at all.
1131
+ // Therefore, we ignore selections and pass them through until the selection event has
1132
+ // been sent.
1133
+ // Note that this mitigation is NOT needed for Fabric.
1134
+ // discovered when upgrading react-hooks
1135
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1136
+ let selection: ?Selection =
1137
+ props.selection == null
1138
+ ? null
1139
+ : {
1140
+ start: props.selection.start,
1141
+ end: props.selection.end ?? props.selection.start,
1142
+ };
1143
+
1144
+ const [mostRecentEventCount, setMostRecentEventCount] = useState<number>(0);
1145
+
1146
+ const [lastNativeText, setLastNativeText] = useState<?Stringish>(props.value);
1147
+ const [lastNativeSelectionState, setLastNativeSelection] = useState<{|
1148
+ selection: ?Selection,
1149
+ mostRecentEventCount: number,
1150
+ |}>({selection, mostRecentEventCount});
1151
+
1152
+ const lastNativeSelection = lastNativeSelectionState.selection;
1153
+ const lastNativeSelectionEventCount =
1154
+ lastNativeSelectionState.mostRecentEventCount;
1155
+
1156
+ if (lastNativeSelectionEventCount < mostRecentEventCount) {
1157
+ selection = null;
1158
+ }
962
1159
 
963
- // Adding typings on ViewManagers is problematic as available functionality is not known until
964
- // registration at runtime and would require native and js to always be in sync.
965
- const TextInputViewManager = UIManager.getViewManagerConfig('RCTTextInput');
1160
+ let viewCommands;
1161
+ if (AndroidTextInputCommands) {
1162
+ viewCommands = AndroidTextInputCommands;
1163
+ }
1164
+ // [Windows
1165
+ else if (WindowsTextInputCommands) {
1166
+ viewCommands = WindowsTextInputCommands;
1167
+ }
1168
+ // Windows]
1169
+ else {
1170
+ viewCommands =
1171
+ props.multiline === true
1172
+ ? RCTMultilineTextInputNativeCommands
1173
+ : RCTSinglelineTextInputNativeCommands;
1174
+ }
966
1175
 
967
- class TextInput extends React.Component<Props, {}> {
968
- // TODO: Once the native side begins supporting programmatic selection
969
- // this will become important for selection management
970
- // private _lastNativeTextSelection: any;
1176
+ const text =
1177
+ typeof props.value === 'string'
1178
+ ? props.value
1179
+ : typeof props.defaultValue === 'string'
1180
+ ? props.defaultValue
1181
+ : '';
1182
+
1183
+ // This is necessary in case native updates the text and JS decides
1184
+ // that the update should be ignored and we should stick with the value
1185
+ // that we have in JS.
1186
+ useLayoutEffect(() => {
1187
+ const nativeUpdate: {text?: string, selection?: Selection} = {};
1188
+
1189
+ if (lastNativeText !== props.value && typeof props.value === 'string') {
1190
+ nativeUpdate.text = props.value;
1191
+ setLastNativeText(props.value);
1192
+ }
971
1193
 
972
- _rafID: AnimationFrameID;
1194
+ if (
1195
+ selection &&
1196
+ lastNativeSelection &&
1197
+ (lastNativeSelection.start !== selection.start ||
1198
+ lastNativeSelection.end !== selection.end)
1199
+ ) {
1200
+ nativeUpdate.selection = selection;
1201
+ setLastNativeSelection({selection, mostRecentEventCount});
1202
+ }
973
1203
 
974
- _lastNativeText: ?Stringish;
975
- _eventCount: number = 0;
1204
+ if (Object.keys(nativeUpdate).length === 0) {
1205
+ return;
1206
+ }
976
1207
 
977
- constructor(props: Props) {
978
- super(props);
979
- }
1208
+ if (inputRef.current != null) {
1209
+ viewCommands.setTextAndSelection(
1210
+ inputRef.current,
1211
+ mostRecentEventCount,
1212
+ text,
1213
+ selection?.start ?? -1,
1214
+ selection?.end ?? -1,
1215
+ );
1216
+ }
1217
+ }, [
1218
+ mostRecentEventCount,
1219
+ inputRef,
1220
+ props.value,
1221
+ props.defaultValue,
1222
+ lastNativeText,
1223
+ selection,
1224
+ lastNativeSelection,
1225
+ text,
1226
+ viewCommands,
1227
+ ]);
1228
+
1229
+ useLayoutEffect(() => {
1230
+ const inputRefValue = inputRef.current;
1231
+
1232
+ if (inputRefValue != null) {
1233
+ TextInputState.registerInput(inputRefValue);
1234
+
1235
+ return () => {
1236
+ TextInputState.unregisterInput(inputRefValue);
1237
+
1238
+ if (TextInputState.currentlyFocusedInput() === inputRefValue) {
1239
+ nullthrows(inputRefValue).blur();
1240
+ }
1241
+ };
1242
+ }
1243
+ }, [inputRef]);
1244
+
1245
+ const setLocalRef = useCallback(
1246
+ (instance: TextInputInstance | null) => {
1247
+ inputRef.current = instance;
1248
+
1249
+ /*
1250
+ Hi reader from the future. I'm sorry for this.
1251
+
1252
+ This is a hack. Ideally we would forwardRef to the underlying
1253
+ host component. However, since TextInput has it's own methods that can be
1254
+ called as well, if we used the standard forwardRef then these
1255
+ methods wouldn't be accessible and thus be a breaking change.
1256
+
1257
+ We have a couple of options of how to handle this:
1258
+ - Return a new ref with everything we methods from both. This is problematic
1259
+ because we need React to also know it is a host component which requires
1260
+ internals of the class implementation of the ref.
1261
+ - Break the API and have some other way to call one set of the methods or
1262
+ the other. This is our long term approach as we want to eventually
1263
+ get the methods on host components off the ref. So instead of calling
1264
+ ref.measure() you might call ReactNative.measure(ref). This would hopefully
1265
+ let the ref for TextInput then have the methods like `.clear`. Or we do it
1266
+ the other way and make it TextInput.clear(textInputRef) which would be fine
1267
+ too. Either way though is a breaking change that is longer term.
1268
+ - Mutate this ref. :( Gross, but accomplishes what we need in the meantime
1269
+ before we can get to the long term breaking change.
1270
+ */
1271
+ if (instance != null) {
1272
+ // $FlowFixMe[incompatible-use] - See the explanation above.
1273
+ Object.assign(instance, {
1274
+ clear(): void {
1275
+ if (inputRef.current != null) {
1276
+ viewCommands.setTextAndSelection(
1277
+ inputRef.current,
1278
+ mostRecentEventCount,
1279
+ '',
1280
+ 0,
1281
+ 0,
1282
+ );
1283
+ }
1284
+ },
1285
+ // TODO: Fix this returning true on null === null, when no input is focused
1286
+ isFocused(): boolean {
1287
+ return TextInputState.currentlyFocusedInput() === inputRef.current;
1288
+ },
1289
+ getNativeRef(): ?React.ElementRef<HostComponent<mixed>> {
1290
+ return inputRef.current;
1291
+ },
1292
+ setSelection(start: number, end: number): void {
1293
+ if (inputRef.current != null) {
1294
+ viewCommands.setTextAndSelection(
1295
+ inputRef.current,
1296
+ mostRecentEventCount,
1297
+ null,
1298
+ start,
1299
+ end,
1300
+ );
1301
+ }
1302
+ },
1303
+ });
1304
+ }
1305
+ },
1306
+ [mostRecentEventCount, viewCommands],
1307
+ );
1308
+
1309
+ const ref = useMergeRefs<TextInputInstance | null>(
1310
+ setLocalRef,
1311
+ props.forwardedRef,
1312
+ );
1313
+
1314
+ const _onChange = (event: ChangeEvent) => {
1315
+ const currentText = event.nativeEvent.text;
1316
+ props.onChange && props.onChange(event);
1317
+ props.onChangeText && props.onChangeText(currentText);
1318
+
1319
+ if (inputRef.current == null) {
1320
+ // calling `props.onChange` or `props.onChangeText`
1321
+ // may clean up the input itself. Exits here.
1322
+ return;
1323
+ }
980
1324
 
981
- /**
982
- * On mount TextInput needs to register itself with TextInputState
983
- * and conditionally request an animation frame for focus.
984
- */
985
- componentDidMount() {
986
- this._lastNativeText = this.props.value;
1325
+ setLastNativeText(currentText);
1326
+ // This must happen last, after we call setLastNativeText.
1327
+ // Different ordering can cause bugs when editing AndroidTextInputs
1328
+ // with multiple Fragments.
1329
+ // We must update this so that controlled input updates work.
1330
+ setMostRecentEventCount(event.nativeEvent.eventCount);
1331
+ };
987
1332
 
988
- // $FlowFixMe - // Win32
989
- TextInputState.registerInput(this);
1333
+ const _onChangeSync = (event: ChangeEvent) => {
1334
+ const currentText = event.nativeEvent.text;
1335
+ props.unstable_onChangeSync && props.unstable_onChangeSync(event);
1336
+ props.unstable_onChangeTextSync &&
1337
+ props.unstable_onChangeTextSync(currentText);
990
1338
 
991
- if (this.props.autoFocus === true) {
992
- this._rafID = requestAnimationFrame(this.focus);
1339
+ if (inputRef.current == null) {
1340
+ // calling `props.onChange` or `props.onChangeText`
1341
+ // may clean up the input itself. Exits here.
1342
+ return;
993
1343
  }
994
- }
995
1344
 
996
- /**
997
- * This is an unfortunate consequence of having controlled TextInputs.
998
- * Tree diffing reconciliation will not always send down text values
999
- * This sets text explicitly.
1000
- */
1001
- componentDidUpdate() {
1002
- if (this._lastNativeText !== this._getText()) {
1003
- this._getText() && this.setNativeText(this._getText());
1004
- }
1345
+ setLastNativeText(currentText);
1346
+ // This must happen last, after we call setLastNativeText.
1347
+ // Different ordering can cause bugs when editing AndroidTextInputs
1348
+ // with multiple Fragments.
1349
+ // We must update this so that controlled input updates work.
1350
+ setMostRecentEventCount(event.nativeEvent.eventCount);
1351
+ };
1005
1352
 
1006
- return;
1007
- }
1353
+ const _onSelectionChange = (event: SelectionChangeEvent) => {
1354
+ props.onSelectionChange && props.onSelectionChange(event);
1008
1355
 
1009
- /**
1010
- * Pre-unmoun the TextInput should blur, unregister and clean up
1011
- * the animation frame for focus (edge cases)
1012
- */
1013
- componentWillUnmount() {
1014
- // blur
1015
- if (this.isFocused()) {
1016
- this.blur();
1356
+ if (inputRef.current == null) {
1357
+ // calling `props.onSelectionChange`
1358
+ // may clean up the input itself. Exits here.
1359
+ return;
1017
1360
  }
1018
1361
 
1019
- // unregister
1020
- // $FlowFixMe - // Win32
1021
- TextInputState.unregisterInput(this);
1362
+ setLastNativeSelection({
1363
+ selection: event.nativeEvent.selection,
1364
+ mostRecentEventCount,
1365
+ });
1366
+ };
1022
1367
 
1023
- // cancel animationFrame
1024
- if (this._rafID !== null) {
1025
- cancelAnimationFrame(this._rafID);
1368
+ const _onFocus = (event: FocusEvent) => {
1369
+ TextInputState.focusInput(inputRef.current);
1370
+ if (props.onFocus) {
1371
+ props.onFocus(event);
1026
1372
  }
1027
- if (this._rafID) {
1028
- return;
1373
+ };
1374
+
1375
+ const _onBlur = (event: BlurEvent) => {
1376
+ TextInputState.blurInput(inputRef.current);
1377
+ if (props.onBlur) {
1378
+ props.onBlur(event);
1029
1379
  }
1030
- return;
1031
- }
1380
+ };
1032
1381
 
1033
- render(): React.Node {
1034
- let {allowFontScaling, ...otherProps} = this.props;
1035
-
1036
- allowFontScaling =
1037
- this.props.allowFontScaling === null ||
1038
- this.props.allowFontScaling === undefined
1039
- ? true
1040
- : this.props.allowFontScaling;
1041
-
1042
- return (
1043
- <TextAncestor.Provider value={true}>
1044
- <RCTTextInput
1045
- {...otherProps}
1046
- allowFontScaling={allowFontScaling}
1047
- text={this._getText()}
1048
- onFocus={this._onFocus}
1049
- onBlur={this._onBlur}
1050
- onChange={this._onChange}
1051
- />
1052
- </TextAncestor.Provider>
1053
- );
1054
- }
1382
+ const _onScroll = (event: ScrollEvent) => {
1383
+ props.onScroll && props.onScroll(event);
1384
+ };
1055
1385
 
1056
- /**
1057
- * Returns true if the TextInput is focused
1058
- */
1059
- isFocused(): boolean {
1060
- return TextInputState.currentlyFocusedInput() === this;
1386
+ let textInput = null;
1387
+
1388
+ const multiline = props.multiline ?? false;
1389
+
1390
+ let submitBehavior: SubmitBehavior;
1391
+ if (props.submitBehavior != null) {
1392
+ // `submitBehavior` is set explicitly
1393
+ if (!multiline && props.submitBehavior === 'newline') {
1394
+ // For single line text inputs, `'newline'` is not a valid option
1395
+ submitBehavior = 'blurAndSubmit';
1396
+ } else {
1397
+ submitBehavior = props.submitBehavior;
1398
+ }
1399
+ } else if (multiline) {
1400
+ if (props.blurOnSubmit === true) {
1401
+ submitBehavior = 'blurAndSubmit';
1402
+ } else {
1403
+ submitBehavior = 'newline';
1404
+ }
1405
+ } else {
1406
+ // Single line
1407
+ if (props.blurOnSubmit !== false) {
1408
+ submitBehavior = 'blurAndSubmit';
1409
+ } else {
1410
+ submitBehavior = 'submit';
1411
+ }
1061
1412
  }
1062
1413
 
1063
- /**
1064
- * Focuses the TextInput
1065
- */
1066
- focus: () => void = (): void => {
1067
- // $FlowFixMe - // Win32
1068
- TextInputState.setFocusedTextInput(this);
1069
- UIManager.dispatchViewManagerCommand(
1070
- findNodeHandle(this),
1071
- TextInputViewManager.Commands.focus,
1072
- null,
1073
- );
1074
- };
1414
+ const accessible = props.accessible !== false;
1415
+ const focusable = props.focusable !== false;
1416
+
1417
+ const config = React.useMemo(
1418
+ () => ({
1419
+ onPress: (event: PressEvent) => {
1420
+ if (props.editable !== false) {
1421
+ if (inputRef.current != null) {
1422
+ inputRef.current.focus();
1423
+ }
1424
+ }
1425
+ },
1426
+ onPressIn: props.onPressIn,
1427
+ onPressOut: props.onPressOut,
1428
+ cancelable:
1429
+ Platform.OS === 'ios' ? !props.rejectResponderTermination : null,
1430
+ }),
1431
+ [
1432
+ props.editable,
1433
+ props.onPressIn,
1434
+ props.onPressOut,
1435
+ props.rejectResponderTermination,
1436
+ ],
1437
+ );
1438
+
1439
+ // Hide caret during test runs due to a flashing caret
1440
+ // makes screenshot tests flakey
1441
+ let caretHidden = props.caretHidden;
1442
+ if (Platform.isTesting) {
1443
+ caretHidden = true;
1444
+ }
1075
1445
 
1076
- /**
1077
- * Blurs the TextInput
1078
- */
1079
- blur: () => void = (): void => {
1080
- // $FlowFixMe - // Win32
1081
- TextInputState.blurTextInput(this);
1082
- UIManager.dispatchViewManagerCommand(
1083
- findNodeHandle(this),
1084
- TextInputViewManager.Commands.blur,
1085
- null,
1086
- );
1446
+ // TextInput handles onBlur and onFocus events
1447
+ // so omitting onBlur and onFocus pressability handlers here.
1448
+ const {onBlur, onFocus, ...eventHandlers} = usePressability(config) || {};
1449
+ const eventPhase = Object.freeze({Capturing: 1, Bubbling: 3});
1450
+ const _keyDown = (event: KeyEvent) => {
1451
+ if (props.keyDownEvents && event.isPropagationStopped() !== true) {
1452
+ // $FlowFixMe - keyDownEvents was already checked to not be undefined
1453
+ for (const el of props.keyDownEvents) {
1454
+ if (
1455
+ event.nativeEvent.code == el.code &&
1456
+ el.handledEventPhase == eventPhase.Bubbling
1457
+ ) {
1458
+ event.stopPropagation();
1459
+ }
1460
+ }
1461
+ }
1462
+ props.onKeyDown && props.onKeyDown(event);
1087
1463
  };
1088
1464
 
1089
- /**
1090
- * Use clear for programmatic clearing of the text
1091
- */
1092
- clear: () => void = (): void => {
1093
- this.setNativeText('');
1465
+ const _keyUp = (event: KeyEvent) => {
1466
+ if (props.keyUpEvents && event.isPropagationStopped() !== true) {
1467
+ // $FlowFixMe - keyDownEvents was already checked to not be undefined
1468
+ for (const el of props.keyUpEvents) {
1469
+ if (event.nativeEvent.code == el.code && el.handledEventPhase == 3) {
1470
+ event.stopPropagation();
1471
+ }
1472
+ }
1473
+ }
1474
+ props.onKeyUp && props.onKeyUp(event);
1094
1475
  };
1095
1476
 
1096
- setEventCount: () => void = (): void => {
1097
- UIManager.dispatchViewManagerCommand(
1098
- findNodeHandle(this),
1099
- TextInputViewManager.Commands.setEventCount,
1100
- [this._eventCount],
1101
- );
1477
+ const _keyDownCapture = (event: KeyEvent) => {
1478
+ if (props.keyDownEvents && event.isPropagationStopped() !== true) {
1479
+ // $FlowFixMe - keyDownEvents was already checked to not be undefined
1480
+ for (const el of props.keyDownEvents) {
1481
+ if (event.nativeEvent.code == el.code && el.handledEventPhase == 1) {
1482
+ event.stopPropagation();
1483
+ }
1484
+ }
1485
+ }
1486
+ props.onKeyDownCapture && props.onKeyDownCapture(event);
1102
1487
  };
1103
1488
 
1104
- setNativeText: (val: ?Stringish) => void = (val: ?Stringish): void => {
1105
- if (this._lastNativeText !== val) {
1106
- UIManager.dispatchViewManagerCommand(
1107
- findNodeHandle(this),
1108
- TextInputViewManager.Commands.setNativeText,
1109
- [val],
1110
- );
1489
+ const _keyUpCapture = (event: KeyEvent) => {
1490
+ if (props.keyUpEvents && event.isPropagationStopped() !== true) {
1491
+ // $FlowFixMe - keyDownEvents was already checked to not be undefined
1492
+ for (const el of props.keyUpEvents) {
1493
+ if (event.nativeEvent.code == el.code && el.handledEventPhase == 1) {
1494
+ event.stopPropagation();
1495
+ }
1496
+ }
1111
1497
  }
1498
+ props.onKeyUpCapture && props.onKeyUpCapture(event);
1112
1499
  };
1113
1500
 
1114
- _getText = (): string | null => {
1115
- if (this.props.value != null && this.props.value != undefined) {
1116
- return this.props.value;
1117
- }
1118
- if (
1119
- this.props.defaultValue != null &&
1120
- this.props.defaultValue != undefined
1121
- ) {
1122
- return this.props.defaultValue;
1501
+ let _accessibilityState;
1502
+ if (
1503
+ accessibilityState != null ||
1504
+ ariaBusy != null ||
1505
+ ariaChecked != null ||
1506
+ ariaDisabled != null ||
1507
+ ariaExpanded != null ||
1508
+ ariaSelected != null
1509
+ ) {
1510
+ _accessibilityState = {
1511
+ busy: ariaBusy ?? accessibilityState?.busy,
1512
+ checked: ariaChecked ?? accessibilityState?.checked,
1513
+ disabled: ariaDisabled ?? accessibilityState?.disabled,
1514
+ expanded: ariaExpanded ?? accessibilityState?.expanded,
1515
+ selected: ariaSelected ?? accessibilityState?.selected,
1516
+ };
1517
+ }
1518
+
1519
+ // $FlowFixMe[underconstrained-implicit-instantiation]
1520
+ let style = flattenStyle(props.style);
1521
+
1522
+ if (Platform.OS === 'ios') {
1523
+ const RCTTextInputView =
1524
+ props.multiline === true
1525
+ ? RCTMultilineTextInputView
1526
+ : RCTSinglelineTextInputView;
1527
+
1528
+ style = props.multiline === true ? [styles.multilineInput, style] : style;
1529
+
1530
+ const useOnChangeSync =
1531
+ (props.unstable_onChangeSync || props.unstable_onChangeTextSync) &&
1532
+ !(props.onChange || props.onChangeText);
1533
+
1534
+ textInput = (
1535
+ <RCTTextInputView
1536
+ // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1537
+ ref={ref}
1538
+ {...otherProps}
1539
+ {...eventHandlers}
1540
+ accessibilityState={_accessibilityState}
1541
+ accessible={accessible}
1542
+ submitBehavior={submitBehavior}
1543
+ caretHidden={caretHidden}
1544
+ dataDetectorTypes={props.dataDetectorTypes}
1545
+ focusable={tabIndex !== undefined ? !tabIndex : focusable}
1546
+ mostRecentEventCount={mostRecentEventCount}
1547
+ nativeID={id ?? props.nativeID}
1548
+ onBlur={_onBlur}
1549
+ onKeyPressSync={props.unstable_onKeyPressSync}
1550
+ onChange={_onChange}
1551
+ onChangeSync={useOnChangeSync === true ? _onChangeSync : null}
1552
+ onContentSizeChange={props.onContentSizeChange}
1553
+ onFocus={_onFocus}
1554
+ onScroll={_onScroll}
1555
+ onSelectionChange={_onSelectionChange}
1556
+ onSelectionChangeShouldSetResponder={emptyFunctionThatReturnsTrue}
1557
+ selection={selection}
1558
+ style={style}
1559
+ text={text}
1560
+ />
1561
+ );
1562
+ } else if (Platform.OS === 'android') {
1563
+ const autoCapitalize = props.autoCapitalize || 'sentences';
1564
+ const _accessibilityLabelledBy =
1565
+ props?.['aria-labelledby'] ?? props?.accessibilityLabelledBy;
1566
+ const placeholder = props.placeholder ?? '';
1567
+ let children = props.children;
1568
+ const childCount = React.Children.count(children);
1569
+ invariant(
1570
+ !(props.value != null && childCount),
1571
+ 'Cannot specify both value and children.',
1572
+ );
1573
+ if (childCount > 1) {
1574
+ children = <Text>{children}</Text>;
1123
1575
  }
1124
- return null;
1125
- };
1126
1576
 
1127
- _onChange = (e: ChangeEvent): void => {
1128
- const text = e.nativeEvent.text;
1129
- this._eventCount = e.nativeEvent.eventCount;
1130
- this.setEventCount();
1577
+ textInput = (
1578
+ /* $FlowFixMe[prop-missing] the types for AndroidTextInput don't match up
1579
+ * exactly with the props for TextInput. This will need to get fixed */
1580
+ /* $FlowFixMe[incompatible-type] the types for AndroidTextInput don't
1581
+ * match up exactly with the props for TextInput. This will need to get
1582
+ * fixed */
1583
+ /* $FlowFixMe[incompatible-type-arg] the types for AndroidTextInput don't
1584
+ * match up exactly with the props for TextInput. This will need to get
1585
+ * fixed */
1586
+ <AndroidTextInput
1587
+ // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1588
+ ref={ref}
1589
+ {...otherProps}
1590
+ {...eventHandlers}
1591
+ accessibilityState={_accessibilityState}
1592
+ accessibilityLabelledBy={_accessibilityLabelledBy}
1593
+ accessible={accessible}
1594
+ autoCapitalize={autoCapitalize}
1595
+ submitBehavior={submitBehavior}
1596
+ caretHidden={caretHidden}
1597
+ children={children}
1598
+ disableFullscreenUI={props.disableFullscreenUI}
1599
+ focusable={tabIndex !== undefined ? !tabIndex : focusable}
1600
+ mostRecentEventCount={mostRecentEventCount}
1601
+ nativeID={id ?? props.nativeID}
1602
+ numberOfLines={props.rows ?? props.numberOfLines}
1603
+ onBlur={_onBlur}
1604
+ onChange={_onChange}
1605
+ onFocus={_onFocus}
1606
+ /* $FlowFixMe[prop-missing] the types for AndroidTextInput don't match
1607
+ * up exactly with the props for TextInput. This will need to get fixed
1608
+ */
1609
+ /* $FlowFixMe[incompatible-type-arg] the types for AndroidTextInput
1610
+ * don't match up exactly with the props for TextInput. This will need
1611
+ * to get fixed */
1612
+ onScroll={_onScroll}
1613
+ onSelectionChange={_onSelectionChange}
1614
+ placeholder={placeholder}
1615
+ selection={selection}
1616
+ style={style}
1617
+ text={text}
1618
+ textBreakStrategy={props.textBreakStrategy}
1619
+ />
1620
+ );
1621
+ } // [Windows
1622
+ else if (Platform.OS === 'win32') {
1623
+ textInput = (
1624
+ <WindowsTextInput
1625
+ // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1626
+ ref={ref}
1627
+ {...props}
1628
+ accessible={accessible}
1629
+ focusable={focusable}
1630
+ dataDetectorTypes={props.dataDetectorTypes}
1631
+ mostRecentEventCount={mostRecentEventCount}
1632
+ onBlur={_onBlur}
1633
+ onChange={_onChange}
1634
+ onContentSizeChange={props.onContentSizeChange}
1635
+ onFocus={_onFocus}
1636
+ onScroll={_onScroll}
1637
+ onSelectionChange={_onSelectionChange}
1638
+ onSelectionChangeShouldSetResponder={emptyFunctionThatReturnsTrue}
1639
+ selection={selection}
1640
+ text={text}
1641
+ onKeyDown={_keyDown}
1642
+ onKeyDownCapture={_keyDownCapture}
1643
+ onKeyUp={_keyUp}
1644
+ onKeyUpCapture={_keyUpCapture}
1645
+ />
1646
+ );
1647
+ } // Windows]
1648
+ return (
1649
+ <TextAncestor.Provider value={true}>{textInput}</TextAncestor.Provider>
1650
+ );
1651
+ }
1131
1652
 
1132
- this.props.onChange && this.props.onChange(e);
1133
- this.props.onChangeText && this.props.onChangeText(text);
1134
- this._lastNativeText = text;
1653
+ const enterKeyHintToReturnTypeMap = {
1654
+ enter: 'default',
1655
+ done: 'done',
1656
+ go: 'go',
1657
+ next: 'next',
1658
+ previous: 'previous',
1659
+ search: 'search',
1660
+ send: 'send',
1661
+ };
1135
1662
 
1136
- this.forceUpdate();
1137
- return;
1138
- };
1663
+ const inputModeToKeyboardTypeMap = {
1664
+ none: 'default',
1665
+ text: 'default',
1666
+ decimal: 'decimal-pad',
1667
+ numeric: 'number-pad',
1668
+ tel: 'phone-pad',
1669
+ search: Platform.OS === 'ios' ? 'web-search' : 'default',
1670
+ email: 'email-address',
1671
+ url: 'url',
1672
+ };
1139
1673
 
1140
- _onFocus = (e: FocusEvent): void => {
1141
- this.focus();
1142
- this.props.onFocus && this.props.onFocus(e);
1143
- };
1674
+ // Map HTML autocomplete values to Android autoComplete values
1675
+ const autoCompleteWebToAutoCompleteAndroidMap = {
1676
+ 'address-line1': 'postal-address-region',
1677
+ 'address-line2': 'postal-address-locality',
1678
+ bday: 'birthdate-full',
1679
+ 'bday-day': 'birthdate-day',
1680
+ 'bday-month': 'birthdate-month',
1681
+ 'bday-year': 'birthdate-year',
1682
+ 'cc-csc': 'cc-csc',
1683
+ 'cc-exp': 'cc-exp',
1684
+ 'cc-exp-month': 'cc-exp-month',
1685
+ 'cc-exp-year': 'cc-exp-year',
1686
+ 'cc-number': 'cc-number',
1687
+ country: 'postal-address-country',
1688
+ 'current-password': 'password',
1689
+ email: 'email',
1690
+ 'honorific-prefix': 'name-prefix',
1691
+ 'honorific-suffix': 'name-suffix',
1692
+ name: 'name',
1693
+ 'additional-name': 'name-middle',
1694
+ 'family-name': 'name-family',
1695
+ 'given-name': 'name-given',
1696
+ 'new-password': 'password-new',
1697
+ off: 'off',
1698
+ 'one-time-code': 'sms-otp',
1699
+ 'postal-code': 'postal-code',
1700
+ sex: 'gender',
1701
+ 'street-address': 'street-address',
1702
+ tel: 'tel',
1703
+ 'tel-country-code': 'tel-country-code',
1704
+ 'tel-national': 'tel-national',
1705
+ username: 'username',
1706
+ };
1144
1707
 
1145
- _onBlur = (e: BlurEvent): void => {
1146
- this.props.onBlur && this.props.onBlur(e);
1147
- };
1148
- }
1708
+ // Map HTML autocomplete values to iOS textContentType values
1709
+ const autoCompleteWebToTextContentTypeMap = {
1710
+ 'address-line1': 'streetAddressLine1',
1711
+ 'address-line2': 'streetAddressLine2',
1712
+ 'cc-number': 'creditCardNumber',
1713
+ 'current-password': 'password',
1714
+ country: 'countryName',
1715
+ email: 'emailAddress',
1716
+ name: 'name',
1717
+ 'additional-name': 'middleName',
1718
+ 'family-name': 'familyName',
1719
+ 'given-name': 'givenName',
1720
+ nickname: 'nickname',
1721
+ 'honorific-prefix': 'namePrefix',
1722
+ 'honorific-suffix': 'nameSuffix',
1723
+ 'new-password': 'newPassword',
1724
+ off: 'none',
1725
+ 'one-time-code': 'oneTimeCode',
1726
+ organization: 'organizationName',
1727
+ 'organization-title': 'jobTitle',
1728
+ 'postal-code': 'postalCode',
1729
+ 'street-address': 'fullStreetAddress',
1730
+ tel: 'telephoneNumber',
1731
+ url: 'URL',
1732
+ username: 'username',
1733
+ };
1734
+
1735
+ const ExportedForwardRef: React.AbstractComponent<
1736
+ React.ElementConfig<typeof InternalTextInput>,
1737
+ TextInputInstance,
1738
+ > = React.forwardRef(function TextInput(
1739
+ {
1740
+ allowFontScaling = true,
1741
+ rejectResponderTermination = true,
1742
+ underlineColorAndroid = 'transparent',
1743
+ autoComplete,
1744
+ textContentType,
1745
+ readOnly,
1746
+ editable,
1747
+ enterKeyHint,
1748
+ returnKeyType,
1749
+ inputMode,
1750
+ showSoftInputOnFocus,
1751
+ keyboardType,
1752
+ ...restProps
1753
+ },
1754
+ forwardedRef: ReactRefSetter<TextInputInstance>,
1755
+ ) {
1756
+ // $FlowFixMe[underconstrained-implicit-instantiation]
1757
+ let style = flattenStyle(restProps.style);
1758
+
1759
+ if (style?.verticalAlign != null) {
1760
+ style.textAlignVertical =
1761
+ verticalAlignToTextAlignVerticalMap[style.verticalAlign];
1762
+ delete style.verticalAlign;
1763
+ }
1764
+
1765
+ return (
1766
+ <InternalTextInput
1767
+ allowFontScaling={allowFontScaling}
1768
+ rejectResponderTermination={rejectResponderTermination}
1769
+ underlineColorAndroid={underlineColorAndroid}
1770
+ editable={readOnly !== undefined ? !readOnly : editable}
1771
+ returnKeyType={
1772
+ enterKeyHint ? enterKeyHintToReturnTypeMap[enterKeyHint] : returnKeyType
1773
+ }
1774
+ keyboardType={
1775
+ inputMode ? inputModeToKeyboardTypeMap[inputMode] : keyboardType
1776
+ }
1777
+ showSoftInputOnFocus={
1778
+ inputMode == null ? showSoftInputOnFocus : inputMode !== 'none'
1779
+ }
1780
+ autoComplete={
1781
+ Platform.OS === 'android'
1782
+ ? // $FlowFixMe
1783
+ autoCompleteWebToAutoCompleteAndroidMap[autoComplete] ??
1784
+ autoComplete
1785
+ : undefined
1786
+ }
1787
+ textContentType={
1788
+ Platform.OS === 'ios' &&
1789
+ autoComplete &&
1790
+ autoComplete in autoCompleteWebToTextContentTypeMap
1791
+ ? // $FlowFixMe
1792
+ autoCompleteWebToTextContentTypeMap[autoComplete]
1793
+ : textContentType
1794
+ }
1795
+ {...restProps}
1796
+ forwardedRef={forwardedRef}
1797
+ style={style}
1798
+ />
1799
+ );
1800
+ });
1801
+
1802
+ ExportedForwardRef.displayName = 'TextInput';
1803
+
1804
+ /**
1805
+ * Switch to `deprecated-react-native-prop-types` for compatibility with future
1806
+ * releases. This is deprecated and will be removed in the future.
1807
+ */
1808
+ ExportedForwardRef.propTypes =
1809
+ require('deprecated-react-native-prop-types').TextInputPropTypes;
1810
+
1811
+ // $FlowFixMe[prop-missing]
1812
+ ExportedForwardRef.State = {
1813
+ currentlyFocusedInput: TextInputState.currentlyFocusedInput,
1814
+
1815
+ currentlyFocusedField: TextInputState.currentlyFocusedField,
1816
+ focusTextInput: TextInputState.focusTextInput,
1817
+ blurTextInput: TextInputState.blurTextInput,
1818
+ };
1819
+
1820
+ export type TextInputComponentStatics = $ReadOnly<{|
1821
+ State: $ReadOnly<{|
1822
+ currentlyFocusedInput: typeof TextInputState.currentlyFocusedInput,
1823
+ currentlyFocusedField: typeof TextInputState.currentlyFocusedField,
1824
+ focusTextInput: typeof TextInputState.focusTextInput,
1825
+ blurTextInput: typeof TextInputState.blurTextInput,
1826
+ |}>,
1827
+ |}>;
1828
+
1829
+ const styles = StyleSheet.create({
1830
+ multilineInput: {
1831
+ // This default top inset makes RCTMultilineTextInputView seem as close as possible
1832
+ // to single-line RCTSinglelineTextInputView defaults, using the system defaults
1833
+ // of font size 17 and a height of 31 points.
1834
+ paddingTop: 5,
1835
+ },
1836
+ });
1837
+
1838
+ const verticalAlignToTextAlignVerticalMap = {
1839
+ auto: 'auto',
1840
+ top: 'top',
1841
+ bottom: 'bottom',
1842
+ middle: 'center',
1843
+ };
1149
1844
 
1150
- module.exports = TextInput;
1845
+ // $FlowFixMe[unclear-type] Unclear type. Using `any` type is not safe.
1846
+ module.exports = ((ExportedForwardRef: any): TextInputType);