import React, { useState } from "react"; import { usePopper } from "react-popper"; import { Placement } from "@popperjs/core"; import { Combobox } from "@headlessui/react"; import { Check, ChevronDown, PlusIcon, Search } from "lucide-react"; // components import { CreateLabelModal } from "components/labels"; // ui import { Tooltip } from "components/ui"; // types import { IIssueLabels } from "types"; type Props = { value: string[]; onChange: (data: string[]) => void; labels: IIssueLabels[]; className?: string; buttonClassName?: string; optionsClassName?: string; maxRender?: number; placement?: Placement; hideDropdownArrow?: boolean; disabled?: boolean; }; export const LabelSelect: React.FC = ({ value, onChange, labels, className = "", buttonClassName = "", optionsClassName = "", maxRender = 2, placement, hideDropdownArrow = false, disabled = false, }) => { const [query, setQuery] = useState(""); const [referenceElement, setReferenceElement] = useState(null); const [popperElement, setPopperElement] = useState(null); const [labelModal, setLabelModal] = useState(false); const { styles, attributes } = usePopper(referenceElement, popperElement, { placement: placement ?? "bottom-start", }); const options = labels?.map((label) => ({ value: label.id, query: label.name, content: (
{label.name}
), })); const filteredOptions = query === "" ? options : options?.filter((option) => option.query.toLowerCase().includes(query.toLowerCase())); const footerOption = ( ); return ( <> {/* TODO: update this logic */} {/* {projectId && ( setLabelModal(false)} projectId={projectId} user={user} /> )} */}
setQuery(e.target.value)} placeholder="Search" displayValue={(assigned: any) => assigned?.name} />
{filteredOptions ? ( filteredOptions.length > 0 ? ( filteredOptions.map((option) => ( `flex items-center justify-between gap-2 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"}` } > {({ selected }) => ( <> {option.content} {selected && } )} )) ) : (

No matching results

) ) : (

Loading...

)}
{footerOption}
); };