react-native-windows 0.80.0-preview.5 → 0.80.0-preview.6

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.
@@ -18,14 +18,30 @@ CompositionTextRangeProvider::CompositionTextRangeProvider(
18
18
  }
19
19
 
20
20
  HRESULT __stdcall CompositionTextRangeProvider::Clone(ITextRangeProvider **pRetVal) {
21
- // no-op
22
- *pRetVal = nullptr;
21
+ if (pRetVal == nullptr)
22
+ return E_POINTER;
23
+
24
+ auto clone = winrt::make<winrt::Microsoft::ReactNative::implementation::CompositionTextRangeProvider>(
25
+ m_view.view().as<winrt::Microsoft::ReactNative::Composition::ComponentView>(), m_parentProvider.get());
26
+ *pRetVal = clone.detach();
23
27
  return S_OK;
24
28
  }
25
29
 
26
30
  HRESULT __stdcall CompositionTextRangeProvider::Compare(ITextRangeProvider *range, BOOL *pRetVal) {
27
- // no-op
28
- *pRetVal = false;
31
+ if (pRetVal == nullptr)
32
+ return E_POINTER;
33
+ if (range == nullptr) {
34
+ *pRetVal = FALSE;
35
+ return S_OK;
36
+ }
37
+
38
+ // Try to cast to our type , considering provider only supports a single range per view
39
+ auto other = dynamic_cast<CompositionTextRangeProvider *>(range);
40
+ if (other && other->m_view.view() == m_view.view()) {
41
+ *pRetVal = TRUE;
42
+ } else {
43
+ *pRetVal = FALSE;
44
+ }
29
45
  return S_OK;
30
46
  }
31
47
 
@@ -34,7 +50,10 @@ HRESULT __stdcall CompositionTextRangeProvider::CompareEndpoints(
34
50
  ITextRangeProvider *targetRange,
35
51
  TextPatternRangeEndpoint targetEndpoint,
36
52
  int *pRetVal) {
37
- // no-op
53
+ if (pRetVal == nullptr)
54
+ return E_POINTER;
55
+
56
+ // For a single-range provider, always equal:
38
57
  *pRetVal = 0;
39
58
  return S_OK;
40
59
  }
@@ -98,13 +117,13 @@ HRESULT __stdcall CompositionTextRangeProvider::GetAttributeValue(TEXTATTRIBUTEI
98
117
  textTransform = props->textAttributes.textTransform.value();
99
118
  }
100
119
  if (fontVariant == facebook::react::FontVariant::SmallCaps) {
101
- return CapStyle_SmallCap;
120
+ pRetVal->lVal = CapStyle_SmallCap;
102
121
  } else if (textTransform == facebook::react::TextTransform::Capitalize) {
103
- return CapStyle_Titling;
122
+ pRetVal->lVal = CapStyle_Titling;
104
123
  } else if (textTransform == facebook::react::TextTransform::Lowercase) {
105
- return CapStyle_None;
124
+ pRetVal->lVal = CapStyle_None;
106
125
  } else if (textTransform == facebook::react::TextTransform::Uppercase) {
107
- return CapStyle_AllCap;
126
+ pRetVal->lVal = CapStyle_AllCap;
108
127
  }
109
128
  } else if (attributeId == UIA_FontNameAttributeId) {
110
129
  pRetVal->vt = VT_BSTR;
@@ -282,6 +301,8 @@ HRESULT __stdcall CompositionTextRangeProvider::ScrollIntoView(BOOL alignToTop)
282
301
  return S_OK;
283
302
  }
284
303
 
304
+ // All the below methods should be implemented once the selection comes for paragraph and TextInput
305
+
285
306
  HRESULT __stdcall CompositionTextRangeProvider::AddToSelection() {
286
307
  // no-op
287
308
  return S_OK;
@@ -40,6 +40,14 @@
40
40
 
41
41
  namespace winrt::Microsoft::ReactNative::implementation {
42
42
 
43
+ ReactPropertyId<winrt::Microsoft::ReactNative::ReactNonAbiValue<
44
+ winrt::weak_ref<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>>>
45
+ ReactNativeIsland::LastFocusedReactNativeIslandProperty() noexcept {
46
+ static const ReactPropertyId<winrt::Microsoft::ReactNative::ReactNonAbiValue<
47
+ winrt::weak_ref<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>>>
48
+ prop{L"ReactNative.Composition", L"ReactNativeIsland"};
49
+ return prop;
50
+ }
43
51
  constexpr float loadingActivitySize = 12.0f;
44
52
  constexpr float loadingActivityHorizontalOffset = 16.0f;
45
53
  constexpr float loadingBarHeight = 36.0f;
@@ -861,6 +869,20 @@ winrt::Microsoft::UI::Content::ContentIsland ReactNativeIsland::Island() {
861
869
  }
862
870
  }
863
871
  });
872
+ focusController.GotFocus(
873
+ [weakThis = get_weak()](const auto &sender, const winrt::Microsoft::UI::Input::FocusChangedEventArgs &args) {
874
+ if (auto pThis = weakThis.get()) {
875
+ // Set the island to React context so it can be accessed by native modules
876
+ if (pThis->m_context && pThis->m_island) {
877
+ auto properties = pThis->m_context.Properties();
878
+ properties.Set(
879
+ ReactNativeIsland::LastFocusedReactNativeIslandProperty(),
880
+ winrt::Microsoft::ReactNative::ReactNonAbiValue<
881
+ winrt::weak_ref<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>>{
882
+ std::in_place, weakThis});
883
+ }
884
+ }
885
+ });
864
886
 
865
887
  // ContentIsland does not support weak_ref, so we cannot use auto_revoke for these events
866
888
  m_islandAutomationProviderRequestedToken = m_island.AutomationProviderRequested(
@@ -49,6 +49,9 @@ struct ReactNativeIsland
49
49
  ~ReactNativeIsland() noexcept;
50
50
 
51
51
  ReactNativeIsland(const winrt::Microsoft::UI::Composition::Compositor &compositor) noexcept;
52
+ static ReactPropertyId<winrt::Microsoft::ReactNative::ReactNonAbiValue<
53
+ winrt::weak_ref<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>>>
54
+ LastFocusedReactNativeIslandProperty() noexcept;
52
55
  ReactNativeIsland(const winrt::Microsoft::ReactNative::Composition::PortalComponentView &portal) noexcept;
53
56
 
54
57
  static winrt::Microsoft::ReactNative::ReactNativeIsland CreatePortal(
@@ -9,6 +9,7 @@
9
9
  #include <Fabric/AbiViewProps.h>
10
10
  #include "CompositionDynamicAutomationProvider.h"
11
11
  #include "RootComponentView.h"
12
+ #include "UiaHelpers.h"
12
13
 
13
14
  namespace winrt::Microsoft::ReactNative::Composition::implementation {
14
15
 
@@ -80,6 +81,16 @@ void SwitchComponentView::updateProps(
80
81
  m_visualUpdateRequired = true;
81
82
  }
82
83
 
84
+ if (oldViewProps.value != newViewProps.value) {
85
+ if (UiaClientsAreListening()) {
86
+ winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
87
+ EnsureUiaProvider(),
88
+ UIA_ToggleToggleStatePropertyId,
89
+ oldViewProps.value ? ToggleState_On : ToggleState_Off,
90
+ newViewProps.value ? ToggleState_On : ToggleState_Off);
91
+ }
92
+ }
93
+
83
94
  Super::updateProps(props, oldProps);
84
95
  }
85
96
 
@@ -166,6 +166,15 @@ void UpdateUiaProperty(winrt::IInspectable provider, PROPERTYID propId, bool old
166
166
  UiaRaiseAutomationPropertyChangedEvent(spProviderSimple.get(), propId, CComVariant(oldValue), CComVariant(newValue));
167
167
  }
168
168
 
169
+ void UpdateUiaProperty(winrt::IInspectable provider, PROPERTYID propId, int oldValue, int newValue) noexcept {
170
+ auto spProviderSimple = provider.try_as<IRawElementProviderSimple>();
171
+
172
+ if (spProviderSimple == nullptr || oldValue == newValue || !WasUiaPropertyAdvised(spProviderSimple, propId))
173
+ return;
174
+
175
+ UiaRaiseAutomationPropertyChangedEvent(spProviderSimple.get(), propId, CComVariant(oldValue), CComVariant(newValue));
176
+ }
177
+
169
178
  void UpdateUiaProperty(
170
179
  winrt::IInspectable provider,
171
180
  PROPERTYID propId,
@@ -29,6 +29,12 @@ void UpdateUiaProperty(
29
29
  bool oldValue,
30
30
  bool newValue) noexcept;
31
31
 
32
+ void UpdateUiaProperty(
33
+ winrt::Windows::Foundation::IInspectable provider,
34
+ PROPERTYID propId,
35
+ int oldValue,
36
+ int newValue) noexcept;
37
+
32
38
  void UpdateUiaProperty(
33
39
  winrt::Windows::Foundation::IInspectable provider,
34
40
  PROPERTYID propId,
@@ -7,6 +7,8 @@
7
7
  #include <UI.Xaml.Automation.Peers.h>
8
8
  #include <UI.Xaml.Controls.h>
9
9
  #include <XamlUtils.h>
10
+ #else
11
+ #include <Fabric/Composition/ReactNativeIsland.h>
10
12
  #endif
11
13
  #include <uiautomationcore.h>
12
14
  #include <uiautomationcoreapi.h>
@@ -79,6 +81,33 @@ void AccessibilityInfo::announceForAccessibility(std::wstring announcement) noex
79
81
  xaml::Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
80
82
  hstr,
81
83
  hstr);
84
+ #else
85
+ if (auto weakIslandWrapper = context.Properties().Get(
86
+ winrt::Microsoft::ReactNative::implementation::ReactNativeIsland::LastFocusedReactNativeIslandProperty())) {
87
+ if (auto weakIsland = weakIslandWrapper.Value()) {
88
+ if (auto reactNativeIsland = weakIsland.get()) {
89
+ if (auto uiaprovider = reactNativeIsland->GetUiaProvider()) {
90
+ if (auto rawProvider = uiaprovider.try_as<IRawElementProviderSimple>()) {
91
+ // Convert announcement to BSTR for UIA
92
+ winrt::hstring hstrAnnouncement{announcement};
93
+ auto bstrAnnouncement = SysAllocString(hstrAnnouncement.c_str());
94
+ if (bstrAnnouncement) {
95
+ // Raise the UIA notification event
96
+ HRESULT hr = UiaRaiseNotificationEvent(
97
+ rawProvider.get(),
98
+ NotificationKind_Other,
99
+ NotificationProcessing_ImportantMostRecent,
100
+ bstrAnnouncement,
101
+ bstrAnnouncement);
102
+ // Clean up BSTRs
103
+ SysFreeString(bstrAnnouncement);
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }
110
+
82
111
  #endif
83
112
  });
84
113
  }
@@ -10,11 +10,11 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.80.0-preview.5</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.80.0-preview.6</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>80</ReactNativeWindowsMinor>
16
16
  <ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
17
17
  <ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
18
- <ReactNativeWindowsCommitId>bfd8cddb021ba85c6382567fc39d315d812c5d08</ReactNativeWindowsCommitId>
18
+ <ReactNativeWindowsCommitId>5b9f6a7139a1664b0e2dd49c5654a52050f39ba1</ReactNativeWindowsCommitId>
19
19
  </PropertyGroup>
20
20
  </Project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.80.0-preview.5",
3
+ "version": "0.80.0-preview.6",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,7 +26,7 @@
26
26
  "@react-native-community/cli": "17.0.0",
27
27
  "@react-native-community/cli-platform-android": "17.0.0",
28
28
  "@react-native-community/cli-platform-ios": "17.0.0",
29
- "@react-native-windows/cli": "0.80.0-preview.4",
29
+ "@react-native-windows/cli": "0.80.0-preview.5",
30
30
  "@react-native/assets": "1.0.0",
31
31
  "@react-native/assets-registry": "0.80.0",
32
32
  "@react-native/codegen": "0.80.0",