1/**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @format
8 */
9
10import type * as React from 'react';
11import {Constructor} from '../../../types/private/Utilities';
12import {TimerMixin} from '../../../types/private/TimerMixin';
13import {
14  HostComponent,
15  NativeMethods,
16} from '../../../types/public/ReactNativeTypes';
17import {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet';
18import {TextStyle} from '../../StyleSheet/StyleSheetTypes';
19import {
20  NativeSyntheticEvent,
21  NativeTouchEvent,
22  TargetedEvent,
23} from '../../Types/CoreEventTypes';
24import {EventEmitter} from '../../vendor/emitter/EventEmitter';
25import {AccessibilityProps} from '../View/ViewAccessibility';
26import {ViewProps} from '../View/ViewPropTypes';
27
28export type KeyboardType =
29  | 'default'
30  | 'email-address'
31  | 'numeric'
32  | 'phone-pad'
33  | 'number-pad'
34  | 'decimal-pad';
35export type KeyboardTypeIOS =
36  | 'ascii-capable'
37  | 'numbers-and-punctuation'
38  | 'url'
39  | 'name-phone-pad'
40  | 'twitter'
41  | 'web-search';
42export type KeyboardTypeAndroid = 'visible-password';
43export type KeyboardTypeOptions =
44  | KeyboardType
45  | KeyboardTypeAndroid
46  | KeyboardTypeIOS;
47
48export type InputModeOptions =
49  | 'none'
50  | 'text'
51  | 'decimal'
52  | 'numeric'
53  | 'tel'
54  | 'search'
55  | 'email'
56  | 'url';
57
58export type ReturnKeyType = 'done' | 'go' | 'next' | 'search' | 'send';
59export type ReturnKeyTypeAndroid = 'none' | 'previous';
60export type ReturnKeyTypeIOS =
61  | 'default'
62  | 'google'
63  | 'join'
64  | 'route'
65  | 'yahoo'
66  | 'emergency-call';
67
68export type ReturnKeyTypeOptions =
69  | ReturnKeyType
70  | ReturnKeyTypeAndroid
71  | ReturnKeyTypeIOS;
72
73type DataDetectorTypes =
74  | 'phoneNumber'
75  | 'link'
76  | 'address'
77  | 'calendarEvent'
78  | 'none'
79  | 'all';
80
81/**
82 * DocumentSelectionState is responsible for maintaining selection information
83 * for a document.
84 *
85 * It is intended for use by AbstractTextEditor-based components for
86 * identifying the appropriate start/end positions to modify the
87 * DocumentContent, and for programmatically setting browser selection when
88 * components re-render.
89 */
90export interface DocumentSelectionState extends EventEmitter {
91  new (anchor: number, focus: number): DocumentSelectionState;
92
93  /**
94   * Apply an update to the state. If either offset value has changed,
95   * set the values and emit the `change` event. Otherwise no-op.
96   *
97   */
98  update(anchor: number, focus: number): void;
99
100  /**
101   * Given a max text length, constrain our selection offsets to ensure
102   * that the selection remains strictly within the text range.
103   *
104   */
105  constrainLength(maxLength: number): void;
106
107  focus(): void;
108  blur(): void;
109  hasFocus(): boolean;
110  isCollapsed(): boolean;
111  isBackward(): boolean;
112
113  getAnchorOffset(): number;
114  getFocusOffset(): number;
115  getStartOffset(): number;
116  getEndOffset(): number;
117  overlaps(start: number, end: number): boolean;
118}
119
120/**
121 * IOS Specific properties for TextInput
122 * @see https://reactnative.dev/docs/textinput#props
123 */
124export interface TextInputIOSProps {
125  /**
126   * enum('never', 'while-editing', 'unless-editing', 'always')
127   * When the clear button should appear on the right side of the text view
128   */
129  clearButtonMode?:
130    | 'never'
131    | 'while-editing'
132    | 'unless-editing'
133    | 'always'
134    | undefined;
135
136  /**
137   * If true, clears the text field automatically when editing begins
138   */
139  clearTextOnFocus?: boolean | undefined;
140
141  /**
142   * Determines the types of data converted to clickable URLs in the text input.
143   * Only valid if `multiline={true}` and `editable={false}`.
144   * By default no data types are detected.
145   *
146   * You can provide one type or an array of many types.
147   *
148   * Possible values for `dataDetectorTypes` are:
149   *
150   * - `'phoneNumber'`
151   * - `'link'`
152   * - `'address'`
153   * - `'calendarEvent'`
154   * - `'none'`
155   * - `'all'`
156   */
157  dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[] | undefined;
158
159  /**
160   * If true, the keyboard disables the return key when there is no text and automatically enables it when there is text.
161   * The default value is false.
162   */
163  enablesReturnKeyAutomatically?: boolean | undefined;
164
165  /**
166   * Determines the color of the keyboard.
167   */
168  keyboardAppearance?: 'default' | 'light' | 'dark' | undefined;
169
170  /**
171   * Provide rules for your password.
172   * For example, say you want to require a password with at least eight characters consisting of a mix of uppercase and lowercase letters, at least one number, and at most two consecutive characters.
173   * "required: upper; required: lower; required: digit; max-consecutive: 2; minlength: 8;"
174   */
175  passwordRules?: string | null | undefined;
176
177  /**
178   * If `true`, allows TextInput to pass touch events to the parent component.
179   * This allows components to be swipeable from the TextInput on iOS,
180   * as is the case on Android by default.
181   * If `false`, TextInput always asks to handle the input (except when disabled).
182   */
183  rejectResponderTermination?: boolean | null | undefined;
184
185  /**
186   * See DocumentSelectionState.js, some state that is responsible for maintaining selection information for a document
187   */
188  selectionState?: DocumentSelectionState | undefined;
189
190  /**
191   * If false, disables spell-check style (i.e. red underlines). The default value is inherited from autoCorrect
192   */
193  spellCheck?: boolean | undefined;
194
195  /**
196   * Give the keyboard and the system information about the expected
197   * semantic meaning for the content that users enter.
198   *
199   * For iOS 11+ you can set `textContentType` to `username` or `password` to
200   * enable autofill of login details from the device keychain.
201   *
202   * For iOS 12+ `newPassword` can be used to indicate a new password input the
203   * user may want to save in the keychain, and `oneTimeCode` can be used to indicate
204   * that a field can be autofilled by a code arriving in an SMS.
205   *
206   * To disable autofill, set textContentType to `none`.
207   *
208   * Possible values for `textContentType` are:
209   *
210   *  - `'none'`
211   *  - `'URL'`
212   *  - `'addressCity'`
213   *  - `'addressCityAndState'`
214   *  - `'addressState'`
215   *  - `'countryName'`
216   *  - `'creditCardNumber'`
217   *  - `'emailAddress'`
218   *  - `'familyName'`
219   *  - `'fullStreetAddress'`
220   *  - `'givenName'`
221   *  - `'jobTitle'`
222   *  - `'location'`
223   *  - `'middleName'`
224   *  - `'name'`
225   *  - `'namePrefix'`
226   *  - `'nameSuffix'`
227   *  - `'nickname'`
228   *  - `'organizationName'`
229   *  - `'postalCode'`
230   *  - `'streetAddressLine1'`
231   *  - `'streetAddressLine2'`
232   *  - `'sublocality'`
233   *  - `'telephoneNumber'`
234   *  - `'username'`
235   *  - `'password'`
236   *  - `'newPassword'`
237   *  - `'oneTimeCode'`
238   *
239   */
240  textContentType?:
241    | 'none'
242    | 'URL'
243    | 'addressCity'
244    | 'addressCityAndState'
245    | 'addressState'
246    | 'countryName'
247    | 'creditCardNumber'
248    | 'emailAddress'
249    | 'familyName'
250    | 'fullStreetAddress'
251    | 'givenName'
252    | 'jobTitle'
253    | 'location'
254    | 'middleName'
255    | 'name'
256    | 'namePrefix'
257    | 'nameSuffix'
258    | 'nickname'
259    | 'organizationName'
260    | 'postalCode'
261    | 'streetAddressLine1'
262    | 'streetAddressLine2'
263    | 'sublocality'
264    | 'telephoneNumber'
265    | 'username'
266    | 'password'
267    | 'newPassword'
268    | 'oneTimeCode'
269    | undefined;
270
271  /**
272   * If false, scrolling of the text view will be disabled. The default value is true. Only works with multiline={true}
273   */
274  scrollEnabled?: boolean | undefined;
275}
276
277/**
278 * Android Specific properties for TextInput
279 * @see https://reactnative.dev/docs/textinput#props
280 */
281export interface TextInputAndroidProps {
282  /**
283   * Specifies autocomplete hints for the system, so it can provide autofill. On Android, the system will always attempt to offer autofill by using heuristics to identify the type of content.
284   * To disable autocomplete, set `autoComplete` to `off`.
285   *
286   * *Android Only*
287   *
288   * Possible values for `autoComplete` are:
289   *
290   * - `birthdate-day`
291   * - `birthdate-full`
292   * - `birthdate-month`
293   * - `birthdate-year`
294   * - `cc-csc`
295   * - `cc-exp`
296   * - `cc-exp-day`
297   * - `cc-exp-month`
298   * - `cc-exp-year`
299   * - `cc-number`
300   * - `email`
301   * - `gender`
302   * - `name`
303   * - `name-family`
304   * - `name-given`
305   * - `name-middle`
306   * - `name-middle-initial`
307   * - `name-prefix`
308   * - `name-suffix`
309   * - `password`
310   * - `password-new`
311   * - `postal-address`
312   * - `postal-address-country`
313   * - `postal-address-extended`
314   * - `postal-address-extended-postal-code`
315   * - `postal-address-locality`
316   * - `postal-address-region`
317   * - `postal-code`
318   * - `street-address`
319   * - `sms-otp`
320   * - `tel`
321   * - `tel-country-code`
322   * - `tel-national`
323   * - `tel-device`
324   * - `username`
325   * - `username-new`
326   * - `off`
327   */
328  autoComplete?:
329    | 'birthdate-day'
330    | 'birthdate-full'
331    | 'birthdate-month'
332    | 'birthdate-year'
333    | 'cc-csc'
334    | 'cc-exp'
335    | 'cc-exp-day'
336    | 'cc-exp-month'
337    | 'cc-exp-year'
338    | 'cc-number'
339    | 'email'
340    | 'gender'
341    | 'name'
342    | 'name-family'
343    | 'name-given'
344    | 'name-middle'
345    | 'name-middle-initial'
346    | 'name-prefix'
347    | 'name-suffix'
348    | 'password'
349    | 'password-new'
350    | 'postal-address'
351    | 'postal-address-country'
352    | 'postal-address-extended'
353    | 'postal-address-extended-postal-code'
354    | 'postal-address-locality'
355    | 'postal-address-region'
356    | 'postal-code'
357    | 'street-address'
358    | 'sms-otp'
359    | 'tel'
360    | 'tel-country-code'
361    | 'tel-national'
362    | 'tel-device'
363    | 'username'
364    | 'username-new'
365    | 'off'
366    | undefined;
367
368  /**
369   * When provided it will set the color of the cursor (or "caret") in the component.
370   * Unlike the behavior of `selectionColor` the cursor color will be set independently
371   * from the color of the text selection box.
372   * @platform android
373   */
374  cursorColor?: ColorValue | null | undefined;
375
376  /**
377   * Determines whether the individual fields in your app should be included in a
378   * view structure for autofill purposes on Android API Level 26+. Defaults to auto.
379   * To disable auto complete, use `off`.
380   *
381   * *Android Only*
382   *
383   * The following values work on Android only:
384   *
385   * - `auto` - let Android decide
386   * - `no` - not important for autofill
387   * - `noExcludeDescendants` - this view and its children aren't important for autofill
388   * - `yes` - is important for autofill
389   * - `yesExcludeDescendants` - this view is important for autofill but its children aren't
390   */
391  importantForAutofill?:
392    | 'auto'
393    | 'no'
394    | 'noExcludeDescendants'
395    | 'yes'
396    | 'yesExcludeDescendants'
397    | undefined;
398
399  /**
400   * When false, if there is a small amount of space available around a text input (e.g. landscape orientation on a phone),
401   *   the OS may choose to have the user edit the text inside of a full screen text input mode.
402   * When true, this feature is disabled and users will always edit the text directly inside of the text input.
403   * Defaults to false.
404   */
405  disableFullscreenUI?: boolean | undefined;
406
407  /**
408   * If defined, the provided image resource will be rendered on the left.
409   */
410  inlineImageLeft?: string | undefined;
411
412  /**
413   * Padding between the inline image, if any, and the text input itself.
414   */
415  inlineImagePadding?: number | undefined;
416
417  /**
418   * Sets the number of lines for a TextInput.
419   * Use it with multiline set to true to be able to fill the lines.
420   */
421  numberOfLines?: number | undefined;
422
423  /**
424   * Sets the return key to the label. Use it instead of `returnKeyType`.
425   * @platform android
426   */
427  returnKeyLabel?: string | undefined;
428
429  /**
430   * Set text break strategy on Android API Level 23+, possible values are simple, highQuality, balanced
431   * The default value is simple.
432   */
433  textBreakStrategy?: 'simple' | 'highQuality' | 'balanced' | undefined;
434
435  /**
436   * The color of the textInput underline.
437   */
438  underlineColorAndroid?: ColorValue | undefined;
439
440  /**
441   * Vertically align text when `multiline` is set to true
442   */
443  textAlignVertical?: 'auto' | 'top' | 'bottom' | 'center' | undefined;
444
445  /**
446   * When false, it will prevent the soft keyboard from showing when the field is focused. The default value is true
447   */
448  showSoftInputOnFocus?: boolean | undefined;
449
450  /**
451   * Vertically align text when `multiline` is set to true
452   */
453  verticalAlign?: 'auto' | 'top' | 'bottom' | 'middle' | undefined;
454}
455
456/**
457 * @see TextInputProps.onFocus
458 */
459export interface TextInputFocusEventData extends TargetedEvent {
460  text: string;
461  eventCount: number;
462}
463
464/**
465 * @see TextInputProps.onScroll
466 */
467export interface TextInputScrollEventData {
468  contentOffset: {x: number; y: number};
469}
470
471/**
472 * @see TextInputProps.onSelectionChange
473 */
474export interface TextInputSelectionChangeEventData extends TargetedEvent {
475  selection: {
476    start: number;
477    end: number;
478  };
479}
480
481/**
482 * @see TextInputProps.onKeyPress
483 */
484export interface TextInputKeyPressEventData {
485  key: string;
486}
487
488/**
489 * @see TextInputProps.onChange
490 */
491export interface TextInputChangeEventData extends TargetedEvent {
492  eventCount: number;
493  text: string;
494}
495
496/**
497 * @see TextInputProps.onContentSizeChange
498 */
499export interface TextInputContentSizeChangeEventData {
500  contentSize: {width: number; height: number};
501}
502
503/**
504 * @see TextInputProps.onEndEditing
505 */
506export interface TextInputEndEditingEventData {
507  text: string;
508}
509
510/**
511 * @see TextInputProps.onSubmitEditing
512 */
513export interface TextInputSubmitEditingEventData {
514  text: string;
515}
516
517/**
518 * @see TextInputProps.onTextInput
519 */
520export interface TextInputTextInputEventData {
521  text: string;
522  previousText: string;
523  range: {start: number; end: number};
524}
525
526/**
527 * @see https://reactnative.dev/docs/textinput#props
528 */
529export interface TextInputProps
530  extends ViewProps,
531    TextInputIOSProps,
532    TextInputAndroidProps,
533    AccessibilityProps {
534  /**
535   * Specifies whether fonts should scale to respect Text Size accessibility settings.
536   * The default is `true`.
537   */
538  allowFontScaling?: boolean | undefined;
539
540  /**
541   * Can tell TextInput to automatically capitalize certain characters.
542   *      characters: all characters,
543   *      words: first letter of each word
544   *      sentences: first letter of each sentence (default)
545   *      none: don't auto capitalize anything
546   *
547   * https://reactnative.dev/docs/textinput#autocapitalize
548   */
549  autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters' | undefined;
550
551  /**
552   * If false, disables auto-correct.
553   * The default value is true.
554   */
555  autoCorrect?: boolean | undefined;
556
557  /**
558   * If true, focuses the input on componentDidMount.
559   * The default value is false.
560   */
561  autoFocus?: boolean | undefined;
562
563  /**
564   * If true, the text field will blur when submitted.
565   * The default value is true.
566   */
567  blurOnSubmit?: boolean | undefined;
568
569  /**
570   * If true, caret is hidden. The default value is false.
571   */
572  caretHidden?: boolean | undefined;
573
574  /**
575   * If true, context menu is hidden. The default value is false.
576   */
577  contextMenuHidden?: boolean | undefined;
578
579  /**
580   * Provides an initial value that will change when the user starts typing.
581   * Useful for simple use-cases where you don't want to deal with listening to events
582   * and updating the value prop to keep the controlled state in sync.
583   */
584  defaultValue?: string | undefined;
585
586  /**
587   * If false, text is not editable. The default value is true.
588   */
589  editable?: boolean | undefined;
590
591  /**
592   * enum("default", 'numeric', 'email-address', "ascii-capable", 'numbers-and-punctuation', 'url', 'number-pad', 'phone-pad', 'name-phone-pad',
593   * 'decimal-pad', 'twitter', 'web-search', 'visible-password')
594   * Determines which keyboard to open, e.g.numeric.
595   * The following values work across platforms: - default - numeric - email-address - phone-pad
596   * The following values work on iOS: - ascii-capable - numbers-and-punctuation - url - number-pad - name-phone-pad - decimal-pad - twitter - web-search
597   * The following values work on Android: - visible-password
598   */
599  keyboardType?: KeyboardTypeOptions | undefined;
600
601  /**
602   * Works like the inputmode attribute in HTML, it determines which keyboard to open, e.g. numeric and has precedence over keyboardType.
603   */
604  inputMode?: InputModeOptions | undefined;
605
606  /**
607   * Limits the maximum number of characters that can be entered.
608   * Use this instead of implementing the logic in JS to avoid flicker.
609   */
610  maxLength?: number | undefined;
611
612  /**
613   * If true, the text input can be multiple lines. The default value is false.
614   */
615  multiline?: boolean | undefined;
616
617  /**
618   * Callback that is called when the text input is blurred
619   */
620  onBlur?:
621    | ((e: NativeSyntheticEvent<TextInputFocusEventData>) => void)
622    | undefined;
623
624  /**
625   * Callback that is called when the text input's text changes.
626   */
627  onChange?:
628    | ((e: NativeSyntheticEvent<TextInputChangeEventData>) => void)
629    | undefined;
630
631  /**
632   * Callback that is called when the text input's text changes.
633   * Changed text is passed as an argument to the callback handler.
634   */
635  onChangeText?: ((text: string) => void) | undefined;
636
637  /**
638   * Callback that is called when the text input's content size changes.
639   * This will be called with
640   * `{ nativeEvent: { contentSize: { width, height } } }`.
641   *
642   * Only called for multiline text inputs.
643   */
644  onContentSizeChange?:
645    | ((e: NativeSyntheticEvent<TextInputContentSizeChangeEventData>) => void)
646    | undefined;
647
648  /**
649   * Callback that is called when text input ends.
650   */
651  onEndEditing?:
652    | ((e: NativeSyntheticEvent<TextInputEndEditingEventData>) => void)
653    | undefined;
654
655  /**
656   * Callback that is called when a touch is engaged.
657   */
658  onPressIn?: ((e: NativeSyntheticEvent<NativeTouchEvent>) => void) | undefined;
659
660  /**
661   * Callback that is called when a touch is released.
662   */
663  onPressOut?:
664    | ((e: NativeSyntheticEvent<NativeTouchEvent>) => void)
665    | undefined;
666
667  /**
668   * Callback that is called when the text input is focused
669   */
670  onFocus?:
671    | ((e: NativeSyntheticEvent<TextInputFocusEventData>) => void)
672    | undefined;
673
674  /**
675   * Callback that is called when the text input selection is changed.
676   */
677  onSelectionChange?:
678    | ((e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => void)
679    | undefined;
680
681  /**
682   * Callback that is called when the text input's submit button is pressed.
683   */
684  onSubmitEditing?:
685    | ((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void)
686    | undefined;
687
688  /**
689   * Callback that is called on new text input with the argument
690   *  `{ nativeEvent: { text, previousText, range: { start, end } } }`.
691   *
692   * This prop requires multiline={true} to be set.
693   */
694  onTextInput?:
695    | ((e: NativeSyntheticEvent<TextInputTextInputEventData>) => void)
696    | undefined;
697
698  /**
699   * Invoked on content scroll with
700   *  `{ nativeEvent: { contentOffset: { x, y } } }`.
701   *
702   * May also contain other properties from ScrollEvent but on Android contentSize is not provided for performance reasons.
703   */
704  onScroll?:
705    | ((e: NativeSyntheticEvent<TextInputScrollEventData>) => void)
706    | undefined;
707
708  /**
709   * Callback that is called when a key is pressed.
710   * This will be called with
711   *  `{ nativeEvent: { key: keyValue } }`
712   * where keyValue is 'Enter' or 'Backspace' for respective keys and the typed-in character otherwise including ' ' for space.
713   *
714   * Fires before onChange callbacks.
715   * Note: on Android only the inputs from soft keyboard are handled, not the hardware keyboard inputs.
716   */
717  onKeyPress?:
718    | ((e: NativeSyntheticEvent<TextInputKeyPressEventData>) => void)
719    | undefined;
720
721  /**
722   * The string that will be rendered before text input has been entered
723   */
724  placeholder?: string | undefined;
725
726  /**
727   * The text color of the placeholder string
728   */
729  placeholderTextColor?: ColorValue | undefined;
730
731  /**
732   * enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call')
733   * Determines how the return key should look.
734   */
735  returnKeyType?: ReturnKeyTypeOptions | undefined;
736
737  /**
738   * If true, the text input obscures the text entered so that sensitive text like passwords stay secure.
739   * The default value is false.
740   */
741  secureTextEntry?: boolean | undefined;
742
743  /**
744   * If true, all text will automatically be selected on focus
745   */
746  selectTextOnFocus?: boolean | undefined;
747
748  /**
749   * The start and end of the text input's selection. Set start and end to
750   * the same value to position the cursor.
751   */
752  selection?: {start: number; end?: number | undefined} | undefined;
753
754  /**
755   * The highlight (and cursor on ios) color of the text input
756   */
757  selectionColor?: ColorValue | undefined;
758
759  /**
760   * Styles
761   */
762  style?: StyleProp<TextStyle> | undefined;
763
764  /**
765   * Align the input text to the left, center, or right sides of the input field.
766   */
767  textAlign?: 'left' | 'center' | 'right' | undefined;
768
769  /**
770   * Used to locate this view in end-to-end tests
771   */
772  testID?: string | undefined;
773
774  /**
775   * Used to connect to an InputAccessoryView. Not part of react-natives documentation, but present in examples and
776   * code.
777   * See https://reactnative.dev/docs/inputaccessoryview for more information.
778   */
779  inputAccessoryViewID?: string | undefined;
780
781  /**
782   * The value to show for the text input. TextInput is a controlled component,
783   * which means the native value will be forced to match this value prop if provided.
784   * For most uses this works great, but in some cases this may cause flickering - one common cause is preventing edits by keeping value the same.
785   * In addition to simply setting the same value, either set editable={false},
786   * or set/update maxLength to prevent unwanted edits without flicker.
787   */
788  value?: string | undefined;
789
790  /**
791   * Specifies largest possible scale a font can reach when allowFontScaling is enabled. Possible values:
792   * - null/undefined (default): inherit from the parent node or the global default (0)
793   * - 0: no max, ignore parent/global default
794   * - >= 1: sets the maxFontSizeMultiplier of this node to this value
795   */
796  maxFontSizeMultiplier?: number | null | undefined;
797}
798
799/**
800 * This class is responsible for coordinating the "focused"
801 * state for TextInputs. All calls relating to the keyboard
802 * should be funneled through here
803 */
804interface TextInputState {
805  /**
806   * @deprecated Use currentlyFocusedInput
807   * Returns the ID of the currently focused text field, if one exists
808   * If no text field is focused it returns null
809   */
810  currentlyFocusedField(): number;
811
812  /**
813   * Returns the ref of the currently focused text field, if one exists
814   * If no text field is focused it returns null
815   */
816  currentlyFocusedInput(): React.ElementRef<HostComponent<unknown>>;
817
818  /**
819   * @param textField ref of the text field to focus
820   * Focuses the specified text field
821   * noop if the text field was already focused
822   */
823  focusTextInput(textField?: React.ElementRef<HostComponent<unknown>>): void;
824
825  /**
826   * @param textField ref of the text field to focus
827   * Unfocuses the specified text field
828   * noop if it wasn't focused
829   */
830  blurTextInput(textField?: React.ElementRef<HostComponent<unknown>>): void;
831}
832
833/**
834 * @see https://reactnative.dev/docs/textinput#methods
835 */
836declare class TextInputComponent extends React.Component<TextInputProps> {}
837declare const TextInputBase: Constructor<NativeMethods> &
838  Constructor<TimerMixin> &
839  typeof TextInputComponent;
840export class TextInput extends TextInputBase {
841  /**
842   * Access the current focus state.
843   */
844  static State: TextInputState;
845
846  /**
847   * Returns if the input is currently focused.
848   */
849  isFocused: () => boolean;
850
851  /**
852   * Removes all text from the input.
853   */
854  clear: () => void;
855}
856