@inputbuffer/feedback 0.1.0 → 0.1.1
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/dist/bar.css +1 -1
- package/dist/bar.esm.js +3 -5
- package/dist/bar.js +3 -5
- package/dist/modal.esm.js +1 -1
- package/dist/modal.js +1 -1
- package/dist/widget.esm.js +4 -6
- package/dist/widget.js +4 -6
- package/package.json +1 -1
package/dist/bar.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.ib-bar-wrapper{--ib-primary: #6366f1;--ib-primary-hover: #4338ca;--ib-background: #f6f6f8;--ib-surface: #ffffff;--ib-text: #111827;--ib-muted: #8d99ae;--ib-border: var(--ib-primary);--ib-focus-color: var(--ib-primary);--ib-input-hover-border: var(--ib-border);--ib-selected: var(--ib-primary);--ib-selected-color: var(--ib-surface);--ib-radius: 2px;--ib-radius-input: 2px;position:relative;display:inline-block;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}.ib-bar-wrapper--fixed{position:fixed;bottom:32px;right:32px;z-index:9998}.ib-bar{display:inline-flex;align-items:stretch;height:40px;width:100%;overflow:hidden;background-color:var(--ib-background);border:1px solid var(--ib-border);border-radius:2px;box-shadow:0 1px 4px #00000014;box-sizing:border-box}.ib-bar-popover{display:none;position:
|
|
1
|
+
.ib-bar-wrapper{--ib-primary: #6366f1;--ib-primary-hover: #4338ca;--ib-background: #f6f6f8;--ib-surface: #ffffff;--ib-text: #111827;--ib-muted: #8d99ae;--ib-border: var(--ib-primary);--ib-focus-color: var(--ib-primary);--ib-input-hover-border: var(--ib-border);--ib-selected: var(--ib-primary);--ib-selected-color: var(--ib-surface);--ib-radius: 2px;--ib-radius-input: 2px;position:relative;display:inline-block;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}.ib-bar-wrapper--fixed{position:fixed;bottom:32px;right:32px;z-index:9998}.ib-bar{display:inline-flex;align-items:stretch;height:40px;width:100%;overflow:hidden;background-color:var(--ib-background);border:1px solid var(--ib-border);border-radius:2px;box-shadow:0 1px 4px #00000014;box-sizing:border-box}.ib-bar-popover{display:none;position:fixed;width:320px;border:1px solid var(--ib-border);border-radius:var(--ib-radius);box-shadow:0 1px 3px #0000001f;box-sizing:border-box;z-index:9999;overflow:hidden}.ib-bar-popover--visible{display:block}.ib-bar-header{background:var(--ib-surface);padding:12px 16px;border-bottom:1px solid var(--ib-border)}.ib-bar-body{background:var(--ib-background);padding:16px}.ib-bar-title{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.1em;color:var(--ib-text);margin:0}.ib-bar-textarea{width:100%;background:var(--ib-background);border:1px solid var(--ib-border);border-radius:var(--ib-radius-input);padding:10px 12px;font-size:14px;font-family:inherit;color:var(--ib-text);resize:vertical;min-height:80px;box-sizing:border-box;outline:none;display:block}.ib-bar-textarea:hover{border-color:var(--ib-input-hover-border)}.ib-bar-textarea:focus{border-color:var(--ib-focus-color);box-shadow:0 0 0 2px color-mix(in srgb,var(--ib-focus-color) 15%,transparent)}.ib-bar-wrapper .ib-bar-body .ib-bar-title-input,.ib-bar-wrapper .ib-bar-body .ib-bar-email{width:100%;background:var(--ib-background);border:1px solid var(--ib-border);border-radius:var(--ib-radius-input);padding:8px 12px;font-size:14px;font-family:inherit;color:var(--ib-text);box-sizing:border-box;outline:none;display:block}.ib-bar-title-input{margin-bottom:8px}.ib-bar-email{margin-top:8px}.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:hover,.ib-bar-wrapper .ib-bar-body .ib-bar-email:hover{border-color:var(--ib-input-hover-border)}.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:focus,.ib-bar-wrapper .ib-bar-body .ib-bar-email:focus{border-color:var(--ib-focus-color);box-shadow:0 0 0 2px color-mix(in srgb,var(--ib-focus-color) 15%,transparent)}.ib-bar-submit{background:var(--ib-primary);color:#fff;border:none;border-radius:var(--ib-radius-input);padding:8px 16px;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;font-family:inherit;cursor:pointer;display:inline-block;transition:background .15s}.ib-bar-submit:hover{background:var(--ib-primary-hover)}.ib-bar-submit:disabled{opacity:.6;cursor:not-allowed}.ib-bar-footer{display:flex;align-items:center;justify-content:space-between;margin-top:10px}.ib-branding a{font-size:10px;color:var(--ib-muted);text-decoration:none;letter-spacing:.03em}.ib-branding a:hover{color:var(--ib-primary);text-decoration:underline}.ib-bar-error,.ib-bar-success{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;margin:8px 0 0}.ib-bar-error:empty,.ib-bar-success:empty{display:none}.ib-bar-error{color:#dc2626}.ib-bar-success{color:#16a34a}.ib-bar-label-area{flex:1;display:flex;align-items:center;padding:0 16px}.ib-bar-label{font-size:11px;font-weight:600;color:var(--ib-muted);text-transform:uppercase;letter-spacing:.1em;white-space:nowrap;user-select:none}.ib-bar-actions{display:flex;align-items:stretch;background:var(--ib-background);border-left:1px solid var(--ib-border)}.ib-bar-actions--no-label{border-left:none}.ib-bar-btn{width:40px;display:flex;align-items:center;justify-content:center;background:var(--ib-background);border:none;border-right:1px solid var(--ib-border);border-radius:0;color:var(--ib-primary);cursor:pointer;transition:background .15s,color .15s,transform .1s;padding:0;-webkit-appearance:none;appearance:none;box-sizing:border-box;margin:0}.ib-bar-btn--down{border-right:none}.ib-bar-btn:hover{background:var(--ib-primary);color:var(--ib-surface);transform:scale(1.15)}.ib-bar-btn:active{transform:scale(.95)}.ib-bar-btn:focus{outline:1px solid var(--ib-primary);outline-offset:-1px}.ib-bar-btn--active{background:var(--ib-selected);color:var(--ib-selected-color)}.ib-bar-btn--active:hover{background:var(--ib-primary-hover, var(--ib-primary));color:var(--ib-surface);transform:scale(1.1)}@media (prefers-color-scheme: dark){.ib-bar-wrapper:not(.ib-theme-light),.ib-bar-wrapper.ib-theme-dark{--ib-primary: #3A5244;--ib-primary-hover: #4E6857;--ib-background: #25272B;--ib-surface: #2C3630;--ib-text: #E5E7EB;--ib-muted: #9CA3AF;--ib-border: #363840;--ib-focus-color: #7B9B82;--ib-input-hover-border: rgba(255, 255, 255, .2);--ib-selected: #7B9B82;--ib-selected-color: #1a2420;--ib-radius: 8px;--ib-radius-input: 4px}}.ib-bar-wrapper.ib-theme-dark{--ib-primary: #3A5244;--ib-primary-hover: #4E6857;--ib-background: #25272B;--ib-surface: #2C3630;--ib-text: #E5E7EB;--ib-muted: #9CA3AF;--ib-border: #363840;--ib-focus-color: #7B9B82;--ib-input-hover-border: rgba(255, 255, 255, .2);--ib-selected: #7B9B82;--ib-selected-color: #1a2420;--ib-radius: 8px;--ib-radius-input: 4px}
|
package/dist/bar.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var S="0.1.
|
|
1
|
+
var S="0.1.1",U="https://inputbuffer.io/api/v0/inputs";async function M(t,o,b,s,r,h){var p;let a={description:o};if(s&&(a.title=s),b&&(a.contactEmail=b),r!=null&&r.sentiment&&(a.sentiment=r.sentiment),r!=null&&r.source&&(a.source=r.source),r!=null&&r.target){let i=r.target;a.targets=[{target_type:i.type,...i.targetId&&{target_id:i.targetId},...i.displayName&&{display_name:i.displayName},...i.dedupKey&&{dedup_key:i.dedupKey},metadata:i.metadata}]}let l=new AbortController,m=setTimeout(()=>l.abort(),1e4),c;try{c=await fetch(h!=null?h:U,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-IB-Client":`inputbuffer-widget/${S} (javascript)`},body:JSON.stringify(a),credentials:"omit",signal:l.signal})}finally{clearTimeout(m)}if(!c.ok){let i=await c.json().catch(()=>({}));throw new Error(((p=i==null?void 0:i.error)==null?void 0:p.message)||"Submission failed. Please try again.")}return c.json()}function R(t){let o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("width","18"),o.setAttribute("height","18"),o.setAttribute("fill","currentColor"),o.setAttribute("aria-hidden","true"),o.style.display="block";let b=document.createElementNS("http://www.w3.org/2000/svg","path");return b.setAttribute("d",t),o.appendChild(b),o}var $="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",q="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 _(t){var O,H;let o,b={vote:[],open:[],submit:[],close:[],error:[]};function s(e,g){var y;(y=b[e])==null||y.forEach(C=>C(g))}let r=document.createElement("div"),h=t.colorScheme==="dark"?" ib-theme-dark":t.colorScheme==="light"?" ib-theme-light":"";r.className="ib-bar-wrapper"+(t.placement==="fixed"?" ib-bar-wrapper--fixed":"")+h;let{theme:a={}}=t;a.primary&&r.style.setProperty("--ib-primary",a.primary),a.background&&r.style.setProperty("--ib-background",a.background),a.surface&&r.style.setProperty("--ib-surface",a.surface),a.text&&r.style.setProperty("--ib-text",a.text),a.selected&&r.style.setProperty("--ib-selected",a.selected),a.selectedColor&&r.style.setProperty("--ib-selected-color",a.selectedColor);let l=document.createElement("div");l.className="ib-bar";let m=document.createElement("div");m.className="ib-bar-label-area";let c=document.createElement("span");c.className="ib-bar-label",c.textContent=(O=t.label)!=null?O:"Was this helpful?",m.appendChild(c);let p=document.createElement("div");p.className="ib-bar-actions"+(t.showLabel===!1?" ib-bar-actions--no-label":"");let i=document.createElement("button");i.type="button",i.className="ib-bar-btn ib-bar-btn--up",i.setAttribute("aria-label","Yes"),i.appendChild(R($));let d=document.createElement("button");d.type="button",d.className="ib-bar-btn ib-bar-btn--down",d.setAttribute("aria-label","No"),d.appendChild(R(q)),p.appendChild(i),p.appendChild(d),t.showLabel!==!1&&l.appendChild(m),l.appendChild(p);let n=document.createElement("div");n.className="ib-bar-popover",n.setAttribute("role","dialog"),n.setAttribute("aria-modal","false");let N=document.createElement("div");if(N.className="ib-bar-header",t.modalTitle){n.setAttribute("aria-labelledby","ib-bar-title");let e=document.createElement("p");e.id="ib-bar-title",e.className="ib-bar-title",e.textContent=t.modalTitle,N.appendChild(e)}else n.setAttribute("aria-label","Feedback");let f=document.createElement("div");f.className="ib-bar-body";let v=document.createElement("textarea");v.className="ib-bar-textarea",v.placeholder=(H=t.modalPlaceholder)!=null?H:"What's on your mind?",v.setAttribute("aria-label","Feedback");let x=document.createElement("p");x.className="ib-bar-error";let B=document.createElement("p");B.className="ib-bar-success";let u=document.createElement("button");if(u.type="button",u.className="ib-bar-submit",u.textContent="Send feedback",t.showTitleField===!0){let e=document.createElement("input");e.type="text",e.className="ib-bar-title-input",e.placeholder="Title (optional)",e.setAttribute("aria-label","Feedback title"),f.appendChild(e)}if(f.appendChild(v),t.showEmailField===!0){let e=document.createElement("input");e.type="email",e.className="ib-bar-email",e.placeholder="Your email (optional)",e.setAttribute("aria-label","Email address"),f.appendChild(e)}f.appendChild(x),f.appendChild(B);let A=document.createElement("div");A.className="ib-bar-footer",A.appendChild(u);let I=document.createElement("div");I.className="ib-branding";let w=document.createElement("a");w.href="https://inputbuffer.io",w.target="_blank",w.rel="noopener noreferrer",w.textContent="Powered by inputbuffer.io",I.appendChild(w),A.appendChild(I),f.appendChild(A),n.appendChild(N),n.appendChild(f),r.appendChild(n),r.appendChild(l);function E(){let e=l.getBoundingClientRect();n.style.top=`${e.top-n.offsetHeight-8}px`,n.style.left=`${e.right-320}px`}function z(e){o=e,n.classList.add("ib-bar-popover--visible"),requestAnimationFrame(E),x.textContent="",B.textContent="",v.focus(),setTimeout(()=>document.addEventListener("click",T),0),document.addEventListener("keydown",P),window.addEventListener("scroll",E,{passive:!0}),window.addEventListener("resize",E,{passive:!0}),s("open",{sentiment:e})}function L(){n.classList.contains("ib-bar-popover--visible")&&(n.classList.remove("ib-bar-popover--visible"),document.removeEventListener("click",T),document.removeEventListener("keydown",P),window.removeEventListener("scroll",E),window.removeEventListener("resize",E),v.value="",s("close"))}function W(){i.classList.remove("ib-bar-btn--active"),d.classList.remove("ib-bar-btn--active"),o=void 0}function T(e){r.contains(e.target)||L()}function P(e){e.key==="Escape"&&L()}async function K(){let e=v.value.trim();if(e.length<10){x.textContent="Please enter at least 10 characters.";return}x.textContent="",u.disabled=!0,u.textContent="Sending\u2026";let g=n.querySelector(".ib-bar-title-input"),y=(g==null?void 0:g.value.trim())||null,C=n.querySelector(".ib-bar-email"),G=(C==null?void 0:C.value.trim())||null;try{let k=await M(t.apiKey,e,G,y,{sentiment:o,target:t.target,source:t.source},t.apiUrl);s("submit",k),B.textContent="Thanks for your feedback!",u.textContent="Send feedback",setTimeout(()=>{L(),W()},2e3)}catch(k){s("error",k instanceof Error?k:new Error("Something went wrong.")),x.textContent=k instanceof Error?k.message:"Something went wrong.",u.disabled=!1,u.textContent="Send feedback"}}function j(e){i.classList.remove("ib-bar-btn--active"),d.classList.remove("ib-bar-btn--active"),e.classList.add("ib-bar-btn--active")}return i.addEventListener("click",()=>{s("vote",{sentiment:"positive"}),j(i),z("positive")}),d.addEventListener("click",()=>{s("vote",{sentiment:"negative"}),j(d),z("negative")}),u.addEventListener("click",K),{element:r,on(e,g){var y;(y=b[e])==null||y.push(g)},destroy(){L(),r.remove()}}}var D=`/* InputBuffer Feedback Bar Styles
|
|
2
2
|
* .ib-bar-* and .ib-bar-popover* classes are stable public API \u2014 do not rename them.
|
|
3
3
|
* Developers may target these classes from their own stylesheets to customize the widget.
|
|
4
4
|
*/
|
|
@@ -46,9 +46,7 @@ var S="0.1.0",G="https://inputbuffer.io/api/v0/inputs";async function M(t,n,o,s,
|
|
|
46
46
|
|
|
47
47
|
.ib-bar-popover {
|
|
48
48
|
display: none;
|
|
49
|
-
position:
|
|
50
|
-
bottom: calc(100% + 8px);
|
|
51
|
-
right: 0;
|
|
49
|
+
position: fixed;
|
|
52
50
|
width: 320px;
|
|
53
51
|
|
|
54
52
|
border: 1px solid var(--ib-border);
|
|
@@ -321,4 +319,4 @@ var S="0.1.0",G="https://inputbuffer.io/api/v0/inputs";async function M(t,n,o,s,
|
|
|
321
319
|
--ib-radius: 8px;
|
|
322
320
|
--ib-radius-input: 4px;
|
|
323
321
|
}
|
|
324
|
-
`;function
|
|
322
|
+
`;function V(){if(typeof document=="undefined"||document.getElementById("ib-bar-styles"))return;let t=document.createElement("style");t.id="ib-bar-styles",t.textContent=D,document.head.appendChild(t)}function J(t){return t.injectStyles!==!1&&V(),_(t)}var F=class extends HTMLElement{constructor(){super(...arguments);this._bar=null}connectedCallback(){var a,l,m,c,p,i,d;let b=this.getAttribute("api-key");if(!b)return;let s=this.getAttribute("inject-styles");(s===null?!0:s!=="false")&&V();let h=this.getAttribute("placement");this._bar=_({apiKey:b,apiUrl:(a=this.getAttribute("api-url"))!=null?a:void 0,label:(l=this.getAttribute("label"))!=null?l:void 0,placement:h==="fixed"?"fixed":"inline",theme:{primary:(m=this.getAttribute("theme-primary"))!=null?m:void 0,background:(c=this.getAttribute("theme-background"))!=null?c:void 0,text:(p=this.getAttribute("theme-text"))!=null?p:void 0,selected:(i=this.getAttribute("theme-selected"))!=null?i:void 0,selectedColor:(d=this.getAttribute("theme-selected-color"))!=null?d:void 0}}),this.appendChild(this._bar.element)}disconnectedCallback(){var b;(b=this._bar)==null||b.destroy(),this._bar=null}};typeof customElements!="undefined"&&!customElements.get("inputbuffer-feedback")&&customElements.define("inputbuffer-feedback",F);var X={createBar:J,version:S};typeof window!="undefined"&&(window.InputBufferIO=X);export{X as InputBufferIO,J as createBar};
|
package/dist/bar.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{var S="0.1.
|
|
1
|
+
"use strict";(()=>{var S="0.1.1",U="https://inputbuffer.io/api/v0/inputs";async function M(t,o,b,s,r,h){var p;let a={description:o};if(s&&(a.title=s),b&&(a.contactEmail=b),r!=null&&r.sentiment&&(a.sentiment=r.sentiment),r!=null&&r.source&&(a.source=r.source),r!=null&&r.target){let i=r.target;a.targets=[{target_type:i.type,...i.targetId&&{target_id:i.targetId},...i.displayName&&{display_name:i.displayName},...i.dedupKey&&{dedup_key:i.dedupKey},metadata:i.metadata}]}let l=new AbortController,m=setTimeout(()=>l.abort(),1e4),c;try{c=await fetch(h!=null?h:U,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-IB-Client":`inputbuffer-widget/${S} (javascript)`},body:JSON.stringify(a),credentials:"omit",signal:l.signal})}finally{clearTimeout(m)}if(!c.ok){let i=await c.json().catch(()=>({}));throw new Error(((p=i==null?void 0:i.error)==null?void 0:p.message)||"Submission failed. Please try again.")}return c.json()}function R(t){let o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("width","18"),o.setAttribute("height","18"),o.setAttribute("fill","currentColor"),o.setAttribute("aria-hidden","true"),o.style.display="block";let b=document.createElementNS("http://www.w3.org/2000/svg","path");return b.setAttribute("d",t),o.appendChild(b),o}var $="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",q="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 _(t){var O,H;let o,b={vote:[],open:[],submit:[],close:[],error:[]};function s(e,g){var y;(y=b[e])==null||y.forEach(C=>C(g))}let r=document.createElement("div"),h=t.colorScheme==="dark"?" ib-theme-dark":t.colorScheme==="light"?" ib-theme-light":"";r.className="ib-bar-wrapper"+(t.placement==="fixed"?" ib-bar-wrapper--fixed":"")+h;let{theme:a={}}=t;a.primary&&r.style.setProperty("--ib-primary",a.primary),a.background&&r.style.setProperty("--ib-background",a.background),a.surface&&r.style.setProperty("--ib-surface",a.surface),a.text&&r.style.setProperty("--ib-text",a.text),a.selected&&r.style.setProperty("--ib-selected",a.selected),a.selectedColor&&r.style.setProperty("--ib-selected-color",a.selectedColor);let l=document.createElement("div");l.className="ib-bar";let m=document.createElement("div");m.className="ib-bar-label-area";let c=document.createElement("span");c.className="ib-bar-label",c.textContent=(O=t.label)!=null?O:"Was this helpful?",m.appendChild(c);let p=document.createElement("div");p.className="ib-bar-actions"+(t.showLabel===!1?" ib-bar-actions--no-label":"");let i=document.createElement("button");i.type="button",i.className="ib-bar-btn ib-bar-btn--up",i.setAttribute("aria-label","Yes"),i.appendChild(R($));let d=document.createElement("button");d.type="button",d.className="ib-bar-btn ib-bar-btn--down",d.setAttribute("aria-label","No"),d.appendChild(R(q)),p.appendChild(i),p.appendChild(d),t.showLabel!==!1&&l.appendChild(m),l.appendChild(p);let n=document.createElement("div");n.className="ib-bar-popover",n.setAttribute("role","dialog"),n.setAttribute("aria-modal","false");let N=document.createElement("div");if(N.className="ib-bar-header",t.modalTitle){n.setAttribute("aria-labelledby","ib-bar-title");let e=document.createElement("p");e.id="ib-bar-title",e.className="ib-bar-title",e.textContent=t.modalTitle,N.appendChild(e)}else n.setAttribute("aria-label","Feedback");let f=document.createElement("div");f.className="ib-bar-body";let v=document.createElement("textarea");v.className="ib-bar-textarea",v.placeholder=(H=t.modalPlaceholder)!=null?H:"What's on your mind?",v.setAttribute("aria-label","Feedback");let x=document.createElement("p");x.className="ib-bar-error";let B=document.createElement("p");B.className="ib-bar-success";let u=document.createElement("button");if(u.type="button",u.className="ib-bar-submit",u.textContent="Send feedback",t.showTitleField===!0){let e=document.createElement("input");e.type="text",e.className="ib-bar-title-input",e.placeholder="Title (optional)",e.setAttribute("aria-label","Feedback title"),f.appendChild(e)}if(f.appendChild(v),t.showEmailField===!0){let e=document.createElement("input");e.type="email",e.className="ib-bar-email",e.placeholder="Your email (optional)",e.setAttribute("aria-label","Email address"),f.appendChild(e)}f.appendChild(x),f.appendChild(B);let A=document.createElement("div");A.className="ib-bar-footer",A.appendChild(u);let I=document.createElement("div");I.className="ib-branding";let w=document.createElement("a");w.href="https://inputbuffer.io",w.target="_blank",w.rel="noopener noreferrer",w.textContent="Powered by inputbuffer.io",I.appendChild(w),A.appendChild(I),f.appendChild(A),n.appendChild(N),n.appendChild(f),r.appendChild(n),r.appendChild(l);function E(){let e=l.getBoundingClientRect();n.style.top=`${e.top-n.offsetHeight-8}px`,n.style.left=`${e.right-320}px`}function z(e){o=e,n.classList.add("ib-bar-popover--visible"),requestAnimationFrame(E),x.textContent="",B.textContent="",v.focus(),setTimeout(()=>document.addEventListener("click",T),0),document.addEventListener("keydown",P),window.addEventListener("scroll",E,{passive:!0}),window.addEventListener("resize",E,{passive:!0}),s("open",{sentiment:e})}function L(){n.classList.contains("ib-bar-popover--visible")&&(n.classList.remove("ib-bar-popover--visible"),document.removeEventListener("click",T),document.removeEventListener("keydown",P),window.removeEventListener("scroll",E),window.removeEventListener("resize",E),v.value="",s("close"))}function W(){i.classList.remove("ib-bar-btn--active"),d.classList.remove("ib-bar-btn--active"),o=void 0}function T(e){r.contains(e.target)||L()}function P(e){e.key==="Escape"&&L()}async function K(){let e=v.value.trim();if(e.length<10){x.textContent="Please enter at least 10 characters.";return}x.textContent="",u.disabled=!0,u.textContent="Sending\u2026";let g=n.querySelector(".ib-bar-title-input"),y=(g==null?void 0:g.value.trim())||null,C=n.querySelector(".ib-bar-email"),G=(C==null?void 0:C.value.trim())||null;try{let k=await M(t.apiKey,e,G,y,{sentiment:o,target:t.target,source:t.source},t.apiUrl);s("submit",k),B.textContent="Thanks for your feedback!",u.textContent="Send feedback",setTimeout(()=>{L(),W()},2e3)}catch(k){s("error",k instanceof Error?k:new Error("Something went wrong.")),x.textContent=k instanceof Error?k.message:"Something went wrong.",u.disabled=!1,u.textContent="Send feedback"}}function j(e){i.classList.remove("ib-bar-btn--active"),d.classList.remove("ib-bar-btn--active"),e.classList.add("ib-bar-btn--active")}return i.addEventListener("click",()=>{s("vote",{sentiment:"positive"}),j(i),z("positive")}),d.addEventListener("click",()=>{s("vote",{sentiment:"negative"}),j(d),z("negative")}),u.addEventListener("click",K),{element:r,on(e,g){var y;(y=b[e])==null||y.push(g)},destroy(){L(),r.remove()}}}var D=`/* InputBuffer Feedback Bar Styles
|
|
2
2
|
* .ib-bar-* and .ib-bar-popover* classes are stable public API \u2014 do not rename them.
|
|
3
3
|
* Developers may target these classes from their own stylesheets to customize the widget.
|
|
4
4
|
*/
|
|
@@ -46,9 +46,7 @@
|
|
|
46
46
|
|
|
47
47
|
.ib-bar-popover {
|
|
48
48
|
display: none;
|
|
49
|
-
position:
|
|
50
|
-
bottom: calc(100% + 8px);
|
|
51
|
-
right: 0;
|
|
49
|
+
position: fixed;
|
|
52
50
|
width: 320px;
|
|
53
51
|
|
|
54
52
|
border: 1px solid var(--ib-border);
|
|
@@ -321,4 +319,4 @@
|
|
|
321
319
|
--ib-radius: 8px;
|
|
322
320
|
--ib-radius-input: 4px;
|
|
323
321
|
}
|
|
324
|
-
`;function
|
|
322
|
+
`;function V(){if(typeof document=="undefined"||document.getElementById("ib-bar-styles"))return;let t=document.createElement("style");t.id="ib-bar-styles",t.textContent=D,document.head.appendChild(t)}function J(t){return t.injectStyles!==!1&&V(),_(t)}var F=class extends HTMLElement{constructor(){super(...arguments);this._bar=null}connectedCallback(){var a,l,m,c,p,i,d;let b=this.getAttribute("api-key");if(!b)return;let s=this.getAttribute("inject-styles");(s===null?!0:s!=="false")&&V();let h=this.getAttribute("placement");this._bar=_({apiKey:b,apiUrl:(a=this.getAttribute("api-url"))!=null?a:void 0,label:(l=this.getAttribute("label"))!=null?l:void 0,placement:h==="fixed"?"fixed":"inline",theme:{primary:(m=this.getAttribute("theme-primary"))!=null?m:void 0,background:(c=this.getAttribute("theme-background"))!=null?c:void 0,text:(p=this.getAttribute("theme-text"))!=null?p:void 0,selected:(i=this.getAttribute("theme-selected"))!=null?i:void 0,selectedColor:(d=this.getAttribute("theme-selected-color"))!=null?d:void 0}}),this.appendChild(this._bar.element)}disconnectedCallback(){var b;(b=this._bar)==null||b.destroy(),this._bar=null}};typeof customElements!="undefined"&&!customElements.get("inputbuffer-feedback")&&customElements.define("inputbuffer-feedback",F);var X={createBar:J,version:S};typeof window!="undefined"&&(window.InputBufferIO=X);})();
|
package/dist/modal.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function B(a){let i=document.getElementById("ib-modal");if(!i)return;let{theme:e={}}=a;e.primary&&i.style.setProperty("--ib-primary",e.primary),e.background&&i.style.setProperty("--ib-background",e.background),e.surface&&i.style.setProperty("--ib-surface",e.surface),e.text&&i.style.setProperty("--ib-text",e.text),e.selected&&i.style.setProperty("--ib-selected",e.selected),e.selectedColor&&i.style.setProperty("--ib-selected-color",e.selectedColor)}var L="0.1.
|
|
1
|
+
function B(a){let i=document.getElementById("ib-modal");if(!i)return;let{theme:e={}}=a;e.primary&&i.style.setProperty("--ib-primary",e.primary),e.background&&i.style.setProperty("--ib-background",e.background),e.surface&&i.style.setProperty("--ib-surface",e.surface),e.text&&i.style.setProperty("--ib-text",e.text),e.selected&&i.style.setProperty("--ib-selected",e.selected),e.selectedColor&&i.style.setProperty("--ib-selected-color",e.selectedColor)}var L="0.1.1",V="https://inputbuffer.io/api/v0/inputs";async function N(a,i,e,b,n,s){var y;let m={description:i};if(b&&(m.title=b),e&&(m.contactEmail=e),n!=null&&n.sentiment&&(m.sentiment=n.sentiment),n!=null&&n.source&&(m.source=n.source),n!=null&&n.target){let l=n.target;m.targets=[{target_type:l.type,...l.targetId&&{target_id:l.targetId},...l.displayName&&{display_name:l.displayName},...l.dedupKey&&{dedup_key:l.dedupKey},metadata:l.metadata}]}let u=new AbortController,h=setTimeout(()=>u.abort(),1e4),c;try{c=await fetch(s!=null?s:V,{method:"POST",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json","X-IB-Client":`inputbuffer-widget/${L} (javascript)`},body:JSON.stringify(m),credentials:"omit",signal:u.signal})}finally{clearTimeout(h)}if(!c.ok){let l=await c.json().catch(()=>({}));throw new Error(((y=l==null?void 0:l.error)==null?void 0:y.message)||"Submission failed. Please try again.")}return c.json()}function z(a){let i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("width","18"),i.setAttribute("height","18"),i.setAttribute("fill","currentColor"),i.setAttribute("aria-hidden","true"),i.style.display="block";let e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d",a),i.appendChild(e),i}var U="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",_="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 S(a){let i=null,e,b,n=null,s=null,m=null,u=null,h=null,c=null,y=null,l=null,w=null,H=[],A=[],I=[];function M(t){if(t.key==="Escape"){k();return}if(t.key==="Tab"&&i){let o=Array.from(i.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(o.length===0)return;let f=o[0],d=o[o.length-1];t.shiftKey?document.activeElement===f&&(t.preventDefault(),d.focus()):document.activeElement===d&&(t.preventDefault(),f.focus())}}async function W(){var o,f;if(!s||!h)return;let t=s.value.trim();if(t.length<10){c&&(c.textContent="Please enter at least 10 characters.",c.style.display="block");return}c&&(c.style.display="none"),h.disabled=!0,h.textContent="Sending\u2026";try{let d=(u==null?void 0:u.value.trim())||((o=e==null?void 0:e.prefill)==null?void 0:o.email)||null,p=(m==null?void 0:m.value.trim())||null,x=b!=null?b:e==null?void 0:e.sentiment,C=await N(a.apiKey,t,d||null,p,{...e,sentiment:x,source:(f=e==null?void 0:e.source)!=null?f:a.source},a.apiUrl);y&&(y.textContent="Thanks for your feedback!",y.style.display="block"),H.forEach(E=>E(C)),n=setTimeout(()=>k(),2e3)}catch(d){let p=d instanceof Error?d:new Error("Unknown error");c&&(c.textContent="Something went wrong. Please try again.",c.style.display="block"),I.forEach(x=>x(p)),h.disabled=!1,h.textContent="Send feedback"}}function D(){let t=document.createElement("div");t.id="ib-overlay";let o=document.createElement("div");o.id="ib-modal",a.colorScheme==="dark"?o.classList.add("ib-theme-dark"):a.colorScheme==="light"&&o.classList.add("ib-theme-light"),o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true");let f=document.createElement("div");if(f.id="ib-modal-header",w=f,a.title?(o.setAttribute("aria-labelledby","ib-title"),l=document.createElement("h2"),l.id="ib-title",l.className="ib-modal-title",l.textContent=a.title,f.appendChild(l)):o.setAttribute("aria-label","Feedback"),a.showSentiment){let v,g,T=document.createElement("div");T.className="ib-modal-sentiment",v=document.createElement("button"),v.type="button",v.className="ib-modal-thumb ib-modal-thumb--up",v.setAttribute("aria-label","Helpful"),v.appendChild(z(U)),g=document.createElement("button"),g.type="button",g.className="ib-modal-thumb ib-modal-thumb--down",g.setAttribute("aria-label","Not helpful"),g.appendChild(z(_)),v.addEventListener("click",()=>{v.classList.add("ib-modal-thumb--active"),g.classList.remove("ib-modal-thumb--active"),b="positive"}),g.addEventListener("click",()=>{g.classList.add("ib-modal-thumb--active"),v.classList.remove("ib-modal-thumb--active"),b="negative"}),T.appendChild(v),T.appendChild(g),f.appendChild(T)}let d=document.createElement("button");d.id="ib-close",d.className="ib-modal-close",d.textContent="\xD7",d.setAttribute("aria-label","Close feedback form"),d.addEventListener("click",k),f.appendChild(d);let p=document.createElement("div");p.id="ib-modal-body",s=document.createElement("textarea"),s.id="ib-textarea",s.className="ib-modal-textarea",s.placeholder=a.placeholder||"What's on your mind?",s.setAttribute("aria-label","Feedback"),h=document.createElement("button"),h.id="ib-submit",h.className="ib-modal-submit",h.textContent="Send feedback",h.addEventListener("click",W),y=document.createElement("p"),y.id="ib-success",y.className="ib-modal-success",c=document.createElement("p"),c.id="ib-error",c.className="ib-modal-error",a.showTitleField===!0&&(m=document.createElement("input"),m.id="ib-title-input",m.className="ib-modal-title-input",m.type="text",m.placeholder="Title (optional)",m.setAttribute("aria-label","Feedback title"),p.appendChild(m)),p.appendChild(s),a.showEmailField===!0&&(u=document.createElement("input"),u.id="ib-email",u.className="ib-modal-email",u.type="email",u.placeholder="Your email (optional)",u.setAttribute("aria-label","Email address"),p.appendChild(u)),p.appendChild(c),p.appendChild(y);let x=document.createElement("div");x.className="ib-modal-footer",x.appendChild(h);let C=document.createElement("div");C.className="ib-branding";let E=document.createElement("a");return E.href="https://inputbuffer.io",E.target="_blank",E.rel="noopener noreferrer",E.textContent="Powered by inputbuffer.io",C.appendChild(E),x.appendChild(C),p.appendChild(x),o.appendChild(f),o.appendChild(p),t.appendChild(o),t.addEventListener("click",v=>{v.target===t&&k()}),document.addEventListener("keydown",M),t}function F(t){var o,f;if(!i){if(e=t,i=D(),document.body.appendChild(i),B(a),t!=null&&t.title){if(l)l.textContent=t.title;else if(w){let d=i.querySelector("#ib-modal");d.removeAttribute("aria-label"),d.setAttribute("aria-labelledby","ib-title"),l=document.createElement("h2"),l.id="ib-title",l.className="ib-modal-title",l.textContent=t.title,w.prepend(l)}}if(t!=null&&t.sentiment){b=t.sentiment;let d=i.querySelector(".ib-modal-thumb--up"),p=i.querySelector(".ib-modal-thumb--down");t.sentiment==="positive"?d==null||d.classList.add("ib-modal-thumb--active"):t.sentiment==="negative"&&(p==null||p.classList.add("ib-modal-thumb--active"))}s&&((o=t==null?void 0:t.prefill)!=null&&o.description)&&(s.value=t.prefill.description),u&&((f=t==null?void 0:t.prefill)!=null&&f.email)&&(u.value=t.prefill.email),s==null||s.focus()}}function k(){i&&(n!==null&&(clearTimeout(n),n=null),document.removeEventListener("keydown",M),i.remove(),i=null,s=null,m=null,u=null,h=null,c=null,y=null,l=null,w=null,e=void 0,b=void 0,A.forEach(t=>t()))}function R(t,o){t==="submit"?H.push(o):t==="close"?A.push(o):t==="error"&&I.push(o)}function K(){k()}return{open:F,close:k,on:R,destroy:K}}var O=`/* 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
|
*/
|
package/dist/modal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{function B(a){let i=document.getElementById("ib-modal");if(!i)return;let{theme:e={}}=a;e.primary&&i.style.setProperty("--ib-primary",e.primary),e.background&&i.style.setProperty("--ib-background",e.background),e.surface&&i.style.setProperty("--ib-surface",e.surface),e.text&&i.style.setProperty("--ib-text",e.text),e.selected&&i.style.setProperty("--ib-selected",e.selected),e.selectedColor&&i.style.setProperty("--ib-selected-color",e.selectedColor)}var L="0.1.
|
|
1
|
+
"use strict";(()=>{function B(a){let i=document.getElementById("ib-modal");if(!i)return;let{theme:e={}}=a;e.primary&&i.style.setProperty("--ib-primary",e.primary),e.background&&i.style.setProperty("--ib-background",e.background),e.surface&&i.style.setProperty("--ib-surface",e.surface),e.text&&i.style.setProperty("--ib-text",e.text),e.selected&&i.style.setProperty("--ib-selected",e.selected),e.selectedColor&&i.style.setProperty("--ib-selected-color",e.selectedColor)}var L="0.1.1",V="https://inputbuffer.io/api/v0/inputs";async function N(a,i,e,b,n,s){var y;let m={description:i};if(b&&(m.title=b),e&&(m.contactEmail=e),n!=null&&n.sentiment&&(m.sentiment=n.sentiment),n!=null&&n.source&&(m.source=n.source),n!=null&&n.target){let l=n.target;m.targets=[{target_type:l.type,...l.targetId&&{target_id:l.targetId},...l.displayName&&{display_name:l.displayName},...l.dedupKey&&{dedup_key:l.dedupKey},metadata:l.metadata}]}let u=new AbortController,h=setTimeout(()=>u.abort(),1e4),c;try{c=await fetch(s!=null?s:V,{method:"POST",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json","X-IB-Client":`inputbuffer-widget/${L} (javascript)`},body:JSON.stringify(m),credentials:"omit",signal:u.signal})}finally{clearTimeout(h)}if(!c.ok){let l=await c.json().catch(()=>({}));throw new Error(((y=l==null?void 0:l.error)==null?void 0:y.message)||"Submission failed. Please try again.")}return c.json()}function z(a){let i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("width","18"),i.setAttribute("height","18"),i.setAttribute("fill","currentColor"),i.setAttribute("aria-hidden","true"),i.style.display="block";let e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d",a),i.appendChild(e),i}var U="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",_="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 S(a){let i=null,e,b,n=null,s=null,m=null,u=null,h=null,c=null,y=null,l=null,w=null,H=[],A=[],I=[];function M(t){if(t.key==="Escape"){k();return}if(t.key==="Tab"&&i){let o=Array.from(i.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(o.length===0)return;let f=o[0],d=o[o.length-1];t.shiftKey?document.activeElement===f&&(t.preventDefault(),d.focus()):document.activeElement===d&&(t.preventDefault(),f.focus())}}async function W(){var o,f;if(!s||!h)return;let t=s.value.trim();if(t.length<10){c&&(c.textContent="Please enter at least 10 characters.",c.style.display="block");return}c&&(c.style.display="none"),h.disabled=!0,h.textContent="Sending\u2026";try{let d=(u==null?void 0:u.value.trim())||((o=e==null?void 0:e.prefill)==null?void 0:o.email)||null,p=(m==null?void 0:m.value.trim())||null,x=b!=null?b:e==null?void 0:e.sentiment,C=await N(a.apiKey,t,d||null,p,{...e,sentiment:x,source:(f=e==null?void 0:e.source)!=null?f:a.source},a.apiUrl);y&&(y.textContent="Thanks for your feedback!",y.style.display="block"),H.forEach(E=>E(C)),n=setTimeout(()=>k(),2e3)}catch(d){let p=d instanceof Error?d:new Error("Unknown error");c&&(c.textContent="Something went wrong. Please try again.",c.style.display="block"),I.forEach(x=>x(p)),h.disabled=!1,h.textContent="Send feedback"}}function D(){let t=document.createElement("div");t.id="ib-overlay";let o=document.createElement("div");o.id="ib-modal",a.colorScheme==="dark"?o.classList.add("ib-theme-dark"):a.colorScheme==="light"&&o.classList.add("ib-theme-light"),o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true");let f=document.createElement("div");if(f.id="ib-modal-header",w=f,a.title?(o.setAttribute("aria-labelledby","ib-title"),l=document.createElement("h2"),l.id="ib-title",l.className="ib-modal-title",l.textContent=a.title,f.appendChild(l)):o.setAttribute("aria-label","Feedback"),a.showSentiment){let v,g,T=document.createElement("div");T.className="ib-modal-sentiment",v=document.createElement("button"),v.type="button",v.className="ib-modal-thumb ib-modal-thumb--up",v.setAttribute("aria-label","Helpful"),v.appendChild(z(U)),g=document.createElement("button"),g.type="button",g.className="ib-modal-thumb ib-modal-thumb--down",g.setAttribute("aria-label","Not helpful"),g.appendChild(z(_)),v.addEventListener("click",()=>{v.classList.add("ib-modal-thumb--active"),g.classList.remove("ib-modal-thumb--active"),b="positive"}),g.addEventListener("click",()=>{g.classList.add("ib-modal-thumb--active"),v.classList.remove("ib-modal-thumb--active"),b="negative"}),T.appendChild(v),T.appendChild(g),f.appendChild(T)}let d=document.createElement("button");d.id="ib-close",d.className="ib-modal-close",d.textContent="\xD7",d.setAttribute("aria-label","Close feedback form"),d.addEventListener("click",k),f.appendChild(d);let p=document.createElement("div");p.id="ib-modal-body",s=document.createElement("textarea"),s.id="ib-textarea",s.className="ib-modal-textarea",s.placeholder=a.placeholder||"What's on your mind?",s.setAttribute("aria-label","Feedback"),h=document.createElement("button"),h.id="ib-submit",h.className="ib-modal-submit",h.textContent="Send feedback",h.addEventListener("click",W),y=document.createElement("p"),y.id="ib-success",y.className="ib-modal-success",c=document.createElement("p"),c.id="ib-error",c.className="ib-modal-error",a.showTitleField===!0&&(m=document.createElement("input"),m.id="ib-title-input",m.className="ib-modal-title-input",m.type="text",m.placeholder="Title (optional)",m.setAttribute("aria-label","Feedback title"),p.appendChild(m)),p.appendChild(s),a.showEmailField===!0&&(u=document.createElement("input"),u.id="ib-email",u.className="ib-modal-email",u.type="email",u.placeholder="Your email (optional)",u.setAttribute("aria-label","Email address"),p.appendChild(u)),p.appendChild(c),p.appendChild(y);let x=document.createElement("div");x.className="ib-modal-footer",x.appendChild(h);let C=document.createElement("div");C.className="ib-branding";let E=document.createElement("a");return E.href="https://inputbuffer.io",E.target="_blank",E.rel="noopener noreferrer",E.textContent="Powered by inputbuffer.io",C.appendChild(E),x.appendChild(C),p.appendChild(x),o.appendChild(f),o.appendChild(p),t.appendChild(o),t.addEventListener("click",v=>{v.target===t&&k()}),document.addEventListener("keydown",M),t}function F(t){var o,f;if(!i){if(e=t,i=D(),document.body.appendChild(i),B(a),t!=null&&t.title){if(l)l.textContent=t.title;else if(w){let d=i.querySelector("#ib-modal");d.removeAttribute("aria-label"),d.setAttribute("aria-labelledby","ib-title"),l=document.createElement("h2"),l.id="ib-title",l.className="ib-modal-title",l.textContent=t.title,w.prepend(l)}}if(t!=null&&t.sentiment){b=t.sentiment;let d=i.querySelector(".ib-modal-thumb--up"),p=i.querySelector(".ib-modal-thumb--down");t.sentiment==="positive"?d==null||d.classList.add("ib-modal-thumb--active"):t.sentiment==="negative"&&(p==null||p.classList.add("ib-modal-thumb--active"))}s&&((o=t==null?void 0:t.prefill)!=null&&o.description)&&(s.value=t.prefill.description),u&&((f=t==null?void 0:t.prefill)!=null&&f.email)&&(u.value=t.prefill.email),s==null||s.focus()}}function k(){i&&(n!==null&&(clearTimeout(n),n=null),document.removeEventListener("keydown",M),i.remove(),i=null,s=null,m=null,u=null,h=null,c=null,y=null,l=null,w=null,e=void 0,b=void 0,A.forEach(t=>t()))}function R(t,o){t==="submit"?H.push(o):t==="close"?A.push(o):t==="error"&&I.push(o)}function K(){k()}return{open:F,close:k,on:R,destroy:K}}var O=`/* 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
|
*/
|
package/dist/widget.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function R(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 W="0.1.0",X="https://inputbuffer.io/api/v0/inputs";async function j(e,t,r,d,o,p){var h;let l={description:t};if(d&&(l.title=d),r&&(l.contactEmail=r),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 u=new AbortController,f=setTimeout(()=>u.abort(),1e4),c;try{c=await fetch(p!=null?p:X,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-IB-Client":`inputbuffer-widget/${W} (javascript)`},body:JSON.stringify(l),credentials:"omit",signal:u.signal})}finally{clearTimeout(f)}if(!c.ok){let n=await c.json().catch(()=>({}));throw new Error(((h=n==null?void 0:n.error)==null?void 0:h.message)||"Submission failed. Please try again.")}return c.json()}function K(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 Q="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",Z="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 U(e){let t=null,r,d,o=null,p=null,l=null,u=null,f=null,c=null,h=null,n=null,g=null,v=[],z=[],C=[];function B(i){if(i.key==="Escape"){L();return}if(i.key==="Tab"&&t){let b=Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(b.length===0)return;let x=b[0],m=b[b.length-1];i.shiftKey?document.activeElement===x&&(i.preventDefault(),m.focus()):document.activeElement===m&&(i.preventDefault(),x.focus())}}async function H(){var b,x;if(!p||!f)return;let i=p.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"),f.disabled=!0,f.textContent="Sending\u2026";try{let m=(u==null?void 0:u.value.trim())||((b=r==null?void 0:r.prefill)==null?void 0:b.email)||null,y=(l==null?void 0:l.value.trim())||null,A=d!=null?d:r==null?void 0:r.sentiment,I=await j(e.apiKey,i,m||null,y,{...r,sentiment:A,source:(x=r==null?void 0:r.source)!=null?x:e.source},e.apiUrl);h&&(h.textContent="Thanks for your feedback!",h.style.display="block"),v.forEach(T=>T(I)),o=setTimeout(()=>L(),2e3)}catch(m){let y=m instanceof Error?m:new Error("Unknown error");c&&(c.textContent="Something went wrong. Please try again.",c.style.display="block"),C.forEach(A=>A(y)),f.disabled=!1,f.textContent="Send feedback"}}function S(){let i=document.createElement("div");i.id="ib-overlay";let b=document.createElement("div");b.id="ib-modal",e.colorScheme==="dark"?b.classList.add("ib-theme-dark"):e.colorScheme==="light"&&b.classList.add("ib-theme-light"),b.setAttribute("role","dialog"),b.setAttribute("aria-modal","true");let x=document.createElement("div");if(x.id="ib-modal-header",g=x,e.title?(b.setAttribute("aria-labelledby","ib-title"),n=document.createElement("h2"),n.id="ib-title",n.className="ib-modal-title",n.textContent=e.title,x.appendChild(n)):b.setAttribute("aria-label","Feedback"),e.showSentiment){let k,a,w=document.createElement("div");w.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(K(Q)),a=document.createElement("button"),a.type="button",a.className="ib-modal-thumb ib-modal-thumb--down",a.setAttribute("aria-label","Not helpful"),a.appendChild(K(Z)),k.addEventListener("click",()=>{k.classList.add("ib-modal-thumb--active"),a.classList.remove("ib-modal-thumb--active"),d="positive"}),a.addEventListener("click",()=>{a.classList.add("ib-modal-thumb--active"),k.classList.remove("ib-modal-thumb--active"),d="negative"}),w.appendChild(k),w.appendChild(a),x.appendChild(w)}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",L),x.appendChild(m);let y=document.createElement("div");y.id="ib-modal-body",p=document.createElement("textarea"),p.id="ib-textarea",p.className="ib-modal-textarea",p.placeholder=e.placeholder||"What's on your mind?",p.setAttribute("aria-label","Feedback"),f=document.createElement("button"),f.id="ib-submit",f.className="ib-modal-submit",f.textContent="Send feedback",f.addEventListener("click",H),h=document.createElement("p"),h.id="ib-success",h.className="ib-modal-success",c=document.createElement("p"),c.id="ib-error",c.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"),y.appendChild(l)),y.appendChild(p),e.showEmailField===!0&&(u=document.createElement("input"),u.id="ib-email",u.className="ib-modal-email",u.type="email",u.placeholder="Your email (optional)",u.setAttribute("aria-label","Email address"),y.appendChild(u)),y.appendChild(c),y.appendChild(h);let A=document.createElement("div");A.className="ib-modal-footer",A.appendChild(f);let I=document.createElement("div");I.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",I.appendChild(T),A.appendChild(I),y.appendChild(A),b.appendChild(x),b.appendChild(y),i.appendChild(b),i.addEventListener("click",k=>{k.target===i&&L()}),document.addEventListener("keydown",B),i}function E(i){var b,x;if(!t){if(r=i,t=S(),document.body.appendChild(t),R(e),i!=null&&i.title){if(n)n.textContent=i.title;else if(g){let m=t.querySelector("#ib-modal");m.removeAttribute("aria-label"),m.setAttribute("aria-labelledby","ib-title"),n=document.createElement("h2"),n.id="ib-title",n.className="ib-modal-title",n.textContent=i.title,g.prepend(n)}}if(i!=null&&i.sentiment){d=i.sentiment;let m=t.querySelector(".ib-modal-thumb--up"),y=t.querySelector(".ib-modal-thumb--down");i.sentiment==="positive"?m==null||m.classList.add("ib-modal-thumb--active"):i.sentiment==="negative"&&(y==null||y.classList.add("ib-modal-thumb--active"))}p&&((b=i==null?void 0:i.prefill)!=null&&b.description)&&(p.value=i.prefill.description),u&&((x=i==null?void 0:i.prefill)!=null&&x.email)&&(u.value=i.prefill.email),p==null||p.focus()}}function L(){t&&(o!==null&&(clearTimeout(o),o=null),document.removeEventListener("keydown",B),t.remove(),t=null,p=null,l=null,u=null,f=null,c=null,h=null,n=null,g=null,r=void 0,d=void 0,z.forEach(i=>i()))}function P(i,b){i==="submit"?v.push(b):i==="close"?z.push(b):i==="error"&&C.push(b)}function N(){L()}return{open:E,close:L,on:P,destroy:N}}function _(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 ee="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",te="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 D(e){var T,k;let t,r={vote:[],open:[],submit:[],close:[],error:[]};function d(a,w){var M;(M=r[a])==null||M.forEach(O=>O(w))}let o=document.createElement("div"),p=e.colorScheme==="dark"?" ib-theme-dark":e.colorScheme==="light"?" ib-theme-light":"";o.className="ib-bar-wrapper"+(e.placement==="fixed"?" ib-bar-wrapper--fixed":"")+p;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 u=document.createElement("div");u.className="ib-bar";let f=document.createElement("div");f.className="ib-bar-label-area";let c=document.createElement("span");c.className="ib-bar-label",c.textContent=(T=e.label)!=null?T:"Was this helpful?",f.appendChild(c);let h=document.createElement("div");h.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(_(ee));let g=document.createElement("button");g.type="button",g.className="ib-bar-btn ib-bar-btn--down",g.setAttribute("aria-label","No"),g.appendChild(_(te)),h.appendChild(n),h.appendChild(g),e.showLabel!==!1&&u.appendChild(f),u.appendChild(h);let v=document.createElement("div");v.className="ib-bar-popover",v.setAttribute("role","dialog"),v.setAttribute("aria-modal","false");let z=document.createElement("div");if(z.className="ib-bar-header",e.modalTitle){v.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,z.appendChild(a)}else v.setAttribute("aria-label","Feedback");let C=document.createElement("div");C.className="ib-bar-body";let B=document.createElement("textarea");B.className="ib-bar-textarea",B.placeholder=(k=e.modalPlaceholder)!=null?k:"What's on your mind?",B.setAttribute("aria-label","Feedback");let H=document.createElement("p");H.className="ib-bar-error";let S=document.createElement("p");S.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(B),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(S);let L=document.createElement("div");L.className="ib-bar-footer",L.appendChild(E);let P=document.createElement("div");P.className="ib-branding";let N=document.createElement("a");N.href="https://inputbuffer.io",N.target="_blank",N.rel="noopener noreferrer",N.textContent="Powered by inputbuffer.io",P.appendChild(N),L.appendChild(P),C.appendChild(L),v.appendChild(z),v.appendChild(C),o.appendChild(v),o.appendChild(u);function i(a){t=a,v.classList.add("ib-bar-popover--visible"),H.textContent="",S.textContent="",B.focus(),setTimeout(()=>document.addEventListener("click",m),0),document.addEventListener("keydown",y),d("open",{sentiment:a})}function b(){v.classList.contains("ib-bar-popover--visible")&&(v.classList.remove("ib-bar-popover--visible"),document.removeEventListener("click",m),document.removeEventListener("keydown",y),B.value="",d("close"))}function x(){n.classList.remove("ib-bar-btn--active"),g.classList.remove("ib-bar-btn--active"),t=void 0}function m(a){o.contains(a.target)||b()}function y(a){a.key==="Escape"&&b()}async function A(){let a=B.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 w=v.querySelector(".ib-bar-title-input"),M=(w==null?void 0:w.value.trim())||null,O=v.querySelector(".ib-bar-email"),J=(O==null?void 0:O.value.trim())||null;try{let F=await j(e.apiKey,a,J,M,{sentiment:t,target:e.target,source:e.source},e.apiUrl);d("submit",F),S.textContent="Thanks for your feedback!",E.textContent="Send feedback",setTimeout(()=>{b(),x()},2e3)}catch(F){d("error",F instanceof Error?F:new Error("Something went wrong.")),H.textContent=F instanceof Error?F.message:"Something went wrong.",E.disabled=!1,E.textContent="Send feedback"}}function I(a){n.classList.remove("ib-bar-btn--active"),g.classList.remove("ib-bar-btn--active"),a.classList.add("ib-bar-btn--active")}return n.addEventListener("click",()=>{d("vote",{sentiment:"positive"}),I(n),i("positive")}),g.addEventListener("click",()=>{d("vote",{sentiment:"negative"}),I(g),i("negative")}),E.addEventListener("click",A),{element:o,on(a,w){var M;(M=r[a])==null||M.push(w)},destroy(){b(),o.remove()}}}var V=`/* InputBuffer Modal Styles
|
|
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
|
|
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
|
*/
|
|
@@ -306,7 +306,7 @@ function R(e){let t=document.getElementById("ib-modal");if(!t)return;let{theme:r
|
|
|
306
306
|
--ib-radius: 8px;
|
|
307
307
|
--ib-radius-input: 4px;
|
|
308
308
|
}
|
|
309
|
-
`;var
|
|
309
|
+
`;var G=`/* InputBuffer Feedback Bar Styles
|
|
310
310
|
* .ib-bar-* and .ib-bar-popover* classes are stable public API \u2014 do not rename them.
|
|
311
311
|
* Developers may target these classes from their own stylesheets to customize the widget.
|
|
312
312
|
*/
|
|
@@ -354,9 +354,7 @@ function R(e){let t=document.getElementById("ib-modal");if(!t)return;let{theme:r
|
|
|
354
354
|
|
|
355
355
|
.ib-bar-popover {
|
|
356
356
|
display: none;
|
|
357
|
-
position:
|
|
358
|
-
bottom: calc(100% + 8px);
|
|
359
|
-
right: 0;
|
|
357
|
+
position: fixed;
|
|
360
358
|
width: 320px;
|
|
361
359
|
|
|
362
360
|
border: 1px solid var(--ib-border);
|
|
@@ -629,4 +627,4 @@ function R(e){let t=document.getElementById("ib-modal");if(!t)return;let{theme:r
|
|
|
629
627
|
--ib-radius: 8px;
|
|
630
628
|
--ib-radius-input: 4px;
|
|
631
629
|
}
|
|
632
|
-
`;var
|
|
630
|
+
`;var b=typeof document!="undefined"?document.currentScript:null;function oe(){if(typeof document=="undefined"||document.getElementById("ib-modal-styles"))return;let e=document.createElement("style");e.id="ib-modal-styles",e.textContent=q,document.head.appendChild(e)}function $(){if(typeof document=="undefined"||document.getElementById("ib-bar-styles"))return;let e=document.createElement("style");e.id="ib-bar-styles",e.textContent=G,document.head.appendChild(e)}function Y(e){e.injectStyles!==!1&&oe();let t=_(e),i=null,d=null;return e.attachTo&&(i=document.querySelector(e.attachTo),i&&(d=()=>t.open(),i.addEventListener("click",d))),{open:o=>t.open(o),close:()=>t.close(),on:(o,m)=>t.on(o,m),destroy:()=>{i&&d&&(i.removeEventListener("click",d),i=null,d=null),t.destroy()}}}function ne(e){return e.injectStyles!==!1&&$(),R(e)}if(typeof HTMLElement!="undefined"){class e extends HTMLElement{constructor(){super(...arguments);this._bar=null}connectedCallback(){var c,h,u,y,n,x,f;let d=this.getAttribute("api-key");if(!d)return;let o=this.getAttribute("inject-styles");(o===null?!0:o!=="false")&&$();let l=this.getAttribute("placement");this._bar=R({apiKey:d,apiUrl:(c=this.getAttribute("api-url"))!=null?c:void 0,label:(h=this.getAttribute("label"))!=null?h:void 0,placement:l==="fixed"?"fixed":"inline",theme:{primary:(u=this.getAttribute("theme-primary"))!=null?u:void 0,background:(y=this.getAttribute("theme-background"))!=null?y:void 0,text:(n=this.getAttribute("theme-text"))!=null?n:void 0,selected:(x=this.getAttribute("theme-selected"))!=null?x:void 0,selectedColor:(f=this.getAttribute("theme-selected-color"))!=null?f:void 0}}),this.appendChild(this._bar.element)}disconnectedCallback(){var d;(d=this._bar)==null||d.destroy(),this._bar=null}}typeof customElements!="undefined"&&!customElements.get("inputbuffer-feedback")&&customElements.define("inputbuffer-feedback",e)}var J={createModal:Y,createBar:ne,version:D};typeof window!="undefined"&&(window.InputBufferIO=J);(function(){if(typeof window=="undefined")return;let t=b==null?void 0:b.dataset.apiKey;if(!t)return;let i=b==null?void 0:b.dataset.injectStyles,d=b==null?void 0:b.dataset.colorScheme,o=Y({apiKey:t,apiUrl:b==null?void 0:b.dataset.apiUrl,attachTo:b==null?void 0:b.dataset.attachTo,injectStyles:i===void 0?!0:i!=="false",colorScheme:d,theme:{primary:b==null?void 0:b.dataset.themePrimary,background:b==null?void 0:b.dataset.themeBackground,text:b==null?void 0:b.dataset.themeText,selected:b==null?void 0:b.dataset.themeSelected,selectedColor:b==null?void 0:b.dataset.themeSelectedColor}});J._defaultInstance=o})();export{J as InputBufferIO};
|
package/dist/widget.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{function R(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 W="0.1.0",X="https://inputbuffer.io/api/v0/inputs";async function j(e,t,r,d,o,p){var h;let l={description:t};if(d&&(l.title=d),r&&(l.contactEmail=r),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 u=new AbortController,f=setTimeout(()=>u.abort(),1e4),c;try{c=await fetch(p!=null?p:X,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-IB-Client":`inputbuffer-widget/${W} (javascript)`},body:JSON.stringify(l),credentials:"omit",signal:u.signal})}finally{clearTimeout(f)}if(!c.ok){let n=await c.json().catch(()=>({}));throw new Error(((h=n==null?void 0:n.error)==null?void 0:h.message)||"Submission failed. Please try again.")}return c.json()}function K(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 Q="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",Z="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 U(e){let t=null,r,d,o=null,p=null,l=null,u=null,f=null,c=null,h=null,n=null,g=null,v=[],z=[],C=[];function B(i){if(i.key==="Escape"){L();return}if(i.key==="Tab"&&t){let b=Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(b.length===0)return;let x=b[0],m=b[b.length-1];i.shiftKey?document.activeElement===x&&(i.preventDefault(),m.focus()):document.activeElement===m&&(i.preventDefault(),x.focus())}}async function H(){var b,x;if(!p||!f)return;let i=p.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"),f.disabled=!0,f.textContent="Sending\u2026";try{let m=(u==null?void 0:u.value.trim())||((b=r==null?void 0:r.prefill)==null?void 0:b.email)||null,y=(l==null?void 0:l.value.trim())||null,A=d!=null?d:r==null?void 0:r.sentiment,I=await j(e.apiKey,i,m||null,y,{...r,sentiment:A,source:(x=r==null?void 0:r.source)!=null?x:e.source},e.apiUrl);h&&(h.textContent="Thanks for your feedback!",h.style.display="block"),v.forEach(T=>T(I)),o=setTimeout(()=>L(),2e3)}catch(m){let y=m instanceof Error?m:new Error("Unknown error");c&&(c.textContent="Something went wrong. Please try again.",c.style.display="block"),C.forEach(A=>A(y)),f.disabled=!1,f.textContent="Send feedback"}}function S(){let i=document.createElement("div");i.id="ib-overlay";let b=document.createElement("div");b.id="ib-modal",e.colorScheme==="dark"?b.classList.add("ib-theme-dark"):e.colorScheme==="light"&&b.classList.add("ib-theme-light"),b.setAttribute("role","dialog"),b.setAttribute("aria-modal","true");let x=document.createElement("div");if(x.id="ib-modal-header",g=x,e.title?(b.setAttribute("aria-labelledby","ib-title"),n=document.createElement("h2"),n.id="ib-title",n.className="ib-modal-title",n.textContent=e.title,x.appendChild(n)):b.setAttribute("aria-label","Feedback"),e.showSentiment){let k,a,w=document.createElement("div");w.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(K(Q)),a=document.createElement("button"),a.type="button",a.className="ib-modal-thumb ib-modal-thumb--down",a.setAttribute("aria-label","Not helpful"),a.appendChild(K(Z)),k.addEventListener("click",()=>{k.classList.add("ib-modal-thumb--active"),a.classList.remove("ib-modal-thumb--active"),d="positive"}),a.addEventListener("click",()=>{a.classList.add("ib-modal-thumb--active"),k.classList.remove("ib-modal-thumb--active"),d="negative"}),w.appendChild(k),w.appendChild(a),x.appendChild(w)}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",L),x.appendChild(m);let y=document.createElement("div");y.id="ib-modal-body",p=document.createElement("textarea"),p.id="ib-textarea",p.className="ib-modal-textarea",p.placeholder=e.placeholder||"What's on your mind?",p.setAttribute("aria-label","Feedback"),f=document.createElement("button"),f.id="ib-submit",f.className="ib-modal-submit",f.textContent="Send feedback",f.addEventListener("click",H),h=document.createElement("p"),h.id="ib-success",h.className="ib-modal-success",c=document.createElement("p"),c.id="ib-error",c.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"),y.appendChild(l)),y.appendChild(p),e.showEmailField===!0&&(u=document.createElement("input"),u.id="ib-email",u.className="ib-modal-email",u.type="email",u.placeholder="Your email (optional)",u.setAttribute("aria-label","Email address"),y.appendChild(u)),y.appendChild(c),y.appendChild(h);let A=document.createElement("div");A.className="ib-modal-footer",A.appendChild(f);let I=document.createElement("div");I.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",I.appendChild(T),A.appendChild(I),y.appendChild(A),b.appendChild(x),b.appendChild(y),i.appendChild(b),i.addEventListener("click",k=>{k.target===i&&L()}),document.addEventListener("keydown",B),i}function E(i){var b,x;if(!t){if(r=i,t=S(),document.body.appendChild(t),R(e),i!=null&&i.title){if(n)n.textContent=i.title;else if(g){let m=t.querySelector("#ib-modal");m.removeAttribute("aria-label"),m.setAttribute("aria-labelledby","ib-title"),n=document.createElement("h2"),n.id="ib-title",n.className="ib-modal-title",n.textContent=i.title,g.prepend(n)}}if(i!=null&&i.sentiment){d=i.sentiment;let m=t.querySelector(".ib-modal-thumb--up"),y=t.querySelector(".ib-modal-thumb--down");i.sentiment==="positive"?m==null||m.classList.add("ib-modal-thumb--active"):i.sentiment==="negative"&&(y==null||y.classList.add("ib-modal-thumb--active"))}p&&((b=i==null?void 0:i.prefill)!=null&&b.description)&&(p.value=i.prefill.description),u&&((x=i==null?void 0:i.prefill)!=null&&x.email)&&(u.value=i.prefill.email),p==null||p.focus()}}function L(){t&&(o!==null&&(clearTimeout(o),o=null),document.removeEventListener("keydown",B),t.remove(),t=null,p=null,l=null,u=null,f=null,c=null,h=null,n=null,g=null,r=void 0,d=void 0,z.forEach(i=>i()))}function P(i,b){i==="submit"?v.push(b):i==="close"?z.push(b):i==="error"&&C.push(b)}function N(){L()}return{open:E,close:L,on:P,destroy:N}}function _(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 ee="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",te="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 D(e){var T,k;let t,r={vote:[],open:[],submit:[],close:[],error:[]};function d(a,w){var M;(M=r[a])==null||M.forEach(O=>O(w))}let o=document.createElement("div"),p=e.colorScheme==="dark"?" ib-theme-dark":e.colorScheme==="light"?" ib-theme-light":"";o.className="ib-bar-wrapper"+(e.placement==="fixed"?" ib-bar-wrapper--fixed":"")+p;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 u=document.createElement("div");u.className="ib-bar";let f=document.createElement("div");f.className="ib-bar-label-area";let c=document.createElement("span");c.className="ib-bar-label",c.textContent=(T=e.label)!=null?T:"Was this helpful?",f.appendChild(c);let h=document.createElement("div");h.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(_(ee));let g=document.createElement("button");g.type="button",g.className="ib-bar-btn ib-bar-btn--down",g.setAttribute("aria-label","No"),g.appendChild(_(te)),h.appendChild(n),h.appendChild(g),e.showLabel!==!1&&u.appendChild(f),u.appendChild(h);let v=document.createElement("div");v.className="ib-bar-popover",v.setAttribute("role","dialog"),v.setAttribute("aria-modal","false");let z=document.createElement("div");if(z.className="ib-bar-header",e.modalTitle){v.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,z.appendChild(a)}else v.setAttribute("aria-label","Feedback");let C=document.createElement("div");C.className="ib-bar-body";let B=document.createElement("textarea");B.className="ib-bar-textarea",B.placeholder=(k=e.modalPlaceholder)!=null?k:"What's on your mind?",B.setAttribute("aria-label","Feedback");let H=document.createElement("p");H.className="ib-bar-error";let S=document.createElement("p");S.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(B),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(S);let L=document.createElement("div");L.className="ib-bar-footer",L.appendChild(E);let P=document.createElement("div");P.className="ib-branding";let N=document.createElement("a");N.href="https://inputbuffer.io",N.target="_blank",N.rel="noopener noreferrer",N.textContent="Powered by inputbuffer.io",P.appendChild(N),L.appendChild(P),C.appendChild(L),v.appendChild(z),v.appendChild(C),o.appendChild(v),o.appendChild(u);function i(a){t=a,v.classList.add("ib-bar-popover--visible"),H.textContent="",S.textContent="",B.focus(),setTimeout(()=>document.addEventListener("click",m),0),document.addEventListener("keydown",y),d("open",{sentiment:a})}function b(){v.classList.contains("ib-bar-popover--visible")&&(v.classList.remove("ib-bar-popover--visible"),document.removeEventListener("click",m),document.removeEventListener("keydown",y),B.value="",d("close"))}function x(){n.classList.remove("ib-bar-btn--active"),g.classList.remove("ib-bar-btn--active"),t=void 0}function m(a){o.contains(a.target)||b()}function y(a){a.key==="Escape"&&b()}async function A(){let a=B.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 w=v.querySelector(".ib-bar-title-input"),M=(w==null?void 0:w.value.trim())||null,O=v.querySelector(".ib-bar-email"),J=(O==null?void 0:O.value.trim())||null;try{let F=await j(e.apiKey,a,J,M,{sentiment:t,target:e.target,source:e.source},e.apiUrl);d("submit",F),S.textContent="Thanks for your feedback!",E.textContent="Send feedback",setTimeout(()=>{b(),x()},2e3)}catch(F){d("error",F instanceof Error?F:new Error("Something went wrong.")),H.textContent=F instanceof Error?F.message:"Something went wrong.",E.disabled=!1,E.textContent="Send feedback"}}function I(a){n.classList.remove("ib-bar-btn--active"),g.classList.remove("ib-bar-btn--active"),a.classList.add("ib-bar-btn--active")}return n.addEventListener("click",()=>{d("vote",{sentiment:"positive"}),I(n),i("positive")}),g.addEventListener("click",()=>{d("vote",{sentiment:"negative"}),I(g),i("negative")}),E.addEventListener("click",A),{element:o,on(a,w){var M;(M=r[a])==null||M.push(w)},destroy(){b(),o.remove()}}}var V=`/* InputBuffer Modal Styles
|
|
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
|
|
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
|
*/
|
|
@@ -306,7 +306,7 @@
|
|
|
306
306
|
--ib-radius: 8px;
|
|
307
307
|
--ib-radius-input: 4px;
|
|
308
308
|
}
|
|
309
|
-
`;var
|
|
309
|
+
`;var G=`/* InputBuffer Feedback Bar Styles
|
|
310
310
|
* .ib-bar-* and .ib-bar-popover* classes are stable public API \u2014 do not rename them.
|
|
311
311
|
* Developers may target these classes from their own stylesheets to customize the widget.
|
|
312
312
|
*/
|
|
@@ -354,9 +354,7 @@
|
|
|
354
354
|
|
|
355
355
|
.ib-bar-popover {
|
|
356
356
|
display: none;
|
|
357
|
-
position:
|
|
358
|
-
bottom: calc(100% + 8px);
|
|
359
|
-
right: 0;
|
|
357
|
+
position: fixed;
|
|
360
358
|
width: 320px;
|
|
361
359
|
|
|
362
360
|
border: 1px solid var(--ib-border);
|
|
@@ -629,4 +627,4 @@
|
|
|
629
627
|
--ib-radius: 8px;
|
|
630
628
|
--ib-radius-input: 4px;
|
|
631
629
|
}
|
|
632
|
-
`;var
|
|
630
|
+
`;var b=typeof document!="undefined"?document.currentScript:null;function oe(){if(typeof document=="undefined"||document.getElementById("ib-modal-styles"))return;let e=document.createElement("style");e.id="ib-modal-styles",e.textContent=q,document.head.appendChild(e)}function $(){if(typeof document=="undefined"||document.getElementById("ib-bar-styles"))return;let e=document.createElement("style");e.id="ib-bar-styles",e.textContent=G,document.head.appendChild(e)}function Y(e){e.injectStyles!==!1&&oe();let t=_(e),i=null,d=null;return e.attachTo&&(i=document.querySelector(e.attachTo),i&&(d=()=>t.open(),i.addEventListener("click",d))),{open:o=>t.open(o),close:()=>t.close(),on:(o,m)=>t.on(o,m),destroy:()=>{i&&d&&(i.removeEventListener("click",d),i=null,d=null),t.destroy()}}}function ne(e){return e.injectStyles!==!1&&$(),R(e)}if(typeof HTMLElement!="undefined"){class e extends HTMLElement{constructor(){super(...arguments);this._bar=null}connectedCallback(){var c,h,u,y,n,x,f;let d=this.getAttribute("api-key");if(!d)return;let o=this.getAttribute("inject-styles");(o===null?!0:o!=="false")&&$();let l=this.getAttribute("placement");this._bar=R({apiKey:d,apiUrl:(c=this.getAttribute("api-url"))!=null?c:void 0,label:(h=this.getAttribute("label"))!=null?h:void 0,placement:l==="fixed"?"fixed":"inline",theme:{primary:(u=this.getAttribute("theme-primary"))!=null?u:void 0,background:(y=this.getAttribute("theme-background"))!=null?y:void 0,text:(n=this.getAttribute("theme-text"))!=null?n:void 0,selected:(x=this.getAttribute("theme-selected"))!=null?x:void 0,selectedColor:(f=this.getAttribute("theme-selected-color"))!=null?f:void 0}}),this.appendChild(this._bar.element)}disconnectedCallback(){var d;(d=this._bar)==null||d.destroy(),this._bar=null}}typeof customElements!="undefined"&&!customElements.get("inputbuffer-feedback")&&customElements.define("inputbuffer-feedback",e)}var J={createModal:Y,createBar:ne,version:D};typeof window!="undefined"&&(window.InputBufferIO=J);(function(){if(typeof window=="undefined")return;let t=b==null?void 0:b.dataset.apiKey;if(!t)return;let i=b==null?void 0:b.dataset.injectStyles,d=b==null?void 0:b.dataset.colorScheme,o=Y({apiKey:t,apiUrl:b==null?void 0:b.dataset.apiUrl,attachTo:b==null?void 0:b.dataset.attachTo,injectStyles:i===void 0?!0:i!=="false",colorScheme:d,theme:{primary:b==null?void 0:b.dataset.themePrimary,background:b==null?void 0:b.dataset.themeBackground,text:b==null?void 0:b.dataset.themeText,selected:b==null?void 0:b.dataset.themeSelected,selectedColor:b==null?void 0:b.dataset.themeSelectedColor}});J._defaultInstance=o})();})();
|