From a3ed8f05e63fde6ce6e8c4f2f126aa4cea68a730 Mon Sep 17 00:00:00 2001 From: Matthias Le Brun Date: Thu, 16 Feb 2017 14:00:58 +0100 Subject: [PATCH] [add] resize 'TextInput' style Fix #363 --- docs/components/TextInput.md | 3 +++ src/apis/StyleSheet/StyleSheetValidation.js | 2 ++ .../TextInput/TextInputStylePropTypes.js | 14 ++++++++++++++ src/components/TextInput/index.js | 7 ++++--- src/components/View/ViewStylePropTypes.js | 2 +- 5 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 src/components/TextInput/TextInputStylePropTypes.js diff --git a/docs/components/TextInput.md b/docs/components/TextInput.md index b0bc5df0..7970d0df 100644 --- a/docs/components/TextInput.md +++ b/docs/components/TextInput.md @@ -144,6 +144,9 @@ If `true`, all text will automatically be selected on focus. **style**: style + ...[Text#style](./Text.md) ++ `resize` ‡ + +‡ web only. **testID**: string diff --git a/src/apis/StyleSheet/StyleSheetValidation.js b/src/apis/StyleSheet/StyleSheetValidation.js index ef41d1dc..2f153af6 100644 --- a/src/apis/StyleSheet/StyleSheetValidation.js +++ b/src/apis/StyleSheet/StyleSheetValidation.js @@ -11,6 +11,7 @@ import { PropTypes } from 'react' import ImageStylePropTypes from '../../components/Image/ImageStylePropTypes' import ReactPropTypeLocations from 'react-dom/lib/ReactPropTypeLocations' import ReactPropTypesSecret from 'react-dom/lib/ReactPropTypesSecret' +import TextInputStylePropTypes from '../../components/TextInput/TextInputStylePropTypes' import TextStylePropTypes from '../../components/Text/TextStylePropTypes' import ViewStylePropTypes from '../../components/View/ViewStylePropTypes' import warning from 'fbjs/lib/warning' @@ -66,6 +67,7 @@ var allStylePropTypes = {}; StyleSheetValidation.addValidStylePropTypes(ImageStylePropTypes) StyleSheetValidation.addValidStylePropTypes(TextStylePropTypes) +StyleSheetValidation.addValidStylePropTypes(TextInputStylePropTypes) StyleSheetValidation.addValidStylePropTypes(ViewStylePropTypes) StyleSheetValidation.addValidStylePropTypes({ appearance: PropTypes.string, diff --git a/src/components/TextInput/TextInputStylePropTypes.js b/src/components/TextInput/TextInputStylePropTypes.js new file mode 100644 index 00000000..04fe0339 --- /dev/null +++ b/src/components/TextInput/TextInputStylePropTypes.js @@ -0,0 +1,14 @@ +import TextStylePropTypes from '../Text/TextStylePropTypes'; +import { PropTypes } from 'react'; + +const { oneOf } = PropTypes; + +const TextInputOnlyStylePropTypes = { + /* @platform web */ + resize: oneOf([ 'none', 'vertical', 'horizontal', 'both' ]) +}; + +module.exports = { + ...TextStylePropTypes, + ...TextInputOnlyStylePropTypes +}; diff --git a/src/components/TextInput/index.js b/src/components/TextInput/index.js index 0eebd801..a06641d2 100644 --- a/src/components/TextInput/index.js +++ b/src/components/TextInput/index.js @@ -5,7 +5,7 @@ import createDOMElement from '../../modules/createDOMElement'; import findNodeHandle from '../../modules/findNodeHandle'; import StyleSheet from '../../apis/StyleSheet'; import StyleSheetPropType from '../../propTypes/StyleSheetPropType'; -import TextStylePropTypes from '../Text/TextStylePropTypes'; +import TextInputStylePropTypes from './TextInputStylePropTypes'; import TextareaAutosize from 'react-textarea-autosize'; import TextInputState from './TextInputState'; import ViewPropTypes from '../View/ViewPropTypes'; @@ -84,7 +84,7 @@ class TextInput extends Component { start: PropTypes.number.isRequired, end: PropTypes.number }), - style: StyleSheetPropType(TextStylePropTypes), + style: StyleSheetPropType(TextInputStylePropTypes), value: PropTypes.string }; @@ -277,7 +277,8 @@ const styles = StyleSheet.create({ boxSizing: 'border-box', color: 'inherit', font: 'inherit', - padding: 0 + padding: 0, + resize: 'none' } }); diff --git a/src/components/View/ViewStylePropTypes.js b/src/components/View/ViewStylePropTypes.js index 91aa528b..17ca2c7a 100644 --- a/src/components/View/ViewStylePropTypes.js +++ b/src/components/View/ViewStylePropTypes.js @@ -45,5 +45,5 @@ module.exports = { userSelect: string, visibility: hiddenOrVisible, willChange: string, - WebkitOverflowScrolling: oneOf([ 'auto', 'touch' ]), + WebkitOverflowScrolling: oneOf([ 'auto', 'touch' ]) };