@@ -32,6 +32,10 @@ const invariant = require('fbjs/lib/invariant');
3232const requireNativeComponent = require ( 'requireNativeComponent' ) ;
3333const warning = require ( 'fbjs/lib/warning' ) ;
3434
35+ import type { ColorValue } from 'StyleSheetTypes' ;
36+ import type { TextStyleProp } from 'StyleSheet' ;
37+ import type { ViewProps } from 'ViewPropTypes' ;
38+
3539let AndroidTextInput ;
3640let RCTMultilineTextInputView ;
3741let RCTSinglelineTextInputView ;
@@ -69,6 +73,144 @@ const DataDetectorTypes = [
6973 'all' ,
7074] ;
7175
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+
72214/**
73215 * A foundational component for inputting text into the app via a
74216 * keyboard. Props provide configurability for several features, such as
@@ -1043,6 +1185,15 @@ const TextInput = createReactClass({
10431185 } ,
10441186} ) ;
10451187
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+
10461197const styles = StyleSheet . create ( {
10471198 multilineInput : {
10481199 // This default top inset makes RCTMultilineTextInputView seem as close as possible
@@ -1052,4 +1203,4 @@ const styles = StyleSheet.create({
10521203 } ,
10531204} ) ;
10541205
1055- module . exports = TextInput ;
1206+ module . exports = TypedTextInput ;
0 commit comments