import React, { useState } from "react"; // react-popper import { usePopper } from "react-popper"; // headless ui import { Listbox } from "@headlessui/react"; // icons import { Check, ChevronDown } from "lucide-react"; // types import { ICustomSelectItemProps, ICustomSelectProps } from "./helper"; const CustomSelect = (props: ICustomSelectProps) => { const { customButtonClassName = "", buttonClassName = "", placement, children, className = "", customButton, disabled = false, input = false, label, maxHeight = "md", noChevron = false, onChange, optionsClassName = "", value, width = "auto", } = props; const [referenceElement, setReferenceElement] = useState(null); const [popperElement, setPopperElement] = useState( null, ); const { styles, attributes } = usePopper(referenceElement, popperElement, { placement: placement ?? "bottom-start", }); return ( <> {customButton ? ( ) : ( )}
{children}
); }; const Option = (props: ICustomSelectItemProps) => { const { children, value, className } = props; return ( `cursor-pointer select-none truncate rounded px-1 py-1.5 ${ active || selected ? "bg-custom-background-80" : "" } ${ selected ? "text-custom-text-100" : "text-custom-text-200" } ${className}` } > {({ selected }) => (
{children}
{selected && }
)}
); }; CustomSelect.Option = Option; export { CustomSelect };