mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 23:24:06 +08:00
[ReactNative] TextInput docs
This commit is contained in:
@@ -73,8 +73,8 @@ type Event = Object;
|
||||
* types, such as a numeric keypad.
|
||||
*
|
||||
* The simplest use case is to plop down a `TextInput` and subscribe to the
|
||||
* `onChangeText` events to read the user input. There are also other events,
|
||||
* such as `onSubmitEditing` and `onFocus` that can be subscribed to. A simple
|
||||
* `onChangeText` events to read the user input. There are also other events,
|
||||
* such as `onSubmitEditing` and `onFocus` that can be subscribed to. A simple
|
||||
* example:
|
||||
*
|
||||
* ```
|
||||
@@ -97,7 +97,6 @@ type Event = Object;
|
||||
* onSubmitEditing: true,
|
||||
* };
|
||||
*/
|
||||
|
||||
var TextInput = React.createClass({
|
||||
propTypes: {
|
||||
/**
|
||||
@@ -115,32 +114,44 @@ var TextInput = React.createClass({
|
||||
'characters',
|
||||
]),
|
||||
/**
|
||||
* If false, disables auto-correct. Default value is true.
|
||||
* If false, disables auto-correct. The default value is true.
|
||||
*/
|
||||
autoCorrect: PropTypes.bool,
|
||||
/**
|
||||
* If true, focuses the input on componentDidMount. Default value is false.
|
||||
* If true, focuses the input on componentDidMount.
|
||||
* The default value is false.
|
||||
*/
|
||||
autoFocus: PropTypes.bool,
|
||||
/**
|
||||
* Set the position of the cursor from where editing will begin.
|
||||
* @platorm android
|
||||
*/
|
||||
textAlign: PropTypes.oneOf([
|
||||
'start',
|
||||
'center',
|
||||
'end',
|
||||
]),
|
||||
/**
|
||||
* Aligns text vertically within the TextInput.
|
||||
* @platform android
|
||||
*/
|
||||
textAlignVertical: PropTypes.oneOf([
|
||||
'top',
|
||||
'center',
|
||||
'bottom',
|
||||
]),
|
||||
/**
|
||||
* If false, text is not editable. Default value is true.
|
||||
* If false, text is not editable. The default value is true.
|
||||
* @platform ios
|
||||
*/
|
||||
editable: PropTypes.bool,
|
||||
/**
|
||||
* Determines which keyboard to open, e.g.`numeric`.
|
||||
*
|
||||
* The following values work across platforms:
|
||||
* - default
|
||||
* - numeric
|
||||
* - email-address
|
||||
*/
|
||||
keyboardType: PropTypes.oneOf([
|
||||
// Cross-platform
|
||||
@@ -160,6 +171,7 @@ var TextInput = React.createClass({
|
||||
]),
|
||||
/**
|
||||
* Determines how the return key should look.
|
||||
* @platform ios
|
||||
*/
|
||||
returnKeyType: PropTypes.oneOf([
|
||||
'default',
|
||||
@@ -175,17 +187,20 @@ var TextInput = React.createClass({
|
||||
'emergency-call',
|
||||
]),
|
||||
/**
|
||||
* Limits the maximum number of characters that can be entered. Use this
|
||||
* Limits the maximum number of characters that can be entered. Use this
|
||||
* instead of implementing the logic in JS to avoid flicker.
|
||||
* @platform ios
|
||||
*/
|
||||
maxLength: PropTypes.number,
|
||||
/**
|
||||
* If true, the keyboard disables the return key when there is no text and
|
||||
* automatically enables it when there is text. Default value is false.
|
||||
* automatically enables it when there is text. The default value is false.
|
||||
* @platform ios
|
||||
*/
|
||||
enablesReturnKeyAutomatically: PropTypes.bool,
|
||||
/**
|
||||
* If true, the text input can be multiple lines. Default value is false.
|
||||
* If true, the text input can be multiple lines.
|
||||
* The default value is false.
|
||||
*/
|
||||
multiline: PropTypes.bool,
|
||||
/**
|
||||
@@ -214,14 +229,9 @@ var TextInput = React.createClass({
|
||||
*/
|
||||
onSubmitEditing: PropTypes.func,
|
||||
/**
|
||||
* Invoked on mount and layout changes with {x, y, width, height}.
|
||||
* Invoked on mount and layout changes with `{x, y, width, height}`.
|
||||
*/
|
||||
onLayout: PropTypes.func,
|
||||
/**
|
||||
* If true, the text input obscures the text entered so that sensitive text
|
||||
* like passwords stay secure. Default value is false.
|
||||
*/
|
||||
password: PropTypes.bool,
|
||||
/**
|
||||
* The string that will be rendered before text input has been entered
|
||||
*/
|
||||
@@ -230,17 +240,23 @@ var TextInput = React.createClass({
|
||||
* The text color of the placeholder string
|
||||
*/
|
||||
placeholderTextColor: PropTypes.string,
|
||||
/**
|
||||
* If true, the text input obscures the text entered so that sensitive text
|
||||
* like passwords stay secure. The default value is false.
|
||||
*/
|
||||
secureTextEntry: PropTypes.bool,
|
||||
/**
|
||||
* See DocumentSelectionState.js, some state that is responsible for
|
||||
* maintaining selection information for a document
|
||||
* @platform ios
|
||||
*/
|
||||
selectionState: PropTypes.instanceOf(DocumentSelectionState),
|
||||
/**
|
||||
* The value to show for the text input. TextInput is a controlled
|
||||
* The value to show for the text input. TextInput is a controlled
|
||||
* component, which means the native value will be forced to match this
|
||||
* value prop if provided. For most uses this works great, but in some
|
||||
* value prop if provided. 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. In addition to simply setting the same value,
|
||||
* by keeping value the same. In addition to simply setting the same value,
|
||||
* either set `editable={false}`, or set/update `maxLength` to prevent
|
||||
* unwanted edits without flicker.
|
||||
*/
|
||||
@@ -253,6 +269,7 @@ var TextInput = React.createClass({
|
||||
defaultValue: PropTypes.string,
|
||||
/**
|
||||
* When the clear button should appear on the right side of the text view
|
||||
* @platform ios
|
||||
*/
|
||||
clearButtonMode: PropTypes.oneOf([
|
||||
'never',
|
||||
@@ -262,10 +279,12 @@ var TextInput = React.createClass({
|
||||
]),
|
||||
/**
|
||||
* If true, clears the text field automatically when editing begins
|
||||
* @platform ios
|
||||
*/
|
||||
clearTextOnFocus: PropTypes.bool,
|
||||
/**
|
||||
* If true, selected the text automatically when editing begins
|
||||
* If true, all text will automatically be selected on focus
|
||||
* @platform ios
|
||||
*/
|
||||
selectTextOnFocus: PropTypes.bool,
|
||||
/**
|
||||
@@ -273,11 +292,12 @@ var TextInput = React.createClass({
|
||||
*/
|
||||
style: Text.propTypes.style,
|
||||
/**
|
||||
* Used to locate this view in end-to-end tests.
|
||||
* Used to locate this view in end-to-end tests
|
||||
*/
|
||||
testID: PropTypes.string,
|
||||
/**
|
||||
* The color of the textInput underline. Is only supported on Android.
|
||||
* The color of the textInput underline.
|
||||
* @platform android
|
||||
*/
|
||||
underlineColorAndroid: PropTypes.string,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user