react-native-macos 0.81.8 → 0.81.12
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.
- package/CHANGELOG.md +8 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +57 -1
- package/Libraries/Text/TextInput/Multiline/RCTWrappedTextView.m +26 -0
- package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +2 -0
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.mm +28 -4
- package/React/Base/RCTConvert.mm +2 -1
- package/React/Base/RCTUIKit.h +2 -0
- package/React/Base/RCTUtils.h +6 -0
- package/React/Base/RCTUtils.mm +1 -1
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/macOS/RCTUIKit.m +16 -0
- package/React/CoreModules/RCTDeviceInfo.mm +1 -1
- package/React/CxxBridge/RCTCxxBridge.mm +16 -7
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +32 -3
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm +14 -3
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +236 -8
- package/React/Fabric/Mounting/ComponentViews/VirtualView/RCTVirtualViewComponentView.mm +12 -0
- package/React/Fabric/Mounting/RCTMountingManager.mm +6 -1
- package/React/Views/RCTViewManager.m +4 -0
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactCommon/React-FabricComponents.podspec +19 -8
- package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
- package/ReactCommon/react/renderer/core/ShadowNode.cpp +29 -19
- package/ReactCommon/react/renderer/core/ShadowNodeFamily.h +2 -0
- package/ReactCommon/react/renderer/uimanager/UIManager.cpp +62 -53
- package/ReactCommon/react/renderer/uimanager/tests/FabricUIManagerTest.cpp +179 -3
- package/package.json +3 -3
- package/react-native.config.js +31 -7
|
@@ -44,6 +44,189 @@ using namespace facebook::react;
|
|
|
44
44
|
|
|
45
45
|
const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
|
|
46
46
|
|
|
47
|
+
#if TARGET_OS_OSX // [macOS
|
|
48
|
+
// The role an accessibility element reports when React Native does not override it. NSControl subclasses, such as the
|
|
49
|
+
// NSTextField behind a single-line TextInput, report their role through their cell; the control's own
|
|
50
|
+
// `accessibilityRole` getter returns NSAccessibilityUnknownRole until a role is set explicitly.
|
|
51
|
+
static NSAccessibilityRole RCTDefaultAccessibilityRoleForElement(NSView *element)
|
|
52
|
+
{
|
|
53
|
+
if ([element isKindOfClass:[NSControl class]]) {
|
|
54
|
+
NSAccessibilityRole cellRole = ((NSControl *)element).cell.accessibilityRole;
|
|
55
|
+
if (cellRole != nil) {
|
|
56
|
+
return cellRole;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return NSAccessibilityUnknownRole;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Fabric keeps these mappings local instead of depending on Paper's RCTConvert.
|
|
63
|
+
static NSAccessibilityRole RCTAccessibilityRoleFromString(NSString *role, BOOL useAriaMappings)
|
|
64
|
+
{
|
|
65
|
+
if (useAriaMappings && [role isEqualToString:@"rowgroup"]) {
|
|
66
|
+
return nil;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static NSDictionary<NSString *, NSAccessibilityRole> *ariaRoleToNSAccessibilityRole;
|
|
70
|
+
static NSDictionary<NSString *, NSAccessibilityRole> *traitOrRoleToAccessibilityRole;
|
|
71
|
+
static dispatch_once_t onceToken;
|
|
72
|
+
dispatch_once(&onceToken, ^{
|
|
73
|
+
ariaRoleToNSAccessibilityRole = @{
|
|
74
|
+
@"alert" : NSAccessibilityGroupRole,
|
|
75
|
+
@"alertdialog" : NSAccessibilityGroupRole,
|
|
76
|
+
@"application" : NSAccessibilityGroupRole,
|
|
77
|
+
@"article" : NSAccessibilityGroupRole,
|
|
78
|
+
@"banner" : NSAccessibilityGroupRole,
|
|
79
|
+
@"button" : NSAccessibilityButtonRole,
|
|
80
|
+
@"cell" : NSAccessibilityCellRole,
|
|
81
|
+
@"checkbox" : NSAccessibilityCheckBoxRole,
|
|
82
|
+
@"columnheader" : NSAccessibilityCellRole,
|
|
83
|
+
@"combobox" : NSAccessibilityComboBoxRole,
|
|
84
|
+
@"complementary" : NSAccessibilityGroupRole,
|
|
85
|
+
@"contentinfo" : NSAccessibilityGroupRole,
|
|
86
|
+
@"definition" : NSAccessibilityGroupRole,
|
|
87
|
+
@"dialog" : NSAccessibilityGroupRole,
|
|
88
|
+
@"directory" : NSAccessibilityListRole,
|
|
89
|
+
@"document" : NSAccessibilityGroupRole,
|
|
90
|
+
@"feed" : NSAccessibilityGroupRole,
|
|
91
|
+
@"figure" : NSAccessibilityGroupRole,
|
|
92
|
+
@"form" : NSAccessibilityGroupRole,
|
|
93
|
+
@"grid" : NSAccessibilityTableRole,
|
|
94
|
+
@"gridcell" : NSAccessibilityCellRole,
|
|
95
|
+
@"group" : NSAccessibilityGroupRole,
|
|
96
|
+
@"heading" : NSAccessibilityStaticTextRole,
|
|
97
|
+
@"image" : NSAccessibilityImageRole,
|
|
98
|
+
@"img" : NSAccessibilityImageRole,
|
|
99
|
+
@"link" : NSAccessibilityLinkRole,
|
|
100
|
+
@"list" : NSAccessibilityListRole,
|
|
101
|
+
@"listbox" : NSAccessibilityListRole,
|
|
102
|
+
@"listitem" : NSAccessibilityGroupRole,
|
|
103
|
+
@"log" : NSAccessibilityGroupRole,
|
|
104
|
+
@"main" : NSAccessibilityGroupRole,
|
|
105
|
+
@"marquee" : NSAccessibilityGroupRole,
|
|
106
|
+
@"math" : NSAccessibilityGroupRole,
|
|
107
|
+
@"menu" : NSAccessibilityMenuRole,
|
|
108
|
+
@"menubar" : NSAccessibilityMenuBarRole,
|
|
109
|
+
@"menuitem" : NSAccessibilityMenuItemRole,
|
|
110
|
+
@"menuitemcheckbox" : NSAccessibilityMenuItemRole,
|
|
111
|
+
@"menuitemradio" : NSAccessibilityMenuItemRole,
|
|
112
|
+
@"meter" : NSAccessibilityLevelIndicatorRole,
|
|
113
|
+
@"navigation" : NSAccessibilityGroupRole,
|
|
114
|
+
@"none" : NSAccessibilityGroupRole,
|
|
115
|
+
@"note" : NSAccessibilityGroupRole,
|
|
116
|
+
@"option" : NSAccessibilityStaticTextRole,
|
|
117
|
+
@"presentation" : NSAccessibilityGroupRole,
|
|
118
|
+
@"progressbar" : NSAccessibilityProgressIndicatorRole,
|
|
119
|
+
@"radio" : NSAccessibilityRadioButtonRole,
|
|
120
|
+
@"radiogroup" : NSAccessibilityRadioGroupRole,
|
|
121
|
+
@"region" : NSAccessibilityGroupRole,
|
|
122
|
+
@"row" : NSAccessibilityRowRole,
|
|
123
|
+
@"rowheader" : NSAccessibilityCellRole,
|
|
124
|
+
@"scrollbar" : NSAccessibilityScrollBarRole,
|
|
125
|
+
@"search" : NSAccessibilityGroupRole,
|
|
126
|
+
@"searchbox" : NSAccessibilityTextFieldRole,
|
|
127
|
+
@"separator" : NSAccessibilitySplitterRole,
|
|
128
|
+
@"slider" : NSAccessibilitySliderRole,
|
|
129
|
+
@"spinbutton" : NSAccessibilityIncrementorRole,
|
|
130
|
+
@"status" : NSAccessibilityGroupRole,
|
|
131
|
+
@"switch" : NSAccessibilityCheckBoxRole,
|
|
132
|
+
@"tab" : NSAccessibilityRadioButtonRole,
|
|
133
|
+
@"table" : NSAccessibilityTableRole,
|
|
134
|
+
@"tablist" : NSAccessibilityTabGroupRole,
|
|
135
|
+
@"tabpanel" : NSAccessibilityGroupRole,
|
|
136
|
+
@"term" : NSAccessibilityGroupRole,
|
|
137
|
+
@"textbox" : NSAccessibilityTextFieldRole,
|
|
138
|
+
@"timer" : NSAccessibilityGroupRole,
|
|
139
|
+
@"toolbar" : NSAccessibilityToolbarRole,
|
|
140
|
+
@"tooltip" : NSAccessibilityGroupRole,
|
|
141
|
+
@"tree" : NSAccessibilityOutlineRole,
|
|
142
|
+
@"treegrid" : NSAccessibilityTableRole,
|
|
143
|
+
@"treeitem" : NSAccessibilityRowRole,
|
|
144
|
+
};
|
|
145
|
+
traitOrRoleToAccessibilityRole = @{
|
|
146
|
+
@"adjustable" : NSAccessibilitySliderRole,
|
|
147
|
+
@"alert" : NSAccessibilityStaticTextRole,
|
|
148
|
+
@"button" : NSAccessibilityButtonRole,
|
|
149
|
+
@"checkbox" : NSAccessibilityCheckBoxRole,
|
|
150
|
+
@"combobox" : NSAccessibilityComboBoxRole,
|
|
151
|
+
@"header" : NSAccessibilityStaticTextRole,
|
|
152
|
+
@"image" : NSAccessibilityImageRole,
|
|
153
|
+
@"imagebutton" : NSAccessibilityButtonRole,
|
|
154
|
+
@"keyboardkey" : NSAccessibilityButtonRole,
|
|
155
|
+
@"link" : NSAccessibilityLinkRole,
|
|
156
|
+
@"menu" : NSAccessibilityMenuRole,
|
|
157
|
+
@"menubar" : NSAccessibilityMenuBarRole,
|
|
158
|
+
@"menuitem" : NSAccessibilityMenuItemRole,
|
|
159
|
+
@"none" : NSAccessibilityUnknownRole,
|
|
160
|
+
@"progressbar" : NSAccessibilityProgressIndicatorRole,
|
|
161
|
+
@"radio" : NSAccessibilityRadioButtonRole,
|
|
162
|
+
@"radiogroup" : NSAccessibilityRadioGroupRole,
|
|
163
|
+
@"scrollbar" : NSAccessibilityScrollBarRole,
|
|
164
|
+
@"search" : NSAccessibilityTextFieldRole,
|
|
165
|
+
@"spinbutton" : NSAccessibilityIncrementorRole,
|
|
166
|
+
@"summary" : NSAccessibilityStaticTextRole,
|
|
167
|
+
@"switch" : NSAccessibilityCheckBoxRole,
|
|
168
|
+
@"tab" : NSAccessibilityButtonRole,
|
|
169
|
+
@"tablist" : NSAccessibilityTabGroupRole,
|
|
170
|
+
@"text" : NSAccessibilityStaticTextRole,
|
|
171
|
+
@"textbox" : NSAccessibilityTextFieldRole,
|
|
172
|
+
@"timer" : NSAccessibilityStaticTextRole,
|
|
173
|
+
@"toolbar" : NSAccessibilityToolbarRole,
|
|
174
|
+
@"disclosure" : NSAccessibilityDisclosureTriangleRole,
|
|
175
|
+
@"group" : NSAccessibilityGroupRole,
|
|
176
|
+
@"list" : NSAccessibilityListRole,
|
|
177
|
+
@"popupbutton" : NSAccessibilityPopUpButtonRole,
|
|
178
|
+
@"menubutton" : NSAccessibilityMenuButtonRole,
|
|
179
|
+
@"table" : NSAccessibilityTableRole,
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
NSAccessibilityRole accessibilityRole =
|
|
184
|
+
useAriaMappings ? ariaRoleToNSAccessibilityRole[role] : traitOrRoleToAccessibilityRole[role];
|
|
185
|
+
if (accessibilityRole == nil && useAriaMappings) {
|
|
186
|
+
accessibilityRole = traitOrRoleToAccessibilityRole[role];
|
|
187
|
+
}
|
|
188
|
+
return accessibilityRole ?: NSAccessibilityUnknownRole;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Matches Paper (`-[RCTViewManager updateAccessibilityRole:withDefaultView:]`): `role` takes precedence over
|
|
192
|
+
// `accessibilityRole`, and the element's default role is used when neither is set.
|
|
193
|
+
static NSAccessibilityRole RCTAccessibilityRoleFromViewProps(const ViewProps &props, NSView *element)
|
|
194
|
+
{
|
|
195
|
+
if (props.role != Role::None) {
|
|
196
|
+
return RCTAccessibilityRoleFromString(RCTNSStringFromString(toString(props.role)), YES);
|
|
197
|
+
}
|
|
198
|
+
if (!props.accessibilityRole.empty()) {
|
|
199
|
+
return RCTAccessibilityRoleFromString(RCTNSStringFromString(props.accessibilityRole), NO);
|
|
200
|
+
}
|
|
201
|
+
NSAccessibilityRole traitsRole =
|
|
202
|
+
RCTAccessibilityRoleFromTraits(RCTUIAccessibilityTraitsFromAccessibilityTraits(props.accessibilityTraits));
|
|
203
|
+
if (![traitsRole isEqualToString:NSAccessibilityUnknownRole]) {
|
|
204
|
+
return traitsRole;
|
|
205
|
+
}
|
|
206
|
+
return RCTDefaultAccessibilityRoleForElement(element);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Setting an NSAccessibility state property makes AppKit advertise that attribute, so like Paper
|
|
210
|
+
// (`-[RCTView isAccessibilitySelectorAllowed:]`) only expose a state when JS provides it. `disabled` and `selected` are
|
|
211
|
+
// plain bools in `AccessibilityState`, so they count as provided whenever `accessibilityState` is set.
|
|
212
|
+
static BOOL RCTViewPropsProvideAccessibilityEnabled(const ViewProps &props)
|
|
213
|
+
{
|
|
214
|
+
const auto traits = RCTUIAccessibilityTraitsFromAccessibilityTraits(props.accessibilityTraits);
|
|
215
|
+
return props.accessibilityState.has_value() || (traits & RCTUIAccessibilityTraitNotEnabled) != 0;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
static BOOL RCTViewPropsProvideAccessibilitySelected(const ViewProps &props)
|
|
219
|
+
{
|
|
220
|
+
const auto traits = RCTUIAccessibilityTraitsFromAccessibilityTraits(props.accessibilityTraits);
|
|
221
|
+
return props.accessibilityState.has_value() || (traits & RCTUIAccessibilityTraitSelected) != 0;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
static BOOL RCTViewPropsProvideAccessibilityExpanded(const ViewProps &props)
|
|
225
|
+
{
|
|
226
|
+
return props.accessibilityState.has_value() && props.accessibilityState->expanded.has_value();
|
|
227
|
+
}
|
|
228
|
+
#endif // macOS]
|
|
229
|
+
|
|
47
230
|
@implementation RCTViewComponentView {
|
|
48
231
|
RCTUIColor *_backgroundColor; // [macOS]
|
|
49
232
|
CALayer *_backgroundColorLayer;
|
|
@@ -483,19 +666,45 @@ const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
|
|
|
483
666
|
_accessibilityElements = [NSMutableArray new];
|
|
484
667
|
}
|
|
485
668
|
|
|
669
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
486
670
|
// `accessibilityTraits`
|
|
487
671
|
if (oldViewProps.accessibilityTraits != newViewProps.accessibilityTraits) {
|
|
488
|
-
#if !TARGET_OS_OSX // [macOS]
|
|
489
672
|
self.accessibilityElement.accessibilityTraits =
|
|
490
673
|
RCTUIAccessibilityTraitsFromAccessibilityTraits(newViewProps.accessibilityTraits);
|
|
674
|
+
}
|
|
491
675
|
#else // [macOS
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
676
|
+
// `role`, `accessibilityRole` and `accessibilityTraits`
|
|
677
|
+
// NSAccessibility has no traits, so all three resolve to a single role on the accessibility element.
|
|
678
|
+
// Role props can change without accessibilityTraits changing, so check all three.
|
|
679
|
+
if (oldViewProps.role != newViewProps.role || oldViewProps.accessibilityRole != newViewProps.accessibilityRole ||
|
|
680
|
+
oldViewProps.accessibilityTraits != newViewProps.accessibilityTraits) {
|
|
681
|
+
self.accessibilityElement.accessibilityRole =
|
|
682
|
+
RCTAccessibilityRoleFromViewProps(newViewProps, self.accessibilityElement);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// `accessibilityState`
|
|
686
|
+
// `disabled` and `selected` can also come from the NotEnabled and Selected traits. Only update a state that is, or
|
|
687
|
+
// was, provided so that elements without it do not start advertising it.
|
|
688
|
+
if (oldViewProps.accessibilityState != newViewProps.accessibilityState ||
|
|
689
|
+
oldViewProps.accessibilityTraits != newViewProps.accessibilityTraits) {
|
|
690
|
+
const auto accessibilityState = newViewProps.accessibilityState.value_or(AccessibilityState{});
|
|
691
|
+
const auto traits = RCTUIAccessibilityTraitsFromAccessibilityTraits(newViewProps.accessibilityTraits);
|
|
692
|
+
if (RCTViewPropsProvideAccessibilityEnabled(newViewProps) ||
|
|
693
|
+
RCTViewPropsProvideAccessibilityEnabled(oldViewProps)) {
|
|
694
|
+
self.accessibilityElement.accessibilityEnabled =
|
|
695
|
+
!accessibilityState.disabled && (traits & RCTUIAccessibilityTraitNotEnabled) == 0;
|
|
696
|
+
}
|
|
697
|
+
if (RCTViewPropsProvideAccessibilitySelected(newViewProps) ||
|
|
698
|
+
RCTViewPropsProvideAccessibilitySelected(oldViewProps)) {
|
|
699
|
+
self.accessibilityElement.accessibilitySelected =
|
|
700
|
+
accessibilityState.selected || (traits & RCTUIAccessibilityTraitSelected) != 0;
|
|
701
|
+
}
|
|
702
|
+
if (RCTViewPropsProvideAccessibilityExpanded(newViewProps) ||
|
|
703
|
+
RCTViewPropsProvideAccessibilityExpanded(oldViewProps)) {
|
|
704
|
+
self.accessibilityElement.accessibilityExpanded = accessibilityState.expanded.value_or(false);
|
|
705
|
+
}
|
|
498
706
|
}
|
|
707
|
+
#endif // macOS]
|
|
499
708
|
|
|
500
709
|
#if !TARGET_OS_OSX // [macOS]
|
|
501
710
|
// `accessibilityState`
|
|
@@ -1562,6 +1771,23 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // [macOS]
|
|
|
1562
1771
|
return [super isAccessibilityElement];
|
|
1563
1772
|
}
|
|
1564
1773
|
|
|
1774
|
+
#if TARGET_OS_OSX // [macOS
|
|
1775
|
+
- (BOOL)isAccessibilitySelectorAllowed:(SEL)selector
|
|
1776
|
+
{
|
|
1777
|
+
const auto &props = static_cast<const ViewProps &>(*_props);
|
|
1778
|
+
if (selector == @selector(isAccessibilityEnabled)) {
|
|
1779
|
+
return RCTViewPropsProvideAccessibilityEnabled(props);
|
|
1780
|
+
}
|
|
1781
|
+
if (selector == @selector(isAccessibilitySelected)) {
|
|
1782
|
+
return RCTViewPropsProvideAccessibilitySelected(props);
|
|
1783
|
+
}
|
|
1784
|
+
if (selector == @selector(isAccessibilityExpanded)) {
|
|
1785
|
+
return RCTViewPropsProvideAccessibilityExpanded(props);
|
|
1786
|
+
}
|
|
1787
|
+
return [super isAccessibilitySelectorAllowed:selector];
|
|
1788
|
+
}
|
|
1789
|
+
#endif // macOS]
|
|
1790
|
+
|
|
1565
1791
|
- (NSString *)accessibilityValue
|
|
1566
1792
|
{
|
|
1567
1793
|
const auto &props = static_cast<const ViewProps &>(*_props);
|
|
@@ -1762,7 +1988,9 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // [macOS]
|
|
|
1762
1988
|
|
|
1763
1989
|
- (void)blur
|
|
1764
1990
|
{
|
|
1765
|
-
[[self window]
|
|
1991
|
+
if ([[self window] firstResponder] == self) {
|
|
1992
|
+
[[self window] makeFirstResponder:nil];
|
|
1993
|
+
}
|
|
1766
1994
|
}
|
|
1767
1995
|
|
|
1768
1996
|
- (BOOL)needsPanelToBecomeKey
|
|
@@ -171,6 +171,18 @@ static BOOL sIsAccessibilityUsed = NO;
|
|
|
171
171
|
[self _unhideIfNeeded];
|
|
172
172
|
return [super accessibilityChildren];
|
|
173
173
|
}
|
|
174
|
+
|
|
175
|
+
- (BOOL)acceptsFirstResponder
|
|
176
|
+
{
|
|
177
|
+
[self _unhideIfNeeded];
|
|
178
|
+
return [super acceptsFirstResponder];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
- (id)accessibilityHitTest:(NSPoint)point
|
|
182
|
+
{
|
|
183
|
+
[self _unhideIfNeeded];
|
|
184
|
+
return [super accessibilityHitTest:point];
|
|
185
|
+
}
|
|
174
186
|
#endif // macOS]
|
|
175
187
|
|
|
176
188
|
- (void)prepareForRecycle
|
|
@@ -346,7 +346,12 @@ static void RCTPerformMountInstructions(
|
|
|
346
346
|
RCTUIView<RCTComponentViewProtocol> *componentView = [_componentViewRegistry findComponentViewWithTag:reactTag]; // [macOS]
|
|
347
347
|
#if !TARGET_OS_OSX // [macOS]
|
|
348
348
|
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, componentView);
|
|
349
|
-
#
|
|
349
|
+
#else // [macOS
|
|
350
|
+
if (componentView != nil) {
|
|
351
|
+
[[componentView window] makeFirstResponder:componentView];
|
|
352
|
+
NSAccessibilityPostNotification(componentView, NSAccessibilityFocusedUIElementChangedNotification);
|
|
353
|
+
}
|
|
354
|
+
#endif // macOS]
|
|
350
355
|
}
|
|
351
356
|
}
|
|
352
357
|
|
|
@@ -355,6 +355,10 @@ RCT_CUSTOM_VIEW_PROPERTY(accessibilityState, NSDictionary, RCTView)
|
|
|
355
355
|
NSMutableDictionary<NSString *, id> *newState = [NSMutableDictionary<NSString *, id> new];
|
|
356
356
|
|
|
357
357
|
if (!state) {
|
|
358
|
+
#if TARGET_OS_OSX // [macOS
|
|
359
|
+
// Removing the prop must clear the previous state, e.g. so a TextInput is re-enabled once `disabled` goes away.
|
|
360
|
+
view.reactAccessibilityElement.accessibilityState = nil;
|
|
361
|
+
#endif // macOS]
|
|
358
362
|
return;
|
|
359
363
|
}
|
|
360
364
|
|
|
@@ -99,14 +99,25 @@ Pod::Spec.new do |s|
|
|
|
99
99
|
sss.header_dir = "react/renderer/components/safeareaview"
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
# [macOS The "scrollview" subspec below duplicates source_files already declared in
|
|
103
|
+
# React-Fabric.podspec's "scrollview" subspec (which uses a recursive
|
|
104
|
+
# `react/renderer/components/scrollview/**/*` glob). The overlap causes
|
|
105
|
+
# ScrollViewShadowNode.cpp and friends to be compiled into both the
|
|
106
|
+
# React-Fabric and React-FabricComponents Pods targets, breaking consumers
|
|
107
|
+
# that link both libraries via `-all_load` (duplicate symbols). Comment it
|
|
108
|
+
# out here so scrollview is only built into React-Fabric -- where
|
|
109
|
+
# React-Fabric's mounting/internal/CullingContext.cpp already needs
|
|
110
|
+
# ScrollViewShadowNode anyway.
|
|
111
|
+
#
|
|
112
|
+
# ss.subspec "scrollview" do |sss|
|
|
113
|
+
# sss.source_files = podspec_sources(["react/renderer/components/scrollview/*.{m,mm,cpp,h}",
|
|
114
|
+
# "react/renderer/components/scrollview/platform/cxx/**/*.{m,mm,cpp,h}"],
|
|
115
|
+
# ["react/renderer/components/scrollview/*.h",
|
|
116
|
+
# "react/renderer/components/scrollview/platform/cxx/**/*.h"])
|
|
117
|
+
# sss.exclude_files = "react/renderer/components/scrollview/tests"
|
|
118
|
+
# sss.header_dir = "react/renderer/components/scrollview"
|
|
119
|
+
# end
|
|
120
|
+
# macOS]
|
|
110
121
|
|
|
111
122
|
ss.subspec "text" do |sss|
|
|
112
123
|
sss.source_files = podspec_sources(["react/renderer/components/text/*.{m,mm,cpp,h}",
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
|
|
15
15
|
#define REACT_NATIVE_VERSION_MAJOR 0
|
|
16
16
|
#define REACT_NATIVE_VERSION_MINOR 81
|
|
17
|
-
#define REACT_NATIVE_VERSION_PATCH
|
|
17
|
+
#define REACT_NATIVE_VERSION_PATCH 12
|
|
18
18
|
|
|
19
19
|
namespace facebook::react {
|
|
20
20
|
|
|
21
21
|
constexpr struct {
|
|
22
22
|
int32_t Major = 0;
|
|
23
23
|
int32_t Minor = 81;
|
|
24
|
-
int32_t Patch =
|
|
24
|
+
int32_t Patch = 12;
|
|
25
25
|
std::string_view Prerelease = "";
|
|
26
26
|
} ReactNativeVersion;
|
|
27
27
|
|
|
@@ -136,32 +136,42 @@ ShadowNode::ShadowNode(
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
// [macOS Backport react/react-native@923e7ddcaf4d (#52646).
|
|
139
140
|
std::shared_ptr<ShadowNode> ShadowNode::clone(
|
|
140
141
|
const ShadowNodeFragment& fragment) const {
|
|
141
142
|
const auto& family = *family_;
|
|
142
143
|
const auto& componentDescriptor = family.componentDescriptor_;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
.state = fragment.state});
|
|
155
|
-
return clonedNode;
|
|
156
|
-
} else {
|
|
157
|
-
// TODO: We might need to merge fragment.priops with
|
|
158
|
-
// `family.nativeProps_DEPRECATED`.
|
|
159
|
-
return componentDescriptor.cloneShadowNode(*this, fragment);
|
|
144
|
+
|
|
145
|
+
std::optional<RawProps> propsOverride;
|
|
146
|
+
{
|
|
147
|
+
std::lock_guard<std::mutex> lock(family.nativePropsMutex);
|
|
148
|
+
if (family.nativeProps_DEPRECATED != nullptr) {
|
|
149
|
+
if (fragment.props == ShadowNodeFragment::propsPlaceholder()) {
|
|
150
|
+
propsOverride.emplace(*family.nativeProps_DEPRECATED);
|
|
151
|
+
} else {
|
|
152
|
+
// TODO: We might need to merge fragment.props with
|
|
153
|
+
// `family.nativeProps_DEPRECATED`.
|
|
154
|
+
}
|
|
160
155
|
}
|
|
161
|
-
} else {
|
|
162
|
-
return componentDescriptor.cloneShadowNode(*this, fragment);
|
|
163
156
|
}
|
|
157
|
+
|
|
158
|
+
if (propsOverride) {
|
|
159
|
+
// Clone existing `props_` with `family.nativeProps_DEPRECATED` to
|
|
160
|
+
// apply previously set props via `setNativeProps` API. The parsed
|
|
161
|
+
// result escapes the lock so the rest of the clone work runs
|
|
162
|
+
// unblocked.
|
|
163
|
+
auto propsParserContext = PropsParserContext{family_->getSurfaceId(), {}};
|
|
164
|
+
return componentDescriptor.cloneShadowNode(
|
|
165
|
+
*this,
|
|
166
|
+
{.props = componentDescriptor.cloneProps(
|
|
167
|
+
propsParserContext, props_, std::move(*propsOverride)),
|
|
168
|
+
.children = fragment.children,
|
|
169
|
+
.state = fragment.state});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return componentDescriptor.cloneShadowNode(*this, fragment);
|
|
164
173
|
}
|
|
174
|
+
// macOS]
|
|
165
175
|
|
|
166
176
|
ContextContainer::Shared ShadowNode::getContextContainer() const {
|
|
167
177
|
return family_->componentDescriptor_.getContextContainer();
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
#include <memory>
|
|
11
|
+
#include <mutex> // [macOS] Backport upstream #52646.
|
|
11
12
|
#include <shared_mutex>
|
|
12
13
|
|
|
13
14
|
#include <react/renderer/core/EventEmitter.h>
|
|
@@ -116,6 +117,7 @@ class ShadowNodeFamily final : public jsi::NativeState {
|
|
|
116
117
|
* architecture and will be removed in the future.
|
|
117
118
|
*/
|
|
118
119
|
mutable std::unique_ptr<folly::dynamic> nativeProps_DEPRECATED;
|
|
120
|
+
mutable std::mutex nativePropsMutex; // [macOS] Backport upstream #52646.
|
|
119
121
|
|
|
120
122
|
/**
|
|
121
123
|
* @return tag for the ShadowNodeFamily.
|
|
@@ -103,6 +103,7 @@ std::shared_ptr<ShadowNode> UIManager::createNode(
|
|
|
103
103
|
return shadowNode;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
// [macOS Backport react/react-native@923e7ddcaf4d (#52646).
|
|
106
107
|
std::shared_ptr<ShadowNode> UIManager::cloneNode(
|
|
107
108
|
const ShadowNode& shadowNode,
|
|
108
109
|
const ShadowNode::SharedListOfShared& children,
|
|
@@ -115,49 +116,51 @@ std::shared_ptr<ShadowNode> UIManager::cloneNode(
|
|
|
115
116
|
|
|
116
117
|
auto& componentDescriptor = shadowNode.getComponentDescriptor();
|
|
117
118
|
auto& family = shadowNode.getFamily();
|
|
118
|
-
auto props = ShadowNodeFragment::propsPlaceholder();
|
|
119
119
|
|
|
120
|
+
auto props = ShadowNodeFragment::propsPlaceholder();
|
|
120
121
|
if (!rawProps.isEmpty()) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
} else {
|
|
158
|
-
props = componentDescriptor.cloneProps(
|
|
159
|
-
propsParserContext, shadowNode.getProps(), std::move(rawProps));
|
|
122
|
+
std::optional<folly::dynamic> finalProps;
|
|
123
|
+
{
|
|
124
|
+
std::lock_guard<std::mutex> lock(family.nativePropsMutex);
|
|
125
|
+
if (family.nativeProps_DEPRECATED != nullptr) {
|
|
126
|
+
// 1. update the nativeProps_DEPRECATED props.
|
|
127
|
+
//
|
|
128
|
+
// In this step, we want the most recent value for the props
|
|
129
|
+
// managed by setNativeProps.
|
|
130
|
+
// Values in `rawProps` patch (take precedence over)
|
|
131
|
+
// `nativeProps_DEPRECATED`. For example, if both
|
|
132
|
+
// `nativeProps_DEPRECATED` and `rawProps` contain key 'A'.
|
|
133
|
+
// Value from `rawProps` overrides what was previously in
|
|
134
|
+
// `nativeProps_DEPRECATED`. Notice that the `nativeProps_DEPRECATED`
|
|
135
|
+
// patch will not get more props from `rawProps`: if the key is not
|
|
136
|
+
// present in `nativeProps_DEPRECATED`, it will not be added.
|
|
137
|
+
//
|
|
138
|
+
// The result of this operation is the new `nativeProps_DEPRECATED`.
|
|
139
|
+
family.nativeProps_DEPRECATED =
|
|
140
|
+
std::make_unique<folly::dynamic>(mergeDynamicProps(
|
|
141
|
+
*family.nativeProps_DEPRECATED, // source
|
|
142
|
+
(folly::dynamic)rawProps, // patch
|
|
143
|
+
NullValueStrategy::Ignore));
|
|
144
|
+
|
|
145
|
+
// 2. Compute the final set of props.
|
|
146
|
+
//
|
|
147
|
+
// This step takes the new props handled by `setNativeProps` and
|
|
148
|
+
// merges them in the `rawProps` managed by React.
|
|
149
|
+
// The new props handled by `nativeProps` now takes precedence
|
|
150
|
+
// on the props handled by React, as we want to make sure that
|
|
151
|
+
// all the props are applied to the component.
|
|
152
|
+
// We use these finalProps as source of truth for the component.
|
|
153
|
+
finalProps = mergeDynamicProps(
|
|
154
|
+
(folly::dynamic)rawProps, // source
|
|
155
|
+
*family.nativeProps_DEPRECATED, // patch
|
|
156
|
+
NullValueStrategy::Override);
|
|
157
|
+
}
|
|
160
158
|
}
|
|
159
|
+
|
|
160
|
+
props = componentDescriptor.cloneProps(
|
|
161
|
+
propsParserContext,
|
|
162
|
+
shadowNode.getProps(),
|
|
163
|
+
finalProps ? RawProps(std::move(*finalProps)) : std::move(rawProps));
|
|
161
164
|
}
|
|
162
165
|
|
|
163
166
|
auto clonedShadowNode = componentDescriptor.cloneShadowNode(
|
|
@@ -170,6 +173,7 @@ std::shared_ptr<ShadowNode> UIManager::cloneNode(
|
|
|
170
173
|
|
|
171
174
|
return clonedShadowNode;
|
|
172
175
|
}
|
|
176
|
+
// macOS]
|
|
173
177
|
|
|
174
178
|
void UIManager::appendChild(
|
|
175
179
|
const std::shared_ptr<const ShadowNode>& parentShadowNode,
|
|
@@ -426,20 +430,25 @@ void UIManager::setNativeProps_DEPRECATED(
|
|
|
426
430
|
const std::shared_ptr<const ShadowNode>& shadowNode,
|
|
427
431
|
RawProps rawProps) const {
|
|
428
432
|
auto& family = shadowNode->getFamily();
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
433
|
+
// [macOS Backport react/react-native@923e7ddcaf4d (#52646).
|
|
434
|
+
{
|
|
435
|
+
std::lock_guard<std::mutex> lock(family.nativePropsMutex);
|
|
436
|
+
if (family.nativeProps_DEPRECATED) {
|
|
437
|
+
// Values in `rawProps` patch (take precedence over)
|
|
438
|
+
// `nativeProps_DEPRECATED`. For example, if both `nativeProps_DEPRECATED`
|
|
439
|
+
// and `rawProps` contain key 'A'. Value from `rawProps` overrides what
|
|
440
|
+
// was previously in `nativeProps_DEPRECATED`.
|
|
441
|
+
family.nativeProps_DEPRECATED =
|
|
442
|
+
std::make_unique<folly::dynamic>(mergeDynamicProps(
|
|
443
|
+
*family.nativeProps_DEPRECATED,
|
|
444
|
+
(folly::dynamic)rawProps,
|
|
445
|
+
NullValueStrategy::Override));
|
|
446
|
+
} else {
|
|
447
|
+
family.nativeProps_DEPRECATED =
|
|
448
|
+
std::make_unique<folly::dynamic>((folly::dynamic)rawProps);
|
|
449
|
+
}
|
|
442
450
|
}
|
|
451
|
+
// macOS]
|
|
443
452
|
|
|
444
453
|
shadowTreeRegistry_.visit(
|
|
445
454
|
family.getSurfaceId(), [&](const ShadowTree& shadowTree) {
|