@product7/feedback-sdk 1.6.1 → 1.6.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/dist/feedback-sdk.js +68 -136
- package/dist/feedback-sdk.js.map +1 -1
- package/dist/feedback-sdk.min.js +1 -1
- package/dist/feedback-sdk.min.js.map +1 -1
- package/package.json +1 -1
- package/src/styles/messenger-views.js +19 -36
- package/src/widgets/MessengerWidget.js +2 -0
- package/src/widgets/messenger/MessengerState.js +1 -0
- package/src/widgets/messenger/views/HelpView.js +46 -100
- package/src/widgets/messenger/views/HomeView.js +1 -1
- package/types/index.d.ts +1 -0
package/dist/feedback-sdk.js
CHANGED
|
@@ -3455,6 +3455,7 @@
|
|
|
3455
3455
|
|
|
3456
3456
|
this.teamName = options.teamName || 'Support';
|
|
3457
3457
|
this.teamAvatars = options.teamAvatars || [];
|
|
3458
|
+
this.greetingMessage = options.greetingMessage || 'Hi there 👋';
|
|
3458
3459
|
this.welcomeMessage = options.welcomeMessage || 'How can we help?';
|
|
3459
3460
|
|
|
3460
3461
|
this.userContext = options.userContext || null;
|
|
@@ -5128,9 +5129,6 @@
|
|
|
5128
5129
|
this.options = options;
|
|
5129
5130
|
this.element = null;
|
|
5130
5131
|
this._unsubscribe = null;
|
|
5131
|
-
|
|
5132
|
-
// Configurable header colour — defaults to Product7 blue
|
|
5133
|
-
this._headerBg = `linear-gradient(180deg, #f0f4ff 0%, #ffffff 100%)`;
|
|
5134
5132
|
}
|
|
5135
5133
|
|
|
5136
5134
|
render() {
|
|
@@ -5173,7 +5171,6 @@
|
|
|
5173
5171
|
/>
|
|
5174
5172
|
</div>
|
|
5175
5173
|
</div>
|
|
5176
|
-
|
|
5177
5174
|
<div class="messenger-help-body">
|
|
5178
5175
|
<div class="messenger-help-collections"></div>
|
|
5179
5176
|
</div>
|
|
@@ -5184,13 +5181,11 @@
|
|
|
5184
5181
|
}
|
|
5185
5182
|
|
|
5186
5183
|
_updateCollectionsList() {
|
|
5187
|
-
const
|
|
5188
|
-
'.messenger-help-collections'
|
|
5189
|
-
);
|
|
5184
|
+
const container = this.element.querySelector('.messenger-help-collections');
|
|
5190
5185
|
const collections = this.state.helpArticles || [];
|
|
5191
5186
|
const searchQuery = (this.state.helpSearchQuery || '').toLowerCase();
|
|
5192
5187
|
|
|
5193
|
-
const
|
|
5188
|
+
const filtered = searchQuery
|
|
5194
5189
|
? collections.filter(
|
|
5195
5190
|
(c) =>
|
|
5196
5191
|
c.title.toLowerCase().includes(searchQuery) ||
|
|
@@ -5198,20 +5193,15 @@
|
|
|
5198
5193
|
)
|
|
5199
5194
|
: collections;
|
|
5200
5195
|
|
|
5201
|
-
if (
|
|
5202
|
-
|
|
5196
|
+
if (filtered.length === 0) {
|
|
5197
|
+
container.innerHTML = this._renderEmptyState();
|
|
5203
5198
|
return;
|
|
5204
5199
|
}
|
|
5205
5200
|
|
|
5206
|
-
|
|
5207
|
-
.map((collection) => this._renderCollectionItem(collection))
|
|
5208
|
-
.join('');
|
|
5209
|
-
|
|
5201
|
+
container.innerHTML = filtered.map((c) => this._renderCollectionItem(c)).join('');
|
|
5210
5202
|
this._attachCollectionEvents();
|
|
5211
5203
|
}
|
|
5212
5204
|
|
|
5213
|
-
// ─── Avatar helpers ──────────────────────────────────────────────────────────
|
|
5214
|
-
|
|
5215
5205
|
_avatarColors = [
|
|
5216
5206
|
{ bg: '#EF4444', text: '#FFFFFF' },
|
|
5217
5207
|
{ bg: '#F97316', text: '#FFFFFF' },
|
|
@@ -5224,50 +5214,35 @@
|
|
|
5224
5214
|
];
|
|
5225
5215
|
|
|
5226
5216
|
_getAvatarColor(id) {
|
|
5227
|
-
const hash = id
|
|
5228
|
-
.split('')
|
|
5229
|
-
.reduce((acc, char) => acc + char.charCodeAt(0), 0);
|
|
5217
|
+
const hash = id.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);
|
|
5230
5218
|
return this._avatarColors[hash % this._avatarColors.length];
|
|
5231
5219
|
}
|
|
5232
5220
|
|
|
5233
5221
|
_getInitials(name) {
|
|
5234
5222
|
if (!name) return 'A';
|
|
5235
|
-
return name
|
|
5236
|
-
.split(' ')
|
|
5237
|
-
.map((n) => n[0])
|
|
5238
|
-
.join('')
|
|
5239
|
-
.toUpperCase()
|
|
5240
|
-
.slice(0, 2);
|
|
5223
|
+
return name.split(' ').map((n) => n[0]).join('').toUpperCase().slice(0, 2);
|
|
5241
5224
|
}
|
|
5242
5225
|
|
|
5243
5226
|
_renderAuthorAvatar(collection) {
|
|
5244
5227
|
if (collection.author?.picture) {
|
|
5245
|
-
return
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
/>
|
|
5252
|
-
`;
|
|
5228
|
+
return `<img
|
|
5229
|
+
src="${collection.author.picture}"
|
|
5230
|
+
alt="${collection.author.name || ''}"
|
|
5231
|
+
class="messenger-help-collection-avatar"
|
|
5232
|
+
title="${collection.author.name || ''}"
|
|
5233
|
+
/>`;
|
|
5253
5234
|
}
|
|
5254
5235
|
|
|
5255
5236
|
const { bg, text } = this._getAvatarColor(collection.id);
|
|
5256
|
-
const initials = collection.author?.name
|
|
5257
|
-
? this._getInitials(collection.author.name)
|
|
5258
|
-
: 'A';
|
|
5237
|
+
const initials = collection.author?.name ? this._getInitials(collection.author.name) : 'A';
|
|
5259
5238
|
|
|
5260
|
-
return
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
>${initials}</span>
|
|
5266
|
-
`;
|
|
5239
|
+
return `<span
|
|
5240
|
+
class="messenger-help-collection-avatar messenger-help-collection-avatar--initials"
|
|
5241
|
+
style="background-color: ${bg}; color: ${text};"
|
|
5242
|
+
title="${collection.author?.name || 'Author'}"
|
|
5243
|
+
>${initials}</span>`;
|
|
5267
5244
|
}
|
|
5268
5245
|
|
|
5269
|
-
// ─── Icon resolution ─────────────────────────────────────────────────────────
|
|
5270
|
-
|
|
5271
5246
|
_resolveCollectionIcon(icon) {
|
|
5272
5247
|
if (!icon) return this._defaultCollectionIcon();
|
|
5273
5248
|
|
|
@@ -5276,53 +5251,40 @@
|
|
|
5276
5251
|
}
|
|
5277
5252
|
|
|
5278
5253
|
if (icon.startsWith('ph:')) {
|
|
5279
|
-
return
|
|
5280
|
-
<
|
|
5281
|
-
|
|
5282
|
-
</span>
|
|
5283
|
-
`;
|
|
5254
|
+
return `<span class="messenger-help-collection-icon">
|
|
5255
|
+
<iconify-icon icon="${icon}" width="18" height="18"></iconify-icon>
|
|
5256
|
+
</span>`;
|
|
5284
5257
|
}
|
|
5285
5258
|
|
|
5286
5259
|
return this._defaultCollectionIcon();
|
|
5287
5260
|
}
|
|
5288
5261
|
|
|
5289
5262
|
_defaultCollectionIcon() {
|
|
5290
|
-
return
|
|
5291
|
-
<
|
|
5292
|
-
|
|
5293
|
-
</span>
|
|
5294
|
-
`;
|
|
5263
|
+
return `<span class="messenger-help-collection-icon">
|
|
5264
|
+
<iconify-icon icon="ph:book-open-duotone" width="18" height="18"></iconify-icon>
|
|
5265
|
+
</span>`;
|
|
5295
5266
|
}
|
|
5296
5267
|
|
|
5297
|
-
// ─── Rendering ───────────────────────────────────────────────────────────────
|
|
5298
|
-
|
|
5299
5268
|
_renderCollectionItem(collection) {
|
|
5300
5269
|
const articleCount = collection.articleCount || 0;
|
|
5301
|
-
const iconHtml = this._resolveCollectionIcon(collection.icon);
|
|
5302
|
-
const avatarHtml = this._renderAuthorAvatar(collection);
|
|
5303
5270
|
|
|
5304
5271
|
return `
|
|
5305
5272
|
<div class="messenger-help-collection" data-collection-id="${collection.id}">
|
|
5306
|
-
${
|
|
5273
|
+
${this._resolveCollectionIcon(collection.icon)}
|
|
5307
5274
|
<div class="messenger-help-collection-content">
|
|
5308
|
-
<
|
|
5275
|
+
<div class="messenger-help-collection-title">${collection.title}</div>
|
|
5309
5276
|
${collection.description ? `<p class="messenger-help-collection-desc">${collection.description}</p>` : ''}
|
|
5310
5277
|
<div class="messenger-help-collection-meta">
|
|
5311
|
-
${
|
|
5278
|
+
${this._renderAuthorAvatar(collection)}
|
|
5312
5279
|
<span class="messenger-help-collection-count">
|
|
5313
5280
|
${articleCount} ${articleCount === 1 ? 'article' : 'articles'}
|
|
5314
5281
|
</span>
|
|
5315
5282
|
</div>
|
|
5316
5283
|
</div>
|
|
5317
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 256 256" class="messenger-help-collection-arrow">
|
|
5318
|
-
<path d="M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"></path>
|
|
5319
|
-
</svg>
|
|
5320
5284
|
</div>
|
|
5321
5285
|
`;
|
|
5322
5286
|
}
|
|
5323
5287
|
|
|
5324
|
-
// ─── Empty states ────────────────────────────────────────────────────────────
|
|
5325
|
-
|
|
5326
5288
|
_renderEmptyState() {
|
|
5327
5289
|
if (this.state.helpSearchQuery) {
|
|
5328
5290
|
return `
|
|
@@ -5347,18 +5309,12 @@
|
|
|
5347
5309
|
`;
|
|
5348
5310
|
}
|
|
5349
5311
|
|
|
5350
|
-
// ─── Events ──────────────────────────────────────────────────────────────────
|
|
5351
|
-
|
|
5352
5312
|
_attachEvents() {
|
|
5353
|
-
this.element
|
|
5354
|
-
.
|
|
5355
|
-
|
|
5356
|
-
this.state.setOpen(false);
|
|
5357
|
-
});
|
|
5313
|
+
this.element.querySelector('.messenger-help-close-btn').addEventListener('click', () => {
|
|
5314
|
+
this.state.setOpen(false);
|
|
5315
|
+
});
|
|
5358
5316
|
|
|
5359
|
-
const searchInput = this.element.querySelector(
|
|
5360
|
-
'.messenger-help-search-input'
|
|
5361
|
-
);
|
|
5317
|
+
const searchInput = this.element.querySelector('.messenger-help-search-input');
|
|
5362
5318
|
let searchTimeout;
|
|
5363
5319
|
searchInput.addEventListener('input', (e) => {
|
|
5364
5320
|
clearTimeout(searchTimeout);
|
|
@@ -5371,32 +5327,23 @@
|
|
|
5371
5327
|
}
|
|
5372
5328
|
|
|
5373
5329
|
_attachCollectionEvents() {
|
|
5374
|
-
this.element
|
|
5375
|
-
.
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
} else if (this.options.onArticleClick) {
|
|
5385
|
-
this.options.onArticleClick(collection);
|
|
5386
|
-
}
|
|
5387
|
-
});
|
|
5330
|
+
this.element.querySelectorAll('.messenger-help-collection').forEach((item) => {
|
|
5331
|
+
item.addEventListener('click', () => {
|
|
5332
|
+
const collection = this.state.helpArticles.find(
|
|
5333
|
+
(c) => c.id === item.dataset.collectionId
|
|
5334
|
+
);
|
|
5335
|
+
if (collection?.url) {
|
|
5336
|
+
window.open(collection.url, '_blank');
|
|
5337
|
+
} else if (this.options.onArticleClick) {
|
|
5338
|
+
this.options.onArticleClick(collection);
|
|
5339
|
+
}
|
|
5388
5340
|
});
|
|
5341
|
+
});
|
|
5389
5342
|
}
|
|
5390
5343
|
|
|
5391
|
-
// ─── Lifecycle ───────────────────────────────────────────────────────────────
|
|
5392
|
-
|
|
5393
5344
|
destroy() {
|
|
5394
|
-
if (this._unsubscribe)
|
|
5395
|
-
|
|
5396
|
-
}
|
|
5397
|
-
if (this.element && this.element.parentNode) {
|
|
5398
|
-
this.element.parentNode.removeChild(this.element);
|
|
5399
|
-
}
|
|
5345
|
+
if (this._unsubscribe) this._unsubscribe();
|
|
5346
|
+
if (this.element?.parentNode) this.element.parentNode.removeChild(this.element);
|
|
5400
5347
|
}
|
|
5401
5348
|
}
|
|
5402
5349
|
|
|
@@ -5446,7 +5393,7 @@
|
|
|
5446
5393
|
</button>
|
|
5447
5394
|
</div>
|
|
5448
5395
|
<div class="messenger-home-welcome">
|
|
5449
|
-
<span class="messenger-home-greeting"
|
|
5396
|
+
<span class="messenger-home-greeting">${this.state.greetingMessage}</span>
|
|
5450
5397
|
<span class="messenger-home-question">${this.state.welcomeMessage}</span>
|
|
5451
5398
|
</div>
|
|
5452
5399
|
</div>
|
|
@@ -5957,6 +5904,7 @@
|
|
|
5957
5904
|
logoUrl: options.logoUrl || 'https://product7.io/p7logo.svg',
|
|
5958
5905
|
teamName: options.teamName || 'Support',
|
|
5959
5906
|
teamAvatars: options.teamAvatars || [],
|
|
5907
|
+
greetingMessage: options.greetingMessage || 'Hi there 👋',
|
|
5960
5908
|
welcomeMessage: options.welcomeMessage || 'How can we help?',
|
|
5961
5909
|
enableHelp: options.enableHelp !== false,
|
|
5962
5910
|
enableChangelog: options.enableChangelog !== false,
|
|
@@ -5974,6 +5922,7 @@
|
|
|
5974
5922
|
this.messengerState = new MessengerState({
|
|
5975
5923
|
teamName: this.messengerOptions.teamName,
|
|
5976
5924
|
teamAvatars: this.messengerOptions.teamAvatars,
|
|
5925
|
+
greetingMessage: this.messengerOptions.greetingMessage,
|
|
5977
5926
|
welcomeMessage: this.messengerOptions.welcomeMessage,
|
|
5978
5927
|
enableHelp: this.messengerOptions.enableHelp,
|
|
5979
5928
|
enableChangelog: this.messengerOptions.enableChangelog,
|
|
@@ -11606,7 +11555,6 @@
|
|
|
11606
11555
|
transform: translateY(-50%);
|
|
11607
11556
|
}
|
|
11608
11557
|
|
|
11609
|
-
/* Search — back to normal style on light bg */
|
|
11610
11558
|
.messenger-help-search-wrap {
|
|
11611
11559
|
position: relative;
|
|
11612
11560
|
width: 100%;
|
|
@@ -11647,7 +11595,6 @@
|
|
|
11647
11595
|
color: var(--color-text-tertiary);
|
|
11648
11596
|
}
|
|
11649
11597
|
|
|
11650
|
-
/* Body */
|
|
11651
11598
|
.messenger-help-body {
|
|
11652
11599
|
flex: 1;
|
|
11653
11600
|
overflow-y: auto;
|
|
@@ -11662,13 +11609,11 @@
|
|
|
11662
11609
|
padding: 0;
|
|
11663
11610
|
}
|
|
11664
11611
|
|
|
11665
|
-
/* ── Collection item ─────────────────────────────── */
|
|
11666
|
-
|
|
11667
11612
|
.messenger-help-collection {
|
|
11668
11613
|
display: flex;
|
|
11669
11614
|
align-items: center;
|
|
11670
11615
|
gap: var(--spacing-3);
|
|
11671
|
-
padding: var(--spacing-
|
|
11616
|
+
padding: var(--spacing-3) var(--spacing-5);
|
|
11672
11617
|
cursor: pointer;
|
|
11673
11618
|
transition: background var(--transition-base);
|
|
11674
11619
|
border-bottom: 1px solid var(--color-border);
|
|
@@ -11678,68 +11623,63 @@
|
|
|
11678
11623
|
background: var(--color-neutral-50);
|
|
11679
11624
|
}
|
|
11680
11625
|
|
|
11681
|
-
/* Icon pill — tinted with primary colour */
|
|
11682
11626
|
.messenger-help-collection-icon {
|
|
11683
11627
|
flex-shrink: 0;
|
|
11684
|
-
width:
|
|
11685
|
-
height:
|
|
11686
|
-
border-radius: var(--radius-md);
|
|
11687
|
-
background: color-mix(in srgb, var(--color-primary) 10%, transparent);
|
|
11688
|
-
color: var(--color-primary);
|
|
11628
|
+
width: 28px;
|
|
11629
|
+
height: 28px;
|
|
11689
11630
|
display: flex;
|
|
11690
11631
|
align-items: center;
|
|
11691
11632
|
justify-content: center;
|
|
11633
|
+
color: var(--color-text-secondary);
|
|
11692
11634
|
}
|
|
11693
11635
|
|
|
11694
11636
|
.messenger-help-collection-icon svg,
|
|
11695
11637
|
.messenger-help-collection-icon iconify-icon {
|
|
11696
|
-
width:
|
|
11697
|
-
height:
|
|
11638
|
+
width: 18px;
|
|
11639
|
+
height: 18px;
|
|
11698
11640
|
display: block;
|
|
11699
11641
|
}
|
|
11700
11642
|
|
|
11701
|
-
/* Content area */
|
|
11702
11643
|
.messenger-help-collection-content {
|
|
11703
11644
|
flex: 1;
|
|
11704
11645
|
min-width: 0;
|
|
11705
11646
|
}
|
|
11706
11647
|
|
|
11707
11648
|
.messenger-help-collection-title {
|
|
11708
|
-
|
|
11709
|
-
font-
|
|
11710
|
-
font-weight: var(--font-weight-bold);
|
|
11649
|
+
font-size: var(--font-size-sm);
|
|
11650
|
+
font-weight: var(--font-weight-medium);
|
|
11711
11651
|
color: var(--color-text-primary);
|
|
11712
11652
|
line-height: var(--line-height-snug);
|
|
11653
|
+
white-space: nowrap;
|
|
11654
|
+
overflow: hidden;
|
|
11655
|
+
text-overflow: ellipsis;
|
|
11713
11656
|
}
|
|
11714
11657
|
|
|
11715
11658
|
.messenger-help-collection-desc {
|
|
11716
|
-
margin:
|
|
11717
|
-
font-size: var(--font-size-
|
|
11659
|
+
margin: 2px 0 var(--spacing-1);
|
|
11660
|
+
font-size: var(--font-size-xs);
|
|
11718
11661
|
color: var(--color-text-secondary);
|
|
11719
11662
|
line-height: var(--line-height-normal);
|
|
11720
|
-
|
|
11721
|
-
-webkit-line-clamp: 2;
|
|
11722
|
-
-webkit-box-orient: vertical;
|
|
11663
|
+
white-space: nowrap;
|
|
11723
11664
|
overflow: hidden;
|
|
11665
|
+
text-overflow: ellipsis;
|
|
11724
11666
|
}
|
|
11725
11667
|
|
|
11726
|
-
/* Meta row: author avatar + article count */
|
|
11727
11668
|
.messenger-help-collection-meta {
|
|
11728
11669
|
display: flex;
|
|
11729
11670
|
align-items: center;
|
|
11730
11671
|
gap: var(--spacing-2);
|
|
11672
|
+
margin-top: 2px;
|
|
11731
11673
|
}
|
|
11732
11674
|
|
|
11733
|
-
/* Avatar — shared base */
|
|
11734
11675
|
.messenger-help-collection-avatar {
|
|
11735
|
-
width:
|
|
11736
|
-
height:
|
|
11676
|
+
width: 16px;
|
|
11677
|
+
height: 16px;
|
|
11737
11678
|
border-radius: var(--radius-full);
|
|
11738
11679
|
flex-shrink: 0;
|
|
11739
11680
|
object-fit: cover;
|
|
11740
11681
|
}
|
|
11741
11682
|
|
|
11742
|
-
/* Initials fallback */
|
|
11743
11683
|
.messenger-help-collection-avatar--initials {
|
|
11744
11684
|
display: inline-flex;
|
|
11745
11685
|
align-items: center;
|
|
@@ -11750,18 +11690,10 @@
|
|
|
11750
11690
|
}
|
|
11751
11691
|
|
|
11752
11692
|
.messenger-help-collection-count {
|
|
11753
|
-
font-size: var(--font-size-
|
|
11754
|
-
color: var(--color-text-tertiary);
|
|
11755
|
-
}
|
|
11756
|
-
|
|
11757
|
-
.messenger-help-collection-arrow {
|
|
11693
|
+
font-size: var(--font-size-xs);
|
|
11758
11694
|
color: var(--color-text-tertiary);
|
|
11759
|
-
flex-shrink: 0;
|
|
11760
|
-
margin-left: auto;
|
|
11761
11695
|
}
|
|
11762
11696
|
|
|
11763
|
-
/* ── Footer (kept for optional use) ─────────────── */
|
|
11764
|
-
|
|
11765
11697
|
.messenger-help-footer {
|
|
11766
11698
|
padding: var(--spacing-4) var(--spacing-5);
|
|
11767
11699
|
border-top: 1px solid var(--color-border);
|