react-native-macos 0.81.5 → 0.81.7
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/Libraries/Components/Pressable/Pressable.js +8 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +16 -0
- package/Libraries/Components/TextInput/TextInput.js +26 -9
- package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
- package/Libraries/Components/View/View.js +30 -10
- package/Libraries/Components/View/ViewPropTypes.js +2 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +8 -0
- package/Libraries/Pressability/Pressability.js +38 -4
- package/Libraries/Text/RCTTextAttributes.mm +1 -1
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +1 -1
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm +1 -1
- package/Libraries/Text/TextInput/RCTBaseTextInputView.mm +6 -3
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.h +0 -4
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.mm +3 -20
- package/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.h +5 -3
- package/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.mm +83 -0
- package/Libraries/Utilities/normalizeLegacyHandledKeyEvents.js +164 -0
- package/React/Base/RCTVersion.m +1 -1
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +31 -1
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +38 -2
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +61 -2
- package/React/Fabric/RCTSurfacePointerHandler.mm +6 -2
- package/React/Views/RCTView.h +1 -0
- package/React/Views/RCTViewManager.m +1 -0
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
- package/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp +1 -1
- package/ReactCommon/react/renderer/components/switch/iosswitch/react/renderer/components/switch/IOSSwitchShadowNode.mm +5 -0
- package/ReactCommon/react/renderer/components/switch/iosswitch/react/renderer/components/switch/MacOSSwitchShadowNode.mm +5 -0
- package/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp +4 -0
- package/ReactCommon/react/renderer/components/view/TouchEventEmitter.h +1 -0
- package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewEventEmitter.cpp +16 -0
- package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewEventEmitter.h +2 -0
- package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewEvents.h +6 -0
- package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewProps.cpp +2 -0
- package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/MouseEvent.h +8 -0
- package/ReactCommon/react/renderer/components/view/primitives.h +2 -0
- package/ReactCommon/react/renderer/components/view/propsConversions.h +4 -0
- package/ReactCommon/react/renderer/graphics/Color.h +1 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h +2 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm +11 -0
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm +13 -2
- package/package.json +26 -5
- package/react-native.config.js +0 -5
- package/sdks/hermes-engine/utils/build-apple-framework.sh +2 -1
- package/sdks/hermes-engine/utils/build-ios-framework.sh +8 -3
- package/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.m +0 -14
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// [macOS]
|
|
12
|
+
// Legacy validKeysDown/validKeysUp/passthroughAllKeyEvents compat layer.
|
|
13
|
+
// When removing legacy support, delete this file and its call sites.
|
|
14
|
+
|
|
15
|
+
import type {HandledKeyEvent, KeyEvent} from '../Types/CoreEventTypes';
|
|
16
|
+
|
|
17
|
+
type LegacyHandledKeyEvent = string | HandledKeyEvent;
|
|
18
|
+
|
|
19
|
+
function expandKey(entry: LegacyHandledKeyEvent): Array<HandledKeyEvent> {
|
|
20
|
+
if (typeof entry !== 'string') {
|
|
21
|
+
return [entry];
|
|
22
|
+
}
|
|
23
|
+
const out: Array<HandledKeyEvent> = [];
|
|
24
|
+
const bools: Array<boolean> = [false, true];
|
|
25
|
+
for (const metaKey of bools) {
|
|
26
|
+
for (const ctrlKey of bools) {
|
|
27
|
+
for (const altKey of bools) {
|
|
28
|
+
for (const shiftKey of bools) {
|
|
29
|
+
out.push({altKey, ctrlKey, key: entry, metaKey, shiftKey});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function normalize(
|
|
38
|
+
legacy: ?$ReadOnlyArray<LegacyHandledKeyEvent>,
|
|
39
|
+
): void | Array<HandledKeyEvent> {
|
|
40
|
+
if (legacy == null) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const result: Array<HandledKeyEvent> = [];
|
|
44
|
+
for (const entry of legacy) {
|
|
45
|
+
result.push(...expandKey(entry));
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function matchesEvent(
|
|
51
|
+
events: $ReadOnlyArray<HandledKeyEvent>,
|
|
52
|
+
event: KeyEvent,
|
|
53
|
+
): boolean {
|
|
54
|
+
return events.some(
|
|
55
|
+
({key, metaKey, ctrlKey, altKey, shiftKey}: HandledKeyEvent) =>
|
|
56
|
+
event.nativeEvent.key === key &&
|
|
57
|
+
Boolean(metaKey) === event.nativeEvent.metaKey &&
|
|
58
|
+
Boolean(ctrlKey) === event.nativeEvent.ctrlKey &&
|
|
59
|
+
Boolean(altKey) === event.nativeEvent.altKey &&
|
|
60
|
+
Boolean(shiftKey) === event.nativeEvent.shiftKey,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type LegacyKeyResult = {
|
|
65
|
+
keyDownEvents: void | Array<HandledKeyEvent>,
|
|
66
|
+
keyUpEvents: void | Array<HandledKeyEvent>,
|
|
67
|
+
onKeyDown: void | ((event: KeyEvent) => void),
|
|
68
|
+
onKeyUp: void | ((event: KeyEvent) => void),
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Returns true if the props contain legacy key props that need processing.
|
|
73
|
+
*/
|
|
74
|
+
export function hasLegacyKeyProps(props: mixed): boolean {
|
|
75
|
+
// $FlowFixMe[unclear-type]
|
|
76
|
+
const p = (props: any);
|
|
77
|
+
return (
|
|
78
|
+
p.validKeysDown != null ||
|
|
79
|
+
p.validKeysUp != null ||
|
|
80
|
+
p.passthroughAllKeyEvents != null
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Strips legacy props from a props object (mutates).
|
|
86
|
+
*/
|
|
87
|
+
export function stripLegacyKeyProps(props: {+[string]: mixed}): void {
|
|
88
|
+
// $FlowFixMe[unclear-type]
|
|
89
|
+
const p = (props: any);
|
|
90
|
+
delete p.validKeysDown;
|
|
91
|
+
delete p.validKeysUp;
|
|
92
|
+
delete p.passthroughAllKeyEvents;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Processes legacy validKeysDown/validKeysUp/passthroughAllKeyEvents props
|
|
97
|
+
* and returns the equivalent modern keyDownEvents/keyUpEvents and wrapped
|
|
98
|
+
* onKeyDown/onKeyUp handlers.
|
|
99
|
+
*
|
|
100
|
+
* Usage in component:
|
|
101
|
+
* if (hasLegacyKeyProps(props)) {
|
|
102
|
+
* const legacy = processLegacyKeyProps(props);
|
|
103
|
+
* // use legacy.keyDownEvents, legacy.onKeyDown, etc.
|
|
104
|
+
* }
|
|
105
|
+
*/
|
|
106
|
+
export default function processLegacyKeyProps(
|
|
107
|
+
// $FlowFixMe[unclear-type]
|
|
108
|
+
props: any,
|
|
109
|
+
): LegacyKeyResult {
|
|
110
|
+
const validKeysDown: ?$ReadOnlyArray<LegacyHandledKeyEvent> =
|
|
111
|
+
props.validKeysDown;
|
|
112
|
+
const validKeysUp: ?$ReadOnlyArray<LegacyHandledKeyEvent> = props.validKeysUp;
|
|
113
|
+
const passthroughAllKeyEvents: ?boolean = props.passthroughAllKeyEvents;
|
|
114
|
+
|
|
115
|
+
const hasModernKeyDown = props.keyDownEvents != null;
|
|
116
|
+
const hasModernKeyUp = props.keyUpEvents != null;
|
|
117
|
+
const legacyPassthrough =
|
|
118
|
+
passthroughAllKeyEvents === true && !hasModernKeyDown;
|
|
119
|
+
|
|
120
|
+
const gateKeyDown =
|
|
121
|
+
!hasModernKeyDown && validKeysDown != null && !legacyPassthrough;
|
|
122
|
+
const gateKeyUp =
|
|
123
|
+
!hasModernKeyUp && validKeysUp != null && !legacyPassthrough;
|
|
124
|
+
|
|
125
|
+
const normalizedDown = props.keyDownEvents ?? normalize(validKeysDown);
|
|
126
|
+
const normalizedUp = props.keyUpEvents ?? normalize(validKeysUp);
|
|
127
|
+
|
|
128
|
+
const keyDownEvents = legacyPassthrough ? undefined : normalizedDown;
|
|
129
|
+
const keyUpEvents = legacyPassthrough ? undefined : normalizedUp;
|
|
130
|
+
|
|
131
|
+
const onKeyDown =
|
|
132
|
+
props.onKeyDown != null
|
|
133
|
+
? (event: KeyEvent) => {
|
|
134
|
+
let isHandled = false;
|
|
135
|
+
if (normalizedDown != null && !event.isPropagationStopped()) {
|
|
136
|
+
isHandled = matchesEvent(normalizedDown, event);
|
|
137
|
+
if (isHandled && hasModernKeyDown) {
|
|
138
|
+
event.stopPropagation();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (!gateKeyDown || isHandled) {
|
|
142
|
+
props.onKeyDown?.(event);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
: undefined;
|
|
146
|
+
|
|
147
|
+
const onKeyUp =
|
|
148
|
+
props.onKeyUp != null
|
|
149
|
+
? (event: KeyEvent) => {
|
|
150
|
+
let isHandled = false;
|
|
151
|
+
if (normalizedUp != null && !event.isPropagationStopped()) {
|
|
152
|
+
isHandled = matchesEvent(normalizedUp, event);
|
|
153
|
+
if (isHandled && hasModernKeyUp) {
|
|
154
|
+
event.stopPropagation();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!gateKeyUp || isHandled) {
|
|
158
|
+
props.onKeyUp?.(event);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
: undefined;
|
|
162
|
+
|
|
163
|
+
return {keyDownEvents, keyUpEvents, onKeyDown, onKeyUp};
|
|
164
|
+
}
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -157,7 +157,9 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(RCTUIScrollView *scrollView, NS
|
|
|
157
157
|
#if !TARGET_OS_OSX // [macOS]
|
|
158
158
|
[_scrollView addSubview:_containerView];
|
|
159
159
|
#else // [macOS
|
|
160
|
-
|
|
160
|
+
// Force overlay scrollbar style to avoid layout issues with legacy scrollbars.
|
|
161
|
+
_scrollView.scrollerStyle = NSScrollerStyleOverlay;
|
|
162
|
+
// Don't set autoresizingMask — AppKit corrupts the documentView frame during tile/resize.
|
|
161
163
|
[_scrollView setDocumentView:_containerView];
|
|
162
164
|
#endif // macOS]
|
|
163
165
|
|
|
@@ -184,6 +186,15 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(RCTUIScrollView *scrollView, NS
|
|
|
184
186
|
#endif // [macOS]
|
|
185
187
|
}
|
|
186
188
|
|
|
189
|
+
#if TARGET_OS_OSX // [macOS
|
|
190
|
+
- (void)_preferredScrollerStyleDidChange:(NSNotification *)notification
|
|
191
|
+
{
|
|
192
|
+
// Re-force overlay style when system preference changes.
|
|
193
|
+
_scrollView.scrollerStyle = NSScrollerStyleOverlay;
|
|
194
|
+
[_scrollView tile];
|
|
195
|
+
}
|
|
196
|
+
#endif // macOS]
|
|
197
|
+
|
|
187
198
|
#if TARGET_OS_IOS
|
|
188
199
|
- (void)_registerKeyboardListener
|
|
189
200
|
{
|
|
@@ -561,6 +572,18 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
|
|
|
561
572
|
return nil;
|
|
562
573
|
}
|
|
563
574
|
|
|
575
|
+
#if TARGET_OS_OSX // [macOS
|
|
576
|
+
// Check scrollbars before content subviews — scrollers are NSScrollView children,
|
|
577
|
+
// not documentView children, so full-width content would swallow their clicks.
|
|
578
|
+
if (isPointInside) {
|
|
579
|
+
NSPoint scrollViewPoint = [_scrollView convertPoint:point fromView:self];
|
|
580
|
+
NSView *scrollViewHit = [_scrollView hitTest:scrollViewPoint];
|
|
581
|
+
if ([scrollViewHit isKindOfClass:[NSScroller class]]) {
|
|
582
|
+
return (RCTPlatformView *)scrollViewHit;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
#endif // macOS]
|
|
586
|
+
|
|
564
587
|
for (RCTPlatformView *subview in [_containerView.subviews reverseObjectEnumerator]) { // [macOS]
|
|
565
588
|
RCTPlatformView *hitView = RCTUIViewHitTestWithEvent(subview, point, self, event); // [macOS]
|
|
566
589
|
if (hitView) {
|
|
@@ -865,12 +888,19 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
|
|
|
865
888
|
[defaultCenter removeObserver:self
|
|
866
889
|
name:NSViewBoundsDidChangeNotification
|
|
867
890
|
object:_scrollView.contentView];
|
|
891
|
+
[defaultCenter removeObserver:self
|
|
892
|
+
name:NSPreferredScrollerStyleDidChangeNotification
|
|
893
|
+
object:nil];
|
|
868
894
|
} else {
|
|
869
895
|
// Register for scrollview's clipview bounds change notifications so we can track scrolling
|
|
870
896
|
[defaultCenter addObserver:self
|
|
871
897
|
selector:@selector(scrollViewDocumentViewBoundsDidChange:)
|
|
872
898
|
name:NSViewBoundsDidChangeNotification
|
|
873
899
|
object:_scrollView.contentView]; // NSClipView
|
|
900
|
+
[defaultCenter addObserver:self
|
|
901
|
+
selector:@selector(_preferredScrollerStyleDidChange:)
|
|
902
|
+
name:NSPreferredScrollerStyleDidChangeNotification
|
|
903
|
+
object:nil];
|
|
874
904
|
}
|
|
875
905
|
#endif // macOS]
|
|
876
906
|
|
|
@@ -170,6 +170,30 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
170
170
|
[self _restoreTextSelection];
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
// [macOS
|
|
174
|
+
- (void)_updateDefaultTextAttributes
|
|
175
|
+
{
|
|
176
|
+
const auto &props = static_cast<const TextInputProps &>(*_props);
|
|
177
|
+
NSMutableDictionary<NSAttributedStringKey, id> *attrs =
|
|
178
|
+
RCTNSTextAttributesFromTextAttributes(props.getEffectiveTextAttributes(RCTFontSizeMultiplier()));
|
|
179
|
+
|
|
180
|
+
_backedTextInputView.defaultTextAttributes = attrs;
|
|
181
|
+
|
|
182
|
+
// Also update the existing attributed text so the visible text re-renders
|
|
183
|
+
// with the new color (defaultTextAttributes only affects newly typed text).
|
|
184
|
+
// Wrap in _comingFromJS to prevent textInputDidChange from pushing a state
|
|
185
|
+
// update back to the shadow tree, which would overwrite our fresh colors
|
|
186
|
+
// with the stale cached attributed string.
|
|
187
|
+
NSString *currentText = _backedTextInputView.attributedText.string;
|
|
188
|
+
if (currentText.length > 0) {
|
|
189
|
+
NSAttributedString *updated = [[NSAttributedString alloc] initWithString:currentText attributes:attrs];
|
|
190
|
+
_comingFromJS = YES;
|
|
191
|
+
_backedTextInputView.attributedText = updated;
|
|
192
|
+
_comingFromJS = NO;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// macOS]
|
|
196
|
+
|
|
173
197
|
#if !TARGET_OS_OSX // [macOS]
|
|
174
198
|
// TODO: replace with registerForTraitChanges once iOS 17.0 is the lowest supported version
|
|
175
199
|
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
|
|
@@ -183,8 +207,20 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
183
207
|
_backedTextInputView.defaultTextAttributes =
|
|
184
208
|
RCTNSTextAttributesFromTextAttributes(newTextInputProps.getEffectiveTextAttributes(RCTFontSizeMultiplier()));
|
|
185
209
|
}
|
|
210
|
+
|
|
211
|
+
// [macOS
|
|
212
|
+
if ([self.traitCollection hasDifferentColorAppearanceComparedToTraitCollection:previousTraitCollection]) {
|
|
213
|
+
[self _updateDefaultTextAttributes];
|
|
214
|
+
}
|
|
215
|
+
// macOS]
|
|
216
|
+
}
|
|
217
|
+
#else // [macOS
|
|
218
|
+
- (void)viewDidChangeEffectiveAppearance
|
|
219
|
+
{
|
|
220
|
+
[super viewDidChangeEffectiveAppearance];
|
|
221
|
+
[self _updateDefaultTextAttributes];
|
|
186
222
|
}
|
|
187
|
-
#endif //
|
|
223
|
+
#endif // macOS]
|
|
188
224
|
|
|
189
225
|
- (void)reactUpdateResponderOffsetForScrollView:(RCTScrollViewComponentView *)scrollView
|
|
190
226
|
{
|
|
@@ -1220,7 +1256,7 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
1220
1256
|
// There are multiple Korean input sources (2-Set, 3-Set, etc). Check substring instead instead
|
|
1221
1257
|
[[[_backedTextInputView inputContext] selectedKeyboardInputSource] containsString:@"com.apple.inputmethod.Korean"] ||
|
|
1222
1258
|
[_backedTextInputView hasMarkedText] ||
|
|
1223
|
-
[_backedTextInputView isKindOfClass:[
|
|
1259
|
+
[_backedTextInputView isKindOfClass:[RCTUISecureTextField class]] ||
|
|
1224
1260
|
#endif // macOS]
|
|
1225
1261
|
fontHasBeenUpdatedBySystem;
|
|
1226
1262
|
|
|
@@ -2031,10 +2031,12 @@ enum DragEventType {
|
|
|
2031
2031
|
enum MouseEventType {
|
|
2032
2032
|
MouseEnter,
|
|
2033
2033
|
MouseLeave,
|
|
2034
|
+
Click,
|
|
2034
2035
|
DoubleClick,
|
|
2036
|
+
AuxClick,
|
|
2035
2037
|
};
|
|
2036
2038
|
|
|
2037
|
-
- (void)emitMouseEvent:(MouseEventType)eventType
|
|
2039
|
+
- (void)emitMouseEvent:(MouseEventType)eventType button:(int)button
|
|
2038
2040
|
{
|
|
2039
2041
|
if (!_eventEmitter) {
|
|
2040
2042
|
return;
|
|
@@ -2054,6 +2056,7 @@ enum MouseEventType {
|
|
|
2054
2056
|
.ctrlKey = static_cast<bool>(modifierFlags & NSEventModifierFlagControl),
|
|
2055
2057
|
.shiftKey = static_cast<bool>(modifierFlags & NSEventModifierFlagShift),
|
|
2056
2058
|
.metaKey = static_cast<bool>(modifierFlags & NSEventModifierFlagCommand),
|
|
2059
|
+
.button = button,
|
|
2057
2060
|
};
|
|
2058
2061
|
|
|
2059
2062
|
switch (eventType) {
|
|
@@ -2065,12 +2068,25 @@ enum MouseEventType {
|
|
|
2065
2068
|
_eventEmitter->onMouseLeave(mouseEvent);
|
|
2066
2069
|
break;
|
|
2067
2070
|
|
|
2071
|
+
case Click:
|
|
2072
|
+
_eventEmitter->onClick(mouseEvent);
|
|
2073
|
+
break;
|
|
2074
|
+
|
|
2068
2075
|
case DoubleClick:
|
|
2069
2076
|
_eventEmitter->onDoubleClick(mouseEvent);
|
|
2070
2077
|
break;
|
|
2078
|
+
|
|
2079
|
+
case AuxClick:
|
|
2080
|
+
_eventEmitter->onAuxClick(mouseEvent);
|
|
2081
|
+
break;
|
|
2071
2082
|
}
|
|
2072
2083
|
}
|
|
2073
2084
|
|
|
2085
|
+
- (void)emitMouseEvent:(MouseEventType)eventType
|
|
2086
|
+
{
|
|
2087
|
+
[self emitMouseEvent:eventType button:0];
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2074
2090
|
- (void)updateMouseOverIfNeeded
|
|
2075
2091
|
{
|
|
2076
2092
|
// When an enclosing scrollview is scrolled using the scrollWheel or trackpad,
|
|
@@ -2185,12 +2201,55 @@ enum MouseEventType {
|
|
|
2185
2201
|
- (void)mouseUp:(NSEvent *)event
|
|
2186
2202
|
{
|
|
2187
2203
|
BOOL hasDoubleClickEventHandler = _props->hostPlatformEvents[HostPlatformViewEvents::Offset::DoubleClick];
|
|
2204
|
+
BOOL hasClickEventHandler = _props->hostPlatformEvents[HostPlatformViewEvents::Offset::Click];
|
|
2188
2205
|
if (hasDoubleClickEventHandler && event.clickCount == 2) {
|
|
2189
|
-
[self emitMouseEvent
|
|
2206
|
+
[self emitMouseEvent:DoubleClick];
|
|
2207
|
+
} else if (hasClickEventHandler && event.clickCount == 1) {
|
|
2208
|
+
[self emitMouseEvent:Click];
|
|
2190
2209
|
} else {
|
|
2191
2210
|
[super mouseUp:event];
|
|
2192
2211
|
}
|
|
2193
2212
|
}
|
|
2213
|
+
|
|
2214
|
+
- (void)rightMouseDown:(NSEvent *)event
|
|
2215
|
+
{
|
|
2216
|
+
// Accept rightMouseDown to prevent the default NSView behavior of passing it
|
|
2217
|
+
// up the responder chain (which can trigger a context menu modal loop that
|
|
2218
|
+
// consumes rightMouseUp).
|
|
2219
|
+
BOOL hasAuxClickEventHandler = _props->hostPlatformEvents[HostPlatformViewEvents::Offset::AuxClick];
|
|
2220
|
+
if (!hasAuxClickEventHandler) {
|
|
2221
|
+
[super rightMouseDown:event];
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
- (void)rightMouseUp:(NSEvent *)event
|
|
2226
|
+
{
|
|
2227
|
+
BOOL hasAuxClickEventHandler = _props->hostPlatformEvents[HostPlatformViewEvents::Offset::AuxClick];
|
|
2228
|
+
if (hasAuxClickEventHandler) {
|
|
2229
|
+
[self emitMouseEvent:AuxClick button:2];
|
|
2230
|
+
} else {
|
|
2231
|
+
[super rightMouseUp:event];
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
- (void)otherMouseDown:(NSEvent *)event
|
|
2236
|
+
{
|
|
2237
|
+
// Accept otherMouseDown so that otherMouseUp is delivered to this view.
|
|
2238
|
+
BOOL hasAuxClickEventHandler = _props->hostPlatformEvents[HostPlatformViewEvents::Offset::AuxClick];
|
|
2239
|
+
if (!hasAuxClickEventHandler) {
|
|
2240
|
+
[super otherMouseDown:event];
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
- (void)otherMouseUp:(NSEvent *)event
|
|
2245
|
+
{
|
|
2246
|
+
BOOL hasAuxClickEventHandler = _props->hostPlatformEvents[HostPlatformViewEvents::Offset::AuxClick];
|
|
2247
|
+
if (hasAuxClickEventHandler) {
|
|
2248
|
+
[self emitMouseEvent:AuxClick button:1];
|
|
2249
|
+
} else {
|
|
2250
|
+
[super otherMouseUp:event];
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2194
2253
|
#endif // macOS]
|
|
2195
2254
|
|
|
2196
2255
|
- (SharedTouchEventEmitter)touchEventEmitterAtPoint:(CGPoint)point
|
|
@@ -703,8 +703,12 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithTarget : (id)target action : (SEL)act
|
|
|
703
703
|
}
|
|
704
704
|
case RCTPointerEventTypeEnd: {
|
|
705
705
|
eventEmitter->onPointerUp(pointerEvent);
|
|
706
|
-
if (pointerEvent.isPrimary && pointerEvent.button == 0
|
|
707
|
-
|
|
706
|
+
if (pointerEvent.isPrimary && pointerEvent.button == 0) {
|
|
707
|
+
if (IsPointerWithinInitialTree(activePointer)) {
|
|
708
|
+
eventEmitter->onClick(std::move(pointerEvent));
|
|
709
|
+
}
|
|
710
|
+
} else if (IsPointerWithinInitialTree(activePointer)) {
|
|
711
|
+
eventEmitter->onAuxClick(std::move(pointerEvent));
|
|
708
712
|
}
|
|
709
713
|
break;
|
|
710
714
|
}
|
package/React/Views/RCTView.h
CHANGED
|
@@ -145,6 +145,7 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
|
|
|
145
145
|
/**
|
|
146
146
|
* (Experimental and unused for Paper) Pointer event handlers.
|
|
147
147
|
*/
|
|
148
|
+
@property (nonatomic, assign) RCTBubblingEventBlock onAuxClick;
|
|
148
149
|
@property (nonatomic, assign) RCTBubblingEventBlock onClick;
|
|
149
150
|
@property (nonatomic, assign) RCTBubblingEventBlock onPointerCancel;
|
|
150
151
|
@property (nonatomic, assign) RCTBubblingEventBlock onPointerDown;
|
|
@@ -882,6 +882,7 @@ RCT_CUSTOM_VIEW_PROPERTY(onTouchEnd, BOOL, RCTView) {}
|
|
|
882
882
|
RCT_CUSTOM_VIEW_PROPERTY(onTouchCancel, BOOL, RCTView) {}
|
|
883
883
|
|
|
884
884
|
// Experimental/WIP Pointer Events (not yet ready for use)
|
|
885
|
+
RCT_EXPORT_VIEW_PROPERTY(onAuxClick, RCTBubblingEventBlock)
|
|
885
886
|
RCT_EXPORT_VIEW_PROPERTY(onClick, RCTBubblingEventBlock)
|
|
886
887
|
RCT_EXPORT_VIEW_PROPERTY(onPointerCancel, RCTBubblingEventBlock)
|
|
887
888
|
RCT_EXPORT_VIEW_PROPERTY(onPointerDown, RCTBubblingEventBlock)
|
|
@@ -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 7
|
|
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 = 7;
|
|
25
25
|
std::string_view Prerelease = "";
|
|
26
26
|
} ReactNativeVersion;
|
|
27
27
|
|
|
@@ -178,7 +178,7 @@ TextAttributes TextAttributes::defaultTextAttributes() {
|
|
|
178
178
|
static auto textAttributes = [] {
|
|
179
179
|
auto textAttributes = TextAttributes{};
|
|
180
180
|
// Non-obvious (can be different among platforms) default text attributes.
|
|
181
|
-
textAttributes.foregroundColor =
|
|
181
|
+
textAttributes.foregroundColor = defaultForegroundTextColor(); // [macOS]
|
|
182
182
|
textAttributes.backgroundColor = clearColor();
|
|
183
183
|
textAttributes.fontSize = 14.0;
|
|
184
184
|
textAttributes.fontSizeMultiplier = 1.0;
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
#include <TargetConditionals.h> // [macOS]
|
|
9
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
10
|
+
|
|
8
11
|
#import <React/RCTUtils.h>
|
|
9
12
|
#import <UIKit/UIKit.h>
|
|
10
13
|
#include "AppleSwitchShadowNode.h"
|
|
@@ -26,3 +29,5 @@ Size SwitchShadowNode::measureContent(
|
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
} // namespace facebook::react
|
|
32
|
+
|
|
33
|
+
#endif // !TARGET_OS_OSX [macOS]
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
#include <TargetConditionals.h> // [macOS]
|
|
9
|
+
#if TARGET_OS_OSX // [macOS]
|
|
10
|
+
|
|
8
11
|
#import <AppKit/AppKit.h>
|
|
9
12
|
#include "AppleSwitchShadowNode.h"
|
|
10
13
|
|
|
@@ -30,3 +33,5 @@ Size SwitchShadowNode::measureContent(
|
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
} // namespace facebook::react
|
|
36
|
+
|
|
37
|
+
#endif // TARGET_OS_OSX [macOS]
|
|
@@ -86,6 +86,10 @@ void TouchEventEmitter::onTouchCancel(TouchEvent event) const {
|
|
|
86
86
|
"touchCancel", std::move(event), RawEvent::Category::ContinuousEnd);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
void TouchEventEmitter::onAuxClick(PointerEvent event) const {
|
|
90
|
+
dispatchPointerEvent("auxClick", std::move(event), RawEvent::Category::Discrete);
|
|
91
|
+
}
|
|
92
|
+
|
|
89
93
|
void TouchEventEmitter::onClick(PointerEvent event) const {
|
|
90
94
|
dispatchPointerEvent("click", std::move(event), RawEvent::Category::Discrete);
|
|
91
95
|
}
|
|
@@ -29,6 +29,7 @@ class TouchEventEmitter : public EventEmitter {
|
|
|
29
29
|
void onTouchEnd(TouchEvent event) const;
|
|
30
30
|
void onTouchCancel(TouchEvent event) const;
|
|
31
31
|
|
|
32
|
+
void onAuxClick(PointerEvent event) const;
|
|
32
33
|
void onClick(PointerEvent event) const;
|
|
33
34
|
void onPointerCancel(PointerEvent event) const;
|
|
34
35
|
void onPointerDown(PointerEvent event) const;
|
|
@@ -63,6 +63,10 @@ static jsi::Object mouseEventPayload(jsi::Runtime& runtime, const MouseEvent& ev
|
|
|
63
63
|
payload.setProperty(runtime, "ctrlKey", event.ctrlKey);
|
|
64
64
|
payload.setProperty(runtime, "shiftKey", event.shiftKey);
|
|
65
65
|
payload.setProperty(runtime, "metaKey", event.metaKey);
|
|
66
|
+
payload.setProperty(runtime, "button", event.button);
|
|
67
|
+
// pointerType lets Pressability's onClick guard distinguish native click
|
|
68
|
+
// events from accessibility/responder-based clicks, avoiding double onPress.
|
|
69
|
+
payload.setProperty(runtime, "pointerType", "mouse");
|
|
66
70
|
return payload;
|
|
67
71
|
};
|
|
68
72
|
|
|
@@ -78,12 +82,24 @@ void HostPlatformViewEventEmitter::onMouseLeave(const MouseEvent& mouseEvent) co
|
|
|
78
82
|
});
|
|
79
83
|
}
|
|
80
84
|
|
|
85
|
+
void HostPlatformViewEventEmitter::onClick(const MouseEvent& mouseEvent) const {
|
|
86
|
+
dispatchEvent("click", [mouseEvent](jsi::Runtime& runtime) {
|
|
87
|
+
return mouseEventPayload(runtime, mouseEvent);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
81
91
|
void HostPlatformViewEventEmitter::onDoubleClick(const MouseEvent& mouseEvent) const {
|
|
82
92
|
dispatchEvent("doubleClick", [mouseEvent](jsi::Runtime& runtime) {
|
|
83
93
|
return mouseEventPayload(runtime, mouseEvent);
|
|
84
94
|
});
|
|
85
95
|
}
|
|
86
96
|
|
|
97
|
+
void HostPlatformViewEventEmitter::onAuxClick(const MouseEvent& mouseEvent) const {
|
|
98
|
+
dispatchEvent("auxClick", [mouseEvent](jsi::Runtime& runtime) {
|
|
99
|
+
return mouseEventPayload(runtime, mouseEvent);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
87
103
|
#pragma mark - Drag and Drop Events
|
|
88
104
|
|
|
89
105
|
jsi::Value HostPlatformViewEventEmitter::dataTransferPayload(
|
|
@@ -33,7 +33,9 @@ class HostPlatformViewEventEmitter : public BaseViewEventEmitter {
|
|
|
33
33
|
|
|
34
34
|
void onMouseEnter(MouseEvent const& mouseEvent) const;
|
|
35
35
|
void onMouseLeave(MouseEvent const& mouseEvent) const;
|
|
36
|
+
void onClick(MouseEvent const& mouseEvent) const;
|
|
36
37
|
void onDoubleClick(MouseEvent const& mouseEvent) const;
|
|
38
|
+
void onAuxClick(MouseEvent const& mouseEvent) const;
|
|
37
39
|
|
|
38
40
|
#pragma mark - Drag and Drop Events
|
|
39
41
|
|
|
@@ -30,6 +30,8 @@ struct HostPlatformViewEvents {
|
|
|
30
30
|
MouseEnter = 4,
|
|
31
31
|
MouseLeave = 5,
|
|
32
32
|
DoubleClick = 6,
|
|
33
|
+
AuxClick = 7,
|
|
34
|
+
Click = 8,
|
|
33
35
|
};
|
|
34
36
|
|
|
35
37
|
constexpr bool operator[](const Offset offset) const {
|
|
@@ -74,6 +76,10 @@ static inline HostPlatformViewEvents convertRawProp(
|
|
|
74
76
|
convertRawProp(context, rawProps, "onMouseLeave", sourceValue[Offset::MouseLeave], defaultValue[Offset::MouseLeave]);
|
|
75
77
|
result[Offset::DoubleClick] =
|
|
76
78
|
convertRawProp(context, rawProps, "onDoubleClick", sourceValue[Offset::DoubleClick], defaultValue[Offset::DoubleClick]);
|
|
79
|
+
result[Offset::AuxClick] =
|
|
80
|
+
convertRawProp(context, rawProps, "onAuxClick", sourceValue[Offset::AuxClick], defaultValue[Offset::AuxClick]);
|
|
81
|
+
result[Offset::Click] =
|
|
82
|
+
convertRawProp(context, rawProps, "onClick", sourceValue[Offset::Click], defaultValue[Offset::Click]);
|
|
77
83
|
|
|
78
84
|
return result;
|
|
79
85
|
}
|
|
@@ -144,6 +144,8 @@ void HostPlatformViewProps::setProp(
|
|
|
144
144
|
VIEW_EVENT_CASE_MACOS(MouseEnter);
|
|
145
145
|
VIEW_EVENT_CASE_MACOS(MouseLeave);
|
|
146
146
|
VIEW_EVENT_CASE_MACOS(DoubleClick);
|
|
147
|
+
VIEW_EVENT_CASE_MACOS(AuxClick);
|
|
148
|
+
VIEW_EVENT_CASE_MACOS(Click);
|
|
147
149
|
RAW_SET_PROP_SWITCH_CASE_BASIC(focusable);
|
|
148
150
|
RAW_SET_PROP_SWITCH_CASE_BASIC(enableFocusRing);
|
|
149
151
|
RAW_SET_PROP_SWITCH_CASE_BASIC(keyDownEvents);
|
|
@@ -54,6 +54,14 @@ struct MouseEvent {
|
|
|
54
54
|
* A flag indicating if the meta key is pressed.
|
|
55
55
|
*/
|
|
56
56
|
bool metaKey{false};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The button number that was pressed when the mouse event was fired:
|
|
60
|
+
* 0 = primary button (usually the left button)
|
|
61
|
+
* 1 = auxiliary button (usually the middle/wheel button)
|
|
62
|
+
* 2 = secondary button (usually the right button)
|
|
63
|
+
*/
|
|
64
|
+
int button{0};
|
|
57
65
|
};
|
|
58
66
|
|
|
59
67
|
struct DataTransferFile {
|
|
@@ -830,6 +830,10 @@ static inline ViewEvents convertRawProp(
|
|
|
830
830
|
"onPointerOutCapture",
|
|
831
831
|
sourceValue[Offset::PointerOutCapture],
|
|
832
832
|
defaultValue[Offset::PointerOutCapture]);
|
|
833
|
+
result[Offset::AuxClick] =
|
|
834
|
+
convertRawProp(context, rawProps, "onAuxClick", sourceValue[Offset::AuxClick], defaultValue[Offset::AuxClick]);
|
|
835
|
+
result[Offset::AuxClickCapture] = convertRawProp(
|
|
836
|
+
context, rawProps, "onAuxClickCapture", sourceValue[Offset::AuxClickCapture], defaultValue[Offset::AuxClickCapture]);
|
|
833
837
|
result[Offset::Click] = convertRawProp(
|
|
834
838
|
context,
|
|
835
839
|
rawProps,
|
|
@@ -70,6 +70,7 @@ SharedColor colorFromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
|
|
70
70
|
SharedColor clearColor();
|
|
71
71
|
SharedColor blackColor();
|
|
72
72
|
SharedColor whiteColor();
|
|
73
|
+
SharedColor defaultForegroundTextColor(); // [macOS]
|
|
73
74
|
|
|
74
75
|
#ifdef RN_SERIALIZABLE_STATE
|
|
75
76
|
inline folly::dynamic toDynamic(const SharedColor& sharedColor) {
|