react-native-macos 0.76.6 → 0.76.8
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/AppDelegate/RCTAppDelegate.mm +0 -5
- package/Libraries/AppDelegate/RCTAppSetupUtils.h +1 -1
- package/Libraries/AppDelegate/RCTAppSetupUtils.mm +4 -2
- package/Libraries/AppDelegate/RCTRootViewFactory.mm +2 -3
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Image/RCTImageLoader.mm +9 -1
- package/Libraries/Image/RCTImageView.mm +5 -0
- package/Libraries/Image/RCTImageViewManager.mm +4 -0
- package/Libraries/Network/RCTDataRequestHandler.mm +10 -6
- package/Libraries/Network/RCTFileRequestHandler.mm +11 -7
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.mm +3 -1
- package/Libraries/Text/TextInput/RCTBaseTextInputView.mm +2 -1
- package/Libraries/Utilities/Appearance.js +3 -1
- package/React/Base/RCTRootView.m +58 -0
- package/React/Base/RCTTouchHandler.m +6 -5
- package/React/Base/RCTUIKit.h +4 -1
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm +2 -5
- package/React/Base/macOS/RCTUIKit.m +9 -2
- package/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.h +2 -1
- package/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +8 -18
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h +3 -0
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +17 -18
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +16 -5
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +14 -11
- package/React/Views/RCTFont.h +2 -0
- package/React/Views/RCTFont.mm +4 -5
- package/React/Views/RCTView.m +2 -11
- package/React/Views/ScrollView/RCTScrollView.h +3 -1
- package/React/Views/ScrollView/RCTScrollView.m +8 -0
- package/React/Views/UIView+React.m +5 -2
- package/ReactAndroid/api/ReactAndroid.api +4 -0
- package/ReactAndroid/cmake-utils/ReactNative-application.cmake +18 -3
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/HeadlessJsTaskService.java +12 -13
- package/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +8 -2
- package/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java +15 -8
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt +1 -7
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt +1 -11
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt +1 -3
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +1 -3
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt +1 -12
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt +1 -3
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java +11 -3
- package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java +11 -3
- package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewHelper.kt +25 -0
- package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java +16 -2
- package/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java +1 -0
- package/ReactAndroid/src/main/jni/react/fabric/Binding.cpp +17 -19
- package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp +1 -15
- package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h +1 -4
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +1 -5
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +1 -6
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +47 -65
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +2 -4
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +1 -5
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +1 -2
- package/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.mm +9 -0
- package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +1 -6
- package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +1 -3
- package/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp +5 -0
- package/ReactCommon/react/renderer/attributedstring/TextAttributes.h +2 -0
- package/ReactCommon/react/renderer/attributedstring/conversions.h +5 -0
- package/ReactCommon/react/renderer/components/rncore/Props.cpp +1 -1
- package/ReactCommon/react/renderer/components/rncore/Props.h +16 -12
- package/ReactCommon/react/renderer/components/rncore/States.h +0 -26
- package/ReactCommon/react/renderer/components/text/BaseTextProps.cpp +12 -0
- package/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h +2 -3
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm +8 -4
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTFontUtils.mm +31 -11
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextPrimitivesConversions.h +2 -2
- package/ReactCommon/react/renderer/uimanager/UIManager.cpp +29 -8
- package/ReactCommon/react/runtime/ReactInstance.cpp +39 -35
- package/ReactCommon/react/runtime/ReactInstance.h +2 -1
- package/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +3 -2
- package/gradle/libs.versions.toml +1 -1
- package/jest/setup.js +5 -1
- package/package.json +8 -8
- package/scripts/cocoapods/new_architecture.rb +1 -1
- package/scripts/cocoapods/utils.rb +6 -6
- package/scripts/codegen/generate-artifacts-executor.js +68 -7
- package/src/private/featureflags/ReactNativeFeatureFlags.js +1 -6
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +1 -2
- package/Libraries/AddressSanitizerCrash/AddressSanitizerCrash.js +0 -13
- package/Libraries/AddressSanitizerCrash/NativeAddressSanitizerCrash.js +0 -19
- package/React/CoreModules/RCTAddressSanitizerCrashManager.h +0 -12
- package/React/CoreModules/RCTAddressSanitizerCrashManager.mm +0 -18
|
@@ -110,11 +110,6 @@
|
|
|
110
110
|
#endif // macOS]
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
- (void)applicationDidEnterBackground:(UIApplication *)application
|
|
114
|
-
{
|
|
115
|
-
// Noop
|
|
116
|
-
}
|
|
117
|
-
|
|
118
113
|
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
|
|
119
114
|
{
|
|
120
115
|
[NSException raise:@"RCTBridgeDelegate::sourceURLForBridge not implemented"
|
|
@@ -46,7 +46,7 @@ std::unique_ptr<facebook::react::JSExecutorFactory> RCTAppSetupJsExecutorFactory
|
|
|
46
46
|
RCT_EXTERN_C_BEGIN
|
|
47
47
|
|
|
48
48
|
void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled);
|
|
49
|
-
|
|
49
|
+
RCTPlatformView *RCTAppSetupDefaultRootView( // [macOS]
|
|
50
50
|
RCTBridge *bridge,
|
|
51
51
|
NSString *moduleName,
|
|
52
52
|
NSDictionary *initialProperties,
|
|
@@ -48,14 +48,16 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
|
|
|
48
48
|
#endif
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
RCTPlatformView * // [macOS]
|
|
52
52
|
RCTAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties, BOOL fabricEnabled)
|
|
53
53
|
{
|
|
54
54
|
if (fabricEnabled) {
|
|
55
55
|
id<RCTSurfaceProtocol> surface = [[RCTFabricSurface alloc] initWithBridge:bridge
|
|
56
56
|
moduleName:moduleName
|
|
57
57
|
initialProperties:initialProperties];
|
|
58
|
-
|
|
58
|
+
RCTPlatformView *rootView = [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
|
|
59
|
+
[surface start];
|
|
60
|
+
return rootView;
|
|
59
61
|
}
|
|
60
62
|
return [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
|
|
61
63
|
}
|
|
@@ -159,9 +159,8 @@ static NSDictionary *updateInitialProps(NSDictionary *initialProps, BOOL isFabri
|
|
|
159
159
|
|
|
160
160
|
RCTFabricSurface *surface = [self.reactHost createSurfaceWithModuleName:moduleName initialProperties:initProps];
|
|
161
161
|
|
|
162
|
-
RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView =
|
|
163
|
-
initWithSurface:surface
|
|
164
|
-
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact];
|
|
162
|
+
RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView =
|
|
163
|
+
[[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
|
|
165
164
|
|
|
166
165
|
#if !TARGET_OS_OSX // [macOS]
|
|
167
166
|
surfaceHostingProxyRootView.backgroundColor = [UIColor systemBackgroundColor];
|
|
@@ -523,7 +523,15 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image, CGSize size, CGFloat scal
|
|
|
523
523
|
|
|
524
524
|
// Add missing png extension
|
|
525
525
|
if (request.URL.fileURL && request.URL.pathExtension.length == 0) {
|
|
526
|
-
|
|
526
|
+
// Check if there exists a file with that url on disk already
|
|
527
|
+
// This should fix issue https://github.com/facebook/react-native/issues/46870
|
|
528
|
+
if ([[NSFileManager defaultManager] fileExistsAtPath:request.URL.path]) {
|
|
529
|
+
mutableRequest.URL = request.URL;
|
|
530
|
+
} else {
|
|
531
|
+
// This is the default behavior in case there is no file on disk with no extension.
|
|
532
|
+
// We assume that the extension is `png`.
|
|
533
|
+
mutableRequest.URL = [request.URL URLByAppendingPathExtension:@"png"];
|
|
534
|
+
}
|
|
527
535
|
}
|
|
528
536
|
if (_redirectDelegate != nil) {
|
|
529
537
|
mutableRequest.URL = [_redirectDelegate redirectAssetsURL:mutableRequest.URL];
|
|
@@ -629,6 +629,11 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
|
|
|
629
629
|
return _imageView;
|
|
630
630
|
}
|
|
631
631
|
|
|
632
|
+
- (NSCell *)reactAccessibilityElementCell
|
|
633
|
+
{
|
|
634
|
+
return _imageView.cell;
|
|
635
|
+
}
|
|
636
|
+
|
|
632
637
|
- (NSColor *)tintColor
|
|
633
638
|
{
|
|
634
639
|
return _imageView.tintColor;
|
|
@@ -30,6 +30,10 @@ RCT_EXPORT_MODULE()
|
|
|
30
30
|
return [[RCTImageView alloc] initWithBridge:self.bridge];
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
#if TARGET_OS_OSX // [macOS
|
|
34
|
+
// setting accessibilityElement on NSImageView has no effect, must be set on NSImageCell
|
|
35
|
+
RCT_REMAP_VIEW_PROPERTY(accessible, reactAccessibilityElementCell.accessibilityElement, BOOL)
|
|
36
|
+
#endif // macOS]
|
|
33
37
|
RCT_EXPORT_VIEW_PROPERTY(blurRadius, CGFloat)
|
|
34
38
|
RCT_EXPORT_VIEW_PROPERTY(capInsets, UIEdgeInsets)
|
|
35
39
|
RCT_REMAP_VIEW_PROPERTY(defaultSource, defaultImage, UIImage)
|
|
@@ -38,8 +38,13 @@ RCT_EXPORT_MODULE()
|
|
|
38
38
|
_queue.maxConcurrentOperationCount = 2;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
NSBlockOperation *op = [NSBlockOperation new];
|
|
42
|
+
__weak NSBlockOperation *weakOp = op;
|
|
43
|
+
[op addExecutionBlock:^{
|
|
44
|
+
NSBlockOperation *strongOp = weakOp; // Strong reference to avoid deallocation during execution
|
|
45
|
+
if (strongOp == nil || [strongOp isCancelled]) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
43
48
|
// Get mime type
|
|
44
49
|
NSRange firstSemicolon = [request.URL.resourceSpecifier rangeOfString:@";"];
|
|
45
50
|
NSString *mimeType =
|
|
@@ -51,18 +56,17 @@ RCT_EXPORT_MODULE()
|
|
|
51
56
|
expectedContentLength:-1
|
|
52
57
|
textEncodingName:nil];
|
|
53
58
|
|
|
54
|
-
[delegate URLRequest:
|
|
59
|
+
[delegate URLRequest:strongOp didReceiveResponse:response];
|
|
55
60
|
|
|
56
61
|
// Load data
|
|
57
62
|
NSError *error;
|
|
58
63
|
NSData *data = [NSData dataWithContentsOfURL:request.URL options:NSDataReadingMappedIfSafe error:&error];
|
|
59
64
|
if (data) {
|
|
60
|
-
[delegate URLRequest:
|
|
65
|
+
[delegate URLRequest:strongOp didReceiveData:data];
|
|
61
66
|
}
|
|
62
|
-
[delegate URLRequest:
|
|
67
|
+
[delegate URLRequest:strongOp didCompleteWithError:error];
|
|
63
68
|
}];
|
|
64
69
|
|
|
65
|
-
weakOp = op;
|
|
66
70
|
[_queue addOperation:op];
|
|
67
71
|
return op;
|
|
68
72
|
}
|
|
@@ -46,14 +46,19 @@ RCT_EXPORT_MODULE()
|
|
|
46
46
|
_fileQueue.maxConcurrentOperationCount = 4;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
NSBlockOperation *op = [NSBlockOperation new];
|
|
50
|
+
__weak NSBlockOperation *weakOp = op;
|
|
51
|
+
[op addExecutionBlock:^{
|
|
52
|
+
NSBlockOperation *strongOp = weakOp; // Strong reference to avoid deallocation during execution
|
|
53
|
+
if (strongOp == nil || [strongOp isCancelled]) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
51
56
|
// Get content length
|
|
52
57
|
NSError *error = nil;
|
|
53
58
|
NSFileManager *fileManager = [NSFileManager new];
|
|
54
59
|
NSDictionary<NSString *, id> *fileAttributes = [fileManager attributesOfItemAtPath:request.URL.path error:&error];
|
|
55
60
|
if (!fileAttributes) {
|
|
56
|
-
[delegate URLRequest:
|
|
61
|
+
[delegate URLRequest:strongOp didCompleteWithError:error];
|
|
57
62
|
return;
|
|
58
63
|
}
|
|
59
64
|
|
|
@@ -70,17 +75,16 @@ RCT_EXPORT_MODULE()
|
|
|
70
75
|
expectedContentLength:[fileAttributes[NSFileSize] ?: @-1 integerValue]
|
|
71
76
|
textEncodingName:nil];
|
|
72
77
|
|
|
73
|
-
[delegate URLRequest:
|
|
78
|
+
[delegate URLRequest:strongOp didReceiveResponse:response];
|
|
74
79
|
|
|
75
80
|
// Load data
|
|
76
81
|
NSData *data = [NSData dataWithContentsOfURL:request.URL options:NSDataReadingMappedIfSafe error:&error];
|
|
77
82
|
if (data) {
|
|
78
|
-
[delegate URLRequest:
|
|
83
|
+
[delegate URLRequest:strongOp didReceiveData:data];
|
|
79
84
|
}
|
|
80
|
-
[delegate URLRequest:
|
|
85
|
+
[delegate URLRequest:strongOp didCompleteWithError:error];
|
|
81
86
|
}];
|
|
82
87
|
|
|
83
|
-
weakOp = op;
|
|
84
88
|
[_fileQueue addOperation:op];
|
|
85
89
|
return op;
|
|
86
90
|
}
|
|
@@ -134,7 +134,9 @@
|
|
|
134
134
|
CGSize textViewSize = [_backedTextInputView intrinsicContentSize];
|
|
135
135
|
NSClipView *clipView = (NSClipView *)_scrollView.contentView;
|
|
136
136
|
if (textViewSize.height > clipView.bounds.size.height) {
|
|
137
|
-
|
|
137
|
+
// Sometimes dimensions returned are in floating point numbers.
|
|
138
|
+
// If the floats are close enough, then don't show the scrollbar even if there is a fraction of overflow with the text.
|
|
139
|
+
return fabs(textViewSize.height - clipView.bounds.size.height) >= 1;
|
|
138
140
|
};
|
|
139
141
|
|
|
140
142
|
return NO;
|
|
@@ -47,6 +47,7 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
47
47
|
{
|
|
48
48
|
if (![self isDescendantOfView:scrollView]) {
|
|
49
49
|
// View is outside scroll view
|
|
50
|
+
scrollView.firstResponderViewOutsideScrollView = self.backedTextInputView;
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -611,7 +612,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
611
612
|
_maxLength.integerValue - (NSInteger)backedTextInputView.attributedText.string.length + (NSInteger)range.length,
|
|
612
613
|
0);
|
|
613
614
|
|
|
614
|
-
if (text.length >
|
|
615
|
+
if (text.length > allowedLength) {
|
|
615
616
|
// If we typed/pasted more than one character, limit the text inputted.
|
|
616
617
|
if (text.length > 1) {
|
|
617
618
|
if (allowedLength > 0) {
|
|
@@ -105,7 +105,9 @@ export function setColorScheme(colorScheme: ?ColorSchemeName): void {
|
|
|
105
105
|
const {NativeAppearance} = state;
|
|
106
106
|
if (NativeAppearance != null) {
|
|
107
107
|
NativeAppearance.setColorScheme(colorScheme ?? 'unspecified');
|
|
108
|
-
state.appearance = {
|
|
108
|
+
state.appearance = {
|
|
109
|
+
colorScheme: toColorScheme(NativeAppearance.getColorScheme()),
|
|
110
|
+
};
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
|
package/React/Base/RCTRootView.m
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
#import "RCTBridge.h"
|
|
17
17
|
#import "RCTConstants.h"
|
|
18
18
|
#import "RCTDevSettings.h" // [macOS]
|
|
19
|
+
#import "RCTFocusChangeEvent.h" // [macOS]
|
|
19
20
|
// [macOS] remove #import "RCTKeyCommands.h"
|
|
20
21
|
#import "RCTLog.h"
|
|
21
22
|
#import "RCTPerformanceLogger.h"
|
|
@@ -432,6 +433,63 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
|
|
|
432
433
|
#endif // macOS]
|
|
433
434
|
|
|
434
435
|
|
|
436
|
+
#pragma mark - Key window blur/focus
|
|
437
|
+
|
|
438
|
+
#if TARGET_OS_OSX // [macOS
|
|
439
|
+
- (void)viewDidMoveToWindow {
|
|
440
|
+
[super viewDidMoveToWindow];
|
|
441
|
+
|
|
442
|
+
NSWindow *window = [self window];
|
|
443
|
+
if (window == nil) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
448
|
+
selector:@selector(containingWindowDidBecomeKey)
|
|
449
|
+
name:NSWindowDidBecomeKeyNotification
|
|
450
|
+
object:window];
|
|
451
|
+
|
|
452
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
453
|
+
selector:@selector(containingWindowDidResignKey)
|
|
454
|
+
name:NSWindowDidResignKeyNotification
|
|
455
|
+
object:window];
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
+ (NSNumber *)reactTagClosestToView:(RCTPlatformView *)view {
|
|
459
|
+
// The first responder may not necessarily have a React tag. For example, if we're focused on
|
|
460
|
+
// a multiline <TextInput>, the RN component whose blur/focus events we need to touch is an
|
|
461
|
+
// RCTMultilineTextInputView, but the first responder will be the underlying RCTUITextView.
|
|
462
|
+
for (RCTPlatformView *testView = view; testView != nil; testView = [testView superview]) {
|
|
463
|
+
NSNumber *reactTag = [testView reactTag];
|
|
464
|
+
if (reactTag != nil) {
|
|
465
|
+
return reactTag;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return nil;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
- (void)containingWindowDidBecomeKey {
|
|
472
|
+
NSResponder *firstResponder = [[self window] firstResponder];
|
|
473
|
+
if ([firstResponder isKindOfClass:[RCTPlatformView class]]) {
|
|
474
|
+
NSNumber *reactTag = [RCTRootView reactTagClosestToView:(RCTPlatformView *)firstResponder];
|
|
475
|
+
if (reactTag != nil) {
|
|
476
|
+
[[[self bridge] eventDispatcher] sendEvent:[RCTFocusChangeEvent focusEventWithReactTag:reactTag]];
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
- (void)containingWindowDidResignKey {
|
|
482
|
+
NSResponder *firstResponder = [[self window] firstResponder];
|
|
483
|
+
if ([firstResponder isKindOfClass:[RCTPlatformView class]]) {
|
|
484
|
+
NSNumber *reactTag = [RCTRootView reactTagClosestToView:(RCTPlatformView *)firstResponder];
|
|
485
|
+
if (reactTag != nil) {
|
|
486
|
+
[[[self bridge] eventDispatcher] sendEvent:[RCTFocusChangeEvent blurEventWithReactTag:reactTag]];
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
#endif // macOS]
|
|
491
|
+
|
|
492
|
+
|
|
435
493
|
#if TARGET_OS_OSX // [macOS
|
|
436
494
|
- (NSMenu *)menuForEvent:(NSEvent *)event
|
|
437
495
|
{
|
|
@@ -128,8 +128,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)coder)
|
|
|
128
128
|
#else // [macOS
|
|
129
129
|
// -[NSView hitTest:] takes coordinates in a view's superview coordinate system.
|
|
130
130
|
// The assumption here is that a RCTUIView/RCTSurfaceView will always have a superview.
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
NSView *superview = [[self view] superview];
|
|
132
|
+
const CGPoint touchLocationInSuperview = [superview convertPoint:touch.locationInWindow fromView:nil];
|
|
133
|
+
NSView *targetView = [self.view hitTest:touchLocationInSuperview];
|
|
133
134
|
// Don't record clicks on scrollbars.
|
|
134
135
|
if ([targetView isKindOfClass:[NSScroller class]]) {
|
|
135
136
|
continue;
|
|
@@ -148,8 +149,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)coder)
|
|
|
148
149
|
} else {
|
|
149
150
|
_shouldSendMouseUpOnSystemBehalf = NO;
|
|
150
151
|
}
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
|
|
153
153
|
while (targetView) {
|
|
154
154
|
BOOL isUserInteractionEnabled = NO;
|
|
155
155
|
if ([((RCTUIView*)targetView) respondsToSelector:@selector(isUserInteractionEnabled)]) { // [macOS]
|
|
@@ -161,7 +161,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)coder)
|
|
|
161
161
|
targetView = targetView.superview;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
const CGPoint touchLocationInSelf = [targetView convertPoint:touchLocationInSuperview fromView:self.view.superview];
|
|
165
|
+
NSNumber *reactTag = [targetView reactTagAtPoint:touchLocationInSelf];
|
|
165
166
|
BOOL isUserInteractionEnabled = NO;
|
|
166
167
|
if ([((RCTUIView*)targetView) respondsToSelector:@selector(isUserInteractionEnabled)]) { // [macOS]
|
|
167
168
|
isUserInteractionEnabled = ((RCTUIView*)targetView).isUserInteractionEnabled; // [macOS]
|
package/React/Base/RCTUIKit.h
CHANGED
|
@@ -486,7 +486,10 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
|
|
|
486
486
|
|
|
487
487
|
NS_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, __unused UIEvent *__nullable event)
|
|
488
488
|
{
|
|
489
|
-
|
|
489
|
+
// [macOS IMPORTANT -- point is in local coordinate space, but OSX expects super coordinate space for hitTest:
|
|
490
|
+
NSView *superview = [view superview];
|
|
491
|
+
NSPoint pointInSuperview = superview != nil ? [view convertPoint:point toView:superview] : point;
|
|
492
|
+
return [view hitTest:pointInSuperview];
|
|
490
493
|
}
|
|
491
494
|
|
|
492
495
|
BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view);
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -53,11 +53,8 @@ static RCTRootViewSizeFlexibility convertToRootViewSizeFlexibility(RCTSurfaceSiz
|
|
|
53
53
|
|
|
54
54
|
- (instancetype)initWithSurface:(id<RCTSurfaceProtocol>)surface
|
|
55
55
|
{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
[surface start];
|
|
59
|
-
}
|
|
60
|
-
return self;
|
|
56
|
+
return [super initWithSurface:surface
|
|
57
|
+
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact];
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
|
|
@@ -454,7 +454,10 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
454
454
|
|
|
455
455
|
- (NSView *)hitTest:(NSPoint)point
|
|
456
456
|
{
|
|
457
|
-
|
|
457
|
+
// IMPORTANT point is passed in super coordinates by OSX, but expected to be passed in local coordinates
|
|
458
|
+
NSView *superview = [self superview];
|
|
459
|
+
NSPoint pointInSelf = superview != nil ? [self convertPoint:point fromView:superview] : point;
|
|
460
|
+
return [self hitTest:pointInSelf withEvent:nil];
|
|
458
461
|
}
|
|
459
462
|
|
|
460
463
|
- (BOOL)wantsUpdateLayer
|
|
@@ -505,7 +508,11 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
505
508
|
|
|
506
509
|
- (NSView *)hitTest:(CGPoint)point withEvent:(__unused UIEvent *)event
|
|
507
510
|
{
|
|
508
|
-
|
|
511
|
+
// [macOS
|
|
512
|
+
// IMPORTANT point is expected to be passed in local coordinates, but OSX expects point to be super
|
|
513
|
+
NSView *superview = [self superview];
|
|
514
|
+
NSPoint pointInSuperview = superview != nil ? [self convertPoint:point toView:superview] : point;
|
|
515
|
+
return self.userInteractionEnabled ? [super hitTest:pointInSuperview] : nil;
|
|
509
516
|
}
|
|
510
517
|
|
|
511
518
|
- (BOOL)pointInside:(CGPoint)point withEvent:(__unused UIEvent *)event
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
* UIView class for root <ModalHostView> component.
|
|
12
12
|
*/
|
|
13
13
|
@interface RCTModalHostViewComponentView : RCTViewComponentView
|
|
14
|
-
|
|
15
14
|
#if !TARGET_OS_OSX // [macOS]
|
|
15
|
+
<UIAdaptivePresentationControllerDelegate>
|
|
16
|
+
|
|
16
17
|
/**
|
|
17
18
|
* Subclasses may override this method and present the modal on different view controller.
|
|
18
19
|
* Default implementation presents the modal on `[self reactViewController]`.
|
|
@@ -137,9 +137,7 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct(
|
|
|
137
137
|
completion:(void (^)(void))completion
|
|
138
138
|
{
|
|
139
139
|
UIViewController *controller = [self reactViewController];
|
|
140
|
-
[
|
|
141
|
-
animated:animated
|
|
142
|
-
completion:completion];
|
|
140
|
+
[controller presentViewController:modalViewController animated:animated completion:completion];
|
|
143
141
|
}
|
|
144
142
|
|
|
145
143
|
- (void)dismissViewController:(UIViewController *)modalViewController
|
|
@@ -154,6 +152,8 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct(
|
|
|
154
152
|
{
|
|
155
153
|
BOOL shouldBePresented = !_isPresented && _shouldPresent && self.window;
|
|
156
154
|
if (shouldBePresented) {
|
|
155
|
+
self.viewController.presentationController.delegate = self;
|
|
156
|
+
|
|
157
157
|
_isPresented = YES;
|
|
158
158
|
[self presentViewController:self.viewController
|
|
159
159
|
animated:_shouldAnimatePresentation
|
|
@@ -279,24 +279,14 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct(
|
|
|
279
279
|
[childComponentView removeFromSuperview];
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
#pragma mark -
|
|
282
|
+
#pragma mark - UIAdaptivePresentationControllerDelegate
|
|
283
283
|
|
|
284
|
-
- (
|
|
284
|
+
- (void)presentationControllerDidAttemptToDismiss:(UIPresentationController *)controller
|
|
285
285
|
{
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
if ([topController isKindOfClass:[UINavigationController class]]) {
|
|
291
|
-
UINavigationController *navigationController = (UINavigationController *)topController;
|
|
292
|
-
topController = navigationController.visibleViewController;
|
|
293
|
-
return [self _topMostViewControllerFrom:topController];
|
|
294
|
-
} else if ([topController isKindOfClass:[UITabBarController class]]) {
|
|
295
|
-
UITabBarController *tabBarController = (UITabBarController *)topController;
|
|
296
|
-
topController = tabBarController.selectedViewController;
|
|
297
|
-
return [self _topMostViewControllerFrom:topController];
|
|
286
|
+
auto eventEmitter = [self modalEventEmitter];
|
|
287
|
+
if (eventEmitter) {
|
|
288
|
+
eventEmitter->onRequestClose({});
|
|
298
289
|
}
|
|
299
|
-
return topController;
|
|
300
290
|
}
|
|
301
291
|
|
|
302
292
|
#endif // [macOS]
|
|
@@ -38,6 +38,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
38
38
|
/** Focus area of newly-activated text input relative to the window to compare against UIKeyboardFrameBegin/End */
|
|
39
39
|
@property (nonatomic, assign) CGRect firstResponderFocus;
|
|
40
40
|
|
|
41
|
+
/** newly-activated text input outside of the scroll view */
|
|
42
|
+
@property (nonatomic, weak) RCTPlatformView *firstResponderViewOutsideScrollView; // [macOS]
|
|
43
|
+
|
|
41
44
|
/*
|
|
42
45
|
* Returns the subview of the scroll view that the component uses to mount all subcomponents into. That's useful to
|
|
43
46
|
* separate component views from auxiliary views to be able to reliably implement pull-to-refresh- and RTL-related
|
|
@@ -199,16 +199,18 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(RCTUIScrollView *scrollView, NS
|
|
|
199
199
|
UIViewAnimationCurve curve =
|
|
200
200
|
(UIViewAnimationCurve)[notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] unsignedIntegerValue];
|
|
201
201
|
CGRect keyboardEndFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
|
202
|
+
CGRect keyboardBeginFrame = [notification.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
|
|
202
203
|
|
|
203
204
|
CGPoint absoluteViewOrigin = [self convertPoint:self.bounds.origin toView:nil];
|
|
204
205
|
CGFloat scrollViewLowerY = isInverted ? absoluteViewOrigin.y : absoluteViewOrigin.y + self.bounds.size.height;
|
|
205
206
|
|
|
206
207
|
UIEdgeInsets newEdgeInsets = _scrollView.contentInset;
|
|
207
208
|
CGFloat inset = MAX(scrollViewLowerY - keyboardEndFrame.origin.y, 0);
|
|
209
|
+
const auto &props = static_cast<const ScrollViewProps &>(*_props);
|
|
208
210
|
if (isInverted) {
|
|
209
|
-
newEdgeInsets.top = MAX(inset,
|
|
211
|
+
newEdgeInsets.top = MAX(inset, props.contentInset.top);
|
|
210
212
|
} else {
|
|
211
|
-
newEdgeInsets.bottom = MAX(inset,
|
|
213
|
+
newEdgeInsets.bottom = MAX(inset, props.contentInset.bottom);
|
|
212
214
|
}
|
|
213
215
|
|
|
214
216
|
CGPoint newContentOffset = _scrollView.contentOffset;
|
|
@@ -220,21 +222,18 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(RCTUIScrollView *scrollView, NS
|
|
|
220
222
|
from:self
|
|
221
223
|
forEvent:nil]) {
|
|
222
224
|
if (CGRectEqualToRect(_firstResponderFocus, CGRectNull)) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (focusEnd > keyboardEndFrame.origin.y) {
|
|
236
|
-
// Text field active region is below visible area with keyboard - update diff to bring into view
|
|
237
|
-
contentDiff = keyboardEndFrame.origin.y - focusEnd;
|
|
225
|
+
UIView *inputAccessoryView = _firstResponderViewOutsideScrollView.inputAccessoryView;
|
|
226
|
+
if (inputAccessoryView) {
|
|
227
|
+
// Text input view is within the inputAccessoryView.
|
|
228
|
+
contentDiff = keyboardEndFrame.origin.y - keyboardBeginFrame.origin.y;
|
|
229
|
+
}
|
|
230
|
+
} else {
|
|
231
|
+
// Inner text field focused
|
|
232
|
+
CGFloat focusEnd = CGRectGetMaxY(self.firstResponderFocus);
|
|
233
|
+
if (focusEnd > keyboardEndFrame.origin.y) {
|
|
234
|
+
// Text field active region is below visible area with keyboard - update diff to bring into view
|
|
235
|
+
contentDiff = keyboardEndFrame.origin.y - focusEnd;
|
|
236
|
+
}
|
|
238
237
|
}
|
|
239
238
|
}
|
|
240
239
|
|
|
@@ -260,7 +259,7 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(RCTUIScrollView *scrollView, NS
|
|
|
260
259
|
animations:^{
|
|
261
260
|
self->_scrollView.contentInset = newEdgeInsets;
|
|
262
261
|
self->_scrollView.verticalScrollIndicatorInsets = newEdgeInsets;
|
|
263
|
-
[self
|
|
262
|
+
[self scrollTo:newContentOffset.x y:newContentOffset.y animated:NO];
|
|
264
263
|
}
|
|
265
264
|
completion:nil];
|
|
266
265
|
}
|
|
@@ -107,9 +107,11 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
107
107
|
NSMutableDictionary<NSAttributedStringKey, id> *defaultAttributes =
|
|
108
108
|
[_backedTextInputView.defaultTextAttributes mutableCopy];
|
|
109
109
|
|
|
110
|
+
#if !TARGET_OS_MACCATALYST
|
|
110
111
|
RCTWeakEventEmitterWrapper *eventEmitterWrapper = [RCTWeakEventEmitterWrapper new];
|
|
111
112
|
eventEmitterWrapper.eventEmitter = _eventEmitter;
|
|
112
113
|
defaultAttributes[RCTAttributedStringEventEmitterKey] = eventEmitterWrapper;
|
|
114
|
+
#endif
|
|
113
115
|
|
|
114
116
|
_backedTextInputView.defaultTextAttributes = defaultAttributes;
|
|
115
117
|
}
|
|
@@ -139,6 +141,7 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
139
141
|
#if !TARGET_OS_OSX // [macOS]
|
|
140
142
|
if (![self isDescendantOfView:scrollView.scrollView] || !_backedTextInputView.isFirstResponder) {
|
|
141
143
|
// View is outside scroll view or it's not a first responder.
|
|
144
|
+
scrollView.firstResponderViewOutsideScrollView = _backedTextInputView;
|
|
142
145
|
return;
|
|
143
146
|
}
|
|
144
147
|
|
|
@@ -283,8 +286,10 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
283
286
|
if (newTextInputProps.textAttributes != oldTextInputProps.textAttributes) {
|
|
284
287
|
NSMutableDictionary<NSAttributedStringKey, id> *defaultAttributes =
|
|
285
288
|
RCTNSTextAttributesFromTextAttributes(newTextInputProps.getEffectiveTextAttributes(RCTFontSizeMultiplier()));
|
|
289
|
+
#if !TARGET_OS_MACCATALYST
|
|
286
290
|
defaultAttributes[RCTAttributedStringEventEmitterKey] =
|
|
287
291
|
_backedTextInputView.defaultTextAttributes[RCTAttributedStringEventEmitterKey];
|
|
292
|
+
#endif
|
|
288
293
|
_backedTextInputView.defaultTextAttributes = defaultAttributes;
|
|
289
294
|
}
|
|
290
295
|
|
|
@@ -473,10 +478,15 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
473
478
|
|
|
474
479
|
- (void)textInputDidChangeSelection
|
|
475
480
|
{
|
|
476
|
-
[self _updateTypingAttributes];
|
|
477
481
|
if (_comingFromJS) {
|
|
478
482
|
return;
|
|
479
483
|
}
|
|
484
|
+
|
|
485
|
+
// T207198334: Setting a new AttributedString (_comingFromJS) will trigger a selection change before the backing
|
|
486
|
+
// string is updated, so indicies won't point to what we want yet. Only respond to user selection change, and let
|
|
487
|
+
// `_setAttributedString` handle updating typing attributes if content changes.
|
|
488
|
+
[self _updateTypingAttributes];
|
|
489
|
+
|
|
480
490
|
const auto &props = static_cast<const TextInputProps &>(*_props);
|
|
481
491
|
if (props.traits.multiline && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
|
|
482
492
|
[self textInputDidChange];
|
|
@@ -805,18 +815,19 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
805
815
|
// https://github.com/facebook/react-native/blob/3102a58df38d96f3dacef0530e4dbb399037fcd2/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/span/SetSpanOperation.kt#L30
|
|
806
816
|
- (void)_updateTypingAttributes
|
|
807
817
|
{
|
|
808
|
-
if (_backedTextInputView.attributedText.length > 0) {
|
|
809
818
|
#if !TARGET_OS_OSX // [macOS]
|
|
819
|
+
if (_backedTextInputView.attributedText.length > 0 && _backedTextInputView.selectedTextRange != nil) {
|
|
810
820
|
NSUInteger offsetStart = [_backedTextInputView offsetFromPosition:_backedTextInputView.beginningOfDocument
|
|
811
821
|
toPosition:_backedTextInputView.selectedTextRange.start];
|
|
812
|
-
|
|
813
|
-
NSUInteger offsetStart = [_backedTextInputView selectedTextRange].location;
|
|
814
|
-
#endif // macOS]
|
|
822
|
+
|
|
815
823
|
|
|
816
824
|
NSUInteger samplePoint = offsetStart == 0 ? 0 : offsetStart - 1;
|
|
817
825
|
_backedTextInputView.typingAttributes = [_backedTextInputView.attributedText attributesAtIndex:samplePoint
|
|
818
826
|
effectiveRange:NULL];
|
|
819
827
|
}
|
|
828
|
+
#else // [macOS
|
|
829
|
+
// TODO
|
|
830
|
+
#endif // macOS]
|
|
820
831
|
}
|
|
821
832
|
|
|
822
833
|
- (void)_setMultiline:(BOOL)multiline
|
|
@@ -1165,15 +1165,10 @@ static RCTCursor RCTCursorFromCursor(Cursor cursor)
|
|
|
1165
1165
|
}
|
|
1166
1166
|
|
|
1167
1167
|
// clipping
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
cornerInsets:RCTGetCornerInsets(
|
|
1173
|
-
RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii),
|
|
1174
|
-
RCTUIEdgeInsetsFromEdgeInsets(borderMetrics.borderWidths))];
|
|
1175
|
-
self.currentContainerView.layer.mask = maskLayer;
|
|
1176
|
-
} else {
|
|
1168
|
+
self.currentContainerView.layer.mask = nil;
|
|
1169
|
+
if (self.currentContainerView.clipsToBounds) {
|
|
1170
|
+
BOOL clipToPaddingBox = ReactNativeFeatureFlags::enableIOSViewClipToPaddingBox();
|
|
1171
|
+
if (!clipToPaddingBox) {
|
|
1177
1172
|
if (borderMetrics.borderRadii.isUniform()) {
|
|
1178
1173
|
self.currentContainerView.layer.cornerRadius = borderMetrics.borderRadii.topLeft.horizontal;
|
|
1179
1174
|
} else {
|
|
@@ -1195,9 +1190,17 @@ static RCTCursor RCTCursorFromCursor(Cursor cursor)
|
|
|
1195
1190
|
subview.layer.mask = [self createMaskLayer:subview.bounds cornerInsets:cornerInsets];
|
|
1196
1191
|
}
|
|
1197
1192
|
}
|
|
1193
|
+
} else if (
|
|
1194
|
+
!borderMetrics.borderWidths.isUniform() || borderMetrics.borderWidths.left != 0 ||
|
|
1195
|
+
!borderMetrics.borderRadii.isUniform()) {
|
|
1196
|
+
CALayer *maskLayer = [self createMaskLayer:RCTCGRectFromRect(_layoutMetrics.getPaddingFrame())
|
|
1197
|
+
cornerInsets:RCTGetCornerInsets(
|
|
1198
|
+
RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii),
|
|
1199
|
+
RCTUIEdgeInsetsFromEdgeInsets(borderMetrics.borderWidths))];
|
|
1200
|
+
self.currentContainerView.layer.mask = maskLayer;
|
|
1201
|
+
} else {
|
|
1202
|
+
self.currentContainerView.layer.cornerRadius = borderMetrics.borderRadii.topLeft.horizontal;
|
|
1198
1203
|
}
|
|
1199
|
-
} else {
|
|
1200
|
-
self.currentContainerView.layer.mask = nil;
|
|
1201
1204
|
}
|
|
1202
1205
|
}
|
|
1203
1206
|
|