({
label,
value,
onSelect,
checkboxes,
isSelected,
isFocused,
endAdornment,
startAdornment,
}: SelectOptionProps)
| 45 | } |
| 46 | |
| 47 | export function SelectOption({ |
| 48 | label, |
| 49 | value, |
| 50 | onSelect, |
| 51 | checkboxes, |
| 52 | isSelected, |
| 53 | isFocused, |
| 54 | endAdornment, |
| 55 | startAdornment, |
| 56 | }: SelectOptionProps) { |
| 57 | const id = useId(); |
| 58 | |
| 59 | return ( |
| 60 | <li |
| 61 | className={clsxMerge(selectOptionVariants({ isSelected, isFocused }))} |
| 62 | role='option' |
| 63 | tabIndex={-1} |
| 64 | onClick={() => { |
| 65 | onSelect?.(value); |
| 66 | }} |
| 67 | onKeyDown={handleKeyboardEvent('Enter', () => { |
| 68 | onSelect?.(value); |
| 69 | })} |
| 70 | aria-selected={isSelected} |
| 71 | aria-labelledby={label ? id : undefined} |
| 72 | > |
| 73 | <div className='flex w-full items-center justify-start gap-2'> |
| 74 | {checkboxes && <Checkbox size='small' checked={isSelected} />} |
| 75 | {startAdornment && ( |
| 76 | <span className='inline-flex size-[18px] items-center justify-center overflow-hidden'>{startAdornment}</span> |
| 77 | )} |
| 78 | {label && ( |
| 79 | <span id={id} className='truncate'> |
| 80 | {label} |
| 81 | </span> |
| 82 | )} |
| 83 | </div> |
| 84 | {endAdornment && <span className='ml-3'>{endAdornment}</span>} |
| 85 | </li> |
| 86 | ); |
| 87 | } |
| 88 | |
| 89 | SelectOption.displayName = 'SelectOption'; |
nothing calls this directly
no test coverage detected