@fluentui/react-aria 0.0.0-nightly-20230317-1454.1 → 0.0.0-nightly-20230321-0440.1

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,9 +2,9 @@
2
2
  "name": "@fluentui/react-aria",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 17 Mar 2023 15:00:11 GMT",
6
- "tag": "@fluentui/react-aria_v0.0.0-nightly-20230317-1454.1",
7
- "version": "0.0.0-nightly-20230317-1454.1",
5
+ "date": "Tue, 21 Mar 2023 04:49:52 GMT",
6
+ "tag": "@fluentui/react-aria_v0.0.0-nightly-20230321-0440.1",
7
+ "version": "0.0.0-nightly-20230321-0440.1",
8
8
  "comments": {
9
9
  "prerelease": [
10
10
  {
@@ -16,14 +16,14 @@
16
16
  {
17
17
  "author": "beachball",
18
18
  "package": "@fluentui/react-aria",
19
- "comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-20230317-1454.1",
20
- "commit": "636275472966fa37b1efc14ac2e70ad32bd39b86"
19
+ "comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-20230321-0440.1",
20
+ "commit": "e913db5700c77cb74564f4422c775d52ef302e91"
21
21
  },
22
22
  {
23
23
  "author": "beachball",
24
24
  "package": "@fluentui/react-aria",
25
- "comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230317-1454.1",
26
- "commit": "636275472966fa37b1efc14ac2e70ad32bd39b86"
25
+ "comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230321-0440.1",
26
+ "commit": "e913db5700c77cb74564f4422c775d52ef302e91"
27
27
  }
28
28
  ]
29
29
  }
package/CHANGELOG.md CHANGED
@@ -1,19 +1,19 @@
1
1
  # Change Log - @fluentui/react-aria
2
2
 
3
- This log was last generated on Fri, 17 Mar 2023 15:00:11 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 21 Mar 2023 04:49:52 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [0.0.0-nightly-20230317-1454.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v0.0.0-nightly-20230317-1454.1)
7
+ ## [0.0.0-nightly-20230321-0440.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v0.0.0-nightly-20230321-0440.1)
8
8
 
9
- Fri, 17 Mar 2023 15:00:11 GMT
10
- [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.3.14..@fluentui/react-aria_v0.0.0-nightly-20230317-1454.1)
9
+ Tue, 21 Mar 2023 04:49:52 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.3.14..@fluentui/react-aria_v0.0.0-nightly-20230321-0440.1)
11
11
 
12
12
  ### Changes
13
13
 
14
14
  - Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
15
- - Bump @fluentui/keyboard-keys to v0.0.0-nightly-20230317-1454.1 ([commit](https://github.com/microsoft/fluentui/commit/636275472966fa37b1efc14ac2e70ad32bd39b86) by beachball)
16
- - Bump @fluentui/react-utilities to v0.0.0-nightly-20230317-1454.1 ([commit](https://github.com/microsoft/fluentui/commit/636275472966fa37b1efc14ac2e70ad32bd39b86) by beachball)
15
+ - Bump @fluentui/keyboard-keys to v0.0.0-nightly-20230321-0440.1 ([commit](https://github.com/microsoft/fluentui/commit/e913db5700c77cb74564f4422c775d52ef302e91) by beachball)
16
+ - Bump @fluentui/react-utilities to v0.0.0-nightly-20230321-0440.1 ([commit](https://github.com/microsoft/fluentui/commit/e913db5700c77cb74564f4422c775d52ef302e91) by beachball)
17
17
 
18
18
  ## [9.3.14](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.3.14)
19
19
 
@@ -1,4 +1,4 @@
1
- export * from "./useARIAButtonProps";
2
- export * from "./useARIAButtonShorthand";
3
- export * from "./types";
1
+ export * from './useARIAButtonProps';
2
+ export * from './useARIAButtonShorthand';
3
+ export * from './types';
4
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,"file":"index.js","sourceRoot":"","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,2 +1,2 @@
1
- import * as React from "react";
1
+ export {};
2
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,"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"]}
@@ -1,6 +1,5 @@
1
- import { Enter, Space } from "@fluentui/keyboard-keys";
2
- import { useEventCallback } from "@fluentui/react-utilities";
3
- import * as React from "react";
1
+ import { Enter, Space } from '@fluentui/keyboard-keys';
2
+ import { useEventCallback } from '@fluentui/react-utilities';
4
3
  /**
5
4
  * @internal
6
5
  *
@@ -32,24 +31,24 @@ export function useARIAButtonProps(type, props) {
32
31
  const {
33
32
  disabled,
34
33
  disabledFocusable = false,
35
- ["aria-disabled"]: ariaDisabled,
34
+ ['aria-disabled']: ariaDisabled,
36
35
  onClick,
37
36
  onKeyDown,
38
37
  onKeyUp,
39
38
  ...rest
40
- } = props ?? {};
41
- const normalizedARIADisabled = typeof ariaDisabled === "string" ? ariaDisabled === "true" : ariaDisabled;
39
+ } = props !== null && props !== void 0 ? props : {};
40
+ const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;
42
41
  const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;
43
42
  const handleClick = useEventCallback(ev => {
44
43
  if (isDisabled) {
45
44
  ev.preventDefault();
46
45
  ev.stopPropagation();
47
46
  } else {
48
- onClick?.(ev);
47
+ onClick === null || onClick === void 0 ? void 0 : onClick(ev);
49
48
  }
50
49
  });
51
50
  const handleKeyDown = useEventCallback(ev => {
52
- onKeyDown?.(ev);
51
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(ev);
53
52
  if (ev.isDefaultPrevented()) {
54
53
  return;
55
54
  }
@@ -62,13 +61,15 @@ export function useARIAButtonProps(type, props) {
62
61
  if (key === Space) {
63
62
  ev.preventDefault();
64
63
  return;
65
- } else if (key === Enter) {
64
+ }
65
+ // If enter is pressed, activate the button
66
+ else if (key === Enter) {
66
67
  ev.preventDefault();
67
68
  ev.currentTarget.click();
68
69
  }
69
70
  });
70
71
  const handleKeyUp = useEventCallback(ev => {
71
- onKeyUp?.(ev);
72
+ onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(ev);
72
73
  if (ev.isDefaultPrevented()) {
73
74
  return;
74
75
  }
@@ -84,20 +85,23 @@ export function useARIAButtonProps(type, props) {
84
85
  }
85
86
  });
86
87
  // 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
+ if (type === 'button' || type === undefined) {
88
89
  return {
89
90
  ...rest,
90
91
  disabled: disabled && !disabledFocusable,
91
- "aria-disabled": disabledFocusable ? true : normalizedARIADisabled,
92
+ 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,
92
93
  // onclick should still use internal handler to ensure prevention if disabled
93
94
  // if disabledFocusable then there's no requirement for handlers as those events should not be propagated
94
95
  onClick: disabledFocusable ? undefined : handleClick,
95
96
  onKeyUp: disabledFocusable ? undefined : onKeyUp,
96
97
  onKeyDown: disabledFocusable ? undefined : onKeyDown
97
98
  };
98
- } else {
99
+ }
100
+ // If an <a> or <div> tag is to be rendered we have to remove disabled and type,
101
+ // and set aria-disabled, role and tabIndex.
102
+ else {
99
103
  const resultProps = {
100
- role: "button",
104
+ role: 'button',
101
105
  tabIndex: disabled && !disabledFocusable ? undefined : 0,
102
106
  ...rest,
103
107
  // If it's not a <button> than listeners are required even with disabledFocusable
@@ -106,9 +110,9 @@ export function useARIAButtonProps(type, props) {
106
110
  onClick: handleClick,
107
111
  onKeyUp: handleKeyUp,
108
112
  onKeyDown: handleKeyDown,
109
- "aria-disabled": disabled || disabledFocusable || normalizedARIADisabled
113
+ 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled
110
114
  };
111
- if (type === "a" && isDisabled) {
115
+ if (type === 'a' && isDisabled) {
112
116
  resultProps.href = undefined;
113
117
  }
114
118
  return resultProps;
@@ -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,YAA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AkB,IAAI;MAC3B;IACF;IAEA,MAAMC,GAAA,GAAML,EAAA,CAAGK,GAAG;IAElB,IAAIP,UAAA,KAAeO,GAAA,KAAQtB,KAAA,IAASsB,GAAA,KAAQrB,KAAI,GAAI;MAClDgB,EAAA,CAAGC,cAAc;MACjBD,EAAA,CAAGE,eAAe;MAClB;IACF;IAEA,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,"names":["Enter","Space","useEventCallback","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":["../../../../../../../../packages/react-components/react-aria/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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G,CAAC;MACxD,GAAGb,IAAI;MACP;MACA;MACA;MACAH,OAAO,EAAEM,WAAW;MACpBJ,OAAO,EAAEa,WAAW;MACpBd,SAAS,EAAES,aAAa;MACxB,eAAe,EAAEb,QAAQ,IAAIC,iBAAiB,IAAIM;KACb;IAEvC,IAAIT,IAAI,KAAK,GAAG,IAAIU,UAAU,EAAE;MAC7BY,WAAiD,CAACG,IAAI,GAAGJ,SAAS;;IAGrE,OAAOC,WAAW;;AAEtB"}
@@ -1,5 +1,5 @@
1
- import { resolveShorthand } from "@fluentui/react-utilities";
2
- import { useARIAButtonProps } from "./useARIAButtonProps";
1
+ import { resolveShorthand } from '@fluentui/react-utilities';
2
+ import { useARIAButtonProps } from './useARIAButtonProps';
3
3
  /**
4
4
  * @internal
5
5
  *
@@ -10,8 +10,9 @@ import { useARIAButtonProps } from "./useARIAButtonProps";
10
10
  * where no attribute addition is required.
11
11
  */
12
12
  export const useARIAButtonShorthand = (slot, options) => {
13
+ var _a;
13
14
  const shorthand = resolveShorthand(slot, options);
14
- const shorthandARIAButton = useARIAButtonProps(shorthand?.as ?? "button", shorthand);
15
+ const shorthandARIAButton = useARIAButtonProps((_a = shorthand === null || shorthand === void 0 ? void 0 : shorthand.as) !== null && _a !== void 0 ? _a : 'button', shorthand);
15
16
  return shorthand && shorthandARIAButton;
16
17
  };
17
18
  //# sourceMappingURL=useARIAButtonShorthand.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["resolveShorthand","useARIAButtonProps","useARIAButtonShorthand","slot","options","shorthand","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;EACzC,MAAME,mBAAA,GAAsBL,kBAAA,CAAoDI,SAAA,EAAWE,EAAA,IAAM,UAAUF,SAAA;EAC3G,OAAOA,SAAA,IAAaC,mBAAA;AACtB"}
1
+ {"version":3,"names":["resolveShorthand","useARIAButtonProps","useARIAButtonShorthand","slot","options","shorthand","shorthandARIAButton","_a","as"],"sources":["../../../../../../../../packages/react-components/react-aria/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,2BAA2B;AAC5D,SAASC,kBAAkB,QAAQ,sBAAsB;AAIzD;;;;;;;;;AASA,OAAO,MAAMC,sBAAsB,GAAkDA,CAACC,IAAI,EAAEC,OAAO,KAAI;;EACrG,MAAMC,SAAS,GAAGL,gBAAgB,CAACG,IAAI,EAAEC,OAAO,CAAC;EACjD,MAAME,mBAAmB,GAAGL,kBAAkB,CAAkC,CAAAM,EAAA,GAAAF,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEG,EAAE,cAAAD,EAAA,cAAAA,EAAA,GAAI,QAAQ,EAAEF,SAAS,CAAC;EACrH,OAAOA,SAAS,IAAIC,mBAAmB;AACzC,CAAC"}
package/lib/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { useARIAButtonShorthand, useARIAButtonProps } from "./button/index";
1
+ export { useARIAButtonShorthand, useARIAButtonProps } from './button/index';
2
2
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"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,"file":"index.js","sourceRoot":"","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"]}
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
+
2
3
  Object.defineProperty(exports, "__esModule", {
3
- value: true
4
+ value: true
4
5
  });
5
- const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
- _exportStar(require("./useARIAButtonProps"), exports);
7
- _exportStar(require("./useARIAButtonShorthand"), exports);
8
- _exportStar(require("./types"), exports);
9
- //# sourceMappingURL=index.js.map
10
-
6
+ const tslib_1 = /*#__PURE__*/require("tslib");
7
+ tslib_1.__exportStar(require("./useARIAButtonProps"), exports);
8
+ tslib_1.__exportStar(require("./useARIAButtonShorthand"), exports);
9
+ tslib_1.__exportStar(require("./types"), exports);
11
10
  //# 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,"names":["tslib_1","__exportStar","require","exports"],"sources":["../../../../../../../../packages/react-components/react-aria/src/button/index.ts"],"sourcesContent":["export * from './useARIAButtonProps';\nexport * from './useARIAButtonShorthand';\nexport * from './types';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,0BAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,8BAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,aAAAC,OAAA"}
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
+
2
3
  Object.defineProperty(exports, "__esModule", {
3
- value: true
4
+ value: true
4
5
  });
5
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
6
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
7
- //# sourceMappingURL=types.js.map
8
-
9
6
  //# 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,"names":[],"sources":["../../../../../../../../packages/react-components/react-aria/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":""}
@@ -1,92 +1,128 @@
1
1
  "use strict";
2
+
2
3
  Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "useARIAButtonProps", {
6
- enumerable: true,
7
- get: ()=>useARIAButtonProps
4
+ value: true
8
5
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _keyboardKeys = require("@fluentui/keyboard-keys");
11
- const _reactUtilities = require("@fluentui/react-utilities");
12
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
6
+ exports.useARIAButtonProps = void 0;
7
+ const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
8
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
9
+ /**
10
+ * @internal
11
+ *
12
+ * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
13
+ * for multiple scenarios of non native button elements. Ensuring 1st rule of ARIA for cases
14
+ * where no attribute addition is required.
15
+ *
16
+ * @param type - the proper scenario to be interpreted by the hook.
17
+ * 1. `button` - Minimal interference from the hook, as semantic button already supports most of the states
18
+ * 2. `a` or `div` - Proper keyboard/mouse handling plus other support to ensure ARIA behavior
19
+ * @param props - the props to be passed down the line to the desired element.
20
+ * This hook will encapsulate proper properties, such as `onClick`, `onKeyDown`, `onKeyUp`, etc,.
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * const buttonProps = useARIAButtonProps('a', {
25
+ * href: './some-route'
26
+ * onClick: () => console.log('this should run both on click and Space and Enter')
27
+ * })
28
+ *
29
+ * // ...
30
+ *
31
+ * return (
32
+ * <a {...buttonProps}>This anchor will behave as a proper button</a>
33
+ * )
34
+ * ```
35
+ */
13
36
  function useARIAButtonProps(type, props) {
14
- const { disabled , disabledFocusable =false , ["aria-disabled"]: ariaDisabled , onClick , onKeyDown , onKeyUp , ...rest } = props ?? {};
15
- const normalizedARIADisabled = typeof ariaDisabled === "string" ? ariaDisabled === "true" : ariaDisabled;
16
- const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;
17
- const handleClick = (0, _reactUtilities.useEventCallback)((ev)=>{
18
- if (isDisabled) {
19
- ev.preventDefault();
20
- ev.stopPropagation();
21
- } else {
22
- onClick?.(ev);
23
- }
24
- });
25
- const handleKeyDown = (0, _reactUtilities.useEventCallback)((ev)=>{
26
- onKeyDown?.(ev);
27
- if (ev.isDefaultPrevented()) {
28
- return;
29
- }
30
- const key = ev.key;
31
- if (isDisabled && (key === _keyboardKeys.Enter || key === _keyboardKeys.Space)) {
32
- ev.preventDefault();
33
- ev.stopPropagation();
34
- return;
35
- }
36
- if (key === _keyboardKeys.Space) {
37
- ev.preventDefault();
38
- return;
39
- } else if (key === _keyboardKeys.Enter) {
40
- ev.preventDefault();
41
- ev.currentTarget.click();
42
- }
43
- });
44
- const handleKeyUp = (0, _reactUtilities.useEventCallback)((ev)=>{
45
- onKeyUp?.(ev);
46
- if (ev.isDefaultPrevented()) {
47
- return;
48
- }
49
- const key = ev.key;
50
- if (isDisabled && (key === _keyboardKeys.Enter || key === _keyboardKeys.Space)) {
51
- ev.preventDefault();
52
- ev.stopPropagation();
53
- return;
54
- }
55
- if (key === _keyboardKeys.Space) {
56
- ev.preventDefault();
57
- ev.currentTarget.click();
58
- }
59
- });
60
- // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly
61
- if (type === "button" || type === undefined) {
62
- return {
63
- ...rest,
64
- disabled: disabled && !disabledFocusable,
65
- "aria-disabled": disabledFocusable ? true : normalizedARIADisabled,
66
- // onclick should still use internal handler to ensure prevention if disabled
67
- // if disabledFocusable then there's no requirement for handlers as those events should not be propagated
68
- onClick: disabledFocusable ? undefined : handleClick,
69
- onKeyUp: disabledFocusable ? undefined : onKeyUp,
70
- onKeyDown: disabledFocusable ? undefined : onKeyDown
71
- };
37
+ const {
38
+ disabled,
39
+ disabledFocusable = false,
40
+ ['aria-disabled']: ariaDisabled,
41
+ onClick,
42
+ onKeyDown,
43
+ onKeyUp,
44
+ ...rest
45
+ } = props !== null && props !== void 0 ? props : {};
46
+ const normalizedARIADisabled = typeof ariaDisabled === 'string' ? ariaDisabled === 'true' : ariaDisabled;
47
+ const isDisabled = disabled || disabledFocusable || normalizedARIADisabled;
48
+ const handleClick = react_utilities_1.useEventCallback(ev => {
49
+ if (isDisabled) {
50
+ ev.preventDefault();
51
+ ev.stopPropagation();
72
52
  } else {
73
- const resultProps = {
74
- role: "button",
75
- tabIndex: disabled && !disabledFocusable ? undefined : 0,
76
- ...rest,
77
- // If it's not a <button> than listeners are required even with disabledFocusable
78
- // Since you cannot assure the default behavior of the element
79
- // E.g: <a> will redirect on click
80
- onClick: handleClick,
81
- onKeyUp: handleKeyUp,
82
- onKeyDown: handleKeyDown,
83
- "aria-disabled": disabled || disabledFocusable || normalizedARIADisabled
84
- };
85
- if (type === "a" && isDisabled) {
86
- resultProps.href = undefined;
87
- }
88
- return resultProps;
53
+ onClick === null || onClick === void 0 ? void 0 : onClick(ev);
89
54
  }
90
- } //# sourceMappingURL=useARIAButtonProps.js.map
91
-
55
+ });
56
+ const handleKeyDown = react_utilities_1.useEventCallback(ev => {
57
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(ev);
58
+ if (ev.isDefaultPrevented()) {
59
+ return;
60
+ }
61
+ const key = ev.key;
62
+ if (isDisabled && (key === keyboard_keys_1.Enter || key === keyboard_keys_1.Space)) {
63
+ ev.preventDefault();
64
+ ev.stopPropagation();
65
+ return;
66
+ }
67
+ if (key === keyboard_keys_1.Space) {
68
+ ev.preventDefault();
69
+ return;
70
+ }
71
+ // If enter is pressed, activate the button
72
+ else if (key === keyboard_keys_1.Enter) {
73
+ ev.preventDefault();
74
+ ev.currentTarget.click();
75
+ }
76
+ });
77
+ const handleKeyUp = react_utilities_1.useEventCallback(ev => {
78
+ onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(ev);
79
+ if (ev.isDefaultPrevented()) {
80
+ return;
81
+ }
82
+ const key = ev.key;
83
+ if (isDisabled && (key === keyboard_keys_1.Enter || key === keyboard_keys_1.Space)) {
84
+ ev.preventDefault();
85
+ ev.stopPropagation();
86
+ return;
87
+ }
88
+ if (key === keyboard_keys_1.Space) {
89
+ ev.preventDefault();
90
+ ev.currentTarget.click();
91
+ }
92
+ });
93
+ // If a <button> tag is to be rendered we just need to set disabled and aria-disabled correctly
94
+ if (type === 'button' || type === undefined) {
95
+ return {
96
+ ...rest,
97
+ disabled: disabled && !disabledFocusable,
98
+ 'aria-disabled': disabledFocusable ? true : normalizedARIADisabled,
99
+ // onclick should still use internal handler to ensure prevention if disabled
100
+ // if disabledFocusable then there's no requirement for handlers as those events should not be propagated
101
+ onClick: disabledFocusable ? undefined : handleClick,
102
+ onKeyUp: disabledFocusable ? undefined : onKeyUp,
103
+ onKeyDown: disabledFocusable ? undefined : onKeyDown
104
+ };
105
+ }
106
+ // If an <a> or <div> tag is to be rendered we have to remove disabled and type,
107
+ // and set aria-disabled, role and tabIndex.
108
+ else {
109
+ const resultProps = {
110
+ role: 'button',
111
+ tabIndex: disabled && !disabledFocusable ? undefined : 0,
112
+ ...rest,
113
+ // If it's not a <button> than listeners are required even with disabledFocusable
114
+ // Since you cannot assure the default behavior of the element
115
+ // E.g: <a> will redirect on click
116
+ onClick: handleClick,
117
+ onKeyUp: handleKeyUp,
118
+ onKeyDown: handleKeyDown,
119
+ 'aria-disabled': disabled || disabledFocusable || normalizedARIADisabled
120
+ };
121
+ if (type === 'a' && isDisabled) {
122
+ resultProps.href = undefined;
123
+ }
124
+ return resultProps;
125
+ }
126
+ }
127
+ exports.useARIAButtonProps = useARIAButtonProps;
92
128
  //# sourceMappingURL=useARIAButtonProps.js.map
@@ -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 ?? {};\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?.(ev);\n }\n });\n const handleKeyDown = useEventCallback(ev => {\n 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?.(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,SAAS,CAAC;IACd,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,UAAUQ;QACZ,CAAC;IACH;IACA,MAAMG,gBAAgBJ,IAAAA,gCAAgB,EAACC,CAAAA,KAAM;QAC3CP,YAAYO;QACZ,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,CAAC;QACD,IAAIG,QAAQE,mBAAK,EAAE;YACjBP,GAAGC,cAAc;YACjB;QACF,OAAO,IAAII,QAAQC,mBAAK,EAAE;YACxBN,GAAGC,cAAc;YACjBD,GAAGQ,aAAa,CAACC,KAAK;QACxB,CAAC;IACH;IACA,MAAMC,cAAcX,IAAAA,gCAAgB,EAACC,CAAAA,KAAM;QACzCN,UAAUM;QACV,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,CAAC;QACD,IAAIG,QAAQE,mBAAK,EAAE;YACjBP,GAAGC,cAAc;YACjBD,GAAGQ,aAAa,CAACC,KAAK;QACxB,CAAC;IACH;IACA,+FAA+F;IAC/F,IAAItB,SAAS,YAAYA,SAASwB,WAAW;QAC3C,OAAO;YACL,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;QACtD;IACF,OAAO;QACL,MAAMmB,cAAc;YAClBC,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;QACpD;QACA,IAAIT,SAAS,OAAOU,YAAY;YAC9Be,YAAYG,IAAI,GAAGJ;QACrB,CAAC;QACD,OAAOC;IACT,CAAC;AACH,EACA,8CAA8C"}
1
+ {"version":3,"names":["keyboard_keys_1","require","react_utilities_1","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","exports"],"sources":["../../../../../../../../packages/react-components/react-aria/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,MAAAA,eAAA,gBAAAC,OAAA;AACA,MAAAC,iBAAA,gBAAAD,OAAA;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgBE,kBAAkBA,CAChCC,IAAW,EACXC,KAAa;EA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MACpBjB,SAAS,EAAEU,aAAa;MACxB,eAAe,EAAEd,QAAQ,IAAIC,iBAAiB,IAAIM;KACb;IAEvC,IAAIT,IAAI,KAAK,GAAG,IAAIU,UAAU,EAAE;MAC7Be,WAAiD,CAACG,IAAI,GAAGJ,SAAS;;IAGrE,OAAOC,WAAW;;AAEtB;AA/GAI,OAAA,CAAA9B,kBAAA,GAAAA,kBAAA"}
@@ -1,17 +1,25 @@
1
1
  "use strict";
2
+
2
3
  Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "useARIAButtonShorthand", {
6
- enumerable: true,
7
- get: ()=>useARIAButtonShorthand
4
+ value: true
8
5
  });
9
- const _reactUtilities = require("@fluentui/react-utilities");
10
- const _useARIAButtonProps = require("./useARIAButtonProps");
11
- const useARIAButtonShorthand = (slot, options)=>{
12
- const shorthand = (0, _reactUtilities.resolveShorthand)(slot, options);
13
- const shorthandARIAButton = (0, _useARIAButtonProps.useARIAButtonProps)(shorthand?.as ?? "button", shorthand);
14
- return shorthand && shorthandARIAButton;
15
- }; //# sourceMappingURL=useARIAButtonShorthand.js.map
16
-
6
+ exports.useARIAButtonShorthand = void 0;
7
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
8
+ const useARIAButtonProps_1 = /*#__PURE__*/require("./useARIAButtonProps");
9
+ /**
10
+ * @internal
11
+ *
12
+ * This function expects to receive a slot, if `as` property is not desired use `useARIAButtonProps` instead
13
+ *
14
+ * Button keyboard handling, role, disabled and tabIndex implementation that ensures ARIA spec
15
+ * for multiple scenarios of shorthand properties. Ensuring 1st rule of ARIA for cases
16
+ * where no attribute addition is required.
17
+ */
18
+ const useARIAButtonShorthand = (slot, options) => {
19
+ var _a;
20
+ const shorthand = react_utilities_1.resolveShorthand(slot, options);
21
+ const shorthandARIAButton = useARIAButtonProps_1.useARIAButtonProps((_a = shorthand === null || shorthand === void 0 ? void 0 : shorthand.as) !== null && _a !== void 0 ? _a : 'button', shorthand);
22
+ return shorthand && shorthandARIAButton;
23
+ };
24
+ exports.useARIAButtonShorthand = useARIAButtonShorthand;
17
25
  //# sourceMappingURL=useARIAButtonShorthand.js.map
@@ -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 const shorthandARIAButton = useARIAButtonProps(shorthand?.as ?? \"button\", shorthand);\n return shorthand && shorthandARIAButton;\n};\n//# sourceMappingURL=useARIAButtonShorthand.js.map"],"names":["useARIAButtonShorthand","slot","options","shorthand","resolveShorthand","shorthandARIAButton","useARIAButtonProps","as"],"mappings":";;;;+BAWaA;;aAAAA;;gCAXoB;oCACE;AAU5B,MAAMA,yBAAyB,CAACC,MAAMC,UAAY;IACvD,MAAMC,YAAYC,IAAAA,gCAAgB,EAACH,MAAMC;IACzC,MAAMG,sBAAsBC,IAAAA,sCAAkB,EAACH,WAAWI,MAAM,UAAUJ;IAC1E,OAAOA,aAAaE;AACtB,GACA,kDAAkD"}
1
+ {"version":3,"names":["react_utilities_1","require","useARIAButtonProps_1","useARIAButtonShorthand","slot","options","shorthand","resolveShorthand","shorthandARIAButton","useARIAButtonProps","_a","as","exports"],"sources":["../../../../../../../../packages/react-components/react-aria/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,MAAAA,iBAAA,gBAAAC,OAAA;AACA,MAAAC,oBAAA,gBAAAD,OAAA;AAIA;;;;;;;;;AASO,MAAME,sBAAsB,GAAkDA,CAACC,IAAI,EAAEC,OAAO,KAAI;;EACrG,MAAMC,SAAS,GAAGN,iBAAA,CAAAO,gBAAgB,CAACH,IAAI,EAAEC,OAAO,CAAC;EACjD,MAAMG,mBAAmB,GAAGN,oBAAA,CAAAO,kBAAkB,CAAkC,CAAAC,EAAA,GAAAJ,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEK,EAAE,cAAAD,EAAA,cAAAA,EAAA,GAAI,QAAQ,EAAEJ,SAAS,CAAC;EACrH,OAAOA,SAAS,IAAIE,mBAAmB;AACzC,CAAC;AAJYI,OAAA,CAAAT,sBAAsB,GAAAA,sBAAA"}
@@ -1,18 +1,20 @@
1
1
  "use strict";
2
+
2
3
  Object.defineProperty(exports, "__esModule", {
3
- value: true
4
+ value: true
4
5
  });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- useARIAButtonShorthand: ()=>_index.useARIAButtonShorthand,
13
- useARIAButtonProps: ()=>_index.useARIAButtonProps
6
+ exports.useARIAButtonProps = exports.useARIAButtonShorthand = void 0;
7
+ var index_1 = /*#__PURE__*/require("./button/index");
8
+ Object.defineProperty(exports, "useARIAButtonShorthand", {
9
+ enumerable: true,
10
+ get: function () {
11
+ return index_1.useARIAButtonShorthand;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "useARIAButtonProps", {
15
+ enumerable: true,
16
+ get: function () {
17
+ return index_1.useARIAButtonProps;
18
+ }
14
19
  });
15
- const _index = require("./button/index");
16
- //# sourceMappingURL=index.js.map
17
-
18
20
  //# 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,"names":["index_1","require","Object","defineProperty","exports","enumerable","get","useARIAButtonShorthand","useARIAButtonProps"],"sources":["../../../../../../../packages/react-components/react-aria/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,IAAAA,OAAA,gBAAAC,OAAA;AAASC,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAN,OAAA,CAAAO,sBAAsB;EAAA;AAAA;AAAEL,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAN,OAAA,CAAAQ,kBAAkB;EAAA;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-aria",
3
- "version": "0.0.0-nightly-20230317-1454.1",
3
+ "version": "0.0.0-nightly-20230321-0440.1",
4
4
  "description": "React helper to ensure ARIA",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -21,7 +21,7 @@
21
21
  "test": "jest --passWithNoTests",
22
22
  "storybook": "start-storybook",
23
23
  "type-check": "tsc -b tsconfig.json",
24
- "generate-api": "just-scripts generate-api"
24
+ "generate-api": "tsc -p ./tsconfig.lib.json --emitDeclarationOnly && just-scripts api-extractor"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@fluentui/eslint-plugin": "*",
@@ -30,9 +30,9 @@
30
30
  "@fluentui/scripts-tasks": "*"
31
31
  },
32
32
  "dependencies": {
33
- "@fluentui/keyboard-keys": "0.0.0-nightly-20230317-1454.1",
34
- "@fluentui/react-utilities": "0.0.0-nightly-20230317-1454.1",
35
- "@swc/helpers": "^0.4.14"
33
+ "@fluentui/keyboard-keys": "0.0.0-nightly-20230321-0440.1",
34
+ "@fluentui/react-utilities": "0.0.0-nightly-20230321-0440.1",
35
+ "tslib": "^2.1.0"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@types/react": ">=16.8.0 <19.0.0",
@@ -44,6 +44,7 @@
44
44
  "exports": {
45
45
  ".": {
46
46
  "types": "./dist/index.d.ts",
47
+ "node": "./lib-commonjs/index.js",
47
48
  "import": "./lib/index.js",
48
49
  "require": "./lib-commonjs/index.js"
49
50
  },
package/.swcrc DELETED
@@ -1,39 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/swcrc",
3
- "env": {
4
- "targets": {
5
- "chrome": "84",
6
- "edge": "84",
7
- "firefox": "75",
8
- "opera": "73",
9
- "safari": "14.1"
10
- },
11
- "bugfixes": true
12
- },
13
- "exclude": [
14
- "/testing",
15
- "/**/*.cy.ts",
16
- "/**/*.cy.tsx",
17
- "/**/*.spec.ts",
18
- "/**/*.spec.tsx",
19
- "/**/*.test.ts",
20
- "/**/*.test.tsx"
21
- ],
22
- "jsc": {
23
- "parser": {
24
- "syntax": "typescript",
25
- "tsx": true,
26
- "decorators": false,
27
- "dynamicImport": false
28
- },
29
- "externalHelpers": true,
30
- "transform": {
31
- "react": {
32
- "runtime": "classic",
33
- "useSpread": true
34
- }
35
- }
36
- },
37
- "minify": false,
38
- "sourceMaps": true
39
- }