"use client"; import { Fragment, useState } from "react"; import { Listbox, ListboxButton, ListboxOption, ListboxOptions, Transition } from "@headlessui/react"; import { CheckIcon, ChevronUpDownIcon } from "@heroicons/react/20/solid"; export interface SelectOption { label: string; value: string | number; icon?: React.ReactNode; color?: string; // Cor para badge/ponto } interface CustomSelectProps { options: SelectOption[]; value: string | number; onChange: (value: any) => void; label?: string; placeholder?: string; className?: string; buttonClassName?: string; } export default function CustomSelect({ options, value, onChange, label, placeholder = "Selecione...", className = "", buttonClassName = "" }: CustomSelectProps) { const selected = options.find((opt) => opt.value === value) || null; return (
{label && ( )}
{selected?.color && ( )} {selected?.icon && {selected.icon}} {selected ? selected.label : placeholder} {options.map((option, idx) => ( `relative cursor-pointer select-none py-2.5 pl-10 pr-4 transition-colors ${active ? "bg-zinc-50 dark:bg-zinc-800 text-brand-600 dark:text-brand-400" : "text-zinc-700 dark:text-zinc-300" }` } value={option.value} > {({ selected: isSelected }) => ( <> {option.color && ( )} {option.icon && {option.icon}} {option.label} {isSelected ? ( ) : null} )} ))}
); }