@upstep/js 0.5.5 → 0.5.7
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/dist/index.cjs +37 -37
- package/dist/index.js +130 -96
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +27 -25
- package/dist/widget.d.ts +2 -0
- package/dist/widget.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
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 x=require("./api-BvhrcMKU.js"),w="#D97757",$={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},M={bg:"#1c1b19",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function E(o){return o==="light"||o==="dark"?o:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function L(o,e,t){return`
|
|
2
2
|
#upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
|
|
3
|
-
#upstep-btn{position:fixed;bottom:24px;${
|
|
3
|
+
#upstep-btn{position:fixed;bottom:24px;${e==="left"?"left:24px":"right:24px"};z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${o};color:#fff;border:none;border-radius:9999px;padding:12px 18px;font-size:14px;font-weight:600;cursor:grab;touch-action:none;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
|
|
4
4
|
#upstep-btn svg{width:16px;height:16px;flex-shrink:0}
|
|
5
5
|
#upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
|
|
6
|
-
#upstep-btn
|
|
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
7
|
@media(max-width:639px){#upstep-btn{padding:12px}#upstep-btn span{display:none}}
|
|
8
|
-
#upstep-backdrop{position:fixed;inset:0;background:${
|
|
8
|
+
#upstep-backdrop{position:fixed;inset:0;background:${t.overlay};backdrop-filter:blur(3px);z-index:9999;display:flex;align-items:center;justify-content:center;padding:16px;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:${t.bg};border:1px solid ${t.border};border-radius:20px;width:100%;max-width:440px;max-height:88vh;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:12.5px;color:${
|
|
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:13px;font-weight:600;color:${
|
|
19
|
-
.upstep-tab.active{background:${
|
|
13
|
+
#upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${t.text};letter-spacing:-.01em}
|
|
14
|
+
#upstep-header p{margin:2px 0 0;font-size:12.5px;color:${t.textFaint}}
|
|
15
|
+
#upstep-close{background:${t.bgSoft};border:none;width:28px;height:28px;border-radius:8px;font-size:14px;cursor:pointer;color:${t.textSoft};line-height:1;display:flex;align-items:center;justify-content:center;transition:background .15s}
|
|
16
|
+
#upstep-close:hover{background:${t.bgHover};color:${t.text}}
|
|
17
|
+
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${t.bgSoft};border-radius:11px}
|
|
18
|
+
.upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:8px;font-size:13px;font-weight:600;color:${t.textSoft};cursor:pointer;transition:all .15s}
|
|
19
|
+
.upstep-tab.active{background:${t.bg};color:${t.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
|
|
20
20
|
#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:${
|
|
21
|
+
.upstep-form textarea{width:100%;min-height:104px;border:1px solid ${t.border};border-radius:12px;padding:12px;font-size:14px;line-height:1.5;resize:vertical;outline:none;background:${t.bgSoft};color:${t.text};transition:border-color .15s}
|
|
22
|
+
.upstep-form textarea::placeholder{color:${t.textFaint}}
|
|
23
|
+
.upstep-form textarea:focus{border-color:${o};background:${t.bg}}
|
|
24
24
|
.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 ${
|
|
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 ${t.border};background:${t.bg};color:${t.textSoft};font-size:12.5px;font-weight:600;cursor:pointer;transition:all .15s}
|
|
26
26
|
.upstep-type-btn svg{width:12px;height:12px;flex-shrink:0}
|
|
27
|
-
.upstep-type-btn:hover{border-color:${
|
|
27
|
+
.upstep-type-btn:hover{border-color:${t.textFaint}}
|
|
28
28
|
.upstep-type-btn.selected{background:${o};color:#fff;border-color:${o}}
|
|
29
29
|
.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
30
|
.upstep-submit:hover{filter:brightness(.94)}
|
|
31
31
|
.upstep-submit:disabled{opacity:.5;cursor:not-allowed}
|
|
32
32
|
#upstep-form-msg{font-size:13px;text-align:center;margin-top:12px;color:${o};font-weight:500}
|
|
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-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${t.border};border-radius:14px;margin-bottom:10px;background:${t.bg};transition:border-color .15s}
|
|
34
|
+
.upstep-feedback-item:hover{border-color:${t.textFaint}}
|
|
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 ${t.border};background:${t.bgSoft};cursor:pointer;transition:all .15s}
|
|
36
36
|
.upstep-vote:hover{border-color:${o}}
|
|
37
37
|
.upstep-vote.voted{border-color:${o};background:${o}1a}
|
|
38
38
|
.upstep-vote-arrow{font-size:11px;line-height:1;color:${o}}
|
|
39
|
-
.upstep-vote-count{font-size:14px;font-weight:700;color:${
|
|
39
|
+
.upstep-vote-count{font-size:14px;font-weight:700;color:${t.text};line-height:1.1}
|
|
40
40
|
.upstep-feedback-main{flex:1;min-width:0}
|
|
41
|
-
.upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${
|
|
41
|
+
.upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${t.text};margin:0 0 8px;word-break:break-word}
|
|
42
42
|
.upstep-feedback-meta{display:flex;align-items:center;gap:7px}
|
|
43
43
|
.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
44
|
.upstep-badge-bug{background:#fdecec;color:#d6453d}
|
|
45
45
|
.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
|
|
46
|
+
.upstep-badge-general{background:${t.bgSoft};color:${t.textSoft}}
|
|
47
|
+
.upstep-feedback-date{font-size:11px;color:${t.textFaint}}
|
|
48
|
+
.upstep-empty{text-align:center;color:${t.textFaint};font-size:14px;padding:40px 0}
|
|
49
|
+
.upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
|
|
50
|
+
`}const S='<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 C{constructor(e,t={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.dragMoved=!1,this.client=e,this.accent=t.accentColor??w,this.position=t.position??"right",this.showLauncher=t.launcher!==!1,this.palette=E(t.theme??"auto")==="dark"?M:$}mount(){this.injectStyles(),this.showLauncher&&this.renderButton()}openWidget(){this.openModal()}closeWidget(){this.closeModal()}injectStyles(){var t;(t=document.getElementById("upstep-styles"))==null||t.remove();const e=document.createElement("style");e.id="upstep-styles",e.textContent=L(this.accent,this.position,this.palette),document.head.appendChild(e)}renderButton(){const e=document.createElement("button");e.id="upstep-btn",e.innerHTML=`${S}<span>Feedback</span>`,e.addEventListener("click",()=>{this.dragMoved||this.openModal()}),document.body.appendChild(e),this.makeDraggable(e)}makeDraggable(e){const s="upstep-btn-pos";try{const i=localStorage.getItem(s);if(i){const{side:a,bottom:u}=JSON.parse(i);e.style.left=a==="left"?"24px":"auto",e.style.right=a==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${u}px`}}catch{}let r=0,c=0,d=0,f=0,b=!1;const y=()=>{const i=e.getBoundingClientRect(),a=i.left+i.width/2<window.innerWidth/2?"left":"right",u=Math.max(24,Math.min(window.innerHeight-i.height-24,i.top)),g=window.innerHeight-u-i.height;e.style.transition="left .25s cubic-bezier(.16,1,.3,1),right .25s cubic-bezier(.16,1,.3,1),top .25s cubic-bezier(.16,1,.3,1),bottom .25s cubic-bezier(.16,1,.3,1),transform .15s,box-shadow .15s",e.style.left=a==="left"?"24px":"auto",e.style.right=a==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${g}px`;try{localStorage.setItem(s,JSON.stringify({side:a,bottom:g}))}catch{}},v=i=>{if(i.pointerType==="mouse"&&i.button!==0)return;this.dragMoved=!1,b=!0;const a=e.getBoundingClientRect();r=i.clientX,c=i.clientY,d=a.left,f=a.top,e.setPointerCapture(i.pointerId),e.style.transition="none"},k=i=>{if(!b)return;const a=i.clientX-r,u=i.clientY-c;!this.dragMoved&&Math.hypot(a,u)<6||(this.dragMoved||e.classList.add("upstep-dragging"),this.dragMoved=!0,e.style.left=`${d+a}px`,e.style.right="auto",e.style.top=`${f+u}px`,e.style.bottom="auto")},h=()=>{b&&(b=!1,e.classList.remove("upstep-dragging"),this.dragMoved&&y())};e.addEventListener("pointerdown",v),e.addEventListener("pointermove",k),e.addEventListener("pointerup",h),e.addEventListener("pointercancel",h)}openModal(){this.isOpen=!0,this.fetchFeed(),this.renderModal()}closeModal(){var e;this.isOpen=!1,(e=document.getElementById("upstep-backdrop"))==null||e.remove()}async fetchFeed(){try{const e=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=e.items,this.renderFeedList()}catch{}}renderModal(){var t,n;const e=document.createElement("div");e.id="upstep-backdrop",e.addEventListener("click",s=>{s.target===e&&this.closeModal()}),e.innerHTML=`
|
|
51
51
|
<div id="upstep-modal">
|
|
52
52
|
<div id="upstep-header">
|
|
53
53
|
<div>
|
|
@@ -64,26 +64,26 @@
|
|
|
64
64
|
${this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
65
65
|
</div>
|
|
66
66
|
</div>
|
|
67
|
-
`,(
|
|
67
|
+
`,(t=document.getElementById("upstep-backdrop"))==null||t.remove(),document.body.appendChild(e),(n=e.querySelector("#upstep-close"))==null||n.addEventListener("click",()=>this.closeModal()),e.querySelectorAll(".upstep-tab").forEach(s=>{s.addEventListener("click",()=>{this.tab=s.dataset.tab,this.renderModal()})}),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const e=["BUG","FEATURE","GENERAL"],t={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},n={BUG:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="8" cy="10" rx="3.5" ry="4.5"/><path d="M8 5.5V4M5.5 6.5 3.5 5M10.5 6.5 12.5 5M4.5 10.5 2.5 10M11.5 10.5 13.5 10"/></svg>',FEATURE:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.1 4.1l1 1M10.9 10.9l1 1M11.9 4.1l-1 1M5.1 10.9l-1 1"/><circle cx="8" cy="8" r="2.5"/></svg>',GENERAL:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"/></svg>'};return`
|
|
68
68
|
<div class="upstep-form">
|
|
69
69
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
70
70
|
<div class="upstep-type-row">
|
|
71
|
-
${
|
|
71
|
+
${e.map(s=>`<button class="upstep-type-btn${this.selectedType===s?" selected":""}" data-type="${s}">${n[s]}${t[s]}</button>`).join("")}
|
|
72
72
|
</div>
|
|
73
73
|
<button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
|
|
74
74
|
<div id="upstep-form-msg"></div>
|
|
75
75
|
</div>
|
|
76
|
-
`}renderFeed(){return this.feedItems.length?this.feedItems.map(
|
|
77
|
-
<div class="upstep-feedback-item" data-id="${
|
|
78
|
-
<button class="upstep-vote${
|
|
76
|
+
`}renderFeed(){return this.feedItems.length?this.feedItems.map(e=>`
|
|
77
|
+
<div class="upstep-feedback-item" data-id="${e.id}">
|
|
78
|
+
<button class="upstep-vote${e.userVote==="UP"?" voted":""}" data-vote="UP" data-feedback="${e.id}">
|
|
79
79
|
<span class="upstep-vote-arrow">▲</span>
|
|
80
|
-
<span class="upstep-vote-count">${
|
|
80
|
+
<span class="upstep-vote-count">${e.upvotes}</span>
|
|
81
81
|
</button>
|
|
82
82
|
<div class="upstep-feedback-main">
|
|
83
|
-
<p class="upstep-feedback-content">${
|
|
83
|
+
<p class="upstep-feedback-content">${F(e.content)}</p>
|
|
84
84
|
<div class="upstep-feedback-meta">
|
|
85
|
-
<span class="upstep-badge upstep-badge-${
|
|
86
|
-
<span class="upstep-feedback-date">${new Date(
|
|
85
|
+
<span class="upstep-badge upstep-badge-${e.type.toLowerCase()}">${e.type}</span>
|
|
86
|
+
<span class="upstep-feedback-date">${new Date(e.createdAt).toLocaleDateString()}</span>
|
|
87
87
|
</div>
|
|
88
88
|
</div>
|
|
89
|
-
</div>`).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const
|
|
89
|
+
</div>`).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const e=document.getElementById("upstep-body");!e||this.tab!=="feed"||(e.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var e;document.querySelectorAll(".upstep-type-btn").forEach(t=>{t.addEventListener("click",()=>{this.selectedType=t.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(n=>n.classList.remove("selected")),t.classList.add("selected")})}),(e=document.getElementById("upstep-submit-btn"))==null||e.addEventListener("click",async()=>{const t=document.getElementById("upstep-textarea"),n=document.getElementById("upstep-form-msg"),s=document.getElementById("upstep-submit-btn");if(!t||this.loading)return;const r=t.value.trim();if(r){this.loading=!0,s&&(s.disabled=!0,s.textContent="Sending…");try{await this.client.submitFeedback({content:r,type:this.selectedType}),t.value="",n&&(n.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{n&&(n.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,s&&(s.disabled=!1,s.textContent="Send feedback")}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote").forEach(e=>{e.addEventListener("click",async()=>{const t=e.dataset.feedback;try{await this.client.vote(t,"UP"),await this.fetchFeed()}catch{}})})}}function F(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let p=null,l=null;const m={init(o){if(p=new x.UpstepApiClient(o),typeof window<"u"){const e={};o.accentColor!==void 0&&(e.accentColor=o.accentColor),o.position!==void 0&&(e.position=o.position),o.theme!==void 0&&(e.theme=o.theme),o.launcher!==void 0&&(e.launcher=o.launcher);const t=()=>{l=new C(p,e),l.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}return p},open(){l==null||l.openWidget()},close(){l==null||l.closeWidget()},identify(o){p==null||p.setUserId(o)},get client(){if(!p)throw new Error("Upstep.init() must be called first");return p}};if(typeof document<"u"){const o=document.currentScript,e=o==null?void 0:o.dataset.apiKey,t=o==null?void 0:o.dataset.userId,n=o==null?void 0:o.dataset.baseUrl,s=o==null?void 0:o.dataset.accentColor,r=o==null?void 0:o.dataset.position,c=o==null?void 0:o.dataset.theme;if(e){const d={apiKey:e};t&&(d.userId=t),n&&(d.baseUrl=n),s&&(d.accentColor=s),(r==="left"||r==="right")&&(d.position=r),(c==="light"||c==="dark"||c==="auto")&&(d.theme=c),m.init(d)}}exports.UpstepApiClient=x.UpstepApiClient;exports.default=m;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { U as
|
|
2
|
-
const
|
|
1
|
+
import { U as v } from "./api-B-umoNRf.mjs";
|
|
2
|
+
const k = "#D97757", w = {
|
|
3
3
|
bg: "#ffffff",
|
|
4
4
|
bgSoft: "#f6f5f2",
|
|
5
5
|
bgHover: "#efede8",
|
|
@@ -8,7 +8,7 @@ const c = "#D97757", u = {
|
|
|
8
8
|
textFaint: "#9b9890",
|
|
9
9
|
border: "#e8e6df",
|
|
10
10
|
overlay: "rgba(26,25,21,.45)"
|
|
11
|
-
},
|
|
11
|
+
}, $ = {
|
|
12
12
|
bg: "#1c1b19",
|
|
13
13
|
bgSoft: "#262522",
|
|
14
14
|
bgHover: "#302e2a",
|
|
@@ -18,65 +18,65 @@ const c = "#D97757", u = {
|
|
|
18
18
|
border: "#33312c",
|
|
19
19
|
overlay: "rgba(0,0,0,.6)"
|
|
20
20
|
};
|
|
21
|
-
function
|
|
21
|
+
function M(o) {
|
|
22
22
|
return o === "light" || o === "dark" ? o : typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function E(o, e, t) {
|
|
25
25
|
return `
|
|
26
26
|
#upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
|
|
27
|
-
#upstep-btn{position:fixed;bottom:24px;${
|
|
27
|
+
#upstep-btn{position:fixed;bottom:24px;${e === "left" ? "left:24px" : "right:24px"};z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${o};color:#fff;border:none;border-radius:9999px;padding:12px 18px;font-size:14px;font-weight:600;cursor:grab;touch-action:none;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
|
|
28
28
|
#upstep-btn svg{width:16px;height:16px;flex-shrink:0}
|
|
29
29
|
#upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
|
|
30
|
-
#upstep-btn
|
|
30
|
+
#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}
|
|
31
31
|
@media(max-width:639px){#upstep-btn{padding:12px}#upstep-btn span{display:none}}
|
|
32
|
-
#upstep-backdrop{position:fixed;inset:0;background:${
|
|
32
|
+
#upstep-backdrop{position:fixed;inset:0;background:${t.overlay};backdrop-filter:blur(3px);z-index:9999;display:flex;align-items:center;justify-content:center;padding:16px;animation:upstep-fade .2s ease}
|
|
33
33
|
@keyframes upstep-fade{from{opacity:0}to{opacity:1}}
|
|
34
34
|
@keyframes upstep-rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:translateY(0)}}
|
|
35
|
-
#upstep-modal{background:${
|
|
35
|
+
#upstep-modal{background:${t.bg};border:1px solid ${t.border};border-radius:20px;width:100%;max-width:440px;max-height:88vh;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)}
|
|
36
36
|
#upstep-header{display:flex;align-items:flex-start;justify-content:space-between;padding:20px 20px 0}
|
|
37
|
-
#upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${
|
|
38
|
-
#upstep-header p{margin:2px 0 0;font-size:12.5px;color:${
|
|
39
|
-
#upstep-close{background:${
|
|
40
|
-
#upstep-close:hover{background:${
|
|
41
|
-
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${
|
|
42
|
-
.upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:8px;font-size:13px;font-weight:600;color:${
|
|
43
|
-
.upstep-tab.active{background:${
|
|
37
|
+
#upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${t.text};letter-spacing:-.01em}
|
|
38
|
+
#upstep-header p{margin:2px 0 0;font-size:12.5px;color:${t.textFaint}}
|
|
39
|
+
#upstep-close{background:${t.bgSoft};border:none;width:28px;height:28px;border-radius:8px;font-size:14px;cursor:pointer;color:${t.textSoft};line-height:1;display:flex;align-items:center;justify-content:center;transition:background .15s}
|
|
40
|
+
#upstep-close:hover{background:${t.bgHover};color:${t.text}}
|
|
41
|
+
#upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${t.bgSoft};border-radius:11px}
|
|
42
|
+
.upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:8px;font-size:13px;font-weight:600;color:${t.textSoft};cursor:pointer;transition:all .15s}
|
|
43
|
+
.upstep-tab.active{background:${t.bg};color:${t.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
|
|
44
44
|
#upstep-body{flex:1;overflow-y:auto;padding:18px 20px 22px}
|
|
45
|
-
.upstep-form textarea{width:100%;min-height:104px;border:1px solid ${
|
|
46
|
-
.upstep-form textarea::placeholder{color:${
|
|
47
|
-
.upstep-form textarea:focus{border-color:${o};background:${
|
|
45
|
+
.upstep-form textarea{width:100%;min-height:104px;border:1px solid ${t.border};border-radius:12px;padding:12px;font-size:14px;line-height:1.5;resize:vertical;outline:none;background:${t.bgSoft};color:${t.text};transition:border-color .15s}
|
|
46
|
+
.upstep-form textarea::placeholder{color:${t.textFaint}}
|
|
47
|
+
.upstep-form textarea:focus{border-color:${o};background:${t.bg}}
|
|
48
48
|
.upstep-type-row{display:flex;gap:7px;margin:12px 0 4px}
|
|
49
|
-
.upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:9px;border:1px solid ${
|
|
49
|
+
.upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:9px;border:1px solid ${t.border};background:${t.bg};color:${t.textSoft};font-size:12.5px;font-weight:600;cursor:pointer;transition:all .15s}
|
|
50
50
|
.upstep-type-btn svg{width:12px;height:12px;flex-shrink:0}
|
|
51
|
-
.upstep-type-btn:hover{border-color:${
|
|
51
|
+
.upstep-type-btn:hover{border-color:${t.textFaint}}
|
|
52
52
|
.upstep-type-btn.selected{background:${o};color:#fff;border-color:${o}}
|
|
53
53
|
.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}
|
|
54
54
|
.upstep-submit:hover{filter:brightness(.94)}
|
|
55
55
|
.upstep-submit:disabled{opacity:.5;cursor:not-allowed}
|
|
56
56
|
#upstep-form-msg{font-size:13px;text-align:center;margin-top:12px;color:${o};font-weight:500}
|
|
57
|
-
.upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${
|
|
58
|
-
.upstep-feedback-item:hover{border-color:${
|
|
59
|
-
.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 ${
|
|
57
|
+
.upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${t.border};border-radius:14px;margin-bottom:10px;background:${t.bg};transition:border-color .15s}
|
|
58
|
+
.upstep-feedback-item:hover{border-color:${t.textFaint}}
|
|
59
|
+
.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 ${t.border};background:${t.bgSoft};cursor:pointer;transition:all .15s}
|
|
60
60
|
.upstep-vote:hover{border-color:${o}}
|
|
61
61
|
.upstep-vote.voted{border-color:${o};background:${o}1a}
|
|
62
62
|
.upstep-vote-arrow{font-size:11px;line-height:1;color:${o}}
|
|
63
|
-
.upstep-vote-count{font-size:14px;font-weight:700;color:${
|
|
63
|
+
.upstep-vote-count{font-size:14px;font-weight:700;color:${t.text};line-height:1.1}
|
|
64
64
|
.upstep-feedback-main{flex:1;min-width:0}
|
|
65
|
-
.upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${
|
|
65
|
+
.upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${t.text};margin:0 0 8px;word-break:break-word}
|
|
66
66
|
.upstep-feedback-meta{display:flex;align-items:center;gap:7px}
|
|
67
67
|
.upstep-badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:9999px;font-size:10.5px;font-weight:700;letter-spacing:.02em}
|
|
68
68
|
.upstep-badge-bug{background:#fdecec;color:#d6453d}
|
|
69
69
|
.upstep-badge-feature{background:#e9f0fd;color:#3b76d6}
|
|
70
|
-
.upstep-badge-general{background:${
|
|
71
|
-
.upstep-feedback-date{font-size:11px;color:${
|
|
72
|
-
.upstep-empty{text-align:center;color:${
|
|
73
|
-
.upstep-empty strong{display:block;color:${
|
|
70
|
+
.upstep-badge-general{background:${t.bgSoft};color:${t.textSoft}}
|
|
71
|
+
.upstep-feedback-date{font-size:11px;color:${t.textFaint}}
|
|
72
|
+
.upstep-empty{text-align:center;color:${t.textFaint};font-size:14px;padding:40px 0}
|
|
73
|
+
.upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
|
|
74
74
|
`;
|
|
75
75
|
}
|
|
76
|
-
const
|
|
77
|
-
class
|
|
78
|
-
constructor(
|
|
79
|
-
this.isOpen = !1, this.tab = "submit", this.feedItems = [], this.selectedType = "GENERAL", this.loading = !1, this.client =
|
|
76
|
+
const L = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';
|
|
77
|
+
class F {
|
|
78
|
+
constructor(e, t = {}) {
|
|
79
|
+
this.isOpen = !1, this.tab = "submit", this.feedItems = [], this.selectedType = "GENERAL", this.loading = !1, this.dragMoved = !1, this.client = e, this.accent = t.accentColor ?? k, this.position = t.position ?? "right", this.showLauncher = t.launcher !== !1, this.palette = M(t.theme ?? "auto") === "dark" ? $ : w;
|
|
80
80
|
}
|
|
81
81
|
mount() {
|
|
82
82
|
this.injectStyles(), this.showLauncher && this.renderButton();
|
|
@@ -90,35 +90,69 @@ class g {
|
|
|
90
90
|
this.closeModal();
|
|
91
91
|
}
|
|
92
92
|
injectStyles() {
|
|
93
|
-
var
|
|
94
|
-
(
|
|
95
|
-
const
|
|
96
|
-
|
|
93
|
+
var t;
|
|
94
|
+
(t = document.getElementById("upstep-styles")) == null || t.remove();
|
|
95
|
+
const e = document.createElement("style");
|
|
96
|
+
e.id = "upstep-styles", e.textContent = E(this.accent, this.position, this.palette), document.head.appendChild(e);
|
|
97
97
|
}
|
|
98
98
|
renderButton() {
|
|
99
|
-
const
|
|
100
|
-
|
|
99
|
+
const e = document.createElement("button");
|
|
100
|
+
e.id = "upstep-btn", e.innerHTML = `${L}<span>Feedback</span>`, e.addEventListener("click", () => {
|
|
101
|
+
this.dragMoved || this.openModal();
|
|
102
|
+
}), document.body.appendChild(e), this.makeDraggable(e);
|
|
103
|
+
}
|
|
104
|
+
makeDraggable(e) {
|
|
105
|
+
const s = "upstep-btn-pos";
|
|
106
|
+
try {
|
|
107
|
+
const i = localStorage.getItem(s);
|
|
108
|
+
if (i) {
|
|
109
|
+
const { side: a, bottom: u } = JSON.parse(i);
|
|
110
|
+
e.style.left = a === "left" ? "24px" : "auto", e.style.right = a === "right" ? "24px" : "auto", e.style.top = "auto", e.style.bottom = `${u}px`;
|
|
111
|
+
}
|
|
112
|
+
} catch {
|
|
113
|
+
}
|
|
114
|
+
let r = 0, c = 0, d = 0, f = 0, b = !1;
|
|
115
|
+
const x = () => {
|
|
116
|
+
const i = e.getBoundingClientRect(), a = i.left + i.width / 2 < window.innerWidth / 2 ? "left" : "right", u = Math.max(24, Math.min(window.innerHeight - i.height - 24, i.top)), g = window.innerHeight - u - i.height;
|
|
117
|
+
e.style.transition = "left .25s cubic-bezier(.16,1,.3,1),right .25s cubic-bezier(.16,1,.3,1),top .25s cubic-bezier(.16,1,.3,1),bottom .25s cubic-bezier(.16,1,.3,1),transform .15s,box-shadow .15s", e.style.left = a === "left" ? "24px" : "auto", e.style.right = a === "right" ? "24px" : "auto", e.style.top = "auto", e.style.bottom = `${g}px`;
|
|
118
|
+
try {
|
|
119
|
+
localStorage.setItem(s, JSON.stringify({ side: a, bottom: g }));
|
|
120
|
+
} catch {
|
|
121
|
+
}
|
|
122
|
+
}, m = (i) => {
|
|
123
|
+
if (i.pointerType === "mouse" && i.button !== 0) return;
|
|
124
|
+
this.dragMoved = !1, b = !0;
|
|
125
|
+
const a = e.getBoundingClientRect();
|
|
126
|
+
r = i.clientX, c = i.clientY, d = a.left, f = a.top, e.setPointerCapture(i.pointerId), e.style.transition = "none";
|
|
127
|
+
}, y = (i) => {
|
|
128
|
+
if (!b) return;
|
|
129
|
+
const a = i.clientX - r, u = i.clientY - c;
|
|
130
|
+
!this.dragMoved && Math.hypot(a, u) < 6 || (this.dragMoved || e.classList.add("upstep-dragging"), this.dragMoved = !0, e.style.left = `${d + a}px`, e.style.right = "auto", e.style.top = `${f + u}px`, e.style.bottom = "auto");
|
|
131
|
+
}, h = () => {
|
|
132
|
+
b && (b = !1, e.classList.remove("upstep-dragging"), this.dragMoved && x());
|
|
133
|
+
};
|
|
134
|
+
e.addEventListener("pointerdown", m), e.addEventListener("pointermove", y), e.addEventListener("pointerup", h), e.addEventListener("pointercancel", h);
|
|
101
135
|
}
|
|
102
136
|
openModal() {
|
|
103
137
|
this.isOpen = !0, this.fetchFeed(), this.renderModal();
|
|
104
138
|
}
|
|
105
139
|
closeModal() {
|
|
106
|
-
var
|
|
107
|
-
this.isOpen = !1, (
|
|
140
|
+
var e;
|
|
141
|
+
this.isOpen = !1, (e = document.getElementById("upstep-backdrop")) == null || e.remove();
|
|
108
142
|
}
|
|
109
143
|
async fetchFeed() {
|
|
110
144
|
try {
|
|
111
|
-
const
|
|
112
|
-
this.feedItems =
|
|
145
|
+
const e = await this.client.listFeedback({ sort: "votes", limit: 20 });
|
|
146
|
+
this.feedItems = e.items, this.renderFeedList();
|
|
113
147
|
} catch {
|
|
114
148
|
}
|
|
115
149
|
}
|
|
116
150
|
renderModal() {
|
|
117
|
-
var
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
s.target ===
|
|
121
|
-
}),
|
|
151
|
+
var t, n;
|
|
152
|
+
const e = document.createElement("div");
|
|
153
|
+
e.id = "upstep-backdrop", e.addEventListener("click", (s) => {
|
|
154
|
+
s.target === e && this.closeModal();
|
|
155
|
+
}), e.innerHTML = `
|
|
122
156
|
<div id="upstep-modal">
|
|
123
157
|
<div id="upstep-header">
|
|
124
158
|
<div>
|
|
@@ -135,14 +169,14 @@ class g {
|
|
|
135
169
|
${this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
|
|
136
170
|
</div>
|
|
137
171
|
</div>
|
|
138
|
-
`, (
|
|
172
|
+
`, (t = document.getElementById("upstep-backdrop")) == null || t.remove(), document.body.appendChild(e), (n = e.querySelector("#upstep-close")) == null || n.addEventListener("click", () => this.closeModal()), e.querySelectorAll(".upstep-tab").forEach((s) => {
|
|
139
173
|
s.addEventListener("click", () => {
|
|
140
174
|
this.tab = s.dataset.tab, this.renderModal();
|
|
141
175
|
});
|
|
142
176
|
}), this.bindSubmitForm(), this.bindVoteButtons();
|
|
143
177
|
}
|
|
144
178
|
renderSubmitForm() {
|
|
145
|
-
const
|
|
179
|
+
const e = ["BUG", "FEATURE", "GENERAL"], t = { BUG: "Bug", FEATURE: "Feature", GENERAL: "General" }, n = {
|
|
146
180
|
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>',
|
|
147
181
|
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>',
|
|
148
182
|
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>'
|
|
@@ -151,7 +185,7 @@ class g {
|
|
|
151
185
|
<div class="upstep-form">
|
|
152
186
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
153
187
|
<div class="upstep-type-row">
|
|
154
|
-
${
|
|
188
|
+
${e.map((s) => `<button class="upstep-type-btn${this.selectedType === s ? " selected" : ""}" data-type="${s}">${n[s]}${t[s]}</button>`).join("")}
|
|
155
189
|
</div>
|
|
156
190
|
<button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
|
|
157
191
|
<div id="upstep-form-msg"></div>
|
|
@@ -160,42 +194,42 @@ class g {
|
|
|
160
194
|
}
|
|
161
195
|
renderFeed() {
|
|
162
196
|
return this.feedItems.length ? this.feedItems.map(
|
|
163
|
-
(
|
|
164
|
-
<div class="upstep-feedback-item" data-id="${
|
|
165
|
-
<button class="upstep-vote${
|
|
197
|
+
(e) => `
|
|
198
|
+
<div class="upstep-feedback-item" data-id="${e.id}">
|
|
199
|
+
<button class="upstep-vote${e.userVote === "UP" ? " voted" : ""}" data-vote="UP" data-feedback="${e.id}">
|
|
166
200
|
<span class="upstep-vote-arrow">▲</span>
|
|
167
|
-
<span class="upstep-vote-count">${
|
|
201
|
+
<span class="upstep-vote-count">${e.upvotes}</span>
|
|
168
202
|
</button>
|
|
169
203
|
<div class="upstep-feedback-main">
|
|
170
|
-
<p class="upstep-feedback-content">${
|
|
204
|
+
<p class="upstep-feedback-content">${S(e.content)}</p>
|
|
171
205
|
<div class="upstep-feedback-meta">
|
|
172
|
-
<span class="upstep-badge upstep-badge-${
|
|
173
|
-
<span class="upstep-feedback-date">${new Date(
|
|
206
|
+
<span class="upstep-badge upstep-badge-${e.type.toLowerCase()}">${e.type}</span>
|
|
207
|
+
<span class="upstep-feedback-date">${new Date(e.createdAt).toLocaleDateString()}</span>
|
|
174
208
|
</div>
|
|
175
209
|
</div>
|
|
176
210
|
</div>`
|
|
177
211
|
).join("") : '<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>';
|
|
178
212
|
}
|
|
179
213
|
renderFeedList() {
|
|
180
|
-
const
|
|
181
|
-
!
|
|
214
|
+
const e = document.getElementById("upstep-body");
|
|
215
|
+
!e || this.tab !== "feed" || (e.innerHTML = this.renderFeed(), this.bindVoteButtons());
|
|
182
216
|
}
|
|
183
217
|
bindSubmitForm() {
|
|
184
|
-
var
|
|
185
|
-
document.querySelectorAll(".upstep-type-btn").forEach((
|
|
186
|
-
|
|
187
|
-
this.selectedType =
|
|
218
|
+
var e;
|
|
219
|
+
document.querySelectorAll(".upstep-type-btn").forEach((t) => {
|
|
220
|
+
t.addEventListener("click", () => {
|
|
221
|
+
this.selectedType = t.dataset.type, document.querySelectorAll(".upstep-type-btn").forEach((n) => n.classList.remove("selected")), t.classList.add("selected");
|
|
188
222
|
});
|
|
189
|
-
}), (
|
|
190
|
-
const
|
|
191
|
-
if (!
|
|
192
|
-
const r =
|
|
223
|
+
}), (e = document.getElementById("upstep-submit-btn")) == null || e.addEventListener("click", async () => {
|
|
224
|
+
const t = document.getElementById("upstep-textarea"), n = document.getElementById("upstep-form-msg"), s = document.getElementById("upstep-submit-btn");
|
|
225
|
+
if (!t || this.loading) return;
|
|
226
|
+
const r = t.value.trim();
|
|
193
227
|
if (r) {
|
|
194
228
|
this.loading = !0, s && (s.disabled = !0, s.textContent = "Sending…");
|
|
195
229
|
try {
|
|
196
|
-
await this.client.submitFeedback({ content: r, type: this.selectedType }),
|
|
230
|
+
await this.client.submitFeedback({ content: r, type: this.selectedType }), t.value = "", n && (n.textContent = "Feedback received. Thank you."), await this.fetchFeed();
|
|
197
231
|
} catch {
|
|
198
|
-
|
|
232
|
+
n && (n.textContent = "Something went wrong. Please try again.");
|
|
199
233
|
} finally {
|
|
200
234
|
this.loading = !1, s && (s.disabled = !1, s.textContent = "Send feedback");
|
|
201
235
|
}
|
|
@@ -203,58 +237,58 @@ class g {
|
|
|
203
237
|
});
|
|
204
238
|
}
|
|
205
239
|
bindVoteButtons() {
|
|
206
|
-
document.querySelectorAll(".upstep-vote").forEach((
|
|
207
|
-
|
|
208
|
-
const
|
|
240
|
+
document.querySelectorAll(".upstep-vote").forEach((e) => {
|
|
241
|
+
e.addEventListener("click", async () => {
|
|
242
|
+
const t = e.dataset.feedback;
|
|
209
243
|
try {
|
|
210
|
-
await this.client.vote(
|
|
244
|
+
await this.client.vote(t, "UP"), await this.fetchFeed();
|
|
211
245
|
} catch {
|
|
212
246
|
}
|
|
213
247
|
});
|
|
214
248
|
});
|
|
215
249
|
}
|
|
216
250
|
}
|
|
217
|
-
function
|
|
251
|
+
function S(o) {
|
|
218
252
|
return o.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
219
253
|
}
|
|
220
|
-
let
|
|
221
|
-
const
|
|
254
|
+
let p = null, l = null;
|
|
255
|
+
const C = {
|
|
222
256
|
init(o) {
|
|
223
|
-
if (
|
|
224
|
-
const
|
|
225
|
-
o.accentColor !== void 0 && (
|
|
226
|
-
const
|
|
227
|
-
|
|
257
|
+
if (p = new v(o), typeof window < "u") {
|
|
258
|
+
const e = {};
|
|
259
|
+
o.accentColor !== void 0 && (e.accentColor = o.accentColor), o.position !== void 0 && (e.position = o.position), o.theme !== void 0 && (e.theme = o.theme), o.launcher !== void 0 && (e.launcher = o.launcher);
|
|
260
|
+
const t = () => {
|
|
261
|
+
l = new F(p, e), l.mount();
|
|
228
262
|
};
|
|
229
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
263
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : t();
|
|
230
264
|
}
|
|
231
|
-
return
|
|
265
|
+
return p;
|
|
232
266
|
},
|
|
233
267
|
/** Open the feedback widget — use this to trigger it from your own UI. */
|
|
234
268
|
open() {
|
|
235
|
-
|
|
269
|
+
l == null || l.openWidget();
|
|
236
270
|
},
|
|
237
271
|
/** Close the feedback widget. */
|
|
238
272
|
close() {
|
|
239
|
-
|
|
273
|
+
l == null || l.closeWidget();
|
|
240
274
|
},
|
|
241
275
|
/** Set / update the end-user id at runtime (e.g. after the user logs in). */
|
|
242
276
|
identify(o) {
|
|
243
|
-
|
|
277
|
+
p == null || p.setUserId(o);
|
|
244
278
|
},
|
|
245
279
|
get client() {
|
|
246
|
-
if (!
|
|
247
|
-
return
|
|
280
|
+
if (!p) throw new Error("Upstep.init() must be called first");
|
|
281
|
+
return p;
|
|
248
282
|
}
|
|
249
283
|
};
|
|
250
284
|
if (typeof document < "u") {
|
|
251
|
-
const o = document.currentScript,
|
|
252
|
-
if (
|
|
253
|
-
const d = { apiKey:
|
|
254
|
-
|
|
285
|
+
const o = document.currentScript, e = o == null ? void 0 : o.dataset.apiKey, t = o == null ? void 0 : o.dataset.userId, n = o == null ? void 0 : o.dataset.baseUrl, s = o == null ? void 0 : o.dataset.accentColor, r = o == null ? void 0 : o.dataset.position, c = o == null ? void 0 : o.dataset.theme;
|
|
286
|
+
if (e) {
|
|
287
|
+
const d = { apiKey: e };
|
|
288
|
+
t && (d.userId = t), n && (d.baseUrl = n), s && (d.accentColor = s), (r === "left" || r === "right") && (d.position = r), (c === "light" || c === "dark" || c === "auto") && (d.theme = c), C.init(d);
|
|
255
289
|
}
|
|
256
290
|
}
|
|
257
291
|
export {
|
|
258
|
-
|
|
259
|
-
|
|
292
|
+
v as UpstepApiClient,
|
|
293
|
+
C as default
|
|
260
294
|
};
|
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),L=require("./api-BvhrcMKU.js"),R="#D97757",M={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},D={bg:"#1c1b19",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function P(i){const[n,t]=r.useState(()=>i==="dark"?!0:i==="light"?!1:typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1);return r.useEffect(()=>{if(i!=="auto"||typeof window>"u"||!window.matchMedia){t(i==="dark");return}const f=window.matchMedia("(prefers-color-scheme: dark)"),u=s=>t(s.matches);return t(f.matches),f.addEventListener("change",u),()=>f.removeEventListener("change",u)},[i]),n?D:M}const F=r.createContext(null);function A({children:i,...n}){const[t]=r.useState(()=>new L.UpstepApiClient(n)),[f,u]=r.useState([]),[s,o]=r.useState(!1),[p,g]=r.useState(!0);r.useEffect(()=>{t.setUserId(n.userId)},[t,n.userId]);const l=r.useCallback(async()=>{try{const x=await t.listFeedback({sort:"votes",limit:20});u(x.items),g(x.showBranding??!0)}catch{}},[t]);r.useEffect(()=>{l()},[l]);const m=r.useCallback(async(x,S,h)=>{const d={content:S};x.trim()&&(d.title=x.trim()),h!==void 0&&(d.type=h),await t.submitFeedback(d),await l()},[t,l]),c=r.useCallback(async(x,S)=>{try{await t.vote(x,S),await l()}catch{}},[t,l]),a=r.useCallback(x=>t.getItem(x),[t]),b=r.useCallback(()=>o(!0),[]),k=r.useCallback(()=>o(!1),[]),y=r.useCallback(x=>t.setUserId(x),[t]);return e.jsx(F.Provider,{value:{client:t,feedItems:f,loadFeed:l,submit:m,vote:c,getItem:a,isOpen:s,open:b,close:k,identify:y,accentColor:n.accentColor??R,theme:n.theme??"auto",showBranding:p},children:i})}function v(){const i=r.useContext(F);if(!i)throw new Error("useUpstep must be used inside <UpstepProvider>");return i}function G({position:i="bottom-right",accentColor:n,theme:t,hideLauncher:f=!1}){const u=v(),s=n??u.accentColor,o=P(t??u.theme),{isOpen:p,open:g,close:l,showBranding:m}=u,[c,a]=r.useState("list"),[b,k]=r.useState(null),[y,x]=r.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:!1);r.useEffect(()=>{const j=window.matchMedia("(max-width: 639px)"),w=U=>x(U.matches);return j.addEventListener("change",w),()=>j.removeEventListener("change",w)},[]);const S=i==="bottom-left"?{position:"fixed",bottom:24,left:24}:{position:"fixed",bottom:24,right:24},h='-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';function d(){l(),setTimeout(()=>{a("list"),k(null)},300)}function T(j){k(j),a("detail")}return e.jsxs(e.Fragment,{children:[!f&&e.jsxs("button",{onClick:g,style:{...S,zIndex:9998,display:"inline-flex",alignItems:"center",gap:7,background:s,color:"#fff",border:"none",borderRadius:9999,padding:y?"12px":"12px 18px",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:h,boxShadow:"0 6px 20px rgba(26,25,21,.18)"},children:[e.jsx(Y,{size:16}),!y&&"Feedback"]}),p&&e.jsx("div",{onClick:j=>j.target===j.currentTarget&&d(),style:{position:"fixed",inset:0,background:o.overlay,backdropFilter:"blur(3px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:16,fontFamily:h},children:e.jsxs("div",{style:{background:o.bg,border:`1px solid ${o.border}`,borderRadius:20,width:"100%",maxWidth:440,maxHeight:"88vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 64px rgba(0,0,0,.28)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${o.border}`,flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c!=="list"&&e.jsx("button",{onClick:()=>a("list"),style:{background:"none",border:"none",cursor:"pointer",color:s,fontSize:13,fontWeight:600,padding:0},children:"← Back"}),c==="list"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:o.text,letterSpacing:"-.01em"},children:"Feedback"}),c==="create"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:o.text,letterSpacing:"-.01em"},children:"New feedback"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c==="list"&&e.jsx("button",{onClick:()=>a("create"),style:{background:s,color:"#fff",border:"none",borderRadius:20,padding:"6px 14px",fontSize:13,fontWeight:700,cursor:"pointer"},children:"+ New"}),e.jsx("button",{onClick:d,style:{background:o.bgSoft,border:"none",width:28,height:28,borderRadius:8,fontSize:14,cursor:"pointer",color:o.textSoft,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px 24px"},children:[c==="list"&&e.jsx(H,{onSelect:T,accent:s,p:o}),c==="detail"&&b&&e.jsx(N,{feedbackId:b,accent:s,p:o,font:h}),c==="create"&&e.jsx(O,{accent:s,p:o,font:h,onDone:()=>a("list")})]}),m&&e.jsxs("a",{href:"https://upstep.dev",target:"_blank",rel:"noopener noreferrer",style:{display:"block",textAlign:"center",padding:"8px 0",borderTop:`1px solid ${o.border}`,fontSize:11,color:o.textFaint,textDecoration:"none",flexShrink:0},children:["Powered by ",e.jsx("strong",{style:{fontWeight:700},children:"Upstep.dev"})]})]})})]})}function H({onSelect:i,accent:n,p:t}){const{feedItems:f,vote:u}=v(),s=f.filter(o=>o.status!=="CLOSED");return s.length?e.jsx(e.Fragment,{children:s.map(o=>{const p=o.userVote==="UP",g=o.title??o.content;return e.jsxs("div",{onClick:()=>i(o.id),style:{display:"flex",gap:12,padding:14,border:`1px solid ${t.border}`,borderRadius:14,marginBottom:10,background:t.bg,cursor:"pointer"},children:[e.jsxs("button",{onClick:l=>{l.stopPropagation(),u(o.id,"UP")},style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,minWidth:46,padding:"7px 0",borderRadius:11,cursor:"pointer",flexShrink:0,border:`1px solid ${p?n:t.border}`,background:p?`${n}1a`:t.bgSoft},children:[e.jsx(E,{color:n}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:t.text,lineHeight:1.1},children:o.upvotes})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:13.5,fontWeight:600,lineHeight:1.4,color:t.text,margin:"0 0 6px",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:g}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx(z,{type:o.type,p:t}),o.status==="PENDING"?e.jsx(B,{}):e.jsx(W,{status:o.status,p:t}),e.jsx("span",{style:{fontSize:11,color:t.textFaint},children:I(o.createdAt)})]})]}),e.jsx("span",{style:{color:t.textFaint,fontSize:18,alignSelf:"center",flexShrink:0},children:"›"})]},o.id)})}):e.jsxs("div",{style:{textAlign:"center",padding:"40px 0"},children:[e.jsx("div",{style:{color:t.textSoft,fontSize:15,fontWeight:600,marginBottom:4},children:"No open feedback yet"}),e.jsx("div",{style:{color:t.textFaint,fontSize:14},children:"Be the first to share one."})]})}function N({feedbackId:i,accent:n,p:t,font:f}){const{vote:u,getItem:s}=v(),[o,p]=r.useState(null),[g,l]=r.useState(!1);r.useEffect(()=>{let a=!1;return s(i).then(b=>{a||p(b)}).catch(()=>{}),()=>{a=!0}},[i,s]);async function m(){if(!(!o||g)){l(!0);try{await u(o.id,"UP");const a=await s(i);p(a)}catch{}finally{l(!1)}}}if(!o)return e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:t.textFaint,fontSize:14},children:"Loading…"});const c=o.title;return e.jsxs("div",{children:[c&&e.jsx("div",{style:{fontSize:20,fontWeight:700,color:t.text,letterSpacing:"-.02em",marginBottom:10,lineHeight:1.3},children:c}),e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:14,flexWrap:"wrap"},children:[e.jsx(z,{type:o.type,p:t}),o.status==="PENDING"?e.jsx(B,{}):e.jsx(W,{status:o.status,p:t})]}),e.jsx("p",{style:{fontSize:15,lineHeight:1.6,color:t.textSoft,marginBottom:20},children:o.content}),e.jsxs("button",{onClick:m,disabled:g,style:{display:"inline-flex",alignItems:"center",gap:8,border:`1px solid ${o.userVote==="UP"?n:t.border}`,background:o.userVote==="UP"?`${n}15`:t.bgSoft,borderRadius:12,padding:"10px 16px",cursor:"pointer",fontFamily:f},children:[e.jsx(E,{color:n,size:13}),e.jsx("span",{style:{fontSize:18,fontWeight:700,color:t.text},children:o.upvotes}),e.jsx("span",{style:{fontSize:13,color:t.textFaint},children:o.userVote==="UP"?"Upvoted":"Upvote"})]}),o.comments.length>0&&e.jsxs("div",{style:{marginTop:28,borderTop:`1px solid ${t.border}`,paddingTop:20},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:t.textFaint,marginBottom:12,textTransform:"uppercase"},children:"Developer response"}),o.comments.map(a=>e.jsx($,{comment:a,p:t,accent:n},a.id))]})]})}function $({comment:i,p:n,accent:t}){return e.jsxs("div",{style:{background:n.bgSoft,border:`1px solid ${n.border}`,borderRadius:12,padding:14,marginBottom:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("span",{style:{background:`${t}20`,color:t,fontSize:11,fontWeight:700,borderRadius:20,padding:"2px 8px"},children:"Developer"}),e.jsx("span",{style:{fontSize:11,color:n.textFaint},children:I(i.createdAt)})]}),e.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:n.textSoft,margin:0},children:i.content})]})}function O({accent:i,p:n,font:t,onDone:f}){const{submit:u}=v(),[s,o]=r.useState(""),[p,g]=r.useState(""),[l,m]=r.useState("GENERAL"),[c,a]=r.useState(!1),[b,k]=r.useState(!1),[y,x]=r.useState("");async function S(){if(!(!s.trim()||c)){a(!0),x("");try{await u(s.trim(),p.trim()||s.trim(),l),k(!0),setTimeout(f,1200)}catch{x("Something went wrong. Please try again.")}finally{a(!1)}}}if(b)return e.jsxs("div",{style:{textAlign:"center",paddingTop:40},children:[e.jsx("div",{style:{fontSize:18,fontWeight:700,color:n.text,marginBottom:6},children:"Submitted"}),e.jsx("div",{style:{fontSize:14,color:n.textFaint},children:"Feedback received. Thank you."})]});const h={width:"100%",border:`1px solid ${n.border}`,borderRadius:12,padding:"10px 12px",fontSize:14,lineHeight:1.5,outline:"none",background:n.bgSoft,color:n.text,fontFamily:t,boxSizing:"border-box"};return e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Type"}),e.jsx("div",{style:{display:"flex",gap:7,marginBottom:16},children:["BUG","FEATURE","GENERAL"].map(d=>e.jsxs("button",{onClick:()=>m(d),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"8px 10px",borderRadius:9,fontSize:12.5,fontWeight:600,cursor:"pointer",background:l===d?i:n.bg,color:l===d?"#fff":n.textSoft,border:`1px solid ${l===d?i:n.border}`,fontFamily:t},children:[C[d].icon,C[d].label]},d))}),e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Title"}),e.jsx("input",{value:s,onChange:d=>o(d.target.value),placeholder:"Short summary of the issue or idea",maxLength:200,style:{...h,marginBottom:16,display:"block"}}),e.jsxs("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:["Description ",e.jsx("span",{style:{fontWeight:400,textTransform:"none",letterSpacing:0},children:"(optional)"})]}),e.jsx("textarea",{value:p,onChange:d=>g(d.target.value),placeholder:"Steps to reproduce, expected behaviour, or more context",maxLength:2e3,rows:4,style:{...h,resize:"vertical",marginBottom:16}}),y&&e.jsx("p",{style:{fontSize:13,color:"#d6453d",marginBottom:12},children:y}),e.jsx("button",{onClick:S,disabled:c||!s.trim(),style:{width:"100%",padding:12,background:i,color:"#fff",border:"none",borderRadius:11,fontSize:14,fontWeight:600,cursor:"pointer",opacity:c||!s.trim()?.5:1,fontFamily:t},children:c?"Submitting…":"Submit feedback"})]})}const C={BUG:{label:"Bug",icon:e.jsxs("svg",{width:12,height:12,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("ellipse",{cx:"8",cy:"10",rx:"3.5",ry:"4.5"}),e.jsx("path",{d:"M8 5.5V4M5.5 6.5 3.5 5M10.5 6.5 12.5 5M4.5 10.5 2.5 10M11.5 10.5 13.5 10"})]})},FEATURE:{label:"Feature",icon:e.jsxs("svg",{width:12,height:12,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.1 4.1l1 1M10.9 10.9l1 1M11.9 4.1l-1 1M5.1 10.9l-1 1"}),e.jsx("circle",{cx:"8",cy:"8",r:"2.5"})]})},GENERAL:{label:"General",icon:e.jsx("svg",{width:12,height:12,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"})})}},V={BUG:"#fdecec",FEATURE:"#e9f0fd"},_={BUG:"#d6453d",FEATURE:"#3b76d6"};function z({type:i,p:n}){return e.jsx("span",{style:{padding:"2px 8px",borderRadius:9999,fontSize:10.5,fontWeight:700,letterSpacing:".02em",background:V[i]??n.bgSoft,color:_[i]??n.textSoft},children:i})}const q={OPEN:"#b45309",IN_PROGRESS:"#1d4ed8",DONE:"#15803d",CLOSED:"#6b7280"};function B(){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:6,padding:"1px 6px",fontSize:10,fontWeight:700,color:"#ea580c"},children:[e.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"#ea580c",display:"inline-block"}}),"Pending review"]})}function W({status:i,p:n}){const t=q[i]??"#9ca3af";return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,background:n.bgSoft,border:`1px solid ${n.border}`,borderRadius:6,padding:"2px 8px",fontSize:10,fontWeight:600,color:n.textSoft},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}}),i.replace("_"," ")]})}function Y({size:i=16,color:n="currentColor"}){return e.jsx("svg",{width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function E({color:i="currentColor",size:n=11}){return e.jsx("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none",stroke:i,strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M8 13V3M3 8l5-5 5 5"})})}function I(i){return new Date(i).toLocaleDateString(void 0,{month:"short",day:"numeric"})}exports.FeedbackWidget=G;exports.UpstepProvider=A;exports.useUpstep=v;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),L=require("./api-BvhrcMKU.js"),R="#D97757",M={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},D={bg:"#1c1b19",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function P(i){const[n,t]=r.useState(()=>i==="dark"?!0:i==="light"?!1:typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1);return r.useEffect(()=>{if(i!=="auto"||typeof window>"u"||!window.matchMedia){t(i==="dark");return}const f=window.matchMedia("(prefers-color-scheme: dark)"),u=s=>t(s.matches);return t(f.matches),f.addEventListener("change",u),()=>f.removeEventListener("change",u)},[i]),n?D:M}const F=r.createContext(null);function A({children:i,...n}){const[t]=r.useState(()=>new L.UpstepApiClient(n)),[f,u]=r.useState([]),[s,o]=r.useState(!1),[p,g]=r.useState(!0);r.useEffect(()=>{t.setUserId(n.userId)},[t,n.userId]);const l=r.useCallback(async()=>{try{const x=await t.listFeedback({sort:"votes",limit:20});u(x.items),g(x.showBranding??!0)}catch{}},[t]);r.useEffect(()=>{l()},[l]);const y=r.useCallback(async(x,j,h)=>{const d={content:j};x.trim()&&(d.title=x.trim()),h!==void 0&&(d.type=h),await t.submitFeedback(d),await l()},[t,l]),c=r.useCallback(async(x,j)=>{try{await t.vote(x,j),await l()}catch{}},[t,l]),a=r.useCallback(x=>t.getItem(x),[t]),b=r.useCallback(()=>o(!0),[]),k=r.useCallback(()=>o(!1),[]),S=r.useCallback(x=>t.setUserId(x),[t]);return e.jsx(F.Provider,{value:{client:t,feedItems:f,loadFeed:l,submit:y,vote:c,getItem:a,isOpen:s,open:b,close:k,identify:S,accentColor:n.accentColor??R,theme:n.theme??"auto",showBranding:p},children:i})}function v(){const i=r.useContext(F);if(!i)throw new Error("useUpstep must be used inside <UpstepProvider>");return i}function G({position:i="bottom-right",accentColor:n,theme:t,hideLauncher:f=!1}){const u=v(),s=n??u.accentColor,o=P(t??u.theme),{isOpen:p,open:g,close:l,showBranding:y}=u,[c,a]=r.useState("list"),[b,k]=r.useState(null),[S,x]=r.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:!1);r.useEffect(()=>{const m=window.matchMedia("(max-width: 639px)");x(m.matches);const w=U=>x(U.matches);return m.addEventListener("change",w),()=>m.removeEventListener("change",w)},[]);const j=i==="bottom-left"?{position:"fixed",bottom:24,left:24}:{position:"fixed",bottom:24,right:24},h='-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';function d(){l(),setTimeout(()=>{a("list"),k(null)},300)}function T(m){k(m),a("detail")}return e.jsxs(e.Fragment,{children:[!f&&e.jsxs("button",{onClick:g,style:{...j,zIndex:9998,display:"inline-flex",alignItems:"center",gap:7,background:s,color:"#fff",border:"none",borderRadius:9999,padding:S?"12px":"12px 18px",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:h,boxShadow:"0 6px 20px rgba(26,25,21,.18)"},children:[e.jsx(Y,{size:16}),!S&&"Feedback"]}),p&&e.jsx("div",{onClick:m=>m.target===m.currentTarget&&d(),style:{position:"fixed",inset:0,background:o.overlay,backdropFilter:"blur(3px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:16,fontFamily:h},children:e.jsxs("div",{style:{background:o.bg,border:`1px solid ${o.border}`,borderRadius:20,width:"100%",maxWidth:440,maxHeight:"88vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 64px rgba(0,0,0,.28)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${o.border}`,flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c!=="list"&&e.jsx("button",{onClick:()=>a("list"),style:{background:"none",border:"none",cursor:"pointer",color:s,fontSize:13,fontWeight:600,padding:0},children:"← Back"}),c==="list"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:o.text,letterSpacing:"-.01em"},children:"Feedback"}),c==="create"&&e.jsx("span",{style:{fontWeight:700,fontSize:16,color:o.text,letterSpacing:"-.01em"},children:"New feedback"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c==="list"&&e.jsx("button",{onClick:()=>a("create"),style:{background:s,color:"#fff",border:"none",borderRadius:20,padding:"6px 14px",fontSize:13,fontWeight:700,cursor:"pointer"},children:"+ New"}),e.jsx("button",{onClick:d,style:{background:o.bgSoft,border:"none",width:28,height:28,borderRadius:8,fontSize:14,cursor:"pointer",color:o.textSoft,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px 24px"},children:[c==="list"&&e.jsx(H,{onSelect:T,accent:s,p:o}),c==="detail"&&b&&e.jsx(N,{feedbackId:b,accent:s,p:o,font:h}),c==="create"&&e.jsx(O,{accent:s,p:o,font:h,onDone:()=>a("list")})]}),y&&e.jsxs("a",{href:"https://upstep.dev",target:"_blank",rel:"noopener noreferrer",style:{display:"block",textAlign:"center",padding:"8px 0",borderTop:`1px solid ${o.border}`,fontSize:11,color:o.textFaint,textDecoration:"none",flexShrink:0},children:["Powered by ",e.jsx("strong",{style:{fontWeight:700},children:"Upstep.dev"})]})]})})]})}function H({onSelect:i,accent:n,p:t}){const{feedItems:f,vote:u}=v(),s=f.filter(o=>o.status!=="CLOSED");return s.length?e.jsx(e.Fragment,{children:s.map(o=>{const p=o.userVote==="UP",g=o.title??o.content;return e.jsxs("div",{onClick:()=>i(o.id),style:{display:"flex",gap:12,padding:14,border:`1px solid ${t.border}`,borderRadius:14,marginBottom:10,background:t.bg,cursor:"pointer"},children:[e.jsxs("button",{onClick:l=>{l.stopPropagation(),u(o.id,"UP")},style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,minWidth:46,padding:"7px 0",borderRadius:11,cursor:"pointer",flexShrink:0,border:`1px solid ${p?n:t.border}`,background:p?`${n}1a`:t.bgSoft},children:[e.jsx(E,{color:n}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:t.text,lineHeight:1.1},children:o.upvotes})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:13.5,fontWeight:600,lineHeight:1.4,color:t.text,margin:"0 0 6px",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:g}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx(z,{type:o.type,p:t}),o.status==="PENDING"?e.jsx(B,{}):e.jsx(W,{status:o.status,p:t}),e.jsx("span",{style:{fontSize:11,color:t.textFaint},children:I(o.createdAt)})]})]}),e.jsx("span",{style:{color:t.textFaint,fontSize:18,alignSelf:"center",flexShrink:0},children:"›"})]},o.id)})}):e.jsxs("div",{style:{textAlign:"center",padding:"40px 0"},children:[e.jsx("div",{style:{color:t.textSoft,fontSize:15,fontWeight:600,marginBottom:4},children:"No open feedback yet"}),e.jsx("div",{style:{color:t.textFaint,fontSize:14},children:"Be the first to share one."})]})}function N({feedbackId:i,accent:n,p:t,font:f}){const{vote:u,getItem:s}=v(),[o,p]=r.useState(null),[g,l]=r.useState(!1);r.useEffect(()=>{let a=!1;return s(i).then(b=>{a||p(b)}).catch(()=>{}),()=>{a=!0}},[i,s]);async function y(){if(!(!o||g)){l(!0);try{await u(o.id,"UP");const a=await s(i);p(a)}catch{}finally{l(!1)}}}if(!o)return e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:t.textFaint,fontSize:14},children:"Loading…"});const c=o.title;return e.jsxs("div",{children:[c&&e.jsx("div",{style:{fontSize:20,fontWeight:700,color:t.text,letterSpacing:"-.02em",marginBottom:10,lineHeight:1.3},children:c}),e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:14,flexWrap:"wrap"},children:[e.jsx(z,{type:o.type,p:t}),o.status==="PENDING"?e.jsx(B,{}):e.jsx(W,{status:o.status,p:t})]}),e.jsx("p",{style:{fontSize:15,lineHeight:1.6,color:t.textSoft,marginBottom:20},children:o.content}),e.jsxs("button",{onClick:y,disabled:g,style:{display:"inline-flex",alignItems:"center",gap:8,border:`1px solid ${o.userVote==="UP"?n:t.border}`,background:o.userVote==="UP"?`${n}15`:t.bgSoft,borderRadius:12,padding:"10px 16px",cursor:"pointer",fontFamily:f},children:[e.jsx(E,{color:n,size:13}),e.jsx("span",{style:{fontSize:18,fontWeight:700,color:t.text},children:o.upvotes}),e.jsx("span",{style:{fontSize:13,color:t.textFaint},children:o.userVote==="UP"?"Upvoted":"Upvote"})]}),o.comments.length>0&&e.jsxs("div",{style:{marginTop:28,borderTop:`1px solid ${t.border}`,paddingTop:20},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:t.textFaint,marginBottom:12,textTransform:"uppercase"},children:"Developer response"}),o.comments.map(a=>e.jsx($,{comment:a,p:t,accent:n},a.id))]})]})}function $({comment:i,p:n,accent:t}){return e.jsxs("div",{style:{background:n.bgSoft,border:`1px solid ${n.border}`,borderRadius:12,padding:14,marginBottom:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("span",{style:{background:`${t}20`,color:t,fontSize:11,fontWeight:700,borderRadius:20,padding:"2px 8px"},children:"Developer"}),e.jsx("span",{style:{fontSize:11,color:n.textFaint},children:I(i.createdAt)})]}),e.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:n.textSoft,margin:0},children:i.content})]})}function O({accent:i,p:n,font:t,onDone:f}){const{submit:u}=v(),[s,o]=r.useState(""),[p,g]=r.useState(""),[l,y]=r.useState("GENERAL"),[c,a]=r.useState(!1),[b,k]=r.useState(!1),[S,x]=r.useState("");async function j(){if(!(!s.trim()||c)){a(!0),x("");try{await u(s.trim(),p.trim()||s.trim(),l),k(!0),setTimeout(f,1200)}catch{x("Something went wrong. Please try again.")}finally{a(!1)}}}if(b)return e.jsxs("div",{style:{textAlign:"center",paddingTop:40},children:[e.jsx("div",{style:{fontSize:18,fontWeight:700,color:n.text,marginBottom:6},children:"Submitted"}),e.jsx("div",{style:{fontSize:14,color:n.textFaint},children:"Feedback received. Thank you."})]});const h={width:"100%",border:`1px solid ${n.border}`,borderRadius:12,padding:"10px 12px",fontSize:14,lineHeight:1.5,outline:"none",background:n.bgSoft,color:n.text,fontFamily:t,boxSizing:"border-box"};return e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Type"}),e.jsx("div",{style:{display:"flex",gap:7,marginBottom:16},children:["BUG","FEATURE","GENERAL"].map(d=>e.jsxs("button",{onClick:()=>y(d),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"8px 10px",borderRadius:9,fontSize:12.5,fontWeight:600,cursor:"pointer",background:l===d?i:n.bg,color:l===d?"#fff":n.textSoft,border:`1px solid ${l===d?i:n.border}`,fontFamily:t},children:[C[d].icon,C[d].label]},d))}),e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:"Title"}),e.jsx("input",{value:s,onChange:d=>o(d.target.value),placeholder:"Short summary of the issue or idea",maxLength:200,style:{...h,marginBottom:16,display:"block"}}),e.jsxs("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".08em",color:n.textFaint,marginBottom:8,textTransform:"uppercase"},children:["Description ",e.jsx("span",{style:{fontWeight:400,textTransform:"none",letterSpacing:0},children:"(optional)"})]}),e.jsx("textarea",{value:p,onChange:d=>g(d.target.value),placeholder:"Steps to reproduce, expected behaviour, or more context",maxLength:2e3,rows:4,style:{...h,resize:"vertical",marginBottom:16}}),S&&e.jsx("p",{style:{fontSize:13,color:"#d6453d",marginBottom:12},children:S}),e.jsx("button",{onClick:j,disabled:c||!s.trim(),style:{width:"100%",padding:12,background:i,color:"#fff",border:"none",borderRadius:11,fontSize:14,fontWeight:600,cursor:"pointer",opacity:c||!s.trim()?.5:1,fontFamily:t},children:c?"Submitting…":"Submit feedback"})]})}const C={BUG:{label:"Bug",icon:e.jsxs("svg",{width:12,height:12,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("ellipse",{cx:"8",cy:"10",rx:"3.5",ry:"4.5"}),e.jsx("path",{d:"M8 5.5V4M5.5 6.5 3.5 5M10.5 6.5 12.5 5M4.5 10.5 2.5 10M11.5 10.5 13.5 10"})]})},FEATURE:{label:"Feature",icon:e.jsxs("svg",{width:12,height:12,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.1 4.1l1 1M10.9 10.9l1 1M11.9 4.1l-1 1M5.1 10.9l-1 1"}),e.jsx("circle",{cx:"8",cy:"8",r:"2.5"})]})},GENERAL:{label:"General",icon:e.jsx("svg",{width:12,height:12,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"})})}},V={BUG:"#fdecec",FEATURE:"#e9f0fd"},_={BUG:"#d6453d",FEATURE:"#3b76d6"};function z({type:i,p:n}){return e.jsx("span",{style:{padding:"2px 8px",borderRadius:9999,fontSize:10.5,fontWeight:700,letterSpacing:".02em",background:V[i]??n.bgSoft,color:_[i]??n.textSoft},children:i})}const q={OPEN:"#b45309",IN_PROGRESS:"#1d4ed8",DONE:"#15803d",CLOSED:"#6b7280"};function B(){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:6,padding:"1px 6px",fontSize:10,fontWeight:700,color:"#ea580c"},children:[e.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"#ea580c",display:"inline-block"}}),"Pending review"]})}function W({status:i,p:n}){const t=q[i]??"#9ca3af";return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,background:n.bgSoft,border:`1px solid ${n.border}`,borderRadius:6,padding:"2px 8px",fontSize:10,fontWeight:600,color:n.textSoft},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}}),i.replace("_"," ")]})}function Y({size:i=16,color:n="currentColor"}){return e.jsx("svg",{width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function E({color:i="currentColor",size:n=11}){return e.jsx("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none",stroke:i,strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M8 13V3M3 8l5-5 5 5"})})}function I(i){return new Date(i).toLocaleDateString(void 0,{month:"short",day:"numeric"})}exports.FeedbackWidget=G;exports.UpstepProvider=A;exports.useUpstep=v;
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAMZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAW,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAMxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAmD3C,UAAU,kBAAkB;IAC1B,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/E,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC/D,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;CACvB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,qBA6DxC;AAED,wBAAgB,SAAS,IAAI,kBAAkB,CAI9C;AAID,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAyB,EACzB,WAAW,EACX,KAAK,EACL,YAAoB,GACrB,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAMZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAW,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAMxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAmD3C,UAAU,kBAAkB;IAC1B,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/E,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC/D,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;CACvB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,qBA6DxC;AAED,wBAAgB,SAAS,IAAI,kBAAkB,CAI9C;AAID,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAyB,EACzB,WAAW,EACX,KAAK,EACL,YAAoB,GACrB,EAAE,mBAAmB,qBAmJrB"}
|
package/dist/react.js
CHANGED
|
@@ -50,18 +50,18 @@ function ne({
|
|
|
50
50
|
z(() => {
|
|
51
51
|
d();
|
|
52
52
|
}, [d]);
|
|
53
|
-
const
|
|
54
|
-
const s = { content:
|
|
53
|
+
const S = w(async (f, k, m) => {
|
|
54
|
+
const s = { content: k };
|
|
55
55
|
f.trim() && (s.title = f.trim()), m !== void 0 && (s.type = m), await t.submitFeedback(s), await d();
|
|
56
|
-
}, [t, d]), c = w(async (f,
|
|
56
|
+
}, [t, d]), c = w(async (f, k) => {
|
|
57
57
|
try {
|
|
58
|
-
await t.vote(f,
|
|
58
|
+
await t.vote(f, k), await d();
|
|
59
59
|
} catch {
|
|
60
60
|
}
|
|
61
61
|
}, [t, d]), a = w(
|
|
62
62
|
(f) => t.getItem(f),
|
|
63
63
|
[t]
|
|
64
|
-
), b = w(() => o(!0), []), F = w(() => o(!1), []),
|
|
64
|
+
), b = w(() => o(!0), []), F = w(() => o(!1), []), v = w((f) => t.setUserId(f), [t]);
|
|
65
65
|
return /* @__PURE__ */ e(
|
|
66
66
|
E.Provider,
|
|
67
67
|
{
|
|
@@ -69,13 +69,13 @@ function ne({
|
|
|
69
69
|
client: t,
|
|
70
70
|
feedItems: h,
|
|
71
71
|
loadFeed: d,
|
|
72
|
-
submit:
|
|
72
|
+
submit: S,
|
|
73
73
|
vote: c,
|
|
74
74
|
getItem: a,
|
|
75
75
|
isOpen: l,
|
|
76
76
|
open: b,
|
|
77
77
|
close: F,
|
|
78
|
-
identify:
|
|
78
|
+
identify: v,
|
|
79
79
|
accentColor: n.accentColor ?? N,
|
|
80
80
|
theme: n.theme ?? "auto",
|
|
81
81
|
showBranding: u
|
|
@@ -95,21 +95,23 @@ function oe({
|
|
|
95
95
|
theme: t,
|
|
96
96
|
hideLauncher: h = !1
|
|
97
97
|
}) {
|
|
98
|
-
const g = B(), l = n ?? g.accentColor, o = O(t ?? g.theme), { isOpen: u, open: x, close: d, showBranding:
|
|
98
|
+
const g = B(), l = n ?? g.accentColor, o = O(t ?? g.theme), { isOpen: u, open: x, close: d, showBranding: S } = g, [c, a] = p("list"), [b, F] = p(null), [v, f] = p(
|
|
99
99
|
() => typeof window < "u" ? window.matchMedia("(max-width: 639px)").matches : !1
|
|
100
100
|
);
|
|
101
101
|
z(() => {
|
|
102
|
-
const
|
|
103
|
-
|
|
102
|
+
const y = window.matchMedia("(max-width: 639px)");
|
|
103
|
+
f(y.matches);
|
|
104
|
+
const C = (P) => f(P.matches);
|
|
105
|
+
return y.addEventListener("change", C), () => y.removeEventListener("change", C);
|
|
104
106
|
}, []);
|
|
105
|
-
const
|
|
107
|
+
const k = i === "bottom-left" ? { position: "fixed", bottom: 24, left: 24 } : { position: "fixed", bottom: 24, right: 24 }, m = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';
|
|
106
108
|
function s() {
|
|
107
109
|
d(), setTimeout(() => {
|
|
108
110
|
a("list"), F(null);
|
|
109
111
|
}, 300);
|
|
110
112
|
}
|
|
111
|
-
function D(
|
|
112
|
-
F(
|
|
113
|
+
function D(y) {
|
|
114
|
+
F(y), a("detail");
|
|
113
115
|
}
|
|
114
116
|
return /* @__PURE__ */ r(I, { children: [
|
|
115
117
|
!h && /* @__PURE__ */ r(
|
|
@@ -117,7 +119,7 @@ function oe({
|
|
|
117
119
|
{
|
|
118
120
|
onClick: x,
|
|
119
121
|
style: {
|
|
120
|
-
...
|
|
122
|
+
...k,
|
|
121
123
|
zIndex: 9998,
|
|
122
124
|
display: "inline-flex",
|
|
123
125
|
alignItems: "center",
|
|
@@ -126,7 +128,7 @@ function oe({
|
|
|
126
128
|
color: "#fff",
|
|
127
129
|
border: "none",
|
|
128
130
|
borderRadius: 9999,
|
|
129
|
-
padding:
|
|
131
|
+
padding: v ? "12px" : "12px 18px",
|
|
130
132
|
fontSize: 14,
|
|
131
133
|
fontWeight: 600,
|
|
132
134
|
cursor: "pointer",
|
|
@@ -135,14 +137,14 @@ function oe({
|
|
|
135
137
|
},
|
|
136
138
|
children: [
|
|
137
139
|
/* @__PURE__ */ e(X, { size: 16 }),
|
|
138
|
-
!
|
|
140
|
+
!v && "Feedback"
|
|
139
141
|
]
|
|
140
142
|
}
|
|
141
143
|
),
|
|
142
144
|
u && /* @__PURE__ */ e(
|
|
143
145
|
"div",
|
|
144
146
|
{
|
|
145
|
-
onClick: (
|
|
147
|
+
onClick: (y) => y.target === y.currentTarget && s(),
|
|
146
148
|
style: {
|
|
147
149
|
position: "fixed",
|
|
148
150
|
inset: 0,
|
|
@@ -223,7 +225,7 @@ function oe({
|
|
|
223
225
|
}
|
|
224
226
|
)
|
|
225
227
|
] }),
|
|
226
|
-
|
|
228
|
+
S && /* @__PURE__ */ r(
|
|
227
229
|
"a",
|
|
228
230
|
{
|
|
229
231
|
href: "https://upstep.dev",
|
|
@@ -330,7 +332,7 @@ function _({ feedbackId: i, accent: n, p: t, font: h }) {
|
|
|
330
332
|
a = !0;
|
|
331
333
|
};
|
|
332
334
|
}, [i, l]);
|
|
333
|
-
async function
|
|
335
|
+
async function S() {
|
|
334
336
|
if (!(!o || x)) {
|
|
335
337
|
d(!0);
|
|
336
338
|
try {
|
|
@@ -356,7 +358,7 @@ function _({ feedbackId: i, accent: n, p: t, font: h }) {
|
|
|
356
358
|
/* @__PURE__ */ r(
|
|
357
359
|
"button",
|
|
358
360
|
{
|
|
359
|
-
onClick:
|
|
361
|
+
onClick: S,
|
|
360
362
|
disabled: x,
|
|
361
363
|
style: {
|
|
362
364
|
display: "inline-flex",
|
|
@@ -392,8 +394,8 @@ function Y({ comment: i, p: n, accent: t }) {
|
|
|
392
394
|
] });
|
|
393
395
|
}
|
|
394
396
|
function q({ accent: i, p: n, font: t, onDone: h }) {
|
|
395
|
-
const { submit: g } = B(), [l, o] = p(""), [u, x] = p(""), [d,
|
|
396
|
-
async function
|
|
397
|
+
const { submit: g } = B(), [l, o] = p(""), [u, x] = p(""), [d, S] = p("GENERAL"), [c, a] = p(!1), [b, F] = p(!1), [v, f] = p("");
|
|
398
|
+
async function k() {
|
|
397
399
|
if (!(!l.trim() || c)) {
|
|
398
400
|
a(!0), f("");
|
|
399
401
|
try {
|
|
@@ -428,7 +430,7 @@ function q({ accent: i, p: n, font: t, onDone: h }) {
|
|
|
428
430
|
/* @__PURE__ */ e("div", { style: { display: "flex", gap: 7, marginBottom: 16 }, children: ["BUG", "FEATURE", "GENERAL"].map((s) => /* @__PURE__ */ r(
|
|
429
431
|
"button",
|
|
430
432
|
{
|
|
431
|
-
onClick: () =>
|
|
433
|
+
onClick: () => S(s),
|
|
432
434
|
style: {
|
|
433
435
|
flex: 1,
|
|
434
436
|
display: "flex",
|
|
@@ -478,11 +480,11 @@ function q({ accent: i, p: n, font: t, onDone: h }) {
|
|
|
478
480
|
style: { ...m, resize: "vertical", marginBottom: 16 }
|
|
479
481
|
}
|
|
480
482
|
),
|
|
481
|
-
|
|
483
|
+
v && /* @__PURE__ */ e("p", { style: { fontSize: 13, color: "#d6453d", marginBottom: 12 }, children: v }),
|
|
482
484
|
/* @__PURE__ */ e(
|
|
483
485
|
"button",
|
|
484
486
|
{
|
|
485
|
-
onClick:
|
|
487
|
+
onClick: k,
|
|
486
488
|
disabled: c || !l.trim(),
|
|
487
489
|
style: {
|
|
488
490
|
width: "100%",
|
package/dist/widget.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare class UpstepWidget {
|
|
|
19
19
|
private position;
|
|
20
20
|
private showLauncher;
|
|
21
21
|
private palette;
|
|
22
|
+
private dragMoved;
|
|
22
23
|
constructor(client: UpstepApiClient, options?: WidgetOptions);
|
|
23
24
|
mount(): void;
|
|
24
25
|
/** Open the feedback modal programmatically (e.g. from your own button). */
|
|
@@ -27,6 +28,7 @@ export declare class UpstepWidget {
|
|
|
27
28
|
closeWidget(): void;
|
|
28
29
|
private injectStyles;
|
|
29
30
|
private renderButton;
|
|
31
|
+
private makeDraggable;
|
|
30
32
|
private openModal;
|
|
31
33
|
private closeModal;
|
|
32
34
|
private fetchFeed;
|
package/dist/widget.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAIxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAuG3C,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,OAAO,CAAU;
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAIxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAuG3C,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,eAAe,EAAE,OAAO,GAAE,aAAkB;IAQhE,KAAK;IAKL,4EAA4E;IAC5E,UAAU;IAIV,iDAAiD;IACjD,WAAW;IAIX,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,aAAa;IA4ErB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,UAAU;YAKJ,SAAS;IAUvB,OAAO,CAAC,WAAW;IAyCnB,OAAO,CAAC,gBAAgB;IAoBxB,OAAO,CAAC,UAAU;IAwBlB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;IAyCtB,OAAO,CAAC,eAAe;CAaxB"}
|