@fluentui-react-native/focus-zone 0.10.28 → 0.10.30

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,37 @@
2
2
  "name": "@fluentui-react-native/focus-zone",
3
3
  "entries": [
4
4
  {
5
- "date": "Tue, 25 Oct 2022 22:45:42 GMT",
5
+ "date": "Thu, 27 Oct 2022 21:01:07 GMT",
6
+ "tag": "@fluentui-react-native/focus-zone_v0.10.30",
7
+ "version": "0.10.30",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "sanajmi@microsoft.com",
12
+ "package": "@fluentui-react-native/focus-zone",
13
+ "commit": "d5c85eced1b43510215dc7aa7f79a3db80616ce7",
14
+ "comment": "FocusZone (macOS): New prop to ignore OS keyboard shortcut preference"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Thu, 27 Oct 2022 11:09:35 GMT",
21
+ "tag": "@fluentui-react-native/focus-zone_v0.10.29",
22
+ "version": "0.10.29",
23
+ "comments": {
24
+ "patch": [
25
+ {
26
+ "author": "beachball",
27
+ "package": "@fluentui-react-native/focus-zone",
28
+ "comment": "Bump @fluentui-react-native/interactive-hooks to v0.19.4",
29
+ "commit": "ceeb4be38b8e0008315f65711c064c5fbd3d8bb8"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Tue, 25 Oct 2022 22:47:45 GMT",
6
36
  "tag": "@fluentui-react-native/focus-zone_v0.10.28",
7
37
  "version": "0.10.28",
8
38
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,28 @@
1
1
  # Change Log - @fluentui-react-native/focus-zone
2
2
 
3
- This log was last generated on Tue, 25 Oct 2022 22:45:42 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 27 Oct 2022 21:01:07 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.10.30
8
+
9
+ Thu, 27 Oct 2022 21:01:07 GMT
10
+
11
+ ### Patches
12
+
13
+ - FocusZone (macOS): New prop to ignore OS keyboard shortcut preference (sanajmi@microsoft.com)
14
+
15
+ ## 0.10.29
16
+
17
+ Thu, 27 Oct 2022 11:09:35 GMT
18
+
19
+ ### Patches
20
+
21
+ - Bump @fluentui-react-native/interactive-hooks to v0.19.4
22
+
7
23
  ## 0.10.28
8
24
 
9
- Tue, 25 Oct 2022 22:45:42 GMT
25
+ Tue, 25 Oct 2022 22:47:45 GMT
10
26
 
11
27
  ### Patches
12
28
 
@@ -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,uPA6BpB,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,uPA8BpB,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 } from 'react-native';
24
+ import { findNodeHandle, Platform } 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, rest = __rest(userProps, ["componentRef", "defaultTabbableElement", "isCircularNavigation"]);
33
+ var componentRef = userProps.componentRef, defaultTabbableElement = userProps.defaultTabbableElement, isCircularNavigation = userProps.isCircularNavigation, forceFocusMacOS = userProps.forceFocusMacOS, rest = __rest(userProps, ["componentRef", "defaultTabbableElement", "isCircularNavigation", "forceFocusMacOS"]);
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({}, rest), { defaultTabbableElement: targetNativeTag, ref: ftzRef, navigateAtEnd: isCircularNavigation ? 'NavigateWrap' : 'NavigateStopAtEnds' }),
46
+ root: __assign(__assign(__assign({}, rest), (Platform.OS === 'macos' ? { forceFocus: forceFocusMacOS } : null)), { 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,MAAM,cAAc,CAAC;AAE9C,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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,CAAC;aAC/B;QACH,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAE7B,OAAO;YACL,SAAS,EAAE,aAAa,CAAqB,UAAU,CAAC,SAAS,CAAC,EAAE;gBAClE,IAAI,iCACC,IAAI,GACJ,CAAC,QAAQ,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KACrE,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,26 +14,48 @@ export interface FocusZoneProps {
14
14
  */
15
15
  defaultTabbableElement?: React.RefObject<React.Component>;
16
16
  /**
17
- ** Defines which arrows to react to
17
+ ** Defines which arrow keys to react to
18
18
  */
19
19
  focusZoneDirection?: FocusZoneDirection;
20
20
  /**
21
- ** If set, the FocusZone will not be tabbable and keyboard navigation will be disabled
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.
22
24
  */
23
25
  disabled?: boolean;
26
+ /**
27
+ * Circular Navigation prop
28
+ * @platform win32
29
+ */
24
30
  isCircularNavigation?: boolean;
25
31
  /**
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.
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
28
35
  */
29
36
  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;
30
47
  /**
31
48
  * Callback called when “focus” event triggered in FocusZone
32
49
  */
33
50
  onFocus?: (e?: any) => void;
34
51
  }
35
- export interface NativeProps extends Omit<FocusZoneProps, 'isCircularNavigation'> {
52
+ interface NonNativeProps {
53
+ isCircularNavigation: FocusZoneProps['isCircularNavigation'];
54
+ forceFocusMacOS: FocusZoneProps['forceFocusMacOS'];
55
+ }
56
+ export interface NativeProps extends Exclude<FocusZoneProps, NonNativeProps> {
36
57
  navigateAtEnd?: NavigateAtEnd;
58
+ forceFocus?: boolean;
37
59
  }
38
60
  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. */
39
61
  export declare type NavigateAtEnd = 'NavigateStopAtEnds' | 'NavigateWrap' | 'NavigateContinue';
@@ -49,4 +71,5 @@ export interface FocusZoneType {
49
71
  slotProps: FocusZoneSlotProps;
50
72
  state: FocusZoneState;
51
73
  }
74
+ export {};
52
75
  //# 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;AA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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"}
@@ -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,uPA6BpB,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,uPA8BpB,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, rest = __rest(userProps, ["componentRef", "defaultTabbableElement", "isCircularNavigation"]);
55
+ var componentRef = userProps.componentRef, defaultTabbableElement = userProps.defaultTabbableElement, isCircularNavigation = userProps.isCircularNavigation, forceFocusMacOS = userProps.forceFocusMacOS, rest = __rest(userProps, ["componentRef", "defaultTabbableElement", "isCircularNavigation", "forceFocusMacOS"]);
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({}, rest), { defaultTabbableElement: targetNativeTag, ref: ftzRef, navigateAtEnd: isCircularNavigation ? 'NavigateWrap' : 'NavigateStopAtEnds' }),
68
+ root: __assign(__assign(__assign({}, rest), (react_native_1.Platform.OS === 'macos' ? { forceFocus: forceFocusMacOS } : null)), { defaultTabbableElement: targetNativeTag, ref: ftzRef, navigateAtEnd: isCircularNavigation ? 'NavigateWrap' : 'NavigateStopAtEnds' }),
69
69
  }),
70
70
  };
71
71
  },
@@ -1 +1 @@
1
- {"version":3,"file":"FocusZone.js","sourceRoot":"","sources":["../src/FocusZone.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA+B;AAC/B,6CAA8C;AAE9C,+EAAgF;AAChF,2EAAoE;AACpE,8EAA+E;AAC/E,0EAA+E;AAE/E,IAAM,YAAY,GAAG,IAAA,uCAAqB,EAAC,cAAc,CAAC,CAAC;AAE3D,IAAM,qBAAqB,GAAG,UAAC,QAAQ,IAAK,OAAA,QAAQ,KAAK,cAAc,EAA3B,CAA2B,CAAC;AAE3D,QAAA,SAAS,GAAG,IAAA,kCAAU,EAAgB;IACjD,eAAe,EAAE,UAAC,SAAyB,EAAE,UAAsC;QACzE,IAAA,YAAY,GAA4D,SAAS,aAArE,EAAE,sBAAsB,GAAoC,SAAS,uBAA7C,EAAE,oBAAoB,GAAc,SAAS,qBAAvB,EAAK,IAAI,UAAK,SAAS,EAAnF,kEAAuE,CAAF,CAAe;QAE1F,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-14,26 +14,48 @@ export interface FocusZoneProps {
14
14
  */
15
15
  defaultTabbableElement?: React.RefObject<React.Component>;
16
16
  /**
17
- ** Defines which arrows to react to
17
+ ** Defines which arrow keys to react to
18
18
  */
19
19
  focusZoneDirection?: FocusZoneDirection;
20
20
  /**
21
- ** If set, the FocusZone will not be tabbable and keyboard navigation will be disabled
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.
22
24
  */
23
25
  disabled?: boolean;
26
+ /**
27
+ * Circular Navigation prop
28
+ * @platform win32
29
+ */
24
30
  isCircularNavigation?: boolean;
25
31
  /**
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.
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
28
35
  */
29
36
  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;
30
47
  /**
31
48
  * Callback called when “focus” event triggered in FocusZone
32
49
  */
33
50
  onFocus?: (e?: any) => void;
34
51
  }
35
- export interface NativeProps extends Omit<FocusZoneProps, 'isCircularNavigation'> {
52
+ interface NonNativeProps {
53
+ isCircularNavigation: FocusZoneProps['isCircularNavigation'];
54
+ forceFocusMacOS: FocusZoneProps['forceFocusMacOS'];
55
+ }
56
+ export interface NativeProps extends Exclude<FocusZoneProps, NonNativeProps> {
36
57
  navigateAtEnd?: NavigateAtEnd;
58
+ forceFocus?: boolean;
37
59
  }
38
60
  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. */
39
61
  export declare type NavigateAtEnd = 'NavigateStopAtEnds' | 'NavigateWrap' | 'NavigateContinue';
@@ -49,4 +71,5 @@ export interface FocusZoneType {
49
71
  slotProps: FocusZoneSlotProps;
50
72
  state: FocusZoneState;
51
73
  }
74
+ export {};
52
75
  //# 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;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAGnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,cAAc,EAAE,sBAAsB,CAAC;IAC/E,aAAa,CAAC,EA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AE,OAAO,CAAC;IAE1B;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;CAC7B;AAGD,UAAU,cAAc;IACtB,oBAAoB,EAAE,cAAc,CAAC,sBAAsB,CAAC,CAAC;IAC7D,eAAe,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAC;CACpD;AACD,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC;IAC1E,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,oBAAY,kBAAkB,GAC1B,eAAe,CAAC,2BAA2B,GAC3C,UAAU,CAAC,oCAAoC,GAC/C,YAAY,CAAC,uCAAuC,GACpD,MAAM,CAAC,CAAC,yCAAyC;AAErD,oBAAY,aAAa,GACrB,oBAAoB,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,6 +13,7 @@ typedef NS_ENUM(NSInteger, FocusZoneDirection) {
13
13
  @interface RCTFocusZone : RCTView
14
14
 
15
15
  @property(nonatomic) BOOL disabled;
16
+ @property(nonatomic) BOOL forceFocus;
16
17
  @property(nonatomic) FocusZoneDirection focusZoneDirection;
17
18
  @property(nonatomic) NSString *navigateAtEnd;
18
19
  @property(nonatomic) NSView *defaultKeyView;
@@ -18,53 +18,31 @@ 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
- }
42
21
 
43
- static inline CGFloat GetMinDistanceBetweenRectVerticesAndPoint(NSRect rect, NSPoint point)
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)
44
27
  {
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
- );
28
+ return focusOnAllFirstResponders ? [view acceptsFirstResponder] : [view canBecomeKeyView];
51
29
  }
52
30
 
53
31
  /// Performs a depth first search looking for the first key view in a parent view's view hierarchy.
54
32
  /// This function does not take into account the geometric position of the view.
55
- static NSView *GetFirstKeyViewWithin(NSView *parentView)
33
+ static NSView *GetFirstKeyViewWithin(NSView *parentView, BOOL forceFocus)
56
34
  {
57
- if ([[parentView subviews] count] < 1)
58
- {
59
- return nil;
60
- }
35
+ if ([[parentView subviews] count] < 1)
36
+ {
37
+ return nil;
38
+ }
61
39
 
62
40
  for (NSView *view in [parentView subviews]) {
63
- if ([view canBecomeKeyView]) {
41
+ if (ShouldFocusOnView(view, forceFocus)) {
64
42
  return view;
65
43
  }
66
44
 
67
- NSView *match = GetFirstKeyViewWithin(view);
45
+ NSView *match = GetFirstKeyViewWithin(view, forceFocus);
68
46
  if (match) {
69
47
  return match;
70
48
  }
@@ -75,14 +53,14 @@ static NSView *GetFirstKeyViewWithin(NSView *parentView)
75
53
  /// Performs a depth first search looking for the last key view in a parent view's view hierarchy.
76
54
  /// We find the last view by simply reversing the order of the subview array.
77
55
  /// This function does not take into account the geometric position of the view.
78
- static NSView *GetLastKeyViewWithin(NSView *parentView)
56
+ static NSView *GetLastKeyViewWithin(NSView *parentView, BOOL forceFocus)
79
57
  {
80
58
  for (NSView *view in [[parentView subviews] reverseObjectEnumerator]) {
81
- if ([view canBecomeKeyView]) {
59
+ if (ShouldFocusOnView(view, forceFocus)) {
82
60
  return view;
83
61
  }
84
62
 
85
- NSView *match = GetLastKeyViewWithin(view);
63
+ NSView *match = GetLastKeyViewWithin(view, forceFocus);
86
64
  if (match) {
87
65
  return match;
88
66
  }
@@ -90,6 +68,38 @@ static NSView *GetLastKeyViewWithin(NSView *parentView)
90
68
  return nil;
91
69
  }
92
70
 
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.
93
103
  static NSView *GetFirstResponder(NSWindow *window)
94
104
  {
95
105
  NSResponder *responder = [window firstResponder];
@@ -100,6 +110,9 @@ static NSView *GetFirstResponder(NSWindow *window)
100
110
  return [responder isKindOfClass:[NSView class]] ? (NSView *)responder : nil;
101
111
  }
102
112
 
113
+
114
+ /// Returns a `FocusZoneAction` for a given NSEvent
115
+ /// - Parameter event: The event to interpret into a command. Should be a keyDown event.
103
116
  static FocusZoneAction GetActionForEvent(NSEvent *event)
104
117
  {
105
118
  FocusZoneAction action = FocusZoneActionNone;
@@ -170,32 +183,39 @@ static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
170
183
  return focusZoneAncestor;
171
184
  }
172
185
 
173
- /// Bypass FocusZone if it's empty or has no focusable elements
174
- static BOOL ShouldSkipFocusZone(NSView *view)
186
+ @implementation RCTFocusZone
187
+
188
+ - (NSView *)firstFocusableView
175
189
  {
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
- }
190
+ return GetFirstKeyViewWithin(self, [self forceFocus]);
191
+ }
185
192
 
186
- return NO;
193
+ - (NSView *)lastFocusableView
194
+ {
195
+ return GetLastKeyViewWithin(self, [self forceFocus]);
187
196
  }
188
197
 
189
- /// Accept firstResponder on FocusZone itself in order to reassign it within the FocusZone.
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.
190
200
  - (BOOL)acceptsFirstResponder
191
201
  {
192
- // Reject first responder if FocusZone is disabled or should be skipped.
193
- return !_disabled && !ShouldSkipFocusZone(self);
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;
194
213
  }
195
214
 
215
+ /// Reassign firstResponder within the FocusZone to either the default key view or first focusable view.
196
216
  - (BOOL)becomeFirstResponder
197
217
  {
198
- NSView *keyView = _defaultKeyView ?: GetFirstKeyViewWithin(self);
218
+ NSView *keyView = _defaultKeyView ?: [self firstFocusableView];
199
219
  return !_disabled && [[self window] makeFirstResponder:keyView];
200
220
  }
201
221
 
@@ -210,7 +230,9 @@ static BOOL ShouldSkipFocusZone(NSView *view)
210
230
  NSView *candidateView = [queue firstObject];
211
231
  [queue removeObjectAtIndex:0];
212
232
 
213
- if ([candidateView isNotEqualTo:self] && [candidateView canBecomeKeyView] && isLeadingCandidate(candidateView))
233
+ if ([candidateView isNotEqualTo:self] &&
234
+ ShouldFocusOnView(candidateView, [self forceFocus]) &&
235
+ isLeadingCandidate(candidateView))
214
236
  {
215
237
  nextViewToFocus = candidateView;
216
238
  }
@@ -281,7 +303,7 @@ static BOOL ShouldSkipFocusZone(NSView *view)
281
303
  if (!skip)
282
304
  {
283
305
  CGFloat distance = GetDistanceBetweenRects(firstResponderRect, candidateRect);
284
-
306
+
285
307
  // If there are other candidate views inside the same ScrollView as the firstResponder,
286
308
  // prefer those views over other views outside the scrollview, even if they are closer.
287
309
  if ([firstResponderEnclosingScrollView isEqualTo:[candidateView enclosingScrollView]])
@@ -356,11 +378,11 @@ static BOOL ShouldSkipFocusZone(NSView *view)
356
378
  {
357
379
  if (action == FocusZoneActionDownArrow)
358
380
  {
359
- return GetFirstKeyViewWithin(self);
381
+ return [self firstFocusableView];
360
382
  }
361
383
  else if (action == FocusZoneActionUpArrow)
362
384
  {
363
- return GetLastKeyViewWithin(self);
385
+ return [self lastFocusableView];
364
386
  }
365
387
  }
366
388
 
@@ -387,7 +409,7 @@ static BOOL ShouldSkipFocusZone(NSView *view)
387
409
  NSView *nextViewToFocus;
388
410
 
389
411
  [[self window] recalculateKeyViewLoop];
390
-
412
+
391
413
  // Find the first view outside the FocusZone (or any parent FocusZones) to place focus
392
414
  RCTFocusZone *focusZoneAncestor = GetFocusZoneAncestor(self);
393
415
 
@@ -406,7 +428,7 @@ static BOOL ShouldSkipFocusZone(NSView *view)
406
428
  {
407
429
  nextViewToFocus = [nextViewToFocus previousValidKeyView];
408
430
  }
409
-
431
+
410
432
  // If the previous view is in a FocusZone, focus on its defaultKeyView
411
433
  // (For FocusZoneActionTab, this is handled by becomeFirstResponder).
412
434
  RCTFocusZone *focusZoneAncestor = GetFocusZoneAncestor(nextViewToFocus);
@@ -7,6 +7,8 @@
7
7
 
8
8
  RCT_EXPORT_MODULE()
9
9
 
10
+ RCT_EXPORT_VIEW_PROPERTY(forceFocus, BOOL)
11
+
10
12
  RCT_EXPORT_VIEW_PROPERTY(disabled, BOOL)
11
13
 
12
14
  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.10.28",
3
+ "version": "0.10.30",
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",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@fluentui-react-native/component-cache": "^1.4.2",
26
- "@fluentui-react-native/interactive-hooks": ">=0.19.3 <1.0.0",
26
+ "@fluentui-react-native/interactive-hooks": ">=0.19.4 <1.0.0",
27
27
  "@uifabricshared/foundation-composable": ">=0.11.1 <1.0.0",
28
28
  "@uifabricshared/foundation-settings": ">=0.12.1 <1.0.0"
29
29
  },
package/src/FocusZone.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { findNodeHandle } from 'react-native';
2
+ import { findNodeHandle, Platform } 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, ...rest } = userProps;
15
+ const { componentRef, defaultTabbableElement, isCircularNavigation, forceFocusMacOS, ...rest } = userProps;
16
16
 
17
17
  const ftzRef = useViewCommandFocus(componentRef);
18
18
 
@@ -29,6 +29,7 @@ export const FocusZone = composable<FocusZoneType>({
29
29
  slotProps: mergeSettings<FocusZoneSlotProps>(useStyling(userProps), {
30
30
  root: {
31
31
  ...rest,
32
+ ...(Platform.OS === 'macos' ? { forceFocus: forceFocusMacOS } : null),
32
33
  defaultTabbableElement: targetNativeTag,
33
34
  ref: ftzRef,
34
35
  navigateAtEnd: isCircularNavigation ? 'NavigateWrap' : 'NavigateStopAtEnds',
@@ -18,32 +18,55 @@ export interface FocusZoneProps {
18
18
  defaultTabbableElement?: React.RefObject<React.Component>;
19
19
 
20
20
  /**
21
- ** Defines which arrows to react to
21
+ ** Defines which arrow keys to react to
22
22
  */
23
23
  focusZoneDirection?: FocusZoneDirection;
24
24
 
25
25
  /**
26
- ** If set, the FocusZone will not be tabbable and keyboard navigation will be disabled
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.
27
29
  */
28
30
  disabled?: boolean;
29
31
 
30
- /* Circular Navigation prop */
32
+ /**
33
+ * Circular Navigation prop
34
+ * @platform win32
35
+ */
31
36
  isCircularNavigation?: boolean;
32
37
 
33
38
  /**
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.
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
36
42
  */
37
43
  use2DNavigation?: boolean;
38
44
 
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
+
39
56
  /**
40
57
  * Callback called when “focus” event triggered in FocusZone
41
58
  */
42
59
  onFocus?: (e?: any) => void;
43
60
  }
44
61
 
45
- export interface NativeProps extends Omit<FocusZoneProps, 'isCircularNavigation'> {
46
- navigateAtEnd?: NavigateAtEnd;
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
47
70
  }
48
71
 
49
72
  export type FocusZoneDirection =