From c9c1aab97e6b66d2fd5f49588afee1a417c40deb Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Sun, 5 Feb 2017 16:50:06 -0800 Subject: [PATCH] Rearrange propType imports --- package.json | 2 +- src/components/ActivityIndicator/index.js | 3 +- src/components/Image/index.js | 3 +- src/components/ListView/ListViewPropTypes.js | 4 +- src/components/ProgressBar/index.js | 3 +- src/components/ScrollView/ScrollViewBase.js | 3 +- src/components/ScrollView/index.js | 3 +- src/components/Switch/index.js | 3 +- src/components/TextInput/index.js | 9 +++-- .../Touchable/TouchableHighlight.js | 3 +- src/components/Touchable/TouchableOpacity.js | 3 +- src/components/View/ViewPropTypes.js | 37 +++++++++++++++++++ src/components/View/index.js | 35 +----------------- yarn.lock | 6 +-- 14 files changed, 66 insertions(+), 51 deletions(-) create mode 100644 src/components/View/ViewPropTypes.js diff --git a/package.json b/package.json index 8a0b0373..964e61cd 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "babel-core": "^6.21.0", "babel-eslint": "^7.1.1", "babel-loader": "^6.2.10", - "babel-plugin-transform-react-remove-prop-types": "^0.2.11", + "babel-plugin-transform-react-remove-prop-types": "^0.3.0", "babel-preset-react-native": "^1.9.1", "del-cli": "^0.2.1", "enzyme": "^2.4.1", diff --git a/src/components/ActivityIndicator/index.js b/src/components/ActivityIndicator/index.js index 3b7192e0..1f0abec5 100644 --- a/src/components/ActivityIndicator/index.js +++ b/src/components/ActivityIndicator/index.js @@ -1,13 +1,14 @@ import applyNativeMethods from '../../modules/applyNativeMethods'; import StyleSheet from '../../apis/StyleSheet'; import View from '../View'; +import ViewPropTypes from '../View/ViewPropTypes'; import React, { Component, PropTypes } from 'react'; class ActivityIndicator extends Component { static displayName = 'ActivityIndicator'; static propTypes = { - ...View.propTypes, + ...ViewPropTypes, animating: PropTypes.bool, color: PropTypes.string, hidesWhenStopped: PropTypes.bool, diff --git a/src/components/Image/index.js b/src/components/Image/index.js index edad6a33..bd4a8a4c 100644 --- a/src/components/Image/index.js +++ b/src/components/Image/index.js @@ -7,6 +7,7 @@ import requestAnimationFrame from 'fbjs/lib/requestAnimationFrame'; import StyleSheet from '../../apis/StyleSheet'; import StyleSheetPropType from '../../propTypes/StyleSheetPropType'; import View from '../View'; +import ViewPropTypes from '../View/ViewPropTypes'; import React, { Component, PropTypes } from 'react'; const emptyObject = {}; @@ -41,7 +42,7 @@ class Image extends Component { static displayName = 'Image'; static propTypes = { - ...View.propTypes, + ...ViewPropTypes, children: PropTypes.any, defaultSource: ImageSourcePropType, onError: PropTypes.func, diff --git a/src/components/ListView/ListViewPropTypes.js b/src/components/ListView/ListViewPropTypes.js index ebc8231d..b3f31354 100644 --- a/src/components/ListView/ListViewPropTypes.js +++ b/src/components/ListView/ListViewPropTypes.js @@ -1,9 +1,9 @@ import ListViewDataSource from './ListViewDataSource'; import { PropTypes } from 'react'; -import ScrollView from '../ScrollView'; +import ScrollView, { propTypes as ScrollViewPropTypes } from '../ScrollView'; export default { - ...ScrollView.propTypes, + ...ScrollViewPropTypes, dataSource: PropTypes.instanceOf(ListViewDataSource).isRequired, renderSeparator: PropTypes.func, renderRow: PropTypes.func.isRequired, diff --git a/src/components/ProgressBar/index.js b/src/components/ProgressBar/index.js index d45b95d5..eaf8443e 100644 --- a/src/components/ProgressBar/index.js +++ b/src/components/ProgressBar/index.js @@ -2,13 +2,14 @@ import applyNativeMethods from '../../modules/applyNativeMethods'; import ColorPropType from '../../propTypes/ColorPropType'; import StyleSheet from '../../apis/StyleSheet'; import View from '../View'; +import ViewPropTypes from '../View/ViewPropTypes'; import React, { Component, PropTypes } from 'react'; class ProgressBar extends Component { static displayName = 'ProgressBar'; static propTypes = { - ...View.propTypes, + ...ViewPropTypes, color: ColorPropType, indeterminate: PropTypes.bool, progress: PropTypes.number, diff --git a/src/components/ScrollView/ScrollViewBase.js b/src/components/ScrollView/ScrollViewBase.js index 62b8a885..7eb22909 100644 --- a/src/components/ScrollView/ScrollViewBase.js +++ b/src/components/ScrollView/ScrollViewBase.js @@ -8,6 +8,7 @@ import debounce from 'debounce'; import View from '../View'; +import ViewPropTypes from '../View/ViewPropTypes'; import React, { Component, PropTypes } from 'react'; const normalizeScrollEvent = (e) => ({ @@ -44,7 +45,7 @@ const normalizeScrollEvent = (e) => ({ */ export default class ScrollViewBase extends Component { static propTypes = { - ...View.propTypes, + ...ViewPropTypes, onMomentumScrollBegin: PropTypes.func, onMomentumScrollEnd: PropTypes.func, onScroll: PropTypes.func, diff --git a/src/components/ScrollView/index.js b/src/components/ScrollView/index.js index c8f5bd87..c61ec6c3 100644 --- a/src/components/ScrollView/index.js +++ b/src/components/ScrollView/index.js @@ -14,6 +14,7 @@ import ScrollViewBase from './ScrollViewBase'; import StyleSheet from '../../apis/StyleSheet'; import StyleSheetPropType from '../../propTypes/StyleSheetPropType'; import View from '../View'; +import ViewPropTypes from '../View/ViewPropTypes'; import ViewStylePropTypes from '../View/ViewStylePropTypes'; import React, { Component, PropTypes } from 'react'; @@ -22,7 +23,7 @@ const emptyObject = {}; /* eslint-disable react/prefer-es6-class */ const ScrollView = React.createClass({ propTypes: { - ...View.propTypes, + ...ViewPropTypes, contentContainerStyle: StyleSheetPropType(ViewStylePropTypes), horizontal: PropTypes.bool, keyboardDismissMode: PropTypes.oneOf([ 'none', 'interactive', 'on-drag' ]), diff --git a/src/components/Switch/index.js b/src/components/Switch/index.js index acab89bf..0f55296f 100644 --- a/src/components/Switch/index.js +++ b/src/components/Switch/index.js @@ -5,6 +5,7 @@ import multiplyStyleLengthValue from '../../modules/multiplyStyleLengthValue'; import StyleSheet from '../../apis/StyleSheet'; import UIManager from '../../apis/UIManager'; import View from '../View'; +import ViewPropTypes from '../View/ViewPropTypes'; import React, { Component, PropTypes } from 'react'; const emptyObject = {}; @@ -15,7 +16,7 @@ class Switch extends Component { static displayName = 'Switch'; static propTypes = { - ...View.propTypes, + ...ViewPropTypes, activeThumbColor: ColorPropType, activeTrackColor: ColorPropType, disabled: PropTypes.bool, diff --git a/src/components/TextInput/index.js b/src/components/TextInput/index.js index 5356de51..a012c200 100644 --- a/src/components/TextInput/index.js +++ b/src/components/TextInput/index.js @@ -4,10 +4,11 @@ import NativeMethodsMixin from '../../modules/NativeMethodsMixin'; import createDOMElement from '../../modules/createDOMElement'; import findNodeHandle from '../../modules/findNodeHandle'; import StyleSheet from '../../apis/StyleSheet'; -import Text from '../Text'; +import StyleSheetPropType from '../../propTypes/StyleSheetPropType'; +import TextStylePropTypes from '../Text/TextStylePropTypes'; import TextareaAutosize from 'react-textarea-autosize'; import TextInputState from './TextInputState'; -import View from '../View'; +import ViewPropTypes from '../View/ViewPropTypes'; import { Component, PropTypes } from 'react'; const emptyObject = {}; @@ -52,7 +53,7 @@ class TextInput extends Component { static displayName = 'TextInput'; static propTypes = { - ...View.propTypes, + ...ViewPropTypes, autoCapitalize: PropTypes.oneOf([ 'characters', 'none', 'sentences', 'words' ]), autoComplete: PropTypes.string, autoCorrect: PropTypes.bool, @@ -83,7 +84,7 @@ class TextInput extends Component { start: PropTypes.number.isRequired, end: PropTypes.number }), - style: Text.propTypes.style, + style: StyleSheetPropType(TextStylePropTypes), value: PropTypes.string }; diff --git a/src/components/Touchable/TouchableHighlight.js b/src/components/Touchable/TouchableHighlight.js index 5988098f..6366a8b1 100644 --- a/src/components/Touchable/TouchableHighlight.js +++ b/src/components/Touchable/TouchableHighlight.js @@ -27,6 +27,7 @@ var ViewStylePropTypes = require('../View/ViewStylePropTypes'); var ensureComponentIsNative = require('./ensureComponentIsNative'); var ensurePositiveDelayProps = require('./ensurePositiveDelayProps'); +var TouchableWithoutFeedbackPropTypes = TouchableWithoutFeedback.propTypes type Event = Object; @@ -67,7 +68,7 @@ var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; var TouchableHighlight = React.createClass({ propTypes: { - ...TouchableWithoutFeedback.propTypes, + ...TouchableWithoutFeedbackPropTypes, /** * Determines what the opacity of the wrapped view should be when touch is * active. diff --git a/src/components/Touchable/TouchableOpacity.js b/src/components/Touchable/TouchableOpacity.js index 14d5a1b3..eb014d21 100644 --- a/src/components/Touchable/TouchableOpacity.js +++ b/src/components/Touchable/TouchableOpacity.js @@ -24,6 +24,7 @@ var View = require('../View'); var ensurePositiveDelayProps = require('./ensurePositiveDelayProps'); var flattenStyle = StyleSheet.flatten +var TouchableWithoutFeedbackPropTypes = TouchableWithoutFeedback.propTypes; type Event = Object; @@ -54,7 +55,7 @@ var TouchableOpacity = React.createClass({ mixins: [TimerMixin, Touchable.Mixin, NativeMethodsMixin], propTypes: { - ...TouchableWithoutFeedback.propTypes, + ...TouchableWithoutFeedbackPropTypes, /** * Determines what the opacity of the wrapped view should be when touch is * active. diff --git a/src/components/View/ViewPropTypes.js b/src/components/View/ViewPropTypes.js new file mode 100644 index 00000000..def4227f --- /dev/null +++ b/src/components/View/ViewPropTypes.js @@ -0,0 +1,37 @@ +import BaseComponentPropTypes from '../../propTypes/BaseComponentPropTypes'; +import EdgeInsetsPropType from '../../propTypes/EdgeInsetsPropType'; +import StyleSheetPropType from '../../propTypes/StyleSheetPropType'; +import ViewStylePropTypes from './ViewStylePropTypes'; +import { PropTypes } from 'react'; + +const ViewPropTypes = { + ...BaseComponentPropTypes, + children: PropTypes.any, + collapsable: PropTypes.bool, + hitSlop: EdgeInsetsPropType, + onClick: PropTypes.func, + onClickCapture: PropTypes.func, + onLayout: PropTypes.func, + onMoveShouldSetResponder: PropTypes.func, + onMoveShouldSetResponderCapture: PropTypes.func, + onResponderGrant: PropTypes.func, + onResponderMove: PropTypes.func, + onResponderReject: PropTypes.func, + onResponderRelease: PropTypes.func, + onResponderTerminate: PropTypes.func, + onResponderTerminationRequest: PropTypes.func, + onStartShouldSetResponder: PropTypes.func, + onStartShouldSetResponderCapture: PropTypes.func, + onTouchCancel: PropTypes.func, + onTouchCancelCapture: PropTypes.func, + onTouchEnd: PropTypes.func, + onTouchEndCapture: PropTypes.func, + onTouchMove: PropTypes.func, + onTouchMoveCapture: PropTypes.func, + onTouchStart: PropTypes.func, + onTouchStartCapture: PropTypes.func, + pointerEvents: PropTypes.oneOf([ 'auto', 'box-none', 'box-only', 'none' ]), + style: StyleSheetPropType(ViewStylePropTypes) +}; + +module.exports = ViewPropTypes; diff --git a/src/components/View/index.js b/src/components/View/index.js index 71289aa0..c23e416d 100644 --- a/src/components/View/index.js +++ b/src/components/View/index.js @@ -2,13 +2,10 @@ import '../../modules/injectResponderEventPlugin'; import applyLayout from '../../modules/applyLayout'; import applyNativeMethods from '../../modules/applyNativeMethods'; -import BaseComponentPropTypes from '../../propTypes/BaseComponentPropTypes'; import createDOMElement from '../../modules/createDOMElement'; -import EdgeInsetsPropType from '../../propTypes/EdgeInsetsPropType'; import normalizeNativeEvent from '../../modules/normalizeNativeEvent'; import StyleSheet from '../../apis/StyleSheet'; -import StyleSheetPropType from '../../propTypes/StyleSheetPropType'; -import ViewStylePropTypes from './ViewStylePropTypes'; +import ViewPropTypes from './ViewPropTypes'; import { Component, PropTypes } from 'react'; const eventHandlerNames = [ @@ -37,35 +34,7 @@ const eventHandlerNames = [ class View extends Component { static displayName = 'View'; - static propTypes = { - ...BaseComponentPropTypes, - children: PropTypes.any, - collapsable: PropTypes.bool, - hitSlop: EdgeInsetsPropType, - onClick: PropTypes.func, - onClickCapture: PropTypes.func, - onLayout: PropTypes.func, - onMoveShouldSetResponder: PropTypes.func, - onMoveShouldSetResponderCapture: PropTypes.func, - onResponderGrant: PropTypes.func, - onResponderMove: PropTypes.func, - onResponderReject: PropTypes.func, - onResponderRelease: PropTypes.func, - onResponderTerminate: PropTypes.func, - onResponderTerminationRequest: PropTypes.func, - onStartShouldSetResponder: PropTypes.func, - onStartShouldSetResponderCapture: PropTypes.func, - onTouchCancel: PropTypes.func, - onTouchCancelCapture: PropTypes.func, - onTouchEnd: PropTypes.func, - onTouchEndCapture: PropTypes.func, - onTouchMove: PropTypes.func, - onTouchMoveCapture: PropTypes.func, - onTouchStart: PropTypes.func, - onTouchStartCapture: PropTypes.func, - pointerEvents: PropTypes.oneOf([ 'auto', 'box-none', 'box-only', 'none' ]), - style: StyleSheetPropType(ViewStylePropTypes) - }; + static propTypes = ViewPropTypes; static defaultProps = { accessible: true diff --git a/yarn.lock b/yarn.lock index bfe7164c..d5c4d8b1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -895,9 +895,9 @@ babel-plugin-transform-react-jsx@^6.3.13, babel-plugin-transform-react-jsx@^6.5. babel-plugin-syntax-jsx "^6.8.0" babel-runtime "^6.0.0" -babel-plugin-transform-react-remove-prop-types: - version "0.2.11" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.2.11.tgz#05eb7cc4670d6506d801680576589c7abcd51b00" +babel-plugin-transform-react-remove-prop-types@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.3.0.tgz#88baefdb530c95c37c6e685f591e263db9fe5585" babel-plugin-transform-regenerator@6.16.1, babel-plugin-transform-regenerator@^6.16.0, babel-plugin-transform-regenerator@^6.5.0, babel-plugin-transform-regenerator@^6.6.0: version "6.16.1"