@@ -39,12 +39,90 @@ type PointerEventProps = $ReadOnly<{
39
39
onPointerMove ?: ( event : PointerEvent ) => void ,
40
40
} > ;
41
41
42
- /**
43
- * @see https://reactnative.dev/docs/text#reference
44
- */
45
- export type TextProps = $ReadOnly < {
46
- ...PointerEventProps ,
42
+ export type TextPropsIOS = {
43
+ /**
44
+ * Specifies whether font should be scaled down automatically to fit given style constraints.
45
+ *
46
+ * See https://reactnative.dev/docs/text#adjustsfontsizetofit
47
+ */
48
+ adjustsFontSizeToFit ?: ?boolean ,
49
+
50
+ /**
51
+ * The Dynamic Type scale ramp to apply to this element on iOS.
52
+ */
53
+ dynamicTypeRamp ?: ?(
54
+ | 'caption2'
55
+ | 'caption1'
56
+ | 'footnote'
57
+ | 'subheadline'
58
+ | 'callout'
59
+ | 'body'
60
+ | 'headline'
61
+ | 'title3'
62
+ | 'title2'
63
+ | 'title1'
64
+ | 'largeTitle'
65
+ ) ,
66
+
67
+ /**
68
+ * When `true`, no visual change is made when text is pressed down. By
69
+ * default, a gray oval highlights the text on press down.
70
+ *
71
+ * See https://reactnative.dev/docs/text#supperhighlighting
72
+ */
73
+ suppressHighlighting ?: ?boolean ,
74
+
75
+ /**
76
+ * Set line break strategy on iOS.
77
+ *
78
+ * See https://reactnative.dev/docs/text.html#linebreakstrategyios
79
+ */
80
+ lineBreakStrategyIOS ?: ?( 'none' | 'standard' | 'hangul-word' | 'push-out' ) ,
81
+ } ;
82
+
83
+ export type TextPropsAndroid = {
84
+ /**
85
+ * Specifies the disabled state of the text view for testing purposes.
86
+ *
87
+ * See https://reactnative.dev/docs/text#disabled
88
+ */
89
+ disabled ?: ?boolean ,
47
90
91
+ /**
92
+ * The highlight color of the text.
93
+ *
94
+ * See https://reactnative.dev/docs/text#selectioncolor
95
+ */
96
+ selectionColor ?: ?ColorValue ,
97
+
98
+ /**
99
+ * Determines the types of data converted to clickable URLs in the text element.
100
+ * By default no data types are detected.
101
+ */
102
+ dataDetectorType ?: ?( 'phoneNumber' | 'link' | 'email' | 'none' | 'all' ) ,
103
+
104
+ /**
105
+ * Set text break strategy on Android API Level 23+
106
+ * default is `highQuality`.
107
+ *
108
+ * See https://reactnative.dev/docs/text#textbreakstrategy
109
+ */
110
+ textBreakStrategy ?: ?( 'balanced' | 'highQuality' | 'simple' ) ,
111
+
112
+ /**
113
+ * iOS Only
114
+ */
115
+ adjustsFontSizeToFit ?: ?boolean ,
116
+
117
+ /**
118
+ * Specifies smallest possible scale a font can reach when adjustsFontSizeToFit is enabled. (values 0.01-1.0).
119
+ *
120
+ * See https://reactnative.dev/docs/text#minimumfontscale
121
+ */
122
+ minimumFontScale ?: ?number ,
123
+ } ;
124
+
125
+ type TextBaseProps = $ReadOnly < {
48
126
/**
49
127
* Indicates whether the view is an accessibility element.
50
128
*
@@ -60,15 +138,9 @@ export type TextProps = $ReadOnly<{
60
138
accessibilityState ?: ?AccessibilityState ,
61
139
'aria-label' ?: ?string ,
62
140
63
- /**
64
- * Whether font should be scaled down automatically.
65
- *
66
- * See https://reactnative.dev/docs/text#adjustsfontsizetofit
67
- */
68
- adjustsFontSizeToFit ?: ?boolean ,
69
-
70
141
/**
71
142
* Whether fonts should scale to respect Text Size accessibility settings.
143
+ * The default is `true`.
72
144
*
73
145
* See https://reactnative.dev/docs/text#allowfontscaling
74
146
*/
@@ -103,12 +175,28 @@ export type TextProps = $ReadOnly<{
103
175
* When `numberOfLines` is set, this prop defines how text will be
104
176
* truncated.
105
177
*
178
+ * This can be one of the following values:
179
+ *
180
+ * - `head` - The line is displayed so that the end fits in the container and the missing text
181
+ * at the beginning of the line is indicated by an ellipsis glyph. e.g., "...wxyz"
182
+ * - `middle` - The line is displayed so that the beginning and end fit in the container and the
183
+ * missing text in the middle is indicated by an ellipsis glyph. "ab...yz"
184
+ * - `tail` - The line is displayed so that the beginning fits in the container and the
185
+ * missing text at the end of the line is indicated by an ellipsis glyph. e.g., "abcd..."
186
+ * - `clip` - Lines are not drawn past the edge of the text container.
187
+ *
188
+ * The default is `tail`.
189
+ *
190
+ * `numberOfLines` must be set in conjunction with this prop.
191
+ *
192
+ * > `clip` is working only for iOS
193
+ *
106
194
* See https://reactnative.dev/docs/text#ellipsizemode
107
195
*/
108
196
ellipsizeMode ?: ?( 'clip' | 'head' | 'middle' | 'tail' ) ,
109
197
110
198
/**
111
- * Used to locate this view from native code.
199
+ * Used to reference react managed views from native code.
112
200
*
113
201
* See https://reactnative.dev/docs/text#nativeid
114
202
*/
@@ -131,7 +219,11 @@ export type TextProps = $ReadOnly<{
131
219
nativeID ?: ?string ,
132
220
133
221
/**
134
- * Used to truncate the text with an ellipsis.
222
+ * Used to truncate the text with an ellipsis after computing the text
223
+ * layout, including line wrapping, such that the total number of lines
224
+ * does not exceed this number.
225
+ *
226
+ * This prop is commonly used with `ellipsizeMode`.
135
227
*
136
228
* See https://reactnative.dev/docs/text#numberoflines
137
229
*/
@@ -140,19 +232,23 @@ export type TextProps = $ReadOnly<{
140
232
/**
141
233
* Invoked on mount and layout changes.
142
234
*
235
+ * {nativeEvent: { layout: {x, y, width, height}}}.
236
+ *
143
237
* See https://reactnative.dev/docs/text#onlayout
144
238
*/
145
239
onLayout ?: ?( event : LayoutChangeEvent ) => mixed ,
146
240
147
241
/**
148
242
* This function is called on long press.
243
+ * e.g., `onLongPress={this.increaseSize}>`
149
244
*
150
245
* See https://reactnative.dev/docs/text#onlongpress
151
246
*/
152
247
onLongPress ?: ?( event : GestureResponderEvent ) => mixed ,
153
248
154
249
/**
155
250
* This function is called on press.
251
+ * Text intrinsically supports press handling with a default highlight state (which can be disabled with suppressHighlighting).
156
252
*
157
253
* See https://reactnative.dev/docs/text#onpress
158
254
*/
@@ -187,6 +283,10 @@ export type TextProps = $ReadOnly<{
187
283
* See https://reactnative.dev/docs/text#selectable
188
284
*/
189
285
selectable ?: ?boolean ,
286
+
287
+ /**
288
+ * @see https://reactnative.dev/docs/text#style
289
+ */
190
290
style ?: ?TextStyleProp ,
191
291
192
292
/**
@@ -195,74 +295,14 @@ export type TextProps = $ReadOnly<{
195
295
* See https://reactnative.dev/docs/text#testid
196
296
*/
197
297
testID ?: ?string ,
298
+ } > ;
198
299
199
- /**
200
- * Android Only
201
- */
202
-
203
- /**
204
- * Specifies the disabled state of the text view for testing purposes.
205
- *
206
- * See https://reactnative.dev/docs/text#disabled
207
- */
208
- disabled ?: ?boolean ,
209
-
210
- /**
211
- * The highlight color of the text.
212
- *
213
- * See https://reactnative.dev/docs/text#selectioncolor
214
- */
215
- selectionColor ?: ?ColorValue ,
216
-
217
- dataDetectorType ?: ?( 'phoneNumber' | 'link' | 'email' | 'none' | 'all' ) ,
218
-
219
- /**
220
- * Set text break strategy on Android.
221
- *
222
- * See https://reactnative.dev/docs/text#textbreakstrategy
223
- */
224
- textBreakStrategy ?: ?( 'balanced' | 'highQuality' | 'simple' ) ,
225
-
226
- /**
227
- * iOS Only
228
- */
229
- adjustsFontSizeToFit ?: ?boolean ,
230
-
231
- /**
232
- * The Dynamic Type scale ramp to apply to this element on iOS.
233
- */
234
- dynamicTypeRamp ?: ?(
235
- | 'caption2'
236
- | 'caption1'
237
- | 'footnote'
238
- | 'subheadline'
239
- | 'callout'
240
- | 'body'
241
- | 'headline'
242
- | 'title3'
243
- | 'title2'
244
- | 'title1'
245
- | 'largeTitle'
246
- ) ,
247
-
248
- /**
249
- * Smallest possible scale a font can reach.
250
- *
251
- * See https://reactnative.dev/docs/text#minimumfontscale
252
- */
253
- minimumFontScale ?: ?number ,
254
-
255
- /**
256
- * When `true`, no visual change is made when text is pressed down.
257
- *
258
- * See https://reactnative.dev/docs/text#supperhighlighting
259
- */
260
- suppressHighlighting ?: ?boolean ,
261
-
262
- /**
263
- * Set line break strategy on iOS.
264
- *
265
- * See https://reactnative.dev/docs/text.html#linebreakstrategyios
266
- */
267
- lineBreakStrategyIOS ?: ?( 'none' | 'standard' | 'hangul-word' | 'push-out' ) ,
300
+ /**
301
+ * @see https://reactnative.dev/docs/text#reference
302
+ */
303
+ export type TextProps = $ReadOnly < {
304
+ ...PointerEventProps ,
305
+ ...TextPropsIOS ,
306
+ ...TextPropsAndroid ,
307
+ ...TextBaseProps ,
268
308
} > ;
0 commit comments