@product7/feedback-sdk 1.4.4 → 1.4.5

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 CHANGED
@@ -86,13 +86,10 @@ widget.mount();
86
86
 
87
87
  ## Documentation
88
88
 
89
- - [Installation Guide](docs/installation.md)
90
- - [Widget Types](docs/widgets.md)
91
- - [Configuration](docs/configuration.md)
92
- - [API Reference](docs/api.md)
93
- - [Theming Guide](docs/theming.md)
94
- - [Examples](docs/examples.md)
95
- - [Migration Guide](docs/migration.md)
89
+ - [Installation Guide](src/docs/installation.md)
90
+ - [Framework Integrations](src/docs/framework-integrations.md)
91
+ - [API Reference](src/docs/api.md)
92
+ - [Examples](src/docs/example.md)
96
93
 
97
94
  ---
98
95
 
package/dist/README.md CHANGED
@@ -86,13 +86,10 @@ widget.mount();
86
86
 
87
87
  ## Documentation
88
88
 
89
- - [Installation Guide](docs/installation.md)
90
- - [Widget Types](docs/widgets.md)
91
- - [Configuration](docs/configuration.md)
92
- - [API Reference](docs/api.md)
93
- - [Theming Guide](docs/theming.md)
94
- - [Examples](docs/examples.md)
95
- - [Migration Guide](docs/migration.md)
89
+ - [Installation Guide](src/docs/installation.md)
90
+ - [Framework Integrations](src/docs/framework-integrations.md)
91
+ - [API Reference](src/docs/api.md)
92
+ - [Examples](src/docs/example.md)
96
93
 
97
94
  ---
98
95
 
@@ -2370,18 +2370,14 @@
2370
2370
 
2371
2371
  this.modalElement
2372
2372
  .querySelector('.changelog-modal-container')
2373
- .addEventListener('click', (e) => {
2374
- e.stopPropagation();
2375
- });
2373
+ .addEventListener('click', (e) => e.stopPropagation());
2376
2374
 
2377
2375
  this.modalElement
2378
2376
  .querySelector('.changelog-modal-close')
2379
2377
  .addEventListener('click', () => this.closeModal());
2380
2378
 
2381
2379
  this._escapeHandler = (e) => {
2382
- if (e.key === 'Escape') {
2383
- this.closeModal();
2384
- }
2380
+ if (e.key === 'Escape') this.closeModal();
2385
2381
  };
2386
2382
  document.addEventListener('keydown', this._escapeHandler);
2387
2383
  }
@@ -2459,9 +2455,7 @@
2459
2455
  }
2460
2456
 
2461
2457
  setTimeout(() => {
2462
- if (container.parentNode) {
2463
- container.parentNode.removeChild(container);
2464
- }
2458
+ if (container.parentNode) container.parentNode.removeChild(container);
2465
2459
  }, 2500);
2466
2460
  }
2467
2461
 
@@ -2524,18 +2518,14 @@
2524
2518
 
2525
2519
  this.listModalElement
2526
2520
  .querySelector('.changelog-list-modal-container')
2527
- .addEventListener('click', (e) => {
2528
- e.stopPropagation();
2529
- });
2521
+ .addEventListener('click', (e) => e.stopPropagation());
2530
2522
 
2531
2523
  this.listModalElement
2532
2524
  .querySelector('.changelog-list-modal-close')
2533
2525
  .addEventListener('click', () => this.closeSidebar());
2534
2526
 
2535
2527
  this._listModalEscapeHandler = (e) => {
2536
- if (e.key === 'Escape') {
2537
- this.closeSidebar();
2538
- }
2528
+ if (e.key === 'Escape') this.closeSidebar();
2539
2529
  };
2540
2530
  document.addEventListener('keydown', this._listModalEscapeHandler);
2541
2531
  }
@@ -2545,9 +2535,7 @@
2545
2535
  '.changelog-list-modal-body'
2546
2536
  );
2547
2537
 
2548
- if (this.isLoading) {
2549
- return;
2550
- }
2538
+ if (this.isLoading) return;
2551
2539
 
2552
2540
  if (this.changelogs.length === 0) {
2553
2541
  body.innerHTML = `
@@ -2570,8 +2558,7 @@
2570
2558
 
2571
2559
  body.querySelectorAll('.changelog-list-item').forEach((item, index) => {
2572
2560
  item.addEventListener('click', () => {
2573
- const changelog = this.changelogs[index];
2574
- this._handleViewUpdate(changelog);
2561
+ this._handleViewUpdate(this.changelogs[index]);
2575
2562
  });
2576
2563
  });
2577
2564
  }
@@ -2582,6 +2569,10 @@
2582
2569
  const date = changelog.published_at
2583
2570
  ? this._formatDate(changelog.published_at)
2584
2571
  : '';
2572
+ const description = this._truncateDescription(
2573
+ changelog.excerpt || changelog.description,
2574
+ 120
2575
+ );
2585
2576
 
2586
2577
  return `
2587
2578
  <div class="changelog-list-item" data-index="${index}">
@@ -2613,13 +2604,7 @@
2613
2604
  : ''
2614
2605
  }
2615
2606
  <h3 class="changelog-list-item-title">${changelog.title}</h3>
2616
- ${
2617
- changelog.excerpt || changelog.description
2618
- ? `
2619
- <p class="changelog-list-item-description">${changelog.excerpt || changelog.description}</p>
2620
- `
2621
- : ''
2622
- }
2607
+ ${description ? `<p class="changelog-list-item-description">${description}</p>` : ''}
2623
2608
  </div>
2624
2609
  </div>
2625
2610
  </div>
@@ -2646,9 +2631,7 @@
2646
2631
  _renderCurrentChangelog() {
2647
2632
  const content = this.modalElement.querySelector('.changelog-modal-content');
2648
2633
 
2649
- if (this.isLoading) {
2650
- return;
2651
- }
2634
+ if (this.isLoading) return;
2652
2635
 
2653
2636
  if (this.changelogs.length === 0) {
2654
2637
  content.innerHTML = `
@@ -2667,6 +2650,10 @@
2667
2650
  const hasImage = changelog.cover_image || changelog.image;
2668
2651
  const imageUrl = changelog.cover_image || changelog.image;
2669
2652
  const hasMultiple = this.changelogs.length > 1;
2653
+ const description = this._truncateDescription(
2654
+ changelog.excerpt || changelog.description,
2655
+ 160
2656
+ );
2670
2657
 
2671
2658
  content.innerHTML = `
2672
2659
  <div class="changelog-popup-item">
@@ -2681,13 +2668,7 @@
2681
2668
  }
2682
2669
  <div class="changelog-popup-body">
2683
2670
  <h2 class="changelog-popup-title">${changelog.title}</h2>
2684
- ${
2685
- changelog.excerpt || changelog.description
2686
- ? `
2687
- <p class="changelog-popup-description">${changelog.excerpt || changelog.description}</p>
2688
- `
2689
- : ''
2690
- }
2671
+ ${description ? `<p class="changelog-popup-description">${description}</p>` : ''}
2691
2672
  <button class="changelog-popup-btn" type="button">
2692
2673
  ${this.options.viewButtonText || 'View Update'}
2693
2674
  </button>
@@ -2734,8 +2715,7 @@
2734
2715
  if (hasMultiple) {
2735
2716
  content.querySelectorAll('.changelog-dot').forEach((dot) => {
2736
2717
  dot.addEventListener('click', (e) => {
2737
- const index = parseInt(e.target.dataset.index, 10);
2738
- this.currentIndex = index;
2718
+ this.currentIndex = parseInt(e.target.dataset.index, 10);
2739
2719
  this._renderCurrentChangelog();
2740
2720
  });
2741
2721
  });
@@ -2745,10 +2725,19 @@
2745
2725
  _handleViewUpdate(changelog) {
2746
2726
  this.sdk.eventBus.emit('changelog:view', { changelog });
2747
2727
 
2748
- if (changelog.url || changelog.slug) {
2749
- const url =
2750
- changelog.url ||
2751
- `${this.options.changelogBaseUrl || ''}/${changelog.slug}`;
2728
+ const changelogBase = (this.options.changelogBaseUrl || '').replace(
2729
+ /\/$/,
2730
+ ''
2731
+ );
2732
+ const url =
2733
+ changelog.url ||
2734
+ (changelog.slug && changelogBase
2735
+ ? `${changelogBase}/${changelog.slug}`
2736
+ : null) ||
2737
+ changelogBase ||
2738
+ null;
2739
+
2740
+ if (url) {
2752
2741
  if (this.options.openInNewTab !== false) {
2753
2742
  window.open(url, '_blank', 'noopener,noreferrer');
2754
2743
  } else {
@@ -2761,10 +2750,26 @@
2761
2750
  }
2762
2751
  }
2763
2752
 
2753
+ _stripHtml(html) {
2754
+ const tmp = document.createElement('div');
2755
+ tmp.innerHTML = html;
2756
+ return (tmp.textContent || tmp.innerText || '').trim();
2757
+ }
2758
+
2759
+ _truncateDescription(html, maxLength = 120) {
2760
+ if (!html) return '';
2761
+ const plain = this._stripHtml(html);
2762
+ if (plain.length <= maxLength) return plain;
2763
+ return plain.substring(0, maxLength).trimEnd() + '...';
2764
+ }
2765
+
2764
2766
  _formatDate(dateString) {
2765
2767
  const date = new Date(dateString);
2766
- const options = { year: 'numeric', month: 'short', day: 'numeric' };
2767
- return date.toLocaleDateString('en-US', options);
2768
+ return date.toLocaleDateString('en-US', {
2769
+ year: 'numeric',
2770
+ month: 'short',
2771
+ day: 'numeric',
2772
+ });
2768
2773
  }
2769
2774
 
2770
2775
  _getContrastColor(hexColor) {
@@ -2778,16 +2783,12 @@
2778
2783
 
2779
2784
  hideBadge() {
2780
2785
  const badge = this.element?.querySelector('.changelog-badge');
2781
- if (badge) {
2782
- badge.style.display = 'none';
2783
- }
2786
+ if (badge) badge.style.display = 'none';
2784
2787
  }
2785
2788
 
2786
2789
  showBadge() {
2787
2790
  const badge = this.element?.querySelector('.changelog-badge');
2788
- if (badge) {
2789
- badge.style.display = 'block';
2790
- }
2791
+ if (badge) badge.style.display = 'block';
2791
2792
  }
2792
2793
 
2793
2794
  nextChangelog() {
@@ -6234,16 +6235,20 @@
6234
6235
  const response = await this.apiService.getHelpCollections();
6235
6236
  if (response.success && response.data) {
6236
6237
  const collections = response.data.collections || response.data;
6237
- const helpBase = (this.messengerOptions.helpUrl || '').replace(/\/$/, '');
6238
+ const helpBase = (this.messengerOptions.helpUrl || '').replace(
6239
+ /\/$/,
6240
+ ''
6241
+ );
6238
6242
 
6239
6243
  return collections.map((collection) => ({
6240
6244
  id: collection.id,
6241
6245
  title: collection.title,
6242
6246
  description: collection.description || '',
6243
6247
  articleCount: collection.article_count || 0,
6244
- url: collection.url_slug && helpBase
6245
- ? `${helpBase}/collections/${collection.url_slug}`
6246
- : helpBase || null,
6248
+ url:
6249
+ collection.url_slug && helpBase
6250
+ ? `${helpBase}/collections/${collection.url_slug}`
6251
+ : helpBase || null,
6247
6252
  }));
6248
6253
  }
6249
6254
  return [];
@@ -6456,7 +6461,9 @@
6456
6461
 
6457
6462
  if (response.success && response.data) {
6458
6463
  const changelogs = Array.isArray(response.data) ? response.data : [];
6459
- const changelogBase = (this.messengerOptions.changelogUrl || '').replace(/\/$/, '');
6464
+ const changelogBase = (
6465
+ this.messengerOptions.changelogUrl || ''
6466
+ ).replace(/\/$/, '');
6460
6467
 
6461
6468
  const mappedItems = changelogs.map((item) => ({
6462
6469
  id: item.id,
@@ -6465,9 +6472,10 @@
6465
6472
  tags: item.labels ? item.labels.map((label) => label.name) : [],
6466
6473
  coverImage: item.cover_image || null,
6467
6474
  publishedAt: item.published_at,
6468
- url: item.slug && changelogBase
6469
- ? `${changelogBase}/${item.slug}`
6470
- : changelogBase || null,
6475
+ url:
6476
+ item.slug && changelogBase
6477
+ ? `${changelogBase}/${item.slug}`
6478
+ : changelogBase || null,
6471
6479
  }));
6472
6480
 
6473
6481
  return {