@upstep/js 0.9.0 → 0.11.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 +24 -0
- package/dist/index.cjs +59 -46
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +164 -137
- 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 +466 -421
- package/dist/support.cjs +1 -1
- package/dist/support.d.ts +10 -1
- package/dist/support.d.ts.map +1 -1
- package/dist/support.js +50 -33
- package/dist/upstep.global.js +27 -14
- package/dist/widget.d.ts +4 -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 x=require("./api-j3GMTEE7.js"),l=require("./theme.cjs");function y(
|
|
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,82 +9,95 @@
|
|
|
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:${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
|
+
.upstep-suggest:hover{border-color:${o}}
|
|
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
|
+
.upstep-hint button{background:none;border:none;padding:0;color:${o};font:inherit;font-weight:600;cursor:pointer}
|
|
34
39
|
#upstep-form-msg{font-size:14px;text-align:center;margin-top:12px;color:${o};font-weight:500}
|
|
35
|
-
.upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${
|
|
36
|
-
.upstep-feedback-item:hover{border-color:${
|
|
37
|
-
.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}
|
|
38
43
|
.upstep-vote:hover{border-color:${o}}
|
|
39
|
-
.upstep-vote.voted{border-color:${o};background:${
|
|
44
|
+
.upstep-vote.voted{border-color:${o};background:${e.accentTint}}
|
|
40
45
|
.upstep-vote-arrow{font-size:11px;line-height:1;color:${o}}
|
|
41
|
-
.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}
|
|
42
47
|
.upstep-feedback-main{flex:1;min-width:0}
|
|
43
|
-
.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}
|
|
44
49
|
.upstep-feedback-meta{display:flex;align-items:center;gap:7px}
|
|
45
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}
|
|
46
51
|
.upstep-badge-bug{background:#fdecec;color:#d6453d}
|
|
47
52
|
.upstep-badge-feature{background:#e9f0fd;color:#3b76d6}
|
|
48
|
-
.upstep-badge-general{background:${
|
|
49
|
-
.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}}
|
|
50
55
|
#upstep-btn{position:fixed}
|
|
51
|
-
.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)}
|
|
52
57
|
@keyframes upstep-pop{from{transform:scale(.4)}to{transform:scale(1)}}
|
|
53
|
-
#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)}
|
|
54
59
|
#upstep-toast b{font-size:12px}
|
|
55
|
-
#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}
|
|
56
61
|
#upstep-toast em{font-style:normal;font-size:11px;font-weight:600;color:${o}}
|
|
57
62
|
@media(prefers-reduced-motion:reduce){.upstep-unread,#upstep-toast{animation:none}}
|
|
58
|
-
.upstep-empty{text-align:center;color:${
|
|
59
|
-
.upstep-empty strong{display:block;color:${
|
|
60
|
-
`}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=`
|
|
61
66
|
<div id="upstep-modal" style="max-width:${this.hasSupport?"460px":"440px"}">
|
|
62
|
-
${this.hasSupport?`<div class="upstep-mode" style="display:flex;align-items:center;gap:14px;padding:
|
|
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>`}
|
|
63
68
|
<div id="upstep-body" style="${this.tab==="support"?"padding:0;overflow:hidden":""}">
|
|
64
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()}
|
|
65
70
|
</div>
|
|
66
71
|
</div>
|
|
67
|
-
`,(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
|
+
<div class="upstep-form">
|
|
74
|
+
<button class="upstep-back" data-goto="feed">← Ideas</button>
|
|
75
|
+
<textarea id="upstep-textarea" placeholder="What would you like us to build?" maxlength="2000"></textarea>
|
|
76
|
+
<button class="upstep-submit" id="upstep-submit-btn">Suggest idea</button>
|
|
77
|
+
<div id="upstep-form-msg"></div>
|
|
78
|
+
<p class="upstep-hint">Something not working? <button data-goto="support">Ask support</button></p>
|
|
79
|
+
</div>
|
|
80
|
+
`:`
|
|
68
81
|
<div class="upstep-form">
|
|
69
82
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
70
83
|
<div class="upstep-type-row">
|
|
71
|
-
${
|
|
84
|
+
${t.map(a=>`<button class="upstep-type-btn${this.selectedType===a?" selected":""}" data-type="${a}">${o[a]}${s[a]}</button>`).join("")}
|
|
72
85
|
</div>
|
|
73
86
|
<button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
|
|
74
87
|
<div id="upstep-form-msg"></div>
|
|
75
88
|
</div>
|
|
76
|
-
`}renderFeed(){return this.feedItems.length?this.feedItems.map(
|
|
77
|
-
<div class="upstep-feedback-item" data-id="${
|
|
78
|
-
<button class="upstep-vote${
|
|
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
|
+
<div class="upstep-feedback-item" data-id="${s.id}">
|
|
91
|
+
<button class="upstep-vote${s.userVote==="UP"?" voted":""}" data-vote="UP" data-feedback="${s.id}">
|
|
79
92
|
<span class="upstep-vote-arrow">▲</span>
|
|
80
|
-
<span class="upstep-vote-count">${
|
|
93
|
+
<span class="upstep-vote-count">${s.upvotes}</span>
|
|
81
94
|
</button>
|
|
82
95
|
<div class="upstep-feedback-main">
|
|
83
|
-
<p class="upstep-feedback-content">${h(
|
|
96
|
+
<p class="upstep-feedback-content">${h(s.content)}</p>
|
|
84
97
|
<div class="upstep-feedback-meta">
|
|
85
|
-
<span class="upstep-badge upstep-badge-${
|
|
86
|
-
<span class="upstep-badge upstep-badge-general">${h(((s
|
|
87
|
-
<span class="upstep-feedback-date">${new Date(
|
|
98
|
+
<span class="upstep-badge upstep-badge-${s.type.toLowerCase()}">${s.type}</span>
|
|
99
|
+
<span class="upstep-badge upstep-badge-general">${h(((o=s.boardStatus)==null?void 0:o.name)??s.status.replace("_"," "))}</span>
|
|
100
|
+
<span class="upstep-feedback-date">${new Date(s.createdAt).toLocaleDateString()}</span>
|
|
88
101
|
</div>
|
|
89
102
|
</div>
|
|
90
|
-
</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"}
|