| 1 | /** |
| 2 | * AI Elements' Suggestion (registry.ai-sdk.dev/suggestion.json), in g1t's |
| 3 | * tokens: what someone might ask first, as quiet pills that wrap. |
| 4 | */ |
| 5 | import type { ComponentProps } from "react"; |
| 6 | |
| 7 | import { cn } from "../../lib/cn"; |
| 8 | import { Button } from "../ui/button"; |
| 9 | |
| 10 | export function Suggestions({ className, ...props }: ComponentProps<"div">) { |
| 11 | return <div role="list" className={cn("flex flex-wrap gap-2", className)} {...props} />; |
| 12 | } |
| 13 | |
| 14 | export function Suggestion({ |
| 15 | suggestion, |
| 16 | onPick, |
| 17 | className, |
| 18 | ...props |
| 19 | }: Omit<ComponentProps<typeof Button>, "onClick"> & { suggestion: string; onPick: (suggestion: string) => void }) { |
| 20 | return ( |
| 21 | <Button |
| 22 | type="button" |
| 23 | role="listitem" |
| 24 | variant="outline" |
| 25 | size="sm" |
| 26 | onClick={() => onPick(suggestion)} |
| 27 | className={cn("h-auto rounded-full px-3 py-1.5 text-left font-normal whitespace-normal text-fg-soft", className)} |
| 28 | {...props} |
| 29 | > |
| 30 | {suggestion} |
| 31 | </Button> |
| 32 | ); |
| 33 | } |