@fluentui/react-tabster 9.0.0-nightly.d730088d7f.0 → 9.0.0-rc.10

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 (88) hide show
  1. package/CHANGELOG.json +502 -15
  2. package/CHANGELOG.md +223 -84
  3. package/README.md +5 -14
  4. package/dist/{react-tabster.d.ts → index.d.ts} +19 -30
  5. package/{lib → dist}/tsdoc-metadata.json +0 -0
  6. package/lib/focus/constants.js +7 -0
  7. package/lib/focus/constants.js.map +1 -0
  8. package/lib/focus/createCustomFocusIndicatorStyle.js +18 -0
  9. package/lib/focus/createCustomFocusIndicatorStyle.js.map +1 -0
  10. package/lib/focus/createFocusOutlineStyle.js +64 -0
  11. package/lib/focus/createFocusOutlineStyle.js.map +1 -0
  12. package/lib/focus/index.js +3 -0
  13. package/lib/focus/index.js.map +1 -0
  14. package/lib/hooks/index.js +2 -3
  15. package/lib/hooks/index.js.map +1 -1
  16. package/lib/hooks/useArrowNavigationGroup.js +7 -3
  17. package/lib/hooks/useArrowNavigationGroup.js.map +1 -1
  18. package/lib/hooks/useFocusFinders.js +25 -33
  19. package/lib/hooks/useFocusFinders.js.map +1 -1
  20. package/lib/hooks/useFocusableGroup.js +19 -22
  21. package/lib/hooks/useFocusableGroup.js.map +1 -1
  22. package/lib/hooks/useKeyboardNavAttribute.js +10 -12
  23. package/lib/hooks/useKeyboardNavAttribute.js.map +1 -1
  24. package/lib/hooks/useModalAttributes.js +12 -14
  25. package/lib/hooks/useModalAttributes.js.map +1 -1
  26. package/lib/hooks/useTabster.js +8 -5
  27. package/lib/hooks/useTabster.js.map +1 -1
  28. package/lib/hooks/useTabsterAttributes.js +1 -1
  29. package/lib/hooks/useTabsterAttributes.js.map +1 -1
  30. package/lib/index.js +2 -1
  31. package/lib/index.js.map +1 -1
  32. package/lib-commonjs/focus/constants.js +13 -0
  33. package/lib-commonjs/focus/constants.js.map +1 -0
  34. package/lib-commonjs/focus/createCustomFocusIndicatorStyle.js +28 -0
  35. package/lib-commonjs/focus/createCustomFocusIndicatorStyle.js.map +1 -0
  36. package/lib-commonjs/focus/createFocusOutlineStyle.js +77 -0
  37. package/lib-commonjs/focus/createFocusOutlineStyle.js.map +1 -0
  38. package/lib-commonjs/focus/index.js +12 -0
  39. package/lib-commonjs/focus/index.js.map +1 -0
  40. package/lib-commonjs/hooks/index.js +5 -7
  41. package/lib-commonjs/hooks/index.js.map +1 -1
  42. package/lib-commonjs/hooks/useArrowNavigationGroup.js +10 -6
  43. package/lib-commonjs/hooks/useArrowNavigationGroup.js.map +1 -1
  44. package/lib-commonjs/hooks/useFocusFinders.js +27 -35
  45. package/lib-commonjs/hooks/useFocusFinders.js.map +1 -1
  46. package/lib-commonjs/hooks/useFocusableGroup.js +23 -26
  47. package/lib-commonjs/hooks/useFocusableGroup.js.map +1 -1
  48. package/lib-commonjs/hooks/useKeyboardNavAttribute.js +15 -17
  49. package/lib-commonjs/hooks/useKeyboardNavAttribute.js.map +1 -1
  50. package/lib-commonjs/hooks/useModalAttributes.js +16 -18
  51. package/lib-commonjs/hooks/useModalAttributes.js.map +1 -1
  52. package/lib-commonjs/hooks/useTabster.js +10 -7
  53. package/lib-commonjs/hooks/useTabster.js.map +1 -1
  54. package/lib-commonjs/hooks/useTabsterAttributes.js +3 -3
  55. package/lib-commonjs/hooks/useTabsterAttributes.js.map +1 -1
  56. package/lib-commonjs/index.js +53 -2
  57. package/lib-commonjs/index.js.map +1 -1
  58. package/package.json +21 -19
  59. package/lib/hooks/index.d.ts +0 -7
  60. package/lib/hooks/useArrowNavigationGroup.d.ts +0 -22
  61. package/lib/hooks/useFocusFinders.d.ts +0 -10
  62. package/lib/hooks/useFocusIndicatorStyle.d.ts +0 -34
  63. package/lib/hooks/useFocusIndicatorStyle.js +0 -96
  64. package/lib/hooks/useFocusIndicatorStyle.js.map +0 -1
  65. package/lib/hooks/useFocusableGroup.d.ts +0 -26
  66. package/lib/hooks/useKeyboardNavAttribute.d.ts +0 -5
  67. package/lib/hooks/useModalAttributes.d.ts +0 -22
  68. package/lib/hooks/useTabster.d.ts +0 -9
  69. package/lib/hooks/useTabsterAttributes.d.ts +0 -5
  70. package/lib/index.d.ts +0 -1
  71. package/lib/symbols.d.ts +0 -2
  72. package/lib/symbols.js +0 -3
  73. package/lib/symbols.js.map +0 -1
  74. package/lib-commonjs/hooks/index.d.ts +0 -7
  75. package/lib-commonjs/hooks/useArrowNavigationGroup.d.ts +0 -22
  76. package/lib-commonjs/hooks/useFocusFinders.d.ts +0 -10
  77. package/lib-commonjs/hooks/useFocusIndicatorStyle.d.ts +0 -34
  78. package/lib-commonjs/hooks/useFocusIndicatorStyle.js +0 -109
  79. package/lib-commonjs/hooks/useFocusIndicatorStyle.js.map +0 -1
  80. package/lib-commonjs/hooks/useFocusableGroup.d.ts +0 -26
  81. package/lib-commonjs/hooks/useKeyboardNavAttribute.d.ts +0 -5
  82. package/lib-commonjs/hooks/useModalAttributes.d.ts +0 -22
  83. package/lib-commonjs/hooks/useTabster.d.ts +0 -9
  84. package/lib-commonjs/hooks/useTabsterAttributes.d.ts +0 -5
  85. package/lib-commonjs/index.d.ts +0 -1
  86. package/lib-commonjs/symbols.d.ts +0 -2
  87. package/lib-commonjs/symbols.js +0 -9
  88. package/lib-commonjs/symbols.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useTabster.ts"],"names":[],"mappings":"AAAA,SAAS,SAAT,QAA0B,iCAA1B;AACA,SAAS,iBAAT,EAA4B,aAA5B,QAAwE,SAAxE;AAEA;;;;;;AAMG;;AACH,OAAO,IAAM,UAAU,GAAG,YAAA;;;AAChB,MAAA,cAAc,GAAK,SAAS,GAAd,cAAd;AAER,MAAM,WAAW,GAAG,CAAA,cAAc,KAAA,IAAd,IAAA,cAAc,KAAA,KAAA,CAAd,GAAc,KAAA,CAAd,GAAA,cAAc,CAAE,WAAhB,KAA+B,SAAnD;AACA,MAAM,cAAc,GAAG;AAAE,IAAA,QAAQ,EAAE;AAAZ,GAAvB;;AAEA,MAAI,CAAC,WAAL,EAAkB;AAChB,WAAO,IAAP;AACD,GARuB,CAUxB;;;AACA,SAAA,CAAA,EAAA,GAAO,iBAAiB,CAAC,WAAD,CAAxB,MAAqC,IAArC,IAAqC,EAAA,KAAA,KAAA,CAArC,GAAqC,EAArC,GAAyC,aAAa,CAAC,WAAD,EAAc,cAAd,CAAtD;AACD,CAZM","sourceRoot":""}
1
+ {"version":3,"sources":["hooks/useTabster.ts"],"names":[],"mappings":"AAAA,SAAS,SAAT,QAA0B,iCAA1B;AACA,SAAS,iBAAT,EAA4B,aAA5B,QAAwE,SAAxE;AAEA;;;;;;AAMG;;AACH,OAAO,MAAM,UAAU,GAAG,MAAsC;;;AAC9D,QAAM;AAAE,IAAA;AAAF,MAAqB,SAAS,EAApC;AAEA,QAAM,WAAW,GAAG,CAAA,cAAc,KAAA,IAAd,IAAA,cAAc,KAAA,KAAA,CAAd,GAAc,KAAA,CAAd,GAAA,cAAc,CAAE,WAAhB,KAA+B,SAAnD;AACA,QAAM,cAAc,GAAkC;AAAE,IAAA,QAAQ,EAAE,EAAZ;AAAgB,IAAA,UAAU,EAAE;AAA5B,GAAtD;;AAEA,MAAI,CAAC,WAAL,EAAkB;AAChB,WAAO,IAAP;AACD,GAR6D,CAU9D;;;AACA,SAAO,CAAA,EAAA,GAAA,iBAAiB,CAAC,WAAD,CAAjB,MAA8B,IAA9B,IAA8B,EAAA,KAAA,KAAA,CAA9B,GAA8B,EAA9B,GAAkC,aAAa,CAAC,WAAD,EAAc,cAAd,CAAtD;AACD,CAZM","sourcesContent":["import { useFluent } from '@fluentui/react-shared-contexts';\nimport { getCurrentTabster, createTabster, Types as TabsterTypes } from 'tabster';\n\n/**\n * Tries to get a tabster instance on the current window or creates a new one\n * Since Tabster is single instance only, feel free to call this hook to ensure Tabster exists if necessary\n *\n * @internal\n * @returns Tabster core instance\n */\nexport const useTabster = (): TabsterTypes.TabsterCore | null => {\n const { targetDocument } = useFluent();\n\n const defaultView = targetDocument?.defaultView || undefined;\n const tabsterOptions: TabsterTypes.TabsterCoreProps = { autoRoot: {}, controlTab: false };\n\n if (!defaultView) {\n return null;\n }\n\n // TODO: worth memoizing once more tabster options are used\n return getCurrentTabster(defaultView) ?? createTabster(defaultView, tabsterOptions);\n};\n"],"sourceRoot":"../src/"}
@@ -4,7 +4,7 @@ import { useTabster } from './useTabster';
4
4
  * Hook that returns tabster attributes while ensuring tabster exists
5
5
  */
6
6
 
7
- export var useTabsterAttributes = function (props) {
7
+ export const useTabsterAttributes = props => {
8
8
  // A tabster instance is not necessary to generate tabster attributes
9
9
  // but calling the hook will ensure that a tabster instance exists internally and avoids consumers doing the same
10
10
  useTabster();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useTabsterAttributes.ts"],"names":[],"mappings":"AAAA,SAAS,mBAAT,QAA2D,SAA3D;AACA,SAAS,UAAT,QAA2B,cAA3B;AAEA;;AAEG;;AACH,OAAO,IAAM,oBAAoB,GAAG,UAAC,KAAD,EAA0C;AAC5E;AACA;AACA,EAAA,UAAU;AAEV,SAAO,mBAAmB,CAAC,KAAD,CAA1B;AACD,CANM","sourceRoot":""}
1
+ {"version":3,"sources":["hooks/useTabsterAttributes.ts"],"names":[],"mappings":"AAAA,SAAS,mBAAT,QAA2D,SAA3D;AACA,SAAS,UAAT,QAA2B,cAA3B;AAEA;;AAEG;;AACH,OAAO,MAAM,oBAAoB,GAAI,KAAD,IAAgF;AAClH;AACA;AACA,EAAA,UAAU;AAEV,SAAO,mBAAmB,CAAC,KAAD,CAA1B;AACD,CANM","sourcesContent":["import { getTabsterAttribute, Types as TabsterTypes } from 'tabster';\nimport { useTabster } from './useTabster';\n\n/**\n * Hook that returns tabster attributes while ensuring tabster exists\n */\nexport const useTabsterAttributes = (props: TabsterTypes.TabsterAttributeProps): TabsterTypes.TabsterDOMAttribute => {\n // A tabster instance is not necessary to generate tabster attributes\n // but calling the hook will ensure that a tabster instance exists internally and avoids consumers doing the same\n useTabster();\n\n return getTabsterAttribute(props);\n};\n"],"sourceRoot":"../src/"}
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":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
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/"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.defaultOptions = exports.KEYBOARD_NAV_SELECTOR = exports.KEYBOARD_NAV_ATTRIBUTE = void 0;
7
+ exports.KEYBOARD_NAV_ATTRIBUTE = 'data-keyboard-nav';
8
+ exports.KEYBOARD_NAV_SELECTOR = `:global([${exports.KEYBOARD_NAV_ATTRIBUTE}])`;
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,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/"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFocusOutlineStyle = void 0;
7
+
8
+ const react_theme_1 = /*#__PURE__*/require("@fluentui/react-theme");
9
+
10
+ const react_1 = /*#__PURE__*/require("@griffel/react");
11
+
12
+ const createCustomFocusIndicatorStyle_1 = /*#__PURE__*/require("./createCustomFocusIndicatorStyle");
13
+
14
+ const constants_1 = /*#__PURE__*/require("./constants");
15
+ /**
16
+ * NOTE: the element with the focus outline needs to have `position: relative` so that the
17
+ * pseudo element can be properly positioned.
18
+ *
19
+ * @param options - Configures the style of the focus outline
20
+ * @returns focus outline styles object
21
+ */
22
+
23
+
24
+ const getFocusOutlineStyles = options => {
25
+ var _a, _b, _c, _d;
26
+
27
+ const {
28
+ outlineRadius,
29
+ outlineColor,
30
+ outlineOffset,
31
+ outlineWidth
32
+ } = options;
33
+ const outlineOffsetTop = ((_a = outlineOffset) === null || _a === void 0 ? void 0 : _a.top) || outlineOffset;
34
+ const outlineOffsetBottom = ((_b = outlineOffset) === null || _b === void 0 ? void 0 : _b.bottom) || outlineOffset;
35
+ const outlineOffsetLeft = ((_c = outlineOffset) === null || _c === void 0 ? void 0 : _c.left) || outlineOffset;
36
+ const outlineOffsetRight = ((_d = outlineOffset) === null || _d === void 0 ? void 0 : _d.right) || outlineOffset;
37
+ return { ...react_1.shorthands.borderColor('transparent'),
38
+ ':after': {
39
+ content: '""',
40
+ position: 'absolute',
41
+ pointerEvents: 'none',
42
+ zIndex: 1,
43
+ ...react_1.shorthands.borderStyle('solid'),
44
+ ...react_1.shorthands.borderWidth(outlineWidth),
45
+ ...react_1.shorthands.borderRadius(outlineRadius),
46
+ ...react_1.shorthands.borderColor(outlineColor),
47
+ top: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetTop})`,
48
+ bottom: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetBottom})`,
49
+ left: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetLeft})`,
50
+ right: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetRight})`
51
+ }
52
+ };
53
+ };
54
+ /**
55
+ * NOTE: The element with the focus outline needs to have `position: relative` so that the
56
+ * pseudo element can be properly positioned.
57
+ *
58
+ * @param options - Configure the style of the focus outline
59
+ * @returns focus outline styles object for @see makeStyles
60
+ */
61
+
62
+
63
+ const createFocusOutlineStyle = ({
64
+ selector = constants_1.defaultOptions.selector,
65
+ style = constants_1.defaultOptions.style
66
+ } = constants_1.defaultOptions) => createCustomFocusIndicatorStyle_1.createCustomFocusIndicatorStyle(getFocusOutlineStyles({
67
+ outlineColor: react_theme_1.tokens.colorStrokeFocus2,
68
+ outlineRadius: react_theme_1.tokens.borderRadiusMedium,
69
+ // FIXME: tokens.strokeWidthThick causes some weird bugs
70
+ outlineWidth: '2px',
71
+ ...style
72
+ }), {
73
+ selector
74
+ });
75
+
76
+ exports.createFocusOutlineStyle = createFocusOutlineStyle;
77
+ //# sourceMappingURL=createFocusOutlineStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["focus/createFocusOutlineStyle.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAEA,MAAA,iCAAA,gBAAA,OAAA,CAAA,mCAAA,CAAA;;AAIA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;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,MAA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,CAAA,cAAA,CAAe,QADY;AAEtC,EAAA,KAAK,GAAG,WAAA,CAAA,cAAA,CAAe;AAFe,IAGJ,WAAA,CAAA,cAHG,KAIrC,iCAAA,CAAA,+BAAA,CACE,qBAAqB,CAAC;AACpB,EAAA,YAAY,EAAE,aAAA,CAAA,MAAA,CAAO,iBADD;AAEpB,EAAA,aAAa,EAAE,aAAA,CAAA,MAAA,CAAO,kBAFF;AAGpB;AACA,EAAA,YAAY,EAAE,KAJM;AAKpB,KAAG;AALiB,CAAD,CADvB,EAQE;AAAE,EAAA;AAAF,CARF,CAJK;;AAAM,OAAA,CAAA,uBAAA,GAAuB,uBAAvB","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,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./createCustomFocusIndicatorStyle"), exports);
10
+
11
+ tslib_1.__exportStar(require("./createFocusOutlineStyle"), exports);
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["focus/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mCAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './createCustomFocusIndicatorStyle';\nexport * from './createFocusOutlineStyle';\n"],"sourceRoot":"../src/"}
@@ -4,19 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var tslib_1 = /*#__PURE__*/require("tslib");
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
8
 
9
9
  tslib_1.__exportStar(require("./useArrowNavigationGroup"), exports);
10
10
 
11
+ tslib_1.__exportStar(require("./useFocusableGroup"), exports);
12
+
11
13
  tslib_1.__exportStar(require("./useFocusFinders"), exports);
12
14
 
15
+ tslib_1.__exportStar(require("./useKeyboardNavAttribute"), exports);
16
+
13
17
  tslib_1.__exportStar(require("./useModalAttributes"), exports);
14
18
 
15
19
  tslib_1.__exportStar(require("./useTabsterAttributes"), exports);
16
-
17
- tslib_1.__exportStar(require("./useFocusIndicatorStyle"), exports);
18
-
19
- tslib_1.__exportStar(require("./useKeyboardNavAttribute"), exports);
20
-
21
- tslib_1.__exportStar(require("./useFocusableGroup"), exports);
22
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,0BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA","sourceRoot":""}
1
+ {"version":3,"sources":["hooks/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './useArrowNavigationGroup';\nexport * from './useFocusableGroup';\nexport * from './useFocusFinders';\nexport * from './useKeyboardNavAttribute';\nexport * from './useModalAttributes';\nexport * from './useTabsterAttributes';\n"],"sourceRoot":"../src/"}
@@ -5,21 +5,21 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useArrowNavigationGroup = void 0;
7
7
 
8
- var tabster_1 = /*#__PURE__*/require("tabster");
8
+ const tabster_1 = /*#__PURE__*/require("tabster");
9
9
 
10
- var useTabsterAttributes_1 = /*#__PURE__*/require("./useTabsterAttributes");
10
+ const useTabsterAttributes_1 = /*#__PURE__*/require("./useTabsterAttributes");
11
11
 
12
- var useTabster_1 = /*#__PURE__*/require("./useTabster");
12
+ const useTabster_1 = /*#__PURE__*/require("./useTabster");
13
13
  /**
14
14
  * A hook that returns the necessary tabster attributes to support arrow key navigation
15
15
  * @param options - Options to configure keyboard navigation
16
16
  */
17
17
 
18
18
 
19
- var useArrowNavigationGroup = function (options) {
19
+ const useArrowNavigationGroup = options => {
20
20
  var _a;
21
21
 
22
- var tabster = useTabster_1.useTabster();
22
+ const tabster = useTabster_1.useTabster();
23
23
 
24
24
  if (tabster) {
25
25
  tabster_1.getMover(tabster);
@@ -29,7 +29,8 @@ var useArrowNavigationGroup = function (options) {
29
29
  mover: {
30
30
  cyclic: !!(options === null || options === void 0 ? void 0 : options.circular),
31
31
  direction: axisToMoverDirection((_a = options === null || options === void 0 ? void 0 : options.axis) !== null && _a !== void 0 ? _a : 'vertical'),
32
- memorizeCurrent: options === null || options === void 0 ? void 0 : options.memorizeCurrent
32
+ memorizeCurrent: options === null || options === void 0 ? void 0 : options.memorizeCurrent,
33
+ tabbable: options === null || options === void 0 ? void 0 : options.tabbable
33
34
  }
34
35
  });
35
36
  };
@@ -41,6 +42,9 @@ function axisToMoverDirection(axis) {
41
42
  case 'horizontal':
42
43
  return tabster_1.Types.MoverDirections.Horizontal;
43
44
 
45
+ case 'grid':
46
+ return tabster_1.Types.MoverDirections.Grid;
47
+
44
48
  case 'vertical':
45
49
  default:
46
50
  return tabster_1.Types.MoverDirections.Vertical;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useArrowNavigationGroup.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,IAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,IAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AAmBA;;;AAGG;;;AACI,IAAM,uBAAuB,GAAG,UAAC,OAAD,EAAyC;;;AAC9E,MAAM,OAAO,GAAG,YAAA,CAAA,UAAA,EAAhB;;AAEA,MAAI,OAAJ,EAAa;AACX,IAAA,SAAA,CAAA,QAAA,CAAS,OAAT;AACD;;AAED,SAAO,sBAAA,CAAA,oBAAA,CAAqB;AAC1B,IAAA,KAAK,EAAE;AACL,MAAA,MAAM,EAAE,CAAC,EAAC,OAAO,KAAA,IAAP,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,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,GAArB,CAAP;AAQD,CAfM;;AAAM,OAAA,CAAA,uBAAA,GAAuB,uBAAvB;;AAiBb,SAAS,oBAAT,CAA8B,IAA9B,EAA0E;AACxE,UAAQ,IAAR;AACE,SAAK,YAAL;AACE,aAAO,SAAA,CAAA,KAAA,CAAM,eAAN,CAAsB,UAA7B;;AACF,SAAK,MAAL;AACE,aAAO,SAAA,CAAA,KAAA,CAAM,eAAN,CAAsB,IAA7B;;AAEF,SAAK,UAAL;AACA;AACE,aAAO,SAAA,CAAA,KAAA,CAAM,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/"}
@@ -5,49 +5,41 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useFocusFinders = void 0;
7
7
 
8
- var React = /*#__PURE__*/require("react");
8
+ const React = /*#__PURE__*/require("react");
9
9
 
10
- var useTabster_1 = /*#__PURE__*/require("./useTabster");
10
+ const useTabster_1 = /*#__PURE__*/require("./useTabster");
11
11
  /**
12
12
  * Returns a set of helper functions that will traverse focusable elements in the context of a root DOM element
13
13
  */
14
14
 
15
15
 
16
- var useFocusFinders = function () {
17
- var tabster = useTabster_1.useTabster(); // Narrow props for now and let need dictate additional props in the future
16
+ const useFocusFinders = () => {
17
+ const tabster = useTabster_1.useTabster(); // Narrow props for now and let need dictate additional props in the future
18
18
 
19
- var findAllFocusable = React.useCallback(function (container, acceptCondition) {
20
- return (tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findAll({
21
- container: container,
22
- acceptCondition: acceptCondition
23
- })) || [];
24
- }, [tabster]);
25
- var findFirstFocusable = React.useCallback(function (container) {
26
- return tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findFirst({
27
- container: container
28
- });
29
- }, [tabster]);
30
- var findLastFocusable = React.useCallback(function (container) {
31
- return tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findLast({
32
- container: container
33
- });
34
- }, [tabster]);
35
- var findNextFocusable = React.useCallback(function (currentElement) {
36
- return tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findNext({
37
- currentElement: currentElement
38
- });
39
- }, [tabster]);
40
- var findPrevFocusable = React.useCallback(function (currentElement) {
41
- return tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findPrev({
42
- currentElement: currentElement
43
- });
44
- }, [tabster]);
19
+ const findAllFocusable = React.useCallback((container, acceptCondition) => (tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findAll({
20
+ container,
21
+ acceptCondition
22
+ })) || [], [tabster]);
23
+ const findFirstFocusable = React.useCallback(container => tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findFirst({
24
+ container
25
+ }), [tabster]);
26
+ const findLastFocusable = React.useCallback(container => tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findLast({
27
+ container
28
+ }), [tabster]);
29
+ const findNextFocusable = React.useCallback((currentElement, options = {}) => tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findNext({
30
+ currentElement,
31
+ ...options
32
+ }), [tabster]);
33
+ const findPrevFocusable = React.useCallback((currentElement, options = {}) => tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findPrev({
34
+ currentElement,
35
+ ...options
36
+ }), [tabster]);
45
37
  return {
46
- findAllFocusable: findAllFocusable,
47
- findFirstFocusable: findFirstFocusable,
48
- findLastFocusable: findLastFocusable,
49
- findNextFocusable: findNextFocusable,
50
- findPrevFocusable: findPrevFocusable
38
+ findAllFocusable,
39
+ findFirstFocusable,
40
+ findLastFocusable,
41
+ findNextFocusable,
42
+ findPrevFocusable
51
43
  };
52
44
  };
53
45
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useFocusFinders.ts"],"names":[],"mappings":";;;;;;;AAAA,IA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OAAA,CAAA,eAAA,GAAe,eAAf","sourcesContent":["import * as React from 'react';\nimport { Types as TabsterTypes } from 'tabster';\nimport { useTabster } from './useTabster';\n\n/**\n * Returns a set of helper functions that will traverse focusable elements in the context of a root DOM element\n */\nexport const useFocusFinders = () => {\n const tabster = useTabster();\n\n // Narrow props for now and let need dictate additional props in the future\n const findAllFocusable = React.useCallback(\n (container: HTMLElement, acceptCondition: (el: HTMLElement) => boolean) =>\n tabster?.focusable.findAll({ container, acceptCondition }) || [],\n [tabster],\n );\n\n const findFirstFocusable = React.useCallback(\n (container: HTMLElement) => tabster?.focusable.findFirst({ container }),\n [tabster],\n );\n\n const findLastFocusable = React.useCallback((container: HTMLElement) => tabster?.focusable.findLast({ container }), [\n tabster,\n ]);\n\n const findNextFocusable = React.useCallback(\n (currentElement: HTMLElement, options: Pick<TabsterTypes.FindNextProps, 'container'> = {}) =>\n tabster?.focusable.findNext({ currentElement, ...options }),\n [tabster],\n );\n\n const findPrevFocusable = React.useCallback(\n (currentElement: HTMLElement, options: Pick<TabsterTypes.FindNextProps, 'container'> = {}) =>\n tabster?.focusable.findPrev({ currentElement, ...options }),\n [tabster],\n );\n\n return {\n findAllFocusable,\n findFirstFocusable,\n findLastFocusable,\n findNextFocusable,\n findPrevFocusable,\n };\n};\n"],"sourceRoot":"../src/"}
@@ -3,40 +3,21 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useFocusableGroup = exports.FocusableGroupTabBehavior = void 0;
6
+ exports.useFocusableGroup = void 0;
7
7
 
8
- var tabster_1 = /*#__PURE__*/require("tabster");
8
+ const tabster_1 = /*#__PURE__*/require("tabster");
9
9
 
10
- var useTabsterAttributes_1 = /*#__PURE__*/require("./useTabsterAttributes");
10
+ const useTabsterAttributes_1 = /*#__PURE__*/require("./useTabsterAttributes");
11
11
 
12
- var useTabster_1 = /*#__PURE__*/require("./useTabster");
13
-
14
- var FocusableGroupTabBehavior;
15
-
16
- (function (FocusableGroupTabBehavior) {
17
- /**
18
- * Tab will cycle into and out of the groupper content.
19
- */
20
- FocusableGroupTabBehavior[FocusableGroupTabBehavior["Unlimited"] = tabster_1.Types.GroupperTabbabilities.Unlimited] = "Unlimited";
21
- /**
22
- * Tab will cycle out of the container, but not into it.
23
- */
24
-
25
- FocusableGroupTabBehavior[FocusableGroupTabBehavior["Limited"] = tabster_1.Types.GroupperTabbabilities.Limited] = "Limited";
26
- /**
27
- * Tab only cycles the inner elements.
28
- */
29
-
30
- FocusableGroupTabBehavior[FocusableGroupTabBehavior["LimitedTrapFocus"] = tabster_1.Types.GroupperTabbabilities.LimitedTrapFocus] = "LimitedTrapFocus";
31
- })(FocusableGroupTabBehavior = exports.FocusableGroupTabBehavior || (exports.FocusableGroupTabBehavior = {}));
12
+ const useTabster_1 = /*#__PURE__*/require("./useTabster");
32
13
  /**
33
14
  * A hook that returns the necessary tabster attributes to support groupping.
34
15
  * @param options - Options to configure keyboard navigation
35
16
  */
36
17
 
37
18
 
38
- var useFocusableGroup = function (options) {
39
- var tabster = useTabster_1.useTabster();
19
+ const useFocusableGroup = options => {
20
+ const tabster = useTabster_1.useTabster();
40
21
 
41
22
  if (tabster) {
42
23
  tabster_1.getGroupper(tabster);
@@ -44,10 +25,26 @@ var useFocusableGroup = function (options) {
44
25
 
45
26
  return useTabsterAttributes_1.useTabsterAttributes({
46
27
  groupper: {
47
- tabbability: options === null || options === void 0 ? void 0 : options.tabBehavior
28
+ tabbability: getTabbability(options === null || options === void 0 ? void 0 : options.tabBehavior)
48
29
  }
49
30
  });
50
31
  };
51
32
 
52
33
  exports.useFocusableGroup = useFocusableGroup;
34
+
35
+ const getTabbability = tabBehavior => {
36
+ switch (tabBehavior) {
37
+ case 'unlimited':
38
+ return tabster_1.Types.GroupperTabbabilities.Unlimited;
39
+
40
+ case 'limited':
41
+ return tabster_1.Types.GroupperTabbabilities.Limited;
42
+
43
+ case 'limitedTrapFocus':
44
+ return tabster_1.Types.GroupperTabbabilities.LimitedTrapFocus;
45
+
46
+ default:
47
+ return undefined;
48
+ }
49
+ };
53
50
  //# sourceMappingURL=useFocusableGroup.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useFocusableGroup.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,IAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,IAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;;AAEA,IAAY,yBAAZ;;AAAA,CAAA,UAAY,yBAAZ,EAAqC;AACnC;;AAEG;AACH,EAAA,yBAAA,CAAA,yBAAA,CAAA,WAAA,CAAA,GAAY,SAAA,CAAA,KAAA,CAAM,qBAAN,CAA4B,SAAxC,CAAA,GAAiD,WAAjD;AACA;;AAEG;;AACH,EAAA,yBAAA,CAAA,yBAAA,CAAA,SAAA,CAAA,GAAU,SAAA,CAAA,KAAA,CAAM,qBAAN,CAA4B,OAAtC,CAAA,GAA6C,SAA7C;AACA;;AAEG;;AACH,EAAA,yBAAA,CAAA,yBAAA,CAAA,kBAAA,CAAA,GAAmB,SAAA,CAAA,KAAA,CAAM,qBAAN,CAA4B,gBAA/C,CAAA,GAA+D,kBAA/D;AACD,CAbD,EAAY,yBAAyB,GAAzB,OAAA,CAAA,yBAAA,KAAA,OAAA,CAAA,yBAAA,GAAyB,EAAzB,CAAZ;AAsBA;;;AAGG;;;AACI,IAAM,iBAAiB,GAAG,UAAC,OAAD,EAAmC;AAClE,MAAM,OAAO,GAAG,YAAA,CAAA,UAAA,EAAhB;;AAEA,MAAI,OAAJ,EAAa;AACX,IAAA,SAAA,CAAA,WAAA,CAAY,OAAZ;AACD;;AAED,SAAO,sBAAA,CAAA,oBAAA,CAAqB;AAC1B,IAAA,QAAQ,EAAE;AACR,MAAA,WAAW,EAAE,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE;AADd;AADgB,GAArB,CAAP;AAKD,CAZM;;AAAM,OAAA,CAAA,iBAAA,GAAiB,iBAAjB","sourceRoot":""}
1
+ {"version":3,"sources":["hooks/useFocusableGroup.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,MAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AASA;;;AAGG;;;AACI,MAAM,iBAAiB,GAAI,OAAD,IAAkE;AACjG,QAAM,OAAO,GAAG,YAAA,CAAA,UAAA,EAAhB;;AAEA,MAAI,OAAJ,EAAa;AACX,IAAA,SAAA,CAAA,WAAA,CAAY,OAAZ;AACD;;AAED,SAAO,sBAAA,CAAA,oBAAA,CAAqB;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,GAArB,CAAP;AAKD,CAZM;;AAAM,OAAA,CAAA,iBAAA,GAAiB,iBAAjB;;AAcb,MAAM,cAAc,GAClB,WADqB,IAEoB;AACzC,UAAQ,WAAR;AACE,SAAK,WAAL;AACE,aAAO,SAAA,CAAA,KAAA,CAAM,qBAAN,CAA4B,SAAnC;;AACF,SAAK,SAAL;AACE,aAAO,SAAA,CAAA,KAAA,CAAM,qBAAN,CAA4B,OAAnC;;AACF,SAAK,kBAAL;AACE,aAAO,SAAA,CAAA,KAAA,CAAM,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/"}
@@ -5,36 +5,34 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useKeyboardNavAttribute = void 0;
7
7
 
8
- var keyborg_1 = /*#__PURE__*/require("keyborg");
8
+ const keyborg_1 = /*#__PURE__*/require("keyborg");
9
9
 
10
- var react_1 = /*#__PURE__*/require("react");
10
+ const react_1 = /*#__PURE__*/require("react");
11
11
 
12
- var symbols_1 = /*#__PURE__*/require("../symbols");
12
+ const constants_1 = /*#__PURE__*/require("../focus/constants");
13
13
 
14
- var react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
14
+ const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
15
15
  /**
16
16
  * instantiates keyborg and add attribute to ensure focus indicator synced to keyborg logic
17
17
  */
18
18
 
19
19
 
20
20
  function useKeyboardNavAttribute() {
21
- var targetDocument = react_shared_contexts_1.useFluent().targetDocument;
22
- var keyborg = react_1.useMemo(function () {
23
- return targetDocument && keyborg_1.createKeyborg(targetDocument.defaultView);
24
- }, [targetDocument]);
25
- var ref = react_1.useRef(null);
26
- react_1.useEffect(function () {
21
+ const {
22
+ targetDocument
23
+ } = react_shared_contexts_1.useFluent();
24
+ const keyborg = react_1.useMemo(() => targetDocument && keyborg_1.createKeyborg(targetDocument.defaultView), [targetDocument]);
25
+ const ref = react_1.useRef(null);
26
+ react_1.useEffect(() => {
27
27
  if (keyborg) {
28
- setBooleanAttribute(ref, symbols_1.KEYBOARD_NAV_ATTRIBUTE, keyborg.isNavigatingWithKeyboard());
28
+ setBooleanAttribute(ref, constants_1.KEYBOARD_NAV_ATTRIBUTE, keyborg.isNavigatingWithKeyboard());
29
29
 
30
- var cb_1 = function (next) {
31
- setBooleanAttribute(ref, symbols_1.KEYBOARD_NAV_ATTRIBUTE, next);
30
+ const cb = next => {
31
+ setBooleanAttribute(ref, constants_1.KEYBOARD_NAV_ATTRIBUTE, next);
32
32
  };
33
33
 
34
- keyborg.subscribe(cb_1);
35
- return function () {
36
- return keyborg.unsubscribe(cb_1);
37
- };
34
+ keyborg.subscribe(cb);
35
+ return () => keyborg.unsubscribe(cb);
38
36
  }
39
37
  }, [keyborg]);
40
38
  return ref;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useKeyboardNavAttribute.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,IAAA,OAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,SAAA,gBAAA,OAAA,CAAA,YAAA,CAAA;;AACA,IAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;AAIA;;AAEG;;;AACH,SAAgB,uBAAhB,GAAuC;AAC7B,MAAA,cAAc,GAAK,uBAAA,CAAA,SAAA,GAAL,cAAd;AACR,MAAM,OAAO,GAAG,OAAA,CAAA,OAAA,CAAQ,YAAA;AAAM,WAAA,cAAc,IAAI,SAAA,CAAA,aAAA,CAAc,cAAc,CAA9C,WAAkB,CAAlB;AAA4D,GAA1E,EAA4E,CAAC,cAAD,CAA5E,CAAhB;AACA,MAAM,GAAG,GAAG,OAAA,CAAA,MAAA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AACA,QAAM,OAAO,GAAG,OAAA,CAAA,OAAA,CAAQ,MAAM,cAAc,IAAI,SAAA,CAAA,aAAA,CAAc,cAAc,CAAC,WAA7B,CAAhC,EAA4E,CAAC,cAAD,CAA5E,CAAhB;AACA,QAAM,GAAG,GAAG,OAAA,CAAA,MAAA,CAAU,IAAV,CAAZ;AACA,EAAA,OAAA,CAAA,SAAA,CAAU,MAAK;AACb,QAAI,OAAJ,EAAa;AACX,MAAA,mBAAmB,CAAC,GAAD,EAAM,WAAA,CAAA,sBAAN,EAA8B,OAAO,CAAC,wBAAR,EAA9B,CAAnB;;AACA,YAAM,EAAE,GAAoB,IAAI,IAAG;AACjC,QAAA,mBAAmB,CAAC,GAAD,EAAM,WAAA,CAAA,sBAAN,EAA8B,IAA9B,CAAnB;AACD,OAFD;;AAGA,MAAA,OAAO,CAAC,SAAR,CAAkB,EAAlB;AACA,aAAO,MAAM,OAAO,CAAC,WAAR,CAAoB,EAApB,CAAb;AACD;AACF,GATD,EASG,CAAC,OAAD,CATH;AAUA,SAAO,GAAP;AACD;;AAfD,OAAA,CAAA,uBAAA,GAAA,uBAAA;;AAiBA,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/"}
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useModalAttributes = void 0;
7
7
 
8
- var react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
8
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
9
9
 
10
- var useTabsterAttributes_1 = /*#__PURE__*/require("./useTabsterAttributes");
10
+ const useTabsterAttributes_1 = /*#__PURE__*/require("./useTabsterAttributes");
11
11
 
12
- var tabster_1 = /*#__PURE__*/require("tabster");
12
+ const tabster_1 = /*#__PURE__*/require("tabster");
13
13
 
14
- var useTabster_1 = /*#__PURE__*/require("./useTabster");
14
+ const useTabster_1 = /*#__PURE__*/require("./useTabster");
15
15
  /**
16
16
  * Applies modal dialog behaviour through DOM attributes
17
17
  * Modal element will focus trap and hide other content on the page
@@ -21,35 +21,33 @@ var useTabster_1 = /*#__PURE__*/require("./useTabster");
21
21
  */
22
22
 
23
23
 
24
- var useModalAttributes = function (options) {
25
- if (options === void 0) {
26
- options = {};
27
- }
28
-
29
- var trapFocus = options.trapFocus,
30
- alwaysFocusable = options.alwaysFocusable;
31
- var tabster = useTabster_1.useTabster(); // Initializes the modalizer and deloser APIs
24
+ const useModalAttributes = (options = {}) => {
25
+ const {
26
+ trapFocus,
27
+ alwaysFocusable
28
+ } = options;
29
+ const tabster = useTabster_1.useTabster(); // Initializes the modalizer and deloser APIs
32
30
 
33
31
  if (tabster) {
34
32
  tabster_1.getModalizer(tabster);
35
33
  tabster_1.getDeloser(tabster);
36
34
  }
37
35
 
38
- var id = react_utilities_1.useId('modal-');
39
- var modalAttributes = useTabsterAttributes_1.useTabsterAttributes({
36
+ const id = react_utilities_1.useId('modal-');
37
+ const modalAttributes = useTabsterAttributes_1.useTabsterAttributes({
40
38
  deloser: {},
41
39
  modalizer: {
42
- id: id,
40
+ id,
43
41
  isOthersAccessible: !trapFocus,
44
42
  isAlwaysAccessible: alwaysFocusable
45
43
  }
46
44
  });
47
- var triggerAttributes = useTabsterAttributes_1.useTabsterAttributes({
45
+ const triggerAttributes = useTabsterAttributes_1.useTabsterAttributes({
48
46
  deloser: {}
49
47
  });
50
48
  return {
51
- modalAttributes: modalAttributes,
52
- triggerAttributes: triggerAttributes
49
+ modalAttributes,
50
+ triggerAttributes
53
51
  };
54
52
  };
55
53
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useModalAttributes.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,IAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,IAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,IAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AAcA;;;;;;AAMG;;;AACI,IAAM,kBAAkB,GAAG,UAChC,OADgC,EACO;AAAvC,MAAA,OAAA,KAAA,KAAA,CAAA,EAAA;AAAA,IAAA,OAAA,GAAA,EAAA;AAAuC;;AAE/B,MAAA,SAAS,GAAsB,OAAO,CAA7B,SAAT;AAAA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OAAJ,EAAa;AACX,IAAA,SAAA,CAAA,YAAA,CAAa,OAAb;AACA,IAAA,SAAA,CAAA,UAAA,CAAW,OAAX;AACD;;AAED,QAAM,EAAE,GAAG,iBAAA,CAAA,KAAA,CAAM,QAAN,CAAX;AACA,QAAM,eAAe,GAAG,sBAAA,CAAA,oBAAA,CAAqB;AAC3C,IAAA,OAAO,EAAE,EADkC;AAE3C,IAAA,SAAS,EAAE;AAAE,MAAA,EAAF;AAAM,MAAA,kBAAkB,EAAE,CAAC,SAA3B;AAAsC,MAAA,kBAAkB,EAAE;AAA1D;AAFgC,GAArB,CAAxB;AAKA,QAAM,iBAAiB,GAAG,sBAAA,CAAA,oBAAA,CAAqB;AAC7C,IAAA,OAAO,EAAE;AADoC,GAArB,CAA1B;AAIA,SAAO;AAAE,IAAA,eAAF;AAAmB,IAAA;AAAnB,GAAP;AACD,CAtBM;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB","sourcesContent":["import { useId } from '@fluentui/react-utilities';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { getDeloser, getModalizer, Types as TabsterTypes } from 'tabster';\nimport { useTabster } from './useTabster';\n\nexport interface UseModalAttributesOptions {\n /**\n * Traps focus inside the elements the attributes are applied\n */\n trapFocus?: boolean;\n\n /**\n * Always reachabled in Tab order\n */\n alwaysFocusable?: boolean;\n}\n\n/**\n * Applies modal dialog behaviour through DOM attributes\n * Modal element will focus trap and hide other content on the page\n * The trigger element will be focused if focus is lost after the modal element is removed\n *\n * @returns DOM attributes to apply to the modal element and its trigger\n */\nexport const useModalAttributes = (\n options: UseModalAttributesOptions = {},\n): { modalAttributes: TabsterTypes.TabsterDOMAttribute; triggerAttributes: TabsterTypes.TabsterDOMAttribute } => {\n const { trapFocus, alwaysFocusable } = options;\n const tabster = useTabster();\n // Initializes the modalizer and deloser APIs\n if (tabster) {\n getModalizer(tabster);\n getDeloser(tabster);\n }\n\n const id = useId('modal-');\n const modalAttributes = useTabsterAttributes({\n deloser: {},\n modalizer: { id, isOthersAccessible: !trapFocus, isAlwaysAccessible: alwaysFocusable },\n });\n\n const triggerAttributes = useTabsterAttributes({\n deloser: {},\n });\n\n return { modalAttributes, triggerAttributes };\n};\n"],"sourceRoot":"../src/"}