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 { DropdownProps } from "./types"; export type CustomSelectProps = DropdownProps & { children: React.ReactNode; value: any; onChange: any; }; const CustomSelect = ({ customButtonClassName = "", buttonClassName = "", placement, children, className = "", customButton, disabled = false, input = false, label, maxHeight = "md", noChevron = false, onChange, optionsClassName = "", value, width = "auto", }: CustomSelectProps) => { const [referenceElement, setReferenceElement] = useState(null); const [popperElement, setPopperElement] = useState(null); const { styles, attributes } = usePopper(referenceElement, popperElement, { placement: placement ?? "bottom-start", }); return ( <> {customButton ? ( ) : ( )}
{children}
); }; type OptionProps = { children: React.ReactNode; value: any; className?: string; }; const Option: React.FC = ({ children, value, className }) => ( `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 };