react-native-macos 0.0.0-fdcec4d55 → 0.0.0-fe1f016b6
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/RCTTextInputViewConfig.js +1 -0
- package/Libraries/Components/TextInput/TextInput.js +118 -1
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +1 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
- package/Libraries/Components/View/ReactNativeViewViewConfig.js +1 -0
- package/Libraries/Components/View/ReactNativeViewViewConfigMacOS.js +3 -3
- package/Libraries/Components/View/View.js +0 -7
- package/Libraries/Components/View/ViewPropTypes.js +10 -6
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Image/RCTImageCache.m +1 -1
- package/Libraries/Image/RCTImageView.mm +14 -10
- 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 +118 -113
- package/Libraries/Lists/VirtualizedSectionList.js +9 -5
- package/Libraries/StyleSheet/StyleSheetTypes.js +25 -0
- package/Libraries/Text/BaseText/RCTBaseTextViewManager.m +1 -0
- package/Libraries/Text/RCTTextAttributes.h +2 -0
- package/Libraries/Text/RCTTextAttributes.m +14 -5
- package/Libraries/Text/Text/RCTDynamicTypeRamp.h +40 -0
- package/Libraries/Text/Text/RCTDynamicTypeRamp.m +77 -0
- package/Libraries/Text/Text/RCTTextView.m +118 -47
- package/Libraries/Text/Text.js +0 -8
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.h +8 -0
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.m +57 -2
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.m +13 -0
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.h +2 -1
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +88 -3
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +13 -1
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +12 -3
- package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +1 -0
- package/Libraries/Text/TextInput/RCTBaseTextInputShadowView.m +12 -0
- package/Libraries/Text/TextInput/RCTBaseTextInputView.h +9 -1
- package/Libraries/Text/TextInput/RCTBaseTextInputView.m +120 -2
- package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +12 -1
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.m +40 -0
- package/Libraries/Text/TextNativeComponent.js +2 -0
- package/Libraries/Text/TextProps.js +29 -0
- package/Libraries/Types/CoreEventTypes.js +0 -1
- package/Libraries/Utilities/codegenNativeComponent.js +1 -0
- package/React/Base/RCTAssert.h +4 -3
- package/React/Base/RCTAssert.m +11 -2
- package/React/Base/RCTBridge.m +1 -1
- package/React/Base/RCTConstants.h +3 -3
- package/React/Base/RCTConstants.m +6 -6
- package/React/Base/RCTConvert.m +8 -4
- package/React/Base/RCTEventDispatcherProtocol.h +5 -0
- package/React/Base/RCTRootView.m +0 -9
- package/React/Base/RCTTouchHandler.m +4 -0
- package/React/Base/RCTUIKit.h +8 -13
- package/React/Base/RCTUtils.m +33 -3
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/macOS/RCTUIKit.m +40 -0
- package/React/CoreModules/RCTAppearance.mm +21 -5
- package/React/CoreModules/RCTEventDispatcher.mm +6 -1
- package/React/CoreModules/RCTPerfMonitor.mm +1 -1
- package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.h +1 -0
- package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +76 -19
- package/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +2 -1
- package/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm +0 -1
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +1 -1
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +35 -9
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +8 -1
- package/React/Fabric/Mounting/RCTComponentViewFactory.mm +2 -9
- package/React/Fabric/Mounting/RCTComponentViewRegistry.h +0 -5
- package/React/Fabric/Mounting/RCTComponentViewRegistry.mm +0 -39
- package/React/Fabric/Mounting/RCTMountingManager.h +1 -1
- package/React/Fabric/Mounting/RCTMountingManager.mm +10 -9
- package/React/Fabric/Mounting/RCTMountingTransactionObserverCoordinator.h +5 -3
- package/React/Fabric/Mounting/RCTMountingTransactionObserverCoordinator.mm +10 -8
- package/React/Fabric/Mounting/RCTMountingTransactionObserving.h +5 -3
- package/React/Fabric/RCTConversions.h +9 -1
- package/React/Fabric/RCTImageResponseObserverProxy.h +1 -0
- package/React/Fabric/RCTLocalizationProvider.mm +10 -4
- package/React/Fabric/RCTScheduler.h +7 -0
- package/React/Fabric/RCTScheduler.mm +15 -0
- package/React/Fabric/RCTSurfacePresenter.h +2 -0
- package/React/Fabric/RCTSurfacePresenter.mm +44 -23
- package/React/Fabric/RCTSurfaceTouchHandler.mm +0 -1
- package/React/Modules/RCTUIManager.m +2 -1
- package/React/React-RCTFabric.podspec +1 -1
- package/React/Tests/Mounting/RCTComponentViewRegistryTests.mm +1 -0
- 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 +16 -0
- package/React/Views/RCTView.m +141 -191
- package/React/Views/RCTViewKeyboardEvent.h +6 -28
- package/React/Views/RCTViewKeyboardEvent.m +66 -61
- package/React/Views/RCTViewManager.m +18 -13
- 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 +70 -63
- package/React/Views/ScrollView/RCTScrollViewManager.m +1 -1
- package/React/Views/UIView+React.h +2 -0
- package/React/Views/UIView+React.m +23 -14
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactCommon/React-Fabric.podspec +1 -1
- package/ReactCommon/React-rncore.podspec +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm +5 -0
- package/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm +4 -2
- package/ReactCommon/react/renderer/core/EventDispatcher.cpp +21 -0
- package/ReactCommon/react/renderer/core/EventDispatcher.h +15 -0
- package/ReactCommon/react/renderer/core/EventListener.cpp +39 -0
- package/ReactCommon/react/renderer/core/EventListener.h +44 -0
- package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
- package/ReactCommon/react/renderer/mounting/TelemetryController.cpp +6 -9
- package/ReactCommon/react/renderer/mounting/TelemetryController.h +7 -7
- package/ReactCommon/react/renderer/scheduler/Scheduler.cpp +18 -0
- package/ReactCommon/react/renderer/scheduler/Scheduler.h +9 -0
- package/ReactCommon/react/utils/ManagedObjectWrapper.h +1 -1
- package/ReactCommon/react/utils/ManagedObjectWrapper.mm +1 -3
- package/package.json +1 -1
- package/scripts/generate-artifacts.js +21 -17
- package/scripts/react_native_pods.rb +0 -3
- package/template/Gemfile.lock +7 -7
- package/template/android/gradlew.bat +89 -89
- package/template/ios/HelloWorldTests/HelloWorldTests.m +1 -0
- package/template/package.json +1 -1
- package/Libraries/Types/RootTagTypes.js~merged +0 -23
- package/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.cpp +0 -12
- package/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.h +0 -32
- 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,6 +717,51 @@ 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)
|
|
720
|
+
- (void)setShadowColor:(NSColor *)shadowColor
|
|
721
|
+
{
|
|
722
|
+
if (_shadowColor != shadowColor)
|
|
723
|
+
{
|
|
724
|
+
_shadowColor = shadowColor;
|
|
725
|
+
[self didUpdateShadow];
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
- (void)setShadowOffset:(CGSize)shadowOffset
|
|
730
|
+
{
|
|
731
|
+
if (!CGSizeEqualToSize(_shadowOffset, shadowOffset))
|
|
732
|
+
{
|
|
733
|
+
_shadowOffset = shadowOffset;
|
|
734
|
+
[self didUpdateShadow];
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
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];
|
|
763
|
+
}
|
|
764
|
+
|
|
719
765
|
- (void)viewDidMoveToWindow
|
|
720
766
|
{
|
|
721
767
|
// Subscribe to view bounds changed notification so that the view can be notified when a
|
|
@@ -733,6 +779,9 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused)
|
|
|
733
779
|
name:NSViewBoundsDidChangeNotification
|
|
734
780
|
object:[[self enclosingScrollView] contentView]];
|
|
735
781
|
}
|
|
782
|
+
|
|
783
|
+
[self reactViewDidMoveToWindow]; // TODO(macOS GH#1412)
|
|
784
|
+
|
|
736
785
|
[super viewDidMoveToWindow];
|
|
737
786
|
}
|
|
738
787
|
|
|
@@ -742,16 +791,16 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused)
|
|
|
742
791
|
// the mouseExited: event does not get called on the view where mouseEntered: was previously called.
|
|
743
792
|
// This creates an unnatural pairing of mouse enter and exit events and can cause problems.
|
|
744
793
|
// We therefore explicitly check for this here and handle them by calling the appropriate callbacks.
|
|
745
|
-
|
|
794
|
+
|
|
746
795
|
if (!_hasMouseOver && self.onMouseEnter)
|
|
747
796
|
{
|
|
748
797
|
NSPoint locationInWindow = [[self window] mouseLocationOutsideOfEventStream];
|
|
749
798
|
NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
|
|
750
|
-
|
|
799
|
+
|
|
751
800
|
if (NSPointInRect(locationInView, [self bounds]))
|
|
752
801
|
{
|
|
753
802
|
_hasMouseOver = YES;
|
|
754
|
-
|
|
803
|
+
|
|
755
804
|
[self sendMouseEventWithBlock:self.onMouseEnter
|
|
756
805
|
locationInfo:[self locationInfoFromDraggingLocation:locationInWindow]
|
|
757
806
|
modifierFlags:0
|
|
@@ -762,11 +811,11 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused)
|
|
|
762
811
|
{
|
|
763
812
|
NSPoint locationInWindow = [[self window] mouseLocationOutsideOfEventStream];
|
|
764
813
|
NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
|
|
765
|
-
|
|
814
|
+
|
|
766
815
|
if (!NSPointInRect(locationInView, [self bounds]))
|
|
767
816
|
{
|
|
768
817
|
_hasMouseOver = NO;
|
|
769
|
-
|
|
818
|
+
|
|
770
819
|
[self sendMouseEventWithBlock:self.onMouseLeave
|
|
771
820
|
locationInfo:[self locationInfoFromDraggingLocation:locationInWindow]
|
|
772
821
|
modifierFlags:0
|
|
@@ -1365,6 +1414,15 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1365
1414
|
#pragma mark - macOS Event Handler
|
|
1366
1415
|
|
|
1367
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
|
+
|
|
1368
1426
|
- (void)setOnDoubleClick:(RCTDirectEventBlock)block
|
|
1369
1427
|
{
|
|
1370
1428
|
if (_onDoubleClick != block) {
|
|
@@ -1382,9 +1440,14 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1382
1440
|
}
|
|
1383
1441
|
}
|
|
1384
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
|
+
|
|
1385
1448
|
- (BOOL)acceptsFirstResponder
|
|
1386
1449
|
{
|
|
1387
|
-
|
|
1450
|
+
return [self focusable] || [super acceptsFirstResponder];
|
|
1388
1451
|
}
|
|
1389
1452
|
|
|
1390
1453
|
- (void)updateTrackingAreas
|
|
@@ -1392,7 +1455,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1392
1455
|
if (_trackingArea) {
|
|
1393
1456
|
[self removeTrackingArea:_trackingArea];
|
|
1394
1457
|
}
|
|
1395
|
-
|
|
1458
|
+
|
|
1396
1459
|
if (self.onMouseEnter || self.onMouseLeave) {
|
|
1397
1460
|
_trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds
|
|
1398
1461
|
options:NSTrackingActiveAlways|NSTrackingMouseEnteredAndExited
|
|
@@ -1400,7 +1463,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1400
1463
|
userInfo:nil];
|
|
1401
1464
|
[self addTrackingArea:_trackingArea];
|
|
1402
1465
|
}
|
|
1403
|
-
|
|
1466
|
+
|
|
1404
1467
|
[super updateTrackingAreas];
|
|
1405
1468
|
}
|
|
1406
1469
|
|
|
@@ -1426,7 +1489,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1426
1489
|
{
|
|
1427
1490
|
NSPoint locationInWindow = event.locationInWindow;
|
|
1428
1491
|
NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
|
|
1429
|
-
|
|
1492
|
+
|
|
1430
1493
|
return @{@"screenX": @(locationInWindow.x),
|
|
1431
1494
|
@"screenY": @(locationInWindow.y),
|
|
1432
1495
|
@"clientX": @(locationInView.x),
|
|
@@ -1457,25 +1520,21 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1457
1520
|
if (modifierFlags & NSEventModifierFlagCommand) {
|
|
1458
1521
|
body[@"metaKey"] = @YES;
|
|
1459
1522
|
}
|
|
1460
|
-
|
|
1523
|
+
|
|
1461
1524
|
if (locationInfo) {
|
|
1462
1525
|
[body addEntriesFromDictionary:locationInfo];
|
|
1463
1526
|
}
|
|
1464
|
-
|
|
1527
|
+
|
|
1465
1528
|
if (additionalData) {
|
|
1466
1529
|
[body addEntriesFromDictionary:additionalData];
|
|
1467
1530
|
}
|
|
1468
|
-
|
|
1531
|
+
|
|
1469
1532
|
block(body);
|
|
1470
1533
|
}
|
|
1471
1534
|
|
|
1472
|
-
- (NSDictionary*)
|
|
1535
|
+
- (NSDictionary*)dataTransferInfoFromPasteboard:(NSPasteboard*)pasteboard
|
|
1473
1536
|
{
|
|
1474
|
-
|
|
1475
|
-
return @{};
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
NSArray *fileNames = [pastboard propertyListForType:NSFilenamesPboardType];
|
|
1537
|
+
NSArray *fileNames = [pasteboard propertyListForType:NSFilenamesPboardType] ?: @[];
|
|
1479
1538
|
NSMutableArray *files = [[NSMutableArray alloc] initWithCapacity:fileNames.count];
|
|
1480
1539
|
NSMutableArray *items = [[NSMutableArray alloc] initWithCapacity:fileNames.count];
|
|
1481
1540
|
NSMutableArray *types = [[NSMutableArray alloc] initWithCapacity:fileNames.count];
|
|
@@ -1495,27 +1554,57 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1495
1554
|
MIMETypeString = (__bridge_transfer NSString *)MIMEType;
|
|
1496
1555
|
}
|
|
1497
1556
|
}
|
|
1498
|
-
|
|
1557
|
+
|
|
1499
1558
|
NSNumber *fileSizeValue = nil;
|
|
1500
1559
|
NSError *fileSizeError = nil;
|
|
1501
1560
|
BOOL success = [fileURL getResourceValue:&fileSizeValue
|
|
1502
1561
|
forKey:NSURLFileSizeKey
|
|
1503
1562
|
error:&fileSizeError];
|
|
1504
|
-
|
|
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
|
+
|
|
1505
1572
|
[files addObject:@{@"name": RCTNullIfNil(fileURL.lastPathComponent),
|
|
1506
1573
|
@"type": RCTNullIfNil(MIMETypeString),
|
|
1507
|
-
@"uri": RCTNullIfNil(fileURL.
|
|
1508
|
-
@"size": success ? fileSizeValue : (id)kCFNull
|
|
1574
|
+
@"uri": RCTNullIfNil(fileURL.path),
|
|
1575
|
+
@"size": success ? fileSizeValue : (id)kCFNull,
|
|
1576
|
+
@"width": RCTNullIfNil(width),
|
|
1577
|
+
@"height": RCTNullIfNil(height)
|
|
1509
1578
|
}];
|
|
1510
|
-
|
|
1579
|
+
|
|
1511
1580
|
[items addObject:@{@"kind": @"file",
|
|
1512
1581
|
@"type": RCTNullIfNil(MIMETypeString),
|
|
1513
1582
|
}];
|
|
1514
|
-
|
|
1583
|
+
|
|
1515
1584
|
[types addObject:RCTNullIfNil(MIMETypeString)];
|
|
1516
1585
|
}
|
|
1517
1586
|
}
|
|
1518
|
-
|
|
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
|
+
|
|
1519
1608
|
return @{@"dataTransfer": @{@"files": files,
|
|
1520
1609
|
@"items": items,
|
|
1521
1610
|
@"types": types}};
|
|
@@ -1524,7 +1613,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1524
1613
|
- (NSDictionary*)locationInfoFromDraggingLocation:(NSPoint)locationInWindow
|
|
1525
1614
|
{
|
|
1526
1615
|
NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
|
|
1527
|
-
|
|
1616
|
+
|
|
1528
1617
|
return @{@"screenX": @(locationInWindow.x),
|
|
1529
1618
|
@"screenY": @(locationInWindow.y),
|
|
1530
1619
|
@"clientX": @(locationInView.x),
|
|
@@ -1536,13 +1625,13 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1536
1625
|
{
|
|
1537
1626
|
NSPasteboard *pboard = sender.draggingPasteboard;
|
|
1538
1627
|
NSDragOperation sourceDragMask = sender.draggingSourceOperationMask;
|
|
1539
|
-
|
|
1628
|
+
|
|
1540
1629
|
[self sendMouseEventWithBlock:self.onDragEnter
|
|
1541
1630
|
locationInfo:[self locationInfoFromDraggingLocation:sender.draggingLocation]
|
|
1542
1631
|
modifierFlags:0
|
|
1543
|
-
additionalData:[self
|
|
1544
|
-
|
|
1545
|
-
if ([pboard
|
|
1632
|
+
additionalData:[self dataTransferInfoFromPasteboard:pboard]];
|
|
1633
|
+
|
|
1634
|
+
if ([pboard availableTypeFromArray:self.registeredDraggedTypes]) {
|
|
1546
1635
|
if (sourceDragMask & NSDragOperationLink) {
|
|
1547
1636
|
return NSDragOperationLink;
|
|
1548
1637
|
} else if (sourceDragMask & NSDragOperationCopy) {
|
|
@@ -1557,7 +1646,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1557
1646
|
[self sendMouseEventWithBlock:self.onDragLeave
|
|
1558
1647
|
locationInfo:[self locationInfoFromDraggingLocation:sender.draggingLocation]
|
|
1559
1648
|
modifierFlags:0
|
|
1560
|
-
additionalData:[self
|
|
1649
|
+
additionalData:[self dataTransferInfoFromPasteboard:sender.draggingPasteboard]];
|
|
1561
1650
|
}
|
|
1562
1651
|
|
|
1563
1652
|
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
|
@@ -1565,7 +1654,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1565
1654
|
[self sendMouseEventWithBlock:self.onDrop
|
|
1566
1655
|
locationInfo:[self locationInfoFromDraggingLocation:sender.draggingLocation]
|
|
1567
1656
|
modifierFlags:0
|
|
1568
|
-
additionalData:[self
|
|
1657
|
+
additionalData:[self dataTransferInfoFromPasteboard:sender.draggingPasteboard]];
|
|
1569
1658
|
return YES;
|
|
1570
1659
|
}
|
|
1571
1660
|
#endif // ]TODO(macOS GH#774)
|
|
@@ -1573,177 +1662,38 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1573
1662
|
#pragma mark - Keyboard Events
|
|
1574
1663
|
|
|
1575
1664
|
#if TARGET_OS_OSX
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
NSString
|
|
1579
|
-
NSString*
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
BOOL shiftKey = NO;
|
|
1585
|
-
BOOL controlKey = NO;
|
|
1586
|
-
BOOL optionKey = NO;
|
|
1587
|
-
BOOL commandKey = NO;
|
|
1588
|
-
BOOL numericPadKey = NO;
|
|
1589
|
-
BOOL helpKey = NO;
|
|
1590
|
-
BOOL functionKey = NO;
|
|
1591
|
-
// commonly used key short-cuts
|
|
1592
|
-
BOOL leftArrowKey = NO;
|
|
1593
|
-
BOOL rightArrowKey = NO;
|
|
1594
|
-
BOOL upArrowKey = NO;
|
|
1595
|
-
BOOL downArrowKey = NO;
|
|
1596
|
-
BOOL tabKeyPressed = NO;
|
|
1597
|
-
BOOL escapeKeyPressed = NO;
|
|
1598
|
-
NSString *key = event.charactersIgnoringModifiers;
|
|
1599
|
-
if ([key length] == 0) {
|
|
1600
|
-
return nil;
|
|
1601
|
-
}
|
|
1602
|
-
unichar const code = [key characterAtIndex:0];
|
|
1603
|
-
|
|
1604
|
-
// detect arrow key presses
|
|
1605
|
-
if (code == NSLeftArrowFunctionKey) {
|
|
1606
|
-
leftArrowKey = YES;
|
|
1607
|
-
} else if (code == NSRightArrowFunctionKey) {
|
|
1608
|
-
rightArrowKey = YES;
|
|
1609
|
-
} else if (code == NSUpArrowFunctionKey) {
|
|
1610
|
-
upArrowKey = YES;
|
|
1611
|
-
} else if (code == NSDownArrowFunctionKey) {
|
|
1612
|
-
downArrowKey = YES;
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
// detect special key presses via the key code
|
|
1616
|
-
switch (event.keyCode) {
|
|
1617
|
-
case 48: // Tab
|
|
1618
|
-
tabKeyPressed = YES;
|
|
1619
|
-
break;
|
|
1620
|
-
case 53: // Escape
|
|
1621
|
-
escapeKeyPressed = YES;
|
|
1622
|
-
break;
|
|
1623
|
-
default:
|
|
1624
|
-
break;
|
|
1665
|
+
- (RCTViewKeyboardEvent*)keyboardEvent:(NSEvent*)event {
|
|
1666
|
+
BOOL keyDown = event.type == NSEventTypeKeyDown;
|
|
1667
|
+
NSArray<NSString *> *validKeys = keyDown ? self.validKeysDown : self.validKeysUp;
|
|
1668
|
+
NSString *key = [RCTViewKeyboardEvent keyFromEvent:event];
|
|
1669
|
+
|
|
1670
|
+
// Only post events for keys we care about
|
|
1671
|
+
if (![validKeys containsObject:key]) {
|
|
1672
|
+
return nil;
|
|
1625
1673
|
}
|
|
1626
1674
|
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
} else if (event.modifierFlags & NSEventModifierFlagCommand) {
|
|
1637
|
-
commandKey = YES;
|
|
1638
|
-
} else if (event.modifierFlags & NSEventModifierFlagNumericPad) {
|
|
1639
|
-
numericPadKey = YES;
|
|
1640
|
-
} else if (event.modifierFlags & NSEventModifierFlagHelp) {
|
|
1641
|
-
helpKey = YES;
|
|
1642
|
-
} else if (event.modifierFlags & NSEventModifierFlagFunction) {
|
|
1643
|
-
functionKey = YES;
|
|
1644
|
-
}
|
|
1645
|
-
|
|
1646
|
-
RCTViewKeyboardEvent *keyboardEvent = nil;
|
|
1647
|
-
// only post events for keys we care about
|
|
1648
|
-
if (downPress) {
|
|
1649
|
-
NSString *keyToReturn = [self keyIsValid:key left:leftArrowKey right:rightArrowKey up:upArrowKey down:downArrowKey tabKey:tabKeyPressed escapeKey:escapeKeyPressed validKeys:[self validKeysDown]];
|
|
1650
|
-
if (keyToReturn != nil) {
|
|
1651
|
-
keyboardEvent = [RCTViewKeyboardEvent keyDownEventWithReactTag:self.reactTag
|
|
1652
|
-
capsLockKey:capsLockKey
|
|
1653
|
-
shiftKey:shiftKey
|
|
1654
|
-
ctrlKey:controlKey
|
|
1655
|
-
altKey:optionKey
|
|
1656
|
-
metaKey:commandKey
|
|
1657
|
-
numericPadKey:numericPadKey
|
|
1658
|
-
helpKey:helpKey
|
|
1659
|
-
functionKey:functionKey
|
|
1660
|
-
leftArrowKey:leftArrowKey
|
|
1661
|
-
rightArrowKey:rightArrowKey
|
|
1662
|
-
upArrowKey:upArrowKey
|
|
1663
|
-
downArrowKey:downArrowKey
|
|
1664
|
-
key:keyToReturn];
|
|
1665
|
-
}
|
|
1666
|
-
} else {
|
|
1667
|
-
NSString *keyToReturn = [self keyIsValid:key left:leftArrowKey right:rightArrowKey up:upArrowKey down:downArrowKey tabKey:tabKeyPressed escapeKey:escapeKeyPressed validKeys:[self validKeysUp]];
|
|
1668
|
-
if (keyToReturn != nil) {
|
|
1669
|
-
keyboardEvent = [RCTViewKeyboardEvent keyUpEventWithReactTag:self.reactTag
|
|
1670
|
-
capsLockKey:capsLockKey
|
|
1671
|
-
shiftKey:shiftKey
|
|
1672
|
-
ctrlKey:controlKey
|
|
1673
|
-
altKey:optionKey
|
|
1674
|
-
metaKey:commandKey
|
|
1675
|
-
numericPadKey:numericPadKey
|
|
1676
|
-
helpKey:helpKey
|
|
1677
|
-
functionKey:functionKey
|
|
1678
|
-
leftArrowKey:leftArrowKey
|
|
1679
|
-
rightArrowKey:rightArrowKey
|
|
1680
|
-
upArrowKey:upArrowKey
|
|
1681
|
-
downArrowKey:downArrowKey
|
|
1682
|
-
key:keyToReturn];
|
|
1675
|
+
return [RCTViewKeyboardEvent keyEventFromEvent:event reactTag:self.reactTag];
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
- (BOOL)handleKeyboardEvent:(NSEvent *)event {
|
|
1679
|
+
if (event.type == NSEventTypeKeyDown ? self.onKeyDown : self.onKeyUp) {
|
|
1680
|
+
RCTViewKeyboardEvent *keyboardEvent = [self keyboardEvent:event];
|
|
1681
|
+
if (keyboardEvent) {
|
|
1682
|
+
[_eventDispatcher sendEvent:keyboardEvent];
|
|
1683
|
+
return YES;
|
|
1683
1684
|
}
|
|
1684
1685
|
}
|
|
1685
|
-
return
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
// check if the user typed key matches a key we need to send an event for
|
|
1689
|
-
// translate key codes over to JS compatible keys
|
|
1690
|
-
- (NSString*)keyIsValid:(NSString*)key left:(BOOL)leftArrowPressed right:(BOOL)rightArrowPressed up:(BOOL)upArrowPressed down:(BOOL)downArrowPressed tabKey:(BOOL)tabKeyPressed escapeKey:(BOOL)escapeKeyPressed validKeys:(NSArray<NSString*>*)validKeys {
|
|
1691
|
-
NSString *keyToReturn = key;
|
|
1692
|
-
|
|
1693
|
-
// Allow the flexibility of defining special keys in multiple ways
|
|
1694
|
-
BOOL enterKeyValidityCheck = [key isEqualToString:@"\r"] && ([validKeys containsObject:@"Enter"] || [validKeys containsObject:@"\r"]);
|
|
1695
|
-
BOOL tabKeyValidityCheck = tabKeyPressed && ([validKeys containsObject:@"Tab"]); // tab has to be checked via a key code so we can't just use the key itself here
|
|
1696
|
-
BOOL escapeKeyValidityCheck = escapeKeyPressed && ([validKeys containsObject:@"Esc"] || [validKeys containsObject:@"Escape"]); // escape has to be checked via a key code so we can't just use the key itself here
|
|
1697
|
-
BOOL leftArrowValidityCheck = [validKeys containsObject:leftArrowPressKey] && leftArrowPressed;
|
|
1698
|
-
BOOL rightArrowValidityCheck = [validKeys containsObject:rightArrowPressKey] && rightArrowPressed;
|
|
1699
|
-
BOOL upArrowValidityCheck = [validKeys containsObject:upArrowPressKey] && upArrowPressed;
|
|
1700
|
-
BOOL downArrowValidityCheck = [validKeys containsObject:downArrowPressKey] && downArrowPressed;
|
|
1701
|
-
|
|
1702
|
-
if (tabKeyValidityCheck) {
|
|
1703
|
-
keyToReturn = @"Tab";
|
|
1704
|
-
} else if (escapeKeyValidityCheck) {
|
|
1705
|
-
keyToReturn = @"Escape";
|
|
1706
|
-
} else if (enterKeyValidityCheck) {
|
|
1707
|
-
keyToReturn = @"Enter";
|
|
1708
|
-
} else if (leftArrowValidityCheck) {
|
|
1709
|
-
keyToReturn = leftArrowPressKey;
|
|
1710
|
-
} else if (rightArrowValidityCheck) {
|
|
1711
|
-
keyToReturn = rightArrowPressKey;
|
|
1712
|
-
} else if (upArrowValidityCheck) {
|
|
1713
|
-
keyToReturn = upArrowPressKey;
|
|
1714
|
-
} else if (downArrowValidityCheck) {
|
|
1715
|
-
keyToReturn = downArrowPressKey;
|
|
1716
|
-
} else if (![validKeys containsObject:key]) {
|
|
1717
|
-
keyToReturn = nil;
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
return keyToReturn;
|
|
1686
|
+
return NO;
|
|
1721
1687
|
}
|
|
1722
1688
|
|
|
1723
1689
|
- (void)keyDown:(NSEvent *)event {
|
|
1724
|
-
if (self
|
|
1725
|
-
[super keyDown:event];
|
|
1726
|
-
return;
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
RCTViewKeyboardEvent *keyboardEvent = [self keyboardEvent:event downPress:YES];
|
|
1730
|
-
if (keyboardEvent != nil) {
|
|
1731
|
-
[_eventDispatcher sendEvent:keyboardEvent];
|
|
1732
|
-
} else {
|
|
1690
|
+
if (![self handleKeyboardEvent:event]) {
|
|
1733
1691
|
[super keyDown:event];
|
|
1734
1692
|
}
|
|
1735
1693
|
}
|
|
1736
1694
|
|
|
1737
1695
|
- (void)keyUp:(NSEvent *)event {
|
|
1738
|
-
if (self
|
|
1739
|
-
[super keyUp:event];
|
|
1740
|
-
return;
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
RCTViewKeyboardEvent *keyboardEvent = [self keyboardEvent:event downPress:NO];
|
|
1744
|
-
if (keyboardEvent != nil) {
|
|
1745
|
-
[_eventDispatcher sendEvent:keyboardEvent];
|
|
1746
|
-
} else {
|
|
1696
|
+
if (![self handleKeyboardEvent:event]) {
|
|
1747
1697
|
[super keyUp:event];
|
|
1748
1698
|
}
|
|
1749
1699
|
}
|
|
@@ -7,33 +7,11 @@
|
|
|
7
7
|
#import <React/RCTComponentEvent.h>
|
|
8
8
|
|
|
9
9
|
@interface RCTViewKeyboardEvent : RCTComponentEvent
|
|
10
|
-
+ (instancetype)keyDownEventWithReactTag:(NSNumber *)reactTag
|
|
11
|
-
capsLockKey:(BOOL)capsLockKey
|
|
12
|
-
shiftKey:(BOOL)shiftKey
|
|
13
|
-
ctrlKey:(BOOL)controlKey
|
|
14
|
-
altKey:(BOOL)optionKey
|
|
15
|
-
metaKey:(BOOL)commandKey
|
|
16
|
-
numericPadKey:(BOOL)numericPadKey
|
|
17
|
-
helpKey:(BOOL)helpKey
|
|
18
|
-
functionKey:(BOOL)functionKey
|
|
19
|
-
leftArrowKey:(BOOL)leftArrowKey
|
|
20
|
-
rightArrowKey:(BOOL)rightArrowKey
|
|
21
|
-
upArrowKey:(BOOL)upArrowKey
|
|
22
|
-
downArrowKey:(BOOL)downArrowKey
|
|
23
|
-
key:(NSString *)key;
|
|
24
10
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
numericPadKey:(BOOL)numericPadKey
|
|
32
|
-
helpKey:(BOOL)helpKey
|
|
33
|
-
functionKey:(BOOL)functionKey
|
|
34
|
-
leftArrowKey:(BOOL)leftArrowKey
|
|
35
|
-
rightArrowKey:(BOOL)rightArrowKey
|
|
36
|
-
upArrowKey:(BOOL)upArrowKey
|
|
37
|
-
downArrowKey:(BOOL)downArrowKey
|
|
38
|
-
key:(NSString *)key;
|
|
11
|
+
#if TARGET_OS_OSX // TODO(macOS GH#774)
|
|
12
|
+
+ (NSDictionary *)bodyFromEvent:(NSEvent *)event;
|
|
13
|
+
+ (NSString *)keyFromEvent:(NSEvent *)event;
|
|
14
|
+
+ (instancetype)keyEventFromEvent:(NSEvent *)event reactTag:(NSNumber *)reactTag;
|
|
15
|
+
#endif // TODO(macOS GH#774)
|
|
16
|
+
|
|
39
17
|
@end
|