@upstep/js 0.5.12 → 0.6.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/README.md +36 -1
- package/dist/api-BuSqdsZp.js +1 -0
- package/dist/{api-DIQt-yuC.mjs → api-C1UV7Szw.mjs} +31 -7
- package/dist/api.d.ts +7 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/embed.d.ts +2 -0
- package/dist/embed.d.ts.map +1 -0
- package/dist/index.cjs +8 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +65 -49
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts +4 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +265 -234
- package/dist/upstep.global.js +91 -0
- package/dist/widget.d.ts +2 -0
- package/dist/widget.d.ts.map +1 -1
- package/package.json +7 -4
- package/dist/api-DLrEC5_l.js +0 -1
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ Mount that once from the client-side root for your framework:
|
|
|
54
54
|
```html
|
|
55
55
|
<script
|
|
56
56
|
type="module"
|
|
57
|
-
src="https://unpkg.com/@upstep/js/dist/
|
|
57
|
+
src="https://unpkg.com/@upstep/js/dist/upstep.global.js"
|
|
58
58
|
data-api-key="upstep_xxx"
|
|
59
59
|
></script>
|
|
60
60
|
```
|
|
@@ -97,3 +97,38 @@ Every entry point (`Upstep.init`, `<UpstepProvider>`, and the script tag's `data
|
|
|
97
97
|
- [Dashboard / sign up](https://upstep.dev/login)
|
|
98
98
|
- [@upstep/react-native](https://www.npmjs.com/package/@upstep/react-native) for React Native apps
|
|
99
99
|
- [upstep_flutter](https://pub.dev/packages/upstep_flutter) for Flutter apps
|
|
100
|
+
|
|
101
|
+
### AI and live chat in the existing widget
|
|
102
|
+
|
|
103
|
+
Version 0.6.0 adds a **Support** tab to the same widget that handles feedback and
|
|
104
|
+
voting. Enable customer support for your paid project in the UpStep dashboard,
|
|
105
|
+
learn the business website, and confirm the business details and contact email.
|
|
106
|
+
The project must be enabled on the server; `chat: true` never bypasses plan access.
|
|
107
|
+
Chat is shown automatically by default when the project has enabled support.
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import Upstep from '@upstep/js';
|
|
111
|
+
Upstep.init({ apiKey: 'YOUR_PROJECT_KEY', chat: true });
|
|
112
|
+
// Use chat: false to keep this embed focused on feedback and voting.
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
import { UpstepProvider, FeedbackWidget } from '@upstep/js/react';
|
|
117
|
+
<UpstepProvider apiKey="YOUR_PROJECT_KEY" chat={true}>
|
|
118
|
+
<FeedbackWidget />
|
|
119
|
+
</UpstepProvider>
|
|
120
|
+
// FeedbackWidget also accepts chat={false} to hide chat in that widget.
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
```html
|
|
124
|
+
<script defer src="https://unpkg.com/@upstep/js@0.6.0/dist/upstep.global.js"
|
|
125
|
+
data-api-key="YOUR_PROJECT_KEY" data-chat="true"></script>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
When no teammate is available, AI continues helping from the business's website
|
|
129
|
+
and confirmed answers. Unresolved issues can become private tickets with stable
|
|
130
|
+
references and the business's confirmed support email. Customer email is optional.
|
|
131
|
+
For private cross-device customer history, pass a backend-signed JWT as
|
|
132
|
+
`supportIdentityToken`, or call `Upstep.identifySupport(token)` after login and
|
|
133
|
+
`Upstep.identifySupport(undefined)` on logout. Never put the identity signing
|
|
134
|
+
secret in browser code. [Integration guide](https://upstep.dev/guides/customer-support).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const d="upstep-anonymous-id";function h(){const o=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;if(typeof window>"u")return o;try{const e=window.localStorage.getItem(d);return e||(window.localStorage.setItem(d,o),o)}catch{return o}}class u{constructor(e){this.baseUrl=(e.baseUrl??"https://upstep.dev").replace(/\/$/,""),this.apiKey=e.apiKey,this.supportIdentityToken=e.supportIdentityToken,this.chat=e.chat!==!1,e.userId!==void 0&&(this.userId=e.userId),this.anonymousId=h()}setUserId(e){this.userId=e}headers(){return{"Content-Type":"application/json","x-api-key":this.apiKey}}async supportEnabled(){if(!this.chat)return!1;try{const e=await fetch(`${this.baseUrl}/api/sdk/support`,{headers:this.headers()});return e.ok&&(await e.json()).enabled===!0}catch{return!1}}supportFrameUrl(e){return`${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(e)}`}connectSupportFrame(e){const t=new URL(this.baseUrl).origin,s=()=>{var n;return(n=e.contentWindow)==null?void 0:n.postMessage({type:"upstep:support:identity",token:this.supportIdentityToken},t)},i=n=>{var r;n.origin===t&&n.source===e.contentWindow&&((r=n.data)==null?void 0:r.type)==="upstep:support:ready"&&s()};return e.addEventListener("load",s),window.addEventListener("message",i),()=>{e.removeEventListener("load",s),window.removeEventListener("message",i)}}async listFeedback(e){const t=new URLSearchParams;e!=null&&e.cursor&&t.set("cursor",e.cursor),e!=null&&e.limit&&t.set("limit",String(e.limit)),e!=null&&e.type&&t.set("type",e.type),e!=null&&e.status&&t.set("status",e.status),e!=null&&e.sort&&t.set("sort",e.sort),this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);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,anonymousId:e.anonymousId??this.anonymousId})});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,anonymousId:this.anonymousId})});if(!s.ok)throw new Error(`Upstep: ${s.status}`)}async getItem(e){const t=new URLSearchParams;this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const s=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}?${t}`,{headers:this.headers()});if(!s.ok)throw new Error(`Upstep: ${s.status}`);return s.json()}async removeVote(e){if(!this.userId&&!this.anonymousId)return;const t=new URLSearchParams;this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const s=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote?${t}`,{method:"DELETE",headers:this.headers()});if(!s.ok)throw new Error(`Upstep: ${s.status}`)}}exports.UpstepApiClient=u;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
1
|
+
const d = "upstep-anonymous-id";
|
|
2
|
+
function h() {
|
|
3
3
|
const o = typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
4
4
|
if (typeof window > "u") return o;
|
|
5
5
|
try {
|
|
6
|
-
const e = window.localStorage.getItem(
|
|
7
|
-
return e || (window.localStorage.setItem(
|
|
6
|
+
const e = window.localStorage.getItem(d);
|
|
7
|
+
return e || (window.localStorage.setItem(d, o), o);
|
|
8
8
|
} catch {
|
|
9
9
|
return o;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
class
|
|
12
|
+
class u {
|
|
13
13
|
constructor(e) {
|
|
14
|
-
this.baseUrl = (e.baseUrl ?? "https://upstep.dev").replace(/\/$/, ""), this.apiKey = e.apiKey, e.userId !== void 0 && (this.userId = e.userId), this.anonymousId =
|
|
14
|
+
this.baseUrl = (e.baseUrl ?? "https://upstep.dev").replace(/\/$/, ""), this.apiKey = e.apiKey, this.supportIdentityToken = e.supportIdentityToken, this.chat = e.chat !== !1, e.userId !== void 0 && (this.userId = e.userId), this.anonymousId = h();
|
|
15
15
|
}
|
|
16
16
|
/** Update the end-user id at runtime (e.g. after the user logs in). */
|
|
17
17
|
setUserId(e) {
|
|
@@ -23,6 +23,30 @@ class r {
|
|
|
23
23
|
"x-api-key": this.apiKey
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
+
async supportEnabled() {
|
|
27
|
+
if (!this.chat) return !1;
|
|
28
|
+
try {
|
|
29
|
+
const e = await fetch(`${this.baseUrl}/api/sdk/support`, { headers: this.headers() });
|
|
30
|
+
return e.ok && (await e.json()).enabled === !0;
|
|
31
|
+
} catch {
|
|
32
|
+
return !1;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
supportFrameUrl(e) {
|
|
36
|
+
return `${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(e)}`;
|
|
37
|
+
}
|
|
38
|
+
connectSupportFrame(e) {
|
|
39
|
+
const t = new URL(this.baseUrl).origin, s = () => {
|
|
40
|
+
var n;
|
|
41
|
+
return (n = e.contentWindow) == null ? void 0 : n.postMessage({ type: "upstep:support:identity", token: this.supportIdentityToken }, t);
|
|
42
|
+
}, r = (n) => {
|
|
43
|
+
var i;
|
|
44
|
+
n.origin === t && n.source === e.contentWindow && ((i = n.data) == null ? void 0 : i.type) === "upstep:support:ready" && s();
|
|
45
|
+
};
|
|
46
|
+
return e.addEventListener("load", s), window.addEventListener("message", r), () => {
|
|
47
|
+
e.removeEventListener("load", s), window.removeEventListener("message", r);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
26
50
|
async listFeedback(e) {
|
|
27
51
|
const t = new URLSearchParams();
|
|
28
52
|
e != null && e.cursor && t.set("cursor", e.cursor), e != null && e.limit && t.set("limit", String(e.limit)), e != null && e.type && t.set("type", e.type), e != null && e.status && t.set("status", e.status), e != null && e.sort && t.set("sort", e.sort), this.userId && t.set("endUserId", this.userId), this.anonymousId && t.set("anonymousId", this.anonymousId);
|
|
@@ -74,5 +98,5 @@ class r {
|
|
|
74
98
|
}
|
|
75
99
|
}
|
|
76
100
|
export {
|
|
77
|
-
|
|
101
|
+
u as U
|
|
78
102
|
};
|
package/dist/api.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { Feedback, FeedbackListResponse, FeedbackWithComments, SubmitFeedbackPayload, VotePayload, UpstepConfig } from '@upstep/types';
|
|
2
2
|
export declare class UpstepApiClient {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
readonly baseUrl: string;
|
|
4
|
+
readonly apiKey: string;
|
|
5
5
|
userId: string | undefined;
|
|
6
|
+
supportIdentityToken: string | undefined;
|
|
7
|
+
chat: boolean;
|
|
6
8
|
readonly anonymousId: string | undefined;
|
|
7
9
|
constructor(config: UpstepConfig);
|
|
8
10
|
/** Update the end-user id at runtime (e.g. after the user logs in). */
|
|
9
11
|
setUserId(userId: string | undefined): void;
|
|
10
12
|
private headers;
|
|
13
|
+
supportEnabled(): Promise<boolean>;
|
|
14
|
+
supportFrameUrl(theme: string): string;
|
|
15
|
+
connectSupportFrame(frame: HTMLIFrameElement): () => void;
|
|
11
16
|
listFeedback(params?: {
|
|
12
17
|
cursor?: string;
|
|
13
18
|
limit?: number;
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACb,MAAM,eAAe,CAAC;AAyBvB,qBAAa,eAAe;IAC1B,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACb,MAAM,eAAe,CAAC;AAyBvB,qBAAa,eAAe;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE7B,MAAM,EAAE,YAAY;IAShC,uEAAuE;IACvE,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAIpC,OAAO,CAAC,OAAO;IAOT,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAKxC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAItC,mBAAmB,CAAC,KAAK,EAAE,iBAAiB;IAStC,YAAY,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACzB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkB3B,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAcjE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IASpE,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAW1D,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWpD"}
|
package/dist/embed.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":""}
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("./api-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("./api-BuSqdsZp.js"),S="#D97757",m={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},x={bg:"#000000",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function y(o){if(o==="light"||o==="dark")return o;if(typeof document<"u"){const e=document.documentElement;return e.classList.contains("dark")||e.getAttribute("data-theme")==="dark"?"dark":"light"}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function L(o,e,t){return`
|
|
2
2
|
#upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
|
|
3
3
|
#upstep-btn{position:fixed;bottom:24px;${e==="left"?"left:24px":"right:24px"};z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${o};color:#fff;border:none;border-radius:9999px;padding:12px 18px;font-size:14px;font-weight:600;cursor:grab;touch-action:none;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
|
|
4
4
|
#upstep-btn svg{width:16px;height:16px;flex-shrink:0}
|
|
@@ -47,24 +47,25 @@
|
|
|
47
47
|
.upstep-feedback-date{font-size:11px;color:${t.textFaint}}
|
|
48
48
|
.upstep-empty{text-align:center;color:${t.textFaint};font-size:14px;padding:40px 0}
|
|
49
49
|
.upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
|
|
50
|
-
`}const C='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';class F{constructor(e,t={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.dragMoved=!1,this.client=e,this.accent=t.accentColor??
|
|
50
|
+
`}const C='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';class F{constructor(e,t={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.dragMoved=!1,this.hasSupport=!1,this.disconnectSupport=null,this.client=e,this.accent=t.accentColor??S,this.position=t.position??"right",this.showLauncher=t.launcher!==!1,this.themeMode=t.theme??"auto",this.palette=y(this.themeMode)==="dark"?x:m}mount(){this.injectStyles(),this.showLauncher&&this.renderButton(),this.client.supportEnabled().then(e=>{if(this.hasSupport=e,e){const t=document.querySelector("#upstep-btn span");t&&(t.textContent="Help & feedback"),this.isOpen&&this.renderModal()}})}openWidget(){this.openModal()}closeWidget(){this.closeModal()}injectStyles(){var t;(t=document.getElementById("upstep-styles"))==null||t.remove();const e=document.createElement("style");e.id="upstep-styles",e.textContent=L(this.accent,this.position,this.palette),document.head.appendChild(e)}renderButton(){const e=document.createElement("button");e.id="upstep-btn",e.setAttribute("aria-label","Open help and feedback"),e.innerHTML=`${C}<span>Feedback</span>`,e.addEventListener("click",()=>{this.dragMoved||this.openModal()}),document.body.appendChild(e),this.makeDraggable(e)}makeDraggable(e){const s="upstep-btn-pos";try{const i=localStorage.getItem(s);if(i){const{side:d,bottom:u}=JSON.parse(i);e.style.left=d==="left"?"24px":"auto",e.style.right=d==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${u}px`}}catch{}let a=0,r=0,l=0,b=0,h=!1;const $=()=>{const i=e.getBoundingClientRect(),d=i.left+i.width/2<window.innerWidth/2?"left":"right",u=Math.max(24,Math.min(window.innerHeight-i.height-24,i.top)),g=window.innerHeight-u-i.height;e.style.transition="left .25s cubic-bezier(.16,1,.3,1),right .25s cubic-bezier(.16,1,.3,1),top .25s cubic-bezier(.16,1,.3,1),bottom .25s cubic-bezier(.16,1,.3,1),transform .15s,box-shadow .15s",e.style.left=d==="left"?"24px":"auto",e.style.right=d==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${g}px`;try{localStorage.setItem(s,JSON.stringify({side:d,bottom:g}))}catch{}},M=i=>{if(i.pointerType==="mouse"&&i.button!==0)return;this.dragMoved=!1,h=!0;const d=e.getBoundingClientRect();a=i.clientX,r=i.clientY,l=d.left,b=d.top,e.setPointerCapture(i.pointerId),e.style.transition="none"},E=i=>{if(!h)return;const d=i.clientX-a,u=i.clientY-r;!this.dragMoved&&Math.hypot(d,u)<6||(this.dragMoved||e.classList.add("upstep-dragging"),this.dragMoved=!0,e.style.left=`${l+d}px`,e.style.right="auto",e.style.top=`${b+u}px`,e.style.bottom="auto")},f=()=>{h&&(h=!1,e.classList.remove("upstep-dragging"),this.dragMoved&&$())};e.addEventListener("pointerdown",M),e.addEventListener("pointermove",E),e.addEventListener("pointerup",f),e.addEventListener("pointercancel",f)}openModal(){this.isOpen=!0,this.palette=y(this.themeMode)==="dark"?x:m,this.injectStyles(),this.fetchFeed(),this.renderModal()}closeModal(){var e,t;(e=this.disconnectSupport)==null||e.call(this),this.disconnectSupport=null,this.isOpen=!1,(t=document.getElementById("upstep-backdrop"))==null||t.remove()}async fetchFeed(){try{const e=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=e.items,this.renderFeedList()}catch{}}renderModal(){var n,s,a;(n=this.disconnectSupport)==null||n.call(this),this.disconnectSupport=null;const e=document.createElement("div");e.id="upstep-backdrop",e.addEventListener("click",r=>{r.target===e&&this.closeModal()}),e.innerHTML=`
|
|
51
51
|
<div id="upstep-modal">
|
|
52
52
|
<div id="upstep-header">
|
|
53
53
|
<div>
|
|
54
|
-
<h2
|
|
55
|
-
<p
|
|
54
|
+
<h2>${this.tab==="support"?"Customer support":"Share your feedback"}</h2>
|
|
55
|
+
<p>${this.tab==="support"?"Ask AI, or talk with the team.":"Tell us what to build next, or vote on ideas."}</p>
|
|
56
56
|
</div>
|
|
57
57
|
<button id="upstep-close" aria-label="Close">✕</button>
|
|
58
58
|
</div>
|
|
59
59
|
<div id="upstep-tabs">
|
|
60
|
+
${this.hasSupport?`<button class="upstep-tab ${this.tab==="support"?"active":""}" data-tab="support">Support</button>`:""}
|
|
60
61
|
<button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Give feedback</button>
|
|
61
62
|
<button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Vote on ideas</button>
|
|
62
63
|
</div>
|
|
63
64
|
<div id="upstep-body">
|
|
64
|
-
${this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
65
|
+
${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg==="#000000"?"dark":"light")}" style="width:100%;height:480px;border:0;display:block;border-radius:12px"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
65
66
|
</div>
|
|
66
67
|
</div>
|
|
67
|
-
`,(
|
|
68
|
+
`,(s=document.getElementById("upstep-backdrop"))==null||s.remove(),document.body.appendChild(e),(a=e.querySelector("#upstep-close"))==null||a.addEventListener("click",()=>this.closeModal()),e.querySelectorAll(".upstep-tab").forEach(r=>{r.addEventListener("click",()=>{this.tab=r.dataset.tab,this.renderModal()})});const t=e.querySelector("#upstep-support-frame");t&&(this.disconnectSupport=this.client.connectSupportFrame(t)),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const e=["BUG","FEATURE","GENERAL"],t={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},n={BUG:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="8" cy="10" rx="3.5" ry="4.5"/><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"/></svg>',FEATURE:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><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"/><circle cx="8" cy="8" r="2.5"/></svg>',GENERAL:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"/></svg>'};return`
|
|
68
69
|
<div class="upstep-form">
|
|
69
70
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
70
71
|
<div class="upstep-type-row">
|
|
@@ -87,4 +88,4 @@
|
|
|
87
88
|
<span class="upstep-feedback-date">${new Date(e.createdAt).toLocaleDateString()}</span>
|
|
88
89
|
</div>
|
|
89
90
|
</div>
|
|
90
|
-
</div>`}).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const e=document.getElementById("upstep-body");!e||this.tab!=="feed"||(e.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var e;document.querySelectorAll(".upstep-type-btn").forEach(t=>{t.addEventListener("click",()=>{this.selectedType=t.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(n=>n.classList.remove("selected")),t.classList.add("selected")})}),(e=document.getElementById("upstep-submit-btn"))==null||e.addEventListener("click",async()=>{const t=document.getElementById("upstep-textarea"),n=document.getElementById("upstep-form-msg"),s=document.getElementById("upstep-submit-btn");if(!t||this.loading)return;const
|
|
91
|
+
</div>`}).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const e=document.getElementById("upstep-body");!e||this.tab!=="feed"||(e.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var e;document.querySelectorAll(".upstep-type-btn").forEach(t=>{t.addEventListener("click",()=>{this.selectedType=t.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(n=>n.classList.remove("selected")),t.classList.add("selected")})}),(e=document.getElementById("upstep-submit-btn"))==null||e.addEventListener("click",async()=>{const t=document.getElementById("upstep-textarea"),n=document.getElementById("upstep-form-msg"),s=document.getElementById("upstep-submit-btn");if(!t||this.loading)return;const a=t.value.trim();if(a){this.loading=!0,s&&(s.disabled=!0,s.textContent="Sending…");try{await this.client.submitFeedback({content:a,type:this.selectedType}),t.value="",n&&(n.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{n&&(n.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,s&&(s.disabled=!1,s.textContent="Send feedback")}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote").forEach(e=>{e.addEventListener("click",async()=>{const t=e.dataset.feedback;try{await this.client.vote(t,"UP"),await this.fetchFeed()}catch{}})})}}function v(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let p=null,c=null;const w={init(o){if(p=new k.UpstepApiClient(o),typeof window<"u"){const e={};o.accentColor!==void 0&&(e.accentColor=o.accentColor),o.position!==void 0&&(e.position=o.position),o.theme!==void 0&&(e.theme=o.theme),o.launcher!==void 0&&(e.launcher=o.launcher);const t=()=>{c=new F(p,e),c.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}return p},open(){c==null||c.openWidget()},close(){c==null||c.closeWidget()},identify(o){p==null||p.setUserId(o)},identifySupport(o){var t;p&&(p.supportIdentityToken=o);const e=document.querySelector("#upstep-support-frame");e&&p&&((t=e.contentWindow)==null||t.postMessage({type:"upstep:support:identity",token:o},new URL(p.baseUrl).origin))},get client(){if(!p)throw new Error("Upstep.init() must be called first");return p}};if(typeof document<"u"){const o=document.currentScript,e=o==null?void 0:o.dataset.apiKey,t=o==null?void 0:o.dataset.userId,n=o==null?void 0:o.dataset.baseUrl,s=o==null?void 0:o.dataset.accentColor,a=o==null?void 0:o.dataset.position,r=o==null?void 0:o.dataset.theme;if(e){const l={apiKey:e};t&&(l.userId=t),(o==null?void 0:o.dataset.chat)!==void 0&&(l.chat=o.dataset.chat!=="false"),n&&(l.baseUrl=n),s&&(l.accentColor=s),(a==="left"||a==="right")&&(l.position=a),(r==="light"||r==="dark"||r==="auto")&&(l.theme=r),w.init(l)}}exports.UpstepApiClient=k.UpstepApiClient;exports.default=w;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ declare const Upstep: {
|
|
|
10
10
|
close(): void;
|
|
11
11
|
/** Set / update the end-user id at runtime (e.g. after the user logs in). */
|
|
12
12
|
identify(userId: string | undefined): void;
|
|
13
|
+
/** Change or clear verified support identity after login/logout. */
|
|
14
|
+
identifySupport(token: string | undefined): void;
|
|
13
15
|
readonly client: UpstepApiClient;
|
|
14
16
|
};
|
|
15
17
|
export default Upstep;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAGxC,YAAY,EAAE,YAAY,EAAE,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,CAAC;AAK3B,QAAA,MAAM,MAAM;iBACG,YAAY;IAqBzB,0EAA0E;;IAK1E,iCAAiC;;IAKjC,6EAA6E;qBAC5D,MAAM,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAGxC,YAAY,EAAE,YAAY,EAAE,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,CAAC;AAK3B,QAAA,MAAM,MAAM;iBACG,YAAY;IAqBzB,0EAA0E;;IAK1E,iCAAiC;;IAKjC,6EAA6E;qBAC5D,MAAM,GAAG,SAAS;IAInC,oEAAoE;2BAC7C,MAAM,GAAG,SAAS;qBAM3B,eAAe;CAI9B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { U as M } from "./api-
|
|
2
|
-
const E = "#D97757",
|
|
1
|
+
import { U as M } from "./api-C1UV7Szw.mjs";
|
|
2
|
+
const E = "#D97757", m = {
|
|
3
3
|
bg: "#ffffff",
|
|
4
4
|
bgSoft: "#f6f5f2",
|
|
5
5
|
bgHover: "#efede8",
|
|
@@ -8,8 +8,8 @@ const E = "#D97757", x = {
|
|
|
8
8
|
textFaint: "#9b9890",
|
|
9
9
|
border: "#e8e6df",
|
|
10
10
|
overlay: "rgba(26,25,21,.45)"
|
|
11
|
-
},
|
|
12
|
-
bg: "#
|
|
11
|
+
}, x = {
|
|
12
|
+
bg: "#000000",
|
|
13
13
|
bgSoft: "#262522",
|
|
14
14
|
bgHover: "#302e2a",
|
|
15
15
|
text: "#f5f4f0",
|
|
@@ -26,7 +26,7 @@ function y(o) {
|
|
|
26
26
|
}
|
|
27
27
|
return typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function S(o, e, t) {
|
|
30
30
|
return `
|
|
31
31
|
#upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
|
|
32
32
|
#upstep-btn{position:fixed;bottom:24px;${e === "left" ? "left:24px" : "right:24px"};z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${o};color:#fff;border:none;border-radius:9999px;padding:12px 18px;font-size:14px;font-weight:600;cursor:grab;touch-action:none;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
|
|
@@ -78,13 +78,18 @@ function L(o, e, t) {
|
|
|
78
78
|
.upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
|
|
79
79
|
`;
|
|
80
80
|
}
|
|
81
|
-
const
|
|
82
|
-
class
|
|
81
|
+
const L = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';
|
|
82
|
+
class C {
|
|
83
83
|
constructor(e, t = {}) {
|
|
84
|
-
this.isOpen = !1, this.tab = "submit", this.feedItems = [], this.selectedType = "GENERAL", this.loading = !1, this.dragMoved = !1, this.client = e, this.accent = t.accentColor ?? E, this.position = t.position ?? "right", this.showLauncher = t.launcher !== !1, this.themeMode = t.theme ?? "auto", this.palette = y(this.themeMode) === "dark" ?
|
|
84
|
+
this.isOpen = !1, this.tab = "submit", this.feedItems = [], this.selectedType = "GENERAL", this.loading = !1, this.dragMoved = !1, this.hasSupport = !1, this.disconnectSupport = null, this.client = e, this.accent = t.accentColor ?? E, this.position = t.position ?? "right", this.showLauncher = t.launcher !== !1, this.themeMode = t.theme ?? "auto", this.palette = y(this.themeMode) === "dark" ? x : m;
|
|
85
85
|
}
|
|
86
86
|
mount() {
|
|
87
|
-
this.injectStyles(), this.showLauncher && this.renderButton()
|
|
87
|
+
this.injectStyles(), this.showLauncher && this.renderButton(), this.client.supportEnabled().then((e) => {
|
|
88
|
+
if (this.hasSupport = e, e) {
|
|
89
|
+
const t = document.querySelector("#upstep-btn span");
|
|
90
|
+
t && (t.textContent = "Help & feedback"), this.isOpen && this.renderModal();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
88
93
|
}
|
|
89
94
|
/** Open the feedback modal programmatically (e.g. from your own button). */
|
|
90
95
|
openWidget() {
|
|
@@ -98,11 +103,11 @@ class F {
|
|
|
98
103
|
var t;
|
|
99
104
|
(t = document.getElementById("upstep-styles")) == null || t.remove();
|
|
100
105
|
const e = document.createElement("style");
|
|
101
|
-
e.id = "upstep-styles", e.textContent =
|
|
106
|
+
e.id = "upstep-styles", e.textContent = S(this.accent, this.position, this.palette), document.head.appendChild(e);
|
|
102
107
|
}
|
|
103
108
|
renderButton() {
|
|
104
109
|
const e = document.createElement("button");
|
|
105
|
-
e.id = "upstep-btn", e.innerHTML = `${
|
|
110
|
+
e.id = "upstep-btn", e.setAttribute("aria-label", "Open help and feedback"), e.innerHTML = `${L}<span>Feedback</span>`, e.addEventListener("click", () => {
|
|
106
111
|
this.dragMoved || this.openModal();
|
|
107
112
|
}), document.body.appendChild(e), this.makeDraggable(e);
|
|
108
113
|
}
|
|
@@ -111,39 +116,39 @@ class F {
|
|
|
111
116
|
try {
|
|
112
117
|
const i = localStorage.getItem(s);
|
|
113
118
|
if (i) {
|
|
114
|
-
const { side:
|
|
115
|
-
e.style.left =
|
|
119
|
+
const { side: d, bottom: u } = JSON.parse(i);
|
|
120
|
+
e.style.left = d === "left" ? "24px" : "auto", e.style.right = d === "right" ? "24px" : "auto", e.style.top = "auto", e.style.bottom = `${u}px`;
|
|
116
121
|
}
|
|
117
122
|
} catch {
|
|
118
123
|
}
|
|
119
|
-
let
|
|
124
|
+
let a = 0, r = 0, l = 0, b = 0, h = !1;
|
|
120
125
|
const k = () => {
|
|
121
|
-
const i = e.getBoundingClientRect(),
|
|
122
|
-
e.style.transition = "left .25s cubic-bezier(.16,1,.3,1),right .25s cubic-bezier(.16,1,.3,1),top .25s cubic-bezier(.16,1,.3,1),bottom .25s cubic-bezier(.16,1,.3,1),transform .15s,box-shadow .15s", e.style.left =
|
|
126
|
+
const i = e.getBoundingClientRect(), d = i.left + i.width / 2 < window.innerWidth / 2 ? "left" : "right", u = Math.max(24, Math.min(window.innerHeight - i.height - 24, i.top)), g = window.innerHeight - u - i.height;
|
|
127
|
+
e.style.transition = "left .25s cubic-bezier(.16,1,.3,1),right .25s cubic-bezier(.16,1,.3,1),top .25s cubic-bezier(.16,1,.3,1),bottom .25s cubic-bezier(.16,1,.3,1),transform .15s,box-shadow .15s", e.style.left = d === "left" ? "24px" : "auto", e.style.right = d === "right" ? "24px" : "auto", e.style.top = "auto", e.style.bottom = `${g}px`;
|
|
123
128
|
try {
|
|
124
|
-
localStorage.setItem(s, JSON.stringify({ side:
|
|
129
|
+
localStorage.setItem(s, JSON.stringify({ side: d, bottom: g }));
|
|
125
130
|
} catch {
|
|
126
131
|
}
|
|
127
132
|
}, w = (i) => {
|
|
128
133
|
if (i.pointerType === "mouse" && i.button !== 0) return;
|
|
129
|
-
this.dragMoved = !1,
|
|
130
|
-
const
|
|
131
|
-
|
|
134
|
+
this.dragMoved = !1, h = !0;
|
|
135
|
+
const d = e.getBoundingClientRect();
|
|
136
|
+
a = i.clientX, r = i.clientY, l = d.left, b = d.top, e.setPointerCapture(i.pointerId), e.style.transition = "none";
|
|
132
137
|
}, $ = (i) => {
|
|
133
|
-
if (!
|
|
134
|
-
const
|
|
135
|
-
!this.dragMoved && Math.hypot(
|
|
138
|
+
if (!h) return;
|
|
139
|
+
const d = i.clientX - a, u = i.clientY - r;
|
|
140
|
+
!this.dragMoved && Math.hypot(d, u) < 6 || (this.dragMoved || e.classList.add("upstep-dragging"), this.dragMoved = !0, e.style.left = `${l + d}px`, e.style.right = "auto", e.style.top = `${b + u}px`, e.style.bottom = "auto");
|
|
136
141
|
}, f = () => {
|
|
137
|
-
|
|
142
|
+
h && (h = !1, e.classList.remove("upstep-dragging"), this.dragMoved && k());
|
|
138
143
|
};
|
|
139
144
|
e.addEventListener("pointerdown", w), e.addEventListener("pointermove", $), e.addEventListener("pointerup", f), e.addEventListener("pointercancel", f);
|
|
140
145
|
}
|
|
141
146
|
openModal() {
|
|
142
|
-
this.isOpen = !0, this.palette = y(this.themeMode) === "dark" ?
|
|
147
|
+
this.isOpen = !0, this.palette = y(this.themeMode) === "dark" ? x : m, this.injectStyles(), this.fetchFeed(), this.renderModal();
|
|
143
148
|
}
|
|
144
149
|
closeModal() {
|
|
145
|
-
var e;
|
|
146
|
-
this.isOpen = !1, (
|
|
150
|
+
var e, t;
|
|
151
|
+
(e = this.disconnectSupport) == null || e.call(this), this.disconnectSupport = null, this.isOpen = !1, (t = document.getElementById("upstep-backdrop")) == null || t.remove();
|
|
147
152
|
}
|
|
148
153
|
async fetchFeed() {
|
|
149
154
|
try {
|
|
@@ -153,32 +158,36 @@ class F {
|
|
|
153
158
|
}
|
|
154
159
|
}
|
|
155
160
|
renderModal() {
|
|
156
|
-
var
|
|
161
|
+
var n, s, a;
|
|
162
|
+
(n = this.disconnectSupport) == null || n.call(this), this.disconnectSupport = null;
|
|
157
163
|
const e = document.createElement("div");
|
|
158
|
-
e.id = "upstep-backdrop", e.addEventListener("click", (
|
|
159
|
-
|
|
164
|
+
e.id = "upstep-backdrop", e.addEventListener("click", (r) => {
|
|
165
|
+
r.target === e && this.closeModal();
|
|
160
166
|
}), e.innerHTML = `
|
|
161
167
|
<div id="upstep-modal">
|
|
162
168
|
<div id="upstep-header">
|
|
163
169
|
<div>
|
|
164
|
-
<h2
|
|
165
|
-
<p
|
|
170
|
+
<h2>${this.tab === "support" ? "Customer support" : "Share your feedback"}</h2>
|
|
171
|
+
<p>${this.tab === "support" ? "Ask AI, or talk with the team." : "Tell us what to build next, or vote on ideas."}</p>
|
|
166
172
|
</div>
|
|
167
173
|
<button id="upstep-close" aria-label="Close">✕</button>
|
|
168
174
|
</div>
|
|
169
175
|
<div id="upstep-tabs">
|
|
176
|
+
${this.hasSupport ? `<button class="upstep-tab ${this.tab === "support" ? "active" : ""}" data-tab="support">Support</button>` : ""}
|
|
170
177
|
<button class="upstep-tab ${this.tab === "submit" ? "active" : ""}" data-tab="submit">Give feedback</button>
|
|
171
178
|
<button class="upstep-tab ${this.tab === "feed" ? "active" : ""}" data-tab="feed">Vote on ideas</button>
|
|
172
179
|
</div>
|
|
173
180
|
<div id="upstep-body">
|
|
174
|
-
${this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
|
|
181
|
+
${this.tab === "support" ? `<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg === "#000000" ? "dark" : "light")}" style="width:100%;height:480px;border:0;display:block;border-radius:12px"></iframe>` : this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
|
|
175
182
|
</div>
|
|
176
183
|
</div>
|
|
177
|
-
`, (
|
|
178
|
-
|
|
179
|
-
this.tab =
|
|
184
|
+
`, (s = document.getElementById("upstep-backdrop")) == null || s.remove(), document.body.appendChild(e), (a = e.querySelector("#upstep-close")) == null || a.addEventListener("click", () => this.closeModal()), e.querySelectorAll(".upstep-tab").forEach((r) => {
|
|
185
|
+
r.addEventListener("click", () => {
|
|
186
|
+
this.tab = r.dataset.tab, this.renderModal();
|
|
180
187
|
});
|
|
181
|
-
})
|
|
188
|
+
});
|
|
189
|
+
const t = e.querySelector("#upstep-support-frame");
|
|
190
|
+
t && (this.disconnectSupport = this.client.connectSupportFrame(t)), this.bindSubmitForm(), this.bindVoteButtons();
|
|
182
191
|
}
|
|
183
192
|
renderSubmitForm() {
|
|
184
193
|
const e = ["BUG", "FEATURE", "GENERAL"], t = { BUG: "Bug", FEATURE: "Feature", GENERAL: "General" }, n = {
|
|
@@ -232,11 +241,11 @@ class F {
|
|
|
232
241
|
}), (e = document.getElementById("upstep-submit-btn")) == null || e.addEventListener("click", async () => {
|
|
233
242
|
const t = document.getElementById("upstep-textarea"), n = document.getElementById("upstep-form-msg"), s = document.getElementById("upstep-submit-btn");
|
|
234
243
|
if (!t || this.loading) return;
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
244
|
+
const a = t.value.trim();
|
|
245
|
+
if (a) {
|
|
237
246
|
this.loading = !0, s && (s.disabled = !0, s.textContent = "Sending…");
|
|
238
247
|
try {
|
|
239
|
-
await this.client.submitFeedback({ content:
|
|
248
|
+
await this.client.submitFeedback({ content: a, type: this.selectedType }), t.value = "", n && (n.textContent = "Feedback received. Thank you."), await this.fetchFeed();
|
|
240
249
|
} catch {
|
|
241
250
|
n && (n.textContent = "Something went wrong. Please try again.");
|
|
242
251
|
} finally {
|
|
@@ -260,14 +269,14 @@ class F {
|
|
|
260
269
|
function v(o) {
|
|
261
270
|
return o.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
262
271
|
}
|
|
263
|
-
let p = null,
|
|
264
|
-
const
|
|
272
|
+
let p = null, c = null;
|
|
273
|
+
const F = {
|
|
265
274
|
init(o) {
|
|
266
275
|
if (p = new M(o), typeof window < "u") {
|
|
267
276
|
const e = {};
|
|
268
277
|
o.accentColor !== void 0 && (e.accentColor = o.accentColor), o.position !== void 0 && (e.position = o.position), o.theme !== void 0 && (e.theme = o.theme), o.launcher !== void 0 && (e.launcher = o.launcher);
|
|
269
278
|
const t = () => {
|
|
270
|
-
|
|
279
|
+
c = new C(p, e), c.mount();
|
|
271
280
|
};
|
|
272
281
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : t();
|
|
273
282
|
}
|
|
@@ -275,29 +284,36 @@ const C = {
|
|
|
275
284
|
},
|
|
276
285
|
/** Open the feedback widget — use this to trigger it from your own UI. */
|
|
277
286
|
open() {
|
|
278
|
-
|
|
287
|
+
c == null || c.openWidget();
|
|
279
288
|
},
|
|
280
289
|
/** Close the feedback widget. */
|
|
281
290
|
close() {
|
|
282
|
-
|
|
291
|
+
c == null || c.closeWidget();
|
|
283
292
|
},
|
|
284
293
|
/** Set / update the end-user id at runtime (e.g. after the user logs in). */
|
|
285
294
|
identify(o) {
|
|
286
295
|
p == null || p.setUserId(o);
|
|
287
296
|
},
|
|
297
|
+
/** Change or clear verified support identity after login/logout. */
|
|
298
|
+
identifySupport(o) {
|
|
299
|
+
var t;
|
|
300
|
+
p && (p.supportIdentityToken = o);
|
|
301
|
+
const e = document.querySelector("#upstep-support-frame");
|
|
302
|
+
e && p && ((t = e.contentWindow) == null || t.postMessage({ type: "upstep:support:identity", token: o }, new URL(p.baseUrl).origin));
|
|
303
|
+
},
|
|
288
304
|
get client() {
|
|
289
305
|
if (!p) throw new Error("Upstep.init() must be called first");
|
|
290
306
|
return p;
|
|
291
307
|
}
|
|
292
308
|
};
|
|
293
309
|
if (typeof document < "u") {
|
|
294
|
-
const o = document.currentScript, e = o == null ? void 0 : o.dataset.apiKey, t = o == null ? void 0 : o.dataset.userId, n = o == null ? void 0 : o.dataset.baseUrl, s = o == null ? void 0 : o.dataset.accentColor,
|
|
310
|
+
const o = document.currentScript, e = o == null ? void 0 : o.dataset.apiKey, t = o == null ? void 0 : o.dataset.userId, n = o == null ? void 0 : o.dataset.baseUrl, s = o == null ? void 0 : o.dataset.accentColor, a = o == null ? void 0 : o.dataset.position, r = o == null ? void 0 : o.dataset.theme;
|
|
295
311
|
if (e) {
|
|
296
|
-
const
|
|
297
|
-
t && (
|
|
312
|
+
const l = { apiKey: e };
|
|
313
|
+
t && (l.userId = t), (o == null ? void 0 : o.dataset.chat) !== void 0 && (l.chat = o.dataset.chat !== "false"), n && (l.baseUrl = n), s && (l.accentColor = s), (a === "left" || a === "right") && (l.position = a), (r === "light" || r === "dark" || r === "auto") && (l.theme = r), F.init(l);
|
|
298
314
|
}
|
|
299
315
|
}
|
|
300
316
|
export {
|
|
301
317
|
M as UpstepApiClient,
|
|
302
|
-
|
|
318
|
+
F as default
|
|
303
319
|
};
|
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),L=require("./api-DLrEC5_l.js"),D="#D97757",M={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},P={bg:"#1c1b19",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function C(){if(typeof document>"u")return!1;const i=document.documentElement;return i.classList.contains("dark")||i.getAttribute("data-theme")==="dark"}function A(i){const[n,t]=r.useState(()=>i==="dark");return r.useEffect(()=>{if(i!=="auto"){t(i==="dark");return}if(t(C()),typeof MutationObserver>"u")return;const u=new MutationObserver(()=>t(C()));return u.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"]}),()=>u.disconnect()},[i]),n?P:M}const z=r.createContext(null);function H({children:i,...n}){const[t]=r.useState(()=>new L.UpstepApiClient(n)),[u,g]=r.useState([]),[s,o]=r.useState(!1),[f,p]=r.useState(!0);r.useEffect(()=>{t.setUserId(n.userId)},[t,n.userId]);const l=r.useCallback(async()=>{try{const x=await t.listFeedback({sort:"votes",limit:20});g(x.items),p(x.showBranding??!0)}catch{}},[t]);r.useEffect(()=>{l()},[l]);const y=r.useCallback(async(x,j,h)=>{const d={content:j};x.trim()&&(d.title=x.trim()),h!==void 0&&(d.type=h),await t.submitFeedback(d),await l()},[t,l]),c=r.useCallback(async(x,j)=>{try{await t.vote(x,j),await l()}catch{}},[t,l]),a=r.useCallback(x=>t.getItem(x),[t]),b=r.useCallback(()=>o(!0),[]),k=r.useCallback(()=>o(!1),[]),S=r.useCallback(x=>t.setUserId(x),[t]);return e.jsx(z.Provider,{value:{client:t,feedItems:u,loadFeed:l,submit:y,vote:c,getItem:a,isOpen:s,open:b,close:k,identify:S,accentColor:n.accentColor??D,theme:n.theme??"auto",showBranding:f},children:i})}function v(){const i=r.useContext(z);if(!i)throw new Error("useUpstep must be used inside <UpstepProvider>");return i}function G({position:i="bottom-right",accentColor:n,theme:t,hideLauncher:u=!1}){const g=v(),s=n??g.accentColor,o=A(t??g.theme),{isOpen:f,open:p,close:l,showBranding:y}=g,[c,a]=r.useState("list"),[b,k]=r.useState(null),[S,x]=r.useState(!1);r.useEffect(()=>{const m=window.matchMedia("(max-width: 639px)");x(m.matches);const w=R=>x(R.matches);return m.addEventListener("change",w),()=>m.removeEventListener("change",w)},[]);const j=i==="bottom-left"?{position:"fixed",bottom:24,left:24}:{position:"fixed",bottom:24,right:24},h='-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';function d(){l(),setTimeout(()=>{a("list"),k(null)},300)}function U(m){k(m),a("detail")}return e.jsxs(e.Fragment,{children:[!u&&e.jsxs("button",{onClick:p,style:{...j,zIndex:9998,display:"inline-flex",alignItems:"center",gap:7,background:s,color:"#fff",border:"none",borderRadius:9999,padding:S?"12px":"12px 18px",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:h,boxShadow:"0 6px 20px rgba(26,25,21,.18)"},children:[e.jsx(K,{size:16}),!S&&"Feedback"]}),f&&e.jsx("div",{onClick:m=>m.target===m.currentTarget&&d(),style:{position:"fixed",inset:0,background:o.overlay,backdropFilter:"blur(3px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:16,fontFamily:h},children:e.jsxs("div",{style:{background:o.bg,border:`1px solid ${o.border}`,borderRadius:20,width:"100%",maxWidth:440,maxHeight:"88vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 64px rgba(0,0,0,.28)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${o.border}`,flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c!=="list"&&e.jsx("button",{onClick:()=>a("list"),style:{background:"none",border:"none",cursor:"pointer",color:s,fontSize:13,fontWeight:600,padding:0},children:"← Back"}),c==="list"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:o.text,letterSpacing:"-.01em"},children:"Feedback"}),c==="create"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:o.text,letterSpacing:"-.01em"},children:"New feedback"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c==="list"&&e.jsx("button",{onClick:()=>a("create"),style:{background:s,color:"#fff",border:"none",borderRadius:20,padding:"6px 14px",fontSize:13,fontWeight:700,cursor:"pointer"},children:"+ New"}),e.jsx("button",{onClick:d,style:{background:o.bgSoft,border:"none",width:28,height:28,borderRadius:8,fontSize:14,cursor:"pointer",color:o.textSoft,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px 24px"},children:[c==="list"&&e.jsx(N,{onSelect:U,accent:s,p:o}),c==="detail"&&b&&e.jsx(O,{feedbackId:b,accent:s,p:o,font:h}),c==="create"&&e.jsx(V,{accent:s,p:o,font:h,onDone:()=>a("list")})]}),y&&e.jsxs("a",{href:"https://upstep.dev",target:"_blank",rel:"noopener noreferrer",style:{display:"block",textAlign:"center",padding:"8px 0",borderTop:`1px solid ${o.border}`,fontSize:11,color:o.textFaint,textDecoration:"none",flexShrink:0},children:["Powered by ",e.jsx("strong",{style:{fontWeight:700},children:"Upstep.dev"})]})]})})]})}function N({onSelect:i,accent:n,p:t}){const{feedItems:u,vote:g}=v(),s=u.filter(o=>o.status!=="CLOSED");return s.length?e.jsx(e.Fragment,{children:s.map(o=>{const f=o.userVote==="UP",p=o.title??o.content;return e.jsxs("div",{onClick:()=>i(o.id),style:{display:"flex",gap:12,padding:14,border:`1px solid ${t.border}`,borderRadius:14,marginBottom:10,background:t.bg,cursor:"pointer"},children:[e.jsxs("button",{onClick:l=>{l.stopPropagation(),g(o.id,"UP")},style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,minWidth:46,padding:"7px 0",borderRadius:11,cursor:"pointer",flexShrink:0,border:`1px solid ${f?n:t.border}`,background:f?`${n}1a`:t.bgSoft},children:[e.jsx(I,{color:n}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:t.text,lineHeight:1.1},children:o.upvotes})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:13.5,fontWeight:600,lineHeight:1.4,color:t.text,margin:"0 0 6px",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:p}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx(B,{type:o.type,p:t}),o.status==="PENDING"?e.jsx(W,{}):e.jsx(E,{status:o.status,boardStatus:o.boardStatus,p:t}),e.jsx("span",{style:{fontSize:11,color:t.textFaint},children:T(o.createdAt)})]})]}),e.jsx("span",{style:{color:t.textFaint,fontSize:18,alignSelf:"center",flexShrink:0},children:"›"})]},o.id)})}):e.jsxs("div",{style:{textAlign:"center",padding:"40px 0"},children:[e.jsx("div",{style:{color:t.textSoft,fontSize:15,fontWeight:600,marginBottom:4},children:"No open feedback yet"}),e.jsx("div",{style:{color:t.textFaint,fontSize:14},children:"Be the first to share one."})]})}function O({feedbackId:i,accent:n,p:t,font:u}){const{vote:g,getItem:s}=v(),[o,f]=r.useState(null),[p,l]=r.useState(!1);r.useEffect(()=>{let a=!1;return s(i).then(b=>{a||f(b)}).catch(()=>{}),()=>{a=!0}},[i,s]);async function y(){if(!(!o||p)){l(!0);try{await g(o.id,"UP");const a=await s(i);f(a)}catch{}finally{l(!1)}}}if(!o)return e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:t.textFaint,fontSize:14},children:"Loading…"});const c=o.title;return e.jsxs("div",{children:[c&&e.jsx("div",{style:{fontSize:20,fontWeight:700,color:t.text,letterSpacing:"-.02em",marginBottom:10,lineHeight:1.3},children:c}),e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:14,flexWrap:"wrap"},children:[e.jsx(B,{type:o.type,p:t}),o.status==="PENDING"?e.jsx(W,{}):e.jsx(E,{status:o.status,boardStatus:o.boardStatus,p:t})]}),e.jsx("p",{style:{fontSize:15,lineHeight:1.6,color:t.textSoft,marginBottom:20},children:o.content}),e.jsxs("button",{onClick:y,disabled:p,style:{display:"inline-flex",alignItems:"center",gap:8,border:`1px solid ${o.userVote==="UP"?n:t.border}`,background:o.userVote==="UP"?`${n}15`:t.bgSoft,borderRadius:12,padding:"10px 16px",cursor:"pointer",fontFamily:u},children:[e.jsx(I,{color:n,size:13}),e.jsx("span",{style:{fontSize:18,fontWeight:700,color:t.text},children:o.upvotes}),e.jsx("span",{style:{fontSize:13,color:t.textFaint},children:o.userVote==="UP"?"Upvoted":"Upvote"})]}),o.comments.length>0&&e.jsxs("div",{style:{marginTop:28,borderTop:`1px solid ${t.border}`,paddingTop:20},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:t.textFaint,marginBottom:12,textTransform:"uppercase"},children:"Developer response"}),o.comments.map(a=>e.jsx($,{comment:a,p:t,accent:n},a.id))]})]})}function $({comment:i,p:n,accent:t}){return e.jsxs("div",{style:{background:n.bgSoft,border:`1px solid ${n.border}`,borderRadius:12,padding:14,marginBottom:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("span",{style:{background:`${t}20`,color:t,fontSize:11,fontWeight:700,borderRadius:20,padding:"2px 8px"},children:"Developer"}),e.jsx("span",{style:{fontSize:11,color:n.textFaint},children:T(i.createdAt)})]}),e.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:n.textSoft,margin:0},children:i.content})]})}function V({accent:i,p:n,font:t,onDone:u}){const{submit:g}=v(),[s,o]=r.useState(""),[f,p]=r.useState(""),[l,y]=r.useState("GENERAL"),[c,a]=r.useState(!1),[b,k]=r.useState(!1),[S,x]=r.useState("");async function j(){if(!(!s.trim()||c)){a(!0),x("");try{await g(s.trim(),f.trim()||s.trim(),l),k(!0),setTimeout(u,1200)}catch{x("Something went wrong. Please try again.")}finally{a(!1)}}}if(b)return e.jsxs("div",{style:{textAlign:"center",paddingTop:40},children:[e.jsx("div",{style:{fontSize:18,fontWeight:700,color:n.text,marginBottom:6},children:"Submitted"}),e.jsx("div",{style:{fontSize:14,color:n.textFaint},children:"Feedback received. Thank you."})]});const h={width:"100%",border:`1px solid ${n.border}`,borderRadius:12,padding:"10px 12px",fontSize:14,lineHeight:1.5,outline:"none",background:n.bgSoft,color:n.text,fontFamily:t,boxSizing:"border-box"};return e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Type"}),e.jsx("div",{style:{display:"flex",gap:7,marginBottom:16},children:["BUG","FEATURE","GENERAL"].map(d=>e.jsxs("button",{onClick:()=>y(d),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"8px 10px",borderRadius:9,fontSize:12.5,fontWeight:600,cursor:"pointer",background:l===d?i:n.bg,color:l===d?"#fff":n.textSoft,border:`1px solid ${l===d?i:n.border}`,fontFamily:t},children:[F[d].icon,F[d].label]},d))}),e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Title"}),e.jsx("input",{value:s,onChange:d=>o(d.target.value),placeholder:"Short summary of the issue or idea",maxLength:200,style:{...h,marginBottom:16,display:"block"}}),e.jsxs("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:["Description ",e.jsx("span",{style:{fontWeight:400,textTransform:"none",letterSpacing:0},children:"(optional)"})]}),e.jsx("textarea",{value:f,onChange:d=>p(d.target.value),placeholder:"Steps to reproduce, expected behaviour, or more context",maxLength:2e3,rows:4,style:{...h,resize:"vertical",marginBottom:16}}),S&&e.jsx("p",{style:{fontSize:13,color:"#d6453d",marginBottom:12},children:S}),e.jsx("button",{onClick:j,disabled:c||!s.trim(),style:{width:"100%",padding:12,background:i,color:"#fff",border:"none",borderRadius:11,fontSize:14,fontWeight:600,cursor:"pointer",opacity:c||!s.trim()?.5:1,fontFamily:t},children:c?"Submitting…":"Submit feedback"})]})}const F={BUG:{label:"Bug",icon:e.jsxs("svg",{width:12,height:12,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("ellipse",{cx:"8",cy:"10",rx:"3.5",ry:"4.5"}),e.jsx("path",{d:"M8 5.5V4M5.5 6.5 3.5 5M10.5 6.5 12.5 5M4.5 10.5 2.5 10M11.5 10.5 13.5 10"})]})},FEATURE:{label:"Feature",icon:e.jsxs("svg",{width:12,height:12,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.1 4.1l1 1M10.9 10.9l1 1M11.9 4.1l-1 1M5.1 10.9l-1 1"}),e.jsx("circle",{cx:"8",cy:"8",r:"2.5"})]})},GENERAL:{label:"General",icon:e.jsx("svg",{width:12,height:12,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"})})}},_={BUG:"#fdecec",FEATURE:"#e9f0fd"},q={BUG:"#d6453d",FEATURE:"#3b76d6"};function B({type:i,p:n}){return e.jsx("span",{style:{padding:"2px 8px",borderRadius:9999,fontSize:10.5,fontWeight:700,letterSpacing:".02em",background:_[i]??n.bgSoft,color:q[i]??n.textSoft},children:i})}const Y={OPEN:"#b45309",IN_PROGRESS:"#1d4ed8",DONE:"#15803d",CLOSED:"#6b7280"};function W(){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 E({status:i,boardStatus:n,p:t}){const u=(n==null?void 0:n.color)??Y[i]??"#9ca3af";return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,background:t.bgSoft,border:`1px solid ${t.border}`,borderRadius:6,padding:"2px 8px",fontSize:10,fontWeight:600,color:t.textSoft},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:u,display:"inline-block",flexShrink:0}}),(n==null?void 0:n.name)??i.replace("_"," ")]})}function K({size:i=16,color:n="currentColor"}){return e.jsx("svg",{width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function I({color:i="currentColor",size:n=11}){return e.jsx("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none",stroke:i,strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M8 13V3M3 8l5-5 5 5"})})}function T(i){return new Date(i).toLocaleDateString(void 0,{month:"short",day:"numeric"})}exports.FeedbackWidget=G;exports.UpstepProvider=H;exports.useUpstep=v;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),A=require("./api-BuSqdsZp.js"),D="#D97757",H={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},N={bg:"#000000",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function E(){if(typeof document>"u")return!1;const o=document.documentElement;return o.classList.contains("dark")||o.getAttribute("data-theme")==="dark"}function $(o){const[n,t]=i.useState(()=>o==="dark");return i.useEffect(()=>{if(o!=="auto"){t(o==="dark");return}if(t(E()),typeof MutationObserver>"u")return;const p=new MutationObserver(()=>t(E()));return p.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"]}),()=>p.disconnect()},[o]),n?N:H}const I=i.createContext(null);function G({children:o,...n}){const[t]=i.useState(()=>new A.UpstepApiClient(n)),[p,f]=i.useState([]),[s,r]=i.useState(!1),[l,m]=i.useState(!0);i.useEffect(()=>{t.setUserId(n.userId)},[t,n.userId]),i.useEffect(()=>{t.supportIdentityToken=n.supportIdentityToken,document.querySelectorAll("iframe[data-upstep-support]").forEach(c=>{var b;return(b=c.contentWindow)==null?void 0:b.postMessage({type:"upstep:support:identity",token:n.supportIdentityToken},new URL(t.baseUrl).origin)})},[t,n.supportIdentityToken]);const d=i.useCallback(async()=>{try{const c=await t.listFeedback({sort:"votes",limit:20});f(c.items),m(c.showBranding??!0)}catch{}},[t]);i.useEffect(()=>{d()},[d]);const S=i.useCallback(async(c,b,y)=>{const u={content:b};c.trim()&&(u.title=c.trim()),y!==void 0&&(u.type=y),await t.submitFeedback(u),await d()},[t,d]),h=i.useCallback(async(c,b)=>{try{await t.vote(c,b),await d()}catch{}},[t,d]),a=i.useCallback(c=>t.getItem(c),[t]),g=i.useCallback(()=>r(!0),[]),v=i.useCallback(()=>r(!1),[]),j=i.useCallback(c=>t.setUserId(c),[t]);return e.jsx(I.Provider,{value:{client:t,feedItems:p,loadFeed:d,submit:S,vote:h,getItem:a,isOpen:s,open:g,close:v,identify:j,accentColor:n.accentColor??D,theme:n.theme??"auto",showBranding:l,chat:n.chat!==!1},children:o})}function w(){const o=i.useContext(I);if(!o)throw new Error("useUpstep must be used inside <UpstepProvider>");return o}function O({position:o="bottom-right",accentColor:n,theme:t,hideLauncher:p=!1,chat:f=!0}){const s=w(),r=n??s.accentColor,l=$(t??s.theme),{isOpen:m,open:d,close:S,showBranding:h}=s,[a,g]=i.useState("list"),[v,j]=i.useState(!1);i.useEffect(()=>{let x=!0;if(s.client.chat=s.chat,!s.chat||!f){j(!1);return}return s.client.supportEnabled().then(k=>{x&&j(k)}),()=>{x=!1}},[s.client,s.chat,f]),i.useEffect(()=>{(!s.chat||!f)&&a==="support"&&g("list")},[s.chat,f,a]);const[c,b]=i.useState(null),[y,u]=i.useState(!1);i.useEffect(()=>{const x=window.matchMedia("(max-width: 639px)");u(x.matches);const k=P=>u(P.matches);return x.addEventListener("change",k),()=>x.removeEventListener("change",k)},[]);const L=o==="bottom-left"?{position:"fixed",bottom:24,left:24}:{position:"fixed",bottom:24,right:24},C='-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';function F(){S(),setTimeout(()=>{g("list"),b(null)},300)}function M(x){b(x),g("detail")}return e.jsxs(e.Fragment,{children:[!p&&e.jsxs("button",{onClick:d,style:{...L,zIndex:9998,display:"inline-flex",alignItems:"center",gap:7,background:r,color:"#fff",border:"none",borderRadius:9999,padding:y?"12px":"12px 18px",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:C,boxShadow:"0 6px 20px rgba(26,25,21,.18)"},children:[e.jsx(Z,{size:16}),!y&&"Feedback"]}),m&&e.jsx("div",{onClick:x=>x.target===x.currentTarget&&F(),style:{position:"fixed",inset:0,background:l.overlay,backdropFilter:"blur(3px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:16,fontFamily:C},children:e.jsxs("div",{style:{background:l.bg,border:`1px solid ${l.border}`,borderRadius:20,width:"100%",maxWidth:440,maxHeight:"88vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 64px rgba(0,0,0,.28)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${l.border}`,flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a!=="list"&&e.jsx("button",{onClick:()=>g("list"),style:{background:"none",border:"none",cursor:"pointer",color:r,fontSize:13,fontWeight:600,padding:0},children:"← Back"}),a==="list"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:l.text,letterSpacing:"-.01em"},children:"Feedback"}),a==="create"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:l.text,letterSpacing:"-.01em"},children:"New feedback"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a==="list"&&e.jsx("button",{onClick:()=>g("create"),style:{background:r,color:"#fff",border:"none",borderRadius:20,padding:"6px 14px",fontSize:13,fontWeight:700,cursor:"pointer"},children:"+ New"}),e.jsx("button",{onClick:F,style:{background:l.bgSoft,border:"none",width:28,height:28,borderRadius:8,fontSize:14,cursor:"pointer",color:l.textSoft,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]})]}),v&&f&&s.chat&&e.jsx("div",{style:{display:"flex",gap:4,padding:"12px 20px 0"},children:[["list","Feedback"],["support","Support"]].map(([x,k])=>e.jsx("button",{onClick:()=>g(x),style:{flex:1,padding:8,border:`1px solid ${l.border}`,borderRadius:9,background:a===x?l.bgSoft:l.bg,color:l.text,cursor:"pointer",fontSize:12},children:k},x))}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px 24px"},children:[a==="support"&&f&&s.chat&&e.jsx(V,{client:s.client,theme:l.bg==="#000000"?"dark":"light"}),a==="list"&&e.jsx(_,{onSelect:M,accent:r,p:l}),a==="detail"&&c&&e.jsx(q,{feedbackId:c,accent:r,p:l,font:C}),a==="create"&&e.jsx(K,{accent:r,p:l,font:C,onDone:()=>g("list")})]}),h&&e.jsxs("a",{href:"https://upstep.dev",target:"_blank",rel:"noopener noreferrer",style:{display:"block",textAlign:"center",padding:"8px 0",borderTop:`1px solid ${l.border}`,fontSize:11,color:l.textFaint,textDecoration:"none",flexShrink:0},children:["Powered by ",e.jsx("strong",{style:{fontWeight:700},children:"Upstep.dev"})]})]})})]})}function V({client:o,theme:n}){const t=i.useRef(null);return i.useEffect(()=>{if(t.current)return o.connectSupportFrame(t.current)},[o]),e.jsx("iframe",{ref:t,"data-upstep-support":!0,title:"Customer support",src:o.supportFrameUrl(n),style:{width:"100%",height:480,border:0,display:"block",borderRadius:12}})}function _({onSelect:o,accent:n,p:t}){const{feedItems:p,vote:f}=w(),s=p.filter(r=>r.status!=="CLOSED");return s.length?e.jsx(e.Fragment,{children:s.map(r=>{const l=r.userVote==="UP",m=r.title??r.content;return e.jsxs("div",{onClick:()=>o(r.id),style:{display:"flex",gap:12,padding:14,border:`1px solid ${t.border}`,borderRadius:14,marginBottom:10,background:t.bg,cursor:"pointer"},children:[e.jsxs("button",{onClick:d=>{d.stopPropagation(),f(r.id,"UP")},style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,minWidth:46,padding:"7px 0",borderRadius:11,cursor:"pointer",flexShrink:0,border:`1px solid ${l?n:t.border}`,background:l?`${n}1a`:t.bgSoft},children:[e.jsx(U,{color:n}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:t.text,lineHeight:1.1},children:r.upvotes})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:13.5,fontWeight:600,lineHeight:1.4,color:t.text,margin:"0 0 6px",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:m}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx(B,{type:r.type,p:t}),r.status==="PENDING"?e.jsx(W,{}):e.jsx(T,{status:r.status,boardStatus:r.boardStatus,p:t}),e.jsx("span",{style:{fontSize:11,color:t.textFaint},children:R(r.createdAt)})]})]}),e.jsx("span",{style:{color:t.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:t.textSoft,fontSize:15,fontWeight:600,marginBottom:4},children:"No open feedback yet"}),e.jsx("div",{style:{color:t.textFaint,fontSize:14},children:"Be the first to share one."})]})}function q({feedbackId:o,accent:n,p:t,font:p}){const{vote:f,getItem:s}=w(),[r,l]=i.useState(null),[m,d]=i.useState(!1);i.useEffect(()=>{let a=!1;return s(o).then(g=>{a||l(g)}).catch(()=>{}),()=>{a=!0}},[o,s]);async function S(){if(!(!r||m)){d(!0);try{await f(r.id,"UP");const a=await s(o);l(a)}catch{}finally{d(!1)}}}if(!r)return e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:t.textFaint,fontSize:14},children:"Loading…"});const h=r.title;return e.jsxs("div",{children:[h&&e.jsx("div",{style:{fontSize:20,fontWeight:700,color:t.text,letterSpacing:"-.02em",marginBottom:10,lineHeight:1.3},children:h}),e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:14,flexWrap:"wrap"},children:[e.jsx(B,{type:r.type,p:t}),r.status==="PENDING"?e.jsx(W,{}):e.jsx(T,{status:r.status,boardStatus:r.boardStatus,p:t})]}),e.jsx("p",{style:{fontSize:15,lineHeight:1.6,color:t.textSoft,marginBottom:20},children:r.content}),e.jsxs("button",{onClick:S,disabled:m,style:{display:"inline-flex",alignItems:"center",gap:8,border:`1px solid ${r.userVote==="UP"?n:t.border}`,background:r.userVote==="UP"?`${n}15`:t.bgSoft,borderRadius:12,padding:"10px 16px",cursor:"pointer",fontFamily:p},children:[e.jsx(U,{color:n,size:13}),e.jsx("span",{style:{fontSize:18,fontWeight:700,color:t.text},children:r.upvotes}),e.jsx("span",{style:{fontSize:13,color:t.textFaint},children:r.userVote==="UP"?"Upvoted":"Upvote"})]}),r.comments.length>0&&e.jsxs("div",{style:{marginTop:28,borderTop:`1px solid ${t.border}`,paddingTop:20},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:t.textFaint,marginBottom:12,textTransform:"uppercase"},children:"Comments"}),r.comments.map(a=>e.jsx(Y,{comment:a,p:t,accent:n},a.id))]})]})}function Y({comment:o,p:n,accent:t}){var p;return e.jsxs("div",{style:{background:n.bgSoft,border:`1px solid ${n.border}`,borderRadius:12,padding:14,marginBottom:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("span",{style:{background:`${t}20`,color:t,fontSize:11,fontWeight:700,borderRadius:20,padding:"2px 8px"},children:((p=o.authorName)==null?void 0:p.trim())||"UpStep Team"}),e.jsx("span",{style:{fontSize:11,color:n.textFaint},children:R(o.createdAt)})]}),e.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:n.textSoft,margin:0},children:o.content})]})}function K({accent:o,p:n,font:t,onDone:p}){const{submit:f}=w(),[s,r]=i.useState(""),[l,m]=i.useState(""),[d,S]=i.useState("GENERAL"),[h,a]=i.useState(!1),[g,v]=i.useState(!1),[j,c]=i.useState("");async function b(){if(!(!s.trim()||h)){a(!0),c("");try{await f(s.trim(),l.trim()||s.trim(),d),v(!0),setTimeout(p,1200)}catch{c("Something went wrong. Please try again.")}finally{a(!1)}}}if(g)return e.jsxs("div",{style:{textAlign:"center",paddingTop:40},children:[e.jsx("div",{style:{fontSize:18,fontWeight:700,color:n.text,marginBottom:6},children:"Submitted"}),e.jsx("div",{style:{fontSize:14,color:n.textFaint},children:"Feedback received. Thank you."})]});const y={width:"100%",border:`1px solid ${n.border}`,borderRadius:12,padding:"10px 12px",fontSize:14,lineHeight:1.5,outline:"none",background:n.bgSoft,color:n.text,fontFamily:t,boxSizing:"border-box"};return e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Type"}),e.jsx("div",{style:{display:"flex",gap:7,marginBottom:16},children:["BUG","FEATURE","GENERAL"].map(u=>e.jsxs("button",{onClick:()=>S(u),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"8px 10px",borderRadius:9,fontSize:12.5,fontWeight:600,cursor:"pointer",background:d===u?o:n.bg,color:d===u?"#fff":n.textSoft,border:`1px solid ${d===u?o:n.border}`,fontFamily:t},children:[z[u].icon,z[u].label]},u))}),e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Title"}),e.jsx("input",{value:s,onChange:u=>r(u.target.value),placeholder:"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:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:["Description ",e.jsx("span",{style:{fontWeight:400,textTransform:"none",letterSpacing:0},children:"(optional)"})]}),e.jsx("textarea",{value:l,onChange:u=>m(u.target.value),placeholder:"Steps to reproduce, expected behaviour, or more context",maxLength:2e3,rows:4,style:{...y,resize:"vertical",marginBottom:16}}),j&&e.jsx("p",{style:{fontSize:13,color:"#d6453d",marginBottom:12},children:j}),e.jsx("button",{onClick:b,disabled:h||!s.trim(),style:{width:"100%",padding:12,background:o,color:"#fff",border:"none",borderRadius:11,fontSize:14,fontWeight:600,cursor:"pointer",opacity:h||!s.trim()?.5:1,fontFamily:t},children:h?"Submitting…":"Submit feedback"})]})}const z={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"})})}},J={BUG:"#fdecec",FEATURE:"#e9f0fd"},Q={BUG:"#d6453d",FEATURE:"#3b76d6"};function B({type:o,p:n}){return e.jsx("span",{style:{padding:"2px 8px",borderRadius:9999,fontSize:10.5,fontWeight:700,letterSpacing:".02em",background:J[o]??n.bgSoft,color:Q[o]??n.textSoft},children:o})}const X={OPEN:"#b45309",IN_PROGRESS:"#1d4ed8",DONE:"#15803d",CLOSED:"#6b7280"};function W(){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 T({status:o,boardStatus:n,p:t}){const p=(n==null?void 0:n.color)??X[o]??"#9ca3af";return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,background:t.bgSoft,border:`1px solid ${t.border}`,borderRadius:6,padding:"2px 8px",fontSize:10,fontWeight:600,color:t.textSoft},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:p,display:"inline-block",flexShrink:0}}),(n==null?void 0:n.name)??o.replace("_"," ")]})}function Z({size:o=16,color:n="currentColor"}){return e.jsx("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function U({color:o="currentColor",size:n=11}){return e.jsx("svg",{width:n,height:n,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 R(o){return new Date(o).toLocaleDateString(void 0,{month:"short",day:"numeric"})}exports.FeedbackWidget=O;exports.UpstepProvider=G;exports.useUpstep=w;
|