andy-widget-react 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { AndyChatProps } from './types';
3
+ declare const AndyChat: React.FC<AndyChatProps>;
4
+ export default AndyChat;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { ChatbotConfig } from '../types';
3
+ interface ChatBubbleProps {
4
+ isOpen: boolean;
5
+ config: ChatbotConfig | null;
6
+ onClick: () => void;
7
+ }
8
+ declare const ChatBubble: React.FC<ChatBubbleProps>;
9
+ export default ChatBubble;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { ChatbotConfig, Message } from '../types';
3
+ interface ChatWindowProps {
4
+ config: ChatbotConfig | null;
5
+ messages: Message[];
6
+ isLoading: boolean;
7
+ onClose: () => void;
8
+ onSendMessage: (message: string) => Promise<void> | void;
9
+ }
10
+ declare const ChatWindow: React.FC<ChatWindowProps>;
11
+ export default ChatWindow;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { FAQItem } from '../types';
3
+ interface FAQProps {
4
+ faqs?: FAQItem[];
5
+ onBack: () => void;
6
+ }
7
+ declare const FAQ: React.FC<FAQProps>;
8
+ export default FAQ;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface MessageInputProps {
3
+ onSendMessage: (message: string) => Promise<void> | void;
4
+ disabled?: boolean;
5
+ placeholder?: string;
6
+ }
7
+ declare const MessageInput: React.FC<MessageInputProps>;
8
+ export default MessageInput;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { Message } from '../types';
3
+ interface MessageListProps {
4
+ messages: Message[];
5
+ isLoading: boolean;
6
+ logoUrl?: string;
7
+ botName?: string;
8
+ }
9
+ declare const MessageList: React.FC<MessageListProps>;
10
+ export default MessageList;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { UserInfo } from '../types';
3
+ interface UserInfoFormProps {
4
+ headerText?: string;
5
+ brandColor?: string;
6
+ onSubmit: (data: UserInfo) => Promise<void> | void;
7
+ onClose: () => void;
8
+ }
9
+ declare const UserInfoForm: React.FC<UserInfoFormProps>;
10
+ export default UserInfoForm;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface WelcomePopupProps {
3
+ message: string;
4
+ brandColor?: string;
5
+ onClose: () => void;
6
+ }
7
+ declare const WelcomePopup: React.FC<WelcomePopupProps>;
8
+ export default WelcomePopup;
@@ -0,0 +1 @@
1
+ export { useAndyChat } from './useAndyChat';
@@ -0,0 +1,2 @@
1
+ import type { UseAndyChatReturn } from '../types';
2
+ export declare const useAndyChat: (embedId: string) => UseAndyChatReturn;
@@ -0,0 +1,13 @@
1
+ export { default as AndyChat } from './AndyChat';
2
+ export { default as Andy } from './AndyChat';
3
+ export { useAndyChat } from './hooks/useAndyChat';
4
+ export { default as ChatBubble } from './components/ChatBubble';
5
+ export { default as ChatWindow } from './components/ChatWindow';
6
+ export { default as MessageList } from './components/MessageList';
7
+ export { default as MessageInput } from './components/MessageInput';
8
+ export { default as FAQ } from './components/FAQ';
9
+ export { default as WelcomePopup } from './components/WelcomePopup';
10
+ export { default as UserInfoForm } from './components/UserInfoForm';
11
+ export type { AndyChatProps, ChatbotConfig, Message, FAQItem, PredefinedQuestion, WelcomePopupConfig, CollectUserInfoConfig, UserInfo, UseAndyChatReturn, ChatBubbleProps, ChatWindowProps, MessageListProps, MessageInputProps, FAQProps, WelcomePopupProps, UserInfoFormProps, FaqItemProps } from './types';
12
+ export { theme, colors, typography, spacing, borderRadius, shadows, zIndex, animation, chat, generateSessionId, parseMarkdown, sanitizeUrl, isValidEmbedId, getEmbedId, getApiBaseUrl, setApiBaseUrl } from 'andy-widget-core';
13
+ export { default } from './AndyChat';
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Type definitions for andy-widget-react
3
+ */
4
+ export interface WelcomePopupConfig {
5
+ enabled: boolean;
6
+ seconds: number;
7
+ message?: string;
8
+ }
9
+ export interface CollectUserInfoConfig {
10
+ enabled: boolean;
11
+ message?: string;
12
+ }
13
+ export interface PredefinedQuestion {
14
+ order: number;
15
+ question: string;
16
+ }
17
+ export interface FAQItem {
18
+ question: string;
19
+ answer: string;
20
+ }
21
+ export interface ChatbotConfig {
22
+ id: string | null;
23
+ name: string;
24
+ theme: 'light' | 'dark' | 'auto';
25
+ logoUrl: string;
26
+ headline: string;
27
+ brandColor: string;
28
+ description: string;
29
+ orientation: 'left' | 'right';
30
+ bubbleStyle: 'icon' | 'pill';
31
+ bubbleLabel: string | null;
32
+ useBrandColor: boolean;
33
+ defaultLang: 'en' | 'es';
34
+ showBranding: boolean;
35
+ welcomeMessage: string;
36
+ showWelcomePopup: WelcomePopupConfig;
37
+ collectUserInfo: CollectUserInfoConfig;
38
+ predefinedQuestions: PredefinedQuestion[];
39
+ faqs: FAQItem[];
40
+ }
41
+ export interface Message {
42
+ id: number;
43
+ content: string;
44
+ sender: 'user' | 'bot';
45
+ timestamp: string;
46
+ isForm?: boolean;
47
+ isLoading?: boolean;
48
+ isError?: boolean;
49
+ }
50
+ export interface UserInfo {
51
+ name: string;
52
+ email: string;
53
+ }
54
+ export interface AndyChatProps {
55
+ /** Required chatbot embed ID (not required if previewMode is true) */
56
+ embedId?: string;
57
+ /** Optional tooltip text for the chat bubble */
58
+ tooltip?: string;
59
+ /** Optional bot name (overrides API value) */
60
+ name?: string;
61
+ /** Optional headline/subtitle (overrides API value) */
62
+ headline?: string;
63
+ /** Optional description (overrides API value) */
64
+ description?: string;
65
+ /** Optional welcome message (overrides API value) */
66
+ welcomeMessage?: string;
67
+ /** Optional custom label for pill-style bubble (overrides default) */
68
+ bubbleLabel?: string;
69
+ /** Optional theme ('light' | 'dark' | 'auto') */
70
+ theme?: 'light' | 'dark' | 'auto';
71
+ /** Optional position ('left' | 'right') */
72
+ orientation?: 'left' | 'right';
73
+ /** Optional brand color hex (e.g., '#3B82F6') */
74
+ brandColor?: string;
75
+ /** Optional bubble style ('icon' | 'pill') */
76
+ bubbleStyle?: 'icon' | 'pill';
77
+ /** Optional whether to use brand color */
78
+ useBrandColor?: boolean;
79
+ /** Optional logo URL */
80
+ logoUrl?: string;
81
+ /** If true, skip API fetch and use props directly as config */
82
+ previewMode?: boolean;
83
+ /** If true, start with chat window open */
84
+ initialOpen?: boolean;
85
+ }
86
+ export interface FaqItemProps {
87
+ question: string;
88
+ answer: string;
89
+ }
90
+ export interface ChatBubbleProps {
91
+ isOpen: boolean;
92
+ onClick: () => void;
93
+ tooltip?: string;
94
+ logoUrl?: string;
95
+ bubbleStyle?: 'icon' | 'pill';
96
+ bubbleLabel?: string;
97
+ theme?: 'light' | 'dark' | 'auto';
98
+ useBrandColor?: boolean;
99
+ }
100
+ export interface ChatWindowProps {
101
+ isOpen: boolean;
102
+ config: ChatbotConfig | null;
103
+ messages: Message[];
104
+ isLoading: boolean;
105
+ showPredefinedQuestions: boolean;
106
+ isCollectingUserInfo: boolean;
107
+ onClose: () => void;
108
+ onSendMessage: (message: string) => void;
109
+ onPredefinedQuestion: (question: string) => void;
110
+ onUserInfoSubmit: (e: React.FormEvent<HTMLFormElement>) => void;
111
+ }
112
+ export interface MessageListProps {
113
+ messages: Message[];
114
+ config: ChatbotConfig | null;
115
+ isLoading: boolean;
116
+ isCollectingUserInfo: boolean;
117
+ onUserInfoSubmit: (e: React.FormEvent<HTMLFormElement>) => void;
118
+ }
119
+ export interface MessageInputProps {
120
+ onSendMessage: (message: string) => void;
121
+ disabled?: boolean;
122
+ placeholder?: string;
123
+ }
124
+ export interface FAQProps {
125
+ faqs: FAQItem[];
126
+ onBack: () => void;
127
+ }
128
+ export interface WelcomePopupProps {
129
+ message: string;
130
+ orientation?: 'left' | 'right';
131
+ onClose: () => void;
132
+ }
133
+ export interface UserInfoFormProps {
134
+ message?: string;
135
+ onSubmit: (e: React.FormEvent<HTMLFormElement>) => void;
136
+ }
137
+ export interface UseAndyChatReturn {
138
+ config: Partial<ChatbotConfig>;
139
+ isLoading: boolean;
140
+ isOpen: boolean;
141
+ showingFaq: boolean;
142
+ showingWelcomePopup: boolean;
143
+ showingUserInfoForm: boolean;
144
+ messages: Message[];
145
+ userInfoCollected: boolean;
146
+ sessionId: string;
147
+ error: string | null;
148
+ initializeChatbot: () => Promise<void>;
149
+ toggleChat: () => void;
150
+ sendMessage: (messageText: string) => Promise<unknown>;
151
+ showFaq: () => void;
152
+ hideFaq: () => void;
153
+ showWelcomePopup: () => void;
154
+ hideWelcomePopup: () => void;
155
+ showUserInfoForm: () => void;
156
+ hideUserInfoForm: () => void;
157
+ submitUserInfo: (userInfo: UserInfo) => Promise<void>;
158
+ startNewSession: () => void;
159
+ addMessage: (message: Message) => void;
160
+ }
161
+ export interface StylesheetOptions {
162
+ color?: string;
163
+ useBrandColor?: boolean;
164
+ theme?: 'light' | 'dark' | 'auto';
165
+ orientation?: 'left' | 'right';
166
+ }
167
+ export interface HostClassOptions {
168
+ theme?: 'light' | 'dark' | 'auto';
169
+ orientation?: 'left' | 'right';
170
+ }
171
+ export interface KeyboardListenerCallback {
172
+ (state: {
173
+ isOpen: boolean;
174
+ height: number;
175
+ }): void;
176
+ }
177
+ export interface KeyboardDetector {
178
+ addListener: (callback: KeyboardListenerCallback) => void;
179
+ removeListener: (callback: KeyboardListenerCallback) => void;
180
+ }
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "andy-widget-react",
3
+ "version": "2.0.5",
4
+ "description": "Official React Widget for embeddable Andy agents",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.esm.js",
8
+ "types": "dist/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/types/index.d.ts",
12
+ "import": "./dist/index.esm.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist/**/*",
18
+ "src/**/*",
19
+ "README.md"
20
+ ],
21
+ "scripts": {
22
+ "build": "rm -rf dist && rollup -c",
23
+ "build:dev": "rm -rf dist && rollup -c",
24
+ "dev": "rollup -c --watch",
25
+ "typecheck": "tsc -p tsconfig.json --noEmit",
26
+ "prepublishOnly": "bun run build"
27
+ },
28
+ "keywords": [
29
+ "react",
30
+ "chatbot",
31
+ "ai",
32
+ "chat",
33
+ "widget",
34
+ "customer-support",
35
+ "embeddable",
36
+ "component"
37
+ ],
38
+ "author": "Andesphere",
39
+ "license": "MIT",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/Andesphere/andy-sdk.git",
43
+ "directory": "packages/react"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "devDependencies": {
49
+ "@babel/core": "^7.27.3",
50
+ "@babel/preset-react": "^7.27.1",
51
+ "@rollup/plugin-babel": "^6.0.4",
52
+ "@rollup/plugin-commonjs": "^28.0.3",
53
+ "@rollup/plugin-node-resolve": "^16.0.1",
54
+ "@rollup/plugin-typescript": "^12.3.0",
55
+ "@rollup/plugin-url": "^8.0.2",
56
+ "@types/react": "^19.1.2",
57
+ "@types/react-dom": "^19.1.2",
58
+ "react": "^19.0.0",
59
+ "react-dom": "^19.0.0",
60
+ "rollup": "^4.41.1",
61
+ "rollup-plugin-postcss": "^4.0.2",
62
+ "tslib": "^2.8.1",
63
+ "typescript": "^5.9.3"
64
+ },
65
+ "peerDependencies": {
66
+ "react": "^18.0.0 || ^19.0.0",
67
+ "react-dom": "^18.0.0 || ^19.0.0"
68
+ },
69
+ "dependencies": {
70
+ "andy-widget-core": "2.0.5"
71
+ }
72
+ }