pushfeedback 0.1.69 → 0.1.70

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.
Files changed (47) hide show
  1. package/dist/components/canvas-editor.d.ts +11 -0
  2. package/dist/components/index.d.ts +1 -0
  3. package/dist/pushfeedback/app-globals-0f993ce5.js +3 -0
  4. package/dist/pushfeedback/canvas-editor.entry.js +860 -0
  5. package/dist/pushfeedback/css-shim-b7d3d95f.js +4 -0
  6. package/dist/pushfeedback/dom-64053c71.js +73 -0
  7. package/dist/{components/feedback-button.js → pushfeedback/feedback-button.entry.js} +30 -73
  8. package/dist/pushfeedback/feedback-modal.entry.js +295 -0
  9. package/dist/pushfeedback/index-36434da0.js +3371 -0
  10. package/dist/pushfeedback/index.esm.js +1 -0
  11. package/dist/pushfeedback/pushfeedback.css +146 -1
  12. package/dist/pushfeedback/pushfeedback.esm.js +148 -1
  13. package/dist/pushfeedback/shadow-css-98135883.js +387 -0
  14. package/dist/types/components/canvas-editor/canvas-editor.d.ts +108 -0
  15. package/dist/types/components/feedback-button/feedback-button.d.ts +11 -0
  16. package/dist/types/components/feedback-modal/feedback-modal.d.ts +22 -79
  17. package/dist/types/components.d.ts +102 -0
  18. package/package.json +3 -4
  19. package/dist/cjs/feedback-button_2.cjs.entry.js +0 -1202
  20. package/dist/cjs/index-9a8f4784.js +0 -1584
  21. package/dist/cjs/index.cjs.js +0 -2
  22. package/dist/cjs/loader.cjs.js +0 -22
  23. package/dist/cjs/pushfeedback.cjs.js +0 -23
  24. package/dist/collection/collection-manifest.json +0 -13
  25. package/dist/collection/components/feedback-button/feedback-button.css +0 -81
  26. package/dist/collection/components/feedback-button/feedback-button.js +0 -949
  27. package/dist/collection/components/feedback-modal/feedback-modal.css +0 -1003
  28. package/dist/collection/components/feedback-modal/feedback-modal.js +0 -1792
  29. package/dist/collection/index.js +0 -1
  30. package/dist/components/feedback-modal.js +0 -6
  31. package/dist/components/feedback-modal2.js +0 -1101
  32. package/dist/components/index.js +0 -3
  33. package/dist/esm/feedback-button_2.entry.js +0 -1197
  34. package/dist/esm/index-f65e9124.js +0 -1555
  35. package/dist/esm/index.js +0 -1
  36. package/dist/esm/loader.js +0 -18
  37. package/dist/esm/polyfills/core-js.js +0 -11
  38. package/dist/esm/polyfills/css-shim.js +0 -1
  39. package/dist/esm/polyfills/dom.js +0 -79
  40. package/dist/esm/polyfills/es5-html-element.js +0 -1
  41. package/dist/esm/polyfills/index.js +0 -34
  42. package/dist/esm/polyfills/system.js +0 -6
  43. package/dist/esm/pushfeedback.js +0 -18
  44. package/dist/index.cjs.js +0 -1
  45. package/dist/index.js +0 -1
  46. package/dist/pushfeedback/p-af2a1f7f.js +0 -2
  47. package/dist/pushfeedback/p-e7f48090.entry.js +0 -1
@@ -1,1197 +0,0 @@
1
- import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-f65e9124.js';
2
-
3
- const feedbackButtonCss = ".feedback-button-content{cursor:pointer;max-width:fit-content;z-index:var(--feedback-button-z-index);font-family:var(--feedback-font-family)}.feedback-button-content--custom-font{font-family:inherit}.feedback-button-content--light{align-items:center;background-color:var(--feedback-button-light-bg-color);border-radius:var(--feedback-button-border-radius);box-shadow:rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;box-sizing:border-box;color:var(--feedback-button-light-text-color);display:flex;font-size:var(--feedback-button-text-font-size);font-weight:var(--feedback-button-text-font-weight);padding:8px 15px}.feedback-button-content--dark{align-items:center;background-color:var(--feedback-button-dark-bg-color);border-radius:var(--feedback-button-border-radius);box-shadow:rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;box-sizing:border-box;color:var(--feedback-button-dark-text-color);display:flex;font-weight:var(--feedback-button-text-font-weight);font-size:var(--feedback-button-text-font-size);padding:8px 15px}.icon-edit{stroke:var(--feedback-button-light-icon-color)}.feedback-button-content--dark .icon-edit{stroke:var(--feedback-button-dark-icon-color)}.feedback-button-content--bottom-right{bottom:10px;position:fixed;right:10px}.feedback-button-content--center-right{position:fixed;transform:rotate(-90deg) translateY(-50%);top:50%}.feedback-button-content--center-right.feedback-button-content--dark,.feedback-button-content--center-right.feedback-button-content--light{border-radius:4px;border-bottom-left-radius:0px;border-bottom-right-radius:0px}.feedback-button-content-icon{height:16px;margin-right:5px;width:16px}.feedback-button-content--center-right .feedback-button-content-icon{rotate:90deg}@media screen and (max-width: 767px){.feedback-button-content--hide-mobile{display:none}}";
4
-
5
- const FeedbackButton = class {
6
- constructor(hostRef) {
7
- registerInstance(this, hostRef);
8
- this.feedbackSent = createEvent(this, "feedbackSent", 7);
9
- this.feedbackError = createEvent(this, "feedbackError", 7);
10
- this.buttonPosition = 'default';
11
- this.buttonStyle = 'default';
12
- this.hideIcon = false;
13
- this.hideMobile = false;
14
- this.sessionId = '';
15
- this.metadata = '';
16
- this.submit = false;
17
- this.customFont = false;
18
- this.emailAddress = '';
19
- this.isEmailRequired = false;
20
- this.fetchData = true;
21
- this.hideEmail = false;
22
- this.hidePrivacyPolicy = true;
23
- this.hideRating = false;
24
- this.hideScreenshotButton = false;
25
- this.modalPosition = 'center';
26
- this.project = '';
27
- this.rating = undefined;
28
- this.ratingMode = 'thumbs';
29
- this.canvasEditorTitle = 'Edit screenshot';
30
- this.canvasEditorCancelText = 'Cancel';
31
- this.canvasEditorSaveText = 'Save';
32
- this.emailPlaceholder = 'Email address (optional)';
33
- this.errorMessage = 'Please try again later.';
34
- this.errorMessage403 = 'The request URL does not match the one defined in PushFeedback for this project.';
35
- this.errorMessage404 = 'We could not find the provided project id in PushFeedback.';
36
- this.footerText = '';
37
- this.messagePlaceholder = 'Comments';
38
- this.modalTitle = 'Share your feedback';
39
- this.modalTitleError = 'Oops!';
40
- this.modalTitleSuccess = 'Thanks for your feedback!';
41
- this.privacyPolicyText = "I have read and expressly consent to the terms of the <a href='https://pushfeedback.com/privacy'>Privacy Policy</a>.";
42
- this.ratingPlaceholder = 'Was this page helpful?';
43
- this.ratingStarsPlaceholder = 'How would you rate this page?';
44
- this.screenshotAttachedText = 'Screenshot attached';
45
- this.screenshotButtonText = 'Add a screenshot';
46
- this.screenshotTakingText = 'Taking screenshot...';
47
- this.screenshotTopbarText = 'Select an element on this page';
48
- this.sendButtonText = 'Send';
49
- this.successMessage = '';
50
- }
51
- componentWillLoad() {
52
- if (!this.sessionId) {
53
- let storedSessionId = localStorage.getItem('pushfeedback_sessionid');
54
- if (!storedSessionId) {
55
- storedSessionId = this.generateRandomSessionId();
56
- localStorage.setItem('pushfeedback_sessionid', storedSessionId);
57
- this.sessionId = storedSessionId;
58
- }
59
- }
60
- else {
61
- localStorage.setItem('pushfeedback_sessionid', this.sessionId);
62
- }
63
- }
64
- componentDidLoad() {
65
- if (this.buttonPosition === 'center-right') {
66
- const buttonContent = this.el.shadowRoot.querySelector('.feedback-button-content');
67
- let adjustement = 0;
68
- if (this.isSafariBrowser()) {
69
- adjustement = 5;
70
- }
71
- buttonContent.style.right = `${((buttonContent.offsetWidth + adjustement) / 2) * -1}px`;
72
- }
73
- if (!this.customFont) {
74
- this.loadInterFont();
75
- }
76
- }
77
- connectedCallback() {
78
- this.feedbackModal = document.createElement('feedback-modal');
79
- const props = [
80
- 'customFont',
81
- 'emailAddress',
82
- 'fetchData',
83
- 'hideEmail',
84
- 'hidePrivacyPolicy',
85
- 'hideRating',
86
- 'hideScreenshotButton',
87
- 'isEmailRequired',
88
- 'modalPosition',
89
- 'project',
90
- 'rating',
91
- 'ratingMode',
92
- 'canvasEditorTitle',
93
- 'canvasEditorCancelText',
94
- 'canvasEditorSaveText',
95
- 'emailPlaceholder',
96
- 'errorMessage',
97
- 'errorMessage403',
98
- 'errorMessage404',
99
- 'footerText',
100
- 'messagePlaceholder',
101
- 'metadata',
102
- 'modalTitle',
103
- 'modalTitleError',
104
- 'modalTitleSuccess',
105
- 'privacyPolicyText',
106
- 'ratingPlaceholder',
107
- 'ratingStarsPlaceholder',
108
- 'screenshotAttachedText',
109
- 'screenshotButtonText',
110
- 'screenshotTakingText',
111
- 'screenshotTopbarText',
112
- 'sendButtonText',
113
- 'successMessage',
114
- ];
115
- props.forEach((prop) => {
116
- this.feedbackModal[prop] = this[prop];
117
- });
118
- document.body.appendChild(this.feedbackModal);
119
- }
120
- disconnectedCallback() {
121
- document.body.removeChild(this.feedbackModal);
122
- }
123
- generateRandomSessionId(length = 16) {
124
- return Math.random().toString(36).substr(2, length);
125
- }
126
- isSafariBrowser() {
127
- const isSafari = /safari/i.test(navigator.userAgent) && !/chrome/i.test(navigator.userAgent);
128
- return isSafari;
129
- }
130
- loadInterFont() {
131
- const link = document.createElement('link');
132
- link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';
133
- link.rel = 'stylesheet';
134
- document.head.appendChild(link);
135
- }
136
- showModal() {
137
- if (this.submit) {
138
- this.submitRatingFeedback();
139
- }
140
- else {
141
- this.feedbackModal.openModal();
142
- }
143
- }
144
- async submitRatingFeedback() {
145
- try {
146
- const body = {
147
- url: window.location.href,
148
- project: this.project,
149
- rating: this.rating || -1,
150
- ratingMode: this.ratingMode,
151
- message: '',
152
- metadata: this.metadata,
153
- session: localStorage.getItem('pushfeedback_sessionid') || '',
154
- };
155
- const res = await fetch('https://app.pushfeedback.com/api/feedback/', {
156
- method: 'POST',
157
- body: JSON.stringify(body),
158
- headers: {
159
- 'Content-Type': 'application/json',
160
- },
161
- });
162
- if (res.status === 201) {
163
- const feedback_with_id = Object.assign(Object.assign({}, body), { id: await res.json() });
164
- this.feedbackSent.emit({ feedback: feedback_with_id });
165
- }
166
- else {
167
- const errorText = await res.text();
168
- const response = {
169
- status: res.status,
170
- message: errorText,
171
- };
172
- this.feedbackError.emit({ error: response });
173
- }
174
- }
175
- catch (error) {
176
- const response = {
177
- status: 500,
178
- message: error,
179
- };
180
- this.feedbackError.emit({ error: response });
181
- }
182
- }
183
- render() {
184
- return (h(Host, null, h("a", { class: `feedback-button-content feedback-button-content--${this.buttonStyle} feedback-button-content--${this.buttonPosition} ${this.customFont ? 'feedback-button-content--custom-font' : ''} ${this.hideMobile ? 'feedback-button-content--hide-mobile' : ''}`, onClick: () => this.showModal() }, !this.hideIcon && this.buttonStyle != 'default' && (h("span", { class: "feedback-button-content-icon" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "#fff", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "icon-edit" }, h("path", { d: "M12 20h9" }), h("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z" })))), h("slot", null))));
185
- }
186
- get el() { return getElement(this); }
187
- };
188
- FeedbackButton.style = feedbackButtonCss;
189
-
190
- const feedbackModalCss = ".text-center{flex-grow:1;text-align:center}.feedback-modal-wrapper *{font-family:var(--feedback-font-family)}.feedback-modal-wrapper--custom-font *{font-family:inherit}.feedback-modal-wrapper{position:absolute;z-index:var(--feedback-modal-modal-wrapper-z-index)}.feedback-overlay{background-color:var(--feedback-modal-screenshot-bg-color);height:100%;left:0;opacity:0;position:fixed;top:0;width:100%;z-index:var(--feedback-modal-screnshot-z-index);transition:opacity 0.2s ease-out}.feedback-overlay--visible{opacity:1}.feedback-modal{display:inline-block;position:relative}.feedback-modal-content{background-color:var(--feedback-modal-content-bg-color);border-color:1px solid var(--feedback-modal-header-text-color);border-radius:var(--feedback-modal-content-border-radius);box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .30), 0px 2px 6px 2px rgba(60, 64, 67, .15);box-sizing:border-box;color:var(--feedback-modal-content-text-color);display:flex;flex-direction:column;left:50%;max-width:90%;padding:20px;position:fixed;top:50%;transform:translate(-50%, -50%) scale(0.95);opacity:0;width:100%;z-index:var(--feedback-modal-content-z-index);transition:transform 0.2s ease-out, opacity 0.2s ease-out}.feedback-modal-content--open{transform:translate(-50%, -50%) scale(1);opacity:1}.feedback-modal-header{align-items:center;color:var(--feedback-modal-header-text-color);display:flex;font-size:var(--feedback-header-font-size);font-weight:var(--feedback-modal-header-font-weight);justify-content:space-between;margin-bottom:20px}.feedback-modal-rating-buttons{width:100%;margin-bottom:20px}.feedback-modal-rating-button{padding:0;background-color:transparent;border:transparent;margin-right:5px;cursor:pointer}.feedback-modal-rating-buttons--thumbs .feedback-modal-rating-button{border:1px solid var(--feedback-modal-button-border-color);border-radius:var(--feedback-modal-button-border-radius);color:var(--feedback-modal-button-text-color);font-size:var(--feedback-modal-button-font-size);font-weight:500;margin-right:10px;justify-content:center;padding:5px 10px}.feedback-modal-rating-buttons--thumbs .feedback-modal-rating-button:hover,.feedback-modal-rating-buttons--thumbs .feedback-modal-rating-button--selected{background-color:var(--feedback-modal-button-bg-color-active);border:1px solid var(--feedback-modal-button-border-color-active);color:var(--feedback-modal-button-text-color-active)}.feedback-modal-rating-buttons--thumbs .feedback-modal-rating-button:hover svg,.feedback-modal-rating-buttons--thumbs .feedback-modal-rating-button--selected svg{stroke:var(--feedback-modal-rating-button-selected-color)}.feedback-modal-rating-buttons svg{stroke:var(--feedback-modal-rating-button-color);cursor:pointer}.feedback-modal-rating-buttons--stars .feedback-modal-rating-button--selected svg{fill:var(--feedback-modal-rating-button-stars-selected-color);stroke:var(--feedback-modal-rating-button-stars-selected-color)}.feedback-modal-text textarea{background-color:var(--feedback-modal-input-bg-color);border:1px solid var(--feedback-modal-input-border-color);border-radius:var(--feedback-modal-input-border-radius);box-sizing:border-box;color:var(--feedback-modal-input-text-color);font-size:var(--feedback-modal-input-font-size);margin-bottom:20px;height:100px;min-height:100px;padding:10px;resize:vertical;width:100%}.feedback-modal-email input{background-color:var(--feedback-modal-input-bg-color);border:1px solid var(--feedback-modal-input-border-color);border-radius:var(--feedback-modal-input-border-radius);box-sizing:border-box;color:var(--feedback-modal-input-text-color);font-size:var(--feedback-modal-input-font-size);margin-bottom:20px;height:40px;padding:10px;width:100%;margin-bottom:20px}.feedback-modal-privacy{font-size:var(--feedback-modal-input-font-size);margin-bottom:20px}.feedback-modal-text textarea:focus,.feedback-modal-email input:focus{border:1px solid var(--feedback-modal-input-border-color-focused);outline:none}.feedback-modal-buttons{display:flex;flex-direction:column}.feedback-modal-buttons .feedback-modal-button{margin-bottom:20px}.feedback-modal-button{align-items:center;background-color:transparent;border:1px solid var(--feedback-modal-button-border-color);border-radius:var(--feedback-modal-button-border-radius);color:var(--feedback-modal-button-text-color);cursor:pointer;display:flex;font-size:var(--feedback-modal-button-font-size);font-weight:500;justify-content:center;min-height:40px;padding:5px 10px}.feedback-modal-button svg{margin-right:6px}.feedback-modal-button path{fill:var(--feedback-modal-button-icon-color)}.feedback-modal-button:hover path,.feedback-modal-button--active path{fill:var(--feedback-modal-button-icon-color-active)}.feedback-modal-button--submit{background-color:var(--feedback-modal-button-submit-bg-color);border:1px solid var(--feedback-modal-button-border-color-active);color:var(--feedback-modal-button-submit-text-color)}.feedback-modal-button:hover,.feedback-modal-button--active{background-color:var(--feedback-modal-button-bg-color-active);border:1px solid var(--feedback-modal-button-border-color-active);color:var(--feedback-modal-button-text-color-active)}.feedback-modal-button--submit:hover{background-color:var(--feedback-modal-button-submit-bg-color-hover);border:1px solid var(--feedback-modal-button-submit-border-color-hover);color:var(--feedback-modal-button-submit-text-color-hover)}.feedback-modal-input-heading{display:block;font-size:14px;font-weight:300;padding-bottom:10px}.feedback-modal-footer{font-size:12px;text-align:center}.feedback-modal-footer a{color:var(--feedback-modal-footer-link);font-weight:500;text-decoration:none}.feedback-logo,.feedback-footer-text{display:block;text-align:center;margin-top:5px}.feedback-footer-text{margin-top:10px;line-height:1.5}.feedback-modal-close{background-color:var(--feedback-modal-close-bg-color);border:0;border-radius:50%;cursor:pointer;height:22px;margin-left:auto;padding:0;width:22px}.feedback-modal-close svg{stroke:var(--feedback-modal-close-color)}.feedback-modal-screenshot{background-color:var(--feedback-modal-screenshot-bg-color);height:100%;left:0;position:fixed;top:0;width:100%;z-index:var(--feedback-modal-screnshot-z-index)}.feedback-modal-screenshot-header{align-items:center;background-color:var(--feedback-modal-screenshot-header-bg-color);border-radius:var(--feedback-modal-content-border-radius);box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .30), 0px 2px 6px 2px rgba(60, 64, 67, .15);box-sizing:border-box;color:var(--feedback-modal-screenshot-header-text-color);cursor:pointer;display:flex;left:50%;top:20px;transform:translateX(-50%);padding:10px;position:fixed;width:max-content;z-index:var(--feedback-modal-screenshot-header-z-index)}.feedback-modal-screenshot-close{height:24px;padding-left:10px;width:24px}.feedback-modal-screenshot-close svg{stroke:var(--feedback-modal-close-color)}.feedback-modal-message{font-size:var(--feedback-modal-message-font-size);margin-top:0}.feedback-modal-element-hover{background-color:transparent;cursor:pointer;border:1px solid var(--feedback-modal-element-hover-border-color)}.feedback-modal-element-selected{background-color:transparent;border:3px solid var(--feedback-modal-element-selected-border-color) !important;box-shadow:0 0 0 2px rgba(0, 123, 255, 0.3) !important}.screenshot-preview{display:inline-block;width:30px;height:30px;overflow:hidden;border-radius:4px;margin-right:10px;box-shadow:0 2px 4px rgba(0, 0, 0, 0.1);cursor:pointer;transition:transform 0.2s ease}.screenshot-preview:hover{transform:scale(1.1)}.screenshot-preview img{width:100%;height:100%;object-fit:cover}.screenshot-loading{display:inline-flex;align-items:center;margin-right:8px}.canvas-editor-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background-color:var(--feedback-modal-screenshot-bg-color);z-index:10001;display:flex;align-items:center;justify-content:center}.canvas-editor-modal{width:95vw;height:98vh;background:var(--feedback-canvas-editor-bg-color);border-radius:var(--feedback-modal-content-border-radius);display:flex;flex-direction:column;overflow:hidden;box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .30), 0px 2px 6px 2px rgba(60, 64, 67, .15)}.canvas-editor-header{background:var(--feedback-canvas-editor-header-bg-color);border-bottom:1px solid var(--feedback-canvas-editor-border-color);padding:12px 16px;display:flex;flex-direction:column;gap:12px;flex-shrink:0}.canvas-editor-title h3{margin:0;font-size:var(--feedback-modal-header-font-size);font-weight:var(--feedback-modal-header-font-weight);color:var(--feedback-modal-header-text-color);font-family:var(--feedback-modal-header-font-family)}.canvas-editor-toolbar{display:flex;align-items:center;gap:20px;flex-wrap:wrap}.toolbar-section{display:flex;align-items:center}.toolbar-section:last-child{margin-left:auto;gap:10px}.tool-group{display:flex;align-items:center;background:var(--feedback-canvas-editor-tool-bg-color);border:1px solid var(--feedback-canvas-editor-border-color);border-radius:var(--feedback-modal-button-border-radius);padding:4px;box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .10)}.tool-btn{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;background:none;border-radius:var(--feedback-modal-button-border-radius);cursor:pointer;color:var(--feedback-canvas-editor-tool-text-color);transition:all 0.2s ease;position:relative}.tool-btn:hover{background:var(--feedback-canvas-editor-tool-bg-hover);color:var(--feedback-modal-button-text-color-active)}.tool-btn.active{background:var(--feedback-canvas-editor-tool-bg-active);color:var(--feedback-canvas-editor-tool-text-active)}.tool-btn:disabled{opacity:0.4;cursor:not-allowed}.tool-btn:disabled:hover{background:none;color:var(--feedback-canvas-editor-tool-text-color)}.toolbar-divider{width:1px;height:20px;background:var(--feedback-canvas-editor-divider-color);margin:0 6px}.undo-btn{background:var(--feedback-canvas-editor-tool-bg-color) !important;border:1px solid var(--feedback-canvas-editor-border-color) !important}.undo-btn:hover:not(:disabled){background:var(--feedback-canvas-editor-tool-bg-hover) !important}.color-palette{display:flex;align-items:center;gap:6px;background:var(--feedback-canvas-editor-tool-bg-color);border:1px solid var(--feedback-canvas-editor-border-color);border-radius:var(--feedback-modal-button-border-radius);padding:6px;box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .10)}.color-slot-wrapper{position:relative}.color-btn{width:28px;height:28px;border-radius:var(--feedback-modal-button-border-radius);border:2px solid transparent;cursor:pointer;transition:all 0.2s ease;position:relative;box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .15);display:flex;align-items:center;justify-content:center}.color-btn:hover{transform:scale(1.05);box-shadow:0px 2px 4px 0px rgba(60, 64, 67, .25)}.color-btn.active{border-color:var(--feedback-primary-color);transform:scale(1.1);box-shadow:0 0 0 2px rgba(0, 112, 244, 0.2)}.color-btn.editing{border-color:var(--feedback-highlight-color);box-shadow:0 0 0 2px rgba(255, 180, 34, 0.3)}.color-btn.editing:hover{border-color:var(--feedback-highlight-color);box-shadow:0 0 0 2px rgba(255, 180, 34, 0.4)}.color-picker-dropdown{position:absolute;top:100%;left:50%;transform:translateX(-50%);margin-top:6px;background:var(--feedback-canvas-editor-tool-bg-color);border:1px solid var(--feedback-canvas-editor-border-color);border-radius:var(--feedback-modal-button-border-radius);padding:6px;box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .30), 0px 2px 6px 2px rgba(60, 64, 67, .15);z-index:1000}.color-picker-dropdown input[type=\"color\"]{width:50px;height:32px;border:none;border-radius:var(--feedback-modal-button-border-radius);cursor:pointer}.size-control{display:flex;align-items:center;gap:10px;background:var(--feedback-canvas-editor-tool-bg-color);border:1px solid var(--feedback-canvas-editor-border-color);border-radius:var(--feedback-modal-button-border-radius);padding:6px 12px;box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .10)}.size-slider{width:70px;height:4px;border-radius:2px;background:var(--feedback-canvas-editor-slider-track);outline:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;border:none}.size-slider::-webkit-slider-track{width:100%;height:4px;cursor:pointer;background:var(--feedback-canvas-editor-slider-track);border-radius:2px;border:none;box-shadow:none}.size-slider::-webkit-slider-thumb{-webkit-appearance:none;width:14px;height:14px;border-radius:50%;background:var(--feedback-primary-color);cursor:pointer;box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .20);border:none;margin-top:-5px;}.size-slider::-moz-range-track{width:100%;height:4px;cursor:pointer;background:var(--feedback-canvas-editor-slider-track);border-radius:2px;border:none;box-shadow:none}.size-slider::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--feedback-primary-color);cursor:pointer;border:none;box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .20)}.size-slider::-moz-range-progress{background:var(--feedback-canvas-editor-slider-track);height:4px;border-radius:2px}.size-slider::-ms-track{width:100%;height:4px;cursor:pointer;background:transparent;border-color:transparent;color:transparent}.size-slider::-ms-fill-lower{background:var(--feedback-canvas-editor-slider-track);border-radius:2px}.size-slider::-ms-fill-upper{background:var(--feedback-canvas-editor-slider-track);border-radius:2px}.size-slider::-ms-thumb{width:14px;height:14px;border-radius:50%;background:var(--feedback-primary-color);cursor:pointer;border:none}.size-value{font-weight:500;color:var(--feedback-canvas-editor-tool-text-color);font-size:var(--feedback-text-font-size);min-width:30px}.action-btn{display:flex;align-items:center;gap:6px;padding:5px 12px;border:1px solid var(--feedback-canvas-editor-action-secondary-border);border-radius:var(--feedback-modal-button-border-radius);cursor:pointer;font-size:var(--feedback-modal-button-font-size);font-weight:500;transition:all 0.2s ease;min-width:65px;justify-content:center;height:36px;font-family:var(--feedback-font-family)}.action-btn.secondary{background:var(--feedback-canvas-editor-action-secondary-bg);color:var(--feedback-canvas-editor-action-secondary-text);border-color:var(--feedback-canvas-editor-action-secondary-border)}.action-btn.secondary:hover{background:var(--feedback-canvas-editor-tool-bg-hover);color:var(--feedback-modal-button-text-color-active);border-color:var(--feedback-modal-button-border-color-active)}.action-btn.primary{background:var(--feedback-canvas-editor-action-primary-bg);color:var(--feedback-canvas-editor-action-primary-text);border-color:var(--feedback-modal-button-border-color-active)}.action-btn.primary:hover{background:var(--feedback-modal-button-submit-bg-color-hover);border-color:var(--feedback-modal-button-submit-border-color-hover)}.canvas-editor-content{flex:1;display:flex;align-items:center;justify-content:center;padding:16px;background:var(--feedback-canvas-editor-content-bg);overflow:hidden;min-height:0;min-width:0}.annotation-canvas{max-width:100%;max-height:100%;width:auto;height:auto;cursor:crosshair;border-radius:var(--feedback-modal-content-border-radius);box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .30), 0px 2px 6px 2px rgba(60, 64, 67, .15);background:var(--feedback-white-color);transition:box-shadow 0.3s ease;object-fit:contain;display:block}.annotation-canvas:hover{box-shadow:0px 2px 4px 0px rgba(60, 64, 67, .35), 0px 4px 12px 4px rgba(60, 64, 67, .20)}@media screen and (min-width: 768px){.feedback-modal-content{max-width:var(--feedback-modal-content-max-width)}.feedback-modal-content.feedback-modal-content--bottom-right{bottom:var(--feedback-modal-content-position-bottom);left:initial;right:var(--feedback-modal-content-position-right);top:initial;transform:initial}.feedback-modal-content.feedback-modal-content--bottom-left{bottom:var(--feedback-modal-content-position-bottom);left:var(--feedback-modal-content-position-left);top:initial;transform:initial}.feedback-modal-content.feedback-modal-content--top-right{right:var(--feedback-modal-content-position-right);top:var(--feedback-modal-content-position-top);transform:initial}.feedback-modal-content.feedback-modal-content--top-left{left:var(--feedback-modal-content-position-left);top:var(--feedback-modal-content-position-top);transform:initial}.feedback-modal-content.feedback-modal-content--center-left{left:5px;right:auto;top:50%;transform:translateY(-50%)}.feedback-modal-content.feedback-modal-content--center-right{left:auto;right:5px;top:50%;transform:translateY(-50%)}.feedback-modal-content.feedback-modal-content--sidebar-left.feedback-modal-content--open,.feedback-modal-content.feedback-modal-content--sidebar-right.feedback-modal-content--open{transform:translateX(0)}.feedback-modal-content.feedback-modal-content--sidebar-left{max-width:var(--feedback-modal-content-sidebar-max-width);left:0;right:auto;height:100vh;top:0;transform:translateX(-100%);transition:transform 0.5s ease-in-out;border-radius:0}.feedback-modal-content.feedback-modal-content--sidebar-right{max-width:var(--feedback-modal-content-sidebar-max-width);left:auto;right:0;height:100vh;top:0;transform:translateX(100%);transition:transform 0.5s ease-in-out;border-radius:0}.feedback-modal-text textarea{height:150px;min-height:150px}.feedback-modal-content.feedback-modal-content--bottom-right{transform:translateY(20px)}.feedback-modal-content.feedback-modal-content--bottom-right.feedback-modal-content--open{transform:translateY(0)}.feedback-modal-content.feedback-modal-content--bottom-left{transform:translateY(20px)}.feedback-modal-content.feedback-modal-content--bottom-left.feedback-modal-content--open{transform:translateY(0)}.feedback-modal-content.feedback-modal-content--top-right{transform:translateY(-20px)}.feedback-modal-content.feedback-modal-content--top-right.feedback-modal-content--open{transform:translateY(0)}.feedback-modal-content.feedback-modal-content--top-left{transform:translateY(-20px)}.feedback-modal-content.feedback-modal-content--top-left.feedback-modal-content--open{transform:translateY(0)}}@media (max-width: 768px){.canvas-editor-modal{width:100vw;height:100vh;border-radius:0}.canvas-editor-header{padding:8px 12px;gap:8px}.canvas-editor-toolbar{flex-direction:column;align-items:stretch;gap:12px}.toolbar-section{justify-content:center}.toolbar-section:last-child{margin-left:0;justify-content:stretch;gap:8px}.action-btn{flex:1;min-width:auto}.canvas-editor-content{padding:8px}.tool-group{flex-wrap:wrap;justify-content:center}.color-palette{flex-wrap:wrap;justify-content:center}.size-control{flex-direction:column;gap:6px;text-align:center}.size-slider{width:100px}}@keyframes feather-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.feather-loader{animation:feather-spin 1s linear infinite;display:block}.screenshot-error-notification{position:fixed;top:20px;left:50%;transform:translateX(-50%);z-index:10001;max-width:500px;width:90%;animation:slideDown 0.3s ease-out}@keyframes slideDown{from{opacity:0;transform:translateX(-50%) translateY(-20px)}to{opacity:1;transform:translateX(-50%) translateY(0)}}.screenshot-error-content{background:#fee;border:1px solid #fcc;border-radius:8px;padding:12px 16px;display:flex;align-items:center;gap:12px;box-shadow:0 4px 12px rgba(0, 0, 0, 0.15);color:#c53030}.screenshot-error-content svg:first-child{color:#e53e3e;flex-shrink:0}.screenshot-error-content span{flex:1;font-size:14px;line-height:1.4;font-weight:500}.error-close-btn{background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:#c53030;flex-shrink:0;transition:background-color 0.2s ease}.error-close-btn:hover{background:rgba(197, 48, 48, 0.1)}@media (max-width: 768px){.canvas-editor-toolbar .tool-group,.canvas-editor-toolbar .color-palette,.canvas-editor-toolbar .size-control,.canvas-editor-toolbar .toolbar-divider{display:none !important}.canvas-editor-toolbar{justify-content:center}.canvas-editor-toolbar .toolbar-section:first-child{display:none}.canvas-editor-toolbar .toolbar-section:nth-child(2){display:none}.canvas-editor-toolbar .toolbar-section:nth-child(3){display:none}.canvas-editor-title{display:none}}";
191
-
192
- const FeedbackModal = class {
193
- constructor(hostRef) {
194
- registerInstance(this, hostRef);
195
- this.feedbackSent = createEvent(this, "feedbackSent", 7);
196
- this.feedbackError = createEvent(this, "feedbackError", 7);
197
- this.onScrollDebounced = () => {
198
- clearTimeout(this.scrollTimeout);
199
- this.scrollTimeout = setTimeout(() => {
200
- document.documentElement.classList.remove('feedback-modal-screenshot-closing');
201
- document.documentElement.style.top = '';
202
- window.removeEventListener('scroll', this.onScrollDebounced);
203
- }, 200);
204
- };
205
- this.handleSubmit = async (event) => {
206
- event.preventDefault();
207
- if (this.isEmailRequired && !this.formEmail) {
208
- return;
209
- }
210
- this.resetOverflow();
211
- this.showScreenshotMode = false;
212
- this.showScreenshotTopBar = false;
213
- this.showModal = false;
214
- this.sending = true;
215
- try {
216
- const body = {
217
- url: window.location.href,
218
- message: this.formMessage,
219
- email: this.formEmail,
220
- project: this.project,
221
- screenshot: this.encodedScreenshot,
222
- rating: this.selectedRating,
223
- ratingMode: this.ratingMode,
224
- metadata: this.metadata,
225
- verification: this.formVerification,
226
- session: localStorage.getItem('pushfeedback_sessionid') || '',
227
- };
228
- const res = await fetch('https://app.pushfeedback.com/api/feedback/', {
229
- method: 'POST',
230
- body: JSON.stringify(body),
231
- headers: {
232
- 'Content-Type': 'application/json',
233
- },
234
- });
235
- if (res.status === 201) {
236
- const feedback_with_id = Object.assign(Object.assign({}, body), { id: await res.json() });
237
- this.feedbackSent.emit({ feedback: feedback_with_id });
238
- this.formSuccess = true;
239
- this.formError = false;
240
- }
241
- else {
242
- const errorText = await res.text();
243
- const response = {
244
- status: res.status,
245
- message: errorText,
246
- };
247
- this.feedbackError.emit({ error: response });
248
- this.formSuccess = false;
249
- this.formError = true;
250
- this.formErrorStatus = res.status;
251
- }
252
- }
253
- catch (error) {
254
- const response = {
255
- status: 500,
256
- message: error,
257
- };
258
- this.feedbackError.emit({ error: response });
259
- this.formSuccess = false;
260
- this.formError = true;
261
- this.formErrorStatus = 500;
262
- }
263
- finally {
264
- this.sending = false;
265
- this.showModal = true;
266
- }
267
- };
268
- this.close = () => {
269
- this.isAnimating = false;
270
- setTimeout(() => {
271
- this.sending = false;
272
- this.showModal = false;
273
- this.showScreenshotMode = false;
274
- this.showScreenshotTopBar = false;
275
- this.hasSelectedElement = false;
276
- this.encodedScreenshot = null;
277
- // Remove highlight from ALL selected elements
278
- document.querySelectorAll('.feedback-modal-element-selected').forEach(el => {
279
- el.classList.remove('feedback-modal-element-selected');
280
- });
281
- // Reset canvas editor states
282
- this.takingScreenshot = false;
283
- this.showPreviewModal = false;
284
- this.showCanvasEditor = false;
285
- this.annotations = [];
286
- this.currentAnnotation = null;
287
- this.isDrawing = false;
288
- this.canvasRef = null;
289
- this.canvasContext = null;
290
- this.originalImageData = null;
291
- // Reset error states
292
- this.showScreenshotError = false;
293
- this.screenshotError = '';
294
- // Reset resizing states
295
- this.isResizing = false;
296
- this.resizingAnnotation = null;
297
- this.resizeStartSize = 16;
298
- this.resizeStartDimensions = null;
299
- this.hoveredAnnotation = null;
300
- this.resizeHandle = false;
301
- // Reset form states
302
- this.formSuccess = false;
303
- this.formError = false;
304
- this.formErrorStatus = 500;
305
- this.formMessage = '';
306
- this.formEmail = '';
307
- this.resetOverflow();
308
- }, 200);
309
- };
310
- this.openScreenShot = async () => {
311
- // Show loading state immediately
312
- this.takingScreenshot = true;
313
- this.showScreenshotError = false;
314
- // Clear any previous annotations when taking a new screenshot
315
- this.annotations = [];
316
- this.currentAnnotation = null;
317
- this.isDrawing = false;
318
- this.hoveredAnnotation = null;
319
- // Hide the feedback modal temporarily to exclude it from screenshot
320
- const wasModalVisible = this.showModal;
321
- this.showModal = false;
322
- // Also hide any feedback buttons on the page
323
- this.hideAllFeedbackElements();
324
- try {
325
- // Wait a moment for UI to update before capturing
326
- await new Promise(resolve => setTimeout(resolve, 100));
327
- // Capture viewport screenshot using browser API
328
- const dataUrl = await this.captureViewportScreenshot();
329
- this.encodedScreenshot = dataUrl;
330
- this.originalImageData = dataUrl;
331
- // Reset loading state
332
- this.takingScreenshot = false;
333
- // Go directly to canvas editor (don't restore modal)
334
- this.showCanvasEditor = true;
335
- // Restore feedback elements visibility
336
- this.showAllFeedbackElements();
337
- // Initialize canvas after a short delay to ensure DOM is ready
338
- setTimeout(() => {
339
- this.initializeCanvas();
340
- }, 100);
341
- }
342
- catch (error) {
343
- console.error('Failed to capture screenshot:', error);
344
- // Reset loading state on error
345
- this.takingScreenshot = false;
346
- // Restore modal and feedback elements on error
347
- this.showModal = wasModalVisible;
348
- this.showAllFeedbackElements();
349
- // Show error message to user
350
- this.handleScreenshotError(error);
351
- }
352
- };
353
- this.hideAllFeedbackElements = () => {
354
- // Hide all feedback buttons and modals on the page
355
- const feedbackElements = document.querySelectorAll('feedback-button, feedback-modal');
356
- feedbackElements.forEach(element => {
357
- element.style.visibility = 'hidden';
358
- });
359
- };
360
- this.showAllFeedbackElements = () => {
361
- // Show all feedback buttons and modals on the page
362
- const feedbackElements = document.querySelectorAll('feedback-button, feedback-modal');
363
- feedbackElements.forEach(element => {
364
- element.style.visibility = 'visible';
365
- });
366
- };
367
- this.handleScreenshotError = (error) => {
368
- let errorMessage = 'Failed to capture screenshot. ';
369
- if (error.name === 'NotAllowedError') {
370
- errorMessage += 'Permission denied. Please allow screen sharing to take screenshots.';
371
- }
372
- else if (error.name === 'NotSupportedError') {
373
- errorMessage += 'Screen capture is not supported in this browser.';
374
- }
375
- else if (error.name === 'NotFoundError') {
376
- errorMessage += 'No screen sources available for capture.';
377
- }
378
- else if (error.name === 'AbortError') {
379
- errorMessage += 'Screenshot capture was cancelled.';
380
- }
381
- else if (error.message && error.message.includes('not supported')) {
382
- errorMessage += 'Your browser does not support screen capture. Please use a browser like Chrome, Firefox, or Safari.';
383
- }
384
- else {
385
- errorMessage += 'An unexpected error occurred. Please try again.';
386
- }
387
- this.screenshotError = errorMessage;
388
- this.showScreenshotError = true;
389
- // Auto-hide error after 5 seconds
390
- setTimeout(() => {
391
- this.showScreenshotError = false;
392
- }, 5000);
393
- };
394
- this.openCanvasEditor = (event) => {
395
- if (event) {
396
- event.stopPropagation();
397
- }
398
- this.showModal = false;
399
- this.showCanvasEditor = true;
400
- // Initialize canvas after a short delay to ensure DOM is ready
401
- setTimeout(() => {
402
- this.initializeCanvas();
403
- }, 100);
404
- };
405
- this.closeCanvasEditor = () => {
406
- this.showCanvasEditor = false;
407
- this.showModal = true;
408
- };
409
- this.saveAnnotations = () => {
410
- if (this.canvasRef) {
411
- // Create final image with annotations
412
- const finalDataUrl = this.canvasRef.toDataURL('image/png');
413
- this.encodedScreenshot = finalDataUrl;
414
- }
415
- this.showCanvasEditor = false;
416
- this.showModal = true;
417
- };
418
- this.initializeCanvas = () => {
419
- if (!this.canvasRef || !this.originalImageData)
420
- return;
421
- this.canvasContext = this.canvasRef.getContext('2d');
422
- const img = new Image();
423
- img.onload = () => {
424
- // Set canvas to original image dimensions
425
- this.canvasRef.width = img.width;
426
- this.canvasRef.height = img.height;
427
- // Get available container dimensions
428
- const containerWidth = this.canvasRef.parentElement.clientWidth - 32; // Account for reduced padding (16px * 2)
429
- const containerHeight = this.canvasRef.parentElement.clientHeight - 32;
430
- // Calculate scale factors for both dimensions
431
- const scaleX = containerWidth / img.width;
432
- const scaleY = containerHeight / img.height;
433
- // Use the smaller scale to ensure complete image fits
434
- const scale = Math.min(scaleX, scaleY, 1); // Never scale up, only down
435
- // Calculate final display dimensions
436
- const displayWidth = img.width * scale;
437
- const displayHeight = img.height * scale;
438
- // Set CSS size for display (this scales the canvas visually)
439
- this.canvasRef.style.width = `${displayWidth}px`;
440
- this.canvasRef.style.height = `${displayHeight}px`;
441
- console.log('Canvas initialized with complete image fit:', {
442
- originalWidth: img.width,
443
- originalHeight: img.height,
444
- displayWidth,
445
- displayHeight,
446
- scale,
447
- scaleX,
448
- scaleY,
449
- containerWidth,
450
- containerHeight,
451
- usingScale: scale === scaleX ? 'width-limited' : 'height-limited'
452
- });
453
- // Draw the original image at full resolution
454
- this.canvasContext.drawImage(img, 0, 0);
455
- // Redraw existing annotations
456
- this.redrawAnnotations();
457
- };
458
- img.src = this.originalImageData;
459
- };
460
- this.redrawAnnotations = () => {
461
- if (!this.canvasContext)
462
- return;
463
- // Clear and redraw background image
464
- const img = new Image();
465
- img.onload = () => {
466
- this.canvasContext.clearRect(0, 0, this.canvasRef.width, this.canvasRef.height);
467
- this.canvasContext.drawImage(img, 0, 0);
468
- // Draw all annotations
469
- this.annotations.forEach(annotation => {
470
- this.drawAnnotation(annotation);
471
- });
472
- };
473
- img.src = this.originalImageData;
474
- };
475
- this.drawAnnotation = (annotation) => {
476
- if (!this.canvasContext)
477
- return;
478
- this.canvasContext.strokeStyle = annotation.color;
479
- this.canvasContext.lineWidth = annotation.lineWidth;
480
- this.canvasContext.lineCap = 'round';
481
- this.canvasContext.lineJoin = 'round';
482
- switch (annotation.type) {
483
- case 'rectangle':
484
- this.canvasContext.strokeRect(annotation.startX, annotation.startY, annotation.width, annotation.height);
485
- // Draw resize handle if this annotation is hovered
486
- if (this.hoveredAnnotation === annotation) {
487
- this.drawRectangleResizeHandles(annotation);
488
- }
489
- break;
490
- case 'line':
491
- this.canvasContext.beginPath();
492
- this.canvasContext.moveTo(annotation.startX, annotation.startY);
493
- this.canvasContext.lineTo(annotation.endX, annotation.endY);
494
- this.canvasContext.stroke();
495
- // Draw resize handles if this annotation is hovered
496
- if (this.hoveredAnnotation === annotation) {
497
- this.drawLineResizeHandles(annotation);
498
- }
499
- break;
500
- case 'arrow':
501
- this.drawArrow(annotation.startX, annotation.startY, annotation.endX, annotation.endY);
502
- // Draw resize handles if this annotation is hovered
503
- if (this.hoveredAnnotation === annotation) {
504
- this.drawLineResizeHandles(annotation); // Same as line
505
- }
506
- break;
507
- case 'text':
508
- const fontSize = annotation.fontSize || 16;
509
- this.canvasContext.fillStyle = annotation.color;
510
- this.canvasContext.font = `${fontSize}px Arial`;
511
- this.canvasContext.fillText(annotation.text, annotation.x, annotation.y);
512
- // Draw resize handle if this annotation is hovered
513
- if (this.hoveredAnnotation === annotation) {
514
- this.drawTextResizeHandle(annotation);
515
- }
516
- break;
517
- }
518
- };
519
- // Draw resize handle for text annotation
520
- this.drawTextResizeHandle = (annotation) => {
521
- if (!this.canvasContext || annotation.type !== 'text')
522
- return;
523
- const fontSize = annotation.fontSize || 16;
524
- const textWidth = this.getTextWidth(annotation.text, fontSize);
525
- const handleSize = 8;
526
- const handleX = annotation.x + textWidth;
527
- const handleY = annotation.y;
528
- // Draw resize handle (small square) - using widget primary color
529
- this.canvasContext.fillStyle = '#0070F4'; // var(--feedback-primary-color)
530
- this.canvasContext.strokeStyle = '#ffffff';
531
- this.canvasContext.lineWidth = 2;
532
- this.canvasContext.fillRect(handleX - handleSize / 2, handleY - handleSize / 2, handleSize, handleSize);
533
- this.canvasContext.strokeRect(handleX - handleSize / 2, handleY - handleSize / 2, handleSize, handleSize);
534
- };
535
- this.drawArrow = (fromX, fromY, toX, toY) => {
536
- const headlen = 15; // Arrow head length
537
- const angle = Math.atan2(toY - fromY, toX - fromX);
538
- // Draw line
539
- this.canvasContext.beginPath();
540
- this.canvasContext.moveTo(fromX, fromY);
541
- this.canvasContext.lineTo(toX, toY);
542
- this.canvasContext.stroke();
543
- // Draw arrow head
544
- this.canvasContext.beginPath();
545
- this.canvasContext.moveTo(toX, toY);
546
- this.canvasContext.lineTo(toX - headlen * Math.cos(angle - Math.PI / 6), toY - headlen * Math.sin(angle - Math.PI / 6));
547
- this.canvasContext.moveTo(toX, toY);
548
- this.canvasContext.lineTo(toX - headlen * Math.cos(angle + Math.PI / 6), toY - headlen * Math.sin(angle + Math.PI / 6));
549
- this.canvasContext.stroke();
550
- };
551
- this.undoLastAnnotation = () => {
552
- this.annotations = this.annotations.slice(0, -1);
553
- this.redrawAnnotations();
554
- };
555
- // Handle color slot editing
556
- this.handleColorSlotClick = (colorIndex) => {
557
- if (this.editingColorIndex === colorIndex) {
558
- // If already editing this slot, just select the color
559
- this.canvasDrawingColor = this.defaultColors[colorIndex];
560
- this.showColorPicker = false;
561
- this.editingColorIndex = -1;
562
- }
563
- else {
564
- // Start editing this color slot
565
- this.editingColorIndex = colorIndex;
566
- this.showColorPicker = true;
567
- this.canvasDrawingColor = this.defaultColors[colorIndex];
568
- }
569
- };
570
- // Update color in slot
571
- this.updateColorSlot = (newColor) => {
572
- if (this.editingColorIndex >= 0 && this.editingColorIndex < this.defaultColors.length) {
573
- this.defaultColors[this.editingColorIndex] = newColor;
574
- this.canvasDrawingColor = newColor;
575
- this.showColorPicker = false;
576
- this.editingColorIndex = -1;
577
- // Force reactivity
578
- this.defaultColors = [...this.defaultColors];
579
- }
580
- };
581
- // Handle color picker input without closing
582
- this.handleColorPickerInput = (event) => {
583
- event.stopPropagation();
584
- const newColor = event.target.value;
585
- if (this.editingColorIndex >= 0 && this.editingColorIndex < this.defaultColors.length) {
586
- this.defaultColors[this.editingColorIndex] = newColor;
587
- this.canvasDrawingColor = newColor;
588
- // Force reactivity
589
- this.defaultColors = [...this.defaultColors];
590
- }
591
- };
592
- // Handle color picker click to prevent closing
593
- this.handleColorPickerClick = (event) => {
594
- event.stopPropagation();
595
- };
596
- // Close color picker
597
- this.closeColorPicker = () => {
598
- this.showColorPicker = false;
599
- this.editingColorIndex = -1;
600
- };
601
- // Check if point is in resize handle for any annotation type
602
- this.isPointInResizeHandle = (x, y, annotation) => {
603
- const handleSize = 8;
604
- switch (annotation.type) {
605
- case 'text':
606
- const textWidth = this.getTextWidth(annotation.text, annotation.fontSize || 16);
607
- const handleX = annotation.x + textWidth;
608
- const handleY = annotation.y;
609
- return x >= handleX - handleSize / 2 && x <= handleX + handleSize / 2 &&
610
- y >= handleY - handleSize / 2 && y <= handleY + handleSize / 2;
611
- case 'rectangle':
612
- const right = annotation.startX + annotation.width;
613
- const bottom = annotation.startY + annotation.height;
614
- // Only check bottom-right corner handle
615
- return x >= right - handleSize / 2 && x <= right + handleSize / 2 &&
616
- y >= bottom - handleSize / 2 && y <= bottom + handleSize / 2;
617
- case 'line':
618
- case 'arrow':
619
- // Check both endpoint handles
620
- const lineHandles = [
621
- { x: annotation.startX, y: annotation.startY, point: 'start' },
622
- { x: annotation.endX, y: annotation.endY, point: 'end' }
623
- ];
624
- for (const handle of lineHandles) {
625
- if (x >= handle.x - handleSize / 2 && x <= handle.x + handleSize / 2 &&
626
- y >= handle.y - handleSize / 2 && y <= handle.y + handleSize / 2) {
627
- return handle.point; // Return which endpoint was clicked
628
- }
629
- }
630
- return false;
631
- default:
632
- return false;
633
- }
634
- };
635
- // Get text width for resize handle positioning
636
- this.getTextWidth = (text, fontSize) => {
637
- // Approximate text width calculation
638
- return text.length * fontSize * 0.6;
639
- };
640
- // Start text resize
641
- this.startTextResize = (annotation, startPos) => {
642
- this.isResizing = true;
643
- this.resizingAnnotation = annotation;
644
- this.resizeStartSize = annotation.fontSize || 16;
645
- this.dragStartPos = startPos;
646
- };
647
- // Handle text resize
648
- this.handleTextResize = (currentPos) => {
649
- if (!this.resizingAnnotation || !this.dragStartPos)
650
- return;
651
- const deltaX = currentPos.x - this.dragStartPos.x;
652
- const deltaY = currentPos.y - this.dragStartPos.y;
653
- const avgDelta = (deltaX + deltaY) / 2;
654
- // Calculate new font size (minimum 8px, maximum 72px)
655
- const newSize = Math.max(8, Math.min(72, this.resizeStartSize + avgDelta * 0.5));
656
- // Update annotation font size
657
- const index = this.annotations.findIndex(a => a === this.resizingAnnotation);
658
- if (index !== -1) {
659
- this.annotations[index] = Object.assign(Object.assign({}, this.resizingAnnotation), { fontSize: Math.round(newSize) });
660
- this.resizingAnnotation = this.annotations[index];
661
- }
662
- this.redrawAnnotations();
663
- };
664
- // Start resize for any annotation type
665
- this.startResize = (annotation, handle, startPos) => {
666
- this.isResizing = true;
667
- this.resizingAnnotation = annotation;
668
- this.resizeHandle = handle;
669
- this.dragStartPos = startPos;
670
- // Store original values for different annotation types
671
- if (annotation.type === 'text') {
672
- this.resizeStartSize = annotation.fontSize || 16;
673
- }
674
- else if (annotation.type === 'rectangle') {
675
- this.resizeStartDimensions = { width: annotation.width, height: annotation.height };
676
- }
677
- };
678
- // Enhanced mouse down handler with resize detection for all annotation types
679
- this.handleCanvasMouseDown = (event) => {
680
- if (!this.canvasRef)
681
- return;
682
- // Disable drawing on mobile devices
683
- if (window.innerWidth <= 768)
684
- return;
685
- // Close color picker if open
686
- if (this.showColorPicker) {
687
- this.closeColorPicker();
688
- }
689
- const coords = this.getCanvasCoordinates(event);
690
- // Check if clicking on existing annotation first
691
- const found = this.findAnnotationAt(coords.x, coords.y);
692
- if (found) {
693
- // Check if clicking on resize handle for any annotation type
694
- const handle = this.isPointInResizeHandle(coords.x, coords.y, found.annotation);
695
- if (handle) {
696
- this.startResize(found.annotation, handle, coords);
697
- this.canvasRef.style.cursor = 'nw-resize';
698
- return;
699
- }
700
- // Start dragging existing annotation
701
- if (!this.isDrawing) {
702
- this.isDragging = true;
703
- this.draggedAnnotation = found.annotation;
704
- this.dragStartPos = coords;
705
- this.canvasRef.style.cursor = 'grabbing';
706
- return;
707
- }
708
- }
709
- // Original drawing logic
710
- this.isDrawing = true;
711
- if (this.canvasDrawingTool === 'text') {
712
- const text = prompt('Enter text:');
713
- if (text) {
714
- const annotation = {
715
- type: 'text',
716
- x: coords.x,
717
- y: coords.y,
718
- text,
719
- color: this.canvasDrawingColor,
720
- fontSize: 16
721
- };
722
- this.annotations = [...this.annotations, annotation];
723
- this.redrawAnnotations();
724
- }
725
- this.isDrawing = false;
726
- }
727
- else {
728
- this.currentAnnotation = {
729
- type: this.canvasDrawingTool,
730
- startX: coords.x,
731
- startY: coords.y,
732
- color: this.canvasDrawingColor,
733
- lineWidth: this.canvasLineWidth
734
- };
735
- }
736
- };
737
- this.handleCanvasMouseMove = (event) => {
738
- if (!this.canvasRef)
739
- return;
740
- // Disable drawing on mobile devices
741
- if (window.innerWidth <= 768)
742
- return;
743
- const coords = this.getCanvasCoordinates(event);
744
- // Handle resizing for any annotation type
745
- if (this.isResizing && this.resizingAnnotation) {
746
- this.handleResize(coords);
747
- return;
748
- }
749
- // Handle dragging existing annotation
750
- if (this.isDragging && this.draggedAnnotation && this.dragStartPos) {
751
- const deltaX = coords.x - this.dragStartPos.x;
752
- const deltaY = coords.y - this.dragStartPos.y;
753
- // Update annotation position
754
- const updatedAnnotation = Object.assign({}, this.draggedAnnotation);
755
- switch (updatedAnnotation.type) {
756
- case 'rectangle':
757
- updatedAnnotation.startX += deltaX;
758
- updatedAnnotation.startY += deltaY;
759
- break;
760
- case 'line':
761
- case 'arrow':
762
- updatedAnnotation.startX += deltaX;
763
- updatedAnnotation.startY += deltaY;
764
- updatedAnnotation.endX += deltaX;
765
- updatedAnnotation.endY += deltaY;
766
- break;
767
- case 'text':
768
- updatedAnnotation.x += deltaX;
769
- updatedAnnotation.y += deltaY;
770
- break;
771
- }
772
- // Update annotation in array
773
- const index = this.annotations.findIndex(a => a === this.draggedAnnotation);
774
- if (index !== -1) {
775
- this.annotations[index] = updatedAnnotation;
776
- this.draggedAnnotation = updatedAnnotation;
777
- }
778
- this.dragStartPos = coords;
779
- this.redrawAnnotations();
780
- return;
781
- }
782
- // Handle drawing new annotation
783
- if (this.isDrawing && this.currentAnnotation) {
784
- if (this.canvasDrawingTool === 'rectangle') {
785
- this.currentAnnotation.width = coords.x - this.currentAnnotation.startX;
786
- this.currentAnnotation.height = coords.y - this.currentAnnotation.startY;
787
- }
788
- else {
789
- this.currentAnnotation.endX = coords.x;
790
- this.currentAnnotation.endY = coords.y;
791
- }
792
- this.redrawAnnotations();
793
- this.drawAnnotation(this.currentAnnotation);
794
- return;
795
- }
796
- // Handle hover states and cursor changes
797
- const found = this.findAnnotationAt(coords.x, coords.y);
798
- if (found) {
799
- // Check if hovering over resize handle for any annotation type
800
- const handle = this.isPointInResizeHandle(coords.x, coords.y, found.annotation);
801
- if (handle) {
802
- this.canvasRef.style.cursor = 'nw-resize';
803
- this.hoveredAnnotation = found.annotation;
804
- this.redrawAnnotations();
805
- return;
806
- }
807
- // Regular hover over annotation
808
- this.canvasRef.style.cursor = 'grab';
809
- if (this.hoveredAnnotation !== found.annotation) {
810
- this.hoveredAnnotation = found.annotation;
811
- this.redrawAnnotations();
812
- }
813
- }
814
- else {
815
- // No annotation under cursor
816
- this.canvasRef.style.cursor = 'crosshair';
817
- if (this.hoveredAnnotation) {
818
- this.hoveredAnnotation = null;
819
- this.redrawAnnotations();
820
- }
821
- }
822
- };
823
- this.handleCanvasMouseUp = () => {
824
- // Disable drawing on mobile devices
825
- if (window.innerWidth <= 768)
826
- return;
827
- // Handle end of resizing
828
- if (this.isResizing) {
829
- this.isResizing = false;
830
- this.resizingAnnotation = null;
831
- this.dragStartPos = null;
832
- this.resizeHandle = false;
833
- this.resizeStartDimensions = null;
834
- if (this.canvasRef) {
835
- this.canvasRef.style.cursor = 'crosshair';
836
- }
837
- return;
838
- }
839
- // Handle end of dragging
840
- if (this.isDragging) {
841
- this.isDragging = false;
842
- this.draggedAnnotation = null;
843
- this.dragStartPos = null;
844
- if (this.canvasRef) {
845
- this.canvasRef.style.cursor = 'crosshair';
846
- }
847
- return;
848
- }
849
- // Handle end of drawing
850
- if (!this.isDrawing || !this.currentAnnotation)
851
- return;
852
- this.isDrawing = false;
853
- this.annotations = [...this.annotations, this.currentAnnotation];
854
- this.currentAnnotation = null;
855
- this.redrawAnnotations();
856
- };
857
- // Draw resize handles for rectangle annotation (only bottom-right corner)
858
- this.drawRectangleResizeHandles = (annotation) => {
859
- if (!this.canvasContext || annotation.type !== 'rectangle')
860
- return;
861
- const handleSize = 8;
862
- const right = annotation.startX + annotation.width;
863
- const bottom = annotation.startY + annotation.height;
864
- // Only draw bottom-right corner handle
865
- const handle = { x: right, y: bottom };
866
- // Draw the handle
867
- this.canvasContext.fillStyle = '#0070F4'; // Primary color
868
- this.canvasContext.strokeStyle = '#ffffff';
869
- this.canvasContext.lineWidth = 2;
870
- this.canvasContext.fillRect(handle.x - handleSize / 2, handle.y - handleSize / 2, handleSize, handleSize);
871
- this.canvasContext.strokeRect(handle.x - handleSize / 2, handle.y - handleSize / 2, handleSize, handleSize);
872
- };
873
- // Draw resize handles for line/arrow annotation
874
- this.drawLineResizeHandles = (annotation) => {
875
- if (!this.canvasContext || (annotation.type !== 'line' && annotation.type !== 'arrow'))
876
- return;
877
- const handleSize = 8;
878
- // Define handle positions (2 endpoints)
879
- const handles = [
880
- { x: annotation.startX, y: annotation.startY },
881
- { x: annotation.endX, y: annotation.endY } // End point
882
- ];
883
- // Draw each handle
884
- this.canvasContext.fillStyle = '#0070F4'; // Primary color
885
- this.canvasContext.strokeStyle = '#ffffff';
886
- this.canvasContext.lineWidth = 2;
887
- handles.forEach(handle => {
888
- this.canvasContext.fillRect(handle.x - handleSize / 2, handle.y - handleSize / 2, handleSize, handleSize);
889
- this.canvasContext.strokeRect(handle.x - handleSize / 2, handle.y - handleSize / 2, handleSize, handleSize);
890
- });
891
- };
892
- // Convert screen coordinates to canvas coordinates
893
- this.getCanvasCoordinates = (event) => {
894
- if (!this.canvasRef)
895
- return { x: 0, y: 0 };
896
- const rect = this.canvasRef.getBoundingClientRect();
897
- // Calculate the scale factor between display size and actual canvas size
898
- const scaleX = this.canvasRef.width / rect.width;
899
- const scaleY = this.canvasRef.height / rect.height;
900
- const x = (event.clientX - rect.left) * scaleX;
901
- const y = (event.clientY - rect.top) * scaleY;
902
- return { x, y };
903
- };
904
- // Find annotation under mouse cursor
905
- this.findAnnotationAt = (x, y) => {
906
- // Check in reverse order (top to bottom)
907
- for (let i = this.annotations.length - 1; i >= 0; i--) {
908
- const annotation = this.annotations[i];
909
- if (this.isPointInAnnotation(x, y, annotation)) {
910
- return { annotation, index: i };
911
- }
912
- }
913
- return null;
914
- };
915
- // Check if point is within annotation bounds
916
- this.isPointInAnnotation = (x, y, annotation) => {
917
- const tolerance = 10; // Click tolerance
918
- switch (annotation.type) {
919
- case 'rectangle':
920
- const left = Math.min(annotation.startX, annotation.startX + annotation.width);
921
- const right = Math.max(annotation.startX, annotation.startX + annotation.width);
922
- const top = Math.min(annotation.startY, annotation.startY + annotation.height);
923
- const bottom = Math.max(annotation.startY, annotation.startY + annotation.height);
924
- return x >= left - tolerance && x <= right + tolerance &&
925
- y >= top - tolerance && y <= bottom + tolerance;
926
- case 'line':
927
- case 'arrow':
928
- // Distance from point to line
929
- const A = annotation.endY - annotation.startY;
930
- const B = annotation.startX - annotation.endX;
931
- const C = annotation.endX * annotation.startY - annotation.startX * annotation.endY;
932
- const distance = Math.abs(A * x + B * y + C) / Math.sqrt(A * A + B * B);
933
- return distance <= tolerance;
934
- case 'text':
935
- // Simple bounding box for text
936
- return x >= annotation.x - tolerance && x <= annotation.x + 100 &&
937
- y >= annotation.y - 20 && y <= annotation.y + tolerance;
938
- default:
939
- return false;
940
- }
941
- };
942
- // Handle resize for different annotation types
943
- this.handleResize = (currentPos) => {
944
- if (!this.resizingAnnotation || !this.dragStartPos)
945
- return;
946
- const annotation = this.resizingAnnotation;
947
- const index = this.annotations.findIndex(a => a === annotation);
948
- if (index === -1)
949
- return;
950
- let updatedAnnotation = Object.assign({}, annotation);
951
- switch (annotation.type) {
952
- case 'text':
953
- // Text resize logic (existing)
954
- const deltaX = currentPos.x - this.dragStartPos.x;
955
- const deltaY = currentPos.y - this.dragStartPos.y;
956
- const avgDelta = (deltaX + deltaY) / 2;
957
- const newSize = Math.max(8, Math.min(72, this.resizeStartSize + avgDelta * 0.5));
958
- updatedAnnotation.fontSize = Math.round(newSize);
959
- break;
960
- case 'rectangle':
961
- // Rectangle resize logic - only bottom-right corner
962
- const rectDeltaX = currentPos.x - this.dragStartPos.x;
963
- const rectDeltaY = currentPos.y - this.dragStartPos.y;
964
- // Update width and height based on original dimensions plus delta
965
- updatedAnnotation.width = Math.max(10, this.resizeStartDimensions.width + rectDeltaX); // Minimum width of 10px
966
- updatedAnnotation.height = Math.max(10, this.resizeStartDimensions.height + rectDeltaY); // Minimum height of 10px
967
- break;
968
- case 'line':
969
- case 'arrow':
970
- // Line/arrow resize logic - move endpoints
971
- if (this.resizeHandle === 'start') {
972
- updatedAnnotation.startX = currentPos.x;
973
- updatedAnnotation.startY = currentPos.y;
974
- }
975
- else if (this.resizeHandle === 'end') {
976
- updatedAnnotation.endX = currentPos.x;
977
- updatedAnnotation.endY = currentPos.y;
978
- }
979
- break;
980
- }
981
- // Update annotation in array
982
- this.annotations[index] = updatedAnnotation;
983
- this.resizingAnnotation = updatedAnnotation;
984
- this.redrawAnnotations();
985
- };
986
- this.sending = false;
987
- this.formMessage = '';
988
- this.formEmail = '';
989
- this.formSuccess = false;
990
- this.formVerification = '';
991
- this.formError = false;
992
- this.formErrorStatus = 500;
993
- this.encodedScreenshot = undefined;
994
- this.isPrivacyChecked = false;
995
- this.whitelabel = false;
996
- this.selectedRating = -1;
997
- this.overlayVisible = false;
998
- this.isAnimating = false;
999
- this.takingScreenshot = false;
1000
- this.showPreviewModal = false;
1001
- this.screenshotError = '';
1002
- this.showScreenshotError = false;
1003
- this.showCanvasEditor = false;
1004
- this.canvasDrawingTool = 'rectangle';
1005
- this.canvasDrawingColor = '#ff0000';
1006
- this.canvasLineWidth = 3;
1007
- this.isDrawing = false;
1008
- this.annotations = [];
1009
- this.currentAnnotation = null;
1010
- this.isDragging = false;
1011
- this.draggedAnnotation = null;
1012
- this.dragStartPos = null;
1013
- this.showColorPicker = false;
1014
- this.editingColorIndex = -1;
1015
- this.isResizing = false;
1016
- this.resizingAnnotation = null;
1017
- this.resizeStartSize = 16;
1018
- this.resizeStartDimensions = null;
1019
- this.hoveredAnnotation = null;
1020
- this.resizeHandle = false;
1021
- this.defaultColors = ['#ff0000', '#00ff00', '#0000ff', '#000000'];
1022
- this.customFont = false;
1023
- this.emailAddress = '';
1024
- this.hideEmail = false;
1025
- this.isEmailRequired = false;
1026
- this.ratingMode = 'thumbs';
1027
- this.hasSelectedElement = false;
1028
- this.hidePrivacyPolicy = true;
1029
- this.hideRating = false;
1030
- this.hideScreenshotButton = false;
1031
- this.project = '';
1032
- this.showScreenshotMode = false;
1033
- this.showScreenshotTopBar = false;
1034
- this.showModal = false;
1035
- this.rating = undefined;
1036
- this.metadata = undefined;
1037
- this.fetchData = true;
1038
- this.emailPlaceholder = 'Email address (optional)';
1039
- this.errorMessage = 'Please try again later.';
1040
- this.errorMessage403 = 'The request URL does not match the one defined in PushFeedback for this project.';
1041
- this.errorMessage404 = 'We could not find the provided project ID in PushFeedback.';
1042
- this.messagePlaceholder = 'Comments';
1043
- this.footerText = '';
1044
- this.modalPosition = 'center';
1045
- this.modalTitle = 'Share your feedback';
1046
- this.modalTitleError = 'Oops!';
1047
- this.modalTitleSuccess = 'Thanks for your feedback!';
1048
- this.privacyPolicyText = "I have read and expressly consent to the terms of the <a href='https://pushfeedback.com/privacy'>Privacy Policy</a>.";
1049
- this.ratingPlaceholder = 'Was this page helpful?';
1050
- this.ratingStarsPlaceholder = 'How would you rate this page?';
1051
- this.sendButtonText = 'Send';
1052
- this.screenshotAttachedText = 'Screenshot attached';
1053
- this.screenshotButtonText = 'Add a screenshot';
1054
- this.screenshotTakingText = 'Taking screenshot...';
1055
- this.screenshotTopbarText = 'Select an element on this page';
1056
- this.successMessage = '';
1057
- this.canvasEditorTitle = 'Edit screenshot';
1058
- this.canvasEditorCancelText = 'Cancel';
1059
- this.canvasEditorSaveText = 'Save';
1060
- }
1061
- componentWillLoad() {
1062
- if (this.fetchData)
1063
- this.fetchProjectData();
1064
- this.formEmail = this.emailAddress;
1065
- if (this.rating) {
1066
- this.selectedRating = this.rating;
1067
- }
1068
- if (this.ratingMode == 'thumbs' && this.rating == 0) {
1069
- this.selectedRating = 5;
1070
- }
1071
- }
1072
- async fetchProjectData() {
1073
- try {
1074
- const response = await fetch('https://app.pushfeedback.com/api/projects/' + this.project + '/');
1075
- const data = await response.json();
1076
- this.whitelabel = data.whitelabel;
1077
- }
1078
- catch (error) {
1079
- console.log(error);
1080
- }
1081
- }
1082
- resetOverflow() {
1083
- // Just clean up any stray classes, don't add/remove during screenshot
1084
- document.documentElement.classList.remove('feedback-modal-screenshot-open');
1085
- document.documentElement.classList.remove('feedback-modal-screenshot-open--scroll');
1086
- document.documentElement.classList.remove('feedback-modal-screenshot-closing');
1087
- }
1088
- handleMessageInput(event) {
1089
- this.formMessage = event.target.value;
1090
- }
1091
- handleEmailInput(event) {
1092
- this.formEmail = event.target.value;
1093
- }
1094
- async captureViewportScreenshot() {
1095
- try {
1096
- // Check if Screen Capture API is supported
1097
- if (!navigator.mediaDevices || !navigator.mediaDevices.getDisplayMedia) {
1098
- throw new Error('Screen Capture API is not supported in this browser');
1099
- }
1100
- // Request screen capture with preference for current tab
1101
- const stream = await navigator.mediaDevices.getDisplayMedia({
1102
- video: {
1103
- mediaSource: 'screen',
1104
- width: { ideal: window.innerWidth },
1105
- height: { ideal: window.innerHeight }
1106
- },
1107
- audio: false,
1108
- preferCurrentTab: true
1109
- });
1110
- // Create video element to capture frame
1111
- const video = document.createElement('video');
1112
- video.srcObject = stream;
1113
- video.autoplay = true;
1114
- video.muted = true;
1115
- return new Promise((resolve, reject) => {
1116
- video.onloadedmetadata = () => {
1117
- video.play();
1118
- // Wait a moment for video to stabilize
1119
- setTimeout(() => {
1120
- try {
1121
- // Create canvas to capture frame
1122
- const canvas = document.createElement('canvas');
1123
- canvas.width = video.videoWidth;
1124
- canvas.height = video.videoHeight;
1125
- const ctx = canvas.getContext('2d');
1126
- ctx.drawImage(video, 0, 0);
1127
- // Stop the stream
1128
- stream.getTracks().forEach(track => track.stop());
1129
- // Convert to data URL
1130
- const dataUrl = canvas.toDataURL('image/png');
1131
- console.log('Screenshot captured successfully using Screen Capture API');
1132
- resolve(dataUrl);
1133
- }
1134
- catch (error) {
1135
- stream.getTracks().forEach(track => track.stop());
1136
- reject(error);
1137
- }
1138
- }, 100);
1139
- };
1140
- video.onerror = (_) => {
1141
- stream.getTracks().forEach(track => track.stop());
1142
- reject(new Error('Failed to load video for screenshot capture'));
1143
- };
1144
- });
1145
- }
1146
- catch (error) {
1147
- console.error('Screen capture failed:', error);
1148
- throw error;
1149
- }
1150
- }
1151
- handleCheckboxChange(event) {
1152
- this.isPrivacyChecked = event.target.checked;
1153
- }
1154
- handleVerification(event) {
1155
- this.formVerification = event.target.value;
1156
- }
1157
- handleRatingChange(newRating) {
1158
- this.selectedRating = newRating;
1159
- }
1160
- render() {
1161
- return (h("div", { class: `feedback-modal-wrapper ${this.customFont ? 'feedback-modal-wrapper--custom-font' : ''}` }, this.showScreenshotError && (h("div", { class: "screenshot-error-notification" }, h("div", { class: "screenshot-error-content" }, h("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("circle", { cx: "12", cy: "12", r: "10" }), h("line", { x1: "15", y1: "9", x2: "9", y2: "15" }), h("line", { x1: "9", y1: "9", x2: "15", y2: "15" })), h("span", null, this.screenshotError), h("button", { class: "error-close-btn", onClick: () => this.showScreenshotError = false, title: "Close" }, h("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), h("line", { x1: "6", y1: "6", x2: "18", y2: "18" })))))), this.showModal && (h("div", { class: `feedback-overlay ${this.isAnimating ? 'feedback-overlay--visible' : ''}` })), this.showModal && (h("div", { class: `feedback-modal-content feedback-modal-content--${this.modalPosition} ${this.isAnimating ? 'feedback-modal-content--open' : ''}`, ref: (el) => (this.modalContent = el) }, h("div", { class: "feedback-modal-header" }, !this.formSuccess && !this.formError ? (h("span", null, this.modalTitle)) : this.formSuccess ? (h("span", null, this.modalTitleSuccess)) : (h("span", null, this.modalTitleError)), h("button", { class: "feedback-modal-close", onClick: this.close }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", stroke: "#191919", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "feather feather-x" }, h("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), h("line", { x1: "6", y1: "6", x2: "18", y2: "18" })))), h("div", { class: "feedback-modal-body" }, !this.formSuccess && !this.formError ? (h("form", { onSubmit: this.handleSubmit }, !this.hideRating && (h("div", { class: "feedback-modal-rating" }, this.ratingMode === 'thumbs' ? (h("div", { class: "feedback-modal-rating-content" }, h("span", { class: "feedback-modal-input-heading" }, this.ratingPlaceholder), h("div", { class: "feedback-modal-rating-buttons feedback-modal-rating-buttons--thumbs" }, h("button", { title: "Yes", class: `feedback-modal-rating-button ${this.selectedRating === 1
1162
- ? 'feedback-modal-rating-button--selected'
1163
- : ''}`, onClick: (event) => {
1164
- event.preventDefault();
1165
- this.handleRatingChange(1);
1166
- } }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "#5F6368", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("path", { d: "M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3" }))), h("button", { title: "No", class: `feedback-modal-rating-button ${this.selectedRating === 5
1167
- ? 'feedback-modal-rating-button--selected'
1168
- : ''}`, onClick: (event) => {
1169
- event.preventDefault();
1170
- this.handleRatingChange(5);
1171
- } }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "#5F6368", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("path", { d: "M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17" })))))) : (h("div", { class: "feedback-modal-rating-content" }, h("span", { class: "feedback-modal-input-heading" }, this.ratingStarsPlaceholder), h("div", { class: "feedback-modal-rating-buttons feedback-modal-rating-buttons--stars" }, [1, 2, 3, 4, 5].map((rating) => (h("button", { key: rating, class: `feedback-modal-rating-button ${this.selectedRating >= rating
1172
- ? 'feedback-modal-rating-button--selected'
1173
- : ''}`, onClick: (event) => {
1174
- event.preventDefault();
1175
- this.handleRatingChange(rating);
1176
- } }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", stroke: "#5F6368", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("polygon", { points: "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" })))))))))), h("div", { class: "feedback-modal-text" }, h("textarea", { placeholder: this.messagePlaceholder, value: this.formMessage, onInput: (event) => this.handleMessageInput(event) })), !this.hideEmail && (h("div", { class: "feedback-modal-email" }, h("input", { placeholder: this.emailPlaceholder, type: "email", onInput: (event) => this.handleEmailInput(event), value: this.formEmail, required: this.isEmailRequired }))), h("div", { class: "feedback-verification" }, h("input", { type: "text", name: "verification", style: { display: 'none' }, onInput: (event) => this.handleVerification(event), value: this.formVerification })), !this.hidePrivacyPolicy && (h("div", { class: "feedback-modal-privacy" }, h("input", { type: "checkbox", id: "privacyPolicy", onChange: (ev) => this.handleCheckboxChange(ev), required: true }), h("span", { innerHTML: this.privacyPolicyText }))), h("div", { class: `feedback-modal-buttons ${this.hideScreenshotButton ? 'single' : ''}` }, !this.hideScreenshotButton && (h("button", { type: "button", class: `feedback-modal-button feedback-modal-button--screenshot ${this.encodedScreenshot ? 'feedback-modal-button--active' : ''}`, onClick: this.openScreenShot, disabled: this.sending || this.takingScreenshot }, this.encodedScreenshot && (h("div", { class: "screenshot-preview", onClick: this.openCanvasEditor }, h("img", { src: this.encodedScreenshot, alt: "Screenshot Preview" }))), !this.encodedScreenshot && !this.takingScreenshot && (h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24", viewBox: "0 -960 960 960", width: "24" }, h("path", { d: "M680-80v-120H560v-80h120v-120h80v120h120v80H760v120h-80ZM200-200v-200h80v120h120v80H200Zm0-360v-200h200v80H280v120h-80Zm480 0v-120H560v-80h200v200h-80Z" }))), this.takingScreenshot && (h("div", { class: "screenshot-loading" }, h("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "#666", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "feather-loader" }, h("line", { x1: "12", y1: "2", x2: "12", y2: "6" }), h("line", { x1: "12", y1: "18", x2: "12", y2: "22" }), h("line", { x1: "4.93", y1: "4.93", x2: "7.76", y2: "7.76" }), h("line", { x1: "16.24", y1: "16.24", x2: "19.07", y2: "19.07" }), h("line", { x1: "2", y1: "12", x2: "6", y2: "12" }), h("line", { x1: "18", y1: "12", x2: "22", y2: "12" }), h("line", { x1: "4.93", y1: "19.07", x2: "7.76", y2: "16.24" }), h("line", { x1: "16.24", y1: "7.76", x2: "19.07", y2: "4.93" })))), this.takingScreenshot ? this.screenshotTakingText :
1177
- this.encodedScreenshot ? this.screenshotAttachedText : this.screenshotButtonText)), h("button", { class: "feedback-modal-button feedback-modal-button--submit", type: "submit", disabled: this.sending }, this.sendButtonText)))) : this.formSuccess && !this.formError ? (h("div", { class: "feedback-modal-success" }, h("p", { class: "feedback-modal-message" }, this.successMessage))) : this.formError && this.formErrorStatus == 404 ? (h("p", { class: "feedback-modal-message" }, this.errorMessage404)) : this.formError && this.formErrorStatus == 403 ? (h("p", { class: "feedback-modal-message" }, this.errorMessage403)) : this.formError ? (h("p", { class: "feedback-modal-message" }, this.errorMessage)) : (h("span", null))), h("div", { class: "feedback-modal-footer" }, h("div", { class: "feedback-logo", style: { display: this.whitelabel ? 'none' : 'block' } }, "Powered by", ' ', h("a", { target: "_blank", href: "https://pushfeedback.com" }, "PushFeedback.com")), this.footerText && (h("div", { class: "feedback-footer-text" }, h("span", { innerHTML: this.footerText })))))), this.showCanvasEditor && (h("div", { class: "canvas-editor-overlay" }, h("div", { class: "canvas-editor-modal" }, h("div", { class: "canvas-editor-header" }, h("div", { class: "canvas-editor-title" }, h("h3", null, this.canvasEditorTitle)), h("div", { class: "canvas-editor-toolbar" }, h("div", { class: "toolbar-section" }, h("div", { class: "tool-group" }, h("button", { class: `tool-btn ${this.canvasDrawingTool === 'rectangle' ? 'active' : ''}`, onClick: () => this.canvasDrawingTool = 'rectangle', title: "Rectangle" }, h("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }))), h("button", { class: `tool-btn ${this.canvasDrawingTool === 'line' ? 'active' : ''}`, onClick: () => this.canvasDrawingTool = 'line', title: "Line" }, h("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("line", { x1: "5", y1: "12", x2: "19", y2: "12" }))), h("button", { class: `tool-btn ${this.canvasDrawingTool === 'arrow' ? 'active' : ''}`, onClick: () => this.canvasDrawingTool = 'arrow', title: "Arrow" }, h("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("line", { x1: "7", y1: "17", x2: "17", y2: "7" }), h("polyline", { points: "7,7 17,7 17,17" }))), h("button", { class: `tool-btn ${this.canvasDrawingTool === 'text' ? 'active' : ''}`, onClick: () => this.canvasDrawingTool = 'text', title: "Text" }, h("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("polyline", { points: "4,7 4,4 20,4 20,7" }), h("line", { x1: "9", y1: "20", x2: "15", y2: "20" }), h("line", { x1: "12", y1: "4", x2: "12", y2: "20" }))), h("div", { class: "toolbar-divider" }), h("button", { class: "tool-btn undo-btn", onClick: this.undoLastAnnotation, disabled: this.annotations.length === 0, title: "Undo" }, h("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("polyline", { points: "1,4 1,10 7,10" }), h("path", { d: "M3.51,15a9,9,0,0,0,14.85-3.36,9,9,0,0,0-9.19-10.15L1.83,10" }))))), h("div", { class: "toolbar-section" }, h("div", { class: "color-palette" }, this.defaultColors.map((color, index) => (h("div", { class: "color-slot-wrapper" }, h("button", { class: `color-btn ${this.canvasDrawingColor === color ? 'active' : ''} ${this.editingColorIndex === index ? 'editing' : ''}`, style: { backgroundColor: color }, onClick: () => this.handleColorSlotClick(index), title: `Color ${index + 1} - Click to customize` }, this.editingColorIndex === index && (h("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "white", "stroke-width": "2" }, h("path", { d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" })))), this.editingColorIndex === index && this.showColorPicker && (h("div", { class: "color-picker-dropdown" }, h("input", { type: "color", value: color, onInput: (e) => this.handleColorPickerInput(e), onClick: (e) => this.handleColorPickerClick(e) })))))))), h("div", { class: "toolbar-section" }, h("div", { class: "size-control" }, h("input", { type: "range", min: "1", max: "10", value: this.canvasLineWidth, onInput: (e) => this.canvasLineWidth = parseInt(e.target.value), class: "size-slider" }), h("span", { class: "size-value" }, this.canvasLineWidth, "px"))), h("div", { class: "toolbar-section" }, h("button", { class: "action-btn secondary", onClick: this.closeCanvasEditor }, this.canvasEditorCancelText), h("button", { class: "action-btn primary", onClick: this.saveAnnotations }, this.canvasEditorSaveText))), h("div", { class: "canvas-editor-content" }, h("canvas", { ref: (el) => this.canvasRef = el, class: "annotation-canvas", onMouseDown: this.handleCanvasMouseDown, onMouseMove: this.handleCanvasMouseMove, onMouseUp: this.handleCanvasMouseUp, onMouseLeave: this.handleCanvasMouseUp }))))))));
1178
- }
1179
- componentDidRender() {
1180
- if (this.showModal) {
1181
- requestAnimationFrame(() => {
1182
- this.overlayVisible = true;
1183
- });
1184
- }
1185
- }
1186
- async openModal() {
1187
- this.showModal = true;
1188
- requestAnimationFrame(() => {
1189
- requestAnimationFrame(() => {
1190
- this.isAnimating = true;
1191
- });
1192
- });
1193
- }
1194
- };
1195
- FeedbackModal.style = feedbackModalCss;
1196
-
1197
- export { FeedbackButton as feedback_button, FeedbackModal as feedback_modal };