@product7/product7-js 0.1.8 → 0.2.0

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.
@@ -5327,8 +5327,8 @@
5327
5327
 
5328
5328
  .messenger-help-collection-icon {
5329
5329
  flex-shrink: 0;
5330
- width: 2.75rem;
5331
- height: 2.75rem;
5330
+ width: 2.25rem;
5331
+ height: 2.25rem;
5332
5332
  display: flex;
5333
5333
  align-items: center;
5334
5334
  justify-content: center;
@@ -5336,14 +5336,14 @@
5336
5336
  }
5337
5337
 
5338
5338
  .messenger-help-collection-icon svg {
5339
- width: 2rem;
5340
- height: 2rem;
5339
+ width: 1.5rem;
5340
+ height: 1.5rem;
5341
5341
  display: block;
5342
5342
  flex-shrink: 0;
5343
5343
  }
5344
5344
 
5345
5345
  .messenger-help-collection-icon iconify-icon {
5346
- font-size: 2rem;
5346
+ font-size: 1.5rem;
5347
5347
  width: 1em;
5348
5348
  height: 1em;
5349
5349
  display: block;
@@ -5957,6 +5957,32 @@
5957
5957
  RATING SCALE (generic)
5958
5958
  ======================================== */
5959
5959
 
5960
+ .feedback-survey-stars {
5961
+ display: flex;
5962
+ gap: var(--spacing-4);
5963
+ justify-content: center;
5964
+ }
5965
+
5966
+ .feedback-survey-star-btn {
5967
+ background: none;
5968
+ border: none;
5969
+ cursor: pointer;
5970
+ font-size: 2.75rem;
5971
+ color: var(--color-neutral-300);
5972
+ padding: 0;
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
+
5960
5986
  .feedback-survey-rating-scale {
5961
5987
  display: flex;
5962
5988
  gap: 0;
@@ -9894,8 +9920,8 @@
9894
9920
  this.element.innerHTML = `
9895
9921
  <div class="messenger-conversations-header">
9896
9922
  <h2>Messages</h2>
9897
- <button class="sdk-close-btn" aria-label="Close">
9898
- <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>
9899
9925
  </button>
9900
9926
  </div>
9901
9927
 
@@ -12113,14 +12139,16 @@
12113
12139
  const topSurveyType = this.surveyOptions.surveyType;
12114
12140
  const configType = config.survey_type;
12115
12141
  let ratingType;
12116
- if (topSurveyType === 'ces') {
12117
- ratingType = 'ces';
12118
- } else if (topSurveyType === 'nps') {
12142
+ if (topSurveyType === 'nps') {
12119
12143
  ratingType = 'nps';
12120
- } 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') {
12121
12149
  ratingType = 'emoji';
12122
12150
  } else {
12123
- ratingType = configType || topSurveyType || 'csat';
12151
+ ratingType = topSurveyType || 'csat';
12124
12152
  }
12125
12153
  const pageAnswer = this.surveyState.pageAnswers[pageId] || {};
12126
12154
  const currentRating = pageAnswer.rating;
@@ -12212,6 +12240,22 @@
12212
12240
  `;
12213
12241
  }
12214
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
+
12215
12259
  return `
12216
12260
  <div class="feedback-survey-rating-scale" data-page-id="${pageId}">
12217
12261
  ${[...Array(scale).keys()]
@@ -12467,6 +12511,8 @@
12467
12511
  const pageId = page.id || `page_${this.surveyState.currentPageIndex}`;
12468
12512
 
12469
12513
  if (page.type === 'rating') {
12514
+ const isStarRating = !!this.surveyElement.querySelector('.feedback-survey-star-btn');
12515
+
12470
12516
  this.surveyElement
12471
12517
  .querySelectorAll('.feedback-survey-page-rating-btn')
12472
12518
  .forEach((btn) => {
@@ -12475,12 +12521,44 @@
12475
12521
  if (Number.isNaN(score)) return;
12476
12522
  this._setPageAnswer(pageId, { rating: score });
12477
12523
 
12478
- this.surveyElement
12479
- .querySelectorAll('.feedback-survey-page-rating-btn')
12480
- .forEach((item) => item.classList.remove('selected'));
12481
- 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
+ }
12482
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
+ }
12483
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
+ }
12484
12562
  }
12485
12563
 
12486
12564
  if (page.type === 'multiple_choice') {