({
icon,
variant = "tertiary/small",
text,
shortcut,
tooltipTitle,
disabled,
placeholder,
dropdownIcon = false,
children,
className,
...props
}: SelectTriggerProps)
| 232 | } |
| 233 | |
| 234 | export function SelectTrigger({ |
| 235 | icon, |
| 236 | variant = "tertiary/small", |
| 237 | text, |
| 238 | shortcut, |
| 239 | tooltipTitle, |
| 240 | disabled, |
| 241 | placeholder, |
| 242 | dropdownIcon = false, |
| 243 | children, |
| 244 | className, |
| 245 | ...props |
| 246 | }: SelectTriggerProps) { |
| 247 | const ref = React.useRef<HTMLButtonElement>(null); |
| 248 | useShortcutKeys({ |
| 249 | shortcut: shortcut, |
| 250 | action: (e) => { |
| 251 | e.preventDefault(); |
| 252 | e.stopPropagation(); |
| 253 | if (ref.current) { |
| 254 | ref.current.click(); |
| 255 | } |
| 256 | }, |
| 257 | disabled, |
| 258 | }); |
| 259 | |
| 260 | const showTooltip = tooltipTitle || shortcut; |
| 261 | const variantClasses = variants[variant]; |
| 262 | |
| 263 | let content: React.ReactNode = ""; |
| 264 | if (children) { |
| 265 | content = children; |
| 266 | } else if (text !== undefined) { |
| 267 | if (typeof text === "function") { |
| 268 | content = <SelectValue>{(value) => <>{text(value) ?? placeholder}</>}</SelectValue>; |
| 269 | } else { |
| 270 | content = text; |
| 271 | } |
| 272 | } else { |
| 273 | content = ( |
| 274 | <SelectValue> |
| 275 | {(value) => ( |
| 276 | <> |
| 277 | {typeof value === "string" |
| 278 | ? value ?? placeholder |
| 279 | : value.length === 0 |
| 280 | ? placeholder |
| 281 | : value.join(", ")} |
| 282 | </> |
| 283 | )} |
| 284 | </SelectValue> |
| 285 | ); |
| 286 | } |
| 287 | |
| 288 | return ( |
| 289 | <Ariakit.TooltipProvider timeout={200}> |
| 290 | <Ariakit.TooltipAnchor |
| 291 | className="button" |
nothing calls this directly
no test coverage detected
searching dependent graphs…