@upstep/js 0.1.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),v=require("./api-CwAgmJ0s.js"),m=n.createContext(null);function w({children:d,...c}){const[s]=n.useState(()=>new v.UpstepApiClient(c)),[p,i]=n.useState([]),o=n.useCallback(async()=>{const r=await s.listFeedback({sort:"votes",limit:20});i(r.items)},[s]);n.useEffect(()=>{o()},[o]);const f=n.useCallback(async(r,a)=>{const l={content:r};a!==void 0&&(l.type=a),await s.submitFeedback(l),await o()},[s,o]),b=n.useCallback(async(r,a)=>{await s.vote(r,a),await o()},[s,o]);return e.jsx(m.Provider,{value:{client:s,feedItems:p,loadFeed:o,submit:f,vote:b},children:d})}function y(){const d=n.useContext(m);if(!d)throw new Error("useUpstep must be used inside <UpstepProvider>");return d}function C({position:d="bottom-right"}){const{feedItems:c,submit:s,vote:p}=y(),[i,o]=n.useState(!1),[f,b]=n.useState("submit"),[r,a]=n.useState(""),[l,S]=n.useState("GENERAL"),[x,g]=n.useState(""),[u,h]=n.useState(!1),j=d==="bottom-left"?{position:"fixed",bottom:24,left:24}:{position:"fixed",bottom:24,right:24};async function k(){if(!(!r.trim()||u)){h(!0);try{await s(r.trim(),l),a(""),g("Thanks for your feedback!")}catch{g("Something went wrong.")}finally{h(!1)}}}return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>o(!0),style:{...j,zIndex:9998,background:"#6366f1",color:"#fff",border:"none",borderRadius:9999,padding:"12px 20px",fontSize:14,fontWeight:600,cursor:"pointer",boxShadow:"0 4px 12px rgba(0,0,0,.2)"},children:"Feedback"}),i&&e.jsx("div",{onClick:t=>t.target===t.currentTarget&&o(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,.45)",zIndex:9999,display:"flex",alignItems:"flex-end",justifyContent:"center"},children:e.jsxs("div",{style:{background:"#fff",borderRadius:"16px 16px 0 0",width:"100%",maxWidth:480,maxHeight:"90vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid #e5e7eb"},children:[e.jsx("span",{style:{fontWeight:700,fontSize:16},children:"Share feedback"}),e.jsx("button",{onClick:()=>o(!1),style:{background:"none",border:"none",fontSize:20,cursor:"pointer",color:"#6b7280"},children:"✕"})]}),e.jsx("div",{style:{display:"flex",borderBottom:"1px solid #e5e7eb"},children:["submit","feed"].map(t=>e.jsx("button",{onClick:()=>b(t),style:{flex:1,padding:10,background:"none",border:"none",fontSize:13,fontWeight:500,cursor:"pointer",color:f===t?"#6366f1":"#6b7280",borderBottom:f===t?"2px solid #6366f1":"2px solid transparent"},children:t==="submit"?"Submit":"Votes & Ideas"},t))}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:16},children:f==="submit"?e.jsxs("div",{children:[e.jsx("textarea",{value:r,onChange:t=>a(t.target.value),placeholder:"What's on your mind?",maxLength:2e3,style:{width:"100%",minHeight:100,border:"1px solid #d1d5db",borderRadius:8,padding:10,fontSize:14,resize:"vertical",outline:"none"}}),e.jsx("div",{style:{display:"flex",gap:8,margin:"10px 0"},children:["BUG","FEATURE","GENERAL"].map(t=>e.jsx("button",{onClick:()=>S(t),style:{padding:"5px 12px",borderRadius:9999,fontSize:12,cursor:"pointer",background:l===t?"#6366f1":"#fff",color:l===t?"#fff":"#374151",border:`1px solid ${l===t?"#6366f1":"#d1d5db"}`},children:t.charAt(0)+t.slice(1).toLowerCase()},t))}),e.jsx("button",{onClick:k,disabled:u||!r.trim(),style:{width:"100%",padding:10,background:"#6366f1",color:"#fff",border:"none",borderRadius:8,fontSize:14,fontWeight:600,cursor:"pointer",opacity:u||!r.trim()?.5:1},children:u?"Sending…":"Send feedback"}),x&&e.jsx("p",{style:{textAlign:"center",fontSize:13,color:"#6b7280",marginTop:8},children:x})]}):e.jsx(U,{items:c,onVote:p})})]})})]})}function U({items:d,onVote:c}){if(!d.length)return e.jsx("p",{style:{textAlign:"center",color:"#9ca3af",fontSize:14,padding:"32px 0"},children:"No feedback yet. Be the first!"});const s={BUG:"#fee2e2",FEATURE:"#dbeafe",GENERAL:"#f3f4f6"},p={BUG:"#dc2626",FEATURE:"#2563eb",GENERAL:"#6b7280"};return e.jsx(e.Fragment,{children:d.map(i=>e.jsxs("div",{style:{padding:"12px 0",borderBottom:"1px solid #f3f4f6"},children:[e.jsx("p",{style:{fontSize:14,color:"#1f2937",margin:"0 0 8px"},children:i.content}),e.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginBottom:8},children:[e.jsx("span",{style:{background:s[i.type],color:p[i.type],borderRadius:9999,padding:"2px 8px",fontSize:11,fontWeight:500,marginRight:6},children:i.type}),new Date(i.createdAt).toLocaleDateString()]}),e.jsx("div",{style:{display:"flex",gap:8},children:["UP","DOWN"].map(o=>e.jsxs("button",{onClick:()=>c(i.id,o),style:{display:"flex",alignItems:"center",gap:4,padding:"4px 10px",borderRadius:9999,border:"1px solid #e5e7eb",background:"#fff",fontSize:12,cursor:"pointer"},children:[o==="UP"?"▲":"▼"," ",o==="UP"?i.upvotes:i.downvotes]},o))})]},i.id))})}exports.FeedbackWidget=C;exports.UpstepProvider=w;exports.useUpstep=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),A=require("./api-p1GbYq1j.js"),I="#D97757",W={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},L={bg:"#1c1b19",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function T(a){const[c,t]=o.useState(()=>a==="dark"?!0:a==="light"?!1:typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1);return o.useEffect(()=>{if(a!=="auto"||typeof window>"u"||!window.matchMedia){t(a==="dark");return}const i=window.matchMedia("(prefers-color-scheme: dark)"),r=d=>t(d.matches);return t(i.matches),i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[a]),c?L:W}const E=o.createContext(null);function G({children:a,...c}){const[t]=o.useState(()=>new A.UpstepApiClient(c)),[i,r]=o.useState([]),[d,n]=o.useState(!1);o.useEffect(()=>{t.setUserId(c.userId)},[t,c.userId]);const f=o.useCallback(async()=>{const l=await t.listFeedback({sort:"votes",limit:20});r(l.items)},[t]);o.useEffect(()=>{f()},[f]);const h=o.useCallback(async(l,x)=>{const u={content:l};x!==void 0&&(u.type=x),await t.submitFeedback(u),await f()},[t,f]),m=o.useCallback(async(l,x)=>{await t.vote(l,x),await f()},[t,f]),y=o.useCallback(()=>n(!0),[]),S=o.useCallback(()=>n(!1),[]),p=o.useCallback(l=>t.setUserId(l),[t]);return e.jsx(E.Provider,{value:{client:t,feedItems:i,loadFeed:f,submit:h,vote:m,isOpen:d,open:y,close:S,identify:p,accentColor:c.accentColor??I,theme:c.theme??"auto"},children:a})}function F(){const a=o.useContext(E);if(!a)throw new Error("useUpstep must be used inside <UpstepProvider>");return a}const B={BUG:"🐞 Bug",FEATURE:"✨ Feature",GENERAL:"💬 General"};function D({position:a="bottom-right",accentColor:c,theme:t,hideLauncher:i=!1}){const r=F(),d=c??r.accentColor,n=T(t??r.theme),{feedItems:f,submit:h,vote:m,isOpen:y,open:S,close:p}=r,[l,x]=o.useState("submit"),[u,v]=o.useState(""),[g,R]=o.useState("GENERAL"),[j,w]=o.useState(""),[b,C]=o.useState(!1),U=a==="bottom-left"?{position:"fixed",bottom:24,left:24}:{position:"fixed",bottom:24,right:24};async function z(){if(!(!u.trim()||b)){C(!0);try{await h(u.trim(),g),v(""),w("Thanks — we got your feedback! 🎉")}catch{w("Something went wrong.")}finally{C(!1)}}}const k='-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';return e.jsxs(e.Fragment,{children:[!i&&e.jsxs("button",{onClick:S,style:{...U,zIndex:9998,display:"inline-flex",alignItems:"center",gap:7,background:d,color:"#fff",border:"none",borderRadius:9999,padding:"12px 18px",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:k,boxShadow:"0 6px 20px rgba(26,25,21,.18)"},children:[e.jsx(H,{})," Feedback"]}),y&&e.jsx("div",{onClick:s=>s.target===s.currentTarget&&p(),style:{position:"fixed",inset:0,background:n.overlay,backdropFilter:"blur(3px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:16,fontFamily:k},children:e.jsxs("div",{style:{background:n.bg,border:`1px solid ${n.border}`,borderRadius:20,width:"100%",maxWidth:440,maxHeight:"88vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 64px rgba(0,0,0,.28)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"20px 20px 0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:700,fontSize:16,color:n.text,letterSpacing:"-.01em"},children:"Share your feedback"}),e.jsx("div",{style:{fontSize:12.5,color:n.textFaint,marginTop:2},children:"Tell us what to build next, or vote on ideas."})]}),e.jsx("button",{onClick:p,style:{background:n.bgSoft,border:"none",width:28,height:28,borderRadius:8,fontSize:14,cursor:"pointer",color:n.textSoft,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]}),e.jsx("div",{style:{display:"flex",gap:4,margin:"16px 20px 0",padding:4,background:n.bgSoft,borderRadius:11},children:["submit","feed"].map(s=>e.jsx("button",{onClick:()=>x(s),style:{flex:1,padding:8,border:"none",borderRadius:8,fontSize:13,fontWeight:600,cursor:"pointer",background:l===s?n.bg:"transparent",color:l===s?n.text:n.textSoft,boxShadow:l===s?"0 1px 3px rgba(0,0,0,.08)":"none"},children:s==="submit"?"Give feedback":"Vote on ideas"},s))}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"18px 20px 22px"},children:l==="submit"?e.jsxs("div",{children:[e.jsx("textarea",{value:u,onChange:s=>v(s.target.value),placeholder:"What's on your mind?",maxLength:2e3,style:{width:"100%",minHeight:104,border:`1px solid ${n.border}`,borderRadius:12,padding:12,fontSize:14,lineHeight:1.5,resize:"vertical",outline:"none",background:n.bgSoft,color:n.text,fontFamily:k}}),e.jsx("div",{style:{display:"flex",gap:7,margin:"12px 0 4px"},children:["BUG","FEATURE","GENERAL"].map(s=>e.jsx("button",{onClick:()=>R(s),style:{flex:1,padding:"8px 10px",borderRadius:9,fontSize:12.5,fontWeight:600,cursor:"pointer",background:g===s?d:n.bg,color:g===s?"#fff":n.textSoft,border:`1px solid ${g===s?d:n.border}`},children:B[s]},s))}),e.jsx("button",{onClick:z,disabled:b||!u.trim(),style:{width:"100%",padding:12,background:d,color:"#fff",border:"none",borderRadius:11,fontSize:14,fontWeight:600,cursor:"pointer",marginTop:14,opacity:b||!u.trim()?.5:1},children:b?"Sending…":"Send feedback"}),j&&e.jsx("p",{style:{textAlign:"center",fontSize:13,color:d,fontWeight:500,marginTop:12},children:j})]}):e.jsx(N,{items:f,onVote:m,accent:d,p:n})})]})})]})}function H(){return e.jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}const P={BUG:"#fdecec",FEATURE:"#e9f0fd",GENERAL:""},M={BUG:"#d6453d",FEATURE:"#3b76d6",GENERAL:""};function N({items:a,onVote:c,accent:t,p:i}){return a.length?e.jsx(e.Fragment,{children:a.map(r=>{const d=r.userVote==="UP";return e.jsxs("div",{style:{display:"flex",gap:12,padding:14,border:`1px solid ${i.border}`,borderRadius:14,marginBottom:10,background:i.bg},children:[e.jsxs("button",{onClick:()=>c(r.id,"UP"),style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,minWidth:46,padding:"7px 0",borderRadius:11,cursor:"pointer",border:`1px solid ${d?t:i.border}`,background:d?`${t}1a`:i.bgSoft},children:[e.jsx("span",{style:{fontSize:11,lineHeight:1,color:t},children:"▲"}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:i.text,lineHeight:1.1},children:r.upvotes})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:13.5,lineHeight:1.5,color:i.text,margin:"0 0 8px",wordBreak:"break-word"},children:r.content}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[e.jsx("span",{style:{padding:"2px 8px",borderRadius:9999,fontSize:10.5,fontWeight:700,letterSpacing:".02em",background:P[r.type]||i.bgSoft,color:M[r.type]||i.textSoft},children:r.type}),e.jsx("span",{style:{fontSize:11,color:i.textFaint},children:new Date(r.createdAt).toLocaleDateString()})]})]})]},r.id)})}):e.jsxs("div",{style:{textAlign:"center",padding:"40px 0"},children:[e.jsx("div",{style:{color:i.textSoft,fontSize:15,fontWeight:600,marginBottom:4},children:"No ideas yet"}),e.jsx("div",{style:{color:i.textFaint,fontSize:14},children:"Be the first to share one."})]})}exports.FeedbackWidget=D;exports.UpstepProvider=G;exports.useUpstep=F;
package/dist/react.d.ts CHANGED
@@ -1,12 +1,25 @@
1
1
  import { default as React, ReactNode } from 'react';
2
2
  import { Feedback, FeedbackType, UpstepConfig } from '@upstep/types';
3
3
  import { UpstepApiClient } from './api';
4
+ type ThemeMode = "light" | "dark" | "auto";
4
5
  interface UpstepContextValue {
5
6
  client: UpstepApiClient;
6
7
  feedItems: Feedback[];
7
8
  loadFeed: () => Promise<void>;
8
9
  submit: (content: string, type?: FeedbackType) => Promise<void>;
9
10
  vote: (feedbackId: string, value: "UP" | "DOWN") => Promise<void>;
11
+ /** Whether the feedback modal is currently open. */
12
+ isOpen: boolean;
13
+ /** Open the feedback modal — call from your own UI (settings, menu, etc.). */
14
+ open: () => void;
15
+ /** Close the feedback modal. */
16
+ close: () => void;
17
+ /** Set / update the end-user id at runtime (e.g. after the user logs in). */
18
+ identify: (userId: string | undefined) => void;
19
+ /** Accent color from provider config (default applied). */
20
+ accentColor: string;
21
+ /** Theme mode from provider config (default "auto"). */
22
+ theme: ThemeMode;
10
23
  }
11
24
  export declare function UpstepProvider({ children, ...config }: UpstepConfig & {
12
25
  children: ReactNode;
@@ -15,7 +28,16 @@ export declare function useUpstep(): UpstepContextValue;
15
28
  interface FeedbackWidgetProps {
16
29
  /** Position of the trigger button */
17
30
  position?: "bottom-right" | "bottom-left";
31
+ /** Accent color. Defaults to the provider's accentColor (or "#D97757"). */
32
+ accentColor?: string;
33
+ /** Theme. Defaults to the provider's theme (or "auto"). */
34
+ theme?: ThemeMode;
35
+ /**
36
+ * Hide the floating launcher button and only show the modal when opened
37
+ * programmatically via `useUpstep().open()` — e.g. from a settings menu.
38
+ */
39
+ hideLauncher?: boolean;
18
40
  }
19
- export declare function FeedbackWidget({ position }: FeedbackWidgetProps): React.JSX.Element;
41
+ export declare function FeedbackWidget({ position, accentColor, theme, hideLauncher, }: FeedbackWidgetProps): React.JSX.Element;
20
42
  export {};
21
43
  //# sourceMappingURL=react.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAMZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAIxC,UAAU,kBAAkB;IAC1B,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnE;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,qBA4BxC;AAED,wBAAgB,SAAS,IAAI,kBAAkB,CAI9C;AAID,UAAU,mBAAmB;IAC3B,qCAAqC;IACrC,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC;CAC3C;AAED,wBAAgB,cAAc,CAAC,EAAE,QAAyB,EAAE,EAAE,mBAAmB,qBA+IhF"}
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,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAMxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAmD3C,UAAU,kBAAkB;IAC1B,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,oDAAoD;IACpD,MAAM,EAAE,OAAO,CAAC;IAChB,8EAA8E;IAC9E,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,gCAAgC;IAChC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,6EAA6E;IAC7E,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/C,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,KAAK,EAAE,SAAS,CAAC;CAClB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,qBA2CxC;AAED,wBAAgB,SAAS,IAAI,kBAAkB,CAI9C;AAID,UAAU,mBAAmB;IAC3B,qCAAqC;IACrC,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC;IAC1C,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAMD,wBAAgB,cAAc,CAAC,EAC7B,QAAyB,EACzB,WAAW,EACX,KAAK,EACL,YAAoB,GACrB,EAAE,mBAAmB,qBAmJrB"}
package/dist/react.js CHANGED
@@ -1,155 +1,268 @@
1
- import { jsxs as c, Fragment as k, jsx as e } from "react/jsx-runtime";
2
- import { createContext as z, useState as s, useCallback as x, useEffect as E, useContext as U } from "react";
3
- import { U as R } from "./api-DWhfFfYu.mjs";
4
- const v = z(null);
5
- function T({
1
+ import { jsxs as c, Fragment as z, jsx as e } from "react/jsx-runtime";
2
+ import { createContext as G, useState as p, useEffect as E, useCallback as b, useContext as T } from "react";
3
+ import { U as B } from "./api-q50Qqen1.mjs";
4
+ const D = "#D97757", H = {
5
+ bg: "#ffffff",
6
+ bgSoft: "#f6f5f2",
7
+ bgHover: "#efede8",
8
+ text: "#1a1915",
9
+ textSoft: "#56544d",
10
+ textFaint: "#9b9890",
11
+ border: "#e8e6df",
12
+ overlay: "rgba(26,25,21,.45)"
13
+ }, j = {
14
+ bg: "#1c1b19",
15
+ bgSoft: "#262522",
16
+ bgHover: "#302e2a",
17
+ text: "#f5f4f0",
18
+ textSoft: "#b4b1a8",
19
+ textFaint: "#7d7a72",
20
+ border: "#33312c",
21
+ overlay: "rgba(0,0,0,.6)"
22
+ };
23
+ function M(d) {
24
+ const [l, t] = p(() => d === "dark" ? !0 : d === "light" ? !1 : typeof window < "u" && window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)").matches : !1);
25
+ return E(() => {
26
+ if (d !== "auto" || typeof window > "u" || !window.matchMedia) {
27
+ t(d === "dark");
28
+ return;
29
+ }
30
+ const n = window.matchMedia("(prefers-color-scheme: dark)"), i = (a) => t(a.matches);
31
+ return t(n.matches), n.addEventListener("change", i), () => n.removeEventListener("change", i);
32
+ }, [d]), l ? j : H;
33
+ }
34
+ const A = G(null);
35
+ function J({
6
36
  children: d,
7
- ...p
37
+ ...l
8
38
  }) {
9
- const [i] = s(() => new R(p)), [f, n] = s([]), o = x(async () => {
10
- const r = await i.listFeedback({ sort: "votes", limit: 20 });
11
- n(r.items);
12
- }, [i]);
39
+ const [t] = p(() => new B(l)), [n, i] = p([]), [a, o] = p(!1);
40
+ E(() => {
41
+ t.setUserId(l.userId);
42
+ }, [t, l.userId]);
43
+ const f = b(async () => {
44
+ const s = await t.listFeedback({ sort: "votes", limit: 20 });
45
+ i(s.items);
46
+ }, [t]);
13
47
  E(() => {
14
- o();
15
- }, [o]);
16
- const b = x(async (r, a) => {
17
- const l = { content: r };
18
- a !== void 0 && (l.type = a), await i.submitFeedback(l), await o();
19
- }, [i, o]), g = x(async (r, a) => {
20
- await i.vote(r, a), await o();
21
- }, [i, o]);
22
- return /* @__PURE__ */ e(v.Provider, { value: { client: i, feedItems: f, loadFeed: o, submit: b, vote: g }, children: d });
48
+ f();
49
+ }, [f]);
50
+ const y = b(async (s, u) => {
51
+ const g = { content: s };
52
+ u !== void 0 && (g.type = u), await t.submitFeedback(g), await f();
53
+ }, [t, f]), v = b(async (s, u) => {
54
+ await t.vote(s, u), await f();
55
+ }, [t, f]), S = b(() => o(!0), []), k = b(() => o(!1), []), h = b((s) => t.setUserId(s), [t]);
56
+ return /* @__PURE__ */ e(
57
+ A.Provider,
58
+ {
59
+ value: {
60
+ client: t,
61
+ feedItems: n,
62
+ loadFeed: f,
63
+ submit: y,
64
+ vote: v,
65
+ isOpen: a,
66
+ open: S,
67
+ close: k,
68
+ identify: h,
69
+ accentColor: l.accentColor ?? D,
70
+ theme: l.theme ?? "auto"
71
+ },
72
+ children: d
73
+ }
74
+ );
23
75
  }
24
- function A() {
25
- const d = U(v);
76
+ function N() {
77
+ const d = T(A);
26
78
  if (!d) throw new Error("useUpstep must be used inside <UpstepProvider>");
27
79
  return d;
28
80
  }
29
- function W({ position: d = "bottom-right" }) {
30
- const { feedItems: p, submit: i, vote: f } = A(), [n, o] = s(!1), [b, g] = s("submit"), [r, a] = s(""), [l, S] = s("GENERAL"), [m, h] = s(""), [u, y] = s(!1), w = d === "bottom-left" ? { position: "fixed", bottom: 24, left: 24 } : { position: "fixed", bottom: 24, right: 24 };
31
- async function C() {
32
- if (!(!r.trim() || u)) {
33
- y(!0);
81
+ const P = {
82
+ BUG: "🐞 Bug",
83
+ FEATURE: "✨ Feature",
84
+ GENERAL: "💬 General"
85
+ };
86
+ function Q({
87
+ position: d = "bottom-right",
88
+ accentColor: l,
89
+ theme: t,
90
+ hideLauncher: n = !1
91
+ }) {
92
+ const i = N(), a = l ?? i.accentColor, o = M(t ?? i.theme), { feedItems: f, submit: y, vote: v, isOpen: S, open: k, close: h } = i, [s, u] = p("submit"), [g, C] = p(""), [x, I] = p("GENERAL"), [F, R] = p(""), [m, U] = p(!1), L = d === "bottom-left" ? { position: "fixed", bottom: 24, left: 24 } : { position: "fixed", bottom: 24, right: 24 };
93
+ async function W() {
94
+ if (!(!g.trim() || m)) {
95
+ U(!0);
34
96
  try {
35
- await i(r.trim(), l), a(""), h("Thanks for your feedback!");
97
+ await y(g.trim(), x), C(""), R("Thanks — we got your feedback! 🎉");
36
98
  } catch {
37
- h("Something went wrong.");
99
+ R("Something went wrong.");
38
100
  } finally {
39
- y(!1);
101
+ U(!1);
40
102
  }
41
103
  }
42
104
  }
43
- return /* @__PURE__ */ c(k, { children: [
44
- /* @__PURE__ */ e(
105
+ const w = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';
106
+ return /* @__PURE__ */ c(z, { children: [
107
+ !n && /* @__PURE__ */ c(
45
108
  "button",
46
109
  {
47
- onClick: () => o(!0),
110
+ onClick: k,
48
111
  style: {
49
- ...w,
112
+ ...L,
50
113
  zIndex: 9998,
51
- background: "#6366f1",
114
+ display: "inline-flex",
115
+ alignItems: "center",
116
+ gap: 7,
117
+ background: a,
52
118
  color: "#fff",
53
119
  border: "none",
54
120
  borderRadius: 9999,
55
- padding: "12px 20px",
121
+ padding: "12px 18px",
56
122
  fontSize: 14,
57
123
  fontWeight: 600,
58
124
  cursor: "pointer",
59
- boxShadow: "0 4px 12px rgba(0,0,0,.2)"
125
+ fontFamily: w,
126
+ boxShadow: "0 6px 20px rgba(26,25,21,.18)"
60
127
  },
61
- children: "Feedback"
128
+ children: [
129
+ /* @__PURE__ */ e($, {}),
130
+ " Feedback"
131
+ ]
62
132
  }
63
133
  ),
64
- n && /* @__PURE__ */ e(
134
+ S && /* @__PURE__ */ e(
65
135
  "div",
66
136
  {
67
- onClick: (t) => t.target === t.currentTarget && o(!1),
137
+ onClick: (r) => r.target === r.currentTarget && h(),
68
138
  style: {
69
139
  position: "fixed",
70
140
  inset: 0,
71
- background: "rgba(0,0,0,.45)",
141
+ background: o.overlay,
142
+ backdropFilter: "blur(3px)",
72
143
  zIndex: 9999,
73
144
  display: "flex",
74
- alignItems: "flex-end",
75
- justifyContent: "center"
145
+ alignItems: "center",
146
+ justifyContent: "center",
147
+ padding: 16,
148
+ fontFamily: w
76
149
  },
77
150
  children: /* @__PURE__ */ c(
78
151
  "div",
79
152
  {
80
153
  style: {
81
- background: "#fff",
82
- borderRadius: "16px 16px 0 0",
154
+ background: o.bg,
155
+ border: `1px solid ${o.border}`,
156
+ borderRadius: 20,
83
157
  width: "100%",
84
- maxWidth: 480,
85
- maxHeight: "90vh",
158
+ maxWidth: 440,
159
+ maxHeight: "88vh",
86
160
  display: "flex",
87
161
  flexDirection: "column",
88
- overflow: "hidden"
162
+ overflow: "hidden",
163
+ boxShadow: "0 24px 64px rgba(0,0,0,.28)"
89
164
  },
90
165
  children: [
91
- /* @__PURE__ */ c("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "16px 20px", borderBottom: "1px solid #e5e7eb" }, children: [
92
- /* @__PURE__ */ e("span", { style: { fontWeight: 700, fontSize: 16 }, children: "Share feedback" }),
93
- /* @__PURE__ */ e("button", { onClick: () => o(!1), style: { background: "none", border: "none", fontSize: 20, cursor: "pointer", color: "#6b7280" }, children: "✕" })
166
+ /* @__PURE__ */ c("div", { style: { display: "flex", alignItems: "flex-start", justifyContent: "space-between", padding: "20px 20px 0" }, children: [
167
+ /* @__PURE__ */ c("div", { children: [
168
+ /* @__PURE__ */ e("div", { style: { fontWeight: 700, fontSize: 16, color: o.text, letterSpacing: "-.01em" }, children: "Share your feedback" }),
169
+ /* @__PURE__ */ e("div", { style: { fontSize: 12.5, color: o.textFaint, marginTop: 2 }, children: "Tell us what to build next, or vote on ideas." })
170
+ ] }),
171
+ /* @__PURE__ */ e(
172
+ "button",
173
+ {
174
+ onClick: h,
175
+ 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" },
176
+ children: "✕"
177
+ }
178
+ )
94
179
  ] }),
95
- /* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: "1px solid #e5e7eb" }, children: ["submit", "feed"].map((t) => /* @__PURE__ */ e(
180
+ /* @__PURE__ */ e("div", { style: { display: "flex", gap: 4, margin: "16px 20px 0", padding: 4, background: o.bgSoft, borderRadius: 11 }, children: ["submit", "feed"].map((r) => /* @__PURE__ */ e(
96
181
  "button",
97
182
  {
98
- onClick: () => g(t),
183
+ onClick: () => u(r),
99
184
  style: {
100
185
  flex: 1,
101
- padding: 10,
102
- background: "none",
186
+ padding: 8,
103
187
  border: "none",
188
+ borderRadius: 8,
104
189
  fontSize: 13,
105
- fontWeight: 500,
190
+ fontWeight: 600,
106
191
  cursor: "pointer",
107
- color: b === t ? "#6366f1" : "#6b7280",
108
- borderBottom: b === t ? "2px solid #6366f1" : "2px solid transparent"
192
+ background: s === r ? o.bg : "transparent",
193
+ color: s === r ? o.text : o.textSoft,
194
+ boxShadow: s === r ? "0 1px 3px rgba(0,0,0,.08)" : "none"
109
195
  },
110
- children: t === "submit" ? "Submit" : "Votes & Ideas"
196
+ children: r === "submit" ? "Give feedback" : "Vote on ideas"
111
197
  },
112
- t
198
+ r
113
199
  )) }),
114
- /* @__PURE__ */ e("div", { style: { flex: 1, overflowY: "auto", padding: 16 }, children: b === "submit" ? /* @__PURE__ */ c("div", { children: [
200
+ /* @__PURE__ */ e("div", { style: { flex: 1, overflowY: "auto", padding: "18px 20px 22px" }, children: s === "submit" ? /* @__PURE__ */ c("div", { children: [
115
201
  /* @__PURE__ */ e(
116
202
  "textarea",
117
203
  {
118
- value: r,
119
- onChange: (t) => a(t.target.value),
204
+ value: g,
205
+ onChange: (r) => C(r.target.value),
120
206
  placeholder: "What's on your mind?",
121
207
  maxLength: 2e3,
122
- style: { width: "100%", minHeight: 100, border: "1px solid #d1d5db", borderRadius: 8, padding: 10, fontSize: 14, resize: "vertical", outline: "none" }
208
+ style: {
209
+ width: "100%",
210
+ minHeight: 104,
211
+ border: `1px solid ${o.border}`,
212
+ borderRadius: 12,
213
+ padding: 12,
214
+ fontSize: 14,
215
+ lineHeight: 1.5,
216
+ resize: "vertical",
217
+ outline: "none",
218
+ background: o.bgSoft,
219
+ color: o.text,
220
+ fontFamily: w
221
+ }
123
222
  }
124
223
  ),
125
- /* @__PURE__ */ e("div", { style: { display: "flex", gap: 8, margin: "10px 0" }, children: ["BUG", "FEATURE", "GENERAL"].map((t) => /* @__PURE__ */ e(
224
+ /* @__PURE__ */ e("div", { style: { display: "flex", gap: 7, margin: "12px 0 4px" }, children: ["BUG", "FEATURE", "GENERAL"].map((r) => /* @__PURE__ */ e(
126
225
  "button",
127
226
  {
128
- onClick: () => S(t),
227
+ onClick: () => I(r),
129
228
  style: {
130
- padding: "5px 12px",
131
- borderRadius: 9999,
132
- fontSize: 12,
229
+ flex: 1,
230
+ padding: "8px 10px",
231
+ borderRadius: 9,
232
+ fontSize: 12.5,
233
+ fontWeight: 600,
133
234
  cursor: "pointer",
134
- background: l === t ? "#6366f1" : "#fff",
135
- color: l === t ? "#fff" : "#374151",
136
- border: `1px solid ${l === t ? "#6366f1" : "#d1d5db"}`
235
+ background: x === r ? a : o.bg,
236
+ color: x === r ? "#fff" : o.textSoft,
237
+ border: `1px solid ${x === r ? a : o.border}`
137
238
  },
138
- children: t.charAt(0) + t.slice(1).toLowerCase()
239
+ children: P[r]
139
240
  },
140
- t
241
+ r
141
242
  )) }),
142
243
  /* @__PURE__ */ e(
143
244
  "button",
144
245
  {
145
- onClick: C,
146
- disabled: u || !r.trim(),
147
- style: { width: "100%", padding: 10, background: "#6366f1", color: "#fff", border: "none", borderRadius: 8, fontSize: 14, fontWeight: 600, cursor: "pointer", opacity: u || !r.trim() ? 0.5 : 1 },
148
- children: u ? "Sending…" : "Send feedback"
246
+ onClick: W,
247
+ disabled: m || !g.trim(),
248
+ style: {
249
+ width: "100%",
250
+ padding: 12,
251
+ background: a,
252
+ color: "#fff",
253
+ border: "none",
254
+ borderRadius: 11,
255
+ fontSize: 14,
256
+ fontWeight: 600,
257
+ cursor: "pointer",
258
+ marginTop: 14,
259
+ opacity: m || !g.trim() ? 0.5 : 1
260
+ },
261
+ children: m ? "Sending…" : "Send feedback"
149
262
  }
150
263
  ),
151
- m && /* @__PURE__ */ e("p", { style: { textAlign: "center", fontSize: 13, color: "#6b7280", marginTop: 8 }, children: m })
152
- ] }) : /* @__PURE__ */ e(F, { items: p, onVote: f }) })
264
+ F && /* @__PURE__ */ e("p", { style: { textAlign: "center", fontSize: 13, color: a, fontWeight: 500, marginTop: 12 }, children: F })
265
+ ] }) : /* @__PURE__ */ e(O, { items: f, onVote: v, accent: a, p: o }) })
153
266
  ]
154
267
  }
155
268
  )
@@ -157,41 +270,65 @@ function W({ position: d = "bottom-right" }) {
157
270
  )
158
271
  ] });
159
272
  }
160
- function F({ items: d, onVote: p }) {
161
- if (!d.length)
162
- return /* @__PURE__ */ e("p", { style: { textAlign: "center", color: "#9ca3af", fontSize: 14, padding: "32px 0" }, children: "No feedback yet. Be the first!" });
163
- const i = {
164
- BUG: "#fee2e2",
165
- FEATURE: "#dbeafe",
166
- GENERAL: "#f3f4f6"
167
- }, f = {
168
- BUG: "#dc2626",
169
- FEATURE: "#2563eb",
170
- GENERAL: "#6b7280"
171
- };
172
- return /* @__PURE__ */ e(k, { children: d.map((n) => /* @__PURE__ */ c("div", { style: { padding: "12px 0", borderBottom: "1px solid #f3f4f6" }, children: [
173
- /* @__PURE__ */ e("p", { style: { fontSize: 14, color: "#1f2937", margin: "0 0 8px" }, children: n.content }),
174
- /* @__PURE__ */ c("div", { style: { fontSize: 11, color: "#9ca3af", marginBottom: 8 }, children: [
175
- /* @__PURE__ */ e("span", { style: { background: i[n.type], color: f[n.type], borderRadius: 9999, padding: "2px 8px", fontSize: 11, fontWeight: 500, marginRight: 6 }, children: n.type }),
176
- new Date(n.createdAt).toLocaleDateString()
177
- ] }),
178
- /* @__PURE__ */ e("div", { style: { display: "flex", gap: 8 }, children: ["UP", "DOWN"].map((o) => /* @__PURE__ */ c(
179
- "button",
180
- {
181
- onClick: () => p(n.id, o),
182
- style: { display: "flex", alignItems: "center", gap: 4, padding: "4px 10px", borderRadius: 9999, border: "1px solid #e5e7eb", background: "#fff", fontSize: 12, cursor: "pointer" },
183
- children: [
184
- o === "UP" ? "▲" : "▼",
185
- " ",
186
- o === "UP" ? n.upvotes : n.downvotes
187
- ]
188
- },
189
- o
190
- )) })
191
- ] }, n.id)) });
273
+ function $() {
274
+ return /* @__PURE__ */ e("svg", { width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) });
275
+ }
276
+ const V = { BUG: "#fdecec", FEATURE: "#e9f0fd", GENERAL: "" }, _ = { BUG: "#d6453d", FEATURE: "#3b76d6", GENERAL: "" };
277
+ function O({
278
+ items: d,
279
+ onVote: l,
280
+ accent: t,
281
+ p: n
282
+ }) {
283
+ return d.length ? /* @__PURE__ */ e(z, { children: d.map((i) => {
284
+ const a = i.userVote === "UP";
285
+ return /* @__PURE__ */ c("div", { style: { display: "flex", gap: 12, padding: 14, border: `1px solid ${n.border}`, borderRadius: 14, marginBottom: 10, background: n.bg }, children: [
286
+ /* @__PURE__ */ c(
287
+ "button",
288
+ {
289
+ onClick: () => l(i.id, "UP"),
290
+ style: {
291
+ display: "flex",
292
+ flexDirection: "column",
293
+ alignItems: "center",
294
+ justifyContent: "center",
295
+ gap: 1,
296
+ minWidth: 46,
297
+ padding: "7px 0",
298
+ borderRadius: 11,
299
+ cursor: "pointer",
300
+ border: `1px solid ${a ? t : n.border}`,
301
+ background: a ? `${t}1a` : n.bgSoft
302
+ },
303
+ children: [
304
+ /* @__PURE__ */ e("span", { style: { fontSize: 11, lineHeight: 1, color: t }, children: "▲" }),
305
+ /* @__PURE__ */ e("span", { style: { fontSize: 14, fontWeight: 700, color: n.text, lineHeight: 1.1 }, children: i.upvotes })
306
+ ]
307
+ }
308
+ ),
309
+ /* @__PURE__ */ c("div", { style: { flex: 1, minWidth: 0 }, children: [
310
+ /* @__PURE__ */ e("p", { style: { fontSize: 13.5, lineHeight: 1.5, color: n.text, margin: "0 0 8px", wordBreak: "break-word" }, children: i.content }),
311
+ /* @__PURE__ */ c("div", { style: { display: "flex", alignItems: "center", gap: 7 }, children: [
312
+ /* @__PURE__ */ e("span", { style: {
313
+ padding: "2px 8px",
314
+ borderRadius: 9999,
315
+ fontSize: 10.5,
316
+ fontWeight: 700,
317
+ letterSpacing: ".02em",
318
+ background: V[i.type] || n.bgSoft,
319
+ color: _[i.type] || n.textSoft
320
+ }, children: i.type }),
321
+ /* @__PURE__ */ e("span", { style: { fontSize: 11, color: n.textFaint }, children: new Date(i.createdAt).toLocaleDateString() })
322
+ ] })
323
+ ] })
324
+ ] }, i.id);
325
+ }) }) : /* @__PURE__ */ c("div", { style: { textAlign: "center", padding: "40px 0" }, children: [
326
+ /* @__PURE__ */ e("div", { style: { color: n.textSoft, fontSize: 15, fontWeight: 600, marginBottom: 4 }, children: "No ideas yet" }),
327
+ /* @__PURE__ */ e("div", { style: { color: n.textFaint, fontSize: 14 }, children: "Be the first to share one." })
328
+ ] });
192
329
  }
193
330
  export {
194
- W as FeedbackWidget,
195
- T as UpstepProvider,
196
- A as useUpstep
331
+ Q as FeedbackWidget,
332
+ J as UpstepProvider,
333
+ N as useUpstep
197
334
  };
package/dist/widget.d.ts CHANGED
@@ -1,13 +1,30 @@
1
1
  import { UpstepApiClient } from './api';
2
+ type ThemeMode = "light" | "dark" | "auto";
3
+ export interface WidgetOptions {
4
+ accentColor?: string;
5
+ position?: "left" | "right";
6
+ /** Color theme. "auto" follows the OS preference. Defaults to "auto". */
7
+ theme?: ThemeMode;
8
+ /** Render the floating launcher button. Defaults to true. */
9
+ launcher?: boolean;
10
+ }
2
11
  export declare class UpstepWidget {
3
12
  private client;
4
- private open;
13
+ private isOpen;
5
14
  private tab;
6
15
  private feedItems;
7
16
  private selectedType;
8
17
  private loading;
9
- constructor(client: UpstepApiClient);
18
+ private accent;
19
+ private position;
20
+ private showLauncher;
21
+ private palette;
22
+ constructor(client: UpstepApiClient, options?: WidgetOptions);
10
23
  mount(): void;
24
+ /** Open the feedback modal programmatically (e.g. from your own button). */
25
+ openWidget(): void;
26
+ /** Close the feedback modal programmatically. */
27
+ closeWidget(): void;
11
28
  private injectStyles;
12
29
  private renderButton;
13
30
  private openModal;
@@ -20,4 +37,5 @@ export declare class UpstepWidget {
20
37
  private bindSubmitForm;
21
38
  private bindVoteButtons;
22
39
  }
40
+ export {};
23
41
  //# sourceMappingURL=widget.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAsCxC,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,eAAe;IAInC,KAAK;IAKL,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,UAAU;YAMJ,SAAS;IAUvB,OAAO,CAAC,WAAW;IAsCnB,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,UAAU;IAsBlB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;IAmCtB,OAAO,CAAC,eAAe;CAcxB"}
1
+ {"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAIxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAoG3C,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,OAAO,CAAU;gBAEb,MAAM,EAAE,eAAe,EAAE,OAAO,GAAE,aAAkB;IAQhE,KAAK;IAKL,4EAA4E;IAC5E,UAAU;IAIV,iDAAiD;IACjD,WAAW;IAIX,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,UAAU;YAKJ,SAAS;IAUvB,OAAO,CAAC,WAAW;IAyCnB,OAAO,CAAC,gBAAgB;IAexB,OAAO,CAAC,UAAU;IAwBlB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;IAyCtB,OAAO,CAAC,eAAe;CAaxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upstep/js",
3
- "version": "0.1.0",
3
+ "version": "0.4.0",
4
4
  "description": "Upstep feedback widget for web apps",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "dist"
22
22
  ],
23
23
  "dependencies": {
24
- "@upstep/types": "0.0.1"
24
+ "@upstep/types": "0.4.0"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "react": ">=18",
@@ -1 +0,0 @@
1
- "use strict";class i{constructor(e){this.baseUrl=(e.baseUrl??"https://upstep.io").replace(/\/$/,""),this.apiKey=e.apiKey,e.userId!==void 0&&(this.userId=e.userId)}headers(){return{"Content-Type":"application/json","x-api-key":this.apiKey}}async listFeedback(e){const t=new URLSearchParams;e!=null&&e.cursor&&t.set("cursor",e.cursor),e!=null&&e.limit&&t.set("limit",String(e.limit)),e!=null&&e.type&&t.set("type",e.type),e!=null&&e.status&&t.set("status",e.status),e!=null&&e.sort&&t.set("sort",e.sort);const s=await fetch(`${this.baseUrl}/api/sdk/feedback?${t}`,{headers:this.headers()});if(!s.ok)throw new Error(`Upstep: ${s.status}`);return s.json()}async submitFeedback(e){const t=await fetch(`${this.baseUrl}/api/sdk/feedback`,{method:"POST",headers:this.headers(),body:JSON.stringify({...e,endUserId:e.endUserId??this.userId})});if(!t.ok)throw new Error(`Upstep: ${t.status}`);return t.json()}async vote(e,t){const s=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote`,{method:"POST",headers:this.headers(),body:JSON.stringify({value:t,endUserId:this.userId})});if(!s.ok)throw new Error(`Upstep: ${s.status}`)}async removeVote(e){if(!this.userId)return;const t=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote?endUserId=${encodeURIComponent(this.userId)}`,{method:"DELETE",headers:this.headers()});if(!t.ok)throw new Error(`Upstep: ${t.status}`)}}exports.UpstepApiClient=i;