@upstep/js 0.5.12 → 0.6.0

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