@upstep/js 0.5.1 → 0.5.3

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