react-native-macos 0.81.4 → 0.81.6
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/Pressable/Pressable.js +8 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +16 -0
- package/Libraries/Components/TextInput/TextInput.js +26 -9
- package/Libraries/Components/View/View.js +30 -10
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/LinkingIOS/RCTLinkingManager.mm +119 -0
- package/Libraries/LinkingIOS/React-RCTLinking.podspec +0 -4
- package/Libraries/Text/RCTTextAttributes.mm +1 -1
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +1 -1
- package/Libraries/Text/TextInput/RCTBaseTextInputView.mm +1 -1
- package/Libraries/Utilities/normalizeLegacyHandledKeyEvents.js +164 -0
- package/React/Base/RCTRootView.m +7 -0
- package/React/Base/RCTUIKit.h +18 -7
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm +9 -0
- package/React/Base/macOS/RCTUIKit.m +65 -8
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.h +6 -0
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm +77 -1
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h +4 -0
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +93 -3
- package/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm +306 -8
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +6 -0
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +26 -18
- package/React/Modules/RCTUIManager.mm +1 -1
- package/React/Views/RCTCursor.m +0 -1
- package/React/Views/RCTView.m +1 -2
- package/React/Views/ScrollView/RCTScrollView.m +25 -0
- package/React/Views/UIView+React.m +1 -1
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
- package/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp +1 -1
- package/ReactCommon/react/renderer/graphics/Color.h +1 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h +10 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm +83 -6
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/PlatformColorParser.mm +18 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/RCTPlatformColorUtils.mm +144 -3
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm +1 -1
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.h +2 -2
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm +3 -3
- package/local-cli/generate-macos.js +0 -3
- package/local-cli/generator-common/index.js +5 -5
- package/local-cli/generator-macos/index.js +7 -22
- package/package.json +2 -2
- package/Libraries/LinkingIOS/macos/RCTLinkingManager.mm +0 -123
|
@@ -381,7 +381,14 @@ function Pressable({
|
|
|
381
381
|
// [macOS
|
|
382
382
|
acceptsFirstMouse: acceptsFirstMouse !== false && !disabled,
|
|
383
383
|
enableFocusRing: enableFocusRing !== false && !disabled,
|
|
384
|
-
keyDownEvents:
|
|
384
|
+
keyDownEvents:
|
|
385
|
+
keyDownEvents ??
|
|
386
|
+
// $FlowFixMe[unclear-type] Legacy props not in type definitions
|
|
387
|
+
(((props: any).validKeysDown: mixed) == null &&
|
|
388
|
+
// $FlowFixMe[unclear-type]
|
|
389
|
+
((props: any).passthroughAllKeyEvents: mixed) !== true
|
|
390
|
+
? [{key: ' '}, {key: 'Enter'}]
|
|
391
|
+
: undefined),
|
|
385
392
|
mouseDownCanMoveWindow: false,
|
|
386
393
|
// macOS]
|
|
387
394
|
};
|
|
@@ -52,6 +52,18 @@ const RCTTextInputViewConfig: PartialViewConfigWithoutName = {
|
|
|
52
52
|
captured: 'onSubmitEditingCapture',
|
|
53
53
|
},
|
|
54
54
|
},
|
|
55
|
+
topKeyDown: {
|
|
56
|
+
phasedRegistrationNames: {
|
|
57
|
+
bubbled: 'onKeyDown',
|
|
58
|
+
captured: 'onKeyDownCapture',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
topKeyUp: {
|
|
62
|
+
phasedRegistrationNames: {
|
|
63
|
+
bubbled: 'onKeyUp',
|
|
64
|
+
captured: 'onKeyUpCapture',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
55
67
|
topTouchCancel: {
|
|
56
68
|
phasedRegistrationNames: {
|
|
57
69
|
bubbled: 'onTouchCancel',
|
|
@@ -173,6 +185,8 @@ const RCTTextInputViewConfig: PartialViewConfigWithoutName = {
|
|
|
173
185
|
clearTextOnSubmit: true,
|
|
174
186
|
grammarCheck: true,
|
|
175
187
|
hideVerticalScrollIndicator: true,
|
|
188
|
+
keyDownEvents: true,
|
|
189
|
+
keyUpEvents: true,
|
|
176
190
|
pastedTypes: true,
|
|
177
191
|
submitKeyEvents: true,
|
|
178
192
|
tooltip: true,
|
|
@@ -191,6 +205,8 @@ const RCTTextInputViewConfig: PartialViewConfigWithoutName = {
|
|
|
191
205
|
onAutoCorrectChange: true,
|
|
192
206
|
onSpellCheckChange: true,
|
|
193
207
|
onGrammarCheckChange: true,
|
|
208
|
+
onKeyDown: true,
|
|
209
|
+
onKeyUp: true,
|
|
194
210
|
// macOS]
|
|
195
211
|
}),
|
|
196
212
|
disableKeyboardShortcuts: true,
|
|
@@ -60,7 +60,13 @@ import flattenStyle from '../../StyleSheet/flattenStyle';
|
|
|
60
60
|
import StyleSheet, {type TextStyleProp} from '../../StyleSheet/StyleSheet';
|
|
61
61
|
import Text from '../../Text/Text';
|
|
62
62
|
import TextAncestorContext from '../../Text/TextAncestorContext';
|
|
63
|
+
// [macOS
|
|
64
|
+
import processLegacyKeyProps, {
|
|
65
|
+
hasLegacyKeyProps,
|
|
66
|
+
stripLegacyKeyProps,
|
|
67
|
+
} from '../../Utilities/normalizeLegacyHandledKeyEvents';
|
|
63
68
|
import Platform from '../../Utilities/Platform';
|
|
69
|
+
// macOS]
|
|
64
70
|
import useMergeRefs from '../../Utilities/useMergeRefs';
|
|
65
71
|
import TextInputState from './TextInputState';
|
|
66
72
|
import invariant from 'invariant';
|
|
@@ -386,6 +392,11 @@ function useTextInputStateSynchronization({
|
|
|
386
392
|
*
|
|
387
393
|
*/
|
|
388
394
|
function InternalTextInput(props: TextInputProps): React.Node {
|
|
395
|
+
// [macOS
|
|
396
|
+
const legacyKeyOverrides = hasLegacyKeyProps(props)
|
|
397
|
+
? processLegacyKeyProps(props)
|
|
398
|
+
: null;
|
|
399
|
+
// macOS]
|
|
389
400
|
const {
|
|
390
401
|
'aria-busy': ariaBusy,
|
|
391
402
|
'aria-checked': ariaChecked,
|
|
@@ -400,7 +411,9 @@ function InternalTextInput(props: TextInputProps): React.Node {
|
|
|
400
411
|
selectionHandleColor,
|
|
401
412
|
cursorColor,
|
|
402
413
|
...otherProps
|
|
403
|
-
|
|
414
|
+
// $FlowFixMe[unclear-type]
|
|
415
|
+
} = ({...props, ...legacyKeyOverrides}: any); // [macOS]
|
|
416
|
+
stripLegacyKeyProps(otherProps); // [macOS]
|
|
404
417
|
|
|
405
418
|
const inputRef = useRef<null | TextInputInstance>(null);
|
|
406
419
|
|
|
@@ -581,10 +594,15 @@ function InternalTextInput(props: TextInputProps): React.Node {
|
|
|
581
594
|
};
|
|
582
595
|
|
|
583
596
|
// [macOS
|
|
597
|
+
const _keyDownEvents =
|
|
598
|
+
legacyKeyOverrides?.keyDownEvents ?? props.keyDownEvents;
|
|
599
|
+
const _keyUpEvents = legacyKeyOverrides?.keyUpEvents ?? props.keyUpEvents;
|
|
600
|
+
const _origOnKeyDown = legacyKeyOverrides?.onKeyDown ?? props.onKeyDown;
|
|
601
|
+
const _origOnKeyUp = legacyKeyOverrides?.onKeyUp ?? props.onKeyUp;
|
|
602
|
+
|
|
584
603
|
const _onKeyDown = (event: KeyEvent) => {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
const isHandled = keyDownEvents.some(
|
|
604
|
+
if (_keyDownEvents != null && !event.isPropagationStopped()) {
|
|
605
|
+
const isHandled = _keyDownEvents.some(
|
|
588
606
|
({key, metaKey, ctrlKey, altKey, shiftKey}: HandledKeyEvent) => {
|
|
589
607
|
return (
|
|
590
608
|
event.nativeEvent.key === key &&
|
|
@@ -599,13 +617,12 @@ function InternalTextInput(props: TextInputProps): React.Node {
|
|
|
599
617
|
event.stopPropagation();
|
|
600
618
|
}
|
|
601
619
|
}
|
|
602
|
-
|
|
620
|
+
_origOnKeyDown?.(event);
|
|
603
621
|
};
|
|
604
622
|
|
|
605
623
|
const _onKeyUp = (event: KeyEvent) => {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
const isHandled = keyUpEvents.some(
|
|
624
|
+
if (_keyUpEvents != null && !event.isPropagationStopped()) {
|
|
625
|
+
const isHandled = _keyUpEvents.some(
|
|
609
626
|
({key, metaKey, ctrlKey, altKey, shiftKey}: HandledKeyEvent) => {
|
|
610
627
|
return (
|
|
611
628
|
event.nativeEvent.key === key &&
|
|
@@ -620,7 +637,7 @@ function InternalTextInput(props: TextInputProps): React.Node {
|
|
|
620
637
|
event.stopPropagation();
|
|
621
638
|
}
|
|
622
639
|
}
|
|
623
|
-
|
|
640
|
+
_origOnKeyUp?.(event);
|
|
624
641
|
};
|
|
625
642
|
// macOS]
|
|
626
643
|
|
|
@@ -13,6 +13,12 @@ import type {ViewProps} from './ViewPropTypes';
|
|
|
13
13
|
|
|
14
14
|
import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
|
|
15
15
|
import TextAncestorContext from '../../Text/TextAncestorContext';
|
|
16
|
+
// [macOS
|
|
17
|
+
import processLegacyKeyProps, {
|
|
18
|
+
hasLegacyKeyProps,
|
|
19
|
+
stripLegacyKeyProps,
|
|
20
|
+
} from '../../Utilities/normalizeLegacyHandledKeyEvents';
|
|
21
|
+
// macOS]
|
|
16
22
|
import ViewNativeComponent from './ViewNativeComponent';
|
|
17
23
|
import * as React from 'react';
|
|
18
24
|
import {use} from 'react';
|
|
@@ -30,13 +36,24 @@ component View(
|
|
|
30
36
|
) {
|
|
31
37
|
const hasTextAncestor = use(TextAncestorContext);
|
|
32
38
|
|
|
39
|
+
// [macOS
|
|
40
|
+
const legacyKeyOverrides = hasLegacyKeyProps(props)
|
|
41
|
+
? processLegacyKeyProps(props)
|
|
42
|
+
: null;
|
|
43
|
+
// macOS]
|
|
44
|
+
|
|
33
45
|
let actualView;
|
|
34
46
|
|
|
35
47
|
// [macOS
|
|
48
|
+
const _keyDownEvents =
|
|
49
|
+
legacyKeyOverrides?.keyDownEvents ?? props.keyDownEvents;
|
|
50
|
+
const _keyUpEvents = legacyKeyOverrides?.keyUpEvents ?? props.keyUpEvents;
|
|
51
|
+
const _origOnKeyDown = legacyKeyOverrides?.onKeyDown ?? props.onKeyDown;
|
|
52
|
+
const _origOnKeyUp = legacyKeyOverrides?.onKeyUp ?? props.onKeyUp;
|
|
53
|
+
|
|
36
54
|
const _onKeyDown = (event: KeyEvent) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const isHandled = keyDownEvents.some(
|
|
55
|
+
if (_keyDownEvents != null && !event.isPropagationStopped()) {
|
|
56
|
+
const isHandled = _keyDownEvents.some(
|
|
40
57
|
({key, metaKey, ctrlKey, altKey, shiftKey}: HandledKeyEvent) => {
|
|
41
58
|
return (
|
|
42
59
|
event.nativeEvent.key === key &&
|
|
@@ -51,13 +68,12 @@ component View(
|
|
|
51
68
|
event.stopPropagation();
|
|
52
69
|
}
|
|
53
70
|
}
|
|
54
|
-
|
|
71
|
+
_origOnKeyDown?.(event);
|
|
55
72
|
};
|
|
56
73
|
|
|
57
74
|
const _onKeyUp = (event: KeyEvent) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const isHandled = keyUpEvents.some(
|
|
75
|
+
if (_keyUpEvents != null && !event.isPropagationStopped()) {
|
|
76
|
+
const isHandled = _keyUpEvents.some(
|
|
61
77
|
({key, metaKey, ctrlKey, altKey, shiftKey}: HandledKeyEvent) => {
|
|
62
78
|
return (
|
|
63
79
|
event.nativeEvent.key === key &&
|
|
@@ -72,7 +88,7 @@ component View(
|
|
|
72
88
|
event.stopPropagation();
|
|
73
89
|
}
|
|
74
90
|
}
|
|
75
|
-
|
|
91
|
+
_origOnKeyUp?.(event);
|
|
76
92
|
};
|
|
77
93
|
// macOS]
|
|
78
94
|
|
|
@@ -96,10 +112,12 @@ component View(
|
|
|
96
112
|
id,
|
|
97
113
|
tabIndex,
|
|
98
114
|
...otherProps
|
|
99
|
-
|
|
115
|
+
// $FlowFixMe[unclear-type]
|
|
116
|
+
} = ({...props, ...legacyKeyOverrides}: any); // [macOS]
|
|
100
117
|
|
|
101
118
|
// Since we destructured props, we can now treat it as mutable
|
|
102
119
|
const processedProps = otherProps as {...ViewProps};
|
|
120
|
+
stripLegacyKeyProps(processedProps); // [macOS]
|
|
103
121
|
|
|
104
122
|
const parsedAriaLabelledBy = ariaLabelledBy?.split(/\s*,\s*/g);
|
|
105
123
|
if (parsedAriaLabelledBy !== undefined) {
|
|
@@ -195,7 +213,9 @@ component View(
|
|
|
195
213
|
nativeID,
|
|
196
214
|
tabIndex,
|
|
197
215
|
...otherProps
|
|
198
|
-
|
|
216
|
+
// $FlowFixMe[unclear-type]
|
|
217
|
+
} = ({...props, ...legacyKeyOverrides}: any); // [macOS]
|
|
218
|
+
stripLegacyKeyProps(otherProps); // [macOS]
|
|
199
219
|
const _accessibilityLabelledBy =
|
|
200
220
|
ariaLabelledBy?.split(/\s*,\s*/g) ?? accessibilityLabelledBy;
|
|
201
221
|
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
#import "RCTLinkingPlugins.h"
|
|
16
16
|
|
|
17
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
18
|
+
|
|
17
19
|
static NSString *const kOpenURLNotification = @"RCTOpenURLNotification";
|
|
18
20
|
|
|
19
21
|
static void postNotificationWithURL(NSURL *URL, id sender)
|
|
@@ -22,6 +24,24 @@ static void postNotificationWithURL(NSURL *URL, id sender)
|
|
|
22
24
|
[[NSNotificationCenter defaultCenter] postNotificationName:kOpenURLNotification object:sender userInfo:payload];
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
#else // [macOS
|
|
28
|
+
|
|
29
|
+
NSString *const RCTOpenURLNotification = @"RCTOpenURLNotification";
|
|
30
|
+
|
|
31
|
+
static NSString *initialURL = nil;
|
|
32
|
+
static BOOL moduleInitalized = NO;
|
|
33
|
+
static BOOL alwaysForegroundLastWindow = YES;
|
|
34
|
+
|
|
35
|
+
static void postNotificationWithURL(NSString *url, id sender)
|
|
36
|
+
{
|
|
37
|
+
NSDictionary<NSString *, id> *payload = @{@"url": url};
|
|
38
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:RCTOpenURLNotification
|
|
39
|
+
object:sender
|
|
40
|
+
userInfo:payload];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#endif // macOS]
|
|
44
|
+
|
|
25
45
|
@interface RCTLinkingManager () <NativeLinkingManagerSpec>
|
|
26
46
|
@end
|
|
27
47
|
|
|
@@ -34,6 +54,8 @@ RCT_EXPORT_MODULE()
|
|
|
34
54
|
return dispatch_get_main_queue();
|
|
35
55
|
}
|
|
36
56
|
|
|
57
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
58
|
+
|
|
37
59
|
- (void)startObserving
|
|
38
60
|
{
|
|
39
61
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
@@ -47,11 +69,33 @@ RCT_EXPORT_MODULE()
|
|
|
47
69
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
48
70
|
}
|
|
49
71
|
|
|
72
|
+
#else // [macOS
|
|
73
|
+
|
|
74
|
+
- (void)startObserving
|
|
75
|
+
{
|
|
76
|
+
moduleInitalized = YES;
|
|
77
|
+
|
|
78
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
79
|
+
selector:@selector(handleOpenURLNotification:)
|
|
80
|
+
name:RCTOpenURLNotification
|
|
81
|
+
object:nil];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
- (void)stopObserving
|
|
85
|
+
{
|
|
86
|
+
moduleInitalized = NO;
|
|
87
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#endif // macOS]
|
|
91
|
+
|
|
50
92
|
- (NSArray<NSString *> *)supportedEvents
|
|
51
93
|
{
|
|
52
94
|
return @[ @"url" ];
|
|
53
95
|
}
|
|
54
96
|
|
|
97
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
98
|
+
|
|
55
99
|
+ (BOOL)application:(UIApplication *)app
|
|
56
100
|
openURL:(NSURL *)URL
|
|
57
101
|
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
|
|
@@ -87,6 +131,43 @@ RCT_EXPORT_MODULE()
|
|
|
87
131
|
[self sendEventWithName:@"url" body:notification.userInfo];
|
|
88
132
|
}
|
|
89
133
|
|
|
134
|
+
#else // [macOS
|
|
135
|
+
|
|
136
|
+
+ (void)setAlwaysForegroundLastWindow:(BOOL)alwaysForeground
|
|
137
|
+
{
|
|
138
|
+
alwaysForegroundLastWindow = alwaysForeground;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
+ (void)getUrlEventHandler:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
|
|
142
|
+
{
|
|
143
|
+
// extract url value from the event
|
|
144
|
+
NSString *url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
|
|
145
|
+
|
|
146
|
+
// If the application was launched via URL, this handler will be called before
|
|
147
|
+
// the module is initialized by the bridge. Store the initial URL, because we are not listening to the notification yet.
|
|
148
|
+
if (!moduleInitalized && initialURL == nil) {
|
|
149
|
+
initialURL = url;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
postNotificationWithURL(url, self);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
- (void)handleOpenURLNotification:(NSNotification *)notification
|
|
156
|
+
{
|
|
157
|
+
// Activate app, because [NSApp mainWindow] returns nil when the app is hidden and another app is maximized
|
|
158
|
+
[NSApp activateIgnoringOtherApps:YES];
|
|
159
|
+
// foreground top level window
|
|
160
|
+
if (alwaysForegroundLastWindow) {
|
|
161
|
+
NSWindow *lastWindow = [[NSApp windows] lastObject];
|
|
162
|
+
[lastWindow makeKeyAndOrderFront:nil];
|
|
163
|
+
}
|
|
164
|
+
[self sendEventWithName:@"url" body:notification.userInfo];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
#endif // macOS]
|
|
168
|
+
|
|
169
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
170
|
+
|
|
90
171
|
RCT_EXPORT_METHOD(openURL
|
|
91
172
|
: (NSURL *)URL resolve
|
|
92
173
|
: (RCTPromiseResolveBlock)resolve reject
|
|
@@ -184,6 +265,44 @@ RCT_EXPORT_METHOD(openSettings : (RCTPromiseResolveBlock)resolve reject : (__unu
|
|
|
184
265
|
}];
|
|
185
266
|
}
|
|
186
267
|
|
|
268
|
+
#else // [macOS
|
|
269
|
+
|
|
270
|
+
RCT_EXPORT_METHOD(openURL:(NSURL *)URL
|
|
271
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
272
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
273
|
+
{
|
|
274
|
+
BOOL result = [[NSWorkspace sharedWorkspace] openURL:URL];
|
|
275
|
+
if (result) {
|
|
276
|
+
resolve(@YES);
|
|
277
|
+
} else {
|
|
278
|
+
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Unable to open URL: %@", URL], nil);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
RCT_EXPORT_METHOD(canOpenURL:(NSURL *)URL
|
|
283
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
284
|
+
reject:(__unused RCTPromiseRejectBlock)reject)
|
|
285
|
+
{
|
|
286
|
+
resolve(@YES);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
RCT_EXPORT_METHOD(getInitialURL:(RCTPromiseResolveBlock)resolve
|
|
290
|
+
reject:(__unused RCTPromiseRejectBlock)reject)
|
|
291
|
+
{
|
|
292
|
+
resolve(RCTNullIfNil(initialURL));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
RCT_EXPORT_METHOD(openSettings:(RCTPromiseResolveBlock)resolve
|
|
296
|
+
reject:(__unused RCTPromiseRejectBlock)reject)
|
|
297
|
+
{
|
|
298
|
+
// macOS doesn't have a direct equivalent of UIApplicationOpenSettingsURLString
|
|
299
|
+
// Open System Preferences instead
|
|
300
|
+
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"x-apple.systempreferences:"]];
|
|
301
|
+
resolve(nil);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
#endif // macOS]
|
|
305
|
+
|
|
187
306
|
RCT_EXPORT_METHOD(sendIntent
|
|
188
307
|
: (NSString *)action extras
|
|
189
308
|
: (NSArray *_Nullable)extras resolve
|
|
@@ -32,10 +32,6 @@ Pod::Spec.new do |s|
|
|
|
32
32
|
s.compiler_flags = '-Wno-nullability-completeness'
|
|
33
33
|
s.source = source
|
|
34
34
|
s.source_files = podspec_sources("*.{m,mm}", "")
|
|
35
|
-
# [macOS
|
|
36
|
-
s.osx.exclude_files = "RCTLinkingManager.mm"
|
|
37
|
-
s.osx.source_files = "macos/RCTLinkingManager.mm"
|
|
38
|
-
# macOS]
|
|
39
35
|
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
|
|
40
36
|
s.header_dir = "RCTLinking"
|
|
41
37
|
s.pod_target_xcconfig = {
|
|
@@ -277,7 +277,7 @@ NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttrib
|
|
|
277
277
|
|
|
278
278
|
- (RCTUIColor *)effectiveForegroundColor // [macOS]
|
|
279
279
|
{
|
|
280
|
-
RCTUIColor *effectiveForegroundColor = _foregroundColor ?: [
|
|
280
|
+
RCTUIColor *effectiveForegroundColor = _foregroundColor ?: [RCTTextAttributes defaultForegroundColor]; // [macOS]
|
|
281
281
|
|
|
282
282
|
if (!isnan(_opacity)) {
|
|
283
283
|
effectiveForegroundColor =
|
|
@@ -69,7 +69,7 @@ static RCTUIColor *defaultPlaceholderColor(void) // [macOS]
|
|
|
69
69
|
_textInputDelegateAdapter = [[RCTBackedTextViewDelegateAdapter alloc] initWithTextView:self];
|
|
70
70
|
|
|
71
71
|
self.backgroundColor = [RCTUIColor clearColor]; // [macOS]
|
|
72
|
-
self.textColor = [RCTUIColor
|
|
72
|
+
self.textColor = [RCTUIColor labelColor]; // [macOS]
|
|
73
73
|
// This line actually removes 5pt (default value) left and right padding in UITextView.
|
|
74
74
|
#if !TARGET_OS_OSX // [macOS]
|
|
75
75
|
self.textContainer.lineFragmentPadding = 0;
|
|
@@ -127,7 +127,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
127
127
|
|
|
128
128
|
NSDictionary<NSAttributedStringKey, id> *textAttributes = [[_textAttributes effectiveTextAttributes] mutableCopy];
|
|
129
129
|
if ([textAttributes valueForKey:NSForegroundColorAttributeName] == nil) {
|
|
130
|
-
[textAttributes setValue:[RCTUIColor
|
|
130
|
+
[textAttributes setValue:[RCTUIColor labelColor] forKey:NSForegroundColorAttributeName]; // [macOS]
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
backedTextInputView.defaultTextAttributes = textAttributes;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// [macOS]
|
|
12
|
+
// Legacy validKeysDown/validKeysUp/passthroughAllKeyEvents compat layer.
|
|
13
|
+
// When removing legacy support, delete this file and its call sites.
|
|
14
|
+
|
|
15
|
+
import type {HandledKeyEvent, KeyEvent} from '../Types/CoreEventTypes';
|
|
16
|
+
|
|
17
|
+
type LegacyHandledKeyEvent = string | HandledKeyEvent;
|
|
18
|
+
|
|
19
|
+
function expandKey(entry: LegacyHandledKeyEvent): Array<HandledKeyEvent> {
|
|
20
|
+
if (typeof entry !== 'string') {
|
|
21
|
+
return [entry];
|
|
22
|
+
}
|
|
23
|
+
const out: Array<HandledKeyEvent> = [];
|
|
24
|
+
const bools: Array<boolean> = [false, true];
|
|
25
|
+
for (const metaKey of bools) {
|
|
26
|
+
for (const ctrlKey of bools) {
|
|
27
|
+
for (const altKey of bools) {
|
|
28
|
+
for (const shiftKey of bools) {
|
|
29
|
+
out.push({altKey, ctrlKey, key: entry, metaKey, shiftKey});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function normalize(
|
|
38
|
+
legacy: ?$ReadOnlyArray<LegacyHandledKeyEvent>,
|
|
39
|
+
): void | Array<HandledKeyEvent> {
|
|
40
|
+
if (legacy == null) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const result: Array<HandledKeyEvent> = [];
|
|
44
|
+
for (const entry of legacy) {
|
|
45
|
+
result.push(...expandKey(entry));
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function matchesEvent(
|
|
51
|
+
events: $ReadOnlyArray<HandledKeyEvent>,
|
|
52
|
+
event: KeyEvent,
|
|
53
|
+
): boolean {
|
|
54
|
+
return events.some(
|
|
55
|
+
({key, metaKey, ctrlKey, altKey, shiftKey}: HandledKeyEvent) =>
|
|
56
|
+
event.nativeEvent.key === key &&
|
|
57
|
+
Boolean(metaKey) === event.nativeEvent.metaKey &&
|
|
58
|
+
Boolean(ctrlKey) === event.nativeEvent.ctrlKey &&
|
|
59
|
+
Boolean(altKey) === event.nativeEvent.altKey &&
|
|
60
|
+
Boolean(shiftKey) === event.nativeEvent.shiftKey,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type LegacyKeyResult = {
|
|
65
|
+
keyDownEvents: void | Array<HandledKeyEvent>,
|
|
66
|
+
keyUpEvents: void | Array<HandledKeyEvent>,
|
|
67
|
+
onKeyDown: void | ((event: KeyEvent) => void),
|
|
68
|
+
onKeyUp: void | ((event: KeyEvent) => void),
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Returns true if the props contain legacy key props that need processing.
|
|
73
|
+
*/
|
|
74
|
+
export function hasLegacyKeyProps(props: mixed): boolean {
|
|
75
|
+
// $FlowFixMe[unclear-type]
|
|
76
|
+
const p = (props: any);
|
|
77
|
+
return (
|
|
78
|
+
p.validKeysDown != null ||
|
|
79
|
+
p.validKeysUp != null ||
|
|
80
|
+
p.passthroughAllKeyEvents != null
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Strips legacy props from a props object (mutates).
|
|
86
|
+
*/
|
|
87
|
+
export function stripLegacyKeyProps(props: {+[string]: mixed}): void {
|
|
88
|
+
// $FlowFixMe[unclear-type]
|
|
89
|
+
const p = (props: any);
|
|
90
|
+
delete p.validKeysDown;
|
|
91
|
+
delete p.validKeysUp;
|
|
92
|
+
delete p.passthroughAllKeyEvents;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Processes legacy validKeysDown/validKeysUp/passthroughAllKeyEvents props
|
|
97
|
+
* and returns the equivalent modern keyDownEvents/keyUpEvents and wrapped
|
|
98
|
+
* onKeyDown/onKeyUp handlers.
|
|
99
|
+
*
|
|
100
|
+
* Usage in component:
|
|
101
|
+
* if (hasLegacyKeyProps(props)) {
|
|
102
|
+
* const legacy = processLegacyKeyProps(props);
|
|
103
|
+
* // use legacy.keyDownEvents, legacy.onKeyDown, etc.
|
|
104
|
+
* }
|
|
105
|
+
*/
|
|
106
|
+
export default function processLegacyKeyProps(
|
|
107
|
+
// $FlowFixMe[unclear-type]
|
|
108
|
+
props: any,
|
|
109
|
+
): LegacyKeyResult {
|
|
110
|
+
const validKeysDown: ?$ReadOnlyArray<LegacyHandledKeyEvent> =
|
|
111
|
+
props.validKeysDown;
|
|
112
|
+
const validKeysUp: ?$ReadOnlyArray<LegacyHandledKeyEvent> = props.validKeysUp;
|
|
113
|
+
const passthroughAllKeyEvents: ?boolean = props.passthroughAllKeyEvents;
|
|
114
|
+
|
|
115
|
+
const hasModernKeyDown = props.keyDownEvents != null;
|
|
116
|
+
const hasModernKeyUp = props.keyUpEvents != null;
|
|
117
|
+
const legacyPassthrough =
|
|
118
|
+
passthroughAllKeyEvents === true && !hasModernKeyDown;
|
|
119
|
+
|
|
120
|
+
const gateKeyDown =
|
|
121
|
+
!hasModernKeyDown && validKeysDown != null && !legacyPassthrough;
|
|
122
|
+
const gateKeyUp =
|
|
123
|
+
!hasModernKeyUp && validKeysUp != null && !legacyPassthrough;
|
|
124
|
+
|
|
125
|
+
const normalizedDown = props.keyDownEvents ?? normalize(validKeysDown);
|
|
126
|
+
const normalizedUp = props.keyUpEvents ?? normalize(validKeysUp);
|
|
127
|
+
|
|
128
|
+
const keyDownEvents = legacyPassthrough ? undefined : normalizedDown;
|
|
129
|
+
const keyUpEvents = legacyPassthrough ? undefined : normalizedUp;
|
|
130
|
+
|
|
131
|
+
const onKeyDown =
|
|
132
|
+
props.onKeyDown != null
|
|
133
|
+
? (event: KeyEvent) => {
|
|
134
|
+
let isHandled = false;
|
|
135
|
+
if (normalizedDown != null && !event.isPropagationStopped()) {
|
|
136
|
+
isHandled = matchesEvent(normalizedDown, event);
|
|
137
|
+
if (isHandled && hasModernKeyDown) {
|
|
138
|
+
event.stopPropagation();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (!gateKeyDown || isHandled) {
|
|
142
|
+
props.onKeyDown?.(event);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
: undefined;
|
|
146
|
+
|
|
147
|
+
const onKeyUp =
|
|
148
|
+
props.onKeyUp != null
|
|
149
|
+
? (event: KeyEvent) => {
|
|
150
|
+
let isHandled = false;
|
|
151
|
+
if (normalizedUp != null && !event.isPropagationStopped()) {
|
|
152
|
+
isHandled = matchesEvent(normalizedUp, event);
|
|
153
|
+
if (isHandled && hasModernKeyUp) {
|
|
154
|
+
event.stopPropagation();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!gateKeyUp || isHandled) {
|
|
158
|
+
props.onKeyUp?.(event);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
: undefined;
|
|
162
|
+
|
|
163
|
+
return {keyDownEvents, keyUpEvents, onKeyDown, onKeyUp};
|
|
164
|
+
}
|
package/React/Base/RCTRootView.m
CHANGED
|
@@ -206,6 +206,13 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
|
|
|
206
206
|
#endif // macOS]
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
#if TARGET_OS_OSX // [macOS
|
|
210
|
+
- (void)viewDidEndLiveResize {
|
|
211
|
+
[super viewDidEndLiveResize];
|
|
212
|
+
[self setNeedsLayout];
|
|
213
|
+
}
|
|
214
|
+
#endif // macOS]
|
|
215
|
+
|
|
209
216
|
- (void)setLoadingView:(RCTUIView *)loadingView // [macOS]
|
|
210
217
|
{
|
|
211
218
|
_loadingView = loadingView;
|