Path: blob/1.0-develop/resources/scripts/components/elements/dropdown/DropdownItem.tsx
10262 views
import React, { forwardRef } from 'react';1import { Menu } from '@headlessui/react';2import styles from './style.module.css';3import classNames from 'classnames';45interface Props {6children: React.ReactNode | ((opts: { active: boolean; disabled: boolean }) => JSX.Element);7danger?: boolean;8disabled?: boolean;9className?: string;10icon?: JSX.Element;11onClick?: (e: React.MouseEvent) => void;12}1314const DropdownItem = forwardRef<HTMLAnchorElement, Props>(15({ disabled, danger, className, onClick, children, icon: IconComponent }, ref) => {16return (17<Menu.Item disabled={disabled}>18{({ disabled, active }) => (19<a20ref={ref}21href={'#'}22className={classNames(23styles.menu_item,24{25[styles.danger]: danger,26[styles.disabled]: disabled,27},28className29)}30onClick={onClick}31>32{IconComponent}33{typeof children === 'function' ? children({ disabled, active }) : children}34</a>35)}36</Menu.Item>37);38}39);4041export default DropdownItem;424344