@upstep/js 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +10 -20
- package/dist/index.js +117 -127
- package/dist/react.cjs +1 -1
- package/dist/react.js +203 -197
- package/dist/upstep.global.js +42 -52
- package/dist/widget.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/upstep.global.js
CHANGED
|
@@ -1,91 +1,81 @@
|
|
|
1
|
-
(function(){"use strict";const
|
|
1
|
+
(function(){"use strict";const b="upstep-anonymous-id";function $(){const s=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;if(typeof window>"u")return s;try{const t=window.localStorage.getItem(b);return t||(window.localStorage.setItem(b,s),s)}catch{return s}}class I{constructor(t){this.baseUrl=(t.baseUrl??"https://upstep.dev").replace(/\/$/,""),this.apiKey=t.apiKey,this.supportIdentityToken=t.supportIdentityToken,this.chat=t.chat!==!1,t.userId!==void 0&&(this.userId=t.userId),this.anonymousId=$()}setUserId(t){this.userId=t}headers(){return{"Content-Type":"application/json","x-api-key":this.apiKey}}async supportEnabled(){if(!this.chat)return!1;try{const t=await fetch(`${this.baseUrl}/api/sdk/support`,{headers:this.headers()});return t.ok&&(await t.json()).enabled===!0}catch{return!1}}supportFrameUrl(t){return`${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(t)}`}connectSupportFrame(t){const e=new URL(this.baseUrl).origin,o=()=>{var n;return(n=t.contentWindow)==null?void 0:n.postMessage({type:"upstep:support:identity",token:this.supportIdentityToken},e)},i=n=>{var a;n.origin===e&&n.source===t.contentWindow&&((a=n.data)==null?void 0:a.type)==="upstep:support:ready"&&o()};return t.addEventListener("load",o),window.addEventListener("message",i),()=>{t.removeEventListener("load",o),window.removeEventListener("message",i)}}async listFeedback(t){const e=new URLSearchParams;t!=null&&t.cursor&&e.set("cursor",t.cursor),t!=null&&t.limit&&e.set("limit",String(t.limit)),t!=null&&t.type&&e.set("type",t.type),t!=null&&t.status&&e.set("status",t.status),t!=null&&t.sort&&e.set("sort",t.sort),this.userId&&e.set("endUserId",this.userId),this.anonymousId&&e.set("anonymousId",this.anonymousId);const o=await fetch(`${this.baseUrl}/api/sdk/feedback?${e}`,{headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`);return o.json()}async submitFeedback(t){const e=await fetch(`${this.baseUrl}/api/sdk/feedback`,{method:"POST",headers:this.headers(),body:JSON.stringify({...t,endUserId:t.endUserId??this.userId,anonymousId:t.anonymousId??this.anonymousId})});if(!e.ok)throw new Error(`Upstep: ${e.status}`);return e.json()}async vote(t,e){const o=await fetch(`${this.baseUrl}/api/sdk/feedback/${t}/vote`,{method:"POST",headers:this.headers(),body:JSON.stringify({value:e,endUserId:this.userId,anonymousId:this.anonymousId})});if(!o.ok)throw new Error(`Upstep: ${o.status}`)}async getItem(t){const e=new URLSearchParams;this.userId&&e.set("endUserId",this.userId),this.anonymousId&&e.set("anonymousId",this.anonymousId);const o=await fetch(`${this.baseUrl}/api/sdk/feedback/${t}?${e}`,{headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`);return o.json()}async removeVote(t){if(!this.userId&&!this.anonymousId)return;const e=new URLSearchParams;this.userId&&e.set("endUserId",this.userId),this.anonymousId&&e.set("anonymousId",this.anonymousId);const o=await fetch(`${this.baseUrl}/api/sdk/feedback/${t}/vote?${e}`,{method:"DELETE",headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`)}}const E="#D97757",f={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},g={bg:"#000000",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function m(s){if(s==="light"||s==="dark")return s;if(typeof document<"u"){const t=document.documentElement;return t.classList.contains("dark")||t.getAttribute("data-theme")==="dark"?"dark":"light"}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function S(s,t,e){return`
|
|
2
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;${
|
|
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:${s};color:#fff;border:none;border-radius:9999px;padding:12px 18px;font-size:14px;font-weight:600;cursor:grab;touch-action:none;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
|
|
4
4
|
#upstep-btn svg{width:16px;height:16px;flex-shrink:0}
|
|
5
5
|
#upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
|
|
6
6
|
#upstep-btn.upstep-dragging{cursor:grabbing;transform:scale(1.06);box-shadow:0 10px 32px rgba(26,25,21,.28);transition:transform .08s,box-shadow .08s}
|
|
7
7
|
@media(max-width:639px){#upstep-btn{padding:12px}#upstep-btn span{display:none}}
|
|
8
|
-
#upstep-backdrop{position:fixed;inset:0;background:${
|
|
8
|
+
#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}
|
|
9
9
|
@keyframes upstep-fade{from{opacity:0}to{opacity:1}}
|
|
10
10
|
@keyframes upstep-rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:translateY(0)}}
|
|
11
|
-
#upstep-modal{background:${
|
|
11
|
+
#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)}
|
|
12
12
|
#upstep-header{display:flex;align-items:flex-start;justify-content:space-between;padding:20px 20px 0}
|
|
13
|
-
#upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${
|
|
14
|
-
#upstep-header p{margin:2px 0 0;font-size:12.5px;color:${
|
|
15
|
-
#upstep-close{background:${
|
|
16
|
-
#upstep-close:hover{background:${
|
|
17
|
-
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${
|
|
18
|
-
.upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:8px;font-size:13px;font-weight:600;color:${
|
|
19
|
-
.upstep-tab.active{background:${
|
|
13
|
+
#upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${e.text};letter-spacing:-.01em}
|
|
14
|
+
#upstep-header p{margin:2px 0 0;font-size:12.5px;color:${e.textFaint}}
|
|
15
|
+
#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}
|
|
16
|
+
#upstep-close:hover{background:${e.bgHover};color:${e.text}}
|
|
17
|
+
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${e.bgSoft};border-radius:11px}
|
|
18
|
+
.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}
|
|
19
|
+
.upstep-mode .upstep-tab.active{background:${e.bgSoft};box-shadow:none}
|
|
20
|
+
.upstep-tab.active{background:${e.bg};color:${e.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
|
|
20
21
|
#upstep-body{flex:1;overflow-y:auto;padding:18px 20px 22px}
|
|
21
|
-
.upstep-form textarea{width:100%;min-height:104px;border:1px solid ${
|
|
22
|
-
.upstep-form textarea::placeholder{color:${
|
|
23
|
-
.upstep-form textarea:focus{border-color:${s};background:${
|
|
22
|
+
.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}
|
|
23
|
+
.upstep-form textarea::placeholder{color:${e.textFaint}}
|
|
24
|
+
.upstep-form textarea:focus{border-color:${s};background:${e.bg}}
|
|
24
25
|
.upstep-type-row{display:flex;gap:7px;margin:12px 0 4px}
|
|
25
|
-
.upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:9px;border:1px solid ${
|
|
26
|
+
.upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;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}
|
|
26
27
|
.upstep-type-btn svg{width:12px;height:12px;flex-shrink:0}
|
|
27
|
-
.upstep-type-btn:hover{border-color:${
|
|
28
|
+
.upstep-type-btn:hover{border-color:${e.textFaint}}
|
|
28
29
|
.upstep-type-btn.selected{background:${s};color:#fff;border-color:${s}}
|
|
29
30
|
.upstep-submit{width:100%;padding:12px;background:${s};color:#fff;border:none;border-radius:11px;font-size:14px;font-weight:600;cursor:pointer;margin-top:14px;transition:filter .15s}
|
|
30
31
|
.upstep-submit:hover{filter:brightness(.94)}
|
|
31
32
|
.upstep-submit:disabled{opacity:.5;cursor:not-allowed}
|
|
32
33
|
#upstep-form-msg{font-size:13px;text-align:center;margin-top:12px;color:${s};font-weight:500}
|
|
33
|
-
.upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${
|
|
34
|
-
.upstep-feedback-item:hover{border-color:${
|
|
35
|
-
.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 ${
|
|
34
|
+
.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}
|
|
35
|
+
.upstep-feedback-item:hover{border-color:${e.textFaint}}
|
|
36
|
+
.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}
|
|
36
37
|
.upstep-vote:hover{border-color:${s}}
|
|
37
38
|
.upstep-vote.voted{border-color:${s};background:${s}1a}
|
|
38
39
|
.upstep-vote-arrow{font-size:11px;line-height:1;color:${s}}
|
|
39
|
-
.upstep-vote-count{font-size:14px;font-weight:700;color:${
|
|
40
|
+
.upstep-vote-count{font-size:14px;font-weight:700;color:${e.text};line-height:1.1}
|
|
40
41
|
.upstep-feedback-main{flex:1;min-width:0}
|
|
41
|
-
.upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${
|
|
42
|
+
.upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${e.text};margin:0 0 8px;word-break:break-word}
|
|
42
43
|
.upstep-feedback-meta{display:flex;align-items:center;gap:7px}
|
|
43
44
|
.upstep-badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:9999px;font-size:10.5px;font-weight:700;letter-spacing:.02em}
|
|
44
45
|
.upstep-badge-bug{background:#fdecec;color:#d6453d}
|
|
45
46
|
.upstep-badge-feature{background:#e9f0fd;color:#3b76d6}
|
|
46
|
-
.upstep-badge-general{background:${
|
|
47
|
-
.upstep-feedback-date{font-size:11px;color:${
|
|
48
|
-
.upstep-empty{text-align:center;color:${
|
|
49
|
-
.upstep-empty strong{display:block;color:${
|
|
50
|
-
`}const M='<svg width="16" height="16" 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 U{constructor(e
|
|
51
|
-
<div id="upstep-modal">
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<p>${this.tab==="support"?"Ask AI, or talk with the team.":"Tell us what to build next, or vote on ideas."}</p>
|
|
56
|
-
</div>
|
|
57
|
-
<button id="upstep-close" aria-label="Close">✕</button>
|
|
58
|
-
</div>
|
|
59
|
-
<div id="upstep-tabs">
|
|
60
|
-
${this.hasSupport?`<button class="upstep-tab ${this.tab==="support"?"active":""}" data-tab="support">Support</button>`:""}
|
|
61
|
-
<button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Give feedback</button>
|
|
62
|
-
<button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Vote on ideas</button>
|
|
63
|
-
</div>
|
|
64
|
-
<div id="upstep-body">
|
|
65
|
-
${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg==="#000000"?"dark":"light")}" style="width:100%;height:480px;border:0;display:block;border-radius:12px"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
47
|
+
.upstep-badge-general{background:${e.bgSoft};color:${e.textSoft}}
|
|
48
|
+
.upstep-feedback-date{font-size:11px;color:${e.textFaint}}
|
|
49
|
+
.upstep-empty{text-align:center;color:${e.textFaint};font-size:14px;padding:40px 0}
|
|
50
|
+
.upstep-empty strong{display:block;color:${e.textSoft};font-size:15px;margin-bottom:4px}
|
|
51
|
+
`}const M='<svg width="16" height="16" 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 U{constructor(t,e={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.dragMoved=!1,this.hasSupport=!1,this.disconnectSupport=null,this.client=t,this.accent=e.accentColor??E,this.position=e.position??"right",this.showLauncher=e.launcher!==!1,this.themeMode=e.theme??"auto",this.palette=m(this.themeMode)==="dark"?g:f}mount(){this.injectStyles(),this.showLauncher&&this.renderButton(),this.client.supportEnabled().then(t=>{if(this.hasSupport=t,t){const e=document.querySelector("#upstep-btn span");e&&(e.textContent="Help & feedback"),this.isOpen&&this.renderModal()}})}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=S(this.accent,this.position,this.palette),document.head.appendChild(t)}renderButton(){const t=document.createElement("button");t.id="upstep-btn",t.setAttribute("aria-label","Open help and feedback"),t.innerHTML=`${M}<span>Feedback</span>`,t.addEventListener("click",()=>{this.dragMoved||this.openModal()}),document.body.appendChild(t),this.makeDraggable(t)}makeDraggable(t){const i="upstep-btn-pos";try{const r=localStorage.getItem(i);if(r){const{side:p,bottom:u}=JSON.parse(r);t.style.left=p==="left"?"24px":"auto",t.style.right=p==="right"?"24px":"auto",t.style.top="auto",t.style.bottom=`${u}px`}}catch{}let n=0,a=0,l=0,v=0,h=!1;const L=()=>{const r=t.getBoundingClientRect(),p=r.left+r.width/2<window.innerWidth/2?"left":"right",u=Math.max(24,Math.min(window.innerHeight-r.height-24,r.top)),w=window.innerHeight-u-r.height;t.style.transition="left .25s cubic-bezier(.16,1,.3,1),right .25s cubic-bezier(.16,1,.3,1),top .25s cubic-bezier(.16,1,.3,1),bottom .25s cubic-bezier(.16,1,.3,1),transform .15s,box-shadow .15s",t.style.left=p==="left"?"24px":"auto",t.style.right=p==="right"?"24px":"auto",t.style.top="auto",t.style.bottom=`${w}px`;try{localStorage.setItem(i,JSON.stringify({side:p,bottom:w}))}catch{}},F=r=>{if(r.pointerType==="mouse"&&r.button!==0)return;this.dragMoved=!1,h=!0;const p=t.getBoundingClientRect();n=r.clientX,a=r.clientY,l=p.left,v=p.top,t.setPointerCapture(r.pointerId),t.style.transition="none"},C=r=>{if(!h)return;const p=r.clientX-n,u=r.clientY-a;!this.dragMoved&&Math.hypot(p,u)<6||(this.dragMoved||t.classList.add("upstep-dragging"),this.dragMoved=!0,t.style.left=`${l+p}px`,t.style.right="auto",t.style.top=`${v+u}px`,t.style.bottom="auto")},k=()=>{h&&(h=!1,t.classList.remove("upstep-dragging"),this.dragMoved&&L())};t.addEventListener("pointerdown",F),t.addEventListener("pointermove",C),t.addEventListener("pointerup",k),t.addEventListener("pointercancel",k)}openModal(){this.isOpen=!0,this.palette=m(this.themeMode)==="dark"?g:f,this.injectStyles(),this.fetchFeed(),this.renderModal()}closeModal(){var t,e;(t=this.disconnectSupport)==null||t.call(this),this.disconnectSupport=null,this.isOpen=!1,(e=document.getElementById("upstep-backdrop"))==null||e.remove()}async fetchFeed(){try{const t=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=t.items,this.renderFeedList()}catch{}}renderModal(){var o,i,n;(o=this.disconnectSupport)==null||o.call(this),this.disconnectSupport=null;const t=document.createElement("div");t.id="upstep-backdrop",t.addEventListener("click",a=>{a.target===t&&this.closeModal()}),t.innerHTML=`
|
|
52
|
+
<div id="upstep-modal" style="max-width:${this.hasSupport?"460px":"440px"}">
|
|
53
|
+
${this.hasSupport?`<div class="upstep-mode" style="display:flex;align-items:center;gap:14px;padding:10px 14px;border-bottom:1px solid ${this.palette.border}"><div id="upstep-tabs" style="margin:0;padding:0;background:transparent;flex:1"><button class="upstep-tab ${this.tab==="support"?"active":""}" data-tab="support">Support</button><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Ideas</button></div><button id="upstep-close" aria-label="Close" style="flex-shrink:0;background:transparent">✕</button></div>`:`<div id="upstep-header"><div><h2>Share your feedback</h2><p>Tell us what to build next, or vote on ideas.</p></div><button id="upstep-close" aria-label="Close">✕</button></div><div id="upstep-tabs"><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Give feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Vote on ideas</button></div>`}
|
|
54
|
+
<div id="upstep-body" style="${this.tab==="support"?"padding:0;overflow:hidden":""}">
|
|
55
|
+
${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg==="#000000"?"dark":"light")}" style="width:100%;height:min(560px,calc(88dvh - 56px));min-height:300px;border:0;display:block"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
66
56
|
</div>
|
|
67
57
|
</div>
|
|
68
|
-
`,(i=document.getElementById("upstep-backdrop"))==null||i.remove(),document.body.appendChild(
|
|
58
|
+
`,(i=document.getElementById("upstep-backdrop"))==null||i.remove(),document.body.appendChild(t),(n=t.querySelector("#upstep-close"))==null||n.addEventListener("click",()=>this.closeModal()),t.querySelectorAll(".upstep-tab").forEach(a=>{a.addEventListener("click",()=>{this.tab=a.dataset.tab,this.renderModal()})});const e=t.querySelector("#upstep-support-frame");e&&(this.disconnectSupport=this.client.connectSupportFrame(e)),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const t=["BUG","FEATURE","GENERAL"],e={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},o={BUG:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="8" cy="10" rx="3.5" ry="4.5"/><path d="M8 5.5V4M5.5 6.5 3.5 5M10.5 6.5 12.5 5M4.5 10.5 2.5 10M11.5 10.5 13.5 10"/></svg>',FEATURE:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.1 4.1l1 1M10.9 10.9l1 1M11.9 4.1l-1 1M5.1 10.9l-1 1"/><circle cx="8" cy="8" r="2.5"/></svg>',GENERAL:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"/></svg>'};return`
|
|
69
59
|
<div class="upstep-form">
|
|
70
60
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
71
61
|
<div class="upstep-type-row">
|
|
72
|
-
${
|
|
62
|
+
${t.map(i=>`<button class="upstep-type-btn${this.selectedType===i?" selected":""}" data-type="${i}">${o[i]}${e[i]}</button>`).join("")}
|
|
73
63
|
</div>
|
|
74
64
|
<button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
|
|
75
65
|
<div id="upstep-form-msg"></div>
|
|
76
66
|
</div>
|
|
77
|
-
`}renderFeed(){return this.feedItems.length?this.feedItems.map(
|
|
78
|
-
<div class="upstep-feedback-item" data-id="${
|
|
79
|
-
<button class="upstep-vote${
|
|
67
|
+
`}renderFeed(){return this.feedItems.length?this.feedItems.map(t=>{var e;return`
|
|
68
|
+
<div class="upstep-feedback-item" data-id="${t.id}">
|
|
69
|
+
<button class="upstep-vote${t.userVote==="UP"?" voted":""}" data-vote="UP" data-feedback="${t.id}">
|
|
80
70
|
<span class="upstep-vote-arrow">▲</span>
|
|
81
|
-
<span class="upstep-vote-count">${
|
|
71
|
+
<span class="upstep-vote-count">${t.upvotes}</span>
|
|
82
72
|
</button>
|
|
83
73
|
<div class="upstep-feedback-main">
|
|
84
|
-
<p class="upstep-feedback-content">${x(
|
|
74
|
+
<p class="upstep-feedback-content">${x(t.content)}</p>
|
|
85
75
|
<div class="upstep-feedback-meta">
|
|
86
|
-
<span class="upstep-badge upstep-badge-${
|
|
87
|
-
<span class="upstep-badge upstep-badge-general">${x(((t
|
|
88
|
-
<span class="upstep-feedback-date">${new Date(
|
|
76
|
+
<span class="upstep-badge upstep-badge-${t.type.toLowerCase()}">${t.type}</span>
|
|
77
|
+
<span class="upstep-badge upstep-badge-general">${x(((e=t.boardStatus)==null?void 0:e.name)??t.status.replace("_"," "))}</span>
|
|
78
|
+
<span class="upstep-feedback-date">${new Date(t.createdAt).toLocaleDateString()}</span>
|
|
89
79
|
</div>
|
|
90
80
|
</div>
|
|
91
|
-
</div>`}).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const
|
|
81
|
+
</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(o=>o.classList.remove("selected")),e.classList.add("selected")})}),(t=document.getElementById("upstep-submit-btn"))==null||t.addEventListener("click",async()=>{const e=document.getElementById("upstep-textarea"),o=document.getElementById("upstep-form-msg"),i=document.getElementById("upstep-submit-btn");if(!e||this.loading)return;const n=e.value.trim();if(n){this.loading=!0,i&&(i.disabled=!0,i.textContent="Sending…");try{await this.client.submitFeedback({content:n,type:this.selectedType}),e.value="",o&&(o.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{o&&(o.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 x(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let d=null,c=null;const y={init(s){if(d=new I(s),typeof window<"u"){const t={};s.accentColor!==void 0&&(t.accentColor=s.accentColor),s.position!==void 0&&(t.position=s.position),s.theme!==void 0&&(t.theme=s.theme),s.launcher!==void 0&&(t.launcher=s.launcher);const e=()=>{c=new U(d,t),c.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}return d},open(){c==null||c.openWidget()},close(){c==null||c.closeWidget()},identify(s){d==null||d.setUserId(s)},identifySupport(s){var e;d&&(d.supportIdentityToken=s);const t=document.querySelector("#upstep-support-frame");t&&d&&((e=t.contentWindow)==null||e.postMessage({type:"upstep:support:identity",token:s},new URL(d.baseUrl).origin))},get client(){if(!d)throw new Error("Upstep.init() must be called first");return d}};if(typeof document<"u"){const s=document.currentScript,t=s==null?void 0:s.dataset.apiKey,e=s==null?void 0:s.dataset.userId,o=s==null?void 0:s.dataset.baseUrl,i=s==null?void 0:s.dataset.accentColor,n=s==null?void 0:s.dataset.position,a=s==null?void 0:s.dataset.theme;if(t){const l={apiKey:t};e&&(l.userId=e),(s==null?void 0:s.dataset.chat)!==void 0&&(l.chat=s.dataset.chat!=="false"),o&&(l.baseUrl=o),i&&(l.accentColor=i),(n==="left"||n==="right")&&(l.position=n),(a==="light"||a==="dark"||a==="auto")&&(l.theme=a),y.init(l)}}window.Upstep=y})();
|
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;AAIxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,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;AAqH3C,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,SAAS,CAAY;IAC7B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,iBAAiB,CAA6B;gBAE1C,MAAM,EAAE,eAAe,EAAE,OAAO,GAAE,aAAkB;IAShE,KAAK;IAML,4EAA4E;IAC5E,UAAU;IAIV,iDAAiD;IACjD,WAAW;IAIX,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,aAAa;IA4ErB,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,UAAU;YAMJ,SAAS;IAUvB,OAAO,CAAC,WAAW;IAkCnB,OAAO,CAAC,gBAAgB;IAoBxB,OAAO,CAAC,UAAU;IAyBlB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;IAyCtB,OAAO,CAAC,eAAe;CAaxB"}
|