@upstep/js 0.1.0 → 0.4.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/dist/api-p1GbYq1j.js +1 -0
- package/dist/{api-DWhfFfYu.mjs → api-q50Qqen1.mjs} +4 -0
- package/dist/api.d.ts +3 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/index.cjs +69 -50
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +173 -104
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts +23 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +251 -114
- package/dist/widget.d.ts +20 -2
- package/dist/widget.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/api-CwAgmJ0s.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class i{constructor(e){this.baseUrl=(e.baseUrl??"https://upstep.io").replace(/\/$/,""),this.apiKey=e.apiKey,e.userId!==void 0&&(this.userId=e.userId)}setUserId(e){this.userId=e}headers(){return{"Content-Type":"application/json","x-api-key":this.apiKey}}async listFeedback(e){const t=new URLSearchParams;e!=null&&e.cursor&&t.set("cursor",e.cursor),e!=null&&e.limit&&t.set("limit",String(e.limit)),e!=null&&e.type&&t.set("type",e.type),e!=null&&e.status&&t.set("status",e.status),e!=null&&e.sort&&t.set("sort",e.sort);const s=await fetch(`${this.baseUrl}/api/sdk/feedback?${t}`,{headers:this.headers()});if(!s.ok)throw new Error(`Upstep: ${s.status}`);return s.json()}async submitFeedback(e){const t=await fetch(`${this.baseUrl}/api/sdk/feedback`,{method:"POST",headers:this.headers(),body:JSON.stringify({...e,endUserId:e.endUserId??this.userId})});if(!t.ok)throw new Error(`Upstep: ${t.status}`);return t.json()}async vote(e,t){const s=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote`,{method:"POST",headers:this.headers(),body:JSON.stringify({value:t,endUserId:this.userId})});if(!s.ok)throw new Error(`Upstep: ${s.status}`)}async removeVote(e){if(!this.userId)return;const t=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote?endUserId=${encodeURIComponent(this.userId)}`,{method:"DELETE",headers:this.headers()});if(!t.ok)throw new Error(`Upstep: ${t.status}`)}}exports.UpstepApiClient=i;
|
|
@@ -2,6 +2,10 @@ class r {
|
|
|
2
2
|
constructor(e) {
|
|
3
3
|
this.baseUrl = (e.baseUrl ?? "https://upstep.io").replace(/\/$/, ""), this.apiKey = e.apiKey, e.userId !== void 0 && (this.userId = e.userId);
|
|
4
4
|
}
|
|
5
|
+
/** Update the end-user id at runtime (e.g. after the user logs in). */
|
|
6
|
+
setUserId(e) {
|
|
7
|
+
this.userId = e;
|
|
8
|
+
}
|
|
5
9
|
headers() {
|
|
6
10
|
return {
|
|
7
11
|
"Content-Type": "application/json",
|
package/dist/api.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ import { Feedback, FeedbackListResponse, SubmitFeedbackPayload, VotePayload, Ups
|
|
|
2
2
|
export declare class UpstepApiClient {
|
|
3
3
|
private readonly baseUrl;
|
|
4
4
|
private readonly apiKey;
|
|
5
|
-
|
|
5
|
+
userId: string | undefined;
|
|
6
6
|
constructor(config: UpstepConfig);
|
|
7
|
+
/** Update the end-user id at runtime (e.g. after the user logs in). */
|
|
8
|
+
setUserId(userId: string | undefined): void;
|
|
7
9
|
private headers;
|
|
8
10
|
listFeedback(params?: {
|
|
9
11
|
cursor?: string;
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACb,MAAM,eAAe,CAAC;AAEvB,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACb,MAAM,eAAe,CAAC;AAEvB,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEf,MAAM,EAAE,YAAY;IAMhC,uEAAuE;IACvE,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAIpC,OAAO,CAAC,OAAO;IAOT,YAAY,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACzB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAe3B,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAajE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IASpE,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQpD"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,67 +1,86 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
2
|
-
#upstep-root *{box-sizing:border-box;font-family
|
|
3
|
-
#upstep-btn{position:fixed;bottom:24px
|
|
4
|
-
#upstep-btn:hover{
|
|
5
|
-
#upstep-
|
|
6
|
-
#upstep-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
#upstep-
|
|
10
|
-
#upstep-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
#upstep-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.upstep-
|
|
17
|
-
.upstep-
|
|
18
|
-
|
|
19
|
-
.upstep-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./api-p1GbYq1j.js"),u="#D97757",b={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},f={bg:"#1c1b19",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function h(o){return o==="light"||o==="dark"?o:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function x(o,t,e){return`
|
|
2
|
+
#upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
|
|
3
|
+
#upstep-btn{position:fixed;bottom:24px;${t==="left"?"left:24px":"right:24px"};z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${o};color:#fff;border:none;border-radius:9999px;padding:12px 18px;font-size:14px;font-weight:600;cursor:pointer;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
|
|
4
|
+
#upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
|
|
5
|
+
#upstep-btn svg{width:16px;height:16px}
|
|
6
|
+
#upstep-backdrop{position:fixed;inset:0;background:${e.overlay};backdrop-filter:blur(3px);z-index:9999;display:flex;align-items:center;justify-content:center;padding:16px;animation:upstep-fade .2s ease}
|
|
7
|
+
@keyframes upstep-fade{from{opacity:0}to{opacity:1}}
|
|
8
|
+
@keyframes upstep-rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:translateY(0)}}
|
|
9
|
+
#upstep-modal{background:${e.bg};border:1px solid ${e.border};border-radius:20px;width:100%;max-width:440px;max-height:88vh;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 24px 64px rgba(0,0,0,.28);animation:upstep-rise .26s cubic-bezier(.16,1,.3,1)}
|
|
10
|
+
#upstep-header{display:flex;align-items:flex-start;justify-content:space-between;padding:20px 20px 0}
|
|
11
|
+
#upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${e.text};letter-spacing:-.01em}
|
|
12
|
+
#upstep-header p{margin:2px 0 0;font-size:12.5px;color:${e.textFaint}}
|
|
13
|
+
#upstep-close{background:${e.bgSoft};border:none;width:28px;height:28px;border-radius:8px;font-size:14px;cursor:pointer;color:${e.textSoft};line-height:1;display:flex;align-items:center;justify-content:center;transition:background .15s}
|
|
14
|
+
#upstep-close:hover{background:${e.bgHover};color:${e.text}}
|
|
15
|
+
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${e.bgSoft};border-radius:11px}
|
|
16
|
+
.upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:8px;font-size:13px;font-weight:600;color:${e.textSoft};cursor:pointer;transition:all .15s}
|
|
17
|
+
.upstep-tab.active{background:${e.bg};color:${e.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
|
|
18
|
+
#upstep-body{flex:1;overflow-y:auto;padding:18px 20px 22px}
|
|
19
|
+
.upstep-form textarea{width:100%;min-height:104px;border:1px solid ${e.border};border-radius:12px;padding:12px;font-size:14px;line-height:1.5;resize:vertical;outline:none;background:${e.bgSoft};color:${e.text};transition:border-color .15s}
|
|
20
|
+
.upstep-form textarea::placeholder{color:${e.textFaint}}
|
|
21
|
+
.upstep-form textarea:focus{border-color:${o};background:${e.bg}}
|
|
22
|
+
.upstep-type-row{display:flex;gap:7px;margin:12px 0 4px}
|
|
23
|
+
.upstep-type-btn{flex:1;padding:8px 10px;border-radius:9px;border:1px solid ${e.border};background:${e.bg};color:${e.textSoft};font-size:12.5px;font-weight:600;cursor:pointer;transition:all .15s}
|
|
24
|
+
.upstep-type-btn:hover{border-color:${e.textFaint}}
|
|
25
|
+
.upstep-type-btn.selected{background:${o};color:#fff;border-color:${o}}
|
|
26
|
+
.upstep-submit{width:100%;padding:12px;background:${o};color:#fff;border:none;border-radius:11px;font-size:14px;font-weight:600;cursor:pointer;margin-top:14px;transition:filter .15s}
|
|
27
|
+
.upstep-submit:hover{filter:brightness(.94)}
|
|
20
28
|
.upstep-submit:disabled{opacity:.5;cursor:not-allowed}
|
|
21
|
-
|
|
22
|
-
.upstep-feedback-item:
|
|
23
|
-
.upstep-feedback-
|
|
24
|
-
.upstep-
|
|
25
|
-
.upstep-vote-
|
|
26
|
-
.upstep-vote
|
|
27
|
-
.upstep-vote-
|
|
28
|
-
.upstep-
|
|
29
|
-
.upstep-
|
|
30
|
-
.upstep-
|
|
31
|
-
.upstep-
|
|
32
|
-
.upstep-
|
|
33
|
-
|
|
29
|
+
#upstep-form-msg{font-size:13px;text-align:center;margin-top:12px;color:${o};font-weight:500}
|
|
30
|
+
.upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${e.border};border-radius:14px;margin-bottom:10px;background:${e.bg};transition:border-color .15s}
|
|
31
|
+
.upstep-feedback-item:hover{border-color:${e.textFaint}}
|
|
32
|
+
.upstep-vote{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:46px;padding:7px 0;border-radius:11px;border:1px solid ${e.border};background:${e.bgSoft};cursor:pointer;transition:all .15s}
|
|
33
|
+
.upstep-vote:hover{border-color:${o}}
|
|
34
|
+
.upstep-vote.voted{border-color:${o};background:${o}1a}
|
|
35
|
+
.upstep-vote-arrow{font-size:11px;line-height:1;color:${o}}
|
|
36
|
+
.upstep-vote-count{font-size:14px;font-weight:700;color:${e.text};line-height:1.1}
|
|
37
|
+
.upstep-feedback-main{flex:1;min-width:0}
|
|
38
|
+
.upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${e.text};margin:0 0 8px;word-break:break-word}
|
|
39
|
+
.upstep-feedback-meta{display:flex;align-items:center;gap:7px}
|
|
40
|
+
.upstep-badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:9999px;font-size:10.5px;font-weight:700;letter-spacing:.02em}
|
|
41
|
+
.upstep-badge-bug{background:#fdecec;color:#d6453d}
|
|
42
|
+
.upstep-badge-feature{background:#e9f0fd;color:#3b76d6}
|
|
43
|
+
.upstep-badge-general{background:${e.bgSoft};color:${e.textSoft}}
|
|
44
|
+
.upstep-feedback-date{font-size:11px;color:${e.textFaint}}
|
|
45
|
+
.upstep-empty{text-align:center;color:${e.textFaint};font-size:14px;padding:40px 0}
|
|
46
|
+
.upstep-empty strong{display:block;color:${e.textSoft};font-size:15px;margin-bottom:4px}
|
|
47
|
+
`}const g='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';class m{constructor(t,e={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.client=t,this.accent=e.accentColor??u,this.position=e.position??"right",this.showLauncher=e.launcher!==!1,this.palette=h(e.theme??"auto")==="dark"?f:b}mount(){this.injectStyles(),this.showLauncher&&this.renderButton()}openWidget(){this.openModal()}closeWidget(){this.closeModal()}injectStyles(){var e;(e=document.getElementById("upstep-styles"))==null||e.remove();const t=document.createElement("style");t.id="upstep-styles",t.textContent=x(this.accent,this.position,this.palette),document.head.appendChild(t)}renderButton(){const t=document.createElement("button");t.id="upstep-btn",t.innerHTML=`${g}<span>Feedback</span>`,t.addEventListener("click",()=>this.openModal()),document.body.appendChild(t)}openModal(){this.isOpen=!0,this.fetchFeed(),this.renderModal()}closeModal(){var t;this.isOpen=!1,(t=document.getElementById("upstep-backdrop"))==null||t.remove()}async fetchFeed(){try{const t=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=t.items,this.renderFeedList()}catch{}}renderModal(){var e,s;const t=document.createElement("div");t.id="upstep-backdrop",t.addEventListener("click",i=>{i.target===t&&this.closeModal()}),t.innerHTML=`
|
|
34
48
|
<div id="upstep-modal">
|
|
35
49
|
<div id="upstep-header">
|
|
36
|
-
<
|
|
37
|
-
|
|
50
|
+
<div>
|
|
51
|
+
<h2>Share your feedback</h2>
|
|
52
|
+
<p>Tell us what to build next, or vote on ideas.</p>
|
|
53
|
+
</div>
|
|
54
|
+
<button id="upstep-close" aria-label="Close">✕</button>
|
|
38
55
|
</div>
|
|
39
56
|
<div id="upstep-tabs">
|
|
40
|
-
<button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">
|
|
41
|
-
<button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">
|
|
57
|
+
<button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Give feedback</button>
|
|
58
|
+
<button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Vote on ideas</button>
|
|
42
59
|
</div>
|
|
43
60
|
<div id="upstep-body">
|
|
44
61
|
${this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
45
62
|
</div>
|
|
46
63
|
</div>
|
|
47
|
-
`,(
|
|
64
|
+
`,(e=document.getElementById("upstep-backdrop"))==null||e.remove(),document.body.appendChild(t),(s=t.querySelector("#upstep-close"))==null||s.addEventListener("click",()=>this.closeModal()),t.querySelectorAll(".upstep-tab").forEach(i=>{i.addEventListener("click",()=>{this.tab=i.dataset.tab,this.renderModal()})}),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const t=["BUG","FEATURE","GENERAL"],e={BUG:"🐞 Bug",FEATURE:"✨ Feature",GENERAL:"💬 General"};return`
|
|
48
65
|
<div class="upstep-form">
|
|
49
66
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
50
67
|
<div class="upstep-type-row">
|
|
51
|
-
${
|
|
68
|
+
${t.map(s=>`<button class="upstep-type-btn${this.selectedType===s?" selected":""}" data-type="${s}">${e[s]}</button>`).join("")}
|
|
52
69
|
</div>
|
|
53
70
|
<button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
|
|
54
|
-
<div id="upstep-form-msg"
|
|
71
|
+
<div id="upstep-form-msg"></div>
|
|
55
72
|
</div>
|
|
56
|
-
`}renderFeed(){return this.feedItems.length?this.feedItems.map(
|
|
57
|
-
<div class="upstep-feedback-item" data-id="${
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
<span class="upstep-
|
|
61
|
-
|
|
73
|
+
`}renderFeed(){return this.feedItems.length?this.feedItems.map(t=>`
|
|
74
|
+
<div class="upstep-feedback-item" data-id="${t.id}">
|
|
75
|
+
<button class="upstep-vote${t.userVote==="UP"?" voted":""}" data-vote="UP" data-feedback="${t.id}">
|
|
76
|
+
<span class="upstep-vote-arrow">▲</span>
|
|
77
|
+
<span class="upstep-vote-count">${t.upvotes}</span>
|
|
78
|
+
</button>
|
|
79
|
+
<div class="upstep-feedback-main">
|
|
80
|
+
<p class="upstep-feedback-content">${y(t.content)}</p>
|
|
81
|
+
<div class="upstep-feedback-meta">
|
|
82
|
+
<span class="upstep-badge upstep-badge-${t.type.toLowerCase()}">${t.type}</span>
|
|
83
|
+
<span class="upstep-feedback-date">${new Date(t.createdAt).toLocaleDateString()}</span>
|
|
84
|
+
</div>
|
|
62
85
|
</div>
|
|
63
|
-
|
|
64
|
-
<button class="upstep-vote-btn" data-vote="UP" data-feedback="${e.id}">▲ ${e.upvotes}</button>
|
|
65
|
-
<button class="upstep-vote-btn" data-vote="DOWN" data-feedback="${e.id}">▼ ${e.downvotes}</button>
|
|
66
|
-
</div>
|
|
67
|
-
</div>`).join(""):'<div class="upstep-empty">No feedback yet. Be the first!</div>'}renderFeedList(){const e=document.getElementById("upstep-body");!e||this.tab!=="feed"||(e.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var e;document.querySelectorAll(".upstep-type-btn").forEach(t=>{t.addEventListener("click",()=>{this.selectedType=t.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(o=>o.classList.remove("selected")),t.classList.add("selected")})}),(e=document.getElementById("upstep-submit-btn"))==null||e.addEventListener("click",async()=>{const t=document.getElementById("upstep-textarea"),o=document.getElementById("upstep-form-msg"),d=document.getElementById("upstep-submit-btn");if(!t||this.loading)return;const i=t.value.trim();if(i){this.loading=!0,d&&(d.disabled=!0);try{await this.client.submitFeedback({content:i,type:this.selectedType}),t.value="",o&&(o.textContent="Thanks for your feedback!"),await this.fetchFeed()}catch{o&&(o.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,d&&(d.disabled=!1)}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote-btn").forEach(e=>{e.addEventListener("click",async()=>{const t=e.dataset.feedback,o=e.dataset.vote;try{await this.client.vote(t,o),await this.fetchFeed()}catch{}})})}}function u(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let n=null;const a={init(s){if(n=new p.UpstepApiClient(s),typeof window<"u"){const e=()=>new c(n).mount();document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}return n},get client(){if(!n)throw new Error("Upstep.init() must be called first");return n}};if(typeof document<"u"){const s=document.currentScript,e=s==null?void 0:s.dataset.apiKey,t=s==null?void 0:s.dataset.userId;if(e){const o={apiKey:e};t&&(o.userId=t),a.init(o)}}exports.UpstepApiClient=p.UpstepApiClient;exports.default=a;
|
|
86
|
+
</div>`).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const t=document.getElementById("upstep-body");!t||this.tab!=="feed"||(t.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var t;document.querySelectorAll(".upstep-type-btn").forEach(e=>{e.addEventListener("click",()=>{this.selectedType=e.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(s=>s.classList.remove("selected")),e.classList.add("selected")})}),(t=document.getElementById("upstep-submit-btn"))==null||t.addEventListener("click",async()=>{const e=document.getElementById("upstep-textarea"),s=document.getElementById("upstep-form-msg"),i=document.getElementById("upstep-submit-btn");if(!e||this.loading)return;const d=e.value.trim();if(d){this.loading=!0,i&&(i.disabled=!0,i.textContent="Sending…");try{await this.client.submitFeedback({content:d,type:this.selectedType}),e.value="",s&&(s.textContent="Thanks — we got your feedback! 🎉"),await this.fetchFeed()}catch{s&&(s.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,i&&(i.disabled=!1,i.textContent="Send feedback")}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote").forEach(t=>{t.addEventListener("click",async()=>{const e=t.dataset.feedback;try{await this.client.vote(e,"UP"),await this.fetchFeed()}catch{}})})}}function y(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let n=null,a=null;const c={init(o){if(n=new l.UpstepApiClient(o),typeof window<"u"){const t={};o.accentColor!==void 0&&(t.accentColor=o.accentColor),o.position!==void 0&&(t.position=o.position),o.theme!==void 0&&(t.theme=o.theme),o.launcher!==void 0&&(t.launcher=o.launcher);const e=()=>{a=new m(n,t),a.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}return n},open(){a==null||a.openWidget()},close(){a==null||a.closeWidget()},identify(o){n==null||n.setUserId(o)},get client(){if(!n)throw new Error("Upstep.init() must be called first");return n}};if(typeof document<"u"){const o=document.currentScript,t=o==null?void 0:o.dataset.apiKey,e=o==null?void 0:o.dataset.userId,s=o==null?void 0:o.dataset.baseUrl,i=o==null?void 0:o.dataset.accentColor,d=o==null?void 0:o.dataset.position,p=o==null?void 0:o.dataset.theme;if(t){const r={apiKey:t};e&&(r.userId=e),s&&(r.baseUrl=s),i&&(r.accentColor=i),(d==="left"||d==="right")&&(r.position=d),(p==="light"||p==="dark"||p==="auto")&&(r.theme=p),c.init(r)}}exports.UpstepApiClient=l.UpstepApiClient;exports.default=c;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ export type { UpstepConfig };
|
|
|
4
4
|
export { UpstepApiClient };
|
|
5
5
|
declare const Upstep: {
|
|
6
6
|
init(config: UpstepConfig): UpstepApiClient;
|
|
7
|
+
/** Open the feedback widget — use this to trigger it from your own UI. */
|
|
8
|
+
open(): void;
|
|
9
|
+
/** Close the feedback widget. */
|
|
10
|
+
close(): void;
|
|
11
|
+
/** Set / update the end-user id at runtime (e.g. after the user logs in). */
|
|
12
|
+
identify(userId: string | undefined): void;
|
|
7
13
|
readonly client: UpstepApiClient;
|
|
8
14
|
};
|
|
9
15
|
export default Upstep;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAGxC,YAAY,EAAE,YAAY,EAAE,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAGxC,YAAY,EAAE,YAAY,EAAE,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,CAAC;AAK3B,QAAA,MAAM,MAAM;iBACG,YAAY;IAqBzB,0EAA0E;;IAK1E,iCAAiC;;IAKjC,6EAA6E;qBAC5D,MAAM,GAAG,SAAS;qBAIrB,eAAe;CAI9B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,184 +1,253 @@
|
|
|
1
|
-
import { U as
|
|
2
|
-
const
|
|
3
|
-
#
|
|
4
|
-
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { U as l } from "./api-q50Qqen1.mjs";
|
|
2
|
+
const c = "#D97757", u = {
|
|
3
|
+
bg: "#ffffff",
|
|
4
|
+
bgSoft: "#f6f5f2",
|
|
5
|
+
bgHover: "#efede8",
|
|
6
|
+
text: "#1a1915",
|
|
7
|
+
textSoft: "#56544d",
|
|
8
|
+
textFaint: "#9b9890",
|
|
9
|
+
border: "#e8e6df",
|
|
10
|
+
overlay: "rgba(26,25,21,.45)"
|
|
11
|
+
}, b = {
|
|
12
|
+
bg: "#1c1b19",
|
|
13
|
+
bgSoft: "#262522",
|
|
14
|
+
bgHover: "#302e2a",
|
|
15
|
+
text: "#f5f4f0",
|
|
16
|
+
textSoft: "#b4b1a8",
|
|
17
|
+
textFaint: "#7d7a72",
|
|
18
|
+
border: "#33312c",
|
|
19
|
+
overlay: "rgba(0,0,0,.6)"
|
|
20
|
+
};
|
|
21
|
+
function f(o) {
|
|
22
|
+
return o === "light" || o === "dark" ? o : typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
23
|
+
}
|
|
24
|
+
function h(o, t, e) {
|
|
25
|
+
return `
|
|
26
|
+
#upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
|
|
27
|
+
#upstep-btn{position:fixed;bottom:24px;${t === "left" ? "left:24px" : "right:24px"};z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${o};color:#fff;border:none;border-radius:9999px;padding:12px 18px;font-size:14px;font-weight:600;cursor:pointer;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
|
|
28
|
+
#upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
|
|
29
|
+
#upstep-btn svg{width:16px;height:16px}
|
|
30
|
+
#upstep-backdrop{position:fixed;inset:0;background:${e.overlay};backdrop-filter:blur(3px);z-index:9999;display:flex;align-items:center;justify-content:center;padding:16px;animation:upstep-fade .2s ease}
|
|
31
|
+
@keyframes upstep-fade{from{opacity:0}to{opacity:1}}
|
|
32
|
+
@keyframes upstep-rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:translateY(0)}}
|
|
33
|
+
#upstep-modal{background:${e.bg};border:1px solid ${e.border};border-radius:20px;width:100%;max-width:440px;max-height:88vh;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 24px 64px rgba(0,0,0,.28);animation:upstep-rise .26s cubic-bezier(.16,1,.3,1)}
|
|
34
|
+
#upstep-header{display:flex;align-items:flex-start;justify-content:space-between;padding:20px 20px 0}
|
|
35
|
+
#upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${e.text};letter-spacing:-.01em}
|
|
36
|
+
#upstep-header p{margin:2px 0 0;font-size:12.5px;color:${e.textFaint}}
|
|
37
|
+
#upstep-close{background:${e.bgSoft};border:none;width:28px;height:28px;border-radius:8px;font-size:14px;cursor:pointer;color:${e.textSoft};line-height:1;display:flex;align-items:center;justify-content:center;transition:background .15s}
|
|
38
|
+
#upstep-close:hover{background:${e.bgHover};color:${e.text}}
|
|
39
|
+
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${e.bgSoft};border-radius:11px}
|
|
40
|
+
.upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:8px;font-size:13px;font-weight:600;color:${e.textSoft};cursor:pointer;transition:all .15s}
|
|
41
|
+
.upstep-tab.active{background:${e.bg};color:${e.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
|
|
42
|
+
#upstep-body{flex:1;overflow-y:auto;padding:18px 20px 22px}
|
|
43
|
+
.upstep-form textarea{width:100%;min-height:104px;border:1px solid ${e.border};border-radius:12px;padding:12px;font-size:14px;line-height:1.5;resize:vertical;outline:none;background:${e.bgSoft};color:${e.text};transition:border-color .15s}
|
|
44
|
+
.upstep-form textarea::placeholder{color:${e.textFaint}}
|
|
45
|
+
.upstep-form textarea:focus{border-color:${o};background:${e.bg}}
|
|
46
|
+
.upstep-type-row{display:flex;gap:7px;margin:12px 0 4px}
|
|
47
|
+
.upstep-type-btn{flex:1;padding:8px 10px;border-radius:9px;border:1px solid ${e.border};background:${e.bg};color:${e.textSoft};font-size:12.5px;font-weight:600;cursor:pointer;transition:all .15s}
|
|
48
|
+
.upstep-type-btn:hover{border-color:${e.textFaint}}
|
|
49
|
+
.upstep-type-btn.selected{background:${o};color:#fff;border-color:${o}}
|
|
50
|
+
.upstep-submit{width:100%;padding:12px;background:${o};color:#fff;border:none;border-radius:11px;font-size:14px;font-weight:600;cursor:pointer;margin-top:14px;transition:filter .15s}
|
|
51
|
+
.upstep-submit:hover{filter:brightness(.94)}
|
|
21
52
|
.upstep-submit:disabled{opacity:.5;cursor:not-allowed}
|
|
22
|
-
|
|
23
|
-
.upstep-feedback-item:
|
|
24
|
-
.upstep-feedback-
|
|
25
|
-
.upstep-
|
|
26
|
-
.upstep-vote-
|
|
27
|
-
.upstep-vote
|
|
28
|
-
.upstep-vote-
|
|
29
|
-
.upstep-
|
|
30
|
-
.upstep-
|
|
31
|
-
.upstep-
|
|
32
|
-
.upstep-
|
|
33
|
-
.upstep-
|
|
53
|
+
#upstep-form-msg{font-size:13px;text-align:center;margin-top:12px;color:${o};font-weight:500}
|
|
54
|
+
.upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${e.border};border-radius:14px;margin-bottom:10px;background:${e.bg};transition:border-color .15s}
|
|
55
|
+
.upstep-feedback-item:hover{border-color:${e.textFaint}}
|
|
56
|
+
.upstep-vote{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:46px;padding:7px 0;border-radius:11px;border:1px solid ${e.border};background:${e.bgSoft};cursor:pointer;transition:all .15s}
|
|
57
|
+
.upstep-vote:hover{border-color:${o}}
|
|
58
|
+
.upstep-vote.voted{border-color:${o};background:${o}1a}
|
|
59
|
+
.upstep-vote-arrow{font-size:11px;line-height:1;color:${o}}
|
|
60
|
+
.upstep-vote-count{font-size:14px;font-weight:700;color:${e.text};line-height:1.1}
|
|
61
|
+
.upstep-feedback-main{flex:1;min-width:0}
|
|
62
|
+
.upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${e.text};margin:0 0 8px;word-break:break-word}
|
|
63
|
+
.upstep-feedback-meta{display:flex;align-items:center;gap:7px}
|
|
64
|
+
.upstep-badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:9999px;font-size:10.5px;font-weight:700;letter-spacing:.02em}
|
|
65
|
+
.upstep-badge-bug{background:#fdecec;color:#d6453d}
|
|
66
|
+
.upstep-badge-feature{background:#e9f0fd;color:#3b76d6}
|
|
67
|
+
.upstep-badge-general{background:${e.bgSoft};color:${e.textSoft}}
|
|
68
|
+
.upstep-feedback-date{font-size:11px;color:${e.textFaint}}
|
|
69
|
+
.upstep-empty{text-align:center;color:${e.textFaint};font-size:14px;padding:40px 0}
|
|
70
|
+
.upstep-empty strong{display:block;color:${e.textSoft};font-size:15px;margin-bottom:4px}
|
|
34
71
|
`;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
72
|
+
}
|
|
73
|
+
const x = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';
|
|
74
|
+
class g {
|
|
75
|
+
constructor(t, e = {}) {
|
|
76
|
+
this.isOpen = !1, this.tab = "submit", this.feedItems = [], this.selectedType = "GENERAL", this.loading = !1, this.client = t, this.accent = e.accentColor ?? c, this.position = e.position ?? "right", this.showLauncher = e.launcher !== !1, this.palette = f(e.theme ?? "auto") === "dark" ? b : u;
|
|
38
77
|
}
|
|
39
78
|
mount() {
|
|
40
|
-
this.injectStyles(), this.renderButton();
|
|
79
|
+
this.injectStyles(), this.showLauncher && this.renderButton();
|
|
80
|
+
}
|
|
81
|
+
/** Open the feedback modal programmatically (e.g. from your own button). */
|
|
82
|
+
openWidget() {
|
|
83
|
+
this.openModal();
|
|
84
|
+
}
|
|
85
|
+
/** Close the feedback modal programmatically. */
|
|
86
|
+
closeWidget() {
|
|
87
|
+
this.closeModal();
|
|
41
88
|
}
|
|
42
89
|
injectStyles() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
90
|
+
var e;
|
|
91
|
+
(e = document.getElementById("upstep-styles")) == null || e.remove();
|
|
92
|
+
const t = document.createElement("style");
|
|
93
|
+
t.id = "upstep-styles", t.textContent = h(this.accent, this.position, this.palette), document.head.appendChild(t);
|
|
46
94
|
}
|
|
47
95
|
renderButton() {
|
|
48
|
-
const
|
|
49
|
-
|
|
96
|
+
const t = document.createElement("button");
|
|
97
|
+
t.id = "upstep-btn", t.innerHTML = `${x}<span>Feedback</span>`, t.addEventListener("click", () => this.openModal()), document.body.appendChild(t);
|
|
50
98
|
}
|
|
51
99
|
openModal() {
|
|
52
|
-
this.
|
|
100
|
+
this.isOpen = !0, this.fetchFeed(), this.renderModal();
|
|
53
101
|
}
|
|
54
102
|
closeModal() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
e == null || e.remove();
|
|
103
|
+
var t;
|
|
104
|
+
this.isOpen = !1, (t = document.getElementById("upstep-backdrop")) == null || t.remove();
|
|
58
105
|
}
|
|
59
106
|
async fetchFeed() {
|
|
60
107
|
try {
|
|
61
|
-
const
|
|
62
|
-
this.feedItems =
|
|
108
|
+
const t = await this.client.listFeedback({ sort: "votes", limit: 20 });
|
|
109
|
+
this.feedItems = t.items, this.renderFeedList();
|
|
63
110
|
} catch {
|
|
64
111
|
}
|
|
65
112
|
}
|
|
66
113
|
renderModal() {
|
|
67
|
-
var
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}),
|
|
114
|
+
var e, s;
|
|
115
|
+
const t = document.createElement("div");
|
|
116
|
+
t.id = "upstep-backdrop", t.addEventListener("click", (i) => {
|
|
117
|
+
i.target === t && this.closeModal();
|
|
118
|
+
}), t.innerHTML = `
|
|
72
119
|
<div id="upstep-modal">
|
|
73
120
|
<div id="upstep-header">
|
|
74
|
-
<
|
|
75
|
-
|
|
121
|
+
<div>
|
|
122
|
+
<h2>Share your feedback</h2>
|
|
123
|
+
<p>Tell us what to build next, or vote on ideas.</p>
|
|
124
|
+
</div>
|
|
125
|
+
<button id="upstep-close" aria-label="Close">✕</button>
|
|
76
126
|
</div>
|
|
77
127
|
<div id="upstep-tabs">
|
|
78
|
-
<button class="upstep-tab ${this.tab === "submit" ? "active" : ""}" data-tab="submit">
|
|
79
|
-
<button class="upstep-tab ${this.tab === "feed" ? "active" : ""}" data-tab="feed">
|
|
128
|
+
<button class="upstep-tab ${this.tab === "submit" ? "active" : ""}" data-tab="submit">Give feedback</button>
|
|
129
|
+
<button class="upstep-tab ${this.tab === "feed" ? "active" : ""}" data-tab="feed">Vote on ideas</button>
|
|
80
130
|
</div>
|
|
81
131
|
<div id="upstep-body">
|
|
82
132
|
${this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
|
|
83
133
|
</div>
|
|
84
134
|
</div>
|
|
85
|
-
`, (
|
|
86
|
-
|
|
87
|
-
this.tab =
|
|
135
|
+
`, (e = document.getElementById("upstep-backdrop")) == null || e.remove(), document.body.appendChild(t), (s = t.querySelector("#upstep-close")) == null || s.addEventListener("click", () => this.closeModal()), t.querySelectorAll(".upstep-tab").forEach((i) => {
|
|
136
|
+
i.addEventListener("click", () => {
|
|
137
|
+
this.tab = i.dataset.tab, this.renderModal();
|
|
88
138
|
});
|
|
89
139
|
}), this.bindSubmitForm(), this.bindVoteButtons();
|
|
90
140
|
}
|
|
91
141
|
renderSubmitForm() {
|
|
142
|
+
const t = ["BUG", "FEATURE", "GENERAL"], e = { BUG: "🐞 Bug", FEATURE: "✨ Feature", GENERAL: "💬 General" };
|
|
92
143
|
return `
|
|
93
144
|
<div class="upstep-form">
|
|
94
145
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
95
146
|
<div class="upstep-type-row">
|
|
96
|
-
${
|
|
147
|
+
${t.map((s) => `<button class="upstep-type-btn${this.selectedType === s ? " selected" : ""}" data-type="${s}">${e[s]}</button>`).join("")}
|
|
97
148
|
</div>
|
|
98
149
|
<button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
|
|
99
|
-
<div id="upstep-form-msg"
|
|
150
|
+
<div id="upstep-form-msg"></div>
|
|
100
151
|
</div>
|
|
101
152
|
`;
|
|
102
153
|
}
|
|
103
154
|
renderFeed() {
|
|
104
155
|
return this.feedItems.length ? this.feedItems.map(
|
|
105
|
-
(
|
|
106
|
-
<div class="upstep-feedback-item" data-id="${
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
<span class="upstep-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<
|
|
114
|
-
|
|
156
|
+
(t) => `
|
|
157
|
+
<div class="upstep-feedback-item" data-id="${t.id}">
|
|
158
|
+
<button class="upstep-vote${t.userVote === "UP" ? " voted" : ""}" data-vote="UP" data-feedback="${t.id}">
|
|
159
|
+
<span class="upstep-vote-arrow">▲</span>
|
|
160
|
+
<span class="upstep-vote-count">${t.upvotes}</span>
|
|
161
|
+
</button>
|
|
162
|
+
<div class="upstep-feedback-main">
|
|
163
|
+
<p class="upstep-feedback-content">${m(t.content)}</p>
|
|
164
|
+
<div class="upstep-feedback-meta">
|
|
165
|
+
<span class="upstep-badge upstep-badge-${t.type.toLowerCase()}">${t.type}</span>
|
|
166
|
+
<span class="upstep-feedback-date">${new Date(t.createdAt).toLocaleDateString()}</span>
|
|
167
|
+
</div>
|
|
115
168
|
</div>
|
|
116
169
|
</div>`
|
|
117
|
-
).join("") : '<div class="upstep-empty">No
|
|
170
|
+
).join("") : '<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>';
|
|
118
171
|
}
|
|
119
172
|
renderFeedList() {
|
|
120
|
-
const
|
|
121
|
-
!
|
|
173
|
+
const t = document.getElementById("upstep-body");
|
|
174
|
+
!t || this.tab !== "feed" || (t.innerHTML = this.renderFeed(), this.bindVoteButtons());
|
|
122
175
|
}
|
|
123
176
|
bindSubmitForm() {
|
|
124
|
-
var
|
|
125
|
-
document.querySelectorAll(".upstep-type-btn").forEach((
|
|
126
|
-
|
|
127
|
-
this.selectedType =
|
|
177
|
+
var t;
|
|
178
|
+
document.querySelectorAll(".upstep-type-btn").forEach((e) => {
|
|
179
|
+
e.addEventListener("click", () => {
|
|
180
|
+
this.selectedType = e.dataset.type, document.querySelectorAll(".upstep-type-btn").forEach((s) => s.classList.remove("selected")), e.classList.add("selected");
|
|
128
181
|
});
|
|
129
|
-
}), (
|
|
130
|
-
const
|
|
131
|
-
if (!
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
this.loading = !0,
|
|
182
|
+
}), (t = document.getElementById("upstep-submit-btn")) == null || t.addEventListener("click", async () => {
|
|
183
|
+
const e = document.getElementById("upstep-textarea"), s = document.getElementById("upstep-form-msg"), i = document.getElementById("upstep-submit-btn");
|
|
184
|
+
if (!e || this.loading) return;
|
|
185
|
+
const d = e.value.trim();
|
|
186
|
+
if (d) {
|
|
187
|
+
this.loading = !0, i && (i.disabled = !0, i.textContent = "Sending…");
|
|
135
188
|
try {
|
|
136
|
-
await this.client.submitFeedback({ content:
|
|
189
|
+
await this.client.submitFeedback({ content: d, type: this.selectedType }), e.value = "", s && (s.textContent = "Thanks — we got your feedback! 🎉"), await this.fetchFeed();
|
|
137
190
|
} catch {
|
|
138
|
-
|
|
191
|
+
s && (s.textContent = "Something went wrong. Please try again.");
|
|
139
192
|
} finally {
|
|
140
|
-
this.loading = !1,
|
|
193
|
+
this.loading = !1, i && (i.disabled = !1, i.textContent = "Send feedback");
|
|
141
194
|
}
|
|
142
195
|
}
|
|
143
196
|
});
|
|
144
197
|
}
|
|
145
198
|
bindVoteButtons() {
|
|
146
|
-
document.querySelectorAll(".upstep-vote
|
|
147
|
-
|
|
148
|
-
const
|
|
199
|
+
document.querySelectorAll(".upstep-vote").forEach((t) => {
|
|
200
|
+
t.addEventListener("click", async () => {
|
|
201
|
+
const e = t.dataset.feedback;
|
|
149
202
|
try {
|
|
150
|
-
await this.client.vote(
|
|
203
|
+
await this.client.vote(e, "UP"), await this.fetchFeed();
|
|
151
204
|
} catch {
|
|
152
205
|
}
|
|
153
206
|
});
|
|
154
207
|
});
|
|
155
208
|
}
|
|
156
209
|
}
|
|
157
|
-
function
|
|
158
|
-
return
|
|
210
|
+
function m(o) {
|
|
211
|
+
return o.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
159
212
|
}
|
|
160
|
-
let n = null;
|
|
161
|
-
const
|
|
162
|
-
init(
|
|
163
|
-
if (n = new
|
|
164
|
-
const
|
|
213
|
+
let n = null, a = null;
|
|
214
|
+
const y = {
|
|
215
|
+
init(o) {
|
|
216
|
+
if (n = new l(o), typeof window < "u") {
|
|
217
|
+
const t = {};
|
|
218
|
+
o.accentColor !== void 0 && (t.accentColor = o.accentColor), o.position !== void 0 && (t.position = o.position), o.theme !== void 0 && (t.theme = o.theme), o.launcher !== void 0 && (t.launcher = o.launcher);
|
|
219
|
+
const e = () => {
|
|
220
|
+
a = new g(n, t), a.mount();
|
|
221
|
+
};
|
|
165
222
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : e();
|
|
166
223
|
}
|
|
167
224
|
return n;
|
|
168
225
|
},
|
|
226
|
+
/** Open the feedback widget — use this to trigger it from your own UI. */
|
|
227
|
+
open() {
|
|
228
|
+
a == null || a.openWidget();
|
|
229
|
+
},
|
|
230
|
+
/** Close the feedback widget. */
|
|
231
|
+
close() {
|
|
232
|
+
a == null || a.closeWidget();
|
|
233
|
+
},
|
|
234
|
+
/** Set / update the end-user id at runtime (e.g. after the user logs in). */
|
|
235
|
+
identify(o) {
|
|
236
|
+
n == null || n.setUserId(o);
|
|
237
|
+
},
|
|
169
238
|
get client() {
|
|
170
239
|
if (!n) throw new Error("Upstep.init() must be called first");
|
|
171
240
|
return n;
|
|
172
241
|
}
|
|
173
242
|
};
|
|
174
243
|
if (typeof document < "u") {
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
-
const
|
|
178
|
-
|
|
244
|
+
const o = document.currentScript, t = o == null ? void 0 : o.dataset.apiKey, e = o == null ? void 0 : o.dataset.userId, s = o == null ? void 0 : o.dataset.baseUrl, i = o == null ? void 0 : o.dataset.accentColor, d = o == null ? void 0 : o.dataset.position, p = o == null ? void 0 : o.dataset.theme;
|
|
245
|
+
if (t) {
|
|
246
|
+
const r = { apiKey: t };
|
|
247
|
+
e && (r.userId = e), s && (r.baseUrl = s), i && (r.accentColor = i), (d === "left" || d === "right") && (r.position = d), (p === "light" || p === "dark" || p === "auto") && (r.theme = p), y.init(r);
|
|
179
248
|
}
|
|
180
249
|
}
|
|
181
250
|
export {
|
|
182
|
-
|
|
183
|
-
|
|
251
|
+
l as UpstepApiClient,
|
|
252
|
+
y as default
|
|
184
253
|
};
|