@react-aria/button 3.3.1 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,125 +1,108 @@
1
- var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
1
+ var $7EMBp$reactariautils = require("@react-aria/utils");
2
+ var $7EMBp$reactariafocus = require("@react-aria/focus");
3
+ var $7EMBp$reactariainteractions = require("@react-aria/interactions");
2
4
 
3
- var {
4
- usePress
5
- } = require("@react-aria/interactions");
5
+ function $parcel$exportWildcard(dest, source) {
6
+ Object.keys(source).forEach(function(key) {
7
+ if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
8
+ return;
9
+ }
6
10
 
7
- var {
8
- useFocusable
9
- } = require("@react-aria/focus");
10
-
11
- var {
12
- filterDOMProps,
13
- mergeProps,
14
- chain
15
- } = require("@react-aria/utils");
11
+ Object.defineProperty(dest, key, {
12
+ enumerable: true,
13
+ get: function get() {
14
+ return source[key];
15
+ }
16
+ });
17
+ });
16
18
 
17
- function $parcel$interopDefault(a) {
18
- return a && a.__esModule ? a.default : a;
19
+ return dest;
19
20
  }
21
+ function $parcel$export(e, n, v, s) {
22
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
23
+ }
24
+ var $cf6d5e8ad7b0b063$exports = {};
25
+
26
+ $parcel$export($cf6d5e8ad7b0b063$exports, "useButton", () => $cf6d5e8ad7b0b063$export$ea18c227d4417cc3);
27
+
20
28
 
21
- /**
22
- * Provides the behavior and accessibility implementation for a button component. Handles mouse, keyboard, and touch interactions,
23
- * focus behavior, and ARIA props for both native button elements and custom element types.
24
- * @param props - Props to be applied to the button.
25
- * @param ref - A ref to a DOM element for the button.
26
- */
27
- function useButton(props, ref) {
28
- /* eslint-enable no-redeclare */
29
- let {
30
- elementType = 'button',
31
- isDisabled,
32
- onPress,
33
- onPressStart,
34
- onPressEnd,
35
- onPressChange,
36
- // @ts-ignore - undocumented
37
- preventFocusOnPress,
38
- // @ts-ignore
39
- onClick: deprecatedOnClick,
40
- href,
41
- target,
42
- rel,
43
- type = 'button'
44
- } = props;
45
- let additionalProps;
46
-
47
- if (elementType !== 'button') {
48
- additionalProps = {
49
- role: 'button',
50
- tabIndex: isDisabled ? undefined : 0,
51
- href: elementType === 'a' && isDisabled ? undefined : href,
52
- target: elementType === 'a' ? target : undefined,
53
- type: elementType === 'input' ? type : undefined,
54
- disabled: elementType === 'input' ? isDisabled : undefined,
55
- 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,
56
- rel: elementType === 'a' ? rel : undefined
29
+
30
+
31
+ function $cf6d5e8ad7b0b063$export$ea18c227d4417cc3(props, ref) {
32
+ let { elementType: elementType = 'button' , isDisabled: isDisabled , onPress: onPress , onPressStart: onPressStart , onPressEnd: onPressEnd , onPressChange: onPressChange , preventFocusOnPress: // @ts-ignore - undocumented
33
+ preventFocusOnPress , allowFocusWhenDisabled: // @ts-ignore - undocumented
34
+ allowFocusWhenDisabled , // @ts-ignore
35
+ onClick: deprecatedOnClick , href: href , target: target , rel: rel , type: type = 'button' } = props;
36
+ let additionalProps;
37
+ if (elementType === 'button') additionalProps = {
38
+ type: type,
39
+ disabled: isDisabled
40
+ };
41
+ else additionalProps = {
42
+ role: 'button',
43
+ tabIndex: isDisabled ? undefined : 0,
44
+ href: elementType === 'a' && isDisabled ? undefined : href,
45
+ target: elementType === 'a' ? target : undefined,
46
+ type: elementType === 'input' ? type : undefined,
47
+ disabled: elementType === 'input' ? isDisabled : undefined,
48
+ 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,
49
+ rel: elementType === 'a' ? rel : undefined
50
+ };
51
+ let { pressProps: pressProps , isPressed: isPressed } = $7EMBp$reactariainteractions.usePress({
52
+ onPressStart: onPressStart,
53
+ onPressEnd: onPressEnd,
54
+ onPressChange: onPressChange,
55
+ onPress: onPress,
56
+ isDisabled: isDisabled,
57
+ preventFocusOnPress: preventFocusOnPress,
58
+ ref: ref
59
+ });
60
+ let { focusableProps: focusableProps } = $7EMBp$reactariafocus.useFocusable(props, ref);
61
+ if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
62
+ let buttonProps = $7EMBp$reactariautils.mergeProps(focusableProps, pressProps, $7EMBp$reactariautils.filterDOMProps(props, {
63
+ labelable: true
64
+ }));
65
+ return {
66
+ isPressed: isPressed,
67
+ buttonProps: $7EMBp$reactariautils.mergeProps(additionalProps, buttonProps, {
68
+ 'aria-haspopup': props['aria-haspopup'],
69
+ 'aria-expanded': props['aria-expanded'],
70
+ 'aria-controls': props['aria-controls'],
71
+ 'aria-pressed': props['aria-pressed'],
72
+ onClick: (e)=>{
73
+ if (deprecatedOnClick) {
74
+ deprecatedOnClick(e);
75
+ console.warn('onClick is deprecated, please use onPress');
76
+ }
77
+ }
78
+ })
57
79
  };
58
- }
59
-
60
- let {
61
- pressProps,
62
- isPressed
63
- } = usePress({
64
- onPressStart,
65
- onPressEnd,
66
- onPressChange,
67
- onPress,
68
- isDisabled,
69
- preventFocusOnPress,
70
- ref
71
- });
72
- let {
73
- focusableProps
74
- } = useFocusable(props, ref);
75
- let buttonProps = mergeProps(focusableProps, pressProps);
76
- buttonProps = mergeProps(buttonProps, filterDOMProps(props, {
77
- labelable: true
78
- }));
79
- return {
80
- isPressed,
81
- // Used to indicate press state for visual
82
- buttonProps: mergeProps(additionalProps, buttonProps, {
83
- 'aria-haspopup': props['aria-haspopup'],
84
- 'aria-expanded': props['aria-expanded'],
85
- 'aria-controls': props['aria-controls'],
86
- 'aria-pressed': props['aria-pressed'],
87
- disabled: isDisabled,
88
- type,
89
- onClick: e => {
90
- if (deprecatedOnClick) {
91
- deprecatedOnClick(e);
92
- console.warn('onClick is deprecated, please use onPress');
93
- }
94
- }
95
- })
96
- };
97
80
  }
98
81
 
99
- exports.useButton = useButton;
100
-
101
- /**
102
- * Provides the behavior and accessibility implementation for a toggle button component.
103
- * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.
104
- */
105
- function useToggleButton(props, state, ref) {
106
- /* eslint-enable no-redeclare */
107
- const {
108
- isSelected
109
- } = state;
110
- const {
111
- isPressed,
112
- buttonProps
113
- } = useButton(_babelRuntimeHelpersExtends({}, props, {
114
- onPress: chain(state.toggle, props.onPress)
115
- }), ref);
116
- return {
117
- isPressed,
118
- buttonProps: mergeProps(buttonProps, {
119
- 'aria-pressed': isSelected
120
- })
121
- };
82
+
83
+ var $06fe23040a134b53$exports = {};
84
+
85
+ $parcel$export($06fe23040a134b53$exports, "useToggleButton", () => $06fe23040a134b53$export$51e84d46ca0bc451);
86
+
87
+
88
+
89
+ function $06fe23040a134b53$export$51e84d46ca0bc451(props, state, ref) {
90
+ const { isSelected: isSelected } = state;
91
+ const { isPressed: isPressed , buttonProps: buttonProps } = $cf6d5e8ad7b0b063$export$ea18c227d4417cc3({
92
+ ...props,
93
+ onPress: $7EMBp$reactariautils.chain(state.toggle, props.onPress)
94
+ }, ref);
95
+ return {
96
+ isPressed: isPressed,
97
+ buttonProps: $7EMBp$reactariautils.mergeProps(buttonProps, {
98
+ 'aria-pressed': isSelected
99
+ })
100
+ };
122
101
  }
123
102
 
124
- exports.useToggleButton = useToggleButton;
103
+
104
+ $parcel$exportWildcard(module.exports, $cf6d5e8ad7b0b063$exports);
105
+ $parcel$exportWildcard(module.exports, $06fe23040a134b53$exports);
106
+
107
+
125
108
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAAOA,CAAC,IAAIA,CAAC,CAACC,UAAP,GAAoBD,CAAC,CAACE,OAAtB,GAAgCF,CAAvC;AACD;;ACuCD;;;;;;AAMO,SAASG,SAAT,CAAmBC,KAAnB,EAAwDC,GAAxD,EAA8G;AACrH;AACE,MAAI;AACFC,IAAAA,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nC,sBAAgBS;AADmB,KAAd;AAFlB,GAAP;AAMD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/button/src/useButton.ts","./packages/@react-aria/button/src/useToggleButton.ts"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\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 {AriaButtonProps} from '@react-types/button';\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/* eslint-disable no-redeclare */\nexport function useButton(props: AriaButtonProps<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonProps<'button'>, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\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<HTMLElement>): ButtonAria<HTMLAttributes<HTMLElement>>;\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/* eslint-enable no-redeclare */\n let {\n elementType = 'button',\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressChange,\n // @ts-ignore - undocumented\n preventFocusOnPress,\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 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 let buttonProps = mergeProps(focusableProps, pressProps);\n buttonProps = mergeProps(buttonProps, 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 disabled: isDisabled,\n type,\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 {mergeProps} from '@react-aria/utils';\nimport {ToggleState} from '@react-stately/toggle';\n\n/* eslint-disable no-redeclare */\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<HTMLElement>): ButtonAria<HTMLAttributes<HTMLElement>>;\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/* eslint-enable no-redeclare */\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":["$parcel$interopDefault","a","__esModule","default","useButton","props","ref","elementType","isDisabled","onPress","onPressStart","onPressEnd","onPressChange","preventFocusOnPress","onClick","deprecatedOnClick","href","target","rel","type","additionalProps","role","tabIndex","undefined","disabled","pressProps","isPressed","usePress","focusableProps","useFocusable","buttonProps","mergeProps","filterDOMProps","labelable","e","console","warn","useToggleButton","state","isSelected","chain","toggle"],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SC8CgB,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;IAC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AAU,CAAC,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;;;;;;;;;SC/Ee,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 */\n\nexport * from './useButton';\nexport * from './useToggleButton';\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 {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\nexport function useButton(props: AriaButtonProps<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonProps<'button'>, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\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<HTMLElement>): ButtonAria<HTMLAttributes<HTMLElement>>;\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 {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<HTMLElement>): ButtonAria<HTMLAttributes<HTMLElement>>;\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
@@ -1,106 +1,91 @@
1
- import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
2
- import { usePress } from "@react-aria/interactions";
3
- import { useFocusable } from "@react-aria/focus";
4
- import { filterDOMProps, mergeProps, chain } from "@react-aria/utils";
5
-
6
- /**
7
- * Provides the behavior and accessibility implementation for a button component. Handles mouse, keyboard, and touch interactions,
8
- * focus behavior, and ARIA props for both native button elements and custom element types.
9
- * @param props - Props to be applied to the button.
10
- * @param ref - A ref to a DOM element for the button.
11
- */
12
- export function useButton(props, ref) {
13
- /* eslint-enable no-redeclare */
14
- let {
15
- elementType = 'button',
16
- isDisabled,
17
- onPress,
18
- onPressStart,
19
- onPressEnd,
20
- onPressChange,
21
- // @ts-ignore - undocumented
22
- preventFocusOnPress,
23
- // @ts-ignore
24
- onClick: deprecatedOnClick,
25
- href,
26
- target,
27
- rel,
28
- type = 'button'
29
- } = props;
30
- let additionalProps;
31
-
32
- if (elementType !== 'button') {
33
- additionalProps = {
34
- role: 'button',
35
- tabIndex: isDisabled ? undefined : 0,
36
- href: elementType === 'a' && isDisabled ? undefined : href,
37
- target: elementType === 'a' ? target : undefined,
38
- type: elementType === 'input' ? type : undefined,
39
- disabled: elementType === 'input' ? isDisabled : undefined,
40
- 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,
41
- rel: elementType === 'a' ? rel : undefined
1
+ import {mergeProps as $fXQi9$mergeProps, filterDOMProps as $fXQi9$filterDOMProps, chain as $fXQi9$chain} from "@react-aria/utils";
2
+ import {useFocusable as $fXQi9$useFocusable} from "@react-aria/focus";
3
+ import {usePress as $fXQi9$usePress} from "@react-aria/interactions";
4
+
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
+ }
8
+ var $406353e93a1b90e2$exports = {};
9
+
10
+ $parcel$export($406353e93a1b90e2$exports, "useButton", () => $406353e93a1b90e2$export$ea18c227d4417cc3);
11
+
12
+
13
+
14
+
15
+ function $406353e93a1b90e2$export$ea18c227d4417cc3(props, ref) {
16
+ let { elementType: elementType = 'button' , isDisabled: isDisabled , onPress: onPress , onPressStart: onPressStart , onPressEnd: onPressEnd , onPressChange: onPressChange , preventFocusOnPress: // @ts-ignore - undocumented
17
+ preventFocusOnPress , allowFocusWhenDisabled: // @ts-ignore - undocumented
18
+ allowFocusWhenDisabled , // @ts-ignore
19
+ onClick: deprecatedOnClick , href: href , target: target , rel: rel , type: type = 'button' } = props;
20
+ let additionalProps;
21
+ if (elementType === 'button') additionalProps = {
22
+ type: type,
23
+ disabled: isDisabled
24
+ };
25
+ else additionalProps = {
26
+ role: 'button',
27
+ 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
34
+ };
35
+ let { pressProps: pressProps , isPressed: isPressed } = $fXQi9$usePress({
36
+ onPressStart: onPressStart,
37
+ onPressEnd: onPressEnd,
38
+ onPressChange: onPressChange,
39
+ onPress: onPress,
40
+ isDisabled: isDisabled,
41
+ preventFocusOnPress: preventFocusOnPress,
42
+ ref: ref
43
+ });
44
+ let { focusableProps: focusableProps } = $fXQi9$useFocusable(props, ref);
45
+ if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
46
+ let buttonProps = $fXQi9$mergeProps(focusableProps, pressProps, $fXQi9$filterDOMProps(props, {
47
+ labelable: true
48
+ }));
49
+ return {
50
+ isPressed: isPressed,
51
+ buttonProps: $fXQi9$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'],
56
+ onClick: (e)=>{
57
+ if (deprecatedOnClick) {
58
+ deprecatedOnClick(e);
59
+ console.warn('onClick is deprecated, please use onPress');
60
+ }
61
+ }
62
+ })
42
63
  };
43
- }
44
-
45
- let {
46
- pressProps,
47
- isPressed
48
- } = usePress({
49
- onPressStart,
50
- onPressEnd,
51
- onPressChange,
52
- onPress,
53
- isDisabled,
54
- preventFocusOnPress,
55
- ref
56
- });
57
- let {
58
- focusableProps
59
- } = useFocusable(props, ref);
60
- let buttonProps = mergeProps(focusableProps, pressProps);
61
- buttonProps = mergeProps(buttonProps, filterDOMProps(props, {
62
- labelable: true
63
- }));
64
- return {
65
- isPressed,
66
- // Used to indicate press state for visual
67
- buttonProps: mergeProps(additionalProps, buttonProps, {
68
- 'aria-haspopup': props['aria-haspopup'],
69
- 'aria-expanded': props['aria-expanded'],
70
- 'aria-controls': props['aria-controls'],
71
- 'aria-pressed': props['aria-pressed'],
72
- disabled: isDisabled,
73
- type,
74
- onClick: e => {
75
- if (deprecatedOnClick) {
76
- deprecatedOnClick(e);
77
- console.warn('onClick is deprecated, please use onPress');
78
- }
79
- }
80
- })
81
- };
82
64
  }
83
65
 
84
- /**
85
- * Provides the behavior and accessibility implementation for a toggle button component.
86
- * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.
87
- */
88
- export function useToggleButton(props, state, ref) {
89
- /* eslint-enable no-redeclare */
90
- const {
91
- isSelected
92
- } = state;
93
- const {
94
- isPressed,
95
- buttonProps
96
- } = useButton(_babelRuntimeHelpersEsmExtends({}, props, {
97
- onPress: chain(state.toggle, props.onPress)
98
- }), ref);
99
- return {
100
- isPressed,
101
- buttonProps: mergeProps(buttonProps, {
102
- 'aria-pressed': isSelected
103
- })
104
- };
66
+
67
+ var $02948abd23f2e84a$exports = {};
68
+
69
+ $parcel$export($02948abd23f2e84a$exports, "useToggleButton", () => $02948abd23f2e84a$export$51e84d46ca0bc451);
70
+
71
+
72
+
73
+ function $02948abd23f2e84a$export$51e84d46ca0bc451(props, state, ref) {
74
+ const { isSelected: isSelected } = state;
75
+ const { isPressed: isPressed , buttonProps: buttonProps } = $406353e93a1b90e2$export$ea18c227d4417cc3({
76
+ ...props,
77
+ onPress: $fXQi9$chain(state.toggle, props.onPress)
78
+ }, ref);
79
+ return {
80
+ isPressed: isPressed,
81
+ buttonProps: $fXQi9$mergeProps(buttonProps, {
82
+ 'aria-pressed': isSelected
83
+ })
84
+ };
105
85
  }
86
+
87
+
88
+
89
+
90
+ export {$406353e93a1b90e2$export$ea18c227d4417cc3 as useButton, $02948abd23f2e84a$export$51e84d46ca0bc451 as useToggleButton};
106
91
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;AAyCA;;;;;;OAMO,SAASA,SAAT,CAAmBC,KAAnB,EAAwDC,GAAxD,EAA8G;AACrH;AACE,MAAI;AACFC,IAAAA,WAAW,GAAG,QADZ;AAEFC,IAAAA,UAFE;AAGFC,IAAAA,OAHE;AAIFC,IAAAA,YAJE;AAKFC,IAAAA,UALE;AAMFC,IAAAA,aANE;AAOF;AACAC,IAAAA,mBARE;AASF;AACAC,IAAAA,OAAO,EAAEC,iBAVP;AAWFC,IAAAA,IAXE;AAYFC,IAAAA,MAZE;AAaFC,IAAAA,GAbE;AAcFC,IAAAA,IAAI,GAAG;AAdL,MAeAd,KAfJ;AAgBA,MAAIe,eAAJ;;AACA,MAAIb,WAAW,KAAK,QAApB,E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,CAACX,eAAD,EAAkBU,WAAlB,EAA+B;AACpD,uBAAiBzB,KAAK,CAAC,eAAD,CAD8B;AAEpD,uBAAiBA,KAAK,CAAC,eAAD,CAF8B;AAGpD,uBAAiBA,KAAK,CAAC,eAAD,CAH8B;AAIpD,sBAAgBA,KAAK,CAAC,cAAD,CAJ+B;AAKpDmB,MAAAA,QAAQ,EAAEhB,UAL0C;AAMpDW,MAAAA,IANoD;AAOpDL,MAAAA,OAAO,EAAGoB,CAAD,IAAO;AACd,YAAInB,iBAAJ,EAAuB;AACrBA,UAAAA,iBAAiB,CAACmB,CAAD,CAAjB;AACAC,UAAAA,OAAO,CAACC,IAAR,CAAa,2CAAb;AACD;AACF;AAZmD,KAA/B;AAFlB,GAAP;AAiBD;;AC7ED;;;;OAIO,SAASC,eAAT,CAAyBhC,KAAzB,EAAoEiC,KAApE,EAAwFhC,GAAxF,EAA8I;AACrJ;AACE,QAAM;AAACiC,IAAAA;AAAD,MAAeD,KAArB;AACA,QAAM;AAACZ,IAAAA,SAAD;AAAYI,IAAAA;AAAZ,MAA2B,6CAC5BzB,KAD4B;AAE/BI,IAAAA,OAAO,EAAE+B,KAAK,CAACF,KAAK,CAACG,MAAP,EAAepC,KAAK,CAACI,OAArB;AAFiB,MAG9BH,GAH8B,CAAjC;AAKA,SAAO;AACLoB,IAAAA,SADK;AAELI,IAAAA,WAAW,EAAEC,UAAU,CAACD,WAAD,EAAc;AACnC,sBAAgBS;AADmB,KAAd;AAFlB,GAAP;AAMD","sources":["./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 */\n\nimport {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n ElementType,\n HTMLAttributes,\n InputHTMLAttributes,\n RefObject\n} from 'react';\nimport {AriaButtonProps} from '@react-types/button';\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/* eslint-disable no-redeclare */\nexport function useButton(props: AriaButtonProps<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonProps<'button'>, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\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<HTMLElement>): ButtonAria<HTMLAttributes<HTMLElement>>;\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/* eslint-enable no-redeclare */\n let {\n elementType = 'button',\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressChange,\n // @ts-ignore - undocumented\n preventFocusOnPress,\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 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 let buttonProps = mergeProps(focusableProps, pressProps);\n buttonProps = mergeProps(buttonProps, 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 disabled: isDisabled,\n type,\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 {mergeProps} from '@react-aria/utils';\nimport {ToggleState} from '@react-stately/toggle';\n\n/* eslint-disable no-redeclare */\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<HTMLElement>): ButtonAria<HTMLAttributes<HTMLElement>>;\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/* eslint-enable no-redeclare */\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":["useButton","props","ref","elementType","isDisabled","onPress","onPressStart","onPressEnd","onPressChange","preventFocusOnPress","onClick","deprecatedOnClick","href","target","rel","type","additionalProps","role","tabIndex","undefined","disabled","pressProps","isPressed","usePress","focusableProps","useFocusable","buttonProps","mergeProps","filterDOMProps","labelable","e","console","warn","useToggleButton","state","isSelected","chain","toggle"],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;SC8CgB,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,SAC1B,eAAe,GAAG,CAAC;cACjB,IAAI;QACJ,QAAQ,EAAE,UAAU;IACtB,CAAC;SAED,eAAe,GAAG,CAAC;QACjB,IAAI,EAAE,CAAQ;QACd,QAAQ,EAAE,UAAU,GAAG,SAAS,GAAG,CAAC;QACpC,IAAI,EAAE,WAAW,KAAK,CAAG,MAAI,UAAU,GAAG,SAAS,GAAG,IAAI;QAC1D,MAAM,EAAE,WAAW,KAAK,CAAG,KAAG,MAAM,GAAG,SAAS;QAChD,IAAI,EAAE,WAAW,KAAK,CAAO,SAAG,IAAI,GAAG,SAAS;QAChD,QAAQ,EAAE,WAAW,KAAK,CAAO,SAAG,UAAU,GAAG,SAAS;QAC1D,CAAe,iBAAG,UAAU,IAAI,WAAW,KAAK,CAAO,SAAG,SAAS,GAAG,UAAU;QAChF,GAAG,EAAE,WAAW,KAAK,CAAG,KAAG,GAAG,GAAG,SAAS;IAC5C,CAAC;IAGH,GAAG,CAAC,CAAC,aAAA,UAAU,cAAE,SAAS,EAAA,CAAC,GAAG,eAAQ,CAAC,CAAC;sB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AS;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 */\n\nexport * from './useButton';\nexport * from './useToggleButton';\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 {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\nexport function useButton(props: AriaButtonProps<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonProps<'button'>, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\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<HTMLElement>): ButtonAria<HTMLAttributes<HTMLElement>>;\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 {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<HTMLElement>): ButtonAria<HTMLAttributes<HTMLElement>>;\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
@@ -1,4 +1,4 @@
1
- import { ElementType, HTMLAttributes, RefObject } from "react";
1
+ import { AnchorHTMLAttributes, ButtonHTMLAttributes, ElementType, HTMLAttributes, InputHTMLAttributes, RefObject } from "react";
2
2
  import { AriaButtonProps, AriaToggleButtonProps } from "@react-types/button";
3
3
  import { ToggleState } from "@react-stately/toggle";
4
4
  export interface ButtonAria<T> {
@@ -1 +1 @@
1
- {"mappings":"A;A;A;AA2BA,4BAA4B,CAAC;IAC3B,oCAAoC;IACpC,WAAW,EAAE,CAAC,CAAC;IACf,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAA;CACnB;AAGD,0BAA0B,KAAK,EAAE,gBAAgB,GAAG,CAAC,EAAE,GAAG,EAAE,UAAU,iBAAiB,CAAC,GAAG,WAAW,qBAAqB,iBAAiB,CAAC,CAAC,CAAC;AAC/I,0BAA0B,KAAK,EAAE,gBAAgB,QA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L,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,WAAW,CAAC,GAAG,WAAW,eAAe,WAAW,CAAC,CAAC,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"],"sourcesContent":[null,null,null],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;AA2BA,4BAA4B,CAAC;IAC3B,oCAAoC;IACpC,WAAW,EAAE,CAAC,CAAC;IACf,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,0BAA0B,KAAK,EAAE,gBAAgB,GAAG,CAAC,EAAE,GAAG,EAAE,UAAU,iBAAiB,CAAC,GAAG,WAAW,qBAAqB,iBAAiB,CAAC,CAAC,CAAC;AAC/I,0BAA0B,KAAK,EAAE,gBAAgB,QAAQ,CAAC,EAAE,GAAG,EAAE,UAAU,iBAAiB,CAAC,GAAG,WAAW,qBAAqB,iBAAiB,CAAC,CAAC,CAAC;AACpJ,0BAA0B,KAAK,EAAE,gBAAgB,KAAK,CAAC,EAAE,GAAG,EAAE,UAAU,cAAc,CAAC,GAAG,WAAW,eAAe,cAAc,CAAC,CAAC,CAAC;AACrI,0BAA0B,KAAK,EAAE,gBAAgB,OAAO,CAAC,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,WAAW,oBAAoB,gBAAgB,CAAC,CAAC,CAAC;AAChJ,0BAA0B,KAAK,EAAE,gBAAgB,MAAM,CAAC,EAAE,GAAG,EAAE,UAAU,eAAe,CAAC,GAAG,WAAW,eAAe,eAAe,CAAC,CAAC,CAAC;AACxI,0BAA0B,KAAK,EAAE,gBAAgB,WAAW,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,WAAW,eAAe,WAAW,CAAC,CAAC,CAAC;ACbrI,gCAAgC,KAAK,EAAE,sBAAsB,GAAG,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,iBAAiB,CAAC,GAAG,WAAW,qBAAqB,iBAAiB,CAAC,CAAC,CAAC;AAC/K,gCAAgC,KAAK,EAAE,sBAAsB,QAAQ,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,iBAAiB,CAAC,GAAG,WAAW,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,WAAW,CAAC,GAAG,WAAW,eAAe,WAAW,CAAC,CAAC,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 */\n\nexport * from './useButton';\nexport * from './useToggleButton';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/button",
3
- "version": "3.3.1",
3
+ "version": "3.4.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,12 +18,11 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-aria/focus": "^3.2.2",
22
- "@react-aria/i18n": "^3.3.0",
23
- "@react-aria/interactions": "^3.3.3",
24
- "@react-aria/utils": "^3.6.0",
25
- "@react-stately/toggle": "^3.2.1",
26
- "@react-types/button": "^3.3.1"
21
+ "@react-aria/focus": "^3.5.1",
22
+ "@react-aria/interactions": "^3.8.0",
23
+ "@react-aria/utils": "^3.11.1",
24
+ "@react-stately/toggle": "^3.2.4",
25
+ "@react-types/button": "^3.4.2"
27
26
  },
28
27
  "peerDependencies": {
29
28
  "react": "^16.8.0 || ^17.0.0-rc.1"
@@ -31,5 +30,5 @@
31
30
  "publishConfig": {
32
31
  "access": "public"
33
32
  },
34
- "gitHead": "7f9dc7fa5144679d2dc733170cb5c1f40d0c5ee5"
33
+ "gitHead": "54c2366c4f31bd4bf619126131cd583c12972acc"
35
34
  }
package/src/useButton.ts CHANGED
@@ -32,7 +32,6 @@ export interface ButtonAria<T> {
32
32
  isPressed: boolean
33
33
  }
34
34
 
35
- /* eslint-disable no-redeclare */
36
35
  export function useButton(props: AriaButtonProps<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
37
36
  export function useButton(props: AriaButtonProps<'button'>, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;
38
37
  export function useButton(props: AriaButtonProps<'div'>, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;
@@ -46,7 +45,6 @@ export function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<HT
46
45
  * @param ref - A ref to a DOM element for the button.
47
46
  */
48
47
  export function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {
49
- /* eslint-enable no-redeclare */
50
48
  let {
51
49
  elementType = 'button',
52
50
  isDisabled,
@@ -56,6 +54,8 @@ export function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<an
56
54
  onPressChange,
57
55
  // @ts-ignore - undocumented
58
56
  preventFocusOnPress,
57
+ // @ts-ignore - undocumented
58
+ allowFocusWhenDisabled,
59
59
  // @ts-ignore
60
60
  onClick: deprecatedOnClick,
61
61
  href,
@@ -64,7 +64,12 @@ export function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<an
64
64
  type = 'button'
65
65
  } = props;
66
66
  let additionalProps;
67
- if (elementType !== 'button') {
67
+ if (elementType === 'button') {
68
+ additionalProps = {
69
+ type,
70
+ disabled: isDisabled
71
+ };
72
+ } else {
68
73
  additionalProps = {
69
74
  role: 'button',
70
75
  tabIndex: isDisabled ? undefined : 0,
@@ -88,8 +93,10 @@ export function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<an
88
93
  });
89
94
 
90
95
  let {focusableProps} = useFocusable(props, ref);
91
- let buttonProps = mergeProps(focusableProps, pressProps);
92
- buttonProps = mergeProps(buttonProps, filterDOMProps(props, {labelable: true}));
96
+ if (allowFocusWhenDisabled) {
97
+ focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
98
+ }
99
+ let buttonProps = mergeProps(focusableProps, pressProps, filterDOMProps(props, {labelable: true}));
93
100
 
94
101
  return {
95
102
  isPressed, // Used to indicate press state for visual
@@ -98,8 +105,6 @@ export function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<an
98
105
  'aria-expanded': props['aria-expanded'],
99
106
  'aria-controls': props['aria-controls'],
100
107
  'aria-pressed': props['aria-pressed'],
101
- disabled: isDisabled,
102
- type,
103
108
  onClick: (e) => {
104
109
  if (deprecatedOnClick) {
105
110
  deprecatedOnClick(e);
@@ -24,7 +24,6 @@ import {chain} from '@react-aria/utils';
24
24
  import {mergeProps} from '@react-aria/utils';
25
25
  import {ToggleState} from '@react-stately/toggle';
26
26
 
27
- /* eslint-disable no-redeclare */
28
27
  export function useToggleButton(props: AriaToggleButtonProps<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
29
28
  export function useToggleButton(props: AriaToggleButtonProps<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;
30
29
  export function useToggleButton(props: AriaToggleButtonProps<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;
@@ -36,7 +35,6 @@ export function useToggleButton(props: AriaToggleButtonProps<ElementType>, state
36
35
  * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.
37
36
  */
38
37
  export function useToggleButton(props: AriaToggleButtonProps<ElementType>, state: ToggleState, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {
39
- /* eslint-enable no-redeclare */
40
38
  const {isSelected} = state;
41
39
  const {isPressed, buttonProps} = useButton({
42
40
  ...props,