Skip to content

Commit

Permalink
Deprecate Text proptypes (#26055)
Browse files Browse the repository at this point in the history
Summary:
This pull request moves `Text`'s prop types to the `DeprecatedPropTypes` folder.

This was already partly in progress - there were redundant `TextPropTypes` and `DeprecatedTextPropTypes` files so I removed one, and made sure the version with the doc strings was the one used.

## Changelog

[General] [Deprecated] - Move `Text` component's proptypes to DeprecatedPropTypes
Pull Request resolved: #26055

Test Plan: Flow checks pass for iOS and Android

Differential Revision: D16801078

Pulled By: TheSavior

fbshipit-source-id: ef19300945d48d0a4a83d728ee32cdf7d1c0f0cc
  • Loading branch information
empyrical authored and facebook-github-bot committed Aug 15, 2019
1 parent 5113323 commit 0057cc9
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 168 deletions.
4 changes: 2 additions & 2 deletions Libraries/Components/View/ReactNativeStyleAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -22,7 +22,7 @@ const ReactNativeStyleAttributes = {};

for (const attributeName of Object.keys({
...DeprecatedViewStylePropTypes,
...TextStylePropTypes,
...DeprecatedTextStylePropTypes,
...DeprecatedImageStylePropTypes,
})) {
ReactNativeStyleAttributes[attributeName] = true;
Expand Down
110 changes: 108 additions & 2 deletions Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
>),
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -153,4 +153,4 @@ const TextStylePropTypes = {
]): React$PropType$Primitive<'auto' | 'ltr' | 'rtl'>),
};

module.exports = TextStylePropTypes;
module.exports = DeprecatedTextStylePropTypes;
4 changes: 2 additions & 2 deletions Libraries/StyleSheet/StyleSheetValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -89,7 +89,7 @@ const allStylePropTypes = {};

if (__DEV__ && !global.__RCTProfileIsProfiling) {
StyleSheetValidation.addValidStylePropTypes(DeprecatedImageStylePropTypes);
StyleSheetValidation.addValidStylePropTypes(TextStylePropTypes);
StyleSheetValidation.addValidStylePropTypes(DeprecatedTextStylePropTypes);
StyleSheetValidation.addValidStylePropTypes(DeprecatedViewStylePropTypes);
}

Expand Down
158 changes: 0 additions & 158 deletions Libraries/Text/TextPropTypes.js

This file was deleted.

0 comments on commit 0057cc9

Please sign in to comment.