import React from 'react'; import Arrow2 from '../assets/dropdown-arrow.svg'; import Edit from '../assets/edit.svg'; import Trash from '../assets/trash.svg'; function Dropdown({ options, selectedValue, onSelect, size = 'w-32', rounded = 'xl', showEdit, onEdit, showDelete, onDelete, placeholder, }: { options: | string[] | { name: string; id: string; type: string }[] | { label: string; value: string }[]; selectedValue: string | { label: string; value: string } | null; onSelect: | ((value: string) => void) | ((value: { name: string; id: string; type: string }) => void) | ((value: { label: string; value: string }) => void); size?: string; rounded?: 'xl' | '3xl'; showEdit?: boolean; onEdit?: (value: { name: string; id: string; type: string }) => void; showDelete?: boolean; onDelete?: (value: string) => void; placeholder?: string; }) { const [isOpen, setIsOpen] = React.useState(false); return (
{isOpen && (
{options.map((option: any, index) => (
{ onSelect(option); setIsOpen(false); }} className="ml-5 flex-1 overflow-hidden overflow-ellipsis whitespace-nowrap py-3 dark:text-light-gray" > {typeof option === 'string' ? option : option.name ? option.name : option.label} {showEdit && onEdit && ( Edit { onEdit({ id: option.id, name: option.name, type: option.type, }); setIsOpen(false); }} /> )} {showDelete && onDelete && ( )}
))}
)}
); } export default Dropdown;