@@ -25,13 +25,13 @@ import * as React from 'react';
25
25
26
26
type ReactRefSetter < T > = { current : null | T , ...} | ( ( ref : null | T ) => mixed ) ;
27
27
28
- export type ChangeEvent = SyntheticEvent <
29
- $ReadOnly < {
30
- eventCount : number ,
31
- target : number ,
32
- text : string ,
33
- } > ,
34
- > ;
28
+ export type TextInputChangeEventData = $ReadOnly < {
29
+ eventCount : number ,
30
+ target : number ,
31
+ text : string ,
32
+ } > ;
33
+
34
+ export type TextInputChangeEvent = SyntheticEvent < TextInputChangeEventData > ;
35
35
36
36
export type TextInputEvent = SyntheticEvent <
37
37
$ReadOnly < {
@@ -46,52 +46,56 @@ export type TextInputEvent = SyntheticEvent<
46
46
} > ,
47
47
> ;
48
48
49
- export type ContentSizeChangeEvent = SyntheticEvent <
50
- $ReadOnly < {
51
- target : number ,
52
- contentSize : $ReadOnly < {
53
- width : number ,
54
- height : number ,
55
- } > ,
49
+ export type TextInputContentSizeChangeEventData = $ReadOnly < {
50
+ target : number ,
51
+ contentSize : $ReadOnly < {
52
+ width : number ,
53
+ height : number ,
56
54
} > ,
57
- > ;
55
+ } > ;
58
56
59
- type TargetEvent = SyntheticEvent <
60
- $ReadOnly < {
61
- target : number ,
62
- } > ,
63
- > ;
57
+ export type TextInputContentSizeChangeEvent =
58
+ SyntheticEvent < TextInputContentSizeChangeEventData > ;
59
+
60
+ export type TargetEvent = $ReadOnly < {
61
+ target : number ,
62
+ } > ;
63
+
64
+ export type TextInputFocusEventData = TargetEvent ;
64
65
65
- export type BlurEvent = TargetEvent ;
66
- export type FocusEvent = TargetEvent ;
66
+ export type TextInputBlurEvent = SyntheticEvent < TextInputFocusEventData > ;
67
+ export type TextInputFocusEvent = SyntheticEvent < TextInputFocusEventData > ;
67
68
68
69
type Selection = $ReadOnly < {
69
70
start : number ,
70
71
end : number ,
71
72
} > ;
72
73
73
- export type SelectionChangeEvent = SyntheticEvent <
74
- $ReadOnly < {
75
- selection : Selection ,
76
- target : number ,
77
- } > ,
78
- > ;
74
+ export type TextInputSelectionChangeEventData = $ReadOnly < {
75
+ ...TargetEvent ,
76
+ selection : Selection ,
77
+ } > ;
79
78
80
- export type KeyPressEvent = SyntheticEvent <
81
- $ReadOnly < {
82
- key : string ,
83
- target ?: ?number ,
84
- eventCount ?: ?number ,
85
- } > ,
86
- > ;
79
+ export type TextInputSelectionChangeEvent =
80
+ SyntheticEvent < TextInputSelectionChangeEventData > ;
87
81
88
- export type EditingEvent = SyntheticEvent <
89
- $ReadOnly < {
90
- eventCount : number ,
91
- text : string ,
92
- target : number ,
93
- } > ,
94
- > ;
82
+ export type TextInputKeyPressEventData = $ReadOnly < {
83
+ ...TargetEvent ,
84
+ key : string ,
85
+ target ?: ?number ,
86
+ eventCount : number ,
87
+ } > ;
88
+
89
+ export type TextInputKeyPressEvent = SyntheticEvent < TextInputKeyPressEventData > ;
90
+
91
+ export type TextInputEndEditingEventData = $ReadOnly < {
92
+ ...TargetEvent ,
93
+ eventCount : number ,
94
+ text : string ,
95
+ } > ;
96
+
97
+ export type TextInputEditingEvent =
98
+ SyntheticEvent < TextInputEndEditingEventData > ;
95
99
96
100
type DataDetectorTypesType =
97
101
| 'phoneNumber'
@@ -727,12 +731,12 @@ export type Props = $ReadOnly<{
727
731
/**
728
732
* Callback that is called when the text input is blurred.
729
733
*/
730
- onBlur ?: ?( e : BlurEvent ) => mixed ,
734
+ onBlur ?: ?( e : TextInputBlurEvent ) => mixed ,
731
735
732
736
/**
733
737
* Callback that is called when the text input's text changes.
734
738
*/
735
- onChange ?: ?( e : ChangeEvent ) => mixed ,
739
+ onChange ?: ?( e : TextInputChangeEvent ) => mixed ,
736
740
737
741
/**
738
742
* DANGER: this API is not stable and will change in the future.
@@ -742,7 +746,7 @@ export type Props = $ReadOnly<{
742
746
*
743
747
* @platform ios
744
748
*/
745
- unstable_onChangeSync ?: ?( e : ChangeEvent ) => mixed ,
749
+ unstable_onChangeSync ?: ?( e : TextInputChangeEvent ) => mixed ,
746
750
747
751
/**
748
752
* Callback that is called when the text input's text changes.
@@ -768,17 +772,17 @@ export type Props = $ReadOnly<{
768
772
*
769
773
* Only called for multiline text inputs.
770
774
*/
771
- onContentSizeChange ?: ?( e : ContentSizeChangeEvent ) => mixed ,
775
+ onContentSizeChange ?: ?( e : TextInputContentSizeChangeEvent ) => mixed ,
772
776
773
777
/**
774
778
* Callback that is called when text input ends.
775
779
*/
776
- onEndEditing ?: ?( e : EditingEvent ) => mixed ,
780
+ onEndEditing ?: ?( e : TextInputEditingEvent ) => mixed ,
777
781
778
782
/**
779
783
* Callback that is called when the text input is focused.
780
784
*/
781
- onFocus ?: ?( e : FocusEvent ) => mixed ,
785
+ onFocus ?: ?( e : TextInputFocusEvent ) => mixed ,
782
786
783
787
/**
784
788
* Callback that is called when a key is pressed.
@@ -787,7 +791,7 @@ export type Props = $ReadOnly<{
787
791
* the typed-in character otherwise including `' '` for space.
788
792
* Fires before `onChange` callbacks.
789
793
*/
790
- onKeyPress ?: ?( e : KeyPressEvent ) => mixed ,
794
+ onKeyPress ?: ?( e : TextInputKeyPressEvent ) => mixed ,
791
795
792
796
/**
793
797
* DANGER: this API is not stable and will change in the future.
@@ -802,7 +806,7 @@ export type Props = $ReadOnly<{
802
806
*
803
807
* @platform ios
804
808
*/
805
- unstable_onKeyPressSync ?: ?( e : KeyPressEvent ) => mixed ,
809
+ unstable_onKeyPressSync ?: ?( e : TextInputKeyPressEvent ) => mixed ,
806
810
807
811
/**
808
812
* Called when a single tap gesture is detected.
@@ -824,13 +828,13 @@ export type Props = $ReadOnly<{
824
828
* This will be called with
825
829
* `{ nativeEvent: { selection: { start, end } } }`.
826
830
*/
827
- onSelectionChange ?: ?( e : SelectionChangeEvent ) => mixed ,
831
+ onSelectionChange ?: ?( e : TextInputSelectionChangeEvent ) => mixed ,
828
832
829
833
/**
830
834
* Callback that is called when the text input's submit button is pressed.
831
835
* Invalid if `multiline={true}` is specified.
832
836
*/
833
- onSubmitEditing ?: ?( e : EditingEvent ) => mixed ,
837
+ onSubmitEditing ?: ?( e : TextInputEditingEvent ) => mixed ,
834
838
835
839
/**
836
840
* Invoked on content scroll with `{ nativeEvent: { contentOffset: { x, y } } }`.
0 commit comments