@agentman/chat-widget
Version:
Agentman Chat Widget for easy integration with web applications
107 lines (106 loc) • 3.27 kB
TypeScript
import type { ChatConfig, ChatTheme } from '../types/types';
import type { ConversationMeta } from '../PersistenceManager';
/**
* ConversationManager - Handles multiple conversation management
*
* This component provides:
* - Conversation list view (replaces chat messages)
* - New conversation creation
* - Conversation switching
* - Conversation deletion
* - Integration with PersistenceManager
*/
export declare class ConversationManager {
private logger;
private config;
private theme;
private element;
private isListViewOpen;
private sourceView;
private boundNewConversationHandler?;
private boundSwitchConversationHandler?;
private boundDeleteConversationHandler?;
private boundToggleListViewHandler?;
constructor(config: ChatConfig, theme: ChatTheme, eventHandlers: {
onNewConversation?: () => void;
onSwitchConversation?: (conversationId: string) => void;
onDeleteConversation?: (conversationId: string) => void;
onToggleListView?: () => void;
});
/**
* Create conversation list view (replaces messages area)
*/
createConversationListView(): HTMLElement;
/**
* Update conversation list display
*/
updateConversationList(conversations: ConversationMeta[], currentId?: string): void;
/**
* Check if the list view is currently open
*/
isOpen(): boolean;
/**
* Close the list view if it's open (without triggering toggle callback)
*/
closeListView(): void;
/**
* Show/hide conversation list view with animations
*/
toggleListView(source?: 'welcome' | 'conversation'): void;
/**
* Get the source view that opened the conversation list
*/
getSourceView(): 'welcome' | 'conversation' | null;
/**
* Check if list view is open
*/
isListViewActive(): boolean;
/**
* Add conversation management button to header (hamburger menu)
*/
addConversationButton(headerElement: HTMLElement, hasConversations?: boolean): void;
/**
* Add new conversation button to header actions (always visible)
*/
addNewConversationButton(headerElement: HTMLElement): void;
/**
* Add a vertical divider in the header actions
*/
addHeaderDivider(headerElement: HTMLElement): void;
/**
* Add back button to header (legacy compatibility - stub method)
*/
addBackButton(headerElement: HTMLElement): void;
/**
* Update header button visibility (legacy compatibility - stub method)
*/
updateHeaderButtons(headerElement: HTMLElement): void;
/**
* Clean up resources
*/
destroy(): void;
/**
* Generate the conversation list template with its own header
*/
private generateConversationListTemplate;
/**
* Attach event listeners for the header buttons and conversation items
*/
private attachEventListeners;
/**
* Attach event listeners to conversation list items
*/
private attachConversationListeners;
/**
* Remove all event listeners
*/
private removeEventListeners;
/**
* Format date for display
*/
private formatDate;
/**
* Escape HTML to prevent XSS
*/
private escapeHtml;
}