@product7/feedback-sdk 1.3.8 → 1.3.9

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.
Files changed (39) hide show
  1. package/dist/feedback-sdk.js +2824 -2371
  2. package/dist/feedback-sdk.js.map +1 -1
  3. package/dist/feedback-sdk.min.js +1 -1
  4. package/dist/feedback-sdk.min.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/api/services/MessengerService.js +5 -5
  7. package/src/core/APIService.js +33 -14
  8. package/src/index.js +1 -1
  9. package/src/styles/base.js +1 -1
  10. package/src/styles/changelog.js +58 -40
  11. package/src/styles/components.js +19 -2
  12. package/src/styles/design-tokens.js +4 -4
  13. package/src/styles/feedback.js +3 -8
  14. package/src/styles/messenger-components.js +473 -0
  15. package/src/styles/messenger-core.js +37 -268
  16. package/src/styles/messenger-features.js +89 -267
  17. package/src/styles/messenger-views.js +391 -325
  18. package/src/styles/messenger.js +17 -558
  19. package/src/styles/styles.js +21 -24
  20. package/src/styles/{surveys.js → survey.js} +55 -20
  21. package/src/widgets/BaseWidget.js +1 -1
  22. package/src/widgets/ButtonWidget.js +1 -1
  23. package/src/widgets/ChangelogWidget.js +1 -1
  24. package/src/widgets/InlineWidget.js +1 -1
  25. package/src/widgets/MessengerWidget.js +15 -9
  26. package/src/widgets/SurveyWidget.js +1 -1
  27. package/src/widgets/TabWidget.js +1 -1
  28. package/src/widgets/messenger/MessengerState.js +5 -2
  29. package/src/widgets/messenger/components/MessengerLauncher.js +22 -18
  30. package/src/widgets/messenger/components/MessengerPanel.js +1 -1
  31. package/src/widgets/messenger/components/NavigationTabs.js +36 -15
  32. package/src/widgets/messenger/views/ChangelogView.js +8 -32
  33. package/src/widgets/messenger/views/ChatView.js +96 -60
  34. package/src/widgets/messenger/views/ConversationsView.js +67 -45
  35. package/src/widgets/messenger/views/HelpView.js +22 -32
  36. package/src/widgets/messenger/views/HomeView.js +58 -40
  37. package/src/widgets/messenger/views/PreChatFormView.js +12 -5
  38. package/src/styles/messenger-help.js +0 -298
  39. package/src/styles/messenger-themes.js +0 -500
@@ -30,31 +30,30 @@ export class HomeView {
30
30
  const recentChangelogHtml = this._renderRecentChangelog();
31
31
 
32
32
  this.element.innerHTML = `
33
- <div class="messenger-home-header">
34
- <div class="messenger-home-header-top">
35
- <div class="messenger-home-logo">
36
- ${this.options.logoUrl ? `<img src="${this.options.logoUrl}" alt="${this.state.teamName}" />` : ''}
33
+ <div class="messenger-home-scroll">
34
+ <div class="messenger-home-header">
35
+ <div class="messenger-home-header-top">
36
+ <div class="messenger-home-logo">
37
+ ${this.options.logoUrl ? `<img src="${this.options.logoUrl}" alt="${this.state.teamName}" />` : ''}
38
+ </div>
39
+ <div class="messenger-home-avatars">${avatarsHtml}</div>
40
+ <button class="sdk-close-btn" aria-label="Close">
41
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="#000000" viewBox="0 0 256 256">
42
+ <path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>
43
+ </svg>
44
+ </button>
45
+ </div>
46
+ <div class="messenger-home-welcome">
47
+ <span class="messenger-home-greeting">Hi there 👋</span>
48
+ <span class="messenger-home-question">${this.state.welcomeMessage}</span>
37
49
  </div>
38
- <div class="messenger-home-avatars">${avatarsHtml}</div>
39
- <button class="sdk-close-btn" aria-label="Close">
40
- <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="#000000" viewBox="0 0 256 256">
41
- <path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>
42
- </svg>
43
- </button>
44
- </div>
45
- <div class="messenger-home-welcome">
46
- <span class="messenger-home-greeting">Hello there.</span>
47
- <span class="messenger-home-question">${this.state.welcomeMessage}</span>
48
- ${this._renderAvailabilityStatus()}
49
50
  </div>
50
- </div>
51
-
52
- <div class="messenger-home-body">
53
- ${this._renderMessageButton()}
54
51
 
55
- ${this._renderFeaturedCard()}
56
-
57
- ${recentChangelogHtml}
52
+ <div class="messenger-home-body">
53
+ ${this._renderMessageButton()}
54
+ ${this._renderFeaturedCard()}
55
+ ${recentChangelogHtml}
56
+ </div>
58
57
  </div>
59
58
  `;
60
59
 
@@ -63,22 +62,24 @@ export class HomeView {
63
62
 
64
63
  _renderAvatarStack() {
65
64
  const avatars = this.state.teamAvatars;
65
+ const colors = ['#5856d6', '#007aff', '#34c759', '#ff9500'];
66
+
66
67
  if (!avatars || avatars.length === 0) {
67
68
  return `
68
69
  <div class="messenger-avatar-stack">
69
- <div class="sdk-avatar sdk-avatar-md">S</div>
70
- <div class="sdk-avatar sdk-avatar-md">T</div>
70
+ <div class="sdk-avatar sdk-avatar-lg" style="background: ${colors[0]};">S</div>
71
+ <div class="sdk-avatar sdk-avatar-lg" style="background: ${colors[1]};">T</div>
71
72
  </div>
72
73
  `;
73
74
  }
74
75
 
75
76
  const avatarItems = avatars
76
- .slice(0, 3)
77
- .map((avatar) => {
77
+ .slice(0, 4)
78
+ .map((avatar, index) => {
78
79
  if (typeof avatar === 'string' && avatar.startsWith('http')) {
79
- return `<div class="sdk-avatar sdk-avatar-md"><img src="${avatar}" alt="Team member" /></div>`;
80
+ return `<div class="sdk-avatar sdk-avatar-lg"><img src="${avatar}" alt="Team member" /></div>`;
80
81
  }
81
- return `<div class="sdk-avatar sdk-avatar-md">${avatar.charAt(0).toUpperCase()}</div>`;
82
+ return `<div class="sdk-avatar sdk-avatar-lg" style="background: ${colors[index % colors.length]};">${avatar.charAt(0).toUpperCase()}</div>`;
82
83
  })
83
84
  .join('');
84
85
 
@@ -112,28 +113,48 @@ export class HomeView {
112
113
  (c) => c.status === 'open'
113
114
  );
114
115
 
116
+ const sendIcon = `
117
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256" style="flex-shrink: 0;">
118
+ <rect width="256" height="256" fill="none"/>
119
+ <line x1="144" y1="128" x2="80" y2="128" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
120
+ <path d="M48.49,221.28A8,8,0,0,0,59.93,231l168-96.09a8,8,0,0,0,0-14l-168-95.85a8,8,0,0,0-11.44,9.67L80,128Z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
121
+ </svg>
122
+ `;
123
+
124
+ const caretIcon = `
125
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256" style="flex-shrink: 0;">
126
+ <rect width="256" height="256" fill="none"/>
127
+ <polyline points="96 48 176 128 96 208" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
128
+ </svg>
129
+ `;
130
+
115
131
  if (openConversation) {
116
132
  const preview = openConversation.lastMessage
117
- ? (openConversation.lastMessage.length > 40
133
+ ? openConversation.lastMessage.length > 40
118
134
  ? openConversation.lastMessage.substring(0, 40) + '...'
119
- : openConversation.lastMessage)
135
+ : openConversation.lastMessage
120
136
  : 'Continue your conversation';
121
-
122
137
  return `
123
138
  <button class="messenger-home-message-btn messenger-home-continue-btn" data-conversation-id="${openConversation.id}">
124
139
  <div class="messenger-home-continue-info">
125
140
  <span class="messenger-home-continue-label">Continue conversation</span>
126
- <span class="messenger-home-continue-preview">${preview}</span>
127
141
  </div>
128
- <i class="ph ph-arrow-right"></i>
142
+ ${sendIcon}
143
+ </button>
144
+ <button class="messenger-home-message-btn" data-action="feedback">
145
+ <span class="messenger-home-continue-label">Leave us feedback</span>
146
+ ${caretIcon}
129
147
  </button>
130
148
  `;
131
149
  }
132
-
133
150
  return `
134
151
  <button class="messenger-home-message-btn">
135
- <span>Send us a message</span>
136
- <i class="ph ph-arrow-right"></i>
152
+ <span>Start a conversation</span>
153
+ ${sendIcon}
154
+ </button>
155
+ <button class="messenger-home-message-btn" data-action="feedback">
156
+ <span>Leave us feedback</span>
157
+ ${caretIcon}
137
158
  </button>
138
159
  `;
139
160
  }
@@ -213,20 +234,17 @@ export class HomeView {
213
234
  this.state.setOpen(false);
214
235
  });
215
236
 
216
- // Send message / continue conversation button
217
237
  const msgBtn = this.element.querySelector('.messenger-home-message-btn');
218
238
  if (msgBtn) {
219
239
  msgBtn.addEventListener('click', () => {
220
240
  const convId = msgBtn.dataset.conversationId;
221
241
  if (convId) {
222
- // Continue existing open conversation
223
242
  this.state.setActiveConversation(convId);
224
243
  this.state.setView('chat');
225
244
  if (this.options.onSelectConversation) {
226
245
  this.options.onSelectConversation(convId);
227
246
  }
228
247
  } else {
229
- // No open conversation — start new
230
248
  this.state.setActiveConversation(null);
231
249
  this.state.setView('chat');
232
250
  }
@@ -274,4 +292,4 @@ export class HomeView {
274
292
  this.element.parentNode.removeChild(this.element);
275
293
  }
276
294
  }
277
- }
295
+ }
@@ -167,8 +167,12 @@ export class PreChatFormView {
167
167
  const nameInput = this.element.querySelector('#messenger-prechat-name');
168
168
  const emailInput = this.element.querySelector('#messenger-prechat-email');
169
169
  const submitBtn = this.element.querySelector('.messenger-prechat-submit');
170
- const submitText = submitBtn.querySelector('.messenger-prechat-submit-text');
171
- const submitLoading = submitBtn.querySelector('.messenger-prechat-submit-loading');
170
+ const submitText = submitBtn.querySelector(
171
+ '.messenger-prechat-submit-text'
172
+ );
173
+ const submitLoading = submitBtn.querySelector(
174
+ '.messenger-prechat-submit-loading'
175
+ );
172
176
 
173
177
  const name = nameInput.value.trim();
174
178
  const email = emailInput.value.trim();
@@ -191,7 +195,7 @@ export class PreChatFormView {
191
195
  if (pendingMessage && this.options.onStartConversation) {
192
196
  this.state.pendingMessage = null;
193
197
  this.state.setView('chat');
194
-
198
+
195
199
  await this.options.onStartConversation(
196
200
  pendingMessage.content,
197
201
  pendingMessage.attachments
@@ -201,7 +205,10 @@ export class PreChatFormView {
201
205
  }
202
206
  } catch (error) {
203
207
  console.error('[PreChatFormView] Error submitting form:', error);
204
- this._showError('messenger-email-error', 'Something went wrong. Please try again.');
208
+ this._showError(
209
+ 'messenger-email-error',
210
+ 'Something went wrong. Please try again.'
211
+ );
205
212
 
206
213
  this._isSubmitting = false;
207
214
  submitBtn.disabled = false;
@@ -215,4 +222,4 @@ export class PreChatFormView {
215
222
  this.element.parentNode.removeChild(this.element);
216
223
  }
217
224
  }
218
- }
225
+ }
@@ -1,298 +0,0 @@
1
- export const messengerHelpStyles = `
2
-
3
- .messenger-help-header {
4
- display: flex;
5
- align-items: center;
6
- justify-content: center;
7
- padding: 20px;
8
- position: relative;
9
- }
10
-
11
- .messenger-help-header h2 {
12
- margin: 0;
13
- font-size: 17px;
14
- font-weight: 600;
15
- color: white;
16
- }
17
-
18
- .messenger-help-header .messenger-close-btn {
19
- position: absolute;
20
- right: 16px;
21
- top: 50%;
22
- transform: translateY(-50%);
23
- }
24
-
25
- .messenger-help-search {
26
- padding: 0 16px 16px;
27
- }
28
-
29
- .messenger-help-search-wrapper {
30
- display: flex;
31
- align-items: center;
32
- background: #2c2c2e;
33
- border-radius: 12px;
34
- padding: 14px 16px;
35
- position: relative;
36
- }
37
-
38
- .messenger-help-search-icon {
39
- position: absolute;
40
- right: 16px;
41
- color: rgba(255, 255, 255, 0.4);
42
- }
43
-
44
- .messenger-help-search-input {
45
- flex: 1;
46
- background: transparent;
47
- border: none;
48
- outline: none;
49
- color: white;
50
- font-size: 16px;
51
- font-family: inherit;
52
- padding-right: 32px;
53
- }
54
-
55
- .messenger-help-search-input::placeholder {
56
- color: rgba(255, 255, 255, 0.4);
57
- }
58
-
59
- .messenger-help-body {
60
- flex: 1;
61
- overflow-y: auto;
62
- padding: 0;
63
- }
64
-
65
- .messenger-help-collections-header {
66
- font-size: 17px;
67
- font-weight: 600;
68
- color: white;
69
- padding: 12px 16px 8px;
70
- border-top: 1px solid rgba(255, 255, 255, 0.1);
71
- }
72
-
73
- .messenger-help-collections {
74
- padding: 0;
75
- }
76
-
77
- .messenger-help-collection {
78
- display: flex;
79
- align-items: center;
80
- padding: 10px 16px;
81
- cursor: pointer;
82
- transition: background 0.2s ease;
83
- border-top: 1px solid rgba(255, 255, 255, 0.1);
84
- }
85
-
86
- .messenger-help-collection:hover {
87
- background: rgba(255, 255, 255, 0.05);
88
- }
89
-
90
- .messenger-help-collection-content {
91
- flex: 1;
92
- min-width: 0;
93
- }
94
-
95
- .messenger-help-collection-title {
96
- margin: 0 0 2px;
97
- font-size: 14px;
98
- font-weight: 600;
99
- color: white;
100
- }
101
-
102
- .messenger-help-collection-desc {
103
- margin: 0 0 2px;
104
- font-size: 14px;
105
- color: rgba(255, 255, 255, 0.7);
106
- line-height: 1.3;
107
- }
108
-
109
- .messenger-help-collection-count {
110
- font-size: 14px;
111
- color: rgba(255, 255, 255, 0.4);
112
- }
113
-
114
- .messenger-help-collection-arrow {
115
- color: rgba(255, 255, 255, 0.3);
116
- flex-shrink: 0;
117
- margin-left: 12px;
118
- }
119
-
120
- .messenger-help-empty {
121
- display: flex;
122
- flex-direction: column;
123
- align-items: center;
124
- justify-content: center;
125
- height: 100%;
126
- text-align: center;
127
- padding: 40px;
128
- }
129
-
130
- .messenger-help-empty-icon {
131
- color: rgba(255, 255, 255, 0.3);
132
- margin-bottom: 16px;
133
- }
134
-
135
- .messenger-help-empty h3 {
136
- margin: 0 0 8px;
137
- font-size: 18px;
138
- font-weight: 600;
139
- color: white;
140
- }
141
-
142
- .messenger-help-empty p {
143
- margin: 0;
144
- font-size: 14px;
145
- color: rgba(255, 255, 255, 0.5);
146
- }
147
-
148
-
149
- .messenger-changelog-header {
150
- display: flex;
151
- align-items: center;
152
- justify-content: space-between;
153
- padding: 20px;
154
- border-bottom: 1px solid rgba(255, 255, 255, 0.1);
155
- }
156
-
157
- .messenger-changelog-header h2 {
158
- margin: 0;
159
- font-size: 20px;
160
- font-weight: 600;
161
- color: white;
162
- }
163
-
164
- .messenger-changelog-subheader {
165
- display: flex;
166
- align-items: center;
167
- justify-content: space-between;
168
- padding: 12px 20px;
169
- border-bottom: 1px solid rgba(255, 255, 255, 0.1);
170
- }
171
-
172
- .messenger-changelog-latest {
173
- font-size: 12px;
174
- font-weight: 600;
175
- color: rgba(255, 255, 255, 0.5);
176
- text-transform: uppercase;
177
- letter-spacing: 0.5px;
178
- }
179
-
180
- .messenger-changelog-team {
181
- display: flex;
182
- align-items: center;
183
- gap: 8px;
184
- font-size: 13px;
185
- color: rgba(255, 255, 255, 0.6);
186
- }
187
-
188
- .messenger-changelog-body {
189
- flex: 1;
190
- overflow-y: auto;
191
- padding: 16px;
192
- }
193
-
194
- .messenger-changelog-card {
195
- background: #2c2c2e;
196
- border-radius: 12px;
197
- overflow: hidden;
198
- margin-bottom: 12px;
199
- cursor: pointer;
200
- transition: all 0.2s ease;
201
- }
202
-
203
- .messenger-changelog-card:hover {
204
- background: #3c3c3e;
205
- transform: translateY(-2px);
206
- }
207
-
208
- .messenger-changelog-cover {
209
- height: 120px;
210
- overflow: hidden;
211
- }
212
-
213
- .messenger-changelog-cover img {
214
- width: 100%;
215
- height: 100%;
216
- object-fit: cover;
217
- }
218
-
219
- .messenger-changelog-content {
220
- padding: 16px;
221
- }
222
-
223
- .messenger-changelog-tags {
224
- display: flex;
225
- flex-wrap: wrap;
226
- gap: 8px;
227
- margin-bottom: 12px;
228
- }
229
-
230
- .messenger-changelog-tag {
231
- font-size: 11px;
232
- font-weight: 600;
233
- color: white;
234
- background: rgba(88, 86, 214, 0.3);
235
- padding: 4px 10px;
236
- border-radius: 12px;
237
- text-transform: uppercase;
238
- letter-spacing: 0.3px;
239
- }
240
-
241
- .messenger-changelog-title {
242
- margin: 0 0 8px;
243
- font-size: 14px;
244
- font-weight: 600;
245
- color: white;
246
- line-height: 1.3;
247
- }
248
-
249
- .messenger-changelog-description {
250
- margin: 0 0 12px;
251
- font-size: 14px;
252
- color: rgba(255, 255, 255, 0.6);
253
- line-height: 1.4;
254
- }
255
-
256
- .messenger-changelog-meta {
257
- display: flex;
258
- align-items: center;
259
- justify-content: space-between;
260
- }
261
-
262
- .messenger-changelog-date {
263
- font-size: 12px;
264
- color: rgba(255, 255, 255, 0.5);
265
- }
266
-
267
- .messenger-changelog-arrow {
268
- color: rgba(255, 255, 255, 0.3);
269
- }
270
-
271
- .messenger-changelog-empty {
272
- display: flex;
273
- flex-direction: column;
274
- align-items: center;
275
- justify-content: center;
276
- height: 100%;
277
- text-align: center;
278
- padding: 40px;
279
- }
280
-
281
- .messenger-changelog-empty-icon {
282
- color: rgba(255, 255, 255, 0.3);
283
- margin-bottom: 16px;
284
- }
285
-
286
- .messenger-changelog-empty h3 {
287
- margin: 0 0 8px;
288
- font-size: 18px;
289
- font-weight: 600;
290
- color: white;
291
- }
292
-
293
- .messenger-changelog-empty p {
294
- margin: 0;
295
- font-size: 14px;
296
- color: rgba(255, 255, 255, 0.5);
297
- }
298
- `;