andy-widget-react 2.3.2 → 3.0.0-next.2
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.
- package/README.md +60 -57
- package/dist/index.cjs +88 -5214
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +84 -5193
- package/dist/index.esm.js.map +1 -1
- package/dist/types/AndyChat.d.ts +7 -0
- package/dist/types/index.d.ts +2 -10
- package/dist/types/types/index.d.ts +33 -161
- package/package.json +3 -10
- package/dist/types/SupportChat.d.ts +0 -4
- package/dist/types/components/ChatBubble.d.ts +0 -9
- package/dist/types/components/ChatWindow.d.ts +0 -11
- package/dist/types/components/FAQ.d.ts +0 -8
- package/dist/types/components/MessageInput.d.ts +0 -8
- package/dist/types/components/MessageList.d.ts +0 -10
- package/dist/types/components/UserInfoForm.d.ts +0 -10
- package/dist/types/components/WelcomePopup.d.ts +0 -8
- package/dist/types/hooks/index.d.ts +0 -1
- package/dist/types/hooks/useAndyChat.d.ts +0 -8
- package/dist/types/hooks/useSupportChat.d.ts +0 -24
- package/src/AndyChat.tsx +0 -1151
- package/src/SupportChat.tsx +0 -106
- package/src/components/ChatBubble.tsx +0 -48
- package/src/components/ChatWindow.tsx +0 -53
- package/src/components/FAQ.tsx +0 -48
- package/src/components/MessageInput.tsx +0 -83
- package/src/components/MessageList.tsx +0 -124
- package/src/components/UserInfoForm.tsx +0 -186
- package/src/components/WelcomePopup.tsx +0 -70
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useAndyChat.ts +0 -312
- package/src/hooks/useSupportChat.ts +0 -29
- package/src/index.ts +0 -67
- package/src/styles/main.css +0 -14
- package/src/types/index.ts +0 -235
package/dist/types/AndyChat.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { AndyChatProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The Andy Widget for React: one `<andy-chat>` element (`andy-widget-core`), whose Widget Mode comes from
|
|
5
|
+
* identity. It shows Sales (`agentId`) to a Visitor and Support to a Requester with a valid pass, and starts a
|
|
6
|
+
* fresh panel on every identity change; this component only hands the element its props. The 2.x props keep
|
|
7
|
+
* working: `embedId` and `mode="support"` as deprecated aliases, the copy and look overrides over the Agent's
|
|
8
|
+
* config, and `previewMode`.
|
|
9
|
+
*/
|
|
3
10
|
declare const AndyChat: React.FC<AndyChatProps>;
|
|
4
11
|
export default AndyChat;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
export { default as AndyChat } from './AndyChat';
|
|
2
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, SupportAndyChatProps, SalesAndyChatProps, 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
3
|
export { default } from './AndyChat';
|
|
4
|
+
export type { AndyChatProps, SalesAndyChatProps, SupportAndyChatProps, PredefinedQuestion } from './types';
|
|
5
|
+
export { getApiBaseUrl, setApiBaseUrl } from 'andy-widget-core';
|
|
@@ -1,193 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
}
|
|
1
|
+
import type { SupportOptions } from 'andy-widget-core';
|
|
2
|
+
/** A Starter as 2.x served them: the question and its place in the list. */
|
|
13
3
|
export interface PredefinedQuestion {
|
|
14
4
|
order: number;
|
|
15
5
|
question: string;
|
|
16
6
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
bootstrap?: {
|
|
41
|
-
convexUrl: string;
|
|
42
|
-
surfaceKey: string;
|
|
43
|
-
surfaceProof: string;
|
|
44
|
-
surfaceProofExpiresAt: number;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export interface Message {
|
|
48
|
-
id: string | number;
|
|
49
|
-
content: string;
|
|
50
|
-
sender: 'user' | 'bot';
|
|
51
|
-
timestamp: string;
|
|
52
|
-
isForm?: boolean;
|
|
53
|
-
isLoading?: boolean;
|
|
54
|
-
isError?: boolean;
|
|
55
|
-
isHuman?: boolean;
|
|
56
|
-
isWaiting?: boolean;
|
|
57
|
-
isStreaming?: boolean;
|
|
58
|
-
}
|
|
59
|
-
export interface UserInfo {
|
|
60
|
-
name: string;
|
|
61
|
-
email: string;
|
|
62
|
-
}
|
|
7
|
+
/**
|
|
8
|
+
* `AndyChat`'s props. Widget Mode comes from identity: `agentId` is the Sales Agent for anonymous Visitors,
|
|
9
|
+
* and `support` gives a signed-in Requester Support Mode once `getRequesterPass` hands over a pass. With
|
|
10
|
+
* `support` and no `agentId`, nothing shows until a Requester is verified. The copy and look overrides
|
|
11
|
+
* (`name` to `logoUrl`) replace the Agent's own in Sales Mode; `previewMode` draws them with no config fetched.
|
|
12
|
+
*/
|
|
63
13
|
export interface SalesAndyChatProps {
|
|
64
14
|
mode?: 'sales';
|
|
65
|
-
/**
|
|
15
|
+
/** The Sales Agent, shown to anonymous Visitors. */
|
|
16
|
+
agentId?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Support Mode for a signed-in Requester. Change `contextKey` on sign-in, sign-out and every user,
|
|
19
|
+
* workspace or organization switch; `getRequesterPass` returns `null` while nobody is signed in.
|
|
20
|
+
*/
|
|
21
|
+
support?: SupportOptions;
|
|
22
|
+
/** @deprecated Use `agentId`. */
|
|
66
23
|
embedId?: string;
|
|
67
|
-
/**
|
|
24
|
+
/** @deprecated The 3.x Launcher has no tooltip; its accessible name says what it opens. */
|
|
68
25
|
tooltip?: string;
|
|
69
|
-
/**
|
|
26
|
+
/** The Agent's name, over the configured one. */
|
|
70
27
|
name?: string;
|
|
71
|
-
/**
|
|
28
|
+
/** The status line under the name. */
|
|
72
29
|
headline?: string;
|
|
73
|
-
/** Optional description (overrides API value) */
|
|
74
30
|
description?: string;
|
|
75
|
-
/**
|
|
31
|
+
/** The Greeting. */
|
|
76
32
|
welcomeMessage?: string;
|
|
77
|
-
/**
|
|
33
|
+
/** The pill Launcher's label. */
|
|
78
34
|
bubbleLabel?: string;
|
|
79
|
-
/**
|
|
35
|
+
/** The Widget's language, over the host page's `<html lang>`, the browser's language and the Agent's `defaultLang`. */
|
|
80
36
|
lang?: 'en' | 'es';
|
|
81
|
-
/**
|
|
37
|
+
/** The Starters. */
|
|
82
38
|
predefinedQuestions?: PredefinedQuestion[];
|
|
83
|
-
/** Optional theme ('light' | 'dark' | 'auto') */
|
|
84
39
|
theme?: 'light' | 'dark' | 'auto';
|
|
85
|
-
/**
|
|
40
|
+
/** The Launcher's side of the page. */
|
|
86
41
|
orientation?: 'left' | 'right';
|
|
87
|
-
/**
|
|
42
|
+
/** The accent, as `#RRGGBB`. */
|
|
88
43
|
brandColor?: string;
|
|
89
|
-
/** Optional bubble style ('icon' | 'pill') */
|
|
90
44
|
bubbleStyle?: 'icon' | 'pill';
|
|
91
|
-
/**
|
|
45
|
+
/** `false` uses the neutral accent instead of `brandColor`. */
|
|
92
46
|
useBrandColor?: boolean;
|
|
93
|
-
/**
|
|
47
|
+
/** The avatar, also shown on the Launcher. */
|
|
94
48
|
logoUrl?: string;
|
|
95
|
-
/**
|
|
49
|
+
/** Draws the overrides with no config fetched (a Widget Preview). Messages still reach `agentId`. */
|
|
96
50
|
previewMode?: boolean;
|
|
97
|
-
/**
|
|
51
|
+
/** Starts with the panel open. */
|
|
98
52
|
initialOpen?: boolean;
|
|
99
53
|
}
|
|
54
|
+
/** The 2.x Support-only props. */
|
|
100
55
|
export interface SupportAndyChatProps {
|
|
56
|
+
/** @deprecated Pass `support` without `agentId`. */
|
|
101
57
|
mode: 'support';
|
|
102
|
-
support:
|
|
58
|
+
support: SupportOptions;
|
|
103
59
|
lang?: 'es' | 'en';
|
|
104
60
|
orientation?: 'left' | 'right';
|
|
105
61
|
initialOpen?: boolean;
|
|
62
|
+
/** @deprecated The 3.x Launcher has no tooltip; its accessible name says what it opens. */
|
|
106
63
|
tooltip?: string;
|
|
107
64
|
}
|
|
108
65
|
export type AndyChatProps = SalesAndyChatProps | SupportAndyChatProps;
|
|
109
|
-
export interface FaqItemProps {
|
|
110
|
-
question: string;
|
|
111
|
-
answer: string;
|
|
112
|
-
}
|
|
113
|
-
export interface ChatBubbleProps {
|
|
114
|
-
isOpen: boolean;
|
|
115
|
-
onClick: () => void;
|
|
116
|
-
tooltip?: string;
|
|
117
|
-
logoUrl?: string;
|
|
118
|
-
bubbleStyle?: 'icon' | 'pill';
|
|
119
|
-
bubbleLabel?: string;
|
|
120
|
-
theme?: 'light' | 'dark' | 'auto';
|
|
121
|
-
useBrandColor?: boolean;
|
|
122
|
-
}
|
|
123
|
-
export interface ChatWindowProps {
|
|
124
|
-
isOpen: boolean;
|
|
125
|
-
config: ChatbotConfig | null;
|
|
126
|
-
messages: Message[];
|
|
127
|
-
isLoading: boolean;
|
|
128
|
-
showPredefinedQuestions: boolean;
|
|
129
|
-
isCollectingUserInfo: boolean;
|
|
130
|
-
onClose: () => void;
|
|
131
|
-
onSendMessage: (message: string) => void;
|
|
132
|
-
onPredefinedQuestion: (question: string) => void;
|
|
133
|
-
onUserInfoSubmit: (e: React.FormEvent<HTMLFormElement>) => void;
|
|
134
|
-
}
|
|
135
|
-
export interface MessageListProps {
|
|
136
|
-
messages: Message[];
|
|
137
|
-
config: ChatbotConfig | null;
|
|
138
|
-
isLoading: boolean;
|
|
139
|
-
isCollectingUserInfo: boolean;
|
|
140
|
-
onUserInfoSubmit: (e: React.FormEvent<HTMLFormElement>) => void;
|
|
141
|
-
}
|
|
142
|
-
export interface MessageInputProps {
|
|
143
|
-
onSendMessage: (message: string) => void;
|
|
144
|
-
disabled?: boolean;
|
|
145
|
-
placeholder?: string;
|
|
146
|
-
}
|
|
147
|
-
export interface FAQProps {
|
|
148
|
-
faqs: FAQItem[];
|
|
149
|
-
onBack: () => void;
|
|
150
|
-
}
|
|
151
|
-
export interface WelcomePopupProps {
|
|
152
|
-
message: string;
|
|
153
|
-
orientation?: 'left' | 'right';
|
|
154
|
-
onClose: () => void;
|
|
155
|
-
}
|
|
156
|
-
export interface UserInfoFormProps {
|
|
157
|
-
message?: string;
|
|
158
|
-
onSubmit: (e: React.FormEvent<HTMLFormElement>) => void;
|
|
159
|
-
}
|
|
160
|
-
export interface UseAndyChatReturn {
|
|
161
|
-
config: Partial<ChatbotConfig>;
|
|
162
|
-
isLoading: boolean;
|
|
163
|
-
isOpen: boolean;
|
|
164
|
-
showingFaq: boolean;
|
|
165
|
-
showingWelcomePopup: boolean;
|
|
166
|
-
showingUserInfoForm: boolean;
|
|
167
|
-
messages: Message[];
|
|
168
|
-
userInfoCollected: boolean;
|
|
169
|
-
sessionId: string;
|
|
170
|
-
error: string | null;
|
|
171
|
-
initializeChatbot: () => Promise<void>;
|
|
172
|
-
toggleChat: () => void;
|
|
173
|
-
sendMessage: (messageText: string) => Promise<unknown>;
|
|
174
|
-
showFaq: () => void;
|
|
175
|
-
hideFaq: () => void;
|
|
176
|
-
showWelcomePopup: () => void;
|
|
177
|
-
hideWelcomePopup: () => void;
|
|
178
|
-
showUserInfoForm: () => void;
|
|
179
|
-
hideUserInfoForm: () => void;
|
|
180
|
-
submitUserInfo: (userInfo: UserInfo) => Promise<void>;
|
|
181
|
-
startNewSession: () => void;
|
|
182
|
-
addMessage: (message: Message) => void;
|
|
183
|
-
}
|
|
184
|
-
export interface StylesheetOptions {
|
|
185
|
-
color?: string;
|
|
186
|
-
useBrandColor?: boolean;
|
|
187
|
-
theme?: 'light' | 'dark' | 'auto';
|
|
188
|
-
orientation?: 'left' | 'right';
|
|
189
|
-
}
|
|
190
|
-
export interface HostClassOptions {
|
|
191
|
-
theme?: 'light' | 'dark' | 'auto';
|
|
192
|
-
orientation?: 'left' | 'right';
|
|
193
|
-
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "andy-widget-react",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.0.0-next.2",
|
|
4
|
+
"description": "The Andy Widget for React: a typed wrapper over <andy-chat>",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"dist/**/*",
|
|
18
|
-
"src/**/*",
|
|
19
18
|
"README.md"
|
|
20
19
|
],
|
|
21
20
|
"scripts": {
|
|
@@ -46,19 +45,13 @@
|
|
|
46
45
|
"access": "public"
|
|
47
46
|
},
|
|
48
47
|
"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
48
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
54
49
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
55
|
-
"@rollup/plugin-url": "^8.0.2",
|
|
56
50
|
"@types/react": "^19.1.2",
|
|
57
51
|
"@types/react-dom": "^19.1.2",
|
|
58
52
|
"react": "^19.0.0",
|
|
59
53
|
"react-dom": "^19.0.0",
|
|
60
54
|
"rollup": "^4.41.1",
|
|
61
|
-
"rollup-plugin-postcss": "^4.0.2",
|
|
62
55
|
"tslib": "^2.8.1",
|
|
63
56
|
"typescript": "^5.9.3"
|
|
64
57
|
},
|
|
@@ -67,6 +60,6 @@
|
|
|
67
60
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
68
61
|
},
|
|
69
62
|
"dependencies": {
|
|
70
|
-
"andy-widget-core": "
|
|
63
|
+
"andy-widget-core": "3.0.0-next.2"
|
|
71
64
|
}
|
|
72
65
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
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;
|
|
@@ -1,11 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useAndyChat } from './useAndyChat';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { UseAndyChatReturn } from '../types';
|
|
2
|
-
import type { SupportOptions } from 'andy-widget-core';
|
|
3
|
-
import { useSupportChat } from './useSupportChat';
|
|
4
|
-
export declare function useAndyChat(embedId: string): UseAndyChatReturn;
|
|
5
|
-
export declare function useAndyChat(options: {
|
|
6
|
-
mode: 'support';
|
|
7
|
-
support: SupportOptions;
|
|
8
|
-
}): ReturnType<typeof useSupportChat>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type SupportOptions, type SupportState } from 'andy-widget-core';
|
|
2
|
-
/** The host context key changes before a new user/company is allowed to see any previous state. */
|
|
3
|
-
export declare const useSupportChat: (options: SupportOptions | null) => {
|
|
4
|
-
mode: "support";
|
|
5
|
-
state: SupportState;
|
|
6
|
-
controller: {
|
|
7
|
-
getSnapshot: () => SupportState;
|
|
8
|
-
subscribe: (listener: () => void) => () => void;
|
|
9
|
-
bootstrap: () => Promise<unknown>;
|
|
10
|
-
send: (content: string) => Promise<unknown>;
|
|
11
|
-
escalate: () => void;
|
|
12
|
-
submit: (subject: string, body: string, replyLanguage?: "es" | "en") => Promise<unknown>;
|
|
13
|
-
showRequests: () => Promise<unknown>;
|
|
14
|
-
inspect: (ticketId: string) => Promise<unknown>;
|
|
15
|
-
reply: (body: string, reopen?: boolean) => Promise<unknown>;
|
|
16
|
-
newProblem: () => void;
|
|
17
|
-
refresh: () => Promise<unknown>;
|
|
18
|
-
setVisible: (visible: boolean) => void;
|
|
19
|
-
setLanguage: (lang?: "es" | "en") => void;
|
|
20
|
-
newConversation: () => void;
|
|
21
|
-
back: () => void;
|
|
22
|
-
dispose: () => void;
|
|
23
|
-
} | null;
|
|
24
|
-
};
|