@@ -32,6 +32,10 @@ const invariant = require('fbjs/lib/invariant');
32
32
const requireNativeComponent = require ( 'requireNativeComponent' ) ;
33
33
const warning = require ( 'fbjs/lib/warning' ) ;
34
34
35
+ import type { ColorValue } from 'StyleSheetTypes' ;
36
+ import type { TextStyleProp } from 'StyleSheet' ;
37
+ import type { ViewProps } from 'ViewPropTypes' ;
38
+
35
39
let AndroidTextInput ;
36
40
let RCTMultilineTextInputView ;
37
41
let RCTSinglelineTextInputView ;
@@ -69,6 +73,144 @@ const DataDetectorTypes = [
69
73
'all' ,
70
74
] ;
71
75
76
+ type DataDetectorTypesType =
77
+ | 'phoneNumber'
78
+ | 'link'
79
+ | 'address'
80
+ | 'calendarEvent'
81
+ | 'none'
82
+ | 'all' ;
83
+
84
+ export type KeyboardType =
85
+ // Cross Platform
86
+ | 'default'
87
+ | 'email-address'
88
+ | 'numeric'
89
+ | 'phone-pad'
90
+ | 'number-pad'
91
+ // iOS-only
92
+ | 'ascii-capable'
93
+ | 'numbers-and-punctuation'
94
+ | 'url'
95
+ | 'name-phone-pad'
96
+ | 'decimal-pad'
97
+ | 'twitter'
98
+ | 'web-search'
99
+ // Android-only
100
+ | 'visible-password' ;
101
+
102
+ export type ReturnKeyType =
103
+ // Cross Platform
104
+ | 'done'
105
+ | 'go'
106
+ | 'next'
107
+ | 'search'
108
+ | 'send'
109
+ // Android-only
110
+ | 'none'
111
+ | 'previous'
112
+ // iOS-only
113
+ | 'default'
114
+ | 'emergency-call'
115
+ | 'google'
116
+ | 'join'
117
+ | 'route'
118
+ | 'yahoo' ;
119
+
120
+ export type AutoCapitalize = 'none' | 'sentences' | 'words' | 'characters' ;
121
+
122
+ type IOSProps = $ReadOnly < { |
123
+ spellCheck ?: ?boolean ,
124
+ keyboardAppearance ?: ?( 'default' | 'light' | 'dark' ) ,
125
+ enablesReturnKeyAutomatically ?: ?boolean ,
126
+ selectionState ?: ?DocumentSelectionState ,
127
+ clearButtonMode ?: ?( 'never' | 'while-editing' | 'unless-editing' | 'always' ) ,
128
+ clearTextOnFocus ?: ?boolean ,
129
+ dataDetectorTypes ?:
130
+ | ?DataDetectorTypesType
131
+ | $ReadOnlyArray < DataDetectorTypesType > ,
132
+ inputAccessoryViewID ?: ?string ,
133
+ textContentType ?: ?(
134
+ | 'none'
135
+ | 'URL'
136
+ | 'addressCity'
137
+ | 'addressCityAndState'
138
+ | 'addressState'
139
+ | 'countryName'
140
+ | 'creditCardNumber'
141
+ | 'emailAddress'
142
+ | 'familyName'
143
+ | 'fullStreetAddress'
144
+ | 'givenName'
145
+ | 'jobTitle'
146
+ | 'location'
147
+ | 'middleName'
148
+ | 'name'
149
+ | 'namePrefix'
150
+ | 'nameSuffix'
151
+ | 'nickname'
152
+ | 'organizationName'
153
+ | 'postalCode'
154
+ | 'streetAddressLine1'
155
+ | 'streetAddressLine2'
156
+ | 'sublocality'
157
+ | 'telephoneNumber'
158
+ | 'username'
159
+ | 'password'
160
+ ) ,
161
+ | } > ;
162
+
163
+ type AndroidProps = $ReadOnly < { |
164
+ returnKeyLabel ?: ?string ,
165
+ numberOfLines ?: ?number ,
166
+ disableFullscreenUI ?: ?boolean ,
167
+ textBreakStrategy ?: ?( 'simple' | 'highQuality' | 'balanced' ) ,
168
+ underlineColorAndroid ?: ?ColorValue ,
169
+ inlineImageLeft ?: ?string ,
170
+ inlineImagePadding ?: ?number ,
171
+ | } > ;
172
+
173
+ type Props = $ReadOnly < { |
174
+ ...ViewProps ,
175
+ ...IOSProps ,
176
+ ...AndroidProps ,
177
+ autoCapitalize ?: ?AutoCapitalize ,
178
+ autoCorrect ?: ?boolean ,
179
+ autoFocus ?: ?boolean ,
180
+ allowFontScaling ?: ?boolean ,
181
+ editable ?: ?boolean ,
182
+ keyboardType ?: ?KeyboardType ,
183
+ returnKeyType ?: ?ReturnKeyType ,
184
+ maxLength ?: ?number ,
185
+ multiline ?: ?boolean ,
186
+ onBlur ?: ?Function ,
187
+ onFocus ?: ?Function ,
188
+ onChange ?: ?Function ,
189
+ onChangeText ?: ?Function ,
190
+ onContentSizeChange ?: ?Function ,
191
+ onTextInput ?: ?Function ,
192
+ onEndEditing ?: ?Function ,
193
+ onSelectionChange ?: ?Function ,
194
+ onSubmitEditing ?: ?Function ,
195
+ onKeyPress ?: ?Function ,
196
+ onScroll ?: ?Function ,
197
+ placeholder ?: ?Stringish ,
198
+ placeholderTextColor ?: ?ColorValue ,
199
+ secureTextEntry ?: ?boolean ,
200
+ selectionColor ?: ?ColorValue ,
201
+ selection ?: ?$ReadOnly < { |
202
+ start : number ,
203
+ end ?: ?number ,
204
+ | } > ,
205
+ value ?: ?Stringish ,
206
+ defaultValue ?: ?Stringish ,
207
+ selectTextOnFocus ?: ?boolean ,
208
+ blurOnSubmit ?: ?boolean ,
209
+ style ?: ?TextStyleProp ,
210
+ caretHidden ?: ?boolean ,
211
+ contextMenuHidden ?: ?boolean ,
212
+ | } > ;
213
+
72
214
/**
73
215
* A foundational component for inputting text into the app via a
74
216
* keyboard. Props provide configurability for several features, such as
@@ -1043,6 +1185,15 @@ const TextInput = createReactClass({
1043
1185
} ,
1044
1186
} ) ;
1045
1187
1188
+ class InternalTextInputType extends ReactNative . NativeComponent < Props > {
1189
+ clear ( ) { }
1190
+
1191
+ // $FlowFixMe
1192
+ isFocused ( ) : boolean { }
1193
+ }
1194
+
1195
+ const TypedTextInput = ( ( TextInput : any ) : Class < InternalTextInputType > ) ;
1196
+
1046
1197
const styles = StyleSheet . create ( {
1047
1198
multilineInput : {
1048
1199
// This default top inset makes RCTMultilineTextInputView seem as close as possible
@@ -1052,4 +1203,4 @@ const styles = StyleSheet.create({
1052
1203
} ,
1053
1204
} ) ;
1054
1205
1055
- module . exports = TextInput ;
1206
+ module . exports = TypedTextInput ;
0 commit comments