UNPKG

@agentman/chat-widget

Version:

Agentman Chat Widget for easy integration with web applications

103 lines (102 loc) 2.55 kB
import type { ChatConfig, ChatTheme } from '../types/types'; /** * InputComponent - Reusable chat input with modern design * * Features: * - Auto-resizing textarea * - Attachment support with + button * - Send button with disabled state * - Consistent styling across views */ export declare class InputComponent { private config; private theme; private element; private boundInputKeyHandler; private boundSendHandler; private boundAttachmentClickHandler?; private boundFileSelectHandler?; private boundAttachmentRemoveHandler?; private attachments; private supportedMimeTypes; private supportsAttachments; constructor(config: ChatConfig, theme: ChatTheme, eventHandlers: { onInputKey: (e: KeyboardEvent) => void; onSend: () => void; onAttachmentClick?: () => void; onFileSelect?: (files: FileList) => void; onAttachmentRemove?: (fileId: string) => void; }); /** * Create and return the input component DOM element */ create(): HTMLElement; /** * Update theme colors */ updateTheme(theme: Partial<ChatTheme>): void; /** * Get the input value */ getInputValue(): string; /** * Clear the input */ clearInput(): void; /** * Focus the input */ focusInput(): void; /** * Update attachment preview */ updateAttachmentPreview(attachments: any[]): void; /** * Clear file input */ clearFileInput(): void; /** * Get the root element */ getRootElement(): HTMLElement | null; /** * Destroy the component and clean up */ destroy(): void; /** * Generate the input component HTML template */ private generateTemplate; /** * Attach event listeners */ private attachEventListeners; /** * Remove event listeners */ private removeEventListeners; /** * Handle input field changes */ private handleInputChange; /** * Update send button enabled/disabled state */ private updateSendButtonState; /** * Get appropriate icon for file type */ private getFileTypeIcon; /** * Escape HTML to prevent XSS */ private escapeHtml; /** * Configure attachment settings based on agent capabilities */ configureAttachments(supportedMimeTypes: string[], supportsAttachments: boolean): void; /** * Get supported MIME types */ getSupportedMimeTypes(): string[]; }