import React, { useState } from "react"; // headless ui import { Combobox, Transition } from "@headlessui/react"; // icons import { Search } from "lucide-react"; // types import { Props } from "./types"; export const CustomSelectAttribute: React.FC = ({ attributeDetails, onChange, value, }) => { const [query, setQuery] = useState(""); const selectedOption = attributeDetails.children.find((option) => option.id === value) ?? attributeDetails.children.find((option) => option.is_default); const options = attributeDetails.children.filter((option) => option.display_name.toLowerCase().includes(query.toLowerCase()) ); return ( onChange(val)} className="relative flex-shrink-0 text-left" > {({ open }: { open: boolean }) => ( <> {selectedOption?.display_name ?? "Select"}
setQuery(e.target.value)} placeholder="Type to search..." displayValue={(assigned: any) => assigned?.name} />
{(options ?? []).map((option) => ( {option.display_name} ))}
)}
); };