react-native-macos 0.0.0-a598ee4ef → 0.0.0-a80cca6c6

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 (79) hide show
  1. package/Libraries/Components/ScrollView/ScrollView.js +11 -45
  2. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  3. package/Libraries/Components/TextInput/TextInput.js +79 -1
  4. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  5. package/Libraries/Components/View/ViewPropTypes.js +10 -6
  6. package/Libraries/Core/ReactNativeVersion.js +1 -1
  7. package/Libraries/Image/RCTImageView.mm +14 -10
  8. package/Libraries/LinkingIOS/RCTLinkingManager.h +1 -0
  9. package/Libraries/LinkingIOS/macos/RCTLinkingManager.mm +12 -5
  10. package/Libraries/Lists/FlatList.js +25 -2
  11. package/Libraries/Lists/VirtualizedList.js +118 -113
  12. package/Libraries/Lists/VirtualizedSectionList.js +9 -5
  13. package/Libraries/Text/BaseText/RCTBaseTextViewManager.m +1 -0
  14. package/Libraries/Text/RCTTextAttributes.h +2 -0
  15. package/Libraries/Text/RCTTextAttributes.m +9 -0
  16. package/Libraries/Text/Text/RCTDynamicTypeRamp.h +40 -0
  17. package/Libraries/Text/Text/RCTDynamicTypeRamp.m +77 -0
  18. package/Libraries/Text/Text/RCTTextView.m +118 -47
  19. package/Libraries/Text/Text.js +0 -8
  20. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.h +8 -0
  21. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.m +57 -2
  22. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.m +13 -0
  23. package/Libraries/Text/TextInput/Multiline/RCTUITextView.h +2 -1
  24. package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +69 -2
  25. package/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +7 -1
  26. package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +12 -3
  27. package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +1 -0
  28. package/Libraries/Text/TextInput/RCTBaseTextInputView.h +4 -1
  29. package/Libraries/Text/TextInput/RCTBaseTextInputView.m +97 -2
  30. package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +6 -1
  31. package/Libraries/Text/TextInput/Singleline/RCTUITextField.m +40 -0
  32. package/Libraries/Text/TextNativeComponent.js +2 -0
  33. package/Libraries/Text/TextProps.js +29 -0
  34. package/Libraries/Types/CoreEventTypes.js +0 -1
  35. package/React/Base/RCTAssert.h +2 -3
  36. package/React/Base/RCTAssert.m +2 -2
  37. package/React/Base/RCTBridge.m +1 -1
  38. package/React/Base/RCTConvert.m +7 -4
  39. package/React/Base/RCTTouchHandler.m +4 -0
  40. package/React/Base/RCTUIKit.h +8 -13
  41. package/React/Base/RCTUtils.m +6 -3
  42. package/React/Base/RCTVersion.m +1 -1
  43. package/React/Base/macOS/RCTUIKit.m +33 -0
  44. package/React/CoreModules/RCTPerfMonitor.mm +1 -1
  45. package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +1 -1
  46. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +10 -1
  47. package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +8 -1
  48. package/React/Fabric/RCTConversions.h +9 -1
  49. package/React/Fabric/RCTSurfacePresenter.mm +0 -1
  50. package/React/Fabric/RCTSurfaceTouchHandler.mm +0 -1
  51. package/React/Modules/RCTUIManager.m +2 -1
  52. package/React/React-RCTFabric.podspec +1 -1
  53. package/React/Views/RCTActivityIndicatorView.m +2 -1
  54. package/React/Views/RCTView.h +1 -0
  55. package/React/Views/RCTView.m +50 -16
  56. package/React/Views/RCTViewKeyboardEvent.m +9 -1
  57. package/React/Views/RCTViewManager.m +4 -14
  58. package/React/Views/ScrollView/RCTScrollContentView.h +4 -0
  59. package/React/Views/ScrollView/RCTScrollContentView.m +6 -0
  60. package/React/Views/ScrollView/RCTScrollContentViewManager.m +2 -0
  61. package/React/Views/ScrollView/RCTScrollView.h +2 -1
  62. package/React/Views/ScrollView/RCTScrollView.m +65 -63
  63. package/React/Views/ScrollView/RCTScrollViewManager.m +1 -1
  64. package/React/Views/UIView+React.h +2 -0
  65. package/React/Views/UIView+React.m +22 -13
  66. package/ReactAndroid/gradle.properties +1 -1
  67. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  68. package/ReactCommon/React-Fabric.podspec +1 -1
  69. package/ReactCommon/React-rncore.podspec +1 -1
  70. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  71. package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
  72. package/ReactCommon/react/utils/ManagedObjectWrapper.h +1 -1
  73. package/ReactCommon/react/utils/ManagedObjectWrapper.mm +1 -3
  74. package/package.json +1 -1
  75. package/scripts/generate-artifacts.js +21 -17
  76. package/scripts/react_native_pods.rb +0 -3
  77. package/template/Gemfile.lock +4 -4
  78. package/template/package.json +1 -1
  79. package/third-party-podspecs/boost-for-react-native.podspec +0 -20
@@ -8,7 +8,8 @@
8
8
  #import "RCTActivityIndicatorView.h"
9
9
 
10
10
  #if TARGET_OS_OSX // [TODO(macOS GH#774)
11
- #import <QuartzCore/QuartzCore.h>
11
+ #import <CoreImage/CIFilter.h>
12
+ #import <CoreImage/CIVector.h>
12
13
 
13
14
  @interface RCTActivityIndicatorView ()
14
15
  @property (nonatomic, readwrite, getter=isAnimating) BOOL animating;
@@ -31,6 +31,7 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
31
31
  - (BOOL)resignFirstResponder;
32
32
 
33
33
  #if TARGET_OS_OSX
34
+ - (NSDictionary*)dataTransferInfoFromPasteboard:(NSPasteboard*)pasteboard;
34
35
  - (BOOL)handleKeyboardEvent:(NSEvent *)event;
35
36
  #endif
36
37
  // ]TODO(OSS Candidate ISS#2710739)
@@ -779,6 +779,9 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused)
779
779
  name:NSViewBoundsDidChangeNotification
780
780
  object:[[self enclosingScrollView] contentView]];
781
781
  }
782
+
783
+ [self reactViewDidMoveToWindow]; // TODO(macOS GH#1412)
784
+
782
785
  [super viewDidMoveToWindow];
783
786
  }
784
787
 
@@ -1437,9 +1440,14 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1437
1440
  }
1438
1441
  }
1439
1442
 
1443
+ - (BOOL)needsPanelToBecomeKey {
1444
+ // We need to override this so that mouse clicks don't move keyboard focus on focusable views by default.
1445
+ return false;
1446
+ }
1447
+
1440
1448
  - (BOOL)acceptsFirstResponder
1441
1449
  {
1442
- return ([self focusable] && [NSApp isFullKeyboardAccessEnabled]) || [super acceptsFirstResponder];
1450
+ return [self focusable] || [super acceptsFirstResponder];
1443
1451
  }
1444
1452
 
1445
1453
  - (void)updateTrackingAreas
@@ -1524,13 +1532,9 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1524
1532
  block(body);
1525
1533
  }
1526
1534
 
1527
- - (NSDictionary*)dataTransferInfoFromPastboard:(NSPasteboard*)pastboard
1535
+ - (NSDictionary*)dataTransferInfoFromPasteboard:(NSPasteboard*)pasteboard
1528
1536
  {
1529
- if (![pastboard.types containsObject:NSFilenamesPboardType]) {
1530
- return @{};
1531
- }
1532
-
1533
- NSArray *fileNames = [pastboard propertyListForType:NSFilenamesPboardType];
1537
+ NSArray *fileNames = [pasteboard propertyListForType:NSFilenamesPboardType] ?: @[];
1534
1538
  NSMutableArray *files = [[NSMutableArray alloc] initWithCapacity:fileNames.count];
1535
1539
  NSMutableArray *items = [[NSMutableArray alloc] initWithCapacity:fileNames.count];
1536
1540
  NSMutableArray *types = [[NSMutableArray alloc] initWithCapacity:fileNames.count];
@@ -1556,11 +1560,21 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1556
1560
  BOOL success = [fileURL getResourceValue:&fileSizeValue
1557
1561
  forKey:NSURLFileSizeKey
1558
1562
  error:&fileSizeError];
1559
-
1563
+
1564
+ NSNumber *width = nil;
1565
+ NSNumber *height = nil;
1566
+ if ([MIMETypeString hasPrefix:@"image/"]) {
1567
+ NSImage *image = [[NSImage alloc] initWithContentsOfURL:fileURL];
1568
+ width = @(image.size.width);
1569
+ height = @(image.size.height);
1570
+ }
1571
+
1560
1572
  [files addObject:@{@"name": RCTNullIfNil(fileURL.lastPathComponent),
1561
1573
  @"type": RCTNullIfNil(MIMETypeString),
1562
- @"uri": RCTNullIfNil(fileURL.absoluteString),
1563
- @"size": success ? fileSizeValue : (id)kCFNull
1574
+ @"uri": RCTNullIfNil(fileURL.path),
1575
+ @"size": success ? fileSizeValue : (id)kCFNull,
1576
+ @"width": RCTNullIfNil(width),
1577
+ @"height": RCTNullIfNil(height)
1564
1578
  }];
1565
1579
 
1566
1580
  [items addObject:@{@"kind": @"file",
@@ -1570,7 +1584,27 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1570
1584
  [types addObject:RCTNullIfNil(MIMETypeString)];
1571
1585
  }
1572
1586
  }
1573
-
1587
+
1588
+ NSPasteboardType imageType = [pasteboard availableTypeFromArray:@[NSPasteboardTypePNG, NSPasteboardTypeTIFF]];
1589
+ if (imageType && fileNames.count == 0) {
1590
+ NSString *MIMETypeString = imageType == NSPasteboardTypePNG ? @"image/png" : @"image/tiff";
1591
+ NSData *imageData = [pasteboard dataForType:imageType];
1592
+ NSImage *image = [[NSImage alloc] initWithData:imageData];
1593
+
1594
+ [files addObject:@{@"type": RCTNullIfNil(MIMETypeString),
1595
+ @"uri": RCTDataURL(MIMETypeString, imageData).absoluteString,
1596
+ @"size": @(imageData.length),
1597
+ @"width": @(image.size.width),
1598
+ @"height": @(image.size.height),
1599
+ }];
1600
+
1601
+ [items addObject:@{@"kind": @"image",
1602
+ @"type": RCTNullIfNil(MIMETypeString),
1603
+ }];
1604
+
1605
+ [types addObject:RCTNullIfNil(MIMETypeString)];
1606
+ }
1607
+
1574
1608
  return @{@"dataTransfer": @{@"files": files,
1575
1609
  @"items": items,
1576
1610
  @"types": types}};
@@ -1595,9 +1629,9 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1595
1629
  [self sendMouseEventWithBlock:self.onDragEnter
1596
1630
  locationInfo:[self locationInfoFromDraggingLocation:sender.draggingLocation]
1597
1631
  modifierFlags:0
1598
- additionalData:[self dataTransferInfoFromPastboard:pboard]];
1599
-
1600
- if ([pboard.types containsObject:NSFilenamesPboardType]) {
1632
+ additionalData:[self dataTransferInfoFromPasteboard:pboard]];
1633
+
1634
+ if ([pboard availableTypeFromArray:self.registeredDraggedTypes]) {
1601
1635
  if (sourceDragMask & NSDragOperationLink) {
1602
1636
  return NSDragOperationLink;
1603
1637
  } else if (sourceDragMask & NSDragOperationCopy) {
@@ -1612,7 +1646,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1612
1646
  [self sendMouseEventWithBlock:self.onDragLeave
1613
1647
  locationInfo:[self locationInfoFromDraggingLocation:sender.draggingLocation]
1614
1648
  modifierFlags:0
1615
- additionalData:[self dataTransferInfoFromPastboard:sender.draggingPasteboard]];
1649
+ additionalData:[self dataTransferInfoFromPasteboard:sender.draggingPasteboard]];
1616
1650
  }
1617
1651
 
1618
1652
  - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
@@ -1620,7 +1654,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1620
1654
  [self sendMouseEventWithBlock:self.onDrop
1621
1655
  locationInfo:[self locationInfoFromDraggingLocation:sender.draggingLocation]
1622
1656
  modifierFlags:0
1623
- additionalData:[self dataTransferInfoFromPastboard:[sender draggingPasteboard]]];
1657
+ additionalData:[self dataTransferInfoFromPasteboard:sender.draggingPasteboard]];
1624
1658
  return YES;
1625
1659
  }
1626
1660
  #endif // ]TODO(macOS GH#774)
@@ -52,7 +52,15 @@
52
52
  return @"Backspace";
53
53
  } else if (code == NSDeleteFunctionKey) {
54
54
  return @"Delete";
55
- }
55
+ } else if (code == NSHomeFunctionKey) {
56
+ return @"Home";
57
+ } else if (code == NSEndFunctionKey) {
58
+ return @"End";
59
+ } else if (code == NSPageUpFunctionKey) {
60
+ return @"PageUp";
61
+ } else if (code == NSPageDownFunctionKey) {
62
+ return @"PageDown";
63
+ }
56
64
 
57
65
  return key;
58
66
  }
@@ -95,7 +95,7 @@ RCT_EXPORT_MODULE()
95
95
 
96
96
  - (void)setBridge:(RCTBridge *)bridge
97
97
  {
98
- RCTWarnNotAllowedForNewArchitecture(self, @"RCTViewManager must not be initialized for the new architecture");
98
+ RCTErrorNotAllowedForNewArchitecture(self, @"RCTViewManager must not be initialized for the new architecture");
99
99
  _bridge = bridge;
100
100
  }
101
101
 
@@ -197,7 +197,7 @@ RCT_REMAP_VIEW_PROPERTY(opacity, alpha, CGFloat)
197
197
  RCT_REMAP_VIEW_PROPERTY(opacity, alphaValue, CGFloat)
198
198
  #endif // ]TODO(macOS GH#774)
199
199
 
200
- #if TARGET_OS_OSX // TODO(macOS GH#774)
200
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
201
201
  RCT_REMAP_VIEW_PROPERTY(shadowColor, layer.shadowColor, CGColor)
202
202
  RCT_REMAP_VIEW_PROPERTY(shadowOffset, layer.shadowOffset, CGSize)
203
203
  RCT_REMAP_VIEW_PROPERTY(shadowOpacity, layer.shadowOpacity, float)
@@ -495,18 +495,8 @@ RCT_EXPORT_VIEW_PROPERTY(onDragLeave, RCTDirectEventBlock)
495
495
  RCT_EXPORT_VIEW_PROPERTY(onDrop, RCTDirectEventBlock)
496
496
  RCT_EXPORT_VIEW_PROPERTY(onKeyDown, RCTDirectEventBlock) // macOS keyboard events
497
497
  RCT_EXPORT_VIEW_PROPERTY(onKeyUp, RCTDirectEventBlock) // macOS keyboard events
498
- RCT_CUSTOM_VIEW_PROPERTY(validKeysDown, NSArray<NSString*>, RCTView)
499
- {
500
- if ([view respondsToSelector:@selector(setValidKeysDown:)]) {
501
- view.validKeysDown = [RCTConvert NSArray:json];
502
- }
503
- }
504
- RCT_CUSTOM_VIEW_PROPERTY(validKeysUp, NSArray<NSString*>, RCTView)
505
- {
506
- if ([view respondsToSelector:@selector(setValidKeysUp:)]) {
507
- view.validKeysUp = [RCTConvert NSArray:json];
508
- }
509
- }
498
+ RCT_EXPORT_VIEW_PROPERTY(validKeysDown, NSArray<NSString*>)
499
+ RCT_EXPORT_VIEW_PROPERTY(validKeysUp, NSArray<NSString*>)
510
500
  #endif // ]TODO(macOS GH#774)
511
501
  #if TARGET_OS_OSX // [TODO(macOS GH#768)
512
502
  RCT_CUSTOM_VIEW_PROPERTY(nextKeyViewTag, NSNumber, RCTView)
@@ -11,4 +11,8 @@
11
11
 
12
12
  @interface RCTScrollContentView : RCTView
13
13
 
14
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
15
+ @property (nonatomic, assign, getter=isInverted) BOOL inverted;
16
+ #endif // ]TODO(macOS GH#774)
17
+
14
18
  @end
@@ -18,6 +18,12 @@
18
18
  #import "RCTScrollView.h"
19
19
 
20
20
  @implementation RCTScrollContentView
21
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
22
+ - (BOOL)isFlipped
23
+ {
24
+ return !self.inverted;
25
+ }
26
+ #endif // ]TODO(macOS GH#774)
21
27
 
22
28
  - (void)reactSetFrame:(CGRect)frame
23
29
  {
@@ -14,6 +14,8 @@
14
14
 
15
15
  RCT_EXPORT_MODULE()
16
16
 
17
+ RCT_EXPORT_OSX_VIEW_PROPERTY(inverted, BOOL) // TODO(macOS GH#774)
18
+
17
19
  - (RCTScrollContentView *)view
18
20
  {
19
21
  return [RCTScrollContentView new];
@@ -65,9 +65,10 @@
65
65
  @property (nonatomic, copy) RCTDirectEventBlock onScrollEndDrag;
66
66
  @property (nonatomic, copy) RCTDirectEventBlock onMomentumScrollBegin;
67
67
  @property (nonatomic, copy) RCTDirectEventBlock onMomentumScrollEnd;
68
- @property (nonatomic, copy) RCTDirectEventBlock onScrollKeyDown; // TODO(macOS GH#774)
69
68
  @property (nonatomic, copy) RCTDirectEventBlock onPreferredScrollerStyleDidChange; // TODO(macOS GH#774)
70
69
 
70
+ @property (nonatomic, copy) RCTDirectEventBlock onInvertedDidChange; // TODO(macOS GH#774)
71
+
71
72
  - (void)flashScrollIndicators; // TODO(macOS GH#774)
72
73
 
73
74
  @end
@@ -23,6 +23,8 @@
23
23
 
24
24
  #if !TARGET_OS_OSX // TODO(macOS GH#774)
25
25
  #import "RCTRefreshControl.h"
26
+ #else
27
+ #import "RCTViewKeyboardEvent.h"
26
28
  #endif // TODO(macOS GH#774)
27
29
 
28
30
  /**
@@ -43,6 +45,7 @@
43
45
  @property (nonatomic, assign) BOOL pinchGestureEnabled;
44
46
  #else // [TODO(macOS GH#774)
45
47
  + (BOOL)isCompatibleWithResponsiveScrolling;
48
+ @property (nonatomic, assign, getter=isInverted) BOOL inverted;
46
49
  @property (nonatomic, assign, getter=isScrollEnabled) BOOL scrollEnabled;
47
50
  @property (nonatomic, strong) NSPanGestureRecognizer *panGestureRecognizer;
48
51
  #endif // ]TODO(macOS GH#774)
@@ -106,9 +109,14 @@
106
109
  return YES;
107
110
  }
108
111
 
112
+ - (BOOL)isFlipped
113
+ {
114
+ return !self.inverted;
115
+ }
116
+
109
117
  - (void)scrollWheel:(NSEvent *)theEvent
110
118
  {
111
- if (!self.scrollEnabled) {
119
+ if (!self.isScrollEnabled) {
112
120
  [[self nextResponder] scrollWheel:theEvent];
113
121
  return;
114
122
  }
@@ -554,6 +562,15 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
554
562
  {
555
563
  [_scrollView setAccessibilityRole:accessibilityRole];
556
564
  }
565
+
566
+ - (void)setInverted:(BOOL)inverted
567
+ {
568
+ BOOL changed = _inverted != inverted;
569
+ _inverted = inverted;
570
+ if (changed && _onInvertedDidChange) {
571
+ _onInvertedDidChange(@{});
572
+ }
573
+ }
557
574
  #endif // ]TODO(macOS GH#774)
558
575
 
559
576
  RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
@@ -1261,74 +1278,58 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
1261
1278
  }];
1262
1279
  }
1263
1280
 
1264
- #if TARGET_OS_OSX // [TODO(macOS GH#774)
1265
-
1266
- - (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode modifierFlags:(NSEventModifierFlags)modifierFlags
1267
- {
1268
- switch (keyCode)
1269
- {
1270
- case 36:
1271
- return @"ENTER";
1272
-
1273
- case 115:
1274
- return @"HOME";
1275
-
1276
- case 116:
1277
- return @"PAGE_UP";
1278
-
1279
- case 119:
1280
- return @"END";
1281
-
1282
- case 121:
1283
- return @"PAGE_DOWN";
1284
-
1285
- case 123:
1286
- return @"LEFT_ARROW";
1287
-
1288
- case 124:
1289
- return @"RIGHT_ARROW";
1281
+ // [TODO(macOS GH#774)
1282
+ #pragma mark - Keyboard Events
1290
1283
 
1291
- case 125:
1292
- if (modifierFlags & NSEventModifierFlagOption) {
1293
- return @"OPTION_DOWN";
1294
- } else {
1295
- return @"DOWN_ARROW";
1296
- }
1284
+ #if TARGET_OS_OSX
1285
+ - (RCTViewKeyboardEvent*)keyboardEvent:(NSEvent*)event {
1286
+ BOOL keyDown = event.type == NSEventTypeKeyDown;
1287
+ NSArray<NSString *> *validKeys = keyDown ? self.validKeysDown : self.validKeysUp;
1288
+ NSString *key = [RCTViewKeyboardEvent keyFromEvent:event];
1289
+
1290
+ // Only post events for keys we care about
1291
+ if (![validKeys containsObject:key]) {
1292
+ return nil;
1293
+ }
1297
1294
 
1298
- case 126:
1299
- if (modifierFlags & NSEventModifierFlagOption) {
1300
- return @"OPTION_UP";
1301
- } else {
1302
- return @"UP_ARROW";
1303
- }
1304
- }
1305
- return @"";
1295
+ return [RCTViewKeyboardEvent keyEventFromEvent:event reactTag:self.reactTag];
1306
1296
  }
1307
1297
 
1308
- - (void)keyDown:(UIEvent*)theEvent
1309
- {
1310
- // Don't emit a scroll event if tab was pressed while the scrollview is first responder
1311
- if (!(self == [[self window] firstResponder] && theEvent.keyCode == 48)) {
1312
- NSString *keyCommand = [self keyCommandFromKeyCode:theEvent.keyCode modifierFlags:theEvent.modifierFlags];
1313
- if (![keyCommand isEqual: @""]) {
1314
- RCT_SEND_SCROLL_EVENT(onScrollKeyDown, (@{ @"key": keyCommand}));
1315
- } else {
1316
- [super keyDown:theEvent];
1298
+ - (BOOL)handleKeyboardEvent:(NSEvent *)event {
1299
+ if (event.type == NSEventTypeKeyDown ? self.onKeyDown : self.onKeyUp) {
1300
+ RCTViewKeyboardEvent *keyboardEvent = [self keyboardEvent:event];
1301
+ if (keyboardEvent) {
1302
+ [_eventDispatcher sendEvent:keyboardEvent];
1303
+ return YES;
1317
1304
  }
1318
1305
  }
1306
+ return NO;
1307
+ }
1308
+
1309
+ - (void)keyDown:(NSEvent *)event {
1310
+ if (![self handleKeyboardEvent:event]) {
1311
+ [super keyDown:event];
1312
+
1313
+ // AX: if a tab key was pressed and the first responder is currently clipped by the scroll view,
1314
+ // automatically scroll to make the view visible to make it navigable via keyboard.
1315
+ NSString *key = [RCTViewKeyboardEvent keyFromEvent:event];
1316
+ if ([key isEqualToString:@"Tab"]) {
1317
+ id firstResponder = [[self window] firstResponder];
1318
+ if ([firstResponder isKindOfClass:[NSView class]] &&
1319
+ [firstResponder isDescendantOf:[_scrollView documentView]]) {
1320
+ NSView *view = (NSView*)firstResponder;
1321
+ NSRect visibleRect = ([view superview] == [_scrollView documentView]) ? NSInsetRect(view.frame, -1, -1) :
1322
+ [view convertRect:view.frame toView:_scrollView.documentView];
1323
+ [[_scrollView documentView] scrollRectToVisible:visibleRect];
1324
+ }
1325
+ }
1326
+ }
1327
+ }
1319
1328
 
1320
- // AX: if a tab key was pressed and the first responder is currently clipped by the scroll view,
1321
- // automatically scroll to make the view visible to make it navigable via keyboard.
1322
- if ([theEvent keyCode] == 48) { //tab key
1323
- id firstResponder = [[self window] firstResponder];
1324
- if ([firstResponder isKindOfClass:[NSView class]] &&
1325
- [firstResponder isDescendantOf:[_scrollView documentView]]) {
1326
- NSView *view = (NSView*)firstResponder;
1327
- NSRect visibleRect = ([view superview] == [_scrollView documentView]) ? NSInsetRect(view.frame, -1, -1) :
1328
- [view convertRect:view.frame toView:_scrollView.documentView];
1329
- [[_scrollView documentView] scrollRectToVisible:visibleRect];
1330
- }
1331
- }
1329
+ - (void)keyUp:(NSEvent *)event {
1330
+ if (![self handleKeyboardEvent:event]) {
1331
+ [super keyUp:event];
1332
+ }
1332
1333
  }
1333
1334
 
1334
1335
  static NSString *RCTStringForScrollerStyle(NSScrollerStyle scrollerStyle) {
@@ -1343,7 +1344,8 @@ static NSString *RCTStringForScrollerStyle(NSScrollerStyle scrollerStyle) {
1343
1344
  - (void)preferredScrollerStyleDidChange:(__unused NSNotification *)notification {
1344
1345
  RCT_SEND_SCROLL_EVENT(onPreferredScrollerStyleDidChange, (@{ @"preferredScrollerStyle": RCTStringForScrollerStyle([NSScroller preferredScrollerStyle])}));
1345
1346
  }
1346
- #endif // ]TODO(macOS GH#774)
1347
+ #endif
1348
+ // ]TODO(macOS GH#774)
1347
1349
 
1348
1350
  // Note: setting several properties of UIScrollView has the effect of
1349
1351
  // resetting its contentOffset to {0, 0}. To prevent this, we generate
@@ -99,7 +99,7 @@ RCT_EXPORT_VIEW_PROPERTY(onScrollToTop, RCTDirectEventBlock)
99
99
  RCT_EXPORT_VIEW_PROPERTY(onScrollEndDrag, RCTDirectEventBlock)
100
100
  RCT_EXPORT_VIEW_PROPERTY(onMomentumScrollBegin, RCTDirectEventBlock)
101
101
  RCT_EXPORT_VIEW_PROPERTY(onMomentumScrollEnd, RCTDirectEventBlock)
102
- RCT_EXPORT_OSX_VIEW_PROPERTY(onScrollKeyDown, RCTDirectEventBlock) // TODO(macOS GH#774)
102
+ RCT_EXPORT_OSX_VIEW_PROPERTY(onInvertedDidChange, RCTDirectEventBlock) // TODO(macOS GH#774)
103
103
  RCT_EXPORT_OSX_VIEW_PROPERTY(onPreferredScrollerStyleDidChange, RCTDirectEventBlock) // TODO(macOS GH#774)
104
104
  RCT_EXPORT_VIEW_PROPERTY(inverted, BOOL)
105
105
  #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* __IPHONE_13_0 */
@@ -91,6 +91,8 @@
91
91
  - (void)reactAddControllerToClosestParent:(UIViewController *)controller;
92
92
  #endif // TODO(macOS GH#774)
93
93
 
94
+ - (void)reactViewDidMoveToWindow; // TODO(macOS GH#1412)
95
+
94
96
  /**
95
97
  * Focus manipulation.
96
98
  */
@@ -267,18 +267,17 @@
267
267
  }
268
268
  #endif // TODO(macOS GH#774)
269
269
 
270
- /**
271
- * Focus manipulation.
272
- */
273
- - (BOOL)reactIsFocusNeeded
270
+ // [TODO(macOS GH#1412)
271
+ - (void)reactViewDidMoveToWindow
274
272
  {
275
- return [(NSNumber *)objc_getAssociatedObject(self, @selector(reactIsFocusNeeded)) boolValue];
273
+ [self reactFocusIfNeeded];
276
274
  }
275
+ // TODO(macOS GH#1412)]
277
276
 
278
- - (void)setReactIsFocusNeeded:(BOOL)isFocusNeeded
279
- {
280
- objc_setAssociatedObject(self, @selector(reactIsFocusNeeded), @(isFocusNeeded), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
281
- }
277
+ /**
278
+ * Focus manipulation.
279
+ */
280
+ static __weak RCTPlatformView *_pendingFocusView; // TODO(macOS GH#1412)
282
281
 
283
282
  - (void)reactFocus
284
283
  {
@@ -287,19 +286,23 @@
287
286
  #else
288
287
  if (![self becomeFirstResponder]) {
289
288
  #endif // TODO(macOS GH#774)]
290
- self.reactIsFocusNeeded = YES;
291
- }
289
+ // [TODO(macOS GH#1412)
290
+ _pendingFocusView = self;
291
+ } else {
292
+ _pendingFocusView = nil;
293
+ }
294
+ // TODO(macOS GH#1412)]
292
295
  }
293
296
 
294
297
  - (void)reactFocusIfNeeded
295
298
  {
296
- if (self.reactIsFocusNeeded) {
299
+ if ([self isEqual:_pendingFocusView]) { // TODO(macOS GH#1412)
297
300
  #if TARGET_OS_OSX // [TODO(macOS GH#774)
298
301
  if ([[self window] makeFirstResponder:self]) {
299
302
  #else
300
303
  if ([self becomeFirstResponder]) {
301
304
  #endif // TODO(macOS GH#774)]
302
- self.reactIsFocusNeeded = NO;
305
+ _pendingFocusView = nil; // TODO(macOS GH#1412)
303
306
  }
304
307
  }
305
308
  }
@@ -313,6 +316,12 @@
313
316
  #else
314
317
  [self resignFirstResponder];
315
318
  #endif // TODO(macOS GH#774)]
319
+
320
+ // [TODO(macOS GH#1412)
321
+ if ([self isEqual:_pendingFocusView]) {
322
+ _pendingFocusView = nil;
323
+ }
324
+ // TODO(macOS GH#1412)]
316
325
  }
317
326
 
318
327
  #pragma mark - Layout
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.0.0-a598ee4ef
1
+ VERSION_NAME=0.0.0-a80cca6c6
2
2
  GROUP=com.facebook.react
3
3
 
4
4
  POM_NAME=ReactNative
@@ -22,5 +22,5 @@ public class ReactNativeVersion {
22
22
  "major", 0,
23
23
  "minor", 0,
24
24
  "patch", 0,
25
- "prerelease", "a598ee4ef");
25
+ "prerelease", "a80cca6c6");
26
26
  }
@@ -29,7 +29,7 @@ Pod::Spec.new do |s|
29
29
  s.homepage = "https://reactnative.dev/"
30
30
  s.license = package["license"]
31
31
  s.author = "Facebook, Inc. and its affiliates"
32
- s.platforms = { :ios => "11.0" }
32
+ s.platforms = { :ios => "11.0", :osx => "10.15" } # TODO(macOS GH#774)
33
33
  s.source = source
34
34
  s.source_files = "dummyFile.cpp"
35
35
  s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES",
@@ -25,7 +25,7 @@ Pod::Spec.new do |s|
25
25
  s.homepage = "https://reactnative.dev/"
26
26
  s.license = package["license"]
27
27
  s.author = "Facebook, Inc. and its affiliates"
28
- s.platforms = { :ios => "11.0" }
28
+ s.platforms = { :ios => "11.0", :osx => "10.15" } # TODO(macOS GH#774)
29
29
  s.source = source
30
30
  s.source_files = "dummyFile.cpp"
31
31
  s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES",
@@ -22,7 +22,7 @@ constexpr struct {
22
22
  int32_t Major = 0;
23
23
  int32_t Minor = 0;
24
24
  int32_t Patch = 0;
25
- std::string_view Prerelease = "a598ee4ef";
25
+ std::string_view Prerelease = "a80cca6c6";
26
26
  } ReactNativeVersion;
27
27
 
28
28
  } // namespace facebook::react
@@ -27,7 +27,7 @@ Pod::Spec.new do |s|
27
27
  s.homepage = "https://reactnative.dev/"
28
28
  s.license = package["license"]
29
29
  s.author = "Facebook, Inc. and its affiliates"
30
- s.platforms = { :ios => "11.0", :tvos => "11.0" }
30
+ s.platforms = { :ios => "11.0", :osx => "10.15" } # TODO(macOS GH#774)
31
31
  s.source = source
32
32
  s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
33
33
  s.source_files = "**/*.{m,mm,cpp,h}"
@@ -10,7 +10,7 @@
10
10
  #include <react/debug/react_native_assert.h>
11
11
 
12
12
  #if defined(__OBJC__) && defined(__cplusplus)
13
- #if TARGET_OS_MAC && TARGET_OS_IPHONE
13
+ #if TARGET_OS_MAC
14
14
 
15
15
  #include <memory>
16
16
 
@@ -7,8 +7,7 @@
7
7
 
8
8
  #include "ManagedObjectWrapper.h"
9
9
 
10
- #if defined(__OBJC__) && defined(__cplusplus)
11
- #if TARGET_OS_MAC && TARGET_OS_IPHONE
10
+ #if TARGET_OS_MAC
12
11
 
13
12
  namespace facebook {
14
13
  namespace react {
@@ -35,4 +34,3 @@ void wrappedManagedObjectDeleter(void *cfPointer) noexcept
35
34
  @end
36
35
 
37
36
  #endif
38
- #endif
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.0.0-a598ee4ef",
3
+ "version": "0.0.0-a80cca6c6",
4
4
  "bin": "./cli.js",
5
5
  "description": "React Native for macOS",
6
6
  "license": "MIT",