@vx-oss/heroui-v2-use-aria-button 2.2.21-alpha.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/LICENSE ADDED
@@ -0,0 +1,32 @@
1
+ SPDX-License-Identifier: MIT
2
+
3
+ The MIT License (MIT)
4
+
5
+ Parameters
6
+
7
+ Creator / Maintainer : Vezham Technologies Private Limited
8
+ Original Author : NextUI Inc
9
+ Licensor : Vezham Technologies Private Limited
10
+
11
+ Copyright © 2025, Vezham Technologies Private Limited. All rights reserved.
12
+ Copyright (c) 2020, NextUI Inc.
13
+
14
+ ---
15
+
16
+ Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ of this software and associated documentation files (the "Software"), to deal
18
+ in the Software without restriction, including without limitation the rights
19
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the Software is
21
+ furnished to do so, subject to the following conditions:
22
+
23
+ The above copyright notice and this permission notice shall be included in all
24
+ copies or substantial portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # @vx-oss/heroui-v2-use-aria-button
2
+
3
+ A Quick description of the component
4
+
5
+ > This is an internal utility, not intended for public usage.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ yarn add @vx-oss/heroui-v2-use-aria-button
11
+ # or
12
+ npm i @vx-oss/heroui-v2-use-aria-button
13
+ ```
14
+
15
+ ## Contribution
16
+
17
+ Yes please! See the
18
+ [contributing guidelines](https://github.com/heroui-inc/heroui/blob/master/CONTRIBUTING.md)
19
+ for details.
20
+
21
+ ## License
22
+
23
+ This project is licensed under the terms of the
24
+ [MIT license](https://github.com/heroui-inc/heroui/blob/master/LICENSE).
@@ -0,0 +1,24 @@
1
+ import { ElementType, RefObject, ButtonHTMLAttributes, AnchorHTMLAttributes, HTMLAttributes, InputHTMLAttributes } from 'react';
2
+ import { AriaButtonProps as AriaButtonProps$1 } from '@react-types/button';
3
+ import { DOMAttributes } from '@react-types/shared';
4
+
5
+ type AriaButtonProps<T extends ElementType = "button"> = AriaButtonProps$1<T> & {
6
+ /** Whether text selection should be enabled on the pressable element. */
7
+ allowTextSelectionOnPress?: boolean;
8
+ /** The role of the button element. */
9
+ role?: string;
10
+ };
11
+ interface ButtonAria<T> {
12
+ /** Props for the button element. */
13
+ buttonProps: T;
14
+ /** Whether the button is currently pressed. */
15
+ isPressed: boolean;
16
+ }
17
+ declare function useAriaButton(props: AriaButtonProps<"button">, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;
18
+ declare function useAriaButton(props: AriaButtonProps<"a">, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
19
+ declare function useAriaButton(props: AriaButtonProps<"div">, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;
20
+ declare function useAriaButton(props: AriaButtonProps<"input">, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;
21
+ declare function useAriaButton(props: AriaButtonProps<"span">, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;
22
+ declare function useAriaButton(props: AriaButtonProps<ElementType>, ref: RefObject<Element>): ButtonAria<DOMAttributes>;
23
+
24
+ export { type AriaButtonProps, type ButtonAria, useAriaButton };
@@ -0,0 +1,24 @@
1
+ import { ElementType, RefObject, ButtonHTMLAttributes, AnchorHTMLAttributes, HTMLAttributes, InputHTMLAttributes } from 'react';
2
+ import { AriaButtonProps as AriaButtonProps$1 } from '@react-types/button';
3
+ import { DOMAttributes } from '@react-types/shared';
4
+
5
+ type AriaButtonProps<T extends ElementType = "button"> = AriaButtonProps$1<T> & {
6
+ /** Whether text selection should be enabled on the pressable element. */
7
+ allowTextSelectionOnPress?: boolean;
8
+ /** The role of the button element. */
9
+ role?: string;
10
+ };
11
+ interface ButtonAria<T> {
12
+ /** Props for the button element. */
13
+ buttonProps: T;
14
+ /** Whether the button is currently pressed. */
15
+ isPressed: boolean;
16
+ }
17
+ declare function useAriaButton(props: AriaButtonProps<"button">, ref: RefObject<HTMLButtonElement>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;
18
+ declare function useAriaButton(props: AriaButtonProps<"a">, ref: RefObject<HTMLAnchorElement>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
19
+ declare function useAriaButton(props: AriaButtonProps<"div">, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;
20
+ declare function useAriaButton(props: AriaButtonProps<"input">, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;
21
+ declare function useAriaButton(props: AriaButtonProps<"span">, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;
22
+ declare function useAriaButton(props: AriaButtonProps<ElementType>, ref: RefObject<Element>): ButtonAria<DOMAttributes>;
23
+
24
+ export { type AriaButtonProps, type ButtonAria, useAriaButton };
package/dist/index.js ADDED
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ useAriaButton: () => useAriaButton
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_utils = require("@react-aria/utils");
27
+ var import_focus = require("@react-aria/focus");
28
+ var import_interactions = require("@react-aria/interactions");
29
+ function useAriaButton(props, ref) {
30
+ let {
31
+ elementType = "button",
32
+ isDisabled,
33
+ onPress,
34
+ onPressStart,
35
+ onPressEnd,
36
+ onPressUp,
37
+ onPressChange,
38
+ // @ts-ignore - undocumented
39
+ preventFocusOnPress,
40
+ // @ts-ignore - undocumented
41
+ allowFocusWhenDisabled,
42
+ onClick,
43
+ href,
44
+ target,
45
+ rel,
46
+ type = "button",
47
+ allowTextSelectionOnPress
48
+ } = props;
49
+ let additionalProps;
50
+ if (elementType === "button") {
51
+ additionalProps = {
52
+ type,
53
+ disabled: isDisabled
54
+ };
55
+ } else {
56
+ additionalProps = {
57
+ role: "button",
58
+ href: elementType === "a" && !isDisabled ? href : void 0,
59
+ target: elementType === "a" ? target : void 0,
60
+ type: elementType === "input" ? type : void 0,
61
+ disabled: elementType === "input" ? isDisabled : void 0,
62
+ "aria-disabled": !isDisabled || elementType === "input" ? void 0 : isDisabled,
63
+ rel: elementType === "a" ? rel : void 0
64
+ };
65
+ }
66
+ let { pressProps, isPressed } = (0, import_interactions.usePress)({
67
+ onClick,
68
+ onPressStart,
69
+ onPressEnd,
70
+ onPressUp,
71
+ onPressChange,
72
+ onPress,
73
+ isDisabled,
74
+ preventFocusOnPress,
75
+ allowTextSelectionOnPress,
76
+ ref
77
+ });
78
+ let { focusableProps } = (0, import_focus.useFocusable)(props, ref);
79
+ if (allowFocusWhenDisabled) {
80
+ focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
81
+ }
82
+ let buttonProps = (0, import_utils.mergeProps)(
83
+ focusableProps,
84
+ pressProps,
85
+ (0, import_utils.filterDOMProps)(props, { labelable: true })
86
+ );
87
+ return {
88
+ isPressed,
89
+ // Used to indicate press state for visual
90
+ buttonProps: (0, import_utils.mergeProps)(additionalProps, buttonProps, {
91
+ "aria-haspopup": props["aria-haspopup"],
92
+ "aria-expanded": props["aria-expanded"],
93
+ "aria-controls": props["aria-controls"],
94
+ "aria-pressed": props["aria-pressed"],
95
+ "aria-current": props["aria-current"]
96
+ })
97
+ };
98
+ }
99
+ // Annotate the CommonJS export names for ESM import in node:
100
+ 0 && (module.exports = {
101
+ useAriaButton
102
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,77 @@
1
+ // src/index.ts
2
+ import { filterDOMProps, mergeProps } from "@react-aria/utils";
3
+ import { useFocusable } from "@react-aria/focus";
4
+ import { usePress } from "@react-aria/interactions";
5
+ function useAriaButton(props, ref) {
6
+ let {
7
+ elementType = "button",
8
+ isDisabled,
9
+ onPress,
10
+ onPressStart,
11
+ onPressEnd,
12
+ onPressUp,
13
+ onPressChange,
14
+ // @ts-ignore - undocumented
15
+ preventFocusOnPress,
16
+ // @ts-ignore - undocumented
17
+ allowFocusWhenDisabled,
18
+ onClick,
19
+ href,
20
+ target,
21
+ rel,
22
+ type = "button",
23
+ allowTextSelectionOnPress
24
+ } = props;
25
+ let additionalProps;
26
+ if (elementType === "button") {
27
+ additionalProps = {
28
+ type,
29
+ disabled: isDisabled
30
+ };
31
+ } else {
32
+ additionalProps = {
33
+ role: "button",
34
+ href: elementType === "a" && !isDisabled ? href : void 0,
35
+ target: elementType === "a" ? target : void 0,
36
+ type: elementType === "input" ? type : void 0,
37
+ disabled: elementType === "input" ? isDisabled : void 0,
38
+ "aria-disabled": !isDisabled || elementType === "input" ? void 0 : isDisabled,
39
+ rel: elementType === "a" ? rel : void 0
40
+ };
41
+ }
42
+ let { pressProps, isPressed } = usePress({
43
+ onClick,
44
+ onPressStart,
45
+ onPressEnd,
46
+ onPressUp,
47
+ onPressChange,
48
+ onPress,
49
+ isDisabled,
50
+ preventFocusOnPress,
51
+ allowTextSelectionOnPress,
52
+ ref
53
+ });
54
+ let { focusableProps } = useFocusable(props, ref);
55
+ if (allowFocusWhenDisabled) {
56
+ focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
57
+ }
58
+ let buttonProps = mergeProps(
59
+ focusableProps,
60
+ pressProps,
61
+ filterDOMProps(props, { labelable: true })
62
+ );
63
+ return {
64
+ isPressed,
65
+ // Used to indicate press state for visual
66
+ buttonProps: mergeProps(additionalProps, buttonProps, {
67
+ "aria-haspopup": props["aria-haspopup"],
68
+ "aria-expanded": props["aria-expanded"],
69
+ "aria-controls": props["aria-controls"],
70
+ "aria-pressed": props["aria-pressed"],
71
+ "aria-current": props["aria-current"]
72
+ })
73
+ };
74
+ }
75
+ export {
76
+ useAriaButton
77
+ };
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@vx-oss/heroui-v2-use-aria-button",
3
+ "version": "2.2.21-alpha.0",
4
+ "description": "Internal hook to handle button a11y and events, this is based on react-aria button hook but without the onClick warning",
5
+ "keywords": [
6
+ "use-aria-button"
7
+ ],
8
+ "author": "Vx OSS Devs <oss-developers@vezham.com>",
9
+ "homepage": "https://vezham.com",
10
+ "license": "MIT",
11
+ "main": "dist/index.js",
12
+ "sideEffects": false,
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/vezham/heroui-v2.git",
22
+ "directory": "packages/hooks/use-aria-button"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/vezham/heroui-v2/issues"
26
+ },
27
+ "peerDependencies": {
28
+ "react": ">=18 || >=19.0.0-rc.0"
29
+ },
30
+ "dependencies": {
31
+ "@react-aria/focus": "3.21.2",
32
+ "@react-aria/interactions": "3.25.6",
33
+ "@react-aria/utils": "3.31.0",
34
+ "@react-types/button": "3.14.1",
35
+ "@react-types/shared": "3.32.1"
36
+ },
37
+ "clean-package": "../../../clean-package.config.json",
38
+ "tsup": {
39
+ "clean": true,
40
+ "target": "es2019",
41
+ "format": [
42
+ "cjs",
43
+ "esm"
44
+ ]
45
+ },
46
+ "module": "dist/index.mjs",
47
+ "types": "dist/index.d.ts",
48
+ "exports": {
49
+ ".": {
50
+ "types": "./dist/index.d.ts",
51
+ "import": "./dist/index.mjs",
52
+ "require": "./dist/index.js"
53
+ },
54
+ "./package.json": "./package.json"
55
+ },
56
+ "scripts": {
57
+ "build": "tsup src --dts",
58
+ "build:fast": "tsup src",
59
+ "dev": "pnpm build:fast --watch",
60
+ "clean": "rimraf dist .turbo",
61
+ "typecheck": "tsc --noEmit"
62
+ }
63
+ }