@onekeyfe/react-native-text-input 0.2.4 → 0.2.7

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 (54) hide show
  1. package/android/generated/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/OneKeyTextInputManagerDelegate.java +3 -2
  2. package/android/generated/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/OneKeyTextInputManagerInterface.java +2 -1
  3. package/android/generated/android/app/build/generated/source/codegen/jni/CMakeLists.txt +4 -17
  4. package/android/src/newarch/TextInputViewManagerSpec.kt +4 -4
  5. package/ios/generated/build/generated/ios/RNTextInputViewSpec/RNTextInputViewSpec.h +3 -0
  6. package/lib/commonjs/AndroidTextInputNativeComponent.js +152 -0
  7. package/lib/commonjs/AndroidTextInputNativeComponent.js.map +1 -0
  8. package/lib/commonjs/Input.js +140 -273
  9. package/lib/commonjs/Input.js.map +1 -1
  10. package/lib/commonjs/TextInputViewNativeComponent.ts +9 -0
  11. package/lib/commonjs/index.js +3 -3
  12. package/lib/typescript/src/TextInputViewNativeComponent.d.ts.map +1 -0
  13. package/lib/typescript/src/enum.d.ts.map +1 -0
  14. package/lib/typescript/src/index.d.ts.map +1 -0
  15. package/lib/typescript/src/type.d.ts.map +1 -0
  16. package/package.json +9 -19
  17. package/src/AndroidTextInputNativeComponent.js +767 -0
  18. package/src/Input.js +418 -247
  19. package/ios/generated/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec-generated.mm +0 -1881
  20. package/ios/generated/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec.h +0 -2321
  21. package/ios/generated/build/generated/ios/FBReactNativeSpecJSI-generated.cpp +0 -2785
  22. package/ios/generated/build/generated/ios/FBReactNativeSpecJSI.h +0 -7511
  23. package/ios/generated/build/generated/ios/RCTModulesConformingToProtocolsProvider.h +0 -18
  24. package/ios/generated/build/generated/ios/RCTModulesConformingToProtocolsProvider.mm +0 -33
  25. package/lib/commonjs/TextInputViewNativeComponent.js +0 -10
  26. package/lib/commonjs/TextInputViewNativeComponent.js.map +0 -1
  27. package/lib/module/Input.js +0 -667
  28. package/lib/module/Input.js.map +0 -1
  29. package/lib/module/TextInputViewNativeComponent.js +0 -5
  30. package/lib/module/TextInputViewNativeComponent.js.map +0 -1
  31. package/lib/module/enum.js +0 -7
  32. package/lib/module/enum.js.map +0 -1
  33. package/lib/module/index.js +0 -9
  34. package/lib/module/index.js.map +0 -1
  35. package/lib/module/type.js +0 -4
  36. package/lib/module/type.js.map +0 -1
  37. package/lib/typescript/commonjs/src/TextInputViewNativeComponent.d.ts.map +0 -1
  38. package/lib/typescript/commonjs/src/enum.d.ts.map +0 -1
  39. package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
  40. package/lib/typescript/commonjs/src/type.d.ts.map +0 -1
  41. package/lib/typescript/module/package.json +0 -1
  42. package/lib/typescript/module/src/TextInputViewNativeComponent.d.ts +0 -8
  43. package/lib/typescript/module/src/TextInputViewNativeComponent.d.ts.map +0 -1
  44. package/lib/typescript/module/src/enum.d.ts +0 -4
  45. package/lib/typescript/module/src/enum.d.ts.map +0 -1
  46. package/lib/typescript/module/src/index.d.ts +0 -8
  47. package/lib/typescript/module/src/index.d.ts.map +0 -1
  48. package/lib/typescript/module/src/type.d.ts +0 -16
  49. package/lib/typescript/module/src/type.d.ts.map +0 -1
  50. /package/lib/{typescript/commonjs → commonjs}/package.json +0 -0
  51. /package/lib/typescript/{commonjs/src → src}/TextInputViewNativeComponent.d.ts +0 -0
  52. /package/lib/typescript/{commonjs/src → src}/enum.d.ts +0 -0
  53. /package/lib/typescript/{commonjs/src → src}/index.d.ts +0 -0
  54. /package/lib/typescript/{commonjs/src → src}/type.d.ts +0 -0
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var _usePressability = _interopRequireDefault(require("react-native/Libraries/Pressability/usePressability"));
4
- var _flattenStyle = _interopRequireDefault(require("react-native/Libraries/StyleSheet/flattenStyle"));
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var ReactNativeFeatureFlags = _interopRequireWildcard(require("react-native/src/private/featureflags/ReactNativeFeatureFlags.js"));
8
+ var _usePressability = _interopRequireDefault(require("react-native/Libraries/Pressability/usePressability.js"));
9
+ var _flattenStyle = _interopRequireDefault(require("react-native/Libraries/StyleSheet/flattenStyle.js"));
5
10
  var _StyleSheet = _interopRequireDefault(require("react-native/Libraries/StyleSheet/StyleSheet"));
6
11
  var _Text = _interopRequireDefault(require("react-native/Libraries/Text/Text"));
7
12
  var _TextAncestor = _interopRequireDefault(require("react-native/Libraries/Text/TextAncestor"));
@@ -13,21 +18,9 @@ var _nullthrows = _interopRequireDefault(require("nullthrows"));
13
18
  var _react = _interopRequireWildcard(require("react"));
14
19
  var React = _react;
15
20
  var _jsxRuntime = require("react/jsx-runtime");
21
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
22
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
23
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
- /* eslint-disable prettier/prettier */
20
-
21
- /**
22
- * Copyright (c) Meta Platforms, Inc. and affiliates.
23
- *
24
- * This source code is licensed under the MIT license found in the
25
- * LICENSE file in the root directory of this source tree.
26
- *
27
- *
28
- * @format
29
- */
30
-
31
24
  let AndroidTextInput;
32
25
  let AndroidTextInputCommands;
33
26
  let RCTSinglelineTextInputView;
@@ -35,8 +28,8 @@ let RCTSinglelineTextInputNativeCommands;
35
28
  let RCTMultilineTextInputView;
36
29
  let RCTMultilineTextInputNativeCommands;
37
30
  if (_Platform.default.OS === 'android') {
38
- AndroidTextInput = require('./TextInputViewNativeComponent').default;
39
- AndroidTextInputCommands = require('react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent').Commands;
31
+ AndroidTextInput = require('./AndroidTextInputNativeComponent').default;
32
+ AndroidTextInputCommands = require('./AndroidTextInputNativeComponent').Commands;
40
33
  } else if (_Platform.default.OS === 'ios') {
41
34
  RCTSinglelineTextInputView = require('react-native/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent').default;
42
35
  RCTSinglelineTextInputNativeCommands = require('react-native/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent').Commands;
@@ -44,142 +37,14 @@ if (_Platform.default.OS === 'android') {
44
37
  RCTMultilineTextInputNativeCommands = require('react-native/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent').Commands;
45
38
  }
46
39
  const emptyFunctionThatReturnsTrue = () => true;
47
-
48
- /**
49
- * A foundational component for inputting text into the app via a
50
- * keyboard. Props provide configurability for several features, such as
51
- * auto-correction, auto-capitalization, placeholder text, and different keyboard
52
- * types, such as a numeric keypad.
53
- *
54
- * The simplest use case is to plop down a `TextInput` and subscribe to the
55
- * `onChangeText` events to read the user input. There are also other events,
56
- * such as `onSubmitEditing` and `onFocus` that can be subscribed to. A simple
57
- * example:
58
- *
59
- * ```ReactNativeWebPlayer
60
- * import React, { Component } from 'react';
61
- * import { AppRegistry, TextInput } from 'react-native';
62
- *
63
- * export default class UselessTextInput extends Component {
64
- * constructor(props) {
65
- * super(props);
66
- * this.state = { text: 'Useless Placeholder' };
67
- * }
68
- *
69
- * render() {
70
- * return (
71
- * <TextInput
72
- * style={{height: 40, borderColor: 'gray', borderWidth: 1}}
73
- * onChangeText={(text) => this.setState({text})}
74
- * value={this.state.text}
75
- * />
76
- * );
77
- * }
78
- * }
79
- *
80
- * // skip this line if using Create React Native App
81
- * AppRegistry.registerComponent('AwesomeProject', () => UselessTextInput);
82
- * ```
83
- *
84
- * Two methods exposed via the native element are .focus() and .blur() that
85
- * will focus or blur the TextInput programmatically.
86
- *
87
- * Note that some props are only available with `multiline={true/false}`.
88
- * Additionally, border styles that apply to only one side of the element
89
- * (e.g., `borderBottomColor`, `borderLeftWidth`, etc.) will not be applied if
90
- * `multiline=false`. To achieve the same effect, you can wrap your `TextInput`
91
- * in a `View`:
92
- *
93
- * ```ReactNativeWebPlayer
94
- * import React, { Component } from 'react';
95
- * import { AppRegistry, View, TextInput } from 'react-native';
96
- *
97
- * class UselessTextInput extends Component {
98
- * render() {
99
- * return (
100
- * <TextInput
101
- * {...this.props} // Inherit any props passed to it; e.g., multiline, numberOfLines below
102
- * editable={true}
103
- * maxLength={40}
104
- * />
105
- * );
106
- * }
107
- * }
108
- *
109
- * export default class UselessTextInputMultiline extends Component {
110
- * constructor(props) {
111
- * super(props);
112
- * this.state = {
113
- * text: 'Useless Multiline Placeholder',
114
- * };
115
- * }
116
- *
117
- * // If you type something in the text box that is a color, the background will change to that
118
- * // color.
119
- * render() {
120
- * return (
121
- * <View style={{
122
- * backgroundColor: this.state.text,
123
- * borderBottomColor: '#000000',
124
- * borderBottomWidth: 1 }}
125
- * >
126
- * <UselessTextInput
127
- * multiline={true}
128
- * numberOfLines={4}
129
- * onChangeText={(text) => this.setState({text})}
130
- * value={this.state.text}
131
- * />
132
- * </View>
133
- * );
134
- * }
135
- * }
136
- *
137
- * // skip these lines if using Create React Native App
138
- * AppRegistry.registerComponent(
139
- * 'AwesomeProject',
140
- * () => UselessTextInputMultiline
141
- * );
142
- * ```
143
- *
144
- * `TextInput` has by default a border at the bottom of its view. This border
145
- * has its padding set by the background image provided by the system, and it
146
- * cannot be changed. Solutions to avoid this is to either not set height
147
- * explicitly, case in which the system will take care of displaying the border
148
- * in the correct position, or to not display the border by setting
149
- * `underlineColorAndroid` to transparent.
150
- *
151
- * Note that on Android performing text selection in input can change
152
- * app's activity `windowSoftInputMode` param to `adjustResize`.
153
- * This may cause issues with components that have position: 'absolute'
154
- * while keyboard is active. To avoid this behavior either specify `windowSoftInputMode`
155
- * in AndroidManifest.xml ( https://developer.android.com/guide/topics/manifest/activity-element.html )
156
- * or control this param programmatically with native code.
157
- *
158
- */
159
- function InternalTextInput(props) {
160
- const {
161
- 'aria-busy': ariaBusy,
162
- 'aria-checked': ariaChecked,
163
- 'aria-disabled': ariaDisabled,
164
- 'aria-expanded': ariaExpanded,
165
- 'aria-selected': ariaSelected,
166
- accessibilityState,
167
- id,
168
- tabIndex,
169
- selection: propsSelection,
170
- selectionColor,
171
- selectionHandleColor,
172
- cursorColor,
173
- ...otherProps
174
- } = props;
175
- const inputRef = (0, _react.useRef)(null);
176
-
177
- // eslint-disable-next-line react-hooks/exhaustive-deps
178
- const selection = propsSelection == null ? null : {
179
- start: propsSelection.start,
180
- end: propsSelection.end ?? propsSelection.start
181
- };
182
- const [mostRecentEventCount, setMostRecentEventCount] = (0, _react.useState)(0);
40
+ function useTextInputStateSynchronization_STATE({
41
+ props,
42
+ mostRecentEventCount,
43
+ selection,
44
+ inputRef,
45
+ text,
46
+ viewCommands
47
+ }) {
183
48
  const [lastNativeText, setLastNativeText] = (0, _react.useState)(props.value);
184
49
  const [lastNativeSelectionState, setLastNativeSelection] = (0, _react.useState)({
185
50
  selection: {
@@ -189,17 +54,6 @@ function InternalTextInput(props) {
189
54
  mostRecentEventCount: mostRecentEventCount
190
55
  });
191
56
  const lastNativeSelection = lastNativeSelectionState.selection;
192
- let viewCommands;
193
- if (AndroidTextInputCommands) {
194
- viewCommands = AndroidTextInputCommands;
195
- } else {
196
- viewCommands = props.multiline === true ? RCTMultilineTextInputNativeCommands : RCTSinglelineTextInputNativeCommands;
197
- }
198
- const text = typeof props.value === 'string' ? props.value : typeof props.defaultValue === 'string' ? props.defaultValue : '';
199
-
200
- // This is necessary in case native updates the text and JS decides
201
- // that the update should be ignored and we should stick with the value
202
- // that we have in JS.
203
57
  (0, _react.useLayoutEffect)(() => {
204
58
  const nativeUpdate = {};
205
59
  if (lastNativeText !== props.value && typeof props.value === 'string') {
@@ -220,6 +74,93 @@ function InternalTextInput(props) {
220
74
  viewCommands.setTextAndSelection(inputRef.current, mostRecentEventCount, text, selection?.start ?? -1, selection?.end ?? -1);
221
75
  }
222
76
  }, [mostRecentEventCount, inputRef, props.value, props.defaultValue, lastNativeText, selection, lastNativeSelection, text, viewCommands]);
77
+ return {
78
+ setLastNativeText,
79
+ setLastNativeSelection
80
+ };
81
+ }
82
+ function useTextInputStateSynchronization_REFS({
83
+ props,
84
+ mostRecentEventCount,
85
+ selection,
86
+ inputRef,
87
+ text,
88
+ viewCommands
89
+ }) {
90
+ const lastNativeTextRef = (0, _react.useRef)(props.value);
91
+ const lastNativeSelectionRef = (0, _react.useRef)({
92
+ selection: {
93
+ start: -1,
94
+ end: -1
95
+ },
96
+ mostRecentEventCount: mostRecentEventCount
97
+ });
98
+ (0, _react.useLayoutEffect)(() => {
99
+ const nativeUpdate = {};
100
+ const lastNativeSelection = lastNativeSelectionRef.current.selection;
101
+ if (lastNativeTextRef.current !== props.value && typeof props.value === 'string') {
102
+ nativeUpdate.text = props.value;
103
+ lastNativeTextRef.current = props.value;
104
+ }
105
+ if (selection && lastNativeSelection && (lastNativeSelection.start !== selection.start || lastNativeSelection.end !== selection.end)) {
106
+ nativeUpdate.selection = selection;
107
+ lastNativeSelectionRef.current = {
108
+ selection,
109
+ mostRecentEventCount
110
+ };
111
+ }
112
+ if (Object.keys(nativeUpdate).length === 0) {
113
+ return;
114
+ }
115
+ if (inputRef.current != null) {
116
+ viewCommands.setTextAndSelection(inputRef.current, mostRecentEventCount, text, selection?.start ?? -1, selection?.end ?? -1);
117
+ }
118
+ }, [mostRecentEventCount, inputRef, props.value, props.defaultValue, selection, text, viewCommands]);
119
+ return {
120
+ setLastNativeText: lastNativeText => {
121
+ lastNativeTextRef.current = lastNativeText;
122
+ },
123
+ setLastNativeSelection: lastNativeSelection => {
124
+ lastNativeSelectionRef.current = lastNativeSelection;
125
+ }
126
+ };
127
+ }
128
+ function InternalTextInput(props) {
129
+ const {
130
+ 'aria-busy': ariaBusy,
131
+ 'aria-checked': ariaChecked,
132
+ 'aria-disabled': ariaDisabled,
133
+ 'aria-expanded': ariaExpanded,
134
+ 'aria-selected': ariaSelected,
135
+ accessibilityState,
136
+ id,
137
+ tabIndex,
138
+ selection: propsSelection,
139
+ selectionColor,
140
+ selectionHandleColor,
141
+ cursorColor,
142
+ ...otherProps
143
+ } = props;
144
+ const inputRef = (0, _react.useRef)(null);
145
+ const selection = propsSelection == null ? null : {
146
+ start: propsSelection.start,
147
+ end: propsSelection.end ?? propsSelection.start
148
+ };
149
+ const text = typeof props.value === 'string' ? props.value : typeof props.defaultValue === 'string' ? props.defaultValue : undefined;
150
+ const viewCommands = AndroidTextInputCommands || (props.multiline === true ? RCTMultilineTextInputNativeCommands : RCTSinglelineTextInputNativeCommands);
151
+ const [mostRecentEventCount, setMostRecentEventCount] = (0, _react.useState)(0);
152
+ const useTextInputStateSynchronization = ReactNativeFeatureFlags.useRefsForTextInputState() ? useTextInputStateSynchronization_REFS : useTextInputStateSynchronization_STATE;
153
+ const {
154
+ setLastNativeText,
155
+ setLastNativeSelection
156
+ } = useTextInputStateSynchronization({
157
+ props,
158
+ inputRef,
159
+ mostRecentEventCount,
160
+ selection,
161
+ text,
162
+ viewCommands
163
+ });
223
164
  (0, _react.useLayoutEffect)(() => {
224
165
  const inputRefValue = inputRef.current;
225
166
  if (inputRefValue != null) {
@@ -231,39 +172,16 @@ function InternalTextInput(props) {
231
172
  }
232
173
  };
233
174
  }
234
- }, [inputRef]);
175
+ }, []);
235
176
  const setLocalRef = (0, _react.useCallback)(instance => {
236
177
  inputRef.current = instance;
237
-
238
- /*
239
- Hi reader from the future. I'm sorry for this.
240
- This is a hack. Ideally we would forwardRef to the underlying
241
- host component. However, since TextInput has it's own methods that can be
242
- called as well, if we used the standard forwardRef then these
243
- methods wouldn't be accessible and thus be a breaking change.
244
- We have a couple of options of how to handle this:
245
- - Return a new ref with everything we methods from both. This is problematic
246
- because we need React to also know it is a host component which requires
247
- internals of the class implementation of the ref.
248
- - Break the API and have some other way to call one set of the methods or
249
- the other. This is our long term approach as we want to eventually
250
- get the methods on host components off the ref. So instead of calling
251
- ref.measure() you might call ReactNative.measure(ref). This would hopefully
252
- let the ref for TextInput then have the methods like `.clear`. Or we do it
253
- the other way and make it TextInput.clear(textInputRef) which would be fine
254
- too. Either way though is a breaking change that is longer term.
255
- - Mutate this ref. :( Gross, but accomplishes what we need in the meantime
256
- before we can get to the long term breaking change.
257
- */
258
178
  if (instance != null) {
259
- // $FlowFixMe[incompatible-use] - See the explanation above.
260
179
  Object.assign(instance, {
261
180
  clear() {
262
181
  if (inputRef.current != null) {
263
182
  viewCommands.setTextAndSelection(inputRef.current, mostRecentEventCount, '', 0, 0);
264
183
  }
265
184
  },
266
- // TODO: Fix this returning true on null === null, when no input is focused
267
185
  isFocused() {
268
186
  return _TextInputState.default.currentlyFocusedInput() === inputRef.current;
269
187
  },
@@ -284,22 +202,14 @@ function InternalTextInput(props) {
284
202
  props.onChange && props.onChange(event);
285
203
  props.onChangeText && props.onChangeText(currentText);
286
204
  if (inputRef.current == null) {
287
- // calling `props.onChange` or `props.onChangeText`
288
- // may clean up the input itself. Exits here.
289
205
  return;
290
206
  }
291
207
  setLastNativeText(currentText);
292
- // This must happen last, after we call setLastNativeText.
293
- // Different ordering can cause bugs when editing AndroidTextInputs
294
- // with multiple Fragments.
295
- // We must update this so that controlled input updates work.
296
208
  setMostRecentEventCount(event.nativeEvent.eventCount);
297
209
  };
298
210
  const _onSelectionChange = event => {
299
211
  props.onSelectionChange && props.onSelectionChange(event);
300
212
  if (inputRef.current == null) {
301
- // calling `props.onSelectionChange`
302
- // may clean up the input itself. Exits here.
303
213
  return;
304
214
  }
305
215
  setLastNativeSelection({
@@ -326,9 +236,7 @@ function InternalTextInput(props) {
326
236
  const multiline = props.multiline ?? false;
327
237
  let submitBehavior;
328
238
  if (props.submitBehavior != null) {
329
- // `submitBehavior` is set explicitly
330
239
  if (!multiline && props.submitBehavior === 'newline') {
331
- // For single line text inputs, `'newline'` is not a valid option
332
240
  submitBehavior = 'blurAndSubmit';
333
241
  } else {
334
242
  submitBehavior = props.submitBehavior;
@@ -340,7 +248,6 @@ function InternalTextInput(props) {
340
248
  submitBehavior = 'newline';
341
249
  }
342
250
  } else {
343
- // Single line
344
251
  if (props.blurOnSubmit !== false) {
345
252
  submitBehavior = 'blurAndSubmit';
346
253
  } else {
@@ -371,21 +278,15 @@ function InternalTextInput(props) {
371
278
  onPressOut: onPressOut,
372
279
  cancelable: _Platform.default.OS === 'ios' ? !rejectResponderTermination : null
373
280
  }), [editable, hitSlop, onPress, onPressIn, onPressOut, rejectResponderTermination]);
374
-
375
- // Hide caret during test runs due to a flashing caret
376
- // makes screenshot tests flakey
377
281
  let caretHidden = props.caretHidden;
378
282
  if (_Platform.default.isTesting) {
379
283
  caretHidden = true;
380
284
  }
381
-
382
- // TextInput handles onBlur and onFocus events
383
- // so omitting onBlur and onFocus pressability handlers here.
384
285
  const {
385
286
  onBlur,
386
287
  onFocus,
387
288
  ...eventHandlers
388
- } = (0, _usePressability.default)(config) || {};
289
+ } = (0, _usePressability.default)(config);
389
290
  let _accessibilityState;
390
291
  if (accessibilityState != null || ariaBusy != null || ariaChecked != null || ariaDisabled != null || ariaExpanded != null || ariaSelected != null) {
391
292
  _accessibilityState = {
@@ -396,18 +297,27 @@ function InternalTextInput(props) {
396
297
  selected: ariaSelected ?? accessibilityState?.selected
397
298
  };
398
299
  }
399
- const style = (0, _flattenStyle.default)(props.style);
400
- if (typeof style?.fontWeight === 'number') {
401
- // $FlowFixMe[prop-missing]
402
- // $FlowFixMe[cannot-write]
403
- style.fontWeight = style?.fontWeight.toString();
300
+ let _style = props.style;
301
+ const flattenedStyle = (0, _flattenStyle.default)(props.style);
302
+ if (flattenedStyle != null) {
303
+ let overrides = null;
304
+ if (typeof flattenedStyle?.fontWeight === 'number') {
305
+ overrides = overrides || {};
306
+ overrides.fontWeight = flattenedStyle.fontWeight.toString();
307
+ }
308
+ if (flattenedStyle.verticalAlign != null) {
309
+ overrides = overrides || {};
310
+ overrides.textAlignVertical = verticalAlignToTextAlignVerticalMap[flattenedStyle.verticalAlign];
311
+ overrides.verticalAlign = undefined;
312
+ }
313
+ if (overrides != null) {
314
+ _style = [_style, overrides];
315
+ }
404
316
  }
405
317
  if (_Platform.default.OS === 'ios') {
406
318
  const RCTTextInputView = props.multiline === true ? RCTMultilineTextInputView : RCTSinglelineTextInputView;
407
- const useMultilineDefaultStyle = props.multiline === true && (style == null || style.padding == null && style.paddingVertical == null && style.paddingTop == null);
408
- textInput = /*#__PURE__*/(0, _jsxRuntime.jsx)(RCTTextInputView
409
- // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
410
- , {
319
+ const useMultilineDefaultStyle = props.multiline === true && (flattenedStyle == null || flattenedStyle.padding == null && flattenedStyle.paddingVertical == null && flattenedStyle.paddingTop == null);
320
+ textInput = /*#__PURE__*/(0, _jsxRuntime.jsx)(RCTTextInputView, {
411
321
  ref: ref,
412
322
  ...otherProps,
413
323
  ...eventHandlers,
@@ -419,6 +329,7 @@ function InternalTextInput(props) {
419
329
  focusable: tabIndex !== undefined ? !tabIndex : focusable,
420
330
  mostRecentEventCount: mostRecentEventCount,
421
331
  nativeID: id ?? props.nativeID,
332
+ numberOfLines: props.rows ?? props.numberOfLines,
422
333
  onBlur: _onBlur,
423
334
  onChange: _onChange,
424
335
  onContentSizeChange: props.onContentSizeChange,
@@ -428,7 +339,7 @@ function InternalTextInput(props) {
428
339
  onSelectionChangeShouldSetResponder: emptyFunctionThatReturnsTrue,
429
340
  selection: selection,
430
341
  selectionColor: selectionColor,
431
- style: _StyleSheet.default.compose(useMultilineDefaultStyle ? styles.multilineDefault : null, style),
342
+ style: _StyleSheet.default.compose(useMultilineDefaultStyle ? styles.multilineDefault : null, _style),
432
343
  text: text
433
344
  });
434
345
  } else if (_Platform.default.OS === 'android') {
@@ -443,29 +354,21 @@ function InternalTextInput(props) {
443
354
  children: children
444
355
  });
445
356
  }
446
- // For consistency with iOS set cursor/selectionHandle color as selectionColor
447
357
  const colorProps = {
448
358
  selectionColor,
449
359
  selectionHandleColor: selectionHandleColor === undefined ? selectionColor : selectionHandleColor,
450
360
  cursorColor: cursorColor === undefined ? selectionColor : cursorColor
451
361
  };
452
- textInput =
453
- /*#__PURE__*/
454
- /* $FlowFixMe[prop-missing] the types for AndroidTextInput don't match up
455
- * exactly with the props for TextInput. This will need to get fixed */
456
- /* $FlowFixMe[incompatible-type] the types for AndroidTextInput don't
457
- * match up exactly with the props for TextInput. This will need to get
458
- * fixed */
459
- /* $FlowFixMe[incompatible-type-arg] the types for AndroidTextInput don't
460
- * match up exactly with the props for TextInput. This will need to get
461
- * fixed */
462
- (0, _jsxRuntime.jsx)(AndroidTextInput
463
- // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
464
- , {
362
+ const {
363
+ onPaste,
364
+ ...rest
365
+ } = otherProps;
366
+ textInput = /*#__PURE__*/(0, _jsxRuntime.jsx)(AndroidTextInput, {
465
367
  ref: ref,
466
- ...otherProps,
368
+ ...rest,
467
369
  ...colorProps,
468
370
  ...eventHandlers,
371
+ onPaste: onPaste,
469
372
  accessibilityState: _accessibilityState,
470
373
  accessibilityLabelledBy: _accessibilityLabelledBy,
471
374
  accessible: accessible,
@@ -480,17 +383,11 @@ function InternalTextInput(props) {
480
383
  numberOfLines: props.rows ?? props.numberOfLines,
481
384
  onBlur: _onBlur,
482
385
  onChange: _onChange,
483
- onFocus: _onFocus
484
- /* $FlowFixMe[prop-missing] the types for AndroidTextInput don't match
485
- * up exactly with the props for TextInput. This will need to get fixed
486
- */
487
- /* $FlowFixMe[incompatible-type-arg] the types for AndroidTextInput
488
- * don't match up exactly with the props for TextInput. This will need
489
- * to get fixed */,
386
+ onFocus: _onFocus,
490
387
  onScroll: _onScroll,
491
388
  onSelectionChange: _onSelectionChange,
492
389
  placeholder: placeholder,
493
- style: style,
390
+ style: _style,
494
391
  text: text,
495
392
  textBreakStrategy: props.textBreakStrategy
496
393
  });
@@ -519,8 +416,6 @@ const inputModeToKeyboardTypeMap = {
519
416
  email: 'email-address',
520
417
  url: 'url'
521
418
  };
522
-
523
- // Map HTML autocomplete values to Android autoComplete values
524
419
  const autoCompleteWebToAutoCompleteAndroidMap = {
525
420
  'address-line1': 'postal-address-region',
526
421
  'address-line2': 'postal-address-locality',
@@ -553,8 +448,6 @@ const autoCompleteWebToAutoCompleteAndroidMap = {
553
448
  'tel-national': 'tel-national',
554
449
  username: 'username'
555
450
  };
556
-
557
- // Map HTML autocomplete values to iOS textContentType values
558
451
  const autoCompleteWebToTextContentTypeMap = {
559
452
  'address-line1': 'streetAddressLine1',
560
453
  'address-line2': 'streetAddressLine2',
@@ -608,18 +501,6 @@ const ExportedForwardRef = /*#__PURE__*/React.forwardRef(function TextInput({
608
501
  keyboardType,
609
502
  ...restProps
610
503
  }, forwardedRef) {
611
- // $FlowFixMe[underconstrained-implicit-instantiation]
612
- let style = (0, _flattenStyle.default)(restProps.style);
613
- if (style?.verticalAlign != null) {
614
- // $FlowFixMe[prop-missing]
615
- // $FlowFixMe[cannot-write]
616
- style.textAlignVertical =
617
- // $FlowFixMe[invalid-computed-prop]
618
- verticalAlignToTextAlignVerticalMap[style.verticalAlign];
619
- // $FlowFixMe[prop-missing]
620
- // $FlowFixMe[cannot-write]
621
- delete style.verticalAlign;
622
- }
623
504
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(InternalTextInput, {
624
505
  allowFontScaling: allowFontScaling,
625
506
  rejectResponderTermination: rejectResponderTermination,
@@ -628,22 +509,13 @@ const ExportedForwardRef = /*#__PURE__*/React.forwardRef(function TextInput({
628
509
  returnKeyType: enterKeyHint ? enterKeyHintToReturnTypeMap[enterKeyHint] : returnKeyType,
629
510
  keyboardType: inputMode ? inputModeToKeyboardTypeMap[inputMode] : keyboardType,
630
511
  showSoftInputOnFocus: inputMode == null ? showSoftInputOnFocus : inputMode !== 'none',
631
- autoComplete: _Platform.default.OS === 'android' ?
632
- // $FlowFixMe[invalid-computed-prop]
633
- // $FlowFixMe[prop-missing]
634
- autoCompleteWebToAutoCompleteAndroidMap[autoComplete] ?? autoComplete : undefined,
635
- textContentType: textContentType != null ? textContentType : _Platform.default.OS === 'ios' && autoComplete && autoComplete in autoCompleteWebToTextContentTypeMap ?
636
- // $FlowFixMe[invalid-computed-prop]
637
- // $FlowFixMe[prop-missing]
638
- autoCompleteWebToTextContentTypeMap[autoComplete] : textContentType,
512
+ autoComplete: _Platform.default.OS === 'android' ? autoCompleteWebToAutoCompleteAndroidMap[autoComplete] ?? autoComplete : undefined,
513
+ textContentType: textContentType != null ? textContentType : _Platform.default.OS === 'ios' && autoComplete && autoComplete in autoCompleteWebToTextContentTypeMap ? autoCompleteWebToTextContentTypeMap[autoComplete] : textContentType,
639
514
  ...restProps,
640
- forwardedRef: forwardedRef,
641
- style: style
515
+ forwardedRef: forwardedRef
642
516
  });
643
517
  });
644
518
  ExportedForwardRef.displayName = 'TextInput';
645
-
646
- // $FlowFixMe[prop-missing]
647
519
  ExportedForwardRef.State = {
648
520
  currentlyFocusedInput: _TextInputState.default.currentlyFocusedInput,
649
521
  currentlyFocusedField: _TextInputState.default.currentlyFocusedField,
@@ -652,9 +524,6 @@ ExportedForwardRef.State = {
652
524
  };
653
525
  const styles = _StyleSheet.default.create({
654
526
  multilineDefault: {
655
- // This default top inset makes RCTMultilineTextInputView seem as close as possible
656
- // to single-line RCTSinglelineTextInputView defaults, using the system defaults
657
- // of font size 17 and a height of 31 points.
658
527
  paddingTop: 5
659
528
  }
660
529
  });
@@ -664,7 +533,5 @@ const verticalAlignToTextAlignVerticalMap = {
664
533
  bottom: 'bottom',
665
534
  middle: 'center'
666
535
  };
667
-
668
- // $FlowFixMe[unclear-type] Unclear type. Using `any` type is not safe.
669
- module.exports = ExportedForwardRef;
536
+ var _default = exports.default = ExportedForwardRef;
670
537
  //# sourceMappingURL=Input.js.map