@upstep/js 0.5.4 → 0.5.6
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/index.cjs +38 -37
- package/dist/index.js +131 -96
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +222 -236
- package/dist/widget.d.ts +2 -0
- package/dist/widget.d.ts.map +1 -1
- package/package.json +2 -2
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"),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;
|
|
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;
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.t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