import React, { useState } from "react"; // react-popper import { usePopper } from "react-popper"; // headless ui import { Combobox } from "@headlessui/react"; // icons import { ChevronDownIcon } from "@heroicons/react/20/solid"; import { CheckIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline"; import { PriorityIcon } from "components/icons"; // components import { Tooltip } from "components/ui"; // types import { TIssuePriorities } from "types"; import { Placement } from "@popperjs/core"; // constants import { PRIORITIES } from "constants/project"; type Props = { value: TIssuePriorities; onChange: (data: any) => void; className?: string; buttonClassName?: string; optionsClassName?: string; placement?: Placement; hideDropdownArrow?: boolean; disabled?: boolean; }; export const PrioritySelect: React.FC = ({ value, onChange, className = "", buttonClassName = "", optionsClassName = "", placement, hideDropdownArrow = false, disabled = false, }) => { const [query, setQuery] = useState(""); const [referenceElement, setReferenceElement] = useState(null); const [popperElement, setPopperElement] = useState(null); const { styles, attributes } = usePopper(referenceElement, popperElement, { placement: placement ?? "bottom-start", }); const options = PRIORITIES?.map((priority) => ({ value: priority, query: priority, content: (
{priority ?? "None"}
), })); const filteredOptions = query === "" ? options : options?.filter((option) => option.query.toLowerCase().includes(query.toLowerCase())); const selectedOption = value ?? "None"; const label = (
); return (
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...

)}
); };