@upstep/js 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +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 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;
@@ -14,7 +14,7 @@ class r {
14
14
  }
15
15
  async listFeedback(e) {
16
16
  const t = new URLSearchParams();
17
- 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);
17
+ 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);
18
18
  const s = await fetch(`${this.baseUrl}/api/sdk/feedback?${t}`, {
19
19
  headers: this.headers()
20
20
  });
@@ -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;IAe3B,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-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`
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-q50Qqen1.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-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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),I=require("./api-Bzvimzou.js"),T="#D97757",R={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},U={bg:"#1c1b19",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function L(o){const[t,n]=s.useState(()=>o==="dark"?!0:o==="light"?!1:typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1);return s.useEffect(()=>{if(o!=="auto"||typeof window>"u"||!window.matchMedia){n(o==="dark");return}const a=window.matchMedia("(prefers-color-scheme: dark)"),x=l=>n(l.matches);return n(a.matches),a.addEventListener("change",x),()=>a.removeEventListener("change",x)},[o]),t?U:R}const C=s.createContext(null);function D({children:o,...t}){const[n]=s.useState(()=>new I.UpstepApiClient(t)),[a,x]=s.useState([]),[l,i]=s.useState(!1);s.useEffect(()=>{n.setUserId(t.userId)},[n,t.userId]);const r=s.useCallback(async()=>{const c=await n.listFeedback({sort:"votes",limit:20});x(c.items)},[n]);s.useEffect(()=>{r()},[r]);const h=s.useCallback(async(c,S,j)=>{const b={content:S};c.trim()&&(b.title=c.trim()),j!==void 0&&(b.type=j),await n.submitFeedback(b),await r()},[n,r]),p=s.useCallback(async(c,S)=>{await n.vote(c,S),await r()},[n,r]),d=s.useCallback(c=>n.getItem(c),[n]),u=s.useCallback(()=>i(!0),[]),f=s.useCallback(()=>i(!1),[]),y=s.useCallback(c=>n.setUserId(c),[n]);return e.jsx(C.Provider,{value:{client:n,feedItems:a,loadFeed:r,submit:h,vote:p,getItem:d,isOpen:l,open:u,close:f,identify:y,accentColor:t.accentColor??T,theme:t.theme??"auto"},children:o})}function k(){const o=s.useContext(C);if(!o)throw new Error("useUpstep must be used inside <UpstepProvider>");return o}function M({position:o="bottom-right",accentColor:t,theme:n,hideLauncher:a=!1}){const x=k(),l=t??x.accentColor,i=L(n??x.theme),{isOpen:r,open:h,close:p}=x,[d,u]=s.useState("list"),[f,y]=s.useState(null),[c,S]=s.useState("open"),j=o==="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';function v(){p(),setTimeout(()=>{u("list"),y(null)},300)}function g(m){y(m),u("detail")}return e.jsxs(e.Fragment,{children:[!a&&e.jsxs("button",{onClick:h,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:b,boxShadow:"0 6px 20px rgba(26,25,21,.18)"},children:[e.jsx(V,{size:16})," Feedback"]}),r&&e.jsx("div",{onClick:m=>m.target===m.currentTarget&&v(),style:{position:"fixed",inset:0,background:i.overlay,backdropFilter:"blur(3px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:16,fontFamily:b},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:[d!=="list"&&e.jsx("button",{onClick:()=>u("list"),style:{background:"none",border:"none",cursor:"pointer",color:l,fontSize:13,fontWeight:600,padding:0},children:"← Back"}),d==="list"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:i.text,letterSpacing:"-.01em"},children:"Feedback"}),d==="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:[d==="list"&&e.jsx("button",{onClick:()=>u("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:v,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:"✕"})]})]}),d==="list"&&e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${i.border}`,flexShrink:0},children:["open","done"].map(m=>e.jsx("button",{onClick:()=>S(m),style:{flex:1,padding:"10px 0",border:"none",background:"none",cursor:"pointer",fontSize:13,fontWeight:600,color:c===m?l:i.textFaint,borderBottom:`2px solid ${c===m?l:"transparent"}`},children:m==="open"?"Open":"Completed"},m))}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px 24px"},children:[d==="list"&&e.jsx(P,{tab:c,onSelect:g,accent:l,p:i}),d==="detail"&&f&&e.jsx(A,{feedbackId:f,accent:l,p:i,font:b}),d==="create"&&e.jsx(O,{accent:l,p:i,font:b,onDone:()=>u("list")})]})]})})]})}function P({tab:o,onSelect:t,accent:n,p:a}){const{feedItems:x}=k(),{vote:l}=k(),i=o==="done"?x.filter(r=>r.status==="DONE"):x.filter(r=>r.status!=="DONE"&&r.status!=="CLOSED");return i.length?e.jsx(e.Fragment,{children:i.map(r=>{const h=r.userVote==="UP",p=r.title??r.content;return e.jsxs("div",{onClick:()=>t(r.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:d=>{d.stopPropagation(),l(r.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 ${h?n:a.border}`,background:h?`${n}1a`:a.bgSoft},children:[e.jsx(B,{color:n}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:a.text,lineHeight:1.1},children:r.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:p}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx(F,{type:r.type,p:a}),r.status==="PENDING"?e.jsx(z,{}):e.jsx(W,{status:r.status,p:a}),e.jsx("span",{style:{fontSize:11,color:a.textFaint},children:E(r.createdAt)})]})]}),e.jsx("span",{style:{color:a.textFaint,fontSize:18,alignSelf:"center",flexShrink:0},children:"›"})]},r.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 A({feedbackId:o,accent:t,p:n,font:a}){const{vote:x,getItem:l}=k(),[i,r]=s.useState(null),[h,p]=s.useState(!1);s.useEffect(()=>{let f=!1;return l(o).then(y=>{f||r(y)}).catch(()=>{}),()=>{f=!0}},[o,l]);async function d(){if(!(!i||h)){p(!0);try{await x(i.id,"UP");const f=await l(o);r(f)}finally{p(!1)}}}if(!i)return e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:n.textFaint,fontSize:14},children:"Loading…"});const u=i.title;return e.jsxs("div",{children:[u&&e.jsx("div",{style:{fontSize:20,fontWeight:700,color:n.text,letterSpacing:"-.02em",marginBottom:10,lineHeight:1.3},children:u}),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(z,{}):e.jsx(W,{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:d,disabled:h,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(B,{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(f=>e.jsx(N,{comment:f,p:n,accent:t},f.id))]})]})}function N({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:x}=k(),[l,i]=s.useState(""),[r,h]=s.useState(""),[p,d]=s.useState("GENERAL"),[u,f]=s.useState(!1),[y,c]=s.useState(!1),[S,j]=s.useState("");async function b(){if(!(!l.trim()||u)){f(!0),j("");try{await x(l.trim(),r.trim()||l.trim(),p),c(!0),setTimeout(a,1200)}catch{j("Something went wrong. Please try again.")}finally{f(!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 v={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(g=>e.jsxs("button",{onClick:()=>d(g),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"8px 10px",borderRadius:9,fontSize:12.5,fontWeight:600,cursor:"pointer",background:p===g?o:t.bg,color:p===g?"#fff":t.textSoft,border:`1px solid ${p===g?o:t.border}`,fontFamily:n},children:[w[g].icon,w[g].label]},g))}),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:g=>i(g.target.value),placeholder:"Short summary of the issue or idea",maxLength:200,style:{...v,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:r,onChange:g=>h(g.target.value),placeholder:"Steps to reproduce, expected behaviour, or more context",maxLength:2e3,rows:4,style:{...v,resize:"vertical",marginBottom:16}}),S&&e.jsx("p",{style:{fontSize:13,color:"#d6453d",marginBottom:12},children:S}),e.jsx("button",{onClick:b,disabled:u||!l.trim(),style:{width:"100%",padding:12,background:o,color:"#fff",border:"none",borderRadius:11,fontSize:14,fontWeight:600,cursor:"pointer",opacity:u||!l.trim()?.5:1,fontFamily:n},children:u?"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"})})}},$={BUG:"#fdecec",FEATURE:"#e9f0fd"},G={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:$[o]??t.bgSoft,color:G[o]??t.textSoft},children:o})}const H={OPEN:"#b45309",IN_PROGRESS:"#1d4ed8",DONE:"#15803d",CLOSED:"#6b7280"};function z(){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 W({status:o,p:t}){const n=H[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 V({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 B({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=M;exports.UpstepProvider=D;exports.useUpstep=k;
package/dist/react.d.ts CHANGED
@@ -1,24 +1,19 @@
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;
23
18
  }
24
19
  export declare function UpstepProvider({ children, ...config }: UpstepConfig & {
@@ -26,16 +21,9 @@ export declare function UpstepProvider({ children, ...config }: UpstepConfig & {
26
21
  }): React.JSX.Element;
27
22
  export declare function useUpstep(): UpstepContextValue;
28
23
  interface FeedbackWidgetProps {
29
- /** Position of the trigger button */
30
24
  position?: "bottom-right" | "bottom-left";
31
- /** Accent color. Defaults to the provider's accentColor (or "#D97757"). */
32
25
  accentColor?: string;
33
- /** Theme. Defaults to the provider's theme (or "auto"). */
34
26
  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
27
  hideLauncher?: boolean;
40
28
  }
41
29
  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;CAClB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,qBAkDxC;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,qBA6IrB"}
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-q50Qqen1.mjs";
4
- const D = "#D97757", H = {
1
+ import { jsxs as l, Fragment as W, jsx as e } from "react/jsx-runtime";
2
+ import { createContext as D, useState as u, useEffect as z, useCallback as w, useContext as M } from "react";
3
+ import { U as P } from "./api-CMuwaAet.mjs";
4
+ const A = "#D97757", N = {
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
+ }, $ = {
14
14
  bg: "#1c1b19",
15
15
  bgSoft: "#262522",
16
16
  bgHover: "#302e2a",
@@ -20,101 +20,95 @@ 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 G(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 z(() => {
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)"), f = (d) => o(d.matches);
31
+ return o(s.matches), s.addEventListener("change", f), () => s.removeEventListener("change", f);
32
+ }, [n]), t ? $ : N;
33
33
  }
34
- const A = G(null);
35
- function J({
36
- children: d,
37
- ...l
34
+ const I = D(null);
35
+ function Z({
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 P(t)), [s, f] = u([]), [d, i] = u(!1);
40
+ z(() => {
41
+ o.setUserId(t.userId);
42
+ }, [o, t.userId]);
43
+ const r = w(async () => {
44
+ const c = await o.listFeedback({ sort: "votes", limit: 20 });
45
+ f(c.items);
46
+ }, [o]);
47
+ z(() => {
48
+ r();
49
+ }, [r]);
50
+ const m = w(async (c, v, k) => {
51
+ const x = { content: v };
52
+ c.trim() && (x.title = c.trim()), k !== void 0 && (x.type = k), await o.submitFeedback(x), await r();
53
+ }, [o, r]), h = w(async (c, v) => {
54
+ await o.vote(c, v), await r();
55
+ }, [o, r]), a = w(
56
+ (c) => o.getItem(c),
57
+ [o]
58
+ ), p = w(() => i(!0), []), g = w(() => i(!1), []), S = w((c) => o.setUserId(c), [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
- 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"
63
+ client: o,
64
+ feedItems: s,
65
+ loadFeed: r,
66
+ submit: m,
67
+ vote: h,
68
+ getItem: a,
69
+ isOpen: d,
70
+ open: p,
71
+ close: g,
72
+ identify: S,
73
+ accentColor: t.accentColor ?? A,
74
+ theme: t.theme ?? "auto"
71
75
  },
72
- children: d
76
+ children: n
73
77
  }
74
78
  );
75
79
  }
76
- function N() {
77
- const d = T(A);
78
- if (!d) throw new Error("useUpstep must be used inside <UpstepProvider>");
79
- return d;
80
+ function F() {
81
+ const n = M(I);
82
+ if (!n) throw new Error("useUpstep must be used inside <UpstepProvider>");
83
+ return n;
80
84
  }
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
85
+ function ee({
86
+ position: n = "bottom-right",
87
+ accentColor: t,
88
+ theme: o,
89
+ hideLauncher: s = !1
91
90
  }) {
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
- }
91
+ const f = F(), d = t ?? f.accentColor, i = G(o ?? f.theme), { isOpen: r, open: m, close: h } = f, [a, p] = u("list"), [g, S] = u(null), [c, v] = u("open"), k = n === "bottom-left" ? { position: "fixed", bottom: 24, left: 24 } : { position: "fixed", bottom: 24, right: 24 }, x = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';
92
+ function C() {
93
+ h(), setTimeout(() => {
94
+ p("list"), S(null);
95
+ }, 300);
104
96
  }
105
- const w = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';
106
- return /* @__PURE__ */ c(z, { children: [
107
- !n && /* @__PURE__ */ c(
97
+ function b(y) {
98
+ S(y), p("detail");
99
+ }
100
+ return /* @__PURE__ */ l(W, { children: [
101
+ !s && /* @__PURE__ */ l(
108
102
  "button",
109
103
  {
110
- onClick: k,
104
+ onClick: m,
111
105
  style: {
112
- ...L,
106
+ ...k,
113
107
  zIndex: 9998,
114
108
  display: "inline-flex",
115
109
  alignItems: "center",
116
110
  gap: 7,
117
- background: a,
111
+ background: d,
118
112
  color: "#fff",
119
113
  border: "none",
120
114
  borderRadius: 9999,
@@ -122,37 +116,37 @@ function Q({
122
116
  fontSize: 14,
123
117
  fontWeight: 600,
124
118
  cursor: "pointer",
125
- fontFamily: w,
119
+ fontFamily: x,
126
120
  boxShadow: "0 6px 20px rgba(26,25,21,.18)"
127
121
  },
128
122
  children: [
129
- /* @__PURE__ */ e($, {}),
123
+ /* @__PURE__ */ e(K, { size: 16 }),
130
124
  " Feedback"
131
125
  ]
132
126
  }
133
127
  ),
134
- S && /* @__PURE__ */ e(
128
+ r && /* @__PURE__ */ e(
135
129
  "div",
136
130
  {
137
- onClick: (r) => r.target === r.currentTarget && h(),
131
+ onClick: (y) => y.target === y.currentTarget && C(),
138
132
  style: {
139
133
  position: "fixed",
140
134
  inset: 0,
141
- background: o.overlay,
135
+ background: i.overlay,
142
136
  backdropFilter: "blur(3px)",
143
137
  zIndex: 9999,
144
138
  display: "flex",
145
139
  alignItems: "center",
146
140
  justifyContent: "center",
147
141
  padding: 16,
148
- fontFamily: w
142
+ fontFamily: x
149
143
  },
150
- children: /* @__PURE__ */ c(
144
+ children: /* @__PURE__ */ l(
151
145
  "div",
152
146
  {
153
147
  style: {
154
- background: o.bg,
155
- border: `1px solid ${o.border}`,
148
+ background: i.bg,
149
+ border: `1px solid ${i.border}`,
156
150
  borderRadius: 20,
157
151
  width: "100%",
158
152
  maxWidth: 440,
@@ -163,106 +157,78 @@ function Q({
163
157
  boxShadow: "0 24px 64px rgba(0,0,0,.28)"
164
158
  },
165
159
  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." })
160
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "16px 20px", borderBottom: `1px solid ${i.border}`, flexShrink: 0 }, children: [
161
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
162
+ a !== "list" && /* @__PURE__ */ e(
163
+ "button",
164
+ {
165
+ onClick: () => p("list"),
166
+ style: { background: "none", border: "none", cursor: "pointer", color: d, fontSize: 13, fontWeight: 600, padding: 0 },
167
+ children: "← Back"
168
+ }
169
+ ),
170
+ a === "list" && /* @__PURE__ */ e("span", { style: { fontWeight: 700, fontSize: 16, color: i.text, letterSpacing: "-.01em" }, children: "Feedback" }),
171
+ a === "create" && /* @__PURE__ */ e("span", { style: { fontWeight: 700, fontSize: 16, color: i.text, letterSpacing: "-.01em" }, children: "New feedback" })
170
172
  ] }),
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
- )
173
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
174
+ a === "list" && /* @__PURE__ */ e(
175
+ "button",
176
+ {
177
+ onClick: () => p("create"),
178
+ style: { background: d, color: "#fff", border: "none", borderRadius: 20, padding: "6px 14px", fontSize: 13, fontWeight: 700, cursor: "pointer" },
179
+ children: "+ New"
180
+ }
181
+ ),
182
+ /* @__PURE__ */ e(
183
+ "button",
184
+ {
185
+ onClick: C,
186
+ 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" },
187
+ children: "✕"
188
+ }
189
+ )
190
+ ] })
179
191
  ] }),
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(
192
+ a === "list" && /* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${i.border}`, flexShrink: 0 }, children: ["open", "done"].map((y) => /* @__PURE__ */ e(
181
193
  "button",
182
194
  {
183
- onClick: () => u(r),
195
+ onClick: () => v(y),
184
196
  style: {
185
197
  flex: 1,
186
- padding: 8,
198
+ padding: "10px 0",
187
199
  border: "none",
188
- borderRadius: 8,
200
+ background: "none",
201
+ cursor: "pointer",
189
202
  fontSize: 13,
190
203
  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"
204
+ color: c === y ? d : i.textFaint,
205
+ borderBottom: `2px solid ${c === y ? d : "transparent"}`
195
206
  },
196
- children: r === "submit" ? "Give feedback" : "Vote on ideas"
207
+ children: y === "open" ? "Open" : "Completed"
197
208
  },
198
- r
209
+ y
199
210
  )) }),
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",
211
+ /* @__PURE__ */ l("div", { style: { flex: 1, overflowY: "auto", padding: "16px 20px 24px" }, children: [
212
+ a === "list" && /* @__PURE__ */ e(
213
+ H,
203
214
  {
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
- }
215
+ tab: c,
216
+ onSelect: b,
217
+ accent: d,
218
+ p: i
222
219
  }
223
220
  ),
224
- /* @__PURE__ */ e("div", { style: { display: "flex", gap: 7, margin: "12px 0 4px" }, children: ["BUG", "FEATURE", "GENERAL"].map((r) => /* @__PURE__ */ e(
225
- "button",
226
- {
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",
221
+ a === "detail" && g && /* @__PURE__ */ e(O, { feedbackId: g, accent: d, p: i, font: x }),
222
+ a === "create" && /* @__PURE__ */ e(
223
+ V,
245
224
  {
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"
225
+ accent: d,
226
+ p: i,
227
+ font: x,
228
+ onDone: () => p("list")
262
229
  }
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 }) })
230
+ )
231
+ ] })
266
232
  ]
267
233
  }
268
234
  )
@@ -270,65 +236,317 @@ function Q({
270
236
  )
271
237
  ] });
272
238
  }
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
239
+ function H({
240
+ tab: n,
241
+ onSelect: t,
242
+ accent: o,
243
+ p: s
282
244
  }) {
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." })
245
+ const { feedItems: f } = F(), { vote: d } = F(), i = n === "done" ? f.filter((r) => r.status === "DONE") : f.filter((r) => r.status !== "DONE" && r.status !== "CLOSED");
246
+ return i.length ? /* @__PURE__ */ e(W, { children: i.map((r) => {
247
+ const m = r.userVote === "UP", h = r.title ?? r.content;
248
+ return /* @__PURE__ */ l(
249
+ "div",
250
+ {
251
+ onClick: () => t(r.id),
252
+ style: {
253
+ display: "flex",
254
+ gap: 12,
255
+ padding: 14,
256
+ border: `1px solid ${s.border}`,
257
+ borderRadius: 14,
258
+ marginBottom: 10,
259
+ background: s.bg,
260
+ cursor: "pointer"
261
+ },
262
+ children: [
263
+ /* @__PURE__ */ l(
264
+ "button",
265
+ {
266
+ onClick: (a) => {
267
+ a.stopPropagation(), d(r.id, "UP");
268
+ },
269
+ style: {
270
+ display: "flex",
271
+ flexDirection: "column",
272
+ alignItems: "center",
273
+ justifyContent: "center",
274
+ gap: 2,
275
+ minWidth: 46,
276
+ padding: "7px 0",
277
+ borderRadius: 11,
278
+ cursor: "pointer",
279
+ flexShrink: 0,
280
+ border: `1px solid ${m ? o : s.border}`,
281
+ background: m ? `${o}1a` : s.bgSoft
282
+ },
283
+ children: [
284
+ /* @__PURE__ */ e(U, { color: o }),
285
+ /* @__PURE__ */ e("span", { style: { fontSize: 14, fontWeight: 700, color: s.text, lineHeight: 1.1 }, children: r.upvotes })
286
+ ]
287
+ }
288
+ ),
289
+ /* @__PURE__ */ l("div", { style: { flex: 1, minWidth: 0 }, children: [
290
+ /* @__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: h }),
291
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 6, flexWrap: "wrap" }, children: [
292
+ /* @__PURE__ */ e(E, { type: r.type, p: s }),
293
+ r.status === "PENDING" ? /* @__PURE__ */ e(T, {}) : /* @__PURE__ */ e(R, { status: r.status, p: s }),
294
+ /* @__PURE__ */ e("span", { style: { fontSize: 11, color: s.textFaint }, children: L(r.createdAt) })
295
+ ] })
296
+ ] }),
297
+ /* @__PURE__ */ e("span", { style: { color: s.textFaint, fontSize: 18, alignSelf: "center", flexShrink: 0 }, children: "›" })
298
+ ]
299
+ },
300
+ r.id
301
+ );
302
+ }) }) : /* @__PURE__ */ l("div", { style: { textAlign: "center", padding: "40px 0" }, children: [
303
+ /* @__PURE__ */ e("div", { style: { color: s.textSoft, fontSize: 15, fontWeight: 600, marginBottom: 4 }, children: n === "done" ? "Nothing completed yet" : "No open feedback yet" }),
304
+ /* @__PURE__ */ e("div", { style: { color: s.textFaint, fontSize: 14 }, children: n === "done" ? "Shipped items will appear here." : "Be the first to share one." })
305
+ ] });
306
+ }
307
+ function O({ feedbackId: n, accent: t, p: o, font: s }) {
308
+ const { vote: f, getItem: d } = F(), [i, r] = u(null), [m, h] = u(!1);
309
+ z(() => {
310
+ let g = !1;
311
+ return d(n).then((S) => {
312
+ g || r(S);
313
+ }).catch(() => {
314
+ }), () => {
315
+ g = !0;
316
+ };
317
+ }, [n, d]);
318
+ async function a() {
319
+ if (!(!i || m)) {
320
+ h(!0);
321
+ try {
322
+ await f(i.id, "UP");
323
+ const g = await d(n);
324
+ r(g);
325
+ } finally {
326
+ h(!1);
327
+ }
328
+ }
329
+ }
330
+ if (!i)
331
+ return /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: "40px 0", color: o.textFaint, fontSize: 14 }, children: "Loading…" });
332
+ const p = i.title;
333
+ return /* @__PURE__ */ l("div", { children: [
334
+ p && /* @__PURE__ */ e("div", { style: { fontSize: 20, fontWeight: 700, color: o.text, letterSpacing: "-.02em", marginBottom: 10, lineHeight: 1.3 }, children: p }),
335
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6, marginBottom: 14, flexWrap: "wrap" }, children: [
336
+ /* @__PURE__ */ e(E, { type: i.type, p: o }),
337
+ i.status === "PENDING" ? /* @__PURE__ */ e(T, {}) : /* @__PURE__ */ e(R, { status: i.status, p: o })
338
+ ] }),
339
+ /* @__PURE__ */ e("p", { style: { fontSize: 15, lineHeight: 1.6, color: o.textSoft, marginBottom: 20 }, children: i.content }),
340
+ /* @__PURE__ */ l(
341
+ "button",
342
+ {
343
+ onClick: a,
344
+ disabled: m,
345
+ style: {
346
+ display: "inline-flex",
347
+ alignItems: "center",
348
+ gap: 8,
349
+ border: `1px solid ${i.userVote === "UP" ? t : o.border}`,
350
+ background: i.userVote === "UP" ? `${t}15` : o.bgSoft,
351
+ borderRadius: 12,
352
+ padding: "10px 16px",
353
+ cursor: "pointer",
354
+ fontFamily: s
355
+ },
356
+ children: [
357
+ /* @__PURE__ */ e(U, { color: t, size: 13 }),
358
+ /* @__PURE__ */ e("span", { style: { fontSize: 18, fontWeight: 700, color: o.text }, children: i.upvotes }),
359
+ /* @__PURE__ */ e("span", { style: { fontSize: 13, color: o.textFaint }, children: i.userVote === "UP" ? "Upvoted" : "Upvote" })
360
+ ]
361
+ }
362
+ ),
363
+ i.comments.length > 0 && /* @__PURE__ */ l("div", { style: { marginTop: 28, borderTop: `1px solid ${o.border}`, paddingTop: 20 }, children: [
364
+ /* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: o.textFaint, marginBottom: 12, textTransform: "uppercase" }, children: "Developer response" }),
365
+ i.comments.map((g) => /* @__PURE__ */ e(j, { comment: g, p: o, accent: t }, g.id))
366
+ ] })
367
+ ] });
368
+ }
369
+ function j({ comment: n, p: t, accent: o }) {
370
+ return /* @__PURE__ */ l("div", { style: { background: t.bgSoft, border: `1px solid ${t.border}`, borderRadius: 12, padding: 14, marginBottom: 10 }, children: [
371
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 8 }, children: [
372
+ /* @__PURE__ */ e("span", { style: { background: `${o}20`, color: o, fontSize: 11, fontWeight: 700, borderRadius: 20, padding: "2px 8px" }, children: "Developer" }),
373
+ /* @__PURE__ */ e("span", { style: { fontSize: 11, color: t.textFaint }, children: L(n.createdAt) })
374
+ ] }),
375
+ /* @__PURE__ */ e("p", { style: { fontSize: 14, lineHeight: 1.5, color: t.textSoft, margin: 0 }, children: n.content })
376
+ ] });
377
+ }
378
+ function V({ accent: n, p: t, font: o, onDone: s }) {
379
+ const { submit: f } = F(), [d, i] = u(""), [r, m] = u(""), [h, a] = u("GENERAL"), [p, g] = u(!1), [S, c] = u(!1), [v, k] = u("");
380
+ async function x() {
381
+ if (!(!d.trim() || p)) {
382
+ g(!0), k("");
383
+ try {
384
+ await f(d.trim(), r.trim() || d.trim(), h), c(!0), setTimeout(s, 1200);
385
+ } catch {
386
+ k("Something went wrong. Please try again.");
387
+ } finally {
388
+ g(!1);
389
+ }
390
+ }
391
+ }
392
+ if (S)
393
+ return /* @__PURE__ */ l("div", { style: { textAlign: "center", paddingTop: 40 }, children: [
394
+ /* @__PURE__ */ e("div", { style: { fontSize: 18, fontWeight: 700, color: t.text, marginBottom: 6 }, children: "Submitted" }),
395
+ /* @__PURE__ */ e("div", { style: { fontSize: 14, color: t.textFaint }, children: "Feedback received. Thank you." })
396
+ ] });
397
+ const C = {
398
+ width: "100%",
399
+ border: `1px solid ${t.border}`,
400
+ borderRadius: 12,
401
+ padding: "10px 12px",
402
+ fontSize: 14,
403
+ lineHeight: 1.5,
404
+ outline: "none",
405
+ background: t.bgSoft,
406
+ color: t.text,
407
+ fontFamily: o,
408
+ boxSizing: "border-box"
409
+ };
410
+ return /* @__PURE__ */ l("div", { children: [
411
+ /* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: t.textFaint, marginBottom: 8, textTransform: "uppercase" }, children: "Type" }),
412
+ /* @__PURE__ */ e("div", { style: { display: "flex", gap: 7, marginBottom: 16 }, children: ["BUG", "FEATURE", "GENERAL"].map((b) => /* @__PURE__ */ l(
413
+ "button",
414
+ {
415
+ onClick: () => a(b),
416
+ style: {
417
+ flex: 1,
418
+ display: "flex",
419
+ alignItems: "center",
420
+ justifyContent: "center",
421
+ gap: 5,
422
+ padding: "8px 10px",
423
+ borderRadius: 9,
424
+ fontSize: 12.5,
425
+ fontWeight: 600,
426
+ cursor: "pointer",
427
+ background: h === b ? n : t.bg,
428
+ color: h === b ? "#fff" : t.textSoft,
429
+ border: `1px solid ${h === b ? n : t.border}`,
430
+ fontFamily: o
431
+ },
432
+ children: [
433
+ B[b].icon,
434
+ B[b].label
435
+ ]
436
+ },
437
+ b
438
+ )) }),
439
+ /* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: t.textFaint, marginBottom: 8, textTransform: "uppercase" }, children: "Title" }),
440
+ /* @__PURE__ */ e(
441
+ "input",
442
+ {
443
+ value: d,
444
+ onChange: (b) => i(b.target.value),
445
+ placeholder: "Short summary of the issue or idea",
446
+ maxLength: 200,
447
+ style: { ...C, marginBottom: 16, display: "block" }
448
+ }
449
+ ),
450
+ /* @__PURE__ */ l("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: t.textFaint, marginBottom: 8, textTransform: "uppercase" }, children: [
451
+ "Description ",
452
+ /* @__PURE__ */ e("span", { style: { fontWeight: 400, textTransform: "none", letterSpacing: 0 }, children: "(optional)" })
453
+ ] }),
454
+ /* @__PURE__ */ e(
455
+ "textarea",
456
+ {
457
+ value: r,
458
+ onChange: (b) => m(b.target.value),
459
+ placeholder: "Steps to reproduce, expected behaviour, or more context",
460
+ maxLength: 2e3,
461
+ rows: 4,
462
+ style: { ...C, resize: "vertical", marginBottom: 16 }
463
+ }
464
+ ),
465
+ v && /* @__PURE__ */ e("p", { style: { fontSize: 13, color: "#d6453d", marginBottom: 12 }, children: v }),
466
+ /* @__PURE__ */ e(
467
+ "button",
468
+ {
469
+ onClick: x,
470
+ disabled: p || !d.trim(),
471
+ style: {
472
+ width: "100%",
473
+ padding: 12,
474
+ background: n,
475
+ color: "#fff",
476
+ border: "none",
477
+ borderRadius: 11,
478
+ fontSize: 14,
479
+ fontWeight: 600,
480
+ cursor: "pointer",
481
+ opacity: p || !d.trim() ? 0.5 : 1,
482
+ fontFamily: o
483
+ },
484
+ children: p ? "Submitting…" : "Submit feedback"
485
+ }
486
+ )
487
+ ] });
488
+ }
489
+ const B = {
490
+ BUG: {
491
+ label: "Bug",
492
+ icon: /* @__PURE__ */ l("svg", { width: 12, height: 12, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", children: [
493
+ /* @__PURE__ */ e("ellipse", { cx: "8", cy: "10", rx: "3.5", ry: "4.5" }),
494
+ /* @__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" })
495
+ ] })
496
+ },
497
+ FEATURE: {
498
+ label: "Feature",
499
+ icon: /* @__PURE__ */ l("svg", { width: 12, height: 12, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", children: [
500
+ /* @__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" }),
501
+ /* @__PURE__ */ e("circle", { cx: "8", cy: "8", r: "2.5" })
502
+ ] })
503
+ },
504
+ GENERAL: {
505
+ label: "General",
506
+ 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" }) })
507
+ }
508
+ }, _ = { BUG: "#fdecec", FEATURE: "#e9f0fd" }, Y = { BUG: "#d6453d", FEATURE: "#3b76d6" };
509
+ function E({ type: n, p: t }) {
510
+ return /* @__PURE__ */ e("span", { style: {
511
+ padding: "2px 8px",
512
+ borderRadius: 9999,
513
+ fontSize: 10.5,
514
+ fontWeight: 700,
515
+ letterSpacing: ".02em",
516
+ background: _[n] ?? t.bgSoft,
517
+ color: Y[n] ?? t.textSoft
518
+ }, children: n });
519
+ }
520
+ const q = {
521
+ OPEN: "#b45309",
522
+ IN_PROGRESS: "#1d4ed8",
523
+ DONE: "#15803d",
524
+ CLOSED: "#6b7280"
525
+ };
526
+ function T() {
527
+ return /* @__PURE__ */ l("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: [
528
+ /* @__PURE__ */ e("span", { style: { width: 5, height: 5, borderRadius: "50%", background: "#ea580c", display: "inline-block" } }),
529
+ "Pending review"
530
+ ] });
531
+ }
532
+ function R({ status: n, p: t }) {
533
+ const o = q[n] ?? "#9ca3af";
534
+ return /* @__PURE__ */ l("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: [
535
+ /* @__PURE__ */ e("span", { style: { width: 6, height: 6, borderRadius: "50%", background: o, display: "inline-block", flexShrink: 0 } }),
536
+ n.replace("_", " ")
328
537
  ] });
329
538
  }
539
+ function K({ size: n = 16, color: t = "currentColor" }) {
540
+ 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" }) });
541
+ }
542
+ function U({ color: n = "currentColor", size: t = 11 }) {
543
+ 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" }) });
544
+ }
545
+ function L(n) {
546
+ return new Date(n).toLocaleDateString(void 0, { month: "short", day: "numeric" });
547
+ }
330
548
  export {
331
- Q as FeedbackWidget,
332
- J as UpstepProvider,
333
- N as useUpstep
549
+ ee as FeedbackWidget,
550
+ Z as UpstepProvider,
551
+ F as useUpstep
334
552
  };
@@ -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.4.0",
3
+ "version": "0.5.1",
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.4.0"
24
+ "@upstep/types": "0.5.1"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "react": ">=18",
@@ -1 +0,0 @@
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);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;