@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,49 +1,57 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "useArrowNavigationGroup", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>useArrowNavigationGroup
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
6
|
+
exports.useArrowNavigationGroup = void 0;
|
7
|
+
const tabster_1 = /*#__PURE__*/require("tabster");
|
8
|
+
const useTabsterAttributes_1 = /*#__PURE__*/require("./useTabsterAttributes");
|
9
|
+
const useTabster_1 = /*#__PURE__*/require("./useTabster");
|
10
|
+
/**
|
11
|
+
* A hook that returns the necessary tabster attributes to support arrow key navigation
|
12
|
+
* @param options - Options to configure keyboard navigation
|
13
|
+
*/
|
14
|
+
const useArrowNavigationGroup = (options = {}) => {
|
15
|
+
const {
|
16
|
+
circular,
|
17
|
+
axis,
|
18
|
+
memorizeCurrent,
|
19
|
+
tabbable,
|
20
|
+
ignoreDefaultKeydown,
|
21
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
22
|
+
unstable_hasDefault
|
23
|
+
} = options;
|
24
|
+
const tabster = useTabster_1.useTabster();
|
25
|
+
if (tabster) {
|
26
|
+
tabster_1.getMover(tabster);
|
27
|
+
}
|
28
|
+
return useTabsterAttributes_1.useTabsterAttributes({
|
29
|
+
mover: {
|
30
|
+
cyclic: !!circular,
|
31
|
+
direction: axisToMoverDirection(axis !== null && axis !== void 0 ? axis : 'vertical'),
|
32
|
+
memorizeCurrent,
|
33
|
+
tabbable,
|
34
|
+
hasDefault: unstable_hasDefault
|
35
|
+
},
|
36
|
+
...(ignoreDefaultKeydown && {
|
37
|
+
focusable: {
|
38
|
+
ignoreKeydown: ignoreDefaultKeydown
|
39
|
+
}
|
40
|
+
})
|
41
|
+
});
|
34
42
|
};
|
43
|
+
exports.useArrowNavigationGroup = useArrowNavigationGroup;
|
35
44
|
function axisToMoverDirection(axis) {
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
48
|
-
|
45
|
+
switch (axis) {
|
46
|
+
case 'horizontal':
|
47
|
+
return tabster_1.Types.MoverDirections.Horizontal;
|
48
|
+
case 'grid':
|
49
|
+
return tabster_1.Types.MoverDirections.Grid;
|
50
|
+
case 'both':
|
51
|
+
return tabster_1.Types.MoverDirections.Both;
|
52
|
+
case 'vertical':
|
53
|
+
default:
|
54
|
+
return tabster_1.Types.MoverDirections.Vertical;
|
55
|
+
}
|
56
|
+
}
|
49
57
|
//# sourceMappingURL=useArrowNavigationGroup.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AAkCA;;;;AAIO,MAAMA,uBAAuB,GAAG,CAACC,UAA0C,EAAE,KAA+B;EACjH,MAAM;IACJC,QAAQ;IACRC,IAAI;IACJC,eAAe;IACfC,QAAQ;IACRC,oBAAoB;IACpB;IACAC;EAAmB,CACpB,GAAGN,OAAO;EACX,MAAMO,OAAO,GAAGC,uBAAU,EAAE;EAE5B,IAAID,OAAO,EAAE;IACXE,kBAAQ,CAACF,OAAO,CAAC;;EAGnB,OAAOG,2CAAoB,CAAC;IAC1BC,KAAK,EAAE;MACLC,MAAM,EAAE,CAAC,CAACX,QAAQ;MAClBY,SAAS,EAAEC,oBAAoB,CAACZ,IAAI,aAAJA,IAAI,cAAJA,IAAI,GAAI,UAAU,CAAC;MACnDC,eAAe;MACfC,QAAQ;MACRW,UAAU,EAAET;KACb;IACD,IAAID,oBAAoB,IAAI;MAC1BW,SAAS,EAAE;QACTC,aAAa,EAAEZ;;KAElB;GACF,CAAC;AACJ,CAAC;AA9BYa,+BAAuB;AAgCpC,SAASJ,oBAAoB,CAACZ,IAA4C;EACxE,QAAQA,IAAI;IACV,KAAK,YAAY;MACf,OAAOO,eAAK,CAACU,eAAe,CAACC,UAAU;IACzC,KAAK,MAAM;MACT,OAAOX,eAAK,CAACU,eAAe,CAACE,IAAI;IACnC,KAAK,MAAM;MACT,OAAOZ,eAAK,CAACU,eAAe,CAACG,IAAI;IAEnC,KAAK,UAAU;IACf;MACE,OAAOb,eAAK,CAACU,eAAe,CAACI,QAAQ;EAAC;AAE5C","names":["useArrowNavigationGroup","options","circular","axis","memorizeCurrent","tabbable","ignoreDefaultKeydown","unstable_hasDefault","tabster","useTabster_1","tabster_1","useTabsterAttributes_1","mover","cyclic","direction","axisToMoverDirection","hasDefault","focusable","ignoreKeydown","exports","MoverDirections","Horizontal","Grid","Both","Vertical"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-tabster/src/hooks/useArrowNavigationGroup.ts"],"sourcesContent":["import { Types, getMover } from 'tabster';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { useTabster } from './useTabster';\n\nexport interface UseArrowNavigationGroupOptions {\n /**\n * Focus will navigate vertically, horizontally or in both directions (grid), defaults to horizontally\n * @defaultValue vertical\n */\n axis?: 'vertical' | 'horizontal' | 'grid' | 'both';\n /**\n * Focus will cycle to the first/last elements of the group without stopping\n */\n circular?: boolean;\n /**\n * Last focused element in the group will be remembered and focused (if still\n * available) when tabbing from outside of the group\n */\n memorizeCurrent?: boolean;\n /**\n * Allow tabbing within the arrow navigation group items.\n */\n tabbable?: boolean;\n /**\n * Tabster should ignore default handling of keydown events\n */\n ignoreDefaultKeydown?: Types.FocusableProps['ignoreKeydown'];\n /**\n * The default focusable item in the group will be an element with Focusable.isDefault property.\n * Note that there is no way in \\@fluentui/react-tabster to set default focusable element,\n * and this option is currently for internal testing purposes only.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_hasDefault?: boolean;\n}\n\n/**\n * A hook that returns the necessary tabster attributes to support arrow key navigation\n * @param options - Options to configure keyboard navigation\n */\nexport const useArrowNavigationGroup = (options: UseArrowNavigationGroupOptions = {}): Types.TabsterDOMAttribute => {\n const {\n circular,\n axis,\n memorizeCurrent,\n tabbable,\n ignoreDefaultKeydown,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_hasDefault,\n } = options;\n const tabster = useTabster();\n\n if (tabster) {\n getMover(tabster);\n }\n\n return useTabsterAttributes({\n mover: {\n cyclic: !!circular,\n direction: axisToMoverDirection(axis ?? 'vertical'),\n memorizeCurrent,\n tabbable,\n hasDefault: unstable_hasDefault,\n },\n ...(ignoreDefaultKeydown && {\n focusable: {\n ignoreKeydown: ignoreDefaultKeydown,\n },\n }),\n });\n};\n\nfunction axisToMoverDirection(axis: UseArrowNavigationGroupOptions['axis']): Types.MoverDirection {\n switch (axis) {\n case 'horizontal':\n return Types.MoverDirections.Horizontal;\n case 'grid':\n return Types.MoverDirections.Grid;\n case 'both':\n return Types.MoverDirections.Both;\n\n case 'vertical':\n default:\n return Types.MoverDirections.Vertical;\n }\n}\n"]}
|
@@ -1,76 +1,62 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "useFocusFinders", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>useFocusFinders
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
targetDocument
|
66
|
-
]);
|
67
|
-
return {
|
68
|
-
findAllFocusable,
|
69
|
-
findFirstFocusable,
|
70
|
-
findLastFocusable,
|
71
|
-
findNextFocusable,
|
72
|
-
findPrevFocusable
|
73
|
-
};
|
74
|
-
}; //# sourceMappingURL=useFocusFinders.js.map
|
75
|
-
|
6
|
+
exports.useFocusFinders = void 0;
|
7
|
+
const React = /*#__PURE__*/require("react");
|
8
|
+
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
9
|
+
const useTabster_1 = /*#__PURE__*/require("./useTabster");
|
10
|
+
/**
|
11
|
+
* Returns a set of helper functions that will traverse focusable elements in the context of a root DOM element
|
12
|
+
*/
|
13
|
+
const useFocusFinders = () => {
|
14
|
+
const tabster = useTabster_1.useTabster();
|
15
|
+
const {
|
16
|
+
targetDocument
|
17
|
+
} = react_shared_contexts_1.useFluent_unstable();
|
18
|
+
// Narrow props for now and let need dictate additional props in the future
|
19
|
+
const findAllFocusable = React.useCallback((container, acceptCondition) => (tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findAll({
|
20
|
+
container,
|
21
|
+
acceptCondition
|
22
|
+
})) || [], [tabster]);
|
23
|
+
const findFirstFocusable = React.useCallback(container => tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findFirst({
|
24
|
+
container
|
25
|
+
}), [tabster]);
|
26
|
+
const findLastFocusable = React.useCallback(container => tabster === null || tabster === void 0 ? void 0 : tabster.focusable.findLast({
|
27
|
+
container
|
28
|
+
}), [tabster]);
|
29
|
+
const findNextFocusable = React.useCallback((currentElement, options = {}) => {
|
30
|
+
if (!tabster || !targetDocument) {
|
31
|
+
return null;
|
32
|
+
}
|
33
|
+
const {
|
34
|
+
container = targetDocument.body
|
35
|
+
} = options;
|
36
|
+
return tabster.focusable.findNext({
|
37
|
+
currentElement,
|
38
|
+
container
|
39
|
+
});
|
40
|
+
}, [tabster, targetDocument]);
|
41
|
+
const findPrevFocusable = React.useCallback((currentElement, options = {}) => {
|
42
|
+
if (!tabster || !targetDocument) {
|
43
|
+
return null;
|
44
|
+
}
|
45
|
+
const {
|
46
|
+
container = targetDocument.body
|
47
|
+
} = options;
|
48
|
+
return tabster.focusable.findPrev({
|
49
|
+
currentElement,
|
50
|
+
container
|
51
|
+
});
|
52
|
+
}, [tabster, targetDocument]);
|
53
|
+
return {
|
54
|
+
findAllFocusable,
|
55
|
+
findFirstFocusable,
|
56
|
+
findLastFocusable,
|
57
|
+
findNextFocusable,
|
58
|
+
findPrevFocusable
|
59
|
+
};
|
60
|
+
};
|
61
|
+
exports.useFocusFinders = useFocusFinders;
|
76
62
|
//# sourceMappingURL=useFocusFinders.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAEA;AACA;AAEA;;;AAGO,MAAMA,eAAe,GAAG,MAAK;EAClC,MAAMC,OAAO,GAAGC,uBAAU,EAAE;EAC5B,MAAM;IAAEC;EAAc,CAAE,GAAGC,0CAAS,EAAE;EAEtC;EACA,MAAMC,gBAAgB,GAAGC,KAAK,CAACC,WAAW,CACxC,CAACC,SAAsB,EAAEC,eAA8C,KACrE,QAAO,aAAPR,OAAO,uBAAPA,OAAO,CAAES,SAAS,CAACC,OAAO,CAAC;IAAEH,SAAS;IAAEC;EAAe,CAAE,CAAC,KAAI,EAAE,EAClE,CAACR,OAAO,CAAC,CACV;EAED,MAAMW,kBAAkB,GAAGN,KAAK,CAACC,WAAW,CACzCC,SAAsB,IAAKP,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAES,SAAS,CAACG,SAAS,CAAC;IAAEL;EAAS,CAAE,CAAC,EACvE,CAACP,OAAO,CAAC,CACV;EAED,MAAMa,iBAAiB,GAAGR,KAAK,CAACC,WAAW,CAAEC,SAAsB,IAAKP,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAES,SAAS,CAACK,QAAQ,CAAC;IAAEP;EAAS,CAAE,CAAC,EAAE,CAClHP,OAAO,CACR,CAAC;EAEF,MAAMe,iBAAiB,GAAGV,KAAK,CAACC,WAAW,CACzC,CAACU,cAA2B,EAAEC,UAAkE,EAAE,KAAI;IACpG,IAAI,CAACjB,OAAO,IAAI,CAACE,cAAc,EAAE;MAC/B,OAAO,IAAI;;IAGb,MAAM;MAAEK,SAAS,GAAGL,cAAc,CAACgB;IAAI,CAAE,GAAGD,OAAO;IAEnD,OAAOjB,OAAO,CAACS,SAAS,CAACU,QAAQ,CAAC;MAAEH,cAAc;MAAET;IAAS,CAAE,CAAC;EAClE,CAAC,EACD,CAACP,OAAO,EAAEE,cAAc,CAAC,CAC1B;EAED,MAAMkB,iBAAiB,GAAGf,KAAK,CAACC,WAAW,CACzC,CAACU,cAA2B,EAAEC,UAAkE,EAAE,KAAI;IACpG,IAAI,CAACjB,OAAO,IAAI,CAACE,cAAc,EAAE;MAC/B,OAAO,IAAI;;IAGb,MAAM;MAAEK,SAAS,GAAGL,cAAc,CAACgB;IAAI,CAAE,GAAGD,OAAO;IAEnD,OAAOjB,OAAO,CAACS,SAAS,CAACY,QAAQ,CAAC;MAAEL,cAAc;MAAET;IAAS,CAAE,CAAC;EAClE,CAAC,EACD,CAACP,OAAO,EAAEE,cAAc,CAAC,CAC1B;EAED,OAAO;IACLE,gBAAgB;IAChBO,kBAAkB;IAClBE,iBAAiB;IACjBE,iBAAiB;IACjBK;GACD;AACH,CAAC;AArDYE,uBAAe","names":["useFocusFinders","tabster","useTabster_1","targetDocument","react_shared_contexts_1","findAllFocusable","React","useCallback","container","acceptCondition","focusable","findAll","findFirstFocusable","findFirst","findLastFocusable","findLast","findNextFocusable","currentElement","options","body","findNext","findPrevFocusable","findPrev","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-tabster/src/hooks/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((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"]}
|
@@ -1,27 +1,23 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "useFocusVisible", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>useFocusVisible
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
6
|
+
exports.useFocusVisible = void 0;
|
7
|
+
const React = /*#__PURE__*/require("react");
|
8
|
+
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
9
|
+
const focusVisiblePolyfill_1 = /*#__PURE__*/require("../focus/focusVisiblePolyfill");
|
13
10
|
function useFocusVisible() {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
11
|
+
const {
|
12
|
+
targetDocument
|
13
|
+
} = react_shared_contexts_1.useFluent_unstable();
|
14
|
+
const scopeRef = React.useRef(null);
|
15
|
+
React.useEffect(() => {
|
16
|
+
if ((targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) && scopeRef.current) {
|
17
|
+
return focusVisiblePolyfill_1.applyFocusVisiblePolyfill(scopeRef.current, targetDocument.defaultView);
|
18
|
+
}
|
19
|
+
}, [scopeRef, targetDocument]);
|
20
|
+
return scopeRef;
|
21
|
+
}
|
22
|
+
exports.useFocusVisible = useFocusVisible;
|
27
23
|
//# sourceMappingURL=useFocusVisible.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AAEA,SAAgBA,eAAe;EAC7B,MAAM;IAAEC;EAAc,CAAE,GAAGC,0CAAS,EAAE;EACtC,MAAMC,QAAQ,GAAGC,KAAK,CAACC,MAAM,CAAW,IAAI,CAAC;EAE7CD,KAAK,CAACE,SAAS,CAAC,MAAK;IACnB,IAAI,eAAc,aAAdL,cAAc,uBAAdA,cAAc,CAAEM,WAAW,KAAIJ,QAAQ,CAACK,OAAO,EAAE;MACnD,OAAOC,gDAAyB,CAACN,QAAQ,CAACK,OAAO,EAAEP,cAAc,CAACM,WAAW,CAAC;;EAElF,CAAC,EAAE,CAACJ,QAAQ,EAAEF,cAAc,CAAC,CAAC;EAE9B,OAAOE,QAAQ;AACjB;AAXAO","names":["useFocusVisible","targetDocument","react_shared_contexts_1","scopeRef","React","useRef","useEffect","defaultView","current","focusVisiblePolyfill_1","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-tabster/src/hooks/useFocusVisible.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { applyFocusVisiblePolyfill } from '../focus/focusVisiblePolyfill';\n\nexport function useFocusVisible<TElement extends HTMLElement = HTMLElement>() {\n const { targetDocument } = useFluent();\n const scopeRef = React.useRef<TElement>(null);\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"]}
|
@@ -1,27 +1,28 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "useFocusWithin", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>useFocusWithin
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
6
|
+
exports.useFocusWithin = void 0;
|
7
|
+
const React = /*#__PURE__*/require("react");
|
8
|
+
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
9
|
+
const focusWithinPolyfill_1 = /*#__PURE__*/require("../focus/focusWithinPolyfill");
|
10
|
+
/**
|
11
|
+
* A ponyfill that allows `:focus-within` to support visibility based on keyboard/mouse navigation
|
12
|
+
* like `:focus-visible` https://github.com/WICG/focus-visible/issues/151
|
13
|
+
* @returns ref to the element that uses `:focus-within` styles
|
14
|
+
*/
|
13
15
|
function useFocusWithin() {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
const {
|
17
|
+
targetDocument
|
18
|
+
} = react_shared_contexts_1.useFluent_unstable();
|
19
|
+
const elementRef = React.useRef(null);
|
20
|
+
React.useEffect(() => {
|
21
|
+
if ((targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) && elementRef.current) {
|
22
|
+
return focusWithinPolyfill_1.applyFocusWithinPolyfill(elementRef.current, targetDocument.defaultView);
|
23
|
+
}
|
24
|
+
}, [elementRef, targetDocument]);
|
25
|
+
return elementRef;
|
26
|
+
}
|
27
|
+
exports.useFocusWithin = useFocusWithin;
|
27
28
|
//# sourceMappingURL=useFocusWithin.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AAEA;;;;;AAKA,SAAgBA,cAAc;EAC5B,MAAM;IAAEC;EAAc,CAAE,GAAGC,0CAAS,EAAE;EACtC,MAAMC,UAAU,GAAGC,KAAK,CAACC,MAAM,CAAW,IAAI,CAAC;EAE/CD,KAAK,CAACE,SAAS,CAAC,MAAK;IACnB,IAAI,eAAc,aAAdL,cAAc,uBAAdA,cAAc,CAAEM,WAAW,KAAIJ,UAAU,CAACK,OAAO,EAAE;MACrD,OAAOC,8CAAwB,CAACN,UAAU,CAACK,OAAO,EAAEP,cAAc,CAACM,WAAW,CAAC;;EAEnF,CAAC,EAAE,CAACJ,UAAU,EAAEF,cAAc,CAAC,CAAC;EAEhC,OAAOE,UAAU;AACnB;AAXAO","names":["useFocusWithin","targetDocument","react_shared_contexts_1","elementRef","React","useRef","useEffect","defaultView","current","focusWithinPolyfill_1","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-tabster/src/hooks/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"]}
|
@@ -1,36 +1,38 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "useFocusableGroup", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>useFocusableGroup
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
exports.useFocusableGroup = void 0;
|
7
|
+
const tabster_1 = /*#__PURE__*/require("tabster");
|
8
|
+
const useTabsterAttributes_1 = /*#__PURE__*/require("./useTabsterAttributes");
|
9
|
+
const useTabster_1 = /*#__PURE__*/require("./useTabster");
|
10
|
+
/**
|
11
|
+
* A hook that returns the necessary tabster attributes to support groupping.
|
12
|
+
* @param options - Options to configure keyboard navigation
|
13
|
+
*/
|
14
|
+
const useFocusableGroup = options => {
|
15
|
+
const tabster = useTabster_1.useTabster();
|
16
|
+
if (tabster) {
|
17
|
+
tabster_1.getGroupper(tabster);
|
18
|
+
}
|
19
|
+
return useTabsterAttributes_1.useTabsterAttributes({
|
20
|
+
groupper: {
|
21
|
+
tabbability: getTabbability(options === null || options === void 0 ? void 0 : options.tabBehavior)
|
16
22
|
}
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
});
|
24
|
+
};
|
25
|
+
exports.useFocusableGroup = useFocusableGroup;
|
26
|
+
const getTabbability = tabBehavior => {
|
27
|
+
switch (tabBehavior) {
|
28
|
+
case 'unlimited':
|
29
|
+
return tabster_1.Types.GroupperTabbabilities.Unlimited;
|
30
|
+
case 'limited':
|
31
|
+
return tabster_1.Types.GroupperTabbabilities.Limited;
|
32
|
+
case 'limited-trap-focus':
|
33
|
+
return tabster_1.Types.GroupperTabbabilities.LimitedTrapFocus;
|
34
|
+
default:
|
35
|
+
return undefined;
|
36
|
+
}
|
22
37
|
};
|
23
|
-
const getTabbability = (tabBehavior)=>{
|
24
|
-
switch(tabBehavior){
|
25
|
-
case 'unlimited':
|
26
|
-
return _tabster.Types.GroupperTabbabilities.Unlimited;
|
27
|
-
case 'limited':
|
28
|
-
return _tabster.Types.GroupperTabbabilities.Limited;
|
29
|
-
case 'limited-trap-focus':
|
30
|
-
return _tabster.Types.GroupperTabbabilities.LimitedTrapFocus;
|
31
|
-
default:
|
32
|
-
return undefined;
|
33
|
-
}
|
34
|
-
}; //# sourceMappingURL=useFocusableGroup.js.map
|
35
|
-
|
36
38
|
//# sourceMappingURL=useFocusableGroup.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AASA;;;;AAIO,MAAMA,iBAAiB,GAAIC,OAAkC,IAA+B;EACjG,MAAMC,OAAO,GAAGC,uBAAU,EAAE;EAE5B,IAAID,OAAO,EAAE;IACXE,qBAAW,CAACF,OAAO,CAAC;;EAGtB,OAAOG,2CAAoB,CAAC;IAC1BC,QAAQ,EAAE;MACRC,WAAW,EAAEC,cAAc,CAACP,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEQ,WAAW;;GAEnD,CAAC;AACJ,CAAC;AAZYC,yBAAiB;AAc9B,MAAMF,cAAc,GAClBC,WAAqD,IACZ;EACzC,QAAQA,WAAW;IACjB,KAAK,WAAW;MACd,OAAOL,eAAK,CAACO,qBAAqB,CAACC,SAAS;IAC9C,KAAK,SAAS;MACZ,OAAOR,eAAK,CAACO,qBAAqB,CAACE,OAAO;IAC5C,KAAK,oBAAoB;MACvB,OAAOT,eAAK,CAACO,qBAAqB,CAACG,gBAAgB;IACrD;MACE,OAAOC,SAAS;EAAC;AAEvB,CAAC","names":["useFocusableGroup","options","tabster","useTabster_1","tabster_1","useTabsterAttributes_1","groupper","tabbability","getTabbability","tabBehavior","exports","GroupperTabbabilities","Unlimited","Limited","LimitedTrapFocus","undefined"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-tabster/src/hooks/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/**\n * A hook that returns the necessary tabster attributes to support groupping.\n * @param options - Options to configure keyboard navigation\n */\nexport const useFocusableGroup = (options?: UseFocusableGroupOptions): Types.TabsterDOMAttribute => {\n const tabster = useTabster();\n\n if (tabster) {\n getGroupper(tabster);\n }\n\n return useTabsterAttributes({\n groupper: {\n tabbability: getTabbability(options?.tabBehavior),\n },\n });\n};\n\nconst getTabbability = (\n tabBehavior?: UseFocusableGroupOptions['tabBehavior'],\n): Types.GroupperTabbability | undefined => {\n switch (tabBehavior) {\n case 'unlimited':\n return Types.GroupperTabbabilities.Unlimited;\n case 'limited':\n return Types.GroupperTabbabilities.Limited;\n case 'limited-trap-focus':\n return Types.GroupperTabbabilities.LimitedTrapFocus;\n default:\n return undefined;\n }\n};\n"]}
|
@@ -1,44 +1,45 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "useKeyboardNavAttribute", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>useKeyboardNavAttribute
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
6
|
+
exports.useKeyboardNavAttribute = void 0;
|
7
|
+
const keyborg_1 = /*#__PURE__*/require("keyborg");
|
8
|
+
const react_1 = /*#__PURE__*/require("react");
|
9
|
+
const constants_1 = /*#__PURE__*/require("../focus/constants");
|
10
|
+
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
11
|
+
/**
|
12
|
+
* Instantiates [keyborg](https://github.com/microsoft/keyborg) and adds `data-keyboard-nav`
|
13
|
+
* attribute to a referenced element to ensure keyboard navigation awareness
|
14
|
+
* synced to keyborg logic without having to cause a re-render on react tree.
|
15
|
+
*/
|
13
16
|
function useKeyboardNavAttribute() {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
]);
|
31
|
-
return ref;
|
17
|
+
const {
|
18
|
+
targetDocument
|
19
|
+
} = react_shared_contexts_1.useFluent_unstable();
|
20
|
+
const keyborg = react_1.useMemo(() => targetDocument && keyborg_1.createKeyborg(targetDocument.defaultView), [targetDocument]);
|
21
|
+
const ref = react_1.useRef(null);
|
22
|
+
react_1.useEffect(() => {
|
23
|
+
if (keyborg) {
|
24
|
+
setBooleanAttribute(ref, constants_1.KEYBOARD_NAV_ATTRIBUTE, keyborg.isNavigatingWithKeyboard());
|
25
|
+
const cb = next => {
|
26
|
+
setBooleanAttribute(ref, constants_1.KEYBOARD_NAV_ATTRIBUTE, next);
|
27
|
+
};
|
28
|
+
keyborg.subscribe(cb);
|
29
|
+
return () => keyborg.unsubscribe(cb);
|
30
|
+
}
|
31
|
+
}, [keyborg]);
|
32
|
+
return ref;
|
32
33
|
}
|
34
|
+
exports.useKeyboardNavAttribute = useKeyboardNavAttribute;
|
33
35
|
function setBooleanAttribute(elementRef, attribute, value) {
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}
|
43
|
-
|
36
|
+
if (!elementRef.current) {
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
if (value) {
|
40
|
+
elementRef.current.setAttribute(attribute, '');
|
41
|
+
} else {
|
42
|
+
elementRef.current.removeAttribute(attribute);
|
43
|
+
}
|
44
|
+
}
|
44
45
|
//# sourceMappingURL=useKeyboardNavAttribute.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAIA;;;;;AAKA,SAAgBA,uBAAuB;EACrC,MAAM;IAAEC;EAAc,CAAE,GAAGC,0CAAS,EAAE;EACtC,MAAMC,OAAO,GAAGC,eAAO,CAAC,MAAMH,cAAc,IAAII,uBAAa,CAACJ,cAAc,CAACK,WAAY,CAAC,EAAE,CAACL,cAAc,CAAC,CAAC;EAC7G,MAAMM,GAAG,GAAGH,cAAM,CAAI,IAAI,CAAC;EAC3BA,iBAAS,CAAC,MAAK;IACb,IAAID,OAAO,EAAE;MACXK,mBAAmB,CAACD,GAAG,EAAEE,kCAAsB,EAAEN,OAAO,CAACO,wBAAwB,EAAE,CAAC;MACpF,MAAMC,EAAE,GAAoBC,IAAI,IAAG;QACjCJ,mBAAmB,CAACD,GAAG,EAAEE,kCAAsB,EAAEG,IAAI,CAAC;MACxD,CAAC;MACDT,OAAO,CAACU,SAAS,CAACF,EAAE,CAAC;MACrB,OAAO,MAAMR,OAAO,CAACW,WAAW,CAACH,EAAE,CAAC;;EAExC,CAAC,EAAE,CAACR,OAAO,CAAC,CAAC;EACb,OAAOI,GAAG;AACZ;AAfAQ;AAiBA,SAASP,mBAAmB,CAACQ,UAAkC,EAAEC,SAAiB,EAAEC,KAAc;EAChG,IAAI,CAACF,UAAU,CAACG,OAAO,EAAE;IACvB;;EAEF,IAAID,KAAK,EAAE;IACTF,UAAU,CAACG,OAAO,CAACC,YAAY,CAACH,SAAS,EAAE,EAAE,CAAC;GAC/C,MAAM;IACLD,UAAU,CAACG,OAAO,CAACE,eAAe,CAACJ,SAAS,CAAC;;AAEjD","names":["useKeyboardNavAttribute","targetDocument","react_shared_contexts_1","keyborg","react_1","keyborg_1","defaultView","ref","setBooleanAttribute","constants_1","isNavigatingWithKeyboard","cb","next","subscribe","unsubscribe","exports","elementRef","attribute","value","current","setAttribute","removeAttribute"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-tabster/src/hooks/useKeyboardNavAttribute.ts"],"sourcesContent":["import { createKeyborg } from 'keyborg';\nimport { useEffect, useMemo, useRef } from 'react';\nimport { KEYBOARD_NAV_ATTRIBUTE } from '../focus/constants';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport type { KeyborgCallback } from 'keyborg';\nimport type { RefObject } from 'react';\n\n/**\n * Instantiates [keyborg](https://github.com/microsoft/keyborg) and adds `data-keyboard-nav`\n * attribute to a referenced element to ensure keyboard navigation awareness\n * synced to keyborg logic without having to cause a re-render on react tree.\n */\nexport function useKeyboardNavAttribute<E extends HTMLElement>() {\n const { targetDocument } = useFluent();\n const keyborg = useMemo(() => targetDocument && createKeyborg(targetDocument.defaultView!), [targetDocument]);\n const ref = useRef<E>(null);\n useEffect(() => {\n if (keyborg) {\n setBooleanAttribute(ref, KEYBOARD_NAV_ATTRIBUTE, keyborg.isNavigatingWithKeyboard());\n const cb: KeyborgCallback = next => {\n setBooleanAttribute(ref, KEYBOARD_NAV_ATTRIBUTE, next);\n };\n keyborg.subscribe(cb);\n return () => keyborg.unsubscribe(cb);\n }\n }, [keyborg]);\n return ref;\n}\n\nfunction setBooleanAttribute(elementRef: RefObject<HTMLElement>, attribute: string, value: boolean) {\n if (!elementRef.current) {\n return;\n }\n if (value) {\n elementRef.current.setAttribute(attribute, '');\n } else {\n elementRef.current.removeAttribute(attribute);\n }\n}\n"]}
|