@fluentui/react-aria 9.3.1 → 9.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,30 @@
2
2
  "name": "@fluentui/react-aria",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 11 Nov 2022 14:53:38 GMT",
5
+ "date": "Thu, 17 Nov 2022 23:02:30 GMT",
6
+ "tag": "@fluentui/react-aria_v9.3.2",
7
+ "version": "9.3.2",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "author": "martinhochel@microsoft.com",
12
+ "package": "@fluentui/react-aria",
13
+ "commit": "ea768501802d65d63ddc63fff3816fb6b5008ae4",
14
+ "comment": "chore: update package scaffold"
15
+ }
16
+ ],
17
+ "patch": [
18
+ {
19
+ "author": "beachball",
20
+ "package": "@fluentui/react-aria",
21
+ "comment": "Bump @fluentui/react-utilities to v9.2.2",
22
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
23
+ }
24
+ ]
25
+ }
26
+ },
27
+ {
28
+ "date": "Fri, 11 Nov 2022 14:57:51 GMT",
6
29
  "tag": "@fluentui/react-aria_v9.3.1",
7
30
  "version": "9.3.1",
8
31
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,21 @@
1
1
  # Change Log - @fluentui/react-aria
2
2
 
3
- This log was last generated on Fri, 11 Nov 2022 14:53:38 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 17 Nov 2022 23:02:30 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.3.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.3.2)
8
+
9
+ Thu, 17 Nov 2022 23:02:30 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.3.1..@fluentui/react-aria_v9.3.2)
11
+
12
+ ### Patches
13
+
14
+ - Bump @fluentui/react-utilities to v9.2.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
15
+
7
16
  ## [9.3.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.3.1)
8
17
 
9
- Fri, 11 Nov 2022 14:53:38 GMT
18
+ Fri, 11 Nov 2022 14:57:51 GMT
10
19
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.3.0..@fluentui/react-aria_v9.3.1)
11
20
 
12
21
  ### Patches
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["button/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC","sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-aria/src/button/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC","sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"../src/","sources":["button/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExtractSlotProps, Slot } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\ntype UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\nexport type ARIAButtonType = 'button' | 'a' | 'div';\n\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"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"../src/","sources":["packages/react-components/react-aria/src/button/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExtractSlotProps, Slot } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\ntype UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\nexport type ARIAButtonType = 'button' | 'a' | 'div';\n\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"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["button/useARIAButtonProps.ts"],"names":[],"mappings":"AAAA,SAAS,KAAT,EAAgB,KAAhB,QAA6B,yBAA7B;AACA,SAAS,gBAAT,QAAiC,2BAAjC;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;;AACH,OAAM,SAAU,kBAAV,CACJ,IADI,EAEJ,KAFI,EAES;EAEb,MAAM;IAAE,QAAF;IAAY,iBAAiB,GAAG,KAAhC;IAAuC,CAAC,eAAD,GAAmB,YAA1D;IAAwE,OAAxE;IAAiF,SAAjF;IAA4F,OAA5F;IAAqG,GAAG;EAAxG,IACJ,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAA,KAAA,GAAS,EADX;EAGA,MAAM,sBAAsB,GAAG,OAAO,YAAP,KAAwB,QAAxB,GAAmC,YAAY,KAAK,MAApD,GAA6D,YAA5F;EAEA,MAAM,UAAU,GAAG,QAAQ,IAAI,iBAAZ,IAAiC,sBAApD;EAEA,MAAM,WAAW,GAAG,gBAAgB,CAAE,EAAD,IAAwD;IAC3F,IAAI,UAAJ,EAAgB;MACd,EAAE,CAAC,cAAH;MACA,EAAE,CAAC,eAAH;IACD,CAHD,MAGO;MACL,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAG,EAAH,CAAP;IACD;EACF,CAPmC,CAApC;EASA,MAAM,aAAa,GAAG,gBAAgB,CAAE,EAAD,IAA2D;IAChG,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAG,EAAH,CAAT;;IAEA,IAAI,EAAE,CAAC,kBAAH,EAAJ,EAA6B;MAC3B;IACD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C;MAQL,SAAS,EAAE,iBAAiB,GAAG,SAAH,GAAe;IARtC,CAAP;EAUD,CAXD,CAaA;EACA;EAdA,KAeK;IACH,MAAM,WAAW,GAAG;MAClB,IAAI,EAAE,QADY;MAElB,QAAQ,EAAE,QAAQ,IAAI,CAAC,iBAAb,GAAiC,SAAjC,GAA6C,CAFrC;MAGlB,GAAG,IAHe;MAIlB;MACA;MACA;MACA,OAAO,EAAE,WAPS;MAQlB,OAAO,EAAE,WARS;MASlB,SAAS,EAAE,aATO;MAUlB,iBAAiB,QAAQ,IAAI,iBAAZ,IAAiC;IAVhC,CAApB;;IAaA,IAAI,IAAI,KAAK,GAAT,IAAgB,UAApB,EAAgC;MAC7B,WAAiD,CAAC,IAAlD,GAAyD,SAAzD;IACF;;IAED,OAAO,WAAP;EACD;AACF","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type { ARIAButtonElementIntersection, ARIAButtonProps, ARIAButtonResultProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n *\n * @param type - the proper scenario to be interpreted by the hook.\n * 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states\n * 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior\n * @param props - the props to be passed down the line to the desired element.\n * This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.\n *\n * @example\n * ```tsx\n * const buttonProps = useARIAButtonProps('a', {\n * href: './some-route'\n * onClick: () => console.log('this should run both on click and Space and Enter')\n * })\n *\n * // ...\n *\n * return (\n * <a {...buttonProps}>This anchor will behave as a proper button</a>\n * )\n * ```\n */\nexport function useARIAButtonProps<Type extends ARIAButtonType, Props extends ARIAButtonProps<Type>>(\n type?: Type,\n props?: Props,\n): ARIAButtonResultProps<Type, Props> {\n const { disabled, disabledFocusable = false, ['aria-disabled']: ariaDisabled, onClick, onKeyDown, onKeyUp, ...rest } =\n props ?? {};\n\n const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;\n\n const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;\n\n const handleClick = useEventCallback((ev: React.MouseEvent<ARIAButtonElementIntersection>) => {\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const handleKeyDown = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n return;\n }\n\n // If enter is pressed, activate the button\n else if (key === Enter) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n const handleKeyUp = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (type === 'button' || type === undefined) {\n return {\n ...rest,\n disabled: disabled && !disabledFocusable,\n 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,\n // onclick should still use internal handler to ensure prevention if disabled\n // if disabledFocusable then there's no requirement for handlers as those events should not be propagated\n onClick: disabledFocusable ? undefined : handleClick,\n onKeyUp: disabledFocusable ? undefined : onKeyUp,\n onKeyDown: disabledFocusable ? undefined : onKeyDown,\n } as ARIAButtonResultProps<Type, Props>;\n }\n\n // If an <a> or <div> tag is to be rendered we have to remove disabled and type,\n // and set aria-disabled, role and tabIndex.\n else {\n const resultProps = {\n role: 'button',\n tabIndex: disabled && !disabledFocusable ? undefined : 0,\n ...rest,\n // If it's not a <button> than listeners are required even with disabledFocusable\n // Since you cannot assure the default behavior of the element\n // E.g: <a> will redirect on click\n onClick: handleClick,\n onKeyUp: handleKeyUp,\n onKeyDown: handleKeyDown,\n 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,\n } as ARIAButtonResultProps<Type, Props>;\n\n if (type === 'a' && isDisabled) {\n (resultProps as ARIAButtonResultProps<'a', Props>).href = undefined;\n }\n\n return resultProps;\n }\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-aria/src/button/useARIAButtonProps.ts"],"names":[],"mappings":"AAAA,SAAS,KAAT,EAAgB,KAAhB,QAA6B,yBAA7B;AACA,SAAS,gBAAT,QAAiC,2BAAjC;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;;AACH,OAAM,SAAU,kBAAV,CACJ,IADI,EAEJ,KAFI,EAES;EAEb,MAAM;IAAE,QAAF;IAAY,iBAAiB,GAAG,KAAhC;IAAuC,CAAC,eAAD,GAAmB,YAA1D;IAAwE,OAAxE;IAAiF,SAAjF;IAA4F,OAA5F;IAAqG,GAAG;EAAxG,IACJ,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAA,KAAA,GAAS,EADX;EAGA,MAAM,sBAAsB,GAAG,OAAO,YAAP,KAAwB,QAAxB,GAAmC,YAAY,KAAK,MAApD,GAA6D,YAA5F;EAEA,MAAM,UAAU,GAAG,QAAQ,IAAI,iBAAZ,IAAiC,sBAApD;EAEA,MAAM,WAAW,GAAG,gBAAgB,CAAE,EAAD,IAAwD;IAC3F,IAAI,UAAJ,EAAgB;MACd,EAAE,CAAC,cAAH;MACA,EAAE,CAAC,eAAH;IACD,CAHD,MAGO;MACL,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,C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IAAI,KAAK,QAAT,IAAqB,IAAI,KAAK,SAAlC,EAA6C;IAC3C,OAAO,EACL,GAAG,IADE;MAEL,QAAQ,EAAE,QAAQ,IAAI,CAAC,iBAFlB;MAGL,iBAAiB,iBAAiB,GAAG,IAAH,GAAU,sBAHvC;MAIL;MACA;MACA,OAAO,EAAE,iBAAiB,GAAG,SAAH,GAAe,WANpC;MAOL,OAAO,EAAE,iBAAiB,GAAG,SAAH,GAAe,OAPpC;MAQL,SAAS,EAAE,iBAAiB,GAAG,SAAH,GAAe;IARtC,CAAP;EAUD,CAXD,CAaA;EACA;EAdA,KAeK;IACH,MAAM,WAAW,GAAG;MAClB,IAAI,EAAE,QADY;MAElB,QAAQ,EAAE,QAAQ,IAAI,CAAC,iBAAb,GAAiC,SAAjC,GAA6C,CAFrC;MAGlB,GAAG,IAHe;MAIlB;MACA;MACA;MACA,OAAO,EAAE,WAPS;MAQlB,OAAO,EAAE,WARS;MASlB,SAAS,EAAE,aATO;MAUlB,iBAAiB,QAAQ,IAAI,iBAAZ,IAAiC;IAVhC,CAApB;;IAaA,IAAI,IAAI,KAAK,GAAT,IAAgB,UAApB,EAAgC;MAC7B,WAAiD,CAAC,IAAlD,GAAyD,SAAzD;IACF;;IAED,OAAO,WAAP;EACD;AACF","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type { ARIAButtonElementIntersection, ARIAButtonProps, ARIAButtonResultProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n *\n * @param type - the proper scenario to be interpreted by the hook.\n * 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states\n * 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior\n * @param props - the props to be passed down the line to the desired element.\n * This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.\n *\n * @example\n * ```tsx\n * const buttonProps = useARIAButtonProps('a', {\n * href: './some-route'\n * onClick: () => console.log('this should run both on click and Space and Enter')\n * })\n *\n * // ...\n *\n * return (\n * <a {...buttonProps}>This anchor will behave as a proper button</a>\n * )\n * ```\n */\nexport function useARIAButtonProps<Type extends ARIAButtonType, Props extends ARIAButtonProps<Type>>(\n type?: Type,\n props?: Props,\n): ARIAButtonResultProps<Type, Props> {\n const { disabled, disabledFocusable = false, ['aria-disabled']: ariaDisabled, onClick, onKeyDown, onKeyUp, ...rest } =\n props ?? {};\n\n const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;\n\n const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;\n\n const handleClick = useEventCallback((ev: React.MouseEvent<ARIAButtonElementIntersection>) => {\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const handleKeyDown = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n return;\n }\n\n // If enter is pressed, activate the button\n else if (key === Enter) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n const handleKeyUp = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (type === 'button' || type === undefined) {\n return {\n ...rest,\n disabled: disabled && !disabledFocusable,\n 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,\n // onclick should still use internal handler to ensure prevention if disabled\n // if disabledFocusable then there's no requirement for handlers as those events should not be propagated\n onClick: disabledFocusable ? undefined : handleClick,\n onKeyUp: disabledFocusable ? undefined : onKeyUp,\n onKeyDown: disabledFocusable ? undefined : onKeyDown,\n } as ARIAButtonResultProps<Type, Props>;\n }\n\n // If an <a> or <div> tag is to be rendered we have to remove disabled and type,\n // and set aria-disabled, role and tabIndex.\n else {\n const resultProps = {\n role: 'button',\n tabIndex: disabled && !disabledFocusable ? undefined : 0,\n ...rest,\n // If it's not a <button> than listeners are required even with disabledFocusable\n // Since you cannot assure the default behavior of the element\n // E.g: <a> will redirect on click\n onClick: handleClick,\n onKeyUp: handleKeyUp,\n onKeyDown: handleKeyDown,\n 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,\n } as ARIAButtonResultProps<Type, Props>;\n\n if (type === 'a' && isDisabled) {\n (resultProps as ARIAButtonResultProps<'a', Props>).href = undefined;\n }\n\n return resultProps;\n }\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["button/useARIAButtonShorthand.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,QAAiC,2BAAjC;AACA,SAAS,kBAAT,QAAmC,sBAAnC;AAIA;;;;;;;;AAQG;;AACH,OAAO,MAAM,sBAAsB,GAAkD,CAAC,IAAD,EAAO,OAAP,KAAkB;;;EACrG,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAD,EAAO,OAAP,CAAlC;EACA,MAAM,mBAAmB,GAAG,kBAAkB,CAAkC,CAAA,EAAA,GAAA,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAE,EAAX,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,EAAb,GAAiB,QAAnD,EAA6D,SAA7D,CAA9C;EACA,OAAO,SAAS,IAAI,mBAApB;AACD,CAJM","sourcesContent":["import { resolveShorthand } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from './useARIAButtonProps';\nimport type { ResolveShorthandFunction } from '@fluentui/react-utilities';\nimport type { ARIAButtonProps, ARIAButtonSlotProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n */\nexport const useARIAButtonShorthand: ResolveShorthandFunction<ARIAButtonSlotProps> = (slot, options) => {\n const shorthand = resolveShorthand(slot, options);\n const shorthandARIAButton = useARIAButtonProps<ARIAButtonType, ARIAButtonProps>(shorthand?.as ?? 'button', shorthand);\n return shorthand && shorthandARIAButton;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-aria/src/button/useARIAButtonShorthand.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,QAAiC,2BAAjC;AACA,SAAS,kBAAT,QAAmC,sBAAnC;AAIA;;;;;;;;AAQG;;AACH,OAAO,MAAM,sBAAsB,GAAkD,CAAC,IAAD,EAAO,OAAP,KAAkB;;;EACrG,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAD,EAAO,OAAP,CAAlC;EACA,MAAM,mBAAmB,GAAG,kBAAkB,CAAkC,CAAA,EAAA,GAAA,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAE,EAAX,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,EAAb,GAAiB,QAAnD,EAA6D,SAA7D,CAA9C;EACA,OAAO,SAAS,IAAI,mBAApB;AACD,CAJM","sourcesContent":["import { resolveShorthand } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from './useARIAButtonProps';\nimport type { ResolveShorthandFunction } from '@fluentui/react-utilities';\nimport type { ARIAButtonProps, ARIAButtonSlotProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n */\nexport const useARIAButtonShorthand: ResolveShorthandFunction<ARIAButtonSlotProps> = (slot, options) => {\n const shorthand = resolveShorthand(slot, options);\n const shorthandARIAButton = useARIAButtonProps<ARIAButtonType, ARIAButtonProps>(shorthand?.as ?? 'button', shorthand);\n return shorthand && shorthandARIAButton;\n};\n"],"sourceRoot":"../src/"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC","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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-aria/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export { useARIAButtonShorthand, useARIAButtonProps } from './button/index';\nexport type {\n ARIAButtonSlotProps,\n ARIAButtonProps,\n ARIAButtonResultProps,\n ARIAButtonType,\n ARIAButtonElement,\n ARIAButtonElementIntersection,\n ARIAButtonAlteredProps,\n} from './button/index';\n"]}
@@ -0,0 +1,8 @@
1
+ define(["require", "exports", "tslib", "./useARIAButtonProps", "./useARIAButtonShorthand", "./types"], function (require, exports, tslib_1, useARIAButtonProps_1, useARIAButtonShorthand_1, types_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(useARIAButtonProps_1, exports);
5
+ tslib_1.__exportStar(useARIAButtonShorthand_1, exports);
6
+ tslib_1.__exportStar(types_1, exports);
7
+ });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-aria/src/button/index.ts"],"names":[],"mappings":";;;IAAA,oDAAqC;IACrC,wDAAyC;IACzC,uCAAwB","sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"]}
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-aria/src/button/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExtractSlotProps, Slot } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\ntype UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\nexport type ARIAButtonType = 'button' | 'a' | 'div';\n\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"]}
@@ -0,0 +1,105 @@
1
+ define(["require", "exports", "tslib", "@fluentui/keyboard-keys", "@fluentui/react-utilities"], function (require, exports, tslib_1, keyboard_keys_1, react_utilities_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useARIAButtonProps = void 0;
5
+ /**
6
+ * @internal
7
+ *
8
+ * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
9
+ * for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases
10
+ * where no attribute addition is required.
11
+ *
12
+ * @param type - the proper scenario to be interpreted by the hook.
13
+ * 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states
14
+ * 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior
15
+ * @param props - the props to be passed down the line to the desired element.
16
+ * This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * const buttonProps = useARIAButtonProps('a', {
21
+ * href: './some-route'
22
+ * onClick: () => console.log('this should run both on click and Space and Enter')
23
+ * })
24
+ *
25
+ * // ...
26
+ *
27
+ * return (
28
+ * <a {...buttonProps}>This anchor will behave as a proper button</a>
29
+ * )
30
+ * ```
31
+ */
32
+ function useARIAButtonProps(type, props) {
33
+ var _a = props !== null && props !== void 0 ? props : {}, disabled = _a.disabled, _b = _a.disabledFocusable, disabledFocusable = _b === void 0 ? false : _b, ariaDisabled = _a["aria-disabled"], onClick = _a.onClick, onKeyDown = _a.onKeyDown, onKeyUp = _a.onKeyUp, rest = tslib_1.__rest(_a, ["disabled", "disabledFocusable", 'aria-disabled', "onClick", "onKeyDown", "onKeyUp"]);
34
+ var normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;
35
+ var isDisabled = disabled || disabledFocusable || normalizedARIADisabled;
36
+ var handleClick = react_utilities_1.useEventCallback(function (ev) {
37
+ if (isDisabled) {
38
+ ev.preventDefault();
39
+ ev.stopPropagation();
40
+ }
41
+ else {
42
+ onClick === null || onClick === void 0 ? void 0 : onClick(ev);
43
+ }
44
+ });
45
+ var handleKeyDown = react_utilities_1.useEventCallback(function (ev) {
46
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(ev);
47
+ if (ev.isDefaultPrevented()) {
48
+ return;
49
+ }
50
+ var key = ev.key;
51
+ if (isDisabled && (key === keyboard_keys_1.Enter || key === keyboard_keys_1.Space)) {
52
+ ev.preventDefault();
53
+ ev.stopPropagation();
54
+ return;
55
+ }
56
+ if (key === keyboard_keys_1.Space) {
57
+ ev.preventDefault();
58
+ return;
59
+ }
60
+ // If enter is pressed, activate the button
61
+ else if (key === keyboard_keys_1.Enter) {
62
+ ev.preventDefault();
63
+ ev.currentTarget.click();
64
+ }
65
+ });
66
+ var handleKeyUp = react_utilities_1.useEventCallback(function (ev) {
67
+ onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(ev);
68
+ if (ev.isDefaultPrevented()) {
69
+ return;
70
+ }
71
+ var key = ev.key;
72
+ if (isDisabled && (key === keyboard_keys_1.Enter || key === keyboard_keys_1.Space)) {
73
+ ev.preventDefault();
74
+ ev.stopPropagation();
75
+ return;
76
+ }
77
+ if (key === keyboard_keys_1.Space) {
78
+ ev.preventDefault();
79
+ ev.currentTarget.click();
80
+ }
81
+ });
82
+ // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly
83
+ if (type === 'button' || type === undefined) {
84
+ return tslib_1.__assign(tslib_1.__assign({}, rest), { disabled: disabled && !disabledFocusable, 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,
85
+ // onclick should still use internal handler to ensure prevention if disabled
86
+ // if disabledFocusable then there's no requirement for handlers as those events should not be propagated
87
+ onClick: disabledFocusable ? undefined : handleClick, onKeyUp: disabledFocusable ? undefined : onKeyUp, onKeyDown: disabledFocusable ? undefined : onKeyDown });
88
+ }
89
+ // If an <a> or <div> tag is to be rendered we have to remove disabled and type,
90
+ // and set aria-disabled, role and tabIndex.
91
+ else {
92
+ var resultProps = tslib_1.__assign(tslib_1.__assign({ role: 'button', tabIndex: disabled && !disabledFocusable ? undefined : 0 }, rest), {
93
+ // If it's not a <button> than listeners are required even with disabledFocusable
94
+ // Since you cannot assure the default behavior of the element
95
+ // E.g: <a> will redirect on click
96
+ onClick: handleClick, onKeyUp: handleKeyUp, onKeyDown: handleKeyDown, 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled });
97
+ if (type === 'a' && isDisabled) {
98
+ resultProps.href = undefined;
99
+ }
100
+ return resultProps;
101
+ }
102
+ }
103
+ exports.useARIAButtonProps = useARIAButtonProps;
104
+ });
105
+ //# sourceMappingURL=useARIAButtonProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useARIAButtonProps.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-aria/src/button/useARIAButtonProps.ts"],"names":[],"mappings":";;;;IAKA;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,SAAgB,kBAAkB,CAChC,IAAW,EACX,KAAa;QAEb,IAAM,KACJ,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,EADL,QAAQ,cAAA,EAAE,yBAAyB,EAAzB,iBAAiB,mBAAG,KAAK,KAAA,EAAqB,YAAY,sBAAA,EAAE,OAAO,aAAA,EAAE,SAAS,eAAA,EAAE,OAAO,aAAA,EAAK,IAAI,sBAA5G,qFAA8G,CACvG,CAAC;QAEd,IAAM,sBAAsB,GAAG,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC;QAEzG,IAAM,UAAU,GAAG,QAAQ,IAAI,iBAAiB,IAAI,sBAAsB,CAAC;QAE3E,IAAM,WAAW,GAAG,kCAAgB,CAAC,UAAC,EAAmD;YACvF,IAAI,UAAU,EAAE;gBACd,EAAE,CAAC,cAAc,EAAE,CAAC;gBACpB,EAAE,CAAC,eAAe,EAAE,CAAC;aACtB;iBAAM;gBACL,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,EAAE,CAAC,CAAC;aACf;QACH,CAAC,CAAC,CAAC;QAEH,IAAM,aAAa,GAAG,kCAAgB,CAAC,UAAC,EAAsD;YAC5F,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG,EAAE,CAAC,CAAC;YAEhB,IAAI,EAAE,CAAC,kBAAkB,EAAE,EAAE;gBAC3B,OAAO;aACR;YAED,IAAM,GAAG,GAAG,EAAE,CAAC,G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B;gBAClE,6EAA6E;gBAC7E,yGAAyG;gBACzG,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,EACpD,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EAChD,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,GACf,CAAC;SACzC;QAED,gFAAgF;QAChF,4CAA4C;aACvC;YACH,IAAM,WAAW,GAAG,oCAClB,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,QAAQ,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IACrD,IAAI;gBACP,iFAAiF;gBACjF,8DAA8D;gBAC9D,kCAAkC;gBAClC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,aAAa,EACxB,eAAe,EAAE,QAAQ,IAAI,iBAAiB,IAAI,sBAAsB,GACnC,CAAC;YAExC,IAAI,IAAI,KAAK,GAAG,IAAI,UAAU,EAAE;gBAC7B,WAAiD,CAAC,IAAI,GAAG,SAAS,CAAC;aACrE;YAED,OAAO,WAAW,CAAC;SACpB;IACH,CAAC;IAxGD,gDAwGC","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type { ARIAButtonElementIntersection, ARIAButtonProps, ARIAButtonResultProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n *\n * @param type - the proper scenario to be interpreted by the hook.\n * 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states\n * 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior\n * @param props - the props to be passed down the line to the desired element.\n * This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.\n *\n * @example\n * ```tsx\n * const buttonProps = useARIAButtonProps('a', {\n * href: './some-route'\n * onClick: () => console.log('this should run both on click and Space and Enter')\n * })\n *\n * // ...\n *\n * return (\n * <a {...buttonProps}>This anchor will behave as a proper button</a>\n * )\n * ```\n */\nexport function useARIAButtonProps<Type extends ARIAButtonType, Props extends ARIAButtonProps<Type>>(\n type?: Type,\n props?: Props,\n): ARIAButtonResultProps<Type, Props> {\n const { disabled, disabledFocusable = false, ['aria-disabled']: ariaDisabled, onClick, onKeyDown, onKeyUp, ...rest } =\n props ?? {};\n\n const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;\n\n const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;\n\n const handleClick = useEventCallback((ev: React.MouseEvent<ARIAButtonElementIntersection>) => {\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const handleKeyDown = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n return;\n }\n\n // If enter is pressed, activate the button\n else if (key === Enter) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n const handleKeyUp = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (type === 'button' || type === undefined) {\n return {\n ...rest,\n disabled: disabled && !disabledFocusable,\n 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,\n // onclick should still use internal handler to ensure prevention if disabled\n // if disabledFocusable then there's no requirement for handlers as those events should not be propagated\n onClick: disabledFocusable ? undefined : handleClick,\n onKeyUp: disabledFocusable ? undefined : onKeyUp,\n onKeyDown: disabledFocusable ? undefined : onKeyDown,\n } as ARIAButtonResultProps<Type, Props>;\n }\n\n // If an <a> or <div> tag is to be rendered we have to remove disabled and type,\n // and set aria-disabled, role and tabIndex.\n else {\n const resultProps = {\n role: 'button',\n tabIndex: disabled && !disabledFocusable ? undefined : 0,\n ...rest,\n // If it's not a <button> than listeners are required even with disabledFocusable\n // Since you cannot assure the default behavior of the element\n // E.g: <a> will redirect on click\n onClick: handleClick,\n onKeyUp: handleKeyUp,\n onKeyDown: handleKeyDown,\n 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,\n } as ARIAButtonResultProps<Type, Props>;\n\n if (type === 'a' && isDisabled) {\n (resultProps as ARIAButtonResultProps<'a', Props>).href = undefined;\n }\n\n return resultProps;\n }\n}\n"]}
@@ -0,0 +1,22 @@
1
+ define(["require", "exports", "@fluentui/react-utilities", "./useARIAButtonProps"], function (require, exports, react_utilities_1, useARIAButtonProps_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useARIAButtonShorthand = void 0;
5
+ /**
6
+ * @internal
7
+ *
8
+ * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead
9
+ *
10
+ * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
11
+ * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
12
+ * where no attribute addition is required.
13
+ */
14
+ var useARIAButtonShorthand = function (slot, options) {
15
+ var _a;
16
+ var shorthand = react_utilities_1.resolveShorthand(slot, options);
17
+ var shorthandARIAButton = useARIAButtonProps_1.useARIAButtonProps((_a = shorthand === null || shorthand === void 0 ? void 0 : shorthand.as) !== null && _a !== void 0 ? _a : 'button', shorthand);
18
+ return shorthand && shorthandARIAButton;
19
+ };
20
+ exports.useARIAButtonShorthand = useARIAButtonShorthand;
21
+ });
22
+ //# sourceMappingURL=useARIAButtonShorthand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useARIAButtonShorthand.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-aria/src/button/useARIAButtonShorthand.ts"],"names":[],"mappings":";;;;IAKA;;;;;;;;OAQG;IACI,IAAM,sBAAsB,GAAkD,UAAC,IAAI,EAAE,OAAO;;QACjG,IAAM,SAAS,GAAG,kCAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAClD,IAAM,mBAAmB,GAAG,uCAAkB,CAAkC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,EAAE,mCAAI,QAAQ,EAAE,SAAS,CAAC,CAAC;QACtH,OAAO,SAAS,IAAI,mBAAmB,CAAC;IAC1C,CAAC,CAAC;IAJW,QAAA,sBAAsB,0BAIjC","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"]}
@@ -0,0 +1,8 @@
1
+ define(["require", "exports", "./button/index"], function (require, exports, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useARIAButtonProps = exports.useARIAButtonShorthand = void 0;
5
+ Object.defineProperty(exports, "useARIAButtonShorthand", { enumerable: true, get: function () { return index_1.useARIAButtonShorthand; } });
6
+ Object.defineProperty(exports, "useARIAButtonProps", { enumerable: true, get: function () { return index_1.useARIAButtonProps; } });
7
+ });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-aria/src/index.ts"],"names":[],"mappings":";;;;IAAS,+GAAA,sBAAsB,OAAA;IAAE,2GAAA,kBAAkB,OAAA","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"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["button/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,0BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-aria/src/button/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,0BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["button/useARIAButtonProps.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;;;AACH,SAAgB,kBAAhB,CACE,IADF,EAEE,KAFF,EAEe;EAEb,MAAM;IAAE,QAAF;IAAY,iBAAiB,GAAG,KAAhC;IAAuC,CAAC,eAAD,GAAmB,YAA1D;IAAwE,OAAxE;IAAiF,SAAjF;IAA4F,OAA5F;IAAqG,GAAG;EAAxG,IACJ,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAA,KAAA,GAAS,EADX;EAGA,MAAM,sBAAsB,GAAG,OAAO,YAAP,KAAwB,QAAxB,GAAmC,YAAY,KAAK,MAApD,GAA6D,YAA5F;EAEA,MAAM,UAAU,GAAG,QAAQ,IAAI,iBAAZ,IAAiC,sBAApD;EAEA,MAAM,WAAW,GAAG,iBAAA,CAAA,gBAAA,CAAkB,EAAD,IAAwD;IAC3F,IAAI,UAAJ,EAAgB;MACd,EAAE,CAAC,cAAH;MACA,EAAE,CAAC,eAAH;IACD,CAHD,MAGO;MACL,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAG,EAAH,CAAP;IACD;EACF,CAPmB,CAApB;EASA,MAAM,aAAa,GAAG,iBAAA,CAAA,gBAAA,CAAkB,EAAD,IAA2D;IAChG,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAG,EAAH,CAAT;;IAEA,IAAI,EAAE,CAAC,kBAAH,EAAJ,EAA6B;MAC3B;IACD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ACA,OAAO,EAAE,iBAAiB,GAAG,SAAH,GAAe,WANpC;MAOL,OAAO,EAAE,iBAAiB,GAAG,SAAH,GAAe,OAPpC;MAQL,SAAS,EAAE,iBAAiB,GAAG,SAAH,GAAe;IARtC,CAAP;EAUD,CAXD,CAaA;EACA;EAdA,KAeK;IACH,MAAM,WAAW,GAAG;MAClB,IAAI,EAAE,QADY;MAElB,QAAQ,EAAE,QAAQ,IAAI,CAAC,iBAAb,GAAiC,SAAjC,GAA6C,CAFrC;MAGlB,GAAG,IAHe;MAIlB;MACA;MACA;MACA,OAAO,EAAE,WAPS;MAQlB,OAAO,EAAE,WARS;MASlB,SAAS,EAAE,aATO;MAUlB,iBAAiB,QAAQ,IAAI,iBAAZ,IAAiC;IAVhC,CAApB;;IAaA,IAAI,IAAI,KAAK,GAAT,IAAgB,UAApB,EAAgC;MAC7B,WAAiD,CAAC,IAAlD,GAAyD,SAAzD;IACF;;IAED,OAAO,WAAP;EACD;AACF;;AAxGD,OAAA,CAAA,kBAAA,GAAA,kBAAA","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type { ARIAButtonElementIntersection, ARIAButtonProps, ARIAButtonResultProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n *\n * @param type - the proper scenario to be interpreted by the hook.\n * 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states\n * 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior\n * @param props - the props to be passed down the line to the desired element.\n * This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.\n *\n * @example\n * ```tsx\n * const buttonProps = useARIAButtonProps('a', {\n * href: './some-route'\n * onClick: () => console.log('this should run both on click and Space and Enter')\n * })\n *\n * // ...\n *\n * return (\n * <a {...buttonProps}>This anchor will behave as a proper button</a>\n * )\n * ```\n */\nexport function useARIAButtonProps<Type extends ARIAButtonType, Props extends ARIAButtonProps<Type>>(\n type?: Type,\n props?: Props,\n): ARIAButtonResultProps<Type, Props> {\n const { disabled, disabledFocusable = false, ['aria-disabled']: ariaDisabled, onClick, onKeyDown, onKeyUp, ...rest } =\n props ?? {};\n\n const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;\n\n const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;\n\n const handleClick = useEventCallback((ev: React.MouseEvent<ARIAButtonElementIntersection>) => {\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const handleKeyDown = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n return;\n }\n\n // If enter is pressed, activate the button\n else if (key === Enter) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n const handleKeyUp = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (type === 'button' || type === undefined) {\n return {\n ...rest,\n disabled: disabled && !disabledFocusable,\n 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,\n // onclick should still use internal handler to ensure prevention if disabled\n // if disabledFocusable then there's no requirement for handlers as those events should not be propagated\n onClick: disabledFocusable ? undefined : handleClick,\n onKeyUp: disabledFocusable ? undefined : onKeyUp,\n onKeyDown: disabledFocusable ? undefined : onKeyDown,\n } as ARIAButtonResultProps<Type, Props>;\n }\n\n // If an <a> or <div> tag is to be rendered we have to remove disabled and type,\n // and set aria-disabled, role and tabIndex.\n else {\n const resultProps = {\n role: 'button',\n tabIndex: disabled && !disabledFocusable ? undefined : 0,\n ...rest,\n // If it's not a <button> than listeners are required even with disabledFocusable\n // Since you cannot assure the default behavior of the element\n // E.g: <a> will redirect on click\n onClick: handleClick,\n onKeyUp: handleKeyUp,\n onKeyDown: handleKeyDown,\n 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,\n } as ARIAButtonResultProps<Type, Props>;\n\n if (type === 'a' && isDisabled) {\n (resultProps as ARIAButtonResultProps<'a', Props>).href = undefined;\n }\n\n return resultProps;\n }\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-aria/src/button/useARIAButtonProps.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;;;AACH,SAAgB,kBAAhB,CACE,IADF,EAEE,KAFF,EAEe;EAEb,MAAM;IAAE,QAAF;IAAY,iBAAiB,GAAG,KAAhC;IAAuC,CAAC,eAAD,GAAmB,YAA1D;IAAwE,OAAxE;IAAiF,SAAjF;IAA4F,OAA5F;IAAqG,GAAG;EAAxG,IACJ,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAA,KAAA,GAAS,EADX;EAGA,MAAM,sBAAsB,GAAG,OAAO,YAAP,KAAwB,QAAxB,GAAmC,YAAY,KAAK,MAApD,GAA6D,YAA5F;EAEA,MAAM,UAAU,GAAG,QAAQ,IAAI,iBAAZ,IAAiC,sBAApD;EAEA,MAAM,WAAW,GAAG,iBA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A,CAAA,KAAR,IAAiB,GAAG,KAAK,eAAA,CAAA,KAA9B,CAAd,EAAoD;MAClD,EAAE,CAAC,cAAH;MACA,EAAE,CAAC,eAAH;MACA;IACD;;IAED,IAAI,GAAG,KAAK,eAAA,CAAA,KAAZ,EAAmB;MACjB,EAAE,CAAC,cAAH;MACA,EAAE,CAAC,aAAH,CAAiB,KAAjB;IACD;EACF,CAnBmB,CAApB,CA7Ca,CAkEb;;EACA,IAAI,IAAI,KAAK,QAAT,IAAqB,IAAI,KAAK,SAAlC,EAA6C;IAC3C,OAAO,EACL,GAAG,IADE;MAEL,QAAQ,EAAE,QAAQ,IAAI,CAAC,iBAFlB;MAGL,iBAAiB,iBAAiB,GAAG,IAAH,GAAU,sBAHvC;MAIL;MACA;MACA,OAAO,EAAE,iBAAiB,GAAG,SAAH,GAAe,WANpC;MAOL,OAAO,EAAE,iBAAiB,GAAG,SAAH,GAAe,OAPpC;MAQL,SAAS,EAAE,iBAAiB,GAAG,SAAH,GAAe;IARtC,CAAP;EAUD,CAXD,CAaA;EACA;EAdA,KAeK;IACH,MAAM,WAAW,GAAG;MAClB,IAAI,EAAE,QADY;MAElB,QAAQ,EAAE,QAAQ,IAAI,CAAC,iBAAb,GAAiC,SAAjC,GAA6C,CAFrC;MAGlB,GAAG,IAHe;MAIlB;MACA;MACA;MACA,OAAO,EAAE,WAPS;MAQlB,OAAO,EAAE,WARS;MASlB,SAAS,EAAE,aATO;MAUlB,iBAAiB,QAAQ,IAAI,iBAAZ,IAAiC;IAVhC,CAApB;;IAaA,IAAI,IAAI,KAAK,GAAT,IAAgB,UAApB,EAAgC;MAC7B,WAAiD,CAAC,IAAlD,GAAyD,SAAzD;IACF;;IAED,OAAO,WAAP;EACD;AACF;;AAxGD,OAAA,CAAA,kBAAA,GAAA,kBAAA","sourcesContent":["import { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type { ARIAButtonElementIntersection, ARIAButtonProps, ARIAButtonResultProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n *\n * @param type - the proper scenario to be interpreted by the hook.\n * 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states\n * 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior\n * @param props - the props to be passed down the line to the desired element.\n * This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.\n *\n * @example\n * ```tsx\n * const buttonProps = useARIAButtonProps('a', {\n * href: './some-route'\n * onClick: () => console.log('this should run both on click and Space and Enter')\n * })\n *\n * // ...\n *\n * return (\n * <a {...buttonProps}>This anchor will behave as a proper button</a>\n * )\n * ```\n */\nexport function useARIAButtonProps<Type extends ARIAButtonType, Props extends ARIAButtonProps<Type>>(\n type?: Type,\n props?: Props,\n): ARIAButtonResultProps<Type, Props> {\n const { disabled, disabledFocusable = false, ['aria-disabled']: ariaDisabled, onClick, onKeyDown, onKeyUp, ...rest } =\n props ?? {};\n\n const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;\n\n const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;\n\n const handleClick = useEventCallback((ev: React.MouseEvent<ARIAButtonElementIntersection>) => {\n if (isDisabled) {\n ev.preventDefault();\n ev.stopPropagation();\n } else {\n onClick?.(ev);\n }\n });\n\n const handleKeyDown = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyDown?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n return;\n }\n\n // If enter is pressed, activate the button\n else if (key === Enter) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n const handleKeyUp = useEventCallback((ev: React.KeyboardEvent<ARIAButtonElementIntersection>) => {\n onKeyUp?.(ev);\n\n if (ev.isDefaultPrevented()) {\n return;\n }\n\n const key = ev.key;\n\n if (isDisabled && (key === Enter || key === Space)) {\n ev.preventDefault();\n ev.stopPropagation();\n return;\n }\n\n if (key === Space) {\n ev.preventDefault();\n ev.currentTarget.click();\n }\n });\n\n // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly\n if (type === 'button' || type === undefined) {\n return {\n ...rest,\n disabled: disabled && !disabledFocusable,\n 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,\n // onclick should still use internal handler to ensure prevention if disabled\n // if disabledFocusable then there's no requirement for handlers as those events should not be propagated\n onClick: disabledFocusable ? undefined : handleClick,\n onKeyUp: disabledFocusable ? undefined : onKeyUp,\n onKeyDown: disabledFocusable ? undefined : onKeyDown,\n } as ARIAButtonResultProps<Type, Props>;\n }\n\n // If an <a> or <div> tag is to be rendered we have to remove disabled and type,\n // and set aria-disabled, role and tabIndex.\n else {\n const resultProps = {\n role: 'button',\n tabIndex: disabled && !disabledFocusable ? undefined : 0,\n ...rest,\n // If it's not a <button> than listeners are required even with disabledFocusable\n // Since you cannot assure the default behavior of the element\n // E.g: <a> will redirect on click\n onClick: handleClick,\n onKeyUp: handleKeyUp,\n onKeyDown: handleKeyDown,\n 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled,\n } as ARIAButtonResultProps<Type, Props>;\n\n if (type === 'a' && isDisabled) {\n (resultProps as ARIAButtonResultProps<'a', Props>).href = undefined;\n }\n\n return resultProps;\n }\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["button/useARIAButtonShorthand.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,oBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;AAIA;;;;;;;;AAQG;;;AACI,MAAM,sBAAsB,GAAkD,CAAC,IAAD,EAAO,OAAP,KAAkB;;;EACrG,MAAM,SAAS,GAAG,iBAAA,CAAA,gBAAA,CAAiB,IAAjB,EAAuB,OAAvB,CAAlB;EACA,MAAM,mBAAmB,GAAG,oBAAA,CAAA,kBAAA,CAAoD,CAAA,EAAA,GAAA,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAE,EAAX,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,EAAb,GAAiB,QAArE,EAA+E,SAA/E,CAA5B;EACA,OAAO,SAAS,IAAI,mBAApB;AACD,CAJM;;AAAM,OAAA,CAAA,sBAAA,GAAsB,sBAAtB","sourcesContent":["import { resolveShorthand } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from './useARIAButtonProps';\nimport type { ResolveShorthandFunction } from '@fluentui/react-utilities';\nimport type { ARIAButtonProps, ARIAButtonSlotProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n */\nexport const useARIAButtonShorthand: ResolveShorthandFunction<ARIAButtonSlotProps> = (slot, options) => {\n const shorthand = resolveShorthand(slot, options);\n const shorthandARIAButton = useARIAButtonProps<ARIAButtonType, ARIAButtonProps>(shorthand?.as ?? 'button', shorthand);\n return shorthand && shorthandARIAButton;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-aria/src/button/useARIAButtonShorthand.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,oBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;AAIA;;;;;;;;AAQG;;;AACI,MAAM,sBAAsB,GAAkD,CAAC,IAAD,EAAO,OAAP,KAAkB;;;EACrG,MAAM,SAAS,GAAG,iBAAA,CAAA,gBAAA,CAAiB,IAAjB,EAAuB,OAAvB,CAAlB;EACA,MAAM,mBAAmB,GAAG,oBAAA,CAAA,kBAAA,CAAoD,CAAA,EAAA,GAAA,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAE,EAAX,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,EAAb,GAAiB,QAArE,EAA+E,SAA/E,CAA5B;EACA,OAAO,SAAS,IAAI,mBAApB;AACD,CAJM;;AAAM,OAAA,CAAA,sBAAA,GAAsB,sBAAtB","sourcesContent":["import { resolveShorthand } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from './useARIAButtonProps';\nimport type { ResolveShorthandFunction } from '@fluentui/react-utilities';\nimport type { ARIAButtonProps, ARIAButtonSlotProps, ARIAButtonType } from './types';\n\n/**\n * @internal\n *\n * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead\n *\n * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec\n * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases\n * where no attribute addition is required.\n */\nexport const useARIAButtonShorthand: ResolveShorthandFunction<ARIAButtonSlotProps> = (slot, options) => {\n const shorthand = resolveShorthand(slot, options);\n const shorthandARIAButton = useARIAButtonProps<ARIAButtonType, ARIAButtonProps>(shorthand?.as ?? 'button', shorthand);\n return shorthand && shorthandARIAButton;\n};\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,wBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,sBAAA;EAAsB;AAAtB,CAAA;AAAwB,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,oBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,kBAAA;EAAkB;AAAlB,CAAA","sourcesContent":["export { useARIAButtonShorthand, useARIAButtonProps } from './button/index';\nexport type {\n ARIAButtonSlotProps,\n ARIAButtonProps,\n ARIAButtonResultProps,\n ARIAButtonType,\n ARIAButtonElement,\n ARIAButtonElementIntersection,\n ARIAButtonAlteredProps,\n} from './button/index';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-aria/src/index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,wBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,sBAAA;EAAsB;AAAtB,CAAA;AAAwB,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,oBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,kBAAA;EAAkB;AAAlB,CAAA","sourcesContent":["export { useARIAButtonShorthand, useARIAButtonProps } from './button/index';\nexport type {\n ARIAButtonSlotProps,\n ARIAButtonProps,\n ARIAButtonResultProps,\n ARIAButtonType,\n ARIAButtonElement,\n ARIAButtonElementIntersection,\n ARIAButtonAlteredProps,\n} from './button/index';\n"],"sourceRoot":"../src/"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-aria",
3
- "version": "9.3.1",
3
+ "version": "9.3.2",
4
4
  "description": "React helper to ensure ARIA",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -19,10 +19,9 @@
19
19
  "lint": "just-scripts lint",
20
20
  "start": "yarn storybook",
21
21
  "test": "jest --passWithNoTests",
22
- "docs": "api-extractor run --config=config/api-extractor.local.json --local",
23
- "build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/types/types/packages/react-components/react-aria/src && yarn docs",
24
22
  "storybook": "start-storybook",
25
- "type-check": "tsc -b tsconfig.json"
23
+ "type-check": "tsc -b tsconfig.json",
24
+ "generate-api": "tsc -p ./tsconfig.lib.json --emitDeclarationOnly && just-scripts api-extractor"
26
25
  },
27
26
  "devDependencies": {
28
27
  "@fluentui/eslint-plugin": "*",
@@ -31,7 +30,7 @@
31
30
  },
32
31
  "dependencies": {
33
32
  "@fluentui/keyboard-keys": "^9.0.1",
34
- "@fluentui/react-utilities": "^9.2.1",
33
+ "@fluentui/react-utilities": "^9.2.2",
35
34
  "tslib": "^2.1.0"
36
35
  },
37
36
  "peerDependencies": {