import { type JSX, Show, splitProps } from 'solid-js'; import { cn } from '../utils/cn'; import { Button } from '../ui/button'; import { renderIcon } from '../ui/icon'; export interface PromptSuggestionProps extends JSX.ButtonHTMLAttributes { children: JSX.Element | string; variant?: 'outline' | 'ghost' | 'default'; /** Row height for the `list` layout: `'md'` (default) or `'lg'` for taller * rows (more vertical padding). Chips/block/highlight are unaffected. */ size?: 'md' | 'lg'; /** Optional leading icon (named icon, image URL/data-URI, or text). */ icon?: string; highlight?: string; /** Render as a full-width, left-aligned list row (the "suggested questions" * idiom) instead of a rounded pill. Wraps long text. Ignored in highlight * mode, which is always a list row. */ block?: boolean; /** Render as a full-width "Ideas for you" list row: a leading icon, a * left-aligned label, and a hover background. Like `block`, but keeps the * leading icon. Ignored in highlight mode. */ list?: boolean; } function PromptSuggestion(props: PromptSuggestionProps) { const [local, rest] = splitProps(props, ['children', 'variant', 'size', 'class', 'icon', 'highlight', 'block', 'list']); const Icon = () => {renderIcon(local.icon, { class: 'size-3.5 shrink-0' })}; const isHighlightMode = () => local.highlight !== undefined && local.highlight.trim() !== ''; const content = () => typeof local.children === 'string' ? local.children : ''; return ( {local.children} } > } > } > {local.children} } > ); } function renderHighlighted(text: string, highlight: string) { const trimmed = highlight.trim(); const textLower = text.toLowerCase(); const highlightLower = trimmed.toLowerCase(); const index = textLower.indexOf(highlightLower); if (index === -1) { return {text}; } const before = text.substring(0, index); const matched = text.substring(index, index + highlightLower.length); const after = text.substring(index + matched.length); return ( <> {before} {matched} {after} ); } export { PromptSuggestion };