react-native-macos 0.0.0-8ed4340a4 → 0.0.0-8f5b6f691
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/Components/ScrollView/ScrollView.js +11 -45
- package/Libraries/Components/TextInput/TextInput.js +30 -1
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +1 -0
- package/Libraries/Components/View/ReactNativeViewViewConfig.js +1 -0
- package/Libraries/Components/View/ReactNativeViewViewConfigMacOS.js +3 -3
- package/Libraries/Components/View/ViewPropTypes.js +10 -6
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/LinkingIOS/RCTLinkingManager.h +1 -0
- package/Libraries/LinkingIOS/macos/RCTLinkingManager.mm +12 -5
- package/Libraries/Lists/FlatList.js +25 -1
- package/Libraries/Lists/VirtualizedList.js +106 -113
- package/Libraries/Lists/VirtualizedSectionList.js +9 -5
- package/Libraries/StyleSheet/StyleSheetTypes.js +25 -0
- package/Libraries/Text/RCTTextAttributes.m +5 -5
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.m +3 -1
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +50 -2
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +6 -1
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +12 -3
- package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +1 -0
- package/Libraries/Text/TextInput/RCTBaseTextInputView.h +1 -0
- package/Libraries/Text/TextInput/RCTBaseTextInputView.m +54 -2
- package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +1 -0
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.m +24 -0
- package/Libraries/Types/CoreEventTypes.js +0 -1
- package/React/Base/RCTConvert.m +3 -0
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/macOS/RCTUIKit.m +7 -0
- package/React/CoreModules/RCTPerfMonitor.mm +1 -1
- package/React/Modules/RCTUIManager.m +2 -1
- package/React/Views/RCTActivityIndicatorView.m +2 -1
- package/React/Views/RCTCursor.h +39 -0
- package/React/Views/RCTCursor.m +105 -0
- package/React/Views/RCTView.h +12 -0
- package/React/Views/RCTView.m +110 -42
- package/React/Views/RCTViewKeyboardEvent.m +9 -1
- package/React/Views/RCTViewManager.m +17 -12
- package/React/Views/ScrollView/RCTScrollContentView.h +4 -0
- package/React/Views/ScrollView/RCTScrollContentView.m +18 -0
- package/React/Views/ScrollView/RCTScrollContentViewManager.m +2 -0
- package/React/Views/ScrollView/RCTScrollView.h +2 -1
- package/React/Views/ScrollView/RCTScrollView.m +69 -62
- package/React/Views/ScrollView/RCTScrollViewManager.m +1 -1
- package/React/Views/UIView+React.h +2 -0
- package/React/Views/UIView+React.m +22 -13
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/package.json +1 -1
- package/scripts/generate-artifacts.js +21 -17
- package/scripts/react_native_pods.rb +0 -3
- package/template/Gemfile.lock +5 -5
- package/template/android/gradlew.bat +89 -89
- package/template/package.json +1 -1
- package/third-party-podspecs/boost-for-react-native.podspec +0 -20
package/React/Views/RCTView.m
CHANGED
|
@@ -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
|
-
|
|
720
|
-
- (NSShadow*)shadow
|
|
720
|
+
- (void)setShadowColor:(NSColor *)shadowColor
|
|
721
721
|
{
|
|
722
|
-
|
|
723
|
-
|
|
722
|
+
if (_shadowColor != shadowColor)
|
|
723
|
+
{
|
|
724
|
+
_shadowColor = shadowColor;
|
|
725
|
+
[self didUpdateShadow];
|
|
726
|
+
}
|
|
727
|
+
}
|
|
724
728
|
|
|
725
|
-
|
|
726
|
-
|
|
729
|
+
- (void)setShadowOffset:(CGSize)shadowOffset
|
|
730
|
+
{
|
|
731
|
+
if (!CGSizeEqualToSize(_shadowOffset, shadowOffset))
|
|
732
|
+
{
|
|
733
|
+
_shadowOffset = shadowOffset;
|
|
734
|
+
[self didUpdateShadow];
|
|
735
|
+
}
|
|
736
|
+
}
|
|
727
737
|
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
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*)
|
|
1530
|
+
- (NSDictionary*)dataTransferInfoFromPasteboard:(NSPasteboard*)pasteboard
|
|
1489
1531
|
{
|
|
1490
|
-
|
|
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.
|
|
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
|
|
1560
|
-
|
|
1561
|
-
if ([pboard
|
|
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
|
|
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
|
|
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
|
-
|
|
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)
|
|
@@ -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
|
{
|
|
@@ -54,6 +60,18 @@
|
|
|
54
60
|
horizontalScrollerHeight:verticalScrollerWidth];
|
|
55
61
|
[[[scrollView bridge] uiManager] setLocalData:localData forView:self];
|
|
56
62
|
}
|
|
63
|
+
|
|
64
|
+
if ([platformScrollView accessibilityRole] == NSAccessibilityTableRole) {
|
|
65
|
+
NSMutableArray *subViews = [[NSMutableArray alloc] initWithCapacity:[[self subviews] count]];
|
|
66
|
+
for (NSView *view in [self subviews]) {
|
|
67
|
+
if ([view isKindOfClass:[RCTView class]]) {
|
|
68
|
+
[subViews addObject:view];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
[platformScrollView setAccessibilityRows:subViews];
|
|
73
|
+
}
|
|
74
|
+
|
|
57
75
|
#endif // ]TODO(macOS GH#774)
|
|
58
76
|
}
|
|
59
77
|
|
|
@@ -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,6 +109,11 @@
|
|
|
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
119
|
if (!self.scrollEnabled) {
|
|
@@ -549,6 +557,20 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
|
|
|
549
557
|
{
|
|
550
558
|
[_scrollView setAccessibilityLabel:accessibilityLabel];
|
|
551
559
|
}
|
|
560
|
+
|
|
561
|
+
- (void)setAccessibilityRole:(NSAccessibilityRole)accessibilityRole
|
|
562
|
+
{
|
|
563
|
+
[_scrollView setAccessibilityRole:accessibilityRole];
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
- (void)setInverted:(BOOL)inverted
|
|
567
|
+
{
|
|
568
|
+
BOOL changed = _inverted != inverted;
|
|
569
|
+
_inverted = inverted;
|
|
570
|
+
if (changed && _onInvertedDidChange) {
|
|
571
|
+
_onInvertedDidChange(@{});
|
|
572
|
+
}
|
|
573
|
+
}
|
|
552
574
|
#endif // ]TODO(macOS GH#774)
|
|
553
575
|
|
|
554
576
|
RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
|
|
@@ -1256,74 +1278,58 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
|
|
|
1256
1278
|
}];
|
|
1257
1279
|
}
|
|
1258
1280
|
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
- (NSString*)keyCommandFromKeyCode:(NSInteger)keyCode modifierFlags:(NSEventModifierFlags)modifierFlags
|
|
1262
|
-
{
|
|
1263
|
-
switch (keyCode)
|
|
1264
|
-
{
|
|
1265
|
-
case 36:
|
|
1266
|
-
return @"ENTER";
|
|
1267
|
-
|
|
1268
|
-
case 115:
|
|
1269
|
-
return @"HOME";
|
|
1270
|
-
|
|
1271
|
-
case 116:
|
|
1272
|
-
return @"PAGE_UP";
|
|
1273
|
-
|
|
1274
|
-
case 119:
|
|
1275
|
-
return @"END";
|
|
1276
|
-
|
|
1277
|
-
case 121:
|
|
1278
|
-
return @"PAGE_DOWN";
|
|
1279
|
-
|
|
1280
|
-
case 123:
|
|
1281
|
-
return @"LEFT_ARROW";
|
|
1282
|
-
|
|
1283
|
-
case 124:
|
|
1284
|
-
return @"RIGHT_ARROW";
|
|
1281
|
+
// [TODO(macOS GH#774)
|
|
1282
|
+
#pragma mark - Keyboard Events
|
|
1285
1283
|
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
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
|
+
}
|
|
1292
1294
|
|
|
1293
|
-
|
|
1294
|
-
if (modifierFlags & NSEventModifierFlagOption) {
|
|
1295
|
-
return @"OPTION_UP";
|
|
1296
|
-
} else {
|
|
1297
|
-
return @"UP_ARROW";
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
return @"";
|
|
1295
|
+
return [RCTViewKeyboardEvent keyEventFromEvent:event reactTag:self.reactTag];
|
|
1301
1296
|
}
|
|
1302
1297
|
|
|
1303
|
-
- (
|
|
1304
|
-
{
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
RCT_SEND_SCROLL_EVENT(onScrollKeyDown, (@{ @"key": keyCommand}));
|
|
1310
|
-
} else {
|
|
1311
|
-
[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;
|
|
1312
1304
|
}
|
|
1313
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
|
+
}
|
|
1314
1328
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
if ([firstResponder isKindOfClass:[NSView class]] &&
|
|
1320
|
-
[firstResponder isDescendantOf:[_scrollView documentView]]) {
|
|
1321
|
-
NSView *view = (NSView*)firstResponder;
|
|
1322
|
-
NSRect visibleRect = ([view superview] == [_scrollView documentView]) ? NSInsetRect(view.frame, -1, -1) :
|
|
1323
|
-
[view convertRect:view.frame toView:_scrollView.documentView];
|
|
1324
|
-
[[_scrollView documentView] scrollRectToVisible:visibleRect];
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1329
|
+
- (void)keyUp:(NSEvent *)event {
|
|
1330
|
+
if (![self handleKeyboardEvent:event]) {
|
|
1331
|
+
[super keyUp:event];
|
|
1332
|
+
}
|
|
1327
1333
|
}
|
|
1328
1334
|
|
|
1329
1335
|
static NSString *RCTStringForScrollerStyle(NSScrollerStyle scrollerStyle) {
|
|
@@ -1338,7 +1344,8 @@ static NSString *RCTStringForScrollerStyle(NSScrollerStyle scrollerStyle) {
|
|
|
1338
1344
|
- (void)preferredScrollerStyleDidChange:(__unused NSNotification *)notification {
|
|
1339
1345
|
RCT_SEND_SCROLL_EVENT(onPreferredScrollerStyleDidChange, (@{ @"preferredScrollerStyle": RCTStringForScrollerStyle([NSScroller preferredScrollerStyle])}));
|
|
1340
1346
|
}
|
|
1341
|
-
#endif
|
|
1347
|
+
#endif
|
|
1348
|
+
// ]TODO(macOS GH#774)
|
|
1342
1349
|
|
|
1343
1350
|
// Note: setting several properties of UIScrollView has the effect of
|
|
1344
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(
|
|
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 */
|