1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | import type * as React from 'react';
|
11 | import {Constructor} from '../../../types/private/Utilities';
|
12 | import {TimerMixin} from '../../../types/private/TimerMixin';
|
13 | import {
|
14 | HostInstance,
|
15 | NativeMethods,
|
16 | } from '../../../types/public/ReactNativeTypes';
|
17 | import {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet';
|
18 | import {TextStyle} from '../../StyleSheet/StyleSheetTypes';
|
19 | import {
|
20 | NativeSyntheticEvent,
|
21 | NativeTouchEvent,
|
22 | TargetedEvent,
|
23 | } from '../../Types/CoreEventTypes';
|
24 | import EventEmitter from '../../vendor/emitter/EventEmitter';
|
25 | import {AccessibilityProps} from '../View/ViewAccessibility';
|
26 | import {ViewProps} from '../View/ViewPropTypes';
|
27 |
|
28 | export type KeyboardType =
|
29 | | 'default'
|
30 | | 'number-pad'
|
31 | | 'decimal-pad'
|
32 | | 'numeric'
|
33 | | 'email-address'
|
34 | | 'phone-pad'
|
35 | | 'url';
|
36 | export type KeyboardTypeIOS =
|
37 | | 'ascii-capable'
|
38 | | 'numbers-and-punctuation'
|
39 | | 'name-phone-pad'
|
40 | | 'twitter'
|
41 | | 'web-search';
|
42 | export type KeyboardTypeAndroid = 'visible-password';
|
43 | export type KeyboardTypeOptions =
|
44 | | KeyboardType
|
45 | | KeyboardTypeAndroid
|
46 | | KeyboardTypeIOS;
|
47 |
|
48 | export type InputModeOptions =
|
49 | | 'none'
|
50 | | 'text'
|
51 | | 'decimal'
|
52 | | 'numeric'
|
53 | | 'tel'
|
54 | | 'search'
|
55 | | 'email'
|
56 | | 'url';
|
57 |
|
58 | export type ReturnKeyType = 'done' | 'go' | 'next' | 'search' | 'send';
|
59 | export type ReturnKeyTypeAndroid = 'none' | 'previous';
|
60 | export type ReturnKeyTypeIOS =
|
61 | | 'default'
|
62 | | 'google'
|
63 | | 'join'
|
64 | | 'route'
|
65 | | 'yahoo'
|
66 | | 'emergency-call';
|
67 |
|
68 | export type ReturnKeyTypeOptions =
|
69 | | ReturnKeyType
|
70 | | ReturnKeyTypeAndroid
|
71 | | ReturnKeyTypeIOS;
|
72 |
|
73 | export type EnterKeyHintTypeAndroid = 'previous';
|
74 | export type EnterKeyHintTypeIOS = 'enter';
|
75 | export type EnterKeyHintType = 'done' | 'go' | 'next' | 'search' | 'send';
|
76 |
|
77 | export type EnterKeyHintTypeOptions =
|
78 | | EnterKeyHintType
|
79 | | EnterKeyHintTypeAndroid
|
80 | | EnterKeyHintTypeIOS;
|
81 |
|
82 | type DataDetectorTypes =
|
83 | | 'phoneNumber'
|
84 | | 'link'
|
85 | | 'address'
|
86 | | 'calendarEvent'
|
87 | | 'trackingNumber'
|
88 | | 'flightNumber'
|
89 | | 'lookupSuggestion'
|
90 | | 'none'
|
91 | | 'all';
|
92 |
|
93 | export type SubmitBehavior = 'submit' | 'blurAndSubmit' | 'newline';
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 | export interface DocumentSelectionState extends EventEmitter {
|
105 | new (anchor: number, focus: number): DocumentSelectionState;
|
106 |
|
107 | |
108 |
|
109 |
|
110 |
|
111 |
|
112 | update(anchor: number, focus: number): void;
|
113 |
|
114 | |
115 |
|
116 |
|
117 |
|
118 |
|
119 | constrainLength(maxLength: number): void;
|
120 |
|
121 | focus(): void;
|
122 | blur(): void;
|
123 | hasFocus(): boolean;
|
124 | isCollapsed(): boolean;
|
125 | isBackward(): boolean;
|
126 |
|
127 | getAnchorOffset(): number;
|
128 | getFocusOffset(): number;
|
129 | getStartOffset(): number;
|
130 | getEndOffset(): number;
|
131 | overlaps(start: number, end: number): boolean;
|
132 | }
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 | export interface TextInputIOSProps {
|
139 | |
140 |
|
141 |
|
142 | disableKeyboardShortcuts?: boolean | undefined;
|
143 |
|
144 | |
145 |
|
146 |
|
147 |
|
148 | clearButtonMode?:
|
149 | | 'never'
|
150 | | 'while-editing'
|
151 | | 'unless-editing'
|
152 | | 'always'
|
153 | | undefined;
|
154 |
|
155 | |
156 |
|
157 |
|
158 | clearTextOnFocus?: boolean | undefined;
|
159 |
|
160 | |
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 | dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[] | undefined;
|
177 |
|
178 | |
179 |
|
180 |
|
181 |
|
182 | enablesReturnKeyAutomatically?: boolean | undefined;
|
183 |
|
184 | |
185 |
|
186 |
|
187 | keyboardAppearance?: 'default' | 'light' | 'dark' | undefined;
|
188 |
|
189 | |
190 |
|
191 |
|
192 |
|
193 |
|
194 | passwordRules?: string | null | undefined;
|
195 |
|
196 | |
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 | rejectResponderTermination?: boolean | null | undefined;
|
203 |
|
204 | |
205 |
|
206 |
|
207 | selectionState?: DocumentSelectionState | undefined;
|
208 |
|
209 | |
210 |
|
211 |
|
212 | spellCheck?: boolean | undefined;
|
213 |
|
214 | |
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 | textContentType?:
|
271 | | 'none'
|
272 | | 'URL'
|
273 | | 'addressCity'
|
274 | | 'addressCityAndState'
|
275 | | 'addressState'
|
276 | | 'countryName'
|
277 | | 'creditCardNumber'
|
278 | | 'creditCardExpiration'
|
279 | | 'creditCardExpirationMonth'
|
280 | | 'creditCardExpirationYear'
|
281 | | 'creditCardSecurityCode'
|
282 | | 'creditCardType'
|
283 | | 'creditCardName'
|
284 | | 'creditCardGivenName'
|
285 | | 'creditCardMiddleName'
|
286 | | 'creditCardFamilyName'
|
287 | | 'emailAddress'
|
288 | | 'familyName'
|
289 | | 'fullStreetAddress'
|
290 | | 'givenName'
|
291 | | 'jobTitle'
|
292 | | 'location'
|
293 | | 'middleName'
|
294 | | 'name'
|
295 | | 'namePrefix'
|
296 | | 'nameSuffix'
|
297 | | 'nickname'
|
298 | | 'organizationName'
|
299 | | 'postalCode'
|
300 | | 'streetAddressLine1'
|
301 | | 'streetAddressLine2'
|
302 | | 'sublocality'
|
303 | | 'telephoneNumber'
|
304 | | 'username'
|
305 | | 'password'
|
306 | | 'newPassword'
|
307 | | 'oneTimeCode'
|
308 | | 'birthdate'
|
309 | | 'birthdateDay'
|
310 | | 'birthdateMonth'
|
311 | | 'birthdateYear'
|
312 | | 'cellularEID'
|
313 | | 'cellularIMEI'
|
314 | | 'dateTime'
|
315 | | 'flightNumber'
|
316 | | 'shipmentTrackingNumber'
|
317 | | undefined;
|
318 |
|
319 | |
320 |
|
321 |
|
322 | scrollEnabled?: boolean | undefined;
|
323 |
|
324 | |
325 |
|
326 |
|
327 | lineBreakStrategyIOS?:
|
328 | | 'none'
|
329 | | 'standard'
|
330 | | 'hangul-word'
|
331 | | 'push-out'
|
332 | | undefined;
|
333 |
|
334 | |
335 |
|
336 |
|
337 |
|
338 | lineBreakModeIOS?:
|
339 | | 'wordWrapping'
|
340 | | 'char'
|
341 | | 'clip'
|
342 | | 'head'
|
343 | | 'middle'
|
344 | | 'tail'
|
345 | | undefined;
|
346 |
|
347 | |
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 | smartInsertDelete?: boolean | undefined;
|
354 | }
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 | export interface TextInputAndroidProps {
|
361 | |
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 | cursorColor?: ColorValue | null | undefined;
|
368 |
|
369 | |
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 | selectionHandleColor?: ColorValue | null | undefined;
|
376 |
|
377 | |
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 | importantForAutofill?:
|
393 | | 'auto'
|
394 | | 'no'
|
395 | | 'noExcludeDescendants'
|
396 | | 'yes'
|
397 | | 'yesExcludeDescendants'
|
398 | | undefined;
|
399 |
|
400 | |
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 | disableFullscreenUI?: boolean | undefined;
|
407 |
|
408 | |
409 |
|
410 |
|
411 | inlineImageLeft?: string | undefined;
|
412 |
|
413 | |
414 |
|
415 |
|
416 | inlineImagePadding?: number | undefined;
|
417 |
|
418 | |
419 |
|
420 |
|
421 |
|
422 | numberOfLines?: number | undefined;
|
423 |
|
424 | |
425 |
|
426 |
|
427 |
|
428 | returnKeyLabel?: string | undefined;
|
429 |
|
430 | |
431 |
|
432 |
|
433 |
|
434 | textBreakStrategy?: 'simple' | 'highQuality' | 'balanced' | undefined;
|
435 |
|
436 | |
437 |
|
438 |
|
439 | underlineColorAndroid?: ColorValue | undefined;
|
440 |
|
441 | |
442 |
|
443 |
|
444 | textAlignVertical?: 'auto' | 'top' | 'bottom' | 'center' | undefined;
|
445 |
|
446 | |
447 |
|
448 |
|
449 | showSoftInputOnFocus?: boolean | undefined;
|
450 |
|
451 | |
452 |
|
453 |
|
454 | verticalAlign?: 'auto' | 'top' | 'bottom' | 'middle' | undefined;
|
455 | }
|
456 |
|
457 |
|
458 |
|
459 |
|
460 | export interface TextInputFocusEventData extends TargetedEvent {
|
461 | text: string;
|
462 | eventCount: number;
|
463 | }
|
464 |
|
465 |
|
466 |
|
467 |
|
468 | export interface TextInputScrollEventData {
|
469 | contentOffset: {x: number; y: number};
|
470 | }
|
471 |
|
472 |
|
473 |
|
474 |
|
475 | export interface TextInputSelectionChangeEventData extends TargetedEvent {
|
476 | selection: {
|
477 | start: number;
|
478 | end: number;
|
479 | };
|
480 | }
|
481 |
|
482 |
|
483 |
|
484 |
|
485 | export interface TextInputKeyPressEventData {
|
486 | key: string;
|
487 | }
|
488 |
|
489 |
|
490 |
|
491 |
|
492 | export interface TextInputChangeEventData extends TargetedEvent {
|
493 | eventCount: number;
|
494 | text: string;
|
495 | }
|
496 |
|
497 |
|
498 |
|
499 |
|
500 | export interface TextInputContentSizeChangeEventData {
|
501 | contentSize: {width: number; height: number};
|
502 | }
|
503 |
|
504 |
|
505 |
|
506 |
|
507 | export interface TextInputEndEditingEventData {
|
508 | text: string;
|
509 | }
|
510 |
|
511 |
|
512 |
|
513 |
|
514 | export interface TextInputSubmitEditingEventData {
|
515 | text: string;
|
516 | }
|
517 |
|
518 |
|
519 |
|
520 |
|
521 | export interface TextInputProps
|
522 | extends ViewProps,
|
523 | TextInputIOSProps,
|
524 | TextInputAndroidProps,
|
525 | AccessibilityProps {
|
526 | |
527 |
|
528 |
|
529 |
|
530 | allowFontScaling?: boolean | undefined;
|
531 |
|
532 | |
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 | autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters' | undefined;
|
542 |
|
543 | |
544 |
|
545 |
|
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 | autoComplete?:
|
610 | | 'additional-name'
|
611 | | 'address-line1'
|
612 | | 'address-line2'
|
613 | | 'birthdate-day'
|
614 | | 'birthdate-full'
|
615 | | 'birthdate-month'
|
616 | | 'birthdate-year'
|
617 | | 'cc-csc'
|
618 | | 'cc-exp'
|
619 | | 'cc-exp-day'
|
620 | | 'cc-exp-month'
|
621 | | 'cc-exp-year'
|
622 | | 'cc-number'
|
623 | | 'cc-name'
|
624 | | 'cc-given-name'
|
625 | | 'cc-middle-name'
|
626 | | 'cc-family-name'
|
627 | | 'cc-type'
|
628 | | 'country'
|
629 | | 'current-password'
|
630 | | 'email'
|
631 | | 'family-name'
|
632 | | 'gender'
|
633 | | 'given-name'
|
634 | | 'honorific-prefix'
|
635 | | 'honorific-suffix'
|
636 | | 'name'
|
637 | | 'name-family'
|
638 | | 'name-given'
|
639 | | 'name-middle'
|
640 | | 'name-middle-initial'
|
641 | | 'name-prefix'
|
642 | | 'name-suffix'
|
643 | | 'new-password'
|
644 | | 'nickname'
|
645 | | 'one-time-code'
|
646 | | 'organization'
|
647 | | 'organization-title'
|
648 | | 'password'
|
649 | | 'password-new'
|
650 | | 'postal-address'
|
651 | | 'postal-address-country'
|
652 | | 'postal-address-extended'
|
653 | | 'postal-address-extended-postal-code'
|
654 | | 'postal-address-locality'
|
655 | | 'postal-address-region'
|
656 | | 'postal-code'
|
657 | | 'street-address'
|
658 | | 'sms-otp'
|
659 | | 'tel'
|
660 | | 'tel-country-code'
|
661 | | 'tel-national'
|
662 | | 'tel-device'
|
663 | | 'url'
|
664 | | 'username'
|
665 | | 'username-new'
|
666 | | 'off'
|
667 | | undefined;
|
668 |
|
669 | |
670 |
|
671 |
|
672 |
|
673 | autoCorrect?: boolean | undefined;
|
674 |
|
675 | |
676 |
|
677 |
|
678 |
|
679 | autoFocus?: boolean | undefined;
|
680 |
|
681 | |
682 |
|
683 |
|
684 |
|
685 |
|
686 |
|
687 |
|
688 |
|
689 |
|
690 |
|
691 |
|
692 |
|
693 | blurOnSubmit?: boolean | undefined;
|
694 |
|
695 | |
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 |
|
708 |
|
709 |
|
710 |
|
711 |
|
712 |
|
713 | submitBehavior?: SubmitBehavior | undefined;
|
714 |
|
715 | |
716 |
|
717 |
|
718 | caretHidden?: boolean | undefined;
|
719 |
|
720 | |
721 |
|
722 |
|
723 | contextMenuHidden?: boolean | undefined;
|
724 |
|
725 | |
726 |
|
727 |
|
728 |
|
729 |
|
730 | defaultValue?: string | undefined;
|
731 |
|
732 | |
733 |
|
734 |
|
735 | editable?: boolean | undefined;
|
736 |
|
737 | |
738 |
|
739 |
|
740 |
|
741 |
|
742 |
|
743 |
|
744 |
|
745 | keyboardType?: KeyboardTypeOptions | undefined;
|
746 |
|
747 | |
748 |
|
749 |
|
750 | inputMode?: InputModeOptions | undefined;
|
751 |
|
752 | |
753 |
|
754 |
|
755 |
|
756 | maxLength?: number | undefined;
|
757 |
|
758 | |
759 |
|
760 |
|
761 | multiline?: boolean | undefined;
|
762 |
|
763 | |
764 |
|
765 |
|
766 | onBlur?:
|
767 | | ((e: NativeSyntheticEvent<TextInputFocusEventData>) => void)
|
768 | | undefined;
|
769 |
|
770 | /**
|
771 | * Callback that is called when the text input's text changes.
|
772 | */
|
773 | onChange?:
|
774 | | ((e: NativeSyntheticEvent<TextInputChangeEventData>) => void)
|
775 | | undefined;
|
776 |
|
777 | /**
|
778 | * Callback that is called when the text input's text changes.
|
779 | * Changed text is passed as an argument to the callback handler.
|
780 | */
|
781 | onChangeText?: ((text: string) => void) | undefined;
|
782 |
|
783 | /**
|
784 | * Callback that is called when the text input's content size changes.
|
785 | * This will be called with
|
786 | * `{ nativeEvent: { contentSize: { width, height } } }`.
|
787 | *
|
788 | * Only called for multiline text inputs.
|
789 | */
|
790 | onContentSizeChange?:
|
791 | | ((e: NativeSyntheticEvent<TextInputContentSizeChangeEventData>) => void)
|
792 | | undefined;
|
793 |
|
794 | /**
|
795 | * Callback that is called when text input ends.
|
796 | */
|
797 | onEndEditing?:
|
798 | | ((e: NativeSyntheticEvent<TextInputEndEditingEventData>) => void)
|
799 | | undefined;
|
800 |
|
801 | /**
|
802 | * Called when a single tap gesture is detected.
|
803 | */
|
804 | onPress?: ((e: NativeSyntheticEvent<NativeTouchEvent>) => void) | undefined;
|
805 |
|
806 | /**
|
807 | * Callback that is called when a touch is engaged.
|
808 | */
|
809 | onPressIn?: ((e: NativeSyntheticEvent<NativeTouchEvent>) => void) | undefined;
|
810 |
|
811 | /**
|
812 | * Callback that is called when a touch is released.
|
813 | */
|
814 | onPressOut?:
|
815 | | ((e: NativeSyntheticEvent<NativeTouchEvent>) => void)
|
816 | | undefined;
|
817 |
|
818 | /**
|
819 | * Callback that is called when the text input is focused
|
820 | */
|
821 | onFocus?:
|
822 | | ((e: NativeSyntheticEvent<TextInputFocusEventData>) => void)
|
823 | | undefined;
|
824 |
|
825 | /**
|
826 | * Callback that is called when the text input selection is changed.
|
827 | */
|
828 | onSelectionChange?:
|
829 | | ((e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => void)
|
830 | | undefined;
|
831 |
|
832 | /**
|
833 | * Callback that is called when the text input's submit button is pressed.
|
834 | */
|
835 | onSubmitEditing?:
|
836 | | ((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void)
|
837 | | undefined;
|
838 |
|
839 | /**
|
840 | * Invoked on content scroll with
|
841 | * `{ nativeEvent: { contentOffset: { x, y } } }`.
|
842 | *
|
843 | * May also contain other properties from ScrollEvent but on Android contentSize is not provided for performance reasons.
|
844 | */
|
845 | onScroll?:
|
846 | | ((e: NativeSyntheticEvent<TextInputScrollEventData>) => void)
|
847 | | undefined;
|
848 |
|
849 | /**
|
850 | * Callback that is called when a key is pressed.
|
851 | * This will be called with
|
852 | * `{ nativeEvent: { key: keyValue } }`
|
853 | * where keyValue is 'Enter' or 'Backspace' for respective keys and the typed-in character otherwise including ' ' for space.
|
854 | *
|
855 | * Fires before onChange callbacks.
|
856 | * Note: on Android only the inputs from soft keyboard are handled, not the hardware keyboard inputs.
|
857 | */
|
858 | onKeyPress?:
|
859 | | ((e: NativeSyntheticEvent<TextInputKeyPressEventData>) => void)
|
860 | | undefined;
|
861 |
|
862 | /**
|
863 | * The string that will be rendered before text input has been entered
|
864 | */
|
865 | placeholder?: string | undefined;
|
866 |
|
867 | /**
|
868 | * The text color of the placeholder string
|
869 | */
|
870 | placeholderTextColor?: ColorValue | undefined;
|
871 |
|
872 | /**
|
873 | * If `true`, text is not editable. The default value is `false`.
|
874 | */
|
875 | readOnly?: boolean | undefined;
|
876 |
|
877 | /**
|
878 | * enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call')
|
879 | * Determines how the return key should look.
|
880 | */
|
881 | returnKeyType?: ReturnKeyTypeOptions | undefined;
|
882 |
|
883 | /**
|
884 | * Determines what text should be shown to the return key on virtual keyboards.
|
885 | * Has precedence over the returnKeyType prop.
|
886 | */
|
887 | enterKeyHint?: EnterKeyHintTypeOptions | undefined;
|
888 |
|
889 | /**
|
890 | * If true, the text input obscures the text entered so that sensitive text like passwords stay secure.
|
891 | * The default value is false.
|
892 | */
|
893 | secureTextEntry?: boolean | undefined;
|
894 |
|
895 | /**
|
896 | * If true, all text will automatically be selected on focus
|
897 | */
|
898 | selectTextOnFocus?: boolean | undefined;
|
899 |
|
900 | /**
|
901 | * The start and end of the text input's selection. Set start and end to
|
902 | * the same value to position the cursor.
|
903 | */
|
904 | selection?: {start: number; end?: number | undefined} | undefined;
|
905 |
|
906 | /**
|
907 | * The highlight (and cursor on ios) color of the text input
|
908 | */
|
909 | selectionColor?: ColorValue | undefined;
|
910 |
|
911 | /**
|
912 | * Styles
|
913 | */
|
914 | style?: StyleProp<TextStyle> | undefined;
|
915 |
|
916 | /**
|
917 | * Align the input text to the left, center, or right sides of the input field.
|
918 | */
|
919 | textAlign?: 'left' | 'center' | 'right' | undefined;
|
920 |
|
921 | /**
|
922 | * Used to locate this view in end-to-end tests
|
923 | */
|
924 | testID?: string | undefined;
|
925 |
|
926 | /**
|
927 | * Used to connect to an InputAccessoryView. Not part of react-natives documentation, but present in examples and
|
928 | * code.
|
929 | * See https://reactnative.dev/docs/inputaccessoryview for more information.
|
930 | */
|
931 | inputAccessoryViewID?: string | undefined;
|
932 |
|
933 | /**
|
934 | * The value to show for the text input. TextInput is a controlled component,
|
935 | * which means the native value will be forced to match this value prop if provided.
|
936 | * 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.
|
937 | * In addition to simply setting the same value, either set editable={false},
|
938 | * or set/update maxLength to prevent unwanted edits without flicker.
|
939 | */
|
940 | value?: string | undefined;
|
941 |
|
942 | /**
|
943 | * Specifies largest possible scale a font can reach when allowFontScaling is enabled. Possible values:
|
944 | * - null/undefined (default): inherit from the parent node or the global default (0)
|
945 | * - 0: no max, ignore parent/global default
|
946 | * - >= 1: sets the maxFontSizeMultiplier of this node to this value
|
947 | */
|
948 | maxFontSizeMultiplier?: number | null | undefined;
|
949 | }
|
950 |
|
951 | /**
|
952 | * This class is responsible for coordinating the "focused"
|
953 | * state for TextInputs. All calls relating to the keyboard
|
954 | * should be funneled through here
|
955 | */
|
956 | interface TextInputState {
|
957 | /**
|
958 | * @deprecated Use currentlyFocusedInput
|
959 | * Returns the ID of the currently focused text field, if one exists
|
960 | * If no text field is focused it returns null
|
961 | */
|
962 | currentlyFocusedField(): number;
|
963 |
|
964 | /**
|
965 | * Returns the ref of the currently focused text field, if one exists
|
966 | * If no text field is focused it returns null
|
967 | */
|
968 | currentlyFocusedInput(): HostInstance;
|
969 |
|
970 | /**
|
971 | * @param textField ref of the text field to focus
|
972 | * Focuses the specified text field
|
973 | * noop if the text field was already focused
|
974 | */
|
975 | focusTextInput(textField?: HostInstance): void;
|
976 |
|
977 | /**
|
978 | * @param textField ref of the text field to focus
|
979 | * Unfocuses the specified text field
|
980 | * noop if it wasn't focused
|
981 | */
|
982 | blurTextInput(textField?: HostInstance): void;
|
983 | }
|
984 |
|
985 | /**
|
986 | * @see https://reactnative.dev/docs/textinput#methods
|
987 | */
|
988 | declare class TextInputComponent extends React.Component<TextInputProps> {}
|
989 | declare const TextInputBase: Constructor<NativeMethods> &
|
990 | Constructor<TimerMixin> &
|
991 | typeof TextInputComponent;
|
992 | export class TextInput extends TextInputBase {
|
993 | /**
|
994 | * Access the current focus state.
|
995 | */
|
996 | static State: TextInputState;
|
997 |
|
998 | /**
|
999 | * Returns if the input is currently focused.
|
1000 | */
|
1001 | isFocused: () => boolean;
|
1002 |
|
1003 | |
1004 |
|
1005 |
|
1006 | clear: () => void;
|
1007 |
|
1008 | |
1009 |
|
1010 |
|
1011 | setSelection: (start: number, end: number) => void;
|
1012 | }
|