react-native-macos 0.72.18 → 0.72.19

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.
@@ -135,7 +135,7 @@ const ReactNativeStyleAttributes: {[string]: AnyAttributeType, ...} = {
135
135
  borderTopLeftRadius: true,
136
136
  borderTopRightRadius: true,
137
137
  borderTopStartRadius: true,
138
- cursor: true,
138
+ cursor: true, // [macOS] [visionOS]
139
139
  opacity: true,
140
140
  pointerEvents: true,
141
141
 
@@ -12,6 +12,6 @@
12
12
  exports.version = {
13
13
  major: 0,
14
14
  minor: 72,
15
- patch: 18,
15
+ patch: 19,
16
16
  prerelease: null,
17
17
  };
@@ -27,6 +27,30 @@ export type DimensionValue =
27
27
  type AnimatableNumericValue = number | Animated.AnimatedNode;
28
28
  type AnimatableStringValue = string | Animated.AnimatedNode;
29
29
 
30
+ // [macOS
31
+ export type CursorValue =
32
+ | 'alias'
33
+ | 'auto'
34
+ | 'col-resize'
35
+ | 'context-menu'
36
+ | 'copy'
37
+ | 'crosshair'
38
+ | 'default'
39
+ | 'disappearing-item'
40
+ | 'e-resize'
41
+ | 'grab'
42
+ | 'grabbing'
43
+ | 'n-resize'
44
+ | 'no-drop'
45
+ | 'not-allowed'
46
+ | 'pointer'
47
+ | 'row-resize'
48
+ | 's-resize'
49
+ | 'text'
50
+ | 'vertical-text'
51
+ | 'w-resize';
52
+ // macOS]
53
+
30
54
  /**
31
55
  * Flex Prop Types
32
56
  * @see https://reactnative.dev/docs/flexbox
@@ -267,6 +291,7 @@ export interface ViewStyle extends FlexStyle, ShadowStyleIOS, TransformsStyle {
267
291
  * Controls whether the View can be the target of touch events.
268
292
  */
269
293
  pointerEvents?: 'box-none' | 'none' | 'box-only' | 'auto' | undefined;
294
+ cursor?: CursorValue | undefined;
270
295
  }
271
296
 
272
297
  export type FontVariant =
@@ -349,4 +374,5 @@ export interface ImageStyle extends FlexStyle, ShadowStyleIOS, TransformsStyle {
349
374
  tintColor?: ColorValue | undefined;
350
375
  opacity?: AnimatableNumericValue | undefined;
351
376
  objectFit?: 'cover' | 'contain' | 'fill' | 'scale-down' | undefined;
377
+ cursor?: CursorValue | undefined;
352
378
  }
@@ -21,8 +21,24 @@ import type {
21
21
  } from './private/_StyleSheetTypesOverrides';
22
22
  import type {____TransformStyle_Internal} from './private/_TransformStyle';
23
23
 
24
+ export type ____ColorValue_Internal = null | string | number | NativeColorValue;
25
+ export type ColorArrayValue = null | $ReadOnlyArray<____ColorValue_Internal>;
26
+ export type PointValue = {
27
+ x: number,
28
+ y: number,
29
+ };
30
+ export type EdgeInsetsValue = {
31
+ top: number,
32
+ left: number,
33
+ right: number,
34
+ bottom: number,
35
+ };
36
+
37
+ export type DimensionValue = number | string | 'auto' | AnimatedNode | null;
38
+ export type AnimatableNumericValue = number | AnimatedNode;
39
+
24
40
  // [macOS
25
- export type CursorValue = ?(
41
+ export type CursorValue =
26
42
  | 'alias'
27
43
  | 'auto'
28
44
  | 'col-resize'
@@ -42,26 +58,9 @@ export type CursorValue = ?(
42
58
  | 's-resize'
43
59
  | 'text'
44
60
  | 'vertical-text'
45
- | 'w-resize'
46
- );
61
+ | 'w-resize';
47
62
  // macOS]
48
63
 
49
- export type ____ColorValue_Internal = null | string | number | NativeColorValue;
50
- export type ColorArrayValue = null | $ReadOnlyArray<____ColorValue_Internal>;
51
- export type PointValue = {
52
- x: number,
53
- y: number,
54
- };
55
- export type EdgeInsetsValue = {
56
- top: number,
57
- left: number,
58
- right: number,
59
- bottom: number,
60
- };
61
-
62
- export type DimensionValue = number | string | 'auto' | AnimatedNode | null;
63
- export type AnimatableNumericValue = number | AnimatedNode;
64
-
65
64
  /**
66
65
  * React Native's layout system is based on Flexbox and is powered both
67
66
  * on iOS and Android by an open source project called `Yoga`:
@@ -678,7 +677,7 @@ export type ____ViewStyle_InternalCore = $ReadOnly<{
678
677
  opacity?: AnimatableNumericValue,
679
678
  elevation?: number,
680
679
  pointerEvents?: 'auto' | 'none' | 'box-none' | 'box-only',
681
- cursor?: CursorValue, // [macOS]
680
+ cursor?: CursorValue, // [macOS][visionOS]
682
681
  }>;
683
682
 
684
683
  export type ____ViewStyle_Internal = $ReadOnly<{
@@ -6,9 +6,7 @@
6
6
  */
7
7
 
8
8
  #import <React/RCTBaseTextViewManager.h>
9
- #if TARGET_OS_OSX // [macOS
10
- #import <React/RCTCursor.h>
11
- #endif // macOS]
9
+ #import <React/RCTCursor.h> // [macOS]
12
10
 
13
11
  @implementation RCTBaseTextViewManager
14
12
 
@@ -7,15 +7,12 @@
7
7
 
8
8
  #import <React/RCTUIKit.h> // [macOS]
9
9
 
10
+ #import <React/RCTCursor.h> // [macOS]
10
11
  #import <React/RCTDynamicTypeRamp.h>
11
12
  #import <React/RCTTextDecorationLineType.h>
12
13
 
13
14
  #import "RCTTextTransform.h"
14
15
 
15
- #if TARGET_OS_OSX // [macOS
16
- #import <React/RCTCursor.h>
17
- #endif // macOS]
18
-
19
16
  NS_ASSUME_NONNULL_BEGIN
20
17
 
21
18
  extern NSString *const RCTTextAttributesIsHighlightedAttributeName;
@@ -8,13 +8,10 @@
8
8
  #import <React/RCTTextAttributes.h>
9
9
 
10
10
  #import <React/RCTAssert.h>
11
+ #import <React/RCTCursor.h> // [macOS]
11
12
  #import <React/RCTFont.h>
12
13
  #import <React/RCTLog.h>
13
14
 
14
- #if TARGET_OS_OSX // [macOS
15
- #import <React/RCTCursor.h>
16
- #endif // macOS]
17
-
18
15
  NSString *const RCTTextAttributesIsHighlightedAttributeName = @"RCTTextAttributesIsHighlightedAttributeName";
19
16
  NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttributeName";
20
17
 
@@ -235,7 +232,7 @@ NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttrib
235
232
 
236
233
  #if TARGET_OS_OSX // [macOS
237
234
  if (_cursor != RCTCursorAuto) {
238
- attributes[NSCursorAttributeName] = [RCTConvert NSCursor:_cursor];
235
+ attributes[NSCursorAttributeName] = NSCursorFromRCTCursor(_cursor);
239
236
  }
240
237
  #endif // macOS]
241
238
 
@@ -11,6 +11,7 @@
11
11
  #import <React/RCTAnimationType.h>
12
12
  #import <React/RCTBorderCurve.h>
13
13
  #import <React/RCTBorderStyle.h>
14
+ #import <React/RCTCursor.h> // [macOS] [visionOS]
14
15
  #import <React/RCTDefines.h>
15
16
  #import <React/RCTLog.h>
16
17
  #import <React/RCTPointerEvents.h>
@@ -89,6 +90,8 @@ typedef NSURL RCTFileURL;
89
90
  #endif
90
91
  #endif // [macOS]
91
92
 
93
+ + (RCTCursor)RCTCursor:(id)json; // [macOS] [visionOS]
94
+
92
95
  #if TARGET_OS_OSX // [macOS
93
96
  + (NSTextCheckingTypes)NSTextCheckingTypes:(id)json;
94
97
  #endif // macOS]
@@ -551,7 +551,38 @@ RCT_ENUM_CONVERTER(
551
551
  }),
552
552
  UIBarStyleDefault,
553
553
  integerValue)
554
- #else // [macOS
554
+ #endif // [macOS]
555
+
556
+ // [macOS [visionOS]
557
+ RCT_ENUM_CONVERTER(
558
+ RCTCursor,
559
+ (@{
560
+ @"alias" : @(RCTCursorAlias),
561
+ @"auto" : @(RCTCursorAuto),
562
+ @"col-resize" : @(RCTCursorColumnResize),
563
+ @"context-menu" : @(RCTCursorContextualMenu),
564
+ @"copy" : @(RCTCursorCopy),
565
+ @"crosshair" : @(RCTCursorCrosshair),
566
+ @"default" : @(RCTCursorDefault),
567
+ @"disappearing-item" : @(RCTCursorDisappearingItem),
568
+ @"e-resize" : @(RCTCursorEastResize),
569
+ @"grab" : @(RCTCursorGrab),
570
+ @"grabbing" : @(RCTCursorGrabbing),
571
+ @"n-resize" : @(RCTCursorNorthResize),
572
+ @"no-drop" : @(RCTCursorNoDrop),
573
+ @"not-allowed" : @(RCTCursorNotAllowed),
574
+ @"pointer" : @(RCTCursorPointer),
575
+ @"row-resize" : @(RCTCursorRowResize),
576
+ @"s-resize" : @(RCTCursorSouthResize),
577
+ @"text" : @(RCTCursorText),
578
+ @"vertical-text" : @(RCTCursorVerticalText),
579
+ @"w-resize" : @(RCTCursorWestResize),
580
+ }),
581
+ RCTCursorAuto,
582
+ integerValue)
583
+ // macOS] [visionOS]
584
+
585
+ #if TARGET_OS_OSX // [macOS
555
586
  RCT_MULTI_ENUM_CONVERTER(NSTextCheckingTypes, (@{
556
587
  @"ortography": @(NSTextCheckingTypeOrthography),
557
588
  @"spelling": @(NSTextCheckingTypeSpelling),
@@ -23,7 +23,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
23
23
  __rnVersion = @{
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(72),
26
- RCTVersionPatch: @(18),
26
+ RCTVersionPatch: @(19),
27
27
  RCTVersionPrerelease: [NSNull null],
28
28
  };
29
29
  });
@@ -89,6 +89,18 @@ using namespace facebook::react;
89
89
  _backgroundColor = backgroundColor;
90
90
  }
91
91
 
92
+ #if TARGET_OS_OSX // [macOS
93
+ - (void)resetCursorRects
94
+ {
95
+ [self discardCursorRects];
96
+ if (_props->cursor != Cursor::Auto)
97
+ {
98
+ NSCursor *cursor = NSCursorFromCursor(_props->cursor);
99
+ [self addCursorRect:self.bounds cursor:cursor];
100
+ }
101
+ }
102
+ #endif // macOS]
103
+
92
104
  #pragma mark - RCTComponentViewProtocol
93
105
 
94
106
  + (ComponentDescriptorProvider)componentDescriptorProvider
@@ -250,6 +262,11 @@ using namespace facebook::react;
250
262
  if (oldViewProps.backfaceVisibility != newViewProps.backfaceVisibility) {
251
263
  self.layer.doubleSided = newViewProps.backfaceVisibility == BackfaceVisibility::Visible;
252
264
  }
265
+
266
+ // `cursor`
267
+ if (oldViewProps.cursor != newViewProps.cursor) {
268
+ needsInvalidateLayer = YES;
269
+ }
253
270
 
254
271
  // `shouldRasterize`
255
272
  if (oldViewProps.shouldRasterize != newViewProps.shouldRasterize) {
@@ -559,6 +576,55 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
559
576
  }
560
577
  }
561
578
 
579
+ #if TARGET_OS_OSX // [macOS
580
+ static NSCursor *NSCursorFromCursor(Cursor cursor)
581
+ {
582
+ switch (cursor) {
583
+ case Cursor::Auto:
584
+ return [NSCursor arrowCursor];
585
+ case Cursor::Alias:
586
+ return [NSCursor dragLinkCursor];
587
+ case Cursor::ColumnResize:
588
+ return [NSCursor resizeLeftRightCursor];
589
+ case Cursor::ContextualMenu:
590
+ return [NSCursor contextualMenuCursor];
591
+ case Cursor::Copy:
592
+ return [NSCursor dragCopyCursor];
593
+ case Cursor::Crosshair:
594
+ return [NSCursor crosshairCursor];
595
+ case Cursor::Default:
596
+ return [NSCursor arrowCursor];
597
+ case Cursor::DisappearingItem:
598
+ return [NSCursor disappearingItemCursor];
599
+ case Cursor::EastResize:
600
+ return [NSCursor resizeRightCursor];
601
+ case Cursor::Grab:
602
+ return [NSCursor openHandCursor];
603
+ case Cursor::Grabbing:
604
+ return [NSCursor closedHandCursor];
605
+ case Cursor::NorthResize:
606
+ return [NSCursor resizeUpCursor];
607
+ case Cursor::NoDrop:
608
+ return [NSCursor operationNotAllowedCursor];
609
+ case Cursor::NotAllowed:
610
+ return [NSCursor operationNotAllowedCursor];
611
+ case Cursor::Pointer:
612
+ return [NSCursor pointingHandCursor];
613
+ case Cursor::RowResize:
614
+ return [NSCursor resizeUpDownCursor];
615
+ case Cursor::SouthResize:
616
+ return [NSCursor resizeDownCursor];
617
+ case Cursor::Text:
618
+ return [NSCursor IBeamCursor];
619
+ case Cursor::VerticalText:
620
+ return [NSCursor IBeamCursorForVerticalLayout];
621
+ case Cursor::WestResize:
622
+ return [NSCursor resizeLeftCursor];
623
+ }
624
+ }
625
+ #endif // macOS]
626
+
627
+
562
628
  - (void)invalidateLayer
563
629
  {
564
630
  CALayer *layer = self.layer;
@@ -586,6 +652,33 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
586
652
  } else {
587
653
  layer.shadowPath = nil;
588
654
  }
655
+
656
+ #if !TARGET_OS_OSX // [visionOS]
657
+ // Stage 1.5. Cursor / Hover Effects
658
+ if (@available(iOS 17.0, *)) {
659
+ UIHoverStyle *hoverStyle = nil;
660
+ if (_props->cursor == Cursor::Pointer) {
661
+ const RCTCornerInsets cornerInsets =
662
+ RCTGetCornerInsets(RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii), UIEdgeInsetsZero);
663
+ #if TARGET_OS_IOS
664
+ // Due to an Apple bug, it seems on iOS, UIShapes made with `[UIShape shapeWithBezierPath:]`
665
+ // evaluate their shape on the superviews' coordinate space. This leads to the hover shape
666
+ // rendering incorrectly on iOS, iOS apps in compatibility mode on visionOS, but not on visionOS.
667
+ // To work around this, for iOS, we can calculate the border path based on `view.frame` (the
668
+ // superview's coordinate space) instead of view.bounds.
669
+ CGPathRef borderPath = RCTPathCreateWithRoundedRect(self.frame, cornerInsets, NULL);
670
+ #else // TARGET_OS_VISION
671
+ CGPathRef borderPath = RCTPathCreateWithRoundedRect(self.bounds, cornerInsets, NULL);
672
+ #endif
673
+ UIBezierPath *bezierPath = [UIBezierPath bezierPathWithCGPath:borderPath];
674
+ CGPathRelease(borderPath);
675
+ UIShape *shape = [UIShape shapeWithBezierPath:bezierPath];
676
+
677
+ hoverStyle = [UIHoverStyle styleWithEffect:[UIHoverAutomaticEffect effect] shape:shape];
678
+ }
679
+ [self setHoverStyle:hoverStyle];
680
+ }
681
+ #endif // [visionOS]
589
682
 
590
683
  // Stage 2. Border Rendering
591
684
  bool const useCoreAnimationBorderRendering =
@@ -5,35 +5,76 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- #import <React/RCTConvert.h>
8
+ #import <Foundation/Foundation.h>
9
9
 
10
10
  typedef NS_ENUM(NSInteger, RCTCursor) {
11
+ RCTCursorAlias,
11
12
  RCTCursorAuto,
12
- RCTCursorArrow,
13
- RCTCursorIBeam,
13
+ RCTCursorColumnResize,
14
+ RCTCursorContextualMenu,
15
+ RCTCursorCopy,
14
16
  RCTCursorCrosshair,
15
- RCTCursorClosedHand,
16
- RCTCursorOpenHand,
17
- RCTCursorPointingHand,
18
- RCTCursorResizeLeft,
19
- RCTCursorResizeRight,
20
- RCTCursorResizeLeftRight,
21
- RCTCursorResizeUp,
22
- RCTCursorResizeDown,
23
- RCTCursorResizeUpDown,
17
+ RCTCursorDefault,
24
18
  RCTCursorDisappearingItem,
25
- RCTCursorIBeamCursorForVerticalLayout,
26
- RCTCursorOperationNotAllowed,
27
- RCTCursorDragLink,
28
- RCTCursorDragCopy,
29
- RCTCursorContextualMenu,
19
+ RCTCursorEastResize,
20
+ RCTCursorGrab,
21
+ RCTCursorGrabbing,
22
+ RCTCursorNorthResize,
23
+ RCTCursorNoDrop,
24
+ RCTCursorNotAllowed,
25
+ RCTCursorPointer,
26
+ RCTCursorRowResize,
27
+ RCTCursorSouthResize,
28
+ RCTCursorText,
29
+ RCTCursorVerticalText,
30
+ RCTCursorWestResize,
30
31
  };
31
32
 
32
- @interface RCTConvert (RCTCursor)
33
-
34
- + (RCTCursor)RCTCursor:(id)json;
35
33
  #if TARGET_OS_OSX // [macOS
36
- + (NSCursor *)NSCursor:(RCTCursor)rctCursor;
34
+ inline static NSCursor *NSCursorFromRCTCursor(RCTCursor cursor)
35
+ {
36
+ switch (cursor) {
37
+ case RCTCursorAlias:
38
+ return [NSCursor dragLinkCursor];
39
+ case RCTCursorAuto:
40
+ return [NSCursor arrowCursor];
41
+ case RCTCursorColumnResize:
42
+ return [NSCursor resizeLeftRightCursor];
43
+ case RCTCursorContextualMenu:
44
+ return [NSCursor contextualMenuCursor];
45
+ case RCTCursorCopy:
46
+ return [NSCursor dragCopyCursor];
47
+ case RCTCursorCrosshair:
48
+ return [NSCursor crosshairCursor];
49
+ case RCTCursorDefault:
50
+ return [NSCursor arrowCursor];
51
+ case RCTCursorDisappearingItem:
52
+ return [NSCursor disappearingItemCursor];
53
+ case RCTCursorEastResize:
54
+ return [NSCursor resizeRightCursor];
55
+ case RCTCursorGrab:
56
+ return [NSCursor openHandCursor];
57
+ case RCTCursorGrabbing:
58
+ return [NSCursor closedHandCursor];
59
+ case RCTCursorNorthResize:
60
+ return [NSCursor resizeUpCursor];
61
+ case RCTCursorNoDrop:
62
+ return [NSCursor operationNotAllowedCursor];
63
+ case RCTCursorNotAllowed:
64
+ return [NSCursor operationNotAllowedCursor];
65
+ case RCTCursorPointer:
66
+ return [NSCursor pointingHandCursor];
67
+ case RCTCursorRowResize:
68
+ return [NSCursor resizeUpDownCursor];
69
+ case RCTCursorSouthResize:
70
+ return [NSCursor resizeDownCursor];
71
+ case RCTCursorText:
72
+ return [NSCursor IBeamCursor];
73
+ case RCTCursorVerticalText:
74
+ return [NSCursor IBeamCursorForVerticalLayout];
75
+ case RCTCursorWestResize:
76
+ return [NSCursor resizeLeftCursor];
77
+ }
78
+ }
37
79
  #endif // macOS]
38
80
 
39
- @end
@@ -10,13 +10,10 @@
10
10
  #import <React/RCTBorderCurve.h>
11
11
  #import <React/RCTBorderStyle.h>
12
12
  #import <React/RCTComponent.h>
13
+ #import <React/RCTCursor.h> // [macOS] [visionOS]
13
14
  #import <React/RCTEventDispatcherProtocol.h> // [macOS]
14
15
  #import <React/RCTPointerEvents.h>
15
16
 
16
- #if TARGET_OS_OSX // [macOS
17
- #import <React/RCTCursor.h>
18
- #endif // macOS]
19
-
20
17
  #if !TARGET_OS_OSX // [macOS]
21
18
  extern const UIAccessibilityTraits SwitchAccessibilityTrait;
22
19
  #endif // [macOS]
@@ -143,6 +140,8 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
143
140
  */
144
141
  @property (nonatomic, assign) UIEdgeInsets hitTestEdgeInsets;
145
142
 
143
+ @property (nonatomic, assign) RCTCursor cursor;
144
+
146
145
  /**
147
146
  * (Experimental and unused for Paper) Pointer event handlers.
148
147
  */
@@ -159,8 +158,6 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
159
158
  /**
160
159
  * macOS Properties
161
160
  */
162
- @property (nonatomic, assign) RCTCursor cursor;
163
-
164
161
  @property (nonatomic, assign) CATransform3D transform3D;
165
162
 
166
163
  // `allowsVibrancy` is readonly on NSView, so let's create a new property to make it assignable
@@ -178,6 +178,7 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // [macOS]
178
178
  _borderCurve = RCTBorderCurveCircular;
179
179
  _borderStyle = RCTBorderStyleSolid;
180
180
  _hitTestEdgeInsets = UIEdgeInsetsZero;
181
+ _cursor = RCTCursorAuto;
181
182
  #if TARGET_OS_OSX // [macOS
182
183
  _transform3D = CATransform3DIdentity;
183
184
  _shadowColor = nil;
@@ -1204,7 +1205,11 @@ static CGFloat RCTDefaultIfNegativeTo(CGFloat defaultValue, CGFloat x)
1204
1205
  }
1205
1206
 
1206
1207
  RCTUpdateShadowPathForView(self);
1207
-
1208
+
1209
+ #if !TARGET_OS_OSX // [visionOS]
1210
+ RCTUpdateHoverStyleForView(self);
1211
+ #endif // [visionOS]
1212
+
1208
1213
  #if TARGET_OS_OSX // [macOS
1209
1214
  // clipsToBounds is stubbed out on macOS because it's not part of NSView
1210
1215
  layer.masksToBounds = self.clipsToBounds;
@@ -1346,6 +1351,33 @@ static void RCTUpdateShadowPathForView(RCTView *view)
1346
1351
  }
1347
1352
  }
1348
1353
 
1354
+ #if !TARGET_OS_OSX // [visionOS
1355
+ static void RCTUpdateHoverStyleForView(RCTView *view)
1356
+ {
1357
+ if (@available(iOS 17.0, *)) {
1358
+ UIHoverStyle *hoverStyle = nil;
1359
+ if ([view cursor] == RCTCursorPointer) {
1360
+ const RCTCornerRadii cornerRadii = [view cornerRadii];
1361
+ const RCTCornerInsets cornerInsets = RCTGetCornerInsets(cornerRadii, UIEdgeInsetsZero);
1362
+ #if TARGET_OS_IOS
1363
+ // Due to an Apple bug, it seems on iOS, `[UIShape shapeWithBezierPath:]` needs to
1364
+ // be calculated in the superviews' coordinate space (view.frame). This is not true
1365
+ // on other platforms like visionOS.
1366
+ CGPathRef borderPath = RCTPathCreateWithRoundedRect(view.frame, cornerInsets, NULL);
1367
+ #else // TARGET_OS_VISION
1368
+ CGPathRef borderPath = RCTPathCreateWithRoundedRect(view.bounds, cornerInsets, NULL);
1369
+ #endif
1370
+ UIBezierPath *bezierPath = [UIBezierPath bezierPathWithCGPath:borderPath];
1371
+ CGPathRelease(borderPath);
1372
+ UIShape *shape = [UIShape shapeWithBezierPath:bezierPath];
1373
+
1374
+ hoverStyle = [UIHoverStyle styleWithEffect:[UIHoverHighlightEffect effect] shape:shape];
1375
+ }
1376
+ [view setHoverStyle:hoverStyle];
1377
+ }
1378
+ }
1379
+ #endif // visionOS]
1380
+
1349
1381
  - (void)updateClippingForLayer:(CALayer *)layer
1350
1382
  {
1351
1383
  CALayer *mask = nil;
@@ -1473,8 +1505,9 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1473
1505
  - (void)resetCursorRects
1474
1506
  {
1475
1507
  [self discardCursorRects];
1476
- NSCursor *cursor = [RCTConvert NSCursor:self.cursor];
1477
- if (cursor) {
1508
+ if ([self cursor] != RCTCursorAuto)
1509
+ {
1510
+ NSCursor *cursor = NSCursorFromRCTCursor(self.cursor);
1478
1511
  [self addCursorRect:self.bounds cursor:cursor];
1479
1512
  }
1480
1513
  }
@@ -13,6 +13,7 @@
13
13
  #import "RCTBridge.h"
14
14
  #import "RCTConvert+Transform.h"
15
15
  #import "RCTConvert.h"
16
+ #import "RCTCursor.h" // [macOS] [visionOS]
16
17
  #import "RCTLog.h"
17
18
  #import "RCTShadowView.h"
18
19
  #import "RCTUIManager.h"
@@ -21,10 +22,6 @@
21
22
  #import "RCTView.h"
22
23
  #import "UIView+React.h"
23
24
 
24
- #if TARGET_OS_OSX // [macOS
25
- #import "RCTCursor.h"
26
- #endif // macOS]
27
-
28
25
  #if !TARGET_OS_OSX // [macOS]
29
26
  @implementation RCTConvert (UIAccessibilityTraits)
30
27
 
@@ -203,6 +200,7 @@ RCT_REMAP_VIEW_PROPERTY(testID, reactAccessibilityElement.accessibilityIdentifie
203
200
 
204
201
  RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor)
205
202
  RCT_REMAP_VIEW_PROPERTY(backfaceVisibility, layer.doubleSided, css_backface_visibility_t)
203
+ RCT_EXPORT_VIEW_PROPERTY(cursor, RCTCursor) // [visionOS]
206
204
  #if !TARGET_OS_OSX // [macOS]
207
205
  RCT_REMAP_VIEW_PROPERTY(opacity, alpha, CGFloat)
208
206
  #else // [macOS
@@ -523,7 +521,6 @@ RCT_EXPORT_VIEW_PROPERTY(onBlur, RCTBubblingEventBlock)
523
521
  #if TARGET_OS_OSX // [macOS
524
522
  #pragma mark - macOS properties
525
523
 
526
- RCT_EXPORT_VIEW_PROPERTY(cursor, RCTCursor)
527
524
  RCT_EXPORT_VIEW_PROPERTY(onMouseEnter, RCTDirectEventBlock)
528
525
  RCT_EXPORT_VIEW_PROPERTY(onMouseLeave, RCTDirectEventBlock)
529
526
  RCT_EXPORT_VIEW_PROPERTY(onDragEnter, RCTDirectEventBlock)
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.72.18
1
+ VERSION_NAME=0.72.19
2
2
  GROUP=com.facebook.react
3
3
 
4
4
  # JVM Versions
@@ -17,6 +17,6 @@ public class ReactNativeVersion {
17
17
  public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
18
18
  "major", 0,
19
19
  "minor", 72,
20
- "patch", 18,
20
+ "patch", 19,
21
21
  "prerelease", null);
22
22
  }
@@ -17,7 +17,7 @@ namespace facebook::react {
17
17
  constexpr struct {
18
18
  int32_t Major = 0;
19
19
  int32_t Minor = 72;
20
- int32_t Patch = 18;
20
+ int32_t Patch = 19;
21
21
  std::string_view Prerelease = "";
22
22
  } ReactNativeVersion;
23
23
 
@@ -120,6 +120,15 @@ ViewProps::ViewProps(
120
120
  "shadowRadius",
121
121
  sourceProps.shadowRadius,
122
122
  {})),
123
+ cursor(
124
+ CoreFeatures::enablePropIteratorSetter
125
+ ? sourceProps.cursor
126
+ : convertRawProp(
127
+ context,
128
+ rawProps,
129
+ "cursor",
130
+ sourceProps.cursor,
131
+ {})),
123
132
  transform(
124
133
  CoreFeatures::enablePropIteratorSetter ? sourceProps.transform
125
134
  : convertRawProp(
@@ -64,6 +64,8 @@ class ViewProps : public YogaStylableProps, public AccessibilityProps {
64
64
  Float shadowOpacity{};
65
65
  Float shadowRadius{3};
66
66
 
67
+ Cursor cursor{};
68
+
67
69
  // Transform
68
70
  Transform transform{};
69
71
  BackfaceVisibility backfaceVisibility{};
@@ -54,7 +54,7 @@ void ViewShadowNode::initialize() noexcept {
54
54
  viewProps.accessibilityElementsHidden ||
55
55
  viewProps.accessibilityViewIsModal ||
56
56
  viewProps.importantForAccessibility != ImportantForAccessibility::Auto ||
57
- viewProps.removeClippedSubviews;
57
+ viewProps.removeClippedSubviews || viewProps.cursor != Cursor::Auto; // [macOS] [visionOS]
58
58
 
59
59
  #ifdef ANDROID
60
60
  formsStackingContext = formsStackingContext || viewProps.elevation != 0;
@@ -677,6 +677,102 @@ inline void fromRawValue(
677
677
  react_native_expect(false);
678
678
  }
679
679
 
680
+ // [macOS [visionOS]
681
+ inline void fromRawValue(
682
+ const PropsParserContext& context,
683
+ const RawValue& value,
684
+ Cursor& result) {
685
+ result = Cursor::Auto;
686
+ react_native_expect(value.hasType<std::string>());
687
+ if (!value.hasType<std::string>()) {
688
+ return;
689
+ }
690
+ auto stringValue = (std::string)value;
691
+ if (stringValue == "alias") {
692
+ result = Cursor::Alias;
693
+ return;
694
+ }
695
+ if (stringValue == "auto") {
696
+ result = Cursor::Auto;
697
+ return;
698
+ }
699
+ if (stringValue == "col-resize") {
700
+ result = Cursor::ColumnResize;
701
+ return;
702
+ }
703
+ if (stringValue == "context-menu") {
704
+ result = Cursor::ContextualMenu;
705
+ return;
706
+ }
707
+ if (stringValue == "copy") {
708
+ result = Cursor::Copy;
709
+ return;
710
+ }
711
+ if (stringValue == "crosshair") {
712
+ result = Cursor::Crosshair;
713
+ return;
714
+ }
715
+ if (stringValue == "default") {
716
+ result = Cursor::Default;
717
+ return;
718
+ }
719
+ if (stringValue == "disappearing-item") {
720
+ result = Cursor::DisappearingItem;
721
+ return;
722
+ }
723
+ if (stringValue == "e-resize") {
724
+ result = Cursor::EastResize;
725
+ return;
726
+ }
727
+ if (stringValue == "grab") {
728
+ result = Cursor::Grab;
729
+ return;
730
+ }
731
+ if (stringValue == "grabbing") {
732
+ result = Cursor::Grabbing;
733
+ return;
734
+ }
735
+ if (stringValue == "n-resize") {
736
+ result = Cursor::NorthResize;
737
+ return;
738
+ }
739
+ if (stringValue == "no-drop") {
740
+ result = Cursor::NoDrop;
741
+ return;
742
+ }
743
+ if (stringValue == "not-allowed") {
744
+ result = Cursor::NotAllowed;
745
+ return;
746
+ }
747
+ if (stringValue == "pointer") {
748
+ result = Cursor::Pointer;
749
+ return;
750
+ }
751
+ if (stringValue == "row-resize") {
752
+ result = Cursor::RowResize;
753
+ return;
754
+ }
755
+ if (stringValue == "s-resize") {
756
+ result = Cursor::SouthResize;
757
+ return;
758
+ }
759
+ if (stringValue == "text") {
760
+ result = Cursor::Text;
761
+ return;
762
+ }
763
+ if (stringValue == "vertical-text") {
764
+ result = Cursor::VerticalText;
765
+ return;
766
+ }
767
+ if (stringValue == "w-resize") {
768
+ result = Cursor::WestResize;
769
+ return;
770
+ }
771
+ LOG(ERROR) << "Could not parse Cursor:" << stringValue;
772
+ react_native_expect(false);
773
+ }
774
+ // macOS] [visionOS]
775
+
680
776
  inline std::string toString(
681
777
  const std::array<float, yoga::enums::count<YGDimension>()> &dimensions) {
682
778
  return "{" + folly::to<std::string>(dimensions[0]) + ", " +
@@ -85,6 +85,31 @@ enum class BorderCurve : uint8_t { Circular, Continuous };
85
85
 
86
86
  enum class BorderStyle : uint8_t { Solid, Dotted, Dashed };
87
87
 
88
+ // [macOS [visionOS]
89
+ enum class Cursor : uint8_t {
90
+ Auto,
91
+ Alias,
92
+ ColumnResize,
93
+ ContextualMenu,
94
+ Copy,
95
+ Crosshair,
96
+ Default,
97
+ DisappearingItem,
98
+ EastResize,
99
+ Grab,
100
+ Grabbing,
101
+ NorthResize,
102
+ NoDrop,
103
+ NotAllowed,
104
+ Pointer,
105
+ RowResize,
106
+ SouthResize,
107
+ Text,
108
+ VerticalText,
109
+ WestResize,
110
+ };
111
+ // macOS] [visionOS]
112
+
88
113
  template <typename T>
89
114
  struct CascadedRectangleEdges {
90
115
  using Counterpart = RectangleEdges<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.72.18",
3
+ "version": "0.72.19",
4
4
  "bin": "./cli.js",
5
5
  "description": "React Native for macOS",
6
6
  "license": "MIT",
@@ -13,7 +13,7 @@
13
13
  "dependencies": {
14
14
  "react": "18.2.0",
15
15
  "react-native-macos": "1000.0.0",
16
- "react-native": "0.72.18"
16
+ "react-native": "0.72.19"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@babel/core": "^7.20.0",
@@ -1,105 +0,0 @@
1
- /*
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- #import <React/RCTCursor.h>
9
-
10
- @implementation RCTConvert (RCTCursor)
11
-
12
- RCT_ENUM_CONVERTER(
13
- RCTCursor,
14
- (@{
15
- @"alias" : @(RCTCursorDragLink),
16
- @"auto" : @(RCTCursorAuto),
17
- @"col-resize" : @(RCTCursorResizeLeftRight),
18
- @"context-menu" : @(RCTCursorContextualMenu),
19
- @"copy" : @(RCTCursorDragCopy),
20
- @"crosshair" : @(RCTCursorCrosshair),
21
- @"default" : @(RCTCursorArrow),
22
- @"disappearing-item" : @(RCTCursorDisappearingItem),
23
- @"e-resize" : @(RCTCursorResizeRight),
24
- @"grab" : @(RCTCursorOpenHand),
25
- @"grabbing" : @(RCTCursorClosedHand),
26
- @"n-resize" : @(RCTCursorResizeUp),
27
- @"no-drop" : @(RCTCursorOperationNotAllowed),
28
- @"not-allowed" : @(RCTCursorOperationNotAllowed),
29
- @"pointer" : @(RCTCursorPointingHand),
30
- @"row-resize" : @(RCTCursorResizeUpDown),
31
- @"s-resize" : @(RCTCursorResizeDown),
32
- @"text" : @(RCTCursorIBeam),
33
- @"vertical-text" : @(RCTCursorIBeamCursorForVerticalLayout),
34
- @"w-resize" : @(RCTCursorResizeLeft),
35
- }),
36
- RCTCursorAuto,
37
- integerValue)
38
-
39
- #if TARGET_OS_OSX // [macOS
40
- + (NSCursor *)NSCursor:(RCTCursor)rctCursor
41
- {
42
- NSCursor *cursor;
43
-
44
- switch (rctCursor) {
45
- case RCTCursorArrow:
46
- cursor = [NSCursor arrowCursor];
47
- break;
48
- case RCTCursorClosedHand:
49
- cursor = [NSCursor closedHandCursor];
50
- break;
51
- case RCTCursorContextualMenu:
52
- cursor = [NSCursor contextualMenuCursor];
53
- break;
54
- case RCTCursorCrosshair:
55
- cursor = [NSCursor crosshairCursor];
56
- break;
57
- case RCTCursorDisappearingItem:
58
- cursor = [NSCursor disappearingItemCursor];
59
- break;
60
- case RCTCursorDragCopy:
61
- cursor = [NSCursor dragCopyCursor];
62
- break;
63
- case RCTCursorDragLink:
64
- cursor = [NSCursor dragLinkCursor];
65
- break;
66
- case RCTCursorIBeam:
67
- cursor = [NSCursor IBeamCursor];
68
- break;
69
- case RCTCursorIBeamCursorForVerticalLayout:
70
- cursor = [NSCursor IBeamCursorForVerticalLayout];
71
- break;
72
- case RCTCursorOpenHand:
73
- cursor = [NSCursor openHandCursor];
74
- break;
75
- case RCTCursorOperationNotAllowed:
76
- cursor = [NSCursor operationNotAllowedCursor];
77
- break;
78
- case RCTCursorPointingHand:
79
- cursor = [NSCursor pointingHandCursor];
80
- break;
81
- case RCTCursorResizeDown:
82
- cursor = [NSCursor resizeDownCursor];
83
- break;
84
- case RCTCursorResizeLeft:
85
- cursor = [NSCursor resizeLeftCursor];
86
- break;
87
- case RCTCursorResizeLeftRight:
88
- cursor = [NSCursor resizeLeftRightCursor];
89
- break;
90
- case RCTCursorResizeRight:
91
- cursor = [NSCursor resizeRightCursor];
92
- break;
93
- case RCTCursorResizeUp:
94
- cursor = [NSCursor resizeUpCursor];
95
- break;
96
- case RCTCursorResizeUpDown:
97
- cursor = [NSCursor resizeUpDownCursor];
98
- break;
99
- }
100
-
101
- return cursor;
102
- }
103
- #endif // macOS]
104
-
105
- @end