@fluentui/react-aria 9.3.20 → 9.3.22

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,52 @@
2
2
  "name": "@fluentui/react-aria",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 18 May 2023 00:35:32 GMT",
5
+ "date": "Wed, 31 May 2023 06:43:06 GMT",
6
+ "tag": "@fluentui/react-aria_v9.3.22",
7
+ "version": "9.3.22",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "beachball",
12
+ "package": "@fluentui/react-aria",
13
+ "comment": "Bump @fluentui/react-utilities to v9.9.2",
14
+ "commit": "17ca96c6b7f684f36a5c63e40e78b4986a86c713"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Thu, 25 May 2023 10:00:48 GMT",
21
+ "tag": "@fluentui/react-aria_v9.3.21",
22
+ "version": "9.3.21",
23
+ "comments": {
24
+ "patch": [
25
+ {
26
+ "author": "beachball",
27
+ "package": "@fluentui/react-aria",
28
+ "comment": "Bump @fluentui/react-utilities to v9.9.1",
29
+ "commit": "8f7c1b7591b3e665ae39e1b22ab0f0b28fb795c4"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Wed, 24 May 2023 20:45:23 GMT",
36
+ "tag": "@fluentui/react-aria_v9.3.20",
37
+ "version": "9.3.20",
38
+ "comments": {
39
+ "none": [
40
+ {
41
+ "author": "olfedias@microsoft.com",
42
+ "package": "@fluentui/react-aria",
43
+ "commit": "69e0617a93cb44ef42f3bd19284b7dc5fe27fed3",
44
+ "comment": "chore: update test-ssr script"
45
+ }
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ "date": "Thu, 18 May 2023 00:39:02 GMT",
6
51
  "tag": "@fluentui/react-aria_v9.3.20",
7
52
  "version": "9.3.20",
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, 18 May 2023 00:35:32 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 31 May 2023 06:43:06 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.3.22](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.3.22)
8
+
9
+ Wed, 31 May 2023 06:43:06 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.3.21..@fluentui/react-aria_v9.3.22)
11
+
12
+ ### Patches
13
+
14
+ - Bump @fluentui/react-utilities to v9.9.2 ([PR #28054](https://github.com/microsoft/fluentui/pull/28054) by beachball)
15
+
16
+ ## [9.3.21](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.3.21)
17
+
18
+ Thu, 25 May 2023 10:00:48 GMT
19
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.3.20..@fluentui/react-aria_v9.3.21)
20
+
21
+ ### Patches
22
+
23
+ - Bump @fluentui/react-utilities to v9.9.1 ([PR #27988](https://github.com/microsoft/fluentui/pull/27988) by beachball)
24
+
7
25
  ## [9.3.20](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.3.20)
8
26
 
9
- Thu, 18 May 2023 00:35:32 GMT
27
+ Thu, 18 May 2023 00:39:02 GMT
10
28
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.3.19..@fluentui/react-aria_v9.3.20)
11
29
 
12
30
  ### Patches
@@ -1,4 +1,3 @@
1
1
  export * from './useARIAButtonProps';
2
2
  export * from './useARIAButtonShorthand';
3
3
  export * from './types';
4
- //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../src/button/index.ts"],"sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,cAAc,uBAAuB;AACrC,cAAc,2BAA2B;AACzC,cAAc,UAAU"}
@@ -1,2 +1 @@
1
1
  import * as React from 'react';
2
- //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React"],"sources":["../../src/button/types.ts"],"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\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 * 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"],"mappings":"AACA,YAAYA,KAAA,MAAW"}
1
+ {"version":3,"sources":["types.ts"],"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\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 * 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"],"names":["React"],"mappings":"AACA,YAAYA,WAAW,QAAQ"}
@@ -27,91 +27,81 @@ import * as React from 'react';
27
27
  * <a {...buttonProps}>This anchor will behave as a proper button</a>
28
28
  * )
29
29
  * ```
30
- */
31
- export function useARIAButtonProps(type, props) {
32
- const {
33
- disabled,
34
- disabledFocusable = false,
35
- ['aria-disabled']: ariaDisabled,
36
- onClick,
37
- onKeyDown,
38
- onKeyUp,
39
- ...rest
40
- } = props !== null && props !== void 0 ? props : {};
41
- const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;
42
- const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;
43
- const handleClick = useEventCallback(ev => {
44
- if (isDisabled) {
45
- ev.preventDefault();
46
- ev.stopPropagation();
30
+ */ export function useARIAButtonProps(type, props) {
31
+ const { disabled , disabledFocusable =false , ['aria-disabled']: ariaDisabled , onClick , onKeyDown , onKeyUp , ...rest } = props !== null && props !== void 0 ? props : {};
32
+ const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;
33
+ const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;
34
+ const handleClick = useEventCallback((ev)=>{
35
+ if (isDisabled) {
36
+ ev.preventDefault();
37
+ ev.stopPropagation();
38
+ } else {
39
+ onClick === null || onClick === void 0 ? void 0 : onClick(ev);
40
+ }
41
+ });
42
+ const handleKeyDown = useEventCallback((ev)=>{
43
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(ev);
44
+ if (ev.isDefaultPrevented()) {
45
+ return;
46
+ }
47
+ const key = ev.key;
48
+ if (isDisabled && (key === Enter || key === Space)) {
49
+ ev.preventDefault();
50
+ ev.stopPropagation();
51
+ return;
52
+ }
53
+ if (key === Space) {
54
+ ev.preventDefault();
55
+ return;
56
+ } else if (key === Enter) {
57
+ ev.preventDefault();
58
+ ev.currentTarget.click();
59
+ }
60
+ });
61
+ const handleKeyUp = useEventCallback((ev)=>{
62
+ onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(ev);
63
+ if (ev.isDefaultPrevented()) {
64
+ return;
65
+ }
66
+ const key = ev.key;
67
+ if (isDisabled && (key === Enter || key === Space)) {
68
+ ev.preventDefault();
69
+ ev.stopPropagation();
70
+ return;
71
+ }
72
+ if (key === Space) {
73
+ ev.preventDefault();
74
+ ev.currentTarget.click();
75
+ }
76
+ });
77
+ // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly
78
+ if (type === 'button' || type === undefined) {
79
+ return {
80
+ ...rest,
81
+ disabled: disabled && !disabledFocusable,
82
+ 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,
83
+ // onclick should still use internal handler to ensure prevention if disabled
84
+ // if disabledFocusable then there's no requirement for handlers as those events should not be propagated
85
+ onClick: disabledFocusable ? undefined : handleClick,
86
+ onKeyUp: disabledFocusable ? undefined : onKeyUp,
87
+ onKeyDown: disabledFocusable ? undefined : onKeyDown
88
+ };
47
89
  } else {
48
- onClick === null || onClick === void 0 ? void 0 : onClick(ev);
90
+ const resultProps = {
91
+ role: 'button',
92
+ tabIndex: disabled && !disabledFocusable ? undefined : 0,
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
+ };
102
+ if (type === 'a' && isDisabled) {
103
+ resultProps.href = undefined;
104
+ }
105
+ return resultProps;
49
106
  }
50
- });
51
- const handleKeyDown = useEventCallback(ev => {
52
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(ev);
53
- if (ev.isDefaultPrevented()) {
54
- return;
55
- }
56
- const key = ev.key;
57
- if (isDisabled && (key === Enter || key === Space)) {
58
- ev.preventDefault();
59
- ev.stopPropagation();
60
- return;
61
- }
62
- if (key === Space) {
63
- ev.preventDefault();
64
- return;
65
- } else if (key === Enter) {
66
- ev.preventDefault();
67
- ev.currentTarget.click();
68
- }
69
- });
70
- const handleKeyUp = useEventCallback(ev => {
71
- onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(ev);
72
- if (ev.isDefaultPrevented()) {
73
- return;
74
- }
75
- const key = ev.key;
76
- if (isDisabled && (key === Enter || key === Space)) {
77
- ev.preventDefault();
78
- ev.stopPropagation();
79
- return;
80
- }
81
- if (key === Space) {
82
- ev.preventDefault();
83
- ev.currentTarget.click();
84
- }
85
- });
86
- // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly
87
- if (type === 'button' || type === undefined) {
88
- return {
89
- ...rest,
90
- disabled: disabled && !disabledFocusable,
91
- 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,
92
- // onclick should still use internal handler to ensure prevention if disabled
93
- // if disabledFocusable then there's no requirement for handlers as those events should not be propagated
94
- onClick: disabledFocusable ? undefined : handleClick,
95
- onKeyUp: disabledFocusable ? undefined : onKeyUp,
96
- onKeyDown: disabledFocusable ? undefined : onKeyDown
97
- };
98
- } else {
99
- const resultProps = {
100
- role: 'button',
101
- tabIndex: disabled && !disabledFocusable ? undefined : 0,
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
- };
111
- if (type === 'a' && isDisabled) {
112
- resultProps.href = undefined;
113
- }
114
- return resultProps;
115
- }
116
107
  }
117
- //# sourceMappingURL=useARIAButtonProps.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Enter","Space","useEventCallback","React","useARIAButtonProps","type","props","disabled","disabledFocusable","ariaDisabled","onClick","onKeyDown","onKeyUp","rest","normalizedARIADisabled","isDisabled","handleClick","ev","preventDefault","stopPropagation","handleKeyDown","isDefaultPrevented","key","currentTarget","click","handleKeyUp","undefined","resultProps","role","tabIndex","href"],"sources":["../../src/button/useARIAButtonProps.ts"],"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 disabledFocusable = false,\n ['aria-disabled']: ariaDisabled,\n onClick,\n onKeyDown,\n onKeyUp,\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 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"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ;AAC7B,SAASC,gBAAgB,QAAQ;AACjC,YAAYC,KAAA,MAAW;AAGvB;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,OAAO,SAASC,mBACdC,IAAW,EACXC,KAAa,EACuB;EACpC,MAAM;IACJC,QAAA;IACAC,iBAAA,GAAoB,KAAK;IACzB,CAAC,kBAAkBC,YAAA;IACnBC,OAAA;IACAC,SAAA;IACAC,OAAA;IACA,GAAGC;EAAA,CACJ,GAAGP,KAAA,aAAAA,KAAA,cAAAA,KAAA,GAAS,CAAC,CAAC;EAEf,MAAMQ,sBAAA,GAAyB,O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A,IAAIG,GAAA,KAAQrB,KAAA,EAAO;MACjBgB,EAAA,CAAGC,cAAc;MACjBD,EAAA,CAAGM,aAAa,CAACC,KAAK;IACxB;EACF;EAEA;EACA,IAAInB,IAAA,KAAS,YAAYA,IAAA,KAASqB,SAAA,EAAW;IAC3C,OAAO;MACL,GAAGb,IAAI;MACPN,QAAA,EAAUA,QAAA,IAAY,CAACC,iBAAA;MACvB,iBAAiBA,iBAAA,GAAoB,IAAI,GAAGM,sBAAsB;MAClE;MACA;MACAJ,OAAA,EAASF,iBAAA,GAAoBkB,SAAA,GAAYV,WAAW;MACpDJ,OAAA,EAASJ,iBAAA,GAAoBkB,SAAA,GAAYd,OAAO;MAChDD,SAAA,EAAWH,iBAAA,GAAoBkB,SAAA,GAAYf;IAC7C;EACF,OAIK;IACH,MAAMgB,WAAA,GAAc;MAClBC,IAAA,EAAM;MACNC,QAAA,EAAUtB,QAAA,IAAY,CAACC,iBAAA,GAAoBkB,SAAA,GAAY,CAAC;MACxD,GAAGb,IAAI;MACP;MACA;MACA;MACAH,OAAA,EAASM,WAAA;MACTJ,OAAA,EAASa,WAAA;MACTd,SAAA,EAAWS,aAAA;MACX,iBAAiBb,QAAA,IAAYC,iBAAA,IAAqBM;IACpD;IAEA,IAAIT,IAAA,KAAS,OAAOU,UAAA,EAAY;MAC7BY,WAAA,CAAkDG,IAAI,GAAGJ,SAAA;IAC5D;IAEA,OAAOC,WAAA;EACT;AACF"}
1
+ {"version":3,"sources":["useARIAButtonProps.ts"],"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 disabledFocusable = false,\n ['aria-disabled']: ariaDisabled,\n onClick,\n onKeyDown,\n onKeyUp,\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 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"],"names":["Enter","Space","useEventCallback","React","useARIAButtonProps","type","props","disabled","disabledFocusable","ariaDisabled","onClick","onKeyDown","onKeyUp","rest","normalizedARIADisabled","isDisabled","handleClick","ev","preventDefault","stopPropagation","handleKeyDown","isDefaultPrevented","key","currentTarget","click","handleKeyUp","undefined","resultProps","role","tabIndex","href"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,0BAA0B;AACvD,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,YAAYC,WAAW,QAAQ;AAG/B;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GACD,OAAO,SAASC,mBACd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QACF,CAAC;QAED,IAAIG,QAAQrB,OAAO;YACjBgB,GAAGC,cAAc;YACjBD,GAAGM,aAAa,CAACC,KAAK;QACxB,CAAC;IACH;IAEA,+FAA+F;IAC/F,IAAInB,SAAS,YAAYA,SAASqB,WAAW;QAC3C,OAAO;YACL,GAAGb,IAAI;YACPN,UAAUA,YAAY,CAACC;YACvB,iBAAiBA,oBAAoB,IAAI,GAAGM,sBAAsB;YAClE,6EAA6E;YAC7E,yGAAyG;YACzGJ,SAASF,oBAAoBkB,YAAYV,WAAW;YACpDJ,SAASJ,oBAAoBkB,YAAYd,OAAO;YAChDD,WAAWH,oBAAoBkB,YAAYf,SAAS;QACtD;IACF,OAIK;QACH,MAAMgB,cAAc;YAClBC,MAAM;YACNC,UAAUtB,YAAY,CAACC,oBAAoBkB,YAAY,CAAC;YACxD,GAAGb,IAAI;YACP,iFAAiF;YACjF,8DAA8D;YAC9D,kCAAkC;YAClCH,SAASM;YACTJ,SAASa;YACTd,WAAWS;YACX,iBAAiBb,YAAYC,qBAAqBM;QACpD;QAEA,IAAIT,SAAS,OAAOU,YAAY;YAC7BY,YAAkDG,IAAI,GAAGJ;QAC5D,CAAC;QAED,OAAOC;IACT,CAAC;AACH,CAAC"}
@@ -8,11 +8,9 @@ import { useARIAButtonProps } from './useARIAButtonProps';
8
8
  * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
9
9
  * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
10
10
  * where no attribute addition is required.
11
- */
12
- export const useARIAButtonShorthand = (slot, options) => {
13
- const shorthand = resolveShorthand(slot, options);
14
- var _shorthand_as;
15
- const shorthandARIAButton = useARIAButtonProps((_shorthand_as = shorthand === null || shorthand === void 0 ? void 0 : shorthand.as) !== null && _shorthand_as !== void 0 ? _shorthand_as : 'button', shorthand);
16
- return shorthand && shorthandARIAButton;
11
+ */ export const useARIAButtonShorthand = (slot, options)=>{
12
+ const shorthand = resolveShorthand(slot, options);
13
+ var _shorthand_as;
14
+ const shorthandARIAButton = useARIAButtonProps((_shorthand_as = shorthand === null || shorthand === void 0 ? void 0 : shorthand.as) !== null && _shorthand_as !== void 0 ? _shorthand_as : 'button', shorthand);
15
+ return shorthand && shorthandARIAButton;
17
16
  };
18
- //# sourceMappingURL=useARIAButtonShorthand.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["resolveShorthand","useARIAButtonProps","useARIAButtonShorthand","slot","options","shorthand","_shorthand_as","shorthandARIAButton","as"],"sources":["../../src/button/useARIAButtonShorthand.ts"],"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"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AAInC;;;;;;;;;AASA,OAAO,MAAMC,sBAAA,GAAwEA,CAACC,IAAA,EAAMC,OAAA,KAAY;EACtG,MAAMC,SAAA,GAAYL,gBAAA,CAAiBG,IAAA,EAAMC,OAAA;MACuCE,aAAA;EAAhF,MAAMC,mBAAA,GAAsBN,kBAAA,CAAoD,CAAAK,aAAA,GAAAD,SAAA,aAAAA,SAAA,uBAAAA,SAAA,CAAWG,EAAE,cAAbF,aAAA,cAAAA,aAAA,GAAiB,QAAQ,EAAED,SAAA;EAC3G,OAAOA,SAAA,IAAaE,mBAAA;AACtB"}
1
+ {"version":3,"sources":["useARIAButtonShorthand.ts"],"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"],"names":["resolveShorthand","useARIAButtonProps","useARIAButtonShorthand","slot","options","shorthand","shorthandARIAButton","as"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,kBAAkB,QAAQ,uBAAuB;AAI1D;;;;;;;;CAQC,GACD,OAAO,MAAMC,yBAAwE,CAACC,MAAMC,UAAY;IACtG,MAAMC,YAAYL,iBAAiBG,MAAMC;QACuCC;IAAhF,MAAMC,sBAAsBL,mBAAoDI,CAAAA,gBAAAA,sBAAAA,uBAAAA,KAAAA,IAAAA,UAAWE,EAAE,cAAbF,2BAAAA,gBAAiB,QAAQ,EAAEA;IAC3G,OAAOA,aAAaC;AACtB,EAAE"}
package/lib/index.js CHANGED
@@ -1,2 +1 @@
1
1
  export { useARIAButtonShorthand, useARIAButtonProps } from './button/index';
2
- //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["useARIAButtonShorthand","useARIAButtonProps"],"sources":["../src/index.ts"],"sourcesContent":["export { useARIAButtonShorthand, useARIAButtonProps } from './button/index';\nexport type {\n ARIAButtonSlotProps,\n ARIAButtonProps,\n ARIAButtonResultProps,\n ARIAButtonType,\n ARIAButtonElement,\n ARIAButtonElementIntersection,\n ARIAButtonAlteredProps,\n} from './button/index';\n"],"mappings":"AAAA,SAASA,sBAAsB,EAAEC,kBAAkB,QAAQ"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export { useARIAButtonShorthand, useARIAButtonProps } from './button/index';\nexport type {\n ARIAButtonSlotProps,\n ARIAButtonProps,\n ARIAButtonResultProps,\n ARIAButtonType,\n ARIAButtonElement,\n ARIAButtonElementIntersection,\n ARIAButtonAlteredProps,\n} from './button/index';\n"],"names":["useARIAButtonShorthand","useARIAButtonProps"],"mappings":"AAAA,SAASA,sBAAsB,EAAEC,kBAAkB,QAAQ,iBAAiB"}
@@ -6,6 +6,3 @@ const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
6
  _exportStar(require("./useARIAButtonProps"), exports);
7
7
  _exportStar(require("./useARIAButtonShorthand"), exports);
8
8
  _exportStar(require("./types"), exports);
9
- //# sourceMappingURL=index.js.map
10
-
11
- //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../lib/button/index.js"],"sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;CACd,iCAAiC"}
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA"}
@@ -4,6 +4,3 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
6
6
  const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
7
- //# sourceMappingURL=types.js.map
8
-
9
- //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../lib/button/types.js"],"sourcesContent":["import * as React from 'react';\n//# sourceMappingURL=types.js.map"],"names":[],"mappings":";;;;;6DAAuB;CACvB,iCAAiC"}
1
+ {"version":3,"sources":["types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;6DAAuB"}
@@ -87,6 +87,4 @@ function useARIAButtonProps(type, props) {
87
87
  }
88
88
  return resultProps;
89
89
  }
90
- } //# sourceMappingURL=useARIAButtonProps.js.map
91
-
92
- //# sourceMappingURL=useARIAButtonProps.js.map
90
+ }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../lib/button/useARIAButtonProps.js"],"sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\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, props) {\n const {\n disabled,\n disabledFocusable = false,\n ['aria-disabled']: ariaDisabled,\n onClick,\n onKeyDown,\n onKeyUp,\n ...rest\n } = props !== null && props !== void 0 ? props : {};\n const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;\n const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;\n const handleClick = useEventCallback(ev => {\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick === null || onClick === void 0 ? void 0 : onClick(ev);\n }\n });\n const handleKeyDown = useEventCallback(ev => {\n onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(ev);\n if (ev.isDefaultPrevented()) {\n return;\n }\n const key = ev.key;\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n if (key === Space) {\n ev.preventDefault();\n return;\n } else if (key === Enter) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n const handleKeyUp = useEventCallback(ev => {\n onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(ev);\n if (ev.isDefaultPrevented()) {\n return;\n }\n const key = ev.key;\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n if (key === Space) {\n ev.preventDefault();\n ev.currentTarget.click();\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 };\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 };\n if (type === 'a' && isDisabled) {\n resultProps.href = undefined;\n }\n return resultProps;\n }\n}\n//# sourceMappingURL=useARIAButtonProps.js.map"],"names":["useARIAButtonProps","type","props","disabled","disabledFocusable","ariaDisabled","onClick","onKeyDown","onKeyUp","rest","normalizedARIADisabled","isDisabled","handleClick","useEventCallback","ev","preventDefault","stopPropagation","handleKeyDown","isDefaultPrevented","key","Enter","Space","currentTarget","click","handleKeyUp","undefined","resultProps","role","tabIndex","href"],"mappings":";;;;+BA8BgBA;;aAAAA;;;8BA9Ba;gCACI;6DACV;AA4BhB,SAASA,mBAAmBC,IAAI,EAAEC,KAAK,EAAE;IAC9C,MAAM,EACJC,SAAQ,EACRC,mBAAoB,KAAK,CAAA,EACzB,CAAC,gBAAgB,EAAEC,aAAY,EAC/BC,QAAO,EACPC,UAAS,EACTC,QAAO,EACP,GAAGC,MACJ,GAAGP,UAAU,IAAI,IAAIA,UAAU,KAAK,IAAIA,QAAQ,CAAC,CAAC;IACnD,MAAMQ,yBAAyB,OAAOL,iBAAiB,WAAWA,iBAAiB,SAASA,YAAY;IACxG,MAAMM,aAAaR,YAAYC,qBAAqBM;IACpD,MAAME,cAAcC,IAAAA,gCAAgB,EAACC,CAAAA,KAAM;QACzC,IAAIH,YAAY;YACdG,GAAGC,cAAc;YACjBD,GAAGE,eAAe;QACpB,OAAO;YACLV,YAAY,IAAI,IAAIA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQQ,GAAG;QAC/D,CAAC;IACH;IACA,MAAMG,gBAAgBJ,IAAAA,gCAAgB,EAACC,CAAAA,KAAM;QAC3CP,cAAc,IAAI,IAAIA,cAAc,KAAK,IAAI,KAAK,IAAIA,UAAUO,GAAG;QACnE,IAAIA,GAAGI,kBAAkB,IAAI;YAC3B;QACF,CAAC;QACD,MAAMC,MAAML,GAAGK,GAAG;QAClB,IAAIR,cAAeQ,CAAAA,QAAQC,mBAAK,IAAID,QAAQE,mBAAK,AAAD,GAAI;YAClDP,GAAGC,cAAc;YACjBD,GAAGE,eAAe;YAClB;QACF,CAA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,CAAC;QACD,OAAOC;IACT,CAAC;AACH,EACA,8CAA8C"}
1
+ {"version":3,"sources":["useARIAButtonProps.js"],"sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\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 */ export function useARIAButtonProps(type, props) {\n const { disabled , disabledFocusable =false , ['aria-disabled']: ariaDisabled , onClick , onKeyDown , onKeyUp , ...rest } = props !== null && props !== void 0 ? props : {};\n const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;\n const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;\n const handleClick = useEventCallback((ev)=>{\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick === null || onClick === void 0 ? void 0 : onClick(ev);\n }\n });\n const handleKeyDown = useEventCallback((ev)=>{\n onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(ev);\n if (ev.isDefaultPrevented()) {\n return;\n }\n const key = ev.key;\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n if (key === Space) {\n ev.preventDefault();\n return;\n } else if (key === Enter) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n const handleKeyUp = useEventCallback((ev)=>{\n onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(ev);\n if (ev.isDefaultPrevented()) {\n return;\n }\n const key = ev.key;\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n if (key === Space) {\n ev.preventDefault();\n ev.currentTarget.click();\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 };\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 };\n if (type === 'a' && isDisabled) {\n resultProps.href = undefined;\n }\n return resultProps;\n }\n}\n"],"names":["useARIAButtonProps","type","props","disabled","disabledFocusable","ariaDisabled","onClick","onKeyDown","onKeyUp","rest","normalizedARIADisabled","isDisabled","handleClick","useEventCallback","ev","preventDefault","stopPropagation","handleKeyDown","isDefaultPrevented","key","Enter","Space","currentTarget","click","handleKeyUp","undefined","resultProps","role","tabIndex","href"],"mappings":";;;;+BA6BoBA;;aAAAA;;;8BA7BS;gCACI;6DACV;AA2BZ,SAASA,mBAAmBC,IAAI,EAAEC,KAAK,EAAE;IAChD,MAAM,EAAEC,SAAQ,EAAGC,mBAAmB,KAAK,CAAA,EAAG,C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K,IAAID,QAAQE,mBAAK,AAAD,GAAI;YAChDP,GAAGC,cAAc;YACjBD,GAAGE,eAAe;YAClB;QACJ,CAAC;QACD,IAAIG,QAAQE,mBAAK,EAAE;YACfP,GAAGC,cAAc;YACjBD,GAAGQ,aAAa,CAACC,KAAK;QAC1B,CAAC;IACL;IACA,+FAA+F;IAC/F,IAAItB,SAAS,YAAYA,SAASwB,WAAW;QACzC,OAAO;YACH,GAAGhB,IAAI;YACPN,UAAUA,YAAY,CAACC;YACvB,iBAAiBA,oBAAoB,IAAI,GAAGM,sBAAsB;YAClE,6EAA6E;YAC7E,yGAAyG;YACzGJ,SAASF,oBAAoBqB,YAAYb,WAAW;YACpDJ,SAASJ,oBAAoBqB,YAAYjB,OAAO;YAChDD,WAAWH,oBAAoBqB,YAAYlB,SAAS;QACxD;IACJ,OAAO;QACH,MAAMmB,cAAc;YAChBC,MAAM;YACNC,UAAUzB,YAAY,CAACC,oBAAoBqB,YAAY,CAAC;YACxD,GAAGhB,IAAI;YACP,iFAAiF;YACjF,8DAA8D;YAC9D,kCAAkC;YAClCH,SAASM;YACTJ,SAASgB;YACTjB,WAAWU;YACX,iBAAiBd,YAAYC,qBAAqBM;QACtD;QACA,IAAIT,SAAS,OAAOU,YAAY;YAC5Be,YAAYG,IAAI,GAAGJ;QACvB,CAAC;QACD,OAAOC;IACX,CAAC;AACL"}
@@ -13,6 +13,4 @@ const useARIAButtonShorthand = (slot, options)=>{
13
13
  var _shorthand_as;
14
14
  const shorthandARIAButton = (0, _useARIAButtonProps.useARIAButtonProps)((_shorthand_as = shorthand === null || shorthand === void 0 ? void 0 : shorthand.as) !== null && _shorthand_as !== void 0 ? _shorthand_as : 'button', shorthand);
15
15
  return shorthand && shorthandARIAButton;
16
- }; //# sourceMappingURL=useARIAButtonShorthand.js.map
17
-
18
- //# sourceMappingURL=useARIAButtonShorthand.js.map
16
+ };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../lib/button/useARIAButtonShorthand.js"],"sourcesContent":["import { resolveShorthand } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from './useARIAButtonProps';\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 = (slot, options) => {\n const shorthand = resolveShorthand(slot, options);\n var _shorthand_as;\n const shorthandARIAButton = useARIAButtonProps((_shorthand_as = shorthand === null || shorthand === void 0 ? void 0 : shorthand.as) !== null && _shorthand_as !== void 0 ? _shorthand_as : 'button', shorthand);\n return shorthand && shorthandARIAButton;\n};\n//# sourceMappingURL=useARIAButtonShorthand.js.map"],"names":["useARIAButtonShorthand","slot","options","shorthand","resolveShorthand","_shorthand_as","shorthandARIAButton","useARIAButtonProps","as"],"mappings":";;;;+BAWaA;;aAAAA;;gCAXoB;oCACE;AAU5B,MAAMA,yBAAyB,CAACC,MAAMC,UAAY;IACvD,MAAMC,YAAYC,IAAAA,gCAAgB,EAACH,MAAMC;IACzC,IAAIG;IACJ,MAAMC,sBAAsBC,IAAAA,sCAAkB,EAAC,AAACF,CAAAA,gBAAgBF,cAAc,IAAI,IAAIA,cAAc,KAAK,IAAI,KAAK,IAAIA,UAAUK,EAAE,AAAD,MAAO,IAAI,IAAIH,kBAAkB,KAAK,IAAIA,gBAAgB,QAAQ,EAAEF;IACrM,OAAOA,aAAaG;AACtB,GACA,kDAAkD"}
1
+ {"version":3,"sources":["useARIAButtonShorthand.js"],"sourcesContent":["import { resolveShorthand } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from './useARIAButtonProps';\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 */ export const useARIAButtonShorthand = (slot, options)=>{\n const shorthand = resolveShorthand(slot, options);\n var _shorthand_as;\n const shorthandARIAButton = useARIAButtonProps((_shorthand_as = shorthand === null || shorthand === void 0 ? void 0 : shorthand.as) !== null && _shorthand_as !== void 0 ? _shorthand_as : 'button', shorthand);\n return shorthand && shorthandARIAButton;\n};\n"],"names":["useARIAButtonShorthand","slot","options","shorthand","resolveShorthand","_shorthand_as","shorthandARIAButton","useARIAButtonProps","as"],"mappings":";;;;+BAUiBA;;aAAAA;;gCAVgB;oCACE;AASxB,MAAMA,yBAAyB,CAACC,MAAMC,UAAU;IACvD,MAAMC,YAAYC,IAAAA,gCAAgB,EAACH,MAAMC;IACzC,IAAIG;IACJ,MAAMC,sBAAsBC,IAAAA,sCAAkB,EAAC,AAACF,CAAAA,gBAAgBF,cAAc,IAAI,IAAIA,cAAc,KAAK,IAAI,KAAK,IAAIA,UAAUK,EAAE,AAAD,MAAO,IAAI,IAAIH,kBAAkB,KAAK,IAAIA,gBAAgB,QAAQ,EAAEF;IACrM,OAAOA,aAAaG;AACxB"}
@@ -13,6 +13,3 @@ _export(exports, {
13
13
  useARIAButtonProps: ()=>_index.useARIAButtonProps
14
14
  });
15
15
  const _index = require("./button/index");
16
- //# sourceMappingURL=index.js.map
17
-
18
- //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../lib/index.js"],"sourcesContent":["export { useARIAButtonShorthand, useARIAButtonProps } from './button/index';\n//# sourceMappingURL=index.js.map"],"names":["useARIAButtonShorthand","useARIAButtonProps"],"mappings":";;;;;;;;;;;IAASA,sBAAsB,MAAtBA,6BAAsB;IAAEC,kBAAkB,MAAlBA,yBAAkB;;uBAAQ;CAC3D,iCAAiC"}
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export { useARIAButtonShorthand, useARIAButtonProps } from './button/index';\n"],"names":["useARIAButtonShorthand","useARIAButtonProps"],"mappings":";;;;;;;;;;;IAASA,sBAAsB,MAAtBA,6BAAsB;IAAEC,kBAAkB,MAAlBA,yBAAkB;;uBAAQ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-aria",
3
- "version": "9.3.20",
3
+ "version": "9.3.22",
4
4
  "description": "React helper to ensure ARIA",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -22,7 +22,7 @@
22
22
  "storybook": "start-storybook",
23
23
  "type-check": "tsc -b tsconfig.json",
24
24
  "generate-api": "just-scripts generate-api",
25
- "test-ssr": "test-ssr ./stories/**/*.stories.tsx"
25
+ "test-ssr": "test-ssr \"./stories/**/*.stories.tsx\""
26
26
  },
27
27
  "devDependencies": {
28
28
  "@fluentui/eslint-plugin": "*",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@fluentui/keyboard-keys": "^9.0.3",
35
- "@fluentui/react-utilities": "^9.9.0",
35
+ "@fluentui/react-utilities": "^9.9.2",
36
36
  "@swc/helpers": "^0.4.14"
37
37
  },
38
38
  "peerDependencies": {