@product7/product7-js 0.1.7 → 0.1.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.
@@ -4454,7 +4454,14 @@
4454
4454
  margin-left: 0;
4455
4455
  }
4456
4456
 
4457
+ .messenger-mobile-close-btn {
4458
+ display: none;
4459
+ }
4460
+
4457
4461
  @media (max-width: 480px) {
4462
+ .messenger-mobile-close-btn {
4463
+ display: flex;
4464
+ }
4458
4465
  .messenger-panel {
4459
4466
  width: 100%;
4460
4467
  height: 100%;
@@ -5481,42 +5488,35 @@
5481
5488
  .messenger-changelog-list {
5482
5489
  display: flex;
5483
5490
  flex-direction: column;
5491
+ gap: var(--spacing-3);
5492
+ padding: var(--spacing-4) var(--spacing-5);
5484
5493
  }
5485
5494
 
5486
5495
  .messenger-changelog-card {
5487
5496
  display: flex;
5488
- align-items: center;
5489
- gap: var(--spacing-3);
5490
- padding: var(--spacing-4) var(--spacing-5);
5491
- border-bottom: 1px solid var(--msg-border);
5497
+ flex-direction: column;
5498
+ border: 1px solid var(--msg-border);
5499
+ border-radius: 10px;
5500
+ overflow: hidden;
5492
5501
  cursor: pointer;
5493
- transition: background var(--transition-base);
5494
- }
5495
-
5496
- .messenger-changelog-card:last-child {
5497
- border-bottom: none;
5502
+ transition: box-shadow var(--transition-base), transform var(--transition-base);
5498
5503
  }
5499
5504
 
5500
5505
  .messenger-changelog-card:hover {
5501
- background: var(--msg-bg-hover);
5502
- }
5503
-
5504
- .messenger-changelog-card:hover .messenger-changelog-arrow {
5505
- color: var(--color-primary);
5506
- transform: translateX(3px);
5506
+ box-shadow: var(--shadow-md);
5507
+ transform: translateY(-1px);
5507
5508
  }
5508
5509
 
5509
5510
  .messenger-changelog-card:active {
5510
- transform: translateY(1px);
5511
+ transform: translateY(0);
5511
5512
  transition-duration: 100ms;
5512
5513
  }
5513
5514
 
5514
5515
  .messenger-changelog-content {
5515
- flex: 1;
5516
- min-width: 0;
5517
5516
  display: flex;
5518
5517
  flex-direction: column;
5519
- gap: 3px;
5518
+ gap: var(--spacing-1);
5519
+ padding: var(--spacing-3) var(--spacing-4);
5520
5520
  }
5521
5521
 
5522
5522
  .messenger-changelog-meta {
@@ -5554,9 +5554,6 @@
5554
5554
  font-weight: var(--font-weight-semibold);
5555
5555
  color: var(--msg-text);
5556
5556
  line-height: var(--line-height-snug);
5557
- white-space: nowrap;
5558
- overflow: hidden;
5559
- text-overflow: ellipsis;
5560
5557
  }
5561
5558
 
5562
5559
  .messenger-changelog-description {
@@ -5571,26 +5568,17 @@
5571
5568
  }
5572
5569
 
5573
5570
  .messenger-changelog-thumb {
5574
- width: 64px;
5575
- height: 64px;
5576
- flex-shrink: 0;
5577
- border-radius: 8px;
5571
+ width: 100%;
5578
5572
  overflow: hidden;
5579
- border: 1px solid var(--msg-border);
5573
+ border-bottom: 1px solid var(--msg-border);
5580
5574
  }
5581
5575
 
5582
5576
  .messenger-changelog-thumb img {
5583
5577
  width: 100%;
5584
- height: 100%;
5578
+ height: 180px;
5585
5579
  display: block;
5586
5580
  object-fit: cover;
5587
5581
  }
5588
-
5589
- .messenger-changelog-arrow {
5590
- flex-shrink: 0;
5591
- color: var(--msg-text-tertiary);
5592
- transition: all var(--transition-base);
5593
- }
5594
5582
  `;
5595
5583
 
5596
5584
  const messengerStyles =
@@ -5969,6 +5957,32 @@
5969
5957
  RATING SCALE (generic)
5970
5958
  ======================================== */
5971
5959
 
5960
+ .feedback-survey-stars {
5961
+ display: flex;
5962
+ gap: var(--spacing-2);
5963
+ justify-content: center;
5964
+ }
5965
+
5966
+ .feedback-survey-star-btn {
5967
+ background: none;
5968
+ border: none;
5969
+ cursor: pointer;
5970
+ font-size: 2rem;
5971
+ color: var(--color-neutral-300);
5972
+ padding: 0 2px;
5973
+ line-height: 1;
5974
+ transition: color var(--transition-fast), transform var(--transition-fast);
5975
+ }
5976
+
5977
+ .feedback-survey-star-btn.filled,
5978
+ .feedback-survey-star-btn.hovered {
5979
+ color: #f59e0b;
5980
+ }
5981
+
5982
+ .feedback-survey-star-btn:active {
5983
+ transform: scale(0.9);
5984
+ }
5985
+
5972
5986
  .feedback-survey-rating-scale {
5973
5987
  display: flex;
5974
5988
  gap: 0;
@@ -9026,8 +9040,8 @@
9026
9040
  <div class="messenger-changelog-header">
9027
9041
  <div class="messenger-changelog-header-top">
9028
9042
  <h2>Latest Updates</h2>
9029
- <button class="sdk-close-btn messenger-changelog-close-btn" aria-label="Close">
9030
- <iconify-icon icon="ph:x-duotone" width="18" height="18"></iconify-icon>
9043
+ <button class="sdk-close-btn messenger-changelog-close-btn messenger-mobile-close-btn" aria-label="Close">
9044
+ <iconify-icon icon="ph:x" width="18" height="18"></iconify-icon>
9031
9045
  </button>
9032
9046
  </div>
9033
9047
  </div>
@@ -9067,30 +9081,13 @@
9067
9081
  }
9068
9082
 
9069
9083
  _renderChangelogCard(item) {
9070
- const dateStr = this._formatDate(item.publishedAt || item.date);
9071
- const labelsHtml =
9072
- item.labels && item.labels.length > 0
9073
- ? item.labels
9074
- .map((label) => {
9075
- const bg = label.color || '#E5E7EB';
9076
- const color = this._getContrastColor(bg);
9077
- return `<span class="messenger-changelog-tag" style="background:${bg};color:${color};">${label.name}</span>`;
9078
- })
9079
- .join('')
9080
- : '';
9081
-
9082
9084
  return `
9083
9085
  <div class="messenger-changelog-card" data-changelog-id="${item.id}">
9086
+ ${item.coverImage ? `<div class="messenger-changelog-thumb"><img src="${item.coverImage}" alt="${item.title}" onerror="this.parentElement.style.display='none';" /></div>` : ''}
9084
9087
  <div class="messenger-changelog-content">
9085
- <div class="messenger-changelog-meta">
9086
- ${dateStr ? `<span class="messenger-changelog-date">${dateStr}</span>` : ''}
9087
- ${labelsHtml}
9088
- </div>
9089
9088
  <h3 class="messenger-changelog-title">${item.title}</h3>
9090
9089
  ${item.description ? `<p class="messenger-changelog-description">${this._stripHtml(item.description)}</p>` : ''}
9091
9090
  </div>
9092
- ${item.coverImage ? `<div class="messenger-changelog-thumb"><img src="${item.coverImage}" alt="${item.title}" onerror="this.style.display='none';" /></div>` : ''}
9093
- <iconify-icon icon="ph:caret-right" class="messenger-changelog-arrow" width="16" height="16"></iconify-icon>
9094
9091
  </div>
9095
9092
  `;
9096
9093
  }
@@ -9133,11 +9130,12 @@
9133
9130
  }
9134
9131
 
9135
9132
  _attachEvents() {
9136
- this.element
9137
- .querySelector('.messenger-changelog-close-btn')
9138
- .addEventListener('click', () => {
9133
+ const mobileCloseBtn = this.element.querySelector('.messenger-changelog-close-btn');
9134
+ if (mobileCloseBtn) {
9135
+ mobileCloseBtn.addEventListener('click', () => {
9139
9136
  this.state.setOpen(false);
9140
9137
  });
9138
+ }
9141
9139
 
9142
9140
  this._attachChangelogEvents();
9143
9141
  }
@@ -9259,11 +9257,8 @@
9259
9257
  <span class="messenger-chat-subtitle">The team can also help</span>
9260
9258
  </div>
9261
9259
  <div class="messenger-chat-header-actions">
9262
- <button class="sdk-btn-icon" aria-label="More options">
9263
- <iconify-icon icon="ph:dots-three-outline-duotone" width="20" height="20"></iconify-icon>
9264
- </button>
9265
- <button class="sdk-close-btn" aria-label="Close">
9266
- <iconify-icon icon="ph:x-duotone" width="18" height="18"></iconify-icon>
9260
+ <button class="sdk-btn-icon sdk-close-btn messenger-mobile-close-btn" aria-label="Close">
9261
+ <iconify-icon icon="ph:x" width="18" height="18"></iconify-icon>
9267
9262
  </button>
9268
9263
  </div>
9269
9264
  </div>
@@ -9540,11 +9535,12 @@
9540
9535
  this.state.setView('messages');
9541
9536
  });
9542
9537
 
9543
- this.element
9544
- .querySelector('.sdk-close-btn')
9545
- .addEventListener('click', () => {
9538
+ const mobileCloseBtn = this.element.querySelector('.messenger-mobile-close-btn');
9539
+ if (mobileCloseBtn) {
9540
+ mobileCloseBtn.addEventListener('click', () => {
9546
9541
  this.state.setOpen(false);
9547
9542
  });
9543
+ }
9548
9544
 
9549
9545
  const input = this.element.querySelector('.messenger-compose-input');
9550
9546
  const sendBtn = this.element.querySelector('.messenger-compose-send');
@@ -9924,8 +9920,8 @@
9924
9920
  this.element.innerHTML = `
9925
9921
  <div class="messenger-conversations-header">
9926
9922
  <h2>Messages</h2>
9927
- <button class="sdk-close-btn" aria-label="Close">
9928
- <iconify-icon icon="ph:x-duotone" width="18" height="18"></iconify-icon>
9923
+ <button class="sdk-close-btn messenger-mobile-close-btn" aria-label="Close">
9924
+ <iconify-icon icon="ph:x" width="18" height="18"></iconify-icon>
9929
9925
  </button>
9930
9926
  </div>
9931
9927
 
@@ -10130,8 +10126,8 @@
10130
10126
  <div class="messenger-help-header">
10131
10127
  <div class="messenger-help-header-top">
10132
10128
  <h2>Help</h2>
10133
- <button class="sdk-close-btn messenger-help-close-btn" aria-label="Close">
10134
- <iconify-icon icon="ph:x-duotone" width="18" height="18"></iconify-icon>
10129
+ <button class="sdk-close-btn messenger-help-close-btn messenger-mobile-close-btn" aria-label="Close">
10130
+ <iconify-icon icon="ph:x" width="18" height="18"></iconify-icon>
10135
10131
  </button>
10136
10132
  </div>
10137
10133
  <div class="messenger-help-search-wrap">
@@ -10298,11 +10294,12 @@
10298
10294
  }
10299
10295
 
10300
10296
  _attachEvents() {
10301
- this.element
10302
- .querySelector('.messenger-help-close-btn')
10303
- .addEventListener('click', () => {
10297
+ const mobileCloseBtn = this.element.querySelector('.messenger-help-close-btn');
10298
+ if (mobileCloseBtn) {
10299
+ mobileCloseBtn.addEventListener('click', () => {
10304
10300
  this.state.setOpen(false);
10305
10301
  });
10302
+ }
10306
10303
 
10307
10304
  const searchInput = this.element.querySelector(
10308
10305
  '.messenger-help-search-input'
@@ -12142,14 +12139,16 @@
12142
12139
  const topSurveyType = this.surveyOptions.surveyType;
12143
12140
  const configType = config.survey_type;
12144
12141
  let ratingType;
12145
- if (topSurveyType === 'ces') {
12146
- ratingType = 'ces';
12147
- } else if (topSurveyType === 'nps') {
12142
+ if (topSurveyType === 'nps') {
12148
12143
  ratingType = 'nps';
12149
- } else if (topSurveyType === 'csat' && !configType) {
12144
+ } else if (configType) {
12145
+ ratingType = configType;
12146
+ } else if (topSurveyType === 'ces') {
12147
+ ratingType = 'ces';
12148
+ } else if (topSurveyType === 'csat') {
12150
12149
  ratingType = 'emoji';
12151
12150
  } else {
12152
- ratingType = configType || topSurveyType || 'csat';
12151
+ ratingType = topSurveyType || 'csat';
12153
12152
  }
12154
12153
  const pageAnswer = this.surveyState.pageAnswers[pageId] || {};
12155
12154
  const currentRating = pageAnswer.rating;
@@ -12241,6 +12240,22 @@
12241
12240
  `;
12242
12241
  }
12243
12242
 
12243
+ if (ratingType === 'star') {
12244
+ const starScale = Number.isFinite(scale) && scale >= 2 ? scale : 5;
12245
+ return `
12246
+ <div class="feedback-survey-stars" data-page-id="${pageId}">
12247
+ ${[...Array(starScale).keys()]
12248
+ .map((i) => {
12249
+ const score = i + 1;
12250
+ const filled = currentRating >= score ? ' filled' : '';
12251
+ return `<button class="feedback-survey-page-rating-btn feedback-survey-star-btn${filled}" data-page-id="${pageId}" data-score="${score}">★</button>`;
12252
+ })
12253
+ .join('')}
12254
+ </div>
12255
+ ${labels}
12256
+ `;
12257
+ }
12258
+
12244
12259
  return `
12245
12260
  <div class="feedback-survey-rating-scale" data-page-id="${pageId}">
12246
12261
  ${[...Array(scale).keys()]
@@ -12496,6 +12511,8 @@
12496
12511
  const pageId = page.id || `page_${this.surveyState.currentPageIndex}`;
12497
12512
 
12498
12513
  if (page.type === 'rating') {
12514
+ const isStarRating = !!this.surveyElement.querySelector('.feedback-survey-star-btn');
12515
+
12499
12516
  this.surveyElement
12500
12517
  .querySelectorAll('.feedback-survey-page-rating-btn')
12501
12518
  .forEach((btn) => {
@@ -12504,12 +12521,44 @@
12504
12521
  if (Number.isNaN(score)) return;
12505
12522
  this._setPageAnswer(pageId, { rating: score });
12506
12523
 
12507
- this.surveyElement
12508
- .querySelectorAll('.feedback-survey-page-rating-btn')
12509
- .forEach((item) => item.classList.remove('selected'));
12510
- btn.classList.add('selected');
12524
+ if (isStarRating) {
12525
+ this.surveyElement
12526
+ .querySelectorAll('.feedback-survey-star-btn')
12527
+ .forEach((star) => {
12528
+ const starScore = parseInt(star.dataset.score);
12529
+ star.classList.toggle('filled', starScore <= score);
12530
+ });
12531
+ } else {
12532
+ this.surveyElement
12533
+ .querySelectorAll('.feedback-survey-page-rating-btn')
12534
+ .forEach((item) => item.classList.remove('selected'));
12535
+ btn.classList.add('selected');
12536
+ }
12511
12537
  });
12538
+
12539
+ if (isStarRating) {
12540
+ btn.addEventListener('mouseenter', () => {
12541
+ const hoverScore = parseInt(btn.dataset.score);
12542
+ this.surveyElement
12543
+ .querySelectorAll('.feedback-survey-star-btn')
12544
+ .forEach((star) => {
12545
+ const starScore = parseInt(star.dataset.score);
12546
+ star.classList.toggle('hovered', starScore <= hoverScore);
12547
+ });
12548
+ });
12549
+ }
12512
12550
  });
12551
+
12552
+ if (isStarRating) {
12553
+ const container = this.surveyElement.querySelector('.feedback-survey-stars');
12554
+ if (container) {
12555
+ container.addEventListener('mouseleave', () => {
12556
+ this.surveyElement
12557
+ .querySelectorAll('.feedback-survey-star-btn')
12558
+ .forEach((star) => star.classList.remove('hovered'));
12559
+ });
12560
+ }
12561
+ }
12513
12562
  }
12514
12563
 
12515
12564
  if (page.type === 'multiple_choice') {