You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
2 years ago
|
import MenuItemContent from "./DropdownMenuItemContent";
|
||
|
import React from "react";
|
||
2 years ago
|
import {
|
||
2 years ago
|
getDropdownMenuItemClassName,
|
||
2 years ago
|
useHandleDropdownMenuItemClick,
|
||
|
} from "./common";
|
||
|
|
||
2 years ago
|
const DropdownMenuItemLink = ({
|
||
|
icon,
|
||
|
shortcut,
|
||
|
href,
|
||
|
children,
|
||
2 years ago
|
onSelect,
|
||
2 years ago
|
className = "",
|
||
1 year ago
|
selected,
|
||
2 years ago
|
...rest
|
||
2 years ago
|
}: {
|
||
2 years ago
|
href: string;
|
||
2 years ago
|
icon?: JSX.Element;
|
||
|
children: React.ReactNode;
|
||
|
shortcut?: string;
|
||
|
className?: string;
|
||
1 year ago
|
selected?: boolean;
|
||
2 years ago
|
onSelect?: (event: Event) => void;
|
||
2 years ago
|
} & React.AnchorHTMLAttributes<HTMLAnchorElement>) => {
|
||
2 years ago
|
const handleClick = useHandleDropdownMenuItemClick(rest.onClick, onSelect);
|
||
|
|
||
2 years ago
|
return (
|
||
|
<a
|
||
2 years ago
|
{...rest}
|
||
2 years ago
|
href={href}
|
||
|
target="_blank"
|
||
|
rel="noreferrer"
|
||
1 year ago
|
className={getDropdownMenuItemClassName(className, selected)}
|
||
2 years ago
|
title={rest.title ?? rest["aria-label"]}
|
||
2 years ago
|
onClick={handleClick}
|
||
2 years ago
|
>
|
||
|
<MenuItemContent icon={icon} shortcut={shortcut}>
|
||
|
{children}
|
||
|
</MenuItemContent>
|
||
|
</a>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default DropdownMenuItemLink;
|
||
|
DropdownMenuItemLink.displayName = "DropdownMenuItemLink";
|