@fluentui/react-tabster 9.12.11 → 9.13.1
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 +75 -1
- package/CHANGELOG.md +30 -2
- package/dist/index.d.ts +7 -2
- package/lib/focus/constants.js +2 -1
- package/lib/focus/constants.js.map +1 -1
- package/lib/focus/createCustomFocusIndicatorStyle.js +10 -7
- package/lib/focus/createCustomFocusIndicatorStyle.js.map +1 -1
- package/lib/focus/createFocusOutlineStyle.js +4 -4
- package/lib/focus/createFocusOutlineStyle.js.map +1 -1
- package/lib/focus/focusVisiblePolyfill.js +1 -2
- package/lib/focus/focusVisiblePolyfill.js.map +1 -1
- package/lib/hooks/useFocusFinders.js +6 -15
- package/lib/hooks/useFocusFinders.js.map +1 -1
- package/lib/hooks/useFocusVisible.js +1 -2
- package/lib/hooks/useFocusVisible.js.map +1 -1
- package/lib/hooks/useFocusWithin.js +1 -2
- package/lib/hooks/useFocusWithin.js.map +1 -1
- package/lib/hooks/useFocusableGroup.js +2 -3
- package/lib/hooks/useFocusableGroup.js.map +1 -1
- package/lib/hooks/useTabster.js +1 -2
- package/lib/hooks/useTabster.js.map +1 -1
- package/lib-commonjs/focus/constants.js +2 -1
- package/lib-commonjs/focus/constants.js.map +1 -1
- package/lib-commonjs/focus/createCustomFocusIndicatorStyle.js +10 -7
- package/lib-commonjs/focus/createCustomFocusIndicatorStyle.js.map +1 -1
- package/lib-commonjs/focus/createFocusOutlineStyle.js +4 -4
- package/lib-commonjs/focus/createFocusOutlineStyle.js.map +1 -1
- package/lib-commonjs/focus/focusVisiblePolyfill.js +1 -2
- package/lib-commonjs/focus/focusVisiblePolyfill.js.map +1 -1
- package/lib-commonjs/hooks/useFocusFinders.js +6 -15
- package/lib-commonjs/hooks/useFocusFinders.js.map +1 -1
- package/lib-commonjs/hooks/useFocusVisible.js +1 -2
- package/lib-commonjs/hooks/useFocusVisible.js.map +1 -1
- package/lib-commonjs/hooks/useFocusWithin.js +1 -2
- package/lib-commonjs/hooks/useFocusWithin.js.map +1 -1
- package/lib-commonjs/hooks/useFocusableGroup.js +2 -3
- package/lib-commonjs/hooks/useFocusableGroup.js.map +1 -1
- package/lib-commonjs/hooks/useTabster.js +1 -2
- package/lib-commonjs/hooks/useTabster.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,81 @@
|
|
2
2
|
"name": "@fluentui/react-tabster",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Tue, 26 Sep 2023 17:44:18 GMT",
|
6
|
+
"tag": "@fluentui/react-tabster_v9.13.1",
|
7
|
+
"version": "9.13.1",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "yuanboxue@microsoft.com",
|
12
|
+
"package": "@fluentui/react-tabster",
|
13
|
+
"commit": "05a23f6f5f331841c9ac9fb63764440c543f791d",
|
14
|
+
"comment": "chore: trigger manual version bump after broken release"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "beachball",
|
18
|
+
"package": "@fluentui/react-tabster",
|
19
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.9.1",
|
20
|
+
"commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-tabster",
|
25
|
+
"comment": "Bump @fluentui/react-theme to v9.1.14",
|
26
|
+
"commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"author": "beachball",
|
30
|
+
"package": "@fluentui/react-tabster",
|
31
|
+
"comment": "Bump @fluentui/react-utilities to v9.13.5",
|
32
|
+
"commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
|
33
|
+
}
|
34
|
+
]
|
35
|
+
}
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"date": "Tue, 26 Sep 2023 15:31:47 GMT",
|
39
|
+
"tag": "@fluentui/react-tabster_v9.13.0",
|
40
|
+
"version": "9.13.0",
|
41
|
+
"comments": {
|
42
|
+
"patch": [
|
43
|
+
{
|
44
|
+
"author": "martinhochel@microsoft.com",
|
45
|
+
"package": "@fluentui/react-tabster",
|
46
|
+
"commit": "e61473fa10195f6ebf2308205c1e72e91b711831",
|
47
|
+
"comment": "fix: bump swc core to mitigate transpilation memory leaks"
|
48
|
+
}
|
49
|
+
],
|
50
|
+
"minor": [
|
51
|
+
{
|
52
|
+
"author": "bernardo.sunderhus@gmail.com",
|
53
|
+
"package": "@fluentui/react-tabster",
|
54
|
+
"commit": "ada4daa280405d7756261d2416c8986b056f86ca",
|
55
|
+
"comment": "feat: adds suffixes to selectors on focus creator methods"
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"author": "beachball",
|
59
|
+
"package": "@fluentui/react-tabster",
|
60
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.9.0",
|
61
|
+
"commit": "e16520437e10cd824ac254dd797e32762b5de72d"
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"author": "beachball",
|
65
|
+
"package": "@fluentui/react-tabster",
|
66
|
+
"comment": "Bump @fluentui/react-theme to v9.1.13",
|
67
|
+
"commit": "e16520437e10cd824ac254dd797e32762b5de72d"
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"author": "beachball",
|
71
|
+
"package": "@fluentui/react-tabster",
|
72
|
+
"comment": "Bump @fluentui/react-utilities to v9.13.4",
|
73
|
+
"commit": "e16520437e10cd824ac254dd797e32762b5de72d"
|
74
|
+
}
|
75
|
+
]
|
76
|
+
}
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"date": "Wed, 20 Sep 2023 17:47:44 GMT",
|
6
80
|
"tag": "@fluentui/react-tabster_v9.12.11",
|
7
81
|
"version": "9.12.11",
|
8
82
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,40 @@
|
|
1
1
|
# Change Log - @fluentui/react-tabster
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Tue, 26 Sep 2023 17:44:18 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.13.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabster_v9.13.1)
|
8
|
+
|
9
|
+
Tue, 26 Sep 2023 17:44:18 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tabster_v9.13.0..@fluentui/react-tabster_v9.13.1)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- chore: trigger manual version bump after broken release ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by yuanboxue@microsoft.com)
|
15
|
+
- Bump @fluentui/react-shared-contexts to v9.9.1 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
|
16
|
+
- Bump @fluentui/react-theme to v9.1.14 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
|
17
|
+
- Bump @fluentui/react-utilities to v9.13.5 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
|
18
|
+
|
19
|
+
## [9.13.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabster_v9.13.0)
|
20
|
+
|
21
|
+
Tue, 26 Sep 2023 15:31:47 GMT
|
22
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tabster_v9.12.11..@fluentui/react-tabster_v9.13.0)
|
23
|
+
|
24
|
+
### Minor changes
|
25
|
+
|
26
|
+
- feat: adds suffixes to selectors on focus creator methods ([PR #29209](https://github.com/microsoft/fluentui/pull/29209) by bernardo.sunderhus@gmail.com)
|
27
|
+
- Bump @fluentui/react-shared-contexts to v9.9.0 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
|
28
|
+
- Bump @fluentui/react-theme to v9.1.13 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
|
29
|
+
- Bump @fluentui/react-utilities to v9.13.4 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
|
30
|
+
|
31
|
+
### Patches
|
32
|
+
|
33
|
+
- fix: bump swc core to mitigate transpilation memory leaks ([PR #29253](https://github.com/microsoft/fluentui/pull/29253) by martinhochel@microsoft.com)
|
34
|
+
|
7
35
|
## [9.12.11](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabster_v9.12.11)
|
8
36
|
|
9
|
-
Wed, 20 Sep 2023 17:
|
37
|
+
Wed, 20 Sep 2023 17:47:44 GMT
|
10
38
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tabster_v9.12.10..@fluentui/react-tabster_v9.12.11)
|
11
39
|
|
12
40
|
### Patches
|
package/dist/index.d.ts
CHANGED
@@ -18,15 +18,20 @@ export declare function applyFocusVisiblePolyfill(scope: HTMLElement, targetWind
|
|
18
18
|
* @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyles
|
19
19
|
* @param options - Configure the style of the focus outline
|
20
20
|
*/
|
21
|
-
export declare function createCustomFocusIndicatorStyle<TStyle extends GriffelStyle | GriffelResetStyle>(style: TStyle, { selector }?: CreateCustomFocusIndicatorStyleOptions): TStyle extends GriffelStyle ? GriffelStyle : GriffelResetStyle;
|
21
|
+
export declare function createCustomFocusIndicatorStyle<TStyle extends GriffelStyle | GriffelResetStyle>(style: TStyle, { selector: selectorType, customizeSelector, }?: CreateCustomFocusIndicatorStyleOptions): TStyle extends GriffelStyle ? GriffelStyle : GriffelResetStyle;
|
22
22
|
|
23
23
|
export declare interface CreateCustomFocusIndicatorStyleOptions {
|
24
24
|
/**
|
25
25
|
* Control if the indicator appears when the corresponding element is focused,
|
26
26
|
* or any child is focused within the corresponding element.
|
27
27
|
* @default 'focus'
|
28
|
+
* @alias selectorType
|
28
29
|
*/
|
29
30
|
selector?: 'focus' | 'focus-within';
|
31
|
+
/**
|
32
|
+
* Customizes the selector provided based on the selector type.
|
33
|
+
*/
|
34
|
+
customizeSelector?: (selector: string) => string;
|
30
35
|
/**
|
31
36
|
* Enables the browser default outline style
|
32
37
|
* @deprecated The custom focus indicator no longer affects outline styles. Outline is overridden
|
@@ -42,7 +47,7 @@ export declare interface CreateCustomFocusIndicatorStyleOptions {
|
|
42
47
|
* @param options - Configure the style of the focus outline
|
43
48
|
* @returns focus outline styles object for @see makeStyles
|
44
49
|
*/
|
45
|
-
export declare const createFocusOutlineStyle: ({ enableOutline, selector, style, }?: CreateFocusOutlineStyleOptions) => GriffelStyle;
|
50
|
+
export declare const createFocusOutlineStyle: ({ enableOutline, selector, customizeSelector, style, }?: CreateFocusOutlineStyleOptions) => GriffelStyle;
|
46
51
|
|
47
52
|
export declare interface CreateFocusOutlineStyleOptions extends Omit<CreateCustomFocusIndicatorStyleOptions, 'enableOutline'> {
|
48
53
|
style?: Partial<FocusOutlineStyleOptions>;
|
package/lib/focus/constants.js
CHANGED
@@ -8,5 +8,6 @@ export const KEYBOARD_NAV_SELECTOR = `:global([${KEYBOARD_NAV_ATTRIBUTE}])`;
|
|
8
8
|
*/ export const FOCUS_WITHIN_ATTR = 'data-fui-focus-within';
|
9
9
|
export const defaultOptions = {
|
10
10
|
style: {},
|
11
|
-
selector: 'focus'
|
11
|
+
selector: 'focus',
|
12
|
+
customizeSelector: (selector)=>selector
|
12
13
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["constants.ts"],"sourcesContent":["export const KEYBOARD_NAV_ATTRIBUTE = 'data-keyboard-nav' as const;\nexport const KEYBOARD_NAV_SELECTOR = `:global([${KEYBOARD_NAV_ATTRIBUTE}])` as const;\n\n/**\n * @internal\n */\nexport const FOCUS_VISIBLE_ATTR = 'data-fui-focus-visible';\n\n/**\n * @internal\n */\nexport const FOCUS_WITHIN_ATTR = 'data-fui-focus-within';\nexport const defaultOptions = {\n style: {},\n selector: 'focus',\n} as const;\n"],"names":["KEYBOARD_NAV_ATTRIBUTE","KEYBOARD_NAV_SELECTOR","FOCUS_VISIBLE_ATTR","FOCUS_WITHIN_ATTR","defaultOptions","style","selector"],"mappings":"AAAA,OAAO,MAAMA,yBAAyB,oBAA6B;AACnE,OAAO,MAAMC,wBAAwB,CAAC,SAAS,EAAED,uBAAuB,EAAE,CAAC,CAAU;AAErF;;CAEC,GACD,OAAO,MAAME,qBAAqB,yBAAyB;AAE3D;;CAEC,GACD,OAAO,MAAMC,oBAAoB,wBAAwB;AACzD,OAAO,MAAMC,iBAAiB;IAC5BC,OAAO,CAAC;IACRC,UAAU;
|
1
|
+
{"version":3,"sources":["constants.ts"],"sourcesContent":["export const KEYBOARD_NAV_ATTRIBUTE = 'data-keyboard-nav' as const;\nexport const KEYBOARD_NAV_SELECTOR = `:global([${KEYBOARD_NAV_ATTRIBUTE}])` as const;\n\n/**\n * @internal\n */\nexport const FOCUS_VISIBLE_ATTR = 'data-fui-focus-visible';\n\n/**\n * @internal\n */\nexport const FOCUS_WITHIN_ATTR = 'data-fui-focus-within';\nexport const defaultOptions = {\n style: {},\n selector: 'focus',\n customizeSelector: (selector: string) => selector,\n} as const;\n"],"names":["KEYBOARD_NAV_ATTRIBUTE","KEYBOARD_NAV_SELECTOR","FOCUS_VISIBLE_ATTR","FOCUS_WITHIN_ATTR","defaultOptions","style","selector","customizeSelector"],"mappings":"AAAA,OAAO,MAAMA,yBAAyB,oBAA6B;AACnE,OAAO,MAAMC,wBAAwB,CAAC,SAAS,EAAED,uBAAuB,EAAE,CAAC,CAAU;AAErF;;CAEC,GACD,OAAO,MAAME,qBAAqB,yBAAyB;AAE3D;;CAEC,GACD,OAAO,MAAMC,oBAAoB,wBAAwB;AACzD,OAAO,MAAMC,iBAAiB;IAC5BC,OAAO,CAAC;IACRC,UAAU;IACVC,mBAAmB,CAACD,WAAqBA;AAC3C,EAAW"}
|
@@ -5,13 +5,16 @@ import { defaultOptions, FOCUS_VISIBLE_ATTR, FOCUS_WITHIN_ATTR } from './constan
|
|
5
5
|
*
|
6
6
|
* @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyles
|
7
7
|
* @param options - Configure the style of the focus outline
|
8
|
-
*/ export function createCustomFocusIndicatorStyle(style, { selector = defaultOptions.selector } = defaultOptions) {
|
8
|
+
*/ export function createCustomFocusIndicatorStyle(style, { selector: selectorType = defaultOptions.selector, customizeSelector = defaultOptions.customizeSelector } = defaultOptions) {
|
9
9
|
return {
|
10
|
-
|
11
|
-
[`&[${FOCUS_VISIBLE_ATTR}]`]: style
|
12
|
-
},
|
13
|
-
...selector === 'focus-within' && {
|
14
|
-
[`&[${FOCUS_WITHIN_ATTR}]:${selector}`]: style
|
15
|
-
}
|
10
|
+
[customizeSelector(createBaseSelector(selectorType))]: style
|
16
11
|
};
|
17
12
|
}
|
13
|
+
function createBaseSelector(selectorType) {
|
14
|
+
switch(selectorType){
|
15
|
+
case 'focus':
|
16
|
+
return `&[${FOCUS_VISIBLE_ATTR}]`;
|
17
|
+
case 'focus-within':
|
18
|
+
return `&[${FOCUS_WITHIN_ATTR}]:focus-within`;
|
19
|
+
}
|
20
|
+
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["createCustomFocusIndicatorStyle.ts"],"sourcesContent":["import { defaultOptions, FOCUS_VISIBLE_ATTR, FOCUS_WITHIN_ATTR } from './constants';\nimport { makeResetStyles } from '@griffel/react';\nimport type { GriffelStyle } from '@griffel/react';\n\n// TODO: Use the type directly from @griffel/react\n// https://github.com/microsoft/griffel/pull/278\ntype GriffelResetStyle = Parameters<typeof makeResetStyles>[0];\n\nexport interface CreateCustomFocusIndicatorStyleOptions {\n /**\n * Control if the indicator appears when the corresponding element is focused,\n * or any child is focused within the corresponding element.\n * @default 'focus'\n */\n selector?: 'focus' | 'focus-within';\n /**\n * Enables the browser default outline style\n * @deprecated The custom focus indicator no longer affects outline styles. Outline is overridden\n * in the default focus indicator function, `createFocusOutlineStyle`.\n */\n enableOutline?: boolean;\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 getDefaultFocusOutlineStyles\n * @param options - Configure the style of the focus outline\n */\nexport function createCustomFocusIndicatorStyle<TStyle extends GriffelStyle | GriffelResetStyle>(\n style: TStyle,\n {
|
1
|
+
{"version":3,"sources":["createCustomFocusIndicatorStyle.ts"],"sourcesContent":["import { defaultOptions, FOCUS_VISIBLE_ATTR, FOCUS_WITHIN_ATTR } from './constants';\nimport { makeResetStyles } from '@griffel/react';\nimport type { GriffelStyle } from '@griffel/react';\n\n// TODO: Use the type directly from @griffel/react\n// https://github.com/microsoft/griffel/pull/278\ntype GriffelResetStyle = Parameters<typeof makeResetStyles>[0];\n\nexport interface CreateCustomFocusIndicatorStyleOptions {\n /**\n * Control if the indicator appears when the corresponding element is focused,\n * or any child is focused within the corresponding element.\n * @default 'focus'\n * @alias selectorType\n */\n selector?: 'focus' | 'focus-within';\n /**\n * Customizes the selector provided based on the selector type.\n */\n customizeSelector?: (selector: string) => string;\n /**\n * Enables the browser default outline style\n * @deprecated The custom focus indicator no longer affects outline styles. Outline is overridden\n * in the default focus indicator function, `createFocusOutlineStyle`.\n */\n enableOutline?: boolean;\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 getDefaultFocusOutlineStyles\n * @param options - Configure the style of the focus outline\n */\nexport function createCustomFocusIndicatorStyle<TStyle extends GriffelStyle | GriffelResetStyle>(\n style: TStyle,\n {\n selector: selectorType = defaultOptions.selector,\n customizeSelector = defaultOptions.customizeSelector,\n }: CreateCustomFocusIndicatorStyleOptions = defaultOptions,\n): TStyle extends GriffelStyle ? GriffelStyle : GriffelResetStyle {\n return { [customizeSelector(createBaseSelector(selectorType))]: style };\n}\n\nfunction createBaseSelector(selectorType: 'focus' | 'focus-within'): string {\n switch (selectorType) {\n case 'focus':\n return `&[${FOCUS_VISIBLE_ATTR}]`;\n case 'focus-within':\n return `&[${FOCUS_WITHIN_ATTR}]:focus-within`;\n }\n}\n"],"names":["defaultOptions","FOCUS_VISIBLE_ATTR","FOCUS_WITHIN_ATTR","createCustomFocusIndicatorStyle","style","selector","selectorType","customizeSelector","createBaseSelector"],"mappings":"AAAA,SAASA,cAAc,EAAEC,kBAAkB,EAAEC,iBAAiB,QAAQ,cAAc;AA4BpF;;;;;;CAMC,GACD,OAAO,SAASC,gCACdC,KAAa,EACb,EACEC,UAAUC,eAAeN,eAAeK,QAAQ,EAChDE,oBAAoBP,eAAeO,iBAAiB,EACb,GAAGP,cAAc;IAE1D,OAAO;QAAE,CAACO,kBAAkBC,mBAAmBF,eAAe,EAAEF;IAAM;AACxE;AAEA,SAASI,mBAAmBF,YAAsC;IAChE,OAAQA;QACN,KAAK;YACH,OAAO,CAAC,EAAE,EAAEL,mBAAmB,CAAC,CAAC;QACnC,KAAK;YACH,OAAO,CAAC,EAAE,EAAEC,kBAAkB,cAAc,CAAC;IACjD;AACF"}
|
@@ -9,8 +9,7 @@ import { defaultOptions } from './constants';
|
|
9
9
|
* @param position - The position of the focus outline
|
10
10
|
* @returns CSS value for the position of the focus outline
|
11
11
|
*/ function getOutlinePosition({ outlineWidth, outlineOffset }, position) {
|
12
|
-
|
13
|
-
const offsetValue = ((_outlineOffset = outlineOffset) === null || _outlineOffset === void 0 ? void 0 : _outlineOffset[position]) || outlineOffset;
|
12
|
+
const offsetValue = (outlineOffset === null || outlineOffset === void 0 ? void 0 : outlineOffset[position]) || outlineOffset;
|
14
13
|
if (!outlineOffset) {
|
15
14
|
return `calc(${outlineWidth} * -1)`;
|
16
15
|
}
|
@@ -48,7 +47,7 @@ import { defaultOptions } from './constants';
|
|
48
47
|
*
|
49
48
|
* @param options - Configure the style of the focus outline
|
50
49
|
* @returns focus outline styles object for @see makeStyles
|
51
|
-
*/ export const createFocusOutlineStyle = ({ enableOutline = false, selector = defaultOptions.selector, style = defaultOptions.style } = defaultOptions)=>({
|
50
|
+
*/ export const createFocusOutlineStyle = ({ enableOutline = false, selector = defaultOptions.selector, customizeSelector, style = defaultOptions.style } = defaultOptions)=>({
|
52
51
|
':focus': {
|
53
52
|
outlineStyle: enableOutline ? undefined : 'none'
|
54
53
|
},
|
@@ -62,6 +61,7 @@ import { defaultOptions } from './constants';
|
|
62
61
|
outlineWidth: '2px',
|
63
62
|
...style
|
64
63
|
}), {
|
65
|
-
selector
|
64
|
+
selector,
|
65
|
+
customizeSelector
|
66
66
|
})
|
67
67
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["createFocusOutlineStyle.ts"],"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 Omit<CreateCustomFocusIndicatorStyleOptions, 'enableOutline'> {\n style?: Partial<FocusOutlineStyleOptions>;\n\n /**\n * Enables the browser default outline style\n */\n enableOutline?: boolean;\n}\n\n/**\n * Get the position of the focus outline\n *\n * @param options - Configures the style of the focus outline\n * @param position - The position of the focus outline\n * @returns CSS value for the position of the focus outline\n */\nfunction getOutlinePosition(\n { outlineWidth, outlineOffset }: FocusOutlineStyleOptions,\n position: 'top' | 'bottom' | 'left' | 'right',\n) {\n const offsetValue = (outlineOffset as FocusOutlineOffset)?.[position] || outlineOffset;\n\n if (!outlineOffset) {\n return `calc(${outlineWidth} * -1)`;\n }\n\n return `calc(0px - ${outlineWidth} - ${offsetValue})`;\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, outlineWidth } = options;\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: getOutlinePosition(options, 'top'),\n right: getOutlinePosition(options, 'right'),\n bottom: getOutlinePosition(options, 'bottom'),\n left: getOutlinePosition(options, 'left'),\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 enableOutline = false,\n selector = defaultOptions.selector,\n style = defaultOptions.style,\n}: CreateFocusOutlineStyleOptions = defaultOptions): GriffelStyle => ({\n ':focus': {\n outlineStyle: enableOutline ? undefined : 'none',\n },\n ':focus-visible': {\n outlineStyle: enableOutline ? undefined : 'none',\n },\n\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});\n"],"names":["tokens","shorthands","createCustomFocusIndicatorStyle","defaultOptions","getOutlinePosition","outlineWidth","outlineOffset","position","offsetValue","getFocusOutlineStyles","options","outlineRadius","outlineColor","borderColor","content","pointerEvents","zIndex","borderStyle","borderWidth","borderRadius","top","right","bottom","left","createFocusOutlineStyle","enableOutline","selector","style","outlineStyle","undefined","colorStrokeFocus2","borderRadiusMedium"],"mappings":"AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,SACEC,+BAA+B,QAE1B,oCAAoC;AAC3C,SAASC,cAAc,QAAQ,cAAc;AAsB7C;;;;;;CAMC,GACD,SAASC,mBACP,EAAEC,YAAY,EAAEC,aAAa,EAA4B,EACzDC,QAA6C;
|
1
|
+
{"version":3,"sources":["createFocusOutlineStyle.ts"],"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 Omit<CreateCustomFocusIndicatorStyleOptions, 'enableOutline'> {\n style?: Partial<FocusOutlineStyleOptions>;\n\n /**\n * Enables the browser default outline style\n */\n enableOutline?: boolean;\n}\n\n/**\n * Get the position of the focus outline\n *\n * @param options - Configures the style of the focus outline\n * @param position - The position of the focus outline\n * @returns CSS value for the position of the focus outline\n */\nfunction getOutlinePosition(\n { outlineWidth, outlineOffset }: FocusOutlineStyleOptions,\n position: 'top' | 'bottom' | 'left' | 'right',\n) {\n const offsetValue = (outlineOffset as FocusOutlineOffset)?.[position] || outlineOffset;\n\n if (!outlineOffset) {\n return `calc(${outlineWidth} * -1)`;\n }\n\n return `calc(0px - ${outlineWidth} - ${offsetValue})`;\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, outlineWidth } = options;\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: getOutlinePosition(options, 'top'),\n right: getOutlinePosition(options, 'right'),\n bottom: getOutlinePosition(options, 'bottom'),\n left: getOutlinePosition(options, 'left'),\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 enableOutline = false,\n selector = defaultOptions.selector,\n customizeSelector,\n style = defaultOptions.style,\n}: CreateFocusOutlineStyleOptions = defaultOptions): GriffelStyle => ({\n ':focus': {\n outlineStyle: enableOutline ? undefined : 'none',\n },\n ':focus-visible': {\n outlineStyle: enableOutline ? undefined : 'none',\n },\n\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, customizeSelector },\n ),\n});\n"],"names":["tokens","shorthands","createCustomFocusIndicatorStyle","defaultOptions","getOutlinePosition","outlineWidth","outlineOffset","position","offsetValue","getFocusOutlineStyles","options","outlineRadius","outlineColor","borderColor","content","pointerEvents","zIndex","borderStyle","borderWidth","borderRadius","top","right","bottom","left","createFocusOutlineStyle","enableOutline","selector","customizeSelector","style","outlineStyle","undefined","colorStrokeFocus2","borderRadiusMedium"],"mappings":"AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,SACEC,+BAA+B,QAE1B,oCAAoC;AAC3C,SAASC,cAAc,QAAQ,cAAc;AAsB7C;;;;;;CAMC,GACD,SAASC,mBACP,EAAEC,YAAY,EAAEC,aAAa,EAA4B,EACzDC,QAA6C;IAE7C,MAAMC,cAAc,CAACF,0BAAAA,oCAAD,AAACA,aAAsC,CAACC,SAAS,KAAID;IAEzE,IAAI,CAACA,eAAe;QAClB,OAAO,CAAC,KAAK,EAAED,aAAa,MAAM,CAAC;IACrC;IAEA,OAAO,CAAC,WAAW,EAAEA,aAAa,GAAG,EAAEG,YAAY,CAAC,CAAC;AACvD;AAEA;;;;;;CAMC,GACD,MAAMC,wBAAwB,CAACC;IAC7B,MAAM,EAAEC,aAAa,EAAEC,YAAY,EAAEP,YAAY,EAAE,GAAGK;IAEtD,OAAO;QACL,GAAGT,WAAWY,WAAW,CAAC,cAAc;QACxC,WAAW;YACTC,SAAS;YACTP,UAAU;YACVQ,eAAe;YACfC,QAAQ;YAER,GAAGf,WAAWgB,WAAW,CAAC,QAAQ;YAClC,GAAGhB,WAAWiB,WAAW,CAACb,aAAa;YACvC,GAAGJ,WAAWkB,YAAY,CAACR,cAAc;YACzC,GAAGV,WAAWY,WAAW,CAACD,aAAa;YAEvCQ,KAAKhB,mBAAmBM,SAAS;YACjCW,OAAOjB,mBAAmBM,SAAS;YACnCY,QAAQlB,mBAAmBM,SAAS;YACpCa,MAAMnB,mBAAmBM,SAAS;QACpC;IACF;AACF;AAEA;;;;;;CAMC,GACD,OAAO,MAAMc,0BAA0B,CAAC,EACtCC,gBAAgB,KAAK,EACrBC,WAAWvB,eAAeuB,QAAQ,EAClCC,iBAAiB,EACjBC,QAAQzB,eAAeyB,KAAK,EACG,GAAGzB,cAAc,GAAoB,CAAA;QACpE,UAAU;YACR0B,cAAcJ,gBAAgBK,YAAY;QAC5C;QACA,kBAAkB;YAChBD,cAAcJ,gBAAgBK,YAAY;QAC5C;QAEA,GAAG5B,gCACDO,sBAAsB;YACpBG,cAAcZ,OAAO+B,iBAAiB;YACtCpB,eAAeX,OAAOgC,kBAAkB;YACxC,wDAAwD;YACxD3B,cAAc;YACd,GAAGuB,KAAK;QACV,IACA;YAAEF;YAAUC;QAAkB,EAC/B;IACH,CAAA,EAAG"}
|
@@ -61,12 +61,11 @@ function removeFocusVisibleClass(el) {
|
|
61
61
|
el.removeAttribute(FOCUS_VISIBLE_ATTR);
|
62
62
|
}
|
63
63
|
function alreadyInScope(el) {
|
64
|
-
var _el;
|
65
64
|
if (!el) {
|
66
65
|
return false;
|
67
66
|
}
|
68
67
|
if (el.focusVisible) {
|
69
68
|
return true;
|
70
69
|
}
|
71
|
-
return alreadyInScope(
|
70
|
+
return alreadyInScope(el === null || el === void 0 ? void 0 : el.parentElement);
|
72
71
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["focusVisiblePolyfill.ts"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport { KEYBORG_FOCUSIN, KeyborgFocusInEvent, createKeyborg, disposeKeyborg } from 'keyborg';\n\nimport { FOCUS_VISIBLE_ATTR } from './constants';\n\n/**\n * Because `addEventListener` type override falls back to 2nd definition (evt name is unknown string literal)\n * evt is being typed as a base class of MouseEvent -> `Event`.\n * This type is used to override `listener` calls to make TS happy\n */\ntype ListenerOverride = (evt: Event) => void;\n\ntype FocusVisibleState = {\n /**\n * Current element with focus visible in state\n */\n current: HTMLElement | undefined;\n};\n\ntype HTMLElementWithFocusVisibleScope = {\n focusVisible: boolean | undefined;\n} & HTMLElement;\n\n/**\n * @internal\n * @param scope - Applies the ponyfill to all DOM children\n * @param targetWindow - window\n */\nexport function applyFocusVisiblePolyfill(scope: HTMLElement, targetWindow: Window): () => void {\n if (alreadyInScope(scope)) {\n // Focus visible polyfill already applied at this scope\n return () => undefined;\n }\n\n const state: FocusVisibleState = {\n current: undefined,\n };\n\n const keyborg = createKeyborg(targetWindow);\n\n // When navigation mode changes remove the focus-visible selector\n keyborg.subscribe(isNavigatingWithKeyboard => {\n if (!isNavigatingWithKeyboard && state.current) {\n removeFocusVisibleClass(state.current);\n state.current = undefined;\n }\n });\n\n // Keyborg's focusin event is delegated so it's only registered once on the window\n // and contains metadata about the focus event\n const keyborgListener = (e: KeyborgFocusInEvent) => {\n if (state.current) {\n removeFocusVisibleClass(state.current);\n state.current = undefined;\n }\n\n if (keyborg.isNavigatingWithKeyboard() && isHTMLElement(e.target) && e.target) {\n // Griffel can't create chained global styles so use the parent element for now\n state.current = e.target;\n applyFocusVisibleClass(state.current);\n }\n };\n\n // Make sure that when focus leaves the scope, the focus visible class is removed\n const blurListener = (e: FocusEvent) => {\n if (!e.relatedTarget || (isHTMLElement(e.relatedTarget) && !scope.contains(e.relatedTarget))) {\n if (state.current) {\n removeFocusVisibleClass(state.current);\n state.current = undefined;\n }\n }\n };\n\n scope.addEventListener(KEYBORG_FOCUSIN, keyborgListener as ListenerOverride);\n scope.addEventListener('focusout', blurListener);\n (scope as HTMLElementWithFocusVisibleScope).focusVisible = true;\n\n // Return disposer\n return () => {\n scope.removeEventListener(KEYBORG_FOCUSIN, keyborgListener as ListenerOverride);\n scope.removeEventListener('focusout', blurListener);\n delete (scope as HTMLElementWithFocusVisibleScope).focusVisible;\n disposeKeyborg(keyborg);\n };\n}\n\nfunction applyFocusVisibleClass(el: HTMLElement) {\n el.setAttribute(FOCUS_VISIBLE_ATTR, '');\n}\n\nfunction removeFocusVisibleClass(el: HTMLElement) {\n el.removeAttribute(FOCUS_VISIBLE_ATTR);\n}\n\nfunction alreadyInScope(el: HTMLElement | null | undefined): boolean {\n if (!el) {\n return false;\n }\n\n if ((el as HTMLElementWithFocusVisibleScope).focusVisible) {\n return true;\n }\n\n return alreadyInScope(el?.parentElement);\n}\n"],"names":["isHTMLElement","KEYBORG_FOCUSIN","createKeyborg","disposeKeyborg","FOCUS_VISIBLE_ATTR","applyFocusVisiblePolyfill","scope","targetWindow","alreadyInScope","undefined","state","current","keyborg","subscribe","isNavigatingWithKeyboard","removeFocusVisibleClass","keyborgListener","e","target","applyFocusVisibleClass","blurListener","relatedTarget","contains","addEventListener","focusVisible","removeEventListener","el","setAttribute","removeAttribute","parentElement"],"mappings":"AAAA,SAASA,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,eAAe,EAAuBC,aAAa,EAAEC,cAAc,QAAQ,UAAU;AAE9F,SAASC,kBAAkB,QAAQ,cAAc;AAoBjD;;;;CAIC,GACD,OAAO,SAASC,0BAA0BC,KAAkB,EAAEC,YAAoB;IAChF,IAAIC,eAAeF,QAAQ;QACzB,uDAAuD;QACvD,OAAO,IAAMG;IACf;IAEA,MAAMC,QAA2B;QAC/BC,SAASF;IACX;IAEA,MAAMG,UAAUV,cAAcK;IAE9B,iEAAiE;IACjEK,QAAQC,SAAS,CAACC,CAAAA;QAChB,IAAI,CAACA,4BAA4BJ,MAAMC,OAAO,EAAE;YAC9CI,wBAAwBL,MAAMC,OAAO;YACrCD,MAAMC,OAAO,GAAGF;QAClB;IACF;IAEA,kFAAkF;IAClF,8CAA8C;IAC9C,MAAMO,kBAAkB,CAACC;QACvB,IAAIP,MAAMC,OAAO,EAAE;YACjBI,wBAAwBL,MAAMC,OAAO;YACrCD,MAAMC,OAAO,GAAGF;QAClB;QAEA,IAAIG,QAAQE,wBAAwB,MAAMd,cAAciB,EAAEC,MAAM,KAAKD,EAAEC,MAAM,EAAE;YAC7E,+EAA+E;YAC/ER,MAAMC,OAAO,GAAGM,EAAEC,MAAM;YACxBC,uBAAuBT,MAAMC,OAAO;QACtC;IACF;IAEA,iFAAiF;IACjF,MAAMS,eAAe,CAACH;QACpB,IAAI,CAACA,EAAEI,aAAa,IAAKrB,cAAciB,EAAEI,aAAa,KAAK,CAACf,MAAMgB,QAAQ,CAACL,EAAEI,aAAa,GAAI;YAC5F,IAAIX,MAAMC,OAAO,EAAE;gBACjBI,wBAAwBL,MAAMC,OAAO;gBACrCD,MAAMC,OAAO,GAAGF;YAClB;QACF;IACF;IAEAH,MAAMiB,gBAAgB,CAACtB,iBAAiBe;IACxCV,MAAMiB,gBAAgB,CAAC,YAAYH;IAClCd,MAA2CkB,YAAY,GAAG;IAE3D,kBAAkB;IAClB,OAAO;QACLlB,MAAMmB,mBAAmB,CAACxB,iBAAiBe;QAC3CV,MAAMmB,mBAAmB,CAAC,YAAYL;QACtC,OAAO,AAACd,MAA2CkB,YAAY;QAC/DrB,eAAeS;IACjB;AACF;AAEA,SAASO,uBAAuBO,EAAe;IAC7CA,GAAGC,YAAY,CAACvB,oBAAoB;AACtC;AAEA,SAASW,wBAAwBW,EAAe;IAC9CA,GAAGE,eAAe,CAACxB;AACrB;AAEA,SAASI,eAAekB,EAAkC;
|
1
|
+
{"version":3,"sources":["focusVisiblePolyfill.ts"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport { KEYBORG_FOCUSIN, KeyborgFocusInEvent, createKeyborg, disposeKeyborg } from 'keyborg';\n\nimport { FOCUS_VISIBLE_ATTR } from './constants';\n\n/**\n * Because `addEventListener` type override falls back to 2nd definition (evt name is unknown string literal)\n * evt is being typed as a base class of MouseEvent -> `Event`.\n * This type is used to override `listener` calls to make TS happy\n */\ntype ListenerOverride = (evt: Event) => void;\n\ntype FocusVisibleState = {\n /**\n * Current element with focus visible in state\n */\n current: HTMLElement | undefined;\n};\n\ntype HTMLElementWithFocusVisibleScope = {\n focusVisible: boolean | undefined;\n} & HTMLElement;\n\n/**\n * @internal\n * @param scope - Applies the ponyfill to all DOM children\n * @param targetWindow - window\n */\nexport function applyFocusVisiblePolyfill(scope: HTMLElement, targetWindow: Window): () => void {\n if (alreadyInScope(scope)) {\n // Focus visible polyfill already applied at this scope\n return () => undefined;\n }\n\n const state: FocusVisibleState = {\n current: undefined,\n };\n\n const keyborg = createKeyborg(targetWindow);\n\n // When navigation mode changes remove the focus-visible selector\n keyborg.subscribe(isNavigatingWithKeyboard => {\n if (!isNavigatingWithKeyboard && state.current) {\n removeFocusVisibleClass(state.current);\n state.current = undefined;\n }\n });\n\n // Keyborg's focusin event is delegated so it's only registered once on the window\n // and contains metadata about the focus event\n const keyborgListener = (e: KeyborgFocusInEvent) => {\n if (state.current) {\n removeFocusVisibleClass(state.current);\n state.current = undefined;\n }\n\n if (keyborg.isNavigatingWithKeyboard() && isHTMLElement(e.target) && e.target) {\n // Griffel can't create chained global styles so use the parent element for now\n state.current = e.target;\n applyFocusVisibleClass(state.current);\n }\n };\n\n // Make sure that when focus leaves the scope, the focus visible class is removed\n const blurListener = (e: FocusEvent) => {\n if (!e.relatedTarget || (isHTMLElement(e.relatedTarget) && !scope.contains(e.relatedTarget))) {\n if (state.current) {\n removeFocusVisibleClass(state.current);\n state.current = undefined;\n }\n }\n };\n\n scope.addEventListener(KEYBORG_FOCUSIN, keyborgListener as ListenerOverride);\n scope.addEventListener('focusout', blurListener);\n (scope as HTMLElementWithFocusVisibleScope).focusVisible = true;\n\n // Return disposer\n return () => {\n scope.removeEventListener(KEYBORG_FOCUSIN, keyborgListener as ListenerOverride);\n scope.removeEventListener('focusout', blurListener);\n delete (scope as HTMLElementWithFocusVisibleScope).focusVisible;\n disposeKeyborg(keyborg);\n };\n}\n\nfunction applyFocusVisibleClass(el: HTMLElement) {\n el.setAttribute(FOCUS_VISIBLE_ATTR, '');\n}\n\nfunction removeFocusVisibleClass(el: HTMLElement) {\n el.removeAttribute(FOCUS_VISIBLE_ATTR);\n}\n\nfunction alreadyInScope(el: HTMLElement | null | undefined): boolean {\n if (!el) {\n return false;\n }\n\n if ((el as HTMLElementWithFocusVisibleScope).focusVisible) {\n return true;\n }\n\n return alreadyInScope(el?.parentElement);\n}\n"],"names":["isHTMLElement","KEYBORG_FOCUSIN","createKeyborg","disposeKeyborg","FOCUS_VISIBLE_ATTR","applyFocusVisiblePolyfill","scope","targetWindow","alreadyInScope","undefined","state","current","keyborg","subscribe","isNavigatingWithKeyboard","removeFocusVisibleClass","keyborgListener","e","target","applyFocusVisibleClass","blurListener","relatedTarget","contains","addEventListener","focusVisible","removeEventListener","el","setAttribute","removeAttribute","parentElement"],"mappings":"AAAA,SAASA,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,eAAe,EAAuBC,aAAa,EAAEC,cAAc,QAAQ,UAAU;AAE9F,SAASC,kBAAkB,QAAQ,cAAc;AAoBjD;;;;CAIC,GACD,OAAO,SAASC,0BAA0BC,KAAkB,EAAEC,YAAoB;IAChF,IAAIC,eAAeF,QAAQ;QACzB,uDAAuD;QACvD,OAAO,IAAMG;IACf;IAEA,MAAMC,QAA2B;QAC/BC,SAASF;IACX;IAEA,MAAMG,UAAUV,cAAcK;IAE9B,iEAAiE;IACjEK,QAAQC,SAAS,CAACC,CAAAA;QAChB,IAAI,CAACA,4BAA4BJ,MAAMC,OAAO,EAAE;YAC9CI,wBAAwBL,MAAMC,OAAO;YACrCD,MAAMC,OAAO,GAAGF;QAClB;IACF;IAEA,kFAAkF;IAClF,8CAA8C;IAC9C,MAAMO,kBAAkB,CAACC;QACvB,IAAIP,MAAMC,OAAO,EAAE;YACjBI,wBAAwBL,MAAMC,OAAO;YACrCD,MAAMC,OAAO,GAAGF;QAClB;QAEA,IAAIG,QAAQE,wBAAwB,MAAMd,cAAciB,EAAEC,MAAM,KAAKD,EAAEC,MAAM,EAAE;YAC7E,+EAA+E;YAC/ER,MAAMC,OAAO,GAAGM,EAAEC,MAAM;YACxBC,uBAAuBT,MAAMC,OAAO;QACtC;IACF;IAEA,iFAAiF;IACjF,MAAMS,eAAe,CAACH;QACpB,IAAI,CAACA,EAAEI,aAAa,IAAKrB,cAAciB,EAAEI,aAAa,KAAK,CAACf,MAAMgB,QAAQ,CAACL,EAAEI,aAAa,GAAI;YAC5F,IAAIX,MAAMC,OAAO,EAAE;gBACjBI,wBAAwBL,MAAMC,OAAO;gBACrCD,MAAMC,OAAO,GAAGF;YAClB;QACF;IACF;IAEAH,MAAMiB,gBAAgB,CAACtB,iBAAiBe;IACxCV,MAAMiB,gBAAgB,CAAC,YAAYH;IAClCd,MAA2CkB,YAAY,GAAG;IAE3D,kBAAkB;IAClB,OAAO;QACLlB,MAAMmB,mBAAmB,CAACxB,iBAAiBe;QAC3CV,MAAMmB,mBAAmB,CAAC,YAAYL;QACtC,OAAO,AAACd,MAA2CkB,YAAY;QAC/DrB,eAAeS;IACjB;AACF;AAEA,SAASO,uBAAuBO,EAAe;IAC7CA,GAAGC,YAAY,CAACvB,oBAAoB;AACtC;AAEA,SAASW,wBAAwBW,EAAe;IAC9CA,GAAGE,eAAe,CAACxB;AACrB;AAEA,SAASI,eAAekB,EAAkC;IACxD,IAAI,CAACA,IAAI;QACP,OAAO;IACT;IAEA,IAAI,AAACA,GAAwCF,YAAY,EAAE;QACzD,OAAO;IACT;IAEA,OAAOhB,eAAekB,eAAAA,yBAAAA,GAAIG,aAAa;AACzC"}
|
@@ -7,29 +7,20 @@ import { useTabster } from './useTabster';
|
|
7
7
|
const tabster = useTabster();
|
8
8
|
const { targetDocument } = useFluent();
|
9
9
|
// Narrow props for now and let need dictate additional props in the future
|
10
|
-
const findAllFocusable = React.useCallback((container, acceptCondition)=>{
|
11
|
-
var _tabster;
|
12
|
-
return ((_tabster = tabster) === null || _tabster === void 0 ? void 0 : _tabster.focusable.findAll({
|
10
|
+
const findAllFocusable = React.useCallback((container, acceptCondition)=>(tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findAll({
|
13
11
|
container,
|
14
12
|
acceptCondition
|
15
|
-
})) || []
|
16
|
-
}, [
|
13
|
+
})) || [], [
|
17
14
|
tabster
|
18
15
|
]);
|
19
|
-
const findFirstFocusable = React.useCallback((container)=>{
|
20
|
-
var _tabster;
|
21
|
-
return (_tabster = tabster) === null || _tabster === void 0 ? void 0 : _tabster.focusable.findFirst({
|
16
|
+
const findFirstFocusable = React.useCallback((container)=>tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findFirst({
|
22
17
|
container
|
23
|
-
})
|
24
|
-
}, [
|
18
|
+
}), [
|
25
19
|
tabster
|
26
20
|
]);
|
27
|
-
const findLastFocusable = React.useCallback((container)=>{
|
28
|
-
var _tabster;
|
29
|
-
return (_tabster = tabster) === null || _tabster === void 0 ? void 0 : _tabster.focusable.findLast({
|
21
|
+
const findLastFocusable = React.useCallback((container)=>tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findLast({
|
30
22
|
container
|
31
|
-
})
|
32
|
-
}, [
|
23
|
+
}), [
|
33
24
|
tabster
|
34
25
|
]);
|
35
26
|
const findNextFocusable = React.useCallback((currentElement, options = {})=>{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useFocusFinders.ts"],"sourcesContent":["import * as React from 'react';\nimport { Types as TabsterTypes } from 'tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\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 const { targetDocument } = useFluent();\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(\n (container: HTMLElement) => tabster?.focusable.findLast({ container }),\n [tabster],\n );\n\n const findNextFocusable = React.useCallback(\n (currentElement: HTMLElement, options: Pick<Partial<TabsterTypes.FindNextProps>, 'container'> = {}) => {\n if (!tabster || !targetDocument) {\n return null;\n }\n\n const { container = targetDocument.body } = options;\n\n return tabster.focusable.findNext({ currentElement, container });\n },\n [tabster, targetDocument],\n );\n\n const findPrevFocusable = React.useCallback(\n (currentElement: HTMLElement, options: Pick<Partial<TabsterTypes.FindNextProps>, 'container'> = {}) => {\n if (!tabster || !targetDocument) {\n return null;\n }\n\n const { container = targetDocument.body } = options;\n\n return tabster.focusable.findPrev({ currentElement, container });\n },\n [tabster, targetDocument],\n );\n\n return {\n findAllFocusable,\n findFirstFocusable,\n findLastFocusable,\n findNextFocusable,\n findPrevFocusable,\n };\n};\n"],"names":["React","useFluent_unstable","useFluent","useTabster","useFocusFinders","tabster","targetDocument","findAllFocusable","useCallback","container","acceptCondition","focusable","findAll","findFirstFocusable","findFirst","findLastFocusable","findLast","findNextFocusable","currentElement","options","body","findNext","findPrevFocusable","findPrev"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,UAAU,QAAQ,eAAe;AAE1C;;CAEC,GACD,OAAO,MAAMC,kBAAkB;IAC7B,MAAMC,UAAUF;IAChB,MAAM,EAAEG,cAAc,EAAE,GAAGJ;IAE3B,2EAA2E;IAC3E,MAAMK,mBAAmBP,MAAMQ,WAAW,CACxC,CAACC,WAAwBC
|
1
|
+
{"version":3,"sources":["useFocusFinders.ts"],"sourcesContent":["import * as React from 'react';\nimport { Types as TabsterTypes } from 'tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\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 const { targetDocument } = useFluent();\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(\n (container: HTMLElement) => tabster?.focusable.findLast({ container }),\n [tabster],\n );\n\n const findNextFocusable = React.useCallback(\n (currentElement: HTMLElement, options: Pick<Partial<TabsterTypes.FindNextProps>, 'container'> = {}) => {\n if (!tabster || !targetDocument) {\n return null;\n }\n\n const { container = targetDocument.body } = options;\n\n return tabster.focusable.findNext({ currentElement, container });\n },\n [tabster, targetDocument],\n );\n\n const findPrevFocusable = React.useCallback(\n (currentElement: HTMLElement, options: Pick<Partial<TabsterTypes.FindNextProps>, 'container'> = {}) => {\n if (!tabster || !targetDocument) {\n return null;\n }\n\n const { container = targetDocument.body } = options;\n\n return tabster.focusable.findPrev({ currentElement, container });\n },\n [tabster, targetDocument],\n );\n\n return {\n findAllFocusable,\n findFirstFocusable,\n findLastFocusable,\n findNextFocusable,\n findPrevFocusable,\n };\n};\n"],"names":["React","useFluent_unstable","useFluent","useTabster","useFocusFinders","tabster","targetDocument","findAllFocusable","useCallback","container","acceptCondition","focusable","findAll","findFirstFocusable","findFirst","findLastFocusable","findLast","findNextFocusable","currentElement","options","body","findNext","findPrevFocusable","findPrev"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,UAAU,QAAQ,eAAe;AAE1C;;CAEC,GACD,OAAO,MAAMC,kBAAkB;IAC7B,MAAMC,UAAUF;IAChB,MAAM,EAAEG,cAAc,EAAE,GAAGJ;IAE3B,2EAA2E;IAC3E,MAAMK,mBAAmBP,MAAMQ,WAAW,CACxC,CAACC,WAAwBC,kBACvBL,CAAAA,oBAAAA,8BAAAA,QAASM,SAAS,CAACC,OAAO,CAAC;YAAEH;YAAWC;QAAgB,OAAM,EAAE,EAClE;QAACL;KAAQ;IAGX,MAAMQ,qBAAqBb,MAAMQ,WAAW,CAC1C,CAACC,YAA2BJ,oBAAAA,8BAAAA,QAASM,SAAS,CAACG,SAAS,CAAC;YAAEL;QAAU,IACrE;QAACJ;KAAQ;IAGX,MAAMU,oBAAoBf,MAAMQ,WAAW,CACzC,CAACC,YAA2BJ,oBAAAA,8BAAAA,QAASM,SAAS,CAACK,QAAQ,CAAC;YAAEP;QAAU,IACpE;QAACJ;KAAQ;IAGX,MAAMY,oBAAoBjB,MAAMQ,WAAW,CACzC,CAACU,gBAA6BC,UAAkE,CAAC,CAAC;QAChG,IAAI,CAACd,WAAW,CAACC,gBAAgB;YAC/B,OAAO;QACT;QAEA,MAAM,EAAEG,YAAYH,eAAec,IAAI,EAAE,GAAGD;QAE5C,OAAOd,QAAQM,SAAS,CAACU,QAAQ,CAAC;YAAEH;YAAgBT;QAAU;IAChE,GACA;QAACJ;QAASC;KAAe;IAG3B,MAAMgB,oBAAoBtB,MAAMQ,WAAW,CACzC,CAACU,gBAA6BC,UAAkE,CAAC,CAAC;QAChG,IAAI,CAACd,WAAW,CAACC,gBAAgB;YAC/B,OAAO;QACT;QAEA,MAAM,EAAEG,YAAYH,eAAec,IAAI,EAAE,GAAGD;QAE5C,OAAOd,QAAQM,SAAS,CAACY,QAAQ,CAAC;YAAEL;YAAgBT;QAAU;IAChE,GACA;QAACJ;QAASC;KAAe;IAG3B,OAAO;QACLC;QACAM;QACAE;QACAE;QACAK;IACF;AACF,EAAE"}
|
@@ -7,8 +7,7 @@ export function useFocusVisible(options = {}) {
|
|
7
7
|
var _options_targetDocument;
|
8
8
|
const targetDocument = (_options_targetDocument = options.targetDocument) !== null && _options_targetDocument !== void 0 ? _options_targetDocument : contextValue.targetDocument;
|
9
9
|
React.useEffect(()=>{
|
10
|
-
|
11
|
-
if (((_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.defaultView) && scopeRef.current) {
|
10
|
+
if ((targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) && scopeRef.current) {
|
12
11
|
return applyFocusVisiblePolyfill(scopeRef.current, targetDocument.defaultView);
|
13
12
|
}
|
14
13
|
}, [
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useFocusVisible.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nimport { applyFocusVisiblePolyfill } from '../focus/focusVisiblePolyfill';\n\ntype UseFocusVisibleOptions = {\n targetDocument?: Document;\n};\n\nexport function useFocusVisible<TElement extends HTMLElement = HTMLElement>(options: UseFocusVisibleOptions = {}) {\n const contextValue = useFluent();\n const scopeRef = React.useRef<TElement>(null);\n\n const targetDocument = options.targetDocument ?? contextValue.targetDocument;\n\n React.useEffect(() => {\n if (targetDocument?.defaultView && scopeRef.current) {\n return applyFocusVisiblePolyfill(scopeRef.current, targetDocument.defaultView);\n }\n }, [scopeRef, targetDocument]);\n\n return scopeRef;\n}\n"],"names":["React","useFluent_unstable","useFluent","applyFocusVisiblePolyfill","useFocusVisible","options","contextValue","scopeRef","useRef","targetDocument","useEffect","defaultView","current"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAElF,SAASC,yBAAyB,QAAQ,gCAAgC;AAM1E,OAAO,SAASC,gBAA4DC,UAAkC,CAAC,CAAC;IAC9G,MAAMC,eAAeJ;IACrB,MAAMK,WAAWP,MAAMQ,MAAM,CAAW;QAEjBH;IAAvB,MAAMI,iBAAiBJ,CAAAA,0BAAAA,QAAQI,cAAc,cAAtBJ,qCAAAA,0BAA0BC,aAAaG,cAAc;IAE5ET,MAAMU,SAAS,CAAC;
|
1
|
+
{"version":3,"sources":["useFocusVisible.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nimport { applyFocusVisiblePolyfill } from '../focus/focusVisiblePolyfill';\n\ntype UseFocusVisibleOptions = {\n targetDocument?: Document;\n};\n\nexport function useFocusVisible<TElement extends HTMLElement = HTMLElement>(options: UseFocusVisibleOptions = {}) {\n const contextValue = useFluent();\n const scopeRef = React.useRef<TElement>(null);\n\n const targetDocument = options.targetDocument ?? contextValue.targetDocument;\n\n React.useEffect(() => {\n if (targetDocument?.defaultView && scopeRef.current) {\n return applyFocusVisiblePolyfill(scopeRef.current, targetDocument.defaultView);\n }\n }, [scopeRef, targetDocument]);\n\n return scopeRef;\n}\n"],"names":["React","useFluent_unstable","useFluent","applyFocusVisiblePolyfill","useFocusVisible","options","contextValue","scopeRef","useRef","targetDocument","useEffect","defaultView","current"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAElF,SAASC,yBAAyB,QAAQ,gCAAgC;AAM1E,OAAO,SAASC,gBAA4DC,UAAkC,CAAC,CAAC;IAC9G,MAAMC,eAAeJ;IACrB,MAAMK,WAAWP,MAAMQ,MAAM,CAAW;QAEjBH;IAAvB,MAAMI,iBAAiBJ,CAAAA,0BAAAA,QAAQI,cAAc,cAAtBJ,qCAAAA,0BAA0BC,aAAaG,cAAc;IAE5ET,MAAMU,SAAS,CAAC;QACd,IAAID,CAAAA,2BAAAA,qCAAAA,eAAgBE,WAAW,KAAIJ,SAASK,OAAO,EAAE;YACnD,OAAOT,0BAA0BI,SAASK,OAAO,EAAEH,eAAeE,WAAW;QAC/E;IACF,GAAG;QAACJ;QAAUE;KAAe;IAE7B,OAAOF;AACT"}
|
@@ -9,8 +9,7 @@ import { applyFocusWithinPolyfill } from '../focus/focusWithinPolyfill';
|
|
9
9
|
const { targetDocument } = useFluent();
|
10
10
|
const elementRef = React.useRef(null);
|
11
11
|
React.useEffect(()=>{
|
12
|
-
|
13
|
-
if (((_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.defaultView) && elementRef.current) {
|
12
|
+
if ((targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) && elementRef.current) {
|
14
13
|
return applyFocusWithinPolyfill(elementRef.current, targetDocument.defaultView);
|
15
14
|
}
|
16
15
|
}, [
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useFocusWithin.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { applyFocusWithinPolyfill } from '../focus/focusWithinPolyfill';\n\n/**\n * A ponyfill that allows `:focus-within` to support visibility based on keyboard/mouse navigation\n * like `:focus-visible` https://github.com/WICG/focus-visible/issues/151\n * @returns ref to the element that uses `:focus-within` styles\n */\nexport function useFocusWithin<TElement extends HTMLElement = HTMLElement>() {\n const { targetDocument } = useFluent();\n const elementRef = React.useRef<TElement>(null);\n\n React.useEffect(() => {\n if (targetDocument?.defaultView && elementRef.current) {\n return applyFocusWithinPolyfill(elementRef.current, targetDocument.defaultView);\n }\n }, [elementRef, targetDocument]);\n\n return elementRef;\n}\n"],"names":["React","useFluent_unstable","useFluent","applyFocusWithinPolyfill","useFocusWithin","targetDocument","elementRef","useRef","useEffect","defaultView","current"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,wBAAwB,QAAQ,+BAA+B;AAExE;;;;CAIC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,cAAc,EAAE,GAAGH;IAC3B,MAAMI,aAAaN,MAAMO,MAAM,CAAW;IAE1CP,MAAMQ,SAAS,CAAC;
|
1
|
+
{"version":3,"sources":["useFocusWithin.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { applyFocusWithinPolyfill } from '../focus/focusWithinPolyfill';\n\n/**\n * A ponyfill that allows `:focus-within` to support visibility based on keyboard/mouse navigation\n * like `:focus-visible` https://github.com/WICG/focus-visible/issues/151\n * @returns ref to the element that uses `:focus-within` styles\n */\nexport function useFocusWithin<TElement extends HTMLElement = HTMLElement>() {\n const { targetDocument } = useFluent();\n const elementRef = React.useRef<TElement>(null);\n\n React.useEffect(() => {\n if (targetDocument?.defaultView && elementRef.current) {\n return applyFocusWithinPolyfill(elementRef.current, targetDocument.defaultView);\n }\n }, [elementRef, targetDocument]);\n\n return elementRef;\n}\n"],"names":["React","useFluent_unstable","useFluent","applyFocusWithinPolyfill","useFocusWithin","targetDocument","elementRef","useRef","useEffect","defaultView","current"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,wBAAwB,QAAQ,+BAA+B;AAExE;;;;CAIC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,cAAc,EAAE,GAAGH;IAC3B,MAAMI,aAAaN,MAAMO,MAAM,CAAW;IAE1CP,MAAMQ,SAAS,CAAC;QACd,IAAIH,CAAAA,2BAAAA,qCAAAA,eAAgBI,WAAW,KAAIH,WAAWI,OAAO,EAAE;YACrD,OAAOP,yBAAyBG,WAAWI,OAAO,EAAEL,eAAeI,WAAW;QAChF;IACF,GAAG;QAACH;QAAYD;KAAe;IAE/B,OAAOC;AACT"}
|
@@ -5,17 +5,16 @@ import { useTabster } from './useTabster';
|
|
5
5
|
* A hook that returns the necessary tabster attributes to support groupping.
|
6
6
|
* @param options - Options to configure keyboard navigation
|
7
7
|
*/ export const useFocusableGroup = (options)=>{
|
8
|
-
var _options, _options1;
|
9
8
|
const tabster = useTabster();
|
10
9
|
if (tabster) {
|
11
10
|
getGroupper(tabster);
|
12
11
|
}
|
13
12
|
return useTabsterAttributes({
|
14
13
|
groupper: {
|
15
|
-
tabbability: getTabbability(
|
14
|
+
tabbability: getTabbability(options === null || options === void 0 ? void 0 : options.tabBehavior)
|
16
15
|
},
|
17
16
|
focusable: {
|
18
|
-
ignoreKeydown:
|
17
|
+
ignoreKeydown: options === null || options === void 0 ? void 0 : options.ignoreDefaultKeydown
|
19
18
|
}
|
20
19
|
});
|
21
20
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useFocusableGroup.ts"],"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' | 'limited-trap-focus';\n\n /**\n * Tabster can ignore default handling of keydown events\n */\n ignoreDefaultKeydown?: Types.FocusableProps['ignoreKeydown'];\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 focusable: {\n ignoreKeydown: options?.ignoreDefaultKeydown,\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 'limited-trap-focus':\n return Types.GroupperTabbabilities.LimitedTrapFocus;\n default:\n return undefined;\n }\n};\n"],"names":["Types","getGroupper","useTabsterAttributes","useTabster","useFocusableGroup","options","tabster","groupper","tabbability","getTabbability","tabBehavior","focusable","ignoreKeydown","ignoreDefaultKeydown","GroupperTabbabilities","Unlimited","Limited","LimitedTrapFocus","undefined"],"mappings":"AAAA,SAASA,KAAK,EAAEC,WAAW,QAAQ,UAAU;AAC7C,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,UAAU,QAAQ,eAAe;AAc1C;;;CAGC,GACD,OAAO,MAAMC,oBAAoB,CAACC;
|
1
|
+
{"version":3,"sources":["useFocusableGroup.ts"],"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' | 'limited-trap-focus';\n\n /**\n * Tabster can ignore default handling of keydown events\n */\n ignoreDefaultKeydown?: Types.FocusableProps['ignoreKeydown'];\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 focusable: {\n ignoreKeydown: options?.ignoreDefaultKeydown,\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 'limited-trap-focus':\n return Types.GroupperTabbabilities.LimitedTrapFocus;\n default:\n return undefined;\n }\n};\n"],"names":["Types","getGroupper","useTabsterAttributes","useTabster","useFocusableGroup","options","tabster","groupper","tabbability","getTabbability","tabBehavior","focusable","ignoreKeydown","ignoreDefaultKeydown","GroupperTabbabilities","Unlimited","Limited","LimitedTrapFocus","undefined"],"mappings":"AAAA,SAASA,KAAK,EAAEC,WAAW,QAAQ,UAAU;AAC7C,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,UAAU,QAAQ,eAAe;AAc1C;;;CAGC,GACD,OAAO,MAAMC,oBAAoB,CAACC;IAChC,MAAMC,UAAUH;IAEhB,IAAIG,SAAS;QACXL,YAAYK;IACd;IAEA,OAAOJ,qBAAqB;QAC1BK,UAAU;YACRC,aAAaC,eAAeJ,oBAAAA,8BAAAA,QAASK,WAAW;QAClD;QACAC,WAAW;YACTC,aAAa,EAAEP,oBAAAA,8BAAAA,QAASQ,oBAAoB;QAC9C;IACF;AACF,EAAE;AAEF,MAAMJ,iBAAiB,CACrBC;IAEA,OAAQA;QACN,KAAK;YACH,OAAOV,MAAMc,qBAAqB,CAACC,SAAS;QAC9C,KAAK;YACH,OAAOf,MAAMc,qBAAqB,CAACE,OAAO;QAC5C,KAAK;YACH,OAAOhB,MAAMc,qBAAqB,CAACG,gBAAgB;QACrD;YACE,OAAOC;IACX;AACF"}
|
package/lib/hooks/useTabster.js
CHANGED
@@ -9,9 +9,8 @@ import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
|
9
9
|
* @internal
|
10
10
|
* @returns Tabster core instance
|
11
11
|
*/ export const useTabster = ()=>{
|
12
|
-
var _targetDocument;
|
13
12
|
const { targetDocument } = useFluent();
|
14
|
-
const defaultView = (
|
13
|
+
const defaultView = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) || undefined;
|
15
14
|
const tabster = React.useMemo(()=>{
|
16
15
|
if (!defaultView) {
|
17
16
|
return null;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useTabster.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { createTabster, disposeTabster, Types as TabsterTypes } from 'tabster';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\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 tabster = React.useMemo(() => {\n if (!defaultView) {\n return null;\n }\n\n return createTabster(defaultView, { autoRoot: {}, controlTab: false });\n }, [defaultView]);\n\n useIsomorphicLayoutEffect(() => {\n return () => {\n if (tabster) {\n disposeTabster(tabster);\n }\n };\n }, [tabster]);\n\n return tabster;\n};\n"],"names":["React","useFluent_unstable","useFluent","createTabster","disposeTabster","useIsomorphicLayoutEffect","useTabster","targetDocument","defaultView","undefined","tabster","useMemo","autoRoot","controlTab"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,aAAa,EAAEC,cAAc,QAA+B,UAAU;AAC/E,SAASC,yBAAyB,QAAQ,4BAA4B;AAEtE;;;;;;CAMC,GACD,OAAO,MAAMC,aAAa;
|
1
|
+
{"version":3,"sources":["useTabster.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { createTabster, disposeTabster, Types as TabsterTypes } from 'tabster';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\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 tabster = React.useMemo(() => {\n if (!defaultView) {\n return null;\n }\n\n return createTabster(defaultView, { autoRoot: {}, controlTab: false });\n }, [defaultView]);\n\n useIsomorphicLayoutEffect(() => {\n return () => {\n if (tabster) {\n disposeTabster(tabster);\n }\n };\n }, [tabster]);\n\n return tabster;\n};\n"],"names":["React","useFluent_unstable","useFluent","createTabster","disposeTabster","useIsomorphicLayoutEffect","useTabster","targetDocument","defaultView","undefined","tabster","useMemo","autoRoot","controlTab"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,aAAa,EAAEC,cAAc,QAA+B,UAAU;AAC/E,SAASC,yBAAyB,QAAQ,4BAA4B;AAEtE;;;;;;CAMC,GACD,OAAO,MAAMC,aAAa;IACxB,MAAM,EAAEC,cAAc,EAAE,GAAGL;IAE3B,MAAMM,cAAcD,CAAAA,2BAAAA,qCAAAA,eAAgBC,WAAW,KAAIC;IACnD,MAAMC,UAAUV,MAAMW,OAAO,CAAC;QAC5B,IAAI,CAACH,aAAa;YAChB,OAAO;QACT;QAEA,OAAOL,cAAcK,aAAa;YAAEI,UAAU,CAAC;YAAGC,YAAY;QAAM;IACtE,GAAG;QAACL;KAAY;IAEhBH,0BAA0B;QACxB,OAAO;YACL,IAAIK,SAAS;gBACXN,eAAeM;YACjB;QACF;IACF,GAAG;QAACA;KAAQ;IAEZ,OAAOA;AACT,EAAE"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["constants.js"],"sourcesContent":["export const KEYBOARD_NAV_ATTRIBUTE = 'data-keyboard-nav';\nexport const KEYBOARD_NAV_SELECTOR = `:global([${KEYBOARD_NAV_ATTRIBUTE}])`;\n/**\n * @internal\n */ export const FOCUS_VISIBLE_ATTR = 'data-fui-focus-visible';\n/**\n * @internal\n */ export const FOCUS_WITHIN_ATTR = 'data-fui-focus-within';\nexport const defaultOptions = {\n style: {},\n selector: 'focus'\n};\n"],"names":["KEYBOARD_NAV_ATTRIBUTE","KEYBOARD_NAV_SELECTOR","FOCUS_VISIBLE_ATTR","FOCUS_WITHIN_ATTR","defaultOptions","style","selector"],"mappings":";;;;;;;;;;;IAAaA,sBAAsB;eAAtBA;;IACAC,qBAAqB;eAArBA;;IAGIC,kBAAkB;eAAlBA;;IAGAC,iBAAiB;eAAjBA;;IACJC,cAAc;eAAdA;;;AARN,MAAMJ,yBAAyB;AAC/B,MAAMC,wBAAwB,CAAC,SAAS,EAAED,uBAAuB,EAAE,CAAC;AAGhE,MAAME,qBAAqB;AAG3B,MAAMC,oBAAoB;AAC9B,MAAMC,iBAAiB;IAC1BC,OAAO,CAAC;IACRC,UAAU;
|
1
|
+
{"version":3,"sources":["constants.js"],"sourcesContent":["export const KEYBOARD_NAV_ATTRIBUTE = 'data-keyboard-nav';\nexport const KEYBOARD_NAV_SELECTOR = `:global([${KEYBOARD_NAV_ATTRIBUTE}])`;\n/**\n * @internal\n */ export const FOCUS_VISIBLE_ATTR = 'data-fui-focus-visible';\n/**\n * @internal\n */ export const FOCUS_WITHIN_ATTR = 'data-fui-focus-within';\nexport const defaultOptions = {\n style: {},\n selector: 'focus',\n customizeSelector: (selector)=>selector\n};\n"],"names":["KEYBOARD_NAV_ATTRIBUTE","KEYBOARD_NAV_SELECTOR","FOCUS_VISIBLE_ATTR","FOCUS_WITHIN_ATTR","defaultOptions","style","selector","customizeSelector"],"mappings":";;;;;;;;;;;IAAaA,sBAAsB;eAAtBA;;IACAC,qBAAqB;eAArBA;;IAGIC,kBAAkB;eAAlBA;;IAGAC,iBAAiB;eAAjBA;;IACJC,cAAc;eAAdA;;;AARN,MAAMJ,yBAAyB;AAC/B,MAAMC,wBAAwB,CAAC,SAAS,EAAED,uBAAuB,EAAE,CAAC;AAGhE,MAAME,qBAAqB;AAG3B,MAAMC,oBAAoB;AAC9B,MAAMC,iBAAiB;IAC1BC,OAAO,CAAC;IACRC,UAAU;IACVC,mBAAmB,CAACD,WAAWA;AACnC"}
|
@@ -9,13 +9,16 @@ Object.defineProperty(exports, "createCustomFocusIndicatorStyle", {
|
|
9
9
|
}
|
10
10
|
});
|
11
11
|
const _constants = require("./constants");
|
12
|
-
function createCustomFocusIndicatorStyle(style, { selector = _constants.defaultOptions.selector } = _constants.defaultOptions) {
|
12
|
+
function createCustomFocusIndicatorStyle(style, { selector: selectorType = _constants.defaultOptions.selector, customizeSelector = _constants.defaultOptions.customizeSelector } = _constants.defaultOptions) {
|
13
13
|
return {
|
14
|
-
|
15
|
-
[`&[${_constants.FOCUS_VISIBLE_ATTR}]`]: style
|
16
|
-
},
|
17
|
-
...selector === 'focus-within' && {
|
18
|
-
[`&[${_constants.FOCUS_WITHIN_ATTR}]:${selector}`]: style
|
19
|
-
}
|
14
|
+
[customizeSelector(createBaseSelector(selectorType))]: style
|
20
15
|
};
|
21
16
|
}
|
17
|
+
function createBaseSelector(selectorType) {
|
18
|
+
switch(selectorType){
|
19
|
+
case 'focus':
|
20
|
+
return `&[${_constants.FOCUS_VISIBLE_ATTR}]`;
|
21
|
+
case 'focus-within':
|
22
|
+
return `&[${_constants.FOCUS_WITHIN_ATTR}]:focus-within`;
|
23
|
+
}
|
24
|
+
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["createCustomFocusIndicatorStyle.js"],"sourcesContent":["import { defaultOptions, FOCUS_VISIBLE_ATTR, FOCUS_WITHIN_ATTR } from './constants';\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 getDefaultFocusOutlineStyles\n * @param options - Configure the style of the focus outline\n */ export function createCustomFocusIndicatorStyle(style, { selector = defaultOptions.selector } = defaultOptions) {\n return {\n
|
1
|
+
{"version":3,"sources":["createCustomFocusIndicatorStyle.js"],"sourcesContent":["import { defaultOptions, FOCUS_VISIBLE_ATTR, FOCUS_WITHIN_ATTR } from './constants';\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 getDefaultFocusOutlineStyles\n * @param options - Configure the style of the focus outline\n */ export function createCustomFocusIndicatorStyle(style, { selector: selectorType = defaultOptions.selector, customizeSelector = defaultOptions.customizeSelector } = defaultOptions) {\n return {\n [customizeSelector(createBaseSelector(selectorType))]: style\n };\n}\nfunction createBaseSelector(selectorType) {\n switch(selectorType){\n case 'focus':\n return `&[${FOCUS_VISIBLE_ATTR}]`;\n case 'focus-within':\n return `&[${FOCUS_WITHIN_ATTR}]:focus-within`;\n }\n}\n"],"names":["createCustomFocusIndicatorStyle","style","selector","selectorType","defaultOptions","customizeSelector","createBaseSelector","FOCUS_VISIBLE_ATTR","FOCUS_WITHIN_ATTR"],"mappings":";;;;+BAOoBA;;;eAAAA;;;2BAPkD;AAO3D,SAASA,gCAAgCC,KAAK,EAAE,EAAEC,UAAUC,eAAeC,yBAAc,CAACF,QAAQ,EAAEG,oBAAoBD,yBAAc,CAACC,iBAAiB,EAAE,GAAGD,yBAAc;IAClL,OAAO;QACH,CAACC,kBAAkBC,mBAAmBH,eAAe,EAAEF;IAC3D;AACJ;AACA,SAASK,mBAAmBH,YAAY;IACpC,OAAOA;QACH,KAAK;YACD,OAAO,CAAC,EAAE,EAAEI,6BAAkB,CAAC,CAAC,CAAC;QACrC,KAAK;YACD,OAAO,CAAC,EAAE,EAAEC,4BAAiB,CAAC,cAAc,CAAC;IACrD;AACJ"}
|
@@ -19,8 +19,7 @@ const _constants = require("./constants");
|
|
19
19
|
* @param position - The position of the focus outline
|
20
20
|
* @returns CSS value for the position of the focus outline
|
21
21
|
*/ function getOutlinePosition({ outlineWidth, outlineOffset }, position) {
|
22
|
-
|
23
|
-
const offsetValue = ((_outlineOffset = outlineOffset) === null || _outlineOffset === void 0 ? void 0 : _outlineOffset[position]) || outlineOffset;
|
22
|
+
const offsetValue = (outlineOffset === null || outlineOffset === void 0 ? void 0 : outlineOffset[position]) || outlineOffset;
|
24
23
|
if (!outlineOffset) {
|
25
24
|
return `calc(${outlineWidth} * -1)`;
|
26
25
|
}
|
@@ -52,7 +51,7 @@ const _constants = require("./constants");
|
|
52
51
|
}
|
53
52
|
};
|
54
53
|
};
|
55
|
-
const createFocusOutlineStyle = ({ enableOutline = false, selector = _constants.defaultOptions.selector, style = _constants.defaultOptions.style } = _constants.defaultOptions)=>({
|
54
|
+
const createFocusOutlineStyle = ({ enableOutline = false, selector = _constants.defaultOptions.selector, customizeSelector, style = _constants.defaultOptions.style } = _constants.defaultOptions)=>({
|
56
55
|
':focus': {
|
57
56
|
outlineStyle: enableOutline ? undefined : 'none'
|
58
57
|
},
|
@@ -66,6 +65,7 @@ const createFocusOutlineStyle = ({ enableOutline = false, selector = _constants.
|
|
66
65
|
outlineWidth: '2px',
|
67
66
|
...style
|
68
67
|
}), {
|
69
|
-
selector
|
68
|
+
selector,
|
69
|
+
customizeSelector
|
70
70
|
})
|
71
71
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["createFocusOutlineStyle.js"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport { shorthands } from '@griffel/react';\nimport { createCustomFocusIndicatorStyle } from './createCustomFocusIndicatorStyle';\nimport { defaultOptions } from './constants';\n/**\n * Get the position of the focus outline\n *\n * @param options - Configures the style of the focus outline\n * @param position - The position of the focus outline\n * @returns CSS value for the position of the focus outline\n */ function getOutlinePosition({ outlineWidth, outlineOffset }, position) {\n
|
1
|
+
{"version":3,"sources":["createFocusOutlineStyle.js"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport { shorthands } from '@griffel/react';\nimport { createCustomFocusIndicatorStyle } from './createCustomFocusIndicatorStyle';\nimport { defaultOptions } from './constants';\n/**\n * Get the position of the focus outline\n *\n * @param options - Configures the style of the focus outline\n * @param position - The position of the focus outline\n * @returns CSS value for the position of the focus outline\n */ function getOutlinePosition({ outlineWidth, outlineOffset }, position) {\n const offsetValue = (outlineOffset === null || outlineOffset === void 0 ? void 0 : outlineOffset[position]) || outlineOffset;\n if (!outlineOffset) {\n return `calc(${outlineWidth} * -1)`;\n }\n return `calc(0px - ${outlineWidth} - ${offsetValue})`;\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 */ const getFocusOutlineStyles = (options)=>{\n const { outlineRadius, outlineColor, outlineWidth } = options;\n return {\n ...shorthands.borderColor('transparent'),\n '::after': {\n content: '\"\"',\n position: 'absolute',\n pointerEvents: 'none',\n zIndex: 1,\n ...shorthands.borderStyle('solid'),\n ...shorthands.borderWidth(outlineWidth),\n ...shorthands.borderRadius(outlineRadius),\n ...shorthands.borderColor(outlineColor),\n top: getOutlinePosition(options, 'top'),\n right: getOutlinePosition(options, 'right'),\n bottom: getOutlinePosition(options, 'bottom'),\n left: getOutlinePosition(options, 'left')\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 */ export const createFocusOutlineStyle = ({ enableOutline = false, selector = defaultOptions.selector, customizeSelector, style = defaultOptions.style } = defaultOptions)=>({\n ':focus': {\n outlineStyle: enableOutline ? undefined : 'none'\n },\n ':focus-visible': {\n outlineStyle: enableOutline ? undefined : 'none'\n },\n ...createCustomFocusIndicatorStyle(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 customizeSelector\n })\n });\n"],"names":["createFocusOutlineStyle","getOutlinePosition","outlineWidth","outlineOffset","position","offsetValue","getFocusOutlineStyles","options","outlineRadius","outlineColor","shorthands","borderColor","content","pointerEvents","zIndex","borderStyle","borderWidth","borderRadius","top","right","bottom","left","enableOutline","selector","defaultOptions","customizeSelector","style","outlineStyle","undefined","createCustomFocusIndicatorStyle","tokens","colorStrokeFocus2","borderRadiusMedium"],"mappings":";;;;+BAiDiBA;;;eAAAA;;;4BAjDM;uBACI;iDACqB;2BACjB;AAC/B;;;;;;CAMC,GAAG,SAASC,mBAAmB,EAAEC,YAAY,EAAEC,aAAa,EAAE,EAAEC,QAAQ;IACrE,MAAMC,cAAc,AAACF,CAAAA,kBAAkB,QAAQA,kBAAkB,KAAK,IAAI,KAAK,IAAIA,aAAa,CAACC,SAAS,AAAD,KAAMD;IAC/G,IAAI,CAACA,eAAe;QAChB,OAAO,CAAC,KAAK,EAAED,aAAa,MAAM,CAAC;IACvC;IACA,OAAO,CAAC,WAAW,EAAEA,aAAa,GAAG,EAAEG,YAAY,CAAC,CAAC;AACzD;AACA;;;;;;CAMC,GAAG,MAAMC,wBAAwB,CAACC;IAC/B,MAAM,EAAEC,aAAa,EAAEC,YAAY,EAAEP,YAAY,EAAE,GAAGK;IACtD,OAAO;QACH,GAAGG,iBAAU,CAACC,WAAW,CAAC,cAAc;QACxC,WAAW;YACPC,SAAS;YACTR,UAAU;YACVS,eAAe;YACfC,QAAQ;YACR,GAAGJ,iBAAU,CAACK,WAAW,CAAC,QAAQ;YAClC,GAAGL,iBAAU,CAACM,WAAW,CAACd,aAAa;YACvC,GAAGQ,iBAAU,CAACO,YAAY,CAACT,cAAc;YACzC,GAAGE,iBAAU,CAACC,WAAW,CAACF,aAAa;YACvCS,KAAKjB,mBAAmBM,SAAS;YACjCY,OAAOlB,mBAAmBM,SAAS;YACnCa,QAAQnB,mBAAmBM,SAAS;YACpCc,MAAMpB,mBAAmBM,SAAS;QACtC;IACJ;AACJ;AAOW,MAAMP,0BAA0B,CAAC,EAAEsB,gBAAgB,KAAK,EAAEC,WAAWC,yBAAc,CAACD,QAAQ,EAAEE,iBAAiB,EAAEC,QAAQF,yBAAc,CAACE,KAAK,EAAE,GAAGF,yBAAc,GAAI,CAAA;QACvK,UAAU;YACNG,cAAcL,gBAAgBM,YAAY;QAC9C;QACA,kBAAkB;YACdD,cAAcL,gBAAgBM,YAAY;QAC9C;QACA,GAAGC,IAAAA,gEAA+B,EAACvB,sBAAsB;YACrDG,cAAcqB,kBAAM,CAACC,iBAAiB;YACtCvB,eAAesB,kBAAM,CAACE,kBAAkB;YACxC,wDAAwD;YACxD9B,cAAc;YACd,GAAGwB,KAAK;QACZ,IAAI;YACAH;YACAE;QACJ,EAAE;IACN,CAAA"}
|
@@ -67,12 +67,11 @@ function removeFocusVisibleClass(el) {
|
|
67
67
|
el.removeAttribute(_constants.FOCUS_VISIBLE_ATTR);
|
68
68
|
}
|
69
69
|
function alreadyInScope(el) {
|
70
|
-
var _el;
|
71
70
|
if (!el) {
|
72
71
|
return false;
|
73
72
|
}
|
74
73
|
if (el.focusVisible) {
|
75
74
|
return true;
|
76
75
|
}
|
77
|
-
return alreadyInScope(
|
76
|
+
return alreadyInScope(el === null || el === void 0 ? void 0 : el.parentElement);
|
78
77
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["focusVisiblePolyfill.js"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport { KEYBORG_FOCUSIN, createKeyborg, disposeKeyborg } from 'keyborg';\nimport { FOCUS_VISIBLE_ATTR } from './constants';\n/**\n * @internal\n * @param scope - Applies the ponyfill to all DOM children\n * @param targetWindow - window\n */ export function applyFocusVisiblePolyfill(scope, targetWindow) {\n if (alreadyInScope(scope)) {\n // Focus visible polyfill already applied at this scope\n return ()=>undefined;\n }\n const state = {\n current: undefined\n };\n const keyborg = createKeyborg(targetWindow);\n // When navigation mode changes remove the focus-visible selector\n keyborg.subscribe((isNavigatingWithKeyboard)=>{\n if (!isNavigatingWithKeyboard && state.current) {\n removeFocusVisibleClass(state.current);\n state.current = undefined;\n }\n });\n // Keyborg's focusin event is delegated so it's only registered once on the window\n // and contains metadata about the focus event\n const keyborgListener = (e)=>{\n if (state.current) {\n removeFocusVisibleClass(state.current);\n state.current = undefined;\n }\n if (keyborg.isNavigatingWithKeyboard() && isHTMLElement(e.target) && e.target) {\n // Griffel can't create chained global styles so use the parent element for now\n state.current = e.target;\n applyFocusVisibleClass(state.current);\n }\n };\n // Make sure that when focus leaves the scope, the focus visible class is removed\n const blurListener = (e)=>{\n if (!e.relatedTarget || isHTMLElement(e.relatedTarget) && !scope.contains(e.relatedTarget)) {\n if (state.current) {\n removeFocusVisibleClass(state.current);\n state.current = undefined;\n }\n }\n };\n scope.addEventListener(KEYBORG_FOCUSIN, keyborgListener);\n scope.addEventListener('focusout', blurListener);\n scope.focusVisible = true;\n // Return disposer\n return ()=>{\n scope.removeEventListener(KEYBORG_FOCUSIN, keyborgListener);\n scope.removeEventListener('focusout', blurListener);\n delete scope.focusVisible;\n disposeKeyborg(keyborg);\n };\n}\nfunction applyFocusVisibleClass(el) {\n el.setAttribute(FOCUS_VISIBLE_ATTR, '');\n}\nfunction removeFocusVisibleClass(el) {\n el.removeAttribute(FOCUS_VISIBLE_ATTR);\n}\nfunction alreadyInScope(el) {\n
|
1
|
+
{"version":3,"sources":["focusVisiblePolyfill.js"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport { KEYBORG_FOCUSIN, createKeyborg, disposeKeyborg } from 'keyborg';\nimport { FOCUS_VISIBLE_ATTR } from './constants';\n/**\n * @internal\n * @param scope - Applies the ponyfill to all DOM children\n * @param targetWindow - window\n */ export function applyFocusVisiblePolyfill(scope, targetWindow) {\n if (alreadyInScope(scope)) {\n // Focus visible polyfill already applied at this scope\n return ()=>undefined;\n }\n const state = {\n current: undefined\n };\n const keyborg = createKeyborg(targetWindow);\n // When navigation mode changes remove the focus-visible selector\n keyborg.subscribe((isNavigatingWithKeyboard)=>{\n if (!isNavigatingWithKeyboard && state.current) {\n removeFocusVisibleClass(state.current);\n state.current = undefined;\n }\n });\n // Keyborg's focusin event is delegated so it's only registered once on the window\n // and contains metadata about the focus event\n const keyborgListener = (e)=>{\n if (state.current) {\n removeFocusVisibleClass(state.current);\n state.current = undefined;\n }\n if (keyborg.isNavigatingWithKeyboard() && isHTMLElement(e.target) && e.target) {\n // Griffel can't create chained global styles so use the parent element for now\n state.current = e.target;\n applyFocusVisibleClass(state.current);\n }\n };\n // Make sure that when focus leaves the scope, the focus visible class is removed\n const blurListener = (e)=>{\n if (!e.relatedTarget || isHTMLElement(e.relatedTarget) && !scope.contains(e.relatedTarget)) {\n if (state.current) {\n removeFocusVisibleClass(state.current);\n state.current = undefined;\n }\n }\n };\n scope.addEventListener(KEYBORG_FOCUSIN, keyborgListener);\n scope.addEventListener('focusout', blurListener);\n scope.focusVisible = true;\n // Return disposer\n return ()=>{\n scope.removeEventListener(KEYBORG_FOCUSIN, keyborgListener);\n scope.removeEventListener('focusout', blurListener);\n delete scope.focusVisible;\n disposeKeyborg(keyborg);\n };\n}\nfunction applyFocusVisibleClass(el) {\n el.setAttribute(FOCUS_VISIBLE_ATTR, '');\n}\nfunction removeFocusVisibleClass(el) {\n el.removeAttribute(FOCUS_VISIBLE_ATTR);\n}\nfunction alreadyInScope(el) {\n if (!el) {\n return false;\n }\n if (el.focusVisible) {\n return true;\n }\n return alreadyInScope(el === null || el === void 0 ? void 0 : el.parentElement);\n}\n"],"names":["applyFocusVisiblePolyfill","scope","targetWindow","alreadyInScope","undefined","state","current","keyborg","createKeyborg","subscribe","isNavigatingWithKeyboard","removeFocusVisibleClass","keyborgListener","e","isHTMLElement","target","applyFocusVisibleClass","blurListener","relatedTarget","contains","addEventListener","KEYBORG_FOCUSIN","focusVisible","removeEventListener","disposeKeyborg","el","setAttribute","FOCUS_VISIBLE_ATTR","removeAttribute","parentElement"],"mappings":";;;;+BAOoBA;;;eAAAA;;;gCAPU;yBACiC;2BAC5B;AAKxB,SAASA,0BAA0BC,KAAK,EAAEC,YAAY;IAC7D,IAAIC,eAAeF,QAAQ;QACvB,uDAAuD;QACvD,OAAO,IAAIG;IACf;IACA,MAAMC,QAAQ;QACVC,SAASF;IACb;IACA,MAAMG,UAAUC,IAAAA,sBAAa,EAACN;IAC9B,iEAAiE;IACjEK,QAAQE,SAAS,CAAC,CAACC;QACf,IAAI,CAACA,4BAA4BL,MAAMC,OAAO,EAAE;YAC5CK,wBAAwBN,MAAMC,OAAO;YACrCD,MAAMC,OAAO,GAAGF;QACpB;IACJ;IACA,kFAAkF;IAClF,8CAA8C;IAC9C,MAAMQ,kBAAkB,CAACC;QACrB,IAAIR,MAAMC,OAAO,EAAE;YACfK,wBAAwBN,MAAMC,OAAO;YACrCD,MAAMC,OAAO,GAAGF;QACpB;QACA,IAAIG,QAAQG,wBAAwB,MAAMI,IAAAA,6BAAa,EAACD,EAAEE,MAAM,KAAKF,EAAEE,MAAM,EAAE;YAC3E,+EAA+E;YAC/EV,MAAMC,OAAO,GAAGO,EAAEE,MAAM;YACxBC,uBAAuBX,MAAMC,OAAO;QACxC;IACJ;IACA,iFAAiF;IACjF,MAAMW,eAAe,CAACJ;QAClB,IAAI,CAACA,EAAEK,aAAa,IAAIJ,IAAAA,6BAAa,EAACD,EAAEK,aAAa,KAAK,CAACjB,MAAMkB,QAAQ,CAACN,EAAEK,aAAa,GAAG;YACxF,IAAIb,MAAMC,OAAO,EAAE;gBACfK,wBAAwBN,MAAMC,OAAO;gBACrCD,MAAMC,OAAO,GAAGF;YACpB;QACJ;IACJ;IACAH,MAAMmB,gBAAgB,CAACC,wBAAe,EAAET;IACxCX,MAAMmB,gBAAgB,CAAC,YAAYH;IACnChB,MAAMqB,YAAY,GAAG;IACrB,kBAAkB;IAClB,OAAO;QACHrB,MAAMsB,mBAAmB,CAACF,wBAAe,EAAET;QAC3CX,MAAMsB,mBAAmB,CAAC,YAAYN;QACtC,OAAOhB,MAAMqB,YAAY;QACzBE,IAAAA,uBAAc,EAACjB;IACnB;AACJ;AACA,SAASS,uBAAuBS,EAAE;IAC9BA,GAAGC,YAAY,CAACC,6BAAkB,EAAE;AACxC;AACA,SAAShB,wBAAwBc,EAAE;IAC/BA,GAAGG,eAAe,CAACD,6BAAkB;AACzC;AACA,SAASxB,eAAesB,EAAE;IACtB,IAAI,CAACA,IAAI;QACL,OAAO;IACX;IACA,IAAIA,GAAGH,YAAY,EAAE;QACjB,OAAO;IACX;IACA,OAAOnB,eAAesB,OAAO,QAAQA,OAAO,KAAK,IAAI,KAAK,IAAIA,GAAGI,aAAa;AAClF"}
|
@@ -16,29 +16,20 @@ const useFocusFinders = ()=>{
|
|
16
16
|
const tabster = (0, _useTabster.useTabster)();
|
17
17
|
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
18
18
|
// Narrow props for now and let need dictate additional props in the future
|
19
|
-
const findAllFocusable = _react.useCallback((container, acceptCondition)=>{
|
20
|
-
var _tabster;
|
21
|
-
return ((_tabster = tabster) === null || _tabster === void 0 ? void 0 : _tabster.focusable.findAll({
|
19
|
+
const findAllFocusable = _react.useCallback((container, acceptCondition)=>(tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findAll({
|
22
20
|
container,
|
23
21
|
acceptCondition
|
24
|
-
})) || []
|
25
|
-
}, [
|
22
|
+
})) || [], [
|
26
23
|
tabster
|
27
24
|
]);
|
28
|
-
const findFirstFocusable = _react.useCallback((container)=>{
|
29
|
-
var _tabster;
|
30
|
-
return (_tabster = tabster) === null || _tabster === void 0 ? void 0 : _tabster.focusable.findFirst({
|
25
|
+
const findFirstFocusable = _react.useCallback((container)=>tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findFirst({
|
31
26
|
container
|
32
|
-
})
|
33
|
-
}, [
|
27
|
+
}), [
|
34
28
|
tabster
|
35
29
|
]);
|
36
|
-
const findLastFocusable = _react.useCallback((container)=>{
|
37
|
-
var _tabster;
|
38
|
-
return (_tabster = tabster) === null || _tabster === void 0 ? void 0 : _tabster.focusable.findLast({
|
30
|
+
const findLastFocusable = _react.useCallback((container)=>tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findLast({
|
39
31
|
container
|
40
|
-
})
|
41
|
-
}, [
|
32
|
+
}), [
|
42
33
|
tabster
|
43
34
|
]);
|
44
35
|
const findNextFocusable = _react.useCallback((currentElement, options = {})=>{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useFocusFinders.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useTabster } from './useTabster';\n/**\n * Returns a set of helper functions that will traverse focusable elements in the context of a root DOM element\n */ export const useFocusFinders = ()=>{\n const tabster = useTabster();\n const { targetDocument } = useFluent();\n // Narrow props for now and let need dictate additional props in the future\n const findAllFocusable = React.useCallback((container, acceptCondition)=>
|
1
|
+
{"version":3,"sources":["useFocusFinders.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useTabster } from './useTabster';\n/**\n * Returns a set of helper functions that will traverse focusable elements in the context of a root DOM element\n */ export const useFocusFinders = ()=>{\n const tabster = useTabster();\n const { targetDocument } = useFluent();\n // Narrow props for now and let need dictate additional props in the future\n const findAllFocusable = React.useCallback((container, acceptCondition)=>(tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findAll({\n container,\n acceptCondition\n })) || [], [\n tabster\n ]);\n const findFirstFocusable = React.useCallback((container)=>tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findFirst({\n container\n }), [\n tabster\n ]);\n const findLastFocusable = React.useCallback((container)=>tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findLast({\n container\n }), [\n tabster\n ]);\n const findNextFocusable = React.useCallback((currentElement, options = {})=>{\n if (!tabster || !targetDocument) {\n return null;\n }\n const { container = targetDocument.body } = options;\n return tabster.focusable.findNext({\n currentElement,\n container\n });\n }, [\n tabster,\n targetDocument\n ]);\n const findPrevFocusable = React.useCallback((currentElement, options = {})=>{\n if (!tabster || !targetDocument) {\n return null;\n }\n const { container = targetDocument.body } = options;\n return tabster.focusable.findPrev({\n currentElement,\n container\n });\n }, [\n tabster,\n targetDocument\n ]);\n return {\n findAllFocusable,\n findFirstFocusable,\n findLastFocusable,\n findNextFocusable,\n findPrevFocusable\n };\n};\n"],"names":["useFocusFinders","tabster","useTabster","targetDocument","useFluent","findAllFocusable","React","useCallback","container","acceptCondition","focusable","findAll","findFirstFocusable","findFirst","findLastFocusable","findLast","findNextFocusable","currentElement","options","body","findNext","findPrevFocusable","findPrev"],"mappings":";;;;+BAKiBA;;;eAAAA;;;;iEALM;qCACyB;4BACrB;AAGhB,MAAMA,kBAAkB;IAC/B,MAAMC,UAAUC,IAAAA,sBAAU;IAC1B,MAAM,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,2EAA2E;IAC3E,MAAMC,mBAAmBC,OAAMC,WAAW,CAAC,CAACC,WAAWC,kBAAkB,AAACR,CAAAA,YAAY,QAAQA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQS,SAAS,CAACC,OAAO,CAAC;YAC9IH;YACAC;QACJ,EAAC,KAAM,EAAE,EAAE;QACXR;KACH;IACD,MAAMW,qBAAqBN,OAAMC,WAAW,CAAC,CAACC,YAAYP,YAAY,QAAQA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQS,SAAS,CAACG,SAAS,CAAC;YAChIL;QACJ,IAAI;QACJP;KACH;IACD,MAAMa,oBAAoBR,OAAMC,WAAW,CAAC,CAACC,YAAYP,YAAY,QAAQA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQS,SAAS,CAACK,QAAQ,CAAC;YAC9HP;QACJ,IAAI;QACJP;KACH;IACD,MAAMe,oBAAoBV,OAAMC,WAAW,CAAC,CAACU,gBAAgBC,UAAU,CAAC,CAAC;QACrE,IAAI,CAACjB,WAAW,CAACE,gBAAgB;YAC7B,OAAO;QACX;QACA,MAAM,EAAEK,YAAYL,eAAegB,IAAI,EAAE,GAAGD;QAC5C,OAAOjB,QAAQS,SAAS,CAACU,QAAQ,CAAC;YAC9BH;YACAT;QACJ;IACJ,GAAG;QACCP;QACAE;KACH;IACD,MAAMkB,oBAAoBf,OAAMC,WAAW,CAAC,CAACU,gBAAgBC,UAAU,CAAC,CAAC;QACrE,IAAI,CAACjB,WAAW,CAACE,gBAAgB;YAC7B,OAAO;QACX;QACA,MAAM,EAAEK,YAAYL,eAAegB,IAAI,EAAE,GAAGD;QAC5C,OAAOjB,QAAQS,SAAS,CAACY,QAAQ,CAAC;YAC9BL;YACAT;QACJ;IACJ,GAAG;QACCP;QACAE;KACH;IACD,OAAO;QACHE;QACAO;QACAE;QACAE;QACAK;IACJ;AACJ"}
|
@@ -18,8 +18,7 @@ function useFocusVisible(options = {}) {
|
|
18
18
|
var _options_targetDocument;
|
19
19
|
const targetDocument = (_options_targetDocument = options.targetDocument) !== null && _options_targetDocument !== void 0 ? _options_targetDocument : contextValue.targetDocument;
|
20
20
|
_react.useEffect(()=>{
|
21
|
-
|
22
|
-
if (((_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.defaultView) && scopeRef.current) {
|
21
|
+
if ((targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) && scopeRef.current) {
|
23
22
|
return (0, _focusVisiblePolyfill.applyFocusVisiblePolyfill)(scopeRef.current, targetDocument.defaultView);
|
24
23
|
}
|
25
24
|
}, [
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useFocusVisible.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { applyFocusVisiblePolyfill } from '../focus/focusVisiblePolyfill';\nexport function useFocusVisible(options = {}) {\n const contextValue = useFluent();\n const scopeRef = React.useRef(null);\n var _options_targetDocument;\n const targetDocument = (_options_targetDocument = options.targetDocument) !== null && _options_targetDocument !== void 0 ? _options_targetDocument : contextValue.targetDocument;\n React.useEffect(()=>{\n
|
1
|
+
{"version":3,"sources":["useFocusVisible.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { applyFocusVisiblePolyfill } from '../focus/focusVisiblePolyfill';\nexport function useFocusVisible(options = {}) {\n const contextValue = useFluent();\n const scopeRef = React.useRef(null);\n var _options_targetDocument;\n const targetDocument = (_options_targetDocument = options.targetDocument) !== null && _options_targetDocument !== void 0 ? _options_targetDocument : contextValue.targetDocument;\n React.useEffect(()=>{\n if ((targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) && scopeRef.current) {\n return applyFocusVisiblePolyfill(scopeRef.current, targetDocument.defaultView);\n }\n }, [\n scopeRef,\n targetDocument\n ]);\n return scopeRef;\n}\n"],"names":["useFocusVisible","options","contextValue","useFluent","scopeRef","React","useRef","_options_targetDocument","targetDocument","useEffect","defaultView","current","applyFocusVisiblePolyfill"],"mappings":";;;;+BAGgBA;;;eAAAA;;;;iEAHO;qCACyB;sCACN;AACnC,SAASA,gBAAgBC,UAAU,CAAC,CAAC;IACxC,MAAMC,eAAeC,IAAAA,uCAAS;IAC9B,MAAMC,WAAWC,OAAMC,MAAM,CAAC;IAC9B,IAAIC;IACJ,MAAMC,iBAAiB,AAACD,CAAAA,0BAA0BN,QAAQO,cAAc,AAAD,MAAO,QAAQD,4BAA4B,KAAK,IAAIA,0BAA0BL,aAAaM,cAAc;IAChLH,OAAMI,SAAS,CAAC;QACZ,IAAI,AAACD,CAAAA,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeE,WAAW,AAAD,KAAMN,SAASO,OAAO,EAAE;YAClH,OAAOC,IAAAA,+CAAyB,EAACR,SAASO,OAAO,EAAEH,eAAeE,WAAW;QACjF;IACJ,GAAG;QACCN;QACAI;KACH;IACD,OAAOJ;AACX"}
|
@@ -16,8 +16,7 @@ function useFocusWithin() {
|
|
16
16
|
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
17
17
|
const elementRef = _react.useRef(null);
|
18
18
|
_react.useEffect(()=>{
|
19
|
-
|
20
|
-
if (((_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.defaultView) && elementRef.current) {
|
19
|
+
if ((targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) && elementRef.current) {
|
21
20
|
return (0, _focusWithinPolyfill.applyFocusWithinPolyfill)(elementRef.current, targetDocument.defaultView);
|
22
21
|
}
|
23
22
|
}, [
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useFocusWithin.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { applyFocusWithinPolyfill } from '../focus/focusWithinPolyfill';\n/**\n * A ponyfill that allows `:focus-within` to support visibility based on keyboard/mouse navigation\n * like `:focus-visible` https://github.com/WICG/focus-visible/issues/151\n * @returns ref to the element that uses `:focus-within` styles\n */ export function useFocusWithin() {\n const { targetDocument } = useFluent();\n const elementRef = React.useRef(null);\n React.useEffect(()=>{\n
|
1
|
+
{"version":3,"sources":["useFocusWithin.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { applyFocusWithinPolyfill } from '../focus/focusWithinPolyfill';\n/**\n * A ponyfill that allows `:focus-within` to support visibility based on keyboard/mouse navigation\n * like `:focus-visible` https://github.com/WICG/focus-visible/issues/151\n * @returns ref to the element that uses `:focus-within` styles\n */ export function useFocusWithin() {\n const { targetDocument } = useFluent();\n const elementRef = React.useRef(null);\n React.useEffect(()=>{\n if ((targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) && elementRef.current) {\n return applyFocusWithinPolyfill(elementRef.current, targetDocument.defaultView);\n }\n }, [\n elementRef,\n targetDocument\n ]);\n return elementRef;\n}\n"],"names":["useFocusWithin","targetDocument","useFluent","elementRef","React","useRef","useEffect","defaultView","current","applyFocusWithinPolyfill"],"mappings":";;;;+BAOoBA;;;eAAAA;;;;iEAPG;qCACyB;qCACP;AAK9B,SAASA;IAChB,MAAM,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,aAAaC,OAAMC,MAAM,CAAC;IAChCD,OAAME,SAAS,CAAC;QACZ,IAAI,AAACL,CAAAA,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeM,WAAW,AAAD,KAAMJ,WAAWK,OAAO,EAAE;YACpH,OAAOC,IAAAA,6CAAwB,EAACN,WAAWK,OAAO,EAAEP,eAAeM,WAAW;QAClF;IACJ,GAAG;QACCJ;QACAF;KACH;IACD,OAAOE;AACX"}
|
@@ -12,17 +12,16 @@ const _tabster = require("tabster");
|
|
12
12
|
const _useTabsterAttributes = require("./useTabsterAttributes");
|
13
13
|
const _useTabster = require("./useTabster");
|
14
14
|
const useFocusableGroup = (options)=>{
|
15
|
-
var _options, _options1;
|
16
15
|
const tabster = (0, _useTabster.useTabster)();
|
17
16
|
if (tabster) {
|
18
17
|
(0, _tabster.getGroupper)(tabster);
|
19
18
|
}
|
20
19
|
return (0, _useTabsterAttributes.useTabsterAttributes)({
|
21
20
|
groupper: {
|
22
|
-
tabbability: getTabbability(
|
21
|
+
tabbability: getTabbability(options === null || options === void 0 ? void 0 : options.tabBehavior)
|
23
22
|
},
|
24
23
|
focusable: {
|
25
|
-
ignoreKeydown:
|
24
|
+
ignoreKeydown: options === null || options === void 0 ? void 0 : options.ignoreDefaultKeydown
|
26
25
|
}
|
27
26
|
});
|
28
27
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useFocusableGroup.js"],"sourcesContent":["import { Types, getGroupper } from 'tabster';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { useTabster } from './useTabster';\n/**\n * A hook that returns the necessary tabster attributes to support groupping.\n * @param options - Options to configure keyboard navigation\n */ export const useFocusableGroup = (options)=>{\n
|
1
|
+
{"version":3,"sources":["useFocusableGroup.js"],"sourcesContent":["import { Types, getGroupper } from 'tabster';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { useTabster } from './useTabster';\n/**\n * A hook that returns the necessary tabster attributes to support groupping.\n * @param options - Options to configure keyboard navigation\n */ export const useFocusableGroup = (options)=>{\n const tabster = useTabster();\n if (tabster) {\n getGroupper(tabster);\n }\n return useTabsterAttributes({\n groupper: {\n tabbability: getTabbability(options === null || options === void 0 ? void 0 : options.tabBehavior)\n },\n focusable: {\n ignoreKeydown: options === null || options === void 0 ? void 0 : options.ignoreDefaultKeydown\n }\n });\n};\nconst getTabbability = (tabBehavior)=>{\n switch(tabBehavior){\n case 'unlimited':\n return Types.GroupperTabbabilities.Unlimited;\n case 'limited':\n return Types.GroupperTabbabilities.Limited;\n case 'limited-trap-focus':\n return Types.GroupperTabbabilities.LimitedTrapFocus;\n default:\n return undefined;\n }\n};\n"],"names":["useFocusableGroup","options","tabster","useTabster","getGroupper","useTabsterAttributes","groupper","tabbability","getTabbability","tabBehavior","focusable","ignoreKeydown","ignoreDefaultKeydown","Types","GroupperTabbabilities","Unlimited","Limited","LimitedTrapFocus","undefined"],"mappings":";;;;+BAMiBA;;;eAAAA;;;yBANkB;sCACE;4BACV;AAIhB,MAAMA,oBAAoB,CAACC;IAClC,MAAMC,UAAUC,IAAAA,sBAAU;IAC1B,IAAID,SAAS;QACTE,IAAAA,oBAAW,EAACF;IAChB;IACA,OAAOG,IAAAA,0CAAoB,EAAC;QACxBC,UAAU;YACNC,aAAaC,eAAeP,YAAY,QAAQA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQQ,WAAW;QACrG;QACAC,WAAW;YACPC,eAAeV,YAAY,QAAQA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQW,oBAAoB;QACjG;IACJ;AACJ;AACA,MAAMJ,iBAAiB,CAACC;IACpB,OAAOA;QACH,KAAK;YACD,OAAOI,cAAK,CAACC,qBAAqB,CAACC,SAAS;QAChD,KAAK;YACD,OAAOF,cAAK,CAACC,qBAAqB,CAACE,OAAO;QAC9C,KAAK;YACD,OAAOH,cAAK,CAACC,qBAAqB,CAACG,gBAAgB;QACvD;YACI,OAAOC;IACf;AACJ"}
|
@@ -14,9 +14,8 @@ const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
14
14
|
const _tabster = require("tabster");
|
15
15
|
const _reactutilities = require("@fluentui/react-utilities");
|
16
16
|
const useTabster = ()=>{
|
17
|
-
var _targetDocument;
|
18
17
|
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
19
|
-
const defaultView = (
|
18
|
+
const defaultView = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) || undefined;
|
20
19
|
const tabster = _react.useMemo(()=>{
|
21
20
|
if (!defaultView) {
|
22
21
|
return null;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useTabster.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { createTabster, disposeTabster } from 'tabster';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\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 */ export const useTabster = ()=>{\n
|
1
|
+
{"version":3,"sources":["useTabster.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { createTabster, disposeTabster } from 'tabster';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\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 */ export const useTabster = ()=>{\n const { targetDocument } = useFluent();\n const defaultView = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) || undefined;\n const tabster = React.useMemo(()=>{\n if (!defaultView) {\n return null;\n }\n return createTabster(defaultView, {\n autoRoot: {},\n controlTab: false\n });\n }, [\n defaultView\n ]);\n useIsomorphicLayoutEffect(()=>{\n return ()=>{\n if (tabster) {\n disposeTabster(tabster);\n }\n };\n }, [\n tabster\n ]);\n return tabster;\n};\n"],"names":["useTabster","targetDocument","useFluent","defaultView","undefined","tabster","React","useMemo","createTabster","autoRoot","controlTab","useIsomorphicLayoutEffect","disposeTabster"],"mappings":";;;;+BAUiBA;;;eAAAA;;;;iEAVM;qCACyB;yBACF;gCACJ;AAO/B,MAAMA,aAAa;IAC1B,MAAM,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,cAAc,AAACF,CAAAA,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeE,WAAW,AAAD,KAAMC;IACpH,MAAMC,UAAUC,OAAMC,OAAO,CAAC;QAC1B,IAAI,CAACJ,aAAa;YACd,OAAO;QACX;QACA,OAAOK,IAAAA,sBAAa,EAACL,aAAa;YAC9BM,UAAU,CAAC;YACXC,YAAY;QAChB;IACJ,GAAG;QACCP;KACH;IACDQ,IAAAA,yCAAyB,EAAC;QACtB,OAAO;YACH,IAAIN,SAAS;gBACTO,IAAAA,uBAAc,EAACP;YACnB;QACJ;IACJ,GAAG;QACCA;KACH;IACD,OAAOA;AACX"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-tabster",
|
3
|
-
"version": "9.
|
3
|
+
"version": "9.13.1",
|
4
4
|
"description": "Utilities for focus management and facade for tabster",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -31,9 +31,9 @@
|
|
31
31
|
"@fluentui/scripts-tasks": "*"
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
|
-
"@fluentui/react-shared-contexts": "^9.
|
35
|
-
"@fluentui/react-theme": "^9.1.
|
36
|
-
"@fluentui/react-utilities": "^9.13.
|
34
|
+
"@fluentui/react-shared-contexts": "^9.9.1",
|
35
|
+
"@fluentui/react-theme": "^9.1.14",
|
36
|
+
"@fluentui/react-utilities": "^9.13.5",
|
37
37
|
"@griffel/react": "^1.5.14",
|
38
38
|
"@swc/helpers": "^0.5.1",
|
39
39
|
"keyborg": "^2.0.0",
|