import * as SelectPrimitive from "@radix-ui/react-select"; import { useState } from "react"; import { ChevronDownIcon } from "./Icons"; interface SelectProps { options: T[]; renderOption: (option: T) => React.ReactNode; onSelect: (option: T) => void; isSelected: (option: T) => boolean; value: string | null | undefined; placeholder?: string; disabled?: boolean; } export function Select(props: SelectProps) { const [isOpen, setIsOpen] = useState(false); return (
{props.value ? props.value : props.placeholder}
{props.options.map((option) => { const isSelected = props.isSelected(option); return (
{ props.onSelect(option); setIsOpen(false); }} > {props.renderOption(option)}
); })}
); }