@inputbuffer/feedback 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +638 -0
- package/dist/api.d.ts +5 -0
- package/dist/bar-entry.d.ts +8 -0
- package/dist/bar.css +1 -0
- package/dist/bar.d.ts +2 -0
- package/dist/bar.esm.js +324 -0
- package/dist/bar.js +324 -0
- package/dist/index.d.ts +18 -0
- package/dist/modal-entry.d.ts +8 -0
- package/dist/modal.css +1 -0
- package/dist/modal.d.ts +13 -0
- package/dist/modal.esm.js +309 -0
- package/dist/modal.js +309 -0
- package/dist/theme.d.ts +2 -0
- package/dist/types.d.ts +100 -0
- package/dist/widget.esm.js +632 -0
- package/dist/widget.js +632 -0
- package/package.json +59 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WidgetConfig, OpenOptions, WidgetInstance } from './types.js';
|
|
2
|
+
declare function createModal(config: WidgetConfig): WidgetInstance;
|
|
3
|
+
declare const InputBufferIO: {
|
|
4
|
+
createModal: typeof createModal;
|
|
5
|
+
version: string;
|
|
6
|
+
};
|
|
7
|
+
export type { WidgetConfig, OpenOptions, WidgetInstance };
|
|
8
|
+
export { InputBufferIO, createModal };
|
package/dist/modal.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#ib-overlay{position:fixed;inset:0;background:#00000080;z-index:2147483647;display:flex;align-items:center;justify-content:center}#ib-modal{--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;color:var(--ib-text);border:1px solid var(--ib-border);border-radius:var(--ib-radius);width:100%;max-width:480px;margin:16px;position:relative;box-shadow:0 4px 24px #0000001f;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:14px;box-sizing:border-box;overflow:hidden}#ib-modal-header{background:var(--ib-surface);padding:12px 16px;border-bottom:1px solid var(--ib-border);display:flex;align-items:center;gap:8px}#ib-modal-body{background-color:var(--ib-background);padding:16px}#ib-title,.ib-modal-title{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.1em;margin:0;color:var(--ib-muted);flex:1}#ib-textarea,.ib-modal-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:100px;box-sizing:border-box;outline:none;display:block}#ib-textarea:hover,.ib-modal-textarea:hover{border-color:var(--ib-input-hover-border)}#ib-textarea:focus,.ib-modal-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-modal-body #ib-title-input,#ib-modal-body .ib-modal-title-input,#ib-modal-body #ib-email,#ib-modal-body .ib-modal-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-title-input,.ib-modal-title-input{margin-bottom:10px}#ib-email,.ib-modal-email{margin-top:10px}#ib-modal-body #ib-title-input:hover,#ib-modal-body .ib-modal-title-input:hover,#ib-modal-body #ib-email:hover,#ib-modal-body .ib-modal-email:hover{border-color:var(--ib-input-hover-border)}#ib-modal-body #ib-title-input:focus,#ib-modal-body .ib-modal-title-input:focus,#ib-modal-body #ib-email:focus,#ib-modal-body .ib-modal-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-submit,.ib-modal-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-submit:hover,.ib-modal-submit:hover{background:var(--ib-primary-hover)}#ib-submit:disabled,.ib-modal-submit:disabled{opacity:.6;cursor:not-allowed}#ib-close,.ib-modal-close{background:none;border:none;font-size:18px;line-height:1;cursor:pointer;color:var(--ib-muted);padding:2px 6px;margin:0;border-radius:var(--ib-radius-input);flex-shrink:0}#ib-close:hover,.ib-modal-close:hover{color:var(--ib-primary)}#ib-success,.ib-modal-success{color:#16a34a;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;margin:8px 0 0;display:none}.ib-modal-footer{display:flex;align-items:center;justify-content:space-between;margin-top:12px}.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-error,.ib-modal-error{color:#dc2626;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;margin:8px 0 0;display:none}.ib-modal-sentiment{display:flex;gap:4px}.ib-modal-thumb{width:30px;height:30px;display:flex;align-items:center;justify-content:center;background:var(--ib-background);border:1px solid var(--ib-border);border-radius:var(--ib-radius-input);color:var(--ib-primary);cursor:pointer;transition:background .15s,color .15s;padding:0;margin:0;flex-shrink:0;-webkit-appearance:none;appearance:none;box-sizing:border-box}.ib-modal-thumb:hover{background:var(--ib-primary);color:var(--ib-surface)}.ib-modal-thumb:focus{outline:1px solid var(--ib-primary);outline-offset:-1px}.ib-modal-thumb--active{background:var(--ib-selected);color:var(--ib-selected-color)}.ib-modal-thumb--active:hover{background:var(--ib-primary-hover)}@media (prefers-color-scheme: dark){#ib-modal:not(.ib-theme-light),#ib-modal.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-radius: 8px;--ib-radius-input: 4px}}#ib-modal.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-radius: 8px;--ib-radius-input: 4px}
|
package/dist/modal.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { WidgetConfig, OpenOptions } from './types.js';
|
|
2
|
+
type SubmitHandler = (result: {
|
|
3
|
+
id: string;
|
|
4
|
+
}) => void;
|
|
5
|
+
type CloseHandler = () => void;
|
|
6
|
+
type ErrorHandler = (err: Error) => void;
|
|
7
|
+
export declare function createModal(config: WidgetConfig): {
|
|
8
|
+
open: (options?: OpenOptions) => void;
|
|
9
|
+
close: () => void;
|
|
10
|
+
on: (event: "submit" | "close" | "error", handler: SubmitHandler | CloseHandler | ErrorHandler) => void;
|
|
11
|
+
destroy: () => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,309 @@
|
|
|
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.0",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
|
+
* All #ib-* IDs are stable public API \u2014 do not rename them.
|
|
3
|
+
* Developers may target these IDs from their own stylesheets to customize the widget.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#ib-overlay {
|
|
7
|
+
position: fixed;
|
|
8
|
+
top: 0;
|
|
9
|
+
right: 0;
|
|
10
|
+
bottom: 0;
|
|
11
|
+
left: 0;
|
|
12
|
+
background: rgba(0, 0, 0, 0.5);
|
|
13
|
+
z-index: 2147483647;
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#ib-modal {
|
|
20
|
+
--ib-primary: #6366f1;
|
|
21
|
+
--ib-primary-hover: #4338ca;
|
|
22
|
+
--ib-background: #f6f6f8;
|
|
23
|
+
--ib-surface: #ffffff;
|
|
24
|
+
--ib-text: #111827;
|
|
25
|
+
--ib-muted: #8d99ae;
|
|
26
|
+
--ib-border: var(--ib-primary);
|
|
27
|
+
--ib-focus-color: var(--ib-primary);
|
|
28
|
+
--ib-input-hover-border: var(--ib-border);
|
|
29
|
+
--ib-selected: var(--ib-primary);
|
|
30
|
+
--ib-selected-color: var(--ib-surface);
|
|
31
|
+
--ib-radius: 2px;
|
|
32
|
+
--ib-radius-input: 2px;
|
|
33
|
+
|
|
34
|
+
color: var(--ib-text);
|
|
35
|
+
border: 1px solid var(--ib-border);
|
|
36
|
+
border-radius: var(--ib-radius);
|
|
37
|
+
width: 100%;
|
|
38
|
+
max-width: 480px;
|
|
39
|
+
margin: 16px;
|
|
40
|
+
position: relative;
|
|
41
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
|
|
42
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
43
|
+
font-size: 14px;
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#ib-modal-header {
|
|
49
|
+
background: var(--ib-surface);
|
|
50
|
+
padding: 12px 16px;
|
|
51
|
+
border-bottom: 1px solid var(--ib-border);
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
gap: 8px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#ib-modal-body {
|
|
58
|
+
background-color: var(--ib-background);
|
|
59
|
+
padding: 16px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#ib-title,
|
|
63
|
+
.ib-modal-title {
|
|
64
|
+
font-size: 11px;
|
|
65
|
+
font-weight: 600;
|
|
66
|
+
text-transform: uppercase;
|
|
67
|
+
letter-spacing: 0.1em;
|
|
68
|
+
margin: 0;
|
|
69
|
+
color: var(--ib-muted);
|
|
70
|
+
flex: 1;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
#ib-textarea,
|
|
74
|
+
.ib-modal-textarea {
|
|
75
|
+
width: 100%;
|
|
76
|
+
background: var(--ib-background);
|
|
77
|
+
border: 1px solid var(--ib-border);
|
|
78
|
+
border-radius: var(--ib-radius-input);
|
|
79
|
+
padding: 10px 12px;
|
|
80
|
+
font-size: 14px;
|
|
81
|
+
font-family: inherit;
|
|
82
|
+
color: var(--ib-text);
|
|
83
|
+
resize: vertical;
|
|
84
|
+
min-height: 100px;
|
|
85
|
+
box-sizing: border-box;
|
|
86
|
+
outline: none;
|
|
87
|
+
display: block;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#ib-textarea:hover,
|
|
91
|
+
.ib-modal-textarea:hover {
|
|
92
|
+
border-color: var(--ib-input-hover-border);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#ib-textarea:focus,
|
|
96
|
+
.ib-modal-textarea:focus {
|
|
97
|
+
border-color: var(--ib-focus-color);
|
|
98
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#ib-modal-body #ib-title-input,
|
|
102
|
+
#ib-modal-body .ib-modal-title-input,
|
|
103
|
+
#ib-modal-body #ib-email,
|
|
104
|
+
#ib-modal-body .ib-modal-email {
|
|
105
|
+
width: 100%;
|
|
106
|
+
background: var(--ib-background);
|
|
107
|
+
border: 1px solid var(--ib-border);
|
|
108
|
+
border-radius: var(--ib-radius-input);
|
|
109
|
+
padding: 8px 12px;
|
|
110
|
+
font-size: 14px;
|
|
111
|
+
font-family: inherit;
|
|
112
|
+
color: var(--ib-text);
|
|
113
|
+
box-sizing: border-box;
|
|
114
|
+
outline: none;
|
|
115
|
+
display: block;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#ib-title-input,
|
|
119
|
+
.ib-modal-title-input {
|
|
120
|
+
margin-bottom: 10px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
#ib-email,
|
|
124
|
+
.ib-modal-email {
|
|
125
|
+
margin-top: 10px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
#ib-modal-body #ib-title-input:hover,
|
|
129
|
+
#ib-modal-body .ib-modal-title-input:hover,
|
|
130
|
+
#ib-modal-body #ib-email:hover,
|
|
131
|
+
#ib-modal-body .ib-modal-email:hover {
|
|
132
|
+
border-color: var(--ib-input-hover-border);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
#ib-modal-body #ib-title-input:focus,
|
|
136
|
+
#ib-modal-body .ib-modal-title-input:focus,
|
|
137
|
+
#ib-modal-body #ib-email:focus,
|
|
138
|
+
#ib-modal-body .ib-modal-email:focus {
|
|
139
|
+
border-color: var(--ib-focus-color);
|
|
140
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
#ib-submit,
|
|
144
|
+
.ib-modal-submit {
|
|
145
|
+
background: var(--ib-primary);
|
|
146
|
+
color: #ffffff;
|
|
147
|
+
border: none;
|
|
148
|
+
border-radius: var(--ib-radius-input);
|
|
149
|
+
padding: 8px 16px;
|
|
150
|
+
font-size: 11px;
|
|
151
|
+
font-weight: 600;
|
|
152
|
+
text-transform: uppercase;
|
|
153
|
+
letter-spacing: 0.08em;
|
|
154
|
+
font-family: inherit;
|
|
155
|
+
cursor: pointer;
|
|
156
|
+
display: inline-block;
|
|
157
|
+
transition: background 0.15s;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
#ib-submit:hover,
|
|
161
|
+
.ib-modal-submit:hover {
|
|
162
|
+
background: var(--ib-primary-hover);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
#ib-submit:disabled,
|
|
166
|
+
.ib-modal-submit:disabled {
|
|
167
|
+
opacity: 0.6;
|
|
168
|
+
cursor: not-allowed;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
#ib-close,
|
|
172
|
+
.ib-modal-close {
|
|
173
|
+
background: none;
|
|
174
|
+
border: none;
|
|
175
|
+
font-size: 18px;
|
|
176
|
+
line-height: 1;
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
color: var(--ib-muted);
|
|
179
|
+
padding: 2px 6px;
|
|
180
|
+
margin: 0;
|
|
181
|
+
border-radius: var(--ib-radius-input);
|
|
182
|
+
flex-shrink: 0;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
#ib-close:hover,
|
|
186
|
+
.ib-modal-close:hover {
|
|
187
|
+
color: var(--ib-primary);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
#ib-success,
|
|
191
|
+
.ib-modal-success {
|
|
192
|
+
color: #16a34a;
|
|
193
|
+
font-size: 11px;
|
|
194
|
+
font-weight: 600;
|
|
195
|
+
text-transform: uppercase;
|
|
196
|
+
letter-spacing: 0.08em;
|
|
197
|
+
margin: 8px 0 0;
|
|
198
|
+
display: none;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.ib-modal-footer {
|
|
202
|
+
display: flex;
|
|
203
|
+
align-items: center;
|
|
204
|
+
justify-content: space-between;
|
|
205
|
+
margin-top: 12px;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.ib-branding a {
|
|
209
|
+
font-size: 10px;
|
|
210
|
+
color: var(--ib-muted);
|
|
211
|
+
text-decoration: none;
|
|
212
|
+
letter-spacing: 0.03em;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.ib-branding a:hover {
|
|
216
|
+
color: var(--ib-primary);
|
|
217
|
+
text-decoration: underline;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
#ib-error,
|
|
221
|
+
.ib-modal-error {
|
|
222
|
+
color: #dc2626;
|
|
223
|
+
font-size: 11px;
|
|
224
|
+
font-weight: 600;
|
|
225
|
+
text-transform: uppercase;
|
|
226
|
+
letter-spacing: 0.08em;
|
|
227
|
+
margin: 8px 0 0;
|
|
228
|
+
display: none;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Modal sentiment thumbs */
|
|
232
|
+
|
|
233
|
+
.ib-modal-sentiment {
|
|
234
|
+
display: flex;
|
|
235
|
+
gap: 4px;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.ib-modal-thumb {
|
|
239
|
+
width: 30px;
|
|
240
|
+
height: 30px;
|
|
241
|
+
display: flex;
|
|
242
|
+
align-items: center;
|
|
243
|
+
justify-content: center;
|
|
244
|
+
background: var(--ib-background);
|
|
245
|
+
border: 1px solid var(--ib-border);
|
|
246
|
+
border-radius: var(--ib-radius-input);
|
|
247
|
+
color: var(--ib-primary);
|
|
248
|
+
cursor: pointer;
|
|
249
|
+
transition: background 0.15s, color 0.15s;
|
|
250
|
+
padding: 0;
|
|
251
|
+
margin: 0;
|
|
252
|
+
flex-shrink: 0;
|
|
253
|
+
-webkit-appearance: none;
|
|
254
|
+
appearance: none;
|
|
255
|
+
box-sizing: border-box;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.ib-modal-thumb:hover {
|
|
259
|
+
background: var(--ib-primary);
|
|
260
|
+
color: var(--ib-surface);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.ib-modal-thumb:focus {
|
|
264
|
+
outline: 1px solid var(--ib-primary);
|
|
265
|
+
outline-offset: -1px;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.ib-modal-thumb--active {
|
|
269
|
+
background: var(--ib-selected);
|
|
270
|
+
color: var(--ib-selected-color);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.ib-modal-thumb--active:hover {
|
|
274
|
+
background: var(--ib-primary-hover);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/* \u2500\u2500 Dark theme \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
278
|
+
|
|
279
|
+
@media (prefers-color-scheme: dark) {
|
|
280
|
+
#ib-modal:not(.ib-theme-light),
|
|
281
|
+
#ib-modal.ib-theme-dark {
|
|
282
|
+
--ib-primary: #3A5244;
|
|
283
|
+
--ib-primary-hover: #4E6857;
|
|
284
|
+
--ib-background: #25272B;
|
|
285
|
+
--ib-surface: #2C3630;
|
|
286
|
+
--ib-text: #E5E7EB;
|
|
287
|
+
--ib-muted: #9CA3AF;
|
|
288
|
+
--ib-border: #363840;
|
|
289
|
+
--ib-focus-color: #7B9B82;
|
|
290
|
+
--ib-input-hover-border: rgba(255, 255, 255, 0.2);
|
|
291
|
+
--ib-radius: 8px;
|
|
292
|
+
--ib-radius-input: 4px;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
#ib-modal.ib-theme-dark {
|
|
297
|
+
--ib-primary: #3A5244;
|
|
298
|
+
--ib-primary-hover: #4E6857;
|
|
299
|
+
--ib-background: #25272B;
|
|
300
|
+
--ib-surface: #2C3630;
|
|
301
|
+
--ib-text: #E5E7EB;
|
|
302
|
+
--ib-muted: #9CA3AF;
|
|
303
|
+
--ib-border: #363840;
|
|
304
|
+
--ib-focus-color: #7B9B82;
|
|
305
|
+
--ib-input-hover-border: rgba(255, 255, 255, 0.2);
|
|
306
|
+
--ib-radius: 8px;
|
|
307
|
+
--ib-radius-input: 4px;
|
|
308
|
+
}
|
|
309
|
+
`;var r=document.currentScript;function G(){if(document.getElementById("ib-modal-styles"))return;let a=document.createElement("style");a.id="ib-modal-styles",a.textContent=O,document.head.appendChild(a)}function P(a){a.injectStyles!==!1&&G();let i=S(a),e=null,b=null;return a.attachTo&&(e=document.querySelector(a.attachTo),e&&(b=()=>i.open(),e.addEventListener("click",b))),{open:n=>i.open(n),close:()=>i.close(),on:(n,s)=>i.on(n,s),destroy:()=>{e&&b&&(e.removeEventListener("click",b),e=null,b=null),i.destroy()}}}var j={createModal:P,version:L};window.InputBufferIO=j;(function(){let i=r==null?void 0:r.dataset.apiKey;if(!i)return;let e=r==null?void 0:r.dataset.injectStyles,b=P({apiKey:i,apiUrl:r==null?void 0:r.dataset.apiUrl,attachTo:r==null?void 0:r.dataset.attachTo,injectStyles:e===void 0?!0:e!=="false",theme:{primary:r==null?void 0:r.dataset.themePrimary,background:r==null?void 0:r.dataset.themeBackground,text:r==null?void 0:r.dataset.themeText,selected:r==null?void 0:r.dataset.themeSelected,selectedColor:r==null?void 0:r.dataset.themeSelectedColor}});j._defaultInstance=b})();export{j as InputBufferIO,P as createModal};
|
package/dist/modal.js
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
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.0",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
|
+
* All #ib-* IDs are stable public API \u2014 do not rename them.
|
|
3
|
+
* Developers may target these IDs from their own stylesheets to customize the widget.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#ib-overlay {
|
|
7
|
+
position: fixed;
|
|
8
|
+
top: 0;
|
|
9
|
+
right: 0;
|
|
10
|
+
bottom: 0;
|
|
11
|
+
left: 0;
|
|
12
|
+
background: rgba(0, 0, 0, 0.5);
|
|
13
|
+
z-index: 2147483647;
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#ib-modal {
|
|
20
|
+
--ib-primary: #6366f1;
|
|
21
|
+
--ib-primary-hover: #4338ca;
|
|
22
|
+
--ib-background: #f6f6f8;
|
|
23
|
+
--ib-surface: #ffffff;
|
|
24
|
+
--ib-text: #111827;
|
|
25
|
+
--ib-muted: #8d99ae;
|
|
26
|
+
--ib-border: var(--ib-primary);
|
|
27
|
+
--ib-focus-color: var(--ib-primary);
|
|
28
|
+
--ib-input-hover-border: var(--ib-border);
|
|
29
|
+
--ib-selected: var(--ib-primary);
|
|
30
|
+
--ib-selected-color: var(--ib-surface);
|
|
31
|
+
--ib-radius: 2px;
|
|
32
|
+
--ib-radius-input: 2px;
|
|
33
|
+
|
|
34
|
+
color: var(--ib-text);
|
|
35
|
+
border: 1px solid var(--ib-border);
|
|
36
|
+
border-radius: var(--ib-radius);
|
|
37
|
+
width: 100%;
|
|
38
|
+
max-width: 480px;
|
|
39
|
+
margin: 16px;
|
|
40
|
+
position: relative;
|
|
41
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
|
|
42
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
43
|
+
font-size: 14px;
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#ib-modal-header {
|
|
49
|
+
background: var(--ib-surface);
|
|
50
|
+
padding: 12px 16px;
|
|
51
|
+
border-bottom: 1px solid var(--ib-border);
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
gap: 8px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#ib-modal-body {
|
|
58
|
+
background-color: var(--ib-background);
|
|
59
|
+
padding: 16px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#ib-title,
|
|
63
|
+
.ib-modal-title {
|
|
64
|
+
font-size: 11px;
|
|
65
|
+
font-weight: 600;
|
|
66
|
+
text-transform: uppercase;
|
|
67
|
+
letter-spacing: 0.1em;
|
|
68
|
+
margin: 0;
|
|
69
|
+
color: var(--ib-muted);
|
|
70
|
+
flex: 1;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
#ib-textarea,
|
|
74
|
+
.ib-modal-textarea {
|
|
75
|
+
width: 100%;
|
|
76
|
+
background: var(--ib-background);
|
|
77
|
+
border: 1px solid var(--ib-border);
|
|
78
|
+
border-radius: var(--ib-radius-input);
|
|
79
|
+
padding: 10px 12px;
|
|
80
|
+
font-size: 14px;
|
|
81
|
+
font-family: inherit;
|
|
82
|
+
color: var(--ib-text);
|
|
83
|
+
resize: vertical;
|
|
84
|
+
min-height: 100px;
|
|
85
|
+
box-sizing: border-box;
|
|
86
|
+
outline: none;
|
|
87
|
+
display: block;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#ib-textarea:hover,
|
|
91
|
+
.ib-modal-textarea:hover {
|
|
92
|
+
border-color: var(--ib-input-hover-border);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#ib-textarea:focus,
|
|
96
|
+
.ib-modal-textarea:focus {
|
|
97
|
+
border-color: var(--ib-focus-color);
|
|
98
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#ib-modal-body #ib-title-input,
|
|
102
|
+
#ib-modal-body .ib-modal-title-input,
|
|
103
|
+
#ib-modal-body #ib-email,
|
|
104
|
+
#ib-modal-body .ib-modal-email {
|
|
105
|
+
width: 100%;
|
|
106
|
+
background: var(--ib-background);
|
|
107
|
+
border: 1px solid var(--ib-border);
|
|
108
|
+
border-radius: var(--ib-radius-input);
|
|
109
|
+
padding: 8px 12px;
|
|
110
|
+
font-size: 14px;
|
|
111
|
+
font-family: inherit;
|
|
112
|
+
color: var(--ib-text);
|
|
113
|
+
box-sizing: border-box;
|
|
114
|
+
outline: none;
|
|
115
|
+
display: block;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#ib-title-input,
|
|
119
|
+
.ib-modal-title-input {
|
|
120
|
+
margin-bottom: 10px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
#ib-email,
|
|
124
|
+
.ib-modal-email {
|
|
125
|
+
margin-top: 10px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
#ib-modal-body #ib-title-input:hover,
|
|
129
|
+
#ib-modal-body .ib-modal-title-input:hover,
|
|
130
|
+
#ib-modal-body #ib-email:hover,
|
|
131
|
+
#ib-modal-body .ib-modal-email:hover {
|
|
132
|
+
border-color: var(--ib-input-hover-border);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
#ib-modal-body #ib-title-input:focus,
|
|
136
|
+
#ib-modal-body .ib-modal-title-input:focus,
|
|
137
|
+
#ib-modal-body #ib-email:focus,
|
|
138
|
+
#ib-modal-body .ib-modal-email:focus {
|
|
139
|
+
border-color: var(--ib-focus-color);
|
|
140
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
#ib-submit,
|
|
144
|
+
.ib-modal-submit {
|
|
145
|
+
background: var(--ib-primary);
|
|
146
|
+
color: #ffffff;
|
|
147
|
+
border: none;
|
|
148
|
+
border-radius: var(--ib-radius-input);
|
|
149
|
+
padding: 8px 16px;
|
|
150
|
+
font-size: 11px;
|
|
151
|
+
font-weight: 600;
|
|
152
|
+
text-transform: uppercase;
|
|
153
|
+
letter-spacing: 0.08em;
|
|
154
|
+
font-family: inherit;
|
|
155
|
+
cursor: pointer;
|
|
156
|
+
display: inline-block;
|
|
157
|
+
transition: background 0.15s;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
#ib-submit:hover,
|
|
161
|
+
.ib-modal-submit:hover {
|
|
162
|
+
background: var(--ib-primary-hover);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
#ib-submit:disabled,
|
|
166
|
+
.ib-modal-submit:disabled {
|
|
167
|
+
opacity: 0.6;
|
|
168
|
+
cursor: not-allowed;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
#ib-close,
|
|
172
|
+
.ib-modal-close {
|
|
173
|
+
background: none;
|
|
174
|
+
border: none;
|
|
175
|
+
font-size: 18px;
|
|
176
|
+
line-height: 1;
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
color: var(--ib-muted);
|
|
179
|
+
padding: 2px 6px;
|
|
180
|
+
margin: 0;
|
|
181
|
+
border-radius: var(--ib-radius-input);
|
|
182
|
+
flex-shrink: 0;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
#ib-close:hover,
|
|
186
|
+
.ib-modal-close:hover {
|
|
187
|
+
color: var(--ib-primary);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
#ib-success,
|
|
191
|
+
.ib-modal-success {
|
|
192
|
+
color: #16a34a;
|
|
193
|
+
font-size: 11px;
|
|
194
|
+
font-weight: 600;
|
|
195
|
+
text-transform: uppercase;
|
|
196
|
+
letter-spacing: 0.08em;
|
|
197
|
+
margin: 8px 0 0;
|
|
198
|
+
display: none;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.ib-modal-footer {
|
|
202
|
+
display: flex;
|
|
203
|
+
align-items: center;
|
|
204
|
+
justify-content: space-between;
|
|
205
|
+
margin-top: 12px;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.ib-branding a {
|
|
209
|
+
font-size: 10px;
|
|
210
|
+
color: var(--ib-muted);
|
|
211
|
+
text-decoration: none;
|
|
212
|
+
letter-spacing: 0.03em;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.ib-branding a:hover {
|
|
216
|
+
color: var(--ib-primary);
|
|
217
|
+
text-decoration: underline;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
#ib-error,
|
|
221
|
+
.ib-modal-error {
|
|
222
|
+
color: #dc2626;
|
|
223
|
+
font-size: 11px;
|
|
224
|
+
font-weight: 600;
|
|
225
|
+
text-transform: uppercase;
|
|
226
|
+
letter-spacing: 0.08em;
|
|
227
|
+
margin: 8px 0 0;
|
|
228
|
+
display: none;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Modal sentiment thumbs */
|
|
232
|
+
|
|
233
|
+
.ib-modal-sentiment {
|
|
234
|
+
display: flex;
|
|
235
|
+
gap: 4px;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.ib-modal-thumb {
|
|
239
|
+
width: 30px;
|
|
240
|
+
height: 30px;
|
|
241
|
+
display: flex;
|
|
242
|
+
align-items: center;
|
|
243
|
+
justify-content: center;
|
|
244
|
+
background: var(--ib-background);
|
|
245
|
+
border: 1px solid var(--ib-border);
|
|
246
|
+
border-radius: var(--ib-radius-input);
|
|
247
|
+
color: var(--ib-primary);
|
|
248
|
+
cursor: pointer;
|
|
249
|
+
transition: background 0.15s, color 0.15s;
|
|
250
|
+
padding: 0;
|
|
251
|
+
margin: 0;
|
|
252
|
+
flex-shrink: 0;
|
|
253
|
+
-webkit-appearance: none;
|
|
254
|
+
appearance: none;
|
|
255
|
+
box-sizing: border-box;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.ib-modal-thumb:hover {
|
|
259
|
+
background: var(--ib-primary);
|
|
260
|
+
color: var(--ib-surface);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.ib-modal-thumb:focus {
|
|
264
|
+
outline: 1px solid var(--ib-primary);
|
|
265
|
+
outline-offset: -1px;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.ib-modal-thumb--active {
|
|
269
|
+
background: var(--ib-selected);
|
|
270
|
+
color: var(--ib-selected-color);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.ib-modal-thumb--active:hover {
|
|
274
|
+
background: var(--ib-primary-hover);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/* \u2500\u2500 Dark theme \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
278
|
+
|
|
279
|
+
@media (prefers-color-scheme: dark) {
|
|
280
|
+
#ib-modal:not(.ib-theme-light),
|
|
281
|
+
#ib-modal.ib-theme-dark {
|
|
282
|
+
--ib-primary: #3A5244;
|
|
283
|
+
--ib-primary-hover: #4E6857;
|
|
284
|
+
--ib-background: #25272B;
|
|
285
|
+
--ib-surface: #2C3630;
|
|
286
|
+
--ib-text: #E5E7EB;
|
|
287
|
+
--ib-muted: #9CA3AF;
|
|
288
|
+
--ib-border: #363840;
|
|
289
|
+
--ib-focus-color: #7B9B82;
|
|
290
|
+
--ib-input-hover-border: rgba(255, 255, 255, 0.2);
|
|
291
|
+
--ib-radius: 8px;
|
|
292
|
+
--ib-radius-input: 4px;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
#ib-modal.ib-theme-dark {
|
|
297
|
+
--ib-primary: #3A5244;
|
|
298
|
+
--ib-primary-hover: #4E6857;
|
|
299
|
+
--ib-background: #25272B;
|
|
300
|
+
--ib-surface: #2C3630;
|
|
301
|
+
--ib-text: #E5E7EB;
|
|
302
|
+
--ib-muted: #9CA3AF;
|
|
303
|
+
--ib-border: #363840;
|
|
304
|
+
--ib-focus-color: #7B9B82;
|
|
305
|
+
--ib-input-hover-border: rgba(255, 255, 255, 0.2);
|
|
306
|
+
--ib-radius: 8px;
|
|
307
|
+
--ib-radius-input: 4px;
|
|
308
|
+
}
|
|
309
|
+
`;var r=document.currentScript;function G(){if(document.getElementById("ib-modal-styles"))return;let a=document.createElement("style");a.id="ib-modal-styles",a.textContent=O,document.head.appendChild(a)}function P(a){a.injectStyles!==!1&&G();let i=S(a),e=null,b=null;return a.attachTo&&(e=document.querySelector(a.attachTo),e&&(b=()=>i.open(),e.addEventListener("click",b))),{open:n=>i.open(n),close:()=>i.close(),on:(n,s)=>i.on(n,s),destroy:()=>{e&&b&&(e.removeEventListener("click",b),e=null,b=null),i.destroy()}}}var j={createModal:P,version:L};window.InputBufferIO=j;(function(){let i=r==null?void 0:r.dataset.apiKey;if(!i)return;let e=r==null?void 0:r.dataset.injectStyles,b=P({apiKey:i,apiUrl:r==null?void 0:r.dataset.apiUrl,attachTo:r==null?void 0:r.dataset.attachTo,injectStyles:e===void 0?!0:e!=="false",theme:{primary:r==null?void 0:r.dataset.themePrimary,background:r==null?void 0:r.dataset.themeBackground,text:r==null?void 0:r.dataset.themeText,selected:r==null?void 0:r.dataset.themeSelected,selectedColor:r==null?void 0:r.dataset.themeSelectedColor}});j._defaultInstance=b})();})();
|
package/dist/theme.d.ts
ADDED