@upstep/js 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
  });
@@ -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 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;
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,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"}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
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-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`
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
4
  #upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
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-CRsXibfd.mjs";
2
2
  const c = "#D97757", u = {
3
3
  bg: "#ffffff",
4
4
  bgSoft: "#f6f5f2",
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"),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;
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsxs as c, Fragment as z, jsx as e } from "react/jsx-runtime";
2
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";
3
+ import { U as B } from "./api-CRsXibfd.mjs";
4
4
  const D = "#D97757", H = {
5
5
  bg: "#ffffff",
6
6
  bgSoft: "#f6f5f2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upstep/js",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Upstep feedback widget for web apps",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "dist"
22
22
  ],
23
23
  "dependencies": {
24
- "@upstep/types": "0.4.0"
24
+ "@upstep/types": "0.5.0"
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;