import { Check, Loader } from "lucide-react"; import { cn } from "../lib/utils"; import { Button } from "../components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "../components/ui/command"; import { Popover, PopoverContent, PopoverTrigger, } from "../components/ui/popover"; import { useState } from "react"; interface Item { value: string | number; label: string; } interface AppSelectBoxProps { items: Item[]; placeholder?: string; haveSearchbar?: boolean; value: string; setValue: React.Dispatch>; loading?: boolean; // New loading prop width?: string; // New width prop disabled?: boolean; title?: string; // Add title prop } export default function AppSelectBox({ haveSearchbar, items, placeholder, value, setValue, loading = false, // Default to false width = "w-[105px]", // Default width disabled = false, title, }: AppSelectBoxProps) { const [open, setOpen] = useState(false); return (
{title && (

{title}

)} {!loading && ( // Only show dropdown content when not loading {haveSearchbar && ( )} آیتمی وجود نداره {items.map((item: Item) => ( { setValue( item.value === value ? "" : item.value.toString() ); setOpen(false); }} > {item.label} ))} )}
); }