@developer.notchatbot/webchat 1.4.5 → 1.4.6
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 +58 -0
- package/dist/components/whatsapp/WhatsAppButton.d.ts +12 -0
- package/dist/index.d.ts +3 -2
- package/dist/types.d.ts +31 -0
- package/dist/webchat-bundle.min.js +3722 -3521
- package/dist/webchat-bundle.min.umd.cjs +41 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,6 +38,12 @@ interface WebChatConfig {
|
|
|
38
38
|
marginSide?: number; // Distance from left/right edge in pixels (default: 16)
|
|
39
39
|
mobile?: WebChatPositionConfig; // Mobile-specific position settings
|
|
40
40
|
desktop?: WebChatPositionConfig; // Desktop-specific position settings
|
|
41
|
+
whatsapp?: { // Integrated WhatsApp Options
|
|
42
|
+
phoneNumber: string; // WhatsApp phone number
|
|
43
|
+
message?: string; // Optional default message text
|
|
44
|
+
active?: boolean; // Enable or disable the button (default: true)
|
|
45
|
+
color?: string; // Customize the internal WhatsApp button color
|
|
46
|
+
};
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
interface WebChatPositionConfig {
|
|
@@ -69,10 +75,51 @@ WebChat.initialize({
|
|
|
69
75
|
position: "bottom-right",
|
|
70
76
|
marginBottom: 30,
|
|
71
77
|
marginSide: 30
|
|
78
|
+
},
|
|
79
|
+
whatsapp: { // Adds a dual-button menu for WhatsApp & WebChat
|
|
80
|
+
phoneNumber: "YOUR_PHONE_NUMBER",
|
|
81
|
+
message: "Hello! I need help...",
|
|
82
|
+
active: true,
|
|
83
|
+
color: "#25D366"
|
|
72
84
|
}
|
|
73
85
|
});
|
|
74
86
|
```
|
|
75
87
|
|
|
88
|
+
# 💬 WhatsApp Button
|
|
89
|
+
|
|
90
|
+
If you simply want a floating WhatsApp action button with no WebChat, you can use `WhatsAppButtonAPI`, which isolates itself in the Shadow DOM to avoid CSS conflicts.
|
|
91
|
+
|
|
92
|
+
## 📦 Installation and Basic Usage
|
|
93
|
+
|
|
94
|
+
```html
|
|
95
|
+
<!-- Load the script -->
|
|
96
|
+
<script src="path/to/webchat.js"></script>
|
|
97
|
+
<script>
|
|
98
|
+
WhatsAppButtonAPI.initialize({
|
|
99
|
+
phoneNumber: "1234567890",
|
|
100
|
+
message: "Hola, me gustaría tener más información.",
|
|
101
|
+
color: "#25D366",
|
|
102
|
+
position: "bottom-right",
|
|
103
|
+
marginBottom: 20,
|
|
104
|
+
marginSide: 20,
|
|
105
|
+
active: true,
|
|
106
|
+
size: 48, // Button dimension in px
|
|
107
|
+
|
|
108
|
+
// Customize device-specific positioning
|
|
109
|
+
desktop: {
|
|
110
|
+
position: "bottom-right",
|
|
111
|
+
marginBottom: 30,
|
|
112
|
+
marginSide: 30
|
|
113
|
+
},
|
|
114
|
+
mobile: {
|
|
115
|
+
position: "bottom-right",
|
|
116
|
+
marginBottom: 80,
|
|
117
|
+
marginSide: 15
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
</script>
|
|
121
|
+
```
|
|
122
|
+
|
|
76
123
|
# 💬 EmbedChat - Embedded Chat
|
|
77
124
|
|
|
78
125
|
EmbedChat allows you to integrate a complete chat system directly into any element of your web page, with full control over size, position, and style.
|
|
@@ -316,6 +363,17 @@ window.unmountEmbedChat('embed-small'); // Unmounts the chat from the element wi
|
|
|
316
363
|
window.mountEmbedChat('embed-small'); // Remounts the chat in the same element with the last config
|
|
317
364
|
```
|
|
318
365
|
|
|
366
|
+
### WhatsApp Global Methods
|
|
367
|
+
|
|
368
|
+
You can programatically show, hide, or destroy the standalone WhatsApp button from the Global window object.
|
|
369
|
+
|
|
370
|
+
```js
|
|
371
|
+
window.WhatsAppButton.initialize(config); // Initializes the standalone widget
|
|
372
|
+
window.hideWhatsApp(); // Hides WhatsApp button (display: none)
|
|
373
|
+
window.showWhatsApp(); // Unhides it
|
|
374
|
+
window.unmountWhatsApp(); // Removes from DOM entirely
|
|
375
|
+
```
|
|
376
|
+
|
|
319
377
|
---
|
|
320
378
|
|
|
321
379
|
### Listen to lifecycle & message events (🆕)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface WhatsAppButtonProps {
|
|
3
|
+
phoneNumber: string;
|
|
4
|
+
color?: string;
|
|
5
|
+
position?: 'bottom-right' | 'bottom-left';
|
|
6
|
+
marginBottom?: number;
|
|
7
|
+
marginSide?: number;
|
|
8
|
+
size?: number;
|
|
9
|
+
message?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const WhatsAppButton: React.FC<WhatsAppButtonProps>;
|
|
12
|
+
export default WhatsAppButton;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { WebChatAPI, EmbedChatAPI } from './types';
|
|
1
|
+
import { WebChatAPI, EmbedChatAPI, WhatsAppAPI } from './types';
|
|
2
2
|
declare const WebChat: WebChatAPI;
|
|
3
3
|
declare const EmbedChatAPI: EmbedChatAPI;
|
|
4
|
-
|
|
4
|
+
declare const WhatsAppButtonAPI: WhatsAppAPI;
|
|
5
|
+
export { WebChat, EmbedChatAPI, WhatsAppButtonAPI };
|
package/dist/types.d.ts
CHANGED
|
@@ -22,6 +22,9 @@ export interface WebChatConfig {
|
|
|
22
22
|
note?: string;
|
|
23
23
|
mobile?: WebChatPositionConfig;
|
|
24
24
|
desktop?: WebChatPositionConfig;
|
|
25
|
+
whatsapp?: Omit<WhatsAppConfig, 'position' | 'marginBottom' | 'marginSide' | 'mobile' | 'desktop'> & {
|
|
26
|
+
active?: boolean;
|
|
27
|
+
};
|
|
25
28
|
}
|
|
26
29
|
export interface EmbedChatInputConfig {
|
|
27
30
|
backgroundColor?: string;
|
|
@@ -111,6 +114,8 @@ export interface ChatButtonProps {
|
|
|
111
114
|
marginSide?: number;
|
|
112
115
|
hasNewMessages?: boolean;
|
|
113
116
|
isMobile?: boolean;
|
|
117
|
+
isMenuOpen?: boolean;
|
|
118
|
+
hasWhatsAppMenu?: boolean;
|
|
114
119
|
}
|
|
115
120
|
export interface ChatWindowProps {
|
|
116
121
|
isOpen: boolean;
|
|
@@ -192,3 +197,29 @@ export interface WebChatAPI {
|
|
|
192
197
|
export interface EmbedChatAPI {
|
|
193
198
|
initialize: (config: EmbedChatConfig) => EmbedChatInstance | null;
|
|
194
199
|
}
|
|
200
|
+
export interface WhatsAppPositionConfig {
|
|
201
|
+
position?: 'bottom-right' | 'bottom-left';
|
|
202
|
+
marginBottom?: number;
|
|
203
|
+
marginSide?: number;
|
|
204
|
+
}
|
|
205
|
+
export interface WhatsAppConfig {
|
|
206
|
+
phoneNumber: string;
|
|
207
|
+
active?: boolean;
|
|
208
|
+
color?: string;
|
|
209
|
+
position?: 'bottom-right' | 'bottom-left';
|
|
210
|
+
marginBottom?: number;
|
|
211
|
+
marginSide?: number;
|
|
212
|
+
size?: number;
|
|
213
|
+
message?: string;
|
|
214
|
+
mobile?: WhatsAppPositionConfig;
|
|
215
|
+
desktop?: WhatsAppPositionConfig;
|
|
216
|
+
}
|
|
217
|
+
export interface WhatsAppInstance {
|
|
218
|
+
destroy: () => void;
|
|
219
|
+
hide: () => void;
|
|
220
|
+
show: () => void;
|
|
221
|
+
updateConfig: (newConfig: Partial<WhatsAppConfig>) => void;
|
|
222
|
+
}
|
|
223
|
+
export interface WhatsAppAPI {
|
|
224
|
+
initialize: (config: WhatsAppConfig) => WhatsAppInstance | null;
|
|
225
|
+
}
|