@fluentui/react-aria 9.2.0 → 9.2.2

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.
Files changed (30) hide show
  1. package/CHANGELOG.json +46 -1
  2. package/CHANGELOG.md +20 -2
  3. package/lib/{hooks/useARIAButton → button}/index.js +0 -0
  4. package/lib/button/index.js.map +1 -0
  5. package/lib/{hooks/useARIAButton → button}/types.js +0 -0
  6. package/lib/button/types.js.map +1 -0
  7. package/lib/{hooks/useARIAButton → button}/useARIAButtonProps.js +3 -5
  8. package/lib/button/useARIAButtonProps.js.map +1 -0
  9. package/lib/{hooks/useARIAButton → button}/useARIAButtonShorthand.js +0 -0
  10. package/lib/button/useARIAButtonShorthand.js.map +1 -0
  11. package/lib/index.js +1 -1
  12. package/lib/index.js.map +1 -1
  13. package/lib-commonjs/{hooks/useARIAButton → button}/index.js +0 -0
  14. package/lib-commonjs/button/index.js.map +1 -0
  15. package/lib-commonjs/{hooks/useARIAButton → button}/types.js +0 -0
  16. package/lib-commonjs/{hooks/useARIAButton → button}/types.js.map +0 -0
  17. package/lib-commonjs/{hooks/useARIAButton → button}/useARIAButtonProps.js +3 -5
  18. package/lib-commonjs/button/useARIAButtonProps.js.map +1 -0
  19. package/lib-commonjs/{hooks/useARIAButton → button}/useARIAButtonShorthand.js +0 -0
  20. package/lib-commonjs/button/useARIAButtonShorthand.js.map +1 -0
  21. package/lib-commonjs/index.js +1 -1
  22. package/lib-commonjs/index.js.map +1 -1
  23. package/package.json +2 -2
  24. package/lib/hooks/useARIAButton/index.js.map +0 -1
  25. package/lib/hooks/useARIAButton/types.js.map +0 -1
  26. package/lib/hooks/useARIAButton/useARIAButtonProps.js.map +0 -1
  27. package/lib/hooks/useARIAButton/useARIAButtonShorthand.js.map +0 -1
  28. package/lib-commonjs/hooks/useARIAButton/index.js.map +0 -1
  29. package/lib-commonjs/hooks/useARIAButton/useARIAButtonProps.js.map +0 -1
  30. package/lib-commonjs/hooks/useARIAButton/useARIAButtonShorthand.js.map +0 -1
package/CHANGELOG.json CHANGED
@@ -2,7 +2,52 @@
2
2
  "name": "@fluentui/react-aria",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 15 Sep 2022 09:45:09 GMT",
5
+ "date": "Thu, 13 Oct 2022 10:59:42 GMT",
6
+ "tag": "@fluentui/react-aria_v9.2.2",
7
+ "version": "9.2.2",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "beachball",
12
+ "package": "@fluentui/react-aria",
13
+ "comment": "Bump @fluentui/react-utilities to v9.1.1",
14
+ "commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Mon, 03 Oct 2022 22:24:33 GMT",
21
+ "tag": "@fluentui/react-aria_v9.2.1",
22
+ "version": "9.2.1",
23
+ "comments": {
24
+ "patch": [
25
+ {
26
+ "author": "bernardo.sunderhus@gmail.com",
27
+ "package": "@fluentui/react-aria",
28
+ "commit": "3b48ff5d92433635997aa69a59b138ec273172ea",
29
+ "comment": "chore: user defined tabIndex should prevail aria-button defined"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Fri, 23 Sep 2022 10:32:29 GMT",
36
+ "tag": "@fluentui/react-aria_v9.2.0",
37
+ "version": "9.2.0",
38
+ "comments": {
39
+ "none": [
40
+ {
41
+ "author": "bernardo.sunderhus@gmail.com",
42
+ "package": "@fluentui/react-aria",
43
+ "commit": "ce5f1ec6a0c0f766679ea708c40538fc2d56c6d9",
44
+ "comment": "chore: restructure folder organization"
45
+ }
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ "date": "Thu, 15 Sep 2022 09:49:48 GMT",
6
51
  "tag": "@fluentui/react-aria_v9.2.0",
7
52
  "version": "9.2.0",
8
53
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,30 @@
1
1
  # Change Log - @fluentui/react-aria
2
2
 
3
- This log was last generated on Thu, 15 Sep 2022 09:45:09 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 13 Oct 2022 10:59:42 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.2.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.2.2)
8
+
9
+ Thu, 13 Oct 2022 10:59:42 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.2.1..@fluentui/react-aria_v9.2.2)
11
+
12
+ ### Patches
13
+
14
+ - Bump @fluentui/react-utilities to v9.1.1 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
15
+
16
+ ## [9.2.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.2.1)
17
+
18
+ Mon, 03 Oct 2022 22:24:33 GMT
19
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.2.0..@fluentui/react-aria_v9.2.1)
20
+
21
+ ### Patches
22
+
23
+ - chore: user defined tabIndex should prevail aria-button defined ([PR #24962](https://github.com/microsoft/fluentui/pull/24962) by bernardo.sunderhus@gmail.com)
24
+
7
25
  ## [9.2.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.2.0)
8
26
 
9
- Thu, 15 Sep 2022 09:45:09 GMT
27
+ Thu, 15 Sep 2022 09:49:48 GMT
10
28
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.1.0..@fluentui/react-aria_v9.2.0)
11
29
 
12
30
  ### Minor changes
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["button/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC","sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"]}
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"../src/","sources":["button/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExtractSlotProps, Slot } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\ntype UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\nexport type ARIAButtonType = 'button' | 'a' | 'div';\n\n/**\n * @internal\n */\nexport type ARIAButtonElement<AlternateAs extends 'a' | 'div' = 'a' | 'div'> =\n | HTMLButtonElement\n | (AlternateAs extends 'a' ? HTMLAnchorElement : never)\n | (AlternateAs extends 'div' ? HTMLDivElement : never);\n\n/**\n * @internal\n */\nexport type ARIAButtonElementIntersection<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = UnionToIntersection<\n ARIAButtonElement<AlternateAs>\n>;\n\n/**\n * Props expected by `useARIAButtonProps` hooks\n */\nexport type ARIAButtonProps<Type extends ARIAButtonType = ARIAButtonType> = React.PropsWithRef<\n JSX.IntrinsicElements[Type]\n> & {\n disabled?: boolean;\n /**\n * When set, allows the button to be focusable even when it has been disabled.\n * This is used in scenarios where it is important to keep a consistent tab order\n * for screen reader and keyboard users. The primary example of this\n * pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.\n *\n * @default false\n */\n disabledFocusable?: boolean;\n};\n\nexport type ARIAButtonSlotProps<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = ExtractSlotProps<\n Slot<'button', AlternateAs>\n> &\n Pick<ARIAButtonProps<ARIAButtonType>, 'disabled' | 'disabledFocusable'>;\n\n/**\n * @internal\n * Props that will be modified internally by `useARIAButtonProps` by each case.\n * This typing is to ensure a well specified return value for `useARIAbButtonProps`\n */\nexport type ARIAButtonAlteredProps<Type extends ARIAButtonType> =\n | (Type extends 'button'\n ? Pick<\n JSX.IntrinsicElements['button'],\n 'onClick' | 'onKeyDown' | 'onKeyUp' | 'disabled' | 'aria-disabled' | 'tabIndex'\n >\n : never)\n | (Type extends 'a'\n ? Pick<\n JSX.IntrinsicElements['a'],\n 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role' | 'href'\n >\n : never)\n | (Type extends 'div'\n ? Pick<JSX.IntrinsicElements['div'], 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role'>\n : never);\n\n/**\n * Merge of props provided by the user and props provided internally.\n */\nexport type ARIAButtonResultProps<Type extends ARIAButtonType, Props> = Props &\n UnionToIntersection<ARIAButtonAlteredProps<Type>>;\n"]}
@@ -31,12 +31,11 @@ import { useEventCallback } from '@fluentui/react-utilities';
31
31
  export function useARIAButtonProps(type, props) {
32
32
  const {
33
33
  disabled,
34
- tabIndex,
35
34
  disabledFocusable = false,
35
+ ['aria-disabled']: ariaDisabled,
36
36
  onClick,
37
37
  onKeyDown,
38
38
  onKeyUp,
39
- ['aria-disabled']: ariaDisabled,
40
39
  ...rest
41
40
  } = props !== null && props !== void 0 ? props : {};
42
41
  const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;
@@ -96,7 +95,6 @@ export function useARIAButtonProps(type, props) {
96
95
 
97
96
  if (type === 'button' || type === undefined) {
98
97
  return { ...rest,
99
- tabIndex,
100
98
  disabled: disabled && !disabledFocusable,
101
99
  'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,
102
100
  // onclick should still use internal handler to ensure prevention if disabled
@@ -110,6 +108,7 @@ export function useARIAButtonProps(type, props) {
110
108
  else {
111
109
  const resultProps = {
112
110
  role: 'button',
111
+ tabIndex: disabled && !disabledFocusable ? undefined : 0,
113
112
  ...rest,
114
113
  // If it's not a <button> than listeners are required even with disabledFocusable
115
114
  // Since you cannot assure the default behavior of the element
@@ -117,8 +116,7 @@ export function useARIAButtonProps(type, props) {
117
116
  onClick: handleClick,
118
117
  onKeyUp: handleKeyUp,
119
118
  onKeyDown: handleKeyDown,
120
- 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,
121
- tabIndex: disabled && !disabledFocusable ? undefined : tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0
119
+ 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled
122
120
  };
123
121
 
124
122
  if (type === 'a' && isDisabled) {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["button/useARIAButtonProps.ts"],"names":[],"mappings":"AAAA,SAAS,KAAT,EAAgB,KAAhB,QAA6B,yBAA7B;AACA,SAAS,gBAAT,QAAiC,2BAAjC;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;;AACH,OAAM,SAAU,kBAAV,CACJ,IADI,EAEJ,KAFI,EAES;EAEb,MAAM;IAAE,QAAF;IAAY,iBAAiB,GAAG,KAAhC;IAAuC,CAAC,eAAD,GAAmB,YAA1D;IAAwE,OAAxE;IAAiF,SAAjF;IAA4F,OAA5F;IAAqG,GAAG;EAAxG,IACJ,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAA,KAAA,GAAS,EADX;EAGA,MAAM,sBAAsB,GAAG,OAAO,YAAP,KAAwB,QAAxB,GAAmC,YAAY,KAAK,MAApD,GAA6D,YAA5F;EAEA,MAAM,UAAU,GAAG,QAAQ,IAAI,iBAAZ,IAAiC,sBAApD;EAEA,MAAM,WAAW,GAAG,gBAAgB,CAAE,EAAD,IAAwD;IAC3F,IAAI,UAAJ,EAAgB;MACd,EAAE,CAAC,cAAH;MACA,EAAE,CAAC,eAAH;IACD,CAHD,MAGO;MACL,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAG,EAAH,CAAP;IACD;EACF,CAPmC,CAApC;EASA,MAAM,aAAa,GAAG,gBAAgB,CAAE,EAAD,IAA2D;IAChG,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAG,EAAH,CAAT;;IAEA,IAAI,EAAE,CAAC,kBAAH,EAAJ,EAA6B;MAC3B;IACD;;IAED,MAAM,GAAG,GAAG,EAAE,CA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,SAAH,GAAe;IARtC,CAAP;EAUD,CAXD,CAaA;EACA;EAdA,KAeK;IACH,MAAM,WAAW,GAAG;MAClB,IAAI,EAAE,QADY;MAElB,QAAQ,EAAE,QAAQ,IAAI,CAAC,iBAAb,GAAiC,SAAjC,GAA6C,CAFrC;MAGlB,GAAG,IAHe;MAIlB;MACA;MACA;MACA,OAAO,EAAE,WAPS;MAQlB,OAAO,EAAE,WARS;MASlB,SAAS,EAAE,aATO;MAUlB,iBAAiB,QAAQ,IAAI,iBAAZ,IAAiC;IAVhC,CAApB;;IAaA,IAAI,IAAI,KAAK,GAAT,IAAgB,UAApB,EAAgC;MAC7B,WAAiD,CAAC,IAAlD,GAAyD,SAAzD;IACF;;IAED,OAAO,WAAP;EACD;AACF","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type { ARIAButtonElementIntersection, ARIAButtonProps, ARIAButtonResultProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n *\n * @param type - the proper scenario to be interpreted by the hook.\n * 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states\n * 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior\n * @param props - the props to be passed down the line to the desired element.\n * This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.\n *\n * @example\n * ```tsx\n * const buttonProps = useARIAButtonProps('a', {\n * href: './some-route'\n * onClick: () => console.log('this should run both on click and Space and Enter')\n * })\n *\n * // ...\n *\n * return (\n * <a {...buttonProps}>This anchor will behave as a proper button</a>\n * )\n * ```\n */\nexport function useARIAButtonProps<Type extends ARIAButtonType, Props extends ARIAButtonProps<Type>>(\n type?: Type,\n props?: Props,\n): ARIAButtonResultProps<Type, Props> {\n const { disabled, disabledFocusable = false, ['aria-disabled']: ariaDisabled, onClick, onKeyDown, onKeyUp, ...rest } =\n props ?? {};\n\n const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;\n\n const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;\n\n const handleClick = useEventCallback((ev: React.MouseEvent<ARIAButtonElementIntersection>) => {\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const handleKeyDown = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n return;\n }\n\n // If enter is pressed, activate the button\n else if (key === Enter) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n const handleKeyUp = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (type === 'button' || type === undefined) {\n return {\n ...rest,\n disabled: disabled && !disabledFocusable,\n 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,\n // onclick should still use internal handler to ensure prevention if disabled\n // if disabledFocusable then there's no requirement for handlers as those events should not be propagated\n onClick: disabledFocusable ? undefined : handleClick,\n onKeyUp: disabledFocusable ? undefined : onKeyUp,\n onKeyDown: disabledFocusable ? undefined : onKeyDown,\n } as ARIAButtonResultProps<Type, Props>;\n }\n\n // If an <a> or <div> tag is to be rendered we have to remove disabled and type,\n // and set aria-disabled, role and tabIndex.\n else {\n const resultProps = {\n role: 'button',\n tabIndex: disabled && !disabledFocusable ? undefined : 0,\n ...rest,\n // If it's not a <button> than listeners are required even with disabledFocusable\n // Since you cannot assure the default behavior of the element\n // E.g: <a> will redirect on click\n onClick: handleClick,\n onKeyUp: handleKeyUp,\n onKeyDown: handleKeyDown,\n 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,\n } as ARIAButtonResultProps<Type, Props>;\n\n if (type === 'a' && isDisabled) {\n (resultProps as ARIAButtonResultProps<'a', Props>).href = undefined;\n }\n\n return resultProps;\n }\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["button/useARIAButtonShorthand.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,QAAiC,2BAAjC;AACA,SAAS,kBAAT,QAAmC,sBAAnC;AAIA;;;;;;;;AAQG;;AACH,OAAO,MAAM,sBAAsB,GAAkD,CAAC,IAAD,EAAO,OAAP,KAAkB;;;EACrG,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAD,EAAO,OAAP,CAAlC;EACA,MAAM,mBAAmB,GAAG,kBAAkB,CAAkC,CAAA,EAAA,GAAA,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAE,EAAX,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,EAAb,GAAiB,QAAnD,EAA6D,SAA7D,CAA9C;EACA,OAAO,SAAS,IAAI,mBAApB;AACD,CAJM","sourcesContent":["import { resolveShorthand } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from './useARIAButtonProps';\nimport type { ResolveShorthandFunction } from '@fluentui/react-utilities';\nimport type { ARIAButtonProps, ARIAButtonSlotProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n */\nexport const useARIAButtonShorthand: ResolveShorthandFunction<ARIAButtonSlotProps> = (slot, options) => {\n const shorthand = resolveShorthand(slot, options);\n const shorthandARIAButton = useARIAButtonProps<ARIAButtonType, ARIAButtonProps>(shorthand?.as ?? 'button', shorthand);\n return shorthand && shorthandARIAButton;\n};\n"],"sourceRoot":"../src/"}
package/lib/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { useARIAButtonShorthand, useARIAButtonProps } from './hooks/useARIAButton/index';
1
+ export { useARIAButtonShorthand, useARIAButtonProps } from './button/index';
2
2
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC","sourcesContent":["export { useARIAButtonShorthand, useARIAButtonProps } from './hooks/useARIAButton/index';\nexport type {\n ARIAButtonSlotProps,\n ARIAButtonProps,\n ARIAButtonResultProps,\n ARIAButtonType,\n ARIAButtonElement,\n ARIAButtonElementIntersection,\n} from './hooks/useARIAButton/index';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export { useARIAButtonShorthand, useARIAButtonProps } from './button/index';\nexport type {\n ARIAButtonSlotProps,\n ARIAButtonProps,\n ARIAButtonResultProps,\n ARIAButtonType,\n ARIAButtonElement,\n ARIAButtonElementIntersection,\n} from './button/index';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["button/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,0BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"],"sourceRoot":"../src/"}
@@ -40,12 +40,11 @@ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
40
40
  function useARIAButtonProps(type, props) {
41
41
  const {
42
42
  disabled,
43
- tabIndex,
44
43
  disabledFocusable = false,
44
+ ['aria-disabled']: ariaDisabled,
45
45
  onClick,
46
46
  onKeyDown,
47
47
  onKeyUp,
48
- ['aria-disabled']: ariaDisabled,
49
48
  ...rest
50
49
  } = props !== null && props !== void 0 ? props : {};
51
50
  const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;
@@ -105,7 +104,6 @@ function useARIAButtonProps(type, props) {
105
104
 
106
105
  if (type === 'button' || type === undefined) {
107
106
  return { ...rest,
108
- tabIndex,
109
107
  disabled: disabled && !disabledFocusable,
110
108
  'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,
111
109
  // onclick should still use internal handler to ensure prevention if disabled
@@ -119,6 +117,7 @@ function useARIAButtonProps(type, props) {
119
117
  else {
120
118
  const resultProps = {
121
119
  role: 'button',
120
+ tabIndex: disabled && !disabledFocusable ? undefined : 0,
122
121
  ...rest,
123
122
  // If it's not a <button> than listeners are required even with disabledFocusable
124
123
  // Since you cannot assure the default behavior of the element
@@ -126,8 +125,7 @@ function useARIAButtonProps(type, props) {
126
125
  onClick: handleClick,
127
126
  onKeyUp: handleKeyUp,
128
127
  onKeyDown: handleKeyDown,
129
- 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,
130
- tabIndex: disabled && !disabledFocusable ? undefined : tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0
128
+ 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled
131
129
  };
132
130
 
133
131
  if (type === 'a' && is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iB,GAAG,SAAH,GAAe,OAPpC;MAQL,SAAS,EAAE,iBAAiB,GAAG,SAAH,GAAe;IARtC,CAAP;EAUD,CAXD,CAaA;EACA;EAdA,KAeK;IACH,MAAM,WAAW,GAAG;MAClB,IAAI,EAAE,QADY;MAElB,QAAQ,EAAE,QAAQ,IAAI,CAAC,iBAAb,GAAiC,SAAjC,GAA6C,CAFrC;MAGlB,GAAG,IAHe;MAIlB;MACA;MACA;MACA,OAAO,EAAE,WAPS;MAQlB,OAAO,EAAE,WARS;MASlB,SAAS,EAAE,aATO;MAUlB,iBAAiB,QAAQ,IAAI,iBAAZ,IAAiC;IAVhC,CAApB;;IAaA,IAAI,IAAI,KAAK,GAAT,IAAgB,UAApB,EAAgC;MAC7B,WAAiD,CAAC,IAAlD,GAAyD,SAAzD;IACF;;IAED,OAAO,WAAP;EACD;AACF;;AAxGD,OAAA,CAAA,kBAAA,GAAA,kBAAA","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type { ARIAButtonElementIntersection, ARIAButtonProps, ARIAButtonResultProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n *\n * @param type - the proper scenario to be interpreted by the hook.\n * 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states\n * 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior\n * @param props - the props to be passed down the line to the desired element.\n * This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.\n *\n * @example\n * ```tsx\n * const buttonProps = useARIAButtonProps('a', {\n * href: './some-route'\n * onClick: () => console.log('this should run both on click and Space and Enter')\n * })\n *\n * // ...\n *\n * return (\n * <a {...buttonProps}>This anchor will behave as a proper button</a>\n * )\n * ```\n */\nexport function useARIAButtonProps<Type extends ARIAButtonType, Props extends ARIAButtonProps<Type>>(\n type?: Type,\n props?: Props,\n): ARIAButtonResultProps<Type, Props> {\n const { disabled, disabledFocusable = false, ['aria-disabled']: ariaDisabled, onClick, onKeyDown, onKeyUp, ...rest } =\n props ?? {};\n\n const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;\n\n const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;\n\n const handleClick = useEventCallback((ev: React.MouseEvent<ARIAButtonElementIntersection>) => {\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const handleKeyDown = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n return;\n }\n\n // If enter is pressed, activate the button\n else if (key === Enter) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n const handleKeyUp = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (type === 'button' || type === undefined) {\n return {\n ...rest,\n disabled: disabled && !disabledFocusable,\n 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,\n // onclick should still use internal handler to ensure prevention if disabled\n // if disabledFocusable then there's no requirement for handlers as those events should not be propagated\n onClick: disabledFocusable ? undefined : handleClick,\n onKeyUp: disabledFocusable ? undefined : onKeyUp,\n onKeyDown: disabledFocusable ? undefined : onKeyDown,\n } as ARIAButtonResultProps<Type, Props>;\n }\n\n // If an <a> or <div> tag is to be rendered we have to remove disabled and type,\n // and set aria-disabled, role and tabIndex.\n else {\n const resultProps = {\n role: 'button',\n tabIndex: disabled && !disabledFocusable ? undefined : 0,\n ...rest,\n // If it's not a <button> than listeners are required even with disabledFocusable\n // Since you cannot assure the default behavior of the element\n // E.g: <a> will redirect on click\n onClick: handleClick,\n onKeyUp: handleKeyUp,\n onKeyDown: handleKeyDown,\n 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,\n } as ARIAButtonResultProps<Type, Props>;\n\n if (type === 'a' && isDisabled) {\n (resultProps as ARIAButtonResultProps<'a', Props>).href = undefined;\n }\n\n return resultProps;\n }\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["button/useARIAButtonShorthand.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,oBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;AAIA;;;;;;;;AAQG;;;AACI,MAAM,sBAAsB,GAAkD,CAAC,IAAD,EAAO,OAAP,KAAkB;;;EACrG,MAAM,SAAS,GAAG,iBAAA,CAAA,gBAAA,CAAiB,IAAjB,EAAuB,OAAvB,CAAlB;EACA,MAAM,mBAAmB,GAAG,oBAAA,CAAA,kBAAA,CAAoD,CAAA,EAAA,GAAA,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAE,EAAX,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,EAAb,GAAiB,QAArE,EAA+E,SAA/E,CAA5B;EACA,OAAO,SAAS,IAAI,mBAApB;AACD,CAJM;;AAAM,OAAA,CAAA,sBAAA,GAAsB,sBAAtB","sourcesContent":["import { resolveShorthand } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from './useARIAButtonProps';\nimport type { ResolveShorthandFunction } from '@fluentui/react-utilities';\nimport type { ARIAButtonProps, ARIAButtonSlotProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n */\nexport const useARIAButtonShorthand: ResolveShorthandFunction<ARIAButtonSlotProps> = (slot, options) => {\n const shorthand = resolveShorthand(slot, options);\n const shorthandARIAButton = useARIAButtonProps<ARIAButtonType, ARIAButtonProps>(shorthand?.as ?? 'button', shorthand);\n return shorthand && shorthandARIAButton;\n};\n"],"sourceRoot":"../src/"}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useARIAButtonProps = exports.useARIAButtonShorthand = void 0;
7
7
 
8
- var index_1 = /*#__PURE__*/require("./hooks/useARIAButton/index");
8
+ var index_1 = /*#__PURE__*/require("./button/index");
9
9
 
10
10
  Object.defineProperty(exports, "useARIAButtonShorthand", {
11
11
  enumerable: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,OAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,wBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,sBAAA;EAAsB;AAAtB,CAAA;AAAwB,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,oBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,kBAAA;EAAkB;AAAlB,CAAA","sourcesContent":["export { useARIAButtonShorthand, useARIAButtonProps } from './hooks/useARIAButton/index';\nexport type {\n ARIAButtonSlotProps,\n ARIAButtonProps,\n ARIAButtonResultProps,\n ARIAButtonType,\n ARIAButtonElement,\n ARIAButtonElementIntersection,\n} from './hooks/useARIAButton/index';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,wBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,sBAAA;EAAsB;AAAtB,CAAA;AAAwB,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,oBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,kBAAA;EAAkB;AAAlB,CAAA","sourcesContent":["export { useARIAButtonShorthand, useARIAButtonProps } from './button/index';\nexport type {\n ARIAButtonSlotProps,\n ARIAButtonProps,\n ARIAButtonResultProps,\n ARIAButtonType,\n ARIAButtonElement,\n ARIAButtonElementIntersection,\n} from './button/index';\n"],"sourceRoot":"../src/"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-aria",
3
- "version": "9.2.0",
3
+ "version": "9.2.2",
4
4
  "description": "React helper to ensure ARIA",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@fluentui/keyboard-keys": "^9.0.0",
34
- "@fluentui/react-utilities": "^9.1.0",
34
+ "@fluentui/react-utilities": "^9.1.1",
35
35
  "tslib": "^2.1.0"
36
36
  },
37
37
  "peerDependencies": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["hooks/useARIAButton/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC","sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"../src/","sources":["hooks/useARIAButton/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExtractSlotProps, Slot } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\ntype UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\nexport type ARIAButtonType = 'button' | 'a' | 'div';\n\n/**\n * @internal\n */\nexport type ARIAButtonElement<AlternateAs extends 'a' | 'div' = 'a' | 'div'> =\n | HTMLButtonElement\n | (AlternateAs extends 'a' ? HTMLAnchorElement : never)\n | (AlternateAs extends 'div' ? HTMLDivElement : never);\n\n/**\n * @internal\n */\nexport type ARIAButtonElementIntersection<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = UnionToIntersection<\n ARIAButtonElement<AlternateAs>\n>;\n\n/**\n * Props expected by `useARIAButtonProps` hooks\n */\nexport type ARIAButtonProps<Type extends ARIAButtonType = ARIAButtonType> = React.PropsWithRef<\n JSX.IntrinsicElements[Type]\n> & {\n disabled?: boolean;\n /**\n * When set, allows the button to be focusable even when it has been disabled.\n * This is used in scenarios where it is important to keep a consistent tab order\n * for screen reader and keyboard users. The primary example of this\n * pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.\n *\n * @default false\n */\n disabledFocusable?: boolean;\n};\n\nexport type ARIAButtonSlotProps<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = ExtractSlotProps<\n Slot<'button', AlternateAs>\n> &\n Pick<ARIAButtonProps<ARIAButtonType>, 'disabled' | 'disabledFocusable'>;\n\n/**\n * @internal\n * Props that will be modified internally by `useARIAButtonProps` by each case.\n * This typing is to ensure a well specified return value for `useARIAbButtonProps`\n */\nexport type ARIAButtonAlteredProps<Type extends ARIAButtonType> =\n | (Type extends 'button'\n ? Pick<\n JSX.IntrinsicElements['button'],\n 'onClick' | 'onKeyDown' | 'onKeyUp' | 'disabled' | 'aria-disabled' | 'tabIndex'\n >\n : never)\n | (Type extends 'a'\n ? Pick<\n JSX.IntrinsicElements['a'],\n 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role' | 'href'\n >\n : never)\n | (Type extends 'div'\n ? Pick<JSX.IntrinsicElements['div'], 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role'>\n : never);\n\n/**\n * Merge of props provided by the user and props provided internally.\n */\nexport type ARIAButtonResultProps<Type extends ARIAButtonType, Props> = Props &\n UnionToIntersection<ARIAButtonAlteredProps<Type>>;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["hooks/useARIAButton/useARIAButtonProps.ts"],"names":[],"mappings":"AAAA,SAAS,KAAT,EAAgB,KAAhB,QAA6B,yBAA7B;AACA,SAAS,gBAAT,QAAiC,2BAAjC;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;;AACH,OAAM,SAAU,kBAAV,CACJ,IADI,EAEJ,KAFI,EAES;EAEb,MAAM;IACJ,QADI;IAEJ,QAFI;IAGJ,iBAAiB,GAAG,KAHhB;IAIJ,OAJI;IAKJ,SALI;IAMJ,OANI;IAOJ,CAAC,eAAD,GAAmB,YAPf;IAQJ,GAAG;EARC,IASF,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAA,KAAA,GAAS,EATb;EAWA,MAAM,sBAAsB,GAAG,OAAO,YAAP,KAAwB,QAAxB,GAAmC,YAAY,KAAK,MAApD,GAA6D,YAA5F;EAEA,MAAM,UAAU,GAAG,QAAQ,IAAI,iBAAZ,IAAiC,sBAApD;EAEA,MAAM,WAAW,GAAG,gBAAgB,CAAE,EAAD,IAAwD;IAC3F,IAAI,UAAJ,EAAgB;MACd,EAAE,CAAC,cAAH;MACA,EAAE,CAAC,eAAH;IACD,CAHD,MAGO;MACL,OAAO,KAAA,IAAP,IAAA,O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Eb;;EACA,IAAI,IAAI,KAAK,QAAT,IAAqB,IAAI,KAAK,SAAlC,EAA6C;IAC3C,OAAO,EACL,GAAG,IADE;MAEL,QAFK;MAGL,QAAQ,EAAE,QAAQ,IAAI,CAAC,iBAHlB;MAIL,iBAAiB,iBAAiB,GAAG,IAAH,GAAU,sBAJvC;MAKL;MACA;MACA,OAAO,EAAE,iBAAiB,GAAG,SAAH,GAAe,WAPpC;MAQL,OAAO,EAAE,iBAAiB,GAAG,SAAH,GAAe,OARpC;MASL,SAAS,EAAE,iBAAiB,GAAG,SAAH,GAAe;IATtC,CAAP;EAWD,CAZD,CAcA;EACA;EAfA,KAgBK;IACH,MAAM,WAAW,GAAG;MAClB,IAAI,EAAE,QADY;MAElB,GAAG,IAFe;MAGlB;MACA;MACA;MACA,OAAO,EAAE,WANS;MAOlB,OAAO,EAAE,WAPS;MAQlB,SAAS,EAAE,aARO;MASlB,iBAAiB,QAAQ,IAAI,iBAAZ,IAAiC,sBAThC;MAUlB,QAAQ,EAAE,QAAQ,IAAI,CAAC,iBAAb,GAAiC,SAAjC,GAA6C,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAA,QAAA,GAAY;IAVjD,CAApB;;IAaA,IAAI,IAAI,KAAK,GAAT,IAAgB,UAApB,EAAgC;MAC7B,WAAiD,CAAC,IAAlD,GAAyD,SAAzD;IACF;;IAED,OAAO,WAAP;EACD;AACF","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type { ARIAButtonElementIntersection, ARIAButtonProps, ARIAButtonResultProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n *\n * @param type - the proper scenario to be interpreted by the hook.\n * 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states\n * 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior\n * @param props - the props to be passed down the line to the desired element.\n * This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.\n *\n * @example\n * ```tsx\n * const buttonProps = useARIAButtonProps('a', {\n * href: './some-route'\n * onClick: () => console.log('this should run both on click and Space and Enter')\n * })\n *\n * // ...\n *\n * return (\n * <a {...buttonProps}>This anchor will behave as a proper button</a>\n * )\n * ```\n */\nexport function useARIAButtonProps<Type extends ARIAButtonType, Props extends ARIAButtonProps<Type>>(\n type?: Type,\n props?: Props,\n): ARIAButtonResultProps<Type, Props> {\n const {\n disabled,\n tabIndex,\n disabledFocusable = false,\n onClick,\n onKeyDown,\n onKeyUp,\n ['aria-disabled']: ariaDisabled,\n ...rest\n } = props ?? {};\n\n const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;\n\n const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;\n\n const handleClick = useEventCallback((ev: React.MouseEvent<ARIAButtonElementIntersection>) => {\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const handleKeyDown = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n return;\n }\n\n // If enter is pressed, activate the button\n else if (key === Enter) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n const handleKeyUp = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (type === 'button' || type === undefined) {\n return {\n ...rest,\n tabIndex,\n disabled: disabled && !disabledFocusable,\n 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,\n // onclick should still use internal handler to ensure prevention if disabled\n // if disabledFocusable then there's no requirement for handlers as those events should not be propagated\n onClick: disabledFocusable ? undefined : handleClick,\n onKeyUp: disabledFocusable ? undefined : onKeyUp,\n onKeyDown: disabledFocusable ? undefined : onKeyDown,\n } as ARIAButtonResultProps<Type, Props>;\n }\n\n // If an <a> or <div> tag is to be rendered we have to remove disabled and type,\n // and set aria-disabled, role and tabIndex.\n else {\n const resultProps = {\n role: 'button',\n ...rest,\n // If it's not a <button> than listeners are required even with disabledFocusable\n // Since you cannot assure the default behavior of the element\n // E.g: <a> will redirect on click\n onClick: handleClick,\n onKeyUp: handleKeyUp,\n onKeyDown: handleKeyDown,\n 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,\n tabIndex: disabled && !disabledFocusable ? undefined : tabIndex ?? 0,\n } as ARIAButtonResultProps<Type, Props>;\n\n if (type === 'a' && isDisabled) {\n (resultProps as ARIAButtonResultProps<'a', Props>).href = undefined;\n }\n\n return resultProps;\n }\n}\n"],"sourceRoot":"../src/"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["hooks/useARIAButton/useARIAButtonShorthand.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,QAAiC,2BAAjC;AACA,SAAS,kBAAT,QAAmC,sBAAnC;AAIA;;;;;;;;AAQG;;AACH,OAAO,MAAM,sBAAsB,GAAkD,CAAC,IAAD,EAAO,OAAP,KAAkB;;;EACrG,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAD,EAAO,OAAP,CAAlC;EACA,MAAM,mBAAmB,GAAG,kBAAkB,CAAkC,CAAA,EAAA,GAAA,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAE,EAAX,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,EAAb,GAAiB,QAAnD,EAA6D,SAA7D,CAA9C;EACA,OAAO,SAAS,IAAI,mBAApB;AACD,CAJM","sourcesContent":["import { resolveShorthand } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from './useARIAButtonProps';\nimport type { ResolveShorthandFunction } from '@fluentui/react-utilities';\nimport type { ARIAButtonProps, ARIAButtonSlotProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n */\nexport const useARIAButtonShorthand: ResolveShorthandFunction<ARIAButtonSlotProps> = (slot, options) => {\n const shorthand = resolveShorthand(slot, options);\n const shorthandARIAButton = useARIAButtonProps<ARIAButtonType, ARIAButtonProps>(shorthand?.as ?? 'button', shorthand);\n return shorthand && shorthandARIAButton;\n};\n"],"sourceRoot":"../src/"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["hooks/useARIAButton/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,0BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"],"sourceRoot":"../src/"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["hooks/useARIAButton/useARIAButtonProps.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;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ACH,MAAM,WAAW,GAAG;MAClB,IAAI,EAAE,QADY;MAElB,GAAG,IAFe;MAGlB;MACA;MACA;MACA,OAAO,EAAE,WANS;MAOlB,OAAO,EAAE,WAPS;MAQlB,SAAS,EAAE,aARO;MASlB,iBAAiB,QAAQ,IAAI,iBAAZ,IAAiC,sBAThC;MAUlB,QAAQ,EAAE,QAAQ,IAAI,CAAC,iBAAb,GAAiC,SAAjC,GAA6C,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAA,QAAA,GAAY;IAVjD,CAApB;;IAaA,IAAI,IAAI,KAAK,GAAT,IAAgB,UAApB,EAAgC;MAC7B,WAAiD,CAAC,IAAlD,GAAyD,SAAzD;IACF;;IAED,OAAO,WAAP;EACD;AACF;;AAjHD,OAAA,CAAA,kBAAA,GAAA,kBAAA","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type { ARIAButtonElementIntersection, ARIAButtonProps, ARIAButtonResultProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n *\n * @param type - the proper scenario to be interpreted by the hook.\n * 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states\n * 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior\n * @param props - the props to be passed down the line to the desired element.\n * This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.\n *\n * @example\n * ```tsx\n * const buttonProps = useARIAButtonProps('a', {\n * href: './some-route'\n * onClick: () => console.log('this should run both on click and Space and Enter')\n * })\n *\n * // ...\n *\n * return (\n * <a {...buttonProps}>This anchor will behave as a proper button</a>\n * )\n * ```\n */\nexport function useARIAButtonProps<Type extends ARIAButtonType, Props extends ARIAButtonProps<Type>>(\n type?: Type,\n props?: Props,\n): ARIAButtonResultProps<Type, Props> {\n const {\n disabled,\n tabIndex,\n disabledFocusable = false,\n onClick,\n onKeyDown,\n onKeyUp,\n ['aria-disabled']: ariaDisabled,\n ...rest\n } = props ?? {};\n\n const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;\n\n const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;\n\n const handleClick = useEventCallback((ev: React.MouseEvent<ARIAButtonElementIntersection>) => {\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const handleKeyDown = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n return;\n }\n\n // If enter is pressed, activate the button\n else if (key === Enter) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n const handleKeyUp = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (type === 'button' || type === undefined) {\n return {\n ...rest,\n tabIndex,\n disabled: disabled && !disabledFocusable,\n 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,\n // onclick should still use internal handler to ensure prevention if disabled\n // if disabledFocusable then there's no requirement for handlers as those events should not be propagated\n onClick: disabledFocusable ? undefined : handleClick,\n onKeyUp: disabledFocusable ? undefined : onKeyUp,\n onKeyDown: disabledFocusable ? undefined : onKeyDown,\n } as ARIAButtonResultProps<Type, Props>;\n }\n\n // If an <a> or <div> tag is to be rendered we have to remove disabled and type,\n // and set aria-disabled, role and tabIndex.\n else {\n const resultProps = {\n role: 'button',\n ...rest,\n // If it's not a <button> than listeners are required even with disabledFocusable\n // Since you cannot assure the default behavior of the element\n // E.g: <a> will redirect on click\n onClick: handleClick,\n onKeyUp: handleKeyUp,\n onKeyDown: handleKeyDown,\n 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,\n tabIndex: disabled && !disabledFocusable ? undefined : tabIndex ?? 0,\n } as ARIAButtonResultProps<Type, Props>;\n\n if (type === 'a' && isDisabled) {\n (resultProps as ARIAButtonResultProps<'a', Props>).href = undefined;\n }\n\n return resultProps;\n }\n}\n"],"sourceRoot":"../src/"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["hooks/useARIAButton/useARIAButtonShorthand.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,oBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;AAIA;;;;;;;;AAQG;;;AACI,MAAM,sBAAsB,GAAkD,CAAC,IAAD,EAAO,OAAP,KAAkB;;;EACrG,MAAM,SAAS,GAAG,iBAAA,CAAA,gBAAA,CAAiB,IAAjB,EAAuB,OAAvB,CAAlB;EACA,MAAM,mBAAmB,GAAG,oBAAA,CAAA,kBAAA,CAAoD,CAAA,EAAA,GAAA,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAE,EAAX,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,EAAb,GAAiB,QAArE,EAA+E,SAA/E,CAA5B;EACA,OAAO,SAAS,IAAI,mBAApB;AACD,CAJM;;AAAM,OAAA,CAAA,sBAAA,GAAsB,sBAAtB","sourcesContent":["import { resolveShorthand } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from './useARIAButtonProps';\nimport type { ResolveShorthandFunction } from '@fluentui/react-utilities';\nimport type { ARIAButtonProps, ARIAButtonSlotProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n */\nexport const useARIAButtonShorthand: ResolveShorthandFunction<ARIAButtonSlotProps> = (slot, options) => {\n const shorthand = resolveShorthand(slot, options);\n const shorthandARIAButton = useARIAButtonProps<ARIAButtonType, ARIAButtonProps>(shorthand?.as ?? 'button', shorthand);\n return shorthand && shorthandARIAButton;\n};\n"],"sourceRoot":"../src/"}