@usero/sdk 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -0
- package/dist/all-M6KEAHE5.cjs +9110 -0
- package/dist/all-M6KEAHE5.cjs.map +1 -0
- package/dist/all-T4CCPHSL.js +9095 -0
- package/dist/all-T4CCPHSL.js.map +1 -0
- package/dist/chunk-5BLDMQED.cjs +18 -0
- package/dist/chunk-5BLDMQED.cjs.map +1 -0
- package/dist/chunk-NSBPE2FW.js +15 -0
- package/dist/chunk-NSBPE2FW.js.map +1 -0
- package/dist/plugins/session-replay.cjs +180 -0
- package/dist/plugins/session-replay.cjs.map +1 -0
- package/dist/plugins/session-replay.d.cts +75 -0
- package/dist/plugins/session-replay.d.ts +75 -0
- package/dist/plugins/session-replay.js +177 -0
- package/dist/plugins/session-replay.js.map +1 -0
- package/dist/react.cjs +138 -35
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +23 -0
- package/dist/react.d.ts +23 -0
- package/dist/react.js +138 -35
- package/dist/react.js.map +1 -1
- package/dist/usero.iife.js +59 -52
- package/dist/usero.iife.js.map +1 -1
- package/dist/vanilla.cjs +139 -35
- package/dist/vanilla.cjs.map +1 -1
- package/dist/vanilla.d.cts +25 -1
- package/dist/vanilla.d.ts +25 -1
- package/dist/vanilla.js +139 -36
- package/dist/vanilla.js.map +1 -1
- package/package.json +9 -1
package/dist/usero.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Usero=(function(exports){'use strict';var
|
|
1
|
+
var Usero=(function(exports){'use strict';var ve={1:"\u{1F61E}",2:"\u{1F610}",3:"\u{1F60A}",4:"\u{1F929}"},q={1:"Needs work",2:"It's okay",3:"Pretty good",4:"Amazing!"},ke={1:"linear-gradient(135deg,#ff6b6b14,#ff6b6b1f)",2:"linear-gradient(135deg,#9ca3af0f,#9ca3af1a)",3:"linear-gradient(135deg,#3b82f614,#3b82f61f)",4:"linear-gradient(135deg,#f59e0b14,#f59e0b1f)"},K="https://usero.io",oe={primary:"#2563eb",background:"#ffffff",text:"#374151",border:"#e5e7eb",shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},G={primary:"#2563eb",background:"#1f2937",text:"#f9fafb",border:"#374151",shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2)"};function ze(t={}){return {...oe,...t}}function Ie(t){return typeof t=="object"&&t!==null&&"error"in t}function De(t){if(typeof t!="object"||t===null)return {success:false,error:"Invalid response"};let n=t,o=n.success===true,s=typeof n.error=="string"?n.error:void 0,d=n.screenshot,r;if(typeof d=="object"&&d!==null){let l=d;typeof l.fileName=="string"&&typeof l.url=="string"&&typeof l.fileSize=="number"&&typeof l.mimeType=="string"&&(r={fileName:l.fileName,url:l.url,fileSize:l.fileSize,mimeType:l.mimeType,width:typeof l.width=="number"?l.width:void 0,height:typeof l.height=="number"?l.height:void 0});}return {success:o,error:s,screenshot:r}}var J=class{constructor(n=K){this.baseUrl=n.replace(/\/$/,"");}async submitFeedback(n){try{let o=await fetch(`${this.baseUrl}/api/feedback`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(1e4)});if(!o.ok){let r=`HTTP ${o.status}: ${o.statusText}`;try{let l=await o.json();Ie(l)&&typeof l.error=="string"&&(r=l.error);}catch{}throw new Error(r)}let s=await o.json(),d=typeof s=="object"&&s!==null&&"message"in s&&typeof s.message=="string"?s.message:"Feedback submitted successfully";return {success:!0,data:s,message:d}}catch(o){return {success:false,error:o instanceof Error?o.message:"An unexpected error occurred"}}}async uploadScreenshot(n,o){let s=new FormData;s.append("screenshot",n),s.append("clientId",o);let d=await fetch(`${this.baseUrl}/api/screenshots`,{method:"POST",body:s,signal:AbortSignal.timeout(3e4)}),r={success:false};try{let l=await d.json();r=De(l);}catch{}if(!d.ok||!r.success||!r.screenshot){let l=r.error??`HTTP ${d.status}: ${d.statusText}`;throw new Error(l)}return r.screenshot}ping(){fetch(`${this.baseUrl}/api/ping`,{signal:AbortSignal.timeout(5e3)}).catch(()=>{});}};function He(t){if(t.startsWith("#")||typeof document>"u")return t;let o=document.createElement("canvas").getContext("2d");return o?(o.fillStyle=t,o.fillStyle):t}function ie(t){let n=He(t);if(!n.startsWith("#")||n.length<7)return n;let o=parseInt(n.slice(1,3),16),s=parseInt(n.slice(3,5),16),d=parseInt(n.slice(5,7),16),r=Math.max(0,o-60),l=Math.min(255,s+40),P=Math.min(255,d+20);return `#${[r,l,P].map(R=>R.toString(16).padStart(2,"0")).join("")}`}function we(t){let n=`[usero:${t}]`;return {debug:(...o)=>{typeof console<"u"&&console.debug(n,...o);},info:(...o)=>{typeof console<"u"&&console.info(n,...o);},warn:(...o)=>{typeof console<"u"&&console.warn(n,...o);},error:(...o)=>{typeof console<"u"&&console.error(n,...o);}}}function Se(t){let n=[],o=t.rating!=null,s=!!t.comment?.trim();return !o&&!s&&n.push("Add rating or comment"),o&&t.rating!==void 0&&![1,2,3,4].includes(t.rating)&&n.push("Invalid rating"),s&&t.comment!==void 0&&(t.comment.length>1e3&&n.push("Comment too long"),/<script[^>]*>.*?<\/script>/gi.test(t.comment)&&n.push("Invalid comment")),{isValid:n.length===0,errors:n}}var Ee=`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
0% { transform: rotate(0deg); }
|
|
4
4
|
100% { transform: rotate(360deg); }
|
|
@@ -7,8 +7,8 @@ var Usero=(function(exports){'use strict';var fe={1:"\u{1F61E}",2:"\u{1F610}",3:
|
|
|
7
7
|
.fb-es {
|
|
8
8
|
display: flex;
|
|
9
9
|
justify-content: center;
|
|
10
|
-
gap:
|
|
11
|
-
padding-bottom:
|
|
10
|
+
gap: 12px;
|
|
11
|
+
padding-bottom: 8px;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
.fb-ec {
|
|
@@ -99,7 +99,7 @@ var Usero=(function(exports){'use strict';var fe={1:"\u{1F61E}",2:"\u{1F610}",3:
|
|
|
99
99
|
|
|
100
100
|
.fb-sub {
|
|
101
101
|
width: 100%;
|
|
102
|
-
padding:
|
|
102
|
+
padding: 12px 24px;
|
|
103
103
|
border: none;
|
|
104
104
|
border-radius: 12px;
|
|
105
105
|
font-size: 15px;
|
|
@@ -127,7 +127,7 @@ var Usero=(function(exports){'use strict';var fe={1:"\u{1F61E}",2:"\u{1F610}",3:
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
.fb-cnt {
|
|
130
|
-
padding: 24px;
|
|
130
|
+
padding: 20px 24px 16px;
|
|
131
131
|
overflow: auto;
|
|
132
132
|
max-height: calc(90vh - 48px);
|
|
133
133
|
}
|
|
@@ -140,22 +140,29 @@ var Usero=(function(exports){'use strict';var fe={1:"\u{1F61E}",2:"\u{1F610}",3:
|
|
|
140
140
|
|
|
141
141
|
.fb-ta {
|
|
142
142
|
width: 100%;
|
|
143
|
-
min-height:
|
|
144
|
-
padding:
|
|
143
|
+
min-height: 80px;
|
|
144
|
+
padding: 10px;
|
|
145
145
|
border-radius: 8px;
|
|
146
146
|
font-size: 14px;
|
|
147
147
|
font-family: inherit;
|
|
148
148
|
outline: none;
|
|
149
149
|
resize: vertical;
|
|
150
150
|
transition: border-color 150ms ease;
|
|
151
|
-
margin-bottom:
|
|
151
|
+
margin-bottom: 2px;
|
|
152
152
|
box-sizing: border-box;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
.fb-toolrow {
|
|
156
|
+
display: flex;
|
|
157
|
+
align-items: center;
|
|
158
|
+
justify-content: space-between;
|
|
159
|
+
gap: 12px;
|
|
160
|
+
margin-bottom: 8px;
|
|
161
|
+
}
|
|
162
|
+
|
|
155
163
|
.fb-charcount {
|
|
156
164
|
font-size: 12px;
|
|
157
165
|
margin-left: auto;
|
|
158
|
-
margin-bottom: 8px;
|
|
159
166
|
text-align: right;
|
|
160
167
|
}
|
|
161
168
|
|
|
@@ -166,8 +173,8 @@ var Usero=(function(exports){'use strict';var fe={1:"\u{1F61E}",2:"\u{1F610}",3:
|
|
|
166
173
|
.fb-email {
|
|
167
174
|
display: flex;
|
|
168
175
|
flex-direction: column;
|
|
169
|
-
gap:
|
|
170
|
-
margin-bottom:
|
|
176
|
+
gap: 6px;
|
|
177
|
+
margin-bottom: 10px;
|
|
171
178
|
}
|
|
172
179
|
|
|
173
180
|
.fb-email-lbl {
|
|
@@ -303,8 +310,8 @@ var Usero=(function(exports){'use strict';var fe={1:"\u{1F61E}",2:"\u{1F610}",3:
|
|
|
303
310
|
.fb-up {
|
|
304
311
|
display: flex;
|
|
305
312
|
flex-direction: column;
|
|
306
|
-
gap:
|
|
307
|
-
margin-bottom:
|
|
313
|
+
gap: 6px;
|
|
314
|
+
margin-bottom: 8px;
|
|
308
315
|
}
|
|
309
316
|
|
|
310
317
|
.fb-upb {
|
|
@@ -406,62 +413,62 @@ var Usero=(function(exports){'use strict';var fe={1:"\u{1F61E}",2:"\u{1F610}",3:
|
|
|
406
413
|
.fb-pnl-base {
|
|
407
414
|
width: 100% !important;
|
|
408
415
|
max-width: none !important;
|
|
409
|
-
top:
|
|
410
|
-
max-height:
|
|
416
|
+
top: 4vh !important;
|
|
417
|
+
max-height: 92vh !important;
|
|
411
418
|
}
|
|
412
|
-
.fb-cnt { padding:
|
|
413
|
-
.fb-ta { font-size: 16px !important; min-height:
|
|
419
|
+
.fb-cnt { padding: 16px 18px 14px !important; max-height: calc(100vh - 40px) !important; }
|
|
420
|
+
.fb-ta { font-size: 16px !important; min-height: 64px !important; }
|
|
414
421
|
.fb-ttl { font-size: 18px !important; }
|
|
415
422
|
.fb-ei { font-size: 24px !important; }
|
|
416
423
|
.fb-el { font-size: 11px !important; }
|
|
417
|
-
.fb-sub { padding:
|
|
424
|
+
.fb-sub { padding: 12px 20px !important; font-size: 16px !important; }
|
|
418
425
|
}
|
|
419
|
-
`;function
|
|
420
|
-
<div class="${["fb-ec",p&&"fb-ec--sel"].filter(Boolean).join(" ")}" style="background:${
|
|
421
|
-
<button type="button" class="fb-eb" data-rating="${
|
|
422
|
-
<div class="fb-ei"><span role="img" aria-label="${
|
|
423
|
-
<div class="fb-el">${
|
|
426
|
+
`;function Oe(){return typeof window>"u"||typeof window.matchMedia!="function"?G:window.matchMedia("(prefers-color-scheme: dark)").matches?G:window.matchMedia("(prefers-color-scheme: light)").matches?oe:G}function ae(t){let n=Oe();return t?{...n,...t}:n}var $e="feedback_user_email";function $(t){return t.replace(/[&<>"']/g,n=>{switch(n){case "&":return "&";case "<":return "<";case ">":return ">";case '"':return """;case "'":return "'";default:return n}})}function We(t,n){let o=t;for(let s of n){if(!s||typeof s!="object")continue;let{metadata:d,...r}=s;o={...o,...r},d&&typeof d=="object"&&(o.metadata={...o.metadata??{},...d});}return o}function Be(){if(typeof window>"u")return "";try{return window.localStorage.getItem($e)??""}catch{return ""}}function je(t){try{window.localStorage.setItem($e,t);}catch{}}function it(t){if(typeof document>"u")return {destroy:()=>{},open:()=>{},close:()=>{},update:()=>{},whenReady:()=>Promise.resolve()};let{clientId:n,baseUrl:o}=t;if(!n||n.length<3){let e=new Error("Invalid config. Contact admin.");return t.onError?.(e),{destroy:()=>{},open:()=>{},close:()=>{},update:()=>{},whenReady:()=>Promise.resolve()}}let s=t.position??"right",d=t.theme,r=ae(d),l=t.title??"Share Feedback",P=t.placeholder??"Tell us what you think... (optional)",R=t.showEmailOption??true,W=t.showScreenshotOption??true,se=t.environment,X=t.metadata,le=t.onSubmit,V=t.onError,de=t.onOpen,ce=t.onClose,Y=new J(o),B=t.plugins??[],Q=new Map,j=new Map,Z=[];for(let e of B){let i={clientId:n,baseUrl:o??K,logger:we(e.name),getStore:()=>Q.get(e.name),setStore:b=>{Q.set(e.name,b);}};if(j.set(e.name,i),e.onInit){let b=(async()=>{try{await e.onInit?.(i);}catch(F){i.logger.error("onInit threw",F);}})();Z.push(b);}}let Te=Z.length===0?Promise.resolve():Promise.all(Z).then(()=>{}),m=false,M,v="",k=false,L=Be(),w=false,g=null,f=[],C=false,h=null,A=3,Fe=10*1024*1024,U=document.createElement("div");U.setAttribute("data-usero-widget",""),U.style.cssText="all: initial;",document.body.appendChild(U);let _=U.attachShadow({mode:"open"}),pe=document.createElement("style");pe.textContent=Ee,_.appendChild(pe);let S=document.createElement("button"),z=document.createElement("div"),c=document.createElement("div");_.appendChild(S),_.appendChild(z),_.appendChild(c);function Pe(e){g=e,u();}function fe(){m||(m=true,M=void 0,v="",k=false,g=null,f=[],h=null,C=false,Y.ping(),de?.(),u());}async function Re(e){if(h=null,!e.type.startsWith("image/")){h="Image files only",u();return}if(e.size>Fe){h="Max 10MB",u();return}if(f.length>=A){h=`Max ${A} screenshots`,u();return}C=true,u();try{let i=await Y.uploadScreenshot(e,n);f=[...f,i];}catch(i){h=i instanceof Error?i.message:"Upload failed";}finally{C=false,u();}}function Me(e){f=f.filter((i,b)=>b!==e),u();}function I(){m&&(m=false,ce?.(),u());}async function ue(){if(w)return;w=true,g=null,u();let e={rating:M,comment:v.trim()||void 0,userEmail:k?L:void 0,screenshots:f.length>0?f:void 0,metadata:{pageUrl:window.location.href,pageTitle:document.title||"Untitled Page",referrer:document.referrer||void 0,timestamp:Date.now()}},i={clientId:n,rating:e.rating,comment:e.comment,userEmail:e.userEmail,pageUrl:e.metadata.pageUrl,pageTitle:e.metadata.pageTitle,referrer:e.metadata.referrer,environment:se};f.length>0&&(i.screenshots=f),X!==void 0&&(i.metadata=X);let b=Se(i);if(!b.isValid){w=false,Pe({type:"error",text:b.errors.join(", ")});return}let F=i;if(B.length>0){let y=B.map(async H=>{if(!H.onFeedbackSubmit)return;let E=j.get(H.name);if(E)try{return await H.onFeedbackSubmit(E,i)}catch(te){E.logger.error("onFeedbackSubmit threw",te);return}}),x=await Promise.all(y);F=We(i,x);}try{let y=await Y.submitFeedback(F);if(y.success)k&&L&&je(L),le?.(e),M=void 0,v="",k=!1,f=[],h=null,g={type:"success",text:"Thank you!"};else {let x=y.error??"Error occurred. Try again.";V?.(new Error(x)),g={type:"error",text:x};}}catch(y){let x=y instanceof Error?y.message:"Error occurred. Try again.";V?.(new Error(x)),g={type:"error",text:x};}finally{w=false,u();}}function Le(){S.className=`fb-btn fb-btn--${s} ${m?"fb-btn--open":""}`,S.setAttribute("aria-label","Open feedback"),S.type="button",S.style.background=`linear-gradient(135deg, ${r.primary}, ${ie(r.primary)})`,S.innerHTML=m?'<span style="font-size:20px;">\u2715</span>':"";}function Ce(){z.className="fb-backdrop",z.style.display=m?"block":"none",z.setAttribute("aria-label","Close modal");}function Ae(){c.className=`fb-pnl-base fb-pnl--${s} ${m?"fb-pnl--open":"fb-pnl--closed"}`,c.style.backgroundColor=r.background,s==="right"?(c.style.borderLeft=`1px solid ${r.border}`,c.style.borderRight=""):(c.style.borderRight=`1px solid ${r.border}`,c.style.borderLeft=""),c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-labelledby","usero-feedback-title");let e=1e3-v.length,i=e<50,b=[1,2,3,4].map(a=>{let p=M===a,re=ke[a];return `
|
|
427
|
+
<div class="${["fb-ec",p&&"fb-ec--sel"].filter(Boolean).join(" ")}" style="background:${re}">
|
|
428
|
+
<button type="button" class="fb-eb" data-rating="${a}" role="radio" aria-checked="${p}" aria-label="${a}: ${q[a]}" style="color:${r.text}">
|
|
429
|
+
<div class="fb-ei"><span role="img" aria-label="${q[a]}">${ve[a]}</span></div>
|
|
430
|
+
<div class="fb-el" style="color:${r.text}">${q[a]}</div>
|
|
424
431
|
</button>
|
|
425
432
|
</div>
|
|
426
|
-
`}).join(""),
|
|
433
|
+
`}).join(""),F=g?`<div class="fb-msg fb-msg--header ${g.type==="success"?"fb-msg--ok":"fb-msg--err"}">${g.type==="success"?"\u2713":"\u26A0"} ${$(g.text)}</div>`:"",y=W?(()=>{let a=f.length>=A,p=C||a;return `
|
|
434
|
+
<input type="file" accept="image/*" data-role="screenshot-input" style="display:none;" aria-label="Choose screenshot" />
|
|
435
|
+
<button type="button" class="fb-upb ${p?"fb-upb--dis":""}" data-role="screenshot-pick" ${p?"disabled":""} style="border:1px solid ${r.border};color:${r.text};">
|
|
436
|
+
${C?'<span class="fb-ups"></span> Uploading...':"\u{1F4F7} Add screenshot"}
|
|
437
|
+
</button>
|
|
438
|
+
`})():"",x=W?(()=>{let a=f.length>=A,p=f.map((Ue,ye)=>`
|
|
427
439
|
<div class="fb-sp">
|
|
428
|
-
<img src="${
|
|
429
|
-
<button type="button" class="fb-sr" data-role="screenshot-remove" data-index="${
|
|
440
|
+
<img src="${$(Ue.url)}" alt="Screenshot ${ye+1}" class="fb-si" />
|
|
441
|
+
<button type="button" class="fb-sr" data-role="screenshot-remove" data-index="${ye}" aria-label="Remove screenshot">\u2715</button>
|
|
430
442
|
</div>
|
|
431
|
-
`).join(""),
|
|
432
|
-
<div class="fb-up">
|
|
433
|
-
<input type="file" accept="image/*" data-role="screenshot-input" style="display:none;" aria-label="Choose screenshot" />
|
|
434
|
-
<button type="button" class="fb-upb ${p?"fb-upb--dis":""}" data-role="screenshot-pick" ${p?"disabled":""} style="border:1px solid ${n.border};color:${n.text};">
|
|
435
|
-
${L?'<span class="fb-ups"></span> Uploading...':"\u{1F4F7} Add screenshot"}
|
|
436
|
-
</button>
|
|
437
|
-
${Me}
|
|
438
|
-
</div>
|
|
439
|
-
`})():"",$e=F?`
|
|
443
|
+
`).join(""),re=h?`<div class="fb-upe">\u26A0 ${$(h)}</div>`:"",xe=a?`<div class="fb-sl">Max ${A}</div>`:"";return h||f.length>0||a?`<div class="fb-up-extras">${re}${f.length>0?`<div class="fb-ss">${p}</div>`:""}${xe}</div>`:""})():"",H=R?`
|
|
440
444
|
<div class="fb-email">
|
|
441
|
-
<label class="fb-email-lbl" style="color:${
|
|
442
|
-
<input type="checkbox" class="fb-email-cb" data-role="share-email" ${
|
|
445
|
+
<label class="fb-email-lbl" style="color:${r.text}">
|
|
446
|
+
<input type="checkbox" class="fb-email-cb" data-role="share-email" ${k?"checked":""} aria-label="Share email" />
|
|
443
447
|
<span>Share my email</span>
|
|
444
448
|
</label>
|
|
445
|
-
${
|
|
449
|
+
${k?`<input type="email" class="fb-email-inp" data-role="email-input" value="${$(L)}" placeholder="your.email@example.com" aria-label="Email" maxlength="254" autocomplete="email" style="border:1px solid ${r.border};color:${r.text};background-color:${r.background};" />`:""}
|
|
446
450
|
</div>
|
|
447
|
-
`:"",
|
|
451
|
+
`:"",E=w,te=`background:linear-gradient(135deg, ${r.primary}, ${ie(r.primary)});color:#ffffff;${E?"opacity:0.6;cursor:not-allowed;":""}`;c.innerHTML=`
|
|
448
452
|
<div class="fb-cnt">
|
|
449
|
-
<div class="fb-hdr" style="border-bottom:1px solid ${
|
|
450
|
-
<h2 id="usero-feedback-title" class="fb-ttl" style="color:${
|
|
451
|
-
${
|
|
452
|
-
<button class="fb-close-btn" data-role="close" style="color:${
|
|
453
|
+
<div class="fb-hdr" style="border-bottom:1px solid ${r.border}">
|
|
454
|
+
<h2 id="usero-feedback-title" class="fb-ttl" style="color:${r.text}">${$(l)}</h2>
|
|
455
|
+
${F}
|
|
456
|
+
<button class="fb-close-btn" data-role="close" style="color:${r.text}" aria-label="Close" type="button">\u2715</button>
|
|
453
457
|
</div>
|
|
454
458
|
<form data-role="form">
|
|
455
|
-
<div class="fb-es" role="radiogroup" aria-label="Rate experience">${
|
|
456
|
-
<textarea class="fb-ta" data-role="comment" placeholder="${
|
|
457
|
-
<div class="fb-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
459
|
+
<div class="fb-es" role="radiogroup" aria-label="Rate experience">${b}</div>
|
|
460
|
+
<textarea class="fb-ta" data-role="comment" placeholder="${$(P)}" aria-label="Comments" maxlength="1000" rows="2" style="border:1px solid ${r.border};color:${r.text};background-color:${r.background};">${$(v)}</textarea>
|
|
461
|
+
<div class="fb-toolrow">
|
|
462
|
+
${y}
|
|
463
|
+
<div class="fb-charcount${i?" fb-charcount--low":""}" data-role="charcount" style="color:${i?"#dc2626":r.text};opacity:${i?1:.6};">${e} chars remaining</div>
|
|
464
|
+
</div>
|
|
465
|
+
${x?`<div class="fb-up">${x}</div>`:""}
|
|
466
|
+
${H}
|
|
467
|
+
<button class="fb-sub ${E?"fb-sub--dis":""}" type="submit" aria-label="Submit" ${E?"disabled":""} style="${te}">
|
|
468
|
+
${w?'<span class="fb-spin"></span>':""}
|
|
469
|
+
${w?"Submitting...":"Send Feedback \u{1F680}"}
|
|
463
470
|
</button>
|
|
464
471
|
</form>
|
|
465
472
|
</div>
|
|
466
|
-
`,
|
|
473
|
+
`,c.querySelector('form[data-role="form"]')?.addEventListener("submit",a=>{a.preventDefault(),ue();}),c.querySelector('button[data-role="close"]')?.addEventListener("click",I),c.querySelectorAll("button[data-rating]").forEach(a=>{a.addEventListener("click",()=>{let p=a.dataset.rating;(p==="1"||p==="2"||p==="3"||p==="4")&&(M=Number(p),u());});});let N=c.querySelector('textarea[data-role="comment"]');N&&N.addEventListener("input",()=>{if(N.value.length<=1e3){v=N.value;let a=c.querySelector('[data-role="charcount"]');if(a){let p=1e3-v.length;a.textContent=`${p} chars remaining`,a.style.color=p<50?"#dc2626":r.text,a.style.opacity=p<50?"1":"0.6";}}});let he=c.querySelector('input[data-role="share-email"]');he?.addEventListener("change",()=>{k=he.checked,u();});let ne=c.querySelector('input[data-role="email-input"]');ne?.addEventListener("input",()=>{ne.value.length<=254&&(L=ne.value);});let O=c.querySelector('input[data-role="screenshot-input"]');c.querySelector('button[data-role="screenshot-pick"]')?.addEventListener("click",()=>{O?.click();}),O?.addEventListener("change",()=>{let a=O.files?.[0];a&&Re(a).finally(()=>{O&&(O.value="");});}),c.querySelectorAll('button[data-role="screenshot-remove"]').forEach(a=>{a.addEventListener("click",()=>{let p=Number(a.dataset.index);Number.isInteger(p)&&Me(p);});});}function u(){Le(),Ce(),Ae();}S.addEventListener("click",()=>{m?I():fe();}),z.addEventListener("click",I);let be=e=>{m&&(e.key==="Escape"&&I(),e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),ue()));};document.addEventListener("keydown",be);let T=null,D=null;function me(){T&&D&&T.removeEventListener("change",D),T=null,D=null;}function ge(){T||typeof window>"u"||typeof window.matchMedia!="function"||(T=window.matchMedia("(prefers-color-scheme: dark)"),D=()=>{d===void 0&&(r=ae(void 0),u());},T.addEventListener("change",D));}d===void 0&&ge(),u();let ee=false;return {destroy:()=>{if(!ee){ee=true,document.removeEventListener("keydown",be),me();for(let e of B){if(!e.onDestroy)continue;let i=j.get(e.name);if(i)try{e.onDestroy(i);}catch(b){i.logger.error("onDestroy threw",b);}}Q.clear(),j.clear(),U.remove();}},open:fe,close:I,whenReady:()=>Te,update:e=>{if(ee)return;let i=false;e.position!==void 0&&e.position!==s&&(s=e.position,i=true),"theme"in e&&(d=e.theme,r=ae(d),d===void 0?ge():me(),i=true),e.title!==void 0&&e.title!==l&&(l=e.title,i=true),e.placeholder!==void 0&&e.placeholder!==P&&(P=e.placeholder,i=true),e.showEmailOption!==void 0&&e.showEmailOption!==R&&(R=e.showEmailOption,i=true),e.showScreenshotOption!==void 0&&e.showScreenshotOption!==W&&(W=e.showScreenshotOption,i=true),"environment"in e&&(se=e.environment),"metadata"in e&&(X=e.metadata),"onSubmit"in e&&(le=e.onSubmit),"onError"in e&&(V=e.onError),"onOpen"in e&&(de=e.onOpen),"onClose"in e&&(ce=e.onClose),i&&u();}}}exports.DARK_THEME=G;exports.DEFAULT_THEME=oe;exports.initUseroFeedbackWidget=it;exports.mergePluginPatches=We;exports.mergeTheme=ze;exports.resolveTheme=ae;return exports;})({});//# sourceMappingURL=usero.iife.js.map
|
|
467
474
|
//# sourceMappingURL=usero.iife.js.map
|