andy-widget-react 2.3.2 → 3.0.0-next.10

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.
@@ -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`. `nudge` shows a bubble above the closed Launcher in either mode.
9
+ */
3
10
  declare const AndyChat: React.FC<AndyChatProps>;
4
11
  export default AndyChat;
@@ -1,13 +1,6 @@
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 type { WidgetNudge } from 'andy-widget-core';
6
+ export { getApiBaseUrl, setApiBaseUrl } from 'andy-widget-core';
@@ -1,193 +1,70 @@
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
- }
1
+ import type { SupportOptions, WidgetNudge } 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
- 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
- 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
- /** Required chatbot embed ID (not required if previewMode is true) */
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
- /** Optional tooltip text for the chat bubble */
24
+ /** @deprecated The 3.x Launcher has no tooltip; its accessible name says what it opens. */
68
25
  tooltip?: string;
69
- /** Optional bot name (overrides API value) */
26
+ /** The Agent's name, over the configured one. */
70
27
  name?: string;
71
- /** Optional headline/subtitle (overrides API value) */
28
+ /** @deprecated Ignored: the 3.x Widget shows only the name and the Greeting, with no status line. */
72
29
  headline?: string;
73
- /** Optional description (overrides API value) */
30
+ /** @deprecated Ignored: the 3.x Widget shows only the name and the Greeting, with no intro description. */
74
31
  description?: string;
75
- /** Optional welcome message (overrides API value) */
32
+ /** The Greeting. */
76
33
  welcomeMessage?: string;
77
- /** Optional custom label for pill-style bubble (overrides default) */
34
+ /** The pill Launcher's label. */
78
35
  bubbleLabel?: string;
79
- /** Optional UI language for the widget's own chrome, overrides the Agent's defaultLang */
36
+ /** The Widget's language, over the host page's `<html lang>`, the browser's language and the Agent's `defaultLang`. */
80
37
  lang?: 'en' | 'es';
81
- /** Optional starter questions (overrides API value) */
38
+ /** The Starters. */
82
39
  predefinedQuestions?: PredefinedQuestion[];
83
- /** Optional theme ('light' | 'dark' | 'auto') */
84
40
  theme?: 'light' | 'dark' | 'auto';
85
- /** Optional position ('left' | 'right') */
41
+ /** The Launcher's side of the page. */
86
42
  orientation?: 'left' | 'right';
87
- /** Optional brand color hex (e.g., '#3B82F6') */
43
+ /** The accent, as `#RRGGBB`. */
88
44
  brandColor?: string;
89
- /** Optional bubble style ('icon' | 'pill') */
90
45
  bubbleStyle?: 'icon' | 'pill';
91
- /** Optional whether to use brand color */
46
+ /** `false` uses the neutral accent instead of `brandColor`. */
92
47
  useBrandColor?: boolean;
93
- /** Optional logo URL */
48
+ /** The avatar, also shown on the Launcher. */
94
49
  logoUrl?: string;
95
- /** If true, skip API fetch and use props directly as config */
50
+ /** Draws the overrides with no config fetched (a Widget Preview). Messages still reach `agentId`. */
96
51
  previewMode?: boolean;
97
- /** If true, start with chat window open */
52
+ /** Starts with the panel open. */
98
53
  initialOpen?: boolean;
54
+ /** A bubble above the closed Launcher, shown once per `id` in this browser; clicking it opens the panel with `draft` prefilled. */
55
+ nudge?: WidgetNudge | null;
99
56
  }
57
+ /** The 2.x Support-only props. */
100
58
  export interface SupportAndyChatProps {
59
+ /** @deprecated Pass `support` without `agentId`. */
101
60
  mode: 'support';
102
- support: import('andy-widget-core').SupportOptions;
61
+ support: SupportOptions;
103
62
  lang?: 'es' | 'en';
104
63
  orientation?: 'left' | 'right';
105
64
  initialOpen?: boolean;
65
+ /** A bubble above the closed Launcher, shown once per `id` in this browser; clicking it opens the panel with `draft` prefilled. */
66
+ nudge?: WidgetNudge | null;
67
+ /** @deprecated The 3.x Launcher has no tooltip; its accessible name says what it opens. */
106
68
  tooltip?: string;
107
69
  }
108
70
  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": "2.3.2",
4
- "description": "Official React Widget for embeddable Andy agents",
3
+ "version": "3.0.0-next.10",
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": "2.3.2"
63
+ "andy-widget-core": "3.0.0-next.10"
71
64
  }
72
65
  }
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { SupportAndyChatProps } from './types';
3
- /** A host identity change also destroys local drafts and menu state before the next render. */
4
- export declare const SupportChat: React.FC<SupportAndyChatProps>;
@@ -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,8 +0,0 @@
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;
@@ -1,8 +0,0 @@
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;
@@ -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,8 +0,0 @@
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;
@@ -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
- };