@react-aria/button 3.14.5 → 3.15.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/import.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import {useButton as $701a24aa0da5b062$export$ea18c227d4417cc3} from "./useButton.mjs";
2
- import {useToggleButton as $55f54f7887471b58$export$51e84d46ca0bc451} from "./useToggleButton.mjs";
3
- import {useToggleButtonGroup as $4547d1bf40011fdf$export$dd5580ae642f110f, useToggleButtonGroupItem as $4547d1bf40011fdf$export$bc53712daae3d6e6} from "./useToggleButtonGroup.mjs";
1
+ import {useButton as $9101daa4035271dc$re_export$useButton} from "react-aria/useButton";
2
+ import {useToggleButton as $9101daa4035271dc$re_export$useToggleButton} from "react-aria/useToggleButton";
3
+ import {useToggleButtonGroup as $9101daa4035271dc$re_export$useToggleButtonGroup, useToggleButtonGroupItem as $9101daa4035271dc$re_export$useToggleButtonGroupItem} from "react-aria/useToggleButtonGroup";
4
4
 
5
5
  /*
6
6
  * Copyright 2020 Adobe. All rights reserved.
@@ -17,5 +17,5 @@ import {useToggleButtonGroup as $4547d1bf40011fdf$export$dd5580ae642f110f, useTo
17
17
 
18
18
 
19
19
 
20
- export {$701a24aa0da5b062$export$ea18c227d4417cc3 as useButton, $55f54f7887471b58$export$51e84d46ca0bc451 as useToggleButton, $4547d1bf40011fdf$export$dd5580ae642f110f as useToggleButtonGroup, $4547d1bf40011fdf$export$bc53712daae3d6e6 as useToggleButtonGroupItem};
20
+ export {$9101daa4035271dc$re_export$useButton as useButton, $9101daa4035271dc$re_export$useToggleButton as useToggleButton, $9101daa4035271dc$re_export$useToggleButtonGroup as useToggleButtonGroup, $9101daa4035271dc$re_export$useToggleButtonGroupItem as useToggleButtonGroupItem};
21
21
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,16 +1,16 @@
1
- var $988353faa005faf8$exports = require("./useButton.main.js");
2
- var $c49208f7d2aac50b$exports = require("./useToggleButton.main.js");
3
- var $7d1e6c2af0d638cd$exports = require("./useToggleButtonGroup.main.js");
1
+ var $awYPH$reactariauseButton = require("react-aria/useButton");
2
+ var $awYPH$reactariauseToggleButton = require("react-aria/useToggleButton");
3
+ var $awYPH$reactariauseToggleButtonGroup = require("react-aria/useToggleButtonGroup");
4
4
 
5
5
 
6
6
  function $parcel$export(e, n, v, s) {
7
7
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
8
  }
9
9
 
10
- $parcel$export(module.exports, "useButton", () => $988353faa005faf8$exports.useButton);
11
- $parcel$export(module.exports, "useToggleButton", () => $c49208f7d2aac50b$exports.useToggleButton);
12
- $parcel$export(module.exports, "useToggleButtonGroup", () => $7d1e6c2af0d638cd$exports.useToggleButtonGroup);
13
- $parcel$export(module.exports, "useToggleButtonGroupItem", () => $7d1e6c2af0d638cd$exports.useToggleButtonGroupItem);
10
+ $parcel$export(module.exports, "useButton", function () { return $awYPH$reactariauseButton.useButton; });
11
+ $parcel$export(module.exports, "useToggleButton", function () { return $awYPH$reactariauseToggleButton.useToggleButton; });
12
+ $parcel$export(module.exports, "useToggleButtonGroup", function () { return $awYPH$reactariauseToggleButtonGroup.useToggleButtonGroup; });
13
+ $parcel$export(module.exports, "useToggleButtonGroupItem", function () { return $awYPH$reactariauseToggleButtonGroup.useToggleButtonGroupItem; });
14
14
  /*
15
15
  * Copyright 2020 Adobe. All rights reserved.
16
16
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
package/dist/main.js.map CHANGED
@@ -1 +1 @@
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 {useToggleButtonGroup, useToggleButtonGroupItem} from './useToggleButtonGroup';\nexport type {AriaButtonOptions, ButtonAria} from './useButton';\nexport type {AriaButtonProps, AriaToggleButtonProps} from '@react-types/button';\nexport type {AriaToggleButtonGroupProps, ToggleButtonGroupAria, AriaToggleButtonGroupItemProps} from './useToggleButtonGroup';\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 'react-aria/useButton';\n\nexport {useToggleButton} from 'react-aria/useToggleButton';\nexport {useToggleButtonGroup, useToggleButtonGroupItem} from 'react-aria/useToggleButtonGroup';\nexport type {ButtonProps, LinkButtonProps, AriaBaseButtonProps, AriaButtonProps, AriaButtonOptions, ButtonAria} from 'react-aria/useButton';\nexport type {ToggleButtonProps, AriaToggleButtonProps, AriaToggleButtonOptions, ToggleButtonAria} from 'react-aria/useToggleButton';\nexport type {AriaToggleButtonGroupProps, ToggleButtonGroupAria, AriaToggleButtonGroupItemProps, AriaToggleButtonGroupItemOptions} from 'react-aria/useToggleButtonGroup';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,6 +1,6 @@
1
- import {useButton as $701a24aa0da5b062$export$ea18c227d4417cc3} from "./useButton.module.js";
2
- import {useToggleButton as $55f54f7887471b58$export$51e84d46ca0bc451} from "./useToggleButton.module.js";
3
- import {useToggleButtonGroup as $4547d1bf40011fdf$export$dd5580ae642f110f, useToggleButtonGroupItem as $4547d1bf40011fdf$export$bc53712daae3d6e6} from "./useToggleButtonGroup.module.js";
1
+ import {useButton as $9101daa4035271dc$re_export$useButton} from "react-aria/useButton";
2
+ import {useToggleButton as $9101daa4035271dc$re_export$useToggleButton} from "react-aria/useToggleButton";
3
+ import {useToggleButtonGroup as $9101daa4035271dc$re_export$useToggleButtonGroup, useToggleButtonGroupItem as $9101daa4035271dc$re_export$useToggleButtonGroupItem} from "react-aria/useToggleButtonGroup";
4
4
 
5
5
  /*
6
6
  * Copyright 2020 Adobe. All rights reserved.
@@ -17,5 +17,5 @@ import {useToggleButtonGroup as $4547d1bf40011fdf$export$dd5580ae642f110f, useTo
17
17
 
18
18
 
19
19
 
20
- export {$701a24aa0da5b062$export$ea18c227d4417cc3 as useButton, $55f54f7887471b58$export$51e84d46ca0bc451 as useToggleButton, $4547d1bf40011fdf$export$dd5580ae642f110f as useToggleButtonGroup, $4547d1bf40011fdf$export$bc53712daae3d6e6 as useToggleButtonGroupItem};
20
+ export {$9101daa4035271dc$re_export$useButton as useButton, $9101daa4035271dc$re_export$useToggleButton as useToggleButton, $9101daa4035271dc$re_export$useToggleButtonGroup as useToggleButtonGroup, $9101daa4035271dc$re_export$useToggleButtonGroupItem as useToggleButtonGroupItem};
21
21
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
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 {useToggleButtonGroup, useToggleButtonGroupItem} from './useToggleButtonGroup';\nexport type {AriaButtonOptions, ButtonAria} from './useButton';\nexport type {AriaButtonProps, AriaToggleButtonProps} from '@react-types/button';\nexport type {AriaToggleButtonGroupProps, ToggleButtonGroupAria, AriaToggleButtonGroupItemProps} from './useToggleButtonGroup';\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 'react-aria/useButton';\n\nexport {useToggleButton} from 'react-aria/useToggleButton';\nexport {useToggleButtonGroup, useToggleButtonGroupItem} from 'react-aria/useToggleButtonGroup';\nexport type {ButtonProps, LinkButtonProps, AriaBaseButtonProps, AriaButtonProps, AriaButtonOptions, ButtonAria} from 'react-aria/useButton';\nexport type {ToggleButtonProps, AriaToggleButtonProps, AriaToggleButtonOptions, ToggleButtonAria} from 'react-aria/useToggleButton';\nexport type {AriaToggleButtonGroupProps, ToggleButtonGroupAria, AriaToggleButtonGroupItemProps, AriaToggleButtonGroupItemOptions} from 'react-aria/useToggleButtonGroup';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,6 @@
1
+ export { useButton } from 'react-aria/useButton';
2
+ export { useToggleButton } from 'react-aria/useToggleButton';
3
+ export { useToggleButtonGroup, useToggleButtonGroupItem } from 'react-aria/useToggleButtonGroup';
4
+ export type { ButtonProps, LinkButtonProps, AriaBaseButtonProps, AriaButtonProps, AriaButtonOptions, ButtonAria } from 'react-aria/useButton';
5
+ export type { ToggleButtonProps, AriaToggleButtonProps, AriaToggleButtonOptions, ToggleButtonAria } from 'react-aria/useToggleButton';
6
+ export type { AriaToggleButtonGroupProps, ToggleButtonGroupAria, AriaToggleButtonGroupItemProps, AriaToggleButtonGroupItemOptions } from 'react-aria/useToggleButtonGroup';
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@react-aria/button",
3
- "version": "3.14.5",
3
+ "version": "3.15.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
8
  "exports": {
9
- "source": "./src/index.ts",
10
- "types": [
11
- "./dist/types.d.ts",
12
- "./src/index.ts"
13
- ],
14
- "import": "./dist/import.mjs",
15
- "require": "./dist/main.js"
9
+ ".": {
10
+ "source": "./src/index.ts",
11
+ "types": "./dist/types/src/index.d.ts",
12
+ "import": "./dist/import.mjs",
13
+ "require": "./dist/main.js"
14
+ },
15
+ "./package.json": "./package.json"
16
16
  },
17
- "types": "dist/types.d.ts",
17
+ "types": "dist/types/src/index.d.ts",
18
18
  "source": "src/index.ts",
19
19
  "files": [
20
20
  "dist",
@@ -26,13 +26,8 @@
26
26
  "url": "https://github.com/adobe/react-spectrum"
27
27
  },
28
28
  "dependencies": {
29
- "@react-aria/interactions": "^3.27.1",
30
- "@react-aria/toolbar": "3.0.0-beta.24",
31
- "@react-aria/utils": "^3.33.1",
32
- "@react-stately/toggle": "^3.9.5",
33
- "@react-types/button": "^3.15.1",
34
- "@react-types/shared": "^3.33.1",
35
- "@swc/helpers": "^0.5.0"
29
+ "@swc/helpers": "^0.5.0",
30
+ "react-aria": "3.48.0"
36
31
  },
37
32
  "peerDependencies": {
38
33
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
@@ -41,5 +36,8 @@
41
36
  "publishConfig": {
42
37
  "access": "public"
43
38
  },
44
- "gitHead": "8df187370053aa35f553cb388ad670f65e1ab371"
39
+ "targets": {
40
+ "types": false
41
+ },
42
+ "gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
45
43
  }
package/src/index.ts CHANGED
@@ -9,9 +9,10 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- export {useButton} from './useButton';
13
- export {useToggleButton} from './useToggleButton';
14
- export {useToggleButtonGroup, useToggleButtonGroupItem} from './useToggleButtonGroup';
15
- export type {AriaButtonOptions, ButtonAria} from './useButton';
16
- export type {AriaButtonProps, AriaToggleButtonProps} from '@react-types/button';
17
- export type {AriaToggleButtonGroupProps, ToggleButtonGroupAria, AriaToggleButtonGroupItemProps} from './useToggleButtonGroup';
12
+ export {useButton} from 'react-aria/useButton';
13
+
14
+ export {useToggleButton} from 'react-aria/useToggleButton';
15
+ export {useToggleButtonGroup, useToggleButtonGroupItem} from 'react-aria/useToggleButtonGroup';
16
+ export type {ButtonProps, LinkButtonProps, AriaBaseButtonProps, AriaButtonProps, AriaButtonOptions, ButtonAria} from 'react-aria/useButton';
17
+ export type {ToggleButtonProps, AriaToggleButtonProps, AriaToggleButtonOptions, ToggleButtonAria} from 'react-aria/useToggleButton';
18
+ export type {AriaToggleButtonGroupProps, ToggleButtonGroupAria, AriaToggleButtonGroupItemProps, AriaToggleButtonGroupItemOptions} from 'react-aria/useToggleButtonGroup';
package/dist/types.d.ts DELETED
@@ -1,58 +0,0 @@
1
- import { AnchorHTMLAttributes, ButtonHTMLAttributes, ElementType, HTMLAttributes, InputHTMLAttributes, RefObject } from "react";
2
- import { AriaButtonProps, AriaToggleButtonProps, AriaToggleButtonGroupItemProps } from "@react-types/button";
3
- import { DOMAttributes, AriaLabelingProps, Orientation, RefObject as _RefObject1 } from "@react-types/shared";
4
- import { ToggleState, ToggleGroupProps, ToggleGroupState } from "@react-stately/toggle";
5
- export interface AriaButtonOptions<E extends ElementType> extends Omit<AriaButtonProps<E>, 'children'> {
6
- }
7
- export interface ButtonAria<T> {
8
- /** Props for the button element. */
9
- buttonProps: T;
10
- /** Whether the button is currently pressed. */
11
- isPressed: boolean;
12
- }
13
- export function useButton(props: AriaButtonOptions<'button'>, ref: RefObject<HTMLButtonElement | null>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;
14
- export function useButton(props: AriaButtonOptions<'a'>, ref: RefObject<HTMLAnchorElement | null>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
15
- export function useButton(props: AriaButtonOptions<'div'>, ref: RefObject<HTMLDivElement | null>): ButtonAria<HTMLAttributes<HTMLDivElement>>;
16
- export function useButton(props: AriaButtonOptions<'input'>, ref: RefObject<HTMLInputElement | null>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;
17
- export function useButton(props: AriaButtonOptions<'span'>, ref: RefObject<HTMLSpanElement | null>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;
18
- export function useButton(props: AriaButtonOptions<ElementType>, ref: RefObject<Element | null>): ButtonAria<DOMAttributes>;
19
- interface AriaToggleButtonOptions<E extends ElementType> extends Omit<AriaToggleButtonProps<E>, 'children'> {
20
- }
21
- interface ToggleButtonAria<T> extends ButtonAria<T> {
22
- /** Whether the button is selected. */
23
- isSelected: boolean;
24
- /** Whether the button is disabled. */
25
- isDisabled: boolean;
26
- }
27
- export function useToggleButton(props: AriaToggleButtonOptions<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement | null>): ToggleButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;
28
- export function useToggleButton(props: AriaToggleButtonOptions<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement | null>): ToggleButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
29
- export function useToggleButton(props: AriaToggleButtonOptions<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement | null>): ToggleButtonAria<HTMLAttributes<HTMLDivElement>>;
30
- export function useToggleButton(props: AriaToggleButtonOptions<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement | null>): ToggleButtonAria<InputHTMLAttributes<HTMLInputElement>>;
31
- export function useToggleButton(props: AriaToggleButtonOptions<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement | null>): ToggleButtonAria<HTMLAttributes<HTMLSpanElement>>;
32
- export function useToggleButton(props: AriaToggleButtonOptions<ElementType>, state: ToggleState, ref: RefObject<Element | null>): ToggleButtonAria<DOMAttributes>;
33
- export interface AriaToggleButtonGroupProps extends ToggleGroupProps, AriaLabelingProps {
34
- /**
35
- * The orientation of the the toggle button group.
36
- * @default 'horizontal'
37
- */
38
- orientation?: Orientation;
39
- }
40
- export interface ToggleButtonGroupAria {
41
- /**
42
- * Props for the toggle button group container.
43
- */
44
- groupProps: DOMAttributes;
45
- }
46
- export function useToggleButtonGroup(props: AriaToggleButtonGroupProps, state: ToggleGroupState, ref: _RefObject1<HTMLElement | null>): ToggleButtonGroupAria;
47
- export { AriaToggleButtonGroupItemProps };
48
- interface AriaToggleButtonGroupItemOptions<E extends ElementType> extends Omit<AriaToggleButtonGroupItemProps<E>, 'children'> {
49
- }
50
- export function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'button'>, state: ToggleGroupState, ref: _RefObject1<HTMLButtonElement | null>): ToggleButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;
51
- export function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'a'>, state: ToggleGroupState, ref: _RefObject1<HTMLAnchorElement | null>): ToggleButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
52
- export function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'div'>, state: ToggleGroupState, ref: _RefObject1<HTMLDivElement | null>): ToggleButtonAria<HTMLAttributes<HTMLDivElement>>;
53
- export function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'input'>, state: ToggleGroupState, ref: _RefObject1<HTMLInputElement | null>): ToggleButtonAria<InputHTMLAttributes<HTMLInputElement>>;
54
- export function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'span'>, state: ToggleGroupState, ref: _RefObject1<HTMLSpanElement | null>): ToggleButtonAria<HTMLAttributes<HTMLSpanElement>>;
55
- export function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<ElementType>, state: ToggleGroupState, ref: _RefObject1<Element | null>): ToggleButtonAria<DOMAttributes>;
56
- export type { AriaButtonProps, AriaToggleButtonProps } from '@react-types/button';
57
-
58
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;AAyBA,mCAAmC,CAAC,SAAS,WAAW,CAAE,SAAQ,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,UAAU,CAAC;CAAG;AAEzG,4BAA4B,CAAC;IAC3B,oCAAoC;IACpC,WAAW,EAAE,CAAC,CAAC;IACf,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAA;CACnB;AAGD,0BAA0B,KAAK,EAAE,kBAAkB,QAAQ,CAAC,EAAE,GAAG,EAAE,UAAU,iBAAiB,GAAG,IAAI,CAAC,GAAG,WAAW,qBAAqB,iBAAiB,CAAC,CAAC,CAAC;AAC7J,0BAA0B,KAAK,EAAE,kBAAkB,GAAG,CAAC,EAAE,GAAG,EAAE,UAAU,iBAAiB,GAAG,IAAI,CAAC,GAAG,WAAW,qBAAqB,iBAAiB,CAAC,CAAC,CAAC;AACxJ,0BAA0B,KAAK,EAAE,kBAAkB,KAAK,CAAC,EAAE,GAAG,EAAE,UAAU,cAAc,GAAG,IAAI,CAAC,GAAG,WAAW,eAAe,cAAc,CAAC,CAAC,CAAC;AAC9I,0BAA0B,KAAK,EAAE,kBAAkB,OAAO,CAAC,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,WAAW,oBAAoB,gBAAgB,CAAC,CAAC,CAAC;AACzJ,0BAA0B,KAAK,EAAE,kBAAkB,MAAM,CAAC,EAAE,GAAG,EAAE,UAAU,eAAe,GAAG,IAAI,CAAC,GAAG,WAAW,eAAe,eAAe,CAAC,CAAC,CAAC;AACjJ,0BAA0B,KAAK,EAAE,kBAAkB,WAAW,CAAC,EAAE,GAAG,EAAE,UAAU,OAAO,GAAG,IAAI,CAAC,GAAG,WAAW,aAAa,CAAC,CAAC;ACd5H,kCAAyC,CAAC,SAAS,WAAW,CAAE,SAAQ,IAAI,CAAC,sBAAsB,CAAC,CAAC,EAAE,UAAU,CAAC;CAAG;AAErH,2BAAkC,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC;IACxD,sCAAsC;IACtC,UAAU,EAAE,OAAO,CAAC;IACpB,sCAAsC;IACtC,UAAU,EAAE,OAAO,CAAA;CACpB;AAGD,gCAAgC,KAAK,EAAE,wBAAwB,QAAQ,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,iBAAiB,GAAG,IAAI,CAAC,GAAG,iBAAiB,qBAAqB,iBAAiB,CAAC,CAAC,CAAC;AACnM,gCAAgC,KAAK,EAAE,wBAAwB,GAAG,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,iBAAiB,GAAG,IAAI,CAAC,GAAG,iBAAiB,qBAAqB,iBAAiB,CAAC,CAAC,CAAC;AAC9L,gCAAgC,KAAK,EAAE,wBAAwB,KAAK,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,cAAc,GAAG,IAAI,CAAC,GAAG,iBAAiB,eAAe,cAAc,CAAC,CAAC,CAAC;AACpL,gCAAgC,KAAK,EAAE,wBAAwB,OAAO,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,iBAAiB,oBAAoB,gBAAgB,CAAC,CAAC,CAAC;AAC/L,gCAAgC,KAAK,EAAE,wBAAwB,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,eAAe,GAAG,IAAI,CAAC,GAAG,iBAAiB,eAAe,eAAe,CAAC,CAAC,CAAC;AACvL,gCAAgC,KAAK,EAAE,wBAAwB,WAAW,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,OAAO,GAAG,IAAI,CAAC,GAAG,iBAAiB,aAAa,CAAC,CAAC;AChBlK,2CAA4C,SAAQ,gBAAgB,EAAE,iBAAiB;IACrF;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B;AAED;IACE;;OAEG;IACH,UAAU,EAAE,aAAa,CAAA;CAC1B;AAED,qCAAqC,KAAK,EAAE,0BAA0B,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,YAAU,WAAW,GAAG,IAAI,CAAC,GAAG,qBAAqB,CAW1J;AAED,OAAY,EAAC,8BAA8B,EAAC,CAAC;AAC7C,2CAAkD,CAAC,SAAS,WAAW,CAAE,SAAQ,IAAI,CAAC,+BAA+B,CAAC,CAAC,EAAE,UAAU,CAAC;CAAG;AAGvI,yCAAyC,KAAK,EAAE,iCAAiC,QAAQ,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,YAAU,iBAAiB,GAAG,IAAI,CAAC,GAAG,iBAAiB,qBAAqB,iBAAiB,CAAC,CAAC,CAAC;AAC1N,yCAAyC,KAAK,EAAE,iCAAiC,GAAG,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,YAAU,iBAAiB,GAAG,IAAI,CAAC,GAAG,iBAAiB,qBAAqB,iBAAiB,CAAC,CAAC,CAAC;AACrN,yCAAyC,KAAK,EAAE,iCAAiC,KAAK,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,YAAU,cAAc,GAAG,IAAI,CAAC,GAAG,iBAAiB,eAAe,cAAc,CAAC,CAAC,CAAC;AAC3M,yCAAyC,KAAK,EAAE,iCAAiC,OAAO,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,YAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,iBAAiB,oBAAoB,gBAAgB,CAAC,CAAC,CAAC;AACtN,yCAAyC,KAAK,EAAE,iCAAiC,MAAM,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,YAAU,eAAe,GAAG,IAAI,CAAC,GAAG,iBAAiB,eAAe,eAAe,CAAC,CAAC,CAAC;AAC9M,yCAAyC,KAAK,EAAE,iCAAiC,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,YAAU,OAAO,GAAG,IAAI,CAAC,GAAG,iBAAiB,aAAa,CAAC,CAAC;AC/CzL,YAAY,EAAC,eAAe,EAAE,qBAAqB,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/button/src/packages/@react-aria/button/src/useButton.ts","packages/@react-aria/button/src/packages/@react-aria/button/src/useToggleButton.ts","packages/@react-aria/button/src/packages/@react-aria/button/src/useToggleButtonGroup.ts","packages/@react-aria/button/src/packages/@react-aria/button/src/index.ts","packages/@react-aria/button/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useButton} from './useButton';\nexport {useToggleButton} from './useToggleButton';\nexport {useToggleButtonGroup, useToggleButtonGroupItem} from './useToggleButtonGroup';\nexport type {AriaButtonOptions, ButtonAria} from './useButton';\nexport type {AriaButtonProps, AriaToggleButtonProps} from '@react-types/button';\nexport type {AriaToggleButtonGroupProps, ToggleButtonGroupAria, AriaToggleButtonGroupItemProps} from './useToggleButtonGroup';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -1,77 +0,0 @@
1
- var $lIlxZ$reactariautils = require("@react-aria/utils");
2
- var $lIlxZ$reactariainteractions = require("@react-aria/interactions");
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, "useButton", () => $988353faa005faf8$export$ea18c227d4417cc3);
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 $988353faa005faf8$export$ea18c227d4417cc3(props, ref) {
23
- let { elementType: elementType = 'button', isDisabled: isDisabled, onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressUp: onPressUp, onPressChange: onPressChange, preventFocusOnPress: preventFocusOnPress, allowFocusWhenDisabled: // @ts-ignore - undocumented
24
- allowFocusWhenDisabled, onClick: onClick, href: href, target: target, rel: rel, type: type = 'button' } = props;
25
- let additionalProps;
26
- if (elementType === 'button') additionalProps = {
27
- type: type,
28
- disabled: isDisabled,
29
- form: props.form,
30
- formAction: props.formAction,
31
- formEncType: props.formEncType,
32
- formMethod: props.formMethod,
33
- formNoValidate: props.formNoValidate,
34
- formTarget: props.formTarget,
35
- name: props.name,
36
- value: props.value
37
- };
38
- else additionalProps = {
39
- role: 'button',
40
- href: elementType === 'a' && !isDisabled ? href : undefined,
41
- target: elementType === 'a' ? target : undefined,
42
- type: elementType === 'input' ? type : undefined,
43
- disabled: elementType === 'input' ? isDisabled : undefined,
44
- 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,
45
- rel: elementType === 'a' ? rel : undefined
46
- };
47
- let { pressProps: pressProps, isPressed: isPressed } = (0, $lIlxZ$reactariainteractions.usePress)({
48
- onPressStart: onPressStart,
49
- onPressEnd: onPressEnd,
50
- onPressChange: onPressChange,
51
- onPress: onPress,
52
- onPressUp: onPressUp,
53
- onClick: onClick,
54
- isDisabled: isDisabled,
55
- preventFocusOnPress: preventFocusOnPress,
56
- ref: ref
57
- });
58
- let { focusableProps: focusableProps } = (0, $lIlxZ$reactariainteractions.useFocusable)(props, ref);
59
- if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
60
- let buttonProps = (0, $lIlxZ$reactariautils.mergeProps)(focusableProps, pressProps, (0, $lIlxZ$reactariautils.filterDOMProps)(props, {
61
- labelable: true
62
- }));
63
- return {
64
- isPressed: isPressed,
65
- buttonProps: (0, $lIlxZ$reactariautils.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
- 'aria-current': props['aria-current'],
71
- 'aria-disabled': props['aria-disabled']
72
- })
73
- };
74
- }
75
-
76
-
77
- //# sourceMappingURL=useButton.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAqCM,SAAS,0CAAU,KAAqC,EAAE,GAAmB;IAClF,IAAI,eACF,cAAc,sBACd,UAAU,WACV,OAAO,gBACP,YAAY,cACZ,UAAU,aACV,SAAS,iBACT,aAAa,uBACb,mBAAmB,0BACnB,4BAA4B;IAC5B,sBAAsB,WACtB,OAAO,QACP,IAAI,UACJ,MAAM,OACN,GAAG,QACH,OAAO,UACR,GAAG;IACJ,IAAI;IACJ,IAAI,gBAAgB,UAClB,kBAAkB;cAChB;QACA,UAAU;QACV,MAAM,MAAM,IAAI;QAChB,YAAY,MAAM,UAAU;QAC5B,aAAa,MAAM,WAAW;QAC9B,YAAY,MAAM,UAAU;QAC5B,gBAAgB,MAAM,cAAc;QACpC,YAAY,MAAM,UAAU;QAC5B,MAAM,MAAM,IAAI;QAChB,OAAO,MAAM,KAAK;IACpB;SAEA,kBAAkB;QAChB,MAAM;QACN,MAAM,gBAAgB,OAAO,CAAC,aAAa,OAAO;QAClD,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;iBACA;oBACA;6BACA;aACA;IACF;IAEA,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,yCAAW,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,gBAAgB,KAAK,CAAC,eAAe;YACrC,iBAAiB,KAAK,CAAC,gBAAgB;QACzC;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, 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 | null>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useButton(props: AriaButtonOptions<'a'>, ref: RefObject<HTMLAnchorElement | null>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonOptions<'div'>, ref: RefObject<HTMLDivElement | null>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useButton(props: AriaButtonOptions<'input'>, ref: RefObject<HTMLInputElement | null>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useButton(props: AriaButtonOptions<'span'>, ref: RefObject<HTMLSpanElement | null>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useButton(props: AriaButtonOptions<ElementType>, ref: RefObject<Element | null>): 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 preventFocusOnPress,\n // @ts-ignore - undocumented\n allowFocusWhenDisabled,\n onClick,\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 form: props.form,\n formAction: props.formAction,\n formEncType: props.formEncType,\n formMethod: props.formMethod,\n formNoValidate: props.formNoValidate,\n formTarget: props.formTarget,\n name: props.name,\n value: props.value\n };\n } else {\n additionalProps = {\n role: 'button',\n href: elementType === 'a' && !isDisabled ? href : undefined,\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 onClick,\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 'aria-current': props['aria-current'],\n 'aria-disabled': props['aria-disabled']\n })\n };\n}\n"],"names":[],"version":3,"file":"useButton.main.js.map"}
@@ -1,72 +0,0 @@
1
- import {mergeProps as $bwqiF$mergeProps, filterDOMProps as $bwqiF$filterDOMProps} from "@react-aria/utils";
2
- import {usePress as $bwqiF$usePress, useFocusable as $bwqiF$useFocusable} from "@react-aria/interactions";
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 $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
17
- let { elementType: elementType = 'button', isDisabled: isDisabled, onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressUp: onPressUp, onPressChange: onPressChange, preventFocusOnPress: preventFocusOnPress, allowFocusWhenDisabled: // @ts-ignore - undocumented
18
- allowFocusWhenDisabled, onClick: onClick, href: href, target: target, rel: rel, type: type = 'button' } = props;
19
- let additionalProps;
20
- if (elementType === 'button') additionalProps = {
21
- type: type,
22
- disabled: isDisabled,
23
- form: props.form,
24
- formAction: props.formAction,
25
- formEncType: props.formEncType,
26
- formMethod: props.formMethod,
27
- formNoValidate: props.formNoValidate,
28
- formTarget: props.formTarget,
29
- name: props.name,
30
- value: props.value
31
- };
32
- else additionalProps = {
33
- role: 'button',
34
- href: elementType === 'a' && !isDisabled ? href : undefined,
35
- target: elementType === 'a' ? target : undefined,
36
- type: elementType === 'input' ? type : undefined,
37
- disabled: elementType === 'input' ? isDisabled : undefined,
38
- 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,
39
- rel: elementType === 'a' ? rel : undefined
40
- };
41
- let { pressProps: pressProps, isPressed: isPressed } = (0, $bwqiF$usePress)({
42
- onPressStart: onPressStart,
43
- onPressEnd: onPressEnd,
44
- onPressChange: onPressChange,
45
- onPress: onPress,
46
- onPressUp: onPressUp,
47
- onClick: onClick,
48
- isDisabled: isDisabled,
49
- preventFocusOnPress: preventFocusOnPress,
50
- ref: ref
51
- });
52
- let { focusableProps: focusableProps } = (0, $bwqiF$useFocusable)(props, ref);
53
- if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
54
- let buttonProps = (0, $bwqiF$mergeProps)(focusableProps, pressProps, (0, $bwqiF$filterDOMProps)(props, {
55
- labelable: true
56
- }));
57
- return {
58
- isPressed: isPressed,
59
- buttonProps: (0, $bwqiF$mergeProps)(additionalProps, buttonProps, {
60
- 'aria-haspopup': props['aria-haspopup'],
61
- 'aria-expanded': props['aria-expanded'],
62
- 'aria-controls': props['aria-controls'],
63
- 'aria-pressed': props['aria-pressed'],
64
- 'aria-current': props['aria-current'],
65
- 'aria-disabled': props['aria-disabled']
66
- })
67
- };
68
- }
69
-
70
-
71
- export {$701a24aa0da5b062$export$ea18c227d4417cc3 as useButton};
72
- //# sourceMappingURL=useButton.module.js.map
@@ -1,72 +0,0 @@
1
- import {mergeProps as $bwqiF$mergeProps, filterDOMProps as $bwqiF$filterDOMProps} from "@react-aria/utils";
2
- import {usePress as $bwqiF$usePress, useFocusable as $bwqiF$useFocusable} from "@react-aria/interactions";
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 $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
17
- let { elementType: elementType = 'button', isDisabled: isDisabled, onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressUp: onPressUp, onPressChange: onPressChange, preventFocusOnPress: preventFocusOnPress, allowFocusWhenDisabled: // @ts-ignore - undocumented
18
- allowFocusWhenDisabled, onClick: onClick, href: href, target: target, rel: rel, type: type = 'button' } = props;
19
- let additionalProps;
20
- if (elementType === 'button') additionalProps = {
21
- type: type,
22
- disabled: isDisabled,
23
- form: props.form,
24
- formAction: props.formAction,
25
- formEncType: props.formEncType,
26
- formMethod: props.formMethod,
27
- formNoValidate: props.formNoValidate,
28
- formTarget: props.formTarget,
29
- name: props.name,
30
- value: props.value
31
- };
32
- else additionalProps = {
33
- role: 'button',
34
- href: elementType === 'a' && !isDisabled ? href : undefined,
35
- target: elementType === 'a' ? target : undefined,
36
- type: elementType === 'input' ? type : undefined,
37
- disabled: elementType === 'input' ? isDisabled : undefined,
38
- 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,
39
- rel: elementType === 'a' ? rel : undefined
40
- };
41
- let { pressProps: pressProps, isPressed: isPressed } = (0, $bwqiF$usePress)({
42
- onPressStart: onPressStart,
43
- onPressEnd: onPressEnd,
44
- onPressChange: onPressChange,
45
- onPress: onPress,
46
- onPressUp: onPressUp,
47
- onClick: onClick,
48
- isDisabled: isDisabled,
49
- preventFocusOnPress: preventFocusOnPress,
50
- ref: ref
51
- });
52
- let { focusableProps: focusableProps } = (0, $bwqiF$useFocusable)(props, ref);
53
- if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
54
- let buttonProps = (0, $bwqiF$mergeProps)(focusableProps, pressProps, (0, $bwqiF$filterDOMProps)(props, {
55
- labelable: true
56
- }));
57
- return {
58
- isPressed: isPressed,
59
- buttonProps: (0, $bwqiF$mergeProps)(additionalProps, buttonProps, {
60
- 'aria-haspopup': props['aria-haspopup'],
61
- 'aria-expanded': props['aria-expanded'],
62
- 'aria-controls': props['aria-controls'],
63
- 'aria-pressed': props['aria-pressed'],
64
- 'aria-current': props['aria-current'],
65
- 'aria-disabled': props['aria-disabled']
66
- })
67
- };
68
- }
69
-
70
-
71
- export {$701a24aa0da5b062$export$ea18c227d4417cc3 as useButton};
72
- //# sourceMappingURL=useButton.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAqCM,SAAS,0CAAU,KAAqC,EAAE,GAAmB;IAClF,IAAI,eACF,cAAc,sBACd,UAAU,WACV,OAAO,gBACP,YAAY,cACZ,UAAU,aACV,SAAS,iBACT,aAAa,uBACb,mBAAmB,0BACnB,4BAA4B;IAC5B,sBAAsB,WACtB,OAAO,QACP,IAAI,UACJ,MAAM,OACN,GAAG,QACH,OAAO,UACR,GAAG;IACJ,IAAI;IACJ,IAAI,gBAAgB,UAClB,kBAAkB;cAChB;QACA,UAAU;QACV,MAAM,MAAM,IAAI;QAChB,YAAY,MAAM,UAAU;QAC5B,aAAa,MAAM,WAAW;QAC9B,YAAY,MAAM,UAAU;QAC5B,gBAAgB,MAAM,cAAc;QACpC,YAAY,MAAM,UAAU;QAC5B,MAAM,MAAM,IAAI;QAChB,OAAO,MAAM,KAAK;IACpB;SAEA,kBAAkB;QAChB,MAAM;QACN,MAAM,gBAAgB,OAAO,CAAC,aAAa,OAAO;QAClD,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;iBACA;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,gBAAgB,KAAK,CAAC,eAAe;YACrC,iBAAiB,KAAK,CAAC,gBAAgB;QACzC;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, 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 | null>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useButton(props: AriaButtonOptions<'a'>, ref: RefObject<HTMLAnchorElement | null>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonOptions<'div'>, ref: RefObject<HTMLDivElement | null>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useButton(props: AriaButtonOptions<'input'>, ref: RefObject<HTMLInputElement | null>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useButton(props: AriaButtonOptions<'span'>, ref: RefObject<HTMLSpanElement | null>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useButton(props: AriaButtonOptions<ElementType>, ref: RefObject<Element | null>): 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 preventFocusOnPress,\n // @ts-ignore - undocumented\n allowFocusWhenDisabled,\n onClick,\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 form: props.form,\n formAction: props.formAction,\n formEncType: props.formEncType,\n formMethod: props.formMethod,\n formNoValidate: props.formNoValidate,\n formTarget: props.formTarget,\n name: props.name,\n value: props.value\n };\n } else {\n additionalProps = {\n role: 'button',\n href: elementType === 'a' && !isDisabled ? href : undefined,\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 onClick,\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 'aria-current': props['aria-current'],\n 'aria-disabled': props['aria-disabled']\n })\n };\n}\n"],"names":[],"version":3,"file":"useButton.module.js.map"}
@@ -1,39 +0,0 @@
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
- isSelected: isSelected,
31
- isDisabled: props.isDisabled || false,
32
- buttonProps: (0, $4M9F2$reactariautils.mergeProps)(buttonProps, {
33
- 'aria-pressed': isSelected
34
- })
35
- };
36
- }
37
-
38
-
39
- //# sourceMappingURL=useToggleButton.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAoCM,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;oBACA;QACA,YAAY,MAAM,UAAU,IAAI;QAChC,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\nexport interface ToggleButtonAria<T> extends ButtonAria<T> {\n /** Whether the button is selected. */\n isSelected: boolean,\n /** Whether the button is disabled. */\n isDisabled: boolean\n}\n\n// Order with overrides is important: 'button' should be default\nexport function useToggleButton(props: AriaToggleButtonOptions<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement | null>): ToggleButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement | null>): ToggleButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement | null>): ToggleButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement | null>): ToggleButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement | null>): ToggleButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<ElementType>, state: ToggleState, ref: RefObject<Element | null>): ToggleButtonAria<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>): ToggleButtonAria<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 isSelected,\n isDisabled: props.isDisabled || false,\n buttonProps: mergeProps(buttonProps, {\n 'aria-pressed': isSelected\n })\n };\n}\n"],"names":[],"version":3,"file":"useToggleButton.main.js.map"}
@@ -1,34 +0,0 @@
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
- isSelected: isSelected,
25
- isDisabled: props.isDisabled || false,
26
- buttonProps: (0, $h7Tql$mergeProps)(buttonProps, {
27
- 'aria-pressed': isSelected
28
- })
29
- };
30
- }
31
-
32
-
33
- export {$55f54f7887471b58$export$51e84d46ca0bc451 as useToggleButton};
34
- //# sourceMappingURL=useToggleButton.module.js.map
@@ -1,34 +0,0 @@
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
- isSelected: isSelected,
25
- isDisabled: props.isDisabled || false,
26
- buttonProps: (0, $h7Tql$mergeProps)(buttonProps, {
27
- 'aria-pressed': isSelected
28
- })
29
- };
30
- }
31
-
32
-
33
- export {$55f54f7887471b58$export$51e84d46ca0bc451 as useToggleButton};
34
- //# sourceMappingURL=useToggleButton.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAoCM,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;oBACA;QACA,YAAY,MAAM,UAAU,IAAI;QAChC,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\nexport interface ToggleButtonAria<T> extends ButtonAria<T> {\n /** Whether the button is selected. */\n isSelected: boolean,\n /** Whether the button is disabled. */\n isDisabled: boolean\n}\n\n// Order with overrides is important: 'button' should be default\nexport function useToggleButton(props: AriaToggleButtonOptions<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement | null>): ToggleButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement | null>): ToggleButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement | null>): ToggleButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement | null>): ToggleButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement | null>): ToggleButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useToggleButton(props: AriaToggleButtonOptions<ElementType>, state: ToggleState, ref: RefObject<Element | null>): ToggleButtonAria<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>): ToggleButtonAria<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 isSelected,\n isDisabled: props.isDisabled || false,\n buttonProps: mergeProps(buttonProps, {\n 'aria-pressed': isSelected\n })\n };\n}\n"],"names":[],"version":3,"file":"useToggleButton.module.js.map"}
@@ -1,64 +0,0 @@
1
- var $c49208f7d2aac50b$exports = require("./useToggleButton.main.js");
2
- var $eYVcO$reactariatoolbar = require("@react-aria/toolbar");
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, "useToggleButtonGroup", () => $7d1e6c2af0d638cd$export$dd5580ae642f110f);
10
- $parcel$export(module.exports, "useToggleButtonGroupItem", () => $7d1e6c2af0d638cd$export$bc53712daae3d6e6);
11
- /*
12
- * Copyright 2024 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
- function $7d1e6c2af0d638cd$export$dd5580ae642f110f(props, state, ref) {
24
- let { isDisabled: isDisabled } = props;
25
- let { toolbarProps: toolbarProps } = (0, $eYVcO$reactariatoolbar.useToolbar)(props, ref);
26
- return {
27
- groupProps: {
28
- ...toolbarProps,
29
- role: state.selectionMode === 'single' ? 'radiogroup' : toolbarProps.role,
30
- 'aria-disabled': isDisabled
31
- }
32
- };
33
- }
34
- function $7d1e6c2af0d638cd$export$bc53712daae3d6e6(props, state, ref) {
35
- let toggleState = {
36
- isSelected: state.selectedKeys.has(props.id),
37
- defaultSelected: false,
38
- setSelected (isSelected) {
39
- state.setSelected(props.id, isSelected);
40
- },
41
- toggle () {
42
- state.toggleKey(props.id);
43
- }
44
- };
45
- let { isPressed: isPressed, isSelected: isSelected, isDisabled: isDisabled, buttonProps: buttonProps } = (0, $c49208f7d2aac50b$exports.useToggleButton)({
46
- ...props,
47
- id: undefined,
48
- isDisabled: props.isDisabled || state.isDisabled
49
- }, toggleState, ref);
50
- if (state.selectionMode === 'single') {
51
- buttonProps.role = 'radio';
52
- buttonProps['aria-checked'] = toggleState.isSelected;
53
- delete buttonProps['aria-pressed'];
54
- }
55
- return {
56
- isPressed: isPressed,
57
- isSelected: isSelected,
58
- isDisabled: isDisabled,
59
- buttonProps: buttonProps
60
- };
61
- }
62
-
63
-
64
- //# sourceMappingURL=useToggleButtonGroup.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AA8BM,SAAS,0CAAqB,KAAiC,EAAE,KAAuB,EAAE,GAAkC;IACjI,IAAI,cAAC,UAAU,EAAC,GAAG;IACnB,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,kCAAS,EAAE,OAAO;IAEvC,OAAO;QACL,YAAY;YACV,GAAG,YAAY;YACf,MAAM,MAAM,aAAa,KAAK,WAAW,eAAe,aAAa,IAAI;YACzE,iBAAiB;QACnB;IACF;AACF;AAgBO,SAAS,0CAAyB,KAAoD,EAAE,KAAuB,EAAE,GAAmB;IACzI,IAAI,cAA2B;QAC7B,YAAY,MAAM,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE;QAC3C,iBAAiB;QACjB,aAAY,UAAU;YACpB,MAAM,WAAW,CAAC,MAAM,EAAE,EAAE;QAC9B;QACA;YACE,MAAM,SAAS,CAAC,MAAM,EAAE;QAC1B;IACF;IAEA,IAAI,aAAC,SAAS,cAAE,UAAU,cAAE,UAAU,eAAE,WAAW,EAAC,GAAG,CAAA,GAAA,yCAAc,EAAE;QACrE,GAAG,KAAK;QACR,IAAI;QACJ,YAAY,MAAM,UAAU,IAAI,MAAM,UAAU;IAClD,GAAG,aAAa;IAChB,IAAI,MAAM,aAAa,KAAK,UAAU;QACpC,YAAY,IAAI,GAAG;QACnB,WAAW,CAAC,eAAe,GAAG,YAAY,UAAU;QACpD,OAAO,WAAW,CAAC,eAAe;IACpC;IAEA,OAAO;mBACL;oBACA;oBACA;qBACA;IACF;AACF","sources":["packages/@react-aria/button/src/useToggleButtonGroup.ts"],"sourcesContent":["/*\n * Copyright 2024 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} from 'react';\nimport {AriaLabelingProps, DOMAttributes, Orientation, RefObject} from '@react-types/shared';\nimport {AriaToggleButtonGroupItemProps} from '@react-types/button';\nimport {ToggleButtonAria, useToggleButton} from './useToggleButton';\nimport {ToggleGroupProps, ToggleGroupState, ToggleState} from '@react-stately/toggle';\nimport {useToolbar} from '@react-aria/toolbar';\n\nexport interface AriaToggleButtonGroupProps extends ToggleGroupProps, AriaLabelingProps {\n /**\n * The orientation of the the toggle button group.\n * @default 'horizontal'\n */\n orientation?: Orientation\n}\n\nexport interface ToggleButtonGroupAria {\n /**\n * Props for the toggle button group container.\n */\n groupProps: DOMAttributes\n}\n\nexport function useToggleButtonGroup(props: AriaToggleButtonGroupProps, state: ToggleGroupState, ref: RefObject<HTMLElement | null>): ToggleButtonGroupAria {\n let {isDisabled} = props;\n let {toolbarProps} = useToolbar(props, ref);\n\n return {\n groupProps: {\n ...toolbarProps,\n role: state.selectionMode === 'single' ? 'radiogroup' : toolbarProps.role,\n 'aria-disabled': isDisabled\n }\n };\n}\n\nexport type {AriaToggleButtonGroupItemProps};\nexport interface AriaToggleButtonGroupItemOptions<E extends ElementType> extends Omit<AriaToggleButtonGroupItemProps<E>, 'children'> {}\n\n// Order with overrides is important: 'button' should be default\nexport function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'button'>, state: ToggleGroupState, ref: RefObject<HTMLButtonElement | null>): ToggleButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'a'>, state: ToggleGroupState, ref: RefObject<HTMLAnchorElement | null>): ToggleButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'div'>, state: ToggleGroupState, ref: RefObject<HTMLDivElement | null>): ToggleButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'input'>, state: ToggleGroupState, ref: RefObject<HTMLInputElement | null>): ToggleButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'span'>, state: ToggleGroupState, ref: RefObject<HTMLSpanElement | null>): ToggleButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<ElementType>, state: ToggleGroupState, ref: RefObject<Element | null>): ToggleButtonAria<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 useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<ElementType>, state: ToggleGroupState, ref: RefObject<any>): ToggleButtonAria<HTMLAttributes<any>> {\n let toggleState: ToggleState = {\n isSelected: state.selectedKeys.has(props.id),\n defaultSelected: false,\n setSelected(isSelected) {\n state.setSelected(props.id, isSelected);\n },\n toggle() {\n state.toggleKey(props.id);\n }\n };\n\n let {isPressed, isSelected, isDisabled, buttonProps} = useToggleButton({\n ...props,\n id: undefined,\n isDisabled: props.isDisabled || state.isDisabled\n }, toggleState, ref);\n if (state.selectionMode === 'single') {\n buttonProps.role = 'radio';\n buttonProps['aria-checked'] = toggleState.isSelected;\n delete buttonProps['aria-pressed'];\n }\n\n return {\n isPressed,\n isSelected,\n isDisabled,\n buttonProps\n };\n}\n"],"names":[],"version":3,"file":"useToggleButtonGroup.main.js.map"}
@@ -1,58 +0,0 @@
1
- import {useToggleButton as $55f54f7887471b58$export$51e84d46ca0bc451} from "./useToggleButton.mjs";
2
- import {useToolbar as $9iEyV$useToolbar} from "@react-aria/toolbar";
3
-
4
- /*
5
- * Copyright 2024 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 $4547d1bf40011fdf$export$dd5580ae642f110f(props, state, ref) {
17
- let { isDisabled: isDisabled } = props;
18
- let { toolbarProps: toolbarProps } = (0, $9iEyV$useToolbar)(props, ref);
19
- return {
20
- groupProps: {
21
- ...toolbarProps,
22
- role: state.selectionMode === 'single' ? 'radiogroup' : toolbarProps.role,
23
- 'aria-disabled': isDisabled
24
- }
25
- };
26
- }
27
- function $4547d1bf40011fdf$export$bc53712daae3d6e6(props, state, ref) {
28
- let toggleState = {
29
- isSelected: state.selectedKeys.has(props.id),
30
- defaultSelected: false,
31
- setSelected (isSelected) {
32
- state.setSelected(props.id, isSelected);
33
- },
34
- toggle () {
35
- state.toggleKey(props.id);
36
- }
37
- };
38
- let { isPressed: isPressed, isSelected: isSelected, isDisabled: isDisabled, buttonProps: buttonProps } = (0, $55f54f7887471b58$export$51e84d46ca0bc451)({
39
- ...props,
40
- id: undefined,
41
- isDisabled: props.isDisabled || state.isDisabled
42
- }, toggleState, ref);
43
- if (state.selectionMode === 'single') {
44
- buttonProps.role = 'radio';
45
- buttonProps['aria-checked'] = toggleState.isSelected;
46
- delete buttonProps['aria-pressed'];
47
- }
48
- return {
49
- isPressed: isPressed,
50
- isSelected: isSelected,
51
- isDisabled: isDisabled,
52
- buttonProps: buttonProps
53
- };
54
- }
55
-
56
-
57
- export {$4547d1bf40011fdf$export$dd5580ae642f110f as useToggleButtonGroup, $4547d1bf40011fdf$export$bc53712daae3d6e6 as useToggleButtonGroupItem};
58
- //# sourceMappingURL=useToggleButtonGroup.module.js.map
@@ -1,58 +0,0 @@
1
- import {useToggleButton as $55f54f7887471b58$export$51e84d46ca0bc451} from "./useToggleButton.module.js";
2
- import {useToolbar as $9iEyV$useToolbar} from "@react-aria/toolbar";
3
-
4
- /*
5
- * Copyright 2024 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 $4547d1bf40011fdf$export$dd5580ae642f110f(props, state, ref) {
17
- let { isDisabled: isDisabled } = props;
18
- let { toolbarProps: toolbarProps } = (0, $9iEyV$useToolbar)(props, ref);
19
- return {
20
- groupProps: {
21
- ...toolbarProps,
22
- role: state.selectionMode === 'single' ? 'radiogroup' : toolbarProps.role,
23
- 'aria-disabled': isDisabled
24
- }
25
- };
26
- }
27
- function $4547d1bf40011fdf$export$bc53712daae3d6e6(props, state, ref) {
28
- let toggleState = {
29
- isSelected: state.selectedKeys.has(props.id),
30
- defaultSelected: false,
31
- setSelected (isSelected) {
32
- state.setSelected(props.id, isSelected);
33
- },
34
- toggle () {
35
- state.toggleKey(props.id);
36
- }
37
- };
38
- let { isPressed: isPressed, isSelected: isSelected, isDisabled: isDisabled, buttonProps: buttonProps } = (0, $55f54f7887471b58$export$51e84d46ca0bc451)({
39
- ...props,
40
- id: undefined,
41
- isDisabled: props.isDisabled || state.isDisabled
42
- }, toggleState, ref);
43
- if (state.selectionMode === 'single') {
44
- buttonProps.role = 'radio';
45
- buttonProps['aria-checked'] = toggleState.isSelected;
46
- delete buttonProps['aria-pressed'];
47
- }
48
- return {
49
- isPressed: isPressed,
50
- isSelected: isSelected,
51
- isDisabled: isDisabled,
52
- buttonProps: buttonProps
53
- };
54
- }
55
-
56
-
57
- export {$4547d1bf40011fdf$export$dd5580ae642f110f as useToggleButtonGroup, $4547d1bf40011fdf$export$bc53712daae3d6e6 as useToggleButtonGroupItem};
58
- //# sourceMappingURL=useToggleButtonGroup.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AA8BM,SAAS,0CAAqB,KAAiC,EAAE,KAAuB,EAAE,GAAkC;IACjI,IAAI,cAAC,UAAU,EAAC,GAAG;IACnB,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE,OAAO;IAEvC,OAAO;QACL,YAAY;YACV,GAAG,YAAY;YACf,MAAM,MAAM,aAAa,KAAK,WAAW,eAAe,aAAa,IAAI;YACzE,iBAAiB;QACnB;IACF;AACF;AAgBO,SAAS,0CAAyB,KAAoD,EAAE,KAAuB,EAAE,GAAmB;IACzI,IAAI,cAA2B;QAC7B,YAAY,MAAM,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE;QAC3C,iBAAiB;QACjB,aAAY,UAAU;YACpB,MAAM,WAAW,CAAC,MAAM,EAAE,EAAE;QAC9B;QACA;YACE,MAAM,SAAS,CAAC,MAAM,EAAE;QAC1B;IACF;IAEA,IAAI,aAAC,SAAS,cAAE,UAAU,cAAE,UAAU,eAAE,WAAW,EAAC,GAAG,CAAA,GAAA,yCAAc,EAAE;QACrE,GAAG,KAAK;QACR,IAAI;QACJ,YAAY,MAAM,UAAU,IAAI,MAAM,UAAU;IAClD,GAAG,aAAa;IAChB,IAAI,MAAM,aAAa,KAAK,UAAU;QACpC,YAAY,IAAI,GAAG;QACnB,WAAW,CAAC,eAAe,GAAG,YAAY,UAAU;QACpD,OAAO,WAAW,CAAC,eAAe;IACpC;IAEA,OAAO;mBACL;oBACA;oBACA;qBACA;IACF;AACF","sources":["packages/@react-aria/button/src/useToggleButtonGroup.ts"],"sourcesContent":["/*\n * Copyright 2024 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} from 'react';\nimport {AriaLabelingProps, DOMAttributes, Orientation, RefObject} from '@react-types/shared';\nimport {AriaToggleButtonGroupItemProps} from '@react-types/button';\nimport {ToggleButtonAria, useToggleButton} from './useToggleButton';\nimport {ToggleGroupProps, ToggleGroupState, ToggleState} from '@react-stately/toggle';\nimport {useToolbar} from '@react-aria/toolbar';\n\nexport interface AriaToggleButtonGroupProps extends ToggleGroupProps, AriaLabelingProps {\n /**\n * The orientation of the the toggle button group.\n * @default 'horizontal'\n */\n orientation?: Orientation\n}\n\nexport interface ToggleButtonGroupAria {\n /**\n * Props for the toggle button group container.\n */\n groupProps: DOMAttributes\n}\n\nexport function useToggleButtonGroup(props: AriaToggleButtonGroupProps, state: ToggleGroupState, ref: RefObject<HTMLElement | null>): ToggleButtonGroupAria {\n let {isDisabled} = props;\n let {toolbarProps} = useToolbar(props, ref);\n\n return {\n groupProps: {\n ...toolbarProps,\n role: state.selectionMode === 'single' ? 'radiogroup' : toolbarProps.role,\n 'aria-disabled': isDisabled\n }\n };\n}\n\nexport type {AriaToggleButtonGroupItemProps};\nexport interface AriaToggleButtonGroupItemOptions<E extends ElementType> extends Omit<AriaToggleButtonGroupItemProps<E>, 'children'> {}\n\n// Order with overrides is important: 'button' should be default\nexport function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'button'>, state: ToggleGroupState, ref: RefObject<HTMLButtonElement | null>): ToggleButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'a'>, state: ToggleGroupState, ref: RefObject<HTMLAnchorElement | null>): ToggleButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'div'>, state: ToggleGroupState, ref: RefObject<HTMLDivElement | null>): ToggleButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'input'>, state: ToggleGroupState, ref: RefObject<HTMLInputElement | null>): ToggleButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'span'>, state: ToggleGroupState, ref: RefObject<HTMLSpanElement | null>): ToggleButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<ElementType>, state: ToggleGroupState, ref: RefObject<Element | null>): ToggleButtonAria<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 useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<ElementType>, state: ToggleGroupState, ref: RefObject<any>): ToggleButtonAria<HTMLAttributes<any>> {\n let toggleState: ToggleState = {\n isSelected: state.selectedKeys.has(props.id),\n defaultSelected: false,\n setSelected(isSelected) {\n state.setSelected(props.id, isSelected);\n },\n toggle() {\n state.toggleKey(props.id);\n }\n };\n\n let {isPressed, isSelected, isDisabled, buttonProps} = useToggleButton({\n ...props,\n id: undefined,\n isDisabled: props.isDisabled || state.isDisabled\n }, toggleState, ref);\n if (state.selectionMode === 'single') {\n buttonProps.role = 'radio';\n buttonProps['aria-checked'] = toggleState.isSelected;\n delete buttonProps['aria-pressed'];\n }\n\n return {\n isPressed,\n isSelected,\n isDisabled,\n buttonProps\n };\n}\n"],"names":[],"version":3,"file":"useToggleButtonGroup.module.js.map"}
package/src/useButton.ts DELETED
@@ -1,121 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {
14
- AnchorHTMLAttributes,
15
- ButtonHTMLAttributes,
16
- ElementType,
17
- HTMLAttributes,
18
- InputHTMLAttributes,
19
- RefObject
20
- } from 'react';
21
- import {AriaButtonProps} from '@react-types/button';
22
- import {DOMAttributes} from '@react-types/shared';
23
- import {filterDOMProps, mergeProps} from '@react-aria/utils';
24
- import {useFocusable, usePress} from '@react-aria/interactions';
25
-
26
- export interface AriaButtonOptions<E extends ElementType> extends Omit<AriaButtonProps<E>, 'children'> {}
27
-
28
- export interface ButtonAria<T> {
29
- /** Props for the button element. */
30
- buttonProps: T,
31
- /** Whether the button is currently pressed. */
32
- isPressed: boolean
33
- }
34
-
35
- // Order with overrides is important: 'button' should be default
36
- export function useButton(props: AriaButtonOptions<'button'>, ref: RefObject<HTMLButtonElement | null>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;
37
- export function useButton(props: AriaButtonOptions<'a'>, ref: RefObject<HTMLAnchorElement | null>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
38
- export function useButton(props: AriaButtonOptions<'div'>, ref: RefObject<HTMLDivElement | null>): ButtonAria<HTMLAttributes<HTMLDivElement>>;
39
- export function useButton(props: AriaButtonOptions<'input'>, ref: RefObject<HTMLInputElement | null>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;
40
- export function useButton(props: AriaButtonOptions<'span'>, ref: RefObject<HTMLSpanElement | null>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;
41
- export function useButton(props: AriaButtonOptions<ElementType>, ref: RefObject<Element | null>): ButtonAria<DOMAttributes>;
42
- /**
43
- * Provides the behavior and accessibility implementation for a button component. Handles mouse, keyboard, and touch interactions,
44
- * focus behavior, and ARIA props for both native button elements and custom element types.
45
- * @param props - Props to be applied to the button.
46
- * @param ref - A ref to a DOM element for the button.
47
- */
48
- export function useButton(props: AriaButtonOptions<ElementType>, ref: RefObject<any>): ButtonAria<HTMLAttributes<any>> {
49
- let {
50
- elementType = 'button',
51
- isDisabled,
52
- onPress,
53
- onPressStart,
54
- onPressEnd,
55
- onPressUp,
56
- onPressChange,
57
- preventFocusOnPress,
58
- // @ts-ignore - undocumented
59
- allowFocusWhenDisabled,
60
- onClick,
61
- href,
62
- target,
63
- rel,
64
- type = 'button'
65
- } = props;
66
- let additionalProps;
67
- if (elementType === 'button') {
68
- additionalProps = {
69
- type,
70
- disabled: isDisabled,
71
- form: props.form,
72
- formAction: props.formAction,
73
- formEncType: props.formEncType,
74
- formMethod: props.formMethod,
75
- formNoValidate: props.formNoValidate,
76
- formTarget: props.formTarget,
77
- name: props.name,
78
- value: props.value
79
- };
80
- } else {
81
- additionalProps = {
82
- role: 'button',
83
- href: elementType === 'a' && !isDisabled ? href : undefined,
84
- target: elementType === 'a' ? target : undefined,
85
- type: elementType === 'input' ? type : undefined,
86
- disabled: elementType === 'input' ? isDisabled : undefined,
87
- 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,
88
- rel: elementType === 'a' ? rel : undefined
89
- };
90
- }
91
-
92
- let {pressProps, isPressed} = usePress({
93
- onPressStart,
94
- onPressEnd,
95
- onPressChange,
96
- onPress,
97
- onPressUp,
98
- onClick,
99
- isDisabled,
100
- preventFocusOnPress,
101
- ref
102
- });
103
-
104
- let {focusableProps} = useFocusable(props, ref);
105
- if (allowFocusWhenDisabled) {
106
- focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
107
- }
108
- let buttonProps = mergeProps(focusableProps, pressProps, filterDOMProps(props, {labelable: true}));
109
-
110
- return {
111
- isPressed, // Used to indicate press state for visual
112
- buttonProps: mergeProps(additionalProps, buttonProps, {
113
- 'aria-haspopup': props['aria-haspopup'],
114
- 'aria-expanded': props['aria-expanded'],
115
- 'aria-controls': props['aria-controls'],
116
- 'aria-pressed': props['aria-pressed'],
117
- 'aria-current': props['aria-current'],
118
- 'aria-disabled': props['aria-disabled']
119
- })
120
- };
121
- }
@@ -1,62 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {
14
- AnchorHTMLAttributes,
15
- ButtonHTMLAttributes,
16
- ElementType,
17
- HTMLAttributes,
18
- InputHTMLAttributes,
19
- RefObject
20
- } from 'react';
21
- import {AriaToggleButtonProps} from '@react-types/button';
22
- import {ButtonAria, useButton} from './useButton';
23
- import {chain, mergeProps} from '@react-aria/utils';
24
- import {DOMAttributes} from '@react-types/shared';
25
- import {ToggleState} from '@react-stately/toggle';
26
-
27
- export interface AriaToggleButtonOptions<E extends ElementType> extends Omit<AriaToggleButtonProps<E>, 'children'> {}
28
-
29
- export interface ToggleButtonAria<T> extends ButtonAria<T> {
30
- /** Whether the button is selected. */
31
- isSelected: boolean,
32
- /** Whether the button is disabled. */
33
- isDisabled: boolean
34
- }
35
-
36
- // Order with overrides is important: 'button' should be default
37
- export function useToggleButton(props: AriaToggleButtonOptions<'button'>, state: ToggleState, ref: RefObject<HTMLButtonElement | null>): ToggleButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;
38
- export function useToggleButton(props: AriaToggleButtonOptions<'a'>, state: ToggleState, ref: RefObject<HTMLAnchorElement | null>): ToggleButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
39
- export function useToggleButton(props: AriaToggleButtonOptions<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement | null>): ToggleButtonAria<HTMLAttributes<HTMLDivElement>>;
40
- export function useToggleButton(props: AriaToggleButtonOptions<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement | null>): ToggleButtonAria<InputHTMLAttributes<HTMLInputElement>>;
41
- export function useToggleButton(props: AriaToggleButtonOptions<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement | null>): ToggleButtonAria<HTMLAttributes<HTMLSpanElement>>;
42
- export function useToggleButton(props: AriaToggleButtonOptions<ElementType>, state: ToggleState, ref: RefObject<Element | null>): ToggleButtonAria<DOMAttributes>;
43
- /**
44
- * Provides the behavior and accessibility implementation for a toggle button component.
45
- * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.
46
- */
47
- export function useToggleButton(props: AriaToggleButtonOptions<ElementType>, state: ToggleState, ref: RefObject<any>): ToggleButtonAria<HTMLAttributes<any>> {
48
- const {isSelected} = state;
49
- const {isPressed, buttonProps} = useButton({
50
- ...props,
51
- onPress: chain(state.toggle, props.onPress)
52
- }, ref);
53
-
54
- return {
55
- isPressed,
56
- isSelected,
57
- isDisabled: props.isDisabled || false,
58
- buttonProps: mergeProps(buttonProps, {
59
- 'aria-pressed': isSelected
60
- })
61
- };
62
- }
@@ -1,97 +0,0 @@
1
- /*
2
- * Copyright 2024 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {
14
- AnchorHTMLAttributes,
15
- ButtonHTMLAttributes,
16
- ElementType,
17
- HTMLAttributes,
18
- InputHTMLAttributes
19
- } from 'react';
20
- import {AriaLabelingProps, DOMAttributes, Orientation, RefObject} from '@react-types/shared';
21
- import {AriaToggleButtonGroupItemProps} from '@react-types/button';
22
- import {ToggleButtonAria, useToggleButton} from './useToggleButton';
23
- import {ToggleGroupProps, ToggleGroupState, ToggleState} from '@react-stately/toggle';
24
- import {useToolbar} from '@react-aria/toolbar';
25
-
26
- export interface AriaToggleButtonGroupProps extends ToggleGroupProps, AriaLabelingProps {
27
- /**
28
- * The orientation of the the toggle button group.
29
- * @default 'horizontal'
30
- */
31
- orientation?: Orientation
32
- }
33
-
34
- export interface ToggleButtonGroupAria {
35
- /**
36
- * Props for the toggle button group container.
37
- */
38
- groupProps: DOMAttributes
39
- }
40
-
41
- export function useToggleButtonGroup(props: AriaToggleButtonGroupProps, state: ToggleGroupState, ref: RefObject<HTMLElement | null>): ToggleButtonGroupAria {
42
- let {isDisabled} = props;
43
- let {toolbarProps} = useToolbar(props, ref);
44
-
45
- return {
46
- groupProps: {
47
- ...toolbarProps,
48
- role: state.selectionMode === 'single' ? 'radiogroup' : toolbarProps.role,
49
- 'aria-disabled': isDisabled
50
- }
51
- };
52
- }
53
-
54
- export type {AriaToggleButtonGroupItemProps};
55
- export interface AriaToggleButtonGroupItemOptions<E extends ElementType> extends Omit<AriaToggleButtonGroupItemProps<E>, 'children'> {}
56
-
57
- // Order with overrides is important: 'button' should be default
58
- export function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'button'>, state: ToggleGroupState, ref: RefObject<HTMLButtonElement | null>): ToggleButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;
59
- export function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'a'>, state: ToggleGroupState, ref: RefObject<HTMLAnchorElement | null>): ToggleButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
60
- export function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'div'>, state: ToggleGroupState, ref: RefObject<HTMLDivElement | null>): ToggleButtonAria<HTMLAttributes<HTMLDivElement>>;
61
- export function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'input'>, state: ToggleGroupState, ref: RefObject<HTMLInputElement | null>): ToggleButtonAria<InputHTMLAttributes<HTMLInputElement>>;
62
- export function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<'span'>, state: ToggleGroupState, ref: RefObject<HTMLSpanElement | null>): ToggleButtonAria<HTMLAttributes<HTMLSpanElement>>;
63
- export function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<ElementType>, state: ToggleGroupState, ref: RefObject<Element | null>): ToggleButtonAria<DOMAttributes>;
64
- /**
65
- * Provides the behavior and accessibility implementation for a toggle button component.
66
- * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.
67
- */
68
- export function useToggleButtonGroupItem(props: AriaToggleButtonGroupItemOptions<ElementType>, state: ToggleGroupState, ref: RefObject<any>): ToggleButtonAria<HTMLAttributes<any>> {
69
- let toggleState: ToggleState = {
70
- isSelected: state.selectedKeys.has(props.id),
71
- defaultSelected: false,
72
- setSelected(isSelected) {
73
- state.setSelected(props.id, isSelected);
74
- },
75
- toggle() {
76
- state.toggleKey(props.id);
77
- }
78
- };
79
-
80
- let {isPressed, isSelected, isDisabled, buttonProps} = useToggleButton({
81
- ...props,
82
- id: undefined,
83
- isDisabled: props.isDisabled || state.isDisabled
84
- }, toggleState, ref);
85
- if (state.selectionMode === 'single') {
86
- buttonProps.role = 'radio';
87
- buttonProps['aria-checked'] = toggleState.isSelected;
88
- delete buttonProps['aria-pressed'];
89
- }
90
-
91
- return {
92
- isPressed,
93
- isSelected,
94
- isDisabled,
95
- buttonProps
96
- };
97
- }