react-native-windows 0.74.29 → 0.74.31

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 (70) hide show
  1. package/Libraries/Components/Button.windows.js +9 -0
  2. package/Libraries/Components/Pressable/Pressable.windows.js +9 -0
  3. package/Libraries/Components/TextInput/TextInput.windows.js +11 -1
  4. package/Libraries/Components/Touchable/TouchableBounce.windows.js +225 -0
  5. package/Libraries/Components/Touchable/TouchableNativeFeedback.windows.js +373 -0
  6. package/Libraries/Components/Touchable/TouchableOpacity.windows.js +7 -0
  7. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +10 -0
  8. package/Libraries/Components/View/View.windows.js +11 -1
  9. package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  10. package/Libraries/Components/View/ViewAccessibility.windows.js +5 -2
  11. package/Libraries/Components/View/ViewPropTypes.windows.js +3 -0
  12. package/Libraries/Image/Image.windows.js +7 -0
  13. package/Libraries/Text/Text.windows.js +11 -1
  14. package/Libraries/Text/TextProps.windows.js +3 -0
  15. package/Microsoft.ReactNative/CompositionComponentView.idl +13 -1
  16. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +1 -2
  17. package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -1
  18. package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +0 -5
  19. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +293 -9
  20. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +28 -1
  21. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +13 -32
  22. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +1 -3
  23. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +1 -1
  24. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h +2 -1
  25. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +18 -5
  26. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +1 -1
  27. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +191 -329
  28. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +3 -61
  29. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.cpp +66 -0
  30. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.h +52 -0
  31. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +21 -0
  32. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +7 -4
  33. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +79 -19
  34. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +12 -6
  35. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +71 -17
  36. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +16 -0
  37. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +1 -1
  38. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +1 -1
  39. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +62 -33
  40. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +5 -2
  41. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +1 -6
  42. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +0 -3
  43. package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +0 -2
  44. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +5 -0
  45. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +19 -1
  46. package/Microsoft.ReactNative/ReactNativeHost.cpp +5 -0
  47. package/Microsoft.ReactNative/ReactNativeIsland.idl +5 -1
  48. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  49. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +253 -0
  50. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +799 -0
  51. package/Shared/Shared.vcxitems +3 -2
  52. package/Shared/Shared.vcxitems.filters +2 -3
  53. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +204 -0
  54. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +287 -0
  55. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +192 -0
  56. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +216 -0
  57. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +242 -0
  58. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +259 -0
  59. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +226 -0
  60. package/codegen/react/components/rnwcore/InputAccessory.g.h +192 -0
  61. package/codegen/react/components/rnwcore/ModalHostView.g.h +271 -0
  62. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +238 -0
  63. package/codegen/react/components/rnwcore/SafeAreaView.g.h +189 -0
  64. package/codegen/react/components/rnwcore/Switch.g.h +255 -0
  65. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +192 -0
  66. package/just-task.js +1 -1
  67. package/package.json +1 -1
  68. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentDescriptor.h +0 -39
  69. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.cpp +0 -18
  70. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.h +0 -39
@@ -42,44 +42,59 @@ HRESULT UiaNavigateHelper(
42
42
  }
43
43
  } break;
44
44
 
45
- case NavigateDirection_LastChild:
46
- __fallthrough;
47
-
45
+ case NavigateDirection_LastChild: {
46
+ auto children = view.Children();
47
+ if (children.Size() != 0) {
48
+ uint32_t index = children.Size() - 1;
49
+ do {
50
+ auto child = children.GetAt(index).as<winrt::Microsoft::ReactNative::implementation::ComponentView>();
51
+ if (uiaProvider = child->EnsureUiaProvider()) {
52
+ break;
53
+ }
54
+ } while (index-- != 0);
55
+ }
56
+ } break;
48
57
  case NavigateDirection_FirstChild: {
49
58
  auto children = view.Children();
50
- auto index = direction == NavigateDirection_FirstChild ? 0 : children.Size() - 1;
51
- if (!children.Size() == 0) {
52
- uiaProvider = children.GetAt(index)
53
- .as<winrt::Microsoft::ReactNative::Composition::implementation::ComponentView>()
54
- ->EnsureUiaProvider();
59
+ if (children.Size() != 0) {
60
+ uint32_t index = 0;
61
+ do {
62
+ auto child = children.GetAt(index).as<winrt::Microsoft::ReactNative::implementation::ComponentView>();
63
+ if (uiaProvider = child->EnsureUiaProvider()) {
64
+ break;
65
+ }
66
+ } while (++index != children.Size());
55
67
  }
56
68
  } break;
57
-
58
69
  case NavigateDirection_NextSibling: {
59
- auto parentCV = view.Parent().as<winrt::Microsoft::ReactNative::Composition::implementation::ComponentView>();
70
+ auto parentCV = view.Parent().as<winrt::Microsoft::ReactNative::implementation::ComponentView>();
60
71
  if (parentCV != nullptr) {
61
72
  auto children = parentCV->Children();
62
73
  auto it = std::find(children.begin(), children.end(), view);
63
- if (++it != children.end()) {
64
- uiaProvider = (*it)
65
- .as<winrt::Microsoft::ReactNative::Composition::implementation::ComponentView>()
66
- ->EnsureUiaProvider();
74
+
75
+ while (++it != children.end()) {
76
+ auto nextchild = (*it).as<winrt::Microsoft::ReactNative::implementation::ComponentView>();
77
+ if (uiaProvider = nextchild->EnsureUiaProvider()) {
78
+ break;
79
+ }
67
80
  }
68
81
  }
69
82
  } break;
70
83
 
71
84
  case NavigateDirection_PreviousSibling: {
72
- auto parentCV = view.Parent().as<winrt::Microsoft::ReactNative::Composition::implementation::ComponentView>();
85
+ auto parentCV = view.Parent().as<winrt::Microsoft::ReactNative::implementation::ComponentView>();
73
86
  if (parentCV != nullptr) {
74
87
  auto children = parentCV->Children();
75
- for (auto i = children.Size() - 1; i > 0; i--) {
76
- auto child = children.GetAt(i);
77
- if (child == view) {
78
- uiaProvider = children.GetAt(i - 1)
79
- .as<winrt::Microsoft::ReactNative::Composition::implementation::ComponentView>()
80
- ->EnsureUiaProvider();
81
- break;
82
- }
88
+ auto it = std::find(children.begin(), children.end(), view);
89
+
90
+ if (it != children.begin()) {
91
+ do {
92
+ it--;
93
+ auto prevchild = (*it).as<winrt::Microsoft::ReactNative::implementation::ComponentView>();
94
+ if (uiaProvider = prevchild->EnsureUiaProvider()) {
95
+ break;
96
+ }
97
+ } while (it != children.begin());
83
98
  }
84
99
  }
85
100
  } break;
@@ -174,16 +189,6 @@ long GetLiveSetting(const std::string &liveRegion) noexcept {
174
189
  return LiveSetting::Off;
175
190
  }
176
191
 
177
- std::string extractAccessibilityValue(const facebook::react::AccessibilityValue &value) noexcept {
178
- if (value.now.has_value()) {
179
- return std::to_string(value.now.value());
180
- } else if (value.text.has_value()) {
181
- return value.text.value();
182
- } else {
183
- return "";
184
- }
185
- }
186
-
187
192
  void DispatchAccessibilityAction(::Microsoft::ReactNative::ReactTaggedView &view, const std::string &action) noexcept {
188
193
  auto strongView = view.view();
189
194
 
@@ -214,6 +219,30 @@ ExpandCollapseState GetExpandCollapseState(const bool &expanded) noexcept {
214
219
  }
215
220
  }
216
221
 
222
+ void AddSelectionItemsToContainer(CompositionDynamicAutomationProvider *provider) noexcept {
223
+ winrt::com_ptr<IRawElementProviderSimple> selectionContainer;
224
+ provider->get_SelectionContainer(selectionContainer.put());
225
+ if (!selectionContainer)
226
+ return;
227
+ auto selectionContainerProvider = selectionContainer.as<CompositionDynamicAutomationProvider>();
228
+ auto simpleProvider = static_cast<IRawElementProviderSimple *>(provider);
229
+ winrt::com_ptr<IRawElementProviderSimple> simpleProviderPtr;
230
+ simpleProviderPtr.copy_from(simpleProvider);
231
+ selectionContainerProvider->AddToSelectionItems(simpleProviderPtr);
232
+ }
233
+
234
+ void RemoveSelectionItemsFromContainer(CompositionDynamicAutomationProvider *provider) noexcept {
235
+ winrt::com_ptr<IRawElementProviderSimple> selectionContainer;
236
+ provider->get_SelectionContainer(selectionContainer.put());
237
+ if (!selectionContainer)
238
+ return;
239
+ auto selectionContainerProvider = selectionContainer.as<CompositionDynamicAutomationProvider>();
240
+ auto simpleProvider = static_cast<IRawElementProviderSimple *>(provider);
241
+ winrt::com_ptr<IRawElementProviderSimple> simpleProviderPtr;
242
+ simpleProviderPtr.copy_from(simpleProvider);
243
+ selectionContainerProvider->RemoveFromSelectionItems(simpleProviderPtr);
244
+ }
245
+
217
246
  ToggleState GetToggleState(const std::optional<facebook::react::AccessibilityState> &state) noexcept {
218
247
  if (state.has_value()) {
219
248
  if (state->checked == facebook::react::AccessibilityState::Checked) {
@@ -1,6 +1,7 @@
1
1
  #pragma once
2
2
 
3
3
  #include <Fabric/ComponentView.h>
4
+ #include <Fabric/Composition/CompositionDynamicAutomationProvider.h>
4
5
  #include <Fabric/ReactTaggedView.h>
5
6
  #include <UIAutomation.h>
6
7
 
@@ -31,11 +32,13 @@ void UpdateUiaProperty(
31
32
 
32
33
  long GetLiveSetting(const std::string &liveRegion) noexcept;
33
34
 
34
- std::string extractAccessibilityValue(const facebook::react::AccessibilityValue &value) noexcept;
35
-
36
35
  void DispatchAccessibilityAction(::Microsoft::ReactNative::ReactTaggedView &view, const std::string &action) noexcept;
37
36
 
38
37
  ExpandCollapseState GetExpandCollapseState(const bool &expanded) noexcept;
39
38
 
39
+ void AddSelectionItemsToContainer(CompositionDynamicAutomationProvider *provider) noexcept;
40
+
41
+ void RemoveSelectionItemsFromContainer(CompositionDynamicAutomationProvider *provider) noexcept;
42
+
40
43
  ToggleState GetToggleState(const std::optional<facebook::react::AccessibilityState> &state) noexcept;
41
44
  } // namespace winrt::Microsoft::ReactNative::implementation
@@ -157,7 +157,6 @@ void FabricUIManager::startSurface(
157
157
 
158
158
  auto root = rootComponentViewDescriptor.view
159
159
  .as<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>();
160
- root->theme(winrt::get_self<winrt::Microsoft::ReactNative::Composition::implementation::Theme>(rootView.Theme()));
161
160
  root->start(rootView);
162
161
  });
163
162
 
@@ -177,15 +176,11 @@ void FabricUIManager::startSurface(
177
176
  void FabricUIManager::stopSurface(facebook::react::SurfaceId surfaceId) noexcept {
178
177
  m_surfaceManager->stopSurface(surfaceId);
179
178
  auto &rootDescriptor = m_registry.componentViewDescriptorWithTag(surfaceId);
179
+ rootDescriptor.view.as<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>()->stop();
180
180
  m_registry.enqueueComponentViewWithComponentHandle(
181
181
  facebook::react::RootShadowNode::Handle(), surfaceId, rootDescriptor);
182
182
  }
183
183
 
184
- winrt::Microsoft::ReactNative::ReactNativeIsland FabricUIManager::GetReactNativeIsland(
185
- facebook::react::SurfaceId surfaceId) const noexcept {
186
- return m_surfaceRegistry.at(surfaceId).wkRootView.get();
187
- }
188
-
189
184
  facebook::react::Size FabricUIManager::measureSurface(
190
185
  facebook::react::SurfaceId surfaceId,
191
186
  const facebook::react::LayoutConstraints &layoutConstraints,
@@ -49,9 +49,6 @@ struct FabricUIManager final : public std::enable_shared_from_this<FabricUIManag
49
49
 
50
50
  const IComponentViewRegistry &GetViewRegistry() const noexcept;
51
51
 
52
- winrt::Microsoft::ReactNative::ReactNativeIsland GetReactNativeIsland(
53
- facebook::react::SurfaceId surfaceId) const noexcept;
54
-
55
52
  static winrt::Microsoft::ReactNative::ReactNotificationId<facebook::react::SurfaceId> NotifyMountedId() noexcept;
56
53
 
57
54
  private:
@@ -6,7 +6,6 @@
6
6
 
7
7
  #include <Fabric/AbiComponentDescriptor.h>
8
8
  #include <Fabric/AbiViewComponentDescriptor.h>
9
- #include <Fabric/Composition/Modal/WindowsModalHostViewComponentDescriptor.h>
10
9
  #include <Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h>
11
10
  #include <react/components/rnwcore/ComponentDescriptors.h>
12
11
  #include <react/renderer/components/image/ImageComponentDescriptor.h>
@@ -37,7 +36,6 @@ WindowsComponentDescriptorRegistry::WindowsComponentDescriptorRegistry()
37
36
  facebook::react::ActivityIndicatorViewComponentDescriptor>());
38
37
  add(facebook::react::concreteComponentDescriptorProvider<facebook::react::DebuggingOverlayComponentDescriptor>());
39
38
  add(facebook::react::concreteComponentDescriptorProvider<facebook::react::ImageComponentDescriptor>());
40
- add(facebook::react::concreteComponentDescriptorProvider<facebook::react::WindowsModalHostViewComponentDescriptor>());
41
39
  add(facebook::react::concreteComponentDescriptorProvider<facebook::react::ParagraphComponentDescriptor>());
42
40
  add(facebook::react::concreteComponentDescriptorProvider<facebook::react::RawTextComponentDescriptor>());
43
41
  add(facebook::react::concreteComponentDescriptorProvider<facebook::react::ScrollViewComponentDescriptor>());
@@ -21,6 +21,10 @@ namespace Microsoft.ReactNative.Composition
21
21
  [experimental]
22
22
  delegate void ComponentIslandComponentViewInitializer(ContentIslandComponentView view);
23
23
 
24
+ [webhosthidden]
25
+ [experimental]
26
+ delegate void PortalComponentViewInitializer(PortalComponentView view);
27
+
24
28
  [experimental]
25
29
  [webhosthidden]
26
30
  delegate Microsoft.UI.Composition.Visual CreateVisualDelegate(Microsoft.ReactNative.ComponentView view);
@@ -55,6 +59,7 @@ namespace Microsoft.ReactNative.Composition
55
59
  {
56
60
  void SetViewComponentViewInitializer(ViewComponentViewInitializer initializer);
57
61
  void SetContentIslandComponentViewInitializer(ComponentIslandComponentViewInitializer initializer);
62
+ void SetPortalComponentViewInitializer(PortalComponentViewInitializer initializer);
58
63
  void SetCreateVisualHandler(CreateVisualDelegate impl);
59
64
  void SetViewFeatures(ComponentViewFeatures viewFeatures);
60
65
  void SetUpdateLayoutMetricsHandler(UpdateLayoutMetricsDelegate impl);
@@ -586,6 +586,24 @@ std::unique_ptr<facebook::jsi::PreparedScriptStore> CreatePreparedScriptStore()
586
586
  }
587
587
 
588
588
  #ifdef USE_FABRIC
589
+
590
+ typedef HRESULT(__stdcall *SetThreadDescriptionFn)(HANDLE, PCWSTR);
591
+ void SetJSThreadDescription() noexcept {
592
+ // Office still supports Server 2016 so we need to use Run Time Dynamic Linking and cannot just use:
593
+ // ::SetThreadDescription(GetCurrentThread(), L"React-Native JavaScript Thread");
594
+
595
+ auto moduleHandle = GetModuleHandleW(L"kernelbase.dll");
596
+ // The description is just for developer experience, so we can skip it if kernelbase isn't already loaded
597
+ if (!moduleHandle)
598
+ return;
599
+
600
+ auto proc = GetProcAddress(moduleHandle, "SetThreadDescription");
601
+ if (!proc)
602
+ return;
603
+
604
+ reinterpret_cast<SetThreadDescriptionFn>(proc)(GetCurrentThread(), L"React-Native JavaScript Thread");
605
+ }
606
+
589
607
  void ReactInstanceWin::InitializeBridgeless() noexcept {
590
608
  InitUIQueue();
591
609
 
@@ -634,7 +652,7 @@ void ReactInstanceWin::InitializeBridgeless() noexcept {
634
652
  Mso::Copy(m_whenDestroyed)));
635
653
 
636
654
  m_jsMessageThread.Load()->runOnQueueSync([&]() {
637
- ::SetThreadDescription(GetCurrentThread(), L"React-Native JavaScript Thread");
655
+ SetJSThreadDescription();
638
656
  auto timerRegistry =
639
657
  ::Microsoft::ReactNative::TimerRegistry::CreateTimerRegistry(m_reactContext->Properties());
640
658
  auto timerRegistryRaw = timerRegistry.get();
@@ -15,6 +15,7 @@
15
15
  #include "ReactInstanceSettings.h"
16
16
 
17
17
  #ifdef USE_FABRIC
18
+ #include <Fabric/Composition/Modal/WindowsModalHostViewComponentView.h>
18
19
  #include <Fabric/WindowsComponentDescriptorRegistry.h>
19
20
  #include <ReactPackageBuilder.h>
20
21
  #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
@@ -115,6 +116,10 @@ IAsyncAction ReactNativeHost::ReloadInstance() noexcept {
115
116
  #endif
116
117
  m_instanceSettings.UseWebDebugger());
117
118
 
119
+ #ifdef USE_FABRIC
120
+ winrt::Microsoft::ReactNative::Composition::implementation::RegisterWindowsModalHostNativeComponent(m_packageBuilder);
121
+ #endif
122
+
118
123
  if (auto packageProviders = InstanceSettings().PackageProviders()) {
119
124
  for (auto const &packageProvider : packageProviders) {
120
125
  packageProvider.CreatePackage(m_packageBuilder);
@@ -6,6 +6,8 @@ import "ReactCoreInjection.idl";
6
6
  import "ReactNativeHost.idl";
7
7
  import "Theme.idl";
8
8
  import "IReactViewComponentBuilder.idl";
9
+ import "CompositionComponentView.idl";
10
+
9
11
  #include "NamespaceRedirect.h"
10
12
  #include "DocString.h"
11
13
 
@@ -83,7 +85,9 @@ namespace Microsoft.ReactNative
83
85
 
84
86
  #ifdef USE_WINUI3
85
87
  ReactNativeIsland(Microsoft.UI.Composition.Compositor compositor);
86
- ReactNativeIsland(Microsoft.UI.Composition.Compositor compositor, Microsoft.ReactNative.IReactContext context, Microsoft.ReactNative.ComponentView componentView);
88
+
89
+ DOC_STRING("Used to create react portals, such as a native modal component.")
90
+ static ReactNativeIsland CreatePortal(Microsoft.ReactNative.Composition.PortalComponentView portal);
87
91
  #endif
88
92
 
89
93
  DOC_STRING(
@@ -10,11 +10,11 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.74.29</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.74.31</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>74</ReactNativeWindowsMinor>
16
- <ReactNativeWindowsPatch>29</ReactNativeWindowsPatch>
16
+ <ReactNativeWindowsPatch>31</ReactNativeWindowsPatch>
17
17
  <ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
18
- <ReactNativeWindowsCommitId>c15cbb774b3faa73f63778955cc8a4085e39210e</ReactNativeWindowsCommitId>
18
+ <ReactNativeWindowsCommitId>ab27bdc176d1976cdc3e9182f83863a89417cf4f</ReactNativeWindowsCommitId>
19
19
  </PropertyGroup>
20
20
  </Project>
@@ -0,0 +1,253 @@
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
+
8
+ #pragma once
9
+
10
+ #include <cinttypes>
11
+ #include <optional>
12
+ #include <string>
13
+ #include <vector>
14
+
15
+ namespace facebook::react {
16
+
17
+ enum class AccessibilityTraits : uint32_t {
18
+ None = 0,
19
+ Button = (1 << 0),
20
+ Link = (1 << 1),
21
+ Image = (1 << 2),
22
+ Selected = (1 << 3),
23
+ PlaysSound = (1 << 4),
24
+ KeyboardKey = (1 << 5),
25
+ StaticText = (1 << 6),
26
+ SummaryElement = (1 << 7),
27
+ NotEnabled = (1 << 8),
28
+ UpdatesFrequently = (1 << 9),
29
+ SearchField = (1 << 10),
30
+ StartsMediaSession = (1 << 11),
31
+ Adjustable = (1 << 12),
32
+ AllowsDirectInteraction = (1 << 13),
33
+ CausesPageTurn = (1 << 14),
34
+ Header = (1 << 15),
35
+ Switch = (1 << 16),
36
+ TabBar = (1 << 17),
37
+ };
38
+
39
+ constexpr enum AccessibilityTraits operator|(
40
+ const enum AccessibilityTraits lhs,
41
+ const enum AccessibilityTraits rhs) {
42
+ return (enum AccessibilityTraits)((uint32_t)lhs | (uint32_t)rhs);
43
+ }
44
+
45
+ constexpr enum AccessibilityTraits operator&(
46
+ const enum AccessibilityTraits lhs,
47
+ const enum AccessibilityTraits rhs) {
48
+ return (enum AccessibilityTraits)((uint32_t)lhs & (uint32_t)rhs);
49
+ }
50
+
51
+ struct AccessibilityAction {
52
+ std::string name{""};
53
+ std::optional<std::string> label{};
54
+ };
55
+
56
+ inline static bool operator==(
57
+ const AccessibilityAction& lhs,
58
+ const AccessibilityAction& rhs) {
59
+ return lhs.name == rhs.name && lhs.label == rhs.label;
60
+ }
61
+
62
+ inline static bool operator!=(
63
+ const AccessibilityAction& lhs,
64
+ const AccessibilityAction& rhs) {
65
+ return !(rhs == lhs);
66
+ }
67
+
68
+ struct AccessibilityState {
69
+ bool disabled{false};
70
+ std::optional<bool> selected{std::nullopt}; // [Windows] - Do not remove; required for Windows ISelectionItemProvider Implementation
71
+ bool busy{false};
72
+ std::optional<bool> expanded{std::nullopt};
73
+ std::optional<bool> readOnly{std::nullopt}; // [Windows] - Do not remove; required for Windows IRangeValueProvider and IValueProvider Implementation
74
+ std::optional<bool> multiselectable{std::nullopt}; // [Windows] - Do not remove; required for Windows ISelectionProvider Implementation
75
+ std::optional<bool> required{std::nullopt}; // [Windows] - Do not remove; required for Windows ISelectionProvider Implementation
76
+ enum { Unchecked, Checked, Mixed, None } checked{None};
77
+ };
78
+
79
+ constexpr bool operator==(
80
+ const AccessibilityState& lhs,
81
+ const AccessibilityState& rhs) {
82
+ return lhs.disabled == rhs.disabled && lhs.selected == rhs.selected &&
83
+ lhs.checked == rhs.checked && lhs.busy == rhs.busy &&
84
+ lhs.expanded == rhs.expanded;
85
+ }
86
+
87
+ constexpr bool operator!=(
88
+ const AccessibilityState& lhs,
89
+ const AccessibilityState& rhs) {
90
+ return !(rhs == lhs);
91
+ }
92
+
93
+ struct AccessibilityLabelledBy {
94
+ std::vector<std::string> value{};
95
+ };
96
+
97
+ inline static bool operator==(
98
+ const AccessibilityLabelledBy& lhs,
99
+ const AccessibilityLabelledBy& rhs) {
100
+ return lhs.value == rhs.value;
101
+ }
102
+
103
+ inline static bool operator!=(
104
+ const AccessibilityLabelledBy& lhs,
105
+ const AccessibilityLabelledBy& rhs) {
106
+ return !(lhs == rhs);
107
+ }
108
+
109
+ struct AccessibilityValue {
110
+ std::optional<int> min;
111
+ std::optional<int> max;
112
+ std::optional<int> now;
113
+ std::optional<std::string> text{};
114
+ };
115
+
116
+ constexpr bool operator==(
117
+ const AccessibilityValue& lhs,
118
+ const AccessibilityValue& rhs) {
119
+ return lhs.min == rhs.min && lhs.max == rhs.max && lhs.now == rhs.now &&
120
+ lhs.text == rhs.text;
121
+ }
122
+
123
+ constexpr bool operator!=(
124
+ const AccessibilityValue& lhs,
125
+ const AccessibilityValue& rhs) {
126
+ return !(rhs == lhs);
127
+ }
128
+
129
+ enum class ImportantForAccessibility : uint8_t {
130
+ Auto,
131
+ Yes,
132
+ No,
133
+ NoHideDescendants,
134
+ };
135
+
136
+ enum class AccessibilityLiveRegion : uint8_t {
137
+ None,
138
+ Polite,
139
+ Assertive,
140
+ };
141
+
142
+ enum class AccessibilityRole {
143
+ None,
144
+ Button,
145
+ Dropdownlist,
146
+ Togglebutton,
147
+ Link,
148
+ Search,
149
+ Image,
150
+ Keyboardkey,
151
+ Text,
152
+ Adjustable,
153
+ Imagebutton,
154
+ Header,
155
+ Summary,
156
+ Alert,
157
+ Checkbox,
158
+ Combobox,
159
+ Menu,
160
+ Menubar,
161
+ Menuitem,
162
+ Progressbar,
163
+ Radio,
164
+ Radiogroup,
165
+ Scrollbar,
166
+ Spinbutton,
167
+ Switch,
168
+ Tab,
169
+ Tabbar,
170
+ Tablist,
171
+ Timer,
172
+ List,
173
+ Toolbar,
174
+ Grid,
175
+ Pager,
176
+ Scrollview,
177
+ Horizontalscrollview,
178
+ Viewgroup,
179
+ Webview,
180
+ Drawerlayout,
181
+ Slidingdrawer,
182
+ Iconmenu,
183
+ };
184
+
185
+ enum class Role {
186
+ Alert,
187
+ Alertdialog,
188
+ Application,
189
+ Article,
190
+ Banner,
191
+ Button,
192
+ Cell,
193
+ Checkbox,
194
+ Columnheader,
195
+ Combobox,
196
+ Complementary,
197
+ Contentinfo,
198
+ Definition,
199
+ Dialog,
200
+ Directory,
201
+ Document,
202
+ Feed,
203
+ Figure,
204
+ Form,
205
+ Grid,
206
+ Group,
207
+ Heading,
208
+ Img,
209
+ Link,
210
+ List,
211
+ Listitem,
212
+ Log,
213
+ Main,
214
+ Marquee,
215
+ Math,
216
+ Menu,
217
+ Menubar,
218
+ Menuitem,
219
+ Meter,
220
+ Navigation,
221
+ None,
222
+ Note,
223
+ Option,
224
+ Presentation,
225
+ Progressbar,
226
+ Radio,
227
+ Radiogroup,
228
+ Region,
229
+ Row,
230
+ Rowgroup,
231
+ Rowheader,
232
+ Scrollbar,
233
+ Searchbox,
234
+ Separator,
235
+ Slider,
236
+ Spinbutton,
237
+ Status,
238
+ Summary,
239
+ Switch,
240
+ Tab,
241
+ Table,
242
+ Tablist,
243
+ Tabpanel,
244
+ Term,
245
+ Timer,
246
+ Toolbar,
247
+ Tooltip,
248
+ Tree,
249
+ Treegrid,
250
+ Treeitem,
251
+ };
252
+
253
+ } // namespace facebook::react