@upstep/js 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -121,7 +121,7 @@ import { UpstepProvider, FeedbackWidget } from '@upstep/js/react';
121
121
  ```
122
122
 
123
123
  ```html
124
- <script defer src="https://unpkg.com/@upstep/js@0.6.0/dist/upstep.global.js"
124
+ <script defer src="https://unpkg.com/@upstep/js@0.6.1/dist/upstep.global.js"
125
125
  data-api-key="YOUR_PROJECT_KEY" data-chat="true"></script>
126
126
  ```
127
127
 
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("./api-BuSqdsZp.js"),S="#D97757",m={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},x={bg:"#000000",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function y(o){if(o==="light"||o==="dark")return o;if(typeof document<"u"){const e=document.documentElement;return e.classList.contains("dark")||e.getAttribute("data-theme")==="dark"?"dark":"light"}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function L(o,e,t){return`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("./api-BuSqdsZp.js"),E="#D97757",x={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},m={bg:"#000000",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function y(o){if(o==="light"||o==="dark")return o;if(typeof document<"u"){const e=document.documentElement;return e.classList.contains("dark")||e.getAttribute("data-theme")==="dark"?"dark":"light"}return 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
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}
@@ -16,6 +16,7 @@
16
16
  #upstep-close:hover{background:${t.bgHover};color:${t.text}}
17
17
  #upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${t.bgSoft};border-radius:11px}
18
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-mode .upstep-tab.active{background:${t.bgSoft};box-shadow:none}
19
20
  .upstep-tab.active{background:${t.bg};color:${t.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
20
21
  #upstep-body{flex:1;overflow-y:auto;padding:18px 20px 22px}
21
22
  .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}
@@ -47,29 +48,18 @@
47
48
  .upstep-feedback-date{font-size:11px;color:${t.textFaint}}
48
49
  .upstep-empty{text-align:center;color:${t.textFaint};font-size:14px;padding:40px 0}
49
50
  .upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
50
- `}const C='<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 F{constructor(e,t={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.dragMoved=!1,this.hasSupport=!1,this.disconnectSupport=null,this.client=e,this.accent=t.accentColor??S,this.position=t.position??"right",this.showLauncher=t.launcher!==!1,this.themeMode=t.theme??"auto",this.palette=y(this.themeMode)==="dark"?x:m}mount(){this.injectStyles(),this.showLauncher&&this.renderButton(),this.client.supportEnabled().then(e=>{if(this.hasSupport=e,e){const t=document.querySelector("#upstep-btn span");t&&(t.textContent="Help & feedback"),this.isOpen&&this.renderModal()}})}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.setAttribute("aria-label","Open help and feedback"),e.innerHTML=`${C}<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:d,bottom:u}=JSON.parse(i);e.style.left=d==="left"?"24px":"auto",e.style.right=d==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${u}px`}}catch{}let a=0,r=0,l=0,b=0,h=!1;const $=()=>{const i=e.getBoundingClientRect(),d=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=d==="left"?"24px":"auto",e.style.right=d==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${g}px`;try{localStorage.setItem(s,JSON.stringify({side:d,bottom:g}))}catch{}},M=i=>{if(i.pointerType==="mouse"&&i.button!==0)return;this.dragMoved=!1,h=!0;const d=e.getBoundingClientRect();a=i.clientX,r=i.clientY,l=d.left,b=d.top,e.setPointerCapture(i.pointerId),e.style.transition="none"},E=i=>{if(!h)return;const d=i.clientX-a,u=i.clientY-r;!this.dragMoved&&Math.hypot(d,u)<6||(this.dragMoved||e.classList.add("upstep-dragging"),this.dragMoved=!0,e.style.left=`${l+d}px`,e.style.right="auto",e.style.top=`${b+u}px`,e.style.bottom="auto")},f=()=>{h&&(h=!1,e.classList.remove("upstep-dragging"),this.dragMoved&&$())};e.addEventListener("pointerdown",M),e.addEventListener("pointermove",E),e.addEventListener("pointerup",f),e.addEventListener("pointercancel",f)}openModal(){this.isOpen=!0,this.palette=y(this.themeMode)==="dark"?x:m,this.injectStyles(),this.fetchFeed(),this.renderModal()}closeModal(){var e,t;(e=this.disconnectSupport)==null||e.call(this),this.disconnectSupport=null,this.isOpen=!1,(t=document.getElementById("upstep-backdrop"))==null||t.remove()}async fetchFeed(){try{const e=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=e.items,this.renderFeedList()}catch{}}renderModal(){var n,s,a;(n=this.disconnectSupport)==null||n.call(this),this.disconnectSupport=null;const e=document.createElement("div");e.id="upstep-backdrop",e.addEventListener("click",r=>{r.target===e&&this.closeModal()}),e.innerHTML=`
51
- <div id="upstep-modal">
52
- <div id="upstep-header">
53
- <div>
54
- <h2>${this.tab==="support"?"Customer support":"Share your feedback"}</h2>
55
- <p>${this.tab==="support"?"Ask AI, or talk with the team.":"Tell us what to build next, or vote on ideas."}</p>
56
- </div>
57
- <button id="upstep-close" aria-label="Close">✕</button>
58
- </div>
59
- <div id="upstep-tabs">
60
- ${this.hasSupport?`<button class="upstep-tab ${this.tab==="support"?"active":""}" data-tab="support">Support</button>`:""}
61
- <button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Give feedback</button>
62
- <button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Vote on ideas</button>
63
- </div>
64
- <div id="upstep-body">
65
- ${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg==="#000000"?"dark":"light")}" style="width:100%;height:480px;border:0;display:block;border-radius:12px"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
51
+ `}const C='<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 F{constructor(e,t={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.dragMoved=!1,this.hasSupport=!1,this.disconnectSupport=null,this.client=e,this.accent=t.accentColor??E,this.position=t.position??"right",this.showLauncher=t.launcher!==!1,this.themeMode=t.theme??"auto",this.palette=y(this.themeMode)==="dark"?m:x}mount(){this.injectStyles(),this.showLauncher&&this.renderButton(),this.client.supportEnabled().then(e=>{if(this.hasSupport=e,e){const t=document.querySelector("#upstep-btn span");t&&(t.textContent="Help & feedback"),this.isOpen&&this.renderModal()}})}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.setAttribute("aria-label","Open help and feedback"),e.innerHTML=`${C}<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:d,bottom:u}=JSON.parse(i);e.style.left=d==="left"?"24px":"auto",e.style.right=d==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${u}px`}}catch{}let n=0,r=0,l=0,h=0,b=!1;const $=()=>{const i=e.getBoundingClientRect(),d=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=d==="left"?"24px":"auto",e.style.right=d==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${g}px`;try{localStorage.setItem(s,JSON.stringify({side:d,bottom:g}))}catch{}},M=i=>{if(i.pointerType==="mouse"&&i.button!==0)return;this.dragMoved=!1,b=!0;const d=e.getBoundingClientRect();n=i.clientX,r=i.clientY,l=d.left,h=d.top,e.setPointerCapture(i.pointerId),e.style.transition="none"},S=i=>{if(!b)return;const d=i.clientX-n,u=i.clientY-r;!this.dragMoved&&Math.hypot(d,u)<6||(this.dragMoved||e.classList.add("upstep-dragging"),this.dragMoved=!0,e.style.left=`${l+d}px`,e.style.right="auto",e.style.top=`${h+u}px`,e.style.bottom="auto")},f=()=>{b&&(b=!1,e.classList.remove("upstep-dragging"),this.dragMoved&&$())};e.addEventListener("pointerdown",M),e.addEventListener("pointermove",S),e.addEventListener("pointerup",f),e.addEventListener("pointercancel",f)}openModal(){this.isOpen=!0,this.palette=y(this.themeMode)==="dark"?m:x,this.injectStyles(),this.fetchFeed(),this.renderModal()}closeModal(){var e,t;(e=this.disconnectSupport)==null||e.call(this),this.disconnectSupport=null,this.isOpen=!1,(t=document.getElementById("upstep-backdrop"))==null||t.remove()}async fetchFeed(){try{const e=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=e.items,this.renderFeedList()}catch{}}renderModal(){var a,s,n;(a=this.disconnectSupport)==null||a.call(this),this.disconnectSupport=null;const e=document.createElement("div");e.id="upstep-backdrop",e.addEventListener("click",r=>{r.target===e&&this.closeModal()}),e.innerHTML=`
52
+ <div id="upstep-modal" style="max-width:${this.hasSupport?"460px":"440px"}">
53
+ ${this.hasSupport?`<div class="upstep-mode" style="display:flex;align-items:center;gap:14px;padding:10px 14px;border-bottom:1px solid ${this.palette.border}"><div id="upstep-tabs" style="margin:0;padding:0;background:transparent;flex:1"><button class="upstep-tab ${this.tab==="support"?"active":""}" data-tab="support">Support</button><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Ideas</button></div><button id="upstep-close" aria-label="Close" style="flex-shrink:0;background:transparent">✕</button></div>`:`<div id="upstep-header"><div><h2>Share your feedback</h2><p>Tell us what to build next, or vote on ideas.</p></div><button id="upstep-close" aria-label="Close">✕</button></div><div id="upstep-tabs"><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Give feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Vote on ideas</button></div>`}
54
+ <div id="upstep-body" style="${this.tab==="support"?"padding:0;overflow:hidden":""}">
55
+ ${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg==="#000000"?"dark":"light")}" style="width:100%;height:min(560px,calc(88dvh - 56px));min-height:300px;border:0;display:block"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
66
56
  </div>
67
57
  </div>
68
- `,(s=document.getElementById("upstep-backdrop"))==null||s.remove(),document.body.appendChild(e),(a=e.querySelector("#upstep-close"))==null||a.addEventListener("click",()=>this.closeModal()),e.querySelectorAll(".upstep-tab").forEach(r=>{r.addEventListener("click",()=>{this.tab=r.dataset.tab,this.renderModal()})});const t=e.querySelector("#upstep-support-frame");t&&(this.disconnectSupport=this.client.connectSupportFrame(t)),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`
58
+ `,(s=document.getElementById("upstep-backdrop"))==null||s.remove(),document.body.appendChild(e),(n=e.querySelector("#upstep-close"))==null||n.addEventListener("click",()=>this.closeModal()),e.querySelectorAll(".upstep-tab").forEach(r=>{r.addEventListener("click",()=>{this.tab=r.dataset.tab,this.renderModal()})});const t=e.querySelector("#upstep-support-frame");t&&(this.disconnectSupport=this.client.connectSupportFrame(t)),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const e=["BUG","FEATURE","GENERAL"],t={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},a={BUG:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="8" cy="10" rx="3.5" ry="4.5"/><path d="M8 5.5V4M5.5 6.5 3.5 5M10.5 6.5 12.5 5M4.5 10.5 2.5 10M11.5 10.5 13.5 10"/></svg>',FEATURE:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.1 4.1l1 1M10.9 10.9l1 1M11.9 4.1l-1 1M5.1 10.9l-1 1"/><circle cx="8" cy="8" r="2.5"/></svg>',GENERAL:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"/></svg>'};return`
69
59
  <div class="upstep-form">
70
60
  <textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
71
61
  <div class="upstep-type-row">
72
- ${e.map(s=>`<button class="upstep-type-btn${this.selectedType===s?" selected":""}" data-type="${s}">${n[s]}${t[s]}</button>`).join("")}
62
+ ${e.map(s=>`<button class="upstep-type-btn${this.selectedType===s?" selected":""}" data-type="${s}">${a[s]}${t[s]}</button>`).join("")}
73
63
  </div>
74
64
  <button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
75
65
  <div id="upstep-form-msg"></div>
@@ -88,4 +78,4 @@
88
78
  <span class="upstep-feedback-date">${new Date(e.createdAt).toLocaleDateString()}</span>
89
79
  </div>
90
80
  </div>
91
- </div>`}).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const 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 a=t.value.trim();if(a){this.loading=!0,s&&(s.disabled=!0,s.textContent="Sending…");try{await this.client.submitFeedback({content:a,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 v(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let p=null,c=null;const w={init(o){if(p=new k.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=()=>{c=new F(p,e),c.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}return p},open(){c==null||c.openWidget()},close(){c==null||c.closeWidget()},identify(o){p==null||p.setUserId(o)},identifySupport(o){var t;p&&(p.supportIdentityToken=o);const e=document.querySelector("#upstep-support-frame");e&&p&&((t=e.contentWindow)==null||t.postMessage({type:"upstep:support:identity",token:o},new URL(p.baseUrl).origin))},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,a=o==null?void 0:o.dataset.position,r=o==null?void 0:o.dataset.theme;if(e){const l={apiKey:e};t&&(l.userId=t),(o==null?void 0:o.dataset.chat)!==void 0&&(l.chat=o.dataset.chat!=="false"),n&&(l.baseUrl=n),s&&(l.accentColor=s),(a==="left"||a==="right")&&(l.position=a),(r==="light"||r==="dark"||r==="auto")&&(l.theme=r),w.init(l)}}exports.UpstepApiClient=k.UpstepApiClient;exports.default=w;
81
+ </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(a=>a.classList.remove("selected")),t.classList.add("selected")})}),(e=document.getElementById("upstep-submit-btn"))==null||e.addEventListener("click",async()=>{const t=document.getElementById("upstep-textarea"),a=document.getElementById("upstep-form-msg"),s=document.getElementById("upstep-submit-btn");if(!t||this.loading)return;const n=t.value.trim();if(n){this.loading=!0,s&&(s.disabled=!0,s.textContent="Sending…");try{await this.client.submitFeedback({content:n,type:this.selectedType}),t.value="",a&&(a.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{a&&(a.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 v(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let p=null,c=null;const w={init(o){if(p=new k.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=()=>{c=new F(p,e),c.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}return p},open(){c==null||c.openWidget()},close(){c==null||c.closeWidget()},identify(o){p==null||p.setUserId(o)},identifySupport(o){var t;p&&(p.supportIdentityToken=o);const e=document.querySelector("#upstep-support-frame");e&&p&&((t=e.contentWindow)==null||t.postMessage({type:"upstep:support:identity",token:o},new URL(p.baseUrl).origin))},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,a=o==null?void 0:o.dataset.baseUrl,s=o==null?void 0:o.dataset.accentColor,n=o==null?void 0:o.dataset.position,r=o==null?void 0:o.dataset.theme;if(e){const l={apiKey:e};t&&(l.userId=t),(o==null?void 0:o.dataset.chat)!==void 0&&(l.chat=o.dataset.chat!=="false"),a&&(l.baseUrl=a),s&&(l.accentColor=s),(n==="left"||n==="right")&&(l.position=n),(r==="light"||r==="dark"||r==="auto")&&(l.theme=r),w.init(l)}}exports.UpstepApiClient=k.UpstepApiClient;exports.default=w;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { U as M } from "./api-C1UV7Szw.mjs";
2
- const E = "#D97757", m = {
2
+ const E = "#D97757", x = {
3
3
  bg: "#ffffff",
4
4
  bgSoft: "#f6f5f2",
5
5
  bgHover: "#efede8",
@@ -8,7 +8,7 @@ const E = "#D97757", m = {
8
8
  textFaint: "#9b9890",
9
9
  border: "#e8e6df",
10
10
  overlay: "rgba(26,25,21,.45)"
11
- }, x = {
11
+ }, m = {
12
12
  bg: "#000000",
13
13
  bgSoft: "#262522",
14
14
  bgHover: "#302e2a",
@@ -21,73 +21,74 @@ const E = "#D97757", m = {
21
21
  function y(o) {
22
22
  if (o === "light" || o === "dark") return o;
23
23
  if (typeof document < "u") {
24
- const e = document.documentElement;
25
- return e.classList.contains("dark") || e.getAttribute("data-theme") === "dark" ? "dark" : "light";
24
+ const t = document.documentElement;
25
+ return t.classList.contains("dark") || t.getAttribute("data-theme") === "dark" ? "dark" : "light";
26
26
  }
27
27
  return typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
28
28
  }
29
- function S(o, e, t) {
29
+ function S(o, t, e) {
30
30
  return `
31
31
  #upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
32
- #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}
32
+ #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:grab;touch-action:none;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
33
33
  #upstep-btn svg{width:16px;height:16px;flex-shrink:0}
34
34
  #upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
35
35
  #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}
36
36
  @media(max-width:639px){#upstep-btn{padding:12px}#upstep-btn span{display:none}}
37
- #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}
37
+ #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}
38
38
  @keyframes upstep-fade{from{opacity:0}to{opacity:1}}
39
39
  @keyframes upstep-rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:translateY(0)}}
40
- #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)}
40
+ #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)}
41
41
  #upstep-header{display:flex;align-items:flex-start;justify-content:space-between;padding:20px 20px 0}
42
- #upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${t.text};letter-spacing:-.01em}
43
- #upstep-header p{margin:2px 0 0;font-size:12.5px;color:${t.textFaint}}
44
- #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}
45
- #upstep-close:hover{background:${t.bgHover};color:${t.text}}
46
- #upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${t.bgSoft};border-radius:11px}
47
- .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}
48
- .upstep-tab.active{background:${t.bg};color:${t.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
42
+ #upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${e.text};letter-spacing:-.01em}
43
+ #upstep-header p{margin:2px 0 0;font-size:12.5px;color:${e.textFaint}}
44
+ #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}
45
+ #upstep-close:hover{background:${e.bgHover};color:${e.text}}
46
+ #upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${e.bgSoft};border-radius:11px}
47
+ .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}
48
+ .upstep-mode .upstep-tab.active{background:${e.bgSoft};box-shadow:none}
49
+ .upstep-tab.active{background:${e.bg};color:${e.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
49
50
  #upstep-body{flex:1;overflow-y:auto;padding:18px 20px 22px}
50
- .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}
51
- .upstep-form textarea::placeholder{color:${t.textFaint}}
52
- .upstep-form textarea:focus{border-color:${o};background:${t.bg}}
51
+ .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}
52
+ .upstep-form textarea::placeholder{color:${e.textFaint}}
53
+ .upstep-form textarea:focus{border-color:${o};background:${e.bg}}
53
54
  .upstep-type-row{display:flex;gap:7px;margin:12px 0 4px}
54
- .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}
55
+ .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}
55
56
  .upstep-type-btn svg{width:12px;height:12px;flex-shrink:0}
56
- .upstep-type-btn:hover{border-color:${t.textFaint}}
57
+ .upstep-type-btn:hover{border-color:${e.textFaint}}
57
58
  .upstep-type-btn.selected{background:${o};color:#fff;border-color:${o}}
58
59
  .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}
59
60
  .upstep-submit:hover{filter:brightness(.94)}
60
61
  .upstep-submit:disabled{opacity:.5;cursor:not-allowed}
61
62
  #upstep-form-msg{font-size:13px;text-align:center;margin-top:12px;color:${o};font-weight:500}
62
- .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}
63
- .upstep-feedback-item:hover{border-color:${t.textFaint}}
64
- .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}
63
+ .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}
64
+ .upstep-feedback-item:hover{border-color:${e.textFaint}}
65
+ .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}
65
66
  .upstep-vote:hover{border-color:${o}}
66
67
  .upstep-vote.voted{border-color:${o};background:${o}1a}
67
68
  .upstep-vote-arrow{font-size:11px;line-height:1;color:${o}}
68
- .upstep-vote-count{font-size:14px;font-weight:700;color:${t.text};line-height:1.1}
69
+ .upstep-vote-count{font-size:14px;font-weight:700;color:${e.text};line-height:1.1}
69
70
  .upstep-feedback-main{flex:1;min-width:0}
70
- .upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${t.text};margin:0 0 8px;word-break:break-word}
71
+ .upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${e.text};margin:0 0 8px;word-break:break-word}
71
72
  .upstep-feedback-meta{display:flex;align-items:center;gap:7px}
72
73
  .upstep-badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:9999px;font-size:10.5px;font-weight:700;letter-spacing:.02em}
73
74
  .upstep-badge-bug{background:#fdecec;color:#d6453d}
74
75
  .upstep-badge-feature{background:#e9f0fd;color:#3b76d6}
75
- .upstep-badge-general{background:${t.bgSoft};color:${t.textSoft}}
76
- .upstep-feedback-date{font-size:11px;color:${t.textFaint}}
77
- .upstep-empty{text-align:center;color:${t.textFaint};font-size:14px;padding:40px 0}
78
- .upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
76
+ .upstep-badge-general{background:${e.bgSoft};color:${e.textSoft}}
77
+ .upstep-feedback-date{font-size:11px;color:${e.textFaint}}
78
+ .upstep-empty{text-align:center;color:${e.textFaint};font-size:14px;padding:40px 0}
79
+ .upstep-empty strong{display:block;color:${e.textSoft};font-size:15px;margin-bottom:4px}
79
80
  `;
80
81
  }
81
82
  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>';
82
- class C {
83
- constructor(e, t = {}) {
84
- this.isOpen = !1, this.tab = "submit", this.feedItems = [], this.selectedType = "GENERAL", this.loading = !1, this.dragMoved = !1, this.hasSupport = !1, this.disconnectSupport = null, this.client = e, this.accent = t.accentColor ?? E, this.position = t.position ?? "right", this.showLauncher = t.launcher !== !1, this.themeMode = t.theme ?? "auto", this.palette = y(this.themeMode) === "dark" ? x : m;
83
+ class F {
84
+ constructor(t, e = {}) {
85
+ this.isOpen = !1, this.tab = "submit", this.feedItems = [], this.selectedType = "GENERAL", this.loading = !1, this.dragMoved = !1, this.hasSupport = !1, this.disconnectSupport = null, this.client = t, this.accent = e.accentColor ?? E, this.position = e.position ?? "right", this.showLauncher = e.launcher !== !1, this.themeMode = e.theme ?? "auto", this.palette = y(this.themeMode) === "dark" ? m : x;
85
86
  }
86
87
  mount() {
87
- this.injectStyles(), this.showLauncher && this.renderButton(), this.client.supportEnabled().then((e) => {
88
- if (this.hasSupport = e, e) {
89
- const t = document.querySelector("#upstep-btn span");
90
- t && (t.textContent = "Help & feedback"), this.isOpen && this.renderModal();
88
+ this.injectStyles(), this.showLauncher && this.renderButton(), this.client.supportEnabled().then((t) => {
89
+ if (this.hasSupport = t, t) {
90
+ const e = document.querySelector("#upstep-btn span");
91
+ e && (e.textContent = "Help & feedback"), this.isOpen && this.renderModal();
91
92
  }
92
93
  });
93
94
  }
@@ -100,97 +101,86 @@ class C {
100
101
  this.closeModal();
101
102
  }
102
103
  injectStyles() {
103
- var t;
104
- (t = document.getElementById("upstep-styles")) == null || t.remove();
105
- const e = document.createElement("style");
106
- e.id = "upstep-styles", e.textContent = S(this.accent, this.position, this.palette), document.head.appendChild(e);
104
+ var e;
105
+ (e = document.getElementById("upstep-styles")) == null || e.remove();
106
+ const t = document.createElement("style");
107
+ t.id = "upstep-styles", t.textContent = S(this.accent, this.position, this.palette), document.head.appendChild(t);
107
108
  }
108
109
  renderButton() {
109
- const e = document.createElement("button");
110
- e.id = "upstep-btn", e.setAttribute("aria-label", "Open help and feedback"), e.innerHTML = `${L}<span>Feedback</span>`, e.addEventListener("click", () => {
110
+ const t = document.createElement("button");
111
+ t.id = "upstep-btn", t.setAttribute("aria-label", "Open help and feedback"), t.innerHTML = `${L}<span>Feedback</span>`, t.addEventListener("click", () => {
111
112
  this.dragMoved || this.openModal();
112
- }), document.body.appendChild(e), this.makeDraggable(e);
113
+ }), document.body.appendChild(t), this.makeDraggable(t);
113
114
  }
114
- makeDraggable(e) {
115
+ makeDraggable(t) {
115
116
  const s = "upstep-btn-pos";
116
117
  try {
117
118
  const i = localStorage.getItem(s);
118
119
  if (i) {
119
120
  const { side: d, bottom: u } = JSON.parse(i);
120
- e.style.left = d === "left" ? "24px" : "auto", e.style.right = d === "right" ? "24px" : "auto", e.style.top = "auto", e.style.bottom = `${u}px`;
121
+ t.style.left = d === "left" ? "24px" : "auto", t.style.right = d === "right" ? "24px" : "auto", t.style.top = "auto", t.style.bottom = `${u}px`;
121
122
  }
122
123
  } catch {
123
124
  }
124
- let a = 0, r = 0, l = 0, b = 0, h = !1;
125
+ let n = 0, r = 0, l = 0, h = 0, b = !1;
125
126
  const k = () => {
126
- const i = e.getBoundingClientRect(), d = 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;
127
- 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 = d === "left" ? "24px" : "auto", e.style.right = d === "right" ? "24px" : "auto", e.style.top = "auto", e.style.bottom = `${g}px`;
127
+ const i = t.getBoundingClientRect(), d = 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;
128
+ t.style.transition = "left .25s cubic-bezier(.16,1,.3,1),right .25s cubic-bezier(.16,1,.3,1),top .25s cubic-bezier(.16,1,.3,1),bottom .25s cubic-bezier(.16,1,.3,1),transform .15s,box-shadow .15s", t.style.left = d === "left" ? "24px" : "auto", t.style.right = d === "right" ? "24px" : "auto", t.style.top = "auto", t.style.bottom = `${g}px`;
128
129
  try {
129
130
  localStorage.setItem(s, JSON.stringify({ side: d, bottom: g }));
130
131
  } catch {
131
132
  }
132
133
  }, w = (i) => {
133
134
  if (i.pointerType === "mouse" && i.button !== 0) return;
134
- this.dragMoved = !1, h = !0;
135
- const d = e.getBoundingClientRect();
136
- a = i.clientX, r = i.clientY, l = d.left, b = d.top, e.setPointerCapture(i.pointerId), e.style.transition = "none";
135
+ this.dragMoved = !1, b = !0;
136
+ const d = t.getBoundingClientRect();
137
+ n = i.clientX, r = i.clientY, l = d.left, h = d.top, t.setPointerCapture(i.pointerId), t.style.transition = "none";
137
138
  }, $ = (i) => {
138
- if (!h) return;
139
- const d = i.clientX - a, u = i.clientY - r;
140
- !this.dragMoved && Math.hypot(d, u) < 6 || (this.dragMoved || e.classList.add("upstep-dragging"), this.dragMoved = !0, e.style.left = `${l + d}px`, e.style.right = "auto", e.style.top = `${b + u}px`, e.style.bottom = "auto");
139
+ if (!b) return;
140
+ const d = i.clientX - n, u = i.clientY - r;
141
+ !this.dragMoved && Math.hypot(d, u) < 6 || (this.dragMoved || t.classList.add("upstep-dragging"), this.dragMoved = !0, t.style.left = `${l + d}px`, t.style.right = "auto", t.style.top = `${h + u}px`, t.style.bottom = "auto");
141
142
  }, f = () => {
142
- h && (h = !1, e.classList.remove("upstep-dragging"), this.dragMoved && k());
143
+ b && (b = !1, t.classList.remove("upstep-dragging"), this.dragMoved && k());
143
144
  };
144
- e.addEventListener("pointerdown", w), e.addEventListener("pointermove", $), e.addEventListener("pointerup", f), e.addEventListener("pointercancel", f);
145
+ t.addEventListener("pointerdown", w), t.addEventListener("pointermove", $), t.addEventListener("pointerup", f), t.addEventListener("pointercancel", f);
145
146
  }
146
147
  openModal() {
147
- this.isOpen = !0, this.palette = y(this.themeMode) === "dark" ? x : m, this.injectStyles(), this.fetchFeed(), this.renderModal();
148
+ this.isOpen = !0, this.palette = y(this.themeMode) === "dark" ? m : x, this.injectStyles(), this.fetchFeed(), this.renderModal();
148
149
  }
149
150
  closeModal() {
150
- var e, t;
151
- (e = this.disconnectSupport) == null || e.call(this), this.disconnectSupport = null, this.isOpen = !1, (t = document.getElementById("upstep-backdrop")) == null || t.remove();
151
+ var t, e;
152
+ (t = this.disconnectSupport) == null || t.call(this), this.disconnectSupport = null, this.isOpen = !1, (e = document.getElementById("upstep-backdrop")) == null || e.remove();
152
153
  }
153
154
  async fetchFeed() {
154
155
  try {
155
- const e = await this.client.listFeedback({ sort: "votes", limit: 20 });
156
- this.feedItems = e.items, this.renderFeedList();
156
+ const t = await this.client.listFeedback({ sort: "votes", limit: 20 });
157
+ this.feedItems = t.items, this.renderFeedList();
157
158
  } catch {
158
159
  }
159
160
  }
160
161
  renderModal() {
161
- var n, s, a;
162
- (n = this.disconnectSupport) == null || n.call(this), this.disconnectSupport = null;
163
- const e = document.createElement("div");
164
- e.id = "upstep-backdrop", e.addEventListener("click", (r) => {
165
- r.target === e && this.closeModal();
166
- }), e.innerHTML = `
167
- <div id="upstep-modal">
168
- <div id="upstep-header">
169
- <div>
170
- <h2>${this.tab === "support" ? "Customer support" : "Share your feedback"}</h2>
171
- <p>${this.tab === "support" ? "Ask AI, or talk with the team." : "Tell us what to build next, or vote on ideas."}</p>
172
- </div>
173
- <button id="upstep-close" aria-label="Close">✕</button>
174
- </div>
175
- <div id="upstep-tabs">
176
- ${this.hasSupport ? `<button class="upstep-tab ${this.tab === "support" ? "active" : ""}" data-tab="support">Support</button>` : ""}
177
- <button class="upstep-tab ${this.tab === "submit" ? "active" : ""}" data-tab="submit">Give feedback</button>
178
- <button class="upstep-tab ${this.tab === "feed" ? "active" : ""}" data-tab="feed">Vote on ideas</button>
179
- </div>
180
- <div id="upstep-body">
181
- ${this.tab === "support" ? `<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg === "#000000" ? "dark" : "light")}" style="width:100%;height:480px;border:0;display:block;border-radius:12px"></iframe>` : this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
162
+ var a, s, n;
163
+ (a = this.disconnectSupport) == null || a.call(this), this.disconnectSupport = null;
164
+ const t = document.createElement("div");
165
+ t.id = "upstep-backdrop", t.addEventListener("click", (r) => {
166
+ r.target === t && this.closeModal();
167
+ }), t.innerHTML = `
168
+ <div id="upstep-modal" style="max-width:${this.hasSupport ? "460px" : "440px"}">
169
+ ${this.hasSupport ? `<div class="upstep-mode" style="display:flex;align-items:center;gap:14px;padding:10px 14px;border-bottom:1px solid ${this.palette.border}"><div id="upstep-tabs" style="margin:0;padding:0;background:transparent;flex:1"><button class="upstep-tab ${this.tab === "support" ? "active" : ""}" data-tab="support">Support</button><button class="upstep-tab ${this.tab === "submit" ? "active" : ""}" data-tab="submit">Feedback</button><button class="upstep-tab ${this.tab === "feed" ? "active" : ""}" data-tab="feed">Ideas</button></div><button id="upstep-close" aria-label="Close" style="flex-shrink:0;background:transparent">✕</button></div>` : `<div id="upstep-header"><div><h2>Share your feedback</h2><p>Tell us what to build next, or vote on ideas.</p></div><button id="upstep-close" aria-label="Close">✕</button></div><div id="upstep-tabs"><button class="upstep-tab ${this.tab === "submit" ? "active" : ""}" data-tab="submit">Give feedback</button><button class="upstep-tab ${this.tab === "feed" ? "active" : ""}" data-tab="feed">Vote on ideas</button></div>`}
170
+ <div id="upstep-body" style="${this.tab === "support" ? "padding:0;overflow:hidden" : ""}">
171
+ ${this.tab === "support" ? `<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg === "#000000" ? "dark" : "light")}" style="width:100%;height:min(560px,calc(88dvh - 56px));min-height:300px;border:0;display:block"></iframe>` : this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
182
172
  </div>
183
173
  </div>
184
- `, (s = document.getElementById("upstep-backdrop")) == null || s.remove(), document.body.appendChild(e), (a = e.querySelector("#upstep-close")) == null || a.addEventListener("click", () => this.closeModal()), e.querySelectorAll(".upstep-tab").forEach((r) => {
174
+ `, (s = document.getElementById("upstep-backdrop")) == null || s.remove(), document.body.appendChild(t), (n = t.querySelector("#upstep-close")) == null || n.addEventListener("click", () => this.closeModal()), t.querySelectorAll(".upstep-tab").forEach((r) => {
185
175
  r.addEventListener("click", () => {
186
176
  this.tab = r.dataset.tab, this.renderModal();
187
177
  });
188
178
  });
189
- const t = e.querySelector("#upstep-support-frame");
190
- t && (this.disconnectSupport = this.client.connectSupportFrame(t)), this.bindSubmitForm(), this.bindVoteButtons();
179
+ const e = t.querySelector("#upstep-support-frame");
180
+ e && (this.disconnectSupport = this.client.connectSupportFrame(e)), this.bindSubmitForm(), this.bindVoteButtons();
191
181
  }
192
182
  renderSubmitForm() {
193
- const e = ["BUG", "FEATURE", "GENERAL"], t = { BUG: "Bug", FEATURE: "Feature", GENERAL: "General" }, n = {
183
+ const t = ["BUG", "FEATURE", "GENERAL"], e = { BUG: "Bug", FEATURE: "Feature", GENERAL: "General" }, a = {
194
184
  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>',
195
185
  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>',
196
186
  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>'
@@ -199,7 +189,7 @@ class C {
199
189
  <div class="upstep-form">
200
190
  <textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
201
191
  <div class="upstep-type-row">
202
- ${e.map((s) => `<button class="upstep-type-btn${this.selectedType === s ? " selected" : ""}" data-type="${s}">${n[s]}${t[s]}</button>`).join("")}
192
+ ${t.map((s) => `<button class="upstep-type-btn${this.selectedType === s ? " selected" : ""}" data-type="${s}">${a[s]}${e[s]}</button>`).join("")}
203
193
  </div>
204
194
  <button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
205
195
  <div id="upstep-form-msg"></div>
@@ -208,20 +198,20 @@ class C {
208
198
  }
209
199
  renderFeed() {
210
200
  return this.feedItems.length ? this.feedItems.map(
211
- (e) => {
212
- var t;
201
+ (t) => {
202
+ var e;
213
203
  return `
214
- <div class="upstep-feedback-item" data-id="${e.id}">
215
- <button class="upstep-vote${e.userVote === "UP" ? " voted" : ""}" data-vote="UP" data-feedback="${e.id}">
204
+ <div class="upstep-feedback-item" data-id="${t.id}">
205
+ <button class="upstep-vote${t.userVote === "UP" ? " voted" : ""}" data-vote="UP" data-feedback="${t.id}">
216
206
  <span class="upstep-vote-arrow">▲</span>
217
- <span class="upstep-vote-count">${e.upvotes}</span>
207
+ <span class="upstep-vote-count">${t.upvotes}</span>
218
208
  </button>
219
209
  <div class="upstep-feedback-main">
220
- <p class="upstep-feedback-content">${v(e.content)}</p>
210
+ <p class="upstep-feedback-content">${v(t.content)}</p>
221
211
  <div class="upstep-feedback-meta">
222
- <span class="upstep-badge upstep-badge-${e.type.toLowerCase()}">${e.type}</span>
223
- <span class="upstep-badge upstep-badge-general">${v(((t = e.boardStatus) == null ? void 0 : t.name) ?? e.status.replace("_", " "))}</span>
224
- <span class="upstep-feedback-date">${new Date(e.createdAt).toLocaleDateString()}</span>
212
+ <span class="upstep-badge upstep-badge-${t.type.toLowerCase()}">${t.type}</span>
213
+ <span class="upstep-badge upstep-badge-general">${v(((e = t.boardStatus) == null ? void 0 : e.name) ?? t.status.replace("_", " "))}</span>
214
+ <span class="upstep-feedback-date">${new Date(t.createdAt).toLocaleDateString()}</span>
225
215
  </div>
226
216
  </div>
227
217
  </div>`;
@@ -229,25 +219,25 @@ class C {
229
219
  ).join("") : '<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>';
230
220
  }
231
221
  renderFeedList() {
232
- const e = document.getElementById("upstep-body");
233
- !e || this.tab !== "feed" || (e.innerHTML = this.renderFeed(), this.bindVoteButtons());
222
+ const t = document.getElementById("upstep-body");
223
+ !t || this.tab !== "feed" || (t.innerHTML = this.renderFeed(), this.bindVoteButtons());
234
224
  }
235
225
  bindSubmitForm() {
236
- var e;
237
- document.querySelectorAll(".upstep-type-btn").forEach((t) => {
238
- t.addEventListener("click", () => {
239
- this.selectedType = t.dataset.type, document.querySelectorAll(".upstep-type-btn").forEach((n) => n.classList.remove("selected")), t.classList.add("selected");
226
+ var t;
227
+ document.querySelectorAll(".upstep-type-btn").forEach((e) => {
228
+ e.addEventListener("click", () => {
229
+ this.selectedType = e.dataset.type, document.querySelectorAll(".upstep-type-btn").forEach((a) => a.classList.remove("selected")), e.classList.add("selected");
240
230
  });
241
- }), (e = document.getElementById("upstep-submit-btn")) == null || e.addEventListener("click", async () => {
242
- const t = document.getElementById("upstep-textarea"), n = document.getElementById("upstep-form-msg"), s = document.getElementById("upstep-submit-btn");
243
- if (!t || this.loading) return;
244
- const a = t.value.trim();
245
- if (a) {
231
+ }), (t = document.getElementById("upstep-submit-btn")) == null || t.addEventListener("click", async () => {
232
+ const e = document.getElementById("upstep-textarea"), a = document.getElementById("upstep-form-msg"), s = document.getElementById("upstep-submit-btn");
233
+ if (!e || this.loading) return;
234
+ const n = e.value.trim();
235
+ if (n) {
246
236
  this.loading = !0, s && (s.disabled = !0, s.textContent = "Sending…");
247
237
  try {
248
- await this.client.submitFeedback({ content: a, type: this.selectedType }), t.value = "", n && (n.textContent = "Feedback received. Thank you."), await this.fetchFeed();
238
+ await this.client.submitFeedback({ content: n, type: this.selectedType }), e.value = "", a && (a.textContent = "Feedback received. Thank you."), await this.fetchFeed();
249
239
  } catch {
250
- n && (n.textContent = "Something went wrong. Please try again.");
240
+ a && (a.textContent = "Something went wrong. Please try again.");
251
241
  } finally {
252
242
  this.loading = !1, s && (s.disabled = !1, s.textContent = "Send feedback");
253
243
  }
@@ -255,11 +245,11 @@ class C {
255
245
  });
256
246
  }
257
247
  bindVoteButtons() {
258
- document.querySelectorAll(".upstep-vote").forEach((e) => {
259
- e.addEventListener("click", async () => {
260
- const t = e.dataset.feedback;
248
+ document.querySelectorAll(".upstep-vote").forEach((t) => {
249
+ t.addEventListener("click", async () => {
250
+ const e = t.dataset.feedback;
261
251
  try {
262
- await this.client.vote(t, "UP"), await this.fetchFeed();
252
+ await this.client.vote(e, "UP"), await this.fetchFeed();
263
253
  } catch {
264
254
  }
265
255
  });
@@ -270,15 +260,15 @@ function v(o) {
270
260
  return o.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
271
261
  }
272
262
  let p = null, c = null;
273
- const F = {
263
+ const C = {
274
264
  init(o) {
275
265
  if (p = new M(o), typeof window < "u") {
276
- const e = {};
277
- 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);
278
- const t = () => {
279
- c = new C(p, e), c.mount();
266
+ const t = {};
267
+ 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);
268
+ const e = () => {
269
+ c = new F(p, t), c.mount();
280
270
  };
281
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : t();
271
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : e();
282
272
  }
283
273
  return p;
284
274
  },
@@ -296,10 +286,10 @@ const F = {
296
286
  },
297
287
  /** Change or clear verified support identity after login/logout. */
298
288
  identifySupport(o) {
299
- var t;
289
+ var e;
300
290
  p && (p.supportIdentityToken = o);
301
- const e = document.querySelector("#upstep-support-frame");
302
- e && p && ((t = e.contentWindow) == null || t.postMessage({ type: "upstep:support:identity", token: o }, new URL(p.baseUrl).origin));
291
+ const t = document.querySelector("#upstep-support-frame");
292
+ t && p && ((e = t.contentWindow) == null || e.postMessage({ type: "upstep:support:identity", token: o }, new URL(p.baseUrl).origin));
303
293
  },
304
294
  get client() {
305
295
  if (!p) throw new Error("Upstep.init() must be called first");
@@ -307,13 +297,13 @@ const F = {
307
297
  }
308
298
  };
309
299
  if (typeof document < "u") {
310
- 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, a = o == null ? void 0 : o.dataset.position, r = o == null ? void 0 : o.dataset.theme;
311
- if (e) {
312
- const l = { apiKey: e };
313
- t && (l.userId = t), (o == null ? void 0 : o.dataset.chat) !== void 0 && (l.chat = o.dataset.chat !== "false"), n && (l.baseUrl = n), s && (l.accentColor = s), (a === "left" || a === "right") && (l.position = a), (r === "light" || r === "dark" || r === "auto") && (l.theme = r), F.init(l);
300
+ const o = document.currentScript, t = o == null ? void 0 : o.dataset.apiKey, e = o == null ? void 0 : o.dataset.userId, a = o == null ? void 0 : o.dataset.baseUrl, s = o == null ? void 0 : o.dataset.accentColor, n = o == null ? void 0 : o.dataset.position, r = o == null ? void 0 : o.dataset.theme;
301
+ if (t) {
302
+ const l = { apiKey: t };
303
+ e && (l.userId = e), (o == null ? void 0 : o.dataset.chat) !== void 0 && (l.chat = o.dataset.chat !== "false"), a && (l.baseUrl = a), s && (l.accentColor = s), (n === "left" || n === "right") && (l.position = n), (r === "light" || r === "dark" || r === "auto") && (l.theme = r), C.init(l);
314
304
  }
315
305
  }
316
306
  export {
317
307
  M as UpstepApiClient,
318
- F as default
308
+ C as default
319
309
  };