pushfeedback 0.0.9 → 0.0.11

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.
@@ -992,7 +992,7 @@ const FeedbackModal = class {
992
992
  return dataUrl;
993
993
  })
994
994
  .catch(function (error) {
995
- console.log(error);
995
+ console.error('Oops, something went wrong!', error);
996
996
  return "";
997
997
  });
998
998
  const page = document.getElementsByTagName('html')[0];
@@ -143,7 +143,7 @@ export class FeedbackModal {
143
143
  return dataUrl;
144
144
  })
145
145
  .catch(function (error) {
146
- console.log(error);
146
+ console.error('Oops, something went wrong!', error);
147
147
  return "";
148
148
  });
149
149
  const page = document.getElementsByTagName('html')[0];
@@ -929,7 +929,7 @@ const FeedbackModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
929
929
  return dataUrl;
930
930
  })
931
931
  .catch(function (error) {
932
- console.log(error);
932
+ console.error('Oops, something went wrong!', error);
933
933
  return "";
934
934
  });
935
935
  const page = document.getElementsByTagName('html')[0];
@@ -988,7 +988,7 @@ const FeedbackModal = class {
988
988
  return dataUrl;
989
989
  })
990
990
  .catch(function (error) {
991
- console.log(error);
991
+ console.error('Oops, something went wrong!', error);
992
992
  return "";
993
993
  });
994
994
  const page = document.getElementsByTagName('html')[0];
@@ -1 +1 @@
1
- import{r as t,h as e,H as o,g as n}from"./p-38d135e1.js";const i=class{constructor(e){t(this,e),this.modalTitle="Share your feedback",this.successModalTitle="Thanks for your feedback!",this.errorModalTitle="Oops! We didn't receive your feedback. Please try again later.",this.modalPosition="center",this.sendButtonText="Send",this.project="",this.screenshotButtonTooltipText="Take a Screenshot",this.screenshotTopbarText="SELECT AN ELEMENT ON THE PAGE",this.email="",this.emailPlaceholder="Email address (optional)",this.messagePlaceholder="How could this page be more helpful?",this.buttonStyle="default",this.buttonPosition="default",this.hideIcon=!1,this.hideScreenshotButton=!1}connectedCallback(){this.feedbackModal=document.createElement("feedback-modal"),["modalTitle","successModalTitle","errorModalTitle","modalPosition","sendButtonText","project","screenshotButtonTooltipText","screenshotTopbarText","email","emailPlaceholder","messagePlaceholder","hideScreenshotButton"].forEach((t=>{this.feedbackModal[t]=this[t]})),document.body.appendChild(this.feedbackModal)}disconnectedCallback(){document.body.removeChild(this.feedbackModal)}componentDidLoad(){if("center-right"===this.buttonPosition){const t=this.el.shadowRoot.querySelector(".feedback-button-content");t.style.right=t.offsetWidth/2*-1+"px"}}showModal(){this.feedbackModal.showModal=!0}render(){return e(o,null,e("a",{class:`feedback-button-content feedback-button-content--${this.buttonStyle} feedback-button-content--${this.buttonPosition}`,onClick:()=>this.showModal()},!this.hideIcon&&"dark"===this.buttonStyle&&e("span",{class:"feedback-button-content-icon"},e("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:"feather feather-repeat"},e("polyline",{points:"17 1 21 5 17 9"}),e("path",{d:"M3 11V9a4 4 0 0 1 4-4h14"}),e("polyline",{points:"7 23 3 19 7 15"}),e("path",{d:"M21 13v2a4 4 0 0 1-4 4H3"}))),!this.hideIcon&&"light"===this.buttonStyle&&e("span",{class:"feedback-button-content-icon"},e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#0070F4","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-repeat"},e("polyline",{points:"17 1 21 5 17 9"}),e("path",{d:"M3 11V9a4 4 0 0 1 4-4h14"}),e("polyline",{points:"7 23 3 19 7 15"}),e("path",{d:"M21 13v2a4 4 0 0 1-4 4H3"}))),e("slot",null)))}get el(){return n(this)}};i.style=".feedback-button-content{cursor:pointer;z-index:300}.feedback-button-content--light{align-items:center;background-color:var(--feedback-white-color);border-radius:20px;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;display:flex;font-family:var(--feedback-font-family);color:var(--feedback-primary-color);font-weight:bold;padding:8px 15px;font-size:var(--feedback-text-font-size)}.feedback-button-content--dark{align-items:center;background-color:var(--feedback-primary-color);border-radius:20px;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;display:flex;font-family:var(--feedback-font-family);color:var(--feedback-white-color);font-weight:bold;padding:8px 15px;font-size:16px}.feedback-button-content--bottom-right{position:fixed;bottom:10px;right:10px}.feedback-button-content--center-right{position:fixed;top:50%;transform:rotate(-90deg) translateY(-50%)}.feedback-button-content--center-right.feedback-button-content--dark,.feedback-button-content--center-right.feedback-button-content--light{border-radius:4px;border-bottom-right-radius:0px;border-bottom-left-radius:0px}.feedback-button-content-icon{margin-right:5px;height:16px;width:16px}";var r,a,s=(r=function(t){!function(){var e=function(){return{escape:function(t){return t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")},parseExtension:e,mimeType:function(t){var o,n;return(o="application/font-woff",n="image/jpeg",{woff:o,woff2:o,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:n,jpeg:n,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"})[e(t).toLowerCase()]||""},dataAsUrl:function(t,e){return"data:"+e+";base64,"+t},isDataUrl:function(t){return-1!==t.search(/^(data:)/)},canvasToBlob:function(t){return t.toBlob?new Promise((function(e){t.toBlob(e)})):function(t){return new Promise((function(e){for(var o=window.atob(t.toDataURL().split(",")[1]),n=o.length,i=new Uint8Array(n),r=0;r<n;r++)i[r]=o.charCodeAt(r);e(new Blob([i],{type:"image/png"}))}))}(t)},resolveUrl:function(t,e){var o=document.implementation.createHTMLDocument(),n=o.createElement("base");o.head.appendChild(n);var i=o.createElement("a");return o.body.appendChild(i),n.href=e,i.href=t,i.href},getAndEncode:function(t){return s.impl.options.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime()),new Promise((function(e){var o,n=new XMLHttpRequest;if(n.onreadystatechange=function(){if(4===n.readyState)if(200===n.status){var i=new FileReader;i.onloadend=function(){var t=i.result.split(/,/)[1];e(t)},i.readAsDataURL(n.response)}else o?e(o):r("cannot fetch resource: "+t+", status: "+n.status)},n.ontimeout=function(){o?e(o):r("timeout of 30000ms occured while fetching resource: "+t)},n.responseType="blob",n.timeout=3e4,n.open("GET",t,!0),n.send(),s.impl.options.imagePlaceholder){var i=s.impl.options.imagePlaceholder.split(/,/);i&&i[1]&&(o=i[1])}function r(t){console.error(t),e("")}}))},uid:(t=0,function(){return"u"+("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)+t++}),delay:function(t){return function(e){return new Promise((function(o){setTimeout((function(){o(e)}),t)}))}},asArray:function(t){for(var e=[],o=t.length,n=0;n<o;n++)e.push(t[n]);return e},escapeXhtml:function(t){return t.replace(/#/g,"%23").replace(/\n/g,"%0A")},makeImage:function(t){return new Promise((function(e,o){var n=new Image;n.onload=function(){e(n)},n.onerror=o,n.src=t}))},width:function(t){var e=o(t,"border-left-width"),n=o(t,"border-right-width");return t.scrollWidth+e+n},height:function(t){var e=o(t,"border-top-width"),n=o(t,"border-bottom-width");return t.scrollHeight+e+n}};var t;function e(t){var e=/\.([^\.\/]*?)$/g.exec(t);return e?e[1]:""}function o(t,e){var o=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(o.replace("px",""))}}(),o=function(){var t=/url\(['"]?([^'"]+?)['"]?\)/g;return{inlineAll:function(t,e,r){return o(t)?Promise.resolve(t).then(n).then((function(o){var n=Promise.resolve(t);return o.forEach((function(t){n=n.then((function(o){return i(o,t,e,r)}))})),n})):Promise.resolve(t)},shouldProcess:o,impl:{readUrls:n,inline:i}};function o(e){return-1!==e.search(t)}function n(o){for(var n,i=[];null!==(n=t.exec(o));)i.push(n[1]);return i.filter((function(t){return!e.isDataUrl(t)}))}function i(t,o,n,i){return Promise.resolve(o).then((function(t){return n?e.resolveUrl(t,n):t})).then(i||e.getAndEncode).then((function(t){return e.dataAsUrl(t,e.mimeType(o))})).then((function(n){return t.replace(function(t){return new RegExp("(url\\(['\"]?)("+e.escape(t)+")(['\"]?\\))","g")}(o),"$1"+n+"$3")}))}}(),n=function(){return{resolveAll:function(){return t().then((function(t){return Promise.all(t.map((function(t){return t.resolve()})))})).then((function(t){return t.join("\n")}))},impl:{readAll:t}};function t(){return Promise.resolve(e.asArray(document.styleSheets)).then((function(t){var o=[];return t.forEach((function(t){try{e.asArray(t.cssRules||[]).forEach(o.push.bind(o))}catch(e){console.log("Error while reading CSS rules from "+t.href,e.toString())}})),o})).then((function(t){return t.filter((function(t){return t.type===CSSRule.FONT_FACE_RULE})).filter((function(t){return o.shouldProcess(t.style.getPropertyValue("src"))}))})).then((function(e){return e.map(t)}));function t(t){return{resolve:function(){return o.inlineAll(t.cssText,(t.parentStyleSheet||{}).href)},src:function(){return t.style.getPropertyValue("src")}}}}}(),i=function(){return{inlineAll:function n(i){return i instanceof Element?function(t){var e=t.style.getPropertyValue("background");return e?o.inlineAll(e).then((function(e){t.style.setProperty("background",e,t.style.getPropertyPriority("background"))})).then((function(){return t})):Promise.resolve(t)}(i).then((function(){return i instanceof HTMLImageElement?t(i).inline():Promise.all(e.asArray(i.childNodes).map((function(t){return n(t)})))})):Promise.resolve(i)},impl:{newImage:t}};function t(t){return{inline:function(o){return e.isDataUrl(t.src)?Promise.resolve():Promise.resolve(t.src).then(o||e.getAndEncode).then((function(o){return e.dataAsUrl(o,e.mimeType(t.src))})).then((function(e){return new Promise((function(o,n){t.onload=o,t.onerror=n,t.src=e}))}))}}}}(),r=void 0,a=!1,s={toSvg:c,toPng:function(t,e){return d(t,e||{}).then((function(t){return t.toDataURL()}))},toJpeg:function(t,e){return d(t,e=e||{}).then((function(t){return t.toDataURL("image/jpeg",e.quality||1)}))},toBlob:function(t,o){return d(t,o||{}).then(e.canvasToBlob)},toPixelData:function(t,o){return d(t,o||{}).then((function(o){return o.getContext("2d").getImageData(0,0,e.width(t),e.height(t)).data}))},impl:{fontFaces:n,images:i,util:e,inliner:o,options:{}}};function c(t,o){return function(t){s.impl.options.imagePlaceholder=void 0===t.imagePlaceholder?r:t.imagePlaceholder,s.impl.options.cacheBust=void 0===t.cacheBust?a:t.cacheBust}(o=o||{}),Promise.resolve(t).then((function(t){return l(t,o.filter,!0)})).then(f).then(u).then((function(t){return o.bgcolor&&(t.style.backgroundColor=o.bgcolor),o.width&&(t.style.width=o.width+"px"),o.height&&(t.style.height=o.height+"px"),o.style&&Object.keys(o.style).forEach((function(e){t.style[e]=o.style[e]})),t})).then((function(n){return function(t,o,n){return Promise.resolve(t).then((function(t){return t.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),(new XMLSerializer).serializeToString(t)})).then(e.escapeXhtml).then((function(t){return'<foreignObject x="0" y="0" width="100%" height="100%">'+t+"</foreignObject>"})).then((function(t){return'<svg xmlns="http://www.w3.org/2000/svg" width="'+o+'" height="'+n+'">'+t+"</svg>"})).then((function(t){return"data:image/svg+xml;charset=utf-8,"+t}))}(n,o.width||e.width(t),o.height||e.height(t))}))}function d(t,o){return c(t,o).then(e.makeImage).then(e.delay(100)).then((function(n){var i=function(t){var n=document.createElement("canvas");if(n.width=o.width||e.width(t),n.height=o.height||e.height(t),o.bgcolor){var i=n.getContext("2d");i.fillStyle=o.bgcolor,i.fillRect(0,0,n.width,n.height)}return n}(t);return i.getContext("2d").drawImage(n,0,0),i}))}function l(t,o,n){return n||!o||o(t)?Promise.resolve(t).then((function(t){return t instanceof HTMLCanvasElement?e.makeImage(t.toDataURL()):t.cloneNode(!1)})).then((function(n){return function(t,o,n){var i=t.childNodes;return 0===i.length?Promise.resolve(o):function(t,e,o){var n=Promise.resolve();return e.forEach((function(e){n=n.then((function(){return l(e,o)})).then((function(e){e&&t.appendChild(e)}))})),n}(o,e.asArray(i),n).then((function(){return o}))}(t,n,o)})).then((function(o){return function(t,o){return o instanceof Element?Promise.resolve().then((function(){n=window.getComputedStyle(t),i=o.style,n.cssText?i.cssText=n.cssText:function(t,o){e.asArray(t).forEach((function(e){o.setProperty(e,t.getPropertyValue(e),t.getPropertyPriority(e))}))}(n,i);var n,i})).then((function(){[":before",":after"].forEach((function(n){!function(n){var i=window.getComputedStyle(t,n),r=i.getPropertyValue("content");if(""!==r&&"none"!==r){var a=e.uid();o.className=o.className+" "+a;var s=document.createElement("style");s.appendChild(function(t,o,n){var i="."+t+":"+o,r=n.cssText?a(n):s(n);return document.createTextNode(i+"{"+r+"}");function a(t){var e=t.getPropertyValue("content");return t.cssText+" content: "+e+";"}function s(t){return e.asArray(t).map(o).join("; ")+";";function o(e){return e+": "+t.getPropertyValue(e)+(t.getPropertyPriority(e)?" !important":"")}}}(a,n,i)),o.appendChild(s)}}(n)}))})).then((function(){t instanceof HTMLTextAreaElement&&(o.innerHTML=t.value),t instanceof HTMLInputElement&&o.setAttribute("value",t.value)})).then((function(){o instanceof SVGElement&&(o.setAttribute("xmlns","http://www.w3.org/2000/svg"),o instanceof SVGRectElement&&["width","height"].forEach((function(t){var e=o.getAttribute(t);e&&o.style.setProperty(t,e)})))})).then((function(){return o})):o}(t,o)})):Promise.resolve()}function f(t){return n.resolveAll().then((function(e){var o=document.createElement("style");return t.appendChild(o),o.appendChild(document.createTextNode(e)),t}))}function u(t){return i.inlineAll(t).then((function(){return t}))}t.exports=s}()},r(a={path:undefined,exports:{},require:function(){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}}),a.exports);const c=class{constructor(e){t(this,e),this.handleSubmit=async t=>{t.preventDefault(),this.resetOverflow(),this.showScreenshotMode=!1,this.showModal=!1,this.sending=!0;let e="";this.encodedScreenshot&&await this.encodedScreenshot.then((t=>{e=t})).catch((t=>{console.log(t)}));try{const t=await fetch("https://app.pushfeedback.com/api/feedback/",{method:"POST",body:JSON.stringify({url:window.location.href,message:this.formMessage,email:this.formEmail,project:this.project,screenshot:e}),headers:{"Content-Type":"application/json"}});201===t.status?(this.formSuccess=!0,this.formError=!1):(this.formSuccess=!1,this.formError=!0,this.formErrorStatus=t.status)}catch(t){console.log(t),this.formSuccess=!1,this.formError=!0,this.formErrorStatus=500}finally{this.sending=!1,this.showModal=!0}},this.close=()=>{this.sending=!1,this.showModal=!1,this.showScreenshotMode=!1,this.hasSelectedElement=!1,this.encodedScreenshot=null,this.formSuccess=!1,this.formError=!1,this.formErrorStatus=500,this.formMessage="",this.formEmail="",this.resetOverflow()},this.openScreenShot=()=>{this.hasSelectedElement=!1,this.showModal=!1,this.showScreenshotMode=!0,this.encodedScreenshot=null,this.resetOverflow()},this.closeScreenShot=()=>{this.showModal=!1,this.showScreenshotMode=!1,this.hasSelectedElement=!1,this.encodedScreenshot=null,this.overlay.style.display="none",this.resetOverflow()},this.handleMouseOverScreenShot=t=>{if(t.preventDefault(),this.hasSelectedElement)return;this.overlay.style.display="none",this.screenshotModal.style.display="none";const e=document.elementFromPoint(t.clientX,t.clientY).getBoundingClientRect();this.screenshotModal.style.display="",this.elementSelected.style.position="absolute",this.elementSelected.style.left=`${e.left}px`,this.elementSelected.style.top=`${e.top}px`,this.elementSelected.style.width=`${e.width}px`,this.elementSelected.style.height=`${e.height}px`,this.elementSelected.classList.add("feedback-modal-element-hover"),this.topSide.style.position="absolute",this.topSide.style.left=`${e.left}px`,this.topSide.style.top="0px",this.topSide.style.width=`${e.width+8}px`,this.topSide.style.height=`${e.top}px`,this.topSide.style.backgroundColor="rgba(0, 0, 0, 0.3)",this.leftSide.style.position="absolute",this.leftSide.style.left="0px",this.leftSide.style.top="0px",this.leftSide.style.width=`${e.left}px`,this.leftSide.style.height="100vh",this.leftSide.style.backgroundColor="rgba(0, 0, 0, 0.3)",this.bottomSide.style.position="absolute",this.bottomSide.style.left=`${e.left}px`,this.bottomSide.style.top=`${e.bottom+8}px`,this.bottomSide.style.width=`${e.width+8}px`,this.bottomSide.style.height="100vh",this.bottomSide.style.backgroundColor="rgba(0, 0, 0, 0.3)",this.rightSide.style.position="absolute",this.rightSide.style.left=`${e.right+8}px`,this.rightSide.style.top="0px",this.rightSide.style.width="100%",this.rightSide.style.height="100vh",this.rightSide.style.backgroundColor="rgba(0, 0, 0, 0.3)",this.screenshotModal.style.backgroundColor="transparent"},this.handleMouseClickedSelectedElement=t=>{t.preventDefault(),this.elementSelected&&this.elementSelected.classList.add("feedback-modal-element-selected");let e=this.elementSelected.getBoundingClientRect().top;this.elementSelected.style.top=`${e+window.pageYOffset}px`;const o=this.elementSelected.cloneNode(!0);document.body.appendChild(o),this.elementSelected.style.top=`${e}px`,this.encodedScreenshot=s.toPng(document.body,{cacheBust:!0}).then((function(t){return document.body.removeChild(o),t})).catch((function(t){return console.log(t),""})),document.getElementsByTagName("html")[0].style.overflow="hidden",this.hasSelectedElement=!0,this.overlay.style.display="block",this.showModal=!0},this.sending=!1,this.formMessage="",this.formEmail="",this.formSuccess=!1,this.formError=!1,this.formErrorStatus=500,this.encodedScreenshot=void 0,this.modalTitle="Share your feedback",this.modalTitleSuccess="Thanks for your feedback!",this.modalTitleError="Oops! We didn't receive your feedback. Please try again later.",this.modalTitleError403="Oops! The request URL does not match the one defined in PushFeedback for this project.",this.modalTitleError404="Oops! We could not find the provided project id in PushFeedback.",this.modalPosition="center",this.sendButtonText="Send",this.project="",this.screenshotButtonTooltipText="Take a Screenshot",this.screenshotTopbarText="SELECT AN ELEMENT ON THE PAGE",this.email="",this.emailPlaceholder="Email address (optional)",this.messagePlaceholder="How could this page be more helpful?",this.showModal=!1,this.showScreenshotMode=!1,this.hasSelectedElement=!1,this.hideScreenshotButton=!1}componentWillLoad(){this.formEmail=this.email}resetOverflow(){document.getElementsByTagName("html")[0].style.overflow="inherit"}handleMessageInput(t){this.formMessage=t.target.value}handleEmailInput(t){this.formEmail=t.target.value}render(){return e("div",{class:"feedback-modal-wrapper"},this.showScreenshotMode&&e("div",{class:"feedback-modal-screenshot",ref:t=>this.screenshotModal=t,onMouseMove:this.handleMouseOverScreenShot},e("div",{class:"feedback-modal-screenshot-element-selected",ref:t=>this.elementSelected=t,onClick:this.handleMouseClickedSelectedElement}),e("div",{class:"top-side",ref:t=>this.topSide=t}),e("div",{class:"left-side",ref:t=>this.leftSide=t}),e("div",{class:"bottom-side",ref:t=>this.bottomSide=t}),e("div",{class:"right-side",ref:t=>this.rightSide=t}),e("div",{class:"feedback-modal-screenshot-header",onClick:this.closeScreenShot},e("span",null,this.screenshotTopbarText),e("span",{class:"feedback-modal-screenshot-close"},e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-x"},e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})))),e("div",{class:"feedback-modal-screenshot-overlay",ref:t=>this.overlay=t})),this.showModal&&e("div",{class:`feedback-modal-content feedback-modal-content--${this.modalPosition}`,ref:t=>this.modalContent=t},e("div",{class:"feedback-modal-header"},this.formSuccess||this.formError?this.formSuccess?e("span",{class:"text-center"},this.modalTitleSuccess):this.formError&&500==this.formErrorStatus?e("span",{class:"text-center"},this.modalTitleError):this.formError&&403==this.formErrorStatus?e("span",{class:"text-center"},this.modalTitleError403):this.formError&&404==this.formErrorStatus?e("span",{class:"text-center"},this.modalTitleError404):e("span",null):e("span",null,this.modalTitle),e("button",{class:"feedback-modal-close",onClick:this.close},e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#ccc","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-x"},e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})))),e("div",{class:"feedback-modal-body"},this.formSuccess||this.formError?e("span",null):e("form",{onSubmit:this.handleSubmit},e("div",{class:"feedback-modal-text"},e("textarea",{placeholder:this.messagePlaceholder,value:this.formMessage,onInput:t=>this.handleMessageInput(t),required:!0})),!this.email&&e("div",{class:"feedback-modal-email"},e("input",{type:"email",placeholder:this.emailPlaceholder,onInput:t=>this.handleEmailInput(t),value:this.formEmail})),e("div",{class:"feedback-modal-buttons "+(this.hideScreenshotButton?"single":"")},!this.hideScreenshotButton&&e("button",{type:"button",class:"button"+(this.encodedScreenshot?" active":""),title:this.screenshotButtonTooltipText,onClick:this.openScreenShot,disabled:this.sending},e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-camera"},e("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),e("circle",{cx:"12",cy:"13",r:"4"}))),e("button",{class:"button",type:"submit",disabled:this.sending},this.sendButtonText)))),e("div",{class:"feedback-modal-footer"},e("div",{class:"feedback-logo"},e("svg",{class:"w-8 h-8",viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg"},e("defs",null,e("radialGradient",{cx:"21.152%",cy:"86.063%",fx:"21.152%",fy:"86.063%",r:"79.941%",id:"footer-logo"},e("stop",{"stop-color":"#4FD1C5",offset:"0%"}),e("stop",{"stop-color":"#81E6D9",offset:"25.871%"}),e("stop",{"stop-color":"#338CF5",offset:"100%"}))),e("rect",{width:"32",height:"32",rx:"16",fill:"url(#footer-logo)","fill-rule":"nonzero"}))," ",e("a",{href:"https://pushfeedback.com"},"PushFeedback")))))}};c.style=".text-center{text-align:center;flex-grow: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;font-family:var(--feedback-modal-content-font-family);max-width:300px;padding:20px;position:fixed;width:100%;z-index:300;left:50%;top:50%;transform:translate(-50%, -50%)}@media screen and (min-width: 768px){.feedback-modal-content.feedback-modal-content--bottom-right{top:initial;left:initial;transform:initial;bottom:var(--feedback-modal-content-position-bottom);right:var(--feedback-modal-content-position-right)}.feedback-modal-content.feedback-modal-content--bottom-left{top:initial;transform:initial;bottom:var(--feedback-modal-content-position-bottom);left:var(--feedback-modal-content-position-left)}.feedback-modal-content.feedback-modal-content--top-right{top:initial;transform:initial;right:var(--feedback-modal-content-position-right);top:var(--fedback-modal-content-position-top)}.feedback-modal-content.feedback-modal-content--top-left{transform:initial;left:var(--feedback-modal-content-position-left);top:var(--fedback-modal-content-position-top)}}.feedback-modal-header{align-items:center;color:var(--feedback-modal-header-text-color);font-family:var(--feedback-modal-header-font-family);display:flex;font-size:var(--feedback-header-font-size);justify-content:space-between;margin-bottom:20px}.feedback-modal-text{margin-bottom:20px}.feedback-modal-text textarea{border:1px solid var(--feedback-modal-input-border-color);border-radius:4px;box-sizing:border-box;font-family:var(--feedback-modal-content-font-family);font-size:var(--feedback-modal-input-font-size);height:100px;padding:10px;resize:none;width:100%}.feedback-modal-email{margin-bottom:20px}.feedback-modal-email input{border:1px solid var(--feedback-modal-input-border-color);border-radius:4px;box-sizing:border-box;font-family:var(--feedback-modal-content-font-family);font-size:var(--feedback-modal-input-font-size);height:40px;padding:10px;width:100%}.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;justify-content:space-between}.feedback-modal-buttons.single{justify-content:flex-end}.button{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;font-size:var(--feedback-modal-button-font-size);padding:5px 10px;min-height:20px}.button:hover,.button.active{color:var(--feedback-modal-button-text-color-active);background-color:var(--feedback-modal-button-bg-color-active);border:1px solid var(--feedback-modal-button-border-color-active)}.feedback-modal-footer{font-size:12px;margin-top:5px 0;text-align:center}.feedback-modal-footer a{color:#191919;text-decoration:none}.feedback-logo{display:flex;align-items:center;justify-content:center;margin-top:5px}.feedback-logo svg{max-width:12px;margin-right:5px}.feedback-modal-close{background-color:var(--feedback-modal-close-bg-color);border:0;border-radius:50%;cursor:pointer;margin-left:auto;padding:0;width:24px;height:24px}.feedback-modal-screenshot{background-color:var(--feedback-modal-screenshot-bg-color);box-shadow:0px 0px 0px 5px var(--feedback-modal-screenshot-element-selected-bg-color) inset;height:100vh;left:0;position:fixed;top:0;width:100%;z-index:100}.feedback-modal-screenshot-header{align-items:center;background-color:var(--feedback-modal-screenshot-header-bg-color);color:var(--feedback-modal-screenshot-element-selected-text-color);cursor:pointer;display:flex;padding:5px;position:fixed;justify-content:center;width:100%;z-index:200}.feedback-modal-screenshot-header span{padding-left:10px;padding-right:10px}.feedback-modal-screenshot-overlay{background-color:transparent;cursor:unset;height:100vh;left:0;position:fixed;top:0;width:100%;z-index:100}.feedback-modal-message{font-size:var(--fedback-modal-message-font-size)}.feedback-modal-element-hover{cursor:pointer;background-color:transparent;border:4px dashed var(--feedback-modal-screenshot-element-hover-border-color)}.feedback-modal-element-selected{border:4px solid var(--feedback-modal-screenshot-element-selected-border-color)}";export{i as feedback_button,c as feedback_modal}
1
+ import{r as t,h as e,H as o,g as n}from"./p-38d135e1.js";const i=class{constructor(e){t(this,e),this.modalTitle="Share your feedback",this.successModalTitle="Thanks for your feedback!",this.errorModalTitle="Oops! We didn't receive your feedback. Please try again later.",this.modalPosition="center",this.sendButtonText="Send",this.project="",this.screenshotButtonTooltipText="Take a Screenshot",this.screenshotTopbarText="SELECT AN ELEMENT ON THE PAGE",this.email="",this.emailPlaceholder="Email address (optional)",this.messagePlaceholder="How could this page be more helpful?",this.buttonStyle="default",this.buttonPosition="default",this.hideIcon=!1,this.hideScreenshotButton=!1}connectedCallback(){this.feedbackModal=document.createElement("feedback-modal"),["modalTitle","successModalTitle","errorModalTitle","modalPosition","sendButtonText","project","screenshotButtonTooltipText","screenshotTopbarText","email","emailPlaceholder","messagePlaceholder","hideScreenshotButton"].forEach((t=>{this.feedbackModal[t]=this[t]})),document.body.appendChild(this.feedbackModal)}disconnectedCallback(){document.body.removeChild(this.feedbackModal)}componentDidLoad(){if("center-right"===this.buttonPosition){const t=this.el.shadowRoot.querySelector(".feedback-button-content");t.style.right=t.offsetWidth/2*-1+"px"}}showModal(){this.feedbackModal.showModal=!0}render(){return e(o,null,e("a",{class:`feedback-button-content feedback-button-content--${this.buttonStyle} feedback-button-content--${this.buttonPosition}`,onClick:()=>this.showModal()},!this.hideIcon&&"dark"===this.buttonStyle&&e("span",{class:"feedback-button-content-icon"},e("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:"feather feather-repeat"},e("polyline",{points:"17 1 21 5 17 9"}),e("path",{d:"M3 11V9a4 4 0 0 1 4-4h14"}),e("polyline",{points:"7 23 3 19 7 15"}),e("path",{d:"M21 13v2a4 4 0 0 1-4 4H3"}))),!this.hideIcon&&"light"===this.buttonStyle&&e("span",{class:"feedback-button-content-icon"},e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#0070F4","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-repeat"},e("polyline",{points:"17 1 21 5 17 9"}),e("path",{d:"M3 11V9a4 4 0 0 1 4-4h14"}),e("polyline",{points:"7 23 3 19 7 15"}),e("path",{d:"M21 13v2a4 4 0 0 1-4 4H3"}))),e("slot",null)))}get el(){return n(this)}};i.style=".feedback-button-content{cursor:pointer;z-index:300}.feedback-button-content--light{align-items:center;background-color:var(--feedback-white-color);border-radius:20px;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;display:flex;font-family:var(--feedback-font-family);color:var(--feedback-primary-color);font-weight:bold;padding:8px 15px;font-size:var(--feedback-text-font-size)}.feedback-button-content--dark{align-items:center;background-color:var(--feedback-primary-color);border-radius:20px;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;display:flex;font-family:var(--feedback-font-family);color:var(--feedback-white-color);font-weight:bold;padding:8px 15px;font-size:16px}.feedback-button-content--bottom-right{position:fixed;bottom:10px;right:10px}.feedback-button-content--center-right{position:fixed;top:50%;transform:rotate(-90deg) translateY(-50%)}.feedback-button-content--center-right.feedback-button-content--dark,.feedback-button-content--center-right.feedback-button-content--light{border-radius:4px;border-bottom-right-radius:0px;border-bottom-left-radius:0px}.feedback-button-content-icon{margin-right:5px;height:16px;width:16px}";var r,a,s=(r=function(t){!function(){var e=function(){return{escape:function(t){return t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")},parseExtension:e,mimeType:function(t){var o,n;return(o="application/font-woff",n="image/jpeg",{woff:o,woff2:o,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:n,jpeg:n,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"})[e(t).toLowerCase()]||""},dataAsUrl:function(t,e){return"data:"+e+";base64,"+t},isDataUrl:function(t){return-1!==t.search(/^(data:)/)},canvasToBlob:function(t){return t.toBlob?new Promise((function(e){t.toBlob(e)})):function(t){return new Promise((function(e){for(var o=window.atob(t.toDataURL().split(",")[1]),n=o.length,i=new Uint8Array(n),r=0;r<n;r++)i[r]=o.charCodeAt(r);e(new Blob([i],{type:"image/png"}))}))}(t)},resolveUrl:function(t,e){var o=document.implementation.createHTMLDocument(),n=o.createElement("base");o.head.appendChild(n);var i=o.createElement("a");return o.body.appendChild(i),n.href=e,i.href=t,i.href},getAndEncode:function(t){return s.impl.options.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime()),new Promise((function(e){var o,n=new XMLHttpRequest;if(n.onreadystatechange=function(){if(4===n.readyState)if(200===n.status){var i=new FileReader;i.onloadend=function(){var t=i.result.split(/,/)[1];e(t)},i.readAsDataURL(n.response)}else o?e(o):r("cannot fetch resource: "+t+", status: "+n.status)},n.ontimeout=function(){o?e(o):r("timeout of 30000ms occured while fetching resource: "+t)},n.responseType="blob",n.timeout=3e4,n.open("GET",t,!0),n.send(),s.impl.options.imagePlaceholder){var i=s.impl.options.imagePlaceholder.split(/,/);i&&i[1]&&(o=i[1])}function r(t){console.error(t),e("")}}))},uid:(t=0,function(){return"u"+("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)+t++}),delay:function(t){return function(e){return new Promise((function(o){setTimeout((function(){o(e)}),t)}))}},asArray:function(t){for(var e=[],o=t.length,n=0;n<o;n++)e.push(t[n]);return e},escapeXhtml:function(t){return t.replace(/#/g,"%23").replace(/\n/g,"%0A")},makeImage:function(t){return new Promise((function(e,o){var n=new Image;n.onload=function(){e(n)},n.onerror=o,n.src=t}))},width:function(t){var e=o(t,"border-left-width"),n=o(t,"border-right-width");return t.scrollWidth+e+n},height:function(t){var e=o(t,"border-top-width"),n=o(t,"border-bottom-width");return t.scrollHeight+e+n}};var t;function e(t){var e=/\.([^\.\/]*?)$/g.exec(t);return e?e[1]:""}function o(t,e){var o=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(o.replace("px",""))}}(),o=function(){var t=/url\(['"]?([^'"]+?)['"]?\)/g;return{inlineAll:function(t,e,r){return o(t)?Promise.resolve(t).then(n).then((function(o){var n=Promise.resolve(t);return o.forEach((function(t){n=n.then((function(o){return i(o,t,e,r)}))})),n})):Promise.resolve(t)},shouldProcess:o,impl:{readUrls:n,inline:i}};function o(e){return-1!==e.search(t)}function n(o){for(var n,i=[];null!==(n=t.exec(o));)i.push(n[1]);return i.filter((function(t){return!e.isDataUrl(t)}))}function i(t,o,n,i){return Promise.resolve(o).then((function(t){return n?e.resolveUrl(t,n):t})).then(i||e.getAndEncode).then((function(t){return e.dataAsUrl(t,e.mimeType(o))})).then((function(n){return t.replace(function(t){return new RegExp("(url\\(['\"]?)("+e.escape(t)+")(['\"]?\\))","g")}(o),"$1"+n+"$3")}))}}(),n=function(){return{resolveAll:function(){return t().then((function(t){return Promise.all(t.map((function(t){return t.resolve()})))})).then((function(t){return t.join("\n")}))},impl:{readAll:t}};function t(){return Promise.resolve(e.asArray(document.styleSheets)).then((function(t){var o=[];return t.forEach((function(t){try{e.asArray(t.cssRules||[]).forEach(o.push.bind(o))}catch(e){console.log("Error while reading CSS rules from "+t.href,e.toString())}})),o})).then((function(t){return t.filter((function(t){return t.type===CSSRule.FONT_FACE_RULE})).filter((function(t){return o.shouldProcess(t.style.getPropertyValue("src"))}))})).then((function(e){return e.map(t)}));function t(t){return{resolve:function(){return o.inlineAll(t.cssText,(t.parentStyleSheet||{}).href)},src:function(){return t.style.getPropertyValue("src")}}}}}(),i=function(){return{inlineAll:function n(i){return i instanceof Element?function(t){var e=t.style.getPropertyValue("background");return e?o.inlineAll(e).then((function(e){t.style.setProperty("background",e,t.style.getPropertyPriority("background"))})).then((function(){return t})):Promise.resolve(t)}(i).then((function(){return i instanceof HTMLImageElement?t(i).inline():Promise.all(e.asArray(i.childNodes).map((function(t){return n(t)})))})):Promise.resolve(i)},impl:{newImage:t}};function t(t){return{inline:function(o){return e.isDataUrl(t.src)?Promise.resolve():Promise.resolve(t.src).then(o||e.getAndEncode).then((function(o){return e.dataAsUrl(o,e.mimeType(t.src))})).then((function(e){return new Promise((function(o,n){t.onload=o,t.onerror=n,t.src=e}))}))}}}}(),r=void 0,a=!1,s={toSvg:c,toPng:function(t,e){return d(t,e||{}).then((function(t){return t.toDataURL()}))},toJpeg:function(t,e){return d(t,e=e||{}).then((function(t){return t.toDataURL("image/jpeg",e.quality||1)}))},toBlob:function(t,o){return d(t,o||{}).then(e.canvasToBlob)},toPixelData:function(t,o){return d(t,o||{}).then((function(o){return o.getContext("2d").getImageData(0,0,e.width(t),e.height(t)).data}))},impl:{fontFaces:n,images:i,util:e,inliner:o,options:{}}};function c(t,o){return function(t){s.impl.options.imagePlaceholder=void 0===t.imagePlaceholder?r:t.imagePlaceholder,s.impl.options.cacheBust=void 0===t.cacheBust?a:t.cacheBust}(o=o||{}),Promise.resolve(t).then((function(t){return l(t,o.filter,!0)})).then(f).then(u).then((function(t){return o.bgcolor&&(t.style.backgroundColor=o.bgcolor),o.width&&(t.style.width=o.width+"px"),o.height&&(t.style.height=o.height+"px"),o.style&&Object.keys(o.style).forEach((function(e){t.style[e]=o.style[e]})),t})).then((function(n){return function(t,o,n){return Promise.resolve(t).then((function(t){return t.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),(new XMLSerializer).serializeToString(t)})).then(e.escapeXhtml).then((function(t){return'<foreignObject x="0" y="0" width="100%" height="100%">'+t+"</foreignObject>"})).then((function(t){return'<svg xmlns="http://www.w3.org/2000/svg" width="'+o+'" height="'+n+'">'+t+"</svg>"})).then((function(t){return"data:image/svg+xml;charset=utf-8,"+t}))}(n,o.width||e.width(t),o.height||e.height(t))}))}function d(t,o){return c(t,o).then(e.makeImage).then(e.delay(100)).then((function(n){var i=function(t){var n=document.createElement("canvas");if(n.width=o.width||e.width(t),n.height=o.height||e.height(t),o.bgcolor){var i=n.getContext("2d");i.fillStyle=o.bgcolor,i.fillRect(0,0,n.width,n.height)}return n}(t);return i.getContext("2d").drawImage(n,0,0),i}))}function l(t,o,n){return n||!o||o(t)?Promise.resolve(t).then((function(t){return t instanceof HTMLCanvasElement?e.makeImage(t.toDataURL()):t.cloneNode(!1)})).then((function(n){return function(t,o,n){var i=t.childNodes;return 0===i.length?Promise.resolve(o):function(t,e,o){var n=Promise.resolve();return e.forEach((function(e){n=n.then((function(){return l(e,o)})).then((function(e){e&&t.appendChild(e)}))})),n}(o,e.asArray(i),n).then((function(){return o}))}(t,n,o)})).then((function(o){return function(t,o){return o instanceof Element?Promise.resolve().then((function(){n=window.getComputedStyle(t),i=o.style,n.cssText?i.cssText=n.cssText:function(t,o){e.asArray(t).forEach((function(e){o.setProperty(e,t.getPropertyValue(e),t.getPropertyPriority(e))}))}(n,i);var n,i})).then((function(){[":before",":after"].forEach((function(n){!function(n){var i=window.getComputedStyle(t,n),r=i.getPropertyValue("content");if(""!==r&&"none"!==r){var a=e.uid();o.className=o.className+" "+a;var s=document.createElement("style");s.appendChild(function(t,o,n){var i="."+t+":"+o,r=n.cssText?a(n):s(n);return document.createTextNode(i+"{"+r+"}");function a(t){var e=t.getPropertyValue("content");return t.cssText+" content: "+e+";"}function s(t){return e.asArray(t).map(o).join("; ")+";";function o(e){return e+": "+t.getPropertyValue(e)+(t.getPropertyPriority(e)?" !important":"")}}}(a,n,i)),o.appendChild(s)}}(n)}))})).then((function(){t instanceof HTMLTextAreaElement&&(o.innerHTML=t.value),t instanceof HTMLInputElement&&o.setAttribute("value",t.value)})).then((function(){o instanceof SVGElement&&(o.setAttribute("xmlns","http://www.w3.org/2000/svg"),o instanceof SVGRectElement&&["width","height"].forEach((function(t){var e=o.getAttribute(t);e&&o.style.setProperty(t,e)})))})).then((function(){return o})):o}(t,o)})):Promise.resolve()}function f(t){return n.resolveAll().then((function(e){var o=document.createElement("style");return t.appendChild(o),o.appendChild(document.createTextNode(e)),t}))}function u(t){return i.inlineAll(t).then((function(){return t}))}t.exports=s}()},r(a={path:undefined,exports:{},require:function(){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}}),a.exports);const c=class{constructor(e){t(this,e),this.handleSubmit=async t=>{t.preventDefault(),this.resetOverflow(),this.showScreenshotMode=!1,this.showModal=!1,this.sending=!0;let e="";this.encodedScreenshot&&await this.encodedScreenshot.then((t=>{e=t})).catch((t=>{console.log(t)}));try{const t=await fetch("https://app.pushfeedback.com/api/feedback/",{method:"POST",body:JSON.stringify({url:window.location.href,message:this.formMessage,email:this.formEmail,project:this.project,screenshot:e}),headers:{"Content-Type":"application/json"}});201===t.status?(this.formSuccess=!0,this.formError=!1):(this.formSuccess=!1,this.formError=!0,this.formErrorStatus=t.status)}catch(t){console.log(t),this.formSuccess=!1,this.formError=!0,this.formErrorStatus=500}finally{this.sending=!1,this.showModal=!0}},this.close=()=>{this.sending=!1,this.showModal=!1,this.showScreenshotMode=!1,this.hasSelectedElement=!1,this.encodedScreenshot=null,this.formSuccess=!1,this.formError=!1,this.formErrorStatus=500,this.formMessage="",this.formEmail="",this.resetOverflow()},this.openScreenShot=()=>{this.hasSelectedElement=!1,this.showModal=!1,this.showScreenshotMode=!0,this.encodedScreenshot=null,this.resetOverflow()},this.closeScreenShot=()=>{this.showModal=!1,this.showScreenshotMode=!1,this.hasSelectedElement=!1,this.encodedScreenshot=null,this.overlay.style.display="none",this.resetOverflow()},this.handleMouseOverScreenShot=t=>{if(t.preventDefault(),this.hasSelectedElement)return;this.overlay.style.display="none",this.screenshotModal.style.display="none";const e=document.elementFromPoint(t.clientX,t.clientY).getBoundingClientRect();this.screenshotModal.style.display="",this.elementSelected.style.position="absolute",this.elementSelected.style.left=`${e.left}px`,this.elementSelected.style.top=`${e.top}px`,this.elementSelected.style.width=`${e.width}px`,this.elementSelected.style.height=`${e.height}px`,this.elementSelected.classList.add("feedback-modal-element-hover"),this.topSide.style.position="absolute",this.topSide.style.left=`${e.left}px`,this.topSide.style.top="0px",this.topSide.style.width=`${e.width+8}px`,this.topSide.style.height=`${e.top}px`,this.topSide.style.backgroundColor="rgba(0, 0, 0, 0.3)",this.leftSide.style.position="absolute",this.leftSide.style.left="0px",this.leftSide.style.top="0px",this.leftSide.style.width=`${e.left}px`,this.leftSide.style.height="100vh",this.leftSide.style.backgroundColor="rgba(0, 0, 0, 0.3)",this.bottomSide.style.position="absolute",this.bottomSide.style.left=`${e.left}px`,this.bottomSide.style.top=`${e.bottom+8}px`,this.bottomSide.style.width=`${e.width+8}px`,this.bottomSide.style.height="100vh",this.bottomSide.style.backgroundColor="rgba(0, 0, 0, 0.3)",this.rightSide.style.position="absolute",this.rightSide.style.left=`${e.right+8}px`,this.rightSide.style.top="0px",this.rightSide.style.width="100%",this.rightSide.style.height="100vh",this.rightSide.style.backgroundColor="rgba(0, 0, 0, 0.3)",this.screenshotModal.style.backgroundColor="transparent"},this.handleMouseClickedSelectedElement=t=>{t.preventDefault(),this.elementSelected&&this.elementSelected.classList.add("feedback-modal-element-selected");let e=this.elementSelected.getBoundingClientRect().top;this.elementSelected.style.top=`${e+window.pageYOffset}px`;const o=this.elementSelected.cloneNode(!0);document.body.appendChild(o),this.elementSelected.style.top=`${e}px`,this.encodedScreenshot=s.toPng(document.body,{cacheBust:!0}).then((function(t){return document.body.removeChild(o),t})).catch((function(t){return console.error("Oops, something went wrong!",t),""})),document.getElementsByTagName("html")[0].style.overflow="hidden",this.hasSelectedElement=!0,this.overlay.style.display="block",this.showModal=!0},this.sending=!1,this.formMessage="",this.formEmail="",this.formSuccess=!1,this.formError=!1,this.formErrorStatus=500,this.encodedScreenshot=void 0,this.modalTitle="Share your feedback",this.modalTitleSuccess="Thanks for your feedback!",this.modalTitleError="Oops! We didn't receive your feedback. Please try again later.",this.modalTitleError403="Oops! The request URL does not match the one defined in PushFeedback for this project.",this.modalTitleError404="Oops! We could not find the provided project id in PushFeedback.",this.modalPosition="center",this.sendButtonText="Send",this.project="",this.screenshotButtonTooltipText="Take a Screenshot",this.screenshotTopbarText="SELECT AN ELEMENT ON THE PAGE",this.email="",this.emailPlaceholder="Email address (optional)",this.messagePlaceholder="How could this page be more helpful?",this.showModal=!1,this.showScreenshotMode=!1,this.hasSelectedElement=!1,this.hideScreenshotButton=!1}componentWillLoad(){this.formEmail=this.email}resetOverflow(){document.getElementsByTagName("html")[0].style.overflow="inherit"}handleMessageInput(t){this.formMessage=t.target.value}handleEmailInput(t){this.formEmail=t.target.value}render(){return e("div",{class:"feedback-modal-wrapper"},this.showScreenshotMode&&e("div",{class:"feedback-modal-screenshot",ref:t=>this.screenshotModal=t,onMouseMove:this.handleMouseOverScreenShot},e("div",{class:"feedback-modal-screenshot-element-selected",ref:t=>this.elementSelected=t,onClick:this.handleMouseClickedSelectedElement}),e("div",{class:"top-side",ref:t=>this.topSide=t}),e("div",{class:"left-side",ref:t=>this.leftSide=t}),e("div",{class:"bottom-side",ref:t=>this.bottomSide=t}),e("div",{class:"right-side",ref:t=>this.rightSide=t}),e("div",{class:"feedback-modal-screenshot-header",onClick:this.closeScreenShot},e("span",null,this.screenshotTopbarText),e("span",{class:"feedback-modal-screenshot-close"},e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-x"},e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})))),e("div",{class:"feedback-modal-screenshot-overlay",ref:t=>this.overlay=t})),this.showModal&&e("div",{class:`feedback-modal-content feedback-modal-content--${this.modalPosition}`,ref:t=>this.modalContent=t},e("div",{class:"feedback-modal-header"},this.formSuccess||this.formError?this.formSuccess?e("span",{class:"text-center"},this.modalTitleSuccess):this.formError&&500==this.formErrorStatus?e("span",{class:"text-center"},this.modalTitleError):this.formError&&403==this.formErrorStatus?e("span",{class:"text-center"},this.modalTitleError403):this.formError&&404==this.formErrorStatus?e("span",{class:"text-center"},this.modalTitleError404):e("span",null):e("span",null,this.modalTitle),e("button",{class:"feedback-modal-close",onClick:this.close},e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#ccc","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-x"},e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})))),e("div",{class:"feedback-modal-body"},this.formSuccess||this.formError?e("span",null):e("form",{onSubmit:this.handleSubmit},e("div",{class:"feedback-modal-text"},e("textarea",{placeholder:this.messagePlaceholder,value:this.formMessage,onInput:t=>this.handleMessageInput(t),required:!0})),!this.email&&e("div",{class:"feedback-modal-email"},e("input",{type:"email",placeholder:this.emailPlaceholder,onInput:t=>this.handleEmailInput(t),value:this.formEmail})),e("div",{class:"feedback-modal-buttons "+(this.hideScreenshotButton?"single":"")},!this.hideScreenshotButton&&e("button",{type:"button",class:"button"+(this.encodedScreenshot?" active":""),title:this.screenshotButtonTooltipText,onClick:this.openScreenShot,disabled:this.sending},e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-camera"},e("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),e("circle",{cx:"12",cy:"13",r:"4"}))),e("button",{class:"button",type:"submit",disabled:this.sending},this.sendButtonText)))),e("div",{class:"feedback-modal-footer"},e("div",{class:"feedback-logo"},e("svg",{class:"w-8 h-8",viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg"},e("defs",null,e("radialGradient",{cx:"21.152%",cy:"86.063%",fx:"21.152%",fy:"86.063%",r:"79.941%",id:"footer-logo"},e("stop",{"stop-color":"#4FD1C5",offset:"0%"}),e("stop",{"stop-color":"#81E6D9",offset:"25.871%"}),e("stop",{"stop-color":"#338CF5",offset:"100%"}))),e("rect",{width:"32",height:"32",rx:"16",fill:"url(#footer-logo)","fill-rule":"nonzero"}))," ",e("a",{href:"https://pushfeedback.com"},"PushFeedback")))))}};c.style=".text-center{text-align:center;flex-grow: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;font-family:var(--feedback-modal-content-font-family);max-width:300px;padding:20px;position:fixed;width:100%;z-index:300;left:50%;top:50%;transform:translate(-50%, -50%)}@media screen and (min-width: 768px){.feedback-modal-content.feedback-modal-content--bottom-right{top:initial;left:initial;transform:initial;bottom:var(--feedback-modal-content-position-bottom);right:var(--feedback-modal-content-position-right)}.feedback-modal-content.feedback-modal-content--bottom-left{top:initial;transform:initial;bottom:var(--feedback-modal-content-position-bottom);left:var(--feedback-modal-content-position-left)}.feedback-modal-content.feedback-modal-content--top-right{top:initial;transform:initial;right:var(--feedback-modal-content-position-right);top:var(--fedback-modal-content-position-top)}.feedback-modal-content.feedback-modal-content--top-left{transform:initial;left:var(--feedback-modal-content-position-left);top:var(--fedback-modal-content-position-top)}}.feedback-modal-header{align-items:center;color:var(--feedback-modal-header-text-color);font-family:var(--feedback-modal-header-font-family);display:flex;font-size:var(--feedback-header-font-size);justify-content:space-between;margin-bottom:20px}.feedback-modal-text{margin-bottom:20px}.feedback-modal-text textarea{border:1px solid var(--feedback-modal-input-border-color);border-radius:4px;box-sizing:border-box;font-family:var(--feedback-modal-content-font-family);font-size:var(--feedback-modal-input-font-size);height:100px;padding:10px;resize:none;width:100%}.feedback-modal-email{margin-bottom:20px}.feedback-modal-email input{border:1px solid var(--feedback-modal-input-border-color);border-radius:4px;box-sizing:border-box;font-family:var(--feedback-modal-content-font-family);font-size:var(--feedback-modal-input-font-size);height:40px;padding:10px;width:100%}.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;justify-content:space-between}.feedback-modal-buttons.single{justify-content:flex-end}.button{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;font-size:var(--feedback-modal-button-font-size);padding:5px 10px;min-height:20px}.button:hover,.button.active{color:var(--feedback-modal-button-text-color-active);background-color:var(--feedback-modal-button-bg-color-active);border:1px solid var(--feedback-modal-button-border-color-active)}.feedback-modal-footer{font-size:12px;margin-top:5px 0;text-align:center}.feedback-modal-footer a{color:#191919;text-decoration:none}.feedback-logo{display:flex;align-items:center;justify-content:center;margin-top:5px}.feedback-logo svg{max-width:12px;margin-right:5px}.feedback-modal-close{background-color:var(--feedback-modal-close-bg-color);border:0;border-radius:50%;cursor:pointer;margin-left:auto;padding:0;width:24px;height:24px}.feedback-modal-screenshot{background-color:var(--feedback-modal-screenshot-bg-color);box-shadow:0px 0px 0px 5px var(--feedback-modal-screenshot-element-selected-bg-color) inset;height:100vh;left:0;position:fixed;top:0;width:100%;z-index:100}.feedback-modal-screenshot-header{align-items:center;background-color:var(--feedback-modal-screenshot-header-bg-color);color:var(--feedback-modal-screenshot-element-selected-text-color);cursor:pointer;display:flex;padding:5px;position:fixed;justify-content:center;width:100%;z-index:200}.feedback-modal-screenshot-header span{padding-left:10px;padding-right:10px}.feedback-modal-screenshot-overlay{background-color:transparent;cursor:unset;height:100vh;left:0;position:fixed;top:0;width:100%;z-index:100}.feedback-modal-message{font-size:var(--fedback-modal-message-font-size)}.feedback-modal-element-hover{cursor:pointer;background-color:transparent;border:4px dashed var(--feedback-modal-screenshot-element-hover-border-color)}.feedback-modal-element-selected{border:4px solid var(--feedback-modal-screenshot-element-selected-border-color)}";export{i as feedback_button,c as feedback_modal}
@@ -1 +1 @@
1
- import{p as e,b as t}from"./p-38d135e1.js";export{s as setNonce}from"./p-38d135e1.js";(()=>{const t=import.meta.url,o={};return""!==t&&(o.resourcesUrl=new URL(".",t).href),e(o)})().then((e=>t([["p-09647793",[[1,"feedback-button",{modalTitle:[1,"modal-title"],successModalTitle:[1,"success-modal-title"],errorModalTitle:[1,"error-modal-title"],modalPosition:[1,"modal-position"],sendButtonText:[1,"send-button-text"],project:[1],screenshotButtonTooltipText:[1,"screenshot-button-tooltip-text"],screenshotTopbarText:[1,"screenshot-topbar-text"],email:[1],emailPlaceholder:[1,"email-placeholder"],messagePlaceholder:[1,"message-placeholder"],buttonStyle:[1,"button-style"],buttonPosition:[1,"button-position"],hideIcon:[4,"hide-icon"],hideScreenshotButton:[4,"hide-screenshot-button"]}],[1,"feedback-modal",{modalTitle:[1,"modal-title"],modalTitleSuccess:[1,"modal-title-success"],modalTitleError:[1,"modal-title-error"],modalTitleError403:[1,"modal-title-error-4-0-3"],modalTitleError404:[1,"modal-title-error-4-0-4"],modalPosition:[1,"modal-position"],sendButtonText:[1,"send-button-text"],project:[1],screenshotButtonTooltipText:[1,"screenshot-button-tooltip-text"],screenshotTopbarText:[1,"screenshot-topbar-text"],email:[1],emailPlaceholder:[1,"email-placeholder"],messagePlaceholder:[1,"message-placeholder"],showModal:[1540,"show-modal"],showScreenshotMode:[1540,"show-screenshot-mode"],hasSelectedElement:[1540,"has-selected-element"],hideScreenshotButton:[4,"hide-screenshot-button"],sending:[32],formMessage:[32],formEmail:[32],formSuccess:[32],formError:[32],formErrorStatus:[32],encodedScreenshot:[32]}]]]],e)));
1
+ import{p as e,b as t}from"./p-38d135e1.js";export{s as setNonce}from"./p-38d135e1.js";(()=>{const t=import.meta.url,o={};return""!==t&&(o.resourcesUrl=new URL(".",t).href),e(o)})().then((e=>t([["p-9ac3c49b",[[1,"feedback-button",{modalTitle:[1,"modal-title"],successModalTitle:[1,"success-modal-title"],errorModalTitle:[1,"error-modal-title"],modalPosition:[1,"modal-position"],sendButtonText:[1,"send-button-text"],project:[1],screenshotButtonTooltipText:[1,"screenshot-button-tooltip-text"],screenshotTopbarText:[1,"screenshot-topbar-text"],email:[1],emailPlaceholder:[1,"email-placeholder"],messagePlaceholder:[1,"message-placeholder"],buttonStyle:[1,"button-style"],buttonPosition:[1,"button-position"],hideIcon:[4,"hide-icon"],hideScreenshotButton:[4,"hide-screenshot-button"]}],[1,"feedback-modal",{modalTitle:[1,"modal-title"],modalTitleSuccess:[1,"modal-title-success"],modalTitleError:[1,"modal-title-error"],modalTitleError403:[1,"modal-title-error-4-0-3"],modalTitleError404:[1,"modal-title-error-4-0-4"],modalPosition:[1,"modal-position"],sendButtonText:[1,"send-button-text"],project:[1],screenshotButtonTooltipText:[1,"screenshot-button-tooltip-text"],screenshotTopbarText:[1,"screenshot-topbar-text"],email:[1],emailPlaceholder:[1,"email-placeholder"],messagePlaceholder:[1,"message-placeholder"],showModal:[1540,"show-modal"],showScreenshotMode:[1540,"show-screenshot-mode"],hasSelectedElement:[1540,"has-selected-element"],hideScreenshotButton:[4,"hide-screenshot-button"],sending:[32],formMessage:[32],formEmail:[32],formSuccess:[32],formError:[32],formErrorStatus:[32],encodedScreenshot:[32]}]]]],e)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pushfeedback",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Feedback widget for websites.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",