react-native-macos 0.81.3 → 0.81.5
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/Core/ReactNativeVersion.js +1 -1
- package/Libraries/LinkingIOS/RCTLinkingManager.mm +119 -0
- package/Libraries/LinkingIOS/React-RCTLinking.podspec +0 -4
- package/Libraries/StyleSheet/PlatformColorValueTypes.macos.js +2 -2
- package/React/Base/RCTBridge.mm +118 -69
- package/React/Base/RCTBridgeModule.h +17 -5
- package/React/Base/RCTDefines.h +11 -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 +69 -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/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h +10 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm +72 -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/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
|
@@ -29,8 +29,33 @@
|
|
|
29
29
|
#import "RCTConversions.h"
|
|
30
30
|
#import "RCTFabricComponentsPlugins.h"
|
|
31
31
|
|
|
32
|
+
#if TARGET_OS_OSX // [macOS
|
|
33
|
+
#import <React/RCTSurfaceTouchHandler.h>
|
|
34
|
+
#endif // macOS]
|
|
35
|
+
|
|
32
36
|
using namespace facebook::react;
|
|
33
37
|
|
|
38
|
+
#if TARGET_OS_OSX // [macOS
|
|
39
|
+
// Cancel React Native's touch handling by finding the RCTSurfaceTouchHandler
|
|
40
|
+
// gesture recognizer in the view hierarchy and toggling its enabled state.
|
|
41
|
+
// This matches what RCTSurfaceTouchHandler._cancelTouches does internally.
|
|
42
|
+
static void RCTCancelTouchesForView(RCTPlatformView *view)
|
|
43
|
+
{
|
|
44
|
+
while (view) {
|
|
45
|
+
for (id gestureHandler in view.gestureRecognizers) {
|
|
46
|
+
if ([gestureHandler isKindOfClass:[RCTSurfaceTouchHandler class]]) {
|
|
47
|
+
[gestureHandler setEnabled:NO];
|
|
48
|
+
[gestureHandler setEnabled:YES];
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
view = view.superview;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
#endif // macOS]
|
|
56
|
+
|
|
57
|
+
#pragma mark - RCTParagraphTextView (default, non-selectable) // [macOS]
|
|
58
|
+
|
|
34
59
|
// ParagraphTextView is an auxiliary view we set as contentView so the drawing
|
|
35
60
|
// can happen on top of the layers manipulated by RCTViewComponentView (the parent view)
|
|
36
61
|
@interface RCTParagraphTextView : RCTUIView // [macOS]
|
|
@@ -41,6 +66,22 @@ using namespace facebook::react;
|
|
|
41
66
|
|
|
42
67
|
@end
|
|
43
68
|
|
|
69
|
+
// [macOS Platform-native text view used when selectable={true}.
|
|
70
|
+
// Handles both text rendering and native text selection.
|
|
71
|
+
#if TARGET_OS_OSX // [macOS
|
|
72
|
+
@interface RCTParagraphSelectableTextView : NSTextView
|
|
73
|
+
|
|
74
|
+
- (void)setNeedsDisplay;
|
|
75
|
+
|
|
76
|
+
#else
|
|
77
|
+
@interface RCTParagraphSelectableTextView : UITextView
|
|
78
|
+
#endif
|
|
79
|
+
|
|
80
|
+
@end
|
|
81
|
+
// macOS]
|
|
82
|
+
|
|
83
|
+
#pragma mark - RCTParagraphComponentView // [macOS]
|
|
84
|
+
|
|
44
85
|
#if !TARGET_OS_OSX // [macOS]
|
|
45
86
|
@interface RCTParagraphComponentView () <UIEditMenuInteractionDelegate>
|
|
46
87
|
|
|
@@ -48,9 +89,9 @@ using namespace facebook::react;
|
|
|
48
89
|
|
|
49
90
|
@end
|
|
50
91
|
#else // [macOS
|
|
51
|
-
@interface RCTParagraphComponentView ()
|
|
92
|
+
@interface RCTParagraphComponentView () <NSTextViewDelegate>
|
|
52
93
|
@end
|
|
53
|
-
#endif //
|
|
94
|
+
#endif // macOS]
|
|
54
95
|
|
|
55
96
|
@implementation RCTParagraphComponentView {
|
|
56
97
|
ParagraphAttributes _paragraphAttributes;
|
|
@@ -59,6 +100,7 @@ using namespace facebook::react;
|
|
|
59
100
|
UILongPressGestureRecognizer *_longPressGestureRecognizer;
|
|
60
101
|
#endif // [macOS]
|
|
61
102
|
RCTParagraphTextView *_textView;
|
|
103
|
+
RCTParagraphSelectableTextView *_selectableTextView; // [macOS]
|
|
62
104
|
}
|
|
63
105
|
|
|
64
106
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
@@ -121,13 +163,14 @@ using namespace facebook::react;
|
|
|
121
163
|
_textView.paragraphAttributes = _paragraphAttributes;
|
|
122
164
|
|
|
123
165
|
if (newParagraphProps.isSelectable != oldParagraphProps.isSelectable) {
|
|
124
|
-
|
|
166
|
+
// [macOS Replaced enableContextMenu/disableContextMenu with _enableSelection/_disableSelection
|
|
167
|
+
// to swap in a native text view that supports text selection.
|
|
125
168
|
if (newParagraphProps.isSelectable) {
|
|
126
|
-
[self
|
|
169
|
+
[self _enableSelection];
|
|
127
170
|
} else {
|
|
128
|
-
[self
|
|
171
|
+
[self _disableSelection];
|
|
129
172
|
}
|
|
130
|
-
|
|
173
|
+
// macOS]
|
|
131
174
|
}
|
|
132
175
|
|
|
133
176
|
[super updateProps:props oldProps:oldProps];
|
|
@@ -138,6 +181,10 @@ using namespace facebook::react;
|
|
|
138
181
|
_textView.state = std::static_pointer_cast<const ParagraphShadowNode::ConcreteState>(state);
|
|
139
182
|
[_textView setNeedsDisplay];
|
|
140
183
|
[self setNeedsLayout];
|
|
184
|
+
|
|
185
|
+
if (_selectableTextView) {
|
|
186
|
+
[self updateSelectableTextStorage];
|
|
187
|
+
}
|
|
141
188
|
}
|
|
142
189
|
|
|
143
190
|
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
|
|
@@ -149,11 +196,18 @@ using namespace facebook::react;
|
|
|
149
196
|
_textView.layoutMetrics = _layoutMetrics;
|
|
150
197
|
[_textView setNeedsDisplay];
|
|
151
198
|
[self setNeedsLayout];
|
|
199
|
+
|
|
200
|
+
if (_selectableTextView) {
|
|
201
|
+
[self updateSelectableTextStorage];
|
|
202
|
+
}
|
|
152
203
|
}
|
|
153
204
|
|
|
154
205
|
- (void)prepareForRecycle
|
|
155
206
|
{
|
|
156
207
|
[super prepareForRecycle];
|
|
208
|
+
if (_selectableTextView) {
|
|
209
|
+
[self _disableSelection];
|
|
210
|
+
}
|
|
157
211
|
_textView.state = nullptr;
|
|
158
212
|
_accessibilityProvider = nil;
|
|
159
213
|
}
|
|
@@ -162,7 +216,114 @@ using namespace facebook::react;
|
|
|
162
216
|
{
|
|
163
217
|
[super layoutSubviews];
|
|
164
218
|
|
|
219
|
+
if (_selectableTextView) {
|
|
220
|
+
_selectableTextView.frame = self.bounds;
|
|
221
|
+
} else {
|
|
222
|
+
_textView.frame = self.bounds;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
#pragma mark - Selection Management
|
|
227
|
+
|
|
228
|
+
- (void)_enableSelection
|
|
229
|
+
{
|
|
230
|
+
if (_selectableTextView) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
_selectableTextView = [[RCTParagraphSelectableTextView alloc] initWithFrame:self.bounds];
|
|
235
|
+
|
|
236
|
+
#if TARGET_OS_OSX // [macOS
|
|
237
|
+
_selectableTextView.delegate = self;
|
|
238
|
+
_selectableTextView.usesFontPanel = NO;
|
|
239
|
+
_selectableTextView.drawsBackground = NO;
|
|
240
|
+
_selectableTextView.linkTextAttributes = @{};
|
|
241
|
+
_selectableTextView.editable = NO;
|
|
242
|
+
_selectableTextView.selectable = YES;
|
|
243
|
+
_selectableTextView.verticallyResizable = NO;
|
|
244
|
+
_selectableTextView.layoutManager.usesFontLeading = NO;
|
|
245
|
+
#else // macOS]
|
|
246
|
+
_selectableTextView.editable = NO;
|
|
247
|
+
_selectableTextView.selectable = YES;
|
|
248
|
+
_selectableTextView.scrollEnabled = NO;
|
|
249
|
+
_selectableTextView.textContainerInset = UIEdgeInsetsZero;
|
|
250
|
+
_selectableTextView.textContainer.lineFragmentPadding = 0;
|
|
251
|
+
_selectableTextView.backgroundColor = [UIColor clearColor];
|
|
252
|
+
#endif // macOS]
|
|
253
|
+
|
|
254
|
+
// Sync text content into the native text view.
|
|
255
|
+
[self updateSelectableTextStorage];
|
|
256
|
+
|
|
257
|
+
// Swap: remove the default text view, install the selectable one.
|
|
258
|
+
[_textView removeFromSuperview];
|
|
259
|
+
self.contentView = _selectableTextView;
|
|
260
|
+
|
|
261
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
262
|
+
// On iOS, also enable the context menu (long press to copy).
|
|
263
|
+
[self enableContextMenu];
|
|
264
|
+
#endif // [macOS]
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
- (void)_disableSelection
|
|
268
|
+
{
|
|
269
|
+
if (!_selectableTextView) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
274
|
+
[self disableContextMenu];
|
|
275
|
+
#endif // [macOS]
|
|
276
|
+
|
|
277
|
+
// Swap back: remove the selectable text view, restore the default one.
|
|
278
|
+
[_selectableTextView removeFromSuperview];
|
|
279
|
+
_selectableTextView = nil;
|
|
280
|
+
|
|
281
|
+
self.contentView = _textView;
|
|
165
282
|
_textView.frame = self.bounds;
|
|
283
|
+
[_textView setNeedsDisplay];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
- (void)updateSelectableTextStorage
|
|
287
|
+
{
|
|
288
|
+
if (!_selectableTextView || !_textView.state) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const auto &stateData = _textView.state->getData();
|
|
293
|
+
auto textLayoutManager = stateData.layoutManager.lock();
|
|
294
|
+
if (!textLayoutManager) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
RCTTextLayoutManager *nativeTextLayoutManager =
|
|
299
|
+
(RCTTextLayoutManager *)unwrapManagedObject(textLayoutManager->getNativeTextLayoutManager());
|
|
300
|
+
CGRect frame = RCTCGRectFromRect(_layoutMetrics.getContentFrame());
|
|
301
|
+
|
|
302
|
+
NSTextStorage *textStorage = [nativeTextLayoutManager getTextStorageForAttributedString:stateData.attributedString
|
|
303
|
+
paragraphAttributes:_paragraphAttributes
|
|
304
|
+
size:frame.size];
|
|
305
|
+
|
|
306
|
+
#if TARGET_OS_OSX // [macOS
|
|
307
|
+
// Sync the layout infrastructure into the NSTextView.
|
|
308
|
+
NSLayoutManager *layoutManager = textStorage.layoutManagers.firstObject;
|
|
309
|
+
NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
|
|
310
|
+
[_selectableTextView replaceTextContainer:textContainer];
|
|
311
|
+
|
|
312
|
+
// Detach layout managers from the source text storage before syncing content.
|
|
313
|
+
NSArray<NSLayoutManager *> *managers = [[textStorage layoutManagers] copy];
|
|
314
|
+
for (NSLayoutManager *manager in managers) {
|
|
315
|
+
[textStorage removeLayoutManager:manager];
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
_selectableTextView.minSize = frame.size;
|
|
319
|
+
_selectableTextView.maxSize = frame.size;
|
|
320
|
+
_selectableTextView.frame = frame;
|
|
321
|
+
[[_selectableTextView textStorage] setAttributedString:textStorage];
|
|
322
|
+
#else // macOS]
|
|
323
|
+
// On iOS, set the attributed text directly. UITextView manages its own layout.
|
|
324
|
+
_selectableTextView.attributedText = textStorage;
|
|
325
|
+
_selectableTextView.frame = frame;
|
|
326
|
+
#endif // macOS]
|
|
166
327
|
}
|
|
167
328
|
|
|
168
329
|
#pragma mark - Accessibility
|
|
@@ -189,7 +350,7 @@ using namespace facebook::react;
|
|
|
189
350
|
return NO;
|
|
190
351
|
}
|
|
191
352
|
|
|
192
|
-
#if !TARGET_OS_OSX // [macOS
|
|
353
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
193
354
|
- (NSArray *)accessibilityElements
|
|
194
355
|
{
|
|
195
356
|
const auto ¶graphProps = static_cast<const ParagraphProps &>(*_props);
|
|
@@ -352,6 +513,89 @@ using namespace facebook::react;
|
|
|
352
513
|
}
|
|
353
514
|
#endif // [macOS]
|
|
354
515
|
|
|
516
|
+
#pragma mark - macOS Mouse Event Handling
|
|
517
|
+
|
|
518
|
+
#if TARGET_OS_OSX // [macOS
|
|
519
|
+
|
|
520
|
+
- (NSView *)hitTest:(NSPoint)point
|
|
521
|
+
{
|
|
522
|
+
NSView *hitView = [super hitTest:point];
|
|
523
|
+
|
|
524
|
+
if (!_selectableTextView) {
|
|
525
|
+
return hitView;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// Intercept clicks on the selectable text view so we can manage selection ourselves,
|
|
529
|
+
// preventing it from swallowing events that may be handled in JS (e.g. onPress).
|
|
530
|
+
NSEventType eventType = NSApp.currentEvent.type;
|
|
531
|
+
BOOL isMouseClickEvent = NSEvent.pressedMouseButtons > 0;
|
|
532
|
+
BOOL isMouseMoveEventType = eventType == NSEventTypeMouseMoved ||
|
|
533
|
+
eventType == NSEventTypeMouseEntered ||
|
|
534
|
+
eventType == NSEventTypeMouseExited ||
|
|
535
|
+
eventType == NSEventTypeCursorUpdate;
|
|
536
|
+
BOOL isMouseMoveEvent = !isMouseClickEvent && isMouseMoveEventType;
|
|
537
|
+
BOOL isTextViewClick = (hitView && hitView == _selectableTextView) && !isMouseMoveEvent;
|
|
538
|
+
|
|
539
|
+
return isTextViewClick ? self : hitView;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
- (void)rightMouseDown:(NSEvent *)event
|
|
543
|
+
{
|
|
544
|
+
if (!_selectableTextView) {
|
|
545
|
+
[super rightMouseDown:event];
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
RCTCancelTouchesForView(self);
|
|
550
|
+
[_selectableTextView rightMouseDown:event];
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
- (void)mouseDown:(NSEvent *)event
|
|
554
|
+
{
|
|
555
|
+
if (!_selectableTextView) {
|
|
556
|
+
[super mouseDown:event];
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// Double/triple-clicks should be forwarded to the NSTextView for word/line selection.
|
|
561
|
+
BOOL shouldForward = event.clickCount > 1;
|
|
562
|
+
|
|
563
|
+
if (!shouldForward) {
|
|
564
|
+
// Peek at next event to know if a drag (selection) is beginning.
|
|
565
|
+
NSEvent *nextEvent = [self.window nextEventMatchingMask:NSEventMaskLeftMouseUp | NSEventMaskLeftMouseDragged
|
|
566
|
+
untilDate:[NSDate distantFuture]
|
|
567
|
+
inMode:NSEventTrackingRunLoopMode
|
|
568
|
+
dequeue:NO];
|
|
569
|
+
shouldForward = nextEvent.type == NSEventTypeLeftMouseDragged;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
if (shouldForward) {
|
|
573
|
+
NSView *contentView = self.window.contentView;
|
|
574
|
+
// -[NSView hitTest:] takes coordinates in a view's superview coordinate system.
|
|
575
|
+
NSPoint point = [contentView.superview convertPoint:event.locationInWindow fromView:nil];
|
|
576
|
+
|
|
577
|
+
if ([contentView hitTest:point] == self) {
|
|
578
|
+
RCTCancelTouchesForView(self);
|
|
579
|
+
[self.window makeFirstResponder:_selectableTextView];
|
|
580
|
+
[_selectableTextView mouseDown:event];
|
|
581
|
+
}
|
|
582
|
+
} else {
|
|
583
|
+
// Clear selection for single clicks.
|
|
584
|
+
_selectableTextView.selectedRange = NSMakeRange(NSNotFound, 0);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
#pragma mark - NSTextViewDelegate
|
|
589
|
+
|
|
590
|
+
- (void)textDidEndEditing:(NSNotification *)notification
|
|
591
|
+
{
|
|
592
|
+
_selectableTextView.selectedRange = NSMakeRange(NSNotFound, 0);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
#endif // macOS]
|
|
596
|
+
|
|
597
|
+
#pragma mark - Responder Chain
|
|
598
|
+
|
|
355
599
|
- (BOOL)canBecomeFirstResponder
|
|
356
600
|
{
|
|
357
601
|
const auto ¶graphProps = static_cast<const ParagraphProps &>(*_props);
|
|
@@ -369,7 +613,19 @@ using namespace facebook::react;
|
|
|
369
613
|
|
|
370
614
|
return [self.nextResponder canPerformAction:action withSender:sender];
|
|
371
615
|
}
|
|
372
|
-
#
|
|
616
|
+
#else // [macOS
|
|
617
|
+
|
|
618
|
+
- (BOOL)resignFirstResponder
|
|
619
|
+
{
|
|
620
|
+
// Don't relinquish first responder while selecting text.
|
|
621
|
+
if (_selectableTextView && NSRunLoop.currentRunLoop.currentMode == NSEventTrackingRunLoopMode) {
|
|
622
|
+
return NO;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
return [super resignFirstResponder];
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
#endif // macOS]
|
|
373
629
|
|
|
374
630
|
- (void)copy:(id)sender
|
|
375
631
|
{
|
|
@@ -404,6 +660,8 @@ Class<RCTComponentViewProtocol> RCTParagraphCls(void)
|
|
|
404
660
|
return RCTParagraphComponentView.class;
|
|
405
661
|
}
|
|
406
662
|
|
|
663
|
+
#pragma mark - RCTParagraphTextView Implementation
|
|
664
|
+
|
|
407
665
|
@implementation RCTParagraphTextView {
|
|
408
666
|
CAShapeLayer *_highlightLayer;
|
|
409
667
|
}
|
|
@@ -450,3 +708,43 @@ Class<RCTComponentViewProtocol> RCTParagraphCls(void)
|
|
|
450
708
|
}
|
|
451
709
|
|
|
452
710
|
@end
|
|
711
|
+
|
|
712
|
+
// [macOS
|
|
713
|
+
#pragma mark - RCTParagraphSelectableTextView Implementation
|
|
714
|
+
|
|
715
|
+
@implementation RCTParagraphSelectableTextView
|
|
716
|
+
|
|
717
|
+
#if TARGET_OS_OSX
|
|
718
|
+
|
|
719
|
+
- (void)setNeedsDisplay
|
|
720
|
+
{
|
|
721
|
+
[self setNeedsDisplay:YES];
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
- (BOOL)canBecomeKeyView
|
|
725
|
+
{
|
|
726
|
+
// Prevent this NSTextView from participating in the key view loop directly.
|
|
727
|
+
// The parent RCTParagraphComponentView manages focus instead.
|
|
728
|
+
return NO;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
- (BOOL)resignFirstResponder
|
|
732
|
+
{
|
|
733
|
+
// Don't relinquish first responder while the user is actively selecting text.
|
|
734
|
+
if (self.selectable && NSRunLoop.currentRunLoop.currentMode == NSEventTrackingRunLoopMode) {
|
|
735
|
+
return NO;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
return [super resignFirstResponder];
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
#else
|
|
742
|
+
|
|
743
|
+
// On iOS, let UITextView handle touches natively for selection support.
|
|
744
|
+
// No hitTest override needed — UITextView's built-in gesture recognizers
|
|
745
|
+
// handle long-press-to-select and other selection interactions.
|
|
746
|
+
|
|
747
|
+
#endif
|
|
748
|
+
|
|
749
|
+
@end
|
|
750
|
+
// macOS]
|
|
@@ -411,6 +411,12 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
411
411
|
NSArray<NSPasteboardType> *types = RCTPasteboardTypeArrayFromProps(newTextInputProps.traits.pastedTypes);
|
|
412
412
|
[_backedTextInputView setReadablePasteBoardTypes:types];
|
|
413
413
|
}
|
|
414
|
+
|
|
415
|
+
if (newTextInputProps.enableFocusRing != oldTextInputProps.enableFocusRing) {
|
|
416
|
+
if ([_backedTextInputView respondsToSelector:@selector(setEnableFocusRing:)]) {
|
|
417
|
+
[_backedTextInputView setEnableFocusRing:newTextInputProps.enableFocusRing];
|
|
418
|
+
}
|
|
419
|
+
}
|
|
414
420
|
#endif // macOS]
|
|
415
421
|
|
|
416
422
|
[super updateProps:props oldProps:oldProps];
|
|
@@ -167,7 +167,7 @@ const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
|
|
|
167
167
|
[self invalidateLayer];
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
#else // [macOS
|
|
170
|
+
#else // [macOS
|
|
171
171
|
- (void)viewDidChangeEffectiveAppearance
|
|
172
172
|
{
|
|
173
173
|
[super viewDidChangeEffectiveAppearance];
|
|
@@ -341,11 +341,6 @@ const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
|
|
|
341
341
|
needsInvalidateLayer = YES;
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
// `cursor`
|
|
345
|
-
if (oldViewProps.cursor != newViewProps.cursor) {
|
|
346
|
-
needsInvalidateLayer = YES;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
344
|
// `shouldRasterize`
|
|
350
345
|
if (oldViewProps.shouldRasterize != newViewProps.shouldRasterize) {
|
|
351
346
|
self.layer.shouldRasterize = newViewProps.shouldRasterize;
|
|
@@ -367,17 +362,12 @@ const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
|
|
|
367
362
|
![_propKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN containsObject:@"transform"]) {
|
|
368
363
|
auto newTransform = newViewProps.resolveTransform(_layoutMetrics);
|
|
369
364
|
CATransform3D caTransform = RCTCATransform3DFromTransformMatrix(newTransform);
|
|
370
|
-
#if TARGET_OS_OSX // [macOS
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
// This compensates for the fact that layer.anchorPoint is {0, 0} instead of {0.5, 0.5} on macOS for some reason.
|
|
375
|
-
CATransform3D originAdjust = CATransform3DTranslate(CATransform3DIdentity, self.frame.size.width / 2, self.frame.size.height / 2, 0);
|
|
376
|
-
caTransform = CATransform3DConcat(CATransform3DConcat(CATransform3DInvert(originAdjust), caTransform), originAdjust);
|
|
377
|
-
}
|
|
365
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
366
|
+
self.layer.transform = caTransform;
|
|
367
|
+
#else // [macOS
|
|
368
|
+
self.transform3D = caTransform;
|
|
378
369
|
#endif // macOS]
|
|
379
370
|
|
|
380
|
-
self.layer.transform = caTransform;
|
|
381
371
|
// Enable edge antialiasing in rotation, skew, or perspective transforms
|
|
382
372
|
self.layer.allowsEdgeAntialiasing = caTransform.m12 != 0.0f || caTransform.m21 != 0.0f || caTransform.m34 != 0.0f;
|
|
383
373
|
}
|
|
@@ -718,7 +708,11 @@ const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
|
|
|
718
708
|
if ((_props->transformOrigin.isSet() || _props->transform.operations.size() > 0) &&
|
|
719
709
|
layoutMetrics.frame.size != oldLayoutMetrics.frame.size) {
|
|
720
710
|
auto newTransform = _props->resolveTransform(layoutMetrics);
|
|
711
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
721
712
|
self.layer.transform = RCTCATransform3DFromTransformMatrix(newTransform);
|
|
713
|
+
#else // [macOS
|
|
714
|
+
self.transform3D = RCTCATransform3DFromTransformMatrix(newTransform);
|
|
715
|
+
#endif // macOS]
|
|
722
716
|
}
|
|
723
717
|
}
|
|
724
718
|
|
|
@@ -812,7 +806,7 @@ const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
|
|
|
812
806
|
}
|
|
813
807
|
|
|
814
808
|
for (RCTPlatformView *subview in [self.subviews reverseObjectEnumerator]) { // [macOS]
|
|
815
|
-
RCTPlatformView *hitView = RCTUIViewHitTestWithEvent(subview,
|
|
809
|
+
RCTPlatformView *hitView = RCTUIViewHitTestWithEvent(subview, point, self, event); // [macOS]
|
|
816
810
|
if (hitView) {
|
|
817
811
|
return hitView;
|
|
818
812
|
}
|
|
@@ -1177,7 +1171,7 @@ static RCTBorderStyle RCTBorderStyleFromOutlineStyle(OutlineStyle outlineStyle)
|
|
|
1177
1171
|
#if !TARGET_OS_OSX // [macOS]
|
|
1178
1172
|
RCTUIColor *backgroundColor = [_backgroundColor resolvedColorWithTraitCollection:self.traitCollection];
|
|
1179
1173
|
#else // [macOS
|
|
1180
|
-
RCTUIColor *backgroundColor = _backgroundColor;
|
|
1174
|
+
RCTUIColor *backgroundColor = [_backgroundColor resolvedColorWithAppearance:self.effectiveAppearance];
|
|
1181
1175
|
#endif // macOS]
|
|
1182
1176
|
// The reason we sometimes do not set self.layer's backgroundColor is because
|
|
1183
1177
|
// we want to support non-uniform border radii, which apple does not natively
|
|
@@ -1208,6 +1202,9 @@ static RCTBorderStyle RCTBorderStyleFromOutlineStyle(OutlineStyle outlineStyle)
|
|
|
1208
1202
|
|
|
1209
1203
|
layer.borderWidth = (CGFloat)borderMetrics.borderWidths.left;
|
|
1210
1204
|
RCTUIColor *borderColor = RCTUIColorFromSharedColor(borderMetrics.borderColors.left); // [macOS]
|
|
1205
|
+
#if TARGET_OS_OSX // [macOS
|
|
1206
|
+
borderColor = [borderColor resolvedColorWithAppearance:self.effectiveAppearance];
|
|
1207
|
+
#endif // macOS]
|
|
1211
1208
|
layer.borderColor = borderColor.CGColor;
|
|
1212
1209
|
layer.cornerRadius = (CGFloat)borderMetrics.borderRadii.topLeft.horizontal;
|
|
1213
1210
|
|
|
@@ -1229,6 +1226,12 @@ static RCTBorderStyle RCTBorderStyleFromOutlineStyle(OutlineStyle outlineStyle)
|
|
|
1229
1226
|
layer.cornerRadius = 0;
|
|
1230
1227
|
|
|
1231
1228
|
RCTBorderColors borderColors = RCTCreateRCTBorderColorsFromBorderColors(borderMetrics.borderColors);
|
|
1229
|
+
#if TARGET_OS_OSX // [macOS
|
|
1230
|
+
borderColors.top = [borderColors.top resolvedColorWithAppearance:self.effectiveAppearance];
|
|
1231
|
+
borderColors.left = [borderColors.left resolvedColorWithAppearance:self.effectiveAppearance];
|
|
1232
|
+
borderColors.bottom = [borderColors.bottom resolvedColorWithAppearance:self.effectiveAppearance];
|
|
1233
|
+
borderColors.right = [borderColors.right resolvedColorWithAppearance:self.effectiveAppearance];
|
|
1234
|
+
#endif // macOS]
|
|
1232
1235
|
|
|
1233
1236
|
RCTAddContourEffectToLayer(
|
|
1234
1237
|
_borderLayer,
|
|
@@ -1255,10 +1258,16 @@ static RCTBorderStyle RCTBorderStyleFromOutlineStyle(OutlineStyle outlineStyle)
|
|
|
1255
1258
|
|
|
1256
1259
|
if (borderMetrics.borderRadii.isUniform() && borderMetrics.borderRadii.topLeft.horizontal == 0) {
|
|
1257
1260
|
RCTUIColor *outlineColor = RCTUIColorFromSharedColor(_props->outlineColor); // [macOS]
|
|
1261
|
+
#if TARGET_OS_OSX // [macOS
|
|
1262
|
+
outlineColor = [outlineColor resolvedColorWithAppearance:self.effectiveAppearance];
|
|
1263
|
+
#endif // macOS]
|
|
1258
1264
|
_outlineLayer.borderWidth = _props->outlineWidth;
|
|
1259
1265
|
_outlineLayer.borderColor = outlineColor.CGColor;
|
|
1260
1266
|
} else {
|
|
1261
1267
|
RCTUIColor *outlineColor = RCTUIColorFromSharedColor(_props->outlineColor); // [macOS]
|
|
1268
|
+
#if TARGET_OS_OSX // [macOS
|
|
1269
|
+
outlineColor = [outlineColor resolvedColorWithAppearance:self.effectiveAppearance];
|
|
1270
|
+
#endif // macOS]
|
|
1262
1271
|
|
|
1263
1272
|
RCTAddContourEffectToLayer(
|
|
1264
1273
|
_outlineLayer,
|
|
@@ -1707,7 +1716,6 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // [macOS]
|
|
|
1707
1716
|
}
|
|
1708
1717
|
|
|
1709
1718
|
#if TARGET_OS_OSX // [macOS
|
|
1710
|
-
|
|
1711
1719
|
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
1712
1720
|
{
|
|
1713
1721
|
if ([commandName isEqualToString:@"focus"]) {
|
|
@@ -1186,7 +1186,7 @@ RCT_EXPORT_METHOD(findSubviewIn
|
|
|
1186
1186
|
{
|
|
1187
1187
|
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTPlatformView *> *viewRegistry) { // [macOS]
|
|
1188
1188
|
RCTPlatformView *view = viewRegistry[reactTag]; // [macOS]
|
|
1189
|
-
RCTPlatformView *target = RCTUIViewHitTestWithEvent(view, point, nil); // [macOS]
|
|
1189
|
+
RCTPlatformView *target = RCTUIViewHitTestWithEvent(view, point, view, nil); // [macOS]
|
|
1190
1190
|
CGRect frame = [target convertRect:target.bounds toView:view];
|
|
1191
1191
|
|
|
1192
1192
|
while (target.reactTag == nil && target.superview != nil) {
|
package/React/Views/RCTCursor.m
CHANGED
package/React/Views/RCTView.m
CHANGED
|
@@ -257,8 +257,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused)
|
|
|
257
257
|
// of the hit view will return YES from -pointInside:withEvent:). See:
|
|
258
258
|
// - https://developer.apple.com/library/ios/qa/qa2013/qa1812.html
|
|
259
259
|
for (RCTUIView *subview in [sortedSubviews reverseObjectEnumerator]) { // [macOS]
|
|
260
|
-
|
|
261
|
-
hitSubview = RCTUIViewHitTestWithEvent(subview, pointForHitTest, event); // macOS]
|
|
260
|
+
hitSubview = RCTUIViewHitTestWithEvent(subview, point, self, event); // [macOS]
|
|
262
261
|
if (hitSubview != nil) {
|
|
263
262
|
break;
|
|
264
263
|
}
|
|
@@ -328,6 +328,7 @@
|
|
|
328
328
|
BOOL _allowNextScrollNoMatterWhat;
|
|
329
329
|
#if TARGET_OS_OSX // [macOS
|
|
330
330
|
BOOL _notifyDidScroll;
|
|
331
|
+
BOOL _disableScrollEvents;
|
|
331
332
|
NSPoint _lastScrollPosition;
|
|
332
333
|
#endif // macOS]
|
|
333
334
|
CGRect _lastClippedToRect;
|
|
@@ -570,8 +571,28 @@ static inline void RCTApplyTransformationAccordingLayoutDirection(
|
|
|
570
571
|
|
|
571
572
|
- (void)setFrame:(CGRect)frame
|
|
572
573
|
{
|
|
574
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
575
|
+
[super setFrame:frame];
|
|
576
|
+
#else // [macOS
|
|
577
|
+
/**
|
|
578
|
+
* Setting the frame on the scroll view will randomly generate between 0 and 4 scroll events. These events happen
|
|
579
|
+
* during the layout phase of the view which generates layout notifications that are sent through the bridge.
|
|
580
|
+
* Because the bridge is heavily used, the scroll events are throttled and reach the JS thread with a random delay.
|
|
581
|
+
* Because the scroll event stores the clip and content view size, delayed scroll events will submit stale layout
|
|
582
|
+
* information that can break virtual list implemenations.
|
|
583
|
+
* By disabling scroll events during the execution of the setFrame method and scheduling one notification on
|
|
584
|
+
* the next run loop, we can mitigate the delayed scroll event by sending it at a time where the bridge is not busy.
|
|
585
|
+
*/
|
|
586
|
+
_disableScrollEvents = YES;
|
|
573
587
|
[super setFrame:frame];
|
|
588
|
+
_disableScrollEvents = NO;
|
|
589
|
+
|
|
590
|
+
if (self.window != nil && !self.window.inLiveResize) {
|
|
591
|
+
[self performSelector:@selector(scrollViewDocumentViewBoundsDidChange:) withObject:nil afterDelay:0];
|
|
592
|
+
}
|
|
593
|
+
#endif // macOS]
|
|
574
594
|
[self centerContentIfNeeded];
|
|
595
|
+
|
|
575
596
|
}
|
|
576
597
|
|
|
577
598
|
- (void)insertReactSubview:(RCTPlatformView *)view atIndex:(NSInteger)atIndex // [macOS]
|
|
@@ -867,6 +888,10 @@ static inline void RCTApplyTransformationAccordingLayoutDirection(
|
|
|
867
888
|
#if TARGET_OS_OSX // [macOS
|
|
868
889
|
- (void)scrollViewDocumentViewBoundsDidChange:(__unused NSNotification *)notification
|
|
869
890
|
{
|
|
891
|
+
if (_disableScrollEvents) {
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
|
|
870
895
|
if (_scrollView.centerContent) {
|
|
871
896
|
// contentOffset setter dynamically centers content when _centerContent == YES
|
|
872
897
|
[_scrollView setContentOffset:_scrollView.contentOffset];
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
|
|
69
69
|
- (NSNumber *)reactTagAtPoint:(CGPoint)point
|
|
70
70
|
{
|
|
71
|
-
RCTPlatformView *view = RCTUIViewHitTestWithEvent(self, point, nil); // [macOS]
|
|
71
|
+
RCTPlatformView *view = RCTUIViewHitTestWithEvent(self, point, self, nil); // [macOS]
|
|
72
72
|
while (view && !view.reactTag) {
|
|
73
73
|
view = view.superview;
|
|
74
74
|
}
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
|
|
15
15
|
#define REACT_NATIVE_VERSION_MAJOR 0
|
|
16
16
|
#define REACT_NATIVE_VERSION_MINOR 81
|
|
17
|
-
#define REACT_NATIVE_VERSION_PATCH
|
|
17
|
+
#define REACT_NATIVE_VERSION_PATCH 5
|
|
18
18
|
|
|
19
19
|
namespace facebook::react {
|
|
20
20
|
|
|
21
21
|
constexpr struct {
|
|
22
22
|
int32_t Major = 0;
|
|
23
23
|
int32_t Minor = 81;
|
|
24
|
-
int32_t Patch =
|
|
24
|
+
int32_t Patch = 5;
|
|
25
25
|
std::string_view Prerelease = "";
|
|
26
26
|
} ReactNativeVersion;
|
|
27
27
|
|
package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h
CHANGED
|
@@ -20,9 +20,19 @@ struct DynamicColor {
|
|
|
20
20
|
int32_t highContrastDarkColor = 0;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
#if TARGET_OS_OSX // [macOS
|
|
24
|
+
struct ColorWithSystemEffect {
|
|
25
|
+
int32_t color = 0;
|
|
26
|
+
std::string effect;
|
|
27
|
+
};
|
|
28
|
+
#endif // macOS]
|
|
29
|
+
|
|
23
30
|
struct Color {
|
|
24
31
|
Color(int32_t color);
|
|
25
32
|
Color(const DynamicColor& dynamicColor);
|
|
33
|
+
#if TARGET_OS_OSX // [macOS
|
|
34
|
+
Color(const ColorWithSystemEffect& colorWithSystemEffect);
|
|
35
|
+
#endif // macOS]
|
|
26
36
|
Color(const ColorComponents& components);
|
|
27
37
|
Color() : uiColor_(nullptr){};
|
|
28
38
|
int32_t getColor() const;
|