@upstep/js 0.3.0 → 0.5.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-q50Qqen1.mjs → api-CRsXibfd.mjs} +1 -1
- package/dist/api-Csp7O_a2.js +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/index.cjs +69 -50
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +154 -112
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts +9 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +245 -122
- package/dist/widget.d.ts +6 -1
- package/dist/widget.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/api-p1GbYq1j.js +0 -1
|
@@ -14,7 +14,7 @@ class r {
|
|
|
14
14
|
}
|
|
15
15
|
async listFeedback(e) {
|
|
16
16
|
const t = new URLSearchParams();
|
|
17
|
-
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);
|
|
17
|
+
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), this.userId && t.set("endUserId", this.userId);
|
|
18
18
|
const s = await fetch(`${this.baseUrl}/api/sdk/feedback?${t}`, {
|
|
19
19
|
headers: this.headers()
|
|
20
20
|
});
|
|
@@ -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),this.userId&&t.set("endUserId",this.userId);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;
|
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,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;
|
|
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;IAiB3B,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-Csp7O_a2.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(o=>{o.addEventListener("click",()=>{this.selectedType=o.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(s=>s.classList.remove("selected")),o.classList.add("selected")})}),(e=document.getElementById("upstep-submit-btn"))==null||e.addEventListener("click",async()=>{const o=document.getElementById("upstep-textarea"),s=document.getElementById("upstep-form-msg"),i=document.getElementById("upstep-submit-btn");if(!o||this.loading)return;const a=o.value.trim();if(a){this.loading=!0,i&&(i.disabled=!0);try{await this.client.submitFeedback({content:a,type:this.selectedType}),o.value="",s&&(s.textContent="Thanks for your feedback!"),await this.fetchFeed()}catch{s&&(s.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,i&&(i.disabled=!1)}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote-btn").forEach(e=>{e.addEventListener("click",async()=>{const o=e.dataset.feedback,s=e.dataset.vote;try{await this.client.vote(o,s),await this.fetchFeed()}catch{}})})}}function f(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let d=null,n=null;const l={init(t){if(d=new r.UpstepApiClient(t),typeof window<"u"){const e={};t.accentColor!==void 0&&(e.accentColor=t.accentColor),t.position!==void 0&&(e.position=t.position),t.launcher!==void 0&&(e.launcher=t.launcher);const o=()=>{n=new b(d,e),n.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o):o()}return d},open(){n==null||n.openWidget()},close(){n==null||n.closeWidget()},identify(t){d==null||d.setUserId(t)},get client(){if(!d)throw new Error("Upstep.init() must be called first");return d}};if(typeof document<"u"){const t=document.currentScript,e=t==null?void 0:t.dataset.apiKey,o=t==null?void 0:t.dataset.userId,s=t==null?void 0:t.dataset.baseUrl,i=t==null?void 0:t.dataset.accentColor,a=t==null?void 0:t.dataset.position;if(e){const p={apiKey:e};o&&(p.userId=o),s&&(p.baseUrl=s),i&&(p.accentColor=i),(a==="left"||a==="right")&&(p.position=a),l.init(p)}}exports.UpstepApiClient=r.UpstepApiClient;exports.default=l;
|
|
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.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;AAK3B,QAAA,MAAM,MAAM;iBACG,YAAY;
|
|
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,43 +1,79 @@
|
|
|
1
|
-
import { U as
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
import { U as l } from "./api-CRsXibfd.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) {
|
|
4
25
|
return `
|
|
5
|
-
#upstep-root *{box-sizing:border-box;font-family
|
|
6
|
-
#upstep-btn{position:fixed;bottom:24px;${
|
|
7
|
-
#upstep-btn:hover{
|
|
8
|
-
#upstep-
|
|
9
|
-
#upstep-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
#upstep-
|
|
13
|
-
#upstep-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
#upstep-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.upstep-
|
|
20
|
-
.upstep-
|
|
21
|
-
|
|
22
|
-
.upstep-
|
|
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)}
|
|
23
52
|
.upstep-submit:disabled{opacity:.5;cursor:not-allowed}
|
|
24
|
-
|
|
25
|
-
.upstep-feedback-item:
|
|
26
|
-
.upstep-feedback-
|
|
27
|
-
.upstep-
|
|
28
|
-
.upstep-vote-
|
|
29
|
-
.upstep-vote
|
|
30
|
-
.upstep-vote-
|
|
31
|
-
.upstep-
|
|
32
|
-
.upstep-
|
|
33
|
-
.upstep-
|
|
34
|
-
.upstep-
|
|
35
|
-
.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}
|
|
36
71
|
`;
|
|
37
72
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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;
|
|
41
77
|
}
|
|
42
78
|
mount() {
|
|
43
79
|
this.injectStyles(), this.showLauncher && this.renderButton();
|
|
@@ -51,161 +87,167 @@ class u {
|
|
|
51
87
|
this.closeModal();
|
|
52
88
|
}
|
|
53
89
|
injectStyles() {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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);
|
|
57
94
|
}
|
|
58
95
|
renderButton() {
|
|
59
|
-
const
|
|
60
|
-
|
|
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);
|
|
61
98
|
}
|
|
62
99
|
openModal() {
|
|
63
|
-
this.
|
|
100
|
+
this.isOpen = !0, this.fetchFeed(), this.renderModal();
|
|
64
101
|
}
|
|
65
102
|
closeModal() {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
e == null || e.remove();
|
|
103
|
+
var t;
|
|
104
|
+
this.isOpen = !1, (t = document.getElementById("upstep-backdrop")) == null || t.remove();
|
|
69
105
|
}
|
|
70
106
|
async fetchFeed() {
|
|
71
107
|
try {
|
|
72
|
-
const
|
|
73
|
-
this.feedItems =
|
|
108
|
+
const t = await this.client.listFeedback({ sort: "votes", limit: 20 });
|
|
109
|
+
this.feedItems = t.items, this.renderFeedList();
|
|
74
110
|
} catch {
|
|
75
111
|
}
|
|
76
112
|
}
|
|
77
113
|
renderModal() {
|
|
78
|
-
var
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
i.target ===
|
|
82
|
-
}),
|
|
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 = `
|
|
83
119
|
<div id="upstep-modal">
|
|
84
120
|
<div id="upstep-header">
|
|
85
|
-
<
|
|
86
|
-
|
|
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>
|
|
87
126
|
</div>
|
|
88
127
|
<div id="upstep-tabs">
|
|
89
|
-
<button class="upstep-tab ${this.tab === "submit" ? "active" : ""}" data-tab="submit">
|
|
90
|
-
<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>
|
|
91
130
|
</div>
|
|
92
131
|
<div id="upstep-body">
|
|
93
132
|
${this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
|
|
94
133
|
</div>
|
|
95
134
|
</div>
|
|
96
|
-
`, (
|
|
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) => {
|
|
97
136
|
i.addEventListener("click", () => {
|
|
98
137
|
this.tab = i.dataset.tab, this.renderModal();
|
|
99
138
|
});
|
|
100
139
|
}), this.bindSubmitForm(), this.bindVoteButtons();
|
|
101
140
|
}
|
|
102
141
|
renderSubmitForm() {
|
|
142
|
+
const t = ["BUG", "FEATURE", "GENERAL"], e = { BUG: "🐞 Bug", FEATURE: "✨ Feature", GENERAL: "💬 General" };
|
|
103
143
|
return `
|
|
104
144
|
<div class="upstep-form">
|
|
105
145
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
106
146
|
<div class="upstep-type-row">
|
|
107
|
-
${
|
|
147
|
+
${t.map((s) => `<button class="upstep-type-btn${this.selectedType === s ? " selected" : ""}" data-type="${s}">${e[s]}</button>`).join("")}
|
|
108
148
|
</div>
|
|
109
149
|
<button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
|
|
110
|
-
<div id="upstep-form-msg"
|
|
150
|
+
<div id="upstep-form-msg"></div>
|
|
111
151
|
</div>
|
|
112
152
|
`;
|
|
113
153
|
}
|
|
114
154
|
renderFeed() {
|
|
115
155
|
return this.feedItems.length ? this.feedItems.map(
|
|
116
|
-
(
|
|
117
|
-
<div class="upstep-feedback-item" data-id="${
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
<span class="upstep-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
<
|
|
125
|
-
|
|
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>
|
|
126
168
|
</div>
|
|
127
169
|
</div>`
|
|
128
|
-
).join("") : '<div class="upstep-empty">No
|
|
170
|
+
).join("") : '<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>';
|
|
129
171
|
}
|
|
130
172
|
renderFeedList() {
|
|
131
|
-
const
|
|
132
|
-
!
|
|
173
|
+
const t = document.getElementById("upstep-body");
|
|
174
|
+
!t || this.tab !== "feed" || (t.innerHTML = this.renderFeed(), this.bindVoteButtons());
|
|
133
175
|
}
|
|
134
176
|
bindSubmitForm() {
|
|
135
|
-
var
|
|
136
|
-
document.querySelectorAll(".upstep-type-btn").forEach((
|
|
137
|
-
|
|
138
|
-
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");
|
|
139
181
|
});
|
|
140
|
-
}), (
|
|
141
|
-
const
|
|
142
|
-
if (!
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
145
|
-
this.loading = !0, i && (i.disabled = !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…");
|
|
146
188
|
try {
|
|
147
|
-
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();
|
|
148
190
|
} catch {
|
|
149
191
|
s && (s.textContent = "Something went wrong. Please try again.");
|
|
150
192
|
} finally {
|
|
151
|
-
this.loading = !1, i && (i.disabled = !1);
|
|
193
|
+
this.loading = !1, i && (i.disabled = !1, i.textContent = "Send feedback");
|
|
152
194
|
}
|
|
153
195
|
}
|
|
154
196
|
});
|
|
155
197
|
}
|
|
156
198
|
bindVoteButtons() {
|
|
157
|
-
document.querySelectorAll(".upstep-vote
|
|
158
|
-
|
|
159
|
-
const
|
|
199
|
+
document.querySelectorAll(".upstep-vote").forEach((t) => {
|
|
200
|
+
t.addEventListener("click", async () => {
|
|
201
|
+
const e = t.dataset.feedback;
|
|
160
202
|
try {
|
|
161
|
-
await this.client.vote(
|
|
203
|
+
await this.client.vote(e, "UP"), await this.fetchFeed();
|
|
162
204
|
} catch {
|
|
163
205
|
}
|
|
164
206
|
});
|
|
165
207
|
});
|
|
166
208
|
}
|
|
167
209
|
}
|
|
168
|
-
function
|
|
169
|
-
return
|
|
210
|
+
function m(o) {
|
|
211
|
+
return o.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
170
212
|
}
|
|
171
|
-
let
|
|
172
|
-
const
|
|
173
|
-
init(
|
|
174
|
-
if (
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
|
|
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();
|
|
179
221
|
};
|
|
180
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
222
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : e();
|
|
181
223
|
}
|
|
182
|
-
return
|
|
224
|
+
return n;
|
|
183
225
|
},
|
|
184
226
|
/** Open the feedback widget — use this to trigger it from your own UI. */
|
|
185
227
|
open() {
|
|
186
|
-
|
|
228
|
+
a == null || a.openWidget();
|
|
187
229
|
},
|
|
188
230
|
/** Close the feedback widget. */
|
|
189
231
|
close() {
|
|
190
|
-
|
|
232
|
+
a == null || a.closeWidget();
|
|
191
233
|
},
|
|
192
234
|
/** Set / update the end-user id at runtime (e.g. after the user logs in). */
|
|
193
|
-
identify(
|
|
194
|
-
|
|
235
|
+
identify(o) {
|
|
236
|
+
n == null || n.setUserId(o);
|
|
195
237
|
},
|
|
196
238
|
get client() {
|
|
197
|
-
if (!
|
|
198
|
-
return
|
|
239
|
+
if (!n) throw new Error("Upstep.init() must be called first");
|
|
240
|
+
return n;
|
|
199
241
|
}
|
|
200
242
|
};
|
|
201
243
|
if (typeof document < "u") {
|
|
202
|
-
const
|
|
203
|
-
if (
|
|
204
|
-
const
|
|
205
|
-
|
|
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);
|
|
206
248
|
}
|
|
207
249
|
}
|
|
208
250
|
export {
|
|
209
|
-
|
|
210
|
-
|
|
251
|
+
l as UpstepApiClient,
|
|
252
|
+
y as default
|
|
211
253
|
};
|
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),A=require("./api-Csp7O_a2.js"),I="#D97757",W={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},L={bg:"#1c1b19",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function T(a){const[c,t]=o.useState(()=>a==="dark"?!0:a==="light"?!1:typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1);return o.useEffect(()=>{if(a!=="auto"||typeof window>"u"||!window.matchMedia){t(a==="dark");return}const i=window.matchMedia("(prefers-color-scheme: dark)"),r=d=>t(d.matches);return t(i.matches),i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[a]),c?L:W}const E=o.createContext(null);function G({children:a,...c}){const[t]=o.useState(()=>new A.UpstepApiClient(c)),[i,r]=o.useState([]),[d,n]=o.useState(!1);o.useEffect(()=>{t.setUserId(c.userId)},[t,c.userId]);const f=o.useCallback(async()=>{const l=await t.listFeedback({sort:"votes",limit:20});r(l.items)},[t]);o.useEffect(()=>{f()},[f]);const h=o.useCallback(async(l,x)=>{const u={content:l};x!==void 0&&(u.type=x),await t.submitFeedback(u),await f()},[t,f]),m=o.useCallback(async(l,x)=>{await t.vote(l,x),await f()},[t,f]),y=o.useCallback(()=>n(!0),[]),S=o.useCallback(()=>n(!1),[]),p=o.useCallback(l=>t.setUserId(l),[t]);return e.jsx(E.Provider,{value:{client:t,feedItems:i,loadFeed:f,submit:h,vote:m,isOpen:d,open:y,close:S,identify:p,accentColor:c.accentColor??I,theme:c.theme??"auto"},children:a})}function F(){const a=o.useContext(E);if(!a)throw new Error("useUpstep must be used inside <UpstepProvider>");return a}const B={BUG:"🐞 Bug",FEATURE:"✨ Feature",GENERAL:"💬 General"};function D({position:a="bottom-right",accentColor:c,theme:t,hideLauncher:i=!1}){const r=F(),d=c??r.accentColor,n=T(t??r.theme),{feedItems:f,submit:h,vote:m,isOpen:y,open:S,close:p}=r,[l,x]=o.useState("submit"),[u,v]=o.useState(""),[g,R]=o.useState("GENERAL"),[j,w]=o.useState(""),[b,C]=o.useState(!1),U=a==="bottom-left"?{position:"fixed",bottom:24,left:24}:{position:"fixed",bottom:24,right:24};async function z(){if(!(!u.trim()||b)){C(!0);try{await h(u.trim(),g),v(""),w("Thanks — we got your feedback! 🎉")}catch{w("Something went wrong.")}finally{C(!1)}}}const k='-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';return e.jsxs(e.Fragment,{children:[!i&&e.jsxs("button",{onClick:S,style:{...U,zIndex:9998,display:"inline-flex",alignItems:"center",gap:7,background:d,color:"#fff",border:"none",borderRadius:9999,padding:"12px 18px",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:k,boxShadow:"0 6px 20px rgba(26,25,21,.18)"},children:[e.jsx(H,{})," Feedback"]}),y&&e.jsx("div",{onClick:s=>s.target===s.currentTarget&&p(),style:{position:"fixed",inset:0,background:n.overlay,backdropFilter:"blur(3px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:16,fontFamily:k},children:e.jsxs("div",{style:{background:n.bg,border:`1px solid ${n.border}`,borderRadius:20,width:"100%",maxWidth:440,maxHeight:"88vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 64px rgba(0,0,0,.28)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"20px 20px 0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:700,fontSize:16,color:n.text,letterSpacing:"-.01em"},children:"Share your feedback"}),e.jsx("div",{style:{fontSize:12.5,color:n.textFaint,marginTop:2},children:"Tell us what to build next, or vote on ideas."})]}),e.jsx("button",{onClick:p,style:{background:n.bgSoft,border:"none",width:28,height:28,borderRadius:8,fontSize:14,cursor:"pointer",color:n.textSoft,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]}),e.jsx("div",{style:{display:"flex",gap:4,margin:"16px 20px 0",padding:4,background:n.bgSoft,borderRadius:11},children:["submit","feed"].map(s=>e.jsx("button",{onClick:()=>x(s),style:{flex:1,padding:8,border:"none",borderRadius:8,fontSize:13,fontWeight:600,cursor:"pointer",background:l===s?n.bg:"transparent",color:l===s?n.text:n.textSoft,boxShadow:l===s?"0 1px 3px rgba(0,0,0,.08)":"none"},children:s==="submit"?"Give feedback":"Vote on ideas"},s))}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"18px 20px 22px"},children:l==="submit"?e.jsxs("div",{children:[e.jsx("textarea",{value:u,onChange:s=>v(s.target.value),placeholder:"What's on your mind?",maxLength:2e3,style:{width:"100%",minHeight:104,border:`1px solid ${n.border}`,borderRadius:12,padding:12,fontSize:14,lineHeight:1.5,resize:"vertical",outline:"none",background:n.bgSoft,color:n.text,fontFamily:k}}),e.jsx("div",{style:{display:"flex",gap:7,margin:"12px 0 4px"},children:["BUG","FEATURE","GENERAL"].map(s=>e.jsx("button",{onClick:()=>R(s),style:{flex:1,padding:"8px 10px",borderRadius:9,fontSize:12.5,fontWeight:600,cursor:"pointer",background:g===s?d:n.bg,color:g===s?"#fff":n.textSoft,border:`1px solid ${g===s?d:n.border}`},children:B[s]},s))}),e.jsx("button",{onClick:z,disabled:b||!u.trim(),style:{width:"100%",padding:12,background:d,color:"#fff",border:"none",borderRadius:11,fontSize:14,fontWeight:600,cursor:"pointer",marginTop:14,opacity:b||!u.trim()?.5:1},children:b?"Sending…":"Send feedback"}),j&&e.jsx("p",{style:{textAlign:"center",fontSize:13,color:d,fontWeight:500,marginTop:12},children:j})]}):e.jsx(N,{items:f,onVote:m,accent:d,p:n})})]})})]})}function H(){return e.jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}const P={BUG:"#fdecec",FEATURE:"#e9f0fd",GENERAL:""},M={BUG:"#d6453d",FEATURE:"#3b76d6",GENERAL:""};function N({items:a,onVote:c,accent:t,p:i}){return a.length?e.jsx(e.Fragment,{children:a.map(r=>{const d=r.userVote==="UP";return e.jsxs("div",{style:{display:"flex",gap:12,padding:14,border:`1px solid ${i.border}`,borderRadius:14,marginBottom:10,background:i.bg},children:[e.jsxs("button",{onClick:()=>c(r.id,"UP"),style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,minWidth:46,padding:"7px 0",borderRadius:11,cursor:"pointer",border:`1px solid ${d?t:i.border}`,background:d?`${t}1a`:i.bgSoft},children:[e.jsx("span",{style:{fontSize:11,lineHeight:1,color:t},children:"▲"}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:i.text,lineHeight:1.1},children:r.upvotes})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:13.5,lineHeight:1.5,color:i.text,margin:"0 0 8px",wordBreak:"break-word"},children:r.content}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[e.jsx("span",{style:{padding:"2px 8px",borderRadius:9999,fontSize:10.5,fontWeight:700,letterSpacing:".02em",background:P[r.type]||i.bgSoft,color:M[r.type]||i.textSoft},children:r.type}),e.jsx("span",{style:{fontSize:11,color:i.textFaint},children:new Date(r.createdAt).toLocaleDateString()})]})]})]},r.id)})}):e.jsxs("div",{style:{textAlign:"center",padding:"40px 0"},children:[e.jsx("div",{style:{color:i.textSoft,fontSize:15,fontWeight:600,marginBottom:4},children:"No ideas yet"}),e.jsx("div",{style:{color:i.textFaint,fontSize:14},children:"Be the first to share one."})]})}exports.FeedbackWidget=D;exports.UpstepProvider=G;exports.useUpstep=F;
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as React, ReactNode } from 'react';
|
|
2
2
|
import { Feedback, FeedbackType, UpstepConfig } from '@upstep/types';
|
|
3
3
|
import { UpstepApiClient } from './api';
|
|
4
|
+
type ThemeMode = "light" | "dark" | "auto";
|
|
4
5
|
interface UpstepContextValue {
|
|
5
6
|
client: UpstepApiClient;
|
|
6
7
|
feedItems: Feedback[];
|
|
@@ -15,6 +16,10 @@ interface UpstepContextValue {
|
|
|
15
16
|
close: () => void;
|
|
16
17
|
/** Set / update the end-user id at runtime (e.g. after the user logs in). */
|
|
17
18
|
identify: (userId: string | undefined) => void;
|
|
19
|
+
/** Accent color from provider config (default applied). */
|
|
20
|
+
accentColor: string;
|
|
21
|
+
/** Theme mode from provider config (default "auto"). */
|
|
22
|
+
theme: ThemeMode;
|
|
18
23
|
}
|
|
19
24
|
export declare function UpstepProvider({ children, ...config }: UpstepConfig & {
|
|
20
25
|
children: ReactNode;
|
|
@@ -23,14 +28,16 @@ export declare function useUpstep(): UpstepContextValue;
|
|
|
23
28
|
interface FeedbackWidgetProps {
|
|
24
29
|
/** Position of the trigger button */
|
|
25
30
|
position?: "bottom-right" | "bottom-left";
|
|
26
|
-
/** Accent color
|
|
31
|
+
/** Accent color. Defaults to the provider's accentColor (or "#D97757"). */
|
|
27
32
|
accentColor?: string;
|
|
33
|
+
/** Theme. Defaults to the provider's theme (or "auto"). */
|
|
34
|
+
theme?: ThemeMode;
|
|
28
35
|
/**
|
|
29
36
|
* Hide the floating launcher button and only show the modal when opened
|
|
30
37
|
* programmatically via `useUpstep().open()` — e.g. from a settings menu.
|
|
31
38
|
*/
|
|
32
39
|
hideLauncher?: boolean;
|
|
33
40
|
}
|
|
34
|
-
export declare function FeedbackWidget({ position, accentColor, hideLauncher, }: FeedbackWidgetProps): React.JSX.Element;
|
|
41
|
+
export declare function FeedbackWidget({ position, accentColor, theme, hideLauncher, }: FeedbackWidgetProps): React.JSX.Element;
|
|
35
42
|
export {};
|
|
36
43
|
//# sourceMappingURL=react.d.ts.map
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAMxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAmD3C,UAAU,kBAAkB;IAC1B,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,oDAAoD;IACpD,MAAM,EAAE,OAAO,CAAC;IAChB,8EAA8E;IAC9E,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,gCAAgC;IAChC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,6EAA6E;IAC7E,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/C,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,KAAK,EAAE,SAAS,CAAC;CAClB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,qBA2CxC;AAED,wBAAgB,SAAS,IAAI,kBAAkB,CAI9C;AAID,UAAU,mBAAmB;IAC3B,qCAAqC;IACrC,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC;IAC1C,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAMD,wBAAgB,cAAc,CAAC,EAC7B,QAAyB,EACzB,WAAW,EACX,KAAK,EACL,YAAoB,GACrB,EAAE,mBAAmB,qBAmJrB"}
|
package/dist/react.js
CHANGED
|
@@ -1,169 +1,268 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { U as
|
|
4
|
-
const
|
|
5
|
-
|
|
1
|
+
import { jsxs as c, Fragment as z, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as G, useState as p, useEffect as E, useCallback as b, useContext as T } from "react";
|
|
3
|
+
import { U as B } from "./api-CRsXibfd.mjs";
|
|
4
|
+
const D = "#D97757", H = {
|
|
5
|
+
bg: "#ffffff",
|
|
6
|
+
bgSoft: "#f6f5f2",
|
|
7
|
+
bgHover: "#efede8",
|
|
8
|
+
text: "#1a1915",
|
|
9
|
+
textSoft: "#56544d",
|
|
10
|
+
textFaint: "#9b9890",
|
|
11
|
+
border: "#e8e6df",
|
|
12
|
+
overlay: "rgba(26,25,21,.45)"
|
|
13
|
+
}, j = {
|
|
14
|
+
bg: "#1c1b19",
|
|
15
|
+
bgSoft: "#262522",
|
|
16
|
+
bgHover: "#302e2a",
|
|
17
|
+
text: "#f5f4f0",
|
|
18
|
+
textSoft: "#b4b1a8",
|
|
19
|
+
textFaint: "#7d7a72",
|
|
20
|
+
border: "#33312c",
|
|
21
|
+
overlay: "rgba(0,0,0,.6)"
|
|
22
|
+
};
|
|
23
|
+
function M(d) {
|
|
24
|
+
const [l, t] = p(() => d === "dark" ? !0 : d === "light" ? !1 : typeof window < "u" && window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)").matches : !1);
|
|
25
|
+
return E(() => {
|
|
26
|
+
if (d !== "auto" || typeof window > "u" || !window.matchMedia) {
|
|
27
|
+
t(d === "dark");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const n = window.matchMedia("(prefers-color-scheme: dark)"), i = (a) => t(a.matches);
|
|
31
|
+
return t(n.matches), n.addEventListener("change", i), () => n.removeEventListener("change", i);
|
|
32
|
+
}, [d]), l ? j : H;
|
|
33
|
+
}
|
|
34
|
+
const A = G(null);
|
|
35
|
+
function J({
|
|
6
36
|
children: d,
|
|
7
|
-
...
|
|
37
|
+
...l
|
|
8
38
|
}) {
|
|
9
|
-
const [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}, [
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
}, [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}, [
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
}, [
|
|
24
|
-
await
|
|
25
|
-
}, [
|
|
39
|
+
const [t] = p(() => new B(l)), [n, i] = p([]), [a, o] = p(!1);
|
|
40
|
+
E(() => {
|
|
41
|
+
t.setUserId(l.userId);
|
|
42
|
+
}, [t, l.userId]);
|
|
43
|
+
const f = b(async () => {
|
|
44
|
+
const s = await t.listFeedback({ sort: "votes", limit: 20 });
|
|
45
|
+
i(s.items);
|
|
46
|
+
}, [t]);
|
|
47
|
+
E(() => {
|
|
48
|
+
f();
|
|
49
|
+
}, [f]);
|
|
50
|
+
const y = b(async (s, u) => {
|
|
51
|
+
const g = { content: s };
|
|
52
|
+
u !== void 0 && (g.type = u), await t.submitFeedback(g), await f();
|
|
53
|
+
}, [t, f]), v = b(async (s, u) => {
|
|
54
|
+
await t.vote(s, u), await f();
|
|
55
|
+
}, [t, f]), S = b(() => o(!0), []), k = b(() => o(!1), []), h = b((s) => t.setUserId(s), [t]);
|
|
26
56
|
return /* @__PURE__ */ e(
|
|
27
|
-
|
|
57
|
+
A.Provider,
|
|
28
58
|
{
|
|
29
|
-
value: {
|
|
59
|
+
value: {
|
|
60
|
+
client: t,
|
|
61
|
+
feedItems: n,
|
|
62
|
+
loadFeed: f,
|
|
63
|
+
submit: y,
|
|
64
|
+
vote: v,
|
|
65
|
+
isOpen: a,
|
|
66
|
+
open: S,
|
|
67
|
+
close: k,
|
|
68
|
+
identify: h,
|
|
69
|
+
accentColor: l.accentColor ?? D,
|
|
70
|
+
theme: l.theme ?? "auto"
|
|
71
|
+
},
|
|
30
72
|
children: d
|
|
31
73
|
}
|
|
32
74
|
);
|
|
33
75
|
}
|
|
34
|
-
function
|
|
35
|
-
const d =
|
|
76
|
+
function N() {
|
|
77
|
+
const d = T(A);
|
|
36
78
|
if (!d) throw new Error("useUpstep must be used inside <UpstepProvider>");
|
|
37
79
|
return d;
|
|
38
80
|
}
|
|
39
|
-
|
|
81
|
+
const P = {
|
|
82
|
+
BUG: "🐞 Bug",
|
|
83
|
+
FEATURE: "✨ Feature",
|
|
84
|
+
GENERAL: "💬 General"
|
|
85
|
+
};
|
|
86
|
+
function Q({
|
|
40
87
|
position: d = "bottom-right",
|
|
41
|
-
accentColor:
|
|
42
|
-
|
|
88
|
+
accentColor: l,
|
|
89
|
+
theme: t,
|
|
90
|
+
hideLauncher: n = !1
|
|
43
91
|
}) {
|
|
44
|
-
const i =
|
|
45
|
-
async function
|
|
46
|
-
if (!(!
|
|
47
|
-
|
|
92
|
+
const i = N(), a = l ?? i.accentColor, o = M(t ?? i.theme), { feedItems: f, submit: y, vote: v, isOpen: S, open: k, close: h } = i, [s, u] = p("submit"), [g, C] = p(""), [x, I] = p("GENERAL"), [F, R] = p(""), [m, U] = p(!1), L = d === "bottom-left" ? { position: "fixed", bottom: 24, left: 24 } : { position: "fixed", bottom: 24, right: 24 };
|
|
93
|
+
async function W() {
|
|
94
|
+
if (!(!g.trim() || m)) {
|
|
95
|
+
U(!0);
|
|
48
96
|
try {
|
|
49
|
-
await
|
|
97
|
+
await y(g.trim(), x), C(""), R("Thanks — we got your feedback! 🎉");
|
|
50
98
|
} catch {
|
|
51
|
-
|
|
99
|
+
R("Something went wrong.");
|
|
52
100
|
} finally {
|
|
53
|
-
|
|
101
|
+
U(!1);
|
|
54
102
|
}
|
|
55
103
|
}
|
|
56
104
|
}
|
|
57
|
-
|
|
58
|
-
|
|
105
|
+
const w = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';
|
|
106
|
+
return /* @__PURE__ */ c(z, { children: [
|
|
107
|
+
!n && /* @__PURE__ */ c(
|
|
59
108
|
"button",
|
|
60
109
|
{
|
|
61
110
|
onClick: k,
|
|
62
111
|
style: {
|
|
63
|
-
...
|
|
112
|
+
...L,
|
|
64
113
|
zIndex: 9998,
|
|
65
|
-
|
|
114
|
+
display: "inline-flex",
|
|
115
|
+
alignItems: "center",
|
|
116
|
+
gap: 7,
|
|
117
|
+
background: a,
|
|
66
118
|
color: "#fff",
|
|
67
119
|
border: "none",
|
|
68
120
|
borderRadius: 9999,
|
|
69
|
-
padding: "12px
|
|
121
|
+
padding: "12px 18px",
|
|
70
122
|
fontSize: 14,
|
|
71
123
|
fontWeight: 600,
|
|
72
124
|
cursor: "pointer",
|
|
73
|
-
|
|
125
|
+
fontFamily: w,
|
|
126
|
+
boxShadow: "0 6px 20px rgba(26,25,21,.18)"
|
|
74
127
|
},
|
|
75
|
-
children:
|
|
128
|
+
children: [
|
|
129
|
+
/* @__PURE__ */ e($, {}),
|
|
130
|
+
" Feedback"
|
|
131
|
+
]
|
|
76
132
|
}
|
|
77
133
|
),
|
|
78
|
-
|
|
134
|
+
S && /* @__PURE__ */ e(
|
|
79
135
|
"div",
|
|
80
136
|
{
|
|
81
|
-
onClick: (
|
|
137
|
+
onClick: (r) => r.target === r.currentTarget && h(),
|
|
82
138
|
style: {
|
|
83
139
|
position: "fixed",
|
|
84
140
|
inset: 0,
|
|
85
|
-
background:
|
|
141
|
+
background: o.overlay,
|
|
142
|
+
backdropFilter: "blur(3px)",
|
|
86
143
|
zIndex: 9999,
|
|
87
144
|
display: "flex",
|
|
88
|
-
alignItems: "
|
|
89
|
-
justifyContent: "center"
|
|
145
|
+
alignItems: "center",
|
|
146
|
+
justifyContent: "center",
|
|
147
|
+
padding: 16,
|
|
148
|
+
fontFamily: w
|
|
90
149
|
},
|
|
91
|
-
children: /* @__PURE__ */
|
|
150
|
+
children: /* @__PURE__ */ c(
|
|
92
151
|
"div",
|
|
93
152
|
{
|
|
94
153
|
style: {
|
|
95
|
-
background:
|
|
96
|
-
|
|
154
|
+
background: o.bg,
|
|
155
|
+
border: `1px solid ${o.border}`,
|
|
156
|
+
borderRadius: 20,
|
|
97
157
|
width: "100%",
|
|
98
|
-
maxWidth:
|
|
99
|
-
maxHeight: "
|
|
158
|
+
maxWidth: 440,
|
|
159
|
+
maxHeight: "88vh",
|
|
100
160
|
display: "flex",
|
|
101
161
|
flexDirection: "column",
|
|
102
|
-
overflow: "hidden"
|
|
162
|
+
overflow: "hidden",
|
|
163
|
+
boxShadow: "0 24px 64px rgba(0,0,0,.28)"
|
|
103
164
|
},
|
|
104
165
|
children: [
|
|
105
|
-
/* @__PURE__ */
|
|
106
|
-
/* @__PURE__ */
|
|
107
|
-
|
|
166
|
+
/* @__PURE__ */ c("div", { style: { display: "flex", alignItems: "flex-start", justifyContent: "space-between", padding: "20px 20px 0" }, children: [
|
|
167
|
+
/* @__PURE__ */ c("div", { children: [
|
|
168
|
+
/* @__PURE__ */ e("div", { style: { fontWeight: 700, fontSize: 16, color: o.text, letterSpacing: "-.01em" }, children: "Share your feedback" }),
|
|
169
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 12.5, color: o.textFaint, marginTop: 2 }, children: "Tell us what to build next, or vote on ideas." })
|
|
170
|
+
] }),
|
|
171
|
+
/* @__PURE__ */ e(
|
|
172
|
+
"button",
|
|
173
|
+
{
|
|
174
|
+
onClick: h,
|
|
175
|
+
style: { background: o.bgSoft, border: "none", width: 28, height: 28, borderRadius: 8, fontSize: 14, cursor: "pointer", color: o.textSoft, display: "flex", alignItems: "center", justifyContent: "center" },
|
|
176
|
+
children: "✕"
|
|
177
|
+
}
|
|
178
|
+
)
|
|
108
179
|
] }),
|
|
109
|
-
/* @__PURE__ */ e("div", { style: { display: "flex",
|
|
180
|
+
/* @__PURE__ */ e("div", { style: { display: "flex", gap: 4, margin: "16px 20px 0", padding: 4, background: o.bgSoft, borderRadius: 11 }, children: ["submit", "feed"].map((r) => /* @__PURE__ */ e(
|
|
110
181
|
"button",
|
|
111
182
|
{
|
|
112
|
-
onClick: () =>
|
|
183
|
+
onClick: () => u(r),
|
|
113
184
|
style: {
|
|
114
185
|
flex: 1,
|
|
115
|
-
padding:
|
|
116
|
-
background: "none",
|
|
186
|
+
padding: 8,
|
|
117
187
|
border: "none",
|
|
188
|
+
borderRadius: 8,
|
|
118
189
|
fontSize: 13,
|
|
119
|
-
fontWeight:
|
|
190
|
+
fontWeight: 600,
|
|
120
191
|
cursor: "pointer",
|
|
121
|
-
|
|
122
|
-
|
|
192
|
+
background: s === r ? o.bg : "transparent",
|
|
193
|
+
color: s === r ? o.text : o.textSoft,
|
|
194
|
+
boxShadow: s === r ? "0 1px 3px rgba(0,0,0,.08)" : "none"
|
|
123
195
|
},
|
|
124
|
-
children:
|
|
196
|
+
children: r === "submit" ? "Give feedback" : "Vote on ideas"
|
|
125
197
|
},
|
|
126
|
-
|
|
198
|
+
r
|
|
127
199
|
)) }),
|
|
128
|
-
/* @__PURE__ */ e("div", { style: { flex: 1, overflowY: "auto", padding:
|
|
200
|
+
/* @__PURE__ */ e("div", { style: { flex: 1, overflowY: "auto", padding: "18px 20px 22px" }, children: s === "submit" ? /* @__PURE__ */ c("div", { children: [
|
|
129
201
|
/* @__PURE__ */ e(
|
|
130
202
|
"textarea",
|
|
131
203
|
{
|
|
132
|
-
value:
|
|
133
|
-
onChange: (
|
|
204
|
+
value: g,
|
|
205
|
+
onChange: (r) => C(r.target.value),
|
|
134
206
|
placeholder: "What's on your mind?",
|
|
135
207
|
maxLength: 2e3,
|
|
136
|
-
style: {
|
|
208
|
+
style: {
|
|
209
|
+
width: "100%",
|
|
210
|
+
minHeight: 104,
|
|
211
|
+
border: `1px solid ${o.border}`,
|
|
212
|
+
borderRadius: 12,
|
|
213
|
+
padding: 12,
|
|
214
|
+
fontSize: 14,
|
|
215
|
+
lineHeight: 1.5,
|
|
216
|
+
resize: "vertical",
|
|
217
|
+
outline: "none",
|
|
218
|
+
background: o.bgSoft,
|
|
219
|
+
color: o.text,
|
|
220
|
+
fontFamily: w
|
|
221
|
+
}
|
|
137
222
|
}
|
|
138
223
|
),
|
|
139
|
-
/* @__PURE__ */ e("div", { style: { display: "flex", gap:
|
|
224
|
+
/* @__PURE__ */ e("div", { style: { display: "flex", gap: 7, margin: "12px 0 4px" }, children: ["BUG", "FEATURE", "GENERAL"].map((r) => /* @__PURE__ */ e(
|
|
140
225
|
"button",
|
|
141
226
|
{
|
|
142
|
-
onClick: () =>
|
|
227
|
+
onClick: () => I(r),
|
|
143
228
|
style: {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
229
|
+
flex: 1,
|
|
230
|
+
padding: "8px 10px",
|
|
231
|
+
borderRadius: 9,
|
|
232
|
+
fontSize: 12.5,
|
|
233
|
+
fontWeight: 600,
|
|
147
234
|
cursor: "pointer",
|
|
148
|
-
background:
|
|
149
|
-
color:
|
|
150
|
-
border: `1px solid ${
|
|
235
|
+
background: x === r ? a : o.bg,
|
|
236
|
+
color: x === r ? "#fff" : o.textSoft,
|
|
237
|
+
border: `1px solid ${x === r ? a : o.border}`
|
|
151
238
|
},
|
|
152
|
-
children:
|
|
239
|
+
children: P[r]
|
|
153
240
|
},
|
|
154
|
-
|
|
241
|
+
r
|
|
155
242
|
)) }),
|
|
156
243
|
/* @__PURE__ */ e(
|
|
157
244
|
"button",
|
|
158
245
|
{
|
|
159
|
-
onClick:
|
|
160
|
-
disabled:
|
|
161
|
-
style: {
|
|
162
|
-
|
|
246
|
+
onClick: W,
|
|
247
|
+
disabled: m || !g.trim(),
|
|
248
|
+
style: {
|
|
249
|
+
width: "100%",
|
|
250
|
+
padding: 12,
|
|
251
|
+
background: a,
|
|
252
|
+
color: "#fff",
|
|
253
|
+
border: "none",
|
|
254
|
+
borderRadius: 11,
|
|
255
|
+
fontSize: 14,
|
|
256
|
+
fontWeight: 600,
|
|
257
|
+
cursor: "pointer",
|
|
258
|
+
marginTop: 14,
|
|
259
|
+
opacity: m || !g.trim() ? 0.5 : 1
|
|
260
|
+
},
|
|
261
|
+
children: m ? "Sending…" : "Send feedback"
|
|
163
262
|
}
|
|
164
263
|
),
|
|
165
|
-
|
|
166
|
-
] }) : /* @__PURE__ */ e(
|
|
264
|
+
F && /* @__PURE__ */ e("p", { style: { textAlign: "center", fontSize: 13, color: a, fontWeight: 500, marginTop: 12 }, children: F })
|
|
265
|
+
] }) : /* @__PURE__ */ e(O, { items: f, onVote: v, accent: a, p: o }) })
|
|
167
266
|
]
|
|
168
267
|
}
|
|
169
268
|
)
|
|
@@ -171,41 +270,65 @@ function j({
|
|
|
171
270
|
)
|
|
172
271
|
] });
|
|
173
272
|
}
|
|
174
|
-
function
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
273
|
+
function $() {
|
|
274
|
+
return /* @__PURE__ */ e("svg", { width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) });
|
|
275
|
+
}
|
|
276
|
+
const V = { BUG: "#fdecec", FEATURE: "#e9f0fd", GENERAL: "" }, _ = { BUG: "#d6453d", FEATURE: "#3b76d6", GENERAL: "" };
|
|
277
|
+
function O({
|
|
278
|
+
items: d,
|
|
279
|
+
onVote: l,
|
|
280
|
+
accent: t,
|
|
281
|
+
p: n
|
|
282
|
+
}) {
|
|
283
|
+
return d.length ? /* @__PURE__ */ e(z, { children: d.map((i) => {
|
|
284
|
+
const a = i.userVote === "UP";
|
|
285
|
+
return /* @__PURE__ */ c("div", { style: { display: "flex", gap: 12, padding: 14, border: `1px solid ${n.border}`, borderRadius: 14, marginBottom: 10, background: n.bg }, children: [
|
|
286
|
+
/* @__PURE__ */ c(
|
|
287
|
+
"button",
|
|
288
|
+
{
|
|
289
|
+
onClick: () => l(i.id, "UP"),
|
|
290
|
+
style: {
|
|
291
|
+
display: "flex",
|
|
292
|
+
flexDirection: "column",
|
|
293
|
+
alignItems: "center",
|
|
294
|
+
justifyContent: "center",
|
|
295
|
+
gap: 1,
|
|
296
|
+
minWidth: 46,
|
|
297
|
+
padding: "7px 0",
|
|
298
|
+
borderRadius: 11,
|
|
299
|
+
cursor: "pointer",
|
|
300
|
+
border: `1px solid ${a ? t : n.border}`,
|
|
301
|
+
background: a ? `${t}1a` : n.bgSoft
|
|
302
|
+
},
|
|
303
|
+
children: [
|
|
304
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 11, lineHeight: 1, color: t }, children: "▲" }),
|
|
305
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 14, fontWeight: 700, color: n.text, lineHeight: 1.1 }, children: i.upvotes })
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
),
|
|
309
|
+
/* @__PURE__ */ c("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
310
|
+
/* @__PURE__ */ e("p", { style: { fontSize: 13.5, lineHeight: 1.5, color: n.text, margin: "0 0 8px", wordBreak: "break-word" }, children: i.content }),
|
|
311
|
+
/* @__PURE__ */ c("div", { style: { display: "flex", alignItems: "center", gap: 7 }, children: [
|
|
312
|
+
/* @__PURE__ */ e("span", { style: {
|
|
313
|
+
padding: "2px 8px",
|
|
314
|
+
borderRadius: 9999,
|
|
315
|
+
fontSize: 10.5,
|
|
316
|
+
fontWeight: 700,
|
|
317
|
+
letterSpacing: ".02em",
|
|
318
|
+
background: V[i.type] || n.bgSoft,
|
|
319
|
+
color: _[i.type] || n.textSoft
|
|
320
|
+
}, children: i.type }),
|
|
321
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 11, color: n.textFaint }, children: new Date(i.createdAt).toLocaleDateString() })
|
|
322
|
+
] })
|
|
323
|
+
] })
|
|
324
|
+
] }, i.id);
|
|
325
|
+
}) }) : /* @__PURE__ */ c("div", { style: { textAlign: "center", padding: "40px 0" }, children: [
|
|
326
|
+
/* @__PURE__ */ e("div", { style: { color: n.textSoft, fontSize: 15, fontWeight: 600, marginBottom: 4 }, children: "No ideas yet" }),
|
|
327
|
+
/* @__PURE__ */ e("div", { style: { color: n.textFaint, fontSize: 14 }, children: "Be the first to share one." })
|
|
328
|
+
] });
|
|
206
329
|
}
|
|
207
330
|
export {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
331
|
+
Q as FeedbackWidget,
|
|
332
|
+
J as UpstepProvider,
|
|
333
|
+
N as useUpstep
|
|
211
334
|
};
|
package/dist/widget.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { UpstepApiClient } from './api';
|
|
2
|
+
type ThemeMode = "light" | "dark" | "auto";
|
|
2
3
|
export interface WidgetOptions {
|
|
3
4
|
accentColor?: string;
|
|
4
5
|
position?: "left" | "right";
|
|
6
|
+
/** Color theme. "auto" follows the OS preference. Defaults to "auto". */
|
|
7
|
+
theme?: ThemeMode;
|
|
5
8
|
/** Render the floating launcher button. Defaults to true. */
|
|
6
9
|
launcher?: boolean;
|
|
7
10
|
}
|
|
8
11
|
export declare class UpstepWidget {
|
|
9
12
|
private client;
|
|
10
|
-
private
|
|
13
|
+
private isOpen;
|
|
11
14
|
private tab;
|
|
12
15
|
private feedItems;
|
|
13
16
|
private selectedType;
|
|
@@ -15,6 +18,7 @@ export declare class UpstepWidget {
|
|
|
15
18
|
private accent;
|
|
16
19
|
private position;
|
|
17
20
|
private showLauncher;
|
|
21
|
+
private palette;
|
|
18
22
|
constructor(client: UpstepApiClient, options?: WidgetOptions);
|
|
19
23
|
mount(): void;
|
|
20
24
|
/** Open the feedback modal programmatically (e.g. from your own button). */
|
|
@@ -33,4 +37,5 @@ export declare class UpstepWidget {
|
|
|
33
37
|
private bindSubmitForm;
|
|
34
38
|
private bindVoteButtons;
|
|
35
39
|
}
|
|
40
|
+
export {};
|
|
36
41
|
//# sourceMappingURL=widget.d.ts.map
|
package/dist/widget.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAIxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAoG3C,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,OAAO,CAAU;gBAEb,MAAM,EAAE,eAAe,EAAE,OAAO,GAAE,aAAkB;IAQhE,KAAK;IAKL,4EAA4E;IAC5E,UAAU;IAIV,iDAAiD;IACjD,WAAW;IAIX,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,UAAU;YAKJ,SAAS;IAUvB,OAAO,CAAC,WAAW;IAyCnB,OAAO,CAAC,gBAAgB;IAexB,OAAO,CAAC,UAAU;IAwBlB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;IAyCtB,OAAO,CAAC,eAAe;CAaxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upstep/js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Upstep feedback widget for web apps",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@upstep/types": "0.
|
|
24
|
+
"@upstep/types": "0.5.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": ">=18",
|
package/dist/api-p1GbYq1j.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;
|