change version 1.7.0

This commit is contained in:
2025-02-23 19:58:59 +07:00
parent d6e3946296
commit d73d28a114
15 changed files with 642 additions and 418 deletions

View File

@@ -3,7 +3,7 @@
import { cn } from "@/lib/utils";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { ComponentProps } from "react";
import { ComponentProps, forwardRef } from "react";
type AnchorProps = ComponentProps<typeof Link> & {
absolute?: boolean;
@@ -11,28 +11,28 @@ type AnchorProps = ComponentProps<typeof Link> & {
disabled?: boolean;
};
export default function Anchor({
absolute,
className = "",
activeClassName = "",
disabled,
children,
...props
}: AnchorProps) {
const path = usePathname();
let isMatch = absolute
? props.href.toString().split("/")[1] == path.split("/")[1]
: path === props.href;
const Anchor = forwardRef<HTMLAnchorElement, AnchorProps>(
({ absolute, className = "", activeClassName = "", disabled, children, ...props }, ref) => {
const path = usePathname();
let isMatch = absolute
? props.href.toString().split("/")[1] == path.split("/")[1]
: path === props.href;
if (props.href.toString().includes("http")) isMatch = false;
if (props.href.toString().includes("http")) isMatch = false;
if (disabled)
return (
<div className={cn(className, "cursor-not-allowed")}>{children}</div>
);
if (disabled)
return (
<div className={cn(className, "cursor-not-allowed")}>{children}</div>
<Link ref={ref} className={cn(className, isMatch && activeClassName)} {...props}>
{children}
</Link>
);
return (
<Link className={cn(className, isMatch && activeClassName)} {...props}>
{children}
</Link>
);
}
}
);
// ✅ Tambahkan display name agar tidak error saat build
Anchor.displayName = "Anchor";
export default Anchor;