@fluentui/react-tabster 9.0.0-rc.9 → 9.0.0
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 +229 -1
- package/CHANGELOG.md +79 -2
- package/dist/index.d.ts +16 -3
- package/{lib → dist}/tsdoc-metadata.json +0 -0
- package/lib/focus/constants.js.map +1 -1
- package/lib/focus/createCustomFocusIndicatorStyle.js +1 -1
- package/lib/focus/createCustomFocusIndicatorStyle.js.map +1 -1
- package/lib/focus/createFocusOutlineStyle.js +1 -1
- package/lib/focus/createFocusOutlineStyle.js.map +1 -1
- package/lib/hooks/useArrowNavigationGroup.js.map +1 -1
- package/lib/hooks/useFocusFinders.js.map +1 -1
- package/lib/hooks/useFocusableGroup.js +1 -1
- package/lib/hooks/useFocusableGroup.js.map +1 -1
- package/lib/hooks/useKeyboardNavAttribute.js +4 -2
- package/lib/hooks/useKeyboardNavAttribute.js.map +1 -1
- package/lib/hooks/useModalAttributes.js +4 -2
- package/lib/hooks/useModalAttributes.js.map +1 -1
- package/lib/hooks/useTabster.js +1 -1
- package/lib/hooks/useTabster.js.map +1 -1
- package/lib/hooks/useTabsterAttributes.js +1 -0
- package/lib/hooks/useTabsterAttributes.js.map +1 -1
- package/lib-commonjs/focus/constants.js.map +1 -1
- package/lib-commonjs/focus/createCustomFocusIndicatorStyle.js +1 -1
- package/lib-commonjs/focus/createCustomFocusIndicatorStyle.js.map +1 -1
- package/lib-commonjs/focus/createFocusOutlineStyle.js +1 -1
- package/lib-commonjs/focus/createFocusOutlineStyle.js.map +1 -1
- package/lib-commonjs/hooks/useArrowNavigationGroup.js.map +1 -1
- package/lib-commonjs/hooks/useFocusFinders.js.map +1 -1
- package/lib-commonjs/hooks/useFocusableGroup.js +1 -1
- package/lib-commonjs/hooks/useFocusableGroup.js.map +1 -1
- package/lib-commonjs/hooks/useKeyboardNavAttribute.js +4 -2
- package/lib-commonjs/hooks/useKeyboardNavAttribute.js.map +1 -1
- package/lib-commonjs/hooks/useModalAttributes.js +4 -2
- package/lib-commonjs/hooks/useModalAttributes.js.map +1 -1
- package/lib-commonjs/hooks/useTabster.js +1 -1
- package/lib-commonjs/hooks/useTabster.js.map +1 -1
- package/lib-commonjs/hooks/useTabsterAttributes.js +1 -0
- package/lib-commonjs/hooks/useTabsterAttributes.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +10 -11
- package/lib/focus/constants.d.ts +0 -6
- package/lib/focus/createCustomFocusIndicatorStyle.d.ts +0 -12
- package/lib/focus/createFocusOutlineStyle.d.ts +0 -24
- package/lib/focus/index.d.ts +0 -2
- package/lib/hooks/index.d.ts +0 -6
- package/lib/hooks/useArrowNavigationGroup.d.ts +0 -26
- package/lib/hooks/useFocusFinders.d.ts +0 -11
- package/lib/hooks/useFocusableGroup.d.ts +0 -12
- package/lib/hooks/useKeyboardNavAttribute.d.ts +0 -5
- package/lib/hooks/useModalAttributes.d.ts +0 -22
- package/lib/hooks/useTabster.d.ts +0 -9
- package/lib/hooks/useTabsterAttributes.d.ts +0 -5
- package/lib/index.d.ts +0 -4
- package/lib-commonjs/focus/constants.d.ts +0 -6
- package/lib-commonjs/focus/createCustomFocusIndicatorStyle.d.ts +0 -12
- package/lib-commonjs/focus/createFocusOutlineStyle.d.ts +0 -24
- package/lib-commonjs/focus/index.d.ts +0 -2
- package/lib-commonjs/hooks/index.d.ts +0 -6
- package/lib-commonjs/hooks/useArrowNavigationGroup.d.ts +0 -26
- package/lib-commonjs/hooks/useFocusFinders.d.ts +0 -11
- package/lib-commonjs/hooks/useFocusableGroup.d.ts +0 -12
- package/lib-commonjs/hooks/useKeyboardNavAttribute.d.ts +0 -5
- package/lib-commonjs/hooks/useModalAttributes.d.ts +0 -22
- package/lib-commonjs/hooks/useTabster.d.ts +0 -9
- package/lib-commonjs/hooks/useTabsterAttributes.d.ts +0 -5
- package/lib-commonjs/index.d.ts +0 -4
@@ -18,7 +18,7 @@ const constants_1 = /*#__PURE__*/require("./constants");
|
|
18
18
|
const createCustomFocusIndicatorStyle = (style, {
|
19
19
|
selector = constants_1.defaultOptions.selector
|
20
20
|
} = constants_1.defaultOptions) => ({
|
21
|
-
':focus
|
21
|
+
':focus': {
|
22
22
|
outlineStyle: 'none'
|
23
23
|
},
|
24
24
|
[`${constants_1.KEYBOARD_NAV_SELECTOR} :${selector}`]: style
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["focus/createCustomFocusIndicatorStyle.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AAOA;;;;;;AAMG;;;AACI,MAAM,+BAA+B,GAAG,CAC7C,KAD6C,EAE7C;
|
1
|
+
{"version":3,"sources":["focus/createCustomFocusIndicatorStyle.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AAOA;;;;;;AAMG;;;AACI,MAAM,+BAA+B,GAAG,CAC7C,KAD6C,EAE7C;EAAE,QAAQ,GAAG,WAAA,CAAA,cAAA,CAAe;AAA5B,IAAiF,WAAA,CAAA,cAFpC,MAG3B;EAClB,UAAU;IACR,YAAY,EAAE;EADN,CADQ;EAIlB,CAAC,GAAG,WAAA,CAAA,qBAAqB,KAAK,QAAQ,EAAtC,GAA2C;AAJzB,CAH2B,CAAxC;;AAAM,OAAA,CAAA,+BAAA,GAA+B,+BAA/B","sourcesContent":["import { KEYBOARD_NAV_SELECTOR, defaultOptions } from './constants';\nimport type { GriffelStyle } from '@griffel/react';\n\nexport interface CreateCustomFocusIndicatorStyleOptions {\n selector?: 'focus' | 'focus-within';\n}\n\n/**\n * Creates a style for @see makeStyles that includes the necessary selectors for focus.\n * Should be used only when @see createFocusOutlineStyle does not fit requirements\n *\n * @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes\n * @param options - Configure the style of the focus outline\n */\nexport const createCustomFocusIndicatorStyle = (\n style: GriffelStyle,\n { selector = defaultOptions.selector }: CreateCustomFocusIndicatorStyleOptions = defaultOptions,\n): GriffelStyle => ({\n ':focus': {\n outlineStyle: 'none',\n },\n [`${KEYBOARD_NAV_SELECTOR} :${selector}`]: style,\n});\n"],"sourceRoot":"../src/"}
|
@@ -35,7 +35,7 @@ const getFocusOutlineStyles = options => {
|
|
35
35
|
const outlineOffsetLeft = ((_c = outlineOffset) === null || _c === void 0 ? void 0 : _c.left) || outlineOffset;
|
36
36
|
const outlineOffsetRight = ((_d = outlineOffset) === null || _d === void 0 ? void 0 : _d.right) || outlineOffset;
|
37
37
|
return { ...react_1.shorthands.borderColor('transparent'),
|
38
|
-
'
|
38
|
+
'::after': {
|
39
39
|
content: '""',
|
40
40
|
position: 'absolute',
|
41
41
|
pointerEvents: 'none',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["focus/createFocusOutlineStyle.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAEA,MAAA,iCAAA,gBAAA,OAAA,CAAA,mCAAA,CAAA;;AAIA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AAiBA;;;;;;AAMG;;;AACH,MAAM,qBAAqB,GAAI,OAAD,IAAoD;;;
|
1
|
+
{"version":3,"sources":["focus/createFocusOutlineStyle.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAEA,MAAA,iCAAA,gBAAA,OAAA,CAAA,mCAAA,CAAA;;AAIA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AAiBA;;;;;;AAMG;;;AACH,MAAM,qBAAqB,GAAI,OAAD,IAAoD;;;EAChF,MAAM;IAAE,aAAF;IAAiB,YAAjB;IAA+B,aAA/B;IAA8C;EAA9C,IA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AsC,cAAc,YAAY,MAAM,mBAAmB,GAZxF;MAaT,IAAI,EAAE,CAAC,aAAD,GAAiB,IAAI,YAAY,EAAjC,GAAsC,cAAc,YAAY,MAAM,iBAAiB,GAbpF;MAcT,KAAK,EAAE,CAAC,aAAD,GAAiB,IAAI,YAAY,EAAjC,GAAsC,cAAc,YAAY,MAAM,kBAAkB;IAdtF;EAFN,CAAP;AAmBD,CA3BD;AA6BA;;;;;;AAMG;;;AACI,MAAM,uBAAuB,GAAG,CAAC;EACtC,QAAQ,GAAG,WAAA,CAAA,cAAA,CAAe,QADY;EAEtC,KAAK,GAAG,WAAA,CAAA,cAAA,CAAe;AAFe,IAGJ,WAAA,CAAA,cAHG,KAIrC,iCAAA,CAAA,+BAAA,CACE,qBAAqB,CAAC;EACpB,YAAY,EAAE,aAAA,CAAA,MAAA,CAAO,iBADD;EAEpB,aAAa,EAAE,aAAA,CAAA,MAAA,CAAO,kBAFF;EAGpB;EACA,YAAY,EAAE,KAJM;EAKpB,GAAG;AALiB,CAAD,CADvB,EAQE;EAAE;AAAF,CARF,CAJK;;AAAM,OAAA,CAAA,uBAAA,GAAuB,uBAAvB","sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport { shorthands } from '@griffel/react';\nimport type { GriffelStyle } from '@griffel/react';\nimport {\n createCustomFocusIndicatorStyle,\n CreateCustomFocusIndicatorStyleOptions,\n} from './createCustomFocusIndicatorStyle';\nimport { defaultOptions } from './constants';\n\nexport type FocusOutlineOffset = Record<'top' | 'bottom' | 'left' | 'right', string>;\nexport type FocusOutlineStyleOptions = {\n /**\n * Only property not supported by the native CSS `outline`, if this is no longer needed\n * we can just go native instead\n */\n outlineRadius: string;\n outlineColor: string;\n outlineWidth: string;\n outlineOffset?: string | FocusOutlineOffset;\n};\nexport interface CreateFocusOutlineStyleOptions extends CreateCustomFocusIndicatorStyleOptions {\n style?: Partial<FocusOutlineStyleOptions>;\n}\n\n/**\n * NOTE: the element with the focus outline needs to have `position: relative` so that the\n * pseudo element can be properly positioned.\n *\n * @param options - Configures the style of the focus outline\n * @returns focus outline styles object\n */\nconst getFocusOutlineStyles = (options: FocusOutlineStyleOptions): GriffelStyle => {\n const { outlineRadius, outlineColor, outlineOffset, outlineWidth } = options;\n\n const outlineOffsetTop = (outlineOffset as FocusOutlineOffset)?.top || outlineOffset;\n const outlineOffsetBottom = (outlineOffset as FocusOutlineOffset)?.bottom || outlineOffset;\n const outlineOffsetLeft = (outlineOffset as FocusOutlineOffset)?.left || outlineOffset;\n const outlineOffsetRight = (outlineOffset as FocusOutlineOffset)?.right || outlineOffset;\n\n return {\n ...shorthands.borderColor('transparent'),\n '::after': {\n content: '\"\"',\n position: 'absolute',\n pointerEvents: 'none',\n zIndex: 1,\n\n ...shorthands.borderStyle('solid'),\n ...shorthands.borderWidth(outlineWidth),\n ...shorthands.borderRadius(outlineRadius),\n ...shorthands.borderColor(outlineColor),\n\n top: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetTop})`,\n bottom: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetBottom})`,\n left: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetLeft})`,\n right: !outlineOffset ? `-${outlineWidth}` : `calc(0px - ${outlineWidth} - ${outlineOffsetRight})`,\n },\n };\n};\n\n/**\n * NOTE: The element with the focus outline needs to have `position: relative` so that the\n * pseudo element can be properly positioned.\n *\n * @param options - Configure the style of the focus outline\n * @returns focus outline styles object for @see makeStyles\n */\nexport const createFocusOutlineStyle = ({\n selector = defaultOptions.selector,\n style = defaultOptions.style,\n}: CreateFocusOutlineStyleOptions = defaultOptions): GriffelStyle =>\n createCustomFocusIndicatorStyle(\n getFocusOutlineStyles({\n outlineColor: tokens.colorStrokeFocus2,\n outlineRadius: tokens.borderRadiusMedium,\n // FIXME: tokens.strokeWidthThick causes some weird bugs\n outlineWidth: '2px',\n ...style,\n }),\n { selector },\n );\n"],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EAAE,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE;IAJd;EADmB,CAArB,CAAP;AAQD,CAfM;;AAAM,OAAA,CAAA,uBAAA,GAAuB,uBAAvB;;AAiBb,SAAS,oBAAT,CAA8B,IAA9B,EAA0E;EACxE,QAAQ,IAAR;IACE,KAAK,YAAL;MACE,OAAO,SAAA,CAAA,KAAA,CAAM,eAAN,CAAsB,UAA7B;;IACF,KAAK,MAAL;MACE,OAAO,SAAA,CAAA,KAAA,CAAM,eAAN,CAAsB,IAA7B;;IAEF,KAAK,UAAL;IACA;MACE,OAAO,SAAA,CAAA,KAAA,CAAM,eAAN,CAAsB,QAA7B;EARJ;AAUD","sourcesContent":["import { Types, getMover } from 'tabster';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { useTabster } from './useTabster';\n\nexport interface UseArrowNavigationGroupOptions {\n /**\n * Focus will navigate vertically, horizontally or in both directions (grid), defaults to horizontally\n * @defaultValue vertical\n */\n axis?: 'vertical' | 'horizontal' | 'grid';\n /**\n * Focus will cycle to the first/last elements of the group without stopping\n */\n circular?: boolean;\n /**\n * Last focused element in the group will be remembered and focused (if still\n * available) when tabbing from outside of the group\n */\n memorizeCurrent?: boolean;\n /**\n * Allow tabbing within the arrow navigation group items.\n */\n tabbable?: boolean;\n}\n\n/**\n * A hook that returns the necessary tabster attributes to support arrow key navigation\n * @param options - Options to configure keyboard navigation\n */\nexport const useArrowNavigationGroup = (options?: UseArrowNavigationGroupOptions): Types.TabsterDOMAttribute => {\n const tabster = useTabster();\n\n if (tabster) {\n getMover(tabster);\n }\n\n return useTabsterAttributes({\n mover: {\n cyclic: !!options?.circular,\n direction: axisToMoverDirection(options?.axis ?? 'vertical'),\n memorizeCurrent: options?.memorizeCurrent,\n tabbable: options?.tabbable,\n },\n });\n};\n\nfunction axisToMoverDirection(axis: UseArrowNavigationGroupOptions['axis']): Types.MoverDirection {\n switch (axis) {\n case 'horizontal':\n return Types.MoverDirections.Horizontal;\n case 'grid':\n return Types.MoverDirections.Grid;\n\n case 'vertical':\n default:\n return Types.MoverDirections.Vertical;\n }\n}\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["hooks/useFocusFinders.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAEA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AAEA;;AAEG;;;AACI,MAAM,eAAe,GAAG,MAAK;
|
1
|
+
{"version":3,"sources":["hooks/useFocusFinders.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAEA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AAEA;;AAEG;;;AACI,MAAM,eAAe,GAAG,MAAK;EAClC,MAAM,OAAO,GAAG,YAAA,CAAA,UAAA,EAAhB,CADkC,CAGlC;;EACA,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAN,CACvB,CAAC,SAAD,EAAyB,eAAzB,KACE,CAAA,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,SAAT,CAAmB,OAAnB,CAA2B;IAAE,SAAF;IAAa;EAAb,CAA3B,CAAA,KAA8D,EAFzC,EAGvB,CAAC,OAAD,CAHuB,CAAzB;EAMA,MAAM,kBAAkB,GAAG,KAAK,CAAC,WAAN,CACxB,SAAD,IAA4B,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,SAAT,CAAmB,SAAnB,CAA6B;IAAE;EAAF,CAA7B,CADH,EAEzB,CAAC,OAAD,CAFyB,CAA3B;EAKA,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAN,CAAmB,SAAD,IAA4B,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,SAAT,CAAmB,QAAnB,CAA4B;IAAE;EAAF,CAA5B,CAA9C,EAA0F,CAClH,OADkH,CAA1F,CAA1B;EAIA,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAN,CACxB,CAAC,cAAD,EAA8B,OAAA,GAAyD,EAAvF,KACE,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,SAAT,CAAmB,QAAnB,CAA4B;IAAE,cAAF;IAAkB,GAAG;EAArB,CAA5B,CAFsB,EAGxB,CAAC,OAAD,CAHwB,CAA1B;EAMA,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAN,CACxB,CAAC,cAAD,EAA8B,OAAA,GAAyD,EAAvF,KACE,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,SAAT,CAAmB,QAAnB,CAA4B;IAAE,cAAF;IAAkB,GAAG;EAArB,CAA5B,CAFsB,EAGxB,CAAC,OAAD,CAHwB,CAA1B;EAMA,OAAO;IACL,gBADK;IAEL,kBAFK;IAGL,iBAHK;IAIL,iBAJK;IAKL;EALK,CAAP;AAOD,CAtCM;;AAAM,OAAA,CAAA,eAAA,GAAe,eAAf","sourcesContent":["import * as React from 'react';\nimport { Types as TabsterTypes } from 'tabster';\nimport { useTabster } from './useTabster';\n\n/**\n * Returns a set of helper functions that will traverse focusable elements in the context of a root DOM element\n */\nexport const useFocusFinders = () => {\n const tabster = useTabster();\n\n // Narrow props for now and let need dictate additional props in the future\n const findAllFocusable = React.useCallback(\n (container: HTMLElement, acceptCondition: (el: HTMLElement) => boolean) =>\n tabster?.focusable.findAll({ container, acceptCondition }) || [],\n [tabster],\n );\n\n const findFirstFocusable = React.useCallback(\n (container: HTMLElement) => tabster?.focusable.findFirst({ container }),\n [tabster],\n );\n\n const findLastFocusable = React.useCallback((container: HTMLElement) => tabster?.focusable.findLast({ container }), [\n tabster,\n ]);\n\n const findNextFocusable = React.useCallback(\n (currentElement: HTMLElement, options: Pick<TabsterTypes.FindNextProps, 'container'> = {}) =>\n tabster?.focusable.findNext({ currentElement, ...options }),\n [tabster],\n );\n\n const findPrevFocusable = React.useCallback(\n (currentElement: HTMLElement, options: Pick<TabsterTypes.FindNextProps, 'container'> = {}) =>\n tabster?.focusable.findPrev({ currentElement, ...options }),\n [tabster],\n );\n\n return {\n findAllFocusable,\n findFirstFocusable,\n findLastFocusable,\n findNextFocusable,\n findPrevFocusable,\n };\n};\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["hooks/useFocusableGroup.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,MAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AASA;;;AAGG;;;AACI,MAAM,iBAAiB,GAAI,OAAD,IAAkE;
|
1
|
+
{"version":3,"sources":["hooks/useFocusableGroup.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,MAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AASA;;;AAGG;;;AACI,MAAM,iBAAiB,GAAI,OAAD,IAAkE;EACjG,MAAM,OAAO,GAAG,YAAA,CAAA,UAAA,EAAhB;;EAEA,IAAI,OAAJ,EAAa;IACX,SAAA,CAAA,WAAA,CAAY,OAAZ;EACD;;EAED,OAAO,sBAAA,CAAA,oBAAA,CAAqB;IAC1B,QAAQ,EAAE;MACR,WAAW,EAAE,cAAc,CAAC,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,WAAV;IADnB;EADgB,CAArB,CAAP;AAKD,CAZM;;AAAM,OAAA,CAAA,iBAAA,GAAiB,iBAAjB;;AAcb,MAAM,cAAc,GAClB,WADqB,IAEoB;EACzC,QAAQ,WAAR;IACE,KAAK,WAAL;MACE,OAAO,SAAA,CAAA,KAAA,CAAM,qBAAN,CAA4B,SAAnC;;IACF,KAAK,SAAL;MACE,OAAO,SAAA,CAAA,KAAA,CAAM,qBAAN,CAA4B,OAAnC;;IACF,KAAK,oBAAL;MACE,OAAO,SAAA,CAAA,KAAA,CAAM,qBAAN,CAA4B,gBAAnC;;IACF;MACE,OAAO,SAAP;EARJ;AAUD,CAbD","sourcesContent":["import { Types, getGroupper } from 'tabster';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { useTabster } from './useTabster';\n\nexport interface UseFocusableGroupOptions {\n /**\n * Behavior for the Tab key.\n */\n tabBehavior?: 'unlimited' | 'limited' | '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"],"sourceRoot":"../src/"}
|
@@ -13,14 +13,16 @@ const constants_1 = /*#__PURE__*/require("../focus/constants");
|
|
13
13
|
|
14
14
|
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
15
15
|
/**
|
16
|
-
*
|
16
|
+
* Instantiates [keyborg](https://github.com/microsoft/keyborg) and adds `data-keyboard-nav`
|
17
|
+
* attribute to a referenced element to ensure keyboard navigation awareness
|
18
|
+
* synced to keyborg logic without having to cause a re-render on react tree.
|
17
19
|
*/
|
18
20
|
|
19
21
|
|
20
22
|
function useKeyboardNavAttribute() {
|
21
23
|
const {
|
22
24
|
targetDocument
|
23
|
-
} = react_shared_contexts_1.
|
25
|
+
} = react_shared_contexts_1.useFluent_unstable();
|
24
26
|
const keyborg = react_1.useMemo(() => targetDocument && keyborg_1.createKeyborg(targetDocument.defaultView), [targetDocument]);
|
25
27
|
const ref = react_1.useRef(null);
|
26
28
|
react_1.useEffect(() => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["hooks/useKeyboardNavAttribute.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,WAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;;AACA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;AAIA
|
1
|
+
{"version":3,"sources":["hooks/useKeyboardNavAttribute.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,WAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;;AACA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;AAIA;;;;AAIG;;;AACH,SAAgB,uBAAhB,GAAuC;EACrC,MAAM;IAAE;EAAF,IAAqB,uBAAA,CAAA,kBAAA,EAA3B;EACA,MAAM,OAAO,GAAG,OAAA,CAAA,OAAA,CAAQ,MAAM,cAAc,IAAI,SAAA,CAAA,aAAA,CAAc,cAAc,CAAC,WAA7B,CAAhC,EAA4E,CAAC,cAAD,CAA5E,CAAhB;EACA,MAAM,GAAG,GAAG,OAAA,CAAA,MAAA,CAAU,IAAV,CAAZ;EACA,OAAA,CAAA,SAAA,CAAU,MAAK;IACb,IAAI,OAAJ,EAAa;MACX,mBAAmB,CAAC,GAAD,EAAM,WAAA,CAAA,sBAAN,EAA8B,OAAO,CAAC,wBAAR,EAA9B,CAAnB;;MACA,MAAM,EAAE,GAAoB,IAAI,IAAG;QACjC,mBAAmB,CAAC,GAAD,EAAM,WAAA,CAAA,sBAAN,EAA8B,IAA9B,CAAnB;MACD,CAFD;;MAGA,OAAO,CAAC,SAAR,CAAkB,EAAlB;MACA,OAAO,MAAM,OAAO,CAAC,WAAR,CAAoB,EAApB,CAAb;IACD;EACF,CATD,EASG,CAAC,OAAD,CATH;EAUA,OAAO,GAAP;AACD;;AAfD,OAAA,CAAA,uBAAA,GAAA,uBAAA;;AAiBA,SAAS,mBAAT,CAA6B,UAA7B,EAAiE,SAAjE,EAAoF,KAApF,EAAkG;EAChG,IAAI,CAAC,UAAU,CAAC,OAAhB,EAAyB;IACvB;EACD;;EACD,IAAI,KAAJ,EAAW;IACT,UAAU,CAAC,OAAX,CAAmB,YAAnB,CAAgC,SAAhC,EAA2C,EAA3C;EACD,CAFD,MAEO;IACL,UAAU,CAAC,OAAX,CAAmB,eAAnB,CAAmC,SAAnC;EACD;AACF","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/dist/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"],"sourceRoot":"../src/"}
|
@@ -24,7 +24,8 @@ const useTabster_1 = /*#__PURE__*/require("./useTabster");
|
|
24
24
|
const useModalAttributes = (options = {}) => {
|
25
25
|
const {
|
26
26
|
trapFocus,
|
27
|
-
alwaysFocusable
|
27
|
+
alwaysFocusable,
|
28
|
+
legacyTrapFocus
|
28
29
|
} = options;
|
29
30
|
const tabster = useTabster_1.useTabster(); // Initializes the modalizer and deloser APIs
|
30
31
|
|
@@ -39,7 +40,8 @@ const useModalAttributes = (options = {}) => {
|
|
39
40
|
modalizer: {
|
40
41
|
id,
|
41
42
|
isOthersAccessible: !trapFocus,
|
42
|
-
isAlwaysAccessible: alwaysFocusable
|
43
|
+
isAlwaysAccessible: alwaysFocusable,
|
44
|
+
isTrapped: legacyTrapFocus
|
43
45
|
}
|
44
46
|
});
|
45
47
|
const triggerAttributes = useTabsterAttributes_1.useTabsterAttributes({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["hooks/useModalAttributes.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;
|
1
|
+
{"version":3,"sources":["hooks/useModalAttributes.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AAyBA;;;;;;AAMG;;;AACI,MAAM,kBAAkB,GAAG,CAChC,OAAA,GAAqC,EADL,KAE8E;EAC9G,MAAM;IAAE,SAAF;IAAa,eAAb;IAA8B;EAA9B,IAAkD,OAAxD;EACA,MAAM,OAAO,GAAG,YAAA,CAAA,UAAA,EAAhB,CAF8G,CAG9G;;EACA,IAAI,OAAJ,EAAa;IACX,SAAA,CAAA,YAAA,CAAa,OAAb;IACA,SAAA,CAAA,UAAA,CAAW,OAAX;EACD;;EAED,MAAM,EAAE,GAAG,iBAAA,CAAA,KAAA,CAAM,QAAN,CAAX;EACA,MAAM,eAAe,GAAG,sBAAA,CAAA,oBAAA,CAAqB;IAC3C,OAAO,EAAE,EADkC;IAE3C,SAAS,EAAE;MACT,EADS;MAET,kBAAkB,EAAE,CAAC,SAFZ;MAGT,kBAAkB,EAAE,eAHX;MAIT,SAAS,EAAE;IAJF;EAFgC,CAArB,CAAxB;EAUA,MAAM,iBAAiB,GAAG,sBAAA,CAAA,oBAAA,CAAqB;IAC7C,OAAO,EAAE;EADoC,CAArB,CAA1B;EAIA,OAAO;IAAE,eAAF;IAAmB;EAAnB,CAAP;AACD,CA3BM;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB","sourcesContent":["import { useId } from '@fluentui/react-utilities';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { getDeloser, getModalizer, Types as TabsterTypes } from 'tabster';\nimport { useTabster } from './useTabster';\n\nexport interface UseModalAttributesOptions {\n /**\n * Traps focus inside the elements the attributes are applied.\n * Prefer this to `legacyTrapFocus`\n * it forbids users to tab out of the focus trap into the actual browser.\n */\n trapFocus?: boolean;\n\n /**\n * Traps focus inside the elements the attributes are applied.\n * This prop enables legacy behavior to match previous versions of Fluent and is not\n * recommended for general use.\n * Enabling `legacyTrapFocus` prevents users from tabbing out of the focus trap and into\n * the actual browser. Prefer using `trapFocus` instead of this prop.\n */\n legacyTrapFocus?: boolean;\n\n /**\n * Always reachabled in Tab order\n */\n alwaysFocusable?: boolean;\n}\n\n/**\n * Applies modal dialog behaviour through DOM attributes\n * Modal element will focus trap and hide other content on the page\n * The trigger element will be focused if focus is lost after the modal element is removed\n *\n * @returns DOM attributes to apply to the modal element and its trigger\n */\nexport const useModalAttributes = (\n options: UseModalAttributesOptions = {},\n): { modalAttributes: TabsterTypes.TabsterDOMAttribute; triggerAttributes: TabsterTypes.TabsterDOMAttribute } => {\n const { trapFocus, alwaysFocusable, legacyTrapFocus } = options;\n const tabster = useTabster();\n // Initializes the modalizer and deloser APIs\n if (tabster) {\n getModalizer(tabster);\n getDeloser(tabster);\n }\n\n const id = useId('modal-');\n const modalAttributes = useTabsterAttributes({\n deloser: {},\n modalizer: {\n id,\n isOthersAccessible: !trapFocus,\n isAlwaysAccessible: alwaysFocusable,\n isTrapped: legacyTrapFocus,\n },\n });\n\n const triggerAttributes = useTabsterAttributes({\n deloser: {},\n });\n\n return { modalAttributes, triggerAttributes };\n};\n"],"sourceRoot":"../src/"}
|
@@ -22,7 +22,7 @@ const useTabster = () => {
|
|
22
22
|
|
23
23
|
const {
|
24
24
|
targetDocument
|
25
|
-
} = react_shared_contexts_1.
|
25
|
+
} = react_shared_contexts_1.useFluent_unstable();
|
26
26
|
const defaultView = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) || undefined;
|
27
27
|
const tabsterOptions = {
|
28
28
|
autoRoot: {},
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["hooks/useTabster.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AACA,MAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;AAEA;;;;;;AAMG;;;AACI,MAAM,UAAU,GAAG,MAAsC;;;
|
1
|
+
{"version":3,"sources":["hooks/useTabster.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AACA,MAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;AAEA;;;;;;AAMG;;;AACI,MAAM,UAAU,GAAG,MAAsC;;;EAC9D,MAAM;IAAE;EAAF,IAAqB,uBAAA,CAAA,kBAAA,EAA3B;EAEA,MAAM,WAAW,GAAG,CAAA,cAAc,KAAA,IAAd,IAAA,cAAc,KAAA,KAAA,CAAd,GAAc,KAAA,CAAd,GAAA,cAAc,CAAE,WAAhB,KAA+B,SAAnD;EACA,MAAM,cAAc,GAAkC;IAAE,QAAQ,EAAE,EAAZ;IAAgB,UAAU,EAAE;EAA5B,CAAtD;;EAEA,IAAI,CAAC,WAAL,EAAkB;IAChB,OAAO,IAAP;EACD,CAR6D,CAU9D;;;EACA,OAAO,CAAA,EAAA,GAAA,SAAA,CAAA,iBAAA,CAAkB,WAAlB,CAAA,MAA8B,IAA9B,IAA8B,EAAA,KAAA,KAAA,CAA9B,GAA8B,EAA9B,GAAkC,SAAA,CAAA,aAAA,CAAc,WAAd,EAA2B,cAA3B,CAAzC;AACD,CAZM;;AAAM,OAAA,CAAA,UAAA,GAAU,UAAV","sourcesContent":["import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { getCurrentTabster, createTabster, Types as TabsterTypes } from 'tabster';\n\n/**\n * Tries to get a tabster instance on the current window or creates a new one\n * Since Tabster is single instance only, feel free to call this hook to ensure Tabster exists if necessary\n *\n * @internal\n * @returns Tabster core instance\n */\nexport const useTabster = (): TabsterTypes.TabsterCore | null => {\n const { targetDocument } = useFluent();\n\n const defaultView = targetDocument?.defaultView || undefined;\n const tabsterOptions: TabsterTypes.TabsterCoreProps = { autoRoot: {}, controlTab: false };\n\n if (!defaultView) {\n return null;\n }\n\n // TODO: worth memoizing once more tabster options are used\n return getCurrentTabster(defaultView) ?? createTabster(defaultView, tabsterOptions);\n};\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["hooks/useTabsterAttributes.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AAEA
|
1
|
+
{"version":3,"sources":["hooks/useTabsterAttributes.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,SAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AAEA;;;AAGG;;;AACI,MAAM,oBAAoB,GAAI,KAAD,IAAgF;EAClH;EACA;EACA,YAAA,CAAA,UAAA;EAEA,OAAO,SAAA,CAAA,mBAAA,CAAoB,KAApB,CAAP;AACD,CANM;;AAAM,OAAA,CAAA,oBAAA,GAAoB,oBAApB","sourcesContent":["import { getTabsterAttribute, Types as TabsterTypes } from 'tabster';\nimport { useTabster } from './useTabster';\n\n/**\n * @internal\n * Hook that returns tabster attributes while ensuring tabster exists\n */\nexport const useTabsterAttributes = (props: TabsterTypes.TabsterAttributeProps): TabsterTypes.TabsterDOMAttribute => {\n // A tabster instance is not necessary to generate tabster attributes\n // but calling the hook will ensure that a tabster instance exists internally and avoids consumers doing the same\n useTabster();\n\n return getTabsterAttribute(props);\n};\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,CA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AA;IAAA,OAAA,OAAA,CAAA,+BAAA;EAA+B;AAA/B,CAAA;AAAiC,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,yBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,uBAAA;EAAuB;AAAvB,CAAA","sourcesContent":["export {\n useArrowNavigationGroup,\n useFocusableGroup,\n useFocusFinders,\n useKeyboardNavAttribute,\n useModalAttributes,\n useTabsterAttributes,\n} from './hooks/index';\nexport type {\n UseArrowNavigationGroupOptions,\n UseFocusableGroupOptions,\n UseModalAttributesOptions,\n} from './hooks/index';\n\nexport { createCustomFocusIndicatorStyle, createFocusOutlineStyle } from './focus/index';\n\nexport type {\n CreateCustomFocusIndicatorStyleOptions,\n CreateFocusOutlineStyleOptions,\n FocusOutlineOffset,\n FocusOutlineStyleOptions,\n} from './focus/index';\n"],"sourceRoot":"../src/"}
|
package/package.json
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-tabster",
|
3
|
-
"version": "9.0.0
|
3
|
+
"version": "9.0.0",
|
4
4
|
"description": "Utilities for focus management and facade for tabster",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
7
|
-
"typings": "
|
7
|
+
"typings": "dist/index.d.ts",
|
8
8
|
"sideEffects": false,
|
9
9
|
"repository": {
|
10
10
|
"type": "git",
|
@@ -15,7 +15,8 @@
|
|
15
15
|
"build": "just-scripts build",
|
16
16
|
"clean": "just-scripts clean",
|
17
17
|
"code-style": "just-scripts code-style",
|
18
|
-
"e2e": "
|
18
|
+
"e2e": "yarn cypress run --component",
|
19
|
+
"e2e:local": "yarn cypress open --component",
|
19
20
|
"just": "just-scripts",
|
20
21
|
"lint": "just-scripts lint",
|
21
22
|
"storybook": "node ../../../scripts/storybook/runner",
|
@@ -30,12 +31,12 @@
|
|
30
31
|
"@fluentui/scripts": "^1.0.0"
|
31
32
|
},
|
32
33
|
"dependencies": {
|
33
|
-
"@griffel/react": "1.0
|
34
|
-
"@fluentui/react-shared-contexts": "9.0.0
|
35
|
-
"@fluentui/react-theme": "9.0.0
|
36
|
-
"@fluentui/react-utilities": "9.0.0
|
34
|
+
"@griffel/react": "1.2.0",
|
35
|
+
"@fluentui/react-shared-contexts": "^9.0.0",
|
36
|
+
"@fluentui/react-theme": "^9.0.0",
|
37
|
+
"@fluentui/react-utilities": "^9.0.0",
|
37
38
|
"keyborg": "^1.1.0",
|
38
|
-
"tabster": "^1.
|
39
|
+
"tabster": "^1.4.2",
|
39
40
|
"tslib": "^2.1.0"
|
40
41
|
},
|
41
42
|
"peerDependencies": {
|
@@ -46,9 +47,7 @@
|
|
46
47
|
},
|
47
48
|
"beachball": {
|
48
49
|
"disallowedChangeTypes": [
|
49
|
-
"major"
|
50
|
-
"minor",
|
51
|
-
"patch"
|
50
|
+
"major"
|
52
51
|
]
|
53
52
|
},
|
54
53
|
"exports": {
|
package/lib/focus/constants.d.ts
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { GriffelStyle } from '@griffel/react';
|
2
|
-
export interface CreateCustomFocusIndicatorStyleOptions {
|
3
|
-
selector?: 'focus' | 'focus-within';
|
4
|
-
}
|
5
|
-
/**
|
6
|
-
* Creates a style for @see makeStyles that includes the necessary selectors for focus.
|
7
|
-
* Should be used only when @see createFocusOutlineStyle does not fit requirements
|
8
|
-
*
|
9
|
-
* @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes
|
10
|
-
* @param options - Configure the style of the focus outline
|
11
|
-
*/
|
12
|
-
export declare const createCustomFocusIndicatorStyle: (style: GriffelStyle, { selector }?: CreateCustomFocusIndicatorStyleOptions) => GriffelStyle;
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import type { GriffelStyle } from '@griffel/react';
|
2
|
-
import { CreateCustomFocusIndicatorStyleOptions } from './createCustomFocusIndicatorStyle';
|
3
|
-
export declare type FocusOutlineOffset = Record<'top' | 'bottom' | 'left' | 'right', string>;
|
4
|
-
export declare type FocusOutlineStyleOptions = {
|
5
|
-
/**
|
6
|
-
* Only property not supported by the native CSS `outline`, if this is no longer needed
|
7
|
-
* we can just go native instead
|
8
|
-
*/
|
9
|
-
outlineRadius: string;
|
10
|
-
outlineColor: string;
|
11
|
-
outlineWidth: string;
|
12
|
-
outlineOffset?: string | FocusOutlineOffset;
|
13
|
-
};
|
14
|
-
export interface CreateFocusOutlineStyleOptions extends CreateCustomFocusIndicatorStyleOptions {
|
15
|
-
style?: Partial<FocusOutlineStyleOptions>;
|
16
|
-
}
|
17
|
-
/**
|
18
|
-
* NOTE: The element with the focus outline needs to have `position: relative` so that the
|
19
|
-
* pseudo element can be properly positioned.
|
20
|
-
*
|
21
|
-
* @param options - Configure the style of the focus outline
|
22
|
-
* @returns focus outline styles object for @see makeStyles
|
23
|
-
*/
|
24
|
-
export declare const createFocusOutlineStyle: ({ selector, style, }?: CreateFocusOutlineStyleOptions) => GriffelStyle;
|
package/lib/focus/index.d.ts
DELETED
package/lib/hooks/index.d.ts
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
import { Types } from 'tabster';
|
2
|
-
export interface UseArrowNavigationGroupOptions {
|
3
|
-
/**
|
4
|
-
* Focus will navigate vertically, horizontally or in both directions (grid), defaults to horizontally
|
5
|
-
* @defaultValue vertical
|
6
|
-
*/
|
7
|
-
axis?: 'vertical' | 'horizontal' | 'grid';
|
8
|
-
/**
|
9
|
-
* Focus will cycle to the first/last elements of the group without stopping
|
10
|
-
*/
|
11
|
-
circular?: boolean;
|
12
|
-
/**
|
13
|
-
* Last focused element in the group will be remembered and focused (if still
|
14
|
-
* available) when tabbing from outside of the group
|
15
|
-
*/
|
16
|
-
memorizeCurrent?: boolean;
|
17
|
-
/**
|
18
|
-
* Allow tabbing within the arrow navigation group items.
|
19
|
-
*/
|
20
|
-
tabbable?: boolean;
|
21
|
-
}
|
22
|
-
/**
|
23
|
-
* A hook that returns the necessary tabster attributes to support arrow key navigation
|
24
|
-
* @param options - Options to configure keyboard navigation
|
25
|
-
*/
|
26
|
-
export declare const useArrowNavigationGroup: (options?: UseArrowNavigationGroupOptions | undefined) => Types.TabsterDOMAttribute;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import { Types as TabsterTypes } from 'tabster';
|
2
|
-
/**
|
3
|
-
* Returns a set of helper functions that will traverse focusable elements in the context of a root DOM element
|
4
|
-
*/
|
5
|
-
export declare const useFocusFinders: () => {
|
6
|
-
findAllFocusable: (container: HTMLElement, acceptCondition: (el: HTMLElement) => boolean) => HTMLElement[];
|
7
|
-
findFirstFocusable: (container: HTMLElement) => HTMLElement | null | undefined;
|
8
|
-
findLastFocusable: (container: HTMLElement) => HTMLElement | null | undefined;
|
9
|
-
findNextFocusable: (currentElement: HTMLElement, options?: Pick<TabsterTypes.FindNextProps, 'container'>) => HTMLElement | null | undefined;
|
10
|
-
findPrevFocusable: (currentElement: HTMLElement, options?: Pick<TabsterTypes.FindNextProps, 'container'>) => HTMLElement | null | undefined;
|
11
|
-
};
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { Types } from 'tabster';
|
2
|
-
export interface UseFocusableGroupOptions {
|
3
|
-
/**
|
4
|
-
* Behavior for the Tab key.
|
5
|
-
*/
|
6
|
-
tabBehavior?: 'unlimited' | 'limited' | 'limitedTrapFocus';
|
7
|
-
}
|
8
|
-
/**
|
9
|
-
* A hook that returns the necessary tabster attributes to support groupping.
|
10
|
-
* @param options - Options to configure keyboard navigation
|
11
|
-
*/
|
12
|
-
export declare const useFocusableGroup: (options?: UseFocusableGroupOptions | undefined) => Types.TabsterDOMAttribute;
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { Types as TabsterTypes } from 'tabster';
|
2
|
-
export interface UseModalAttributesOptions {
|
3
|
-
/**
|
4
|
-
* Traps focus inside the elements the attributes are applied
|
5
|
-
*/
|
6
|
-
trapFocus?: boolean;
|
7
|
-
/**
|
8
|
-
* Always reachabled in Tab order
|
9
|
-
*/
|
10
|
-
alwaysFocusable?: boolean;
|
11
|
-
}
|
12
|
-
/**
|
13
|
-
* Applies modal dialog behaviour through DOM attributes
|
14
|
-
* Modal element will focus trap and hide other content on the page
|
15
|
-
* The trigger element will be focused if focus is lost after the modal element is removed
|
16
|
-
*
|
17
|
-
* @returns DOM attributes to apply to the modal element and its trigger
|
18
|
-
*/
|
19
|
-
export declare const useModalAttributes: (options?: UseModalAttributesOptions) => {
|
20
|
-
modalAttributes: TabsterTypes.TabsterDOMAttribute;
|
21
|
-
triggerAttributes: TabsterTypes.TabsterDOMAttribute;
|
22
|
-
};
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { Types as TabsterTypes } from 'tabster';
|
2
|
-
/**
|
3
|
-
* Tries to get a tabster instance on the current window or creates a new one
|
4
|
-
* Since Tabster is single instance only, feel free to call this hook to ensure Tabster exists if necessary
|
5
|
-
*
|
6
|
-
* @internal
|
7
|
-
* @returns Tabster core instance
|
8
|
-
*/
|
9
|
-
export declare const useTabster: () => TabsterTypes.TabsterCore | null;
|
package/lib/index.d.ts
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
export { useArrowNavigationGroup, useFocusableGroup, useFocusFinders, useKeyboardNavAttribute, useModalAttributes, useTabsterAttributes, } from './hooks/index';
|
2
|
-
export type { UseArrowNavigationGroupOptions, UseFocusableGroupOptions, UseModalAttributesOptions, } from './hooks/index';
|
3
|
-
export { createCustomFocusIndicatorStyle, createFocusOutlineStyle } from './focus/index';
|
4
|
-
export type { CreateCustomFocusIndicatorStyleOptions, CreateFocusOutlineStyleOptions, FocusOutlineOffset, FocusOutlineStyleOptions, } from './focus/index';
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { GriffelStyle } from '@griffel/react';
|
2
|
-
export interface CreateCustomFocusIndicatorStyleOptions {
|
3
|
-
selector?: 'focus' | 'focus-within';
|
4
|
-
}
|
5
|
-
/**
|
6
|
-
* Creates a style for @see makeStyles that includes the necessary selectors for focus.
|
7
|
-
* Should be used only when @see createFocusOutlineStyle does not fit requirements
|
8
|
-
*
|
9
|
-
* @param style - styling applied on focus, defaults to @see getDefaultFocusOutlineStyes
|
10
|
-
* @param options - Configure the style of the focus outline
|
11
|
-
*/
|
12
|
-
export declare const createCustomFocusIndicatorStyle: (style: GriffelStyle, { selector }?: CreateCustomFocusIndicatorStyleOptions) => GriffelStyle;
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import type { GriffelStyle } from '@griffel/react';
|
2
|
-
import { CreateCustomFocusIndicatorStyleOptions } from './createCustomFocusIndicatorStyle';
|
3
|
-
export declare type FocusOutlineOffset = Record<'top' | 'bottom' | 'left' | 'right', string>;
|
4
|
-
export declare type FocusOutlineStyleOptions = {
|
5
|
-
/**
|
6
|
-
* Only property not supported by the native CSS `outline`, if this is no longer needed
|
7
|
-
* we can just go native instead
|
8
|
-
*/
|
9
|
-
outlineRadius: string;
|
10
|
-
outlineColor: string;
|
11
|
-
outlineWidth: string;
|
12
|
-
outlineOffset?: string | FocusOutlineOffset;
|
13
|
-
};
|
14
|
-
export interface CreateFocusOutlineStyleOptions extends CreateCustomFocusIndicatorStyleOptions {
|
15
|
-
style?: Partial<FocusOutlineStyleOptions>;
|
16
|
-
}
|
17
|
-
/**
|
18
|
-
* NOTE: The element with the focus outline needs to have `position: relative` so that the
|
19
|
-
* pseudo element can be properly positioned.
|
20
|
-
*
|
21
|
-
* @param options - Configure the style of the focus outline
|
22
|
-
* @returns focus outline styles object for @see makeStyles
|
23
|
-
*/
|
24
|
-
export declare const createFocusOutlineStyle: ({ selector, style, }?: CreateFocusOutlineStyleOptions) => GriffelStyle;
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import { Types } from 'tabster';
|
2
|
-
export interface UseArrowNavigationGroupOptions {
|
3
|
-
/**
|
4
|
-
* Focus will navigate vertically, horizontally or in both directions (grid), defaults to horizontally
|
5
|
-
* @defaultValue vertical
|
6
|
-
*/
|
7
|
-
axis?: 'vertical' | 'horizontal' | 'grid';
|
8
|
-
/**
|
9
|
-
* Focus will cycle to the first/last elements of the group without stopping
|
10
|
-
*/
|
11
|
-
circular?: boolean;
|
12
|
-
/**
|
13
|
-
* Last focused element in the group will be remembered and focused (if still
|
14
|
-
* available) when tabbing from outside of the group
|
15
|
-
*/
|
16
|
-
memorizeCurrent?: boolean;
|
17
|
-
/**
|
18
|
-
* Allow tabbing within the arrow navigation group items.
|
19
|
-
*/
|
20
|
-
tabbable?: boolean;
|
21
|
-
}
|
22
|
-
/**
|
23
|
-
* A hook that returns the necessary tabster attributes to support arrow key navigation
|
24
|
-
* @param options - Options to configure keyboard navigation
|
25
|
-
*/
|
26
|
-
export declare const useArrowNavigationGroup: (options?: UseArrowNavigationGroupOptions | undefined) => Types.TabsterDOMAttribute;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import { Types as TabsterTypes } from 'tabster';
|
2
|
-
/**
|
3
|
-
* Returns a set of helper functions that will traverse focusable elements in the context of a root DOM element
|
4
|
-
*/
|
5
|
-
export declare const useFocusFinders: () => {
|
6
|
-
findAllFocusable: (container: HTMLElement, acceptCondition: (el: HTMLElement) => boolean) => HTMLElement[];
|
7
|
-
findFirstFocusable: (container: HTMLElement) => HTMLElement | null | undefined;
|
8
|
-
findLastFocusable: (container: HTMLElement) => HTMLElement | null | undefined;
|
9
|
-
findNextFocusable: (currentElement: HTMLElement, options?: Pick<TabsterTypes.FindNextProps, 'container'>) => HTMLElement | null | undefined;
|
10
|
-
findPrevFocusable: (currentElement: HTMLElement, options?: Pick<TabsterTypes.FindNextProps, 'container'>) => HTMLElement | null | undefined;
|
11
|
-
};
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { Types } from 'tabster';
|
2
|
-
export interface UseFocusableGroupOptions {
|
3
|
-
/**
|
4
|
-
* Behavior for the Tab key.
|
5
|
-
*/
|
6
|
-
tabBehavior?: 'unlimited' | 'limited' | 'limitedTrapFocus';
|
7
|
-
}
|
8
|
-
/**
|
9
|
-
* A hook that returns the necessary tabster attributes to support groupping.
|
10
|
-
* @param options - Options to configure keyboard navigation
|
11
|
-
*/
|
12
|
-
export declare const useFocusableGroup: (options?: UseFocusableGroupOptions | undefined) => Types.TabsterDOMAttribute;
|