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