diff --git a/Libraries/Components/View/ReactNativeStyleAttributes.js b/Libraries/Components/View/ReactNativeStyleAttributes.js index 8264f1f3779dd1..c1126c724e554b 100644 --- a/Libraries/Components/View/ReactNativeStyleAttributes.js +++ b/Libraries/Components/View/ReactNativeStyleAttributes.js @@ -11,7 +11,7 @@ 'use strict'; const DeprecatedImageStylePropTypes = require('../../DeprecatedPropTypes/DeprecatedImageStylePropTypes'); -const TextStylePropTypes = require('../../Text/TextStylePropTypes'); +const DeprecatedTextStylePropTypes = require('../../DeprecatedPropTypes/DeprecatedTextStylePropTypes'); const DeprecatedViewStylePropTypes = require('../../DeprecatedPropTypes/DeprecatedViewStylePropTypes'); const processColor = require('../../StyleSheet/processColor'); @@ -22,7 +22,7 @@ const ReactNativeStyleAttributes = {}; for (const attributeName of Object.keys({ ...DeprecatedViewStylePropTypes, - ...TextStylePropTypes, + ...DeprecatedTextStylePropTypes, ...DeprecatedImageStylePropTypes, })) { ReactNativeStyleAttributes[attributeName] = true; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js index 7474f53b6fb50c..f053e8e283d6ce 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js @@ -14,39 +14,145 @@ const DeprecatedColorPropType = require('./DeprecatedColorPropType'); const DeprecatedEdgeInsetsPropType = require('./DeprecatedEdgeInsetsPropType'); const DeprecatedStyleSheetPropType = require('./DeprecatedStyleSheetPropType'); const PropTypes = require('prop-types'); -const TextStylePropTypes = require('../Text/TextStylePropTypes'); +const DeprecatedTextStylePropTypes = require('./DeprecatedTextStylePropTypes'); const stylePropType: ReactPropsCheckType = DeprecatedStyleSheetPropType( - TextStylePropTypes, + DeprecatedTextStylePropTypes, ); +const DataDetectorTypes = ['phoneNumber', 'link', 'email', 'none', 'all']; + module.exports = { + /** + * When `numberOfLines` is set, this prop defines how text will be + * truncated. + * + * See https://facebook.github.io/react-native/docs/text.html#ellipsizemode + */ ellipsizeMode: (PropTypes.oneOf([ 'head', 'middle', 'tail', 'clip', ]): React$PropType$Primitive<'head' | 'middle' | 'tail' | 'clip'>), + /** + * Used to truncate the text with an ellipsis. + * + * See https://facebook.github.io/react-native/docs/text.html#numberoflines + */ numberOfLines: PropTypes.number, + /** + * Set text break strategy on Android. + * + * See https://facebook.github.io/react-native/docs/text.html#textbreakstrategy + */ textBreakStrategy: (PropTypes.oneOf([ 'simple', 'highQuality', 'balanced', ]): React$PropType$Primitive<'simple' | 'highQuality' | 'balanced'>), + /** + * Invoked on mount and layout changes. + * + * See https://facebook.github.io/react-native/docs/text.html#onlayout + */ onLayout: PropTypes.func, + /** + * This function is called on press. + * + * See https://facebook.github.io/react-native/docs/text.html#onpress + */ onPress: PropTypes.func, + /** + * This function is called on long press. + * + * See https://facebook.github.io/react-native/docs/text.html#onlongpress + */ onLongPress: PropTypes.func, + /** + * Defines how far your touch may move off of the button, before + * deactivating the button. + * + * See https://facebook.github.io/react-native/docs/text.html#pressretentionoffset + */ pressRetentionOffset: DeprecatedEdgeInsetsPropType, + /** + * Lets the user select text. + * + * See https://facebook.github.io/react-native/docs/text.html#selectable + */ selectable: PropTypes.bool, + /** + * The highlight color of the text. + * + * See https://facebook.github.io/react-native/docs/text.html#selectioncolor + */ selectionColor: DeprecatedColorPropType, + /** + * When `true`, no visual change is made when text is pressed down. + * + * See https://facebook.github.io/react-native/docs/text.html#supperhighlighting + */ suppressHighlighting: PropTypes.bool, style: stylePropType, + /** + * Used to locate this view in end-to-end tests. + * + * See https://facebook.github.io/react-native/docs/text.html#testid + */ testID: PropTypes.string, + /** + * Used to locate this view from native code. + * + * See https://facebook.github.io/react-native/docs/text.html#nativeid + */ nativeID: PropTypes.string, + /** + * Whether fonts should scale to respect Text Size accessibility settings. + * + * See https://facebook.github.io/react-native/docs/text.html#allowfontscaling + */ allowFontScaling: PropTypes.bool, + /** + * Specifies largest possible scale a font can reach when `allowFontScaling` is enabled. + * Possible values: + * `null/undefined` (default): inherit from the parent node or the global default (0) + * `0`: no max, ignore parent/global default + * `>= 1`: sets the maxFontSizeMultiplier of this node to this value + */ maxFontSizeMultiplier: PropTypes.number, + /** + * Indicates whether the view is an accessibility element. + * + * See https://facebook.github.io/react-native/docs/text.html#accessible + */ accessible: PropTypes.bool, + /** + * Whether font should be scaled down automatically. + * + * See https://facebook.github.io/react-native/docs/text.html#adjustsfontsizetofit + */ adjustsFontSizeToFit: PropTypes.bool, + /** + * Smallest possible scale a font can reach. + * + * See https://facebook.github.io/react-native/docs/text.html#minimumfontscale + */ minimumFontScale: PropTypes.number, + /** + * Specifies the disabled state of the text view for testing purposes. + * + * See https://facebook.github.io/react-native/docs/text.html#disabled + */ disabled: PropTypes.bool, + /** + * Determines the types of data converted to clickable URLs in text. + * + * See https://facebook.github.io/react-native/docs/text.html#dataDetectorType + */ + dataDetectorType: (PropTypes.oneOf( + DataDetectorTypes, + ): React$PropType$Primitive< + 'phoneNumber' | 'link' | 'email' | 'none' | 'all', + >), }; diff --git a/Libraries/Text/TextStylePropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedTextStylePropTypes.js similarity index 93% rename from Libraries/Text/TextStylePropTypes.js rename to Libraries/DeprecatedPropTypes/DeprecatedTextStylePropTypes.js index d1ad5ba5bf9c3b..63ab3213ffd6e7 100644 --- a/Libraries/Text/TextStylePropTypes.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedTextStylePropTypes.js @@ -10,11 +10,11 @@ 'use strict'; -const DeprecatedColorPropType = require('../DeprecatedPropTypes/DeprecatedColorPropType'); -const DeprecatedViewStylePropTypes = require('../DeprecatedPropTypes/DeprecatedViewStylePropTypes'); +const DeprecatedColorPropType = require('./DeprecatedColorPropType'); +const DeprecatedViewStylePropTypes = require('./DeprecatedViewStylePropTypes'); const ReactPropTypes = require('prop-types'); -const TextStylePropTypes = { +const DeprecatedTextStylePropTypes = { ...DeprecatedViewStylePropTypes, color: DeprecatedColorPropType, @@ -153,4 +153,4 @@ const TextStylePropTypes = { ]): React$PropType$Primitive<'auto' | 'ltr' | 'rtl'>), }; -module.exports = TextStylePropTypes; +module.exports = DeprecatedTextStylePropTypes; diff --git a/Libraries/StyleSheet/StyleSheetValidation.js b/Libraries/StyleSheet/StyleSheetValidation.js index d2bb5303f6e955..6871751eb0dad0 100644 --- a/Libraries/StyleSheet/StyleSheetValidation.js +++ b/Libraries/StyleSheet/StyleSheetValidation.js @@ -11,7 +11,7 @@ 'use strict'; const DeprecatedImageStylePropTypes = require('../DeprecatedPropTypes/DeprecatedImageStylePropTypes'); -const TextStylePropTypes = require('../Text/TextStylePropTypes'); +const DeprecatedTextStylePropTypes = require('../DeprecatedPropTypes/DeprecatedTextStylePropTypes'); const DeprecatedViewStylePropTypes = require('../DeprecatedPropTypes/DeprecatedViewStylePropTypes'); const invariant = require('invariant'); @@ -89,7 +89,7 @@ const allStylePropTypes = {}; if (__DEV__ && !global.__RCTProfileIsProfiling) { StyleSheetValidation.addValidStylePropTypes(DeprecatedImageStylePropTypes); - StyleSheetValidation.addValidStylePropTypes(TextStylePropTypes); + StyleSheetValidation.addValidStylePropTypes(DeprecatedTextStylePropTypes); StyleSheetValidation.addValidStylePropTypes(DeprecatedViewStylePropTypes); } diff --git a/Libraries/Text/TextPropTypes.js b/Libraries/Text/TextPropTypes.js deleted file mode 100644 index 216ac303f84fe8..00000000000000 --- a/Libraries/Text/TextPropTypes.js +++ /dev/null @@ -1,158 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - * @format - */ - -'use strict'; - -const DeprecatedColorPropType = require('../DeprecatedPropTypes/DeprecatedColorPropType'); -const DeprecatedEdgeInsetsPropType = require('../DeprecatedPropTypes/DeprecatedEdgeInsetsPropType'); -const DeprecatedStyleSheetPropType = require('../DeprecatedPropTypes/DeprecatedStyleSheetPropType'); -const PropTypes = require('prop-types'); -const TextStylePropTypes = require('./TextStylePropTypes'); - -const stylePropType: ReactPropsCheckType = DeprecatedStyleSheetPropType( - TextStylePropTypes, -); - -const DataDetectorTypes = ['phoneNumber', 'link', 'email', 'none', 'all']; - -module.exports = { - /** - * When `numberOfLines` is set, this prop defines how text will be - * truncated. - * - * See https://facebook.github.io/react-native/docs/text.html#ellipsizemode - */ - ellipsizeMode: (PropTypes.oneOf([ - 'head', - 'middle', - 'tail', - 'clip', - ]): React$PropType$Primitive<'head' | 'middle' | 'tail' | 'clip'>), - /** - * Used to truncate the text with an ellipsis. - * - * See https://facebook.github.io/react-native/docs/text.html#numberoflines - */ - numberOfLines: PropTypes.number, - /** - * Set text break strategy on Android. - * - * See https://facebook.github.io/react-native/docs/text.html#textbreakstrategy - */ - textBreakStrategy: (PropTypes.oneOf([ - 'simple', - 'highQuality', - 'balanced', - ]): React$PropType$Primitive<'simple' | 'highQuality' | 'balanced'>), - /** - * Invoked on mount and layout changes. - * - * See https://facebook.github.io/react-native/docs/text.html#onlayout - */ - onLayout: PropTypes.func, - /** - * This function is called on press. - * - * See https://facebook.github.io/react-native/docs/text.html#onpress - */ - onPress: PropTypes.func, - /** - * This function is called on long press. - * - * See https://facebook.github.io/react-native/docs/text.html#onlongpress - */ - onLongPress: PropTypes.func, - /** - * Defines how far your touch may move off of the button, before - * deactivating the button. - * - * See https://facebook.github.io/react-native/docs/text.html#pressretentionoffset - */ - pressRetentionOffset: DeprecatedEdgeInsetsPropType, - /** - * Lets the user select text. - * - * See https://facebook.github.io/react-native/docs/text.html#selectable - */ - selectable: PropTypes.bool, - /** - * The highlight color of the text. - * - * See https://facebook.github.io/react-native/docs/text.html#selectioncolor - */ - selectionColor: DeprecatedColorPropType, - /** - * When `true`, no visual change is made when text is pressed down. - * - * See https://facebook.github.io/react-native/docs/text.html#supperhighlighting - */ - suppressHighlighting: PropTypes.bool, - style: stylePropType, - /** - * Used to locate this view in end-to-end tests. - * - * See https://facebook.github.io/react-native/docs/text.html#testid - */ - testID: PropTypes.string, - /** - * Used to locate this view from native code. - * - * See https://facebook.github.io/react-native/docs/text.html#nativeid - */ - nativeID: PropTypes.string, - /** - * Whether fonts should scale to respect Text Size accessibility settings. - * - * See https://facebook.github.io/react-native/docs/text.html#allowfontscaling - */ - allowFontScaling: PropTypes.bool, - /** - * Specifies largest possible scale a font can reach when `allowFontScaling` is enabled. - * Possible values: - * `null/undefined` (default): inherit from the parent node or the global default (0) - * `0`: no max, ignore parent/global default - * `>= 1`: sets the maxFontSizeMultiplier of this node to this value - */ - maxFontSizeMultiplier: PropTypes.number, - /** - * Indicates whether the view is an accessibility element. - * - * See https://facebook.github.io/react-native/docs/text.html#accessible - */ - accessible: PropTypes.bool, - /** - * Whether font should be scaled down automatically. - * - * See https://facebook.github.io/react-native/docs/text.html#adjustsfontsizetofit - */ - adjustsFontSizeToFit: PropTypes.bool, - /** - * Smallest possible scale a font can reach. - * - * See https://facebook.github.io/react-native/docs/text.html#minimumfontscale - */ - minimumFontScale: PropTypes.number, - /** - * Specifies the disabled state of the text view for testing purposes. - * - * See https://facebook.github.io/react-native/docs/text.html#disabled - */ - disabled: PropTypes.bool, - /** - * Determines the types of data converted to clickable URLs in text. - * - * See https://facebook.github.io/react-native/docs/text.html#dataDetectorType - */ - dataDetectorType: (PropTypes.oneOf( - DataDetectorTypes, - ): React$PropType$Primitive< - 'phoneNumber' | 'link' | 'email' | 'none' | 'all', - >), -};