@product7/product7-js 0.5.6 → 0.5.7
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 -7
- package/dist/README.md +6 -7
- package/dist/product7-js.js +7155 -6999
- 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/LiveChatService.js +12 -12
- package/src/core/APIService.js +1 -1
- package/src/core/WebSocketService.js +1 -1
- package/src/index.js +6 -5
- package/src/styles/base.js +8 -8
- package/src/styles/{live-chat-components.js → liveChat-components.js} +113 -113
- package/src/styles/{live-chat-core.js → liveChat-core.js} +95 -30
- package/src/styles/{live-chat-features.js → liveChat-features.js} +19 -19
- package/src/styles/{live-chat-views.js → liveChat-views.js} +136 -136
- package/src/styles/liveChat.js +17 -0
- package/src/styles/liveChatCustomStyles.js +14 -14
- package/src/styles/styles.js +2 -2
- package/src/widgets/BaseWidget.js +2 -2
- package/src/widgets/ChangelogWidget.js +3 -3
- package/src/widgets/LiveChatWidget.js +17 -13
- package/src/widgets/SurveyWidget.js +7 -7
- package/src/widgets/WidgetFactory.js +1 -1
- package/src/widgets/{live-chat → liveChat}/components/LiveChatLauncher.js +15 -15
- package/src/widgets/{live-chat → liveChat}/components/LiveChatPanel.js +40 -9
- package/src/widgets/{live-chat → liveChat}/components/NavigationTabs.js +16 -16
- package/src/widgets/{live-chat → liveChat}/views/ChangelogView.js +17 -17
- package/src/widgets/{live-chat → liveChat}/views/ChatView.js +153 -95
- package/src/widgets/{live-chat → liveChat}/views/ConversationsView.js +24 -24
- package/src/widgets/{live-chat → liveChat}/views/HelpView.js +32 -32
- package/src/widgets/{live-chat → liveChat}/views/HomeView.js +52 -52
- package/src/widgets/{live-chat → liveChat}/views/PreChatFormView.js +15 -18
- package/types/index.d.ts +0 -2
- package/src/styles/live-chat.js +0 -17
- /package/src/widgets/{live-chat → liveChat}/LiveChatState.js +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { liveChatComponentsStyles } from './liveChat-components.js';
|
|
2
|
+
import { liveChatCoreStyles } from './liveChat-core.js';
|
|
3
|
+
import { liveChatFeaturesStyles } from './liveChat-features.js';
|
|
4
|
+
import { liveChatViewsStyles } from './liveChat-views.js';
|
|
5
|
+
|
|
6
|
+
export const liveChatStyles =
|
|
7
|
+
liveChatCoreStyles +
|
|
8
|
+
liveChatViewsStyles +
|
|
9
|
+
liveChatComponentsStyles +
|
|
10
|
+
liveChatFeaturesStyles;
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
liveChatComponentsStyles,
|
|
14
|
+
liveChatCoreStyles,
|
|
15
|
+
liveChatFeaturesStyles,
|
|
16
|
+
liveChatViewsStyles,
|
|
17
|
+
};
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
theme = 'light',
|
|
7
7
|
} = options;
|
|
8
8
|
|
|
9
|
-
let styleElement = document.getElementById('product7-
|
|
9
|
+
let styleElement = document.getElementById('product7-liveChat-custom-styles');
|
|
10
10
|
|
|
11
11
|
if (!styleElement) {
|
|
12
12
|
styleElement = document.createElement('style');
|
|
13
|
-
styleElement.id = 'product7-
|
|
13
|
+
styleElement.id = 'product7-liveChat-custom-styles';
|
|
14
14
|
document.head.appendChild(styleElement);
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
const darkBorder = adjustColor(backgroundColor, 34);
|
|
38
38
|
|
|
39
39
|
styleElement.textContent = `
|
|
40
|
-
#product7-
|
|
40
|
+
#product7-liveChat-widget {
|
|
41
41
|
--color-primary: ${primaryColor} !important;
|
|
42
42
|
--color-primary-hover: ${adjustColor(primaryColor, -10)} !important;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
.
|
|
45
|
+
.liveChat-launcher-btn {
|
|
46
46
|
background: ${primaryColor} !important;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
.
|
|
49
|
+
.liveChat-launcher-btn:hover {
|
|
50
50
|
box-shadow: 0 8px 24px ${adjustColor(primaryColor, 0, 0.3)} !important;
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -60,25 +60,25 @@
|
|
|
60
60
|
border-color: ${adjustColor(primaryColor, -10)} !important;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
.
|
|
63
|
+
.liveChat-compose-send:hover:not(:disabled) {
|
|
64
64
|
background: ${primaryColor} !important;
|
|
65
65
|
border-color: ${primaryColor} !important;
|
|
66
66
|
color: #FFFFFF !important;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
.
|
|
70
|
-
.
|
|
69
|
+
.liveChat-nav-tab.active .liveChat-nav-icon,
|
|
70
|
+
.liveChat-nav-tab.active .liveChat-nav-label {
|
|
71
71
|
color: ${primaryColor} !important;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
.
|
|
74
|
+
.liveChat-home-view::before {
|
|
75
75
|
background: radial-gradient(circle, ${adjustColor(primaryColor, 0, 0.08)} 0%, transparent 70%) !important;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
${
|
|
79
79
|
backgroundColor !== '#ffffff'
|
|
80
80
|
? `
|
|
81
|
-
.
|
|
81
|
+
.liveChat-panel-content {
|
|
82
82
|
background: ${backgroundColor} !important;
|
|
83
83
|
}
|
|
84
84
|
`
|
|
@@ -88,15 +88,15 @@
|
|
|
88
88
|
${
|
|
89
89
|
textColor !== '#1d1d1f'
|
|
90
90
|
? `
|
|
91
|
-
.
|
|
92
|
-
.
|
|
91
|
+
.liveChat-panel-content,
|
|
92
|
+
.liveChat-view {
|
|
93
93
|
color: ${textColor} !important;
|
|
94
94
|
}
|
|
95
95
|
`
|
|
96
96
|
: ''
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
/* Dark theme is now handled by CSS custom properties in
|
|
99
|
+
/* Dark theme is now handled by CSS custom properties in liveChat-core.js */
|
|
100
100
|
`;
|
|
101
101
|
|
|
102
102
|
console.log('✅ Custom web chat styles applied:', { primaryColor, theme });
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
|
|
105
105
|
export function removeliveChatCustomStyles() {
|
|
106
106
|
const styleElement = document.getElementById(
|
|
107
|
-
'product7-
|
|
107
|
+
'product7-liveChat-custom-styles'
|
|
108
108
|
);
|
|
109
109
|
if (styleElement && styleElement.parentNode) {
|
|
110
110
|
styleElement.parentNode.removeChild(styleElement);
|
package/src/styles/styles.js
CHANGED
|
@@ -3,8 +3,8 @@ import { changelogStyles } from './changelog.js';
|
|
|
3
3
|
import { componentsStyles } from './components.js';
|
|
4
4
|
import { designTokens } from './design-tokens.js';
|
|
5
5
|
import { feedbackStyles } from './feedback.js';
|
|
6
|
+
import { liveChatStyles } from './liveChat.js';
|
|
6
7
|
import { surveyStyles } from './survey.js';
|
|
7
|
-
import { liveChatStyles } from './live-chat.js';
|
|
8
8
|
|
|
9
9
|
export const CSS_STYLES =
|
|
10
10
|
designTokens +
|
|
@@ -21,6 +21,6 @@ export {
|
|
|
21
21
|
componentsStyles,
|
|
22
22
|
designTokens,
|
|
23
23
|
feedbackStyles,
|
|
24
|
-
surveyStyles,
|
|
25
24
|
liveChatStyles,
|
|
25
|
+
surveyStyles,
|
|
26
26
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class BaseWidget {
|
|
1
|
+
export class BaseWidget {
|
|
2
2
|
static STORAGE_KEY = 'feedback_submitted';
|
|
3
3
|
static DEFAULT_COOLDOWN_DAYS = 30;
|
|
4
4
|
|
|
@@ -384,7 +384,7 @@ export class BaseWidget {
|
|
|
384
384
|
<div class="feedback-panel-header">
|
|
385
385
|
<h3>Send Feedback</h3>
|
|
386
386
|
<button class="sdk-close-btn" type="button" aria-label="Close">
|
|
387
|
-
<iconify-icon icon="ph:x
|
|
387
|
+
<iconify-icon icon="ph:x" width="18" height="18"></iconify-icon>
|
|
388
388
|
</button>
|
|
389
389
|
</div>
|
|
390
390
|
<div class="feedback-panel-body">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseWidget } from './BaseWidget.js';
|
|
1
|
+
import { BaseWidget } from './BaseWidget.js';
|
|
2
2
|
|
|
3
3
|
export class ChangelogWidget extends BaseWidget {
|
|
4
4
|
constructor(options) {
|
|
@@ -112,7 +112,7 @@ export class ChangelogWidget extends BaseWidget {
|
|
|
112
112
|
this.modalElement.innerHTML = `
|
|
113
113
|
<div class="changelog-modal-container">
|
|
114
114
|
<button class="changelog-modal-close" type="button" aria-label="Close">
|
|
115
|
-
<iconify-icon icon="ph:x
|
|
115
|
+
<iconify-icon icon="ph:x" width="18" height="18"></iconify-icon>
|
|
116
116
|
</button>
|
|
117
117
|
<div class="changelog-modal-content">
|
|
118
118
|
<div class="changelog-loading">
|
|
@@ -263,7 +263,7 @@ export class ChangelogWidget extends BaseWidget {
|
|
|
263
263
|
<div class="changelog-list-modal-header">
|
|
264
264
|
<h2>${this.options.title || "What's New"} 🎉</h2>
|
|
265
265
|
<button class="changelog-list-modal-close" type="button" aria-label="Close">
|
|
266
|
-
<iconify-icon icon="ph:x
|
|
266
|
+
<iconify-icon icon="ph:x" width="18" height="18"></iconify-icon>
|
|
267
267
|
</button>
|
|
268
268
|
</div>
|
|
269
269
|
<div class="changelog-list-modal-body">
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { WebSocketService } from '../core/WebSocketService.js';
|
|
1
|
+
import { WebSocketService } from '../core/WebSocketService.js';
|
|
2
2
|
import {
|
|
3
3
|
applyliveChatCustomStyles,
|
|
4
4
|
removeliveChatCustomStyles,
|
|
5
5
|
} from '../styles/liveChatCustomStyles.js';
|
|
6
6
|
import { NotificationSound } from '../utils/NotificationSound.js';
|
|
7
7
|
import { BaseWidget } from './BaseWidget.js';
|
|
8
|
-
import { LiveChatState } from './
|
|
9
|
-
import { LiveChatLauncher } from './
|
|
10
|
-
import { LiveChatPanel } from './
|
|
11
|
-
import { ChangelogView } from './
|
|
12
|
-
import { ChatView } from './
|
|
13
|
-
import { ConversationsView } from './
|
|
14
|
-
import { HelpView } from './
|
|
15
|
-
import { HomeView } from './
|
|
16
|
-
import { PreChatFormView } from './
|
|
8
|
+
import { LiveChatState } from './liveChat/LiveChatState.js';
|
|
9
|
+
import { LiveChatLauncher } from './liveChat/components/LiveChatLauncher.js';
|
|
10
|
+
import { LiveChatPanel } from './liveChat/components/LiveChatPanel.js';
|
|
11
|
+
import { ChangelogView } from './liveChat/views/ChangelogView.js';
|
|
12
|
+
import { ChatView } from './liveChat/views/ChatView.js';
|
|
13
|
+
import { ConversationsView } from './liveChat/views/ConversationsView.js';
|
|
14
|
+
import { HelpView } from './liveChat/views/HelpView.js';
|
|
15
|
+
import { HomeView } from './liveChat/views/HomeView.js';
|
|
16
|
+
import { PreChatFormView } from './liveChat/views/PreChatFormView.js';
|
|
17
17
|
|
|
18
18
|
export class LiveChatWidget extends BaseWidget {
|
|
19
19
|
constructor(options) {
|
|
@@ -150,7 +150,7 @@ export class LiveChatWidget extends BaseWidget {
|
|
|
150
150
|
|
|
151
151
|
_render() {
|
|
152
152
|
const container = document.createElement('div');
|
|
153
|
-
container.className = `
|
|
153
|
+
container.className = `liveChat-widget theme-${this.liveChatOptions.theme}`;
|
|
154
154
|
container.style.zIndex = '999999';
|
|
155
155
|
|
|
156
156
|
applyliveChatCustomStyles({
|
|
@@ -181,7 +181,8 @@ export class LiveChatWidget extends BaseWidget {
|
|
|
181
181
|
logoUrl: this.liveChatOptions.logoUrl,
|
|
182
182
|
featuredContent: this.liveChatOptions.featuredContent,
|
|
183
183
|
onSendMessage:
|
|
184
|
-
this.liveChatOptions.onSendMessage ||
|
|
184
|
+
this.liveChatOptions.onSendMessage ||
|
|
185
|
+
this._handleSendMessage.bind(this),
|
|
185
186
|
onStartConversation: this._handleStartConversation.bind(this),
|
|
186
187
|
onTyping: this.sendTypingIndicator.bind(this),
|
|
187
188
|
onSelectConversation: this._handleSelectConversation.bind(this),
|
|
@@ -707,7 +708,10 @@ export class LiveChatWidget extends BaseWidget {
|
|
|
707
708
|
const response = await this.apiService.getHelpCollections();
|
|
708
709
|
if (response.success && response.data) {
|
|
709
710
|
const collections = response.data.collections || response.data;
|
|
710
|
-
const helpBase = (this.liveChatOptions.helpUrl || '').replace(
|
|
711
|
+
const helpBase = (this.liveChatOptions.helpUrl || '').replace(
|
|
712
|
+
/\/$/,
|
|
713
|
+
''
|
|
714
|
+
);
|
|
711
715
|
|
|
712
716
|
const sorted = [...collections].sort(
|
|
713
717
|
(a, b) => (a.order ?? 0) - (b.order ?? 0)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseWidget } from './BaseWidget.js';
|
|
1
|
+
import { BaseWidget } from './BaseWidget.js';
|
|
2
2
|
|
|
3
3
|
export class SurveyWidget extends BaseWidget {
|
|
4
4
|
constructor(options) {
|
|
@@ -153,7 +153,7 @@ export class SurveyWidget extends BaseWidget {
|
|
|
153
153
|
}`;
|
|
154
154
|
|
|
155
155
|
this.surveyElement.innerHTML = `
|
|
156
|
-
<button class="feedback-survey-close"><iconify-icon icon="ph:x
|
|
156
|
+
<button class="feedback-survey-close"><iconify-icon icon="ph:x" width="16" height="16"></iconify-icon></button>
|
|
157
157
|
${showTitle ? `<h3 class="feedback-survey-title">${config.title}</h3>` : ''}
|
|
158
158
|
${showDescription ? `<p class="feedback-survey-description">${config.description}</p>` : ''}
|
|
159
159
|
${isMultiPage && this.surveyOptions.pages.length > 1 ? `<div class="feedback-survey-progress"><div class="feedback-survey-progress-track"><div class="feedback-survey-progress-fill" style="width:${progressPercent}%"></div></div></div>` : ''}
|
|
@@ -493,7 +493,7 @@ export class SurveyWidget extends BaseWidget {
|
|
|
493
493
|
typeof currentRating === 'number' && currentRating >= score
|
|
494
494
|
? ' filled'
|
|
495
495
|
: '';
|
|
496
|
-
return `<button class="feedback-survey-page-rating-btn feedback-survey-star-btn${filled}" data-page-id="${pageId}" data-score="${score}"><iconify-icon icon="ph:star
|
|
496
|
+
return `<button class="feedback-survey-page-rating-btn feedback-survey-star-btn${filled}" data-page-id="${pageId}" data-score="${score}"><iconify-icon icon="ph:star" width="32" height="32" style="pointer-events:none;"></iconify-icon></button>`;
|
|
497
497
|
}).join('')}
|
|
498
498
|
</div>
|
|
499
499
|
${labels}
|
|
@@ -1211,7 +1211,7 @@ export class SurveyWidget extends BaseWidget {
|
|
|
1211
1211
|
|
|
1212
1212
|
const error = document.createElement('div');
|
|
1213
1213
|
error.className = 'feedback-survey-error';
|
|
1214
|
-
error.innerHTML = `<iconify-icon icon="ph:warning
|
|
1214
|
+
error.innerHTML = `<iconify-icon icon="ph:warning" width="15" height="15"></iconify-icon><span>${message}</span>`;
|
|
1215
1215
|
|
|
1216
1216
|
this.surveyElement.prepend(error);
|
|
1217
1217
|
|
|
@@ -1247,16 +1247,16 @@ export class SurveyWidget extends BaseWidget {
|
|
|
1247
1247
|
}
|
|
1248
1248
|
|
|
1249
1249
|
this.surveyElement.innerHTML = `
|
|
1250
|
-
<button class="feedback-survey-close"><iconify-icon icon="ph:x
|
|
1250
|
+
<button class="feedback-survey-close"><iconify-icon icon="ph:x" width="16" height="16"></iconify-icon></button>
|
|
1251
1251
|
<div class="feedback-survey-thankyou">
|
|
1252
|
-
<iconify-icon icon="ph:check-circle
|
|
1252
|
+
<iconify-icon icon="ph:check-circle" width="48" height="48" class="feedback-survey-thankyou-icon"></iconify-icon>
|
|
1253
1253
|
<h3 class="feedback-survey-thankyou-title">${title}</h3>
|
|
1254
1254
|
${
|
|
1255
1255
|
buttonText
|
|
1256
1256
|
? `
|
|
1257
1257
|
<a class="feedback-survey-thankyou-btn" href="${buttonUrl}" target="_blank" rel="noopener noreferrer">
|
|
1258
1258
|
${buttonText}
|
|
1259
|
-
<iconify-icon icon="ph:arrow-square-out
|
|
1259
|
+
<iconify-icon icon="ph:arrow-square-out" width="15" height="15" style="pointer-events:none;"></iconify-icon>
|
|
1260
1260
|
</a>`
|
|
1261
1261
|
: ''
|
|
1262
1262
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { ButtonWidget } from './ButtonWidget.js';
|
|
3
3
|
import { ChangelogWidget } from './ChangelogWidget.js';
|
|
4
4
|
import { InlineWidget } from './InlineWidget.js';
|
|
5
|
+
import { LiveChatWidget } from './LiveChatWidget.js';
|
|
5
6
|
import { SurveyWidget } from './SurveyWidget.js';
|
|
6
7
|
import { TabWidget } from './TabWidget.js';
|
|
7
|
-
import { LiveChatWidget } from './LiveChatWidget.js';
|
|
8
8
|
|
|
9
9
|
export class WidgetFactory {
|
|
10
10
|
static widgets = new Map([
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
render() {
|
|
14
14
|
this.element = document.createElement('div');
|
|
15
|
-
this.element.className = `
|
|
15
|
+
this.element.className = `liveChat-launcher liveChat-launcher-${this.options.position}`;
|
|
16
16
|
|
|
17
17
|
this._updateContent();
|
|
18
18
|
this._attachEvents();
|
|
@@ -32,22 +32,22 @@
|
|
|
32
32
|
_updateContent() {
|
|
33
33
|
const badgeHtml =
|
|
34
34
|
this.state.unreadCount > 0
|
|
35
|
-
? `<span class="
|
|
35
|
+
? `<span class="liveChat-launcher-badge">${this.state.unreadCount > 9 ? '9+' : this.state.unreadCount}</span>`
|
|
36
36
|
: '';
|
|
37
37
|
|
|
38
38
|
this.element.innerHTML = `
|
|
39
|
-
<button class="
|
|
40
|
-
<span class="
|
|
41
|
-
<iconify-icon icon="ph:chats-circle
|
|
39
|
+
<button class="liveChat-launcher-btn" aria-label="Open live chat">
|
|
40
|
+
<span class="liveChat-launcher-icon liveChat-launcher-icon-chat">
|
|
41
|
+
<iconify-icon icon="ph:chats-circle" width="24" height="24"></iconify-icon>
|
|
42
42
|
</span>
|
|
43
|
-
<span class="
|
|
43
|
+
<span class="liveChat-launcher-icon liveChat-launcher-icon-close" style="display: none;">
|
|
44
44
|
<iconify-icon icon="ph:caret-down-bold" width="22" height="22"></iconify-icon>
|
|
45
45
|
</span>
|
|
46
46
|
${badgeHtml}
|
|
47
47
|
</button>
|
|
48
48
|
`;
|
|
49
49
|
|
|
50
|
-
const btn = this.element.querySelector('.
|
|
50
|
+
const btn = this.element.querySelector('.liveChat-launcher-btn');
|
|
51
51
|
if (btn && this.options.primaryColor) {
|
|
52
52
|
btn.style.setProperty(
|
|
53
53
|
'background',
|
|
@@ -59,32 +59,32 @@
|
|
|
59
59
|
|
|
60
60
|
_attachEvents() {
|
|
61
61
|
this.element
|
|
62
|
-
.querySelector('.
|
|
62
|
+
.querySelector('.liveChat-launcher-btn')
|
|
63
63
|
.addEventListener('click', () => {
|
|
64
64
|
this.state.setOpen(!this.state.isOpen);
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
_updateIcon() {
|
|
69
|
-
const chatIcon = this.element.querySelector('.
|
|
69
|
+
const chatIcon = this.element.querySelector('.liveChat-launcher-icon-chat');
|
|
70
70
|
const closeIcon = this.element.querySelector(
|
|
71
|
-
'.
|
|
71
|
+
'.liveChat-launcher-icon-close'
|
|
72
72
|
);
|
|
73
73
|
|
|
74
74
|
if (this.state.isOpen) {
|
|
75
75
|
chatIcon.style.display = 'none';
|
|
76
76
|
closeIcon.style.display = 'flex';
|
|
77
|
-
this.element.classList.add('
|
|
77
|
+
this.element.classList.add('liveChat-launcher-open');
|
|
78
78
|
} else {
|
|
79
79
|
chatIcon.style.display = 'flex';
|
|
80
80
|
closeIcon.style.display = 'none';
|
|
81
|
-
this.element.classList.remove('
|
|
81
|
+
this.element.classList.remove('liveChat-launcher-open');
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
_updateBadge() {
|
|
86
86
|
const existingBadge = this.element.querySelector(
|
|
87
|
-
'.
|
|
87
|
+
'.liveChat-launcher-badge'
|
|
88
88
|
);
|
|
89
89
|
if (existingBadge) {
|
|
90
90
|
existingBadge.remove();
|
|
@@ -92,10 +92,10 @@
|
|
|
92
92
|
|
|
93
93
|
if (this.state.unreadCount > 0 && !this.state.isOpen) {
|
|
94
94
|
const badge = document.createElement('span');
|
|
95
|
-
badge.className = '
|
|
95
|
+
badge.className = 'liveChat-launcher-badge';
|
|
96
96
|
badge.textContent =
|
|
97
97
|
this.state.unreadCount > 9 ? '9+' : this.state.unreadCount;
|
|
98
|
-
this.element.querySelector('.
|
|
98
|
+
this.element.querySelector('.liveChat-launcher-btn').appendChild(badge);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -12,6 +12,7 @@ export class LiveChatPanel {
|
|
|
12
12
|
this.currentViewComponent = null;
|
|
13
13
|
this.viewRegistry = {};
|
|
14
14
|
this._unsubscribe = null;
|
|
15
|
+
this._expanded = false;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
registerView(name, ViewClass) {
|
|
@@ -20,17 +21,20 @@ export class LiveChatPanel {
|
|
|
20
21
|
|
|
21
22
|
render() {
|
|
22
23
|
this.element = document.createElement('div');
|
|
23
|
-
this.element.className = `
|
|
24
|
+
this.element.className = `liveChat-panel liveChat-panel-${this.options.position}`;
|
|
24
25
|
|
|
25
26
|
this.element.innerHTML = `
|
|
26
|
-
<div class="
|
|
27
|
-
<div class="
|
|
28
|
-
<div class="
|
|
27
|
+
<div class="liveChat-panel-content">
|
|
28
|
+
<div class="liveChat-panel-views"></div>
|
|
29
|
+
<div class="liveChat-panel-nav"></div>
|
|
29
30
|
</div>
|
|
30
31
|
`;
|
|
31
32
|
|
|
33
|
+
this.options.onToggleExpand = () => this._toggleExpand();
|
|
34
|
+
this.options.isExpanded = () => this._expanded;
|
|
35
|
+
|
|
32
36
|
this.navigationTabs = new NavigationTabs(this.state, this.options);
|
|
33
|
-
const navContainer = this.element.querySelector('.
|
|
37
|
+
const navContainer = this.element.querySelector('.liveChat-panel-nav');
|
|
34
38
|
navContainer.appendChild(this.navigationTabs.render());
|
|
35
39
|
|
|
36
40
|
this._renderCurrentView();
|
|
@@ -44,9 +48,30 @@ export class LiveChatPanel {
|
|
|
44
48
|
return this.element;
|
|
45
49
|
}
|
|
46
50
|
|
|
51
|
+
_toggleExpand() {
|
|
52
|
+
this._expanded = !this._expanded;
|
|
53
|
+
this.element.classList.toggle('liveChat-panel-expanded', this._expanded);
|
|
54
|
+
|
|
55
|
+
const menuIcon = this.element.querySelector(
|
|
56
|
+
'.liveChat-expand-window-btn iconify-icon'
|
|
57
|
+
);
|
|
58
|
+
const menuLabel = this.element.querySelector(
|
|
59
|
+
'.liveChat-expand-window-btn span'
|
|
60
|
+
);
|
|
61
|
+
if (menuIcon)
|
|
62
|
+
menuIcon.setAttribute(
|
|
63
|
+
'icon',
|
|
64
|
+
this._expanded ? 'ph:arrows-in' : 'ph:arrows-out'
|
|
65
|
+
);
|
|
66
|
+
if (menuLabel)
|
|
67
|
+
menuLabel.textContent = this._expanded
|
|
68
|
+
? 'Collapse window'
|
|
69
|
+
: 'Expand window';
|
|
70
|
+
}
|
|
71
|
+
|
|
47
72
|
_renderCurrentView() {
|
|
48
|
-
const viewsContainer = this.element.querySelector('.
|
|
49
|
-
const navContainer = this.element.querySelector('.
|
|
73
|
+
const viewsContainer = this.element.querySelector('.liveChat-panel-views');
|
|
74
|
+
const navContainer = this.element.querySelector('.liveChat-panel-nav');
|
|
50
75
|
|
|
51
76
|
if (this.currentViewComponent && this.currentViewComponent.destroy) {
|
|
52
77
|
this.currentViewComponent.destroy();
|
|
@@ -54,12 +79,18 @@ export class LiveChatPanel {
|
|
|
54
79
|
|
|
55
80
|
viewsContainer.innerHTML = '';
|
|
56
81
|
|
|
82
|
+
// Collapse expanded state when leaving chat view
|
|
83
|
+
if (this.state.currentView !== 'chat' && this._expanded) {
|
|
84
|
+
this._expanded = false;
|
|
85
|
+
this.element.classList.remove('liveChat-panel-expanded');
|
|
86
|
+
}
|
|
87
|
+
|
|
57
88
|
const ViewClass = this.viewRegistry[this.state.currentView];
|
|
58
89
|
if (ViewClass) {
|
|
59
90
|
this.currentViewComponent = new ViewClass(this.state, this.options);
|
|
60
91
|
viewsContainer.appendChild(this.currentViewComponent.render());
|
|
61
92
|
} else {
|
|
62
|
-
viewsContainer.innerHTML = `<div class="
|
|
93
|
+
viewsContainer.innerHTML = `<div class="liveChat-empty-state">
|
|
63
94
|
<p>View not found: ${this.state.currentView}</p>
|
|
64
95
|
</div>`;
|
|
65
96
|
}
|
|
@@ -88,7 +119,7 @@ export class LiveChatPanel {
|
|
|
88
119
|
}
|
|
89
120
|
|
|
90
121
|
setHeader(headerContent) {
|
|
91
|
-
const header = this.element.querySelector('.
|
|
122
|
+
const header = this.element.querySelector('.liveChat-panel-header');
|
|
92
123
|
if (header) {
|
|
93
124
|
header.innerHTML = headerContent;
|
|
94
125
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
render() {
|
|
10
10
|
this.element = document.createElement('div');
|
|
11
|
-
this.element.className = '
|
|
11
|
+
this.element.className = 'liveChat-panel-nav';
|
|
12
12
|
|
|
13
13
|
this._updateContent();
|
|
14
14
|
this._attachEvents();
|
|
@@ -24,24 +24,24 @@
|
|
|
24
24
|
|
|
25
25
|
_getTabs() {
|
|
26
26
|
const tabs = [
|
|
27
|
-
{ id: 'home', label: 'Home', icon: 'ph:house-simple
|
|
27
|
+
{ id: 'home', label: 'Home', icon: 'ph:house-simple' },
|
|
28
28
|
{
|
|
29
29
|
id: 'messages',
|
|
30
30
|
label: 'Messages',
|
|
31
|
-
icon: 'ph:chats
|
|
31
|
+
icon: 'ph:chats',
|
|
32
32
|
badge: this.state.unreadCount,
|
|
33
33
|
},
|
|
34
34
|
];
|
|
35
35
|
|
|
36
36
|
if (this.state.enableHelp) {
|
|
37
|
-
tabs.push({ id: 'help', label: 'Help', icon: 'ph:books
|
|
37
|
+
tabs.push({ id: 'help', label: 'Help', icon: 'ph:books' });
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if (this.state.enableChangelog) {
|
|
41
41
|
tabs.push({
|
|
42
42
|
id: 'changelog',
|
|
43
43
|
label: 'Updates',
|
|
44
|
-
icon: 'ph:megaphone
|
|
44
|
+
icon: 'ph:megaphone',
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
const isActive = this.state.currentView === tab.id;
|
|
56
56
|
const badgeHtml =
|
|
57
57
|
tab.badge && tab.badge > 0
|
|
58
|
-
? `<span class="
|
|
58
|
+
? `<span class="liveChat-nav-badge">${tab.badge > 9 ? '9+' : tab.badge}</span>`
|
|
59
59
|
: '';
|
|
60
60
|
|
|
61
61
|
return `
|
|
62
|
-
<button class="
|
|
63
|
-
<span class="
|
|
62
|
+
<button class="liveChat-nav-tab ${isActive ? 'active' : ''}" data-tab="${tab.id}">
|
|
63
|
+
<span class="liveChat-nav-icon">
|
|
64
64
|
<iconify-icon icon="${tab.icon}" width="22" height="22"></iconify-icon>
|
|
65
65
|
</span>
|
|
66
|
-
<span class="
|
|
66
|
+
<span class="liveChat-nav-label">${tab.label}</span>
|
|
67
67
|
${badgeHtml}
|
|
68
68
|
</button>
|
|
69
69
|
`;
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
.join('');
|
|
72
72
|
|
|
73
73
|
this.element.innerHTML = `
|
|
74
|
-
<div class="
|
|
74
|
+
<div class="liveChat-nav-tabs">
|
|
75
75
|
${tabsHtml}
|
|
76
76
|
</div>
|
|
77
|
-
<div class="
|
|
78
|
-
<a href="https://product7.io" target="_blank" rel="noopener noreferrer" class="
|
|
77
|
+
<div class="liveChat-nav-footer">
|
|
78
|
+
<a href="https://product7.io" target="_blank" rel="noopener noreferrer" class="liveChat-powered-by">
|
|
79
79
|
<svg width="12" height="14" viewBox="0 0 28 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
80
80
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.0615 5.28044C8.5161 4.42949 3.30825 11.1456 5.89967 17.6588C6.9321 20.2538 9.06268 22.2644 11.8777 23.1968C16.2682 24.6507 18.4038 22.3222 19.0483 23.9691C19.4055 24.8894 18.7282 25.3209 17.988 25.4938C10.9146 27.15 5.15304 22.7566 3.5869 17.5531C1.52205 10.6941 5.98684 4.6667 11.3483 3.41065C17.8801 1.88094 24.0325 6.19355 24.3926 12.7175C24.7448 19.0921 18.6217 24.5978 11.927 22.2036C10.8789 21.8285 8.8419 20.6682 8.46823 19.858C8.06026 18.9727 8.80261 18.1725 9.68285 18.3576C10.2223 18.4726 10.3116 18.8706 11.3161 19.5372C14.4549 21.6213 19.1276 20.6132 21.2046 17.0972C23.991 12.3817 21.0481 6.05351 15.06 5.27758L15.0615 5.28044Z" fill="#21244A"/>
|
|
81
81
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.2492 2.19833C11.944 1.71463 8.88819 3.07214 6.91479 4.49682C2.27067 7.85488 0.76169 14.5038 3.49672 19.8731C4.08535 21.0096 4.84379 22.0497 5.7459 22.9576L7.16343 24.2515C7.67214 24.9131 7.27203 25.7176 6.64115 25.9269C5.13502 26.4271 2.0499 21.8172 1.42044 20.5383C0.0872204 17.8297 -0.312889 14.9047 0.242977 11.503C1.66908 2.77063 11.221 -2.51652 19.7197 1.21021C27.7548 4.73331 30.2733 15.4555 23.9351 22.0773C23.3107 22.7296 21.6352 24.4823 20.6278 23.8907C20.0076 23.5263 19.8933 22.6446 20.5192 22.1238C21.0301 21.6986 21.4759 21.435 21.9896 20.9734C23.6665 19.4688 25.2562 16.8752 25.3477 13.5636C25.4427 10.2055 24.1266 7.5848 22.3904 5.74859C20.6392 3.89665 18.6751 2.69919 15.2456 2.19691L15.2492 2.19833Z" fill="#F69F06"/>
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
|
|
91
91
|
_attachEvents() {
|
|
92
92
|
this.element.addEventListener('click', (e) => {
|
|
93
|
-
const tab = e.target.closest('.
|
|
93
|
+
const tab = e.target.closest('.liveChat-nav-tab');
|
|
94
94
|
if (tab) {
|
|
95
95
|
const tabId = tab.dataset.tab;
|
|
96
96
|
this.state.setView(tabId);
|
|
@@ -99,18 +99,18 @@
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
_updateActiveTab() {
|
|
102
|
-
const tabs = this.element.querySelectorAll('.
|
|
102
|
+
const tabs = this.element.querySelectorAll('.liveChat-nav-tab');
|
|
103
103
|
tabs.forEach((tab) => {
|
|
104
104
|
const isActive = tab.dataset.tab === this.state.currentView;
|
|
105
105
|
tab.classList.toggle('active', isActive);
|
|
106
106
|
|
|
107
107
|
if (tab.dataset.tab === 'messages') {
|
|
108
|
-
const existingBadge = tab.querySelector('.
|
|
108
|
+
const existingBadge = tab.querySelector('.liveChat-nav-badge');
|
|
109
109
|
if (existingBadge) existingBadge.remove();
|
|
110
110
|
|
|
111
111
|
if (this.state.unreadCount > 0) {
|
|
112
112
|
const badge = document.createElement('span');
|
|
113
|
-
badge.className = '
|
|
113
|
+
badge.className = 'liveChat-nav-badge';
|
|
114
114
|
badge.textContent =
|
|
115
115
|
this.state.unreadCount > 9 ? '9+' : this.state.unreadCount;
|
|
116
116
|
tab.appendChild(badge);
|