[add] TextInput disabled prop

Add support for disabling TextInput elements

Fix #1036
This commit is contained in:
Nicolas Gallagher
2019-12-20 19:15:22 +00:00
parent 8fa9fc5cc5
commit fc033a3161
6 changed files with 45 additions and 1 deletions
@@ -11,6 +11,7 @@ ofProps.propTypes = {
blurOnSubmit: PropTypes.bool,
clearTextOnFocus: PropTypes.bool,
defaultValue: PropTypes.string,
disabled: PropTypes.bool,
editable: PropTypes.bool,
keyboardType: PropTypes.string,
maxLength: PropTypes.number,
@@ -52,6 +53,7 @@ export { default as autoCapitalize } from './examples/AutoCapitalize';
export { default as blurOnSubmit } from './examples/BlurOnSubmit';
export { default as clearButtonMode } from './examples/ClearButtonMode';
export { default as clearTextOnFocus } from './examples/ClearTextOnFocus';
export { default as disabled } from './examples/Disabled';
export { default as editable } from './examples/Editable';
export { default as keyboardType } from './examples/KeyboardType';
export { default as maxLength } from './examples/MaxLength';
@@ -56,7 +56,7 @@ into the field.
</Story>
</Preview>
### clearTextOnFocus: ?boolean = false
### clearTextOnFocus
If `true`, clears the text field automatically when focused.
@@ -72,6 +72,16 @@ Provides an initial value that will change when the user starts typing. Useful
for simple use-cases where you don't want to deal with listening to events and
updating the value prop to keep the controlled state in sync.
### disabled
If `true`, the input is disabled. (Web-only)
<Preview withSource='none'>
<Story name="disabled">
<Stories.disabled />
</Story>
</Preview>
### editable
If `false`, text is not editable (i.e., read-only).
@@ -0,0 +1,17 @@
import React from 'react';
import { styles } from '../helpers';
import { TextInput, View } from 'react-native';
export default function Disabled() {
return (
<View>
<TextInput defaultValue="disabled text input" disabled={true} style={styles.textinput} />
<TextInput
defaultValue="disabled multiline text input"
disabled={true}
multiline={true}
style={styles.multiline}
/>
</View>
);
}