react-native-macos 0.71.28 → 0.71.30
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/TextInput/RCTMultilineTextInputNativeComponent.js +1 -1
- package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +1 -1
- package/Libraries/Components/TextInput/TextInput.flow.js +1 -0
- package/Libraries/Components/TextInput/TextInput.js +10 -0
- package/Libraries/Components/TextInput/TextInputNativeCommands.js +13 -1
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Image/RCTUIImageViewAnimated.h +1 -6
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.h +3 -0
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +1 -1
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +4 -1
- package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +5 -0
- package/Libraries/Text/TextInput/RCTBaseTextInputView.h +2 -0
- package/Libraries/Text/TextInput/RCTBaseTextInputView.m +110 -13
- package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +11 -0
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.h +3 -0
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.m +1 -1
- package/React/Base/RCTUIKit.h +14 -5
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/macOS/RCTUIKit.m +93 -21
- package/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm +5 -4
- package/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm +3 -3
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +3 -0
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +3 -58
- package/React/Fabric/RCTSurfaceTouchHandler.mm +1 -0
- package/React/Views/ScrollView/RCTScrollView.m +0 -1
- package/React/Views/UIView+React.m +9 -0
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +13 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.mm +3 -0
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm +2 -3
- package/package.json +1 -1
- package/template/package.json +1 -1
|
@@ -23,7 +23,7 @@ type NativeType = HostComponent<mixed>;
|
|
|
23
23
|
type NativeCommands = TextInputNativeCommands<NativeType>;
|
|
24
24
|
|
|
25
25
|
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
26
|
-
supportedCommands: ['focus', 'blur', 'setTextAndSelection'],
|
|
26
|
+
supportedCommands: ['focus', 'blur', 'setTextAndSelection', 'setGhostText'], // [macOS]
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = {
|
|
@@ -23,7 +23,7 @@ type NativeType = HostComponent<mixed>;
|
|
|
23
23
|
type NativeCommands = TextInputNativeCommands<NativeType>;
|
|
24
24
|
|
|
25
25
|
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
26
|
-
supportedCommands: ['focus', 'blur', 'setTextAndSelection'],
|
|
26
|
+
supportedCommands: ['focus', 'blur', 'setTextAndSelection', 'setGhostText'], // [macOS]
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = {
|
|
@@ -1038,6 +1038,7 @@ type ImperativeMethods = $ReadOnly<{|
|
|
|
1038
1038
|
isFocused: () => boolean,
|
|
1039
1039
|
getNativeRef: () => ?React.ElementRef<HostComponent<mixed>>,
|
|
1040
1040
|
setSelection: (start: number, end: number) => void,
|
|
1041
|
+
setGhostText: (ghostText: ?string) => void, // [macOS]
|
|
1041
1042
|
|}>;
|
|
1042
1043
|
|
|
1043
1044
|
/**
|
|
@@ -1086,6 +1086,7 @@ type ImperativeMethods = $ReadOnly<{|
|
|
|
1086
1086
|
isFocused: () => boolean,
|
|
1087
1087
|
getNativeRef: () => ?React.ElementRef<HostComponent<mixed>>,
|
|
1088
1088
|
setSelection: (start: number, end: number) => void,
|
|
1089
|
+
setGhostText: (ghostText: ?string) => void, // [macOS]
|
|
1089
1090
|
|}>;
|
|
1090
1091
|
|
|
1091
1092
|
const emptyFunctionThatReturnsTrue = () => true;
|
|
@@ -1366,6 +1367,14 @@ function InternalTextInput(props: Props): React.Node {
|
|
|
1366
1367
|
}
|
|
1367
1368
|
}
|
|
1368
1369
|
|
|
1370
|
+
// [macOS
|
|
1371
|
+
function setGhostText(ghostText: ?string) {
|
|
1372
|
+
if (inputRef.current != null) {
|
|
1373
|
+
viewCommands.setGhostText(inputRef.current, ghostText);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
// macOS]
|
|
1377
|
+
|
|
1369
1378
|
// TODO: Fix this returning true on null === null, when no input is focused
|
|
1370
1379
|
function isFocused(): boolean {
|
|
1371
1380
|
return TextInputState.currentlyFocusedInput() === inputRef.current;
|
|
@@ -1407,6 +1416,7 @@ function InternalTextInput(props: Props): React.Node {
|
|
|
1407
1416
|
ref.isFocused = isFocused;
|
|
1408
1417
|
ref.getNativeRef = getNativeRef;
|
|
1409
1418
|
ref.setSelection = setSelection;
|
|
1419
|
+
ref.setGhostText = setGhostText; // [macOS]
|
|
1410
1420
|
}
|
|
1411
1421
|
},
|
|
1412
1422
|
});
|
|
@@ -22,8 +22,20 @@ export interface TextInputNativeCommands<T> {
|
|
|
22
22
|
start: Int32,
|
|
23
23
|
end: Int32,
|
|
24
24
|
) => void;
|
|
25
|
+
// [macOS
|
|
26
|
+
// NYI on Android
|
|
27
|
+
+setGhostText: (
|
|
28
|
+
viewRef: React.ElementRef<T>,
|
|
29
|
+
value: ?string, // in theory this is nullable
|
|
30
|
+
) => void;
|
|
31
|
+
// macOS]
|
|
25
32
|
}
|
|
26
33
|
|
|
27
|
-
const supportedCommands = [
|
|
34
|
+
const supportedCommands = [
|
|
35
|
+
'focus',
|
|
36
|
+
'blur',
|
|
37
|
+
'setTextAndSelection',
|
|
38
|
+
'setGhostText',
|
|
39
|
+
]; // [macOS]
|
|
28
40
|
|
|
29
41
|
export default supportedCommands;
|
|
@@ -8,10 +8,5 @@
|
|
|
8
8
|
#import <React/RCTAnimatedImage.h>
|
|
9
9
|
#import <React/RCTDefines.h>
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
@interface RCTUIImageViewAnimated : UIImageView
|
|
13
|
-
#else // [macOS
|
|
14
|
-
@interface RCTUIImageViewAnimated : NSImageView
|
|
15
|
-
#endif // macOS]
|
|
16
|
-
|
|
11
|
+
@interface RCTUIImageViewAnimated : RCTUIImageView // [macOS]
|
|
17
12
|
@end
|
|
@@ -52,10 +52,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
52
52
|
@property (nonatomic, copy) NSString *text;
|
|
53
53
|
@property (nonatomic, assign) NSTextAlignment textAlignment;
|
|
54
54
|
@property (nonatomic, copy, nullable) NSAttributedString *attributedText;
|
|
55
|
+
@property (nonatomic, assign) CGFloat pointScaleFactor;
|
|
55
56
|
- (NSSize)sizeThatFits:(NSSize)size;
|
|
56
57
|
- (void)setReadablePasteBoardTypes:(NSArray<NSPasteboardType> *)readablePasteboardTypes;
|
|
57
58
|
#endif // macOS]
|
|
58
59
|
|
|
60
|
+
@property (nonatomic, getter=isGhostTextChanging) BOOL ghostTextChanging; // [macOS]
|
|
61
|
+
|
|
59
62
|
@end
|
|
60
63
|
|
|
61
64
|
NS_ASSUME_NONNULL_END
|
|
@@ -459,7 +459,7 @@ static RCTUIColor *defaultPlaceholderColor() // [macOS]
|
|
|
459
459
|
.size;
|
|
460
460
|
placeholderSize = CGSizeMake(RCTCeilPixelValue(placeholderSize.width), RCTCeilPixelValue(placeholderSize.height));
|
|
461
461
|
#else // [macOS
|
|
462
|
-
CGFloat scale = self.window.backingScaleFactor;
|
|
462
|
+
CGFloat scale = _pointScaleFactor ?: self.window.backingScaleFactor;
|
|
463
463
|
CGSize placeholderSize = [placeholder sizeWithAttributes:[self _placeholderTextAttributes]];
|
|
464
464
|
placeholderSize = CGSizeMake(RCTCeilPixelValue(placeholderSize.width, scale), RCTCeilPixelValue(placeholderSize.height, scale));
|
|
465
465
|
#endif // macOS]
|
|
@@ -382,7 +382,10 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo
|
|
|
382
382
|
{
|
|
383
383
|
if (_lastStringStateWasUpdatedWith && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
|
|
384
384
|
[self textViewDidChange:_backedTextInputView];
|
|
385
|
-
|
|
385
|
+
|
|
386
|
+
if (![_backedTextInputView isGhostTextChanging]) { // [macOS]
|
|
387
|
+
_ignoreNextTextInputCall = YES;
|
|
388
|
+
} // [macOS]
|
|
386
389
|
}
|
|
387
390
|
_lastStringStateWasUpdatedWith = _backedTextInputView.attributedText;
|
|
388
391
|
[self textViewProbablyDidChangeSelection];
|
|
@@ -59,6 +59,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
59
59
|
@property (nonatomic, assign, readonly) CGFloat zoomScale;
|
|
60
60
|
@property (nonatomic, assign, readonly) CGPoint contentOffset;
|
|
61
61
|
@property (nonatomic, assign, readonly) UIEdgeInsets contentInset;
|
|
62
|
+
#if TARGET_OS_OSX // [macOS
|
|
63
|
+
@property (nonatomic, assign) CGFloat pointScaleFactor;
|
|
64
|
+
#endif // macOS]
|
|
62
65
|
|
|
63
66
|
// This protocol disallows direct access to `selectedTextRange` property because
|
|
64
67
|
// unwise usage of it can break the `delegate` behavior. So, we always have to
|
|
@@ -84,6 +87,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
84
87
|
// Use `attributedText.string` instead.
|
|
85
88
|
@property (nonatomic, copy, nullable) NSString *text NS_UNAVAILABLE;
|
|
86
89
|
|
|
90
|
+
@property (nonatomic, getter=isGhostTextChanging) BOOL ghostTextChanging; // [macOS]
|
|
91
|
+
|
|
87
92
|
@end
|
|
88
93
|
|
|
89
94
|
NS_ASSUME_NONNULL_END
|
|
@@ -68,6 +68,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
68
68
|
@property (nonatomic, assign) BOOL showSoftInputOnFocus;
|
|
69
69
|
#endif // [macOS]
|
|
70
70
|
|
|
71
|
+
@property (nonatomic, copy, nullable) NSString *ghostText; // [macOS]
|
|
72
|
+
|
|
71
73
|
/**
|
|
72
74
|
Sets selection intext input if both start and end are within range of the text input.
|
|
73
75
|
**/
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
@implementation RCTBaseTextInputView {
|
|
27
27
|
__weak RCTBridge *_bridge;
|
|
28
28
|
__weak id<RCTEventDispatcherProtocol> _eventDispatcher;
|
|
29
|
+
|
|
30
|
+
NSInteger _ghostTextPosition; // [macOS] only valid if _ghostText != nil
|
|
31
|
+
|
|
29
32
|
BOOL _hasInputAccesoryView;
|
|
30
33
|
// [macOS] remove explicit _predictedText ivar declaration
|
|
31
34
|
BOOL _didMoveToWindow;
|
|
@@ -164,7 +167,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
164
167
|
|
|
165
168
|
textNeedsUpdate = ([self textOf:attributedTextCopy equals:backedTextInputViewTextCopy] == NO);
|
|
166
169
|
|
|
167
|
-
if (eventLag == 0 && textNeedsUpdate) {
|
|
170
|
+
if ((eventLag == 0 || self.backedTextInputView.ghostTextChanging) && textNeedsUpdate) { // [macOS]
|
|
168
171
|
#if !TARGET_OS_OSX // [macOS]
|
|
169
172
|
UITextRange *selection = self.backedTextInputView.selectedTextRange;
|
|
170
173
|
#else // [macOS
|
|
@@ -191,7 +194,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
191
194
|
[self.backedTextInputView positionFromPosition:self.backedTextInputView.beginningOfDocument offset:newOffset];
|
|
192
195
|
[self.backedTextInputView setSelectedTextRange:[self.backedTextInputView textRangeFromPosition:position
|
|
193
196
|
toPosition:position]
|
|
194
|
-
notifyDelegate
|
|
197
|
+
notifyDelegate:!self.backedTextInputView.ghostTextChanging]; // [macOS]
|
|
195
198
|
}
|
|
196
199
|
#else // [macOS
|
|
197
200
|
if (selection.length == 0) {
|
|
@@ -200,7 +203,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
200
203
|
NSInteger offsetFromEnd = oldTextLength - start;
|
|
201
204
|
NSInteger newOffset = self.backedTextInputView.attributedText.length - offsetFromEnd;
|
|
202
205
|
[self.backedTextInputView setSelectedTextRange:NSMakeRange(newOffset, 0)
|
|
203
|
-
notifyDelegate
|
|
206
|
+
notifyDelegate:!self.backedTextInputView.ghostTextChanging];
|
|
204
207
|
}
|
|
205
208
|
#endif // macOS]
|
|
206
209
|
|
|
@@ -415,6 +418,8 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
415
418
|
|
|
416
419
|
- (void)textInputDidEndEditing
|
|
417
420
|
{
|
|
421
|
+
self.ghostText = nil; // [macOS]
|
|
422
|
+
|
|
418
423
|
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeEnd
|
|
419
424
|
reactTag:self.reactTag
|
|
420
425
|
text:[self.backedTextInputView.attributedText.string copy]
|
|
@@ -524,6 +529,8 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
524
529
|
{
|
|
525
530
|
id<RCTBackedTextInputViewProtocol> backedTextInputView = self.backedTextInputView;
|
|
526
531
|
|
|
532
|
+
self.ghostText = nil; // [macOS]
|
|
533
|
+
|
|
527
534
|
if (!backedTextInputView.textWasPasted) {
|
|
528
535
|
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeKeyPress
|
|
529
536
|
reactTag:self.reactTag
|
|
@@ -590,7 +597,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
590
597
|
withString:text];
|
|
591
598
|
}
|
|
592
599
|
|
|
593
|
-
if (_onTextInput) {
|
|
600
|
+
if (_onTextInput && !self.backedTextInputView.ghostTextChanging) { // [macOS]
|
|
594
601
|
_onTextInput(@{
|
|
595
602
|
// We copy the string here because if it's a mutable string it may get released before we stop using it on a
|
|
596
603
|
// different thread, causing a crash.
|
|
@@ -624,20 +631,24 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
624
631
|
[self setPredictedText:backedTextInputView.attributedText.string]; // [macOS]
|
|
625
632
|
}
|
|
626
633
|
|
|
627
|
-
|
|
634
|
+
if (!self.backedTextInputView.ghostTextChanging) { // [macOS]
|
|
635
|
+
_nativeEventCount++;
|
|
628
636
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
637
|
+
if (_onChange) {
|
|
638
|
+
_onChange(@{
|
|
639
|
+
@"text" : [self.attributedText.string copy],
|
|
640
|
+
@"target" : self.reactTag,
|
|
641
|
+
@"eventCount" : @(_nativeEventCount),
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
} // [macOS]
|
|
636
645
|
}
|
|
637
646
|
|
|
638
647
|
- (void)textInputDidChangeSelection
|
|
639
648
|
{
|
|
640
|
-
|
|
649
|
+
self.ghostText = nil; // [macOS]
|
|
650
|
+
|
|
651
|
+
if (!_onSelectionChange || self.backedTextInputView.ghostTextChanging) { // [macOS]
|
|
641
652
|
return;
|
|
642
653
|
}
|
|
643
654
|
|
|
@@ -875,6 +886,92 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
875
886
|
}
|
|
876
887
|
#endif // [macOS]
|
|
877
888
|
|
|
889
|
+
// [macOS
|
|
890
|
+
|
|
891
|
+
- (NSDictionary<NSAttributedStringKey, id> *)ghostTextAttributes
|
|
892
|
+
{
|
|
893
|
+
RCTUIView<RCTBackedTextInputViewProtocol> *backedTextInputView = self.backedTextInputView;
|
|
894
|
+
NSMutableDictionary<NSAttributedStringKey, id> *textAttributes =
|
|
895
|
+
[backedTextInputView.defaultTextAttributes mutableCopy] ?: [NSMutableDictionary new];
|
|
896
|
+
|
|
897
|
+
if (@available(iOS 13.0, *)) {
|
|
898
|
+
[textAttributes setValue:backedTextInputView.placeholderColor ?: [RCTUIColor placeholderTextColor]
|
|
899
|
+
forKey:NSForegroundColorAttributeName];
|
|
900
|
+
} else {
|
|
901
|
+
if (backedTextInputView.placeholderColor) {
|
|
902
|
+
[textAttributes setValue:backedTextInputView.placeholderColor forKey:NSForegroundColorAttributeName];
|
|
903
|
+
} else {
|
|
904
|
+
[textAttributes removeObjectForKey:NSForegroundColorAttributeName];
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
return textAttributes;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
- (void)setGhostText:(NSString *)ghostText {
|
|
912
|
+
RCTTextSelection *selection = self.selection;
|
|
913
|
+
NSString *newGhostText = ghostText.length > 0 ? ghostText : nil;
|
|
914
|
+
|
|
915
|
+
if (selection.start != selection.end) {
|
|
916
|
+
newGhostText = nil;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
if ((_ghostText == nil && newGhostText == nil) || [_ghostText isEqual:newGhostText]) {
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
if (self.backedTextInputView.ghostTextChanging) {
|
|
924
|
+
// look out for nested callbacks -- this can happen for example when selection changes in response to
|
|
925
|
+
// attributed text changing. Such callbacks are initiated by Apple, or we could suppress this other ways.
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
self.backedTextInputView.ghostTextChanging = YES;
|
|
930
|
+
|
|
931
|
+
if (_ghostText != nil) {
|
|
932
|
+
BOOL shouldDeleteGhostText = YES;
|
|
933
|
+
NSRange ghostTextRange = NSMakeRange(_ghostTextPosition, _ghostText.length);
|
|
934
|
+
NSMutableAttributedString *attributedString = [self.attributedText mutableCopy];
|
|
935
|
+
|
|
936
|
+
if ([attributedString length] < NSMaxRange(ghostTextRange)) {
|
|
937
|
+
RCTAssert(false, @"Ghost text not fully present in text view text");
|
|
938
|
+
shouldDeleteGhostText = NO;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
NSString *actualGhostText = shouldDeleteGhostText
|
|
942
|
+
? [[attributedString attributedSubstringFromRange:ghostTextRange] string]
|
|
943
|
+
: nil;
|
|
944
|
+
|
|
945
|
+
if (![actualGhostText isEqual:_ghostText]) {
|
|
946
|
+
RCTAssert(false, @"Ghost text does not match text view text");
|
|
947
|
+
shouldDeleteGhostText = NO;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
if (shouldDeleteGhostText) {
|
|
951
|
+
[attributedString deleteCharactersInRange:ghostTextRange];
|
|
952
|
+
self.attributedText = attributedString;
|
|
953
|
+
[self setSelectionStart:selection.start selectionEnd:selection.end];
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
_ghostText = [newGhostText copy];
|
|
958
|
+
_ghostTextPosition = selection.start;
|
|
959
|
+
|
|
960
|
+
if (_ghostText != nil) {
|
|
961
|
+
NSMutableAttributedString *attributedString = [self.attributedText mutableCopy];
|
|
962
|
+
NSAttributedString *ghostAttributedString = [[NSAttributedString alloc] initWithString:_ghostText
|
|
963
|
+
attributes:self.ghostTextAttributes];
|
|
964
|
+
|
|
965
|
+
[attributedString insertAttributedString:ghostAttributedString atIndex:_ghostTextPosition];
|
|
966
|
+
self.attributedText = attributedString;
|
|
967
|
+
[self setSelectionStart:_ghostTextPosition selectionEnd:_ghostTextPosition];
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
self.backedTextInputView.ghostTextChanging = NO;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
// macOS]
|
|
974
|
+
|
|
878
975
|
#pragma mark - Helpers
|
|
879
976
|
|
|
880
977
|
static BOOL findMismatch(NSString *first, NSString *second, NSRange *firstRange, NSRange *secondRange)
|
|
@@ -169,6 +169,17 @@ RCT_EXPORT_METHOD(setTextAndSelection
|
|
|
169
169
|
}];
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
// [macOS
|
|
173
|
+
RCT_EXPORT_METHOD(setGhostText
|
|
174
|
+
:(nonnull NSNumber *)reactTag
|
|
175
|
+
:(NSString *)text) {
|
|
176
|
+
|
|
177
|
+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTPlatformView *> *viewRegistry) {
|
|
178
|
+
[(RCTBaseTextInputView *)viewRegistry[reactTag] setGhostText:text];
|
|
179
|
+
}];
|
|
180
|
+
}
|
|
181
|
+
// macOS]
|
|
182
|
+
|
|
172
183
|
#pragma mark - RCTUIManagerObserver
|
|
173
184
|
|
|
174
185
|
- (void)uiManagerWillPerformMounting:(__unused RCTUIManager *)uiManager
|
|
@@ -59,8 +59,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
59
59
|
@property (nonatomic, assign) BOOL enableFocusRing;
|
|
60
60
|
@property (nonatomic, strong, nullable) RCTUIColor *selectionColor;
|
|
61
61
|
@property (weak, nullable) id<RCTUITextFieldDelegate> delegate;
|
|
62
|
+
@property (nonatomic, assign) CGFloat pointScaleFactor;
|
|
62
63
|
#endif // macOS]
|
|
63
64
|
|
|
65
|
+
@property (nonatomic, getter=isGhostTextChanging) BOOL ghostTextChanging; // [macOS]
|
|
66
|
+
|
|
64
67
|
@end
|
|
65
68
|
|
|
66
69
|
NS_ASSUME_NONNULL_END
|
|
@@ -593,7 +593,7 @@
|
|
|
593
593
|
size = CGSizeMake(RCTCeilPixelValue(size.width), RCTCeilPixelValue(size.height));
|
|
594
594
|
#else // [macOS
|
|
595
595
|
CGSize size = [text sizeWithAttributes:@{NSFontAttributeName: self.font}];
|
|
596
|
-
CGFloat scale = self.window.backingScaleFactor;
|
|
596
|
+
CGFloat scale = _pointScaleFactor ?: self.window.backingScaleFactor;
|
|
597
597
|
RCTAssert(scale != 0.0, @"Layout occurs before the view is in a window?");
|
|
598
598
|
if (scale == 0) {
|
|
599
599
|
scale = [[NSScreen mainScreen] backingScaleFactor];
|
package/React/Base/RCTUIKit.h
CHANGED
|
@@ -391,7 +391,6 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
|
|
|
391
391
|
- (void)layoutIfNeeded;
|
|
392
392
|
|
|
393
393
|
- (void)layoutSubviews;
|
|
394
|
-
- (NSArray<RCTUIView *> *)reactZIndexSortedSubviews; // [macOS]
|
|
395
394
|
|
|
396
395
|
- (void)setNeedsDisplay;
|
|
397
396
|
|
|
@@ -417,10 +416,6 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
|
|
|
417
416
|
* Specifies whether focus ring should be drawn when the view has the first responder status.
|
|
418
417
|
*/
|
|
419
418
|
@property (nonatomic, assign) BOOL enableFocusRing;
|
|
420
|
-
/**
|
|
421
|
-
* The z-index of the view.
|
|
422
|
-
*/
|
|
423
|
-
@property (nonatomic, assign) NSInteger reactZIndex;
|
|
424
419
|
|
|
425
420
|
@end
|
|
426
421
|
|
|
@@ -586,3 +581,17 @@ typedef UITouch RCTUITouch;
|
|
|
586
581
|
@interface RCTUITouch : NSEvent
|
|
587
582
|
@end
|
|
588
583
|
#endif
|
|
584
|
+
|
|
585
|
+
// RCTUIImageView
|
|
586
|
+
|
|
587
|
+
#if !TARGET_OS_OSX
|
|
588
|
+
typedef UIImageView RCTUIImageView;
|
|
589
|
+
#else
|
|
590
|
+
@interface RCTUIImageView : NSImageView
|
|
591
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
592
|
+
@property (nonatomic, assign) BOOL clipsToBounds;
|
|
593
|
+
@property (nonatomic, strong) RCTUIColor *tintColor;
|
|
594
|
+
@property (nonatomic, assign) UIViewContentMode contentMode;
|
|
595
|
+
NS_ASSUME_NONNULL_END
|
|
596
|
+
@end
|
|
597
|
+
#endif
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -416,27 +416,6 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
416
416
|
[super layout];
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
-
- (NSArray<RCTUIView *> *)reactZIndexSortedSubviews
|
|
420
|
-
{
|
|
421
|
-
// Check if sorting is required - in most cases it won't be.
|
|
422
|
-
BOOL sortingRequired = NO;
|
|
423
|
-
for (RCTUIView *subview in self.subviews) {
|
|
424
|
-
if (subview.reactZIndex != 0) {
|
|
425
|
-
sortingRequired = YES;
|
|
426
|
-
break;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
return sortingRequired ? [self.subviews sortedArrayUsingComparator:^NSComparisonResult(RCTUIView *a, RCTUIView *b) {
|
|
430
|
-
if (a.reactZIndex > b.reactZIndex) {
|
|
431
|
-
return NSOrderedDescending;
|
|
432
|
-
} else {
|
|
433
|
-
// Ensure sorting is stable by treating equal zIndex as ascending so
|
|
434
|
-
// that original order is preserved.
|
|
435
|
-
return NSOrderedAscending;
|
|
436
|
-
}
|
|
437
|
-
}] : self.subviews;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
419
|
- (void)setNeedsDisplay
|
|
441
420
|
{
|
|
442
421
|
self.needsDisplay = YES;
|
|
@@ -472,6 +451,7 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
472
451
|
{
|
|
473
452
|
if (self = [super initWithFrame:frame]) {
|
|
474
453
|
self.scrollEnabled = YES;
|
|
454
|
+
self.drawsBackground = NO;
|
|
475
455
|
}
|
|
476
456
|
|
|
477
457
|
return self;
|
|
@@ -781,4 +761,96 @@ BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
|
|
|
781
761
|
|
|
782
762
|
@end
|
|
783
763
|
|
|
764
|
+
// RCTUIImageView
|
|
765
|
+
|
|
766
|
+
@implementation RCTUIImageView {
|
|
767
|
+
CALayer *_tintingLayer;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
771
|
+
{
|
|
772
|
+
if (self = [super initWithFrame:frame]) {
|
|
773
|
+
[self setLayer:[[CALayer alloc] init]];
|
|
774
|
+
[self setWantsLayer:YES];
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
return self;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
- (BOOL)clipsToBounds
|
|
781
|
+
{
|
|
782
|
+
return [[self layer] masksToBounds];
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
- (void)setClipsToBounds:(BOOL)clipsToBounds
|
|
786
|
+
{
|
|
787
|
+
[[self layer] setMasksToBounds:clipsToBounds];
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
- (void)setContentMode:(UIViewContentMode)contentMode
|
|
791
|
+
{
|
|
792
|
+
_contentMode = contentMode;
|
|
793
|
+
|
|
794
|
+
CALayer *layer = [self layer];
|
|
795
|
+
switch (contentMode) {
|
|
796
|
+
case UIViewContentModeScaleAspectFill:
|
|
797
|
+
[layer setContentsGravity:kCAGravityResizeAspectFill];
|
|
798
|
+
break;
|
|
799
|
+
|
|
800
|
+
case UIViewContentModeScaleAspectFit:
|
|
801
|
+
[layer setContentsGravity:kCAGravityResizeAspect];
|
|
802
|
+
break;
|
|
803
|
+
|
|
804
|
+
case UIViewContentModeScaleToFill:
|
|
805
|
+
[layer setContentsGravity:kCAGravityResize];
|
|
806
|
+
break;
|
|
807
|
+
|
|
808
|
+
case UIViewContentModeCenter:
|
|
809
|
+
[layer setContentsGravity:kCAGravityCenter];
|
|
810
|
+
break;
|
|
811
|
+
|
|
812
|
+
default:
|
|
813
|
+
break;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
- (UIImage *)image
|
|
818
|
+
{
|
|
819
|
+
return [[self layer] contents];
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
- (void)setImage:(UIImage *)image
|
|
823
|
+
{
|
|
824
|
+
CALayer *layer = [self layer];
|
|
825
|
+
|
|
826
|
+
if ([layer contents] != image || [layer backgroundColor] != nil) {
|
|
827
|
+
if (_tintColor) {
|
|
828
|
+
if (!_tintingLayer) {
|
|
829
|
+
_tintingLayer = [CALayer new];
|
|
830
|
+
[_tintingLayer setFrame:self.bounds];
|
|
831
|
+
[_tintingLayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
|
|
832
|
+
[_tintingLayer setZPosition:1.0];
|
|
833
|
+
CIFilter *sourceInCompositingFilter = [CIFilter filterWithName:@"CISourceInCompositing"];
|
|
834
|
+
[sourceInCompositingFilter setDefaults];
|
|
835
|
+
[_tintingLayer setCompositingFilter:sourceInCompositingFilter];
|
|
836
|
+
[layer addSublayer:_tintingLayer];
|
|
837
|
+
}
|
|
838
|
+
[_tintingLayer setBackgroundColor:_tintColor.CGColor];
|
|
839
|
+
} else {
|
|
840
|
+
[_tintingLayer removeFromSuperlayer];
|
|
841
|
+
_tintingLayer = nil;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
if (image != nil && [image resizingMode] == NSImageResizingModeTile) {
|
|
845
|
+
[layer setContents:nil];
|
|
846
|
+
[layer setBackgroundColor:[NSColor colorWithPatternImage:image].CGColor];
|
|
847
|
+
} else {
|
|
848
|
+
[layer setContents:image];
|
|
849
|
+
[layer setBackgroundColor:nil];
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
@end
|
|
855
|
+
|
|
784
856
|
#endif
|
|
@@ -31,10 +31,8 @@ using namespace facebook::react;
|
|
|
31
31
|
_props = defaultProps;
|
|
32
32
|
|
|
33
33
|
_imageView = [RCTUIImageViewAnimated new];
|
|
34
|
-
#if !TARGET_OS_OSX // [macOS]
|
|
35
34
|
_imageView.clipsToBounds = YES;
|
|
36
35
|
_imageView.contentMode = RCTContentModeFromImageResizeMode(defaultProps->resizeMode);
|
|
37
|
-
#endif // [macOS]
|
|
38
36
|
_imageView.layer.minificationFilter = kCAFilterTrilinear;
|
|
39
37
|
_imageView.layer.magnificationFilter = kCAFilterTrilinear;
|
|
40
38
|
|
|
@@ -58,7 +56,6 @@ using namespace facebook::react;
|
|
|
58
56
|
auto const &oldImageProps = *std::static_pointer_cast<ImageProps const>(_props);
|
|
59
57
|
auto const &newImageProps = *std::static_pointer_cast<ImageProps const>(props);
|
|
60
58
|
|
|
61
|
-
#if !TARGET_OS_OSX // [macOS]
|
|
62
59
|
// `resizeMode`
|
|
63
60
|
if (oldImageProps.resizeMode != newImageProps.resizeMode) {
|
|
64
61
|
_imageView.contentMode = RCTContentModeFromImageResizeMode(newImageProps.resizeMode);
|
|
@@ -68,7 +65,6 @@ using namespace facebook::react;
|
|
|
68
65
|
if (oldImageProps.tintColor != newImageProps.tintColor) {
|
|
69
66
|
_imageView.tintColor = RCTUIColorFromSharedColor(newImageProps.tintColor);
|
|
70
67
|
}
|
|
71
|
-
#endif // [macOS]
|
|
72
68
|
|
|
73
69
|
[super updateProps:props oldProps:oldProps];
|
|
74
70
|
}
|
|
@@ -149,6 +145,11 @@ using namespace facebook::react;
|
|
|
149
145
|
image = [image resizableImageWithCapInsets:RCTUIEdgeInsetsFromEdgeInsets(imageProps.capInsets)
|
|
150
146
|
resizingMode:UIImageResizingModeStretch];
|
|
151
147
|
}
|
|
148
|
+
#else
|
|
149
|
+
if (imageProps.resizeMode == ImageResizeMode::Repeat) {
|
|
150
|
+
image.capInsets = RCTUIEdgeInsetsFromEdgeInsets(imageProps.capInsets);
|
|
151
|
+
image.resizingMode = NSImageResizingModeTile;
|
|
152
|
+
}
|
|
152
153
|
#endif // [macOS]
|
|
153
154
|
|
|
154
155
|
if (imageProps.blurRadius > __FLT_EPSILON__) {
|
|
@@ -54,13 +54,13 @@ using namespace facebook::react;
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
UIEdgeInsets insets = [self _safeAreaInsets];
|
|
57
|
+
CGFloat scale = _layoutMetrics.pointScaleFactor; // [macOS]
|
|
57
58
|
#if !TARGET_OS_OSX // [macOS]
|
|
58
59
|
insets.left = RCTRoundPixelValue(insets.left);
|
|
59
60
|
insets.top = RCTRoundPixelValue(insets.top);
|
|
60
61
|
insets.right = RCTRoundPixelValue(insets.right);
|
|
61
62
|
insets.bottom = RCTRoundPixelValue(insets.bottom);
|
|
62
63
|
#else // [macOS
|
|
63
|
-
CGFloat scale = [[NSScreen mainScreen] backingScaleFactor];;
|
|
64
64
|
insets.left = RCTRoundPixelValue(insets.left, scale);
|
|
65
65
|
insets.top = RCTRoundPixelValue(insets.top, scale);
|
|
66
66
|
insets.right = RCTRoundPixelValue(insets.right, scale);
|
|
@@ -68,8 +68,8 @@ using namespace facebook::react;
|
|
|
68
68
|
#endif // macOS]
|
|
69
69
|
|
|
70
70
|
auto newPadding = RCTEdgeInsetsFromUIEdgeInsets(insets);
|
|
71
|
-
auto threshold = 1.0 /
|
|
72
|
-
|
|
71
|
+
auto threshold = 1.0 / scale + 0.01; // Size of a pixel plus some small threshold. [macOS]
|
|
72
|
+
|
|
73
73
|
_state->updateState(
|
|
74
74
|
[=](SafeAreaViewShadowNode::ConcreteState::Data const &oldData)
|
|
75
75
|
-> SafeAreaViewShadowNode::ConcreteState::SharedData {
|
|
@@ -259,6 +259,9 @@ using namespace facebook::react;
|
|
|
259
259
|
{
|
|
260
260
|
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
261
261
|
|
|
262
|
+
#if TARGET_OS_OSX // [macOS
|
|
263
|
+
_backedTextInputView.pointScaleFactor = layoutMetrics.pointScaleFactor;
|
|
264
|
+
#endif // macOS]
|
|
262
265
|
_backedTextInputView.frame =
|
|
263
266
|
UIEdgeInsetsInsetRect(self.bounds, RCTUIEdgeInsetsFromEdgeInsets(layoutMetrics.borderWidth));
|
|
264
267
|
_backedTextInputView.textContainerInset =
|
|
@@ -460,7 +460,6 @@ using namespace facebook::react;
|
|
|
460
460
|
return _propKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN;
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
-
#if !TARGET_OS_OSX // [macOS]
|
|
464
463
|
- (RCTUIView *)betterHitTest:(CGPoint)point withEvent:(UIEvent *)event // [macOS]
|
|
465
464
|
{
|
|
466
465
|
// This is a classic textbook implementation of `hitTest:` with a couple of improvements:
|
|
@@ -511,60 +510,6 @@ using namespace facebook::react;
|
|
|
511
510
|
return view != self ? view : nil;
|
|
512
511
|
}
|
|
513
512
|
}
|
|
514
|
-
#else // [macOS
|
|
515
|
-
|
|
516
|
-
- (RCTUIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event // [macOS]
|
|
517
|
-
{
|
|
518
|
-
BOOL canReceiveTouchEvents = ([self isUserInteractionEnabled] && ![self isHidden]);
|
|
519
|
-
if (!canReceiveTouchEvents) {
|
|
520
|
-
return nil;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
// `hitSubview` is the topmost subview which was hit. The hit point can
|
|
524
|
-
// be outside the bounds of `view` (e.g., if -clipsToBounds is NO).
|
|
525
|
-
RCTUIView *hitSubview = nil; // [macOS]
|
|
526
|
-
BOOL isPointInside = [self pointInside:point withEvent:event];
|
|
527
|
-
BOOL needsHitSubview = !(_props->pointerEvents == PointerEventsMode::None || _props->pointerEvents == PointerEventsMode::BoxOnly);
|
|
528
|
-
if (needsHitSubview && (![self clipsToBounds] || isPointInside)) {
|
|
529
|
-
// Take z-index into account when calculating the touch target.
|
|
530
|
-
NSArray<RCTUIView *> *sortedSubviews = [self reactZIndexSortedSubviews]; // [macOS]
|
|
531
|
-
|
|
532
|
-
// The default behaviour of UIKit is that if a view does not contain a point,
|
|
533
|
-
// then no subviews will be returned from hit testing, even if they contain
|
|
534
|
-
// the hit point. By doing hit testing directly on the subviews, we bypass
|
|
535
|
-
// the strict containment policy (i.e., UIKit guarantees that every ancestor
|
|
536
|
-
// of the hit view will return YES from -pointInside:withEvent:). See:
|
|
537
|
-
// - https://developer.apple.com/library/ios/qa/qa2013/qa1812.html
|
|
538
|
-
for (RCTUIView *subview in [sortedSubviews reverseObjectEnumerator]) { // [macOS]
|
|
539
|
-
CGPoint pointForHitTest = CGPointZero;
|
|
540
|
-
if ([subview isKindOfClass:[RCTUIView class]]) { // [macOS]
|
|
541
|
-
pointForHitTest = [subview convertPoint:point fromView:self];
|
|
542
|
-
} else {
|
|
543
|
-
pointForHitTest = point;
|
|
544
|
-
}
|
|
545
|
-
hitSubview = (RCTUIView *)[subview hitTest:pointForHitTest]; // [macOS]
|
|
546
|
-
if (hitSubview != nil) {
|
|
547
|
-
break;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
RCTUIView *hitView = (isPointInside ? self : nil); // [macOS]
|
|
553
|
-
|
|
554
|
-
switch (_props->pointerEvents) {
|
|
555
|
-
case PointerEventsMode::None:
|
|
556
|
-
return nil;
|
|
557
|
-
case PointerEventsMode::Auto:
|
|
558
|
-
return hitSubview ?: hitView;
|
|
559
|
-
case PointerEventsMode::BoxOnly:
|
|
560
|
-
return hitView;
|
|
561
|
-
case PointerEventsMode::BoxNone:
|
|
562
|
-
return hitSubview;
|
|
563
|
-
default:
|
|
564
|
-
return hitSubview ?: hitView;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
#endif // macOS]
|
|
568
513
|
|
|
569
514
|
static RCTCornerRadii RCTCornerRadiiFromBorderRadii(BorderRadii borderRadii)
|
|
570
515
|
{
|
|
@@ -689,7 +634,7 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
|
|
|
689
634
|
RCTBorderColors borderColors = RCTCreateRCTBorderColorsFromBorderColors(borderMetrics.borderColors);
|
|
690
635
|
|
|
691
636
|
#if TARGET_OS_OSX // [macOS
|
|
692
|
-
CGFloat scaleFactor =
|
|
637
|
+
CGFloat scaleFactor = _layoutMetrics.pointScaleFactor;
|
|
693
638
|
#else
|
|
694
639
|
// On iOS setting the scaleFactor to 0.0 will default to the device's native scale factor.
|
|
695
640
|
CGFloat scaleFactor = 0.0;
|
|
@@ -714,13 +659,13 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
|
|
|
714
659
|
CGRect contentsCenter = CGRect{
|
|
715
660
|
CGPoint{imageCapInsets.left / imageSize.width, imageCapInsets.top / imageSize.height},
|
|
716
661
|
CGSize{(CGFloat)1.0 / imageSize.width, (CGFloat)1.0 / imageSize.height}};
|
|
717
|
-
|
|
662
|
+
|
|
718
663
|
#if !TARGET_OS_OSX // [macOS]
|
|
719
664
|
_borderLayer.contents = (id)image.CGImage;
|
|
720
665
|
_borderLayer.contentsScale = image.scale;
|
|
721
666
|
#else // [macOS
|
|
722
667
|
_borderLayer.contents = [image layerContentsForContentsScale:scaleFactor];
|
|
723
|
-
_borderLayer.contentsScale =
|
|
668
|
+
_borderLayer.contentsScale = scaleFactor;
|
|
724
669
|
#endif // macOS]
|
|
725
670
|
|
|
726
671
|
BOOL isResizable = !UIEdgeInsetsEqualToEdgeInsets(image.capInsets, UIEdgeInsetsZero);
|
|
@@ -660,6 +660,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithTarget : (id)target action : (SEL)act
|
|
|
660
660
|
}
|
|
661
661
|
_activeTouches.erase(touch);
|
|
662
662
|
#else // [macOS
|
|
663
|
+
_identifierPool.enqueue(activeTouch.touch.identifier);
|
|
663
664
|
_activeTouches.erase(touch.eventNumber);
|
|
664
665
|
#endif // macOS]
|
|
665
666
|
}
|
|
@@ -476,7 +476,6 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
|
|
|
476
476
|
_scrollView.delegate = self;
|
|
477
477
|
_scrollView.delaysContentTouches = NO;
|
|
478
478
|
#else // [macOS
|
|
479
|
-
_scrollView.drawsBackground = NO;
|
|
480
479
|
_scrollView.postsBoundsChangedNotifications = YES;
|
|
481
480
|
_lastScrollPosition = NSZeroPoint;
|
|
482
481
|
#endif // macOS]
|
|
@@ -413,6 +413,15 @@ static __weak RCTPlatformView *_pendingFocusView; // [macOS]
|
|
|
413
413
|
self, @selector(accessibilityValueInternal), accessibilityValue, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
+
// [macOS
|
|
417
|
+
#pragma mark - Hit testing
|
|
418
|
+
#if TARGET_OS_OSX
|
|
419
|
+
- (RCTPlatformView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
|
420
|
+
{
|
|
421
|
+
return [self hitTest:point];
|
|
422
|
+
}
|
|
423
|
+
#endif // macOS]
|
|
424
|
+
|
|
416
425
|
#pragma mark - Debug
|
|
417
426
|
- (void)react_addRecursiveDescriptionToString:(NSMutableString *)string atLevel:(NSUInteger)level
|
|
418
427
|
{
|
package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java
CHANGED
|
@@ -146,6 +146,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
|
|
146
146
|
private static final int BLUR_TEXT_INPUT = 2;
|
|
147
147
|
private static final int SET_MOST_RECENT_EVENT_COUNT = 3;
|
|
148
148
|
private static final int SET_TEXT_AND_SELECTION = 4;
|
|
149
|
+
private static final int SET_GHOST_TEXT = 5; // [macOS]
|
|
149
150
|
|
|
150
151
|
private static final int INPUT_TYPE_KEYBOARD_NUMBER_PAD = InputType.TYPE_CLASS_NUMBER;
|
|
151
152
|
private static final int INPUT_TYPE_KEYBOARD_DECIMAL_PAD =
|
|
@@ -272,7 +273,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
|
|
272
273
|
|
|
273
274
|
@Override
|
|
274
275
|
public @Nullable Map<String, Integer> getCommandsMap() {
|
|
275
|
-
return MapBuilder.of("focusTextInput", FOCUS_TEXT_INPUT, "blurTextInput", BLUR_TEXT_INPUT);
|
|
276
|
+
return MapBuilder.of("focusTextInput", FOCUS_TEXT_INPUT, "blurTextInput", BLUR_TEXT_INPUT, "setGhostText", SET_GHOST_TEXT); // [macOS]
|
|
276
277
|
}
|
|
277
278
|
|
|
278
279
|
@Override
|
|
@@ -291,6 +292,11 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
|
|
291
292
|
case SET_TEXT_AND_SELECTION:
|
|
292
293
|
this.receiveCommand(reactEditText, "setTextAndSelection", args);
|
|
293
294
|
break;
|
|
295
|
+
// [macOS
|
|
296
|
+
case SET_GHOST_TEXT:
|
|
297
|
+
this.receiveCommand(reactEditText, "setGhostText", args);
|
|
298
|
+
break;
|
|
299
|
+
// macOS]
|
|
294
300
|
}
|
|
295
301
|
}
|
|
296
302
|
|
|
@@ -325,6 +331,12 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
|
|
325
331
|
}
|
|
326
332
|
reactEditText.maybeSetSelection(mostRecentEventCount, start, end);
|
|
327
333
|
break;
|
|
334
|
+
// [macOS
|
|
335
|
+
case "setGhostText":
|
|
336
|
+
default:
|
|
337
|
+
throw new IllegalArgumentException(
|
|
338
|
+
"Unsupported command setGhostText received by ReactTextInputManager.");
|
|
339
|
+
// macOS]
|
|
328
340
|
}
|
|
329
341
|
}
|
|
330
342
|
|
|
@@ -180,6 +180,9 @@ static inline NSString *_NSStringFromCString(
|
|
|
180
180
|
static inline facebook::react::ColorComponents _ColorComponentsFromUIColor(RCTUIColor *color) // [macOS]
|
|
181
181
|
{
|
|
182
182
|
CGFloat rgba[4];
|
|
183
|
+
#if TARGET_OS_OSX // [macOS
|
|
184
|
+
color = [color colorUsingColorSpace:[NSColorSpace genericRGBColorSpace]];
|
|
185
|
+
#endif // macOS]
|
|
183
186
|
RCTGetRGBAColorComponents(color.CGColor, rgba);
|
|
184
187
|
return {(float)rgba[0], (float)rgba[1], (float)rgba[2], (float)rgba[3]};
|
|
185
188
|
}
|
|
@@ -416,9 +416,8 @@ static void RCTApplyBaselineOffset(NSMutableAttributedString *attributedText)
|
|
|
416
416
|
if (!font) {
|
|
417
417
|
return;
|
|
418
418
|
}
|
|
419
|
-
|
|
420
|
-
maximumFontLineHeight = MAX(font
|
|
421
|
-
#endif // [macOS]
|
|
419
|
+
|
|
420
|
+
maximumFontLineHeight = MAX(UIFontLineHeight(font), maximumFontLineHeight); // [macOS]
|
|
422
421
|
}];
|
|
423
422
|
|
|
424
423
|
if (maximumLineHeight < maximumFontLineHeight) {
|
package/package.json
CHANGED