@onekeyfe/react-native-text-input 0.2.5 → 0.2.8

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