Skip to content

Commit cd8128b

Browse files
elicwhitefacebook-github-bot
authored andcommitted
Move Text PropTypes to it's own file
Reviewed By: fkgozali Differential Revision: D7226404 fbshipit-source-id: b5637dee9a4f10daf0682e46f1ec8920ea03ae33
1 parent e057322 commit cd8128b

File tree

2 files changed

+130
-114
lines changed

2 files changed

+130
-114
lines changed

Libraries/Text/Text.js

+2-114
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@
1010
*/
1111
'use strict';
1212

13-
const ColorPropType = require('ColorPropType');
14-
const EdgeInsetsPropType = require('EdgeInsetsPropType');
1513
const NativeMethodsMixin = require('NativeMethodsMixin');
1614
const React = require('React');
17-
const PropTypes = require('prop-types');
1815
const ReactNativeViewAttributes = require('ReactNativeViewAttributes');
19-
const StyleSheetPropType = require('StyleSheetPropType');
20-
const TextStylePropTypes = require('TextStylePropTypes');
16+
const TextPropTypes = require('TextPropTypes');
2117
const Touchable = require('Touchable');
2218
const UIManager = require('UIManager');
2319

@@ -27,8 +23,6 @@ const mergeFast = require('mergeFast');
2723
const processColor = require('processColor');
2824
const {ViewContextTypes} = require('ViewContext');
2925

30-
const stylePropType = StyleSheetPropType(TextStylePropTypes);
31-
3226
const viewConfig = {
3327
validAttributes: mergeFast(ReactNativeViewAttributes.UIView, {
3428
isHighlighted: true,
@@ -55,113 +49,7 @@ import type {ViewChildContext} from 'ViewContext';
5549

5650
const Text = createReactClass({
5751
displayName: 'Text',
58-
propTypes: {
59-
/**
60-
* When `numberOfLines` is set, this prop defines how text will be
61-
* truncated.
62-
*
63-
* See https://facebook.github.io/react-native/docs/text.html#ellipsizemode
64-
*/
65-
ellipsizeMode: PropTypes.oneOf(['head', 'middle', 'tail', 'clip']),
66-
/**
67-
* Used to truncate the text with an ellipsis.
68-
*
69-
* See https://facebook.github.io/react-native/docs/text.html#numberoflines
70-
*/
71-
numberOfLines: PropTypes.number,
72-
/**
73-
* Set text break strategy on Android.
74-
*
75-
* See https://facebook.github.io/react-native/docs/text.html#textbreakstrategy
76-
*/
77-
textBreakStrategy: PropTypes.oneOf(['simple', 'highQuality', 'balanced']),
78-
/**
79-
* Invoked on mount and layout changes.
80-
*
81-
* See https://facebook.github.io/react-native/docs/text.html#onlayout
82-
*/
83-
onLayout: PropTypes.func,
84-
/**
85-
* This function is called on press.
86-
*
87-
* See https://facebook.github.io/react-native/docs/text.html#onpress
88-
*/
89-
onPress: PropTypes.func,
90-
/**
91-
* This function is called on long press.
92-
*
93-
* See https://facebook.github.io/react-native/docs/text.html#onlongpress
94-
*/
95-
onLongPress: PropTypes.func,
96-
/**
97-
* Defines how far your touch may move off of the button, before
98-
* deactivating the button.
99-
*
100-
* See https://facebook.github.io/react-native/docs/text.html#pressretentionoffset
101-
*/
102-
pressRetentionOffset: EdgeInsetsPropType,
103-
/**
104-
* Lets the user select text.
105-
*
106-
* See https://facebook.github.io/react-native/docs/text.html#selectable
107-
*/
108-
selectable: PropTypes.bool,
109-
/**
110-
* The highlight color of the text.
111-
*
112-
* See https://facebook.github.io/react-native/docs/text.html#selectioncolor
113-
*/
114-
selectionColor: ColorPropType,
115-
/**
116-
* When `true`, no visual change is made when text is pressed down.
117-
*
118-
* See https://facebook.github.io/react-native/docs/text.html#supperhighlighting
119-
*/
120-
suppressHighlighting: PropTypes.bool,
121-
style: stylePropType,
122-
/**
123-
* Used to locate this view in end-to-end tests.
124-
*
125-
* See https://facebook.github.io/react-native/docs/text.html#testid
126-
*/
127-
testID: PropTypes.string,
128-
/**
129-
* Used to locate this view from native code.
130-
*
131-
* See https://facebook.github.io/react-native/docs/text.html#nativeid
132-
*/
133-
nativeID: PropTypes.string,
134-
/**
135-
* Whether fonts should scale to respect Text Size accessibility settings.
136-
*
137-
* See https://facebook.github.io/react-native/docs/text.html#allowfontscaling
138-
*/
139-
allowFontScaling: PropTypes.bool,
140-
/**
141-
* Indicates whether the view is an accessibility element.
142-
*
143-
* See https://facebook.github.io/react-native/docs/text.html#accessible
144-
*/
145-
accessible: PropTypes.bool,
146-
/**
147-
* Whether font should be scaled down automatically.
148-
*
149-
* See https://facebook.github.io/react-native/docs/text.html#adjustsfontsizetofit
150-
*/
151-
adjustsFontSizeToFit: PropTypes.bool,
152-
/**
153-
* Smallest possible scale a font can reach.
154-
*
155-
* See https://facebook.github.io/react-native/docs/text.html#minimumfontscale
156-
*/
157-
minimumFontScale: PropTypes.number,
158-
/**
159-
* Specifies the disabled state of the text view for testing purposes.
160-
*
161-
* See https://facebook.github.io/react-native/docs/text.html#disabled
162-
*/
163-
disabled: PropTypes.bool,
164-
},
52+
propTypes: TextPropTypes,
16553
getDefaultProps(): Object {
16654
return {
16755
accessible: true,

Libraries/Text/TextPropTypes.js

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @providesModule TextPropTypes
8+
* @flow
9+
* @format
10+
*/
11+
12+
'use strict';
13+
14+
const ColorPropType = require('ColorPropType');
15+
const EdgeInsetsPropType = require('EdgeInsetsPropType');
16+
const PropTypes = require('prop-types');
17+
const StyleSheetPropType = require('StyleSheetPropType');
18+
const TextStylePropTypes = require('TextStylePropTypes');
19+
20+
const stylePropType = StyleSheetPropType(TextStylePropTypes);
21+
22+
module.exports = {
23+
/**
24+
* When `numberOfLines` is set, this prop defines how text will be
25+
* truncated.
26+
*
27+
* See https://facebook.github.io/react-native/docs/text.html#ellipsizemode
28+
*/
29+
ellipsizeMode: PropTypes.oneOf(['head', 'middle', 'tail', 'clip']),
30+
/**
31+
* Used to truncate the text with an ellipsis.
32+
*
33+
* See https://facebook.github.io/react-native/docs/text.html#numberoflines
34+
*/
35+
numberOfLines: PropTypes.number,
36+
/**
37+
* Set text break strategy on Android.
38+
*
39+
* See https://facebook.github.io/react-native/docs/text.html#textbreakstrategy
40+
*/
41+
textBreakStrategy: PropTypes.oneOf(['simple', 'highQuality', 'balanced']),
42+
/**
43+
* Invoked on mount and layout changes.
44+
*
45+
* See https://facebook.github.io/react-native/docs/text.html#onlayout
46+
*/
47+
onLayout: PropTypes.func,
48+
/**
49+
* This function is called on press.
50+
*
51+
* See https://facebook.github.io/react-native/docs/text.html#onpress
52+
*/
53+
onPress: PropTypes.func,
54+
/**
55+
* This function is called on long press.
56+
*
57+
* See https://facebook.github.io/react-native/docs/text.html#onlongpress
58+
*/
59+
onLongPress: PropTypes.func,
60+
/**
61+
* Defines how far your touch may move off of the button, before
62+
* deactivating the button.
63+
*
64+
* See https://facebook.github.io/react-native/docs/text.html#pressretentionoffset
65+
*/
66+
pressRetentionOffset: EdgeInsetsPropType,
67+
/**
68+
* Lets the user select text.
69+
*
70+
* See https://facebook.github.io/react-native/docs/text.html#selectable
71+
*/
72+
selectable: PropTypes.bool,
73+
/**
74+
* The highlight color of the text.
75+
*
76+
* See https://facebook.github.io/react-native/docs/text.html#selectioncolor
77+
*/
78+
selectionColor: ColorPropType,
79+
/**
80+
* When `true`, no visual change is made when text is pressed down.
81+
*
82+
* See https://facebook.github.io/react-native/docs/text.html#supperhighlighting
83+
*/
84+
suppressHighlighting: PropTypes.bool,
85+
style: stylePropType,
86+
/**
87+
* Used to locate this view in end-to-end tests.
88+
*
89+
* See https://facebook.github.io/react-native/docs/text.html#testid
90+
*/
91+
testID: PropTypes.string,
92+
/**
93+
* Used to locate this view from native code.
94+
*
95+
* See https://facebook.github.io/react-native/docs/text.html#nativeid
96+
*/
97+
nativeID: PropTypes.string,
98+
/**
99+
* Whether fonts should scale to respect Text Size accessibility settings.
100+
*
101+
* See https://facebook.github.io/react-native/docs/text.html#allowfontscaling
102+
*/
103+
allowFontScaling: PropTypes.bool,
104+
/**
105+
* Indicates whether the view is an accessibility element.
106+
*
107+
* See https://facebook.github.io/react-native/docs/text.html#accessible
108+
*/
109+
accessible: PropTypes.bool,
110+
/**
111+
* Whether font should be scaled down automatically.
112+
*
113+
* See https://facebook.github.io/react-native/docs/text.html#adjustsfontsizetofit
114+
*/
115+
adjustsFontSizeToFit: PropTypes.bool,
116+
/**
117+
* Smallest possible scale a font can reach.
118+
*
119+
* See https://facebook.github.io/react-native/docs/text.html#minimumfontscale
120+
*/
121+
minimumFontScale: PropTypes.number,
122+
/**
123+
* Specifies the disabled state of the text view for testing purposes.
124+
*
125+
* See https://facebook.github.io/react-native/docs/text.html#disabled
126+
*/
127+
disabled: PropTypes.bool,
128+
};

0 commit comments

Comments
 (0)