@fluentui/react-tabster 9.0.0-rc.5 → 9.0.0-rc.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.json +142 -1
  2. package/CHANGELOG.md +118 -82
  3. package/README.md +5 -14
  4. package/dist/{react-tabster.d.ts → index.d.ts} +14 -8
  5. package/lib/{symbols.d.ts → focus/constants.d.ts} +4 -0
  6. package/lib/{symbols.js → focus/constants.js} +5 -1
  7. package/lib/focus/constants.js.map +1 -0
  8. package/lib/focus/createCustomFocusIndicatorStyle.d.ts +12 -0
  9. package/lib/focus/createCustomFocusIndicatorStyle.js +18 -0
  10. package/lib/focus/createCustomFocusIndicatorStyle.js.map +1 -0
  11. package/{lib-commonjs/hooks/useFocusIndicatorStyle.d.ts → lib/focus/createFocusOutlineStyle.d.ts} +4 -13
  12. package/lib/{hooks/useFocusIndicatorStyle.js → focus/createFocusOutlineStyle.js} +20 -40
  13. package/lib/focus/createFocusOutlineStyle.js.map +1 -0
  14. package/lib/focus/index.d.ts +2 -0
  15. package/lib/focus/index.js +3 -0
  16. package/lib/focus/index.js.map +1 -0
  17. package/lib/hooks/index.d.ts +2 -3
  18. package/lib/hooks/index.js +2 -3
  19. package/lib/hooks/index.js.map +1 -1
  20. package/lib/hooks/useArrowNavigationGroup.d.ts +6 -2
  21. package/lib/hooks/useArrowNavigationGroup.js +5 -1
  22. package/lib/hooks/useArrowNavigationGroup.js.map +1 -1
  23. package/lib/hooks/useFocusableGroup.js.map +1 -1
  24. package/lib/hooks/useKeyboardNavAttribute.js +1 -1
  25. package/lib/hooks/useKeyboardNavAttribute.js.map +1 -1
  26. package/lib/index.d.ts +4 -1
  27. package/lib/index.js +2 -1
  28. package/lib/index.js.map +1 -1
  29. package/lib-commonjs/{symbols.d.ts → focus/constants.d.ts} +4 -0
  30. package/lib-commonjs/{symbols.js → focus/constants.js} +6 -2
  31. package/lib-commonjs/focus/constants.js.map +1 -0
  32. package/lib-commonjs/focus/createCustomFocusIndicatorStyle.d.ts +12 -0
  33. package/lib-commonjs/focus/createCustomFocusIndicatorStyle.js +28 -0
  34. package/lib-commonjs/focus/createCustomFocusIndicatorStyle.js.map +1 -0
  35. package/{lib/hooks/useFocusIndicatorStyle.d.ts → lib-commonjs/focus/createFocusOutlineStyle.d.ts} +4 -13
  36. package/lib-commonjs/{hooks/useFocusIndicatorStyle.js → focus/createFocusOutlineStyle.js} +24 -44
  37. package/lib-commonjs/focus/createFocusOutlineStyle.js.map +1 -0
  38. package/lib-commonjs/focus/index.d.ts +2 -0
  39. package/lib-commonjs/focus/index.js +12 -0
  40. package/lib-commonjs/focus/index.js.map +1 -0
  41. package/lib-commonjs/hooks/index.d.ts +2 -3
  42. package/lib-commonjs/hooks/index.js +4 -6
  43. package/lib-commonjs/hooks/index.js.map +1 -1
  44. package/lib-commonjs/hooks/useArrowNavigationGroup.d.ts +6 -2
  45. package/lib-commonjs/hooks/useArrowNavigationGroup.js +5 -1
  46. package/lib-commonjs/hooks/useArrowNavigationGroup.js.map +1 -1
  47. package/lib-commonjs/hooks/useFocusableGroup.js.map +1 -1
  48. package/lib-commonjs/hooks/useKeyboardNavAttribute.js +3 -3
  49. package/lib-commonjs/hooks/useKeyboardNavAttribute.js.map +1 -1
  50. package/lib-commonjs/index.d.ts +4 -1
  51. package/lib-commonjs/index.js +53 -2
  52. package/lib-commonjs/index.js.map +1 -1
  53. package/package.json +10 -15
  54. package/lib/hooks/useFocusIndicatorStyle.js.map +0 -1
  55. package/lib/symbols.js.map +0 -1
  56. package/lib-commonjs/hooks/useFocusIndicatorStyle.js.map +0 -1
  57. package/lib-commonjs/symbols.js.map +0 -1
package/README.md CHANGED
@@ -2,19 +2,14 @@
2
2
 
3
3
  **Tabster components for [Fluent UI React](https://developer.microsoft.com/en-us/fluentui)**
4
4
 
5
- Experimental library for focus management that leverages [tabster](https://github.com/microsoft/tabster).
6
-
7
- These library is not production-ready and **should never be used in product**. This space is useful for testing new features whose APIs might change before final release.
8
-
9
- The provider needs to be wrapped around your application:
10
-
11
- ```tsx
12
- <TabsterProvider>{children}</TabsterProvider>
13
- ```
5
+ Library for focus management that leverages [tabster](https://github.com/microsoft/tabster).
14
6
 
15
7
  The API currently only supports declarative data-\* attributes that are returned using the exported react hooks:
16
8
 
17
9
  ```tsx
10
+ import * as React from 'react';
11
+ import { useArrowNavigationGroup } from '@fluentui/react-tabster';
12
+
18
13
  const Item: React.FC = ({ children }) => <div tabIndex={0}>Item</div>;
19
14
 
20
15
  const ArrowNavigationExample: React.FC = ({ children }) => {
@@ -33,10 +28,6 @@ const ArrowNavigationExample: React.FC = ({ children }) => {
33
28
  };
34
29
 
35
30
  const App: React.FC = () => {
36
- return (
37
- <TabsterProvider>
38
- <ArrowNavigationExample />
39
- </TabsterProvider>
40
- );
31
+ return <ArrowNavigationExample />;
41
32
  };
42
33
  ```
@@ -7,10 +7,11 @@ import { Types } from 'tabster';
7
7
  * Should be used only when @see createFocusOutlineStyle does not fit requirements
8
8
  *
9
9
  * @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes
10
+ * @param options - Configure the style of the focus outline
10
11
  */
11
- export declare const createCustomFocusIndicatorStyle: (style: GriffelStyle, options?: CreateFocusIndicatorStyleRuleOptions) => GriffelStyle;
12
+ export declare const createCustomFocusIndicatorStyle: (style: GriffelStyle, { selector }?: CreateCustomFocusIndicatorStyleOptions) => GriffelStyle;
12
13
 
13
- export declare interface CreateFocusIndicatorStyleRuleOptions {
14
+ export declare interface CreateCustomFocusIndicatorStyleOptions {
14
15
  selector?: 'focus' | 'focus-within';
15
16
  }
16
17
 
@@ -18,13 +19,14 @@ export declare interface CreateFocusIndicatorStyleRuleOptions {
18
19
  * NOTE: The element with the focus outline needs to have `position: relative` so that the
19
20
  * pseudo element can be properly positioned.
20
21
  *
21
- * @param theme - Theme used in @see makeStyles
22
22
  * @param options - Configure the style of the focus outline
23
23
  * @returns focus outline styles object for @see makeStyles
24
24
  */
25
- export declare const createFocusOutlineStyle: (options?: {
26
- style: Partial<FocusOutlineStyleOptions>;
27
- } & CreateFocusIndicatorStyleRuleOptions) => GriffelStyle;
25
+ export declare const createFocusOutlineStyle: ({ selector, style, }?: CreateFocusOutlineStyleOptions) => GriffelStyle;
26
+
27
+ export declare interface CreateFocusOutlineStyleOptions extends CreateCustomFocusIndicatorStyleOptions {
28
+ style?: Partial<FocusOutlineStyleOptions>;
29
+ }
28
30
 
29
31
  export declare type FocusOutlineOffset = Record<'top' | 'bottom' | 'left' | 'right', string>;
30
32
 
@@ -47,10 +49,10 @@ export declare const useArrowNavigationGroup: (options?: UseArrowNavigationGroup
47
49
 
48
50
  export declare interface UseArrowNavigationGroupOptions {
49
51
  /**
50
- * Focus will navigate vertically or horizontally, defaults to horizontally
52
+ * Focus will navigate vertically, horizontally or in both directions (grid), defaults to horizontally
51
53
  * @defaultValue vertical
52
54
  */
53
- axis?: 'vertical' | 'horizontal';
55
+ axis?: 'vertical' | 'horizontal' | 'grid';
54
56
  /**
55
57
  * Focus will cycle to the first/last elements of the group without stopping
56
58
  */
@@ -60,6 +62,10 @@ export declare interface UseArrowNavigationGroupOptions {
60
62
  * available) when tabbing from outside of the group
61
63
  */
62
64
  memorizeCurrent?: boolean;
65
+ /**
66
+ * Allow tabbing within the arrow navigation group items.
67
+ */
68
+ tabbable?: boolean;
63
69
  }
64
70
 
65
71
  /**
@@ -1,2 +1,6 @@
1
1
  export declare const KEYBOARD_NAV_ATTRIBUTE: "data-keyboard-nav";
2
2
  export declare const KEYBOARD_NAV_SELECTOR: ":global([data-keyboard-nav])";
3
+ export declare const defaultOptions: {
4
+ readonly style: {};
5
+ readonly selector: "focus";
6
+ };
@@ -1,3 +1,7 @@
1
1
  export const KEYBOARD_NAV_ATTRIBUTE = 'data-keyboard-nav';
2
2
  export const KEYBOARD_NAV_SELECTOR = `:global([${KEYBOARD_NAV_ATTRIBUTE}])`;
3
- //# sourceMappingURL=symbols.js.map
3
+ export const defaultOptions = {
4
+ style: {},
5
+ selector: 'focus'
6
+ };
7
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["focus/constants.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,sBAAsB,GAAG,mBAA/B;AACP,OAAO,MAAM,qBAAqB,GAAG,YAAY,sBAAsB,IAAhE;AACP,OAAO,MAAM,cAAc,GAAG;AAC5B,EAAA,KAAK,EAAE,EADqB;AAE5B,EAAA,QAAQ,EAAE;AAFkB,CAAvB","sourcesContent":["export const KEYBOARD_NAV_ATTRIBUTE = 'data-keyboard-nav' as const;\nexport const KEYBOARD_NAV_SELECTOR = `:global([${KEYBOARD_NAV_ATTRIBUTE}])` as const;\nexport const defaultOptions = {\n style: {},\n selector: 'focus',\n} as const;\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,12 @@
1
+ import type { GriffelStyle } from '@griffel/react';
2
+ export interface CreateCustomFocusIndicatorStyleOptions {
3
+ selector?: 'focus' | 'focus-within';
4
+ }
5
+ /**
6
+ * Creates a style for @see makeStyles that includes the necessary selectors for focus.
7
+ * Should be used only when @see createFocusOutlineStyle does not fit requirements
8
+ *
9
+ * @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes
10
+ * @param options - Configure the style of the focus outline
11
+ */
12
+ export declare const createCustomFocusIndicatorStyle: (style: GriffelStyle, { selector }?: CreateCustomFocusIndicatorStyleOptions) => GriffelStyle;
@@ -0,0 +1,18 @@
1
+ import { KEYBOARD_NAV_SELECTOR, defaultOptions } from './constants';
2
+ /**
3
+ * Creates a style for @see makeStyles that includes the necessary selectors for focus.
4
+ * Should be used only when @see createFocusOutlineStyle does not fit requirements
5
+ *
6
+ * @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes
7
+ * @param options - Configure the style of the focus outline
8
+ */
9
+
10
+ export const createCustomFocusIndicatorStyle = (style, {
11
+ selector = defaultOptions.selector
12
+ } = defaultOptions) => ({
13
+ ':focus-visible': {
14
+ outlineStyle: 'none'
15
+ },
16
+ [`${KEYBOARD_NAV_SELECTOR} :${selector}`]: style
17
+ });
18
+ //# sourceMappingURL=createCustomFocusIndicatorStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["focus/createCustomFocusIndicatorStyle.ts"],"names":[],"mappings":"AAAA,SAAS,qBAAT,EAAgC,cAAhC,QAAsD,aAAtD;AAOA;;;;;;AAMG;;AACH,OAAO,MAAM,+BAA+B,GAAG,CAC7C,KAD6C,EAE7C;AAAE,EAAA,QAAQ,GAAG,cAAc,CAAC;AAA5B,IAAiF,cAFpC,MAG3B;AAClB,oBAAkB;AAChB,IAAA,YAAY,EAAE;AADE,GADA;AAIlB,GAAC,GAAG,qBAAqB,KAAK,QAAQ,EAAtC,GAA2C;AAJzB,CAH2B,CAAxC","sourcesContent":["import { KEYBOARD_NAV_SELECTOR, defaultOptions } from './constants';\nimport type { GriffelStyle } from '@griffel/react';\n\nexport interface CreateCustomFocusIndicatorStyleOptions {\n selector?: 'focus' | 'focus-within';\n}\n\n/**\n * Creates a style for @see makeStyles that includes the necessary selectors for focus.\n * Should be used only when @see createFocusOutlineStyle does not fit requirements\n *\n * @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes\n * @param options - Configure the style of the focus outline\n */\nexport const createCustomFocusIndicatorStyle = (\n style: GriffelStyle,\n { selector = defaultOptions.selector }: CreateCustomFocusIndicatorStyleOptions = defaultOptions,\n): GriffelStyle => ({\n ':focus-visible': {\n outlineStyle: 'none',\n },\n [`${KEYBOARD_NAV_SELECTOR} :${selector}`]: style,\n});\n"],"sourceRoot":"../src/"}
@@ -1,4 +1,5 @@
1
1
  import type { GriffelStyle } from '@griffel/react';
2
+ import { CreateCustomFocusIndicatorStyleOptions } from './createCustomFocusIndicatorStyle';
2
3
  export declare type FocusOutlineOffset = Record<'top' | 'bottom' | 'left' | 'right', string>;
3
4
  export declare type FocusOutlineStyleOptions = {
4
5
  /**
@@ -10,24 +11,14 @@ export declare type FocusOutlineStyleOptions = {
10
11
  outlineWidth: string;
11
12
  outlineOffset?: string | FocusOutlineOffset;
12
13
  };
13
- export interface CreateFocusIndicatorStyleRuleOptions {
14
- selector?: 'focus' | 'focus-within';
14
+ export interface CreateFocusOutlineStyleOptions extends CreateCustomFocusIndicatorStyleOptions {
15
+ style?: Partial<FocusOutlineStyleOptions>;
15
16
  }
16
17
  /**
17
18
  * NOTE: The element with the focus outline needs to have `position: relative` so that the
18
19
  * pseudo element can be properly positioned.
19
20
  *
20
- * @param theme - Theme used in @see makeStyles
21
21
  * @param options - Configure the style of the focus outline
22
22
  * @returns focus outline styles object for @see makeStyles
23
23
  */
24
- export declare const createFocusOutlineStyle: (options?: {
25
- style: Partial<FocusOutlineStyleOptions>;
26
- } & CreateFocusIndicatorStyleRuleOptions) => GriffelStyle;
27
- /**
28
- * Creates a style for @see makeStyles that includes the necessary selectors for focus.
29
- * Should be used only when @see createFocusOutlineStyle does not fit requirements
30
- *
31
- * @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes
32
- */
33
- export declare const createCustomFocusIndicatorStyle: (style: GriffelStyle, options?: CreateFocusIndicatorStyleRuleOptions) => GriffelStyle;
24
+ export declare const createFocusOutlineStyle: ({ selector, style, }?: CreateFocusOutlineStyleOptions) => GriffelStyle;
@@ -1,5 +1,7 @@
1
1
  import { tokens } from '@fluentui/react-theme';
2
- import { KEYBOARD_NAV_SELECTOR } from '../symbols';
2
+ import { shorthands } from '@griffel/react';
3
+ import { createCustomFocusIndicatorStyle } from './createCustomFocusIndicatorStyle';
4
+ import { defaultOptions } from './constants';
3
5
  /**
4
6
  * NOTE: the element with the focus outline needs to have `position: relative` so that the
5
7
  * pseudo element can be properly positioned.
@@ -21,18 +23,16 @@ const getFocusOutlineStyles = options => {
21
23
  const outlineOffsetBottom = ((_b = outlineOffset) === null || _b === void 0 ? void 0 : _b.bottom) || outlineOffset;
22
24
  const outlineOffsetLeft = ((_c = outlineOffset) === null || _c === void 0 ? void 0 : _c.left) || outlineOffset;
23
25
  const outlineOffsetRight = ((_d = outlineOffset) === null || _d === void 0 ? void 0 : _d.right) || outlineOffset;
24
- return {
25
- borderColor: 'transparent',
26
+ return { ...shorthands.borderColor('transparent'),
26
27
  ':after': {
27
28
  content: '""',
28
29
  position: 'absolute',
29
30
  pointerEvents: 'none',
30
- boxSizing: 'outline-box',
31
31
  zIndex: 1,
32
- borderStyle: 'solid',
33
- borderWidth: outlineWidth,
34
- borderRadius: outlineRadius,
35
- borderColor: outlineColor,
32
+ ...shorthands.borderStyle('solid'),
33
+ ...shorthands.borderWidth(outlineWidth),
34
+ ...shorthands.borderRadius(outlineRadius),
35
+ ...shorthands.borderColor(outlineColor),
36
36
  top: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetTop})`,
37
37
  bottom: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetBottom})`,
38
38
  left: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetLeft})`,
@@ -40,45 +40,25 @@ const getFocusOutlineStyles = options => {
40
40
  }
41
41
  };
42
42
  };
43
-
44
- const defaultOptions = {
45
- selector: 'focus'
46
- };
47
43
  /**
48
44
  * NOTE: The element with the focus outline needs to have `position: relative` so that the
49
45
  * pseudo element can be properly positioned.
50
46
  *
51
- * @param theme - Theme used in @see makeStyles
52
47
  * @param options - Configure the style of the focus outline
53
48
  * @returns focus outline styles object for @see makeStyles
54
49
  */
55
50
 
56
- export const createFocusOutlineStyle = (options = {
57
- style: {},
58
- ...defaultOptions
59
- }) => ({
60
- ':focus-visible': {
61
- outlineStyle: 'none'
62
- },
63
- [`${KEYBOARD_NAV_SELECTOR} :${options.selector || defaultOptions.selector}`]: getFocusOutlineStyles({
64
- outlineColor: tokens.colorStrokeFocus2,
65
- outlineRadius: tokens.borderRadiusMedium,
66
- // FIXME: tokens.strokeWidthThick causes some weird bugs
67
- outlineWidth: '2px',
68
- ...options.style
69
- })
70
- });
71
- /**
72
- * Creates a style for @see makeStyles that includes the necessary selectors for focus.
73
- * Should be used only when @see createFocusOutlineStyle does not fit requirements
74
- *
75
- * @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes
76
- */
77
51
 
78
- export const createCustomFocusIndicatorStyle = (style, options = defaultOptions) => ({
79
- ':focus-visible': {
80
- outlineStyle: 'none'
81
- },
82
- [`${KEYBOARD_NAV_SELECTOR} :${options.selector || defaultOptions.selector}`]: style
52
+ export const createFocusOutlineStyle = ({
53
+ selector = defaultOptions.selector,
54
+ style = defaultOptions.style
55
+ } = defaultOptions) => createCustomFocusIndicatorStyle(getFocusOutlineStyles({
56
+ outlineColor: tokens.colorStrokeFocus2,
57
+ outlineRadius: tokens.borderRadiusMedium,
58
+ // FIXME: tokens.strokeWidthThick causes some weird bugs
59
+ outlineWidth: '2px',
60
+ ...style
61
+ }), {
62
+ selector
83
63
  });
84
- //# sourceMappingURL=useFocusIndicatorStyle.js.map
64
+ //# sourceMappingURL=createFocusOutlineStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["focus/createFocusOutlineStyle.ts"],"names":[],"mappings":"AAAA,SAAS,MAAT,QAAuB,uBAAvB;AACA,SAAS,UAAT,QAA2B,gBAA3B;AAEA,SACE,+BADF,QAGO,mCAHP;AAIA,SAAS,cAAT,QAA+B,aAA/B;AAiBA;;;;;;AAMG;;AACH,MAAM,qBAAqB,GAAI,OAAD,IAAoD;;;AAChF,QAAM;AAAE,IAAA,aAAF;AAAiB,IAAA,YAAjB;AAA+B,IAAA,aAA/B;AAA8C,IAAA;AAA9C,MAA+D,OAArE;AAEA,QAAM,gBAAgB,GAAG,CAAA,CAAA,EAAA,GAAC,aAAD,MAAqC,IAArC,IAAqC,EAAA,KAAA,KAAA,CAArC,GAAqC,KAAA,CAArC,GAAqC,EAAA,CAAE,GAAvC,KAA8C,aAAvE;AACA,QAAM,mBAAmB,GAAG,CAAA,CAAA,EAAA,GAAC,aAAD,MAAqC,IAArC,IAAqC,EAAA,KAAA,KAAA,CAArC,GAAqC,KAAA,CAArC,GAAqC,EAAA,CAAE,MAAvC,KAAiD,aAA7E;AACA,QAAM,iBAAiB,GAAG,CAAA,CAAA,EAAA,GAAC,aAAD,MAAqC,IAArC,IAAqC,EAAA,KAAA,KAAA,CAArC,GAAqC,KAAA,CAArC,GAAqC,EAAA,CAAE,IAAvC,KAA+C,aAAzE;AACA,QAAM,kBAAkB,GAAG,CAAA,CAAA,EAAA,GAAC,aAAD,MAAqC,IAArC,IAAqC,EAAA,KAAA,KAAA,CAArC,GAAqC,KAAA,CAArC,GAAqC,EAAA,CAAE,KAAvC,KAAgD,aAA3E;AAEA,SAAO,EACL,GAAG,UAAU,CAAC,WAAX,CAAuB,aAAvB,CADE;AAEL,cAAU;AACR,MAAA,OAAO,EAAE,IADD;AAER,MAAA,QAAQ,EAAE,UAFF;AAGR,MAAA,aAAa,EAAE,MAHP;AAIR,MAAA,MAAM,EAAE,CAJA;AAMR,SAAG,UAAU,CAAC,WAAX,CAAuB,OAAvB,CANK;AAOR,SAAG,UAAU,CAAC,WAAX,CAAuB,YAAvB,CAPK;AAQR,SAAG,UAAU,CAAC,YAAX,CAAwB,aAAxB,CARK;AASR,SAAG,UAAU,CAAC,WAAX,CAAuB,YAAvB,CATK;AAWR,MAAA,GAAG,EAAE,CAAC,aAAD,GAAiB,IAAI,YAAY,EAAjC,GAAsC,cAAc,YAAY,MAAM,gBAAgB,GAXnF;AAYR,MAAA,MAAM,EAAE,CAAC,aAAD,GAAiB,IAAI,YAAY,EAAjC,GAAsC,cAAc,YAAY,MAAM,mBAAmB,GAZzF;AAaR,MAAA,IAAI,EAAE,CAAC,aAAD,GAAiB,IAAI,YAAY,EAAjC,GAAsC,cAAc,YAAY,MAAM,iBAAiB,GAbrF;AAcR,MAAA,KAAK,EAAE,CAAC,aAAD,GAAiB,IAAI,YAAY,EAAjC,GAAsC,cAAc,YAAY,MAAM,kBAAkB;AAdvF;AAFL,GAAP;AAmBD,CA3BD;AA6BA;;;;;;AAMG;;;AACH,OAAO,MAAM,uBAAuB,GAAG,CAAC;AACtC,EAAA,QAAQ,GAAG,cAAc,CAAC,QADY;AAEtC,EAAA,KAAK,GAAG,cAAc,CAAC;AAFe,IAGJ,cAHG,KAIrC,+BAA+B,CAC7B,qBAAqB,CAAC;AACpB,EAAA,YAAY,EAAE,MAAM,CAAC,iBADD;AAEpB,EAAA,aAAa,EAAE,MAAM,CAAC,kBAFF;AAGpB;AACA,EAAA,YAAY,EAAE,KAJM;AAKpB,KAAG;AALiB,CAAD,CADQ,EAQ7B;AAAE,EAAA;AAAF,CAR6B,CAJ1B","sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport { shorthands } from '@griffel/react';\nimport type { GriffelStyle } from '@griffel/react';\nimport {\n createCustomFocusIndicatorStyle,\n CreateCustomFocusIndicatorStyleOptions,\n} from './createCustomFocusIndicatorStyle';\nimport { defaultOptions } from './constants';\n\nexport type FocusOutlineOffset = Record<'top' | 'bottom' | 'left' | 'right', string>;\nexport type FocusOutlineStyleOptions = {\n /**\n * Only property not supported by the native CSS `outline`, if this is no longer needed\n * we can just go native instead\n */\n outlineRadius: string;\n outlineColor: string;\n outlineWidth: string;\n outlineOffset?: string | FocusOutlineOffset;\n};\nexport interface CreateFocusOutlineStyleOptions extends CreateCustomFocusIndicatorStyleOptions {\n style?: Partial<FocusOutlineStyleOptions>;\n}\n\n/**\n * NOTE: the element with the focus outline needs to have `position: relative` so that the\n * pseudo element can be properly positioned.\n *\n * @param options - Configures the style of the focus outline\n * @returns focus outline styles object\n */\nconst getFocusOutlineStyles = (options: FocusOutlineStyleOptions): GriffelStyle => {\n const { outlineRadius, outlineColor, outlineOffset, outlineWidth } = options;\n\n const outlineOffsetTop = (outlineOffset as FocusOutlineOffset)?.top || outlineOffset;\n const outlineOffsetBottom = (outlineOffset as FocusOutlineOffset)?.bottom || outlineOffset;\n const outlineOffsetLeft = (outlineOffset as FocusOutlineOffset)?.left || outlineOffset;\n const outlineOffsetRight = (outlineOffset as FocusOutlineOffset)?.right || outlineOffset;\n\n return {\n ...shorthands.borderColor('transparent'),\n ':after': {\n content: '\"\"',\n position: 'absolute',\n pointerEvents: 'none',\n zIndex: 1,\n\n ...shorthands.borderStyle('solid'),\n ...shorthands.borderWidth(outlineWidth),\n ...shorthands.borderRadius(outlineRadius),\n ...shorthands.borderColor(outlineColor),\n\n top: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetTop})`,\n bottom: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetBottom})`,\n left: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetLeft})`,\n right: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetRight})`,\n },\n };\n};\n\n/**\n * NOTE: The element with the focus outline needs to have `position: relative` so that the\n * pseudo element can be properly positioned.\n *\n * @param options - Configure the style of the focus outline\n * @returns focus outline styles object for @see makeStyles\n */\nexport const createFocusOutlineStyle = ({\n selector = defaultOptions.selector,\n style = defaultOptions.style,\n}: CreateFocusOutlineStyleOptions = defaultOptions): GriffelStyle =>\n createCustomFocusIndicatorStyle(\n getFocusOutlineStyles({\n outlineColor: tokens.colorStrokeFocus2,\n outlineRadius: tokens.borderRadiusMedium,\n // FIXME: tokens.strokeWidthThick causes some weird bugs\n outlineWidth: '2px',\n ...style,\n }),\n { selector },\n );\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,2 @@
1
+ export * from './createCustomFocusIndicatorStyle';
2
+ export * from './createFocusOutlineStyle';
@@ -0,0 +1,3 @@
1
+ export * from './createCustomFocusIndicatorStyle';
2
+ export * from './createFocusOutlineStyle';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["focus/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC","sourcesContent":["export * from './createCustomFocusIndicatorStyle';\nexport * from './createFocusOutlineStyle';\n"]}
@@ -1,7 +1,6 @@
1
1
  export * from './useArrowNavigationGroup';
2
+ export * from './useFocusableGroup';
2
3
  export * from './useFocusFinders';
4
+ export * from './useKeyboardNavAttribute';
3
5
  export * from './useModalAttributes';
4
6
  export * from './useTabsterAttributes';
5
- export * from './useFocusIndicatorStyle';
6
- export * from './useKeyboardNavAttribute';
7
- export * from './useFocusableGroup';
@@ -1,8 +1,7 @@
1
1
  export * from './useArrowNavigationGroup';
2
+ export * from './useFocusableGroup';
2
3
  export * from './useFocusFinders';
4
+ export * from './useKeyboardNavAttribute';
3
5
  export * from './useModalAttributes';
4
6
  export * from './useTabsterAttributes';
5
- export * from './useFocusIndicatorStyle';
6
- export * from './useKeyboardNavAttribute';
7
- export * from './useFocusableGroup';
8
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './useArrowNavigationGroup';\nexport * from './useFocusFinders';\nexport * from './useModalAttributes';\nexport * from './useTabsterAttributes';\nexport * from './useFocusIndicatorStyle';\nexport * from './useKeyboardNavAttribute';\nexport * from './useFocusableGroup';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC","sourcesContent":["export * from './useArrowNavigationGroup';\nexport * from './useFocusableGroup';\nexport * from './useFocusFinders';\nexport * from './useKeyboardNavAttribute';\nexport * from './useModalAttributes';\nexport * from './useTabsterAttributes';\n"]}
@@ -1,10 +1,10 @@
1
1
  import { Types } from 'tabster';
2
2
  export interface UseArrowNavigationGroupOptions {
3
3
  /**
4
- * Focus will navigate vertically or horizontally, defaults to horizontally
4
+ * Focus will navigate vertically, horizontally or in both directions (grid), defaults to horizontally
5
5
  * @defaultValue vertical
6
6
  */
7
- axis?: 'vertical' | 'horizontal';
7
+ axis?: 'vertical' | 'horizontal' | 'grid';
8
8
  /**
9
9
  * Focus will cycle to the first/last elements of the group without stopping
10
10
  */
@@ -14,6 +14,10 @@ export interface UseArrowNavigationGroupOptions {
14
14
  * available) when tabbing from outside of the group
15
15
  */
16
16
  memorizeCurrent?: boolean;
17
+ /**
18
+ * Allow tabbing within the arrow navigation group items.
19
+ */
20
+ tabbable?: boolean;
17
21
  }
18
22
  /**
19
23
  * A hook that returns the necessary tabster attributes to support arrow key navigation
@@ -19,7 +19,8 @@ export const useArrowNavigationGroup = options => {
19
19
  mover: {
20
20
  cyclic: !!(options === null || options === void 0 ? void 0 : options.circular),
21
21
  direction: axisToMoverDirection((_a = options === null || options === void 0 ? void 0 : options.axis) !== null && _a !== void 0 ? _a : 'vertical'),
22
- memorizeCurrent: options === null || options === void 0 ? void 0 : options.memorizeCurrent
22
+ memorizeCurrent: options === null || options === void 0 ? void 0 : options.memorizeCurrent,
23
+ tabbable: options === null || options === void 0 ? void 0 : options.tabbable
23
24
  }
24
25
  });
25
26
  };
@@ -29,6 +30,9 @@ function axisToMoverDirection(axis) {
29
30
  case 'horizontal':
30
31
  return Types.MoverDirections.Horizontal;
31
32
 
33
+ case 'grid':
34
+ return Types.MoverDirections.Grid;
35
+
32
36
  case 'vertical':
33
37
  default:
34
38
  return Types.MoverDirections.Vertical;
@@ -1 +1 @@
1
- {"version":3,"sources":["hooks/useArrowNavigationGroup.ts"],"names":[],"mappings":"AAAA,SAAS,KAAT,EAAgB,QAAhB,QAAgC,SAAhC;AACA,SAAS,oBAAT,QAAqC,wBAArC;AACA,SAAS,UAAT,QAA2B,cAA3B;AAmBA;;;AAGG;;AACH,OAAO,MAAM,uBAAuB,GAAI,OAAD,IAA6C;;;AAClF,QAAM,OAAO,GAAG,UAAU,EAA1B;;AAEA,MAAI,OAAJ,EAAa;AACX,IAAA,QAAQ,CAAC,OAAD,CAAR;AACD;;AAED,SAAO,oBAAoB,CAAC;AAC1B,IAAA,KAAK,EAAE;AACL,MAAA,MAAM,EAAE,CAAC,EAAC,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,QAAV,CADJ;AAEL,MAAA,SAAS,EAAE,oBAAoB,CAAC,CAAA,EAAA,GAAA,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,IAAT,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,EAAb,GAAiB,UAAlB,CAF1B;AAGL,MAAA,eAAe,EAAE,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE;AAHrB;AADmB,GAAD,CAA3B;AAOD,CAdM;;AAgBP,SAAS,oBAAT,CAA8B,IAA9B,EAA0E;AACxE,UAAQ,IAAR;AACE,SAAK,YAAL;AACE,aAAO,KAAK,CAAC,eAAN,CAAsB,UAA7B;;AAEF,SAAK,UAAL;AACA;AACE,aAAO,KAAK,CAAC,eAAN,CAAsB,QAA7B;AANJ;AAQD","sourcesContent":["import { Types, getMover } from 'tabster';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { useTabster } from './useTabster';\n\nexport interface UseArrowNavigationGroupOptions {\n /**\n * Focus will navigate vertically or horizontally, defaults to horizontally\n * @defaultValue vertical\n */\n axis?: 'vertical' | 'horizontal';\n /**\n * Focus will cycle to the first/last elements of the group without stopping\n */\n circular?: boolean;\n /**\n * Last focused element in the group will be remembered and focused (if still\n * available) when tabbing from outside of the group\n */\n memorizeCurrent?: boolean;\n}\n\n/**\n * A hook that returns the necessary tabster attributes to support arrow key navigation\n * @param options - Options to configure keyboard navigation\n */\nexport const useArrowNavigationGroup = (options?: UseArrowNavigationGroupOptions) => {\n const tabster = useTabster();\n\n if (tabster) {\n getMover(tabster);\n }\n\n return useTabsterAttributes({\n mover: {\n cyclic: !!options?.circular,\n direction: axisToMoverDirection(options?.axis ?? 'vertical'),\n memorizeCurrent: options?.memorizeCurrent,\n },\n });\n};\n\nfunction axisToMoverDirection(axis: UseArrowNavigationGroupOptions['axis']): Types.MoverDirection {\n switch (axis) {\n case 'horizontal':\n return Types.MoverDirections.Horizontal;\n\n case 'vertical':\n default:\n return Types.MoverDirections.Vertical;\n }\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["hooks/useArrowNavigationGroup.ts"],"names":[],"mappings":"AAAA,SAAS,KAAT,EAAgB,QAAhB,QAAgC,SAAhC;AACA,SAAS,oBAAT,QAAqC,wBAArC;AACA,SAAS,UAAT,QAA2B,cAA3B;AAuBA;;;AAGG;;AACH,OAAO,MAAM,uBAAuB,GAAI,OAAD,IAAwE;;;AAC7G,QAAM,OAAO,GAAG,UAAU,EAA1B;;AAEA,MAAI,OAAJ,EAAa;AACX,IAAA,QAAQ,CAAC,OAAD,CAAR;AACD;;AAED,SAAO,oBAAoB,CAAC;AAC1B,IAAA,KAAK,EAAE;AACL,MAAA,MAAM,EAAE,CAAC,EAAC,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,QAAV,CADJ;AAEL,MAAA,SAAS,EAAE,oBAAoB,CAAC,CAAA,EAAA,GAAA,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,IAAT,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,EAAb,GAAiB,UAAlB,CAF1B;AAGL,MAAA,eAAe,EAAE,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,eAHrB;AAIL,MAAA,QAAQ,EAAE,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE;AAJd;AADmB,GAAD,CAA3B;AAQD,CAfM;;AAiBP,SAAS,oBAAT,CAA8B,IAA9B,EAA0E;AACxE,UAAQ,IAAR;AACE,SAAK,YAAL;AACE,aAAO,KAAK,CAAC,eAAN,CAAsB,UAA7B;;AACF,SAAK,MAAL;AACE,aAAO,KAAK,CAAC,eAAN,CAAsB,IAA7B;;AAEF,SAAK,UAAL;AACA;AACE,aAAO,KAAK,CAAC,eAAN,CAAsB,QAA7B;AARJ;AAUD","sourcesContent":["import { Types, getMover } from 'tabster';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { useTabster } from './useTabster';\n\nexport interface UseArrowNavigationGroupOptions {\n /**\n * Focus will navigate vertically, horizontally or in both directions (grid), defaults to horizontally\n * @defaultValue vertical\n */\n axis?: 'vertical' | 'horizontal' | 'grid';\n /**\n * Focus will cycle to the first/last elements of the group without stopping\n */\n circular?: boolean;\n /**\n * Last focused element in the group will be remembered and focused (if still\n * available) when tabbing from outside of the group\n */\n memorizeCurrent?: boolean;\n /**\n * Allow tabbing within the arrow navigation group items.\n */\n tabbable?: boolean;\n}\n\n/**\n * A hook that returns the necessary tabster attributes to support arrow key navigation\n * @param options - Options to configure keyboard navigation\n */\nexport const useArrowNavigationGroup = (options?: UseArrowNavigationGroupOptions): Types.TabsterDOMAttribute => {\n const tabster = useTabster();\n\n if (tabster) {\n getMover(tabster);\n }\n\n return useTabsterAttributes({\n mover: {\n cyclic: !!options?.circular,\n direction: axisToMoverDirection(options?.axis ?? 'vertical'),\n memorizeCurrent: options?.memorizeCurrent,\n tabbable: options?.tabbable,\n },\n });\n};\n\nfunction axisToMoverDirection(axis: UseArrowNavigationGroupOptions['axis']): Types.MoverDirection {\n switch (axis) {\n case 'horizontal':\n return Types.MoverDirections.Horizontal;\n case 'grid':\n return Types.MoverDirections.Grid;\n\n case 'vertical':\n default:\n return Types.MoverDirections.Vertical;\n }\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["hooks/useFocusableGroup.ts"],"names":[],"mappings":"AAAA,SAAS,KAAT,EAAgB,WAAhB,QAAmC,SAAnC;AACA,SAAS,oBAAT,QAAqC,wBAArC;AACA,SAAS,UAAT,QAA2B,cAA3B;AASA;;;AAGG;;AACH,OAAO,MAAM,iBAAiB,GAAI,OAAD,IAAuC;AACtE,QAAM,OAAO,GAAG,UAAU,EAA1B;;AAEA,MAAI,OAAJ,EAAa;AACX,IAAA,WAAW,CAAC,OAAD,CAAX;AACD;;AAED,SAAO,oBAAoB,CAAC;AAC1B,IAAA,QAAQ,EAAE;AACR,MAAA,WAAW,EAAE,cAAc,CAAC,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,WAAV;AADnB;AADgB,GAAD,CAA3B;AAKD,CAZM;;AAcP,MAAM,cAAc,GAClB,WADqB,IAEoB;AACzC,UAAQ,WAAR;AACE,SAAK,WAAL;AACE,aAAO,KAAK,CAAC,qBAAN,CAA4B,SAAnC;;AACF,SAAK,SAAL;AACE,aAAO,KAAK,CAAC,qBAAN,CAA4B,OAAnC;;AACF,SAAK,kBAAL;AACE,aAAO,KAAK,CAAC,qBAAN,CAA4B,gBAAnC;;AACF;AACE,aAAO,SAAP;AARJ;AAUD,CAbD","sourcesContent":["import { Types, getGroupper } from 'tabster';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { useTabster } from './useTabster';\n\nexport interface UseFocusableGroupOptions {\n /**\n * Behavior for the Tab key.\n */\n tabBehavior?: 'unlimited' | 'limited' | 'limitedTrapFocus';\n}\n\n/**\n * A hook that returns the necessary tabster attributes to support groupping.\n * @param options - Options to configure keyboard navigation\n */\nexport const useFocusableGroup = (options?: UseFocusableGroupOptions) => {\n const tabster = useTabster();\n\n if (tabster) {\n getGroupper(tabster);\n }\n\n return useTabsterAttributes({\n groupper: {\n tabbability: getTabbability(options?.tabBehavior),\n },\n });\n};\n\nconst getTabbability = (\n tabBehavior?: UseFocusableGroupOptions['tabBehavior'],\n): Types.GroupperTabbability | undefined => {\n switch (tabBehavior) {\n case 'unlimited':\n return Types.GroupperTabbabilities.Unlimited;\n case 'limited':\n return Types.GroupperTabbabilities.Limited;\n case 'limitedTrapFocus':\n return Types.GroupperTabbabilities.LimitedTrapFocus;\n default:\n return undefined;\n }\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["hooks/useFocusableGroup.ts"],"names":[],"mappings":"AAAA,SAAS,KAAT,EAAgB,WAAhB,QAAmC,SAAnC;AACA,SAAS,oBAAT,QAAqC,wBAArC;AACA,SAAS,UAAT,QAA2B,cAA3B;AASA;;;AAGG;;AACH,OAAO,MAAM,iBAAiB,GAAI,OAAD,IAAkE;AACjG,QAAM,OAAO,GAAG,UAAU,EAA1B;;AAEA,MAAI,OAAJ,EAAa;AACX,IAAA,WAAW,CAAC,OAAD,CAAX;AACD;;AAED,SAAO,oBAAoB,CAAC;AAC1B,IAAA,QAAQ,EAAE;AACR,MAAA,WAAW,EAAE,cAAc,CAAC,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,WAAV;AADnB;AADgB,GAAD,CAA3B;AAKD,CAZM;;AAcP,MAAM,cAAc,GAClB,WADqB,IAEoB;AACzC,UAAQ,WAAR;AACE,SAAK,WAAL;AACE,aAAO,KAAK,CAAC,qBAAN,CAA4B,SAAnC;;AACF,SAAK,SAAL;AACE,aAAO,KAAK,CAAC,qBAAN,CAA4B,OAAnC;;AACF,SAAK,kBAAL;AACE,aAAO,KAAK,CAAC,qBAAN,CAA4B,gBAAnC;;AACF;AACE,aAAO,SAAP;AARJ;AAUD,CAbD","sourcesContent":["import { Types, getGroupper } from 'tabster';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { useTabster } from './useTabster';\n\nexport interface UseFocusableGroupOptions {\n /**\n * Behavior for the Tab key.\n */\n tabBehavior?: 'unlimited' | 'limited' | 'limitedTrapFocus';\n}\n\n/**\n * A hook that returns the necessary tabster attributes to support groupping.\n * @param options - Options to configure keyboard navigation\n */\nexport const useFocusableGroup = (options?: UseFocusableGroupOptions): Types.TabsterDOMAttribute => {\n const tabster = useTabster();\n\n if (tabster) {\n getGroupper(tabster);\n }\n\n return useTabsterAttributes({\n groupper: {\n tabbability: getTabbability(options?.tabBehavior),\n },\n });\n};\n\nconst getTabbability = (\n tabBehavior?: UseFocusableGroupOptions['tabBehavior'],\n): Types.GroupperTabbability | undefined => {\n switch (tabBehavior) {\n case 'unlimited':\n return Types.GroupperTabbabilities.Unlimited;\n case 'limited':\n return Types.GroupperTabbabilities.Limited;\n case 'limitedTrapFocus':\n return Types.GroupperTabbabilities.LimitedTrapFocus;\n default:\n return undefined;\n }\n};\n"],"sourceRoot":"../src/"}
@@ -1,6 +1,6 @@
1
1
  import { createKeyborg } from 'keyborg';
2
2
  import { useEffect, useMemo, useRef } from 'react';
3
- import { KEYBOARD_NAV_ATTRIBUTE } from '../symbols';
3
+ import { KEYBOARD_NAV_ATTRIBUTE } from '../focus/constants';
4
4
  import { useFluent } from '@fluentui/react-shared-contexts';
5
5
  /**
6
6
  * instantiates keyborg and add attribute to ensure focus indicator synced to keyborg logic
@@ -1 +1 @@
1
- {"version":3,"sources":["hooks/useKeyboardNavAttribute.ts"],"names":[],"mappings":"AAAA,SAAS,aAAT,QAA8B,SAA9B;AACA,SAAS,SAAT,EAAoB,OAApB,EAA6B,MAA7B,QAA2C,OAA3C;AACA,SAAS,sBAAT,QAAuC,YAAvC;AACA,SAAS,SAAT,QAA0B,iCAA1B;AAIA;;AAEG;;AACH,OAAM,SAAU,uBAAV,GAAiC;AACrC,QAAM;AAAE,IAAA;AAAF,MAAqB,SAAS,EAApC;AACA,QAAM,OAAO,GAAG,OAAO,CAAC,MAAM,cAAc,IAAI,aAAa,CAAC,cAAc,CAAC,WAAhB,CAAtC,EAAqE,CAAC,cAAD,CAArE,CAAvB;AACA,QAAM,GAAG,GAAG,MAAM,CAAI,IAAJ,CAAlB;AACA,EAAA,SAAS,CAAC,MAAK;AACb,QAAI,OAAJ,EAAa;AACX,MAAA,mBAAmB,CAAC,GAAD,EAAM,sBAAN,EAA8B,OAAO,CAAC,wBAAR,EAA9B,CAAnB;;AACA,YAAM,EAAE,GAAoB,IAAI,IAAG;AACjC,QAAA,mBAAmB,CAAC,GAAD,EAAM,sBAAN,EAA8B,IAA9B,CAAnB;AACD,OAFD;;AAGA,MAAA,OAAO,CAAC,SAAR,CAAkB,EAAlB;AACA,aAAO,MAAM,OAAO,CAAC,WAAR,CAAoB,EAApB,CAAb;AACD;AACF,GATQ,EASN,CAAC,OAAD,CATM,CAAT;AAUA,SAAO,GAAP;AACD;;AAED,SAAS,mBAAT,CAA6B,UAA7B,EAAiE,SAAjE,EAAoF,KAApF,EAAkG;AAChG,MAAI,CAAC,UAAU,CAAC,OAAhB,EAAyB;AACvB;AACD;;AACD,MAAI,KAAJ,EAAW;AACT,IAAA,UAAU,CAAC,OAAX,CAAmB,YAAnB,CAAgC,SAAhC,EAA2C,EAA3C;AACD,GAFD,MAEO;AACL,IAAA,UAAU,CAAC,OAAX,CAAmB,eAAnB,CAAmC,SAAnC;AACD;AACF","sourcesContent":["import { createKeyborg } from 'keyborg';\nimport { useEffect, useMemo, useRef } from 'react';\nimport { KEYBOARD_NAV_ATTRIBUTE } from '../symbols';\nimport { useFluent } from '@fluentui/react-shared-contexts';\nimport type { KeyborgCallback } from 'keyborg/dist/Keyborg';\nimport type { RefObject } from 'react';\n\n/**\n * instantiates keyborg and add attribute to ensure focus indicator synced to keyborg logic\n */\nexport function useKeyboardNavAttribute<E extends HTMLElement>() {\n const { targetDocument } = useFluent();\n const keyborg = useMemo(() => targetDocument && createKeyborg(targetDocument.defaultView!), [targetDocument]);\n const ref = useRef<E>(null);\n useEffect(() => {\n if (keyborg) {\n setBooleanAttribute(ref, KEYBOARD_NAV_ATTRIBUTE, keyborg.isNavigatingWithKeyboard());\n const cb: KeyborgCallback = next => {\n setBooleanAttribute(ref, KEYBOARD_NAV_ATTRIBUTE, next);\n };\n keyborg.subscribe(cb);\n return () => keyborg.unsubscribe(cb);\n }\n }, [keyborg]);\n return ref;\n}\n\nfunction setBooleanAttribute(elementRef: RefObject<HTMLElement>, attribute: string, value: boolean) {\n if (!elementRef.current) {\n return;\n }\n if (value) {\n elementRef.current.setAttribute(attribute, '');\n } else {\n elementRef.current.removeAttribute(attribute);\n }\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["hooks/useKeyboardNavAttribute.ts"],"names":[],"mappings":"AAAA,SAAS,aAAT,QAA8B,SAA9B;AACA,SAAS,SAAT,EAAoB,OAApB,EAA6B,MAA7B,QAA2C,OAA3C;AACA,SAAS,sBAAT,QAAuC,oBAAvC;AACA,SAAS,SAAT,QAA0B,iCAA1B;AAIA;;AAEG;;AACH,OAAM,SAAU,uBAAV,GAAiC;AACrC,QAAM;AAAE,IAAA;AAAF,MAAqB,SAAS,EAApC;AACA,QAAM,OAAO,GAAG,OAAO,CAAC,MAAM,cAAc,IAAI,aAAa,CAAC,cAAc,CAAC,WAAhB,CAAtC,EAAqE,CAAC,cAAD,CAArE,CAAvB;AACA,QAAM,GAAG,GAAG,MAAM,CAAI,IAAJ,CAAlB;AACA,EAAA,SAAS,CAAC,MAAK;AACb,QAAI,OAAJ,EAAa;AACX,MAAA,mBAAmB,CAAC,GAAD,EAAM,sBAAN,EAA8B,OAAO,CAAC,wBAAR,EAA9B,CAAnB;;AACA,YAAM,EAAE,GAAoB,IAAI,IAAG;AACjC,QAAA,mBAAmB,CAAC,GAAD,EAAM,sBAAN,EAA8B,IAA9B,CAAnB;AACD,OAFD;;AAGA,MAAA,OAAO,CAAC,SAAR,CAAkB,EAAlB;AACA,aAAO,MAAM,OAAO,CAAC,WAAR,CAAoB,EAApB,CAAb;AACD;AACF,GATQ,EASN,CAAC,OAAD,CATM,CAAT;AAUA,SAAO,GAAP;AACD;;AAED,SAAS,mBAAT,CAA6B,UAA7B,EAAiE,SAAjE,EAAoF,KAApF,EAAkG;AAChG,MAAI,CAAC,UAAU,CAAC,OAAhB,EAAyB;AACvB;AACD;;AACD,MAAI,KAAJ,EAAW;AACT,IAAA,UAAU,CAAC,OAAX,CAAmB,YAAnB,CAAgC,SAAhC,EAA2C,EAA3C;AACD,GAFD,MAEO;AACL,IAAA,UAAU,CAAC,OAAX,CAAmB,eAAnB,CAAmC,SAAnC;AACD;AACF","sourcesContent":["import { createKeyborg } from 'keyborg';\nimport { useEffect, useMemo, useRef } from 'react';\nimport { KEYBOARD_NAV_ATTRIBUTE } from '../focus/constants';\nimport { useFluent } from '@fluentui/react-shared-contexts';\nimport type { KeyborgCallback } from 'keyborg/dist/Keyborg';\nimport type { RefObject } from 'react';\n\n/**\n * instantiates keyborg and add attribute to ensure focus indicator synced to keyborg logic\n */\nexport function useKeyboardNavAttribute<E extends HTMLElement>() {\n const { targetDocument } = useFluent();\n const keyborg = useMemo(() => targetDocument && createKeyborg(targetDocument.defaultView!), [targetDocument]);\n const ref = useRef<E>(null);\n useEffect(() => {\n if (keyborg) {\n setBooleanAttribute(ref, KEYBOARD_NAV_ATTRIBUTE, keyborg.isNavigatingWithKeyboard());\n const cb: KeyborgCallback = next => {\n setBooleanAttribute(ref, KEYBOARD_NAV_ATTRIBUTE, next);\n };\n keyborg.subscribe(cb);\n return () => keyborg.unsubscribe(cb);\n }\n }, [keyborg]);\n return ref;\n}\n\nfunction setBooleanAttribute(elementRef: RefObject<HTMLElement>, attribute: string, value: boolean) {\n if (!elementRef.current) {\n return;\n }\n if (value) {\n elementRef.current.setAttribute(attribute, '');\n } else {\n elementRef.current.removeAttribute(attribute);\n }\n}\n"],"sourceRoot":"../src/"}
package/lib/index.d.ts CHANGED
@@ -1 +1,4 @@
1
- export * from './hooks/index';
1
+ export { useArrowNavigationGroup, useFocusableGroup, useFocusFinders, useKeyboardNavAttribute, useModalAttributes, useTabsterAttributes, } from './hooks/index';
2
+ export type { UseArrowNavigationGroupOptions, UseFocusableGroupOptions, UseModalAttributesOptions, } from './hooks/index';
3
+ export { createCustomFocusIndicatorStyle, createFocusOutlineStyle } from './focus/index';
4
+ export type { CreateCustomFocusIndicatorStyleOptions, CreateFocusOutlineStyleOptions, FocusOutlineOffset, FocusOutlineStyleOptions, } from './focus/index';
package/lib/index.js CHANGED
@@ -1,2 +1,3 @@
1
- export * from './hooks/index';
1
+ export { useArrowNavigationGroup, useFocusableGroup, useFocusFinders, useKeyboardNavAttribute, useModalAttributes, useTabsterAttributes } from './hooks/index';
2
+ export { createCustomFocusIndicatorStyle, createFocusOutlineStyle } from './focus/index';
2
3
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC","sourcesContent":["export * from './hooks/index';\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,SACE,uBADF,EAEE,iBAFF,EAGE,eAHF,EAIE,uBAJF,EAKE,kBALF,EAME,oBANF,QAOO,eAPP;AAcA,SAAS,+BAAT,EAA0C,uBAA1C,QAAyE,eAAzE","sourcesContent":["export {\n useArrowNavigationGroup,\n useFocusableGroup,\n useFocusFinders,\n useKeyboardNavAttribute,\n useModalAttributes,\n useTabsterAttributes,\n} from './hooks/index';\nexport type {\n UseArrowNavigationGroupOptions,\n UseFocusableGroupOptions,\n UseModalAttributesOptions,\n} from './hooks/index';\n\nexport { createCustomFocusIndicatorStyle, createFocusOutlineStyle } from './focus/index';\n\nexport type {\n CreateCustomFocusIndicatorStyleOptions,\n CreateFocusOutlineStyleOptions,\n FocusOutlineOffset,\n FocusOutlineStyleOptions,\n} from './focus/index';\n"],"sourceRoot":"../src/"}
@@ -1,2 +1,6 @@
1
1
  export declare const KEYBOARD_NAV_ATTRIBUTE: "data-keyboard-nav";
2
2
  export declare const KEYBOARD_NAV_SELECTOR: ":global([data-keyboard-nav])";
3
+ export declare const defaultOptions: {
4
+ readonly style: {};
5
+ readonly selector: "focus";
6
+ };
@@ -3,7 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.KEYBOARD_NAV_SELECTOR = exports.KEYBOARD_NAV_ATTRIBUTE = void 0;
6
+ exports.defaultOptions = exports.KEYBOARD_NAV_SELECTOR = exports.KEYBOARD_NAV_ATTRIBUTE = void 0;
7
7
  exports.KEYBOARD_NAV_ATTRIBUTE = 'data-keyboard-nav';
8
8
  exports.KEYBOARD_NAV_SELECTOR = `:global([${exports.KEYBOARD_NAV_ATTRIBUTE}])`;
9
- //# sourceMappingURL=symbols.js.map
9
+ exports.defaultOptions = {
10
+ style: {},
11
+ selector: 'focus'
12
+ };
13
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["focus/constants.ts"],"names":[],"mappings":";;;;;;AAAa,OAAA,CAAA,sBAAA,GAAyB,mBAAzB;AACA,OAAA,CAAA,qBAAA,GAAwB,YAAY,OAAA,CAAA,sBAAsB,IAA1D;AACA,OAAA,CAAA,cAAA,GAAiB;AAC5B,EAAA,KAAK,EAAE,EADqB;AAE5B,EAAA,QAAQ,EAAE;AAFkB,CAAjB","sourcesContent":["export const KEYBOARD_NAV_ATTRIBUTE = 'data-keyboard-nav' as const;\nexport const KEYBOARD_NAV_SELECTOR = `:global([${KEYBOARD_NAV_ATTRIBUTE}])` as const;\nexport const defaultOptions = {\n style: {},\n selector: 'focus',\n} as const;\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,12 @@
1
+ import type { GriffelStyle } from '@griffel/react';
2
+ export interface CreateCustomFocusIndicatorStyleOptions {
3
+ selector?: 'focus' | 'focus-within';
4
+ }
5
+ /**
6
+ * Creates a style for @see makeStyles that includes the necessary selectors for focus.
7
+ * Should be used only when @see createFocusOutlineStyle does not fit requirements
8
+ *
9
+ * @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes
10
+ * @param options - Configure the style of the focus outline
11
+ */
12
+ export declare const createCustomFocusIndicatorStyle: (style: GriffelStyle, { selector }?: CreateCustomFocusIndicatorStyleOptions) => GriffelStyle;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCustomFocusIndicatorStyle = void 0;
7
+
8
+ const constants_1 = /*#__PURE__*/require("./constants");
9
+ /**
10
+ * Creates a style for @see makeStyles that includes the necessary selectors for focus.
11
+ * Should be used only when @see createFocusOutlineStyle does not fit requirements
12
+ *
13
+ * @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes
14
+ * @param options - Configure the style of the focus outline
15
+ */
16
+
17
+
18
+ const createCustomFocusIndicatorStyle = (style, {
19
+ selector = constants_1.defaultOptions.selector
20
+ } = constants_1.defaultOptions) => ({
21
+ ':focus-visible': {
22
+ outlineStyle: 'none'
23
+ },
24
+ [`${constants_1.KEYBOARD_NAV_SELECTOR} :${selector}`]: style
25
+ });
26
+
27
+ exports.createCustomFocusIndicatorStyle = createCustomFocusIndicatorStyle;
28
+ //# sourceMappingURL=createCustomFocusIndicatorStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["focus/createCustomFocusIndicatorStyle.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AAOA;;;;;;AAMG;;;AACI,MAAM,+BAA+B,GAAG,CAC7C,KAD6C,EAE7C;AAAE,EAAA,QAAQ,GAAG,WAAA,CAAA,cAAA,CAAe;AAA5B,IAAiF,WAAA,CAAA,cAFpC,MAG3B;AAClB,oBAAkB;AAChB,IAAA,YAAY,EAAE;AADE,GADA;AAIlB,GAAC,GAAG,WAAA,CAAA,qBAAqB,KAAK,QAAQ,EAAtC,GAA2C;AAJzB,CAH2B,CAAxC;;AAAM,OAAA,CAAA,+BAAA,GAA+B,+BAA/B","sourcesContent":["import { KEYBOARD_NAV_SELECTOR, defaultOptions } from './constants';\nimport type { GriffelStyle } from '@griffel/react';\n\nexport interface CreateCustomFocusIndicatorStyleOptions {\n selector?: 'focus' | 'focus-within';\n}\n\n/**\n * Creates a style for @see makeStyles that includes the necessary selectors for focus.\n * Should be used only when @see createFocusOutlineStyle does not fit requirements\n *\n * @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes\n * @param options - Configure the style of the focus outline\n */\nexport const createCustomFocusIndicatorStyle = (\n style: GriffelStyle,\n { selector = defaultOptions.selector }: CreateCustomFocusIndicatorStyleOptions = defaultOptions,\n): GriffelStyle => ({\n ':focus-visible': {\n outlineStyle: 'none',\n },\n [`${KEYBOARD_NAV_SELECTOR} :${selector}`]: style,\n});\n"],"sourceRoot":"../src/"}
@@ -1,4 +1,5 @@
1
1
  import type { GriffelStyle } from '@griffel/react';
2
+ import { CreateCustomFocusIndicatorStyleOptions } from './createCustomFocusIndicatorStyle';
2
3
  export declare type FocusOutlineOffset = Record<'top' | 'bottom' | 'left' | 'right', string>;
3
4
  export declare type FocusOutlineStyleOptions = {
4
5
  /**
@@ -10,24 +11,14 @@ export declare type FocusOutlineStyleOptions = {
10
11
  outlineWidth: string;
11
12
  outlineOffset?: string | FocusOutlineOffset;
12
13
  };
13
- export interface CreateFocusIndicatorStyleRuleOptions {
14
- selector?: 'focus' | 'focus-within';
14
+ export interface CreateFocusOutlineStyleOptions extends CreateCustomFocusIndicatorStyleOptions {
15
+ style?: Partial<FocusOutlineStyleOptions>;
15
16
  }
16
17
  /**
17
18
  * NOTE: The element with the focus outline needs to have `position: relative` so that the
18
19
  * pseudo element can be properly positioned.
19
20
  *
20
- * @param theme - Theme used in @see makeStyles
21
21
  * @param options - Configure the style of the focus outline
22
22
  * @returns focus outline styles object for @see makeStyles
23
23
  */
24
- export declare const createFocusOutlineStyle: (options?: {
25
- style: Partial<FocusOutlineStyleOptions>;
26
- } & CreateFocusIndicatorStyleRuleOptions) => GriffelStyle;
27
- /**
28
- * Creates a style for @see makeStyles that includes the necessary selectors for focus.
29
- * Should be used only when @see createFocusOutlineStyle does not fit requirements
30
- *
31
- * @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes
32
- */
33
- export declare const createCustomFocusIndicatorStyle: (style: GriffelStyle, options?: CreateFocusIndicatorStyleRuleOptions) => GriffelStyle;
24
+ export declare const createFocusOutlineStyle: ({ selector, style, }?: CreateFocusOutlineStyleOptions) => GriffelStyle;