import React from "react"; // headless ui import { Listbox, Transition } from "@headlessui/react"; import { Props } from "./types"; const CustomListbox: React.FC = ({ title = "", options, value, onChange, multiple, icon, width, footerOption, optionsFontsize, className, label, }) => { return ( {({ open }) => ( <> {label && (
{label}
)} {icon ?? null} {Array.isArray(value) ? value.map((v) => options?.find((o) => o.value === v)?.display).join(", ") || `${title}` : options?.find((o) => o.value === value)?.display || `${title}`}
{options ? ( options.length > 0 ? ( options.map((option) => ( `${ selected || (Array.isArray(value) ? value.includes(option.value) : value === option.value) ? "bg-indigo-50 font-medium" : "" } ${ active ? "bg-indigo-50" : "" } relative cursor-pointer select-none p-2 text-gray-900` } value={option.value} > {option.icon} {option.color && ( )} {option.display} )) ) : (

No options

) ) : (

Loading...

)}
{footerOption ?? null}
)}
); }; export default CustomListbox;