@inputbuffer/feedback 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +192 -56
- package/dist/api.d.ts +3 -2
- package/dist/attrs.d.ts +13 -0
- package/dist/bar-entry.d.ts +2 -0
- package/dist/bar.css +1 -1
- package/dist/bar.esm.js +5 -12
- package/dist/bar.js +5 -12
- package/dist/errors.d.ts +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/modal-entry.d.ts +2 -0
- package/dist/modal.css +1 -1
- package/dist/modal.esm.js +5 -16
- package/dist/modal.js +5 -16
- package/dist/types.d.ts +71 -22
- package/dist/widget.esm.js +9 -27
- package/dist/widget.js +9 -27
- package/package.json +1 -1
package/dist/widget.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function K(e){let t=document.getElementById("ib-modal");if(!t)return;let{theme:i={}}=e;i.primary&&t.style.setProperty("--ib-primary",i.primary),i.background&&t.style.setProperty("--ib-background",i.background),i.surface&&t.style.setProperty("--ib-surface",i.surface),i.text&&t.style.setProperty("--ib-text",i.text),i.selected&&t.style.setProperty("--ib-selected",i.selected),i.selectedColor&&t.style.setProperty("--ib-selected-color",i.selectedColor)}var D="0.1.1",Q="https://inputbuffer.io/api/v0/inputs";async function W(e,t,i,d,o,m){var y;let l={description:t};if(d&&(l.title=d),i&&(l.contactEmail=i),o!=null&&o.sentiment&&(l.sentiment=o.sentiment),o!=null&&o.source&&(l.source=o.source),o!=null&&o.target){let n=o.target;l.targets=[{target_type:n.type,...n.targetId&&{target_id:n.targetId},...n.displayName&&{display_name:n.displayName},...n.dedupKey&&{dedup_key:n.dedupKey},metadata:n.metadata}]}let c=new AbortController,h=setTimeout(()=>c.abort(),1e4),u;try{u=await fetch(m!=null?m:Q,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-IB-Client":`inputbuffer-widget/${D} (javascript)`},body:JSON.stringify(l),credentials:"omit",signal:c.signal})}finally{clearTimeout(h)}if(!u.ok){let n=await u.json().catch(()=>({}));throw new Error(((y=n==null?void 0:n.error)==null?void 0:y.message)||"Submission failed. Please try again.")}return u.json()}function U(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("fill","currentColor"),t.setAttribute("aria-hidden","true"),t.style.display="block";let i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d",e),t.appendChild(i),t}var Z="M9 21h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2zM9 9l4.34-4.34L12 10h9v2l-3 7H9V9zM1 9h2v12H1z",ee="M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L10.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm0 12l-4.34 4.34L12 14H3v-2l3-7h9v10zm4-12h2v12h-2z";function _(e){let t=null,i,d,o=null,m=null,l=null,c=null,h=null,u=null,y=null,n=null,x=null,f=[],S=[],C=[];function A(r){if(r.key==="Escape"){L();return}if(r.key==="Tab"&&t){let s=Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(s.length===0)return;let v=s[0],p=s[s.length-1];r.shiftKey?document.activeElement===v&&(r.preventDefault(),p.focus()):document.activeElement===p&&(r.preventDefault(),v.focus())}}async function H(){var s,v;if(!m||!h)return;let r=m.value.trim();if(r.length<10){u&&(u.textContent="Please enter at least 10 characters.",u.style.display="block");return}u&&(u.style.display="none"),h.disabled=!0,h.textContent="Sending\u2026";try{let p=(c==null?void 0:c.value.trim())||((s=i==null?void 0:i.prefill)==null?void 0:s.email)||null,g=(l==null?void 0:l.value.trim())||null,B=d!=null?d:i==null?void 0:i.sentiment,N=await W(e.apiKey,r,p||null,g,{...i,sentiment:B,source:(v=i==null?void 0:i.source)!=null?v:e.source},e.apiUrl);y&&(y.textContent="Thanks for your feedback!",y.style.display="block"),f.forEach(T=>T(N)),o=setTimeout(()=>L(),2e3)}catch(p){let g=p instanceof Error?p:new Error("Unknown error");u&&(u.textContent="Something went wrong. Please try again.",u.style.display="block"),C.forEach(B=>B(g)),h.disabled=!1,h.textContent="Send feedback"}}function F(){let r=document.createElement("div");r.id="ib-overlay";let s=document.createElement("div");s.id="ib-modal",e.colorScheme==="dark"?s.classList.add("ib-theme-dark"):e.colorScheme==="light"&&s.classList.add("ib-theme-light"),s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true");let v=document.createElement("div");if(v.id="ib-modal-header",x=v,e.title?(s.setAttribute("aria-labelledby","ib-title"),n=document.createElement("h2"),n.id="ib-title",n.className="ib-modal-title",n.textContent=e.title,v.appendChild(n)):s.setAttribute("aria-label","Feedback"),e.showSentiment){let k,w,a=document.createElement("div");a.className="ib-modal-sentiment",k=document.createElement("button"),k.type="button",k.className="ib-modal-thumb ib-modal-thumb--up",k.setAttribute("aria-label","Helpful"),k.appendChild(U(Z)),w=document.createElement("button"),w.type="button",w.className="ib-modal-thumb ib-modal-thumb--down",w.setAttribute("aria-label","Not helpful"),w.appendChild(U(ee)),k.addEventListener("click",()=>{k.classList.add("ib-modal-thumb--active"),w.classList.remove("ib-modal-thumb--active"),d="positive"}),w.addEventListener("click",()=>{w.classList.add("ib-modal-thumb--active"),k.classList.remove("ib-modal-thumb--active"),d="negative"}),a.appendChild(k),a.appendChild(w),v.appendChild(a)}let p=document.createElement("button");p.id="ib-close",p.className="ib-modal-close",p.textContent="\xD7",p.setAttribute("aria-label","Close feedback form"),p.addEventListener("click",L),v.appendChild(p);let g=document.createElement("div");g.id="ib-modal-body",m=document.createElement("textarea"),m.id="ib-textarea",m.className="ib-modal-textarea",m.placeholder=e.placeholder||"What's on your mind?",m.setAttribute("aria-label","Feedback"),h=document.createElement("button"),h.id="ib-submit",h.className="ib-modal-submit",h.textContent="Send feedback",h.addEventListener("click",H),y=document.createElement("p"),y.id="ib-success",y.className="ib-modal-success",u=document.createElement("p"),u.id="ib-error",u.className="ib-modal-error",e.showTitleField===!0&&(l=document.createElement("input"),l.id="ib-title-input",l.className="ib-modal-title-input",l.type="text",l.placeholder="Title (optional)",l.setAttribute("aria-label","Feedback title"),g.appendChild(l)),g.appendChild(m),e.showEmailField===!0&&(c=document.createElement("input"),c.id="ib-email",c.className="ib-modal-email",c.type="email",c.placeholder="Your email (optional)",c.setAttribute("aria-label","Email address"),g.appendChild(c)),g.appendChild(u),g.appendChild(y);let B=document.createElement("div");B.className="ib-modal-footer",B.appendChild(h);let N=document.createElement("div");N.className="ib-branding";let T=document.createElement("a");return T.href="https://inputbuffer.io",T.target="_blank",T.rel="noopener noreferrer",T.textContent="Powered by inputbuffer.io",N.appendChild(T),B.appendChild(N),g.appendChild(B),s.appendChild(v),s.appendChild(g),r.appendChild(s),r.addEventListener("click",k=>{k.target===r&&L()}),document.addEventListener("keydown",A),r}function E(r){var s,v;if(!t){if(i=r,t=F(),document.body.appendChild(t),K(e),r!=null&&r.title){if(n)n.textContent=r.title;else if(x){let p=t.querySelector("#ib-modal");p.removeAttribute("aria-label"),p.setAttribute("aria-labelledby","ib-title"),n=document.createElement("h2"),n.id="ib-title",n.className="ib-modal-title",n.textContent=r.title,x.prepend(n)}}if(r!=null&&r.sentiment){d=r.sentiment;let p=t.querySelector(".ib-modal-thumb--up"),g=t.querySelector(".ib-modal-thumb--down");r.sentiment==="positive"?p==null||p.classList.add("ib-modal-thumb--active"):r.sentiment==="negative"&&(g==null||g.classList.add("ib-modal-thumb--active"))}m&&((s=r==null?void 0:r.prefill)!=null&&s.description)&&(m.value=r.prefill.description),c&&((v=r==null?void 0:r.prefill)!=null&&v.email)&&(c.value=r.prefill.email),m==null||m.focus()}}function L(){t&&(o!==null&&(clearTimeout(o),o=null),document.removeEventListener("keydown",A),t.remove(),t=null,m=null,l=null,c=null,h=null,u=null,y=null,n=null,x=null,i=void 0,d=void 0,S.forEach(r=>r()))}function O(r,s){r==="submit"?f.push(s):r==="close"?S.push(s):r==="error"&&C.push(s)}function I(){L()}return{open:E,close:L,on:O,destroy:I}}function V(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("fill","currentColor"),t.setAttribute("aria-hidden","true"),t.style.display="block";let i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d",e),t.appendChild(i),t}var te="M9 21h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2zM9 9l4.34-4.34L12 10h9v2l-3 7H9V9zM1 9h2v12H1z",ie="M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L10.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm0 12l-4.34 4.34L12 14H3v-2l3-7h9v10zm4-12h2v12h-2z";function R(e){var k,w;let t,i={vote:[],open:[],submit:[],close:[],error:[]};function d(a,M){var z;(z=i[a])==null||z.forEach(j=>j(M))}let o=document.createElement("div"),m=e.colorScheme==="dark"?" ib-theme-dark":e.colorScheme==="light"?" ib-theme-light":"";o.className="ib-bar-wrapper"+(e.placement==="fixed"?" ib-bar-wrapper--fixed":"")+m;let{theme:l={}}=e;l.primary&&o.style.setProperty("--ib-primary",l.primary),l.background&&o.style.setProperty("--ib-background",l.background),l.surface&&o.style.setProperty("--ib-surface",l.surface),l.text&&o.style.setProperty("--ib-text",l.text),l.selected&&o.style.setProperty("--ib-selected",l.selected),l.selectedColor&&o.style.setProperty("--ib-selected-color",l.selectedColor);let c=document.createElement("div");c.className="ib-bar";let h=document.createElement("div");h.className="ib-bar-label-area";let u=document.createElement("span");u.className="ib-bar-label",u.textContent=(k=e.label)!=null?k:"Was this helpful?",h.appendChild(u);let y=document.createElement("div");y.className="ib-bar-actions"+(e.showLabel===!1?" ib-bar-actions--no-label":"");let n=document.createElement("button");n.type="button",n.className="ib-bar-btn ib-bar-btn--up",n.setAttribute("aria-label","Yes"),n.appendChild(V(te));let x=document.createElement("button");x.type="button",x.className="ib-bar-btn ib-bar-btn--down",x.setAttribute("aria-label","No"),x.appendChild(V(ie)),y.appendChild(n),y.appendChild(x),e.showLabel!==!1&&c.appendChild(h),c.appendChild(y);let f=document.createElement("div");f.className="ib-bar-popover",f.setAttribute("role","dialog"),f.setAttribute("aria-modal","false");let S=document.createElement("div");if(S.className="ib-bar-header",e.modalTitle){f.setAttribute("aria-labelledby","ib-bar-title");let a=document.createElement("p");a.id="ib-bar-title",a.className="ib-bar-title",a.textContent=e.modalTitle,S.appendChild(a)}else f.setAttribute("aria-label","Feedback");let C=document.createElement("div");C.className="ib-bar-body";let A=document.createElement("textarea");A.className="ib-bar-textarea",A.placeholder=(w=e.modalPlaceholder)!=null?w:"What's on your mind?",A.setAttribute("aria-label","Feedback");let H=document.createElement("p");H.className="ib-bar-error";let F=document.createElement("p");F.className="ib-bar-success";let E=document.createElement("button");if(E.type="button",E.className="ib-bar-submit",E.textContent="Send feedback",e.showTitleField===!0){let a=document.createElement("input");a.type="text",a.className="ib-bar-title-input",a.placeholder="Title (optional)",a.setAttribute("aria-label","Feedback title"),C.appendChild(a)}if(C.appendChild(A),e.showEmailField===!0){let a=document.createElement("input");a.type="email",a.className="ib-bar-email",a.placeholder="Your email (optional)",a.setAttribute("aria-label","Email address"),C.appendChild(a)}C.appendChild(H),C.appendChild(F);let L=document.createElement("div");L.className="ib-bar-footer",L.appendChild(E);let O=document.createElement("div");O.className="ib-branding";let I=document.createElement("a");I.href="https://inputbuffer.io",I.target="_blank",I.rel="noopener noreferrer",I.textContent="Powered by inputbuffer.io",O.appendChild(I),L.appendChild(O),C.appendChild(L),f.appendChild(S),f.appendChild(C),o.appendChild(f),o.appendChild(c);function r(){let a=c.getBoundingClientRect();f.style.top=`${a.top-f.offsetHeight-8}px`,f.style.left=`${a.right-320}px`}function s(a){t=a,f.classList.add("ib-bar-popover--visible"),requestAnimationFrame(r),H.textContent="",F.textContent="",A.focus(),setTimeout(()=>document.addEventListener("click",g),0),document.addEventListener("keydown",B),window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r,{passive:!0}),d("open",{sentiment:a})}function v(){f.classList.contains("ib-bar-popover--visible")&&(f.classList.remove("ib-bar-popover--visible"),document.removeEventListener("click",g),document.removeEventListener("keydown",B),window.removeEventListener("scroll",r),window.removeEventListener("resize",r),A.value="",d("close"))}function p(){n.classList.remove("ib-bar-btn--active"),x.classList.remove("ib-bar-btn--active"),t=void 0}function g(a){o.contains(a.target)||v()}function B(a){a.key==="Escape"&&v()}async function N(){let a=A.value.trim();if(a.length<10){H.textContent="Please enter at least 10 characters.";return}H.textContent="",E.disabled=!0,E.textContent="Sending\u2026";let M=f.querySelector(".ib-bar-title-input"),z=(M==null?void 0:M.value.trim())||null,j=f.querySelector(".ib-bar-email"),X=(j==null?void 0:j.value.trim())||null;try{let P=await W(e.apiKey,a,X,z,{sentiment:t,target:e.target,source:e.source},e.apiUrl);d("submit",P),F.textContent="Thanks for your feedback!",E.textContent="Send feedback",setTimeout(()=>{v(),p()},2e3)}catch(P){d("error",P instanceof Error?P:new Error("Something went wrong.")),H.textContent=P instanceof Error?P.message:"Something went wrong.",E.disabled=!1,E.textContent="Send feedback"}}function T(a){n.classList.remove("ib-bar-btn--active"),x.classList.remove("ib-bar-btn--active"),a.classList.add("ib-bar-btn--active")}return n.addEventListener("click",()=>{d("vote",{sentiment:"positive"}),T(n),s("positive")}),x.addEventListener("click",()=>{d("vote",{sentiment:"negative"}),T(x),s("negative")}),E.addEventListener("click",N),{element:o,on(a,M){var z;(z=i[a])==null||z.push(M)},destroy(){v(),o.remove()}}}var q=`/* InputBuffer Modal Styles
|
|
1
|
+
function X(e){let t=document.getElementById("ib-modal");if(!t)return;let{theme:r={}}=e;r.primary&&t.style.setProperty("--ib-primary",r.primary),r.background&&t.style.setProperty("--ib-background",r.background),r.surface&&t.style.setProperty("--ib-surface",r.surface),r.text&&t.style.setProperty("--ib-text",r.text),r.selected&&t.style.setProperty("--ib-selected",r.selected),r.selectedColor&&t.style.setProperty("--ib-selected-color",r.selectedColor)}var _=class extends Error{constructor(t){super(t.detail),this.name="ApiError",this.type=t.type,this.title=t.title,this.status=t.status,this.detail=t.detail,this.category=t.category,this.field=t.field}};var Y="Something went wrong. Please try again.";function j(e){return e instanceof _?e.category==="user"?e.detail:(e.category==="integration"&&M(`${e.title}: ${e.detail}`,e.type),Y):Y}function M(e,t){typeof console!="undefined"&&console.warn(`[inputbuffer] ${e}`,t!=null?t:"")}var U="0.3.0",pe="https://inputbuffer.io",me="/api/v0/feedback",fe="/api/v0/reactions",ge=1e4,he=5e3,ve=500,ye=300;function Q(e,t){return`${(e!=null?e:pe).replace(/\/+$/,"")}${t}`}async function Z(e,t,r){var d,s,c,p;let n=new AbortController,g=setTimeout(()=>n.abort(),ge),a;try{a=await fetch(e,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-IB-Client":`inputbuffer-widget/${U} (javascript)`},body:JSON.stringify(r),credentials:"omit",signal:n.signal})}finally{clearTimeout(g)}if(!a.ok){let b=await a.json().catch(()=>({}));throw new _({type:(d=b.type)!=null?d:"https://inputbuffer.io/docs/api/problems/internal-error",title:(s=b.title)!=null?s:"Error",detail:(c=b.detail)!=null?c:"Submission failed. Please try again.",status:(p=b.status)!=null?p:a.status,category:b.category,field:b.field})}return a}async function D(e,t,r,n,g){let a={description:t.slice(0,he)};if(r&&(a.title=r.slice(0,ve)),n!=null&&n.submittedBy&&(a.submitted_by=n.submittedBy.slice(0,ye)),n!=null&&n.target){let c=n.target;a.targets=[{type:c.type,metadata:c.metadata}]}let d=await Z(Q(g,me),e,a),{data:s}=await d.json();return{id:s.id}}async function ee(e,t,r,n,g){let a={reaction_value:t,target:{type:r.type,metadata:r.metadata}};n&&(a.user_id=n);let d;try{d=await Z(Q(g,fe),e,a)}catch(c){throw c instanceof _&&c.status===422&&c.field==="user_id"&&M("Reaction rejected: no user_id and no client IP. Set the `userId` option (or the `user-id` attribute)."),c}let{data:s}=await d.json();return s}function te(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("fill","currentColor"),t.setAttribute("aria-hidden","true"),t.style.display="block";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d",e),t.appendChild(r),t}var xe="M9 21h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2zM9 9l4.34-4.34L12 10h9v2l-3 7H9V9zM1 9h2v12H1z",Ee="M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L10.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm0 12l-4.34 4.34L12 14H3v-2l3-7h9v10zm4-12h2v12h-2z";function re(e){let t=null,r,n,g=null,a=null,d=null,s=null,c=null,p=null,b=null,B=null,z=[],H=[],E=[];function k(i){if(i.key==="Escape"){y();return}if(i.key==="Tab"&&t){let l=Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(l.length===0)return;let u=l[0],m=l[l.length-1];i.shiftKey?document.activeElement===u&&(i.preventDefault(),m.focus()):document.activeElement===m&&(i.preventDefault(),u.focus())}}async function h(){var l;if(!a||!s)return;let i=a.value.trim();if(i.length<10){c&&(c.textContent="Please enter at least 10 characters.",c.style.display="block");return}c&&(c.style.display="none"),s.disabled=!0,s.textContent="Sending\u2026";try{let u=(d==null?void 0:d.value.trim())||null,m=n!=null?n:r==null?void 0:r.sentiment,v=await D(e.apiKey,i,u,{...r,sentiment:m,submittedBy:(l=r==null?void 0:r.submittedBy)!=null?l:e.submittedBy},e.apiUrl);p&&(p.textContent="Thanks for your feedback!",p.style.display="block"),z.forEach(A=>A(v)),g=setTimeout(()=>y(),2e3)}catch(u){let m=u instanceof Error?u:new Error("Unknown error");c&&(c.textContent=j(u),c.style.display="block"),E.forEach(v=>v(m)),s.disabled=!1,s.textContent="Send feedback"}}function O(){let i=document.createElement("div");i.id="ib-overlay";let l=document.createElement("div");l.id="ib-modal",e.colorScheme==="dark"?l.classList.add("ib-theme-dark"):e.colorScheme==="light"&&l.classList.add("ib-theme-light"),l.setAttribute("role","dialog"),l.setAttribute("aria-modal","true");let u=document.createElement("div");if(u.id="ib-modal-header",B=u,e.title?(l.setAttribute("aria-labelledby","ib-title"),b=document.createElement("h2"),b.id="ib-title",b.className="ib-modal-title",b.textContent=e.title,u.appendChild(b)):l.setAttribute("aria-label","Feedback"),e.showSentiment){let x,w,R=document.createElement("div");R.className="ib-modal-sentiment",x=document.createElement("button"),x.type="button",x.className="ib-modal-thumb ib-modal-thumb--up",x.setAttribute("aria-label","Helpful"),x.appendChild(te(xe)),w=document.createElement("button"),w.type="button",w.className="ib-modal-thumb ib-modal-thumb--down",w.setAttribute("aria-label","Not helpful"),w.appendChild(te(Ee)),x.addEventListener("click",()=>{x.classList.add("ib-modal-thumb--active"),w.classList.remove("ib-modal-thumb--active"),n="positive"}),w.addEventListener("click",()=>{w.classList.add("ib-modal-thumb--active"),x.classList.remove("ib-modal-thumb--active"),n="negative"}),R.appendChild(x),R.appendChild(w),u.appendChild(R)}let m=document.createElement("button");m.id="ib-close",m.className="ib-modal-close",m.textContent="\xD7",m.setAttribute("aria-label","Close feedback form"),m.addEventListener("click",y),u.appendChild(m);let v=document.createElement("div");v.id="ib-modal-body",a=document.createElement("textarea"),a.id="ib-textarea",a.className="ib-modal-textarea",a.placeholder=e.placeholder||"What's on your mind?",a.maxLength=5e3,a.setAttribute("aria-label","Feedback"),s=document.createElement("button"),s.id="ib-submit",s.className="ib-modal-submit",s.textContent="Send feedback",s.addEventListener("click",h),p=document.createElement("p"),p.id="ib-success",p.className="ib-modal-success",c=document.createElement("p"),c.id="ib-error",c.className="ib-modal-error",e.showTitleField===!0&&(d=document.createElement("input"),d.id="ib-title-input",d.className="ib-modal-title-input",d.type="text",d.placeholder="Title (optional)",d.maxLength=500,d.setAttribute("aria-label","Feedback title"),v.appendChild(d)),v.appendChild(a),v.appendChild(c),v.appendChild(p);let A=document.createElement("div");A.className="ib-modal-footer",A.appendChild(s);let I=document.createElement("div");I.className="ib-branding";let F=document.createElement("a");return F.href="https://inputbuffer.io",F.target="_blank",F.rel="noopener noreferrer",F.textContent="Powered by inputbuffer.io",I.appendChild(F),A.appendChild(I),v.appendChild(A),l.appendChild(u),l.appendChild(v),i.appendChild(l),i.addEventListener("click",x=>{x.target===i&&y()}),document.addEventListener("keydown",k),i}function S(i){var l;if(!t){if(r=i,t=O(),document.body.appendChild(t),X(e),i!=null&&i.title){if(b)b.textContent=i.title;else if(B){let u=t.querySelector("#ib-modal");u.removeAttribute("aria-label"),u.setAttribute("aria-labelledby","ib-title"),b=document.createElement("h2"),b.id="ib-title",b.className="ib-modal-title",b.textContent=i.title,B.prepend(b)}}if(i!=null&&i.sentiment){n=i.sentiment;let u=t.querySelector(".ib-modal-thumb--up"),m=t.querySelector(".ib-modal-thumb--down");i.sentiment==="positive"?u==null||u.classList.add("ib-modal-thumb--active"):i.sentiment==="negative"&&(m==null||m.classList.add("ib-modal-thumb--active"))}a&&((l=i==null?void 0:i.prefill)!=null&&l.description)&&(a.value=i.prefill.description),a==null||a.focus()}}function y(){t&&(g!==null&&(clearTimeout(g),g=null),document.removeEventListener("keydown",k),t.remove(),t=null,a=null,d=null,s=null,c=null,p=null,b=null,B=null,r=void 0,n=void 0,H.forEach(i=>i()))}function L(i,l){i==="submit"?z.push(l):i==="close"?H.push(l):i==="error"&&E.push(l)}function P(){y()}return{open:S,close:y,on:L,destroy:P}}function ie(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("fill","currentColor"),t.setAttribute("aria-hidden","true"),t.style.display="block";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d",e),t.appendChild(r),t}var ke="M9 21h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2zM9 9l4.34-4.34L12 10h9v2l-3 7H9V9zM1 9h2v12H1z",we="M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L10.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm0 12l-4.34 4.34L12 14H3v-2l3-7h9v10zm4-12h2v12h-2z",Ce=24*60*60*1e3;function K(e){var G,J;let t;function r(){let o=e.target;return o?`ib:reaction:${e.apiKey}:${o.type}:${JSON.stringify(o.metadata)}`:`ib:reaction:${e.apiKey}:${window.location.pathname}`}function n(){try{let o=localStorage.getItem(r());if(!o)return null;let{sentiment:T,ts:C}=JSON.parse(o);return Date.now()-C>Ce?(localStorage.removeItem(r()),null):T}catch{return null}}function g(o){try{localStorage.setItem(r(),JSON.stringify({sentiment:o,ts:Date.now()}))}catch{}}let a={vote:[],open:[],submit:[],close:[],error:[]};function d(o,T){var C;(C=a[o])==null||C.forEach(N=>N(T))}let s=document.createElement("div"),c=e.colorScheme==="dark"?" ib-theme-dark":e.colorScheme==="light"?" ib-theme-light":"";s.className="ib-bar-wrapper"+(e.placement==="fixed"?" ib-bar-wrapper--fixed":"")+c;let{theme:p={}}=e;p.primary&&s.style.setProperty("--ib-primary",p.primary),p.background&&s.style.setProperty("--ib-background",p.background),p.surface&&s.style.setProperty("--ib-surface",p.surface),p.text&&s.style.setProperty("--ib-text",p.text),p.selected&&s.style.setProperty("--ib-selected",p.selected),p.selectedColor&&s.style.setProperty("--ib-selected-color",p.selectedColor);let b=document.createElement("div");b.className="ib-bar";let B=document.createElement("div");B.className="ib-bar-label-area";let z=document.createElement("span");z.className="ib-bar-label",z.textContent=(G=e.label)!=null?G:"Was this helpful?",B.appendChild(z);let H=document.createElement("div");H.className="ib-bar-actions"+(e.showLabel===!1?" ib-bar-actions--no-label":"");let E=document.createElement("button");E.type="button",E.className="ib-bar-btn ib-bar-btn--up",E.setAttribute("aria-label","Yes"),E.appendChild(ie(ke));let k=document.createElement("button");k.type="button",k.className="ib-bar-btn ib-bar-btn--down",k.setAttribute("aria-label","No"),k.appendChild(ie(we)),H.appendChild(E),H.appendChild(k),e.showLabel!==!1&&b.appendChild(B),b.appendChild(H);let h=document.createElement("div");h.className="ib-bar-popover",h.setAttribute("role","dialog"),h.setAttribute("aria-modal","false");let O=document.createElement("div");if(O.className="ib-bar-header",e.modalTitle){h.setAttribute("aria-labelledby","ib-bar-title");let o=document.createElement("p");o.id="ib-bar-title",o.className="ib-bar-title",o.textContent=e.modalTitle,O.appendChild(o)}else h.setAttribute("aria-label","Feedback");let S=document.createElement("div");S.className="ib-bar-body";let y=document.createElement("textarea");y.className="ib-bar-textarea",y.placeholder=(J=e.modalPlaceholder)!=null?J:"What's on your mind?",y.maxLength=5e3,y.setAttribute("aria-label","Feedback");let L=document.createElement("p");L.className="ib-bar-error";let P=document.createElement("p");P.className="ib-bar-success";let i=document.createElement("button");if(i.type="button",i.className="ib-bar-submit",i.textContent="Send feedback",e.showTitleField===!0){let o=document.createElement("input");o.type="text",o.className="ib-bar-title-input",o.placeholder="Title (optional)",o.maxLength=500,o.setAttribute("aria-label","Feedback title"),S.appendChild(o)}S.appendChild(y),S.appendChild(L),S.appendChild(P);let l=document.createElement("div");l.className="ib-bar-footer",l.appendChild(i);let u=document.createElement("div");u.className="ib-branding";let m=document.createElement("a");m.href="https://inputbuffer.io",m.target="_blank",m.rel="noopener noreferrer",m.textContent="Powered by inputbuffer.io",u.appendChild(m),l.appendChild(u),S.appendChild(l),h.appendChild(O),h.appendChild(S),s.appendChild(h),s.appendChild(b);function v(){let o=b.getBoundingClientRect();h.style.top=`${o.top-h.offsetHeight-8}px`,h.style.left=`${o.right-320}px`}function A(o){t=o,h.classList.add("ib-bar-popover--visible"),requestAnimationFrame(v),L.textContent="",P.textContent="",y.focus(),setTimeout(()=>document.addEventListener("click",x),0),document.addEventListener("keydown",w),window.addEventListener("scroll",v,{passive:!0}),window.addEventListener("resize",v,{passive:!0}),d("open",{sentiment:o})}function I(){h.classList.contains("ib-bar-popover--visible")&&(h.classList.remove("ib-bar-popover--visible"),document.removeEventListener("click",x),document.removeEventListener("keydown",w),window.removeEventListener("scroll",v),window.removeEventListener("resize",v),y.value="",d("close"))}function F(){E.classList.remove("ib-bar-btn--active"),k.classList.remove("ib-bar-btn--active"),t=void 0}function x(o){s.contains(o.target)||I()}function w(o){o.key==="Escape"&&I()}async function R(){let o=y.value.trim();if(o.length<10){L.textContent="Please enter at least 10 characters.";return}L.textContent="",i.disabled=!0,i.textContent="Sending\u2026";let T=h.querySelector(".ib-bar-title-input"),C=(T==null?void 0:T.value.trim())||null;try{let N=await D(e.apiKey,o,C,{sentiment:t,target:e.target,submittedBy:e.submittedBy},e.apiUrl);d("submit",N),P.textContent="Thanks for your feedback!",i.textContent="Send feedback",setTimeout(()=>{I(),F()},2e3)}catch(N){d("error",N instanceof Error?N:new Error("Something went wrong.")),L.textContent=j(N),i.disabled=!1,i.textContent="Send feedback"}}function q(o){E.classList.remove("ib-bar-btn--active"),k.classList.remove("ib-bar-btn--active"),o.classList.add("ib-bar-btn--active")}let W=n();W&&(t=W,q(W==="positive"?E:k));function V(o,T){var C;g(o),q(T),A(o),d("vote",{sentiment:o}),e.target&&ee(e.apiKey,o==="positive"?1:-1,e.target,(C=e.userId)!=null?C:null,e.apiUrl).catch(()=>{})}return E.addEventListener("click",()=>V("positive",E)),k.addEventListener("click",()=>V("negative",k)),i.addEventListener("click",R),{element:s,on(o,T){var C;(C=a[o])==null||C.push(T)},destroy(){I(),s.remove()}}}function f(e,t){var r;return(r=e.getAttribute(t))!=null?r:void 0}function ne(e,t){let r=e.getAttribute(t);return r===null?void 0:r==="true"}function Te(e){return{primary:f(e,"theme-primary"),background:f(e,"theme-background"),text:f(e,"theme-text"),selected:f(e,"theme-selected"),selectedColor:f(e,"theme-selected-color")}}function Se(e){var r;let t=e.getAttribute("target-type");if(t)switch(t){case"documentation":{let n=(r=f(e,"target-page-url"))!=null?r:typeof window!="undefined"?window.location.href:void 0;if(!n){M('target-type="documentation" needs target-page-url. Ignoring the target.');return}return{type:"documentation",metadata:{page_url:n,section_heading:f(e,"target-section-heading"),doc_version:f(e,"target-doc-version")}}}case"rest_endpoint":{let n=f(e,"target-method"),g=f(e,"target-path");if(!n||!g){M('target-type="rest_endpoint" needs target-method and target-path. Ignoring the target.');return}return{type:"rest_endpoint",metadata:{method:n,path:g,host:f(e,"target-host"),api_version:f(e,"target-api-version")}}}case"cli_command":{let n=f(e,"target-command");if(!n){M('target-type="cli_command" needs target-command. Ignoring the target.');return}let g=f(e,"target-args");return{type:"cli_command",metadata:{command:n,subcommand:f(e,"target-subcommand"),cli_version:f(e,"target-cli-version"),args:g?g.split(",").map(a=>a.trim()).filter(Boolean):void 0}}}default:M(`Unknown target-type "${t}". Expected documentation, rest_endpoint, or cli_command.`);return}}function oe(e,t){return{apiKey:t,apiUrl:f(e,"api-url"),label:f(e,"label"),showLabel:ne(e,"show-label"),placement:e.getAttribute("placement")==="fixed"?"fixed":"inline",colorScheme:f(e,"color-scheme"),modalTitle:f(e,"modal-title"),modalPlaceholder:f(e,"modal-placeholder"),showTitleField:ne(e,"show-title-field"),submittedBy:f(e,"submitted-by"),userId:f(e,"user-id"),target:Se(e),theme:Te(e)}}function ae(e){return e.getAttribute("inject-styles")!=="false"}function se(e,t){let r=e.dataset;return{apiKey:t,apiUrl:r.apiUrl,attachTo:r.attachTo,injectStyles:r.injectStyles===void 0?!0:r.injectStyles!=="false",colorScheme:r.colorScheme,title:r.title,placeholder:r.placeholder,showTitleField:r.showTitleField===void 0?void 0:r.showTitleField==="true",showSentiment:r.showSentiment===void 0?void 0:r.showSentiment==="true",submittedBy:r.submittedBy,theme:{primary:r.themePrimary,background:r.themeBackground,text:r.themeText,selected:r.themeSelected,selectedColor:r.themeSelectedColor}}}var le=`/* InputBuffer Modal Styles
|
|
2
2
|
* All #ib-* IDs are stable public API \u2014 do not rename them.
|
|
3
3
|
* Developers may target these IDs from their own stylesheets to customize the widget.
|
|
4
4
|
*/
|
|
@@ -99,9 +99,7 @@ function K(e){let t=document.getElementById("ib-modal");if(!t)return;let{theme:i
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
#ib-modal-body #ib-title-input,
|
|
102
|
-
#ib-modal-body .ib-modal-title-input
|
|
103
|
-
#ib-modal-body #ib-email,
|
|
104
|
-
#ib-modal-body .ib-modal-email {
|
|
102
|
+
#ib-modal-body .ib-modal-title-input {
|
|
105
103
|
width: 100%;
|
|
106
104
|
background: var(--ib-background);
|
|
107
105
|
border: 1px solid var(--ib-border);
|
|
@@ -120,22 +118,13 @@ function K(e){let t=document.getElementById("ib-modal");if(!t)return;let{theme:i
|
|
|
120
118
|
margin-bottom: 10px;
|
|
121
119
|
}
|
|
122
120
|
|
|
123
|
-
#ib-email,
|
|
124
|
-
.ib-modal-email {
|
|
125
|
-
margin-top: 10px;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
121
|
#ib-modal-body #ib-title-input:hover,
|
|
129
|
-
#ib-modal-body .ib-modal-title-input:hover
|
|
130
|
-
#ib-modal-body #ib-email:hover,
|
|
131
|
-
#ib-modal-body .ib-modal-email:hover {
|
|
122
|
+
#ib-modal-body .ib-modal-title-input:hover {
|
|
132
123
|
border-color: var(--ib-input-hover-border);
|
|
133
124
|
}
|
|
134
125
|
|
|
135
126
|
#ib-modal-body #ib-title-input:focus,
|
|
136
|
-
#ib-modal-body .ib-modal-title-input:focus
|
|
137
|
-
#ib-modal-body #ib-email:focus,
|
|
138
|
-
#ib-modal-body .ib-modal-email:focus {
|
|
127
|
+
#ib-modal-body .ib-modal-title-input:focus {
|
|
139
128
|
border-color: var(--ib-focus-color);
|
|
140
129
|
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
141
130
|
}
|
|
@@ -306,7 +295,7 @@ function K(e){let t=document.getElementById("ib-modal");if(!t)return;let{theme:i
|
|
|
306
295
|
--ib-radius: 8px;
|
|
307
296
|
--ib-radius-input: 4px;
|
|
308
297
|
}
|
|
309
|
-
`;var
|
|
298
|
+
`;var de=`/* InputBuffer Feedback Bar Styles
|
|
310
299
|
* .ib-bar-* and .ib-bar-popover* classes are stable public API \u2014 do not rename them.
|
|
311
300
|
* Developers may target these classes from their own stylesheets to customize the widget.
|
|
312
301
|
*/
|
|
@@ -414,8 +403,7 @@ function K(e){let t=document.getElementById("ib-modal");if(!t)return;let{theme:i
|
|
|
414
403
|
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
415
404
|
}
|
|
416
405
|
|
|
417
|
-
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input
|
|
418
|
-
.ib-bar-wrapper .ib-bar-body .ib-bar-email {
|
|
406
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input {
|
|
419
407
|
width: 100%;
|
|
420
408
|
background: var(--ib-background);
|
|
421
409
|
border: 1px solid var(--ib-border);
|
|
@@ -433,17 +421,11 @@ function K(e){let t=document.getElementById("ib-modal");if(!t)return;let{theme:i
|
|
|
433
421
|
margin-bottom: 8px;
|
|
434
422
|
}
|
|
435
423
|
|
|
436
|
-
.ib-bar-
|
|
437
|
-
margin-top: 8px;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:hover,
|
|
441
|
-
.ib-bar-wrapper .ib-bar-body .ib-bar-email:hover {
|
|
424
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:hover {
|
|
442
425
|
border-color: var(--ib-input-hover-border);
|
|
443
426
|
}
|
|
444
427
|
|
|
445
|
-
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:focus
|
|
446
|
-
.ib-bar-wrapper .ib-bar-body .ib-bar-email:focus {
|
|
428
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:focus {
|
|
447
429
|
border-color: var(--ib-focus-color);
|
|
448
430
|
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
449
431
|
}
|
|
@@ -627,4 +609,4 @@ function K(e){let t=document.getElementById("ib-modal");if(!t)return;let{theme:i
|
|
|
627
609
|
--ib-radius: 8px;
|
|
628
610
|
--ib-radius-input: 4px;
|
|
629
611
|
}
|
|
630
|
-
`;var
|
|
612
|
+
`;var $=typeof document!="undefined"?document.currentScript:null;function Ae(){if(typeof document=="undefined"||document.getElementById("ib-modal-styles"))return;let e=document.createElement("style");e.id="ib-modal-styles",e.textContent=le,document.head.appendChild(e)}function ce(){if(typeof document=="undefined"||document.getElementById("ib-bar-styles"))return;let e=document.createElement("style");e.id="ib-bar-styles",e.textContent=de,document.head.appendChild(e)}function be(e){e.injectStyles!==!1&&Ae();let t=re(e),r=null,n=null;return e.attachTo&&(r=document.querySelector(e.attachTo),r&&(n=()=>t.open(),r.addEventListener("click",n))),{open:g=>t.open(g),close:()=>t.close(),on:(g,a)=>t.on(g,a),destroy:()=>{r&&n&&(r.removeEventListener("click",n),r=null,n=null),t.destroy()}}}function Ie(e){return e.injectStyles!==!1&&ce(),K(e)}if(typeof HTMLElement!="undefined"){class e extends HTMLElement{constructor(){super(...arguments);this._bar=null}connectedCallback(){let n=this.getAttribute("api-key");n&&(ae(this)&&ce(),this._bar=K(oe(this,n)),this.appendChild(this._bar.element))}disconnectedCallback(){var n;(n=this._bar)==null||n.destroy(),this._bar=null}}typeof customElements!="undefined"&&!customElements.get("inputbuffer-feedback")&&customElements.define("inputbuffer-feedback",e)}var ue={createModal:be,createBar:Ie,version:U};typeof window!="undefined"&&(window.InputBufferIO=ue);(function(){if(typeof window=="undefined"||!$)return;let t=$.dataset.apiKey;if(!t)return;let r=be(se($,t));ue._defaultInstance=r})();export{_ as ApiError,ue as InputBufferIO};
|
package/dist/widget.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{function K(e){let t=document.getElementById("ib-modal");if(!t)return;let{theme:i={}}=e;i.primary&&t.style.setProperty("--ib-primary",i.primary),i.background&&t.style.setProperty("--ib-background",i.background),i.surface&&t.style.setProperty("--ib-surface",i.surface),i.text&&t.style.setProperty("--ib-text",i.text),i.selected&&t.style.setProperty("--ib-selected",i.selected),i.selectedColor&&t.style.setProperty("--ib-selected-color",i.selectedColor)}var D="0.1.1",Q="https://inputbuffer.io/api/v0/inputs";async function W(e,t,i,d,o,m){var y;let l={description:t};if(d&&(l.title=d),i&&(l.contactEmail=i),o!=null&&o.sentiment&&(l.sentiment=o.sentiment),o!=null&&o.source&&(l.source=o.source),o!=null&&o.target){let n=o.target;l.targets=[{target_type:n.type,...n.targetId&&{target_id:n.targetId},...n.displayName&&{display_name:n.displayName},...n.dedupKey&&{dedup_key:n.dedupKey},metadata:n.metadata}]}let c=new AbortController,h=setTimeout(()=>c.abort(),1e4),u;try{u=await fetch(m!=null?m:Q,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-IB-Client":`inputbuffer-widget/${D} (javascript)`},body:JSON.stringify(l),credentials:"omit",signal:c.signal})}finally{clearTimeout(h)}if(!u.ok){let n=await u.json().catch(()=>({}));throw new Error(((y=n==null?void 0:n.error)==null?void 0:y.message)||"Submission failed. Please try again.")}return u.json()}function U(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("fill","currentColor"),t.setAttribute("aria-hidden","true"),t.style.display="block";let i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d",e),t.appendChild(i),t}var Z="M9 21h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2zM9 9l4.34-4.34L12 10h9v2l-3 7H9V9zM1 9h2v12H1z",ee="M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L10.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm0 12l-4.34 4.34L12 14H3v-2l3-7h9v10zm4-12h2v12h-2z";function _(e){let t=null,i,d,o=null,m=null,l=null,c=null,h=null,u=null,y=null,n=null,x=null,f=[],S=[],C=[];function A(r){if(r.key==="Escape"){L();return}if(r.key==="Tab"&&t){let s=Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(s.length===0)return;let v=s[0],p=s[s.length-1];r.shiftKey?document.activeElement===v&&(r.preventDefault(),p.focus()):document.activeElement===p&&(r.preventDefault(),v.focus())}}async function H(){var s,v;if(!m||!h)return;let r=m.value.trim();if(r.length<10){u&&(u.textContent="Please enter at least 10 characters.",u.style.display="block");return}u&&(u.style.display="none"),h.disabled=!0,h.textContent="Sending\u2026";try{let p=(c==null?void 0:c.value.trim())||((s=i==null?void 0:i.prefill)==null?void 0:s.email)||null,g=(l==null?void 0:l.value.trim())||null,B=d!=null?d:i==null?void 0:i.sentiment,N=await W(e.apiKey,r,p||null,g,{...i,sentiment:B,source:(v=i==null?void 0:i.source)!=null?v:e.source},e.apiUrl);y&&(y.textContent="Thanks for your feedback!",y.style.display="block"),f.forEach(T=>T(N)),o=setTimeout(()=>L(),2e3)}catch(p){let g=p instanceof Error?p:new Error("Unknown error");u&&(u.textContent="Something went wrong. Please try again.",u.style.display="block"),C.forEach(B=>B(g)),h.disabled=!1,h.textContent="Send feedback"}}function F(){let r=document.createElement("div");r.id="ib-overlay";let s=document.createElement("div");s.id="ib-modal",e.colorScheme==="dark"?s.classList.add("ib-theme-dark"):e.colorScheme==="light"&&s.classList.add("ib-theme-light"),s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true");let v=document.createElement("div");if(v.id="ib-modal-header",x=v,e.title?(s.setAttribute("aria-labelledby","ib-title"),n=document.createElement("h2"),n.id="ib-title",n.className="ib-modal-title",n.textContent=e.title,v.appendChild(n)):s.setAttribute("aria-label","Feedback"),e.showSentiment){let k,w,a=document.createElement("div");a.className="ib-modal-sentiment",k=document.createElement("button"),k.type="button",k.className="ib-modal-thumb ib-modal-thumb--up",k.setAttribute("aria-label","Helpful"),k.appendChild(U(Z)),w=document.createElement("button"),w.type="button",w.className="ib-modal-thumb ib-modal-thumb--down",w.setAttribute("aria-label","Not helpful"),w.appendChild(U(ee)),k.addEventListener("click",()=>{k.classList.add("ib-modal-thumb--active"),w.classList.remove("ib-modal-thumb--active"),d="positive"}),w.addEventListener("click",()=>{w.classList.add("ib-modal-thumb--active"),k.classList.remove("ib-modal-thumb--active"),d="negative"}),a.appendChild(k),a.appendChild(w),v.appendChild(a)}let p=document.createElement("button");p.id="ib-close",p.className="ib-modal-close",p.textContent="\xD7",p.setAttribute("aria-label","Close feedback form"),p.addEventListener("click",L),v.appendChild(p);let g=document.createElement("div");g.id="ib-modal-body",m=document.createElement("textarea"),m.id="ib-textarea",m.className="ib-modal-textarea",m.placeholder=e.placeholder||"What's on your mind?",m.setAttribute("aria-label","Feedback"),h=document.createElement("button"),h.id="ib-submit",h.className="ib-modal-submit",h.textContent="Send feedback",h.addEventListener("click",H),y=document.createElement("p"),y.id="ib-success",y.className="ib-modal-success",u=document.createElement("p"),u.id="ib-error",u.className="ib-modal-error",e.showTitleField===!0&&(l=document.createElement("input"),l.id="ib-title-input",l.className="ib-modal-title-input",l.type="text",l.placeholder="Title (optional)",l.setAttribute("aria-label","Feedback title"),g.appendChild(l)),g.appendChild(m),e.showEmailField===!0&&(c=document.createElement("input"),c.id="ib-email",c.className="ib-modal-email",c.type="email",c.placeholder="Your email (optional)",c.setAttribute("aria-label","Email address"),g.appendChild(c)),g.appendChild(u),g.appendChild(y);let B=document.createElement("div");B.className="ib-modal-footer",B.appendChild(h);let N=document.createElement("div");N.className="ib-branding";let T=document.createElement("a");return T.href="https://inputbuffer.io",T.target="_blank",T.rel="noopener noreferrer",T.textContent="Powered by inputbuffer.io",N.appendChild(T),B.appendChild(N),g.appendChild(B),s.appendChild(v),s.appendChild(g),r.appendChild(s),r.addEventListener("click",k=>{k.target===r&&L()}),document.addEventListener("keydown",A),r}function E(r){var s,v;if(!t){if(i=r,t=F(),document.body.appendChild(t),K(e),r!=null&&r.title){if(n)n.textContent=r.title;else if(x){let p=t.querySelector("#ib-modal");p.removeAttribute("aria-label"),p.setAttribute("aria-labelledby","ib-title"),n=document.createElement("h2"),n.id="ib-title",n.className="ib-modal-title",n.textContent=r.title,x.prepend(n)}}if(r!=null&&r.sentiment){d=r.sentiment;let p=t.querySelector(".ib-modal-thumb--up"),g=t.querySelector(".ib-modal-thumb--down");r.sentiment==="positive"?p==null||p.classList.add("ib-modal-thumb--active"):r.sentiment==="negative"&&(g==null||g.classList.add("ib-modal-thumb--active"))}m&&((s=r==null?void 0:r.prefill)!=null&&s.description)&&(m.value=r.prefill.description),c&&((v=r==null?void 0:r.prefill)!=null&&v.email)&&(c.value=r.prefill.email),m==null||m.focus()}}function L(){t&&(o!==null&&(clearTimeout(o),o=null),document.removeEventListener("keydown",A),t.remove(),t=null,m=null,l=null,c=null,h=null,u=null,y=null,n=null,x=null,i=void 0,d=void 0,S.forEach(r=>r()))}function O(r,s){r==="submit"?f.push(s):r==="close"?S.push(s):r==="error"&&C.push(s)}function I(){L()}return{open:E,close:L,on:O,destroy:I}}function V(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("fill","currentColor"),t.setAttribute("aria-hidden","true"),t.style.display="block";let i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d",e),t.appendChild(i),t}var te="M9 21h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2zM9 9l4.34-4.34L12 10h9v2l-3 7H9V9zM1 9h2v12H1z",ie="M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L10.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm0 12l-4.34 4.34L12 14H3v-2l3-7h9v10zm4-12h2v12h-2z";function R(e){var k,w;let t,i={vote:[],open:[],submit:[],close:[],error:[]};function d(a,M){var z;(z=i[a])==null||z.forEach(j=>j(M))}let o=document.createElement("div"),m=e.colorScheme==="dark"?" ib-theme-dark":e.colorScheme==="light"?" ib-theme-light":"";o.className="ib-bar-wrapper"+(e.placement==="fixed"?" ib-bar-wrapper--fixed":"")+m;let{theme:l={}}=e;l.primary&&o.style.setProperty("--ib-primary",l.primary),l.background&&o.style.setProperty("--ib-background",l.background),l.surface&&o.style.setProperty("--ib-surface",l.surface),l.text&&o.style.setProperty("--ib-text",l.text),l.selected&&o.style.setProperty("--ib-selected",l.selected),l.selectedColor&&o.style.setProperty("--ib-selected-color",l.selectedColor);let c=document.createElement("div");c.className="ib-bar";let h=document.createElement("div");h.className="ib-bar-label-area";let u=document.createElement("span");u.className="ib-bar-label",u.textContent=(k=e.label)!=null?k:"Was this helpful?",h.appendChild(u);let y=document.createElement("div");y.className="ib-bar-actions"+(e.showLabel===!1?" ib-bar-actions--no-label":"");let n=document.createElement("button");n.type="button",n.className="ib-bar-btn ib-bar-btn--up",n.setAttribute("aria-label","Yes"),n.appendChild(V(te));let x=document.createElement("button");x.type="button",x.className="ib-bar-btn ib-bar-btn--down",x.setAttribute("aria-label","No"),x.appendChild(V(ie)),y.appendChild(n),y.appendChild(x),e.showLabel!==!1&&c.appendChild(h),c.appendChild(y);let f=document.createElement("div");f.className="ib-bar-popover",f.setAttribute("role","dialog"),f.setAttribute("aria-modal","false");let S=document.createElement("div");if(S.className="ib-bar-header",e.modalTitle){f.setAttribute("aria-labelledby","ib-bar-title");let a=document.createElement("p");a.id="ib-bar-title",a.className="ib-bar-title",a.textContent=e.modalTitle,S.appendChild(a)}else f.setAttribute("aria-label","Feedback");let C=document.createElement("div");C.className="ib-bar-body";let A=document.createElement("textarea");A.className="ib-bar-textarea",A.placeholder=(w=e.modalPlaceholder)!=null?w:"What's on your mind?",A.setAttribute("aria-label","Feedback");let H=document.createElement("p");H.className="ib-bar-error";let F=document.createElement("p");F.className="ib-bar-success";let E=document.createElement("button");if(E.type="button",E.className="ib-bar-submit",E.textContent="Send feedback",e.showTitleField===!0){let a=document.createElement("input");a.type="text",a.className="ib-bar-title-input",a.placeholder="Title (optional)",a.setAttribute("aria-label","Feedback title"),C.appendChild(a)}if(C.appendChild(A),e.showEmailField===!0){let a=document.createElement("input");a.type="email",a.className="ib-bar-email",a.placeholder="Your email (optional)",a.setAttribute("aria-label","Email address"),C.appendChild(a)}C.appendChild(H),C.appendChild(F);let L=document.createElement("div");L.className="ib-bar-footer",L.appendChild(E);let O=document.createElement("div");O.className="ib-branding";let I=document.createElement("a");I.href="https://inputbuffer.io",I.target="_blank",I.rel="noopener noreferrer",I.textContent="Powered by inputbuffer.io",O.appendChild(I),L.appendChild(O),C.appendChild(L),f.appendChild(S),f.appendChild(C),o.appendChild(f),o.appendChild(c);function r(){let a=c.getBoundingClientRect();f.style.top=`${a.top-f.offsetHeight-8}px`,f.style.left=`${a.right-320}px`}function s(a){t=a,f.classList.add("ib-bar-popover--visible"),requestAnimationFrame(r),H.textContent="",F.textContent="",A.focus(),setTimeout(()=>document.addEventListener("click",g),0),document.addEventListener("keydown",B),window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r,{passive:!0}),d("open",{sentiment:a})}function v(){f.classList.contains("ib-bar-popover--visible")&&(f.classList.remove("ib-bar-popover--visible"),document.removeEventListener("click",g),document.removeEventListener("keydown",B),window.removeEventListener("scroll",r),window.removeEventListener("resize",r),A.value="",d("close"))}function p(){n.classList.remove("ib-bar-btn--active"),x.classList.remove("ib-bar-btn--active"),t=void 0}function g(a){o.contains(a.target)||v()}function B(a){a.key==="Escape"&&v()}async function N(){let a=A.value.trim();if(a.length<10){H.textContent="Please enter at least 10 characters.";return}H.textContent="",E.disabled=!0,E.textContent="Sending\u2026";let M=f.querySelector(".ib-bar-title-input"),z=(M==null?void 0:M.value.trim())||null,j=f.querySelector(".ib-bar-email"),X=(j==null?void 0:j.value.trim())||null;try{let P=await W(e.apiKey,a,X,z,{sentiment:t,target:e.target,source:e.source},e.apiUrl);d("submit",P),F.textContent="Thanks for your feedback!",E.textContent="Send feedback",setTimeout(()=>{v(),p()},2e3)}catch(P){d("error",P instanceof Error?P:new Error("Something went wrong.")),H.textContent=P instanceof Error?P.message:"Something went wrong.",E.disabled=!1,E.textContent="Send feedback"}}function T(a){n.classList.remove("ib-bar-btn--active"),x.classList.remove("ib-bar-btn--active"),a.classList.add("ib-bar-btn--active")}return n.addEventListener("click",()=>{d("vote",{sentiment:"positive"}),T(n),s("positive")}),x.addEventListener("click",()=>{d("vote",{sentiment:"negative"}),T(x),s("negative")}),E.addEventListener("click",N),{element:o,on(a,M){var z;(z=i[a])==null||z.push(M)},destroy(){v(),o.remove()}}}var q=`/* InputBuffer Modal Styles
|
|
1
|
+
"use strict";(()=>{function X(e){let t=document.getElementById("ib-modal");if(!t)return;let{theme:r={}}=e;r.primary&&t.style.setProperty("--ib-primary",r.primary),r.background&&t.style.setProperty("--ib-background",r.background),r.surface&&t.style.setProperty("--ib-surface",r.surface),r.text&&t.style.setProperty("--ib-text",r.text),r.selected&&t.style.setProperty("--ib-selected",r.selected),r.selectedColor&&t.style.setProperty("--ib-selected-color",r.selectedColor)}var _=class extends Error{constructor(t){super(t.detail),this.name="ApiError",this.type=t.type,this.title=t.title,this.status=t.status,this.detail=t.detail,this.category=t.category,this.field=t.field}};var Y="Something went wrong. Please try again.";function j(e){return e instanceof _?e.category==="user"?e.detail:(e.category==="integration"&&M(`${e.title}: ${e.detail}`,e.type),Y):Y}function M(e,t){typeof console!="undefined"&&console.warn(`[inputbuffer] ${e}`,t!=null?t:"")}var U="0.3.0",pe="https://inputbuffer.io",me="/api/v0/feedback",fe="/api/v0/reactions",ge=1e4,he=5e3,ve=500,ye=300;function Q(e,t){return`${(e!=null?e:pe).replace(/\/+$/,"")}${t}`}async function Z(e,t,r){var d,s,c,p;let n=new AbortController,g=setTimeout(()=>n.abort(),ge),a;try{a=await fetch(e,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-IB-Client":`inputbuffer-widget/${U} (javascript)`},body:JSON.stringify(r),credentials:"omit",signal:n.signal})}finally{clearTimeout(g)}if(!a.ok){let b=await a.json().catch(()=>({}));throw new _({type:(d=b.type)!=null?d:"https://inputbuffer.io/docs/api/problems/internal-error",title:(s=b.title)!=null?s:"Error",detail:(c=b.detail)!=null?c:"Submission failed. Please try again.",status:(p=b.status)!=null?p:a.status,category:b.category,field:b.field})}return a}async function D(e,t,r,n,g){let a={description:t.slice(0,he)};if(r&&(a.title=r.slice(0,ve)),n!=null&&n.submittedBy&&(a.submitted_by=n.submittedBy.slice(0,ye)),n!=null&&n.target){let c=n.target;a.targets=[{type:c.type,metadata:c.metadata}]}let d=await Z(Q(g,me),e,a),{data:s}=await d.json();return{id:s.id}}async function ee(e,t,r,n,g){let a={reaction_value:t,target:{type:r.type,metadata:r.metadata}};n&&(a.user_id=n);let d;try{d=await Z(Q(g,fe),e,a)}catch(c){throw c instanceof _&&c.status===422&&c.field==="user_id"&&M("Reaction rejected: no user_id and no client IP. Set the `userId` option (or the `user-id` attribute)."),c}let{data:s}=await d.json();return s}function te(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("fill","currentColor"),t.setAttribute("aria-hidden","true"),t.style.display="block";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d",e),t.appendChild(r),t}var xe="M9 21h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2zM9 9l4.34-4.34L12 10h9v2l-3 7H9V9zM1 9h2v12H1z",Ee="M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L10.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm0 12l-4.34 4.34L12 14H3v-2l3-7h9v10zm4-12h2v12h-2z";function re(e){let t=null,r,n,g=null,a=null,d=null,s=null,c=null,p=null,b=null,B=null,z=[],H=[],E=[];function k(i){if(i.key==="Escape"){y();return}if(i.key==="Tab"&&t){let l=Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(l.length===0)return;let u=l[0],m=l[l.length-1];i.shiftKey?document.activeElement===u&&(i.preventDefault(),m.focus()):document.activeElement===m&&(i.preventDefault(),u.focus())}}async function h(){var l;if(!a||!s)return;let i=a.value.trim();if(i.length<10){c&&(c.textContent="Please enter at least 10 characters.",c.style.display="block");return}c&&(c.style.display="none"),s.disabled=!0,s.textContent="Sending\u2026";try{let u=(d==null?void 0:d.value.trim())||null,m=n!=null?n:r==null?void 0:r.sentiment,v=await D(e.apiKey,i,u,{...r,sentiment:m,submittedBy:(l=r==null?void 0:r.submittedBy)!=null?l:e.submittedBy},e.apiUrl);p&&(p.textContent="Thanks for your feedback!",p.style.display="block"),z.forEach(A=>A(v)),g=setTimeout(()=>y(),2e3)}catch(u){let m=u instanceof Error?u:new Error("Unknown error");c&&(c.textContent=j(u),c.style.display="block"),E.forEach(v=>v(m)),s.disabled=!1,s.textContent="Send feedback"}}function O(){let i=document.createElement("div");i.id="ib-overlay";let l=document.createElement("div");l.id="ib-modal",e.colorScheme==="dark"?l.classList.add("ib-theme-dark"):e.colorScheme==="light"&&l.classList.add("ib-theme-light"),l.setAttribute("role","dialog"),l.setAttribute("aria-modal","true");let u=document.createElement("div");if(u.id="ib-modal-header",B=u,e.title?(l.setAttribute("aria-labelledby","ib-title"),b=document.createElement("h2"),b.id="ib-title",b.className="ib-modal-title",b.textContent=e.title,u.appendChild(b)):l.setAttribute("aria-label","Feedback"),e.showSentiment){let x,w,R=document.createElement("div");R.className="ib-modal-sentiment",x=document.createElement("button"),x.type="button",x.className="ib-modal-thumb ib-modal-thumb--up",x.setAttribute("aria-label","Helpful"),x.appendChild(te(xe)),w=document.createElement("button"),w.type="button",w.className="ib-modal-thumb ib-modal-thumb--down",w.setAttribute("aria-label","Not helpful"),w.appendChild(te(Ee)),x.addEventListener("click",()=>{x.classList.add("ib-modal-thumb--active"),w.classList.remove("ib-modal-thumb--active"),n="positive"}),w.addEventListener("click",()=>{w.classList.add("ib-modal-thumb--active"),x.classList.remove("ib-modal-thumb--active"),n="negative"}),R.appendChild(x),R.appendChild(w),u.appendChild(R)}let m=document.createElement("button");m.id="ib-close",m.className="ib-modal-close",m.textContent="\xD7",m.setAttribute("aria-label","Close feedback form"),m.addEventListener("click",y),u.appendChild(m);let v=document.createElement("div");v.id="ib-modal-body",a=document.createElement("textarea"),a.id="ib-textarea",a.className="ib-modal-textarea",a.placeholder=e.placeholder||"What's on your mind?",a.maxLength=5e3,a.setAttribute("aria-label","Feedback"),s=document.createElement("button"),s.id="ib-submit",s.className="ib-modal-submit",s.textContent="Send feedback",s.addEventListener("click",h),p=document.createElement("p"),p.id="ib-success",p.className="ib-modal-success",c=document.createElement("p"),c.id="ib-error",c.className="ib-modal-error",e.showTitleField===!0&&(d=document.createElement("input"),d.id="ib-title-input",d.className="ib-modal-title-input",d.type="text",d.placeholder="Title (optional)",d.maxLength=500,d.setAttribute("aria-label","Feedback title"),v.appendChild(d)),v.appendChild(a),v.appendChild(c),v.appendChild(p);let A=document.createElement("div");A.className="ib-modal-footer",A.appendChild(s);let I=document.createElement("div");I.className="ib-branding";let F=document.createElement("a");return F.href="https://inputbuffer.io",F.target="_blank",F.rel="noopener noreferrer",F.textContent="Powered by inputbuffer.io",I.appendChild(F),A.appendChild(I),v.appendChild(A),l.appendChild(u),l.appendChild(v),i.appendChild(l),i.addEventListener("click",x=>{x.target===i&&y()}),document.addEventListener("keydown",k),i}function S(i){var l;if(!t){if(r=i,t=O(),document.body.appendChild(t),X(e),i!=null&&i.title){if(b)b.textContent=i.title;else if(B){let u=t.querySelector("#ib-modal");u.removeAttribute("aria-label"),u.setAttribute("aria-labelledby","ib-title"),b=document.createElement("h2"),b.id="ib-title",b.className="ib-modal-title",b.textContent=i.title,B.prepend(b)}}if(i!=null&&i.sentiment){n=i.sentiment;let u=t.querySelector(".ib-modal-thumb--up"),m=t.querySelector(".ib-modal-thumb--down");i.sentiment==="positive"?u==null||u.classList.add("ib-modal-thumb--active"):i.sentiment==="negative"&&(m==null||m.classList.add("ib-modal-thumb--active"))}a&&((l=i==null?void 0:i.prefill)!=null&&l.description)&&(a.value=i.prefill.description),a==null||a.focus()}}function y(){t&&(g!==null&&(clearTimeout(g),g=null),document.removeEventListener("keydown",k),t.remove(),t=null,a=null,d=null,s=null,c=null,p=null,b=null,B=null,r=void 0,n=void 0,H.forEach(i=>i()))}function L(i,l){i==="submit"?z.push(l):i==="close"?H.push(l):i==="error"&&E.push(l)}function P(){y()}return{open:S,close:y,on:L,destroy:P}}function ie(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("fill","currentColor"),t.setAttribute("aria-hidden","true"),t.style.display="block";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d",e),t.appendChild(r),t}var ke="M9 21h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2zM9 9l4.34-4.34L12 10h9v2l-3 7H9V9zM1 9h2v12H1z",we="M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L10.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm0 12l-4.34 4.34L12 14H3v-2l3-7h9v10zm4-12h2v12h-2z",Ce=24*60*60*1e3;function K(e){var G,J;let t;function r(){let o=e.target;return o?`ib:reaction:${e.apiKey}:${o.type}:${JSON.stringify(o.metadata)}`:`ib:reaction:${e.apiKey}:${window.location.pathname}`}function n(){try{let o=localStorage.getItem(r());if(!o)return null;let{sentiment:T,ts:C}=JSON.parse(o);return Date.now()-C>Ce?(localStorage.removeItem(r()),null):T}catch{return null}}function g(o){try{localStorage.setItem(r(),JSON.stringify({sentiment:o,ts:Date.now()}))}catch{}}let a={vote:[],open:[],submit:[],close:[],error:[]};function d(o,T){var C;(C=a[o])==null||C.forEach(N=>N(T))}let s=document.createElement("div"),c=e.colorScheme==="dark"?" ib-theme-dark":e.colorScheme==="light"?" ib-theme-light":"";s.className="ib-bar-wrapper"+(e.placement==="fixed"?" ib-bar-wrapper--fixed":"")+c;let{theme:p={}}=e;p.primary&&s.style.setProperty("--ib-primary",p.primary),p.background&&s.style.setProperty("--ib-background",p.background),p.surface&&s.style.setProperty("--ib-surface",p.surface),p.text&&s.style.setProperty("--ib-text",p.text),p.selected&&s.style.setProperty("--ib-selected",p.selected),p.selectedColor&&s.style.setProperty("--ib-selected-color",p.selectedColor);let b=document.createElement("div");b.className="ib-bar";let B=document.createElement("div");B.className="ib-bar-label-area";let z=document.createElement("span");z.className="ib-bar-label",z.textContent=(G=e.label)!=null?G:"Was this helpful?",B.appendChild(z);let H=document.createElement("div");H.className="ib-bar-actions"+(e.showLabel===!1?" ib-bar-actions--no-label":"");let E=document.createElement("button");E.type="button",E.className="ib-bar-btn ib-bar-btn--up",E.setAttribute("aria-label","Yes"),E.appendChild(ie(ke));let k=document.createElement("button");k.type="button",k.className="ib-bar-btn ib-bar-btn--down",k.setAttribute("aria-label","No"),k.appendChild(ie(we)),H.appendChild(E),H.appendChild(k),e.showLabel!==!1&&b.appendChild(B),b.appendChild(H);let h=document.createElement("div");h.className="ib-bar-popover",h.setAttribute("role","dialog"),h.setAttribute("aria-modal","false");let O=document.createElement("div");if(O.className="ib-bar-header",e.modalTitle){h.setAttribute("aria-labelledby","ib-bar-title");let o=document.createElement("p");o.id="ib-bar-title",o.className="ib-bar-title",o.textContent=e.modalTitle,O.appendChild(o)}else h.setAttribute("aria-label","Feedback");let S=document.createElement("div");S.className="ib-bar-body";let y=document.createElement("textarea");y.className="ib-bar-textarea",y.placeholder=(J=e.modalPlaceholder)!=null?J:"What's on your mind?",y.maxLength=5e3,y.setAttribute("aria-label","Feedback");let L=document.createElement("p");L.className="ib-bar-error";let P=document.createElement("p");P.className="ib-bar-success";let i=document.createElement("button");if(i.type="button",i.className="ib-bar-submit",i.textContent="Send feedback",e.showTitleField===!0){let o=document.createElement("input");o.type="text",o.className="ib-bar-title-input",o.placeholder="Title (optional)",o.maxLength=500,o.setAttribute("aria-label","Feedback title"),S.appendChild(o)}S.appendChild(y),S.appendChild(L),S.appendChild(P);let l=document.createElement("div");l.className="ib-bar-footer",l.appendChild(i);let u=document.createElement("div");u.className="ib-branding";let m=document.createElement("a");m.href="https://inputbuffer.io",m.target="_blank",m.rel="noopener noreferrer",m.textContent="Powered by inputbuffer.io",u.appendChild(m),l.appendChild(u),S.appendChild(l),h.appendChild(O),h.appendChild(S),s.appendChild(h),s.appendChild(b);function v(){let o=b.getBoundingClientRect();h.style.top=`${o.top-h.offsetHeight-8}px`,h.style.left=`${o.right-320}px`}function A(o){t=o,h.classList.add("ib-bar-popover--visible"),requestAnimationFrame(v),L.textContent="",P.textContent="",y.focus(),setTimeout(()=>document.addEventListener("click",x),0),document.addEventListener("keydown",w),window.addEventListener("scroll",v,{passive:!0}),window.addEventListener("resize",v,{passive:!0}),d("open",{sentiment:o})}function I(){h.classList.contains("ib-bar-popover--visible")&&(h.classList.remove("ib-bar-popover--visible"),document.removeEventListener("click",x),document.removeEventListener("keydown",w),window.removeEventListener("scroll",v),window.removeEventListener("resize",v),y.value="",d("close"))}function F(){E.classList.remove("ib-bar-btn--active"),k.classList.remove("ib-bar-btn--active"),t=void 0}function x(o){s.contains(o.target)||I()}function w(o){o.key==="Escape"&&I()}async function R(){let o=y.value.trim();if(o.length<10){L.textContent="Please enter at least 10 characters.";return}L.textContent="",i.disabled=!0,i.textContent="Sending\u2026";let T=h.querySelector(".ib-bar-title-input"),C=(T==null?void 0:T.value.trim())||null;try{let N=await D(e.apiKey,o,C,{sentiment:t,target:e.target,submittedBy:e.submittedBy},e.apiUrl);d("submit",N),P.textContent="Thanks for your feedback!",i.textContent="Send feedback",setTimeout(()=>{I(),F()},2e3)}catch(N){d("error",N instanceof Error?N:new Error("Something went wrong.")),L.textContent=j(N),i.disabled=!1,i.textContent="Send feedback"}}function q(o){E.classList.remove("ib-bar-btn--active"),k.classList.remove("ib-bar-btn--active"),o.classList.add("ib-bar-btn--active")}let W=n();W&&(t=W,q(W==="positive"?E:k));function V(o,T){var C;g(o),q(T),A(o),d("vote",{sentiment:o}),e.target&&ee(e.apiKey,o==="positive"?1:-1,e.target,(C=e.userId)!=null?C:null,e.apiUrl).catch(()=>{})}return E.addEventListener("click",()=>V("positive",E)),k.addEventListener("click",()=>V("negative",k)),i.addEventListener("click",R),{element:s,on(o,T){var C;(C=a[o])==null||C.push(T)},destroy(){I(),s.remove()}}}function f(e,t){var r;return(r=e.getAttribute(t))!=null?r:void 0}function ne(e,t){let r=e.getAttribute(t);return r===null?void 0:r==="true"}function Te(e){return{primary:f(e,"theme-primary"),background:f(e,"theme-background"),text:f(e,"theme-text"),selected:f(e,"theme-selected"),selectedColor:f(e,"theme-selected-color")}}function Se(e){var r;let t=e.getAttribute("target-type");if(t)switch(t){case"documentation":{let n=(r=f(e,"target-page-url"))!=null?r:typeof window!="undefined"?window.location.href:void 0;if(!n){M('target-type="documentation" needs target-page-url. Ignoring the target.');return}return{type:"documentation",metadata:{page_url:n,section_heading:f(e,"target-section-heading"),doc_version:f(e,"target-doc-version")}}}case"rest_endpoint":{let n=f(e,"target-method"),g=f(e,"target-path");if(!n||!g){M('target-type="rest_endpoint" needs target-method and target-path. Ignoring the target.');return}return{type:"rest_endpoint",metadata:{method:n,path:g,host:f(e,"target-host"),api_version:f(e,"target-api-version")}}}case"cli_command":{let n=f(e,"target-command");if(!n){M('target-type="cli_command" needs target-command. Ignoring the target.');return}let g=f(e,"target-args");return{type:"cli_command",metadata:{command:n,subcommand:f(e,"target-subcommand"),cli_version:f(e,"target-cli-version"),args:g?g.split(",").map(a=>a.trim()).filter(Boolean):void 0}}}default:M(`Unknown target-type "${t}". Expected documentation, rest_endpoint, or cli_command.`);return}}function oe(e,t){return{apiKey:t,apiUrl:f(e,"api-url"),label:f(e,"label"),showLabel:ne(e,"show-label"),placement:e.getAttribute("placement")==="fixed"?"fixed":"inline",colorScheme:f(e,"color-scheme"),modalTitle:f(e,"modal-title"),modalPlaceholder:f(e,"modal-placeholder"),showTitleField:ne(e,"show-title-field"),submittedBy:f(e,"submitted-by"),userId:f(e,"user-id"),target:Se(e),theme:Te(e)}}function ae(e){return e.getAttribute("inject-styles")!=="false"}function se(e,t){let r=e.dataset;return{apiKey:t,apiUrl:r.apiUrl,attachTo:r.attachTo,injectStyles:r.injectStyles===void 0?!0:r.injectStyles!=="false",colorScheme:r.colorScheme,title:r.title,placeholder:r.placeholder,showTitleField:r.showTitleField===void 0?void 0:r.showTitleField==="true",showSentiment:r.showSentiment===void 0?void 0:r.showSentiment==="true",submittedBy:r.submittedBy,theme:{primary:r.themePrimary,background:r.themeBackground,text:r.themeText,selected:r.themeSelected,selectedColor:r.themeSelectedColor}}}var le=`/* InputBuffer Modal Styles
|
|
2
2
|
* All #ib-* IDs are stable public API \u2014 do not rename them.
|
|
3
3
|
* Developers may target these IDs from their own stylesheets to customize the widget.
|
|
4
4
|
*/
|
|
@@ -99,9 +99,7 @@
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
#ib-modal-body #ib-title-input,
|
|
102
|
-
#ib-modal-body .ib-modal-title-input
|
|
103
|
-
#ib-modal-body #ib-email,
|
|
104
|
-
#ib-modal-body .ib-modal-email {
|
|
102
|
+
#ib-modal-body .ib-modal-title-input {
|
|
105
103
|
width: 100%;
|
|
106
104
|
background: var(--ib-background);
|
|
107
105
|
border: 1px solid var(--ib-border);
|
|
@@ -120,22 +118,13 @@
|
|
|
120
118
|
margin-bottom: 10px;
|
|
121
119
|
}
|
|
122
120
|
|
|
123
|
-
#ib-email,
|
|
124
|
-
.ib-modal-email {
|
|
125
|
-
margin-top: 10px;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
121
|
#ib-modal-body #ib-title-input:hover,
|
|
129
|
-
#ib-modal-body .ib-modal-title-input:hover
|
|
130
|
-
#ib-modal-body #ib-email:hover,
|
|
131
|
-
#ib-modal-body .ib-modal-email:hover {
|
|
122
|
+
#ib-modal-body .ib-modal-title-input:hover {
|
|
132
123
|
border-color: var(--ib-input-hover-border);
|
|
133
124
|
}
|
|
134
125
|
|
|
135
126
|
#ib-modal-body #ib-title-input:focus,
|
|
136
|
-
#ib-modal-body .ib-modal-title-input:focus
|
|
137
|
-
#ib-modal-body #ib-email:focus,
|
|
138
|
-
#ib-modal-body .ib-modal-email:focus {
|
|
127
|
+
#ib-modal-body .ib-modal-title-input:focus {
|
|
139
128
|
border-color: var(--ib-focus-color);
|
|
140
129
|
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
141
130
|
}
|
|
@@ -306,7 +295,7 @@
|
|
|
306
295
|
--ib-radius: 8px;
|
|
307
296
|
--ib-radius-input: 4px;
|
|
308
297
|
}
|
|
309
|
-
`;var
|
|
298
|
+
`;var de=`/* InputBuffer Feedback Bar Styles
|
|
310
299
|
* .ib-bar-* and .ib-bar-popover* classes are stable public API \u2014 do not rename them.
|
|
311
300
|
* Developers may target these classes from their own stylesheets to customize the widget.
|
|
312
301
|
*/
|
|
@@ -414,8 +403,7 @@
|
|
|
414
403
|
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
415
404
|
}
|
|
416
405
|
|
|
417
|
-
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input
|
|
418
|
-
.ib-bar-wrapper .ib-bar-body .ib-bar-email {
|
|
406
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input {
|
|
419
407
|
width: 100%;
|
|
420
408
|
background: var(--ib-background);
|
|
421
409
|
border: 1px solid var(--ib-border);
|
|
@@ -433,17 +421,11 @@
|
|
|
433
421
|
margin-bottom: 8px;
|
|
434
422
|
}
|
|
435
423
|
|
|
436
|
-
.ib-bar-
|
|
437
|
-
margin-top: 8px;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:hover,
|
|
441
|
-
.ib-bar-wrapper .ib-bar-body .ib-bar-email:hover {
|
|
424
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:hover {
|
|
442
425
|
border-color: var(--ib-input-hover-border);
|
|
443
426
|
}
|
|
444
427
|
|
|
445
|
-
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:focus
|
|
446
|
-
.ib-bar-wrapper .ib-bar-body .ib-bar-email:focus {
|
|
428
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:focus {
|
|
447
429
|
border-color: var(--ib-focus-color);
|
|
448
430
|
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
449
431
|
}
|
|
@@ -627,4 +609,4 @@
|
|
|
627
609
|
--ib-radius: 8px;
|
|
628
610
|
--ib-radius-input: 4px;
|
|
629
611
|
}
|
|
630
|
-
`;var
|
|
612
|
+
`;var $=typeof document!="undefined"?document.currentScript:null;function Ae(){if(typeof document=="undefined"||document.getElementById("ib-modal-styles"))return;let e=document.createElement("style");e.id="ib-modal-styles",e.textContent=le,document.head.appendChild(e)}function ce(){if(typeof document=="undefined"||document.getElementById("ib-bar-styles"))return;let e=document.createElement("style");e.id="ib-bar-styles",e.textContent=de,document.head.appendChild(e)}function be(e){e.injectStyles!==!1&&Ae();let t=re(e),r=null,n=null;return e.attachTo&&(r=document.querySelector(e.attachTo),r&&(n=()=>t.open(),r.addEventListener("click",n))),{open:g=>t.open(g),close:()=>t.close(),on:(g,a)=>t.on(g,a),destroy:()=>{r&&n&&(r.removeEventListener("click",n),r=null,n=null),t.destroy()}}}function Ie(e){return e.injectStyles!==!1&&ce(),K(e)}if(typeof HTMLElement!="undefined"){class e extends HTMLElement{constructor(){super(...arguments);this._bar=null}connectedCallback(){let n=this.getAttribute("api-key");n&&(ae(this)&&ce(),this._bar=K(oe(this,n)),this.appendChild(this._bar.element))}disconnectedCallback(){var n;(n=this._bar)==null||n.destroy(),this._bar=null}}typeof customElements!="undefined"&&!customElements.get("inputbuffer-feedback")&&customElements.define("inputbuffer-feedback",e)}var ue={createModal:be,createBar:Ie,version:U};typeof window!="undefined"&&(window.InputBufferIO=ue);(function(){if(typeof window=="undefined"||!$)return;let t=$.dataset.apiKey;if(!t)return;let r=be(se($,t));ue._defaultInstance=r})();})();
|