UNPKG

pulsewidget

Version:

A beautiful, customizable chatbot widget for React applications with full TypeScript support and smooth animations

81 lines (73 loc) 2.73 kB
import { Dispatch } from 'react'; import { JSX as JSX_2 } from 'react/jsx-runtime'; import { SetStateAction } from 'react'; export declare interface ChatbotConfig { /** API endpoint for chat messages */ apiEndpoint: string; /** Optional custom headers for API requests */ apiHeaders?: Record<string, string>; /** Transform request before sending to API */ formatRequest?: (messages: Message[]) => any; /** Transform API response to get message content */ formatResponse?: (response: any) => string; } export declare interface ChatbotTheme { primaryColor?: string; backgroundColor?: string; userMessageBg?: string; assistantMessageBg?: string; borderColor?: string; textColor?: string; } export declare function ChatbotWidget({ config, botName, botAvatar, toggleButtonImage, theme, suggestions, placeholder, welcomeMessage, welcomeSubtitle, className, allowExpand, defaultOpen, onToggle, onMessageSent, onResponseReceived, }: ChatbotWidgetProps): JSX_2.Element; export declare interface ChatbotWidgetProps { /** Configuration for API communication */ config: ChatbotConfig; /** Bot name displayed in header */ botName?: string; /** Bot avatar image URL */ botAvatar?: string; /** Toggle button image URL */ toggleButtonImage?: string; /** Theme customization */ theme?: ChatbotTheme; /** Initial suggestions to display */ suggestions?: string[]; /** Input placeholder text */ placeholder?: string; /** Welcome message */ welcomeMessage?: string; /** Welcome subtitle */ welcomeSubtitle?: string; /** Custom CSS class for container */ className?: string; /** Error message to display on API failure */ errorMessage?: string; /** Show/hide expand button */ allowExpand?: boolean; /** Initial open state */ defaultOpen?: boolean; /** Callback when chat opens/closes */ onToggle?: (isOpen: boolean) => void; /** Callback when message is sent */ onMessageSent?: (message: Message) => void; /** Callback when response is received */ onResponseReceived?: (message: Message) => void; } export declare interface Message { id: string; role: 'user' | 'assistant'; content: string; } export declare function useChat(config: ChatbotConfig): { messages: Message[]; input: string; isLoading: boolean; handleInputChange: (value: string) => void; handleSubmit: (e?: React.FormEvent) => Promise<{ userMessage: Message; botMessage: Message; } | undefined>; setMessages: Dispatch<SetStateAction<Message[]>>; }; export { }