react-native-macos 0.0.0-b9fb2dd1a → 0.0.0-bb8a035db

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 (58) hide show
  1. package/Libraries/Components/ScrollView/ScrollView.js +11 -45
  2. package/Libraries/Components/TextInput/TextInput.js +72 -1
  3. package/Libraries/Components/View/ReactNativeStyleAttributes.js +1 -0
  4. package/Libraries/Components/View/ReactNativeViewViewConfig.js +1 -0
  5. package/Libraries/Components/View/ReactNativeViewViewConfigMacOS.js +3 -3
  6. package/Libraries/Components/View/ViewPropTypes.js +10 -6
  7. package/Libraries/Core/ReactNativeVersion.js +1 -1
  8. package/Libraries/LinkingIOS/RCTLinkingManager.h +1 -0
  9. package/Libraries/LinkingIOS/macos/RCTLinkingManager.mm +12 -5
  10. package/Libraries/Lists/FlatList.js +25 -1
  11. package/Libraries/Lists/VirtualizedList.js +106 -113
  12. package/Libraries/Lists/VirtualizedSectionList.js +9 -5
  13. package/Libraries/StyleSheet/StyleSheetTypes.js +25 -0
  14. package/Libraries/Text/RCTTextAttributes.m +5 -5
  15. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.h +3 -0
  16. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.m +6 -1
  17. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.m +11 -0
  18. package/Libraries/Text/TextInput/Multiline/RCTUITextView.h +1 -0
  19. package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +69 -2
  20. package/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +7 -1
  21. package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +12 -3
  22. package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +1 -0
  23. package/Libraries/Text/TextInput/RCTBaseTextInputView.h +4 -1
  24. package/Libraries/Text/TextInput/RCTBaseTextInputView.m +97 -2
  25. package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +6 -0
  26. package/Libraries/Text/TextInput/Singleline/RCTUITextField.m +40 -0
  27. package/Libraries/Types/CoreEventTypes.js +0 -1
  28. package/React/Base/RCTConvert.m +9 -5
  29. package/React/Base/RCTTouchHandler.m +4 -0
  30. package/React/Base/RCTUtils.m +6 -3
  31. package/React/Base/RCTVersion.m +1 -1
  32. package/React/Base/macOS/RCTUIKit.m +7 -0
  33. package/React/CoreModules/RCTPerfMonitor.mm +1 -1
  34. package/React/Modules/RCTUIManager.m +2 -1
  35. package/React/Views/RCTActivityIndicatorView.m +2 -1
  36. package/React/Views/RCTCursor.h +39 -0
  37. package/React/Views/RCTCursor.m +105 -0
  38. package/React/Views/RCTView.h +12 -0
  39. package/React/Views/RCTView.m +110 -42
  40. package/React/Views/RCTViewKeyboardEvent.m +9 -1
  41. package/React/Views/RCTViewManager.m +17 -12
  42. package/React/Views/ScrollView/RCTScrollContentView.h +4 -0
  43. package/React/Views/ScrollView/RCTScrollContentView.m +18 -0
  44. package/React/Views/ScrollView/RCTScrollContentViewManager.m +2 -0
  45. package/React/Views/ScrollView/RCTScrollView.h +2 -1
  46. package/React/Views/ScrollView/RCTScrollView.m +69 -62
  47. package/React/Views/ScrollView/RCTScrollViewManager.m +1 -1
  48. package/React/Views/UIView+React.h +2 -0
  49. package/React/Views/UIView+React.m +22 -13
  50. package/ReactAndroid/gradle.properties +1 -1
  51. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  52. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  53. package/package.json +1 -1
  54. package/scripts/generate-artifacts.js +21 -17
  55. package/scripts/react_native_pods.rb +0 -3
  56. package/template/Gemfile.lock +5 -5
  57. package/template/package.json +1 -1
  58. package/third-party-podspecs/boost-for-react-native.podspec +0 -20
@@ -10,6 +10,7 @@
10
10
  #if !TARGET_OS_OSX // [TODO(macOS GH#774)
11
11
  #import <UIKit/UIGestureRecognizerSubclass.h>
12
12
  #endif // ]TODO(macOS GH#774)
13
+ #import <React/RCTUITextField.h> // TODO(macOS GH#774)
13
14
 
14
15
  #import "RCTAssert.h"
15
16
  #import "RCTBridge.h"
@@ -138,6 +139,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)coder)
138
139
  _shouldSendMouseUpOnSystemBehalf = [(NSControl*)targetView isEnabled];
139
140
  } else if ([targetView isKindOfClass:[NSText class]]) {
140
141
  _shouldSendMouseUpOnSystemBehalf = [(NSText*)targetView isSelectable];
142
+ }
143
+ else if ([targetView.superview isKindOfClass:[RCTUITextField class]]) {
144
+ _shouldSendMouseUpOnSystemBehalf = [(RCTUITextField*)targetView.superview isSelectable];
141
145
  } else {
142
146
  _shouldSendMouseUpOnSystemBehalf = NO;
143
147
  }
@@ -905,9 +905,12 @@ UIImage *__nullable RCTImageFromLocalAssetURL(NSURL *imageURL)
905
905
  }
906
906
  #if !TARGET_OS_OSX // TODO(macOS GH#774)
907
907
  image = [UIImage imageWithContentsOfFile:filePath];
908
- #else // TODO(macOS GH#774)
909
- image = [[NSImage alloc] initWithContentsOfFile:filePath]; // TODO(macOS GH#774)
910
- #endif // TODO(macOS GH#774)
908
+ #else // [TODO(macOS GH#774)
909
+ // macOS keeps file handles in open state for lifetime of image if "initWithContentsOfFile:" is used with path inside app bundle
910
+ // Workaround is to load file in data and then convert data to image
911
+ NSData *data = [NSData dataWithContentsOfFile:filePath];
912
+ image = [[NSImage alloc] initWithData:data];
913
+ #endif // ]TODO(macOS GH#774)
911
914
  }
912
915
  }
913
916
 
@@ -28,7 +28,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
28
28
  RCTVersionMajor: @(0),
29
29
  RCTVersionMinor: @(0),
30
30
  RCTVersionPatch: @(0),
31
- RCTVersionPrerelease: @"b9fb2dd1a",
31
+ RCTVersionPrerelease: @"bb8a035db",
32
32
  };
33
33
  });
34
34
  return __rnVersion;
@@ -423,6 +423,13 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
423
423
  }
424
424
  }
425
425
 
426
+ // We purposely don't use RCTCursor for the parameter type here because it would introduce an import cycle:
427
+ // RCTUIKit > RCTCursor > RCTConvert > RCTUIKit
428
+ - (void)setCursor:(NSInteger)cursor
429
+ {
430
+ // This method is required to be defined due to [RCTVirtualTextViewManager view] returning a RCTUIView.
431
+ }
432
+
426
433
  @end
427
434
 
428
435
  // RCTUIScrollView
@@ -176,7 +176,7 @@ RCT_EXPORT_MODULE()
176
176
  {
177
177
  if (!_devMenuItem) {
178
178
  __weak __typeof__(self) weakSelf = self;
179
- __weak RCTDevSettings *devSettings = [self->_moduleRegistry moduleForName:"DevSettings"];
179
+ __weak RCTDevSettings *devSettings = [[self bridge] devSettings]; // TODO(macOS GH#774)
180
180
  if (devSettings.isPerfMonitorShown) {
181
181
  [weakSelf show];
182
182
  }
@@ -332,12 +332,13 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
332
332
  _viewRegistry[reactTag] = rootView;
333
333
 
334
334
  // Register shadow view
335
+ RCTRootShadowView *shadowView = [RCTRootShadowView new]; // TODO(macOS GH#774) - do this early to prevent RCTI18nUtil deadlock
336
+
335
337
  RCTExecuteOnUIManagerQueue(^{
336
338
  if (!self->_viewRegistry) {
337
339
  return;
338
340
  }
339
341
 
340
- RCTRootShadowView *shadowView = [RCTRootShadowView new];
341
342
  shadowView.availableSize = availableSize;
342
343
  shadowView.reactTag = reactTag;
343
344
  shadowView.viewName = NSStringFromClass([rootView class]);
@@ -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;
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright (c) Facebook, Inc. and its 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
+
8
+ #import <React/RCTConvert.h>
9
+
10
+ typedef NS_ENUM(NSInteger, RCTCursor) {
11
+ RCTCursorAuto,
12
+ RCTCursorArrow,
13
+ RCTCursorIBeam,
14
+ RCTCursorCrosshair,
15
+ RCTCursorClosedHand,
16
+ RCTCursorOpenHand,
17
+ RCTCursorPointingHand,
18
+ RCTCursorResizeLeft,
19
+ RCTCursorResizeRight,
20
+ RCTCursorResizeLeftRight,
21
+ RCTCursorResizeUp,
22
+ RCTCursorResizeDown,
23
+ RCTCursorResizeUpDown,
24
+ RCTCursorDisappearingItem,
25
+ RCTCursorIBeamCursorForVerticalLayout,
26
+ RCTCursorOperationNotAllowed,
27
+ RCTCursorDragLink,
28
+ RCTCursorDragCopy,
29
+ RCTCursorContextualMenu,
30
+ };
31
+
32
+ @interface RCTConvert (RCTCursor)
33
+
34
+ + (RCTCursor)RCTCursor:(id)json;
35
+ #if TARGET_OS_OSX // TODO(macOS GH#774)
36
+ + (NSCursor *)NSCursor:(RCTCursor)rctCursor;
37
+ #endif // ]TODO(macOS GH#774)
38
+
39
+ @end
@@ -0,0 +1,105 @@
1
+ /*
2
+ * Copyright (c) Facebook, Inc. and its 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
+
8
+ #import <React/RCTCursor.h>
9
+
10
+ @implementation RCTConvert (RCTCursor)
11
+
12
+ RCT_ENUM_CONVERTER(
13
+ RCTCursor,
14
+ (@{
15
+ @"alias" : @(RCTCursorDragLink),
16
+ @"auto" : @(RCTCursorAuto),
17
+ @"col-resize" : @(RCTCursorResizeLeftRight),
18
+ @"context-menu" : @(RCTCursorContextualMenu),
19
+ @"copy" : @(RCTCursorDragCopy),
20
+ @"crosshair" : @(RCTCursorCrosshair),
21
+ @"default" : @(RCTCursorArrow),
22
+ @"disappearing-item" : @(RCTCursorDisappearingItem),
23
+ @"e-resize" : @(RCTCursorResizeRight),
24
+ @"grab" : @(RCTCursorOpenHand),
25
+ @"grabbing" : @(RCTCursorClosedHand),
26
+ @"n-resize" : @(RCTCursorResizeUp),
27
+ @"no-drop" : @(RCTCursorOperationNotAllowed),
28
+ @"not-allowed" : @(RCTCursorOperationNotAllowed),
29
+ @"pointer" : @(RCTCursorPointingHand),
30
+ @"row-resize" : @(RCTCursorResizeUpDown),
31
+ @"s-resize" : @(RCTCursorResizeDown),
32
+ @"text" : @(RCTCursorIBeam),
33
+ @"vertical-text" : @(RCTCursorIBeamCursorForVerticalLayout),
34
+ @"w-resize" : @(RCTCursorResizeLeft),
35
+ }),
36
+ RCTCursorAuto,
37
+ integerValue)
38
+
39
+ #if TARGET_OS_OSX // TODO(macOS GH#774)
40
+ + (NSCursor *)NSCursor:(RCTCursor)rctCursor
41
+ {
42
+ NSCursor *cursor;
43
+
44
+ switch (rctCursor) {
45
+ case RCTCursorArrow:
46
+ cursor = [NSCursor arrowCursor];
47
+ break;
48
+ case RCTCursorClosedHand:
49
+ cursor = [NSCursor closedHandCursor];
50
+ break;
51
+ case RCTCursorContextualMenu:
52
+ cursor = [NSCursor contextualMenuCursor];
53
+ break;
54
+ case RCTCursorCrosshair:
55
+ cursor = [NSCursor crosshairCursor];
56
+ break;
57
+ case RCTCursorDisappearingItem:
58
+ cursor = [NSCursor disappearingItemCursor];
59
+ break;
60
+ case RCTCursorDragCopy:
61
+ cursor = [NSCursor dragCopyCursor];
62
+ break;
63
+ case RCTCursorDragLink:
64
+ cursor = [NSCursor dragLinkCursor];
65
+ break;
66
+ case RCTCursorIBeam:
67
+ cursor = [NSCursor IBeamCursor];
68
+ break;
69
+ case RCTCursorIBeamCursorForVerticalLayout:
70
+ cursor = [NSCursor IBeamCursorForVerticalLayout];
71
+ break;
72
+ case RCTCursorOpenHand:
73
+ cursor = [NSCursor openHandCursor];
74
+ break;
75
+ case RCTCursorOperationNotAllowed:
76
+ cursor = [NSCursor operationNotAllowedCursor];
77
+ break;
78
+ case RCTCursorPointingHand:
79
+ cursor = [NSCursor pointingHandCursor];
80
+ break;
81
+ case RCTCursorResizeDown:
82
+ cursor = [NSCursor resizeDownCursor];
83
+ break;
84
+ case RCTCursorResizeLeft:
85
+ cursor = [NSCursor resizeLeftCursor];
86
+ break;
87
+ case RCTCursorResizeLeftRight:
88
+ cursor = [NSCursor resizeLeftRightCursor];
89
+ break;
90
+ case RCTCursorResizeRight:
91
+ cursor = [NSCursor resizeRightCursor];
92
+ break;
93
+ case RCTCursorResizeUp:
94
+ cursor = [NSCursor resizeUpCursor];
95
+ break;
96
+ case RCTCursorResizeUpDown:
97
+ cursor = [NSCursor resizeUpDownCursor];
98
+ break;
99
+ }
100
+
101
+ return cursor;
102
+ }
103
+ #endif // ]TODO(macOS GH#774)
104
+
105
+ @end
@@ -12,6 +12,10 @@
12
12
  #import <React/RCTEventDispatcherProtocol.h> // TODO(OSS Candidate ISS#2710739)
13
13
  #import <React/RCTPointerEvents.h>
14
14
 
15
+ #if TARGET_OS_OSX // TODO(macOS GH#774)
16
+ #import <React/RCTCursor.h>
17
+ #endif // TODO(macOS GH#774)
18
+
15
19
  #if !TARGET_OS_OSX // TODO(macOS GH#774)
16
20
  extern const UIAccessibilityTraits SwitchAccessibilityTrait;
17
21
  #endif // TODO(macOS GH#774)
@@ -27,6 +31,7 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
27
31
  - (BOOL)resignFirstResponder;
28
32
 
29
33
  #if TARGET_OS_OSX
34
+ - (NSDictionary*)dataTransferInfoFromPasteboard:(NSPasteboard*)pasteboard;
30
35
  - (BOOL)handleKeyboardEvent:(NSEvent *)event;
31
36
  #endif
32
37
  // ]TODO(OSS Candidate ISS#2710739)
@@ -123,6 +128,7 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
123
128
  /**
124
129
  * macOS Properties
125
130
  */
131
+ @property (nonatomic, assign) RCTCursor cursor;
126
132
 
127
133
  @property (nonatomic, assign) CATransform3D transform3D;
128
134
 
@@ -139,6 +145,12 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
139
145
  @property (nonatomic, copy) RCTDirectEventBlock onKeyUp;
140
146
  @property (nonatomic, copy) NSArray<NSString*> *validKeysDown;
141
147
  @property (nonatomic, copy) NSArray<NSString*> *validKeysUp;
148
+
149
+ // Shadow Properties
150
+ @property (nonatomic, strong) NSColor *shadowColor;
151
+ @property (nonatomic, assign) CGFloat shadowOpacity;
152
+ @property (nonatomic, assign) CGFloat shadowRadius;
153
+ @property (nonatomic, assign) CGSize shadowOffset;
142
154
  #endif // ]TODO(macOS GH#774)
143
155
 
144
156
  /**
@@ -165,6 +165,7 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // TODO(macOS I
165
165
  _hitTestEdgeInsets = UIEdgeInsetsZero;
166
166
  #if TARGET_OS_OSX // TODO(macOS GH#774)
167
167
  _transform3D = CATransform3DIdentity;
168
+ _shadowColor = nil;
168
169
  #endif // TODO(macOS GH#774)
169
170
 
170
171
  _backgroundColor = super.backgroundColor;
@@ -716,20 +717,49 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused)
716
717
  #endif // TODO(macOS GH#774)
717
718
 
718
719
  #if TARGET_OS_OSX // [TODO(macOS GH#774)
719
- // Workaround AppKit issue with directly manipulating the view layer's shadow.
720
- - (NSShadow*)shadow
720
+ - (void)setShadowColor:(NSColor *)shadowColor
721
721
  {
722
- CALayer *layer = self.layer;
723
- NSShadow *shadow = nil;
722
+ if (_shadowColor != shadowColor)
723
+ {
724
+ _shadowColor = shadowColor;
725
+ [self didUpdateShadow];
726
+ }
727
+ }
724
728
 
725
- if (layer.shadowColor != nil && layer.shadowOpacity > 0) {
726
- shadow = [NSShadow new];
729
+ - (void)setShadowOffset:(CGSize)shadowOffset
730
+ {
731
+ if (!CGSizeEqualToSize(_shadowOffset, shadowOffset))
732
+ {
733
+ _shadowOffset = shadowOffset;
734
+ [self didUpdateShadow];
735
+ }
736
+ }
727
737
 
728
- shadow.shadowColor = [[NSColor colorWithCGColor:layer.shadowColor] colorWithAlphaComponent:layer.shadowOpacity];
729
- shadow.shadowOffset = layer.shadowOffset;
730
- shadow.shadowBlurRadius = layer.shadowRadius;
731
- }
732
- return shadow;
738
+ - (void)setShadowOpacity:(CGFloat)shadowOpacity
739
+ {
740
+ if (_shadowOpacity != shadowOpacity)
741
+ {
742
+ _shadowOpacity = shadowOpacity;
743
+ [self didUpdateShadow];
744
+ }
745
+ }
746
+
747
+ - (void)setShadowRadius:(CGFloat)shadowRadius
748
+ {
749
+ if (_shadowRadius != shadowRadius)
750
+ {
751
+ _shadowRadius = shadowRadius;
752
+ [self didUpdateShadow];
753
+ }
754
+ }
755
+
756
+ -(void)didUpdateShadow
757
+ {
758
+ NSShadow *shadow = [NSShadow new];
759
+ shadow.shadowColor = [[self shadowColor] colorWithAlphaComponent:[self shadowOpacity]];
760
+ shadow.shadowOffset = [self shadowOffset];
761
+ shadow.shadowBlurRadius = [self shadowRadius];
762
+ [self setShadow:shadow];
733
763
  }
734
764
 
735
765
  - (void)viewDidMoveToWindow
@@ -749,6 +779,9 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused)
749
779
  name:NSViewBoundsDidChangeNotification
750
780
  object:[[self enclosingScrollView] contentView]];
751
781
  }
782
+
783
+ [self reactViewDidMoveToWindow]; // TODO(macOS GH#1412)
784
+
752
785
  [super viewDidMoveToWindow];
753
786
  }
754
787
 
@@ -758,16 +791,16 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused)
758
791
  // the mouseExited: event does not get called on the view where mouseEntered: was previously called.
759
792
  // This creates an unnatural pairing of mouse enter and exit events and can cause problems.
760
793
  // We therefore explicitly check for this here and handle them by calling the appropriate callbacks.
761
-
794
+
762
795
  if (!_hasMouseOver && self.onMouseEnter)
763
796
  {
764
797
  NSPoint locationInWindow = [[self window] mouseLocationOutsideOfEventStream];
765
798
  NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
766
-
799
+
767
800
  if (NSPointInRect(locationInView, [self bounds]))
768
801
  {
769
802
  _hasMouseOver = YES;
770
-
803
+
771
804
  [self sendMouseEventWithBlock:self.onMouseEnter
772
805
  locationInfo:[self locationInfoFromDraggingLocation:locationInWindow]
773
806
  modifierFlags:0
@@ -778,11 +811,11 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused)
778
811
  {
779
812
  NSPoint locationInWindow = [[self window] mouseLocationOutsideOfEventStream];
780
813
  NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
781
-
814
+
782
815
  if (!NSPointInRect(locationInView, [self bounds]))
783
816
  {
784
817
  _hasMouseOver = NO;
785
-
818
+
786
819
  [self sendMouseEventWithBlock:self.onMouseLeave
787
820
  locationInfo:[self locationInfoFromDraggingLocation:locationInWindow]
788
821
  modifierFlags:0
@@ -1381,6 +1414,15 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1381
1414
  #pragma mark - macOS Event Handler
1382
1415
 
1383
1416
  #if TARGET_OS_OSX
1417
+ - (void)resetCursorRects
1418
+ {
1419
+ [self discardCursorRects];
1420
+ NSCursor *cursor = [RCTConvert NSCursor:self.cursor];
1421
+ if (cursor) {
1422
+ [self addCursorRect:self.bounds cursor:cursor];
1423
+ }
1424
+ }
1425
+
1384
1426
  - (void)setOnDoubleClick:(RCTDirectEventBlock)block
1385
1427
  {
1386
1428
  if (_onDoubleClick != block) {
@@ -1408,7 +1450,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1408
1450
  if (_trackingArea) {
1409
1451
  [self removeTrackingArea:_trackingArea];
1410
1452
  }
1411
-
1453
+
1412
1454
  if (self.onMouseEnter || self.onMouseLeave) {
1413
1455
  _trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds
1414
1456
  options:NSTrackingActiveAlways|NSTrackingMouseEnteredAndExited
@@ -1416,7 +1458,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1416
1458
  userInfo:nil];
1417
1459
  [self addTrackingArea:_trackingArea];
1418
1460
  }
1419
-
1461
+
1420
1462
  [super updateTrackingAreas];
1421
1463
  }
1422
1464
 
@@ -1442,7 +1484,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1442
1484
  {
1443
1485
  NSPoint locationInWindow = event.locationInWindow;
1444
1486
  NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
1445
-
1487
+
1446
1488
  return @{@"screenX": @(locationInWindow.x),
1447
1489
  @"screenY": @(locationInWindow.y),
1448
1490
  @"clientX": @(locationInView.x),
@@ -1473,25 +1515,21 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1473
1515
  if (modifierFlags & NSEventModifierFlagCommand) {
1474
1516
  body[@"metaKey"] = @YES;
1475
1517
  }
1476
-
1518
+
1477
1519
  if (locationInfo) {
1478
1520
  [body addEntriesFromDictionary:locationInfo];
1479
1521
  }
1480
-
1522
+
1481
1523
  if (additionalData) {
1482
1524
  [body addEntriesFromDictionary:additionalData];
1483
1525
  }
1484
-
1526
+
1485
1527
  block(body);
1486
1528
  }
1487
1529
 
1488
- - (NSDictionary*)dataTransferInfoFromPastboard:(NSPasteboard*)pastboard
1530
+ - (NSDictionary*)dataTransferInfoFromPasteboard:(NSPasteboard*)pasteboard
1489
1531
  {
1490
- if (![pastboard.types containsObject:NSFilenamesPboardType]) {
1491
- return @{};
1492
- }
1493
-
1494
- NSArray *fileNames = [pastboard propertyListForType:NSFilenamesPboardType];
1532
+ NSArray *fileNames = [pasteboard propertyListForType:NSFilenamesPboardType] ?: @[];
1495
1533
  NSMutableArray *files = [[NSMutableArray alloc] initWithCapacity:fileNames.count];
1496
1534
  NSMutableArray *items = [[NSMutableArray alloc] initWithCapacity:fileNames.count];
1497
1535
  NSMutableArray *types = [[NSMutableArray alloc] initWithCapacity:fileNames.count];
@@ -1511,27 +1549,57 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1511
1549
  MIMETypeString = (__bridge_transfer NSString *)MIMEType;
1512
1550
  }
1513
1551
  }
1514
-
1552
+
1515
1553
  NSNumber *fileSizeValue = nil;
1516
1554
  NSError *fileSizeError = nil;
1517
1555
  BOOL success = [fileURL getResourceValue:&fileSizeValue
1518
1556
  forKey:NSURLFileSizeKey
1519
1557
  error:&fileSizeError];
1520
-
1558
+
1559
+ NSNumber *width = nil;
1560
+ NSNumber *height = nil;
1561
+ if ([MIMETypeString hasPrefix:@"image/"]) {
1562
+ NSImage *image = [[NSImage alloc] initWithContentsOfURL:fileURL];
1563
+ width = @(image.size.width);
1564
+ height = @(image.size.height);
1565
+ }
1566
+
1521
1567
  [files addObject:@{@"name": RCTNullIfNil(fileURL.lastPathComponent),
1522
1568
  @"type": RCTNullIfNil(MIMETypeString),
1523
- @"uri": RCTNullIfNil(fileURL.absoluteString),
1524
- @"size": success ? fileSizeValue : (id)kCFNull
1569
+ @"uri": RCTNullIfNil(fileURL.path),
1570
+ @"size": success ? fileSizeValue : (id)kCFNull,
1571
+ @"width": RCTNullIfNil(width),
1572
+ @"height": RCTNullIfNil(height)
1525
1573
  }];
1526
-
1574
+
1527
1575
  [items addObject:@{@"kind": @"file",
1528
1576
  @"type": RCTNullIfNil(MIMETypeString),
1529
1577
  }];
1530
-
1578
+
1531
1579
  [types addObject:RCTNullIfNil(MIMETypeString)];
1532
1580
  }
1533
1581
  }
1534
-
1582
+
1583
+ NSPasteboardType imageType = [pasteboard availableTypeFromArray:@[NSPasteboardTypePNG, NSPasteboardTypeTIFF]];
1584
+ if (imageType && fileNames.count == 0) {
1585
+ NSString *MIMETypeString = imageType == NSPasteboardTypePNG ? @"image/png" : @"image/tiff";
1586
+ NSData *imageData = [pasteboard dataForType:imageType];
1587
+ NSImage *image = [[NSImage alloc] initWithData:imageData];
1588
+
1589
+ [files addObject:@{@"type": RCTNullIfNil(MIMETypeString),
1590
+ @"uri": RCTDataURL(MIMETypeString, imageData).absoluteString,
1591
+ @"size": @(imageData.length),
1592
+ @"width": @(image.size.width),
1593
+ @"height": @(image.size.height),
1594
+ }];
1595
+
1596
+ [items addObject:@{@"kind": @"image",
1597
+ @"type": RCTNullIfNil(MIMETypeString),
1598
+ }];
1599
+
1600
+ [types addObject:RCTNullIfNil(MIMETypeString)];
1601
+ }
1602
+
1535
1603
  return @{@"dataTransfer": @{@"files": files,
1536
1604
  @"items": items,
1537
1605
  @"types": types}};
@@ -1540,7 +1608,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1540
1608
  - (NSDictionary*)locationInfoFromDraggingLocation:(NSPoint)locationInWindow
1541
1609
  {
1542
1610
  NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
1543
-
1611
+
1544
1612
  return @{@"screenX": @(locationInWindow.x),
1545
1613
  @"screenY": @(locationInWindow.y),
1546
1614
  @"clientX": @(locationInView.x),
@@ -1552,13 +1620,13 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1552
1620
  {
1553
1621
  NSPasteboard *pboard = sender.draggingPasteboard;
1554
1622
  NSDragOperation sourceDragMask = sender.draggingSourceOperationMask;
1555
-
1623
+
1556
1624
  [self sendMouseEventWithBlock:self.onDragEnter
1557
1625
  locationInfo:[self locationInfoFromDraggingLocation:sender.draggingLocation]
1558
1626
  modifierFlags:0
1559
- additionalData:[self dataTransferInfoFromPastboard:pboard]];
1560
-
1561
- if ([pboard.types containsObject:NSFilenamesPboardType]) {
1627
+ additionalData:[self dataTransferInfoFromPasteboard:pboard]];
1628
+
1629
+ if ([pboard availableTypeFromArray:self.registeredDraggedTypes]) {
1562
1630
  if (sourceDragMask & NSDragOperationLink) {
1563
1631
  return NSDragOperationLink;
1564
1632
  } else if (sourceDragMask & NSDragOperationCopy) {
@@ -1573,7 +1641,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1573
1641
  [self sendMouseEventWithBlock:self.onDragLeave
1574
1642
  locationInfo:[self locationInfoFromDraggingLocation:sender.draggingLocation]
1575
1643
  modifierFlags:0
1576
- additionalData:[self dataTransferInfoFromPastboard:sender.draggingPasteboard]];
1644
+ additionalData:[self dataTransferInfoFromPasteboard:sender.draggingPasteboard]];
1577
1645
  }
1578
1646
 
1579
1647
  - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
@@ -1581,7 +1649,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1581
1649
  [self sendMouseEventWithBlock:self.onDrop
1582
1650
  locationInfo:[self locationInfoFromDraggingLocation:sender.draggingLocation]
1583
1651
  modifierFlags:0
1584
- additionalData:[self dataTransferInfoFromPastboard:[sender draggingPasteboard]]];
1652
+ additionalData:[self dataTransferInfoFromPasteboard:sender.draggingPasteboard]];
1585
1653
  return YES;
1586
1654
  }
1587
1655
  #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
  }
@@ -21,6 +21,10 @@
21
21
  #import "RCTView.h"
22
22
  #import "UIView+React.h"
23
23
 
24
+ #if TARGET_OS_OSX // TODO(macOS GH#774)
25
+ #import "RCTCursor.h"
26
+ #endif // TODO(macOS GH774)
27
+
24
28
  #if !TARGET_OS_OSX // TODO(macOS GH#774)
25
29
  @implementation RCTConvert (UIAccessibilityTraits)
26
30
 
@@ -51,6 +55,7 @@ RCT_MULTI_ENUM_CONVERTER(
51
55
  // a set of RN accessibilityTraits are macOS specific accessiblity roles and map to nothing on iOS:
52
56
  @"disclosure" : @(UIAccessibilityTraitNone),
53
57
  @"group" : @(UIAccessibilityTraitNone),
58
+ @"table": @(UIAccessibilityTraitNone),
54
59
  // ]TODO(macOS GH#774)
55
60
  @"alert" : @(UIAccessibilityTraitNone),
56
61
  @"checkbox" : @(UIAccessibilityTraitNone),
@@ -191,10 +196,19 @@ RCT_REMAP_VIEW_PROPERTY(opacity, alpha, CGFloat)
191
196
  #else // [TODO(macOS GH#774)
192
197
  RCT_REMAP_VIEW_PROPERTY(opacity, alphaValue, CGFloat)
193
198
  #endif // ]TODO(macOS GH#774)
199
+
200
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
194
201
  RCT_REMAP_VIEW_PROPERTY(shadowColor, layer.shadowColor, CGColor)
195
202
  RCT_REMAP_VIEW_PROPERTY(shadowOffset, layer.shadowOffset, CGSize)
196
203
  RCT_REMAP_VIEW_PROPERTY(shadowOpacity, layer.shadowOpacity, float)
197
204
  RCT_REMAP_VIEW_PROPERTY(shadowRadius, layer.shadowRadius, CGFloat)
205
+ #else // [TODO(macOS GH#774)
206
+ RCT_EXPORT_VIEW_PROPERTY(shadowColor, NSColor)
207
+ RCT_EXPORT_VIEW_PROPERTY(shadowOffset, CGSize)
208
+ RCT_EXPORT_VIEW_PROPERTY(shadowOpacity, CGFloat)
209
+ RCT_EXPORT_VIEW_PROPERTY(shadowRadius, CGFloat)
210
+ #endif // ]TODO(macOS GH#774)
211
+
198
212
  RCT_REMAP_VIEW_PROPERTY(needsOffscreenAlphaCompositing, layer.allowsGroupOpacity, BOOL)
199
213
  RCT_CUSTOM_VIEW_PROPERTY(overflow, YGOverflow, RCTView)
200
214
  {
@@ -471,6 +485,7 @@ RCT_EXPORT_VIEW_PROPERTY(onBlur, RCTBubblingEventBlock)
471
485
  #if TARGET_OS_OSX // [TODO(macOS GH#774)
472
486
  #pragma mark - macOS properties
473
487
 
488
+ RCT_EXPORT_VIEW_PROPERTY(cursor, RCTCursor)
474
489
  RCT_EXPORT_VIEW_PROPERTY(onDoubleClick, RCTDirectEventBlock)
475
490
  RCT_EXPORT_VIEW_PROPERTY(onClick, RCTDirectEventBlock)
476
491
  RCT_EXPORT_VIEW_PROPERTY(onMouseEnter, RCTDirectEventBlock)
@@ -480,18 +495,8 @@ RCT_EXPORT_VIEW_PROPERTY(onDragLeave, RCTDirectEventBlock)
480
495
  RCT_EXPORT_VIEW_PROPERTY(onDrop, RCTDirectEventBlock)
481
496
  RCT_EXPORT_VIEW_PROPERTY(onKeyDown, RCTDirectEventBlock) // macOS keyboard events
482
497
  RCT_EXPORT_VIEW_PROPERTY(onKeyUp, RCTDirectEventBlock) // macOS keyboard events
483
- RCT_CUSTOM_VIEW_PROPERTY(validKeysDown, NSArray<NSString*>, RCTView)
484
- {
485
- if ([view respondsToSelector:@selector(setValidKeysDown:)]) {
486
- view.validKeysDown = [RCTConvert NSArray:json];
487
- }
488
- }
489
- RCT_CUSTOM_VIEW_PROPERTY(validKeysUp, NSArray<NSString*>, RCTView)
490
- {
491
- if ([view respondsToSelector:@selector(setValidKeysUp:)]) {
492
- view.validKeysUp = [RCTConvert NSArray:json];
493
- }
494
- }
498
+ RCT_EXPORT_VIEW_PROPERTY(validKeysDown, NSArray<NSString*>)
499
+ RCT_EXPORT_VIEW_PROPERTY(validKeysUp, NSArray<NSString*>)
495
500
  #endif // ]TODO(macOS GH#774)
496
501
  #if TARGET_OS_OSX // [TODO(macOS GH#768)
497
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