"use client"; import { Button } from "@app/components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@app/components/ui/command"; import { Popover, PopoverContent, PopoverTrigger } from "@app/components/ui/popover"; import { cn } from "@app/lib/cn"; import { CheckIcon, ChevronsUpDown } from "lucide-react"; import { useState } from "react"; export type DescribedSelectOption = { value: TValue; title: string; description: string; }; type DescribedSelectProps = { options: ReadonlyArray>; value: TValue; onChange: (value: TValue) => void; searchPlaceholder: string; emptyMessage: string; placeholder?: string; disabled?: boolean; className?: string; }; export function DescribedSelect({ options, value, onChange, searchPlaceholder, emptyMessage, placeholder, disabled, className }: DescribedSelectProps) { const [open, setOpen] = useState(false); const selected = options.find((option) => option.value === value); return (
{emptyMessage} {options.map((option) => ( { onChange(option.value); setOpen(false); }} >
{option.title} {option.description}
))}
); }