react-native-macos 0.73.30 → 0.73.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,6 @@
12
12
  exports.version = {
13
13
  major: 0,
14
14
  minor: 73,
15
- patch: 30,
15
+ patch: 31,
16
16
  prerelease: null,
17
17
  };
@@ -123,6 +123,8 @@ NS_ASSUME_NONNULL_END
123
123
 
124
124
  #import <AppKit/AppKit.h>
125
125
 
126
+ #import <React/RCTComponent.h>
127
+
126
128
  NS_ASSUME_NONNULL_BEGIN
127
129
 
128
130
  //
@@ -403,6 +405,15 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
403
405
 
404
406
  - (void)setNeedsDisplay;
405
407
 
408
+ // Methods related to mouse events
409
+ - (NSDictionary*)locationInfoFromDraggingLocation:(NSPoint)locationInWindow;
410
+ - (NSDictionary*)locationInfoFromEvent:(NSEvent*)event;
411
+
412
+ - (void)sendMouseEventWithBlock:(RCTDirectEventBlock)block
413
+ locationInfo:(NSDictionary*)locationInfo
414
+ modifierFlags:(NSEventModifierFlags)modifierFlags
415
+ additionalData:(NSDictionary*)additionalData;
416
+
406
417
  // FUTURE: When Xcode 14 is no longer supported (CI is building with Xcode 15), we can remove this override since it's now declared on NSView
407
418
  @property BOOL clipsToBounds;
408
419
  @property (nonatomic, copy) NSColor *backgroundColor;
@@ -426,6 +437,24 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
426
437
  */
427
438
  @property (nonatomic, assign) BOOL enableFocusRing;
428
439
 
440
+ // Mouse events
441
+ @property (nonatomic, copy) RCTDirectEventBlock onMouseEnter;
442
+ @property (nonatomic, copy) RCTDirectEventBlock onMouseLeave;
443
+ @property (nonatomic, copy) RCTDirectEventBlock onDragEnter;
444
+ @property (nonatomic, copy) RCTDirectEventBlock onDragLeave;
445
+ @property (nonatomic, copy) RCTDirectEventBlock onDrop;
446
+
447
+ // Focus events
448
+ @property (nonatomic, copy) RCTBubblingEventBlock onBlur;
449
+ @property (nonatomic, copy) RCTBubblingEventBlock onFocus;
450
+
451
+ @property (nonatomic, copy) RCTBubblingEventBlock onResponderGrant;
452
+ @property (nonatomic, copy) RCTBubblingEventBlock onResponderMove;
453
+ @property (nonatomic, copy) RCTBubblingEventBlock onResponderRelease;
454
+ @property (nonatomic, copy) RCTBubblingEventBlock onResponderTerminate;
455
+ @property (nonatomic, copy) RCTBubblingEventBlock onResponderTerminationRequest;
456
+ @property (nonatomic, copy) RCTBubblingEventBlock onStartShouldSetResponder;
457
+
429
458
  @end
430
459
 
431
460
  // UIScrollView
@@ -23,7 +23,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
23
23
  __rnVersion = @{
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(73),
26
- RCTVersionPatch: @(30),
26
+ RCTVersionPatch: @(31),
27
27
  RCTVersionPrerelease: [NSNull null],
28
28
  };
29
29
  });
@@ -12,6 +12,7 @@
12
12
  #import <React/RCTUIKit.h>
13
13
 
14
14
  #import <React/RCTAssert.h>
15
+ #import <UIView+React.h>
15
16
 
16
17
  #import <objc/runtime.h>
17
18
 
@@ -214,6 +215,7 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *bezierPath)
214
215
  @private
215
216
  NSColor *_backgroundColor;
216
217
  BOOL _clipsToBounds;
218
+ BOOL _hasMouseOver;
217
219
  BOOL _userInteractionEnabled;
218
220
  BOOL _mouseDownCanMoveWindow;
219
221
  }
@@ -287,9 +289,142 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
287
289
 
288
290
  - (void)viewDidMoveToWindow
289
291
  {
292
+ // Subscribe to view bounds changed notification so that the view can be notified when a
293
+ // scroll event occurs either due to trackpad/gesture based scrolling or a scrollwheel event
294
+ // both of which would not cause the mouseExited to be invoked.
295
+
296
+ if ([self window] == nil) {
297
+ [[NSNotificationCenter defaultCenter] removeObserver:self
298
+ name:NSViewBoundsDidChangeNotification
299
+ object:nil];
300
+ }
301
+ else if ([[self enclosingScrollView] contentView] != nil) {
302
+ [[NSNotificationCenter defaultCenter] addObserver:self
303
+ selector:@selector(viewBoundsChanged:)
304
+ name:NSViewBoundsDidChangeNotification
305
+ object:[[self enclosingScrollView] contentView]];
306
+ }
307
+
308
+ [self reactViewDidMoveToWindow]; // [macOS] Github#1412
309
+
290
310
  [self didMoveToWindow];
291
311
  }
292
312
 
313
+ - (void)viewBoundsChanged:(NSNotification*)__unused inNotif
314
+ {
315
+ // When an enclosing scrollview is scrolled using the scrollWheel or trackpad,
316
+ // the mouseExited: event does not get called on the view where mouseEntered: was previously called.
317
+ // This creates an unnatural pairing of mouse enter and exit events and can cause problems.
318
+ // We therefore explicitly check for this here and handle them by calling the appropriate callbacks.
319
+
320
+ if (!_hasMouseOver && self.onMouseEnter)
321
+ {
322
+ NSPoint locationInWindow = [[self window] mouseLocationOutsideOfEventStream];
323
+ NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
324
+
325
+ if (NSPointInRect(locationInView, [self bounds]))
326
+ {
327
+ _hasMouseOver = YES;
328
+
329
+ [self sendMouseEventWithBlock:self.onMouseEnter
330
+ locationInfo:[self locationInfoFromDraggingLocation:locationInWindow]
331
+ modifierFlags:0
332
+ additionalData:nil];
333
+ }
334
+ }
335
+ else if (_hasMouseOver && self.onMouseLeave)
336
+ {
337
+ NSPoint locationInWindow = [[self window] mouseLocationOutsideOfEventStream];
338
+ NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
339
+
340
+ if (!NSPointInRect(locationInView, [self bounds]))
341
+ {
342
+ _hasMouseOver = NO;
343
+
344
+ [self sendMouseEventWithBlock:self.onMouseLeave
345
+ locationInfo:[self locationInfoFromDraggingLocation:locationInWindow]
346
+ modifierFlags:0
347
+ additionalData:nil];
348
+ }
349
+ }
350
+ }
351
+
352
+ - (NSDictionary*)locationInfoFromDraggingLocation:(NSPoint)locationInWindow
353
+ {
354
+ NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
355
+
356
+ return @{@"screenX": @(locationInWindow.x),
357
+ @"screenY": @(locationInWindow.y),
358
+ @"clientX": @(locationInView.x),
359
+ @"clientY": @(locationInView.y)
360
+ };
361
+ }
362
+
363
+ - (NSDictionary*)locationInfoFromEvent:(NSEvent*)event
364
+ {
365
+ NSPoint locationInWindow = event.locationInWindow;
366
+ NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
367
+
368
+ return @{@"screenX": @(locationInWindow.x),
369
+ @"screenY": @(locationInWindow.y),
370
+ @"clientX": @(locationInView.x),
371
+ @"clientY": @(locationInView.y)
372
+ };
373
+ }
374
+
375
+ - (void)mouseEntered:(NSEvent *)event
376
+ {
377
+ _hasMouseOver = YES;
378
+ [self sendMouseEventWithBlock:self.onMouseEnter
379
+ locationInfo:[self locationInfoFromEvent:event]
380
+ modifierFlags:event.modifierFlags
381
+ additionalData:nil];
382
+ }
383
+
384
+ - (void)mouseExited:(NSEvent *)event
385
+ {
386
+ _hasMouseOver = NO;
387
+ [self sendMouseEventWithBlock:self.onMouseLeave
388
+ locationInfo:[self locationInfoFromEvent:event]
389
+ modifierFlags:event.modifierFlags
390
+ additionalData:nil];
391
+ }
392
+
393
+ - (void)sendMouseEventWithBlock:(RCTDirectEventBlock)block
394
+ locationInfo:(NSDictionary*)locationInfo
395
+ modifierFlags:(NSEventModifierFlags)modifierFlags
396
+ additionalData:(NSDictionary*)additionalData
397
+ {
398
+ if (block == nil) {
399
+ return;
400
+ }
401
+
402
+ NSMutableDictionary *body = [NSMutableDictionary new];
403
+
404
+ if (modifierFlags & NSEventModifierFlagShift) {
405
+ body[@"shiftKey"] = @YES;
406
+ }
407
+ if (modifierFlags & NSEventModifierFlagControl) {
408
+ body[@"ctrlKey"] = @YES;
409
+ }
410
+ if (modifierFlags & NSEventModifierFlagOption) {
411
+ body[@"altKey"] = @YES;
412
+ }
413
+ if (modifierFlags & NSEventModifierFlagCommand) {
414
+ body[@"metaKey"] = @YES;
415
+ }
416
+
417
+ if (locationInfo) {
418
+ [body addEntriesFromDictionary:locationInfo];
419
+ }
420
+
421
+ if (additionalData) {
422
+ [body addEntriesFromDictionary:additionalData];
423
+ }
424
+
425
+ block(body);
426
+ }
427
+
293
428
  - (BOOL)mouseDownCanMoveWindow{
294
429
  return _mouseDownCanMoveWindow;
295
430
  }
@@ -167,12 +167,6 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
167
167
  // that we can set through JS and the getter for `allowsVibrancy` can read in RCTView.
168
168
  @property (nonatomic, assign) BOOL allowsVibrancyInternal;
169
169
 
170
- @property (nonatomic, copy) RCTDirectEventBlock onMouseEnter;
171
- @property (nonatomic, copy) RCTDirectEventBlock onMouseLeave;
172
- @property (nonatomic, copy) RCTDirectEventBlock onDragEnter;
173
- @property (nonatomic, copy) RCTDirectEventBlock onDragLeave;
174
- @property (nonatomic, copy) RCTDirectEventBlock onDrop;
175
-
176
170
  // Keyboarding events
177
171
  // NOTE does not properly work with single line text inputs (most key downs). This is because those are
178
172
  // presumably handled by the window's field editor. To make it work, we'd need to look into providing
@@ -137,7 +137,6 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // [macOS]
137
137
  id<RCTEventDispatcherProtocol> _eventDispatcher; // [macOS]
138
138
  #if TARGET_OS_OSX // [macOS
139
139
  NSTrackingArea *_trackingArea;
140
- BOOL _hasMouseOver;
141
140
  BOOL _mouseDownCanMoveWindow;
142
141
  #endif // macOS]
143
142
  NSMutableDictionary<NSString *, NSDictionary *> *accessibilityActionsNameMap;
@@ -778,67 +777,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused)
778
777
  [self setShadow:shadow];
779
778
  }
780
779
 
781
- - (void)viewDidMoveToWindow
782
- {
783
- // Subscribe to view bounds changed notification so that the view can be notified when a
784
- // scroll event occurs either due to trackpad/gesture based scrolling or a scrollwheel event
785
- // both of which would not cause the mouseExited to be invoked.
786
-
787
- if ([self window] == nil) {
788
- [[NSNotificationCenter defaultCenter] removeObserver:self
789
- name:NSViewBoundsDidChangeNotification
790
- object:nil];
791
- }
792
- else if ([[self enclosingScrollView] contentView] != nil) {
793
- [[NSNotificationCenter defaultCenter] addObserver:self
794
- selector:@selector(viewBoundsChanged:)
795
- name:NSViewBoundsDidChangeNotification
796
- object:[[self enclosingScrollView] contentView]];
797
- }
798
-
799
- [self reactViewDidMoveToWindow]; // [macOS] Github#1412
800
-
801
- [super viewDidMoveToWindow];
802
- }
803
-
804
- - (void)viewBoundsChanged:(NSNotification*)__unused inNotif
805
- {
806
- // When an enclosing scrollview is scrolled using the scrollWheel or trackpad,
807
- // the mouseExited: event does not get called on the view where mouseEntered: was previously called.
808
- // This creates an unnatural pairing of mouse enter and exit events and can cause problems.
809
- // We therefore explicitly check for this here and handle them by calling the appropriate callbacks.
810
-
811
- if (!_hasMouseOver && self.onMouseEnter)
812
- {
813
- NSPoint locationInWindow = [[self window] mouseLocationOutsideOfEventStream];
814
- NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
815
-
816
- if (NSPointInRect(locationInView, [self bounds]))
817
- {
818
- _hasMouseOver = YES;
819
780
 
820
- [self sendMouseEventWithBlock:self.onMouseEnter
821
- locationInfo:[self locationInfoFromDraggingLocation:locationInWindow]
822
- modifierFlags:0
823
- additionalData:nil];
824
- }
825
- }
826
- else if (_hasMouseOver && self.onMouseLeave)
827
- {
828
- NSPoint locationInWindow = [[self window] mouseLocationOutsideOfEventStream];
829
- NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
830
-
831
- if (!NSPointInRect(locationInView, [self bounds]))
832
- {
833
- _hasMouseOver = NO;
834
-
835
- [self sendMouseEventWithBlock:self.onMouseLeave
836
- locationInfo:[self locationInfoFromDraggingLocation:locationInWindow]
837
- modifierFlags:0
838
- additionalData:nil];
839
- }
840
- }
841
- }
842
781
  #endif // macOS]
843
782
 
844
783
  #pragma mark - Statics for dealing with layoutGuides
@@ -1549,24 +1488,6 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1549
1488
  [super updateTrackingAreas];
1550
1489
  }
1551
1490
 
1552
- - (void)mouseEntered:(NSEvent *)event
1553
- {
1554
- _hasMouseOver = YES;
1555
- [self sendMouseEventWithBlock:self.onMouseEnter
1556
- locationInfo:[self locationInfoFromEvent:event]
1557
- modifierFlags:event.modifierFlags
1558
- additionalData:nil];
1559
- }
1560
-
1561
- - (void)mouseExited:(NSEvent *)event
1562
- {
1563
- _hasMouseOver = NO;
1564
- [self sendMouseEventWithBlock:self.onMouseLeave
1565
- locationInfo:[self locationInfoFromEvent:event]
1566
- modifierFlags:event.modifierFlags
1567
- additionalData:nil];
1568
- }
1569
-
1570
1491
  - (BOOL)mouseDownCanMoveWindow{
1571
1492
  return _mouseDownCanMoveWindow;
1572
1493
  }
@@ -1579,53 +1500,6 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1579
1500
  return _allowsVibrancyInternal;
1580
1501
  }
1581
1502
 
1582
- - (NSDictionary*)locationInfoFromEvent:(NSEvent*)event
1583
- {
1584
- NSPoint locationInWindow = event.locationInWindow;
1585
- NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
1586
-
1587
- return @{@"screenX": @(locationInWindow.x),
1588
- @"screenY": @(locationInWindow.y),
1589
- @"clientX": @(locationInView.x),
1590
- @"clientY": @(locationInView.y)
1591
- };
1592
- }
1593
-
1594
- - (void)sendMouseEventWithBlock:(RCTDirectEventBlock)block
1595
- locationInfo:(NSDictionary*)locationInfo
1596
- modifierFlags:(NSEventModifierFlags)modifierFlags
1597
- additionalData:(NSDictionary*)additionalData
1598
- {
1599
- if (block == nil) {
1600
- return;
1601
- }
1602
-
1603
- NSMutableDictionary *body = [NSMutableDictionary new];
1604
-
1605
- if (modifierFlags & NSEventModifierFlagShift) {
1606
- body[@"shiftKey"] = @YES;
1607
- }
1608
- if (modifierFlags & NSEventModifierFlagControl) {
1609
- body[@"ctrlKey"] = @YES;
1610
- }
1611
- if (modifierFlags & NSEventModifierFlagOption) {
1612
- body[@"altKey"] = @YES;
1613
- }
1614
- if (modifierFlags & NSEventModifierFlagCommand) {
1615
- body[@"metaKey"] = @YES;
1616
- }
1617
-
1618
- if (locationInfo) {
1619
- [body addEntriesFromDictionary:locationInfo];
1620
- }
1621
-
1622
- if (additionalData) {
1623
- [body addEntriesFromDictionary:additionalData];
1624
- }
1625
-
1626
- block(body);
1627
- }
1628
-
1629
1503
  - (NSDictionary*)dataTransferInfoFromPasteboard:(NSPasteboard*)pasteboard
1630
1504
  {
1631
1505
  NSArray *fileNames = [pasteboard propertyListForType:NSFilenamesPboardType] ?: @[];
@@ -1704,17 +1578,6 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1704
1578
  @"types": types}};
1705
1579
  }
1706
1580
 
1707
- - (NSDictionary*)locationInfoFromDraggingLocation:(NSPoint)locationInWindow
1708
- {
1709
- NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
1710
-
1711
- return @{@"screenX": @(locationInWindow.x),
1712
- @"screenY": @(locationInWindow.y),
1713
- @"clientX": @(locationInView.x),
1714
- @"clientY": @(locationInView.y)
1715
- };
1716
- }
1717
-
1718
1581
  - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
1719
1582
  {
1720
1583
  NSPasteboard *pboard = sender.draggingPasteboard;
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.73.30
1
+ VERSION_NAME=0.73.31
2
2
  react.internal.publishingGroup=com.facebook.react
3
3
 
4
4
  android.useAndroidX=true
@@ -17,6 +17,6 @@ public class ReactNativeVersion {
17
17
  public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
18
18
  "major", 0,
19
19
  "minor", 73,
20
- "patch", 30,
20
+ "patch", 31,
21
21
  "prerelease", null);
22
22
  }
@@ -17,7 +17,7 @@ namespace facebook::react {
17
17
  constexpr struct {
18
18
  int32_t Major = 0;
19
19
  int32_t Minor = 73;
20
- int32_t Patch = 30;
20
+ int32_t Patch = 31;
21
21
  std::string_view Prerelease = "";
22
22
  } ReactNativeVersion;
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.73.30",
3
+ "version": "0.73.31",
4
4
  "description": "React Native for macOS",
5
5
  "license": "MIT",
6
6
  "repository": {