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