({ isOpen, isFocused, isDisabled, size, placeholder, icon, ref }: SelectValueProps)
| 35 | } |
| 36 | |
| 37 | const SelectValue = ({ isOpen, isFocused, isDisabled, size, placeholder, icon, ref }: SelectValueProps) => { |
| 38 | return ( |
| 39 | <AriaButton |
| 40 | ref={ref} |
| 41 | className={cx( |
| 42 | "relative flex w-full cursor-pointer items-center rounded-lg bg-primary shadow-xs ring-1 ring-primary outline-hidden transition duration-100 ease-linear ring-inset", |
| 43 | (isFocused || isOpen) && "ring-2 ring-brand", |
| 44 | isDisabled && "cursor-not-allowed opacity-50", |
| 45 | )} |
| 46 | > |
| 47 | <AriaSelectValue<SelectItemType> |
| 48 | className={(state) => |
| 49 | cx( |
| 50 | "flex h-max w-full items-center justify-start truncate text-left align-middle", |
| 51 | |
| 52 | sizes[size].root, |
| 53 | |
| 54 | // With icon |
| 55 | (state.selectedItems[0]?.icon || icon) && sizes[size].withIcon, |
| 56 | |
| 57 | // Icon styles |
| 58 | "*:data-icon:shrink-0 *:data-icon:text-fg-quaternary", |
| 59 | ) |
| 60 | } |
| 61 | > |
| 62 | {(state) => { |
| 63 | const selectedItem = state.selectedItems[0]; |
| 64 | const Icon = selectedItem?.icon || icon; |
| 65 | |
| 66 | return ( |
| 67 | <> |
| 68 | {selectedItem?.avatarUrl ? ( |
| 69 | <Avatar size="xs" src={selectedItem.avatarUrl} alt={selectedItem.label} className={cx(size === "sm" && "size-5")} /> |
| 70 | ) : isReactComponent(Icon) ? ( |
| 71 | <Icon data-icon aria-hidden="true" /> |
| 72 | ) : isValidElement(Icon) ? ( |
| 73 | Icon |
| 74 | ) : null} |
| 75 | |
| 76 | {selectedItem ? ( |
| 77 | <section className={cx("flex w-full truncate", sizes[size].textContainer)}> |
| 78 | <p className={cx("truncate font-medium text-primary", sizes[size].text)}>{selectedItem?.label}</p> |
| 79 | {selectedItem?.supportingText && <p className={cx("text-tertiary", sizes[size].text)}>{selectedItem?.supportingText}</p>} |
| 80 | </section> |
| 81 | ) : ( |
| 82 | <p className={cx("text-placeholder", sizes[size].text)}>{placeholder}</p> |
| 83 | )} |
| 84 | |
| 85 | <ChevronDown |
| 86 | aria-hidden="true" |
| 87 | className={cx("ml-auto shrink-0 text-fg-quaternary", size === "lg" ? "size-5" : "size-4 stroke-[2.25px]")} |
| 88 | /> |
| 89 | </> |
| 90 | ); |
| 91 | }} |
| 92 | </AriaSelectValue> |
| 93 | </AriaButton> |
| 94 | ); |
nothing calls this directly
no test coverage detected