@upstep/js 0.5.5 → 0.5.6
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/index.cjs +37 -37
- package/dist/index.js +130 -96
- package/dist/widget.d.ts +2 -0
- package/dist/widget.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("./api-BvhrcMKU.js"),w="#D97757",$={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},M={bg:"#1c1b19",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function E(o){return o==="light"||o==="dark"?o:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function L(o,e,t){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;${e==="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: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
|
-
#upstep-btn
|
|
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:${t.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:${t.bg};border:1px solid ${t.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:${t.text};letter-spacing:-.01em}
|
|
14
|
+
#upstep-header p{margin:2px 0 0;font-size:12.5px;color:${t.textFaint}}
|
|
15
|
+
#upstep-close{background:${t.bgSoft};border:none;width:28px;height:28px;border-radius:8px;font-size:14px;cursor:pointer;color:${t.textSoft};line-height:1;display:flex;align-items:center;justify-content:center;transition:background .15s}
|
|
16
|
+
#upstep-close:hover{background:${t.bgHover};color:${t.text}}
|
|
17
|
+
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${t.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:${t.textSoft};cursor:pointer;transition:all .15s}
|
|
19
|
+
.upstep-tab.active{background:${t.bg};color:${t.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
|
|
20
20
|
#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:${o};background:${
|
|
21
|
+
.upstep-form textarea{width:100%;min-height:104px;border:1px solid ${t.border};border-radius:12px;padding:12px;font-size:14px;line-height:1.5;resize:vertical;outline:none;background:${t.bgSoft};color:${t.text};transition:border-color .15s}
|
|
22
|
+
.upstep-form textarea::placeholder{color:${t.textFaint}}
|
|
23
|
+
.upstep-form textarea:focus{border-color:${o};background:${t.bg}}
|
|
24
24
|
.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 ${
|
|
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 ${t.border};background:${t.bg};color:${t.textSoft};font-size:12.5px;font-weight:600;cursor:pointer;transition:all .15s}
|
|
26
26
|
.upstep-type-btn svg{width:12px;height:12px;flex-shrink:0}
|
|
27
|
-
.upstep-type-btn:hover{border-color:${
|
|
27
|
+
.upstep-type-btn:hover{border-color:${t.textFaint}}
|
|
28
28
|
.upstep-type-btn.selected{background:${o};color:#fff;border-color:${o}}
|
|
29
29
|
.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}
|
|
30
30
|
.upstep-submit:hover{filter:brightness(.94)}
|
|
31
31
|
.upstep-submit:disabled{opacity:.5;cursor:not-allowed}
|
|
32
32
|
#upstep-form-msg{font-size:13px;text-align:center;margin-top:12px;color:${o};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 ${
|
|
33
|
+
.upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${t.border};border-radius:14px;margin-bottom:10px;background:${t.bg};transition:border-color .15s}
|
|
34
|
+
.upstep-feedback-item:hover{border-color:${t.textFaint}}
|
|
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 ${t.border};background:${t.bgSoft};cursor:pointer;transition:all .15s}
|
|
36
36
|
.upstep-vote:hover{border-color:${o}}
|
|
37
37
|
.upstep-vote.voted{border-color:${o};background:${o}1a}
|
|
38
38
|
.upstep-vote-arrow{font-size:11px;line-height:1;color:${o}}
|
|
39
|
-
.upstep-vote-count{font-size:14px;font-weight:700;color:${
|
|
39
|
+
.upstep-vote-count{font-size:14px;font-weight:700;color:${t.text};line-height:1.1}
|
|
40
40
|
.upstep-feedback-main{flex:1;min-width:0}
|
|
41
|
-
.upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${
|
|
41
|
+
.upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${t.text};margin:0 0 8px;word-break:break-word}
|
|
42
42
|
.upstep-feedback-meta{display:flex;align-items:center;gap:7px}
|
|
43
43
|
.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
44
|
.upstep-badge-bug{background:#fdecec;color:#d6453d}
|
|
45
45
|
.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
|
|
46
|
+
.upstep-badge-general{background:${t.bgSoft};color:${t.textSoft}}
|
|
47
|
+
.upstep-feedback-date{font-size:11px;color:${t.textFaint}}
|
|
48
|
+
.upstep-empty{text-align:center;color:${t.textFaint};font-size:14px;padding:40px 0}
|
|
49
|
+
.upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
|
|
50
|
+
`}const S='<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 C{constructor(e,t={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.dragMoved=!1,this.client=e,this.accent=t.accentColor??w,this.position=t.position??"right",this.showLauncher=t.launcher!==!1,this.palette=E(t.theme??"auto")==="dark"?M:$}mount(){this.injectStyles(),this.showLauncher&&this.renderButton()}openWidget(){this.openModal()}closeWidget(){this.closeModal()}injectStyles(){var t;(t=document.getElementById("upstep-styles"))==null||t.remove();const e=document.createElement("style");e.id="upstep-styles",e.textContent=L(this.accent,this.position,this.palette),document.head.appendChild(e)}renderButton(){const e=document.createElement("button");e.id="upstep-btn",e.innerHTML=`${S}<span>Feedback</span>`,e.addEventListener("click",()=>{this.dragMoved||this.openModal()}),document.body.appendChild(e),this.makeDraggable(e)}makeDraggable(e){const s="upstep-btn-pos";try{const i=localStorage.getItem(s);if(i){const{side:a,bottom:u}=JSON.parse(i);e.style.left=a==="left"?"24px":"auto",e.style.right=a==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${u}px`}}catch{}let r=0,c=0,d=0,f=0,b=!1;const y=()=>{const i=e.getBoundingClientRect(),a=i.left+i.width/2<window.innerWidth/2?"left":"right",u=Math.max(24,Math.min(window.innerHeight-i.height-24,i.top)),g=window.innerHeight-u-i.height;e.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",e.style.left=a==="left"?"24px":"auto",e.style.right=a==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${g}px`;try{localStorage.setItem(s,JSON.stringify({side:a,bottom:g}))}catch{}},v=i=>{if(i.pointerType==="mouse"&&i.button!==0)return;this.dragMoved=!1,b=!0;const a=e.getBoundingClientRect();r=i.clientX,c=i.clientY,d=a.left,f=a.top,e.setPointerCapture(i.pointerId),e.style.transition="none"},k=i=>{if(!b)return;const a=i.clientX-r,u=i.clientY-c;!this.dragMoved&&Math.hypot(a,u)<6||(this.dragMoved||e.classList.add("upstep-dragging"),this.dragMoved=!0,e.style.left=`${d+a}px`,e.style.right="auto",e.style.top=`${f+u}px`,e.style.bottom="auto")},h=()=>{b&&(b=!1,e.classList.remove("upstep-dragging"),this.dragMoved&&y())};e.addEventListener("pointerdown",v),e.addEventListener("pointermove",k),e.addEventListener("pointerup",h),e.addEventListener("pointercancel",h)}openModal(){this.isOpen=!0,this.fetchFeed(),this.renderModal()}closeModal(){var e;this.isOpen=!1,(e=document.getElementById("upstep-backdrop"))==null||e.remove()}async fetchFeed(){try{const e=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=e.items,this.renderFeedList()}catch{}}renderModal(){var t,n;const e=document.createElement("div");e.id="upstep-backdrop",e.addEventListener("click",s=>{s.target===e&&this.closeModal()}),e.innerHTML=`
|
|
51
51
|
<div id="upstep-modal">
|
|
52
52
|
<div id="upstep-header">
|
|
53
53
|
<div>
|
|
@@ -64,26 +64,26 @@
|
|
|
64
64
|
${this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
65
65
|
</div>
|
|
66
66
|
</div>
|
|
67
|
-
`,(
|
|
67
|
+
`,(t=document.getElementById("upstep-backdrop"))==null||t.remove(),document.body.appendChild(e),(n=e.querySelector("#upstep-close"))==null||n.addEventListener("click",()=>this.closeModal()),e.querySelectorAll(".upstep-tab").forEach(s=>{s.addEventListener("click",()=>{this.tab=s.dataset.tab,this.renderModal()})}),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const e=["BUG","FEATURE","GENERAL"],t={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},n={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`
|
|
68
68
|
<div class="upstep-form">
|
|
69
69
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
70
70
|
<div class="upstep-type-row">
|
|
71
|
-
${
|
|
71
|
+
${e.map(s=>`<button class="upstep-type-btn${this.selectedType===s?" selected":""}" data-type="${s}">${n[s]}${t[s]}</button>`).join("")}
|
|
72
72
|
</div>
|
|
73
73
|
<button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
|
|
74
74
|
<div id="upstep-form-msg"></div>
|
|
75
75
|
</div>
|
|
76
|
-
`}renderFeed(){return this.feedItems.length?this.feedItems.map(
|
|
77
|
-
<div class="upstep-feedback-item" data-id="${
|
|
78
|
-
<button class="upstep-vote${
|
|
76
|
+
`}renderFeed(){return this.feedItems.length?this.feedItems.map(e=>`
|
|
77
|
+
<div class="upstep-feedback-item" data-id="${e.id}">
|
|
78
|
+
<button class="upstep-vote${e.userVote==="UP"?" voted":""}" data-vote="UP" data-feedback="${e.id}">
|
|
79
79
|
<span class="upstep-vote-arrow">▲</span>
|
|
80
|
-
<span class="upstep-vote-count">${
|
|
80
|
+
<span class="upstep-vote-count">${e.upvotes}</span>
|
|
81
81
|
</button>
|
|
82
82
|
<div class="upstep-feedback-main">
|
|
83
|
-
<p class="upstep-feedback-content">${
|
|
83
|
+
<p class="upstep-feedback-content">${F(e.content)}</p>
|
|
84
84
|
<div class="upstep-feedback-meta">
|
|
85
|
-
<span class="upstep-badge upstep-badge-${
|
|
86
|
-
<span class="upstep-feedback-date">${new Date(
|
|
85
|
+
<span class="upstep-badge upstep-badge-${e.type.toLowerCase()}">${e.type}</span>
|
|
86
|
+
<span class="upstep-feedback-date">${new Date(e.createdAt).toLocaleDateString()}</span>
|
|
87
87
|
</div>
|
|
88
88
|
</div>
|
|
89
|
-
</div>`).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const
|
|
89
|
+
</div>`).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const e=document.getElementById("upstep-body");!e||this.tab!=="feed"||(e.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var e;document.querySelectorAll(".upstep-type-btn").forEach(t=>{t.addEventListener("click",()=>{this.selectedType=t.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(n=>n.classList.remove("selected")),t.classList.add("selected")})}),(e=document.getElementById("upstep-submit-btn"))==null||e.addEventListener("click",async()=>{const t=document.getElementById("upstep-textarea"),n=document.getElementById("upstep-form-msg"),s=document.getElementById("upstep-submit-btn");if(!t||this.loading)return;const r=t.value.trim();if(r){this.loading=!0,s&&(s.disabled=!0,s.textContent="Sending…");try{await this.client.submitFeedback({content:r,type:this.selectedType}),t.value="",n&&(n.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{n&&(n.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,s&&(s.disabled=!1,s.textContent="Send feedback")}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote").forEach(e=>{e.addEventListener("click",async()=>{const t=e.dataset.feedback;try{await this.client.vote(t,"UP"),await this.fetchFeed()}catch{}})})}}function F(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let p=null,l=null;const m={init(o){if(p=new x.UpstepApiClient(o),typeof window<"u"){const e={};o.accentColor!==void 0&&(e.accentColor=o.accentColor),o.position!==void 0&&(e.position=o.position),o.theme!==void 0&&(e.theme=o.theme),o.launcher!==void 0&&(e.launcher=o.launcher);const t=()=>{l=new C(p,e),l.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}return p},open(){l==null||l.openWidget()},close(){l==null||l.closeWidget()},identify(o){p==null||p.setUserId(o)},get client(){if(!p)throw new Error("Upstep.init() must be called first");return p}};if(typeof document<"u"){const o=document.currentScript,e=o==null?void 0:o.dataset.apiKey,t=o==null?void 0:o.dataset.userId,n=o==null?void 0:o.dataset.baseUrl,s=o==null?void 0:o.dataset.accentColor,r=o==null?void 0:o.dataset.position,c=o==null?void 0:o.dataset.theme;if(e){const d={apiKey:e};t&&(d.userId=t),n&&(d.baseUrl=n),s&&(d.accentColor=s),(r==="left"||r==="right")&&(d.position=r),(c==="light"||c==="dark"||c==="auto")&&(d.theme=c),m.init(d)}}exports.UpstepApiClient=x.UpstepApiClient;exports.default=m;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { U as
|
|
2
|
-
const
|
|
1
|
+
import { U as v } from "./api-B-umoNRf.mjs";
|
|
2
|
+
const k = "#D97757", w = {
|
|
3
3
|
bg: "#ffffff",
|
|
4
4
|
bgSoft: "#f6f5f2",
|
|
5
5
|
bgHover: "#efede8",
|
|
@@ -8,7 +8,7 @@ const c = "#D97757", u = {
|
|
|
8
8
|
textFaint: "#9b9890",
|
|
9
9
|
border: "#e8e6df",
|
|
10
10
|
overlay: "rgba(26,25,21,.45)"
|
|
11
|
-
},
|
|
11
|
+
}, $ = {
|
|
12
12
|
bg: "#1c1b19",
|
|
13
13
|
bgSoft: "#262522",
|
|
14
14
|
bgHover: "#302e2a",
|
|
@@ -18,65 +18,65 @@ const c = "#D97757", u = {
|
|
|
18
18
|
border: "#33312c",
|
|
19
19
|
overlay: "rgba(0,0,0,.6)"
|
|
20
20
|
};
|
|
21
|
-
function
|
|
21
|
+
function M(o) {
|
|
22
22
|
return o === "light" || o === "dark" ? o : typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function E(o, e, t) {
|
|
25
25
|
return `
|
|
26
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;${
|
|
27
|
+
#upstep-btn{position:fixed;bottom:24px;${e === "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:grab;touch-action:none;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
|
|
28
28
|
#upstep-btn svg{width:16px;height:16px;flex-shrink:0}
|
|
29
29
|
#upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
|
|
30
|
-
#upstep-btn
|
|
30
|
+
#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}
|
|
31
31
|
@media(max-width:639px){#upstep-btn{padding:12px}#upstep-btn span{display:none}}
|
|
32
|
-
#upstep-backdrop{position:fixed;inset:0;background:${
|
|
32
|
+
#upstep-backdrop{position:fixed;inset:0;background:${t.overlay};backdrop-filter:blur(3px);z-index:9999;display:flex;align-items:center;justify-content:center;padding:16px;animation:upstep-fade .2s ease}
|
|
33
33
|
@keyframes upstep-fade{from{opacity:0}to{opacity:1}}
|
|
34
34
|
@keyframes upstep-rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:translateY(0)}}
|
|
35
|
-
#upstep-modal{background:${
|
|
35
|
+
#upstep-modal{background:${t.bg};border:1px solid ${t.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)}
|
|
36
36
|
#upstep-header{display:flex;align-items:flex-start;justify-content:space-between;padding:20px 20px 0}
|
|
37
|
-
#upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${
|
|
38
|
-
#upstep-header p{margin:2px 0 0;font-size:12.5px;color:${
|
|
39
|
-
#upstep-close{background:${
|
|
40
|
-
#upstep-close:hover{background:${
|
|
41
|
-
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${
|
|
42
|
-
.upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:8px;font-size:13px;font-weight:600;color:${
|
|
43
|
-
.upstep-tab.active{background:${
|
|
37
|
+
#upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${t.text};letter-spacing:-.01em}
|
|
38
|
+
#upstep-header p{margin:2px 0 0;font-size:12.5px;color:${t.textFaint}}
|
|
39
|
+
#upstep-close{background:${t.bgSoft};border:none;width:28px;height:28px;border-radius:8px;font-size:14px;cursor:pointer;color:${t.textSoft};line-height:1;display:flex;align-items:center;justify-content:center;transition:background .15s}
|
|
40
|
+
#upstep-close:hover{background:${t.bgHover};color:${t.text}}
|
|
41
|
+
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${t.bgSoft};border-radius:11px}
|
|
42
|
+
.upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:8px;font-size:13px;font-weight:600;color:${t.textSoft};cursor:pointer;transition:all .15s}
|
|
43
|
+
.upstep-tab.active{background:${t.bg};color:${t.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
|
|
44
44
|
#upstep-body{flex:1;overflow-y:auto;padding:18px 20px 22px}
|
|
45
|
-
.upstep-form textarea{width:100%;min-height:104px;border:1px solid ${
|
|
46
|
-
.upstep-form textarea::placeholder{color:${
|
|
47
|
-
.upstep-form textarea:focus{border-color:${o};background:${
|
|
45
|
+
.upstep-form textarea{width:100%;min-height:104px;border:1px solid ${t.border};border-radius:12px;padding:12px;font-size:14px;line-height:1.5;resize:vertical;outline:none;background:${t.bgSoft};color:${t.text};transition:border-color .15s}
|
|
46
|
+
.upstep-form textarea::placeholder{color:${t.textFaint}}
|
|
47
|
+
.upstep-form textarea:focus{border-color:${o};background:${t.bg}}
|
|
48
48
|
.upstep-type-row{display:flex;gap:7px;margin:12px 0 4px}
|
|
49
|
-
.upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:9px;border:1px solid ${
|
|
49
|
+
.upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:9px;border:1px solid ${t.border};background:${t.bg};color:${t.textSoft};font-size:12.5px;font-weight:600;cursor:pointer;transition:all .15s}
|
|
50
50
|
.upstep-type-btn svg{width:12px;height:12px;flex-shrink:0}
|
|
51
|
-
.upstep-type-btn:hover{border-color:${
|
|
51
|
+
.upstep-type-btn:hover{border-color:${t.textFaint}}
|
|
52
52
|
.upstep-type-btn.selected{background:${o};color:#fff;border-color:${o}}
|
|
53
53
|
.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}
|
|
54
54
|
.upstep-submit:hover{filter:brightness(.94)}
|
|
55
55
|
.upstep-submit:disabled{opacity:.5;cursor:not-allowed}
|
|
56
56
|
#upstep-form-msg{font-size:13px;text-align:center;margin-top:12px;color:${o};font-weight:500}
|
|
57
|
-
.upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${
|
|
58
|
-
.upstep-feedback-item:hover{border-color:${
|
|
59
|
-
.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 ${
|
|
57
|
+
.upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${t.border};border-radius:14px;margin-bottom:10px;background:${t.bg};transition:border-color .15s}
|
|
58
|
+
.upstep-feedback-item:hover{border-color:${t.textFaint}}
|
|
59
|
+
.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 ${t.border};background:${t.bgSoft};cursor:pointer;transition:all .15s}
|
|
60
60
|
.upstep-vote:hover{border-color:${o}}
|
|
61
61
|
.upstep-vote.voted{border-color:${o};background:${o}1a}
|
|
62
62
|
.upstep-vote-arrow{font-size:11px;line-height:1;color:${o}}
|
|
63
|
-
.upstep-vote-count{font-size:14px;font-weight:700;color:${
|
|
63
|
+
.upstep-vote-count{font-size:14px;font-weight:700;color:${t.text};line-height:1.1}
|
|
64
64
|
.upstep-feedback-main{flex:1;min-width:0}
|
|
65
|
-
.upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${
|
|
65
|
+
.upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${t.text};margin:0 0 8px;word-break:break-word}
|
|
66
66
|
.upstep-feedback-meta{display:flex;align-items:center;gap:7px}
|
|
67
67
|
.upstep-badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:9999px;font-size:10.5px;font-weight:700;letter-spacing:.02em}
|
|
68
68
|
.upstep-badge-bug{background:#fdecec;color:#d6453d}
|
|
69
69
|
.upstep-badge-feature{background:#e9f0fd;color:#3b76d6}
|
|
70
|
-
.upstep-badge-general{background:${
|
|
71
|
-
.upstep-feedback-date{font-size:11px;color:${
|
|
72
|
-
.upstep-empty{text-align:center;color:${
|
|
73
|
-
.upstep-empty strong{display:block;color:${
|
|
70
|
+
.upstep-badge-general{background:${t.bgSoft};color:${t.textSoft}}
|
|
71
|
+
.upstep-feedback-date{font-size:11px;color:${t.textFaint}}
|
|
72
|
+
.upstep-empty{text-align:center;color:${t.textFaint};font-size:14px;padding:40px 0}
|
|
73
|
+
.upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
|
|
74
74
|
`;
|
|
75
75
|
}
|
|
76
|
-
const
|
|
77
|
-
class
|
|
78
|
-
constructor(
|
|
79
|
-
this.isOpen = !1, this.tab = "submit", this.feedItems = [], this.selectedType = "GENERAL", this.loading = !1, this.client =
|
|
76
|
+
const L = '<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>';
|
|
77
|
+
class F {
|
|
78
|
+
constructor(e, t = {}) {
|
|
79
|
+
this.isOpen = !1, this.tab = "submit", this.feedItems = [], this.selectedType = "GENERAL", this.loading = !1, this.dragMoved = !1, this.client = e, this.accent = t.accentColor ?? k, this.position = t.position ?? "right", this.showLauncher = t.launcher !== !1, this.palette = M(t.theme ?? "auto") === "dark" ? $ : w;
|
|
80
80
|
}
|
|
81
81
|
mount() {
|
|
82
82
|
this.injectStyles(), this.showLauncher && this.renderButton();
|
|
@@ -90,35 +90,69 @@ class g {
|
|
|
90
90
|
this.closeModal();
|
|
91
91
|
}
|
|
92
92
|
injectStyles() {
|
|
93
|
-
var
|
|
94
|
-
(
|
|
95
|
-
const
|
|
96
|
-
|
|
93
|
+
var t;
|
|
94
|
+
(t = document.getElementById("upstep-styles")) == null || t.remove();
|
|
95
|
+
const e = document.createElement("style");
|
|
96
|
+
e.id = "upstep-styles", e.textContent = E(this.accent, this.position, this.palette), document.head.appendChild(e);
|
|
97
97
|
}
|
|
98
98
|
renderButton() {
|
|
99
|
-
const
|
|
100
|
-
|
|
99
|
+
const e = document.createElement("button");
|
|
100
|
+
e.id = "upstep-btn", e.innerHTML = `${L}<span>Feedback</span>`, e.addEventListener("click", () => {
|
|
101
|
+
this.dragMoved || this.openModal();
|
|
102
|
+
}), document.body.appendChild(e), this.makeDraggable(e);
|
|
103
|
+
}
|
|
104
|
+
makeDraggable(e) {
|
|
105
|
+
const s = "upstep-btn-pos";
|
|
106
|
+
try {
|
|
107
|
+
const i = localStorage.getItem(s);
|
|
108
|
+
if (i) {
|
|
109
|
+
const { side: a, bottom: u } = JSON.parse(i);
|
|
110
|
+
e.style.left = a === "left" ? "24px" : "auto", e.style.right = a === "right" ? "24px" : "auto", e.style.top = "auto", e.style.bottom = `${u}px`;
|
|
111
|
+
}
|
|
112
|
+
} catch {
|
|
113
|
+
}
|
|
114
|
+
let r = 0, c = 0, d = 0, f = 0, b = !1;
|
|
115
|
+
const x = () => {
|
|
116
|
+
const i = e.getBoundingClientRect(), a = i.left + i.width / 2 < window.innerWidth / 2 ? "left" : "right", u = Math.max(24, Math.min(window.innerHeight - i.height - 24, i.top)), g = window.innerHeight - u - i.height;
|
|
117
|
+
e.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", e.style.left = a === "left" ? "24px" : "auto", e.style.right = a === "right" ? "24px" : "auto", e.style.top = "auto", e.style.bottom = `${g}px`;
|
|
118
|
+
try {
|
|
119
|
+
localStorage.setItem(s, JSON.stringify({ side: a, bottom: g }));
|
|
120
|
+
} catch {
|
|
121
|
+
}
|
|
122
|
+
}, m = (i) => {
|
|
123
|
+
if (i.pointerType === "mouse" && i.button !== 0) return;
|
|
124
|
+
this.dragMoved = !1, b = !0;
|
|
125
|
+
const a = e.getBoundingClientRect();
|
|
126
|
+
r = i.clientX, c = i.clientY, d = a.left, f = a.top, e.setPointerCapture(i.pointerId), e.style.transition = "none";
|
|
127
|
+
}, y = (i) => {
|
|
128
|
+
if (!b) return;
|
|
129
|
+
const a = i.clientX - r, u = i.clientY - c;
|
|
130
|
+
!this.dragMoved && Math.hypot(a, u) < 6 || (this.dragMoved || e.classList.add("upstep-dragging"), this.dragMoved = !0, e.style.left = `${d + a}px`, e.style.right = "auto", e.style.top = `${f + u}px`, e.style.bottom = "auto");
|
|
131
|
+
}, h = () => {
|
|
132
|
+
b && (b = !1, e.classList.remove("upstep-dragging"), this.dragMoved && x());
|
|
133
|
+
};
|
|
134
|
+
e.addEventListener("pointerdown", m), e.addEventListener("pointermove", y), e.addEventListener("pointerup", h), e.addEventListener("pointercancel", h);
|
|
101
135
|
}
|
|
102
136
|
openModal() {
|
|
103
137
|
this.isOpen = !0, this.fetchFeed(), this.renderModal();
|
|
104
138
|
}
|
|
105
139
|
closeModal() {
|
|
106
|
-
var
|
|
107
|
-
this.isOpen = !1, (
|
|
140
|
+
var e;
|
|
141
|
+
this.isOpen = !1, (e = document.getElementById("upstep-backdrop")) == null || e.remove();
|
|
108
142
|
}
|
|
109
143
|
async fetchFeed() {
|
|
110
144
|
try {
|
|
111
|
-
const
|
|
112
|
-
this.feedItems =
|
|
145
|
+
const e = await this.client.listFeedback({ sort: "votes", limit: 20 });
|
|
146
|
+
this.feedItems = e.items, this.renderFeedList();
|
|
113
147
|
} catch {
|
|
114
148
|
}
|
|
115
149
|
}
|
|
116
150
|
renderModal() {
|
|
117
|
-
var
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
s.target ===
|
|
121
|
-
}),
|
|
151
|
+
var t, n;
|
|
152
|
+
const e = document.createElement("div");
|
|
153
|
+
e.id = "upstep-backdrop", e.addEventListener("click", (s) => {
|
|
154
|
+
s.target === e && this.closeModal();
|
|
155
|
+
}), e.innerHTML = `
|
|
122
156
|
<div id="upstep-modal">
|
|
123
157
|
<div id="upstep-header">
|
|
124
158
|
<div>
|
|
@@ -135,14 +169,14 @@ class g {
|
|
|
135
169
|
${this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
|
|
136
170
|
</div>
|
|
137
171
|
</div>
|
|
138
|
-
`, (
|
|
172
|
+
`, (t = document.getElementById("upstep-backdrop")) == null || t.remove(), document.body.appendChild(e), (n = e.querySelector("#upstep-close")) == null || n.addEventListener("click", () => this.closeModal()), e.querySelectorAll(".upstep-tab").forEach((s) => {
|
|
139
173
|
s.addEventListener("click", () => {
|
|
140
174
|
this.tab = s.dataset.tab, this.renderModal();
|
|
141
175
|
});
|
|
142
176
|
}), this.bindSubmitForm(), this.bindVoteButtons();
|
|
143
177
|
}
|
|
144
178
|
renderSubmitForm() {
|
|
145
|
-
const
|
|
179
|
+
const e = ["BUG", "FEATURE", "GENERAL"], t = { BUG: "Bug", FEATURE: "Feature", GENERAL: "General" }, n = {
|
|
146
180
|
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>',
|
|
147
181
|
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>',
|
|
148
182
|
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>'
|
|
@@ -151,7 +185,7 @@ class g {
|
|
|
151
185
|
<div class="upstep-form">
|
|
152
186
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
153
187
|
<div class="upstep-type-row">
|
|
154
|
-
${
|
|
188
|
+
${e.map((s) => `<button class="upstep-type-btn${this.selectedType === s ? " selected" : ""}" data-type="${s}">${n[s]}${t[s]}</button>`).join("")}
|
|
155
189
|
</div>
|
|
156
190
|
<button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
|
|
157
191
|
<div id="upstep-form-msg"></div>
|
|
@@ -160,42 +194,42 @@ class g {
|
|
|
160
194
|
}
|
|
161
195
|
renderFeed() {
|
|
162
196
|
return this.feedItems.length ? this.feedItems.map(
|
|
163
|
-
(
|
|
164
|
-
<div class="upstep-feedback-item" data-id="${
|
|
165
|
-
<button class="upstep-vote${
|
|
197
|
+
(e) => `
|
|
198
|
+
<div class="upstep-feedback-item" data-id="${e.id}">
|
|
199
|
+
<button class="upstep-vote${e.userVote === "UP" ? " voted" : ""}" data-vote="UP" data-feedback="${e.id}">
|
|
166
200
|
<span class="upstep-vote-arrow">▲</span>
|
|
167
|
-
<span class="upstep-vote-count">${
|
|
201
|
+
<span class="upstep-vote-count">${e.upvotes}</span>
|
|
168
202
|
</button>
|
|
169
203
|
<div class="upstep-feedback-main">
|
|
170
|
-
<p class="upstep-feedback-content">${
|
|
204
|
+
<p class="upstep-feedback-content">${S(e.content)}</p>
|
|
171
205
|
<div class="upstep-feedback-meta">
|
|
172
|
-
<span class="upstep-badge upstep-badge-${
|
|
173
|
-
<span class="upstep-feedback-date">${new Date(
|
|
206
|
+
<span class="upstep-badge upstep-badge-${e.type.toLowerCase()}">${e.type}</span>
|
|
207
|
+
<span class="upstep-feedback-date">${new Date(e.createdAt).toLocaleDateString()}</span>
|
|
174
208
|
</div>
|
|
175
209
|
</div>
|
|
176
210
|
</div>`
|
|
177
211
|
).join("") : '<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>';
|
|
178
212
|
}
|
|
179
213
|
renderFeedList() {
|
|
180
|
-
const
|
|
181
|
-
!
|
|
214
|
+
const e = document.getElementById("upstep-body");
|
|
215
|
+
!e || this.tab !== "feed" || (e.innerHTML = this.renderFeed(), this.bindVoteButtons());
|
|
182
216
|
}
|
|
183
217
|
bindSubmitForm() {
|
|
184
|
-
var
|
|
185
|
-
document.querySelectorAll(".upstep-type-btn").forEach((
|
|
186
|
-
|
|
187
|
-
this.selectedType =
|
|
218
|
+
var e;
|
|
219
|
+
document.querySelectorAll(".upstep-type-btn").forEach((t) => {
|
|
220
|
+
t.addEventListener("click", () => {
|
|
221
|
+
this.selectedType = t.dataset.type, document.querySelectorAll(".upstep-type-btn").forEach((n) => n.classList.remove("selected")), t.classList.add("selected");
|
|
188
222
|
});
|
|
189
|
-
}), (
|
|
190
|
-
const
|
|
191
|
-
if (!
|
|
192
|
-
const r =
|
|
223
|
+
}), (e = document.getElementById("upstep-submit-btn")) == null || e.addEventListener("click", async () => {
|
|
224
|
+
const t = document.getElementById("upstep-textarea"), n = document.getElementById("upstep-form-msg"), s = document.getElementById("upstep-submit-btn");
|
|
225
|
+
if (!t || this.loading) return;
|
|
226
|
+
const r = t.value.trim();
|
|
193
227
|
if (r) {
|
|
194
228
|
this.loading = !0, s && (s.disabled = !0, s.textContent = "Sending…");
|
|
195
229
|
try {
|
|
196
|
-
await this.client.submitFeedback({ content: r, type: this.selectedType }),
|
|
230
|
+
await this.client.submitFeedback({ content: r, type: this.selectedType }), t.value = "", n && (n.textContent = "Feedback received. Thank you."), await this.fetchFeed();
|
|
197
231
|
} catch {
|
|
198
|
-
|
|
232
|
+
n && (n.textContent = "Something went wrong. Please try again.");
|
|
199
233
|
} finally {
|
|
200
234
|
this.loading = !1, s && (s.disabled = !1, s.textContent = "Send feedback");
|
|
201
235
|
}
|
|
@@ -203,58 +237,58 @@ class g {
|
|
|
203
237
|
});
|
|
204
238
|
}
|
|
205
239
|
bindVoteButtons() {
|
|
206
|
-
document.querySelectorAll(".upstep-vote").forEach((
|
|
207
|
-
|
|
208
|
-
const
|
|
240
|
+
document.querySelectorAll(".upstep-vote").forEach((e) => {
|
|
241
|
+
e.addEventListener("click", async () => {
|
|
242
|
+
const t = e.dataset.feedback;
|
|
209
243
|
try {
|
|
210
|
-
await this.client.vote(
|
|
244
|
+
await this.client.vote(t, "UP"), await this.fetchFeed();
|
|
211
245
|
} catch {
|
|
212
246
|
}
|
|
213
247
|
});
|
|
214
248
|
});
|
|
215
249
|
}
|
|
216
250
|
}
|
|
217
|
-
function
|
|
251
|
+
function S(o) {
|
|
218
252
|
return o.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
219
253
|
}
|
|
220
|
-
let
|
|
221
|
-
const
|
|
254
|
+
let p = null, l = null;
|
|
255
|
+
const C = {
|
|
222
256
|
init(o) {
|
|
223
|
-
if (
|
|
224
|
-
const
|
|
225
|
-
o.accentColor !== void 0 && (
|
|
226
|
-
const
|
|
227
|
-
|
|
257
|
+
if (p = new v(o), typeof window < "u") {
|
|
258
|
+
const e = {};
|
|
259
|
+
o.accentColor !== void 0 && (e.accentColor = o.accentColor), o.position !== void 0 && (e.position = o.position), o.theme !== void 0 && (e.theme = o.theme), o.launcher !== void 0 && (e.launcher = o.launcher);
|
|
260
|
+
const t = () => {
|
|
261
|
+
l = new F(p, e), l.mount();
|
|
228
262
|
};
|
|
229
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
263
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : t();
|
|
230
264
|
}
|
|
231
|
-
return
|
|
265
|
+
return p;
|
|
232
266
|
},
|
|
233
267
|
/** Open the feedback widget — use this to trigger it from your own UI. */
|
|
234
268
|
open() {
|
|
235
|
-
|
|
269
|
+
l == null || l.openWidget();
|
|
236
270
|
},
|
|
237
271
|
/** Close the feedback widget. */
|
|
238
272
|
close() {
|
|
239
|
-
|
|
273
|
+
l == null || l.closeWidget();
|
|
240
274
|
},
|
|
241
275
|
/** Set / update the end-user id at runtime (e.g. after the user logs in). */
|
|
242
276
|
identify(o) {
|
|
243
|
-
|
|
277
|
+
p == null || p.setUserId(o);
|
|
244
278
|
},
|
|
245
279
|
get client() {
|
|
246
|
-
if (!
|
|
247
|
-
return
|
|
280
|
+
if (!p) throw new Error("Upstep.init() must be called first");
|
|
281
|
+
return p;
|
|
248
282
|
}
|
|
249
283
|
};
|
|
250
284
|
if (typeof document < "u") {
|
|
251
|
-
const o = document.currentScript,
|
|
252
|
-
if (
|
|
253
|
-
const d = { apiKey:
|
|
254
|
-
|
|
285
|
+
const o = document.currentScript, e = o == null ? void 0 : o.dataset.apiKey, t = o == null ? void 0 : o.dataset.userId, n = o == null ? void 0 : o.dataset.baseUrl, s = o == null ? void 0 : o.dataset.accentColor, r = o == null ? void 0 : o.dataset.position, c = o == null ? void 0 : o.dataset.theme;
|
|
286
|
+
if (e) {
|
|
287
|
+
const d = { apiKey: e };
|
|
288
|
+
t && (d.userId = t), n && (d.baseUrl = n), s && (d.accentColor = s), (r === "left" || r === "right") && (d.position = r), (c === "light" || c === "dark" || c === "auto") && (d.theme = c), C.init(d);
|
|
255
289
|
}
|
|
256
290
|
}
|
|
257
291
|
export {
|
|
258
|
-
|
|
259
|
-
|
|
292
|
+
v as UpstepApiClient,
|
|
293
|
+
C as default
|
|
260
294
|
};
|
package/dist/widget.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare class UpstepWidget {
|
|
|
19
19
|
private position;
|
|
20
20
|
private showLauncher;
|
|
21
21
|
private palette;
|
|
22
|
+
private dragMoved;
|
|
22
23
|
constructor(client: UpstepApiClient, options?: WidgetOptions);
|
|
23
24
|
mount(): void;
|
|
24
25
|
/** Open the feedback modal programmatically (e.g. from your own button). */
|
|
@@ -27,6 +28,7 @@ export declare class UpstepWidget {
|
|
|
27
28
|
closeWidget(): void;
|
|
28
29
|
private injectStyles;
|
|
29
30
|
private renderButton;
|
|
31
|
+
private makeDraggable;
|
|
30
32
|
private openModal;
|
|
31
33
|
private closeModal;
|
|
32
34
|
private fetchFeed;
|
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;AAuG3C,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;
|
|
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;AAuG3C,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;IACzB,OAAO,CAAC,SAAS,CAAS;gBAEd,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;IAWpB,OAAO,CAAC,aAAa;IA4ErB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,UAAU;YAKJ,SAAS;IAUvB,OAAO,CAAC,WAAW;IAyCnB,OAAO,CAAC,gBAAgB;IAoBxB,OAAO,CAAC,UAAU;IAwBlB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;IAyCtB,OAAO,CAAC,eAAe;CAaxB"}
|