import React from "react"; // headless ui import { Listbox, Transition } from "@headlessui/react"; type Props = { title?: string; label?: string; options?: Array<{ display: string; value: any; color?: string; icon?: JSX.Element }>; icon?: JSX.Element; value: any; onChange: (value: any) => void; multiple?: boolean; optionsFontsize?: "sm" | "md" | "lg" | "xl" | "2xl"; className?: string; footerOption?: JSX.Element; }; export const CustomListbox: React.FC = ({ title = "", options, value, onChange, multiple, icon, footerOption, optionsFontsize, className, label, }) => ( {({ 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)?.color && ( o.value === value)?.color, }} /> )}{" "} {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}
)}
);