()
| 7 | import { useSelectContext } from './context'; |
| 8 | |
| 9 | export const SelectButton: FC = () => { |
| 10 | const { |
| 11 | ids: { selectId, listboxId, labelId }, |
| 12 | size, |
| 13 | state, |
| 14 | describedBy, |
| 15 | hasLabel, |
| 16 | hasError, |
| 17 | placeholder, |
| 18 | selected, |
| 19 | open, |
| 20 | disabled, |
| 21 | buttonClassName, |
| 22 | } = useSelectContext(); |
| 23 | return ( |
| 24 | <ListboxButton |
| 25 | id={selectId} |
| 26 | as="button" |
| 27 | type="button" |
| 28 | aria-haspopup="listbox" |
| 29 | aria-expanded={open} |
| 30 | aria-controls={listboxId} |
| 31 | aria-labelledby={hasLabel ? labelId : undefined} |
| 32 | aria-describedby={describedBy} |
| 33 | aria-invalid={hasError || undefined} |
| 34 | aria-errormessage={hasError ? `${selectId}-error` : undefined} |
| 35 | disabled={disabled} |
| 36 | className={cn( |
| 37 | selectVariants({ size, state, className: buttonClassName }), |
| 38 | )} |
| 39 | > |
| 40 | <span className="block truncate">{selected?.label ?? placeholder}</span> |
| 41 | <span className="flex items-center"> |
| 42 | <ChevronDown |
| 43 | size={16} |
| 44 | aria-hidden="true" |
| 45 | className={cn( |
| 46 | 'text-foreground transition-transform', |
| 47 | open && 'rotate-180', |
| 48 | )} |
| 49 | /> |
| 50 | </span> |
| 51 | </ListboxButton> |
| 52 | ); |
| 53 | }; |
nothing calls this directly
no test coverage detected