@product7/feedback-sdk 1.7.4 → 1.7.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@product7/feedback-sdk",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "JavaScript SDK for integrating Product7 feedback widgets into any website",
5
5
  "main": "dist/feedback-sdk.js",
6
6
  "module": "src/index.js",
@@ -33,6 +33,7 @@ export const surveyStyles = `
33
33
  min-width: 320px;
34
34
  max-width: 400px;
35
35
  font-family: inherit;
36
+ overflow: hidden;
36
37
  }
37
38
 
38
39
  .feedback-survey-theme-dark {
@@ -250,11 +251,16 @@ export const surveyStyles = `
250
251
  }
251
252
 
252
253
  .feedback-survey-csat-btn:hover {
253
- transform: scale(1.1);
254
+ transform: scale(1.15);
254
255
  }
255
256
 
256
257
  .feedback-survey-csat-btn.selected {
257
- transform: scale(1.2);
258
+ transform: scale(1.5);
259
+ }
260
+
261
+ .feedback-survey-csat:has(.selected) .feedback-survey-csat-btn:not(.selected) {
262
+ transform: scale(0.8);
263
+ opacity: 0.35;
258
264
  }
259
265
 
260
266
  /* ========================================
@@ -533,7 +539,9 @@ export const surveyStyles = `
533
539
  SUBMIT & FEEDBACK
534
540
  ======================================== */
535
541
 
536
- .feedback-survey-submit {
542
+ .feedback-survey-submit,
543
+ .feedback-survey-link-btn {
544
+ display: block;
537
545
  width: 100%;
538
546
  padding: var(--spacing-3);
539
547
  background: var(--color-primary);
@@ -544,27 +552,49 @@ export const surveyStyles = `
544
552
  font-weight: var(--font-weight-medium);
545
553
  cursor: pointer;
546
554
  font-family: inherit;
555
+ text-align: center;
556
+ text-decoration: none;
547
557
  transition: all var(--transition-base);
548
558
  }
549
559
 
550
- .feedback-survey-submit:hover {
560
+ .feedback-survey-submit:hover,
561
+ .feedback-survey-link-btn:hover {
551
562
  background: var(--color-primary-hover);
552
563
  border-color: var(--color-primary-hover);
564
+ color: var(--color-white);
565
+ text-decoration: none;
553
566
  }
554
567
 
555
568
  .feedback-survey-error {
556
- color: var(--color-error);
569
+ position: absolute;
570
+ top: 0;
571
+ left: 0;
572
+ right: 0;
573
+ background: #FF9900;
574
+ color: #000;
557
575
  font-size: var(--font-size-sm);
558
- margin-top: var(--spacing-2);
559
- text-align: center;
576
+ font-weight: var(--font-weight-medium);
577
+ padding: 10px 14px;
578
+ display: flex;
579
+ align-items: center;
580
+ gap: 8px;
581
+ z-index: 2;
582
+ }
583
+
584
+ .feedback-survey-error svg {
585
+ width: 16px;
586
+ height: 16px;
587
+ flex-shrink: 0;
560
588
  }
561
589
 
562
- .feedback-survey-success {
590
+ /* ========================================
591
+ NOTIFICATION TOASTS
592
+ ======================================== */
593
+
594
+ .feedback-sdk-notification {
563
595
  position: fixed;
564
596
  top: var(--spacing-6);
565
597
  right: var(--spacing-6);
566
- background: var(--color-success);
567
- color: var(--color-white);
568
598
  padding: var(--spacing-3) var(--spacing-5);
569
599
  border-radius: var(--radius-xl);
570
600
  font-size: var(--font-size-sm);
@@ -572,14 +602,38 @@ export const surveyStyles = `
572
602
  z-index: var(--z-notification);
573
603
  box-shadow: var(--shadow-lg);
574
604
  font-family: inherit;
605
+ color: #fff;
575
606
  }
576
607
 
577
- .feedback-survey-success > div {
608
+ .feedback-sdk-notification > div {
578
609
  display: flex;
579
610
  align-items: center;
580
611
  gap: var(--spacing-2);
581
612
  }
582
613
 
614
+ .feedback-sdk-notification svg {
615
+ width: 18px;
616
+ height: 18px;
617
+ flex-shrink: 0;
618
+ }
619
+
620
+ .feedback-sdk-notification-success {
621
+ background: #037F0C;
622
+ }
623
+
624
+ .feedback-sdk-notification-error {
625
+ background: #D13212;
626
+ }
627
+
628
+ .feedback-sdk-notification-warning {
629
+ background: #FF9900;
630
+ color: #000;
631
+ }
632
+
633
+ .feedback-sdk-notification-info {
634
+ background: #0972D3;
635
+ }
636
+
583
637
  /* ========================================
584
638
  RESPONSIVE
585
639
  ======================================== */
@@ -58,7 +58,7 @@ export class SurveyWidget extends BaseWidget {
58
58
 
59
59
  document
60
60
  .querySelectorAll(
61
- '.feedback-survey, .feedback-survey-backdrop, .feedback-survey-success'
61
+ '.feedback-survey, .feedback-survey-backdrop, .feedback-survey-success, .feedback-sdk-notification'
62
62
  )
63
63
  .forEach((el) => {
64
64
  if (el && el.parentNode) {
@@ -414,8 +414,18 @@ export class SurveyWidget extends BaseWidget {
414
414
  const pageId = page.id || `page_${this.surveyState.currentPageIndex}`;
415
415
  const config = page.ratingConfig || page.rating_config || {};
416
416
  const scale = Number(config.scale) || 5;
417
- const ratingType =
418
- config.survey_type || this.surveyOptions.surveyType || 'csat';
417
+ const topSurveyType = this.surveyOptions.surveyType;
418
+ const configType = config.survey_type;
419
+ let ratingType;
420
+ if (topSurveyType === 'ces') {
421
+ ratingType = 'ces';
422
+ } else if (topSurveyType === 'nps') {
423
+ ratingType = 'nps';
424
+ } else if (topSurveyType === 'csat' && !configType) {
425
+ ratingType = 'emoji';
426
+ } else {
427
+ ratingType = configType || topSurveyType || 'csat';
428
+ }
419
429
  const pageAnswer = this.surveyState.pageAnswers[pageId] || {};
420
430
  const currentRating = pageAnswer.rating;
421
431
  const defaultLowLabel =
@@ -1182,30 +1192,20 @@ export class SurveyWidget extends BaseWidget {
1182
1192
 
1183
1193
  const error = document.createElement('div');
1184
1194
  error.className = 'feedback-survey-error';
1185
- error.textContent = message;
1195
+ error.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><path d="M236.8,188.09,149.35,36a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM120,104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm8,88a12,12,0,1,1,12-12A12,12,0,0,1,128,192Z" fill="currentColor"/></svg><span>${message}</span>`;
1186
1196
 
1187
- const submitBtn = this.surveyElement.querySelector(
1188
- '.feedback-survey-submit'
1189
- );
1190
- const actions = this.surveyElement.querySelector(
1191
- '.feedback-survey-actions'
1192
- );
1193
- const anchor = submitBtn || actions;
1194
- if (anchor && anchor.parentNode) {
1195
- anchor.parentNode.insertBefore(error, anchor);
1196
- } else {
1197
- this.surveyElement.appendChild(error);
1198
- }
1197
+ this.surveyElement.prepend(error);
1199
1198
 
1200
1199
  setTimeout(() => error.remove(), 3000);
1201
1200
  }
1202
1201
 
1203
1202
  _showSuccessNotification() {
1204
1203
  const notification = document.createElement('div');
1205
- notification.className = 'feedback-survey-success';
1204
+ notification.className =
1205
+ 'feedback-sdk-notification feedback-sdk-notification-success';
1206
1206
  notification.innerHTML = `
1207
1207
  <div>
1208
- <span style="font-size: 18px;">✓</span>
1208
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><path d="M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z" fill="currentColor"/></svg>
1209
1209
  <span>Thank you for your feedback!</span>
1210
1210
  </div>
1211
1211
  `;