import { createEffect, onMount } from "solid-js"; import { Button } from "@/components/ui/button"; import { IconSend } from "@/components/ui/icons"; import { Textarea } from "@/components/ui/textarea"; import { cn } from "@/lib/cn"; const MAX_HEIGHT_PX = 176; export function RagComposer(props: { value: string; placeholder: string; sendLabel: string; hint: string; disabled: boolean; /** Take the caret on mount — the landing screen is the composer, so it should * be ready to type into, and a send that re-places it returns focus. */ autofocus?: boolean; class?: string; onInput: (value: string) => void; onSubmit: () => void; }) { let field: HTMLTextAreaElement | undefined; const resize = () => { if (!field) return; field.style.height = "auto"; field.style.height = `${Math.min(field.scrollHeight, MAX_HEIGHT_PX)}px`; }; createEffect(() => { void props.value; resize(); }); onMount(() => { if (props.autofocus) field?.focus(); }); return (
); }