@mrrocket/sdk 0.4.0 → 0.9.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/CHANGELOG.md +43 -0
- package/README.md +137 -8
- package/dist/api-client.d.ts +213 -0
- package/dist/api-client.js +67 -0
- package/dist/api-client.js.map +1 -0
- package/dist/api.d.ts +9 -109
- package/dist/api.js +7 -62
- package/dist/api.js.map +1 -1
- package/dist/browser/mrrocket-flows.js +64 -0
- package/dist/browser/mrrocket-messenger.js +313 -0
- package/dist/browser/mrrocket-push.js +1 -0
- package/dist/browser/mrrocket-replay.js +3 -3
- package/dist/browser/mrrocket-sw.js +1 -0
- package/dist/browser/mrrocket.js +2 -1
- package/dist/browser.d.ts +3 -2
- package/dist/browser.js +6 -1
- package/dist/browser.js.map +1 -1
- package/dist/capture.d.ts +1 -13
- package/dist/capture.js +1 -22
- package/dist/capture.js.map +1 -1
- package/dist/client.d.ts +36 -1
- package/dist/client.js +161 -6
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +10 -0
- package/dist/context.js.map +1 -1
- package/dist/core.d.ts +64 -3
- package/dist/core.js +54 -2
- package/dist/core.js.map +1 -1
- package/dist/feedback.d.ts +19 -4
- package/dist/feedback.js +655 -190
- package/dist/feedback.js.map +1 -1
- package/dist/flows-ui.d.ts +23 -0
- package/dist/flows-ui.js +384 -0
- package/dist/flows-ui.js.map +1 -0
- package/dist/flows-web.d.ts +19 -0
- package/dist/flows-web.js +42 -0
- package/dist/flows-web.js.map +1 -0
- package/dist/flows.d.ts +222 -0
- package/dist/flows.js +409 -0
- package/dist/flows.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/messenger-ui.d.ts +47 -0
- package/dist/messenger-ui.js +583 -0
- package/dist/messenger-ui.js.map +1 -0
- package/dist/messenger.d.ts +37 -0
- package/dist/messenger.js +69 -0
- package/dist/messenger.js.map +1 -0
- package/dist/proxy.d.ts +34 -1
- package/dist/proxy.js +14 -1
- package/dist/proxy.js.map +1 -1
- package/dist/push-web.d.ts +43 -0
- package/dist/push-web.js +81 -0
- package/dist/push-web.js.map +1 -0
- package/dist/rage.d.ts +14 -0
- package/dist/rage.js +27 -0
- package/dist/rage.js.map +1 -0
- package/dist/react-native/index.d.cts +640 -3
- package/dist/react-native/index.d.ts +640 -3
- package/dist/react-native/index.js +2015 -34
- package/dist/react-native/index.js.map +1 -1
- package/dist/styles-css.d.ts +6 -0
- package/dist/styles-css.js +327 -0
- package/dist/styles-css.js.map +1 -0
- package/dist/styles.d.ts +1 -2
- package/dist/styles.js +3 -134
- package/dist/styles.js.map +1 -1
- package/dist/ui.d.ts +3 -0
- package/dist/ui.js +12 -0
- package/dist/ui.js.map +1 -1
- package/package.json +20 -4
package/dist/feedback.js
CHANGED
|
@@ -1,14 +1,71 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/feedback.tsx
|
|
4
|
-
import { useCallback, useEffect, useId, useRef, useState } from "react";
|
|
5
|
-
import {
|
|
6
|
-
|
|
4
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
5
|
+
import {
|
|
6
|
+
createApi,
|
|
7
|
+
useApi
|
|
8
|
+
} from "./api.js";
|
|
9
|
+
import { useCtx } from "./context.js";
|
|
10
|
+
import { Chat, ChevronUp, Cross, Moon, Plus, Root, Search, StatusPill, Sun, VoteButton, similarPosts, timeAgo, useEscape } from "./ui.js";
|
|
7
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
var
|
|
9
|
-
|
|
12
|
+
var whoKey = (apiKey) => `ckw-board-who:${apiKey}`;
|
|
13
|
+
var readWho = (apiKey) => {
|
|
14
|
+
try {
|
|
15
|
+
const raw = window.localStorage.getItem(whoKey(apiKey));
|
|
16
|
+
const w = raw ? JSON.parse(raw) : null;
|
|
17
|
+
return w && typeof w.id === "string" && typeof w.name === "string" && typeof w.email === "string" ? w : null;
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var newWhoId = () => {
|
|
23
|
+
try {
|
|
24
|
+
return `fb_${crypto.randomUUID()}`;
|
|
25
|
+
} catch {
|
|
26
|
+
return `fb_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 10)}`;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
30
|
+
var useIdentity = () => {
|
|
31
|
+
const ctx = useCtx();
|
|
32
|
+
const [saved, setSaved] = useState(null);
|
|
33
|
+
const [asking, setAsking] = useState(null);
|
|
34
|
+
useEffect(() => setSaved(readWho(ctx.apiKey)), [ctx.apiKey]);
|
|
35
|
+
const fromApp = !!ctx.user && (!!ctx.user.email || !!ctx.user.name);
|
|
36
|
+
const writer = useMemo(
|
|
37
|
+
() => fromApp || !saved ? null : { distinctId: saved.id, user: { name: saved.name, email: saved.email } },
|
|
38
|
+
[fromApp, saved]
|
|
39
|
+
);
|
|
40
|
+
const api = useApi(writer);
|
|
41
|
+
const known = fromApp || !!saved;
|
|
42
|
+
const save = useCallback(
|
|
43
|
+
(name2, email) => {
|
|
44
|
+
const who = { id: saved?.id ?? newWhoId(), name: name2.trim(), email: email.trim().toLowerCase() };
|
|
45
|
+
try {
|
|
46
|
+
window.localStorage.setItem(whoKey(ctx.apiKey), JSON.stringify(who));
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
setSaved(who);
|
|
50
|
+
return createApi({ apiKey: ctx.apiKey, host: ctx.host, distinctId: who.id, user: { name: who.name, email: who.email } });
|
|
51
|
+
},
|
|
52
|
+
[ctx.apiKey, ctx.host, saved]
|
|
53
|
+
);
|
|
54
|
+
const forget = useCallback(() => {
|
|
55
|
+
try {
|
|
56
|
+
window.localStorage.removeItem(whoKey(ctx.apiKey));
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
setSaved(null);
|
|
60
|
+
}, [ctx.apiKey]);
|
|
61
|
+
const need = useCallback((fn) => known ? fn(api) : setAsking(() => fn), [known, api]);
|
|
62
|
+
const name = fromApp ? String(ctx.user?.name ?? ctx.user?.email ?? "") : saved?.name ?? "";
|
|
63
|
+
return { api, known, fromApp, name, save, forget, need, asking, cancel: () => setAsking(null) };
|
|
64
|
+
};
|
|
65
|
+
var useFeedbackList = (api, opts) => {
|
|
10
66
|
const [posts, setPosts] = useState([]);
|
|
11
67
|
const [boards, setBoards] = useState([]);
|
|
68
|
+
const [product, setProduct] = useState(null);
|
|
12
69
|
const [loading, setLoading] = useState(true);
|
|
13
70
|
const [error, setError] = useState("");
|
|
14
71
|
const [tick, setTick] = useState(0);
|
|
@@ -21,6 +78,7 @@ var useFeedbackList = (opts) => {
|
|
|
21
78
|
api.list({ board, sort, q: q?.trim() || void 0 }, ctl.signal).then((r) => {
|
|
22
79
|
setPosts(r.posts);
|
|
23
80
|
setBoards(r.boards);
|
|
81
|
+
if (r.product) setProduct(r.product);
|
|
24
82
|
setError("");
|
|
25
83
|
setLoading(false);
|
|
26
84
|
}).catch((e) => {
|
|
@@ -38,41 +96,124 @@ var useFeedbackList = (opts) => {
|
|
|
38
96
|
}, [api, board, sort, q, tick]);
|
|
39
97
|
const patch = useCallback((id, fn) => setPosts((all) => all.map((p) => p.id === id ? fn(p) : p)), []);
|
|
40
98
|
const vote = useCallback(
|
|
41
|
-
(post) => {
|
|
99
|
+
(post, as = api) => {
|
|
42
100
|
const flip = (p) => ({ ...p, voted: !p.voted, votes: p.votes + (p.voted ? -1 : 1) });
|
|
43
101
|
patch(post.id, flip);
|
|
44
|
-
|
|
102
|
+
as.vote(post.id).then((r) => patch(post.id, (p) => ({ ...p, voted: r.voted, votes: r.votes }))).catch((e) => {
|
|
45
103
|
patch(post.id, flip);
|
|
46
104
|
setError(`Your vote was not saved. ${e.message}`);
|
|
47
105
|
});
|
|
48
106
|
},
|
|
49
107
|
[api, patch]
|
|
50
108
|
);
|
|
51
|
-
return {
|
|
109
|
+
return { posts, setPosts, patch, boards, product, loading, error, setError, vote, reload: () => setTick((t) => t + 1) };
|
|
110
|
+
};
|
|
111
|
+
var BOARD_TONE = { feature: "blue", bug: "red", integration: "violet", improvement: "green" };
|
|
112
|
+
var TypeChip = ({ board, boards }) => /* @__PURE__ */ jsx("span", { className: "ckw-type", "data-tone": BOARD_TONE[board] ?? "gray", children: boards.find((b) => b.id === board)?.label ?? board });
|
|
113
|
+
var Avatar = ({ name, team }) => /* @__PURE__ */ jsx("span", { className: "ckw-av", "data-team": team || void 0, "aria-hidden": "true", children: (name.trim()[0] ?? "?").toUpperCase() });
|
|
114
|
+
var Skeleton = ({ rows = 3 }) => /* @__PURE__ */ jsx("div", { "aria-hidden": "true", children: Array.from({ length: rows }, (_, i) => /* @__PURE__ */ jsx("div", { className: "ckw-skel" }, i)) });
|
|
115
|
+
var ErrorBar = ({ message, onRetry, onClose }) => /* @__PURE__ */ jsxs("div", { className: "ckw-error", role: "alert", children: [
|
|
116
|
+
/* @__PURE__ */ jsx("span", { children: message }),
|
|
117
|
+
onRetry ? /* @__PURE__ */ jsx("button", { type: "button", className: "ckw-btn", onClick: onRetry, children: "Retry" }) : onClose && /* @__PURE__ */ jsx("button", { type: "button", className: "ckw-btn ckw-btn-ghost", onClick: onClose, "aria-label": "Dismiss", children: /* @__PURE__ */ jsx(Cross, {}) })
|
|
118
|
+
] });
|
|
119
|
+
var Modal = ({ title, onClose, children }) => {
|
|
120
|
+
const box = useRef(null);
|
|
121
|
+
const id = useId();
|
|
122
|
+
useEscape(onClose);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
const before = document.activeElement;
|
|
125
|
+
box.current?.querySelector("input, textarea, button")?.focus();
|
|
126
|
+
return () => before?.focus?.();
|
|
127
|
+
}, []);
|
|
128
|
+
const trap = (e) => {
|
|
129
|
+
if (e.key !== "Tab" || !box.current) return;
|
|
130
|
+
const f = [...box.current.querySelectorAll("a[href], button:not([disabled]), input, select, textarea")];
|
|
131
|
+
if (!f.length) return;
|
|
132
|
+
const first = f[0];
|
|
133
|
+
const last = f[f.length - 1];
|
|
134
|
+
if (e.shiftKey && document.activeElement === first) e.preventDefault(), last.focus();
|
|
135
|
+
else if (!e.shiftKey && document.activeElement === last) e.preventDefault(), first.focus();
|
|
136
|
+
};
|
|
137
|
+
return /* @__PURE__ */ jsx("div", { className: "ckw-scrim", onMouseDown: (e) => e.target === e.currentTarget && onClose(), children: /* @__PURE__ */ jsxs("div", { ref: box, className: "ckw-modal", role: "dialog", "aria-modal": "true", "aria-labelledby": id, onKeyDown: trap, children: [
|
|
138
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-modal-head", children: [
|
|
139
|
+
/* @__PURE__ */ jsx("h2", { id, children: title }),
|
|
140
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "ckw-icon-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx(Cross, {}) })
|
|
141
|
+
] }),
|
|
142
|
+
children
|
|
143
|
+
] }) });
|
|
144
|
+
};
|
|
145
|
+
var IdentityFields = ({ name, email, setName, setEmail }) => {
|
|
146
|
+
const id = useId();
|
|
147
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
148
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-pair", children: [
|
|
149
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-field", children: [
|
|
150
|
+
/* @__PURE__ */ jsx("label", { className: "ckw-label", htmlFor: `${id}-n`, children: "Your name" }),
|
|
151
|
+
/* @__PURE__ */ jsx("input", { id: `${id}-n`, className: "ckw-input", value: name, maxLength: 80, required: true, autoComplete: "name", onChange: (e) => setName(e.target.value) })
|
|
152
|
+
] }),
|
|
153
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-field", children: [
|
|
154
|
+
/* @__PURE__ */ jsx("label", { className: "ckw-label", htmlFor: `${id}-e`, children: "Email" }),
|
|
155
|
+
/* @__PURE__ */ jsx("input", { id: `${id}-e`, className: "ckw-input", type: "email", value: email, maxLength: 200, required: true, autoComplete: "email", onChange: (e) => setEmail(e.target.value) })
|
|
156
|
+
] })
|
|
157
|
+
] }),
|
|
158
|
+
/* @__PURE__ */ jsx("p", { className: "ckw-fine", children: "Others see your first name and last initial. Your email is only for updates on what you posted or voted for." })
|
|
159
|
+
] });
|
|
160
|
+
};
|
|
161
|
+
var IdentityDialog = ({ identity }) => {
|
|
162
|
+
const [name, setName] = useState("");
|
|
163
|
+
const [email, setEmail] = useState("");
|
|
164
|
+
const ok = name.trim().length > 0 && EMAIL.test(email.trim());
|
|
165
|
+
const run = identity.asking;
|
|
166
|
+
if (!run) return null;
|
|
167
|
+
return /* @__PURE__ */ jsx(Modal, { title: "Before you vote or comment", onClose: identity.cancel, children: /* @__PURE__ */ jsxs(
|
|
168
|
+
"form",
|
|
169
|
+
{
|
|
170
|
+
className: "ckw-modal-body",
|
|
171
|
+
onSubmit: (e) => {
|
|
172
|
+
e.preventDefault();
|
|
173
|
+
if (!ok) return;
|
|
174
|
+
const api = identity.save(name, email);
|
|
175
|
+
identity.cancel();
|
|
176
|
+
run(api);
|
|
177
|
+
},
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ jsx(IdentityFields, { name, email, setName, setEmail }),
|
|
180
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-actions", children: [
|
|
181
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "ckw-btn ckw-btn-ghost", onClick: identity.cancel, children: "Cancel" }),
|
|
182
|
+
/* @__PURE__ */ jsx("button", { type: "submit", className: "ckw-btn ckw-btn-primary", disabled: !ok, children: "Continue" })
|
|
183
|
+
] })
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
) });
|
|
52
187
|
};
|
|
53
188
|
var SubmitForm = ({
|
|
54
|
-
|
|
189
|
+
identity,
|
|
55
190
|
boards,
|
|
56
191
|
posts,
|
|
57
192
|
onCreated,
|
|
58
193
|
onVote,
|
|
59
194
|
onCancel,
|
|
60
|
-
compact
|
|
195
|
+
compact,
|
|
196
|
+
bare
|
|
61
197
|
}) => {
|
|
62
198
|
const id = useId();
|
|
63
199
|
const [title, setTitle] = useState("");
|
|
64
200
|
const [body, setBody] = useState("");
|
|
65
201
|
const [board, setBoard] = useState("");
|
|
202
|
+
const [name, setName] = useState("");
|
|
203
|
+
const [email, setEmail] = useState("");
|
|
66
204
|
const [busy, setBusy] = useState(false);
|
|
67
205
|
const [error, setError] = useState("");
|
|
68
206
|
const chosen = board || boards[0]?.id || "";
|
|
69
207
|
const dupes = similarPosts(title, posts);
|
|
208
|
+
const ask = !identity.known;
|
|
209
|
+
const ready = title.trim().length >= 3 && (!ask || name.trim().length > 0 && EMAIL.test(email.trim()));
|
|
70
210
|
const submit = async (e) => {
|
|
71
211
|
e.preventDefault();
|
|
72
|
-
if (!
|
|
212
|
+
if (!ready || busy) return;
|
|
73
213
|
setBusy(true);
|
|
74
214
|
setError("");
|
|
75
215
|
try {
|
|
216
|
+
const api = ask ? identity.save(name, email) : identity.api;
|
|
76
217
|
const created = await api.submit({ title: title.trim(), body: body.trim() || void 0, board: chosen });
|
|
77
218
|
setTitle("");
|
|
78
219
|
setBody("");
|
|
@@ -83,10 +224,10 @@ var SubmitForm = ({
|
|
|
83
224
|
setBusy(false);
|
|
84
225
|
}
|
|
85
226
|
};
|
|
86
|
-
return /* @__PURE__ */ jsxs("form", { className: "ckw-form", onSubmit: submit, children: [
|
|
227
|
+
return /* @__PURE__ */ jsxs("form", { className: bare ? "ckw-modal-body" : "ckw-form", onSubmit: submit, children: [
|
|
87
228
|
/* @__PURE__ */ jsxs("div", { className: "ckw-field", children: [
|
|
88
229
|
/* @__PURE__ */ jsx("label", { className: "ckw-label", htmlFor: `${id}-t`, children: "Title" }),
|
|
89
|
-
/* @__PURE__ */ jsx("input", { id: `${id}-t`, className: "ckw-input", value: title, maxLength:
|
|
230
|
+
/* @__PURE__ */ jsx("input", { id: `${id}-t`, className: "ckw-input", value: title, maxLength: 120, required: true, autoFocus: true, onChange: (e) => setTitle(e.target.value), placeholder: "Short, specific summary" })
|
|
90
231
|
] }),
|
|
91
232
|
dupes.length > 0 && /* @__PURE__ */ jsxs("div", { className: "ckw-dupes", role: "status", children: [
|
|
92
233
|
/* @__PURE__ */ jsx("p", { children: "Similar requests. Vote instead of adding a duplicate:" }),
|
|
@@ -96,116 +237,223 @@ var SubmitForm = ({
|
|
|
96
237
|
] }, d.id))
|
|
97
238
|
] }),
|
|
98
239
|
!compact && /* @__PURE__ */ jsxs("div", { className: "ckw-field", children: [
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
|
|
240
|
+
/* @__PURE__ */ jsxs("label", { className: "ckw-label", htmlFor: `${id}-b`, children: [
|
|
241
|
+
"Details ",
|
|
242
|
+
/* @__PURE__ */ jsx("span", { className: "ckw-opt-l", children: "optional" })
|
|
243
|
+
] }),
|
|
244
|
+
/* @__PURE__ */ jsx("textarea", { id: `${id}-b`, className: "ckw-textarea", value: body, maxLength: 2e3, onChange: (e) => setBody(e.target.value), placeholder: "What are you trying to do? What gets in the way?" })
|
|
101
245
|
] }),
|
|
102
246
|
boards.length > 1 && /* @__PURE__ */ jsxs("div", { className: "ckw-field", children: [
|
|
103
|
-
/* @__PURE__ */ jsx("
|
|
104
|
-
/* @__PURE__ */ jsx("
|
|
247
|
+
/* @__PURE__ */ jsx("span", { className: "ckw-label", id: `${id}-c`, children: "Type" }),
|
|
248
|
+
/* @__PURE__ */ jsx("div", { className: "ckw-chips", role: "radiogroup", "aria-labelledby": `${id}-c`, style: { marginBottom: 0 }, children: boards.map((b) => /* @__PURE__ */ jsx("button", { type: "button", role: "radio", "aria-checked": chosen === b.id, className: "ckw-chip", onClick: () => setBoard(b.id), children: b.label }, b.id)) })
|
|
105
249
|
] }),
|
|
250
|
+
ask && /* @__PURE__ */ jsx(IdentityFields, { name, email, setName, setEmail }),
|
|
106
251
|
error && /* @__PURE__ */ jsx("div", { className: "ckw-error", role: "alert", children: error }),
|
|
107
252
|
/* @__PURE__ */ jsxs("div", { className: "ckw-actions", children: [
|
|
108
253
|
onCancel && /* @__PURE__ */ jsx("button", { type: "button", className: "ckw-btn ckw-btn-ghost", onClick: onCancel, children: "Cancel" }),
|
|
109
|
-
/* @__PURE__ */ jsx("button", { type: "submit", className: "ckw-btn ckw-btn-primary", disabled: busy || !
|
|
254
|
+
/* @__PURE__ */ jsx("button", { type: "submit", className: "ckw-btn ckw-btn-primary", disabled: busy || !ready, children: busy ? "Sending\u2026" : "Submit" })
|
|
110
255
|
] })
|
|
111
256
|
] });
|
|
112
257
|
};
|
|
113
|
-
var
|
|
258
|
+
var PostCard = ({ post, boards, onOpen, onVote }) => /* @__PURE__ */ jsxs("li", { className: "ckw-post", children: [
|
|
114
259
|
/* @__PURE__ */ jsx(VoteButton, { post, onVote }),
|
|
115
260
|
/* @__PURE__ */ jsxs("div", { className: "ckw-main", children: [
|
|
116
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "ckw-link", onClick: () => onOpen(post), children: post.title }),
|
|
261
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "ckw-link ckw-stretch", onClick: () => onOpen(post), children: post.title }),
|
|
117
262
|
post.body && /* @__PURE__ */ jsx("p", { className: "ckw-excerpt", children: post.body }),
|
|
118
263
|
/* @__PURE__ */ jsxs("div", { className: "ckw-meta", children: [
|
|
119
|
-
/* @__PURE__ */ jsx(
|
|
120
|
-
/* @__PURE__ */
|
|
264
|
+
/* @__PURE__ */ jsx(TypeChip, { board: post.board, boards }),
|
|
265
|
+
post.status !== "review" && /* @__PURE__ */ jsx(StatusPill, { status: post.status }),
|
|
266
|
+
/* @__PURE__ */ jsxs("span", { className: "ckw-stat", "aria-label": `${post.comments} comments`, children: [
|
|
121
267
|
/* @__PURE__ */ jsx(Chat, {}),
|
|
122
268
|
" ",
|
|
123
269
|
post.comments
|
|
124
270
|
] }),
|
|
125
|
-
/* @__PURE__ */ jsx("span", { children: timeAgo(post.createdAt) })
|
|
271
|
+
/* @__PURE__ */ jsx("span", { className: "ckw-dot-sep", children: [post.author, timeAgo(post.createdAt)].filter(Boolean).join(" \xB7 ") })
|
|
126
272
|
] })
|
|
127
273
|
] })
|
|
128
274
|
] });
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
275
|
+
var Requests = ({
|
|
276
|
+
list,
|
|
277
|
+
sort,
|
|
278
|
+
setSort,
|
|
279
|
+
board,
|
|
280
|
+
setBoard,
|
|
281
|
+
q,
|
|
282
|
+
onOpen,
|
|
283
|
+
onVote,
|
|
284
|
+
onNew
|
|
285
|
+
}) => {
|
|
286
|
+
const { posts, boards } = list;
|
|
287
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { children: [
|
|
288
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-tools", children: [
|
|
289
|
+
/* @__PURE__ */ jsx("div", { className: "ckw-seg", role: "group", "aria-label": "Sort", children: ["top", "new"].map((s) => /* @__PURE__ */ jsx("button", { type: "button", "aria-pressed": sort === s, onClick: () => setSort(s), children: s === "top" ? "Top" : "New" }, s)) }),
|
|
290
|
+
boards.length > 1 && /* @__PURE__ */ jsxs("div", { className: "ckw-chips ckw-chips-inline", role: "group", "aria-label": "Type", children: [
|
|
291
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "ckw-chip", "aria-pressed": !board, onClick: () => setBoard(void 0), children: "All" }),
|
|
292
|
+
boards.map((b) => /* @__PURE__ */ jsx("button", { type: "button", className: "ckw-chip", "aria-pressed": board === b.id, onClick: () => setBoard(b.id), children: b.label }, b.id))
|
|
293
|
+
] })
|
|
294
|
+
] }),
|
|
295
|
+
/* @__PURE__ */ jsx("div", { "aria-live": "polite", "aria-busy": list.loading, children: list.loading && posts.length === 0 ? /* @__PURE__ */ jsx(Skeleton, {}) : posts.length === 0 && !list.error ? /* @__PURE__ */ jsxs("div", { className: "ckw-empty", children: [
|
|
296
|
+
/* @__PURE__ */ jsx("p", { children: q ? "No request matches your search." : board ? "Nothing of this type yet." : "No requests yet." }),
|
|
297
|
+
!q && /* @__PURE__ */ jsxs("button", { type: "button", className: "ckw-btn ckw-btn-primary", onClick: onNew, children: [
|
|
298
|
+
/* @__PURE__ */ jsx(Plus, {}),
|
|
299
|
+
" Suggest the first one"
|
|
300
|
+
] })
|
|
301
|
+
] }) : /* @__PURE__ */ jsx("ul", { className: "ckw-posts", children: posts.map((p) => /* @__PURE__ */ jsx(PostCard, { post: p, boards, onOpen, onVote }, p.id)) }) })
|
|
302
|
+
] }) });
|
|
303
|
+
};
|
|
304
|
+
var PostDetail = ({
|
|
305
|
+
post,
|
|
306
|
+
boards,
|
|
307
|
+
identity,
|
|
308
|
+
onBack,
|
|
309
|
+
onVote,
|
|
310
|
+
backLabel
|
|
311
|
+
}) => {
|
|
136
312
|
const id = useId();
|
|
137
313
|
const [comments, setComments] = useState(null);
|
|
138
314
|
const [error, setError] = useState("");
|
|
139
315
|
const [text, setText] = useState("");
|
|
140
316
|
const [busy, setBusy] = useState(false);
|
|
141
317
|
const [added, setAdded] = useState(0);
|
|
318
|
+
const { api } = identity;
|
|
142
319
|
useEffect(() => {
|
|
143
320
|
const ctl = new AbortController();
|
|
144
321
|
api.comments(post.id, ctl.signal).then((r) => setComments(r.comments)).catch((e) => e.name !== "AbortError" && setError(e.message));
|
|
145
322
|
return () => ctl.abort();
|
|
146
323
|
}, [api, post.id]);
|
|
147
|
-
const send =
|
|
324
|
+
const send = (e) => {
|
|
148
325
|
e.preventDefault();
|
|
149
326
|
const body = text.trim();
|
|
150
327
|
if (!body || busy) return;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
328
|
+
identity.need(async (as) => {
|
|
329
|
+
setBusy(true);
|
|
330
|
+
setError("");
|
|
331
|
+
const temp = { id: `tmp-${Date.now()}`, body, author: "You", isTeam: false, postedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
332
|
+
setComments((c) => [...c ?? [], temp]);
|
|
333
|
+
setText("");
|
|
334
|
+
try {
|
|
335
|
+
const real = await as.comment(post.id, body);
|
|
336
|
+
setComments((c) => (c ?? []).map((x) => x.id === temp.id ? real : x));
|
|
337
|
+
setAdded((n) => n + 1);
|
|
338
|
+
} catch (err) {
|
|
339
|
+
setComments((c) => (c ?? []).filter((x) => x.id !== temp.id));
|
|
340
|
+
setText(body);
|
|
341
|
+
setError(err.message);
|
|
342
|
+
} finally {
|
|
343
|
+
setBusy(false);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
167
346
|
};
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
"
|
|
347
|
+
const count = Math.max(post.comments + added, comments?.length ?? 0);
|
|
348
|
+
return /* @__PURE__ */ jsxs("article", { className: "ckw-detail", children: [
|
|
349
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "ckw-back", onClick: onBack, children: [
|
|
350
|
+
/* @__PURE__ */ jsx("span", { className: "ckw-back-icon", children: /* @__PURE__ */ jsx(ChevronUp, {}) }),
|
|
351
|
+
backLabel
|
|
172
352
|
] }),
|
|
173
|
-
/* @__PURE__ */ jsxs("div", { className: "ckw-detail-
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
|
|
176
|
-
/* @__PURE__ */
|
|
177
|
-
|
|
178
|
-
/* @__PURE__ */ jsx(
|
|
179
|
-
/* @__PURE__ */ jsx("span", { children: timeAgo(post.createdAt) })
|
|
353
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-detail-grid", children: [
|
|
354
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-detail-main", children: [
|
|
355
|
+
/* @__PURE__ */ jsx("h2", { className: "ckw-detail-title", children: post.title }),
|
|
356
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-byline", children: [
|
|
357
|
+
/* @__PURE__ */ jsx(Avatar, { name: post.author ?? "?", team: post.author === "Team" }),
|
|
358
|
+
/* @__PURE__ */ jsx("span", { children: post.author ?? "Someone" }),
|
|
359
|
+
/* @__PURE__ */ jsx("span", { className: "ckw-dot-sep", children: timeAgo(post.createdAt) })
|
|
360
|
+
] }),
|
|
361
|
+
post.body && /* @__PURE__ */ jsx("p", { className: "ckw-body", children: post.body }),
|
|
362
|
+
/* @__PURE__ */ jsxs("h3", { className: "ckw-h", children: [
|
|
363
|
+
"Comments ",
|
|
364
|
+
/* @__PURE__ */ jsx("span", { className: "ckw-count", children: count })
|
|
365
|
+
] }),
|
|
366
|
+
/* @__PURE__ */ jsxs("form", { className: "ckw-composer", onSubmit: send, children: [
|
|
367
|
+
/* @__PURE__ */ jsx("label", { className: "ckw-sr", htmlFor: id, children: "Leave a comment" }),
|
|
368
|
+
/* @__PURE__ */ jsx("textarea", { id, className: "ckw-textarea", value: text, maxLength: 1e3, placeholder: "Leave a comment", onChange: (e) => setText(e.target.value) }),
|
|
369
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-actions", children: [
|
|
370
|
+
identity.known && identity.name && /* @__PURE__ */ jsxs("span", { className: "ckw-fine ckw-as", children: [
|
|
371
|
+
"Commenting as ",
|
|
372
|
+
identity.name
|
|
373
|
+
] }),
|
|
374
|
+
/* @__PURE__ */ jsx("button", { type: "submit", className: "ckw-btn ckw-btn-primary", disabled: busy || !text.trim(), children: "Comment" })
|
|
375
|
+
] })
|
|
376
|
+
] }),
|
|
377
|
+
error && /* @__PURE__ */ jsx(ErrorBar, { message: error, onClose: () => setError("") }),
|
|
378
|
+
/* @__PURE__ */ jsxs("div", { "aria-live": "polite", children: [
|
|
379
|
+
comments === null && !error && /* @__PURE__ */ jsx(Skeleton, { rows: 2 }),
|
|
380
|
+
comments?.length === 0 && /* @__PURE__ */ jsx("p", { className: "ckw-sub", children: "No comments yet." }),
|
|
381
|
+
comments?.map((c) => /* @__PURE__ */ jsxs("div", { className: "ckw-comment", children: [
|
|
382
|
+
/* @__PURE__ */ jsx(Avatar, { name: c.author, team: c.isTeam }),
|
|
383
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-main", children: [
|
|
384
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
385
|
+
/* @__PURE__ */ jsx("b", { children: c.author }),
|
|
386
|
+
c.isTeam && /* @__PURE__ */ jsx("span", { className: "ckw-team", children: "Team" }),
|
|
387
|
+
/* @__PURE__ */ jsx("span", { className: "ckw-time", children: timeAgo(c.postedAt) })
|
|
388
|
+
] }),
|
|
389
|
+
/* @__PURE__ */ jsx("p", { children: c.body })
|
|
390
|
+
] })
|
|
391
|
+
] }, c.id))
|
|
392
|
+
] })
|
|
393
|
+
] }),
|
|
394
|
+
/* @__PURE__ */ jsxs("aside", { className: "ckw-side", "aria-label": "About this request", children: [
|
|
395
|
+
/* @__PURE__ */ jsxs(
|
|
396
|
+
"button",
|
|
397
|
+
{
|
|
398
|
+
type: "button",
|
|
399
|
+
className: "ckw-upvote",
|
|
400
|
+
"aria-pressed": post.voted,
|
|
401
|
+
"aria-label": `${post.voted ? "Remove your vote" : "Upvote"}. ${post.votes} votes`,
|
|
402
|
+
onClick: () => onVote(post),
|
|
403
|
+
children: [
|
|
404
|
+
/* @__PURE__ */ jsx(ChevronUp, {}),
|
|
405
|
+
/* @__PURE__ */ jsx("span", { children: post.voted ? "Upvoted" : "Upvote" }),
|
|
406
|
+
/* @__PURE__ */ jsx("b", { children: post.votes })
|
|
407
|
+
]
|
|
408
|
+
}
|
|
409
|
+
),
|
|
410
|
+
/* @__PURE__ */ jsxs("dl", { className: "ckw-facts", children: [
|
|
411
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
412
|
+
/* @__PURE__ */ jsx("dt", { children: "Status" }),
|
|
413
|
+
/* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx(StatusPill, { status: post.status }) })
|
|
414
|
+
] }),
|
|
415
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
416
|
+
/* @__PURE__ */ jsx("dt", { children: "Type" }),
|
|
417
|
+
/* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx(TypeChip, { board: post.board, boards }) })
|
|
418
|
+
] }),
|
|
419
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
420
|
+
/* @__PURE__ */ jsx("dt", { children: "Posted" }),
|
|
421
|
+
/* @__PURE__ */ jsx("dd", { children: new Date(post.createdAt).toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" }) })
|
|
422
|
+
] })
|
|
180
423
|
] })
|
|
181
424
|
] })
|
|
182
|
-
] }),
|
|
183
|
-
post.body && /* @__PURE__ */ jsx("p", { className: "ckw-body", children: post.body }),
|
|
184
|
-
/* @__PURE__ */ jsxs("h3", { className: "ckw-h", children: [
|
|
185
|
-
"Comments (",
|
|
186
|
-
Math.max(post.comments + added, comments?.length ?? 0),
|
|
187
|
-
")"
|
|
188
|
-
] }),
|
|
189
|
-
error && /* @__PURE__ */ jsx(ErrorBar, { message: error, onClose: () => setError("") }),
|
|
190
|
-
/* @__PURE__ */ jsxs("div", { "aria-live": "polite", children: [
|
|
191
|
-
comments === null && !error && /* @__PURE__ */ jsx(Skeleton, {}),
|
|
192
|
-
comments?.length === 0 && /* @__PURE__ */ jsx("p", { className: "ckw-sub", children: "No comments yet. Be the first." }),
|
|
193
|
-
comments?.map((c) => /* @__PURE__ */ jsxs("div", { className: "ckw-comment", children: [
|
|
194
|
-
/* @__PURE__ */ jsx("b", { children: c.author }),
|
|
195
|
-
c.isTeam && /* @__PURE__ */ jsx("span", { className: "ckw-team", children: "Team" }),
|
|
196
|
-
/* @__PURE__ */ jsx("span", { className: "ckw-time", children: timeAgo(c.postedAt) }),
|
|
197
|
-
/* @__PURE__ */ jsx("p", { children: c.body })
|
|
198
|
-
] }, c.id))
|
|
199
|
-
] }),
|
|
200
|
-
/* @__PURE__ */ jsxs("form", { className: "ckw-form", onSubmit: send, style: { marginTop: 12 }, children: [
|
|
201
|
-
/* @__PURE__ */ jsx("label", { className: "ckw-label", htmlFor: id, children: "Add a comment" }),
|
|
202
|
-
/* @__PURE__ */ jsx("textarea", { id, className: "ckw-textarea", value: text, maxLength: 2e3, onChange: (e) => setText(e.target.value) }),
|
|
203
|
-
/* @__PURE__ */ jsx("div", { className: "ckw-actions", children: /* @__PURE__ */ jsx("button", { type: "submit", className: "ckw-btn ckw-btn-primary", disabled: busy || !text.trim(), children: "Comment" }) })
|
|
204
425
|
] })
|
|
205
426
|
] });
|
|
206
427
|
};
|
|
207
|
-
var
|
|
208
|
-
|
|
428
|
+
var COLUMNS = [
|
|
429
|
+
{ status: "review", label: "Backlog", note: "Under consideration" },
|
|
430
|
+
{ status: "planned", label: "Next up", note: "Committed and queued" },
|
|
431
|
+
{ status: "progress", label: "In progress", note: "Actively being built" },
|
|
432
|
+
{ status: "shipped", label: "Done", note: "Recently shipped" }
|
|
433
|
+
];
|
|
434
|
+
var matchesQ = (q, ...texts) => {
|
|
435
|
+
const t = q.trim().toLowerCase();
|
|
436
|
+
return !t || texts.some((x) => x.toLowerCase().includes(t));
|
|
437
|
+
};
|
|
438
|
+
var RoadmapCard = ({ post, boards, onOpen, onVote }) => /* @__PURE__ */ jsxs("li", { className: "ckw-card", children: [
|
|
439
|
+
/* @__PURE__ */ jsx(TypeChip, { board: post.board, boards }),
|
|
440
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "ckw-link ckw-stretch", onClick: () => onOpen(post), children: post.title }),
|
|
441
|
+
post.body && /* @__PURE__ */ jsx("p", { className: "ckw-excerpt", children: post.body }),
|
|
442
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-card-foot", children: [
|
|
443
|
+
/* @__PURE__ */ jsxs("span", { className: "ckw-who", children: [
|
|
444
|
+
/* @__PURE__ */ jsx(Avatar, { name: post.author ?? "?", team: post.author === "Team" }),
|
|
445
|
+
/* @__PURE__ */ jsx("span", { children: post.author ?? "" })
|
|
446
|
+
] }),
|
|
447
|
+
/* @__PURE__ */ jsx(VoteButton, { post, onVote, small: true })
|
|
448
|
+
] })
|
|
449
|
+
] });
|
|
450
|
+
var Roadmap = ({
|
|
451
|
+
api,
|
|
452
|
+
boards,
|
|
453
|
+
q,
|
|
454
|
+
onOpen,
|
|
455
|
+
voteRef
|
|
456
|
+
}) => {
|
|
209
457
|
const [data, setData] = useState(null);
|
|
210
458
|
const [error, setError] = useState("");
|
|
211
459
|
const [tick, setTick] = useState(0);
|
|
@@ -214,39 +462,34 @@ var Roadmap = ({ onOpen }) => {
|
|
|
214
462
|
api.roadmap(ctl.signal).then((r) => (setData(r), setError(""))).catch((e) => e.name !== "AbortError" && setError(e.message));
|
|
215
463
|
return () => ctl.abort();
|
|
216
464
|
}, [api, tick]);
|
|
465
|
+
const patch = (id, fn) => setData((d) => {
|
|
466
|
+
if (!d) return d;
|
|
467
|
+
const columns = { ...d.columns };
|
|
468
|
+
for (const k of Object.keys(columns)) columns[k] = columns[k]?.map((p) => p.id === id ? fn(p) : p);
|
|
469
|
+
return { columns };
|
|
470
|
+
});
|
|
471
|
+
const vote = (post) => voteRef(post, (r) => {
|
|
472
|
+
if (r) patch(post.id, (p) => ({ ...p, ...r }));
|
|
473
|
+
});
|
|
217
474
|
if (error) return /* @__PURE__ */ jsx(ErrorBar, { message: error, onRetry: () => setTick((t) => t + 1) });
|
|
218
|
-
if (!data)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
[
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
/* @__PURE__ */ jsx("span", { children: data.columns[k].length })
|
|
229
|
-
] }),
|
|
230
|
-
data.columns[k].length === 0 && /* @__PURE__ */ jsx("p", { className: "ckw-sub", children: "Nothing here yet." }),
|
|
231
|
-
data.columns[k].map((p) => /* @__PURE__ */ jsxs("div", { className: "ckw-card", children: [
|
|
232
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "ckw-link", onClick: () => onOpen(p), children: p.title }),
|
|
233
|
-
/* @__PURE__ */ jsxs("div", { className: "ckw-meta", style: { marginTop: 0 }, children: [
|
|
234
|
-
/* @__PURE__ */ jsxs("span", { className: "ckw-stat", children: [
|
|
235
|
-
/* @__PURE__ */ jsx(ChevronUp, {}),
|
|
236
|
-
" ",
|
|
237
|
-
p.votes
|
|
475
|
+
if (!data)
|
|
476
|
+
return /* @__PURE__ */ jsx("div", { className: "ckw-cols", "aria-hidden": "true", children: COLUMNS.map((c) => /* @__PURE__ */ jsx("div", { className: "ckw-col", children: /* @__PURE__ */ jsx(Skeleton, { rows: 2 }) }, c.status)) });
|
|
477
|
+
return /* @__PURE__ */ jsx("div", { className: "ckw-cols", children: COLUMNS.map((c) => {
|
|
478
|
+
const cards = (data.columns[c.status] ?? []).filter((p) => matchesQ(q, p.title, p.body));
|
|
479
|
+
return /* @__PURE__ */ jsxs("section", { className: "ckw-col", "aria-label": c.label, children: [
|
|
480
|
+
/* @__PURE__ */ jsxs("header", { className: "ckw-col-head", children: [
|
|
481
|
+
/* @__PURE__ */ jsxs("h3", { children: [
|
|
482
|
+
/* @__PURE__ */ jsx("span", { className: "ckw-sdot", "data-s": c.status }),
|
|
483
|
+
c.label,
|
|
484
|
+
/* @__PURE__ */ jsx("span", { className: "ckw-count", children: cards.length })
|
|
238
485
|
] }),
|
|
239
|
-
/* @__PURE__ */
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
] })
|
|
245
|
-
] }, p.id))
|
|
246
|
-
] }, k)) });
|
|
486
|
+
/* @__PURE__ */ jsx("p", { children: c.note })
|
|
487
|
+
] }),
|
|
488
|
+
cards.length === 0 ? /* @__PURE__ */ jsx("p", { className: "ckw-col-empty", children: q ? "No match" : "Nothing here yet" }) : /* @__PURE__ */ jsx("ul", { className: "ckw-col-list", children: cards.map((p) => /* @__PURE__ */ jsx(RoadmapCard, { post: p, boards, onOpen, onVote: vote }, p.id)) })
|
|
489
|
+
] }, c.status);
|
|
490
|
+
}) });
|
|
247
491
|
};
|
|
248
|
-
var Changelog = () => {
|
|
249
|
-
const api = useApi();
|
|
492
|
+
var Changelog = ({ api, q }) => {
|
|
250
493
|
const [entries, setEntries] = useState(null);
|
|
251
494
|
const [error, setError] = useState("");
|
|
252
495
|
const [tick, setTick] = useState(0);
|
|
@@ -257,99 +500,293 @@ var Changelog = () => {
|
|
|
257
500
|
}, [api, tick]);
|
|
258
501
|
if (error) return /* @__PURE__ */ jsx(ErrorBar, { message: error, onRetry: () => setTick((t) => t + 1) });
|
|
259
502
|
if (!entries) return /* @__PURE__ */ jsx(Skeleton, {});
|
|
260
|
-
|
|
261
|
-
return /* @__PURE__ */ jsx("div", { children:
|
|
503
|
+
const shown = entries.filter((e) => matchesQ(q, e.title, e.body));
|
|
504
|
+
if (shown.length === 0) return /* @__PURE__ */ jsx("div", { className: "ckw-empty", children: q ? "No update matches your search." : "No updates published yet." });
|
|
505
|
+
return /* @__PURE__ */ jsx("div", { className: "ckw-log", children: shown.map((e) => /* @__PURE__ */ jsxs("article", { className: "ckw-entry", children: [
|
|
262
506
|
/* @__PURE__ */ jsx("time", { dateTime: e.publishedAt, children: new Date(e.publishedAt).toLocaleDateString(void 0, { month: "long", day: "numeric", year: "numeric" }) }),
|
|
263
|
-
/* @__PURE__ */
|
|
264
|
-
|
|
507
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
508
|
+
/* @__PURE__ */ jsx("h3", { children: e.title }),
|
|
509
|
+
/* @__PURE__ */ jsx("p", { children: e.body })
|
|
510
|
+
] })
|
|
265
511
|
] }, e.id)) });
|
|
266
512
|
};
|
|
267
|
-
var
|
|
268
|
-
|
|
513
|
+
var TABS = [
|
|
514
|
+
["requests", "Feedback"],
|
|
515
|
+
["roadmap", "Roadmap"],
|
|
516
|
+
["changelog", "Changelog"]
|
|
517
|
+
];
|
|
518
|
+
var readUrl = () => {
|
|
519
|
+
const p = new URLSearchParams(window.location.search);
|
|
520
|
+
const v = p.get("view");
|
|
521
|
+
return { tab: v === "roadmap" || v === "changelog" ? v : "requests", post: p.get("post") };
|
|
522
|
+
};
|
|
523
|
+
var writeUrl = (tab, post, push) => {
|
|
524
|
+
const url = new URL(window.location.href);
|
|
525
|
+
if (tab === "requests") url.searchParams.delete("view");
|
|
526
|
+
else url.searchParams.set("view", tab);
|
|
527
|
+
if (post) url.searchParams.set("post", post);
|
|
528
|
+
else url.searchParams.delete("post");
|
|
529
|
+
if (url.href === window.location.href) return;
|
|
530
|
+
if (push) window.history.pushState(null, "", url);
|
|
531
|
+
else window.history.replaceState(null, "", url);
|
|
532
|
+
};
|
|
533
|
+
var THEME_KEY = "ckw-theme";
|
|
534
|
+
var systemDark = () => typeof window !== "undefined" && !!window.matchMedia?.("(prefers-color-scheme: dark)").matches;
|
|
535
|
+
var FeedbackBoard = ({
|
|
536
|
+
title = "Feedback",
|
|
537
|
+
subtitle = "Tell us what to build next and vote on what matters to you.",
|
|
538
|
+
theme,
|
|
539
|
+
accent,
|
|
540
|
+
header = true,
|
|
541
|
+
syncUrl = false,
|
|
542
|
+
fullPage = false,
|
|
543
|
+
initialTab = "requests"
|
|
544
|
+
}) => {
|
|
545
|
+
const { host } = useCtx();
|
|
546
|
+
const identity = useIdentity();
|
|
547
|
+
const [tab, setTab] = useState(initialTab);
|
|
269
548
|
const [sort, setSort] = useState("top");
|
|
270
549
|
const [board, setBoard] = useState();
|
|
271
550
|
const [q, setQ] = useState("");
|
|
551
|
+
const [searching, setSearching] = useState(false);
|
|
272
552
|
const [creating, setCreating] = useState(false);
|
|
273
553
|
const [opened, setOpened] = useState(null);
|
|
274
|
-
const
|
|
554
|
+
const [openId, setOpenId] = useState(null);
|
|
555
|
+
const [mode, setMode] = useState(theme ?? "auto");
|
|
556
|
+
const [thanks, setThanks] = useState(false);
|
|
557
|
+
const list = useFeedbackList(identity.api, { board, sort, q: tab === "requests" ? q : "" });
|
|
275
558
|
const { posts, setPosts, vote } = list;
|
|
559
|
+
const searchRef = useRef(null);
|
|
560
|
+
useEffect(() => {
|
|
561
|
+
if (!header) return;
|
|
562
|
+
try {
|
|
563
|
+
const t = window.localStorage.getItem(THEME_KEY);
|
|
564
|
+
if (t === "light" || t === "dark") setMode(t);
|
|
565
|
+
} catch {
|
|
566
|
+
}
|
|
567
|
+
}, [header]);
|
|
568
|
+
const dark = mode === "dark" || mode === "auto" && systemDark();
|
|
569
|
+
const flipTheme = () => {
|
|
570
|
+
const next = dark ? "light" : "dark";
|
|
571
|
+
setMode(next);
|
|
572
|
+
try {
|
|
573
|
+
window.localStorage.setItem(THEME_KEY, next);
|
|
574
|
+
} catch {
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
useEffect(() => {
|
|
578
|
+
if (!syncUrl) return;
|
|
579
|
+
const sync = () => {
|
|
580
|
+
const u = readUrl();
|
|
581
|
+
setTab(u.tab);
|
|
582
|
+
setOpenId(u.post);
|
|
583
|
+
if (!u.post) setOpened(null);
|
|
584
|
+
};
|
|
585
|
+
sync();
|
|
586
|
+
window.addEventListener("popstate", sync);
|
|
587
|
+
return () => window.removeEventListener("popstate", sync);
|
|
588
|
+
}, [syncUrl]);
|
|
589
|
+
const go = (next, post = null) => {
|
|
590
|
+
setTab(next);
|
|
591
|
+
setOpened(post);
|
|
592
|
+
setOpenId(post?.id ?? null);
|
|
593
|
+
if (syncUrl) writeUrl(next, post?.id ?? null, true);
|
|
594
|
+
};
|
|
595
|
+
useEffect(() => {
|
|
596
|
+
if (!openId || opened?.id === openId) return;
|
|
597
|
+
const inList = posts.find((p) => p.id === openId);
|
|
598
|
+
if (inList) return setOpened(inList);
|
|
599
|
+
if (list.loading) return;
|
|
600
|
+
const ctl = new AbortController();
|
|
601
|
+
identity.api.post(openId, ctl.signal).then(setOpened).catch((e) => {
|
|
602
|
+
if (e.name === "AbortError") return;
|
|
603
|
+
setOpenId(null);
|
|
604
|
+
if (syncUrl) writeUrl(tab, null, false);
|
|
605
|
+
});
|
|
606
|
+
return () => ctl.abort();
|
|
607
|
+
}, [openId, posts, list.loading]);
|
|
276
608
|
const current = opened && (posts.find((p) => p.id === opened.id) ?? opened);
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
list.setError(`Your vote was not saved. ${e.message}`);
|
|
283
|
-
});
|
|
609
|
+
const voteAny = (p, done) => identity.need((as) => {
|
|
610
|
+
const flip = (o) => o && o.id === p.id ? { ...o, voted: !p.voted, votes: p.votes + (p.voted ? -1 : 1) } : o;
|
|
611
|
+
const inList = posts.some((x) => x.id === p.id);
|
|
612
|
+
if (inList && !done) {
|
|
613
|
+
vote(p, as);
|
|
284
614
|
return;
|
|
285
615
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
616
|
+
setOpened(flip);
|
|
617
|
+
done?.({ voted: !p.voted, votes: p.votes + (p.voted ? -1 : 1) });
|
|
618
|
+
as.vote(p.id).then((r) => {
|
|
619
|
+
setOpened((o) => o && o.id === p.id ? { ...o, ...r } : o);
|
|
620
|
+
if (inList) list.patch(p.id, (x) => ({ ...x, ...r }));
|
|
621
|
+
done?.(r);
|
|
622
|
+
}).catch((e) => {
|
|
623
|
+
setOpened((o) => o && o.id === p.id ? { ...o, voted: p.voted, votes: p.votes } : o);
|
|
624
|
+
done?.({ voted: p.voted, votes: p.votes });
|
|
625
|
+
list.setError(`Your vote was not saved. ${e.message}`);
|
|
626
|
+
});
|
|
627
|
+
});
|
|
293
628
|
const onTabKey = (e) => {
|
|
294
|
-
const i =
|
|
629
|
+
const i = TABS.findIndex(([k]) => k === tab);
|
|
295
630
|
const n = e.key === "ArrowRight" ? i + 1 : e.key === "ArrowLeft" ? i - 1 : null;
|
|
296
631
|
if (n === null) return;
|
|
297
632
|
e.preventDefault();
|
|
298
|
-
|
|
299
|
-
setOpened(null);
|
|
633
|
+
go(TABS[(n + TABS.length) % TABS.length][0]);
|
|
300
634
|
};
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
635
|
+
const product = list.product;
|
|
636
|
+
const abs = (u) => u ? u.startsWith("/") ? `${host}${u}` : u : null;
|
|
637
|
+
const marks = [abs(product?.logo), abs(product?.logoFallback)].filter((u, i, a) => !!u && a.indexOf(u) === i);
|
|
638
|
+
const [failed, setFailed] = useState(0);
|
|
639
|
+
const logo = marks[failed] ?? null;
|
|
640
|
+
const name = product?.name ?? title;
|
|
641
|
+
const newPost = () => (setThanks(false), setCreating(true));
|
|
642
|
+
const searchLabel = tab === "roadmap" ? "Search roadmap" : tab === "changelog" ? "Search updates" : "Search requests";
|
|
643
|
+
return /* @__PURE__ */ jsxs(Root, { theme: header ? dark ? "dark" : "light" : theme, accent, className: `ckw-board${fullPage ? " ckw-full" : ""}`, children: [
|
|
644
|
+
header ? /* @__PURE__ */ jsx("header", { className: "ckw-top", children: /* @__PURE__ */ jsxs("div", { className: "ckw-top-row", children: [
|
|
645
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "ckw-brand", onClick: () => go("requests"), children: [
|
|
646
|
+
logo ? (
|
|
647
|
+
// eslint-disable-next-line @next/next/no-img-element
|
|
648
|
+
/* @__PURE__ */ jsx("img", { src: logo, alt: "", width: 28, height: 28, onError: () => setFailed((n) => n + 1) }, logo)
|
|
649
|
+
) : /* @__PURE__ */ jsx("span", { className: "ckw-brand-mark", "aria-hidden": "true", children: name.slice(0, 1).toUpperCase() }),
|
|
650
|
+
/* @__PURE__ */ jsx("span", { children: name })
|
|
306
651
|
] }),
|
|
307
|
-
/* @__PURE__ */
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
children:
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
posts,
|
|
335
|
-
onVote: vote,
|
|
336
|
-
onCancel: () => setCreating(false),
|
|
337
|
-
onCreated: (p) => {
|
|
338
|
-
setPosts((all) => [p, ...all]);
|
|
339
|
-
setCreating(false);
|
|
652
|
+
/* @__PURE__ */ jsx("nav", { className: "ckw-nav", role: "tablist", "aria-label": "Board sections", onKeyDown: onTabKey, children: TABS.map(([k, label]) => /* @__PURE__ */ jsx(
|
|
653
|
+
"button",
|
|
654
|
+
{
|
|
655
|
+
type: "button",
|
|
656
|
+
role: "tab",
|
|
657
|
+
id: `ckw-tab-${k}`,
|
|
658
|
+
"aria-selected": tab === k && !current,
|
|
659
|
+
tabIndex: tab === k ? 0 : -1,
|
|
660
|
+
className: "ckw-nav-tab",
|
|
661
|
+
onClick: () => go(k),
|
|
662
|
+
children: label
|
|
663
|
+
},
|
|
664
|
+
k
|
|
665
|
+
)) }),
|
|
666
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-top-tools", children: [
|
|
667
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-searchbox", "data-open": searching || !!q || void 0, children: [
|
|
668
|
+
/* @__PURE__ */ jsx(
|
|
669
|
+
"button",
|
|
670
|
+
{
|
|
671
|
+
type: "button",
|
|
672
|
+
className: "ckw-icon-btn",
|
|
673
|
+
"aria-label": searchLabel,
|
|
674
|
+
onClick: () => {
|
|
675
|
+
setSearching(true);
|
|
676
|
+
window.setTimeout(() => searchRef.current?.focus(), 0);
|
|
677
|
+
},
|
|
678
|
+
children: /* @__PURE__ */ jsx(Search, {})
|
|
340
679
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
680
|
+
),
|
|
681
|
+
/* @__PURE__ */ jsx(
|
|
682
|
+
"input",
|
|
683
|
+
{
|
|
684
|
+
ref: searchRef,
|
|
685
|
+
type: "search",
|
|
686
|
+
className: "ckw-search-input",
|
|
687
|
+
"aria-label": searchLabel,
|
|
688
|
+
placeholder: "Search\u2026",
|
|
689
|
+
value: q,
|
|
690
|
+
onChange: (e) => {
|
|
691
|
+
setQ(e.target.value);
|
|
692
|
+
if (current) go(tab);
|
|
693
|
+
},
|
|
694
|
+
onBlur: () => setSearching(false),
|
|
695
|
+
onKeyDown: (e) => e.key === "Escape" && (setQ(""), e.target.blur())
|
|
696
|
+
}
|
|
697
|
+
)
|
|
346
698
|
] }),
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
699
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "ckw-icon-btn", onClick: flipTheme, "aria-label": dark ? "Switch to light mode" : "Switch to dark mode", children: dark ? /* @__PURE__ */ jsx(Sun, {}) : /* @__PURE__ */ jsx(Moon, {}) }),
|
|
700
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "ckw-btn ckw-btn-primary ckw-submit", "aria-label": "Submit feedback", onClick: newPost, children: [
|
|
701
|
+
/* @__PURE__ */ jsx(Plus, {}),
|
|
702
|
+
" ",
|
|
703
|
+
/* @__PURE__ */ jsx("span", { children: "Submit feedback" })
|
|
704
|
+
] })
|
|
705
|
+
] })
|
|
706
|
+
] }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
707
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-head", children: [
|
|
708
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
709
|
+
/* @__PURE__ */ jsx("h2", { className: "ckw-title", children: title }),
|
|
710
|
+
subtitle && /* @__PURE__ */ jsx("p", { className: "ckw-sub", children: subtitle })
|
|
350
711
|
] }),
|
|
351
|
-
/* @__PURE__ */
|
|
352
|
-
|
|
712
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "ckw-btn ckw-btn-primary", onClick: newPost, children: [
|
|
713
|
+
/* @__PURE__ */ jsx(Plus, {}),
|
|
714
|
+
" Request a feature"
|
|
715
|
+
] })
|
|
716
|
+
] }),
|
|
717
|
+
/* @__PURE__ */ jsx("div", { className: "ckw-tabs", role: "tablist", "aria-label": "Feedback sections", onKeyDown: onTabKey, children: TABS.map(([k, label]) => /* @__PURE__ */ jsx("button", { type: "button", role: "tab", id: `ckw-tab-${k}`, "aria-selected": tab === k, tabIndex: tab === k ? 0 : -1, className: "ckw-tab", onClick: () => go(k), children: k === "requests" ? "Requests" : label }, k)) }),
|
|
718
|
+
/* @__PURE__ */ jsx(
|
|
719
|
+
"input",
|
|
720
|
+
{
|
|
721
|
+
className: "ckw-input ckw-search",
|
|
722
|
+
type: "search",
|
|
723
|
+
"aria-label": searchLabel,
|
|
724
|
+
placeholder: searchLabel,
|
|
725
|
+
value: q,
|
|
726
|
+
onChange: (e) => setQ(e.target.value),
|
|
727
|
+
style: { marginBottom: 12 }
|
|
728
|
+
}
|
|
729
|
+
)
|
|
730
|
+
] }),
|
|
731
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-body-wrap", role: "tabpanel", "aria-labelledby": `ckw-tab-${tab}`, children: [
|
|
732
|
+
header && !current && /* @__PURE__ */ jsxs("div", { className: "ckw-intro", children: [
|
|
733
|
+
/* @__PURE__ */ jsx("h1", { children: tab === "roadmap" ? "Roadmap" : tab === "changelog" ? "Changelog" : "Feedback" }),
|
|
734
|
+
/* @__PURE__ */ jsx("p", { children: tab === "roadmap" ? "What we are considering, building next and shipped." : tab === "changelog" ? "New and improved, newest first." : subtitle })
|
|
735
|
+
] }),
|
|
736
|
+
thanks && !current && /* @__PURE__ */ jsxs("div", { className: "ckw-note", role: "status", children: [
|
|
737
|
+
"Thanks, your request is in. You can follow it here.",
|
|
738
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "ckw-icon-btn", "aria-label": "Dismiss", onClick: () => setThanks(false), children: /* @__PURE__ */ jsx(Cross, {}) })
|
|
739
|
+
] }),
|
|
740
|
+
list.error && /* @__PURE__ */ jsx(ErrorBar, { message: list.error, onRetry: tab === "requests" && !current ? list.reload : void 0, onClose: () => list.setError("") }),
|
|
741
|
+
current ? /* @__PURE__ */ jsx(
|
|
742
|
+
PostDetail,
|
|
743
|
+
{
|
|
744
|
+
post: current,
|
|
745
|
+
boards: list.boards,
|
|
746
|
+
identity,
|
|
747
|
+
backLabel: tab === "roadmap" ? "Roadmap" : "All requests",
|
|
748
|
+
onBack: () => go(tab),
|
|
749
|
+
onVote: (p) => voteAny(p)
|
|
750
|
+
}
|
|
751
|
+
) : tab === "requests" ? /* @__PURE__ */ jsx(
|
|
752
|
+
Requests,
|
|
753
|
+
{
|
|
754
|
+
list,
|
|
755
|
+
sort,
|
|
756
|
+
setSort,
|
|
757
|
+
board,
|
|
758
|
+
setBoard,
|
|
759
|
+
q,
|
|
760
|
+
onOpen: (p) => go("requests", p),
|
|
761
|
+
onVote: (p) => voteAny(p),
|
|
762
|
+
onNew: newPost
|
|
763
|
+
}
|
|
764
|
+
) : tab === "roadmap" ? /* @__PURE__ */ jsx(Roadmap, { api: identity.api, boards: list.boards, q, onOpen: (p) => go("roadmap", p), voteRef: (p, done) => voteAny(p, done) }) : /* @__PURE__ */ jsx(Changelog, { api: identity.api, q })
|
|
765
|
+
] }),
|
|
766
|
+
creating && /* @__PURE__ */ jsx(Modal, { title: "Submit feedback", onClose: () => setCreating(false), children: /* @__PURE__ */ jsx(
|
|
767
|
+
SubmitForm,
|
|
768
|
+
{
|
|
769
|
+
bare: true,
|
|
770
|
+
identity,
|
|
771
|
+
boards: list.boards,
|
|
772
|
+
posts,
|
|
773
|
+
onVote: (p) => voteAny(p),
|
|
774
|
+
onCancel: () => setCreating(false),
|
|
775
|
+
onCreated: (p) => {
|
|
776
|
+
setPosts((all) => [p, ...all.filter((x) => x.id !== p.id)]);
|
|
777
|
+
setCreating(false);
|
|
778
|
+
setThanks(true);
|
|
779
|
+
go("requests");
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
) }),
|
|
783
|
+
/* @__PURE__ */ jsx(IdentityDialog, { identity }),
|
|
784
|
+
identity.known && !identity.fromApp && header && /* @__PURE__ */ jsxs("p", { className: "ckw-foot", children: [
|
|
785
|
+
"Posting as ",
|
|
786
|
+
identity.name,
|
|
787
|
+
".",
|
|
788
|
+
" ",
|
|
789
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "ckw-linkish", onClick: identity.forget, children: "Not you?" })
|
|
353
790
|
] })
|
|
354
791
|
] });
|
|
355
792
|
};
|
|
@@ -361,10 +798,12 @@ var setWidgetOpen = (v) => {
|
|
|
361
798
|
};
|
|
362
799
|
var useFeedback = () => ({ open: () => setWidgetOpen(true), close: () => setWidgetOpen(false) });
|
|
363
800
|
var WidgetPanel = ({ boardUrl, onClose }) => {
|
|
801
|
+
const identity = useIdentity();
|
|
364
802
|
const [suggesting, setSuggesting] = useState(false);
|
|
365
803
|
const [thanks, setThanks] = useState(false);
|
|
366
|
-
const list = useFeedbackList({ sort: "top" });
|
|
804
|
+
const list = useFeedbackList(identity.api, { sort: "top" });
|
|
367
805
|
const { posts, setPosts } = list;
|
|
806
|
+
const vote = (p) => identity.need((as) => list.vote(p, as));
|
|
368
807
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
369
808
|
/* @__PURE__ */ jsxs("div", { className: "ckw-pop-head", children: [
|
|
370
809
|
/* @__PURE__ */ jsx("span", { children: suggesting ? "Suggest something" : "Top requests" }),
|
|
@@ -372,14 +811,14 @@ var WidgetPanel = ({ boardUrl, onClose }) => {
|
|
|
372
811
|
] }),
|
|
373
812
|
/* @__PURE__ */ jsxs("div", { className: "ckw-pop-body", children: [
|
|
374
813
|
list.error && /* @__PURE__ */ jsx(ErrorBar, { message: list.error, onClose: () => list.setError("") }),
|
|
375
|
-
thanks ? /* @__PURE__ */ jsx("div", { className: "ckw-empty", role: "status", children: "Thanks, your request is in." }) : suggesting ? /* @__PURE__ */ jsx(
|
|
814
|
+
identity.asking ? /* @__PURE__ */ jsx(WidgetIdentity, { identity }) : thanks ? /* @__PURE__ */ jsx("div", { className: "ckw-empty", role: "status", children: "Thanks, your request is in." }) : suggesting ? /* @__PURE__ */ jsx(
|
|
376
815
|
SubmitForm,
|
|
377
816
|
{
|
|
378
817
|
compact: true,
|
|
379
|
-
|
|
818
|
+
identity,
|
|
380
819
|
boards: list.boards,
|
|
381
820
|
posts,
|
|
382
|
-
onVote:
|
|
821
|
+
onVote: vote,
|
|
383
822
|
onCancel: () => setSuggesting(false),
|
|
384
823
|
onCreated: (p) => {
|
|
385
824
|
setPosts((all) => [p, ...all]);
|
|
@@ -388,7 +827,7 @@ var WidgetPanel = ({ boardUrl, onClose }) => {
|
|
|
388
827
|
}
|
|
389
828
|
}
|
|
390
829
|
) : list.loading && posts.length === 0 ? /* @__PURE__ */ jsx(Skeleton, {}) : posts.length === 0 && !list.error ? /* @__PURE__ */ jsx("div", { className: "ckw-empty", children: "No requests yet. Suggest the first one." }) : /* @__PURE__ */ jsx("ul", { className: "ckw-list", "aria-live": "polite", children: posts.slice(0, 5).map((p) => /* @__PURE__ */ jsxs("li", { className: "ckw-row", children: [
|
|
391
|
-
/* @__PURE__ */ jsx(VoteButton, { post: p, onVote:
|
|
830
|
+
/* @__PURE__ */ jsx(VoteButton, { post: p, onVote: vote }),
|
|
392
831
|
/* @__PURE__ */ jsxs("div", { className: "ckw-main", children: [
|
|
393
832
|
/* @__PURE__ */ jsx("span", { style: { fontWeight: 600, overflowWrap: "anywhere" }, children: p.title }),
|
|
394
833
|
/* @__PURE__ */ jsx("div", { className: "ckw-meta", children: /* @__PURE__ */ jsx(StatusPill, { status: p.status }) })
|
|
@@ -397,7 +836,7 @@ var WidgetPanel = ({ boardUrl, onClose }) => {
|
|
|
397
836
|
] }),
|
|
398
837
|
/* @__PURE__ */ jsxs("div", { className: "ckw-pop-foot", children: [
|
|
399
838
|
boardUrl ? /* @__PURE__ */ jsx("a", { href: boardUrl, children: "See all" }) : /* @__PURE__ */ jsx("span", {}),
|
|
400
|
-
!suggesting && !thanks && /* @__PURE__ */ jsxs("button", { type: "button", className: "ckw-btn ckw-btn-primary", onClick: () => setSuggesting(true), children: [
|
|
839
|
+
!suggesting && !thanks && !identity.asking && /* @__PURE__ */ jsxs("button", { type: "button", className: "ckw-btn ckw-btn-primary", onClick: () => setSuggesting(true), children: [
|
|
401
840
|
/* @__PURE__ */ jsx(Plus, {}),
|
|
402
841
|
" Suggest something"
|
|
403
842
|
] }),
|
|
@@ -405,6 +844,32 @@ var WidgetPanel = ({ boardUrl, onClose }) => {
|
|
|
405
844
|
] })
|
|
406
845
|
] });
|
|
407
846
|
};
|
|
847
|
+
var WidgetIdentity = ({ identity }) => {
|
|
848
|
+
const [name, setName] = useState("");
|
|
849
|
+
const [email, setEmail] = useState("");
|
|
850
|
+
const ok = name.trim().length > 0 && EMAIL.test(email.trim());
|
|
851
|
+
return /* @__PURE__ */ jsxs(
|
|
852
|
+
"form",
|
|
853
|
+
{
|
|
854
|
+
className: "ckw-form",
|
|
855
|
+
onSubmit: (e) => {
|
|
856
|
+
e.preventDefault();
|
|
857
|
+
const run = identity.asking;
|
|
858
|
+
if (!ok || !run) return;
|
|
859
|
+
const api = identity.save(name, email);
|
|
860
|
+
identity.cancel();
|
|
861
|
+
run(api);
|
|
862
|
+
},
|
|
863
|
+
children: [
|
|
864
|
+
/* @__PURE__ */ jsx(IdentityFields, { name, email, setName, setEmail }),
|
|
865
|
+
/* @__PURE__ */ jsxs("div", { className: "ckw-actions", children: [
|
|
866
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "ckw-btn ckw-btn-ghost", onClick: identity.cancel, children: "Cancel" }),
|
|
867
|
+
/* @__PURE__ */ jsx("button", { type: "submit", className: "ckw-btn ckw-btn-primary", disabled: !ok, children: "Continue" })
|
|
868
|
+
] })
|
|
869
|
+
]
|
|
870
|
+
}
|
|
871
|
+
);
|
|
872
|
+
};
|
|
408
873
|
var FeedbackWidget = ({ position = "bottom-right", label = "Feedback", boardUrl, theme, accent }) => {
|
|
409
874
|
const [open, setOpen] = useState(false);
|
|
410
875
|
const fab = useRef(null);
|