UNPKG

@agentman/chat-widget

Version:

Agentman Chat Widget for easy integration with web applications

101 lines (100 loc) 2.5 kB
/** * HeaderButton - Unified button component for all header actions * * Provides a single implementation for all header buttons (collapse, new, chats, etc.) * with variant-specific behavior handled through configuration. */ /** * Button types with semantic meaning */ export type ButtonType = 'collapse' | 'new' | 'chats' | 'back' | 'expand' | 'minimize'; /** * Button configuration */ export interface HeaderButtonConfig { type: ButtonType; label?: string; showLabel?: boolean; onClick: () => void; className?: string; ariaLabel?: string; title?: string; } /** * HeaderButton Class * * Creates consistent, accessible header buttons with: * - Semantic button types (collapse, new, chats, etc.) * - Optional text labels * - Variant-aware styling * - Proper accessibility attributes */ export declare class HeaderButton { private button; private config; private variant; constructor(config: HeaderButtonConfig, variant?: string); /** * Create the button element */ private createButton; /** * Get button icon based on type */ private getIcon; /** * Get button content (icon + optional label) */ private getButtonContent; /** * Get default aria-label */ private getDefaultAriaLabel; /** * Get default title */ private getDefaultTitle; /** * Escape HTML to prevent XSS */ private escapeHtml; /** * Get the button element */ getElement(): HTMLButtonElement; /** * Update button label */ updateLabel(label: string): void; /** * Show/hide label */ toggleLabel(show: boolean): void; /** * Enable/disable button */ setEnabled(enabled: boolean): void; /** * Destroy the button */ destroy(): void; /** * Static factory methods for common buttons */ /** * Create a collapse/minimize button (variant-aware) */ static createCollapseButton(onClick: () => void, variant?: string, showLabel?: boolean): HeaderButton; /** * Create a new conversation button */ static createNewButton(onClick: () => void, showLabel?: boolean): HeaderButton; /** * Create a chats/history button */ static createChatsButton(onClick: () => void, showLabel?: boolean): HeaderButton; /** * Create a back button */ static createBackButton(onClick: () => void, showLabel?: boolean): HeaderButton; }