@product7/feedback-sdk 1.7.5 → 1.7.7
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 +108 -29
- package/dist/feedback-sdk.js.map +1 -1
- package/dist/feedback-sdk.min.js +1 -1
- package/dist/feedback-sdk.min.js.map +1 -1
- package/package.json +1 -1
- package/src/styles/survey.js +88 -9
- package/src/widgets/SurveyWidget.js +20 -20
package/package.json
CHANGED
package/src/styles/survey.js
CHANGED
|
@@ -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.
|
|
254
|
+
transform: scale(1.15);
|
|
254
255
|
}
|
|
255
256
|
|
|
256
257
|
.feedback-survey-csat-btn.selected {
|
|
257
|
-
transform: scale(1.
|
|
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
|
/* ========================================
|
|
@@ -293,6 +299,38 @@ export const surveyStyles = `
|
|
|
293
299
|
color: var(--color-white);
|
|
294
300
|
}
|
|
295
301
|
|
|
302
|
+
.feedback-survey-ces-list {
|
|
303
|
+
display: flex;
|
|
304
|
+
flex-direction: column;
|
|
305
|
+
gap: var(--spacing-2);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.feedback-survey-ces-list-btn {
|
|
309
|
+
width: 100%;
|
|
310
|
+
padding: var(--spacing-3) var(--spacing-4);
|
|
311
|
+
border: 1px solid var(--color-border);
|
|
312
|
+
border-radius: var(--radius-md);
|
|
313
|
+
background: var(--color-surface);
|
|
314
|
+
cursor: pointer;
|
|
315
|
+
font-size: var(--font-size-base);
|
|
316
|
+
font-weight: var(--font-weight-medium);
|
|
317
|
+
color: var(--color-text-primary);
|
|
318
|
+
transition: all var(--transition-fast);
|
|
319
|
+
font-family: inherit;
|
|
320
|
+
text-align: left;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.feedback-survey-ces-list-btn:hover {
|
|
324
|
+
background: var(--color-neutral-100);
|
|
325
|
+
border-color: var(--color-border);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.feedback-survey-ces-list-btn.selected {
|
|
329
|
+
background: var(--color-primary);
|
|
330
|
+
border-color: var(--color-primary);
|
|
331
|
+
color: var(--color-white);
|
|
332
|
+
}
|
|
333
|
+
|
|
296
334
|
.feedback-survey-rating-scale {
|
|
297
335
|
display: flex;
|
|
298
336
|
gap: 0;
|
|
@@ -560,18 +598,35 @@ export const surveyStyles = `
|
|
|
560
598
|
}
|
|
561
599
|
|
|
562
600
|
.feedback-survey-error {
|
|
563
|
-
|
|
601
|
+
position: absolute;
|
|
602
|
+
top: 0;
|
|
603
|
+
left: 0;
|
|
604
|
+
right: 0;
|
|
605
|
+
background: #FF9900;
|
|
606
|
+
color: #000;
|
|
564
607
|
font-size: var(--font-size-sm);
|
|
565
|
-
|
|
566
|
-
|
|
608
|
+
font-weight: var(--font-weight-medium);
|
|
609
|
+
padding: 10px 14px;
|
|
610
|
+
display: flex;
|
|
611
|
+
align-items: center;
|
|
612
|
+
gap: 8px;
|
|
613
|
+
z-index: 2;
|
|
567
614
|
}
|
|
568
615
|
|
|
569
|
-
.feedback-survey-
|
|
616
|
+
.feedback-survey-error svg {
|
|
617
|
+
width: 16px;
|
|
618
|
+
height: 16px;
|
|
619
|
+
flex-shrink: 0;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/* ========================================
|
|
623
|
+
NOTIFICATION TOASTS
|
|
624
|
+
======================================== */
|
|
625
|
+
|
|
626
|
+
.feedback-sdk-notification {
|
|
570
627
|
position: fixed;
|
|
571
628
|
top: var(--spacing-6);
|
|
572
629
|
right: var(--spacing-6);
|
|
573
|
-
background: var(--color-success);
|
|
574
|
-
color: var(--color-white);
|
|
575
630
|
padding: var(--spacing-3) var(--spacing-5);
|
|
576
631
|
border-radius: var(--radius-xl);
|
|
577
632
|
font-size: var(--font-size-sm);
|
|
@@ -579,14 +634,38 @@ export const surveyStyles = `
|
|
|
579
634
|
z-index: var(--z-notification);
|
|
580
635
|
box-shadow: var(--shadow-lg);
|
|
581
636
|
font-family: inherit;
|
|
637
|
+
color: #fff;
|
|
582
638
|
}
|
|
583
639
|
|
|
584
|
-
.feedback-
|
|
640
|
+
.feedback-sdk-notification > div {
|
|
585
641
|
display: flex;
|
|
586
642
|
align-items: center;
|
|
587
643
|
gap: var(--spacing-2);
|
|
588
644
|
}
|
|
589
645
|
|
|
646
|
+
.feedback-sdk-notification svg {
|
|
647
|
+
width: 18px;
|
|
648
|
+
height: 18px;
|
|
649
|
+
flex-shrink: 0;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
.feedback-sdk-notification-success {
|
|
653
|
+
background: #037F0C;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
.feedback-sdk-notification-error {
|
|
657
|
+
background: #D13212;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
.feedback-sdk-notification-warning {
|
|
661
|
+
background: #FF9900;
|
|
662
|
+
color: #000;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
.feedback-sdk-notification-info {
|
|
666
|
+
background: #0972D3;
|
|
667
|
+
}
|
|
668
|
+
|
|
590
669
|
/* ========================================
|
|
591
670
|
RESPONSIVE
|
|
592
671
|
======================================== */
|
|
@@ -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
|
|
418
|
-
|
|
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 =
|
|
@@ -466,12 +476,12 @@ export class SurveyWidget extends BaseWidget {
|
|
|
466
476
|
if (ratingType === 'ces') {
|
|
467
477
|
const cesLabels = ['Very Difficult', 'Difficult', 'Neutral', 'Easy', 'Very Easy'];
|
|
468
478
|
return `
|
|
469
|
-
<div class="feedback-survey-ces" data-page-id="${pageId}">
|
|
479
|
+
<div class="feedback-survey-ces-list" data-page-id="${pageId}">
|
|
470
480
|
${cesLabels
|
|
471
481
|
.map((label, i) => {
|
|
472
482
|
const score = i + 1;
|
|
473
483
|
const selected = currentRating === score ? ' selected' : '';
|
|
474
|
-
return `<button class="feedback-survey-page-rating-btn feedback-survey-ces-btn${selected}" data-page-id="${pageId}" data-score="${score}">${label}</button>`;
|
|
484
|
+
return `<button class="feedback-survey-page-rating-btn feedback-survey-ces-list-btn${selected}" data-page-id="${pageId}" data-score="${score}">${label}</button>`;
|
|
475
485
|
})
|
|
476
486
|
.join('')}
|
|
477
487
|
</div>
|
|
@@ -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.
|
|
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
|
-
|
|
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 =
|
|
1204
|
+
notification.className =
|
|
1205
|
+
'feedback-sdk-notification feedback-sdk-notification-success';
|
|
1206
1206
|
notification.innerHTML = `
|
|
1207
1207
|
<div>
|
|
1208
|
-
<
|
|
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
|
`;
|