@upstep/js 0.7.0 → 0.7.2
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 +6 -4
- package/dist/{api-C1UV7Szw.mjs → api-DSXEYv9R.mjs} +38 -16
- package/dist/api-ZqVkOuh0.js +1 -0
- package/dist/api.d.ts +1 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.js +8 -8
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +98 -95
- package/dist/upstep.global.js +4 -4
- package/dist/widget.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/api-BuSqdsZp.js +0 -1
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ Every entry point (`Upstep.init`, `<UpstepProvider>`, and the script tag's `data
|
|
|
70
70
|
| `apiKey` | `string` | — | **Required.** Your project's API key. |
|
|
71
71
|
| `userId` | `string` | — | End-user id from your app, used to deduplicate votes per user. Call `identify(userId)` if it's only known after login. |
|
|
72
72
|
| `baseUrl` | `string` | `https://upstep.dev` | Only needed for self-hosted or staging setups. |
|
|
73
|
-
| `accentColor` | `string` | `#
|
|
73
|
+
| `accentColor` | `string` | `#D97757` | Any CSS color, used for the launcher button and highlights. |
|
|
74
74
|
| `theme` | `"light" \| "dark" \| "auto"` | `"auto"` | `"auto"` follows the host page's `prefers-color-scheme`. |
|
|
75
75
|
| `position` | `"left" \| "right"` | `"right"` | Deprecated. Website launchers and panels stay bottom-right. |
|
|
76
76
|
| `launcher` | `boolean` | `true` | Set `false` to hide the floating button and trigger the widget yourself via `Upstep.open()`. |
|
|
@@ -100,7 +100,7 @@ Every entry point (`Upstep.init`, `<UpstepProvider>`, and the script tag's `data
|
|
|
100
100
|
|
|
101
101
|
### AI and live chat in the existing widget
|
|
102
102
|
|
|
103
|
-
Version 0.7.
|
|
103
|
+
Version 0.7.2 includes a **Support** tab to the same widget that handles feedback and
|
|
104
104
|
voting. Enable customer support for your paid project in the UpStep dashboard,
|
|
105
105
|
learn the business website, and confirm the business details and contact email.
|
|
106
106
|
The project must be enabled on the server; `chat: true` never bypasses plan access.
|
|
@@ -121,7 +121,7 @@ import { UpstepProvider, FeedbackWidget } from '@upstep/js/react';
|
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
```html
|
|
124
|
-
<script defer src="https://unpkg.com/@upstep/js@0.7.
|
|
124
|
+
<script defer src="https://unpkg.com/@upstep/js@0.7.2/dist/upstep.global.js"
|
|
125
125
|
data-api-key="YOUR_PROJECT_KEY" data-chat="true"></script>
|
|
126
126
|
```
|
|
127
127
|
|
|
@@ -137,6 +137,8 @@ secret in browser code. [Integration guide](https://upstep.dev/guides/customer-s
|
|
|
137
137
|
|
|
138
138
|
The website launcher and its opened chat/feedback panel stay in the bottom-right corner. Position options and old drag positions no longer move website widgets. Text uses a readable size with softer surfaces, white light mode and black dark mode.
|
|
139
139
|
|
|
140
|
-
Support can show quick replies, issue details, resolution confirmations, and a contact card. The team action appears only after AI
|
|
140
|
+
Support can show quick replies, issue details, resolution confirmations, and a contact card. The team action appears only after AI discusses the issue and tries to help, or establishes that a human must perform the action. Asking for an agent alone never opens a contact form. Active cards stay near the composer, contact details use two short steps, and optional issue fields expand only when needed. The server requires a name and valid email before queueing a private ticket. AI replies stay short, with separate paragraphs and no em dashes.
|
|
141
141
|
|
|
142
142
|
A DOM-free client is available from `@upstep/js/support` for custom native integrations. The React Native SDK uses this same client inside its existing feedback sheet.
|
|
143
|
+
|
|
144
|
+
Business branding comes from Customer support → Settings in UpStep. Website learning detects a business icon for review; you can replace it with an upload or public image URL. The approved icon is shared by the web and native chat widgets. Setup questions offer suggested choices when appropriate, with a custom answer field.
|
|
@@ -26,19 +26,28 @@ class u {
|
|
|
26
26
|
async supportEnabled() {
|
|
27
27
|
if (!this.chat) return !1;
|
|
28
28
|
try {
|
|
29
|
-
const e = await fetch(`${this.baseUrl}/api/sdk/support`, {
|
|
29
|
+
const e = await fetch(`${this.baseUrl}/api/sdk/support`, {
|
|
30
|
+
headers: this.headers()
|
|
31
|
+
});
|
|
30
32
|
return e.ok && (await e.json()).enabled === !0;
|
|
31
33
|
} catch {
|
|
32
34
|
return !1;
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
|
-
supportFrameUrl(e) {
|
|
36
|
-
return `${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(e)}`;
|
|
37
|
+
supportFrameUrl(e, t = "#D97757") {
|
|
38
|
+
return `${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(e)}&accent=${encodeURIComponent(t)}`;
|
|
37
39
|
}
|
|
38
40
|
connectSupportFrame(e) {
|
|
39
41
|
const t = new URL(this.baseUrl).origin, s = () => {
|
|
40
42
|
var n;
|
|
41
|
-
return (n = e.contentWindow) == null ? void 0 : n.postMessage(
|
|
43
|
+
return (n = e.contentWindow) == null ? void 0 : n.postMessage(
|
|
44
|
+
{
|
|
45
|
+
type: "upstep:support:identity",
|
|
46
|
+
token: this.supportIdentityToken,
|
|
47
|
+
accentColor: getComputedStyle(e).color
|
|
48
|
+
},
|
|
49
|
+
t
|
|
50
|
+
);
|
|
42
51
|
}, r = (n) => {
|
|
43
52
|
var i;
|
|
44
53
|
n.origin === t && n.source === e.contentWindow && ((i = n.data) == null ? void 0 : i.type) === "upstep:support:ready" && s();
|
|
@@ -70,19 +79,29 @@ class u {
|
|
|
70
79
|
return t.json();
|
|
71
80
|
}
|
|
72
81
|
async vote(e, t) {
|
|
73
|
-
const s = await fetch(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
const s = await fetch(
|
|
83
|
+
`${this.baseUrl}/api/sdk/feedback/${e}/vote`,
|
|
84
|
+
{
|
|
85
|
+
method: "POST",
|
|
86
|
+
headers: this.headers(),
|
|
87
|
+
body: JSON.stringify({
|
|
88
|
+
value: t,
|
|
89
|
+
endUserId: this.userId,
|
|
90
|
+
anonymousId: this.anonymousId
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
);
|
|
78
94
|
if (!s.ok) throw new Error(`Upstep: ${s.status}`);
|
|
79
95
|
}
|
|
80
96
|
async getItem(e) {
|
|
81
97
|
const t = new URLSearchParams();
|
|
82
98
|
this.userId && t.set("endUserId", this.userId), this.anonymousId && t.set("anonymousId", this.anonymousId);
|
|
83
|
-
const s = await fetch(
|
|
84
|
-
|
|
85
|
-
|
|
99
|
+
const s = await fetch(
|
|
100
|
+
`${this.baseUrl}/api/sdk/feedback/${e}?${t}`,
|
|
101
|
+
{
|
|
102
|
+
headers: this.headers()
|
|
103
|
+
}
|
|
104
|
+
);
|
|
86
105
|
if (!s.ok) throw new Error(`Upstep: ${s.status}`);
|
|
87
106
|
return s.json();
|
|
88
107
|
}
|
|
@@ -90,10 +109,13 @@ class u {
|
|
|
90
109
|
if (!this.userId && !this.anonymousId) return;
|
|
91
110
|
const t = new URLSearchParams();
|
|
92
111
|
this.userId && t.set("endUserId", this.userId), this.anonymousId && t.set("anonymousId", this.anonymousId);
|
|
93
|
-
const s = await fetch(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
112
|
+
const s = await fetch(
|
|
113
|
+
`${this.baseUrl}/api/sdk/feedback/${e}/vote?${t}`,
|
|
114
|
+
{
|
|
115
|
+
method: "DELETE",
|
|
116
|
+
headers: this.headers()
|
|
117
|
+
}
|
|
118
|
+
);
|
|
97
119
|
if (!s.ok) throw new Error(`Upstep: ${s.status}`);
|
|
98
120
|
}
|
|
99
121
|
}
|
|
@@ -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,t="#D97757"){return`${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(e)}&accent=${encodeURIComponent(t)}`}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,accentColor:getComputedStyle(e).color},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;
|
package/dist/api.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare class UpstepApiClient {
|
|
|
11
11
|
setUserId(userId: string | undefined): void;
|
|
12
12
|
private headers;
|
|
13
13
|
supportEnabled(): Promise<boolean>;
|
|
14
|
-
supportFrameUrl(theme: string): string;
|
|
14
|
+
supportFrameUrl(theme: string, accentColor?: string): string;
|
|
15
15
|
connectSupportFrame(frame: HTMLIFrameElement): () => void;
|
|
16
16
|
listFeedback(params?: {
|
|
17
17
|
cursor?: string;
|
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,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;
|
|
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;IAYxC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,SAAY,GAAG,MAAM;IAI/D,mBAAmB,CAAC,KAAK,EAAE,iBAAiB;IA2BtC,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;IAgBpE,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAc1D,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAcpD"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("./api-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("./api-ZqVkOuh0.js"),x="#D97757",l={bg:"#ffffff",bgSoft:"#f5f5f5",bgHover:"#ededed",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},c={bg:"#000000",bgSoft:"#171717",bgHover:"#262626",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function u(o){if(o==="light"||o==="dark")return o;if(typeof document<"u"){const t=document.documentElement;return t.classList.contains("dark")||t.getAttribute("data-theme")==="dark"?"dark":"light"}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function m(o,t,e){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;right:24px;left:auto;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:pointer;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}
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
.upstep-feedback-date{font-size:11px;color:${e.textFaint}}
|
|
49
49
|
.upstep-empty{text-align:center;color:${e.textFaint};font-size:14px;padding:40px 0}
|
|
50
50
|
.upstep-empty strong{display:block;color:${e.textSoft};font-size:15px;margin-bottom:4px}
|
|
51
|
-
`}const g='<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 y{constructor(t,e={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.hasSupport=!1,this.disconnectSupport=null,this.client=t,this.accent=e.accentColor??x,this.position="right",this.showLauncher=e.launcher!==!1,this.themeMode=e.theme??"auto",this.palette=
|
|
51
|
+
`}const g='<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 y{constructor(t,e={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.hasSupport=!1,this.disconnectSupport=null,this.client=t,this.accent=e.accentColor??x,this.position="right",this.showLauncher=e.launcher!==!1,this.themeMode=e.theme??"auto",this.palette=u(this.themeMode)==="dark"?c:l}mount(){this.injectStyles(),this.showLauncher&&this.renderButton(),this.client.supportEnabled().then(t=>{if(this.hasSupport=t,t){const e=document.querySelector("#upstep-btn span");e&&(e.textContent="Help & feedback"),this.isOpen&&this.renderModal()}})}openWidget(){this.openModal()}closeWidget(){this.closeModal()}injectStyles(){var e;(e=document.getElementById("upstep-styles"))==null||e.remove();const t=document.createElement("style");t.id="upstep-styles",t.textContent=m(this.accent,this.position,this.palette),document.head.appendChild(t)}renderButton(){const t=document.createElement("button");t.id="upstep-btn",t.setAttribute("aria-label","Open help and feedback"),t.innerHTML=`${g}<span>Feedback</span>`,t.addEventListener("click",()=>{this.openModal()}),document.body.appendChild(t)}openModal(){!this.isOpen&&this.hasSupport&&(this.tab="support"),this.isOpen=!0,this.palette=u(this.themeMode)==="dark"?c:l,this.injectStyles(),this.fetchFeed(),this.renderModal()}closeModal(){var t,e;(t=this.disconnectSupport)==null||t.call(this),this.disconnectSupport=null,this.isOpen=!1,(e=document.getElementById("upstep-backdrop"))==null||e.remove()}async fetchFeed(){try{const t=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=t.items,this.renderFeedList()}catch{}}renderModal(){var i,s,n;(i=this.disconnectSupport)==null||i.call(this),this.disconnectSupport=null;const t=document.createElement("div");t.id="upstep-backdrop",t.addEventListener("click",d=>{d.target===t&&this.closeModal()}),t.innerHTML=`
|
|
52
52
|
<div id="upstep-modal" style="max-width:${this.hasSupport?"460px":"440px"}">
|
|
53
53
|
${this.hasSupport?`<div class="upstep-mode" style="display:flex;align-items:center;gap:14px;padding:10px 14px;border-bottom:1px solid ${this.palette.border}"><div id="upstep-tabs" style="margin:0;padding:0;background:transparent;flex:1"><button class="upstep-tab ${this.tab==="support"?"active":""}" data-tab="support">Support</button><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Ideas</button></div><button id="upstep-close" aria-label="Close" style="flex-shrink:0;background:transparent">✕</button></div>`:`<div id="upstep-header"><div><h2>Share your feedback</h2><p>Tell us what to build next, or vote on ideas.</p></div><button id="upstep-close" aria-label="Close">✕</button></div><div id="upstep-tabs"><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Give feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Vote on ideas</button></div>`}
|
|
54
54
|
<div id="upstep-body" style="${this.tab==="support"?"padding:0;overflow:hidden":""}">
|
|
55
|
-
${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:min(560px,calc(100dvh - 168px));min-height:300px;border:0;display:block"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
55
|
+
${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg==="#000000"?"dark":"light",this.accent)}" style="width:100%;height:min(560px,calc(100dvh - 168px));min-height:300px;border:0;display:block"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
56
56
|
</div>
|
|
57
57
|
</div>
|
|
58
|
-
`,(s=document.getElementById("upstep-backdrop"))==null||s.remove(),document.body.appendChild(t),(n=t.querySelector("#upstep-close"))==null||n.addEventListener("click",()=>this.closeModal()),t.querySelectorAll(".upstep-tab").forEach(d=>{d.addEventListener("click",()=>{this.tab=d.dataset.tab,this.renderModal()})});const e=t.querySelector("#upstep-support-frame");e&&(this.disconnectSupport=this.client.connectSupportFrame(e)),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const t=["BUG","FEATURE","GENERAL"],e={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},i={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`
|
|
58
|
+
`,(s=document.getElementById("upstep-backdrop"))==null||s.remove(),document.body.appendChild(t),(n=t.querySelector("#upstep-close"))==null||n.addEventListener("click",()=>this.closeModal()),t.querySelectorAll(".upstep-tab").forEach(d=>{d.addEventListener("click",()=>{this.tab=d.dataset.tab,this.renderModal()})});const e=t.querySelector("#upstep-support-frame");e&&(e.style.color=this.accent,this.disconnectSupport=this.client.connectSupportFrame(e)),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const t=["BUG","FEATURE","GENERAL"],e={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},i={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`
|
|
59
59
|
<div class="upstep-form">
|
|
60
60
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
61
61
|
<div class="upstep-type-row">
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { U as h } from "./api-
|
|
2
|
-
const f = "#
|
|
1
|
+
import { U as h } from "./api-DSXEYv9R.mjs";
|
|
2
|
+
const f = "#D97757", l = {
|
|
3
3
|
bg: "#ffffff",
|
|
4
|
-
bgSoft: "#
|
|
5
|
-
bgHover: "#
|
|
4
|
+
bgSoft: "#f5f5f5",
|
|
5
|
+
bgHover: "#ededed",
|
|
6
6
|
text: "#1a1915",
|
|
7
7
|
textSoft: "#56544d",
|
|
8
8
|
textFaint: "#9b9890",
|
|
@@ -10,8 +10,8 @@ const f = "#5B7168", l = {
|
|
|
10
10
|
overlay: "rgba(26,25,21,.45)"
|
|
11
11
|
}, c = {
|
|
12
12
|
bg: "#000000",
|
|
13
|
-
bgSoft: "#
|
|
14
|
-
bgHover: "#
|
|
13
|
+
bgSoft: "#171717",
|
|
14
|
+
bgHover: "#262626",
|
|
15
15
|
text: "#f5f4f0",
|
|
16
16
|
textSoft: "#b4b1a8",
|
|
17
17
|
textFaint: "#7d7a72",
|
|
@@ -136,7 +136,7 @@ class g {
|
|
|
136
136
|
<div id="upstep-modal" style="max-width:${this.hasSupport ? "460px" : "440px"}">
|
|
137
137
|
${this.hasSupport ? `<div class="upstep-mode" style="display:flex;align-items:center;gap:14px;padding:10px 14px;border-bottom:1px solid ${this.palette.border}"><div id="upstep-tabs" style="margin:0;padding:0;background:transparent;flex:1"><button class="upstep-tab ${this.tab === "support" ? "active" : ""}" data-tab="support">Support</button><button class="upstep-tab ${this.tab === "submit" ? "active" : ""}" data-tab="submit">Feedback</button><button class="upstep-tab ${this.tab === "feed" ? "active" : ""}" data-tab="feed">Ideas</button></div><button id="upstep-close" aria-label="Close" style="flex-shrink:0;background:transparent">✕</button></div>` : `<div id="upstep-header"><div><h2>Share your feedback</h2><p>Tell us what to build next, or vote on ideas.</p></div><button id="upstep-close" aria-label="Close">✕</button></div><div id="upstep-tabs"><button class="upstep-tab ${this.tab === "submit" ? "active" : ""}" data-tab="submit">Give feedback</button><button class="upstep-tab ${this.tab === "feed" ? "active" : ""}" data-tab="feed">Vote on ideas</button></div>`}
|
|
138
138
|
<div id="upstep-body" style="${this.tab === "support" ? "padding:0;overflow:hidden" : ""}">
|
|
139
|
-
${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:min(560px,calc(100dvh - 168px));min-height:300px;border:0;display:block"></iframe>` : this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
|
|
139
|
+
${this.tab === "support" ? `<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg === "#000000" ? "dark" : "light", this.accent)}" style="width:100%;height:min(560px,calc(100dvh - 168px));min-height:300px;border:0;display:block"></iframe>` : this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
|
|
140
140
|
</div>
|
|
141
141
|
</div>
|
|
142
142
|
`, (s = document.getElementById("upstep-backdrop")) == null || s.remove(), document.body.appendChild(t), (n = t.querySelector("#upstep-close")) == null || n.addEventListener("click", () => this.closeModal()), t.querySelectorAll(".upstep-tab").forEach((d) => {
|
|
@@ -147,7 +147,7 @@ class g {
|
|
|
147
147
|
const e = t.querySelector(
|
|
148
148
|
"#upstep-support-frame"
|
|
149
149
|
);
|
|
150
|
-
e && (this.disconnectSupport = this.client.connectSupportFrame(e)), this.bindSubmitForm(), this.bindVoteButtons();
|
|
150
|
+
e && (e.style.color = this.accent, this.disconnectSupport = this.client.connectSupportFrame(e)), this.bindSubmitForm(), this.bindVoteButtons();
|
|
151
151
|
}
|
|
152
152
|
renderSubmitForm() {
|
|
153
153
|
const t = ["BUG", "FEATURE", "GENERAL"], e = {
|
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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="#5B7168",H={bg:"#ffffff",bgSoft:"#f4f6f4",bgHover:"#eaf0eb",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},N={bg:"#000000",bgSoft:"#191d1b",bgHover:"#252d28",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function z(){if(typeof document>"u")return!1;const o=document.documentElement;return o.classList.contains("dark")||o.getAttribute("data-theme")==="dark"}function O(o){const[n,t]=i.useState(()=>o==="dark");return i.useEffect(()=>{if(o!=="auto"){t(o==="dark");return}if(t(z()),typeof MutationObserver>"u")return;const f=new MutationObserver(()=>t(z()));return f.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"]}),()=>f.disconnect()},[o]),n?N:H}const B=i.createContext(null);function $({children:o,...n}){const[t]=i.useState(()=>new A.UpstepApiClient(n)),[f,d]=i.useState([]),[s,r]=i.useState(!1),[l,h]=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(p=>{var m;return(m=p.contentWindow)==null?void 0:m.postMessage({type:"upstep:support:identity",token:n.supportIdentityToken},new URL(t.baseUrl).origin)})},[t,n.supportIdentityToken]);const c=i.useCallback(async()=>{try{const p=await t.listFeedback({sort:"votes",limit:20});d(p.items),h(p.showBranding??!0)}catch{}},[t]);i.useEffect(()=>{c()},[c]);const j=i.useCallback(async(p,m,S)=>{const u={content:m};p.trim()&&(u.title=p.trim()),S!==void 0&&(u.type=S),await t.submitFeedback(u),await c()},[t,c]),b=i.useCallback(async(p,m)=>{try{await t.vote(p,m),await c()}catch{}},[t,c]),a=i.useCallback(p=>t.getItem(p),[t]),g=i.useCallback(()=>r(!0),[]),y=i.useCallback(()=>r(!1),[]),k=i.useCallback(p=>t.setUserId(p),[t]);return e.jsx(B.Provider,{value:{client:t,feedItems:f,loadFeed:c,submit:j,vote:b,getItem:a,isOpen:s,open:g,close:y,identify:k,accentColor:n.accentColor??D,theme:n.theme??"auto",showBranding:l,chat:n.chat!==!1},children:o})}function w(){const o=i.useContext(B);if(!o)throw new Error("useUpstep must be used inside <UpstepProvider>");return o}function G({position:o="bottom-right",accentColor:n,theme:t,hideLauncher:f=!1,chat:d=!0}){const s=w(),r=n??s.accentColor,l=O(t??s.theme),{isOpen:h,open:c,close:j,showBranding:b}=s,[a,g]=i.useState("list"),[y,k]=i.useState(!1);i.useEffect(()=>{let x=!0;if(s.client.chat=s.chat,!s.chat||!d){k(!1);return}return s.client.supportEnabled().then(v=>{x&&k(v)}),()=>{x=!1}},[s.client,s.chat,d]),i.useEffect(()=>{(!s.chat||!d)&&a==="support"&&g("list")},[s.chat,d,a]),i.useEffect(()=>{h&&g(y&&d&&s.chat?"support":"list")},[h,y,d,s.chat]);const[p,m]=i.useState(null),[S,u]=i.useState(!1);i.useEffect(()=>{const x=window.matchMedia("(max-width: 639px)");u(x.matches);const v=P=>u(P.matches);return x.addEventListener("change",v),()=>x.removeEventListener("change",v)},[]);const L={position:"fixed",bottom:24,right:24},C='-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';function F(){j(),m(null)}function M(x){m(x),g("detail")}return e.jsxs(e.Fragment,{children:[!f&&e.jsxs("button",{"aria-label":"Open help and feedback",onClick:c,style:{...L,zIndex:9998,display:"inline-flex",alignItems:"center",gap:7,background:r,color:"#fff",border:"none",borderRadius:9999,padding:S?"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}),!S&&(y&&d&&s.chat?"Help & feedback":"Feedback")]}),h&&e.jsx("div",{onClick:x=>x.target===x.currentTarget&&F(),style:{position:"fixed",inset:0,background:"transparent",zIndex:9999,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:S?"0 12px 80px":"0 24px 88px",fontFamily:C},children:e.jsxs("div",{style:{background:l.bg,border:`1px solid ${l.border}`,borderRadius:20,width:"100%",maxWidth:y&&d&&s.chat?460:440,maxHeight:"calc(100dvh - 112px)",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 64px rgba(0,0,0,.28)"},children:[y&&d&&s.chat?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"10px 14px",borderBottom:`1px solid ${l.border}`,flexShrink:0},children:[e.jsx("div",{style:{display:"flex",flex:1,gap:4},children:[["support","Support"],["list","Feedback"]].map(([x,v])=>e.jsx("button",{onClick:()=>g(x),style:{flex:1,border:0,borderRadius:8,padding:"9px 12px",background:(a==="support"?x==="support":x==="list")?l.bgSoft:"transparent",color:(a==="support"?x==="support":x==="list")?l.text:l.textSoft,fontSize:14,fontWeight:600,cursor:"pointer"},children:v},x))}),e.jsx("button",{"aria-label":"Close",onClick:F,style:{border:0,background:"transparent",color:l.textSoft,padding:6,cursor:"pointer",fontSize:14},children:"✕"})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${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:14,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:14,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:"✕"})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:a==="support"?0:"16px 20px 24px"},children:[a==="support"&&d&&s.chat&&e.jsx(V,{client:s.client,theme:l.bg==="#000000"?"dark":"light"}),y&&d&&s.chat&&a!=="support"&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:a==="list"?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:14,fontWeight:600,color:l.text},children:"Feedback & ideas"}),e.jsx("button",{onClick:()=>g("create"),style:{border:0,borderRadius:8,background:r,color:"white",fontSize:14,padding:"7px 10px",cursor:"pointer"},children:"+ New"})]}):e.jsx("button",{onClick:()=>g("list"),style:{border:0,background:"none",padding:0,color:l.textSoft,fontSize:14,cursor:"pointer"},children:"← Back to feedback"})}),a==="list"&&e.jsx(_,{onSelect:M,accent:r,p:l}),a==="detail"&&p&&e.jsx(q,{feedbackId:p,accent:r,p:l,font:C}),a==="create"&&e.jsx(K,{accent:r,p:l,font:C,onDone:()=>g("list")})]}),b&&a!=="support"&&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:"min(560px, calc(100dvh - 168px))",minHeight:300,border:0,display:"block"}})}function _({onSelect:o,accent:n,p:t}){const{feedItems:f,vote:d}=w(),s=f.filter(r=>r.status!=="CLOSED");return s.length?e.jsx(e.Fragment,{children:s.map(r=>{const l=r.userVote==="UP",h=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:c=>{c.stopPropagation(),d(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:14,fontWeight:600,lineHeight:1.4,color:t.text,margin:"0 0 6px",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:h}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx(I,{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:f}){const{vote:d,getItem:s}=w(),[r,l]=i.useState(null),[h,c]=i.useState(!1);i.useEffect(()=>{let a=!1;return s(o).then(g=>{a||l(g)}).catch(()=>{}),()=>{a=!0}},[o,s]);async function j(){if(!(!r||h)){c(!0);try{await d(r.id,"UP");const a=await s(o);l(a)}catch{}finally{c(!1)}}}if(!r)return e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:t.textFaint,fontSize:14},children:"Loading…"});const b=r.title;return e.jsxs("div",{children:[b&&e.jsx("div",{style:{fontSize:20,fontWeight:700,color:t.text,letterSpacing:"-.02em",marginBottom:10,lineHeight:1.3},children:b}),e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:14,flexWrap:"wrap"},children:[e.jsx(I,{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:j,disabled:h,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:f},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:14,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 f;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:((f=o.authorName)==null?void 0:f.trim())||"UpStep Team"}),e.jsx("span",{style:{fontSize:11,color:n.textFaint},children:R(o.createdAt)})]}),e.jsx("p",{style:{fontSize:16,lineHeight:1.6,color:n.textSoft,margin:0},children:o.content})]})}function K({accent:o,p:n,font:t,onDone:f}){const{submit:d}=w(),[s,r]=i.useState(""),[l,h]=i.useState(""),[c,j]=i.useState("GENERAL"),[b,a]=i.useState(!1),[g,y]=i.useState(!1),[k,p]=i.useState("");async function m(){if(!(!s.trim()||b)){a(!0),p("");try{await d(s.trim(),l.trim()||s.trim(),c),y(!0),setTimeout(f,1200)}catch{p("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 S={width:"100%",border:`1px solid ${n.border}`,borderRadius:12,padding:"10px 12px",fontSize:16,lineHeight:1.6,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:()=>j(u),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"8px 10px",borderRadius:9,fontSize:14,fontWeight:600,cursor:"pointer",background:c===u?o:n.bg,color:c===u?"#fff":n.textSoft,border:`1px solid ${c===u?o:n.border}`,fontFamily:t},children:[E[u].icon,E[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:{...S,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=>h(u.target.value),placeholder:"Steps to reproduce, expected behaviour, or more context",maxLength:2e3,rows:4,style:{...S,resize:"vertical",marginBottom:16}}),k&&e.jsx("p",{style:{fontSize:14,color:"#d6453d",marginBottom:12},children:k}),e.jsx("button",{onClick:m,disabled:b||!s.trim(),style:{width:"100%",padding:12,background:o,color:"#fff",border:"none",borderRadius:11,fontSize:14,fontWeight:600,cursor:"pointer",opacity:b||!s.trim()?.5:1,fontFamily:t},children:b?"Submitting…":"Submit feedback"})]})}const E={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 I({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 f=(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:f,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=G;exports.UpstepProvider=$;exports.useUpstep=w;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),A=require("./api-ZqVkOuh0.js"),D="#D97757",H={bg:"#ffffff",bgSoft:"#f5f5f5",bgHover:"#ededed",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},N={bg:"#000000",bgSoft:"#171717",bgHover:"#262626",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function z(){if(typeof document>"u")return!1;const o=document.documentElement;return o.classList.contains("dark")||o.getAttribute("data-theme")==="dark"}function O(o){const[n,t]=i.useState(()=>o==="dark");return i.useEffect(()=>{if(o!=="auto"){t(o==="dark");return}if(t(z()),typeof MutationObserver>"u")return;const d=new MutationObserver(()=>t(z()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"]}),()=>d.disconnect()},[o]),n?N:H}const B=i.createContext(null);function $({children:o,...n}){const[t]=i.useState(()=>new A.UpstepApiClient(n)),[d,c]=i.useState([]),[s,r]=i.useState(!1),[l,h]=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(u=>{var m;return(m=u.contentWindow)==null?void 0:m.postMessage({type:"upstep:support:identity",token:n.supportIdentityToken},new URL(t.baseUrl).origin)})},[t,n.supportIdentityToken]);const p=i.useCallback(async()=>{try{const u=await t.listFeedback({sort:"votes",limit:20});c(u.items),h(u.showBranding??!0)}catch{}},[t]);i.useEffect(()=>{p()},[p]);const j=i.useCallback(async(u,m,S)=>{const x={content:m};u.trim()&&(x.title=u.trim()),S!==void 0&&(x.type=S),await t.submitFeedback(x),await p()},[t,p]),b=i.useCallback(async(u,m)=>{try{await t.vote(u,m),await p()}catch{}},[t,p]),a=i.useCallback(u=>t.getItem(u),[t]),g=i.useCallback(()=>r(!0),[]),y=i.useCallback(()=>r(!1),[]),k=i.useCallback(u=>t.setUserId(u),[t]);return e.jsx(B.Provider,{value:{client:t,feedItems:d,loadFeed:p,submit:j,vote:b,getItem:a,isOpen:s,open:g,close:y,identify:k,accentColor:n.accentColor??D,theme:n.theme??"auto",showBranding:l,chat:n.chat!==!1},children:o})}function w(){const o=i.useContext(B);if(!o)throw new Error("useUpstep must be used inside <UpstepProvider>");return o}function G({position:o="bottom-right",accentColor:n,theme:t,hideLauncher:d=!1,chat:c=!0}){const s=w(),r=n??s.accentColor,l=O(t??s.theme),{isOpen:h,open:p,close:j,showBranding:b}=s,[a,g]=i.useState("list"),[y,k]=i.useState(!1);i.useEffect(()=>{let f=!0;if(s.client.chat=s.chat,!s.chat||!c){k(!1);return}return s.client.supportEnabled().then(v=>{f&&k(v)}),()=>{f=!1}},[s.client,s.chat,c]),i.useEffect(()=>{(!s.chat||!c)&&a==="support"&&g("list")},[s.chat,c,a]),i.useEffect(()=>{h&&g(y&&c&&s.chat?"support":"list")},[h,y,c,s.chat]);const[u,m]=i.useState(null),[S,x]=i.useState(!1);i.useEffect(()=>{const f=window.matchMedia("(max-width: 639px)");x(f.matches);const v=P=>x(P.matches);return f.addEventListener("change",v),()=>f.removeEventListener("change",v)},[]);const L={position:"fixed",bottom:24,right:24},C='-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';function F(){j(),m(null)}function M(f){m(f),g("detail")}return e.jsxs(e.Fragment,{children:[!d&&e.jsxs("button",{"aria-label":"Open help and feedback",onClick:p,style:{...L,zIndex:9998,display:"inline-flex",alignItems:"center",gap:7,background:r,color:"#fff",border:"none",borderRadius:9999,padding:S?"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}),!S&&(y&&c&&s.chat?"Help & feedback":"Feedback")]}),h&&e.jsx("div",{onClick:f=>f.target===f.currentTarget&&F(),style:{position:"fixed",inset:0,background:"transparent",zIndex:9999,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:S?"0 12px 80px":"0 24px 88px",fontFamily:C},children:e.jsxs("div",{style:{background:l.bg,border:`1px solid ${l.border}`,borderRadius:20,width:"100%",maxWidth:y&&c&&s.chat?460:440,maxHeight:"calc(100dvh - 112px)",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 64px rgba(0,0,0,.28)"},children:[y&&c&&s.chat?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"10px 14px",borderBottom:`1px solid ${l.border}`,flexShrink:0},children:[e.jsx("div",{style:{display:"flex",flex:1,gap:4},children:[["support","Support"],["list","Feedback"]].map(([f,v])=>e.jsx("button",{onClick:()=>g(f),style:{flex:1,border:0,borderRadius:8,padding:"9px 12px",background:(a==="support"?f==="support":f==="list")?l.bgSoft:"transparent",color:(a==="support"?f==="support":f==="list")?l.text:l.textSoft,fontSize:14,fontWeight:600,cursor:"pointer"},children:v},f))}),e.jsx("button",{"aria-label":"Close",onClick:F,style:{border:0,background:"transparent",color:l.textSoft,padding:6,cursor:"pointer",fontSize:14},children:"✕"})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${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:14,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:14,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:"✕"})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:a==="support"?0:"16px 20px 24px"},children:[a==="support"&&c&&s.chat&&e.jsx(V,{client:s.client,accentColor:r,theme:l.bg==="#000000"?"dark":"light"}),y&&c&&s.chat&&a!=="support"&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:a==="list"?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:14,fontWeight:600,color:l.text},children:"Feedback & ideas"}),e.jsx("button",{onClick:()=>g("create"),style:{border:0,borderRadius:8,background:r,color:"white",fontSize:14,padding:"7px 10px",cursor:"pointer"},children:"+ New"})]}):e.jsx("button",{onClick:()=>g("list"),style:{border:0,background:"none",padding:0,color:l.textSoft,fontSize:14,cursor:"pointer"},children:"← Back to feedback"})}),a==="list"&&e.jsx(_,{onSelect:M,accent:r,p:l}),a==="detail"&&u&&e.jsx(q,{feedbackId:u,accent:r,p:l,font:C}),a==="create"&&e.jsx(K,{accent:r,p:l,font:C,onDone:()=>g("list")})]}),b&&a!=="support"&&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,accentColor:t}){const d=i.useRef(null);return i.useEffect(()=>{if(d.current)return o.connectSupportFrame(d.current)},[o]),e.jsx("iframe",{ref:d,"data-upstep-support":!0,title:"Customer support",src:o.supportFrameUrl(n,t),style:{color:t,width:"100%",height:"min(560px, calc(100dvh - 168px))",minHeight:300,border:0,display:"block"}})}function _({onSelect:o,accent:n,p:t}){const{feedItems:d,vote:c}=w(),s=d.filter(r=>r.status!=="CLOSED");return s.length?e.jsx(e.Fragment,{children:s.map(r=>{const l=r.userVote==="UP",h=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:p=>{p.stopPropagation(),c(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:14,fontWeight:600,lineHeight:1.4,color:t.text,margin:"0 0 6px",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:h}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx(I,{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:d}){const{vote:c,getItem:s}=w(),[r,l]=i.useState(null),[h,p]=i.useState(!1);i.useEffect(()=>{let a=!1;return s(o).then(g=>{a||l(g)}).catch(()=>{}),()=>{a=!0}},[o,s]);async function j(){if(!(!r||h)){p(!0);try{await c(r.id,"UP");const a=await s(o);l(a)}catch{}finally{p(!1)}}}if(!r)return e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:t.textFaint,fontSize:14},children:"Loading…"});const b=r.title;return e.jsxs("div",{children:[b&&e.jsx("div",{style:{fontSize:20,fontWeight:700,color:t.text,letterSpacing:"-.02em",marginBottom:10,lineHeight:1.3},children:b}),e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:14,flexWrap:"wrap"},children:[e.jsx(I,{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:j,disabled:h,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:d},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:14,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 d;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:((d=o.authorName)==null?void 0:d.trim())||"UpStep Team"}),e.jsx("span",{style:{fontSize:11,color:n.textFaint},children:R(o.createdAt)})]}),e.jsx("p",{style:{fontSize:16,lineHeight:1.6,color:n.textSoft,margin:0},children:o.content})]})}function K({accent:o,p:n,font:t,onDone:d}){const{submit:c}=w(),[s,r]=i.useState(""),[l,h]=i.useState(""),[p,j]=i.useState("GENERAL"),[b,a]=i.useState(!1),[g,y]=i.useState(!1),[k,u]=i.useState("");async function m(){if(!(!s.trim()||b)){a(!0),u("");try{await c(s.trim(),l.trim()||s.trim(),p),y(!0),setTimeout(d,1200)}catch{u("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 S={width:"100%",border:`1px solid ${n.border}`,borderRadius:12,padding:"10px 12px",fontSize:16,lineHeight:1.6,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(x=>e.jsxs("button",{onClick:()=>j(x),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"8px 10px",borderRadius:9,fontSize:14,fontWeight:600,cursor:"pointer",background:p===x?o:n.bg,color:p===x?"#fff":n.textSoft,border:`1px solid ${p===x?o:n.border}`,fontFamily:t},children:[E[x].icon,E[x].label]},x))}),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:x=>r(x.target.value),placeholder:"Short summary of the issue or idea",maxLength:200,style:{...S,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:x=>h(x.target.value),placeholder:"Steps to reproduce, expected behaviour, or more context",maxLength:2e3,rows:4,style:{...S,resize:"vertical",marginBottom:16}}),k&&e.jsx("p",{style:{fontSize:14,color:"#d6453d",marginBottom:12},children:k}),e.jsx("button",{onClick:m,disabled:b||!s.trim(),style:{width:"100%",padding:12,background:o,color:"#fff",border:"none",borderRadius:11,fontSize:14,fontWeight:600,cursor:"pointer",opacity:b||!s.trim()?.5:1,fontFamily:t},children:b?"Submitting…":"Submit feedback"})]})}const E={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 I({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 d=(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:d,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=G;exports.UpstepProvider=$;exports.useUpstep=w;
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAEV,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAMxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAmF3C,UAAU,kBAAkB;IAC1B,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,EAAE,CACN,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,YAAY,KAChB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC/D,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;CACf;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,qBAgGxC;AAED,wBAAgB,SAAS,IAAI,kBAAkB,CAI9C;AAID,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mFAAmF;IACnF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAyB,EACzB,WAAW,EACX,KAAK,EACL,YAAoB,EACpB,IAAW,GACZ,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAEV,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAMxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAmF3C,UAAU,kBAAkB;IAC1B,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,EAAE,CACN,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,YAAY,KAChB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC/D,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;CACf;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,qBAgGxC;AAED,wBAAgB,SAAS,IAAI,kBAAkB,CAI9C;AAID,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mFAAmF;IACnF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAyB,EACzB,WAAW,EACX,KAAK,EACL,YAAoB,EACpB,IAAW,GACZ,EAAE,mBAAmB,qBAsYrB"}
|
package/dist/react.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsxs as d, Fragment as T, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { createContext as G, useState as h, useEffect as k, useCallback as F, useContext as O, useRef as j } from "react";
|
|
3
|
-
import { U as V } from "./api-
|
|
4
|
-
const _ = "#
|
|
3
|
+
import { U as V } from "./api-DSXEYv9R.mjs";
|
|
4
|
+
const _ = "#D97757", Y = {
|
|
5
5
|
bg: "#ffffff",
|
|
6
|
-
bgSoft: "#
|
|
7
|
-
bgHover: "#
|
|
6
|
+
bgSoft: "#f5f5f5",
|
|
7
|
+
bgHover: "#ededed",
|
|
8
8
|
text: "#1a1915",
|
|
9
9
|
textSoft: "#56544d",
|
|
10
10
|
textFaint: "#9b9890",
|
|
@@ -12,8 +12,8 @@ const _ = "#5B7168", Y = {
|
|
|
12
12
|
overlay: "rgba(26,25,21,.45)"
|
|
13
13
|
}, q = {
|
|
14
14
|
bg: "#000000",
|
|
15
|
-
bgSoft: "#
|
|
16
|
-
bgHover: "#
|
|
15
|
+
bgSoft: "#171717",
|
|
16
|
+
bgHover: "#262626",
|
|
17
17
|
text: "#f5f4f0",
|
|
18
18
|
textSoft: "#b4b1a8",
|
|
19
19
|
textFaint: "#7d7a72",
|
|
@@ -33,11 +33,11 @@ function K(o) {
|
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
if (t(E()), typeof MutationObserver > "u") return;
|
|
36
|
-
const
|
|
37
|
-
return
|
|
36
|
+
const a = new MutationObserver(() => t(E()));
|
|
37
|
+
return a.observe(document.documentElement, {
|
|
38
38
|
attributes: !0,
|
|
39
39
|
attributeFilter: ["class", "data-theme"]
|
|
40
|
-
}), () =>
|
|
40
|
+
}), () => a.disconnect();
|
|
41
41
|
}, [o]), n ? q : Y;
|
|
42
42
|
}
|
|
43
43
|
const R = G(null);
|
|
@@ -45,14 +45,14 @@ function de({
|
|
|
45
45
|
children: o,
|
|
46
46
|
...n
|
|
47
47
|
}) {
|
|
48
|
-
const [t] = h(() => new V(n)), [
|
|
48
|
+
const [t] = h(() => new V(n)), [a, c] = h([]), [i, r] = h(!1), [l, x] = h(!0);
|
|
49
49
|
k(() => {
|
|
50
50
|
t.setUserId(n.userId);
|
|
51
51
|
}, [t, n.userId]), k(() => {
|
|
52
52
|
t.supportIdentityToken = n.supportIdentityToken, document.querySelectorAll("iframe[data-upstep-support]").forEach(
|
|
53
|
-
(
|
|
53
|
+
(u) => {
|
|
54
54
|
var y;
|
|
55
|
-
return (y =
|
|
55
|
+
return (y = u.contentWindow) == null ? void 0 : y.postMessage(
|
|
56
56
|
{
|
|
57
57
|
type: "upstep:support:identity",
|
|
58
58
|
token: n.supportIdentityToken
|
|
@@ -62,35 +62,35 @@ function de({
|
|
|
62
62
|
}
|
|
63
63
|
);
|
|
64
64
|
}, [t, n.supportIdentityToken]);
|
|
65
|
-
const
|
|
65
|
+
const p = F(async () => {
|
|
66
66
|
try {
|
|
67
|
-
const
|
|
68
|
-
|
|
67
|
+
const u = await t.listFeedback({ sort: "votes", limit: 20 });
|
|
68
|
+
c(u.items), x(u.showBranding ?? !0);
|
|
69
69
|
} catch {
|
|
70
70
|
}
|
|
71
71
|
}, [t]);
|
|
72
72
|
k(() => {
|
|
73
|
-
|
|
74
|
-
}, [
|
|
73
|
+
p();
|
|
74
|
+
}, [p]);
|
|
75
75
|
const w = F(
|
|
76
|
-
async (
|
|
77
|
-
const
|
|
78
|
-
|
|
76
|
+
async (u, y, v) => {
|
|
77
|
+
const f = { content: y };
|
|
78
|
+
u.trim() && (f.title = u.trim()), v !== void 0 && (f.type = v), await t.submitFeedback(f), await p();
|
|
79
79
|
},
|
|
80
|
-
[t,
|
|
80
|
+
[t, p]
|
|
81
81
|
), m = F(
|
|
82
|
-
async (
|
|
82
|
+
async (u, y) => {
|
|
83
83
|
try {
|
|
84
|
-
await t.vote(
|
|
84
|
+
await t.vote(u, y), await p();
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
|
-
[t,
|
|
88
|
+
[t, p]
|
|
89
89
|
), s = F(
|
|
90
|
-
(
|
|
90
|
+
(u) => t.getItem(u),
|
|
91
91
|
[t]
|
|
92
92
|
), b = F(() => r(!0), []), S = F(() => r(!1), []), C = F(
|
|
93
|
-
(
|
|
93
|
+
(u) => t.setUserId(u),
|
|
94
94
|
[t]
|
|
95
95
|
);
|
|
96
96
|
return /* @__PURE__ */ e(
|
|
@@ -98,8 +98,8 @@ function de({
|
|
|
98
98
|
{
|
|
99
99
|
value: {
|
|
100
100
|
client: t,
|
|
101
|
-
feedItems:
|
|
102
|
-
loadFeed:
|
|
101
|
+
feedItems: a,
|
|
102
|
+
loadFeed: p,
|
|
103
103
|
submit: w,
|
|
104
104
|
vote: m,
|
|
105
105
|
getItem: s,
|
|
@@ -125,37 +125,37 @@ function ae({
|
|
|
125
125
|
position: o = "bottom-right",
|
|
126
126
|
accentColor: n,
|
|
127
127
|
theme: t,
|
|
128
|
-
hideLauncher:
|
|
129
|
-
chat:
|
|
128
|
+
hideLauncher: a = !1,
|
|
129
|
+
chat: c = !0
|
|
130
130
|
}) {
|
|
131
131
|
const i = I(), r = n ?? i.accentColor, l = K(t ?? i.theme), {
|
|
132
132
|
isOpen: x,
|
|
133
|
-
open:
|
|
133
|
+
open: p,
|
|
134
134
|
close: w,
|
|
135
135
|
showBranding: m
|
|
136
136
|
} = i, [s, b] = h("list"), [S, C] = h(!1);
|
|
137
137
|
k(() => {
|
|
138
|
-
let
|
|
139
|
-
if (i.client.chat = i.chat, !i.chat || !
|
|
138
|
+
let g = !0;
|
|
139
|
+
if (i.client.chat = i.chat, !i.chat || !c) {
|
|
140
140
|
C(!1);
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
143
|
return i.client.supportEnabled().then((z) => {
|
|
144
|
-
|
|
144
|
+
g && C(z);
|
|
145
145
|
}), () => {
|
|
146
|
-
|
|
146
|
+
g = !1;
|
|
147
147
|
};
|
|
148
|
-
}, [i.client, i.chat,
|
|
149
|
-
(!i.chat || !
|
|
150
|
-
}, [i.chat,
|
|
151
|
-
x && b(S &&
|
|
152
|
-
}, [x, S,
|
|
153
|
-
const [
|
|
148
|
+
}, [i.client, i.chat, c]), k(() => {
|
|
149
|
+
(!i.chat || !c) && s === "support" && b("list");
|
|
150
|
+
}, [i.chat, c, s]), k(() => {
|
|
151
|
+
x && b(S && c && i.chat ? "support" : "list");
|
|
152
|
+
}, [x, S, c, i.chat]);
|
|
153
|
+
const [u, y] = h(null), [v, f] = h(!1);
|
|
154
154
|
k(() => {
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
const z = ($) =>
|
|
158
|
-
return
|
|
155
|
+
const g = window.matchMedia("(max-width: 639px)");
|
|
156
|
+
f(g.matches);
|
|
157
|
+
const z = ($) => f($.matches);
|
|
158
|
+
return g.addEventListener("change", z), () => g.removeEventListener("change", z);
|
|
159
159
|
}, []);
|
|
160
160
|
const H = {
|
|
161
161
|
position: "fixed",
|
|
@@ -165,15 +165,15 @@ function ae({
|
|
|
165
165
|
function W() {
|
|
166
166
|
w(), y(null);
|
|
167
167
|
}
|
|
168
|
-
function N(
|
|
169
|
-
y(
|
|
168
|
+
function N(g) {
|
|
169
|
+
y(g), b("detail");
|
|
170
170
|
}
|
|
171
171
|
return /* @__PURE__ */ d(T, { children: [
|
|
172
|
-
!
|
|
172
|
+
!a && /* @__PURE__ */ d(
|
|
173
173
|
"button",
|
|
174
174
|
{
|
|
175
175
|
"aria-label": "Open help and feedback",
|
|
176
|
-
onClick:
|
|
176
|
+
onClick: p,
|
|
177
177
|
style: {
|
|
178
178
|
...H,
|
|
179
179
|
zIndex: 9998,
|
|
@@ -193,14 +193,14 @@ function ae({
|
|
|
193
193
|
},
|
|
194
194
|
children: [
|
|
195
195
|
/* @__PURE__ */ e(re, { size: 16 }),
|
|
196
|
-
!v && (S &&
|
|
196
|
+
!v && (S && c && i.chat ? "Help & feedback" : "Feedback")
|
|
197
197
|
]
|
|
198
198
|
}
|
|
199
199
|
),
|
|
200
200
|
x && /* @__PURE__ */ e(
|
|
201
201
|
"div",
|
|
202
202
|
{
|
|
203
|
-
onClick: (
|
|
203
|
+
onClick: (g) => g.target === g.currentTarget && W(),
|
|
204
204
|
style: {
|
|
205
205
|
position: "fixed",
|
|
206
206
|
inset: 0,
|
|
@@ -220,7 +220,7 @@ function ae({
|
|
|
220
220
|
border: `1px solid ${l.border}`,
|
|
221
221
|
borderRadius: 20,
|
|
222
222
|
width: "100%",
|
|
223
|
-
maxWidth: S &&
|
|
223
|
+
maxWidth: S && c && i.chat ? 460 : 440,
|
|
224
224
|
maxHeight: "calc(100dvh - 112px)",
|
|
225
225
|
display: "flex",
|
|
226
226
|
flexDirection: "column",
|
|
@@ -228,7 +228,7 @@ function ae({
|
|
|
228
228
|
boxShadow: "0 24px 64px rgba(0,0,0,.28)"
|
|
229
229
|
},
|
|
230
230
|
children: [
|
|
231
|
-
S &&
|
|
231
|
+
S && c && i.chat ? /* @__PURE__ */ d(
|
|
232
232
|
"div",
|
|
233
233
|
{
|
|
234
234
|
style: {
|
|
@@ -243,24 +243,24 @@ function ae({
|
|
|
243
243
|
/* @__PURE__ */ e("div", { style: { display: "flex", flex: 1, gap: 4 }, children: [
|
|
244
244
|
["support", "Support"],
|
|
245
245
|
["list", "Feedback"]
|
|
246
|
-
].map(([
|
|
246
|
+
].map(([g, z]) => /* @__PURE__ */ e(
|
|
247
247
|
"button",
|
|
248
248
|
{
|
|
249
|
-
onClick: () => b(
|
|
249
|
+
onClick: () => b(g),
|
|
250
250
|
style: {
|
|
251
251
|
flex: 1,
|
|
252
252
|
border: 0,
|
|
253
253
|
borderRadius: 8,
|
|
254
254
|
padding: "9px 12px",
|
|
255
|
-
background: (s === "support" ?
|
|
256
|
-
color: (s === "support" ?
|
|
255
|
+
background: (s === "support" ? g === "support" : g === "list") ? l.bgSoft : "transparent",
|
|
256
|
+
color: (s === "support" ? g === "support" : g === "list") ? l.text : l.textSoft,
|
|
257
257
|
fontSize: 14,
|
|
258
258
|
fontWeight: 600,
|
|
259
259
|
cursor: "pointer"
|
|
260
260
|
},
|
|
261
261
|
children: z
|
|
262
262
|
},
|
|
263
|
-
|
|
263
|
+
g
|
|
264
264
|
)) }),
|
|
265
265
|
/* @__PURE__ */ e(
|
|
266
266
|
"button",
|
|
@@ -385,14 +385,15 @@ function ae({
|
|
|
385
385
|
padding: s === "support" ? 0 : "16px 20px 24px"
|
|
386
386
|
},
|
|
387
387
|
children: [
|
|
388
|
-
s === "support" &&
|
|
388
|
+
s === "support" && c && i.chat && /* @__PURE__ */ e(
|
|
389
389
|
J,
|
|
390
390
|
{
|
|
391
391
|
client: i.client,
|
|
392
|
+
accentColor: r,
|
|
392
393
|
theme: l.bg === "#000000" ? "dark" : "light"
|
|
393
394
|
}
|
|
394
395
|
),
|
|
395
|
-
S &&
|
|
396
|
+
S && c && i.chat && s !== "support" && /* @__PURE__ */ e(
|
|
396
397
|
"div",
|
|
397
398
|
{
|
|
398
399
|
style: {
|
|
@@ -443,10 +444,10 @@ function ae({
|
|
|
443
444
|
}
|
|
444
445
|
),
|
|
445
446
|
s === "list" && /* @__PURE__ */ e(Q, { onSelect: N, accent: r, p: l }),
|
|
446
|
-
s === "detail" &&
|
|
447
|
+
s === "detail" && u && /* @__PURE__ */ e(
|
|
447
448
|
X,
|
|
448
449
|
{
|
|
449
|
-
feedbackId:
|
|
450
|
+
feedbackId: u,
|
|
450
451
|
accent: r,
|
|
451
452
|
p: l,
|
|
452
453
|
font: B
|
|
@@ -496,19 +497,21 @@ function ae({
|
|
|
496
497
|
}
|
|
497
498
|
function J({
|
|
498
499
|
client: o,
|
|
499
|
-
theme: n
|
|
500
|
+
theme: n,
|
|
501
|
+
accentColor: t
|
|
500
502
|
}) {
|
|
501
|
-
const
|
|
503
|
+
const a = j(null);
|
|
502
504
|
return k(() => {
|
|
503
|
-
if (
|
|
505
|
+
if (a.current) return o.connectSupportFrame(a.current);
|
|
504
506
|
}, [o]), /* @__PURE__ */ e(
|
|
505
507
|
"iframe",
|
|
506
508
|
{
|
|
507
|
-
ref:
|
|
509
|
+
ref: a,
|
|
508
510
|
"data-upstep-support": !0,
|
|
509
511
|
title: "Customer support",
|
|
510
|
-
src: o.supportFrameUrl(n),
|
|
512
|
+
src: o.supportFrameUrl(n, t),
|
|
511
513
|
style: {
|
|
514
|
+
color: t,
|
|
512
515
|
width: "100%",
|
|
513
516
|
height: "min(560px, calc(100dvh - 168px))",
|
|
514
517
|
minHeight: 300,
|
|
@@ -523,7 +526,7 @@ function Q({
|
|
|
523
526
|
accent: n,
|
|
524
527
|
p: t
|
|
525
528
|
}) {
|
|
526
|
-
const { feedItems:
|
|
529
|
+
const { feedItems: a, vote: c } = I(), i = a.filter((r) => r.status !== "CLOSED");
|
|
527
530
|
return i.length ? /* @__PURE__ */ e(T, { children: i.map((r) => {
|
|
528
531
|
const l = r.userVote === "UP", x = r.title ?? r.content;
|
|
529
532
|
return /* @__PURE__ */ d(
|
|
@@ -544,8 +547,8 @@ function Q({
|
|
|
544
547
|
/* @__PURE__ */ d(
|
|
545
548
|
"button",
|
|
546
549
|
{
|
|
547
|
-
onClick: (
|
|
548
|
-
|
|
550
|
+
onClick: (p) => {
|
|
551
|
+
p.stopPropagation(), c(r.id, "UP");
|
|
549
552
|
},
|
|
550
553
|
style: {
|
|
551
554
|
display: "flex",
|
|
@@ -656,9 +659,9 @@ function X({
|
|
|
656
659
|
feedbackId: o,
|
|
657
660
|
accent: n,
|
|
658
661
|
p: t,
|
|
659
|
-
font:
|
|
662
|
+
font: a
|
|
660
663
|
}) {
|
|
661
|
-
const { vote:
|
|
664
|
+
const { vote: c, getItem: i } = I(), [r, l] = h(null), [x, p] = h(!1);
|
|
662
665
|
k(() => {
|
|
663
666
|
let s = !1;
|
|
664
667
|
return i(o).then((b) => {
|
|
@@ -670,14 +673,14 @@ function X({
|
|
|
670
673
|
}, [o, i]);
|
|
671
674
|
async function w() {
|
|
672
675
|
if (!(!r || x)) {
|
|
673
|
-
|
|
676
|
+
p(!0);
|
|
674
677
|
try {
|
|
675
|
-
await
|
|
678
|
+
await c(r.id, "UP");
|
|
676
679
|
const s = await i(o);
|
|
677
680
|
l(s);
|
|
678
681
|
} catch {
|
|
679
682
|
} finally {
|
|
680
|
-
|
|
683
|
+
p(!1);
|
|
681
684
|
}
|
|
682
685
|
}
|
|
683
686
|
}
|
|
@@ -753,7 +756,7 @@ function X({
|
|
|
753
756
|
borderRadius: 12,
|
|
754
757
|
padding: "10px 16px",
|
|
755
758
|
cursor: "pointer",
|
|
756
|
-
fontFamily:
|
|
759
|
+
fontFamily: a
|
|
757
760
|
},
|
|
758
761
|
children: [
|
|
759
762
|
/* @__PURE__ */ e(D, { color: n, size: 13 }),
|
|
@@ -796,7 +799,7 @@ function Z({
|
|
|
796
799
|
p: n,
|
|
797
800
|
accent: t
|
|
798
801
|
}) {
|
|
799
|
-
var
|
|
802
|
+
var a;
|
|
800
803
|
return /* @__PURE__ */ d(
|
|
801
804
|
"div",
|
|
802
805
|
{
|
|
@@ -829,7 +832,7 @@ function Z({
|
|
|
829
832
|
borderRadius: 20,
|
|
830
833
|
padding: "2px 8px"
|
|
831
834
|
},
|
|
832
|
-
children: ((
|
|
835
|
+
children: ((a = o.authorName) == null ? void 0 : a.trim()) || "UpStep Team"
|
|
833
836
|
}
|
|
834
837
|
),
|
|
835
838
|
/* @__PURE__ */ e("span", { style: { fontSize: 11, color: n.textFaint }, children: P(o.createdAt) })
|
|
@@ -851,16 +854,16 @@ function ee({
|
|
|
851
854
|
accent: o,
|
|
852
855
|
p: n,
|
|
853
856
|
font: t,
|
|
854
|
-
onDone:
|
|
857
|
+
onDone: a
|
|
855
858
|
}) {
|
|
856
|
-
const { submit:
|
|
859
|
+
const { submit: c } = I(), [i, r] = h(""), [l, x] = h(""), [p, w] = h("GENERAL"), [m, s] = h(!1), [b, S] = h(!1), [C, u] = h("");
|
|
857
860
|
async function y() {
|
|
858
861
|
if (!(!i.trim() || m)) {
|
|
859
|
-
s(!0),
|
|
862
|
+
s(!0), u("");
|
|
860
863
|
try {
|
|
861
|
-
await
|
|
864
|
+
await c(i.trim(), l.trim() || i.trim(), p), S(!0), setTimeout(a, 1200);
|
|
862
865
|
} catch {
|
|
863
|
-
|
|
866
|
+
u("Something went wrong. Please try again.");
|
|
864
867
|
} finally {
|
|
865
868
|
s(!1);
|
|
866
869
|
}
|
|
@@ -910,10 +913,10 @@ function ee({
|
|
|
910
913
|
children: "Type"
|
|
911
914
|
}
|
|
912
915
|
),
|
|
913
|
-
/* @__PURE__ */ e("div", { style: { display: "flex", gap: 7, marginBottom: 16 }, children: ["BUG", "FEATURE", "GENERAL"].map((
|
|
916
|
+
/* @__PURE__ */ e("div", { style: { display: "flex", gap: 7, marginBottom: 16 }, children: ["BUG", "FEATURE", "GENERAL"].map((f) => /* @__PURE__ */ d(
|
|
914
917
|
"button",
|
|
915
918
|
{
|
|
916
|
-
onClick: () => w(
|
|
919
|
+
onClick: () => w(f),
|
|
917
920
|
style: {
|
|
918
921
|
flex: 1,
|
|
919
922
|
display: "flex",
|
|
@@ -925,17 +928,17 @@ function ee({
|
|
|
925
928
|
fontSize: 14,
|
|
926
929
|
fontWeight: 600,
|
|
927
930
|
cursor: "pointer",
|
|
928
|
-
background:
|
|
929
|
-
color:
|
|
930
|
-
border: `1px solid ${
|
|
931
|
+
background: p === f ? o : n.bg,
|
|
932
|
+
color: p === f ? "#fff" : n.textSoft,
|
|
933
|
+
border: `1px solid ${p === f ? o : n.border}`,
|
|
931
934
|
fontFamily: t
|
|
932
935
|
},
|
|
933
936
|
children: [
|
|
934
|
-
U[
|
|
935
|
-
U[
|
|
937
|
+
U[f].icon,
|
|
938
|
+
U[f].label
|
|
936
939
|
]
|
|
937
940
|
},
|
|
938
|
-
|
|
941
|
+
f
|
|
939
942
|
)) }),
|
|
940
943
|
/* @__PURE__ */ e(
|
|
941
944
|
"div",
|
|
@@ -955,7 +958,7 @@ function ee({
|
|
|
955
958
|
"input",
|
|
956
959
|
{
|
|
957
960
|
value: i,
|
|
958
|
-
onChange: (
|
|
961
|
+
onChange: (f) => r(f.target.value),
|
|
959
962
|
placeholder: "Short summary of the issue or idea",
|
|
960
963
|
maxLength: 200,
|
|
961
964
|
style: { ...v, marginBottom: 16, display: "block" }
|
|
@@ -989,7 +992,7 @@ function ee({
|
|
|
989
992
|
"textarea",
|
|
990
993
|
{
|
|
991
994
|
value: l,
|
|
992
|
-
onChange: (
|
|
995
|
+
onChange: (f) => x(f.target.value),
|
|
993
996
|
placeholder: "Steps to reproduce, expected behaviour, or more context",
|
|
994
997
|
maxLength: 2e3,
|
|
995
998
|
rows: 4,
|
|
@@ -1141,7 +1144,7 @@ function A({
|
|
|
1141
1144
|
boardStatus: n,
|
|
1142
1145
|
p: t
|
|
1143
1146
|
}) {
|
|
1144
|
-
const
|
|
1147
|
+
const a = (n == null ? void 0 : n.color) ?? oe[o] ?? "#9ca3af";
|
|
1145
1148
|
return /* @__PURE__ */ d(
|
|
1146
1149
|
"span",
|
|
1147
1150
|
{
|
|
@@ -1165,7 +1168,7 @@ function A({
|
|
|
1165
1168
|
width: 6,
|
|
1166
1169
|
height: 6,
|
|
1167
1170
|
borderRadius: "50%",
|
|
1168
|
-
background:
|
|
1171
|
+
background: a,
|
|
1169
1172
|
display: "inline-block",
|
|
1170
1173
|
flexShrink: 0
|
|
1171
1174
|
}
|
package/dist/upstep.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){"use strict";const
|
|
1
|
+
(function(){"use strict";const l="upstep-anonymous-id";function m(){const s=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;if(typeof window>"u")return s;try{const e=window.localStorage.getItem(l);return e||(window.localStorage.setItem(l,s),s)}catch{return s}}class x{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=m()}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,t="#D97757"){return`${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(e)}&accent=${encodeURIComponent(t)}`}connectSupportFrame(e){const t=new URL(this.baseUrl).origin,o=()=>{var n;return(n=e.contentWindow)==null?void 0:n.postMessage({type:"upstep:support:identity",token:this.supportIdentityToken,accentColor:getComputedStyle(e).color},t)},i=n=>{var a;n.origin===t&&n.source===e.contentWindow&&((a=n.data)==null?void 0:a.type)==="upstep:support:ready"&&o()};return e.addEventListener("load",o),window.addEventListener("message",i),()=>{e.removeEventListener("load",o),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 o=await fetch(`${this.baseUrl}/api/sdk/feedback?${t}`,{headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`);return o.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 o=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(!o.ok)throw new Error(`Upstep: ${o.status}`)}async getItem(e){const t=new URLSearchParams;this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const o=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}?${t}`,{headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`);return o.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 o=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote?${t}`,{method:"DELETE",headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`)}}const g="#D97757",u={bg:"#ffffff",bgSoft:"#f5f5f5",bgHover:"#ededed",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},c={bg:"#000000",bgSoft:"#171717",bgHover:"#262626",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function h(s){if(s==="light"||s==="dark")return s;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 y(s,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;right:24px;left:auto;z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${s};color:#fff;border:none;border-radius:9999px;padding:12px 18px;font-size:14px;font-weight:600;cursor:pointer;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}
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
.upstep-feedback-date{font-size:11px;color:${t.textFaint}}
|
|
49
49
|
.upstep-empty{text-align:center;color:${t.textFaint};font-size:14px;padding:40px 0}
|
|
50
50
|
.upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
|
|
51
|
-
`}const k='<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 v{constructor(e,t={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.hasSupport=!1,this.disconnectSupport=null,this.client=e,this.accent=t.accentColor??g,this.position="right",this.showLauncher=t.launcher!==!1,this.themeMode=t.theme??"auto",this.palette=h(this.themeMode)==="dark"?c:
|
|
51
|
+
`}const k='<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 v{constructor(e,t={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.hasSupport=!1,this.disconnectSupport=null,this.client=e,this.accent=t.accentColor??g,this.position="right",this.showLauncher=t.launcher!==!1,this.themeMode=t.theme??"auto",this.palette=h(this.themeMode)==="dark"?c:u}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=y(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=`${k}<span>Feedback</span>`,e.addEventListener("click",()=>{this.openModal()}),document.body.appendChild(e)}openModal(){!this.isOpen&&this.hasSupport&&(this.tab="support"),this.isOpen=!0,this.palette=h(this.themeMode)==="dark"?c:u,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 o,i,n;(o=this.disconnectSupport)==null||o.call(this),this.disconnectSupport=null;const e=document.createElement("div");e.id="upstep-backdrop",e.addEventListener("click",a=>{a.target===e&&this.closeModal()}),e.innerHTML=`
|
|
52
52
|
<div id="upstep-modal" style="max-width:${this.hasSupport?"460px":"440px"}">
|
|
53
53
|
${this.hasSupport?`<div class="upstep-mode" style="display:flex;align-items:center;gap:14px;padding:10px 14px;border-bottom:1px solid ${this.palette.border}"><div id="upstep-tabs" style="margin:0;padding:0;background:transparent;flex:1"><button class="upstep-tab ${this.tab==="support"?"active":""}" data-tab="support">Support</button><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Ideas</button></div><button id="upstep-close" aria-label="Close" style="flex-shrink:0;background:transparent">✕</button></div>`:`<div id="upstep-header"><div><h2>Share your feedback</h2><p>Tell us what to build next, or vote on ideas.</p></div><button id="upstep-close" aria-label="Close">✕</button></div><div id="upstep-tabs"><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Give feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Vote on ideas</button></div>`}
|
|
54
54
|
<div id="upstep-body" style="${this.tab==="support"?"padding:0;overflow:hidden":""}">
|
|
55
|
-
${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:min(560px,calc(100dvh - 168px));min-height:300px;border:0;display:block"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
55
|
+
${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg==="#000000"?"dark":"light",this.accent)}" style="width:100%;height:min(560px,calc(100dvh - 168px));min-height:300px;border:0;display:block"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
56
56
|
</div>
|
|
57
57
|
</div>
|
|
58
|
-
`,(i=document.getElementById("upstep-backdrop"))==null||i.remove(),document.body.appendChild(e),(n=e.querySelector("#upstep-close"))==null||n.addEventListener("click",()=>this.closeModal()),e.querySelectorAll(".upstep-tab").forEach(a=>{a.addEventListener("click",()=>{this.tab=a.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"},o={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`
|
|
58
|
+
`,(i=document.getElementById("upstep-backdrop"))==null||i.remove(),document.body.appendChild(e),(n=e.querySelector("#upstep-close"))==null||n.addEventListener("click",()=>this.closeModal()),e.querySelectorAll(".upstep-tab").forEach(a=>{a.addEventListener("click",()=>{this.tab=a.dataset.tab,this.renderModal()})});const t=e.querySelector("#upstep-support-frame");t&&(t.style.color=this.accent,this.disconnectSupport=this.client.connectSupportFrame(t)),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const e=["BUG","FEATURE","GENERAL"],t={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},o={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`
|
|
59
59
|
<div class="upstep-form">
|
|
60
60
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
61
61
|
<div class="upstep-type-row">
|
package/dist/widget.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;AA4H3C,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,SAAS,CAAY;IAC7B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,iBAAiB,CAA6B;gBAE1C,MAAM,EAAE,eAAe,EAAE,OAAO,GAAE,aAAkB;IAShE,KAAK;IAaL,4EAA4E;IAC5E,UAAU;IAIV,iDAAiD;IACjD,WAAW;IAIX,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,UAAU;YAOJ,SAAS;IAUvB,OAAO,CAAC,WAAW;
|
|
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;AA4H3C,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,SAAS,CAAY;IAC7B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,iBAAiB,CAA6B;gBAE1C,MAAM,EAAE,eAAe,EAAE,OAAO,GAAE,aAAkB;IAShE,KAAK;IAaL,4EAA4E;IAC5E,UAAU;IAIV,iDAAiD;IACjD,WAAW;IAIX,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,UAAU;YAOJ,SAAS;IAUvB,OAAO,CAAC,WAAW;IA0CnB,OAAO,CAAC,gBAAgB;IA0BxB,OAAO,CAAC,UAAU;IAyBlB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;IAsDtB,OAAO,CAAC,eAAe;CAaxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upstep/js",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "UpStep feedback, voting and AI support widgets for web apps",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://upstep.dev",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dist"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@upstep/types": "0.7.
|
|
45
|
+
"@upstep/types": "0.7.2"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": ">=18",
|
package/dist/api-BuSqdsZp.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;
|