@fluentui/react-tabster 9.0.0-nightly.f81b28ceb3.1 → 9.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +254 -13
- package/CHANGELOG.md +75 -9
- package/dist/react-tabster.d.ts +10 -27
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useArrowNavigationGroup.js +2 -2
- package/lib/hooks/useArrowNavigationGroup.js.map +1 -1
- package/lib/hooks/useFocusFinders.d.ts +3 -2
- package/lib/hooks/useFocusFinders.js +25 -33
- package/lib/hooks/useFocusFinders.js.map +1 -1
- package/lib/hooks/useFocusIndicatorStyle.d.ts +6 -7
- package/lib/hooks/useFocusIndicatorStyle.js +40 -52
- package/lib/hooks/useFocusIndicatorStyle.js.map +1 -1
- package/lib/hooks/useFocusableGroup.d.ts +2 -16
- package/lib/hooks/useFocusableGroup.js +19 -22
- package/lib/hooks/useFocusableGroup.js.map +1 -1
- package/lib/hooks/useKeyboardNavAttribute.js +9 -11
- package/lib/hooks/useKeyboardNavAttribute.js.map +1 -1
- package/lib/hooks/useModalAttributes.js +12 -14
- package/lib/hooks/useModalAttributes.js.map +1 -1
- package/lib/hooks/useTabster.js +8 -5
- package/lib/hooks/useTabster.js.map +1 -1
- package/lib/hooks/useTabsterAttributes.js +1 -1
- package/lib/hooks/useTabsterAttributes.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/symbols.js +2 -2
- package/lib/symbols.js.map +1 -1
- package/lib-commonjs/hooks/index.js +1 -1
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useArrowNavigationGroup.js +5 -5
- package/lib-commonjs/hooks/useArrowNavigationGroup.js.map +1 -1
- package/lib-commonjs/hooks/useFocusFinders.d.ts +3 -2
- package/lib-commonjs/hooks/useFocusFinders.js +27 -35
- package/lib-commonjs/hooks/useFocusFinders.js.map +1 -1
- package/lib-commonjs/hooks/useFocusIndicatorStyle.d.ts +6 -7
- package/lib-commonjs/hooks/useFocusIndicatorStyle.js +41 -53
- package/lib-commonjs/hooks/useFocusIndicatorStyle.js.map +1 -1
- package/lib-commonjs/hooks/useFocusableGroup.d.ts +2 -16
- package/lib-commonjs/hooks/useFocusableGroup.js +23 -26
- package/lib-commonjs/hooks/useFocusableGroup.js.map +1 -1
- package/lib-commonjs/hooks/useKeyboardNavAttribute.js +13 -15
- package/lib-commonjs/hooks/useKeyboardNavAttribute.js.map +1 -1
- package/lib-commonjs/hooks/useModalAttributes.js +16 -18
- package/lib-commonjs/hooks/useModalAttributes.js.map +1 -1
- package/lib-commonjs/hooks/useTabster.js +10 -7
- package/lib-commonjs/hooks/useTabster.js.map +1 -1
- package/lib-commonjs/hooks/useTabsterAttributes.js +3 -3
- package/lib-commonjs/hooks/useTabsterAttributes.js.map +1 -1
- package/lib-commonjs/index.js +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/symbols.js +1 -1
- package/lib-commonjs/symbols.js.map +1 -1
- package/package.json +11 -11
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { tokens } from '@fluentui/react-theme';
|
2
2
|
import { KEYBOARD_NAV_SELECTOR } from '../symbols';
|
3
3
|
/**
|
4
4
|
* NOTE: the element with the focus outline needs to have `position: relative` so that the
|
@@ -8,17 +8,19 @@ import { KEYBOARD_NAV_SELECTOR } from '../symbols';
|
|
8
8
|
* @returns focus outline styles object
|
9
9
|
*/
|
10
10
|
|
11
|
-
|
11
|
+
const getFocusOutlineStyles = options => {
|
12
12
|
var _a, _b, _c, _d;
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
const {
|
15
|
+
outlineRadius,
|
16
|
+
outlineColor,
|
17
|
+
outlineOffset,
|
18
|
+
outlineWidth
|
19
|
+
} = options;
|
20
|
+
const outlineOffsetTop = ((_a = outlineOffset) === null || _a === void 0 ? void 0 : _a.top) || outlineOffset;
|
21
|
+
const outlineOffsetBottom = ((_b = outlineOffset) === null || _b === void 0 ? void 0 : _b.bottom) || outlineOffset;
|
22
|
+
const outlineOffsetLeft = ((_c = outlineOffset) === null || _c === void 0 ? void 0 : _c.left) || outlineOffset;
|
23
|
+
const outlineOffsetRight = ((_d = outlineOffset) === null || _d === void 0 ? void 0 : _d.right) || outlineOffset;
|
22
24
|
return {
|
23
25
|
borderColor: 'transparent',
|
24
26
|
':after': {
|
@@ -31,15 +33,15 @@ var getFocusOutlineStyles = function (options) {
|
|
31
33
|
borderWidth: outlineWidth,
|
32
34
|
borderRadius: outlineRadius,
|
33
35
|
borderColor: outlineColor,
|
34
|
-
top: !outlineOffset ?
|
35
|
-
bottom: !outlineOffset ?
|
36
|
-
left: !outlineOffset ?
|
37
|
-
right: !outlineOffset ?
|
36
|
+
top: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetTop})`,
|
37
|
+
bottom: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetBottom})`,
|
38
|
+
left: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetLeft})`,
|
39
|
+
right: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetRight})`
|
38
40
|
}
|
39
41
|
};
|
40
42
|
};
|
41
43
|
|
42
|
-
|
44
|
+
const defaultOptions = {
|
43
45
|
selector: 'focus'
|
44
46
|
};
|
45
47
|
/**
|
@@ -51,46 +53,32 @@ var defaultOptions = {
|
|
51
53
|
* @returns focus outline styles object for @see makeStyles
|
52
54
|
*/
|
53
55
|
|
54
|
-
export
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
}
|
68
|
-
|
69
|
-
outlineRadius: theme.borderRadiusMedium,
|
70
|
-
// FIXME: theme.global.strokeWidth.thick causes some weird bugs
|
71
|
-
outlineWidth: '2px'
|
72
|
-
}, options.style)), _a;
|
73
|
-
};
|
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
|
+
});
|
74
71
|
/**
|
75
|
-
* Creates a style
|
72
|
+
* Creates a style for @see makeStyles that includes the necessary selectors for focus.
|
76
73
|
* Should be used only when @see createFocusOutlineStyle does not fit requirements
|
77
74
|
*
|
78
|
-
* @param
|
75
|
+
* @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes
|
79
76
|
*/
|
80
77
|
|
81
|
-
export
|
82
|
-
|
83
|
-
|
84
|
-
}
|
85
|
-
|
86
|
-
|
87
|
-
var _a;
|
88
|
-
|
89
|
-
return _a = {
|
90
|
-
':focus-visible': {
|
91
|
-
outline: 'none'
|
92
|
-
}
|
93
|
-
}, _a[KEYBOARD_NAV_SELECTOR + " :" + (options.selector || defaultOptions.selector)] = typeof rule === 'function' ? rule(theme) : rule, _a;
|
94
|
-
};
|
95
|
-
};
|
78
|
+
export const createCustomFocusIndicatorStyle = (style, options = defaultOptions) => ({
|
79
|
+
':focus-visible': {
|
80
|
+
outlineStyle: 'none'
|
81
|
+
},
|
82
|
+
[`${KEYBOARD_NAV_SELECTOR} :${options.selector || defaultOptions.selector}`]: style
|
83
|
+
});
|
96
84
|
//# sourceMappingURL=useFocusIndicatorStyle.js.map
|
@@ -1 +1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B,cAAc,CAAC,QAAQ,EAAzE,GAA8E;AAJ5D,CAH2B,CAAxC","sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport { KEYBOARD_NAV_SELECTOR } from '../symbols';\nimport type { GriffelStyle } from '@griffel/react';\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};\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) => {\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 borderColor: 'transparent',\n ':after': {\n content: '\"\"',\n position: 'absolute',\n pointerEvents: 'none',\n boxSizing: 'outline-box',\n zIndex: 1,\n\n borderStyle: 'solid',\n borderWidth: outlineWidth,\n borderRadius: outlineRadius,\n 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\nexport interface CreateFocusIndicatorStyleRuleOptions {\n selector?: 'focus' | 'focus-within';\n}\n\nconst defaultOptions: CreateFocusIndicatorStyleRuleOptions = {\n selector: 'focus',\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 theme - Theme used in @see makeStyles\n * @param options - Configure the style of the focus outline\n * @returns focus outline styles object for @see makeStyles\n */\nexport const createFocusOutlineStyle = (\n options: {\n style: Partial<FocusOutlineStyleOptions>;\n } & CreateFocusIndicatorStyleRuleOptions = { style: {}, ...defaultOptions },\n): GriffelStyle => ({\n ':focus-visible': {\n outlineStyle: 'none',\n },\n [`${KEYBOARD_NAV_SELECTOR} :${options.selector || defaultOptions.selector}`]: getFocusOutlineStyles({\n outlineColor: tokens.colorStrokeFocus2,\n outlineRadius: tokens.borderRadiusMedium,\n // FIXME: tokens.strokeWidthThick causes some weird bugs\n outlineWidth: '2px',\n ...options.style,\n }),\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 */\nexport const createCustomFocusIndicatorStyle = (\n style: GriffelStyle,\n options: CreateFocusIndicatorStyleRuleOptions = defaultOptions,\n): GriffelStyle => ({\n ':focus-visible': {\n outlineStyle: 'none',\n },\n [`${KEYBOARD_NAV_SELECTOR} :${options.selector || defaultOptions.selector}`]: style,\n});\n"],"sourceRoot":"../src/"}
|
@@ -1,23 +1,9 @@
|
|
1
1
|
import { Types } from 'tabster';
|
2
|
-
export declare enum FocusableGroupTabBehavior {
|
3
|
-
/**
|
4
|
-
* Tab will cycle into and out of the groupper content.
|
5
|
-
*/
|
6
|
-
Unlimited,
|
7
|
-
/**
|
8
|
-
* Tab will cycle out of the container, but not into it.
|
9
|
-
*/
|
10
|
-
Limited,
|
11
|
-
/**
|
12
|
-
* Tab only cycles the inner elements.
|
13
|
-
*/
|
14
|
-
LimitedTrapFocus
|
15
|
-
}
|
16
2
|
export interface UseFocusableGroupOptions {
|
17
3
|
/**
|
18
|
-
*
|
4
|
+
* Behavior for the Tab key.
|
19
5
|
*/
|
20
|
-
tabBehavior?:
|
6
|
+
tabBehavior?: 'unlimited' | 'limited' | 'limitedTrapFocus';
|
21
7
|
}
|
22
8
|
/**
|
23
9
|
* A hook that returns the necessary tabster attributes to support groupping.
|
@@ -1,32 +1,13 @@
|
|
1
1
|
import { Types, getGroupper } from 'tabster';
|
2
2
|
import { useTabsterAttributes } from './useTabsterAttributes';
|
3
3
|
import { useTabster } from './useTabster';
|
4
|
-
export var FocusableGroupTabBehavior;
|
5
|
-
|
6
|
-
(function (FocusableGroupTabBehavior) {
|
7
|
-
/**
|
8
|
-
* Tab will cycle into and out of the groupper content.
|
9
|
-
*/
|
10
|
-
FocusableGroupTabBehavior[FocusableGroupTabBehavior["Unlimited"] = Types.GroupperTabbabilities.Unlimited] = "Unlimited";
|
11
|
-
/**
|
12
|
-
* Tab will cycle out of the container, but not into it.
|
13
|
-
*/
|
14
|
-
|
15
|
-
FocusableGroupTabBehavior[FocusableGroupTabBehavior["Limited"] = Types.GroupperTabbabilities.Limited] = "Limited";
|
16
|
-
/**
|
17
|
-
* Tab only cycles the inner elements.
|
18
|
-
*/
|
19
|
-
|
20
|
-
FocusableGroupTabBehavior[FocusableGroupTabBehavior["LimitedTrapFocus"] = Types.GroupperTabbabilities.LimitedTrapFocus] = "LimitedTrapFocus";
|
21
|
-
})(FocusableGroupTabBehavior || (FocusableGroupTabBehavior = {}));
|
22
4
|
/**
|
23
5
|
* A hook that returns the necessary tabster attributes to support groupping.
|
24
6
|
* @param options - Options to configure keyboard navigation
|
25
7
|
*/
|
26
8
|
|
27
|
-
|
28
|
-
|
29
|
-
var tabster = useTabster();
|
9
|
+
export const useFocusableGroup = options => {
|
10
|
+
const tabster = useTabster();
|
30
11
|
|
31
12
|
if (tabster) {
|
32
13
|
getGroupper(tabster);
|
@@ -34,8 +15,24 @@ export var useFocusableGroup = function (options) {
|
|
34
15
|
|
35
16
|
return useTabsterAttributes({
|
36
17
|
groupper: {
|
37
|
-
tabbability: options === null || options === void 0 ? void 0 : options.tabBehavior
|
18
|
+
tabbability: getTabbability(options === null || options === void 0 ? void 0 : options.tabBehavior)
|
38
19
|
}
|
39
20
|
});
|
40
21
|
};
|
22
|
+
|
23
|
+
const getTabbability = tabBehavior => {
|
24
|
+
switch (tabBehavior) {
|
25
|
+
case 'unlimited':
|
26
|
+
return Types.GroupperTabbabilities.Unlimited;
|
27
|
+
|
28
|
+
case 'limited':
|
29
|
+
return Types.GroupperTabbabilities.Limited;
|
30
|
+
|
31
|
+
case 'limitedTrapFocus':
|
32
|
+
return Types.GroupperTabbabilities.LimitedTrapFocus;
|
33
|
+
|
34
|
+
default:
|
35
|
+
return undefined;
|
36
|
+
}
|
37
|
+
};
|
41
38
|
//# sourceMappingURL=useFocusableGroup.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
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/"}
|
@@ -7,23 +7,21 @@ import { useFluent } from '@fluentui/react-shared-contexts';
|
|
7
7
|
*/
|
8
8
|
|
9
9
|
export function useKeyboardNavAttribute() {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
useEffect(
|
10
|
+
const {
|
11
|
+
targetDocument
|
12
|
+
} = useFluent();
|
13
|
+
const keyborg = useMemo(() => targetDocument && createKeyborg(targetDocument.defaultView), [targetDocument]);
|
14
|
+
const ref = useRef(null);
|
15
|
+
useEffect(() => {
|
16
16
|
if (keyborg) {
|
17
17
|
setBooleanAttribute(ref, KEYBOARD_NAV_ATTRIBUTE, keyborg.isNavigatingWithKeyboard());
|
18
18
|
|
19
|
-
|
19
|
+
const cb = next => {
|
20
20
|
setBooleanAttribute(ref, KEYBOARD_NAV_ATTRIBUTE, next);
|
21
21
|
};
|
22
22
|
|
23
|
-
keyborg.subscribe(
|
24
|
-
return
|
25
|
-
return keyborg.unsubscribe(cb_1);
|
26
|
-
};
|
23
|
+
keyborg.subscribe(cb);
|
24
|
+
return () => keyborg.unsubscribe(cb);
|
27
25
|
}
|
28
26
|
}, [keyborg]);
|
29
27
|
return ref;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
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/"}
|
@@ -10,35 +10,33 @@ import { useTabster } from './useTabster';
|
|
10
10
|
* @returns DOM attributes to apply to the modal element and its trigger
|
11
11
|
*/
|
12
12
|
|
13
|
-
export
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
alwaysFocusable = options.alwaysFocusable;
|
20
|
-
var tabster = useTabster(); // Initializes the modalizer and deloser APIs
|
13
|
+
export const useModalAttributes = (options = {}) => {
|
14
|
+
const {
|
15
|
+
trapFocus,
|
16
|
+
alwaysFocusable
|
17
|
+
} = options;
|
18
|
+
const tabster = useTabster(); // Initializes the modalizer and deloser APIs
|
21
19
|
|
22
20
|
if (tabster) {
|
23
21
|
getModalizer(tabster);
|
24
22
|
getDeloser(tabster);
|
25
23
|
}
|
26
24
|
|
27
|
-
|
28
|
-
|
25
|
+
const id = useId('modal-');
|
26
|
+
const modalAttributes = useTabsterAttributes({
|
29
27
|
deloser: {},
|
30
28
|
modalizer: {
|
31
|
-
id
|
29
|
+
id,
|
32
30
|
isOthersAccessible: !trapFocus,
|
33
31
|
isAlwaysAccessible: alwaysFocusable
|
34
32
|
}
|
35
33
|
});
|
36
|
-
|
34
|
+
const triggerAttributes = useTabsterAttributes({
|
37
35
|
deloser: {}
|
38
36
|
});
|
39
37
|
return {
|
40
|
-
modalAttributes
|
41
|
-
triggerAttributes
|
38
|
+
modalAttributes,
|
39
|
+
triggerAttributes
|
42
40
|
};
|
43
41
|
};
|
44
42
|
//# sourceMappingURL=useModalAttributes.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["hooks/useModalAttributes.ts"],"names":[],"mappings":"AAAA,SAAS,KAAT,QAAsB,2BAAtB;AACA,SAAS,oBAAT,QAAqC,wBAArC;AACA,SAAS,UAAT,EAAqB,YAArB,QAAgE,SAAhE;AACA,SAAS,UAAT,QAA2B,cAA3B;AAcA;;;;;;AAMG;;AACH,OAAO,MAAM,kBAAkB,GAAG,CAChC,OAAA,GAAqC,EADL,KAE8E;AAC9G,QAAM;AAAE,IAAA,SAAF;AAAa,IAAA;AAAb,MAAiC,OAAvC;AACA,QAAM,OAAO,GAAG,UAAU,EAA1B,CAF8G,CAG9G;;AACA,MAAI,OAAJ,EAAa;AACX,IAAA,YAAY,CAAC,OAAD,CAAZ;AACA,IAAA,UAAU,CAAC,OAAD,CAAV;AACD;;AAED,QAAM,EAAE,GAAG,KAAK,CAAC,QAAD,CAAhB;AACA,QAAM,eAAe,GAAG,oBAAoB,CAAC;AAC3C,IAAA,OAAO,EAAE,EADkC;AAE3C,IAAA,SAAS,EAAE;AAAE,MAAA,EAAF;AAAM,MAAA,kBAAkB,EAAE,CAAC,SAA3B;AAAsC,MAAA,kBAAkB,EAAE;AAA1D;AAFgC,GAAD,CAA5C;AAKA,QAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAC7C,IAAA,OAAO,EAAE;AADoC,GAAD,CAA9C;AAIA,SAAO;AAAE,IAAA,eAAF;AAAmB,IAAA;AAAnB,GAAP;AACD,CAtBM","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/"}
|
package/lib/hooks/useTabster.js
CHANGED
@@ -8,13 +8,16 @@ import { getCurrentTabster, createTabster } from 'tabster';
|
|
8
8
|
* @returns Tabster core instance
|
9
9
|
*/
|
10
10
|
|
11
|
-
export
|
11
|
+
export const useTabster = () => {
|
12
12
|
var _a;
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
const {
|
15
|
+
targetDocument
|
16
|
+
} = useFluent();
|
17
|
+
const defaultView = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) || undefined;
|
18
|
+
const tabsterOptions = {
|
19
|
+
autoRoot: {},
|
20
|
+
controlTab: false
|
18
21
|
};
|
19
22
|
|
20
23
|
if (!defaultView) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
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
|
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":["
|
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.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC","sourcesContent":["export * from './hooks/index';\n"]}
|
package/lib/symbols.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export
|
2
|
-
export
|
1
|
+
export const KEYBOARD_NAV_ATTRIBUTE = 'data-keyboard-nav';
|
2
|
+
export const KEYBOARD_NAV_SELECTOR = `:global([${KEYBOARD_NAV_ATTRIBUTE}])`;
|
3
3
|
//# sourceMappingURL=symbols.js.map
|
package/lib/symbols.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"symbols.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"symbols.js","sourceRoot":"../src/","sources":["symbols.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAA4B,CAAC;AACnE,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,sBAAsB,IAAa,CAAC","sourcesContent":["export const KEYBOARD_NAV_ATTRIBUTE = 'data-keyboard-nav' as const;\nexport const KEYBOARD_NAV_SELECTOR = `:global([${KEYBOARD_NAV_ATTRIBUTE}])` as const;\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
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,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","sourcesContent":["export * from './useArrowNavigationGroup';\nexport * from './useFocusFinders';\nexport * from './useModalAttributes';\nexport * from './useTabsterAttributes';\nexport * from './useFocusIndicatorStyle';\nexport * from './useKeyboardNavAttribute';\nexport * from './useFocusableGroup';\n"],"sourceRoot":"../src/"}
|
@@ -5,21 +5,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.useArrowNavigationGroup = void 0;
|
7
7
|
|
8
|
-
|
8
|
+
const tabster_1 = /*#__PURE__*/require("tabster");
|
9
9
|
|
10
|
-
|
10
|
+
const useTabsterAttributes_1 = /*#__PURE__*/require("./useTabsterAttributes");
|
11
11
|
|
12
|
-
|
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
|
-
|
19
|
+
const useArrowNavigationGroup = options => {
|
20
20
|
var _a;
|
21
21
|
|
22
|
-
|
22
|
+
const tabster = useTabster_1.useTabster();
|
23
23
|
|
24
24
|
if (tabster) {
|
25
25
|
tabster_1.getMover(tabster);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["hooks/useArrowNavigationGroup.ts"],"names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TabsterAttributes';\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,3 +1,4 @@
|
|
1
|
+
import { Types as TabsterTypes } from 'tabster';
|
1
2
|
/**
|
2
3
|
* Returns a set of helper functions that will traverse focusable elements in the context of a root DOM element
|
3
4
|
*/
|
@@ -5,6 +6,6 @@ export declare const useFocusFinders: () => {
|
|
5
6
|
findAllFocusable: (container: HTMLElement, acceptCondition: (el: HTMLElement) => boolean) => HTMLElement[];
|
6
7
|
findFirstFocusable: (container: HTMLElement) => HTMLElement | null | undefined;
|
7
8
|
findLastFocusable: (container: HTMLElement) => HTMLElement | null | undefined;
|
8
|
-
findNextFocusable: (currentElement: HTMLElement) => HTMLElement | null | undefined;
|
9
|
-
findPrevFocusable: (currentElement: HTMLElement) => HTMLElement | null | undefined;
|
9
|
+
findNextFocusable: (currentElement: HTMLElement, options?: Pick<TabsterTypes.FindNextProps, 'container'>) => HTMLElement | null | undefined;
|
10
|
+
findPrevFocusable: (currentElement: HTMLElement, options?: Pick<TabsterTypes.FindNextProps, 'container'>) => HTMLElement | null | undefined;
|
10
11
|
};
|
@@ -5,49 +5,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.useFocusFinders = void 0;
|
7
7
|
|
8
|
-
|
8
|
+
const React = /*#__PURE__*/require("react");
|
9
9
|
|
10
|
-
|
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
|
-
|
17
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
47
|
-
findFirstFocusable
|
48
|
-
findLastFocusable
|
49
|
-
findNextFocusable
|
50
|
-
findPrevFocusable
|
38
|
+
findAllFocusable,
|
39
|
+
findFirstFocusable,
|
40
|
+
findLastFocusable,
|
41
|
+
findNextFocusable,
|
42
|
+
findPrevFocusable
|
51
43
|
};
|
52
44
|
};
|
53
45
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["hooks/useFocusFinders.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAEA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AAEA;;AAEG;;;AACI,MAAM,eAAe,GAAG,MAAK;AAClC,QAAM,OAAO,GAAG,YAAA,CAAA,UAAA,EAAhB,CADkC,CAGlC;;AACA,QAAM,gBAAgB,GAAG,KAAK,CAAC,WAAN,CACvB,CAAC,SAAD,EAAyB,eAAzB,KACE,CAAA,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,SAAT,CAAmB,OAAnB,CAA2B;AAAE,IAAA,SAAF;AAAa,IAAA;AAAb,GAA3B,CAAA,KAA8D,EAFzC,EAGvB,CAAC,OAAD,CAHuB,CAAzB;AAMA,QAAM,kBAAkB,GAAG,KAAK,CAAC,WAAN,CACxB,SAAD,IAA4B,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,SAAT,CAAmB,SAAnB,CAA6B;AAAE,IAAA;AAAF,GAA7B,CADH,EAEzB,CAAC,OAAD,CAFyB,CAA3B;AAKA,QAAM,iBAAiB,GAAG,KAAK,CAAC,WAAN,CAAmB,SAAD,IAA4B,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,SAAT,CAAmB,QAAnB,CAA4B;AAAE,IAAA;AAAF,GAA5B,CAA9C,EAA0F,CAClH,OADkH,CAA1F,CAA1B;AAIA,QAAM,iBAAiB,GAAG,KAAK,CAAC,WAAN,CACxB,CAAC,cAAD,EAA8B,OAAA,GAAyD,EAAvF,KACE,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,SAAT,CAAmB,QAAnB,CAA4B;AAAE,IAAA,cAAF;AAAkB,OAAG;AAArB,GAA5B,CAFsB,EAGxB,CAAC,OAAD,CAHwB,CAA1B;AAMA,QAAM,iBAAiB,GAAG,KAAK,CAAC,WAAN,CACxB,CAAC,cAAD,EAA8B,OAAA,GAAyD,EAAvF,KACE,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,SAAT,CAAmB,QAAnB,CAA4B;AAAE,IAAA,cAAF;AAAkB,OAAG;AAArB,GAA5B,CAFsB,EAGxB,CAAC,OAAD,CAHwB,CAA1B;AAMA,SAAO;AACL,IAAA,gBADK;AAEL,IAAA,kBAFK;AAGL,IAAA,iBAHK;AAIL,IAAA,iBAJK;AAKL,IAAA;AALK,GAAP;AAOD,CAtCM;;AAAM,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/"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import type {
|
2
|
-
import type { MakeStyles, MakeStylesStyleRule } from '@fluentui/make-styles';
|
1
|
+
import type { GriffelStyle } from '@griffel/react';
|
3
2
|
export declare type FocusOutlineOffset = Record<'top' | 'bottom' | 'left' | 'right', string>;
|
4
3
|
export declare type FocusOutlineStyleOptions = {
|
5
4
|
/**
|
@@ -22,13 +21,13 @@ export interface CreateFocusIndicatorStyleRuleOptions {
|
|
22
21
|
* @param options - Configure the style of the focus outline
|
23
22
|
* @returns focus outline styles object for @see makeStyles
|
24
23
|
*/
|
25
|
-
export declare const createFocusOutlineStyle: (
|
24
|
+
export declare const createFocusOutlineStyle: (options?: {
|
26
25
|
style: Partial<FocusOutlineStyleOptions>;
|
27
|
-
} & CreateFocusIndicatorStyleRuleOptions) =>
|
26
|
+
} & CreateFocusIndicatorStyleRuleOptions) => GriffelStyle;
|
28
27
|
/**
|
29
|
-
* Creates a style
|
28
|
+
* Creates a style for @see makeStyles that includes the necessary selectors for focus.
|
30
29
|
* Should be used only when @see createFocusOutlineStyle does not fit requirements
|
31
30
|
*
|
32
|
-
* @param
|
31
|
+
* @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes
|
33
32
|
*/
|
34
|
-
export declare const createCustomFocusIndicatorStyle: (
|
33
|
+
export declare const createCustomFocusIndicatorStyle: (style: GriffelStyle, options?: CreateFocusIndicatorStyleRuleOptions) => GriffelStyle;
|