@product7/product7-js 0.5.5 → 0.5.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 +6 -5
- package/dist/README.md +6 -5
- package/dist/product7-js.js +821 -816
- 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/services/{WebChatService.js → LiveChatService.js} +14 -14
- package/src/core/APIService.js +15 -15
- package/src/core/Product7.js +9 -4
- package/src/core/WebSocketService.js +1 -1
- package/src/docs/api.md +8 -8
- package/src/docs/example.md +9 -9
- package/src/docs/framework-integrations.md +3 -3
- package/src/index.js +37 -37
- package/src/styles/base.js +8 -8
- package/src/styles/{web-chat-components.js → live-chat-components.js} +114 -114
- package/src/styles/{web-chat-core.js → live-chat-core.js} +30 -30
- package/src/styles/{web-chat-features.js → live-chat-features.js} +20 -20
- package/src/styles/{web-chat-views.js → live-chat-views.js} +137 -137
- package/src/styles/live-chat.js +17 -0
- package/src/styles/{webChatCustomStyles.js → liveChatCustomStyles.js} +16 -16
- package/src/styles/styles.js +3 -3
- package/src/widgets/{WebChatWidget.js → LiveChatWidget.js} +166 -166
- package/src/widgets/WidgetFactory.js +2 -2
- package/src/widgets/{web-chat/WebChatState.js → live-chat/LiveChatState.js} +1 -1
- package/src/widgets/{web-chat/components/WebChatLauncher.js → live-chat/components/LiveChatLauncher.js} +15 -15
- package/src/widgets/{web-chat/components/WebChatPanel.js → live-chat/components/LiveChatPanel.js} +10 -10
- package/src/widgets/{web-chat → live-chat}/components/NavigationTabs.js +12 -12
- package/src/widgets/{web-chat → live-chat}/views/ChangelogView.js +16 -16
- package/src/widgets/{web-chat → live-chat}/views/ChatView.js +90 -90
- package/src/widgets/{web-chat → live-chat}/views/ConversationsView.js +23 -23
- package/src/widgets/{web-chat → live-chat}/views/HelpView.js +28 -28
- package/src/widgets/{web-chat → live-chat}/views/HomeView.js +52 -52
- package/src/widgets/{web-chat → live-chat}/views/PreChatFormView.js +16 -16
- package/types/index.d.ts +9 -8
- package/src/styles/web-chat.js +0 -17
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
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 LiveChatService {
|
|
5
5
|
constructor(baseAPI) {
|
|
6
6
|
this.api = baseAPI;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
async
|
|
9
|
+
async getLiveChatSettings() {
|
|
10
10
|
await this.api._ensureSession();
|
|
11
11
|
|
|
12
12
|
if (this.api.mock) {
|
|
@@ -21,7 +21,7 @@ export class WebChatService {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
return this.api._makeRequest('/widget/
|
|
24
|
+
return this.api._makeRequest('/widget/live-chat/settings', {
|
|
25
25
|
method: 'GET',
|
|
26
26
|
headers: { Authorization: `Bearer ${this.api.sessionToken}` },
|
|
27
27
|
});
|
|
@@ -45,7 +45,7 @@ export class WebChatService {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
return this.api._makeRequest('/widget/
|
|
48
|
+
return this.api._makeRequest('/widget/live-chat/agents/online', {
|
|
49
49
|
method: 'GET',
|
|
50
50
|
headers: { Authorization: `Bearer ${this.api.sessionToken}` },
|
|
51
51
|
});
|
|
@@ -64,7 +64,7 @@ export class WebChatService {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const endpoint = this.api._getEndpointWithParams(
|
|
67
|
-
'/widget/
|
|
67
|
+
'/widget/live-chat/conversations',
|
|
68
68
|
options
|
|
69
69
|
);
|
|
70
70
|
return this.api._makeRequest(endpoint, {
|
|
@@ -86,7 +86,7 @@ export class WebChatService {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
return this.api._makeRequest(
|
|
89
|
-
`/widget/
|
|
89
|
+
`/widget/live-chat/conversations/${conversationId}`,
|
|
90
90
|
{
|
|
91
91
|
method: 'GET',
|
|
92
92
|
headers: { Authorization: `Bearer ${this.api.sessionToken}` },
|
|
@@ -120,7 +120,7 @@ export class WebChatService {
|
|
|
120
120
|
return { status: true, data: newConv };
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
return this.api._makeRequest('/widget/
|
|
123
|
+
return this.api._makeRequest('/widget/live-chat/conversations', {
|
|
124
124
|
method: 'POST',
|
|
125
125
|
headers: {
|
|
126
126
|
'Content-Type': 'application/json',
|
|
@@ -154,7 +154,7 @@ export class WebChatService {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
return this.api._makeRequest(
|
|
157
|
-
`/widget/
|
|
157
|
+
`/widget/live-chat/conversations/${conversationId}/messages`,
|
|
158
158
|
{
|
|
159
159
|
method: 'POST',
|
|
160
160
|
headers: {
|
|
@@ -183,7 +183,7 @@ export class WebChatService {
|
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
return this.api._makeRequest('/widget/
|
|
186
|
+
return this.api._makeRequest('/widget/live-chat/unread', {
|
|
187
187
|
method: 'GET',
|
|
188
188
|
headers: { Authorization: `Bearer ${this.api.sessionToken}` },
|
|
189
189
|
});
|
|
@@ -197,7 +197,7 @@ export class WebChatService {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
return this.api._makeRequest(
|
|
200
|
-
`/widget/
|
|
200
|
+
`/widget/live-chat/conversations/${conversationId}/read`,
|
|
201
201
|
{
|
|
202
202
|
method: 'POST',
|
|
203
203
|
headers: { Authorization: `Bearer ${this.api.sessionToken}` },
|
|
@@ -219,7 +219,7 @@ export class WebChatService {
|
|
|
219
219
|
|
|
220
220
|
const params = { ...options };
|
|
221
221
|
const endpoint = this.api._getEndpointWithParams(
|
|
222
|
-
`/widget/
|
|
222
|
+
`/widget/live-chat/conversations/${conversationId}/messages`,
|
|
223
223
|
params
|
|
224
224
|
);
|
|
225
225
|
return this.api._makeRequest(endpoint, {
|
|
@@ -236,7 +236,7 @@ export class WebChatService {
|
|
|
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/live-chat/upload', {
|
|
240
240
|
method: 'POST',
|
|
241
241
|
headers: {
|
|
242
242
|
'Content-Type': 'application/json',
|
|
@@ -258,7 +258,7 @@ export class WebChatService {
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
return this.api._makeRequest(
|
|
261
|
-
`/widget/
|
|
261
|
+
`/widget/live-chat/conversations/${conversationId}/rating`,
|
|
262
262
|
{
|
|
263
263
|
method: 'POST',
|
|
264
264
|
headers: {
|
|
@@ -278,7 +278,7 @@ export class WebChatService {
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
return this.api._makeRequest(
|
|
281
|
-
`/widget/
|
|
281
|
+
`/widget/live-chat/conversations/${conversationId}/typing`,
|
|
282
282
|
{
|
|
283
283
|
method: 'POST',
|
|
284
284
|
headers: {
|
package/src/core/APIService.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { FeedbackService } from '../api/services/FeedbackService.js';
|
|
3
3
|
import { HelpService } from '../api/services/HelpService.js';
|
|
4
4
|
import { SurveyService } from '../api/services/SurveyService.js';
|
|
5
|
-
import {
|
|
5
|
+
import { LiveChatService } from '../api/services/LiveChatService.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.liveChat = new LiveChatService(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 getLiveChatSettings() {
|
|
36
|
+
return this.liveChat.getLiveChatSettings();
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
async checkAgentsOnline() {
|
|
40
|
-
return this.
|
|
40
|
+
return this.liveChat.checkAgentsOnline();
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
async getConversations(options) {
|
|
44
|
-
return this.
|
|
44
|
+
return this.liveChat.getConversations(options);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
async getConversation(conversationId) {
|
|
48
|
-
return this.
|
|
48
|
+
return this.liveChat.getConversation(conversationId);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
async getMessages(conversationId, options) {
|
|
52
|
-
return this.
|
|
52
|
+
return this.liveChat.getMessages(conversationId, options);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
async startConversation(data) {
|
|
56
|
-
return this.
|
|
56
|
+
return this.liveChat.startConversation(data);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
async sendMessage(conversationId, data) {
|
|
60
|
-
return this.
|
|
60
|
+
return this.liveChat.sendMessage(conversationId, data);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
async uploadFile(base64Data, filename) {
|
|
64
|
-
return this.
|
|
64
|
+
return this.liveChat.uploadFile(base64Data, filename);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
async sendTypingIndicator(conversationId, isTyping) {
|
|
68
|
-
return this.
|
|
68
|
+
return this.liveChat.sendTypingIndicator(conversationId, isTyping);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
async markConversationAsRead(conversationId) {
|
|
72
|
-
return this.
|
|
72
|
+
return this.liveChat.markConversationAsRead(conversationId);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
async getUnreadCount() {
|
|
76
|
-
return this.
|
|
76
|
+
return this.liveChat.getUnreadCount();
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
async submitRating(conversationId, data) {
|
|
80
|
-
return this.
|
|
80
|
+
return this.liveChat.submitRating(conversationId, data);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
async identify(metadata) {
|
package/src/core/Product7.js
CHANGED
|
@@ -58,7 +58,12 @@ export class Product7 {
|
|
|
58
58
|
|
|
59
59
|
const serverConfig = initData.config ? { ...initData.config } : {};
|
|
60
60
|
if (initData.widgets) {
|
|
61
|
-
|
|
61
|
+
const widgets = { ...initData.widgets };
|
|
62
|
+
if (widgets.web_chat && !widgets.liveChat) {
|
|
63
|
+
widgets.liveChat = widgets.web_chat;
|
|
64
|
+
delete widgets.web_chat;
|
|
65
|
+
}
|
|
66
|
+
serverConfig.widgets = widgets;
|
|
62
67
|
}
|
|
63
68
|
if (Object.keys(serverConfig).length > 0) {
|
|
64
69
|
this.config = deepMerge(serverConfig, this.config);
|
|
@@ -130,8 +135,8 @@ export class Product7 {
|
|
|
130
135
|
return this.createWidget('feedback', options);
|
|
131
136
|
}
|
|
132
137
|
|
|
133
|
-
|
|
134
|
-
return this.createWidget('
|
|
138
|
+
createLiveChatWidget(options = {}) {
|
|
139
|
+
return this.createWidget('liveChat', options);
|
|
135
140
|
}
|
|
136
141
|
|
|
137
142
|
createChangelogWidget(options = {}) {
|
|
@@ -923,7 +928,7 @@ export class Product7 {
|
|
|
923
928
|
_bindMethods() {
|
|
924
929
|
this.createWidget = this.createWidget.bind(this);
|
|
925
930
|
this.createFeedbackWidget = this.createFeedbackWidget.bind(this);
|
|
926
|
-
this.
|
|
931
|
+
this.createLiveChatWidget = this.createLiveChatWidget.bind(this);
|
|
927
932
|
this.createChangelogWidget = this.createChangelogWidget.bind(this);
|
|
928
933
|
this.createSurveyWidget = this.createSurveyWidget.bind(this);
|
|
929
934
|
this.destroyWidget = this.destroyWidget.bind(this);
|
|
@@ -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/live-chat/ws?token=${encodeURIComponent(this.sessionToken)}`;
|
|
55
55
|
|
|
56
56
|
try {
|
|
57
57
|
this.ws = new WebSocket(wsURL);
|
package/src/docs/api.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# API Reference
|
|
1
|
+
# API Reference
|
|
2
2
|
|
|
3
3
|
## Product7
|
|
4
4
|
|
|
@@ -60,7 +60,7 @@ const widget = sdk.createFeedbackWidget({
|
|
|
60
60
|
});
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
#### `
|
|
63
|
+
#### `createLiveChatWidget(options?): LiveChatWidget`
|
|
64
64
|
|
|
65
65
|
Creates the web chat widget.
|
|
66
66
|
|
|
@@ -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
|
+
- `'liveChat'`
|
|
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
|
+
## LiveChatWidget
|
|
190
190
|
|
|
191
|
-
Created by `sdk.
|
|
191
|
+
Created by `sdk.createLiveChatWidget()`.
|
|
192
192
|
|
|
193
193
|
### Methods
|
|
194
194
|
|
|
@@ -301,9 +301,9 @@ Created by `sdk.createChangelogWidget()`.
|
|
|
301
301
|
|
|
302
302
|
### Web Chat Events
|
|
303
303
|
|
|
304
|
-
- `
|
|
305
|
-
- `
|
|
306
|
-
- `
|
|
304
|
+
- `liveChat:opened`
|
|
305
|
+
- `liveChat:closed`
|
|
306
|
+
- `liveChat:messageSent`
|
|
307
307
|
|
|
308
308
|
### Survey Events
|
|
309
309
|
|
package/src/docs/example.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Examples
|
|
1
|
+
# Examples
|
|
2
2
|
|
|
3
3
|
## Basic Usage
|
|
4
4
|
|
|
@@ -208,37 +208,37 @@ if (surveys.length > 0) {
|
|
|
208
208
|
### Basic Web Chat
|
|
209
209
|
|
|
210
210
|
```javascript
|
|
211
|
-
const
|
|
211
|
+
const liveChat = sdk.createLiveChatWidget({
|
|
212
212
|
position: 'bottom-right',
|
|
213
213
|
teamName: 'Support Team',
|
|
214
214
|
enableHelp: true,
|
|
215
215
|
enableChangelog: true,
|
|
216
216
|
});
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
liveChat.mount();
|
|
219
219
|
```
|
|
220
220
|
|
|
221
221
|
### Headless Web Chat
|
|
222
222
|
|
|
223
223
|
```javascript
|
|
224
|
-
const
|
|
224
|
+
const liveChat = sdk.createLiveChatWidget({
|
|
225
225
|
headless: true,
|
|
226
226
|
enableHelp: true,
|
|
227
227
|
});
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
liveChat.mount();
|
|
230
230
|
|
|
231
231
|
document
|
|
232
232
|
.querySelector('#support-link')
|
|
233
|
-
?.addEventListener('click', () =>
|
|
233
|
+
?.addEventListener('click', () => liveChat.open());
|
|
234
234
|
```
|
|
235
235
|
|
|
236
236
|
### Programmatic Web Chat Navigation
|
|
237
237
|
|
|
238
238
|
```javascript
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
liveChat.open();
|
|
240
|
+
liveChat.navigateTo('help');
|
|
241
|
+
liveChat.close();
|
|
242
242
|
```
|
|
243
243
|
|
|
244
244
|
---
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Framework Integrations
|
|
1
|
+
# Framework Integrations
|
|
2
2
|
|
|
3
3
|
Use this guide to integrate `@product7/product7-js` in modern frontend frameworks.
|
|
4
4
|
|
|
@@ -560,13 +560,13 @@ const survey = sdk.createSurveyWidget({
|
|
|
560
560
|
survey.mount();
|
|
561
561
|
survey.open();
|
|
562
562
|
|
|
563
|
-
const
|
|
563
|
+
const liveChat = sdk.createLiveChatWidget({
|
|
564
564
|
position: 'bottom-right',
|
|
565
565
|
teamName: 'Support Team',
|
|
566
566
|
enableHelp: true,
|
|
567
567
|
enableChangelog: true,
|
|
568
568
|
});
|
|
569
|
-
|
|
569
|
+
liveChat.mount();
|
|
570
570
|
|
|
571
571
|
const changelog = sdk.createChangelogWidget({
|
|
572
572
|
position: 'bottom-left',
|
package/src/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { ChangelogWidget } from './widgets/ChangelogWidget.js';
|
|
|
15
15
|
import { InlineWidget } from './widgets/InlineWidget.js';
|
|
16
16
|
import { SurveyWidget } from './widgets/SurveyWidget.js';
|
|
17
17
|
import { TabWidget } from './widgets/TabWidget.js';
|
|
18
|
-
import {
|
|
18
|
+
import { LiveChatWidget } from './widgets/LiveChatWidget.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
|
+
_LiveChatWidget: null,
|
|
147
147
|
_surveyWidget: null,
|
|
148
148
|
|
|
149
149
|
version: '1.0.0',
|
|
@@ -333,10 +333,10 @@ const Product7 = {
|
|
|
333
333
|
// Web Chat
|
|
334
334
|
// ==================
|
|
335
335
|
|
|
336
|
-
async
|
|
336
|
+
async liveChat(options = {}, callback) {
|
|
337
337
|
const sdk = await ensureSDK(options);
|
|
338
338
|
if (!sdk) {
|
|
339
|
-
Product7._q.push(['
|
|
339
|
+
Product7._q.push(['liveChat', options, callback]);
|
|
340
340
|
return null;
|
|
341
341
|
}
|
|
342
342
|
|
|
@@ -377,30 +377,30 @@ const Product7 = {
|
|
|
377
377
|
widgetOptions.enabled = true;
|
|
378
378
|
|
|
379
379
|
try {
|
|
380
|
-
const widget = sdk.
|
|
380
|
+
const widget = sdk.createLiveChatWidget(widgetOptions);
|
|
381
381
|
widget.mount();
|
|
382
382
|
widget.show();
|
|
383
383
|
|
|
384
|
-
Product7.
|
|
384
|
+
Product7._LiveChatWidget = widget;
|
|
385
385
|
|
|
386
386
|
if (typeof callback === 'function') {
|
|
387
387
|
callback({ action: 'widgetReady' });
|
|
388
388
|
|
|
389
|
-
sdk.eventBus.on('
|
|
389
|
+
sdk.eventBus.on('liveChat:messageSent', (data) => {
|
|
390
390
|
callback({ action: 'messageSent', message: data });
|
|
391
391
|
});
|
|
392
392
|
|
|
393
|
-
sdk.eventBus.on('
|
|
394
|
-
callback({ action: '
|
|
393
|
+
sdk.eventBus.on('liveChat:opened', () => {
|
|
394
|
+
callback({ action: 'liveChatOpened' });
|
|
395
395
|
});
|
|
396
396
|
|
|
397
|
-
sdk.eventBus.on('
|
|
398
|
-
callback({ action: '
|
|
397
|
+
sdk.eventBus.on('liveChat:closed', () => {
|
|
398
|
+
callback({ action: 'liveChatClosed' });
|
|
399
399
|
});
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
-
// Listen for data-product7-
|
|
403
|
-
Product7.
|
|
402
|
+
// Listen for data-product7-live-chat clicks
|
|
403
|
+
Product7._setupLiveChatAttributeTriggers();
|
|
404
404
|
Product7._setupPostMessageListener();
|
|
405
405
|
|
|
406
406
|
return widget;
|
|
@@ -411,23 +411,23 @@ const Product7 = {
|
|
|
411
411
|
}
|
|
412
412
|
},
|
|
413
413
|
|
|
414
|
-
|
|
415
|
-
if (Product7.
|
|
416
|
-
Product7.
|
|
414
|
+
openLiveChat() {
|
|
415
|
+
if (Product7._LiveChatWidget) {
|
|
416
|
+
Product7._LiveChatWidget.open?.() || Product7._LiveChatWidget.openPanel?.();
|
|
417
417
|
}
|
|
418
418
|
},
|
|
419
419
|
|
|
420
|
-
|
|
421
|
-
if (Product7.
|
|
422
|
-
Product7.
|
|
423
|
-
Product7.
|
|
420
|
+
closeLiveChat() {
|
|
421
|
+
if (Product7._LiveChatWidget) {
|
|
422
|
+
Product7._LiveChatWidget.close?.() ||
|
|
423
|
+
Product7._LiveChatWidget.closePanel?.();
|
|
424
424
|
}
|
|
425
425
|
},
|
|
426
426
|
|
|
427
|
-
|
|
428
|
-
if (Product7.
|
|
429
|
-
Product7.
|
|
430
|
-
Product7.
|
|
427
|
+
destroyLiveChat() {
|
|
428
|
+
if (Product7._LiveChatWidget) {
|
|
429
|
+
Product7._LiveChatWidget.destroy();
|
|
430
|
+
Product7._LiveChatWidget = null;
|
|
431
431
|
}
|
|
432
432
|
},
|
|
433
433
|
|
|
@@ -731,7 +731,7 @@ const Product7 = {
|
|
|
731
731
|
|
|
732
732
|
destroy() {
|
|
733
733
|
Product7.destroyFeedback();
|
|
734
|
-
Product7.
|
|
734
|
+
Product7.destroyLiveChat();
|
|
735
735
|
Product7.destroySurvey();
|
|
736
736
|
if (Product7._sdk) {
|
|
737
737
|
Product7._sdk.destroy();
|
|
@@ -741,7 +741,7 @@ const Product7 = {
|
|
|
741
741
|
Product7._organization = null;
|
|
742
742
|
Product7._q = [];
|
|
743
743
|
Product7._feedbackListenerAttached = false;
|
|
744
|
-
Product7.
|
|
744
|
+
Product7._liveChatListenerAttached = false;
|
|
745
745
|
Product7._postMessageListenerAttached = false;
|
|
746
746
|
},
|
|
747
747
|
|
|
@@ -772,16 +772,16 @@ const Product7 = {
|
|
|
772
772
|
});
|
|
773
773
|
},
|
|
774
774
|
|
|
775
|
-
|
|
775
|
+
_setupLiveChatAttributeTriggers() {
|
|
776
776
|
if (typeof document === 'undefined') return;
|
|
777
|
-
if (Product7.
|
|
778
|
-
Product7.
|
|
777
|
+
if (Product7._liveChatListenerAttached) return;
|
|
778
|
+
Product7._liveChatListenerAttached = true;
|
|
779
779
|
|
|
780
780
|
document.addEventListener('click', (e) => {
|
|
781
|
-
const trigger = e.target.closest('[data-product7-
|
|
781
|
+
const trigger = e.target.closest('[data-product7-live-chat]');
|
|
782
782
|
if (trigger) {
|
|
783
783
|
e.preventDefault();
|
|
784
|
-
Product7.
|
|
784
|
+
Product7.openLiveChat();
|
|
785
785
|
}
|
|
786
786
|
});
|
|
787
787
|
},
|
|
@@ -802,11 +802,11 @@ const Product7 = {
|
|
|
802
802
|
case 'closeFeedback':
|
|
803
803
|
Product7.closeFeedback();
|
|
804
804
|
break;
|
|
805
|
-
case '
|
|
806
|
-
Product7.
|
|
805
|
+
case 'openLiveChat':
|
|
806
|
+
Product7.openLiveChat();
|
|
807
807
|
break;
|
|
808
|
-
case '
|
|
809
|
-
Product7.
|
|
808
|
+
case 'closeLiveChat':
|
|
809
|
+
Product7.closeLiveChat();
|
|
810
810
|
break;
|
|
811
811
|
case 'closeSurvey':
|
|
812
812
|
Product7.closeSurvey();
|
|
@@ -823,7 +823,7 @@ const Product7 = {
|
|
|
823
823
|
TabWidget,
|
|
824
824
|
InlineWidget,
|
|
825
825
|
SurveyWidget,
|
|
826
|
-
|
|
826
|
+
LiveChatWidget,
|
|
827
827
|
WidgetFactory,
|
|
828
828
|
EventBus,
|
|
829
829
|
APIService,
|
|
@@ -864,7 +864,7 @@ export {
|
|
|
864
864
|
SurveyWidget,
|
|
865
865
|
TabWidget,
|
|
866
866
|
ValidationError,
|
|
867
|
-
|
|
867
|
+
LiveChatWidget,
|
|
868
868
|
WidgetError,
|
|
869
869
|
WidgetFactory,
|
|
870
870
|
};
|
package/src/styles/base.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const baseStyles = `
|
|
2
2
|
.feedback-widget,
|
|
3
|
-
.
|
|
3
|
+
.live-chat-widget,
|
|
4
4
|
.changelog-widget,
|
|
5
5
|
.feedback-survey,
|
|
6
6
|
.feedback-panel,
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
.feedback-widget *,
|
|
16
16
|
.feedback-widget *::before,
|
|
17
17
|
.feedback-widget *::after,
|
|
18
|
-
.
|
|
19
|
-
.
|
|
20
|
-
.
|
|
18
|
+
.live-chat-widget *,
|
|
19
|
+
.live-chat-widget *::before,
|
|
20
|
+
.live-chat-widget *::after,
|
|
21
21
|
.changelog-widget *,
|
|
22
22
|
.changelog-widget *::before,
|
|
23
23
|
.changelog-widget *::after,
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
@media (prefers-reduced-motion: reduce) {
|
|
43
43
|
.feedback-widget *,
|
|
44
|
-
.
|
|
44
|
+
.live-chat-widget *,
|
|
45
45
|
.changelog-widget *,
|
|
46
46
|
.feedback-survey * {
|
|
47
47
|
transition: none !important;
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
.sdk-notification,
|
|
57
57
|
.changelog-widget,
|
|
58
58
|
.changelog-modal,
|
|
59
|
-
.
|
|
60
|
-
.
|
|
61
|
-
.
|
|
59
|
+
.live-chat-widget,
|
|
60
|
+
.live-chat-launcher,
|
|
61
|
+
.live-chat-panel,
|
|
62
62
|
.feedback-survey,
|
|
63
63
|
.feedback-survey-backdrop {
|
|
64
64
|
display: none !important;
|