@upstep/js 0.5.6 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),L=require("./api-BvhrcMKU.js"),R="#D97757",M={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},D={bg:"#1c1b19",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function P(i){const[n,t]=r.useState(()=>i==="dark"?!0:i==="light"?!1:typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1);return r.useEffect(()=>{if(i!=="auto"||typeof window>"u"||!window.matchMedia){t(i==="dark");return}const f=window.matchMedia("(prefers-color-scheme: dark)"),u=s=>t(s.matches);return t(f.matches),f.addEventListener("change",u),()=>f.removeEventListener("change",u)},[i]),n?D:M}const F=r.createContext(null);function A({children:i,...n}){const[t]=r.useState(()=>new L.UpstepApiClient(n)),[f,u]=r.useState([]),[s,o]=r.useState(!1),[p,g]=r.useState(!0);r.useEffect(()=>{t.setUserId(n.userId)},[t,n.userId]);const l=r.useCallback(async()=>{try{const x=await t.listFeedback({sort:"votes",limit:20});u(x.items),g(x.showBranding??!0)}catch{}},[t]);r.useEffect(()=>{l()},[l]);const m=r.useCallback(async(x,S,h)=>{const d={content:S};x.trim()&&(d.title=x.trim()),h!==void 0&&(d.type=h),await t.submitFeedback(d),await l()},[t,l]),c=r.useCallback(async(x,S)=>{try{await t.vote(x,S),await l()}catch{}},[t,l]),a=r.useCallback(x=>t.getItem(x),[t]),b=r.useCallback(()=>o(!0),[]),k=r.useCallback(()=>o(!1),[]),y=r.useCallback(x=>t.setUserId(x),[t]);return e.jsx(F.Provider,{value:{client:t,feedItems:f,loadFeed:l,submit:m,vote:c,getItem:a,isOpen:s,open:b,close:k,identify:y,accentColor:n.accentColor??R,theme:n.theme??"auto",showBranding:p},children:i})}function v(){const i=r.useContext(F);if(!i)throw new Error("useUpstep must be used inside <UpstepProvider>");return i}function G({position:i="bottom-right",accentColor:n,theme:t,hideLauncher:f=!1}){const u=v(),s=n??u.accentColor,o=P(t??u.theme),{isOpen:p,open:g,close:l,showBranding:m}=u,[c,a]=r.useState("list"),[b,k]=r.useState(null),[y,x]=r.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:!1);r.useEffect(()=>{const j=window.matchMedia("(max-width: 639px)"),w=U=>x(U.matches);return j.addEventListener("change",w),()=>j.removeEventListener("change",w)},[]);const S=i==="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 d(){l(),setTimeout(()=>{a("list"),k(null)},300)}function T(j){k(j),a("detail")}return e.jsxs(e.Fragment,{children:[!f&&e.jsxs("button",{onClick:g,style:{...S,zIndex:9998,display:"inline-flex",alignItems:"center",gap:7,background:s,color:"#fff",border:"none",borderRadius:9999,padding:y?"12px":"12px 18px",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:h,boxShadow:"0 6px 20px rgba(26,25,21,.18)"},children:[e.jsx(Y,{size:16}),!y&&"Feedback"]}),p&&e.jsx("div",{onClick:j=>j.target===j.currentTarget&&d(),style:{position:"fixed",inset:0,background:o.overlay,backdropFilter:"blur(3px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:16,fontFamily:h},children:e.jsxs("div",{style:{background:o.bg,border:`1px solid ${o.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 ${o.border}`,flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c!=="list"&&e.jsx("button",{onClick:()=>a("list"),style:{background:"none",border:"none",cursor:"pointer",color:s,fontSize:13,fontWeight:600,padding:0},children:"← Back"}),c==="list"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:o.text,letterSpacing:"-.01em"},children:"Feedback"}),c==="create"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:o.text,letterSpacing:"-.01em"},children:"New feedback"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c==="list"&&e.jsx("button",{onClick:()=>a("create"),style:{background:s,color:"#fff",border:"none",borderRadius:20,padding:"6px 14px",fontSize:13,fontWeight:700,cursor:"pointer"},children:"+ New"}),e.jsx("button",{onClick:d,style:{background:o.bgSoft,border:"none",width:28,height:28,borderRadius:8,fontSize:14,cursor:"pointer",color:o.textSoft,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px 24px"},children:[c==="list"&&e.jsx(H,{onSelect:T,accent:s,p:o}),c==="detail"&&b&&e.jsx(N,{feedbackId:b,accent:s,p:o,font:h}),c==="create"&&e.jsx(O,{accent:s,p:o,font:h,onDone:()=>a("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 ${o.border}`,fontSize:11,color:o.textFaint,textDecoration:"none",flexShrink:0},children:["Powered by ",e.jsx("strong",{style:{fontWeight:700},children:"Upstep.dev"})]})]})})]})}function H({onSelect:i,accent:n,p:t}){const{feedItems:f,vote:u}=v(),s=f.filter(o=>o.status!=="CLOSED");return s.length?e.jsx(e.Fragment,{children:s.map(o=>{const p=o.userVote==="UP",g=o.title??o.content;return e.jsxs("div",{onClick:()=>i(o.id),style:{display:"flex",gap:12,padding:14,border:`1px solid ${t.border}`,borderRadius:14,marginBottom:10,background:t.bg,cursor:"pointer"},children:[e.jsxs("button",{onClick:l=>{l.stopPropagation(),u(o.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 ${p?n:t.border}`,background:p?`${n}1a`:t.bgSoft},children:[e.jsx(E,{color:n}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:t.text,lineHeight:1.1},children:o.upvotes})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:13.5,fontWeight:600,lineHeight:1.4,color:t.text,margin:"0 0 6px",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:g}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx(z,{type:o.type,p:t}),o.status==="PENDING"?e.jsx(B,{}):e.jsx(W,{status:o.status,p:t}),e.jsx("span",{style:{fontSize:11,color:t.textFaint},children:I(o.createdAt)})]})]}),e.jsx("span",{style:{color:t.textFaint,fontSize:18,alignSelf:"center",flexShrink:0},children:"›"})]},o.id)})}):e.jsxs("div",{style:{textAlign:"center",padding:"40px 0"},children:[e.jsx("div",{style:{color:t.textSoft,fontSize:15,fontWeight:600,marginBottom:4},children:"No open feedback yet"}),e.jsx("div",{style:{color:t.textFaint,fontSize:14},children:"Be the first to share one."})]})}function N({feedbackId:i,accent:n,p:t,font:f}){const{vote:u,getItem:s}=v(),[o,p]=r.useState(null),[g,l]=r.useState(!1);r.useEffect(()=>{let a=!1;return s(i).then(b=>{a||p(b)}).catch(()=>{}),()=>{a=!0}},[i,s]);async function m(){if(!(!o||g)){l(!0);try{await u(o.id,"UP");const a=await s(i);p(a)}catch{}finally{l(!1)}}}if(!o)return e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:t.textFaint,fontSize:14},children:"Loading…"});const c=o.title;return e.jsxs("div",{children:[c&&e.jsx("div",{style:{fontSize:20,fontWeight:700,color:t.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(z,{type:o.type,p:t}),o.status==="PENDING"?e.jsx(B,{}):e.jsx(W,{status:o.status,p:t})]}),e.jsx("p",{style:{fontSize:15,lineHeight:1.6,color:t.textSoft,marginBottom:20},children:o.content}),e.jsxs("button",{onClick:m,disabled:g,style:{display:"inline-flex",alignItems:"center",gap:8,border:`1px solid ${o.userVote==="UP"?n:t.border}`,background:o.userVote==="UP"?`${n}15`:t.bgSoft,borderRadius:12,padding:"10px 16px",cursor:"pointer",fontFamily:f},children:[e.jsx(E,{color:n,size:13}),e.jsx("span",{style:{fontSize:18,fontWeight:700,color:t.text},children:o.upvotes}),e.jsx("span",{style:{fontSize:13,color:t.textFaint},children:o.userVote==="UP"?"Upvoted":"Upvote"})]}),o.comments.length>0&&e.jsxs("div",{style:{marginTop:28,borderTop:`1px solid ${t.border}`,paddingTop:20},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:t.textFaint,marginBottom:12,textTransform:"uppercase"},children:"Developer response"}),o.comments.map(a=>e.jsx($,{comment:a,p:t,accent:n},a.id))]})]})}function $({comment:i,p:n,accent:t}){return e.jsxs("div",{style:{background:n.bgSoft,border:`1px solid ${n.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:`${t}20`,color:t,fontSize:11,fontWeight:700,borderRadius:20,padding:"2px 8px"},children:"Developer"}),e.jsx("span",{style:{fontSize:11,color:n.textFaint},children:I(i.createdAt)})]}),e.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:n.textSoft,margin:0},children:i.content})]})}function O({accent:i,p:n,font:t,onDone:f}){const{submit:u}=v(),[s,o]=r.useState(""),[p,g]=r.useState(""),[l,m]=r.useState("GENERAL"),[c,a]=r.useState(!1),[b,k]=r.useState(!1),[y,x]=r.useState("");async function S(){if(!(!s.trim()||c)){a(!0),x("");try{await u(s.trim(),p.trim()||s.trim(),l),k(!0),setTimeout(f,1200)}catch{x("Something went wrong. Please try again.")}finally{a(!1)}}}if(b)return e.jsxs("div",{style:{textAlign:"center",paddingTop:40},children:[e.jsx("div",{style:{fontSize:18,fontWeight:700,color:n.text,marginBottom:6},children:"Submitted"}),e.jsx("div",{style:{fontSize:14,color:n.textFaint},children:"Feedback received. Thank you."})]});const h={width:"100%",border:`1px solid ${n.border}`,borderRadius:12,padding:"10px 12px",fontSize:14,lineHeight:1.5,outline:"none",background:n.bgSoft,color:n.text,fontFamily:t,boxSizing:"border-box"};return e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Type"}),e.jsx("div",{style:{display:"flex",gap:7,marginBottom:16},children:["BUG","FEATURE","GENERAL"].map(d=>e.jsxs("button",{onClick:()=>m(d),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"8px 10px",borderRadius:9,fontSize:12.5,fontWeight:600,cursor:"pointer",background:l===d?i:n.bg,color:l===d?"#fff":n.textSoft,border:`1px solid ${l===d?i:n.border}`,fontFamily:t},children:[C[d].icon,C[d].label]},d))}),e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Title"}),e.jsx("input",{value:s,onChange:d=>o(d.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:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:["Description ",e.jsx("span",{style:{fontWeight:400,textTransform:"none",letterSpacing:0},children:"(optional)"})]}),e.jsx("textarea",{value:p,onChange:d=>g(d.target.value),placeholder:"Steps to reproduce, expected behaviour, or more context",maxLength:2e3,rows:4,style:{...h,resize:"vertical",marginBottom:16}}),y&&e.jsx("p",{style:{fontSize:13,color:"#d6453d",marginBottom:12},children:y}),e.jsx("button",{onClick:S,disabled:c||!s.trim(),style:{width:"100%",padding:12,background:i,color:"#fff",border:"none",borderRadius:11,fontSize:14,fontWeight:600,cursor:"pointer",opacity:c||!s.trim()?.5:1,fontFamily:t},children:c?"Submitting…":"Submit feedback"})]})}const C={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"})})}},V={BUG:"#fdecec",FEATURE:"#e9f0fd"},_={BUG:"#d6453d",FEATURE:"#3b76d6"};function z({type:i,p:n}){return e.jsx("span",{style:{padding:"2px 8px",borderRadius:9999,fontSize:10.5,fontWeight:700,letterSpacing:".02em",background:V[i]??n.bgSoft,color:_[i]??n.textSoft},children:i})}const q={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 W({status:i,p:n}){const t=q[i]??"#9ca3af";return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,background:n.bgSoft,border:`1px solid ${n.border}`,borderRadius:6,padding:"2px 8px",fontSize:10,fontWeight:600,color:n.textSoft},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}}),i.replace("_"," ")]})}function Y({size:i=16,color:n="currentColor"}){return e.jsx("svg",{width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:n,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 E({color:i="currentColor",size:n=11}){return e.jsx("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none",stroke:i,strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M8 13V3M3 8l5-5 5 5"})})}function I(i){return new Date(i).toLocaleDateString(void 0,{month:"short",day:"numeric"})}exports.FeedbackWidget=G;exports.UpstepProvider=A;exports.useUpstep=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),L=require("./api-BvhrcMKU.js"),R="#D97757",M={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},D={bg:"#1c1b19",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function P(i){const[n,t]=r.useState(()=>i==="dark");return r.useEffect(()=>{if(i!=="auto"||typeof window>"u"||!window.matchMedia){t(i==="dark");return}const f=window.matchMedia("(prefers-color-scheme: dark)"),u=s=>t(s.matches);return t(f.matches),f.addEventListener("change",u),()=>f.removeEventListener("change",u)},[i]),n?D:M}const F=r.createContext(null);function A({children:i,...n}){const[t]=r.useState(()=>new L.UpstepApiClient(n)),[f,u]=r.useState([]),[s,o]=r.useState(!1),[g,p]=r.useState(!0);r.useEffect(()=>{t.setUserId(n.userId)},[t,n.userId]);const l=r.useCallback(async()=>{try{const x=await t.listFeedback({sort:"votes",limit:20});u(x.items),p(x.showBranding??!0)}catch{}},[t]);r.useEffect(()=>{l()},[l]);const y=r.useCallback(async(x,j,h)=>{const d={content:j};x.trim()&&(d.title=x.trim()),h!==void 0&&(d.type=h),await t.submitFeedback(d),await l()},[t,l]),c=r.useCallback(async(x,j)=>{try{await t.vote(x,j),await l()}catch{}},[t,l]),a=r.useCallback(x=>t.getItem(x),[t]),b=r.useCallback(()=>o(!0),[]),v=r.useCallback(()=>o(!1),[]),S=r.useCallback(x=>t.setUserId(x),[t]);return e.jsx(F.Provider,{value:{client:t,feedItems:f,loadFeed:l,submit:y,vote:c,getItem:a,isOpen:s,open:b,close:v,identify:S,accentColor:n.accentColor??R,theme:n.theme??"auto",showBranding:g},children:i})}function k(){const i=r.useContext(F);if(!i)throw new Error("useUpstep must be used inside <UpstepProvider>");return i}function G({position:i="bottom-right",accentColor:n,theme:t,hideLauncher:f=!1}){const u=k(),s=n??u.accentColor,o=P(t??u.theme),{isOpen:g,open:p,close:l,showBranding:y}=u,[c,a]=r.useState("list"),[b,v]=r.useState(null),[S,x]=r.useState(!1);r.useEffect(()=>{const m=window.matchMedia("(max-width: 639px)");x(m.matches);const w=U=>x(U.matches);return m.addEventListener("change",w),()=>m.removeEventListener("change",w)},[]);const j=i==="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 d(){l(),setTimeout(()=>{a("list"),v(null)},300)}function T(m){v(m),a("detail")}return e.jsxs(e.Fragment,{children:[!f&&e.jsxs("button",{onClick:p,style:{...j,zIndex:9998,display:"inline-flex",alignItems:"center",gap:7,background:s,color:"#fff",border:"none",borderRadius:9999,padding:S?"12px":"12px 18px",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:h,boxShadow:"0 6px 20px rgba(26,25,21,.18)"},children:[e.jsx(Y,{size:16}),!S&&"Feedback"]}),g&&e.jsx("div",{onClick:m=>m.target===m.currentTarget&&d(),style:{position:"fixed",inset:0,background:o.overlay,backdropFilter:"blur(3px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:16,fontFamily:h},children:e.jsxs("div",{style:{background:o.bg,border:`1px solid ${o.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 ${o.border}`,flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c!=="list"&&e.jsx("button",{onClick:()=>a("list"),style:{background:"none",border:"none",cursor:"pointer",color:s,fontSize:13,fontWeight:600,padding:0},children:"← Back"}),c==="list"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:o.text,letterSpacing:"-.01em"},children:"Feedback"}),c==="create"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:o.text,letterSpacing:"-.01em"},children:"New feedback"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c==="list"&&e.jsx("button",{onClick:()=>a("create"),style:{background:s,color:"#fff",border:"none",borderRadius:20,padding:"6px 14px",fontSize:13,fontWeight:700,cursor:"pointer"},children:"+ New"}),e.jsx("button",{onClick:d,style:{background:o.bgSoft,border:"none",width:28,height:28,borderRadius:8,fontSize:14,cursor:"pointer",color:o.textSoft,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px 24px"},children:[c==="list"&&e.jsx(H,{onSelect:T,accent:s,p:o}),c==="detail"&&b&&e.jsx(N,{feedbackId:b,accent:s,p:o,font:h}),c==="create"&&e.jsx(O,{accent:s,p:o,font:h,onDone:()=>a("list")})]}),y&&e.jsxs("a",{href:"https://upstep.dev",target:"_blank",rel:"noopener noreferrer",style:{display:"block",textAlign:"center",padding:"8px 0",borderTop:`1px solid ${o.border}`,fontSize:11,color:o.textFaint,textDecoration:"none",flexShrink:0},children:["Powered by ",e.jsx("strong",{style:{fontWeight:700},children:"Upstep.dev"})]})]})})]})}function H({onSelect:i,accent:n,p:t}){const{feedItems:f,vote:u}=k(),s=f.filter(o=>o.status!=="CLOSED");return s.length?e.jsx(e.Fragment,{children:s.map(o=>{const g=o.userVote==="UP",p=o.title??o.content;return e.jsxs("div",{onClick:()=>i(o.id),style:{display:"flex",gap:12,padding:14,border:`1px solid ${t.border}`,borderRadius:14,marginBottom:10,background:t.bg,cursor:"pointer"},children:[e.jsxs("button",{onClick:l=>{l.stopPropagation(),u(o.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:t.border}`,background:g?`${n}1a`:t.bgSoft},children:[e.jsx(E,{color:n}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:t.text,lineHeight:1.1},children:o.upvotes})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:13.5,fontWeight:600,lineHeight:1.4,color:t.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(z,{type:o.type,p:t}),o.status==="PENDING"?e.jsx(B,{}):e.jsx(W,{status:o.status,p:t}),e.jsx("span",{style:{fontSize:11,color:t.textFaint},children:I(o.createdAt)})]})]}),e.jsx("span",{style:{color:t.textFaint,fontSize:18,alignSelf:"center",flexShrink:0},children:"›"})]},o.id)})}):e.jsxs("div",{style:{textAlign:"center",padding:"40px 0"},children:[e.jsx("div",{style:{color:t.textSoft,fontSize:15,fontWeight:600,marginBottom:4},children:"No open feedback yet"}),e.jsx("div",{style:{color:t.textFaint,fontSize:14},children:"Be the first to share one."})]})}function N({feedbackId:i,accent:n,p:t,font:f}){const{vote:u,getItem:s}=k(),[o,g]=r.useState(null),[p,l]=r.useState(!1);r.useEffect(()=>{let a=!1;return s(i).then(b=>{a||g(b)}).catch(()=>{}),()=>{a=!0}},[i,s]);async function y(){if(!(!o||p)){l(!0);try{await u(o.id,"UP");const a=await s(i);g(a)}catch{}finally{l(!1)}}}if(!o)return e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:t.textFaint,fontSize:14},children:"Loading…"});const c=o.title;return e.jsxs("div",{children:[c&&e.jsx("div",{style:{fontSize:20,fontWeight:700,color:t.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(z,{type:o.type,p:t}),o.status==="PENDING"?e.jsx(B,{}):e.jsx(W,{status:o.status,p:t})]}),e.jsx("p",{style:{fontSize:15,lineHeight:1.6,color:t.textSoft,marginBottom:20},children:o.content}),e.jsxs("button",{onClick:y,disabled:p,style:{display:"inline-flex",alignItems:"center",gap:8,border:`1px solid ${o.userVote==="UP"?n:t.border}`,background:o.userVote==="UP"?`${n}15`:t.bgSoft,borderRadius:12,padding:"10px 16px",cursor:"pointer",fontFamily:f},children:[e.jsx(E,{color:n,size:13}),e.jsx("span",{style:{fontSize:18,fontWeight:700,color:t.text},children:o.upvotes}),e.jsx("span",{style:{fontSize:13,color:t.textFaint},children:o.userVote==="UP"?"Upvoted":"Upvote"})]}),o.comments.length>0&&e.jsxs("div",{style:{marginTop:28,borderTop:`1px solid ${t.border}`,paddingTop:20},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:t.textFaint,marginBottom:12,textTransform:"uppercase"},children:"Developer response"}),o.comments.map(a=>e.jsx($,{comment:a,p:t,accent:n},a.id))]})]})}function $({comment:i,p:n,accent:t}){return e.jsxs("div",{style:{background:n.bgSoft,border:`1px solid ${n.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:`${t}20`,color:t,fontSize:11,fontWeight:700,borderRadius:20,padding:"2px 8px"},children:"Developer"}),e.jsx("span",{style:{fontSize:11,color:n.textFaint},children:I(i.createdAt)})]}),e.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:n.textSoft,margin:0},children:i.content})]})}function O({accent:i,p:n,font:t,onDone:f}){const{submit:u}=k(),[s,o]=r.useState(""),[g,p]=r.useState(""),[l,y]=r.useState("GENERAL"),[c,a]=r.useState(!1),[b,v]=r.useState(!1),[S,x]=r.useState("");async function j(){if(!(!s.trim()||c)){a(!0),x("");try{await u(s.trim(),g.trim()||s.trim(),l),v(!0),setTimeout(f,1200)}catch{x("Something went wrong. Please try again.")}finally{a(!1)}}}if(b)return e.jsxs("div",{style:{textAlign:"center",paddingTop:40},children:[e.jsx("div",{style:{fontSize:18,fontWeight:700,color:n.text,marginBottom:6},children:"Submitted"}),e.jsx("div",{style:{fontSize:14,color:n.textFaint},children:"Feedback received. Thank you."})]});const h={width:"100%",border:`1px solid ${n.border}`,borderRadius:12,padding:"10px 12px",fontSize:14,lineHeight:1.5,outline:"none",background:n.bgSoft,color:n.text,fontFamily:t,boxSizing:"border-box"};return e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Type"}),e.jsx("div",{style:{display:"flex",gap:7,marginBottom:16},children:["BUG","FEATURE","GENERAL"].map(d=>e.jsxs("button",{onClick:()=>y(d),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"8px 10px",borderRadius:9,fontSize:12.5,fontWeight:600,cursor:"pointer",background:l===d?i:n.bg,color:l===d?"#fff":n.textSoft,border:`1px solid ${l===d?i:n.border}`,fontFamily:t},children:[C[d].icon,C[d].label]},d))}),e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Title"}),e.jsx("input",{value:s,onChange:d=>o(d.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:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:["Description ",e.jsx("span",{style:{fontWeight:400,textTransform:"none",letterSpacing:0},children:"(optional)"})]}),e.jsx("textarea",{value:g,onChange:d=>p(d.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||!s.trim(),style:{width:"100%",padding:12,background:i,color:"#fff",border:"none",borderRadius:11,fontSize:14,fontWeight:600,cursor:"pointer",opacity:c||!s.trim()?.5:1,fontFamily:t},children:c?"Submitting…":"Submit feedback"})]})}const C={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"})})}},V={BUG:"#fdecec",FEATURE:"#e9f0fd"},_={BUG:"#d6453d",FEATURE:"#3b76d6"};function z({type:i,p:n}){return e.jsx("span",{style:{padding:"2px 8px",borderRadius:9999,fontSize:10.5,fontWeight:700,letterSpacing:".02em",background:V[i]??n.bgSoft,color:_[i]??n.textSoft},children:i})}const q={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 W({status:i,p:n}){const t=q[i]??"#9ca3af";return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,background:n.bgSoft,border:`1px solid ${n.border}`,borderRadius:6,padding:"2px 8px",fontSize:10,fontWeight:600,color:n.textSoft},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}}),i.replace("_"," ")]})}function Y({size:i=16,color:n="currentColor"}){return e.jsx("svg",{width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:n,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 E({color:i="currentColor",size:n=11}){return e.jsx("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none",stroke:i,strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M8 13V3M3 8l5-5 5 5"})})}function I(i){return new Date(i).toLocaleDateString(void 0,{month:"short",day:"numeric"})}exports.FeedbackWidget=G;exports.UpstepProvider=A;exports.useUpstep=k;
@@ -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;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,qBAkJrB"}
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;AAiD3C,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,qBAoJrB"}
package/dist/react.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsxs as r, Fragment as I, jsx as e } from "react/jsx-runtime";
2
- import { createContext as A, useState as p, useEffect as z, useCallback as w, useContext as G } from "react";
2
+ import { createContext as A, useState as g, useEffect as z, useCallback as w, useContext as G } from "react";
3
3
  import { U as H } from "./api-B-umoNRf.mjs";
4
4
  const N = "#D97757", $ = {
5
5
  bg: "#ffffff",
@@ -21,14 +21,14 @@ const N = "#D97757", $ = {
21
21
  overlay: "rgba(0,0,0,.6)"
22
22
  };
23
23
  function O(i) {
24
- const [n, t] = p(() => i === "dark" ? !0 : i === "light" ? !1 : typeof window < "u" && window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)").matches : !1);
24
+ const [n, t] = g(() => i === "dark");
25
25
  return z(() => {
26
26
  if (i !== "auto" || typeof window > "u" || !window.matchMedia) {
27
27
  t(i === "dark");
28
28
  return;
29
29
  }
30
- const h = window.matchMedia("(prefers-color-scheme: dark)"), g = (l) => t(l.matches);
31
- return t(h.matches), h.addEventListener("change", g), () => h.removeEventListener("change", g);
30
+ const h = window.matchMedia("(prefers-color-scheme: dark)"), p = (l) => t(l.matches);
31
+ return t(h.matches), h.addEventListener("change", p), () => h.removeEventListener("change", p);
32
32
  }, [i]), n ? j : $;
33
33
  }
34
34
  const E = A(null);
@@ -36,32 +36,32 @@ function ne({
36
36
  children: i,
37
37
  ...n
38
38
  }) {
39
- const [t] = p(() => new H(n)), [h, g] = p([]), [l, o] = p(!1), [u, x] = p(!0);
39
+ const [t] = g(() => new H(n)), [h, p] = g([]), [l, o] = g(!1), [u, x] = g(!0);
40
40
  z(() => {
41
41
  t.setUserId(n.userId);
42
42
  }, [t, n.userId]);
43
43
  const d = w(async () => {
44
44
  try {
45
45
  const f = await t.listFeedback({ sort: "votes", limit: 20 });
46
- g(f.items), x(f.showBranding ?? !0);
46
+ p(f.items), x(f.showBranding ?? !0);
47
47
  } catch {
48
48
  }
49
49
  }, [t]);
50
50
  z(() => {
51
51
  d();
52
52
  }, [d]);
53
- const y = w(async (f, v, m) => {
54
- const s = { content: v };
55
- f.trim() && (s.title = f.trim()), m !== void 0 && (s.type = m), await t.submitFeedback(s), await d();
56
- }, [t, d]), c = w(async (f, v) => {
53
+ const S = w(async (f, k, b) => {
54
+ const a = { content: k };
55
+ f.trim() && (a.title = f.trim()), b !== void 0 && (a.type = b), await t.submitFeedback(a), await d();
56
+ }, [t, d]), c = w(async (f, k) => {
57
57
  try {
58
- await t.vote(f, v), await d();
58
+ await t.vote(f, k), await d();
59
59
  } catch {
60
60
  }
61
- }, [t, d]), a = w(
61
+ }, [t, d]), s = w(
62
62
  (f) => t.getItem(f),
63
63
  [t]
64
- ), b = w(() => o(!0), []), F = w(() => o(!1), []), S = w((f) => t.setUserId(f), [t]);
64
+ ), m = w(() => o(!0), []), F = w(() => o(!1), []), v = w((f) => t.setUserId(f), [t]);
65
65
  return /* @__PURE__ */ e(
66
66
  E.Provider,
67
67
  {
@@ -69,13 +69,13 @@ function ne({
69
69
  client: t,
70
70
  feedItems: h,
71
71
  loadFeed: d,
72
- submit: y,
72
+ submit: S,
73
73
  vote: c,
74
- getItem: a,
74
+ getItem: s,
75
75
  isOpen: l,
76
- open: b,
76
+ open: m,
77
77
  close: F,
78
- identify: S,
78
+ identify: v,
79
79
  accentColor: n.accentColor ?? N,
80
80
  theme: n.theme ?? "auto",
81
81
  showBranding: u
@@ -95,21 +95,21 @@ function oe({
95
95
  theme: t,
96
96
  hideLauncher: h = !1
97
97
  }) {
98
- const g = B(), l = n ?? g.accentColor, o = O(t ?? g.theme), { isOpen: u, open: x, close: d, showBranding: y } = g, [c, a] = p("list"), [b, F] = p(null), [S, f] = p(
99
- () => typeof window < "u" ? window.matchMedia("(max-width: 639px)").matches : !1
100
- );
98
+ const p = B(), l = n ?? p.accentColor, o = O(t ?? p.theme), { isOpen: u, open: x, close: d, showBranding: S } = p, [c, s] = g("list"), [m, F] = g(null), [v, f] = g(!1);
101
99
  z(() => {
102
- const k = window.matchMedia("(max-width: 639px)"), C = (P) => f(P.matches);
103
- return k.addEventListener("change", C), () => k.removeEventListener("change", C);
100
+ const y = window.matchMedia("(max-width: 639px)");
101
+ f(y.matches);
102
+ const C = (P) => f(P.matches);
103
+ return y.addEventListener("change", C), () => y.removeEventListener("change", C);
104
104
  }, []);
105
- const v = i === "bottom-left" ? { position: "fixed", bottom: 24, left: 24 } : { position: "fixed", bottom: 24, right: 24 }, m = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';
106
- function s() {
105
+ const k = i === "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';
106
+ function a() {
107
107
  d(), setTimeout(() => {
108
- a("list"), F(null);
108
+ s("list"), F(null);
109
109
  }, 300);
110
110
  }
111
- function D(k) {
112
- F(k), a("detail");
111
+ function M(y) {
112
+ F(y), s("detail");
113
113
  }
114
114
  return /* @__PURE__ */ r(I, { children: [
115
115
  !h && /* @__PURE__ */ r(
@@ -117,7 +117,7 @@ function oe({
117
117
  {
118
118
  onClick: x,
119
119
  style: {
120
- ...v,
120
+ ...k,
121
121
  zIndex: 9998,
122
122
  display: "inline-flex",
123
123
  alignItems: "center",
@@ -126,23 +126,23 @@ function oe({
126
126
  color: "#fff",
127
127
  border: "none",
128
128
  borderRadius: 9999,
129
- padding: S ? "12px" : "12px 18px",
129
+ padding: v ? "12px" : "12px 18px",
130
130
  fontSize: 14,
131
131
  fontWeight: 600,
132
132
  cursor: "pointer",
133
- fontFamily: m,
133
+ fontFamily: b,
134
134
  boxShadow: "0 6px 20px rgba(26,25,21,.18)"
135
135
  },
136
136
  children: [
137
137
  /* @__PURE__ */ e(X, { size: 16 }),
138
- !S && "Feedback"
138
+ !v && "Feedback"
139
139
  ]
140
140
  }
141
141
  ),
142
142
  u && /* @__PURE__ */ e(
143
143
  "div",
144
144
  {
145
- onClick: (k) => k.target === k.currentTarget && s(),
145
+ onClick: (y) => y.target === y.currentTarget && a(),
146
146
  style: {
147
147
  position: "fixed",
148
148
  inset: 0,
@@ -153,7 +153,7 @@ function oe({
153
153
  alignItems: "center",
154
154
  justifyContent: "center",
155
155
  padding: 16,
156
- fontFamily: m
156
+ fontFamily: b
157
157
  },
158
158
  children: /* @__PURE__ */ r(
159
159
  "div",
@@ -176,7 +176,7 @@ function oe({
176
176
  c !== "list" && /* @__PURE__ */ e(
177
177
  "button",
178
178
  {
179
- onClick: () => a("list"),
179
+ onClick: () => s("list"),
180
180
  style: { background: "none", border: "none", cursor: "pointer", color: l, fontSize: 13, fontWeight: 600, padding: 0 },
181
181
  children: "← Back"
182
182
  }
@@ -188,7 +188,7 @@ function oe({
188
188
  c === "list" && /* @__PURE__ */ e(
189
189
  "button",
190
190
  {
191
- onClick: () => a("create"),
191
+ onClick: () => s("create"),
192
192
  style: { background: l, color: "#fff", border: "none", borderRadius: 20, padding: "6px 14px", fontSize: 13, fontWeight: 700, cursor: "pointer" },
193
193
  children: "+ New"
194
194
  }
@@ -196,7 +196,7 @@ function oe({
196
196
  /* @__PURE__ */ e(
197
197
  "button",
198
198
  {
199
- onClick: s,
199
+ onClick: a,
200
200
  style: { background: o.bgSoft, border: "none", width: 28, height: 28, borderRadius: 8, fontSize: 14, cursor: "pointer", color: o.textSoft, display: "flex", alignItems: "center", justifyContent: "center" },
201
201
  children: "✕"
202
202
  }
@@ -207,23 +207,23 @@ function oe({
207
207
  c === "list" && /* @__PURE__ */ e(
208
208
  V,
209
209
  {
210
- onSelect: D,
210
+ onSelect: M,
211
211
  accent: l,
212
212
  p: o
213
213
  }
214
214
  ),
215
- c === "detail" && b && /* @__PURE__ */ e(_, { feedbackId: b, accent: l, p: o, font: m }),
215
+ c === "detail" && m && /* @__PURE__ */ e(_, { feedbackId: m, accent: l, p: o, font: b }),
216
216
  c === "create" && /* @__PURE__ */ e(
217
217
  q,
218
218
  {
219
219
  accent: l,
220
220
  p: o,
221
- font: m,
222
- onDone: () => a("list")
221
+ font: b,
222
+ onDone: () => s("list")
223
223
  }
224
224
  )
225
225
  ] }),
226
- y && /* @__PURE__ */ r(
226
+ S && /* @__PURE__ */ r(
227
227
  "a",
228
228
  {
229
229
  href: "https://upstep.dev",
@@ -257,7 +257,7 @@ function V({
257
257
  accent: n,
258
258
  p: t
259
259
  }) {
260
- const { feedItems: h, vote: g } = B(), l = h.filter((o) => o.status !== "CLOSED");
260
+ const { feedItems: h, vote: p } = B(), l = h.filter((o) => o.status !== "CLOSED");
261
261
  return l.length ? /* @__PURE__ */ e(I, { children: l.map((o) => {
262
262
  const u = o.userVote === "UP", x = o.title ?? o.content;
263
263
  return /* @__PURE__ */ r(
@@ -279,7 +279,7 @@ function V({
279
279
  "button",
280
280
  {
281
281
  onClick: (d) => {
282
- d.stopPropagation(), g(o.id, "UP");
282
+ d.stopPropagation(), p(o.id, "UP");
283
283
  },
284
284
  style: {
285
285
  display: "flex",
@@ -306,7 +306,7 @@ function V({
306
306
  /* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", gap: 6, flexWrap: "wrap" }, children: [
307
307
  /* @__PURE__ */ e(T, { type: o.type, p: t }),
308
308
  o.status === "PENDING" ? /* @__PURE__ */ e(L, {}) : /* @__PURE__ */ e(U, { status: o.status, p: t }),
309
- /* @__PURE__ */ e("span", { style: { fontSize: 11, color: t.textFaint }, children: M(o.createdAt) })
309
+ /* @__PURE__ */ e("span", { style: { fontSize: 11, color: t.textFaint }, children: D(o.createdAt) })
310
310
  ] })
311
311
  ] }),
312
312
  /* @__PURE__ */ e("span", { style: { color: t.textFaint, fontSize: 18, alignSelf: "center", flexShrink: 0 }, children: "›" })
@@ -320,23 +320,23 @@ function V({
320
320
  ] });
321
321
  }
322
322
  function _({ feedbackId: i, accent: n, p: t, font: h }) {
323
- const { vote: g, getItem: l } = B(), [o, u] = p(null), [x, d] = p(!1);
323
+ const { vote: p, getItem: l } = B(), [o, u] = g(null), [x, d] = g(!1);
324
324
  z(() => {
325
- let a = !1;
326
- return l(i).then((b) => {
327
- a || u(b);
325
+ let s = !1;
326
+ return l(i).then((m) => {
327
+ s || u(m);
328
328
  }).catch(() => {
329
329
  }), () => {
330
- a = !0;
330
+ s = !0;
331
331
  };
332
332
  }, [i, l]);
333
- async function y() {
333
+ async function S() {
334
334
  if (!(!o || x)) {
335
335
  d(!0);
336
336
  try {
337
- await g(o.id, "UP");
338
- const a = await l(i);
339
- u(a);
337
+ await p(o.id, "UP");
338
+ const s = await l(i);
339
+ u(s);
340
340
  } catch {
341
341
  } finally {
342
342
  d(!1);
@@ -356,7 +356,7 @@ function _({ feedbackId: i, accent: n, p: t, font: h }) {
356
356
  /* @__PURE__ */ r(
357
357
  "button",
358
358
  {
359
- onClick: y,
359
+ onClick: S,
360
360
  disabled: x,
361
361
  style: {
362
362
  display: "inline-flex",
@@ -378,7 +378,7 @@ function _({ feedbackId: i, accent: n, p: t, font: h }) {
378
378
  ),
379
379
  o.comments.length > 0 && /* @__PURE__ */ r("div", { style: { marginTop: 28, borderTop: `1px solid ${t.border}`, paddingTop: 20 }, children: [
380
380
  /* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: t.textFaint, marginBottom: 12, textTransform: "uppercase" }, children: "Developer response" }),
381
- o.comments.map((a) => /* @__PURE__ */ e(Y, { comment: a, p: t, accent: n }, a.id))
381
+ o.comments.map((s) => /* @__PURE__ */ e(Y, { comment: s, p: t, accent: n }, s.id))
382
382
  ] })
383
383
  ] });
384
384
  }
@@ -386,31 +386,31 @@ function Y({ comment: i, p: n, accent: t }) {
386
386
  return /* @__PURE__ */ r("div", { style: { background: n.bgSoft, border: `1px solid ${n.border}`, borderRadius: 12, padding: 14, marginBottom: 10 }, children: [
387
387
  /* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 8 }, children: [
388
388
  /* @__PURE__ */ e("span", { style: { background: `${t}20`, color: t, fontSize: 11, fontWeight: 700, borderRadius: 20, padding: "2px 8px" }, children: "Developer" }),
389
- /* @__PURE__ */ e("span", { style: { fontSize: 11, color: n.textFaint }, children: M(i.createdAt) })
389
+ /* @__PURE__ */ e("span", { style: { fontSize: 11, color: n.textFaint }, children: D(i.createdAt) })
390
390
  ] }),
391
391
  /* @__PURE__ */ e("p", { style: { fontSize: 14, lineHeight: 1.5, color: n.textSoft, margin: 0 }, children: i.content })
392
392
  ] });
393
393
  }
394
394
  function q({ accent: i, p: n, font: t, onDone: h }) {
395
- const { submit: g } = B(), [l, o] = p(""), [u, x] = p(""), [d, y] = p("GENERAL"), [c, a] = p(!1), [b, F] = p(!1), [S, f] = p("");
396
- async function v() {
395
+ const { submit: p } = B(), [l, o] = g(""), [u, x] = g(""), [d, S] = g("GENERAL"), [c, s] = g(!1), [m, F] = g(!1), [v, f] = g("");
396
+ async function k() {
397
397
  if (!(!l.trim() || c)) {
398
- a(!0), f("");
398
+ s(!0), f("");
399
399
  try {
400
- await g(l.trim(), u.trim() || l.trim(), d), F(!0), setTimeout(h, 1200);
400
+ await p(l.trim(), u.trim() || l.trim(), d), F(!0), setTimeout(h, 1200);
401
401
  } catch {
402
402
  f("Something went wrong. Please try again.");
403
403
  } finally {
404
- a(!1);
404
+ s(!1);
405
405
  }
406
406
  }
407
407
  }
408
- if (b)
408
+ if (m)
409
409
  return /* @__PURE__ */ r("div", { style: { textAlign: "center", paddingTop: 40 }, children: [
410
410
  /* @__PURE__ */ e("div", { style: { fontSize: 18, fontWeight: 700, color: n.text, marginBottom: 6 }, children: "Submitted" }),
411
411
  /* @__PURE__ */ e("div", { style: { fontSize: 14, color: n.textFaint }, children: "Feedback received. Thank you." })
412
412
  ] });
413
- const m = {
413
+ const b = {
414
414
  width: "100%",
415
415
  border: `1px solid ${n.border}`,
416
416
  borderRadius: 12,
@@ -425,10 +425,10 @@ function q({ accent: i, p: n, font: t, onDone: h }) {
425
425
  };
426
426
  return /* @__PURE__ */ r("div", { children: [
427
427
  /* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: n.textFaint, marginBottom: 8, textTransform: "uppercase" }, children: "Type" }),
428
- /* @__PURE__ */ e("div", { style: { display: "flex", gap: 7, marginBottom: 16 }, children: ["BUG", "FEATURE", "GENERAL"].map((s) => /* @__PURE__ */ r(
428
+ /* @__PURE__ */ e("div", { style: { display: "flex", gap: 7, marginBottom: 16 }, children: ["BUG", "FEATURE", "GENERAL"].map((a) => /* @__PURE__ */ r(
429
429
  "button",
430
430
  {
431
- onClick: () => y(s),
431
+ onClick: () => S(a),
432
432
  style: {
433
433
  flex: 1,
434
434
  display: "flex",
@@ -440,27 +440,27 @@ function q({ accent: i, p: n, font: t, onDone: h }) {
440
440
  fontSize: 12.5,
441
441
  fontWeight: 600,
442
442
  cursor: "pointer",
443
- background: d === s ? i : n.bg,
444
- color: d === s ? "#fff" : n.textSoft,
445
- border: `1px solid ${d === s ? i : n.border}`,
443
+ background: d === a ? i : n.bg,
444
+ color: d === a ? "#fff" : n.textSoft,
445
+ border: `1px solid ${d === a ? i : n.border}`,
446
446
  fontFamily: t
447
447
  },
448
448
  children: [
449
- W[s].icon,
450
- W[s].label
449
+ W[a].icon,
450
+ W[a].label
451
451
  ]
452
452
  },
453
- s
453
+ a
454
454
  )) }),
455
455
  /* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: n.textFaint, marginBottom: 8, textTransform: "uppercase" }, children: "Title" }),
456
456
  /* @__PURE__ */ e(
457
457
  "input",
458
458
  {
459
459
  value: l,
460
- onChange: (s) => o(s.target.value),
460
+ onChange: (a) => o(a.target.value),
461
461
  placeholder: "Short summary of the issue or idea",
462
462
  maxLength: 200,
463
- style: { ...m, marginBottom: 16, display: "block" }
463
+ style: { ...b, marginBottom: 16, display: "block" }
464
464
  }
465
465
  ),
466
466
  /* @__PURE__ */ r("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: n.textFaint, marginBottom: 8, textTransform: "uppercase" }, children: [
@@ -471,18 +471,18 @@ function q({ accent: i, p: n, font: t, onDone: h }) {
471
471
  "textarea",
472
472
  {
473
473
  value: u,
474
- onChange: (s) => x(s.target.value),
474
+ onChange: (a) => x(a.target.value),
475
475
  placeholder: "Steps to reproduce, expected behaviour, or more context",
476
476
  maxLength: 2e3,
477
477
  rows: 4,
478
- style: { ...m, resize: "vertical", marginBottom: 16 }
478
+ style: { ...b, resize: "vertical", marginBottom: 16 }
479
479
  }
480
480
  ),
481
- S && /* @__PURE__ */ e("p", { style: { fontSize: 13, color: "#d6453d", marginBottom: 12 }, children: S }),
481
+ v && /* @__PURE__ */ e("p", { style: { fontSize: 13, color: "#d6453d", marginBottom: 12 }, children: v }),
482
482
  /* @__PURE__ */ e(
483
483
  "button",
484
484
  {
485
- onClick: v,
485
+ onClick: k,
486
486
  disabled: c || !l.trim(),
487
487
  style: {
488
488
  width: "100%",
@@ -558,7 +558,7 @@ function X({ size: i = 16, color: n = "currentColor" }) {
558
558
  function R({ color: i = "currentColor", size: n = 11 }) {
559
559
  return /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 16 16", fill: "none", stroke: i, strokeWidth: 2.2, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M8 13V3M3 8l5-5 5 5" }) });
560
560
  }
561
- function M(i) {
561
+ function D(i) {
562
562
  return new Date(i).toLocaleDateString(void 0, { month: "short", day: "numeric" });
563
563
  }
564
564
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upstep/js",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "Upstep feedback widget for web apps",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",