import Dropdown, { DropdownProps } from "./Dropdown"; import { FormListItem } from "./FormList"; interface FormDropdownList extends Omit { values: T[]; keyProperty: keyof T; titleProperty: keyof T; descriptionProperty?: keyof T; currentValue: string; onChange(newValue: string): void; } export default function FormDropdownList({ values, keyProperty, titleProperty, descriptionProperty, currentValue, onChange, ...restProps }: FormDropdownList) { const currentValueData = values.find(value => value[keyProperty] === currentValue); return ( {values.map(item => ( onChange(item[keyProperty] as string)} checked={currentValue === item[keyProperty]} description={descriptionProperty && item[descriptionProperty] as string} selected={currentValue === item[keyProperty]} > {item[titleProperty] as string} ))} ) }