@office-iss/react-native-win32 0.0.0-canary.287 → 0.0.0-canary.289

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/.flowconfig +6 -2
  2. package/CHANGELOG.json +63 -1
  3. package/CHANGELOG.md +24 -4
  4. package/Libraries/Alert/Alert.d.ts +4 -1
  5. package/Libraries/Alert/Alert.js +3 -0
  6. package/Libraries/{Modal/ModalInjection.js → Alert/RCTAlertManager.js.flow} +7 -4
  7. package/Libraries/Animated/Animated.js +8 -37
  8. package/Libraries/Animated/Animated.js.flow +15 -0
  9. package/Libraries/Animated/AnimatedExports.js +47 -0
  10. package/Libraries/Animated/AnimatedExports.js.flow +48 -0
  11. package/Libraries/Animated/Easing.js +13 -15
  12. package/Libraries/Animated/createAnimatedComponent.js +24 -12
  13. package/Libraries/Animated/nodes/AnimatedNode.js +2 -1
  14. package/Libraries/Animated/nodes/AnimatedProps.js +18 -1
  15. package/Libraries/Animated/nodes/AnimatedValue.js +6 -2
  16. package/Libraries/Animated/useAnimatedValue.js +1 -3
  17. package/Libraries/Blob/URL.js +23 -10
  18. package/Libraries/Blob/URLSearchParams.js.flow +23 -0
  19. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +1 -1
  20. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +1 -1
  21. package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js.flow +20 -0
  22. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +8 -8
  23. package/Libraries/Components/Button.js +2 -2
  24. package/Libraries/Components/Button.win32.js +2 -2
  25. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +14 -100
  26. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +64 -4
  27. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js +138 -0
  28. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +7 -4
  29. package/Libraries/Components/LayoutConformance/LayoutConformance.js +6 -4
  30. package/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js +1 -1
  31. package/Libraries/Components/Pressable/Pressable.js +18 -63
  32. package/Libraries/Components/Pressable/Pressable.win32.js +19 -65
  33. package/Libraries/Components/Pressable/useAndroidRippleForView.js +2 -2
  34. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +4 -46
  35. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +10 -4
  36. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js +54 -0
  37. package/Libraries/Components/RefreshControl/RefreshControl.js +10 -7
  38. package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +2 -1
  39. package/Libraries/Components/SafeAreaView/SafeAreaView.js +1 -1
  40. package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +1 -1
  41. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +2 -4
  42. package/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +2 -4
  43. package/Libraries/Components/ScrollView/ScrollView.js +43 -59
  44. package/Libraries/Components/ScrollView/ScrollViewCommands.js +1 -1
  45. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +2 -4
  46. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +6 -7
  47. package/Libraries/Components/StatusBar/StatusBar.js +33 -22
  48. package/Libraries/Components/Switch/Switch.js +70 -41
  49. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +2 -4
  50. package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +2 -4
  51. package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +2 -4
  52. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  53. package/Libraries/Components/TextInput/Tests/TextInputTest.d.ts +2 -1
  54. package/Libraries/Components/TextInput/Tests/TextInputTest.js.map +1 -1
  55. package/Libraries/Components/TextInput/TextInput.d.ts +6 -0
  56. package/Libraries/Components/TextInput/TextInput.flow.js +45 -14
  57. package/Libraries/Components/TextInput/TextInput.js +121 -136
  58. package/Libraries/Components/TextInput/TextInput.win32.js +122 -137
  59. package/Libraries/Components/TextInput/TextInputState.js +2 -18
  60. package/Libraries/Components/TextInput/TextInputState.win32.js +2 -18
  61. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +1 -1
  62. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.d.ts +2 -1
  63. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  64. package/Libraries/Components/Touchable/Touchable.js +7 -7
  65. package/Libraries/Components/Touchable/Touchable.win32.js +7 -7
  66. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  67. package/Libraries/Components/Touchable/TouchableHighlight.js +35 -14
  68. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +95 -47
  69. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +248 -43
  70. package/Libraries/Components/Touchable/TouchableOpacity.js +52 -10
  71. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +112 -59
  72. package/Libraries/Components/View/View.js +1 -1
  73. package/Libraries/Components/View/View.win32.js +1 -1
  74. package/Libraries/Components/View/ViewNativeComponent.js +2 -4
  75. package/Libraries/Components/View/ViewPropTypes.js +15 -12
  76. package/Libraries/Components/View/ViewPropTypes.win32.js +74 -71
  77. package/Libraries/Core/ReactNativeVersion.js +2 -2
  78. package/Libraries/Core/setUpReactDevTools.js +2 -0
  79. package/Libraries/Debugging/DebuggingOverlayRegistry.js +10 -7
  80. package/Libraries/Image/Image.android.js +1 -1
  81. package/Libraries/Image/Image.js.flow +27 -0
  82. package/Libraries/Image/ImageBackground.js +1 -1
  83. package/Libraries/Image/ImageProps.js +97 -30
  84. package/Libraries/Image/ImageTypes.flow.js +16 -6
  85. package/Libraries/Image/ImageViewNativeComponent.js +3 -5
  86. package/Libraries/Image/Tests/ImageWin32Test.d.ts +2 -1
  87. package/Libraries/Image/Tests/ImageWin32Test.js.map +1 -1
  88. package/Libraries/Image/TextInlineImageNativeComponent.js +2 -4
  89. package/Libraries/Interaction/InteractionManager.js +9 -1
  90. package/Libraries/Interaction/PanResponder.js +11 -11
  91. package/Libraries/Interaction/TaskQueue.js +3 -2
  92. package/Libraries/Lists/FlatList.js +8 -7
  93. package/Libraries/LogBox/LogBox.js +1 -1
  94. package/Libraries/Modal/Modal.js +30 -4
  95. package/Libraries/NativeComponent/BaseViewConfig.js.flow +14 -0
  96. package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
  97. package/Libraries/Network/RCTNetworking.js.flow +44 -0
  98. package/Libraries/Network/XMLHttpRequest_new.js +3 -0
  99. package/Libraries/Network/XMLHttpRequest_old.js +3 -0
  100. package/Libraries/Pressability/HoverState.js +1 -0
  101. package/Libraries/Pressability/HoverState.win32.js +1 -0
  102. package/Libraries/Pressability/Pressability.js +2 -2
  103. package/Libraries/Pressability/Pressability.win32.js +3 -3
  104. package/Libraries/ReactNative/AppRegistry.flow.js +49 -0
  105. package/Libraries/ReactNative/AppRegistry.js +2 -322
  106. package/Libraries/ReactNative/AppRegistry.js.flow +23 -0
  107. package/Libraries/ReactNative/AppRegistryImpl.js +316 -0
  108. package/Libraries/ReactNative/FabricUIManager.js +5 -3
  109. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +7 -5
  110. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +1 -4
  111. package/Libraries/ReactNative/RendererImplementation.js +3 -5
  112. package/Libraries/ReactNative/requireNativeComponent.js +1 -1
  113. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +12 -0
  114. package/Libraries/Renderer/shims/ReactNativeTypes.js +39 -91
  115. package/Libraries/StyleSheet/PlatformColorValueTypes.js.flow +22 -0
  116. package/Libraries/StyleSheet/PlatformColorValueTypesIOS.js +6 -0
  117. package/Libraries/StyleSheet/StyleSheet.js +5 -197
  118. package/Libraries/StyleSheet/StyleSheet.js.flow +166 -0
  119. package/Libraries/StyleSheet/{StyleSheet.win32.js → StyleSheetExports.js} +2 -151
  120. package/Libraries/StyleSheet/StyleSheetExports.js.flow +110 -0
  121. package/Libraries/StyleSheet/StyleSheetTypes.js +42 -18
  122. package/Libraries/Text/Text.d.ts +1 -1
  123. package/Libraries/Text/Text.js +3 -1
  124. package/Libraries/Text/Text.win32.js +3 -1
  125. package/Libraries/Text/TextNativeComponent.js +1 -1
  126. package/Libraries/Text/TextNativeComponent.win32.js +1 -1
  127. package/Libraries/Text/TextProps.js +124 -84
  128. package/Libraries/Text/TextProps.win32.js +124 -84
  129. package/Libraries/Types/CodegenTypesNamespace.d.ts +45 -0
  130. package/Libraries/Types/CodegenTypesNamespace.js +14 -0
  131. package/Libraries/Types/CoreEventTypes.js +1 -1
  132. package/Libraries/Types/CoreEventTypes.win32.js +1 -1
  133. package/Libraries/Types/ReactDevToolsTypes.js +4 -8
  134. package/Libraries/Utilities/BackHandler.js.flow +25 -0
  135. package/Libraries/Utilities/DevSettings.js +14 -0
  136. package/Libraries/Utilities/Dimensions.js +5 -0
  137. package/Libraries/Utilities/Dimensions.win32.js +5 -0
  138. package/{flow/Position.js → Libraries/Utilities/Platform.js.flow} +3 -6
  139. package/Libraries/Utilities/PlatformTypes.js +97 -7
  140. package/Libraries/Utilities/codegenNativeCommands.d.ts +18 -0
  141. package/Libraries/Utilities/codegenNativeComponent.d.ts +26 -0
  142. package/Libraries/Utilities/codegenNativeComponent.js +1 -1
  143. package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +2 -4
  144. package/Libraries/vendor/emitter/EventEmitter.js +6 -2
  145. package/flow/global.js +1 -0
  146. package/flow/jest.js +4 -2
  147. package/index.js +47 -43
  148. package/index.win32.js +63 -59
  149. package/overrides.json +27 -35
  150. package/package.json +18 -18
  151. package/src/private/animated/NativeAnimatedHelper.js +18 -7
  152. package/src/private/animated/NativeAnimatedHelper.win32.js +18 -7
  153. package/src/private/animated/createAnimatedPropsHook.js +34 -15
  154. package/src/private/components/HScrollViewNativeComponents.js +1 -1
  155. package/src/private/components/VScrollViewNativeComponents.js +1 -1
  156. package/src/private/featureflags/ReactNativeFeatureFlags.js +24 -36
  157. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +9 -1
  158. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +4 -4
  159. package/src/private/inspector/getInspectorDataForViewAtPoint.js +2 -4
  160. package/src/private/setup/setUpDOM.js +36 -1
  161. package/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js +1 -1
  162. package/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js +1 -1
  163. package/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js +1 -1
  164. package/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js +1 -1
  165. package/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js +1 -1
  166. package/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js +1 -1
  167. package/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js +1 -1
  168. package/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js +1 -1
  169. package/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js +1 -1
  170. package/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js +1 -1
  171. package/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js +1 -1
  172. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +1 -1
  173. package/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js +1 -1
  174. package/src/private/types/HostComponent.js +16 -0
  175. package/src/private/types/HostInstance.js +50 -0
  176. package/src/private/webapis/dom/nodes/ReactNativeDocument.js +1 -0
  177. package/src/private/webapis/dom/nodes/ReactNativeElement.js +40 -32
  178. package/src/private/webapis/dom/nodes/ReadOnlyCharacterData.js +1 -1
  179. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +1 -1
  180. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -19
  181. package/src/private/webapis/dom/nodes/internals/NodeInternals.js +6 -0
  182. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +4 -4
  183. package/src/private/webapis/mutationobserver/MutationObserver.js +9 -9
  184. package/src/private/webapis/performance/PerformanceObserver.js +6 -6
  185. package/src/types/globals.d.ts +628 -0
  186. package/src/types/third_party/event-target-shim.d.ts +392 -0
  187. package/src-win/Libraries/Components/TextInput/Tests/TextInputTest.tsx +7 -7
  188. package/src-win/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +3 -3
  189. package/src-win/Libraries/Image/Tests/ImageWin32Test.tsx +1 -1
  190. package/src-win/Libraries/Text/Text.d.ts +1 -1
  191. package/types/index.d.ts +5 -52
  192. package/types/modules/globals.d.ts +0 -599
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and 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
8
+ * @format
9
+ */
10
+
11
+ export * as default from './StyleSheetExports';
12
+
13
+ import type {
14
+ ____ColorValue_Internal,
15
+ ____DangerouslyImpreciseStyle_Internal,
16
+ ____DangerouslyImpreciseStyleProp_Internal,
17
+ ____ImageStyle_Internal,
18
+ ____ImageStyleProp_Internal,
19
+ ____TextStyle_Internal,
20
+ ____TextStyleProp_Internal,
21
+ ____ViewStyle_Internal,
22
+ ____ViewStyleProp_Internal,
23
+ } from './StyleSheetTypes';
24
+
25
+ export type {StyleProp} from './StyleSheetTypes';
26
+
27
+ export type StyleSheetProperties = {
28
+ hairlineWidth: number,
29
+ flatten<T: string>(style: T): T,
30
+ };
31
+
32
+ export type {NativeColorValue} from './StyleSheetTypes';
33
+
34
+ /**
35
+ * This type should be used as the type for anything that is a color. It is
36
+ * most useful when using DynamicColorIOS which can be a string or a dynamic
37
+ * color object.
38
+ *
39
+ * type props = {backgroundColor: ColorValue};
40
+ */
41
+ export type ColorValue = ____ColorValue_Internal;
42
+
43
+ /**
44
+ * This type should be used as the type for a prop that is passed through
45
+ * to a <View>'s `style` prop. This ensures call sites of the component
46
+ * can't pass styles that View doesn't support such as `fontSize`.`
47
+ *
48
+ * type Props = {style: ViewStyleProp}
49
+ * const MyComponent = (props: Props) => <View style={props.style} />
50
+ */
51
+ export type ViewStyleProp = ____ViewStyleProp_Internal;
52
+
53
+ /**
54
+ * This type should be used as the type for a prop that is passed through
55
+ * to a <Text>'s `style` prop. This ensures call sites of the component
56
+ * can't pass styles that Text doesn't support such as `resizeMode`.`
57
+ *
58
+ * type Props = {style: TextStyleProp}
59
+ * const MyComponent = (props: Props) => <Text style={props.style} />
60
+ */
61
+ export type TextStyleProp = ____TextStyleProp_Internal;
62
+
63
+ /**
64
+ * This type should be used as the type for a prop that is passed through
65
+ * to an <Image>'s `style` prop. This ensures call sites of the component
66
+ * can't pass styles that Image doesn't support such as `fontSize`.`
67
+ *
68
+ * type Props = {style: ImageStyleProp}
69
+ * const MyComponent = (props: Props) => <Image style={props.style} />
70
+ */
71
+ export type ImageStyleProp = ____ImageStyleProp_Internal;
72
+
73
+ /**
74
+ * WARNING: You probably shouldn't be using this type. This type
75
+ * is similar to the ones above except it allows styles that are accepted
76
+ * by all of View, Text, or Image. It is therefore very unsafe to pass this
77
+ * through to an underlying component. Using this is almost always a mistake
78
+ * and using one of the other more restrictive types is likely the right choice.
79
+ */
80
+ export type DangerouslyImpreciseStyleProp =
81
+ ____DangerouslyImpreciseStyleProp_Internal;
82
+
83
+ /**
84
+ * Utility type for getting the values for specific style keys.
85
+ *
86
+ * The following is bad because position is more restrictive than 'string':
87
+ * ```
88
+ * type Props = {position: string};
89
+ * ```
90
+ *
91
+ * You should use the following instead:
92
+ *
93
+ * ```
94
+ * type Props = {position: TypeForStyleKey<'position'>};
95
+ * ```
96
+ *
97
+ * This will correctly give you the type 'absolute' | 'relative'
98
+ */
99
+ export type TypeForStyleKey<
100
+ +key: $Keys<____DangerouslyImpreciseStyle_Internal>,
101
+ > = $ElementType<____DangerouslyImpreciseStyle_Internal, key>;
102
+
103
+ /**
104
+ * This type is an object of the different possible style
105
+ * properties that can be specified for View.
106
+ *
107
+ * Note that this isn't a safe way to type a style prop for a component as
108
+ * results from StyleSheet.create return an internal identifier, not
109
+ * an object of styles.
110
+ *
111
+ * If you want to type the style prop of a function,
112
+ * consider using ViewStyleProp.
113
+ *
114
+ * A reasonable usage of this type is for helper functions that return an
115
+ * object of styles to pass to a View that can't be precomputed with
116
+ * StyleSheet.create.
117
+ */
118
+ export type ViewStyle = ____ViewStyle_Internal;
119
+
120
+ /**
121
+ * This type is an object of the different possible style
122
+ * properties that can be specified for Text.
123
+ *
124
+ * Note that this isn't a safe way to type a style prop for a component as
125
+ * results from StyleSheet.create return an internal identifier, not
126
+ * an object of styles.
127
+ *
128
+ * If you want to type the style prop of a function,
129
+ * consider using TextStyleProp.
130
+ *
131
+ * A reasonable usage of this type is for helper functions that return an
132
+ * object of styles to pass to a Text that can't be precomputed with
133
+ * StyleSheet.create.
134
+ */
135
+ export type TextStyle = ____TextStyle_Internal;
136
+
137
+ /**
138
+ * This type is an object of the different possible style
139
+ * properties that can be specified for Image.
140
+ *
141
+ * Note that this isn't a safe way to type a style prop for a component as
142
+ * results from StyleSheet.create return an internal identifier, not
143
+ * an object of styles.
144
+ *
145
+ * If you want to type the style prop of a function,
146
+ * consider using ImageStyleProp.
147
+ *
148
+ * A reasonable usage of this type is for helper functions that return an
149
+ * object of styles to pass to an Image that can't be precomputed with
150
+ * StyleSheet.create.
151
+ */
152
+ export type ImageStyle = ____ImageStyle_Internal;
153
+
154
+ /**
155
+ * WARNING: You probably shouldn't be using this type. This type is an object
156
+ * with all possible style keys and their values. Note that this isn't
157
+ * a safe way to type a style prop for a component as results from
158
+ * StyleSheet.create return an internal identifier, not an object of styles.
159
+ *
160
+ * If you want to type the style prop of a function, consider using
161
+ * ViewStyleProp, TextStyleProp, or ImageStyleProp.
162
+ *
163
+ * This should only be used by very core utilities that operate on an object
164
+ * containing any possible style value.
165
+ */
166
+ export type DangerouslyImpreciseStyle = ____DangerouslyImpreciseStyle_Internal;
@@ -10,18 +10,7 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- import type {
14
- ____ColorValue_Internal,
15
- ____DangerouslyImpreciseStyle_Internal,
16
- ____DangerouslyImpreciseStyleProp_Internal,
17
- ____ImageStyle_Internal,
18
- ____ImageStyleProp_Internal,
19
- ____Styles_Internal,
20
- ____TextStyle_Internal,
21
- ____TextStyleProp_Internal,
22
- ____ViewStyle_Internal,
23
- ____ViewStyleProp_Internal,
24
- } from './StyleSheetTypes';
13
+ import type {____Styles_Internal} from './StyleSheetTypes';
25
14
 
26
15
  import composeStyles from '../../src/private/styles/composeStyles';
27
16
  import flatten from './flattenStyle';
@@ -29,146 +18,8 @@ import flatten from './flattenStyle';
29
18
  const ReactNativeStyleAttributes =
30
19
  require('../Components/View/ReactNativeStyleAttributes').default;
31
20
  const PixelRatio = require('../Utilities/PixelRatio').default;
32
- const Platform = require('../Utilities/Platform').default; // [Win32]
33
21
 
34
- export type {NativeColorValue} from './StyleSheetTypes';
35
-
36
- /**
37
- * This type should be used as the type for anything that is a color. It is
38
- * most useful when using DynamicColorIOS which can be a string or a dynamic
39
- * color object.
40
- *
41
- * type props = {backgroundColor: ColorValue};
42
- */
43
- export type ColorValue = ____ColorValue_Internal;
44
-
45
- /**
46
- * This type should be used as the type for a prop that is passed through
47
- * to a <View>'s `style` prop. This ensures call sites of the component
48
- * can't pass styles that View doesn't support such as `fontSize`.`
49
- *
50
- * type Props = {style: ViewStyleProp}
51
- * const MyComponent = (props: Props) => <View style={props.style} />
52
- */
53
- export type ViewStyleProp = ____ViewStyleProp_Internal;
54
-
55
- /**
56
- * This type should be used as the type for a prop that is passed through
57
- * to a <Text>'s `style` prop. This ensures call sites of the component
58
- * can't pass styles that Text doesn't support such as `resizeMode`.`
59
- *
60
- * type Props = {style: TextStyleProp}
61
- * const MyComponent = (props: Props) => <Text style={props.style} />
62
- */
63
- export type TextStyleProp = ____TextStyleProp_Internal;
64
-
65
- /**
66
- * This type should be used as the type for a prop that is passed through
67
- * to an <Image>'s `style` prop. This ensures call sites of the component
68
- * can't pass styles that Image doesn't support such as `fontSize`.`
69
- *
70
- * type Props = {style: ImageStyleProp}
71
- * const MyComponent = (props: Props) => <Image style={props.style} />
72
- */
73
- export type ImageStyleProp = ____ImageStyleProp_Internal;
74
-
75
- /**
76
- * WARNING: You probably shouldn't be using this type. This type
77
- * is similar to the ones above except it allows styles that are accepted
78
- * by all of View, Text, or Image. It is therefore very unsafe to pass this
79
- * through to an underlying component. Using this is almost always a mistake
80
- * and using one of the other more restrictive types is likely the right choice.
81
- */
82
- export type DangerouslyImpreciseStyleProp =
83
- ____DangerouslyImpreciseStyleProp_Internal;
84
-
85
- /**
86
- * Utility type for getting the values for specific style keys.
87
- *
88
- * The following is bad because position is more restrictive than 'string':
89
- * ```
90
- * type Props = {position: string};
91
- * ```
92
- *
93
- * You should use the following instead:
94
- *
95
- * ```
96
- * type Props = {position: TypeForStyleKey<'position'>};
97
- * ```
98
- *
99
- * This will correctly give you the type 'absolute' | 'relative'
100
- */
101
- export type TypeForStyleKey<
102
- +key: $Keys<____DangerouslyImpreciseStyle_Internal>,
103
- > = $ElementType<____DangerouslyImpreciseStyle_Internal, key>;
104
-
105
- /**
106
- * This type is an object of the different possible style
107
- * properties that can be specified for View.
108
- *
109
- * Note that this isn't a safe way to type a style prop for a component as
110
- * results from StyleSheet.create return an internal identifier, not
111
- * an object of styles.
112
- *
113
- * If you want to type the style prop of a function,
114
- * consider using ViewStyleProp.
115
- *
116
- * A reasonable usage of this type is for helper functions that return an
117
- * object of styles to pass to a View that can't be precomputed with
118
- * StyleSheet.create.
119
- */
120
- export type ViewStyle = ____ViewStyle_Internal;
121
-
122
- /**
123
- * This type is an object of the different possible style
124
- * properties that can be specified for Text.
125
- *
126
- * Note that this isn't a safe way to type a style prop for a component as
127
- * results from StyleSheet.create return an internal identifier, not
128
- * an object of styles.
129
- *
130
- * If you want to type the style prop of a function,
131
- * consider using TextStyleProp.
132
- *
133
- * A reasonable usage of this type is for helper functions that return an
134
- * object of styles to pass to a Text that can't be precomputed with
135
- * StyleSheet.create.
136
- */
137
- export type TextStyle = ____TextStyle_Internal;
138
-
139
- /**
140
- * This type is an object of the different possible style
141
- * properties that can be specified for Image.
142
- *
143
- * Note that this isn't a safe way to type a style prop for a component as
144
- * results from StyleSheet.create return an internal identifier, not
145
- * an object of styles.
146
- *
147
- * If you want to type the style prop of a function,
148
- * consider using ImageStyleProp.
149
- *
150
- * A reasonable usage of this type is for helper functions that return an
151
- * object of styles to pass to an Image that can't be precomputed with
152
- * StyleSheet.create.
153
- */
154
- export type ImageStyle = ____ImageStyle_Internal;
155
-
156
- /**
157
- * WARNING: You probably shouldn't be using this type. This type is an object
158
- * with all possible style keys and their values. Note that this isn't
159
- * a safe way to type a style prop for a component as results from
160
- * StyleSheet.create return an internal identifier, not an object of styles.
161
- *
162
- * If you want to type the style prop of a function, consider using
163
- * ViewStyleProp, TextStyleProp, or ImageStyleProp.
164
- *
165
- * This should only be used by very core utilities that operate on an object
166
- * containing any possible style value.
167
- */
168
- export type DangerouslyImpreciseStyle = ____DangerouslyImpreciseStyle_Internal;
169
-
170
- let hairlineWidth: number =
171
- Platform.OS === 'win32' ? 0.5 : PixelRatio.roundToNearestPixel(0.4); // TODO(windows ISS) - Avoid calls to PixelRatio - needs multi window support
22
+ let hairlineWidth: number = PixelRatio.roundToNearestPixel(0.4);
172
23
  if (hairlineWidth === 0) {
173
24
  hairlineWidth = 1 / PixelRatio.get();
174
25
  }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and 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
8
+ * @format
9
+ */
10
+
11
+ import type {____Styles_Internal} from './StyleSheetTypes';
12
+
13
+ import composeStyles from '../../src/private/styles/composeStyles';
14
+ import flattenStyle from './flattenStyle';
15
+
16
+ /**
17
+ * This is defined as the width of a thin line on the platform. It can be
18
+ * used as the thickness of a border or division between two elements.
19
+ * Example:
20
+ * ```
21
+ * {
22
+ * borderBottomColor: '#bbb',
23
+ * borderBottomWidth: StyleSheet.hairlineWidth
24
+ * }
25
+ * ```
26
+ *
27
+ * This constant will always be a round number of pixels (so a line defined
28
+ * by it look crisp) and will try to match the standard width of a thin line
29
+ * on the underlying platform. However, you should not rely on it being a
30
+ * constant size, because on different platforms and screen densities its
31
+ * value may be calculated differently.
32
+ */
33
+ declare export const hairlineWidth: number;
34
+
35
+ /**
36
+ * A very common pattern is to create overlays with position absolute and zero positioning,
37
+ * so `absoluteFill` can be used for convenience and to reduce duplication of these repeated
38
+ * styles.
39
+ */
40
+ declare export const absoluteFill: any;
41
+
42
+ /**
43
+ * Sometimes you may want `absoluteFill` but with a couple tweaks - `absoluteFillObject` can be
44
+ * used to create a customized entry in a `StyleSheet`, e.g.:
45
+ *
46
+ * const styles = StyleSheet.create({
47
+ * wrapper: {
48
+ * ...StyleSheet.absoluteFillObject,
49
+ * top: 10,
50
+ * backgroundColor: 'transparent',
51
+ * },
52
+ * });
53
+ */
54
+ declare export const absoluteFillObject: {
55
+ +bottom: 0,
56
+ +left: 0,
57
+ +position: 'absolute',
58
+ +right: 0,
59
+ +top: 0,
60
+ };
61
+
62
+ /**
63
+ * Combines two styles such that style2 will override any styles in style1.
64
+ * If either style is falsy, the other one is returned without allocating
65
+ * an array, saving allocations and maintaining reference equality for
66
+ * PureComponent checks.
67
+ */
68
+ declare export const compose: typeof composeStyles;
69
+
70
+ /**
71
+ * Flattens an array of style objects, into one aggregated style object.
72
+ *
73
+ * Example:
74
+ * ```
75
+ * const styles = StyleSheet.create({
76
+ * listItem: {
77
+ * flex: 1,
78
+ * fontSize: 16,
79
+ * color: 'white'
80
+ * },
81
+ * selectedListItem: {
82
+ * color: 'green'
83
+ * }
84
+ * });
85
+ *
86
+ * StyleSheet.flatten([styles.listItem, styles.selectedListItem])
87
+ * // returns { flex: 1, fontSize: 16, color: 'green' }
88
+ * ```
89
+ */
90
+ declare export const flatten: typeof flattenStyle;
91
+
92
+ /**
93
+ * WARNING: EXPERIMENTAL. Breaking changes will probably happen a lot and will
94
+ * not be reliably announced. The whole thing might be deleted, who knows? Use
95
+ * at your own risk.
96
+ *
97
+ * Sets a function to use to pre-process a style property value. This is used
98
+ * internally to process color and transform values. You should not use this
99
+ * unless you really know what you are doing and have exhausted other options.
100
+ */
101
+ declare export const setStyleAttributePreprocessor: (
102
+ property: string,
103
+ process: (nextProp: any) => any,
104
+ ) => void;
105
+
106
+ /**
107
+ * An identity function for creating style sheets.
108
+ */
109
+ // $FlowFixMe[unsupported-variance-annotation]
110
+ declare export const create: <+S: ____Styles_Internal>(obj: S) => $ReadOnly<S>;
@@ -760,10 +760,7 @@ type ____BlendMode_Internal =
760
760
  | 'color'
761
761
  | 'luminosity';
762
762
 
763
- export type ____ViewStyle_InternalCore = $ReadOnly<{
764
- ...$Exact<____LayoutStyle_Internal>,
765
- ...$Exact<____ShadowStyle_Internal>,
766
- ...$Exact<____TransformStyle_Internal>,
763
+ export type ____ViewStyle_InternalBase = $ReadOnly<{
767
764
  backfaceVisibility?: 'visible' | 'hidden',
768
765
  backgroundColor?: ____ColorValue_Internal,
769
766
  borderColor?: ____ColorValue_Internal,
@@ -813,6 +810,13 @@ export type ____ViewStyle_InternalCore = $ReadOnly<{
813
810
  isolation?: 'auto' | 'isolate',
814
811
  }>;
815
812
 
813
+ export type ____ViewStyle_InternalCore = $ReadOnly<{
814
+ ...$Exact<____LayoutStyle_Internal>,
815
+ ...$Exact<____ShadowStyle_Internal>,
816
+ ...$Exact<____TransformStyle_Internal>,
817
+ ...____ViewStyle_InternalBase,
818
+ }>;
819
+
816
820
  export type ____ViewStyle_Internal = $ReadOnly<{
817
821
  ...____ViewStyle_InternalCore,
818
822
  ...____ViewStyle_InternalOverrides,
@@ -903,8 +907,7 @@ export type ____FontVariantArray_Internal = $ReadOnlyArray<
903
907
  | 'stylistic-twenty',
904
908
  >;
905
909
 
906
- export type ____TextStyle_InternalCore = $ReadOnly<{
907
- ...$Exact<____ViewStyle_Internal>,
910
+ type ____TextStyle_InternalBase = $ReadOnly<{
908
911
  color?: ____ColorValue_Internal,
909
912
  fontFamily?: string,
910
913
  fontSize?: number,
@@ -935,6 +938,11 @@ export type ____TextStyle_InternalCore = $ReadOnly<{
935
938
  writingDirection?: 'auto' | 'ltr' | 'rtl',
936
939
  }>;
937
940
 
941
+ export type ____TextStyle_InternalCore = $ReadOnly<{
942
+ ...$Exact<____ViewStyle_Internal>,
943
+ ...____TextStyle_InternalBase,
944
+ }>;
945
+
938
946
  export type ____TextStyle_Internal = $ReadOnly<{
939
947
  ...____TextStyle_InternalCore,
940
948
  ...____TextStyle_InternalOverrides,
@@ -967,24 +975,24 @@ export type ____DangerouslyImpreciseStyle_Internal = $ReadOnly<{
967
975
  ...
968
976
  }>;
969
977
 
970
- type GenericStyleProp<+T> =
978
+ export type StyleProp<+T> =
971
979
  | null
972
980
  | void
973
981
  | T
974
982
  | false
975
983
  | ''
976
- | $ReadOnlyArray<GenericStyleProp<T>>;
984
+ | $ReadOnlyArray<StyleProp<T>>;
977
985
 
978
- export type ____DangerouslyImpreciseStyleProp_Internal = GenericStyleProp<
986
+ export type ____DangerouslyImpreciseStyleProp_Internal = StyleProp<
979
987
  Partial<____DangerouslyImpreciseStyle_Internal>,
980
988
  >;
981
- export type ____ViewStyleProp_Internal = GenericStyleProp<
989
+ export type ____ViewStyleProp_Internal = StyleProp<
982
990
  $ReadOnly<Partial<____ViewStyle_Internal>>,
983
991
  >;
984
- export type ____TextStyleProp_Internal = GenericStyleProp<
992
+ export type ____TextStyleProp_Internal = StyleProp<
985
993
  $ReadOnly<Partial<____TextStyle_Internal>>,
986
994
  >;
987
- export type ____ImageStyleProp_Internal = GenericStyleProp<
995
+ export type ____ImageStyleProp_Internal = StyleProp<
988
996
  $ReadOnly<Partial<____ImageStyle_Internal>>,
989
997
  >;
990
998
 
@@ -995,10 +1003,26 @@ export type ____Styles_Internal = {
995
1003
  ...
996
1004
  };
997
1005
 
998
- export type ____FlattenStyleProp_Internal<
999
- +TStyleProp: GenericStyleProp<mixed>,
1000
- > = TStyleProp extends null | void | false | ''
1006
+ // A depth limiter, to avoid TS2589 in TypeScript. This and
1007
+ // ____FlattenStyleProp_Helper should be considered internal.
1008
+ type FlattenDepthLimiter = [void, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
1009
+ type ____FlattenStyleProp_Helper<
1010
+ +TStyleProp: StyleProp<mixed>,
1011
+ Depth: $Values<FlattenDepthLimiter> = 9,
1012
+ > = Depth extends 0
1001
1013
  ? empty
1002
- : TStyleProp extends $ReadOnlyArray<infer V>
1003
- ? ____FlattenStyleProp_Internal<V>
1004
- : TStyleProp;
1014
+ : TStyleProp extends null | void | false | ''
1015
+ ? empty
1016
+ : // When TStyleProp is an array, recurse with decremented Depth
1017
+ TStyleProp extends $ReadOnlyArray<infer V>
1018
+ ? ____FlattenStyleProp_Helper<
1019
+ V,
1020
+ Depth extends number ? FlattenDepthLimiter[Depth] : 0,
1021
+ >
1022
+ : TStyleProp;
1023
+
1024
+ export type ____FlattenStyleProp_Internal<+TStyleProp: StyleProp<mixed>> =
1025
+ ____FlattenStyleProp_Helper<TStyleProp> extends empty
1026
+ ? // $FlowFixMe[unclear-type]
1027
+ any
1028
+ : ____FlattenStyleProp_Helper<TStyleProp>;
@@ -263,7 +263,7 @@ export interface TextProps
263
263
 
264
264
  /**
265
265
  * This function is called on long press.
266
- * e.g., `onLongPress={this.increaseSize}>``
266
+ * e.g., `onLongPress={this.increaseSize}>`
267
267
  */
268
268
  onLongPress?: ((event: GestureResponderEvent) => void) | undefined;
269
269
 
@@ -24,6 +24,8 @@ import {NativeText, NativeVirtualText} from './TextNativeComponent';
24
24
  import * as React from 'react';
25
25
  import {useContext, useMemo, useState} from 'react';
26
26
 
27
+ export type {TextProps} from './TextProps';
28
+
27
29
  type TextForwardRef = React.ElementRef<
28
30
  typeof NativeText | typeof NativeVirtualText,
29
31
  >;
@@ -34,7 +36,7 @@ type TextForwardRef = React.ElementRef<
34
36
  * @see https://reactnative.dev/docs/text
35
37
  */
36
38
  const Text: component(
37
- ref: React.RefSetter<TextForwardRef>,
39
+ ref?: React.RefSetter<TextForwardRef>,
38
40
  ...props: TextProps
39
41
  ) = React.forwardRef(
40
42
  (
@@ -24,6 +24,8 @@ import {NativeText, NativeVirtualText} from './TextNativeComponent';
24
24
  import * as React from 'react';
25
25
  import {useContext, useMemo, useState} from 'react';
26
26
 
27
+ export type {TextProps} from './TextProps';
28
+
27
29
  type TextForwardRef = React.ElementRef<
28
30
  typeof NativeText | typeof NativeVirtualText,
29
31
  >;
@@ -34,7 +36,7 @@ type TextForwardRef = React.ElementRef<
34
36
  * @see https://reactnative.dev/docs/text
35
37
  */
36
38
  const Text: component(
37
- ref: React.RefSetter<TextForwardRef>,
39
+ ref?: React.RefSetter<TextForwardRef>,
38
40
  ...props: TextProps
39
41
  ) = React.forwardRef(
40
42
  (
@@ -8,7 +8,7 @@
8
8
  * @format
9
9
  */
10
10
 
11
- import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
11
+ import type {HostComponent} from '../../src/private/types/HostComponent';
12
12
  import type {ProcessedColorValue} from '../StyleSheet/processColor';
13
13
  import type {GestureResponderEvent} from '../Types/CoreEventTypes';
14
14
  import type {TextProps} from './TextProps';
@@ -8,7 +8,7 @@
8
8
  * @format
9
9
  */
10
10
 
11
- import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
11
+ import type {HostComponent} from '../../src/private/types/HostComponent';
12
12
  import type {ProcessedColorValue} from '../StyleSheet/processColor';
13
13
  import type {GestureResponderEvent} from '../Types/CoreEventTypes';
14
14
  import type {TextProps} from './TextProps';