@upstep/js 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/index.cjs +42 -42
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -47
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts +9 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +349 -310
- package/dist/upstep.global.js +4 -4
- package/dist/widget.d.ts +3 -0
- package/dist/widget.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -77,6 +77,8 @@ Every entry point (`Upstep.init`, `<UpstepProvider>`, and the script tag's `data
|
|
|
77
77
|
| `colors` | `object` | — | Brand colors for the panel and support chat: `background`, `surface`, `border`, `text`, `textMuted`, `accentText`, plus `light` / `dark` variants. Unset keys keep the defaults. |
|
|
78
78
|
| `radius` | `number` | `12` | Base corner radius in px. Every corner scales with it; `0` is square. Clamped to 0–32. |
|
|
79
79
|
| `fontFamily` | `string` | system font | CSS font-family for the widget. |
|
|
80
|
+
| `chat` | `boolean` | `true` | Set `false` to hide support chat and keep the widget to feedback and voting. |
|
|
81
|
+
| `feedback` | `boolean` | `true` | Set `false` for a support-chat-only widget: no Ideas tab or feedback form. The launcher appears only once support chat is enabled for the project and this website. |
|
|
80
82
|
|
|
81
83
|
```js
|
|
82
84
|
Upstep.init({
|
|
@@ -143,6 +145,28 @@ import { UpstepProvider, FeedbackWidget } from '@upstep/js/react';
|
|
|
143
145
|
data-api-key="YOUR_PROJECT_KEY" data-chat="true"></script>
|
|
144
146
|
```
|
|
145
147
|
|
|
148
|
+
### Support chat only
|
|
149
|
+
|
|
150
|
+
Version 0.11.0 adds `feedback: false` for products that want help chat without a
|
|
151
|
+
public ideas board. The launcher reads **Help**, the panel shows only the chat,
|
|
152
|
+
and the ideas list is never loaded. Nothing renders where support is not enabled,
|
|
153
|
+
for example on a domain other than the project's website.
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
<UpstepProvider apiKey="YOUR_PROJECT_KEY" feedback={false}>
|
|
157
|
+
<FeedbackWidget />
|
|
158
|
+
</UpstepProvider>
|
|
159
|
+
// FeedbackWidget also accepts feedback={false} for that widget alone.
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
```html
|
|
163
|
+
<script defer src="https://upstep.dev/sdk/upstep.js"
|
|
164
|
+
data-api-key="YOUR_PROJECT_KEY" data-feedback="false"></script>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Feature requests the AI recognises in chat still offer the ideas-board card, so
|
|
168
|
+
they reach your board in the dashboard even though customers cannot browse it.
|
|
169
|
+
|
|
146
170
|
When no teammate is available, AI continues helping from the business's website
|
|
147
171
|
and confirmed answers. Unresolved issues can become private tickets with stable
|
|
148
172
|
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.
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
2
|
-
#upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}${
|
|
3
|
-
#upstep-btn,#upstep-btn *,#upstep-backdrop,#upstep-backdrop *,#upstep-toast,#upstep-toast *{font-family:${
|
|
4
|
-
#upstep-btn{position:fixed;bottom:24px;${s};z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${o};color:${
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("./api-j3GMTEE7.js"),l=require("./theme.cjs");function y(e){const t=e==null?void 0:e.trim();return t&&/^[\w\s,"'.-]{1,200}$/.test(t)?t:""}function f(e){if(e==="light"||e==="dark")return e;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 k(e,t){const s="right:24px;left:auto",o=e.accent,a=e.accentText,i=r=>`${l.scaleRadius(r,e.radius)}px`;return`
|
|
2
|
+
#upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}${t?`
|
|
3
|
+
#upstep-btn,#upstep-btn *,#upstep-backdrop,#upstep-backdrop *,#upstep-toast,#upstep-toast *{font-family:${t}}`:""}
|
|
4
|
+
#upstep-btn{position:fixed;bottom:24px;${s};z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${o};color:${a};border:none;border-radius:${i(9999)};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}
|
|
5
5
|
#upstep-btn svg{width:16px;height:16px;flex-shrink:0}
|
|
6
6
|
#upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
|
|
7
7
|
@media(max-width:639px){#upstep-btn{padding:12px}#upstep-btn span{display:none}}
|
|
@@ -9,67 +9,67 @@
|
|
|
9
9
|
#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}
|
|
10
10
|
@keyframes upstep-fade{from{opacity:0}to{opacity:1}}
|
|
11
11
|
@keyframes upstep-rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:translateY(0)}}
|
|
12
|
-
#upstep-modal{background:${
|
|
12
|
+
#upstep-modal{background:${e.bg};border:1px solid ${e.border};border-radius:${i(20)};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)}
|
|
13
13
|
#upstep-header{display:flex;align-items:flex-start;justify-content:space-between;padding:20px 20px 0}
|
|
14
|
-
#upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${
|
|
15
|
-
#upstep-header p{margin:2px 0 0;font-size:14px;color:${
|
|
16
|
-
#upstep-close{background:${
|
|
17
|
-
#upstep-close:hover{background:${
|
|
18
|
-
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${
|
|
19
|
-
.upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:${i(8)};font-size:14px;font-weight:600;color:${
|
|
20
|
-
.upstep-mode .upstep-tab.active{background:${
|
|
21
|
-
.upstep-tab.active{background:${
|
|
14
|
+
#upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${e.text};letter-spacing:-.01em}
|
|
15
|
+
#upstep-header p{margin:2px 0 0;font-size:14px;color:${e.textFaint}}
|
|
16
|
+
#upstep-close{background:${e.bgSoft};border:none;width:28px;height:28px;border-radius:${i(8)};font-size:14px;cursor:pointer;color:${e.textSoft};line-height:1;display:flex;align-items:center;justify-content:center;transition:background .15s}
|
|
17
|
+
#upstep-close:hover{background:${e.bgHover};color:${e.text}}
|
|
18
|
+
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${e.bgSoft};border-radius:${i(11)}}
|
|
19
|
+
.upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:${i(8)};font-size:14px;font-weight:600;color:${e.textSoft};cursor:pointer;transition:all .15s}
|
|
20
|
+
.upstep-mode .upstep-tab.active{background:${e.bgSoft};box-shadow:none}
|
|
21
|
+
.upstep-tab.active{background:${e.bg};color:${e.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
|
|
22
22
|
#upstep-body{flex:1;overflow-y:auto;padding:18px 20px 22px}
|
|
23
|
-
.upstep-form textarea{width:100%;min-height:104px;border:1px solid ${
|
|
24
|
-
.upstep-form textarea::placeholder{color:${
|
|
25
|
-
.upstep-form textarea:focus{border-color:${o};background:${
|
|
23
|
+
.upstep-form textarea{width:100%;min-height:104px;border:1px solid ${e.border};border-radius:${i(12)};padding:12px;font-size:16px;line-height:1.6;resize:vertical;outline:none;background:${e.bgSoft};color:${e.text};transition:border-color .15s}
|
|
24
|
+
.upstep-form textarea::placeholder{color:${e.textFaint}}
|
|
25
|
+
.upstep-form textarea:focus{border-color:${o};background:${e.bg}}
|
|
26
26
|
.upstep-type-row{display:flex;gap:7px;margin:12px 0 4px}
|
|
27
|
-
.upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:${i(9)};border:1px solid ${
|
|
27
|
+
.upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:${i(9)};border:1px solid ${e.border};background:${e.bg};color:${e.textSoft};font-size:14px;font-weight:600;cursor:pointer;transition:all .15s}
|
|
28
28
|
.upstep-type-btn svg{width:12px;height:12px;flex-shrink:0}
|
|
29
|
-
.upstep-type-btn:hover{border-color:${
|
|
30
|
-
.upstep-type-btn.selected{background:${o};color:${
|
|
31
|
-
.upstep-submit{width:100%;padding:12px;background:${o};color:${
|
|
29
|
+
.upstep-type-btn:hover{border-color:${e.textFaint}}
|
|
30
|
+
.upstep-type-btn.selected{background:${o};color:${a};border-color:${o}}
|
|
31
|
+
.upstep-submit{width:100%;padding:12px;background:${o};color:${a};border:none;border-radius:${i(11)};font-size:14px;font-weight:600;cursor:pointer;margin-top:14px;transition:filter .15s}
|
|
32
32
|
.upstep-submit:hover{filter:brightness(.94)}
|
|
33
33
|
.upstep-submit:disabled{opacity:.5;cursor:not-allowed}
|
|
34
|
-
.upstep-suggest{width:100%;display:flex;align-items:center;justify-content:center;gap:6px;padding:10px;margin-bottom:12px;background:${
|
|
34
|
+
.upstep-suggest{width:100%;display:flex;align-items:center;justify-content:center;gap:6px;padding:10px;margin-bottom:12px;background:${e.bg};color:${e.text};border:1px dashed ${e.border};border-radius:${i(11)};font-size:14px;font-weight:600;cursor:pointer;transition:border-color .15s}
|
|
35
35
|
.upstep-suggest:hover{border-color:${o}}
|
|
36
|
-
.upstep-back{background:none;border:none;padding:0;margin-bottom:10px;color:${
|
|
37
|
-
.upstep-hint{font-size:13px;color:${
|
|
36
|
+
.upstep-back{background:none;border:none;padding:0;margin-bottom:10px;color:${e.textSoft};font-size:13px;font-weight:600;cursor:pointer}
|
|
37
|
+
.upstep-hint{font-size:13px;color:${e.textFaint};margin:10px 0 0;text-align:center}
|
|
38
38
|
.upstep-hint button{background:none;border:none;padding:0;color:${o};font:inherit;font-weight:600;cursor:pointer}
|
|
39
39
|
#upstep-form-msg{font-size:14px;text-align:center;margin-top:12px;color:${o};font-weight:500}
|
|
40
|
-
.upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${
|
|
41
|
-
.upstep-feedback-item:hover{border-color:${
|
|
42
|
-
.upstep-vote{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:46px;padding:7px 0;border-radius:${i(11)};border:1px solid ${
|
|
40
|
+
.upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${e.border};border-radius:${i(14)};margin-bottom:10px;background:${e.bg};transition:border-color .15s}
|
|
41
|
+
.upstep-feedback-item:hover{border-color:${e.textFaint}}
|
|
42
|
+
.upstep-vote{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:46px;padding:7px 0;border-radius:${i(11)};border:1px solid ${e.border};background:${e.bgSoft};cursor:pointer;transition:all .15s}
|
|
43
43
|
.upstep-vote:hover{border-color:${o}}
|
|
44
|
-
.upstep-vote.voted{border-color:${o};background:${
|
|
44
|
+
.upstep-vote.voted{border-color:${o};background:${e.accentTint}}
|
|
45
45
|
.upstep-vote-arrow{font-size:11px;line-height:1;color:${o}}
|
|
46
|
-
.upstep-vote-count{font-size:14px;font-weight:700;color:${
|
|
46
|
+
.upstep-vote-count{font-size:14px;font-weight:700;color:${e.text};line-height:1.1}
|
|
47
47
|
.upstep-feedback-main{flex:1;min-width:0}
|
|
48
|
-
.upstep-feedback-content{font-size:16px;line-height:1.5;color:${
|
|
48
|
+
.upstep-feedback-content{font-size:16px;line-height:1.5;color:${e.text};margin:0 0 8px;word-break:break-word}
|
|
49
49
|
.upstep-feedback-meta{display:flex;align-items:center;gap:7px}
|
|
50
50
|
.upstep-badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:${i(9999)};font-size:10.5px;font-weight:700;letter-spacing:.02em}
|
|
51
51
|
.upstep-badge-bug{background:#fdecec;color:#d6453d}
|
|
52
52
|
.upstep-badge-feature{background:#e9f0fd;color:#3b76d6}
|
|
53
|
-
.upstep-badge-general{background:${
|
|
54
|
-
.upstep-feedback-date{font-size:11px;color:${
|
|
53
|
+
.upstep-badge-general{background:${e.bgSoft};color:${e.textSoft}}
|
|
54
|
+
.upstep-feedback-date{font-size:11px;color:${e.textFaint}}
|
|
55
55
|
#upstep-btn{position:fixed}
|
|
56
|
-
.upstep-unread{position:absolute;top:-7px;right:-5px;min-width:22px;height:22px;padding:0 6px;border-radius:11px;background:${
|
|
56
|
+
.upstep-unread{position:absolute;top:-7px;right:-5px;min-width:22px;height:22px;padding:0 6px;border-radius:11px;background:${e.text};color:${e.bg};border:2px solid ${e.bg};font-size:12px;font-weight:700;line-height:18px;text-align:center;font-variant-numeric:tabular-nums;animation:upstep-pop .45s cubic-bezier(.3,1.6,.5,1)}
|
|
57
57
|
@keyframes upstep-pop{from{transform:scale(.4)}to{transform:scale(1)}}
|
|
58
|
-
#upstep-toast{position:fixed;bottom:84px;right:24px;z-index:9998;max-width:min(300px,calc(100vw - 48px));display:grid;gap:2px;text-align:left;background:${
|
|
58
|
+
#upstep-toast{position:fixed;bottom:84px;right:24px;z-index:9998;max-width:min(300px,calc(100vw - 48px));display:grid;gap:2px;text-align:left;background:${e.bg};color:${e.text};border:1px solid ${e.border};border-radius:${i(14)} ${i(14)} ${i(4)} ${i(14)};padding:10px 12px;box-shadow:0 10px 32px rgba(0,0,0,.2);cursor:pointer;animation:upstep-rise .26s cubic-bezier(.16,1,.3,1)}
|
|
59
59
|
#upstep-toast b{font-size:12px}
|
|
60
|
-
#upstep-toast span{font-size:14px;line-height:1.4;color:${
|
|
60
|
+
#upstep-toast span{font-size:14px;line-height:1.4;color:${e.textSoft};display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
|
|
61
61
|
#upstep-toast em{font-style:normal;font-size:11px;font-weight:600;color:${o}}
|
|
62
62
|
@media(prefers-reduced-motion:reduce){.upstep-unread,#upstep-toast{animation:none}}
|
|
63
|
-
.upstep-empty{text-align:center;color:${
|
|
64
|
-
.upstep-empty strong{display:block;color:${
|
|
65
|
-
`}const
|
|
63
|
+
.upstep-empty{text-align:center;color:${e.textFaint};font-size:14px;padding:40px 0}
|
|
64
|
+
.upstep-empty strong{display:block;color:${e.textSoft};font-size:15px;margin-bottom:4px}
|
|
65
|
+
`}const v='<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 ${constructor(t,s={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.hasSupport=!1,this.disconnectSupport=null,this.unread=0,this.audio=null,this.frameTheme=null,this.unreadListeners=new Set,this.client=t,this.options=s,this.position="right",this.showLauncher=s.launcher!==!1,this.feedback=s.feedback!==!1,this.themeMode=s.theme??"auto",this.palette=this.buildPalette(f(this.themeMode))}buildPalette(t){return l.buildWidgetPalette({mode:t,accentColor:this.options.accentColor,colors:this.options.colors,radius:this.options.radius})}get accent(){return this.palette.accent}supportFrameSrc(){return this.client.supportFrameUrl(this.palette.dark?"dark":"light",this.accent,{colors:this.options.colors,radius:this.options.radius,fontFamily:this.options.fontFamily})}mount(){this.injectStyles(),this.showLauncher&&this.feedback&&this.renderButton(),this.client.supportEnabled().then(t=>{if(this.hasSupport=t,t){this.showLauncher&&!this.feedback&&this.renderButton();const s=document.querySelector("#upstep-btn span");s&&(s.textContent=this.feedback?"Help & feedback":"Help"),this.isOpen?this.renderModal():this.hasOpenedSupport()&&this.preloadSupport()}})}openWidget(){this.openModal()}closeWidget(){this.closeModal()}isChatVisible(){return this.isOpen}onUnread(t){return this.unreadListeners.add(t),t(this.unread),()=>{this.unreadListeners.delete(t)}}injectStyles(){var s;(s=document.getElementById("upstep-styles"))==null||s.remove();const t=document.createElement("style");t.id="upstep-styles",t.textContent=k(this.palette,y(this.options.fontFamily)),document.head.appendChild(t)}renderButton(){const t=document.createElement("button");t.id="upstep-btn",t.setAttribute("aria-label",this.feedback?"Open help and feedback":"Open support chat"),t.innerHTML=`${v}<span>${this.feedback?"Feedback":"Help"}</span>`,t.addEventListener("click",()=>{this.openModal()}),document.body.appendChild(t)}supportFrame(){return document.querySelector("#upstep-support-frame")}get usedKey(){return`upstep:support-opened:${this.client.baseUrl}`}hasOpenedSupport(){try{return localStorage.getItem(this.usedKey)==="1"}catch{return!1}}preloadSupport(){this.tab="support",this.renderModal(!0)}openModal(){if(!this.feedback&&!this.hasSupport)return;if(this.unlockAudio(),!this.isOpen&&this.hasSupport){this.tab="support";try{localStorage.setItem(this.usedKey,"1")}catch{}}const t=f(this.themeMode),s=document.getElementById("upstep-backdrop"),o=this.supportFrame();if(!this.isOpen&&s&&o&&s.style.display==="none"&&this.frameTheme===t){this.isOpen=!0,s.style.display="",this.client.notifySupportVisibility(o,!0),this.setUnread(0),this.fetchFeed();return}this.isOpen=!0,this.palette=this.buildPalette(t),this.injectStyles(),this.fetchFeed(),this.renderModal(),this.setUnread(0)}closeModal(){var t,s;if(this.isOpen=!1,this.hasSupport){const o=this.supportFrame(),a=document.getElementById("upstep-backdrop");o&&a?(a.style.display="none",this.client.notifySupportVisibility(o,!1)):this.preloadSupport();return}(t=this.disconnectSupport)==null||t.call(this),this.disconnectSupport=null,(s=document.getElementById("upstep-backdrop"))==null||s.remove()}setUnread(t){this.unread=t;const s=document.getElementById("upstep-btn"),o=s==null?void 0:s.querySelector(".upstep-unread");if(s){if(t>0){const i=o??document.createElement("span");i.className="upstep-unread",i.textContent=t>9?"9+":String(t),o||s.appendChild(i)}else o==null||o.remove();s.setAttribute("aria-label",t>0?`Open help and feedback, ${t} unread ${t===1?"message":"messages"}`:"Open help and feedback")}const a=document.title.replace(/^\(\d+\)\s/,"");document.title=t>0?`(${t}) ${a}`:a,t===0&&this.hideToast(),this.unreadListeners.forEach(i=>i(t))}onSupportUnread(t){if(this.isOpen)return this.setUnread(0);this.setUnread(t.count),t.newMessage&&t.count>0&&(this.showToast(t),t.sound&&this.chime())}showToast(t){this.hideToast();const s=document.createElement("button");s.id="upstep-toast",s.type="button",s.setAttribute("role","status");const o=document.createElement("b");o.textContent=t.author||"New message";const a=document.createElement("span");a.textContent=t.preview;const i=document.createElement("em");i.textContent=t.count>1?`${t.count} new messages`:"Tap to reply",s.append(o,a,i),s.addEventListener("click",()=>this.openModal()),document.body.appendChild(s),this.toastTimer=setTimeout(()=>this.hideToast(),9e3)}hideToast(){var t;clearTimeout(this.toastTimer),(t=document.getElementById("upstep-toast"))==null||t.remove()}unlockAudio(){try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;this.audio=this.audio??new t,this.audio.state==="suspended"&&this.audio.resume()}catch{}}chime(){const t=this.audio;if(!t||t.state!=="running")return;const s=t.currentTime;for(const[o,a]of[[880,0],[1318,.12]]){const i=t.createOscillator(),r=t.createGain();i.type="sine",i.frequency.value=o,r.gain.setValueAtTime(1e-4,s+a),r.gain.exponentialRampToValueAtTime(.14,s+a+.02),r.gain.exponentialRampToValueAtTime(1e-4,s+a+.5),i.connect(r),r.connect(t.destination),i.start(s+a),i.stop(s+a+.55)}}async fetchFeed(){if(this.feedback)try{const t=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=t.items,this.renderFeedList()}catch{}}renderModal(t=!1){var a,i,r;(a=this.disconnectSupport)==null||a.call(this),this.disconnectSupport=null;const s=document.createElement("div");s.id="upstep-backdrop",s.addEventListener("click",n=>{n.target===s&&this.closeModal()}),s.innerHTML=`
|
|
66
66
|
<div id="upstep-modal" style="max-width:${this.hasSupport?"460px":"440px"}">
|
|
67
|
-
${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!=="support"?"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>`}
|
|
67
|
+
${this.hasSupport&&!this.feedback?`<div class="upstep-mode" style="display:flex;align-items:center;gap:14px;padding:14px 16px 14px 20px;border-bottom:1px solid ${this.palette.border}"><h2 style="flex:1;margin:0;font-size:16px">Support</h2><button id="upstep-close" aria-label="Close" style="flex-shrink:0;background:transparent">✕</button></div>`: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!=="support"?"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>`}
|
|
68
68
|
<div id="upstep-body" style="${this.tab==="support"?"padding:0;overflow:hidden":""}">
|
|
69
69
|
${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${h(this.supportFrameSrc())}" style="width:100%;height:min(560px,calc(100dvh - 168px));min-height:300px;border:0;display:block"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
70
70
|
</div>
|
|
71
71
|
</div>
|
|
72
|
-
`,(i=document.getElementById("upstep-backdrop"))==null||i.remove(),
|
|
72
|
+
`,(i=document.getElementById("upstep-backdrop"))==null||i.remove(),t&&(s.style.display="none"),document.body.appendChild(s),(r=s.querySelector("#upstep-close"))==null||r.addEventListener("click",()=>this.closeModal()),s.querySelectorAll(".upstep-tab").forEach(n=>{n.addEventListener("click",()=>{this.tab=n.dataset.tab,this.renderModal()})});const o=s.querySelector("#upstep-support-frame");o&&(o.style.color=this.accent,this.frameTheme=this.palette.dark?"dark":"light",this.disconnectSupport=this.client.connectSupportFrame(o,{isVisible:()=>this.isOpen,onUnread:n=>this.onSupportUnread(n)})),this.bindSubmitForm(),this.bindFeed()}renderSubmitForm(){const t=["BUG","FEATURE","GENERAL"],s={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 this.hasSupport?`
|
|
73
73
|
<div class="upstep-form">
|
|
74
74
|
<button class="upstep-back" data-goto="feed">← Ideas</button>
|
|
75
75
|
<textarea id="upstep-textarea" placeholder="What would you like us to build?" maxlength="2000"></textarea>
|
|
@@ -81,12 +81,12 @@
|
|
|
81
81
|
<div class="upstep-form">
|
|
82
82
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
83
83
|
<div class="upstep-type-row">
|
|
84
|
-
${
|
|
84
|
+
${t.map(a=>`<button class="upstep-type-btn${this.selectedType===a?" selected":""}" data-type="${a}">${o[a]}${s[a]}</button>`).join("")}
|
|
85
85
|
</div>
|
|
86
86
|
<button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
|
|
87
87
|
<div id="upstep-form-msg"></div>
|
|
88
88
|
</div>
|
|
89
|
-
`}renderFeed(){const
|
|
89
|
+
`}renderFeed(){const t=this.hasSupport?'<button class="upstep-suggest" data-goto="submit"><span aria-hidden="true">+</span> Suggest an idea</button>':"";return this.feedItems.length?t+this.feedItems.map(s=>{var o;return`
|
|
90
90
|
<div class="upstep-feedback-item" data-id="${s.id}">
|
|
91
91
|
<button class="upstep-vote${s.userVote==="UP"?" voted":""}" data-vote="UP" data-feedback="${s.id}">
|
|
92
92
|
<span class="upstep-vote-arrow">▲</span>
|
|
@@ -100,4 +100,4 @@
|
|
|
100
100
|
<span class="upstep-feedback-date">${new Date(s.createdAt).toLocaleDateString()}</span>
|
|
101
101
|
</div>
|
|
102
102
|
</div>
|
|
103
|
-
</div>`}).join(""):`${
|
|
103
|
+
</div>`}).join(""):`${t}<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.bindFeed())}bindSubmitForm(){var t;document.querySelectorAll(".upstep-type-btn").forEach(s=>{s.addEventListener("click",()=>{this.selectedType=s.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(o=>o.classList.remove("selected")),s.classList.add("selected")})}),(t=document.getElementById("upstep-submit-btn"))==null||t.addEventListener("click",async()=>{const s=document.getElementById("upstep-textarea"),o=document.getElementById("upstep-form-msg"),a=document.getElementById("upstep-submit-btn");if(!s||this.loading)return;const i=s.value.trim();if(i){this.loading=!0,a&&(a.disabled=!0,a.textContent="Sending…");try{await this.client.submitFeedback({content:i,type:this.hasSupport?"FEATURE":this.selectedType}),s.value="",o&&(o.textContent=this.hasSupport?"Idea received. Thank you.":"Feedback received. Thank you."),await this.fetchFeed()}catch{o&&(o.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,a&&(a.disabled=!1,a.textContent=this.hasSupport?"Suggest idea":"Send feedback")}}})}bindFeed(){this.bindVoteButtons(),document.querySelectorAll("#upstep-body [data-goto]").forEach(t=>{t.addEventListener("click",()=>{this.tab=t.dataset.goto,this.renderModal()})})}bindVoteButtons(){document.querySelectorAll(".upstep-vote").forEach(t=>{t.addEventListener("click",async()=>{const s=t.dataset.feedback;try{await this.client.vote(s,"UP"),await this.fetchFeed()}catch{}})})}}function h(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let d=null,p=null;const g={init(e){if(d=new x.UpstepApiClient(e),typeof window<"u"){const t={};e.accentColor!==void 0&&(t.accentColor=e.accentColor),e.position!==void 0&&(t.position=e.position),e.theme!==void 0&&(t.theme=e.theme),e.launcher!==void 0&&(t.launcher=e.launcher),e.feedback!==void 0&&(t.feedback=e.feedback),e.colors!==void 0&&(t.colors=e.colors),e.radius!==void 0&&(t.radius=e.radius),e.fontFamily!==void 0&&(t.fontFamily=e.fontFamily);const s=()=>{p=new $(d,t),p.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",s):s()}return d},open(){p==null||p.openWidget()},close(){p==null||p.closeWidget()},identify(e){d==null||d.setUserId(e)},identifySupport(e){var s;d&&(d.supportIdentityToken=e);const t=document.querySelector("#upstep-support-frame");t&&d&&((s=t.contentWindow)==null||s.postMessage({type:"upstep:support:identity",token:e,visible:(p==null?void 0:p.isChatVisible())??!0},new URL(d.baseUrl).origin))},onUnread(e){return(p==null?void 0:p.onUnread(e))??(()=>{})},get client(){if(!d)throw new Error("Upstep.init() must be called first");return d}};if(typeof document<"u"){const e=document.currentScript,t=e==null?void 0:e.dataset.apiKey,s=e==null?void 0:e.dataset.userId,o=e==null?void 0:e.dataset.baseUrl,a=e==null?void 0:e.dataset.accentColor,i=e==null?void 0:e.dataset.position,r=e==null?void 0:e.dataset.theme;if(t){const n={apiKey:t};s&&(n.userId=s),(e==null?void 0:e.dataset.chat)!==void 0&&(n.chat=e.dataset.chat!=="false"),(e==null?void 0:e.dataset.feedback)!==void 0&&(n.feedback=e.dataset.feedback!=="false"),o&&(n.baseUrl=o),a&&(n.accentColor=a),(i==="left"||i==="right")&&(n.position=i),(r==="light"||r==="dark"||r==="auto")&&(n.theme=r);const b=e==null?void 0:e.dataset.colors;if(b)try{const c=JSON.parse(b);c&&typeof c=="object"&&(n.colors=c)}catch{console.warn("Upstep: data-colors must be JSON")}const u=e==null?void 0:e.dataset.radius;u&&Number.isFinite(Number(u))&&(n.radius=Number(u));const m=e==null?void 0:e.dataset.fontFamily;m&&(n.fontFamily=m),g.init(n)}}exports.UpstepApiClient=x.UpstepApiClient;exports.buildWidgetPalette=l.buildWidgetPalette;exports.readableTextOn=l.readableTextOn;exports.default=g;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAGxC,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAK7D,QAAA,MAAM,MAAM;iBACG,YAAY;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAGxC,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAK7D,QAAA,MAAM,MAAM;iBACG,YAAY;IAyBzB,0EAA0E;;IAK1E,iCAAiC;;IAKjC,6EAA6E;qBAC5D,MAAM,GAAG,SAAS;IAInC,oEAAoE;2BAC7C,MAAM,GAAG,SAAS;IAMzC,iGAAiG;uBAC9E,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;qBAI5B,eAAe;CAI9B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { U as f } from "./api-CROQwfAo.mjs";
|
|
2
2
|
import { buildWidgetPalette as x, scaleRadius as g } from "./theme.js";
|
|
3
|
-
import { readableTextOn as
|
|
3
|
+
import { readableTextOn as M } from "./theme.js";
|
|
4
4
|
function y(t) {
|
|
5
5
|
const e = t == null ? void 0 : t.trim();
|
|
6
6
|
return e && /^[\w\s,"'.-]{1,200}$/.test(e) ? e : "";
|
|
@@ -13,12 +13,12 @@ function m(t) {
|
|
|
13
13
|
}
|
|
14
14
|
return typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const s = "right:24px;left:auto", o = t.accent,
|
|
16
|
+
function k(t, e) {
|
|
17
|
+
const s = "right:24px;left:auto", o = t.accent, a = t.accentText, i = (r) => `${g(r, t.radius)}px`;
|
|
18
18
|
return `
|
|
19
19
|
#upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}${e ? `
|
|
20
20
|
#upstep-btn,#upstep-btn *,#upstep-backdrop,#upstep-backdrop *,#upstep-toast,#upstep-toast *{font-family:${e}}` : ""}
|
|
21
|
-
#upstep-btn{position:fixed;bottom:24px;${s};z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${o};color:${
|
|
21
|
+
#upstep-btn{position:fixed;bottom:24px;${s};z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${o};color:${a};border:none;border-radius:${i(9999)};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}
|
|
22
22
|
#upstep-btn svg{width:16px;height:16px;flex-shrink:0}
|
|
23
23
|
#upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
|
|
24
24
|
@media(max-width:639px){#upstep-btn{padding:12px}#upstep-btn span{display:none}}
|
|
@@ -44,8 +44,8 @@ function v(t, e) {
|
|
|
44
44
|
.upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:${i(9)};border:1px solid ${t.border};background:${t.bg};color:${t.textSoft};font-size:14px;font-weight:600;cursor:pointer;transition:all .15s}
|
|
45
45
|
.upstep-type-btn svg{width:12px;height:12px;flex-shrink:0}
|
|
46
46
|
.upstep-type-btn:hover{border-color:${t.textFaint}}
|
|
47
|
-
.upstep-type-btn.selected{background:${o};color:${
|
|
48
|
-
.upstep-submit{width:100%;padding:12px;background:${o};color:${
|
|
47
|
+
.upstep-type-btn.selected{background:${o};color:${a};border-color:${o}}
|
|
48
|
+
.upstep-submit{width:100%;padding:12px;background:${o};color:${a};border:none;border-radius:${i(11)};font-size:14px;font-weight:600;cursor:pointer;margin-top:14px;transition:filter .15s}
|
|
49
49
|
.upstep-submit:hover{filter:brightness(.94)}
|
|
50
50
|
.upstep-submit:disabled{opacity:.5;cursor:not-allowed}
|
|
51
51
|
.upstep-suggest{width:100%;display:flex;align-items:center;justify-content:center;gap:6px;padding:10px;margin-bottom:12px;background:${t.bg};color:${t.text};border:1px dashed ${t.border};border-radius:${i(11)};font-size:14px;font-weight:600;cursor:pointer;transition:border-color .15s}
|
|
@@ -81,10 +81,10 @@ function v(t, e) {
|
|
|
81
81
|
.upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
|
|
82
82
|
`;
|
|
83
83
|
}
|
|
84
|
-
const
|
|
84
|
+
const v = '<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>';
|
|
85
85
|
class $ {
|
|
86
86
|
constructor(e, s = {}) {
|
|
87
|
-
this.isOpen = !1, this.tab = "submit", this.feedItems = [], this.selectedType = "GENERAL", this.loading = !1, this.hasSupport = !1, this.disconnectSupport = null, this.unread = 0, this.audio = null, this.frameTheme = null, this.unreadListeners = /* @__PURE__ */ new Set(), this.client = e, this.options = s, this.position = "right", this.showLauncher = s.launcher !== !1, this.themeMode = s.theme ?? "auto", this.palette = this.buildPalette(m(this.themeMode));
|
|
87
|
+
this.isOpen = !1, this.tab = "submit", this.feedItems = [], this.selectedType = "GENERAL", this.loading = !1, this.hasSupport = !1, this.disconnectSupport = null, this.unread = 0, this.audio = null, this.frameTheme = null, this.unreadListeners = /* @__PURE__ */ new Set(), this.client = e, this.options = s, this.position = "right", this.showLauncher = s.launcher !== !1, this.feedback = s.feedback !== !1, this.themeMode = s.theme ?? "auto", this.palette = this.buildPalette(m(this.themeMode));
|
|
88
88
|
}
|
|
89
89
|
buildPalette(e) {
|
|
90
90
|
return x({
|
|
@@ -109,10 +109,11 @@ class $ {
|
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
mount() {
|
|
112
|
-
this.injectStyles(), this.showLauncher && this.renderButton(), this.client.supportEnabled().then((e) => {
|
|
112
|
+
this.injectStyles(), this.showLauncher && this.feedback && this.renderButton(), this.client.supportEnabled().then((e) => {
|
|
113
113
|
if (this.hasSupport = e, e) {
|
|
114
|
+
this.showLauncher && !this.feedback && this.renderButton();
|
|
114
115
|
const s = document.querySelector("#upstep-btn span");
|
|
115
|
-
s && (s.textContent = "Help & feedback"), this.isOpen ? this.renderModal() : this.hasOpenedSupport() && this.preloadSupport();
|
|
116
|
+
s && (s.textContent = this.feedback ? "Help & feedback" : "Help"), this.isOpen ? this.renderModal() : this.hasOpenedSupport() && this.preloadSupport();
|
|
116
117
|
}
|
|
117
118
|
});
|
|
118
119
|
}
|
|
@@ -138,14 +139,17 @@ class $ {
|
|
|
138
139
|
var s;
|
|
139
140
|
(s = document.getElementById("upstep-styles")) == null || s.remove();
|
|
140
141
|
const e = document.createElement("style");
|
|
141
|
-
e.id = "upstep-styles", e.textContent =
|
|
142
|
+
e.id = "upstep-styles", e.textContent = k(
|
|
142
143
|
this.palette,
|
|
143
144
|
y(this.options.fontFamily)
|
|
144
145
|
), document.head.appendChild(e);
|
|
145
146
|
}
|
|
146
147
|
renderButton() {
|
|
147
148
|
const e = document.createElement("button");
|
|
148
|
-
e.id = "upstep-btn", e.setAttribute(
|
|
149
|
+
e.id = "upstep-btn", e.setAttribute(
|
|
150
|
+
"aria-label",
|
|
151
|
+
this.feedback ? "Open help and feedback" : "Open support chat"
|
|
152
|
+
), e.innerHTML = `${v}<span>${this.feedback ? "Feedback" : "Help"}</span>`, e.addEventListener("click", () => {
|
|
149
153
|
this.openModal();
|
|
150
154
|
}), document.body.appendChild(e);
|
|
151
155
|
}
|
|
@@ -166,6 +170,7 @@ class $ {
|
|
|
166
170
|
this.tab = "support", this.renderModal(!0);
|
|
167
171
|
}
|
|
168
172
|
openModal() {
|
|
173
|
+
if (!this.feedback && !this.hasSupport) return;
|
|
169
174
|
if (this.unlockAudio(), !this.isOpen && this.hasSupport) {
|
|
170
175
|
this.tab = "support";
|
|
171
176
|
try {
|
|
@@ -183,8 +188,8 @@ class $ {
|
|
|
183
188
|
closeModal() {
|
|
184
189
|
var e, s;
|
|
185
190
|
if (this.isOpen = !1, this.hasSupport) {
|
|
186
|
-
const o = this.supportFrame(),
|
|
187
|
-
o &&
|
|
191
|
+
const o = this.supportFrame(), a = document.getElementById("upstep-backdrop");
|
|
192
|
+
o && a ? (a.style.display = "none", this.client.notifySupportVisibility(o, !1)) : this.preloadSupport();
|
|
188
193
|
return;
|
|
189
194
|
}
|
|
190
195
|
(e = this.disconnectSupport) == null || e.call(this), this.disconnectSupport = null, (s = document.getElementById("upstep-backdrop")) == null || s.remove();
|
|
@@ -202,8 +207,8 @@ class $ {
|
|
|
202
207
|
e > 0 ? `Open help and feedback, ${e} unread ${e === 1 ? "message" : "messages"}` : "Open help and feedback"
|
|
203
208
|
);
|
|
204
209
|
}
|
|
205
|
-
const
|
|
206
|
-
document.title = e > 0 ? `(${e}) ${
|
|
210
|
+
const a = document.title.replace(/^\(\d+\)\s/, "");
|
|
211
|
+
document.title = e > 0 ? `(${e}) ${a}` : a, e === 0 && this.hideToast(), this.unreadListeners.forEach((i) => i(e));
|
|
207
212
|
}
|
|
208
213
|
onSupportUnread(e) {
|
|
209
214
|
if (this.isOpen) return this.setUnread(0);
|
|
@@ -215,10 +220,10 @@ class $ {
|
|
|
215
220
|
s.id = "upstep-toast", s.type = "button", s.setAttribute("role", "status");
|
|
216
221
|
const o = document.createElement("b");
|
|
217
222
|
o.textContent = e.author || "New message";
|
|
218
|
-
const
|
|
219
|
-
|
|
223
|
+
const a = document.createElement("span");
|
|
224
|
+
a.textContent = e.preview;
|
|
220
225
|
const i = document.createElement("em");
|
|
221
|
-
i.textContent = e.count > 1 ? `${e.count} new messages` : "Tap to reply", s.append(o,
|
|
226
|
+
i.textContent = e.count > 1 ? `${e.count} new messages` : "Tap to reply", s.append(o, a, i), s.addEventListener("click", () => this.openModal()), document.body.appendChild(s), this.toastTimer = setTimeout(() => this.hideToast(), 9e3);
|
|
222
227
|
}
|
|
223
228
|
hideToast() {
|
|
224
229
|
var e;
|
|
@@ -237,37 +242,38 @@ class $ {
|
|
|
237
242
|
const e = this.audio;
|
|
238
243
|
if (!e || e.state !== "running") return;
|
|
239
244
|
const s = e.currentTime;
|
|
240
|
-
for (const [o,
|
|
245
|
+
for (const [o, a] of [
|
|
241
246
|
[880, 0],
|
|
242
247
|
[1318, 0.12]
|
|
243
248
|
]) {
|
|
244
249
|
const i = e.createOscillator(), r = e.createGain();
|
|
245
|
-
i.type = "sine", i.frequency.value = o, r.gain.setValueAtTime(1e-4, s +
|
|
250
|
+
i.type = "sine", i.frequency.value = o, r.gain.setValueAtTime(1e-4, s + a), r.gain.exponentialRampToValueAtTime(0.14, s + a + 0.02), r.gain.exponentialRampToValueAtTime(1e-4, s + a + 0.5), i.connect(r), r.connect(e.destination), i.start(s + a), i.stop(s + a + 0.55);
|
|
246
251
|
}
|
|
247
252
|
}
|
|
248
253
|
async fetchFeed() {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
+
if (this.feedback)
|
|
255
|
+
try {
|
|
256
|
+
const e = await this.client.listFeedback({ sort: "votes", limit: 20 });
|
|
257
|
+
this.feedItems = e.items, this.renderFeedList();
|
|
258
|
+
} catch {
|
|
259
|
+
}
|
|
254
260
|
}
|
|
255
261
|
renderModal(e = !1) {
|
|
256
|
-
var
|
|
257
|
-
(
|
|
262
|
+
var a, i, r;
|
|
263
|
+
(a = this.disconnectSupport) == null || a.call(this), this.disconnectSupport = null;
|
|
258
264
|
const s = document.createElement("div");
|
|
259
|
-
s.id = "upstep-backdrop", s.addEventListener("click", (
|
|
260
|
-
|
|
265
|
+
s.id = "upstep-backdrop", s.addEventListener("click", (n) => {
|
|
266
|
+
n.target === s && this.closeModal();
|
|
261
267
|
}), s.innerHTML = `
|
|
262
268
|
<div id="upstep-modal" style="max-width:${this.hasSupport ? "460px" : "440px"}">
|
|
263
|
-
${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 !== "support" ? "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>`}
|
|
269
|
+
${this.hasSupport && !this.feedback ? `<div class="upstep-mode" style="display:flex;align-items:center;gap:14px;padding:14px 16px 14px 20px;border-bottom:1px solid ${this.palette.border}"><h2 style="flex:1;margin:0;font-size:16px">Support</h2><button id="upstep-close" aria-label="Close" style="flex-shrink:0;background:transparent">✕</button></div>` : 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 !== "support" ? "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>`}
|
|
264
270
|
<div id="upstep-body" style="${this.tab === "support" ? "padding:0;overflow:hidden" : ""}">
|
|
265
271
|
${this.tab === "support" ? `<iframe id="upstep-support-frame" title="Customer support" src="${c(this.supportFrameSrc())}" style="width:100%;height:min(560px,calc(100dvh - 168px));min-height:300px;border:0;display:block"></iframe>` : this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
|
|
266
272
|
</div>
|
|
267
273
|
</div>
|
|
268
|
-
`, (i = document.getElementById("upstep-backdrop")) == null || i.remove(), e && (s.style.display = "none"), document.body.appendChild(s), (r = s.querySelector("#upstep-close")) == null || r.addEventListener("click", () => this.closeModal()), s.querySelectorAll(".upstep-tab").forEach((
|
|
269
|
-
|
|
270
|
-
this.tab =
|
|
274
|
+
`, (i = document.getElementById("upstep-backdrop")) == null || i.remove(), e && (s.style.display = "none"), document.body.appendChild(s), (r = s.querySelector("#upstep-close")) == null || r.addEventListener("click", () => this.closeModal()), s.querySelectorAll(".upstep-tab").forEach((n) => {
|
|
275
|
+
n.addEventListener("click", () => {
|
|
276
|
+
this.tab = n.dataset.tab, this.renderModal();
|
|
271
277
|
});
|
|
272
278
|
});
|
|
273
279
|
const o = s.querySelector(
|
|
@@ -275,7 +281,7 @@ class $ {
|
|
|
275
281
|
);
|
|
276
282
|
o && (o.style.color = this.accent, this.frameTheme = this.palette.dark ? "dark" : "light", this.disconnectSupport = this.client.connectSupportFrame(o, {
|
|
277
283
|
isVisible: () => this.isOpen,
|
|
278
|
-
onUnread: (
|
|
284
|
+
onUnread: (n) => this.onSupportUnread(n)
|
|
279
285
|
})), this.bindSubmitForm(), this.bindFeed();
|
|
280
286
|
}
|
|
281
287
|
renderSubmitForm() {
|
|
@@ -300,7 +306,7 @@ class $ {
|
|
|
300
306
|
<div class="upstep-form">
|
|
301
307
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
302
308
|
<div class="upstep-type-row">
|
|
303
|
-
${e.map((
|
|
309
|
+
${e.map((a) => `<button class="upstep-type-btn${this.selectedType === a ? " selected" : ""}" data-type="${a}">${o[a]}${s[a]}</button>`).join("")}
|
|
304
310
|
</div>
|
|
305
311
|
<button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
|
|
306
312
|
<div id="upstep-form-msg"></div>
|
|
@@ -343,13 +349,13 @@ class $ {
|
|
|
343
349
|
}), (e = document.getElementById("upstep-submit-btn")) == null || e.addEventListener("click", async () => {
|
|
344
350
|
const s = document.getElementById(
|
|
345
351
|
"upstep-textarea"
|
|
346
|
-
), o = document.getElementById("upstep-form-msg"),
|
|
352
|
+
), o = document.getElementById("upstep-form-msg"), a = document.getElementById(
|
|
347
353
|
"upstep-submit-btn"
|
|
348
354
|
);
|
|
349
355
|
if (!s || this.loading) return;
|
|
350
356
|
const i = s.value.trim();
|
|
351
357
|
if (i) {
|
|
352
|
-
this.loading = !0,
|
|
358
|
+
this.loading = !0, a && (a.disabled = !0, a.textContent = "Sending…");
|
|
353
359
|
try {
|
|
354
360
|
await this.client.submitFeedback({
|
|
355
361
|
content: i,
|
|
@@ -358,7 +364,7 @@ class $ {
|
|
|
358
364
|
} catch {
|
|
359
365
|
o && (o.textContent = "Something went wrong. Please try again.");
|
|
360
366
|
} finally {
|
|
361
|
-
this.loading = !1,
|
|
367
|
+
this.loading = !1, a && (a.disabled = !1, a.textContent = this.hasSupport ? "Suggest idea" : "Send feedback");
|
|
362
368
|
}
|
|
363
369
|
}
|
|
364
370
|
});
|
|
@@ -390,7 +396,7 @@ const w = {
|
|
|
390
396
|
init(t) {
|
|
391
397
|
if (d = new f(t), typeof window < "u") {
|
|
392
398
|
const e = {};
|
|
393
|
-
t.accentColor !== void 0 && (e.accentColor = t.accentColor), t.position !== void 0 && (e.position = t.position), t.theme !== void 0 && (e.theme = t.theme), t.launcher !== void 0 && (e.launcher = t.launcher), t.colors !== void 0 && (e.colors = t.colors), t.radius !== void 0 && (e.radius = t.radius), t.fontFamily !== void 0 && (e.fontFamily = t.fontFamily);
|
|
399
|
+
t.accentColor !== void 0 && (e.accentColor = t.accentColor), t.position !== void 0 && (e.position = t.position), t.theme !== void 0 && (e.theme = t.theme), t.launcher !== void 0 && (e.launcher = t.launcher), t.feedback !== void 0 && (e.feedback = t.feedback), t.colors !== void 0 && (e.colors = t.colors), t.radius !== void 0 && (e.radius = t.radius), t.fontFamily !== void 0 && (e.fontFamily = t.fontFamily);
|
|
394
400
|
const s = () => {
|
|
395
401
|
p = new $(d, e), p.mount();
|
|
396
402
|
};
|
|
@@ -428,27 +434,27 @@ const w = {
|
|
|
428
434
|
}
|
|
429
435
|
};
|
|
430
436
|
if (typeof document < "u") {
|
|
431
|
-
const t = document.currentScript, e = t == null ? void 0 : t.dataset.apiKey, s = t == null ? void 0 : t.dataset.userId, o = t == null ? void 0 : t.dataset.baseUrl,
|
|
437
|
+
const t = document.currentScript, e = t == null ? void 0 : t.dataset.apiKey, s = t == null ? void 0 : t.dataset.userId, o = t == null ? void 0 : t.dataset.baseUrl, a = t == null ? void 0 : t.dataset.accentColor, i = t == null ? void 0 : t.dataset.position, r = t == null ? void 0 : t.dataset.theme;
|
|
432
438
|
if (e) {
|
|
433
|
-
const
|
|
434
|
-
s && (
|
|
439
|
+
const n = { apiKey: e };
|
|
440
|
+
s && (n.userId = s), (t == null ? void 0 : t.dataset.chat) !== void 0 && (n.chat = t.dataset.chat !== "false"), (t == null ? void 0 : t.dataset.feedback) !== void 0 && (n.feedback = t.dataset.feedback !== "false"), o && (n.baseUrl = o), a && (n.accentColor = a), (i === "left" || i === "right") && (n.position = i), (r === "light" || r === "dark" || r === "auto") && (n.theme = r);
|
|
435
441
|
const h = t == null ? void 0 : t.dataset.colors;
|
|
436
442
|
if (h)
|
|
437
443
|
try {
|
|
438
444
|
const u = JSON.parse(h);
|
|
439
|
-
u && typeof u == "object" && (
|
|
445
|
+
u && typeof u == "object" && (n.colors = u);
|
|
440
446
|
} catch {
|
|
441
447
|
console.warn("Upstep: data-colors must be JSON");
|
|
442
448
|
}
|
|
443
449
|
const l = t == null ? void 0 : t.dataset.radius;
|
|
444
|
-
l && Number.isFinite(Number(l)) && (
|
|
450
|
+
l && Number.isFinite(Number(l)) && (n.radius = Number(l));
|
|
445
451
|
const b = t == null ? void 0 : t.dataset.fontFamily;
|
|
446
|
-
b && (
|
|
452
|
+
b && (n.fontFamily = b), w.init(n);
|
|
447
453
|
}
|
|
448
454
|
}
|
|
449
455
|
export {
|
|
450
456
|
f as UpstepApiClient,
|
|
451
457
|
x as buildWidgetPalette,
|
|
452
458
|
w as default,
|
|
453
|
-
|
|
459
|
+
M as readableTextOn
|
|
454
460
|
};
|