@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
package/dist/bar.d.ts
ADDED
package/dist/bar.esm.js
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
var S="0.1.0",G="https://inputbuffer.io/api/v0/inputs";async function M(t,n,o,s,r,h){var p;let a={description:n};if(s&&(a.title=s),o&&(a.contactEmail=o),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 c=new AbortController,m=setTimeout(()=>c.abort(),1e4),l;try{l=await fetch(h!=null?h:G,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-IB-Client":`inputbuffer-widget/${S} (javascript)`},body:JSON.stringify(a),credentials:"omit",signal:c.signal})}finally{clearTimeout(m)}if(!l.ok){let i=await l.json().catch(()=>({}));throw new Error(((p=i==null?void 0:i.error)==null?void 0:p.message)||"Submission failed. Please try again.")}return l.json()}function H(t){let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("width","18"),n.setAttribute("height","18"),n.setAttribute("fill","currentColor"),n.setAttribute("aria-hidden","true"),n.style.display="block";let o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("d",t),n.appendChild(o),n}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",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 L(t){var j,O;let n,o={vote:[],open:[],submit:[],close:[],error:[]};function s(e,g){var y;(y=o[e])==null||y.forEach(E=>E(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 c=document.createElement("div");c.className="ib-bar";let m=document.createElement("div");m.className="ib-bar-label-area";let l=document.createElement("span");l.className="ib-bar-label",l.textContent=(j=t.label)!=null?j:"Was this helpful?",m.appendChild(l);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(H(U));let d=document.createElement("button");d.type="button",d.className="ib-bar-btn ib-bar-btn--down",d.setAttribute("aria-label","No"),d.appendChild(H(q)),p.appendChild(i),p.appendChild(d),t.showLabel!==!1&&c.appendChild(m),c.appendChild(p);let b=document.createElement("div");b.className="ib-bar-popover",b.setAttribute("role","dialog"),b.setAttribute("aria-modal","false");let N=document.createElement("div");if(N.className="ib-bar-header",t.modalTitle){b.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 b.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=(O=t.modalPlaceholder)!=null?O:"What's on your mind?",v.setAttribute("aria-label","Feedback");let x=document.createElement("p");x.className="ib-bar-error";let C=document.createElement("p");C.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(C);let B=document.createElement("div");B.className="ib-bar-footer",B.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),B.appendChild(I),f.appendChild(B),b.appendChild(N),b.appendChild(f),r.appendChild(b),r.appendChild(c);function F(e){n=e,b.classList.add("ib-bar-popover--visible"),x.textContent="",C.textContent="",v.focus(),setTimeout(()=>document.addEventListener("click",T),0),document.addEventListener("keydown",z),s("open",{sentiment:e})}function A(){b.classList.contains("ib-bar-popover--visible")&&(b.classList.remove("ib-bar-popover--visible"),document.removeEventListener("click",T),document.removeEventListener("keydown",z),v.value="",s("close"))}function V(){i.classList.remove("ib-bar-btn--active"),d.classList.remove("ib-bar-btn--active"),n=void 0}function T(e){r.contains(e.target)||A()}function z(e){e.key==="Escape"&&A()}async function W(){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=b.querySelector(".ib-bar-title-input"),y=(g==null?void 0:g.value.trim())||null,E=b.querySelector(".ib-bar-email"),K=(E==null?void 0:E.value.trim())||null;try{let k=await M(t.apiKey,e,K,y,{sentiment:n,target:t.target,source:t.source},t.apiUrl);s("submit",k),C.textContent="Thanks for your feedback!",u.textContent="Send feedback",setTimeout(()=>{A(),V()},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 P(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"}),P(i),F("positive")}),d.addEventListener("click",()=>{s("vote",{sentiment:"negative"}),P(d),F("negative")}),u.addEventListener("click",W),{element:r,on(e,g){var y;(y=o[e])==null||y.push(g)},destroy(){A(),r.remove()}}}var R=`/* InputBuffer Feedback Bar Styles
|
|
2
|
+
* .ib-bar-* and .ib-bar-popover* classes are stable public API \u2014 do not rename them.
|
|
3
|
+
* Developers may target these classes from their own stylesheets to customize the widget.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.ib-bar-wrapper {
|
|
7
|
+
--ib-primary: #6366f1;
|
|
8
|
+
--ib-primary-hover: #4338ca;
|
|
9
|
+
--ib-background: #f6f6f8;
|
|
10
|
+
--ib-surface: #ffffff;
|
|
11
|
+
--ib-text: #111827;
|
|
12
|
+
--ib-muted: #8d99ae;
|
|
13
|
+
--ib-border: var(--ib-primary);
|
|
14
|
+
--ib-focus-color: var(--ib-primary);
|
|
15
|
+
--ib-input-hover-border: var(--ib-border);
|
|
16
|
+
--ib-selected: var(--ib-primary);
|
|
17
|
+
--ib-selected-color: var(--ib-surface);
|
|
18
|
+
--ib-radius: 2px;
|
|
19
|
+
--ib-radius-input: 2px;
|
|
20
|
+
|
|
21
|
+
position: relative;
|
|
22
|
+
display: inline-block;
|
|
23
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.ib-bar-wrapper--fixed {
|
|
27
|
+
position: fixed;
|
|
28
|
+
bottom: 32px;
|
|
29
|
+
right: 32px;
|
|
30
|
+
z-index: 9998;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.ib-bar {
|
|
34
|
+
display: inline-flex;
|
|
35
|
+
align-items: stretch;
|
|
36
|
+
height: 40px;
|
|
37
|
+
width: 100%;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
|
|
40
|
+
background-color: var(--ib-background);
|
|
41
|
+
border: 1px solid var(--ib-border);
|
|
42
|
+
border-radius: 2px;
|
|
43
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.ib-bar-popover {
|
|
48
|
+
display: none;
|
|
49
|
+
position: absolute;
|
|
50
|
+
bottom: calc(100% + 8px);
|
|
51
|
+
right: 0;
|
|
52
|
+
width: 320px;
|
|
53
|
+
|
|
54
|
+
border: 1px solid var(--ib-border);
|
|
55
|
+
border-radius: var(--ib-radius);
|
|
56
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
|
|
57
|
+
box-sizing: border-box;
|
|
58
|
+
z-index: 9999;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.ib-bar-popover--visible {
|
|
63
|
+
display: block;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.ib-bar-header {
|
|
67
|
+
background: var(--ib-surface);
|
|
68
|
+
padding: 12px 16px;
|
|
69
|
+
border-bottom: 1px solid var(--ib-border);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.ib-bar-body {
|
|
73
|
+
background: var(--ib-background);
|
|
74
|
+
padding: 16px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.ib-bar-title {
|
|
78
|
+
font-size: 11px;
|
|
79
|
+
font-weight: 600;
|
|
80
|
+
text-transform: uppercase;
|
|
81
|
+
letter-spacing: 0.1em;
|
|
82
|
+
color: var(--ib-text);
|
|
83
|
+
margin: 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.ib-bar-textarea {
|
|
87
|
+
width: 100%;
|
|
88
|
+
background: var(--ib-background);
|
|
89
|
+
border: 1px solid var(--ib-border);
|
|
90
|
+
border-radius: var(--ib-radius-input);
|
|
91
|
+
padding: 10px 12px;
|
|
92
|
+
font-size: 14px;
|
|
93
|
+
font-family: inherit;
|
|
94
|
+
color: var(--ib-text);
|
|
95
|
+
resize: vertical;
|
|
96
|
+
min-height: 80px;
|
|
97
|
+
box-sizing: border-box;
|
|
98
|
+
outline: none;
|
|
99
|
+
display: block;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.ib-bar-textarea:hover {
|
|
103
|
+
border-color: var(--ib-input-hover-border);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.ib-bar-textarea:focus {
|
|
107
|
+
border-color: var(--ib-focus-color);
|
|
108
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input,
|
|
112
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-email {
|
|
113
|
+
width: 100%;
|
|
114
|
+
background: var(--ib-background);
|
|
115
|
+
border: 1px solid var(--ib-border);
|
|
116
|
+
border-radius: var(--ib-radius-input);
|
|
117
|
+
padding: 8px 12px;
|
|
118
|
+
font-size: 14px;
|
|
119
|
+
font-family: inherit;
|
|
120
|
+
color: var(--ib-text);
|
|
121
|
+
box-sizing: border-box;
|
|
122
|
+
outline: none;
|
|
123
|
+
display: block;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.ib-bar-title-input {
|
|
127
|
+
margin-bottom: 8px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.ib-bar-email {
|
|
131
|
+
margin-top: 8px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:hover,
|
|
135
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-email:hover {
|
|
136
|
+
border-color: var(--ib-input-hover-border);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:focus,
|
|
140
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-email:focus {
|
|
141
|
+
border-color: var(--ib-focus-color);
|
|
142
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.ib-bar-submit {
|
|
146
|
+
background: var(--ib-primary);
|
|
147
|
+
color: #ffffff;
|
|
148
|
+
border: none;
|
|
149
|
+
border-radius: var(--ib-radius-input);
|
|
150
|
+
padding: 8px 16px;
|
|
151
|
+
font-size: 11px;
|
|
152
|
+
font-weight: 600;
|
|
153
|
+
text-transform: uppercase;
|
|
154
|
+
letter-spacing: 0.08em;
|
|
155
|
+
font-family: inherit;
|
|
156
|
+
cursor: pointer;
|
|
157
|
+
display: inline-block;
|
|
158
|
+
transition: background 0.15s;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.ib-bar-submit:hover {
|
|
162
|
+
background: var(--ib-primary-hover);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.ib-bar-submit:disabled {
|
|
166
|
+
opacity: 0.6;
|
|
167
|
+
cursor: not-allowed;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.ib-bar-footer {
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
justify-content: space-between;
|
|
174
|
+
margin-top: 10px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.ib-branding a {
|
|
178
|
+
font-size: 10px;
|
|
179
|
+
color: var(--ib-muted);
|
|
180
|
+
text-decoration: none;
|
|
181
|
+
letter-spacing: 0.03em;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.ib-branding a:hover {
|
|
185
|
+
color: var(--ib-primary);
|
|
186
|
+
text-decoration: underline;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.ib-bar-error,
|
|
190
|
+
.ib-bar-success {
|
|
191
|
+
font-size: 11px;
|
|
192
|
+
font-weight: 600;
|
|
193
|
+
text-transform: uppercase;
|
|
194
|
+
letter-spacing: 0.08em;
|
|
195
|
+
margin: 8px 0 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.ib-bar-error:empty,
|
|
199
|
+
.ib-bar-success:empty {
|
|
200
|
+
display: none;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.ib-bar-error {
|
|
204
|
+
color: #dc2626;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.ib-bar-success {
|
|
208
|
+
color: #16a34a;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.ib-bar-label-area {
|
|
212
|
+
flex: 1;
|
|
213
|
+
display: flex;
|
|
214
|
+
align-items: center;
|
|
215
|
+
padding: 0 16px;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.ib-bar-label {
|
|
219
|
+
font-size: 11px;
|
|
220
|
+
font-weight: 600;
|
|
221
|
+
color: var(--ib-muted);
|
|
222
|
+
text-transform: uppercase;
|
|
223
|
+
letter-spacing: 0.1em;
|
|
224
|
+
white-space: nowrap;
|
|
225
|
+
user-select: none;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.ib-bar-actions {
|
|
229
|
+
display: flex;
|
|
230
|
+
align-items: stretch;
|
|
231
|
+
background: var(--ib-background);
|
|
232
|
+
border-left: 1px solid var(--ib-border);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.ib-bar-actions--no-label {
|
|
236
|
+
border-left: none;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.ib-bar-btn {
|
|
240
|
+
width: 40px;
|
|
241
|
+
display: flex;
|
|
242
|
+
align-items: center;
|
|
243
|
+
justify-content: center;
|
|
244
|
+
background: var(--ib-background);
|
|
245
|
+
border: none;
|
|
246
|
+
border-right: 1px solid var(--ib-border);
|
|
247
|
+
border-radius: 0;
|
|
248
|
+
color: var(--ib-primary);
|
|
249
|
+
cursor: pointer;
|
|
250
|
+
transition: background 0.15s, color 0.15s, transform 0.1s;
|
|
251
|
+
padding: 0;
|
|
252
|
+
-webkit-appearance: none;
|
|
253
|
+
appearance: none;
|
|
254
|
+
box-sizing: border-box;
|
|
255
|
+
margin: 0;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.ib-bar-btn--down {
|
|
259
|
+
border-right: none;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.ib-bar-btn:hover {
|
|
263
|
+
background: var(--ib-primary);
|
|
264
|
+
color: var(--ib-surface);
|
|
265
|
+
transform: scale(1.15);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.ib-bar-btn:active {
|
|
269
|
+
transform: scale(0.95);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.ib-bar-btn:focus {
|
|
273
|
+
outline: 1px solid var(--ib-primary);
|
|
274
|
+
outline-offset: -1px;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.ib-bar-btn--active {
|
|
278
|
+
background: var(--ib-selected);
|
|
279
|
+
color: var(--ib-selected-color);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.ib-bar-btn--active:hover {
|
|
283
|
+
background: var(--ib-primary-hover, var(--ib-primary));
|
|
284
|
+
color: var(--ib-surface);
|
|
285
|
+
transform: scale(1.1);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/* \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 */
|
|
289
|
+
|
|
290
|
+
@media (prefers-color-scheme: dark) {
|
|
291
|
+
.ib-bar-wrapper:not(.ib-theme-light),
|
|
292
|
+
.ib-bar-wrapper.ib-theme-dark {
|
|
293
|
+
--ib-primary: #3A5244;
|
|
294
|
+
--ib-primary-hover: #4E6857;
|
|
295
|
+
--ib-background: #25272B;
|
|
296
|
+
--ib-surface: #2C3630;
|
|
297
|
+
--ib-text: #E5E7EB;
|
|
298
|
+
--ib-muted: #9CA3AF;
|
|
299
|
+
--ib-border: #363840;
|
|
300
|
+
--ib-focus-color: #7B9B82;
|
|
301
|
+
--ib-input-hover-border: rgba(255, 255, 255, 0.2);
|
|
302
|
+
--ib-selected: #7B9B82;
|
|
303
|
+
--ib-selected-color: #1a2420;
|
|
304
|
+
--ib-radius: 8px;
|
|
305
|
+
--ib-radius-input: 4px;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.ib-bar-wrapper.ib-theme-dark {
|
|
310
|
+
--ib-primary: #3A5244;
|
|
311
|
+
--ib-primary-hover: #4E6857;
|
|
312
|
+
--ib-background: #25272B;
|
|
313
|
+
--ib-surface: #2C3630;
|
|
314
|
+
--ib-text: #E5E7EB;
|
|
315
|
+
--ib-muted: #9CA3AF;
|
|
316
|
+
--ib-border: #363840;
|
|
317
|
+
--ib-focus-color: #7B9B82;
|
|
318
|
+
--ib-input-hover-border: rgba(255, 255, 255, 0.2);
|
|
319
|
+
--ib-selected: #7B9B82;
|
|
320
|
+
--ib-selected-color: #1a2420;
|
|
321
|
+
--ib-radius: 8px;
|
|
322
|
+
--ib-radius-input: 4px;
|
|
323
|
+
}
|
|
324
|
+
`;function D(){if(typeof document=="undefined"||document.getElementById("ib-bar-styles"))return;let t=document.createElement("style");t.id="ib-bar-styles",t.textContent=R,document.head.appendChild(t)}function $(t){return t.injectStyles!==!1&&D(),L(t)}var _=class extends HTMLElement{constructor(){super(...arguments);this._bar=null}connectedCallback(){var a,c,m,l,p,i,d;let o=this.getAttribute("api-key");if(!o)return;let s=this.getAttribute("inject-styles");(s===null?!0:s!=="false")&&D();let h=this.getAttribute("placement");this._bar=L({apiKey:o,apiUrl:(a=this.getAttribute("api-url"))!=null?a:void 0,label:(c=this.getAttribute("label"))!=null?c:void 0,placement:h==="fixed"?"fixed":"inline",theme:{primary:(m=this.getAttribute("theme-primary"))!=null?m:void 0,background:(l=this.getAttribute("theme-background"))!=null?l: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 o;(o=this._bar)==null||o.destroy(),this._bar=null}};typeof customElements!="undefined"&&!customElements.get("inputbuffer-feedback")&&customElements.define("inputbuffer-feedback",_);var J={createBar:$,version:S};typeof window!="undefined"&&(window.InputBufferIO=J);export{J as InputBufferIO,$ as createBar};
|
package/dist/bar.js
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use strict";(()=>{var S="0.1.0",G="https://inputbuffer.io/api/v0/inputs";async function M(t,n,o,s,r,h){var p;let a={description:n};if(s&&(a.title=s),o&&(a.contactEmail=o),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 c=new AbortController,m=setTimeout(()=>c.abort(),1e4),l;try{l=await fetch(h!=null?h:G,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-IB-Client":`inputbuffer-widget/${S} (javascript)`},body:JSON.stringify(a),credentials:"omit",signal:c.signal})}finally{clearTimeout(m)}if(!l.ok){let i=await l.json().catch(()=>({}));throw new Error(((p=i==null?void 0:i.error)==null?void 0:p.message)||"Submission failed. Please try again.")}return l.json()}function H(t){let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("width","18"),n.setAttribute("height","18"),n.setAttribute("fill","currentColor"),n.setAttribute("aria-hidden","true"),n.style.display="block";let o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("d",t),n.appendChild(o),n}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",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 L(t){var j,O;let n,o={vote:[],open:[],submit:[],close:[],error:[]};function s(e,g){var y;(y=o[e])==null||y.forEach(E=>E(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 c=document.createElement("div");c.className="ib-bar";let m=document.createElement("div");m.className="ib-bar-label-area";let l=document.createElement("span");l.className="ib-bar-label",l.textContent=(j=t.label)!=null?j:"Was this helpful?",m.appendChild(l);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(H(U));let d=document.createElement("button");d.type="button",d.className="ib-bar-btn ib-bar-btn--down",d.setAttribute("aria-label","No"),d.appendChild(H(q)),p.appendChild(i),p.appendChild(d),t.showLabel!==!1&&c.appendChild(m),c.appendChild(p);let b=document.createElement("div");b.className="ib-bar-popover",b.setAttribute("role","dialog"),b.setAttribute("aria-modal","false");let N=document.createElement("div");if(N.className="ib-bar-header",t.modalTitle){b.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 b.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=(O=t.modalPlaceholder)!=null?O:"What's on your mind?",v.setAttribute("aria-label","Feedback");let x=document.createElement("p");x.className="ib-bar-error";let C=document.createElement("p");C.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(C);let B=document.createElement("div");B.className="ib-bar-footer",B.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),B.appendChild(I),f.appendChild(B),b.appendChild(N),b.appendChild(f),r.appendChild(b),r.appendChild(c);function F(e){n=e,b.classList.add("ib-bar-popover--visible"),x.textContent="",C.textContent="",v.focus(),setTimeout(()=>document.addEventListener("click",T),0),document.addEventListener("keydown",z),s("open",{sentiment:e})}function A(){b.classList.contains("ib-bar-popover--visible")&&(b.classList.remove("ib-bar-popover--visible"),document.removeEventListener("click",T),document.removeEventListener("keydown",z),v.value="",s("close"))}function V(){i.classList.remove("ib-bar-btn--active"),d.classList.remove("ib-bar-btn--active"),n=void 0}function T(e){r.contains(e.target)||A()}function z(e){e.key==="Escape"&&A()}async function W(){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=b.querySelector(".ib-bar-title-input"),y=(g==null?void 0:g.value.trim())||null,E=b.querySelector(".ib-bar-email"),K=(E==null?void 0:E.value.trim())||null;try{let k=await M(t.apiKey,e,K,y,{sentiment:n,target:t.target,source:t.source},t.apiUrl);s("submit",k),C.textContent="Thanks for your feedback!",u.textContent="Send feedback",setTimeout(()=>{A(),V()},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 P(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"}),P(i),F("positive")}),d.addEventListener("click",()=>{s("vote",{sentiment:"negative"}),P(d),F("negative")}),u.addEventListener("click",W),{element:r,on(e,g){var y;(y=o[e])==null||y.push(g)},destroy(){A(),r.remove()}}}var R=`/* InputBuffer Feedback Bar Styles
|
|
2
|
+
* .ib-bar-* and .ib-bar-popover* classes are stable public API \u2014 do not rename them.
|
|
3
|
+
* Developers may target these classes from their own stylesheets to customize the widget.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.ib-bar-wrapper {
|
|
7
|
+
--ib-primary: #6366f1;
|
|
8
|
+
--ib-primary-hover: #4338ca;
|
|
9
|
+
--ib-background: #f6f6f8;
|
|
10
|
+
--ib-surface: #ffffff;
|
|
11
|
+
--ib-text: #111827;
|
|
12
|
+
--ib-muted: #8d99ae;
|
|
13
|
+
--ib-border: var(--ib-primary);
|
|
14
|
+
--ib-focus-color: var(--ib-primary);
|
|
15
|
+
--ib-input-hover-border: var(--ib-border);
|
|
16
|
+
--ib-selected: var(--ib-primary);
|
|
17
|
+
--ib-selected-color: var(--ib-surface);
|
|
18
|
+
--ib-radius: 2px;
|
|
19
|
+
--ib-radius-input: 2px;
|
|
20
|
+
|
|
21
|
+
position: relative;
|
|
22
|
+
display: inline-block;
|
|
23
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.ib-bar-wrapper--fixed {
|
|
27
|
+
position: fixed;
|
|
28
|
+
bottom: 32px;
|
|
29
|
+
right: 32px;
|
|
30
|
+
z-index: 9998;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.ib-bar {
|
|
34
|
+
display: inline-flex;
|
|
35
|
+
align-items: stretch;
|
|
36
|
+
height: 40px;
|
|
37
|
+
width: 100%;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
|
|
40
|
+
background-color: var(--ib-background);
|
|
41
|
+
border: 1px solid var(--ib-border);
|
|
42
|
+
border-radius: 2px;
|
|
43
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.ib-bar-popover {
|
|
48
|
+
display: none;
|
|
49
|
+
position: absolute;
|
|
50
|
+
bottom: calc(100% + 8px);
|
|
51
|
+
right: 0;
|
|
52
|
+
width: 320px;
|
|
53
|
+
|
|
54
|
+
border: 1px solid var(--ib-border);
|
|
55
|
+
border-radius: var(--ib-radius);
|
|
56
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
|
|
57
|
+
box-sizing: border-box;
|
|
58
|
+
z-index: 9999;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.ib-bar-popover--visible {
|
|
63
|
+
display: block;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.ib-bar-header {
|
|
67
|
+
background: var(--ib-surface);
|
|
68
|
+
padding: 12px 16px;
|
|
69
|
+
border-bottom: 1px solid var(--ib-border);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.ib-bar-body {
|
|
73
|
+
background: var(--ib-background);
|
|
74
|
+
padding: 16px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.ib-bar-title {
|
|
78
|
+
font-size: 11px;
|
|
79
|
+
font-weight: 600;
|
|
80
|
+
text-transform: uppercase;
|
|
81
|
+
letter-spacing: 0.1em;
|
|
82
|
+
color: var(--ib-text);
|
|
83
|
+
margin: 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.ib-bar-textarea {
|
|
87
|
+
width: 100%;
|
|
88
|
+
background: var(--ib-background);
|
|
89
|
+
border: 1px solid var(--ib-border);
|
|
90
|
+
border-radius: var(--ib-radius-input);
|
|
91
|
+
padding: 10px 12px;
|
|
92
|
+
font-size: 14px;
|
|
93
|
+
font-family: inherit;
|
|
94
|
+
color: var(--ib-text);
|
|
95
|
+
resize: vertical;
|
|
96
|
+
min-height: 80px;
|
|
97
|
+
box-sizing: border-box;
|
|
98
|
+
outline: none;
|
|
99
|
+
display: block;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.ib-bar-textarea:hover {
|
|
103
|
+
border-color: var(--ib-input-hover-border);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.ib-bar-textarea:focus {
|
|
107
|
+
border-color: var(--ib-focus-color);
|
|
108
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input,
|
|
112
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-email {
|
|
113
|
+
width: 100%;
|
|
114
|
+
background: var(--ib-background);
|
|
115
|
+
border: 1px solid var(--ib-border);
|
|
116
|
+
border-radius: var(--ib-radius-input);
|
|
117
|
+
padding: 8px 12px;
|
|
118
|
+
font-size: 14px;
|
|
119
|
+
font-family: inherit;
|
|
120
|
+
color: var(--ib-text);
|
|
121
|
+
box-sizing: border-box;
|
|
122
|
+
outline: none;
|
|
123
|
+
display: block;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.ib-bar-title-input {
|
|
127
|
+
margin-bottom: 8px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.ib-bar-email {
|
|
131
|
+
margin-top: 8px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:hover,
|
|
135
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-email:hover {
|
|
136
|
+
border-color: var(--ib-input-hover-border);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-title-input:focus,
|
|
140
|
+
.ib-bar-wrapper .ib-bar-body .ib-bar-email:focus {
|
|
141
|
+
border-color: var(--ib-focus-color);
|
|
142
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-focus-color) 15%, transparent);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.ib-bar-submit {
|
|
146
|
+
background: var(--ib-primary);
|
|
147
|
+
color: #ffffff;
|
|
148
|
+
border: none;
|
|
149
|
+
border-radius: var(--ib-radius-input);
|
|
150
|
+
padding: 8px 16px;
|
|
151
|
+
font-size: 11px;
|
|
152
|
+
font-weight: 600;
|
|
153
|
+
text-transform: uppercase;
|
|
154
|
+
letter-spacing: 0.08em;
|
|
155
|
+
font-family: inherit;
|
|
156
|
+
cursor: pointer;
|
|
157
|
+
display: inline-block;
|
|
158
|
+
transition: background 0.15s;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.ib-bar-submit:hover {
|
|
162
|
+
background: var(--ib-primary-hover);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.ib-bar-submit:disabled {
|
|
166
|
+
opacity: 0.6;
|
|
167
|
+
cursor: not-allowed;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.ib-bar-footer {
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
justify-content: space-between;
|
|
174
|
+
margin-top: 10px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.ib-branding a {
|
|
178
|
+
font-size: 10px;
|
|
179
|
+
color: var(--ib-muted);
|
|
180
|
+
text-decoration: none;
|
|
181
|
+
letter-spacing: 0.03em;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.ib-branding a:hover {
|
|
185
|
+
color: var(--ib-primary);
|
|
186
|
+
text-decoration: underline;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.ib-bar-error,
|
|
190
|
+
.ib-bar-success {
|
|
191
|
+
font-size: 11px;
|
|
192
|
+
font-weight: 600;
|
|
193
|
+
text-transform: uppercase;
|
|
194
|
+
letter-spacing: 0.08em;
|
|
195
|
+
margin: 8px 0 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.ib-bar-error:empty,
|
|
199
|
+
.ib-bar-success:empty {
|
|
200
|
+
display: none;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.ib-bar-error {
|
|
204
|
+
color: #dc2626;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.ib-bar-success {
|
|
208
|
+
color: #16a34a;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.ib-bar-label-area {
|
|
212
|
+
flex: 1;
|
|
213
|
+
display: flex;
|
|
214
|
+
align-items: center;
|
|
215
|
+
padding: 0 16px;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.ib-bar-label {
|
|
219
|
+
font-size: 11px;
|
|
220
|
+
font-weight: 600;
|
|
221
|
+
color: var(--ib-muted);
|
|
222
|
+
text-transform: uppercase;
|
|
223
|
+
letter-spacing: 0.1em;
|
|
224
|
+
white-space: nowrap;
|
|
225
|
+
user-select: none;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.ib-bar-actions {
|
|
229
|
+
display: flex;
|
|
230
|
+
align-items: stretch;
|
|
231
|
+
background: var(--ib-background);
|
|
232
|
+
border-left: 1px solid var(--ib-border);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.ib-bar-actions--no-label {
|
|
236
|
+
border-left: none;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.ib-bar-btn {
|
|
240
|
+
width: 40px;
|
|
241
|
+
display: flex;
|
|
242
|
+
align-items: center;
|
|
243
|
+
justify-content: center;
|
|
244
|
+
background: var(--ib-background);
|
|
245
|
+
border: none;
|
|
246
|
+
border-right: 1px solid var(--ib-border);
|
|
247
|
+
border-radius: 0;
|
|
248
|
+
color: var(--ib-primary);
|
|
249
|
+
cursor: pointer;
|
|
250
|
+
transition: background 0.15s, color 0.15s, transform 0.1s;
|
|
251
|
+
padding: 0;
|
|
252
|
+
-webkit-appearance: none;
|
|
253
|
+
appearance: none;
|
|
254
|
+
box-sizing: border-box;
|
|
255
|
+
margin: 0;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.ib-bar-btn--down {
|
|
259
|
+
border-right: none;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.ib-bar-btn:hover {
|
|
263
|
+
background: var(--ib-primary);
|
|
264
|
+
color: var(--ib-surface);
|
|
265
|
+
transform: scale(1.15);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.ib-bar-btn:active {
|
|
269
|
+
transform: scale(0.95);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.ib-bar-btn:focus {
|
|
273
|
+
outline: 1px solid var(--ib-primary);
|
|
274
|
+
outline-offset: -1px;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.ib-bar-btn--active {
|
|
278
|
+
background: var(--ib-selected);
|
|
279
|
+
color: var(--ib-selected-color);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.ib-bar-btn--active:hover {
|
|
283
|
+
background: var(--ib-primary-hover, var(--ib-primary));
|
|
284
|
+
color: var(--ib-surface);
|
|
285
|
+
transform: scale(1.1);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/* \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 */
|
|
289
|
+
|
|
290
|
+
@media (prefers-color-scheme: dark) {
|
|
291
|
+
.ib-bar-wrapper:not(.ib-theme-light),
|
|
292
|
+
.ib-bar-wrapper.ib-theme-dark {
|
|
293
|
+
--ib-primary: #3A5244;
|
|
294
|
+
--ib-primary-hover: #4E6857;
|
|
295
|
+
--ib-background: #25272B;
|
|
296
|
+
--ib-surface: #2C3630;
|
|
297
|
+
--ib-text: #E5E7EB;
|
|
298
|
+
--ib-muted: #9CA3AF;
|
|
299
|
+
--ib-border: #363840;
|
|
300
|
+
--ib-focus-color: #7B9B82;
|
|
301
|
+
--ib-input-hover-border: rgba(255, 255, 255, 0.2);
|
|
302
|
+
--ib-selected: #7B9B82;
|
|
303
|
+
--ib-selected-color: #1a2420;
|
|
304
|
+
--ib-radius: 8px;
|
|
305
|
+
--ib-radius-input: 4px;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.ib-bar-wrapper.ib-theme-dark {
|
|
310
|
+
--ib-primary: #3A5244;
|
|
311
|
+
--ib-primary-hover: #4E6857;
|
|
312
|
+
--ib-background: #25272B;
|
|
313
|
+
--ib-surface: #2C3630;
|
|
314
|
+
--ib-text: #E5E7EB;
|
|
315
|
+
--ib-muted: #9CA3AF;
|
|
316
|
+
--ib-border: #363840;
|
|
317
|
+
--ib-focus-color: #7B9B82;
|
|
318
|
+
--ib-input-hover-border: rgba(255, 255, 255, 0.2);
|
|
319
|
+
--ib-selected: #7B9B82;
|
|
320
|
+
--ib-selected-color: #1a2420;
|
|
321
|
+
--ib-radius: 8px;
|
|
322
|
+
--ib-radius-input: 4px;
|
|
323
|
+
}
|
|
324
|
+
`;function D(){if(typeof document=="undefined"||document.getElementById("ib-bar-styles"))return;let t=document.createElement("style");t.id="ib-bar-styles",t.textContent=R,document.head.appendChild(t)}function $(t){return t.injectStyles!==!1&&D(),L(t)}var _=class extends HTMLElement{constructor(){super(...arguments);this._bar=null}connectedCallback(){var a,c,m,l,p,i,d;let o=this.getAttribute("api-key");if(!o)return;let s=this.getAttribute("inject-styles");(s===null?!0:s!=="false")&&D();let h=this.getAttribute("placement");this._bar=L({apiKey:o,apiUrl:(a=this.getAttribute("api-url"))!=null?a:void 0,label:(c=this.getAttribute("label"))!=null?c:void 0,placement:h==="fixed"?"fixed":"inline",theme:{primary:(m=this.getAttribute("theme-primary"))!=null?m:void 0,background:(l=this.getAttribute("theme-background"))!=null?l: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 o;(o=this._bar)==null||o.destroy(),this._bar=null}};typeof customElements!="undefined"&&!customElements.get("inputbuffer-feedback")&&customElements.define("inputbuffer-feedback",_);var J={createBar:$,version:S};typeof window!="undefined"&&(window.InputBufferIO=J);})();
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WidgetConfig, OpenOptions, WidgetInstance, FeedbackBarConfig, FeedbackBarInstance } from './types.js';
|
|
2
|
+
declare function createModal(config: WidgetConfig): WidgetInstance;
|
|
3
|
+
declare function createBar(config: FeedbackBarConfig): FeedbackBarInstance;
|
|
4
|
+
declare const InputBufferIO: {
|
|
5
|
+
createModal: typeof createModal;
|
|
6
|
+
createBar: typeof createBar;
|
|
7
|
+
version: string;
|
|
8
|
+
};
|
|
9
|
+
declare global {
|
|
10
|
+
interface Window {
|
|
11
|
+
InputBufferIO: typeof InputBufferIO;
|
|
12
|
+
}
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
'inputbuffer-feedback': HTMLElement;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export type { WidgetConfig, OpenOptions, WidgetInstance, FeedbackBarConfig, FeedbackBarInstance };
|
|
18
|
+
export { InputBufferIO };
|