@upstep/js 0.3.0 → 0.4.0

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