// @flow
import * as React from "react";
import cn from "classnames";
import { Icon, Badge } from "../";
type Props = {|
+children?: React.Node,
+className?: string,
/**
* Display an Icon to the left of DropdownItem content
*/
+icon?: string,
/**
* The content of the DropdownItem if children is not used
*/
+value?: string,
/**
* Display a badge with this content to the right of DropdownItem content
*/
+badge?: string,
/**
* The type/color of Badge to be displayed
*/
+badgeType?: string,
/**
* Where the user should be taken on click.
* By default this will be passed as the 'href' prop to the tag,
* but to the RootComponent it will be a 'to' prop instead
*/
+to?: string,
/**
* A component to be used instead of an tag
*/
+RootComponent?: React.ElementType,
/**
* onClick handler
*/
+onClick?: (event: SyntheticMouseEvent<*>) => mixed,
/**
* Whether or not to pass "exact" property to underlying NavLink component
*/
+useExact?: boolean,
|};
/**
* An individual item that should be contained within a Dropdown.Menu
*/
function DropdownItem({
className,
icon,
value,
children,
badge,
badgeType,
to,
RootComponent,
onClick,
useExact,
}: Props): React.Node {
const classes = cn({ "dropdown-item": true }, className);
const childrenForAll = (
{badge && (
{badge}
)}
{icon && (
{" "}
)}
{value}
{children}
);
return RootComponent ? (
{childrenForAll}
) : (
{childrenForAll}
);
}
DropdownItem.displayName = "Dropdown.Item";
/** @component */
export default DropdownItem;