TextProps.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  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. * @flow strict-local
  8. * @format
  9. */
  10. 'use strict';
  11. import type {
  12. LayoutEvent,
  13. PressEvent,
  14. TextLayoutEvent,
  15. } from '../Types/CoreEventTypes';
  16. import type {Node} from 'react';
  17. import type {TextStyleProp} from '../StyleSheet/StyleSheet';
  18. import type {
  19. AccessibilityRole,
  20. AccessibilityState,
  21. } from '../Components/View/ViewAccessibility';
  22. export type PressRetentionOffset = $ReadOnly<{|
  23. top: number,
  24. left: number,
  25. bottom: number,
  26. right: number,
  27. |}>;
  28. /**
  29. * @see https://reactnative.dev/docs/text.html#reference
  30. */
  31. export type TextProps = $ReadOnly<{|
  32. /**
  33. * Indicates whether the view is an accessibility element.
  34. *
  35. * See https://reactnative.dev/docs/text.html#accessible
  36. */
  37. accessible?: ?boolean,
  38. accessibilityHint?: ?Stringish,
  39. accessibilityLabel?: ?Stringish,
  40. accessibilityRole?: ?AccessibilityRole,
  41. accessibilityState?: ?AccessibilityState,
  42. /**
  43. * Whether font should be scaled down automatically.
  44. *
  45. * See https://reactnative.dev/docs/text.html#adjustsfontsizetofit
  46. */
  47. adjustsFontSizeToFit?: ?boolean,
  48. /**
  49. * Whether fonts should scale to respect Text Size accessibility settings.
  50. *
  51. * See https://reactnative.dev/docs/text.html#allowfontscaling
  52. */
  53. allowFontScaling?: ?boolean,
  54. children?: ?Node,
  55. /**
  56. * When `numberOfLines` is set, this prop defines how text will be
  57. * truncated.
  58. *
  59. * See https://reactnative.dev/docs/text.html#ellipsizemode
  60. */
  61. ellipsizeMode?: ?('clip' | 'head' | 'middle' | 'tail'),
  62. /**
  63. * Specifies largest possible scale a font can reach when `allowFontScaling` is enabled.
  64. * Possible values:
  65. * `null/undefined` (default): inherit from the parent node or the global default (0)
  66. * `0`: no max, ignore parent/global default
  67. * `>= 1`: sets the maxFontSizeMultiplier of this node to this value
  68. */
  69. maxFontSizeMultiplier?: ?number,
  70. /**
  71. * Used to locate this view from native code.
  72. *
  73. * See https://reactnative.dev/docs/text.html#nativeid
  74. */
  75. nativeID?: ?string,
  76. /**
  77. * Used to truncate the text with an ellipsis.
  78. *
  79. * See https://reactnative.dev/docs/text.html#numberoflines
  80. */
  81. numberOfLines?: ?number,
  82. /**
  83. * Invoked on mount and layout changes.
  84. *
  85. * See https://reactnative.dev/docs/text.html#onlayout
  86. */
  87. onLayout?: ?(event: LayoutEvent) => mixed,
  88. /**
  89. * This function is called on long press.
  90. *
  91. * See https://reactnative.dev/docs/text.html#onlongpress
  92. */
  93. onLongPress?: ?(event: PressEvent) => mixed,
  94. /**
  95. * This function is called on press.
  96. *
  97. * See https://reactnative.dev/docs/text.html#onpress
  98. */
  99. onPress?: ?(event: PressEvent) => mixed,
  100. onResponderGrant?: ?(event: PressEvent, dispatchID: string) => void,
  101. onResponderMove?: ?(event: PressEvent) => void,
  102. onResponderRelease?: ?(event: PressEvent) => void,
  103. onResponderTerminate?: ?(event: PressEvent) => void,
  104. onResponderTerminationRequest?: ?() => boolean,
  105. onStartShouldSetResponder?: ?() => boolean,
  106. onMoveShouldSetResponder?: ?() => boolean,
  107. onTextLayout?: ?(event: TextLayoutEvent) => mixed,
  108. /**
  109. * Defines how far your touch may move off of the button, before
  110. * deactivating the button.
  111. *
  112. * See https://reactnative.dev/docs/text.html#pressretentionoffset
  113. */
  114. pressRetentionOffset?: ?PressRetentionOffset,
  115. /**
  116. * Lets the user select text.
  117. *
  118. * See https://reactnative.dev/docs/text.html#selectable
  119. */
  120. selectable?: ?boolean,
  121. style?: ?TextStyleProp,
  122. /**
  123. * Used to locate this view in end-to-end tests.
  124. *
  125. * See https://reactnative.dev/docs/text.html#testid
  126. */
  127. testID?: ?string,
  128. /**
  129. * Android Only
  130. */
  131. /**
  132. * Specifies the disabled state of the text view for testing purposes.
  133. *
  134. * See https://reactnative.dev/docs/text.html#disabled
  135. */
  136. disabled?: ?boolean,
  137. /**
  138. * The highlight color of the text.
  139. *
  140. * See https://reactnative.dev/docs/text.html#selectioncolor
  141. */
  142. selectionColor?: ?string,
  143. dataDetectorType?: ?('phoneNumber' | 'link' | 'email' | 'none' | 'all'),
  144. /**
  145. * Set text break strategy on Android.
  146. *
  147. * See https://reactnative.dev/docs/text.html#textbreakstrategy
  148. */
  149. textBreakStrategy?: ?('balanced' | 'highQuality' | 'simple'),
  150. /**
  151. * iOS Only
  152. */
  153. adjustsFontSizeToFit?: ?boolean,
  154. /**
  155. * Smallest possible scale a font can reach.
  156. *
  157. * See https://reactnative.dev/docs/text.html#minimumfontscale
  158. */
  159. minimumFontScale?: ?number,
  160. /**
  161. * When `true`, no visual change is made when text is pressed down.
  162. *
  163. * See https://reactnative.dev/docs/text.html#supperhighlighting
  164. */
  165. suppressHighlighting?: ?boolean,
  166. |}>;