import React, { Fragment } from 'react'; import cx from 'classnames'; import { Listbox, Transition } from '@headlessui/react'; import SelectIcon from '../icons/SelectIcon'; export interface Props { className?: string; value?: T; name?: string; displayValue?: string; onChange: (value: T) => void; options: { value: T; label: any }[]; disabled?: boolean; label?: string; placeholder?: string; } const Select = ({ className, value, name, displayValue, options, onChange, disabled = false, label, placeholder, }: Props) => { return (
{ onChange(value); }} disabled={disabled} name={name} > {label && ( {label}: )} {value ? displayValue || value : placeholder} {options.map(opt => ( {opt.label} ))}
); }; export default Select;