react-native-windows 0.74.23 → 0.74.24

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 (44) hide show
  1. package/Microsoft.ReactNative/CompositionComponentView.idl +2 -1
  2. package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +4 -1
  3. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +1 -1
  4. package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +7 -0
  5. package/Microsoft.ReactNative/Fabric/AbiViewProps.h +2 -0
  6. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +11 -4
  7. package/Microsoft.ReactNative/Fabric/ComponentView.h +3 -2
  8. package/Microsoft.ReactNative/Fabric/Composition/BorderPrimitive.cpp +926 -0
  9. package/Microsoft.ReactNative/Fabric/Composition/BorderPrimitive.h +76 -0
  10. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +31 -13
  11. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +27 -3
  12. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +3 -1
  13. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +193 -892
  14. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +17 -22
  15. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +1 -1
  16. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +129 -122
  17. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +14 -8
  18. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +34 -20
  19. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +5 -3
  20. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +40 -2
  21. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +9 -0
  22. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +31 -3
  23. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +8 -8
  24. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +31 -1
  25. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +4 -0
  26. package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +9 -3
  27. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +11 -0
  28. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +2 -0
  29. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +1 -0
  30. package/Microsoft.ReactNative/IReactViewComponentBuilder.idl +1 -1
  31. package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +25 -129
  32. package/Microsoft.ReactNative/ReactNativeAppBuilder.h +5 -13
  33. package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +13 -34
  34. package/Microsoft.ReactNative/ReactNativeIsland.idl +3 -2
  35. package/Microsoft.ReactNative/ReactNativeWin32App.cpp +129 -18
  36. package/Microsoft.ReactNative/ReactNativeWin32App.h +14 -5
  37. package/Microsoft.ReactNative/ViewProps.idl +2 -0
  38. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  39. package/Shared/Shared.vcxitems +3 -10
  40. package/Shared/Shared.vcxitems.filters +1 -0
  41. package/package.json +3 -3
  42. package/templates/cpp-app/windows/MyApp/MyApp.cpp +46 -130
  43. package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.cpp +0 -59
  44. package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.h +0 -23
@@ -0,0 +1,76 @@
1
+
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+
5
+ #pragma once
6
+
7
+ #include <Fabric/ComponentView.h>
8
+ #include <Microsoft.ReactNative.Cxx/ReactContext.h>
9
+ #include <react/renderer/components/view/ViewEventEmitter.h>
10
+ #include <react/renderer/components/view/ViewProps.h>
11
+ #include "CompositionHelpers.h"
12
+
13
+ namespace winrt::Microsoft::ReactNative::Composition::implementation {
14
+
15
+ struct ComponentView;
16
+
17
+ // Controls adding/removing appropriate visuals to a parent to render a specific border without requiring
18
+ struct BorderPrimitive {
19
+ static constexpr size_t SpecialBorderLayerCount = 8;
20
+
21
+ // Use when attaching to an existing visual - We do this for View's border properties, to optimize the number of
22
+ // visuals for each view.
23
+ BorderPrimitive(
24
+ winrt::Microsoft::ReactNative::Composition::implementation::ComponentView &outer,
25
+ const winrt::Microsoft::ReactNative::Composition::Experimental::IVisual &rootVisual);
26
+
27
+ // This ctor creates a new root visual that can then be added to the visual tree
28
+ BorderPrimitive(winrt::Microsoft::ReactNative::Composition::implementation::ComponentView &outer);
29
+
30
+ void markNeedsUpdate() noexcept;
31
+
32
+ void updateProps(
33
+ const facebook::react::ViewProps &oldViewProps,
34
+ const facebook::react::ViewProps &newViewProps) noexcept;
35
+ void finalize(
36
+ facebook::react::LayoutMetrics const &layoutMetrics,
37
+ const facebook::react::BorderMetrics &borderMetrics) noexcept;
38
+ void onThemeChanged(
39
+ facebook::react::LayoutMetrics const &layoutMetrics,
40
+ const facebook::react::BorderMetrics &borderMetrics) noexcept;
41
+
42
+ uint8_t numberOfVisuals() const noexcept;
43
+ winrt::Microsoft::ReactNative::Composition::Experimental::IVisual RootVisual() const noexcept;
44
+
45
+ static facebook::react::BorderMetrics resolveAndAlignBorderMetrics(
46
+ facebook::react::LayoutMetrics const &layoutMetrics,
47
+ const facebook::react::ViewProps &viewProps) noexcept;
48
+
49
+ static bool requiresBorder(
50
+ const facebook::react::BorderMetrics &borderMetrics,
51
+ winrt::Microsoft::ReactNative::Composition::implementation::Theme *theme) noexcept;
52
+
53
+ static winrt::com_ptr<ID2D1PathGeometry> GenerateRoundedRectPathGeometry(
54
+ winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
55
+ const facebook::react::RectangleCorners<float> &baseRadius,
56
+ const facebook::react::RectangleEdges<float> &inset,
57
+ const facebook::react::RectangleEdges<float> &rectPathGeometry) noexcept;
58
+
59
+ private:
60
+ std::array<winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual, SpecialBorderLayerCount>
61
+ FindSpecialBorderLayers() const noexcept;
62
+
63
+ bool TryUpdateSpecialBorderLayers(
64
+ winrt::Microsoft::ReactNative::Composition::implementation::Theme *theme,
65
+ std::array<winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual, SpecialBorderLayerCount>
66
+ &spBorderVisuals,
67
+ facebook::react::LayoutMetrics const &layoutMetrics,
68
+ const facebook::react::BorderMetrics &borderMetrics) noexcept;
69
+
70
+ uint8_t m_numBorderVisuals{0};
71
+ winrt::Microsoft::ReactNative::Composition::implementation::ComponentView *m_outer;
72
+ winrt::Microsoft::ReactNative::Composition::Experimental::IVisual m_rootVisual{nullptr};
73
+ bool m_needsUpdate{true};
74
+ };
75
+
76
+ } // namespace winrt::Microsoft::ReactNative::Composition::implementation
@@ -1,6 +1,8 @@
1
1
  #include "pch.h"
2
2
  #include "CompositionDynamicAutomationProvider.h"
3
3
  #include <Fabric/ComponentView.h>
4
+ #include <Fabric/Composition/SwitchComponentView.h>
5
+ #include <Fabric/Composition/TextInput/WindowsTextInputComponentView.h>
4
6
  #include <Unicode.h>
5
7
  #include "RootComponentView.h"
6
8
  #include "UiaHelpers.h"
@@ -141,6 +143,20 @@ bool expandableControl(const facebook::react::SharedViewProps props) {
141
143
  return false;
142
144
  }
143
145
 
146
+ bool togglableControl(const facebook::react::SharedViewProps props) {
147
+ if (props->accessibilityState.has_value() &&
148
+ props->accessibilityState->checked != facebook::react::AccessibilityState::None) {
149
+ return true;
150
+ }
151
+ auto accessibilityActions = props->accessibilityActions;
152
+ for (size_t i = 0; i < accessibilityActions.size(); i++) {
153
+ if (accessibilityActions[i].name == "toggle") {
154
+ return true;
155
+ }
156
+ }
157
+ return false;
158
+ }
159
+
144
160
  HRESULT __stdcall CompositionDynamicAutomationProvider::GetPatternProvider(PATTERNID patternId, IUnknown **pRetVal) {
145
161
  if (pRetVal == nullptr)
146
162
  return E_POINTER;
@@ -158,10 +174,7 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::GetPatternProvider(PATTE
158
174
  auto accessibilityRole = props->accessibilityRole;
159
175
  // Invoke control pattern is used to support controls that do not maintain state
160
176
  // when activated but rather initiate or perform a single, unambiguous action.
161
- if (patternId == UIA_InvokePatternId &&
162
- (accessibilityRole == "button" || accessibilityRole == "imagebutton" || accessibilityRole == "link" ||
163
- accessibilityRole == "splitbutton" || (accessibilityRole == "menuitem" && props->onAccessibilityTap) ||
164
- (accessibilityRole == "treeitem" && props->onAccessibilityTap))) {
177
+ if (patternId == UIA_InvokePatternId && (props->onAccessibilityTap)) {
165
178
  *pRetVal = static_cast<IInvokeProvider *>(this);
166
179
  AddRef();
167
180
  }
@@ -171,21 +184,21 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::GetPatternProvider(PATTE
171
184
  AddRef();
172
185
  }
173
186
 
174
- if (patternId == UIA_ValuePatternId) {
187
+ if (patternId == UIA_ValuePatternId &&
188
+ (strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::WindowsTextInputComponentView>() ||
189
+ accessibilityValueHasValue(props->accessibilityValue))) {
175
190
  *pRetVal = static_cast<IValueProvider *>(this);
176
191
  AddRef();
177
192
  }
178
193
 
179
- if (patternId == UIA_TogglePatternId && (accessibilityRole == "switch" || accessibilityRole == "checkbox")) {
194
+ if (patternId == UIA_TogglePatternId &&
195
+ (strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::SwitchComponentView>() ||
196
+ togglableControl(props))) {
180
197
  *pRetVal = static_cast<IToggleProvider *>(this);
181
198
  AddRef();
182
199
  }
183
200
 
184
- if (patternId == UIA_ExpandCollapsePatternId &&
185
- (accessibilityRole == "combobox" || accessibilityRole == "splitbutton" || accessibilityRole == "treeitem" ||
186
- (expandableControl(props) &&
187
- (accessibilityRole == "toolbar" || accessibilityRole == "menuitem" || accessibilityRole == "menubar" ||
188
- accessibilityRole == "listitem" || accessibilityRole == "group" || accessibilityRole == "button")))) {
201
+ if (patternId == UIA_ExpandCollapsePatternId && expandableControl(props)) {
189
202
  *pRetVal = static_cast<IExpandCollapseProvider *>(this);
190
203
  AddRef();
191
204
  }
@@ -480,8 +493,13 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::get_ToggleState(ToggleSt
480
493
  if (!strongView)
481
494
  return UIA_E_ELEMENTNOTAVAILABLE;
482
495
 
483
- *pRetVal =
484
- winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(strongView)->getToggleState();
496
+ auto props = std::static_pointer_cast<const facebook::react::ViewProps>(
497
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(strongView)->props());
498
+
499
+ *pRetVal = (props->accessibilityState.has_value() &&
500
+ props->accessibilityState->checked != facebook::react::AccessibilityState::None)
501
+ ? GetToggleState(props->accessibilityState)
502
+ : winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(strongView)->getToggleState();
485
503
  return S_OK;
486
504
  }
487
505
 
@@ -139,8 +139,9 @@ struct CompositionInputKeyboardSource : winrt::implements<
139
139
 
140
140
  CompositionEventHandler::CompositionEventHandler(
141
141
  const winrt::Microsoft::ReactNative::ReactContext &context,
142
- const winrt::Microsoft::ReactNative::ReactNativeIsland &reactNativeIsland)
143
- : m_context(context), m_wkRootView(reactNativeIsland) {}
142
+ const winrt::Microsoft::ReactNative::ReactNativeIsland &reactNativeIsland,
143
+ const int fragmentTag)
144
+ : m_fragmentTag(fragmentTag), m_context(context), m_wkRootView(reactNativeIsland) {}
144
145
 
145
146
  void CompositionEventHandler::Initialize() noexcept {
146
147
  #ifdef USE_WINUI3
@@ -831,7 +832,30 @@ void CompositionEventHandler::getTargetPointerArgs(
831
832
  ptLocal.y = ptScaled.y - (clientRect.top / strongRootView.ScaleFactor());
832
833
  }
833
834
  } else {
834
- tag = RootComponentView().hitTest(ptScaled, ptLocal);
835
+ if (m_fragmentTag == -1) {
836
+ tag = RootComponentView().hitTest(ptScaled, ptLocal);
837
+ return;
838
+ }
839
+
840
+ // check if the fragment tag exists
841
+ if (!fabricuiManager->GetViewRegistry().findComponentViewWithTag(m_fragmentTag)) {
842
+ return;
843
+ }
844
+
845
+ auto fagmentView = fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(m_fragmentTag).view;
846
+ auto fagmentchildren = fagmentView.Children();
847
+
848
+ // call the hitTest with the fargment as the RootComponent
849
+ for (auto index = fagmentchildren.Size(); index > 0; index--) {
850
+ auto childView = fagmentchildren.GetAt(index - 1);
851
+ auto targetTag =
852
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(childView)->hitTest(
853
+ ptScaled, ptLocal);
854
+ if (targetTag != -1) {
855
+ tag = targetTag;
856
+ break;
857
+ }
858
+ }
835
859
  }
836
860
  }
837
861
 
@@ -31,7 +31,8 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
31
31
  public:
32
32
  CompositionEventHandler(
33
33
  const winrt::Microsoft::ReactNative::ReactContext &context,
34
- const winrt::Microsoft::ReactNative::ReactNativeIsland &ReactNativeIsland);
34
+ const winrt::Microsoft::ReactNative::ReactNativeIsland &ReactNativeIsland,
35
+ const int fragmentTag);
35
36
  virtual ~CompositionEventHandler();
36
37
 
37
38
  void Initialize() noexcept;
@@ -148,6 +149,7 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
148
149
 
149
150
  std::map<PointerId, ActiveTouch> m_activeTouches; // iOS is map of touch event args to ActiveTouch..?
150
151
  PointerId m_touchId = 0;
152
+ int m_fragmentTag = -1;
151
153
 
152
154
  std::map<PointerId, std::vector<ReactTaggedView>> m_currentlyHoveredViewsPerPointer;
153
155
  winrt::weak_ref<winrt::Microsoft::ReactNative::ReactNativeIsland> m_wkRootView;