@agentman/chat-widget
Version:
Agentman Chat Widget for easy integration with web applications
180 lines (179 loc) • 5.51 kB
TypeScript
import type { ChatConfig, ChatTheme, ChatAssets } from '../types/types';
import { InputComponent } from './InputComponent';
/**
* InputBarSheetWelcomeView - Purpose-built welcome view for input-bar-sheet mode
*
* Key differences from WelcomeScreen:
* - Simplified DOM structure for better collapse/expand control
* - No CSS override battles - clean, purpose-built styles
* - Optimized for sheet pattern (collapsed 72px → expanded 80vh)
*
* Implements same public interface as WelcomeScreen for ViewManager compatibility
*/
export declare class InputBarSheetWelcomeView {
private config;
private theme;
private assets;
private element;
private boundInputKeyHandler;
private boundSendHandler;
private boundPromptClickHandler;
private boundConversationsClickHandler?;
private boundToggleHandler?;
private boundAttachmentClickHandler?;
private boundFileSelectHandler?;
private boundAttachmentRemoveHandler?;
private boundHasConversationsHandler?;
private boundPromptHandlers;
private inputComponent;
private typewriterController;
constructor(config: ChatConfig, theme: ChatTheme, assets: ChatAssets, eventHandlers: {
onInputKey: (e: KeyboardEvent) => void;
onSend: () => void;
onPromptClick: (prompt: string) => void;
onConversationsClick?: () => void;
onToggle?: () => void;
onAttachmentClick?: () => void;
onFileSelect?: (files: FileList) => void;
onAttachmentRemove?: (fileId: string) => void;
hasConversations?: () => boolean;
});
/**
* Create and return the welcome view DOM element
* Public interface - matches WelcomeScreen
*/
create(): HTMLElement;
/**
* Update theme colors
* Public interface - matches WelcomeScreen
*/
updateTheme(theme: Partial<ChatTheme>): void;
/**
* Get the input value
* Public interface - matches WelcomeScreen
*/
getInputValue(): string;
/**
* Clear the input
* Public interface - matches WelcomeScreen
*/
clearInput(): void;
/**
* Focus the input
* Public interface - matches WelcomeScreen
*/
focusInput(): void;
/**
* Get the input component instance
* Public interface - matches WelcomeScreen
*/
getInputComponent(): InputComponent | null;
/**
* Get the root element
* Public interface - matches WelcomeScreen
*/
getRootElement(): HTMLElement | null;
/**
* Refresh prompts from config (for dynamic URL-based prompts)
* Updates both the typewriter text and prompt buttons
*/
refreshPrompts(): void;
/**
* Update attachment preview
* Public interface - matches WelcomeScreen
*/
updateAttachmentPreview(attachments: Record<string, unknown>[]): void;
/**
* Clear file input
* Public interface - matches WelcomeScreen
*/
clearFileInput(): void;
/**
* Destroy the component and clean up
* Public interface - matches WelcomeScreen
*/
destroy(): void;
/**
* Generate the input-bar-full welcome template
* Simplified structure optimized for collapse/expand
*/
private generateTemplate;
/**
* Generate minimize button for top-right corner
*
* DESIGN NOTE: This is a visual indicator only, not a functional button.
* The entire welcome screen is clickable to collapse (handled by parent component).
* This button uses `pointer-events: none` in CSS to allow click-through while
* providing a clear visual cue for users about where to interact.
*
* Alternative considered: Making this button functional with its own click handler,
* but that would create redundant event handling and potential z-index conflicts.
*/
private generateMinimizeButton;
/**
* Generate welcome header with logo and title
* Only shown when expanded
*/
private generateHeader;
/**
* Generate welcome message
* Only shown when expanded
*/
private generateMessage;
/**
* Generate input section
* Always visible (in both collapsed and expanded states)
*/
private generateInputSection;
/**
* Generate branded zone with logo and brand text
* Transforms from pill to circle on expand
*/
private generateBrandZone;
/**
* Generate message prompts
* Only shown when expanded
*/
private generatePrompts;
/**
* Generate bottom section with conversations link and branding
* Only shown when expanded
*/
private generateBottomSection;
/**
* Create and mount the input component
*/
private createInputComponent;
/**
* Create and initialize the typewriter effect
*/
private createTypewriter;
/**
* Attach event listeners for prompts and conversations
*/
private attachEventListeners;
/**
* Attach prompt button event listeners
*/
private attachPromptListeners;
/**
* Attach conversations link event listener
*/
private attachConversationsListener;
/**
* Remove prompt button event listeners only
*/
private removePromptListeners;
/**
* Remove all event listeners (for destroy)
*/
private removeEventListeners;
/**
* Apply theme CSS variables to the element
*/
private applyTheme;
/**
* Escape HTML to prevent XSS
*/
private escapeHtml;
}