@fluentui/react-aria 9.0.0 → 9.1.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 CHANGED
@@ -2,7 +2,74 @@
2
2
  "name": "@fluentui/react-aria",
3
3
  "entries": [
4
4
  {
5
- "date": "Tue, 28 Jun 2022 15:09:25 GMT",
5
+ "date": "Wed, 03 Aug 2022 16:00:04 GMT",
6
+ "tag": "@fluentui/react-aria_v9.1.0",
7
+ "version": "9.1.0",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "author": "lingfangao@hotmail.com",
12
+ "package": "@fluentui/react-aria",
13
+ "commit": "99cc385631d04a76ee10ebc143cb9fecd99640b6",
14
+ "comment": "chore: Add `prerelease` as disallowed changetype for 9.0.0 packages"
15
+ }
16
+ ],
17
+ "patch": [
18
+ {
19
+ "author": "bernardo.sunderhus@gmail.com",
20
+ "package": "@fluentui/react-aria",
21
+ "commit": "a0e1e0c2780ad6ba73aaeee1aa1525168a4d4045",
22
+ "comment": "feat: treats aria-disabled as disabled state on useARIAButtonProps"
23
+ }
24
+ ],
25
+ "minor": [
26
+ {
27
+ "author": "bernardo.sunderhus@gmail.com",
28
+ "package": "@fluentui/react-aria",
29
+ "commit": "1293f53f79ea1dc7429f77e174b2dfdaffa99558",
30
+ "comment": "chore: Splits useARIAButton into useARIAButtonProps and useARIAButtonShorthand."
31
+ }
32
+ ]
33
+ }
34
+ },
35
+ {
36
+ "date": "Thu, 14 Jul 2022 21:21:08 GMT",
37
+ "tag": "@fluentui/react-aria_v9.0.2",
38
+ "version": "9.0.2",
39
+ "comments": {
40
+ "patch": [
41
+ {
42
+ "author": "Humberto.Morimoto@microsoft.com",
43
+ "package": "@fluentui/react-aria",
44
+ "commit": "802bc4e3730a88b0fc61b5bf42ef7fc6b6543fe2",
45
+ "comment": "fix: Fixing bad version bump of @fluentui/react-utilities."
46
+ },
47
+ {
48
+ "author": "beachball",
49
+ "package": "@fluentui/react-aria",
50
+ "comment": "Bump @fluentui/react-utilities to v9.0.2",
51
+ "commit": "79b513146194367544160f364b0a7dd749ed93e4"
52
+ }
53
+ ]
54
+ }
55
+ },
56
+ {
57
+ "date": "Thu, 14 Jul 2022 17:06:26 GMT",
58
+ "tag": "@fluentui/react-aria_v9.0.1",
59
+ "version": "9.0.1",
60
+ "comments": {
61
+ "patch": [
62
+ {
63
+ "author": "beachball",
64
+ "package": "@fluentui/react-aria",
65
+ "comment": "Bump @fluentui/react-utilities to v9.0.1-0",
66
+ "commit": "35237381e941c8935b1892c9217096cea3e5601f"
67
+ }
68
+ ]
69
+ }
70
+ },
71
+ {
72
+ "date": "Tue, 28 Jun 2022 15:14:13 GMT",
6
73
  "tag": "@fluentui/react-aria_v9.0.0",
7
74
  "version": "9.0.0",
8
75
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,44 @@
1
1
  # Change Log - @fluentui/react-aria
2
2
 
3
- This log was last generated on Tue, 28 Jun 2022 15:09:25 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 03 Aug 2022 16:00:04 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.1.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.1.0)
8
+
9
+ Wed, 03 Aug 2022 16:00:04 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.0.2..@fluentui/react-aria_v9.1.0)
11
+
12
+ ### Minor changes
13
+
14
+ - chore: Splits useARIAButton into useARIAButtonProps and useARIAButtonShorthand. ([PR #24032](https://github.com/microsoft/fluentui/pull/24032) by bernardo.sunderhus@gmail.com)
15
+
16
+ ### Patches
17
+
18
+ - feat: treats aria-disabled as disabled state on useARIAButtonProps ([PR #24197](https://github.com/microsoft/fluentui/pull/24197) by bernardo.sunderhus@gmail.com)
19
+
20
+ ## [9.0.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.0.2)
21
+
22
+ Thu, 14 Jul 2022 21:21:08 GMT
23
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.0.1..@fluentui/react-aria_v9.0.2)
24
+
25
+ ### Patches
26
+
27
+ - fix: Fixing bad version bump of @fluentui/react-utilities. ([PR #23920](https://github.com/microsoft/fluentui/pull/23920) by Humberto.Morimoto@microsoft.com)
28
+ - Bump @fluentui/react-utilities to v9.0.2 ([PR #23918](https://github.com/microsoft/fluentui/pull/23918) by beachball)
29
+
30
+ ## [9.0.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.0.1)
31
+
32
+ Thu, 14 Jul 2022 17:06:26 GMT
33
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.0.0..@fluentui/react-aria_v9.0.1)
34
+
35
+ ### Patches
36
+
37
+ - Bump @fluentui/react-utilities to v9.0.1-0 ([PR #23897](https://github.com/microsoft/fluentui/pull/23897) by beachball)
38
+
7
39
  ## [9.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.0.0)
8
40
 
9
- Tue, 28 Jun 2022 15:09:25 GMT
41
+ Tue, 28 Jun 2022 15:14:13 GMT
10
42
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.0.0-rc.10..@fluentui/react-aria_v9.0.0)
11
43
 
12
44
  ### Patches
package/dist/index.d.ts CHANGED
@@ -1,26 +1,41 @@
1
1
  import type { ExtractSlotProps } from '@fluentui/react-utilities';
2
+ import * as React_2 from 'react';
2
3
  import type { ResolveShorthandFunction } from '@fluentui/react-utilities';
3
4
  import type { Slot } from '@fluentui/react-utilities';
4
5
 
5
- export declare type ARIAButtonSlotProps = ExtractSlotProps<Slot<'button', 'a'>> & {
6
+ export declare type ARIAButtonProps<Type extends 'a' | 'div' | 'button' = 'a' | 'div' | 'button'> = React_2.PropsWithRef<JSX.IntrinsicElements[Type]> & Pick<ARIAButtonSlotProps, 'disabled' | 'disabledFocusable'>;
7
+
8
+ export declare type ARIAButtonSlotProps<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = ExtractSlotProps<Slot<'button', AlternateAs>> & {
6
9
  disabled?: boolean;
10
+ /**
11
+ * When set, allows the button to be focusable even when it has been disabled.
12
+ * This is used in scenarios where it is important to keep a consistent tab order
13
+ * for screen reader and keyboard users. The primary example of this
14
+ * pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.
15
+ *
16
+ * @default false
17
+ */
7
18
  disabledFocusable?: boolean;
8
19
  };
9
20
 
10
21
  /**
11
22
  * @internal
12
- * Merges disabled declaration with `aria-disabled`
23
+ *
24
+ * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
25
+ * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
26
+ * where no attribute addition is required.
13
27
  */
14
- export declare function mergeARIADisabled(shorthand: {
15
- 'aria-disabled'?: string | boolean;
16
- disabled?: boolean;
17
- }): boolean;
28
+ export declare function useARIAButtonProps<Type extends NonNullable<ARIAButtonSlotProps['as']>>(type?: Type, props?: ARIAButtonProps): React_2.PropsWithRef<JSX.IntrinsicElements[Type]>;
18
29
 
19
30
  /**
31
+ * @internal
32
+ *
33
+ * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead
34
+ *
20
35
  * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
21
36
  * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
22
37
  * where no attribute addition is required.
23
38
  */
24
- export declare const useARIAButton: ResolveShorthandFunction<ARIAButtonSlotProps>;
39
+ export declare const useARIAButtonShorthand: ResolveShorthandFunction<ARIAButtonSlotProps>;
25
40
 
26
41
  export { }
@@ -1,32 +1,35 @@
1
1
  import { Enter, Space } from '@fluentui/keyboard-keys';
2
2
  import { resolveShorthand, useEventCallback } from '@fluentui/react-utilities';
3
3
  /**
4
+ * @internal
5
+ *
4
6
  * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
5
7
  * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
6
8
  * where no attribute addition is required.
7
9
  */
8
10
 
9
- export const useARIAButton = (shorthand, options) => {
10
- var _a;
11
-
12
- const shorthandProps = resolveShorthand(shorthand, options);
11
+ export function useARIAButtonProps(type, props) {
13
12
  const {
14
13
  disabled,
15
- disabledFocusable,
14
+ tabIndex,
15
+ disabledFocusable = false,
16
16
  onClick,
17
17
  onKeyDown,
18
18
  onKeyUp,
19
- tabIndex
20
- } = shorthandProps || {};
21
- const onClickHandler = useEventCallback(ev => {
22
- if (disabled || disabledFocusable) {
19
+ ['aria-disabled']: ariaDisabled,
20
+ ...rest
21
+ } = props !== null && props !== void 0 ? props : {};
22
+ const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;
23
+ const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;
24
+ const handleClick = useEventCallback(ev => {
25
+ if (isDisabled) {
23
26
  ev.preventDefault();
24
27
  ev.stopPropagation();
25
28
  } else {
26
29
  onClick === null || onClick === void 0 ? void 0 : onClick(ev);
27
30
  }
28
31
  });
29
- const onKeyDownHandler = useEventCallback(ev => {
32
+ const handleKeyDown = useEventCallback(ev => {
30
33
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(ev);
31
34
 
32
35
  if (ev.isDefaultPrevented()) {
@@ -35,7 +38,7 @@ export const useARIAButton = (shorthand, options) => {
35
38
 
36
39
  const key = ev.key;
37
40
 
38
- if ((disabled || disabledFocusable) && (key === Enter || key === Space)) {
41
+ if (isDisabled && (key === Enter || key === Space)) {
39
42
  ev.preventDefault();
40
43
  ev.stopPropagation();
41
44
  return;
@@ -50,7 +53,7 @@ export const useARIAButton = (shorthand, options) => {
50
53
  ev.currentTarget.click();
51
54
  }
52
55
  });
53
- const onKeyupHandler = useEventCallback(ev => {
56
+ const handleKeyUp = useEventCallback(ev => {
54
57
  onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(ev);
55
58
 
56
59
  if (ev.isDefaultPrevented()) {
@@ -59,7 +62,7 @@ export const useARIAButton = (shorthand, options) => {
59
62
 
60
63
  const key = ev.key;
61
64
 
62
- if ((disabled || disabledFocusable) && (key === Enter || key === Space)) {
65
+ if (isDisabled && (key === Enter || key === Space)) {
63
66
  ev.preventDefault();
64
67
  ev.stopPropagation();
65
68
  return;
@@ -69,35 +72,57 @@ export const useARIAButton = (shorthand, options) => {
69
72
  ev.preventDefault();
70
73
  ev.currentTarget.click();
71
74
  }
72
- });
75
+ }); // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly
73
76
 
74
- if (shorthandProps) {
75
- // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly
76
- if (shorthandProps.as === 'button' || shorthandProps.as === undefined) {
77
- shorthandProps.disabled = disabled && !disabledFocusable;
78
- shorthandProps['aria-disabled'] = disabledFocusable ? true : undefined; // Undefine events if disabledFocusable is passed in
79
-
80
- if (disabledFocusable) {
81
- shorthandProps.onClick = undefined;
82
- shorthandProps.onKeyDown = undefined;
83
- shorthandProps.onKeyUp = undefined;
84
- }
85
- } // If an <a> tag is to be rendered we have to remove disabled and type, and set aria-disabled, role and tabIndex.
86
- else {
87
- delete shorthandProps.disabled;
88
- shorthandProps['aria-disabled'] = disabled || disabledFocusable;
89
- shorthandProps.href = disabled ? undefined : shorthandProps.href;
90
- shorthandProps.onClick = onClickHandler;
91
- shorthandProps.onKeyDown = onKeyDownHandler;
92
- shorthandProps.onKeyUp = onKeyupHandler;
93
- shorthandProps.role = (_a = shorthandProps.role) !== null && _a !== void 0 ? _a : 'button';
94
- shorthandProps.tabIndex = disabled && !disabledFocusable ? undefined : tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0;
95
- } // Remove non-DOM disabledFocusable prop
77
+ if (type === 'button' || type === undefined) {
78
+ return { ...rest,
79
+ tabIndex,
80
+ disabled: disabled && !disabledFocusable,
81
+ 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,
82
+ // onclick should still use internal handler to ensure prevention if disabled
83
+ // if disabledFocusable then there's no requirement for handlers as those events should not be propagated
84
+ onClick: disabledFocusable ? undefined : handleClick,
85
+ onKeyUp: disabledFocusable ? undefined : onKeyUp,
86
+ onKeyDown: disabledFocusable ? undefined : onKeyDown
87
+ };
88
+ } // If an <a> or <div> tag is to be rendered we have to remove disabled and type,
89
+ // and set aria-disabled, role and tabIndex.
90
+ else {
91
+ const nextProps = {
92
+ role: 'button',
93
+ ...rest,
94
+ // If it's not a <button> than listeners are required even with disabledFocusable
95
+ // Since you cannot assure the default behavior of the element
96
+ // E.g: <a> will redirect on click
97
+ onClick: handleClick,
98
+ onKeyUp: handleKeyUp,
99
+ onKeyDown: handleKeyDown,
100
+ 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,
101
+ tabIndex: disabled && !disabledFocusable ? undefined : tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0
102
+ };
96
103
 
104
+ if (type === 'a' && isDisabled) {
105
+ nextProps.href = undefined;
106
+ }
97
107
 
98
- delete shorthandProps.disabledFocusable;
108
+ return nextProps;
99
109
  }
110
+ }
111
+ /**
112
+ * @internal
113
+ *
114
+ * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead
115
+ *
116
+ * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
117
+ * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
118
+ * where no attribute addition is required.
119
+ */
120
+
121
+ export const useARIAButtonShorthand = (slot, options) => {
122
+ var _a;
100
123
 
101
- return shorthandProps;
124
+ const shorthand = resolveShorthand(slot, options);
125
+ const shorthandARIAButton = useARIAButtonProps((_a = shorthand === null || shorthand === void 0 ? void 0 : shorthand.as) !== null && _a !== void 0 ? _a : 'button', shorthand);
126
+ return shorthand && shorthandARIAButton;
102
127
  };
103
128
  //# sourceMappingURL=useARIAButton.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["hooks/useARIAButton.ts"],"names":[],"mappings":"AAAA,SAAS,KAAT,EAAgB,K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AAC,SAAf,GAA2B,gBAA3B;MACA,cAAc,CAAC,OAAf,GAAyB,cAAzB;MACA,cAAc,CAAC,IAAf,GAAsB,CAAA,EAAA,GAAA,cAAc,CAAC,IAAf,MAAmB,IAAnB,IAAmB,EAAA,KAAA,KAAA,CAAnB,GAAmB,EAAnB,GAAuB,QAA7C;MACA,cAAc,CAAC,QAAf,GAA0B,QAAQ,IAAI,CAAC,iBAAb,GAAiC,SAAjC,GAA6C,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAA,QAAA,GAAY,CAAnF;IACD,CA1BiB,CA4BlB;;;IACA,OAAO,cAAc,CAAC,iBAAtB;EACD;;EAED,OAAO,cAAP;AACD,CAhGM","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { resolveShorthand, useEventCallback } from '@fluentui/react-utilities';\nimport type { ExtractSlotProps, ResolveShorthandFunction, Slot } from '@fluentui/react-utilities';\n\nexport type ARIAButtonSlotProps = ExtractSlotProps<Slot<'button', 'a'>> & {\n disabled?: boolean;\n disabledFocusable?: boolean;\n};\n\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 useARIAButton: ResolveShorthandFunction<ARIAButtonSlotProps> = (shorthand, options) => {\n const shorthandProps = resolveShorthand(shorthand, options);\n\n const { disabled, disabledFocusable, onClick, onKeyDown, onKeyUp, tabIndex } = (shorthandProps ||\n {}) as ARIAButtonSlotProps;\n\n const onClickHandler: ARIAButtonSlotProps['onClick'] = useEventCallback(ev => {\n if (disabled || disabledFocusable) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const onKeyDownHandler: ARIAButtonSlotProps['onKeyDown'] = useEventCallback(ev => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if ((disabled || disabledFocusable) && (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 onKeyupHandler: ARIAButtonSlotProps['onKeyUp'] = useEventCallback(ev => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if ((disabled || disabledFocusable) && (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 (shorthandProps) {\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (shorthandProps.as === 'button' || shorthandProps.as === undefined) {\n shorthandProps.disabled = disabled && !disabledFocusable;\n shorthandProps['aria-disabled'] = disabledFocusable ? true : undefined;\n\n // Undefine events if disabledFocusable is passed in\n if (disabledFocusable) {\n shorthandProps.onClick = undefined;\n shorthandProps.onKeyDown = undefined;\n shorthandProps.onKeyUp = undefined;\n }\n }\n\n // If an <a> tag is to be rendered we have to remove disabled and type, and set aria-disabled, role and tabIndex.\n else {\n delete shorthandProps.disabled;\n shorthandProps['aria-disabled'] = disabled || disabledFocusable;\n (shorthandProps as JSX.IntrinsicElements['a']).href = disabled\n ? undefined\n : (shorthandProps as JSX.IntrinsicElements['a']).href;\n shorthandProps.onClick = onClickHandler;\n shorthandProps.onKeyDown = onKeyDownHandler;\n shorthandProps.onKeyUp = onKeyupHandler;\n shorthandProps.role = shorthandProps.role ?? 'button';\n shorthandProps.tabIndex = disabled && !disabledFocusable ? undefined : tabIndex ?? 0;\n }\n\n // Remove non-DOM disabledFocusable prop\n delete shorthandProps.disabledFocusable;\n }\n\n return shorthandProps;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["hooks/useARIAButton.ts"],"names":[],"mappings":"AAAA,SAAS,KAAT,EAAgB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AE,WAPO;MAQhB,SAAS,EAAE,aARK;MAShB,iBAAiB,QAAQ,IAAI,iBAAZ,IAAiC,sBATlC;MAUhB,QAAQ,EAAE,QAAQ,IAAI,CAAC,iBAAb,GAAiC,SAAjC,GAA6C,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAA,QAAA,GAAY;IAVnD,CAAlB;;IAaA,IAAI,IAAI,KAAK,GAAT,IAAgB,UAApB,EAAgC;MAC7B,SAAwC,CAAC,IAAzC,GAAgD,SAAhD;IACF;;IAED,OAAO,SAAP;EACD;AACF;AAED;;;;;;;;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,CAAC,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,QAAlB,EAA4B,SAA5B,CAA9C;EACA,OAAO,SAAS,IAAI,mBAApB;AACD,CAJM","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { resolveShorthand, useEventCallback } from '@fluentui/react-utilities';\nimport type { ExtractSlotProps, ResolveShorthandFunction, Slot } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nexport type ARIAButtonSlotProps<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = ExtractSlotProps<\n Slot<'button', AlternateAs>\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 ARIAButtonProps<Type extends 'a' | 'div' | 'button' = 'a' | 'div' | 'button'> = React.PropsWithRef<\n JSX.IntrinsicElements[Type]\n> &\n Pick<ARIAButtonSlotProps, 'disabled' | 'disabledFocusable'>;\n\n/**\n * @internal\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 function useARIAButtonProps<Type extends NonNullable<ARIAButtonSlotProps['as']>>(\n type?: Type,\n props?: ARIAButtonProps,\n): React.PropsWithRef<JSX.IntrinsicElements[Type]> {\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: ARIAButtonProps['onClick'] = useEventCallback(ev => {\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const handleKeyDown: ARIAButtonProps['onKeyDown'] = useEventCallback(ev => {\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: ARIAButtonProps['onKeyUp'] = useEventCallback(ev => {\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 React.PropsWithRef<JSX.IntrinsicElements[Type]>;\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 nextProps = {\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 React.PropsWithRef<JSX.IntrinsicElements[Type]>;\n\n if (type === 'a' && isDisabled) {\n (nextProps as JSX.IntrinsicElements['a']).href = undefined;\n }\n\n return nextProps;\n }\n}\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(shorthand?.as ?? 'button', shorthand);\n return shorthand && shorthandARIAButton;\n};\n"],"sourceRoot":"../src/"}
package/lib/index.js CHANGED
@@ -1,3 +1,2 @@
1
- export { useARIAButton } from './hooks/index';
2
- export { mergeARIADisabled } from './utils/index';
1
+ export { useARIAButtonShorthand, useARIAButtonProps } from './hooks/index';
3
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,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC","sourcesContent":["export { useARIAButton } from './hooks/index';\nexport type { ARIAButtonSlotProps } from './hooks/index';\nexport { mergeARIADisabled } from './utils/index';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC","sourcesContent":["export { useARIAButtonShorthand, useARIAButtonProps } from './hooks/index';\nexport type { ARIAButtonSlotProps, ARIAButtonProps } from './hooks/index';\n"]}
@@ -3,39 +3,42 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useARIAButton = void 0;
6
+ exports.useARIAButtonShorthand = exports.useARIAButtonProps = void 0;
7
7
 
8
8
  const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
9
9
 
10
10
  const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
11
  /**
12
+ * @internal
13
+ *
12
14
  * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
13
15
  * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
14
16
  * where no attribute addition is required.
15
17
  */
16
18
 
17
19
 
18
- const useARIAButton = (shorthand, options) => {
19
- var _a;
20
-
21
- const shorthandProps = react_utilities_1.resolveShorthand(shorthand, options);
20
+ function useARIAButtonProps(type, props) {
22
21
  const {
23
22
  disabled,
24
- disabledFocusable,
23
+ tabIndex,
24
+ disabledFocusable = false,
25
25
  onClick,
26
26
  onKeyDown,
27
27
  onKeyUp,
28
- tabIndex
29
- } = shorthandProps || {};
30
- const onClickHandler = react_utilities_1.useEventCallback(ev => {
31
- if (disabled || disabledFocusable) {
28
+ ['aria-disabled']: ariaDisabled,
29
+ ...rest
30
+ } = props !== null && props !== void 0 ? props : {};
31
+ const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;
32
+ const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;
33
+ const handleClick = react_utilities_1.useEventCallback(ev => {
34
+ if (isDisabled) {
32
35
  ev.preventDefault();
33
36
  ev.stopPropagation();
34
37
  } else {
35
38
  onClick === null || onClick === void 0 ? void 0 : onClick(ev);
36
39
  }
37
40
  });
38
- const onKeyDownHandler = react_utilities_1.useEventCallback(ev => {
41
+ const handleKeyDown = react_utilities_1.useEventCallback(ev => {
39
42
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(ev);
40
43
 
41
44
  if (ev.isDefaultPrevented()) {
@@ -44,7 +47,7 @@ const useARIAButton = (shorthand, options) => {
44
47
 
45
48
  const key = ev.key;
46
49
 
47
- if ((disabled || disabledFocusable) && (key === keyboard_keys_1.Enter || key === keyboard_keys_1.Space)) {
50
+ if (isDisabled && (key === keyboard_keys_1.Enter || key === keyboard_keys_1.Space)) {
48
51
  ev.preventDefault();
49
52
  ev.stopPropagation();
50
53
  return;
@@ -59,7 +62,7 @@ const useARIAButton = (shorthand, options) => {
59
62
  ev.currentTarget.click();
60
63
  }
61
64
  });
62
- const onKeyupHandler = react_utilities_1.useEventCallback(ev => {
65
+ const handleKeyUp = react_utilities_1.useEventCallback(ev => {
63
66
  onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(ev);
64
67
 
65
68
  if (ev.isDefaultPrevented()) {
@@ -68,7 +71,7 @@ const useARIAButton = (shorthand, options) => {
68
71
 
69
72
  const key = ev.key;
70
73
 
71
- if ((disabled || disabledFocusable) && (key === keyboard_keys_1.Enter || key === keyboard_keys_1.Space)) {
74
+ if (isDisabled && (key === keyboard_keys_1.Enter || key === keyboard_keys_1.Space)) {
72
75
  ev.preventDefault();
73
76
  ev.stopPropagation();
74
77
  return;
@@ -78,37 +81,61 @@ const useARIAButton = (shorthand, options) => {
78
81
  ev.preventDefault();
79
82
  ev.currentTarget.click();
80
83
  }
81
- });
84
+ }); // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly
85
+
86
+ if (type === 'button' || type === undefined) {
87
+ return { ...rest,
88
+ tabIndex,
89
+ disabled: disabled && !disabledFocusable,
90
+ 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,
91
+ // onclick should still use internal handler to ensure prevention if disabled
92
+ // if disabledFocusable then there's no requirement for handlers as those events should not be propagated
93
+ onClick: disabledFocusable ? undefined : handleClick,
94
+ onKeyUp: disabledFocusable ? undefined : onKeyUp,
95
+ onKeyDown: disabledFocusable ? undefined : onKeyDown
96
+ };
97
+ } // If an <a> or <div> tag is to be rendered we have to remove disabled and type,
98
+ // and set aria-disabled, role and tabIndex.
99
+ else {
100
+ const nextProps = {
101
+ role: 'button',
102
+ ...rest,
103
+ // If it's not a <button> than listeners are required even with disabledFocusable
104
+ // Since you cannot assure the default behavior of the element
105
+ // E.g: <a> will redirect on click
106
+ onClick: handleClick,
107
+ onKeyUp: handleKeyUp,
108
+ onKeyDown: handleKeyDown,
109
+ 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,
110
+ tabIndex: disabled && !disabledFocusable ? undefined : tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0
111
+ };
112
+
113
+ if (type === 'a' && isDisabled) {
114
+ nextProps.href = undefined;
115
+ }
82
116
 
83
- if (shorthandProps) {
84
- // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly
85
- if (shorthandProps.as === 'button' || shorthandProps.as === undefined) {
86
- shorthandProps.disabled = disabled && !disabledFocusable;
87
- shorthandProps['aria-disabled'] = disabledFocusable ? true : undefined; // Undefine events if disabledFocusable is passed in
88
-
89
- if (disabledFocusable) {
90
- shorthandProps.onClick = undefined;
91
- shorthandProps.onKeyDown = undefined;
92
- shorthandProps.onKeyUp = undefined;
93
- }
94
- } // If an <a> tag is to be rendered we have to remove disabled and type, and set aria-disabled, role and tabIndex.
95
- else {
96
- delete shorthandProps.disabled;
97
- shorthandProps['aria-disabled'] = disabled || disabledFocusable;
98
- shorthandProps.href = disabled ? undefined : shorthandProps.href;
99
- shorthandProps.onClick = onClickHandler;
100
- shorthandProps.onKeyDown = onKeyDownHandler;
101
- shorthandProps.onKeyUp = onKeyupHandler;
102
- shorthandProps.role = (_a = shorthandProps.role) !== null && _a !== void 0 ? _a : 'button';
103
- shorthandProps.tabIndex = disabled && !disabledFocusable ? undefined : tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0;
104
- } // Remove non-DOM disabledFocusable prop
105
-
106
-
107
- delete shorthandProps.disabledFocusable;
117
+ return nextProps;
108
118
  }
119
+ }
120
+
121
+ exports.useARIAButtonProps = useARIAButtonProps;
122
+ /**
123
+ * @internal
124
+ *
125
+ * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead
126
+ *
127
+ * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
128
+ * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
129
+ * where no attribute addition is required.
130
+ */
131
+
132
+ const useARIAButtonShorthand = (slot, options) => {
133
+ var _a;
109
134
 
110
- return shorthandProps;
135
+ const shorthand = react_utilities_1.resolveShorthand(slot, options);
136
+ const shorthandARIAButton = useARIAButtonProps((_a = shorthand === null || shorthand === void 0 ? void 0 : shorthand.as) !== null && _a !== void 0 ? _a : 'button', shorthand);
137
+ return shorthand && shorthandARIAButton;
111
138
  };
112
139
 
113
- exports.useARIAButton = useARIAButton;
140
+ exports.useARIAButtonShorthand = useARIAButtonShorthand;
114
141
  //# sourceMappingURL=useARIAButton.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["hooks/useARIAButton.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,eAAA,gBAAA,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iBAA9C;MACC,cAA6C,CAAC,IAA9C,GAAqD,QAAQ,GAC1D,SAD0D,GAEzD,cAA6C,CAAC,IAFlD;MAGD,cAAc,CAAC,OAAf,GAAyB,cAAzB;MACA,cAAc,CAAC,SAAf,GAA2B,gBAA3B;MACA,cAAc,CAAC,OAAf,GAAyB,cAAzB;MACA,cAAc,CAAC,IAAf,GAAsB,CAAA,EAAA,GAAA,cAAc,CAAC,IAAf,MAAmB,IAAnB,IAAmB,EAAA,KAAA,KAAA,CAAnB,GAAmB,EAAnB,GAAuB,QAA7C;MACA,cAAc,CAAC,QAAf,GAA0B,QAAQ,IAAI,CAAC,iBAAb,GAAiC,SAAjC,GAA6C,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAA,QAAA,GAAY,CAAnF;IACD,CA1BiB,CA4BlB;;;IACA,OAAO,cAAc,CAAC,iBAAtB;EACD;;EAED,OAAO,cAAP;AACD,CAhGM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { resolveShorthand, useEventCallback } from '@fluentui/react-utilities';\nimport type { ExtractSlotProps, ResolveShorthandFunction, Slot } from '@fluentui/react-utilities';\n\nexport type ARIAButtonSlotProps = ExtractSlotProps<Slot<'button', 'a'>> & {\n disabled?: boolean;\n disabledFocusable?: boolean;\n};\n\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 useARIAButton: ResolveShorthandFunction<ARIAButtonSlotProps> = (shorthand, options) => {\n const shorthandProps = resolveShorthand(shorthand, options);\n\n const { disabled, disabledFocusable, onClick, onKeyDown, onKeyUp, tabIndex } = (shorthandProps ||\n {}) as ARIAButtonSlotProps;\n\n const onClickHandler: ARIAButtonSlotProps['onClick'] = useEventCallback(ev => {\n if (disabled || disabledFocusable) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const onKeyDownHandler: ARIAButtonSlotProps['onKeyDown'] = useEventCallback(ev => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if ((disabled || disabledFocusable) && (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 onKeyupHandler: ARIAButtonSlotProps['onKeyUp'] = useEventCallback(ev => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if ((disabled || disabledFocusable) && (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 (shorthandProps) {\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (shorthandProps.as === 'button' || shorthandProps.as === undefined) {\n shorthandProps.disabled = disabled && !disabledFocusable;\n shorthandProps['aria-disabled'] = disabledFocusable ? true : undefined;\n\n // Undefine events if disabledFocusable is passed in\n if (disabledFocusable) {\n shorthandProps.onClick = undefined;\n shorthandProps.onKeyDown = undefined;\n shorthandProps.onKeyUp = undefined;\n }\n }\n\n // If an <a> tag is to be rendered we have to remove disabled and type, and set aria-disabled, role and tabIndex.\n else {\n delete shorthandProps.disabled;\n shorthandProps['aria-disabled'] = disabled || disabledFocusable;\n (shorthandProps as JSX.IntrinsicElements['a']).href = disabled\n ? undefined\n : (shorthandProps as JSX.IntrinsicElements['a']).href;\n shorthandProps.onClick = onClickHandler;\n shorthandProps.onKeyDown = onKeyDownHandler;\n shorthandProps.onKeyUp = onKeyupHandler;\n shorthandProps.role = shorthandProps.role ?? 'button';\n shorthandProps.tabIndex = disabled && !disabledFocusable ? undefined : tabIndex ?? 0;\n }\n\n // Remove non-DOM disabledFocusable prop\n delete shorthandProps.disabledFocusable;\n }\n\n return shorthandProps;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["hooks/useARIAButton.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAwBA;;;;;;AAMG;;;AACH,SAAgB,kBAAhB,CACE,IADF,EAEE,KAFF,EAEyB;EAEvB,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,GAA+B,iBAAA,CAAA,gBAAA,CAAiB,EAAE,IAAG;IACpE,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,CAP+C,CAAhD;EASA,MAAM,aAAa,GAAiC,iBAAA,CAAA,gBAAA,CAAiB,EAAE,IAAG;IACxE,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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-keys';\nimport { resolveShorthand, useEventCallback } from '@fluentui/react-utilities';\nimport type { ExtractSlotProps, ResolveShorthandFunction, Slot } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nexport type ARIAButtonSlotProps<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = ExtractSlotProps<\n Slot<'button', AlternateAs>\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 ARIAButtonProps<Type extends 'a' | 'div' | 'button' = 'a' | 'div' | 'button'> = React.PropsWithRef<\n JSX.IntrinsicElements[Type]\n> &\n Pick<ARIAButtonSlotProps, 'disabled' | 'disabledFocusable'>;\n\n/**\n * @internal\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 function useARIAButtonProps<Type extends NonNullable<ARIAButtonSlotProps['as']>>(\n type?: Type,\n props?: ARIAButtonProps,\n): React.PropsWithRef<JSX.IntrinsicElements[Type]> {\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: ARIAButtonProps['onClick'] = useEventCallback(ev => {\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const handleKeyDown: ARIAButtonProps['onKeyDown'] = useEventCallback(ev => {\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: ARIAButtonProps['onKeyUp'] = useEventCallback(ev => {\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 React.PropsWithRef<JSX.IntrinsicElements[Type]>;\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 nextProps = {\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 React.PropsWithRef<JSX.IntrinsicElements[Type]>;\n\n if (type === 'a' && isDisabled) {\n (nextProps as JSX.IntrinsicElements['a']).href = undefined;\n }\n\n return nextProps;\n }\n}\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(shorthand?.as ?? 'button', shorthand);\n return shorthand && shorthandARIAButton;\n};\n"],"sourceRoot":"../src/"}
@@ -3,23 +3,20 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.mergeARIADisabled = exports.useARIAButton = void 0;
6
+ exports.useARIAButtonProps = exports.useARIAButtonShorthand = void 0;
7
7
 
8
8
  var index_1 = /*#__PURE__*/require("./hooks/index");
9
9
 
10
- Object.defineProperty(exports, "useARIAButton", {
10
+ Object.defineProperty(exports, "useARIAButtonShorthand", {
11
11
  enumerable: true,
12
12
  get: function () {
13
- return index_1.useARIAButton;
13
+ return index_1.useARIAButtonShorthand;
14
14
  }
15
15
  });
16
-
17
- var index_2 = /*#__PURE__*/require("./utils/index");
18
-
19
- Object.defineProperty(exports, "mergeARIADisabled", {
16
+ Object.defineProperty(exports, "useARIAButtonProps", {
20
17
  enumerable: true,
21
18
  get: function () {
22
- return index_2.mergeARIADisabled;
19
+ return index_1.useARIAButtonProps;
23
20
  }
24
21
  });
25
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,eAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,aAAA;EAAa;AAAb,CAAA;;AAET,IAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,mBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,iBAAA;EAAiB;AAAjB,CAAA","sourcesContent":["export { useARIAButton } from './hooks/index';\nexport type { ARIAButtonSlotProps } from './hooks/index';\nexport { mergeARIADisabled } from './utils/index';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,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/index';\nexport type { ARIAButtonSlotProps, ARIAButtonProps } from './hooks/index';\n"],"sourceRoot":"../src/"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-aria",
3
- "version": "9.0.0",
3
+ "version": "9.1.0",
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.0.0",
34
+ "@fluentui/react-utilities": "^9.0.2",
35
35
  "tslib": "^2.1.0"
36
36
  },
37
37
  "peerDependencies": {
@@ -42,7 +42,8 @@
42
42
  },
43
43
  "beachball": {
44
44
  "disallowedChangeTypes": [
45
- "major"
45
+ "major",
46
+ "prerelease"
46
47
  ]
47
48
  },
48
49
  "exports": {
@@ -1,2 +0,0 @@
1
- export * from './mergeARIADisabled';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './mergeARIADisabled';\n"]}
@@ -1,16 +0,0 @@
1
- /**
2
- * @internal
3
- * Merges disabled declaration with `aria-disabled`
4
- */
5
- export function mergeARIADisabled(shorthand) {
6
- var _a;
7
-
8
- const disabled = (_a = shorthand.disabled) !== null && _a !== void 0 ? _a : shorthand['aria-disabled'];
9
-
10
- if (typeof disabled === 'string') {
11
- return disabled === 'false' ? false : true;
12
- }
13
-
14
- return disabled !== null && disabled !== void 0 ? disabled : false;
15
- }
16
- //# sourceMappingURL=mergeARIADisabled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["utils/mergeARIADisabled.ts"],"names":[],"mappings":"AAAA;;;AAGG;AACH,OAAM,SAAU,iBAAV,CAA4B,SAA5B,EAAiG;;;EACrG,MAAM,QAAQ,GAAG,CAAA,EAAA,GAAA,SAAS,CAAC,QAAV,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,EAAlB,GAAsB,SAAS,CAAC,eAAD,CAAhD;;EACA,IAAI,OAAO,QAAP,KAAoB,QAAxB,EAAkC;IAChC,OAAO,QAAQ,KAAK,OAAb,GAAuB,KAAvB,GAA+B,IAAtC;EACD;;EACD,OAAO,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAA,QAAA,GAAY,KAAnB;AACD","sourcesContent":["/**\n * @internal\n * Merges disabled declaration with `aria-disabled`\n */\nexport function mergeARIADisabled(shorthand: { 'aria-disabled'?: string | boolean; disabled?: boolean }) {\n const disabled = shorthand.disabled ?? shorthand['aria-disabled'];\n if (typeof disabled === 'string') {\n return disabled === 'false' ? false : true;\n }\n return disabled ?? false;\n}\n"],"sourceRoot":"../src/"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- const tslib_1 = /*#__PURE__*/require("tslib");
8
-
9
- tslib_1.__exportStar(require("./mergeARIADisabled"), exports);
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './mergeARIADisabled';\n"],"sourceRoot":"../src/"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.mergeARIADisabled = void 0;
7
- /**
8
- * @internal
9
- * Merges disabled declaration with `aria-disabled`
10
- */
11
-
12
- function mergeARIADisabled(shorthand) {
13
- var _a;
14
-
15
- const disabled = (_a = shorthand.disabled) !== null && _a !== void 0 ? _a : shorthand['aria-disabled'];
16
-
17
- if (typeof disabled === 'string') {
18
- return disabled === 'false' ? false : true;
19
- }
20
-
21
- return disabled !== null && disabled !== void 0 ? disabled : false;
22
- }
23
-
24
- exports.mergeARIADisabled = mergeARIADisabled;
25
- //# sourceMappingURL=mergeARIADisabled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["utils/mergeARIADisabled.ts"],"names":[],"mappings":";;;;;;AAAA;;;AAGG;;AACH,SAAgB,iBAAhB,CAAkC,SAAlC,EAAuG;;;EACrG,MAAM,QAAQ,GAAG,CAAA,EAAA,GAAA,SAAS,CAAC,QAAV,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,EAAlB,GAAsB,SAAS,CAAC,eAAD,CAAhD;;EACA,IAAI,OAAO,QAAP,KAAoB,QAAxB,EAAkC;IAChC,OAAO,QAAQ,KAAK,OAAb,GAAuB,KAAvB,GAA+B,IAAtC;EACD;;EACD,OAAO,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAA,QAAA,GAAY,KAAnB;AACD;;AAND,OAAA,CAAA,iBAAA,GAAA,iBAAA","sourcesContent":["/**\n * @internal\n * Merges disabled declaration with `aria-disabled`\n */\nexport function mergeARIADisabled(shorthand: { 'aria-disabled'?: string | boolean; disabled?: boolean }) {\n const disabled = shorthand.disabled ?? shorthand['aria-disabled'];\n if (typeof disabled === 'string') {\n return disabled === 'false' ? false : true;\n }\n return disabled ?? false;\n}\n"],"sourceRoot":"../src/"}