import { Field } from "react-final-form"; import { Listbox, Transition } from "@headlessui/react"; import { CheckIcon, SelectorIcon } from "@heroicons/react/solid"; import { Fragment } from "react"; import { classNames } from "../../../styles/utils"; interface SelectOption { label: string; value: string; } interface props { name: string; label: string; optionDefaultText: string; options: SelectOption[]; } function SelectField({ name, label, optionDefaultText, options }: props) { return (
( {({ open }) => ( <> {label}
{input.value ? options.find((c) => c.value === input.value)!.label : optionDefaultText} {options.map((opt) => ( classNames( active ? "text-white bg-indigo-600" : "text-gray-900", "cursor-default select-none relative py-2 pl-3 pr-9" ) } value={opt.value} > {({ selected, active }) => ( <> {opt.label} {selected ? ( ) : null} )} ))}
)}
)} />
); } export default SelectField;