mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
30 lines
738 B
TypeScript
30 lines
738 B
TypeScript
import React from "react";
|
|
import Link, { LinkProps } from "next/link";
|
|
|
|
type MakeOptional<Type, Key extends keyof Type> = Omit<Type, Key> &
|
|
Partial<Pick<Type, Key>>;
|
|
|
|
type RefineLinkProps = (
|
|
| (MakeOptional<LinkProps, "href"> & {
|
|
to: LinkProps["href"];
|
|
})
|
|
| LinkProps
|
|
) & {
|
|
children: React.ReactNode;
|
|
ref?: React.Ref<HTMLAnchorElement>;
|
|
};
|
|
|
|
export const RefineLink: React.FC<RefineLinkProps> = React.forwardRef(
|
|
({ children, ...props }, ref) => (
|
|
<Link
|
|
ref={ref}
|
|
href={"to" in props ? props.to : props.href}
|
|
legacyBehavior={false}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</Link>
|
|
),
|
|
);
|
|
RefineLink.displayName = "RefineLink";
|