react-native-macos 0.81.8 → 0.81.12
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/CHANGELOG.md +8 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +57 -1
- package/Libraries/Text/TextInput/Multiline/RCTWrappedTextView.m +26 -0
- package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +2 -0
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.mm +28 -4
- package/React/Base/RCTConvert.mm +2 -1
- package/React/Base/RCTUIKit.h +2 -0
- package/React/Base/RCTUtils.h +6 -0
- package/React/Base/RCTUtils.mm +1 -1
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/macOS/RCTUIKit.m +16 -0
- package/React/CoreModules/RCTDeviceInfo.mm +1 -1
- package/React/CxxBridge/RCTCxxBridge.mm +16 -7
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +32 -3
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm +14 -3
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +236 -8
- package/React/Fabric/Mounting/ComponentViews/VirtualView/RCTVirtualViewComponentView.mm +12 -0
- package/React/Fabric/Mounting/RCTMountingManager.mm +6 -1
- package/React/Views/RCTViewManager.m +4 -0
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactCommon/React-FabricComponents.podspec +19 -8
- package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
- package/ReactCommon/react/renderer/core/ShadowNode.cpp +29 -19
- package/ReactCommon/react/renderer/core/ShadowNodeFamily.h +2 -0
- package/ReactCommon/react/renderer/uimanager/UIManager.cpp +62 -53
- package/ReactCommon/react/renderer/uimanager/tests/FabricUIManagerTest.cpp +179 -3
- package/package.json +3 -3
- package/react-native.config.js +31 -7
package/CHANGELOG.md
ADDED
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
#endif // [macOS]
|
|
27
27
|
NSArray<NSString *> *_acceptDragAndDropTypes;
|
|
28
28
|
#if TARGET_OS_OSX // [macOS
|
|
29
|
+
BOOL _enableFocusRing;
|
|
30
|
+
BOOL _enabled;
|
|
29
31
|
NSArray<NSPasteboardType> *_readablePasteboardTypes;
|
|
30
32
|
#endif // macOS]
|
|
31
33
|
}
|
|
@@ -64,6 +66,8 @@ static RCTUIColor *defaultPlaceholderColor(void) // [macOS]
|
|
|
64
66
|
// Fix blurry text on non-retina displays.
|
|
65
67
|
self.canDrawSubviewsIntoLayer = YES;
|
|
66
68
|
self.allowsUndo = YES;
|
|
69
|
+
_enableFocusRing = YES;
|
|
70
|
+
_enabled = YES;
|
|
67
71
|
#endif // macOS]
|
|
68
72
|
|
|
69
73
|
_textInputDelegateAdapter = [[RCTBackedTextViewDelegateAdapter alloc] initWithTextView:self];
|
|
@@ -258,6 +262,58 @@ static RCTUIColor *defaultPlaceholderColor(void) // [macOS]
|
|
|
258
262
|
|
|
259
263
|
return success;
|
|
260
264
|
}
|
|
265
|
+
|
|
266
|
+
- (NSFocusRingType)focusRingType
|
|
267
|
+
{
|
|
268
|
+
return _enableFocusRing ? NSFocusRingTypeDefault : NSFocusRingTypeNone;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
- (void)setEnableFocusRing:(BOOL)enableFocusRing
|
|
272
|
+
{
|
|
273
|
+
if (_enableFocusRing != enableFocusRing) {
|
|
274
|
+
_enableFocusRing = enableFocusRing;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
[super setFocusRingType:self.focusRingType];
|
|
278
|
+
[self setKeyboardFocusRingNeedsDisplayInRect:self.bounds];
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
- (BOOL)enableFocusRing
|
|
282
|
+
{
|
|
283
|
+
return _enableFocusRing;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
- (BOOL)isEnabled
|
|
287
|
+
{
|
|
288
|
+
return _enabled;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
- (void)setEnabled:(BOOL)enabled
|
|
292
|
+
{
|
|
293
|
+
if (_enabled != enabled) {
|
|
294
|
+
_enabled = enabled;
|
|
295
|
+
|
|
296
|
+
// NSTextView has no enabled state. Behave like a disabled NSTextField: report AXEnabled = NO, refuse first
|
|
297
|
+
// responder (see -acceptsFirstResponder) and end editing if the view is focused.
|
|
298
|
+
self.accessibilityEnabled = enabled;
|
|
299
|
+
if (!enabled && self.window.firstResponder == self) {
|
|
300
|
+
[self.window makeFirstResponder:nil];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
- (BOOL)acceptsFirstResponder
|
|
306
|
+
{
|
|
307
|
+
return _enabled && [super acceptsFirstResponder];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
- (void)setAccessibilityState:(NSDictionary<NSString *, id> *)accessibilityState
|
|
311
|
+
{
|
|
312
|
+
// Paper routes `accessibilityState` to the backed text view through -[RCTBaseTextInputView reactAccessibilityElement].
|
|
313
|
+
[super setAccessibilityState:accessibilityState];
|
|
314
|
+
id disabled = accessibilityState[@"disabled"];
|
|
315
|
+
self.enabled = !([disabled isKindOfClass:[NSNumber class]] && [disabled boolValue]);
|
|
316
|
+
}
|
|
261
317
|
#endif // macOS]
|
|
262
318
|
|
|
263
319
|
- (void)setDefaultTextAttributes:(NSDictionary<NSAttributedStringKey, id> *)defaultTextAttributes
|
|
@@ -284,6 +340,7 @@ static RCTUIColor *defaultPlaceholderColor(void) // [macOS]
|
|
|
284
340
|
|
|
285
341
|
- (void)setDisableKeyboardShortcuts:(BOOL)disableKeyboardShortcuts
|
|
286
342
|
{
|
|
343
|
+
_disableKeyboardShortcuts = disableKeyboardShortcuts;
|
|
287
344
|
#if TARGET_OS_IOS
|
|
288
345
|
// Initialize the initial values only once
|
|
289
346
|
if (_initialValueLeadingBarButtonGroups == nil) {
|
|
@@ -300,7 +357,6 @@ static RCTUIColor *defaultPlaceholderColor(void) // [macOS]
|
|
|
300
357
|
self.inputAssistantItem.leadingBarButtonGroups = _initialValueLeadingBarButtonGroups;
|
|
301
358
|
self.inputAssistantItem.trailingBarButtonGroups = _initialValueTrailingBarButtonGroups;
|
|
302
359
|
}
|
|
303
|
-
_disableKeyboardShortcuts = disableKeyboardShortcuts;
|
|
304
360
|
#endif
|
|
305
361
|
}
|
|
306
362
|
|
|
@@ -49,6 +49,9 @@
|
|
|
49
49
|
_forwardingTextView.textContainer.containerSize = NSMakeSize(FLT_MAX, FLT_MAX);
|
|
50
50
|
_forwardingTextView.textContainer.widthTracksTextView = YES;
|
|
51
51
|
_forwardingTextView.textInputDelegate = self;
|
|
52
|
+
if ([_forwardingTextView respondsToSelector:@selector(setEnableFocusRing:)]) {
|
|
53
|
+
[_forwardingTextView setEnableFocusRing:YES];
|
|
54
|
+
}
|
|
52
55
|
|
|
53
56
|
_scrollView.documentView = _forwardingTextView;
|
|
54
57
|
_scrollView.contentView.postsBoundsChangedNotifications = YES;
|
|
@@ -105,6 +108,12 @@
|
|
|
105
108
|
return _forwardingTextView;
|
|
106
109
|
}
|
|
107
110
|
|
|
111
|
+
- (BOOL)canBecomeKeyView
|
|
112
|
+
{
|
|
113
|
+
// The forwarding text view is the Tab stop; this wrapper would otherwise add a second one.
|
|
114
|
+
return NO;
|
|
115
|
+
}
|
|
116
|
+
|
|
108
117
|
- (BOOL)acceptsFirstResponder
|
|
109
118
|
{
|
|
110
119
|
return _forwardingTextView.acceptsFirstResponder;
|
|
@@ -120,6 +129,16 @@
|
|
|
120
129
|
return [_forwardingTextView resignFirstResponder];
|
|
121
130
|
}
|
|
122
131
|
|
|
132
|
+
- (BOOL)isEnabled
|
|
133
|
+
{
|
|
134
|
+
return _forwardingTextView.isEnabled;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
- (void)setEnabled:(BOOL)enabled
|
|
138
|
+
{
|
|
139
|
+
_forwardingTextView.enabled = enabled;
|
|
140
|
+
}
|
|
141
|
+
|
|
123
142
|
#pragma mark -
|
|
124
143
|
#pragma mark Text Input delegate forwarding
|
|
125
144
|
|
|
@@ -197,12 +216,19 @@
|
|
|
197
216
|
|
|
198
217
|
- (BOOL)enableFocusRing
|
|
199
218
|
{
|
|
219
|
+
if ([_forwardingTextView respondsToSelector:@selector(enableFocusRing)]) {
|
|
220
|
+
return [_forwardingTextView enableFocusRing];
|
|
221
|
+
}
|
|
222
|
+
|
|
200
223
|
return _scrollView.enableFocusRing;
|
|
201
224
|
}
|
|
202
225
|
|
|
203
226
|
- (void)setEnableFocusRing:(BOOL)enableFocusRing
|
|
204
227
|
{
|
|
205
228
|
_scrollView.enableFocusRing = enableFocusRing;
|
|
229
|
+
if ([_forwardingTextView respondsToSelector:@selector(setEnableFocusRing:)]) {
|
|
230
|
+
[_forwardingTextView setEnableFocusRing:enableFocusRing];
|
|
231
|
+
}
|
|
206
232
|
}
|
|
207
233
|
|
|
208
234
|
@end
|
|
@@ -40,6 +40,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
40
40
|
@property (nonatomic, assign) BOOL textWasPasted;
|
|
41
41
|
@property (nonatomic, readonly) NSResponder *responder;
|
|
42
42
|
@property (nonatomic, assign) BOOL enableFocusRing;
|
|
43
|
+
// Driven by `accessibilityState.disabled`; `editable` only controls whether the text can be changed.
|
|
44
|
+
@property (nonatomic, assign, getter=isEnabled) BOOL enabled;
|
|
43
45
|
#endif // macOS]
|
|
44
46
|
@property (nonatomic, assign, readonly) BOOL dictationRecognizing;
|
|
45
47
|
@property (nonatomic, assign) UIEdgeInsets textContainerInset;
|
|
@@ -391,18 +391,42 @@
|
|
|
391
391
|
|
|
392
392
|
- (BOOL)isEditable
|
|
393
393
|
{
|
|
394
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
394
395
|
return self.isEnabled;
|
|
396
|
+
#else // [macOS
|
|
397
|
+
return [super isEditable];
|
|
398
|
+
#endif // macOS]
|
|
395
399
|
}
|
|
396
400
|
|
|
397
401
|
- (void)setEditable:(BOOL)editable
|
|
398
402
|
{
|
|
399
|
-
#if TARGET_OS_OSX // [macOS
|
|
400
|
-
|
|
403
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
404
|
+
self.enabled = editable;
|
|
405
|
+
#else // [macOS
|
|
406
|
+
// On macOS read-only text remains selectable and focusable, matching desktop behavior rather than iOS's disabled
|
|
407
|
+
// field. `accessibilityState.disabled` disables it; the super call sets NSTextFieldCell's editable state.
|
|
401
408
|
[super setEditable:editable];
|
|
409
|
+
self.selectable = YES;
|
|
402
410
|
#endif // macOS]
|
|
403
|
-
self.enabled = editable;
|
|
404
411
|
}
|
|
405
412
|
|
|
413
|
+
#if TARGET_OS_OSX // [macOS
|
|
414
|
+
- (BOOL)acceptsFirstResponder
|
|
415
|
+
{
|
|
416
|
+
// NSTextField refuses first responder when it is not editable, which would make read-only fields unreachable with
|
|
417
|
+
// Tab. Accept it while the field is enabled and selectable; disabled fields are skipped.
|
|
418
|
+
return self.isEnabled && self.isSelectable;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
- (void)setAccessibilityState:(NSDictionary<NSString *, id> *)accessibilityState
|
|
422
|
+
{
|
|
423
|
+
// Paper routes `accessibilityState` to the backed text field through -[RCTBaseTextInputView reactAccessibilityElement].
|
|
424
|
+
[super setAccessibilityState:accessibilityState];
|
|
425
|
+
id disabled = accessibilityState[@"disabled"];
|
|
426
|
+
self.enabled = !([disabled isKindOfClass:[NSNumber class]] && [disabled boolValue]);
|
|
427
|
+
}
|
|
428
|
+
#endif // macOS]
|
|
429
|
+
|
|
406
430
|
#if !TARGET_OS_OSX // [macOS]
|
|
407
431
|
- (void)setSecureTextEntry:(BOOL)secureTextEntry
|
|
408
432
|
{
|
|
@@ -423,6 +447,7 @@
|
|
|
423
447
|
|
|
424
448
|
- (void)setDisableKeyboardShortcuts:(BOOL)disableKeyboardShortcuts
|
|
425
449
|
{
|
|
450
|
+
_disableKeyboardShortcuts = disableKeyboardShortcuts;
|
|
426
451
|
#if TARGET_OS_IOS
|
|
427
452
|
// Initialize the initial values only once
|
|
428
453
|
if (_initialValueLeadingBarButtonGroups == nil) {
|
|
@@ -439,7 +464,6 @@
|
|
|
439
464
|
self.inputAssistantItem.leadingBarButtonGroups = _initialValueLeadingBarButtonGroups;
|
|
440
465
|
self.inputAssistantItem.trailingBarButtonGroups = _initialValueTrailingBarButtonGroups;
|
|
441
466
|
}
|
|
442
|
-
_disableKeyboardShortcuts = disableKeyboardShortcuts;
|
|
443
467
|
#endif
|
|
444
468
|
}
|
|
445
469
|
|
package/React/Base/RCTConvert.mm
CHANGED
|
@@ -1664,6 +1664,7 @@ RCT_ENUM_CONVERTER(
|
|
|
1664
1664
|
@"tab": NSAccessibilityButtonRole, // no exact match on macOS
|
|
1665
1665
|
@"tablist": NSAccessibilityTabGroupRole,
|
|
1666
1666
|
@"text": NSAccessibilityStaticTextRole, // also a legacy iOS accessibilityTraits
|
|
1667
|
+
@"textbox": NSAccessibilityTextFieldRole,
|
|
1667
1668
|
@"timer": NSAccessibilityStaticTextRole, // no exact match on macOS
|
|
1668
1669
|
@"toolbar": NSAccessibilityToolbarRole,
|
|
1669
1670
|
// Roles/traits that are macOS specific and are used by some of the core components (Lists):
|
|
@@ -1689,7 +1690,7 @@ RCT_ENUM_CONVERTER(
|
|
|
1689
1690
|
return useAriaMappings ? [RCTConvert accessibilityRoleFromAriaRole:json] : [RCTConvert accessibilityRoleFromTrait:json];
|
|
1690
1691
|
} else if ([json isKindOfClass:[NSArray class]]) {
|
|
1691
1692
|
for (NSString *trait in json) {
|
|
1692
|
-
NSString *accessibilityRole = useAriaMappings ? [RCTConvert accessibilityRoleFromAriaRole:
|
|
1693
|
+
NSString *accessibilityRole = useAriaMappings ? [RCTConvert accessibilityRoleFromAriaRole:trait] : [RCTConvert accessibilityRoleFromTrait:trait];
|
|
1693
1694
|
if (![accessibilityRole isEqualToString:NSAccessibilityUnknownRole]) {
|
|
1694
1695
|
return accessibilityRole;
|
|
1695
1696
|
}
|
package/React/Base/RCTUIKit.h
CHANGED
package/React/Base/RCTUtils.h
CHANGED
|
@@ -142,6 +142,12 @@ RCT_EXTERN NSURL *RCTDataURL(NSString *mimeType, NSData *data);
|
|
|
142
142
|
// Gzip functionality - compression level in range 0 - 1 (-1 for default)
|
|
143
143
|
RCT_EXTERN NSData *__nullable RCTGzipData(NSData *__nullable data, float level);
|
|
144
144
|
|
|
145
|
+
// [macOS
|
|
146
|
+
// Determines whether data is already gzipped. Declared here (rather than only in
|
|
147
|
+
// RCTUtils.mm) so it keeps C linkage and can be called from .m unit tests.
|
|
148
|
+
RCT_EXTERN BOOL RCTIsGzippedData(NSData *__nullable data);
|
|
149
|
+
// macOS]
|
|
150
|
+
|
|
145
151
|
// Returns the relative path within the main bundle for an absolute URL
|
|
146
152
|
// (or nil, if the URL does not specify a path within the main bundle)
|
|
147
153
|
RCT_EXTERN NSString *__nullable RCTBundlePathForURL(NSURL *__nullable URL);
|
package/React/Base/RCTUtils.mm
CHANGED
|
@@ -781,7 +781,7 @@ NSURL *RCTDataURL(NSString *mimeType, NSData *data)
|
|
|
781
781
|
[data base64EncodedStringWithOptions:(NSDataBase64EncodingOptions)0]]];
|
|
782
782
|
}
|
|
783
783
|
|
|
784
|
-
|
|
784
|
+
// [macOS] RCTUtils.h supplies C linkage for Objective-C callers.
|
|
785
785
|
BOOL RCTIsGzippedData(NSData *__nullable data)
|
|
786
786
|
{
|
|
787
787
|
UInt8 *bytes = (UInt8 *)data.bytes;
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -168,6 +168,7 @@ void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath)
|
|
|
168
168
|
BOOL _respondsToDisplayLayer;
|
|
169
169
|
CATransform3D _transform3D;
|
|
170
170
|
BOOL _hasCustomTransform3D;
|
|
171
|
+
NSEdgeInsets _lastSafeAreaInsets;
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
+ (NSSet<NSString *> *)keyPathsForValuesAffectingValueForKey:(NSString *)key
|
|
@@ -204,6 +205,15 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
204
205
|
return self;
|
|
205
206
|
}
|
|
206
207
|
|
|
208
|
+
- (void)rct_updateSafeAreaInsets
|
|
209
|
+
{
|
|
210
|
+
NSEdgeInsets insets = self.safeAreaInsets;
|
|
211
|
+
if (!NSEdgeInsetsEqual(insets, _lastSafeAreaInsets)) {
|
|
212
|
+
_lastSafeAreaInsets = insets;
|
|
213
|
+
[self safeAreaInsetsDidChange];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
207
217
|
- (instancetype)initWithFrame:(NSRect)frameRect
|
|
208
218
|
{
|
|
209
219
|
return RCTUIViewCommonInit([super initWithFrame:frameRect]);
|
|
@@ -243,6 +253,7 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
243
253
|
- (void)viewDidMoveToWindow
|
|
244
254
|
{
|
|
245
255
|
[self didMoveToWindow];
|
|
256
|
+
[self rct_updateSafeAreaInsets];
|
|
246
257
|
}
|
|
247
258
|
|
|
248
259
|
- (BOOL)mouseDownCanMoveWindow{
|
|
@@ -353,6 +364,7 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
353
364
|
{
|
|
354
365
|
[super layout];
|
|
355
366
|
if (self.window != nil) {
|
|
367
|
+
[self rct_updateSafeAreaInsets];
|
|
356
368
|
[self layoutSubviews];
|
|
357
369
|
}
|
|
358
370
|
}
|
|
@@ -425,6 +437,10 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
425
437
|
[super layout];
|
|
426
438
|
}
|
|
427
439
|
|
|
440
|
+
- (void)safeAreaInsetsDidChange
|
|
441
|
+
{
|
|
442
|
+
}
|
|
443
|
+
|
|
428
444
|
- (void)setNeedsDisplay
|
|
429
445
|
{
|
|
430
446
|
self.needsDisplay = YES;
|
|
@@ -84,7 +84,7 @@ RCT_EXPORT_MODULE()
|
|
|
84
84
|
|
|
85
85
|
_currentInterfaceDimensions = [self _exportedDimensions];
|
|
86
86
|
|
|
87
|
-
#if
|
|
87
|
+
#if TARGET_OS_IOS // [macOS] [visionOS]
|
|
88
88
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
89
89
|
selector:@selector(interfaceOrientationDidChange)
|
|
90
90
|
name:UIApplicationDidBecomeActiveNotification
|
|
@@ -1115,12 +1115,12 @@ struct RCTInstanceCallback : public InstanceCallback {
|
|
|
1115
1115
|
_valid = NO;
|
|
1116
1116
|
_moduleRegistryCreated = NO;
|
|
1117
1117
|
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1118
|
+
// [macOS
|
|
1119
|
+
// The JS thread may be waiting on the main thread to finish initializing so
|
|
1120
|
+
// we cannot call `_jsMessageThread->runOnQueueSync()` here without causing a
|
|
1121
|
+
// deadlock. We haven't upstreamed this fix because as of writing, 0.87.0-rc.0
|
|
1122
|
+
// is out and old arch is deprecated.
|
|
1123
|
+
void (^postFailToLoadNotification)(void) = ^{
|
|
1124
1124
|
self->_reactInstance.reset();
|
|
1125
1125
|
self->_jsMessageThread.reset();
|
|
1126
1126
|
|
|
@@ -1133,7 +1133,16 @@ struct RCTInstanceCallback : public InstanceCallback {
|
|
|
1133
1133
|
}
|
|
1134
1134
|
|
|
1135
1135
|
RCTFatal(error);
|
|
1136
|
-
}
|
|
1136
|
+
};
|
|
1137
|
+
|
|
1138
|
+
if (self->_jsMessageThread) {
|
|
1139
|
+
// Make sure initializeBridge completed
|
|
1140
|
+
self->_jsMessageThread->runOnQueue(
|
|
1141
|
+
[postFailToLoadNotification] { dispatch_async(dispatch_get_main_queue(), postFailToLoadNotification); });
|
|
1142
|
+
} else {
|
|
1143
|
+
dispatch_async(dispatch_get_main_queue(), postFailToLoadNotification);
|
|
1144
|
+
}
|
|
1145
|
+
// macOS]
|
|
1137
1146
|
}
|
|
1138
1147
|
|
|
1139
1148
|
RCT_NOT_IMPLEMENTED(-(instancetype)initWithDelegate
|
|
@@ -255,6 +255,20 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
255
255
|
|
|
256
256
|
#pragma mark - RCTViewComponentView overrides
|
|
257
257
|
|
|
258
|
+
#if TARGET_OS_OSX // [macOS
|
|
259
|
+
// The backed text input owns focus and accessibility; keep this host out of the key view loop to avoid a second Tab
|
|
260
|
+
// stop. `focus()` targets the backed view.
|
|
261
|
+
- (BOOL)canBecomeKeyView
|
|
262
|
+
{
|
|
263
|
+
return NO;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
- (BOOL)acceptsFirstResponder
|
|
267
|
+
{
|
|
268
|
+
return NO;
|
|
269
|
+
}
|
|
270
|
+
#endif // macOS]
|
|
271
|
+
|
|
258
272
|
- (NSObject *)accessibilityElement
|
|
259
273
|
{
|
|
260
274
|
return _backedTextInputView;
|
|
@@ -305,6 +319,13 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
305
319
|
_backedTextInputView.editable = newTextInputProps.traits.editable;
|
|
306
320
|
}
|
|
307
321
|
|
|
322
|
+
#if TARGET_OS_OSX // [macOS
|
|
323
|
+
// `accessibilityState.disabled` disables the backed text input; `editable={false}` only makes it read-only.
|
|
324
|
+
if (newTextInputProps.accessibilityState != oldTextInputProps.accessibilityState) {
|
|
325
|
+
_backedTextInputView.enabled = !newTextInputProps.accessibilityState.value_or(AccessibilityState{}).disabled;
|
|
326
|
+
}
|
|
327
|
+
#endif // macOS]
|
|
328
|
+
|
|
308
329
|
#if !TARGET_OS_OSX // [macOS]
|
|
309
330
|
if (newTextInputProps.multiline &&
|
|
310
331
|
newTextInputProps.traits.dataDetectorTypes != oldTextInputProps.traits.dataDetectorTypes) {
|
|
@@ -964,7 +985,10 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
964
985
|
[_backedTextInputView becomeFirstResponder];
|
|
965
986
|
#else // [macOS
|
|
966
987
|
NSWindow *window = [_backedTextInputView window];
|
|
967
|
-
[
|
|
988
|
+
NSResponder *responder = [_backedTextInputView respondsToSelector:@selector(responder)]
|
|
989
|
+
? _backedTextInputView.responder
|
|
990
|
+
: (NSResponder *)_backedTextInputView;
|
|
991
|
+
[window makeFirstResponder:responder];
|
|
968
992
|
#endif // macOS]
|
|
969
993
|
|
|
970
994
|
const auto &props = static_cast<const TextInputProps &>(*_props);
|
|
@@ -994,8 +1018,13 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
|
|
994
1018
|
if ([_backedTextInputView isKindOfClass:[NSTextField class]] &&
|
|
995
1019
|
[(NSTextField *)_backedTextInputView currentEditor] != nil) {
|
|
996
1020
|
[window makeFirstResponder:nil];
|
|
997
|
-
} else
|
|
998
|
-
[
|
|
1021
|
+
} else {
|
|
1022
|
+
NSResponder *responder = [_backedTextInputView respondsToSelector:@selector(responder)]
|
|
1023
|
+
? _backedTextInputView.responder
|
|
1024
|
+
: (NSResponder *)_backedTextInputView;
|
|
1025
|
+
if ([window firstResponder] == responder) {
|
|
1026
|
+
[window makeFirstResponder:nil];
|
|
1027
|
+
}
|
|
999
1028
|
}
|
|
1000
1029
|
#endif // macOS]
|
|
1001
1030
|
}
|
|
@@ -33,8 +33,12 @@ void RCTCopyBackedTextInput(
|
|
|
33
33
|
toTextInput.accessibilityHelp = fromTextInput.accessibilityHelp;
|
|
34
34
|
toTextInput.accessibilityIdentifier = fromTextInput.accessibilityIdentifier;
|
|
35
35
|
toTextInput.accessibilityLabel = fromTextInput.accessibilityLabel;
|
|
36
|
-
|
|
36
|
+
// An unset role reads back as NSAccessibilityUnknownRole; copying it would hide the new view's default role.
|
|
37
|
+
if (![fromTextInput.accessibilityRole isEqualToString:NSAccessibilityUnknownRole]) {
|
|
38
|
+
toTextInput.accessibilityRole = fromTextInput.accessibilityRole;
|
|
39
|
+
}
|
|
37
40
|
toTextInput.autoresizingMask = fromTextInput.autoresizingMask;
|
|
41
|
+
toTextInput.enabled = fromTextInput.enabled;
|
|
38
42
|
#endif // macOS]
|
|
39
43
|
#if TARGET_OS_IOS // [macOS] [visionOS]
|
|
40
44
|
toTextInput.inputAccessoryView = fromTextInput.inputAccessoryView;
|
|
@@ -58,16 +62,23 @@ void RCTCopyBackedTextInput(
|
|
|
58
62
|
toTextInput.clearButtonMode = fromTextInput.clearButtonMode;
|
|
59
63
|
#endif // [macOS]
|
|
60
64
|
toTextInput.scrollEnabled = fromTextInput.scrollEnabled;
|
|
65
|
+
toTextInput.disableKeyboardShortcuts = fromTextInput.disableKeyboardShortcuts;
|
|
66
|
+
toTextInput.acceptDragAndDropTypes = fromTextInput.acceptDragAndDropTypes;
|
|
61
67
|
#if !TARGET_OS_OSX // [macOS]
|
|
62
68
|
toTextInput.secureTextEntry = fromTextInput.secureTextEntry;
|
|
63
69
|
toTextInput.keyboardType = fromTextInput.keyboardType;
|
|
64
70
|
toTextInput.textContentType = fromTextInput.textContentType;
|
|
65
71
|
toTextInput.smartInsertDeleteType = fromTextInput.smartInsertDeleteType;
|
|
66
72
|
toTextInput.passwordRules = fromTextInput.passwordRules;
|
|
67
|
-
toTextInput.disableKeyboardShortcuts = fromTextInput.disableKeyboardShortcuts;
|
|
68
|
-
toTextInput.acceptDragAndDropTypes = fromTextInput.acceptDragAndDropTypes;
|
|
69
73
|
|
|
70
74
|
[toTextInput setSelectedTextRange:fromTextInput.selectedTextRange notifyDelegate:NO];
|
|
75
|
+
#else // [macOS]
|
|
76
|
+
toTextInput.enableFocusRing = fromTextInput.enableFocusRing;
|
|
77
|
+
toTextInput.pointScaleFactor = fromTextInput.pointScaleFactor;
|
|
78
|
+
toTextInput.automaticSpellingCorrectionEnabled = fromTextInput.automaticSpellingCorrectionEnabled;
|
|
79
|
+
toTextInput.grammarCheckingEnabled = fromTextInput.grammarCheckingEnabled;
|
|
80
|
+
toTextInput.continuousSpellCheckingEnabled = fromTextInput.continuousSpellCheckingEnabled;
|
|
81
|
+
[toTextInput setSelectedTextRange:[fromTextInput selectedTextRange] notifyDelegate:NO];
|
|
71
82
|
#endif // [macOS]
|
|
72
83
|
}
|
|
73
84
|
|