react-native-macos 0.81.6 → 0.81.8

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 (57) hide show
  1. package/Libraries/Blob/RCTBlobManager.h +0 -0
  2. package/Libraries/Blob/RCTBlobManager.mm +0 -0
  3. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +0 -0
  4. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  5. package/Libraries/Components/View/ViewPropTypes.js +2 -0
  6. package/Libraries/Core/ReactNativeVersion.js +1 -1
  7. package/Libraries/NativeComponent/BaseViewConfig.ios.js +8 -0
  8. package/Libraries/Pressability/Pressability.js +38 -4
  9. package/Libraries/StyleSheet/normalizeColor.js +0 -0
  10. package/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +13 -4
  11. package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm +1 -1
  12. package/Libraries/Text/TextInput/RCTBaseTextInputView.mm +5 -2
  13. package/Libraries/Text/TextInput/Singleline/RCTUITextField.h +0 -4
  14. package/Libraries/Text/TextInput/Singleline/RCTUITextField.mm +3 -20
  15. package/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.h +5 -3
  16. package/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.mm +83 -0
  17. package/React/Base/RCTJavaScriptLoader.h +0 -0
  18. package/React/Base/RCTJavaScriptLoader.mm +0 -0
  19. package/React/Base/RCTVersion.m +1 -1
  20. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +27 -21
  21. package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +192 -4
  22. package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputNativeCommands.h +20 -0
  23. package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +61 -2
  24. package/React/Fabric/RCTSurfacePointerHandler.mm +6 -2
  25. package/React/Views/RCTComponentData.mm +1 -1
  26. package/React/Views/RCTView.h +1 -0
  27. package/React/Views/RCTViewManager.m +1 -0
  28. package/ReactAndroid/gradle.properties +1 -1
  29. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
  30. package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
  31. package/ReactCommon/react/renderer/components/switch/iosswitch/react/renderer/components/switch/IOSSwitchShadowNode.mm +5 -0
  32. package/ReactCommon/react/renderer/components/switch/iosswitch/react/renderer/components/switch/MacOSSwitchShadowNode.mm +5 -0
  33. package/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp +4 -0
  34. package/ReactCommon/react/renderer/components/view/TouchEventEmitter.h +1 -0
  35. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewEventEmitter.cpp +16 -0
  36. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewEventEmitter.h +2 -0
  37. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewEvents.h +6 -0
  38. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewProps.cpp +2 -0
  39. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/MouseEvent.h +8 -0
  40. package/ReactCommon/react/renderer/components/view/primitives.h +2 -0
  41. package/ReactCommon/react/renderer/components/view/propsConversions.h +4 -0
  42. package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h +2 -0
  43. package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm +11 -0
  44. package/gradle/libs.versions.toml +1 -1
  45. package/local-cli/cli.js +0 -0
  46. package/package.json +27 -6
  47. package/react-native.config.js +0 -1
  48. package/scripts/compose-source-maps.js +0 -0
  49. package/scripts/featureflags/index.js +47 -0
  50. package/scripts/find-node-for-xcode.sh +0 -0
  51. package/scripts/ios-prebuild/cli.js +136 -0
  52. package/sdks/hermes-engine/utils/build-apple-framework.sh +2 -1
  53. package/sdks/hermes-engine/utils/build-ios-framework.sh +8 -3
  54. package/sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh +0 -0
  55. package/third-party-podspecs/RCT-Folly.podspec +1 -1
  56. package/third-party-podspecs/fmt.podspec +2 -2
  57. package/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.m +0 -14
@@ -103,6 +103,10 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
103
103
 
104
104
  BOOL _hasInputAccessoryView;
105
105
  CGSize _previousContentSize;
106
+ #if TARGET_OS_OSX // [macOS
107
+ NSString *_ghostText;
108
+ NSInteger _ghostTextPosition;
109
+ #endif // macOS]
106
110
  }
107
111
 
108
112
  #pragma mark - UIView overrides
@@ -170,6 +174,30 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
170
174
  [self _restoreTextSelection];
171
175
  }
172
176
 
177
+ // [macOS
178
+ - (void)_updateDefaultTextAttributes
179
+ {
180
+ const auto &props = static_cast<const TextInputProps &>(*_props);
181
+ NSMutableDictionary<NSAttributedStringKey, id> *attrs =
182
+ RCTNSTextAttributesFromTextAttributes(props.getEffectiveTextAttributes(RCTFontSizeMultiplier()));
183
+
184
+ _backedTextInputView.defaultTextAttributes = attrs;
185
+
186
+ // Also update the existing attributed text so the visible text re-renders
187
+ // with the new color (defaultTextAttributes only affects newly typed text).
188
+ // Wrap in _comingFromJS to prevent textInputDidChange from pushing a state
189
+ // update back to the shadow tree, which would overwrite our fresh colors
190
+ // with the stale cached attributed string.
191
+ NSString *currentText = _backedTextInputView.attributedText.string;
192
+ if (currentText.length > 0) {
193
+ NSAttributedString *updated = [[NSAttributedString alloc] initWithString:currentText attributes:attrs];
194
+ _comingFromJS = YES;
195
+ _backedTextInputView.attributedText = updated;
196
+ _comingFromJS = NO;
197
+ }
198
+ }
199
+ // macOS]
200
+
173
201
  #if !TARGET_OS_OSX // [macOS]
174
202
  // TODO: replace with registerForTraitChanges once iOS 17.0 is the lowest supported version
175
203
  - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
@@ -183,8 +211,20 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
183
211
  _backedTextInputView.defaultTextAttributes =
184
212
  RCTNSTextAttributesFromTextAttributes(newTextInputProps.getEffectiveTextAttributes(RCTFontSizeMultiplier()));
185
213
  }
214
+
215
+ // [macOS
216
+ if ([self.traitCollection hasDifferentColorAppearanceComparedToTraitCollection:previousTraitCollection]) {
217
+ [self _updateDefaultTextAttributes];
218
+ }
219
+ // macOS]
186
220
  }
187
- #endif // [macOS]
221
+ #else // [macOS
222
+ - (void)viewDidChangeEffectiveAppearance
223
+ {
224
+ [super viewDidChangeEffectiveAppearance];
225
+ [self _updateDefaultTextAttributes];
226
+ }
227
+ #endif // macOS]
188
228
 
189
229
  - (void)reactUpdateResponderOffsetForScrollView:(RCTScrollViewComponentView *)scrollView
190
230
  {
@@ -478,6 +518,10 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
478
518
  _lastStringStateWasUpdatedWith = nil;
479
519
  _ignoreNextTextInputCall = NO;
480
520
  _didMoveToWindow = NO;
521
+ #if TARGET_OS_OSX // [macOS
522
+ _ghostText = nil;
523
+ _ghostTextPosition = 0;
524
+ #endif // macOS]
481
525
  [_backedTextInputView resignFirstResponder];
482
526
  }
483
527
 
@@ -502,6 +546,10 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
502
546
 
503
547
  - (void)textInputDidEndEditing
504
548
  {
549
+ #if TARGET_OS_OSX // [macOS
550
+ [self setGhostText:nil];
551
+ #endif // macOS]
552
+
505
553
  if (_eventEmitter) {
506
554
  static_cast<const TextInputEventEmitter &>(*_eventEmitter).onEndEditing([self _textInputMetrics]);
507
555
  static_cast<const TextInputEventEmitter &>(*_eventEmitter).onBlur([self _textInputMetrics]);
@@ -536,6 +584,12 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
536
584
 
537
585
  - (NSString *)textInputShouldChangeText:(NSString *)text inRange:(NSRange)range
538
586
  {
587
+ #if TARGET_OS_OSX // [macOS
588
+ // Clear ghost text before the text change so the undo manager's snapshot
589
+ // of the pre-edit state never contains ghost text.
590
+ [self setGhostText:nil];
591
+ #endif // macOS]
592
+
539
593
  const auto &props = static_cast<const TextInputProps &>(*_props);
540
594
 
541
595
  if (!_backedTextInputView.textWasPasted) {
@@ -581,6 +635,17 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
581
635
  return;
582
636
  }
583
637
 
638
+ #if TARGET_OS_OSX // [macOS
639
+ if (_ghostText != nil) {
640
+ NSAttributedString *attributedStringWithoutGhostText = [self removingGhostTextFromString:_backedTextInputView.attributedText strict:NO];
641
+ if (attributedStringWithoutGhostText != nil && ![attributedStringWithoutGhostText isEqual:_backedTextInputView.attributedText]) {
642
+ _backedTextInputView.attributedText = attributedStringWithoutGhostText;
643
+ }
644
+ _ghostText = nil;
645
+ _ghostTextPosition = 0;
646
+ }
647
+ #endif // macOS]
648
+
584
649
  if (_ignoreNextTextInputCall && [_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
585
650
  _ignoreNextTextInputCall = NO;
586
651
  return;
@@ -596,6 +661,14 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
596
661
 
597
662
  - (void)textInputDidChangeSelection
598
663
  {
664
+ #if TARGET_OS_OSX // [macOS
665
+ // Clear ghost text on any user selection change, matching Paper behavior.
666
+ // This prevents the user from selecting ghost text.
667
+ if (_ghostText != nil && !_comingFromJS && !_backedTextInputView.ghostTextChanging) {
668
+ [self setGhostText:nil];
669
+ }
670
+ #endif // macOS]
671
+
599
672
  if (_comingFromJS) {
600
673
  return;
601
674
  }
@@ -769,6 +842,115 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
769
842
  }
770
843
  }
771
844
 
845
+ #if TARGET_OS_OSX // [macOS
846
+ #pragma mark - Ghost Text
847
+
848
+ - (NSDictionary<NSAttributedStringKey, id> *)ghostTextAttributes
849
+ {
850
+ NSMutableDictionary<NSAttributedStringKey, id> *textAttributes =
851
+ [_backedTextInputView.defaultTextAttributes mutableCopy] ?: [NSMutableDictionary new];
852
+
853
+ [textAttributes setValue:_backedTextInputView.placeholderColor ?: [RCTPlatformColor placeholderTextColor]
854
+ forKey:NSForegroundColorAttributeName];
855
+
856
+ return textAttributes;
857
+ }
858
+
859
+ - (void)setGhostText:(NSString *)ghostText
860
+ {
861
+ NSRange selectedRange = [_backedTextInputView selectedTextRange];
862
+ NSInteger selectionStart = selectedRange.location;
863
+ NSInteger selectionEnd = selectedRange.location + selectedRange.length;
864
+ NSString *newGhostText = ghostText.length > 0 ? ghostText : nil;
865
+
866
+ if (selectionStart != selectionEnd) {
867
+ newGhostText = nil;
868
+ }
869
+
870
+ if ((_ghostText == nil && newGhostText == nil) || [_ghostText isEqual:newGhostText]) {
871
+ return;
872
+ }
873
+
874
+ if (_backedTextInputView.ghostTextChanging) {
875
+ // look out for nested callbacks -- this can happen for example when selection changes in response to
876
+ // attributed text changing. Such callbacks are initiated by Apple, or we could suppress this other ways.
877
+ return;
878
+ }
879
+
880
+ _backedTextInputView.ghostTextChanging = YES;
881
+
882
+ if (_ghostText != nil) {
883
+ // When setGhostText: is called after making a standard edit, the ghost text may already be gone
884
+ BOOL ghostTextMayAlreadyBeGone = newGhostText == nil;
885
+ NSAttributedString *attributedStringWithoutGhostText = [self removingGhostTextFromString:_backedTextInputView.attributedText strict:!ghostTextMayAlreadyBeGone];
886
+
887
+ if (attributedStringWithoutGhostText != nil) {
888
+ _backedTextInputView.attributedText = attributedStringWithoutGhostText;
889
+ [_backedTextInputView setSelectedTextRange:NSMakeRange(selectionStart, selectionEnd - selectionStart) notifyDelegate:NO];
890
+ }
891
+ }
892
+
893
+ _ghostText = [newGhostText copy];
894
+ _ghostTextPosition = selectionStart;
895
+
896
+ if (_ghostText != nil) {
897
+ NSMutableAttributedString *attributedString = [_backedTextInputView.attributedText mutableCopy];
898
+ NSAttributedString *ghostAttributedString = [[NSAttributedString alloc] initWithString:_ghostText
899
+ attributes:self.ghostTextAttributes];
900
+
901
+ [attributedString insertAttributedString:ghostAttributedString atIndex:_ghostTextPosition];
902
+ _backedTextInputView.attributedText = attributedString;
903
+ [_backedTextInputView setSelectedTextRange:NSMakeRange(_ghostTextPosition, 0) notifyDelegate:NO];
904
+ }
905
+
906
+ _backedTextInputView.ghostTextChanging = NO;
907
+ }
908
+
909
+ /**
910
+ * Attempts to remove the ghost text from a provided string given our current state.
911
+ *
912
+ * If `strict` mode is enabled, this method assumes the ghost text exists exactly
913
+ * where we expect it to be. We assert and return `nil` if we don't find the expected ghost text.
914
+ * It's the responsibility of the caller to make sure the result isn't `nil`.
915
+ *
916
+ * If disabled, we allow for the possibility that the ghost text has already been removed,
917
+ * which can happen if a delegate callback is trying to remove ghost text after invoking `setAttributedText:`.
918
+ */
919
+ - (NSAttributedString *)removingGhostTextFromString:(NSAttributedString *)string strict:(BOOL)strict
920
+ {
921
+ if (_ghostText == nil) {
922
+ return string;
923
+ }
924
+
925
+ NSRange ghostTextRange = NSMakeRange(_ghostTextPosition, _ghostText.length);
926
+ NSMutableAttributedString *attributedString = [string mutableCopy];
927
+
928
+ if ([attributedString length] < NSMaxRange(ghostTextRange)) {
929
+ if (strict) {
930
+ RCTAssert(false, @"Ghost text not fully present in text view text");
931
+ return nil;
932
+ } else {
933
+ return string;
934
+ }
935
+ }
936
+
937
+ NSString *actualGhostText = [[attributedString attributedSubstringFromRange:ghostTextRange] string];
938
+
939
+ if (![actualGhostText isEqual:_ghostText]) {
940
+ if (strict) {
941
+ RCTAssert(false, @"Ghost text does not match text view text");
942
+ return nil;
943
+ } else {
944
+ return string;
945
+ }
946
+ }
947
+
948
+ [attributedString deleteCharactersInRange:ghostTextRange];
949
+ return attributedString;
950
+ }
951
+
952
+ #endif // macOS]
953
+
772
954
  #pragma mark - Native Commands
773
955
 
774
956
  - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
@@ -806,7 +988,13 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
806
988
  [_backedTextInputView resignFirstResponder];
807
989
  #else // [macOS
808
990
  NSWindow *window = [_backedTextInputView window];
809
- if ([window firstResponder] == _backedTextInputView.responder) {
991
+ // On macOS, when an NSTextField is focused, the window's firstResponder is the
992
+ // field editor (an NSTextView), not the text field itself. Check currentEditor
993
+ // to determine if the text field is actively being edited.
994
+ if ([_backedTextInputView isKindOfClass:[NSTextField class]] &&
995
+ [(NSTextField *)_backedTextInputView currentEditor] != nil) {
996
+ [window makeFirstResponder:nil];
997
+ } else if ([window firstResponder] == _backedTextInputView.responder) {
810
998
  [window makeFirstResponder:nil];
811
999
  }
812
1000
  #endif // macOS]
@@ -845,7 +1033,7 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
845
1033
  #else // [macOS
846
1034
  NSInteger startPosition = MIN(start, end);
847
1035
  NSInteger endPosition = MAX(start, end);
848
- [_backedTextInputView setSelectedTextRange:NSMakeRange(startPosition, endPosition - startPosition) notifyDelegate:YES];
1036
+ [_backedTextInputView setSelectedTextRange:NSMakeRange(startPosition, endPosition - startPosition) notifyDelegate:NO];
849
1037
  #endif // macOS]
850
1038
  _comingFromJS = NO;
851
1039
  }
@@ -1220,7 +1408,7 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
1220
1408
  // There are multiple Korean input sources (2-Set, 3-Set, etc). Check substring instead instead
1221
1409
  [[[_backedTextInputView inputContext] selectedKeyboardInputSource] containsString:@"com.apple.inputmethod.Korean"] ||
1222
1410
  [_backedTextInputView hasMarkedText] ||
1223
- [_backedTextInputView isKindOfClass:[NSSecureTextField class]] ||
1411
+ [_backedTextInputView isKindOfClass:[RCTUISecureTextField class]] ||
1224
1412
  #endif // macOS]
1225
1413
  fontHasBeenUpdatedBySystem;
1226
1414
 
@@ -18,6 +18,9 @@ NS_ASSUME_NONNULL_BEGIN
18
18
  value:(NSString *__nullable)value
19
19
  start:(NSInteger)start
20
20
  end:(NSInteger)end;
21
+ #if TARGET_OS_OSX // [macOS
22
+ - (void)setGhostText:(NSString *__nullable)ghostText;
23
+ #endif // macOS]
21
24
  @end
22
25
 
23
26
  RCT_EXTERN inline void
@@ -96,6 +99,23 @@ RCTTextInputHandleCommand(id<RCTTextInputViewProtocol> componentView, const NSSt
96
99
  return;
97
100
  }
98
101
 
102
+ #if TARGET_OS_OSX // [macOS
103
+ if ([commandName isEqualToString:@"setGhostText"]) {
104
+ #if RCT_DEBUG
105
+ if ([args count] != 1) {
106
+ RCTLogError(
107
+ @"%@ command %@ received %d arguments, expected %d.", @"TextInput", commandName, (int)[args count], 1);
108
+ return;
109
+ }
110
+ #endif
111
+
112
+ NSObject *arg0 = args[0];
113
+ NSString *value = [arg0 isKindOfClass:[NSNull class]] ? nil : (NSString *)arg0;
114
+ [componentView setGhostText:value];
115
+ return;
116
+ }
117
+ #endif // macOS]
118
+
99
119
  #if RCT_DEBUG
100
120
  RCTLogError(@"%@ received command %@, which is not a supported command.", @"TextInput", commandName);
101
121
  #endif
@@ -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 :DoubleClick];
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 && IsPointerWithinInitialTree(activePointer)) {
707
- eventEmitter->onClick(std::move(pointerEvent));
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
  }
@@ -286,7 +286,7 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
286
286
  #define RCT_CASE(_value, _type) \
287
287
  case _value: { \
288
288
  __block BOOL setDefaultValue = NO; \
289
- __block _type defaultValue; \
289
+ __block _type defaultValue{}; /*[macOS]*/ \
290
290
  _type (*convert)(id, SEL, id) = (__typeof(convert))objc_msgSend; \
291
291
  _type (*get)(id, SEL) = (__typeof(get))objc_msgSend; \
292
292
  void (*set)(id, SEL, _type) = (__typeof(set))objc_msgSend; \
@@ -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)
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.81.6
1
+ VERSION_NAME=0.81.8
2
2
  react.internal.publishingGroup=com.facebook.react
3
3
 
4
4
  android.useAndroidX=true
@@ -14,7 +14,7 @@ public object ReactNativeVersion {
14
14
  public val VERSION: Map<String, Any?> = mapOf(
15
15
  "major" to 0,
16
16
  "minor" to 81,
17
- "patch" to 6,
17
+ "patch" to 8,
18
18
  "prerelease" to null
19
19
  )
20
20
  }
@@ -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 6
17
+ #define REACT_NATIVE_VERSION_PATCH 8
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 = 6;
24
+ int32_t Patch = 8;
25
25
  std::string_view Prerelease = "";
26
26
  } ReactNativeVersion;
27
27
 
@@ -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 {
@@ -67,6 +67,8 @@ struct ViewEvents {
67
67
  PointerDownCapture = 35,
68
68
  PointerUp = 36,
69
69
  PointerUpCapture = 37,
70
+ AuxClick = 38,
71
+ AuxClickCapture = 39,
70
72
  };
71
73
 
72
74
  constexpr bool operator[](const Offset offset) const {
@@ -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,
@@ -10,6 +10,8 @@
10
10
  #include <react/renderer/graphics/ColorComponents.h>
11
11
  #include <react/utils/hash_combine.h>
12
12
  #include <cmath>
13
+ #include <string>
14
+ #include <vector>
13
15
 
14
16
  namespace facebook::react {
15
17