mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
42 lines
1,011 B
TypeScript
42 lines
1,011 B
TypeScript
import React from "react";
|
|
import {
|
|
getDropdownMenuItemClassName,
|
|
useHandleDropdownMenuItemClick,
|
|
} from "./common";
|
|
import MenuItemContent from "./DropdownMenuItemContent";
|
|
|
|
const DropdownMenuItem = ({
|
|
icon,
|
|
onSelect,
|
|
children,
|
|
shortcut,
|
|
className,
|
|
selected,
|
|
...rest
|
|
}: {
|
|
icon?: JSX.Element;
|
|
onSelect: (event: Event) => void;
|
|
children: React.ReactNode;
|
|
shortcut?: string;
|
|
selected?: boolean;
|
|
className?: string;
|
|
} & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onSelect">) => {
|
|
const handleClick = useHandleDropdownMenuItemClick(rest.onClick, onSelect);
|
|
|
|
return (
|
|
<button
|
|
{...rest}
|
|
onClick={handleClick}
|
|
type="button"
|
|
className={getDropdownMenuItemClassName(className, selected)}
|
|
title={rest.title ?? rest["aria-label"]}
|
|
>
|
|
<MenuItemContent icon={icon} shortcut={shortcut}>
|
|
{children}
|
|
</MenuItemContent>
|
|
</button>
|
|
);
|
|
};
|
|
|
|
export default DropdownMenuItem;
|
|
DropdownMenuItem.displayName = "DropdownMenuItem";
|