@upstep/js 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -5
- package/dist/index.cjs +44 -54
- package/dist/index.js +140 -169
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +886 -271
- package/dist/support.cjs +1 -0
- package/dist/support.d.ts +47 -0
- package/dist/support.d.ts.map +1 -0
- package/dist/support.js +127 -0
- package/dist/upstep.global.js +20 -30
- package/dist/widget.d.ts +0 -2
- package/dist/widget.d.ts.map +1 -1
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -70,9 +70,9 @@ 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` | `#5B7168` | 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
|
-
| `position` | `"left" \| "right"` | `"right"` |
|
|
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()`. |
|
|
77
77
|
|
|
78
78
|
## API
|
|
@@ -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.
|
|
103
|
+
Version 0.7.0 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,14 +121,22 @@ import { UpstepProvider, FeedbackWidget } from '@upstep/js/react';
|
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
```html
|
|
124
|
-
<script defer src="https://unpkg.com/@upstep/js@0.
|
|
124
|
+
<script defer src="https://unpkg.com/@upstep/js@0.7.0/dist/upstep.global.js"
|
|
125
125
|
data-api-key="YOUR_PROJECT_KEY" data-chat="true"></script>
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
When no teammate is available, AI continues helping from the business's website
|
|
129
129
|
and confirmed answers. Unresolved issues can become private tickets with stable
|
|
130
|
-
references and the business's confirmed support email.
|
|
130
|
+
references and the business's confirmed support email. AI help needs no contact details. Before a team handoff, the customer confirms their name and email.
|
|
131
131
|
For private cross-device customer history, pass a backend-signed JWT as
|
|
132
132
|
`supportIdentityToken`, or call `Upstep.identifySupport(token)` after login and
|
|
133
133
|
`Upstep.identifySupport(undefined)` on logout. Never put the identity signing
|
|
134
134
|
secret in browser code. [Integration guide](https://upstep.dev/guides/customer-support).
|
|
135
|
+
|
|
136
|
+
### Widget layout and support forms
|
|
137
|
+
|
|
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
|
+
|
|
140
|
+
Support can show quick replies, issue details, resolution confirmations, and a contact card. The team action appears only after AI identifies an issue it cannot resolve. 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
|
+
|
|
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.
|
package/dist/index.cjs
CHANGED
|
@@ -1,91 +1,81 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("./api-BuSqdsZp.js"),x="#5B7168",l={bg:"#ffffff",bgSoft:"#f4f6f4",bgHover:"#eaf0eb",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},u={bg:"#000000",bgSoft:"#191d1b",bgHover:"#252d28",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function c(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
|
-
#upstep-btn{position:fixed;bottom:24px
|
|
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}
|
|
5
5
|
#upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
|
|
6
|
-
#upstep-btn.upstep-dragging{cursor:grabbing;transform:scale(1.06);box-shadow:0 10px 32px rgba(26,25,21,.28);transition:transform .08s,box-shadow .08s}
|
|
7
6
|
@media(max-width:639px){#upstep-btn{padding:12px}#upstep-btn span{display:none}}
|
|
8
|
-
#upstep-backdrop{
|
|
7
|
+
@media(max-width:639px){#upstep-backdrop{padding:0 12px 80px!important}#upstep-modal{max-height:calc(100dvh - 104px)!important}}
|
|
8
|
+
#upstep-backdrop{position:fixed;inset:0;background:transparent;z-index:9999;display:flex;align-items:flex-end;justify-content:flex-end;padding:0 24px 88px;animation:upstep-fade .2s ease}
|
|
9
9
|
@keyframes upstep-fade{from{opacity:0}to{opacity:1}}
|
|
10
10
|
@keyframes upstep-rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:translateY(0)}}
|
|
11
|
-
#upstep-modal{background:${
|
|
11
|
+
#upstep-modal{background:${e.bg};border:1px solid ${e.border};border-radius:20px;width:100%;max-width:440px;max-height:calc(100dvh - 112px);display:flex;flex-direction:column;overflow:hidden;box-shadow:0 24px 64px rgba(0,0,0,.28);animation:upstep-rise .26s cubic-bezier(.16,1,.3,1)}
|
|
12
12
|
#upstep-header{display:flex;align-items:flex-start;justify-content:space-between;padding:20px 20px 0}
|
|
13
|
-
#upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${
|
|
14
|
-
#upstep-header p{margin:2px 0 0;font-size:
|
|
15
|
-
#upstep-close{background:${
|
|
16
|
-
#upstep-close:hover{background:${
|
|
17
|
-
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${
|
|
18
|
-
.upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:8px;font-size:
|
|
19
|
-
.upstep-tab.active{background:${
|
|
13
|
+
#upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${e.text};letter-spacing:-.01em}
|
|
14
|
+
#upstep-header p{margin:2px 0 0;font-size:14px;color:${e.textFaint}}
|
|
15
|
+
#upstep-close{background:${e.bgSoft};border:none;width:28px;height:28px;border-radius:8px;font-size:14px;cursor:pointer;color:${e.textSoft};line-height:1;display:flex;align-items:center;justify-content:center;transition:background .15s}
|
|
16
|
+
#upstep-close:hover{background:${e.bgHover};color:${e.text}}
|
|
17
|
+
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${e.bgSoft};border-radius:11px}
|
|
18
|
+
.upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:8px;font-size:14px;font-weight:600;color:${e.textSoft};cursor:pointer;transition:all .15s}
|
|
19
|
+
.upstep-mode .upstep-tab.active{background:${e.bgSoft};box-shadow:none}
|
|
20
|
+
.upstep-tab.active{background:${e.bg};color:${e.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
|
|
20
21
|
#upstep-body{flex:1;overflow-y:auto;padding:18px 20px 22px}
|
|
21
|
-
.upstep-form textarea{width:100%;min-height:104px;border:1px solid ${
|
|
22
|
-
.upstep-form textarea::placeholder{color:${
|
|
23
|
-
.upstep-form textarea:focus{border-color:${o};background:${
|
|
22
|
+
.upstep-form textarea{width:100%;min-height:104px;border:1px solid ${e.border};border-radius:12px;padding:12px;font-size:16px;line-height:1.6;resize:vertical;outline:none;background:${e.bgSoft};color:${e.text};transition:border-color .15s}
|
|
23
|
+
.upstep-form textarea::placeholder{color:${e.textFaint}}
|
|
24
|
+
.upstep-form textarea:focus{border-color:${o};background:${e.bg}}
|
|
24
25
|
.upstep-type-row{display:flex;gap:7px;margin:12px 0 4px}
|
|
25
|
-
.upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:9px;border:1px solid ${
|
|
26
|
+
.upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:9px;border:1px solid ${e.border};background:${e.bg};color:${e.textSoft};font-size:14px;font-weight:600;cursor:pointer;transition:all .15s}
|
|
26
27
|
.upstep-type-btn svg{width:12px;height:12px;flex-shrink:0}
|
|
27
|
-
.upstep-type-btn:hover{border-color:${
|
|
28
|
+
.upstep-type-btn:hover{border-color:${e.textFaint}}
|
|
28
29
|
.upstep-type-btn.selected{background:${o};color:#fff;border-color:${o}}
|
|
29
30
|
.upstep-submit{width:100%;padding:12px;background:${o};color:#fff;border:none;border-radius:11px;font-size:14px;font-weight:600;cursor:pointer;margin-top:14px;transition:filter .15s}
|
|
30
31
|
.upstep-submit:hover{filter:brightness(.94)}
|
|
31
32
|
.upstep-submit:disabled{opacity:.5;cursor:not-allowed}
|
|
32
|
-
#upstep-form-msg{font-size:
|
|
33
|
-
.upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${
|
|
34
|
-
.upstep-feedback-item:hover{border-color:${
|
|
35
|
-
.upstep-vote{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:46px;padding:7px 0;border-radius:11px;border:1px solid ${
|
|
33
|
+
#upstep-form-msg{font-size:14px;text-align:center;margin-top:12px;color:${o};font-weight:500}
|
|
34
|
+
.upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${e.border};border-radius:14px;margin-bottom:10px;background:${e.bg};transition:border-color .15s}
|
|
35
|
+
.upstep-feedback-item:hover{border-color:${e.textFaint}}
|
|
36
|
+
.upstep-vote{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:46px;padding:7px 0;border-radius:11px;border:1px solid ${e.border};background:${e.bgSoft};cursor:pointer;transition:all .15s}
|
|
36
37
|
.upstep-vote:hover{border-color:${o}}
|
|
37
38
|
.upstep-vote.voted{border-color:${o};background:${o}1a}
|
|
38
39
|
.upstep-vote-arrow{font-size:11px;line-height:1;color:${o}}
|
|
39
|
-
.upstep-vote-count{font-size:14px;font-weight:700;color:${
|
|
40
|
+
.upstep-vote-count{font-size:14px;font-weight:700;color:${e.text};line-height:1.1}
|
|
40
41
|
.upstep-feedback-main{flex:1;min-width:0}
|
|
41
|
-
.upstep-feedback-content{font-size:
|
|
42
|
+
.upstep-feedback-content{font-size:16px;line-height:1.5;color:${e.text};margin:0 0 8px;word-break:break-word}
|
|
42
43
|
.upstep-feedback-meta{display:flex;align-items:center;gap:7px}
|
|
43
44
|
.upstep-badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:9999px;font-size:10.5px;font-weight:700;letter-spacing:.02em}
|
|
44
45
|
.upstep-badge-bug{background:#fdecec;color:#d6453d}
|
|
45
46
|
.upstep-badge-feature{background:#e9f0fd;color:#3b76d6}
|
|
46
|
-
.upstep-badge-general{background:${
|
|
47
|
-
.upstep-feedback-date{font-size:11px;color:${
|
|
48
|
-
.upstep-empty{text-align:center;color:${
|
|
49
|
-
.upstep-empty strong{display:block;color:${
|
|
50
|
-
`}const
|
|
51
|
-
<div id="upstep-modal">
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<p>${this.tab==="support"?"Ask AI, or talk with the team.":"Tell us what to build next, or vote on ideas."}</p>
|
|
56
|
-
</div>
|
|
57
|
-
<button id="upstep-close" aria-label="Close">✕</button>
|
|
58
|
-
</div>
|
|
59
|
-
<div id="upstep-tabs">
|
|
60
|
-
${this.hasSupport?`<button class="upstep-tab ${this.tab==="support"?"active":""}" data-tab="support">Support</button>`:""}
|
|
61
|
-
<button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Give feedback</button>
|
|
62
|
-
<button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Vote on ideas</button>
|
|
63
|
-
</div>
|
|
64
|
-
<div id="upstep-body">
|
|
65
|
-
${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg==="#000000"?"dark":"light")}" style="width:100%;height:480px;border:0;display:block;border-radius:12px"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
47
|
+
.upstep-badge-general{background:${e.bgSoft};color:${e.textSoft}}
|
|
48
|
+
.upstep-feedback-date{font-size:11px;color:${e.textFaint}}
|
|
49
|
+
.upstep-empty{text-align:center;color:${e.textFaint};font-size:14px;padding:40px 0}
|
|
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=c(this.themeMode)==="dark"?u: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=c(this.themeMode)==="dark"?u: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
|
+
<div id="upstep-modal" style="max-width:${this.hasSupport?"460px":"440px"}">
|
|
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
|
+
<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()}
|
|
66
56
|
</div>
|
|
67
57
|
</div>
|
|
68
|
-
`,(s=document.getElementById("upstep-backdrop"))==null||s.remove(),document.body.appendChild(
|
|
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`
|
|
69
59
|
<div class="upstep-form">
|
|
70
60
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
71
61
|
<div class="upstep-type-row">
|
|
72
|
-
${
|
|
62
|
+
${t.map(s=>`<button class="upstep-type-btn${this.selectedType===s?" selected":""}" data-type="${s}">${i[s]}${e[s]}</button>`).join("")}
|
|
73
63
|
</div>
|
|
74
64
|
<button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
|
|
75
65
|
<div id="upstep-form-msg"></div>
|
|
76
66
|
</div>
|
|
77
|
-
`}renderFeed(){return this.feedItems.length?this.feedItems.map(
|
|
78
|
-
<div class="upstep-feedback-item" data-id="${
|
|
79
|
-
<button class="upstep-vote${
|
|
67
|
+
`}renderFeed(){return this.feedItems.length?this.feedItems.map(t=>{var e;return`
|
|
68
|
+
<div class="upstep-feedback-item" data-id="${t.id}">
|
|
69
|
+
<button class="upstep-vote${t.userVote==="UP"?" voted":""}" data-vote="UP" data-feedback="${t.id}">
|
|
80
70
|
<span class="upstep-vote-arrow">▲</span>
|
|
81
|
-
<span class="upstep-vote-count">${
|
|
71
|
+
<span class="upstep-vote-count">${t.upvotes}</span>
|
|
82
72
|
</button>
|
|
83
73
|
<div class="upstep-feedback-main">
|
|
84
|
-
<p class="upstep-feedback-content">${
|
|
74
|
+
<p class="upstep-feedback-content">${b(t.content)}</p>
|
|
85
75
|
<div class="upstep-feedback-meta">
|
|
86
|
-
<span class="upstep-badge upstep-badge-${
|
|
87
|
-
<span class="upstep-badge upstep-badge-general">${
|
|
88
|
-
<span class="upstep-feedback-date">${new Date(
|
|
76
|
+
<span class="upstep-badge upstep-badge-${t.type.toLowerCase()}">${t.type}</span>
|
|
77
|
+
<span class="upstep-badge upstep-badge-general">${b(((e=t.boardStatus)==null?void 0:e.name)??t.status.replace("_"," "))}</span>
|
|
78
|
+
<span class="upstep-feedback-date">${new Date(t.createdAt).toLocaleDateString()}</span>
|
|
89
79
|
</div>
|
|
90
80
|
</div>
|
|
91
|
-
</div>`}).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const
|
|
81
|
+
</div>`}).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const t=document.getElementById("upstep-body");!t||this.tab!=="feed"||(t.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var t;document.querySelectorAll(".upstep-type-btn").forEach(e=>{e.addEventListener("click",()=>{this.selectedType=e.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(i=>i.classList.remove("selected")),e.classList.add("selected")})}),(t=document.getElementById("upstep-submit-btn"))==null||t.addEventListener("click",async()=>{const e=document.getElementById("upstep-textarea"),i=document.getElementById("upstep-form-msg"),s=document.getElementById("upstep-submit-btn");if(!e||this.loading)return;const n=e.value.trim();if(n){this.loading=!0,s&&(s.disabled=!0,s.textContent="Sending…");try{await this.client.submitFeedback({content:n,type:this.selectedType}),e.value="",i&&(i.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{i&&(i.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,s&&(s.disabled=!1,s.textContent="Send feedback")}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote").forEach(t=>{t.addEventListener("click",async()=>{const e=t.dataset.feedback;try{await this.client.vote(e,"UP"),await this.fetchFeed()}catch{}})})}}function b(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let a=null,r=null;const f={init(o){if(a=new h.UpstepApiClient(o),typeof window<"u"){const t={};o.accentColor!==void 0&&(t.accentColor=o.accentColor),o.position!==void 0&&(t.position=o.position),o.theme!==void 0&&(t.theme=o.theme),o.launcher!==void 0&&(t.launcher=o.launcher);const e=()=>{r=new y(a,t),r.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}return a},open(){r==null||r.openWidget()},close(){r==null||r.closeWidget()},identify(o){a==null||a.setUserId(o)},identifySupport(o){var e;a&&(a.supportIdentityToken=o);const t=document.querySelector("#upstep-support-frame");t&&a&&((e=t.contentWindow)==null||e.postMessage({type:"upstep:support:identity",token:o},new URL(a.baseUrl).origin))},get client(){if(!a)throw new Error("Upstep.init() must be called first");return a}};if(typeof document<"u"){const o=document.currentScript,t=o==null?void 0:o.dataset.apiKey,e=o==null?void 0:o.dataset.userId,i=o==null?void 0:o.dataset.baseUrl,s=o==null?void 0:o.dataset.accentColor,n=o==null?void 0:o.dataset.position,d=o==null?void 0:o.dataset.theme;if(t){const p={apiKey:t};e&&(p.userId=e),(o==null?void 0:o.dataset.chat)!==void 0&&(p.chat=o.dataset.chat!=="false"),i&&(p.baseUrl=i),s&&(p.accentColor=s),(n==="left"||n==="right")&&(p.position=n),(d==="light"||d==="dark"||d==="auto")&&(p.theme=d),f.init(p)}}exports.UpstepApiClient=h.UpstepApiClient;exports.default=f;
|