@product7/feedback-sdk 1.6.7 → 1.6.8

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.6.7",
3
+ "version": "1.6.8",
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",
@@ -130,6 +130,23 @@ export const changelogStyles = `
130
130
  font-family: inherit;
131
131
  }
132
132
 
133
+ .changelog-modal-backdrop,
134
+ .changelog-list-modal-backdrop {
135
+ position: fixed;
136
+ inset: 0;
137
+ background: rgba(0, 0, 0, 0.5);
138
+ opacity: 0;
139
+ pointer-events: none;
140
+ transition: opacity var(--transition-slow);
141
+ z-index: var(--z-modal-backdrop);
142
+ }
143
+
144
+ .changelog-modal-backdrop.show,
145
+ .changelog-list-modal-backdrop.show {
146
+ opacity: 1;
147
+ pointer-events: auto;
148
+ }
149
+
133
150
  .changelog-modal.open {
134
151
  pointer-events: auto;
135
152
  }
@@ -393,6 +410,53 @@ export const changelogStyles = `
393
410
  opacity: 1;
394
411
  }
395
412
 
413
+ .changelog-theme-dark.changelog-widget .changelog-trigger-btn {
414
+ background: #0F172A;
415
+ color: #E2E8F0;
416
+ border: 1px solid #334155;
417
+ }
418
+
419
+ .changelog-theme-dark.changelog-modal-backdrop,
420
+ .changelog-theme-dark.changelog-list-modal-backdrop {
421
+ background: rgba(2, 6, 23, 0.72);
422
+ }
423
+
424
+ .changelog-theme-dark .changelog-modal-container,
425
+ .changelog-theme-dark .changelog-list-modal-container {
426
+ background: #111827;
427
+ border: 1px solid #334155;
428
+ }
429
+
430
+ .changelog-theme-dark .changelog-list-modal-header {
431
+ background: #111827;
432
+ border-bottom-color: #334155;
433
+ }
434
+
435
+ .changelog-theme-dark .changelog-list-modal-header h2,
436
+ .changelog-theme-dark .changelog-list-item-title,
437
+ .changelog-theme-dark .changelog-popup-title,
438
+ .changelog-theme-dark .changelog-view-all-btn {
439
+ color: #F3F4F6;
440
+ }
441
+
442
+ .changelog-theme-dark .changelog-list-item-description,
443
+ .changelog-theme-dark .changelog-popup-description,
444
+ .changelog-theme-dark .changelog-list-item-date {
445
+ color: #9CA3AF;
446
+ }
447
+
448
+ .changelog-theme-dark .changelog-list-item {
449
+ border-bottom-color: #334155;
450
+ }
451
+
452
+ .changelog-theme-dark .changelog-list-item:hover {
453
+ background: #1F2937;
454
+ }
455
+
456
+ .changelog-theme-dark .changelog-popup-btn {
457
+ color: #FFFFFF;
458
+ }
459
+
396
460
  .changelog-list-modal-header {
397
461
  display: flex;
398
462
  align-items: center;
@@ -136,8 +136,26 @@ export const feedbackStyles = `
136
136
  transform: translateX(0);
137
137
  }
138
138
 
139
+ .feedback-modal {
140
+ position: fixed;
141
+ top: 50%;
142
+ left: 50%;
143
+ transform: translate(-50%, -50%) scale(0.96);
144
+ width: min(460px, calc(100vw - (var(--spacing-5) * 2)));
145
+ max-height: min(560px, calc(100vh - (var(--spacing-6) * 2)));
146
+ z-index: var(--z-popover);
147
+ transition: transform var(--transition-slow);
148
+ font-family: inherit;
149
+ box-shadow: rgba(50, 50, 93, 0.25) 0px 2px 5px -1px, rgba(0, 0, 0, 0.3) 0px 1px 3px -1px;
150
+ }
151
+
152
+ .feedback-modal.open {
153
+ transform: translate(-50%, -50%) scale(1);
154
+ }
155
+
139
156
  .feedback-panel-content {
140
- background: var(--color-white);
157
+ background: var(--feedback-panel-bg, var(--color-white));
158
+ color: var(--feedback-panel-text, var(--color-text-primary));
141
159
  height: 100%;
142
160
  display: flex;
143
161
  flex-direction: column;
@@ -157,7 +175,7 @@ export const feedbackStyles = `
157
175
  margin: 0;
158
176
  font-size: var(--font-size-xl);
159
177
  font-weight: var(--font-weight-semibold);
160
- color: var(--color-text-primary);
178
+ color: var(--feedback-panel-text, var(--color-text-primary));
161
179
  }
162
180
 
163
181
  .feedback-panel-body {
@@ -196,6 +214,51 @@ export const feedbackStyles = `
196
214
  display: block;
197
215
  }
198
216
 
217
+ .feedback-panel.theme-dark .feedback-panel-content,
218
+ .feedback-modal.theme-dark .feedback-panel-content {
219
+ background: #111827;
220
+ color: #E2E8F0;
221
+ }
222
+
223
+ .feedback-panel.theme-dark .feedback-panel-header,
224
+ .feedback-modal.theme-dark .feedback-panel-header {
225
+ border-bottom-color: #374151;
226
+ }
227
+
228
+ .feedback-panel.theme-dark .sdk-label,
229
+ .feedback-panel.theme-dark .feedback-panel-header h3,
230
+ .feedback-modal.theme-dark .sdk-label,
231
+ .feedback-modal.theme-dark .feedback-panel-header h3 {
232
+ color: #E2E8F0;
233
+ }
234
+
235
+ .feedback-panel.theme-dark .sdk-input,
236
+ .feedback-panel.theme-dark .sdk-textarea,
237
+ .feedback-modal.theme-dark .sdk-input,
238
+ .feedback-modal.theme-dark .sdk-textarea {
239
+ background: #1F2937;
240
+ border-color: #374151;
241
+ color: #E2E8F0;
242
+ }
243
+
244
+ .feedback-panel.theme-dark .sdk-input::placeholder,
245
+ .feedback-panel.theme-dark .sdk-textarea::placeholder,
246
+ .feedback-modal.theme-dark .sdk-input::placeholder,
247
+ .feedback-modal.theme-dark .sdk-textarea::placeholder {
248
+ color: #9CA3AF;
249
+ }
250
+
251
+ .feedback-panel.theme-dark .sdk-close-btn,
252
+ .feedback-modal.theme-dark .sdk-close-btn {
253
+ color: #9CA3AF;
254
+ }
255
+
256
+ .feedback-panel.theme-dark .sdk-close-btn:hover,
257
+ .feedback-modal.theme-dark .sdk-close-btn:hover {
258
+ background: #1F2937;
259
+ color: #E2E8F0;
260
+ }
261
+
199
262
  @media (max-width: 768px) {
200
263
  .feedback-widget-button {
201
264
  bottom: var(--spacing-4);
@@ -17,7 +17,12 @@ export function applyMessengerCustomStyles(options = {}) {
17
17
  }
18
18
 
19
19
  const adjustColor = (hex, percent, alpha = 1) => {
20
- const num = parseInt(hex.replace('#', ''), 16);
20
+ const normalized = String(hex || '').trim();
21
+ if (!/^#?[0-9a-fA-F]{6}$/.test(normalized)) {
22
+ return normalized || '#000000';
23
+ }
24
+
25
+ const num = parseInt(normalized.replace('#', ''), 16);
21
26
  const r = Math.max(0, Math.min(255, (num >> 16) + percent));
22
27
  const g = Math.max(0, Math.min(255, ((num >> 8) & 0x00ff) + percent));
23
28
  const b = Math.max(0, Math.min(255, (num & 0x0000ff) + percent));
@@ -29,6 +34,10 @@ export function applyMessengerCustomStyles(options = {}) {
29
34
  return '#' + ((r << 16) | (g << 8) | b).toString(16).padStart(6, '0');
30
35
  };
31
36
 
37
+ const darkSurface = adjustColor(backgroundColor, 12);
38
+ const darkSurfaceAlt = adjustColor(backgroundColor, 20);
39
+ const darkBorder = adjustColor(backgroundColor, 34);
40
+
32
41
  styleElement.textContent = `
33
42
  #product7-messenger-widget {
34
43
  --color-primary: ${primaryColor} !important;
@@ -90,6 +99,77 @@ export function applyMessengerCustomStyles(options = {}) {
90
99
  `
91
100
  : ''
92
101
  }
102
+
103
+ ${
104
+ theme === 'dark'
105
+ ? `
106
+ .messenger-widget.theme-dark .messenger-panel-content,
107
+ .messenger-widget.theme-dark .messenger-home-view,
108
+ .messenger-widget.theme-dark .messenger-nav,
109
+ .messenger-widget.theme-dark .messenger-chat-compose,
110
+ .messenger-widget.theme-dark .messenger-compose-attachments-preview,
111
+ .messenger-widget.theme-dark .messenger-home-featured,
112
+ .messenger-widget.theme-dark .messenger-chat-header {
113
+ background: ${backgroundColor} !important;
114
+ border-color: ${darkBorder} !important;
115
+ }
116
+
117
+ .messenger-widget.theme-dark .messenger-view,
118
+ .messenger-widget.theme-dark .messenger-chat-title,
119
+ .messenger-widget.theme-dark .messenger-home-greeting,
120
+ .messenger-widget.theme-dark .messenger-home-question,
121
+ .messenger-widget.theme-dark .messenger-home-featured-content h3,
122
+ .messenger-widget.theme-dark .messenger-home-featured-content p,
123
+ .messenger-widget.theme-dark .messenger-home-changelog-card-title,
124
+ .messenger-widget.theme-dark .messenger-home-changelog-card-desc,
125
+ .messenger-widget.theme-dark .messenger-conversation-title,
126
+ .messenger-widget.theme-dark .messenger-article-title,
127
+ .messenger-widget.theme-dark .messenger-compose-input,
128
+ .messenger-widget.theme-dark .messenger-message-sender,
129
+ .messenger-widget.theme-dark .messenger-message-time,
130
+ .messenger-widget.theme-dark .messenger-nav-label {
131
+ color: ${textColor} !important;
132
+ }
133
+
134
+ .messenger-widget.theme-dark .messenger-home-view {
135
+ background: linear-gradient(180deg, ${adjustColor(backgroundColor, 10)} 0%, ${backgroundColor} 55%) !important;
136
+ }
137
+
138
+ .messenger-widget.theme-dark .messenger-home-view::before {
139
+ background: radial-gradient(circle, ${adjustColor(primaryColor, 0, 0.12)} 0%, transparent 70%) !important;
140
+ }
141
+
142
+ .messenger-widget.theme-dark .messenger-home-message-btn,
143
+ .messenger-widget.theme-dark .messenger-home-changelog-card,
144
+ .messenger-widget.theme-dark .messenger-compose-input-wrapper,
145
+ .messenger-widget.theme-dark .messenger-message-received .messenger-message-bubble,
146
+ .messenger-widget.theme-dark .messenger-message-file,
147
+ .messenger-widget.theme-dark .messenger-prechat-card,
148
+ .messenger-widget.theme-dark .messenger-list-item,
149
+ .messenger-widget.theme-dark .messenger-article-item {
150
+ background: ${darkSurface} !important;
151
+ border-color: ${darkBorder} !important;
152
+ }
153
+
154
+ .messenger-widget.theme-dark .messenger-home-message-btn:hover,
155
+ .messenger-widget.theme-dark .messenger-home-changelog-card:hover,
156
+ .messenger-widget.theme-dark .messenger-list-item:hover,
157
+ .messenger-widget.theme-dark .messenger-article-item:hover {
158
+ background: ${darkSurfaceAlt} !important;
159
+ }
160
+
161
+ .messenger-widget.theme-dark .messenger-message-own .messenger-message-bubble,
162
+ .messenger-widget.theme-dark .messenger-compose-send,
163
+ .messenger-widget.theme-dark .messenger-launcher-btn,
164
+ .messenger-widget.theme-dark .messenger-nav-badge,
165
+ .messenger-widget.theme-dark .messenger-launcher-badge,
166
+ .messenger-widget.theme-dark .messenger-home-changelog-cover-text,
167
+ .messenger-widget.theme-dark .messenger-attachment-remove {
168
+ color: #FFFFFF !important;
169
+ }
170
+ `
171
+ : ''
172
+ }
93
173
  `;
94
174
 
95
175
  console.log('✅ Custom messenger styles applied:', { primaryColor, theme });
@@ -14,6 +14,10 @@ export const surveyStyles = `
14
14
  animation: fadeIn var(--transition-slow);
15
15
  }
16
16
 
17
+ .feedback-survey-backdrop-dark {
18
+ background: rgba(2, 6, 23, 0.72);
19
+ }
20
+
17
21
  /* ========================================
18
22
  SURVEY CARD
19
23
  ======================================== */
@@ -31,6 +35,79 @@ export const surveyStyles = `
31
35
  font-family: inherit;
32
36
  }
33
37
 
38
+ .feedback-survey-theme-dark {
39
+ background: #111827;
40
+ border-color: #374151;
41
+ }
42
+
43
+ .feedback-survey-theme-dark .feedback-survey-title,
44
+ .feedback-survey-theme-dark .feedback-survey-description-primary .feedback-survey-description {
45
+ color: #F3F4F6;
46
+ }
47
+
48
+ .feedback-survey-theme-dark .feedback-survey-description,
49
+ .feedback-survey-theme-dark .feedback-survey-labels,
50
+ .feedback-survey-theme-dark .feedback-survey-progress {
51
+ color: #9CA3AF;
52
+ }
53
+
54
+ .feedback-survey-theme-dark .feedback-survey-close {
55
+ color: #9CA3AF;
56
+ }
57
+
58
+ .feedback-survey-theme-dark .feedback-survey-close:hover {
59
+ background: #1F2937;
60
+ color: #F3F4F6;
61
+ }
62
+
63
+ .feedback-survey-theme-dark .feedback-survey-rating-scale {
64
+ border-color: #374151;
65
+ background: #1F2937;
66
+ }
67
+
68
+ .feedback-survey-theme-dark .feedback-survey-rating-scale-btn {
69
+ background: #1F2937;
70
+ border-right-color: #374151;
71
+ color: #F3F4F6;
72
+ }
73
+
74
+ .feedback-survey-theme-dark .feedback-survey-rating-scale-btn:hover,
75
+ .feedback-survey-theme-dark .feedback-survey-nps-btn:hover,
76
+ .feedback-survey-theme-dark .feedback-survey-ces-btn:hover,
77
+ .feedback-survey-theme-dark .feedback-survey-page-choice-btn:hover {
78
+ background: #273549;
79
+ }
80
+
81
+ .feedback-survey-theme-dark .feedback-survey-nps-btn,
82
+ .feedback-survey-theme-dark .feedback-survey-ces-btn,
83
+ .feedback-survey-theme-dark .feedback-survey-freq-btn,
84
+ .feedback-survey-theme-dark .feedback-survey-page-choice-btn {
85
+ background: #1F2937;
86
+ border-color: #374151;
87
+ color: #E5E7EB;
88
+ }
89
+
90
+ .feedback-survey-theme-dark .feedback-survey-page-textarea,
91
+ .feedback-survey-theme-dark .feedback-survey-select,
92
+ .feedback-survey-theme-dark .feedback-survey-input,
93
+ .feedback-survey-theme-dark .feedback-survey-textarea {
94
+ background: #1F2937;
95
+ border-color: #374151;
96
+ color: #F3F4F6;
97
+ }
98
+
99
+ .feedback-survey-theme-dark .feedback-survey-page-textarea::placeholder,
100
+ .feedback-survey-theme-dark .feedback-survey-input::placeholder,
101
+ .feedback-survey-theme-dark .feedback-survey-textarea::placeholder {
102
+ color: #9CA3AF;
103
+ }
104
+
105
+ .feedback-survey-theme-dark .feedback-survey-back {
106
+ background: #111827;
107
+ border-color: #374151;
108
+ color: #E5E7EB;
109
+ }
110
+
34
111
  .feedback-survey-bottom-right {
35
112
  bottom: var(--spacing-6);
36
113
  right: var(--spacing-6);
@@ -18,7 +18,7 @@ export class BaseWidget {
18
18
  backgroundColor: options.backgroundColor || '#ffffff',
19
19
  textColor: options.textColor || '#1F2937',
20
20
  autoShow: false,
21
- showBackdrop: false,
21
+ showBackdrop: true,
22
22
  customStyles: {},
23
23
  suppressAfterSubmission: true,
24
24
  suppressionDays: BaseWidget.DEFAULT_COOLDOWN_DAYS,
@@ -136,9 +136,11 @@ export class BaseWidget {
136
136
  _showLoadingModal() {
137
137
  this.state.isLoading = true;
138
138
 
139
- this.backdropElement = document.createElement('div');
140
- this.backdropElement.className = 'sdk-modal-backdrop';
141
- document.body.appendChild(this.backdropElement);
139
+ if (this.options.showBackdrop) {
140
+ this.backdropElement = document.createElement('div');
141
+ this.backdropElement.className = 'sdk-modal-backdrop';
142
+ document.body.appendChild(this.backdropElement);
143
+ }
142
144
 
143
145
  this.loadingElement = document.createElement('div');
144
146
  this.loadingElement.className = 'feedback-loading-modal';
@@ -148,7 +150,9 @@ export class BaseWidget {
148
150
  document.body.appendChild(this.loadingElement);
149
151
 
150
152
  requestAnimationFrame(() => {
151
- this.backdropElement.classList.add('show');
153
+ if (this.backdropElement) {
154
+ this.backdropElement.classList.add('show');
155
+ }
152
156
  this.loadingElement.classList.add('show');
153
157
  });
154
158
  }
@@ -343,16 +347,17 @@ export class BaseWidget {
343
347
  : 'feedback-panel';
344
348
  const sizeClass = `size-${this.options.size}`;
345
349
  this.panelElement = document.createElement('div');
346
- this.panelElement.className = `${modeClass} ${sizeClass}`;
350
+ const themeClass = `theme-${this.options.theme || 'light'}`;
351
+ this.panelElement.className = `${modeClass} ${sizeClass} ${themeClass}`;
352
+ this.panelElement.style.setProperty('--color-primary', this.options.primaryColor);
347
353
  this.panelElement.style.setProperty(
348
- '--primary-color',
349
- this.options.primaryColor
354
+ '--feedback-panel-bg',
355
+ this.options.backgroundColor
350
356
  );
351
357
  this.panelElement.style.setProperty(
352
- '--bg-color',
353
- this.options.backgroundColor
358
+ '--feedback-panel-text',
359
+ this.options.textColor
354
360
  );
355
- this.panelElement.style.setProperty('--text-color', this.options.textColor);
356
361
  this.panelElement.innerHTML = this._getPanelHTML();
357
362
 
358
363
  document.body.appendChild(this.panelElement);
@@ -12,7 +12,7 @@ export class ChangelogWidget extends BaseWidget {
12
12
 
13
13
  _render() {
14
14
  const trigger = document.createElement('div');
15
- trigger.className = `changelog-widget position-${this.options.position}`;
15
+ trigger.className = `changelog-widget position-${this.options.position} changelog-theme-${this.options.theme || 'light'}`;
16
16
  trigger.innerHTML = `
17
17
  <button class="changelog-trigger-btn" type="button" aria-label="View Updates">
18
18
  <svg class="changelog-icon" width="18" height="18" viewBox="0 0 24 24" fill="currentColor">
@@ -88,12 +88,12 @@ export class ChangelogWidget extends BaseWidget {
88
88
 
89
89
  _createModal() {
90
90
  this.backdropElement = document.createElement('div');
91
- this.backdropElement.className = 'changelog-modal-backdrop';
91
+ this.backdropElement.className = `changelog-modal-backdrop changelog-theme-${this.options.theme || 'light'}`;
92
92
  document.body.appendChild(this.backdropElement);
93
93
  this.backdropElement.addEventListener('click', () => this.closeModal());
94
94
 
95
95
  this.modalElement = document.createElement('div');
96
- this.modalElement.className = 'changelog-modal';
96
+ this.modalElement.className = `changelog-modal changelog-theme-${this.options.theme || 'light'}`;
97
97
  this.modalElement.innerHTML = `
98
98
  <div class="changelog-modal-container">
99
99
  <button class="changelog-modal-close" type="button" aria-label="Close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><line x1="200" y1="56" x2="56" y2="200" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="200" y1="200" x2="56" y2="56" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg></button>
@@ -231,14 +231,14 @@ export class ChangelogWidget extends BaseWidget {
231
231
 
232
232
  _createListModal() {
233
233
  this.listModalBackdropElement = document.createElement('div');
234
- this.listModalBackdropElement.className = 'changelog-list-modal-backdrop';
234
+ this.listModalBackdropElement.className = `changelog-list-modal-backdrop changelog-theme-${this.options.theme || 'light'}`;
235
235
  document.body.appendChild(this.listModalBackdropElement);
236
236
  this.listModalBackdropElement.addEventListener('click', () =>
237
237
  this.closeSidebar()
238
238
  );
239
239
 
240
240
  this.listModalElement = document.createElement('div');
241
- this.listModalElement.className = 'changelog-list-modal';
241
+ this.listModalElement.className = `changelog-list-modal changelog-theme-${this.options.theme || 'light'}`;
242
242
  this.listModalElement.innerHTML = `
243
243
  <div class="changelog-list-modal-container">
244
244
  <div class="changelog-list-modal-header">
@@ -17,6 +17,19 @@ import { PreChatFormView } from './messenger/views/PreChatFormView.js';
17
17
  export class MessengerWidget extends BaseWidget {
18
18
  constructor(options) {
19
19
  super({ ...options, type: 'messenger' });
20
+ const resolvedTheme = options.theme || 'light';
21
+ const hasExplicitTextColor = Object.prototype.hasOwnProperty.call(
22
+ options,
23
+ 'textColor'
24
+ );
25
+ const hasExplicitBackgroundColor = Object.prototype.hasOwnProperty.call(
26
+ options,
27
+ 'backgroundColor'
28
+ );
29
+ const defaultTextColor =
30
+ resolvedTheme === 'dark' ? '#E2E8F0' : '#1d1d1f';
31
+ const defaultBackgroundColor =
32
+ resolvedTheme === 'dark' ? '#0F172A' : '#ffffff';
20
33
 
21
34
  const resolvedEnableChangelog =
22
35
  typeof options.enableChangelog === 'boolean'
@@ -25,10 +38,12 @@ export class MessengerWidget extends BaseWidget {
25
38
 
26
39
  this.messengerOptions = {
27
40
  position: options.position || 'bottom-right',
28
- theme: options.theme || 'light',
41
+ theme: resolvedTheme,
29
42
  primaryColor: options.primaryColor || '#155EEF',
30
- textColor: options.textColor || '#1d1d1f',
31
- backgroundColor: options.backgroundColor || '#ffffff',
43
+ textColor: hasExplicitTextColor ? options.textColor : defaultTextColor,
44
+ backgroundColor: hasExplicitBackgroundColor
45
+ ? options.backgroundColor
46
+ : defaultBackgroundColor,
32
47
  logoUrl: options.logoUrl || 'https://product7.io/p7logo.svg',
33
48
  teamName: options.teamName || 'Support',
34
49
  teamAvatars: options.teamAvatars || [],
@@ -8,6 +8,7 @@ export class SurveyWidget extends BaseWidget {
8
8
  surveyId: options.surveyId || null,
9
9
  surveyType: options.surveyType || 'nps',
10
10
  position: options.position || 'bottom-right',
11
+ theme: options.theme || 'light',
11
12
  enabled:
12
13
  typeof options.enabled === 'boolean' ? options.enabled : undefined,
13
14
  title: options.title || null,
@@ -52,6 +53,20 @@ export class SurveyWidget extends BaseWidget {
52
53
  };
53
54
  }
54
55
 
56
+ static removeDanglingElements() {
57
+ if (typeof document === 'undefined') return;
58
+
59
+ document
60
+ .querySelectorAll(
61
+ '.feedback-survey, .feedback-survey-backdrop, .feedback-survey-success'
62
+ )
63
+ .forEach((el) => {
64
+ if (el && el.parentNode) {
65
+ el.parentNode.removeChild(el);
66
+ }
67
+ });
68
+ }
69
+
55
70
  _render() {
56
71
  const container = document.createElement('div');
57
72
  container.className = 'feedback-survey-container';
@@ -72,6 +87,7 @@ export class SurveyWidget extends BaseWidget {
72
87
  return this;
73
88
  }
74
89
 
90
+ SurveyWidget.removeDanglingElements();
75
91
  this._renderSurvey();
76
92
  this.surveyState.isVisible = true;
77
93
  this.sdk.eventBus.emit('survey:shown', {
@@ -107,7 +123,7 @@ export class SurveyWidget extends BaseWidget {
107
123
 
108
124
  if (this.surveyOptions.position === 'center') {
109
125
  this.backdropElement = document.createElement('div');
110
- this.backdropElement.className = 'feedback-survey-backdrop';
126
+ this.backdropElement.className = `feedback-survey-backdrop feedback-survey-backdrop-${this.surveyOptions.theme}`;
111
127
  document.body.appendChild(this.backdropElement);
112
128
  this.backdropElement.addEventListener('click', () =>
113
129
  this._handleDismiss()
@@ -115,7 +131,7 @@ export class SurveyWidget extends BaseWidget {
115
131
  }
116
132
 
117
133
  this.surveyElement = document.createElement('div');
118
- this.surveyElement.className = `feedback-survey feedback-survey-${this.surveyOptions.position}${
134
+ this.surveyElement.className = `feedback-survey feedback-survey-${this.surveyOptions.position} feedback-survey-theme-${this.surveyOptions.theme}${
119
135
  showDescription && !showTitle
120
136
  ? ' feedback-survey-description-primary'
121
137
  : ''
@@ -1135,7 +1151,7 @@ export class SurveyWidget extends BaseWidget {
1135
1151
  }, 3000);
1136
1152
  }
1137
1153
 
1138
- _closeSurvey(resetState = true) {
1154
+ _closeSurvey(resetState = true, immediate = false) {
1139
1155
  if (this._escapeHandler) {
1140
1156
  document.removeEventListener('keydown', this._escapeHandler);
1141
1157
  this._escapeHandler = null;
@@ -1150,21 +1166,33 @@ export class SurveyWidget extends BaseWidget {
1150
1166
  this.surveyOptions.position === 'center'
1151
1167
  ? 'translate(-50%, -50%) scale(0.95)'
1152
1168
  : 'translateY(20px)';
1153
- setTimeout(() => {
1154
- if (surveyEl && surveyEl.parentNode) {
1169
+ if (immediate) {
1170
+ if (surveyEl.parentNode) {
1155
1171
  surveyEl.parentNode.removeChild(surveyEl);
1156
1172
  }
1157
- }, 300);
1173
+ } else {
1174
+ setTimeout(() => {
1175
+ if (surveyEl && surveyEl.parentNode) {
1176
+ surveyEl.parentNode.removeChild(surveyEl);
1177
+ }
1178
+ }, 300);
1179
+ }
1158
1180
  this.surveyElement = null;
1159
1181
  }
1160
1182
 
1161
1183
  if (backdropEl) {
1162
1184
  backdropEl.style.opacity = '0';
1163
- setTimeout(() => {
1164
- if (backdropEl && backdropEl.parentNode) {
1185
+ if (immediate) {
1186
+ if (backdropEl.parentNode) {
1165
1187
  backdropEl.parentNode.removeChild(backdropEl);
1166
1188
  }
1167
- }, 300);
1189
+ } else {
1190
+ setTimeout(() => {
1191
+ if (backdropEl && backdropEl.parentNode) {
1192
+ backdropEl.parentNode.removeChild(backdropEl);
1193
+ }
1194
+ }, 300);
1195
+ }
1168
1196
  this.backdropElement = null;
1169
1197
  }
1170
1198
 
@@ -1182,7 +1210,7 @@ export class SurveyWidget extends BaseWidget {
1182
1210
  }
1183
1211
 
1184
1212
  destroy() {
1185
- this._closeSurvey();
1213
+ this._closeSurvey(true, true);
1186
1214
  super.destroy();
1187
1215
  }
1188
1216
  }