pushfeedback 0.1.43 → 0.1.45

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 (42) hide show
  1. package/dist/pushfeedback/app-globals-0f993ce5.js +3 -0
  2. package/dist/pushfeedback/css-shim-b7d3d95f.js +4 -0
  3. package/dist/pushfeedback/dom-64053c71.js +73 -0
  4. package/dist/{components/feedback-button.js → pushfeedback/feedback-button.entry.js} +120 -175
  5. package/dist/{components/feedback-modal2.js → pushfeedback/feedback-modal.entry.js} +333 -356
  6. package/dist/pushfeedback/index-6a05f159.js +3371 -0
  7. package/dist/pushfeedback/index.esm.js +1 -0
  8. package/dist/pushfeedback/pushfeedback.css +108 -1
  9. package/dist/pushfeedback/pushfeedback.esm.js +148 -1
  10. package/dist/pushfeedback/shadow-css-98135883.js +387 -0
  11. package/dist/types/components/feedback-button/feedback-button.d.ts +43 -43
  12. package/dist/types/components/feedback-modal/feedback-modal.d.ts +67 -67
  13. package/dist/types/index.d.ts +1 -1
  14. package/package.json +1 -1
  15. package/dist/cjs/feedback-button_2.cjs.entry.js +0 -8267
  16. package/dist/cjs/index-b596cc3a.js +0 -1551
  17. package/dist/cjs/index.cjs.js +0 -2
  18. package/dist/cjs/loader.cjs.js +0 -22
  19. package/dist/cjs/pushfeedback.cjs.js +0 -23
  20. package/dist/collection/collection-manifest.json +0 -13
  21. package/dist/collection/components/feedback-button/feedback-button.css +0 -63
  22. package/dist/collection/components/feedback-button/feedback-button.js +0 -671
  23. package/dist/collection/components/feedback-modal/feedback-modal.css +0 -388
  24. package/dist/collection/components/feedback-modal/feedback-modal.js +0 -845
  25. package/dist/collection/index.js +0 -1
  26. package/dist/components/feedback-modal.js +0 -6
  27. package/dist/components/index.js +0 -3
  28. package/dist/esm/feedback-button_2.entry.js +0 -8262
  29. package/dist/esm/index-deb00b84.js +0 -1523
  30. package/dist/esm/index.js +0 -1
  31. package/dist/esm/loader.js +0 -18
  32. package/dist/esm/polyfills/core-js.js +0 -11
  33. package/dist/esm/polyfills/css-shim.js +0 -1
  34. package/dist/esm/polyfills/dom.js +0 -79
  35. package/dist/esm/polyfills/es5-html-element.js +0 -1
  36. package/dist/esm/polyfills/index.js +0 -34
  37. package/dist/esm/polyfills/system.js +0 -6
  38. package/dist/esm/pushfeedback.js +0 -18
  39. package/dist/index.cjs.js +0 -1
  40. package/dist/index.js +0 -1
  41. package/dist/pushfeedback/p-4571809a.entry.js +0 -22
  42. package/dist/pushfeedback/p-90e8ba79.js +0 -2
@@ -1,17 +1,44 @@
1
- import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
1
+ import { r as registerInstance, h } from './index-6a05f159.js';
2
2
 
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
 
5
+ function getDefaultExportFromCjs (x) {
6
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
7
+ }
8
+
5
9
  function createCommonjsModule(fn, basedir, module) {
6
10
  return module = {
7
11
  path: basedir,
8
12
  exports: {},
9
13
  require: function (path, base) {
10
- return commonjsRequire();
14
+ return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
11
15
  }
12
16
  }, fn(module, module.exports), module.exports;
13
17
  }
14
18
 
19
+ function getDefaultExportFromNamespaceIfPresent (n) {
20
+ return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
21
+ }
22
+
23
+ function getDefaultExportFromNamespaceIfNotNamed (n) {
24
+ return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
25
+ }
26
+
27
+ function getAugmentedNamespace(n) {
28
+ if (n.__esModule) return n;
29
+ var a = Object.defineProperty({}, '__esModule', {value: true});
30
+ Object.keys(n).forEach(function (k) {
31
+ var d = Object.getOwnPropertyDescriptor(n, k);
32
+ Object.defineProperty(a, k, d.get ? d : {
33
+ enumerable: true,
34
+ get: function () {
35
+ return n[k];
36
+ }
37
+ });
38
+ });
39
+ return a;
40
+ }
41
+
15
42
  function commonjsRequire () {
16
43
  throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
17
44
  }
@@ -23,8 +50,11 @@ var html2canvas = createCommonjsModule(function (module, exports) {
23
50
  * Released under MIT License
24
51
  */
25
52
  (function (global, factory) {
26
- module.exports = factory() ;
27
- }(commonjsGlobal, (function () {
53
+ 'object' === 'object' && 'object' !== 'undefined' ? module.exports = factory() :
54
+ typeof undefined === 'function' && undefined.amd ? undefined(factory) :
55
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.html2canvas = factory());
56
+ }(commonjsGlobal, (function () { 'use strict';
57
+
28
58
  /*! *****************************************************************************
29
59
  Copyright (c) Microsoft Corporation.
30
60
 
@@ -3179,7 +3209,8 @@ var html2canvas = createCommonjsModule(function (module, exports) {
3179
3209
  // doesn't support 3D transforms at the moment
3180
3210
  var matrix3d = function (args) {
3181
3211
  var values = args.filter(function (arg) { return arg.type === 17 /* NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
3182
- var a1 = values[0], b1 = values[1]; var a2 = values[4], b2 = values[5]; var a4 = values[12], b4 = values[13]; return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;
3212
+ var a1 = values[0], b1 = values[1]; values[2]; values[3]; var a2 = values[4], b2 = values[5]; values[6]; values[7]; values[8]; values[9]; values[10]; values[11]; var a4 = values[12], b4 = values[13]; values[14]; values[15];
3213
+ return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;
3183
3214
  };
3184
3215
  var SUPPORTED_TRANSFORM_FUNCTIONS = {
3185
3216
  matrix: matrix,
@@ -4763,6 +4794,7 @@ var html2canvas = createCommonjsModule(function (module, exports) {
4763
4794
  container.flags |= 8 /* IS_LIST_OWNER */;
4764
4795
  }
4765
4796
  parent.elements.push(container);
4797
+ childNode.slot;
4766
4798
  if (childNode.shadowRoot) {
4767
4799
  parseNodeTree(context, childNode.shadowRoot, container, root);
4768
4800
  }
@@ -7844,355 +7876,300 @@ var html2canvas = createCommonjsModule(function (module, exports) {
7844
7876
  //# sourceMappingURL=html2canvas.js.map
7845
7877
  });
7846
7878
 
7847
- const feedbackModalCss = ".text-center{flex-grow:1;text-align:center}.feedback-modal-wrapper{position:absolute;z-index:var(--feedback-modal-wrapper-z-index)}.feedback-overlay{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{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;font-family:var(--feedback-modal-content-font-family);left:50%;max-width:90%;padding:20px;position:fixed;top:50%;transform:translate(-50%, -50%);width:100%;z-index:var(--feedback-modal-content-z-index)}.feedback-modal-header{align-items:center;color:var(--feedback-modal-header-text-color);display:flex;font-family:var(--feedback-modal-header-font-family);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-family:var(--feedback-modal-content-font-family);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-family:var(--feedback-modal-content-font-family);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-family:var(--feedback-modal-content-font-family);font-size:var(--feedback-modal-input-font-size);margin-bottom:20px;height:40px;padding:10px;width:100%;margin-bottom:20px}.feedback-modal-privacy{font-family:var(--feedback-modal-content-font-family);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-family:var(--feedback-modal-content-font-family);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;font-family:var(--feedback-modal-content-font-family)}.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{align-items:center;display:flex;justify-content:center;margin-top:5px}.feedback-logo a{margin-left:3px}.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;font-family:var(--feedback-modal-content-font-family);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:1px solid var(--feedback-modal-element-selected-border-color)}@media screen and (min-width: 768px){.feedback-modal-content{max-width:600px}.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:300px;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:300px;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}}";
7848
-
7849
- const FeedbackModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7850
- constructor() {
7851
- super();
7852
- this.__registerHost();
7853
- this.__attachShadow();
7854
- this.onScrollDebounced = () => {
7855
- clearTimeout(this.scrollTimeout);
7856
- this.scrollTimeout = setTimeout(() => {
7857
- document.documentElement.classList.remove('feedback-modal-screenshot-closing');
7858
- document.documentElement.style.top = "";
7859
- window.removeEventListener('scroll', this.onScrollDebounced);
7860
- }, 200);
7861
- };
7862
- this.handleSubmit = async (event) => {
7863
- event.preventDefault();
7864
- this.resetOverflow();
7865
- this.showScreenshotMode = false;
7866
- this.showScreenshotTopBar = false;
7867
- this.showModal = false;
7868
- this.sending = true;
7869
- try {
7870
- const res = await fetch('https://app.pushfeedback.com/api/feedback/', {
7871
- method: 'POST',
7872
- body: JSON.stringify({
7873
- url: window.location.href,
7874
- message: this.formMessage,
7875
- email: this.formEmail,
7876
- project: this.project,
7877
- screenshot: this.encodedScreenshot,
7878
- rating: this.selectedRating,
7879
- ratingMode: this.ratingMode,
7880
- verification: this.formVerification,
7881
- session: localStorage.getItem('pushfeedback_sessionid') || '',
7882
- }),
7883
- headers: {
7884
- 'Content-Type': 'application/json'
7885
- }
7886
- });
7887
- if (res.status === 201) {
7888
- this.formSuccess = true;
7889
- this.formError = false;
7890
- }
7891
- else {
7892
- this.formSuccess = false;
7893
- this.formError = true;
7894
- this.formErrorStatus = res.status;
7895
- }
7896
- }
7897
- catch (error) {
7898
- console.log(error);
7899
- this.formSuccess = false;
7900
- this.formError = true;
7901
- this.formErrorStatus = 500;
7902
- }
7903
- finally {
7904
- this.sending = false;
7905
- this.showModal = true;
7906
- }
7907
- };
7908
- this.close = () => {
7909
- this.sending = false;
7910
- this.showModal = false;
7911
- this.showScreenshotMode = false;
7912
- this.showScreenshotTopBar = false;
7913
- this.hasSelectedElement = false;
7914
- this.encodedScreenshot = null;
7915
- this.formSuccess = false;
7916
- this.formError = false;
7917
- this.formErrorStatus = 500;
7918
- this.formMessage = '';
7919
- this.formEmail = '';
7920
- this.resetOverflow();
7921
- };
7922
- this.openScreenShot = () => {
7923
- this.hasSelectedElement = false;
7924
- this.showModal = false;
7925
- this.showScreenshotMode = true;
7926
- this.showScreenshotTopBar = true;
7927
- this.encodedScreenshot = null;
7928
- if (window.innerWidth > document.documentElement.clientWidth) {
7929
- document.documentElement.classList.add('feedback-modal-screenshot-open--scroll');
7930
- }
7931
- const scrollY = window.scrollY;
7932
- document.documentElement.style.top = `-${scrollY}px`;
7933
- window.scrollTo(0, parseInt(document.documentElement.style.top || '0') * -1);
7934
- document.documentElement.classList.add('feedback-modal-screenshot-open');
7935
- };
7936
- this.closeScreenShot = () => {
7937
- this.showModal = false;
7938
- this.showScreenshotMode = false;
7939
- this.showScreenshotTopBar = false;
7940
- this.hasSelectedElement = false;
7941
- this.encodedScreenshot = null;
7942
- this.resetOverflow();
7943
- };
7944
- this.handleMouseOverScreenShot = (event) => {
7945
- event.preventDefault();
7946
- if (this.hasSelectedElement)
7947
- return;
7948
- const borderOffset = 2;
7949
- this.screenshotModal.style.display = 'none';
7950
- const elementUnder = document.elementFromPoint(event.clientX, event.clientY);
7951
- const rect = elementUnder.getBoundingClientRect();
7952
- this.screenshotModal.style.display = '';
7953
- // Get the bounding box of the element selected
7954
- this.elementSelected.style.position = "absolute";
7955
- this.elementSelected.style.left = `${rect.left}px`;
7956
- this.elementSelected.style.top = `${rect.top}px`;
7957
- this.elementSelected.style.width = `${rect.width}px`;
7958
- this.elementSelected.style.height = `${rect.height}px`;
7959
- this.elementSelected.classList.add('feedback-modal-element-hover');
7960
- // Set the background color of nonselected areas
7961
- // Top
7962
- this.topSide.style.position = "absolute";
7963
- this.topSide.style.left = `${rect.left}px`;
7964
- this.topSide.style.top = '0px';
7965
- this.topSide.style.width = `${rect.width + borderOffset}px`;
7966
- this.topSide.style.height = `${rect.top}px`;
7967
- this.topSide.style.backgroundColor = "rgba(0, 0, 0, 0.4)";
7968
- // Left
7969
- this.leftSide.style.position = "absolute";
7970
- this.leftSide.style.left = '0px';
7971
- this.leftSide.style.top = '0px';
7972
- this.leftSide.style.width = `${rect.left}px`;
7973
- this.leftSide.style.height = '100vh';
7974
- this.leftSide.style.backgroundColor = "rgba(0, 0, 0, 0.4)";
7975
- // Bottom
7976
- this.bottomSide.style.position = "absolute";
7977
- this.bottomSide.style.left = `${rect.left}px`;
7978
- this.bottomSide.style.top = `${rect.bottom + borderOffset}px`;
7979
- this.bottomSide.style.width = `${rect.width + borderOffset}px`;
7980
- this.bottomSide.style.height = '100vh';
7981
- this.bottomSide.style.backgroundColor = "rgba(0, 0, 0, 0.4)";
7982
- // Right
7983
- this.rightSide.style.position = "absolute";
7984
- this.rightSide.style.left = `${rect.right + borderOffset}px`;
7985
- this.rightSide.style.top = '0px';
7986
- this.rightSide.style.width = '100%';
7987
- this.rightSide.style.height = '100vh';
7988
- this.rightSide.style.backgroundColor = "rgba(0, 0, 0, 0.4)";
7989
- // Restore the visibility of the screenshot-modal
7990
- this.screenshotModal.style.backgroundColor = 'transparent';
7991
- };
7992
- this.handleMouseClickedSelectedElement = async (event) => {
7993
- event.preventDefault();
7994
- if (!this.elementSelected) {
7995
- return;
7996
- }
7997
- this.hasSelectedElement = true;
7998
- this.elementSelected.classList.add('feedback-modal-element-selected');
7999
- // Get the top position including the scroll offset
8000
- const rectTop = this.elementSelected.getBoundingClientRect().top;
8001
- const topWithScroll = rectTop + window.scrollY;
8002
- // Move the element with the scroll offset
8003
- this.elementSelected.style.top = `${topWithScroll}px`;
8004
- // Clone the selected element and append it to the body
8005
- const clonedElementSelected = this.elementSelected.cloneNode(true);
8006
- document.body.appendChild(clonedElementSelected);
8007
- // Reset the top position of the original element
8008
- this.elementSelected.style.top = `${rectTop}px`;
8009
- this.showScreenshotTopBar = false;
8010
- this.showModal = false;
8011
- try {
8012
- const dataUrl = await this.captureScreenshot();
8013
- console.log('Screenshot captured');
8014
- this.encodedScreenshot = dataUrl;
8015
- }
8016
- catch (error) {
8017
- console.error('Failed to capture screenshot:', error);
8018
- this.hasSelectedElement = false;
8019
- }
8020
- finally {
8021
- // Remove the cloned element and show the modal again
8022
- document.body.removeChild(clonedElementSelected);
8023
- this.showModal = true;
8024
- }
8025
- };
8026
- this.sending = false;
8027
- this.formMessage = '';
8028
- this.formEmail = '';
8029
- this.formSuccess = false;
8030
- this.formVerification = '';
8031
- this.formError = false;
8032
- this.formErrorStatus = 500;
8033
- this.encodedScreenshot = undefined;
8034
- this.isPrivacyChecked = false;
8035
- this.whitelabel = false;
8036
- this.selectedRating = 0;
8037
- this.errorMessage = "Please try again later.";
8038
- this.errorMessage403 = "The request URL does not match the one defined in PushFeedback for this project.";
8039
- this.errorMessage404 = "We could not find the provided project ID in PushFeedback.";
8040
- this.modalTitle = 'Share your feedback';
8041
- this.modalTitleSuccess = 'Thanks for your feedback!';
8042
- this.modalTitleError = "Oops!";
8043
- this.modalPosition = 'center';
8044
- this.sendButtonText = 'Send';
8045
- this.successMessage = "";
8046
- this.project = '';
8047
- this.screenshotButtonText = 'Add a screenshot';
8048
- this.screenshotTopbarText = 'Select an element on this page';
8049
- this.hideEmail = false;
8050
- this.emailAddress = '';
8051
- this.emailPlaceholder = 'Email address (optional)';
8052
- this.messagePlaceholder = 'Comments';
8053
- this.hideRating = false;
8054
- this.rating = undefined;
8055
- this.ratingMode = 'thumbs';
8056
- this.ratingPlaceholder = 'Was this page helpful?';
8057
- this.ratingStarsPlaceholder = 'How would you rate this page?';
8058
- this.showModal = false;
8059
- this.showScreenshotMode = false;
8060
- this.showScreenshotTopBar = false;
8061
- this.hasSelectedElement = false;
8062
- this.hideScreenshotButton = false;
8063
- this.hidePrivacyPolicy = true;
8064
- this.privacyPolicyText = "I have read and expressly consent to the terms of the <a href='https://pushfeedback.com/privacy'>Privacy Policy</a>.";
8065
- this.fetchData = true;
8066
- }
8067
- componentWillLoad() {
8068
- if (this.fetchData)
8069
- this.fetchProjectData();
8070
- this.formEmail = this.emailAddress;
8071
- if (this.rating) {
8072
- this.selectedRating = this.rating;
8073
- }
8074
- if (this.ratingMode == "thumbs" && this.rating == 0) {
8075
- this.selectedRating = 5;
8076
- }
8077
- }
8078
- async fetchProjectData() {
8079
- try {
8080
- const response = await fetch('https://app.pushfeedback.com/api/projects/' + this.project + '/');
8081
- const data = await response.json();
8082
- this.whitelabel = data.whitelabel;
8083
- }
8084
- catch (error) {
8085
- console.log(error);
8086
- }
8087
- }
8088
- resetOverflow() {
8089
- document.documentElement.classList.remove('feedback-modal-screenshot-open');
8090
- document.documentElement.classList.remove('feedback-modal-screenshot-open--scroll');
8091
- document.documentElement.classList.add('feedback-modal-screenshot-closing');
8092
- window.scrollTo(0, parseInt(document.documentElement.style.top || '0') * -1);
8093
- window.addEventListener('scroll', this.onScrollDebounced);
8094
- }
8095
- handleMessageInput(event) {
8096
- this.formMessage = event.target.value;
8097
- }
8098
- handleEmailInput(event) {
8099
- this.formEmail = event.target.value;
8100
- }
8101
- captureScreenshot() {
8102
- return new Promise((resolve, reject) => {
8103
- requestAnimationFrame(() => {
8104
- html2canvas(document.body, {
8105
- x: window.scrollX,
8106
- y: window.scrollY,
8107
- width: window.innerWidth,
8108
- height: window.innerHeight,
8109
- }).then(canvas => {
8110
- const dataUrl = canvas.toDataURL();
8111
- resolve(dataUrl);
8112
- })
8113
- .catch(error => {
8114
- console.error(error);
8115
- reject(error);
8116
- });
8117
- });
8118
- });
8119
- }
8120
- handleCheckboxChange(event) {
8121
- this.isPrivacyChecked = event.target.checked;
8122
- }
8123
- handleVerification(event) {
8124
- this.formVerification = event.target.value;
8125
- }
8126
- handleRatingChange(newRating) {
8127
- this.selectedRating = newRating;
8128
- }
8129
- render() {
8130
- return (h("div", { class: 'feedback-modal-wrapper' }, this.showScreenshotMode && (h("div", { class: "feedback-modal-screenshot", ref: el => (this.screenshotModal = el), onMouseMove: this.handleMouseOverScreenShot }, h("div", { class: "feedback-modal-screenshot-element-selected", ref: el => (this.elementSelected = el), onClick: this.handleMouseClickedSelectedElement }), h("div", { class: "top-side", ref: el => (this.topSide = el) }), h("div", { class: "left-side", ref: el => (this.leftSide = el) }), h("div", { class: "bottom-side", ref: el => (this.bottomSide = el) }), h("div", { class: "right-side", ref: el => (this.rightSide = el) }), this.showScreenshotTopBar && (h("div", { class: "feedback-modal-screenshot-header", onClick: this.closeScreenShot }, h("span", null, this.screenshotTopbarText), h("span", { class: "feedback-modal-screenshot-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" }))))))), this.showModal && (h("div", { class: "feedback-overlay" })), this.showModal && (h("div", { class: `feedback-modal-content feedback-modal-content--${this.modalPosition} ${this.showModal ? '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 ? 'feedback-modal-rating-button--selected' : ''}`, onClick: (event) => {
8131
- event.preventDefault();
8132
- this.handleRatingChange(1);
8133
- } }, 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 ? 'feedback-modal-rating-button--selected' : ''}`, onClick: (event) => {
8134
- event.preventDefault();
8135
- this.handleRatingChange(5);
8136
- } }, 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 ? 'feedback-modal-rating-button--selected' : ''}`, onClick: (event) => {
8137
- event.preventDefault();
8138
- this.handleRatingChange(rating);
8139
- } }, 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 }))), 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 }, 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.screenshotButtonText)), h("button", { class: "feedback-modal-button feedback-modal-button--submit", type: "submit", disabled: this.sending }, this.sendButtonText)))) : this.formSuccess && !this.formError ? (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", style: { display: this.whitelabel ? 'none' : 'block' } }, h("div", { class: "feedback-logo" }, "Powered by ", h("a", { target: "_blank", href: "https://pushfeedback.com" }, "PushFeedback.com")))))));
8140
- }
8141
- static get style() { return feedbackModalCss; }
8142
- }, [1, "feedback-modal", {
8143
- "errorMessage": [1, "error-message"],
8144
- "errorMessage403": [1, "error-message-4-0-3"],
8145
- "errorMessage404": [1, "error-message-4-0-4"],
8146
- "modalTitle": [1, "modal-title"],
8147
- "modalTitleSuccess": [1, "modal-title-success"],
8148
- "modalTitleError": [1, "modal-title-error"],
8149
- "modalPosition": [1, "modal-position"],
8150
- "sendButtonText": [1, "send-button-text"],
8151
- "successMessage": [1, "success-message"],
8152
- "project": [1],
8153
- "screenshotButtonText": [1, "screenshot-button-text"],
8154
- "screenshotTopbarText": [1, "screenshot-topbar-text"],
8155
- "hideEmail": [4, "hide-email"],
8156
- "emailAddress": [1, "email-address"],
8157
- "emailPlaceholder": [1, "email-placeholder"],
8158
- "messagePlaceholder": [1, "message-placeholder"],
8159
- "hideRating": [4, "hide-rating"],
8160
- "rating": [2],
8161
- "ratingMode": [1, "rating-mode"],
8162
- "ratingPlaceholder": [1, "rating-placeholder"],
8163
- "ratingStarsPlaceholder": [1, "rating-stars-placeholder"],
8164
- "showModal": [1540, "show-modal"],
8165
- "showScreenshotMode": [1540, "show-screenshot-mode"],
8166
- "showScreenshotTopBar": [1540, "show-screenshot-top-bar"],
8167
- "hasSelectedElement": [1540, "has-selected-element"],
8168
- "hideScreenshotButton": [4, "hide-screenshot-button"],
8169
- "hidePrivacyPolicy": [4, "hide-privacy-policy"],
8170
- "privacyPolicyText": [1, "privacy-policy-text"],
8171
- "fetchData": [4, "fetch-data"],
8172
- "sending": [32],
8173
- "formMessage": [32],
8174
- "formEmail": [32],
8175
- "formSuccess": [32],
8176
- "formVerification": [32],
8177
- "formError": [32],
8178
- "formErrorStatus": [32],
8179
- "encodedScreenshot": [32],
8180
- "isPrivacyChecked": [32],
8181
- "whitelabel": [32],
8182
- "selectedRating": [32]
8183
- }]);
8184
- function defineCustomElement() {
8185
- if (typeof customElements === "undefined") {
8186
- return;
8187
- }
8188
- const components = ["feedback-modal"];
8189
- components.forEach(tagName => { switch (tagName) {
8190
- case "feedback-modal":
8191
- if (!customElements.get(tagName)) {
8192
- customElements.define(tagName, FeedbackModal);
8193
- }
8194
- break;
8195
- } });
8196
- }
7879
+ const feedbackModalCss = ".text-center{flex-grow:1;text-align:center}.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;position:fixed;top:0;width:100%;z-index:var(--feedback-modal-screnshot-z-index)}.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;font-family:var(--feedback-modal-content-font-family);left:50%;max-width:90%;padding:20px;position:fixed;top:50%;transform:translate(-50%, -50%);width:100%;z-index:var(--feedback-modal-content-z-index)}.feedback-modal-header{align-items:center;color:var(--feedback-modal-header-text-color);display:flex;font-family:var(--feedback-modal-header-font-family);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-family:var(--feedback-modal-content-font-family);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-family:var(--feedback-modal-content-font-family);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-family:var(--feedback-modal-content-font-family);font-size:var(--feedback-modal-input-font-size);margin-bottom:20px;height:40px;padding:10px;width:100%;margin-bottom:20px}.feedback-modal-privacy{font-family:var(--feedback-modal-content-font-family);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-family:var(--feedback-modal-content-font-family);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;font-family:var(--feedback-modal-content-font-family)}.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{align-items:center;display:flex;justify-content:center;margin-top:5px}.feedback-logo a{margin-left:3px}.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;font-family:var(--feedback-modal-content-font-family);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:1px solid var(--feedback-modal-element-selected-border-color)}@media screen and (min-width: 768px){.feedback-modal-content{max-width:600px}.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:300px;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:300px;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}}";
7880
+
7881
+ const FeedbackModal = class {
7882
+ constructor(hostRef) {
7883
+ registerInstance(this, hostRef);
7884
+ this.onScrollDebounced = () => {
7885
+ clearTimeout(this.scrollTimeout);
7886
+ this.scrollTimeout = setTimeout(() => {
7887
+ document.documentElement.classList.remove('feedback-modal-screenshot-closing');
7888
+ document.documentElement.style.top = "";
7889
+ window.removeEventListener('scroll', this.onScrollDebounced);
7890
+ }, 200);
7891
+ };
7892
+ this.handleSubmit = async (event) => {
7893
+ event.preventDefault();
7894
+ this.resetOverflow();
7895
+ this.showScreenshotMode = false;
7896
+ this.showScreenshotTopBar = false;
7897
+ this.showModal = false;
7898
+ this.sending = true;
7899
+ try {
7900
+ const res = await fetch('https://app.pushfeedback.com/api/feedback/', {
7901
+ method: 'POST',
7902
+ body: JSON.stringify({
7903
+ url: window.location.href,
7904
+ message: this.formMessage,
7905
+ email: this.formEmail,
7906
+ project: this.project,
7907
+ screenshot: this.encodedScreenshot,
7908
+ rating: this.selectedRating,
7909
+ ratingMode: this.ratingMode,
7910
+ verification: this.formVerification,
7911
+ session: localStorage.getItem('pushfeedback_sessionid') || '',
7912
+ }),
7913
+ headers: {
7914
+ 'Content-Type': 'application/json'
7915
+ }
7916
+ });
7917
+ if (res.status === 201) {
7918
+ this.formSuccess = true;
7919
+ this.formError = false;
7920
+ }
7921
+ else {
7922
+ this.formSuccess = false;
7923
+ this.formError = true;
7924
+ this.formErrorStatus = res.status;
7925
+ }
7926
+ }
7927
+ catch (error) {
7928
+ console.log(error);
7929
+ this.formSuccess = false;
7930
+ this.formError = true;
7931
+ this.formErrorStatus = 500;
7932
+ }
7933
+ finally {
7934
+ this.sending = false;
7935
+ this.showModal = true;
7936
+ }
7937
+ };
7938
+ this.close = () => {
7939
+ this.sending = false;
7940
+ this.showModal = false;
7941
+ this.showScreenshotMode = false;
7942
+ this.showScreenshotTopBar = false;
7943
+ this.hasSelectedElement = false;
7944
+ this.encodedScreenshot = null;
7945
+ this.formSuccess = false;
7946
+ this.formError = false;
7947
+ this.formErrorStatus = 500;
7948
+ this.formMessage = '';
7949
+ this.formEmail = '';
7950
+ this.resetOverflow();
7951
+ };
7952
+ this.openScreenShot = () => {
7953
+ this.hasSelectedElement = false;
7954
+ this.showModal = false;
7955
+ this.showScreenshotMode = true;
7956
+ this.showScreenshotTopBar = true;
7957
+ this.encodedScreenshot = null;
7958
+ if (window.innerWidth > document.documentElement.clientWidth) {
7959
+ document.documentElement.classList.add('feedback-modal-screenshot-open--scroll');
7960
+ }
7961
+ const scrollY = window.scrollY;
7962
+ document.documentElement.style.top = `-${scrollY}px`;
7963
+ window.scrollTo(0, parseInt(document.documentElement.style.top || '0') * -1);
7964
+ document.documentElement.classList.add('feedback-modal-screenshot-open');
7965
+ };
7966
+ this.closeScreenShot = () => {
7967
+ this.showModal = false;
7968
+ this.showScreenshotMode = false;
7969
+ this.showScreenshotTopBar = false;
7970
+ this.hasSelectedElement = false;
7971
+ this.encodedScreenshot = null;
7972
+ this.resetOverflow();
7973
+ };
7974
+ this.handleMouseOverScreenShot = (event) => {
7975
+ event.preventDefault();
7976
+ if (this.hasSelectedElement)
7977
+ return;
7978
+ const borderOffset = 2;
7979
+ this.screenshotModal.style.display = 'none';
7980
+ const elementUnder = document.elementFromPoint(event.clientX, event.clientY);
7981
+ const rect = elementUnder.getBoundingClientRect();
7982
+ this.screenshotModal.style.display = '';
7983
+ // Get the bounding box of the element selected
7984
+ this.elementSelected.style.position = "absolute";
7985
+ this.elementSelected.style.left = `${rect.left}px`;
7986
+ this.elementSelected.style.top = `${rect.top}px`;
7987
+ this.elementSelected.style.width = `${rect.width}px`;
7988
+ this.elementSelected.style.height = `${rect.height}px`;
7989
+ this.elementSelected.classList.add('feedback-modal-element-hover');
7990
+ // Set the background color of nonselected areas
7991
+ // Top
7992
+ this.topSide.style.position = "absolute";
7993
+ this.topSide.style.left = `${rect.left}px`;
7994
+ this.topSide.style.top = '0px';
7995
+ this.topSide.style.width = `${rect.width + borderOffset}px`;
7996
+ this.topSide.style.height = `${rect.top}px`;
7997
+ this.topSide.style.backgroundColor = "rgba(0, 0, 0, 0.4)";
7998
+ // Left
7999
+ this.leftSide.style.position = "absolute";
8000
+ this.leftSide.style.left = '0px';
8001
+ this.leftSide.style.top = '0px';
8002
+ this.leftSide.style.width = `${rect.left}px`;
8003
+ this.leftSide.style.height = '100vh';
8004
+ this.leftSide.style.backgroundColor = "rgba(0, 0, 0, 0.4)";
8005
+ // Bottom
8006
+ this.bottomSide.style.position = "absolute";
8007
+ this.bottomSide.style.left = `${rect.left}px`;
8008
+ this.bottomSide.style.top = `${rect.bottom + borderOffset}px`;
8009
+ this.bottomSide.style.width = `${rect.width + borderOffset}px`;
8010
+ this.bottomSide.style.height = '100vh';
8011
+ this.bottomSide.style.backgroundColor = "rgba(0, 0, 0, 0.4)";
8012
+ // Right
8013
+ this.rightSide.style.position = "absolute";
8014
+ this.rightSide.style.left = `${rect.right + borderOffset}px`;
8015
+ ;
8016
+ this.rightSide.style.top = '0px';
8017
+ this.rightSide.style.width = '100%';
8018
+ this.rightSide.style.height = '100vh';
8019
+ this.rightSide.style.backgroundColor = "rgba(0, 0, 0, 0.4)";
8020
+ // Restore the visibility of the screenshot-modal
8021
+ this.screenshotModal.style.backgroundColor = 'transparent';
8022
+ };
8023
+ this.handleMouseClickedSelectedElement = async (event) => {
8024
+ event.preventDefault();
8025
+ if (!this.elementSelected) {
8026
+ return;
8027
+ }
8028
+ this.hasSelectedElement = true;
8029
+ this.elementSelected.classList.add('feedback-modal-element-selected');
8030
+ // Get the top position including the scroll offset
8031
+ const rectTop = this.elementSelected.getBoundingClientRect().top;
8032
+ const topWithScroll = rectTop + window.scrollY;
8033
+ // Move the element with the scroll offset
8034
+ this.elementSelected.style.top = `${topWithScroll}px`;
8035
+ // Clone the selected element and append it to the body
8036
+ const clonedElementSelected = this.elementSelected.cloneNode(true);
8037
+ document.body.appendChild(clonedElementSelected);
8038
+ // Reset the top position of the original element
8039
+ this.elementSelected.style.top = `${rectTop}px`;
8040
+ this.showScreenshotTopBar = false;
8041
+ this.showModal = false;
8042
+ try {
8043
+ const dataUrl = await this.captureScreenshot();
8044
+ console.log('Screenshot captured');
8045
+ this.encodedScreenshot = dataUrl;
8046
+ }
8047
+ catch (error) {
8048
+ console.error('Failed to capture screenshot:', error);
8049
+ this.hasSelectedElement = false;
8050
+ }
8051
+ finally {
8052
+ // Remove the cloned element and show the modal again
8053
+ document.body.removeChild(clonedElementSelected);
8054
+ this.showModal = true;
8055
+ }
8056
+ };
8057
+ this.sending = false;
8058
+ this.formMessage = '';
8059
+ this.formEmail = '';
8060
+ this.formSuccess = false;
8061
+ this.formVerification = '';
8062
+ this.formError = false;
8063
+ this.formErrorStatus = 500;
8064
+ this.encodedScreenshot = undefined;
8065
+ this.isPrivacyChecked = false;
8066
+ this.whitelabel = false;
8067
+ this.selectedRating = 0;
8068
+ this.errorMessage = "Please try again later.";
8069
+ this.errorMessage403 = "The request URL does not match the one defined in PushFeedback for this project.";
8070
+ this.errorMessage404 = "We could not find the provided project ID in PushFeedback.";
8071
+ this.modalTitle = 'Share your feedback';
8072
+ this.modalTitleSuccess = 'Thanks for your feedback!';
8073
+ this.modalTitleError = "Oops!";
8074
+ this.modalPosition = 'center';
8075
+ this.sendButtonText = 'Send';
8076
+ this.successMessage = "";
8077
+ this.project = '';
8078
+ this.screenshotButtonText = 'Add a screenshot';
8079
+ this.screenshotTopbarText = 'Select an element on this page';
8080
+ this.hideEmail = false;
8081
+ this.emailAddress = '';
8082
+ this.emailPlaceholder = 'Email address (optional)';
8083
+ this.messagePlaceholder = 'Comments';
8084
+ this.hideRating = false;
8085
+ this.rating = undefined;
8086
+ this.ratingMode = 'thumbs';
8087
+ this.ratingPlaceholder = 'Was this page helpful?';
8088
+ this.ratingStarsPlaceholder = 'How would you rate this page?';
8089
+ this.showModal = false;
8090
+ this.showScreenshotMode = false;
8091
+ this.showScreenshotTopBar = false;
8092
+ this.hasSelectedElement = false;
8093
+ this.hideScreenshotButton = false;
8094
+ this.hidePrivacyPolicy = true;
8095
+ this.privacyPolicyText = "I have read and expressly consent to the terms of the <a href='https://pushfeedback.com/privacy'>Privacy Policy</a>.";
8096
+ this.fetchData = true;
8097
+ }
8098
+ componentWillLoad() {
8099
+ if (this.fetchData)
8100
+ this.fetchProjectData();
8101
+ this.formEmail = this.emailAddress;
8102
+ if (this.rating) {
8103
+ this.selectedRating = this.rating;
8104
+ }
8105
+ if (this.ratingMode == "thumbs" && this.rating == 0) {
8106
+ this.selectedRating = 5;
8107
+ }
8108
+ }
8109
+ async fetchProjectData() {
8110
+ try {
8111
+ const response = await fetch('https://app.pushfeedback.com/api/projects/' + this.project + '/');
8112
+ const data = await response.json();
8113
+ this.whitelabel = data.whitelabel;
8114
+ }
8115
+ catch (error) {
8116
+ console.log(error);
8117
+ }
8118
+ }
8119
+ resetOverflow() {
8120
+ document.documentElement.classList.remove('feedback-modal-screenshot-open');
8121
+ document.documentElement.classList.remove('feedback-modal-screenshot-open--scroll');
8122
+ document.documentElement.classList.add('feedback-modal-screenshot-closing');
8123
+ window.scrollTo(0, parseInt(document.documentElement.style.top || '0') * -1);
8124
+ window.addEventListener('scroll', this.onScrollDebounced);
8125
+ }
8126
+ handleMessageInput(event) {
8127
+ this.formMessage = event.target.value;
8128
+ }
8129
+ handleEmailInput(event) {
8130
+ this.formEmail = event.target.value;
8131
+ }
8132
+ captureScreenshot() {
8133
+ return new Promise((resolve, reject) => {
8134
+ requestAnimationFrame(() => {
8135
+ html2canvas(document.body, {
8136
+ x: window.scrollX,
8137
+ y: window.scrollY,
8138
+ width: window.innerWidth,
8139
+ height: window.innerHeight,
8140
+ }).then(canvas => {
8141
+ const dataUrl = canvas.toDataURL();
8142
+ resolve(dataUrl);
8143
+ })
8144
+ .catch(error => {
8145
+ console.error(error);
8146
+ reject(error);
8147
+ });
8148
+ });
8149
+ });
8150
+ }
8151
+ handleCheckboxChange(event) {
8152
+ this.isPrivacyChecked = event.target.checked;
8153
+ }
8154
+ handleVerification(event) {
8155
+ this.formVerification = event.target.value;
8156
+ }
8157
+ handleRatingChange(newRating) {
8158
+ this.selectedRating = newRating;
8159
+ }
8160
+ render() {
8161
+ return (h("div", { class: 'feedback-modal-wrapper' }, this.showScreenshotMode && (h("div", { class: "feedback-modal-screenshot", ref: el => (this.screenshotModal = el), onMouseMove: this.handleMouseOverScreenShot }, h("div", { class: "feedback-modal-screenshot-element-selected", ref: el => (this.elementSelected = el), onClick: this.handleMouseClickedSelectedElement }), h("div", { class: "top-side", ref: el => (this.topSide = el) }), h("div", { class: "left-side", ref: el => (this.leftSide = el) }), h("div", { class: "bottom-side", ref: el => (this.bottomSide = el) }), h("div", { class: "right-side", ref: el => (this.rightSide = el) }), this.showScreenshotTopBar && (h("div", { class: "feedback-modal-screenshot-header", onClick: this.closeScreenShot }, h("span", null, this.screenshotTopbarText), h("span", { class: "feedback-modal-screenshot-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" }))))))), this.showModal && (h("div", { class: "feedback-overlay" })), this.showModal && (h("div", { class: `feedback-modal-content feedback-modal-content--${this.modalPosition} ${this.showModal ? '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 ? 'feedback-modal-rating-button--selected' : ''}`, onClick: (event) => {
8162
+ event.preventDefault();
8163
+ this.handleRatingChange(1);
8164
+ } }, 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 ? 'feedback-modal-rating-button--selected' : ''}`, onClick: (event) => {
8165
+ event.preventDefault();
8166
+ this.handleRatingChange(5);
8167
+ } }, 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 ? 'feedback-modal-rating-button--selected' : ''}`, onClick: (event) => {
8168
+ event.preventDefault();
8169
+ this.handleRatingChange(rating);
8170
+ } }, 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 }))), 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 }, 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.screenshotButtonText)), h("button", { class: "feedback-modal-button feedback-modal-button--submit", type: "submit", disabled: this.sending }, this.sendButtonText)))) : this.formSuccess && !this.formError ? (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", style: { display: this.whitelabel ? 'none' : 'block' } }, h("div", { class: "feedback-logo" }, "Powered by ", h("a", { target: "_blank", href: "https://pushfeedback.com" }, "PushFeedback.com")))))));
8171
+ }
8172
+ };
8173
+ FeedbackModal.style = feedbackModalCss;
8197
8174
 
8198
- export { FeedbackModal as F, defineCustomElement as d };
8175
+ export { FeedbackModal as feedback_modal };