@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
@@ -107,15 +107,21 @@ export class URL {
107
107
  }
108
108
 
109
109
  get hash(): string {
110
- throw new Error('URL.hash is not implemented');
110
+ const hashMatch = this._url.match(/#([^/]*)/);
111
+ return hashMatch ? `#${hashMatch[1]}` : '';
111
112
  }
112
113
 
113
114
  get host(): string {
114
- throw new Error('URL.host is not implemented');
115
+ const hostMatch = this._url.match(/^https?:\/\/(?:[^@]+@)?([^:/?#]+)/);
116
+ const portMatch = this._url.match(/:(\d+)(?=[/?#]|$)/);
117
+ return hostMatch
118
+ ? hostMatch[1] + (portMatch ? `:${portMatch[1]}` : '')
119
+ : '';
115
120
  }
116
121
 
117
122
  get hostname(): string {
118
- throw new Error('URL.hostname is not implemented');
123
+ const hostnameMatch = this._url.match(/^https?:\/\/(?:[^@]+@)?([^:/?#]+)/);
124
+ return hostnameMatch ? hostnameMatch[1] : '';
119
125
  }
120
126
 
121
127
  get href(): string {
@@ -123,27 +129,33 @@ export class URL {
123
129
  }
124
130
 
125
131
  get origin(): string {
126
- throw new Error('URL.origin is not implemented');
132
+ const matches = this._url.match(/^(https?:\/\/[^/]+)/);
133
+ return matches ? matches[1] : '';
127
134
  }
128
135
 
129
136
  get password(): string {
130
- throw new Error('URL.password is not implemented');
137
+ const passwordMatch = this._url.match(/https?:\/\/.*:(.*)@/);
138
+ return passwordMatch ? passwordMatch[1] : '';
131
139
  }
132
140
 
133
141
  get pathname(): string {
134
- throw new Error('URL.pathname not implemented');
142
+ const pathMatch = this._url.match(/https?:\/\/[^/]+(\/[^?#]*)?/);
143
+ return pathMatch ? pathMatch[1] || '/' : '/';
135
144
  }
136
145
 
137
146
  get port(): string {
138
- throw new Error('URL.port is not implemented');
147
+ const portMatch = this._url.match(/:(\d+)(?=[/?#]|$)/);
148
+ return portMatch ? portMatch[1] : '';
139
149
  }
140
150
 
141
151
  get protocol(): string {
142
- throw new Error('URL.protocol is not implemented');
152
+ const protocolMatch = this._url.match(/^([a-zA-Z][a-zA-Z\d+\-.]*):/);
153
+ return protocolMatch ? protocolMatch[1] + ':' : '';
143
154
  }
144
155
 
145
156
  get search(): string {
146
- throw new Error('URL.search is not implemented');
157
+ const searchMatch = this._url.match(/\?([^#]*)/);
158
+ return searchMatch ? `?${searchMatch[1]}` : '';
147
159
  }
148
160
 
149
161
  get searchParams(): URLSearchParams {
@@ -168,6 +180,7 @@ export class URL {
168
180
  }
169
181
 
170
182
  get username(): string {
171
- throw new Error('URL.username is not implemented');
183
+ const usernameMatch = this._url.match(/^https?:\/\/([^:@]+)(?::[^@]*)?@/);
184
+ return usernameMatch ? usernameMatch[1] : '';
172
185
  }
173
186
  }
@@ -0,0 +1,23 @@
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
+ * @format
8
+ * @flow
9
+ */
10
+
11
+ declare export class URLSearchParams {
12
+ _searchParams: Array<[string, string]>;
13
+ constructor(params?: Record<string, string>): void;
14
+ append(key: string, value: string): void;
15
+ delete(name: string): empty;
16
+ get(name: string): empty;
17
+ getAll(name: string): empty;
18
+ has(name: string): empty;
19
+ set(name: string, value: string): empty;
20
+ sort(): empty;
21
+ @@iterator(): Iterator<[string, string]>;
22
+ toString(): string;
23
+ }
@@ -8,7 +8,7 @@
8
8
  * @format
9
9
  */
10
10
 
11
- import type {HostInstance} from '../../Renderer/shims/ReactNativeTypes';
11
+ import type {HostInstance} from '../../../src/private/types/HostInstance';
12
12
  import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
13
13
 
14
14
  import RCTDeviceEventEmitter from '../../EventEmitter/RCTDeviceEventEmitter';
@@ -8,7 +8,7 @@
8
8
  * @format
9
9
  */
10
10
 
11
- import type {HostInstance} from '../../Renderer/shims/ReactNativeTypes';
11
+ import type {HostInstance} from '../../../src/private/types/HostInstance';
12
12
  import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
13
13
 
14
14
  import RCTDeviceEventEmitter from '../../EventEmitter/RCTDeviceEventEmitter';
@@ -0,0 +1,20 @@
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
+ * @format
8
+ * @flow strict-local
9
+ */
10
+
11
+ /**
12
+ * This is a function exposed to the React Renderer that can be used by the
13
+ * pre-Fabric renderer to emit accessibility events to pre-Fabric nodes.
14
+ */
15
+ declare function legacySendAccessibilityEvent(
16
+ reactTag: number,
17
+ eventType: string,
18
+ ): void;
19
+
20
+ export default legacySendAccessibilityEvent;
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  'use strict';
12
- import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
12
+ import type {HostComponent} from '../../../src/private/types/HostComponent';
13
13
  import type {ViewProps} from '../View/ViewPropTypes';
14
14
 
15
15
  import StyleSheet, {type ColorValue} from '../../StyleSheet/StyleSheet';
@@ -26,7 +26,7 @@ const GRAY = '#999999';
26
26
 
27
27
  type IndicatorSize = number | 'small' | 'large';
28
28
 
29
- type IOSProps = $ReadOnly<{
29
+ type ActivityIndicatorIOSProps = $ReadOnly<{
30
30
  /**
31
31
  Whether the indicator should hide when not animating.
32
32
 
@@ -34,9 +34,9 @@ type IOSProps = $ReadOnly<{
34
34
  */
35
35
  hidesWhenStopped?: ?boolean,
36
36
  }>;
37
- type Props = $ReadOnly<{
37
+ export type ActivityIndicatorProps = $ReadOnly<{
38
38
  ...ViewProps,
39
- ...IOSProps,
39
+ ...ActivityIndicatorIOSProps,
40
40
 
41
41
  /**
42
42
  Whether to show the indicator (`true`) or hide it (`false`).
@@ -69,7 +69,7 @@ const ActivityIndicator = (
69
69
  size = 'small',
70
70
  style,
71
71
  ...restProps
72
- }: Props,
72
+ }: ActivityIndicatorProps,
73
73
  forwardedRef?: any,
74
74
  ) => {
75
75
  let sizeStyle;
@@ -112,7 +112,7 @@ const ActivityIndicator = (
112
112
  // $FlowFixMe[prop-missing] Flow doesn't know when this is the android component
113
113
  <PlatformActivityIndicator {...nativeProps} {...androidProps} />
114
114
  ) : (
115
- /* $FlowFixMe[prop-missing] (>=0.106.0 site=react_native_android_fb) This comment
115
+ /* $FlowFixMe[incompatible-type] (>=0.106.0 site=react_native_android_fb) This comment
116
116
  * suppresses an error found when Flow v0.106 was deployed. To see the
117
117
  * error, delete this comment and run Flow. */
118
118
  <PlatformActivityIndicator {...nativeProps} />
@@ -154,8 +154,8 @@ const ActivityIndicator = (
154
154
  */
155
155
 
156
156
  const ActivityIndicatorWithRef: component(
157
- ref: React.RefSetter<HostComponent<empty>>,
158
- ...props: Props
157
+ ref?: React.RefSetter<HostComponent<empty>>,
158
+ ...props: ActivityIndicatorProps
159
159
  ) = React.forwardRef(ActivityIndicator);
160
160
  ActivityIndicatorWithRef.displayName = 'ActivityIndicator';
161
161
 
@@ -27,7 +27,7 @@ import View from './View/View';
27
27
  import invariant from 'invariant';
28
28
  import * as React from 'react';
29
29
 
30
- type ButtonProps = $ReadOnly<{
30
+ export type ButtonProps = $ReadOnly<{
31
31
  /**
32
32
  Text to display inside the button. On Android the given title will be
33
33
  converted to the uppercased form.
@@ -286,7 +286,7 @@ const Touchable: typeof TouchableNativeFeedback | typeof TouchableOpacity =
286
286
  type ButtonRef = React.ElementRef<typeof Touchable>;
287
287
 
288
288
  const Button: component(
289
- ref: React.RefSetter<ButtonRef>,
289
+ ref?: React.RefSetter<ButtonRef>,
290
290
  ...props: ButtonProps
291
291
  ) = React.forwardRef((props: ButtonProps, ref: React.RefSetter<ButtonRef>) => {
292
292
  const {
@@ -28,7 +28,7 @@ import View from './View/View';
28
28
  import invariant from 'invariant';
29
29
  import * as React from 'react';
30
30
 
31
- type ButtonProps = $ReadOnly<{
31
+ export type ButtonProps = $ReadOnly<{
32
32
  /**
33
33
  Text to display inside the button. On Android the given title will be
34
34
  converted to the uppercased form.
@@ -289,7 +289,7 @@ const Touchable: typeof TouchableNativeFeedback | typeof TouchableOpacity =
289
289
  type ButtonRef = React.ElementRef<typeof Touchable>;
290
290
 
291
291
  const Button: component(
292
- ref: React.RefSetter<ButtonRef>,
292
+ ref?: React.RefSetter<ButtonRef>,
293
293
  ...props: ButtonProps
294
294
  ) = React.forwardRef((props: ButtonProps, ref: React.RefSetter<ButtonRef>) => {
295
295
  // Win32
@@ -8,14 +8,18 @@
8
8
  * @format
9
9
  */
10
10
 
11
- import type {AccessibilityRole} from '../../Components/View/ViewAccessibility';
12
11
  import type {
13
12
  MeasureInWindowOnSuccessCallback,
14
13
  MeasureLayoutOnSuccessCallback,
15
14
  MeasureOnSuccessCallback,
16
- } from '../../Renderer/shims/ReactNativeTypes';
17
- import type {ColorValue, ViewStyleProp} from '../../StyleSheet/StyleSheet';
18
- import type {DirectEventHandler} from '../../Types/CodegenTypes';
15
+ } from '../../../src/private/types/HostInstance';
16
+ import type {AccessibilityRole} from '../../Components/View/ViewAccessibility';
17
+ import typeof DrawerLayoutAndroidCommon from './DrawerLayoutAndroid.js';
18
+ import type {
19
+ DrawerLayoutAndroidMethods,
20
+ DrawerLayoutAndroidProps,
21
+ DrawerLayoutAndroidState,
22
+ } from './DrawerLayoutAndroidTypes';
19
23
 
20
24
  import StyleSheet from '../../StyleSheet/StyleSheet';
21
25
  import dismissKeyboard from '../../Utilities/dismissKeyboard';
@@ -29,99 +33,6 @@ import * as React from 'react';
29
33
 
30
34
  const DRAWER_STATES = ['Idle', 'Dragging', 'Settling'];
31
35
 
32
- type DrawerStates = 'Idle' | 'Dragging' | 'Settling';
33
-
34
- type DrawerSlideEvent = $ReadOnly<{
35
- offset: number,
36
- }>;
37
-
38
- type Props = $ReadOnly<{
39
- accessibilityRole?: ?AccessibilityRole,
40
-
41
- /**
42
- * Determines whether the keyboard gets dismissed in response to a drag.
43
- * - 'none' (the default), drags do not dismiss the keyboard.
44
- * - 'on-drag', the keyboard is dismissed when a drag begins.
45
- */
46
- keyboardDismissMode?: ?('none' | 'on-drag'),
47
-
48
- /**
49
- * Specifies the background color of the drawer. The default value is white.
50
- * If you want to set the opacity of the drawer, use rgba. Example:
51
- *
52
- * ```
53
- * return (
54
- * <DrawerLayoutAndroid drawerBackgroundColor="rgba(0,0,0,0.5)">
55
- * </DrawerLayoutAndroid>
56
- * );
57
- * ```
58
- */
59
- drawerBackgroundColor?: ?ColorValue,
60
-
61
- /**
62
- * Specifies the side of the screen from which the drawer will slide in.
63
- */
64
- drawerPosition: ?('left' | 'right'),
65
-
66
- /**
67
- * Specifies the width of the drawer, more precisely the width of the view that be pulled in
68
- * from the edge of the window.
69
- */
70
- drawerWidth?: ?number,
71
-
72
- /**
73
- * Specifies the lock mode of the drawer. The drawer can be locked in 3 states:
74
- * - unlocked (default), meaning that the drawer will respond (open/close) to touch gestures.
75
- * - locked-closed, meaning that the drawer will stay closed and not respond to gestures.
76
- * - locked-open, meaning that the drawer will stay opened and not respond to gestures.
77
- * The drawer may still be opened and closed programmatically (`openDrawer`/`closeDrawer`).
78
- */
79
- drawerLockMode?: ?('unlocked' | 'locked-closed' | 'locked-open'),
80
-
81
- /**
82
- * Function called whenever there is an interaction with the navigation view.
83
- */
84
- onDrawerSlide?: ?DirectEventHandler<DrawerSlideEvent>,
85
-
86
- /**
87
- * Function called when the drawer state has changed. The drawer can be in 3 states:
88
- * - Idle, meaning there is no interaction with the navigation view happening at the time
89
- * - Dragging, meaning there is currently an interaction with the navigation view
90
- * - Settling, meaning that there was an interaction with the navigation view, and the
91
- * navigation view is now finishing its closing or opening animation
92
- */
93
- onDrawerStateChanged?: ?(state: DrawerStates) => mixed,
94
-
95
- /**
96
- * Function called whenever the navigation view has been opened.
97
- */
98
- onDrawerOpen?: ?() => mixed,
99
-
100
- /**
101
- * Function called whenever the navigation view has been closed.
102
- */
103
- onDrawerClose?: ?() => mixed,
104
-
105
- /**
106
- * The navigation view that will be rendered to the side of the screen and can be pulled in.
107
- */
108
- renderNavigationView: () => React.MixedElement,
109
-
110
- /**
111
- * Make the drawer take the entire screen and draw the background of the
112
- * status bar to allow it to open over the status bar. It will only have an
113
- * effect on API 21+.
114
- */
115
- statusBarBackgroundColor?: ?ColorValue,
116
-
117
- children?: React.Node,
118
- style?: ?ViewStyleProp,
119
- }>;
120
-
121
- type State = {
122
- drawerOpened: boolean,
123
- };
124
-
125
36
  /**
126
37
  * React component that wraps the platform `DrawerLayout` (Android only). The
127
38
  * Drawer (typically used for navigation) is rendered with `renderNavigationView`
@@ -153,7 +64,10 @@ type State = {
153
64
  * },
154
65
  * ```
155
66
  */
156
- class DrawerLayoutAndroid extends React.Component<Props, State> {
67
+ class DrawerLayoutAndroid
68
+ extends React.Component<DrawerLayoutAndroidProps, DrawerLayoutAndroidState>
69
+ implements DrawerLayoutAndroidMethods
70
+ {
157
71
  static get positions(): mixed {
158
72
  console.warn(
159
73
  'Setting DrawerLayoutAndroid drawerPosition using `DrawerLayoutAndroid.positions` is deprecated. Instead pass the string value "left" or "right"',
@@ -168,7 +82,7 @@ class DrawerLayoutAndroid extends React.Component<Props, State> {
168
82
  React.ElementRef<typeof AndroidDrawerLayoutNativeComponent>,
169
83
  >();
170
84
 
171
- state: State = {
85
+ state: DrawerLayoutAndroidState = {
172
86
  drawerOpened: false,
173
87
  };
174
88
 
@@ -391,4 +305,4 @@ const styles = StyleSheet.create({
391
305
  },
392
306
  });
393
307
 
394
- export default DrawerLayoutAndroid;
308
+ export default DrawerLayoutAndroid as $FlowFixMe as DrawerLayoutAndroidCommon;
@@ -10,8 +10,68 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- // $FlowFixMe[cannot-resolve-module]
14
- import typeof DrawerLayoutAndroid from './DrawerLayoutAndroid.android';
13
+ // import typeof DrawerLayoutAndroid from './DrawerLayoutAndroid.android';
14
+ import type {
15
+ MeasureInWindowOnSuccessCallback,
16
+ MeasureLayoutOnSuccessCallback,
17
+ MeasureOnSuccessCallback,
18
+ } from '../../../src/private/types/HostInstance';
19
+ import type {
20
+ DrawerLayoutAndroidMethods,
21
+ DrawerLayoutAndroidProps,
22
+ DrawerLayoutAndroidState,
23
+ } from './DrawerLayoutAndroidTypes';
15
24
 
16
- export default require('../UnimplementedViews/UnimplementedView')
17
- .default as $FlowFixMe as DrawerLayoutAndroid;
25
+ import UnimplementedView from '../UnimplementedViews/UnimplementedView';
26
+ import * as React from 'react';
27
+
28
+ export type {
29
+ DrawerLayoutAndroidProps,
30
+ DrawerSlideEvent,
31
+ } from './DrawerLayoutAndroidTypes';
32
+
33
+ export default class DrawerLayoutAndroid
34
+ extends React.Component<DrawerLayoutAndroidProps, DrawerLayoutAndroidState>
35
+ implements DrawerLayoutAndroidMethods
36
+ {
37
+ render(): React.Node {
38
+ return <UnimplementedView {...this.props} />;
39
+ }
40
+
41
+ openDrawer(): void {
42
+ throw new Error('DrawerLayoutAndroid is only available on Android');
43
+ }
44
+
45
+ closeDrawer(): void {
46
+ throw new Error('DrawerLayoutAndroid is only available on Android');
47
+ }
48
+
49
+ blur(): void {
50
+ throw new Error('DrawerLayoutAndroid is only available on Android');
51
+ }
52
+
53
+ focus(): void {
54
+ throw new Error('DrawerLayoutAndroid is only available on Android');
55
+ }
56
+
57
+ measure(callback: MeasureOnSuccessCallback): void {
58
+ throw new Error('DrawerLayoutAndroid is only available on Android');
59
+ }
60
+
61
+ measureInWindow(callback: MeasureInWindowOnSuccessCallback): void {
62
+ throw new Error('DrawerLayoutAndroid is only available on Android');
63
+ }
64
+
65
+ measureLayout(
66
+ relativeToNativeNode: number,
67
+ onSuccess: MeasureLayoutOnSuccessCallback,
68
+ onFail?: () => void,
69
+ ): void {
70
+ throw new Error('DrawerLayoutAndroid is only available on Android');
71
+ }
72
+
73
+ // $FlowFixMe[unclear-type]
74
+ setNativeProps(nativeProps: Object): void {
75
+ throw new Error('DrawerLayoutAndroid is only available on Android');
76
+ }
77
+ }
@@ -0,0 +1,138 @@
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 {
12
+ MeasureInWindowOnSuccessCallback,
13
+ MeasureLayoutOnSuccessCallback,
14
+ MeasureOnSuccessCallback,
15
+ } from '../../../src/private/types/HostInstance';
16
+ import type {ColorValue} from '../../StyleSheet/StyleSheet';
17
+ import type {NativeSyntheticEvent} from '../../Types/CoreEventTypes';
18
+ import type {ViewProps} from '../View/ViewPropTypes';
19
+
20
+ import * as React from 'react';
21
+
22
+ export type DrawerStates = 'Idle' | 'Dragging' | 'Settling';
23
+
24
+ export type DrawerSlideEvent = NativeSyntheticEvent<
25
+ $ReadOnly<{
26
+ offset: number,
27
+ }>,
28
+ >;
29
+
30
+ export type DrawerLayoutAndroidProps = $ReadOnly<{
31
+ ...ViewProps,
32
+
33
+ /**
34
+ * Determines whether the keyboard gets dismissed in response to a drag.
35
+ * - 'none' (the default), drags do not dismiss the keyboard.
36
+ * - 'on-drag', the keyboard is dismissed when a drag begins.
37
+ */
38
+ keyboardDismissMode?: ?('none' | 'on-drag'),
39
+
40
+ /**
41
+ * Specifies the background color of the drawer. The default value is white.
42
+ * If you want to set the opacity of the drawer, use rgba. Example:
43
+ *
44
+ * ```
45
+ * return (
46
+ * <DrawerLayoutAndroid drawerBackgroundColor="rgba(0,0,0,0.5)">
47
+ * </DrawerLayoutAndroid>
48
+ * );
49
+ * ```
50
+ */
51
+ drawerBackgroundColor?: ?ColorValue,
52
+
53
+ /**
54
+ * Specifies the side of the screen from which the drawer will slide in.
55
+ */
56
+ drawerPosition: ?('left' | 'right'),
57
+
58
+ /**
59
+ * Specifies the width of the drawer, more precisely the width of the view that be pulled in
60
+ * from the edge of the window.
61
+ */
62
+ drawerWidth?: ?number,
63
+
64
+ /**
65
+ * Specifies the lock mode of the drawer. The drawer can be locked in 3 states:
66
+ * - unlocked (default), meaning that the drawer will respond (open/close) to touch gestures.
67
+ * - locked-closed, meaning that the drawer will stay closed and not respond to gestures.
68
+ * - locked-open, meaning that the drawer will stay opened and not respond to gestures.
69
+ * The drawer may still be opened and closed programmatically (`openDrawer`/`closeDrawer`).
70
+ */
71
+ drawerLockMode?: ?('unlocked' | 'locked-closed' | 'locked-open'),
72
+
73
+ /**
74
+ * Function called whenever there is an interaction with the navigation view.
75
+ */
76
+ onDrawerSlide?: ?(event: DrawerSlideEvent) => mixed,
77
+
78
+ /**
79
+ * Function called when the drawer state has changed. The drawer can be in 3 states:
80
+ * - Idle, meaning there is no interaction with the navigation view happening at the time
81
+ * - Dragging, meaning there is currently an interaction with the navigation view
82
+ * - Settling, meaning that there was an interaction with the navigation view, and the
83
+ * navigation view is now finishing its closing or opening animation
84
+ */
85
+ onDrawerStateChanged?: ?(state: DrawerStates) => mixed,
86
+
87
+ /**
88
+ * Function called whenever the navigation view has been opened.
89
+ */
90
+ onDrawerOpen?: ?() => mixed,
91
+
92
+ /**
93
+ * Function called whenever the navigation view has been closed.
94
+ */
95
+ onDrawerClose?: ?() => mixed,
96
+
97
+ /**
98
+ * The navigation view that will be rendered to the side of the screen and can be pulled in.
99
+ */
100
+ renderNavigationView: () => React.MixedElement,
101
+
102
+ /**
103
+ * Make the drawer take the entire screen and draw the background of the
104
+ * status bar to allow it to open over the status bar. It will only have an
105
+ * effect on API 21+.
106
+ */
107
+ statusBarBackgroundColor?: ?ColorValue,
108
+ }>;
109
+
110
+ export type DrawerLayoutAndroidState = {
111
+ drawerOpened: boolean,
112
+ };
113
+
114
+ export interface DrawerLayoutAndroidMethods {
115
+ /**
116
+ * Opens the drawer.
117
+ */
118
+ openDrawer(): void;
119
+
120
+ /**
121
+ * Closes the drawer.
122
+ */
123
+ closeDrawer(): void;
124
+
125
+ /**
126
+ * Native methods
127
+ */
128
+ blur(): void;
129
+ focus(): void;
130
+ measure(callback: MeasureOnSuccessCallback): void;
131
+ measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;
132
+ measureLayout(
133
+ relativeToNativeNode: number,
134
+ onSuccess: MeasureLayoutOnSuccessCallback,
135
+ onFail?: () => void,
136
+ ): void;
137
+ setNativeProps(nativeProps: Object): void;
138
+ }
@@ -25,7 +25,7 @@ import View from '../View/View';
25
25
  import Keyboard from './Keyboard';
26
26
  import * as React from 'react';
27
27
 
28
- type Props = $ReadOnly<{
28
+ export type KeyboardAvoidingViewProps = $ReadOnly<{
29
29
  ...ViewProps,
30
30
 
31
31
  /**
@@ -59,7 +59,10 @@ type State = {
59
59
  * View that moves out of the way when the keyboard appears by automatically
60
60
  * adjusting its height, position, or bottom padding.
61
61
  */
62
- class KeyboardAvoidingView extends React.Component<Props, State> {
62
+ class KeyboardAvoidingView extends React.Component<
63
+ KeyboardAvoidingViewProps,
64
+ State,
65
+ > {
63
66
  _frame: ?ViewLayout = null;
64
67
  _keyboardEvent: ?KeyboardEvent = null;
65
68
  _subscriptions: Array<EventSubscription> = [];
@@ -67,7 +70,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
67
70
  _initialFrameHeight: number = 0;
68
71
  _bottom: number = 0;
69
72
 
70
- constructor(props: Props) {
73
+ constructor(props: KeyboardAvoidingViewProps) {
71
74
  super(props);
72
75
  this.state = {bottom: 0};
73
76
  this.viewRef = React.createRef();
@@ -175,7 +178,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
175
178
  }
176
179
  };
177
180
 
178
- componentDidUpdate(_: Props, prevState: State): void {
181
+ componentDidUpdate(_: KeyboardAvoidingViewProps, prevState: State): void {
179
182
  const enabled = this.props.enabled ?? true;
180
183
  if (enabled && this._bottom !== prevState.bottom) {
181
184
  this.setState({bottom: this._bottom});
@@ -13,7 +13,7 @@ import StyleSheet from '../../StyleSheet/StyleSheet';
13
13
  import LayoutConformanceNativeComponent from './LayoutConformanceNativeComponent';
14
14
  import * as React from 'react';
15
15
 
16
- type Props = $ReadOnly<{
16
+ export type LayoutConformanceProps = $ReadOnly<{
17
17
  /**
18
18
  * strict: Layout in accordance with W3C spec, even when breaking
19
19
  * compatibility: Layout with the same behavior as previous versions of React Native
@@ -29,13 +29,15 @@ type Props = $ReadOnly<{
29
29
  // degrade the error experience).
30
30
  const isFabricUIManagerInstalled = global?.nativeFabricUIManager != null;
31
31
 
32
- function LayoutConformance(props: Props): React.Node {
32
+ function LayoutConformance(props: LayoutConformanceProps): React.Node {
33
33
  return (
34
34
  <LayoutConformanceNativeComponent {...props} style={styles.container} />
35
35
  );
36
36
  }
37
37
 
38
- function UnimplementedLayoutConformance(props: Props): React.Node {
38
+ function UnimplementedLayoutConformance(
39
+ props: LayoutConformanceProps,
40
+ ): React.Node {
39
41
  if (__DEV__) {
40
42
  const warnOnce = require('../../Utilities/warnOnce').default;
41
43
 
@@ -50,7 +52,7 @@ function UnimplementedLayoutConformance(props: Props): React.Node {
50
52
 
51
53
  export default (isFabricUIManagerInstalled
52
54
  ? LayoutConformance
53
- : UnimplementedLayoutConformance) as component(...Props);
55
+ : UnimplementedLayoutConformance) as component(...LayoutConformanceProps);
54
56
 
55
57
  const styles = StyleSheet.create({
56
58
  container: {
@@ -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 {ViewProps} from '../View/ViewPropTypes';
13
13
 
14
14
  import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry';