@upstep/js 0.5.0 → 0.5.2

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.
@@ -1 +1 @@
1
- "use strict";class i{constructor(e){this.baseUrl=(e.baseUrl??"https://upstep.io").replace(/\/$/,""),this.apiKey=e.apiKey,e.userId!==void 0&&(this.userId=e.userId)}setUserId(e){this.userId=e}headers(){return{"Content-Type":"application/json","x-api-key":this.apiKey}}async listFeedback(e){const t=new URLSearchParams;e!=null&&e.cursor&&t.set("cursor",e.cursor),e!=null&&e.limit&&t.set("limit",String(e.limit)),e!=null&&e.type&&t.set("type",e.type),e!=null&&e.status&&t.set("status",e.status),e!=null&&e.sort&&t.set("sort",e.sort),this.userId&&t.set("endUserId",this.userId);const s=await fetch(`${this.baseUrl}/api/sdk/feedback?${t}`,{headers:this.headers()});if(!s.ok)throw new Error(`Upstep: ${s.status}`);return s.json()}async submitFeedback(e){const t=await fetch(`${this.baseUrl}/api/sdk/feedback`,{method:"POST",headers:this.headers(),body:JSON.stringify({...e,endUserId:e.endUserId??this.userId})});if(!t.ok)throw new Error(`Upstep: ${t.status}`);return t.json()}async vote(e,t){const s=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote`,{method:"POST",headers:this.headers(),body:JSON.stringify({value:t,endUserId:this.userId})});if(!s.ok)throw new Error(`Upstep: ${s.status}`)}async removeVote(e){if(!this.userId)return;const t=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote?endUserId=${encodeURIComponent(this.userId)}`,{method:"DELETE",headers:this.headers()});if(!t.ok)throw new Error(`Upstep: ${t.status}`)}}exports.UpstepApiClient=i;
1
+ "use strict";class i{constructor(e){this.baseUrl=(e.baseUrl??"https://upstep.io").replace(/\/$/,""),this.apiKey=e.apiKey,e.userId!==void 0&&(this.userId=e.userId)}setUserId(e){this.userId=e}headers(){return{"Content-Type":"application/json","x-api-key":this.apiKey}}async listFeedback(e){const t=new URLSearchParams;e!=null&&e.cursor&&t.set("cursor",e.cursor),e!=null&&e.limit&&t.set("limit",String(e.limit)),e!=null&&e.type&&t.set("type",e.type),e!=null&&e.status&&t.set("status",e.status),e!=null&&e.sort&&t.set("sort",e.sort),this.userId&&t.set("endUserId",this.userId);const s=await fetch(`${this.baseUrl}/api/sdk/feedback?${t}`,{headers:this.headers()});if(!s.ok)throw new Error(`Upstep: ${s.status}`);return s.json()}async submitFeedback(e){const t=await fetch(`${this.baseUrl}/api/sdk/feedback`,{method:"POST",headers:this.headers(),body:JSON.stringify({...e,endUserId:e.endUserId??this.userId})});if(!t.ok)throw new Error(`Upstep: ${t.status}`);return t.json()}async vote(e,t){const s=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote`,{method:"POST",headers:this.headers(),body:JSON.stringify({value:t,endUserId:this.userId})});if(!s.ok)throw new Error(`Upstep: ${s.status}`)}async getItem(e){const t=new URLSearchParams;this.userId&&t.set("endUserId",this.userId);const s=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}?${t}`,{headers:this.headers()});if(!s.ok)throw new Error(`Upstep: ${s.status}`);return s.json()}async removeVote(e){if(!this.userId)return;const t=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote?endUserId=${encodeURIComponent(this.userId)}`,{method:"DELETE",headers:this.headers()});if(!t.ok)throw new Error(`Upstep: ${t.status}`)}}exports.UpstepApiClient=i;
@@ -41,6 +41,15 @@ class r {
41
41
  });
42
42
  if (!s.ok) throw new Error(`Upstep: ${s.status}`);
43
43
  }
44
+ async getItem(e) {
45
+ const t = new URLSearchParams();
46
+ this.userId && t.set("endUserId", this.userId);
47
+ const s = await fetch(`${this.baseUrl}/api/sdk/feedback/${e}?${t}`, {
48
+ headers: this.headers()
49
+ });
50
+ if (!s.ok) throw new Error(`Upstep: ${s.status}`);
51
+ return s.json();
52
+ }
44
53
  async removeVote(e) {
45
54
  if (!this.userId) return;
46
55
  const t = await fetch(
package/dist/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Feedback, FeedbackListResponse, SubmitFeedbackPayload, VotePayload, UpstepConfig } from '@upstep/types';
1
+ import { Feedback, FeedbackListResponse, FeedbackWithComments, SubmitFeedbackPayload, VotePayload, UpstepConfig } from '@upstep/types';
2
2
  export declare class UpstepApiClient {
3
3
  private readonly baseUrl;
4
4
  private readonly apiKey;
@@ -16,6 +16,7 @@ export declare class UpstepApiClient {
16
16
  }): Promise<FeedbackListResponse>;
17
17
  submitFeedback(payload: SubmitFeedbackPayload): Promise<Feedback>;
18
18
  vote(feedbackId: string, value: VotePayload["value"]): Promise<void>;
19
+ getItem(feedbackId: string): Promise<FeedbackWithComments>;
19
20
  removeVote(feedbackId: string): Promise<void>;
20
21
  }
21
22
  //# sourceMappingURL=api.d.ts.map
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACb,MAAM,eAAe,CAAC;AAEvB,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEf,MAAM,EAAE,YAAY;IAMhC,uEAAuE;IACvE,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAIpC,OAAO,CAAC,OAAO;IAOT,YAAY,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACzB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAiB3B,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAajE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IASpE,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQpD"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACb,MAAM,eAAe,CAAC;AAEvB,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEf,MAAM,EAAE,YAAY;IAMhC,uEAAuE;IACvE,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAIpC,OAAO,CAAC,OAAO;IAOT,YAAY,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACzB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAiB3B,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAajE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IASpE,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAU1D,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQpD"}
package/dist/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./api-Csp7O_a2.js"),u="#D97757",b={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},f={bg:"#1c1b19",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function h(o){return o==="light"||o==="dark"?o:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function x(o,t,e){return`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./api-Bzvimzou.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
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;${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 svg{width:16px;height:16px;flex-shrink:0}
4
5
  #upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
5
6
  #upstep-btn svg{width:16px;height:16px}
6
7
  #upstep-backdrop{position:fixed;inset:0;background:${e.overlay};backdrop-filter:blur(3px);z-index:9999;display:flex;align-items:center;justify-content:center;padding:16px;animation:upstep-fade .2s ease}
@@ -20,7 +21,8 @@
20
21
  .upstep-form textarea::placeholder{color:${e.textFaint}}
21
22
  .upstep-form textarea:focus{border-color:${o};background:${e.bg}}
22
23
  .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{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:9px;border:1px solid ${e.border};background:${e.bg};color:${e.textSoft};font-size:12.5px;font-weight:600;cursor:pointer;transition:all .15s}
25
+ .upstep-type-btn svg{width:12px;height:12px;flex-shrink:0}
24
26
  .upstep-type-btn:hover{border-color:${e.textFaint}}
25
27
  .upstep-type-btn.selected{background:${o};color:#fff;border-color:${o}}
26
28
  .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}
@@ -44,7 +46,7 @@
44
46
  .upstep-feedback-date{font-size:11px;color:${e.textFaint}}
45
47
  .upstep-empty{text-align:center;color:${e.textFaint};font-size:14px;padding:40px 0}
46
48
  .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=`
49
+ `}const g='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';class m{constructor(t,e={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.client=t,this.accent=e.accentColor??u,this.position=e.position??"right",this.showLauncher=e.launcher!==!1,this.palette=h(e.theme??"auto")==="dark"?f:b}mount(){this.injectStyles(),this.showLauncher&&this.renderButton()}openWidget(){this.openModal()}closeWidget(){this.closeModal()}injectStyles(){var e;(e=document.getElementById("upstep-styles"))==null||e.remove();const t=document.createElement("style");t.id="upstep-styles",t.textContent=x(this.accent,this.position,this.palette),document.head.appendChild(t)}renderButton(){const t=document.createElement("button");t.id="upstep-btn",t.innerHTML=`${g}<span>Feedback</span>`,t.addEventListener("click",()=>this.openModal()),document.body.appendChild(t)}openModal(){this.isOpen=!0,this.fetchFeed(),this.renderModal()}closeModal(){var t;this.isOpen=!1,(t=document.getElementById("upstep-backdrop"))==null||t.remove()}async fetchFeed(){try{const t=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=t.items,this.renderFeedList()}catch{}}renderModal(){var e,i;const t=document.createElement("div");t.id="upstep-backdrop",t.addEventListener("click",s=>{s.target===t&&this.closeModal()}),t.innerHTML=`
48
50
  <div id="upstep-modal">
49
51
  <div id="upstep-header">
50
52
  <div>
@@ -61,11 +63,11 @@
61
63
  ${this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
62
64
  </div>
63
65
  </div>
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`
66
+ `,(e=document.getElementById("upstep-backdrop"))==null||e.remove(),document.body.appendChild(t),(i=t.querySelector("#upstep-close"))==null||i.addEventListener("click",()=>this.closeModal()),t.querySelectorAll(".upstep-tab").forEach(s=>{s.addEventListener("click",()=>{this.tab=s.dataset.tab,this.renderModal()})}),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const t=["BUG","FEATURE","GENERAL"],e={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},i={BUG:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="8" cy="10" rx="3.5" ry="4.5"/><path d="M8 5.5V4M5.5 6.5 3.5 5M10.5 6.5 12.5 5M4.5 10.5 2.5 10M11.5 10.5 13.5 10"/></svg>',FEATURE:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.1 4.1l1 1M10.9 10.9l1 1M11.9 4.1l-1 1M5.1 10.9l-1 1"/><circle cx="8" cy="8" r="2.5"/></svg>',GENERAL:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"/></svg>'};return`
65
67
  <div class="upstep-form">
66
68
  <textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
67
69
  <div class="upstep-type-row">
68
- ${t.map(s=>`<button class="upstep-type-btn${this.selectedType===s?" selected":""}" data-type="${s}">${e[s]}</button>`).join("")}
70
+ ${t.map(s=>`<button class="upstep-type-btn${this.selectedType===s?" selected":""}" data-type="${s}">${i[s]}${e[s]}</button>`).join("")}
69
71
  </div>
70
72
  <button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
71
73
  <div id="upstep-form-msg"></div>
@@ -83,4 +85,4 @@
83
85
  <span class="upstep-feedback-date">${new Date(t.createdAt).toLocaleDateString()}</span>
84
86
  </div>
85
87
  </div>
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;
88
+ </div>`).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const t=document.getElementById("upstep-body");!t||this.tab!=="feed"||(t.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var t;document.querySelectorAll(".upstep-type-btn").forEach(e=>{e.addEventListener("click",()=>{this.selectedType=e.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(i=>i.classList.remove("selected")),e.classList.add("selected")})}),(t=document.getElementById("upstep-submit-btn"))==null||t.addEventListener("click",async()=>{const e=document.getElementById("upstep-textarea"),i=document.getElementById("upstep-form-msg"),s=document.getElementById("upstep-submit-btn");if(!e||this.loading)return;const r=e.value.trim();if(r){this.loading=!0,s&&(s.disabled=!0,s.textContent="Sending…");try{await this.client.submitFeedback({content:r,type:this.selectedType}),e.value="",i&&(i.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{i&&(i.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,s&&(s.disabled=!1,s.textContent="Send feedback")}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote").forEach(t=>{t.addEventListener("click",async()=>{const e=t.dataset.feedback;try{await this.client.vote(e,"UP"),await this.fetchFeed()}catch{}})})}}function y(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let n=null,a=null;const c={init(o){if(n=new l.UpstepApiClient(o),typeof window<"u"){const t={};o.accentColor!==void 0&&(t.accentColor=o.accentColor),o.position!==void 0&&(t.position=o.position),o.theme!==void 0&&(t.theme=o.theme),o.launcher!==void 0&&(t.launcher=o.launcher);const e=()=>{a=new m(n,t),a.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}return n},open(){a==null||a.openWidget()},close(){a==null||a.closeWidget()},identify(o){n==null||n.setUserId(o)},get client(){if(!n)throw new Error("Upstep.init() must be called first");return n}};if(typeof document<"u"){const o=document.currentScript,t=o==null?void 0:o.dataset.apiKey,e=o==null?void 0:o.dataset.userId,i=o==null?void 0:o.dataset.baseUrl,s=o==null?void 0:o.dataset.accentColor,r=o==null?void 0:o.dataset.position,p=o==null?void 0:o.dataset.theme;if(t){const d={apiKey:t};e&&(d.userId=e),i&&(d.baseUrl=i),s&&(d.accentColor=s),(r==="left"||r==="right")&&(d.position=r),(p==="light"||p==="dark"||p==="auto")&&(d.theme=p),c.init(d)}}exports.UpstepApiClient=l.UpstepApiClient;exports.default=c;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { U as l } from "./api-CRsXibfd.mjs";
1
+ import { U as l } from "./api-CMuwaAet.mjs";
2
2
  const c = "#D97757", u = {
3
3
  bg: "#ffffff",
4
4
  bgSoft: "#f6f5f2",
@@ -25,6 +25,7 @@ function h(o, t, e) {
25
25
  return `
26
26
  #upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
27
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 svg{width:16px;height:16px;flex-shrink:0}
28
29
  #upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
29
30
  #upstep-btn svg{width:16px;height:16px}
30
31
  #upstep-backdrop{position:fixed;inset:0;background:${e.overlay};backdrop-filter:blur(3px);z-index:9999;display:flex;align-items:center;justify-content:center;padding:16px;animation:upstep-fade .2s ease}
@@ -44,7 +45,8 @@ function h(o, t, e) {
44
45
  .upstep-form textarea::placeholder{color:${e.textFaint}}
45
46
  .upstep-form textarea:focus{border-color:${o};background:${e.bg}}
46
47
  .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{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:9px;border:1px solid ${e.border};background:${e.bg};color:${e.textSoft};font-size:12.5px;font-weight:600;cursor:pointer;transition:all .15s}
49
+ .upstep-type-btn svg{width:12px;height:12px;flex-shrink:0}
48
50
  .upstep-type-btn:hover{border-color:${e.textFaint}}
49
51
  .upstep-type-btn.selected{background:${o};color:#fff;border-color:${o}}
50
52
  .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}
@@ -111,10 +113,10 @@ class g {
111
113
  }
112
114
  }
113
115
  renderModal() {
114
- var e, s;
116
+ var e, i;
115
117
  const t = document.createElement("div");
116
- t.id = "upstep-backdrop", t.addEventListener("click", (i) => {
117
- i.target === t && this.closeModal();
118
+ t.id = "upstep-backdrop", t.addEventListener("click", (s) => {
119
+ s.target === t && this.closeModal();
118
120
  }), t.innerHTML = `
119
121
  <div id="upstep-modal">
120
122
  <div id="upstep-header">
@@ -132,19 +134,23 @@ class g {
132
134
  ${this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
133
135
  </div>
134
136
  </div>
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) => {
136
- i.addEventListener("click", () => {
137
- this.tab = i.dataset.tab, this.renderModal();
137
+ `, (e = document.getElementById("upstep-backdrop")) == null || e.remove(), document.body.appendChild(t), (i = t.querySelector("#upstep-close")) == null || i.addEventListener("click", () => this.closeModal()), t.querySelectorAll(".upstep-tab").forEach((s) => {
138
+ s.addEventListener("click", () => {
139
+ this.tab = s.dataset.tab, this.renderModal();
138
140
  });
139
141
  }), this.bindSubmitForm(), this.bindVoteButtons();
140
142
  }
141
143
  renderSubmitForm() {
142
- const t = ["BUG", "FEATURE", "GENERAL"], e = { BUG: "🐞 Bug", FEATURE: "✨ Feature", GENERAL: "💬 General" };
144
+ const t = ["BUG", "FEATURE", "GENERAL"], e = { BUG: "Bug", FEATURE: "Feature", GENERAL: "General" }, i = {
145
+ BUG: '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="8" cy="10" rx="3.5" ry="4.5"/><path d="M8 5.5V4M5.5 6.5 3.5 5M10.5 6.5 12.5 5M4.5 10.5 2.5 10M11.5 10.5 13.5 10"/></svg>',
146
+ FEATURE: '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.1 4.1l1 1M10.9 10.9l1 1M11.9 4.1l-1 1M5.1 10.9l-1 1"/><circle cx="8" cy="8" r="2.5"/></svg>',
147
+ 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>'
148
+ };
143
149
  return `
144
150
  <div class="upstep-form">
145
151
  <textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
146
152
  <div class="upstep-type-row">
147
- ${t.map((s) => `<button class="upstep-type-btn${this.selectedType === s ? " selected" : ""}" data-type="${s}">${e[s]}</button>`).join("")}
153
+ ${t.map((s) => `<button class="upstep-type-btn${this.selectedType === s ? " selected" : ""}" data-type="${s}">${i[s]}${e[s]}</button>`).join("")}
148
154
  </div>
149
155
  <button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
150
156
  <div id="upstep-form-msg"></div>
@@ -177,20 +183,20 @@ class g {
177
183
  var t;
178
184
  document.querySelectorAll(".upstep-type-btn").forEach((e) => {
179
185
  e.addEventListener("click", () => {
180
- this.selectedType = e.dataset.type, document.querySelectorAll(".upstep-type-btn").forEach((s) => s.classList.remove("selected")), e.classList.add("selected");
186
+ this.selectedType = e.dataset.type, document.querySelectorAll(".upstep-type-btn").forEach((i) => i.classList.remove("selected")), e.classList.add("selected");
181
187
  });
182
188
  }), (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");
189
+ const e = document.getElementById("upstep-textarea"), i = document.getElementById("upstep-form-msg"), s = document.getElementById("upstep-submit-btn");
184
190
  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…");
191
+ const r = e.value.trim();
192
+ if (r) {
193
+ this.loading = !0, s && (s.disabled = !0, s.textContent = "Sending…");
188
194
  try {
189
- await this.client.submitFeedback({ content: d, type: this.selectedType }), e.value = "", s && (s.textContent = "Thanks — we got your feedback! 🎉"), await this.fetchFeed();
195
+ await this.client.submitFeedback({ content: r, type: this.selectedType }), e.value = "", i && (i.textContent = "Feedback received. Thank you."), await this.fetchFeed();
190
196
  } catch {
191
- s && (s.textContent = "Something went wrong. Please try again.");
197
+ i && (i.textContent = "Something went wrong. Please try again.");
192
198
  } finally {
193
- this.loading = !1, i && (i.disabled = !1, i.textContent = "Send feedback");
199
+ this.loading = !1, s && (s.disabled = !1, s.textContent = "Send feedback");
194
200
  }
195
201
  }
196
202
  });
@@ -241,10 +247,10 @@ const y = {
241
247
  }
242
248
  };
243
249
  if (typeof document < "u") {
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;
250
+ const o = document.currentScript, t = o == null ? void 0 : o.dataset.apiKey, e = o == null ? void 0 : o.dataset.userId, i = o == null ? void 0 : o.dataset.baseUrl, s = o == null ? void 0 : o.dataset.accentColor, r = o == null ? void 0 : o.dataset.position, p = o == null ? void 0 : o.dataset.theme;
245
251
  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);
252
+ const d = { apiKey: t };
253
+ e && (d.userId = e), i && (d.baseUrl = i), s && (d.accentColor = s), (r === "left" || r === "right") && (d.position = r), (p === "light" || p === "dark" || p === "auto") && (d.theme = p), y.init(d);
248
254
  }
249
255
  }
250
256
  export {
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"),A=require("./api-Csp7O_a2.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),T=require("./api-Bzvimzou.js"),U="#D97757",R={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 D(o){const[t,n]=r.useState(()=>o==="dark"?!0:o==="light"?!1:typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1);return r.useEffect(()=>{if(o!=="auto"||typeof window>"u"||!window.matchMedia){n(o==="dark");return}const a=window.matchMedia("(prefers-color-scheme: dark)"),p=l=>n(l.matches);return n(a.matches),a.addEventListener("change",p),()=>a.removeEventListener("change",p)},[o]),t?L:R}const C=r.createContext(null);function M({children:o,...t}){const[n]=r.useState(()=>new T.UpstepApiClient(t)),[a,p]=r.useState([]),[l,i]=r.useState(!1),[s,g]=r.useState(!0);r.useEffect(()=>{n.setUserId(t.userId)},[n,t.userId]);const d=r.useCallback(async()=>{const f=await n.listFeedback({sort:"votes",limit:20});p(f.items),g(f.showBranding??!0)},[n]);r.useEffect(()=>{d()},[d]);const m=r.useCallback(async(f,j,h)=>{const u={content:j};f.trim()&&(u.title=f.trim()),h!==void 0&&(u.type=h),await n.submitFeedback(u),await d()},[n,d]),c=r.useCallback(async(f,j)=>{await n.vote(f,j),await d()},[n,d]),x=r.useCallback(f=>n.getItem(f),[n]),y=r.useCallback(()=>i(!0),[]),k=r.useCallback(()=>i(!1),[]),S=r.useCallback(f=>n.setUserId(f),[n]);return e.jsx(C.Provider,{value:{client:n,feedItems:a,loadFeed:d,submit:m,vote:c,getItem:x,isOpen:l,open:y,close:k,identify:S,accentColor:t.accentColor??U,theme:t.theme??"auto",showBranding:s},children:o})}function v(){const o=r.useContext(C);if(!o)throw new Error("useUpstep must be used inside <UpstepProvider>");return o}function P({position:o="bottom-right",accentColor:t,theme:n,hideLauncher:a=!1}){const p=v(),l=t??p.accentColor,i=D(n??p.theme),{isOpen:s,open:g,close:d,showBranding:m}=p,[c,x]=r.useState("list"),[y,k]=r.useState(null),[S,f]=r.useState("open"),j=o==="bottom-left"?{position:"fixed",bottom:24,left:24}:{position:"fixed",bottom:24,right:24},h='-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';function u(){d(),setTimeout(()=>{x("list"),k(null)},300)}function I(b){k(b),x("detail")}return e.jsxs(e.Fragment,{children:[!a&&e.jsxs("button",{onClick:g,style:{...j,zIndex:9998,display:"inline-flex",alignItems:"center",gap:7,background:l,color:"#fff",border:"none",borderRadius:9999,padding:"12px 18px",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:h,boxShadow:"0 6px 20px rgba(26,25,21,.18)"},children:[e.jsx(_,{size:16})," Feedback"]}),s&&e.jsx("div",{onClick:b=>b.target===b.currentTarget&&u(),style:{position:"fixed",inset:0,background:i.overlay,backdropFilter:"blur(3px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:16,fontFamily:h},children:e.jsxs("div",{style:{background:i.bg,border:`1px solid ${i.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:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${i.border}`,flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c!=="list"&&e.jsx("button",{onClick:()=>x("list"),style:{background:"none",border:"none",cursor:"pointer",color:l,fontSize:13,fontWeight:600,padding:0},children:"← Back"}),c==="list"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:i.text,letterSpacing:"-.01em"},children:"Feedback"}),c==="create"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:i.text,letterSpacing:"-.01em"},children:"New feedback"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c==="list"&&e.jsx("button",{onClick:()=>x("create"),style:{background:l,color:"#fff",border:"none",borderRadius:20,padding:"6px 14px",fontSize:13,fontWeight:700,cursor:"pointer"},children:"+ New"}),e.jsx("button",{onClick:u,style:{background:i.bgSoft,border:"none",width:28,height:28,borderRadius:8,fontSize:14,cursor:"pointer",color:i.textSoft,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]})]}),c==="list"&&e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${i.border}`,flexShrink:0},children:["open","done"].map(b=>e.jsx("button",{onClick:()=>f(b),style:{flex:1,padding:"10px 0",border:"none",background:"none",cursor:"pointer",fontSize:13,fontWeight:600,color:S===b?l:i.textFaint,borderBottom:`2px solid ${S===b?l:"transparent"}`},children:b==="open"?"Open":"Completed"},b))}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px 24px"},children:[c==="list"&&e.jsx(A,{tab:S,onSelect:I,accent:l,p:i}),c==="detail"&&y&&e.jsx(N,{feedbackId:y,accent:l,p:i,font:h}),c==="create"&&e.jsx(O,{accent:l,p:i,font:h,onDone:()=>x("list")})]}),m&&e.jsxs("a",{href:"https://upstep.dev",target:"_blank",rel:"noopener noreferrer",style:{display:"block",textAlign:"center",padding:"8px 0",borderTop:`1px solid ${i.border}`,fontSize:11,color:i.textFaint,textDecoration:"none",flexShrink:0},children:["Powered by ",e.jsx("strong",{style:{fontWeight:700},children:"Upstep.dev"})]})]})})]})}function A({tab:o,onSelect:t,accent:n,p:a}){const{feedItems:p}=v(),{vote:l}=v(),i=o==="done"?p.filter(s=>s.status==="DONE"):p.filter(s=>s.status!=="DONE"&&s.status!=="CLOSED");return i.length?e.jsx(e.Fragment,{children:i.map(s=>{const g=s.userVote==="UP",d=s.title??s.content;return e.jsxs("div",{onClick:()=>t(s.id),style:{display:"flex",gap:12,padding:14,border:`1px solid ${a.border}`,borderRadius:14,marginBottom:10,background:a.bg,cursor:"pointer"},children:[e.jsxs("button",{onClick:m=>{m.stopPropagation(),l(s.id,"UP")},style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,minWidth:46,padding:"7px 0",borderRadius:11,cursor:"pointer",flexShrink:0,border:`1px solid ${g?n:a.border}`,background:g?`${n}1a`:a.bgSoft},children:[e.jsx(W,{color:n}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:a.text,lineHeight:1.1},children:s.upvotes})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:13.5,fontWeight:600,lineHeight:1.4,color:a.text,margin:"0 0 6px",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:d}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx(F,{type:s.type,p:a}),s.status==="PENDING"?e.jsx(B,{}):e.jsx(z,{status:s.status,p:a}),e.jsx("span",{style:{fontSize:11,color:a.textFaint},children:E(s.createdAt)})]})]}),e.jsx("span",{style:{color:a.textFaint,fontSize:18,alignSelf:"center",flexShrink:0},children:"›"})]},s.id)})}):e.jsxs("div",{style:{textAlign:"center",padding:"40px 0"},children:[e.jsx("div",{style:{color:a.textSoft,fontSize:15,fontWeight:600,marginBottom:4},children:o==="done"?"Nothing completed yet":"No open feedback yet"}),e.jsx("div",{style:{color:a.textFaint,fontSize:14},children:o==="done"?"Shipped items will appear here.":"Be the first to share one."})]})}function N({feedbackId:o,accent:t,p:n,font:a}){const{vote:p,getItem:l}=v(),[i,s]=r.useState(null),[g,d]=r.useState(!1);r.useEffect(()=>{let x=!1;return l(o).then(y=>{x||s(y)}).catch(()=>{}),()=>{x=!0}},[o,l]);async function m(){if(!(!i||g)){d(!0);try{await p(i.id,"UP");const x=await l(o);s(x)}finally{d(!1)}}}if(!i)return e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:n.textFaint,fontSize:14},children:"Loading…"});const c=i.title;return e.jsxs("div",{children:[c&&e.jsx("div",{style:{fontSize:20,fontWeight:700,color:n.text,letterSpacing:"-.02em",marginBottom:10,lineHeight:1.3},children:c}),e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:14,flexWrap:"wrap"},children:[e.jsx(F,{type:i.type,p:n}),i.status==="PENDING"?e.jsx(B,{}):e.jsx(z,{status:i.status,p:n})]}),e.jsx("p",{style:{fontSize:15,lineHeight:1.6,color:n.textSoft,marginBottom:20},children:i.content}),e.jsxs("button",{onClick:m,disabled:g,style:{display:"inline-flex",alignItems:"center",gap:8,border:`1px solid ${i.userVote==="UP"?t:n.border}`,background:i.userVote==="UP"?`${t}15`:n.bgSoft,borderRadius:12,padding:"10px 16px",cursor:"pointer",fontFamily:a},children:[e.jsx(W,{color:t,size:13}),e.jsx("span",{style:{fontSize:18,fontWeight:700,color:n.text},children:i.upvotes}),e.jsx("span",{style:{fontSize:13,color:n.textFaint},children:i.userVote==="UP"?"Upvoted":"Upvote"})]}),i.comments.length>0&&e.jsxs("div",{style:{marginTop:28,borderTop:`1px solid ${n.border}`,paddingTop:20},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:12,textTransform:"uppercase"},children:"Developer response"}),i.comments.map(x=>e.jsx($,{comment:x,p:n,accent:t},x.id))]})]})}function $({comment:o,p:t,accent:n}){return e.jsxs("div",{style:{background:t.bgSoft,border:`1px solid ${t.border}`,borderRadius:12,padding:14,marginBottom:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("span",{style:{background:`${n}20`,color:n,fontSize:11,fontWeight:700,borderRadius:20,padding:"2px 8px"},children:"Developer"}),e.jsx("span",{style:{fontSize:11,color:t.textFaint},children:E(o.createdAt)})]}),e.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:t.textSoft,margin:0},children:o.content})]})}function O({accent:o,p:t,font:n,onDone:a}){const{submit:p}=v(),[l,i]=r.useState(""),[s,g]=r.useState(""),[d,m]=r.useState("GENERAL"),[c,x]=r.useState(!1),[y,k]=r.useState(!1),[S,f]=r.useState("");async function j(){if(!(!l.trim()||c)){x(!0),f("");try{await p(l.trim(),s.trim()||l.trim(),d),k(!0),setTimeout(a,1200)}catch{f("Something went wrong. Please try again.")}finally{x(!1)}}}if(y)return e.jsxs("div",{style:{textAlign:"center",paddingTop:40},children:[e.jsx("div",{style:{fontSize:18,fontWeight:700,color:t.text,marginBottom:6},children:"Submitted"}),e.jsx("div",{style:{fontSize:14,color:t.textFaint},children:"Feedback received. Thank you."})]});const h={width:"100%",border:`1px solid ${t.border}`,borderRadius:12,padding:"10px 12px",fontSize:14,lineHeight:1.5,outline:"none",background:t.bgSoft,color:t.text,fontFamily:n,boxSizing:"border-box"};return e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:t.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Type"}),e.jsx("div",{style:{display:"flex",gap:7,marginBottom:16},children:["BUG","FEATURE","GENERAL"].map(u=>e.jsxs("button",{onClick:()=>m(u),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"8px 10px",borderRadius:9,fontSize:12.5,fontWeight:600,cursor:"pointer",background:d===u?o:t.bg,color:d===u?"#fff":t.textSoft,border:`1px solid ${d===u?o:t.border}`,fontFamily:n},children:[w[u].icon,w[u].label]},u))}),e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:t.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Title"}),e.jsx("input",{value:l,onChange:u=>i(u.target.value),placeholder:"Short summary of the issue or idea",maxLength:200,style:{...h,marginBottom:16,display:"block"}}),e.jsxs("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:t.textFaint,marginBottom:8,textTransform:"uppercase"},children:["Description ",e.jsx("span",{style:{fontWeight:400,textTransform:"none",letterSpacing:0},children:"(optional)"})]}),e.jsx("textarea",{value:s,onChange:u=>g(u.target.value),placeholder:"Steps to reproduce, expected behaviour, or more context",maxLength:2e3,rows:4,style:{...h,resize:"vertical",marginBottom:16}}),S&&e.jsx("p",{style:{fontSize:13,color:"#d6453d",marginBottom:12},children:S}),e.jsx("button",{onClick:j,disabled:c||!l.trim(),style:{width:"100%",padding:12,background:o,color:"#fff",border:"none",borderRadius:11,fontSize:14,fontWeight:600,cursor:"pointer",opacity:c||!l.trim()?.5:1,fontFamily:n},children:c?"Submitting…":"Submit feedback"})]})}const w={BUG:{label:"Bug",icon:e.jsxs("svg",{width:12,height:12,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("ellipse",{cx:"8",cy:"10",rx:"3.5",ry:"4.5"}),e.jsx("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"})]})},FEATURE:{label:"Feature",icon:e.jsxs("svg",{width:12,height:12,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("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"}),e.jsx("circle",{cx:"8",cy:"8",r:"2.5"})]})},GENERAL:{label:"General",icon:e.jsx("svg",{width:12,height:12,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"})})}},G={BUG:"#fdecec",FEATURE:"#e9f0fd"},H={BUG:"#d6453d",FEATURE:"#3b76d6"};function F({type:o,p:t}){return e.jsx("span",{style:{padding:"2px 8px",borderRadius:9999,fontSize:10.5,fontWeight:700,letterSpacing:".02em",background:G[o]??t.bgSoft,color:H[o]??t.textSoft},children:o})}const V={OPEN:"#b45309",IN_PROGRESS:"#1d4ed8",DONE:"#15803d",CLOSED:"#6b7280"};function B(){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:6,padding:"1px 6px",fontSize:10,fontWeight:700,color:"#ea580c"},children:[e.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"#ea580c",display:"inline-block"}}),"Pending review"]})}function z({status:o,p:t}){const n=V[o]??"#9ca3af";return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,background:t.bgSoft,border:`1px solid ${t.border}`,borderRadius:6,padding:"2px 8px",fontSize:10,fontWeight:600,color:t.textSoft},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:n,display:"inline-block",flexShrink:0}}),o.replace("_"," ")]})}function _({size:o=16,color:t="currentColor"}){return e.jsx("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:t,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"})})}function W({color:o="currentColor",size:t=11}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",stroke:o,strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M8 13V3M3 8l5-5 5 5"})})}function E(o){return new Date(o).toLocaleDateString(void 0,{month:"short",day:"numeric"})}exports.FeedbackWidget=P;exports.UpstepProvider=M;exports.useUpstep=v;
package/dist/react.d.ts CHANGED
@@ -1,41 +1,30 @@
1
1
  import { default as React, ReactNode } from 'react';
2
- import { Feedback, FeedbackType, UpstepConfig } from '@upstep/types';
2
+ import { Feedback, FeedbackType, FeedbackWithComments, UpstepConfig } from '@upstep/types';
3
3
  import { UpstepApiClient } from './api';
4
4
  type ThemeMode = "light" | "dark" | "auto";
5
5
  interface UpstepContextValue {
6
6
  client: UpstepApiClient;
7
7
  feedItems: Feedback[];
8
8
  loadFeed: () => Promise<void>;
9
- submit: (content: string, type?: FeedbackType) => Promise<void>;
9
+ submit: (title: string, content: string, type?: FeedbackType) => Promise<void>;
10
10
  vote: (feedbackId: string, value: "UP" | "DOWN") => Promise<void>;
11
- /** Whether the feedback modal is currently open. */
11
+ getItem: (feedbackId: string) => Promise<FeedbackWithComments>;
12
12
  isOpen: boolean;
13
- /** Open the feedback modal — call from your own UI (settings, menu, etc.). */
14
13
  open: () => void;
15
- /** Close the feedback modal. */
16
14
  close: () => void;
17
- /** Set / update the end-user id at runtime (e.g. after the user logs in). */
18
15
  identify: (userId: string | undefined) => void;
19
- /** Accent color from provider config (default applied). */
20
16
  accentColor: string;
21
- /** Theme mode from provider config (default "auto"). */
22
17
  theme: ThemeMode;
18
+ showBranding: boolean;
23
19
  }
24
20
  export declare function UpstepProvider({ children, ...config }: UpstepConfig & {
25
21
  children: ReactNode;
26
22
  }): React.JSX.Element;
27
23
  export declare function useUpstep(): UpstepContextValue;
28
24
  interface FeedbackWidgetProps {
29
- /** Position of the trigger button */
30
25
  position?: "bottom-right" | "bottom-left";
31
- /** Accent color. Defaults to the provider's accentColor (or "#D97757"). */
32
26
  accentColor?: string;
33
- /** Theme. Defaults to the provider's theme (or "auto"). */
34
27
  theme?: ThemeMode;
35
- /**
36
- * Hide the floating launcher button and only show the modal when opened
37
- * programmatically via `useUpstep().open()` — e.g. from a settings menu.
38
- */
39
28
  hideLauncher?: boolean;
40
29
  }
41
30
  export declare function FeedbackWidget({ position, accentColor, theme, hideLauncher, }: FeedbackWidgetProps): React.JSX.Element;
@@ -1 +1 @@
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"}
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,EAAW,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzG,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,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/E,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC/D,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;CACvB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,qBAqDxC;AAED,wBAAgB,SAAS,IAAI,kBAAkB,CAI9C;AAID,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAyB,EACzB,WAAW,EACX,KAAK,EACL,YAAoB,GACrB,EAAE,mBAAmB,qBA6JrB"}
package/dist/react.js CHANGED
@@ -1,7 +1,7 @@
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-CRsXibfd.mjs";
4
- const D = "#D97757", H = {
1
+ import { jsxs as r, Fragment as W, jsx as e } from "react/jsx-runtime";
2
+ import { createContext as M, useState as u, useEffect as C, useCallback as w, useContext as P } from "react";
3
+ import { U as A } from "./api-CMuwaAet.mjs";
4
+ const N = "#D97757", $ = {
5
5
  bg: "#ffffff",
6
6
  bgSoft: "#f6f5f2",
7
7
  bgHover: "#efede8",
@@ -10,7 +10,7 @@ const D = "#D97757", H = {
10
10
  textFaint: "#9b9890",
11
11
  border: "#e8e6df",
12
12
  overlay: "rgba(26,25,21,.45)"
13
- }, j = {
13
+ }, G = {
14
14
  bg: "#1c1b19",
15
15
  bgSoft: "#262522",
16
16
  bgHover: "#302e2a",
@@ -20,101 +20,96 @@ const D = "#D97757", H = {
20
20
  border: "#33312c",
21
21
  overlay: "rgba(0,0,0,.6)"
22
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");
23
+ function H(n) {
24
+ const [t, o] = u(() => n === "dark" ? !0 : n === "light" ? !1 : typeof window < "u" && window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)").matches : !1);
25
+ return C(() => {
26
+ if (n !== "auto" || typeof window > "u" || !window.matchMedia) {
27
+ o(n === "dark");
28
28
  return;
29
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;
30
+ const s = window.matchMedia("(prefers-color-scheme: dark)"), h = (d) => o(d.matches);
31
+ return o(s.matches), s.addEventListener("change", h), () => s.removeEventListener("change", h);
32
+ }, [n]), t ? G : $;
33
33
  }
34
- const A = G(null);
35
- function J({
36
- children: d,
37
- ...l
34
+ const I = M(null);
35
+ function ee({
36
+ children: n,
37
+ ...t
38
38
  }) {
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]);
39
+ const [o] = u(() => new A(t)), [s, h] = u([]), [d, i] = u(!1), [l, x] = u(!0);
40
+ C(() => {
41
+ o.setUserId(t.userId);
42
+ }, [o, t.userId]);
43
+ const a = w(async () => {
44
+ const g = await o.listFeedback({ sort: "votes", limit: 20 });
45
+ h(g.items), x(g.showBranding ?? !0);
46
+ }, [o]);
47
+ C(() => {
48
+ a();
49
+ }, [a]);
50
+ const y = w(async (g, v, b) => {
51
+ const p = { content: v };
52
+ g.trim() && (p.title = g.trim()), b !== void 0 && (p.type = b), await o.submitFeedback(p), await a();
53
+ }, [o, a]), c = w(async (g, v) => {
54
+ await o.vote(g, v), await a();
55
+ }, [o, a]), f = w(
56
+ (g) => o.getItem(g),
57
+ [o]
58
+ ), S = w(() => i(!0), []), F = w(() => i(!1), []), k = w((g) => o.setUserId(g), [o]);
56
59
  return /* @__PURE__ */ e(
57
- A.Provider,
60
+ I.Provider,
58
61
  {
59
62
  value: {
60
- client: t,
61
- feedItems: n,
62
- loadFeed: f,
63
+ client: o,
64
+ feedItems: s,
65
+ loadFeed: a,
63
66
  submit: y,
64
- vote: v,
65
- isOpen: a,
67
+ vote: c,
68
+ getItem: f,
69
+ isOpen: d,
66
70
  open: S,
67
- close: k,
68
- identify: h,
69
- accentColor: l.accentColor ?? D,
70
- theme: l.theme ?? "auto"
71
+ close: F,
72
+ identify: k,
73
+ accentColor: t.accentColor ?? N,
74
+ theme: t.theme ?? "auto",
75
+ showBranding: l
71
76
  },
72
- children: d
77
+ children: n
73
78
  }
74
79
  );
75
80
  }
76
- function N() {
77
- const d = T(A);
78
- if (!d) throw new Error("useUpstep must be used inside <UpstepProvider>");
79
- return d;
81
+ function B() {
82
+ const n = P(I);
83
+ if (!n) throw new Error("useUpstep must be used inside <UpstepProvider>");
84
+ return n;
80
85
  }
81
- const P = {
82
- BUG: "🐞 Bug",
83
- FEATURE: "✨ Feature",
84
- GENERAL: "💬 General"
85
- };
86
- function Q({
87
- position: d = "bottom-right",
88
- accentColor: l,
89
- theme: t,
90
- hideLauncher: n = !1
86
+ function te({
87
+ position: n = "bottom-right",
88
+ accentColor: t,
89
+ theme: o,
90
+ hideLauncher: s = !1
91
91
  }) {
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);
96
- try {
97
- await y(g.trim(), x), C(""), R("Thanks — we got your feedback! 🎉");
98
- } catch {
99
- R("Something went wrong.");
100
- } finally {
101
- U(!1);
102
- }
103
- }
92
+ const h = B(), d = t ?? h.accentColor, i = H(o ?? h.theme), { isOpen: l, open: x, close: a, showBranding: y } = h, [c, f] = u("list"), [S, F] = u(null), [k, g] = u("open"), v = n === "bottom-left" ? { position: "fixed", bottom: 24, left: 24 } : { position: "fixed", bottom: 24, right: 24 }, b = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';
93
+ function p() {
94
+ a(), setTimeout(() => {
95
+ f("list"), F(null);
96
+ }, 300);
97
+ }
98
+ function D(m) {
99
+ F(m), f("detail");
104
100
  }
105
- const w = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';
106
- return /* @__PURE__ */ c(z, { children: [
107
- !n && /* @__PURE__ */ c(
101
+ return /* @__PURE__ */ r(W, { children: [
102
+ !s && /* @__PURE__ */ r(
108
103
  "button",
109
104
  {
110
- onClick: k,
105
+ onClick: x,
111
106
  style: {
112
- ...L,
107
+ ...v,
113
108
  zIndex: 9998,
114
109
  display: "inline-flex",
115
110
  alignItems: "center",
116
111
  gap: 7,
117
- background: a,
112
+ background: d,
118
113
  color: "#fff",
119
114
  border: "none",
120
115
  borderRadius: 9999,
@@ -122,37 +117,37 @@ function Q({
122
117
  fontSize: 14,
123
118
  fontWeight: 600,
124
119
  cursor: "pointer",
125
- fontFamily: w,
120
+ fontFamily: b,
126
121
  boxShadow: "0 6px 20px rgba(26,25,21,.18)"
127
122
  },
128
123
  children: [
129
- /* @__PURE__ */ e($, {}),
124
+ /* @__PURE__ */ e(J, { size: 16 }),
130
125
  " Feedback"
131
126
  ]
132
127
  }
133
128
  ),
134
- S && /* @__PURE__ */ e(
129
+ l && /* @__PURE__ */ e(
135
130
  "div",
136
131
  {
137
- onClick: (r) => r.target === r.currentTarget && h(),
132
+ onClick: (m) => m.target === m.currentTarget && p(),
138
133
  style: {
139
134
  position: "fixed",
140
135
  inset: 0,
141
- background: o.overlay,
136
+ background: i.overlay,
142
137
  backdropFilter: "blur(3px)",
143
138
  zIndex: 9999,
144
139
  display: "flex",
145
140
  alignItems: "center",
146
141
  justifyContent: "center",
147
142
  padding: 16,
148
- fontFamily: w
143
+ fontFamily: b
149
144
  },
150
- children: /* @__PURE__ */ c(
145
+ children: /* @__PURE__ */ r(
151
146
  "div",
152
147
  {
153
148
  style: {
154
- background: o.bg,
155
- border: `1px solid ${o.border}`,
149
+ background: i.bg,
150
+ border: `1px solid ${i.border}`,
156
151
  borderRadius: 20,
157
152
  width: "100%",
158
153
  maxWidth: 440,
@@ -163,106 +158,100 @@ function Q({
163
158
  boxShadow: "0 24px 64px rgba(0,0,0,.28)"
164
159
  },
165
160
  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." })
161
+ /* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "16px 20px", borderBottom: `1px solid ${i.border}`, flexShrink: 0 }, children: [
162
+ /* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
163
+ c !== "list" && /* @__PURE__ */ e(
164
+ "button",
165
+ {
166
+ onClick: () => f("list"),
167
+ style: { background: "none", border: "none", cursor: "pointer", color: d, fontSize: 13, fontWeight: 600, padding: 0 },
168
+ children: "← Back"
169
+ }
170
+ ),
171
+ c === "list" && /* @__PURE__ */ e("span", { style: { fontWeight: 700, fontSize: 16, color: i.text, letterSpacing: "-.01em" }, children: "Feedback" }),
172
+ c === "create" && /* @__PURE__ */ e("span", { style: { fontWeight: 700, fontSize: 16, color: i.text, letterSpacing: "-.01em" }, children: "New feedback" })
170
173
  ] }),
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
- )
174
+ /* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
175
+ c === "list" && /* @__PURE__ */ e(
176
+ "button",
177
+ {
178
+ onClick: () => f("create"),
179
+ style: { background: d, color: "#fff", border: "none", borderRadius: 20, padding: "6px 14px", fontSize: 13, fontWeight: 700, cursor: "pointer" },
180
+ children: "+ New"
181
+ }
182
+ ),
183
+ /* @__PURE__ */ e(
184
+ "button",
185
+ {
186
+ onClick: p,
187
+ style: { background: i.bgSoft, border: "none", width: 28, height: 28, borderRadius: 8, fontSize: 14, cursor: "pointer", color: i.textSoft, display: "flex", alignItems: "center", justifyContent: "center" },
188
+ children: "✕"
189
+ }
190
+ )
191
+ ] })
179
192
  ] }),
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(
193
+ c === "list" && /* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${i.border}`, flexShrink: 0 }, children: ["open", "done"].map((m) => /* @__PURE__ */ e(
181
194
  "button",
182
195
  {
183
- onClick: () => u(r),
196
+ onClick: () => g(m),
184
197
  style: {
185
198
  flex: 1,
186
- padding: 8,
199
+ padding: "10px 0",
187
200
  border: "none",
188
- borderRadius: 8,
201
+ background: "none",
202
+ cursor: "pointer",
189
203
  fontSize: 13,
190
204
  fontWeight: 600,
191
- cursor: "pointer",
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"
205
+ color: k === m ? d : i.textFaint,
206
+ borderBottom: `2px solid ${k === m ? d : "transparent"}`
195
207
  },
196
- children: r === "submit" ? "Give feedback" : "Vote on ideas"
208
+ children: m === "open" ? "Open" : "Completed"
197
209
  },
198
- r
210
+ m
199
211
  )) }),
200
- /* @__PURE__ */ e("div", { style: { flex: 1, overflowY: "auto", padding: "18px 20px 22px" }, children: s === "submit" ? /* @__PURE__ */ c("div", { children: [
201
- /* @__PURE__ */ e(
202
- "textarea",
212
+ /* @__PURE__ */ r("div", { style: { flex: 1, overflowY: "auto", padding: "16px 20px 24px" }, children: [
213
+ c === "list" && /* @__PURE__ */ e(
214
+ O,
203
215
  {
204
- value: g,
205
- onChange: (r) => C(r.target.value),
206
- placeholder: "What's on your mind?",
207
- maxLength: 2e3,
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
- }
216
+ tab: k,
217
+ onSelect: D,
218
+ accent: d,
219
+ p: i
222
220
  }
223
221
  ),
224
- /* @__PURE__ */ e("div", { style: { display: "flex", gap: 7, margin: "12px 0 4px" }, children: ["BUG", "FEATURE", "GENERAL"].map((r) => /* @__PURE__ */ e(
225
- "button",
222
+ c === "detail" && S && /* @__PURE__ */ e(j, { feedbackId: S, accent: d, p: i, font: b }),
223
+ c === "create" && /* @__PURE__ */ e(
224
+ _,
226
225
  {
227
- onClick: () => I(r),
228
- style: {
229
- flex: 1,
230
- padding: "8px 10px",
231
- borderRadius: 9,
232
- fontSize: 12.5,
233
- fontWeight: 600,
234
- cursor: "pointer",
235
- background: x === r ? a : o.bg,
236
- color: x === r ? "#fff" : o.textSoft,
237
- border: `1px solid ${x === r ? a : o.border}`
238
- },
239
- children: P[r]
240
- },
241
- r
242
- )) }),
243
- /* @__PURE__ */ e(
244
- "button",
245
- {
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"
226
+ accent: d,
227
+ p: i,
228
+ font: b,
229
+ onDone: () => f("list")
262
230
  }
263
- ),
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 }) })
231
+ )
232
+ ] }),
233
+ y && /* @__PURE__ */ r(
234
+ "a",
235
+ {
236
+ href: "https://upstep.dev",
237
+ target: "_blank",
238
+ rel: "noopener noreferrer",
239
+ style: {
240
+ display: "block",
241
+ textAlign: "center",
242
+ padding: "8px 0",
243
+ borderTop: `1px solid ${i.border}`,
244
+ fontSize: 11,
245
+ color: i.textFaint,
246
+ textDecoration: "none",
247
+ flexShrink: 0
248
+ },
249
+ children: [
250
+ "Powered by ",
251
+ /* @__PURE__ */ e("strong", { style: { fontWeight: 700 }, children: "Upstep.dev" })
252
+ ]
253
+ }
254
+ )
266
255
  ]
267
256
  }
268
257
  )
@@ -270,65 +259,317 @@ function Q({
270
259
  )
271
260
  ] });
272
261
  }
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
262
  function O({
278
- items: d,
279
- onVote: l,
280
- accent: t,
281
- p: n
263
+ tab: n,
264
+ onSelect: t,
265
+ accent: o,
266
+ p: s
282
267
  }) {
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." })
268
+ const { feedItems: h } = B(), { vote: d } = B(), i = n === "done" ? h.filter((l) => l.status === "DONE") : h.filter((l) => l.status !== "DONE" && l.status !== "CLOSED");
269
+ return i.length ? /* @__PURE__ */ e(W, { children: i.map((l) => {
270
+ const x = l.userVote === "UP", a = l.title ?? l.content;
271
+ return /* @__PURE__ */ r(
272
+ "div",
273
+ {
274
+ onClick: () => t(l.id),
275
+ style: {
276
+ display: "flex",
277
+ gap: 12,
278
+ padding: 14,
279
+ border: `1px solid ${s.border}`,
280
+ borderRadius: 14,
281
+ marginBottom: 10,
282
+ background: s.bg,
283
+ cursor: "pointer"
284
+ },
285
+ children: [
286
+ /* @__PURE__ */ r(
287
+ "button",
288
+ {
289
+ onClick: (y) => {
290
+ y.stopPropagation(), d(l.id, "UP");
291
+ },
292
+ style: {
293
+ display: "flex",
294
+ flexDirection: "column",
295
+ alignItems: "center",
296
+ justifyContent: "center",
297
+ gap: 2,
298
+ minWidth: 46,
299
+ padding: "7px 0",
300
+ borderRadius: 11,
301
+ cursor: "pointer",
302
+ flexShrink: 0,
303
+ border: `1px solid ${x ? o : s.border}`,
304
+ background: x ? `${o}1a` : s.bgSoft
305
+ },
306
+ children: [
307
+ /* @__PURE__ */ e(R, { color: o }),
308
+ /* @__PURE__ */ e("span", { style: { fontSize: 14, fontWeight: 700, color: s.text, lineHeight: 1.1 }, children: l.upvotes })
309
+ ]
310
+ }
311
+ ),
312
+ /* @__PURE__ */ r("div", { style: { flex: 1, minWidth: 0 }, children: [
313
+ /* @__PURE__ */ e("p", { style: { fontSize: 13.5, fontWeight: 600, lineHeight: 1.4, color: s.text, margin: "0 0 6px", overflow: "hidden", display: "-webkit-box", WebkitLineClamp: 2, WebkitBoxOrient: "vertical" }, children: a }),
314
+ /* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", gap: 6, flexWrap: "wrap" }, children: [
315
+ /* @__PURE__ */ e(T, { type: l.type, p: s }),
316
+ l.status === "PENDING" ? /* @__PURE__ */ e(E, {}) : /* @__PURE__ */ e(U, { status: l.status, p: s }),
317
+ /* @__PURE__ */ e("span", { style: { fontSize: 11, color: s.textFaint }, children: L(l.createdAt) })
318
+ ] })
319
+ ] }),
320
+ /* @__PURE__ */ e("span", { style: { color: s.textFaint, fontSize: 18, alignSelf: "center", flexShrink: 0 }, children: "›" })
321
+ ]
322
+ },
323
+ l.id
324
+ );
325
+ }) }) : /* @__PURE__ */ r("div", { style: { textAlign: "center", padding: "40px 0" }, children: [
326
+ /* @__PURE__ */ e("div", { style: { color: s.textSoft, fontSize: 15, fontWeight: 600, marginBottom: 4 }, children: n === "done" ? "Nothing completed yet" : "No open feedback yet" }),
327
+ /* @__PURE__ */ e("div", { style: { color: s.textFaint, fontSize: 14 }, children: n === "done" ? "Shipped items will appear here." : "Be the first to share one." })
328
+ ] });
329
+ }
330
+ function j({ feedbackId: n, accent: t, p: o, font: s }) {
331
+ const { vote: h, getItem: d } = B(), [i, l] = u(null), [x, a] = u(!1);
332
+ C(() => {
333
+ let f = !1;
334
+ return d(n).then((S) => {
335
+ f || l(S);
336
+ }).catch(() => {
337
+ }), () => {
338
+ f = !0;
339
+ };
340
+ }, [n, d]);
341
+ async function y() {
342
+ if (!(!i || x)) {
343
+ a(!0);
344
+ try {
345
+ await h(i.id, "UP");
346
+ const f = await d(n);
347
+ l(f);
348
+ } finally {
349
+ a(!1);
350
+ }
351
+ }
352
+ }
353
+ if (!i)
354
+ return /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: "40px 0", color: o.textFaint, fontSize: 14 }, children: "Loading…" });
355
+ const c = i.title;
356
+ return /* @__PURE__ */ r("div", { children: [
357
+ c && /* @__PURE__ */ e("div", { style: { fontSize: 20, fontWeight: 700, color: o.text, letterSpacing: "-.02em", marginBottom: 10, lineHeight: 1.3 }, children: c }),
358
+ /* @__PURE__ */ r("div", { style: { display: "flex", gap: 6, marginBottom: 14, flexWrap: "wrap" }, children: [
359
+ /* @__PURE__ */ e(T, { type: i.type, p: o }),
360
+ i.status === "PENDING" ? /* @__PURE__ */ e(E, {}) : /* @__PURE__ */ e(U, { status: i.status, p: o })
361
+ ] }),
362
+ /* @__PURE__ */ e("p", { style: { fontSize: 15, lineHeight: 1.6, color: o.textSoft, marginBottom: 20 }, children: i.content }),
363
+ /* @__PURE__ */ r(
364
+ "button",
365
+ {
366
+ onClick: y,
367
+ disabled: x,
368
+ style: {
369
+ display: "inline-flex",
370
+ alignItems: "center",
371
+ gap: 8,
372
+ border: `1px solid ${i.userVote === "UP" ? t : o.border}`,
373
+ background: i.userVote === "UP" ? `${t}15` : o.bgSoft,
374
+ borderRadius: 12,
375
+ padding: "10px 16px",
376
+ cursor: "pointer",
377
+ fontFamily: s
378
+ },
379
+ children: [
380
+ /* @__PURE__ */ e(R, { color: t, size: 13 }),
381
+ /* @__PURE__ */ e("span", { style: { fontSize: 18, fontWeight: 700, color: o.text }, children: i.upvotes }),
382
+ /* @__PURE__ */ e("span", { style: { fontSize: 13, color: o.textFaint }, children: i.userVote === "UP" ? "Upvoted" : "Upvote" })
383
+ ]
384
+ }
385
+ ),
386
+ i.comments.length > 0 && /* @__PURE__ */ r("div", { style: { marginTop: 28, borderTop: `1px solid ${o.border}`, paddingTop: 20 }, children: [
387
+ /* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: o.textFaint, marginBottom: 12, textTransform: "uppercase" }, children: "Developer response" }),
388
+ i.comments.map((f) => /* @__PURE__ */ e(V, { comment: f, p: o, accent: t }, f.id))
389
+ ] })
390
+ ] });
391
+ }
392
+ function V({ comment: n, p: t, accent: o }) {
393
+ return /* @__PURE__ */ r("div", { style: { background: t.bgSoft, border: `1px solid ${t.border}`, borderRadius: 12, padding: 14, marginBottom: 10 }, children: [
394
+ /* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 8 }, children: [
395
+ /* @__PURE__ */ e("span", { style: { background: `${o}20`, color: o, fontSize: 11, fontWeight: 700, borderRadius: 20, padding: "2px 8px" }, children: "Developer" }),
396
+ /* @__PURE__ */ e("span", { style: { fontSize: 11, color: t.textFaint }, children: L(n.createdAt) })
397
+ ] }),
398
+ /* @__PURE__ */ e("p", { style: { fontSize: 14, lineHeight: 1.5, color: t.textSoft, margin: 0 }, children: n.content })
399
+ ] });
400
+ }
401
+ function _({ accent: n, p: t, font: o, onDone: s }) {
402
+ const { submit: h } = B(), [d, i] = u(""), [l, x] = u(""), [a, y] = u("GENERAL"), [c, f] = u(!1), [S, F] = u(!1), [k, g] = u("");
403
+ async function v() {
404
+ if (!(!d.trim() || c)) {
405
+ f(!0), g("");
406
+ try {
407
+ await h(d.trim(), l.trim() || d.trim(), a), F(!0), setTimeout(s, 1200);
408
+ } catch {
409
+ g("Something went wrong. Please try again.");
410
+ } finally {
411
+ f(!1);
412
+ }
413
+ }
414
+ }
415
+ if (S)
416
+ return /* @__PURE__ */ r("div", { style: { textAlign: "center", paddingTop: 40 }, children: [
417
+ /* @__PURE__ */ e("div", { style: { fontSize: 18, fontWeight: 700, color: t.text, marginBottom: 6 }, children: "Submitted" }),
418
+ /* @__PURE__ */ e("div", { style: { fontSize: 14, color: t.textFaint }, children: "Feedback received. Thank you." })
419
+ ] });
420
+ const b = {
421
+ width: "100%",
422
+ border: `1px solid ${t.border}`,
423
+ borderRadius: 12,
424
+ padding: "10px 12px",
425
+ fontSize: 14,
426
+ lineHeight: 1.5,
427
+ outline: "none",
428
+ background: t.bgSoft,
429
+ color: t.text,
430
+ fontFamily: o,
431
+ boxSizing: "border-box"
432
+ };
433
+ return /* @__PURE__ */ r("div", { children: [
434
+ /* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: t.textFaint, marginBottom: 8, textTransform: "uppercase" }, children: "Type" }),
435
+ /* @__PURE__ */ e("div", { style: { display: "flex", gap: 7, marginBottom: 16 }, children: ["BUG", "FEATURE", "GENERAL"].map((p) => /* @__PURE__ */ r(
436
+ "button",
437
+ {
438
+ onClick: () => y(p),
439
+ style: {
440
+ flex: 1,
441
+ display: "flex",
442
+ alignItems: "center",
443
+ justifyContent: "center",
444
+ gap: 5,
445
+ padding: "8px 10px",
446
+ borderRadius: 9,
447
+ fontSize: 12.5,
448
+ fontWeight: 600,
449
+ cursor: "pointer",
450
+ background: a === p ? n : t.bg,
451
+ color: a === p ? "#fff" : t.textSoft,
452
+ border: `1px solid ${a === p ? n : t.border}`,
453
+ fontFamily: o
454
+ },
455
+ children: [
456
+ z[p].icon,
457
+ z[p].label
458
+ ]
459
+ },
460
+ p
461
+ )) }),
462
+ /* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: t.textFaint, marginBottom: 8, textTransform: "uppercase" }, children: "Title" }),
463
+ /* @__PURE__ */ e(
464
+ "input",
465
+ {
466
+ value: d,
467
+ onChange: (p) => i(p.target.value),
468
+ placeholder: "Short summary of the issue or idea",
469
+ maxLength: 200,
470
+ style: { ...b, marginBottom: 16, display: "block" }
471
+ }
472
+ ),
473
+ /* @__PURE__ */ r("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: t.textFaint, marginBottom: 8, textTransform: "uppercase" }, children: [
474
+ "Description ",
475
+ /* @__PURE__ */ e("span", { style: { fontWeight: 400, textTransform: "none", letterSpacing: 0 }, children: "(optional)" })
476
+ ] }),
477
+ /* @__PURE__ */ e(
478
+ "textarea",
479
+ {
480
+ value: l,
481
+ onChange: (p) => x(p.target.value),
482
+ placeholder: "Steps to reproduce, expected behaviour, or more context",
483
+ maxLength: 2e3,
484
+ rows: 4,
485
+ style: { ...b, resize: "vertical", marginBottom: 16 }
486
+ }
487
+ ),
488
+ k && /* @__PURE__ */ e("p", { style: { fontSize: 13, color: "#d6453d", marginBottom: 12 }, children: k }),
489
+ /* @__PURE__ */ e(
490
+ "button",
491
+ {
492
+ onClick: v,
493
+ disabled: c || !d.trim(),
494
+ style: {
495
+ width: "100%",
496
+ padding: 12,
497
+ background: n,
498
+ color: "#fff",
499
+ border: "none",
500
+ borderRadius: 11,
501
+ fontSize: 14,
502
+ fontWeight: 600,
503
+ cursor: "pointer",
504
+ opacity: c || !d.trim() ? 0.5 : 1,
505
+ fontFamily: o
506
+ },
507
+ children: c ? "Submitting…" : "Submit feedback"
508
+ }
509
+ )
510
+ ] });
511
+ }
512
+ const z = {
513
+ BUG: {
514
+ label: "Bug",
515
+ icon: /* @__PURE__ */ r("svg", { width: 12, height: 12, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", children: [
516
+ /* @__PURE__ */ e("ellipse", { cx: "8", cy: "10", rx: "3.5", ry: "4.5" }),
517
+ /* @__PURE__ */ e("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" })
518
+ ] })
519
+ },
520
+ FEATURE: {
521
+ label: "Feature",
522
+ icon: /* @__PURE__ */ r("svg", { width: 12, height: 12, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", children: [
523
+ /* @__PURE__ */ e("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" }),
524
+ /* @__PURE__ */ e("circle", { cx: "8", cy: "8", r: "2.5" })
525
+ ] })
526
+ },
527
+ GENERAL: {
528
+ label: "General",
529
+ icon: /* @__PURE__ */ e("svg", { width: 12, height: 12, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z" }) })
530
+ }
531
+ }, Y = { BUG: "#fdecec", FEATURE: "#e9f0fd" }, q = { BUG: "#d6453d", FEATURE: "#3b76d6" };
532
+ function T({ type: n, p: t }) {
533
+ return /* @__PURE__ */ e("span", { style: {
534
+ padding: "2px 8px",
535
+ borderRadius: 9999,
536
+ fontSize: 10.5,
537
+ fontWeight: 700,
538
+ letterSpacing: ".02em",
539
+ background: Y[n] ?? t.bgSoft,
540
+ color: q[n] ?? t.textSoft
541
+ }, children: n });
542
+ }
543
+ const K = {
544
+ OPEN: "#b45309",
545
+ IN_PROGRESS: "#1d4ed8",
546
+ DONE: "#15803d",
547
+ CLOSED: "#6b7280"
548
+ };
549
+ function E() {
550
+ return /* @__PURE__ */ r("span", { style: { display: "inline-flex", alignItems: "center", gap: 4, background: "#fff7ed", border: "1px solid #fed7aa", borderRadius: 6, padding: "1px 6px", fontSize: 10, fontWeight: 700, color: "#ea580c" }, children: [
551
+ /* @__PURE__ */ e("span", { style: { width: 5, height: 5, borderRadius: "50%", background: "#ea580c", display: "inline-block" } }),
552
+ "Pending review"
553
+ ] });
554
+ }
555
+ function U({ status: n, p: t }) {
556
+ const o = K[n] ?? "#9ca3af";
557
+ return /* @__PURE__ */ r("span", { style: { display: "inline-flex", alignItems: "center", gap: 5, background: t.bgSoft, border: `1px solid ${t.border}`, borderRadius: 6, padding: "2px 8px", fontSize: 10, fontWeight: 600, color: t.textSoft }, children: [
558
+ /* @__PURE__ */ e("span", { style: { width: 6, height: 6, borderRadius: "50%", background: o, display: "inline-block", flexShrink: 0 } }),
559
+ n.replace("_", " ")
328
560
  ] });
329
561
  }
562
+ function J({ size: n = 16, color: t = "currentColor" }) {
563
+ return /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "none", stroke: t, 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" }) });
564
+ }
565
+ function R({ color: n = "currentColor", size: t = 11 }) {
566
+ return /* @__PURE__ */ e("svg", { width: t, height: t, viewBox: "0 0 16 16", fill: "none", stroke: n, strokeWidth: 2.2, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M8 13V3M3 8l5-5 5 5" }) });
567
+ }
568
+ function L(n) {
569
+ return new Date(n).toLocaleDateString(void 0, { month: "short", day: "numeric" });
570
+ }
330
571
  export {
331
- Q as FeedbackWidget,
332
- J as UpstepProvider,
333
- N as useUpstep
572
+ te as FeedbackWidget,
573
+ ee as UpstepProvider,
574
+ B as useUpstep
334
575
  };
@@ -1 +1 @@
1
- {"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAIxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;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"}
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;AAsG3C,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;IAoBxB,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.5.0",
3
+ "version": "0.5.2",
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.5.0"
24
+ "@upstep/types": "0.5.1"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "react": ">=18",