@vx-oss/heroui-v2-use-aria-link 2.2.22-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 +32 -0
- package/README.md +24 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +78 -0
- package/dist/index.mjs +59 -0
- package/package.json +63 -0
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-link
|
|
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-link
|
|
11
|
+
# or
|
|
12
|
+
npm i @vx-oss/heroui-v2-use-aria-link
|
|
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).
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AriaLinkProps } from '@react-types/link';
|
|
2
|
+
import { DOMAttributes, FocusableElement } from '@react-types/shared';
|
|
3
|
+
import { RefObject } from 'react';
|
|
4
|
+
|
|
5
|
+
interface AriaLinkOptions extends AriaLinkProps {
|
|
6
|
+
/** Indicates the element that represents the current item within a container or set of related elements. */
|
|
7
|
+
"aria-current"?: DOMAttributes["aria-current"];
|
|
8
|
+
/** Whether the link is disabled. */
|
|
9
|
+
isDisabled?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The HTML element used to render the link, e.g. 'a', or 'span'.
|
|
12
|
+
* @default 'a'
|
|
13
|
+
*/
|
|
14
|
+
elementType?: string;
|
|
15
|
+
}
|
|
16
|
+
interface LinkAria {
|
|
17
|
+
/** Props for the link element. */
|
|
18
|
+
linkProps: DOMAttributes;
|
|
19
|
+
/** Whether the link is currently pressed. */
|
|
20
|
+
isPressed: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Provides the behavior and accessibility implementation for a link component.
|
|
24
|
+
* A link allows a user to navigate to another page or resource within a web page
|
|
25
|
+
* or application.
|
|
26
|
+
*/
|
|
27
|
+
declare function useAriaLink(props: AriaLinkOptions, ref: RefObject<FocusableElement>): LinkAria;
|
|
28
|
+
|
|
29
|
+
export { type AriaLinkOptions, type LinkAria, useAriaLink };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AriaLinkProps } from '@react-types/link';
|
|
2
|
+
import { DOMAttributes, FocusableElement } from '@react-types/shared';
|
|
3
|
+
import { RefObject } from 'react';
|
|
4
|
+
|
|
5
|
+
interface AriaLinkOptions extends AriaLinkProps {
|
|
6
|
+
/** Indicates the element that represents the current item within a container or set of related elements. */
|
|
7
|
+
"aria-current"?: DOMAttributes["aria-current"];
|
|
8
|
+
/** Whether the link is disabled. */
|
|
9
|
+
isDisabled?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The HTML element used to render the link, e.g. 'a', or 'span'.
|
|
12
|
+
* @default 'a'
|
|
13
|
+
*/
|
|
14
|
+
elementType?: string;
|
|
15
|
+
}
|
|
16
|
+
interface LinkAria {
|
|
17
|
+
/** Props for the link element. */
|
|
18
|
+
linkProps: DOMAttributes;
|
|
19
|
+
/** Whether the link is currently pressed. */
|
|
20
|
+
isPressed: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Provides the behavior and accessibility implementation for a link component.
|
|
24
|
+
* A link allows a user to navigate to another page or resource within a web page
|
|
25
|
+
* or application.
|
|
26
|
+
*/
|
|
27
|
+
declare function useAriaLink(props: AriaLinkOptions, ref: RefObject<FocusableElement>): LinkAria;
|
|
28
|
+
|
|
29
|
+
export { type AriaLinkOptions, type LinkAria, useAriaLink };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
useAriaLink: () => useAriaLink
|
|
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 useAriaLink(props, ref) {
|
|
30
|
+
let {
|
|
31
|
+
elementType = "a",
|
|
32
|
+
onPress,
|
|
33
|
+
onPressStart,
|
|
34
|
+
onPressEnd,
|
|
35
|
+
onClick,
|
|
36
|
+
isDisabled,
|
|
37
|
+
...otherProps
|
|
38
|
+
} = props;
|
|
39
|
+
let linkProps = {};
|
|
40
|
+
if (elementType !== "a") {
|
|
41
|
+
linkProps = {
|
|
42
|
+
role: "link",
|
|
43
|
+
tabIndex: !isDisabled ? 0 : void 0
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
let { focusableProps } = (0, import_focus.useFocusable)(props, ref);
|
|
47
|
+
let { pressProps, isPressed } = (0, import_interactions.usePress)({
|
|
48
|
+
onClick,
|
|
49
|
+
onPress,
|
|
50
|
+
onPressStart,
|
|
51
|
+
onPressEnd,
|
|
52
|
+
isDisabled,
|
|
53
|
+
ref
|
|
54
|
+
});
|
|
55
|
+
let domProps = (0, import_utils.filterDOMProps)(otherProps, { labelable: true, isLink: elementType === "a" });
|
|
56
|
+
let interactionHandlers = (0, import_utils.mergeProps)(focusableProps, pressProps);
|
|
57
|
+
let router = (0, import_utils.useRouter)();
|
|
58
|
+
let routerLinkProps = (0, import_utils.useLinkProps)(props);
|
|
59
|
+
return {
|
|
60
|
+
isPressed,
|
|
61
|
+
// Used to indicate press state for visual
|
|
62
|
+
linkProps: (0, import_utils.mergeProps)(domProps, routerLinkProps, {
|
|
63
|
+
...interactionHandlers,
|
|
64
|
+
...linkProps,
|
|
65
|
+
"aria-disabled": isDisabled || void 0,
|
|
66
|
+
"aria-current": props["aria-current"],
|
|
67
|
+
onClick: (e) => {
|
|
68
|
+
var _a;
|
|
69
|
+
(_a = pressProps.onClick) == null ? void 0 : _a.call(pressProps, e);
|
|
70
|
+
(0, import_utils.handleLinkClick)(e, router, props.href, props.routerOptions);
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
useAriaLink
|
|
78
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
filterDOMProps,
|
|
4
|
+
mergeProps,
|
|
5
|
+
useRouter,
|
|
6
|
+
useLinkProps,
|
|
7
|
+
handleLinkClick
|
|
8
|
+
} from "@react-aria/utils";
|
|
9
|
+
import { useFocusable } from "@react-aria/focus";
|
|
10
|
+
import { usePress } from "@react-aria/interactions";
|
|
11
|
+
function useAriaLink(props, ref) {
|
|
12
|
+
let {
|
|
13
|
+
elementType = "a",
|
|
14
|
+
onPress,
|
|
15
|
+
onPressStart,
|
|
16
|
+
onPressEnd,
|
|
17
|
+
onClick,
|
|
18
|
+
isDisabled,
|
|
19
|
+
...otherProps
|
|
20
|
+
} = props;
|
|
21
|
+
let linkProps = {};
|
|
22
|
+
if (elementType !== "a") {
|
|
23
|
+
linkProps = {
|
|
24
|
+
role: "link",
|
|
25
|
+
tabIndex: !isDisabled ? 0 : void 0
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
let { focusableProps } = useFocusable(props, ref);
|
|
29
|
+
let { pressProps, isPressed } = usePress({
|
|
30
|
+
onClick,
|
|
31
|
+
onPress,
|
|
32
|
+
onPressStart,
|
|
33
|
+
onPressEnd,
|
|
34
|
+
isDisabled,
|
|
35
|
+
ref
|
|
36
|
+
});
|
|
37
|
+
let domProps = filterDOMProps(otherProps, { labelable: true, isLink: elementType === "a" });
|
|
38
|
+
let interactionHandlers = mergeProps(focusableProps, pressProps);
|
|
39
|
+
let router = useRouter();
|
|
40
|
+
let routerLinkProps = useLinkProps(props);
|
|
41
|
+
return {
|
|
42
|
+
isPressed,
|
|
43
|
+
// Used to indicate press state for visual
|
|
44
|
+
linkProps: mergeProps(domProps, routerLinkProps, {
|
|
45
|
+
...interactionHandlers,
|
|
46
|
+
...linkProps,
|
|
47
|
+
"aria-disabled": isDisabled || void 0,
|
|
48
|
+
"aria-current": props["aria-current"],
|
|
49
|
+
onClick: (e) => {
|
|
50
|
+
var _a;
|
|
51
|
+
(_a = pressProps.onClick) == null ? void 0 : _a.call(pressProps, e);
|
|
52
|
+
handleLinkClick(e, router, props.href, props.routerOptions);
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
useAriaLink
|
|
59
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vx-oss/heroui-v2-use-aria-link",
|
|
3
|
+
"version": "2.2.22-alpha.0",
|
|
4
|
+
"description": "Internal hook to handle link a11y and events, this is based on react-aria link hook but without the onClick warning",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"use-aria-link"
|
|
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-link"
|
|
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/link": "3.6.5",
|
|
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
|
+
}
|