@react-aria/button 3.9.2 → 3.9.4

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/import.mjs CHANGED
@@ -1,82 +1,5 @@
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
- function $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
29
- let { elementType: elementType = "button", isDisabled: isDisabled, onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressUp: onPressUp, onPressChange: onPressChange, preventFocusOnPress: // @ts-ignore - undocumented
30
- preventFocusOnPress, allowFocusWhenDisabled: // @ts-ignore - undocumented
31
- allowFocusWhenDisabled, // @ts-ignore
32
- onClick: deprecatedOnClick, href: href, target: target, rel: rel, type: type = "button" } = props;
33
- let additionalProps;
34
- if (elementType === "button") additionalProps = {
35
- type: type,
36
- disabled: isDisabled
37
- };
38
- else additionalProps = {
39
- role: "button",
40
- tabIndex: isDisabled ? undefined : 0,
41
- href: elementType === "a" && isDisabled ? undefined : href,
42
- target: elementType === "a" ? target : undefined,
43
- type: elementType === "input" ? type : undefined,
44
- disabled: elementType === "input" ? isDisabled : undefined,
45
- "aria-disabled": !isDisabled || elementType === "input" ? undefined : isDisabled,
46
- rel: elementType === "a" ? rel : undefined
47
- };
48
- let { pressProps: pressProps, isPressed: isPressed } = (0, $cE0pI$usePress)({
49
- onPressStart: onPressStart,
50
- onPressEnd: onPressEnd,
51
- onPressChange: onPressChange,
52
- onPress: onPress,
53
- onPressUp: onPressUp,
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
-
1
+ import {useButton as $701a24aa0da5b062$export$ea18c227d4417cc3} from "./useButton.mjs";
2
+ import {useToggleButton as $55f54f7887471b58$export$51e84d46ca0bc451} from "./useToggleButton.mjs";
80
3
 
81
4
  /*
82
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -90,21 +13,6 @@ function $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
90
13
  * governing permissions and limitations under the License.
91
14
  */
92
15
 
93
- function $55f54f7887471b58$export$51e84d46ca0bc451(props, state, ref) {
94
- const { isSelected: isSelected } = state;
95
- const { isPressed: isPressed, buttonProps: buttonProps } = (0, $701a24aa0da5b062$export$ea18c227d4417cc3)({
96
- ...props,
97
- onPress: (0, $cE0pI$chain)(state.toggle, props.onPress)
98
- }, ref);
99
- return {
100
- isPressed: isPressed,
101
- buttonProps: (0, $cE0pI$mergeProps)(buttonProps, {
102
- "aria-pressed": isSelected
103
- })
104
- };
105
- }
106
-
107
-
108
16
 
109
17
 
110
18
  export {$701a24aa0da5b062$export$ea18c227d4417cc3 as useButton, $55f54f7887471b58$export$51e84d46ca0bc451 as useToggleButton};
package/dist/main.js CHANGED
@@ -1,90 +1,13 @@
1
- var $eeQ2i$reactariautils = require("@react-aria/utils");
2
- var $eeQ2i$reactariafocus = require("@react-aria/focus");
3
- var $eeQ2i$reactariainteractions = require("@react-aria/interactions");
1
+ var $988353faa005faf8$exports = require("./useButton.main.js");
2
+ var $c49208f7d2aac50b$exports = require("./useToggleButton.main.js");
4
3
 
5
4
 
6
5
  function $parcel$export(e, n, v, s) {
7
6
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
7
  }
9
8
 
10
- $parcel$export(module.exports, "useButton", () => $988353faa005faf8$export$ea18c227d4417cc3);
11
- $parcel$export(module.exports, "useToggleButton", () => $c49208f7d2aac50b$export$51e84d46ca0bc451);
12
- /*
13
- * Copyright 2020 Adobe. All rights reserved.
14
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
15
- * you may not use this file except in compliance with the License. You may obtain a copy
16
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software distributed under
19
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20
- * OF ANY KIND, either express or implied. See the License for the specific language
21
- * governing permissions and limitations under the License.
22
- */ /*
23
- * Copyright 2020 Adobe. All rights reserved.
24
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
25
- * you may not use this file except in compliance with the License. You may obtain a copy
26
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
27
- *
28
- * Unless required by applicable law or agreed to in writing, software distributed under
29
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
30
- * OF ANY KIND, either express or implied. See the License for the specific language
31
- * governing permissions and limitations under the License.
32
- */
33
-
34
-
35
- function $988353faa005faf8$export$ea18c227d4417cc3(props, ref) {
36
- let { elementType: elementType = "button", isDisabled: isDisabled, onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressUp: onPressUp, onPressChange: onPressChange, preventFocusOnPress: // @ts-ignore - undocumented
37
- preventFocusOnPress, allowFocusWhenDisabled: // @ts-ignore - undocumented
38
- allowFocusWhenDisabled, // @ts-ignore
39
- onClick: deprecatedOnClick, href: href, target: target, rel: rel, type: type = "button" } = props;
40
- let additionalProps;
41
- if (elementType === "button") additionalProps = {
42
- type: type,
43
- disabled: isDisabled
44
- };
45
- else additionalProps = {
46
- role: "button",
47
- tabIndex: isDisabled ? undefined : 0,
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
54
- };
55
- let { pressProps: pressProps, isPressed: isPressed } = (0, $eeQ2i$reactariainteractions.usePress)({
56
- onPressStart: onPressStart,
57
- onPressEnd: onPressEnd,
58
- onPressChange: onPressChange,
59
- onPress: onPress,
60
- onPressUp: onPressUp,
61
- isDisabled: isDisabled,
62
- preventFocusOnPress: preventFocusOnPress,
63
- ref: ref
64
- });
65
- let { focusableProps: focusableProps } = (0, $eeQ2i$reactariafocus.useFocusable)(props, ref);
66
- if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
67
- let buttonProps = (0, $eeQ2i$reactariautils.mergeProps)(focusableProps, pressProps, (0, $eeQ2i$reactariautils.filterDOMProps)(props, {
68
- labelable: true
69
- }));
70
- return {
71
- isPressed: isPressed,
72
- buttonProps: (0, $eeQ2i$reactariautils.mergeProps)(additionalProps, buttonProps, {
73
- "aria-haspopup": props["aria-haspopup"],
74
- "aria-expanded": props["aria-expanded"],
75
- "aria-controls": props["aria-controls"],
76
- "aria-pressed": props["aria-pressed"],
77
- onClick: (e)=>{
78
- if (deprecatedOnClick) {
79
- deprecatedOnClick(e);
80
- console.warn("onClick is deprecated, please use onPress");
81
- }
82
- }
83
- })
84
- };
85
- }
86
-
87
-
9
+ $parcel$export(module.exports, "useButton", () => $988353faa005faf8$exports.useButton);
10
+ $parcel$export(module.exports, "useToggleButton", () => $c49208f7d2aac50b$exports.useToggleButton);
88
11
  /*
89
12
  * Copyright 2020 Adobe. All rights reserved.
90
13
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -97,21 +20,6 @@ function $988353faa005faf8$export$ea18c227d4417cc3(props, ref) {
97
20
  * governing permissions and limitations under the License.
98
21
  */
99
22
 
100
- function $c49208f7d2aac50b$export$51e84d46ca0bc451(props, state, ref) {
101
- const { isSelected: isSelected } = state;
102
- const { isPressed: isPressed, buttonProps: buttonProps } = (0, $988353faa005faf8$export$ea18c227d4417cc3)({
103
- ...props,
104
- onPress: (0, $eeQ2i$reactariautils.chain)(state.toggle, props.onPress)
105
- }, ref);
106
- return {
107
- isPressed: isPressed,
108
- buttonProps: (0, $eeQ2i$reactariautils.mergeProps)(buttonProps, {
109
- "aria-pressed": isSelected
110
- })
111
- };
112
- }
113
-
114
-
115
23
 
116
24
 
117
25
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;AAsCM,SAAS,0CAAU,KAAqC,EAAE,GAAmB;IAClF,IAAI,eACF,cAAc,sBACd,UAAU,WACV,OAAO,gBACP,YAAY,cACZ,UAAU,aACV,SAAS,iBACT,aAAa,uBACb,4BAA4B;IAC5B,mBAAmB,0BACnB,4BAA4B;IAC5B,sBAAsB,EACtB,aAAa;IACb,SAAS,iBAAiB,QAC1B,IAAI,UACJ,MAAM,OACN,GAAG,QACH,OAAO,UACR,GAAG;IACJ,IAAI;IACJ,IAAI,gBAAgB,UAClB,kBAAkB;cAChB;QACA,UAAU;IACZ;SAEA,kBAAkB;QAChB,MAAM;QACN,UAAU,aAAa,YAAY;QACnC,MAAM,gBAAgB,OAAO,aAAa,YAAY;QACtD,QAAQ,gBAAgB,MAAM,SAAS;QACvC,MAAM,gBAAgB,UAAU,OAAO;QACvC,UAAU,gBAAgB,UAAU,aAAa;QACjD,iBAAiB,CAAC,cAAc,gBAAgB,UAAU,YAAY;QACtE,KAAK,gBAAgB,MAAM,MAAM;IACnC;IAGF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;sBACrC;oBACA;uBACA;iBACA;mBACA;oBACA;6BACA;aACA;IACF;IAEA,IAAI,kBAAC,cAAc,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,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAE/F,OAAO;mBACL;QACA,aAAa,CAAA,GAAA,gCAAS,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;gBACR,IAAI,mBAAmB;oBACrB,kBAAkB;oBAClB,QAAQ,IAAI,CAAC;gBACf;YACF;QACF;IACF;AACF;;CD7GC;AEVD;;;;;;;;;;CAUC;;AA6BM,SAAS,0CAAgB,KAA2C,EAAE,KAAkB,EAAE,GAAmB;IAClH,MAAM,cAAC,UAAU,EAAC,GAAG;IACrB,MAAM,aAAC,SAAS,eAAE,WAAW,EAAC,GAAG,CAAA,GAAA,yCAAQ,EAAE;QACzC,GAAG,KAAK;QACR,SAAS,CAAA,GAAA,2BAAI,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO;IAC5C,GAAG;IAEH,OAAO;mBACL;QACA,aAAa,CAAA,GAAA,gCAAS,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 {AriaButtonOptions, 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, mergeProps} from '@react-aria/utils';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface AriaButtonOptions<E extends ElementType> extends Omit<AriaButtonProps<E>, 'children'> {}\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: AriaButtonOptions<'button'>, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useButton(props: AriaButtonOptions<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonOptions<'div'>, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useButton(props: AriaButtonOptions<'input'>, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useButton(props: AriaButtonOptions<'span'>, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useButton(props: AriaButtonOptions<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: AriaButtonOptions<ElementType>, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {\n let {\n elementType = 'button',\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressUp,\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 onPressUp,\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, mergeProps} from '@react-aria/utils';\nimport {DOMAttributes} from '@react-types/shared';\nimport {ToggleState} from '@react-stately/toggle';\n\nexport interface AriaToggleButtonOptions<E extends ElementType> extends Omit<AriaToggleButtonProps<E>, 'children'> {}\n\n// Order with overrides is important: 'button' should be default\nexport function useToggleButton(props: AriaToggleButtonOptions<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<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: AriaToggleButtonOptions<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;;;;;;;;;;CAUC","sources":["packages/@react-aria/button/src/index.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 {AriaButtonOptions, ButtonAria} from './useButton';\nexport type {AriaButtonProps, AriaToggleButtonProps} from '@react-types/button';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,82 +1,5 @@
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
- function $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
29
- let { elementType: elementType = "button", isDisabled: isDisabled, onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressUp: onPressUp, onPressChange: onPressChange, preventFocusOnPress: // @ts-ignore - undocumented
30
- preventFocusOnPress, allowFocusWhenDisabled: // @ts-ignore - undocumented
31
- allowFocusWhenDisabled, // @ts-ignore
32
- onClick: deprecatedOnClick, href: href, target: target, rel: rel, type: type = "button" } = props;
33
- let additionalProps;
34
- if (elementType === "button") additionalProps = {
35
- type: type,
36
- disabled: isDisabled
37
- };
38
- else additionalProps = {
39
- role: "button",
40
- tabIndex: isDisabled ? undefined : 0,
41
- href: elementType === "a" && isDisabled ? undefined : href,
42
- target: elementType === "a" ? target : undefined,
43
- type: elementType === "input" ? type : undefined,
44
- disabled: elementType === "input" ? isDisabled : undefined,
45
- "aria-disabled": !isDisabled || elementType === "input" ? undefined : isDisabled,
46
- rel: elementType === "a" ? rel : undefined
47
- };
48
- let { pressProps: pressProps, isPressed: isPressed } = (0, $cE0pI$usePress)({
49
- onPressStart: onPressStart,
50
- onPressEnd: onPressEnd,
51
- onPressChange: onPressChange,
52
- onPress: onPress,
53
- onPressUp: onPressUp,
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
-
1
+ import {useButton as $701a24aa0da5b062$export$ea18c227d4417cc3} from "./useButton.module.js";
2
+ import {useToggleButton as $55f54f7887471b58$export$51e84d46ca0bc451} from "./useToggleButton.module.js";
80
3
 
81
4
  /*
82
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -90,21 +13,6 @@ function $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
90
13
  * governing permissions and limitations under the License.
91
14
  */
92
15
 
93
- function $55f54f7887471b58$export$51e84d46ca0bc451(props, state, ref) {
94
- const { isSelected: isSelected } = state;
95
- const { isPressed: isPressed, buttonProps: buttonProps } = (0, $701a24aa0da5b062$export$ea18c227d4417cc3)({
96
- ...props,
97
- onPress: (0, $cE0pI$chain)(state.toggle, props.onPress)
98
- }, ref);
99
- return {
100
- isPressed: isPressed,
101
- buttonProps: (0, $cE0pI$mergeProps)(buttonProps, {
102
- "aria-pressed": isSelected
103
- })
104
- };
105
- }
106
-
107
-
108
16
 
109
17
 
110
18
  export {$701a24aa0da5b062$export$ea18c227d4417cc3 as useButton, $55f54f7887471b58$export$51e84d46ca0bc451 as useToggleButton};
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;AAsCM,SAAS,0CAAU,KAAqC,EAAE,GAAmB;IAClF,IAAI,eACF,cAAc,sBACd,UAAU,WACV,OAAO,gBACP,YAAY,cACZ,UAAU,aACV,SAAS,iBACT,aAAa,uBACb,4BAA4B;IAC5B,mBAAmB,0BACnB,4BAA4B;IAC5B,sBAAsB,EACtB,aAAa;IACb,SAAS,iBAAiB,QAC1B,IAAI,UACJ,MAAM,OACN,GAAG,QACH,OAAO,UACR,GAAG;IACJ,IAAI;IACJ,IAAI,gBAAgB,UAClB,kBAAkB;cAChB;QACA,UAAU;IACZ;SAEA,kBAAkB;QAChB,MAAM;QACN,UAAU,aAAa,YAAY;QACnC,MAAM,gBAAgB,OAAO,aAAa,YAAY;QACtD,QAAQ,gBAAgB,MAAM,SAAS;QACvC,MAAM,gBAAgB,UAAU,OAAO;QACvC,UAAU,gBAAgB,UAAU,aAAa;QACjD,iBAAiB,CAAC,cAAc,gBAAgB,UAAU,YAAY;QACtE,KAAK,gBAAgB,MAAM,MAAM;IACnC;IAGF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;sBACrC;oBACA;uBACA;iBACA;mBACA;oBACA;6BACA;aACA;IACF;IAEA,IAAI,kBAAC,cAAc,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,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAE/F,OAAO;mBACL;QACA,aAAa,CAAA,GAAA,iBAAS,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;gBACR,IAAI,mBAAmB;oBACrB,kBAAkB;oBAClB,QAAQ,IAAI,CAAC;gBACf;YACF;QACF;IACF;AACF;;CD7GC;AEVD;;;;;;;;;;CAUC;;AA6BM,SAAS,0CAAgB,KAA2C,EAAE,KAAkB,EAAE,GAAmB;IAClH,MAAM,cAAC,UAAU,EAAC,GAAG;IACrB,MAAM,aAAC,SAAS,eAAE,WAAW,EAAC,GAAG,CAAA,GAAA,yCAAQ,EAAE;QACzC,GAAG,KAAK;QACR,SAAS,CAAA,GAAA,YAAI,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO;IAC5C,GAAG;IAEH,OAAO;mBACL;QACA,aAAa,CAAA,GAAA,iBAAS,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 {AriaButtonOptions, 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, mergeProps} from '@react-aria/utils';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface AriaButtonOptions<E extends ElementType> extends Omit<AriaButtonProps<E>, 'children'> {}\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: AriaButtonOptions<'button'>, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useButton(props: AriaButtonOptions<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonOptions<'div'>, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useButton(props: AriaButtonOptions<'input'>, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useButton(props: AriaButtonOptions<'span'>, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useButton(props: AriaButtonOptions<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: AriaButtonOptions<ElementType>, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {\n let {\n elementType = 'button',\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressUp,\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 onPressUp,\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, mergeProps} from '@react-aria/utils';\nimport {DOMAttributes} from '@react-types/shared';\nimport {ToggleState} from '@react-stately/toggle';\n\nexport interface AriaToggleButtonOptions<E extends ElementType> extends Omit<AriaToggleButtonProps<E>, 'children'> {}\n\n// Order with overrides is important: 'button' should be default\nexport function useToggleButton(props: AriaToggleButtonOptions<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<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: AriaToggleButtonOptions<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;;;;;;;;;;CAUC","sources":["packages/@react-aria/button/src/index.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 {AriaButtonOptions, ButtonAria} from './useButton';\nexport type {AriaButtonProps, AriaToggleButtonProps} from '@react-types/button';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,77 @@
1
+ var $lIlxZ$reactariautils = require("@react-aria/utils");
2
+ var $lIlxZ$reactariafocus = require("@react-aria/focus");
3
+ var $lIlxZ$reactariainteractions = require("@react-aria/interactions");
4
+
5
+
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
+ }
9
+
10
+ $parcel$export(module.exports, "useButton", () => $988353faa005faf8$export$ea18c227d4417cc3);
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
+
23
+
24
+ function $988353faa005faf8$export$ea18c227d4417cc3(props, ref) {
25
+ let { elementType: elementType = "button", isDisabled: isDisabled, onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressUp: onPressUp, onPressChange: onPressChange, preventFocusOnPress: // @ts-ignore - undocumented
26
+ preventFocusOnPress, allowFocusWhenDisabled: // @ts-ignore - undocumented
27
+ allowFocusWhenDisabled, // @ts-ignore
28
+ onClick: deprecatedOnClick, href: href, target: target, rel: rel, type: type = "button" } = props;
29
+ let additionalProps;
30
+ if (elementType === "button") additionalProps = {
31
+ type: type,
32
+ disabled: isDisabled
33
+ };
34
+ else additionalProps = {
35
+ role: "button",
36
+ tabIndex: isDisabled ? undefined : 0,
37
+ href: elementType === "a" && isDisabled ? undefined : href,
38
+ target: elementType === "a" ? target : undefined,
39
+ type: elementType === "input" ? type : undefined,
40
+ disabled: elementType === "input" ? isDisabled : undefined,
41
+ "aria-disabled": !isDisabled || elementType === "input" ? undefined : isDisabled,
42
+ rel: elementType === "a" ? rel : undefined
43
+ };
44
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $lIlxZ$reactariainteractions.usePress)({
45
+ onPressStart: onPressStart,
46
+ onPressEnd: onPressEnd,
47
+ onPressChange: onPressChange,
48
+ onPress: onPress,
49
+ onPressUp: onPressUp,
50
+ isDisabled: isDisabled,
51
+ preventFocusOnPress: preventFocusOnPress,
52
+ ref: ref
53
+ });
54
+ let { focusableProps: focusableProps } = (0, $lIlxZ$reactariafocus.useFocusable)(props, ref);
55
+ if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
56
+ let buttonProps = (0, $lIlxZ$reactariautils.mergeProps)(focusableProps, pressProps, (0, $lIlxZ$reactariautils.filterDOMProps)(props, {
57
+ labelable: true
58
+ }));
59
+ return {
60
+ isPressed: isPressed,
61
+ buttonProps: (0, $lIlxZ$reactariautils.mergeProps)(additionalProps, buttonProps, {
62
+ "aria-haspopup": props["aria-haspopup"],
63
+ "aria-expanded": props["aria-expanded"],
64
+ "aria-controls": props["aria-controls"],
65
+ "aria-pressed": props["aria-pressed"],
66
+ onClick: (e)=>{
67
+ if (deprecatedOnClick) {
68
+ deprecatedOnClick(e);
69
+ console.warn("onClick is deprecated, please use onPress");
70
+ }
71
+ }
72
+ })
73
+ };
74
+ }
75
+
76
+
77
+ //# sourceMappingURL=useButton.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAsCM,SAAS,0CAAU,KAAqC,EAAE,GAAmB;IAClF,IAAI,eACF,cAAc,sBACd,UAAU,WACV,OAAO,gBACP,YAAY,cACZ,UAAU,aACV,SAAS,iBACT,aAAa,uBACb,4BAA4B;IAC5B,mBAAmB,0BACnB,4BAA4B;IAC5B,sBAAsB,EACtB,aAAa;IACb,SAAS,iBAAiB,QAC1B,IAAI,UACJ,MAAM,OACN,GAAG,QACH,OAAO,UACR,GAAG;IACJ,IAAI;IACJ,IAAI,gBAAgB,UAClB,kBAAkB;cAChB;QACA,UAAU;IACZ;SAEA,kBAAkB;QAChB,MAAM;QACN,UAAU,aAAa,YAAY;QACnC,MAAM,gBAAgB,OAAO,aAAa,YAAY;QACtD,QAAQ,gBAAgB,MAAM,SAAS;QACvC,MAAM,gBAAgB,UAAU,OAAO;QACvC,UAAU,gBAAgB,UAAU,aAAa;QACjD,iBAAiB,CAAC,cAAc,gBAAgB,UAAU,YAAY;QACtE,KAAK,gBAAgB,MAAM,MAAM;IACnC;IAGF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;sBACrC;oBACA;uBACA;iBACA;mBACA;oBACA;6BACA;aACA;IACF;IAEA,IAAI,kBAAC,cAAc,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,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAE/F,OAAO;mBACL;QACA,aAAa,CAAA,GAAA,gCAAS,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;gBACR,IAAI,mBAAmB;oBACrB,kBAAkB;oBAClB,QAAQ,IAAI,CAAC;gBACf;YACF;QACF;IACF;AACF","sources":["packages/@react-aria/button/src/useButton.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 {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface AriaButtonOptions<E extends ElementType> extends Omit<AriaButtonProps<E>, 'children'> {}\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: AriaButtonOptions<'button'>, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useButton(props: AriaButtonOptions<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonOptions<'div'>, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useButton(props: AriaButtonOptions<'input'>, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useButton(props: AriaButtonOptions<'span'>, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useButton(props: AriaButtonOptions<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: AriaButtonOptions<ElementType>, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {\n let {\n elementType = 'button',\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressUp,\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 onPressUp,\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"],"names":[],"version":3,"file":"useButton.main.js.map"}
@@ -0,0 +1,72 @@
1
+ import {mergeProps as $bwqiF$mergeProps, filterDOMProps as $bwqiF$filterDOMProps} from "@react-aria/utils";
2
+ import {useFocusable as $bwqiF$useFocusable} from "@react-aria/focus";
3
+ import {usePress as $bwqiF$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
+
17
+
18
+ function $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
19
+ let { elementType: elementType = "button", isDisabled: isDisabled, onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressUp: onPressUp, onPressChange: onPressChange, preventFocusOnPress: // @ts-ignore - undocumented
20
+ preventFocusOnPress, allowFocusWhenDisabled: // @ts-ignore - undocumented
21
+ allowFocusWhenDisabled, // @ts-ignore
22
+ onClick: deprecatedOnClick, href: href, target: target, rel: rel, type: type = "button" } = props;
23
+ let additionalProps;
24
+ if (elementType === "button") additionalProps = {
25
+ type: type,
26
+ disabled: isDisabled
27
+ };
28
+ else additionalProps = {
29
+ role: "button",
30
+ tabIndex: isDisabled ? undefined : 0,
31
+ href: elementType === "a" && isDisabled ? undefined : href,
32
+ target: elementType === "a" ? target : undefined,
33
+ type: elementType === "input" ? type : undefined,
34
+ disabled: elementType === "input" ? isDisabled : undefined,
35
+ "aria-disabled": !isDisabled || elementType === "input" ? undefined : isDisabled,
36
+ rel: elementType === "a" ? rel : undefined
37
+ };
38
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $bwqiF$usePress)({
39
+ onPressStart: onPressStart,
40
+ onPressEnd: onPressEnd,
41
+ onPressChange: onPressChange,
42
+ onPress: onPress,
43
+ onPressUp: onPressUp,
44
+ isDisabled: isDisabled,
45
+ preventFocusOnPress: preventFocusOnPress,
46
+ ref: ref
47
+ });
48
+ let { focusableProps: focusableProps } = (0, $bwqiF$useFocusable)(props, ref);
49
+ if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
50
+ let buttonProps = (0, $bwqiF$mergeProps)(focusableProps, pressProps, (0, $bwqiF$filterDOMProps)(props, {
51
+ labelable: true
52
+ }));
53
+ return {
54
+ isPressed: isPressed,
55
+ buttonProps: (0, $bwqiF$mergeProps)(additionalProps, buttonProps, {
56
+ "aria-haspopup": props["aria-haspopup"],
57
+ "aria-expanded": props["aria-expanded"],
58
+ "aria-controls": props["aria-controls"],
59
+ "aria-pressed": props["aria-pressed"],
60
+ onClick: (e)=>{
61
+ if (deprecatedOnClick) {
62
+ deprecatedOnClick(e);
63
+ console.warn("onClick is deprecated, please use onPress");
64
+ }
65
+ }
66
+ })
67
+ };
68
+ }
69
+
70
+
71
+ export {$701a24aa0da5b062$export$ea18c227d4417cc3 as useButton};
72
+ //# sourceMappingURL=useButton.mjs.map
@@ -0,0 +1,72 @@
1
+ import {mergeProps as $bwqiF$mergeProps, filterDOMProps as $bwqiF$filterDOMProps} from "@react-aria/utils";
2
+ import {useFocusable as $bwqiF$useFocusable} from "@react-aria/focus";
3
+ import {usePress as $bwqiF$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
+
17
+
18
+ function $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
19
+ let { elementType: elementType = "button", isDisabled: isDisabled, onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressUp: onPressUp, onPressChange: onPressChange, preventFocusOnPress: // @ts-ignore - undocumented
20
+ preventFocusOnPress, allowFocusWhenDisabled: // @ts-ignore - undocumented
21
+ allowFocusWhenDisabled, // @ts-ignore
22
+ onClick: deprecatedOnClick, href: href, target: target, rel: rel, type: type = "button" } = props;
23
+ let additionalProps;
24
+ if (elementType === "button") additionalProps = {
25
+ type: type,
26
+ disabled: isDisabled
27
+ };
28
+ else additionalProps = {
29
+ role: "button",
30
+ tabIndex: isDisabled ? undefined : 0,
31
+ href: elementType === "a" && isDisabled ? undefined : href,
32
+ target: elementType === "a" ? target : undefined,
33
+ type: elementType === "input" ? type : undefined,
34
+ disabled: elementType === "input" ? isDisabled : undefined,
35
+ "aria-disabled": !isDisabled || elementType === "input" ? undefined : isDisabled,
36
+ rel: elementType === "a" ? rel : undefined
37
+ };
38
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $bwqiF$usePress)({
39
+ onPressStart: onPressStart,
40
+ onPressEnd: onPressEnd,
41
+ onPressChange: onPressChange,
42
+ onPress: onPress,
43
+ onPressUp: onPressUp,
44
+ isDisabled: isDisabled,
45
+ preventFocusOnPress: preventFocusOnPress,
46
+ ref: ref
47
+ });
48
+ let { focusableProps: focusableProps } = (0, $bwqiF$useFocusable)(props, ref);
49
+ if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
50
+ let buttonProps = (0, $bwqiF$mergeProps)(focusableProps, pressProps, (0, $bwqiF$filterDOMProps)(props, {
51
+ labelable: true
52
+ }));
53
+ return {
54
+ isPressed: isPressed,
55
+ buttonProps: (0, $bwqiF$mergeProps)(additionalProps, buttonProps, {
56
+ "aria-haspopup": props["aria-haspopup"],
57
+ "aria-expanded": props["aria-expanded"],
58
+ "aria-controls": props["aria-controls"],
59
+ "aria-pressed": props["aria-pressed"],
60
+ onClick: (e)=>{
61
+ if (deprecatedOnClick) {
62
+ deprecatedOnClick(e);
63
+ console.warn("onClick is deprecated, please use onPress");
64
+ }
65
+ }
66
+ })
67
+ };
68
+ }
69
+
70
+
71
+ export {$701a24aa0da5b062$export$ea18c227d4417cc3 as useButton};
72
+ //# sourceMappingURL=useButton.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAsCM,SAAS,0CAAU,KAAqC,EAAE,GAAmB;IAClF,IAAI,eACF,cAAc,sBACd,UAAU,WACV,OAAO,gBACP,YAAY,cACZ,UAAU,aACV,SAAS,iBACT,aAAa,uBACb,4BAA4B;IAC5B,mBAAmB,0BACnB,4BAA4B;IAC5B,sBAAsB,EACtB,aAAa;IACb,SAAS,iBAAiB,QAC1B,IAAI,UACJ,MAAM,OACN,GAAG,QACH,OAAO,UACR,GAAG;IACJ,IAAI;IACJ,IAAI,gBAAgB,UAClB,kBAAkB;cAChB;QACA,UAAU;IACZ;SAEA,kBAAkB;QAChB,MAAM;QACN,UAAU,aAAa,YAAY;QACnC,MAAM,gBAAgB,OAAO,aAAa,YAAY;QACtD,QAAQ,gBAAgB,MAAM,SAAS;QACvC,MAAM,gBAAgB,UAAU,OAAO;QACvC,UAAU,gBAAgB,UAAU,aAAa;QACjD,iBAAiB,CAAC,cAAc,gBAAgB,UAAU,YAAY;QACtE,KAAK,gBAAgB,MAAM,MAAM;IACnC;IAGF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;sBACrC;oBACA;uBACA;iBACA;mBACA;oBACA;6BACA;aACA;IACF;IAEA,IAAI,kBAAC,cAAc,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,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAE/F,OAAO;mBACL;QACA,aAAa,CAAA,GAAA,iBAAS,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;gBACR,IAAI,mBAAmB;oBACrB,kBAAkB;oBAClB,QAAQ,IAAI,CAAC;gBACf;YACF;QACF;IACF;AACF","sources":["packages/@react-aria/button/src/useButton.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 {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface AriaButtonOptions<E extends ElementType> extends Omit<AriaButtonProps<E>, 'children'> {}\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: AriaButtonOptions<'button'>, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useButton(props: AriaButtonOptions<'a'>, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonOptions<'div'>, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useButton(props: AriaButtonOptions<'input'>, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useButton(props: AriaButtonOptions<'span'>, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useButton(props: AriaButtonOptions<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: AriaButtonOptions<ElementType>, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {\n let {\n elementType = 'button',\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressUp,\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 onPressUp,\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"],"names":[],"version":3,"file":"useButton.module.js.map"}
@@ -0,0 +1,37 @@
1
+ var $988353faa005faf8$exports = require("./useButton.main.js");
2
+ var $4M9F2$reactariautils = require("@react-aria/utils");
3
+
4
+
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
+ }
8
+
9
+ $parcel$export(module.exports, "useToggleButton", () => $c49208f7d2aac50b$export$51e84d46ca0bc451);
10
+ /*
11
+ * Copyright 2020 Adobe. All rights reserved.
12
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License. You may obtain a copy
14
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software distributed under
17
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
+ * OF ANY KIND, either express or implied. See the License for the specific language
19
+ * governing permissions and limitations under the License.
20
+ */
21
+
22
+ function $c49208f7d2aac50b$export$51e84d46ca0bc451(props, state, ref) {
23
+ const { isSelected: isSelected } = state;
24
+ const { isPressed: isPressed, buttonProps: buttonProps } = (0, $988353faa005faf8$exports.useButton)({
25
+ ...props,
26
+ onPress: (0, $4M9F2$reactariautils.chain)(state.toggle, props.onPress)
27
+ }, ref);
28
+ return {
29
+ isPressed: isPressed,
30
+ buttonProps: (0, $4M9F2$reactariautils.mergeProps)(buttonProps, {
31
+ "aria-pressed": isSelected
32
+ })
33
+ };
34
+ }
35
+
36
+
37
+ //# sourceMappingURL=useToggleButton.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AA6BM,SAAS,0CAAgB,KAA2C,EAAE,KAAkB,EAAE,GAAmB;IAClH,MAAM,cAAC,UAAU,EAAC,GAAG;IACrB,MAAM,aAAC,SAAS,eAAE,WAAW,EAAC,GAAG,CAAA,GAAA,mCAAQ,EAAE;QACzC,GAAG,KAAK;QACR,SAAS,CAAA,GAAA,2BAAI,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO;IAC5C,GAAG;IAEH,OAAO;mBACL;QACA,aAAa,CAAA,GAAA,gCAAS,EAAE,aAAa;YACnC,gBAAgB;QAClB;IACF;AACF","sources":["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 {AriaToggleButtonProps} from '@react-types/button';\nimport {ButtonAria, useButton} from './useButton';\nimport {chain, mergeProps} from '@react-aria/utils';\nimport {DOMAttributes} from '@react-types/shared';\nimport {ToggleState} from '@react-stately/toggle';\n\nexport interface AriaToggleButtonOptions<E extends ElementType> extends Omit<AriaToggleButtonProps<E>, 'children'> {}\n\n// Order with overrides is important: 'button' should be default\nexport function useToggleButton(props: AriaToggleButtonOptions<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<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: AriaToggleButtonOptions<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":"useToggleButton.main.js.map"}
@@ -0,0 +1,32 @@
1
+ import {useButton as $701a24aa0da5b062$export$ea18c227d4417cc3} from "./useButton.mjs";
2
+ import {chain as $h7Tql$chain, mergeProps as $h7Tql$mergeProps} from "@react-aria/utils";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ function $55f54f7887471b58$export$51e84d46ca0bc451(props, state, ref) {
17
+ const { isSelected: isSelected } = state;
18
+ const { isPressed: isPressed, buttonProps: buttonProps } = (0, $701a24aa0da5b062$export$ea18c227d4417cc3)({
19
+ ...props,
20
+ onPress: (0, $h7Tql$chain)(state.toggle, props.onPress)
21
+ }, ref);
22
+ return {
23
+ isPressed: isPressed,
24
+ buttonProps: (0, $h7Tql$mergeProps)(buttonProps, {
25
+ "aria-pressed": isSelected
26
+ })
27
+ };
28
+ }
29
+
30
+
31
+ export {$55f54f7887471b58$export$51e84d46ca0bc451 as useToggleButton};
32
+ //# sourceMappingURL=useToggleButton.mjs.map
@@ -0,0 +1,32 @@
1
+ import {useButton as $701a24aa0da5b062$export$ea18c227d4417cc3} from "./useButton.module.js";
2
+ import {chain as $h7Tql$chain, mergeProps as $h7Tql$mergeProps} from "@react-aria/utils";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ function $55f54f7887471b58$export$51e84d46ca0bc451(props, state, ref) {
17
+ const { isSelected: isSelected } = state;
18
+ const { isPressed: isPressed, buttonProps: buttonProps } = (0, $701a24aa0da5b062$export$ea18c227d4417cc3)({
19
+ ...props,
20
+ onPress: (0, $h7Tql$chain)(state.toggle, props.onPress)
21
+ }, ref);
22
+ return {
23
+ isPressed: isPressed,
24
+ buttonProps: (0, $h7Tql$mergeProps)(buttonProps, {
25
+ "aria-pressed": isSelected
26
+ })
27
+ };
28
+ }
29
+
30
+
31
+ export {$55f54f7887471b58$export$51e84d46ca0bc451 as useToggleButton};
32
+ //# sourceMappingURL=useToggleButton.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AA6BM,SAAS,0CAAgB,KAA2C,EAAE,KAAkB,EAAE,GAAmB;IAClH,MAAM,cAAC,UAAU,EAAC,GAAG;IACrB,MAAM,aAAC,SAAS,eAAE,WAAW,EAAC,GAAG,CAAA,GAAA,yCAAQ,EAAE;QACzC,GAAG,KAAK;QACR,SAAS,CAAA,GAAA,YAAI,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO;IAC5C,GAAG;IAEH,OAAO;mBACL;QACA,aAAa,CAAA,GAAA,iBAAS,EAAE,aAAa;YACnC,gBAAgB;QAClB;IACF;AACF","sources":["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 {AriaToggleButtonProps} from '@react-types/button';\nimport {ButtonAria, useButton} from './useButton';\nimport {chain, mergeProps} from '@react-aria/utils';\nimport {DOMAttributes} from '@react-types/shared';\nimport {ToggleState} from '@react-stately/toggle';\n\nexport interface AriaToggleButtonOptions<E extends ElementType> extends Omit<AriaToggleButtonProps<E>, 'children'> {}\n\n// Order with overrides is important: 'button' should be default\nexport function useToggleButton(props: AriaToggleButtonOptions<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<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: AriaToggleButtonOptions<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":"useToggleButton.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/button",
3
- "version": "3.9.2",
3
+ "version": "3.9.4",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,12 +22,12 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/focus": "^3.16.1",
26
- "@react-aria/interactions": "^3.21.0",
27
- "@react-aria/utils": "^3.23.1",
28
- "@react-stately/toggle": "^3.7.1",
29
- "@react-types/button": "^3.9.1",
30
- "@react-types/shared": "^3.22.0",
25
+ "@react-aria/focus": "^3.17.0",
26
+ "@react-aria/interactions": "^3.21.2",
27
+ "@react-aria/utils": "^3.24.0",
28
+ "@react-stately/toggle": "^3.7.3",
29
+ "@react-types/button": "^3.9.3",
30
+ "@react-types/shared": "^3.23.0",
31
31
  "@swc/helpers": "^0.5.0"
32
32
  },
33
33
  "peerDependencies": {
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "f040ff62678e6a31375b96c05396df0bae660350"
39
+ "gitHead": "f645f29edc1322153fd60af4640cbcab1d992dbd"
40
40
  }