@sytechui/link 2.2.26

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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Next UI Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # @sytechui/link
2
+
3
+ Links allow users to click their way from page to page. This component is styled to resemble a hyperlink and semantically renders an `<a>` tag.
4
+
5
+ Please refer to the [documentation](https://heroui.com/docs/components/link) for more information.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ yarn add @sytechui/link
11
+ # or
12
+ npm i @sytechui/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).
@@ -0,0 +1,78 @@
1
+ "use client";
2
+
3
+ // src/use-link.ts
4
+ import { link } from "@sytechui/theme";
5
+ import { useAriaLink } from "@sytechui/use-aria-link";
6
+ import { mapPropsVariants, useProviderContext } from "@sytechui/system";
7
+ import { useDOMRef } from "@sytechui/react-utils";
8
+ import { useFocusRing } from "@react-aria/focus";
9
+ import { dataAttr, objectToDeps, mergeProps } from "@sytechui/shared-utils";
10
+ import { useMemo, useCallback } from "react";
11
+ function useLink(originalProps) {
12
+ var _a, _b, _c, _d;
13
+ const globalContext = useProviderContext();
14
+ const [props, variantProps] = mapPropsVariants(originalProps, link.variantKeys);
15
+ const {
16
+ ref,
17
+ as,
18
+ children,
19
+ anchorIcon,
20
+ isExternal = false,
21
+ showAnchorIcon = false,
22
+ autoFocus = false,
23
+ className,
24
+ onPress,
25
+ onPressStart,
26
+ onPressEnd,
27
+ onClick,
28
+ ...otherProps
29
+ } = props;
30
+ const Component = as || "a";
31
+ const domRef = useDOMRef(ref);
32
+ const disableAnimation = (_b = (_a = originalProps == null ? void 0 : originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
33
+ const { linkProps } = useAriaLink(
34
+ {
35
+ ...otherProps,
36
+ onPress,
37
+ onPressStart,
38
+ onPressEnd,
39
+ // @ts-ignore React Aria Link does accept onClick as a prop but it's not in the types
40
+ onClick,
41
+ isDisabled: originalProps.isDisabled,
42
+ elementType: `${as}`
43
+ },
44
+ domRef
45
+ );
46
+ const { isFocused, isFocusVisible, focusProps } = useFocusRing({
47
+ autoFocus
48
+ });
49
+ if (isExternal) {
50
+ otherProps.rel = (_c = otherProps.rel) != null ? _c : "noopener noreferrer";
51
+ otherProps.target = (_d = otherProps.target) != null ? _d : "_blank";
52
+ }
53
+ const styles = useMemo(
54
+ () => link({
55
+ ...variantProps,
56
+ disableAnimation,
57
+ className
58
+ }),
59
+ [objectToDeps(variantProps), disableAnimation, className]
60
+ );
61
+ const getLinkProps = useCallback(() => {
62
+ return {
63
+ ref: domRef,
64
+ className: styles,
65
+ "data-focus": dataAttr(isFocused),
66
+ "data-disabled": dataAttr(originalProps.isDisabled),
67
+ "data-focus-visible": dataAttr(isFocusVisible),
68
+ ...mergeProps(focusProps, linkProps, otherProps, {
69
+ href: linkProps.href
70
+ })
71
+ };
72
+ }, [styles, isFocused, isFocusVisible, focusProps, linkProps, otherProps]);
73
+ return { Component, children, anchorIcon, showAnchorIcon, getLinkProps };
74
+ }
75
+
76
+ export {
77
+ useLink
78
+ };
@@ -0,0 +1,29 @@
1
+ "use client";
2
+
3
+ // src/link-icon.tsx
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ var LinkIcon = () => /* @__PURE__ */ jsxs(
6
+ "svg",
7
+ {
8
+ "aria-hidden": "true",
9
+ className: "flex mx-1 text-current self-center",
10
+ fill: "none",
11
+ height: "1em",
12
+ shapeRendering: "geometricPrecision",
13
+ stroke: "currentColor",
14
+ strokeLinecap: "round",
15
+ strokeLinejoin: "round",
16
+ strokeWidth: "1.5",
17
+ viewBox: "0 0 24 24",
18
+ width: "1em",
19
+ children: [
20
+ /* @__PURE__ */ jsx("path", { d: "M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6" }),
21
+ /* @__PURE__ */ jsx("path", { d: "M15 3h6v6" }),
22
+ /* @__PURE__ */ jsx("path", { d: "M10 14L21 3" })
23
+ ]
24
+ }
25
+ );
26
+
27
+ export {
28
+ LinkIcon
29
+ };
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import {
3
+ useLink
4
+ } from "./chunk-3YUB6UMD.mjs";
5
+
6
+ // src/link.tsx
7
+ import { forwardRef } from "@sytechui/system";
8
+ import { LinkIcon } from "@sytechui/shared-icons";
9
+ import { linkAnchorClasses } from "@sytechui/theme";
10
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
+ var Link = forwardRef((props, ref) => {
12
+ const {
13
+ Component,
14
+ children,
15
+ showAnchorIcon,
16
+ anchorIcon = /* @__PURE__ */ jsx(LinkIcon, { className: linkAnchorClasses }),
17
+ getLinkProps
18
+ } = useLink({
19
+ ref,
20
+ ...props
21
+ });
22
+ return /* @__PURE__ */ jsx(Component, { ...getLinkProps(), children: /* @__PURE__ */ jsxs(Fragment, { children: [
23
+ children,
24
+ showAnchorIcon && anchorIcon
25
+ ] }) });
26
+ });
27
+ Link.displayName = "HeroUI.Link";
28
+ var link_default = Link;
29
+
30
+ export {
31
+ link_default
32
+ };
@@ -0,0 +1,9 @@
1
+ export { default as Link, LinkProps } from './link.mjs';
2
+ export { useLink } from './use-link.mjs';
3
+ export { LinkIcon } from './link-icon.mjs';
4
+ import '@sytechui/system';
5
+ import 'react';
6
+ import '@react-types/link';
7
+ import '@sytechui/theme';
8
+ import '@sytechui/react-utils';
9
+ import 'react/jsx-runtime';
@@ -0,0 +1,9 @@
1
+ export { default as Link, LinkProps } from './link.js';
2
+ export { useLink } from './use-link.js';
3
+ export { LinkIcon } from './link-icon.js';
4
+ import '@sytechui/system';
5
+ import 'react';
6
+ import '@react-types/link';
7
+ import '@sytechui/theme';
8
+ import '@sytechui/react-utils';
9
+ import 'react/jsx-runtime';
package/dist/index.js ADDED
@@ -0,0 +1,157 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ Link: () => link_default,
25
+ LinkIcon: () => LinkIcon2,
26
+ useLink: () => useLink
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+
30
+ // src/link.tsx
31
+ var import_system2 = require("@sytechui/system");
32
+ var import_shared_icons = require("@sytechui/shared-icons");
33
+ var import_theme2 = require("@sytechui/theme");
34
+
35
+ // src/use-link.ts
36
+ var import_theme = require("@sytechui/theme");
37
+ var import_use_aria_link = require("@sytechui/use-aria-link");
38
+ var import_system = require("@sytechui/system");
39
+ var import_react_utils = require("@sytechui/react-utils");
40
+ var import_focus = require("@react-aria/focus");
41
+ var import_shared_utils = require("@sytechui/shared-utils");
42
+ var import_react = require("react");
43
+ function useLink(originalProps) {
44
+ var _a, _b, _c, _d;
45
+ const globalContext = (0, import_system.useProviderContext)();
46
+ const [props, variantProps] = (0, import_system.mapPropsVariants)(originalProps, import_theme.link.variantKeys);
47
+ const {
48
+ ref,
49
+ as,
50
+ children,
51
+ anchorIcon,
52
+ isExternal = false,
53
+ showAnchorIcon = false,
54
+ autoFocus = false,
55
+ className,
56
+ onPress,
57
+ onPressStart,
58
+ onPressEnd,
59
+ onClick,
60
+ ...otherProps
61
+ } = props;
62
+ const Component = as || "a";
63
+ const domRef = (0, import_react_utils.useDOMRef)(ref);
64
+ const disableAnimation = (_b = (_a = originalProps == null ? void 0 : originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
65
+ const { linkProps } = (0, import_use_aria_link.useAriaLink)(
66
+ {
67
+ ...otherProps,
68
+ onPress,
69
+ onPressStart,
70
+ onPressEnd,
71
+ // @ts-ignore React Aria Link does accept onClick as a prop but it's not in the types
72
+ onClick,
73
+ isDisabled: originalProps.isDisabled,
74
+ elementType: `${as}`
75
+ },
76
+ domRef
77
+ );
78
+ const { isFocused, isFocusVisible, focusProps } = (0, import_focus.useFocusRing)({
79
+ autoFocus
80
+ });
81
+ if (isExternal) {
82
+ otherProps.rel = (_c = otherProps.rel) != null ? _c : "noopener noreferrer";
83
+ otherProps.target = (_d = otherProps.target) != null ? _d : "_blank";
84
+ }
85
+ const styles = (0, import_react.useMemo)(
86
+ () => (0, import_theme.link)({
87
+ ...variantProps,
88
+ disableAnimation,
89
+ className
90
+ }),
91
+ [(0, import_shared_utils.objectToDeps)(variantProps), disableAnimation, className]
92
+ );
93
+ const getLinkProps = (0, import_react.useCallback)(() => {
94
+ return {
95
+ ref: domRef,
96
+ className: styles,
97
+ "data-focus": (0, import_shared_utils.dataAttr)(isFocused),
98
+ "data-disabled": (0, import_shared_utils.dataAttr)(originalProps.isDisabled),
99
+ "data-focus-visible": (0, import_shared_utils.dataAttr)(isFocusVisible),
100
+ ...(0, import_shared_utils.mergeProps)(focusProps, linkProps, otherProps, {
101
+ href: linkProps.href
102
+ })
103
+ };
104
+ }, [styles, isFocused, isFocusVisible, focusProps, linkProps, otherProps]);
105
+ return { Component, children, anchorIcon, showAnchorIcon, getLinkProps };
106
+ }
107
+
108
+ // src/link.tsx
109
+ var import_jsx_runtime = require("react/jsx-runtime");
110
+ var Link = (0, import_system2.forwardRef)((props, ref) => {
111
+ const {
112
+ Component,
113
+ children,
114
+ showAnchorIcon,
115
+ anchorIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_icons.LinkIcon, { className: import_theme2.linkAnchorClasses }),
116
+ getLinkProps
117
+ } = useLink({
118
+ ref,
119
+ ...props
120
+ });
121
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ...getLinkProps(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
122
+ children,
123
+ showAnchorIcon && anchorIcon
124
+ ] }) });
125
+ });
126
+ Link.displayName = "HeroUI.Link";
127
+ var link_default = Link;
128
+
129
+ // src/link-icon.tsx
130
+ var import_jsx_runtime2 = require("react/jsx-runtime");
131
+ var LinkIcon2 = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
132
+ "svg",
133
+ {
134
+ "aria-hidden": "true",
135
+ className: "flex mx-1 text-current self-center",
136
+ fill: "none",
137
+ height: "1em",
138
+ shapeRendering: "geometricPrecision",
139
+ stroke: "currentColor",
140
+ strokeLinecap: "round",
141
+ strokeLinejoin: "round",
142
+ strokeWidth: "1.5",
143
+ viewBox: "0 0 24 24",
144
+ width: "1em",
145
+ children: [
146
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6" }),
147
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M15 3h6v6" }),
148
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M10 14L21 3" })
149
+ ]
150
+ }
151
+ );
152
+ // Annotate the CommonJS export names for ESM import in node:
153
+ 0 && (module.exports = {
154
+ Link,
155
+ LinkIcon,
156
+ useLink
157
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import {
3
+ LinkIcon
4
+ } from "./chunk-7LH7ZARU.mjs";
5
+ import {
6
+ link_default
7
+ } from "./chunk-N4RYZLGW.mjs";
8
+ import {
9
+ useLink
10
+ } from "./chunk-3YUB6UMD.mjs";
11
+ export {
12
+ link_default as Link,
13
+ LinkIcon,
14
+ useLink
15
+ };
@@ -0,0 +1,5 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ declare const LinkIcon: () => react_jsx_runtime.JSX.Element;
4
+
5
+ export { LinkIcon };
@@ -0,0 +1,5 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ declare const LinkIcon: () => react_jsx_runtime.JSX.Element;
4
+
5
+ export { LinkIcon };
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/link-icon.tsx
22
+ var link_icon_exports = {};
23
+ __export(link_icon_exports, {
24
+ LinkIcon: () => LinkIcon
25
+ });
26
+ module.exports = __toCommonJS(link_icon_exports);
27
+ var import_jsx_runtime = require("react/jsx-runtime");
28
+ var LinkIcon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
29
+ "svg",
30
+ {
31
+ "aria-hidden": "true",
32
+ className: "flex mx-1 text-current self-center",
33
+ fill: "none",
34
+ height: "1em",
35
+ shapeRendering: "geometricPrecision",
36
+ stroke: "currentColor",
37
+ strokeLinecap: "round",
38
+ strokeLinejoin: "round",
39
+ strokeWidth: "1.5",
40
+ viewBox: "0 0 24 24",
41
+ width: "1em",
42
+ children: [
43
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6" }),
44
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M15 3h6v6" }),
45
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 14L21 3" })
46
+ ]
47
+ }
48
+ );
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ LinkIcon
52
+ });
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import {
3
+ LinkIcon
4
+ } from "./chunk-7LH7ZARU.mjs";
5
+ export {
6
+ LinkIcon
7
+ };
@@ -0,0 +1,12 @@
1
+ import * as _sytechui_system from '@sytechui/system';
2
+ import { UseLinkProps } from './use-link.mjs';
3
+ import 'react';
4
+ import '@react-types/link';
5
+ import '@sytechui/theme';
6
+ import '@sytechui/react-utils';
7
+
8
+ interface LinkProps extends UseLinkProps {
9
+ }
10
+ declare const Link: _sytechui_system.InternalForwardRefRenderFunction<"a", LinkProps, never>;
11
+
12
+ export { type LinkProps, Link as default };
package/dist/link.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import * as _sytechui_system from '@sytechui/system';
2
+ import { UseLinkProps } from './use-link.js';
3
+ import 'react';
4
+ import '@react-types/link';
5
+ import '@sytechui/theme';
6
+ import '@sytechui/react-utils';
7
+
8
+ interface LinkProps extends UseLinkProps {
9
+ }
10
+ declare const Link: _sytechui_system.InternalForwardRefRenderFunction<"a", LinkProps, never>;
11
+
12
+ export { type LinkProps, Link as default };
package/dist/link.js ADDED
@@ -0,0 +1,123 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/link.tsx
22
+ var link_exports = {};
23
+ __export(link_exports, {
24
+ default: () => link_default
25
+ });
26
+ module.exports = __toCommonJS(link_exports);
27
+ var import_system2 = require("@sytechui/system");
28
+ var import_shared_icons = require("@sytechui/shared-icons");
29
+ var import_theme2 = require("@sytechui/theme");
30
+
31
+ // src/use-link.ts
32
+ var import_theme = require("@sytechui/theme");
33
+ var import_use_aria_link = require("@sytechui/use-aria-link");
34
+ var import_system = require("@sytechui/system");
35
+ var import_react_utils = require("@sytechui/react-utils");
36
+ var import_focus = require("@react-aria/focus");
37
+ var import_shared_utils = require("@sytechui/shared-utils");
38
+ var import_react = require("react");
39
+ function useLink(originalProps) {
40
+ var _a, _b, _c, _d;
41
+ const globalContext = (0, import_system.useProviderContext)();
42
+ const [props, variantProps] = (0, import_system.mapPropsVariants)(originalProps, import_theme.link.variantKeys);
43
+ const {
44
+ ref,
45
+ as,
46
+ children,
47
+ anchorIcon,
48
+ isExternal = false,
49
+ showAnchorIcon = false,
50
+ autoFocus = false,
51
+ className,
52
+ onPress,
53
+ onPressStart,
54
+ onPressEnd,
55
+ onClick,
56
+ ...otherProps
57
+ } = props;
58
+ const Component = as || "a";
59
+ const domRef = (0, import_react_utils.useDOMRef)(ref);
60
+ const disableAnimation = (_b = (_a = originalProps == null ? void 0 : originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
61
+ const { linkProps } = (0, import_use_aria_link.useAriaLink)(
62
+ {
63
+ ...otherProps,
64
+ onPress,
65
+ onPressStart,
66
+ onPressEnd,
67
+ // @ts-ignore React Aria Link does accept onClick as a prop but it's not in the types
68
+ onClick,
69
+ isDisabled: originalProps.isDisabled,
70
+ elementType: `${as}`
71
+ },
72
+ domRef
73
+ );
74
+ const { isFocused, isFocusVisible, focusProps } = (0, import_focus.useFocusRing)({
75
+ autoFocus
76
+ });
77
+ if (isExternal) {
78
+ otherProps.rel = (_c = otherProps.rel) != null ? _c : "noopener noreferrer";
79
+ otherProps.target = (_d = otherProps.target) != null ? _d : "_blank";
80
+ }
81
+ const styles = (0, import_react.useMemo)(
82
+ () => (0, import_theme.link)({
83
+ ...variantProps,
84
+ disableAnimation,
85
+ className
86
+ }),
87
+ [(0, import_shared_utils.objectToDeps)(variantProps), disableAnimation, className]
88
+ );
89
+ const getLinkProps = (0, import_react.useCallback)(() => {
90
+ return {
91
+ ref: domRef,
92
+ className: styles,
93
+ "data-focus": (0, import_shared_utils.dataAttr)(isFocused),
94
+ "data-disabled": (0, import_shared_utils.dataAttr)(originalProps.isDisabled),
95
+ "data-focus-visible": (0, import_shared_utils.dataAttr)(isFocusVisible),
96
+ ...(0, import_shared_utils.mergeProps)(focusProps, linkProps, otherProps, {
97
+ href: linkProps.href
98
+ })
99
+ };
100
+ }, [styles, isFocused, isFocusVisible, focusProps, linkProps, otherProps]);
101
+ return { Component, children, anchorIcon, showAnchorIcon, getLinkProps };
102
+ }
103
+
104
+ // src/link.tsx
105
+ var import_jsx_runtime = require("react/jsx-runtime");
106
+ var Link = (0, import_system2.forwardRef)((props, ref) => {
107
+ const {
108
+ Component,
109
+ children,
110
+ showAnchorIcon,
111
+ anchorIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_icons.LinkIcon, { className: import_theme2.linkAnchorClasses }),
112
+ getLinkProps
113
+ } = useLink({
114
+ ref,
115
+ ...props
116
+ });
117
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ...getLinkProps(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
118
+ children,
119
+ showAnchorIcon && anchorIcon
120
+ ] }) });
121
+ });
122
+ Link.displayName = "HeroUI.Link";
123
+ var link_default = Link;
package/dist/link.mjs ADDED
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import {
3
+ link_default
4
+ } from "./chunk-N4RYZLGW.mjs";
5
+ import "./chunk-3YUB6UMD.mjs";
6
+ export {
7
+ link_default as default
8
+ };
@@ -0,0 +1,46 @@
1
+ import * as react from 'react';
2
+ import { MouseEventHandler } from 'react';
3
+ import * as _sytechui_system from '@sytechui/system';
4
+ import { HTMLHeroUIProps, PropGetter } from '@sytechui/system';
5
+ import { AriaLinkProps } from '@react-types/link';
6
+ import { LinkVariantProps } from '@sytechui/theme';
7
+ import { ReactRef } from '@sytechui/react-utils';
8
+
9
+ interface Props extends HTMLHeroUIProps<"a">, LinkVariantProps {
10
+ /**
11
+ * Ref to the DOM node.
12
+ */
13
+ ref?: ReactRef<HTMLAnchorElement | null>;
14
+ /**
15
+ * Whether the link is external.
16
+ * @default false
17
+ */
18
+ isExternal?: boolean;
19
+ /**
20
+ * Whether to show the icon when the link is external.
21
+ * @default false
22
+ */
23
+ showAnchorIcon?: boolean;
24
+ /**
25
+ * The icon to display right after the link.
26
+ * @default <LinkIcon />
27
+ */
28
+ anchorIcon?: React.ReactNode;
29
+ /**
30
+ * The native link click event handler.
31
+ * use `onPress` instead.
32
+ * @deprecated
33
+ */
34
+ onClick?: MouseEventHandler<HTMLAnchorElement>;
35
+ }
36
+ type UseLinkProps = Props & AriaLinkProps;
37
+ declare function useLink(originalProps: UseLinkProps): {
38
+ Component: _sytechui_system.As<any>;
39
+ children: react.ReactNode;
40
+ anchorIcon: react.ReactNode;
41
+ showAnchorIcon: boolean;
42
+ getLinkProps: PropGetter;
43
+ };
44
+ type UseLinkReturn = ReturnType<typeof useLink>;
45
+
46
+ export { type UseLinkProps, type UseLinkReturn, useLink };
@@ -0,0 +1,46 @@
1
+ import * as react from 'react';
2
+ import { MouseEventHandler } from 'react';
3
+ import * as _sytechui_system from '@sytechui/system';
4
+ import { HTMLHeroUIProps, PropGetter } from '@sytechui/system';
5
+ import { AriaLinkProps } from '@react-types/link';
6
+ import { LinkVariantProps } from '@sytechui/theme';
7
+ import { ReactRef } from '@sytechui/react-utils';
8
+
9
+ interface Props extends HTMLHeroUIProps<"a">, LinkVariantProps {
10
+ /**
11
+ * Ref to the DOM node.
12
+ */
13
+ ref?: ReactRef<HTMLAnchorElement | null>;
14
+ /**
15
+ * Whether the link is external.
16
+ * @default false
17
+ */
18
+ isExternal?: boolean;
19
+ /**
20
+ * Whether to show the icon when the link is external.
21
+ * @default false
22
+ */
23
+ showAnchorIcon?: boolean;
24
+ /**
25
+ * The icon to display right after the link.
26
+ * @default <LinkIcon />
27
+ */
28
+ anchorIcon?: React.ReactNode;
29
+ /**
30
+ * The native link click event handler.
31
+ * use `onPress` instead.
32
+ * @deprecated
33
+ */
34
+ onClick?: MouseEventHandler<HTMLAnchorElement>;
35
+ }
36
+ type UseLinkProps = Props & AriaLinkProps;
37
+ declare function useLink(originalProps: UseLinkProps): {
38
+ Component: _sytechui_system.As<any>;
39
+ children: react.ReactNode;
40
+ anchorIcon: react.ReactNode;
41
+ showAnchorIcon: boolean;
42
+ getLinkProps: PropGetter;
43
+ };
44
+ type UseLinkReturn = ReturnType<typeof useLink>;
45
+
46
+ export { type UseLinkProps, type UseLinkReturn, useLink };
@@ -0,0 +1,101 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/use-link.ts
22
+ var use_link_exports = {};
23
+ __export(use_link_exports, {
24
+ useLink: () => useLink
25
+ });
26
+ module.exports = __toCommonJS(use_link_exports);
27
+ var import_theme = require("@sytechui/theme");
28
+ var import_use_aria_link = require("@sytechui/use-aria-link");
29
+ var import_system = require("@sytechui/system");
30
+ var import_react_utils = require("@sytechui/react-utils");
31
+ var import_focus = require("@react-aria/focus");
32
+ var import_shared_utils = require("@sytechui/shared-utils");
33
+ var import_react = require("react");
34
+ function useLink(originalProps) {
35
+ var _a, _b, _c, _d;
36
+ const globalContext = (0, import_system.useProviderContext)();
37
+ const [props, variantProps] = (0, import_system.mapPropsVariants)(originalProps, import_theme.link.variantKeys);
38
+ const {
39
+ ref,
40
+ as,
41
+ children,
42
+ anchorIcon,
43
+ isExternal = false,
44
+ showAnchorIcon = false,
45
+ autoFocus = false,
46
+ className,
47
+ onPress,
48
+ onPressStart,
49
+ onPressEnd,
50
+ onClick,
51
+ ...otherProps
52
+ } = props;
53
+ const Component = as || "a";
54
+ const domRef = (0, import_react_utils.useDOMRef)(ref);
55
+ const disableAnimation = (_b = (_a = originalProps == null ? void 0 : originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
56
+ const { linkProps } = (0, import_use_aria_link.useAriaLink)(
57
+ {
58
+ ...otherProps,
59
+ onPress,
60
+ onPressStart,
61
+ onPressEnd,
62
+ // @ts-ignore React Aria Link does accept onClick as a prop but it's not in the types
63
+ onClick,
64
+ isDisabled: originalProps.isDisabled,
65
+ elementType: `${as}`
66
+ },
67
+ domRef
68
+ );
69
+ const { isFocused, isFocusVisible, focusProps } = (0, import_focus.useFocusRing)({
70
+ autoFocus
71
+ });
72
+ if (isExternal) {
73
+ otherProps.rel = (_c = otherProps.rel) != null ? _c : "noopener noreferrer";
74
+ otherProps.target = (_d = otherProps.target) != null ? _d : "_blank";
75
+ }
76
+ const styles = (0, import_react.useMemo)(
77
+ () => (0, import_theme.link)({
78
+ ...variantProps,
79
+ disableAnimation,
80
+ className
81
+ }),
82
+ [(0, import_shared_utils.objectToDeps)(variantProps), disableAnimation, className]
83
+ );
84
+ const getLinkProps = (0, import_react.useCallback)(() => {
85
+ return {
86
+ ref: domRef,
87
+ className: styles,
88
+ "data-focus": (0, import_shared_utils.dataAttr)(isFocused),
89
+ "data-disabled": (0, import_shared_utils.dataAttr)(originalProps.isDisabled),
90
+ "data-focus-visible": (0, import_shared_utils.dataAttr)(isFocusVisible),
91
+ ...(0, import_shared_utils.mergeProps)(focusProps, linkProps, otherProps, {
92
+ href: linkProps.href
93
+ })
94
+ };
95
+ }, [styles, isFocused, isFocusVisible, focusProps, linkProps, otherProps]);
96
+ return { Component, children, anchorIcon, showAnchorIcon, getLinkProps };
97
+ }
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ useLink
101
+ });
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import {
3
+ useLink
4
+ } from "./chunk-3YUB6UMD.mjs";
5
+ export {
6
+ useLink
7
+ };
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@sytechui/link",
3
+ "version": "2.2.26",
4
+ "description": "Links allow users to click their way from page to page. This component is styled to resemble a hyperlink and semantically renders an &lt;a&gt;",
5
+ "keywords": [
6
+ "link"
7
+ ],
8
+ "author": "HeroUI <support@heroui.com>",
9
+ "homepage": "https://heroui.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/heroui-inc/heroui.git",
22
+ "directory": "packages/components/link"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/heroui-inc/heroui/issues"
26
+ },
27
+ "peerDependencies": {
28
+ "react": ">=18 || >=19.0.0-rc.0",
29
+ "react-dom": ">=18 || >=19.0.0-rc.0",
30
+ "@sytechui/theme": ">=2.4.24",
31
+ "@sytechui/system": ">=2.4.18"
32
+ },
33
+ "dependencies": {
34
+ "@react-aria/focus": "3.21.5",
35
+ "@react-types/link": "3.6.7",
36
+ "@sytechui/shared-utils": "2.1.12",
37
+ "@sytechui/shared-icons": "2.1.10",
38
+ "@sytechui/react-utils": "2.1.14",
39
+ "@sytechui/use-aria-link": "2.2.23"
40
+ },
41
+ "clean-package": "../../../clean-package.config.json",
42
+ "module": "dist/index.mjs",
43
+ "types": "dist/index.d.ts",
44
+ "exports": {
45
+ ".": {
46
+ "types": "./dist/index.d.ts",
47
+ "import": "./dist/index.mjs",
48
+ "require": "./dist/index.js"
49
+ },
50
+ "./package.json": "./package.json"
51
+ },
52
+ "scripts": {
53
+ "build": "tsup src --dts",
54
+ "dev": "pnpm build:fast --watch",
55
+ "clean": "rimraf dist .turbo",
56
+ "typecheck": "tsc --noEmit",
57
+ "build:fast": "tsup src"
58
+ }
59
+ }