@upstep/js 0.11.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),Y=require("./api-j3GMTEE7.js"),x=require("./theme.cjs"),J='-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';function P(o,t){return x.withAlpha(o,t)??`color-mix(in srgb, ${o} ${Math.round(t*100)}%, transparent)`}function M(){if(typeof document>"u")return!1;const o=document.documentElement;return o.classList.contains("dark")||o.getAttribute("data-theme")==="dark"}function K(o,t){const[n,u]=a.useState(()=>o==="dark");a.useEffect(()=>{if(o!=="auto"){u(o==="dark");return}if(u(M()),typeof MutationObserver>"u")return;const l=new MutationObserver(()=>u(M()));return l.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"]}),()=>l.disconnect()},[o]);const{accentColor:c,colors:m,radius:r}=t;return a.useMemo(()=>x.buildWidgetPalette({mode:n?"dark":"light",accentColor:c,colors:m,radius:r}),[n,c,JSON.stringify(m??null),r])}const D=a.createContext(null);function Q({children:o,...t}){const[n]=a.useState(()=>new Y.UpstepApiClient(t)),[u,c]=a.useState([]),[m,r]=a.useState(!1),[l,S]=a.useState(!0);a.useEffect(()=>{n.setUserId(t.userId)},[n,t.userId]),a.useEffect(()=>{n.supportIdentityToken=t.supportIdentityToken,document.querySelectorAll("iframe[data-upstep-support]").forEach(f=>{var k;return(k=f.contentWindow)==null?void 0:k.postMessage({type:"upstep:support:identity",token:t.supportIdentityToken},new URL(n.baseUrl).origin)})},[n,t.supportIdentityToken]);const i=a.useCallback(async()=>{try{const f=await n.listFeedback({sort:"votes",limit:20});c(f.items),S(f.showBranding??!0)}catch{}},[n]);a.useEffect(()=>{i()},[i]);const y=a.useCallback(async(f,k,p)=>{const b={content:k};f.trim()&&(b.title=f.trim()),p!==void 0&&(b.type=p),await n.submitFeedback(b),await i()},[n,i]),s=a.useCallback(async(f,k)=>{try{await n.vote(f,k),await i()}catch{}},[n,i]),d=a.useCallback(f=>n.getItem(f),[n]),j=a.useCallback(()=>r(!0),[]),v=a.useCallback(()=>r(!1),[]),C=a.useCallback(f=>n.setUserId(f),[n]);return e.jsx(D.Provider,{value:{client:n,feedItems:u,loadFeed:i,submit:y,vote:s,getItem:d,isOpen:m,open:j,close:v,identify:C,accentColor:t.accentColor??x.DEFAULT_ACCENT,customAccentColor:t.accentColor,theme:t.theme??"auto",colors:t.colors,radius:t.radius,fontFamily:t.fontFamily,showBranding:l,chat:t.chat!==!1,feedback:t.feedback!==!1},children:o})}function R(){const o=a.useContext(D);if(!o)throw new Error("useUpstep must be used inside <UpstepProvider>");return o}function X({position:o="bottom-right",accentColor:t,theme:n,colors:u,radius:c,fontFamily:m,hideLauncher:r=!1,chat:l=!0,feedback:S}){var L;const i=R(),y=(S??!0)&&i.feedback,s=K(n??i.theme,{accentColor:t??i.customAccentColor,colors:u??i.colors,radius:c??i.radius}),d=s.accent,j={colors:u??i.colors,radius:c??i.radius,fontFamily:m??i.fontFamily},{isOpen:v,open:C,close:f,showBranding:k}=i,[p,b]=a.useState("list"),[h,I]=a.useState(!1),F=h&&l&&i.chat;a.useEffect(()=>{let g=!0;if(i.client.chat=i.chat,!i.chat||!l){I(!1);return}return i.client.supportEnabled().then(w=>{g&&I(w)}),()=>{g=!1}},[i.client,i.chat,l]),a.useEffect(()=>{(!i.chat||!l)&&p==="support"&&b("list")},[i.chat,l,p]),a.useEffect(()=>{v&&b(h&&l&&i.chat?"support":"list")},[v,h,l,i.chat]);const[W,B]=a.useState(null),[T,U]=a.useState(!1);a.useEffect(()=>{const g=window.matchMedia("(max-width: 639px)");U(g.matches);const w=q=>U(q.matches);return g.addEventListener("change",w),()=>g.removeEventListener("change",w)},[]);const V={position:"fixed",bottom:24,right:24},E=((L=j.fontFamily)==null?void 0:L.trim())||J;function z(){f(),B(null)}function _(g){B(g),b("detail")}return e.jsxs(e.Fragment,{children:[!r&&(y||F)&&e.jsxs("button",{"aria-label":y?"Open help and feedback":"Open support chat",onClick:C,style:{...V,zIndex:9998,display:"inline-flex",alignItems:"center",gap:7,background:d,color:s.accentText,border:"none",borderRadius:x.scaleRadius(9999,s.radius),padding:T?"12px":"12px 18px",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:E,boxShadow:"0 6px 20px rgba(26,25,21,.18)"},children:[e.jsx(ae,{size:16}),!T&&(F?y?"Help & feedback":"Help":"Feedback")]}),v&&(y||F)&&e.jsx("div",{onClick:g=>g.target===g.currentTarget&&z(),style:{position:"fixed",inset:0,background:"transparent",zIndex:9999,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:T?"0 12px 80px":"0 24px 88px",fontFamily:E},children:e.jsxs("div",{style:{background:s.bg,border:`1px solid ${s.border}`,borderRadius:x.scaleRadius(20,s.radius),width:"100%",maxWidth:h&&l&&i.chat?460:440,maxHeight:"calc(100dvh - 112px)",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 64px rgba(0,0,0,.28)"},children:[F&&!y?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"14px 16px 14px 20px",borderBottom:`1px solid ${s.border}`,flexShrink:0},children:[e.jsx("span",{style:{flex:1,fontSize:16,fontWeight:600,color:s.text},children:"Support"}),e.jsx("button",{"aria-label":"Close",onClick:z,style:{border:0,background:"transparent",color:s.textSoft,padding:6,cursor:"pointer",fontSize:14},children:"✕"})]}):F?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"10px 14px",borderBottom:`1px solid ${s.border}`,flexShrink:0},children:[e.jsx("div",{style:{display:"flex",flex:1,gap:4},children:[["support","Support"],["list","Ideas"]].map(([g,w])=>e.jsx("button",{onClick:()=>b(g),style:{flex:1,border:0,borderRadius:x.scaleRadius(8,s.radius),padding:"9px 12px",background:(p==="support"?g==="support":g==="list")?s.bgSoft:"transparent",color:(p==="support"?g==="support":g==="list")?s.text:s.textSoft,fontSize:14,fontWeight:600,cursor:"pointer"},children:w},g))}),e.jsx("button",{"aria-label":"Close",onClick:z,style:{border:0,background:"transparent",color:s.textSoft,padding:6,cursor:"pointer",fontSize:14},children:"✕"})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${s.border}`,flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[p!=="list"&&e.jsx("button",{onClick:()=>b("list"),style:{background:"none",border:"none",cursor:"pointer",color:d,fontSize:14,fontWeight:600,padding:0},children:"← Back"}),p==="list"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:s.text,letterSpacing:"-.01em"},children:"Feedback"}),p==="create"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:s.text,letterSpacing:"-.01em"},children:"New feedback"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[p==="list"&&e.jsx("button",{onClick:()=>b("create"),style:{background:d,color:s.accentText,border:"none",borderRadius:x.scaleRadius(20,s.radius),padding:"6px 14px",fontSize:14,fontWeight:700,cursor:"pointer"},children:"+ New"}),e.jsx("button",{onClick:z,style:{background:s.bgSoft,border:"none",width:28,height:28,borderRadius:x.scaleRadius(8,s.radius),fontSize:14,cursor:"pointer",color:s.textSoft,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:p==="support"?0:"16px 20px 24px"},children:[p==="support"&&l&&i.chat&&e.jsx(Z,{client:i.client,accentColor:d,theme:s.dark?"dark":"light",appearance:j}),h&&l&&i.chat&&p!=="support"&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:p==="list"?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:14,fontWeight:600,color:s.text},children:"Ideas"}),e.jsx("button",{onClick:()=>b("create"),style:{border:0,borderRadius:x.scaleRadius(8,s.radius),background:d,color:s.accentText,fontSize:14,padding:"7px 10px",cursor:"pointer"},children:"+ Suggest an idea"})]}):e.jsx("button",{onClick:()=>b("list"),style:{border:0,background:"none",padding:0,color:s.textSoft,fontSize:14,cursor:"pointer"},children:"← Back to ideas"})}),p==="list"&&e.jsx(ee,{onSelect:_,accent:d,p:s}),p==="detail"&&W&&e.jsx(te,{feedbackId:W,accent:d,p:s,font:E}),p==="create"&&e.jsx(oe,{accent:d,p:s,font:E,ideasOnly:!!(h&&l&&i.chat),onDone:()=>b("list")})]}),k&&p!=="support"&&e.jsxs("a",{href:"https://upstep.dev",target:"_blank",rel:"noopener noreferrer",style:{display:"block",textAlign:"center",padding:"8px 0",borderTop:`1px solid ${s.border}`,fontSize:11,color:s.textFaint,textDecoration:"none",flexShrink:0},children:["Powered by"," ",e.jsx("strong",{style:{fontWeight:700},children:"Upstep.dev"})]})]})})]})}function Z({client:o,theme:t,accentColor:n,appearance:u}){const c=a.useRef(null);return a.useEffect(()=>{if(c.current)return o.connectSupportFrame(c.current)},[o]),e.jsx("iframe",{ref:c,"data-upstep-support":!0,title:"Customer support",src:o.supportFrameUrl(t,n,u),style:{color:n,width:"100%",height:"min(560px, calc(100dvh - 168px))",minHeight:300,border:0,display:"block"}})}function ee({onSelect:o,accent:t,p:n}){const{feedItems:u,vote:c}=R(),m=u.filter(r=>r.status!=="CLOSED");return m.length?e.jsx(e.Fragment,{children:m.map(r=>{const l=r.userVote==="UP",S=r.title??r.content;return e.jsxs("div",{onClick:()=>o(r.id),style:{display:"flex",gap:12,padding:14,border:`1px solid ${n.border}`,borderRadius:x.scaleRadius(14,n.radius),marginBottom:10,background:n.bg,cursor:"pointer"},children:[e.jsxs("button",{onClick:i=>{i.stopPropagation(),c(r.id,"UP")},style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,minWidth:46,padding:"7px 0",borderRadius:x.scaleRadius(11,n.radius),cursor:"pointer",flexShrink:0,border:`1px solid ${l?t:n.border}`,background:l?n.accentTint:n.bgSoft},children:[e.jsx(O,{color:t}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:n.text,lineHeight:1.1},children:r.upvotes})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:14,fontWeight:600,lineHeight:1.4,color:n.text,margin:"0 0 6px",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:S}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx(N,{type:r.type,p:n}),r.status==="PENDING"?e.jsx(H,{}):e.jsx($,{status:r.status,boardStatus:r.boardStatus,p:n}),e.jsx("span",{style:{fontSize:11,color:n.textFaint},children:G(r.createdAt)})]})]}),e.jsx("span",{style:{color:n.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:n.textSoft,fontSize:15,fontWeight:600,marginBottom:4},children:"No open feedback yet"}),e.jsx("div",{style:{color:n.textFaint,fontSize:14},children:"Be the first to share one."})]})}function te({feedbackId:o,accent:t,p:n,font:u}){const{vote:c,getItem:m}=R(),[r,l]=a.useState(null),[S,i]=a.useState(!1);a.useEffect(()=>{let d=!1;return m(o).then(j=>{d||l(j)}).catch(()=>{}),()=>{d=!0}},[o,m]);async function y(){if(!(!r||S)){i(!0);try{await c(r.id,"UP");const d=await m(o);l(d)}catch{}finally{i(!1)}}}if(!r)return e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:n.textFaint,fontSize:14},children:"Loading…"});const s=r.title;return e.jsxs("div",{children:[s&&e.jsx("div",{style:{fontSize:20,fontWeight:700,color:n.text,letterSpacing:"-.02em",marginBottom:10,lineHeight:1.3},children:s}),e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:14,flexWrap:"wrap"},children:[e.jsx(N,{type:r.type,p:n}),r.status==="PENDING"?e.jsx(H,{}):e.jsx($,{status:r.status,boardStatus:r.boardStatus,p:n})]}),e.jsx("p",{style:{fontSize:15,lineHeight:1.6,color:n.textSoft,marginBottom:20},children:r.content}),e.jsxs("button",{onClick:y,disabled:S,style:{display:"inline-flex",alignItems:"center",gap:8,border:`1px solid ${r.userVote==="UP"?t:n.border}`,background:r.userVote==="UP"?P(t,.08):n.bgSoft,borderRadius:x.scaleRadius(12,n.radius),padding:"10px 16px",cursor:"pointer",fontFamily:u},children:[e.jsx(O,{color:t,size:13}),e.jsx("span",{style:{fontSize:18,fontWeight:700,color:n.text},children:r.upvotes}),e.jsx("span",{style:{fontSize:14,color:n.textFaint},children:r.userVote==="UP"?"Upvoted":"Upvote"})]}),r.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:"Comments"}),r.comments.map(d=>e.jsx(ne,{comment:d,p:n,accent:t},d.id))]})]})}function ne({comment:o,p:t,accent:n}){var u;return e.jsxs("div",{style:{background:t.bgSoft,border:`1px solid ${t.border}`,borderRadius:x.scaleRadius(12,t.radius),padding:14,marginBottom:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("span",{style:{background:P(n,.125),color:n,fontSize:11,fontWeight:700,borderRadius:x.scaleRadius(20,t.radius),padding:"2px 8px"},children:((u=o.authorName)==null?void 0:u.trim())||"UpStep Team"}),e.jsx("span",{style:{fontSize:11,color:t.textFaint},children:G(o.createdAt)})]}),e.jsx("p",{style:{fontSize:16,lineHeight:1.6,color:t.textSoft,margin:0},children:o.content})]})}function oe({accent:o,p:t,font:n,onDone:u,ideasOnly:c=!1}){const{submit:m}=R(),[r,l]=a.useState(""),[S,i]=a.useState(""),[y,s]=a.useState(c?"FEATURE":"GENERAL"),[d,j]=a.useState(!1),[v,C]=a.useState(!1),[f,k]=a.useState("");async function p(){if(!(!r.trim()||d)){j(!0),k("");try{await m(r.trim(),S.trim()||r.trim(),y),C(!0),setTimeout(u,1200)}catch{k("Something went wrong. Please try again.")}finally{j(!1)}}}if(v)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:c?"Idea received. Thank you.":"Feedback received. Thank you."})]});const b={width:"100%",border:`1px solid ${t.border}`,borderRadius:x.scaleRadius(12,t.radius),padding:"10px 12px",fontSize:16,lineHeight:1.6,outline:"none",background:t.bgSoft,color:t.text,fontFamily:n,boxSizing:"border-box"};return e.jsxs("div",{children:[!c&&e.jsxs(e.Fragment,{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(h=>e.jsxs("button",{onClick:()=>s(h),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"8px 10px",borderRadius:x.scaleRadius(9,t.radius),fontSize:14,fontWeight:600,cursor:"pointer",background:y===h?o:t.bg,color:y===h?t.accentText:t.textSoft,border:`1px solid ${y===h?o:t.border}`,fontFamily:n},children:[A[h].icon,A[h].label]},h))})]}),e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:t.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Title"}),e.jsx("input",{value:r,onChange:h=>l(h.target.value),placeholder:c?"What would you like us to build?":"Short summary of the issue or idea",maxLength:200,style:{...b,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:h=>i(h.target.value),placeholder:c?"Why would it help? (optional)":"Steps to reproduce, expected behaviour, or more context",maxLength:2e3,rows:4,style:{...b,resize:"vertical",marginBottom:16}}),f&&e.jsx("p",{style:{fontSize:14,color:"#d6453d",marginBottom:12},children:f}),e.jsx("button",{onClick:p,disabled:d||!r.trim(),style:{width:"100%",padding:12,background:o,color:t.accentText,border:"none",borderRadius:x.scaleRadius(11,t.radius),fontSize:14,fontWeight:600,cursor:"pointer",opacity:d||!r.trim()?.5:1,fontFamily:n},children:d?"Submitting…":c?"Suggest idea":"Submit feedback"})]})}const A={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"})})}},re={BUG:"#fdecec",FEATURE:"#e9f0fd"},ie={BUG:"#d6453d",FEATURE:"#3b76d6"};function N({type:o,p:t}){return e.jsx("span",{style:{padding:"2px 8px",borderRadius:x.scaleRadius(9999,t.radius),fontSize:10.5,fontWeight:700,letterSpacing:".02em",background:re[o]??t.bgSoft,color:ie[o]??t.textSoft},children:o})}const se={OPEN:"#b45309",IN_PROGRESS:"#1d4ed8",DONE:"#15803d",CLOSED:"#6b7280"};function H(){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 $({status:o,boardStatus:t,p:n}){const u=(t==null?void 0:t.color)??se[o]??"#9ca3af";return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,background:n.bgSoft,border:`1px solid ${n.border}`,borderRadius:x.scaleRadius(6,n.radius),padding:"2px 8px",fontSize:10,fontWeight:600,color:n.textSoft},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:u,display:"inline-block",flexShrink:0}}),(t==null?void 0:t.name)??o.replace("_"," ")]})}function ae({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 O({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 G(o){return new Date(o).toLocaleDateString(void 0,{month:"short",day:"numeric"})}exports.FeedbackWidget=X;exports.UpstepProvider=Q;exports.useUpstep=R;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),Y=require("./api-j3GMTEE7.js"),f=require("./theme.cjs"),J='-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';function P(o,t){return f.withAlpha(o,t)??`color-mix(in srgb, ${o} ${Math.round(t*100)}%, transparent)`}function M(){if(typeof document>"u")return!1;const o=document.documentElement;return o.classList.contains("dark")||o.getAttribute("data-theme")==="dark"}function K(o,t){const[n,x]=a.useState(()=>o==="dark");a.useEffect(()=>{if(o!=="auto"){x(o==="dark");return}if(x(M()),typeof MutationObserver>"u")return;const d=new MutationObserver(()=>x(M()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"]}),()=>d.disconnect()},[o]);const{accentColor:u,colors:b,radius:r}=t;return a.useMemo(()=>f.buildWidgetPalette({mode:n?"dark":"light",accentColor:u,colors:b,radius:r}),[n,u,JSON.stringify(b??null),r])}const D=a.createContext(null);function Q({children:o,...t}){const[n]=a.useState(()=>new Y.UpstepApiClient(t)),[x,u]=a.useState([]),[b,r]=a.useState(!1),[d,S]=a.useState(!0);a.useEffect(()=>{n.setUserId(t.userId)},[n,t.userId]),a.useEffect(()=>{n.supportIdentityToken=t.supportIdentityToken,document.querySelectorAll("iframe[data-upstep-support]").forEach(h=>{var l;return(l=h.contentWindow)==null?void 0:l.postMessage({type:"upstep:support:identity",token:t.supportIdentityToken},new URL(n.baseUrl).origin)})},[n,t.supportIdentityToken]);const i=a.useCallback(async()=>{try{const h=await n.listFeedback({sort:"votes",limit:20});u(h.items),S(h.showBranding??!0)}catch{}},[n]),m=t.feedback!==!1;a.useEffect(()=>{m&&i()},[i,m]);const s=a.useCallback(async(h,l,y)=>{const p={content:l};h.trim()&&(p.title=h.trim()),y!==void 0&&(p.type=y),await n.submitFeedback(p),await i()},[n,i]),c=a.useCallback(async(h,l)=>{try{await n.vote(h,l),await i()}catch{}},[n,i]),k=a.useCallback(h=>n.getItem(h),[n]),j=a.useCallback(()=>r(!0),[]),C=a.useCallback(()=>r(!1),[]),v=a.useCallback(h=>n.setUserId(h),[n]);return e.jsx(D.Provider,{value:{client:n,feedItems:x,loadFeed:i,submit:s,vote:c,getItem:k,isOpen:b,open:j,close:C,identify:v,accentColor:t.accentColor??f.DEFAULT_ACCENT,customAccentColor:t.accentColor,theme:t.theme??"auto",colors:t.colors,radius:t.radius,fontFamily:t.fontFamily,showBranding:d,chat:t.chat!==!1,feedback:t.feedback!==!1},children:o})}function R(){const o=a.useContext(D);if(!o)throw new Error("useUpstep must be used inside <UpstepProvider>");return o}function X({position:o="bottom-right",accentColor:t,theme:n,colors:x,radius:u,fontFamily:b,hideLauncher:r=!1,chat:d=!0,feedback:S}){var L;const i=R(),m=(S??!0)&&i.feedback,s=K(n??i.theme,{accentColor:t??i.customAccentColor,colors:x??i.colors,radius:u??i.radius}),c=s.accent,k={colors:x??i.colors,radius:u??i.radius,fontFamily:b??i.fontFamily},{isOpen:j,open:C,close:v,showBranding:h}=i,[l,y]=a.useState("list"),[p,I]=a.useState(!1),F=p&&d&&i.chat;a.useEffect(()=>{let g=!0;if(i.client.chat=i.chat,!i.chat||!d){I(!1);return}return i.client.supportEnabled().then(w=>{g&&I(w)}),()=>{g=!1}},[i.client,i.chat,d]),a.useEffect(()=>{(!i.chat||!d)&&l==="support"&&y("list")},[i.chat,d,l]),a.useEffect(()=>{j&&y(p&&d&&i.chat?"support":"list")},[j,p,d,i.chat]);const[W,B]=a.useState(null),[T,U]=a.useState(!1);a.useEffect(()=>{const g=window.matchMedia("(max-width: 639px)");U(g.matches);const w=q=>U(q.matches);return g.addEventListener("change",w),()=>g.removeEventListener("change",w)},[]);const V={position:"fixed",bottom:24,right:24},E=((L=k.fontFamily)==null?void 0:L.trim())||J;function z(){v(),B(null)}function _(g){B(g),y("detail")}return e.jsxs(e.Fragment,{children:[!r&&(m||F)&&e.jsxs("button",{"aria-label":m?"Open help and feedback":"Open support chat",onClick:C,style:{...V,zIndex:9998,display:"inline-flex",alignItems:"center",gap:7,background:c,color:s.accentText,border:"none",borderRadius:f.scaleRadius(9999,s.radius),padding:T?"12px":"12px 18px",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:E,boxShadow:"0 6px 20px rgba(26,25,21,.18)"},children:[e.jsx(ae,{size:16}),!T&&(F?m?"Help & feedback":"Help":"Feedback")]}),j&&(m||F)&&e.jsx("div",{onClick:g=>g.target===g.currentTarget&&z(),style:{position:"fixed",inset:0,background:"transparent",zIndex:9999,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:T?"0 12px 80px":"0 24px 88px",fontFamily:E},children:e.jsxs("div",{style:{background:s.bg,border:`1px solid ${s.border}`,borderRadius:f.scaleRadius(20,s.radius),width:"100%",maxWidth:p&&d&&i.chat?460:440,maxHeight:"calc(100dvh - 112px)",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 64px rgba(0,0,0,.28)"},children:[F&&!m?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"14px 16px 14px 20px",borderBottom:`1px solid ${s.border}`,flexShrink:0},children:[e.jsx("span",{style:{flex:1,fontSize:16,fontWeight:600,color:s.text},children:"Support"}),e.jsx("button",{"aria-label":"Close",onClick:z,style:{border:0,background:"transparent",color:s.textSoft,padding:6,cursor:"pointer",fontSize:14},children:"✕"})]}):F?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"10px 14px",borderBottom:`1px solid ${s.border}`,flexShrink:0},children:[e.jsx("div",{style:{display:"flex",flex:1,gap:4},children:[["support","Support"],["list","Ideas"]].map(([g,w])=>e.jsx("button",{onClick:()=>y(g),style:{flex:1,border:0,borderRadius:f.scaleRadius(8,s.radius),padding:"9px 12px",background:(l==="support"?g==="support":g==="list")?s.bgSoft:"transparent",color:(l==="support"?g==="support":g==="list")?s.text:s.textSoft,fontSize:14,fontWeight:600,cursor:"pointer"},children:w},g))}),e.jsx("button",{"aria-label":"Close",onClick:z,style:{border:0,background:"transparent",color:s.textSoft,padding:6,cursor:"pointer",fontSize:14},children:"✕"})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${s.border}`,flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[l!=="list"&&e.jsx("button",{onClick:()=>y("list"),style:{background:"none",border:"none",cursor:"pointer",color:c,fontSize:14,fontWeight:600,padding:0},children:"← Back"}),l==="list"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:s.text,letterSpacing:"-.01em"},children:"Feedback"}),l==="create"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:s.text,letterSpacing:"-.01em"},children:"New feedback"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[l==="list"&&e.jsx("button",{onClick:()=>y("create"),style:{background:c,color:s.accentText,border:"none",borderRadius:f.scaleRadius(20,s.radius),padding:"6px 14px",fontSize:14,fontWeight:700,cursor:"pointer"},children:"+ New"}),e.jsx("button",{onClick:z,style:{background:s.bgSoft,border:"none",width:28,height:28,borderRadius:f.scaleRadius(8,s.radius),fontSize:14,cursor:"pointer",color:s.textSoft,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:l==="support"?0:"16px 20px 24px"},children:[l==="support"&&d&&i.chat&&e.jsx(Z,{client:i.client,accentColor:c,theme:s.dark?"dark":"light",appearance:k}),p&&d&&i.chat&&l!=="support"&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:l==="list"?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:14,fontWeight:600,color:s.text},children:"Ideas"}),e.jsx("button",{onClick:()=>y("create"),style:{border:0,borderRadius:f.scaleRadius(8,s.radius),background:c,color:s.accentText,fontSize:14,padding:"7px 10px",cursor:"pointer"},children:"+ Suggest an idea"})]}):e.jsx("button",{onClick:()=>y("list"),style:{border:0,background:"none",padding:0,color:s.textSoft,fontSize:14,cursor:"pointer"},children:"← Back to ideas"})}),l==="list"&&e.jsx(ee,{onSelect:_,accent:c,p:s}),l==="detail"&&W&&e.jsx(te,{feedbackId:W,accent:c,p:s,font:E}),l==="create"&&e.jsx(oe,{accent:c,p:s,font:E,ideasOnly:!!(p&&d&&i.chat),onDone:()=>y("list")})]}),h&&l!=="support"&&e.jsxs("a",{href:"https://upstep.dev",target:"_blank",rel:"noopener noreferrer",style:{display:"block",textAlign:"center",padding:"8px 0",borderTop:`1px solid ${s.border}`,fontSize:11,color:s.textFaint,textDecoration:"none",flexShrink:0},children:["Powered by"," ",e.jsx("strong",{style:{fontWeight:700},children:"Upstep.dev"})]})]})})]})}function Z({client:o,theme:t,accentColor:n,appearance:x}){const u=a.useRef(null);return a.useEffect(()=>{if(u.current)return o.connectSupportFrame(u.current)},[o]),e.jsx("iframe",{ref:u,"data-upstep-support":!0,title:"Customer support",src:o.supportFrameUrl(t,n,x),style:{color:n,width:"100%",height:"min(560px, calc(100dvh - 168px))",minHeight:300,border:0,display:"block"}})}function ee({onSelect:o,accent:t,p:n}){const{feedItems:x,vote:u}=R(),b=x.filter(r=>r.status!=="CLOSED");return b.length?e.jsx(e.Fragment,{children:b.map(r=>{const d=r.userVote==="UP",S=r.title??r.content;return e.jsxs("div",{onClick:()=>o(r.id),style:{display:"flex",gap:12,padding:14,border:`1px solid ${n.border}`,borderRadius:f.scaleRadius(14,n.radius),marginBottom:10,background:n.bg,cursor:"pointer"},children:[e.jsxs("button",{onClick:i=>{i.stopPropagation(),u(r.id,"UP")},style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,minWidth:46,padding:"7px 0",borderRadius:f.scaleRadius(11,n.radius),cursor:"pointer",flexShrink:0,border:`1px solid ${d?t:n.border}`,background:d?n.accentTint:n.bgSoft},children:[e.jsx($,{color:t}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:n.text,lineHeight:1.1},children:r.upvotes})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:14,fontWeight:600,lineHeight:1.4,color:n.text,margin:"0 0 6px",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:S}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx(N,{type:r.type,p:n}),r.status==="PENDING"?e.jsx(H,{}):e.jsx(O,{status:r.status,boardStatus:r.boardStatus,p:n}),e.jsx("span",{style:{fontSize:11,color:n.textFaint},children:G(r.createdAt)})]})]}),e.jsx("span",{style:{color:n.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:n.textSoft,fontSize:15,fontWeight:600,marginBottom:4},children:"No open feedback yet"}),e.jsx("div",{style:{color:n.textFaint,fontSize:14},children:"Be the first to share one."})]})}function te({feedbackId:o,accent:t,p:n,font:x}){const{vote:u,getItem:b}=R(),[r,d]=a.useState(null),[S,i]=a.useState(!1);a.useEffect(()=>{let c=!1;return b(o).then(k=>{c||d(k)}).catch(()=>{}),()=>{c=!0}},[o,b]);async function m(){if(!(!r||S)){i(!0);try{await u(r.id,"UP");const c=await b(o);d(c)}catch{}finally{i(!1)}}}if(!r)return e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:n.textFaint,fontSize:14},children:"Loading…"});const s=r.title;return e.jsxs("div",{children:[s&&e.jsx("div",{style:{fontSize:20,fontWeight:700,color:n.text,letterSpacing:"-.02em",marginBottom:10,lineHeight:1.3},children:s}),e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:14,flexWrap:"wrap"},children:[e.jsx(N,{type:r.type,p:n}),r.status==="PENDING"?e.jsx(H,{}):e.jsx(O,{status:r.status,boardStatus:r.boardStatus,p:n})]}),e.jsx("p",{style:{fontSize:15,lineHeight:1.6,color:n.textSoft,marginBottom:20},children:r.content}),e.jsxs("button",{onClick:m,disabled:S,style:{display:"inline-flex",alignItems:"center",gap:8,border:`1px solid ${r.userVote==="UP"?t:n.border}`,background:r.userVote==="UP"?P(t,.08):n.bgSoft,borderRadius:f.scaleRadius(12,n.radius),padding:"10px 16px",cursor:"pointer",fontFamily:x},children:[e.jsx($,{color:t,size:13}),e.jsx("span",{style:{fontSize:18,fontWeight:700,color:n.text},children:r.upvotes}),e.jsx("span",{style:{fontSize:14,color:n.textFaint},children:r.userVote==="UP"?"Upvoted":"Upvote"})]}),r.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:"Comments"}),r.comments.map(c=>e.jsx(ne,{comment:c,p:n,accent:t},c.id))]})]})}function ne({comment:o,p:t,accent:n}){var x;return e.jsxs("div",{style:{background:t.bgSoft,border:`1px solid ${t.border}`,borderRadius:f.scaleRadius(12,t.radius),padding:14,marginBottom:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("span",{style:{background:P(n,.125),color:n,fontSize:11,fontWeight:700,borderRadius:f.scaleRadius(20,t.radius),padding:"2px 8px"},children:((x=o.authorName)==null?void 0:x.trim())||"UpStep Team"}),e.jsx("span",{style:{fontSize:11,color:t.textFaint},children:G(o.createdAt)})]}),e.jsx("p",{style:{fontSize:16,lineHeight:1.6,color:t.textSoft,margin:0},children:o.content})]})}function oe({accent:o,p:t,font:n,onDone:x,ideasOnly:u=!1}){const{submit:b}=R(),[r,d]=a.useState(""),[S,i]=a.useState(""),[m,s]=a.useState(u?"FEATURE":"GENERAL"),[c,k]=a.useState(!1),[j,C]=a.useState(!1),[v,h]=a.useState("");async function l(){if(!(!r.trim()||c)){k(!0),h("");try{await b(r.trim(),S.trim()||r.trim(),m),C(!0),setTimeout(x,1200)}catch{h("Something went wrong. Please try again.")}finally{k(!1)}}}if(j)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:u?"Idea received. Thank you.":"Feedback received. Thank you."})]});const y={width:"100%",border:`1px solid ${t.border}`,borderRadius:f.scaleRadius(12,t.radius),padding:"10px 12px",fontSize:16,lineHeight:1.6,outline:"none",background:t.bgSoft,color:t.text,fontFamily:n,boxSizing:"border-box"};return e.jsxs("div",{children:[!u&&e.jsxs(e.Fragment,{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(p=>e.jsxs("button",{onClick:()=>s(p),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"8px 10px",borderRadius:f.scaleRadius(9,t.radius),fontSize:14,fontWeight:600,cursor:"pointer",background:m===p?o:t.bg,color:m===p?t.accentText:t.textSoft,border:`1px solid ${m===p?o:t.border}`,fontFamily:n},children:[A[p].icon,A[p].label]},p))})]}),e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:t.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Title"}),e.jsx("input",{value:r,onChange:p=>d(p.target.value),placeholder:u?"What would you like us to build?":"Short summary of the issue or idea",maxLength:200,style:{...y,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:p=>i(p.target.value),placeholder:u?"Why would it help? (optional)":"Steps to reproduce, expected behaviour, or more context",maxLength:2e3,rows:4,style:{...y,resize:"vertical",marginBottom:16}}),v&&e.jsx("p",{style:{fontSize:14,color:"#d6453d",marginBottom:12},children:v}),e.jsx("button",{onClick:l,disabled:c||!r.trim(),style:{width:"100%",padding:12,background:o,color:t.accentText,border:"none",borderRadius:f.scaleRadius(11,t.radius),fontSize:14,fontWeight:600,cursor:"pointer",opacity:c||!r.trim()?.5:1,fontFamily:n},children:c?"Submitting…":u?"Suggest idea":"Submit feedback"})]})}const A={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"})})}},re={BUG:"#fdecec",FEATURE:"#e9f0fd"},ie={BUG:"#d6453d",FEATURE:"#3b76d6"};function N({type:o,p:t}){return e.jsx("span",{style:{padding:"2px 8px",borderRadius:f.scaleRadius(9999,t.radius),fontSize:10.5,fontWeight:700,letterSpacing:".02em",background:re[o]??t.bgSoft,color:ie[o]??t.textSoft},children:o})}const se={OPEN:"#b45309",IN_PROGRESS:"#1d4ed8",DONE:"#15803d",CLOSED:"#6b7280"};function H(){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 O({status:o,boardStatus:t,p:n}){const x=(t==null?void 0:t.color)??se[o]??"#9ca3af";return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,background:n.bgSoft,border:`1px solid ${n.border}`,borderRadius:f.scaleRadius(6,n.radius),padding:"2px 8px",fontSize:10,fontWeight:600,color:n.textSoft},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:x,display:"inline-block",flexShrink:0}}),(t==null?void 0:t.name)??o.replace("_"," ")]})}function ae({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 $({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 G(o){return new Date(o).toLocaleDateString(void 0,{month:"short",day:"numeric"})}exports.FeedbackWidget=X;exports.UpstepProvider=Q;exports.useUpstep=R;
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAEV,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAcxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AA+E3C,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,CACN,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,YAAY,KAChB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,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,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACzC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,iFAAiF;IACjF,QAAQ,EAAE,OAAO,CAAC;CACnB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,qBAqGxC;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,sDAAsD;IACtD,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mFAAmF;IACnF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAyB,EACzB,WAAW,EACX,KAAK,EACL,MAAM,EACN,MAAM,EACN,UAAU,EACV,YAAoB,EACpB,IAAW,EACX,QAAQ,GACT,EAAE,mBAAmB,qBAibrB"}
1
+ {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAEV,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAcxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AA+E3C,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,CACN,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,YAAY,KAChB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,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,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACzC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,iFAAiF;IACjF,QAAQ,EAAE,OAAO,CAAC;CACnB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,qBAuGxC;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,sDAAsD;IACtD,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mFAAmF;IACnF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAyB,EACzB,WAAW,EACX,KAAK,EACL,MAAM,EACN,MAAM,EACN,UAAU,EACV,YAAoB,EACpB,IAAW,EACX,QAAQ,GACT,EAAE,mBAAmB,qBAibrB"}
package/dist/react.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { jsxs as s, Fragment as R, jsx as t } from "react/jsx-runtime";
2
- import X, { createContext as Z, useState as x, useEffect as w, useCallback as z, useContext as ee, useRef as te } from "react";
2
+ import X, { createContext as Z, useState as x, useEffect as v, useCallback as F, useContext as ee, useRef as te } from "react";
3
3
  import { U as oe } from "./api-CROQwfAo.mjs";
4
- import { scaleRadius as b, DEFAULT_ACCENT as ne, buildWidgetPalette as re, withAlpha as ie } from "./theme.js";
4
+ import { scaleRadius as m, DEFAULT_ACCENT as ne, buildWidgetPalette as re, withAlpha as ie } from "./theme.js";
5
5
  const le = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';
6
- function j(n, e) {
6
+ function O(n, e) {
7
7
  return ie(n, e) ?? `color-mix(in srgb, ${n} ${Math.round(e * 100)}%, transparent)`;
8
8
  }
9
9
  function H() {
@@ -12,45 +12,45 @@ function H() {
12
12
  return n.classList.contains("dark") || n.getAttribute("data-theme") === "dark";
13
13
  }
14
14
  function se(n, e) {
15
- const [o, p] = x(() => n === "dark");
16
- w(() => {
15
+ const [o, h] = x(() => n === "dark");
16
+ v(() => {
17
17
  if (n !== "auto") {
18
- p(n === "dark");
18
+ h(n === "dark");
19
19
  return;
20
20
  }
21
- if (p(H()), typeof MutationObserver > "u") return;
22
- const a = new MutationObserver(() => p(H()));
23
- return a.observe(document.documentElement, {
21
+ if (h(H()), typeof MutationObserver > "u") return;
22
+ const d = new MutationObserver(() => h(H()));
23
+ return d.observe(document.documentElement, {
24
24
  attributes: !0,
25
25
  attributeFilter: ["class", "data-theme"]
26
- }), () => a.disconnect();
26
+ }), () => d.disconnect();
27
27
  }, [n]);
28
- const { accentColor: c, colors: y, radius: r } = e;
28
+ const { accentColor: p, colors: b, radius: r } = e;
29
29
  return X.useMemo(
30
30
  () => re({
31
31
  mode: o ? "dark" : "light",
32
- accentColor: c,
33
- colors: y,
32
+ accentColor: p,
33
+ colors: b,
34
34
  radius: r
35
35
  }),
36
36
  // `colors` is usually an inline object literal, so compare it by value.
37
37
  // eslint-disable-next-line react-hooks/exhaustive-deps
38
- [o, c, JSON.stringify(y ?? null), r]
38
+ [o, p, JSON.stringify(b ?? null), r]
39
39
  );
40
40
  }
41
- const G = Z(null);
42
- function ke({
41
+ const j = Z(null);
42
+ function Se({
43
43
  children: n,
44
44
  ...e
45
45
  }) {
46
- const [o] = x(() => new oe(e)), [p, c] = x([]), [y, r] = x(!1), [a, k] = x(!0);
47
- w(() => {
46
+ const [o] = x(() => new oe(e)), [h, p] = x([]), [b, r] = x(!1), [d, S] = x(!0);
47
+ v(() => {
48
48
  o.setUserId(e.userId);
49
- }, [o, e.userId]), w(() => {
49
+ }, [o, e.userId]), v(() => {
50
50
  o.supportIdentityToken = e.supportIdentityToken, document.querySelectorAll("iframe[data-upstep-support]").forEach(
51
- (h) => {
52
- var v;
53
- return (v = h.contentWindow) == null ? void 0 : v.postMessage(
51
+ (f) => {
52
+ var a;
53
+ return (a = f.contentWindow) == null ? void 0 : a.postMessage(
54
54
  {
55
55
  type: "upstep:support:identity",
56
56
  token: e.supportIdentityToken
@@ -60,58 +60,58 @@ function ke({
60
60
  }
61
61
  );
62
62
  }, [o, e.supportIdentityToken]);
63
- const i = z(async () => {
63
+ const i = F(async () => {
64
64
  try {
65
- const h = await o.listFeedback({ sort: "votes", limit: 20 });
66
- c(h.items), k(h.showBranding ?? !0);
65
+ const f = await o.listFeedback({ sort: "votes", limit: 20 });
66
+ p(f.items), S(f.showBranding ?? !0);
67
67
  } catch {
68
68
  }
69
- }, [o]);
70
- w(() => {
71
- i();
72
- }, [i]);
73
- const S = z(
74
- async (h, v, u) => {
75
- const m = { content: v };
76
- h.trim() && (m.title = h.trim()), u !== void 0 && (m.type = u), await o.submitFeedback(m), await i();
69
+ }, [o]), y = e.feedback !== !1;
70
+ v(() => {
71
+ y && i();
72
+ }, [i, y]);
73
+ const l = F(
74
+ async (f, a, k) => {
75
+ const u = { content: a };
76
+ f.trim() && (u.title = f.trim()), k !== void 0 && (u.type = k), await o.submitFeedback(u), await i();
77
77
  },
78
78
  [o, i]
79
- ), l = z(
80
- async (h, v) => {
79
+ ), c = F(
80
+ async (f, a) => {
81
81
  try {
82
- await o.vote(h, v), await i();
82
+ await o.vote(f, a), await i();
83
83
  } catch {
84
84
  }
85
85
  },
86
86
  [o, i]
87
- ), d = z(
88
- (h) => o.getItem(h),
87
+ ), w = F(
88
+ (f) => o.getItem(f),
89
89
  [o]
90
- ), C = z(() => r(!0), []), F = z(() => r(!1), []), T = z(
91
- (h) => o.setUserId(h),
90
+ ), C = F(() => r(!0), []), T = F(() => r(!1), []), z = F(
91
+ (f) => o.setUserId(f),
92
92
  [o]
93
93
  );
94
94
  return /* @__PURE__ */ t(
95
- G.Provider,
95
+ j.Provider,
96
96
  {
97
97
  value: {
98
98
  client: o,
99
- feedItems: p,
99
+ feedItems: h,
100
100
  loadFeed: i,
101
- submit: S,
102
- vote: l,
103
- getItem: d,
104
- isOpen: y,
101
+ submit: l,
102
+ vote: c,
103
+ getItem: w,
104
+ isOpen: b,
105
105
  open: C,
106
- close: F,
107
- identify: T,
106
+ close: T,
107
+ identify: z,
108
108
  accentColor: e.accentColor ?? ne,
109
109
  customAccentColor: e.accentColor,
110
110
  theme: e.theme ?? "auto",
111
111
  colors: e.colors,
112
112
  radius: e.radius,
113
113
  fontFamily: e.fontFamily,
114
- showBranding: a,
114
+ showBranding: d,
115
115
  chat: e.chat !== !1,
116
116
  feedback: e.feedback !== !1
117
117
  },
@@ -120,7 +120,7 @@ function ke({
120
120
  );
121
121
  }
122
122
  function U() {
123
- const n = ee(G);
123
+ const n = ee(j);
124
124
  if (!n) throw new Error("useUpstep must be used inside <UpstepProvider>");
125
125
  return n;
126
126
  }
@@ -128,31 +128,31 @@ function ve({
128
128
  position: n = "bottom-right",
129
129
  accentColor: e,
130
130
  theme: o,
131
- colors: p,
132
- radius: c,
133
- fontFamily: y,
131
+ colors: h,
132
+ radius: p,
133
+ fontFamily: b,
134
134
  hideLauncher: r = !1,
135
- chat: a = !0,
136
- feedback: k
135
+ chat: d = !0,
136
+ feedback: S
137
137
  }) {
138
138
  var N;
139
- const i = U(), S = (k ?? !0) && i.feedback, l = se(o ?? i.theme, {
139
+ const i = U(), y = (S ?? !0) && i.feedback, l = se(o ?? i.theme, {
140
140
  accentColor: e ?? i.customAccentColor,
141
- colors: p ?? i.colors,
142
- radius: c ?? i.radius
143
- }), d = l.accent, C = {
144
- colors: p ?? i.colors,
145
- radius: c ?? i.radius,
146
- fontFamily: y ?? i.fontFamily
141
+ colors: h ?? i.colors,
142
+ radius: p ?? i.radius
143
+ }), c = l.accent, w = {
144
+ colors: h ?? i.colors,
145
+ radius: p ?? i.radius,
146
+ fontFamily: b ?? i.fontFamily
147
147
  }, {
148
- isOpen: F,
148
+ isOpen: C,
149
149
  open: T,
150
- close: h,
151
- showBranding: v
152
- } = i, [u, m] = x("list"), [f, M] = x(!1), W = f && a && i.chat;
153
- w(() => {
150
+ close: z,
151
+ showBranding: f
152
+ } = i, [a, k] = x("list"), [u, M] = x(!1), W = u && d && i.chat;
153
+ v(() => {
154
154
  let g = !0;
155
- if (i.client.chat = i.chat, !i.chat || !a) {
155
+ if (i.client.chat = i.chat, !i.chat || !d) {
156
156
  M(!1);
157
157
  return;
158
158
  }
@@ -161,13 +161,13 @@ function ve({
161
161
  }), () => {
162
162
  g = !1;
163
163
  };
164
- }, [i.client, i.chat, a]), w(() => {
165
- (!i.chat || !a) && u === "support" && m("list");
166
- }, [i.chat, a, u]), w(() => {
167
- F && m(f && a && i.chat ? "support" : "list");
168
- }, [F, f, a, i.chat]);
164
+ }, [i.client, i.chat, d]), v(() => {
165
+ (!i.chat || !d) && a === "support" && k("list");
166
+ }, [i.chat, d, a]), v(() => {
167
+ C && k(u && d && i.chat ? "support" : "list");
168
+ }, [C, u, d, i.chat]);
169
169
  const [A, P] = x(null), [L, D] = x(!1);
170
- w(() => {
170
+ v(() => {
171
171
  const g = window.matchMedia("(max-width: 639px)");
172
172
  D(g.matches);
173
173
  const I = (Q) => D(Q.matches);
@@ -177,18 +177,18 @@ function ve({
177
177
  position: "fixed",
178
178
  bottom: 24,
179
179
  right: 24
180
- }, B = ((N = C.fontFamily) == null ? void 0 : N.trim()) || le;
180
+ }, B = ((N = w.fontFamily) == null ? void 0 : N.trim()) || le;
181
181
  function E() {
182
- h(), P(null);
182
+ z(), P(null);
183
183
  }
184
184
  function K(g) {
185
- P(g), m("detail");
185
+ P(g), k("detail");
186
186
  }
187
187
  return /* @__PURE__ */ s(R, { children: [
188
- !r && (S || W) && /* @__PURE__ */ s(
188
+ !r && (y || W) && /* @__PURE__ */ s(
189
189
  "button",
190
190
  {
191
- "aria-label": S ? "Open help and feedback" : "Open support chat",
191
+ "aria-label": y ? "Open help and feedback" : "Open support chat",
192
192
  onClick: T,
193
193
  style: {
194
194
  ...J,
@@ -196,10 +196,10 @@ function ve({
196
196
  display: "inline-flex",
197
197
  alignItems: "center",
198
198
  gap: 7,
199
- background: d,
199
+ background: c,
200
200
  color: l.accentText,
201
201
  border: "none",
202
- borderRadius: b(9999, l.radius),
202
+ borderRadius: m(9999, l.radius),
203
203
  padding: L ? "12px" : "12px 18px",
204
204
  fontSize: 14,
205
205
  fontWeight: 600,
@@ -209,11 +209,11 @@ function ve({
209
209
  },
210
210
  children: [
211
211
  /* @__PURE__ */ t(xe, { size: 16 }),
212
- !L && (W ? S ? "Help & feedback" : "Help" : "Feedback")
212
+ !L && (W ? y ? "Help & feedback" : "Help" : "Feedback")
213
213
  ]
214
214
  }
215
215
  ),
216
- F && (S || W) && /* @__PURE__ */ t(
216
+ C && (y || W) && /* @__PURE__ */ t(
217
217
  "div",
218
218
  {
219
219
  onClick: (g) => g.target === g.currentTarget && E(),
@@ -234,9 +234,9 @@ function ve({
234
234
  style: {
235
235
  background: l.bg,
236
236
  border: `1px solid ${l.border}`,
237
- borderRadius: b(20, l.radius),
237
+ borderRadius: m(20, l.radius),
238
238
  width: "100%",
239
- maxWidth: f && a && i.chat ? 460 : 440,
239
+ maxWidth: u && d && i.chat ? 460 : 440,
240
240
  maxHeight: "calc(100dvh - 112px)",
241
241
  display: "flex",
242
242
  flexDirection: "column",
@@ -244,7 +244,7 @@ function ve({
244
244
  boxShadow: "0 24px 64px rgba(0,0,0,.28)"
245
245
  },
246
246
  children: [
247
- W && !S ? /* @__PURE__ */ s(
247
+ W && !y ? /* @__PURE__ */ s(
248
248
  "div",
249
249
  {
250
250
  style: {
@@ -299,14 +299,14 @@ function ve({
299
299
  ].map(([g, I]) => /* @__PURE__ */ t(
300
300
  "button",
301
301
  {
302
- onClick: () => m(g),
302
+ onClick: () => k(g),
303
303
  style: {
304
304
  flex: 1,
305
305
  border: 0,
306
- borderRadius: b(8, l.radius),
306
+ borderRadius: m(8, l.radius),
307
307
  padding: "9px 12px",
308
- background: (u === "support" ? g === "support" : g === "list") ? l.bgSoft : "transparent",
309
- color: (u === "support" ? g === "support" : g === "list") ? l.text : l.textSoft,
308
+ background: (a === "support" ? g === "support" : g === "list") ? l.bgSoft : "transparent",
309
+ color: (a === "support" ? g === "support" : g === "list") ? l.text : l.textSoft,
310
310
  fontSize: 14,
311
311
  fontWeight: 600,
312
312
  cursor: "pointer"
@@ -346,15 +346,15 @@ function ve({
346
346
  },
347
347
  children: [
348
348
  /* @__PURE__ */ s("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
349
- u !== "list" && /* @__PURE__ */ t(
349
+ a !== "list" && /* @__PURE__ */ t(
350
350
  "button",
351
351
  {
352
- onClick: () => m("list"),
352
+ onClick: () => k("list"),
353
353
  style: {
354
354
  background: "none",
355
355
  border: "none",
356
356
  cursor: "pointer",
357
- color: d,
357
+ color: c,
358
358
  fontSize: 14,
359
359
  fontWeight: 600,
360
360
  padding: 0
@@ -362,7 +362,7 @@ function ve({
362
362
  children: "← Back"
363
363
  }
364
364
  ),
365
- u === "list" && /* @__PURE__ */ t(
365
+ a === "list" && /* @__PURE__ */ t(
366
366
  "span",
367
367
  {
368
368
  style: {
@@ -374,7 +374,7 @@ function ve({
374
374
  children: "Feedback"
375
375
  }
376
376
  ),
377
- u === "create" && /* @__PURE__ */ t(
377
+ a === "create" && /* @__PURE__ */ t(
378
378
  "span",
379
379
  {
380
380
  style: {
@@ -388,15 +388,15 @@ function ve({
388
388
  )
389
389
  ] }),
390
390
  /* @__PURE__ */ s("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
391
- u === "list" && /* @__PURE__ */ t(
391
+ a === "list" && /* @__PURE__ */ t(
392
392
  "button",
393
393
  {
394
- onClick: () => m("create"),
394
+ onClick: () => k("create"),
395
395
  style: {
396
- background: d,
396
+ background: c,
397
397
  color: l.accentText,
398
398
  border: "none",
399
- borderRadius: b(20, l.radius),
399
+ borderRadius: m(20, l.radius),
400
400
  padding: "6px 14px",
401
401
  fontSize: 14,
402
402
  fontWeight: 700,
@@ -414,7 +414,7 @@ function ve({
414
414
  border: "none",
415
415
  width: 28,
416
416
  height: 28,
417
- borderRadius: b(8, l.radius),
417
+ borderRadius: m(8, l.radius),
418
418
  fontSize: 14,
419
419
  cursor: "pointer",
420
420
  color: l.textSoft,
@@ -435,19 +435,19 @@ function ve({
435
435
  style: {
436
436
  flex: 1,
437
437
  overflowY: "auto",
438
- padding: u === "support" ? 0 : "16px 20px 24px"
438
+ padding: a === "support" ? 0 : "16px 20px 24px"
439
439
  },
440
440
  children: [
441
- u === "support" && a && i.chat && /* @__PURE__ */ t(
441
+ a === "support" && d && i.chat && /* @__PURE__ */ t(
442
442
  ae,
443
443
  {
444
444
  client: i.client,
445
- accentColor: d,
445
+ accentColor: c,
446
446
  theme: l.dark ? "dark" : "light",
447
- appearance: C
447
+ appearance: w
448
448
  }
449
449
  ),
450
- f && a && i.chat && u !== "support" && /* @__PURE__ */ t(
450
+ u && d && i.chat && a !== "support" && /* @__PURE__ */ t(
451
451
  "div",
452
452
  {
453
453
  style: {
@@ -456,7 +456,7 @@ function ve({
456
456
  justifyContent: "space-between",
457
457
  marginBottom: 16
458
458
  },
459
- children: u === "list" ? /* @__PURE__ */ s(R, { children: [
459
+ children: a === "list" ? /* @__PURE__ */ s(R, { children: [
460
460
  /* @__PURE__ */ t(
461
461
  "span",
462
462
  {
@@ -467,11 +467,11 @@ function ve({
467
467
  /* @__PURE__ */ t(
468
468
  "button",
469
469
  {
470
- onClick: () => m("create"),
470
+ onClick: () => k("create"),
471
471
  style: {
472
472
  border: 0,
473
- borderRadius: b(8, l.radius),
474
- background: d,
473
+ borderRadius: m(8, l.radius),
474
+ background: c,
475
475
  color: l.accentText,
476
476
  fontSize: 14,
477
477
  padding: "7px 10px",
@@ -483,7 +483,7 @@ function ve({
483
483
  ] }) : /* @__PURE__ */ t(
484
484
  "button",
485
485
  {
486
- onClick: () => m("list"),
486
+ onClick: () => k("list"),
487
487
  style: {
488
488
  border: 0,
489
489
  background: "none",
@@ -497,30 +497,30 @@ function ve({
497
497
  )
498
498
  }
499
499
  ),
500
- u === "list" && /* @__PURE__ */ t(de, { onSelect: K, accent: d, p: l }),
501
- u === "detail" && A && /* @__PURE__ */ t(
500
+ a === "list" && /* @__PURE__ */ t(de, { onSelect: K, accent: c, p: l }),
501
+ a === "detail" && A && /* @__PURE__ */ t(
502
502
  ce,
503
503
  {
504
504
  feedbackId: A,
505
- accent: d,
505
+ accent: c,
506
506
  p: l,
507
507
  font: B
508
508
  }
509
509
  ),
510
- u === "create" && /* @__PURE__ */ t(
510
+ a === "create" && /* @__PURE__ */ t(
511
511
  ue,
512
512
  {
513
- accent: d,
513
+ accent: c,
514
514
  p: l,
515
515
  font: B,
516
- ideasOnly: !!(f && a && i.chat),
517
- onDone: () => m("list")
516
+ ideasOnly: !!(u && d && i.chat),
517
+ onDone: () => k("list")
518
518
  }
519
519
  )
520
520
  ]
521
521
  }
522
522
  ),
523
- v && u !== "support" && /* @__PURE__ */ s(
523
+ f && a !== "support" && /* @__PURE__ */ s(
524
524
  "a",
525
525
  {
526
526
  href: "https://upstep.dev",
@@ -554,18 +554,18 @@ function ae({
554
554
  client: n,
555
555
  theme: e,
556
556
  accentColor: o,
557
- appearance: p
557
+ appearance: h
558
558
  }) {
559
- const c = te(null);
560
- return w(() => {
561
- if (c.current) return n.connectSupportFrame(c.current);
559
+ const p = te(null);
560
+ return v(() => {
561
+ if (p.current) return n.connectSupportFrame(p.current);
562
562
  }, [n]), /* @__PURE__ */ t(
563
563
  "iframe",
564
564
  {
565
- ref: c,
565
+ ref: p,
566
566
  "data-upstep-support": !0,
567
567
  title: "Customer support",
568
- src: n.supportFrameUrl(e, o, p),
568
+ src: n.supportFrameUrl(e, o, h),
569
569
  style: {
570
570
  color: o,
571
571
  width: "100%",
@@ -582,9 +582,9 @@ function de({
582
582
  accent: e,
583
583
  p: o
584
584
  }) {
585
- const { feedItems: p, vote: c } = U(), y = p.filter((r) => r.status !== "CLOSED");
586
- return y.length ? /* @__PURE__ */ t(R, { children: y.map((r) => {
587
- const a = r.userVote === "UP", k = r.title ?? r.content;
585
+ const { feedItems: h, vote: p } = U(), b = h.filter((r) => r.status !== "CLOSED");
586
+ return b.length ? /* @__PURE__ */ t(R, { children: b.map((r) => {
587
+ const d = r.userVote === "UP", S = r.title ?? r.content;
588
588
  return /* @__PURE__ */ s(
589
589
  "div",
590
590
  {
@@ -594,7 +594,7 @@ function de({
594
594
  gap: 12,
595
595
  padding: 14,
596
596
  border: `1px solid ${o.border}`,
597
- borderRadius: b(14, o.radius),
597
+ borderRadius: m(14, o.radius),
598
598
  marginBottom: 10,
599
599
  background: o.bg,
600
600
  cursor: "pointer"
@@ -604,7 +604,7 @@ function de({
604
604
  "button",
605
605
  {
606
606
  onClick: (i) => {
607
- i.stopPropagation(), c(r.id, "UP");
607
+ i.stopPropagation(), p(r.id, "UP");
608
608
  },
609
609
  style: {
610
610
  display: "flex",
@@ -614,11 +614,11 @@ function de({
614
614
  gap: 2,
615
615
  minWidth: 46,
616
616
  padding: "7px 0",
617
- borderRadius: b(11, o.radius),
617
+ borderRadius: m(11, o.radius),
618
618
  cursor: "pointer",
619
619
  flexShrink: 0,
620
- border: `1px solid ${a ? e : o.border}`,
621
- background: a ? o.accentTint : o.bgSoft
620
+ border: `1px solid ${d ? e : o.border}`,
621
+ background: d ? o.accentTint : o.bgSoft
622
622
  },
623
623
  children: [
624
624
  /* @__PURE__ */ t(Y, { color: e }),
@@ -652,7 +652,7 @@ function de({
652
652
  WebkitLineClamp: 2,
653
653
  WebkitBoxOrient: "vertical"
654
654
  },
655
- children: k
655
+ children: S
656
656
  }
657
657
  ),
658
658
  /* @__PURE__ */ s(
@@ -665,7 +665,7 @@ function de({
665
665
  flexWrap: "wrap"
666
666
  },
667
667
  children: [
668
- /* @__PURE__ */ t(O, { type: r.type, p: o }),
668
+ /* @__PURE__ */ t(G, { type: r.type, p: o }),
669
669
  r.status === "PENDING" ? /* @__PURE__ */ t(V, {}) : /* @__PURE__ */ t(
670
670
  _,
671
671
  {
@@ -715,25 +715,25 @@ function ce({
715
715
  feedbackId: n,
716
716
  accent: e,
717
717
  p: o,
718
- font: p
718
+ font: h
719
719
  }) {
720
- const { vote: c, getItem: y } = U(), [r, a] = x(null), [k, i] = x(!1);
721
- w(() => {
722
- let d = !1;
723
- return y(n).then((C) => {
724
- d || a(C);
720
+ const { vote: p, getItem: b } = U(), [r, d] = x(null), [S, i] = x(!1);
721
+ v(() => {
722
+ let c = !1;
723
+ return b(n).then((w) => {
724
+ c || d(w);
725
725
  }).catch(() => {
726
726
  }), () => {
727
- d = !0;
727
+ c = !0;
728
728
  };
729
- }, [n, y]);
730
- async function S() {
731
- if (!(!r || k)) {
729
+ }, [n, b]);
730
+ async function y() {
731
+ if (!(!r || S)) {
732
732
  i(!0);
733
733
  try {
734
- await c(r.id, "UP");
735
- const d = await y(n);
736
- a(d);
734
+ await p(r.id, "UP");
735
+ const c = await b(n);
736
+ d(c);
737
737
  } catch {
738
738
  } finally {
739
739
  i(!1);
@@ -774,7 +774,7 @@ function ce({
774
774
  {
775
775
  style: { display: "flex", gap: 6, marginBottom: 14, flexWrap: "wrap" },
776
776
  children: [
777
- /* @__PURE__ */ t(O, { type: r.type, p: o }),
777
+ /* @__PURE__ */ t(G, { type: r.type, p: o }),
778
778
  r.status === "PENDING" ? /* @__PURE__ */ t(V, {}) : /* @__PURE__ */ t(
779
779
  _,
780
780
  {
@@ -801,18 +801,18 @@ function ce({
801
801
  /* @__PURE__ */ s(
802
802
  "button",
803
803
  {
804
- onClick: S,
805
- disabled: k,
804
+ onClick: y,
805
+ disabled: S,
806
806
  style: {
807
807
  display: "inline-flex",
808
808
  alignItems: "center",
809
809
  gap: 8,
810
810
  border: `1px solid ${r.userVote === "UP" ? e : o.border}`,
811
- background: r.userVote === "UP" ? j(e, 0.08) : o.bgSoft,
812
- borderRadius: b(12, o.radius),
811
+ background: r.userVote === "UP" ? O(e, 0.08) : o.bgSoft,
812
+ borderRadius: m(12, o.radius),
813
813
  padding: "10px 16px",
814
814
  cursor: "pointer",
815
- fontFamily: p
815
+ fontFamily: h
816
816
  },
817
817
  children: [
818
818
  /* @__PURE__ */ t(Y, { color: e, size: 13 }),
@@ -844,7 +844,7 @@ function ce({
844
844
  children: "Comments"
845
845
  }
846
846
  ),
847
- r.comments.map((d) => /* @__PURE__ */ t(pe, { comment: d, p: o, accent: e }, d.id))
847
+ r.comments.map((c) => /* @__PURE__ */ t(pe, { comment: c, p: o, accent: e }, c.id))
848
848
  ]
849
849
  }
850
850
  )
@@ -855,14 +855,14 @@ function pe({
855
855
  p: e,
856
856
  accent: o
857
857
  }) {
858
- var p;
858
+ var h;
859
859
  return /* @__PURE__ */ s(
860
860
  "div",
861
861
  {
862
862
  style: {
863
863
  background: e.bgSoft,
864
864
  border: `1px solid ${e.border}`,
865
- borderRadius: b(12, e.radius),
865
+ borderRadius: m(12, e.radius),
866
866
  padding: 14,
867
867
  marginBottom: 10
868
868
  },
@@ -881,14 +881,14 @@ function pe({
881
881
  "span",
882
882
  {
883
883
  style: {
884
- background: j(o, 0.125),
884
+ background: O(o, 0.125),
885
885
  color: o,
886
886
  fontSize: 11,
887
887
  fontWeight: 700,
888
- borderRadius: b(20, e.radius),
888
+ borderRadius: m(20, e.radius),
889
889
  padding: "2px 8px"
890
890
  },
891
- children: ((p = n.authorName) == null ? void 0 : p.trim()) || "UpStep Team"
891
+ children: ((h = n.authorName) == null ? void 0 : h.trim()) || "UpStep Team"
892
892
  }
893
893
  ),
894
894
  /* @__PURE__ */ t("span", { style: { fontSize: 11, color: e.textFaint }, children: q(n.createdAt) })
@@ -910,25 +910,25 @@ function ue({
910
910
  accent: n,
911
911
  p: e,
912
912
  font: o,
913
- onDone: p,
914
- ideasOnly: c = !1
913
+ onDone: h,
914
+ ideasOnly: p = !1
915
915
  }) {
916
- const { submit: y } = U(), [r, a] = x(""), [k, i] = x(""), [S, l] = x(
917
- c ? "FEATURE" : "GENERAL"
918
- ), [d, C] = x(!1), [F, T] = x(!1), [h, v] = x("");
919
- async function u() {
920
- if (!(!r.trim() || d)) {
921
- C(!0), v("");
916
+ const { submit: b } = U(), [r, d] = x(""), [S, i] = x(""), [y, l] = x(
917
+ p ? "FEATURE" : "GENERAL"
918
+ ), [c, w] = x(!1), [C, T] = x(!1), [z, f] = x("");
919
+ async function a() {
920
+ if (!(!r.trim() || c)) {
921
+ w(!0), f("");
922
922
  try {
923
- await y(r.trim(), k.trim() || r.trim(), S), T(!0), setTimeout(p, 1200);
923
+ await b(r.trim(), S.trim() || r.trim(), y), T(!0), setTimeout(h, 1200);
924
924
  } catch {
925
- v("Something went wrong. Please try again.");
925
+ f("Something went wrong. Please try again.");
926
926
  } finally {
927
- C(!1);
927
+ w(!1);
928
928
  }
929
929
  }
930
930
  }
931
- if (F)
931
+ if (C)
932
932
  return /* @__PURE__ */ s("div", { style: { textAlign: "center", paddingTop: 40 }, children: [
933
933
  /* @__PURE__ */ t(
934
934
  "div",
@@ -942,12 +942,12 @@ function ue({
942
942
  children: "Submitted"
943
943
  }
944
944
  ),
945
- /* @__PURE__ */ t("div", { style: { fontSize: 14, color: e.textFaint }, children: c ? "Idea received. Thank you." : "Feedback received. Thank you." })
945
+ /* @__PURE__ */ t("div", { style: { fontSize: 14, color: e.textFaint }, children: p ? "Idea received. Thank you." : "Feedback received. Thank you." })
946
946
  ] });
947
- const m = {
947
+ const k = {
948
948
  width: "100%",
949
949
  border: `1px solid ${e.border}`,
950
- borderRadius: b(12, e.radius),
950
+ borderRadius: m(12, e.radius),
951
951
  padding: "10px 12px",
952
952
  fontSize: 16,
953
953
  lineHeight: 1.6,
@@ -958,7 +958,7 @@ function ue({
958
958
  boxSizing: "border-box"
959
959
  };
960
960
  return /* @__PURE__ */ s("div", { children: [
961
- !c && /* @__PURE__ */ s(R, { children: [
961
+ !p && /* @__PURE__ */ s(R, { children: [
962
962
  /* @__PURE__ */ t(
963
963
  "div",
964
964
  {
@@ -973,10 +973,10 @@ function ue({
973
973
  children: "Type"
974
974
  }
975
975
  ),
976
- /* @__PURE__ */ t("div", { style: { display: "flex", gap: 7, marginBottom: 16 }, children: ["BUG", "FEATURE", "GENERAL"].map((f) => /* @__PURE__ */ s(
976
+ /* @__PURE__ */ t("div", { style: { display: "flex", gap: 7, marginBottom: 16 }, children: ["BUG", "FEATURE", "GENERAL"].map((u) => /* @__PURE__ */ s(
977
977
  "button",
978
978
  {
979
- onClick: () => l(f),
979
+ onClick: () => l(u),
980
980
  style: {
981
981
  flex: 1,
982
982
  display: "flex",
@@ -984,21 +984,21 @@ function ue({
984
984
  justifyContent: "center",
985
985
  gap: 5,
986
986
  padding: "8px 10px",
987
- borderRadius: b(9, e.radius),
987
+ borderRadius: m(9, e.radius),
988
988
  fontSize: 14,
989
989
  fontWeight: 600,
990
990
  cursor: "pointer",
991
- background: S === f ? n : e.bg,
992
- color: S === f ? e.accentText : e.textSoft,
993
- border: `1px solid ${S === f ? n : e.border}`,
991
+ background: y === u ? n : e.bg,
992
+ color: y === u ? e.accentText : e.textSoft,
993
+ border: `1px solid ${y === u ? n : e.border}`,
994
994
  fontFamily: o
995
995
  },
996
996
  children: [
997
- $[f].icon,
998
- $[f].label
997
+ $[u].icon,
998
+ $[u].label
999
999
  ]
1000
1000
  },
1001
- f
1001
+ u
1002
1002
  )) })
1003
1003
  ] }),
1004
1004
  /* @__PURE__ */ t(
@@ -1019,10 +1019,10 @@ function ue({
1019
1019
  "input",
1020
1020
  {
1021
1021
  value: r,
1022
- onChange: (f) => a(f.target.value),
1023
- placeholder: c ? "What would you like us to build?" : "Short summary of the issue or idea",
1022
+ onChange: (u) => d(u.target.value),
1023
+ placeholder: p ? "What would you like us to build?" : "Short summary of the issue or idea",
1024
1024
  maxLength: 200,
1025
- style: { ...m, marginBottom: 16, display: "block" }
1025
+ style: { ...k, marginBottom: 16, display: "block" }
1026
1026
  }
1027
1027
  ),
1028
1028
  /* @__PURE__ */ s(
@@ -1052,34 +1052,34 @@ function ue({
1052
1052
  /* @__PURE__ */ t(
1053
1053
  "textarea",
1054
1054
  {
1055
- value: k,
1056
- onChange: (f) => i(f.target.value),
1057
- placeholder: c ? "Why would it help? (optional)" : "Steps to reproduce, expected behaviour, or more context",
1055
+ value: S,
1056
+ onChange: (u) => i(u.target.value),
1057
+ placeholder: p ? "Why would it help? (optional)" : "Steps to reproduce, expected behaviour, or more context",
1058
1058
  maxLength: 2e3,
1059
1059
  rows: 4,
1060
- style: { ...m, resize: "vertical", marginBottom: 16 }
1060
+ style: { ...k, resize: "vertical", marginBottom: 16 }
1061
1061
  }
1062
1062
  ),
1063
- h && /* @__PURE__ */ t("p", { style: { fontSize: 14, color: "#d6453d", marginBottom: 12 }, children: h }),
1063
+ z && /* @__PURE__ */ t("p", { style: { fontSize: 14, color: "#d6453d", marginBottom: 12 }, children: z }),
1064
1064
  /* @__PURE__ */ t(
1065
1065
  "button",
1066
1066
  {
1067
- onClick: u,
1068
- disabled: d || !r.trim(),
1067
+ onClick: a,
1068
+ disabled: c || !r.trim(),
1069
1069
  style: {
1070
1070
  width: "100%",
1071
1071
  padding: 12,
1072
1072
  background: n,
1073
1073
  color: e.accentText,
1074
1074
  border: "none",
1075
- borderRadius: b(11, e.radius),
1075
+ borderRadius: m(11, e.radius),
1076
1076
  fontSize: 14,
1077
1077
  fontWeight: 600,
1078
1078
  cursor: "pointer",
1079
- opacity: d || !r.trim() ? 0.5 : 1,
1079
+ opacity: c || !r.trim() ? 0.5 : 1,
1080
1080
  fontFamily: o
1081
1081
  },
1082
- children: d ? "Submitting…" : c ? "Suggest idea" : "Submit feedback"
1082
+ children: c ? "Submitting…" : p ? "Suggest idea" : "Submit feedback"
1083
1083
  }
1084
1084
  )
1085
1085
  ] });
@@ -1143,13 +1143,13 @@ const $ = {
1143
1143
  )
1144
1144
  }
1145
1145
  }, he = { BUG: "#fdecec", FEATURE: "#e9f0fd" }, fe = { BUG: "#d6453d", FEATURE: "#3b76d6" };
1146
- function O({ type: n, p: e }) {
1146
+ function G({ type: n, p: e }) {
1147
1147
  return /* @__PURE__ */ t(
1148
1148
  "span",
1149
1149
  {
1150
1150
  style: {
1151
1151
  padding: "2px 8px",
1152
- borderRadius: b(9999, e.radius),
1152
+ borderRadius: m(9999, e.radius),
1153
1153
  fontSize: 10.5,
1154
1154
  fontWeight: 700,
1155
1155
  letterSpacing: ".02em",
@@ -1205,7 +1205,7 @@ function _({
1205
1205
  boardStatus: e,
1206
1206
  p: o
1207
1207
  }) {
1208
- const p = (e == null ? void 0 : e.color) ?? ge[n] ?? "#9ca3af";
1208
+ const h = (e == null ? void 0 : e.color) ?? ge[n] ?? "#9ca3af";
1209
1209
  return /* @__PURE__ */ s(
1210
1210
  "span",
1211
1211
  {
@@ -1215,7 +1215,7 @@ function _({
1215
1215
  gap: 5,
1216
1216
  background: o.bgSoft,
1217
1217
  border: `1px solid ${o.border}`,
1218
- borderRadius: b(6, o.radius),
1218
+ borderRadius: m(6, o.radius),
1219
1219
  padding: "2px 8px",
1220
1220
  fontSize: 10,
1221
1221
  fontWeight: 600,
@@ -1229,7 +1229,7 @@ function _({
1229
1229
  width: 6,
1230
1230
  height: 6,
1231
1231
  borderRadius: "50%",
1232
- background: p,
1232
+ background: h,
1233
1233
  display: "inline-block",
1234
1234
  flexShrink: 0
1235
1235
  }
@@ -1286,6 +1286,6 @@ function q(n) {
1286
1286
  }
1287
1287
  export {
1288
1288
  ve as FeedbackWidget,
1289
- ke as UpstepProvider,
1289
+ Se as UpstepProvider,
1290
1290
  U as useUpstep
1291
1291
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upstep/js",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "UpStep feedback, voting and AI support widgets for web apps",
5
5
  "license": "MIT",
6
6
  "homepage": "https://upstep.dev",