@fluentui-react-native/focus-zone 0.11.1 → 0.11.2

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.json CHANGED
@@ -2,7 +2,22 @@
2
2
  "name": "@fluentui-react-native/focus-zone",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 09 Nov 2022 22:50:45 GMT",
5
+ "date": "Thu, 10 Nov 2022 02:05:14 GMT",
6
+ "tag": "@fluentui-react-native/focus-zone_v0.11.2",
7
+ "version": "0.11.2",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "email not defined",
12
+ "package": "@fluentui-react-native/focus-zone",
13
+ "commit": "6f086d9beaa1aea80f475f62d8bdb80f3c855c83",
14
+ "comment": "Fix infinite loop in ContextualMenu"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Wed, 09 Nov 2022 22:52:11 GMT",
6
21
  "tag": "@fluentui-react-native/focus-zone_v0.11.1",
7
22
  "version": "0.11.1",
8
23
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Change Log - @fluentui-react-native/focus-zone
2
2
 
3
- This log was last generated on Wed, 09 Nov 2022 22:50:45 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 10 Nov 2022 02:05:14 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.11.2
8
+
9
+ Thu, 10 Nov 2022 02:05:14 GMT
10
+
11
+ ### Patches
12
+
13
+ - Fix infinite loop in ContextualMenu (email not defined)
14
+
7
15
  ## 0.11.1
8
16
 
9
- Wed, 09 Nov 2022 22:50:45 GMT
17
+ Wed, 09 Nov 2022 22:52:11 GMT
10
18
 
11
19
  ### Patches
12
20
 
@@ -1 +1 @@
1
- {"version":3,"file":"FocusZone.d.ts","sourceRoot":"","sources":["../src/FocusZone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAiB,MAAM,mBAAmB,CAAC;AAUtF,eAAO,MAAM,SAAS,uPA8BpB,CAAC"}
1
+ {"version":3,"file":"FocusZone.d.ts","sourceRoot":"","sources":["../src/FocusZone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAiB,MAAM,mBAAmB,CAAC;AAUtF,eAAO,MAAM,SAAS,uPA6BpB,CAAC"}
package/lib/FocusZone.js CHANGED
@@ -21,7 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  import * as React from 'react';
24
- import { findNodeHandle, Platform } from 'react-native';
24
+ import { findNodeHandle } from 'react-native';
25
25
  import { composable } from '@uifabricshared/foundation-composable';
26
26
  import { mergeSettings } from '@uifabricshared/foundation-settings';
27
27
  import { useViewCommandFocus } from '@fluentui-react-native/interactive-hooks';
@@ -30,7 +30,7 @@ var RCTFocusZone = ensureNativeComponent('RCTFocusZone');
30
30
  var filterOutComponentRef = function (propName) { return propName !== 'componentRef'; };
31
31
  export var FocusZone = composable({
32
32
  usePrepareProps: function (userProps, useStyling) {
33
- var componentRef = userProps.componentRef, defaultTabbableElement = userProps.defaultTabbableElement, isCircularNavigation = userProps.isCircularNavigation, forceFocusMacOS = userProps.forceFocusMacOS, rest = __rest(userProps, ["componentRef", "defaultTabbableElement", "isCircularNavigation", "forceFocusMacOS"]);
33
+ var componentRef = userProps.componentRef, defaultTabbableElement = userProps.defaultTabbableElement, isCircularNavigation = userProps.isCircularNavigation, rest = __rest(userProps, ["componentRef", "defaultTabbableElement", "isCircularNavigation"]);
34
34
  var ftzRef = useViewCommandFocus(componentRef);
35
35
  var _a = React.useState(undefined), targetNativeTag = _a[0], setTargetNativeTag = _a[1];
36
36
  React.useLayoutEffect(function () {
@@ -43,7 +43,7 @@ export var FocusZone = composable({
43
43
  }, [defaultTabbableElement]);
44
44
  return {
45
45
  slotProps: mergeSettings(useStyling(userProps), {
46
- root: __assign(__assign(__assign({}, rest), (Platform.OS === 'macos' && { forceFocus: forceFocusMacOS })), { defaultTabbableElement: targetNativeTag, ref: ftzRef, navigateAtEnd: isCircularNavigation ? 'NavigateWrap' : 'NavigateStopAtEnds' }),
46
+ root: __assign(__assign({}, rest), { defaultTabbableElement: targetNativeTag, ref: ftzRef, navigateAtEnd: isCircularNavigation ? 'NavigateWrap' : 'NavigateStopAtEnds' }),
47
47
  }),
48
48
  };
49
49
  },
@@ -1 +1 @@
1
- {"version":3,"file":"FocusZone.js","sourceRoot":"","sources":["../src/FocusZone.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAe,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,IAAM,YAAY,GAAG,qBAAqB,CAAC,cAAc,CAAC,CAAC;AAE3D,IAAM,qBAAqB,GAAG,UAAC,QAAQ,IAAK,OAAA,QAAQ,KAAK,cAAc,EAA3B,CAA2B,CAAC;AAExE,MAAM,CAAC,IAAM,SAAS,GAAG,UAAU,CAAgB;IACjD,eAAe,EAAE,UAAC,SAAyB,EAAE,UAAsC;QACzE,IAAA,YAAY,GAA6E,SAAS,aAAtF,EAAE,sBAAsB,GAAqD,SAAS,uBAA9D,EAAE,oBAAoB,GAA+B,SAAS,qBAAxC,EAAE,eAAe,GAAc,SAAS,gBAAvB,EAAK,IAAI,UAAK,SAAS,EAApG,qFAAwF,CAAF,CAAe;QAE3G,IAAM,MAAM,GAA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,MAAM,EAAE,qBAAqB,EAAE;KAChE;CACF,CAAC,CAAC"}
@@ -14,48 +14,26 @@ export interface FocusZoneProps {
14
14
  */
15
15
  defaultTabbableElement?: React.RefObject<React.Component>;
16
16
  /**
17
- ** Defines which arrow keys to react to
17
+ ** Defines which arrows to react to
18
18
  */
19
19
  focusZoneDirection?: FocusZoneDirection;
20
20
  /**
21
- * Disables the FocusZone, with slightly different behavior on macOS and win32.
22
- * On win32, the FocusZone will not be tabbable and keyboard navigation will be disabled.
23
- * on macOS, the FocusZone will "pass through" events, and the children will respond as if there was no FocusZone.
21
+ ** If set, the FocusZone will not be tabbable and keyboard navigation will be disabled
24
22
  */
25
23
  disabled?: boolean;
26
- /**
27
- * Circular Navigation prop
28
- * @platform win32
29
- */
30
24
  isCircularNavigation?: boolean;
31
25
  /**
32
- * Allows for 2D navigation. This navigation strategy takes into account the position of elements
33
- * on screen, and navigates in the direction the user selects to the nearest element.
34
- * @platform win32
26
+ *Allows for 2D navigation. This navigation strategy takes into account the position of elements
27
+ on screen, and navigates in the direction the user selects to the nearest element.
35
28
  */
36
29
  use2DNavigation?: boolean;
37
- /**
38
- * Moves focus between all focusable views, rather than just key views.
39
- *
40
- * On macOS, not every focusable view is a key view (i.e: we can press Tab to move focus to it).
41
- * Rather, there is a system preference to toggle which views are in the key view loop.
42
- * This prop allows you to focus on all focusable views, rather than just key views.
43
- * For more info, see https://microsoft.github.io/apple-ux-guide/KeyboardFocus.html
44
- * @platform macOS
45
- */
46
- forceFocusMacOS?: boolean;
47
30
  /**
48
31
  * Callback called when “focus” event triggered in FocusZone
49
32
  */
50
33
  onFocus?: (e?: any) => void;
51
34
  }
52
- interface NonNativeProps {
53
- isCircularNavigation: FocusZoneProps['isCircularNavigation'];
54
- forceFocusMacOS: FocusZoneProps['forceFocusMacOS'];
55
- }
56
- export interface NativeProps extends Exclude<FocusZoneProps, NonNativeProps> {
35
+ export interface NativeProps extends Omit<FocusZoneProps, 'isCircularNavigation'> {
57
36
  navigateAtEnd?: NavigateAtEnd;
58
- forceFocus?: boolean;
59
37
  }
60
38
  export declare type FocusZoneDirection = 'bidirectional' /** React to all arrows. */ | 'vertical' /** Only react to up/down arrows. */ | 'horizontal' /** Only react to left/right arrows. */ | 'none'; /** Doesn't respond to any arrow keys. */
61
39
  export declare type NavigateAtEnd = 'NavigateStopAtEnds' | 'NavigateWrap' | 'NavigateContinue';
@@ -71,5 +49,4 @@ export interface FocusZoneType {
71
49
  slotProps: FocusZoneSlotProps;
72
50
  state: FocusZoneState;
73
51
  }
74
- export {};
75
52
  //# sourceMappingURL=FocusZone.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FocusZone.types.d.ts","sourceRoot":"","sources":["../src/FocusZone.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpE,eAAO,MAAM,aAAa,cAAc,CAAC;AAEzC,MAAM,WAAW,cAAc;CAAG;AAElC,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAE3C;;OAEG;IACH,sBAAsB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAE1D;;OAEG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,C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}
1
+ {"version":3,"file":"FocusZone.d.ts","sourceRoot":"","sources":["../src/FocusZone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAiB,MAAM,mBAAmB,CAAC;AAUtF,eAAO,MAAM,SAAS,uPA6BpB,CAAC"}
@@ -52,7 +52,7 @@ var RCTFocusZone = (0, component_cache_1.ensureNativeComponent)('RCTFocusZone');
52
52
  var filterOutComponentRef = function (propName) { return propName !== 'componentRef'; };
53
53
  exports.FocusZone = (0, foundation_composable_1.composable)({
54
54
  usePrepareProps: function (userProps, useStyling) {
55
- var componentRef = userProps.componentRef, defaultTabbableElement = userProps.defaultTabbableElement, isCircularNavigation = userProps.isCircularNavigation, forceFocusMacOS = userProps.forceFocusMacOS, rest = __rest(userProps, ["componentRef", "defaultTabbableElement", "isCircularNavigation", "forceFocusMacOS"]);
55
+ var componentRef = userProps.componentRef, defaultTabbableElement = userProps.defaultTabbableElement, isCircularNavigation = userProps.isCircularNavigation, rest = __rest(userProps, ["componentRef", "defaultTabbableElement", "isCircularNavigation"]);
56
56
  var ftzRef = (0, interactive_hooks_1.useViewCommandFocus)(componentRef);
57
57
  var _a = React.useState(undefined), targetNativeTag = _a[0], setTargetNativeTag = _a[1];
58
58
  React.useLayoutEffect(function () {
@@ -65,7 +65,7 @@ exports.FocusZone = (0, foundation_composable_1.composable)({
65
65
  }, [defaultTabbableElement]);
66
66
  return {
67
67
  slotProps: (0, foundation_settings_1.mergeSettings)(useStyling(userProps), {
68
- root: __assign(__assign(__assign({}, rest), (react_native_1.Platform.OS === 'macos' && { forceFocus: forceFocusMacOS })), { defaultTabbableElement: targetNativeTag, ref: ftzRef, navigateAtEnd: isCircularNavigation ? 'NavigateWrap' : 'NavigateStopAtEnds' }),
68
+ root: __assign(__assign({}, rest), { defaultTabbableElement: targetNativeTag, ref: ftzRef, navigateAtEnd: isCircularNavigation ? 'NavigateWrap' : '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ACpB,IAAI,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,OAAO,EAAE;gBACnC,kBAAkB,CAAC,IAAA,6BAAc,EAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC;aACpE;iBAAM;gBACL,kBAAkB,CAAC,SAAS,CAAC,CAAC;aAC/B;QACH,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAE7B,OAAO;YACL,SAAS,EAAE,IAAA,mCAAa,EAAqB,UAAU,CAAC,SAAS,CAAC,EAAE;gBAClE,IAAI,wBACC,IAAI,KACP,sBAAsB,EAAE,eAAe,EACvC,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,oBAAoB,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,oBAAoB,GAC5E;aACF,CAAC;SACH,CAAC;IACJ,CAAC;IACD,KAAK,EAAE;QACL,IAAI,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,qBAAqB,EAAE;KAChE;CACF,CAAC,CAAC"}
@@ -14,48 +14,26 @@ export interface FocusZoneProps {
14
14
  */
15
15
  defaultTabbableElement?: React.RefObject<React.Component>;
16
16
  /**
17
- ** Defines which arrow keys to react to
17
+ ** Defines which arrows to react to
18
18
  */
19
19
  focusZoneDirection?: FocusZoneDirection;
20
20
  /**
21
- * Disables the FocusZone, with slightly different behavior on macOS and win32.
22
- * On win32, the FocusZone will not be tabbable and keyboard navigation will be disabled.
23
- * on macOS, the FocusZone will "pass through" events, and the children will respond as if there was no FocusZone.
21
+ ** If set, the FocusZone will not be tabbable and keyboard navigation will be disabled
24
22
  */
25
23
  disabled?: boolean;
26
- /**
27
- * Circular Navigation prop
28
- * @platform win32
29
- */
30
24
  isCircularNavigation?: boolean;
31
25
  /**
32
- * Allows for 2D navigation. This navigation strategy takes into account the position of elements
33
- * on screen, and navigates in the direction the user selects to the nearest element.
34
- * @platform win32
26
+ *Allows for 2D navigation. This navigation strategy takes into account the position of elements
27
+ on screen, and navigates in the direction the user selects to the nearest element.
35
28
  */
36
29
  use2DNavigation?: boolean;
37
- /**
38
- * Moves focus between all focusable views, rather than just key views.
39
- *
40
- * On macOS, not every focusable view is a key view (i.e: we can press Tab to move focus to it).
41
- * Rather, there is a system preference to toggle which views are in the key view loop.
42
- * This prop allows you to focus on all focusable views, rather than just key views.
43
- * For more info, see https://microsoft.github.io/apple-ux-guide/KeyboardFocus.html
44
- * @platform macOS
45
- */
46
- forceFocusMacOS?: boolean;
47
30
  /**
48
31
  * Callback called when “focus” event triggered in FocusZone
49
32
  */
50
33
  onFocus?: (e?: any) => void;
51
34
  }
52
- interface NonNativeProps {
53
- isCircularNavigation: FocusZoneProps['isCircularNavigation'];
54
- forceFocusMacOS: FocusZoneProps['forceFocusMacOS'];
55
- }
56
- export interface NativeProps extends Exclude<FocusZoneProps, NonNativeProps> {
35
+ export interface NativeProps extends Omit<FocusZoneProps, 'isCircularNavigation'> {
57
36
  navigateAtEnd?: NavigateAtEnd;
58
- forceFocus?: boolean;
59
37
  }
60
38
  export declare type FocusZoneDirection = 'bidirectional' /** React to all arrows. */ | 'vertical' /** Only react to up/down arrows. */ | 'horizontal' /** Only react to left/right arrows. */ | 'none'; /** Doesn't respond to any arrow keys. */
61
39
  export declare type NavigateAtEnd = 'NavigateStopAtEnds' | 'NavigateWrap' | 'NavigateContinue';
@@ -71,5 +49,4 @@ export interface FocusZoneType {
71
49
  slotProps: FocusZoneSlotProps;
72
50
  state: FocusZoneState;
73
51
  }
74
- export {};
75
52
  //# sourceMappingURL=FocusZone.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FocusZone.types.d.ts","sourceRoot":"","sources":["../src/FocusZone.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpE,eAAO,MAAM,a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GACpB,cAAc,GACd,kBAAkB,CAAC;AAEvB,MAAM,WAAW,eAAe;CAAG;AAEnC,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,oBAAY,mBAAmB,GAAG,WAAW,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;AAElF,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,KAAK,EAAE,cAAc,CAAC;CACvB"}
@@ -13,7 +13,6 @@ typedef NS_ENUM(NSInteger, FocusZoneDirection) {
13
13
  @interface RCTFocusZone : RCTView
14
14
 
15
15
  @property(nonatomic) BOOL disabled;
16
- @property(nonatomic) BOOL forceFocus;
17
16
  @property(nonatomic) FocusZoneDirection focusZoneDirection;
18
17
  @property(nonatomic) NSString *navigateAtEnd;
19
18
  @property(nonatomic) NSView *defaultKeyView;
@@ -18,31 +18,53 @@ typedef BOOL (^IsViewLeadingCandidateForNextFocus)(NSView *candidateView);
18
18
  // enumerated in the same row (or column) as the current focused view
19
19
  static const CGFloat FocusZoneBuffer = 3;
20
20
 
21
+ @implementation RCTFocusZone
22
+
23
+ static inline CGFloat GetDistanceBetweenPoints(NSPoint point1, NSPoint point2)
24
+ {
25
+ NSPoint delta = NSMakePoint(point1.x - point2.x, point1.y - point2.y);
26
+ return sqrt(delta.x * delta.x + delta.y * delta.y);
27
+ }
28
+
29
+ static inline CGFloat GetDistanceBetweenRects(NSRect rect1, NSRect rect2)
30
+ {
31
+ // Get the top left corner of the rect, top right in RTL
32
+ bool isRTL = [[RCTI18nUtil sharedInstance] isRTL];
33
+
34
+ CGFloat rect1Offset = isRTL ? rect1.size.width : 0;
35
+ CGFloat rect2Offset = isRTL ? rect2.size.width : 0;
36
+
37
+ NSPoint rect1Corner = NSMakePoint(rect1.origin.x + rect1Offset , rect1.origin.y);
38
+ NSPoint rect2Corner = NSMakePoint(rect2.origin.x + rect2Offset , rect2.origin.y);
39
+
40
+ return GetDistanceBetweenPoints(rect1Corner, rect2Corner);
41
+ }
21
42
 
22
- /// Returns whether FocusZone should move focus on the view in question.
23
- /// - Parameters:
24
- /// - view: The view to check if we should move focus to, should be a child / subview of the FocusZone in question.
25
- /// - forceFocus: Check if we should focus on all views that accept first responder status, rather than just key views.
26
- BOOL ShouldFocusOnView(NSView *view, BOOL focusOnAllFirstResponders)
43
+ static inline CGFloat GetMinDistanceBetweenRectVerticesAndPoint(NSRect rect, NSPoint point)
27
44
  {
28
- return focusOnAllFirstResponders ? [view acceptsFirstResponder] : [view canBecomeKeyView];
45
+ return fmin(
46
+ fmin(GetDistanceBetweenPoints(point, NSMakePoint(NSMinX(rect), NSMinY(rect))),
47
+ GetDistanceBetweenPoints(point, NSMakePoint(NSMaxX(rect), NSMaxY(rect)))),
48
+ fmin(GetDistanceBetweenPoints(point, NSMakePoint(NSMaxX(rect), NSMinY(rect))),
49
+ GetDistanceBetweenPoints(point, NSMakePoint(NSMinX(rect), NSMaxY(rect))))
50
+ );
29
51
  }
30
52
 
31
53
  /// Performs a depth first search looking for the first key view in a parent view's view hierarchy.
32
54
  /// This function does not take into account the geometric position of the view.
33
- static NSView *GetFirstKeyViewWithin(NSView *parentView, BOOL forceFocus)
55
+ static NSView *GetFirstKeyViewWithin(NSView *parentView)
34
56
  {
35
- if ([[parentView subviews] count] < 1)
36
- {
37
- return nil;
38
- }
57
+ if ([[parentView subviews] count] < 1)
58
+ {
59
+ return nil;
60
+ }
39
61
 
40
62
  for (NSView *view in [parentView subviews]) {
41
- if (ShouldFocusOnView(view, forceFocus)) {
63
+ if ([view canBecomeKeyView]) {
42
64
  return view;
43
65
  }
44
66
 
45
- NSView *match = GetFirstKeyViewWithin(view, forceFocus);
67
+ NSView *match = GetFirstKeyViewWithin(view);
46
68
  if (match) {
47
69
  return match;
48
70
  }
@@ -53,14 +75,14 @@ static NSView *GetFirstKeyViewWithin(NSView *parentView, BOOL forceFocus)
53
75
  /// Performs a depth first search looking for the last key view in a parent view's view hierarchy.
54
76
  /// We find the last view by simply reversing the order of the subview array.
55
77
  /// This function does not take into account the geometric position of the view.
56
- static NSView *GetLastKeyViewWithin(NSView *parentView, BOOL forceFocus)
78
+ static NSView *GetLastKeyViewWithin(NSView *parentView)
57
79
  {
58
80
  for (NSView *view in [[parentView subviews] reverseObjectEnumerator]) {
59
- if (ShouldFocusOnView(view, forceFocus)) {
81
+ if ([view canBecomeKeyView]) {
60
82
  return view;
61
83
  }
62
84
 
63
- NSView *match = GetLastKeyViewWithin(view, forceFocus);
85
+ NSView *match = GetLastKeyViewWithin(view);
64
86
  if (match) {
65
87
  return match;
66
88
  }
@@ -68,38 +90,6 @@ static NSView *GetLastKeyViewWithin(NSView *parentView, BOOL forceFocus)
68
90
  return nil;
69
91
  }
70
92
 
71
- static inline CGFloat GetDistanceBetweenPoints(NSPoint point1, NSPoint point2)
72
- {
73
- NSPoint delta = NSMakePoint(point1.x - point2.x, point1.y - point2.y);
74
- return sqrt(delta.x * delta.x + delta.y * delta.y);
75
- }
76
-
77
- static inline CGFloat GetDistanceBetweenRects(NSRect rect1, NSRect rect2)
78
- {
79
- // Get the top left corner of the rect, top right in RTL
80
- bool isRTL = [[RCTI18nUtil sharedInstance] isRTL];
81
-
82
- CGFloat rect1Offset = isRTL ? rect1.size.width : 0;
83
- CGFloat rect2Offset = isRTL ? rect2.size.width : 0;
84
-
85
- NSPoint rect1Corner = NSMakePoint(rect1.origin.x + rect1Offset , rect1.origin.y);
86
- NSPoint rect2Corner = NSMakePoint(rect2.origin.x + rect2Offset , rect2.origin.y);
87
-
88
- return GetDistanceBetweenPoints(rect1Corner, rect2Corner);
89
- }
90
-
91
- static inline CGFloat GetMinDistanceBetweenRectVerticesAndPoint(NSRect rect, NSPoint point)
92
- {
93
- return fmin(
94
- fmin(GetDistanceBetweenPoints(point, NSMakePoint(NSMinX(rect), NSMinY(rect))),
95
- GetDistanceBetweenPoints(point, NSMakePoint(NSMaxX(rect), NSMaxY(rect)))),
96
- fmin(GetDistanceBetweenPoints(point, NSMakePoint(NSMaxX(rect), NSMinY(rect))),
97
- GetDistanceBetweenPoints(point, NSMakePoint(NSMinX(rect), NSMaxY(rect))))
98
- );
99
- }
100
-
101
- /// Returns the first NSView in the given windows NSResponder chain.
102
- /// - Parameter window: The window whose NSResponder chain we should check.
103
93
  static NSView *GetFirstResponder(NSWindow *window)
104
94
  {
105
95
  NSResponder *responder = [window firstResponder];
@@ -110,9 +100,6 @@ static NSView *GetFirstResponder(NSWindow *window)
110
100
  return [responder isKindOfClass:[NSView class]] ? (NSView *)responder : nil;
111
101
  }
112
102
 
113
-
114
- /// Returns a `FocusZoneAction` for a given NSEvent
115
- /// - Parameter event: The event to interpret into a command. Should be a keyDown event.
116
103
  static FocusZoneAction GetActionForEvent(NSEvent *event)
117
104
  {
118
105
  FocusZoneAction action = FocusZoneActionNone;
@@ -183,39 +170,32 @@ static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
183
170
  return focusZoneAncestor;
184
171
  }
185
172
 
186
- @implementation RCTFocusZone
187
-
188
- - (NSView *)firstFocusableView
173
+ /// Bypass FocusZone if it's empty or has no focusable elements
174
+ static BOOL ShouldSkipFocusZone(NSView *view)
189
175
  {
190
- return GetFirstKeyViewWithin(self, [self forceFocus]);
191
- }
176
+ if([view isKindOfClass:[RCTFocusZone class]])
177
+ {
178
+ NSView *keyView = GetFirstKeyViewWithin(view);
179
+ // FocusZone is empty or has no focusable elements
180
+ if (keyView == nil)
181
+ {
182
+ return YES;
183
+ }
184
+ }
192
185
 
193
- - (NSView *)lastFocusableView
194
- {
195
- return GetLastKeyViewWithin(self, [self forceFocus]);
186
+ return NO;
196
187
  }
197
188
 
198
- /// Accept firstResponder on FocusZone itself in order to reassign it within the FocusZone with `becomeFirstResponder`.
199
- /// Reject firstResponder if FocusZone is disabled or should be skipped.
189
+ /// Accept firstResponder on FocusZone itself in order to reassign it within the FocusZone.
200
190
  - (BOOL)acceptsFirstResponder
201
191
  {
202
- BOOL rejectsResponderStatus = NO;
203
- if (!_disabled) {
204
- // Bypass FocusZone if it's empty or has no focusable elements
205
- NSView *focusableView = [self firstFocusableView];
206
- // FocusZone is empty or has no focusable elements
207
- if (focusableView == nil)
208
- {
209
- rejectsResponderStatus = YES;
210
- }
211
- }
212
- return !rejectsResponderStatus;
192
+ // Reject first responder if FocusZone is disabled or should be skipped.
193
+ return !_disabled && !ShouldSkipFocusZone(self);
213
194
  }
214
195
 
215
- /// Reassign firstResponder within the FocusZone to either the default key view or first focusable view.
216
196
  - (BOOL)becomeFirstResponder
217
197
  {
218
- NSView *keyView = _defaultKeyView ?: [self firstFocusableView];
198
+ NSView *keyView = _defaultKeyView ?: GetFirstKeyViewWithin(self);
219
199
  return !_disabled && [[self window] makeFirstResponder:keyView];
220
200
  }
221
201
 
@@ -230,9 +210,7 @@ static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
230
210
  NSView *candidateView = [queue firstObject];
231
211
  [queue removeObjectAtIndex:0];
232
212
 
233
- if ([candidateView isNotEqualTo:self] &&
234
- ShouldFocusOnView(candidateView, [self forceFocus]) &&
235
- isLeadingCandidate(candidateView))
213
+ if ([candidateView isNotEqualTo:self] && [candidateView canBecomeKeyView] && isLeadingCandidate(candidateView))
236
214
  {
237
215
  nextViewToFocus = candidateView;
238
216
  }
@@ -303,7 +281,7 @@ static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
303
281
  if (!skip)
304
282
  {
305
283
  CGFloat distance = GetDistanceBetweenRects(firstResponderRect, candidateRect);
306
-
284
+
307
285
  // If there are other candidate views inside the same ScrollView as the firstResponder,
308
286
  // prefer those views over other views outside the scrollview, even if they are closer.
309
287
  if ([firstResponderEnclosingScrollView isEqualTo:[candidateView enclosingScrollView]])
@@ -378,11 +356,11 @@ static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
378
356
  {
379
357
  if (action == FocusZoneActionDownArrow)
380
358
  {
381
- return [self firstFocusableView];
359
+ return GetFirstKeyViewWithin(self);
382
360
  }
383
361
  else if (action == FocusZoneActionUpArrow)
384
362
  {
385
- return [self lastFocusableView];
363
+ return GetLastKeyViewWithin(self);
386
364
  }
387
365
  }
388
366
 
@@ -409,7 +387,7 @@ static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
409
387
  NSView *nextViewToFocus;
410
388
 
411
389
  [[self window] recalculateKeyViewLoop];
412
-
390
+
413
391
  // Find the first view outside the FocusZone (or any parent FocusZones) to place focus
414
392
  RCTFocusZone *focusZoneAncestor = GetFocusZoneAncestor(self);
415
393
 
@@ -440,7 +418,7 @@ static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
440
418
  }
441
419
  nextViewToFocus = [nextViewToFocus previousValidKeyView];
442
420
  }
443
-
421
+
444
422
  // If the previous view is in a FocusZone, focus on its defaultKeyView
445
423
  // (For FocusZoneActionTab, this is handled by becomeFirstResponder).
446
424
  RCTFocusZone *focusZoneAncestor = GetFocusZoneAncestor(nextViewToFocus);
@@ -7,8 +7,6 @@
7
7
 
8
8
  RCT_EXPORT_MODULE()
9
9
 
10
- RCT_EXPORT_VIEW_PROPERTY(forceFocus, BOOL)
11
-
12
10
  RCT_EXPORT_VIEW_PROPERTY(disabled, BOOL)
13
11
 
14
12
  RCT_CUSTOM_VIEW_PROPERTY(focusZoneDirection, NSString, RCTFocusZone)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-react-native/focus-zone",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "A cross-platform FocusZone component using the Fluent Design System",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
package/src/FocusZone.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { findNodeHandle, Platform } from 'react-native';
2
+ import { findNodeHandle } from 'react-native';
3
3
  import { FocusZoneProps, FocusZoneSlotProps, FocusZoneType } from './FocusZone.types';
4
4
  import { IUseStyling, composable } from '@uifabricshared/foundation-composable';
5
5
  import { mergeSettings } from '@uifabricshared/foundation-settings';
@@ -12,7 +12,7 @@ const filterOutComponentRef = (propName) => propName !== 'componentRef';
12
12
 
13
13
  export const FocusZone = composable<FocusZoneType>({
14
14
  usePrepareProps: (userProps: FocusZoneProps, useStyling: IUseStyling<FocusZoneType>) => {
15
- const { componentRef, defaultTabbableElement, isCircularNavigation, forceFocusMacOS, ...rest } = userProps;
15
+ const { componentRef, defaultTabbableElement, isCircularNavigation, ...rest } = userProps;
16
16
 
17
17
  const ftzRef = useViewCommandFocus(componentRef);
18
18
 
@@ -29,7 +29,6 @@ export const FocusZone = composable<FocusZoneType>({
29
29
  slotProps: mergeSettings<FocusZoneSlotProps>(useStyling(userProps), {
30
30
  root: {
31
31
  ...rest,
32
- ...(Platform.OS === 'macos' && { forceFocus: forceFocusMacOS }),
33
32
  defaultTabbableElement: targetNativeTag,
34
33
  ref: ftzRef,
35
34
  navigateAtEnd: isCircularNavigation ? 'NavigateWrap' : 'NavigateStopAtEnds',
@@ -18,55 +18,32 @@ export interface FocusZoneProps {
18
18
  defaultTabbableElement?: React.RefObject<React.Component>;
19
19
 
20
20
  /**
21
- ** Defines which arrow keys to react to
21
+ ** Defines which arrows to react to
22
22
  */
23
23
  focusZoneDirection?: FocusZoneDirection;
24
24
 
25
25
  /**
26
- * Disables the FocusZone, with slightly different behavior on macOS and win32.
27
- * On win32, the FocusZone will not be tabbable and keyboard navigation will be disabled.
28
- * on macOS, the FocusZone will "pass through" events, and the children will respond as if there was no FocusZone.
26
+ ** If set, the FocusZone will not be tabbable and keyboard navigation will be disabled
29
27
  */
30
28
  disabled?: boolean;
31
29
 
32
- /**
33
- * Circular Navigation prop
34
- * @platform win32
35
- */
30
+ /* Circular Navigation prop */
36
31
  isCircularNavigation?: boolean;
37
32
 
38
33
  /**
39
- * Allows for 2D navigation. This navigation strategy takes into account the position of elements
40
- * on screen, and navigates in the direction the user selects to the nearest element.
41
- * @platform win32
34
+ *Allows for 2D navigation. This navigation strategy takes into account the position of elements
35
+ on screen, and navigates in the direction the user selects to the nearest element.
42
36
  */
43
37
  use2DNavigation?: boolean;
44
38
 
45
- /**
46
- * Moves focus between all focusable views, rather than just key views.
47
- *
48
- * On macOS, not every focusable view is a key view (i.e: we can press Tab to move focus to it).
49
- * Rather, there is a system preference to toggle which views are in the key view loop.
50
- * This prop allows you to focus on all focusable views, rather than just key views.
51
- * For more info, see https://microsoft.github.io/apple-ux-guide/KeyboardFocus.html
52
- * @platform macOS
53
- */
54
- forceFocusMacOS?: boolean;
55
-
56
39
  /**
57
40
  * Callback called when “focus” event triggered in FocusZone
58
41
  */
59
42
  onFocus?: (e?: any) => void;
60
43
  }
61
44
 
62
- // Props on JS FocusZone that don't exist in the native module
63
- interface NonNativeProps {
64
- isCircularNavigation: FocusZoneProps['isCircularNavigation'];
65
- forceFocusMacOS: FocusZoneProps['forceFocusMacOS'];
66
- }
67
- export interface NativeProps extends Exclude<FocusZoneProps, NonNativeProps> {
68
- navigateAtEnd?: NavigateAtEnd; // win32 only
69
- forceFocus?: boolean; // macOS only
45
+ export interface NativeProps extends Omit<FocusZoneProps, 'isCircularNavigation'> {
46
+ navigateAtEnd?: NavigateAtEnd;
70
47
  }
71
48
 
72
49
  export type FocusZoneDirection =