react-native-macos 0.0.0-b9fb2dd1a → 0.0.0-bc0c2c4d1

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.
Files changed (100) hide show
  1. package/Libraries/Components/ScrollView/ScrollView.js +11 -45
  2. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  3. package/Libraries/Components/TextInput/TextInput.js +79 -1
  4. package/Libraries/Components/View/ReactNativeStyleAttributes.js +1 -0
  5. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  6. package/Libraries/Components/View/ReactNativeViewViewConfig.js +1 -0
  7. package/Libraries/Components/View/ReactNativeViewViewConfigMacOS.js +3 -3
  8. package/Libraries/Components/View/ViewPropTypes.js +10 -6
  9. package/Libraries/Core/ReactNativeVersion.js +1 -1
  10. package/Libraries/Image/RCTImageView.mm +14 -10
  11. package/Libraries/LinkingIOS/RCTLinkingManager.h +1 -0
  12. package/Libraries/LinkingIOS/macos/RCTLinkingManager.mm +12 -5
  13. package/Libraries/Lists/FlatList.js +25 -1
  14. package/Libraries/Lists/VirtualizedList.js +118 -113
  15. package/Libraries/Lists/VirtualizedSectionList.js +9 -5
  16. package/Libraries/StyleSheet/StyleSheetTypes.js +25 -0
  17. package/Libraries/Text/BaseText/RCTBaseTextViewManager.m +1 -0
  18. package/Libraries/Text/RCTTextAttributes.h +2 -0
  19. package/Libraries/Text/RCTTextAttributes.m +14 -5
  20. package/Libraries/Text/Text/RCTDynamicTypeRamp.h +40 -0
  21. package/Libraries/Text/Text/RCTDynamicTypeRamp.m +77 -0
  22. package/Libraries/Text/Text/RCTTextView.m +118 -47
  23. package/Libraries/Text/Text.js +0 -8
  24. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.h +8 -0
  25. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.m +57 -2
  26. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.m +13 -0
  27. package/Libraries/Text/TextInput/Multiline/RCTUITextView.h +2 -1
  28. package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +69 -2
  29. package/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +7 -1
  30. package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +12 -3
  31. package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +1 -0
  32. package/Libraries/Text/TextInput/RCTBaseTextInputView.h +4 -1
  33. package/Libraries/Text/TextInput/RCTBaseTextInputView.m +97 -2
  34. package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +6 -1
  35. package/Libraries/Text/TextInput/Singleline/RCTUITextField.m +40 -0
  36. package/Libraries/Text/TextNativeComponent.js +2 -0
  37. package/Libraries/Text/TextProps.js +29 -0
  38. package/Libraries/Types/CoreEventTypes.js +0 -1
  39. package/React/Base/RCTAssert.h +4 -3
  40. package/React/Base/RCTAssert.m +11 -2
  41. package/React/Base/RCTBridge.m +1 -1
  42. package/React/Base/RCTConstants.h +6 -0
  43. package/React/Base/RCTConstants.m +15 -0
  44. package/React/Base/RCTConvert.m +8 -4
  45. package/React/Base/RCTTouchHandler.m +4 -0
  46. package/React/Base/RCTUIKit.h +8 -13
  47. package/React/Base/RCTUtils.m +6 -3
  48. package/React/Base/RCTVersion.m +1 -1
  49. package/React/Base/macOS/RCTUIKit.m +40 -0
  50. package/React/CoreModules/RCTPerfMonitor.mm +1 -1
  51. package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +6 -2
  52. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +1 -1
  53. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +17 -3
  54. package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +8 -1
  55. package/React/Fabric/Mounting/RCTMountingManager.h +1 -1
  56. package/React/Fabric/Mounting/RCTMountingManager.mm +3 -3
  57. package/React/Fabric/RCTConversions.h +9 -1
  58. package/React/Fabric/RCTLocalizationProvider.mm +10 -4
  59. package/React/Fabric/RCTScheduler.h +5 -0
  60. package/React/Fabric/RCTScheduler.mm +10 -0
  61. package/React/Fabric/RCTSurfacePresenter.h +2 -0
  62. package/React/Fabric/RCTSurfacePresenter.mm +12 -11
  63. package/React/Fabric/RCTSurfaceTouchHandler.mm +0 -1
  64. package/React/Modules/RCTUIManager.m +2 -1
  65. package/React/React-RCTFabric.podspec +1 -1
  66. package/React/Views/RCTActivityIndicatorView.m +2 -1
  67. package/React/Views/RCTCursor.h +39 -0
  68. package/React/Views/RCTCursor.m +105 -0
  69. package/React/Views/RCTView.h +12 -0
  70. package/React/Views/RCTView.m +116 -43
  71. package/React/Views/RCTViewKeyboardEvent.m +9 -1
  72. package/React/Views/RCTViewManager.m +18 -13
  73. package/React/Views/ScrollView/RCTScrollContentView.h +4 -0
  74. package/React/Views/ScrollView/RCTScrollContentView.m +18 -0
  75. package/React/Views/ScrollView/RCTScrollContentViewManager.m +2 -0
  76. package/React/Views/ScrollView/RCTScrollView.h +2 -1
  77. package/React/Views/ScrollView/RCTScrollView.m +70 -63
  78. package/React/Views/ScrollView/RCTScrollViewManager.m +1 -1
  79. package/React/Views/UIView+React.h +2 -0
  80. package/React/Views/UIView+React.m +22 -13
  81. package/ReactAndroid/gradle.properties +1 -1
  82. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  83. package/ReactCommon/React-Fabric.podspec +1 -1
  84. package/ReactCommon/React-rncore.podspec +1 -1
  85. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  86. package/ReactCommon/react/renderer/core/EventDispatcher.cpp +21 -0
  87. package/ReactCommon/react/renderer/core/EventDispatcher.h +15 -0
  88. package/ReactCommon/react/renderer/core/EventListener.cpp +39 -0
  89. package/ReactCommon/react/renderer/core/EventListener.h +44 -0
  90. package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
  91. package/ReactCommon/react/renderer/scheduler/Scheduler.cpp +14 -0
  92. package/ReactCommon/react/renderer/scheduler/Scheduler.h +6 -0
  93. package/ReactCommon/react/utils/ManagedObjectWrapper.h +1 -1
  94. package/ReactCommon/react/utils/ManagedObjectWrapper.mm +1 -3
  95. package/package.json +1 -1
  96. package/scripts/generate-artifacts.js +21 -17
  97. package/scripts/react_native_pods.rb +0 -3
  98. package/template/Gemfile.lock +7 -7
  99. package/template/package.json +1 -1
  100. package/third-party-podspecs/boost-for-react-native.podspec +0 -20
@@ -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 initWithFrame:CGRectZero]) {
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)
@@ -423,6 +430,46 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
423
430
  _onGrammarCheckChange(@{@"enabled": [NSNumber numberWithBool:enabled]});
424
431
  }
425
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
+ }
426
473
  #endif // ]TODO(macOS GH#774)
427
474
 
428
475
  - (BOOL)textInputShouldReturn
@@ -589,6 +636,35 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
589
636
  return YES;
590
637
  }
591
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
+
592
668
  - (void)textInputDidCancel {
593
669
  [_eventDispatcher sendTextEventWithType:RCTTextEventTypeKeyPress
594
670
  reactTag:self.reactTag
@@ -597,6 +673,25 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
597
673
  eventCount:_nativeEventCount];
598
674
  [self textInputDidEndEditing];
599
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
+ }
600
695
  #endif // ]TODO(macOS GH#774)
601
696
 
602
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)
@@ -71,12 +70,18 @@ RCT_EXPORT_VIEW_PROPERTY(passwordRules, NSString)
71
70
  RCT_EXPORT_VIEW_PROPERTY(onAutoCorrectChange, RCTBubblingEventBlock);
72
71
  RCT_EXPORT_VIEW_PROPERTY(onSpellCheckChange, RCTBubblingEventBlock);
73
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 *>);
74
78
  #endif // TODO(macOS GH#774)
75
79
 
76
80
  RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
77
81
  RCT_EXPORT_VIEW_PROPERTY(onKeyPressSync, RCTDirectEventBlock)
78
82
  RCT_EXPORT_VIEW_PROPERTY(onChangeSync, RCTDirectEventBlock)
79
83
  RCT_EXPORT_VIEW_PROPERTY(onSelectionChange, RCTDirectEventBlock)
84
+ RCT_EXPORT_VIEW_PROPERTY(onPaste, RCTDirectEventBlock)
80
85
  RCT_EXPORT_VIEW_PROPERTY(onTextInput, RCTDirectEventBlock)
81
86
  RCT_EXPORT_VIEW_PROPERTY(onScroll, RCTDirectEventBlock)
82
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
  |}>;
@@ -133,7 +133,6 @@ export type ScrollEvent = SyntheticEvent<
133
133
  |}>,
134
134
  zoomScale?: number,
135
135
  responderIgnoreScroll?: boolean,
136
- key?: string, // TODO(macOS GH#774)
137
136
  preferredScrollerStyle?: string, // TODO(macOS GH#774)
138
137
  |}>,
139
138
  >;
@@ -183,7 +183,8 @@ __attribute__((used)) RCT_EXTERN void RCTEnableNewArchitectureViolationReporting
183
183
 
184
184
  // When reporting is enabled, trigger an assertion.
185
185
  __attribute__((used)) RCT_EXTERN void RCTEnforceNotAllowedForNewArchitecture(id context, NSString *extra);
186
-
187
- // When reporting is enabled, warn about the violation. Use this to prepare a specific callsite
186
+ // When reporting is enabled, trigger an error but do not crash. Use this to prepare a specific callsite
188
187
  // for stricter enforcement. When ready, switch it to use the variant above.
189
- __attribute__((used)) RCT_EXTERN void RCTWarnNotAllowedForNewArchitecture(id context, NSString *extra);
188
+ __attribute__((used)) RCT_EXTERN void RCTErrorNotAllowedForNewArchitecture(id context, NSString *extra);
189
+ // When reporting is enabled, log an message. When ready, switch it to use the variant above.
190
+ __attribute__((used)) RCT_EXTERN void RCTLogNotAllowedForNewArchitecture(id context, NSString *extra);
@@ -274,11 +274,20 @@ void RCTEnforceNotAllowedForNewArchitecture(id context, NSString *extra)
274
274
  RCTAssert(0, @"%@", getNewArchitectureViolationMessage(context, extra));
275
275
  }
276
276
 
277
- void RCTWarnNotAllowedForNewArchitecture(id context, NSString *extra)
277
+ void RCTErrorNotAllowedForNewArchitecture(id context, NSString *extra)
278
278
  {
279
279
  if (!newArchitectureViolationReporting) {
280
280
  return;
281
281
  }
282
282
 
283
- RCTLogWarn(@"%@", getNewArchitectureViolationMessage(context, extra));
283
+ RCTLogError(@"%@", getNewArchitectureViolationMessage(context, extra));
284
+ }
285
+
286
+ void RCTLogNotAllowedForNewArchitecture(id context, NSString *extra)
287
+ {
288
+ if (!newArchitectureViolationReporting) {
289
+ return;
290
+ }
291
+
292
+ RCTLogInfo(@"%@", getNewArchitectureViolationMessage(context, extra));
284
293
  }
@@ -60,7 +60,7 @@ NSArray<Class> *RCTGetModuleClasses(void)
60
60
  void RCTRegisterModule(Class);
61
61
  void RCTRegisterModule(Class moduleClass)
62
62
  {
63
- RCTWarnNotAllowedForNewArchitecture(
63
+ RCTLogNotAllowedForNewArchitecture(
64
64
  @"RCTRegisterModule()", [NSString stringWithFormat:@"'%@' was registered unexpectedly", moduleClass]);
65
65
 
66
66
  static dispatch_once_t onceToken;
@@ -15,3 +15,9 @@ RCT_EXTERN NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollec
15
15
  */
16
16
  RCT_EXTERN BOOL RCTExperimentGetPreemptiveViewAllocationDisabled(void);
17
17
  RCT_EXTERN void RCTExperimentSetPreemptiveViewAllocationDisabled(BOOL value);
18
+
19
+ /*
20
+ * W3C Pointer Events
21
+ */
22
+ RCT_EXTERN BOOL RCTGetDispatchW3CPointerEvents(void);
23
+ RCT_EXTERN void RCTSetDispatchW3CPointerEvents(BOOL value);
@@ -24,3 +24,18 @@ void RCTExperimentSetPreemptiveViewAllocationDisabled(BOOL value)
24
24
  {
25
25
  RCTExperimentPreemptiveViewAllocationDisabled = value;
26
26
  }
27
+
28
+ /*
29
+ * W3C Pointer Events
30
+ */
31
+ static BOOL RCTDispatchW3CPointerEvents = NO;
32
+
33
+ BOOL RCTGetDispatchW3CPointerEvents()
34
+ {
35
+ return RCTDispatchW3CPointerEvents;
36
+ }
37
+
38
+ void RCTSetDispatchW3CPointerEvents(BOOL value)
39
+ {
40
+ RCTDispatchW3CPointerEvents = value;
41
+ }
@@ -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 *mutablePastboardTypes = [NSMutableArray new];
1250
+ NSMutableArray *mutablePasteboardTypes = [NSMutableArray new];
1248
1251
  for (NSString *type in json) {
1249
- [mutablePastboardTypes addObjectsFromArray:[RCTConvert NSPasteboardType:type]];
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
 
@@ -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
  }
@@ -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];
@@ -905,9 +905,12 @@ UIImage *__nullable RCTImageFromLocalAssetURL(NSURL *imageURL)
905
905
  }
906
906
  #if !TARGET_OS_OSX // TODO(macOS GH#774)
907
907
  image = [UIImage imageWithContentsOfFile:filePath];
908
- #else // TODO(macOS GH#774)
909
- image = [[NSImage alloc] initWithContentsOfFile:filePath]; // TODO(macOS GH#774)
910
- #endif // TODO(macOS GH#774)
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)
911
914
  }
912
915
  }
913
916
 
@@ -28,7 +28,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
28
28
  RCTVersionMajor: @(0),
29
29
  RCTVersionMinor: @(0),
30
30
  RCTVersionPatch: @(0),
31
- RCTVersionPrerelease: @"b9fb2dd1a",
31
+ RCTVersionPrerelease: @"bc0c2c4d1",
32
32
  };
33
33
  });
34
34
  return __rnVersion;
@@ -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
@@ -176,7 +176,7 @@ RCT_EXPORT_MODULE()
176
176
  {
177
177
  if (!_devMenuItem) {
178
178
  __weak __typeof__(self) weakSelf = self;
179
- __weak RCTDevSettings *devSettings = [self->_moduleRegistry moduleForName:"DevSettings"];
179
+ __weak RCTDevSettings *devSettings = [[self bridge] devSettings]; // TODO(macOS GH#774)
180
180
  if (devSettings.isPerfMonitorShown) {
181
181
  [weakSelf show];
182
182
  }
@@ -29,8 +29,6 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
29
29
  - (instancetype)initWithFrame:(CGRect)frame
30
30
  {
31
31
  if (self = [super initWithFrame:frame]) {
32
- RCTWarnNotAllowedForNewArchitecture(
33
- self, @"ViewManager with interop layer is not allowed in the new architecture.");
34
32
  static const auto defaultProps = std::make_shared<const LegacyViewManagerInteropViewProps>();
35
33
  _props = defaultProps;
36
34
  _viewsToBeMounted = [NSMutableArray new];
@@ -67,6 +65,12 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
67
65
 
68
66
  + (BOOL)isSupported:(NSString *)componentName
69
67
  {
68
+ RCTLogNotAllowedForNewArchitecture(
69
+ self,
70
+ [NSString
71
+ stringWithFormat:
72
+ @"Legacy ViewManagers should be migrated to Fabric ComponentViews in the new architecture to reduce risk. Component using interop layer: %@",
73
+ componentName]);
70
74
  return [[RCTLegacyViewManagerInteropComponentView supportedViewManagers] containsObject:componentName];
71
75
  }
72
76
 
@@ -25,7 +25,7 @@ using namespace facebook::react;
25
25
 
26
26
  @implementation RCTPullToRefreshViewComponentView {
27
27
  UIRefreshControl *_refreshControl;
28
- RCTScrollViewComponentView *_scrollViewComponentView;
28
+ RCTScrollViewComponentView *__weak _scrollViewComponentView;
29
29
  }
30
30
 
31
31
  - (instancetype)initWithFrame:(CGRect)frame