import React from "react"; // headless ui import { Listbox, Transition } from "@headlessui/react"; // icons import { CheckIcon } from "@heroicons/react/20/solid"; 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) => ( `${ active ? "text-white bg-theme" : "text-gray-900" } cursor-pointer select-none relative p-2 rounded-md` } value={option.value} > {({ selected, active }) => ( <> {option.display} {selected || (Array.isArray(value) ? value.includes(option.value) : value === option.value) ? ( ) : null} )} )) ) : (

No options

) ) : (

Loading...

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