@product7/product7-js 0.5.2 → 0.5.4
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 +4 -4
- package/dist/README.md +4 -4
- package/dist/product7-js.js +7120 -7132
- package/dist/product7-js.js.map +1 -1
- package/dist/product7-js.min.js +1 -1
- package/dist/product7-js.min.js.map +1 -1
- package/package.json +1 -1
- package/src/api/APIService.js +1 -0
- package/src/api/services/{MessengerService.js → WebChatService.js} +15 -15
- package/src/core/APIService.js +16 -16
- package/src/core/Product7.js +4 -4
- package/src/core/WebSocketService.js +3 -3
- package/src/docs/api.md +9 -9
- package/src/docs/example.md +12 -12
- package/src/docs/framework-integrations.md +5 -5
- package/src/index.js +41 -42
- package/src/styles/base.js +9 -9
- package/src/styles/design-tokens.js +2 -2
- package/src/styles/feedback.js +2 -2
- package/src/styles/styles.js +4 -4
- package/src/styles/{messenger-components.js → web-chat-components.js} +114 -114
- package/src/styles/{messenger-core.js → web-chat-core.js} +32 -32
- package/src/styles/{messenger-features.js → web-chat-features.js} +20 -20
- package/src/styles/{messenger-views.js → web-chat-views.js} +137 -137
- package/src/styles/web-chat.js +17 -0
- package/src/styles/{messengerCustomStyles.js → webChatCustomStyles.js} +17 -19
- package/src/widgets/{MessengerWidget.js → WebChatWidget.js} +169 -172
- package/src/widgets/WidgetFactory.js +3 -3
- package/src/widgets/{messenger/MessengerState.js → web-chat/WebChatState.js} +1 -1
- package/src/widgets/{messenger → web-chat}/components/NavigationTabs.js +13 -13
- package/src/widgets/{messenger/components/MessengerLauncher.js → web-chat/components/WebChatLauncher.js} +15 -17
- package/src/widgets/{messenger/components/MessengerPanel.js → web-chat/components/WebChatPanel.js} +11 -11
- package/src/widgets/{messenger → web-chat}/views/ChangelogView.js +17 -17
- package/src/widgets/{messenger → web-chat}/views/ChatView.js +97 -99
- package/src/widgets/{messenger → web-chat}/views/ConversationsView.js +24 -24
- package/src/widgets/{messenger → web-chat}/views/HelpView.js +29 -29
- package/src/widgets/{messenger → web-chat}/views/HomeView.js +53 -55
- package/src/widgets/{messenger → web-chat}/views/PreChatFormView.js +17 -17
- package/src/styles/messenger.js +0 -17
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { MOCK_CONVERSATIONS, MOCK_MESSAGES } from '../mock-data/index.js';
|
|
1
|
+
import { MOCK_CONVERSATIONS, MOCK_MESSAGES } from '../mock-data/index.js';
|
|
2
2
|
import { delay } from '../utils/helpers.js';
|
|
3
3
|
|
|
4
|
-
export class
|
|
4
|
+
export class WebChatService {
|
|
5
5
|
constructor(baseAPI) {
|
|
6
6
|
this.api = baseAPI;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
async
|
|
9
|
+
async getWebChatSettings() {
|
|
10
10
|
await this.api._ensureSession();
|
|
11
11
|
|
|
12
12
|
if (this.api.mock) {
|
|
@@ -21,7 +21,7 @@ export class MessengerService {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
return this.api._makeRequest('/widget/
|
|
24
|
+
return this.api._makeRequest('/widget/web-chat/settings', {
|
|
25
25
|
method: 'GET',
|
|
26
26
|
headers: { Authorization: `Bearer ${this.api.sessionToken}` },
|
|
27
27
|
});
|
|
@@ -45,7 +45,7 @@ export class MessengerService {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
return this.api._makeRequest('/widget/
|
|
48
|
+
return this.api._makeRequest('/widget/web-chat/agents/online', {
|
|
49
49
|
method: 'GET',
|
|
50
50
|
headers: { Authorization: `Bearer ${this.api.sessionToken}` },
|
|
51
51
|
});
|
|
@@ -64,7 +64,7 @@ export class MessengerService {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const endpoint = this.api._getEndpointWithParams(
|
|
67
|
-
'/widget/
|
|
67
|
+
'/widget/web-chat/conversations',
|
|
68
68
|
options
|
|
69
69
|
);
|
|
70
70
|
return this.api._makeRequest(endpoint, {
|
|
@@ -86,7 +86,7 @@ export class MessengerService {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
return this.api._makeRequest(
|
|
89
|
-
`/widget/
|
|
89
|
+
`/widget/web-chat/conversations/${conversationId}`,
|
|
90
90
|
{
|
|
91
91
|
method: 'GET',
|
|
92
92
|
headers: { Authorization: `Bearer ${this.api.sessionToken}` },
|
|
@@ -120,7 +120,7 @@ export class MessengerService {
|
|
|
120
120
|
return { status: true, data: newConv };
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
return this.api._makeRequest('/widget/
|
|
123
|
+
return this.api._makeRequest('/widget/web-chat/conversations', {
|
|
124
124
|
method: 'POST',
|
|
125
125
|
headers: {
|
|
126
126
|
'Content-Type': 'application/json',
|
|
@@ -154,7 +154,7 @@ export class MessengerService {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
return this.api._makeRequest(
|
|
157
|
-
`/widget/
|
|
157
|
+
`/widget/web-chat/conversations/${conversationId}/messages`,
|
|
158
158
|
{
|
|
159
159
|
method: 'POST',
|
|
160
160
|
headers: {
|
|
@@ -183,7 +183,7 @@ export class MessengerService {
|
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
return this.api._makeRequest('/widget/
|
|
186
|
+
return this.api._makeRequest('/widget/web-chat/unread', {
|
|
187
187
|
method: 'GET',
|
|
188
188
|
headers: { Authorization: `Bearer ${this.api.sessionToken}` },
|
|
189
189
|
});
|
|
@@ -197,7 +197,7 @@ export class MessengerService {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
return this.api._makeRequest(
|
|
200
|
-
`/widget/
|
|
200
|
+
`/widget/web-chat/conversations/${conversationId}/read`,
|
|
201
201
|
{
|
|
202
202
|
method: 'POST',
|
|
203
203
|
headers: { Authorization: `Bearer ${this.api.sessionToken}` },
|
|
@@ -219,7 +219,7 @@ export class MessengerService {
|
|
|
219
219
|
|
|
220
220
|
const params = { ...options };
|
|
221
221
|
const endpoint = this.api._getEndpointWithParams(
|
|
222
|
-
`/widget/
|
|
222
|
+
`/widget/web-chat/conversations/${conversationId}/messages`,
|
|
223
223
|
params
|
|
224
224
|
);
|
|
225
225
|
return this.api._makeRequest(endpoint, {
|
|
@@ -236,7 +236,7 @@ export class MessengerService {
|
|
|
236
236
|
return { status: true, url: `https://mock-cdn.example.com/${filename}` };
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
return this.api._makeRequest('/widget/
|
|
239
|
+
return this.api._makeRequest('/widget/web-chat/upload', {
|
|
240
240
|
method: 'POST',
|
|
241
241
|
headers: {
|
|
242
242
|
'Content-Type': 'application/json',
|
|
@@ -258,7 +258,7 @@ export class MessengerService {
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
return this.api._makeRequest(
|
|
261
|
-
`/widget/
|
|
261
|
+
`/widget/web-chat/conversations/${conversationId}/rating`,
|
|
262
262
|
{
|
|
263
263
|
method: 'POST',
|
|
264
264
|
headers: {
|
|
@@ -278,7 +278,7 @@ export class MessengerService {
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
return this.api._makeRequest(
|
|
281
|
-
`/widget/
|
|
281
|
+
`/widget/web-chat/conversations/${conversationId}/typing`,
|
|
282
282
|
{
|
|
283
283
|
method: 'POST',
|
|
284
284
|
headers: {
|
package/src/core/APIService.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ChangelogService } from '../api/services/ChangelogService.js';
|
|
1
|
+
import { ChangelogService } from '../api/services/ChangelogService.js';
|
|
2
2
|
import { FeedbackService } from '../api/services/FeedbackService.js';
|
|
3
3
|
import { HelpService } from '../api/services/HelpService.js';
|
|
4
|
-
import { MessengerService } from '../api/services/MessengerService.js';
|
|
5
4
|
import { SurveyService } from '../api/services/SurveyService.js';
|
|
5
|
+
import { WebChatService } from '../api/services/WebChatService.js';
|
|
6
6
|
import { BaseAPIService } from './BaseAPIService.js';
|
|
7
7
|
|
|
8
8
|
export class APIService extends BaseAPIService {
|
|
@@ -11,7 +11,7 @@ export class APIService extends BaseAPIService {
|
|
|
11
11
|
|
|
12
12
|
this.feedback = new FeedbackService(this);
|
|
13
13
|
this.survey = new SurveyService(this);
|
|
14
|
-
this.
|
|
14
|
+
this.webChat = new WebChatService(this);
|
|
15
15
|
this.help = new HelpService(this);
|
|
16
16
|
this.changelog = new ChangelogService(this);
|
|
17
17
|
}
|
|
@@ -32,52 +32,52 @@ export class APIService extends BaseAPIService {
|
|
|
32
32
|
return this.survey.dismissSurvey(surveyId);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
async
|
|
36
|
-
return this.
|
|
35
|
+
async getWebChatSettings() {
|
|
36
|
+
return this.webChat.getWebChatSettings();
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
async checkAgentsOnline() {
|
|
40
|
-
return this.
|
|
40
|
+
return this.webChat.checkAgentsOnline();
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
async getConversations(options) {
|
|
44
|
-
return this.
|
|
44
|
+
return this.webChat.getConversations(options);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
async getConversation(conversationId) {
|
|
48
|
-
return this.
|
|
48
|
+
return this.webChat.getConversation(conversationId);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
async getMessages(conversationId, options) {
|
|
52
|
-
return this.
|
|
52
|
+
return this.webChat.getMessages(conversationId, options);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
async startConversation(data) {
|
|
56
|
-
return this.
|
|
56
|
+
return this.webChat.startConversation(data);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
async sendMessage(conversationId, data) {
|
|
60
|
-
return this.
|
|
60
|
+
return this.webChat.sendMessage(conversationId, data);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
async uploadFile(base64Data, filename) {
|
|
64
|
-
return this.
|
|
64
|
+
return this.webChat.uploadFile(base64Data, filename);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
async sendTypingIndicator(conversationId, isTyping) {
|
|
68
|
-
return this.
|
|
68
|
+
return this.webChat.sendTypingIndicator(conversationId, isTyping);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
async markConversationAsRead(conversationId) {
|
|
72
|
-
return this.
|
|
72
|
+
return this.webChat.markConversationAsRead(conversationId);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
async getUnreadCount() {
|
|
76
|
-
return this.
|
|
76
|
+
return this.webChat.getUnreadCount();
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
async submitRating(conversationId, data) {
|
|
80
|
-
return this.
|
|
80
|
+
return this.webChat.submitRating(conversationId, data);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
async identify(metadata) {
|
package/src/core/Product7.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSS_STYLES } from '../styles/styles.js';
|
|
1
|
+
import { CSS_STYLES } from '../styles/styles.js';
|
|
2
2
|
import { ConfigError, SDKError } from '../utils/errors.js';
|
|
3
3
|
import { deepMerge, generateId } from '../utils/helpers.js';
|
|
4
4
|
import { WidgetFactory } from '../widgets/WidgetFactory.js';
|
|
@@ -130,8 +130,8 @@ export class Product7 {
|
|
|
130
130
|
return this.createWidget('feedback', options);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
return this.createWidget('
|
|
133
|
+
createWebChatWidget(options = {}) {
|
|
134
|
+
return this.createWidget('webChat', options);
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
createChangelogWidget(options = {}) {
|
|
@@ -923,7 +923,7 @@ export class Product7 {
|
|
|
923
923
|
_bindMethods() {
|
|
924
924
|
this.createWidget = this.createWidget.bind(this);
|
|
925
925
|
this.createFeedbackWidget = this.createFeedbackWidget.bind(this);
|
|
926
|
-
this.
|
|
926
|
+
this.createWebChatWidget = this.createWebChatWidget.bind(this);
|
|
927
927
|
this.createChangelogWidget = this.createChangelogWidget.bind(this);
|
|
928
928
|
this.createSurveyWidget = this.createSurveyWidget.bind(this);
|
|
929
929
|
this.destroyWidget = this.destroyWidget.bind(this);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebSocketService - Real-time communication for
|
|
1
|
+
/**
|
|
2
|
+
* WebSocketService - Real-time communication for web chat widget
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export class WebSocketService {
|
|
@@ -51,7 +51,7 @@ export class WebSocketService {
|
|
|
51
51
|
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
52
52
|
let wsURL = this.baseURL.replace(/^https?:/, wsProtocol);
|
|
53
53
|
wsURL = wsURL.replace('/api/v1', '');
|
|
54
|
-
wsURL = `${wsURL}/api/v1/widget/
|
|
54
|
+
wsURL = `${wsURL}/api/v1/widget/web-chat/ws?token=${encodeURIComponent(this.sessionToken)}`;
|
|
55
55
|
|
|
56
56
|
try {
|
|
57
57
|
this.ws = new WebSocket(wsURL);
|
package/src/docs/api.md
CHANGED
|
@@ -60,9 +60,9 @@ const widget = sdk.createFeedbackWidget({
|
|
|
60
60
|
});
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
#### `
|
|
63
|
+
#### `createWebChatWidget(options?): WebChatWidget`
|
|
64
64
|
|
|
65
|
-
Creates the
|
|
65
|
+
Creates the web chat widget.
|
|
66
66
|
|
|
67
67
|
#### `createChangelogWidget(options?): ChangelogWidget`
|
|
68
68
|
|
|
@@ -78,7 +78,7 @@ Low-level factory for advanced usage. Supported types include:
|
|
|
78
78
|
|
|
79
79
|
- `'feedback'`
|
|
80
80
|
- `'button'` (legacy alias for feedback)
|
|
81
|
-
- `'
|
|
81
|
+
- `'webChat'`
|
|
82
82
|
- `'survey'`
|
|
83
83
|
- `'changelog'`
|
|
84
84
|
- `'inline'`
|
|
@@ -186,9 +186,9 @@ Created by `sdk.createFeedbackWidget()` or `sdk.createWidget('feedback', ...)`.
|
|
|
186
186
|
|
|
187
187
|
---
|
|
188
188
|
|
|
189
|
-
##
|
|
189
|
+
## WebChatWidget
|
|
190
190
|
|
|
191
|
-
Created by `sdk.
|
|
191
|
+
Created by `sdk.createWebChatWidget()`.
|
|
192
192
|
|
|
193
193
|
### Methods
|
|
194
194
|
|
|
@@ -299,11 +299,11 @@ Created by `sdk.createChangelogWidget()`.
|
|
|
299
299
|
- `feedback:submitted`
|
|
300
300
|
- `feedback:error`
|
|
301
301
|
|
|
302
|
-
###
|
|
302
|
+
### Web Chat Events
|
|
303
303
|
|
|
304
|
-
- `
|
|
305
|
-
- `
|
|
306
|
-
- `
|
|
304
|
+
- `webChat:opened`
|
|
305
|
+
- `webChat:closed`
|
|
306
|
+
- `webChat:messageSent`
|
|
307
307
|
|
|
308
308
|
### Survey Events
|
|
309
309
|
|
package/src/docs/example.md
CHANGED
|
@@ -203,42 +203,42 @@ if (surveys.length > 0) {
|
|
|
203
203
|
|
|
204
204
|
---
|
|
205
205
|
|
|
206
|
-
##
|
|
206
|
+
## Web Chat Widget
|
|
207
207
|
|
|
208
|
-
### Basic
|
|
208
|
+
### Basic Web Chat
|
|
209
209
|
|
|
210
210
|
```javascript
|
|
211
|
-
const
|
|
211
|
+
const webChat = sdk.createWebChatWidget({
|
|
212
212
|
position: 'bottom-right',
|
|
213
213
|
teamName: 'Support Team',
|
|
214
214
|
enableHelp: true,
|
|
215
215
|
enableChangelog: true,
|
|
216
216
|
});
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
webChat.mount();
|
|
219
219
|
```
|
|
220
220
|
|
|
221
|
-
### Headless
|
|
221
|
+
### Headless Web Chat
|
|
222
222
|
|
|
223
223
|
```javascript
|
|
224
|
-
const
|
|
224
|
+
const webChat = sdk.createWebChatWidget({
|
|
225
225
|
headless: true,
|
|
226
226
|
enableHelp: true,
|
|
227
227
|
});
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
webChat.mount();
|
|
230
230
|
|
|
231
231
|
document
|
|
232
232
|
.querySelector('#support-link')
|
|
233
|
-
?.addEventListener('click', () =>
|
|
233
|
+
?.addEventListener('click', () => webChat.open());
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
-
### Programmatic
|
|
236
|
+
### Programmatic Web Chat Navigation
|
|
237
237
|
|
|
238
238
|
```javascript
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
webChat.open();
|
|
240
|
+
webChat.navigateTo('help');
|
|
241
|
+
webChat.close();
|
|
242
242
|
```
|
|
243
243
|
|
|
244
244
|
---
|
|
@@ -542,7 +542,7 @@ Astro renders on the server by default, so initialize Product7 from a client-loa
|
|
|
542
542
|
|
|
543
543
|
## Adding More Widgets
|
|
544
544
|
|
|
545
|
-
Use the same SDK instance for feedback, survey,
|
|
545
|
+
Use the same SDK instance for feedback, survey, web chat, and changelog.
|
|
546
546
|
|
|
547
547
|
```ts
|
|
548
548
|
const feedback = sdk.createFeedbackWidget({
|
|
@@ -560,13 +560,13 @@ const survey = sdk.createSurveyWidget({
|
|
|
560
560
|
survey.mount();
|
|
561
561
|
survey.open();
|
|
562
562
|
|
|
563
|
-
const
|
|
563
|
+
const webChat = sdk.createWebChatWidget({
|
|
564
564
|
position: 'bottom-right',
|
|
565
565
|
teamName: 'Support Team',
|
|
566
566
|
enableHelp: true,
|
|
567
567
|
enableChangelog: true,
|
|
568
568
|
});
|
|
569
|
-
|
|
569
|
+
webChat.mount();
|
|
570
570
|
|
|
571
571
|
const changelog = sdk.createChangelogWidget({
|
|
572
572
|
position: 'bottom-left',
|
|
@@ -588,5 +588,5 @@ changelog.mount();
|
|
|
588
588
|
Move SDK code to client-only lifecycle hooks or client-only components.
|
|
589
589
|
- Duplicate widget instances
|
|
590
590
|
Cache widget references and avoid remounting in repeated renders.
|
|
591
|
-
-
|
|
592
|
-
Use `headless: true` when creating the
|
|
591
|
+
- Web chat shows the launcher when you want only programmatic control
|
|
592
|
+
Use `headless: true` when creating the web chat widget.
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APIService } from './core/APIService.js';
|
|
1
|
+
import { APIService } from './core/APIService.js';
|
|
2
2
|
import { EventBus } from './core/EventBus.js';
|
|
3
3
|
import { Product7 as Product7SDK } from './core/Product7.js';
|
|
4
4
|
import {
|
|
@@ -13,9 +13,9 @@ import { BaseWidget } from './widgets/BaseWidget.js';
|
|
|
13
13
|
import { ButtonWidget } from './widgets/ButtonWidget.js';
|
|
14
14
|
import { ChangelogWidget } from './widgets/ChangelogWidget.js';
|
|
15
15
|
import { InlineWidget } from './widgets/InlineWidget.js';
|
|
16
|
-
import { MessengerWidget } from './widgets/MessengerWidget.js';
|
|
17
16
|
import { SurveyWidget } from './widgets/SurveyWidget.js';
|
|
18
17
|
import { TabWidget } from './widgets/TabWidget.js';
|
|
18
|
+
import { WebChatWidget } from './widgets/WebChatWidget.js';
|
|
19
19
|
import { WidgetFactory } from './widgets/WidgetFactory.js';
|
|
20
20
|
|
|
21
21
|
// --- Identify: transform flat user data into internal format ---
|
|
@@ -143,7 +143,7 @@ const Product7 = {
|
|
|
143
143
|
_organization: null,
|
|
144
144
|
_q: [],
|
|
145
145
|
_feedbackWidget: null,
|
|
146
|
-
|
|
146
|
+
_WebChatWidget: null,
|
|
147
147
|
_surveyWidget: null,
|
|
148
148
|
|
|
149
149
|
version: '1.0.0',
|
|
@@ -330,13 +330,13 @@ const Product7 = {
|
|
|
330
330
|
},
|
|
331
331
|
|
|
332
332
|
// ==================
|
|
333
|
-
//
|
|
333
|
+
// Web Chat
|
|
334
334
|
// ==================
|
|
335
335
|
|
|
336
|
-
async
|
|
336
|
+
async webChat(options = {}, callback) {
|
|
337
337
|
const sdk = await ensureSDK(options);
|
|
338
338
|
if (!sdk) {
|
|
339
|
-
Product7._q.push(['
|
|
339
|
+
Product7._q.push(['webChat', options, callback]);
|
|
340
340
|
return null;
|
|
341
341
|
}
|
|
342
342
|
|
|
@@ -372,63 +372,62 @@ const Product7 = {
|
|
|
372
372
|
widgetOptions.position = options.placement;
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
-
//
|
|
375
|
+
// Web Chat is always explicitly shown — never suppress based on feedback submission history
|
|
376
376
|
widgetOptions.suppressAfterSubmission = false;
|
|
377
377
|
widgetOptions.enabled = true;
|
|
378
378
|
|
|
379
379
|
try {
|
|
380
|
-
const widget = sdk.
|
|
380
|
+
const widget = sdk.createWebChatWidget(widgetOptions);
|
|
381
381
|
widget.mount();
|
|
382
382
|
widget.show();
|
|
383
383
|
|
|
384
|
-
Product7.
|
|
384
|
+
Product7._WebChatWidget = widget;
|
|
385
385
|
|
|
386
386
|
if (typeof callback === 'function') {
|
|
387
387
|
callback({ action: 'widgetReady' });
|
|
388
388
|
|
|
389
|
-
sdk.eventBus.on('
|
|
389
|
+
sdk.eventBus.on('webChat:messageSent', (data) => {
|
|
390
390
|
callback({ action: 'messageSent', message: data });
|
|
391
391
|
});
|
|
392
392
|
|
|
393
|
-
sdk.eventBus.on('
|
|
394
|
-
callback({ action: '
|
|
393
|
+
sdk.eventBus.on('webChat:opened', () => {
|
|
394
|
+
callback({ action: 'webChatOpened' });
|
|
395
395
|
});
|
|
396
396
|
|
|
397
|
-
sdk.eventBus.on('
|
|
398
|
-
callback({ action: '
|
|
397
|
+
sdk.eventBus.on('webChat:closed', () => {
|
|
398
|
+
callback({ action: 'webChatClosed' });
|
|
399
399
|
});
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
-
// Listen for data-product7-
|
|
403
|
-
Product7.
|
|
402
|
+
// Listen for data-product7-web-chat clicks
|
|
403
|
+
Product7._setupWebChatAttributeTriggers();
|
|
404
404
|
Product7._setupPostMessageListener();
|
|
405
405
|
|
|
406
406
|
return widget;
|
|
407
407
|
} catch (error) {
|
|
408
|
-
console.error('[Product7] Failed to initialize
|
|
408
|
+
console.error('[Product7] Failed to initialize web chat widget:', error);
|
|
409
409
|
if (typeof callback === 'function') callback({ action: 'error', error });
|
|
410
410
|
return null;
|
|
411
411
|
}
|
|
412
412
|
},
|
|
413
413
|
|
|
414
|
-
|
|
415
|
-
if (Product7.
|
|
416
|
-
Product7.
|
|
417
|
-
Product7._messengerWidget.openPanel?.();
|
|
414
|
+
openWebChat() {
|
|
415
|
+
if (Product7._WebChatWidget) {
|
|
416
|
+
Product7._WebChatWidget.open?.() || Product7._WebChatWidget.openPanel?.();
|
|
418
417
|
}
|
|
419
418
|
},
|
|
420
419
|
|
|
421
|
-
|
|
422
|
-
if (Product7.
|
|
423
|
-
Product7.
|
|
424
|
-
Product7.
|
|
420
|
+
closeWebChat() {
|
|
421
|
+
if (Product7._WebChatWidget) {
|
|
422
|
+
Product7._WebChatWidget.close?.() ||
|
|
423
|
+
Product7._WebChatWidget.closePanel?.();
|
|
425
424
|
}
|
|
426
425
|
},
|
|
427
426
|
|
|
428
|
-
|
|
429
|
-
if (Product7.
|
|
430
|
-
Product7.
|
|
431
|
-
Product7.
|
|
427
|
+
destroyWebChat() {
|
|
428
|
+
if (Product7._WebChatWidget) {
|
|
429
|
+
Product7._WebChatWidget.destroy();
|
|
430
|
+
Product7._WebChatWidget = null;
|
|
432
431
|
}
|
|
433
432
|
},
|
|
434
433
|
|
|
@@ -732,7 +731,7 @@ const Product7 = {
|
|
|
732
731
|
|
|
733
732
|
destroy() {
|
|
734
733
|
Product7.destroyFeedback();
|
|
735
|
-
Product7.
|
|
734
|
+
Product7.destroyWebChat();
|
|
736
735
|
Product7.destroySurvey();
|
|
737
736
|
if (Product7._sdk) {
|
|
738
737
|
Product7._sdk.destroy();
|
|
@@ -742,7 +741,7 @@ const Product7 = {
|
|
|
742
741
|
Product7._organization = null;
|
|
743
742
|
Product7._q = [];
|
|
744
743
|
Product7._feedbackListenerAttached = false;
|
|
745
|
-
Product7.
|
|
744
|
+
Product7._webChatListenerAttached = false;
|
|
746
745
|
Product7._postMessageListenerAttached = false;
|
|
747
746
|
},
|
|
748
747
|
|
|
@@ -773,16 +772,16 @@ const Product7 = {
|
|
|
773
772
|
});
|
|
774
773
|
},
|
|
775
774
|
|
|
776
|
-
|
|
775
|
+
_setupWebChatAttributeTriggers() {
|
|
777
776
|
if (typeof document === 'undefined') return;
|
|
778
|
-
if (Product7.
|
|
779
|
-
Product7.
|
|
777
|
+
if (Product7._webChatListenerAttached) return;
|
|
778
|
+
Product7._webChatListenerAttached = true;
|
|
780
779
|
|
|
781
780
|
document.addEventListener('click', (e) => {
|
|
782
|
-
const trigger = e.target.closest('[data-product7-
|
|
781
|
+
const trigger = e.target.closest('[data-product7-web-chat]');
|
|
783
782
|
if (trigger) {
|
|
784
783
|
e.preventDefault();
|
|
785
|
-
Product7.
|
|
784
|
+
Product7.openWebChat();
|
|
786
785
|
}
|
|
787
786
|
});
|
|
788
787
|
},
|
|
@@ -803,11 +802,11 @@ const Product7 = {
|
|
|
803
802
|
case 'closeFeedback':
|
|
804
803
|
Product7.closeFeedback();
|
|
805
804
|
break;
|
|
806
|
-
case '
|
|
807
|
-
Product7.
|
|
805
|
+
case 'openWebChat':
|
|
806
|
+
Product7.openWebChat();
|
|
808
807
|
break;
|
|
809
|
-
case '
|
|
810
|
-
Product7.
|
|
808
|
+
case 'closeWebChat':
|
|
809
|
+
Product7.closeWebChat();
|
|
811
810
|
break;
|
|
812
811
|
case 'closeSurvey':
|
|
813
812
|
Product7.closeSurvey();
|
|
@@ -824,7 +823,7 @@ const Product7 = {
|
|
|
824
823
|
TabWidget,
|
|
825
824
|
InlineWidget,
|
|
826
825
|
SurveyWidget,
|
|
827
|
-
|
|
826
|
+
WebChatWidget,
|
|
828
827
|
WidgetFactory,
|
|
829
828
|
EventBus,
|
|
830
829
|
APIService,
|
|
@@ -860,12 +859,12 @@ export {
|
|
|
860
859
|
EventBus,
|
|
861
860
|
helpers,
|
|
862
861
|
InlineWidget,
|
|
863
|
-
MessengerWidget,
|
|
864
862
|
Product7SDK as Product7,
|
|
865
863
|
SDKError,
|
|
866
864
|
SurveyWidget,
|
|
867
865
|
TabWidget,
|
|
868
866
|
ValidationError,
|
|
867
|
+
WebChatWidget,
|
|
869
868
|
WidgetError,
|
|
870
869
|
WidgetFactory,
|
|
871
870
|
};
|
package/src/styles/base.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const baseStyles = `
|
|
1
|
+
export const baseStyles = `
|
|
2
2
|
.feedback-widget,
|
|
3
|
-
.
|
|
3
|
+
.web-chat-widget,
|
|
4
4
|
.changelog-widget,
|
|
5
5
|
.feedback-survey,
|
|
6
6
|
.feedback-panel,
|
|
@@ -15,9 +15,9 @@ export const baseStyles = `
|
|
|
15
15
|
.feedback-widget *,
|
|
16
16
|
.feedback-widget *::before,
|
|
17
17
|
.feedback-widget *::after,
|
|
18
|
-
.
|
|
19
|
-
.
|
|
20
|
-
.
|
|
18
|
+
.web-chat-widget *,
|
|
19
|
+
.web-chat-widget *::before,
|
|
20
|
+
.web-chat-widget *::after,
|
|
21
21
|
.changelog-widget *,
|
|
22
22
|
.changelog-widget *::before,
|
|
23
23
|
.changelog-widget *::after,
|
|
@@ -41,7 +41,7 @@ export const baseStyles = `
|
|
|
41
41
|
|
|
42
42
|
@media (prefers-reduced-motion: reduce) {
|
|
43
43
|
.feedback-widget *,
|
|
44
|
-
.
|
|
44
|
+
.web-chat-widget *,
|
|
45
45
|
.changelog-widget *,
|
|
46
46
|
.feedback-survey * {
|
|
47
47
|
transition: none !important;
|
|
@@ -56,9 +56,9 @@ export const baseStyles = `
|
|
|
56
56
|
.sdk-notification,
|
|
57
57
|
.changelog-widget,
|
|
58
58
|
.changelog-modal,
|
|
59
|
-
.
|
|
60
|
-
.
|
|
61
|
-
.
|
|
59
|
+
.web-chat-widget,
|
|
60
|
+
.web-chat-launcher,
|
|
61
|
+
.web-chat-panel,
|
|
62
62
|
.feedback-survey,
|
|
63
63
|
.feedback-survey-backdrop {
|
|
64
64
|
display: none !important;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const designTokens = `
|
|
1
|
+
export const designTokens = `
|
|
2
2
|
:root {
|
|
3
3
|
--color-primary: #155EEF;
|
|
4
4
|
--color-primary-hover: #1249CA;
|
|
@@ -41,7 +41,7 @@ export const designTokens = `
|
|
|
41
41
|
--color-text-secondary: #4B5563;
|
|
42
42
|
--color-text-tertiary: #6B7280;
|
|
43
43
|
|
|
44
|
-
/*
|
|
44
|
+
/* Web Chat semantic tokens (light defaults) */
|
|
45
45
|
--msg-bg: #FFFFFF;
|
|
46
46
|
--msg-bg-surface: #F3F4F6;
|
|
47
47
|
--msg-bg-elevated: #FFFFFF;
|
package/src/styles/feedback.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const feedbackStyles = `
|
|
1
|
+
export const feedbackStyles = `
|
|
2
2
|
.feedback-widget-button {
|
|
3
3
|
position: fixed;
|
|
4
4
|
z-index: var(--z-notification);
|
|
@@ -246,7 +246,7 @@ export const feedbackStyles = `
|
|
|
246
246
|
|
|
247
247
|
.feedback-panel.theme-dark,
|
|
248
248
|
.feedback-modal.theme-dark {
|
|
249
|
-
/* Aligned with
|
|
249
|
+
/* Aligned with web chat dark theme */
|
|
250
250
|
--color-white: #0f1317;
|
|
251
251
|
--color-background: #0f1317;
|
|
252
252
|
--color-surface: #1a1e24;
|