react-native-macos 0.0.0-3ebfa694f → 0.0.0-415f763fc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/Components/ScrollView/ScrollView.js +11 -45
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
- package/Libraries/Components/TextInput/TextInput.js +118 -1
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +1 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
- package/Libraries/Components/View/ReactNativeViewViewConfig.js +1 -0
- package/Libraries/Components/View/ReactNativeViewViewConfigMacOS.js +3 -3
- package/Libraries/Components/View/ViewPropTypes.js +10 -6
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Image/RCTImageView.mm +14 -10
- package/Libraries/LinkingIOS/RCTLinkingManager.h +1 -0
- package/Libraries/LinkingIOS/macos/RCTLinkingManager.mm +12 -5
- package/Libraries/Lists/FlatList.js +25 -1
- package/Libraries/Lists/VirtualizedList.js +118 -113
- package/Libraries/Lists/VirtualizedSectionList.js +9 -5
- package/Libraries/StyleSheet/StyleSheetTypes.js +25 -0
- package/Libraries/Text/BaseText/RCTBaseTextViewManager.m +1 -0
- package/Libraries/Text/RCTTextAttributes.h +2 -0
- package/Libraries/Text/RCTTextAttributes.m +14 -5
- package/Libraries/Text/Text/RCTDynamicTypeRamp.h +40 -0
- package/Libraries/Text/Text/RCTDynamicTypeRamp.m +77 -0
- package/Libraries/Text/Text/RCTTextView.m +118 -47
- package/Libraries/Text/Text.js +0 -8
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.h +8 -0
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.m +57 -2
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.m +13 -0
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.h +2 -1
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +88 -3
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +13 -1
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +12 -3
- package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +1 -0
- package/Libraries/Text/TextInput/RCTBaseTextInputShadowView.m +12 -0
- package/Libraries/Text/TextInput/RCTBaseTextInputView.h +9 -1
- package/Libraries/Text/TextInput/RCTBaseTextInputView.m +120 -2
- package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +12 -1
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.m +40 -0
- package/Libraries/Text/TextNativeComponent.js +2 -0
- package/Libraries/Text/TextProps.js +29 -0
- package/Libraries/Types/CoreEventTypes.js +0 -1
- package/React/Base/RCTConvert.m +8 -4
- package/React/Base/RCTRootView.m +0 -9
- package/React/Base/RCTTouchHandler.m +4 -0
- package/React/Base/RCTUIKit.h +8 -13
- package/React/Base/RCTUtils.m +33 -3
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/macOS/RCTUIKit.m +40 -0
- package/React/CoreModules/RCTAppearance.mm +21 -5
- package/React/CoreModules/RCTPerfMonitor.mm +1 -1
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +8 -1
- package/React/Fabric/RCTSurfacePresenter.mm +0 -1
- package/React/Modules/RCTUIManager.m +2 -1
- package/React/React-RCTFabric.podspec +1 -1
- package/React/Views/RCTActivityIndicatorView.m +2 -1
- package/React/Views/RCTCursor.h +39 -0
- package/React/Views/RCTCursor.m +105 -0
- package/React/Views/RCTView.h +16 -0
- package/React/Views/RCTView.m +141 -191
- package/React/Views/RCTViewKeyboardEvent.h +6 -28
- package/React/Views/RCTViewKeyboardEvent.m +66 -61
- package/React/Views/RCTViewManager.m +17 -12
- package/React/Views/ScrollView/RCTScrollContentView.h +4 -0
- package/React/Views/ScrollView/RCTScrollContentView.m +18 -0
- package/React/Views/ScrollView/RCTScrollContentViewManager.m +2 -0
- package/React/Views/ScrollView/RCTScrollView.h +2 -1
- package/React/Views/ScrollView/RCTScrollView.m +70 -63
- package/React/Views/ScrollView/RCTScrollViewManager.m +1 -1
- package/React/Views/UIView+React.h +2 -0
- package/React/Views/UIView+React.m +23 -14
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactCommon/React-Fabric.podspec +1 -1
- package/ReactCommon/React-rncore.podspec +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
- package/package.json +1 -1
- package/scripts/generate-artifacts.js +21 -17
- package/scripts/react_native_pods.rb +0 -3
- package/template/Gemfile.lock +7 -7
- package/template/android/gradlew.bat +89 -89
- package/template/package.json +1 -1
- package/third-party-podspecs/boost-for-react-native.podspec +0 -20
|
@@ -39,10 +39,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
39
39
|
@property (nonatomic, copy, nullable) RCTDirectEventBlock onContentSizeChange;
|
|
40
40
|
@property (nonatomic, copy, nullable) RCTDirectEventBlock onSelectionChange;
|
|
41
41
|
@property (nonatomic, copy, nullable) RCTDirectEventBlock onChange;
|
|
42
|
+
@property (nonatomic, copy, nullable) RCTDirectEventBlock onPaste; // TODO(OSS Candidate GH#774)
|
|
42
43
|
@property (nonatomic, copy, nullable) RCTDirectEventBlock onChangeSync;
|
|
43
44
|
@property (nonatomic, copy, nullable) RCTDirectEventBlock onTextInput;
|
|
44
45
|
@property (nonatomic, copy, nullable) RCTDirectEventBlock onScroll;
|
|
45
|
-
|
|
46
|
+
#if TARGET_OS_OSX // TODO(macOS GH#774)
|
|
47
|
+
@property (nonatomic, copy, nullable) RCTBubblingEventBlock onAutoCorrectChange;
|
|
48
|
+
@property (nonatomic, copy, nullable) RCTBubblingEventBlock onSpellCheckChange;
|
|
49
|
+
@property (nonatomic, copy, nullable) RCTBubblingEventBlock onGrammarCheckChange;
|
|
50
|
+
@property (nonatomic, assign) BOOL clearTextOnSubmit;
|
|
51
|
+
@property (nonatomic, copy, nullable) RCTDirectEventBlock onSubmitEditing;
|
|
52
|
+
@property (nonatomic, copy) NSArray<NSDictionary *> *submitKeyEvents;
|
|
53
|
+
#endif // TODO(macOS GH#774)
|
|
46
54
|
@property (nonatomic, assign) NSInteger mostRecentEventCount;
|
|
47
55
|
@property (nonatomic, assign, readonly) NSInteger nativeEventCount;
|
|
48
56
|
@property (nonatomic, assign) BOOL autoFocus;
|
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
#import <React/RCTUtils.h>
|
|
15
15
|
#import <React/UIView+React.h>
|
|
16
16
|
|
|
17
|
+
#import <React/RCTViewKeyboardEvent.h> // TODO(macOS GH#774)
|
|
17
18
|
#import <React/RCTInputAccessoryView.h>
|
|
18
19
|
#import <React/RCTInputAccessoryViewContent.h>
|
|
19
20
|
#import <React/RCTTextAttributes.h>
|
|
20
21
|
#import <React/RCTTextSelection.h>
|
|
22
|
+
#import <React/RCTUITextView.h> // TODO(macOS GH#774)
|
|
21
23
|
#import "../RCTTextUIKit.h" // TODO(macOS GH#774)
|
|
22
24
|
|
|
23
25
|
@implementation RCTBaseTextInputView {
|
|
@@ -32,7 +34,7 @@
|
|
|
32
34
|
{
|
|
33
35
|
RCTAssertParam(bridge);
|
|
34
36
|
|
|
35
|
-
if (self = [super
|
|
37
|
+
if (self = [super initWithEventDispatcher:bridge.eventDispatcher]) { // TODO(OSS Candidate GH#774)
|
|
36
38
|
_bridge = bridge;
|
|
37
39
|
_eventDispatcher = bridge.eventDispatcher;
|
|
38
40
|
}
|
|
@@ -42,7 +44,6 @@
|
|
|
42
44
|
|
|
43
45
|
RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|
44
46
|
RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)decoder)
|
|
45
|
-
RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
46
47
|
|
|
47
48
|
- (RCTUIView<RCTBackedTextInputViewProtocol> *)backedTextInputView // TODO(macOS ISS#3536887)
|
|
48
49
|
{
|
|
@@ -153,6 +154,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
|
153
154
|
range:NSMakeRange(0, attributedTextCopy.length)];
|
|
154
155
|
|
|
155
156
|
textNeedsUpdate = ([self textOf:attributedTextCopy equals:backedTextInputViewTextCopy] == NO);
|
|
157
|
+
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
158
|
+
// If we are in a language that uses conversion (e.g. Japanese), ignore updates if we have unconverted text.
|
|
159
|
+
if ([self.backedTextInputView hasMarkedText]) {
|
|
160
|
+
textNeedsUpdate = NO;
|
|
161
|
+
}
|
|
162
|
+
#endif // ]TODO(macOS GH#774)
|
|
156
163
|
|
|
157
164
|
if (eventLag == 0 && textNeedsUpdate) {
|
|
158
165
|
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
@@ -402,6 +409,69 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
|
402
409
|
eventCount:_nativeEventCount];
|
|
403
410
|
}
|
|
404
411
|
|
|
412
|
+
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
413
|
+
- (void)automaticSpellingCorrectionDidChange:(BOOL)enabled
|
|
414
|
+
{
|
|
415
|
+
if (_onAutoCorrectChange) {
|
|
416
|
+
_onAutoCorrectChange(@{@"enabled": [NSNumber numberWithBool:enabled]});
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
- (void)continuousSpellCheckingDidChange:(BOOL)enabled
|
|
421
|
+
{
|
|
422
|
+
if (_onSpellCheckChange) {
|
|
423
|
+
_onSpellCheckChange(@{@"enabled": [NSNumber numberWithBool:enabled]});
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
- (void)grammarCheckingDidChange:(BOOL)enabled
|
|
428
|
+
{
|
|
429
|
+
if (_onGrammarCheckChange) {
|
|
430
|
+
_onGrammarCheckChange(@{@"enabled": [NSNumber numberWithBool:enabled]});
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
- (void)submitOnKeyDownIfNeeded:(NSEvent *)event
|
|
435
|
+
{
|
|
436
|
+
NSDictionary *currentKeyboardEvent = [RCTViewKeyboardEvent bodyFromEvent:event];
|
|
437
|
+
// Enter is the default clearTextOnSubmit key
|
|
438
|
+
BOOL shouldSubmit = NO;
|
|
439
|
+
if (!_submitKeyEvents) {
|
|
440
|
+
shouldSubmit = [currentKeyboardEvent[@"key"] isEqualToString:@"Enter"]
|
|
441
|
+
&& ![currentKeyboardEvent[@"altKey"] boolValue]
|
|
442
|
+
&& ![currentKeyboardEvent[@"shiftKey"] boolValue]
|
|
443
|
+
&& ![currentKeyboardEvent[@"ctrlKey"] boolValue]
|
|
444
|
+
&& ![currentKeyboardEvent[@"metaKey"] boolValue]
|
|
445
|
+
&& ![currentKeyboardEvent[@"functionKey"] boolValue]; // Default clearTextOnSubmit key
|
|
446
|
+
} else {
|
|
447
|
+
for (NSDictionary *submitKeyEvent in _submitKeyEvents) {
|
|
448
|
+
if (
|
|
449
|
+
[submitKeyEvent[@"key"] isEqualToString:currentKeyboardEvent[@"key"]] &&
|
|
450
|
+
[submitKeyEvent[@"altKey"] boolValue] == [currentKeyboardEvent[@"altKey"] boolValue] &&
|
|
451
|
+
[submitKeyEvent[@"shiftKey"] boolValue] == [currentKeyboardEvent[@"shiftKey"] boolValue] &&
|
|
452
|
+
[submitKeyEvent[@"ctrlKey"] boolValue]== [currentKeyboardEvent[@"ctrlKey"] boolValue] &&
|
|
453
|
+
[submitKeyEvent[@"metaKey"] boolValue]== [currentKeyboardEvent[@"metaKey"] boolValue] &&
|
|
454
|
+
[submitKeyEvent[@"functionKey"] boolValue]== [currentKeyboardEvent[@"functionKey"] boolValue]
|
|
455
|
+
) {
|
|
456
|
+
shouldSubmit = YES;
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (shouldSubmit) {
|
|
463
|
+
if (_onSubmitEditing) {
|
|
464
|
+
_onSubmitEditing(@{});
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (_clearTextOnSubmit) {
|
|
468
|
+
self.backedTextInputView.attributedText = [NSAttributedString new];
|
|
469
|
+
[self.backedTextInputView.textInputDelegate textInputDidChange];
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
#endif // ]TODO(macOS GH#774)
|
|
474
|
+
|
|
405
475
|
- (BOOL)textInputShouldReturn
|
|
406
476
|
{
|
|
407
477
|
// We send `submit` event here, in `textInputShouldReturn`
|
|
@@ -566,6 +636,35 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
|
566
636
|
return YES;
|
|
567
637
|
}
|
|
568
638
|
|
|
639
|
+
- (BOOL)hasValidKeyDownOrValidKeyUp:(NSString *)key {
|
|
640
|
+
return [self.validKeysDown containsObject:key] || [self.validKeysUp containsObject:key];
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
- (NSDragOperation)textInputDraggingEntered:(id<NSDraggingInfo>)draggingInfo
|
|
644
|
+
{
|
|
645
|
+
if ([draggingInfo.draggingPasteboard availableTypeFromArray:self.registeredDraggedTypes]) {
|
|
646
|
+
return [self draggingEntered:draggingInfo];
|
|
647
|
+
}
|
|
648
|
+
return NSDragOperationNone;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
- (void)textInputDraggingExited:(id<NSDraggingInfo>)draggingInfo
|
|
652
|
+
{
|
|
653
|
+
if ([draggingInfo.draggingPasteboard availableTypeFromArray:self.registeredDraggedTypes]) {
|
|
654
|
+
[self draggingExited:draggingInfo];
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
- (BOOL)textInputShouldHandleDragOperation:(id<NSDraggingInfo>)draggingInfo
|
|
659
|
+
{
|
|
660
|
+
if ([draggingInfo.draggingPasteboard availableTypeFromArray:self.registeredDraggedTypes]) {
|
|
661
|
+
[self performDragOperation:draggingInfo];
|
|
662
|
+
return NO;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
return YES;
|
|
666
|
+
}
|
|
667
|
+
|
|
569
668
|
- (void)textInputDidCancel {
|
|
570
669
|
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeKeyPress
|
|
571
670
|
reactTag:self.reactTag
|
|
@@ -574,6 +673,25 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
|
574
673
|
eventCount:_nativeEventCount];
|
|
575
674
|
[self textInputDidEndEditing];
|
|
576
675
|
}
|
|
676
|
+
|
|
677
|
+
- (BOOL)textInputShouldHandleKeyEvent:(NSEvent *)event {
|
|
678
|
+
return ![self handleKeyboardEvent:event];
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
- (BOOL)textInputShouldHandlePaste:(__unused id)sender
|
|
682
|
+
{
|
|
683
|
+
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
|
|
684
|
+
NSPasteboardType fileType = [pasteboard availableTypeFromArray:@[NSFilenamesPboardType, NSPasteboardTypePNG, NSPasteboardTypeTIFF]];
|
|
685
|
+
NSArray<NSPasteboardType>* pastedTypes = ((RCTUITextView*) self.backedTextInputView).readablePasteboardTypes;
|
|
686
|
+
|
|
687
|
+
// If there's a fileType that is of interest, notify JS. Also blocks notifying JS if it's a text paste
|
|
688
|
+
if (_onPaste && fileType != nil && [pastedTypes containsObject:fileType]) {
|
|
689
|
+
_onPaste([self dataTransferInfoFromPasteboard:pasteboard]);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// Only allow pasting text.
|
|
693
|
+
return fileType == nil;
|
|
694
|
+
}
|
|
577
695
|
#endif // ]TODO(macOS GH#774)
|
|
578
696
|
|
|
579
697
|
- (void)updateLocalData
|
|
@@ -53,7 +53,6 @@ RCT_REMAP_NOT_OSX_VIEW_PROPERTY(spellCheck, backedTextInputView.spellCheckingTyp
|
|
|
53
53
|
RCT_REMAP_OSX_VIEW_PROPERTY(spellCheck, backedTextInputView.continuousSpellCheckingEnabled, BOOL) // TODO(macOS GH#774)
|
|
54
54
|
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(caretHidden, backedTextInputView.caretHidden, BOOL) // TODO(macOS GH#774)
|
|
55
55
|
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(clearButtonMode, backedTextInputView.clearButtonMode, UITextFieldViewMode) // TODO(macOS GH#774)
|
|
56
|
-
RCT_REMAP_VIEW_PROPERTY(scrollEnabled, backedTextInputView.scrollEnabled, BOOL)
|
|
57
56
|
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(secureTextEntry, backedTextInputView.secureTextEntry, BOOL) // TODO(macOS GH#774)
|
|
58
57
|
RCT_EXPORT_VIEW_PROPERTY(autoFocus, BOOL)
|
|
59
58
|
RCT_EXPORT_VIEW_PROPERTY(blurOnSubmit, BOOL)
|
|
@@ -67,10 +66,22 @@ RCT_EXPORT_VIEW_PROPERTY(inputAccessoryViewID, NSString)
|
|
|
67
66
|
RCT_EXPORT_VIEW_PROPERTY(textContentType, NSString)
|
|
68
67
|
RCT_EXPORT_VIEW_PROPERTY(passwordRules, NSString)
|
|
69
68
|
|
|
69
|
+
#if TARGET_OS_OSX // TODO(macOS GH#774)
|
|
70
|
+
RCT_EXPORT_VIEW_PROPERTY(onAutoCorrectChange, RCTBubblingEventBlock);
|
|
71
|
+
RCT_EXPORT_VIEW_PROPERTY(onSpellCheckChange, RCTBubblingEventBlock);
|
|
72
|
+
RCT_EXPORT_VIEW_PROPERTY(onGrammarCheckChange, RCTBubblingEventBlock);
|
|
73
|
+
|
|
74
|
+
// Specifically for clearing text on enter key press
|
|
75
|
+
RCT_EXPORT_VIEW_PROPERTY(clearTextOnSubmit, BOOL);
|
|
76
|
+
RCT_EXPORT_VIEW_PROPERTY(onSubmitEditing, RCTBubblingEventBlock);
|
|
77
|
+
RCT_EXPORT_VIEW_PROPERTY(submitKeyEvents, NSArray<NSDictionary *>);
|
|
78
|
+
#endif // TODO(macOS GH#774)
|
|
79
|
+
|
|
70
80
|
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
|
|
71
81
|
RCT_EXPORT_VIEW_PROPERTY(onKeyPressSync, RCTDirectEventBlock)
|
|
72
82
|
RCT_EXPORT_VIEW_PROPERTY(onChangeSync, RCTDirectEventBlock)
|
|
73
83
|
RCT_EXPORT_VIEW_PROPERTY(onSelectionChange, RCTDirectEventBlock)
|
|
84
|
+
RCT_EXPORT_VIEW_PROPERTY(onPaste, RCTDirectEventBlock)
|
|
74
85
|
RCT_EXPORT_VIEW_PROPERTY(onTextInput, RCTDirectEventBlock)
|
|
75
86
|
RCT_EXPORT_VIEW_PROPERTY(onScroll, RCTDirectEventBlock)
|
|
76
87
|
|
|
@@ -127,6 +127,13 @@
|
|
|
127
127
|
#endif // ]TODO(macOS GH#774)
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
131
|
+
- (BOOL)hasMarkedText
|
|
132
|
+
{
|
|
133
|
+
return ((NSTextView *)self.currentEditor).hasMarkedText;
|
|
134
|
+
}
|
|
135
|
+
#endif // ]TODO(macOS GH#774)
|
|
136
|
+
|
|
130
137
|
#pragma mark - Accessibility
|
|
131
138
|
|
|
132
139
|
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
@@ -144,11 +151,27 @@
|
|
|
144
151
|
|
|
145
152
|
- (void)setTextContainerInset:(UIEdgeInsets)textContainerInset
|
|
146
153
|
{
|
|
154
|
+
if (UIEdgeInsetsEqualToEdgeInsets(textContainerInset, _textContainerInset)) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
147
158
|
_textContainerInset = textContainerInset;
|
|
148
159
|
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
149
160
|
[self setNeedsLayout];
|
|
150
161
|
#else // [TODO(macOS GH#774)
|
|
151
162
|
((RCTUITextFieldCell*)self.cell).textContainerInset = _textContainerInset;
|
|
163
|
+
|
|
164
|
+
if (self.currentEditor) {
|
|
165
|
+
NSRange selectedRange = self.currentEditor.selectedRange;
|
|
166
|
+
|
|
167
|
+
// Relocate the NSTextView without changing the selection.
|
|
168
|
+
[self.cell selectWithFrame:self.bounds
|
|
169
|
+
inView:self
|
|
170
|
+
editor:self.currentEditor
|
|
171
|
+
delegate:self
|
|
172
|
+
start:selectedRange.location
|
|
173
|
+
length:selectedRange.length];
|
|
174
|
+
}
|
|
152
175
|
#endif // ]TODO(macOS GH#774)
|
|
153
176
|
}
|
|
154
177
|
|
|
@@ -482,6 +505,17 @@
|
|
|
482
505
|
}
|
|
483
506
|
return isFirstResponder;
|
|
484
507
|
}
|
|
508
|
+
|
|
509
|
+
- (BOOL)performKeyEquivalent:(NSEvent *)event
|
|
510
|
+
{
|
|
511
|
+
// The currentEditor is NSText for historical reasons, but documented to be NSTextView.
|
|
512
|
+
NSTextView *currentEditor = (NSTextView *)self.currentEditor;
|
|
513
|
+
// The currentEditor is non-nil when focused and hasMarkedText means an IME is open.
|
|
514
|
+
if (currentEditor && !currentEditor.hasMarkedText && ![self.textInputDelegate textInputShouldHandleKeyEvent:event]) {
|
|
515
|
+
return YES; // Don't send currentEditor the keydown event.
|
|
516
|
+
}
|
|
517
|
+
return [super performKeyEquivalent:event];
|
|
518
|
+
}
|
|
485
519
|
#endif // ]TODO(macOS GH#774)
|
|
486
520
|
|
|
487
521
|
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
@@ -563,6 +597,12 @@
|
|
|
563
597
|
[super deleteBackward];
|
|
564
598
|
}
|
|
565
599
|
}
|
|
600
|
+
#else
|
|
601
|
+
- (void)keyUp:(NSEvent *)event {
|
|
602
|
+
if ([self.textInputDelegate textInputShouldHandleKeyEvent:event]) {
|
|
603
|
+
[super keyUp:event];
|
|
604
|
+
}
|
|
605
|
+
}
|
|
566
606
|
#endif // ]TODO(OSS Candidate ISS#2710739)
|
|
567
607
|
|
|
568
608
|
@end
|
|
@@ -33,7 +33,9 @@ export const NativeText: HostComponent<NativeTextProps> =
|
|
|
33
33
|
isPressable: true,
|
|
34
34
|
numberOfLines: true,
|
|
35
35
|
ellipsizeMode: true,
|
|
36
|
+
focusable: true,
|
|
36
37
|
allowFontScaling: true,
|
|
38
|
+
dynamicTypeRamp: true,
|
|
37
39
|
maxFontSizeMultiplier: true,
|
|
38
40
|
disabled: true,
|
|
39
41
|
selectable: true,
|
|
@@ -186,6 +186,23 @@ export type TextProps = $ReadOnly<{|
|
|
|
186
186
|
*/
|
|
187
187
|
adjustsFontSizeToFit?: ?boolean,
|
|
188
188
|
|
|
189
|
+
/**
|
|
190
|
+
* The Dynamic Text scale ramp to apply to this element on iOS.
|
|
191
|
+
*/
|
|
192
|
+
dynamicTypeRamp?: ?(
|
|
193
|
+
| 'caption2'
|
|
194
|
+
| 'caption1'
|
|
195
|
+
| 'footnote'
|
|
196
|
+
| 'subheadline'
|
|
197
|
+
| 'callout'
|
|
198
|
+
| 'body'
|
|
199
|
+
| 'headline'
|
|
200
|
+
| 'title3'
|
|
201
|
+
| 'title2'
|
|
202
|
+
| 'title1'
|
|
203
|
+
| 'largeTitle'
|
|
204
|
+
),
|
|
205
|
+
|
|
189
206
|
/**
|
|
190
207
|
* Smallest possible scale a font can reach.
|
|
191
208
|
*
|
|
@@ -208,4 +225,16 @@ export type TextProps = $ReadOnly<{|
|
|
|
208
225
|
* Specifies the Tooltip for the button view
|
|
209
226
|
*/
|
|
210
227
|
tooltip?: ?string,
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* When `true`, indicates that the text can be focused in key view loop
|
|
231
|
+
* By default, when `selectable={true}` the text view will be focusable unless disabled
|
|
232
|
+
*/
|
|
233
|
+
focusable?: ?boolean,
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Specifies whether focus ring should be drawn when the view has the first responder status.
|
|
237
|
+
* Only works when `focusable={true}`
|
|
238
|
+
*/
|
|
239
|
+
enableFocusRing?: ?boolean, // TODO(macOS GH#774)
|
|
211
240
|
|}>;
|
package/React/Base/RCTConvert.m
CHANGED
|
@@ -1234,8 +1234,11 @@ RCT_JSON_ARRAY_CONVERTER(NSNumber)
|
|
|
1234
1234
|
|
|
1235
1235
|
if ([type isEqualToString:@"fileUrl"]) {
|
|
1236
1236
|
return @[NSFilenamesPboardType];
|
|
1237
|
+
} else if ([type isEqualToString:@"image"]) {
|
|
1238
|
+
return @[NSPasteboardTypePNG, NSPasteboardTypeTIFF];
|
|
1239
|
+
} else if ([type isEqualToString:@"string"]) {
|
|
1240
|
+
return @[NSPasteboardTypeString];
|
|
1237
1241
|
}
|
|
1238
|
-
|
|
1239
1242
|
return @[];
|
|
1240
1243
|
}
|
|
1241
1244
|
|
|
@@ -1244,11 +1247,11 @@ RCT_JSON_ARRAY_CONVERTER(NSNumber)
|
|
|
1244
1247
|
if ([json isKindOfClass:[NSString class]]) {
|
|
1245
1248
|
return [RCTConvert NSPasteboardType:json];
|
|
1246
1249
|
} else if ([json isKindOfClass:[NSArray class]]) {
|
|
1247
|
-
NSMutableArray *
|
|
1250
|
+
NSMutableArray *mutablePasteboardTypes = [NSMutableArray new];
|
|
1248
1251
|
for (NSString *type in json) {
|
|
1249
|
-
[
|
|
1250
|
-
return mutablePastboardTypes.copy;
|
|
1252
|
+
[mutablePasteboardTypes addObjectsFromArray:[RCTConvert NSPasteboardType:type]];
|
|
1251
1253
|
}
|
|
1254
|
+
return mutablePasteboardTypes.copy;
|
|
1252
1255
|
}
|
|
1253
1256
|
return @[];
|
|
1254
1257
|
}
|
|
@@ -1461,6 +1464,7 @@ RCT_ENUM_CONVERTER(
|
|
|
1461
1464
|
@"list": NSAccessibilityListRole,
|
|
1462
1465
|
@"popupbutton": NSAccessibilityPopUpButtonRole,
|
|
1463
1466
|
@"menubutton": NSAccessibilityMenuButtonRole,
|
|
1467
|
+
@"table": NSAccessibilityTableRole,
|
|
1464
1468
|
};
|
|
1465
1469
|
});
|
|
1466
1470
|
|
package/React/Base/RCTRootView.m
CHANGED
|
@@ -431,15 +431,6 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
|
|
|
431
431
|
RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey : self.traitCollection,
|
|
432
432
|
}];
|
|
433
433
|
}
|
|
434
|
-
#else // [TODO(macOS GH#774)
|
|
435
|
-
- (void)viewDidChangeEffectiveAppearance {
|
|
436
|
-
[[NSNotificationCenter defaultCenter] postNotificationName:RCTUserInterfaceStyleDidChangeNotification
|
|
437
|
-
object:self
|
|
438
|
-
userInfo:@{
|
|
439
|
-
RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey: self.effectiveAppearance,
|
|
440
|
-
}];
|
|
441
|
-
|
|
442
|
-
}
|
|
443
434
|
#endif // ]TODO(macOS GH#774)
|
|
444
435
|
|
|
445
436
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
11
11
|
#import <UIKit/UIGestureRecognizerSubclass.h>
|
|
12
12
|
#endif // ]TODO(macOS GH#774)
|
|
13
|
+
#import <React/RCTUITextField.h> // TODO(macOS GH#774)
|
|
13
14
|
|
|
14
15
|
#import "RCTAssert.h"
|
|
15
16
|
#import "RCTBridge.h"
|
|
@@ -138,6 +139,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)coder)
|
|
|
138
139
|
_shouldSendMouseUpOnSystemBehalf = [(NSControl*)targetView isEnabled];
|
|
139
140
|
} else if ([targetView isKindOfClass:[NSText class]]) {
|
|
140
141
|
_shouldSendMouseUpOnSystemBehalf = [(NSText*)targetView isSelectable];
|
|
142
|
+
}
|
|
143
|
+
else if ([targetView.superview isKindOfClass:[RCTUITextField class]]) {
|
|
144
|
+
_shouldSendMouseUpOnSystemBehalf = [(RCTUITextField*)targetView.superview isSelectable];
|
|
141
145
|
} else {
|
|
142
146
|
_shouldSendMouseUpOnSystemBehalf = NO;
|
|
143
147
|
}
|
package/React/Base/RCTUIKit.h
CHANGED
|
@@ -80,11 +80,6 @@ UIKIT_STATIC_INLINE void RCTUIViewSetContentModeRedraw(UIView *view)
|
|
|
80
80
|
view.contentMode = UIViewContentModeRedraw;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
UIKIT_STATIC_INLINE BOOL RCTUIViewDrawViewHierarchyInRectAfterScreenUpdates(RCTPlatformView *view, CGRect rect, BOOL afterUpdates)
|
|
84
|
-
{
|
|
85
|
-
return [view drawViewHierarchyInRect:rect afterScreenUpdates:afterUpdates];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
83
|
UIKIT_STATIC_INLINE BOOL RCTUIViewIsDescendantOfView(RCTPlatformView *view, RCTPlatformView *parent)
|
|
89
84
|
{
|
|
90
85
|
return [view isDescendantOfView:parent];
|
|
@@ -427,9 +422,17 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
|
|
|
427
422
|
@property (nonatomic, assign) BOOL alwaysBounceVertical;
|
|
428
423
|
// macOS specific properties
|
|
429
424
|
@property (nonatomic, assign) BOOL enableFocusRing;
|
|
425
|
+
@property (nonatomic, assign, getter=isScrollEnabled) BOOL scrollEnabled;
|
|
430
426
|
|
|
431
427
|
@end
|
|
432
428
|
|
|
429
|
+
@interface RCTClipView : NSClipView // [TODO(macOS GH#774)
|
|
430
|
+
|
|
431
|
+
@property (nonatomic, assign) BOOL constrainScrolling;
|
|
432
|
+
|
|
433
|
+
@end // ]TODO(macOS GH#774)
|
|
434
|
+
|
|
435
|
+
|
|
433
436
|
NS_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, __unused UIEvent *event)
|
|
434
437
|
{
|
|
435
438
|
return [view hitTest:point];
|
|
@@ -442,14 +445,6 @@ NS_INLINE void RCTUIViewSetContentModeRedraw(RCTPlatformView *view)
|
|
|
442
445
|
view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize;
|
|
443
446
|
}
|
|
444
447
|
|
|
445
|
-
NS_INLINE BOOL RCTUIViewDrawViewHierarchyInRectAfterScreenUpdates(RCTPlatformView *view, CGRect rect, __unused BOOL afterUpdates)
|
|
446
|
-
{
|
|
447
|
-
RCTAssert(afterUpdates, @"We're redrawing the view so it will necessarily include the latest changes.");
|
|
448
|
-
(void) afterUpdates;
|
|
449
|
-
[view displayRectIgnoringOpacity:NSRectToCGRect(rect)];
|
|
450
|
-
return YES;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
448
|
NS_INLINE BOOL RCTUIViewIsDescendantOfView(RCTPlatformView *view, RCTPlatformView *parent)
|
|
454
449
|
{
|
|
455
450
|
return [view isDescendantOf:parent];
|
package/React/Base/RCTUtils.m
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
#import "RCTAssert.h"
|
|
22
22
|
#import "RCTLog.h"
|
|
23
23
|
|
|
24
|
+
static const NSUInteger RCTMaxCachableImageCount = 100;
|
|
25
|
+
|
|
24
26
|
NSString *const RCTErrorUnspecified = @"EUNSPECIFIED";
|
|
25
27
|
|
|
26
28
|
// Returns the Path of Home directory
|
|
@@ -829,11 +831,29 @@ UIImage *__nullable RCTImageFromLocalBundleAssetURL(NSURL *imageURL)
|
|
|
829
831
|
return RCTImageFromLocalAssetURL(bundleImageUrl);
|
|
830
832
|
}
|
|
831
833
|
|
|
834
|
+
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
835
|
+
static NSCache<NSURL *, UIImage *> *RCTLocalImageCache()
|
|
836
|
+
{
|
|
837
|
+
static NSCache *imageCache;
|
|
838
|
+
static dispatch_once_t onceToken;
|
|
839
|
+
dispatch_once(&onceToken, ^{
|
|
840
|
+
imageCache = [NSCache new];
|
|
841
|
+
imageCache.countLimit = RCTMaxCachableImageCount;
|
|
842
|
+
});
|
|
843
|
+
return imageCache;
|
|
844
|
+
}
|
|
845
|
+
#endif // ]TODO(macOS GH#774)
|
|
846
|
+
|
|
832
847
|
UIImage *__nullable RCTImageFromLocalAssetURL(NSURL *imageURL)
|
|
833
848
|
{
|
|
834
849
|
NSString *imageName = RCTBundlePathForURL(imageURL);
|
|
835
850
|
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
836
851
|
NSURL *bundleImageURL = nil;
|
|
852
|
+
|
|
853
|
+
UIImage *cachedImage = [RCTLocalImageCache() objectForKey:imageURL];
|
|
854
|
+
if (cachedImage) {
|
|
855
|
+
return cachedImage;
|
|
856
|
+
}
|
|
837
857
|
#endif // ]TODO(macOS GH#774)
|
|
838
858
|
|
|
839
859
|
NSBundle *bundle = nil;
|
|
@@ -885,9 +905,12 @@ UIImage *__nullable RCTImageFromLocalAssetURL(NSURL *imageURL)
|
|
|
885
905
|
}
|
|
886
906
|
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
887
907
|
image = [UIImage imageWithContentsOfFile:filePath];
|
|
888
|
-
#else // TODO(macOS GH#774)
|
|
889
|
-
|
|
890
|
-
|
|
908
|
+
#else // [TODO(macOS GH#774)
|
|
909
|
+
// macOS keeps file handles in open state for lifetime of image if "initWithContentsOfFile:" is used with path inside app bundle
|
|
910
|
+
// Workaround is to load file in data and then convert data to image
|
|
911
|
+
NSData *data = [NSData dataWithContentsOfFile:filePath];
|
|
912
|
+
image = [[NSImage alloc] initWithData:data];
|
|
913
|
+
#endif // ]TODO(macOS GH#774)
|
|
891
914
|
}
|
|
892
915
|
}
|
|
893
916
|
|
|
@@ -911,6 +934,13 @@ UIImage *__nullable RCTImageFromLocalAssetURL(NSURL *imageURL)
|
|
|
911
934
|
}
|
|
912
935
|
}
|
|
913
936
|
}
|
|
937
|
+
|
|
938
|
+
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
939
|
+
if (image) {
|
|
940
|
+
[RCTLocalImageCache() setObject:image forKey:imageURL];
|
|
941
|
+
}
|
|
942
|
+
#endif // ]TODO(macOS GH#774)
|
|
943
|
+
|
|
914
944
|
return image;
|
|
915
945
|
}
|
|
916
946
|
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -423,12 +423,28 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
+
// We purposely don't use RCTCursor for the parameter type here because it would introduce an import cycle:
|
|
427
|
+
// RCTUIKit > RCTCursor > RCTConvert > RCTUIKit
|
|
428
|
+
- (void)setCursor:(NSInteger)cursor
|
|
429
|
+
{
|
|
430
|
+
// This method is required to be defined due to [RCTVirtualTextViewManager view] returning a RCTUIView.
|
|
431
|
+
}
|
|
432
|
+
|
|
426
433
|
@end
|
|
427
434
|
|
|
428
435
|
// RCTUIScrollView
|
|
429
436
|
|
|
430
437
|
@implementation RCTUIScrollView // TODO(macOS ISS#3536887)
|
|
431
438
|
|
|
439
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
440
|
+
{
|
|
441
|
+
if (self = [super initWithFrame:frame]) {
|
|
442
|
+
self.scrollEnabled = YES;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return self;
|
|
446
|
+
}
|
|
447
|
+
|
|
432
448
|
- (void)setEnableFocusRing:(BOOL)enableFocusRing {
|
|
433
449
|
if (_enableFocusRing != enableFocusRing) {
|
|
434
450
|
_enableFocusRing = enableFocusRing;
|
|
@@ -535,6 +551,7 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
535
551
|
self.verticalScrollElasticity = alwaysBounceVertical ? NSScrollElasticityAllowed : NSScrollElasticityNone;
|
|
536
552
|
}
|
|
537
553
|
|
|
554
|
+
|
|
538
555
|
@end
|
|
539
556
|
|
|
540
557
|
BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
|
|
@@ -550,3 +567,26 @@ BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
|
|
|
550
567
|
|
|
551
568
|
return clipsToBounds;
|
|
552
569
|
}
|
|
570
|
+
|
|
571
|
+
@implementation RCTClipView
|
|
572
|
+
|
|
573
|
+
- (instancetype)initWithFrame:(NSRect)frameRect
|
|
574
|
+
{
|
|
575
|
+
if (self = [super initWithFrame:frameRect]) {
|
|
576
|
+
self.constrainScrolling = NO;
|
|
577
|
+
self.drawsBackground = NO;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
return self;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
- (NSRect)constrainBoundsRect:(NSRect)proposedBounds
|
|
584
|
+
{
|
|
585
|
+
if (self.constrainScrolling) {
|
|
586
|
+
return NSMakeRect(0, 0, 0, 0);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
return [super constrainBoundsRect:proposedBounds];
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
@end
|
|
@@ -137,21 +137,26 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getColorScheme)
|
|
|
137
137
|
return _currentColorScheme;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
140
141
|
- (void)appearanceChanged:(NSNotification *)notification
|
|
141
142
|
{
|
|
142
143
|
NSDictionary *userInfo = [notification userInfo];
|
|
143
|
-
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
144
144
|
UITraitCollection *traitCollection = nil;
|
|
145
145
|
if (userInfo) {
|
|
146
146
|
traitCollection = userInfo[RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey];
|
|
147
147
|
}
|
|
148
148
|
NSString *newColorScheme = RCTColorSchemePreference(traitCollection);
|
|
149
149
|
#else // [TODO(macOS GH#774)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
- (void)observeValueForKeyPath:(NSString *)keyPath
|
|
151
|
+
ofObject:(id)object
|
|
152
|
+
change:(NSDictionary *)change
|
|
153
|
+
context:(void *)context
|
|
154
|
+
{
|
|
155
|
+
if (object != NSApp || ![keyPath isEqualToString:@"effectiveAppearance"]) {
|
|
156
|
+
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
|
157
|
+
return;
|
|
153
158
|
}
|
|
154
|
-
NSString *newColorScheme = RCTColorSchemePreference(
|
|
159
|
+
NSString *newColorScheme = RCTColorSchemePreference(nil);
|
|
155
160
|
#endif // ]TODO(macOS GH#774)
|
|
156
161
|
if (![_currentColorScheme isEqualToString:newColorScheme]) {
|
|
157
162
|
_currentColorScheme = newColorScheme;
|
|
@@ -168,19 +173,30 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getColorScheme)
|
|
|
168
173
|
|
|
169
174
|
- (void)startObserving
|
|
170
175
|
{
|
|
176
|
+
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
171
177
|
if (@available(iOS 13.0, *)) {
|
|
172
178
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
173
179
|
selector:@selector(appearanceChanged:)
|
|
174
180
|
name:RCTUserInterfaceStyleDidChangeNotification
|
|
175
181
|
object:nil];
|
|
176
182
|
}
|
|
183
|
+
#else
|
|
184
|
+
[NSApp addObserver:self
|
|
185
|
+
forKeyPath:@"effectiveAppearance"
|
|
186
|
+
options:NSKeyValueObservingOptionNew
|
|
187
|
+
context:nil];
|
|
188
|
+
#endif // ]TODO(macOS GH#774)
|
|
177
189
|
}
|
|
178
190
|
|
|
179
191
|
- (void)stopObserving
|
|
180
192
|
{
|
|
193
|
+
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
181
194
|
if (@available(iOS 13.0, *)) {
|
|
182
195
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
183
196
|
}
|
|
197
|
+
#else
|
|
198
|
+
[NSApp removeObserver:self forKeyPath:@"effectiveAppearance" context:nil];
|
|
199
|
+
#endif // ]TODO(macOS GH#774)
|
|
184
200
|
}
|
|
185
201
|
|
|
186
202
|
@end
|