@product7/feedback-sdk 1.4.5 → 1.4.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.4.5",
3
+ "version": "1.4.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",
@@ -1,7 +1,7 @@
1
1
  export const feedbackStyles = `
2
2
  .feedback-widget-button {
3
3
  position: fixed;
4
- z-index: var(--z-modal);
4
+ z-index: var(--z-notification);
5
5
  }
6
6
 
7
7
  .feedback-widget-button.position-bottom-right {
@@ -43,6 +43,8 @@ export const feedbackStyles = `
43
43
  background: var(--color-primary);
44
44
  box-shadow: var(--shadow-md);
45
45
  width: fit-content;
46
+ touch-action: manipulation;
47
+ -webkit-tap-highlight-color: transparent;
46
48
  }
47
49
 
48
50
  .feedback-trigger-btn:hover:not(:disabled) {
@@ -81,6 +83,7 @@ export const feedbackStyles = `
81
83
  transition: opacity var(--transition-base);
82
84
  box-shadow: var(--shadow-sm);
83
85
  cursor: pointer;
86
+ pointer-events: none;
84
87
  }
85
88
 
86
89
  .feedback-minimize-icon svg,
@@ -93,6 +96,7 @@ export const feedbackStyles = `
93
96
 
94
97
  .feedback-widget-button:not(.minimized) .feedback-trigger-btn:hover .feedback-minimize-icon {
95
98
  opacity: 1;
99
+ pointer-events: auto;
96
100
  }
97
101
 
98
102
  .feedback-widget-button.minimized .feedback-trigger-btn {
@@ -112,6 +116,7 @@ export const feedbackStyles = `
112
116
 
113
117
  .feedback-widget-button.minimized .feedback-trigger-btn:hover .feedback-expand-icon {
114
118
  opacity: 1;
119
+ pointer-events: auto;
115
120
  }
116
121
 
117
122
  .feedback-panel {
@@ -216,44 +221,30 @@ export const feedbackStyles = `
216
221
  }
217
222
 
218
223
  .feedback-panel {
219
- width: 100%;
224
+ width: min(420px, calc(100vw - (var(--spacing-4) * 2)));
225
+ max-height: min(500px, calc(100vh - 88px));
220
226
  top: auto;
221
- bottom: 0;
222
- right: 0;
223
- left: 0;
224
- height: 85vh;
225
- max-height: 85vh;
226
- transform: translateY(100%);
227
- border-radius: var(--radius-3xl) var(--radius-3xl) 0 0;
227
+ bottom: 72px;
228
+ right: var(--spacing-4);
229
+ left: auto;
230
+ transform: translateX(calc(100% + 24px));
231
+ border-radius: var(--radius-2xl);
228
232
  }
229
233
 
230
234
  .feedback-panel.open {
231
- transform: translateY(0);
235
+ transform: translateX(0);
232
236
  }
233
237
 
234
238
  .feedback-panel-header {
235
- padding: var(--spacing-5);
236
- position: relative;
237
- }
238
-
239
- .feedback-panel-header::before {
240
- content: '';
241
- position: absolute;
242
- top: var(--spacing-2);
243
- left: 50%;
244
- transform: translateX(-50%);
245
- width: 40px;
246
- height: 4px;
247
- background: var(--color-neutral-300);
248
- border-radius: 2px;
239
+ padding: var(--spacing-4) var(--spacing-6);
249
240
  }
250
241
 
251
242
  .feedback-panel-body {
252
- padding: var(--spacing-5);
243
+ padding: var(--spacing-6);
253
244
  }
254
245
 
255
246
  .feedback-form-group textarea {
256
- min-height: 150px;
247
+ min-height: 120px;
257
248
  }
258
249
  }
259
250
  `;
@@ -4,6 +4,7 @@ export class ButtonWidget extends BaseWidget {
4
4
  constructor(options) {
5
5
  super({ ...options, type: 'button' });
6
6
  this.isMinimized = false;
7
+ this._hiddenForOpenPanel = false;
7
8
  }
8
9
 
9
10
  _render() {
@@ -41,6 +42,21 @@ export class ButtonWidget extends BaseWidget {
41
42
  const button = this.element.querySelector('.feedback-trigger-btn');
42
43
  const minimizeIcon = this.element.querySelector('.feedback-minimize-icon');
43
44
  const expandIcon = this.element.querySelector('.feedback-expand-icon');
45
+ const isControlIcon = (target) => {
46
+ if (!(target instanceof Element)) return false;
47
+ return Boolean(
48
+ target.closest('.feedback-minimize-icon') ||
49
+ target.closest('.feedback-expand-icon')
50
+ );
51
+ };
52
+ const openIfAllowed = (target) => {
53
+ if (isControlIcon(target)) {
54
+ return;
55
+ }
56
+ if (!this.isMinimized) {
57
+ this.openPanel();
58
+ }
59
+ };
44
60
 
45
61
  minimizeIcon.addEventListener('click', (e) => {
46
62
  e.stopPropagation();
@@ -55,16 +71,13 @@ export class ButtonWidget extends BaseWidget {
55
71
  });
56
72
 
57
73
  button.addEventListener('click', (e) => {
58
- if (
59
- e.target.closest('.feedback-minimize-icon') ||
60
- e.target.closest('.feedback-expand-icon')
61
- ) {
62
- return;
63
- }
74
+ openIfAllowed(e.target);
75
+ });
64
76
 
65
- if (!this.isMinimized) {
66
- this.openPanel();
67
- }
77
+ // Pointer events improve consistency across touch and mouse devices.
78
+ button.addEventListener('pointerup', (e) => {
79
+ if (e.pointerType === 'mouse') return;
80
+ openIfAllowed(e.target);
68
81
  });
69
82
  }
70
83
 
@@ -78,6 +91,28 @@ export class ButtonWidget extends BaseWidget {
78
91
  this.element.classList.remove('minimized');
79
92
  }
80
93
 
94
+ openPanel() {
95
+ if (!this.state.isOpen) {
96
+ this._hiddenForOpenPanel = true;
97
+ this.hide();
98
+ }
99
+ super.openPanel();
100
+ }
101
+
102
+ closePanel() {
103
+ const shouldRestoreButton = this._hiddenForOpenPanel;
104
+ super.closePanel();
105
+
106
+ if (shouldRestoreButton) {
107
+ setTimeout(() => {
108
+ if (!this.destroyed) {
109
+ this.show();
110
+ }
111
+ this._hiddenForOpenPanel = false;
112
+ }, 320);
113
+ }
114
+ }
115
+
81
116
  mount(container) {
82
117
  super.mount(container);
83
118
  }