UNPKG

@ticketping/chat-widget

Version:

Customer support chat widget for Ticketping - Intercom-like experience with real-time messaging

186 lines (162 loc) 4.15 kB
// TypeScript declarations for @ticketping/chat-widget export interface TicketpingConfig { // Required appId: string; teamSlug: string; teamLogoIcon?: string; // API Configuration apiBase?: string; wsBase?: string; // Authentication userJWT?: string; enableSecureMode?: boolean; // Widget Appearance position?: 'bottom-right' | 'bottom-left'; theme?: 'default' | 'dark' | 'light' | CustomTheme; zIndex?: number; // Widget Behavior autoOpen?: boolean; enableTypingIndicators?: boolean; enableFileUpload?: boolean; enableEmojis?: boolean; // File Upload maxFileSize?: number; allowedFileTypes?: string[]; // Messages maxMessageLength?: number; enableMarkdown?: boolean; enableLinkPreviews?: boolean; // Conversations showConversationHistory?: boolean; maxConversationsStored?: number; autoDeleteAfterDays?: number; // Notifications enableSoundNotifications?: boolean; enableBrowserNotifications?: boolean; // Analytics analytics?: boolean; trackUserInteractions?: boolean; // Localization locale?: string; timezone?: string; // Development debug?: boolean; logLevel?: 'debug' | 'info' | 'warn' | 'error'; // Custom Labels labels?: WidgetLabels; // Custom CSS customCSS?: string; // Callbacks onReady?: () => void; onOpen?: () => void; onClose?: () => void; onMessageSent?: (message: ChatMessage) => void; onMessageReceived?: (message: ChatMessage) => void; onConversationStarted?: (id: string) => void; onError?: (error: any) => void; } export interface CustomTheme { primaryColor?: string; primaryButtonText?: string; primaryHover?: string; textPrimary?: string; textSecondary?: string; textMuted?: string; background?: string; backgroundSecondary?: string; backgroundTertiary?: string; border?: string; borderLight?: string; notificationBg?: string; successColor?: string; offlineColor?: string; errorBg?: string; errorText?: string; errorBorder?: string; shadowLight?: string; shadowMedium?: string; shadowDark?: string; iconColor?: string; } export interface WidgetLabels { headerTitle?: string; headerSubtitle?: string; homeTab?: string; messagesTab?: string; welcomeTitle?: string; welcomeMessage?: string; startConversationButton?: string; messageInputPlaceholder?: string; sendButton?: string; attachButton?: string; typingIndicator?: string; agentOnline?: string; agentOffline?: string; connectionLost?: string; fileTooLarge?: string; fileTypeNotAllowed?: string; messageTooLong?: string; sendError?: string; loadError?: string; noConversations?: string; noConversationsDescription?: string; helpArticlesTitle?: string; helpArticles?: HelpArticle[]; } export interface HelpArticle { title: string; url: string; icon: string; } export interface UserData { id: string; name: string; email: string; company?: string; userJWT?: string; [key: string]: any; } export interface ChatMessage { sessionId: string; type: 'user_message' | 'agent_message' | 'system_message'; sender: 'USER' | 'AGENT' | 'SYSTEM'; messageText: string; created: string; file?: { name: string; size: number; type: string; url: string; }; [key: string]: any; } export interface TicketpingChatInstance { open(): void; close(): void; toggle(): void; identify(userData: UserData): Promise<void>; sendMessage(messageData: any): Promise<void>; startConversation(): Promise<void>; destroy(): void; config: TicketpingConfig; isInitialized: boolean; isOpen: boolean; currentUser: UserData | null; } declare global { interface Window { TicketpingChat: { instance: TicketpingChatInstance | null; init: (config: TicketpingConfig) => TicketpingChatInstance; identify: (userData: UserData) => void; open: () => void; close: () => void; startConversation: () => void; destroy: () => void; version: string; }; ticketpingConfig?: TicketpingConfig; } } declare const TicketpingChat: TicketpingChatInstance; export default TicketpingChat;