import { ChevronDownIcon } from "@heroicons/react/solid"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@radix-ui/react-collapsible"; import React from "react"; import classNames from "@lib/classNames"; import { useLocale } from "@lib/hooks/useLocale"; import { RadioArea, RadioAreaGroup } from "@components/ui/form/radio-area/RadioAreaGroup"; type OptionProps = React.OptionHTMLAttributes & { description?: string; }; type RadioAreaSelectProps = React.SelectHTMLAttributes & { options: OptionProps[]; // allow options to be passed programmatically, like options={} }; export const Select = function RadioAreaSelect(props: RadioAreaSelectProps) { const { t } = useLocale(); const { options, disabled = !options.length, // if not explicitly disabled and the options length is empty, disable anyway placeholder = t("select"), } = props; const getLabel = (value: string | ReadonlyArray | number) => options.find((option: OptionProps) => option.value === value)?.label; return ( {getLabel(props.value) ?? placeholder} {options.map((option) => ( {option.label}

{option.description}

))}
); }; export default Select;