@react-aria/button 3.6.3 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,112 @@
1
+ import {mergeProps as $cE0pI$mergeProps, filterDOMProps as $cE0pI$filterDOMProps, chain as $cE0pI$chain} from "@react-aria/utils";
2
+ import {useFocusable as $cE0pI$useFocusable} from "@react-aria/focus";
3
+ import {usePress as $cE0pI$usePress} from "@react-aria/interactions";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */ /*
16
+ * Copyright 2020 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */
26
+
27
+
28
+
29
+ function $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
30
+ let { elementType: elementType = "button" , isDisabled: isDisabled , onPress: onPress , onPressStart: onPressStart , onPressEnd: onPressEnd , onPressChange: onPressChange , preventFocusOnPress: // @ts-ignore - undocumented
31
+ preventFocusOnPress , allowFocusWhenDisabled: // @ts-ignore - undocumented
32
+ allowFocusWhenDisabled , // @ts-ignore
33
+ onClick: deprecatedOnClick , href: href , target: target , rel: rel , type: type = "button" } = props;
34
+ let additionalProps;
35
+ if (elementType === "button") additionalProps = {
36
+ type: type,
37
+ disabled: isDisabled
38
+ };
39
+ else additionalProps = {
40
+ role: "button",
41
+ tabIndex: isDisabled ? undefined : 0,
42
+ href: elementType === "a" && isDisabled ? undefined : href,
43
+ target: elementType === "a" ? target : undefined,
44
+ type: elementType === "input" ? type : undefined,
45
+ disabled: elementType === "input" ? isDisabled : undefined,
46
+ "aria-disabled": !isDisabled || elementType === "input" ? undefined : isDisabled,
47
+ rel: elementType === "a" ? rel : undefined
48
+ };
49
+ let { pressProps: pressProps , isPressed: isPressed } = (0, $cE0pI$usePress)({
50
+ onPressStart: onPressStart,
51
+ onPressEnd: onPressEnd,
52
+ onPressChange: onPressChange,
53
+ onPress: onPress,
54
+ isDisabled: isDisabled,
55
+ preventFocusOnPress: preventFocusOnPress,
56
+ ref: ref
57
+ });
58
+ let { focusableProps: focusableProps } = (0, $cE0pI$useFocusable)(props, ref);
59
+ if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
60
+ let buttonProps = (0, $cE0pI$mergeProps)(focusableProps, pressProps, (0, $cE0pI$filterDOMProps)(props, {
61
+ labelable: true
62
+ }));
63
+ return {
64
+ isPressed: isPressed,
65
+ buttonProps: (0, $cE0pI$mergeProps)(additionalProps, buttonProps, {
66
+ "aria-haspopup": props["aria-haspopup"],
67
+ "aria-expanded": props["aria-expanded"],
68
+ "aria-controls": props["aria-controls"],
69
+ "aria-pressed": props["aria-pressed"],
70
+ onClick: (e)=>{
71
+ if (deprecatedOnClick) {
72
+ deprecatedOnClick(e);
73
+ console.warn("onClick is deprecated, please use onPress");
74
+ }
75
+ }
76
+ })
77
+ };
78
+ }
79
+
80
+
81
+ /*
82
+ * Copyright 2020 Adobe. All rights reserved.
83
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
84
+ * you may not use this file except in compliance with the License. You may obtain a copy
85
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
86
+ *
87
+ * Unless required by applicable law or agreed to in writing, software distributed under
88
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
89
+ * OF ANY KIND, either express or implied. See the License for the specific language
90
+ * governing permissions and limitations under the License.
91
+ */
92
+
93
+
94
+ function $55f54f7887471b58$export$51e84d46ca0bc451(props, state, ref) {
95
+ const { isSelected: isSelected } = state;
96
+ const { isPressed: isPressed , buttonProps: buttonProps } = (0, $701a24aa0da5b062$export$ea18c227d4417cc3)({
97
+ ...props,
98
+ onPress: (0, $cE0pI$chain)(state.toggle, props.onPress)
99
+ }, ref);
100
+ return {
101
+ isPressed: isPressed,
102
+ buttonProps: (0, $cE0pI$mergeProps)(buttonProps, {
103
+ "aria-pressed": isSelected
104
+ })
105
+ };
106
+ }
107
+
108
+
109
+
110
+
111
+ export {$701a24aa0da5b062$export$ea18c227d4417cc3 as useButton, $55f54f7887471b58$export$51e84d46ca0bc451 as useToggleButton};
112
+ //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -8,31 +8,51 @@ function $parcel$export(e, n, v, s) {
8
8
 
9
9
  $parcel$export(module.exports, "useButton", () => $988353faa005faf8$export$ea18c227d4417cc3);
10
10
  $parcel$export(module.exports, "useToggleButton", () => $c49208f7d2aac50b$export$51e84d46ca0bc451);
11
-
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */ /*
22
+ * Copyright 2020 Adobe. All rights reserved.
23
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
24
+ * you may not use this file except in compliance with the License. You may obtain a copy
25
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
26
+ *
27
+ * Unless required by applicable law or agreed to in writing, software distributed under
28
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
29
+ * OF ANY KIND, either express or implied. See the License for the specific language
30
+ * governing permissions and limitations under the License.
31
+ */
12
32
 
13
33
 
14
34
 
15
35
  function $988353faa005faf8$export$ea18c227d4417cc3(props, ref) {
16
- let { elementType: elementType = 'button' , isDisabled: isDisabled , onPress: onPress , onPressStart: onPressStart , onPressEnd: onPressEnd , onPressChange: onPressChange , preventFocusOnPress: // @ts-ignore - undocumented
36
+ let { elementType: elementType = "button" , isDisabled: isDisabled , onPress: onPress , onPressStart: onPressStart , onPressEnd: onPressEnd , onPressChange: onPressChange , preventFocusOnPress: // @ts-ignore - undocumented
17
37
  preventFocusOnPress , allowFocusWhenDisabled: // @ts-ignore - undocumented
18
38
  allowFocusWhenDisabled , // @ts-ignore
19
- onClick: deprecatedOnClick , href: href , target: target , rel: rel , type: type = 'button' } = props;
39
+ onClick: deprecatedOnClick , href: href , target: target , rel: rel , type: type = "button" } = props;
20
40
  let additionalProps;
21
- if (elementType === 'button') additionalProps = {
41
+ if (elementType === "button") additionalProps = {
22
42
  type: type,
23
43
  disabled: isDisabled
24
44
  };
25
45
  else additionalProps = {
26
- role: 'button',
46
+ role: "button",
27
47
  tabIndex: isDisabled ? undefined : 0,
28
- href: elementType === 'a' && isDisabled ? undefined : href,
29
- target: elementType === 'a' ? target : undefined,
30
- type: elementType === 'input' ? type : undefined,
31
- disabled: elementType === 'input' ? isDisabled : undefined,
32
- 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,
33
- rel: elementType === 'a' ? rel : undefined
48
+ href: elementType === "a" && isDisabled ? undefined : href,
49
+ target: elementType === "a" ? target : undefined,
50
+ type: elementType === "input" ? type : undefined,
51
+ disabled: elementType === "input" ? isDisabled : undefined,
52
+ "aria-disabled": !isDisabled || elementType === "input" ? undefined : isDisabled,
53
+ rel: elementType === "a" ? rel : undefined
34
54
  };
35
- let { pressProps: pressProps , isPressed: isPressed } = $eeQ2i$reactariainteractions.usePress({
55
+ let { pressProps: pressProps , isPressed: isPressed } = (0, $eeQ2i$reactariainteractions.usePress)({
36
56
  onPressStart: onPressStart,
37
57
  onPressEnd: onPressEnd,
38
58
  onPressChange: onPressChange,
@@ -41,22 +61,22 @@ function $988353faa005faf8$export$ea18c227d4417cc3(props, ref) {
41
61
  preventFocusOnPress: preventFocusOnPress,
42
62
  ref: ref
43
63
  });
44
- let { focusableProps: focusableProps } = $eeQ2i$reactariafocus.useFocusable(props, ref);
64
+ let { focusableProps: focusableProps } = (0, $eeQ2i$reactariafocus.useFocusable)(props, ref);
45
65
  if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
46
- let buttonProps = $eeQ2i$reactariautils.mergeProps(focusableProps, pressProps, $eeQ2i$reactariautils.filterDOMProps(props, {
66
+ let buttonProps = (0, $eeQ2i$reactariautils.mergeProps)(focusableProps, pressProps, (0, $eeQ2i$reactariautils.filterDOMProps)(props, {
47
67
  labelable: true
48
68
  }));
49
69
  return {
50
70
  isPressed: isPressed,
51
- buttonProps: $eeQ2i$reactariautils.mergeProps(additionalProps, buttonProps, {
52
- 'aria-haspopup': props['aria-haspopup'],
53
- 'aria-expanded': props['aria-expanded'],
54
- 'aria-controls': props['aria-controls'],
55
- 'aria-pressed': props['aria-pressed'],
71
+ buttonProps: (0, $eeQ2i$reactariautils.mergeProps)(additionalProps, buttonProps, {
72
+ "aria-haspopup": props["aria-haspopup"],
73
+ "aria-expanded": props["aria-expanded"],
74
+ "aria-controls": props["aria-controls"],
75
+ "aria-pressed": props["aria-pressed"],
56
76
  onClick: (e)=>{
57
77
  if (deprecatedOnClick) {
58
78
  deprecatedOnClick(e);
59
- console.warn('onClick is deprecated, please use onPress');
79
+ console.warn("onClick is deprecated, please use onPress");
60
80
  }
61
81
  }
62
82
  })
@@ -64,19 +84,29 @@ function $988353faa005faf8$export$ea18c227d4417cc3(props, ref) {
64
84
  }
65
85
 
66
86
 
67
-
87
+ /*
88
+ * Copyright 2020 Adobe. All rights reserved.
89
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
90
+ * you may not use this file except in compliance with the License. You may obtain a copy
91
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
92
+ *
93
+ * Unless required by applicable law or agreed to in writing, software distributed under
94
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
95
+ * OF ANY KIND, either express or implied. See the License for the specific language
96
+ * governing permissions and limitations under the License.
97
+ */
68
98
 
69
99
 
70
100
  function $c49208f7d2aac50b$export$51e84d46ca0bc451(props, state, ref) {
71
101
  const { isSelected: isSelected } = state;
72
- const { isPressed: isPressed , buttonProps: buttonProps } = $988353faa005faf8$export$ea18c227d4417cc3({
102
+ const { isPressed: isPressed , buttonProps: buttonProps } = (0, $988353faa005faf8$export$ea18c227d4417cc3)({
73
103
  ...props,
74
- onPress: $eeQ2i$reactariautils.chain(state.toggle, props.onPress)
104
+ onPress: (0, $eeQ2i$reactariautils.chain)(state.toggle, props.onPress)
75
105
  }, ref);
76
106
  return {
77
107
  isPressed: isPressed,
78
- buttonProps: $eeQ2i$reactariautils.mergeProps(buttonProps, {
79
- 'aria-pressed': isSelected
108
+ buttonProps: (0, $eeQ2i$reactariautils.mergeProps)(buttonProps, {
109
+ "aria-pressed": isSelected
80
110
  })
81
111
  };
82
112
  }
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;SCgDgB,yCAAS,CAAC,KAAmC,EAAE,GAAmB,EAAmC,CAAC;IACpH,GAAG,CAAC,CAAC,cACH,WAAW,GAAG,CAAQ,sBACtB,UAAU,YACV,OAAO,iBACP,YAAY,eACZ,UAAU,kBACV,aAAa,wBACb,EAA4B,AAA5B,0BAA4B;IAC5B,mBA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AC,cAAc,EAAE,UAAU,EAAE,oCAAc,CAAC,KAAK,EAAE,CAAC;QAAA,SAAS,EAAE,IAAI;IAAA,CAAC;IAEhG,MAAM,CAAC,CAAC;mBACN,SAAS;QACT,WAAW,EAAE,gCAAU,CAAC,eAAe,EAAE,WAAW,EAAE,CAAC;YACrD,CAAe,gBAAE,KAAK,CAAC,CAAe;YACtC,CAAe,gBAAE,KAAK,CAAC,CAAe;YACtC,CAAe,gBAAE,KAAK,CAAC,CAAe;YACtC,CAAc,eAAE,KAAK,CAAC,CAAc;YACpC,OAAO,GAAG,CAAC,GAAK,CAAC;gBACf,EAAE,EAAE,iBAAiB,EAAE,CAAC;oBACtB,iBAAiB,CAAC,CAAC;oBACnB,OAAO,CAAC,IAAI,CAAC,CAA2C;gBAC1D,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;;;;;;SChFe,yCAAe,CAAC,KAAyC,EAAE,KAAkB,EAAE,GAAmB,EAAmC,CAAC;IACpJ,KAAK,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,KAAK;IAC1B,KAAK,CAAC,CAAC,YAAA,SAAS,gBAAE,WAAW,EAAA,CAAC,GAAG,yCAAS,CAAC,CAAC;WACvC,KAAK;QACR,OAAO,EAAE,2BAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO;IAC5C,CAAC,EAAE,GAAG;IAEN,MAAM,CAAC,CAAC;mBACN,SAAS;QACT,WAAW,EAAE,gCAAU,CAAC,WAAW,EAAE,CAAC;YACpC,CAAc,eAAE,UAAU;QAC5B,CAAC;IACH,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/button/src/index.ts","packages/@react-aria/button/src/useButton.ts","packages/@react-aria/button/src/useToggleButton.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useButton} from './useButton';\nexport {useToggleButton} from './useToggleButton';\nexport type {ButtonAria} from './useButton';\nexport type {AriaButtonProps, AriaToggleButtonProps} from '@react-types/button';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n ElementType,\n HTMLAttributes,\n InputHTMLAttributes,\n RefObject\n} from 'react';\nimport {AriaButtonProps} from '@react-types/button';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {mergeProps} from '@react-aria/utils';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\n\nexport interface ButtonAria<T> {\n /** Props for the button element. */\n buttonProps: T,\n /** Whether the button is currently pressed. */\n isPressed: boolean\n}\n\n// Order with overrides is important: 'button' should be default\nexport function useButton(props: AriaButtonProps<'button'>, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useButton(props: AriaButtonProps<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonProps<'div'>, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useButton(props: AriaButtonProps<'input'>, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useButton(props: AriaButtonProps<'span'>, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<Element>): ButtonAria<DOMAttributes>;\n/**\n * Provides the behavior and accessibility implementation for a button component. Handles mouse, keyboard, and touch interactions,\n * focus behavior, and ARIA props for both native button elements and custom element types.\n * @param props - Props to be applied to the button.\n * @param ref - A ref to a DOM element for the button.\n */\nexport function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {\n let {\n elementType = 'button',\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressChange,\n // @ts-ignore - undocumented\n preventFocusOnPress,\n // @ts-ignore - undocumented\n allowFocusWhenDisabled,\n // @ts-ignore\n onClick: deprecatedOnClick,\n href,\n target,\n rel,\n type = 'button'\n } = props;\n let additionalProps;\n if (elementType === 'button') {\n additionalProps = {\n type,\n disabled: isDisabled\n };\n } else {\n additionalProps = {\n role: 'button',\n tabIndex: isDisabled ? undefined : 0,\n href: elementType === 'a' && isDisabled ? undefined : href,\n target: elementType === 'a' ? target : undefined,\n type: elementType === 'input' ? type : undefined,\n disabled: elementType === 'input' ? isDisabled : undefined,\n 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,\n rel: elementType === 'a' ? rel : undefined\n };\n }\n\n let {pressProps, isPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n isDisabled,\n preventFocusOnPress,\n ref\n });\n\n let {focusableProps} = useFocusable(props, ref);\n if (allowFocusWhenDisabled) {\n focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;\n }\n let buttonProps = mergeProps(focusableProps, pressProps, filterDOMProps(props, {labelable: true}));\n\n return {\n isPressed, // Used to indicate press state for visual\n buttonProps: mergeProps(additionalProps, buttonProps, {\n 'aria-haspopup': props['aria-haspopup'],\n 'aria-expanded': props['aria-expanded'],\n 'aria-controls': props['aria-controls'],\n 'aria-pressed': props['aria-pressed'],\n onClick: (e) => {\n if (deprecatedOnClick) {\n deprecatedOnClick(e);\n console.warn('onClick is deprecated, please use onPress');\n }\n }\n })\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n ElementType,\n HTMLAttributes,\n InputHTMLAttributes,\n RefObject\n} from 'react';\nimport {AriaToggleButtonProps} from '@react-types/button';\nimport {ButtonAria, useButton} from './useButton';\nimport {chain} from '@react-aria/utils';\nimport {DOMAttributes} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport {ToggleState} from '@react-stately/toggle';\n\nexport function useToggleButton(props: AriaToggleButtonProps<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<ElementType>, state: ToggleState, ref: RefObject<Element>): ButtonAria<DOMAttributes>;\n/**\n * Provides the behavior and accessibility implementation for a toggle button component.\n * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.\n */\nexport function useToggleButton(props: AriaToggleButtonProps<ElementType>, state: ToggleState, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {\n const {isSelected} = state;\n const {isPressed, buttonProps} = useButton({\n ...props,\n onPress: chain(state.toggle, props.onPress)\n }, ref);\n\n return {\n isPressed,\n buttonProps: mergeProps(buttonProps, {\n 'aria-pressed': isSelected\n })\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;;;AAoCO,SAAS,0CAAU,KAAmC,EAAE,GAAmB,EAAmC;IACnH,IAAI,eACF,cAAc,uBACd,WAAU,WACV,QAAO,gBACP,aAAY,cACZ,WAAU,iBACV,cAAa,uBACb,4BAA4B;IAC5B,oBAAmB,0BACnB,4BAA4B;IAC5B,uBAAsB,EACtB,aAAa;IACb,SAAS,kBAAiB,QAC1B,KAAI,UACJ,OAAM,OACN,IAAG,QACH,OAAO,WACR,GAAG;IACJ,IAAI;IACJ,IAAI,gBAAgB,UAClB,kBAAkB;cAChB;QACA,UAAU;IACZ;SAEA,kBAAkB;QAChB,MAAM;QACN,UAAU,aAAa,YAAY,CAAC;QACpC,MAAM,gBAAgB,OAAO,aAAa,YAAY,IAAI;QAC1D,QAAQ,gBAAgB,MAAM,SAAS,SAAS;QAChD,MAAM,gBAAgB,UAAU,OAAO,SAAS;QAChD,UAAU,gBAAgB,UAAU,aAAa,SAAS;QAC1D,iBAAiB,CAAC,cAAc,gBAAgB,UAAU,YAAY,UAAU;QAChF,KAAK,gBAAgB,MAAM,MAAM,SAAS;IAC5C;IAGF,IAAI,cAAC,WAAU,aAAE,UAAS,EAAC,GAAG,CAAA,GAAA,qCAAQ,AAAD,EAAE;sBACrC;oBACA;uBACA;iBACA;oBACA;6BACA;aACA;IACF;IAEA,IAAI,kBAAC,eAAc,EAAC,GAAG,CAAA,GAAA,kCAAW,EAAE,OAAO;IAC3C,IAAI,wBACF,eAAe,QAAQ,GAAG,aAAa,KAAK,eAAe,QAAQ;IAErE,IAAI,cAAc,CAAA,GAAA,gCAAS,EAAE,gBAAgB,YAAY,CAAA,GAAA,oCAAc,AAAD,EAAE,OAAO;QAAC,WAAW,IAAI;IAAA;IAE/F,OAAO;mBACL;QACA,aAAa,CAAA,GAAA,gCAAU,AAAD,EAAE,iBAAiB,aAAa;YACpD,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,gBAAgB,KAAK,CAAC,eAAe;YACrC,SAAS,CAAC,IAAM;gBACd,IAAI,mBAAmB;oBACrB,kBAAkB;oBAClB,QAAQ,IAAI,CAAC;gBACf,CAAC;YACH;QACF;IACF;AACF;;CD3GC,GACD;AEXA;;;;;;;;;;CAUC,GAED;;;AA0BO,SAAS,0CAAgB,KAAyC,EAAE,KAAkB,EAAE,GAAmB,EAAmC;IACnJ,MAAM,cAAC,WAAU,EAAC,GAAG;IACrB,MAAM,aAAC,UAAS,eAAE,YAAW,EAAC,GAAG,CAAA,GAAA,yCAAS,AAAD,EAAE;QACzC,GAAG,KAAK;QACR,SAAS,CAAA,GAAA,2BAAI,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO;IAC5C,GAAG;IAEH,OAAO;mBACL;QACA,aAAa,CAAA,GAAA,gCAAU,AAAD,EAAE,aAAa;YACnC,gBAAgB;QAClB;IACF;AACF;","sources":["packages/@react-aria/button/src/index.ts","packages/@react-aria/button/src/useButton.ts","packages/@react-aria/button/src/useToggleButton.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useButton} from './useButton';\nexport {useToggleButton} from './useToggleButton';\nexport type {ButtonAria} from './useButton';\nexport type {AriaButtonProps, AriaToggleButtonProps} from '@react-types/button';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n ElementType,\n HTMLAttributes,\n InputHTMLAttributes,\n RefObject\n} from 'react';\nimport {AriaButtonProps} from '@react-types/button';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {mergeProps} from '@react-aria/utils';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\n\nexport interface ButtonAria<T> {\n /** Props for the button element. */\n buttonProps: T,\n /** Whether the button is currently pressed. */\n isPressed: boolean\n}\n\n// Order with overrides is important: 'button' should be default\nexport function useButton(props: AriaButtonProps<'button'>, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useButton(props: AriaButtonProps<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonProps<'div'>, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useButton(props: AriaButtonProps<'input'>, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useButton(props: AriaButtonProps<'span'>, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<Element>): ButtonAria<DOMAttributes>;\n/**\n * Provides the behavior and accessibility implementation for a button component. Handles mouse, keyboard, and touch interactions,\n * focus behavior, and ARIA props for both native button elements and custom element types.\n * @param props - Props to be applied to the button.\n * @param ref - A ref to a DOM element for the button.\n */\nexport function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {\n let {\n elementType = 'button',\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressChange,\n // @ts-ignore - undocumented\n preventFocusOnPress,\n // @ts-ignore - undocumented\n allowFocusWhenDisabled,\n // @ts-ignore\n onClick: deprecatedOnClick,\n href,\n target,\n rel,\n type = 'button'\n } = props;\n let additionalProps;\n if (elementType === 'button') {\n additionalProps = {\n type,\n disabled: isDisabled\n };\n } else {\n additionalProps = {\n role: 'button',\n tabIndex: isDisabled ? undefined : 0,\n href: elementType === 'a' && isDisabled ? undefined : href,\n target: elementType === 'a' ? target : undefined,\n type: elementType === 'input' ? type : undefined,\n disabled: elementType === 'input' ? isDisabled : undefined,\n 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,\n rel: elementType === 'a' ? rel : undefined\n };\n }\n\n let {pressProps, isPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n isDisabled,\n preventFocusOnPress,\n ref\n });\n\n let {focusableProps} = useFocusable(props, ref);\n if (allowFocusWhenDisabled) {\n focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;\n }\n let buttonProps = mergeProps(focusableProps, pressProps, filterDOMProps(props, {labelable: true}));\n\n return {\n isPressed, // Used to indicate press state for visual\n buttonProps: mergeProps(additionalProps, buttonProps, {\n 'aria-haspopup': props['aria-haspopup'],\n 'aria-expanded': props['aria-expanded'],\n 'aria-controls': props['aria-controls'],\n 'aria-pressed': props['aria-pressed'],\n onClick: (e) => {\n if (deprecatedOnClick) {\n deprecatedOnClick(e);\n console.warn('onClick is deprecated, please use onPress');\n }\n }\n })\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n ElementType,\n HTMLAttributes,\n InputHTMLAttributes,\n RefObject\n} from 'react';\nimport {AriaToggleButtonProps} from '@react-types/button';\nimport {ButtonAria, useButton} from './useButton';\nimport {chain} from '@react-aria/utils';\nimport {DOMAttributes} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport {ToggleState} from '@react-stately/toggle';\n\n// Order with overrides is important: 'button' should be default\nexport function useToggleButton(props: AriaToggleButtonProps<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<ElementType>, state: ToggleState, ref: RefObject<Element>): ButtonAria<DOMAttributes>;\n/**\n * Provides the behavior and accessibility implementation for a toggle button component.\n * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.\n */\nexport function useToggleButton(props: AriaToggleButtonProps<ElementType>, state: ToggleState, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {\n const {isSelected} = state;\n const {isPressed, buttonProps} = useButton({\n ...props,\n onPress: chain(state.toggle, props.onPress)\n }, ref);\n\n return {\n isPressed,\n buttonProps: mergeProps(buttonProps, {\n 'aria-pressed': isSelected\n })\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -2,31 +2,51 @@ import {mergeProps as $cE0pI$mergeProps, filterDOMProps as $cE0pI$filterDOMProps
2
2
  import {useFocusable as $cE0pI$useFocusable} from "@react-aria/focus";
3
3
  import {usePress as $cE0pI$usePress} from "@react-aria/interactions";
4
4
 
5
-
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */ /*
16
+ * Copyright 2020 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */
6
26
 
7
27
 
8
28
 
9
29
  function $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
10
- let { elementType: elementType = 'button' , isDisabled: isDisabled , onPress: onPress , onPressStart: onPressStart , onPressEnd: onPressEnd , onPressChange: onPressChange , preventFocusOnPress: // @ts-ignore - undocumented
30
+ let { elementType: elementType = "button" , isDisabled: isDisabled , onPress: onPress , onPressStart: onPressStart , onPressEnd: onPressEnd , onPressChange: onPressChange , preventFocusOnPress: // @ts-ignore - undocumented
11
31
  preventFocusOnPress , allowFocusWhenDisabled: // @ts-ignore - undocumented
12
32
  allowFocusWhenDisabled , // @ts-ignore
13
- onClick: deprecatedOnClick , href: href , target: target , rel: rel , type: type = 'button' } = props;
33
+ onClick: deprecatedOnClick , href: href , target: target , rel: rel , type: type = "button" } = props;
14
34
  let additionalProps;
15
- if (elementType === 'button') additionalProps = {
35
+ if (elementType === "button") additionalProps = {
16
36
  type: type,
17
37
  disabled: isDisabled
18
38
  };
19
39
  else additionalProps = {
20
- role: 'button',
40
+ role: "button",
21
41
  tabIndex: isDisabled ? undefined : 0,
22
- href: elementType === 'a' && isDisabled ? undefined : href,
23
- target: elementType === 'a' ? target : undefined,
24
- type: elementType === 'input' ? type : undefined,
25
- disabled: elementType === 'input' ? isDisabled : undefined,
26
- 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,
27
- rel: elementType === 'a' ? rel : undefined
42
+ href: elementType === "a" && isDisabled ? undefined : href,
43
+ target: elementType === "a" ? target : undefined,
44
+ type: elementType === "input" ? type : undefined,
45
+ disabled: elementType === "input" ? isDisabled : undefined,
46
+ "aria-disabled": !isDisabled || elementType === "input" ? undefined : isDisabled,
47
+ rel: elementType === "a" ? rel : undefined
28
48
  };
29
- let { pressProps: pressProps , isPressed: isPressed } = $cE0pI$usePress({
49
+ let { pressProps: pressProps , isPressed: isPressed } = (0, $cE0pI$usePress)({
30
50
  onPressStart: onPressStart,
31
51
  onPressEnd: onPressEnd,
32
52
  onPressChange: onPressChange,
@@ -35,22 +55,22 @@ function $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
35
55
  preventFocusOnPress: preventFocusOnPress,
36
56
  ref: ref
37
57
  });
38
- let { focusableProps: focusableProps } = $cE0pI$useFocusable(props, ref);
58
+ let { focusableProps: focusableProps } = (0, $cE0pI$useFocusable)(props, ref);
39
59
  if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
40
- let buttonProps = $cE0pI$mergeProps(focusableProps, pressProps, $cE0pI$filterDOMProps(props, {
60
+ let buttonProps = (0, $cE0pI$mergeProps)(focusableProps, pressProps, (0, $cE0pI$filterDOMProps)(props, {
41
61
  labelable: true
42
62
  }));
43
63
  return {
44
64
  isPressed: isPressed,
45
- buttonProps: $cE0pI$mergeProps(additionalProps, buttonProps, {
46
- 'aria-haspopup': props['aria-haspopup'],
47
- 'aria-expanded': props['aria-expanded'],
48
- 'aria-controls': props['aria-controls'],
49
- 'aria-pressed': props['aria-pressed'],
65
+ buttonProps: (0, $cE0pI$mergeProps)(additionalProps, buttonProps, {
66
+ "aria-haspopup": props["aria-haspopup"],
67
+ "aria-expanded": props["aria-expanded"],
68
+ "aria-controls": props["aria-controls"],
69
+ "aria-pressed": props["aria-pressed"],
50
70
  onClick: (e)=>{
51
71
  if (deprecatedOnClick) {
52
72
  deprecatedOnClick(e);
53
- console.warn('onClick is deprecated, please use onPress');
73
+ console.warn("onClick is deprecated, please use onPress");
54
74
  }
55
75
  }
56
76
  })
@@ -58,19 +78,29 @@ function $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
58
78
  }
59
79
 
60
80
 
61
-
81
+ /*
82
+ * Copyright 2020 Adobe. All rights reserved.
83
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
84
+ * you may not use this file except in compliance with the License. You may obtain a copy
85
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
86
+ *
87
+ * Unless required by applicable law or agreed to in writing, software distributed under
88
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
89
+ * OF ANY KIND, either express or implied. See the License for the specific language
90
+ * governing permissions and limitations under the License.
91
+ */
62
92
 
63
93
 
64
94
  function $55f54f7887471b58$export$51e84d46ca0bc451(props, state, ref) {
65
95
  const { isSelected: isSelected } = state;
66
- const { isPressed: isPressed , buttonProps: buttonProps } = $701a24aa0da5b062$export$ea18c227d4417cc3({
96
+ const { isPressed: isPressed , buttonProps: buttonProps } = (0, $701a24aa0da5b062$export$ea18c227d4417cc3)({
67
97
  ...props,
68
- onPress: $cE0pI$chain(state.toggle, props.onPress)
98
+ onPress: (0, $cE0pI$chain)(state.toggle, props.onPress)
69
99
  }, ref);
70
100
  return {
71
101
  isPressed: isPressed,
72
- buttonProps: $cE0pI$mergeProps(buttonProps, {
73
- 'aria-pressed': isSelected
102
+ buttonProps: (0, $cE0pI$mergeProps)(buttonProps, {
103
+ "aria-pressed": isSelected
74
104
  })
75
105
  };
76
106
  }
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;SCgDgB,yCAAS,CAAC,KAAmC,EAAE,GAAmB,EAAmC,CAAC;IACpH,GAAG,CAAC,CAAC,cACH,WAAW,GAAG,CAAQ,sBACtB,UAAU,YACV,OAAO,iBACP,YAAY,eACZ,UAAU,kBACV,aAAa,wBACb,EAA4B,AAA5B,0BAA4B;IAC5B,mBAAmB,2BACnB,EAA4B,AAA5B,0BAA4B;IAC5B,sBAAsB,GACtB,EAAa,AAAb,WAAa;IACb,OAAO,EAAE,iBAAiB,SAC1B,IAAI,WACJ,MAAM,QACN,GAAG,SACH,IAAI,GAAG,CAAQ,SACjB,CAAC,GAAG,KAAK;IACT,GAAG,CAAC,eAAe;IACnB,EAAE,EAAE,WAAW,KAAK,CAAQ,SAC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KAAK,CAAC,CAAe;YACtC,CAAe,gBAAE,KAAK,CAAC,CAAe;YACtC,CAAc,eAAE,KAAK,CAAC,CAAc;YACpC,OAAO,GAAG,CAAC,GAAK,CAAC;gBACf,EAAE,EAAE,iBAAiB,EAAE,CAAC;oBACtB,iBAAiB,CAAC,CAAC;oBACnB,OAAO,CAAC,IAAI,CAAC,CAA2C;gBAC1D,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;;;;;;SChFe,yCAAe,CAAC,KAAyC,EAAE,KAAkB,EAAE,GAAmB,EAAmC,CAAC;IACpJ,KAAK,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,KAAK;IAC1B,KAAK,CAAC,CAAC,YAAA,SAAS,gBAAE,WAAW,EAAA,CAAC,GAAG,yCAAS,CAAC,CAAC;WACvC,KAAK;QACR,OAAO,EAAE,YAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO;IAC5C,CAAC,EAAE,GAAG;IAEN,MAAM,CAAC,CAAC;mBACN,SAAS;QACT,WAAW,EAAE,iBAAU,CAAC,WAAW,EAAE,CAAC;YACpC,CAAc,eAAE,UAAU;QAC5B,CAAC;IACH,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/button/src/index.ts","packages/@react-aria/button/src/useButton.ts","packages/@react-aria/button/src/useToggleButton.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useButton} from './useButton';\nexport {useToggleButton} from './useToggleButton';\nexport type {ButtonAria} from './useButton';\nexport type {AriaButtonProps, AriaToggleButtonProps} from '@react-types/button';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n ElementType,\n HTMLAttributes,\n InputHTMLAttributes,\n RefObject\n} from 'react';\nimport {AriaButtonProps} from '@react-types/button';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {mergeProps} from '@react-aria/utils';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\n\nexport interface ButtonAria<T> {\n /** Props for the button element. */\n buttonProps: T,\n /** Whether the button is currently pressed. */\n isPressed: boolean\n}\n\n// Order with overrides is important: 'button' should be default\nexport function useButton(props: AriaButtonProps<'button'>, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useButton(props: AriaButtonProps<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonProps<'div'>, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useButton(props: AriaButtonProps<'input'>, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useButton(props: AriaButtonProps<'span'>, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<Element>): ButtonAria<DOMAttributes>;\n/**\n * Provides the behavior and accessibility implementation for a button component. Handles mouse, keyboard, and touch interactions,\n * focus behavior, and ARIA props for both native button elements and custom element types.\n * @param props - Props to be applied to the button.\n * @param ref - A ref to a DOM element for the button.\n */\nexport function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {\n let {\n elementType = 'button',\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressChange,\n // @ts-ignore - undocumented\n preventFocusOnPress,\n // @ts-ignore - undocumented\n allowFocusWhenDisabled,\n // @ts-ignore\n onClick: deprecatedOnClick,\n href,\n target,\n rel,\n type = 'button'\n } = props;\n let additionalProps;\n if (elementType === 'button') {\n additionalProps = {\n type,\n disabled: isDisabled\n };\n } else {\n additionalProps = {\n role: 'button',\n tabIndex: isDisabled ? undefined : 0,\n href: elementType === 'a' && isDisabled ? undefined : href,\n target: elementType === 'a' ? target : undefined,\n type: elementType === 'input' ? type : undefined,\n disabled: elementType === 'input' ? isDisabled : undefined,\n 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,\n rel: elementType === 'a' ? rel : undefined\n };\n }\n\n let {pressProps, isPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n isDisabled,\n preventFocusOnPress,\n ref\n });\n\n let {focusableProps} = useFocusable(props, ref);\n if (allowFocusWhenDisabled) {\n focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;\n }\n let buttonProps = mergeProps(focusableProps, pressProps, filterDOMProps(props, {labelable: true}));\n\n return {\n isPressed, // Used to indicate press state for visual\n buttonProps: mergeProps(additionalProps, buttonProps, {\n 'aria-haspopup': props['aria-haspopup'],\n 'aria-expanded': props['aria-expanded'],\n 'aria-controls': props['aria-controls'],\n 'aria-pressed': props['aria-pressed'],\n onClick: (e) => {\n if (deprecatedOnClick) {\n deprecatedOnClick(e);\n console.warn('onClick is deprecated, please use onPress');\n }\n }\n })\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n ElementType,\n HTMLAttributes,\n InputHTMLAttributes,\n RefObject\n} from 'react';\nimport {AriaToggleButtonProps} from '@react-types/button';\nimport {ButtonAria, useButton} from './useButton';\nimport {chain} from '@react-aria/utils';\nimport {DOMAttributes} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport {ToggleState} from '@react-stately/toggle';\n\nexport function useToggleButton(props: AriaToggleButtonProps<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<ElementType>, state: ToggleState, ref: RefObject<Element>): ButtonAria<DOMAttributes>;\n/**\n * Provides the behavior and accessibility implementation for a toggle button component.\n * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.\n */\nexport function useToggleButton(props: AriaToggleButtonProps<ElementType>, state: ToggleState, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {\n const {isSelected} = state;\n const {isPressed, buttonProps} = useButton({\n ...props,\n onPress: chain(state.toggle, props.onPress)\n }, ref);\n\n return {\n isPressed,\n buttonProps: mergeProps(buttonProps, {\n 'aria-pressed': isSelected\n })\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;;;AAoCO,SAAS,0CAAU,KAAmC,EAAE,GAAmB,EAAmC;IACnH,IAAI,eACF,cAAc,uBACd,WAAU,WACV,QAAO,gBACP,aAAY,cACZ,WAAU,iBACV,cAAa,uBACb,4BAA4B;IAC5B,oBAAmB,0BACnB,4BAA4B;IAC5B,uBAAsB,EACtB,aAAa;IACb,SAAS,kBAAiB,QAC1B,KAAI,UACJ,OAAM,OACN,IAAG,QACH,OAAO,WACR,GAAG;IACJ,IAAI;IACJ,IAAI,gBAAgB,UAClB,kBAAkB;cAChB;QACA,UAAU;IACZ;SAEA,kBAAkB;QAChB,MAAM;QACN,UAAU,aAAa,YAAY,CAAC;QACpC,MAAM,gBAAgB,OAAO,aAAa,YAAY,IAAI;QAC1D,QAAQ,gBAAgB,MAAM,SAAS,SAAS;QAChD,MAAM,gBAAgB,UAAU,OAAO,SAAS;QAChD,UAAU,gBAAgB,UAAU,aAAa,SAAS;QAC1D,iBAAiB,CAAC,cAAc,gBAAgB,UAAU,YAAY,UAAU;QAChF,KAAK,gBAAgB,MAAM,MAAM,SAAS;IAC5C;IAGF,IAAI,cAAC,WAAU,aAAE,UAAS,EAAC,GAAG,CAAA,GAAA,eAAQ,AAAD,EAAE;sBACrC;oBACA;uBACA;iBACA;oBACA;6BACA;aACA;IACF;IAEA,IAAI,kBAAC,eAAc,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE,OAAO;IAC3C,IAAI,wBACF,eAAe,QAAQ,GAAG,aAAa,KAAK,eAAe,QAAQ;IAErE,IAAI,cAAc,CAAA,GAAA,iBAAS,EAAE,gBAAgB,YAAY,CAAA,GAAA,qBAAc,AAAD,EAAE,OAAO;QAAC,WAAW,IAAI;IAAA;IAE/F,OAAO;mBACL;QACA,aAAa,CAAA,GAAA,iBAAU,AAAD,EAAE,iBAAiB,aAAa;YACpD,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,gBAAgB,KAAK,CAAC,eAAe;YACrC,SAAS,CAAC,IAAM;gBACd,IAAI,mBAAmB;oBACrB,kBAAkB;oBAClB,QAAQ,IAAI,CAAC;gBACf,CAAC;YACH;QACF;IACF;AACF;;CD3GC,GACD;AEXA;;;;;;;;;;CAUC,GAED;;;AA0BO,SAAS,0CAAgB,KAAyC,EAAE,KAAkB,EAAE,GAAmB,EAAmC;IACnJ,MAAM,cAAC,WAAU,EAAC,GAAG;IACrB,MAAM,aAAC,UAAS,eAAE,YAAW,EAAC,GAAG,CAAA,GAAA,yCAAS,AAAD,EAAE;QACzC,GAAG,KAAK;QACR,SAAS,CAAA,GAAA,YAAI,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO;IAC5C,GAAG;IAEH,OAAO;mBACL;QACA,aAAa,CAAA,GAAA,iBAAU,AAAD,EAAE,aAAa;YACnC,gBAAgB;QAClB;IACF;AACF;","sources":["packages/@react-aria/button/src/index.ts","packages/@react-aria/button/src/useButton.ts","packages/@react-aria/button/src/useToggleButton.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useButton} from './useButton';\nexport {useToggleButton} from './useToggleButton';\nexport type {ButtonAria} from './useButton';\nexport type {AriaButtonProps, AriaToggleButtonProps} from '@react-types/button';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n ElementType,\n HTMLAttributes,\n InputHTMLAttributes,\n RefObject\n} from 'react';\nimport {AriaButtonProps} from '@react-types/button';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {mergeProps} from '@react-aria/utils';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\n\nexport interface ButtonAria<T> {\n /** Props for the button element. */\n buttonProps: T,\n /** Whether the button is currently pressed. */\n isPressed: boolean\n}\n\n// Order with overrides is important: 'button' should be default\nexport function useButton(props: AriaButtonProps<'button'>, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useButton(props: AriaButtonProps<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonProps<'div'>, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useButton(props: AriaButtonProps<'input'>, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useButton(props: AriaButtonProps<'span'>, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<Element>): ButtonAria<DOMAttributes>;\n/**\n * Provides the behavior and accessibility implementation for a button component. Handles mouse, keyboard, and touch interactions,\n * focus behavior, and ARIA props for both native button elements and custom element types.\n * @param props - Props to be applied to the button.\n * @param ref - A ref to a DOM element for the button.\n */\nexport function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {\n let {\n elementType = 'button',\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressChange,\n // @ts-ignore - undocumented\n preventFocusOnPress,\n // @ts-ignore - undocumented\n allowFocusWhenDisabled,\n // @ts-ignore\n onClick: deprecatedOnClick,\n href,\n target,\n rel,\n type = 'button'\n } = props;\n let additionalProps;\n if (elementType === 'button') {\n additionalProps = {\n type,\n disabled: isDisabled\n };\n } else {\n additionalProps = {\n role: 'button',\n tabIndex: isDisabled ? undefined : 0,\n href: elementType === 'a' && isDisabled ? undefined : href,\n target: elementType === 'a' ? target : undefined,\n type: elementType === 'input' ? type : undefined,\n disabled: elementType === 'input' ? isDisabled : undefined,\n 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,\n rel: elementType === 'a' ? rel : undefined\n };\n }\n\n let {pressProps, isPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n isDisabled,\n preventFocusOnPress,\n ref\n });\n\n let {focusableProps} = useFocusable(props, ref);\n if (allowFocusWhenDisabled) {\n focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;\n }\n let buttonProps = mergeProps(focusableProps, pressProps, filterDOMProps(props, {labelable: true}));\n\n return {\n isPressed, // Used to indicate press state for visual\n buttonProps: mergeProps(additionalProps, buttonProps, {\n 'aria-haspopup': props['aria-haspopup'],\n 'aria-expanded': props['aria-expanded'],\n 'aria-controls': props['aria-controls'],\n 'aria-pressed': props['aria-pressed'],\n onClick: (e) => {\n if (deprecatedOnClick) {\n deprecatedOnClick(e);\n console.warn('onClick is deprecated, please use onPress');\n }\n }\n })\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n ElementType,\n HTMLAttributes,\n InputHTMLAttributes,\n RefObject\n} from 'react';\nimport {AriaToggleButtonProps} from '@react-types/button';\nimport {ButtonAria, useButton} from './useButton';\nimport {chain} from '@react-aria/utils';\nimport {DOMAttributes} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport {ToggleState} from '@react-stately/toggle';\n\n// Order with overrides is important: 'button' should be default\nexport function useToggleButton(props: AriaToggleButtonProps<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useToggleButton(props: AriaToggleButtonProps<ElementType>, state: ToggleState, ref: RefObject<Element>): ButtonAria<DOMAttributes>;\n/**\n * Provides the behavior and accessibility implementation for a toggle button component.\n * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.\n */\nexport function useToggleButton(props: AriaToggleButtonProps<ElementType>, state: ToggleState, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {\n const {isSelected} = state;\n const {isPressed, buttonProps} = useButton({\n ...props,\n onPress: chain(state.toggle, props.onPress)\n }, ref);\n\n return {\n isPressed,\n buttonProps: mergeProps(buttonProps, {\n 'aria-pressed': isSelected\n })\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -14,8 +14,8 @@ export function useButton(props: AriaButtonProps<'div'>, ref: RefObject<HTMLDivE
14
14
  export function useButton(props: AriaButtonProps<'input'>, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;
15
15
  export function useButton(props: AriaButtonProps<'span'>, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;
16
16
  export function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<Element>): ButtonAria<DOMAttributes>;
17
- export function useToggleButton(props: AriaToggleButtonProps<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
18
17
  export function useToggleButton(props: AriaToggleButtonProps<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;
18
+ export function useToggleButton(props: AriaToggleButtonProps<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
19
19
  export function useToggleButton(props: AriaToggleButtonProps<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;
20
20
  export function useToggleButton(props: AriaToggleButtonProps<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;
21
21
  export function useToggleButton(props: AriaToggleButtonProps<'span'>, state: ToggleState, ref: RefObject<HTMLSpanEl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,qBAAqB,iBAAiB,CAAC,CAAC,CAAC;AACpL,gCAAgC,KAAK,EAAE,sBAAsB,KAAK,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,cAAc,CAAC,GAAG,WAAW,eAAe,cAAc,CAAC,CAAC,CAAC;AACrK,gCAAgC,KAAK,EAAE,sBAAsB,OAAO,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,WAAW,oBAAoB,gBAAgB,CAAC,CAAC,CAAC;AAChL,gCAAgC,KAAK,EAAE,sBAAsB,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,eAAe,CAAC,GAAG,WAAW,eAAe,eAAe,CAAC,CAAC,CAAC;AACxK,gCAAgC,KAAK,EAAE,sBAAsB,WAAW,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,OAAO,CAAC,GAAG,WAAW,aAAa,CAAC,CAAC;AClBnJ,YAAY,EAAC,eAAe,EAAE,qBAAqB,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/button/src/packages/@react-aria/button/src/useButton.ts","packages/@react-aria/button/src/packages/@react-aria/button/src/useToggleButton.ts","packages/@react-aria/button/src/packages/@react-aria/button/src/index.ts","packages/@react-aria/button/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useButton} from './useButton';\nexport {useToggleButton} from './useToggleButton';\nexport type {ButtonAria} from './useButton';\nexport type {AriaButtonProps, Ari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WAAW,qBAAqB,iBAAiB,CAAC,CAAC,CAAC;AAC/K,gCAAgC,KAAK,EAAE,sBAAsB,KAAK,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,cAAc,CAAC,GAAG,WAAW,eAAe,cAAc,CAAC,CAAC,CAAC;AACrK,gCAAgC,KAAK,EAAE,sBAAsB,OAAO,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,WAAW,oBAAoB,gBAAgB,CAAC,CAAC,CAAC;AAChL,gCAAgC,KAAK,EAAE,sBAAsB,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,eAAe,CAAC,GAAG,WAAW,eAAe,eAAe,CAAC,CAAC,CAAC;AACxK,gCAAgC,KAAK,EAAE,sBAAsB,WAAW,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,OAAO,CAAC,GAAG,WAAW,aAAa,CAAC,CAAC;ACnBnJ,YAAY,EAAC,eAAe,EAAE,qBAAqB,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/button/src/packages/@react-aria/button/src/useButton.ts","packages/@react-aria/button/src/packages/@react-aria/button/src/useToggleButton.ts","packages/@react-aria/button/src/packages/@react-aria/button/src/index.ts","packages/@react-aria/button/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useButton} from './useButton';\nexport {useToggleButton} from './useToggleButton';\nexport type {ButtonAria} from './useButton';\nexport type {AriaButtonProps, AriaToggleButtonProps} from '@react-types/button';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/button",
3
- "version": "3.6.3",
3
+ "version": "3.7.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -17,13 +22,13 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@babel/runtime": "^7.6.2",
21
- "@react-aria/focus": "^3.10.0",
22
- "@react-aria/interactions": "^3.13.0",
23
- "@react-aria/utils": "^3.14.1",
24
- "@react-stately/toggle": "^3.4.3",
25
- "@react-types/button": "^3.7.0",
26
- "@react-types/shared": "^3.16.0"
25
+ "@react-aria/focus": "^3.11.0",
26
+ "@react-aria/interactions": "^3.14.0",
27
+ "@react-aria/utils": "^3.15.0",
28
+ "@react-stately/toggle": "^3.5.0",
29
+ "@react-types/button": "^3.7.1",
30
+ "@react-types/shared": "^3.17.0",
31
+ "@swc/helpers": "^0.4.14"
27
32
  },
28
33
  "peerDependencies": {
29
34
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -31,5 +36,5 @@
31
36
  "publishConfig": {
32
37
  "access": "public"
33
38
  },
34
- "gitHead": "2954307ddbefe149241685440c81f80ece6b2c83"
39
+ "gitHead": "a0efee84aa178cb1a202951dfd6d8de02b292307"
35
40
  }
@@ -25,8 +25,9 @@ import {DOMAttributes} from '@react-types/shared';
25
25
  import {mergeProps} from '@react-aria/utils';
26
26
  import {ToggleState} from '@react-stately/toggle';
27
27
 
28
- export function useToggleButton(props: AriaToggleButtonProps<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
28
+ // Order with overrides is important: 'button' should be default
29
29
  export function useToggleButton(props: AriaToggleButtonProps<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;
30
+ export function useToggleButton(props: AriaToggleButtonProps<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
30
31
  export function useToggleButton(props: AriaToggleButtonProps<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;
31
32
  export function useToggleButton(props: AriaToggleButtonProps<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;
32
33
  export function useToggleButton(props: AriaToggleButtonProps<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;