@office-iss/react-native-win32 0.71.0 → 0.71.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.flowconfig +1 -0
- package/CHANGELOG.json +12667 -12652
- package/CHANGELOG.md +23 -15
- package/Libraries/Components/Button/ButtonWin32.Props.d.ts +2 -2
- package/Libraries/Components/Button/ButtonWin32.d.ts +1 -1
- package/Libraries/Components/Button/ButtonWin32.js +6 -4
- package/Libraries/Components/Button/ButtonWin32.js.map +1 -1
- package/Libraries/Components/Pressable/Pressable.win32.js +0 -1
- package/Libraries/Components/Text/TextWin32.Props.d.ts +3 -9
- package/Libraries/Components/Text/TextWin32.Props.js.map +1 -1
- package/Libraries/Components/Text/TextWin32.d.ts +1 -1
- package/Libraries/Components/Text/TextWin32.js.map +1 -1
- package/Libraries/Components/TextInput/TextInput.Types.win32.d.ts +9 -9
- package/Libraries/Components/TextInput/TextInput.win32.js +1150 -154
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js +4 -4
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.d.ts +119 -16
- package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +99 -24
- package/Libraries/Components/Touchable/TouchableWin32.Props.d.ts +2 -2
- package/Libraries/Components/Touchable/TouchableWin32.Props.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableWin32.Types.d.ts +9 -9
- package/Libraries/Components/Touchable/TouchableWin32.js +5 -6
- package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
- package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +29 -10
- package/Libraries/Components/View/Tests/ViewWin32Test.js +31 -51
- package/Libraries/Components/View/Tests/ViewWin32Test.js.map +1 -1
- package/Libraries/Components/View/ViewAccessibility.win32.d.ts +527 -0
- package/Libraries/Components/View/ViewAccessibility.win32.js +178 -0
- package/Libraries/Components/View/ViewPropTypes.win32.d.ts +372 -0
- package/Libraries/Components/View/ViewPropTypes.win32.js +23 -0
- package/Libraries/Components/View/ViewWin32.d.ts +30 -12
- package/Libraries/Components/View/ViewWin32.js +161 -71
- package/Libraries/Image/Image.win32.js +0 -1
- package/Libraries/Pressability/Pressability.win32.js +2 -2
- package/Libraries/Utilities/AcessibilityMapping.win32.js +156 -0
- package/Libraries/__tests__/ButtonWin32-test.js +1 -1
- package/Libraries/platform-types.d.ts +7 -13
- package/index.win32.js +1 -1
- package/jest.config.js +2 -4
- package/overrides.json +38 -8
- package/package.json +5 -5
- package/src/Libraries/Components/Button/ButtonWin32.tsx +8 -8
- package/src/Libraries/Components/Text/TextWin32.Props.ts +2 -15
- package/src/Libraries/Components/Text/TextWin32.tsx +6 -2
- package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +5 -5
- package/src/Libraries/Components/Touchable/TouchableNativeFeedback.win32.d.ts +119 -0
- package/src/Libraries/Components/Touchable/TouchableWin32.Props.tsx +1 -1
- package/src/Libraries/Components/Touchable/TouchableWin32.tsx +6 -7
- package/src/Libraries/Components/View/Tests/ViewWin32Test.tsx +28 -52
- package/src/Libraries/Components/View/ViewAccessibility.win32.d.ts +527 -0
- package/src/Libraries/Components/View/ViewPropTypes.win32.d.ts +372 -0
- package/src/Libraries/Components/View/ViewWin32.d.ts +30 -0
- package/src/Libraries/platform-types.d.ts +7 -13
- package/types/modules/BatchedBridge.d.ts +32 -0
- package/types/modules/Codegen.d.ts +74 -0
- package/types/modules/Devtools.d.ts +31 -0
- package/types/modules/LaunchScreen.d.ts +18 -0
- package/types/modules/globals.d.ts +577 -0
- package/types/private/TimerMixin.d.ts +19 -0
- package/types/private/Utilities.d.ts +10 -0
- package/types/public/DeprecatedPropertiesAlias.d.ts +205 -0
- package/types/public/Insets.d.ts +15 -0
- package/types/public/ReactNativeRenderer.d.ts +149 -0
- package/types/public/ReactNativeTypes.d.ts +143 -0
- package/Libraries/Components/TextInput/TextInput.win32.d.ts +0 -68
- package/Libraries/Components/TextInput/TextInput.win32.js.map +0 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.Props.d.ts +0 -7
- package/Libraries/Components/Touchable/TouchableNativeFeedback.Props.js +0 -3
- package/Libraries/Components/Touchable/TouchableNativeFeedback.Props.js.map +0 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js.map +0 -1
- package/Libraries/Components/View/ViewWin32.Props.d.ts +0 -174
- package/Libraries/Components/View/ViewWin32.Props.js +0 -11
- package/Libraries/Components/View/ViewWin32.Props.js.map +0 -1
- package/Libraries/Components/View/ViewWin32.js.map +0 -1
- package/src/Libraries/Components/TextInput/TextInput.win32.tsx +0 -217
- package/src/Libraries/Components/Touchable/TouchableNativeFeedback.Props.ts +0 -9
- package/src/Libraries/Components/Touchable/TouchableNativeFeedback.win32.tsx +0 -27
- package/src/Libraries/Components/View/ViewWin32.Props.ts +0 -281
- package/src/Libraries/Components/View/ViewWin32.tsx +0 -119
|
@@ -1,154 +1,1150 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This is a forked and slightly modified version of React Native's TextInput.
|
|
3
|
+
* The fork is necessary as platform checks in the base implementation made the
|
|
4
|
+
* control unusable on win32. In addition to cleaning up some of the code, this
|
|
5
|
+
* fork also uses Typescript rather than Flow for type safety.
|
|
6
|
+
*
|
|
7
|
+
* More general documentation on this control can be found at
|
|
8
|
+
* https://facebook.github.io/react-native/docs/textinput.html
|
|
9
|
+
*
|
|
10
|
+
* The original implementation can be found at
|
|
11
|
+
* https://github.com/facebook/react-native/blob/1013a010492a7bef5ff58073a088ac924a986e9e/Libraries/Components/TextInput/TextInput.js
|
|
12
|
+
*
|
|
13
|
+
* This control does not support the full React Native TextInput interface yet.
|
|
14
|
+
* Most of the work necessary to make that happen needs to happen on the native side.
|
|
15
|
+
* Future work on the JS side may include:
|
|
16
|
+
* 1. Expanded typings for some of the events
|
|
17
|
+
* 2. Additional work to manage selection
|
|
18
|
+
* 3. Any base/default styling work
|
|
19
|
+
*
|
|
20
|
+
* @flow strict-local
|
|
21
|
+
* @format
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
|
|
25
|
+
import {findNodeHandle} from '../../ReactNative/RendererProxy';
|
|
26
|
+
import UIManager from '../../ReactNative/UIManager';
|
|
27
|
+
import requireNativeComponent from '../../ReactNative/requireNativeComponent';
|
|
28
|
+
import * as React from 'react';
|
|
29
|
+
import TextAncestor from '../../Text/TextAncestor';
|
|
30
|
+
import TextInputState from './TextInputState';
|
|
31
|
+
import type {ViewProps} from '../View/ViewPropTypes';
|
|
32
|
+
import type {
|
|
33
|
+
PressEvent,
|
|
34
|
+
ScrollEvent,
|
|
35
|
+
SyntheticEvent,
|
|
36
|
+
} from '../../Types/CoreEventTypes';
|
|
37
|
+
import StyleSheet, {
|
|
38
|
+
type ColorValue,
|
|
39
|
+
type TextStyleProp,
|
|
40
|
+
type ViewStyleProp,
|
|
41
|
+
} from '../../StyleSheet/StyleSheet';
|
|
42
|
+
|
|
43
|
+
type ReactRefSetter<T> = {current: null | T, ...} | ((ref: null | T) => mixed);
|
|
44
|
+
type TextInputInstance = React.ElementRef<HostComponent<mixed>> & {
|
|
45
|
+
+clear: () => void,
|
|
46
|
+
+isFocused: () => boolean,
|
|
47
|
+
+getNativeRef: () => ?React.ElementRef<HostComponent<mixed>>,
|
|
48
|
+
+setSelection: (start: number, end: number) => void,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type ChangeEvent = SyntheticEvent<
|
|
52
|
+
$ReadOnly<{|
|
|
53
|
+
eventCount: number,
|
|
54
|
+
target: number,
|
|
55
|
+
text: string,
|
|
56
|
+
|}>,
|
|
57
|
+
>;
|
|
58
|
+
|
|
59
|
+
export type TextInputEvent = SyntheticEvent<
|
|
60
|
+
$ReadOnly<{|
|
|
61
|
+
eventCount: number,
|
|
62
|
+
previousText: string,
|
|
63
|
+
range: $ReadOnly<{|
|
|
64
|
+
start: number,
|
|
65
|
+
end: number,
|
|
66
|
+
|}>,
|
|
67
|
+
target: number,
|
|
68
|
+
text: string,
|
|
69
|
+
|}>,
|
|
70
|
+
>;
|
|
71
|
+
|
|
72
|
+
export type ContentSizeChangeEvent = SyntheticEvent<
|
|
73
|
+
$ReadOnly<{|
|
|
74
|
+
target: number,
|
|
75
|
+
contentSize: $ReadOnly<{|
|
|
76
|
+
width: number,
|
|
77
|
+
height: number,
|
|
78
|
+
|}>,
|
|
79
|
+
|}>,
|
|
80
|
+
>;
|
|
81
|
+
|
|
82
|
+
type TargetEvent = SyntheticEvent<
|
|
83
|
+
$ReadOnly<{|
|
|
84
|
+
target: number,
|
|
85
|
+
|}>,
|
|
86
|
+
>;
|
|
87
|
+
|
|
88
|
+
export type BlurEvent = TargetEvent;
|
|
89
|
+
export type FocusEvent = TargetEvent;
|
|
90
|
+
|
|
91
|
+
type Selection = $ReadOnly<{|
|
|
92
|
+
start: number,
|
|
93
|
+
end: number,
|
|
94
|
+
|}>;
|
|
95
|
+
|
|
96
|
+
export type SelectionChangeEvent = SyntheticEvent<
|
|
97
|
+
$ReadOnly<{|
|
|
98
|
+
selection: Selection,
|
|
99
|
+
target: number,
|
|
100
|
+
|}>,
|
|
101
|
+
>;
|
|
102
|
+
|
|
103
|
+
export type KeyPressEvent = SyntheticEvent<
|
|
104
|
+
$ReadOnly<{|
|
|
105
|
+
key: string,
|
|
106
|
+
target?: ?number,
|
|
107
|
+
eventCount?: ?number,
|
|
108
|
+
|}>,
|
|
109
|
+
>;
|
|
110
|
+
|
|
111
|
+
export type EditingEvent = SyntheticEvent<
|
|
112
|
+
$ReadOnly<{|
|
|
113
|
+
eventCount: number,
|
|
114
|
+
text: string,
|
|
115
|
+
target: number,
|
|
116
|
+
|}>,
|
|
117
|
+
>;
|
|
118
|
+
|
|
119
|
+
type DataDetectorTypesType =
|
|
120
|
+
| 'phoneNumber'
|
|
121
|
+
| 'link'
|
|
122
|
+
| 'address'
|
|
123
|
+
| 'calendarEvent'
|
|
124
|
+
| 'none'
|
|
125
|
+
| 'all';
|
|
126
|
+
|
|
127
|
+
export type KeyboardType =
|
|
128
|
+
// Cross Platform
|
|
129
|
+
| 'default'
|
|
130
|
+
| 'email-address'
|
|
131
|
+
| 'numeric'
|
|
132
|
+
| 'phone-pad'
|
|
133
|
+
| 'number-pad'
|
|
134
|
+
| 'decimal-pad'
|
|
135
|
+
| 'url'
|
|
136
|
+
// iOS-only
|
|
137
|
+
| 'ascii-capable'
|
|
138
|
+
| 'numbers-and-punctuation'
|
|
139
|
+
| 'name-phone-pad'
|
|
140
|
+
| 'twitter'
|
|
141
|
+
| 'web-search'
|
|
142
|
+
// iOS 10+ only
|
|
143
|
+
| 'ascii-capable-number-pad'
|
|
144
|
+
// Android-only
|
|
145
|
+
| 'visible-password';
|
|
146
|
+
|
|
147
|
+
export type InputMode =
|
|
148
|
+
| 'none'
|
|
149
|
+
| 'text'
|
|
150
|
+
| 'decimal'
|
|
151
|
+
| 'numeric'
|
|
152
|
+
| 'tel'
|
|
153
|
+
| 'search'
|
|
154
|
+
| 'email'
|
|
155
|
+
| 'url';
|
|
156
|
+
|
|
157
|
+
export type ReturnKeyType =
|
|
158
|
+
// Cross Platform
|
|
159
|
+
| 'done'
|
|
160
|
+
| 'go'
|
|
161
|
+
| 'next'
|
|
162
|
+
| 'search'
|
|
163
|
+
| 'send'
|
|
164
|
+
// Android-only
|
|
165
|
+
| 'none'
|
|
166
|
+
| 'previous'
|
|
167
|
+
// iOS-only
|
|
168
|
+
| 'default'
|
|
169
|
+
| 'emergency-call'
|
|
170
|
+
| 'google'
|
|
171
|
+
| 'join'
|
|
172
|
+
| 'route'
|
|
173
|
+
| 'yahoo';
|
|
174
|
+
|
|
175
|
+
export type SubmitBehavior = 'submit' | 'blurAndSubmit' | 'newline';
|
|
176
|
+
|
|
177
|
+
export type AutoCapitalize = 'none' | 'sentences' | 'words' | 'characters';
|
|
178
|
+
|
|
179
|
+
export type TextContentType =
|
|
180
|
+
| 'none'
|
|
181
|
+
| 'URL'
|
|
182
|
+
| 'addressCity'
|
|
183
|
+
| 'addressCityAndState'
|
|
184
|
+
| 'addressState'
|
|
185
|
+
| 'countryName'
|
|
186
|
+
| 'creditCardNumber'
|
|
187
|
+
| 'emailAddress'
|
|
188
|
+
| 'familyName'
|
|
189
|
+
| 'fullStreetAddress'
|
|
190
|
+
| 'givenName'
|
|
191
|
+
| 'jobTitle'
|
|
192
|
+
| 'location'
|
|
193
|
+
| 'middleName'
|
|
194
|
+
| 'name'
|
|
195
|
+
| 'namePrefix'
|
|
196
|
+
| 'nameSuffix'
|
|
197
|
+
| 'nickname'
|
|
198
|
+
| 'organizationName'
|
|
199
|
+
| 'postalCode'
|
|
200
|
+
| 'streetAddressLine1'
|
|
201
|
+
| 'streetAddressLine2'
|
|
202
|
+
| 'sublocality'
|
|
203
|
+
| 'telephoneNumber'
|
|
204
|
+
| 'username'
|
|
205
|
+
| 'password'
|
|
206
|
+
| 'newPassword'
|
|
207
|
+
| 'oneTimeCode';
|
|
208
|
+
|
|
209
|
+
export type enterKeyHintType =
|
|
210
|
+
| 'enter'
|
|
211
|
+
| 'done'
|
|
212
|
+
| 'go'
|
|
213
|
+
| 'next'
|
|
214
|
+
| 'previous'
|
|
215
|
+
| 'search'
|
|
216
|
+
| 'send';
|
|
217
|
+
|
|
218
|
+
type PasswordRules = string;
|
|
219
|
+
|
|
220
|
+
type IOSProps = $ReadOnly<{|
|
|
221
|
+
/**
|
|
222
|
+
* Give the keyboard and the system information about the
|
|
223
|
+
* expected semantic meaning for the content that users enter.
|
|
224
|
+
* @platform ios
|
|
225
|
+
*/
|
|
226
|
+
autoComplete?: ?(
|
|
227
|
+
| 'address-line1'
|
|
228
|
+
| 'address-line2'
|
|
229
|
+
| 'cc-number'
|
|
230
|
+
| 'current-password'
|
|
231
|
+
| 'country'
|
|
232
|
+
| 'email'
|
|
233
|
+
| 'name'
|
|
234
|
+
| 'additional-name'
|
|
235
|
+
| 'family-name'
|
|
236
|
+
| 'given-name'
|
|
237
|
+
| 'nickname'
|
|
238
|
+
| 'honorific-prefix'
|
|
239
|
+
| 'honorific-suffix'
|
|
240
|
+
| 'new-password'
|
|
241
|
+
| 'off'
|
|
242
|
+
| 'one-time-code'
|
|
243
|
+
| 'organization'
|
|
244
|
+
| 'organization-title'
|
|
245
|
+
| 'postal-code'
|
|
246
|
+
| 'street-address'
|
|
247
|
+
| 'tel'
|
|
248
|
+
| 'url'
|
|
249
|
+
| 'username'
|
|
250
|
+
),
|
|
251
|
+
/**
|
|
252
|
+
* When the clear button should appear on the right side of the text view.
|
|
253
|
+
* This property is supported only for single-line TextInput component.
|
|
254
|
+
* @platform ios
|
|
255
|
+
*/
|
|
256
|
+
clearButtonMode?: ?('never' | 'while-editing' | 'unless-editing' | 'always'),
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* If `true`, clears the text field automatically when editing begins.
|
|
260
|
+
* @platform ios
|
|
261
|
+
*/
|
|
262
|
+
clearTextOnFocus?: ?boolean,
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Determines the types of data converted to clickable URLs in the text input.
|
|
266
|
+
* Only valid if `multiline={true}` and `editable={false}`.
|
|
267
|
+
* By default no data types are detected.
|
|
268
|
+
*
|
|
269
|
+
* You can provide one type or an array of many types.
|
|
270
|
+
*
|
|
271
|
+
* Possible values for `dataDetectorTypes` are:
|
|
272
|
+
*
|
|
273
|
+
* - `'phoneNumber'`
|
|
274
|
+
* - `'link'`
|
|
275
|
+
* - `'address'`
|
|
276
|
+
* - `'calendarEvent'`
|
|
277
|
+
* - `'none'`
|
|
278
|
+
* - `'all'`
|
|
279
|
+
*
|
|
280
|
+
* @platform ios
|
|
281
|
+
*/
|
|
282
|
+
dataDetectorTypes?:
|
|
283
|
+
| ?DataDetectorTypesType
|
|
284
|
+
| $ReadOnlyArray<DataDetectorTypesType>,
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* If `true`, the keyboard disables the return key when there is no text and
|
|
288
|
+
* automatically enables it when there is text. The default value is `false`.
|
|
289
|
+
* @platform ios
|
|
290
|
+
*/
|
|
291
|
+
enablesReturnKeyAutomatically?: ?boolean,
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* An optional identifier which links a custom InputAccessoryView to
|
|
295
|
+
* this text input. The InputAccessoryView is rendered above the
|
|
296
|
+
* keyboard when this text input is focused.
|
|
297
|
+
* @platform ios
|
|
298
|
+
*/
|
|
299
|
+
inputAccessoryViewID?: ?string,
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Determines the color of the keyboard.
|
|
303
|
+
* @platform ios
|
|
304
|
+
*/
|
|
305
|
+
keyboardAppearance?: ?('default' | 'light' | 'dark'),
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Provide rules for your password.
|
|
309
|
+
* 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.
|
|
310
|
+
* "required: upper; required: lower; required: digit; max-consecutive: 2; minlength: 8;"
|
|
311
|
+
* @platform ios
|
|
312
|
+
*/
|
|
313
|
+
passwordRules?: ?PasswordRules,
|
|
314
|
+
|
|
315
|
+
/*
|
|
316
|
+
* If `true`, allows TextInput to pass touch events to the parent component.
|
|
317
|
+
* This allows components to be swipeable from the TextInput on iOS,
|
|
318
|
+
* as is the case on Android by default.
|
|
319
|
+
* If `false`, TextInput always asks to handle the input (except when disabled).
|
|
320
|
+
* @platform ios
|
|
321
|
+
*/
|
|
322
|
+
rejectResponderTermination?: ?boolean,
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* If `false`, scrolling of the text view will be disabled.
|
|
326
|
+
* The default value is `true`. Does only work with 'multiline={true}'.
|
|
327
|
+
* @platform ios
|
|
328
|
+
*/
|
|
329
|
+
scrollEnabled?: ?boolean,
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* If `false`, disables spell-check style (i.e. red underlines).
|
|
333
|
+
* The default value is inherited from `autoCorrect`.
|
|
334
|
+
* @platform ios
|
|
335
|
+
*/
|
|
336
|
+
spellCheck?: ?boolean,
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Give the keyboard and the system information about the
|
|
340
|
+
* expected semantic meaning for the content that users enter.
|
|
341
|
+
* @platform ios
|
|
342
|
+
*/
|
|
343
|
+
textContentType?: ?TextContentType,
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Set line break strategy on iOS.
|
|
347
|
+
* @platform ios
|
|
348
|
+
*/
|
|
349
|
+
lineBreakStrategyIOS?: ?('none' | 'standard' | 'hangul-word' | 'push-out'),
|
|
350
|
+
|}>;
|
|
351
|
+
|
|
352
|
+
type AndroidProps = $ReadOnly<{|
|
|
353
|
+
/**
|
|
354
|
+
* 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.
|
|
355
|
+
* To disable autocomplete, set `autoComplete` to `off`.
|
|
356
|
+
*
|
|
357
|
+
* *Android Only*
|
|
358
|
+
*
|
|
359
|
+
* Possible values for `autoComplete` are:
|
|
360
|
+
*
|
|
361
|
+
* - `birthdate-day`
|
|
362
|
+
* - `birthdate-full`
|
|
363
|
+
* - `birthdate-month`
|
|
364
|
+
* - `birthdate-year`
|
|
365
|
+
* - `cc-csc`
|
|
366
|
+
* - `cc-exp`
|
|
367
|
+
* - `cc-exp-day`
|
|
368
|
+
* - `cc-exp-month`
|
|
369
|
+
* - `cc-exp-year`
|
|
370
|
+
* - `cc-number`
|
|
371
|
+
* - `email`
|
|
372
|
+
* - `gender`
|
|
373
|
+
* - `name`
|
|
374
|
+
* - `name-family`
|
|
375
|
+
* - `name-given`
|
|
376
|
+
* - `name-middle`
|
|
377
|
+
* - `name-middle-initial`
|
|
378
|
+
* - `name-prefix`
|
|
379
|
+
* - `name-suffix`
|
|
380
|
+
* - `password`
|
|
381
|
+
* - `password-new`
|
|
382
|
+
* - `postal-address`
|
|
383
|
+
* - `postal-address-country`
|
|
384
|
+
* - `postal-address-extended`
|
|
385
|
+
* - `postal-address-extended-postal-code`
|
|
386
|
+
* - `postal-address-locality`
|
|
387
|
+
* - `postal-address-region`
|
|
388
|
+
* - `postal-code`
|
|
389
|
+
* - `street-address`
|
|
390
|
+
* - `sms-otp`
|
|
391
|
+
* - `tel`
|
|
392
|
+
* - `tel-country-code`
|
|
393
|
+
* - `tel-national`
|
|
394
|
+
* - `tel-device`
|
|
395
|
+
* - `username`
|
|
396
|
+
* - `username-new`
|
|
397
|
+
* - `off`
|
|
398
|
+
*
|
|
399
|
+
* @platform android
|
|
400
|
+
*/
|
|
401
|
+
autoComplete?: ?(
|
|
402
|
+
| 'birthdate-day'
|
|
403
|
+
| 'birthdate-full'
|
|
404
|
+
| 'birthdate-month'
|
|
405
|
+
| 'birthdate-year'
|
|
406
|
+
| 'cc-csc'
|
|
407
|
+
| 'cc-exp'
|
|
408
|
+
| 'cc-exp-day'
|
|
409
|
+
| 'cc-exp-month'
|
|
410
|
+
| 'cc-exp-year'
|
|
411
|
+
| 'cc-number'
|
|
412
|
+
| 'email'
|
|
413
|
+
| 'gender'
|
|
414
|
+
| 'name'
|
|
415
|
+
| 'name-family'
|
|
416
|
+
| 'name-given'
|
|
417
|
+
| 'name-middle'
|
|
418
|
+
| 'name-middle-initial'
|
|
419
|
+
| 'name-prefix'
|
|
420
|
+
| 'name-suffix'
|
|
421
|
+
| 'password'
|
|
422
|
+
| 'password-new'
|
|
423
|
+
| 'postal-address'
|
|
424
|
+
| 'postal-address-country'
|
|
425
|
+
| 'postal-address-extended'
|
|
426
|
+
| 'postal-address-extended-postal-code'
|
|
427
|
+
| 'postal-address-locality'
|
|
428
|
+
| 'postal-address-region'
|
|
429
|
+
| 'postal-code'
|
|
430
|
+
| 'street-address'
|
|
431
|
+
| 'sms-otp'
|
|
432
|
+
| 'tel'
|
|
433
|
+
| 'tel-country-code'
|
|
434
|
+
| 'tel-national'
|
|
435
|
+
| 'tel-device'
|
|
436
|
+
| 'username'
|
|
437
|
+
| 'username-new'
|
|
438
|
+
| 'off'
|
|
439
|
+
// additional HTML autocomplete values
|
|
440
|
+
| 'address-line1'
|
|
441
|
+
| 'address-line2'
|
|
442
|
+
| 'bday'
|
|
443
|
+
| 'bday-day'
|
|
444
|
+
| 'bday-month'
|
|
445
|
+
| 'bday-year'
|
|
446
|
+
| 'country'
|
|
447
|
+
| 'current-password'
|
|
448
|
+
| 'honorific-prefix'
|
|
449
|
+
| 'honorific-suffix'
|
|
450
|
+
| 'additional-name'
|
|
451
|
+
| 'family-name'
|
|
452
|
+
| 'given-name'
|
|
453
|
+
| 'new-password'
|
|
454
|
+
| 'one-time-code'
|
|
455
|
+
| 'sex'
|
|
456
|
+
),
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* When provided it will set the color of the cursor (or "caret") in the component.
|
|
460
|
+
* Unlike the behavior of `selectionColor` the cursor color will be set independently
|
|
461
|
+
* from the color of the text selection box.
|
|
462
|
+
* @platform android
|
|
463
|
+
*/
|
|
464
|
+
cursorColor?: ?ColorValue,
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* When `false`, if there is a small amount of space available around a text input
|
|
468
|
+
* (e.g. landscape orientation on a phone), the OS may choose to have the user edit
|
|
469
|
+
* the text inside of a full screen text input mode. When `true`, this feature is
|
|
470
|
+
* disabled and users will always edit the text directly inside of the text input.
|
|
471
|
+
* Defaults to `false`.
|
|
472
|
+
* @platform android
|
|
473
|
+
*/
|
|
474
|
+
disableFullscreenUI?: ?boolean,
|
|
475
|
+
|
|
476
|
+
importantForAutofill?: ?(
|
|
477
|
+
| 'auto'
|
|
478
|
+
| 'no'
|
|
479
|
+
| 'noExcludeDescendants'
|
|
480
|
+
| 'yes'
|
|
481
|
+
| 'yesExcludeDescendants'
|
|
482
|
+
),
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* If defined, the provided image resource will be rendered on the left.
|
|
486
|
+
* The image resource must be inside `/android/app/src/main/res/drawable` and referenced
|
|
487
|
+
* like
|
|
488
|
+
* ```
|
|
489
|
+
* <TextInput
|
|
490
|
+
* inlineImageLeft='search_icon'
|
|
491
|
+
* />
|
|
492
|
+
* ```
|
|
493
|
+
* @platform android
|
|
494
|
+
*/
|
|
495
|
+
inlineImageLeft?: ?string,
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Padding between the inline image, if any, and the text input itself.
|
|
499
|
+
* @platform android
|
|
500
|
+
*/
|
|
501
|
+
inlineImagePadding?: ?number,
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Sets the number of lines for a `TextInput`. Use it with multiline set to
|
|
505
|
+
* `true` to be able to fill the lines.
|
|
506
|
+
* @platform android
|
|
507
|
+
*/
|
|
508
|
+
numberOfLines?: ?number,
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Sets the return key to the label. Use it instead of `returnKeyType`.
|
|
512
|
+
* @platform android
|
|
513
|
+
*/
|
|
514
|
+
returnKeyLabel?: ?string,
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Sets the number of rows for a `TextInput`. Use it with multiline set to
|
|
518
|
+
* `true` to be able to fill the lines.
|
|
519
|
+
* @platform android
|
|
520
|
+
*/
|
|
521
|
+
rows?: ?number,
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* When `false`, it will prevent the soft keyboard from showing when the field is focused.
|
|
525
|
+
* Defaults to `true`.
|
|
526
|
+
*/
|
|
527
|
+
showSoftInputOnFocus?: ?boolean,
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Set text break strategy on Android API Level 23+, possible values are `simple`, `highQuality`, `balanced`
|
|
531
|
+
* The default value is `simple`.
|
|
532
|
+
* @platform android
|
|
533
|
+
*/
|
|
534
|
+
textBreakStrategy?: ?('simple' | 'highQuality' | 'balanced'),
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* The color of the `TextInput` underline.
|
|
538
|
+
* @platform android
|
|
539
|
+
*/
|
|
540
|
+
underlineColorAndroid?: ?ColorValue,
|
|
541
|
+
|}>;
|
|
542
|
+
|
|
543
|
+
export type Props = $ReadOnly<{|
|
|
544
|
+
...$Diff<ViewProps, $ReadOnly<{|style: ?ViewStyleProp|}>>,
|
|
545
|
+
...IOSProps,
|
|
546
|
+
...AndroidProps,
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Can tell `TextInput` to automatically capitalize certain characters.
|
|
550
|
+
*
|
|
551
|
+
* - `characters`: all characters.
|
|
552
|
+
* - `words`: first letter of each word.
|
|
553
|
+
* - `sentences`: first letter of each sentence (*default*).
|
|
554
|
+
* - `none`: don't auto capitalize anything.
|
|
555
|
+
*/
|
|
556
|
+
autoCapitalize?: ?AutoCapitalize,
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* If `false`, disables auto-correct. The default value is `true`.
|
|
560
|
+
*/
|
|
561
|
+
autoCorrect?: ?boolean,
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* If `true`, focuses the input on `componentDidMount`.
|
|
565
|
+
* The default value is `false`.
|
|
566
|
+
*/
|
|
567
|
+
autoFocus?: ?boolean,
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Specifies whether fonts should scale to respect Text Size accessibility settings. The
|
|
571
|
+
* default is `true`.
|
|
572
|
+
*/
|
|
573
|
+
allowFontScaling?: ?boolean,
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* If `true`, caret is hidden. The default value is `false`.
|
|
577
|
+
*
|
|
578
|
+
* On Android devices manufactured by Xiaomi with Android Q,
|
|
579
|
+
* when keyboardType equals 'email-address'this will be set
|
|
580
|
+
* in native to 'true' to prevent a system related crash. This
|
|
581
|
+
* will cause cursor to be diabled as a side-effect.
|
|
582
|
+
*
|
|
583
|
+
*/
|
|
584
|
+
caretHidden?: ?boolean,
|
|
585
|
+
|
|
586
|
+
/*
|
|
587
|
+
* If `true`, contextMenuHidden is hidden. The default value is `false`.
|
|
588
|
+
*/
|
|
589
|
+
contextMenuHidden?: ?boolean,
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Provides an initial value that will change when the user starts typing.
|
|
593
|
+
* Useful for simple use-cases where you do not want to deal with listening
|
|
594
|
+
* to events and updating the value prop to keep the controlled state in sync.
|
|
595
|
+
*/
|
|
596
|
+
defaultValue?: ?Stringish,
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* If `false`, text is not editable. The default value is `true`.
|
|
600
|
+
*/
|
|
601
|
+
editable?: ?boolean,
|
|
602
|
+
|
|
603
|
+
forwardedRef?: ?ReactRefSetter<TextInputInstance>,
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* `enterKeyHint` defines what action label (or icon) to present for the enter key on virtual keyboards.
|
|
607
|
+
*
|
|
608
|
+
* The following values is supported:
|
|
609
|
+
*
|
|
610
|
+
* - `enter`
|
|
611
|
+
* - `done`
|
|
612
|
+
* - `go`
|
|
613
|
+
* - `next`
|
|
614
|
+
* - `previous`
|
|
615
|
+
* - `search`
|
|
616
|
+
* - `send`
|
|
617
|
+
*/
|
|
618
|
+
enterKeyHint?: ?enterKeyHintType,
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* `inputMode` works like the `inputmode` attribute in HTML, it determines which
|
|
622
|
+
* keyboard to open, e.g.`numeric` and has precedence over keyboardType
|
|
623
|
+
*
|
|
624
|
+
* Support the following values:
|
|
625
|
+
*
|
|
626
|
+
* - `none`
|
|
627
|
+
* - `text`
|
|
628
|
+
* - `decimal`
|
|
629
|
+
* - `numeric`
|
|
630
|
+
* - `tel`
|
|
631
|
+
* - `search`
|
|
632
|
+
* - `email`
|
|
633
|
+
* - `url`
|
|
634
|
+
*/
|
|
635
|
+
inputMode?: ?InputMode,
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Determines which keyboard to open, e.g.`numeric`.
|
|
639
|
+
*
|
|
640
|
+
* The following values work across platforms:
|
|
641
|
+
*
|
|
642
|
+
* - `default`
|
|
643
|
+
* - `numeric`
|
|
644
|
+
* - `number-pad`
|
|
645
|
+
* - `decimal-pad`
|
|
646
|
+
* - `email-address`
|
|
647
|
+
* - `phone-pad`
|
|
648
|
+
* - `url`
|
|
649
|
+
*
|
|
650
|
+
* *iOS Only*
|
|
651
|
+
*
|
|
652
|
+
* The following values work on iOS only:
|
|
653
|
+
*
|
|
654
|
+
* - `ascii-capable`
|
|
655
|
+
* - `numbers-and-punctuation`
|
|
656
|
+
* - `name-phone-pad`
|
|
657
|
+
* - `twitter`
|
|
658
|
+
* - `web-search`
|
|
659
|
+
*
|
|
660
|
+
* *Android Only*
|
|
661
|
+
*
|
|
662
|
+
* The following values work on Android only:
|
|
663
|
+
*
|
|
664
|
+
* - `visible-password`
|
|
665
|
+
*
|
|
666
|
+
*/
|
|
667
|
+
keyboardType?: ?KeyboardType,
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Specifies largest possible scale a font can reach when `allowFontScaling` is enabled.
|
|
671
|
+
* Possible values:
|
|
672
|
+
* `null/undefined` (default): inherit from the parent node or the global default (0)
|
|
673
|
+
* `0`: no max, ignore parent/global default
|
|
674
|
+
* `>= 1`: sets the maxFontSizeMultiplier of this node to this value
|
|
675
|
+
*/
|
|
676
|
+
maxFontSizeMultiplier?: ?number,
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Limits the maximum number of characters that can be entered. Use this
|
|
680
|
+
* instead of implementing the logic in JS to avoid flicker.
|
|
681
|
+
*/
|
|
682
|
+
maxLength?: ?number,
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* If `true`, the text input can be multiple lines.
|
|
686
|
+
* The default value is `false`.
|
|
687
|
+
*/
|
|
688
|
+
multiline?: ?boolean,
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Callback that is called when the text input is blurred.
|
|
692
|
+
*/
|
|
693
|
+
onBlur?: ?(e: BlurEvent) => mixed,
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Callback that is called when the text input's text changes.
|
|
697
|
+
*/
|
|
698
|
+
onChange?: ?(e: ChangeEvent) => mixed,
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* DANGER: this API is not stable and will change in the future.
|
|
702
|
+
*
|
|
703
|
+
* Callback will be called on the main thread and may result in dropped frames.
|
|
704
|
+
* Callback that is called when the text input's text changes.
|
|
705
|
+
*
|
|
706
|
+
* @platform ios
|
|
707
|
+
*/
|
|
708
|
+
unstable_onChangeSync?: ?(e: ChangeEvent) => mixed,
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Callback that is called when the text input's text changes.
|
|
712
|
+
* Changed text is passed as an argument to the callback handler.
|
|
713
|
+
*/
|
|
714
|
+
onChangeText?: ?(text: string) => mixed,
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* DANGER: this API is not stable and will change in the future.
|
|
718
|
+
*
|
|
719
|
+
* Callback will be called on the main thread and may result in dropped frames.
|
|
720
|
+
* Callback that is called when the text input's text changes.
|
|
721
|
+
* Changed text is passed as an argument to the callback handler.
|
|
722
|
+
*
|
|
723
|
+
* @platform ios
|
|
724
|
+
*/
|
|
725
|
+
unstable_onChangeTextSync?: ?(text: string) => mixed,
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Callback that is called when the text input's content size changes.
|
|
729
|
+
* This will be called with
|
|
730
|
+
* `{ nativeEvent: { contentSize: { width, height } } }`.
|
|
731
|
+
*
|
|
732
|
+
* Only called for multiline text inputs.
|
|
733
|
+
*/
|
|
734
|
+
onContentSizeChange?: ?(e: ContentSizeChangeEvent) => mixed,
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Callback that is called when text input ends.
|
|
738
|
+
*/
|
|
739
|
+
onEndEditing?: ?(e: EditingEvent) => mixed,
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* Callback that is called when the text input is focused.
|
|
743
|
+
*/
|
|
744
|
+
onFocus?: ?(e: FocusEvent) => mixed,
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Callback that is called when a key is pressed.
|
|
748
|
+
* This will be called with `{ nativeEvent: { key: keyValue } }`
|
|
749
|
+
* where `keyValue` is `'Enter'` or `'Backspace'` for respective keys and
|
|
750
|
+
* the typed-in character otherwise including `' '` for space.
|
|
751
|
+
* Fires before `onChange` callbacks.
|
|
752
|
+
*/
|
|
753
|
+
onKeyPress?: ?(e: KeyPressEvent) => mixed,
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* DANGER: this API is not stable and will change in the future.
|
|
757
|
+
*
|
|
758
|
+
* Callback will be called on the main thread and may result in dropped frames.
|
|
759
|
+
*
|
|
760
|
+
* Callback that is called when a key is pressed.
|
|
761
|
+
* This will be called with `{ nativeEvent: { key: keyValue } }`
|
|
762
|
+
* where `keyValue` is `'Enter'` or `'Backspace'` for respective keys and
|
|
763
|
+
* the typed-in character otherwise including `' '` for space.
|
|
764
|
+
* Fires before `onChange` callbacks.
|
|
765
|
+
*
|
|
766
|
+
* @platform ios
|
|
767
|
+
*/
|
|
768
|
+
unstable_onKeyPressSync?: ?(e: KeyPressEvent) => mixed,
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Called when a touch is engaged.
|
|
772
|
+
*/
|
|
773
|
+
onPressIn?: ?(event: PressEvent) => mixed,
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Called when a touch is released.
|
|
777
|
+
*/
|
|
778
|
+
onPressOut?: ?(event: PressEvent) => mixed,
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Callback that is called when the text input selection is changed.
|
|
782
|
+
* This will be called with
|
|
783
|
+
* `{ nativeEvent: { selection: { start, end } } }`.
|
|
784
|
+
*/
|
|
785
|
+
onSelectionChange?: ?(e: SelectionChangeEvent) => mixed,
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Callback that is called when the text input's submit button is pressed.
|
|
789
|
+
* Invalid if `multiline={true}` is specified.
|
|
790
|
+
*/
|
|
791
|
+
onSubmitEditing?: ?(e: EditingEvent) => mixed,
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Invoked on content scroll with `{ nativeEvent: { contentOffset: { x, y } } }`.
|
|
795
|
+
* May also contain other properties from ScrollEvent but on Android contentSize
|
|
796
|
+
* is not provided for performance reasons.
|
|
797
|
+
*/
|
|
798
|
+
onScroll?: ?(e: ScrollEvent) => mixed,
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* The string that will be rendered before text input has been entered.
|
|
802
|
+
*/
|
|
803
|
+
placeholder?: ?Stringish,
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* The text color of the placeholder string.
|
|
807
|
+
*/
|
|
808
|
+
placeholderTextColor?: ?ColorValue,
|
|
809
|
+
|
|
810
|
+
/** `readOnly` works like the `readonly` attribute in HTML.
|
|
811
|
+
* If `true`, text is not editable. The default value is `false`.
|
|
812
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly
|
|
813
|
+
* for more details.
|
|
814
|
+
*/
|
|
815
|
+
readOnly?: ?boolean,
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Determines how the return key should look. On Android you can also use
|
|
819
|
+
* `returnKeyLabel`.
|
|
820
|
+
*
|
|
821
|
+
* *Cross platform*
|
|
822
|
+
*
|
|
823
|
+
* The following values work across platforms:
|
|
824
|
+
*
|
|
825
|
+
* - `done`
|
|
826
|
+
* - `go`
|
|
827
|
+
* - `next`
|
|
828
|
+
* - `search`
|
|
829
|
+
* - `send`
|
|
830
|
+
*
|
|
831
|
+
* *Android Only*
|
|
832
|
+
*
|
|
833
|
+
* The following values work on Android only:
|
|
834
|
+
*
|
|
835
|
+
* - `none`
|
|
836
|
+
* - `previous`
|
|
837
|
+
*
|
|
838
|
+
* *iOS Only*
|
|
839
|
+
*
|
|
840
|
+
* The following values work on iOS only:
|
|
841
|
+
*
|
|
842
|
+
* - `default`
|
|
843
|
+
* - `emergency-call`
|
|
844
|
+
* - `google`
|
|
845
|
+
* - `join`
|
|
846
|
+
* - `route`
|
|
847
|
+
* - `yahoo`
|
|
848
|
+
*/
|
|
849
|
+
returnKeyType?: ?ReturnKeyType,
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* If `true`, the text input obscures the text entered so that sensitive text
|
|
853
|
+
* like passwords stay secure. The default value is `false`. Does not work with 'multiline={true}'.
|
|
854
|
+
*/
|
|
855
|
+
secureTextEntry?: ?boolean,
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* The start and end of the text input's selection. Set start and end to
|
|
859
|
+
* the same value to position the cursor.
|
|
860
|
+
*/
|
|
861
|
+
selection?: ?$ReadOnly<{|
|
|
862
|
+
start: number,
|
|
863
|
+
end?: ?number,
|
|
864
|
+
|}>,
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* The highlight and cursor color of the text input.
|
|
868
|
+
*/
|
|
869
|
+
selectionColor?: ?ColorValue,
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* If `true`, all text will automatically be selected on focus.
|
|
873
|
+
*/
|
|
874
|
+
selectTextOnFocus?: ?boolean,
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* If `true`, the text field will blur when submitted.
|
|
878
|
+
* The default value is true for single-line fields and false for
|
|
879
|
+
* multiline fields. Note that for multiline fields, setting `blurOnSubmit`
|
|
880
|
+
* to `true` means that pressing return will blur the field and trigger the
|
|
881
|
+
* `onSubmitEditing` event instead of inserting a newline into the field.
|
|
882
|
+
*
|
|
883
|
+
* @deprecated
|
|
884
|
+
* Note that `submitBehavior` now takes the place of `blurOnSubmit` and will
|
|
885
|
+
* override any behavior defined by `blurOnSubmit`.
|
|
886
|
+
* @see submitBehavior
|
|
887
|
+
*/
|
|
888
|
+
blurOnSubmit?: ?boolean,
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* When the return key is pressed,
|
|
892
|
+
*
|
|
893
|
+
* For single line inputs:
|
|
894
|
+
*
|
|
895
|
+
* - `'newline`' defaults to `'blurAndSubmit'`
|
|
896
|
+
* - `undefined` defaults to `'blurAndSubmit'`
|
|
897
|
+
*
|
|
898
|
+
* For multiline inputs:
|
|
899
|
+
*
|
|
900
|
+
* - `'newline'` adds a newline
|
|
901
|
+
* - `undefined` defaults to `'newline'`
|
|
902
|
+
*
|
|
903
|
+
* For both single line and multiline inputs:
|
|
904
|
+
*
|
|
905
|
+
* - `'submit'` will only send a submit event and not blur the input
|
|
906
|
+
* - `'blurAndSubmit`' will both blur the input and send a submit event
|
|
907
|
+
*/
|
|
908
|
+
submitBehavior?: ?SubmitBehavior,
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* Note that not all Text styles are supported, an incomplete list of what is not supported includes:
|
|
912
|
+
*
|
|
913
|
+
* - `borderLeftWidth`
|
|
914
|
+
* - `borderTopWidth`
|
|
915
|
+
* - `borderRightWidth`
|
|
916
|
+
* - `borderBottomWidth`
|
|
917
|
+
* - `borderTopLeftRadius`
|
|
918
|
+
* - `borderTopRightRadius`
|
|
919
|
+
* - `borderBottomRightRadius`
|
|
920
|
+
* - `borderBottomLeftRadius`
|
|
921
|
+
*
|
|
922
|
+
* see [Issue#7070](https://github.com/facebook/react-native/issues/7070)
|
|
923
|
+
* for more detail.
|
|
924
|
+
*
|
|
925
|
+
* [Styles](docs/style.html)
|
|
926
|
+
*/
|
|
927
|
+
style?: ?TextStyleProp,
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* The value to show for the text input. `TextInput` is a controlled
|
|
931
|
+
* component, which means the native value will be forced to match this
|
|
932
|
+
* value prop if provided. For most uses, this works great, but in some
|
|
933
|
+
* cases this may cause flickering - one common cause is preventing edits
|
|
934
|
+
* by keeping value the same. In addition to simply setting the same value,
|
|
935
|
+
* either set `editable={false}`, or set/update `maxLength` to prevent
|
|
936
|
+
* unwanted edits without flicker.
|
|
937
|
+
*/
|
|
938
|
+
value?: ?Stringish,
|
|
939
|
+
|
|
940
|
+
text?: ?Stringish, // Win32
|
|
941
|
+
|}>;
|
|
942
|
+
|
|
943
|
+
/*
|
|
944
|
+
import {
|
|
945
|
+
TextInputProps,
|
|
946
|
+
NativeMethods,
|
|
947
|
+
} from 'react-native';
|
|
948
|
+
import {
|
|
949
|
+
IBlurEvent,
|
|
950
|
+
IChangeEvent,
|
|
951
|
+
IFocusEvent,
|
|
952
|
+
} from './TextInput.Types.win32';
|
|
953
|
+
import React from 'react'
|
|
954
|
+
|
|
955
|
+
type RCTTextInputProps = TextInputProps & {
|
|
956
|
+
text: string;
|
|
957
|
+
};
|
|
958
|
+
*/
|
|
959
|
+
|
|
960
|
+
// RCTTextInput is the native component that win32 understands
|
|
961
|
+
const RCTTextInput = requireNativeComponent<Props>('RCTTextInput');
|
|
962
|
+
|
|
963
|
+
// Adding typings on ViewManagers is problematic as available functionality is not known until
|
|
964
|
+
// registration at runtime and would require native and js to always be in sync.
|
|
965
|
+
const TextInputViewManager = UIManager.getViewManagerConfig('RCTTextInput');
|
|
966
|
+
|
|
967
|
+
class TextInput extends React.Component<Props, {}> {
|
|
968
|
+
// TODO: Once the native side begins supporting programmatic selection
|
|
969
|
+
// this will become important for selection management
|
|
970
|
+
// private _lastNativeTextSelection: any;
|
|
971
|
+
|
|
972
|
+
_rafID: AnimationFrameID;
|
|
973
|
+
|
|
974
|
+
_lastNativeText: ?Stringish;
|
|
975
|
+
_eventCount: number = 0;
|
|
976
|
+
|
|
977
|
+
constructor(props: Props) {
|
|
978
|
+
super(props);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* On mount TextInput needs to register itself with TextInputState
|
|
983
|
+
* and conditionally request an animation frame for focus.
|
|
984
|
+
*/
|
|
985
|
+
componentDidMount() {
|
|
986
|
+
this._lastNativeText = this.props.value;
|
|
987
|
+
|
|
988
|
+
// $FlowFixMe - // Win32
|
|
989
|
+
TextInputState.registerInput(this);
|
|
990
|
+
|
|
991
|
+
if (this.props.autoFocus === true) {
|
|
992
|
+
this._rafID = requestAnimationFrame(this.focus);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* This is an unfortunate consequence of having controlled TextInputs.
|
|
998
|
+
* Tree diffing reconciliation will not always send down text values
|
|
999
|
+
* This sets text explicitly.
|
|
1000
|
+
*/
|
|
1001
|
+
componentDidUpdate() {
|
|
1002
|
+
if (this._lastNativeText !== this._getText()) {
|
|
1003
|
+
this._getText() && this.setNativeText(this._getText());
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* Pre-unmoun the TextInput should blur, unregister and clean up
|
|
1011
|
+
* the animation frame for focus (edge cases)
|
|
1012
|
+
*/
|
|
1013
|
+
componentWillUnmount() {
|
|
1014
|
+
// blur
|
|
1015
|
+
if (this.isFocused()) {
|
|
1016
|
+
this.blur();
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
// unregister
|
|
1020
|
+
// $FlowFixMe - // Win32
|
|
1021
|
+
TextInputState.unregisterInput(this);
|
|
1022
|
+
|
|
1023
|
+
// cancel animationFrame
|
|
1024
|
+
if (this._rafID !== null) {
|
|
1025
|
+
cancelAnimationFrame(this._rafID);
|
|
1026
|
+
}
|
|
1027
|
+
if (this._rafID) {
|
|
1028
|
+
return;
|
|
1029
|
+
}
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
render(): React.Node {
|
|
1034
|
+
let {allowFontScaling, ...otherProps} = this.props;
|
|
1035
|
+
|
|
1036
|
+
allowFontScaling =
|
|
1037
|
+
this.props.allowFontScaling === null ||
|
|
1038
|
+
this.props.allowFontScaling === undefined
|
|
1039
|
+
? true
|
|
1040
|
+
: this.props.allowFontScaling;
|
|
1041
|
+
|
|
1042
|
+
return (
|
|
1043
|
+
<TextAncestor.Provider value={true}>
|
|
1044
|
+
<RCTTextInput
|
|
1045
|
+
{...otherProps}
|
|
1046
|
+
allowFontScaling={allowFontScaling}
|
|
1047
|
+
text={this._getText()}
|
|
1048
|
+
onFocus={this._onFocus}
|
|
1049
|
+
onBlur={this._onBlur}
|
|
1050
|
+
onChange={this._onChange}
|
|
1051
|
+
/>
|
|
1052
|
+
</TextAncestor.Provider>
|
|
1053
|
+
);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Returns true if the TextInput is focused
|
|
1058
|
+
*/
|
|
1059
|
+
isFocused(): boolean {
|
|
1060
|
+
return TextInputState.currentlyFocusedInput() === this;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* Focuses the TextInput
|
|
1065
|
+
*/
|
|
1066
|
+
focus: () => void = (): void => {
|
|
1067
|
+
// $FlowFixMe - // Win32
|
|
1068
|
+
TextInputState.setFocusedTextInput(this);
|
|
1069
|
+
UIManager.dispatchViewManagerCommand(
|
|
1070
|
+
findNodeHandle(this),
|
|
1071
|
+
TextInputViewManager.Commands.focus,
|
|
1072
|
+
null,
|
|
1073
|
+
);
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Blurs the TextInput
|
|
1078
|
+
*/
|
|
1079
|
+
blur: () => void = (): void => {
|
|
1080
|
+
// $FlowFixMe - // Win32
|
|
1081
|
+
TextInputState.blurTextInput(this);
|
|
1082
|
+
UIManager.dispatchViewManagerCommand(
|
|
1083
|
+
findNodeHandle(this),
|
|
1084
|
+
TextInputViewManager.Commands.blur,
|
|
1085
|
+
null,
|
|
1086
|
+
);
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* Use clear for programmatic clearing of the text
|
|
1091
|
+
*/
|
|
1092
|
+
clear: () => void = (): void => {
|
|
1093
|
+
this.setNativeText('');
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1096
|
+
setEventCount: () => void = (): void => {
|
|
1097
|
+
UIManager.dispatchViewManagerCommand(
|
|
1098
|
+
findNodeHandle(this),
|
|
1099
|
+
TextInputViewManager.Commands.setEventCount,
|
|
1100
|
+
[this._eventCount],
|
|
1101
|
+
);
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
setNativeText: (val: ?Stringish) => void = (val: ?Stringish): void => {
|
|
1105
|
+
if (this._lastNativeText !== val) {
|
|
1106
|
+
UIManager.dispatchViewManagerCommand(
|
|
1107
|
+
findNodeHandle(this),
|
|
1108
|
+
TextInputViewManager.Commands.setNativeText,
|
|
1109
|
+
[val],
|
|
1110
|
+
);
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
|
|
1114
|
+
_getText = (): string | null => {
|
|
1115
|
+
if (this.props.value != null && this.props.value != undefined) {
|
|
1116
|
+
return this.props.value;
|
|
1117
|
+
}
|
|
1118
|
+
if (
|
|
1119
|
+
this.props.defaultValue != null &&
|
|
1120
|
+
this.props.defaultValue != undefined
|
|
1121
|
+
) {
|
|
1122
|
+
return this.props.defaultValue;
|
|
1123
|
+
}
|
|
1124
|
+
return null;
|
|
1125
|
+
};
|
|
1126
|
+
|
|
1127
|
+
_onChange = (e: ChangeEvent): void => {
|
|
1128
|
+
const text = e.nativeEvent.text;
|
|
1129
|
+
this._eventCount = e.nativeEvent.eventCount;
|
|
1130
|
+
this.setEventCount();
|
|
1131
|
+
|
|
1132
|
+
this.props.onChange && this.props.onChange(e);
|
|
1133
|
+
this.props.onChangeText && this.props.onChangeText(text);
|
|
1134
|
+
this._lastNativeText = text;
|
|
1135
|
+
|
|
1136
|
+
this.forceUpdate();
|
|
1137
|
+
return;
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1140
|
+
_onFocus = (e: FocusEvent): void => {
|
|
1141
|
+
this.focus();
|
|
1142
|
+
this.props.onFocus && this.props.onFocus(e);
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
_onBlur = (e: BlurEvent): void => {
|
|
1146
|
+
this.props.onBlur && this.props.onBlur(e);
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
module.exports = TextInput;
|