react-native-macos 0.81.4 → 0.81.6

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 (45) hide show
  1. package/Libraries/Components/Pressable/Pressable.js +8 -1
  2. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +16 -0
  3. package/Libraries/Components/TextInput/TextInput.js +26 -9
  4. package/Libraries/Components/View/View.js +30 -10
  5. package/Libraries/Core/ReactNativeVersion.js +1 -1
  6. package/Libraries/LinkingIOS/RCTLinkingManager.mm +119 -0
  7. package/Libraries/LinkingIOS/React-RCTLinking.podspec +0 -4
  8. package/Libraries/Text/RCTTextAttributes.mm +1 -1
  9. package/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +1 -1
  10. package/Libraries/Text/TextInput/RCTBaseTextInputView.mm +1 -1
  11. package/Libraries/Utilities/normalizeLegacyHandledKeyEvents.js +164 -0
  12. package/React/Base/RCTRootView.m +7 -0
  13. package/React/Base/RCTUIKit.h +18 -7
  14. package/React/Base/RCTVersion.m +1 -1
  15. package/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm +9 -0
  16. package/React/Base/macOS/RCTUIKit.m +65 -8
  17. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.h +6 -0
  18. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm +77 -1
  19. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h +4 -0
  20. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +93 -3
  21. package/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm +306 -8
  22. package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +6 -0
  23. package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +26 -18
  24. package/React/Modules/RCTUIManager.mm +1 -1
  25. package/React/Views/RCTCursor.m +0 -1
  26. package/React/Views/RCTView.m +1 -2
  27. package/React/Views/ScrollView/RCTScrollView.m +25 -0
  28. package/React/Views/UIView+React.m +1 -1
  29. package/ReactAndroid/gradle.properties +1 -1
  30. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
  31. package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
  32. package/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp +1 -1
  33. package/ReactCommon/react/renderer/graphics/Color.h +1 -0
  34. package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h +10 -0
  35. package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm +83 -6
  36. package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/PlatformColorParser.mm +18 -0
  37. package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/RCTPlatformColorUtils.mm +144 -3
  38. package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm +1 -1
  39. package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.h +2 -2
  40. package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm +3 -3
  41. package/local-cli/generate-macos.js +0 -3
  42. package/local-cli/generator-common/index.js +5 -5
  43. package/local-cli/generator-macos/index.js +7 -22
  44. package/package.json +2 -2
  45. package/Libraries/LinkingIOS/macos/RCTLinkingManager.mm +0 -123
@@ -64,9 +64,9 @@ UIKIT_STATIC_INLINE void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath
64
64
  #define RCTUIImage UIImage
65
65
  #define RCTUIPanGestureRecognizer UIPanGestureRecognizer
66
66
 
67
- UIKIT_STATIC_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, __unused UIEvent *__nullable event)
67
+ UIKIT_STATIC_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, RCTPlatformView *fromView, __unused UIEvent *__nullable event)
68
68
  {
69
- return [view hitTest:point withEvent:event];
69
+ return [view hitTest:[view convertPoint:point fromView:fromView] withEvent:event];
70
70
  }
71
71
 
72
72
  UIKIT_STATIC_INLINE void RCTUIViewSetContentModeRedraw(UIView *view)
@@ -98,6 +98,7 @@ UIKIT_STATIC_INLINE CGRect CGRectValue(NSValue *value)
98
98
  // semantically equivalent types
99
99
  //
100
100
 
101
+ #define RCTPlatformColor UIColor
101
102
  #define RCTUIColor UIColor
102
103
 
103
104
  // [macOS RCTUIAccessibilityTraits - typedef to UIAccessibilityTraits on iOS
@@ -376,8 +377,15 @@ NS_INLINE NSAccessibilityRole RCTAccessibilityRoleFromTraits(RCTUIAccessibilityT
376
377
  // macOS]
377
378
 
378
379
  // UIColor.h/NSColor.h
380
+ #define RCTPlatformColor NSColor
379
381
  #define RCTUIColor NSColor
380
382
 
383
+ @interface NSColor (RCTAppearanceResolving)
384
+ /// Resolve a dynamic/semantic NSColor for a specific appearance, analogous to
385
+ /// UIColor's -resolvedColorWithTraitCollection: on iOS.
386
+ - (NSColor *)resolvedColorWithAppearance:(NSAppearance *)appearance;
387
+ @end
388
+
381
389
  // UIFont.h/NSFont.h
382
390
  // Both NSFont and UIFont are toll-free bridged to CTFontRef so we'll assume they're semantically equivalent
383
391
  @compatibility_alias UIFont NSFont;
@@ -514,6 +522,7 @@ void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath);
514
522
 
515
523
  @property (nonatomic, copy) NSColor *backgroundColor;
516
524
  @property (nonatomic) CGAffineTransform transform;
525
+ @property (nonatomic) CATransform3D transform3D;
517
526
 
518
527
  /**
519
528
  * Specifies whether the view should receive the mouse down event when the
@@ -533,12 +542,10 @@ void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath);
533
542
  */
534
543
  @property (nonatomic, assign) BOOL enableFocusRing;
535
544
 
536
- // [macOS
537
545
  /**
538
546
  * iOS compatibility shim. On macOS, this forwards to accessibilityChildren.
539
547
  */
540
548
  @property (nonatomic, copy) NSArray *accessibilityElements;
541
- // macOS]
542
549
 
543
550
  @end
544
551
 
@@ -585,11 +592,15 @@ void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath);
585
592
  @end
586
593
 
587
594
 
588
- NS_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, __unused UIEvent *__nullable event)
595
+ // Use CALayer coordinate conversion which correctly accounts for layer.transform.
596
+ // NSView's convertPoint:fromView: does not account for layer transforms on macOS.
597
+ // IMPORTANT -- NSView's hitTest: expects a point in the superview's coordinate space,
598
+ // so we convert from fromView → superview using CALayer, which handles layer transforms correctly.
599
+ // This allows hit testing to work correctly between nested RCTUIViews and plain NSViews.
600
+ NS_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, RCTPlatformView *fromView, __unused UIEvent *__nullable event)
589
601
  {
590
- // [macOS IMPORTANT -- point is in local coordinate space, but OSX expects super coordinate space for hitTest:
591
602
  NSView *superview = [view superview];
592
- NSPoint pointInSuperview = superview != nil ? [view convertPoint:point toView:superview] : point;
603
+ NSPoint pointInSuperview = superview != nil ? [superview.layer convertPoint:point fromLayer:fromView.layer] : point;
593
604
  return [view hitTest:pointInSuperview];
594
605
  }
595
606
 
@@ -23,7 +23,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
23
23
  __rnVersion = @{
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(81),
26
- RCTVersionPatch: @(4),
26
+ RCTVersionPatch: @(6),
27
27
  RCTVersionPrerelease: [NSNull null],
28
28
  };
29
29
  });
@@ -144,6 +144,15 @@ RCT_NOT_IMPLEMENTED(-(nullable instancetype)initWithCoder : (NSCoder *)coder)
144
144
  _autoHideDisabled = disabled;
145
145
  }
146
146
 
147
+ #pragma mark - NSView
148
+
149
+ #if TARGET_OS_OSX // [macOS
150
+ - (void)viewDidEndLiveResize {
151
+ [super viewDidEndLiveResize];
152
+ [self setNeedsLayout];
153
+ }
154
+ #endif // macOS]
155
+
147
156
  #pragma mark - isActivityIndicatorViewVisible
148
157
 
149
158
  - (void)setIsActivityIndicatorViewVisible:(BOOL)visible
@@ -9,6 +9,7 @@
9
9
 
10
10
  #if TARGET_OS_OSX
11
11
 
12
+ #import <QuartzCore/QuartzCore.h>
12
13
  #import <React/RCTUIKit.h>
13
14
 
14
15
  #import <React/RCTAssert.h>
@@ -165,6 +166,8 @@ void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath)
165
166
  BOOL _userInteractionEnabled;
166
167
  BOOL _mouseDownCanMoveWindow;
167
168
  BOOL _respondsToDisplayLayer;
169
+ CATransform3D _transform3D;
170
+ BOOL _hasCustomTransform3D;
168
171
  }
169
172
 
170
173
  + (NSSet<NSString *> *)keyPathsForValuesAffectingValueForKey:(NSString *)key
@@ -195,6 +198,8 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
195
198
  self->_enableFocusRing = YES;
196
199
  self->_mouseDownCanMoveWindow = YES;
197
200
  self->_respondsToDisplayLayer = [self respondsToSelector:@selector(displayLayer:)];
201
+ self->_transform3D = CATransform3DIdentity;
202
+ self->_hasCustomTransform3D = NO;
198
203
  }
199
204
  return self;
200
205
  }
@@ -271,20 +276,46 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
271
276
 
272
277
  - (void)setTransform:(CGAffineTransform)transform
273
278
  {
274
- self.layer.affineTransform = transform;
279
+ self.transform3D = CATransform3DMakeAffineTransform(transform);
280
+ }
281
+
282
+ - (CATransform3D)transform3D
283
+ {
284
+ return _transform3D;
285
+ }
286
+
287
+ - (void)setTransform3D:(CATransform3D)transform3D
288
+ {
289
+ // On macOS, layer.anchorPoint defaults to {0, 0} instead of {0.5, 0.5} on iOS.
290
+ // Compensate so transforms are applied from the view's center as expected.
291
+ CGPoint anchorPoint = self.layer.anchorPoint;
292
+ if (CGPointEqualToPoint(anchorPoint, CGPointZero) && !CATransform3DEqualToTransform(transform3D, CATransform3DIdentity)) {
293
+ CATransform3D originAdjust = CATransform3DTranslate(CATransform3DIdentity, self.frame.size.width / 2, self.frame.size.height / 2, 0);
294
+ transform3D = CATransform3DConcat(CATransform3DConcat(CATransform3DInvert(originAdjust), transform3D), originAdjust);
295
+ }
296
+
297
+ _transform3D = transform3D;
298
+ _hasCustomTransform3D = !CATransform3DEqualToTransform(transform3D, CATransform3DIdentity);
299
+ self.layer.transform = transform3D;
275
300
  }
276
301
 
277
302
  - (NSView *)hitTest:(NSPoint)point
278
303
  {
279
- // IMPORTANT point is passed in super coordinates by OSX, but expected to be passed in local coordinates
280
- NSView *superview = [self superview];
281
- NSPoint pointInSelf = superview != nil ? [self convertPoint:point fromView:superview] : point;
282
- return [self hitTest:pointInSelf withEvent:nil];
304
+ // NSView's hitTest: receives a point in superview coordinates. Convert to local
305
+ // coordinates using CALayer, which correctly accounts for layer.transform.
306
+ // NSView's convertPoint:fromView: does NOT account for layer transforms.
307
+ CGPoint localPoint;
308
+ if (self.layer.superlayer) {
309
+ localPoint = [self.layer convertPoint:point fromLayer:self.layer.superlayer];
310
+ } else {
311
+ localPoint = point;
312
+ }
313
+ return [self hitTest:localPoint withEvent:nil];
283
314
  }
284
315
 
285
316
  - (BOOL)wantsUpdateLayer
286
317
  {
287
- return [self respondsToSelector:@selector(displayLayer:)];
318
+ return _respondsToDisplayLayer || _hasCustomTransform3D;
288
319
  }
289
320
 
290
321
  - (void)updateLayer
@@ -297,8 +328,13 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
297
328
  [layer setBackgroundColor:[_backgroundColor CGColor]];
298
329
  }
299
330
 
300
- // In Fabric, wantsUpdateLayer is always enabled and doesn't guarantee that
301
- // the instance has a displayLayer method.
331
+ // On macOS, AppKit's layer-backed view system resets layer.transform to identity
332
+ // during its layout/display cycle because NSView has no built-in transform property
333
+ // (unlike UIView on iOS). We must re-apply the stored transform after each cycle.
334
+ if (_hasCustomTransform3D && !CATransform3DEqualToTransform(layer.transform, _transform3D)) {
335
+ layer.transform = _transform3D;
336
+ }
337
+
302
338
  if (_respondsToDisplayLayer) {
303
339
  [(id<CALayerDelegate>)self displayLayer:layer];
304
340
  }
@@ -905,4 +941,25 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
905
941
 
906
942
  @end
907
943
 
944
+ // NSColor (RCTAppearanceResolving)
945
+
946
+ @implementation NSColor (RCTAppearanceResolving)
947
+
948
+ - (NSColor *)resolvedColorWithAppearance:(NSAppearance *)appearance
949
+ {
950
+ __block NSColor *resolved = self;
951
+ [appearance performAsCurrentDrawingAppearance:^{
952
+ CGColorRef cgColor = self.CGColor;
953
+ if (cgColor) {
954
+ NSColor *fromCG = [NSColor colorWithCGColor:cgColor];
955
+ if (fromCG) {
956
+ resolved = fromCG;
957
+ }
958
+ }
959
+ }];
960
+ return resolved;
961
+ }
962
+
963
+ @end
964
+
908
965
  #endif
@@ -52,6 +52,12 @@ NS_ASSUME_NONNULL_BEGIN
52
52
  @property (nonatomic, assign) BOOL snapToEnd;
53
53
  @property (nonatomic, copy) NSArray<NSNumber *> *snapToOffsets;
54
54
 
55
+ #if TARGET_OS_OSX // [macOS
56
+ - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;
57
+ - (void)zoomToRect:(CGRect)rect animated:(BOOL)animated;
58
+ - (void)flashScrollIndicators;
59
+ #endif // macOS]
60
+
55
61
  /*
56
62
  * Makes `setContentOffset:` method no-op when given `block` is executed.
57
63
  * The block is being executed synchronously.
@@ -41,7 +41,16 @@
41
41
  // because this attribute affects a position of vertical scrollbar; we don't want this
42
42
  // scrollbar flip because we also flip it with whole `UIScrollView` flip.
43
43
  self.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
44
- #endif // [macOS]
44
+ #else // [macOS
45
+ // Similar to iOS's contentInsetAdjustmentBehavior fix
46
+ // For example: When using NSWindowStyleMaskFullSizeContentView (hidden title bar) and ScrollView as root,
47
+ // NSScrollView.automaticallyAdjustsContentInsets (default YES) adds contentInset.top to push content below the toolbar.
48
+ // However, React Native doesn't know about this native contentInset adjustments,causing some caltulation issues
49
+ self.automaticallyAdjustsContentInsets = NO;
50
+ self.hasHorizontalScroller = YES;
51
+ self.hasVerticalScroller = YES;
52
+ self.autohidesScrollers = YES;
53
+ #endif // macOS]
45
54
 
46
55
  __weak __typeof(self) weakSelf = self;
47
56
  _delegateSplitter = [[RCTGenericDelegateSplitter alloc] initWithDelegateUpdateBlock:^(id delegate) {
@@ -98,16 +107,83 @@
98
107
  if (_isSetContentOffsetDisabled) {
99
108
  return;
100
109
  }
110
+ #if !TARGET_OS_OSX // [macOS]
101
111
  super.contentOffset = CGPointMake(
102
112
  RCTSanitizeNaNValue(contentOffset.x, @"scrollView.contentOffset.x"),
103
113
  RCTSanitizeNaNValue(contentOffset.y, @"scrollView.contentOffset.y"));
114
+ #else // [macOS
115
+ if (!NSEqualPoints(contentOffset, self.documentVisibleRect.origin)) {
116
+ [self.contentView scrollToPoint:contentOffset];
117
+ [self reflectScrolledClipView:self.contentView];
118
+ }
119
+ #endif // macOS]
104
120
  }
105
121
 
106
122
  - (void)setFrame:(CGRect)frame
107
123
  {
124
+ #if !TARGET_OS_OSX // [macOS]
108
125
  [super setFrame:frame];
109
126
  [self centerContentIfNeeded];
127
+ #else // [macOS
128
+ // Preserving and revalidating `contentOffset`.
129
+ CGPoint originalOffset = self.contentOffset;
130
+
131
+ [super setFrame:frame];
132
+
133
+ UIEdgeInsets contentInset = self.contentInset;
134
+ CGSize contentSize = self.contentSize;
135
+
136
+ // If contentSize has not been measured yet we can't check bounds.
137
+ if (CGSizeEqualToSize(contentSize, CGSizeZero)) {
138
+ self.contentOffset = originalOffset;
139
+ } else {
140
+ CGSize boundsSize = self.bounds.size;
141
+ CGFloat xMaxOffset = contentSize.width - boundsSize.width + contentInset.right;
142
+ CGFloat yMaxOffset = contentSize.height - boundsSize.height + contentInset.bottom;
143
+ // Make sure offset doesn't exceed bounds. This can happen on screen rotation.
144
+ if ((originalOffset.x >= -contentInset.left) && (originalOffset.x <= xMaxOffset) &&
145
+ (originalOffset.y >= -contentInset.top) && (originalOffset.y <= yMaxOffset)) {
146
+ return;
147
+ }
148
+ self.contentOffset = CGPointMake(
149
+ MAX(-contentInset.left, MIN(xMaxOffset, originalOffset.x)),
150
+ MAX(-contentInset.top, MIN(yMaxOffset, originalOffset.y)));
151
+ }
152
+ #endif // macOS]
153
+ }
154
+
155
+ #if TARGET_OS_OSX // [macOS
156
+ - (NSSize)contentSize
157
+ {
158
+ if (!self.documentView) {
159
+ return [super contentSize];
160
+ }
161
+
162
+ return self.documentView.frame.size;
163
+ }
164
+
165
+ - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
166
+ {
167
+ if (animated) {
168
+ [NSAnimationContext beginGrouping];
169
+ [[NSAnimationContext currentContext] setDuration:0.3];
170
+ [[self.contentView animator] setBoundsOrigin:contentOffset];
171
+ [NSAnimationContext endGrouping];
172
+ } else {
173
+ self.contentOffset = contentOffset;
174
+ }
175
+ }
176
+
177
+ - (void)zoomToRect:(CGRect)rect animated:(BOOL)animated
178
+ {
179
+ [self magnifyToFitRect:rect];
180
+ }
181
+
182
+ - (void)flashScrollIndicators
183
+ {
184
+ [self flashScrollers];
110
185
  }
186
+ #endif // macOS]
111
187
 
112
188
  - (void)didAddSubview:(RCTPlatformView *)subview // [macOS]
113
189
  {
@@ -54,6 +54,10 @@ NS_ASSUME_NONNULL_BEGIN
54
54
  @property (nonatomic, strong, readonly)
55
55
  RCTGenericDelegateSplitter<id<RCTUIScrollViewDelegate>> *scrollViewDelegateSplitter;
56
56
 
57
+ #if TARGET_OS_OSX // [macOS
58
+ @property (nonatomic, assign) UIEdgeInsets contentInset;
59
+ #endif // macOS]
60
+
57
61
  @end
58
62
 
59
63
  /*
@@ -95,6 +95,15 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(RCTUIScrollView *scrollView, NS
95
95
  RCTScrollableProtocol,
96
96
  RCTEnhancedScrollViewOverridingDelegate>
97
97
 
98
+ - (void)_preserveContentOffsetIfNeededWithBlock:(void (^)())block;
99
+ - (void)_remountChildrenIfNeeded;
100
+ - (void)_remountChildren;
101
+ - (void)_forceDispatchNextScrollEvent;
102
+ - (void)_handleScrollEndIfNeeded;
103
+ - (void)_handleFinishedScrolling:(RCTUIScrollView *)scrollView;
104
+ - (void)_prepareForMaintainVisibleScrollPosition;
105
+ - (void)_adjustForMaintainVisibleContentPosition;
106
+
98
107
  @end
99
108
 
100
109
  @implementation RCTScrollViewComponentView {
@@ -151,7 +160,7 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(RCTUIScrollView *scrollView, NS
151
160
  _containerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
152
161
  [_scrollView setDocumentView:_containerView];
153
162
  #endif // macOS]
154
-
163
+
155
164
  #if !TARGET_OS_OSX // [macOS]
156
165
  [self.scrollViewDelegateSplitter addDelegate:self];
157
166
  #endif // [macOS]
@@ -175,6 +184,30 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(RCTUIScrollView *scrollView, NS
175
184
  #endif // [macOS]
176
185
  }
177
186
 
187
+ #if TARGET_OS_OSX // [macOS
188
+ - (void)layoutSubviews
189
+ {
190
+ [super layoutSubviews];
191
+
192
+ // On macOS, the _containerView is the NSScrollView's documentView and has autoresizingMask set so
193
+ // it fills the visible area before React's first layout pass. However, AppKit's autoresizing can
194
+ // corrupt the documentView's frame by adding the NSClipView's size delta to the container's
195
+ // dimensions (e.g., during initial tile or window resize), inflating it well beyond the correct
196
+ // content size. This produces massive horizontal and vertical overflow on first render.
197
+ //
198
+ // After React has set the content size via updateState:, we reset the documentView frame here to
199
+ // undo any autoresizing corruption. This runs after AppKit's layout (which triggers autoresizing),
200
+ // so it reliably corrects the frame.
201
+ if (!CGSizeEqualToSize(_contentSize, CGSizeZero)) {
202
+ CGRect containerFrame = _containerView.frame;
203
+ if (!CGSizeEqualToSize(containerFrame.size, _contentSize)) {
204
+ containerFrame.size = _contentSize;
205
+ _containerView.frame = containerFrame;
206
+ }
207
+ }
208
+ }
209
+ #endif // macOS]
210
+
178
211
  #if TARGET_OS_IOS
179
212
  - (void)_registerKeyboardListener
180
213
  {
@@ -279,6 +312,19 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
279
312
  }
280
313
  #endif
281
314
 
315
+ #if TARGET_OS_OSX // [macOS
316
+ - (void)setContentInset:(UIEdgeInsets)contentInset
317
+ {
318
+ if (UIEdgeInsetsEqualToEdgeInsets(contentInset, _contentInset)) {
319
+ return;
320
+ }
321
+
322
+ _contentInset = contentInset;
323
+ _scrollView.contentInset = contentInset;
324
+ _scrollView.scrollIndicatorInsets = contentInset;
325
+ }
326
+ #endif // macOS]
327
+
282
328
  - (RCTGenericDelegateSplitter<id<RCTUIScrollViewDelegate>> *)scrollViewDelegateSplitter
283
329
  {
284
330
  return ((RCTEnhancedScrollView *)_scrollView).delegateSplitter;
@@ -408,7 +454,11 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
408
454
  MAP_SCROLL_VIEW_PROP(zoomScale);
409
455
 
410
456
  if (oldScrollViewProps.contentInset != newScrollViewProps.contentInset) {
457
+ #if !TARGET_OS_OSX // [macOS]
411
458
  _scrollView.contentInset = RCTUIEdgeInsetsFromEdgeInsets(newScrollViewProps.contentInset);
459
+ #else // [macOS
460
+ self.contentInset = RCTUIEdgeInsetsFromEdgeInsets(newScrollViewProps.contentInset);
461
+ #endif // macOS]
412
462
  }
413
463
 
414
464
  RCTEnhancedScrollView *scrollView = (RCTEnhancedScrollView *)_scrollView;
@@ -452,7 +502,7 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
452
502
  _shouldUpdateContentInsetAdjustmentBehavior = NO;
453
503
  }
454
504
  #endif // [macOS]
455
-
505
+
456
506
  MAP_SCROLL_VIEW_PROP(disableIntervalMomentum);
457
507
  MAP_SCROLL_VIEW_PROP(snapToInterval);
458
508
 
@@ -536,7 +586,7 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
536
586
  }
537
587
 
538
588
  for (RCTPlatformView *subview in [_containerView.subviews reverseObjectEnumerator]) { // [macOS]
539
- RCTPlatformView *hitView = RCTUIViewHitTestWithEvent(subview, [subview convertPoint:point fromView:self], event); // [macOS]
589
+ RCTPlatformView *hitView = RCTUIViewHitTestWithEvent(subview, point, self, event); // [macOS]
540
590
  if (hitView) {
541
591
  return hitView;
542
592
  }
@@ -673,6 +723,22 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
673
723
  _firstVisibleView = nil;
674
724
  }
675
725
 
726
+ #if TARGET_OS_OSX // [macOS
727
+ #pragma mark - NSScrollView scroll notification
728
+
729
+ - (void)scrollViewDocumentViewBoundsDidChange:(__unused NSNotification *)notification
730
+ {
731
+ RCTEnhancedScrollView *scrollView = _scrollView;
732
+
733
+ if (scrollView.centerContent) {
734
+ // Update content centering through contentOffset setter
735
+ [scrollView setContentOffset:scrollView.contentOffset];
736
+ }
737
+
738
+ [self scrollViewDidScroll:scrollView];
739
+ }
740
+ #endif // macOS]
741
+
676
742
  #pragma mark - UIScrollViewDelegate
677
743
 
678
744
  #if !TARGET_OS_OSX // [macOS]
@@ -816,6 +882,22 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
816
882
  [super viewDidMoveToWindow];
817
883
  #endif // [macOS]
818
884
 
885
+ #if TARGET_OS_OSX // [macOS
886
+ NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
887
+ if (self.window == nil) {
888
+ // Unregister scrollview's clipview bounds change notifications
889
+ [defaultCenter removeObserver:self
890
+ name:NSViewBoundsDidChangeNotification
891
+ object:_scrollView.contentView];
892
+ } else {
893
+ // Register for scrollview's clipview bounds change notifications so we can track scrolling
894
+ [defaultCenter addObserver:self
895
+ selector:@selector(scrollViewDocumentViewBoundsDidChange:)
896
+ name:NSViewBoundsDidChangeNotification
897
+ object:_scrollView.contentView]; // NSClipView
898
+ }
899
+ #endif // macOS]
900
+
819
901
  if (!self.window) {
820
902
  // The view is being removed, ensure that the scroll end event is dispatched
821
903
  [self _handleScrollEndIfNeeded];
@@ -898,6 +980,8 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
898
980
  {
899
981
  #if !TARGET_OS_OSX // [macOS]
900
982
  [_scrollView flashScrollIndicators];
983
+ #else // [macOS
984
+ [(RCTEnhancedScrollView *)_scrollView flashScrollers];
901
985
  #endif // [macOS]
902
986
  }
903
987
 
@@ -997,7 +1081,11 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
997
1081
 
998
1082
  [self _forceDispatchNextScrollEvent];
999
1083
 
1084
+ #if !TARGET_OS_OSX // [macOS]
1000
1085
  [_scrollView setContentOffset:offset animated:animated];
1086
+ #else // [macOS
1087
+ [(RCTEnhancedScrollView *)_scrollView setContentOffset:offset animated:animated];
1088
+ #endif // macOS]
1001
1089
 
1002
1090
  if (!animated) {
1003
1091
  // When not animated, the expected workflow in ``scrollViewDidEndScrollingAnimation`` after scrolling is not going
@@ -1010,6 +1098,8 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
1010
1098
  {
1011
1099
  #if !TARGET_OS_OSX // [macOS]
1012
1100
  [_scrollView zoomToRect:rect animated:animated];
1101
+ #else // [macOS
1102
+ [(RCTEnhancedScrollView *)_scrollView zoomToRect:rect animated:animated];
1013
1103
  #endif // [macOS]
1014
1104
  }
1015
1105