import { PopoverAnchor } from "@radix-ui/react-popover"; import { useRef, useState } from "react"; import { DropDownComponentType } from "../../types/components"; import { cn } from "../../utils/utils"; import { default as ForwardedIconComponent } from "../genericIconComponent"; import { Button } from "../ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "../ui/command"; import { Popover, PopoverContent, PopoverContentWithoutPortal, PopoverTrigger, } from "../ui/popover"; export default function Dropdown({ disabled, isLoading, value, options, onSelect, editNode = false, id = "", children, }: DropDownComponentType): JSX.Element { const [open, setOpen] = useState(children ? true : false); const refButton = useRef(null); const PopoverContentDropdown = children ? PopoverContent : PopoverContentWithoutPortal; return ( <> {Object.keys(options)?.length > 0 ? ( <> {} : setOpen}> {children ? ( {children} ) : ( )} No values found. {options?.map((option, id) => ( { onSelect(currentValue); setOpen(false); }} data-testid={`${option}-${id ?? ""}-option`} > {option} ))} ) : ( <> {(!isLoading && (
No parameters are available for display.
)) || (
Loading...
)} )} ); }