react-native-windows 0.66.5 → 0.67.0-preview.4

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 (240) hide show
  1. package/.flowconfig +2 -1
  2. package/CHANGELOG.json +934 -102
  3. package/CHANGELOG.md +358 -43
  4. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +14 -1
  5. package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +2 -0
  6. package/Libraries/Alert/Alert.windows.js +48 -21
  7. package/Libraries/Alert/NativeDialogManagerWindows.js +49 -0
  8. package/Libraries/Animated/AnimatedEvent.js +23 -4
  9. package/Libraries/Animated/NativeAnimatedHelper.js +2 -2
  10. package/Libraries/Animated/components/AnimatedImage.js +3 -3
  11. package/Libraries/Animated/components/AnimatedScrollView.js +3 -3
  12. package/Libraries/Animated/components/AnimatedText.js +3 -3
  13. package/Libraries/Animated/components/AnimatedView.js +1 -3
  14. package/Libraries/Animated/createAnimatedComponent.js +3 -34
  15. package/Libraries/Components/Button.js +3 -0
  16. package/Libraries/Components/Button.windows.js +70 -38
  17. package/Libraries/Components/DatePicker/DatePickerIOS.ios.js +3 -6
  18. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +4 -7
  19. package/Libraries/Components/Flyout/Flyout.js +3 -3
  20. package/Libraries/Components/Flyout/Flyout.js.map +1 -1
  21. package/Libraries/Components/Flyout/FlyoutProps.d.ts +4 -0
  22. package/Libraries/Components/Flyout/FlyoutProps.js.map +1 -1
  23. package/Libraries/Components/Glyph/Glyph.js +2 -2
  24. package/Libraries/Components/Glyph/Glyph.js.map +1 -1
  25. package/Libraries/Components/Keyboard/KeyboardExt.js +4 -3
  26. package/Libraries/Components/Keyboard/KeyboardExt.js.map +1 -1
  27. package/Libraries/Components/Popup/Popup.js +3 -3
  28. package/Libraries/Components/Popup/Popup.js.map +1 -1
  29. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +1 -0
  30. package/Libraries/Components/ScrollView/ScrollView.js +17 -16
  31. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +268 -252
  32. package/Libraries/Components/View/View.js +1 -1
  33. package/Libraries/Components/View/View.windows.js +1 -1
  34. package/Libraries/Components/View/ViewAccessibility.js +1 -1
  35. package/Libraries/Components/View/ViewAccessibility.windows.js +1 -1
  36. package/Libraries/Components/View/ViewWindows.js +1 -1
  37. package/Libraries/Components/View/ViewWindows.js.map +1 -1
  38. package/Libraries/Components/View/ViewWindowsProps.d.ts +42 -2
  39. package/Libraries/Components/View/ViewWindowsProps.js.map +1 -1
  40. package/Libraries/Core/ExceptionsManager.js +45 -80
  41. package/Libraries/Core/ExtendedError.js +0 -1
  42. package/Libraries/Core/ReactNativeVersion.js +2 -2
  43. package/Libraries/Core/setUpBatchedBridge.js +1 -1
  44. package/Libraries/Core/setUpGlobals.js +2 -4
  45. package/Libraries/Core/setUpTimers.js +2 -2
  46. package/Libraries/Image/Image.ios.js +6 -0
  47. package/Libraries/Image/Image.windows.js +6 -0
  48. package/Libraries/Image/ImageBackground.js +10 -8
  49. package/Libraries/Image/ImageProps.js +28 -0
  50. package/Libraries/LogBox/Data/LogBoxData.js +18 -19
  51. package/Libraries/LogBox/UI/LogBoxImages/alert-triangle.png +0 -0
  52. package/Libraries/LogBox/UI/LogBoxImages/chevron-left.png +0 -0
  53. package/Libraries/LogBox/UI/LogBoxImages/chevron-right.png +0 -0
  54. package/Libraries/LogBox/UI/LogBoxImages/close.png +0 -0
  55. package/Libraries/LogBox/UI/LogBoxImages/loader.png +0 -0
  56. package/Libraries/NewAppScreen/components/logo.png +0 -0
  57. package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +2 -1
  58. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +2 -0
  59. package/Libraries/Pressability/Pressability.js +13 -13
  60. package/Libraries/Pressability/Pressability.windows.js +13 -13
  61. package/Libraries/Pressability/PressabilityPerformanceEventEmitter.js +1 -1
  62. package/Libraries/ReactNative/AppRegistry.js +4 -2
  63. package/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +1569 -875
  64. package/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +529 -319
  65. package/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +570 -362
  66. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +1592 -891
  67. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +521 -311
  68. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +562 -354
  69. package/Libraries/Share/Share.js +1 -1
  70. package/Libraries/StyleSheet/normalizeColor.js +2 -2
  71. package/Libraries/Text/Text.windows.js +1 -0
  72. package/Libraries/Text/TextNativeComponent.windows.js +72 -0
  73. package/Libraries/Text/TextProps.js +1 -7
  74. package/Libraries/TurboModule/TurboModuleRegistry.js +1 -1
  75. package/Libraries/Utilities/HMRClient.js +1 -1
  76. package/Microsoft.ReactNative/ABIViewManager.cpp +10 -1
  77. package/Microsoft.ReactNative/ABIViewManager.h +3 -0
  78. package/Microsoft.ReactNative/Base/CoreNativeModules.cpp +0 -6
  79. package/Microsoft.ReactNative/IReactDispatcher.cpp +16 -1
  80. package/Microsoft.ReactNative/IViewManager.idl +25 -0
  81. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +35 -6
  82. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +60 -0
  83. package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp +3 -4
  84. package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.h +3 -3
  85. package/Microsoft.ReactNative/Modules/AlertModule.cpp +57 -14
  86. package/Microsoft.ReactNative/Modules/AlertModule.h +17 -24
  87. package/Microsoft.ReactNative/Modules/Animated/InterpolationAnimatedNode.cpp +4 -2
  88. package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp +3 -1
  89. package/Microsoft.ReactNative/Modules/AppStateModule.cpp +8 -6
  90. package/Microsoft.ReactNative/Modules/AppStateModule.h +6 -9
  91. package/Microsoft.ReactNative/Modules/DeviceInfoModule.cpp +34 -22
  92. package/Microsoft.ReactNative/Modules/DeviceInfoModule.h +8 -4
  93. package/Microsoft.ReactNative/Modules/I18nManagerModule.cpp +6 -4
  94. package/Microsoft.ReactNative/Modules/I18nManagerModule.h +3 -2
  95. package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +47 -95
  96. package/Microsoft.ReactNative/Modules/ImageViewManagerModule.h +28 -17
  97. package/Microsoft.ReactNative/Modules/LinkingManagerModule.cpp +14 -4
  98. package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +1 -1
  99. package/Microsoft.ReactNative/Modules/PaperUIManagerModule.cpp +82 -66
  100. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +14 -1
  101. package/Microsoft.ReactNative/ReactInstanceSettings.idl +3 -1
  102. package/Microsoft.ReactNative/ReactPointerEventArgs.cpp +37 -0
  103. package/Microsoft.ReactNative/ReactPointerEventArgs.h +28 -0
  104. package/Microsoft.ReactNative/ReactPointerEventArgs.idl +67 -0
  105. package/Microsoft.ReactNative/Utils/TextTransform.h +1 -1
  106. package/Microsoft.ReactNative/Utils/XamlIslandUtils.cpp +24 -10
  107. package/Microsoft.ReactNative/Utils/XamlIslandUtils.h +4 -2
  108. package/Microsoft.ReactNative/Version.rc +2 -19
  109. package/Microsoft.ReactNative/Views/FlyoutViewManager.cpp +57 -2
  110. package/Microsoft.ReactNative/Views/FrameworkElementTransferProperties.cpp +3 -0
  111. package/Microsoft.ReactNative/Views/FrameworkElementViewManager.cpp +7 -2
  112. package/Microsoft.ReactNative/Views/Image/ImageViewManager.cpp +16 -6
  113. package/Microsoft.ReactNative/Views/Image/ReactImage.cpp +18 -11
  114. package/Microsoft.ReactNative/Views/Image/ReactImage.h +3 -1
  115. package/Microsoft.ReactNative/Views/RawTextViewManager.cpp +4 -53
  116. package/Microsoft.ReactNative/Views/RawTextViewManager.h +0 -3
  117. package/Microsoft.ReactNative/Views/ShadowNodeBase.h +5 -0
  118. package/Microsoft.ReactNative/Views/Text/TextHighlighterVisitor.cpp +52 -0
  119. package/Microsoft.ReactNative/Views/Text/TextHighlighterVisitor.h +37 -0
  120. package/Microsoft.ReactNative/Views/Text/TextHitTestUtils.cpp +343 -0
  121. package/Microsoft.ReactNative/Views/Text/TextHitTestUtils.h +13 -0
  122. package/Microsoft.ReactNative/Views/Text/TextHitTestVisitor.cpp +76 -0
  123. package/Microsoft.ReactNative/Views/Text/TextHitTestVisitor.h +32 -0
  124. package/Microsoft.ReactNative/Views/Text/TextParentVisitor.cpp +12 -0
  125. package/Microsoft.ReactNative/Views/Text/TextParentVisitor.h +19 -0
  126. package/Microsoft.ReactNative/Views/Text/TextPropertyChangedParentVisitor.cpp +80 -0
  127. package/Microsoft.ReactNative/Views/Text/TextPropertyChangedParentVisitor.h +43 -0
  128. package/Microsoft.ReactNative/Views/Text/TextTransformParentVisitor.cpp +21 -0
  129. package/Microsoft.ReactNative/Views/Text/TextTransformParentVisitor.h +23 -0
  130. package/Microsoft.ReactNative/Views/Text/TextTransformVisitor.cpp +70 -0
  131. package/Microsoft.ReactNative/Views/Text/TextTransformVisitor.h +34 -0
  132. package/Microsoft.ReactNative/Views/Text/TextVisitor.cpp +56 -0
  133. package/Microsoft.ReactNative/Views/Text/TextVisitor.h +34 -0
  134. package/Microsoft.ReactNative/Views/Text/TextVisitorScope.h +35 -0
  135. package/Microsoft.ReactNative/Views/Text/TextVisitors.h +47 -0
  136. package/Microsoft.ReactNative/Views/TextViewManager.cpp +112 -103
  137. package/Microsoft.ReactNative/Views/TextViewManager.h +6 -12
  138. package/Microsoft.ReactNative/Views/TouchEventHandler.cpp +171 -129
  139. package/Microsoft.ReactNative/Views/TouchEventHandler.h +19 -15
  140. package/Microsoft.ReactNative/Views/ViewManagerBase.cpp +31 -0
  141. package/Microsoft.ReactNative/Views/ViewManagerBase.h +2 -0
  142. package/Microsoft.ReactNative/Views/ViewViewManager.cpp +0 -5
  143. package/Microsoft.ReactNative/Views/VirtualTextViewManager.cpp +21 -91
  144. package/Microsoft.ReactNative/Views/VirtualTextViewManager.h +5 -8
  145. package/Microsoft.ReactNative/XamlView.h +3 -3
  146. package/Microsoft.ReactNative/packages.config +1 -1
  147. package/Microsoft.ReactNative.Cxx/NativeModules.h +114 -0
  148. package/Microsoft.ReactNative.Cxx/VersionMacros.h +19 -0
  149. package/PropertySheets/External/Microsoft.ReactNative.Common.props +2 -0
  150. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppApp.props +1 -0
  151. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppLib.props +1 -0
  152. package/PropertySheets/Generated/PackageVersion.g.props +19 -0
  153. package/PropertySheets/PackageVersionDefinitions.props +28 -0
  154. package/PropertySheets/WinUI.props +1 -1
  155. package/Scripts/Microsoft.ReactNative.Managed.nuspec +1 -1
  156. package/Scripts/copyRNLibraries.js +12 -0
  157. package/Scripts/rnw-dependencies.ps1 +25 -24
  158. package/Shared/HermesSamplingProfiler.cpp +3 -21
  159. package/Shared/Modules/PlatformConstantsModule.cpp +1 -15
  160. package/Shared/Utils.cpp +58 -0
  161. package/Shared/Utils.h +3 -0
  162. package/codegen/NativeAccessibilityInfoSpec.g.h +9 -9
  163. package/codegen/NativeAccessibilityManagerSpec.g.h +49 -21
  164. package/codegen/NativeActionSheetManagerSpec.g.h +62 -6
  165. package/codegen/NativeAlertManagerSpec.g.h +4 -4
  166. package/codegen/NativeAnimatedModuleSpec.g.h +10 -10
  167. package/codegen/NativeAnimatedTurboModuleSpec.g.h +10 -10
  168. package/codegen/NativeAppStateSpec.g.h +25 -3
  169. package/codegen/NativeAppearanceSpec.g.h +3 -3
  170. package/codegen/NativeAsyncLocalStorageSpec.g.h +66 -18
  171. package/codegen/NativeAsyncSQLiteDBStorageSpec.g.h +66 -18
  172. package/codegen/NativeBlobModuleSpec.g.h +24 -6
  173. package/codegen/NativeBugReportingSpec.g.h +3 -3
  174. package/codegen/NativeDatePickerAndroidSpec.g.h +3 -3
  175. package/codegen/NativeDevLoadingViewSpec.g.h +3 -3
  176. package/codegen/NativeDeviceInfoSpec.g.h +18 -0
  177. package/codegen/NativeDialogManagerAndroidSpec.g.h +28 -4
  178. package/codegen/NativeDialogManagerWindowsSpec.g.h +77 -0
  179. package/codegen/NativeExceptionsManagerSpec.g.h +11 -11
  180. package/codegen/NativeFileReaderModuleSpec.g.h +6 -6
  181. package/codegen/NativeFrameRateLoggerSpec.g.h +11 -3
  182. package/codegen/NativeI18nManagerSpec.g.h +20 -0
  183. package/codegen/NativeImageEditorSpec.g.h +30 -6
  184. package/codegen/NativeImageLoaderAndroidSpec.g.h +6 -6
  185. package/codegen/NativeImageLoaderIOSSpec.g.h +6 -6
  186. package/codegen/NativeImagePickerIOSSpec.g.h +28 -12
  187. package/codegen/NativeImageStoreAndroidSpec.g.h +3 -3
  188. package/codegen/NativeImageStoreIOSSpec.g.h +21 -9
  189. package/codegen/NativeIntentAndroidSpec.g.h +3 -3
  190. package/codegen/NativeJSCHeapCaptureSpec.g.h +3 -3
  191. package/codegen/NativeJSCSamplingProfilerSpec.g.h +3 -3
  192. package/codegen/NativeJSDevSupportSpec.g.h +18 -0
  193. package/codegen/NativeNetworkingAndroidSpec.g.h +6 -6
  194. package/codegen/NativeNetworkingIOSSpec.g.h +26 -6
  195. package/codegen/NativePermissionsAndroidSpec.g.h +3 -3
  196. package/codegen/NativePlatformConstantsAndroidSpec.g.h +48 -0
  197. package/codegen/NativePlatformConstantsIOSSpec.g.h +38 -0
  198. package/codegen/NativePlatformConstantsWinSpec.g.h +32 -0
  199. package/codegen/NativePushNotificationManagerIOSSpec.g.h +35 -25
  200. package/codegen/NativeRedBoxSpec.g.h +3 -3
  201. package/codegen/NativeSampleTurboModuleSpec.g.h +32 -12
  202. package/codegen/NativeSegmentFetcherSpec.g.h +6 -6
  203. package/codegen/NativeSettingsManagerSpec.g.h +22 -6
  204. package/codegen/NativeShareModuleSpec.g.h +11 -3
  205. package/codegen/NativeSourceCodeSpec.g.h +16 -0
  206. package/codegen/NativeStatusBarManagerAndroidSpec.g.h +21 -3
  207. package/codegen/NativeStatusBarManagerIOSSpec.g.h +30 -6
  208. package/codegen/NativeToastAndroidSpec.g.h +24 -0
  209. package/codegen/NativeUIManagerSpec.g.h +63 -63
  210. package/codegen/NativeVibrationSpec.g.h +3 -3
  211. package/codegen/NativeWebSocketModuleSpec.g.h +9 -3
  212. package/index.js +15 -10
  213. package/index.windows.js +15 -10
  214. package/jest/mockModal.js +31 -0
  215. package/jest/setup.js +5 -3
  216. package/just-task.js +2 -1
  217. package/package.json +23 -20
  218. package/rntypes/BatchedBridge.d.ts +23 -0
  219. package/rntypes/Devtools.d.ts +20 -0
  220. package/rntypes/LaunchScreen.d.ts +9 -0
  221. package/rntypes/globals.d.ts +496 -0
  222. package/rntypes/index.d.ts +9966 -0
  223. package/rntypes/legacy-properties.d.ts +266 -0
  224. package/template/cpp-app/proj/MyApp.vcxproj +0 -5
  225. package/template/cpp-app/src/pch.h +1 -0
  226. package/template/cpp-lib/src/pch.h +3 -0
  227. package/template/cs-app/proj/MyApp.csproj +0 -6
  228. package/typings-index.d.ts +2 -1
  229. package/typings-index.js +7 -5
  230. package/typings-index.js.map +1 -1
  231. package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js +0 -87
  232. package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js +0 -30
  233. package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.windows.js +0 -30
  234. package/Libraries/Components/DatePickerAndroid/DatePickerAndroidTypes.js +0 -30
  235. package/Libraries/Components/StaticContainer.react.js +0 -51
  236. package/Libraries/Components/Touchable/ensurePositiveDelayProps.js +0 -25
  237. package/Libraries/Interaction/InteractionMixin.js +0 -54
  238. package/Libraries/ReactNative/queryLayoutByID.js +0 -58
  239. package/template/cpp-app/keys/MyApp_TemporaryKey.pfx +0 -0
  240. package/template/cs-app/keys/MyApp_TemporaryKey.pfx +0 -0
@@ -51,7 +51,7 @@ class Share {
51
51
  *
52
52
  * #### iOS
53
53
  *
54
- * - `url` - an URL to share
54
+ * - `url` - a URL to share
55
55
  *
56
56
  * At least one of URL and message is required.
57
57
  *
@@ -10,7 +10,7 @@
10
10
 
11
11
  /* eslint no-bitwise: 0 */
12
12
 
13
- import normalizeColorBase from '@react-native/normalize-color/base';
13
+ import _normalizeColor from '@react-native/normalize-color';
14
14
 
15
15
  import type {ColorValue} from './StyleSheet';
16
16
  import type {ProcessedColorValue} from './processColor';
@@ -27,7 +27,7 @@ function normalizeColor(
27
27
  }
28
28
 
29
29
  if (typeof color === 'string' || typeof color === 'number') {
30
- return normalizeColorBase(color);
30
+ return _normalizeColor(color);
31
31
  }
32
32
  }
33
33
 
@@ -170,6 +170,7 @@ const Text: React.AbstractComponent<
170
170
  {...restProps}
171
171
  {...eventHandlersForText}
172
172
  isHighlighted={isHighlighted}
173
+ isPressable={isPressable}
173
174
  numberOfLines={numberOfLines}
174
175
  selectionColor={selectionColor}
175
176
  style={style}
@@ -0,0 +1,72 @@
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
8
+ * @format
9
+ */
10
+
11
+ import ReactNativeViewAttributes from '../Components/View/ReactNativeViewAttributes';
12
+ import UIManager from '../ReactNative/UIManager';
13
+ import {type HostComponent} from '../Renderer/shims/ReactNativeTypes';
14
+ import createReactNativeComponentClass from '../Renderer/shims/createReactNativeComponentClass';
15
+ import {type ProcessedColorValue} from '../StyleSheet/processColor';
16
+ import {type TextProps} from './TextProps';
17
+
18
+ type NativeTextProps = $ReadOnly<{
19
+ ...TextProps,
20
+ isHighlighted?: ?boolean,
21
+ isPressable?: ?boolean, // [Windows]
22
+ selectionColor?: ?ProcessedColorValue,
23
+ }>;
24
+
25
+ export const NativeText: HostComponent<NativeTextProps> = (createReactNativeComponentClass(
26
+ 'RCTText',
27
+ () => ({
28
+ // $FlowFixMe[incompatible-call]
29
+ validAttributes: {
30
+ ...ReactNativeViewAttributes.UIView,
31
+ isHighlighted: true,
32
+ isPressable: true, // [Windows]
33
+ numberOfLines: true,
34
+ ellipsizeMode: true,
35
+ allowFontScaling: true,
36
+ maxFontSizeMultiplier: true,
37
+ disabled: true,
38
+ selectable: true,
39
+ selectionColor: true,
40
+ adjustsFontSizeToFit: true,
41
+ minimumFontScale: true,
42
+ textBreakStrategy: true,
43
+ onTextLayout: true,
44
+ onInlineViewLayout: true,
45
+ dataDetectorType: true,
46
+ android_hyphenationFrequency: true,
47
+ },
48
+ directEventTypes: {
49
+ topTextLayout: {
50
+ registrationName: 'onTextLayout',
51
+ },
52
+ topInlineViewLayout: {
53
+ registrationName: 'onInlineViewLayout',
54
+ },
55
+ },
56
+ uiViewClassName: 'RCTText',
57
+ }),
58
+ ): any);
59
+
60
+ export const NativeVirtualText: HostComponent<NativeTextProps> =
61
+ !global.RN$Bridgeless && !UIManager.hasViewManagerConfig('RCTVirtualText')
62
+ ? NativeText
63
+ : (createReactNativeComponentClass('RCTVirtualText', () => ({
64
+ // $FlowFixMe[incompatible-call]
65
+ validAttributes: {
66
+ ...ReactNativeViewAttributes.UIView,
67
+ isHighlighted: true,
68
+ isPressable: true, // [Windows]
69
+ maxFontSizeMultiplier: true,
70
+ },
71
+ uiViewClassName: 'RCTVirtualText',
72
+ })): any);
@@ -66,13 +66,7 @@ export type TextProps = $ReadOnly<{|
66
66
  * Set hyphenation strategy on Android.
67
67
  *
68
68
  */
69
- android_hyphenationFrequency?: ?(
70
- | 'normal'
71
- | 'none'
72
- | 'full'
73
- | 'high'
74
- | 'balanced'
75
- ),
69
+ android_hyphenationFrequency?: ?('normal' | 'none' | 'full'),
76
70
  children?: ?Node,
77
71
 
78
72
  /**
@@ -16,7 +16,7 @@ const turboModuleProxy = global.__turboModuleProxy;
16
16
 
17
17
  function requireModule<T: TurboModule>(name: string): ?T {
18
18
  // Bridgeless mode requires TurboModules
19
- if (!global.RN$Bridgeless) {
19
+ if (global.RN$Bridgeless !== true) {
20
20
  // Backward compatibility layer during migration.
21
21
  const legacyModule = NativeModules[name];
22
22
  if (legacyModule != null) {
@@ -119,7 +119,7 @@ const HMRClient: HMRClientNativeInterface = {
119
119
  JSON.stringify({
120
120
  type: 'log',
121
121
  level,
122
- mode: global.RN$Bridgeless ? 'NOBRIDGE' : 'BRIDGE',
122
+ mode: global.RN$Bridgeless === true ? 'NOBRIDGE' : 'BRIDGE',
123
123
  data: data.map(item =>
124
124
  typeof item === 'string'
125
125
  ? item
@@ -40,7 +40,8 @@ ABIViewManager::ABIViewManager(
40
40
  m_viewManagerWithCommands{viewManager.try_as<IViewManagerWithCommands>()},
41
41
  m_viewManagerWithExportedEventTypeConstants{viewManager.try_as<IViewManagerWithExportedEventTypeConstants>()},
42
42
  m_viewManagerRequiresNativeLayout{viewManager.try_as<IViewManagerRequiresNativeLayout>()},
43
- m_viewManagerWithChildren{viewManager.try_as<IViewManagerWithChildren>()} {
43
+ m_viewManagerWithChildren{viewManager.try_as<IViewManagerWithChildren>()},
44
+ m_viewManagerWithPointerEvents{viewManager.try_as<IViewManagerWithPointerEvents>()} {
44
45
  if (m_viewManagerWithReactContext) {
45
46
  m_viewManagerWithReactContext.ReactContext(winrt::make<implementation::ReactContext>(Mso::Copy(reactContext)));
46
47
  }
@@ -215,6 +216,14 @@ YGMeasureFunc ABIViewManager::GetYogaCustomMeasureFunc() const {
215
216
  }
216
217
  }
217
218
 
219
+ void ABIViewManager::OnPointerEvent(::Microsoft::ReactNative::ShadowNodeBase *node, const ReactPointerEventArgs &args) {
220
+ if (m_viewManagerWithPointerEvents) {
221
+ m_viewManagerWithPointerEvents.OnPointerEvent(node->GetView(), args);
222
+ }
223
+ // Call the base method to handle `pointerEvents` behavior
224
+ Super::OnPointerEvent(node, args);
225
+ }
226
+
218
227
  ::Microsoft::ReactNative::ShadowNode *ABIViewManager::createShadow() const {
219
228
  return new ABIShadowNode(
220
229
  m_viewManagerRequiresNativeLayout && m_viewManagerRequiresNativeLayout.RequiresNativeLayout());
@@ -65,6 +65,8 @@ class ABIViewManager : public ::Microsoft::ReactNative::FrameworkElementViewMana
65
65
  return m_viewManagerRequiresNativeLayout != nullptr && m_viewManagerRequiresNativeLayout.RequiresNativeLayout();
66
66
  }
67
67
 
68
+ void OnPointerEvent(::Microsoft::ReactNative::ShadowNodeBase *node, const ReactPointerEventArgs &args) override;
69
+
68
70
  protected:
69
71
  xaml::DependencyObject CreateViewCore(int64_t, const winrt::Microsoft::ReactNative::JSValueObject &props) override;
70
72
 
@@ -77,6 +79,7 @@ class ABIViewManager : public ::Microsoft::ReactNative::FrameworkElementViewMana
77
79
  IViewManagerWithExportedEventTypeConstants m_viewManagerWithExportedEventTypeConstants;
78
80
  IViewManagerWithChildren m_viewManagerWithChildren;
79
81
  IViewManagerRequiresNativeLayout m_viewManagerRequiresNativeLayout;
82
+ IViewManagerWithPointerEvents m_viewManagerWithPointerEvents;
80
83
 
81
84
  winrt::Windows::Foundation::Collections::IMapView<winrt::hstring, ViewManagerPropertyType> m_nativeProps;
82
85
  };
@@ -11,7 +11,6 @@
11
11
  #include <Modules/AppearanceModule.h>
12
12
  #include <Modules/AsyncStorageModuleWin32.h>
13
13
  #include <Modules/ClipboardModule.h>
14
- #include <Modules/ImageViewManagerModule.h>
15
14
  #include <Modules/LinkingManagerModule.h>
16
15
  #include <Modules/NativeUIManager.h>
17
16
  #include <Modules/NetworkingModule.h>
@@ -63,11 +62,6 @@ std::vector<facebook::react::NativeModuleDescription> GetCoreModules(
63
62
  modules.emplace_back(
64
63
  LinkingManagerModule::name, []() { return std::make_unique<LinkingManagerModule>(); }, batchingUIMessageQueue);
65
64
 
66
- modules.emplace_back(
67
- ImageViewManagerModule::name,
68
- []() { return std::make_unique<ImageViewManagerModule>(); },
69
- batchingUIMessageQueue);
70
-
71
65
  modules.emplace_back(
72
66
  AppThemeModule::Name,
73
67
  [appTheme = std::move(appTheme)]() mutable { return std::make_unique<AppThemeModule>(std::move(appTheme)); },
@@ -5,6 +5,8 @@
5
5
  #include "IReactDispatcher.h"
6
6
  #include "ReactDispatcherHelper.g.cpp"
7
7
 
8
+ #include <glog/logging.h>
9
+
8
10
  using namespace winrt;
9
11
  using namespace Windows::Foundation;
10
12
 
@@ -37,8 +39,21 @@ bool ReactDispatcher::HasThreadAccess() noexcept {
37
39
  return m_queue.HasThreadAccess();
38
40
  }
39
41
 
42
+ ReactDispatcherCallback CreateLoggingCallback(ReactDispatcherCallback const &callback) {
43
+ return [callback]() {
44
+ try {
45
+ callback();
46
+ } catch (winrt::hresult_error const &error) {
47
+ std::stringstream errorCode;
48
+ errorCode << "0x" << std::hex << error.code();
49
+ LOG(ERROR) << "HRESULT " << errorCode.str() << ": " << winrt::to_string(error.message());
50
+ throw;
51
+ }
52
+ };
53
+ }
54
+
40
55
  void ReactDispatcher::Post(ReactDispatcherCallback const &callback) noexcept {
41
- return m_queue.Post([callback]() noexcept { callback(); });
56
+ return m_queue.Post([callback = CreateLoggingCallback(callback)]() noexcept { callback(); });
42
57
  }
43
58
 
44
59
  void ReactDispatcher::Post(Mso::DispatchTask &&task) const noexcept {
@@ -2,6 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
 
4
4
  import "IViewManagerCore.idl";
5
+ import "ReactPointerEventArgs.idl";
5
6
 
6
7
  #include "NamespaceRedirect.h"
7
8
  #include "DocString.h"
@@ -63,4 +64,28 @@ namespace Microsoft.ReactNative
63
64
  interface IViewManagerCreateWithProperties {
64
65
  Object CreateViewWithProperties(IJSValueReader propertyMapReader);
65
66
  };
67
+
68
+ [experimental]
69
+ [webhosthidden]
70
+ DOC_STRING(
71
+ "Experimental interface enabling view managers to release pointer capture "
72
+ "from the React root view and start handling pointer events itself."
73
+ )
74
+ interface IViewManagerWithPointerEvents {
75
+ DOC_STRING(
76
+ "When pointer events are received on the React root view, the top-level "
77
+ "pointer event handler invokes this callback for each React view "
78
+ "ancestor of the @Windows.UI.Xaml.RoutedEventArgs.OriginalSource "
79
+ "element with a view manager that implements "
80
+ "@IViewManagerWithPointerEvents to allow the view manager to modify "
81
+ "handling for the pointer event. This can be used to refine the target "
82
+ "view. E.g., setting the @ReactPointerEventArgs.Target property to null "
83
+ "will force the React root view to choose one of the view's ancestors "
84
+ "as the hit target. Alternatively, the view manager may also set the "
85
+ "@ReactPointerEventArgs.Target to any descendent of provided view to "
86
+ "enable hit testing on views that do not derive from "
87
+ "@Windows.UI.Xaml.UIElement."
88
+ )
89
+ void OnPointerEvent(Object view, ReactPointerEventArgs args);
90
+ };
66
91
  } // namespace Microsoft.ReactNative
@@ -26,6 +26,8 @@
26
26
  <Import Project="$(SolutionDir)\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props" Condition="Exists('$(SolutionDir)\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props')" />
27
27
  <Import Project="$(SolutionDir)\packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props" Condition="Exists('$(SolutionDir)\packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props')" />
28
28
  <Import Project="$(ReactNativeWindowsDir)PropertySheets\React.Cpp.props" />
29
+ <Import Project="$(ReactNativeWindowsDir)PropertySheets\Generated\PackageVersion.g.props" />
30
+ <Import Project="$(ReactNativeWindowsDir)PropertySheets\PackageVersionDefinitions.props" />
29
31
  <ItemGroup Label="ProjectConfigurations">
30
32
  <ProjectConfiguration Include="Debug|ARM64">
31
33
  <Configuration>Debug</Configuration>
@@ -89,7 +91,7 @@
89
91
  <ItemDefinitionGroup>
90
92
  <ClCompile>
91
93
  <PrecompiledHeader>Use</PrecompiledHeader>
92
- <RuntimeTypeInfo Condition="'$(UseFabric)' == 'true'">true</RuntimeTypeInfo>
94
+ <RuntimeTypeInfo Condition="'$(UseFabric)' == 'true' AND '$(Configuration)'=='Debug'">true</RuntimeTypeInfo>
93
95
  <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
94
96
  <PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
95
97
  <ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
@@ -344,6 +346,16 @@
344
346
  <ClInclude Include="Views\SwitchViewManager.h" />
345
347
  <ClInclude Include="Views\TextInputViewManager.h" />
346
348
  <ClInclude Include="Views\TextViewManager.h" />
349
+ <ClInclude Include="Views\Text\TextHighlighterVisitor.h" />
350
+ <ClInclude Include="Views\Text\TextHitTestUtils.h" />
351
+ <ClInclude Include="Views\Text\TextHitTestVisitor.h" />
352
+ <ClInclude Include="Views\Text\TextParentVisitor.h" />
353
+ <ClInclude Include="Views\Text\TextPropertyChangedParentVisitor.h" />
354
+ <ClInclude Include="Views\Text\TextTransformParentVisitor.h" />
355
+ <ClInclude Include="Views\Text\TextTransformVisitor.h" />
356
+ <ClInclude Include="Views\Text\TextVisitorScope.h" />
357
+ <ClInclude Include="Views\Text\TextVisitor.h" />
358
+ <ClInclude Include="Views\Text\TextVisitors.h" />
347
359
  <ClInclude Include="Views\TouchEventHandler.h" />
348
360
  <ClInclude Include="Views\ViewControl.h" />
349
361
  <ClInclude Include="Views\ViewManager.h" />
@@ -381,6 +393,10 @@
381
393
  <SubType>Code</SubType>
382
394
  </ClInclude>
383
395
  <ClInclude Include="XamlView.h" />
396
+ <ClInclude Include="ReactPointerEventArgs.h">
397
+ <DependentUpon>ReactPointerEventArgs.idl</DependentUpon>
398
+ <SubType>Code</SubType>
399
+ </ClInclude>
384
400
  </ItemGroup>
385
401
  <ItemGroup Condition="'$(UseFabric)' == 'true'">
386
402
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\react\config\ReactNativeConfig.cpp" />
@@ -567,6 +583,10 @@
567
583
  <ClCompile Include="Modules\TimingModule.cpp" />
568
584
  <ClCompile Include="Modules\PaperUIManagerModule.cpp" />
569
585
  <ClCompile Include="NativeModulesProvider.cpp" />
586
+ <ClCompile Include="ReactPointerEventArgs.cpp">
587
+ <DependentUpon>ReactPointerEventArgs.idl</DependentUpon>
588
+ <SubType>Code</SubType>
589
+ </ClCompile>
570
590
  <ClCompile Include="RedBoxErrorInfo.cpp" />
571
591
  <ClCompile Include="RedBoxErrorFrameInfo.cpp" />
572
592
  <ClCompile Include="TurboModulesProvider.cpp" />
@@ -646,6 +666,14 @@
646
666
  <ClCompile Include="Views\SwitchViewManager.cpp" />
647
667
  <ClCompile Include="Views\TextInputViewManager.cpp" />
648
668
  <ClCompile Include="Views\TextViewManager.cpp" />
669
+ <ClCompile Include="Views\Text\TextHighlighterVisitor.cpp" />
670
+ <ClCompile Include="Views\Text\TextHitTestUtils.cpp" />
671
+ <ClCompile Include="Views\Text\TextHitTestVisitor.cpp" />
672
+ <ClCompile Include="Views\Text\TextParentVisitor.cpp" />
673
+ <ClCompile Include="Views\Text\TextPropertyChangedParentVisitor.cpp" />
674
+ <ClCompile Include="Views\Text\TextTransformParentVisitor.cpp" />
675
+ <ClCompile Include="Views\Text\TextTransformVisitor.cpp" />
676
+ <ClCompile Include="Views\Text\TextVisitor.cpp" />
649
677
  <ClCompile Include="Views\TouchEventHandler.cpp" />
650
678
  <ClCompile Include="Views\ViewControl.cpp" />
651
679
  <ClCompile Include="Views\ViewManagerBase.cpp" />
@@ -732,6 +760,7 @@
732
760
  <SubType>Designer</SubType>
733
761
  </Midl>
734
762
  <Midl Include="XamlHelper.idl" />
763
+ <Midl Include="ReactPointerEventArgs.idl" />
735
764
  </ItemGroup>
736
765
  <ItemGroup>
737
766
  <None Include="packages.config" />
@@ -745,11 +774,11 @@
745
774
  </ItemGroup>
746
775
  <ItemGroup>
747
776
  <ResourceCompile Include="Version.rc">
748
- <PreprocessorDefinitions Condition="'$(RNW_PKG_VERSION_STR)'!=''">
749
- RNW_PKG_VERSION_STR=$(RNW_PKG_VERSION_STR);
750
- RNW_PKG_VERSION_MAJOR=$(RNW_PKG_VERSION_MAJOR);
751
- RNW_PKG_VERSION_MINOR=$(RNW_PKG_VERSION_MINOR);
752
- RNW_PKG_VERSION_PATCH=$(RNW_PKG_VERSION_PATCH);
777
+ <PreprocessorDefinitions>
778
+ RNW_VERSION=$(ReactNativeWindowsVersion);
779
+ RNW_MAJOR=$(ReactNativeWindowsMajor);
780
+ RNW_MINOR=$(ReactNativeWindowsMinor);
781
+ RNW_PATCH=$(ReactNativeWindowsPatch);
753
782
  _UNICODE;
754
783
  UNICODE;
755
784
  %(PreprocessorDefinitions)
@@ -309,6 +309,31 @@
309
309
  <ClCompile Include="ReactHost\JSCallInvokerScheduler.cpp">
310
310
  <Filter>ReactHost</Filter>
311
311
  </ClCompile>
312
+ <ClCompile Include="Views\Text\TextHighlighterVisitor.cpp">
313
+ <Filter>Views\Text</Filter>
314
+ </ClCompile>
315
+ <ClCompile Include="Views\Text\TextHitTestUtils.cpp">
316
+ <Filter>Views\Text</Filter>
317
+ </ClCompile>
318
+ <ClCompile Include="Views\Text\TextHitTestVisitor.cpp">
319
+ <Filter>Views\Text</Filter>
320
+ </ClCompile>
321
+ <ClCompile Include="Views\Text\TextParentVisitor.cpp">
322
+ <Filter>Views\Text</Filter>
323
+ </ClCompile>
324
+ <ClCompile Include="Views\Text\TextPropertyChangedParentVisitor.cpp">
325
+ <Filter>Views\Text</Filter>
326
+ </ClCompile>
327
+ <ClCompile Include="Views\Text\TextTransformParentVisitor.cpp">
328
+ <Filter>Views\Text</Filter>
329
+ </ClCompile>
330
+ <ClCompile Include="Views\Text\TextTransformVisitor.cpp">
331
+ <Filter>Views\Text</Filter>
332
+ </ClCompile>
333
+ <ClCompile Include="Views\Text\TextVisitor.cpp">
334
+ <Filter>Views\Text</Filter>
335
+ </ClCompile>
336
+ <ClCompile Include="ReactPointerEventArgs.cpp" />
312
337
  </ItemGroup>
313
338
  <ItemGroup>
314
339
  <ClInclude Include="ABICxxModule.h" />
@@ -672,6 +697,37 @@
672
697
  <ClInclude Include="Utils\ShadowNodeTypeUtils.h">
673
698
  <Filter>Utils</Filter>
674
699
  </ClInclude>
700
+ <ClInclude Include="Views\Text\TextHighlighterVisitor.h">
701
+ <Filter>Views\Text</Filter>
702
+ </ClInclude>
703
+ <ClInclude Include="Views\Text\TextHitTestVisitor.h">
704
+ <Filter>Views\Text</Filter>
705
+ </ClInclude>
706
+ <ClInclude Include="Views\Text\TextHitTestUtils.h">
707
+ <Filter>Views\Text</Filter>
708
+ </ClInclude>
709
+ <ClInclude Include="Views\Text\TextParentVisitor.h">
710
+ <Filter>Views\Text</Filter>
711
+ </ClInclude>
712
+ <ClInclude Include="Views\Text\TextPropertyChangedParentVisitor.h">
713
+ <Filter>Views\Text</Filter>
714
+ </ClInclude>
715
+ <ClInclude Include="Views\Text\TextTransformParentVisitor.h">
716
+ <Filter>Views\Text</Filter>
717
+ </ClInclude>
718
+ <ClInclude Include="Views\Text\TextTransformVisitor.h">
719
+ <Filter>Views\Text</Filter>
720
+ </ClInclude>
721
+ <ClInclude Include="Views\Text\TextVisitorScope.h">
722
+ <Filter>Views\Text</Filter>
723
+ </ClInclude>
724
+ <ClInclude Include="Views\Text\TextVisitor.h">
725
+ <Filter>Views\Text</Filter>
726
+ </ClInclude>
727
+ <ClInclude Include="Views\Text\TextVisitors.h">
728
+ <Filter>Views\Text</Filter>
729
+ </ClInclude>
730
+ <ClInclude Include="ReactPointerEventArgs.h" />
675
731
  </ItemGroup>
676
732
  <ItemGroup>
677
733
  <Midl Include="IJSValueReader.idl" />
@@ -709,6 +765,7 @@
709
765
  <Midl Include="JsiApi.idl" />
710
766
  <Midl Include="DocString.idl" />
711
767
  <Midl Include="DesktopWindowMessage.idl" />
768
+ <Midl Include="ReactPointerEventArgs.idl" />
712
769
  </ItemGroup>
713
770
  <ItemGroup>
714
771
  <None Include="microsoft.reactnative.def" />
@@ -755,6 +812,9 @@
755
812
  <Filter Include="JSI">
756
813
  <UniqueIdentifier>{24290499-e864-407e-89c0-473f2b8dbb6e}</UniqueIdentifier>
757
814
  </Filter>
815
+ <Filter Include="Views\Text">
816
+ <UniqueIdentifier>{8b871c42-6131-44c2-a73f-f1061780e97f}</UniqueIdentifier>
817
+ </Filter>
758
818
  </ItemGroup>
759
819
  <ItemGroup>
760
820
  <ResourceCompile Include="Version.rc" />
@@ -19,7 +19,7 @@ void AccessibilityInfo::Initialize(winrt::Microsoft::ReactNative::ReactContext c
19
19
  m_context = reactContext;
20
20
  }
21
21
 
22
- void AccessibilityInfo::isReduceMotionEnabled(std::function<void(React::JSValue const &)> const &onSuccess) noexcept {
22
+ void AccessibilityInfo::isReduceMotionEnabled(std::function<void(bool)> const &onSuccess) noexcept {
23
23
  auto jsDispatcher = m_context.JSDispatcher();
24
24
  m_context.UIDispatcher().Post([weakThis = weak_from_this(), jsDispatcher, onSuccess] {
25
25
  if (auto strongThis = weakThis.lock()) {
@@ -30,8 +30,7 @@ void AccessibilityInfo::isReduceMotionEnabled(std::function<void(React::JSValue
30
30
  });
31
31
  }
32
32
 
33
- void AccessibilityInfo::isTouchExplorationEnabled(
34
- std::function<void(React::JSValue const &)> const &onSuccess) noexcept {
33
+ void AccessibilityInfo::isTouchExplorationEnabled(std::function<void(bool)> const &onSuccess) noexcept {
35
34
  onSuccess(UiaClientsAreListening());
36
35
  }
37
36
 
@@ -73,7 +72,7 @@ void AccessibilityInfo::announceForAccessibility(std::string announcement) noexc
73
72
 
74
73
  void AccessibilityInfo::getRecommendedTimeoutMillis(
75
74
  double mSec,
76
- std::function<void(React::JSValue const &)> const &onSuccess) noexcept {
75
+ std::function<void(double)> const &onSuccess) noexcept {
77
76
  onSuccess(mSec);
78
77
  }
79
78
 
@@ -12,10 +12,10 @@ struct AccessibilityInfo : public std::enable_shared_from_this<AccessibilityInfo
12
12
  void Initialize(winrt::Microsoft::ReactNative::ReactContext const &reactContext) noexcept;
13
13
 
14
14
  REACT_METHOD(isReduceMotionEnabled)
15
- void isReduceMotionEnabled(std::function<void(React::JSValue const &)> const &onSuccess) noexcept;
15
+ void isReduceMotionEnabled(std::function<void(bool)> const &onSuccess) noexcept;
16
16
 
17
17
  REACT_METHOD(isTouchExplorationEnabled)
18
- void isTouchExplorationEnabled(std::function<void(React::JSValue const &)> const &onSuccess) noexcept;
18
+ void isTouchExplorationEnabled(std::function<void(bool)> const &onSuccess) noexcept;
19
19
 
20
20
  REACT_METHOD(setAccessibilityFocus)
21
21
  void setAccessibilityFocus(double reactTag) noexcept;
@@ -24,7 +24,7 @@ struct AccessibilityInfo : public std::enable_shared_from_this<AccessibilityInfo
24
24
  void announceForAccessibility(std::string announcement) noexcept;
25
25
 
26
26
  REACT_METHOD(getRecommendedTimeoutMillis)
27
- void getRecommendedTimeoutMillis(double mSec, std::function<void(React::JSValue const &)> const &onSuccess) noexcept;
27
+ void getRecommendedTimeoutMillis(double mSec, std::function<void(double)> const &onSuccess) noexcept;
28
28
 
29
29
  private:
30
30
  React::ReactContext m_context;
@@ -15,10 +15,13 @@
15
15
 
16
16
  namespace Microsoft::ReactNative {
17
17
 
18
- void Alert::showAlert(ShowAlertArgs const &args, std::function<void(std::string)> result) noexcept {
19
- m_context.UIDispatcher().Post([weakThis = weak_from_this(), args, result] {
18
+ void Alert::showAlert(
19
+ DialogOptions &&args,
20
+ std::function<void(std::string)> /*error*/,
21
+ std::function<void(std::string, int)> result) noexcept {
22
+ m_context.UIDispatcher().Post([weakThis = weak_from_this(), args = std::move(args), result]() mutable {
20
23
  if (auto strongThis = weakThis.lock()) {
21
- strongThis->pendingAlerts.push({args, result});
24
+ strongThis->pendingAlerts.emplace(std::move(args), result);
22
25
  if (strongThis->pendingAlerts.size() == 1) {
23
26
  strongThis->ProcessPendingAlertRequests();
24
27
  }
@@ -29,22 +32,37 @@ void Alert::showAlert(ShowAlertArgs const &args, std::function<void(std::string)
29
32
  void Alert::ProcessPendingAlertRequests() noexcept {
30
33
  if (pendingAlerts.empty())
31
34
  return;
32
- const auto &[args, result] = pendingAlerts.front();
35
+ const auto &pendingAlert = pendingAlerts.front();
36
+ const auto &args = pendingAlert.args;
37
+ const auto &result = pendingAlert.result;
33
38
  auto jsDispatcher = m_context.JSDispatcher();
34
39
 
35
40
  xaml::Controls::ContentDialog dialog{};
36
- dialog.Title(winrt::box_value(Microsoft::Common::Unicode::Utf8ToUtf16(args.title)));
37
- dialog.Content(winrt::box_value(Microsoft::Common::Unicode::Utf8ToUtf16(args.message)));
38
- dialog.PrimaryButtonText(Microsoft::Common::Unicode::Utf8ToUtf16(args.buttonPositive));
39
- dialog.SecondaryButtonText(Microsoft::Common::Unicode::Utf8ToUtf16(args.buttonNegative));
40
- dialog.CloseButtonText(Microsoft::Common::Unicode::Utf8ToUtf16(args.buttonNeutral));
41
- if (args.defaultButton >= 0 && args.defaultButton <= 3) {
42
- dialog.DefaultButton(static_cast<xaml::Controls::ContentDialogButton>(args.defaultButton));
41
+ xaml::Controls::TextBlock titleTextBlock;
42
+ xaml::Controls::TextBlock messageTextBlock;
43
+ titleTextBlock.Text(Microsoft::Common::Unicode::Utf8ToUtf16(args.title.value_or(std::string{})));
44
+ titleTextBlock.IsTextSelectionEnabled(true);
45
+ titleTextBlock.MaxLines(2);
46
+ titleTextBlock.TextWrapping(xaml::TextWrapping::Wrap);
47
+ messageTextBlock.Text(Microsoft::Common::Unicode::Utf8ToUtf16(args.message.value_or(std::string{})));
48
+ messageTextBlock.IsTextSelectionEnabled(true);
49
+ messageTextBlock.TextWrapping(xaml::TextWrapping::Wrap);
50
+ dialog.Title(titleTextBlock);
51
+ dialog.Content(messageTextBlock);
52
+ dialog.PrimaryButtonText(Microsoft::Common::Unicode::Utf8ToUtf16(args.buttonPositive.value_or(std::string{})));
53
+ dialog.SecondaryButtonText(Microsoft::Common::Unicode::Utf8ToUtf16(args.buttonNegative.value_or(std::string{})));
54
+ dialog.CloseButtonText(Microsoft::Common::Unicode::Utf8ToUtf16(args.buttonNeutral.value_or(std::string{})));
55
+ int defaultButton = args.defaultButton.value_or(0);
56
+ if (defaultButton >= 0 && defaultButton <= 3) {
57
+ dialog.DefaultButton(static_cast<xaml::Controls::ContentDialogButton>(defaultButton));
43
58
  }
44
59
 
60
+ auto useXamlRootForThemeBugWorkaround = false;
61
+
45
62
  if (Is19H1OrHigher()) {
46
63
  // XamlRoot added in 19H1
47
64
  if (const auto xamlRoot = React::XamlUIService::GetXamlRoot(m_context.Properties().Handle())) {
65
+ useXamlRootForThemeBugWorkaround = true;
48
66
  dialog.XamlRoot(xamlRoot);
49
67
  auto rootChangedToken = xamlRoot.Changed([=](auto &&, auto &&) {
50
68
  const auto rootSize = xamlRoot.Size();
@@ -70,19 +88,35 @@ void Alert::ProcessPendingAlertRequests() noexcept {
70
88
  }
71
89
  }
72
90
 
91
+ // Workaround XAML bug with ContentDialog and dark theme:
92
+ // https://github.com/microsoft/microsoft-ui-xaml/issues/2331
93
+ dialog.Opened([useXamlRootForThemeBugWorkaround](winrt::IInspectable const &sender, auto &&) {
94
+ auto contentDialog = sender.as<xaml::Controls::ContentDialog>();
95
+ auto popups = xaml::Media::VisualTreeHelper::GetOpenPopupsForXamlRoot(contentDialog.XamlRoot());
96
+
97
+ auto contentAsFrameworkElement = useXamlRootForThemeBugWorkaround
98
+ ? contentDialog.XamlRoot().Content().try_as<xaml::FrameworkElement>()
99
+ : xaml::Window::Current().Content().try_as<xaml::FrameworkElement>();
100
+ if (contentAsFrameworkElement) {
101
+ for (uint32_t i = 0; i < popups.Size(); i++) {
102
+ popups.GetAt(i).RequestedTheme(contentAsFrameworkElement.ActualTheme());
103
+ }
104
+ }
105
+ });
106
+
73
107
  auto asyncOp = dialog.ShowAsync();
74
108
  asyncOp.Completed(
75
109
  [jsDispatcher, result, this](
76
110
  const winrt::IAsyncOperation<xaml::Controls::ContentDialogResult> &asyncOp, winrt::AsyncStatus status) {
77
111
  switch (asyncOp.GetResults()) {
78
112
  case xaml::Controls::ContentDialogResult::Primary:
79
- jsDispatcher.Post([result] { result("positive"); });
113
+ jsDispatcher.Post([result, this] { result(m_constants.buttonClicked, m_constants.buttonPositive); });
80
114
  break;
81
115
  case xaml::Controls::ContentDialogResult::Secondary:
82
- jsDispatcher.Post([result] { result("negative"); });
116
+ jsDispatcher.Post([result, this] { result(m_constants.buttonClicked, m_constants.buttonNegative); });
83
117
  break;
84
118
  case xaml::Controls::ContentDialogResult::None:
85
- jsDispatcher.Post([result] { result("neutral"); });
119
+ jsDispatcher.Post([result, this] { result(m_constants.buttonClicked, m_constants.buttonNeutral); });
86
120
  break;
87
121
  default:
88
122
  break;
@@ -92,8 +126,17 @@ void Alert::ProcessPendingAlertRequests() noexcept {
92
126
  });
93
127
  }
94
128
 
129
+ Alert::Constants Alert::GetConstants() noexcept {
130
+ return m_constants;
131
+ }
132
+
95
133
  void Alert::Initialize(React::ReactContext const &reactContext) noexcept {
96
134
  m_context = reactContext;
135
+ m_constants.buttonClicked = "buttonClicked";
136
+ m_constants.dismissed = "dismissed";
137
+ m_constants.buttonPositive = -1;
138
+ m_constants.buttonNegative = -2;
139
+ m_constants.buttonNeutral = -3;
97
140
  }
98
141
 
99
142
  } // namespace Microsoft::ReactNative