import { type JSX, Show, splitProps } from 'solid-js'; import { cn } from '../utils/cn'; import { Button } from '../ui/button'; export interface PromptSuggestionProps extends JSX.ButtonHTMLAttributes { children: JSX.Element | string; variant?: 'outline' | 'ghost' | 'default'; size?: 'sm' | 'md' | 'lg' | 'icon' | 'icon-sm'; 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; } function PromptSuggestion(props: PromptSuggestionProps) { const [local, rest] = splitProps(props, ['children', 'variant', 'size', 'class', 'highlight', 'block']); 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 };