@upstep/js 0.5.4 → 0.5.6
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 +38 -37
- package/dist/index.js +131 -96
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +222 -236
- package/dist/widget.d.ts +2 -0
- package/dist/widget.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as r, Fragment as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { U as
|
|
1
|
+
import { jsxs as r, Fragment as I, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as A, useState as p, useEffect as z, useCallback as w, useContext as G } from "react";
|
|
3
|
+
import { U as H } from "./api-B-umoNRf.mjs";
|
|
4
4
|
const N = "#D97757", $ = {
|
|
5
5
|
bg: "#ffffff",
|
|
6
6
|
bgSoft: "#f6f5f2",
|
|
@@ -10,7 +10,7 @@ const N = "#D97757", $ = {
|
|
|
10
10
|
textFaint: "#9b9890",
|
|
11
11
|
border: "#e8e6df",
|
|
12
12
|
overlay: "rgba(26,25,21,.45)"
|
|
13
|
-
},
|
|
13
|
+
}, j = {
|
|
14
14
|
bg: "#1c1b19",
|
|
15
15
|
bgSoft: "#262522",
|
|
16
16
|
bgHover: "#302e2a",
|
|
@@ -20,92 +20,99 @@ const N = "#D97757", $ = {
|
|
|
20
20
|
border: "#33312c",
|
|
21
21
|
overlay: "rgba(0,0,0,.6)"
|
|
22
22
|
};
|
|
23
|
-
function
|
|
24
|
-
const [
|
|
25
|
-
return
|
|
26
|
-
if (
|
|
27
|
-
|
|
23
|
+
function O(i) {
|
|
24
|
+
const [n, t] = p(() => i === "dark" ? !0 : i === "light" ? !1 : typeof window < "u" && window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)").matches : !1);
|
|
25
|
+
return z(() => {
|
|
26
|
+
if (i !== "auto" || typeof window > "u" || !window.matchMedia) {
|
|
27
|
+
t(i === "dark");
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
const
|
|
31
|
-
return
|
|
32
|
-
}, [
|
|
30
|
+
const h = window.matchMedia("(prefers-color-scheme: dark)"), g = (l) => t(l.matches);
|
|
31
|
+
return t(h.matches), h.addEventListener("change", g), () => h.removeEventListener("change", g);
|
|
32
|
+
}, [i]), n ? j : $;
|
|
33
33
|
}
|
|
34
|
-
const
|
|
35
|
-
function
|
|
36
|
-
children:
|
|
37
|
-
...
|
|
34
|
+
const E = A(null);
|
|
35
|
+
function ne({
|
|
36
|
+
children: i,
|
|
37
|
+
...n
|
|
38
38
|
}) {
|
|
39
|
-
const [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, [
|
|
43
|
-
const
|
|
39
|
+
const [t] = p(() => new H(n)), [h, g] = p([]), [l, o] = p(!1), [u, x] = p(!0);
|
|
40
|
+
z(() => {
|
|
41
|
+
t.setUserId(n.userId);
|
|
42
|
+
}, [t, n.userId]);
|
|
43
|
+
const d = w(async () => {
|
|
44
44
|
try {
|
|
45
|
-
const
|
|
46
|
-
|
|
45
|
+
const f = await t.listFeedback({ sort: "votes", limit: 20 });
|
|
46
|
+
g(f.items), x(f.showBranding ?? !0);
|
|
47
47
|
} catch {
|
|
48
48
|
}
|
|
49
|
-
}, [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}, [
|
|
53
|
-
const y = w(async (
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
}, [
|
|
49
|
+
}, [t]);
|
|
50
|
+
z(() => {
|
|
51
|
+
d();
|
|
52
|
+
}, [d]);
|
|
53
|
+
const y = w(async (f, v, m) => {
|
|
54
|
+
const s = { content: v };
|
|
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, v) => {
|
|
57
57
|
try {
|
|
58
|
-
await
|
|
58
|
+
await t.vote(f, v), await d();
|
|
59
59
|
} catch {
|
|
60
60
|
}
|
|
61
|
-
}, [
|
|
62
|
-
(
|
|
63
|
-
[
|
|
64
|
-
),
|
|
61
|
+
}, [t, d]), a = w(
|
|
62
|
+
(f) => t.getItem(f),
|
|
63
|
+
[t]
|
|
64
|
+
), b = w(() => o(!0), []), F = w(() => o(!1), []), S = w((f) => t.setUserId(f), [t]);
|
|
65
65
|
return /* @__PURE__ */ e(
|
|
66
|
-
|
|
66
|
+
E.Provider,
|
|
67
67
|
{
|
|
68
68
|
value: {
|
|
69
|
-
client:
|
|
70
|
-
feedItems:
|
|
71
|
-
loadFeed:
|
|
69
|
+
client: t,
|
|
70
|
+
feedItems: h,
|
|
71
|
+
loadFeed: d,
|
|
72
72
|
submit: y,
|
|
73
73
|
vote: c,
|
|
74
|
-
getItem:
|
|
75
|
-
isOpen:
|
|
76
|
-
open:
|
|
74
|
+
getItem: a,
|
|
75
|
+
isOpen: l,
|
|
76
|
+
open: b,
|
|
77
77
|
close: F,
|
|
78
|
-
identify:
|
|
79
|
-
accentColor:
|
|
80
|
-
theme:
|
|
81
|
-
showBranding:
|
|
78
|
+
identify: S,
|
|
79
|
+
accentColor: n.accentColor ?? N,
|
|
80
|
+
theme: n.theme ?? "auto",
|
|
81
|
+
showBranding: u
|
|
82
82
|
},
|
|
83
|
-
children:
|
|
83
|
+
children: i
|
|
84
84
|
}
|
|
85
85
|
);
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
const
|
|
89
|
-
if (!
|
|
90
|
-
return
|
|
87
|
+
function B() {
|
|
88
|
+
const i = G(E);
|
|
89
|
+
if (!i) throw new Error("useUpstep must be used inside <UpstepProvider>");
|
|
90
|
+
return i;
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
position:
|
|
94
|
-
accentColor:
|
|
95
|
-
theme:
|
|
96
|
-
hideLauncher:
|
|
92
|
+
function oe({
|
|
93
|
+
position: i = "bottom-right",
|
|
94
|
+
accentColor: n,
|
|
95
|
+
theme: t,
|
|
96
|
+
hideLauncher: h = !1
|
|
97
97
|
}) {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
const g = B(), l = n ?? g.accentColor, o = O(t ?? g.theme), { isOpen: u, open: x, close: d, showBranding: y } = g, [c, a] = p("list"), [b, F] = p(null), [S, f] = p(
|
|
99
|
+
() => typeof window < "u" ? window.matchMedia("(max-width: 639px)").matches : !1
|
|
100
|
+
);
|
|
101
|
+
z(() => {
|
|
102
|
+
const k = window.matchMedia("(max-width: 639px)"), C = (P) => f(P.matches);
|
|
103
|
+
return k.addEventListener("change", C), () => k.removeEventListener("change", C);
|
|
104
|
+
}, []);
|
|
105
|
+
const v = 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
|
+
function s() {
|
|
107
|
+
d(), setTimeout(() => {
|
|
108
|
+
a("list"), F(null);
|
|
102
109
|
}, 300);
|
|
103
110
|
}
|
|
104
|
-
function D(
|
|
105
|
-
F(
|
|
111
|
+
function D(k) {
|
|
112
|
+
F(k), a("detail");
|
|
106
113
|
}
|
|
107
|
-
return /* @__PURE__ */ r(
|
|
108
|
-
!
|
|
114
|
+
return /* @__PURE__ */ r(I, { children: [
|
|
115
|
+
!h && /* @__PURE__ */ r(
|
|
109
116
|
"button",
|
|
110
117
|
{
|
|
111
118
|
onClick: x,
|
|
@@ -115,45 +122,45 @@ function te({
|
|
|
115
122
|
display: "inline-flex",
|
|
116
123
|
alignItems: "center",
|
|
117
124
|
gap: 7,
|
|
118
|
-
background:
|
|
125
|
+
background: l,
|
|
119
126
|
color: "#fff",
|
|
120
127
|
border: "none",
|
|
121
128
|
borderRadius: 9999,
|
|
122
|
-
padding: "12px 18px",
|
|
129
|
+
padding: S ? "12px" : "12px 18px",
|
|
123
130
|
fontSize: 14,
|
|
124
131
|
fontWeight: 600,
|
|
125
132
|
cursor: "pointer",
|
|
126
|
-
fontFamily:
|
|
133
|
+
fontFamily: m,
|
|
127
134
|
boxShadow: "0 6px 20px rgba(26,25,21,.18)"
|
|
128
135
|
},
|
|
129
136
|
children: [
|
|
130
|
-
/* @__PURE__ */ e(
|
|
131
|
-
"
|
|
137
|
+
/* @__PURE__ */ e(X, { size: 16 }),
|
|
138
|
+
!S && "Feedback"
|
|
132
139
|
]
|
|
133
140
|
}
|
|
134
141
|
),
|
|
135
|
-
|
|
142
|
+
u && /* @__PURE__ */ e(
|
|
136
143
|
"div",
|
|
137
144
|
{
|
|
138
|
-
onClick: (
|
|
145
|
+
onClick: (k) => k.target === k.currentTarget && s(),
|
|
139
146
|
style: {
|
|
140
147
|
position: "fixed",
|
|
141
148
|
inset: 0,
|
|
142
|
-
background:
|
|
149
|
+
background: o.overlay,
|
|
143
150
|
backdropFilter: "blur(3px)",
|
|
144
151
|
zIndex: 9999,
|
|
145
152
|
display: "flex",
|
|
146
153
|
alignItems: "center",
|
|
147
154
|
justifyContent: "center",
|
|
148
155
|
padding: 16,
|
|
149
|
-
fontFamily:
|
|
156
|
+
fontFamily: m
|
|
150
157
|
},
|
|
151
158
|
children: /* @__PURE__ */ r(
|
|
152
159
|
"div",
|
|
153
160
|
{
|
|
154
161
|
style: {
|
|
155
|
-
background:
|
|
156
|
-
border: `1px solid ${
|
|
162
|
+
background: o.bg,
|
|
163
|
+
border: `1px solid ${o.border}`,
|
|
157
164
|
borderRadius: 20,
|
|
158
165
|
width: "100%",
|
|
159
166
|
maxWidth: 440,
|
|
@@ -164,75 +171,55 @@ function te({
|
|
|
164
171
|
boxShadow: "0 24px 64px rgba(0,0,0,.28)"
|
|
165
172
|
},
|
|
166
173
|
children: [
|
|
167
|
-
/* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "16px 20px", borderBottom: `1px solid ${
|
|
174
|
+
/* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "16px 20px", borderBottom: `1px solid ${o.border}`, flexShrink: 0 }, children: [
|
|
168
175
|
/* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
169
176
|
c !== "list" && /* @__PURE__ */ e(
|
|
170
177
|
"button",
|
|
171
178
|
{
|
|
172
|
-
onClick: () =>
|
|
173
|
-
style: { background: "none", border: "none", cursor: "pointer", color:
|
|
179
|
+
onClick: () => a("list"),
|
|
180
|
+
style: { background: "none", border: "none", cursor: "pointer", color: l, fontSize: 13, fontWeight: 600, padding: 0 },
|
|
174
181
|
children: "← Back"
|
|
175
182
|
}
|
|
176
183
|
),
|
|
177
|
-
c === "list" && /* @__PURE__ */ e("span", { style: { fontWeight: 700, fontSize: 16, color:
|
|
178
|
-
c === "create" && /* @__PURE__ */ e("span", { style: { fontWeight: 700, fontSize: 16, color:
|
|
184
|
+
c === "list" && /* @__PURE__ */ e("span", { style: { fontWeight: 700, fontSize: 16, color: o.text, letterSpacing: "-.01em" }, children: "Feedback" }),
|
|
185
|
+
c === "create" && /* @__PURE__ */ e("span", { style: { fontWeight: 700, fontSize: 16, color: o.text, letterSpacing: "-.01em" }, children: "New feedback" })
|
|
179
186
|
] }),
|
|
180
187
|
/* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
181
188
|
c === "list" && /* @__PURE__ */ e(
|
|
182
189
|
"button",
|
|
183
190
|
{
|
|
184
|
-
onClick: () =>
|
|
185
|
-
style: { background:
|
|
191
|
+
onClick: () => a("create"),
|
|
192
|
+
style: { background: l, color: "#fff", border: "none", borderRadius: 20, padding: "6px 14px", fontSize: 13, fontWeight: 700, cursor: "pointer" },
|
|
186
193
|
children: "+ New"
|
|
187
194
|
}
|
|
188
195
|
),
|
|
189
196
|
/* @__PURE__ */ e(
|
|
190
197
|
"button",
|
|
191
198
|
{
|
|
192
|
-
onClick:
|
|
193
|
-
style: { background:
|
|
199
|
+
onClick: s,
|
|
200
|
+
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" },
|
|
194
201
|
children: "✕"
|
|
195
202
|
}
|
|
196
203
|
)
|
|
197
204
|
] })
|
|
198
205
|
] }),
|
|
199
|
-
c === "list" && /* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${i.border}`, flexShrink: 0 }, children: ["open", "done"].map((m) => /* @__PURE__ */ e(
|
|
200
|
-
"button",
|
|
201
|
-
{
|
|
202
|
-
onClick: () => g(m),
|
|
203
|
-
style: {
|
|
204
|
-
flex: 1,
|
|
205
|
-
padding: "10px 0",
|
|
206
|
-
border: "none",
|
|
207
|
-
background: "none",
|
|
208
|
-
cursor: "pointer",
|
|
209
|
-
fontSize: 13,
|
|
210
|
-
fontWeight: 600,
|
|
211
|
-
color: k === m ? d : i.textFaint,
|
|
212
|
-
borderBottom: `2px solid ${k === m ? d : "transparent"}`
|
|
213
|
-
},
|
|
214
|
-
children: m === "open" ? "Open" : "Completed"
|
|
215
|
-
},
|
|
216
|
-
m
|
|
217
|
-
)) }),
|
|
218
206
|
/* @__PURE__ */ r("div", { style: { flex: 1, overflowY: "auto", padding: "16px 20px 24px" }, children: [
|
|
219
207
|
c === "list" && /* @__PURE__ */ e(
|
|
220
|
-
|
|
208
|
+
V,
|
|
221
209
|
{
|
|
222
|
-
tab: k,
|
|
223
210
|
onSelect: D,
|
|
224
|
-
accent:
|
|
225
|
-
p:
|
|
211
|
+
accent: l,
|
|
212
|
+
p: o
|
|
226
213
|
}
|
|
227
214
|
),
|
|
228
|
-
c === "detail" &&
|
|
215
|
+
c === "detail" && b && /* @__PURE__ */ e(_, { feedbackId: b, accent: l, p: o, font: m }),
|
|
229
216
|
c === "create" && /* @__PURE__ */ e(
|
|
230
|
-
|
|
217
|
+
q,
|
|
231
218
|
{
|
|
232
|
-
accent:
|
|
233
|
-
p:
|
|
234
|
-
font:
|
|
235
|
-
onDone: () =>
|
|
219
|
+
accent: l,
|
|
220
|
+
p: o,
|
|
221
|
+
font: m,
|
|
222
|
+
onDone: () => a("list")
|
|
236
223
|
}
|
|
237
224
|
)
|
|
238
225
|
] }),
|
|
@@ -246,9 +233,9 @@ function te({
|
|
|
246
233
|
display: "block",
|
|
247
234
|
textAlign: "center",
|
|
248
235
|
padding: "8px 0",
|
|
249
|
-
borderTop: `1px solid ${
|
|
236
|
+
borderTop: `1px solid ${o.border}`,
|
|
250
237
|
fontSize: 11,
|
|
251
|
-
color:
|
|
238
|
+
color: o.textFaint,
|
|
252
239
|
textDecoration: "none",
|
|
253
240
|
flexShrink: 0
|
|
254
241
|
},
|
|
@@ -265,35 +252,34 @@ function te({
|
|
|
265
252
|
)
|
|
266
253
|
] });
|
|
267
254
|
}
|
|
268
|
-
function
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
p: s
|
|
255
|
+
function V({
|
|
256
|
+
onSelect: i,
|
|
257
|
+
accent: n,
|
|
258
|
+
p: t
|
|
273
259
|
}) {
|
|
274
|
-
const { feedItems:
|
|
275
|
-
return
|
|
276
|
-
const
|
|
260
|
+
const { feedItems: h, vote: g } = B(), l = h.filter((o) => o.status !== "CLOSED");
|
|
261
|
+
return l.length ? /* @__PURE__ */ e(I, { children: l.map((o) => {
|
|
262
|
+
const u = o.userVote === "UP", x = o.title ?? o.content;
|
|
277
263
|
return /* @__PURE__ */ r(
|
|
278
264
|
"div",
|
|
279
265
|
{
|
|
280
|
-
onClick: () =>
|
|
266
|
+
onClick: () => i(o.id),
|
|
281
267
|
style: {
|
|
282
268
|
display: "flex",
|
|
283
269
|
gap: 12,
|
|
284
270
|
padding: 14,
|
|
285
|
-
border: `1px solid ${
|
|
271
|
+
border: `1px solid ${t.border}`,
|
|
286
272
|
borderRadius: 14,
|
|
287
273
|
marginBottom: 10,
|
|
288
|
-
background:
|
|
274
|
+
background: t.bg,
|
|
289
275
|
cursor: "pointer"
|
|
290
276
|
},
|
|
291
277
|
children: [
|
|
292
278
|
/* @__PURE__ */ r(
|
|
293
279
|
"button",
|
|
294
280
|
{
|
|
295
|
-
onClick: (
|
|
296
|
-
|
|
281
|
+
onClick: (d) => {
|
|
282
|
+
d.stopPropagation(), g(o.id, "UP");
|
|
297
283
|
},
|
|
298
284
|
style: {
|
|
299
285
|
display: "flex",
|
|
@@ -306,67 +292,67 @@ function O({
|
|
|
306
292
|
borderRadius: 11,
|
|
307
293
|
cursor: "pointer",
|
|
308
294
|
flexShrink: 0,
|
|
309
|
-
border: `1px solid ${
|
|
310
|
-
background:
|
|
295
|
+
border: `1px solid ${u ? n : t.border}`,
|
|
296
|
+
background: u ? `${n}1a` : t.bgSoft
|
|
311
297
|
},
|
|
312
298
|
children: [
|
|
313
|
-
/* @__PURE__ */ e(R, { color:
|
|
314
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 14, fontWeight: 700, color:
|
|
299
|
+
/* @__PURE__ */ e(R, { color: n }),
|
|
300
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 14, fontWeight: 700, color: t.text, lineHeight: 1.1 }, children: o.upvotes })
|
|
315
301
|
]
|
|
316
302
|
}
|
|
317
303
|
),
|
|
318
304
|
/* @__PURE__ */ r("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
319
|
-
/* @__PURE__ */ e("p", { style: { fontSize: 13.5, fontWeight: 600, lineHeight: 1.4, color:
|
|
305
|
+
/* @__PURE__ */ e("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: x }),
|
|
320
306
|
/* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", gap: 6, flexWrap: "wrap" }, children: [
|
|
321
|
-
/* @__PURE__ */ e(T, { type:
|
|
322
|
-
|
|
323
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 11, color:
|
|
307
|
+
/* @__PURE__ */ e(T, { type: o.type, p: t }),
|
|
308
|
+
o.status === "PENDING" ? /* @__PURE__ */ e(L, {}) : /* @__PURE__ */ e(U, { status: o.status, p: t }),
|
|
309
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 11, color: t.textFaint }, children: M(o.createdAt) })
|
|
324
310
|
] })
|
|
325
311
|
] }),
|
|
326
|
-
/* @__PURE__ */ e("span", { style: { color:
|
|
312
|
+
/* @__PURE__ */ e("span", { style: { color: t.textFaint, fontSize: 18, alignSelf: "center", flexShrink: 0 }, children: "›" })
|
|
327
313
|
]
|
|
328
314
|
},
|
|
329
|
-
|
|
315
|
+
o.id
|
|
330
316
|
);
|
|
331
317
|
}) }) : /* @__PURE__ */ r("div", { style: { textAlign: "center", padding: "40px 0" }, children: [
|
|
332
|
-
/* @__PURE__ */ e("div", { style: { color:
|
|
333
|
-
/* @__PURE__ */ e("div", { style: { color:
|
|
318
|
+
/* @__PURE__ */ e("div", { style: { color: t.textSoft, fontSize: 15, fontWeight: 600, marginBottom: 4 }, children: "No open feedback yet" }),
|
|
319
|
+
/* @__PURE__ */ e("div", { style: { color: t.textFaint, fontSize: 14 }, children: "Be the first to share one." })
|
|
334
320
|
] });
|
|
335
321
|
}
|
|
336
|
-
function
|
|
337
|
-
const { vote:
|
|
338
|
-
|
|
339
|
-
let
|
|
340
|
-
return
|
|
341
|
-
|
|
322
|
+
function _({ feedbackId: i, accent: n, p: t, font: h }) {
|
|
323
|
+
const { vote: g, getItem: l } = B(), [o, u] = p(null), [x, d] = p(!1);
|
|
324
|
+
z(() => {
|
|
325
|
+
let a = !1;
|
|
326
|
+
return l(i).then((b) => {
|
|
327
|
+
a || u(b);
|
|
342
328
|
}).catch(() => {
|
|
343
329
|
}), () => {
|
|
344
|
-
|
|
330
|
+
a = !0;
|
|
345
331
|
};
|
|
346
|
-
}, [
|
|
332
|
+
}, [i, l]);
|
|
347
333
|
async function y() {
|
|
348
|
-
if (!(!
|
|
349
|
-
|
|
334
|
+
if (!(!o || x)) {
|
|
335
|
+
d(!0);
|
|
350
336
|
try {
|
|
351
|
-
await
|
|
352
|
-
const
|
|
353
|
-
|
|
337
|
+
await g(o.id, "UP");
|
|
338
|
+
const a = await l(i);
|
|
339
|
+
u(a);
|
|
354
340
|
} catch {
|
|
355
341
|
} finally {
|
|
356
|
-
|
|
342
|
+
d(!1);
|
|
357
343
|
}
|
|
358
344
|
}
|
|
359
345
|
}
|
|
360
|
-
if (!
|
|
361
|
-
return /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: "40px 0", color:
|
|
362
|
-
const c =
|
|
346
|
+
if (!o)
|
|
347
|
+
return /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: "40px 0", color: t.textFaint, fontSize: 14 }, children: "Loading…" });
|
|
348
|
+
const c = o.title;
|
|
363
349
|
return /* @__PURE__ */ r("div", { children: [
|
|
364
|
-
c && /* @__PURE__ */ e("div", { style: { fontSize: 20, fontWeight: 700, color:
|
|
350
|
+
c && /* @__PURE__ */ e("div", { style: { fontSize: 20, fontWeight: 700, color: t.text, letterSpacing: "-.02em", marginBottom: 10, lineHeight: 1.3 }, children: c }),
|
|
365
351
|
/* @__PURE__ */ r("div", { style: { display: "flex", gap: 6, marginBottom: 14, flexWrap: "wrap" }, children: [
|
|
366
|
-
/* @__PURE__ */ e(T, { type:
|
|
367
|
-
|
|
352
|
+
/* @__PURE__ */ e(T, { type: o.type, p: t }),
|
|
353
|
+
o.status === "PENDING" ? /* @__PURE__ */ e(L, {}) : /* @__PURE__ */ e(U, { status: o.status, p: t })
|
|
368
354
|
] }),
|
|
369
|
-
/* @__PURE__ */ e("p", { style: { fontSize: 15, lineHeight: 1.6, color:
|
|
355
|
+
/* @__PURE__ */ e("p", { style: { fontSize: 15, lineHeight: 1.6, color: t.textSoft, marginBottom: 20 }, children: o.content }),
|
|
370
356
|
/* @__PURE__ */ r(
|
|
371
357
|
"button",
|
|
372
358
|
{
|
|
@@ -376,73 +362,73 @@ function j({ feedbackId: n, accent: t, p: o, font: s }) {
|
|
|
376
362
|
display: "inline-flex",
|
|
377
363
|
alignItems: "center",
|
|
378
364
|
gap: 8,
|
|
379
|
-
border: `1px solid ${
|
|
380
|
-
background:
|
|
365
|
+
border: `1px solid ${o.userVote === "UP" ? n : t.border}`,
|
|
366
|
+
background: o.userVote === "UP" ? `${n}15` : t.bgSoft,
|
|
381
367
|
borderRadius: 12,
|
|
382
368
|
padding: "10px 16px",
|
|
383
369
|
cursor: "pointer",
|
|
384
|
-
fontFamily:
|
|
370
|
+
fontFamily: h
|
|
385
371
|
},
|
|
386
372
|
children: [
|
|
387
|
-
/* @__PURE__ */ e(R, { color:
|
|
388
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 18, fontWeight: 700, color:
|
|
389
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 13, color:
|
|
373
|
+
/* @__PURE__ */ e(R, { color: n, size: 13 }),
|
|
374
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 18, fontWeight: 700, color: t.text }, children: o.upvotes }),
|
|
375
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 13, color: t.textFaint }, children: o.userVote === "UP" ? "Upvoted" : "Upvote" })
|
|
390
376
|
]
|
|
391
377
|
}
|
|
392
378
|
),
|
|
393
|
-
|
|
394
|
-
/* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color:
|
|
395
|
-
|
|
379
|
+
o.comments.length > 0 && /* @__PURE__ */ r("div", { style: { marginTop: 28, borderTop: `1px solid ${t.border}`, paddingTop: 20 }, children: [
|
|
380
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: t.textFaint, marginBottom: 12, textTransform: "uppercase" }, children: "Developer response" }),
|
|
381
|
+
o.comments.map((a) => /* @__PURE__ */ e(Y, { comment: a, p: t, accent: n }, a.id))
|
|
396
382
|
] })
|
|
397
383
|
] });
|
|
398
384
|
}
|
|
399
|
-
function
|
|
400
|
-
return /* @__PURE__ */ r("div", { style: { background:
|
|
385
|
+
function Y({ comment: i, p: n, accent: t }) {
|
|
386
|
+
return /* @__PURE__ */ r("div", { style: { background: n.bgSoft, border: `1px solid ${n.border}`, borderRadius: 12, padding: 14, marginBottom: 10 }, children: [
|
|
401
387
|
/* @__PURE__ */ r("div", { style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 8 }, children: [
|
|
402
|
-
/* @__PURE__ */ e("span", { style: { background: `${
|
|
403
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 11, color:
|
|
388
|
+
/* @__PURE__ */ e("span", { style: { background: `${t}20`, color: t, fontSize: 11, fontWeight: 700, borderRadius: 20, padding: "2px 8px" }, children: "Developer" }),
|
|
389
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 11, color: n.textFaint }, children: M(i.createdAt) })
|
|
404
390
|
] }),
|
|
405
|
-
/* @__PURE__ */ e("p", { style: { fontSize: 14, lineHeight: 1.5, color:
|
|
391
|
+
/* @__PURE__ */ e("p", { style: { fontSize: 14, lineHeight: 1.5, color: n.textSoft, margin: 0 }, children: i.content })
|
|
406
392
|
] });
|
|
407
393
|
}
|
|
408
|
-
function
|
|
409
|
-
const { submit:
|
|
394
|
+
function q({ accent: i, p: n, font: t, onDone: h }) {
|
|
395
|
+
const { submit: g } = B(), [l, o] = p(""), [u, x] = p(""), [d, y] = p("GENERAL"), [c, a] = p(!1), [b, F] = p(!1), [S, f] = p("");
|
|
410
396
|
async function v() {
|
|
411
|
-
if (!(!
|
|
412
|
-
|
|
397
|
+
if (!(!l.trim() || c)) {
|
|
398
|
+
a(!0), f("");
|
|
413
399
|
try {
|
|
414
|
-
await
|
|
400
|
+
await g(l.trim(), u.trim() || l.trim(), d), F(!0), setTimeout(h, 1200);
|
|
415
401
|
} catch {
|
|
416
|
-
|
|
402
|
+
f("Something went wrong. Please try again.");
|
|
417
403
|
} finally {
|
|
418
|
-
|
|
404
|
+
a(!1);
|
|
419
405
|
}
|
|
420
406
|
}
|
|
421
407
|
}
|
|
422
|
-
if (
|
|
408
|
+
if (b)
|
|
423
409
|
return /* @__PURE__ */ r("div", { style: { textAlign: "center", paddingTop: 40 }, children: [
|
|
424
|
-
/* @__PURE__ */ e("div", { style: { fontSize: 18, fontWeight: 700, color:
|
|
425
|
-
/* @__PURE__ */ e("div", { style: { fontSize: 14, color:
|
|
410
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 18, fontWeight: 700, color: n.text, marginBottom: 6 }, children: "Submitted" }),
|
|
411
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 14, color: n.textFaint }, children: "Feedback received. Thank you." })
|
|
426
412
|
] });
|
|
427
|
-
const
|
|
413
|
+
const m = {
|
|
428
414
|
width: "100%",
|
|
429
|
-
border: `1px solid ${
|
|
415
|
+
border: `1px solid ${n.border}`,
|
|
430
416
|
borderRadius: 12,
|
|
431
417
|
padding: "10px 12px",
|
|
432
418
|
fontSize: 14,
|
|
433
419
|
lineHeight: 1.5,
|
|
434
420
|
outline: "none",
|
|
435
|
-
background:
|
|
436
|
-
color:
|
|
437
|
-
fontFamily:
|
|
421
|
+
background: n.bgSoft,
|
|
422
|
+
color: n.text,
|
|
423
|
+
fontFamily: t,
|
|
438
424
|
boxSizing: "border-box"
|
|
439
425
|
};
|
|
440
426
|
return /* @__PURE__ */ r("div", { children: [
|
|
441
|
-
/* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color:
|
|
442
|
-
/* @__PURE__ */ e("div", { style: { display: "flex", gap: 7, marginBottom: 16 }, children: ["BUG", "FEATURE", "GENERAL"].map((
|
|
427
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: n.textFaint, marginBottom: 8, textTransform: "uppercase" }, children: "Type" }),
|
|
428
|
+
/* @__PURE__ */ e("div", { style: { display: "flex", gap: 7, marginBottom: 16 }, children: ["BUG", "FEATURE", "GENERAL"].map((s) => /* @__PURE__ */ r(
|
|
443
429
|
"button",
|
|
444
430
|
{
|
|
445
|
-
onClick: () => y(
|
|
431
|
+
onClick: () => y(s),
|
|
446
432
|
style: {
|
|
447
433
|
flex: 1,
|
|
448
434
|
display: "flex",
|
|
@@ -454,69 +440,69 @@ function _({ accent: n, p: t, font: o, onDone: s }) {
|
|
|
454
440
|
fontSize: 12.5,
|
|
455
441
|
fontWeight: 600,
|
|
456
442
|
cursor: "pointer",
|
|
457
|
-
background:
|
|
458
|
-
color:
|
|
459
|
-
border: `1px solid ${
|
|
460
|
-
fontFamily:
|
|
443
|
+
background: d === s ? i : n.bg,
|
|
444
|
+
color: d === s ? "#fff" : n.textSoft,
|
|
445
|
+
border: `1px solid ${d === s ? i : n.border}`,
|
|
446
|
+
fontFamily: t
|
|
461
447
|
},
|
|
462
448
|
children: [
|
|
463
|
-
|
|
464
|
-
|
|
449
|
+
W[s].icon,
|
|
450
|
+
W[s].label
|
|
465
451
|
]
|
|
466
452
|
},
|
|
467
|
-
|
|
453
|
+
s
|
|
468
454
|
)) }),
|
|
469
|
-
/* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color:
|
|
455
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: n.textFaint, marginBottom: 8, textTransform: "uppercase" }, children: "Title" }),
|
|
470
456
|
/* @__PURE__ */ e(
|
|
471
457
|
"input",
|
|
472
458
|
{
|
|
473
|
-
value:
|
|
474
|
-
onChange: (
|
|
459
|
+
value: l,
|
|
460
|
+
onChange: (s) => o(s.target.value),
|
|
475
461
|
placeholder: "Short summary of the issue or idea",
|
|
476
462
|
maxLength: 200,
|
|
477
|
-
style: { ...
|
|
463
|
+
style: { ...m, marginBottom: 16, display: "block" }
|
|
478
464
|
}
|
|
479
465
|
),
|
|
480
|
-
/* @__PURE__ */ r("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color:
|
|
466
|
+
/* @__PURE__ */ r("div", { style: { fontSize: 10, fontWeight: 700, letterSpacing: ".08em", color: n.textFaint, marginBottom: 8, textTransform: "uppercase" }, children: [
|
|
481
467
|
"Description ",
|
|
482
468
|
/* @__PURE__ */ e("span", { style: { fontWeight: 400, textTransform: "none", letterSpacing: 0 }, children: "(optional)" })
|
|
483
469
|
] }),
|
|
484
470
|
/* @__PURE__ */ e(
|
|
485
471
|
"textarea",
|
|
486
472
|
{
|
|
487
|
-
value:
|
|
488
|
-
onChange: (
|
|
473
|
+
value: u,
|
|
474
|
+
onChange: (s) => x(s.target.value),
|
|
489
475
|
placeholder: "Steps to reproduce, expected behaviour, or more context",
|
|
490
476
|
maxLength: 2e3,
|
|
491
477
|
rows: 4,
|
|
492
|
-
style: { ...
|
|
478
|
+
style: { ...m, resize: "vertical", marginBottom: 16 }
|
|
493
479
|
}
|
|
494
480
|
),
|
|
495
|
-
|
|
481
|
+
S && /* @__PURE__ */ e("p", { style: { fontSize: 13, color: "#d6453d", marginBottom: 12 }, children: S }),
|
|
496
482
|
/* @__PURE__ */ e(
|
|
497
483
|
"button",
|
|
498
484
|
{
|
|
499
485
|
onClick: v,
|
|
500
|
-
disabled: c || !
|
|
486
|
+
disabled: c || !l.trim(),
|
|
501
487
|
style: {
|
|
502
488
|
width: "100%",
|
|
503
489
|
padding: 12,
|
|
504
|
-
background:
|
|
490
|
+
background: i,
|
|
505
491
|
color: "#fff",
|
|
506
492
|
border: "none",
|
|
507
493
|
borderRadius: 11,
|
|
508
494
|
fontSize: 14,
|
|
509
495
|
fontWeight: 600,
|
|
510
496
|
cursor: "pointer",
|
|
511
|
-
opacity: c || !
|
|
512
|
-
fontFamily:
|
|
497
|
+
opacity: c || !l.trim() ? 0.5 : 1,
|
|
498
|
+
fontFamily: t
|
|
513
499
|
},
|
|
514
500
|
children: c ? "Submitting…" : "Submit feedback"
|
|
515
501
|
}
|
|
516
502
|
)
|
|
517
503
|
] });
|
|
518
504
|
}
|
|
519
|
-
const
|
|
505
|
+
const W = {
|
|
520
506
|
BUG: {
|
|
521
507
|
label: "Bug",
|
|
522
508
|
icon: /* @__PURE__ */ r("svg", { width: 12, height: 12, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
@@ -535,48 +521,48 @@ const z = {
|
|
|
535
521
|
label: "General",
|
|
536
522
|
icon: /* @__PURE__ */ e("svg", { width: 12, height: 12, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z" }) })
|
|
537
523
|
}
|
|
538
|
-
},
|
|
539
|
-
function T({ type:
|
|
524
|
+
}, K = { BUG: "#fdecec", FEATURE: "#e9f0fd" }, J = { BUG: "#d6453d", FEATURE: "#3b76d6" };
|
|
525
|
+
function T({ type: i, p: n }) {
|
|
540
526
|
return /* @__PURE__ */ e("span", { style: {
|
|
541
527
|
padding: "2px 8px",
|
|
542
528
|
borderRadius: 9999,
|
|
543
529
|
fontSize: 10.5,
|
|
544
530
|
fontWeight: 700,
|
|
545
531
|
letterSpacing: ".02em",
|
|
546
|
-
background:
|
|
547
|
-
color:
|
|
548
|
-
}, children:
|
|
532
|
+
background: K[i] ?? n.bgSoft,
|
|
533
|
+
color: J[i] ?? n.textSoft
|
|
534
|
+
}, children: i });
|
|
549
535
|
}
|
|
550
|
-
const
|
|
536
|
+
const Q = {
|
|
551
537
|
OPEN: "#b45309",
|
|
552
538
|
IN_PROGRESS: "#1d4ed8",
|
|
553
539
|
DONE: "#15803d",
|
|
554
540
|
CLOSED: "#6b7280"
|
|
555
541
|
};
|
|
556
|
-
function
|
|
542
|
+
function L() {
|
|
557
543
|
return /* @__PURE__ */ r("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: [
|
|
558
544
|
/* @__PURE__ */ e("span", { style: { width: 5, height: 5, borderRadius: "50%", background: "#ea580c", display: "inline-block" } }),
|
|
559
545
|
"Pending review"
|
|
560
546
|
] });
|
|
561
547
|
}
|
|
562
|
-
function U({ status:
|
|
563
|
-
const
|
|
564
|
-
return /* @__PURE__ */ r("span", { style: { display: "inline-flex", alignItems: "center", gap: 5, background:
|
|
565
|
-
/* @__PURE__ */ e("span", { style: { width: 6, height: 6, borderRadius: "50%", background:
|
|
566
|
-
|
|
548
|
+
function U({ status: i, p: n }) {
|
|
549
|
+
const t = Q[i] ?? "#9ca3af";
|
|
550
|
+
return /* @__PURE__ */ r("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: [
|
|
551
|
+
/* @__PURE__ */ e("span", { style: { width: 6, height: 6, borderRadius: "50%", background: t, display: "inline-block", flexShrink: 0 } }),
|
|
552
|
+
i.replace("_", " ")
|
|
567
553
|
] });
|
|
568
554
|
}
|
|
569
|
-
function
|
|
570
|
-
return /* @__PURE__ */ e("svg", { width:
|
|
555
|
+
function X({ size: i = 16, color: n = "currentColor" }) {
|
|
556
|
+
return /* @__PURE__ */ e("svg", { width: i, height: i, viewBox: "0 0 24 24", fill: "none", stroke: n, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) });
|
|
571
557
|
}
|
|
572
|
-
function R({ color:
|
|
573
|
-
return /* @__PURE__ */ e("svg", { width:
|
|
558
|
+
function R({ color: i = "currentColor", size: n = 11 }) {
|
|
559
|
+
return /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 16 16", fill: "none", stroke: i, strokeWidth: 2.2, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M8 13V3M3 8l5-5 5 5" }) });
|
|
574
560
|
}
|
|
575
|
-
function
|
|
576
|
-
return new Date(
|
|
561
|
+
function M(i) {
|
|
562
|
+
return new Date(i).toLocaleDateString(void 0, { month: "short", day: "numeric" });
|
|
577
563
|
}
|
|
578
564
|
export {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
565
|
+
oe as FeedbackWidget,
|
|
566
|
+
ne as UpstepProvider,
|
|
567
|
+
B as useUpstep
|
|
582
568
|
};
|