diff --git a/src/components/Text/TextStylePropTypes.js b/src/components/Text/TextStylePropTypes.js index 4f3014f6..02fa2883 100644 --- a/src/components/Text/TextStylePropTypes.js +++ b/src/components/Text/TextStylePropTypes.js @@ -1,7 +1,45 @@ -import TextPropTypes from '../../propTypes/TextPropTypes'; +import ColorPropType from '../../propTypes/ColorPropType'; +import { PropTypes } from 'react'; import ViewStylePropTypes from '../View/ViewStylePropTypes'; -module.exports = process.env.NODE_ENV !== 'production' ? { +const { number, oneOf, oneOfType, shape, string } = PropTypes; +const numberOrString = oneOfType([ number, string ]); + +const ShadowOffsetPropType = shape({ width: number, height: number }); +const TextAlignPropType = oneOf([ 'center', 'inherit', 'justify', 'justify-all', 'left', 'right' ]); +const WritingDirectionPropType = oneOf([ 'auto', 'ltr', 'rtl' ]); + +const TextOnlyStylePropTypes = { + color: ColorPropType, + fontFamily: string, + fontSize: numberOrString, + fontStyle: string, + fontWeight: string, + letterSpacing: numberOrString, + lineHeight: numberOrString, + textAlign: TextAlignPropType, + textAlignVertical: oneOf([ 'auto', 'bottom', 'center', 'top' ]), + textDecorationLine: string, + textShadowColor: ColorPropType, + textShadowOffset: ShadowOffsetPropType, + textShadowRadius: number, + writingDirection: WritingDirectionPropType, + /* @platform web */ + textOverflow: string, + textRendering: oneOf([ 'auto', 'geometricPrecision', 'optimizeLegibility', 'optimizeSpeed' ]), + textTransform: oneOf([ 'capitalize', 'lowercase', 'none', 'uppercase' ]), + unicodeBidi: oneOf([ 'normal', 'bidi-override', 'embed', 'isolate', 'isolate-override', 'plaintext' ]), + whiteSpace: string, + wordWrap: string, + MozOsxFontSmoothing: string, + WebkitFontSmoothing: string, + // opt-out of RTL flipping + textAlign$noI18n: TextAlignPropType, + textShadowOffset$noI18n: ShadowOffsetPropType, + writingDirection$noI18n: WritingDirectionPropType +}; + +module.exports = { ...ViewStylePropTypes, - ...TextPropTypes -} : {}; + ...TextOnlyStylePropTypes +}; diff --git a/src/propTypes/TextPropTypes.js b/src/propTypes/TextPropTypes.js deleted file mode 100644 index 0e6082a9..00000000 --- a/src/propTypes/TextPropTypes.js +++ /dev/null @@ -1,42 +0,0 @@ -import ColorPropType from './ColorPropType'; -import { PropTypes } from 'react'; - -const { number, oneOf, oneOfType, shape, string } = PropTypes; -const numberOrString = oneOfType([ number, string ]); - -const ShadowOffsetPropType = shape({ width: number, height: number }); -const TextAlignPropType = oneOf([ 'center', 'inherit', 'justify', 'justify-all', 'left', 'right' ]); -const WritingDirectionPropType = oneOf([ 'auto', 'ltr', 'rtl' ]); - -const TextPropTypes = process.env.NODE_ENV !== 'production' ? { - // box model - color: ColorPropType, - fontFamily: string, - fontSize: numberOrString, - fontStyle: string, - fontWeight: string, - letterSpacing: numberOrString, - lineHeight: numberOrString, - textAlign: TextAlignPropType, - textAlignVertical: oneOf([ 'auto', 'bottom', 'center', 'top' ]), - textDecorationLine: string, - textShadowColor: ColorPropType, - textShadowOffset: ShadowOffsetPropType, - textShadowRadius: number, - writingDirection: WritingDirectionPropType, - /* @platform web */ - textOverflow: string, - textRendering: oneOf([ 'auto', 'geometricPrecision', 'optimizeLegibility', 'optimizeSpeed' ]), - textTransform: oneOf([ 'capitalize', 'lowercase', 'none', 'uppercase' ]), - unicodeBidi: oneOf([ 'normal', 'bidi-override', 'embed', 'isolate', 'isolate-override', 'plaintext' ]), - whiteSpace: string, - wordWrap: string, - MozOsxFontSmoothing: string, - WebkitFontSmoothing: string, - // opt-out of RTL flipping - textAlign$noI18n: TextAlignPropType, - textShadowOffset$noI18n: ShadowOffsetPropType, - writingDirection$noI18n: WritingDirectionPropType -} : {}; - -module.exports = TextPropTypes;