import type React from 'react'; import type { ActivityOptions, BubbleOptions, ChatSubmitDetail, ChatTurn, FileAddDetail, FileRejectDetail, FileRemoveDetail, FocusDetail, GroupOptions, GroupPart, KeyboardDetail, ScrollEndDetail, StreamHandle } from './types.js'; export interface ChatRef extends HTMLElement { /** Adds a pre-rendered HTML turn to the chat (low-level). Prefer addUserMessage/addAssistantMessage. Returns the turn ID. */ addMessage(html: string, opts?: { id?: string; }): string; /** Adds a user message. Renders via WASM automatically. */ addUserMessage(content: string, opts?: BubbleOptions): void; /** Adds an assistant message. Renders via WASM automatically. */ addAssistantMessage(content: string, opts?: BubbleOptions): void; /** Adds a multi-part grouped message (text + code, etc.). */ addGroupMessage(role: "user" | "assistant", parts: GroupPart[], opts?: GroupOptions): void; /** Adds a tool activity group (search, read, write, etc.). */ addActivity(opts?: ActivityOptions): void; /** Scrolls the message area to the bottom. */ scrollToBottom(): void; /** Clears all messages from the chat. */ clear(): void; /** Focuses the chat input textarea. */ focus(): void; /** Returns the current input textarea value. */ getValue(): string; /** Sets the input textarea value programmatically. */ setValue(value: string): void; /** Starts a streaming assistant turn. Returns a handle with appendTokens() and end(). */ startStreamingTurn(role?: "user" | "assistant", opts?: { id?: string; senderName?: string; size?: string; }): StreamHandle; /** Removes a message by turn ID. */ removeMessage(id: string): boolean; /** Updates a message's HTML by turn ID. */ updateMessage(id: string, html: string): boolean; /** Adds files programmatically to the chat input. */ addFiles(files: FileList): void; /** Removes all file attachments from the chat input. */ clearAttachments(): void; } /** * A full chat container — pass initial turns via `turns` prop, then use imperative `addUserMessage()`/`addAssistantMessage()` for new messages. * Streaming: call `startStreamingTurn()` which returns a handle with `appendTokens()` and `end()`. * Do NOT render message components as children. * * In React, reach the imperative methods through a ref: * `const api = useRef(null)`, pass `ref={api}`, then `api.current?.addMessage()`. * Available: addMessage(), addUserMessage(), addAssistantMessage(), +12 more. * * @csspart base, drop-overlay, footer, header, input-area, messages, new-content, thumb, track, typing */ export interface ChatOwnProps { /** * Unique identifier for the element. * @example 'example-id' */ id?: string; /** * Corner radius style. Allowed values: `sharp`, `rounded`. * @example 'sharp' */ shape?: 'sharp' | 'rounded'; /** * Chat layout variant. Allowed values: `standard`, `compact`, `fullscreen`. * @example 'standard' */ layout?: 'standard' | 'compact' | 'fullscreen'; /** * Component size. Allowed values: `xs`, `sm`, `md`, `lg`, `xl`. * @example 'xs' */ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'; /** * Fixed height for the chat container. Accepts "fill" (grow to fill the flex parent), a Tailwind height class (e.g. "h-[600px]", "h-96"), or a raw CSS length (e.g. "520px", "50vh"). Defaults to "h-[600px]". * @example 'h-[600px]' */ height?: string; /** * Shape variant for the chat scrollbar. Allowed values: `sharp`, `rounded`, `pill`. * @example 'sharp' */ scrollbarShape?: 'sharp' | 'rounded' | 'pill'; /** * Scrollbar track treatment in the chat area: a visible track gutter, or a floating thumb. Allowed values: `with-track`, `floating`. * @example 'with-track' */ scrollbarTrack?: 'with-track' | 'floating'; /** * Array of chat turn objects representing the conversation. * @example [{ html: '

Hello

' }] */ turns?: ChatTurn[]; /** * Typing indicator state. Set to `typing` to show it (with `typingSender`); empty string hides it. Allowed values: ``, `typing`. * @example 'typing' */ typing?: '' | 'typing'; /** * Display name of the sender currently typing. * @example 'example' */ typingSender?: string; /** * Shape variant for the chat input field. Allowed values: `sharp`, `rounded`, `pill`. * @example 'sharp' */ inputShape?: 'sharp' | 'rounded' | 'pill'; /** * Placeholder text for the chat input field. * @example 'example' */ inputPlaceholder?: string; /** * Whether the chat input is disabled. * @defaultValue false * @example true */ inputDisabled?: boolean; /** * Maximum character count for the chat input. * @defaultValue 0 * @example 1 */ inputMaxLength?: number; /** * Whether to display the secondary action button in the input. * @defaultValue true * @example true */ showActionButton?: boolean; /** * Visible label text. * @example 'Example label' */ label?: string; /** * Accessible label for the chat input field. * @example 'example' */ inputLabel?: string; /** * Accessible label for the submit/send button. * @example 'example' */ submitLabel?: string; /** * Content displayed when the chat has no messages. * @example 'example' */ emptyState?: string; /** * Whether to show the file attachment button in the input. * @defaultValue false * @example true */ acceptFiles?: boolean; /** * Accepted file types for the attachment button (MIME types or extensions). * @example 'image/*,.pdf' */ accept?: string; /** * Maximum file size in bytes for attachments. * @defaultValue 0 * @example 1 */ maxFileSize?: number; /** * Whether multiple file selection is allowed for attachments. * @defaultValue false * @example true */ multipleFiles?: boolean; /** * Whether a message is currently being submitted. Disables the send button. * @defaultValue false * @example true */ inputSubmitting?: boolean; /** * Fires when the user submits the current value. Detail: `ChatSubmitDetail`. * @example (event) => console.log(event.detail.value) */ onSubmit?: (event: CustomEvent) => void; /** * Fires after files are accepted for attachment. Detail: `FileAddDetail`. * @example (event) => console.log(event.detail.files) */ onFileAdd?: (event: CustomEvent) => void; /** * Fires after an attachment is removed. Detail: `FileRemoveDetail`. * @example (event) => console.log(event.detail.files) */ onFileRemove?: (event: CustomEvent) => void; /** * Fires when files fail attachment validation. Detail: `FileRejectDetail`. * @example (event) => console.log(event.detail.reason) */ onFileReject?: (event: CustomEvent) => void; /** * Fires when the scroll container reaches its end. Detail: `ScrollEndDetail`. * @example (event) => console.log(event.detail) */ onScrollEnd?: (event: CustomEvent) => void; /** * Fires when focus enters the component. Detail: `FocusDetail`. * @example (event) => console.log(event.detail.relatedTarget) */ onFocus?: (event: CustomEvent) => void; /** * Fires when focus leaves the component. Detail: `FocusDetail`. * @example (event) => console.log(event.detail.relatedTarget) */ onBlur?: (event: CustomEvent) => void; /** * Fires when a key is pressed inside the component. Detail: `KeyboardDetail`. * @example (event) => console.log(event.detail.key) */ onKeydown?: (event: CustomEvent) => void; /** Content for the `header` slot. * @example Content */ header?: React.ReactNode; /** Content for the `footer` slot. * @example Content */ footer?: React.ReactNode; /** CSS class applied to the Custom Element host. * @example 'my-component' */ className?: string; /** Inline styles applied to the Custom Element host. * @example { marginTop: 8 } */ style?: React.CSSProperties; } /** * Props for ``: the component's own API plus every standard DOM * attribute and native React event handler, forwarded verbatim to the * `` host — `id`, `data-*`, `aria-*`, `title`, `tabIndex`, * `slot`, `onMouseEnter`, and the rest. Own props always win over a * same-named DOM attribute. */ export type ChatProps = ChatOwnProps & Omit, keyof ChatOwnProps | 'children' | 'dangerouslySetInnerHTML'>; export declare const Chat: React.ForwardRefExoticComponent, "children" | "dangerouslySetInnerHTML" | keyof ChatOwnProps> & React.RefAttributes>;