@fluentui/react-tabster 0.0.0-nightly-20230223-2115.1 → 0.0.0-nightly-20230228-0425.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 +9 -9
- package/CHANGELOG.md +7 -7
- package/lib/focus/constants.js.map +1 -1
- package/lib/focus/createCustomFocusIndicatorStyle.js +4 -5
- package/lib/focus/createCustomFocusIndicatorStyle.js.map +1 -1
- package/lib/focus/createFocusOutlineStyle.js +17 -19
- package/lib/focus/createFocusOutlineStyle.js.map +1 -1
- package/lib/focus/focusVisiblePolyfill.js.map +1 -1
- package/lib/focus/focusWithinPolyfill.js.map +1 -1
- package/lib/focus/index.js.map +1 -1
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useArrowNavigationGroup.js +2 -3
- package/lib/hooks/useArrowNavigationGroup.js.map +1 -1
- package/lib/hooks/useFocusFinders.js +12 -20
- package/lib/hooks/useFocusFinders.js.map +1 -1
- package/lib/hooks/useFocusVisible.js.map +1 -1
- package/lib/hooks/useFocusWithin.js.map +1 -1
- package/lib/hooks/useFocusableGroup.js.map +1 -1
- package/lib/hooks/useKeyboardNavAttribute.js.map +1 -1
- package/lib/hooks/useModalAttributes.js +1 -2
- package/lib/hooks/useModalAttributes.js.map +1 -1
- package/lib/hooks/useTabster.js.map +1 -1
- package/lib/hooks/useTabsterAttributes.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/focus/constants.js +17 -23
- package/lib-commonjs/focus/constants.js.map +1 -1
- package/lib-commonjs/focus/createCustomFocusIndicatorStyle.js +31 -24
- package/lib-commonjs/focus/createCustomFocusIndicatorStyle.js.map +1 -1
- package/lib-commonjs/focus/createFocusOutlineStyle.js +57 -45
- package/lib-commonjs/focus/createFocusOutlineStyle.js.map +1 -1
- package/lib-commonjs/focus/focusVisiblePolyfill.js +71 -68
- package/lib-commonjs/focus/focusVisiblePolyfill.js.map +1 -1
- package/lib-commonjs/focus/focusWithinPolyfill.js +47 -44
- package/lib-commonjs/focus/focusWithinPolyfill.js.map +1 -1
- package/lib-commonjs/focus/index.js +7 -8
- package/lib-commonjs/focus/index.js.map +1 -1
- package/lib-commonjs/hooks/index.js +11 -12
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useArrowNavigationGroup.js +51 -43
- package/lib-commonjs/hooks/useArrowNavigationGroup.js.map +1 -1
- package/lib-commonjs/hooks/useFocusFinders.js +58 -72
- package/lib-commonjs/hooks/useFocusFinders.js.map +1 -1
- package/lib-commonjs/hooks/useFocusVisible.js +18 -22
- package/lib-commonjs/hooks/useFocusVisible.js.map +1 -1
- package/lib-commonjs/hooks/useFocusWithin.js +23 -22
- package/lib-commonjs/hooks/useFocusWithin.js.map +1 -1
- package/lib-commonjs/hooks/useFocusableGroup.js +32 -30
- package/lib-commonjs/hooks/useFocusableGroup.js.map +1 -1
- package/lib-commonjs/hooks/useKeyboardNavAttribute.js +38 -37
- package/lib-commonjs/hooks/useKeyboardNavAttribute.js.map +1 -1
- package/lib-commonjs/hooks/useModalAttributes.js +44 -36
- package/lib-commonjs/hooks/useModalAttributes.js.map +1 -1
- package/lib-commonjs/hooks/useTabster.js +38 -36
- package/lib-commonjs/hooks/useTabster.js.map +1 -1
- package/lib-commonjs/hooks/useTabsterAttributes.js +16 -14
- package/lib-commonjs/hooks/useTabsterAttributes.js.map +1 -1
- package/lib-commonjs/index.js +73 -25
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +6 -6
- package/.swcrc +0 -33
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAaA,8BAAsB,GAAG,mBAA4B;AACrDA,6BAAqB,GAAG,YAAYA,8BAAsB,IAAa;AAEpF;;;AAGaA,0BAAkB,GAAG,wBAAwB;AAE1D;;;AAGaA,yBAAiB,GAAG,uBAAuB;AAC3CA,sBAAc,GAAG;EAC5BC,KAAK,EAAE,EAAE;EACTC,QAAQ,EAAE;CACF","names":["exports","style","selector"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-tabster/src/focus/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"]}
|
@@ -1,28 +1,35 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "createCustomFocusIndicatorStyle", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>createCustomFocusIndicatorStyle
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
26
|
-
|
27
|
-
|
6
|
+
exports.createCustomFocusIndicatorStyle = void 0;
|
7
|
+
const constants_1 = /*#__PURE__*/require("./constants");
|
8
|
+
/**
|
9
|
+
* Creates a style for @see makeStyles that includes the necessary selectors for focus.
|
10
|
+
* Should be used only when @see createFocusOutlineStyle does not fit requirements
|
11
|
+
*
|
12
|
+
* @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyles
|
13
|
+
* @param options - Configure the style of the focus outline
|
14
|
+
*/
|
15
|
+
function createCustomFocusIndicatorStyle(style, {
|
16
|
+
selector = constants_1.defaultOptions.selector,
|
17
|
+
enableOutline = false
|
18
|
+
} = constants_1.defaultOptions) {
|
19
|
+
return {
|
20
|
+
':focus': {
|
21
|
+
outlineStyle: enableOutline ? undefined : 'none'
|
22
|
+
},
|
23
|
+
':focus-visible': {
|
24
|
+
outlineStyle: enableOutline ? undefined : 'none'
|
25
|
+
},
|
26
|
+
...(selector === 'focus' && {
|
27
|
+
[`&[${constants_1.FOCUS_VISIBLE_ATTR}]`]: style
|
28
|
+
}),
|
29
|
+
...(selector === 'focus-within' && {
|
30
|
+
[`&[${constants_1.FOCUS_WITHIN_ATTR}]:${selector}`]: style
|
31
|
+
})
|
32
|
+
};
|
33
|
+
}
|
34
|
+
exports.createCustomFocusIndicatorStyle = createCustomFocusIndicatorStyle;
|
28
35
|
//# sourceMappingURL=createCustomFocusIndicatorStyle.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAiBA;;;;;;;AAOA,SAAgBA,+BAA+B,CAC7CC,KAAa,EACb;EACEC,QAAQ,GAAGC,0BAAc,CAACD,QAAQ;EAClCE,aAAa,GAAG;AAAK,IACqBD,0BAAc;EAE1D,OAAO;IACL,QAAQ,EAAE;MACRE,YAAY,EAAED,aAAa,GAAGE,SAAS,GAAG;KAC3C;IACD,gBAAgB,EAAE;MAChBD,YAAY,EAAED,aAAa,GAAGE,SAAS,GAAG;KAC3C;IAED,IAAIJ,QAAQ,KAAK,OAAO,IAAI;MAC1B,CAAC,KAAKC,8BAAkB,GAAG,GAAGF;KAC/B,CAAC;IACF,IAAIC,QAAQ,KAAK,cAAc,IAAI;MACjC,CAAC,KAAKC,6BAAiB,KAAKD,QAAQ,EAAE,GAAGD;KAC1C;GACF;AACH;AAtBAM","names":["createCustomFocusIndicatorStyle","style","selector","constants_1","enableOutline","outlineStyle","undefined","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-tabster/src/focus/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 selector?: 'focus' | 'focus-within';\n /**\n * Enables the browser default outline style\n * @default false\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 = defaultOptions.selector,\n enableOutline = false,\n }: CreateCustomFocusIndicatorStyleOptions = defaultOptions,\n): TStyle extends GriffelStyle ? GriffelStyle : GriffelResetStyle {\n return {\n ':focus': {\n outlineStyle: enableOutline ? undefined : 'none',\n },\n ':focus-visible': {\n outlineStyle: enableOutline ? undefined : 'none',\n },\n\n ...(selector === 'focus' && {\n [`&[${FOCUS_VISIBLE_ATTR}]`]: style,\n }),\n ...(selector === 'focus-within' && {\n [`&[${FOCUS_WITHIN_ATTR}]:${selector}`]: style,\n }),\n };\n}\n"]}
|
@@ -1,56 +1,68 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "createFocusOutlineStyle", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>createFocusOutlineStyle
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
6
|
+
exports.createFocusOutlineStyle = void 0;
|
7
|
+
const react_theme_1 = /*#__PURE__*/require("@fluentui/react-theme");
|
8
|
+
const react_1 = /*#__PURE__*/require("@griffel/react");
|
9
|
+
const createCustomFocusIndicatorStyle_1 = /*#__PURE__*/require("./createCustomFocusIndicatorStyle");
|
10
|
+
const constants_1 = /*#__PURE__*/require("./constants");
|
13
11
|
/**
|
14
12
|
* NOTE: the element with the focus outline needs to have `position: relative` so that the
|
15
13
|
* pseudo element can be properly positioned.
|
16
14
|
*
|
17
15
|
* @param options - Configures the style of the focus outline
|
18
16
|
* @returns focus outline styles object
|
19
|
-
*/
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
17
|
+
*/
|
18
|
+
const getFocusOutlineStyles = options => {
|
19
|
+
var _a, _b, _c, _d;
|
20
|
+
const {
|
21
|
+
outlineRadius,
|
22
|
+
outlineColor,
|
23
|
+
outlineOffset,
|
24
|
+
outlineWidth
|
25
|
+
} = options;
|
26
|
+
const outlineOffsetTop = ((_a = outlineOffset) === null || _a === void 0 ? void 0 : _a.top) || outlineOffset;
|
27
|
+
const outlineOffsetBottom = ((_b = outlineOffset) === null || _b === void 0 ? void 0 : _b.bottom) || outlineOffset;
|
28
|
+
const outlineOffsetLeft = ((_c = outlineOffset) === null || _c === void 0 ? void 0 : _c.left) || outlineOffset;
|
29
|
+
const outlineOffsetRight = ((_d = outlineOffset) === null || _d === void 0 ? void 0 : _d.right) || outlineOffset;
|
30
|
+
return {
|
31
|
+
...react_1.shorthands.borderColor('transparent'),
|
32
|
+
'::after': {
|
33
|
+
content: '""',
|
34
|
+
position: 'absolute',
|
35
|
+
pointerEvents: 'none',
|
36
|
+
zIndex: 1,
|
37
|
+
...react_1.shorthands.borderStyle('solid'),
|
38
|
+
...react_1.shorthands.borderWidth(outlineWidth),
|
39
|
+
...react_1.shorthands.borderRadius(outlineRadius),
|
40
|
+
...react_1.shorthands.borderColor(outlineColor),
|
41
|
+
top: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetTop})`,
|
42
|
+
bottom: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetBottom})`,
|
43
|
+
left: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetLeft})`,
|
44
|
+
right: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetRight})`
|
45
|
+
}
|
46
|
+
};
|
42
47
|
};
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
48
|
+
/**
|
49
|
+
* NOTE: The element with the focus outline needs to have `position: relative` so that the
|
50
|
+
* pseudo element can be properly positioned.
|
51
|
+
*
|
52
|
+
* @param options - Configure the style of the focus outline
|
53
|
+
* @returns focus outline styles object for @see makeStyles
|
54
|
+
*/
|
55
|
+
const createFocusOutlineStyle = ({
|
56
|
+
selector = constants_1.defaultOptions.selector,
|
57
|
+
style = constants_1.defaultOptions.style
|
58
|
+
} = constants_1.defaultOptions) => createCustomFocusIndicatorStyle_1.createCustomFocusIndicatorStyle(getFocusOutlineStyles({
|
59
|
+
outlineColor: react_theme_1.tokens.colorStrokeFocus2,
|
60
|
+
outlineRadius: react_theme_1.tokens.borderRadiusMedium,
|
61
|
+
// FIXME: tokens.strokeWidthThick causes some weird bugs
|
62
|
+
outlineWidth: '2px',
|
63
|
+
...style
|
64
|
+
}), {
|
65
|
+
selector
|
66
|
+
});
|
67
|
+
exports.createFocusOutlineStyle = createFocusOutlineStyle;
|
56
68
|
//# sourceMappingURL=createFocusOutlineStyle.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAEA;AAIA;AAiBA;;;;;;;AAOA,MAAMA,qBAAqB,GAAIC,OAAiC,IAAkB;;EAChF,MAAM;IAAEC,aAAa;IAAEC,YAAY;IAAEC,aAAa;IAAEC;EAAY,CAAE,GAAGJ,OAAO;EAE5E,MAAMK,gBAAgB,GAAG,OAACF,aAAoC,0CAAEG,GAAG,KAAIH,aAAa;EACpF,MAAMI,mBAAmB,GAAG,OAACJ,aAAoC,0CAAEK,MAAM,KAAIL,aAAa;EAC1F,MAAMM,iBAAiB,GAAG,OAACN,aAAoC,0CAAEO,IAAI,KAAIP,aAAa;EACtF,MAAMQ,kBAAkB,GAAG,OAACR,aAAoC,0CAAES,KAAK,KAAIT,aAAa;EAExF,OAAO;IACL,GAAGU,kBAAU,CAACC,WAAW,CAAC,aAAa,CAAC;IACxC,SAAS,EAAE;MACTC,OAAO,EAAE,IAAI;MACbC,QAAQ,EAAE,UAAU;MACpBC,aAAa,EAAE,MAAM;MACrBC,MAAM,EAAE,CAAC;MAET,GAAGL,kBAAU,CAACM,WAAW,CAAC,OAAO,CAAC;MAClC,GAAGN,kBAAU,CAACO,WAAW,CAAChB,YAAY,CAAC;MACvC,GAAGS,kBAAU,CAACQ,YAAY,CAACpB,aAAa,CAAC;MACzC,GAAGY,kBAAU,CAACC,WAAW,CAACZ,YAAY,CAAC;MAEvCI,GAAG,EAAE,CAACH,aAAa,GAAG,IAAIC,YAAY,EAAE,GAAG,cAAcA,YAAY,MAAMC,gBAAgB,GAAG;MAC9FG,MAAM,EAAE,CAACL,aAAa,GAAG,IAAIC,YAAY,EAAE,GAAG,cAAcA,YAAY,MAAMG,mBAAmB,GAAG;MACpGG,IAAI,EAAE,CAACP,aAAa,GAAG,IAAIC,YAAY,EAAE,GAAG,cAAcA,YAAY,MAAMK,iBAAiB,GAAG;MAChGG,KAAK,EAAE,CAACT,aAAa,GAAG,IAAIC,YAAY,EAAE,GAAG,cAAcA,YAAY,MAAMO,kBAAkB;;GAElG;AACH,CAAC;AAED;;;;;;;AAOO,MAAMW,uBAAuB,GAAG,CAAC;EACtCC,QAAQ,GAAGC,0BAAc,CAACD,QAAQ;EAClCE,KAAK,GAAGD,0BAAc,CAACC;AAAK,IACMD,0BAAc,KAChDE,iEAA+B,CAC7B3B,qBAAqB,CAAC;EACpBG,YAAY,EAAEyB,oBAAM,CAACC,iBAAiB;EACtC3B,aAAa,EAAE0B,oBAAM,CAACE,kBAAkB;EACxC;EACAzB,YAAY,EAAE,KAAK;EACnB,GAAGqB;CACJ,CAAC,EACF;EAAEF;AAAQ,CAAE,CACb;AAbUO,+BAAuB","names":["getFocusOutlineStyles","options","outlineRadius","outlineColor","outlineOffset","outlineWidth","outlineOffsetTop","top","outlineOffsetBottom","bottom","outlineOffsetLeft","left","outlineOffsetRight","right","react_1","borderColor","content","position","pointerEvents","zIndex","borderStyle","borderWidth","borderRadius","createFocusOutlineStyle","selector","constants_1","style","createCustomFocusIndicatorStyle_1","react_theme_1","colorStrokeFocus2","borderRadiusMedium","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-tabster/src/focus/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 CreateCustomFocusIndicatorStyleOptions {\n style?: Partial<FocusOutlineStyleOptions>;\n}\n\n/**\n * NOTE: the element with the focus outline needs to have `position: relative` so that the\n * pseudo element can be properly positioned.\n *\n * @param options - Configures the style of the focus outline\n * @returns focus outline styles object\n */\nconst getFocusOutlineStyles = (options: FocusOutlineStyleOptions): GriffelStyle => {\n const { outlineRadius, outlineColor, outlineOffset, outlineWidth } = options;\n\n const outlineOffsetTop = (outlineOffset as FocusOutlineOffset)?.top || outlineOffset;\n const outlineOffsetBottom = (outlineOffset as FocusOutlineOffset)?.bottom || outlineOffset;\n const outlineOffsetLeft = (outlineOffset as FocusOutlineOffset)?.left || outlineOffset;\n const outlineOffsetRight = (outlineOffset as FocusOutlineOffset)?.right || outlineOffset;\n\n return {\n ...shorthands.borderColor('transparent'),\n '::after': {\n content: '\"\"',\n position: 'absolute',\n pointerEvents: 'none',\n zIndex: 1,\n\n ...shorthands.borderStyle('solid'),\n ...shorthands.borderWidth(outlineWidth),\n ...shorthands.borderRadius(outlineRadius),\n ...shorthands.borderColor(outlineColor),\n\n top: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetTop})`,\n bottom: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetBottom})`,\n left: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetLeft})`,\n right: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetRight})`,\n },\n };\n};\n\n/**\n * NOTE: The element with the focus outline needs to have `position: relative` so that the\n * pseudo element can be properly positioned.\n *\n * @param options - Configure the style of the focus outline\n * @returns focus outline styles object for @see makeStyles\n */\nexport const createFocusOutlineStyle = ({\n selector = defaultOptions.selector,\n style = defaultOptions.style,\n}: CreateFocusOutlineStyleOptions = defaultOptions): GriffelStyle =>\n createCustomFocusIndicatorStyle(\n getFocusOutlineStyles({\n outlineColor: tokens.colorStrokeFocus2,\n outlineRadius: tokens.borderRadiusMedium,\n // FIXME: tokens.strokeWidthThick causes some weird bugs\n outlineWidth: '2px',\n ...style,\n }),\n { selector },\n );\n"]}
|
@@ -1,82 +1,85 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "applyFocusVisiblePolyfill", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>applyFocusVisiblePolyfill
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
6
|
+
exports.applyFocusVisiblePolyfill = void 0;
|
7
|
+
const keyborg_1 = /*#__PURE__*/require("keyborg");
|
8
|
+
const constants_1 = /*#__PURE__*/require("./constants");
|
9
|
+
/**
|
10
|
+
* @internal
|
11
|
+
* @param scope - Applies the ponyfill to all DOM children
|
12
|
+
* @param win - window
|
13
|
+
*/
|
11
14
|
function applyFocusVisiblePolyfill(scope, win) {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
if (alreadyInScope(scope)) {
|
16
|
+
// Focus visible polyfill already applied at this scope
|
17
|
+
return () => undefined;
|
18
|
+
}
|
19
|
+
const state = {
|
20
|
+
current: undefined
|
21
|
+
};
|
22
|
+
const keyborg = keyborg_1.createKeyborg(win);
|
23
|
+
// When navigation mode changes remove the focus-visible selector
|
24
|
+
keyborg.subscribe(isNavigatingWithKeyboard => {
|
25
|
+
if (!isNavigatingWithKeyboard && state.current) {
|
26
|
+
removeFocusVisibleClass(state.current);
|
27
|
+
state.current = undefined;
|
28
|
+
}
|
29
|
+
});
|
30
|
+
// Keyborg's focusin event is delegated so it's only registered once on the window
|
31
|
+
// and contains metadata about the focus event
|
32
|
+
const keyborgListener = e => {
|
33
|
+
if (state.current) {
|
34
|
+
removeFocusVisibleClass(state.current);
|
35
|
+
state.current = undefined;
|
36
|
+
}
|
37
|
+
if (keyborg.isNavigatingWithKeyboard() && isHTMLElement(e.target) && e.target) {
|
38
|
+
// Griffel can't create chained global styles so use the parent element for now
|
39
|
+
state.current = e.target;
|
40
|
+
applyFocusVisibleClass(state.current);
|
41
|
+
}
|
42
|
+
};
|
43
|
+
// Make sure that when focus leaves the scope, the focus visible class is removed
|
44
|
+
const blurListener = e => {
|
45
|
+
if (!e.relatedTarget || isHTMLElement(e.relatedTarget) && !scope.contains(e.relatedTarget)) {
|
46
|
+
if (state.current) {
|
47
|
+
removeFocusVisibleClass(state.current);
|
48
|
+
state.current = undefined;
|
49
|
+
}
|
15
50
|
}
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
// Keyborg's focusin event is delegated so it's only registered once on the window
|
28
|
-
// and contains metadata about the focus event
|
29
|
-
const keyborgListener = (e)=>{
|
30
|
-
if (state.current) {
|
31
|
-
removeFocusVisibleClass(state.current);
|
32
|
-
state.current = undefined;
|
33
|
-
}
|
34
|
-
if (keyborg.isNavigatingWithKeyboard() && isHTMLElement(e.target) && e.target) {
|
35
|
-
// Griffel can't create chained global styles so use the parent element for now
|
36
|
-
state.current = e.target;
|
37
|
-
applyFocusVisibleClass(state.current);
|
38
|
-
}
|
39
|
-
};
|
40
|
-
// Make sure that when focus leaves the scope, the focus visible class is removed
|
41
|
-
const blurListener = (e)=>{
|
42
|
-
if (!e.relatedTarget || isHTMLElement(e.relatedTarget) && !scope.contains(e.relatedTarget)) {
|
43
|
-
if (state.current) {
|
44
|
-
removeFocusVisibleClass(state.current);
|
45
|
-
state.current = undefined;
|
46
|
-
}
|
47
|
-
}
|
48
|
-
};
|
49
|
-
scope.addEventListener(_keyborg.KEYBORG_FOCUSIN, keyborgListener);
|
50
|
-
scope.addEventListener('focusout', blurListener);
|
51
|
-
scope.focusVisible = true;
|
52
|
-
// Return disposer
|
53
|
-
return ()=>{
|
54
|
-
scope.removeEventListener(_keyborg.KEYBORG_FOCUSIN, keyborgListener);
|
55
|
-
scope.removeEventListener('focusout', blurListener);
|
56
|
-
delete scope.focusVisible;
|
57
|
-
(0, _keyborg.disposeKeyborg)(keyborg);
|
58
|
-
};
|
51
|
+
};
|
52
|
+
scope.addEventListener(keyborg_1.KEYBORG_FOCUSIN, keyborgListener);
|
53
|
+
scope.addEventListener('focusout', blurListener);
|
54
|
+
scope.focusVisible = true;
|
55
|
+
// Return disposer
|
56
|
+
return () => {
|
57
|
+
scope.removeEventListener(keyborg_1.KEYBORG_FOCUSIN, keyborgListener);
|
58
|
+
scope.removeEventListener('focusout', blurListener);
|
59
|
+
delete scope.focusVisible;
|
60
|
+
keyborg_1.disposeKeyborg(keyborg);
|
61
|
+
};
|
59
62
|
}
|
63
|
+
exports.applyFocusVisiblePolyfill = applyFocusVisiblePolyfill;
|
60
64
|
function applyFocusVisibleClass(el) {
|
61
|
-
|
65
|
+
el.setAttribute(constants_1.FOCUS_VISIBLE_ATTR, '');
|
62
66
|
}
|
63
67
|
function removeFocusVisibleClass(el) {
|
64
|
-
|
68
|
+
el.removeAttribute(constants_1.FOCUS_VISIBLE_ATTR);
|
65
69
|
}
|
66
70
|
function isHTMLElement(target) {
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
+
if (!target) {
|
72
|
+
return false;
|
73
|
+
}
|
74
|
+
return Boolean(target && typeof target === 'object' && 'classList' in target && 'contains' in target);
|
71
75
|
}
|
72
76
|
function alreadyInScope(el) {
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
}
|
81
|
-
|
77
|
+
if (!el) {
|
78
|
+
return false;
|
79
|
+
}
|
80
|
+
if (el.focusVisible) {
|
81
|
+
return true;
|
82
|
+
}
|
83
|
+
return alreadyInScope(el === null || el === void 0 ? void 0 : el.parentElement);
|
84
|
+
}
|
82
85
|
//# sourceMappingURL=focusVisiblePolyfill.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAoBA;;;;;AAKA,SAAgBA,yBAAyB,CAACC,KAAkB,EAAEC,GAAW;EACvE,IAAIC,cAAc,CAACF,KAAK,CAAC,EAAE;IACzB;IACA,OAAO,MAAMG,SAAS;;EAGxB,MAAMC,KAAK,GAAsB;IAC/BC,OAAO,EAAEF;GACV;EAED,MAAMG,OAAO,GAAGC,uBAAa,CAACN,GAAG,CAAC;EAElC;EACAK,OAAO,CAACE,SAAS,CAACC,wBAAwB,IAAG;IAC3C,IAAI,CAACA,wBAAwB,IAAIL,KAAK,CAACC,OAAO,EAAE;MAC9CK,uBAAuB,CAACN,KAAK,CAACC,OAAO,CAAC;MACtCD,KAAK,CAACC,OAAO,GAAGF,SAAS;;EAE7B,CAAC,CAAC;EAEF;EACA;EACA,MAAMQ,eAAe,GAAIC,CAAsB,IAAI;IACjD,IAAIR,KAAK,CAACC,OAAO,EAAE;MACjBK,uBAAuB,CAACN,KAAK,CAACC,OAAO,CAAC;MACtCD,KAAK,CAACC,OAAO,GAAGF,SAAS;;IAG3B,IAAIG,OAAO,CAACG,wBAAwB,EAAE,IAAII,aAAa,CAACD,CAAC,CAACE,MAAM,CAAC,IAAIF,CAAC,CAACE,MAAM,EAAE;MAC7E;MACAV,KAAK,CAACC,OAAO,GAAGO,CAAC,CAACE,MAAM;MACxBC,sBAAsB,CAACX,KAAK,CAACC,OAAO,CAAC;;EAEzC,CAAC;EAED;EACA,MAAMW,YAAY,GAAIJ,CAAa,IAAI;IACrC,IAAI,CAACA,CAAC,CAACK,aAAa,IAAKJ,aAAa,CAACD,CAAC,CAACK,aAAa,CAAC,IAAI,CAACjB,KAAK,CAACkB,QAAQ,CAACN,CAAC,CAACK,aAAa,CAAE,EAAE;MAC5F,IAAIb,KAAK,CAACC,OAAO,EAAE;QACjBK,uBAAuB,CAACN,KAAK,CAACC,OAAO,CAAC;QACtCD,KAAK,CAACC,OAAO,GAAGF,SAAS;;;EAG/B,CAAC;EAEDH,KAAK,CAACmB,gBAAgB,CAACZ,yBAAe,EAAEI,eAAmC,CAAC;EAC5EX,KAAK,CAACmB,gBAAgB,CAAC,UAAU,EAAEH,YAAY,CAAC;EAC/ChB,KAA0C,CAACoB,YAAY,GAAG,IAAI;EAE/D;EACA,OAAO,MAAK;IACVpB,KAAK,CAACqB,mBAAmB,CAACd,yBAAe,EAAEI,eAAmC,CAAC;IAC/EX,KAAK,CAACqB,mBAAmB,CAAC,UAAU,EAAEL,YAAY,CAAC;IACnD,OAAQhB,KAA0C,CAACoB,YAAY;IAC/Db,wBAAc,CAACD,OAAO,CAAC;EACzB,CAAC;AACH;AAxDAgB;AA0DA,SAASP,sBAAsB,CAACQ,EAAe;EAC7CA,EAAE,CAACC,YAAY,CAACC,8BAAkB,EAAE,EAAE,CAAC;AACzC;AAEA,SAASf,uBAAuB,CAACa,EAAe;EAC9CA,EAAE,CAACG,eAAe,CAACD,8BAAkB,CAAC;AACxC;AAEA,SAASZ,aAAa,CAACC,MAA0B;EAC/C,IAAI,CAACA,MAAM,EAAE;IACX,OAAO,KAAK;;EAEd,OAAOa,OAAO,CAACb,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAI,WAAW,IAAIA,MAAM,IAAI,UAAU,IAAIA,MAAM,CAAC;AACvG;AAEA,SAASZ,cAAc,CAACqB,EAAkC;EACxD,IAAI,CAACA,EAAE,EAAE;IACP,OAAO,KAAK;;EAGd,IAAKA,EAAuC,CAACH,YAAY,EAAE;IACzD,OAAO,IAAI;;EAGb,OAAOlB,cAAc,CAACqB,EAAE,aAAFA,EAAE,uBAAFA,EAAE,CAAEK,aAAa,CAAC;AAC1C","names":["applyFocusVisiblePolyfill","scope","win","alreadyInScope","undefined","state","current","keyborg","keyborg_1","subscribe","isNavigatingWithKeyboard","removeFocusVisibleClass","keyborgListener","e","isHTMLElement","target","applyFocusVisibleClass","blurListener","relatedTarget","contains","addEventListener","focusVisible","removeEventListener","exports","el","setAttribute","constants_1","removeAttribute","Boolean","parentElement"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-tabster/src/focus/focusVisiblePolyfill.ts"],"sourcesContent":["import { KEYBORG_FOCUSIN, KeyborgFocusInEvent, createKeyborg, disposeKeyborg } from 'keyborg';\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 win - window\n */\nexport function applyFocusVisiblePolyfill(scope: HTMLElement, win: 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(win);\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 isHTMLElement(target: EventTarget | null): target is HTMLElement {\n if (!target) {\n return false;\n }\n return Boolean(target && typeof target === 'object' && 'classList' in target && 'contains' in target);\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"]}
|
@@ -1,55 +1,58 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "applyFocusWithinPolyfill", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>applyFocusWithinPolyfill
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
6
|
+
exports.applyFocusWithinPolyfill = void 0;
|
7
|
+
const keyborg_1 = /*#__PURE__*/require("keyborg");
|
8
|
+
const constants_1 = /*#__PURE__*/require("./constants");
|
9
|
+
/**
|
10
|
+
* A ponyfill that allows `:focus-within` to support visibility based on keyboard/mouse navigation
|
11
|
+
* like `:focus-visible` https://github.com/WICG/focus-visible/issues/151
|
12
|
+
* @returns ref to the element that uses `:focus-within` styles
|
13
|
+
*/
|
11
14
|
function applyFocusWithinPolyfill(element, win) {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
15
|
+
const keyborg = keyborg_1.createKeyborg(win);
|
16
|
+
// When navigation mode changes to mouse, remove the focus-within selector
|
17
|
+
keyborg.subscribe(isNavigatingWithKeyboard => {
|
18
|
+
if (!isNavigatingWithKeyboard) {
|
19
|
+
removeFocusWithinClass(element);
|
20
|
+
}
|
21
|
+
});
|
22
|
+
// Keyborg's focusin event is delegated so it's only registered once on the window
|
23
|
+
// and contains metadata about the focus event
|
24
|
+
const keyborgListener = e => {
|
25
|
+
if (keyborg.isNavigatingWithKeyboard() && isHTMLElement(e.target)) {
|
26
|
+
// Griffel can't create chained global styles so use the parent element for now
|
27
|
+
applyFocusWithinClass(element);
|
28
|
+
}
|
29
|
+
};
|
30
|
+
// Make sure that when focus leaves the scope, the focus within class is removed
|
31
|
+
const blurListener = e => {
|
32
|
+
if (!e.relatedTarget || isHTMLElement(e.relatedTarget) && !element.contains(e.relatedTarget)) {
|
33
|
+
removeFocusWithinClass(element);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
element.addEventListener(keyborg_1.KEYBORG_FOCUSIN, keyborgListener);
|
37
|
+
element.addEventListener('focusout', blurListener);
|
38
|
+
// Return disposer
|
39
|
+
return () => {
|
40
|
+
element.removeEventListener(keyborg_1.KEYBORG_FOCUSIN, keyborgListener);
|
41
|
+
element.removeEventListener('focusout', blurListener);
|
42
|
+
keyborg_1.disposeKeyborg(keyborg);
|
43
|
+
};
|
41
44
|
}
|
45
|
+
exports.applyFocusWithinPolyfill = applyFocusWithinPolyfill;
|
42
46
|
function applyFocusWithinClass(el) {
|
43
|
-
|
47
|
+
el.setAttribute(constants_1.FOCUS_WITHIN_ATTR, '');
|
44
48
|
}
|
45
49
|
function removeFocusWithinClass(el) {
|
46
|
-
|
50
|
+
el.removeAttribute(constants_1.FOCUS_WITHIN_ATTR);
|
47
51
|
}
|
48
52
|
function isHTMLElement(target) {
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
}
|
54
|
-
|
53
|
+
if (!target) {
|
54
|
+
return false;
|
55
|
+
}
|
56
|
+
return Boolean(target && typeof target === 'object' && 'classList' in target && 'contains' in target);
|
57
|
+
}
|
55
58
|
//# sourceMappingURL=focusWithinPolyfill.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AASA;;;;;AAKA,SAAgBA,wBAAwB,CAACC,OAAoB,EAAEC,GAAW;EACxE,MAAMC,OAAO,GAAGC,uBAAa,CAACF,GAAG,CAAC;EAElC;EACAC,OAAO,CAACE,SAAS,CAACC,wBAAwB,IAAG;IAC3C,IAAI,CAACA,wBAAwB,EAAE;MAC7BC,sBAAsB,CAACN,OAAO,CAAC;;EAEnC,CAAC,CAAC;EAEF;EACA;EACA,MAAMO,eAAe,GAAIC,CAAsB,IAAI;IACjD,IAAIN,OAAO,CAACG,wBAAwB,EAAE,IAAII,aAAa,CAACD,CAAC,CAACE,MAAM,CAAC,EAAE;MACjE;MACAC,qBAAqB,CAACX,OAAO,CAAC;;EAElC,CAAC;EAED;EACA,MAAMY,YAAY,GAAIJ,CAAa,IAAI;IACrC,IAAI,CAACA,CAAC,CAACK,aAAa,IAAKJ,aAAa,CAACD,CAAC,CAACK,aAAa,CAAC,IAAI,CAACb,OAAO,CAACc,QAAQ,CAACN,CAAC,CAACK,aAAa,CAAE,EAAE;MAC9FP,sBAAsB,CAACN,OAAO,CAAC;;EAEnC,CAAC;EAEDA,OAAO,CAACe,gBAAgB,CAACZ,yBAAe,EAAEI,eAAmC,CAAC;EAC9EP,OAAO,CAACe,gBAAgB,CAAC,UAAU,EAAEH,YAAY,CAAC;EAElD;EACA,OAAO,MAAK;IACVZ,OAAO,CAACgB,mBAAmB,CAACb,yBAAe,EAAEI,eAAmC,CAAC;IACjFP,OAAO,CAACgB,mBAAmB,CAAC,UAAU,EAAEJ,YAAY,CAAC;IACrDT,wBAAc,CAACD,OAAO,CAAC;EACzB,CAAC;AACH;AAnCAe;AAqCA,SAASN,qBAAqB,CAACO,EAAe;EAC5CA,EAAE,CAACC,YAAY,CAACC,6BAAiB,EAAE,EAAE,CAAC;AACxC;AAEA,SAASd,sBAAsB,CAACY,EAAe;EAC7CA,EAAE,CAACG,eAAe,CAACD,6BAAiB,CAAC;AACvC;AAEA,SAASX,aAAa,CAACC,MAA0B;EAC/C,IAAI,CAACA,MAAM,EAAE;IACX,OAAO,KAAK;;EAEd,OAAOY,OAAO,CAACZ,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAI,WAAW,IAAIA,MAAM,IAAI,UAAU,IAAIA,MAAM,CAAC;AACvG","names":["applyFocusWithinPolyfill","element","win","keyborg","keyborg_1","subscribe","isNavigatingWithKeyboard","removeFocusWithinClass","keyborgListener","e","isHTMLElement","target","applyFocusWithinClass","blurListener","relatedTarget","contains","addEventListener","removeEventListener","exports","el","setAttribute","constants_1","removeAttribute","Boolean"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-tabster/src/focus/focusWithinPolyfill.ts"],"sourcesContent":["import { KEYBORG_FOCUSIN, KeyborgFocusInEvent, createKeyborg, disposeKeyborg } from 'keyborg';\nimport { FOCUS_WITHIN_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\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 applyFocusWithinPolyfill(element: HTMLElement, win: Window): () => void {\n const keyborg = createKeyborg(win);\n\n // When navigation mode changes to mouse, remove the focus-within selector\n keyborg.subscribe(isNavigatingWithKeyboard => {\n if (!isNavigatingWithKeyboard) {\n removeFocusWithinClass(element);\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 (keyborg.isNavigatingWithKeyboard() && isHTMLElement(e.target)) {\n // Griffel can't create chained global styles so use the parent element for now\n applyFocusWithinClass(element);\n }\n };\n\n // Make sure that when focus leaves the scope, the focus within class is removed\n const blurListener = (e: FocusEvent) => {\n if (!e.relatedTarget || (isHTMLElement(e.relatedTarget) && !element.contains(e.relatedTarget))) {\n removeFocusWithinClass(element);\n }\n };\n\n element.addEventListener(KEYBORG_FOCUSIN, keyborgListener as ListenerOverride);\n element.addEventListener('focusout', blurListener);\n\n // Return disposer\n return () => {\n element.removeEventListener(KEYBORG_FOCUSIN, keyborgListener as ListenerOverride);\n element.removeEventListener('focusout', blurListener);\n disposeKeyborg(keyborg);\n };\n}\n\nfunction applyFocusWithinClass(el: HTMLElement) {\n el.setAttribute(FOCUS_WITHIN_ATTR, '');\n}\n\nfunction removeFocusWithinClass(el: HTMLElement) {\n el.removeAttribute(FOCUS_WITHIN_ATTR);\n}\n\nfunction isHTMLElement(target: EventTarget | null): target is HTMLElement {\n if (!target) {\n return false;\n }\n return Boolean(target && typeof target === 'object' && 'classList' in target && 'contains' in target);\n}\n"]}
|
@@ -1,12 +1,11 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
+
value: true
|
4
5
|
});
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
//# sourceMappingURL=index.js.map
|
11
|
-
|
6
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
7
|
+
tslib_1.__exportStar(require("./createCustomFocusIndicatorStyle"), exports);
|
8
|
+
tslib_1.__exportStar(require("./createFocusOutlineStyle"), exports);
|
9
|
+
tslib_1.__exportStar(require("./focusVisiblePolyfill"), exports);
|
10
|
+
tslib_1.__exportStar(require("./focusWithinPolyfill"), exports);
|
12
11
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-tabster/src/focus/index.ts"],"sourcesContent":["export * from './createCustomFocusIndicatorStyle';\nexport * from './createFocusOutlineStyle';\nexport * from './focusVisiblePolyfill';\nexport * from './focusWithinPolyfill';\n"]}
|
@@ -1,16 +1,15 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
+
value: true
|
4
5
|
});
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
//# sourceMappingURL=index.js.map
|
15
|
-
|
6
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
7
|
+
tslib_1.__exportStar(require("./useArrowNavigationGroup"), exports);
|
8
|
+
tslib_1.__exportStar(require("./useFocusableGroup"), exports);
|
9
|
+
tslib_1.__exportStar(require("./useFocusFinders"), exports);
|
10
|
+
tslib_1.__exportStar(require("./useFocusVisible"), exports);
|
11
|
+
tslib_1.__exportStar(require("./useFocusWithin"), exports);
|
12
|
+
tslib_1.__exportStar(require("./useKeyboardNavAttribute"), exports);
|
13
|
+
tslib_1.__exportStar(require("./useModalAttributes"), exports);
|
14
|
+
tslib_1.__exportStar(require("./useTabsterAttributes"), exports);
|
16
15
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-tabster/src/hooks/index.ts"],"sourcesContent":["export * from './useArrowNavigationGroup';\nexport * from './useFocusableGroup';\nexport * from './useFocusFinders';\nexport * from './useFocusVisible';\nexport * from './useFocusWithin';\nexport * from './useKeyboardNavAttribute';\nexport * from './useModalAttributes';\nexport * from './useTabsterAttributes';\n"]}
|