Files
NapCatQQ/.pnpm-store/v3/files/9b/9bda91114904a04387f9f6f20a961b577c1f67d487837651e847739e53fe195a3c341200204609b25bc4d10662ad5f9747aaf0e746e17481d925f6d327d931
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

77 lines
2.3 KiB
Plaintext

"use client";
// src/use-link.ts
import { link } from "@heroui/theme";
import { useAriaLink } from "@heroui/use-aria-link";
import { mapPropsVariants, useProviderContext } from "@heroui/system";
import { useDOMRef } from "@heroui/react-utils";
import { useFocusRing } from "@react-aria/focus";
import { dataAttr, objectToDeps } from "@heroui/shared-utils";
import { useMemo, useCallback } from "react";
import { mergeProps } from "@react-aria/utils";
function useLink(originalProps) {
var _a, _b, _c, _d;
const globalContext = useProviderContext();
const [props, variantProps] = mapPropsVariants(originalProps, link.variantKeys);
const {
ref,
as,
children,
anchorIcon,
isExternal = false,
showAnchorIcon = false,
autoFocus = false,
className,
onPress,
onPressStart,
onPressEnd,
onClick,
...otherProps
} = props;
const Component = as || "a";
const domRef = useDOMRef(ref);
const disableAnimation = (_b = (_a = originalProps == null ? void 0 : originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
const { linkProps } = useAriaLink(
{
...otherProps,
onPress,
onPressStart,
onPressEnd,
onClick,
isDisabled: originalProps.isDisabled,
elementType: `${as}`
},
domRef
);
const { isFocused, isFocusVisible, focusProps } = useFocusRing({
autoFocus
});
if (isExternal) {
otherProps.rel = (_c = otherProps.rel) != null ? _c : "noopener noreferrer";
otherProps.target = (_d = otherProps.target) != null ? _d : "_blank";
}
const classNames = useMemo(
() => link({
...variantProps,
disableAnimation,
className
}),
[objectToDeps(variantProps), disableAnimation, className]
);
const getLinkProps = useCallback(() => {
return {
ref: domRef,
className: classNames,
"data-focus": dataAttr(isFocused),
"data-disabled": dataAttr(originalProps.isDisabled),
"data-focus-visible": dataAttr(isFocusVisible),
...mergeProps(focusProps, linkProps, otherProps)
};
}, [classNames, isFocused, isFocusVisible, focusProps, linkProps, otherProps]);
return { Component, children, anchorIcon, showAnchorIcon, getLinkProps };
}
export {
useLink
};